18 #define DEF_RANKSEP 1.00
30 int nsteps =
SLEAF(n) + 1;
33 if ((next =
agtail(ep)) == n)
39 if (nsteps <
SLEAF(next)) {
41 setNStepsToLeaf(g, next, n);
56 if ((np =
agtail(ep)) == n)
73 int INF = nnodes * nnodes;
97 int maxNStepsToLeaf = 0;
106 setNStepsToLeaf(g, n, 0);
110 if (
SLEAF(n) > maxNStepsToLeaf) {
111 maxNStepsToLeaf =
SLEAF(n);
130 if ((next =
agtail(ep)) == n)
142 setNStepsToCenter(g, next, n);
167 static void* pull(
queue* q)
171 if ((ip = q->
head)) {
198 if ((next =
agtail(ep)) == n)
223 setNStepsToCenter(sg, center);
241 static void setSubtreeSize(
Agraph_t * g)
266 if ((next =
agtail(ep)) == n)
271 if (
SPAN(next) != 0.0)
276 setChildSubtreeSpans(g, next);
284 setChildSubtreeSpans(sg, center);
300 if ((next =
agtail(ep)) == n)
311 setChildPositions(sg, next);
318 setChildPositions(sg, center);
329 getRankseps (
Agraph_t* g,
int maxrank)
335 double* ranks =
N_NEW(maxrank+1,
double);
336 double xf = 0.0, delx = 0.0, d;
339 while ((rk <= maxrank) && ((d = strtod (p, &endp)) > 0)) {
344 while ((c = *p) && (isspace(c) || (c ==
':')))
352 for (i = rk; i <= maxrank; i++) {
360 static void setAbsolutePos(
Agraph_t * g,
int maxrank)
367 ranksep = getRankseps (g, maxrank);
369 fputs (
"Rank separation = ", stderr);
370 for (i = 0; i <= maxrank; i++)
371 fprintf (stderr,
"%.03lf ", ranksep[i]);
372 fputs (
"\n", stderr);
391 " : leaf stsz nkids cntr parent span theta\n");
397 fprintf(stderr,
"%4s :%6d%6d%6d%6d%7s%7.3f%7.3f%8.3f%8.3f\n",
412 int maxNStepsToCenter;
424 center = findCenterNode(sg);
426 maxNStepsToCenter = setParentNodes(sg,center);
428 fprintf(stderr,
"root = %s max steps to root = %d\n",
agnameof(center), maxNStepsToCenter);
429 if (maxNStepsToCenter < 0) {
430 agerr(
AGERR,
"twopi: use of weight=0 creates disconnected component.\n");
436 setSubtreeSpans(sg, center);
438 setPositions(sg, center);
440 setAbsolutePos(sg, maxNStepsToCenter);
int initLayout(vtx_data *graph, int n, int dim, double **coords, node_t **nodes)
CGRAPH_API Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
int agerr(agerrlevel_t level, const char *fmt,...)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * circleLayout(Agraph_t *sg, Agnode_t *center)
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
CGRAPH_API char * agnameof(void *)
#define agfindedgeattr(g, a)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
CGRAPH_API Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
#define agfindgraphattr(g, a)
EXTERN unsigned char Verbose
CGRAPH_API int agnnodes(Agraph_t *g)
char * late_string(void *obj, attrsym_t *attr, char *def)