Closed AndiLeni closed 1 year ago
AFAICT you want to replicate something very similar to https://stackoverflow.com/questions/25734244/how-do-i-place-nodes-on-the-same-level-in-dot. Did you check the documentation or the examples (e.g. searching for rank
)?
In [1]: import graphviz
...:
...: g = graphviz.Digraph(name='G')
...:
...: g.attr(rankdir='TB')
...:
...: with g.subgraph() as s:
...: s.attr(rank='min')
...: s.node('A')
...: s.node('X')
...:
...: with g.subgraph() as s:
...: s.attr(rank='max')
...: s.node('B')
...: s.node('D')
...: s.node('Y')
...:
...: g.edge('A', 'B')
...: g.edge('A', 'C')
...: g.edge('C', 'D')
...: g.edge('X', 'Y')
...:
...: print(g)
...: g
digraph G {
rankdir=TB
{
rank=min
A
X
}
{
rank=max
B
D
Y
}
A -> B
A -> C
C -> D
X -> Y
}
Out[1]:
Thanks for the hint. It was an issue with graphviz and not related to this python module.
I used subgraphs with min and max, but those are not exclusive. In the graphviz forum I was told to use source and sink instead, which works fine.
Thanks nonetheless and kind regards
Hello,
I am trying to add a rank to my graph. In detail, I want to add the two following lines to my graph, but I have no idea where such an option should be set.
Thanks and kind regards
Full example: