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?
相关问题
- how to define constructor for Python's new Nam
- Jackson Deserialization not calling deserialize on
- streaming md5sum of contents of a large remote tar
- How to maintain order of key-value in DataFrame sa
- How to get the background from multiple images by
Here is a JSON approach that I just did, together with code to read the results back in. It saves the node and edge attributes, in case you need that.
Are the nodes and edges enough information? If so, you could write your own function:
Generally I use the following code :
it will create json formatted graph in which the nodes are in
nodes
and edges inlinks
in addition to other information about the graph (directionality, ... etc)This documentation contains a full description
A simple example is this:
You can also take a look at the Javascript/SVG/D3 nice example on adding physics to the graph visualization.
Try this: