PGROUTING  3.2
pgrouting::contraction::Pgr_deadend< G > Class Template Reference

#include "pgr_deadEndContraction.hpp"

Collaboration diagram for pgrouting::contraction::Pgr_deadend< G >:

Public Member Functions

 Pgr_deadend ()=default
 
void calculateVertices (G &graph)
 
void doContraction (G &graph)
 
bool is_dead_end (G &graph, V v)
 
void setForbiddenVertices (Identifiers< V > forbidden_vertices)
 

Private Types

using E = typename G::E
 
using V = typename G::V
 

Private Attributes

Identifiers< VdeadendVertices
 
Identifiers< VforbiddenVertices
 

Detailed Description

template<class G>
class pgrouting::contraction::Pgr_deadend< G >

Definition at line 45 of file pgr_deadEndContraction.hpp.

Member Typedef Documentation

◆ E

template<class G >
using pgrouting::contraction::Pgr_deadend< G >::E = typename G::E
private

Definition at line 48 of file pgr_deadEndContraction.hpp.

◆ V

template<class G >
using pgrouting::contraction::Pgr_deadend< G >::V = typename G::V
private

Definition at line 47 of file pgr_deadEndContraction.hpp.

Constructor & Destructor Documentation

◆ Pgr_deadend()

template<class G >
pgrouting::contraction::Pgr_deadend< G >::Pgr_deadend ( )
default

Member Function Documentation

◆ calculateVertices()

template<class G >
void pgrouting::contraction::Pgr_deadend< G >::calculateVertices ( G &  graph)
inline

◆ doContraction()

template<class G >
void pgrouting::contraction::Pgr_deadend< G >::doContraction ( G &  graph)
inline

Definition at line 78 of file pgr_deadEndContraction.hpp.

78  {
79  calculateVertices(graph);
80 
81  while (!deadendVertices.empty()) {
82  V v = deadendVertices.front();
83  deadendVertices -= v;
84  pgassert(is_dead_end(graph, v));
85 
86  Identifiers<V> local;
87  for (auto u : graph.find_adjacent_vertices(v)) {
88  /*
89  * u{v1} --{v2}-> v{v3}
90  *
91  * u{v1 + v + v2 + v3} v{}
92  */
93  auto v2(graph.get_min_cost_edge(u, v));
94  graph[u].contracted_vertices() += std::get<1>(v2);
95  graph[u].contracted_vertices() += graph[v].id;
96  graph[u].contracted_vertices() += graph[v].contracted_vertices();
97 
98  deadendVertices -= v;
99  local += u;
100  }
101 
102  graph[v].contracted_vertices().clear();
103  boost::clear_vertex(v, graph.graph);
104 
105  /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
106  CHECK_FOR_INTERRUPTS();
107 
108  for (const auto u : local) {
109  if (is_dead_end(graph, u) && !forbiddenVertices.has(u)) {
110  deadendVertices += u;
111  } else {
112  deadendVertices -= u;
113  }
114  }
115  }
116  }

References pgrouting::contraction::Pgr_deadend< G >::calculateVertices(), Identifiers< T >::clear(), pgrouting::contraction::Pgr_deadend< G >::deadendVertices, Identifiers< T >::empty(), pgrouting::contraction::Pgr_deadend< G >::forbiddenVertices, Identifiers< T >::front(), Identifiers< T >::has(), pgrouting::contraction::Pgr_deadend< G >::is_dead_end(), and pgassert.

Referenced by pgrouting::contraction::Pgr_contract< G >::perform_deadEnd().

◆ is_dead_end()

template<class G >
bool pgrouting::contraction::Pgr_deadend< G >::is_dead_end ( G &  graph,
V  v 
)
inline

Definition at line 67 of file pgr_deadEndContraction.hpp.

67  {
68  if (graph.is_undirected()) {
69  return graph.find_adjacent_vertices(v).size() == 1;
70  }
71 
72  pgassert(graph.is_directed());
73 
74  return graph.find_adjacent_vertices(v).size() == 1
75  || (graph.in_degree(v) > 0 && graph.out_degree(v) == 0);
76  }

References pgassert.

Referenced by pgrouting::contraction::Pgr_deadend< G >::calculateVertices(), and pgrouting::contraction::Pgr_deadend< G >::doContraction().

◆ setForbiddenVertices()

template<class G >
void pgrouting::contraction::Pgr_deadend< G >::setForbiddenVertices ( Identifiers< V forbidden_vertices)
inline

Member Data Documentation

◆ deadendVertices

◆ forbiddenVertices


The documentation for this class was generated from the following file:
pgrouting::contraction::Pgr_deadend::calculateVertices
void calculateVertices(G &graph)
Definition: pgr_deadEndContraction.hpp:59
pgrouting::contraction::Pgr_deadend::forbiddenVertices
Identifiers< V > forbiddenVertices
Definition: pgr_deadEndContraction.hpp:120
pgrouting::contraction::Pgr_deadend::is_dead_end
bool is_dead_end(G &graph, V v)
Definition: pgr_deadEndContraction.hpp:67
pgrouting::contraction::Pgr_deadend::deadendVertices
Identifiers< V > deadendVertices
Definition: pgr_deadEndContraction.hpp:119
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
Identifiers::clear
void clear()
Definition: identifiers.hpp:84
Identifiers::empty
bool empty() const
Definition: identifiers.hpp:79
Identifiers::front
T front() const
Definition: identifiers.hpp:80
Identifiers::has
bool has(const T other) const
true ids() has element
Definition: identifiers.hpp:98
pgrouting::contraction::Pgr_deadend::V
typename G::V V
Definition: pgr_deadEndContraction.hpp:47
Identifiers< V >