Split MLD many-to-many method
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#include "engine/routing_algorithms.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
|
||||
template <typename Algorithm>
|
||||
std::vector<EdgeDuration>
|
||||
RoutingAlgorithms<Algorithm>::ManyToManySearch(const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices) const
|
||||
{
|
||||
return routing_algorithms::manyToManySearch(
|
||||
heaps, *facade, phantom_nodes, source_indices, target_indices);
|
||||
}
|
||||
|
||||
template std::vector<EdgeDuration>
|
||||
RoutingAlgorithms<routing_algorithms::ch::Algorithm>::ManyToManySearch(
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices) const;
|
||||
|
||||
template std::vector<EdgeDuration>
|
||||
RoutingAlgorithms<routing_algorithms::corech::Algorithm>::ManyToManySearch(
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices) const;
|
||||
|
||||
// One-to-many and many-to-one can be handled with MLD separately from many-to-many search.
|
||||
// One-to-many (many-to-one) search is a unidirectional forward (backward) Dijkstra search
|
||||
// with the candidate node level min(GetQueryLevel(phantom_node, phantom_nodes, node)
|
||||
template <>
|
||||
std::vector<EdgeDuration> RoutingAlgorithms<routing_algorithms::mld::Algorithm>::ManyToManySearch(
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices) const
|
||||
{
|
||||
if (source_indices.size() == 1)
|
||||
{ // TODO: check if target_indices.size() == 1 and do a bi-directional search
|
||||
return routing_algorithms::mld::oneToManySearch<routing_algorithms::FORWARD_DIRECTION>(
|
||||
heaps, *facade, phantom_nodes, source_indices.front(), target_indices);
|
||||
}
|
||||
|
||||
if (target_indices.size() == 1)
|
||||
{
|
||||
return routing_algorithms::mld::oneToManySearch<routing_algorithms::REVERSE_DIRECTION>(
|
||||
heaps, *facade, phantom_nodes, target_indices.front(), source_indices);
|
||||
}
|
||||
|
||||
return routing_algorithms::manyToManySearch(
|
||||
heaps, *facade, phantom_nodes, source_indices, target_indices);
|
||||
}
|
||||
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
@@ -322,11 +322,11 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
std::vector<EdgeWeight> manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const DataFacade<Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::vector<std::size_t> source_indices,
|
||||
std::vector<std::size_t> target_indices)
|
||||
std::vector<EdgeDuration> manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const DataFacade<Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::vector<std::size_t> source_indices,
|
||||
std::vector<std::size_t> target_indices)
|
||||
{
|
||||
if (source_indices.empty())
|
||||
{
|
||||
@@ -415,20 +415,57 @@ std::vector<EdgeWeight> manyToManySearch(SearchEngineData<Algorithm> &engine_wor
|
||||
return durations_table;
|
||||
}
|
||||
|
||||
template std::vector<EdgeWeight>
|
||||
template std::vector<EdgeDuration>
|
||||
manyToManySearch(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const DataFacade<ch::Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::vector<std::size_t> source_indices,
|
||||
std::vector<std::size_t> target_indices);
|
||||
|
||||
template std::vector<EdgeWeight>
|
||||
template std::vector<EdgeDuration>
|
||||
manyToManySearch(SearchEngineData<mld::Algorithm> &engine_working_data,
|
||||
const DataFacade<mld::Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::vector<std::size_t> source_indices,
|
||||
std::vector<std::size_t> target_indices);
|
||||
|
||||
namespace mld
|
||||
{
|
||||
|
||||
template <bool DIRECTION>
|
||||
std::vector<EdgeDuration> oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const DataFacade<Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::size_t phantom_index,
|
||||
std::vector<std::size_t> phantom_indices)
|
||||
{
|
||||
if (phantom_indices.empty())
|
||||
{
|
||||
phantom_indices.resize(phantom_nodes.size());
|
||||
std::iota(phantom_indices.begin(), phantom_indices.end(), 0);
|
||||
}
|
||||
|
||||
std::vector<EdgeWeight> weights(phantom_nodes.size(), INVALID_EDGE_WEIGHT);
|
||||
std::vector<EdgeDuration> durations(phantom_nodes.size(), MAXIMAL_EDGE_DURATION);
|
||||
|
||||
return durations;
|
||||
}
|
||||
|
||||
template std::vector<EdgeDuration>
|
||||
oneToManySearch<FORWARD_DIRECTION>(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const DataFacade<Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::size_t phantom_index,
|
||||
std::vector<std::size_t> phantom_indices);
|
||||
|
||||
template std::vector<EdgeDuration>
|
||||
oneToManySearch<REVERSE_DIRECTION>(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const DataFacade<Algorithm> &facade,
|
||||
const std::vector<PhantomNode> &phantom_nodes,
|
||||
std::size_t phantom_index,
|
||||
std::vector<std::size_t> phantom_indices);
|
||||
} // mld
|
||||
|
||||
} // namespace routing_algorithms
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
Reference in New Issue
Block a user