1 digraph dfg {
2 compound = true;
3 subgraph cluster_parent {
4 color=blue;
5 label="Parent";
6 A->B [lhead=cluster_child_1];
7 A->C;
8 subgraph cluster_child_1 {
9 color=green;
10 label="Child #1";
11 B->C;
12 }
13 subgraph cluster_child_2 {
14 color=green;
15 label="Child #2";
16 C->D [ltail=cluster_child_1];
17 }
18 D->E;
19 E->B [lhead=cluster_child_1];
20 }
21 }
The program above produces:
The key (non-intuitive) pieces for working with subgraphs are:
- Subgraph names must start with the string "cluster" --- for example, cluster_child_1.
- Edges that terminate at a subgraph (e.g., Node A to Child #1) must have the attribute "lhead" defined as the subgraph name.
- Edges that start at a subgraph (e.g., Child #1 to Node D) must have the attribute "ltail" defined as the subgraph name.
No comments:
Post a Comment