name
name

Reputation: 5175

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

Upvotes: 22

Views: 14649

Answers (2)

Jason
Jason

Reputation: 2371

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.

Upvotes: 46

RTBarnard
RTBarnard

Reputation: 4444

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?

Upvotes: 7

Related Questions