On Fri, Aug 5, 2011 at 10:44, Alin Bastea <alin...@gmail.com> wrote:
>
> Can anyone tell me how do I add in pydot an edge between two
> subgraphs?
This seems to work for me;
--
import pydot
g = pydot.Graph()
s1 = pydot.Cluster('first')
s2 = pydot.Cluster('second')
nodeA = pydot.Node('a')
nodeB = pydot.Node('b')
nodeC = pydot.Node('c')
s1.add_node(nodeA)
s1.add_node(nodeB)
s2.add_node(nodeC)
g.add_subgraph(s1)
g.add_subgraph(s2)
g.add_edge(pydot.Edge(nodeA, nodeB))
g.add_edge(pydot.Edge(nodeB, nodeC))
print(g.to_string())
--
I've previously assumed that edges in the parent graph can refer to
nodes within subgraphs, and DOT seems happy with rendering it, but I'm
not 100% sure it's allowed.
Note that you can create Edge objects based on the nodes name/id as
well, so you could do;
g.add_edge(pydot.Edge('a', 'b'))
g.add_edge(pydot.Edge('b', 'c'))
directly.
Hope that helps,
- Kim