Question

I noticed something very strange with a small graph. It only seems to exist in one certain configuration (that I can find) of said graph. Namely: the direction of one of the edges flips depending on the presence of a label. If the label is present, the edge goes the wrong way, if it is absent, the edge points the right way.

Here are the two versions of the graph:

Correct version Incorrect version

As you can see, the arrowhead on the edge titled foobar reverses direction as soon as the label is present. The definition says 4 -> 3, so, as I understand it, the head should be at 3, the tail originating from 4. But the opposite is the case as soon as I add a label. Nothing but the label=foobar attribute was changed in the code.

I must apologize for the size of the graph. I would normally try to find a minimal example, but in this case, changing even the slightest thing about the layout of the nodes changes the outcome, and the edge is displayed correctly regardless of the presence of a label.

The code is here:

digraph G {
    2;
    3;
    6;
    red;
    11;
    4;
    8;
    brown;
    1;
    ne2;
    12;
    two;
    one;
    yellow;
    e2;
    10;
    5;
    green;
    four;
    three;
    7;
    9;
    1 -> 2 [style=bold];
    1 -> 4 [style=bold];
    1 -> 5 [style=bold];
    1 -> 3 [style=bold];
    2 -> ne2 [style=bold];
    2 -> e2 [style=bold];
    4 -> 6 [style=bold];
    4 -> 7 [style=bold];
    6 -> 10 [style=bold];
    6 -> 9 [style=bold];
    6 -> 8 [style=bold];
    7 -> 11 [style=bold];
    7 -> 12 [style=bold];
    5 -> one [style=bold];
    5 -> two [style=bold];
    5 -> three [style=bold];
    5 -> four [style=bold];
    3 -> green [style=bold];
    3 -> red [style=bold];
    3 -> yellow [style=bold];
    3 -> brown [style=bold];
    4 -> 3 [constraint=false
                    ,style=dotted
                    ,label=foobar
                    ,arrowhead=odot];
    ne2 -> 4 [constraint=false
                     ,label=head
                     ,style=dotted
                     ,arrowhead=odot];
    7 -> four [constraint=false
                ,label=baz
                ,style=dotted
                ,arrowhead=odot];
    6 -> two [constraint=false
                ,label=baz
                ,style=dotted
                ,arrowhead=odot];
    4 -> 5 [constraint=false
                     ,label=baz
                     ,style=dotted
                     ,arrowhead=odot];
    ne2 -> 2 [constraint=false
                   ,label=tail
                   ,style=dotted
                   ,arrowhead=odot];
}

My current graphviz version is:

dot - graphviz version 2.26.3 (20100126.1600)

Did I misunderstand something fundamental about the way these graphs are constructed from dot files? It seems unreasonable to me that the arrow head position should be influenced by the presence of a label.

Was it helpful?

Solution

This is indeed a bug. It was fixed in version 2.28, so upgrading should be sufficient.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top