PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
basePath_SSEC.cpp File Reference
#include "cpp_common/basePath_SSEC.hpp"
#include <deque>
#include <iostream>
#include <algorithm>
#include <utility>
#include "c_types/general_path_element_t.h"
#include "cpp_common/pgr_assert.h"
Include dependency graph for basePath_SSEC.cpp:

Go to the source code of this file.

Functions

size_t collapse_paths (General_path_element_t **ret_path, const std::deque< Path > &paths)
 
size_t count_tuples (const std::deque< Path > &paths)
 
void equi_cost (std::deque< Path > &paths)
 
std::ostream & operator<< (std::ostream &log, const Path &path)
 

Function Documentation

size_t collapse_paths ( General_path_element_t **  ret_path,
const std::deque< Path > &  paths 
)

Definition at line 238 of file basePath_SSEC.cpp.

Referenced by do_pgr_astarManyToMany(), do_pgr_bdAstar(), do_pgr_bdDijkstra(), do_pgr_driving_many_to_dist(), do_pgr_many_to_many_dijkstra(), do_pgr_many_withPointsDD(), and do_pgr_withPoints().

240  {
241  size_t sequence = 0;
242  for (const Path &path : paths) {
243  if (path.path.size() > 0)
244  path.generate_postgres_data(ret_path, sequence);
245  }
246  return sequence;
247 }

Here is the caller graph for this function:

size_t count_tuples ( const std::deque< Path > &  paths)

Definition at line 315 of file basePath_SSEC.cpp.

Referenced by do_pgr_astarManyToMany(), do_pgr_bdAstar(), do_pgr_bdDijkstra(), do_pgr_dijkstraVia(), do_pgr_driving_many_to_dist(), do_pgr_ksp(), do_pgr_many_to_many_dijkstra(), do_pgr_many_withPointsDD(), do_pgr_withPoints(), and do_pgr_withPointsKsp().

315  {
316  size_t count(0);
317  for (const Path &e : paths) {
318  count += e.path.size();
319  }
320  return count;
321 }

Here is the caller graph for this function:

void equi_cost ( std::deque< Path > &  paths)

Definition at line 264 of file basePath_SSEC.cpp.

References Path_t::node, Path::size(), and Path::start_id().

Referenced by process_drivingDistance().

264  {
265  /* sort paths by size: largest first */
266  std::sort(paths.begin(), paths.end(),
267  [](const Path &e1, const Path &e2)->bool {
268  return e2.size() < e1.size();
269  });
270 
271  /* sort each path by node: smaller id first */
272  for (auto &p : paths) {
273  if (p.size() < 2) continue;
274  std::sort(p.begin(), p.end(),
275  [](const Path_t &e1, const Path_t &e2)->bool {
276  return e1.node < e2.node;
277  });
278  }
279 
280  for (auto &p1 : paths) {
281  for (const auto &p2 : paths) {
282  if (p1.start_id() == p2.start_id()) continue;
283  for (const auto &stop : p2.path) {
284  /* find the node of p2 in p1 */
285  auto pos = lower_bound(p1.begin(), p1.end(), stop,
286  [](const Path_t &l, const Path_t &r)->bool {
287  return l.node < r.node;
288  });
289 
290  if (pos != p1.end()
291  && (stop.node == pos->node)
292  && (stop.agg_cost < pos->agg_cost)) {
293  /* both share the same node &
294  * the second path has the smallest
295  * So erasing from the first path */
296  p1.erase(pos);
297  }
298  }
299  }
300  }
301  /* sort paths by start_id */
302  std::sort(paths.begin(), paths.end(),
303  [](const Path &e1, const Path &e2)->bool {
304  return e1.start_id() < e2.start_id();
305  });
306 
307  /* sort each path by agg_cost, node */
308  for (auto &path : paths) {
309  path.sort_by_node_agg_cost();
310  }
311 }
int64_t node
Definition: path_t.h:37
Definition: path_t.h:36
int64_t start_id() const
size_t size() const

Here is the call graph for this function:

Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  log,
const Path path 
)

Definition at line 72 of file basePath_SSEC.cpp.

References Path::end_id(), and Path::start_id().

72  {
73  log << "Path: " << path.start_id() << " -> " << path.end_id() << "\n"
74  << "seq\tnode\tedge\tcost\tagg_cost\n";
75  int64_t i = 0;
76  for (const auto &e : path) {
77  log << i << "\t"
78  << e.node << "\t"
79  << e.edge << "\t"
80  << e.cost << "\t"
81  << e.agg_cost << "\n";
82  ++i;
83  }
84  return log;
85 }
int64_t end_id() const
int64_t start_id() const

Here is the call graph for this function: