* Also, if center != 0, we are guaranteed that center is
* in the graph.
*/
-void circleLayout(Agraph_t * sg, Agnode_t * center)
+Agnode_t* circleLayout(Agraph_t * sg, Agnode_t * center)
{
int maxNStepsToCenter;
Agnode_t *n = agfstnode(sg);
ND_pos(n)[0] = 0;
ND_pos(n)[1] = 0;
- return;
+ return center;
}
initLayout(sg);
setAbsolutePos(sg, maxNStepsToCenter);
/* dumpGraph (sg); */
+ return center;
}
#define SPAN(n) (RDATA(n)->span)
#define THETA(n) (RDATA(n)->theta)
- extern void circleLayout(Agraph_t * sg, Agnode_t * center);
+ extern Agnode_t* circleLayout(Agraph_t * sg, Agnode_t * center);
extern void twopi_layout(Agraph_t * g);
extern void twopi_cleanup(Agraph_t * g);
extern void twopi_init_graph(graph_t * g);
{
Agnode_t *ctr = 0;
char *s;
+ int setRoot = 0;
twopi_init_graph(g);
s = agget(g, "root");
- if (s && (*s != '\0')) {
- ctr = agfindnode(g, s);
- if (!ctr) {
- agerr(AGWARN, "specified root node \"%s\" was not found.", s);
- agerr(AGPREV, "Using default calculation for root node\n");
+ if ((s = agget(g, "root"))) {
+ if (*s) {
+ ctr = agfindnode(g, s);
+ if (!ctr) {
+ agerr(AGWARN, "specified root node \"%s\" was not found.", s);
+ agerr(AGPREV, "Using default calculation for root node\n");
+ setRoot = 1;
+ }
+ }
+ else {
+ setRoot = 1;
}
}
if (agnnodes(g)) {
ccs = ccomps(g, &ncc, 0);
if (ncc == 1) {
- circleLayout(g, ctr);
+ c = circleLayout(g, ctr);
+ if (setRoot && !ctr)
+ ctr = c;
free(ND_alg(agfstnode(g)));
adjustNodes(g);
spline_edges(g);
else
c = 0;
nodeInduce(sg);
- circleLayout(sg, c);
+ c = circleLayout(sg, c);
+ if (setRoot && !ctr)
+ ctr = c;
adjustNodes(sg);
setEdgeType (sg, ET_LINE);
spline_edges(sg);
}
free(ccs);
}
+ if (setRoot)
+ agset (g, "root", agnameof (ctr));
dotneato_postprocess(g);
}