]> granicus.if.org Git - graphviz/commitdiff
Fixed some flat edge problems, and got DEBUG=1 working again.
authorStephen North <north@research.att.com>
Fri, 8 Feb 2013 22:28:04 +0000 (17:28 -0500)
committerStephen North <north@research.att.com>
Fri, 8 Feb 2013 22:28:04 +0000 (17:28 -0500)
Not sure if backward compatible with old libgraph.

19 files changed:
cmd/tools/gvpack.c
lib/circogen/block.c
lib/circogen/blockpath.c
lib/circogen/blocktree.c
lib/circogen/circular.c
lib/circogen/deglist.c
lib/circogen/edgelist.c
lib/circogen/nodelist.c
lib/common/ns.c
lib/common/routespl.c
lib/dotgen/dotinit.c
lib/dotgen/fastgr.c
lib/dotgen/mincross.c
lib/dotgen/position.c
lib/fdpgen/dbg.c
lib/fdpgen/dbg.h
lib/fdpgen/tlayout.c
lib/fdpgen/xlayout.c
lib/neatogen/constraint.c

index 9d86bc377fa9180f995ca27535a664c4f68664d3..5dad5b4011f4246fadd2199c8e61931700b55915 100644 (file)
@@ -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[])
index 4d3e972992ab5bc0b59874df7e3602d5ff15d4f6..2df9d488e4e8b1ff13416a9e4a9c9980661f6acd 100644 (file)
@@ -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 = "<nil>";
-           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)));
            }
        }
     }
index 5844bc03c88cf8298cd034e417bafbf1cf476597..aef6dc7a65ee12e992d052d68cf6a480de63e633 100644 (file)
@@ -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
index 38193720f7ba81acb83eaf3cb90bbd5ba5f83fca..72942e69473e3ded2759e61ae5bdb4249b4c3c3d 100644 (file)
@@ -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);
 
index 68758a0ed71000b607960645aa522b803ebd3d19..e311003d291dd0ea118c5e2d28ed03b26b3036a4 100644 (file)
@@ -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 = "<P0>";
     if (BLOCK(n))
-       bname = BLOCK(n)->sub_graph->name;
+       bname = agnameof(BLOCK(n)->sub_graph);
     else
        pname = "<B0>";
-    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 = "<ROOT>";
        dist1 = DISTONE(n);
        if (dist1 > 0)
-           name1 = LEAFONE(n)->name;
+           name1 = agnameof(LEAFONE(n));
        else
            name1 = "<null>";
        dist2 = DISTTWO(n);
        if (dist2 > 0)
-           name2 = LEAFTWO(n)->name;
+           name2 = agnameof(LEAFTWO(n));
        else
            name2 = "<null>";
        fprintf(stderr, "%s %s %d %s %d\n", tname, name1, dist1, name2,
index 1ebc82f779946915c19b1d1a669805bd501bffd3..abb86eb0d6eb77b70a0172ff6b1c9107beae87ea 100644 (file)
@@ -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");
     }
index 2240327f99bea100a005fa0a81513f6fb94a87b4..edceac409aad1f30bd0e411804c9a2a691e9ff22 100644 (file)
@@ -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);
 }
index 7b105b947326083bfe28eb41f401a70be18143da..2ef2bff8193c54592d52f0c8d4516505cd818773 100644 (file)
@@ -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);
index 07697ae8eb493c3b1e386e8e6fd424c8814653fb..941648536eb4ebcfc37ff723d7c2ba97b750bfb4 100644 (file)
@@ -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));
        }
     }
 
index ec41a8ed50d5c17be5859509381ef613d4a5fa74..7e66c43815c9cf1b83dc26f51ff732da9de7bb4f 100644 (file)
@@ -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
 
index f4d10019f36ad769c5ff1b7bfe46b31a88665f02..c262503d5ba1bb1e4e2476f39be68d65b91e230b 100644 (file)
@@ -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");
index 23e7fbecbc2ff6f9063a4b07398982c80fa6cfd3..03663b3601921aaff2d36c2893e0c4b97463de9f 100644 (file)
@@ -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);
index a3eb7e32f88ecfe64f8c3f2efcda57f5aff94c52..d7a4eb0d85d3639f6a2c09ae55859e64fb52d098 100644 (file)
 #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();
     }
index 6f3d9cbcfd7c0cdacf4498e7af4dd4d3d9cec0ac..68e88cd53308e795f46a535833c42680d6e50a65 100644 (file)
@@ -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); 
index 912de78715c11e849566e4209e081c873cd3d555..8fa8e3940dec488cd6165b932959fea29273ca64 100644 (file)
@@ -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);
            }
 
index c62bb8ca18526c2a62d18f088dca4794d7bb2ae2..8fd36f9b2752bf485b8c3712b881145bae5ec68a 100644 (file)
@@ -22,7 +22,7 @@ extern "C" {
 
 #include <fdp.h>
 #include <stdio.h>
-#include <graph.h>
+#include <cgraph.h>
 
     extern double Scale;
     extern void outputGraph(Agraph_t *, FILE *, int);
index 9216bc310b5ed029a3da41449d76968857754040..120e9e0341b5eb6b5edd2bf47208c5e0994bd156 100644 (file)
@@ -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
index 446060c9d53f14338786ed8c384af7d9281bdd2a..f93bcc33c8df51e8b8644d5096237156b2ab7874 100644 (file)
@@ -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;
index 7c6411d347663a6fa85c80a1a9b882b9c3fb89ce..ecb703cfd840c12012137edcf353574fe195066e 100644 (file)
@@ -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
            }
        }
     }