From 0e7c3d8ad49f3a308a796effed9df5be6dcc251f Mon Sep 17 00:00:00 2001 From: Jingchen Ye <11172084+97littleleaf11@users.noreply.github.com> Date: Fri, 10 Mar 2023 00:47:28 +0800 Subject: [PATCH] Move TarjanSCC from extractor to util (#6562) --- include/util/matrix_graph_wrapper.hpp | 2 +- include/{extractor => util}/tarjan_scc.hpp | 4 ++-- src/extractor/extractor.cpp | 4 ++-- src/partitioner/recursive_bisection_state.cpp | 4 ++-- src/tools/components.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) rename include/{extractor => util}/tarjan_scc.hpp (99%) diff --git a/include/util/matrix_graph_wrapper.hpp b/include/util/matrix_graph_wrapper.hpp index 2ff068392..c40fd131a 100644 --- a/include/util/matrix_graph_wrapper.hpp +++ b/include/util/matrix_graph_wrapper.hpp @@ -10,7 +10,7 @@ namespace osrm::util { -// This Wrapper provides all methods that are needed for extractor::TarjanSCC, when the graph is +// This Wrapper provides all methods that are needed for util::TarjanSCC, when the graph is // given in a matrix representation (e.g. as output from a distance table call) template class MatrixGraphWrapper diff --git a/include/extractor/tarjan_scc.hpp b/include/util/tarjan_scc.hpp similarity index 99% rename from include/extractor/tarjan_scc.hpp rename to include/util/tarjan_scc.hpp index 113001518..eb6170264 100644 --- a/include/extractor/tarjan_scc.hpp +++ b/include/util/tarjan_scc.hpp @@ -22,7 +22,7 @@ #include #include -namespace osrm::extractor +namespace osrm::util { template class TarjanSCC @@ -178,6 +178,6 @@ template class TarjanSCC unsigned GetComponentID(const NodeID node) const { return components_index[node]; } }; -} // namespace osrm::extractor +} // namespace osrm::util #endif /* TARJAN_SCC_HPP */ diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index b2107bef1..a48ffdb02 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -16,7 +16,6 @@ #include "extractor/restriction_graph.hpp" #include "extractor/restriction_parser.hpp" #include "extractor/scripting_environment.hpp" -#include "extractor/tarjan_scc.hpp" #include "extractor/turn_path_filter.hpp" #include "extractor/way_restriction_map.hpp" @@ -31,6 +30,7 @@ #include "util/log.hpp" #include "util/static_graph.hpp" #include "util/static_rtree.hpp" +#include "util/tarjan_scc.hpp" #include "util/timing_util.hpp" // Keep debug include to make sure the debug header is in sync with types. @@ -699,7 +699,7 @@ void Extractor::FindComponents(unsigned number_of_edge_based_nodes, auto uncontracted_graph = UncontractedGraph(number_of_edge_based_nodes, edges); - TarjanSCC component_search(uncontracted_graph); + util::TarjanSCC component_search(uncontracted_graph); component_search.Run(); for (NodeID node_id = 0; node_id < number_of_edge_based_nodes; ++node_id) diff --git a/src/partitioner/recursive_bisection_state.cpp b/src/partitioner/recursive_bisection_state.cpp index e5cb9226a..f6581674c 100644 --- a/src/partitioner/recursive_bisection_state.cpp +++ b/src/partitioner/recursive_bisection_state.cpp @@ -1,6 +1,6 @@ #include "partitioner/recursive_bisection_state.hpp" -#include "extractor/tarjan_scc.hpp" #include "partitioner/tarjan_graph_wrapper.hpp" +#include "util/tarjan_scc.hpp" #include #include // for CHAR_BIT @@ -89,7 +89,7 @@ RecursiveBisectionState::PrePartitionWithSCC(const std::size_t small_component_s // since our graphs are unidirectional, we don't realy need the scc. But tarjan is so nice and // assigns IDs and counts sizes TarjanGraphWrapper wrapped_graph(bisection_graph); - extractor::TarjanSCC scc_algo(wrapped_graph); + util::TarjanSCC scc_algo(wrapped_graph); scc_algo.Run(); // Map Edges to Sccs diff --git a/src/tools/components.cpp b/src/tools/components.cpp index a9b50419c..edd9a3242 100644 --- a/src/tools/components.cpp +++ b/src/tools/components.cpp @@ -1,6 +1,5 @@ #include "extractor/files.hpp" #include "extractor/packed_osm_ids.hpp" -#include "extractor/tarjan_scc.hpp" #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" @@ -8,6 +7,7 @@ #include "util/fingerprint.hpp" #include "util/log.hpp" #include "util/static_graph.hpp" +#include "util/tarjan_scc.hpp" #include "util/typedefs.hpp" #include @@ -145,7 +145,7 @@ int main(int argc, char *argv[]) util::Log() << "Starting SCC graph traversal"; - extractor::TarjanSCC tarjan{*graph}; + util::TarjanSCC tarjan{*graph}; tarjan.Run(); util::Log() << "Identified: " << tarjan.GetNumberOfComponents() << " components";