From 2de3fc9f6f5bc688ac06c2cc7d3098adb73133ef Mon Sep 17 00:00:00 2001 From: Huyen Chau Nguyen Date: Wed, 19 Aug 2015 19:44:11 +0200 Subject: [PATCH] fix GetAdjacendEdgeRange of matrix wrapper for tarjan scc and fix wrongly solved merge conflict --- algorithms/tarjan_scc.hpp | 9 ++++----- data_structures/matrix_graph_wrapper.hpp | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/algorithms/tarjan_scc.hpp b/algorithms/tarjan_scc.hpp index 8444d785a..6f5bc1563 100644 --- a/algorithms/tarjan_scc.hpp +++ b/algorithms/tarjan_scc.hpp @@ -52,6 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include template class TarjanSCC { @@ -192,6 +193,7 @@ template class TarjanSCC }); } + std::size_t get_number_of_components() const { return component_size_vector.size(); } std::size_t get_size_one_count() const { return size_one_counter; } @@ -201,12 +203,9 @@ template class TarjanSCC return component_size_vector[component_id]; } - unsigned get_component_size_by_id(const unsigned component_id) const - { - return component_size_vector[component_id]; - } - unsigned get_component_id(const NodeID node) const { return components_index[node]; } + + }; #endif /* TARJAN_SCC_HPP */ diff --git a/data_structures/matrix_graph_wrapper.hpp b/data_structures/matrix_graph_wrapper.hpp index 9a6180ce9..95b0e4c86 100644 --- a/data_structures/matrix_graph_wrapper.hpp +++ b/data_structures/matrix_graph_wrapper.hpp @@ -42,13 +42,13 @@ public: return number_of_nodes_; } - std::vector GetAdjacentEdgeRange(const NodeID node) const { - std::vector edges; - auto neq_invalid_edge_weight = [](EdgeWeight e){return (e != INVALID_EDGE_WEIGHT);}; - std::copy_if(std::begin(table_), - std::end(table_), - std::back_inserter(edges), - neq_invalid_edge_weight); + std::vector GetAdjacentEdgeRange(const NodeID node) const { + std::vector edges; + for (auto i = 0; i < number_of_nodes_; ++i) { + if (*(std::begin(table_) + node * number_of_nodes_ + i) != INVALID_EDGE_WEIGHT) { + edges.push_back(i); + } + } return edges; }