from graphviz.graph import Graph g = Graph("G", "digraph") n1 = g.add_node("Hello") g2 = g.add_graph("c1") e = g.add_edge("Hello", "World") g2.add_edge("Toto", "Titi") print g.output() g.save("test.png")
from graphviz.graph import Graph g = Graph("G") c0 = g.add_graph( "cluster0" ) c0["label"] = "process #1" c0["style"] = "filled" c0["color"] = "lightgrey" c0.node["style"] = "filled" c0.node["color"] = "white" a0 = c0.add_node( "a0" ) a1 = c0.add_node( "a1" ) a2 = c0.add_node( "a2" ) a3 = c0.add_node( "a3" ) c0.add_edge( a0, a1 ) c0.add_edge( a1, a2 ) c0.add_edge( a2, a3 ) c1 = g.add_graph( "cluster1" ) c1["label"] = "process #2" c1["color"] = "blue" c1.node["style"] = "filled" b0 = c1.add_node( "b0" ) b1 = c1.add_node( "b1" ) b2 = c1.add_node( "b2" ) b3 = c1.add_node( "b3" ) c1.add_edge( b0, b1 ) c1.add_edge( b1, b2 ) c1.add_edge( b2, b3 )