From: Matthew Fernandez Date: Sun, 9 Jan 2022 16:56:53 +0000 (-0800) Subject: node_distinct_coloring: take 'weightedQ' parameter as a C99 bool X-Git-Tag: 3.0.0~79^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fed75ac239e9e81189f6a8784038248219aed083;p=graphviz node_distinct_coloring: take 'weightedQ' parameter as a C99 bool --- diff --git a/cmd/gvmap/make_map.c b/cmd/gvmap/make_map.c index 69c279643..a1014cc6c 100644 --- a/cmd/gvmap/make_map.c +++ b/cmd/gvmap/make_map.c @@ -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; diff --git a/lib/edgepaint/node_distinct_coloring.c b/lib/edgepaint/node_distinct_coloring.c index 741419970..8cdf14907 100644 --- a/lib/edgepaint/node_distinct_coloring.c +++ b/lib/edgepaint/node_distinct_coloring.c @@ -14,6 +14,7 @@ #include #include #include +#include #include 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, diff --git a/lib/edgepaint/node_distinct_coloring.h b/lib/edgepaint/node_distinct_coloring.h index b8550eb55..b15d1f6c2 100644 --- a/lib/edgepaint/node_distinct_coloring.h +++ b/lib/edgepaint/node_distinct_coloring.h @@ -10,6 +10,10 @@ #pragma once +#include + 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);