}
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);
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;
}
}
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;
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);
}
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;
#ifndef WIN32
#include <unistd.h>
#endif
+#include <ctype.h>
+
#include "neato.h"
#include "pack.h"
#include "stress.h"
#endif
#include "kkutils.h"
#include "pointset.h"
-#include <ctype.h>
#ifndef HAVE_SRAND48
#define srand48 srand
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)
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) &&
}
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;
}
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;
}
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
#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;
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++;
}
}
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);
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--;
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;
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;
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,
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);
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 */
#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 */
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);
#ifdef DIGCOLA
float *edists = NULL;
#endif
+#ifndef WITH_CGRAPH
int haveLen;
+#else
+ attrsym_t *haveLen;
+#endif
int haveWt;
int haveDir;
PointMap *ps = newPM();
#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);
}
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;
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 */
}
#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,
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);
* 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];
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);
}
}
{
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));
}
}
*/
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;
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);
}
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;
} else {
test.p1 = test.p2 = tp;
}
- test.n2 = test.n1 = e->tail;
+ test.n2 = test.n1 = agtail(e);
}
dummy.id = test;
dummy.e = e;
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;
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);
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;
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;
}
}
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++) {
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);
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))
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);
}
/* 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);
}
/* 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),
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++) {
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++;
}
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;
#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 */
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;
}
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)
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);
}
}
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;
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;