How can I get bidirectional connections concentrated between clusters?

421 Views Asked by At

Take the following digraph:

digraph "all"{

  subgraph "cluster cluster 1" {
    node [label="1"] "1"
    node [label="2"] "2"
  }

  subgraph "cluster cluster 2" {
    node [label="3"] "3"
    node [label="4"] "4"
  }

  1 -> 2
  2 -> 1

  3 -> 4
  4 -> 3

}

enter image description here

In order to turn bidirectional connections into a single arrow,
I must use concentrate=true;.

digraph "all"{

  subgraph "cluster cluster 1" {
    node [label="1"] "1"
    node [label="2"] "2"
  }

  subgraph "cluster cluster 2" {
    node [label="3"] "3"
    node [label="4"] "4"
  }

  1 -> 2
  2 -> 1

  3 -> 4
  4 -> 3

  concentrate=true;

}

enter image description here

This works inside individual clusters, but it does not work across clusters.
I've tried sprinkling concentrate=true in other places as well, but it did not work.

digraph "all"{

  subgraph "cluster cluster 1" {
    node [label="1"] "1"
    node [label="2"] "2"
    concentrate=true;
  }

  subgraph "cluster cluster 2" {
    node [label="3"] "3"
    node [label="4"] "4"
    concentrate=true;
  }

  1 -> 2
  2 -> 1

  3 -> 4
  4 -> 3

  2 -> 3
  3 -> 2

  concentrate=true;

}

enter image description here
How can I concentrate connections between digraph clusters?

2

There are 2 best solutions below

1
bootsy On

Use the connection modifier [dir=both]

2 -> 3 [dir=both]

You can then remove the link from 3 -> 2

0
razor On

For bidirectional graphs if you don't need to show the arrows, you can add "edge[arrowhead=none]" in addition to "concentrate=true".