In [1]:
import networkx as nx
import d3shims # pip install d3shims
nx_force()Provided a NetworkX graph, render it in JS using D3js.
G: a NetworkX graph. 'weight' attributes on the edges causes D3 to draw a heavier line, and adding a 'group' attribute to the nodes will have them appear a different color.
Provided a NetworkX graph (G), render it in JS using D3js.None or 'always'
In [2]:
G = nx.Graph()
G.add_star(range(5))
G.add_cycle(range(4, 10))
d3shims.nx_force(G, size=(200, 200))
Out[2]:
In [3]:
G = nx.read_dot('lesmis.dot')
d3shims.nx_force(G, size=(600, 600), labels='always', linkdistance=100)
Out[3]:
Les Misérables character co-appearence data compiled by Donald Knuth.