I\'m trying to produce a flow diagram of a tree structure. I\'ve been able to create representative graphs with networkx, but I need a way to show the
You can use pygraphviz to get close:
>>> import pygraphviz
>>> import networkx
>>> import networkx as nx
>>> G = nx.Graph()
>>> G.add_node("ROOT")
>>> for i in xrange(5):
... G.add_node("Child_%i" % i)
... G.add_node("Grandchild_%i" % i)
... G.add_node("Greatgrandchild_%i" % i)
... G.add_edge("ROOT", "Child_%i" % i)
... G.add_edge("Child_%i" % i, "Grandchild_%i" % i)
... G.add_edge("Grandchild_%i" % i, "Greatgrandchild_%i" % i)
>>> A = nx.to_agraph(G)
>>> A.layout('dot', args='-Nfontsize=10 -Nwidth=".2" -Nheight=".2" -Nmargin=0 -Gfontsize=8')
>>> A.draw('test.png')
Result:
Note I copied the graphviz options from the link you posted above. I'm not sure why the 4th child is drawn on top instead of in strictly vertical format. Maybe someone who knows more about the Graphviz options can help with that.