1

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 ...

TylerH
  • 20,799
  • 66
  • 75
  • 101
Steffen
  • 163
  • 1
  • 10

2 Answers2

4

A solution making use of the portPos modifier:

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

Another solution is to make use of the dir and color modifiers:

digraph G {
    graph [rankdir=LR, overlap=false];
    subgraph cluster1 {
       d1;
       n1;
    }
    subgraph cluster2 {
       n2;
       d2;
    }
    n2 -> n1[dir=both color="red:blue"];
    d0 -> d1;
    d0 -> d2;
}

You can even use color="black:black" if you want to maintain the black and white coloring scheme.

  • Thank you very much so far! I need these two edges, but second solution was interesting to know. First solution is limited. Please have a look at: digraph G { graph [rankdir=LR, overlap=false]; subgraph cluster1 { d1; n1; } subgraph cluster3 { d3; n3; } subgraph cluster2 { n2; d2; } n1:se -> n2:ne [color=green]; n2 -> n1 [color=red]; d0 -> d1; d0 -> d2; d0 -> d3 } – Steffen Mar 25 '12 at 17:42
3

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

marapet
  • 54,856
  • 12
  • 170
  • 184