ses_layout.c
authoryu.dongliang <18588496441@163.com>
Wed, 1 Nov 2023 06:29:04 +0000 (14:29 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 1 Nov 2023 06:29:04 +0000 (14:29 +0800)
ses_core.h
ses_layout.c

index 539c21b18cac337329b0ab31ba2d46678e0c5e3d..39be787d0be056518650a2a51aaa2c92545d401b 100644 (file)
@@ -124,6 +124,8 @@ ses_ctx_t*  ses_ctx_alloc();
 void        ses_ctx_free (ses_ctx_t* ctx);
 
 
+int ses_cross_graph_kcolor(scf_vector_t* graph, int k, scf_vector_t* colors);
+
 int ses_layout_board (ScfEboard*    b);
 int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count);
 
index de5f9a0f3a0df4fc4c0fbf7db8adaa6930379585..1f311e58a1271f487350bf5b5089be4ff3341842 100644 (file)
@@ -1249,6 +1249,35 @@ static void __ses_mov_pos(ScfEfunction* f, int d)
        }
 }
 
+int ses_cross(ScfEfunction* f, int d)
+{
+       scf_vector_t* graph  = scf_vector_alloc();
+       scf_vector_t* colors = scf_vector_alloc();
+       ses_edge_t*   edge;
+
+       scf_loge("\n");
+       __ses_get_crosses(f, d, graph);
+
+       scf_vector_add(colors, (void*)1);
+       scf_vector_add(colors, (void*)2);
+
+       int ret = ses_cross_graph_kcolor(graph, 2, colors);
+       if (ret < 0) {
+               scf_loge("\n");
+       }
+
+       int i;
+       for (i = 0; i < graph->size; i++) {
+               edge      = graph->data[i];
+
+               scf_logi("i: %d, c%ld->color: %ld\n", i, edge->c->id, edge->color);
+       }
+
+       scf_vector_clear(graph, ( void (*)(void*) )ses_edge_free);
+       scf_vector_free(graph);
+       scf_vector_free(colors);
+}
+
 int ses_layout_function(ScfEfunction* f, int d)
 {
        ScfEcomponent* c;
@@ -1276,31 +1305,17 @@ int ses_layout_function(ScfEfunction* f, int d)
 
        qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id);
 
-       scf_vector_t* crosses0 = scf_vector_alloc();
-       scf_vector_t* crosses1 = scf_vector_alloc();
-
-       scf_loge("\n");
-       __ses_get_crosses(f, d, crosses0);
-
        __ses_de_cross(f, d);
 
        __ses_setc_xy(f, d);
        __ses_xchg_cx(f, d);
        __ses_xchg_ce(f, d);
 
-       scf_loge("\n");
-       __ses_get_crosses(f, d, crosses1);
+       ses_cross(f, d);
 
        __ses_mov_pos(f, d);
        __ses_layout_cx(f, d);
 
-       scf_vector_clear(crosses0, ( void (*)(void*) )ses_edge_free);
-       scf_vector_clear(crosses1, ( void (*)(void*) )ses_edge_free);
-       scf_vector_free(crosses0);
-       scf_vector_free(crosses1);
-       crosses0 = NULL;
-       crosses1 = NULL;
-
        int tx0 = INT_MAX;
        int tx1 = 0;