__ses_de_cross()
authoryu.dongliang <18588496441@163.com>
Wed, 8 Nov 2023 07:12:24 +0000 (15:12 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 8 Nov 2023 07:12:24 +0000 (15:12 +0800)
ses_layout.c

index 708ba980d05410609d3ceafa679490d73d61c14c..ffb4c188eb29436f6abb58a66a7f4fb1cdf381e2 100644 (file)
@@ -1048,7 +1048,7 @@ next:
        return 0;
 }
 
-static int __ses_de_cross(ScfEfunction* f, int d)
+static int __ses_de_cross(ScfEfunction* f, int d, intptr_t N)
 {
        ScfEcomponent* c;
        ScfEline*      el;
@@ -1070,7 +1070,6 @@ static int __ses_de_cross(ScfEfunction* f, int d)
                return -ENOMEM;
        }
 
-       intptr_t N = 2;
        intptr_t i;
        intptr_t j;
        intptr_t k;
@@ -1079,13 +1078,15 @@ static int __ses_de_cross(ScfEfunction* f, int d)
        if (ret < 0)
                return ret;
 
-       if (0  < graph->size) {
-               v  = graph->data[0];
-
-               N  = v->edges->size;
+       if (N <= 0) {
+               if (0 < graph->size) {
+                       v = graph->data[0];
+                       N = v->edges->size;
+               } else
+                       N = 2;
        }
 
-       for (j = N; j >= 1; j--) {
+       for (j = N; j >= 2; j--) {
 
                for (i = 1; i <= j; i++)
                        scf_vector_add(colors, (void*)i);
@@ -1098,7 +1099,7 @@ static int __ses_de_cross(ScfEfunction* f, int d)
                for (i = 0; i < graph->size; i++) {
                        v         = graph->data[i];
 
-                       if (v->color < 0) {
+                       if (v->color < 0 && j > 2) {
                                c = v->data;
                                scf_loge("j: %ld, i: %ld, c%ld->color: %ld\n", j, i, c->id, v->color);
                                break;
@@ -1111,10 +1112,18 @@ static int __ses_de_cross(ScfEfunction* f, int d)
                for (i = 0; i < graph->size; i++) {
                        v         = graph->data[i];
 
-                       c        = v->data;
-                       c->color = v->color;
+                       c = v->data;
+                       if (v->color > 0) {
+                               c->color = v->color;
+                               scf_logi("j: %ld, i: %ld, c%ld->color: %ld\n", j, i, c->id, c->color);
+                       } else {
+                               c->color = j;
+                               scf_loge("j: %ld, i: %ld, c%ld->color: %ld\n", j, i, c->id, c->color);
+                       }
+
                        v->color = 0;
                }
+               printf("\n");
 
                scf_vector_clear(colors, NULL);
        }
@@ -1475,7 +1484,7 @@ int ses_layout_function(ScfEfunction* f, int d)
 
        qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id);
 
-       ret = __ses_de_cross(f, d);
+       ret = __ses_de_cross(f, d, 0);
        if (ret < 0)
                return ret;