How to plot a network/graph in Python using GraphViz

thanks to Amy Teegarden for figuring out how to do this, and for the example code


In [1]:
import graphviz
import igraph
g = graphviz.Graph()
for x, y in [[0,1],[1,2],[2,4],[2,3],[4,1],[3,0]]:
    g.edge(str(x), str(y))
g.graph_attr['size'] = '10, 5'
g.graph_attr['splines'] = 'line'
g.graph_attr['ratio'] = 'fill'
g


Out[1]:
%3 0 0 1 1 0--1 2 2 1--2 4 4 2--4 3 3 2--3 4--1 3--0

In [ ]: