Method to save networkx graph to json graph?

后端 未结 6 1000
长发绾君心
长发绾君心 2020-12-29 04:38

Seems like there should be a method in networkx to export the json graph format, but I don\'t see it. I imagine this should be easy to do with nx.to_dict_of_dicts(), but wou

6条回答
  •  猫巷女王i
    2020-12-29 04:52

    Try this:

    # Save graph
    nx.write_gml(G, "path_where_graph_should_be_saved.gml")
    
    # Read graph
    G = nx.read_gml('path_to_graph_graph.gml')
    

提交回复
热议问题