if (!graph || !colors || 0 == colors->size)
return -EINVAL;
- return __graph_kcolor(graph, k, colors);
+ int ret = __graph_kcolor(graph, k, colors);
+ if (ret < 0)
+ return ret;
+
+ scf_vector_t* __colors = scf_vector_clone(colors);
+ if (!__colors)
+ return -ENOMEM;
+
+ ses_vertex_t* v = NULL;
+ int i;
+ int j;
+
+ for (i = 0; i < graph->size; i++) {
+ v = graph->data[i];
+
+ scf_vector_del(__colors, (void*)v->color);
+ }
+
+ for (j = 0; j < __colors->size; j++) {
+
+ for (i = 0; i < graph->size; i++) {
+ v = graph->data[i];
+
+ if (v->color < 0) {
+ v->color = (intptr_t)__colors->data[j];
+ break;
+ }
+ }
+ }
+
+ scf_vector_free(__colors);
+ return 0;
}
scf_loge("**********\n");
}
- int n = 0;
-
for (i = 0; i < graph->size; i++) {
v = graph->data[i];
- c = v->data;
-
if (v->color < 0) {
- c->color = j;
- n++;
scf_loge("j: %ld, i: %ld, c%ld->color: %ld\n", j, i, c->id, v->color);
- } else
- c->color = v->color;
- v->color = 0;
+ break;
+ }
}
- if (n > 0)
+ if (i < graph->size)
break;
+ for (i = 0; i < graph->size; i++) {
+ v = graph->data[i];
+
+ c = v->data;
+ c->color = v->color;
+ v->color = 0;
+ }
+
scf_vector_clear(colors, NULL);
}
int x1 = 0;
- N = j;
+ N = j + 1;
for (j = 1; j <= N; j++) {