Steven Jeuris
Steven Jeuris

Reputation: 19100

Strict graph which displays multiple edges differently

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.

Upvotes: 2

Views: 2812

Answers (1)

Stéphane
Stéphane

Reputation: 20340

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

Upvotes: 4

Related Questions