From: Matthew Fernandez Date: Mon, 28 Nov 2022 00:40:50 +0000 (-0800) Subject: sparse QuadTree_get_supernodes: remove 'flag' that is always set to 0 X-Git-Tag: 7.0.4~3^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=75aad61a75a7117e18a354e0eaa9c07fb0d7822d;p=graphviz sparse QuadTree_get_supernodes: remove 'flag' that is always set to 0 Note that we can also remove follow on checks after calls to this function when `flag` is known to be 0 based on its prior initialization. --- diff --git a/lib/sfdpgen/spring_electrical.c b/lib/sfdpgen/spring_electrical.c index 745b3eda3..b6e9ac1ba 100644 --- a/lib/sfdpgen/spring_electrical.c +++ b/lib/sfdpgen/spring_electrical.c @@ -927,7 +927,7 @@ void spring_electrical_embedding(int dim, SparseMatrix A0, spring_electrical_con start = clock(); #endif QuadTree_get_supernodes(qt, ctrl->bh, &(x[dim*i]), i, &nsuper, &nsupermax, - ¢er, &supernode_wgts, &distances, &counts, flag); + ¢er, &supernode_wgts, &distances, &counts); #ifdef TIME end = clock(); @@ -935,7 +935,6 @@ void spring_electrical_embedding(int dim, SparseMatrix A0, spring_electrical_con #endif counts_avg += counts; nsuper_avg += nsuper; - if (*flag) goto RETURN; for (j = 0; j < nsuper; j++){ dist = MAX(distances[j], MINDIST); for (k = 0; k < dim; k++){ @@ -1236,9 +1235,8 @@ static void spring_maxent_embedding(int dim, SparseMatrix A0, SparseMatrix D, sp /* repulsive force ||x_i-x_j||^(1 - p) (x_i - x_j) */ if (USE_QT){ QuadTree_get_supernodes(qt, ctrl->bh, &(x[dim*i]), i, &nsuper, &nsupermax, - ¢er, &supernode_wgts, &distances, &counts, flag); + ¢er, &supernode_wgts, &distances, &counts); nsuper_avg += nsuper; - if (*flag) goto RETURN; for (j = 0; j < nsuper; j++){ dist = MAX(distances[j], MINDIST); for (k = 0; k < dim; k++){ @@ -1408,9 +1406,8 @@ void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D /* repulsive force K^(1 - p)/||x_i-x_j||^(1 - p) (x_i - x_j) */ if (USE_QT){ QuadTree_get_supernodes(qt, ctrl->bh, &(x[dim*i]), i, &nsuper, &nsupermax, - ¢er, &supernode_wgts, &distances, &counts, flag); + ¢er, &supernode_wgts, &distances, &counts); nsuper_avg += nsuper; - if (*flag) goto RETURN; for (j = 0; j < nsuper; j++){ dist = MAX(distances[j], MINDIST); for (k = 0; k < dim; k++){ diff --git a/lib/sparse/QuadTree.c b/lib/sparse/QuadTree.c index a12a42ba9..67b3cf7dd 100644 --- a/lib/sparse/QuadTree.c +++ b/lib/sparse/QuadTree.c @@ -121,14 +121,13 @@ static void QuadTree_get_supernodes_internal(QuadTree qt, double bh, double *poi } void QuadTree_get_supernodes(QuadTree qt, double bh, double *point, int nodeid, int *nsuper, - int *nsupermax, double **center, double **supernode_wgts, double **distances, double *counts, int *flag){ + int *nsupermax, double **center, double **supernode_wgts, double **distances, double *counts) { int dim = qt->dim; (*counts) = 0; *nsuper = 0; - *flag = 0; *nsupermax = 10; if (!*center) *center = MALLOC(sizeof(double)*(*nsupermax)*dim); if (!*supernode_wgts) *supernode_wgts = MALLOC(sizeof(double)*(*nsupermax)); diff --git a/lib/sparse/QuadTree.h b/lib/sparse/QuadTree.h index f58eed59f..a83113fff 100644 --- a/lib/sparse/QuadTree.h +++ b/lib/sparse/QuadTree.h @@ -51,7 +51,7 @@ QuadTree QuadTree_new_from_point_list(int dim, int n, int max_level, double *coo double point_distance(double *p1, double *p2, int dim); void QuadTree_get_supernodes(QuadTree qt, double bh, double *point, int nodeid, int *nsuper, - int *nsupermax, double **center, double **supernode_wgts, double **distances, double *counts, int *flag); + int *nsupermax, double **center, double **supernode_wgts, double **distances, double *counts); void QuadTree_get_repulsive_force(QuadTree qt, double *force, double *x, double bh, double p, double KP, double *counts);