Clusters - outline geometry attribute?

Is it possible to change the geometry of a cluster outline? To maybe a circle or . . . ?
Thanks much

No, there is no straight-forward way to change the shape of the cluster “periphery”. However it can be (kind of) done by fiddling a bit with the .gv file & the post-processing the result, with GVPR (part of the Graphviz package), like so:

digraph G {
graph [size="6,6"];
node [label="\N"];
subgraph cluster0 {
	graph [_newshape=circle margin=36]  // note _newshape and large margin
	x0
	y0
	z0
	x0 -> y0
	x0 -> z0
}
subgraph cluster1 {
	graph [_newshape=pentagon margin=36]
	x1
	y1
	z1
	x1 -> y1 
	x1 -> z1 
}
subgraph cluster2 {
	graph [_newshape=oval margin=36]
	x2
	y2
	z2
	x2 -> y2
	x2 -> z2
}
a
b
c
a -> b
b -> c
a -> x0
b -> x1
b -> x2
a -> z2
c -> z1

}
This command line:
f=changeCluster;/bin/dot -Tdot $f.gv |gvpr -c -f newclusterperf.gvpr| neato -n2 -Tpng >$f.neato.png
And this GVPR program:

BEGIN{
int i, n;
node_t aNode;
graph_t aGraph;
double MinX,MinY,MaxX,MaxY,  dX, dY,  cX,cY;
string s; 
}
BEG_G{
 for (aGraph = fstsubg($G); aGraph; aGraph = nxtsubg(aGraph)) {
   if (match(aGraph.name,"cluster")==0){
     //print ("// cluster:  >", aGraph.name,"<");
     if (hasAttr(aGraph, "_newshape") && aGraph._newshape!=""){
       aGraph.peripheries="0";  // we will replace the periphery rectangle
       sscanf (aGraph.bb, "%lf,%lf,%lf,%lf", &MinX, &MinY, &MaxX, &MaxY);
   idStr=sprintf("___NEWPERIPH_%d", ++i);
       aNode=node($G, idStr);
   s=sprintf("%f", (MaxX-MinX)/72);
       aNode.width=s;
   s=sprintf("%f", (MaxY-MinY)/72);
   aNode.height=s;
   s=sprintf("%f,%f", MinX+((MaxX-MinX)/2), MinY+((MaxY-MinY)/2));
   aNode.pos=s;
       aNode.shape=aGraph._newshape;
     }
   }
 }

}

Produce this:
changeCluster.neato

Perfect. Thanks a lot Steve, really appreciate the feedback. Pretty sure I see what you’re doing there and that should work just fine.

I’m going to make the assumption that the new periphery will scale automatically to accommodate the contents , given the margin statement.

Just one other note – when I tried to use an undirected edge (similar to the gallery example using fdp) I noticed that the example was missing

several semi-colons, which caused it to fail with no error, but also with no graph . . . You may already know about that, but thought it should be mentioned jic.

I’m just starting to use this, one of my colleagues turned me on to it since he’s been using it for years, so the quick response is most highly appreciated.

Thanks again for the assist.

Kind regards,

Steve Webb

1 Like

I was too rushed when I first posted.

  • we’re removing the periphery & replacing it with an overlayed node (not part of the std. dot language, but “legal”)
  • we specify the node shape with the “new” _newshape attribute (again quite legal. Ignored by dot & neato, but passed on to GVPR)
  • the large margin allows us to place the overlay node inside the periphery boundary (the cluster’s bb). If the node was outside the bb, it would overlap other parts of the graph.
  • there is a bug in my GVPR program, add this line:
    aNode.label="";
    after this one:
    aNode.pos=s;

Enjoy.

1 Like

I thought I was the only one who would stoop to using such tricks in gvpr. It’s good to have company. :grinning:

1 Like

I consider that a compliment. GVPR is quite good for prototypes, quick fixes, and tweaking graphs in ways that the main engines don’t support.

1 Like

Not an issue – also see why you added the label null.

Sorry to bother you with a minor issue, but gvpr and neato are not in this 64b 2.44.1 distribution.

I found a 32 gvpr in the zip file on the site and my security system doesn’t seem to think that it’s a problem and it should probably work ok on this platform??

No such luck with the neato.exe…. run it through dot with -Kneato ?

Thanks much

Stephen

1 Like

Yes. You should be able to use the 32-bit gvpr and dot -Kneato which is identical to running neato where available.

We are tracking the lack of these programs in Windows CMake builds (which are the only 64-bit builds for Windows) in:

Thanks much. Thought so, but given the targeted nature of the information that Steve gave me, thought that I should check.

Did see the thread on gpvr, but will keep track of this one also.

Thanks again.

Stephen

1 Like

:blush:Underscore ‘should’. It appears that the gvprlib is trying to call - but unable to find - cdt, cgraph, and gvc dlls. even though they are in the same directory and also in the PATH. This is causing the gvpr init to fail. 32 vs 64 bit issue?? The core files are 64, but that version of gvpr (and its library) is 32, since the 64 bit wasn’t in the build. Any thoughts that you might have would be much appreciated. Hair’s not on fire, but would like to see if I can get this working. Going back to a version that includes gvpr is not a problem if it is possible……

Thanks much.

S.