Dot graph language - how to make bidirectional edges automatically?

GraphGraphvizDot

Graph Problem Overview


Here is a very simplified example of my Dot graph:

strict digraph graphName {
A->B
B->A
}

This creates alt text

Instead I want a single edge shown between A and B but with a double arrow head. I know how to get the double arrowhead as a global option:

strict digraph graphName {
  edge [dir="both"]
A->B
B->A
}

But that looks very ugly, and not all of my edges should be dual headed.

alt text

If I do more processing of the graph and detect the double reference myself and replace the two edges with a single edge, it looks OK. But I'd rather not have to do this extra step

strict digraph graphName {
A->B [dir="both"]
}

alt text

Any better solutions?

Graph Solutions


Solution 1 - Graph

You should just use:

A -> B [dir=both]

Solution 2 - Graph

How about 'concentrate=true'?:

strict digraph graphName {
concentrate=true
A->B
B->A
}

with concentrate=true

From the documentation:

> If true, use edge concentrators. This > merges multiedges into a single edge > and causes partially parallel edges to > share part of their paths. The latter > feature is not yet available outside > of dot.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionI82MuchView Question on Stackoverflow
Solution 1 - Graphuser2598811View Answer on Stackoverflow
Solution 2 - GraphspenthilView Answer on Stackoverflow