Cannot get bounding box of subgraph/cluster, moving from graph to cgraph

Hello, I am trying to convert my code to use cgraph instead of graph. I am trying to get the bounding box of subgraphs, I've trierd: 

GD_width(graph), GD_height(graph) -> both come out to zero.

agget(graph, "bb") -> I get the bb of the main graph, regardless of which sub graph I pass as graph, and I would like to get just the dimensions of the sub-graph.

. agget(graph, "width") -> gives null.

Previously when using graph.h instead of cgraph I got the bounding box of the subgraphs using:

printf("bounding box is: %f %f %f %f name is: %s\n", g->u.bb.LL.x, g->u.bb.LL.y, g->u.bb.UR.x, g->u.bb.UR.y, "");

However I cannot access the bounding box this way using cgraph? Could you please give me instruction how to fix this? Thank you.

As I mentioned, the interface

As I mentioned, the interface using cgraph is basically the same as with graph. So, if you were using the bb attribute with graph, you would use the bb attribute with cgraph. In particular, you can use the GD_bb macro:

printf("bounding box is: %f %f %f %f name is: %s\n", GD(bb)->LL.x, GD_bb(g)->LL.y, GD_bb(g)->UR.x, GD_bb(g)->UR.y, "");

We encourage users to use the various GD_, ND_ and ED_ macros defined in types.h precisely to protect their code from implementation changes. See the library manual http://www.graphviz.org/doc/libguide/libguide.pdf for more details.

As for using agget() to access attributes, these values won't be set until you "render" the graph into dot using

gvRender(gvc,graph,"dot", NULL):

See page 18 of the library manual.

Recent comments