From: ellson Date: Thu, 23 Oct 2008 04:05:44 +0000 (+0000) Subject: cgraph fixes X-Git-Tag: LAST_LIBGRAPH~32^2~2995 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33996cb44e37237844a8f6c856bf636ff9b63743;p=graphviz cgraph fixes --- diff --git a/lib/neatogen/multispline.c b/lib/neatogen/multispline.c index c83b02af3..e481b1d5c 100644 --- a/lib/neatogen/multispline.c +++ b/lib/neatogen/multispline.c @@ -779,7 +779,7 @@ finishEdge (edge_t* e, Ppoly_t spl, int flip, pointf p, pointf q) } if (Verbose > 1) fprintf(stderr, "spline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); - clip_and_install(e, e->head, spline, spl.pn, &sinfo); + clip_and_install(e, aghead(e), spline, spl.pn, &sinfo); free(spline); addEdgeLabels(e, p1, q1); @@ -850,14 +850,14 @@ genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline) Pedge_t *medges = N_GNEW(trip->poly.pn, Pedge_t); int pn; int mult = ED_count(e); - node_t* head = e->head; + node_t* head = aghead(e); eps[0].x = trip->poly.ps[s].x, eps[0].y = trip->poly.ps[s].y; eps[1].x = trip->poly.ps[t].x, eps[1].y = trip->poly.ps[t].y; Pshortestpath(&(trip->poly), eps, &pl); if (pl.pn == 2) { - makeStraightEdge(head->graph, e, doPolyline); + makeStraightEdge(agraphof(head), e, doPolyline); return 0; } @@ -872,7 +872,7 @@ genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline) } tweakPath (poly, s, t, pl); Proutespline(medges, poly.pn, pl, evs, &spl); - finishEdge (e, spl, e->head != head, eps[0], eps[1]); + finishEdge (e, spl, aghead(e) != head, eps[0], eps[1]); free(medges); return 0; @@ -915,7 +915,7 @@ genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline) tweakPath (poly, 0, pl.pn-1, mmpl); Proutespline(medges, poly.pn, mmpl, evs, &spl); } - finishEdge (e, spl, e->head != head, eps[0], eps[1]); + finishEdge (e, spl, aghead(e) != head, eps[0], eps[1]); e = ED_to_virt(e); } @@ -1299,8 +1299,8 @@ triPath(tgraph * g, int n, int v0, int v1, PQ * pq) int makeMultiSpline(edge_t* e, router_t * rtr, int doPolyline) { Ppolyline_t line = ED_path(e); - node_t *t = e->tail; - node_t *h = e->head; + node_t *t = agtail(e); + node_t *h = aghead(e); pointf t_p = line.ps[0]; pointf h_p = line.ps[line.pn - 1]; tripoly_t *poly; diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index 06adcc170..023acf8c8 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -23,6 +23,8 @@ #ifndef WIN32 #include #endif +#include + #include "neato.h" #include "pack.h" #include "stress.h" @@ -31,7 +33,6 @@ #endif #include "kkutils.h" #include "pointset.h" -#include #ifndef HAVE_SRAND48 #define srand48 srand @@ -49,8 +50,8 @@ void neato_init_node(node_t * n) 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)); + ND_pos(n) = N_NEW(GD_ndim(agraphof(n)), double); + gv_nodesize(n, GD_flip(agraphof(n))); } static void neato_init_edge(edge_t * e) @@ -74,7 +75,11 @@ int user_pos(attrsym_t * posptr, attrsym_t * pinptr, node_t * np, int nG) if (posptr == NULL) return FALSE; pvec = ND_pos(np); +#ifndef WITH_CGRAPH p = agxget(np, posptr->index); +#else + p = agxget(np, posptr); +#endif if (p[0]) { c = '\0'; if ((Ndim >= 3) && @@ -87,8 +92,11 @@ int user_pos(attrsym_t * posptr, attrsym_t * pinptr, node_t * np, int nG) } if (Ndim > 3) jitter_d(np, nG, 3); - if ((c == '!') - || (pinptr && mapbool(agxget(np, pinptr->index)))) +#ifndef WITH_CGRAPH + if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr->index)))) +#else + if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr)))) +#endif ND_pinned(np) = P_PIN; return TRUE; } @@ -100,8 +108,11 @@ int user_pos(attrsym_t * posptr, attrsym_t * pinptr, node_t * np, int nG) pvec[i] = pvec[i] / PSinputscale; } if (Ndim > 2) { - if (N_z && (p = agxget(np, N_z->index)) && - (sscanf(p,"%lf",&z) == 1)) { +#ifndef WITH_CGRAPH + if (N_z && (p = agxget(np, N_z->index)) && (sscanf(p,"%lf",&z) == 1)) { +#else + if (N_z && (p = agxget(np, N_z)) && (sscanf(p,"%lf",&z) == 1)) { +#endif if (PSinputscale > 0.0) { pvec[2] = z / PSinputscale; } @@ -112,8 +123,11 @@ int user_pos(attrsym_t * posptr, attrsym_t * pinptr, node_t * np, int nG) else jitter3d(np, nG); } - if ((c == '!') - || (pinptr && mapbool(agxget(np, pinptr->index)))) +#ifndef WITH_CGRAPH + if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr->index)))) +#else + if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr)))) +#endif ND_pinned(np) = P_PIN; return TRUE; } else @@ -205,11 +219,13 @@ static void set_elabel(edge_t * e, textlabel_t * l, char *name) #ifdef IPSEPCOLA static cluster_data* cluster_map(graph_t *mastergraph, graph_t *g) { +#ifndef WITH_CGRAPH /* search meta-graph to find clusters */ - graph_t *mg, *subg; node_t *mm, *mn; - node_t *n; edge_t *me; +#endif + graph_t *mg, *subg; + node_t *n; /* array of arrays of node indices in each cluster */ int **cs,*cn; int i,j,nclusters=0; @@ -217,12 +233,16 @@ static cluster_data* cluster_map(graph_t *mastergraph, graph_t *g) cluster_data *cdata = GNEW(cluster_data); cdata->ntoplevel = agnnodes(g); + mg = agraphof(mastergraph); +#ifndef WITH_CGRAPH mm = mastergraph->meta_node; - mg = mm->graph; for (me = agfstout(mg, mm); me; me = agnxtout(mg, me)) { - mn = me->head; + mn = aghead(me); subg = agusergraph(mn); - if (!strncmp(subg->name, "cluster", 7)) { +#else + for (subg = agfstsubg(mastergraph); subg; subg = agnxtsubg(subg)) { +#endif + if (!strncmp(agnameof(subg), "cluster", 7)) { nclusters++; } } @@ -230,12 +250,16 @@ static cluster_data* cluster_map(graph_t *mastergraph, graph_t *g) cdata->nclusters = nclusters; cs = cdata->clusters = N_GNEW(nclusters,int*); cn = cdata->clustersizes = N_GNEW(nclusters,int); +#ifndef WITH_CGRAPH /* fprintf(stderr,"search %d clusters...\n",nclusters); */ for (me = agfstout(mg, mm); me; me = agnxtout(mg, me)) { mn = me->head; subg = agusergraph(mn); +#else + for (subg = agfstsubg(mg); subg; subg = agnxtsubg(subg)) { +#endif /* clusters are processed by separate calls to ordered_edges */ - if (!strncmp(subg->name, "cluster", 7)) { + if (!strncmp(agnameof(subg), "cluster", 7)) { int *c; *cn = agnnodes(subg); @@ -246,10 +270,10 @@ static cluster_data* cluster_map(graph_t *mastergraph, graph_t *g) node_t *gn; int ind = 0; for (gn = agfstnode(g); gn; gn = agnxtnode(g, gn)) { - if(gn->id==n->id) break; + if(AGID(gn)==AGID(n)) break; ind++; } - /* fprintf(stderr," node=%s, id=%d, ind=%d\n",n->name,n->id,ind); */ + /* fprintf(stderr," node=%s, id=%d, ind=%d\n",agnameof(n),n->id,ind); */ *c++=ind; assigned[ind]=TRUE; cdata->ntoplevel--; @@ -298,7 +322,11 @@ static int user_spline(attrsym_t * E_pos, edge_t * e) int more = 1; int stype, etype; +#ifndef WITH_CGRAPH pos = agxget(e, E_pos->index); +#else + pos = agxget(e, E_pos); +#endif if (*pos == '\0') return 0; @@ -395,7 +423,11 @@ static pos_edge nop_init_edges(Agraph_t * g) node_t *n; edge_t *e; int nedges = 0; +#ifndef WITH_CGRAPH attrsym_t *E_pos = agfindattr(g->proto->e, "pos"); +#else + attrsym_t *E_pos = agattr(g, AGEDGE, "pos", NULL); +#endif if (!E_pos || (Nop < 2)) return NoEdges; @@ -427,7 +459,11 @@ static int chkBB(Agraph_t * g, attrsym_t * G_bb) char *s; boxf bb; +#ifndef WITH_CGRAPH s = agxget(g, G_bb->index); +#else + s = agxget(g, G_bb); +#endif if (sscanf(s, BS, &bb.LL.x, &bb.LL.y, &bb.UR.x, &bb.UR.y) == 4) { if (bb.LL.y > bb.UR.y) { /* If the LL.y coordinate is bigger than the UR.y coordinate, @@ -465,10 +501,9 @@ dfs(node_t * mn, Agraph_t * g, attrsym_t * G_lp, attrsym_t * G_bb) 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); + graph_t *subg = agusergraph(mn); #endif if (!strncmp(agnameof(subg), "cluster", 7) && chkBB(subg, G_bb)) { add_cluster(g, subg); @@ -637,8 +672,8 @@ int init_nop(Agraph_t * g, int adjust) 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); + attrsym_t *G_lp = agattr(g, AGRAPH, "lp", NULL); + attrsym_t *G_bb = agattr(g, AGRAPH, "bb", NULL); #endif /* WITH_CGRAPH */ /* If G_bb not defined, define it */ @@ -646,7 +681,7 @@ int init_nop(Agraph_t * g, int adjust) #ifndef WITH_CGRAPH G_bb = agraphattr(g, "bb", ""); #else /* WITH_CGRAPH */ - G_bb = agattr(g, AGRAPH,"bb", "",1); + G_bb = agattr(g, AGRAPH, "bb", ""); #endif /* WITH_CGRAPH */ scan_graph(g); /* mainly to set up GD_neato_nlist */ @@ -701,8 +736,8 @@ static void neato_init_graph (Agraph_t * g) 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); + outdim = late_int(g, agattr(g, AGRAPH, "dimen", NULL), 2, 2); + GD_ndim(g->root) = late_int(g, agattr(g, AGRAPH, "dim", NULL), outdim, 2); #endif /* WITH_CGRAPH */ Ndim = GD_ndim(g->root) = MIN(GD_ndim(g->root), MAXDIM); GD_odim(g->root) = MIN(outdim, Ndim); @@ -863,7 +898,11 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m #ifdef DIGCOLA float *edists = NULL; #endif +#ifndef WITH_CGRAPH int haveLen; +#else + attrsym_t *haveLen; +#endif int haveWt; int haveDir; PointMap *ps = newPM(); @@ -877,8 +916,7 @@ static vtx_data *makeGraphData(graph_t * g, int nv, int *nedges, int mode, int m #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); + haveLen = agattr(g, AGEDGE, "len", 0) ; #endif /* WITH_CGRAPH */ haveWt = (E_weight != 0); } @@ -1115,7 +1153,7 @@ void dumpData(graph_t * g, vtx_data * gp, int nv, int ne) fprintf(stderr, "n %d e %d\n", nv, ne); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { - fprintf(stderr, "\"%s\" %d\n", v->name, ND_id(v)); + fprintf(stderr, "\"%s\" %d\n", agnameof(v), ND_id(v)); } for (i = 0; i < nv; i++) { n = gp[i].nedges; @@ -1171,7 +1209,7 @@ majorization(graph_t *mg, graph_t * g, int nv, int mode, int model, int dim, int start_timer(); #ifdef WITH_CGRAPH fprintf(stderr, "majorization\n"); - fprintf(stderr, "%i\n",count_nodes(g)); +// fprintf(stderr, "%i\n", count_nodes(g)); #endif /* WITH_CGRAPH */ } @@ -1186,7 +1224,7 @@ majorization(graph_t *mg, graph_t * g, int nv, int mode, int model, int dim, int #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); + double lgap = late_double(g, agattr(g, AGRAPH, "levelsgap", NULL), 0.0, -MAXDOUBLE); #endif /* WITH_CGRAPH */ if (mode == MODE_HIER) { stress_majorization_with_hierarchy(gp, nv, ne, coords, nodes, Ndim, @@ -1341,8 +1379,8 @@ void neatoLayout(Agraph_t * mg, Agraph_t * g, int layoutMode, int layoutModel) if ((nG < 2) || (MaxIter <=0)) return; #ifdef WITH_CGRAPH - if (Verbose) { - fprintf(stderr, "%i\n",count_nodes(g)); +// if (Verbose) { +// fprintf(stderr, "%i\n", count_nodes(g)); #endif /* WITH_CGRAPH */ if (layoutMode) majorization(mg, g, nG, layoutMode, layoutModel, Ndim, MaxIter); @@ -1354,8 +1392,7 @@ void neatoLayout(Agraph_t * mg, Agraph_t * g, int layoutMode, int layoutModel) * If dimension == 3 and z attribute is declared, * attach z value to nodes if not defined. */ -static void -addZ (Agraph_t* g) +static void addZ (Agraph_t* g) { node_t* n; char buf[BUFSIZ]; @@ -1452,16 +1489,21 @@ void neato_layout(Agraph_t * g) free (cc); #ifdef IPSEPCOLA { - graph_t *mg, *subg; + graph_t *subg; +#ifndef WITH_CGRAPH + graph_t *mg; node_t *mm, *mn; edge_t *me; mm = g->meta_node; - mg = mm->graph; + mg = agraphof(mm); for (me = agfstout(mg, mm); me; me = agnxtout(mg, me)) { - mn = me->head; + mn = aghead(me); subg = agusergraph(mn); - if (!strncmp(subg->name, "cluster", 7)) { - add_cluster(g,subg); +#else + for (subg = agfstsubg(agroot(g)); subg; subg = agnxtsubg(subg)) { +#endif + if (!strncmp(agnameof(subg), "cluster", 7)) { + add_cluster(g, subg); compute_bb(subg); } } diff --git a/lib/neatogen/neatosplines.c b/lib/neatogen/neatosplines.c index 740bcc96c..142158c29 100644 --- a/lib/neatogen/neatosplines.c +++ b/lib/neatogen/neatosplines.c @@ -111,11 +111,11 @@ static void makePortLabels(edge_t * e) { if (ED_head_label(e) && !ED_head_label(e)->set) { place_portlabel(e, TRUE); - updateBB(e->tail->graph, ED_head_label(e)); + updateBB(agraphof(agtail(e)), ED_head_label(e)); } if (ED_tail_label(e) && !ED_tail_label(e)->set) { place_portlabel(e, FALSE); - updateBB(e->tail->graph, ED_tail_label(e)); + updateBB(agraphof(agtail(e)), ED_tail_label(e)); } } @@ -200,7 +200,7 @@ polylineMidpoint (splines* spl, pointf* pp, pointf* pq) */ void addEdgeLabels(edge_t * e, pointf rp, pointf rq) { - int et = EDGE_TYPE (e->head->graph->root); + int et = EDGE_TYPE (agroot(agraphof(aghead(e)))); pointf p, q; pointf d; /* midpoint of segment p-q */ point ld; @@ -252,7 +252,7 @@ void addEdgeLabels(edge_t * e, pointf rp, pointf rq) ED_label(e)->pos.x = spf.x + ld.x; ED_label(e)->pos.y = spf.y + ld.y; ED_label(e)->set = TRUE; - updateBB(e->tail->graph, ED_label(e)); + updateBB(agraphof(agtail(e)), ED_label(e)); } makePortLabels(e); } @@ -335,15 +335,15 @@ static edge_t *equivEdge(Dt_t * map, edge_t * e) edgeitem dummy; edgeitem *ip; - if (e->tail < e->head) { - test.n1 = e->tail; + if (agtail(e) < aghead(e)) { + test.n1 = agtail(e); test.p1 = ED_tail_port(e).p; - test.n2 = e->head; + test.n2 = aghead(e); test.p2 = ED_head_port(e).p; - } else if (e->tail > e->head) { - test.n2 = e->tail; + } else if (agtail(e) > aghead(e)) { + test.n2 = agtail(e); test.p2 = ED_tail_port(e).p; - test.n1 = e->head; + test.n1 = aghead(e); test.p1 = ED_head_port(e).p; } else { pointf hp = ED_head_port(e).p; @@ -363,7 +363,7 @@ static edge_t *equivEdge(Dt_t * map, edge_t * e) } else { test.p1 = test.p2 = tp; } - test.n2 = test.n1 = e->tail; + test.n2 = test.n1 = agtail(e); } dummy.id = test; dummy.e = e; @@ -387,7 +387,7 @@ void makeSelfArcs(path * P, edge_t * e, int stepx) edges1[0] = e; makeSelfEdge(P, edges1, 0, 1, stepx, stepx, &sinfo); if (ED_label(e)) - updateBB(e->tail->graph, ED_label(e)); + updateBB(agraphof(agtail(e)), ED_label(e)); makePortLabels(e); } else { int i; @@ -400,7 +400,7 @@ void makeSelfArcs(path * P, edge_t * e, int stepx) for (i = 0; i < cnt; i++) { e = edges[i]; if (ED_label(e)) - updateBB(e->tail->graph, ED_label(e)); + updateBB(agraphof(agtail(e)), ED_label(e)); makePortLabels(e); } free(edges); @@ -415,8 +415,8 @@ void makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) { pointf dumb[4]; - node_t *n = e->tail; - node_t *head = e->head; + node_t *n = agtail(e); + node_t *head = aghead(e); int e_cnt = ED_count(e); pointf perp; pointf del; @@ -429,7 +429,7 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) p = dumb[1] = dumb[0] = add_pointf(ND_coord(n), ED_tail_port(e).p); q = dumb[2] = dumb[3] = add_pointf(ND_coord(head), ED_head_port(e).p); if (e_cnt == 1) { - clip_and_install(e, e->head, dumb, 4, &sinfo); + clip_and_install(e, aghead(e), dumb, 4, &sinfo); addEdgeLabels(e, p, q); return; } @@ -457,7 +457,7 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) } for (i = 0; i < e_cnt; i++) { - if (e0->head == head) { + if (aghead(e0) == head) { p = dumb[0]; q = dumb[3]; for (j = 0; j < 4; j++) { @@ -480,10 +480,10 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) pts[i] = dumber[i]; } make_polyline (line, &spl); - clip_and_install(e0, e0->head, spl.ps, spl.pn, &sinfo); + clip_and_install(e0, aghead(e0), spl.ps, spl.pn, &sinfo); } else - clip_and_install(e0, e0->head, dumber, 4, &sinfo); + clip_and_install(e0, aghead(e0), dumber, 4, &sinfo); addEdgeLabels(e0, p, q); e0 = ED_to_virt(e0); @@ -648,14 +648,14 @@ getPath(edge_t * e, vconfig_t * vconfig, int chkPts, Ppoly_t ** obs, int pp, qp; Ppoint_t p, q; - p = add_pointf(ND_coord(e->tail), ED_tail_port(e).p); - q = add_pointf(ND_coord(e->head), ED_head_port(e).p); + p = add_pointf(ND_coord(agtail(e)), ED_tail_port(e).p); + q = add_pointf(ND_coord(aghead(e)), ED_head_port(e).p); /* determine the polygons (if any) that contain the endpoints */ pp = qp = POLYID_NONE; if (chkPts) { - pp = ND_lim(e->tail); - qp = ND_lim(e->head); + pp = ND_lim(agtail(e)); + qp = ND_lim(aghead(e)); /* for (i = 0; i < npoly; i++) { if ((pp == POLYID_NONE) && in_poly(*obs[i], p)) @@ -681,8 +681,8 @@ makePolyline(edge_t * e) q0 = line.ps[line.pn - 1]; make_polyline (line, &spl); if (Verbose > 1) - fprintf(stderr, "polyline %s %s\n", e->tail->name, e->head->name); - clip_and_install(e, e->head, spl.ps, spl.pn, &sinfo); + fprintf(stderr, "polyline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); + clip_and_install(e, aghead(e), spl.ps, spl.pn, &sinfo); addEdgeLabels(e, p0, q0); } @@ -725,8 +725,8 @@ void makeSpline(edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts) /* north why did you ever use int coords */ if (Verbose > 1) - fprintf(stderr, "spline %s %s\n", e->tail->name, e->head->name); - clip_and_install(e, e->head, spline.ps, spline.pn, &sinfo); + fprintf(stderr, "spline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); + clip_and_install(e, aghead(e), spline.ps, spline.pn, &sinfo); free(barriers); addEdgeLabels(e, p, q); } @@ -805,8 +805,8 @@ static int _spline_edges(graph_t * g, expand_t* pmargin, int edgetype) /* spline-drawing pass */ for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { -/* fprintf (stderr, "%s -- %s %d\n", e->tail->name, e->head->name, ED_count(e)); */ - node_t *head = e->head; +/* fprintf (stderr, "%s -- %s %d\n", agnameof(agtail(e)), agnameof(aghead(e)), ED_count(e)); */ + node_t *head = aghead(e); if (useEdges && ED_spl(e)) { addEdgeLabels(e, add_pointf(ND_coord(n), ED_tail_port(e).p), @@ -1010,10 +1010,10 @@ static void scaleEdge(edge_t * e, double xf, double yf) bezier *bez; pointf delh, delt; - delh.x = POINTS(ND_pos(e->head)[0] * (xf - 1.0)); - delh.y = POINTS(ND_pos(e->head)[1] * (yf - 1.0)); - delt.x = POINTS(ND_pos(e->tail)[0] * (xf - 1.0)); - delt.y = POINTS(ND_pos(e->tail)[1] * (yf - 1.0)); + delh.x = POINTS(ND_pos(aghead(e))[0] * (xf - 1.0)); + delh.y = POINTS(ND_pos(aghead(e))[1] * (yf - 1.0)); + delt.x = POINTS(ND_pos(agtail(e))[0] * (xf - 1.0)); + delt.y = POINTS(ND_pos(agtail(e))[1] * (yf - 1.0)); bez = ED_spl(e)->list; for (i = 0; i < ED_spl(e)->size; i++) { diff --git a/lib/neatogen/stuff.c b/lib/neatogen/stuff.c index 52fc46505..40e37570c 100644 --- a/lib/neatogen/stuff.c +++ b/lib/neatogen/stuff.c @@ -137,18 +137,18 @@ static int degreeKind(graph_t * g, node_t * n, node_t ** op) node_t *other = NULL; for (ep = agfstedge(g, n); ep; ep = agnxtedge(g, ep, n)) { - if (ep->head == ep->tail) + if (aghead(ep) == agtail(ep)) continue; /* ignore loops */ if (deg == 1) { - if (((ep->tail == n) && (ep->head == other)) || /* ignore multiedge */ - ((ep->tail == other) && (ep->head == n))) + if (((agtail(ep) == n) && (aghead(ep) == other)) || /* ignore multiedge */ + ((agtail(ep) == other) && (aghead(ep) == n))) continue; return 2; } else { /* deg == 0 */ - if (ep->tail == n) - other = ep->head; + if (agtail(ep) == n) + other = aghead(ep); else - other = ep->tail; + other = agtail(ep); *op = other; deg++; } @@ -201,7 +201,7 @@ static double setEdgeLen(graph_t * G, node_t * np, int lenx) 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); + agerr(AGERR, "bad edge len %f in %s ignored\n", len, agnameof(G)); len = 1.0; } ED_dist(ep) = len; @@ -227,7 +227,7 @@ int scan_graph_mode(graph_t * G, int mode) #endif /* WITH_CGRAPH */ if (Verbose) - fprintf(stderr, "Scanning graph %s, %d nodes\n", G->name, + fprintf(stderr, "Scanning graph %s, %d nodes\n", agnameof(G), agnnodes(G)); /* Eliminate singletons and trees */ @@ -367,13 +367,12 @@ void diffeq_model(graph_t * G, int nG) for (i = 0; i < nG; i++) { 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]))) + if ((e = 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))) + if ((e = 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; @@ -449,7 +448,7 @@ void solve_model(graph_t * G, int nG) } if (GD_move(G) == MaxIter) agerr(AGWARN, "Max. iterations (%d) reached on graph %s\n", - MaxIter, G->name); + MaxIter, agnameof(G)); } void update_arrays(graph_t * G, int nG, int i) @@ -597,7 +596,7 @@ void move_node(graph_t * G, int nG, node_t * n) sum += fabs(b[i]); } /* Why not squared? */ sum = sqrt(sum); - fprintf(stderr, "%s %.3f\n", n->name, sum); + fprintf(stderr, "%s %.3f\n", agnameof(n), sum); } } @@ -631,7 +630,7 @@ void heapdown(node_t * v) while ((left = 2 * i + 1) < Heapsize) { right = left + 1; if ((right < Heapsize) - && (Heap[right]->u.dist < Heap[left]->u.dist)) + && (ND_dist(Heap[right]) < ND_dist(Heap[left]))) c = right; else c = left; @@ -711,8 +710,8 @@ void s1(graph_t * G, node_t * node) if (v != Src) make_spring(G, Src, v, ND_dist(v)); for (e = agfstedge(G, v); e; e = agnxtedge(G, e, v)) { - if ((u = e->head) == v) - u = e->tail; + if ((u = agtail(e)) == v) + u = agtail(e); /* FIXME - isn't this redundant? Why the if? */ f = ND_dist(v) + ED_dist(e); if (ND_dist(u) > f) { ND_dist(u) = f;