Agnode_t *n, *next_n;
par = agparent(g);
- if ((par == NILgraph) && (AGDISC(g, mem)->close)) {
+ if (par == NILgraph && AGDISC(g, mem)->close) {
/* free entire heap */
agmethod_delete(g, g); /* invoke user callbacks */
agfreeid(g, AGRAPH, AGID(g));
obj = arg_obj;
g = agraphof(obj);
rec = aggetrec(obj, recname, FALSE);
- if ((rec == NIL(Agrec_t *)) && (recsize > 0)) {
+ if (rec == NIL(Agrec_t *) && recsize > 0) {
rec = agalloc(g, recsize);
rec->name = agstrdup(g, recname);
objputrec(g, obj, rec);
int i;
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- if ((PARENT(n) == g) && (n != tex) && (n != hex)
- && !IS_CLUST_NODE(n)) {
+ if (PARENT(n) == g && n != tex && n != hex && !IS_CLUST_NODE(n)) {
addObj(l, makeObstacle(n, pm, FALSE));
}
}
for (i = 1; i <= GD_n_cluster(g); i++) {
sg = GD_clust(g)[i];
- if ((sg != tex) && (sg != hex)) {
+ if (sg != tex && sg != hex) {
addObj(l, makeClustObs(sg, pm));
}
}
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
head = aghead(e);
- if ((n == head) && ED_count(e)) { /* self arc */
+ if (n == head && ED_count(e)) { /* self arc */
if (!P) {
P = NEW(path);
P->boxes = N_NEW(agnnodes(g) + 20 * 2 * 9, boxf);
expand_t margin = sepFactor(g);
int pack = getPack (g, CL_OFFSET, CL_OFFSET);
agerr(AGWARN, "compoundEdges: nodes touch - falling back to straight line edges\n");
- if ((pack <= pm->x) || (pack <= pm->y))
+ if (pack <= pm->x || pack <= pm->y)
agerr(AGPREV, "pack value %d is smaller than esep (%.03f,%.03f)\n", pack, pm->x, pm->y);
- else if ((margin.x <= pm->x) || (margin.y <= pm->y))
+ else if (margin.x <= pm->x || margin.y <= pm->y)
agerr(AGPREV, "sep value (%.03f,%.03f) is smaller than esep (%.03f,%.03f)\n",
margin.x, margin.y, pm->x, pm->y);
rv = 1;
/* Check for rotation
*/
- if ((p = agget(g, "rotate")) && (*p != '\0')
- && ((angle = atoi(p)) != 0)) {
+ if ((p = agget(g, "rotate")) && *p != '\0' && (angle = atoi(p)) != 0) {
fprintf(fp, "306 396 translate\n");
fprintf(fp, "%d rotate\n", angle);
fprintf(fp, "-306 -396 translate\n");
if (width > PSWidth) {
if (height > PSHeight) {
scale =
- (PSWidth / width <
+ PSWidth / width <
PSHeight / height ? PSWidth / width : PSHeight /
- height);
+ height;
} else
scale = PSWidth / width;
} else if (height > PSHeight) {
pvec[j] = pvec[j] / PSinputscale;
}
ND_pinned(np) = P_SET;
- if ((c == '!')
+ if (c == '!'
|| (pinsym && mapbool(agxget(np, pinsym))))
ND_pinned(np) = P_PIN;
} else
NOTUSED(d);
NOTUSED(disc);
- if ((diff = (p1->i - p2->i)))
+ if ((diff = p1->i - p2->i))
return diff;
else
- return (p1->j - p2->j);
+ return p1->j - p2->j;
}
static Grid *_grid; /* hack because can't attach info. to Dt_t */
int nsize;
if (nnodes > g->listSize) {
- nsize = MAX(nnodes, 2 * (g->listSize));
+ nsize = MAX(nnodes, 2 * g->listSize);
if (g->listMem)
free(g->listMem);
g->listMem = N_GNEW(nsize, node_list);
key.p.i = i;
key.p.j = j;
- return ((cell *) dtsearch(g->data, &key));
+ return (cell *) dtsearch(g->data, &key);
}
/* gLength:
int margin;
graph_t **cp = cc;
point *pp = pts;
- int isRoot = (rg == infop->rootg);
+ int isRoot = rg == infop->rootg;
int isEmpty = 0;
/* compute graph bounding box in points */
if (g != infop->rootg) {
parent =agparent(g);
pp = agxget(parent, G_coord);
- if ((pp == p) || !strcmp(p, pp))
+ if (pp == p || !strcmp(p, pp))
return;
}
c = '\0';
/* create derived nodes from remaining nodes */
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
if (!DNODE(n)) {
- if (PARENT(n) && (PARENT(n) != GPARENT(g))) {
+ if (PARENT(n) && PARENT(n) != GPARENT(g)) {
agerr (AGERR, "node \"%s\" is contained in two non-comparable clusters \"%s\" and \"%s\"\n", agnameof(n), agnameof(g), agnameof(PARENT(n)));
longjmp (jbuf, 1);
}
while (i < deg - 1) {
a = erecs[i].alpha;
j = i + 1;
- while ((j < deg) && (erecs[j].alpha == a))
+ while (j < deg && erecs[j].alpha == a)
j++;
if (j == i + 1)
i = j;
for (j = 0; j < ED_count(e); j++, ep++) {
el = *ep;
pp[i].e = el;
- pp[i].n = (DNODE(agtail(el)) == n ? agtail(el) : aghead(el));
+ pp[i].n = DNODE(agtail(el)) == n ? agtail(el) : aghead(el);
pp[i].alpha = angle;
i += inc;
angle += delta;
infop->G_height = agattr(g, AGRAPH, "height", NULL);
infop->rootg = g;
infop->gid = 0;
- infop->pack.mode = getPackInfo(g, l_node, CL_OFFSET / 2, &(infop->pack));
+ infop->pack.mode = getPackInfo(g, l_node, CL_OFFSET / 2, &infop->pack);
}
/* mkClusters:
if (trySplines)
Nop = 2;
}
- if (trySplines || (et != ET_COMPOUND)) {
+ if (trySplines || et != ET_COMPOUND) {
if (HAS_CLUST_EDGE(g)) {
agerr(AGWARN,
"splines and cluster edges not supported - using line segments\n");
static double cool(double temp, int t)
{
- return (T_T0 * (T_maxIters - t)) / T_maxIters;
+ return T_T0 * (T_maxIters - t) / T_maxIters;
}
/* reset_params:
T_seed = DFLT_smode;
}
- T_pass1 = (T_unscaled * T_maxIters) / 100;
+ T_pass1 = T_unscaled * T_maxIters / 100;
T_K2 = T_K * T_K;
if (T_useGrid) {
}
dist = sqrt(dist2);
if (T_useNew)
- force = (ED_factor(e) * (dist - ED_dist(e))) / dist;
+ force = ED_factor(e) * (dist - ED_dist(e)) / dist;
else
- force = (ED_factor(e) * dist) / ED_dist(e);
+ force = ED_factor(e) * dist / ED_dist(e);
DISP(q)[0] -= xdelta * force;
DISP(q)[1] -= ydelta * force;
DISP(p)[0] += xdelta * force;
x = ND_pos(n)[0] + dx;
y = ND_pos(n)[1] + dy;
} else {
- double fact = temp / (sqrt(len2));
+ double fact = temp / sqrt(len2);
x = ND_pos(n)[0] + dx * fact;
y = ND_pos(n)[1] + dy * fact;
}
/* if ports, limit by boundary */
if (pp) {
- d = sqrt((x * x) / T_Wd2 + (y * y) / T_Ht2);
+ d = sqrt(x * x / T_Wd2 + y * y / T_Ht2);
if (IS_PORT(n)) {
ND_pos(n)[0] = x / d;
ND_pos(n)[1] = y / d;
width = EXPFACTOR * (bb.UR.x - bb.LL.x);
height = EXPFACTOR * (bb.UR.y - bb.LL.y);
area = 4.0 * T_Wd * T_Ht;
- quot = (width * height) / area;
+ quot = width * height / area;
if (quot >= 1.0) { /* If bbox has large enough area, use it */
T_Wd = width / 2.0;
T_Ht = height / 2.0;
for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) {
if (aghead(ep) == agtail(ep))
continue;
- op = (aghead(ep) == np ? agtail(ep) : aghead(ep));
+ op = aghead(ep) == np ? agtail(ep) : aghead(ep);
if (!hasPos(op))
continue;
if (cnt) {
}
}
- if ((ctr.x != 0.0) || (ctr.y != 0.0)) {
+ if (ctr.x != 0.0 || ctr.y != 0.0) {
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
ND_pos(n)[0] += ctr.x;
ND_pos(n)[1] += ctr.y;
static double cool(int t)
{
- return (X_T0 * (X_numIters - t)) / X_numIters;
+ return X_T0 * (X_numIters - t) / X_numIters;
}
#define EPSILON 0.01
dx = p.x - q.x;
dy = p.y - q.y;
- return (sqrt(dx * dx + dy * dy));
+ return sqrt(dx * dx + dy * dy);
}
/* bBox:
if (q_ll.x > p_ur.x) {
if (q_ll.y > p_ur.y) {
- return (dist(p_ur, q_ll));
+ return dist(p_ur, q_ll);
} else if (q_ll.y >= p_ll.y) {
- return (q_ll.x - p_ur.x);
+ return q_ll.x - p_ur.x;
} else {
if (q_ur.y >= p_ll.y)
- return (q_ll.x - p_ur.x);
+ return q_ll.x - p_ur.x;
else {
p_ur.y = p_ll.y; /* p_ur is now lower right */
q_ll.y = q_ur.y; /* q_ll is now upper left */
- return (dist(p_ur, q_ll));
+ return dist(p_ur, q_ll);
}
}
} else if (q_ll.x >= p_ll.x) {
if (q_ll.y > p_ur.y) {
- return (q_ll.y - p_ur.x);
+ return q_ll.y - p_ur.x;
} else if (q_ll.y >= p_ll.y) {
return 0.0;
} else {
if (q_ur.y >= p_ll.y)
return 0.0;
else
- return (p_ll.y - q_ur.y);
+ return p_ll.y - q_ur.y;
}
} else {
if (q_ll.y > p_ur.y) {
if (q_ur.x >= p_ll.x)
- return (q_ll.y - p_ur.y);
+ return q_ll.y - p_ur.y;
else {
p_ur.x = p_ll.x; /* p_ur is now upper left */
q_ll.x = q_ur.x; /* q_ll is now lower right */
- return (dist(p_ur, q_ll));
+ return dist(p_ur, q_ll);
}
} else if (q_ll.y >= p_ll.y) {
if (q_ur.x >= p_ll.x)
return 0.0;
else
- return (p_ll.x - q_ur.x);
+ return p_ll.x - q_ur.x;
} else {
if (q_ur.x >= p_ll.x) {
if (q_ur.y >= p_ll.y)
return 0.0;
else
- return (p_ll.y - q_ur.y);
+ return p_ll.y - q_ur.y;
} else {
if (q_ur.y >= p_ll.y)
- return (p_ll.x - q_ur.x);
+ return p_ll.x - q_ur.x;
else
- return (dist(p_ll, q_ur));
+ return dist(p_ll, q_ur);
}
}
}
ydelta = ND_pos(q)[1] - ND_pos(p)[1];
if (ydelta < 0)
ydelta = -ydelta;
- ret = ((xdelta <= (WD2(p) + WD2(q))) && (ydelta <= (HT2(p) + HT2(q))));
+ ret = xdelta <= WD2(p) + WD2(q) && ydelta <= HT2(p) + HT2(q);
return ret;
#else
double dist2, xdelta, ydelta;
xdelta = ND_pos(q)[0] - ND_pos(p)[0];
ydelta = ND_pos(q)[1] - ND_pos(p)[1];
dist2 = xdelta * xdelta + ydelta * ydelta;
- return (dist2 <= (din * din));
+ return dist2 <= din * din;
#endif
}
if (dist < X_K + din)
return;
dout = dist - din;
- force = (dout * dout) / ((X_K + din) * dist);
+ force = dout * dout / ((X_K + din) * dist);
#else
if (overlap(p, q)) {
#ifdef DEBUG
dist = sqrt(xdelta * xdelta + ydelta * ydelta);
din = RAD(p) + RAD(q);
dout = dist - din;
- force = (dout * dout) / ((X_K + din) * dist);
+ force = dout * dout / ((X_K + din) * dist);
#endif
#ifdef DEBUG
if (Verbose == 4) {
} else {
/* to avoid sqrt, consider abs(x) + abs(y) */
len = sqrt(len2);
- ND_pos(n)[0] += (disp[0] * temp) / len;
- ND_pos(n)[1] += (disp[1] * temp) / len;
+ ND_pos(n)[0] += disp[0] * temp / len;
+ ND_pos(n)[1] += disp[1] * temp / len;
}
}
return overlaps;
try = 0;
xpms = *pxpms;
K = xpms.K;
- while (ov && (try < tries)) {
+ while (ov && try < tries) {
xinit_params(g, nnodes, &xpms);
X_ov = X_C * K2;
- X_nonov = (nedges*X_ov*2.0)/(nnodes*(nnodes-1));
+ X_nonov = nedges*X_ov*2.0/(nnodes*(nnodes-1));
#ifdef DEBUG
if (Verbose) {
prIndent();
#endif
fprintf (stderr, "xLayout ");
}
- if (!ovlp || (*ovlp == '\0')) {
+ if (!ovlp || *ovlp == '\0') {
ovlp = DFLT_overlap;
}
/* look for optional ":" or "number:" */
- if ((cp = strchr(ovlp, ':')) && ((cp == ovlp) || isdigit(*ovlp))) {
+ if ((cp = strchr(ovlp, ':')) && (cp == ovlp || isdigit(*ovlp))) {
cp++;
rest = cp;
tries = atoi (ovlp);