but there are a few nodes I need both to be at the same row level
I know (according to dotguide.pdf pages 17-19) that if I set
{rank = same ; firstnode; secondnode; thirdnode ... }
they wll be horizontally aligned
now, I'm puzzled about how to add that using pygraphviz, and I can't
find anything mentioning "rank" in the reference
could anyone lend a hand?
I'm not sure I completely understand the way the rank=same
situation is handled by graphviz. But I think something like this
will work - here I am using a subgraph to collect a set of
nodes and then assigning graph_attr['rank']='same' on that subgraph
only. I think the correct solution is an "anonymous subgraph"
which is not currently handled by correctly pygraphviz - I'll see if I can
fix that.
e.g the difference between
graph a {
{ rank=same; 4;5,6}
1 -- 2;
1 -- 3;
2 -- 3;
3 -- 4;
3 -- 5;
3 -- 6;
4 -- 6;
}
and
graph a {
subgraph { rank = same;
4; 5; 6;
};
1 -- 2;
1 -- 3;
2 -- 3;
3 -- 4;
3 -- 5;
3 -- 6;
4 -- 6;
}
Aric
-----------------------
from pygraphviz import *
A=AGraph()
A.add_edge(1,2)
A.add_edge(2,3)
A.add_edge(1,3)
A.add_edge(3,4)
A.add_edge(3,5)
A.add_edge(3,6)
A.add_edge(4,6)
B=A.add_subgraph([4,5,6],name='s1')
B.graph_attr['rank']='same'
print A.string() # print to screen
A.layout() # layout with default (neato)
A.draw('simple.png',prog='dot') # draw png