fix GetAdjacendEdgeRange of matrix wrapper for tarjan scc and fix wrongly solved merge conflict

This commit is contained in:
Huyen Chau Nguyen 2015-08-19 19:44:11 +02:00
parent 78a8cf6982
commit 2de3fc9f6f
2 changed files with 11 additions and 12 deletions

View File

@ -52,6 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
#include <map>
template <typename GraphT> class TarjanSCC template <typename GraphT> class TarjanSCC
{ {
@ -192,6 +193,7 @@ template <typename GraphT> class TarjanSCC
}); });
} }
std::size_t get_number_of_components() const { return component_size_vector.size(); } 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; } std::size_t get_size_one_count() const { return size_one_counter; }
@ -201,12 +203,9 @@ template <typename GraphT> class TarjanSCC
return component_size_vector[component_id]; 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]; } unsigned get_component_id(const NodeID node) const { return components_index[node]; }
}; };
#endif /* TARJAN_SCC_HPP */ #endif /* TARJAN_SCC_HPP */

View File

@ -42,13 +42,13 @@ public:
return number_of_nodes_; return number_of_nodes_;
} }
std::vector<EdgeWeight> GetAdjacentEdgeRange(const NodeID node) const { std::vector<T> GetAdjacentEdgeRange(const NodeID node) const {
std::vector<EdgeWeight> edges; std::vector<T> edges;
auto neq_invalid_edge_weight = [](EdgeWeight e){return (e != INVALID_EDGE_WEIGHT);}; for (auto i = 0; i < number_of_nodes_; ++i) {
std::copy_if(std::begin(table_), if (*(std::begin(table_) + node * number_of_nodes_ + i) != INVALID_EDGE_WEIGHT) {
std::end(table_), edges.push_back(i);
std::back_inserter(edges), }
neq_invalid_edge_weight); }
return edges; return edges;
} }