Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
node_distinct_coloring.c File Reference
#include <sparse/general.h>
#include <sparse/SparseMatrix.h>
#include <sparse/QuadTree.h>
#include <edgepaint/node_distinct_coloring.h>
#include <edgepaint/lab.h>
#include <edgepaint/furtherest_point.h>
#include <sparse/color_palette.h>
#include <stdbool.h>
#include <string.h>
#include <util/alloc.h>
Include dependency graph for node_distinct_coloring.c:

Go to the source code of this file.

Functions

static void node_distinct_coloring_internal2 (int scheme, QuadTree qt, bool weightedQ, SparseMatrix A, int cdim, double accuracy, int seed, double *colors, double *color_diff0, double *color_diff_sum0)
 
static void node_distinct_coloring_internal (int scheme, QuadTree qt, bool weightedQ, SparseMatrix A, int cdim, double accuracy, int seed, double *colors)
 
int node_distinct_coloring (const char *color_scheme, int *lightness, bool weightedQ, SparseMatrix A0, double accuracy, int seed, int *cdim0, double **colors)
 

Function Documentation

◆ node_distinct_coloring()

int node_distinct_coloring ( const char *  color_scheme,
int *  lightness,
bool  weightedQ,
SparseMatrix  A,
double  accuracy,
int  seed,
int *  cdim,
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, where weights are stored as entries of A0. 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.

Parameters
color_schemergb, gray, lab, or one of the color palettes in color_palettes.h, or a list of hex rgb colors separated by comma like "#ff0000,#00ff00"
lightnessof the form 0,70, specifying the range of lightness of LAB color. Ignored if scheme is not COLOR_LAB.
Athe graph of n nodes
accuracyhow accurate to find the optimal
seedrandom_seed. If negative, consider -seed as the number of random start iterations
cdimdimension of the color space
colorOn 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)

Definition at line 179 of file node_distinct_coloring.c.

References A, B, color_blend_rgb2lab(), COLOR_GRAY, COLOR_LAB, color_palettes_get(), COLOR_RGB, ERROR_BAD_COLOR_SCHEME, free(), gv_calloc(), lab_gamut_quadtree(), node_distinct_coloring_internal(), NULL, QuadTree_delete(), QuadTree_new_from_point_list(), seed, SparseMatrix_delete(), SparseMatrix_get_submatrix(), SparseMatrix_symmetrize(), SparseMatrix_weakly_connected_components(), and Verbose.

Referenced by edge_distinct_coloring(), and map_palette_optimal_coloring().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ node_distinct_coloring_internal()

static void node_distinct_coloring_internal ( int  scheme,
QuadTree  qt,
bool  weightedQ,
SparseMatrix  A,
int  cdim,
double  accuracy,
int  seed,
double *  colors 
)
static

Definition at line 153 of file node_distinct_coloring.c.

References A, irand(), node_distinct_coloring_internal2(), and seed.

Referenced by node_distinct_coloring().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ node_distinct_coloring_internal2()

static void node_distinct_coloring_internal2 ( int  scheme,
QuadTree  qt,
bool  weightedQ,
SparseMatrix  A,
int  cdim,
double  accuracy,
int  seed,
double *  colors,
double *  color_diff0,
double *  color_diff_sum0 
)
static

Definition at line 22 of file node_distinct_coloring.c.

References lab_struct::a, A, rgb_struct::b, lab_struct::b, black, center(), COLOR_GRAY, COLOR_LAB, color_lab_init(), COLOR_RGB, drand(), free(), furtherest_point(), furtherest_point_in_list(), rgb_struct::g, gv_calloc(), imin(), lab_struct::l, LAB2RGB(), LAB2RGB_real_01(), MATRIX_TYPE_REAL, MAX, MIN, NULL, QuadTree_get_nearest(), rgb_struct::r, RGB2LAB(), seed, and Verbose.

Referenced by node_distinct_coloring_internal().

Here is the call graph for this function:
Here is the caller graph for this function: