2014-11-28 09:33:08 -05:00
|
|
|
#ifndef MANY_TO_MANY_ROUTING_HPP
|
|
|
|
#define MANY_TO_MANY_ROUTING_HPP
|
2014-05-16 10:09:40 -04:00
|
|
|
|
2017-01-09 15:40:33 -05:00
|
|
|
#include "engine/algorithm.hpp"
|
2017-07-13 09:05:08 -04:00
|
|
|
#include "engine/datafacade.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "engine/search_engine_data.hpp"
|
2014-05-16 10:09:40 -04:00
|
|
|
|
2017-02-24 20:24:21 -05:00
|
|
|
#include "util/typedefs.hpp"
|
2014-05-16 10:09:40 -04:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::engine::routing_algorithms
|
2014-05-16 10:09:40 -04:00
|
|
|
{
|
2017-09-29 06:38:24 -04:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
struct NodeBucket
|
|
|
|
{
|
|
|
|
NodeID middle_node;
|
2018-04-20 18:18:55 -04:00
|
|
|
NodeID parent_node;
|
2018-05-08 09:54:20 -04:00
|
|
|
unsigned column_index : 31; // a column in the weight/duration matrix
|
|
|
|
unsigned from_clique_arc : 1;
|
2017-09-29 06:38:24 -04:00
|
|
|
EdgeWeight weight;
|
|
|
|
EdgeDuration duration;
|
2018-10-30 00:47:49 -04:00
|
|
|
EdgeDistance distance;
|
2017-09-29 06:38:24 -04:00
|
|
|
|
2018-04-20 18:18:55 -04:00
|
|
|
NodeBucket(NodeID middle_node,
|
|
|
|
NodeID parent_node,
|
2018-04-07 22:20:59 -04:00
|
|
|
bool from_clique_arc,
|
2018-04-20 18:18:55 -04:00
|
|
|
unsigned column_index,
|
|
|
|
EdgeWeight weight,
|
2018-10-30 00:47:49 -04:00
|
|
|
EdgeDuration duration,
|
|
|
|
EdgeDistance distance)
|
2018-05-08 09:54:20 -04:00
|
|
|
: middle_node(middle_node), parent_node(parent_node), column_index(column_index),
|
2018-10-30 00:47:49 -04:00
|
|
|
from_clique_arc(from_clique_arc), weight(weight), duration(duration), distance(distance)
|
2018-05-08 09:54:20 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NodeBucket(NodeID middle_node,
|
|
|
|
NodeID parent_node,
|
|
|
|
unsigned column_index,
|
|
|
|
EdgeWeight weight,
|
2018-10-30 00:47:49 -04:00
|
|
|
EdgeDuration duration,
|
|
|
|
EdgeDistance distance)
|
2018-05-08 09:54:20 -04:00
|
|
|
: middle_node(middle_node), parent_node(parent_node), column_index(column_index),
|
2018-10-30 00:47:49 -04:00
|
|
|
from_clique_arc(false), weight(weight), duration(duration), distance(distance)
|
2017-09-29 06:38:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// partial order comparison
|
2018-04-20 18:18:55 -04:00
|
|
|
bool operator<(const NodeBucket &rhs) const
|
|
|
|
{
|
|
|
|
return std::tie(middle_node, column_index) < std::tie(rhs.middle_node, rhs.column_index);
|
|
|
|
}
|
2017-09-29 06:38:24 -04:00
|
|
|
|
|
|
|
// functor for equal_range
|
|
|
|
struct Compare
|
|
|
|
{
|
|
|
|
bool operator()(const NodeBucket &lhs, const NodeID &rhs) const
|
|
|
|
{
|
|
|
|
return lhs.middle_node < rhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator()(const NodeID &lhs, const NodeBucket &rhs) const
|
|
|
|
{
|
|
|
|
return lhs < rhs.middle_node;
|
|
|
|
}
|
|
|
|
};
|
2018-04-20 18:18:55 -04:00
|
|
|
|
|
|
|
// functor for equal_range
|
|
|
|
struct ColumnCompare
|
|
|
|
{
|
|
|
|
unsigned column_idx;
|
|
|
|
|
|
|
|
ColumnCompare(unsigned column_idx) : column_idx(column_idx){};
|
|
|
|
|
|
|
|
bool operator()(const NodeBucket &lhs, const NodeID &rhs) const // lowerbound
|
|
|
|
{
|
|
|
|
return std::tie(lhs.middle_node, lhs.column_index) < std::tie(rhs, column_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator()(const NodeID &lhs, const NodeBucket &rhs) const // upperbound
|
|
|
|
{
|
|
|
|
return std::tie(lhs, column_idx) < std::tie(rhs.middle_node, rhs.column_index);
|
|
|
|
}
|
|
|
|
};
|
2017-09-29 06:38:24 -04:00
|
|
|
};
|
2018-05-08 09:54:20 -04:00
|
|
|
} // namespace
|
2017-09-29 06:38:24 -04:00
|
|
|
|
2017-06-30 17:45:00 -04:00
|
|
|
template <typename Algorithm>
|
2018-04-20 18:18:55 -04:00
|
|
|
std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>>
|
|
|
|
manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
|
|
|
const DataFacade<Algorithm> &facade,
|
2022-08-27 06:36:20 -04:00
|
|
|
const std::vector<PhantomNodeCandidates> &candidates_list,
|
2018-04-20 18:18:55 -04:00
|
|
|
const std::vector<std::size_t> &source_indices,
|
|
|
|
const std::vector<std::size_t> &target_indices,
|
2018-10-30 18:09:19 -04:00
|
|
|
const bool calculate_distance);
|
2017-09-20 14:17:04 -04:00
|
|
|
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::engine::routing_algorithms
|
2016-01-05 10:51:13 -05:00
|
|
|
|
2014-05-16 10:09:40 -04:00
|
|
|
#endif
|