]> granicus.if.org Git - graphviz/commitdiff
*** empty log message ***
authorellson <devnull@localhost>
Tue, 21 Oct 2008 21:24:34 +0000 (21:24 +0000)
committerellson <devnull@localhost>
Tue, 21 Oct 2008 21:24:34 +0000 (21:24 +0000)
lib/neatogen/adjust.c
lib/neatogen/constraint.c
lib/neatogen/neatoinit.c
lib/neatogen/stress.c
lib/neatogen/stuff.c

index 7730779c972174df5afc16f6e966bd976b0adfee..c1268e229d7d9452289de578f1892b074804c4cc 100644 (file)
@@ -750,8 +750,8 @@ void normalize(graph_t * g)
     if (e == NULL)
        return;
 
-    theta = -atan2(ND_pos(e->head)[1] - ND_pos(e->tail)[1],
-                  ND_pos(e->head)[0] - ND_pos(e->tail)[0]);
+    theta = -atan2(ND_pos(aghead(e))[1] - ND_pos(agtail(e))[1],
+                  ND_pos(aghead(e))[0] - ND_pos(agtail(e))[0]);
 
     for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
        p.x = ND_pos(v)[0];
@@ -832,7 +832,7 @@ removeOverlapAs(graph_t * G, char* flag)
        return 0;
 
     if (Verbose)
-       fprintf(stderr, "Adjusting %s using %s\n", G->name, am->print);
+       fprintf(stderr, "Adjusting %s using %s\n", agnameof(G), am->print);
 
     if (am->mode > AM_SCALE) {
 /* start_timer(); */
index 6b6e7161ce90ad43ca0a5337bfdbbeef5a862968..d796458f342388dd6987fc3059c549d775745178 100644 (file)
@@ -232,7 +232,12 @@ static graph_t *mkNConstraintG(graph_t * g, Dt_t * list,
 
     for (p = (nitem *) dtflatten(list); p;
         p = (nitem *) dtlink(list, (Dtlink_t *) p)) {
-       n = agnode(cg, p->np->name);    /* FIX */
+#ifndef WITH_CGRAPH
+       n = agnode(cg, agnameof(p->np));        /* FIX */
+#else
+       n = agnode(cg, agnameof(p->np), 1);      /* FIX */
+       agbindrec(n, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
+#endif
        ND_alg(n) = p;
        p->cnode = n;
        alloc_elist(0, ND_in(n));
@@ -256,7 +261,11 @@ static graph_t *mkNConstraintG(graph_t * g, Dt_t * list,
                ED_minlen(e) = delta;
                ED_weight(e) = 1;
            }
+#ifndef WITH_CGRAPH
            if (e && agfindedge(g,p->np, nxp->np)) {
+#else /* WITH_CGRAPH */
+           if (e && agedge(g,p->np, nxp->np, (char*)0, 0)) {
+#endif /* WITH_CGRAPH */
                ED_weight(e) = 100;
             }
 #if 0
@@ -280,7 +289,7 @@ static graph_t *mkNConstraintG(graph_t * g, Dt_t * list,
        n = p->cnode;
        for (e = agfstout(cg,n); e; e = agnxtout(cg,e)) {
            elist_append(e, ND_out(n));
-           elist_append(e, ND_in(e->head));
+           elist_append(e, ND_in(aghead(e)));
        }
     }
 
@@ -330,7 +339,12 @@ static graph_t *mkConstraintG(graph_t * g, Dt_t * list,
        if (oldval != p->val) {
            oldval = p->val;
            /* n = newNode (cg); */
-           n = agnode(cg, p->np->name);        /* FIX */
+#ifndef WITH_CGRAPH
+           n = agnode(cg, agnameof(p->np));    /* FIX */
+#else
+           n = agnode(cg, agnameof(p->np), 1); /* FIX */
+           agbindrec(n, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
+#endif
            ND_alg(n) = p;
            if (root) {
                ND_next(lastn) = n;
@@ -369,7 +383,13 @@ static graph_t *mkConstraintG(graph_t * g, Dt_t * list,
     vg = agopen("vg", AGDIGRAPHSTRICT);
     for (p = (nitem *) dtflatten(list); p;
         p = (nitem *) dtlink(list, (Dtlink_t *) p)) {
-       n = agnode(vg, p->np->name);
+#ifndef WITH_CGRAPH
+       n = agnode(vg, agnameof(p->np));     /* FIX */
+#else
+       n = agnode(cg, agnameof(p->np), 1);  /* FIX */
+       agbindrec(cg, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE);  //node custom data
+
+#endif
        p->vnode = n;
        ND_alg(n) = p;
     }
index a19aa168d7c6627c905f51ad8a4ecab20b2de205..b0db754b257ab7bae314e20bc36ed70d2ac04dbc 100644 (file)
@@ -45,6 +45,9 @@ static char *cc_pfx = "_neato_cc";
 
 void neato_init_node(node_t * n)
 {
+#ifdef WITH_CGRAPH
+    agbindrec(n, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE);  //node custom data
+#endif /* WITH_CGRAPH */
     common_init_node(n);
     ND_pos(n) = N_NEW(GD_ndim(n->graph), double);
     gv_nodesize(n, GD_flip(n->graph));
@@ -52,8 +55,13 @@ void neato_init_node(node_t * n)
 
 static void neato_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);
+#ifndef WITH_CGRAPH
 
+#endif /* WITH_CGRAPH */
     ED_factor(e) = late_double(e, E_weight, 1.0, 1.0);
 }
 
@@ -110,7 +118,7 @@ int user_pos(attrsym_t * posptr, attrsym_t * pinptr, node_t * np, int nG)
            return TRUE;
        } else
            agerr(AGERR, "node %s, position %s, expected two doubles\n",
-                 np->name, p);
+                 agnameof(np), p);
     }
     return FALSE;
 }
@@ -122,8 +130,13 @@ static void neato_init_node_edge(graph_t * g)
     int nG = agnnodes(g);
     attrsym_t *N_pin;
 
+#ifndef WITH_CGRAPH
     N_pos = agfindattr(g->proto->n, "pos");
     N_pin = agfindattr(g->proto->n, "pin");
+#else
+    N_pos = agattr(g, AGNODE, "pos", 0);
+    N_pin = agattr(g, AGNODE, "pin", 0);
+#endif
 
     for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
        neato_init_node(n);
@@ -441,19 +454,31 @@ static void nop_init_graphs(Agraph_t *, attrsym_t *, attrsym_t *);
 /* dfs:
  */
 static void
+#ifndef WITH_CGRAPH
 dfs(node_t * mn, Agraph_t * g, attrsym_t * G_lp, attrsym_t * G_bb)
+#else /* WITH_CGRAPH */
+dfs(Agraph_t * subg, Agraph_t * g, attrsym_t * G_lp, attrsym_t * G_bb)
+#endif /* WITH_CGRAPH */
 {
     graph_t *subg;
 
+#ifndef WITH_CGRAPH
     subg = agusergraph(mn);
-    if (!strncmp(subg->name, "cluster", 7) && chkBB(subg, G_bb)) {
+#endif
+    if (!strncmp(agnameof(subg), "cluster", 7) && chkBB(subg, G_bb)) {
        add_cluster(g, subg);
        nop_init_graphs(subg, G_lp, G_bb);
     } else {
+#ifndef WITH_CGRAPH
        graph_t *mg = g->meta_node->graph;
        edge_t *me;
        for (me = agfstout(mg, mn); me; me = agnxtout(mg, me)) {
            dfs(me->head, g, G_lp, G_bb);
+#else
+       graph_t *mg;
+       for (mg = agfstsubg(g); subg; subg = agnxtsubg(subg)) {
+           dfs(mg, g, G_lp, G_bb);
+#endif
        }
     }
 }
@@ -466,13 +491,21 @@ dfs(node_t * mn, Agraph_t * g, attrsym_t * G_lp, attrsym_t * G_bb)
 static void
 nop_init_graphs(Agraph_t * g, attrsym_t * G_lp, attrsym_t * G_bb)
 {
+#ifndef WITH_CGRAPH
     graph_t *mg;
     edge_t *me;
+#else
+    graph_t *subg;
+#endif
     char *s;
     double x, y;
 
     if (GD_label(g) && G_lp) {
+#ifndef WITH_CGRAPH
        s = agxget(g, G_lp->index);
+#else
+       s = agxget(g, G_lp);
+#endif
        if (sscanf(s, "%lf,%lf", &x, &y) == 2) {
            GD_label(g)->pos = pointfof(x, y);
            GD_label(g)->set = TRUE;
@@ -481,9 +514,14 @@ nop_init_graphs(Agraph_t * g, attrsym_t * G_lp, attrsym_t * G_bb)
 
     if (!G_bb)
        return;
+#ifndef WITH_CGRAPH
     mg = g->meta_node->graph;
     for (me = agfstout(mg, g->meta_node); me; me = agnxtout(mg, me)) {
        dfs(me->head, g, G_lp, G_bb);
+#else /* WITH_CGRAPH */
+    for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) {
+       dfs(subg, g, G_lp, G_bb);
+#endif /* WITH_CGRAPH */
     }
 }
 
@@ -590,18 +628,27 @@ int init_nop(Agraph_t * g, int adjust)
     int i;
     node_t *np;
     pos_edge posEdges;         /* How many edges have spline info */
+#ifndef WITH_CGRAPH
     attrsym_t *G_lp = agfindattr(g, "lp");
     attrsym_t *G_bb = agfindattr(g, "bb");
+#else /* WITH_CGRAPH */
+    attrsym_t *G_lp = agattr(g,AGRAPH, "lp",(char*)0);
+    attrsym_t *G_bb = agattr(g, AGRAPH,"bb",(char*)0);
+#endif /* WITH_CGRAPH */
 
     /* If G_bb not defined, define it */
     if (!G_bb)
+#ifndef WITH_CGRAPH
        G_bb = agraphattr(g, "bb", "");
+#else /* WITH_CGRAPH */
+       G_bb = agattr(g, AGRAPH,"bb", "",1);
+#endif /* WITH_CGRAPH */
 
     scan_graph(g);             /* mainly to set up GD_neato_nlist */
     for (i = 0; (np = GD_neato_nlist(g)[i]); i++) {
-       if (!hasPos(np) && strncmp(np->name, "cluster", 7)) {
+       if (!hasPos(np) && strncmp(agnameof(np), "cluster", 7)) {
            agerr(AGERR, "node %s in graph %s has no position\n",
-                 np->name, g->name);
+                 agnameof(np), agnameof(g));
            return 1;
        }
     }
@@ -645,8 +692,13 @@ static void neato_init_graph (Agraph_t * g)
     int outdim;
 
     setEdgeType (g, ET_LINE);
+#ifndef WITH_CGRAPH
     outdim = late_int(g, agfindattr(g, "dimen"), 2, 2);
     GD_ndim(g->root) = late_int(g, agfindattr(g, "dim"), outdim, 2);
+#else /* WITH_CGRAPH */
+    outdim = late_int(g, agattr(g,AGRAPH, "dimen",(char*)0), 2, 2);
+    GD_ndim(g->root) = late_int(g, agattr(g,AGRAPH, "dim",(char*)0), outdim, 2);
+#endif /* WITH_CGRAPH */
     Ndim = GD_ndim(g->root) = MIN(GD_ndim(g->root), MAXDIM);
     GD_odim(g->root) = MIN(outdim, Ndim);
     neato_init_node_edge(g);
@@ -669,7 +721,7 @@ static int neatoModel(graph_t * g)
     }
     agerr(AGWARN,
          "Unknown value %s for attribute \"model\" in graph %s - ignored\n",
-         p, g->name);
+         p, agnameof(g));
     return MODEL_SHORTPATH;
 }
 
@@ -697,7 +749,7 @@ static int neatoMode(graph_t * g)
        else
            agerr(AGWARN,
                  "Illegal value %s for attribute \"mode\" in graph %s - ignored\n",
-                 str, g->name);
+                 str, agnameof(g));
     }
 
     return mode;
@@ -708,8 +760,8 @@ static int neatoMode(graph_t * g)
  */
 static int checkEdge(PointMap * pm, edge_t * ep, int idx)
 {
-    int i = ND_id(ep->tail);
-    int j = ND_id(ep->head);
+    int i = ND_id(agtail(ep));
+    int j = ND_id(aghead(ep));
     int tmp;
 
     if (i > j) {
@@ -817,7 +869,12 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m
        haveLen = FALSE;
        haveWt = FALSE;
     } else {
+#ifndef WITH_CGRAPH
        haveLen = (agindex(g->root->proto->e, "len") >= 0);
+#else /* WITH_CGRAPH */
+       haveLen = agattr(g,AGEDGE,"len",(char*)0) ;
+//     haveLen = (agindex(g->root->proto->e, "len") >= 0);
+#endif /* WITH_CGRAPH */
        haveWt = (E_weight != 0);
     }
     if (mode == MODE_HIER || mode == MODE_IPSEP)
@@ -863,7 +920,7 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m
        i_nedges = 1;           /* one for the self */
 
        for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) {
-           if (ep->head == ep->tail)
+           if (aghead(ep) == agtail(ep))
                continue;       /* ignore loops */
            idx = checkEdge(ps, ep, j);
            if (idx != j) {     /* seen before */
@@ -874,7 +931,7 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m
                    graph[i].ewgts[idx] = MAX(ED_dist(ep), curlen);
                }
            } else {
-               node_t *vp = (((ep->tail) == np) ? ep->head : ep->tail);
+               node_t *vp = (((agtail(ep)) == np) ? aghead(ep) : agtail(ep));
                ne++;
                j++;
 
@@ -891,7 +948,7 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m
                     if(s&&!strncmp(s,"none",4)) {
                         *edists++ = 0;
                     } else {
-                        *edists++ = (np == ep->head ? 1.0 : -1.0);
+                        *edists++ = (np == aghead(ep) ? 1.0 : -1.0);
                     }
                 }
 #endif
@@ -1096,6 +1153,7 @@ majorization(graph_t *mg, graph_t * g, int nv, int mode, int model, int dim, int
     int init;
 
     init = checkStart(g, nv, (mode == MODE_HIER ? INIT_SELF : INIT_RANDOM));
+
     coords = N_GNEW(dim, double *);
     coords[0] = N_GNEW(nv * dim, double);
     for (i = 1; i < Ndim; i++) {
@@ -1106,6 +1164,11 @@ majorization(graph_t *mg, graph_t * g, int nv, int mode, int model, int dim, int
                model, (init == INIT_SELF), MaxIter, Epsilon);
        fprintf(stderr, "convert graph: ");
        start_timer();
+#ifdef WITH_CGRAPH
+        fprintf(stderr, "majorization\n");
+       fprintf(stderr, "%i\n",count_nodes(g));
+
+#endif /* WITH_CGRAPH */
     }
     gp = makeGraphData(g, nv, &ne, mode, model, &nodes);
 
@@ -1115,7 +1178,11 @@ majorization(graph_t *mg, graph_t * g, int nv, int mode, int model, int dim, int
 
 #ifdef DIGCOLA
     if (mode != MODE_MAJOR) {
+#ifndef WITH_CGRAPH
         double lgap = late_double(g, agfindattr(g, "levelsgap"), 0.0, -MAXDOUBLE);
+#else /* WITH_CGRAPH */
+        double lgap = late_double(g, agattr(g,AGRAPH, "levelsgap",(char*)0), 0.0, -MAXDOUBLE);
+#endif /* WITH_CGRAPH */
         if (mode == MODE_HIER) {        
             stress_majorization_with_hierarchy(gp, nv, ne, coords, nodes, Ndim,
                        (init == INIT_SELF), model, MaxIter, lgap);
@@ -1230,7 +1297,7 @@ static void kkNeato(Agraph_t * g, int nG, int model)
        if (!circuit_model(g, nG)) {
            agerr(AGWARN,
                  "graph %s is disconnected. Hence, the circuit model\n",
-                 g->name);
+                 agnameof(g));
            agerr(AGPREV,
                  "is undefined. Reverting to the shortest path model.\n");
            agerr(AGPREV,
@@ -1268,6 +1335,10 @@ void neatoLayout(Agraph_t * mg, Agraph_t * g, int layoutMode, int layoutModel)
     nG = scan_graph_mode(g, layoutMode);
     if ((nG < 2) || (MaxIter <=0))
        return;
+#ifdef WITH_CGRAPH
+    if (Verbose) {
+       fprintf(stderr, "%i\n",count_nodes(g));
+#endif /* WITH_CGRAPH */
     if (layoutMode)
        majorization(mg, g, nG, layoutMode, layoutModel, Ndim, MaxIter);
     else
@@ -1287,7 +1358,11 @@ addZ (Agraph_t* g)
     if ((Ndim >= 3) && N_z) { 
        for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
            sprintf(buf, "%d", POINTS(ND_pos(n)[2]));
+#ifndef WITH_CGRAPH
            agxset(n, N_z->index, buf);
+#else /* WITH_CGRAPH */
+           agxset(n, N_z, buf);
+#endif /* WITH_CGRAPH */
        }
     }
 }
index 12754cdb8c9ce7e38c6bc35c7dd71b1d13f2613e..f1369a73c8f88eb1ea809ada9620a34715c19318 100644 (file)
@@ -1819,10 +1819,19 @@ int stress_majorization_kD_mkernel(vtx_data * graph,    /* Input graph in sparse re
                compute_stressf(coords, lap2, dim, n),
                iterations, elapsed_sec());
     }
+#ifdef WITH_CGRAPH
+    if (Verbose)
+       fprintf (stderr, "coords\n");
+#endif /* WITH_CGRAPH */
 
     for (i = 0; i < dim; i++) {
        for (j = 0; j < n; j++) {
            d_coords[i][j] = coords[i][j];
+#ifdef WITH_CGRAPH
+            if (Verbose)
+               fprintf (stderr, "%d\n",coords[i][j]);
+                       
+#endif /* WITH_CGRAPH */
        }
     }
     free(coords[0]);
index 1c5c1b70ec4d392c6da1b2c36168cb12845e9d1c..52fc465051c10f45e453387621eb3265a44e3e4e 100644 (file)
@@ -194,9 +194,12 @@ static double setEdgeLen(graph_t * G, node_t * np, int lenx)
 {
     edge_t *ep;
     double total_len = 0.0;
-    double len;
+    double len=0;
+
     for (ep = agfstout(G, np); ep; ep = agnxtout(G, ep)) {
+#ifndef WITH_CGRAPH
        len = doubleattr(ep, lenx, 1.0);
+#endif /* WITH_CGRAPH */
        if (len <= 0) {
            agerr(AGERR, "bad edge len %f in %s ignored\n", len, G->name);
            len = 1.0;
@@ -219,6 +222,9 @@ int scan_graph_mode(graph_t * G, int mode)
     char *str;
     node_t *np, *xp, *other;
     double total_len = 0.0;
+#ifdef WITH_CGRAPH
+    int c=0;
+#endif /* WITH_CGRAPH */
 
     if (Verbose)
        fprintf(stderr, "Scanning graph %s, %d nodes\n", G->name,
@@ -237,6 +243,7 @@ int scan_graph_mode(graph_t * G, int mode)
            }
        }
     }
+
     nV = agnnodes(G);
     nE = agnedges(G);
 
@@ -287,16 +294,16 @@ int scan_graph(graph_t * g)
 
 void free_scan_graph(graph_t * g)
 {
-    /* int  nG; */
+#ifndef WITH_CGRAPH
     free(GD_neato_nlist(g));
     if (!Nop) {
        free_array(GD_dist(g));
        free_array(GD_spring(g));
        free_array(GD_sum_t(g));
-       /* nG = agnnodes(g); */
        free_3array(GD_t(g));
        GD_t(g) = NULL;
     }
+#endif /* WITH_CGRAPH */
 }
 
 void jitter_d(node_t * np, int nG, int n)
@@ -361,8 +368,13 @@ void diffeq_model(graph_t * G, int nG)
        for (j = 0; j < i; j++) {
            f = Spring_coeff / (D[i][j] * D[i][j]);
            if ((e =
+#ifndef WITH_CGRAPH
                 agfindedge(G, GD_neato_nlist(G)[i],
                            GD_neato_nlist(G)[j])))
+#else /* WITH_CGRAPH */
+                agedge(G, GD_neato_nlist(G)[i],
+                           GD_neato_nlist(G)[j],(char*)0,0)))
+#endif /* WITH_CGRAPH */
                f = f * ED_factor(e);
            K[i][j] = K[j][i] = f;
        }