22
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)?

Steve Ives
  • 7,894
  • 3
  • 24
  • 55
name
  • 5,095
  • 5
  • 27
  • 36
  • 2
    Do you want one edge with two labels? In other words, what do you want that would be different than just having one statement which specifies one edge between a and b? – datageist Feb 24 '10 at 08:20
  • I wonder if there's a way to make the edge thicker if there are more duplicates of it. – Geremia Mar 19 '16 at 05:04

2 Answers2

45

The "strict" keyword may help you.

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

This will combine the edges. But I believe it will only apply the first label.

Jason
  • 2,341
  • 17
  • 14
7

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?

RTBarnard
  • 4,374
  • 27
  • 27
  • Thx for the answer. It really visually is not distinguished. With labels I would like to concatenate them. I will probably have to write again the file with modifications. – name Feb 24 '10 at 08:38
  • 2
    You're correct. Your objective goes beyond the node/edge processing capabilities of graphviz and does require some sort of pre-processing to merge duplicates into the form you're looking for. Of course, with smaller graphs like the example, you can sort of fake it with the splines option. – RTBarnard Feb 24 '10 at 08:45