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));