use SCC code for exploration of components
This commit is contained in:
parent
47f65ccba6
commit
8d8724b3e1
@ -76,7 +76,7 @@ class TarjanSCC
|
||||
bool on_stack;
|
||||
};
|
||||
|
||||
std::vector<unsigned> components_index;
|
||||
std::vector<unsigned> components_index;
|
||||
std::vector<NodeID> component_size_vector;
|
||||
std::shared_ptr<GraphT> m_node_based_graph;
|
||||
std::unordered_set<NodeID> barrier_node_set;
|
||||
@ -84,18 +84,19 @@ class TarjanSCC
|
||||
unsigned size_one_counter;
|
||||
|
||||
public:
|
||||
template<class ContainerT>
|
||||
TarjanSCC(std::shared_ptr<GraphT> graph,
|
||||
const RestrictionMap &restrictions,
|
||||
const std::vector<NodeID> &barrier_node_list)
|
||||
const ContainerT &barrier_node_list)
|
||||
: 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)
|
||||
{
|
||||
barrier_node_set.insert(std::begin(barrier_node_list), std::end(barrier_node_list));
|
||||
BOOST_ASSERT(m_node_based_graph->GetNumberOfNodes() > 0);
|
||||
}
|
||||
|
||||
void Run()
|
||||
void run()
|
||||
{
|
||||
TIMER_START(SCC_RUN);
|
||||
// The following is a hack to distinguish between stuff that happens
|
||||
@ -160,7 +161,7 @@ class TarjanSCC
|
||||
// At an only_-restriction but not at the right turn
|
||||
// continue;
|
||||
}
|
||||
|
||||
|
||||
if (m_restriction_map.CheckIfTurnIsRestricted(u, v, vprime))
|
||||
{
|
||||
// continue;
|
||||
@ -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
|
||||
{
|
||||
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 "../algorithms/bfs_components.hpp"
|
||||
#include "../algorithms/tiny_components.hpp"
|
||||
#include "../data_structures/percent.hpp"
|
||||
#include "../Util/compute_angle.hpp"
|
||||
#include "../Util/integer_range.hpp"
|
||||
@ -473,12 +473,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
|
||||
SimpleLogger().Write() << "Identifying components of the road network";
|
||||
|
||||
// Run a BFS on the undirected graph and identify small components
|
||||
BFSComponentExplorer<NodeBasedDynamicGraph> component_explorer(
|
||||
*m_node_based_graph, *m_restriction_map, m_barrier_nodes);
|
||||
TarjanSCC<NodeBasedDynamicGraph> component_explorer(
|
||||
m_node_based_graph, *m_restriction_map, m_barrier_nodes);
|
||||
|
||||
component_explorer.run();
|
||||
|
||||
SimpleLogger().Write() << "identified: " << component_explorer.GetNumberOfComponents()
|
||||
SimpleLogger().Write() << "identified: " << component_explorer.get_number_of_components()
|
||||
<< " many components";
|
||||
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
|
||||
// may actually be in two distinct components. We choose the smallest
|
||||
const unsigned size_of_component = std::min(component_explorer.GetComponentSize(u),
|
||||
component_explorer.GetComponentSize(v));
|
||||
const unsigned size_of_component = std::min(component_explorer.get_component_size(u),
|
||||
component_explorer.get_component_size(v));
|
||||
|
||||
const bool component_is_tiny = (size_of_component < 1000);
|
||||
if (edge_data.edgeBasedNodeID == SPECIAL_NODEID)
|
||||
|
@ -184,7 +184,7 @@ int main(int argc, char *argv[])
|
||||
auto tarjan = osrm::make_unique<TarjanSCC<TarjanDynamicGraph>>(graph,
|
||||
restriction_map,
|
||||
bollard_node_list);
|
||||
tarjan->Run();
|
||||
tarjan->run();
|
||||
|
||||
// output
|
||||
TIMER_START(SCC_RUN_SETUP);
|
||||
|
Loading…
Reference in New Issue
Block a user