Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Positioning Nodes With `{rank=same ...}` Side Effects

Tags:

graphviz

I have a graph defined as such:

digraph G {
    rankdir=LR
    node[shape=circle]
    q_[shape=none label=""]
    q3[shape=doublecircle]
    q4[shape=doublecircle]
    q_->q0
    q0->q1[label="λ"]
    q0->q2->q4[label=a]
    q1->q4->q2[label=b]
    q1->q3[label=a]
    q3->q4[label="λ"]
    {rank=same; q4 q3}
    {rank=same; q1 q2}
}

The graph outputs the following image:

enter image description here

You can play with the graph here: http://graph.gafol.net/derive/effpjWfSD

My question is:

Why is q4 pointing to q3 in the rendered graph and not the way I specified it in the markup? Is it because {rank=same; q4 q3} has more semantic meaning than just positioning nodes? If that is the case, how can I position the nodes so that the output is not as hideous as the output is without using {rank=same; ...}?

like image 607
kzh Avatar asked Mar 08 '11 14:03

kzh


1 Answers

There is no hidden semantic meaning in rank=same, this is simply a bug.

The edge is correctly drawn when for example omitting the label of the edge or rankdir=LR.

You may correct this particular graph by adding the dir attribute to the incorrectly drawn edge:

q3->q4[label="λ", dir=back]

This is of course of no help when dynamically creating graphs.

This bug may be related to one of the other known bugs caused by rankdir=LR, reported on http://www.graphviz.org:8080/bugs/openbugs.html

like image 110
marapet Avatar answered Dec 15 '22 08:12

marapet