cdlib.readwrite.write_community_json

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

Generate a JSON representation of the clustering object

Parameters:
  • communities – a cdlib clustering object
  • path – output filename
  • compress – wheter to copress the JSON, default False
Returns:

a JSON formatted string representing the object

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