Search code examples
graphvizedges

GraphViz, grouping multiple edges between the same nodes but with different labels


digraph G {
  a -> b [ label = "foo" ];
  a -> b [ label = "bar" ];
}

This will create two edges between the 'a' and 'b' nodes. Is there a way to have only one edge (group them)?


Solution

  • I think it really depends on what your desired output would be. One possibility is:

    digraph G {
       graph [ splines = false ]
       a -> b [ label = "foo" ];
       a -> b [ label = "bar" ];
     }
    

    Where not using splines draws edges with straight line segments and so duplicate edges will not be distinguished visually.

    In your ideal output, what would the single edge look like since there are to be two different labels for it?