GraphViz – How to connect subgraphs?

The DOT user manual gives the following example of a graph with clusters with edges between clusters:

IMPORTANT: The initial compound=true statement is required.

digraph G {
  compound=true;
  subgraph cluster0 {
    a -> b;
    a -> c;
    b -> d;
    c -> d;
  }
  subgraph cluster1 {
    e -> g;
    e -> f;
  }
  b -> f [lhead=cluster1];
  d -> e;
  c -> g [ltail=cluster0,lhead=cluster1];
  c -> e [ltail=cluster0];
  d -> h;
}

… and edges between nodes and clusters:

enter image description here

Leave a Comment