PGROUTING  2.6
Path Class Reference

#include "basePath_SSEC.hpp"

Collaboration diagram for Path:

Public Member Functions

 Path ()
 
 Path (int64_t s_id, int64_t e_id)
 
 Path (const Path &)=default
 
template<typename G , typename V >
 Path (G &graph, int64_t source, double distance, const std::vector< V > &predecessors, const std::vector< double > &distances)
 
template<typename G , typename V >
 Path (G &graph, V v_source, double distance, const std::vector< V > &predecessors, const std::vector< double > &distances)
 
template<typename G , typename V >
 Path (const G &graph, const V v_source, const V v_target, const std::vector< V > &predecessors, const std::vector< double > &distances, bool only_cost, bool normal=true)
 
void append (const Path &other)
 Path: 2 -> 9 seq node edge cost agg_cost 0 2 4 1 0 1 5 8 1 1 2 6 9 1 2 3 9 -1 0 3 Path: 9 -> 3 seq node edge cost agg_cost 0 9 16 1 0 1 4 3 1 1 2 3 -1 0 2 Path: 2 -> 3 seq node edge cost agg_cost 0 2 4 1 0 1 5 8 1 1 2 6 9 1 2 3 9 16 1 3 4 4 3 1 4 5 3 -1 0 5. More...
 
void appendPath (const Path &o_path)
 
const Path_tback () const
 
Path_tback ()
 
pthIt begin ()
 
ConstpthIt begin () const
 
void clear ()
 
template<typename G , typename V >
void complete_path (const G &graph, const V v_source, const V v_target, const std::vector< V > &predecessors, const std::vector< double > &distances, bool normal)
 constructs a path based on results More...
 
bool empty () const
 
void empty_path (unsigned int d_vertex)
 
pthIt end ()
 
ConstpthIt end () const
 
int64_t end_id () const
 
void end_id (int64_t value)
 
void erase (pthIt pos)
 
const Path_tfront () const
 
Path_tfront ()
 
void generate_postgres_data (General_path_element_t **postgres_data, size_t &sequence) const
 
void get_pg_dd_path (General_path_element_t **ret_path, size_t &sequence) const
 
void get_pg_ksp_path (General_path_element_t **ret_path, size_t &sequence, int routeId) const
 
Path getSubpath (unsigned int j) const
 
bool isEqual (const Path &subpath) const
 
const Path_toperator[] (size_t i) const
 
Path_toperator[] (size_t i)
 
void push_back (Path_t data)
 
void push_front (Path_t data)
 
void push_front (int64_t d_vertex, int64_t d_edge, double d_cost, double d_tot_cost)
 
void recalculate_agg_cost ()
 
Pathrenumber_vertices (int64_t value)
 
void reverse ()
 
Path_t set_data (int64_t d_from, int64_t d_to, int64_t d_vertex, int64_t d_edge, double d_cost, double d_tot_cost)
 
size_t size () const
 
void sort_by_node_agg_cost ()
 Sorts a path by node, aggcost ascending. More...
 
int64_t start_id () const
 
void start_id (int64_t value)
 
double tot_cost () const
 

Private Types

typedef std::deque< Path_t >::const_iterator ConstpthIt
 
typedef std::deque< Path_t >::iterator pthIt
 

Private Attributes

int64_t m_end_id
 
int64_t m_start_id
 
double m_tot_cost
 
std::deque< Path_tpath
 

Friends

size_t collapse_paths (General_path_element_t **ret_path, const std::deque< Path > &paths)
 
size_t count_tuples (const std::deque< Path > &paths)
 counts the tuples to be returned More...
 
void equi_cost (std::deque< Path > &paths)
 discards common vertices with greater agg_cost More...
 
std::ostream & operator<< (std::ostream &log, const Path &p)
 

Detailed Description

Definition at line 46 of file basePath_SSEC.hpp.

Member Typedef Documentation

typedef std::deque< Path_t >::const_iterator Path::ConstpthIt
private

Definition at line 48 of file basePath_SSEC.hpp.

typedef std::deque< Path_t >::iterator Path::pthIt
private

Definition at line 47 of file basePath_SSEC.hpp.

Constructor & Destructor Documentation

Path::Path ( )
inline

Definition at line 57 of file basePath_SSEC.hpp.

Referenced by Path().

57 : m_tot_cost(0) {}
double m_tot_cost

Here is the caller graph for this function:

Path::Path ( int64_t  s_id,
int64_t  e_id 
)
inline

Definition at line 58 of file basePath_SSEC.hpp.

References Path().

59  : m_start_id(s_id), m_end_id(e_id), m_tot_cost(0)
60  {}
int64_t m_end_id
int64_t m_start_id
double m_tot_cost

Here is the call graph for this function:

Path::Path ( const Path )
default
template<typename G , typename V >
Path::Path ( G &  graph,
int64_t  source,
double  distance,
const std::vector< V > &  predecessors,
const std::vector< double > &  distances 
)
inline

Definition at line 147 of file basePath_SSEC.hpp.

References push_back().

152  :
153  m_start_id(source),
154  m_end_id(source) {
155  for (V i = 0; i < distances.size(); ++i) {
156  if (distances[i] <= distance) {
157  auto cost = distances[i] - distances[predecessors[i]];
158  auto edge_id = graph.get_edge_id(predecessors[i], i, cost);
159  push_back(
160  {graph[i].id,
161  edge_id, cost,
162  distances[i]});
163  }
164  }
165  }
int64_t m_end_id
int64_t m_start_id
void push_back(Path_t data)

Here is the call graph for this function:

template<typename G , typename V >
Path::Path ( G &  graph,
v_source,
double  distance,
const std::vector< V > &  predecessors,
const std::vector< double > &  distances 
)
inline

Definition at line 168 of file basePath_SSEC.hpp.

References push_back().

173  :
174  m_start_id(graph.graph[v_source].id),
175  m_end_id(graph.graph[v_source].id) {
176  for (V i = 0; i < distances.size(); ++i) {
177  if (distances[i] <= distance) {
178  auto cost = distances[i] - distances[predecessors[i]];
179  auto edge_id = graph.get_edge_id(predecessors[i], i, cost);
180  push_back(
181  {graph[i].id,
182  edge_id, cost,
183  distances[i]});
184  }
185  }
186  }
int64_t m_end_id
int64_t m_start_id
void push_back(Path_t data)

Here is the call graph for this function:

template<typename G , typename V >
Path::Path ( const G &  graph,
const V  v_source,
const V  v_target,
const std::vector< V > &  predecessors,
const std::vector< double > &  distances,
bool  only_cost,
bool  normal = true 
)
inline

Definition at line 190 of file basePath_SSEC.hpp.

References complete_path(), and push_front().

197  :
198  m_start_id(graph.graph[v_source].id),
199  m_end_id(graph.graph[v_target].id) {
200  if (!only_cost) {
201  complete_path(graph,
202  v_source,
203  v_target,
204  predecessors,
205  distances,
206  normal);
207  return;
208  }
209  /*
210  * only_cost
211  */
212  if (v_target != predecessors[v_target]) {
213  push_front(
214  {graph.graph[v_target].id,
215  -1,
216  distances[v_target],
217  distances[v_target]});
218  }
219  return;
220  }
int64_t m_end_id
void push_front(Path_t data)
int64_t m_start_id
void complete_path(const G &graph, const V v_source, const V v_target, const std::vector< V > &predecessors, const std::vector< double > &distances, bool normal)
constructs a path based on results

Here is the call graph for this function:

Member Function Documentation

void Path::append ( const Path other)

Path: 2 -> 9 seq node edge cost agg_cost 0 2 4 1 0 1 5 8 1 1 2 6 9 1 2 3 9 -1 0 3 Path: 9 -> 3 seq node edge cost agg_cost 0 9 16 1 0 1 4 3 1 1 2 3 -1 0 2 Path: 2 -> 3 seq node edge cost agg_cost 0 2 4 1 0 1 5 8 1 1 2 6 9 1 2 3 9 16 1 3 4 4 3 1 4 5 3 -1 0 5.

Definition at line 160 of file basePath_SSEC.cpp.

References m_end_id, m_start_id, path, pgassert, and push_back().

Referenced by pgrouting::bidirectional::Pgr_bidirectional< G >::bidirectional(), and front().

160  {
161  pgassert(m_end_id == other.m_start_id);
162  if (other.m_start_id == other.m_end_id) {
163  pgassert(other.path.empty());
164  return;
165  }
166  if (m_start_id == m_end_id) {
167  pgassert(path.empty());
168  *this = other;
169  return;
170  }
171 #if 0
172  pgassert(path.back().cost == 0);
173 #endif
174  pgassert(path.back().edge == -1);
175  m_end_id = other.m_end_id;
176 
177  auto last = path.back();
178  auto agg_cost = last.agg_cost;
179 
180  path.pop_back();
181 
182  for (auto item : other.path) {
183  item.agg_cost += agg_cost;
184  push_back(item);
185  }
186 }
int64_t m_end_id
int64_t m_start_id
void push_back(Path_t data)
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
std::deque< Path_t > path

Here is the call graph for this function:

Here is the caller graph for this function:

void Path::appendPath ( const Path o_path)

Definition at line 131 of file basePath_SSEC.cpp.

References m_tot_cost, and path.

Referenced by Pgr_ksp< G >::doNextCycle(), and front().

131  {
132  path.insert(path.end(), o_path.path.begin(), o_path.path.end());
133  m_tot_cost += o_path.m_tot_cost;
134 }
std::deque< Path_t > path
double m_tot_cost

Here is the caller graph for this function:

const Path_t& Path::back ( ) const
inline

Definition at line 85 of file basePath_SSEC.hpp.

85 {return path.back();}
std::deque< Path_t > path
Path_t& Path::back ( )
inline

Definition at line 86 of file basePath_SSEC.hpp.

86 {return path.back();}
std::deque< Path_t > path
pthIt Path::begin ( )
inline

Definition at line 78 of file basePath_SSEC.hpp.

Referenced by isEqual().

78 {return path.begin();}
std::deque< Path_t > path

Here is the caller graph for this function:

ConstpthIt Path::begin ( ) const
inline

Definition at line 80 of file basePath_SSEC.hpp.

80 {return path.begin();}
std::deque< Path_t > path
void Path::clear ( )

Definition at line 84 of file basePath_SSEC.cpp.

References m_end_id, m_start_id, m_tot_cost, and path.

Referenced by pgrouting::trsp::Pgr_trspHandler::clear(), and front().

84  {
85  path.clear();
86  m_tot_cost = 0;
87  m_start_id = 0;
88  m_end_id = 0;
89 }
int64_t m_end_id
int64_t m_start_id
std::deque< Path_t > path
double m_tot_cost

Here is the caller graph for this function:

template<typename G , typename V >
void Path::complete_path ( const G &  graph,
const V  v_source,
const V  v_target,
const std::vector< V > &  predecessors,
const std::vector< double > &  distances,
bool  normal 
)
inline

constructs a path based on results

Normal = false for reversed search path like in pgr_bdDijkstra

Definition at line 226 of file basePath_SSEC.hpp.

References push_front().

Referenced by Path().

232  {
233  // no path was found
234  if (v_target == predecessors[v_target]) {
235  return;
236  }
237 
238  /*
239  * set the target
240  */
241  auto target = v_target;
242 
243  /*
244  * the last stop is the target
245  */
246  push_front(
247  {graph.graph[target].id, -1,
248  0, distances[target]});
249 
250  /*
251  * get the path
252  */
253  while (target != v_source) {
254  /*
255  * done when the predecesor of the target is the target
256  */
257  if (target == predecessors[target]) break;
258 
259  /*
260  * Inserting values in the path
261  */
262  auto cost = distances[target] - distances[predecessors[target]];
263  auto vertex_id = graph.graph[predecessors[target]].id;
264  auto edge_id = normal?
265  graph.get_edge_id(predecessors[target], target, cost)
266  : graph.get_edge_id(target, predecessors[target], cost);
267 
268  push_front({
269  vertex_id,
270  edge_id,
271  cost,
272  distances[target] - cost});
273  target = predecessors[target];
274  }
275 
276  return;
277  }
void push_front(Path_t data)

Here is the call graph for this function:

Here is the caller graph for this function:

bool Path::empty ( ) const
inline

Definition at line 70 of file basePath_SSEC.hpp.

References push_back(), and push_front().

Referenced by pgrouting::Pg_points_graph::adjust_pids(), pgrouting::Pg_points_graph::eliminate_details(), pgrouting::Pg_points_graph::eliminate_details_dd(), Pgr_dijkstraTRSP< G >::getDijkstraSolution(), Pgr_ksp< G >::getFirstSolution(), isEqual(), and pgRouting::pgr_dijkstraVia().

70 {return path.empty();}
std::deque< Path_t > path

Here is the call graph for this function:

Here is the caller graph for this function:

void Path::empty_path ( unsigned int  d_vertex)

Referenced by front().

Here is the caller graph for this function:

pthIt Path::end ( )
inline

Definition at line 79 of file basePath_SSEC.hpp.

Referenced by isEqual().

79 {return path.end();}
std::deque< Path_t > path

Here is the caller graph for this function:

ConstpthIt Path::end ( ) const
inline

Definition at line 81 of file basePath_SSEC.hpp.

81 {return path.end();}
std::deque< Path_t > path
void Path::end_id ( int64_t  value)
inline

Definition at line 66 of file basePath_SSEC.hpp.

66 {m_end_id = value;}
int64_t m_end_id
void Path::erase ( pthIt  pos)
inline

Definition at line 84 of file basePath_SSEC.hpp.

84 {path.erase(pos);}
std::deque< Path_t > path
const Path_t& Path::front ( ) const
inline

Definition at line 87 of file basePath_SSEC.hpp.

87 {return path.front();}
std::deque< Path_t > path
Path_t& Path::front ( )
inline
void Path::generate_postgres_data ( General_path_element_t **  postgres_data,
size_t &  sequence 
) const

Definition at line 189 of file basePath_SSEC.cpp.

References end_id(), path, and start_id().

Referenced by do_pgr_dijkstraTRSP(), and front().

191  {
192  int i = 1;
193  double total_cost = 0;
194  for (const auto e : path) {
195  (*postgres_data)[sequence] =
196  {i, start_id(), end_id(), e.node, e.edge, e.cost, e.agg_cost};
197  total_cost += e.cost;
198  ++i;
199  ++sequence;
200  }
201 }
int64_t end_id() const
int64_t start_id() const
std::deque< Path_t > path

Here is the call graph for this function:

Here is the caller graph for this function:

void Path::get_pg_dd_path ( General_path_element_t **  ret_path,
size_t &  sequence 
) const

Definition at line 204 of file basePath_SSEC.cpp.

References path, and start_id().

Referenced by front().

206  {
207  for (unsigned int i = 0; i < path.size(); i++) {
208  (*ret_path)[sequence].seq = i;
209  (*ret_path)[sequence].start_id = start_id();
210  (*ret_path)[sequence].end_id = start_id();
211  (*ret_path)[sequence].node = path[i].node;
212  (*ret_path)[sequence].edge = path[i].edge;
213  (*ret_path)[sequence].cost = path[i].cost;
214  (*ret_path)[sequence].agg_cost = path[i].agg_cost;
215  sequence++;
216  }
217 }
int64_t start_id() const
std::deque< Path_t > path

Here is the call graph for this function:

Here is the caller graph for this function:

void Path::get_pg_ksp_path ( General_path_element_t **  ret_path,
size_t &  sequence,
int  routeId 
) const

Definition at line 220 of file basePath_SSEC.cpp.

References end_id(), and path.

Referenced by front().

222  {
223  for (unsigned int i = 0; i < path.size(); i++) {
224  (*ret_path)[sequence].seq = i + 1;
225  (*ret_path)[sequence].start_id = routeId;
226  (*ret_path)[sequence].end_id = end_id();
227  (*ret_path)[sequence].node = path[i].node;
228  (*ret_path)[sequence].edge = path[i].edge;
229  (*ret_path)[sequence].cost = path[i].cost;
230  (*ret_path)[sequence].agg_cost = (i == 0)?
231  0 :
232  (*ret_path)[sequence-1].agg_cost + path[i-1].cost;
233  sequence++;
234  }
235 }
int64_t end_id() const
std::deque< Path_t > path

Here is the call graph for this function:

Here is the caller graph for this function:

Path Path::getSubpath ( unsigned int  j) const

Definition at line 108 of file basePath_SSEC.cpp.

References end_id(), path, pgassert, push_back(), start_id(), and tot_cost().

Referenced by Pgr_ksp< G >::doNextCycle(), and front().

108  {
109  Path result(start_id(), end_id());
110  if (j == 0) return result;
111  for (auto i = path.begin(); i != path.begin() + j; ++i) {
112  result.push_back((*i));
113  }
114  pgassert(result.tot_cost() != 0);
115  pgassert(this->tot_cost() != 0);
116  return result;
117 }
int64_t end_id() const
double tot_cost() const
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
int64_t start_id() const
std::deque< Path_t > path

Here is the call graph for this function:

Here is the caller graph for this function:

bool Path::isEqual ( const Path subpath) const

Definition at line 120 of file basePath_SSEC.cpp.

References begin(), empty(), end(), path, and size().

Referenced by front().

120  {
121  if (subpath.empty()) return true;
122  if (subpath.size() >= path.size()) return false;
123  std::deque< Path_t >::const_iterator i, j;
124  for (i = path.begin(), j = subpath.begin();
125  j != subpath.end();
126  ++i, ++j)
127  if ((*i).node != (*j).node) return false;
128  return true;
129 }
pthIt end()
pthIt begin()
bool empty() const
size_t size() const
std::deque< Path_t > path

Here is the call graph for this function:

Here is the caller graph for this function:

const Path_t& Path::operator[] ( size_t  i) const
inline

Definition at line 74 of file basePath_SSEC.hpp.

74 {return path[i];}
std::deque< Path_t > path
Path_t& Path::operator[] ( size_t  i)
inline

Definition at line 75 of file basePath_SSEC.hpp.

References renumber_vertices().

75 {return path[i];}
std::deque< Path_t > path

Here is the call graph for this function:

void Path::push_back ( Path_t  data)

Definition at line 49 of file basePath_SSEC.cpp.

References Path_t::cost, m_tot_cost, and path.

Referenced by append(), pgrouting::trsp::Pgr_trspHandler::construct_path(), Pgr_dijkstra< G >::drivingDistance_no_equicost(), pgrouting::Pg_points_graph::eliminate_details(), empty(), getSubpath(), Path(), and pgrouting::trsp::Pgr_trspHandler::process_trsp().

49  {
50  path.push_back(data);
51  m_tot_cost += data.cost;
52 }
double cost
Definition: path_t.h:39
std::deque< Path_t > path
double m_tot_cost

Here is the caller graph for this function:

void Path::push_front ( Path_t  data)

Definition at line 44 of file basePath_SSEC.cpp.

References Path_t::cost, m_tot_cost, and path.

Referenced by complete_path(), empty(), front(), and Path().

44  {
45  path.push_front(data);
46  m_tot_cost += data.cost;
47 }
double cost
Definition: path_t.h:39
std::deque< Path_t > path
double m_tot_cost

Here is the caller graph for this function:

void Path::push_front ( int64_t  d_vertex,
int64_t  d_edge,
double  d_cost,
double  d_tot_cost 
)
void Path::recalculate_agg_cost ( )

Definition at line 74 of file basePath_SSEC.cpp.

References m_tot_cost, and path.

Referenced by front().

74  {
75  m_tot_cost = 0;
76  for (auto &p : path) {
77  p.agg_cost = m_tot_cost;
78  m_tot_cost += p.cost;
79  }
80 }
std::deque< Path_t > path
double m_tot_cost

Here is the caller graph for this function:

Path & Path::renumber_vertices ( int64_t  value)

Definition at line 35 of file basePath_SSEC.cpp.

References m_end_id, m_start_id, and path.

Referenced by operator[](), and pgrouting::trsp::Pgr_trspHandler::process_trsp().

35  {
36  for (auto &r : path) {
37  r.node += value;
38  }
39  m_start_id += value;
40  m_end_id += value;
41  return *this;
42 }
int64_t m_end_id
int64_t m_start_id
std::deque< Path_t > path

Here is the caller graph for this function:

void Path::reverse ( )

Definition at line 54 of file basePath_SSEC.cpp.

References m_end_id, m_start_id, and path.

Referenced by pgrouting::bidirectional::Pgr_bidirectional< G >::bidirectional(), front(), pgr_astar(), and pgr_dijkstra().

54  {
55  std::swap(m_start_id, m_end_id);
56  if (path.size() <= 1) return;
57  std::deque< Path_t > newpath;
58  for (size_t i = 0; i < path.size(); ++i) {
59  newpath.push_front({
60  path[i].node,
61  (i == 0? -1 : path[i - 1].edge),
62  (i == 0? 0 : path[i - 1].cost),
63  0
64  });
65  }
66  for (size_t i = 0; i < newpath.size(); ++i) {
67  newpath[i].agg_cost = (i == 0)?
68  0 :
69  newpath[i - 1].agg_cost + newpath[i - 1].cost;
70  }
71  path = newpath;
72 }
int64_t m_end_id
int64_t m_start_id
std::deque< Path_t > path

Here is the caller graph for this function:

Path_t Path::set_data ( int64_t  d_from,
int64_t  d_to,
int64_t  d_vertex,
int64_t  d_edge,
double  d_cost,
double  d_tot_cost 
)

Referenced by front().

Here is the caller graph for this function:

size_t Path::size ( ) const
inline

Definition at line 69 of file basePath_SSEC.hpp.

Referenced by Pgr_dijkstraTRSP< G >::dijkstraTRSP(), do_pgr_dijkstraTRSP(), Pgr_ksp< G >::doNextCycle(), equi_cost(), isEqual(), Pgr_ksp< G >::compPaths::operator()(), pgRouting::pgr_dijkstraVia(), and Pgr_ksp< G >::Yen().

69 {return path.size();}
std::deque< Path_t > path

Here is the caller graph for this function:

void Path::sort_by_node_agg_cost ( )

Sorts a path by node, aggcost ascending.

nodes ASC agg_cost ASC

Definition at line 244 of file basePath_SSEC.cpp.

References Path_t::agg_cost, Path_t::node, and path.

Referenced by front().

244  {
245  std::sort(path.begin(), path.end(),
246  [](const Path_t &l, const Path_t &r)
247  {return l.node < r.node;});
248  std::stable_sort(path.begin(), path.end(),
249  [](const Path_t &l, const Path_t &r)
250  {return l.agg_cost < r.agg_cost;});
251 }
int64_t node
Definition: path_t.h:37
Definition: path_t.h:36
std::deque< Path_t > path
double agg_cost
Definition: path_t.h:40

Here is the caller graph for this function:

void Path::start_id ( int64_t  value)
inline

Definition at line 64 of file basePath_SSEC.hpp.

64 {m_start_id = value;}
int64_t m_start_id
double Path::tot_cost ( ) const
inline

Definition at line 67 of file basePath_SSEC.hpp.

References m_tot_cost.

Referenced by getSubpath(), and Pgr_ksp< G >::compPaths::operator()().

67 {return m_tot_cost;}
double m_tot_cost

Here is the caller graph for this function:

Friends And Related Function Documentation

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

Definition at line 259 of file basePath_SSEC.cpp.

Referenced by front().

261  {
262  size_t sequence = 0;
263  for (const Path &path : paths) {
264  if (path.path.size() > 0)
265  path.generate_postgres_data(ret_path, sequence);
266  }
267  return sequence;
268 }
std::deque< Path_t > path
size_t count_tuples ( const std::deque< Path > &  paths)
friend

counts the tuples to be returned

Definition at line 336 of file basePath_SSEC.cpp.

Referenced by front().

336  {
337  size_t count(0);
338  for (const Path &e : paths) {
339  count += e.path.size();
340  }
341  return count;
342 }
void equi_cost ( std::deque< Path > &  paths)
friend

discards common vertices with greater agg_cost

Definition at line 285 of file basePath_SSEC.cpp.

Referenced by front().

285  {
286  /* sort paths by size: largest first */
287  std::sort(paths.begin(), paths.end(),
288  [](const Path &e1, const Path &e2)->bool {
289  return e2.size() < e1.size();
290  });
291 
292  /* sort each path by node: smaller id first */
293  for (auto &p : paths) {
294  if (p.size() < 2) continue;
295  std::sort(p.begin(), p.end(),
296  [](const Path_t &e1, const Path_t &e2)->bool {
297  return e1.node < e2.node;
298  });
299  }
300 
301  for (auto &p1 : paths) {
302  for (const auto &p2 : paths) {
303  if (p1.start_id() == p2.start_id()) continue;
304  for (const auto &stop : p2.path) {
305  /* find the node of p2 in p1 */
306  auto pos = lower_bound(p1.begin(), p1.end(), stop,
307  [](const Path_t &l, const Path_t &r)->bool {
308  return l.node < r.node;
309  });
310 
311  if (pos != p1.end()
312  && (stop.node == pos->node)
313  && (stop.agg_cost < pos->agg_cost)) {
314  /* both share the same node &
315  * the second path has the smallest
316  * So erasing from the first path */
317  p1.erase(pos);
318  }
319  }
320  }
321  }
322  /* sort paths by start_id */
323  std::sort(paths.begin(), paths.end(),
324  [](const Path &e1, const Path &e2)->bool {
325  return e1.start_id() < e2.start_id();
326  });
327 
328  /* sort each path by agg_cost, node */
329  for (auto &path : paths) {
330  path.sort_by_node_agg_cost();
331  }
332 }
int64_t node
Definition: path_t.h:37
Definition: path_t.h:36
int64_t start_id() const
size_t size() const
std::deque< Path_t > path
std::ostream& operator<< ( std::ostream &  log,
const Path p 
)
friend

Definition at line 91 of file basePath_SSEC.cpp.

Referenced by front().

91  {
92  log << "Path: " << path.start_id() << " -> " << path.end_id() << "\n"
93  << "seq\tnode\tedge\tcost\tagg_cost\n";
94  int64_t i = 0;
95  for (const auto &e : path) {
96  log << i << "\t"
97  << e.node << "\t"
98  << e.edge << "\t"
99  << e.cost << "\t"
100  << e.agg_cost << "\n";
101  ++i;
102  }
103  return log;
104 }
std::deque< Path_t > path

Member Data Documentation

int64_t Path::m_end_id
private

Definition at line 53 of file basePath_SSEC.hpp.

Referenced by append(), clear(), end_id(), renumber_vertices(), and reverse().

int64_t Path::m_start_id
private

Definition at line 52 of file basePath_SSEC.hpp.

Referenced by append(), clear(), renumber_vertices(), reverse(), and start_id().

double Path::m_tot_cost
private

The documentation for this class was generated from the following files: