Search code examples
graphvizdot

Graphviz drawing two arrows intead of one


I have a strange result trying to make a simple graph using graphviz. Two arrows are drawn between 3 and 4 instead of one. I can't figure out why, if it is a bug or if I've done something wrong. Here is a minimal example, anything I remove makes the problem dissapear:

digraph dia {
    newrank=true;

    1 -> 2;

    subgraph cluster_1 {
        label = "1";
        3 -> 5;
        3 -> 6;
        5 -> 6
    }
    subgraph cluster_2 {
        label = "2";
        4;
    }
    3 -> 4;

    {rank="same"; 2; 5; 6;}
    {rank="same"; 3; 4}
}

It produces the following output:

Graphviz output

My actual graph is larger than that, and I need newrank property.

I think I have the lastest version of graphviz...

dot - graphviz version 2.40.1 (20161225.0304)

Thanks for any help !


Solution

  • I also noticed some strange things going on in graphviz when clusters are being used (especially in combination with rank=same. So probably a bug, yes.

    In your situation simply adding a port to one of the problematic nodes fixes the problem:

    3:e -> 4;