From 231fad73fc4f1825ee14e99b9c629995c4a2fb8d Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 27 May 2022 22:45:54 -0700 Subject: [PATCH] gvmap: remove 'accuracy' parameter from 'map_palette_optimal_coloring' This is always passed as 0.01. --- cmd/gvmap/gvmap.c | 2 +- cmd/gvmap/make_map.c | 9 +++++---- cmd/gvmap/make_map.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/gvmap/gvmap.c b/cmd/gvmap/gvmap.c index d1b7bd2ae..0f2ed36b1 100644 --- a/cmd/gvmap/gvmap.c +++ b/cmd/gvmap/gvmap.c @@ -370,7 +370,7 @@ makeMap (SparseMatrix graph, int n, double* x, double* width, int* grouping, if (pm->color_optimize && country_graph && rgb_r && rgb_g && rgb_b) map_optimal_coloring(pm->seed, country_graph, rgb_r, rgb_g, rgb_b); else if (pm->color_scheme_str){ - map_palette_optimal_coloring(pm->color_scheme_str, country_graph, 0.01, -10, + map_palette_optimal_coloring(pm->color_scheme_str, country_graph, -10, &rgb_r, &rgb_g, &rgb_b); } diff --git a/cmd/gvmap/make_map.c b/cmd/gvmap/make_map.c index 3b238171d..262b2368c 100644 --- a/cmd/gvmap/make_map.c +++ b/cmd/gvmap/make_map.c @@ -28,16 +28,13 @@ #include #include -void map_palette_optimal_coloring(char *color_scheme, SparseMatrix A0, double accuracy, int seed, +void map_palette_optimal_coloring(char *color_scheme, SparseMatrix A0, int seed, float **rgb_r, float **rgb_g, float **rgb_b){ /* for a graph A, get a distinctive color of its nodes so that the color distanmce among all nodes are maximized. Here color distance on a node is defined as the minimum of color differences between a node and its neighbors. - accuracy is the threshold given so that when finding the coloring for each node, the optimal is - with in "accuracy" of the true global optimal. color_scheme: rgb, gray, lab, or one of the color palettes in color_palettes.h, or a list of hex rgb colors separaterd by comma like "#ff0000,#00ff00" A: the graph of n nodes - accuracy: how accurate to find the optimal cdim: dimension of the color space seed: random_seed. If negative, consider -seed as the number of random start iterations rgb_r, rgb_g, rgb_b: float array of length A->m + 1, which contains color for each country. 1-based @@ -65,6 +62,10 @@ void map_palette_optimal_coloring(char *color_scheme, SparseMatrix A0, double ac // color. Ignored if scheme is not COLOR_LAB. char *lightness = "0,100"; + // accuracy is the threshold given so that when finding the coloring for each + // node, the optimal is with in "accuracy" of the true global optimal. + const double accuracy = 0.01; + node_distinct_coloring(color_scheme, lightness, weightedQ, A, accuracy, seed, &cdim, &colors); diff --git a/cmd/gvmap/make_map.h b/cmd/gvmap/make_map.h index 156ce2d5c..01ccfdc8d 100644 --- a/cmd/gvmap/make_map.h +++ b/cmd/gvmap/make_map.h @@ -28,7 +28,7 @@ void plot_dot_map(Agraph_t* gr, int n, int dim, double *x, SparseMatrix polys, const char* opacity, SparseMatrix A, FILE*); void map_optimal_coloring(int seed, SparseMatrix A, float *rgb_r, float *rgb_g, float *rgb_b); -void map_palette_optimal_coloring(char *color_scheme, SparseMatrix A, double accuracy, int seed, float **rgb_r, float **rgb_g, float **rgb_b); +void map_palette_optimal_coloring(char *color_scheme, SparseMatrix A, int seed, float **rgb_r, float **rgb_g, float **rgb_b); enum {POLY_LINE_REAL_EDGE, POLY_LINE_NOT_REAL_EDGE}; #define neighbor(t, i, edim, elist) elist[(edim)*(t)+i] -- 2.40.0