27 #ifndef INCLUDE_DAGSHORTESTPATH_PGR_DAGSHORTESTPATH_HPP_
28 #define INCLUDE_DAGSHORTESTPATH_PGR_DAGSHORTESTPATH_HPP_
31 #include <boost/config.hpp>
32 #include <boost/graph/dijkstra_shortest_paths.hpp>
33 #include <boost/graph/adjacency_list.hpp>
34 #include <boost/graph/dag_shortest_paths.hpp>
60 bool only_cost =
false) {
67 std::numeric_limits<double>::infinity());
70 if (!graph.has_vertex(start_vertex)
71 || !graph.has_vertex(end_vertex)) {
72 return Path(start_vertex, end_vertex);
76 auto v_source(graph.get_V(start_vertex));
77 auto v_target(graph.get_V(end_vertex));
95 const std::vector< int64_t > &end_vertex,
99 size_t n_goals = (std::numeric_limits<size_t>::max)();
102 graph.num_vertices(),
103 std::numeric_limits<double>::infinity());
107 if (!graph.has_vertex(start_vertex))
108 return std::deque<Path>();
109 auto v_source(graph.get_V(start_vertex));
111 std::set< V > s_v_targets;
112 for (
const auto &vertex : end_vertex) {
113 if (graph.has_vertex(vertex)) {
114 s_v_targets.insert(graph.get_V(vertex));
118 std::vector< V > v_targets(s_v_targets.begin(), s_v_targets.end());
122 std::deque< Path > paths;
124 paths =
get_paths(graph, v_source, v_targets, only_cost);
126 std::stable_sort(paths.begin(), paths.end(),
127 [](
const Path &e1,
const Path &e2)->bool {
128 return e1.end_id() < e2.end_id();
137 const std::vector < int64_t > &start_vertex,
140 std::deque<Path> paths;
142 for (
const auto &start : start_vertex) {
144 dag(graph, start, end_vertex, only_cost));
147 std::stable_sort(paths.begin(), paths.end(),
148 [](
const Path &e1,
const Path &e2)->bool {
149 return e1.start_id() < e2.start_id();
158 const std::vector< int64_t > &start_vertex,
159 const std::vector< int64_t > &end_vertex,
162 std::deque<Path> paths;
164 for (
const auto &start : start_vertex) {
169 paths.insert(paths.begin(), r_paths.begin(), r_paths.end());
172 std::sort(paths.begin(), paths.end(),
173 [](
const Path &e1,
const Path &e2)->bool {
174 return e1.end_id() < e2.end_id();
176 std::stable_sort(paths.begin(), paths.end(),
177 [](
const Path &e1,
const Path &e2)->bool {
178 return e1.start_id() < e2.start_id();
186 const std::vector<pgr_combination_t> &combinations,
188 std::deque<Path> paths;
191 std::map< int64_t, std::vector<int64_t> > vertex_map;
193 std::map< int64_t, std::vector<int64_t> >::iterator it = vertex_map.find(comb.source);
194 if (it != vertex_map.end()) {
195 it->second.push_back(comb.target);
197 std::vector<int64_t > targets{comb.target};
198 vertex_map[comb.source] = targets;
202 for (
const auto &start_ends : vertex_map) {
203 auto result_paths =
dag(
210 std::make_move_iterator(result_paths.begin()),
211 std::make_move_iterator(result_paths.end()));
226 CHECK_FOR_INTERRUPTS();
228 boost::dag_shortest_paths(graph.graph, source,
230 .weight_map(get(&G::G_T_E::cost, graph.graph))
235 }
catch (boost::exception
const& ex) {
238 }
catch (std::exception &e) {
251 const std::vector< V > &targets,
252 size_t n_goals = (std::numeric_limits<size_t>::max)()) {
254 CHECK_FOR_INTERRUPTS();
256 boost::dag_shortest_paths(graph.graph, source,
258 .weight_map(get(&G::G_T_E::cost, graph.graph))
260 .distance_inf(std::numeric_limits<double>::infinity())
264 }
catch (boost::exception
const& ex) {
267 }
catch (std::exception &e) {
290 std::vector< V > &targets,
291 bool only_cost)
const {
292 std::deque<Path> paths;
293 for (
const auto target : targets) {
294 paths.push_back(
Path(
334 const std::vector< V > &goals,
336 m_goals(goals.begin(), goals.end()),
341 if (s_it ==
m_goals.end())
return;
360 #endif // INCLUDE_DAGSHORTESTPATH_PGR_DAGSHORTESTPATH_HPP_