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

#include "pgr_contract.hpp"

Public Member Functions

 Pgr_contract (G &graph, Identifiers< V > forbidden_vertices, std::vector< int64_t > contraction_order, int64_t max_cycles)
 

Private Types

typedef G::V V
 

Private Member Functions

void one_cycle (G &graph, int64_t kind, Identifiers< V > &forbidden_vertices)
 
void perform_deadEnd (G &graph, Identifiers< V > forbidden_vertices)
 
void perform_linear (G &graph, Identifiers< V > &forbidden_vertices)
 

Detailed Description

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

Definition at line 49 of file pgr_contract.hpp.

Member Typedef Documentation

◆ V

template<class G >
typedef G::V pgrouting::contraction::Pgr_contract< G >::V
private

Definition at line 50 of file pgr_contract.hpp.

Constructor & Destructor Documentation

◆ Pgr_contract()

template<class G >
pgrouting::contraction::Pgr_contract< G >::Pgr_contract ( G &  graph,
Identifiers< V forbidden_vertices,
std::vector< int64_t >  contraction_order,
int64_t  max_cycles 
)
inline

Definition at line 53 of file pgr_contract.hpp.

58  {
59  std::deque<int64_t> contract_order;
60  // push -1 to indicate the start of the queue
61  contract_order.push_back(-1);
62  contract_order.insert(
63  contract_order.end(),
64  contraction_order.begin(), contraction_order.end());
65  for (int64_t i = 0; i < max_cycles; ++i) {
66  int64_t front = contract_order.front();
67  contract_order.pop_front();
68  contract_order.push_back(front);
69  auto kind = contract_order.front();
70  while (kind != -1) {
71  one_cycle(graph, kind, forbidden_vertices);
72  contract_order.pop_front();
73  contract_order.push_back(front);
74  kind = contract_order.front();
75  }
76  }
77  }

References pgrouting::contraction::Pgr_contract< G >::one_cycle().

Member Function Documentation

◆ one_cycle()

template<class G >
void pgrouting::contraction::Pgr_contract< G >::one_cycle ( G &  graph,
int64_t  kind,
Identifiers< V > &  forbidden_vertices 
)
inlineprivate

Definition at line 81 of file pgr_contract.hpp.

84  {
85  switch (kind) {
86  case -1:
87  pgassert(false);
88  break;
89 
90  case 1:
91  perform_deadEnd(graph, forbidden_vertices);
92  break;
93 
94 
95  case 2:
96  perform_linear(graph, forbidden_vertices);
97  break;
98  default:
99  pgassert(false);
100  break;
101  }
102  }

References pgrouting::contraction::Pgr_contract< G >::perform_deadEnd(), pgrouting::contraction::Pgr_contract< G >::perform_linear(), and pgassert.

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

◆ perform_deadEnd()

template<class G >
void pgrouting::contraction::Pgr_contract< G >::perform_deadEnd ( G &  graph,
Identifiers< V forbidden_vertices 
)
inlineprivate

Definition at line 104 of file pgr_contract.hpp.

105  {
106  Pgr_deadend<G> deadendContractor;
107  deadendContractor.setForbiddenVertices(forbidden_vertices);
108 
109  deadendContractor.calculateVertices(graph);
110  try {
111  deadendContractor.doContraction(graph);
112  }
113  catch ( ... ) {
114  throw;
115  }
116  }

References pgrouting::contraction::Pgr_deadend< G >::calculateVertices(), pgrouting::contraction::Pgr_deadend< G >::doContraction(), and pgrouting::contraction::Pgr_deadend< G >::setForbiddenVertices().

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

◆ perform_linear()

template<class G >
void pgrouting::contraction::Pgr_contract< G >::perform_linear ( G &  graph,
Identifiers< V > &  forbidden_vertices 
)
inlineprivate

Definition at line 119 of file pgr_contract.hpp.

120  {
121  Pgr_linear<G> linearContractor;
122  try {
123  linearContractor(graph, forbidden_vertices);
124  }
125  catch ( ... ) {
126  throw;
127  }
128  }

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


The documentation for this class was generated from the following file:
pgrouting::contraction::Pgr_contract::perform_deadEnd
void perform_deadEnd(G &graph, Identifiers< V > forbidden_vertices)
Definition: pgr_contract.hpp:104
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
pgrouting::contraction::Pgr_contract::perform_linear
void perform_linear(G &graph, Identifiers< V > &forbidden_vertices)
Definition: pgr_contract.hpp:119
pgrouting::contraction::Pgr_contract::one_cycle
void one_cycle(G &graph, int64_t kind, Identifiers< V > &forbidden_vertices)
Definition: pgr_contract.hpp:81