PGROUTING  3.2
pgr_dijkstra.hpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 Copyright (c) 2015 pgRouting developers
5 
6 Copyright (c) 2015 Celia Virginia Vergara Castillo
8 
9 Copyright (c) 2020 The combinations_sql signature is added by Mahmoud SAKR
10 and Esteban ZIMANYI
12 
13 ------
14 
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19 
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24 
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 
29  ********************************************************************PGR-GNU*/
30 
31 #ifndef INCLUDE_DIJKSTRA_PGR_DIJKSTRA_HPP_
32 #define INCLUDE_DIJKSTRA_PGR_DIJKSTRA_HPP_
33 #pragma once
34 
35 #include <boost/config.hpp>
36 #include <boost/graph/adjacency_list.hpp>
38 
39 #include <boost/graph/dijkstra_shortest_paths.hpp>
40 
41 #include <deque>
42 #include <set>
43 #include <vector>
44 #include <algorithm>
45 #include <sstream>
46 #include <functional>
47 #include <limits>
48 #include <map>
49 #include <numeric>
50 
55 
56 #if 0
57 #include "./../../common/src/signalhandler.h"
58 #endif
59 
60 namespace pgrouting {
61 
62 template < class G > class Pgr_dijkstra;
63 // user's functions
64 // for development
65 
66 template < class G >
67 std::deque<Path>
69  G &graph,
70  std::vector< int64_t > start_vids,
71  double distance,
72  bool equicost,
73  std::ostringstream &log) {
74  Pgr_dijkstra< G > fn_dijkstra;
75  return fn_dijkstra.drivingDistance(
76  graph,
77  start_vids,
78  distance,
79  equicost,
80  log);
81 }
82 
83 
84 /* 1 to 1*/
85 template < class G >
86 Path
88  G &graph,
89  int64_t source,
90  int64_t target,
91  bool only_cost = false) {
92  Pgr_dijkstra< G > fn_dijkstra;
93  return fn_dijkstra.dijkstra(graph, source, target, only_cost);
94 }
95 
96 
97 
98 
99 //******************************************
100 
101 template < class G >
102 class Pgr_dijkstra {
103  public:
104  typedef typename G::V V;
105  typedef typename G::E E;
106 
108 
111  G &graph,
112  int64_t start_vertex,
113  double distance) {
115  graph,
116  start_vertex,
117  distance)) {
118  auto path = Path(graph,
119  start_vertex,
120  distance,
121  predecessors,
122  distances);
123 
124  std::sort(path.begin(), path.end(),
125  [](const Path_t &l, const Path_t &r)
126  {return l.node < r.node;});
127  std::stable_sort(path.begin(), path.end(),
128  [](const Path_t &l, const Path_t &r)
129  {return l.agg_cost < r.agg_cost;});
130  return path;
131  }
132 
133  /* The result is empty */
134  Path p(start_vertex, start_vertex);
135  p.push_back({start_vertex, -1, 0, 0});
136  return p;
137  }
138 
139  // preparation for many to distance
140  std::deque< Path > drivingDistance(
141  G &graph,
142  const std::vector< int64_t > &start_vertex,
143  double distance,
144  bool equicost,
145  std::ostringstream &the_log) {
146  if (equicost) {
147  auto paths = drivingDistance_with_equicost(
148  graph,
149  start_vertex,
150  distance);
151  the_log << log.str();
152  return paths;
153  } else {
155  graph,
156  start_vertex,
157  distance);
158  }
159  }
160 
161 
162 
163 
164 
165 
167 
169 
170 
173  G &graph,
174  int64_t start_vertex,
175  int64_t end_vertex,
176  bool only_cost = false) {
177  clear();
178 
179  // adjust predecessors and distances vectors
180  predecessors.resize(graph.num_vertices());
181  distances.resize(
182  graph.num_vertices(),
183  std::numeric_limits<double>::infinity());
184 
185 
186  if (!graph.has_vertex(start_vertex)
187  || !graph.has_vertex(end_vertex)) {
188  return Path(start_vertex, end_vertex);
189  }
190 
191  // get the graphs source and target
192  auto v_source(graph.get_V(start_vertex));
193  auto v_target(graph.get_V(end_vertex));
194 
195  // perform the algorithm
196  dijkstra_1_to_1(graph, v_source, v_target);
197 
198  // get the results
199  return Path(
200  graph,
201  v_source, v_target,
203  only_cost, true);
204  }
205 
206 
207 
208 
209 
210 
212  std::deque<Path> dijkstra(
213  G &graph,
214  int64_t start_vertex,
215  const std::vector< int64_t > &end_vertex,
216  bool only_cost,
217  size_t n_goals) {
218  // adjust predecessors and distances vectors
219  clear();
220 
221  predecessors.resize(graph.num_vertices());
222  distances.resize(
223  graph.num_vertices(),
224  std::numeric_limits<double>::infinity());
225 
226 
227  // get the graphs source and target
228  if (!graph.has_vertex(start_vertex)) return std::deque<Path>();
229 
230  auto v_source(graph.get_V(start_vertex));
231 
232  std::set< V > s_v_targets;
233  for (const auto &vertex : end_vertex) {
234  if (graph.has_vertex(vertex)) s_v_targets.insert(graph.get_V(vertex));
235  }
236 
237  std::vector< V > v_targets(s_v_targets.begin(), s_v_targets.end());
238  // perform the algorithm
239  dijkstra_1_to_many(graph, v_source, v_targets, n_goals);
240 
241  std::deque< Path > paths;
242  // get the results // route id are the targets
243  paths = get_paths(graph, v_source, v_targets, only_cost);
244 
245  return paths;
246  }
247 
248  // preparation for many to 1
249  std::deque<Path> dijkstra(
250  G &graph,
251  const std::vector < int64_t > &start_vertex,
252  int64_t end_vertex,
253  bool only_cost) {
254  std::deque<Path> paths;
255 
256  for (const auto &start : start_vertex) {
257  paths.push_back(
258  dijkstra(graph, start, end_vertex, only_cost));
259  }
260 
261  std::stable_sort(paths.begin(), paths.end(),
262  [](const Path &e1, const Path &e2)->bool {
263  return e1.start_id() < e2.start_id();
264  });
265  return paths;
266  }
267 
268 
269  // preparation for many to many
270  std::deque<Path> dijkstra(
271  G &graph,
272  const std::vector< int64_t > &start_vertex,
273  const std::vector< int64_t > &end_vertex,
274  bool only_cost,
275  size_t n_goals = (std::numeric_limits<size_t>::max)()) {
276  // a call to 1 to many is faster for each of the sources
277  std::deque<Path> paths;
278 
279  for (const auto &start : start_vertex) {
280  auto r_paths = dijkstra(
281  graph,
282  start, end_vertex,
283  only_cost, n_goals);
284  paths.insert(paths.begin(), r_paths.begin(), r_paths.end());
285  }
286 
287  return paths;
288  }
289 
290  // preparation for parallel arrays
291  std::deque<Path> dijkstra(
292  G &graph,
293  const std::vector< pgr_combination_t > &combinations,
294  bool only_cost,
295  size_t n_goals) {
296  // a call to 1 to many is faster for each of the sources
297  std::deque<Path> paths;
298 
299  // group targets per distinct source
300  std::map<int64_t , std::vector<int64_t> > vertex_map;
301  for (const pgr_combination_t &comb : combinations) {
302  std::map< int64_t , std::vector<int64_t> >::iterator it = vertex_map.find(comb.source);
303  if (it != vertex_map.end()) {
304  it->second.push_back(comb.target);
305  } else {
306  std::vector<int64_t > targets{comb.target};
307  vertex_map[comb.source] = targets;
308  }
309  }
310 
311  for (const auto &start_ends : vertex_map) {
312  auto r_paths = dijkstra(
313  graph,
314  start_ends.first, start_ends.second,
315  only_cost, n_goals);
316  paths.insert(paths.begin(), r_paths.begin(), r_paths.end());
317  }
318 
319  return paths;
320  }
321 
323 
324  private:
327  G &graph,
328  V source,
329  V target) {
330  /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
331  CHECK_FOR_INTERRUPTS();
332  try {
333  boost::dijkstra_shortest_paths(graph.graph, source,
334  boost::predecessor_map(&predecessors[0])
335  .weight_map(get(&G::G_T_E::cost, graph.graph))
336  .distance_map(&distances[0])
337  .visitor(visitors::dijkstra_one_goal_visitor<V>(target)));
338  } catch(found_goals &) {
339  return true;
340  } catch (boost::exception const& ex) {
341  (void)ex;
342  throw;
343  } catch (std::exception &e) {
344  (void)e;
345  throw;
346  } catch (...) {
347  throw;
348  }
349  return true;
350  }
351 
360  G &graph,
361  V source,
362  double distance) {
363  /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
364  CHECK_FOR_INTERRUPTS();
365  try {
366  boost::dijkstra_shortest_paths(graph.graph, source,
367  boost::predecessor_map(&predecessors[0])
368  .weight_map(get(&G::G_T_E::cost, graph.graph))
369  .distance_map(&distances[0])
370  .visitor(dijkstra_distance_visitor(
371  distance,
373  distances)));
374  } catch(found_goals &) {
375  /*No op*/
376  } catch (boost::exception const&) {
377  throw;
378  } catch (std::exception&) {
379  throw;
380  } catch (...) {
381  throw;
382  }
383  return true;
384  }
385 
392  G &graph,
393  V source,
394  double distance) {
395  pgassert(predecessors.size() == graph.num_vertices());
396  pgassert(distances.size() == graph.num_vertices());
397  distances[source] = 0;
398  std::vector<boost::default_color_type> color_map(graph.num_vertices());
399  /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
400  CHECK_FOR_INTERRUPTS();
401  try {
402  boost::dijkstra_shortest_paths_no_init(graph.graph, source,
403  make_iterator_property_map(
404  predecessors.begin(),
405  graph.vertIndex),
406  make_iterator_property_map(
407  distances.begin(),
408  graph.vertIndex),
409  get(&G::G_T_E::cost, graph.graph),
410  graph.vertIndex,
411  std::less<double>(),
412  boost::closed_plus<double>(),
413  static_cast<double>(0),
415  log,
416  source,
417  distance,
418  predecessors,
419  distances,
420  color_map),
421  boost::make_iterator_property_map(
422  color_map.begin(),
423  graph.vertIndex,
424  color_map[0]));
425  } catch(found_goals &) {
426  return true;
427  } catch (boost::exception const& ex) {
428  (void)ex;
429  throw;
430  } catch (std::exception &e) {
431  (void)e;
432  throw;
433  } catch (...) {
434  throw;
435  }
436 
437  return true;
438  }
439 
440 
454  G &graph,
455  int64_t start_vertex,
456  double distance) {
457  clear();
458 
459  predecessors.resize(graph.num_vertices());
460  distances.resize(
461  graph.num_vertices(),
462  std::numeric_limits<double>::infinity());
463 
464  // get source;
465  if (!graph.has_vertex(start_vertex)) {
466  return false;
467  }
468 
469  return dijkstra_1_to_distance(
470  graph,
471  graph.get_V(start_vertex),
472  distance);
473  }
474 
475 
489  G &graph,
490  V start_vertex,
491  double distance) {
492  pgassert(predecessors.size() == graph.num_vertices());
493  pgassert(distances.size() == graph.num_vertices());
494 
495  std::iota(predecessors.begin(), predecessors.end(), 0);
496 
498  graph,
499  start_vertex,
500  distance);
501  }
502 
503  /* preparation for many to distance with equicost
504  *
505  * Idea:
506  * The distances vector does not change
507  * The predecessors vector does not change
508  * The first @b valid execution is done normally:
509  * - The distances will have:
510  * - inf
511  * - values < distance
512  * - values > distance
513  * Subsequent @b valid executions
514  * - will not change the:
515  * - values < distance
516  * Don't know yet what happens to predecessors
517  */
518  std::deque< Path > drivingDistance_with_equicost(
519  G &graph,
520  const std::vector< int64_t > &start_vertex,
521  double distance) {
522  clear();
523  log << "Number of edges:" << boost::num_edges(graph.graph) << "\n";
524 
525  predecessors.resize(graph.num_vertices());
526  distances.resize(
527  graph.num_vertices(),
528  std::numeric_limits<double>::infinity());
529 
530  /*
531  * Vector to store the different predessesors
532  * each is of size = graph.num_vertices()
533  *
534  * TODO(vicky)
535  * - figure out less storage if possible
536  */
537  std::deque< std::vector< V > > pred(start_vertex.size());
538 
539  // perform the algorithm
540  size_t i = 0;
541  for (const auto &vertex : start_vertex) {
542  nodesInDistance.clear();
543  /*
544  * The vertex does not exist
545  * Nothing to do
546  */
547  if (graph.has_vertex(vertex)) {
549  graph,
550  graph.get_V(vertex),
551  distance)) {
552  pred[i] = predecessors;
553  }
554  }
555  ++i;
556  }
557 
558 
559  /*
560  * predecessors of vertices in the set are themselves
561  */
562  for (const auto &vertex : start_vertex) {
563  for (auto &p : pred) {
564  if (!p.empty() && graph.has_vertex(vertex))
565  p[graph.get_V(vertex)] = graph.get_V(vertex);
566  }
567  }
568 
569 
571  graph,
572  start_vertex,
573  pred,
574  distance);
575  }
576 
585  G &graph,
586  const std::vector< int64_t > &start_vertex,
587  std::deque< std::vector< V > > &pred,
588  double distance) {
589  /*
590  * precondition
591  */
592  pgassert(start_vertex.size() == pred.size());
593 
594 
595  /*
596  * Creating all the result "paths"
597  */
598  std::deque<Path> paths;
599  for (const auto vertex : start_vertex) {
600  paths.push_back(Path(vertex, vertex));
601  paths.back().push_back({vertex, -1, 0, 0});
602  }
603 
604  /*
605  * Ciclying the distances:
606  * To which vertex do they belong to?
607  */
608  for (V d = 0; d < distances.size(); ++d) {
609  /*
610  * Sikiping distances greater than the one asked for
611  */
612  if (!(distances[d] <= distance)) continue;
613 
614  for (auto i = start_vertex.size(); i > 0; --i) {
615  /*
616  * The vertex does not exist on the graph
617  */
618  if (pred[i - 1].empty()) break;
619 
620 
621  /*
622  * The predecessor = current then
623  * its unreachable to this vertex
624  */
625  if (pred[i - 1][d] == d) continue;
626 
627  auto cost = distances[d] - distances[pred[i - 1][d]];
628  auto edge_id = graph.get_edge_id(pred[i - 1][d], d, cost);
629  pgassert(edge_id != -1);
630  paths[i - 1].push_back(
631  {graph[d].id,
632  edge_id, cost,
633  distances[d]});
634  break;
635  }
636  }
637 
638  for (auto &path : paths) {
639  path.sort_by_node_agg_cost();
640  }
641  return paths;
642  }
643 
644 
645  // preparation for many to distance No equicost
646  std::deque< Path > drivingDistance_no_equicost(
647  G &graph,
648  const std::vector< int64_t > &start_vertex,
649  double distance) {
650  // perform the algorithm
651  std::deque<Path> paths;
652  for (const auto &vertex : start_vertex) {
653  if (execute_drivingDistance(graph, vertex, distance)) {
654  auto path = Path(
655  graph,
656  vertex,
657  distance,
658  predecessors,
659  distances);
660  path.sort_by_node_agg_cost();
661  paths.push_back(path);
662  } else {
663  Path p(vertex, vertex);
664  p.push_back({vertex, -1, 0, 0});
665  paths.push_back(p);
666  }
667  }
668  return paths;
669  }
670 
671 
674  G &graph,
675  V source,
676  const std::vector< V > &targets,
677  size_t n_goals) {
678  /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
679  CHECK_FOR_INTERRUPTS();
680  std::set<V> goals_found;
681  std::set<V> goals(targets.begin(), targets.end());
682  try {
683  boost::dijkstra_shortest_paths(graph.graph, source,
684  boost::predecessor_map(&predecessors[0])
685  .weight_map(get(&G::G_T_E::cost, graph.graph))
686  .distance_map(&distances[0])
687  .distance_inf(std::numeric_limits<double>::infinity())
688  .visitor(dijkstra_many_goal_visitor(goals, n_goals, goals_found)));
689  } catch(found_goals &) {
690  for (const auto &g : goals) {
691  if (goals_found.find(g) == goals_found.end()) {
692  /* goal was not found */
693  predecessors[g] = g;
694  }
695  }
696  return true;
697  } catch (boost::exception const& ex) {
698  (void)ex;
699  throw;
700  } catch (std::exception &e) {
701  (void)e;
702  throw;
703  } catch (...) {
704  throw;
705  }
706  return true;
707  }
708 
709 
710  void clear() {
711  predecessors.clear();
712  distances.clear();
713  nodesInDistance.clear();
714  }
715 
716 
717 
718 
719  // used when multiple goals
720  std::deque<Path> get_paths(
721  const G &graph,
722  V source,
723  std::vector< V > &targets,
724  bool only_cost) const {
725  std::deque<Path> paths;
726  for (const auto target : targets) {
727  paths.push_back(Path(
728  graph,
729  source, target,
731  only_cost, true));
732  }
733  return paths;
734  }
735 
736 
737 
739 
740  std::vector< V > predecessors;
741  std::vector< double > distances;
742  std::deque< V > nodesInDistance;
743  std::ostringstream log;
745 
746 
748 
749  class dijkstra_many_goal_visitor : public boost::default_dijkstra_visitor {
751  public:
753  const std::set<V> &goals,
754  size_t n_goals,
755  std::set<V> &f_goals) :
756  m_goals(goals),
757  m_n_goals(n_goals),
758  m_found_goals(f_goals) {
759  }
760  template <class B_G>
761  void examine_vertex(V u, B_G &) {
762  auto s_it = m_goals.find(u);
763 
764  /* examined vertex is not a goal */
765  if (s_it == m_goals.end()) return;
766 
767  // found one more goal
768  m_found_goals.insert(*s_it);
769  m_goals.erase(s_it);
770 
771  // all goals found
772  if (m_goals.size() == 0) throw found_goals();
773 
774  // number of requested goals found
775  --m_n_goals;
776  if (m_n_goals == 0) throw found_goals();
777  }
778 
779  private:
780  std::set< V > m_goals;
781  size_t m_n_goals;
782  std::set< V > &m_found_goals;
783  };
784 
785 
787  class dijkstra_distance_visitor : public boost::default_dijkstra_visitor {
788  public:
790  double distance_goal,
791  std::deque< V > &nodesInDistance,
792  std::vector< double > &distances) :
793  m_distance_goal(distance_goal),
795  m_dist(distances) {
796  pgassert(m_nodes.empty());
798  }
799  template <class B_G>
800  void examine_vertex(V u, B_G &) {
801  if (m_dist[u] > m_distance_goal) {
802  throw found_goals();
803  }
804  m_nodes.push_back(u);
805  }
806 
807  private:
809  std::deque< V > &m_nodes;
810  std::vector< double > &m_dist;
811  };
812 
815  : public boost::default_dijkstra_visitor {
816  public:
818  std::ostringstream &p_log,
819  V source,
820  double distance_goal,
821  std::vector< V > &predecessors,
822  std::vector< double > &distances,
823  std::vector<boost::default_color_type> &color_map) :
824  log(p_log),
825  first(source),
826  m_distance_goal(distance_goal),
827  m_num_examined(0),
829  m_dist(distances),
830  m_color(color_map) {
831  pgassert(m_num_examined == 0);
833  }
834 
835  template <class B_G>
836  void examine_vertex(V u, B_G &) {
837  if ( 0 == m_num_examined++) first = u;
838  if (m_dist[u] > m_distance_goal) {
839  throw found_goals();
840  }
841  if (u != first && m_predecessors[u] == u) {
842  m_color[u] = boost::black_color;
843  }
844  }
845 
846  template <class B_G>
847  void examine_edge(E e, B_G &g) {
848  if (source(e, g) != first
849  && m_predecessors[source(e, g)] == source(e, g)) {
850  m_color[target(e, g)] = boost::black_color;
851  }
852  }
853 
854 
855  template <class B_G>
856  void edge_relaxed(E, B_G &) {
857  }
858 
859 
860 
861  template <class B_G>
862  void edge_not_relaxed(E e, B_G &g) {
863  if (source(e, g) != first
864  && m_predecessors[source(e, g)] == source(e, g)) {
865  m_color[target(e, g)] = boost::black_color;
866  }
867  }
868 
869 
870  template <class B_G>
871  void finish_vertex(V, B_G &) {
872  }
873 
874 
875  template <class B_G>
876  void discover_vertex(V u, B_G &) {
877  if (u != first && m_predecessors[u] == u) {
878  m_color[u] = boost::black_color;
879  }
880  }
881 
882  private:
883  std::ostringstream &log;
887  std::vector< V > &m_predecessors;
888  std::vector< double > &m_dist;
889  std::vector<boost::default_color_type> &m_color;
890  };
891 };
892 
893 } // namespace pgrouting
894 
895 
896 #endif // INCLUDE_DIJKSTRA_PGR_DIJKSTRA_HPP_
interruption.h
pgrouting::Pgr_dijkstra::nodesInDistance
std::deque< V > nodesInDistance
Definition: pgr_dijkstra.hpp:742
pgrouting::Pgr_dijkstra::E
G::E E
Definition: pgr_dijkstra.hpp:105
pgrouting::Pgr_dijkstra::clear
void clear()
Definition: pgr_dijkstra.hpp:710
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::edge_relaxed
void edge_relaxed(E, B_G &)
Definition: pgr_dijkstra.hpp:856
Path
Definition: basePath_SSEC.hpp:47
Path::push_back
void push_back(Path_t data)
Definition: basePath_SSEC.cpp:52
pgr_base_graph.hpp
pgrouting::Pgr_dijkstra::execute_drivingDistance
bool execute_drivingDistance(G &graph, int64_t start_vertex, double distance)
to use with driving distance
Definition: pgr_dijkstra.hpp:453
pgrouting::Pgr_dijkstra::dijkstra_1_to_1
bool dijkstra_1_to_1(G &graph, V source, V target)
Call to Dijkstra 1 source to 1 target.
Definition: pgr_dijkstra.hpp:326
pgrouting::Pgr_dijkstra::dijkstra
std::deque< Path > dijkstra(G &graph, const std::vector< int64_t > &start_vertex, int64_t end_vertex, bool only_cost)
Definition: pgr_dijkstra.hpp:249
pgrouting::Pgr_dijkstra::dijkstra_many_goal_visitor::m_n_goals
size_t m_n_goals
Definition: pgr_dijkstra.hpp:781
Path_t
Definition: path_t.h:36
pgrouting::Pgr_dijkstra::drivingDistance
std::deque< Path > drivingDistance(G &graph, const std::vector< int64_t > &start_vertex, double distance, bool equicost, std::ostringstream &the_log)
Definition: pgr_dijkstra.hpp:140
pgrouting::Pgr_dijkstra::predecessors
std::vector< V > predecessors
Definition: pgr_dijkstra.hpp:740
pgr_combination_t.h
dijkstra_one_goal_visitor.hpp
pgrouting::Pgr_dijkstra::drivingDistance_with_equicost
std::deque< Path > drivingDistance_with_equicost(G &graph, const std::vector< int64_t > &start_vertex, double distance)
Definition: pgr_dijkstra.hpp:518
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor::m_dist
std::vector< double > & m_dist
Definition: pgr_dijkstra.hpp:810
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::m_color
std::vector< boost::default_color_type > & m_color
Definition: pgr_dijkstra.hpp:889
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::m_num_examined
size_t m_num_examined
Definition: pgr_dijkstra.hpp:886
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor::m_distance_goal
double m_distance_goal
Definition: pgr_dijkstra.hpp:808
pgrouting::Pgr_dijkstra::get_drivingDistance_with_equicost_paths
std::deque< Path > get_drivingDistance_with_equicost_paths(G &graph, const std::vector< int64_t > &start_vertex, std::deque< std::vector< V > > &pred, double distance)
gets results in form of a container of paths
Definition: pgr_dijkstra.hpp:584
pgrouting::visitors::dijkstra_one_goal_visitor
Definition: dijkstra_one_goal_visitor.hpp:39
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
pgrouting::Pgr_dijkstra::dijkstra_many_goal_visitor::m_found_goals
std::set< V > & m_found_goals
Definition: pgr_dijkstra.hpp:782
pgrouting::Pgr_dijkstra::dijkstra_many_goal_visitor::examine_vertex
void examine_vertex(V u, B_G &)
Definition: pgr_dijkstra.hpp:761
pgrouting::Pgr_dijkstra::dijkstra
std::deque< Path > dijkstra(G &graph, int64_t start_vertex, const std::vector< int64_t > &end_vertex, bool only_cost, size_t n_goals)
Dijkstra 1 to many.
Definition: pgr_dijkstra.hpp:212
pred
static size_t pred(size_t i, size_t n)
Definition: pgr_tsp.cpp:64
pgrouting::Pgr_dijkstra::dijkstra_many_goal_visitor::dijkstra_many_goal_visitor
dijkstra_many_goal_visitor(const std::set< V > &goals, size_t n_goals, std::set< V > &f_goals)
Definition: pgr_dijkstra.hpp:752
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::m_dist
std::vector< double > & m_dist
Definition: pgr_dijkstra.hpp:888
pgrouting::pgr_dijkstra
Path pgr_dijkstra(G &graph, int64_t source, int64_t target, bool only_cost=false)
Definition: pgr_dijkstra.hpp:87
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::discover_vertex
void discover_vertex(V u, B_G &)
Definition: pgr_dijkstra.hpp:876
pgrouting::alphashape::E
boost::graph_traits< BG >::edge_descriptor E
Definition: pgr_alphaShape.h:57
pgr_combination_t
Definition: pgr_combination_t.h:43
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::examine_edge
void examine_edge(E e, B_G &g)
Definition: pgr_dijkstra.hpp:847
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::examine_vertex
void examine_vertex(V u, B_G &)
Definition: pgr_dijkstra.hpp:836
pgrouting::Pgr_dijkstra::dijkstra_1_to_many
bool dijkstra_1_to_many(G &graph, V source, const std::vector< V > &targets, size_t n_goals)
Dijkstra 1 source to many targets.
Definition: pgr_dijkstra.hpp:673
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init
class for stopping when a distance/cost has being surpassed
Definition: pgr_dijkstra.hpp:814
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::dijkstra_distance_visitor_no_init
dijkstra_distance_visitor_no_init(std::ostringstream &p_log, V source, double distance_goal, std::vector< V > &predecessors, std::vector< double > &distances, std::vector< boost::default_color_type > &color_map)
Definition: pgr_dijkstra.hpp:817
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor
class for stopping when a distance/cost has being surpassed
Definition: pgr_dijkstra.hpp:787
pgrouting::pgr_drivingDistance
std::deque< Path > pgr_drivingDistance(G &graph, std::vector< int64_t > start_vids, double distance, bool equicost, std::ostringstream &log)
Definition: pgr_dijkstra.hpp:68
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::m_predecessors
std::vector< V > & m_predecessors
Definition: pgr_dijkstra.hpp:887
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor::m_nodes
std::deque< V > & m_nodes
Definition: pgr_dijkstra.hpp:809
pgrouting::Pgr_dijkstra::dijkstra
std::deque< Path > dijkstra(G &graph, const std::vector< pgr_combination_t > &combinations, bool only_cost, size_t n_goals)
Definition: pgr_dijkstra.hpp:291
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::m_distance_goal
double m_distance_goal
Definition: pgr_dijkstra.hpp:885
pgrouting::Pgr_dijkstra::dijkstra_1_to_distance_no_init
bool dijkstra_1_to_distance_no_init(G &graph, V source, double distance)
Call to Dijkstra 1 to distance no init.
Definition: pgr_dijkstra.hpp:391
pgrouting::Pgr_dijkstra::execute_drivingDistance_no_init
bool execute_drivingDistance_no_init(G &graph, V start_vertex, double distance)
to use with driving distance
Definition: pgr_dijkstra.hpp:488
pgrouting::alphashape::G
graph::Pgr_base_graph< BG, XY_vertex, Basic_edge > G
Definition: pgr_alphaShape.h:56
pgrouting::Pgr_dijkstra::log
std::ostringstream log
Definition: pgr_dijkstra.hpp:743
pgrouting::Pgr_dijkstra::dijkstra
std::deque< Path > dijkstra(G &graph, const std::vector< int64_t > &start_vertex, const std::vector< int64_t > &end_vertex, bool only_cost, size_t n_goals=(std::numeric_limits< size_t >::max)())
Definition: pgr_dijkstra.hpp:270
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor::dijkstra_distance_visitor
dijkstra_distance_visitor(double distance_goal, std::deque< V > &nodesInDistance, std::vector< double > &distances)
Definition: pgr_dijkstra.hpp:789
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::first
V first
Definition: pgr_dijkstra.hpp:884
pgrouting::Pgr_dijkstra::drivingDistance_no_equicost
std::deque< Path > drivingDistance_no_equicost(G &graph, const std::vector< int64_t > &start_vertex, double distance)
Definition: pgr_dijkstra.hpp:646
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::log
std::ostringstream & log
Definition: pgr_dijkstra.hpp:883
pgrouting::Pgr_dijkstra::dijkstra_1_to_distance
bool dijkstra_1_to_distance(G &graph, V source, double distance)
Call to Dijkstra 1 to distance.
Definition: pgr_dijkstra.hpp:359
pgrouting::found_goals
exception for visitor termination
Definition: found_goals.hpp:33
pgrouting::Pgr_dijkstra::distances
std::vector< double > distances
Definition: pgr_dijkstra.hpp:741
pgrouting::Pgr_dijkstra::V
G::V V
Definition: pgr_dijkstra.hpp:104
pgrouting::alphashape::V
boost::graph_traits< BG >::vertex_descriptor V
Definition: pgr_alphaShape.h:58
pgrouting::Pgr_dijkstra::drivingDistance
Path drivingDistance(G &graph, int64_t start_vertex, double distance)
1 to distance
Definition: pgr_dijkstra.hpp:110
pgrouting::Pgr_dijkstra::dijkstra_many_goal_visitor::m_goals
std::set< V > m_goals
Definition: pgr_dijkstra.hpp:780
pgrouting::Pgr_dijkstra
Definition: pgr_dijkstra.hpp:62
pgrouting::Pgr_dijkstra::dijkstra_many_goal_visitor
class for stopping when all targets are found
Definition: pgr_dijkstra.hpp:750
pgrouting::Pgr_dijkstra::get_paths
std::deque< Path > get_paths(const G &graph, V source, std::vector< V > &targets, bool only_cost) const
Definition: pgr_dijkstra.hpp:720
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::finish_vertex
void finish_vertex(V, B_G &)
Definition: pgr_dijkstra.hpp:871
pgrouting::Pgr_dijkstra::dijkstra
Path dijkstra(G &graph, int64_t start_vertex, int64_t end_vertex, bool only_cost=false)
Dijkstra 1 to 1.
Definition: pgr_dijkstra.hpp:172
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor::examine_vertex
void examine_vertex(V u, B_G &)
Definition: pgr_dijkstra.hpp:800
pgrouting::Pgr_dijkstra::dijkstra_distance_visitor_no_init::edge_not_relaxed
void edge_not_relaxed(E e, B_G &g)
Definition: pgr_dijkstra.hpp:862
basePath_SSEC.hpp