This makes things simpler for readers, callers, as well as the compiler.
color_diff_sum: the sum of min color dfference across all nodes
*/
real *colors = NULL, color_diff, color_diff_sum;
- int flag;
int n = A0->m, i, cdim;
SparseMatrix A;
SparseMatrix_export(stdout, A);
}
- node_distinct_coloring(color_scheme, lightness, weightedQ, A, accuracy, iter_max, seed, &cdim, &colors, &color_diff, &color_diff_sum, &flag);
+ node_distinct_coloring(color_scheme, lightness, weightedQ, A, accuracy, iter_max, seed, &cdim, &colors, &color_diff, &color_diff_sum);
if (A != A0){
SparseMatrix_delete(A);
#endif
int weightedQ = FALSE;
int iter_max = 100;
- node_distinct_coloring(color_scheme, lightness, weightedQ, C, accuracy, iter_max, seed, &cdim, &colors, &color_diff, &color_diff_sum, &flag);
+ flag = node_distinct_coloring(color_scheme, lightness, weightedQ, C, accuracy, iter_max, seed, &cdim, &colors, &color_diff, &color_diff_sum);
if (flag) goto RETURN;
#ifdef TIME
fprintf(stderr, "cpu for color assignmment =%10.3f\n", ((real) (clock() - start))/CLOCKS_PER_SEC);
}
-void node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, SparseMatrix A0, real accuracy, int iter_max, int seed, int *cdim0, real **colors, real *color_diff0,
- real *color_diff_sum0, int *flag){
+int node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, SparseMatrix A0, real accuracy, int iter_max, int seed, int *cdim0, real **colors, real *color_diff0,
+ real *color_diff_sum0){
/*
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,
qt = lab_gamut_quadtree(lightness, max_qtree_level);
if (!qt){
fprintf(stderr, "out of memory\n");
- *flag = -1;
- return;
+ return -1;
}
} else if (strcmp(color_scheme, "rgb") == 0){
if (Verbose) fprintf(stderr,"rgb\n");
qt = QuadTree_new_from_point_list(cdim, maxcolors, max_qtree_level, colors, NULL);
assert(qt);
} else {
- *flag = ERROR_BAD_COLOR_SCHEME;
- return;
+ return ERROR_BAD_COLOR_SCHEME;
}
*color_diff0 = *color_diff_sum0 = -1;
if (accuracy <= 0) accuracy = 0.0001;
- *flag = 0;
n = A->m;
if (n != A->n) {
- *flag = -1;
- return;
+ return -1;
}
if (!(*colors)) {
*color_diff_sum0 /= nnodes;
if (A != A0) SparseMatrix_delete(A);
+ return 0;
}
enum {COLOR_RGB, COLOR_GRAY, COLOR_LAB};
enum {ERROR_BAD_COLOR_SCHEME = -9};
-void node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, SparseMatrix A, real accuracy, int iter_max, int seed, int *cdim, real **colors, real *color_diff, real *color_diff_sum, int *flag);
+int node_distinct_coloring(char *color_scheme, char *lightness, int weightedQ, SparseMatrix A, real accuracy, int iter_max, int seed, int *cdim, real **colors, real *color_diff, real *color_diff_sum);
#endif