f = m->pos.y - b;
g = after(m)->pos.x - a;
h = after(m)->pos.y - b;
- t = (c * f) - (d * e);
- i[0] = ((t == 0) ? 0 : (t > 0 ? 1 : -1));
- t = (c * h) - (d * g);
- i[1] = ((t == 0) ? 0 : (t > 0 ? 1 : -1));
+ t = c * f - d * e;
+ i[0] = t == 0 ? 0 : (t > 0 ? 1 : -1);
+ t = c * h - d * g;
+ i[1] = t == 0 ? 0 : (t > 0 ? 1 : -1);
i[2] = i[0] * i[1];
}
/* determine if g lies between f and h */
static int between(double f, double g, double h)
{
- if ((f == g) || (g == h))
- return (0);
- return ((f < g) ? (g < h ? 1 : -1) : (h < g ? 1 : -1));
+ if (f == g || g == h)
+ return 0;
+ return f < g ? (g < h ? 1 : -1) : (h < g ? 1 : -1);
}
/* determine if vertex i of line m is on line l */
pointf a, b, c;
a = l->pos;
b = after(l)->pos;
- c = (i == 0) ? m->pos : after(m)->pos;
- return ((a.x == b.x) ? ((a.x == c.x)
- && (-1 !=
- between(a.y, c.y, b.y))) : between(a.x,
- c.x,
- b.x));
+ c = i == 0 ? m->pos : after(m)->pos;
+ return a.x == b.x
+ ? (a.x == c.x && -1 != between(a.y, c.y, b.y))
+ : between(a.x, c.x, b.x);
}
/* determine point of detected intersections */
double m1, m2, c1, c2;
if (cond <= 0)
- return (0);
+ return 0;
ls = l->pos;
le = after(l)->pos;
ms = m->pos;
} else {
m1 = SLOPE(ms, me);
m2 = SLOPE(ls, le);
- c1 = ms.y - (m1 * ms.x);
- c2 = ls.y - (m2 * ls.x);
+ c1 = ms.y - m1 * ms.x;
+ c2 = ls.y - m2 * ls.x;
*x = (c2 - c1) / (m1 - m2);
- *y = ((m1 * c2) - (c1 * m2)) / (m1 - m2);
+ *y = (m1 * c2 - c1 * m2) / (m1 - m2);
}
break;
case 2: /* the two lines have a common segment */
if (online(l, m, 0) == -1) { /* ms between ls and le */
pt1 = ms;
- pt2 =
- (online(m, l, 1) ==
- -1) ? ((online(m, l, 0) == -1) ? le : ls) : me;
+ pt2 = online(m, l, 1) == -1
+ ? (online(m, l, 0) == -1 ? le : ls) : me;
} else if (online(l, m, 1) == -1) { /* me between ls and le */
pt1 = me;
- pt2 =
- (online(l, m, 0) ==
- -1) ? ((online(m, l, 0) == -1) ? le : ls) : ms;
+ pt2 = online(l, m, 0) == -1
+ ? (online(m, l, 0) == -1 ? le : ls) : ms;
} else {
/* may be degenerate? */
if (online(m, l, 0) != -1)
*y = me.y;
}
} /* end switch */
- return (1);
+ return 1;
}
static void
vsd = secondv->pos;
avsd = after(secondv)->pos;
- if (((vft.x != avft.x) && (vsd.x != avsd.x)) ||
- ((vft.x == avft.x) &&
- !EQ_PT(vft, p) &&
- !EQ_PT(avft, p)) ||
- ((vsd.x == avsd.x) &&
- !EQ_PT(vsd, p) && !EQ_PT(avsd, p)))
+ if ((vft.x != avft.x && vsd.x != avsd.x) ||
+ (vft.x == avft.x && !EQ_PT(vft, p) && !EQ_PT(avft, p)) ||
+ (vsd.x == avsd.x && !EQ_PT(vsd, p) && !EQ_PT(avsd, p)))
{
if (Verbose > 1) {
fprintf(stderr, "\nintersection at %.3f %.3f\n",
sgnarea(m, l, i);
if (i[2] > 0)
return 0;
- if (!intpoint
- (l, m, &x, &y, (i[2] < 0) ? 3 : online(m, l, abs(i[0]))))
+ if (!intpoint(l, m, &x, &y, i[2] < 0 ? 3 : online(m, l, abs(i[0]))))
return 0;
}
- else if (!intpoint(l, m, &x, &y, (i[0] == i[1]) ?
+ else if (!intpoint(l, m, &x, &y, i[0] == i[1] ?
2 * MAX(online(l, m, 0),
online(l, m, 1)) : online(l, m, abs(i[0]))))
return 0;
/* i > j if i.x > j.x or i.x = j.x and i.y > j.y */
double t;
if ((t = (*i)->pos.x - (*j)->pos.x) != 0.)
- return ((t > 0.) ? 1 : -1);
+ return t > 0. ? 1 : -1;
if ((t = (*i)->pos.y - (*j)->pos.y) == 0.)
- return (0);
+ return 0;
else
- return ((t > 0.) ? 1 : -1);
+ return t > 0. ? 1 : -1;
}
/* find_ints:
p = agxget(np, posptr);
if (p[0]) {
c = '\0';
- if ((Ndim >= 3) &&
- (sscanf(p, "%lf,%lf,%lf%c", pvec, pvec+1, pvec+2, &c) >= 3)){
+ if (Ndim >= 3 && sscanf(p, "%lf,%lf,%lf%c", pvec, pvec+1, pvec+2, &c) >= 3){
ND_pinned(np) = P_SET;
if (PSinputscale > 0.0) {
int i;
}
if (Ndim > 3)
jitter_d(np, nG, 3);
- if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr))))
+ if (c == '!' || (pinptr && mapbool(agxget(np, pinptr))))
ND_pinned(np) = P_PIN;
return TRUE;
}
pvec[i] /= PSinputscale;
}
if (Ndim > 2) {
- if (N_z && (p = agxget(np, N_z)) && (sscanf(p,"%lf",&z) == 1)) {
+ if (N_z && (p = agxget(np, N_z)) && sscanf(p,"%lf",&z) == 1) {
if (PSinputscale > 0.0) {
pvec[2] = z / PSinputscale;
}
else
jitter3d(np, nG);
}
- if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr))))
+ if (c == '!' || (pinptr && mapbool(agxget(np, pinptr))))
ND_pinned(np) = P_PIN;
return TRUE;
} else
static void neato_cleanup_graph(graph_t * g)
{
- if (Nop || (Pack < 0)) {
+ if (Nop || Pack < 0) {
free_scan_graph(g);
free(GD_clust(g));
}
pos++; /* skip white space */
if ((c = *pos)) { /* skip token */
cnt++;
- while ((c = *pos) && !isspace(c) && (c != ';'))
+ while ((c = *pos) && !isspace(c) && c != ';')
pos++;
}
} while (isspace(c));
double x, y;
char *lp;
lp = agget(obj, name);
- if (lp && (sscanf(lp, "%lf,%lf", &x, &y) == 2)) {
+ if (lp && sscanf(lp, "%lf,%lf", &x, &y) == 2) {
l->pos = pointfof(x, y);
l->set = TRUE;
}
npts = numFields((unsigned char *) pos); /* count potential points */
n = npts;
- if ((n < 4) || (n % 3 != 1)) {
+ if (n < 4 || n % 3 != 1) {
gv_free_splines(e);
if (!warned) {
warned = 1;
return AllEdges;
E_pos = agfindedgeattr(g, "pos");
- if (!E_pos || (Nop < 2))
+ if (!E_pos || Nop < 2)
return NoEdges;
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
else
haveBackground = 0;
- if (adjust && (Nop == 1) && !haveBackground)
+ if (adjust && Nop == 1 && !haveBackground)
didAdjust = adjustNodes(g);
if (didAdjust) {
node_t *n;
State = GVSPLINES;
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- ND_coord(n).x = POINTS_PER_INCH * (ND_pos(n)[0]);
- ND_coord(n).y = POINTS_PER_INCH * (ND_pos(n)[1]);
+ ND_coord(n).x = POINTS_PER_INCH * ND_pos(n)[0];
+ ND_coord(n).y = POINTS_PER_INCH * ND_pos(n)[1];
}
}
else {
boolean didShift;
- if (translate && !haveBackground && ((GD_bb(g).LL.x != 0)||(GD_bb(g).LL.y != 0)))
+ if (translate && !haveBackground && (GD_bb(g).LL.x != 0||GD_bb(g).LL.y != 0))
neato_translate (g);
didShift = neato_set_aspect(g);
/* if we have some edge positions and we either shifted or adjusted, free edge positions */
- if ((posEdges != NoEdges) && (didShift || didAdjust)) {
+ if (posEdges != NoEdges && (didShift || didAdjust)) {
freeEdgeInfo (g);
posEdges = NoEdges;
}
/* if mode is IPSEP make it an in-edge
* at both ends, so that an edge constraint won't be generated!
*/
- double x = (mode==MODE_IPSEP?-1.0:1.0);
+ double x = mode==MODE_IPSEP?-1.0:1.0;
np = nodes[i];
ND_mark(np) = TRUE;
hp = nodes[j];
if (ND_onstack(hp)) { /* back edge: reverse it */
graph[i].edists[e] = x;
- for (f = 1; (f < graph[j].nedges) &&(graph[j].edges[f] != i); f++) ;
+ for (f = 1; f < graph[j].nedges && graph[j].edges[f] != i; f++) ;
assert (f < graph[j].nedges);
graph[j].edists[f] = -1.0;
}
haveWt = FALSE;
} else {
haveLen = agattr(g, AGEDGE, "len", 0) ;
- haveWt = (E_weight != 0);
+ haveWt = E_weight != 0;
}
if (mode == MODE_HIER || mode == MODE_IPSEP)
haveDir = TRUE;
graph[i].ewgts[idx] = MAX(ED_dist(ep), curlen);
}
} else {
- node_t *vp = (((agtail(ep)) == np) ? aghead(ep) : agtail(ep));
+ node_t *vp = agtail(ep) == np ? aghead(ep) : agtail(ep);
ne++;
j++;
if(s&&!strncmp(s,"none",4)) {
*edists++ = 0;
} else {
- *edists++ = (np == aghead(ep) ? 1.0 : -1.0);
+ *edists++ = np == aghead(ep) ? 1.0 : -1.0;
}
}
#endif
node_t *np;
a = 0.0;
- da = (2 * M_PI) / nG;
+ da = 2 * M_PI / nG;
for (np = agfstnode(G); np; np = agnxtnode(G, np)) {
ND_pos(np)[0] = nG * Spring_coeff * cos(a);
ND_pos(np)[1] = nG * Spring_coeff * sin(a);
char *p = agget(G, "start");
int init = dflt;
- if (!p || (*p == '\0')) return dflt;
+ if (!p || *p == '\0') return dflt;
if (isalpha(*(unsigned char *)p)) {
if (!strncmp(p, SMART, SLEN(SMART))) {
init = INIT_SELF;
static int checkExp (graph_t * G)
{
int exp = late_int(G, agfindgraphattr(G, exp_name), 2, 0);
- if ((exp == 0) || (exp > 2)) {
+ if (exp == 0 || exp > 2) {
agerr (AGWARN, "%s attribute value must be 1 or 2 - ignoring\n", exp_name);
exp = 2;
}
seed = 1;
init = setSeed (G, dflt, &seed);
- if (N_pos && (init != INIT_RANDOM)) {
+ if (N_pos && init != INIT_RANDOM) {
agerr(AGWARN, "node positions are ignored unless start=random\n");
}
if (init == INIT_REGULAR) initRegular(G, nG);
expand_t margin;
#endif
#endif
- int init = checkStart(g, nv, (mode == MODE_HIER ? INIT_SELF : INIT_RANDOM));
+ int init = checkStart(g, nv, mode == MODE_HIER ? INIT_SELF : INIT_RANDOM);
int opts = checkExp (g);
if (init == INIT_SELF)
}
if (Verbose) {
fprintf(stderr, "model %d smart_init %d stresswt %d iterations %d tol %f\n",
- model, (init == INIT_SELF), opts & opt_exp_flag, MaxIter, Epsilon);
+ model, init == INIT_SELF, opts & opt_exp_flag, MaxIter, Epsilon);
fprintf(stderr, "convert graph: ");
start_timer();
fprintf(stderr, "majorization\n");
MaxIter = 100 * agnnodes(g);
nG = scan_graph_mode(g, layoutMode);
- if ((nG < 2) || (MaxIter < 0))
+ if (nG < 2 || MaxIter < 0)
return;
if (layoutMode == MODE_KK)
kkNeato(g, nG, layoutModel);
node_t* n;
char buf[BUFSIZ];
- if ((Ndim >= 3) && N_z) {
+ if (Ndim >= 3 && N_z) {
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- snprintf(buf, sizeof(buf), "%lf", POINTS_PER_INCH * (ND_pos(n)[2]));
+ snprintf(buf, sizeof(buf), "%lf", POINTS_PER_INCH * ND_pos(n)[2]);
agxset(n, N_z, buf);
}
}
/* If the user has not indicated packing but we are
* using the new neato, turn packing on.
*/
- if ((Pack < 0) && layoutMode)
+ if (Pack < 0 && layoutMode)
Pack = CL_OFFSET;
pinfo.mode = l_node;
} else if (Pack < 0)