Method to save networkx graph to json graph?

This documentation contains a full description

A simple example is this:

import networkx as nx
from networkx.readwrite import json_graph

DG = nx.DiGraph()
DG.add_edge('a', 'b')
print json_graph.dumps(DG)

You can also take a look at the Javascript/SVG/D3 nice example on adding physics to the graph visualization.

Leave a Comment