From 2eeba5bd9a686ef16bf53162dd7a4fe3f03d9a2f Mon Sep 17 00:00:00 2001 From: GroteGnoom <8137208+GroteGnoom@users.noreply.github.com> Date: Sat, 9 Dec 2023 16:40:29 +0100 Subject: [PATCH] simplify no_of_subsets --- src/paths/steiner.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/paths/steiner.cpp b/src/paths/steiner.cpp index 761f2f0ed5..c9b85bf6bf 100644 --- a/src/paths/steiner.cpp +++ b/src/paths/steiner.cpp @@ -283,19 +283,19 @@ igraph_error_t igraph_steiner_dreyfus_wagner( * Number of subsets is 2 ^ (number of steiner_terminals_copy) - (number of steiner_terminals_copy + 1) */ + igraph_integer_t no_of_subsets = + pow(2, no_of_terminals - 1) - no_of_terminals; + IGRAPH_CHECK( igraph_matrix_init(&dp_cache, - no_of_nodes + - pow(2, igraph_vector_int_size(&steiner_terminals_copy)) - - (igraph_vector_int_size(&steiner_terminals_copy) + 1), + no_of_nodes + no_of_subsets, no_of_nodes)); IGRAPH_FINALLY(igraph_matrix_destroy, &dp_cache); std::vector > distance_matrix = std::vector > ( - no_of_nodes + pow(2, igraph_vector_int_size(&steiner_terminals_copy)) - - (igraph_vector_int_size(&steiner_terminals_copy) + 1), + no_of_nodes + no_of_subsets, std::vector(no_of_nodes, int_set()) ); /* Addition to the dp_cache where at the same indices of the matrix we are storing