cdlib.readwrite.write_community_json

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

生成聚类对象的JSON表示

Parameters:
  • communities – 一个cdlib聚类对象

  • path – 输出文件名

  • compress – 是否压缩JSON,默认为False

Returns:

表示对象的JSON格式字符串

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")