Can graphviz create automatic group/cluster outlines?

I am creating a network graph from some data. Not all the data is connected, leading to individual groups (or clusters? I’m not sure of the right terminology).

Below is an example of what it looks like. (Using ‘neato’).

Is it possible to get graphviz to detect and draw lines around the individual (loose) groups?

I believe that ccomps (http://www.graphviz.org/pdf/ccomps.1.pdf) (a Graphviz program) can identify disconnected subsets and create a subgraph for each subset. The following (Linux) command will identify these subsets and create a cluster around each.
ccomps -x myfile.gv | sed -e '/digraph .*_cc_/s/digraph /subgraph cluster/' -e '1idigraph N {' -e '$a}'
(edited to fix blunder)
(also posted to stack overflow)

1 Like

I don’t believe we have a way to do this cleanly. The clever polyomino packing algorithm packs the individual components tightly, so drawing bounding boxes around them won’t work - the boxes may overlap, as shown in the example that is provided.

The gvpack command in graphviz (documented here) provides an interface to the underlying graphviz pack library so it might be a place to start thinking about implementing this feature. The gvpack command is documented here.

Also, it’s slightly worse than you might think, because the polyominos are a bunch of rectangles that cover the graph layout, but probably what we want are boundaries drawn by alpha shapes which you could think of like putting shrink-wrap around a set of points. As the article mentions it is a generalization of the concept of a convex hull. This figure helps to illustrate:
ScagnosticsBase.svg

Sorry not to have better news. This could be a great student project if people still do student projects in C. Really it might not be that hard to walk a subgraph to get enough of the layout points of nodes and edges, feed the points to a 3rd party alpha shapes library, and copy the result back to each component subgraph.

1 Like