From: Stephen North Date: Fri, 8 Feb 2013 22:28:04 +0000 (-0500) Subject: Fixed some flat edge problems, and got DEBUG=1 working again. X-Git-Tag: LAST_LIBGRAPH~32^2~240 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=342b87015a14ada251faf02489757ce6bfd0e8f9;p=graphviz Fixed some flat edge problems, and got DEBUG=1 working again. Not sure if backward compatible with old libgraph. --- diff --git a/cmd/tools/gvpack.c b/cmd/tools/gvpack.c index 9d86bc377..5dad5b401 100644 --- a/cmd/tools/gvpack.c +++ b/cmd/tools/gvpack.c @@ -948,13 +948,14 @@ void dump(Agraph_t * g) edge_t *e; for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - fprintf(stderr, "%s\n", v->name); + fprintf(stderr, "%s\n", agnameof(v)); for (e = agfstout(g, v); e; e = agnxtout(g, e)) { fprintf(stderr, " %s -- %s\n", agnameof(agtail(e)), agnameof(aghead(e))); } } } +#ifndef WITH_CGRAPH void dumps(Agraph_t * g) { graph_t *subg; @@ -970,6 +971,17 @@ void dumps(Agraph_t * g) fprintf(stderr, "====\n"); } } +#else +void dumps(Agraph_t * g) +{ + graph_t *subg; + + for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) { + dump(subg); + fprintf(stderr, "====\n"); + } +} +#endif #endif int main(int argc, char *argv[]) diff --git a/lib/circogen/block.c b/lib/circogen/block.c index 4d3e97299..2df9d488e 100644 --- a/lib/circogen/block.c +++ b/lib/circogen/block.c @@ -98,17 +98,17 @@ void printBlocklist(blocklist_t * snl) Agnode_t *n; char *p; Agraph_t *g = bp->sub_graph; - fprintf(stderr, "block=%s\n", g->name); + fprintf(stderr, "block=%s\n", agnameof(g)); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { Agedge_t *e; if (PARENT(n)) - p = PARENT(n)->name; + p = agnameof(PARENT(n)); else p = ""; - fprintf(stderr, " %s (%d %s)\n", n->name, VAL(n), p); + fprintf(stderr, " %s (%d %s)\n", agnameof(n), VAL(n), p); for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { - fprintf(stderr, " %s--%s\n", e->tail->name, - e->head->name); + fprintf(stderr, " %s--", agnameof(agtail(e))); + fprintf(stderr, "%s\n", agnameof(aghead(e))); } } } diff --git a/lib/circogen/blockpath.c b/lib/circogen/blockpath.c index 5844bc03c..aef6dc7a6 100644 --- a/lib/circogen/blockpath.c +++ b/lib/circogen/blockpath.c @@ -723,8 +723,10 @@ void prTree(Agraph_t * g) Agnode_t *n; for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - if (TPARENT(n)) - fprintf(stderr, "%s -> %s\n", n->name, TPARENT(n)->name); + if (TPARENT(n)) { + fprintf(stderr, "%s ", agnameof(n)); + fprintf(stderr, "-> %s\n", agnameof(TPARENT(n))); + } } } #endif diff --git a/lib/circogen/blocktree.c b/lib/circogen/blocktree.c index 38193720f..72942e694 100644 --- a/lib/circogen/blocktree.c +++ b/lib/circogen/blocktree.c @@ -257,9 +257,9 @@ void print_blocktree(block_t * sn, int depth) indent(depth); g = sn->sub_graph; - fprintf(stderr, "%s:", g->name); + fprintf(stderr, "%s:", agnameof(g)); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - fprintf(stderr, " %s", n->name); + fprintf(stderr, " %s", agnameof(n)); } fputs("\n", stderr); diff --git a/lib/circogen/circular.c b/lib/circogen/circular.c index 68758a0ed..e311003d2 100644 --- a/lib/circogen/circular.c +++ b/lib/circogen/circular.c @@ -137,11 +137,12 @@ void prGraph(Agraph_t * g) Agnode_t *n; Agedge_t *e; - fprintf(stderr, "%s\n", g->name); + fprintf(stderr, "%s\n", agnameof(g)); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - fprintf(stderr, "%s (%x)\n", n->name, (unsigned int) n); + fprintf(stderr, "%s (%x)\n", agnameof(n), (unsigned int) n); for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - fprintf(stderr, "%s -- %s (%x)\n", n->name, e->head->name, + fprintf(stderr, "%s", agnameof(n)); + fprintf(stderr, " -- %s (%x)\n", agnameof(aghead(e)), (unsigned int) e); } } @@ -162,31 +163,31 @@ void prData(Agnode_t * n, int pass) int dist1, dist2; if (PARENT(n)) - pname = PARENT(n)->name; + pname = agnameof(PARENT(n)); else pname = ""; if (BLOCK(n)) - bname = BLOCK(n)->sub_graph->name; + bname = agnameof(BLOCK(n)->sub_graph); else pname = ""; - fprintf(stderr, "%s: %x %s %s ", n->name, FLAGS(n), pname, bname); + fprintf(stderr, "%s: %x %s %s ", agnameof(n), FLAGS(n), pname, bname); switch (pass) { case 0: fprintf(stderr, "%d %d\n", VAL(n), LOWVAL(n)); break; case 1: if (TPARENT(n)) - tname = TPARENT(n)->name; + tname = agnameof(TPARENT(n)); else tname = ""; dist1 = DISTONE(n); if (dist1 > 0) - name1 = LEAFONE(n)->name; + name1 = agnameof(LEAFONE(n)); else name1 = ""; dist2 = DISTTWO(n); if (dist2 > 0) - name2 = LEAFTWO(n)->name; + name2 = agnameof(LEAFTWO(n)); else name2 = ""; fprintf(stderr, "%s %s %d %s %d\n", tname, name1, dist1, name2, diff --git a/lib/circogen/deglist.c b/lib/circogen/deglist.c index 1ebc82f77..abb86eb0d 100644 --- a/lib/circogen/deglist.c +++ b/lib/circogen/deglist.c @@ -153,7 +153,7 @@ void printDeglist(deglist_t * dl) if (np) fprintf(stderr, " (%d)", ip->deg); for (; np; np = ND_next(np)) { - fprintf(stderr, " %s", np->name); + fprintf(stderr, " %s", agnameof(np)); } fprintf(stderr, "\n"); } diff --git a/lib/circogen/edgelist.c b/lib/circogen/edgelist.c index 2240327f9..edceac409 100644 --- a/lib/circogen/edgelist.c +++ b/lib/circogen/edgelist.c @@ -87,7 +87,8 @@ void print_edge(edgelist * list) for (temp = (edgelistitem *) dtflatten(list); temp; temp = (edgelistitem *) dtlink(list, (Dtlink_t *) temp)) { ep = temp->edge; - fprintf(stderr, "%s--%s \n", ep->tail->name, ep->head->name); + fprintf(stderr, "%s--", agnameof(agtail(ep))); + fprintf(stderr, "%s \n", agnameof(aghead(ep))); } fputs("\n", stderr); } diff --git a/lib/circogen/nodelist.c b/lib/circogen/nodelist.c index 7b105b947..2ef2bff81 100644 --- a/lib/circogen/nodelist.c +++ b/lib/circogen/nodelist.c @@ -313,10 +313,10 @@ int node_position(nodelist_t * list, Agnode_t * n) #ifdef OLD nodelistitem_t *temp; int i = 0; - char *name = n->name; + char *name = agnameof(n); for (temp = list->first; temp; temp = temp->next) { - if (temp->curr->name == name) { + if (streq(agnameof(temp->curr),name)) { return i; } i++; @@ -360,7 +360,7 @@ void printNodelist(nodelist_t * list) temp = list->first; while (temp != NULL) { - fprintf(stderr, "%s ", temp->curr->name); + fprintf(stderr, "%s ", agnameof(temp->curr)); temp = temp->next; } fputs("\n", stderr); diff --git a/lib/common/ns.c b/lib/common/ns.c index 07697ae8e..941648536 100644 --- a/lib/common/ns.c +++ b/lib/common/ns.c @@ -342,7 +342,7 @@ static int feasible_tree(void) if (Tree_node.list[i] == n) break; if (i >= Tree_node.size) - fprintf(stderr, "\t%s\n", n->name); + fprintf(stderr, "\t%s\n", agnameof(n)); } #endif return 1; @@ -874,24 +874,24 @@ static void dump_graph (graph_t* g) edge_t *e; node_t *n,*w; FILE* fp = fopen ("ns.gv", "w"); - fprintf (fp, "digraph %s {\n", g->name); + fprintf (fp, "digraph %s {\n", agnameof(g)); for (n = GD_nlist(g); n; n = ND_next(n)) { - if (streq(n->name,"virtual")) + if (streq(agnameof(n),"virtual")) fprintf (fp, " \"%p\"\n", n); else - fprintf (fp, " \"%s\"\n", n->name); + fprintf (fp, " \"%s\"\n", agnameof(n)); } for (n = GD_nlist(g); n; n = ND_next(n)) { for (i = 0; (e = ND_out(n).list[i]); i++) { - if (streq(n->name,"virtual")) + if (streq(agnameof(n),"virtual")) fprintf (fp, " \"%p\"", n); else - fprintf (fp, " \"%s\"", n->name); + fprintf (fp, " \"%s\"", agnameof(n)); w = aghead(e); - if (streq(w->name,"virtual")) + if (streq(agnameof(w),"virtual")) fprintf (fp, " -> \"%p\"\n", w); else - fprintf (fp, " -> \"%s\"\n", w->name); + fprintf (fp, " -> \"%s\"\n", agnameof(w)); } } diff --git a/lib/common/routespl.c b/lib/common/routespl.c index ec41a8ed5..7e66c4381 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -213,11 +213,11 @@ static void psprintinit (int begin) static int debugleveln(edge_t* realedge, int i) { - return (GD_showboxes(realedge->head->graph) == i || - GD_showboxes(realedge->tail->graph) == i || + return (GD_showboxes(agraphof(aghead(realedge))) == i || + GD_showboxes(agraphof(agtail(realedge))) == i || ED_showboxes(realedge) == i || - ND_showboxes(realedge->head) == i || - ND_showboxes(realedge->tail) == i); + ND_showboxes(aghead(realedge)) == i || + ND_showboxes(agtail(realedge)) == i); } #endif /* DEBUG */ @@ -639,11 +639,11 @@ static pointf *_routesplines(path * pp, int *npoints, int polyline) *npoints = spl.pn; #ifdef DEBUG - if (GD_showboxes(realedge->head->graph) == 2 || - GD_showboxes(realedge->tail->graph) == 2 || + if (GD_showboxes(agraphof(aghead(realedge))) == 2 || + GD_showboxes(agraphof(agtail(realedge))) == 2 || ED_showboxes(realedge) == 2 || - ND_showboxes(realedge->head) == 2 || - ND_showboxes(realedge->tail) == 2) + ND_showboxes(aghead(realedge)) == 2 || + ND_showboxes(agtail(realedge)) == 2) printboxes(boxn, boxes); #endif diff --git a/lib/dotgen/dotinit.c b/lib/dotgen/dotinit.c index f4d10019f..c262503d5 100644 --- a/lib/dotgen/dotinit.c +++ b/lib/dotgen/dotinit.c @@ -236,10 +236,10 @@ dumpRanks (graph_t * g) for (j = 0; j < rank[i].n; j++) { u = rank[i].v[j]; rcnt++; - if (streq(u->name,"virtual")) + if (streq(agnameof(u),"virtual")) fprintf (stderr, " %x", u); else - fprintf (stderr, " %s", u->name); + fprintf (stderr, " %s", agnameof(u)); } fprintf (stderr, "\n"); diff --git a/lib/dotgen/fastgr.c b/lib/dotgen/fastgr.c index 23e7fbecb..03663b360 100644 --- a/lib/dotgen/fastgr.c +++ b/lib/dotgen/fastgr.c @@ -79,14 +79,14 @@ edge_t *fast_edge(edge_t * e) for (i = 0; (f = ND_out(agtail(e)).list[i]); i++) { if (e == f) { fprintf(stderr, "duplicate fast edge\n"); - return; + return 0; } assert(aghead(e) != aghead(f)); } for (i = 0; (f = ND_in(aghead(e)).list[i]); i++) { if (e == f) { fprintf(stderr, "duplicate fast edge\n"); - return; + return 0; } assert(agtail(e) != agtail(f)); } @@ -289,7 +289,7 @@ static char *NAME(node_t * n) { static char buf[20]; if (ND_node_type(n) == NORMAL) - return n->name; + return agnameof(n); sprintf(buf, "V%p", n); return buf; } @@ -302,22 +302,22 @@ void fastgr(graph_t * g) for (n = GD_nlist(g); n; n = ND_next(n)) { fprintf(stderr, "%s %d: (", NAME(n), ND_rank(n)); - for (i = 0; e = ND_out(n).list[i]; i++) { + for (i = 0; (e = ND_out(n).list[i]); i++) { fprintf(stderr, " %s:%d", NAME(aghead(e)), ED_count(e)); w = aghead(e); if (g == g->root) { - for (j = 0; f = ND_in(w).list[j]; j++) + for (j = 0; (f = ND_in(w).list[j]); j++) if (e == f) break; assert(f != NULL); } } fprintf(stderr, " ) ("); - for (i = 0; e = ND_in(n).list[i]; i++) { + for (i = 0; (e = ND_in(n).list[i]); i++) { fprintf(stderr, " %s:%d", NAME(agtail(e)), ED_count(e)); w = agtail(e); if (g == g->root) { - for (j = 0; f = ND_out(w).list[j]; j++) + for (j = 0; (f = ND_out(w).list[j]); j++) if (e == f) break; assert(f != NULL); diff --git a/lib/dotgen/mincross.c b/lib/dotgen/mincross.c index a3eb7e32f..d7a4eb0d8 100644 --- a/lib/dotgen/mincross.c +++ b/lib/dotgen/mincross.c @@ -26,6 +26,11 @@ #define saveorder(v) (ND_coord(v)).x #define flatindex(v) ND_low(v) +static int gd_minrank(Agraph_t *g) {return GD_minrank(g);} +static int gd_maxrank(Agraph_t *g) {return GD_maxrank(g);} +static rank_t *gd_rank(Agraph_t *g, int r) {return &GD_rank(g)[r];} +static int nd_order(Agnode_t *v) { return ND_order(v); } + /* forward declarations */ static boolean medians(graph_t * g, int r0, int r1); static int nodeposcmpf(node_t ** n0, node_t ** n1); @@ -761,11 +766,13 @@ static node_t *neighbor(node_t * v, int dir) node_t *rv; rv = NULL; +assert(v); if (dir < 0) { if (ND_order(v) > 0) rv = GD_rank(Root)[ND_rank(v)].v[ND_order(v) - 1]; } else rv = GD_rank(Root)[ND_rank(v)].v[ND_order(v) + 1]; +assert((rv == 0) || (ND_order(rv)-ND_order(v))*dir > 0); return rv; } @@ -1213,6 +1220,15 @@ void enqueue_neighbors(nodequeue * q, node_t * n0, int pass) } } +static int constraining_flat_edge(Agraph_t *g, Agnode_t *v, Agedge_t *e) +{ + if (ED_weight(e) == 0) return FALSE; + if (!inside_cluster(g,agtail(e))) return FALSE; + if (!inside_cluster(g,aghead(e))) return FALSE; + return TRUE; +} + + /* construct nodes reachable from 'here' in post-order. * This is the same as doing a topological sort in reverse order. */ @@ -1224,14 +1240,7 @@ static int postorder(graph_t * g, node_t * v, node_t ** list, int r) MARK(v) = TRUE; if (ND_flat_out(v).size > 0) { for (i = 0; (e = ND_flat_out(v).list[i]); i++) { - if (ED_weight(e) == 0) - continue; - if ((ND_node_type(aghead(e)) == NORMAL) & - (NOT(agcontains(g, aghead(e))))) - continue; - if (ND_clust(aghead(e)) != ND_clust(agtail(e))) - continue; - + if (!constraining_flat_edge(g,v,e)) continue; if (MARK(aghead(e)) == FALSE) cnt += postorder(g, aghead(e), list + cnt, r); } @@ -1243,7 +1252,7 @@ static int postorder(graph_t * g, node_t * v, node_t ** list, int r) static void flat_reorder(graph_t * g) { - int i, j, r, pos, n_search, local_in_cnt, local_out_cnt; + int i, j, r, pos, n_search, local_in_cnt, local_out_cnt, base_order; node_t *v, **left, **right, *t; node_t **temprank = NULL; edge_t *flat_e, *e; @@ -1251,6 +1260,8 @@ static void flat_reorder(graph_t * g) if (GD_has_flat_edges(g) == FALSE) return; for (r = GD_minrank(g); r <= GD_maxrank(g); r++) { + if (GD_rank(g)[r].n == 0) continue; + base_order = ND_order(GD_rank(g)[r].v[0]); for (i = 0; i < GD_rank(g)[r].n; i++) MARK(GD_rank(g)[r].v[i]) = FALSE; temprank = ALLOC(i + 1, temprank, node_t *); @@ -1261,15 +1272,11 @@ static void flat_reorder(graph_t * g) local_in_cnt = local_out_cnt = 0; for (j = 0; j < ND_flat_in(v).size; j++) { flat_e = ND_flat_in(v).list[j]; - if ((ED_weight(flat_e) > 0) - && (inside_cluster(g, agtail(flat_e)))) - local_in_cnt++; + if (constraining_flat_edge(g,v,flat_e)) local_in_cnt++; } for (j = 0; j < ND_flat_out(v).size; j++) { flat_e = ND_flat_out(v).list[j]; - if ((ED_weight(flat_e) > 0) - && (inside_cluster(g, aghead(flat_e)))) - local_out_cnt++; + if (constraining_flat_edge(g,v,flat_e)) local_out_cnt++; } if ((local_in_cnt == 0) && (local_out_cnt == 0)) temprank[pos++] = v; @@ -1294,7 +1301,7 @@ static void flat_reorder(graph_t * g) if (pos) { for (i = 0; i < GD_rank(g)[r].n; i++) { v = GD_rank(g)[r].v[i] = temprank[i]; - ND_order(v) = i + (GD_rank(g)[r].v - GD_rank(Root)[r].v); + ND_order(v) = i + base_order; } /* nonconstraint flat edges must be made LR */ @@ -1302,8 +1309,9 @@ static void flat_reorder(graph_t * g) v = GD_rank(g)[r].v[i]; if (ND_flat_out(v).list) { for (j = 0; (e = ND_flat_out(v).list[j]); j++) { - if (ND_order(aghead(e)) < ND_order(agtail(e))) { - /*assert(ED_weight(e) == 0); */ + if ( ((GD_flip(g) == FALSE) && (ND_order(aghead(e)) < ND_order(agtail(e)))) || + ( GD_flip(g)) && (ND_order(aghead(e)) > ND_order(agtail(e)) )) { + assert(constraining_flat_edge(g,v,e) == FALSE); delete_flat_edge(e); j--; flat_rev(g, e); @@ -1654,7 +1662,7 @@ void check_rs(graph_t * g, int null_ok) int i, r; node_t *v, *prev; - fprintf(stderr, "\n\n%s:\n", g->name); + fprintf(stderr, "\n\n%s:\n", agnameof(g)); for (r = GD_minrank(g); r <= GD_maxrank(g); r++) { fprintf(stderr, "%d: ", r); prev = NULL; @@ -1665,7 +1673,7 @@ void check_rs(graph_t * g, int null_ok) if (null_ok == FALSE) abort(); } else { - fprintf(stderr, "%s(%d)\t", v->name, ND_mval(v)); + fprintf(stderr, "%s(%d)\t", agnameof(v), ND_mval(v)); assert(ND_rank(v) == r); assert(v != prev); prev = v; @@ -1722,7 +1730,7 @@ void check_exchange(node_t * v, node_t * w) r = ND_rank(v); for (i = ND_order(v) + 1; i < ND_order(w); i++) { - u = GD_rank(v->graph)[r].v[i]; + u = GD_rank(agraphof(v))[r].v[i]; if (ND_clust(u)) abort(); } diff --git a/lib/dotgen/position.c b/lib/dotgen/position.c index 6f3d9cbcf..68e88cd53 100644 --- a/lib/dotgen/position.c +++ b/lib/dotgen/position.c @@ -47,7 +47,8 @@ dumpNS (graph_t * g) el = ND_out(n); for (i = 0; i < el.size; i++) { e = el.list[i]; - fprintf (stderr, "%s(%x) -> %s(%x) : %d\n", agtail(e)->name,agtail(e), aghead(e)->name, aghead(e), + fprintf (stderr, "%s(%x) -> ", agnameof(agtail(e)),agtail(e)); + fprintf (stderr, "%s(%x) : %d\n", agnameof(aghead(e)), aghead(e), ED_minlen(e)); } n = ND_next(n); diff --git a/lib/fdpgen/dbg.c b/lib/fdpgen/dbg.c index 912de7871..8fa8e3940 100644 --- a/lib/fdpgen/dbg.c +++ b/lib/fdpgen/dbg.c @@ -46,6 +46,12 @@ void prIndent(void) fputs(" ", stderr); } +void prEdge(edge_t *e,char *s) +{ + fprintf(stderr,"%s --", agnameof(agtail(e))); + fprintf(stderr,"%s%s", agnameof(aghead(e)),s); +} + static void dumpBB(graph_t * g) { boxf bb; @@ -73,7 +79,7 @@ static void dumpSG(graph_t * g) for (i = 1; i <= GD_n_cluster(g); i++) { subg = (GD_clust(g))[i]; prIndent(); - fprintf(stderr, " subgraph %s : %d nodes\n", subg->name, + fprintf(stderr, " subgraph %s : %d nodes\n", agnameof(subg), agnnodes(subg)); dumpBB(subg); incInd (); @@ -96,27 +102,26 @@ void dumpE(graph_t * g, int derived) int deg; prIndent(); - fprintf(stderr, "Graph %s : %d nodes %d edges\n", g->name, agnnodes(g), + fprintf(stderr, "Graph %s : %d nodes %d edges\n", agnameof(g), agnnodes(g), agnedges(g)); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { deg = 0; for (e = agfstout(g, n); e; e = agnxtout(g, e)) { deg++; prIndent(); - fprintf(stderr, " %s -- %s\n", e->tail->name, e->head->name); + prEdge(e,"\n"); if (derived) { for (i = 0, ep = (Agedge_t **) ED_to_virt(e); i < ED_count(e); i++, ep++) { el = *ep; prIndent(); - fprintf(stderr, " %s -- %s\n", el->tail->name, - el->head->name); + prEdge(el,"\n"); } } } if (deg == 0) { /* no out edges */ if (!agfstin(g, n)) /* no in edges */ - fprintf(stderr, " %s\n", n->name); + fprintf(stderr, " %s\n", agnameof(n)); } } if (!derived) { @@ -125,8 +130,8 @@ void dumpE(graph_t * g, int derived) int sz = NPORTS(g); fprintf(stderr, " %d ports\n", sz); while (pp->e) { - fprintf(stderr, " %s : %s -- %s\n", pp->n->name, - pp->e->tail->name, pp->e->head->name); + fprintf(stderr, " %s : ", agnameof(pp->n)); + prEdge(pp->e,"\n"); pp++; } } @@ -145,7 +150,7 @@ void dump(graph_t * g, int level, int doBB) if (Verbose < level) return; prIndent(); - fprintf(stderr, "Graph %s : %d nodes\n", g->name, agnnodes(g)); + fprintf(stderr, "Graph %s : %d nodes\n", agnameof(g), agnnodes(g)); dumpBB(g); if (Verbose > level) { incInd(); @@ -163,11 +168,11 @@ void dump(graph_t * g, int level, int doBB) bb.UR.x = bb.LL.x + w; bb.UR.y = bb.LL.y + h; fprintf(stderr, "%s: (%f,%f) ((%f,%f) , (%f,%f))\n", - n->name, pos.x, pos.y, bb.LL.x, bb.LL.y, bb.UR.x, + agnameof(n), pos.x, pos.y, bb.LL.x, bb.LL.y, bb.UR.x, bb.UR.y); } else { fprintf(stderr, "%s: (%f,%f) (%f,%f) \n", - n->name, pos.x, pos.y, w, h); + agnameof(n), pos.x, pos.y, w, h); } } } @@ -269,8 +274,6 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode) Agnode_t *n; Agnode_t *h; Agedge_t *e; - Agnodeinfo_t *data; - Agnodeinfo_t *hdata; double minx, miny, maxx, maxy; double scale, width, height; int do_arrow; @@ -292,22 +295,20 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode) do_arrow = 0; n = agfstnode(g); - data = &(n->u); - minx = data->pos[0]; - miny = data->pos[1]; - maxx = data->pos[0]; - maxy = data->pos[1]; + minx = ND_pos(n)[0]; + miny = ND_pos(n)[1]; + maxx = ND_pos(n)[0]; + maxy = ND_pos(n)[1]; n = agnxtnode(g, n); for (; n; n = agnxtnode(g, n)) { - data = &(n->u); - if (data->pos[0] < minx) - minx = data->pos[0]; - if (data->pos[1] < miny) - miny = data->pos[1]; - if (data->pos[0] > maxx) - maxx = data->pos[0]; - if (data->pos[1] > maxy) - maxy = data->pos[1]; + if (ND_pos(n)[0] < minx) + minx = ND_pos(n)[0]; + if (ND_pos(n)[1] < miny) + miny = ND_pos(n)[1]; + if (ND_pos(n)[0] > maxx) + maxx = ND_pos(n)[0]; + if (ND_pos(n)[1] > maxy) + maxy = ND_pos(n)[1]; } /* Convert to points @@ -382,29 +383,26 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode) for (n = agfstnode(g); n; n = agnxtnode(g, n)) { if (IS_PORT(n)) { double r; - data = &(n->u); - r = sqrt(data->pos[0] * data->pos[0] + - data->pos[1] * data->pos[1]); + r = sqrt(ND_pos(n)[0] * ND_pos(n)[0] + + ND_pos(n)[1] * ND_pos(n)[1]); fprintf(fp, "0 0 %f inch drawCircle\n", r); break; } } for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - data = &(n->u); for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - h = e->head; - hdata = &(h->u); + h = aghead(e); fprintf(fp, "%f inch %f inch moveto %f inch %f inch lineto\n", - data->pos[0], data->pos[1], hdata->pos[0], - hdata->pos[1]); + ND_pos(n)[0], ND_pos(n)[1], ND_pos(h)[0], + ND_pos(h)[1]); fprintf(fp, "stroke\n"); if (do_arrow) { theta = - atan2(data->pos[1] - hdata->pos[1], - data->pos[0] - hdata->pos[0]); + atan2(ND_pos(n)[1] - ND_pos(h)[1], + ND_pos(n)[0] - ND_pos(h)[0]); fprintf(fp, "%f %f %.2f %.2f %.2f doArrow\n", - hdata->pos[0], hdata->pos[1], DEGREES(theta), + ND_pos(h)[0], ND_pos(h)[1], DEGREES(theta), arrow_l, arrow_w); } @@ -423,18 +421,17 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode) } #else for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - data = &(n->u); - fprintf(fp, "%% %s\n", n->name); + fprintf(fp, "%% %s\n", agnameof(n)); if (expMode) { double wd, ht; double r; - wd = data->width; - ht = data->height; + wd = ND_width(n); + ht = ND_height(n); r = sqrt((wd * wd / 4) + ht * ht / 4); fprintf(fp, "%f inch %f inch %f inch %f inch doBox\n", wd, ht, - data->pos[0] - (wd / 2), data->pos[1] - (ht / 2)); + ND_pos(n)[0] - (wd / 2), ND_pos(n)[1] - (ht / 2)); fprintf(fp, "%f inch %f inch %f inch drawCircle\n", - data->pos[0], data->pos[1], r); + ND_pos(n)[0], ND_pos(n)[1], r); } else { if (IS_PORT(n)) { if (!portColor) { @@ -448,27 +445,25 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode) } } } - fprintf(fp, "%f inch %f inch %f fillCircle\n", data->pos[0], - data->pos[1], 3 / scale); + fprintf(fp, "%f inch %f inch %f fillCircle\n", ND_pos(n)[0], + ND_pos(n)[1], 3 / scale); } #endif fprintf(fp, "0.667 1.000 1.000 sethsbcolor\n"); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - data = &(n->u); for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - h = e->head; - hdata = &(h->u); + h = aghead(e); fprintf(fp, "%f inch %f inch moveto %f inch %f inch lineto\n", - data->pos[0], data->pos[1], hdata->pos[0], - hdata->pos[1]); + ND_pos(n)[0], ND_pos(n)[1], ND_pos(h)[0], + ND_pos(h)[1]); fprintf(fp, "stroke\n"); if (do_arrow) { theta = - atan2(data->pos[1] - hdata->pos[1], - data->pos[0] - hdata->pos[0]); + atan2(ND_pos(n)[1] - ND_pos(h)[1], + ND_pos(n)[0] - ND_pos(h)[0]); fprintf(fp, "%f %f %.2f %.2f %.2f doArrow\n", - hdata->pos[0], hdata->pos[1], DEGREES(theta), + ND_pos(h)[0], ND_pos(h)[1], DEGREES(theta), arrow_l, arrow_w); } diff --git a/lib/fdpgen/dbg.h b/lib/fdpgen/dbg.h index c62bb8ca1..8fd36f9b2 100644 --- a/lib/fdpgen/dbg.h +++ b/lib/fdpgen/dbg.h @@ -22,7 +22,7 @@ extern "C" { #include #include -#include +#include extern double Scale; extern void outputGraph(Agraph_t *, FILE *, int); diff --git a/lib/fdpgen/tlayout.c b/lib/fdpgen/tlayout.c index 9216bc310..120e9e034 100644 --- a/lib/fdpgen/tlayout.c +++ b/lib/fdpgen/tlayout.c @@ -152,7 +152,8 @@ static int init_params(graph_t * g, xparams * xpms) #ifdef DEBUG if (Verbose) { prIndent(); - fprintf(stderr, "tlayout %s(%s) : T0 %f\n", g->name, GORIG(g->root)->name, T_T0); + fprintf(stderr, "tlayout %s", agnameof(g)); + fprintf(stderr, "(%s) : T0 %f\n", agnameof(GORIG(g->root)), T_T0); } #endif ret = 1; @@ -225,7 +226,7 @@ void fdp_initParams(graph_t * g) prIndent(); fprintf(stderr, "Params %s : K %f T0 %f Tfact %f maxIters %d unscaled %d\n", - g->name, + agnameof(g), T_K, T_T0, T_Tfact, T_maxIters, T_unscaled); } #endif diff --git a/lib/fdpgen/xlayout.c b/lib/fdpgen/xlayout.c index 446060c9d..f93bcc33c 100644 --- a/lib/fdpgen/xlayout.c +++ b/lib/fdpgen/xlayout.c @@ -57,6 +57,12 @@ static expand_t X_marg; static double X_nonov; static double X_ov; +void pr2graphs(Agraph_t *g0, Agraph_t *g1) +{ + fprintf(stderr,"%s",agnameof(g0)); + fprintf(stderr,"(%s)",agnameof(g1)); +} + static double RAD(Agnode_t * n) { double w = WD2(n); @@ -81,9 +87,9 @@ static void xinit_params(graph_t* g, int n, xparams * xpms) #ifdef DEBUG if (Verbose) { prIndent(); - fprintf(stderr, - "xLayout %s(%s) : n = %d K = %f T0 = %f loop %d C %f\n", - g->name, GORIG(g->root)->name, + fprintf(stderr, "xLayout "); + pr2graphs(g,GORIG(agroot(g))); + fprintf(stderr, " : n = %d K = %f T0 = %f loop %d C %f\n", xParams.numIters, xParams.K, xParams.T0, xParams.loopcnt, xParams.C); } @@ -476,8 +482,9 @@ static int x_layout(graph_t * g, xparams * pxpms, int tries) #ifdef DEBUG if (Verbose) { prIndent(); - fprintf(stderr, "try %d (%d): %d overlaps on %s(%s) \n", try, tries, ov, - g->name, GORIG(g->root)->name); + fprintf(stderr, "try %d (%d): %d overlaps on ", try, tries, ov); + pr2graphs(g,GORIG(agroot(g))); + fprintf(stderr," \n"); } #endif @@ -494,8 +501,9 @@ static int x_layout(graph_t * g, xparams * pxpms, int tries) } #ifdef DEBUG if (Verbose && ov) - fprintf(stderr, "Warning: %d overlaps remain on %s(%s)\n", ov, - g->name, GORIG(g->root)->name); + fprintf(stderr, "Warning: %d overlaps remain on ", ov); + pr2graphs(g,GORIG(agroot(g))); + fprintf(stderr,"\n"); #endif return ov; diff --git a/lib/neatogen/constraint.c b/lib/neatogen/constraint.c index 7c6411d34..ecb703cfd 100644 --- a/lib/neatogen/constraint.c +++ b/lib/neatogen/constraint.c @@ -188,13 +188,13 @@ validate(graph_t * g) for (n = GD_nlist(g);n; n = ND_next(n)) { assert(outdegree(g,n) == ND_out(n).size); for (i = 0; (e = ND_out(n).list[i]); i++) { - assert(e->tail == n); - assert( e == agfindedge(g, n, e->head)); + assert(agtail(e) == n); + assert( e == agfindedge(g, n, aghead(e))); } assert(indegree(g,n) == ND_in(n).size); for (i = 0; (e = ND_in(n).list[i]); i++) { - assert(e->head == n); - assert( e == agfindedge(g, e->tail, n)); + assert(aghead(e) == n); + assert( e == agfindedge(g, agtail(e), n)); } cnt++; } @@ -580,10 +580,18 @@ static void constrainY(graph_t* g, nitem* nlist, int nnodes, intersectfn ifn, edge_t *e; for (n = agfstnode(cg); n; n = agnxtnode(cg, n)) { sprintf(buf, "%d", ND_rank(n)); +#ifndef WITH_CGRAPH agxset(n, rksym->index, buf); +#else + agxset(n, rksym, buf); +#endif for (e = agfstedge(cg, n); e; e = agnxtedge(cg, e, n)) { sprintf(buf, "%d", ED_minlen(e)); +#ifndef WITH_CGRAPH agxset(e, mlsym->index, buf); +#else + agxset(e, mlsym, buf); +#endif } } }