dtview(dd->dict.e, parent_dd->dict.e);
dtview(dd->dict.g, parent_dd->dict.g);
} else {
- if (ProtoGraph && (g != ProtoGraph)) {
+ if (ProtoGraph && g != ProtoGraph) {
/* it's not ok to dtview here for several reasons. the proto
graph could change, and the sym indices don't match */
parent_dd = agdatadict(ProtoGraph, FALSE);
Agattr_t *data;
data = agattrrec(n);
- if ((!data) || (!data->dict))
+ if (!data || !data->dict)
(void) agmakeattrs(g, n);
}
Agattr_t *data;
data = agattrrec(e);
- if ((!data) || (!data->dict))
+ if (!data || !data->dict)
(void) agmakeattrs(g, e);
}
rv = 0; /* note was "", but this provides more info */
else {
data = agattrrec(obj);
- rv = (char *) (data->str[sym->id]);
+ rv = (char *) data->str[sym->id];
}
return rv;
}
char *rv;
data = agattrrec(obj);
- assert((sym->id >= 0) && (sym->id < topdictsize(obj)));
+ assert(sym->id >= 0 && sym->id < topdictsize(obj));
rv = (char *) (data->str[sym->id]);
return rv;
}
g = agraphof(obj);
hdr = obj;
data = agattrrec(hdr);
- assert((sym->id >= 0) && (sym->id < topdictsize(obj)));
+ assert(sym->id >= 0 && sym->id < topdictsize(obj));
agstrfree(g, data->str[sym->id]);
data->str[sym->id] = agstrdup(g, value);
if (hdr->tag.objtype == AGRAPH) {
if (rv == NULL) {
do {
rv = !rv ? agfstin(g, n) : agnxtin(g,rv);
- } while (rv && (rv->node == n));
+ } while (rv && rv->node == n);
}
} else {
do {
rv = agnxtin(g, e); /* so that we only see each edge once, */
e = rv;
- } while (rv && (rv->node == n)); /* ignore loops as in-edges */
+ } while (rv && rv->node == n); /* ignore loops as in-edges */
}
return rv;
}
e = agfindedge_by_id(g, h, t, id);
if (e == NULL && cflag && ok_to_make_edge(g, t, h)) {
root = agroot(g);
- if ((g != root) && ((e = agfindedge_by_id(root, t, h, id)))) {
+ if (g != root && ((e = agfindedge_by_id(root, t, h, id)))) {
subedge(g, e); /* old */
} else {
if (agallocid(g, AGEDGE, id)) {
if (AGID(e0->node) < AGID(e1->node)) return -1;
if (AGID(e0->node) > AGID(e1->node)) return 1;
/* same node */
- if ((AGTYPE(e0) != 0) && (AGTYPE(e1) != 0)) {
+ if (AGTYPE(e0) != 0 && AGTYPE(e1) != 0) {
if (AGID(e0) < AGID(e1)) return -1;
if (AGID(e0) > AGID(e1)) return 1;
}
p = buf;
*p++ = '\"';
uc = *(unsigned char *) s++;
- maybe_num = isdigit(uc) || (uc == '.') || (uc == '-');
+ maybe_num = isdigit(uc) || uc == '.' || uc == '-';
while (uc) {
if (uc == '\"') {
*p++ = '\\';
* id char.
*/
if (Max_outputline) {
- if (uc && backslash_pending && !(is_id_char(p[-1]) || (p[-1] == '\\')) && is_id_char(uc)) {
+ if (uc && backslash_pending && !(is_id_char(p[-1]) || p[-1] == '\\') && is_id_char(uc)) {
*p++ = '\\';
*p++ = '\n';
needs_quotes = true;
backslash_pending = false;
cnt = 0;
} else if (uc && (cnt >= Max_outputline)) {
- if (!(is_id_char(p[-1]) || (p[-1] == '\\')) && is_id_char(uc)) {
+ if (!(is_id_char(p[-1]) || p[-1] == '\\') && is_id_char(uc)) {
*p++ = '\\';
*p++ = '\n';
needs_quotes = true;
}
*p++ = '\"';
*p = '\0';
- if (needs_quotes || ((cnt == 1) && ((*arg == '.') || (*arg == '-'))))
+ if (needs_quotes || (cnt == 1 && (*arg == '.' || *arg == '-')))
return buf;
/* Use quotes to protect tokens (example, a node named "node") */
dd = agdatadict(g, FALSE);
if (!dd)
return true;
- if ((dtsize(dd->dict.n) > 0) || (dtsize(dd->dict.e) > 0))
+ if (dtsize(dd->dict.n) > 0 || dtsize(dd->dict.e) > 0)
return false;
return true;
}
int cnt = 0;
int rv;
- if ((AGTYPE(obj) == AGINEDGE) || (AGTYPE(obj) == AGOUTEDGE)) {
+ if (AGTYPE(obj) == AGINEDGE || AGTYPE(obj) == AGOUTEDGE) {
CHKRV(rv = write_edge_name(obj, ofile, FALSE));
if (rv)
cnt++;
g = agraphof(obj);
if (data)
for (sym = dtfirst(defdict); sym; sym = dtnext(defdict, sym)) {
- if ((AGTYPE(obj) == AGINEDGE) || (AGTYPE(obj) == AGOUTEDGE)) {
- if (Tailport && (sym->id == Tailport->id))
+ if (AGTYPE(obj) == AGINEDGE || AGTYPE(obj) == AGOUTEDGE) {
+ if (Tailport && sym->id == Tailport->id)
continue;
- if (Headport && (sym->id == Headport->id))
+ if (Headport && sym->id == Headport->id)
continue;
}
if (data->str[sym->id] != sym->defval) {
Level = 0; /* re-initialize tab level */
if ((s = agget(g, "linelength")) && isdigit(*s)) {
len = (int)strtol(s, (char **)NULL, 10);
- if ((len == 0) || (len >= MIN_OUTPUTLINE))
+ if (len == 0 || len >= MIN_OUTPUTLINE)
Max_outputline = len;
}
set_attrwf(g, true, false);
e->npoints = np;
e->dim = dim;
e->len = np;
- e->x = MALLOC(dim*(e->len)*sizeof(real));
- memcpy(e->x, x, dim*(e->len)*sizeof(real));
- e->edge_length = dist(dim, &(x[0*dim]), &(x[(np-1)*dim]));
+ e->x = MALLOC(dim*e->len*sizeof(real));
+ memcpy(e->x, x, dim*e->len*sizeof(real));
+ e->edge_length = dist(dim, &x[0*dim], &x[(np-1)*dim]);
e->wgt = 1.;
e->wgts = NULL;
return e;
e->npoints = np;
e->dim = dim;
e->len = np;
- e->x = MALLOC(dim*(e->len)*sizeof(real));
- memcpy(e->x, x, dim*(e->len)*sizeof(real));
- e->edge_length = dist(dim, &(x[0*dim]), &(x[(np-1)*dim]));
+ e->x = MALLOC(dim*e->len*sizeof(real));
+ memcpy(e->x, x, dim*e->len*sizeof(real));
+ e->edge_length = dist(dim, &x[0*dim], &x[(np-1)*dim]);
e->wgt = wgt;
e->wgts = MALLOC(sizeof(real)*(np - 1));
for (i = 0; i < np - 1; i++) e->wgts[i] = wgt;
int n = e->npoints;
y = MALLOC(sizeof(real)*e->dim);
- for (i = 0; i < (e->npoints)/2; i++){
- memcpy(y, &(x[i*dim]), sizeof(real)*dim);
- memcpy(&(x[(n-1-i)*dim]), &(x[i*dim]), sizeof(real)*dim);
- memcpy(&(x[i*dim]), y, sizeof(real)*dim);
+ for (i = 0; i < e->npoints/2; i++){
+ memcpy(y, &x[i*dim], sizeof(real)*dim);
+ memcpy(&x[(n-1-i)*dim], &x[i*dim], sizeof(real)*dim);
+ memcpy(&x[i*dim], y, sizeof(real)*dim);
}
FREE(y);
return e;
int dim = e1->dim, flipped = FALSE;
u1 = e1->x;
- v1 = (e1->x)+(e1->npoints)*dim-dim;
+ v1 = e1->x+e1->npoints*dim-dim;
u2 = e2->x;
- v2 = (e2->x)+(e2->npoints)*dim-dim;
+ v2 = e2->x+e2->npoints*dim-dim;
dist1 = sqr_dist(dim, u1, u2) + sqr_dist(dim, v1, v2);
dist2 = sqr_dist(dim, u1, v2) + sqr_dist(dim, v1, u2);
if (dist1 > dist2){
int dim = e1->dim, flipped = FALSE, i;
u1 = e1->x;
- v1 = (e1->x)+(e1->npoints)*dim-dim;
+ v1 = e1->x+e1->npoints*dim-dim;
u2 = e2->x;
- v2 = (e2->x)+(e2->npoints)*dim-dim;
+ v2 = e2->x+e2->npoints*dim-dim;
dist1 = sqr_dist(dim, u1, u2) + sqr_dist(dim, v1, v2);
dist2 = sqr_dist(dim, u1, v2) + sqr_dist(dim, v1, u2);
if (dist1 > dist2){
}
}
e->len = len;
- np = e->npoints = 2*(e->npoints) - 1;
- e->edge_length = dist(dim, &(x[0*dim]), &(x[(np-1)*dim]));
+ np = e->npoints = 2*e->npoints - 1;
+ e->edge_length = dist(dim, &x[0*dim], &x[(np-1)*dim]);
return e;
}
s = edge_length;
s = similarity*edge_length;
for (i = 1; i <= np - 2; i++){
- dist = sqr_dist(dim, &(x1[i*dim]), &(x2[i*dim]));
+ dist = sqr_dist(dim, &x1[i*dim], &x2[i*dim]);
if (dist < SMALL) dist = SMALL;
ss = s/(dist+0.1*edge_length*sqrt(dist));
for (j = 0; j < dim; j++) force[i*dim + j] += ss*(x2[i*dim + j] - x1[i*dim + j]);
s = -edge_length;
s = -similarity*edge_length;
for (i = 1; i <= np - 2; i++){
- dist = sqr_dist(dim, &(x1[i*dim]), &(x2[(np - 1 - i)*dim]));
+ dist = sqr_dist(dim, &x1[i*dim], &x2[(np - 1 - i)*dim]);
if (dist < SMALL) dist = SMALL;
ss = s/(dist+0.1*edge_length*sqrt(dist));
for (j = 0; j < dim; j++) force[i*dim + j] += ss*(x2[(np - 1 - i)*dim + j] - x1[i*dim + j]);
if (Verbose > 1)
fprintf(stderr, "total interaction pairs = %d out of %d, avg neighbors per edge = %f\n",A->nz, A->m*A->m, A->nz/(real) A->m);
- force_t = MALLOC(sizeof(real)*dim*(np));
- force_a = MALLOC(sizeof(real)*dim*(np));
+ force_t = MALLOC(sizeof(real)*dim*np);
+ force_a = MALLOC(sizeof(real)*dim*np);
while (step > 0.001 && iter < maxit){
start = clock();
iter++;
e2 = edges[ja[j]];
edge_attraction_force(a[j], e1, e2, force_a);
}
- fnorm_t = MAX(SMALL, norm(dim*(np - 2), &(force_t[1*dim])));
- fnorm_a = MAX(SMALL, norm(dim*(np - 2), &(force_a[1*dim])));
+ fnorm_t = MAX(SMALL, norm(dim*(np - 2), &force_t[1*dim]));
+ fnorm_a = MAX(SMALL, norm(dim*(np - 2), &force_a[1*dim]));
edge_length = e1->edge_length;
for (j = 1; j <= np - 2; j++){
clusterp = D->ia;
clusters = D->ja;
for (i = 0; i < nclusters; i++){
- ink1 = ink(edges, clusterp[i+1] - clusterp[i], &(clusters[clusterp[i]]), &ink0, &meet1, &meet2, angle_param, angle);
+ ink1 = ink(edges, clusterp[i+1] - clusterp[i], &clusters[clusterp[i]], &ink0, &meet1, &meet2, angle_param, angle);
if (Verbose > 1)
fprintf(stderr,"nedges = %d ink0 = %f, ink1 = %f\n",clusterp[i+1] - clusterp[i], ink0, ink1);
if (ink1 < ink0){
edges = MALLOC(sizeof(pedge)*ne);
for (i = 0; i < ne; i++){
- edges[i] = pedge_new(2, dim, &(x[dim*2*i]));
+ edges[i] = pedge_new(2, dim, &x[dim*2*i]);
}
A = SparseMatrix_symmetrize(A0, TRUE);