]> granicus.if.org Git - graphviz/commitdiff
remove ascending parameter from vector_ordering
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 23 Jun 2021 03:35:33 +0000 (20:35 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 25 Jun 2021 13:52:00 +0000 (06:52 -0700)
All calls to this use ascending, so having this configurable was adding
unnecessary maintenance burden.

cmd/gvmap/country_graph_coloring.c
lib/sparse/general.c
lib/sparse/general.h

index e60bee50c79589f70330d4782d9d33821b0b0570..acffdf3d26087d827fefe6da852c2b03c185c430 100644 (file)
@@ -308,7 +308,7 @@ static void country_graph_coloring_internal(int seed, SparseMatrix A, int **p, r
     power_method(L, L->n, 1, seed, maxit, tol, &v, &eigv);
   }
 
-  vector_ordering(n, v, p, TRUE);
+  vector_ordering(n, v, p);
   if (Verbose)
     fprintf(stderr, "cpu time for spectral ordering (before greedy) = %f\n", (real) (clock() - start)/(CLOCKS_PER_SEC));
 
index a31415cad5a213413b8dfcb0d77e6e04020b6b42..c36ab37fe6f7f58e0bc471c3d3056bf37d71a643 100644 (file)
@@ -19,7 +19,7 @@ real vector_median(int n, real *x){
   /* find the median value in a list of real */
   int *p = NULL;
   real res;
-  vector_ordering(n, x, &p, TRUE);
+  vector_ordering(n, x, &p);
 
   if ((n/2)*2 == n){
     res = 0.5*(x[p[n/2-1]] + x[p[n/2]]);
@@ -35,7 +35,7 @@ real vector_percentile(int n, real *x, real y){
   */
   int *p = NULL, i;
   real res;
-  vector_ordering(n, x, &p, TRUE);
+  vector_ordering(n, x, &p);
   
 
   y = MIN(y, 1);
@@ -203,16 +203,9 @@ static int comp_ascend_int(const void *s1, const void *s2){
   return 0;
 }
 
-
-void vector_ordering(int n, real *v, int **p, int ascending){
-  /* give the position of the lagest, second largest etc in vector v if ascending = FALSE
-
-     or
-
-     give the position of the smallest, second smallest etc  in vector v if ascending = TRUE.
+void vector_ordering(int n, real *v, int **p){
+  /* give the position of the smallest, second smallest etc in vector v.
      results in p. If *p == NULL, p is assigned.
-
-     ascending: TRUE if v[p] is from small to large.
   */
 
   real *u;
@@ -226,11 +219,7 @@ void vector_ordering(int n, real *v, int **p, int ascending){
     u[2*i] = v[i];
   }
 
-  if (ascending){
-    qsort(u, n, sizeof(real)*2, comp_ascend);
-  } else {
-    qsort(u, n, sizeof(real)*2, comp_descend);
-  }
+  qsort(u, n, sizeof(real)*2, comp_ascend);
 
   for (i = 0; i < n; i++) (*p)[i] = (int) u[2*i+1];
   FREE(u);
index a6092ce2b6b7889dfe1ba4de0129b2581d3a25b4..006487d1689ddc567da411128b6524cb0421e0b1 100644 (file)
@@ -104,7 +104,7 @@ void vector_float_take(int n, float *v, int m, int *p, float **u);
    give the position of the smallest, second smallest etc  in vector v if ascending = TRUE.
    results in p. If *p == NULL, p is assigned.
 */
-void vector_ordering(int n, real *v, int **p, int ascending);
+void vector_ordering(int n, real *v, int **p);
 void vector_sort_real(int n, real *v, int ascending);
 void vector_sort_int(int n, int *v, int ascending);
 real vector_median(int n, real *x);