Search code examples
graphvizoverlapdirected-graphedges

Overlapping edges in graphviz


I've two overlapping edges and don't know why:

digraph G {
    graph [rankdir=LR, overlap=false];
    subgraph cluster1 {
       d1;
       n1;
    }
    subgraph cluster2 {
       n2;
       d2;
    }
    n1 -> n2;
    n2 -> n1;
    d0 -> d1;
    d0 -> d2;
}

enter image description here

Is there any way to display both edges n1 -> n2 and n2 -> n1 separately? Removing the clusters is not an option but would help ...


Solution

  • Trial-and-error solution (don't ask me why this works...):

    digraph G {
        graph [rankdir=LR, overlap=false];
        subgraph cluster1 {
           d1;
           n1;
        }
        subgraph cluster2 {
           n2;
           d2;
        }
        n1 -> n2;
        n1 -> n2[constraint=false, dir=back];
        n2 -> n1[style=invis];
        d0 -> d1;
        d0 -> d2;
    }
    

    graphviz output