]> granicus.if.org Git - graphviz/commitdiff
remove some unnecessary bracketing
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 22 Nov 2020 05:51:02 +0000 (21:51 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 23 Jan 2021 19:24:27 +0000 (11:24 -0800)
lib/cgraph/graph.c
lib/cgraph/rec.c
lib/fdpgen/clusteredges.c
lib/fdpgen/dbg.c
lib/fdpgen/fdpinit.c
lib/fdpgen/grid.c
lib/fdpgen/layout.c
lib/fdpgen/tlayout.c
lib/fdpgen/xlayout.c

index d6eece37c5fca49d0e29ce98868fd545e226a578..d695c6949bf45290501b48673eab8b5d8194d502 100644 (file)
@@ -97,7 +97,7 @@ int agclose(Agraph_t * g)
     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));
index 0a51db4f557a815f2531de100af2dee1de75c6b0..61a3411f0ce18eeb7108e0b9e76a1ea8c7bc0f3a 100644 (file)
@@ -94,7 +94,7 @@ void *agbindrec(void *arg_obj, char *recname, unsigned int recsize,
     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);
index 67d490d11adf50a03d93b4cedd38fb1591b4d37d..5323d8154d7034b17f4cd5a75d49605f047fae49 100644 (file)
@@ -154,14 +154,13 @@ addGraphObjs(objlist * l, graph_t * g, void *tex, void *hex, expand_t* pm)
     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));
        }
     }
@@ -266,7 +265,7 @@ int compoundEdges(graph_t * g, expand_t* pm, int edgetype)
     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);
@@ -287,9 +286,9 @@ int compoundEdges(graph_t * g, expand_t* pm, int edgetype)
                        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;
index 4460b664c3d063827fd56530f600406ec5205aae..c294a946221707c4ed33c3ca2b4edc41c8ad514a 100644 (file)
@@ -320,8 +320,7 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode)
 
     /* 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");
@@ -338,9 +337,9 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode)
        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) {
index b18faff011f29069488818fb8e1751e968cadd19..b272dc6509c8e18356bb1cc830925a21db6ebdcb 100644 (file)
@@ -51,7 +51,7 @@ static void initialPositions(graph_t * g)
                        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
index 06612f8e3687f035c4ddf87556b178cb22bacbfa..f99c0136e7aa4569ecd9c7f417c49fed24ea2346 100644 (file)
@@ -100,10 +100,10 @@ static int ijcmpf(Dt_t * d, gridpt * p1, gridpt * p2, Dtdisc_t * disc)
 
     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 */
@@ -184,7 +184,7 @@ void adjustGrid(Grid * g, int nnodes)
     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);
@@ -255,7 +255,7 @@ cell *findGrid(Grid * g, int i, int j)
 
     key.p.i = i;
     key.p.j = j;
-    return ((cell *) dtsearch(g->data, &key));
+    return (cell *) dtsearch(g->data, &key);
 }
 
 /* gLength:
index cdf494acb4dbe3ca8a8159b49fd4b46c5e1e3555..d52372949a13d1056421c75a30a1dfe8d0e02c91 100644 (file)
@@ -85,7 +85,7 @@ finalCC(graph_t * g, int c_cnt, graph_t ** cc, point * pts, graph_t * rg,
     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 */
@@ -349,7 +349,7 @@ static void chkPos(graph_t* g, node_t* n, layout_info* infop, boxf* bbp)
        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';
@@ -482,7 +482,7 @@ static graph_t *deriveGraph(graph_t * g, layout_info * infop)
     /* 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);
            }
@@ -638,7 +638,7 @@ static erec *getEdgeList(node_t * n, graph_t * g)
        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;
@@ -707,7 +707,7 @@ genPorts(node_t * n, erec * er, bport_t * pp, int idx, double bnd)
     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;
@@ -1001,7 +1001,7 @@ static void init_info(graph_t * g, layout_info * infop)
     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:
@@ -1088,7 +1088,7 @@ fdpSplines (graph_t * g)
            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");
index be8deea451fcb4b4153d96b87e98e91b702941ed..d008959009f2d9c458d67d235f1673c9bb623578 100644 (file)
@@ -120,7 +120,7 @@ static parms_t parms;
 
 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:
@@ -200,7 +200,7 @@ void fdp_initParams(graph_t * g)
        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) {
@@ -342,9 +342,9 @@ static void applyAttr(Agnode_t * p, Agnode_t * q, Agedge_t * e)
     }
     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;
@@ -372,14 +372,14 @@ static void updatePos(Agraph_t * g, double temp, bport_t * pp)
            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;
@@ -500,7 +500,7 @@ static pointf initPositions(graph_t * g, bport_t * pp)
        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;
@@ -578,7 +578,7 @@ static pointf initPositions(graph_t * g, bport_t * pp)
                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) {
@@ -691,7 +691,7 @@ void fdp_tLayout(graph_t * g, xparams * xpms)
        }
     }
 
-    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;
index 1348b48dc8b28a9c2717bbb29614765aaf50f607..cc1c7d12f328d9d4df759f1939300ccfb5c48997 100644 (file)
@@ -105,7 +105,7 @@ static void xinit_params(graph_t* g, int n, xparams * xpms)
 
 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
@@ -120,7 +120,7 @@ static double dist(pointf p, pointf q)
 
     dx = p.x - q.x;
     dy = p.y - q.y;
-    return (sqrt(dx * dx + dy * dy));
+    return sqrt(dx * dx + dy * dy);
 }
 
 /* bBox:
@@ -150,54 +150,54 @@ static double boxDist(node_t * p, node_t * q)
 
     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);
            }
        }
     }
@@ -219,7 +219,7 @@ static int overlap(node_t * p, node_t * q)
     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;
@@ -229,7 +229,7 @@ static int overlap(node_t * p, node_t * q)
     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
 }
 
@@ -350,7 +350,7 @@ static void applyAttr(Agnode_t * p, Agnode_t * q)
     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
@@ -366,7 +366,7 @@ static void applyAttr(Agnode_t * p, Agnode_t * q)
     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) {
@@ -433,8 +433,8 @@ static int adjust(Agraph_t * g, double temp)
        } 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;
@@ -475,10 +475,10 @@ static int x_layout(graph_t * g, xparams * pxpms, int tries)
     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();
@@ -535,11 +535,11 @@ void fdp_xLayout(graph_t * g, xparams * xpms)
 #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);