]> granicus.if.org Git - graphviz/commitdiff
node_distinct_coloring: take 'weightedQ' parameter as a C99 bool
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 9 Jan 2022 16:56:53 +0000 (08:56 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 10 Jan 2022 15:51:35 +0000 (07:51 -0800)
cmd/gvmap/make_map.c
lib/edgepaint/node_distinct_coloring.c
lib/edgepaint/node_distinct_coloring.h

index 69c2796433e7d3220069d64c460facdd08316828..a1014cc6c5a3e73ddd9f1b74f565f7b4d663c17a 100644 (file)
@@ -50,7 +50,7 @@ void map_palette_optimal_coloring(char *color_scheme, char *lightness, SparseMat
   int n = A0->m, i, cdim;
 
   SparseMatrix A;
-  int weightedQ = TRUE;
+  bool weightedQ = true;
   int iter_max = 100;
 
   {double *dist = NULL;
index 741419970768b4d775f2a6181cab098538300fa9..8cdf14907b78c049bd995152f3714623071fb59f 100644 (file)
@@ -14,6 +14,7 @@
 #include <edgepaint/lab.h>
 #include <edgepaint/furtherest_point.h>
 #include <sparse/color_palette.h>
+#include <stdbool.h>
 #include <string.h>
 
 static double mydist(int dim, double *x, double *y){
@@ -24,8 +25,12 @@ static double mydist(int dim, double *x, double *y){
 }
 
 
-static void node_distinct_coloring_internal2(int scheme, QuadTree qt, int weightedQ, SparseMatrix A, int cdim, double accuracy, int iter_max, int seed, double *colors, 
-                                            double *color_diff0, double *color_diff_sum0){
+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,
+                                             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;
   int max_level;
@@ -154,7 +159,11 @@ static void node_distinct_coloring_internal2(int scheme, QuadTree qt, int weight
   free(x);
 }
  
-static void node_distinct_coloring_internal(int scheme, QuadTree qt, int weightedQ,  SparseMatrix A, int cdim, double accuracy, int iter_max, int seed, double *colors){
+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 i;
   double color_diff;
   double color_diff_sum;
@@ -177,7 +186,9 @@ static void node_distinct_coloring_internal(int scheme, QuadTree qt, int weighte
  
 }
 
-int node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, SparseMatrix A0, double accuracy, int iter_max, int seed, int *cdim0, double **colors){
+int node_distinct_coloring(char *color_scheme, char *lightness, bool weightedQ,
+                           SparseMatrix A0, double accuracy, int iter_max,
+                           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,
index b8550eb55226d6e3587d36e0f6a9199606268c81..b15d1f6c2eb35157471e9b7a4f72eb00537fbfa6 100644 (file)
 
 #pragma once
 
+#include <stdbool.h>
+
 enum {COLOR_RGB, COLOR_GRAY, COLOR_LAB};
 enum {ERROR_BAD_COLOR_SCHEME = -9};
-int node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, SparseMatrix A, double accuracy, int iter_max, int seed, int *cdim, double **colors);
+int node_distinct_coloring(char *color_scheme, char *lightness, bool weightedQ,
+                           SparseMatrix A, double accuracy, int iter_max,
+                           int seed, int *cdim, double **colors);