How can I create edges between cluster boxes?

This only works in Graphviz version 1.7 and higher. To make edges between clusters, first set the graph attribute compound=true. Then, you can specify a cluster by name as a logical head or tail to an edge. This will cause the edge joining the two nodes to be clipped to the exterior of the box around the given cluster.

For example,

  • digraph G {
    • compound=true; nodesep=1.0; subgraph cluster_A {
      • a -> b; a -> c;

      } subgraph cluster_B {
      • d -> e; f -> e;


      a -> e [ ltail=cluster_A,

      • lhead=cluster_B ];

has an edge going from cluster_A to cluster_B. If, instead, you say

  • a -> e [ltail=cluster_A];

this gives you an edge from cluster_A to node e. Or you could just specify an lhead attribute. The program warns if a cluster specified as a logical node is not defined. Also, if a cluster is specified as a logical head for an edge, the real head must be contained in the cluster, and the real tail must not be. A similar check is done for logical tails. In these cases, the edge is drawn between the real nodes as usual.

GraphvizWiki: FaqClusterEdge (last edited 2008-01-16 20:11:20 by H-135-207-131-158)

Recent comments