Skip to content

Commit

Permalink
Added the testcase that was on PR which was previously failing
Browse files Browse the repository at this point in the history
  • Loading branch information
RonakGSahu committed Jul 22, 2023
1 parent 1ffa9ab commit e7ca410
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
28 changes: 28 additions & 0 deletions tests/unit/igraph_steiner_tree_fpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down
7 changes: 6 additions & 1 deletion tests/unit/igraph_steiner_tree_fpt.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
value: 4.000000

A 3 vertices square graph with weights
Tree edges:
0 1 3 8 11
value: 500.000000

0 comments on commit e7ca410

Please sign in to comment.