From e7ca410e3ba7ada82e23bf1a486e36951b38236d Mon Sep 17 00:00:00 2001 From: RonakGSahu Date: Sat, 22 Jul 2023 18:35:54 -0400 Subject: [PATCH] Added the testcase that was on PR which was previously failing --- tests/unit/igraph_steiner_tree_fpt.c | 28 ++++++++++++++++++++++++++ tests/unit/igraph_steiner_tree_fpt.out | 7 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/unit/igraph_steiner_tree_fpt.c b/tests/unit/igraph_steiner_tree_fpt.c index 58e4463b81..7f0e1b460b 100644 --- a/tests/unit/igraph_steiner_tree_fpt.c +++ b/tests/unit/igraph_steiner_tree_fpt.c @@ -385,6 +385,9 @@ int main(void) { igraph_vector_int_print(&tree_edges_new); printf("value: %f\n", value_new_1); + igraph_vector_int_destroy(&tree_edges_new); + igraph_vector_int_destroy(&terminals_new); + printf("\nA simple square graph with few more edges outside the square\n"); igraph_t g_new_2; igraph_real_t value_new_2; @@ -404,11 +407,36 @@ int main(void) { printf("value: %f\n", value_new_2); + igraph_vector_int_destroy(&tree_edges_new); + igraph_vector_int_destroy(&terminals_new); + + printf("\nA 3 vertices square graph with weights\n"); + igraph_t g_new_3; + igraph_vector_t weights; + igraph_vector_init(&weights, 12); + igraph_vector_fill(&weights, 100); + igraph_small(&g_new_3, 9, IGRAPH_UNDIRECTED, + 0, 1, 1, 2, + 0, 3, 1, 4, 2, 5, + 3, 4, 4, 5, + 3, 6, 4, 7, 5, 8, + 6, 7, 7, 8, + -1); + igraph_vector_int_init_int_end(&terminals_new, -1, 0, 4, 2, 8, -1); + igraph_vector_int_init(&tree_edges_new, 0); + igraph_steiner_dreyfus_wagner(&g_new_3, &terminals_new, &weights, &value_new, &tree_edges_new); + printf("Tree edges:\n"); + igraph_vector_int_print(&tree_edges_new); + printf("value: %f\n", value_new); + + igraph_destroy(&g_new); igraph_destroy(&g_new_1); igraph_destroy(&g_new_2); + igraph_destroy(&g_new_3); igraph_vector_int_destroy(&tree_edges_new); igraph_vector_int_destroy(&terminals_new); + igraph_vector_destroy(&weights); VERIFY_FINALLY_STACK(); diff --git a/tests/unit/igraph_steiner_tree_fpt.out b/tests/unit/igraph_steiner_tree_fpt.out index fd0ed2a4b9..8385bc2222 100644 --- a/tests/unit/igraph_steiner_tree_fpt.out +++ b/tests/unit/igraph_steiner_tree_fpt.out @@ -73,4 +73,9 @@ value: 6.000000 A simple square graph with few more edges outside the square Tree edges: 0 2 3 5 -value: 4.000000 \ No newline at end of file +value: 4.000000 + +A 3 vertices square graph with weights +Tree edges: +0 1 3 8 11 +value: 500.000000