]> granicus.if.org Git - graphviz/commitdiff
sparse QuadTree_get_supernodes: remove 'flag' that is always set to 0
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 28 Nov 2022 00:40:50 +0000 (16:40 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 30 Nov 2022 02:07:36 +0000 (18:07 -0800)
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.

lib/sfdpgen/spring_electrical.c
lib/sparse/QuadTree.c
lib/sparse/QuadTree.h

index 745b3eda3d351ad13aa7334566f674763c71ba76..b6e9ac1baf0a5d074b5a85f6964f9f1cfe4e3527 100644 (file)
@@ -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,
-                               &center, &supernode_wgts, &distances, &counts, flag);
+                               &center, &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,
-                               &center, &supernode_wgts, &distances, &counts, flag);
+                               &center, &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,
-                               &center, &supernode_wgts, &distances, &counts, flag);
+                               &center, &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++){
index a12a42ba94156e6e4a55eee0cf354fe9863c8565..67b3cf7dd86fbea0c9e373c34253ad99aa225aa4 100644 (file)
@@ -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));
index f58eed59fb1ca0435528c7602611c16c5ae7c230..a83113fff695dc491625ea1a643bcd46a081fb9f 100644 (file)
@@ -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);