From c411ee96eb90ee6aa7f4c1e6ead766dbfabce6f2 Mon Sep 17 00:00:00 2001 From: wjf-hs Date: Fri, 25 Apr 2025 16:56:58 +0800 Subject: [PATCH] =?UTF-8?q?add=5Fedge=E8=B0=83=E8=AF=95=E9=80=9A=E8=BF=87?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E7=BB=AD=E5=86=8D=E5=8C=BA=E5=88=86=E6=98=AF?= =?UTF-8?q?=E6=9C=89=E5=90=91=E5=9B=BE=E8=BF=98=E6=98=AF=E6=97=A0=E5=90=91?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graph.c | 11 ++++++----- test/test_graph.c | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/graph.c b/src/graph.c index 70eb4d5..03c6163 100644 --- a/src/graph.c +++ b/src/graph.c @@ -625,16 +625,16 @@ static bool graph_add_edge(struct _graph* self, void* from, void* to, uint32_t w return false; } - to_node = find_node(self, from); + to_node = find_node(self, to); if (to_node == NULL) { return false; } - printf("print from and to obj start \n"); - self->print_obj(from_node->obj); - self->print_obj(to_node->obj); - printf("print from and to obj end \n"); + // printf("print from and to obj start \n"); + // self->print_obj(from_node->obj); + // self->print_obj(to_node->obj); + // printf("print from and to obj end \n"); // from_node add edge struct _graph_edge* new_edge = graph_edge_new(to_node, weight); @@ -653,6 +653,7 @@ static bool graph_add_edge(struct _graph* self, void* from, void* to, uint32_t w } // if graph is undirected + // to_node add edge struct _graph_edge* new_edge2 = graph_edge_new(from_node, weight); if (new_edge2 == NULL) { diff --git a/test/test_graph.c b/test/test_graph.c index 18c9285..18d73e0 100644 --- a/test/test_graph.c +++ b/test/test_graph.c @@ -93,8 +93,8 @@ void test_graph_add_edge(void) // test add_edge TEST_ASSERT_TRUE(graph->add_edge(graph, &data[0], &data[1], 55)); - // TEST_ASSERT_TRUE(graph->add_edge(graph, &data[0], &data[2], 66)); - // TEST_ASSERT_TRUE(graph->add_edge(graph, &data[1], &data[3], 77)); + TEST_ASSERT_TRUE(graph->add_edge(graph, &data[0], &data[2], 66)); + TEST_ASSERT_TRUE(graph->add_edge(graph, &data[1], &data[3], 77)); graph->print(graph); TEST_ASSERT_FALSE(graph->add_edge(graph, &temp, &data[1], 0));