PGROUTING  3.2
detail Namespace Reference

Functions

template<class G >
std::deque< Pathpgr_dijkstra (G &graph, std::vector< int64_t > sources, std::vector< int64_t > targets, bool only_cost, bool normal, size_t n_goals, bool global)
 
template<class G >
std::deque< Pathpgr_dijkstra (G &graph, std::vector< pgr_combination_t > &combinations, bool only_cost, bool normal, size_t n_goals, bool global)
 
void post_process (std::deque< Path > &paths, bool only_cost, bool normal, size_t n_goals, bool global)
 

Function Documentation

◆ pgr_dijkstra() [1/2]

template<class G >
std::deque< Path > detail::pgr_dijkstra ( G &  graph,
std::vector< int64_t >  sources,
std::vector< int64_t >  targets,
bool  only_cost,
bool  normal,
size_t  n_goals,
bool  global 
)

Definition at line 100 of file dijkstra_driver.cpp.

107  {
108  std::sort(sources.begin(), sources.end());
109  sources.erase(
110  std::unique(sources.begin(), sources.end()),
111  sources.end());
112 
113  std::sort(targets.begin(), targets.end());
114  targets.erase(
115  std::unique(targets.begin(), targets.end()),
116  targets.end());
117 
118  pgrouting::Pgr_dijkstra< G > fn_dijkstra;
119  auto paths = fn_dijkstra.dijkstra(
120  graph,
121  sources, targets,
122  only_cost, n_goals);
123 
124  post_process(paths, only_cost, normal, n_goals, global);
125 
126  return paths;
127 }

References pgrouting::Pgr_dijkstra< G >::dijkstra(), and post_process().

Referenced by do_pgr_combinations_dijkstra(), and do_pgr_many_to_many_dijkstra().

◆ pgr_dijkstra() [2/2]

template<class G >
std::deque< Path > detail::pgr_dijkstra ( G &  graph,
std::vector< pgr_combination_t > &  combinations,
bool  only_cost,
bool  normal,
size_t  n_goals,
bool  global 
)

Definition at line 132 of file dijkstra_driver.cpp.

138  {
139  pgrouting::Pgr_dijkstra< G > fn_dijkstra;
140  auto paths = fn_dijkstra.dijkstra(
141  graph,
142  combinations,
143  only_cost, n_goals);
144 
145  post_process(paths, only_cost, normal, n_goals, global);
146 
147  return paths;
148 }

References pgrouting::Pgr_dijkstra< G >::dijkstra(), and post_process().

◆ post_process()

void detail::post_process ( std::deque< Path > &  paths,
bool  only_cost,
bool  normal,
size_t  n_goals,
bool  global 
)

Definition at line 51 of file dijkstra_driver.cpp.

51  {
52  paths.erase(std::remove_if(paths.begin(), paths.end(),
53  [](const Path &p) {
54  return p.size() == 0;
55  }),
56  paths.end());
57  using difference_type = std::deque<double>::difference_type;
58 
59  if (!normal) {
60  for (auto &path : paths) path.reverse();
61  }
62 
63  if (!only_cost) {
64  for (auto &p : paths) {
66  }
67  }
68 
69  if (n_goals != (std::numeric_limits<size_t>::max)()) {
70  std::sort(paths.begin(), paths.end(),
71  [](const Path &e1, const Path &e2)->bool {
72  return e1.end_id() < e2.end_id();
73  });
74  std::stable_sort(paths.begin(), paths.end(),
75  [](const Path &e1, const Path &e2)->bool {
76  return e1.start_id() < e2.start_id();
77  });
78  std::stable_sort(paths.begin(), paths.end(),
79  [](const Path &e1, const Path &e2)->bool {
80  return e1.tot_cost() < e2.tot_cost();
81  });
82  if (global && n_goals < paths.size()) {
83  paths.erase(paths.begin() + static_cast<difference_type>(n_goals), paths.end());
84  }
85  } else {
86  std::sort(paths.begin(), paths.end(),
87  [](const Path &e1, const Path &e2)->bool {
88  return e1.end_id() < e2.end_id();
89  });
90  std::stable_sort(paths.begin(), paths.end(),
91  [](const Path &e1, const Path &e2)->bool {
92  return e1.start_id() < e2.start_id();
93  });
94  }
95 }

References Path::recalculate_agg_cost().

Referenced by pgr_dijkstra().

Path
Definition: basePath_SSEC.hpp:47
detail::post_process
void post_process(std::deque< Path > &paths, bool only_cost, bool normal, size_t n_goals, bool global)
Definition: dijkstra_driver.cpp:51
pgrouting::Pgr_dijkstra
Definition: pgr_dijkstra.hpp:62
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
Path::recalculate_agg_cost
void recalculate_agg_cost()
Definition: basePath_SSEC.cpp:77