]> granicus.if.org Git - graphviz/commitdiff
edgepaint: remove 'iter_max' parameter from 'node_distinct_coloring'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 22 May 2022 17:08:54 +0000 (10:08 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 26 May 2022 14:09:53 +0000 (07:09 -0700)
This is always set to 100.

cmd/gvmap/make_map.c
lib/edgepaint/edge_distinct_coloring.c
lib/edgepaint/node_distinct_coloring.c
lib/edgepaint/node_distinct_coloring.h

index b5e5540f9364996a61d2dc3d6a5aa89b206d6e4f..eef39e7f971a34253728d8223ca3fee6466b5166 100644 (file)
@@ -52,7 +52,6 @@ void map_palette_optimal_coloring(char *color_scheme, char *lightness, SparseMat
 
   SparseMatrix A;
   bool weightedQ = true;
-  int iter_max = 100;
 
   {double *dist = NULL;
     A = SparseMatrix_symmetrize(A0, false);
@@ -64,7 +63,8 @@ void map_palette_optimal_coloring(char *color_scheme, char *lightness, SparseMat
     SparseMatrix_export(stdout, A);
   }
 
-  node_distinct_coloring(color_scheme, lightness, weightedQ, A, accuracy, iter_max, seed, &cdim, &colors);
+  node_distinct_coloring(color_scheme, lightness, weightedQ, A, accuracy, seed,
+                         &cdim, &colors);
 
   if (A != A0){
     SparseMatrix_delete(A);
index 5226373699961404b784a67a4007491d4803990b..517ccdabf0acfe7c351c2a0fc1b98cf53809e091 100644 (file)
@@ -238,8 +238,8 @@ Agraph_t* edge_distinct_coloring(char *color_scheme, char *lightness, Agraph_t*
     clock_t start = clock();
 #endif
     int weightedQ = FALSE;
-    int iter_max = 100;
-    flag = node_distinct_coloring(color_scheme, lightness, weightedQ, C, accuracy, iter_max, seed, &cdim, &colors);
+    flag = node_distinct_coloring(color_scheme, lightness, weightedQ, C,
+                                  accuracy, seed, &cdim, &colors);
     if (flag) goto RETURN;
 #ifdef TIME
     fprintf(stderr, "cpu for color assignmment =%10.3f\n", ((double) (clock() - start))/CLOCKS_PER_SEC);
index 1ebda2fe281734bf25bcbd3453be926881ff848b..43e31cdc1c5ecf0da839f87142055f82c6e7a71b 100644 (file)
@@ -20,8 +20,8 @@
 static void node_distinct_coloring_internal2(int scheme, QuadTree qt,
                                              bool weightedQ, SparseMatrix A,
                                              int cdim, double accuracy,
-                                             int iter_max, int seed,
-                                             double *colors, double *color_diff0,
+                                             int seed, double *colors,
+                                             double *color_diff0,
                                              double *color_diff_sum0) {
   /* here we assume the graph is connected. And that the matrix is symmetric */
   int i, j, *ia, *ja, n, k = 0;
@@ -34,6 +34,7 @@ static void node_distinct_coloring_internal2(int scheme, QuadTree qt,
   double color_diff = 0, color_diff_old;
   double color_diff_sum = 0, color_diff_sum_old, *cc;
   int iter = 0;
+  static const int iter_max = 100;
   double cspace_size = 0.7;
   double red[3], black[3], min;
   int flag = 0, imin;
@@ -154,8 +155,7 @@ static void node_distinct_coloring_internal2(int scheme, QuadTree qt,
 static void node_distinct_coloring_internal(int scheme, QuadTree qt,
                                             bool weightedQ, SparseMatrix A,
                                             int cdim, double accuracy,
-                                            int iter_max, int seed,
-                                            double *colors) {
+                                            int seed, double *colors) {
   int i;
   double color_diff;
   double color_diff_sum;
@@ -167,20 +167,20 @@ static void node_distinct_coloring_internal(int scheme, QuadTree qt,
     iter = -seed;
     for (i = 0; i < iter; i++){
       seed = irand(100000);
-      node_distinct_coloring_internal2(scheme, qt, weightedQ, A, cdim, accuracy, iter_max, seed, colors, &color_diff, &color_diff_sum);
+      node_distinct_coloring_internal2(scheme, qt, weightedQ, A, cdim, accuracy, seed, colors, &color_diff, &color_diff_sum);
       if (color_diff_max < color_diff){
        seed_max = seed; color_diff_max = color_diff;
       }
     }
     seed = seed_max;
   } 
-  node_distinct_coloring_internal2(scheme, qt, weightedQ, A, cdim, accuracy, iter_max, seed, colors, &color_diff, &color_diff_sum);
+  node_distinct_coloring_internal2(scheme, qt, weightedQ, A, cdim, accuracy, seed, colors, &color_diff, &color_diff_sum);
  
 }
 
 int node_distinct_coloring(char *color_scheme, char *lightness, bool weightedQ,
-                           SparseMatrix A0, double accuracy, int iter_max,
-                           int seed, int *cdim0, double **colors) {
+                           SparseMatrix A0, double accuracy, int seed,
+                           int *cdim0, double **colors) {
   /* 
      for a graph A, get a distinctive color of its nodes so that the color distance among all neighboring nodes are maximized. Here
      color distance on a node is defined as the minimum of color differences between a node and its neighbors (or the minimum of weighted color differences if weightedQ = true,
@@ -193,7 +193,6 @@ int node_distinct_coloring(char *color_scheme, char *lightness, bool weightedQ,
      A: the graph of n nodes
      accuracy: how accurate to find the optimal
      seed: random_seed. If negative, consider -seed as the number of random start iterations
-     iter_max: max number of 
      cdim: dimension of the color space
      color: On input an array of size n*cdim, if NULL, will be allocated. On exit the final color assignment for node i is [cdim*i,cdim*(i+1)), in RGB (between 0 to 1)
   */ 
@@ -208,8 +207,6 @@ int node_distinct_coloring(char *color_scheme, char *lightness, bool weightedQ,
   int maxcolors = 10000, max_qtree_level = 10, r, g, b;
   char *color_list = NULL;
 
-  if (iter_max < 0) iter_max = 100;
-
   color_list = color_palettes_get(color_scheme);
   if (color_list) color_scheme = color_list;
 
@@ -260,7 +257,7 @@ int node_distinct_coloring(char *color_scheme, char *lightness, bool weightedQ,
   for (i = 0; i < ncomps; i++){
     nn = comps_ptr[i+1] - comps_ptr[i];
     B = SparseMatrix_get_submatrix(A, nn, nn, &(comps[comps_ptr[i]]), &(comps[comps_ptr[i]]));
-    node_distinct_coloring_internal(scheme, qt, weightedQ, B, cdim, accuracy, iter_max, seed, ctmp);
+    node_distinct_coloring_internal(scheme, qt, weightedQ, B, cdim, accuracy, seed, ctmp);
 
     for (j = comps_ptr[i]; j < comps_ptr[i+1]; j++){
       jj = j - comps_ptr[i];
index b15d1f6c2eb35157471e9b7a4f72eb00537fbfa6..e485514d1a63464c5b5bf46d3a49e8189cdab9bd 100644 (file)
@@ -15,5 +15,5 @@
 enum {COLOR_RGB, COLOR_GRAY, COLOR_LAB};
 enum {ERROR_BAD_COLOR_SCHEME = -9};
 int node_distinct_coloring(char *color_scheme, char *lightness, bool weightedQ,
-                           SparseMatrix A, double accuracy, int iter_max,
-                           int seed, int *cdim, double **colors);
+                           SparseMatrix A, double accuracy, int seed, int *cdim,
+                           double **colors);