use SCC code for exploration of components
This commit is contained in:
		
							parent
							
								
									47f65ccba6
								
							
						
					
					
						commit
						8d8724b3e1
					
				| @ -84,9 +84,10 @@ class TarjanSCC | |||||||
|     unsigned size_one_counter; |     unsigned size_one_counter; | ||||||
| 
 | 
 | ||||||
|   public: |   public: | ||||||
|  |     template<class ContainerT> | ||||||
|     TarjanSCC(std::shared_ptr<GraphT> graph, |     TarjanSCC(std::shared_ptr<GraphT> graph, | ||||||
|               const RestrictionMap &restrictions, |               const RestrictionMap &restrictions, | ||||||
|               const std::vector<NodeID> &barrier_node_list) |               const ContainerT &barrier_node_list) | ||||||
|         : components_index(graph->GetNumberOfNodes(), SPECIAL_NODEID), |         : components_index(graph->GetNumberOfNodes(), SPECIAL_NODEID), | ||||||
|           m_node_based_graph(graph), m_restriction_map(restrictions), |           m_node_based_graph(graph), m_restriction_map(restrictions), | ||||||
|           size_one_counter(0) |           size_one_counter(0) | ||||||
| @ -95,7 +96,7 @@ class TarjanSCC | |||||||
|         BOOST_ASSERT(m_node_based_graph->GetNumberOfNodes() > 0); |         BOOST_ASSERT(m_node_based_graph->GetNumberOfNodes() > 0); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void Run() |     void run() | ||||||
|     { |     { | ||||||
|         TIMER_START(SCC_RUN); |         TIMER_START(SCC_RUN); | ||||||
|         // The following is a hack to distinguish between stuff that happens
 |         // The following is a hack to distinguish between stuff that happens
 | ||||||
| @ -231,6 +232,12 @@ class TarjanSCC | |||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     std::size_t get_number_of_components() const | ||||||
|  |     { | ||||||
|  |         return component_size_vector.size(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     unsigned get_component_size(const NodeID node) const |     unsigned get_component_size(const NodeID node) const | ||||||
|     { |     { | ||||||
|         return component_size_vector[components_index[node]]; |         return component_size_vector[components_index[node]]; | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #include "edge_based_graph_factory.hpp" | #include "edge_based_graph_factory.hpp" | ||||||
| #include "../algorithms/bfs_components.hpp" | #include "../algorithms/tiny_components.hpp" | ||||||
| #include "../data_structures/percent.hpp" | #include "../data_structures/percent.hpp" | ||||||
| #include "../Util/compute_angle.hpp" | #include "../Util/compute_angle.hpp" | ||||||
| #include "../Util/integer_range.hpp" | #include "../Util/integer_range.hpp" | ||||||
| @ -473,12 +473,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes() | |||||||
|     SimpleLogger().Write() << "Identifying components of the road network"; |     SimpleLogger().Write() << "Identifying components of the road network"; | ||||||
| 
 | 
 | ||||||
|     // Run a BFS on the undirected graph and identify small components
 |     // Run a BFS on the undirected graph and identify small components
 | ||||||
|     BFSComponentExplorer<NodeBasedDynamicGraph> component_explorer( |     TarjanSCC<NodeBasedDynamicGraph> component_explorer( | ||||||
|         *m_node_based_graph, *m_restriction_map, m_barrier_nodes); |         m_node_based_graph, *m_restriction_map, m_barrier_nodes); | ||||||
| 
 | 
 | ||||||
|     component_explorer.run(); |     component_explorer.run(); | ||||||
| 
 | 
 | ||||||
|     SimpleLogger().Write() << "identified: " << component_explorer.GetNumberOfComponents() |     SimpleLogger().Write() << "identified: " << component_explorer.get_number_of_components() | ||||||
|                            << " many components"; |                            << " many components"; | ||||||
|     SimpleLogger().Write() << "generating edge-expanded nodes"; |     SimpleLogger().Write() << "generating edge-expanded nodes"; | ||||||
| 
 | 
 | ||||||
| @ -507,8 +507,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes() | |||||||
| 
 | 
 | ||||||
|             // Note: edges that end on barrier nodes or on a turn restriction
 |             // Note: edges that end on barrier nodes or on a turn restriction
 | ||||||
|             // may actually be in two distinct components. We choose the smallest
 |             // may actually be in two distinct components. We choose the smallest
 | ||||||
|             const unsigned size_of_component = std::min(component_explorer.GetComponentSize(u), |             const unsigned size_of_component = std::min(component_explorer.get_component_size(u), | ||||||
|                                                         component_explorer.GetComponentSize(v)); |                                                         component_explorer.get_component_size(v)); | ||||||
| 
 | 
 | ||||||
|             const bool component_is_tiny = (size_of_component < 1000); |             const bool component_is_tiny = (size_of_component < 1000); | ||||||
|             if (edge_data.edgeBasedNodeID == SPECIAL_NODEID) |             if (edge_data.edgeBasedNodeID == SPECIAL_NODEID) | ||||||
|  | |||||||
| @ -184,7 +184,7 @@ int main(int argc, char *argv[]) | |||||||
|         auto tarjan = osrm::make_unique<TarjanSCC<TarjanDynamicGraph>>(graph, |         auto tarjan = osrm::make_unique<TarjanSCC<TarjanDynamicGraph>>(graph, | ||||||
|                                                                        restriction_map, |                                                                        restriction_map, | ||||||
|                                                                        bollard_node_list); |                                                                        bollard_node_list); | ||||||
|         tarjan->Run(); |         tarjan->run(); | ||||||
| 
 | 
 | ||||||
|         // output
 |         // output
 | ||||||
|         TIMER_START(SCC_RUN_SETUP); |         TIMER_START(SCC_RUN_SETUP); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user