2

Grouping multiple edges together is possible by defining the graph as strict.

From the Graphviz documentation:

If the graph is strict then multiple edges are not allowed between the same pairs of nodes.

What I am interested in however, is whether I can define some 'behavior' how to group them together. For example, I would be interested in adding a label showing how many edges have been grouped together, or changing the thickness of the arrow.

Is something similar possible using Graphviz directly? I suppose I could do my own preprocessing but I don't want to reinvent the wheel.

Community
  • 1
  • 1
Steven Jeuris
  • 17,256
  • 8
  • 69
  • 149

1 Answers1

4

Note that grouping edges together is actually defined with:

concentrate="true";

But what you ask (adding a label or thickness of the edge/arrow) can easily be done by adding attributes to your edges. For example:

A -> B [penwidth="4.5"];

Adding a label to the edge uses the same "[...]" format:

A -> B [label="8 edges have been combined"];

Sometimes you might want a line to go from the label to the edge:

A -> B [label="this is my edge" decorate="true"];

The arrowhead size is also an attribute of the edge. While I haven't tried this one, the documentation says arrowsize is "Multiplicative scale factor for arrowheads." I would try this:

A -> B [arrowsize="2.0"];

Lastly, note you can combine attributes. For example:

A -> B [label="test" penwidth="5" decorate="true" arrowsize="4.1"];

Source: http://www.graphviz.org/content/attrs

Stéphane
  • 18,697
  • 23
  • 86
  • 128
  • Yup ... that was easy enough to figure out, but it still involves preprocessing. :) You could update your answer to state that without preprocessing (and e.g. adding the attributes you listed) this is not possible in GraphViz. That is also how I ended up doing it eventually ... – Steven Jeuris Aug 11 '14 at 09:47