Subgraphs play three roles in Graphviz. First, a subgraph can be used to represent graph structure, indicating that certain nodes and edges should be grouped together.
But is that used anywhere? Dot doesn’t seem to care about the grouping, unless it is a cluster.
digraph G {
subgraph cluster_test {c1 c2}
a -> b
a ->c1
b->c2
}
While cluster subgraphs physically group/gather their embedded nodes, non-cluster subgraphs (only) logically effect the embedded nodes/edges - by applying common attributes to the set.
I think I’d like to use this subgraph feature to physically group nodes. I’m trying to understand what you are referring to as a cluster? I don’t see anything in the AGraph class documentation about a cluster? I’m taking two nodes that have already been added to the graph and putting them in a python list and doing the G.add_subgraph(list) function call. The result is they do not seem to be grouped together in the resulting graph.
I look at your example and the only difference I see is in the name ‘cluster_test’ vs. ‘cluster’.
OK I found that cluster is an attribute so I specified ‘cluster=True’ on the add_subgraph()… The script seemed to run OK but I didn’t see any difference. I’m using prog=‘neato’. I’m not really sure if it’s valid for neato?
OK now I find a post that neato doesn’t support clusters?
OK well I tried ldp and didn’t get the grouping but the graph looks worse. Mine is a 3 tiered hierarchical graph and I was using the mode=hier in neato. I tried dot and that produced an unreadable graph. So anyone have any suggestions for a 3 tiered graph?