views:

34

answers:

1

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 would require a bit of manipulation. Anyone know of a simple and elegant solution?

A: 

Are the nodes and edges enough information? If so, you could write your own function:

json.dumps(dict(nodes=graph.nodes(), edges=graph.edges()))
Ryan Ginstrom