Connect edges with graph dot

1.3k views Asked by At

I need to add a link between two edges using dot. What I need to add to the graph is the red link labeled "b" between the two edges showed in picture.

The source code is the following:

digraph { 
    a -> b; 
    a -> c; 
} 

enter image description here

1

There are 1 answers

0
gismo141 On

Today I had the same problem and solved it with a small hack:

  1. create small point-shaped nodes for each edge you want to connect
  2. connect the main-nodes via the fake-nodes
  3. connect the fake-nodes
digraph {
    fakeAB [label="", shape=point, width=0.01, height=0.01];
    fakeAC [label="", shape=point, width=0.01, height=0.01];

    {
        rank=same;
            "b"; "c";
    }

    {
        rank=same;
            fakeAB; fakeAC;
    }

    "a" -> fakeAB [arrowhead=none];
    "a" -> fakeAC [arrowhead=none];
    fakeAB -> "b";
    fakeAC -> "c";

    fakeAB -> fakeAC [label="b", color="red", arrowhead=none];
}

The result:

Connected Edges