From b80f42c3c648c46be2a08ad2ef15e8456363d6d0 Mon Sep 17 00:00:00 2001 From: ellson Date: Tue, 21 Oct 2008 22:06:47 +0000 Subject: [PATCH] twopigen ==> cgraph --- lib/twopigen/circle.c | 27 ++++++++++++++++----------- lib/twopigen/twopiinit.c | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/twopigen/circle.c b/lib/twopigen/circle.c index a48cf8407..382f68f40 100644 --- a/lib/twopigen/circle.c +++ b/lib/twopigen/circle.c @@ -27,11 +27,12 @@ static void setNStepsToLeaf(Agraph_t * g, Agnode_t * n, Agnode_t * prev) { Agnode_t *next; Agedge_t *ep; + int nsteps = SLEAF(n) + 1; for (ep = agfstedge(g, n); ep; ep = agnxtedge(g, ep, n)) { - if ((next = ep->tail) == n) - next = ep->head; + if ((next = agtail(ep)) == n) + next = aghead(ep); if (prev == next) continue; @@ -53,8 +54,8 @@ static int isLeaf(Agraph_t * g, Agnode_t * n) Agnode_t *np; for (ep = agfstedge(g, n); ep; ep = agnxtedge(g, ep, n)) { - if ((np = ep->tail) == n) - np = ep->head; + if ((np = agtail(ep)) == n) + np = aghead(ep); if (n == np) continue; /* loop */ if (neighp) { @@ -126,8 +127,8 @@ static void setNStepsToCenter(Agraph_t * g, Agnode_t * n, Agnode_t * prev) int nsteps = SCENTER(n) + 1; for (ep = agfstedge(g, n); ep; ep = agnxtedge(g, ep, n)) { - if ((next = ep->tail) == n) - next = ep->head; + if ((next = agtail(ep)) == n) + next = aghead(ep); if (prev == next) continue; @@ -195,8 +196,8 @@ static void setChildSubtreeSpans(Agraph_t * g, Agnode_t * n) ratio = SPAN(n) / STSIZE(n); for (ep = agfstedge(g, n); ep; ep = agnxtedge(g, ep, n)) { - if ((next = ep->tail) == n) - next = ep->head; + if ((next = agtail(ep)) == n) + next = aghead(ep); if (SPARENT(next) != n) continue; /* handles loops */ @@ -229,8 +230,8 @@ static void setChildPositions(Agraph_t * sg, Agnode_t * n) theta = THETA(n) - SPAN(n) / 2; for (ep = agfstedge(sg, n); ep; ep = agnxtedge(sg, ep, n)) { - if ((next = ep->tail) == n) - next = ep->head; + if ((next = agtail(ep)) == n) + next = aghead(ep); if (SPARENT(next) != n) continue; /* handles loops */ if (THETA(next) != UNSET) @@ -257,7 +258,11 @@ static void setAbsolutePos(Agraph_t * g) double xf; double hyp; +#ifndef WITH_CGRAPH p = late_string(g, agfindattr(g->root, "ranksep"), NULL); +#else /* WITH_CGRAPH */ + p = late_string(g, agattr(g->root,AGRAPH, "ranksep",(char*)0), NULL); +#endif /* WITH_CGRAPH */ if (p) { if (sscanf(p, "%lf", &xf) == 0) xf = DEF_RANKSEP; @@ -320,7 +325,7 @@ void circleLayout(Agraph_t * sg, Agnode_t * center) if (!center) center = findCenterNode(sg); if (Verbose) - fprintf(stderr, "root = %s\n", center->name); + fprintf(stderr, "root = %s\n", agnameof(center)); /* maxNStepsToCenter = setParentNodes(sg,center); */ setParentNodes(sg, center); diff --git a/lib/twopigen/twopiinit.c b/lib/twopigen/twopiinit.c index 76efdb1bf..cdae79fe0 100644 --- a/lib/twopigen/twopiinit.c +++ b/lib/twopigen/twopiinit.c @@ -27,8 +27,10 @@ static void twopi_init_edge(edge_t * e) { +#ifdef WITH_CGRAPH + agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data +#endif /* WITH_CGRAPH */ common_init_edge(e); - ED_factor(e) = late_double(e, E_weight, 1.0, 0.0); } @@ -41,9 +43,9 @@ static void twopi_init_node_edge(graph_t * g) GD_neato_nlist(g) = N_NEW(agnnodes(g) + 1, node_t *); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { + neato_init_node(n); ND_alg(n) = alg + i; GD_neato_nlist(g)[i++] = n; - neato_init_node(n); } for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { @@ -70,7 +72,11 @@ void twopi_layout(Agraph_t * g) twopi_init_graph(g); s = agget(g, "root"); if (s && (*s != '\0')) { +#ifndef WITH_CGRAPH ctr = agfindnode(g, s); +#else /* WITH_CGRAPH */ + ctr = agnode(g, s,0); +#endif /* WITH_CGRAPH */ if (!ctr) { agerr(AGWARN, "specified root node \"%s\" was not found.", s); agerr(AGPREV, "Using default calculation for root node\n"); @@ -123,7 +129,12 @@ void twopi_layout(Agraph_t * g) static void twopi_cleanup_graph(graph_t * g) { free(GD_neato_nlist(g)); - if (g != g->root) memset(&(g->u), 0, sizeof(Agraphinfo_t)); + if (g != agroot(g)) +#ifndef WITH_CGRAPH + memset(&(g->u), 0, sizeof(Agraphinfo_t)); +#else /* WITH_CGRAPH */ + agclean(g,AGRAPH,"Agraphinfo_t"); +#endif /* WITH_CGRAPH */ } void twopi_cleanup(graph_t * g) -- 2.40.0