cdlib.readwrite.read_community_json

cdlib.readwrite.read_community_json(path: str, compress: bool = False) object

从JSON文件中读取社区列表。

Parameters:
  • path – 输入文件名

  • compress – 文件是否为压缩格式,默认为 False

Returns:

一个聚类对象

Example:

>>> import networkx as nx
>>> from cdlib import algorithms, readwrite
>>> g = nx.karate_club_graph()
>>> coms = algorithms.louvain(g)
>>> readwrite.write_community_json(coms, "communities.json")
>>> readwrite.read_community_json(coms, "communities.json")