PGROUTING  2.6-dev
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, Identifiers< int64_t > &remaining_vertices, std::vector< pgrouting::CH_edge > &shortcut_edges, std::ostringstream &debug)
 

Private Types

typedef G::V V
 

Private Member Functions

void perform_deadEnd (G &graph, Identifiers< V > forbidden_vertices, std::ostringstream &debug)
 
void perform_linear (G &graph, Identifiers< V > &forbidden_vertices, std::ostringstream &debug)
 

Detailed Description

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

Definition at line 47 of file pgr_contract.hpp.

Member Typedef Documentation

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

Definition at line 48 of file pgr_contract.hpp.

Constructor & Destructor Documentation

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,
Identifiers< int64_t > &  remaining_vertices,
std::vector< pgrouting::CH_edge > &  shortcut_edges,
std::ostringstream &  debug 
)
inline

Definition at line 86 of file pgr_contract.hpp.

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

93  {
94  std::deque<int64_t> contract_order;
95  // push -1 to indicate the start of the queue
96  contract_order.push_back(-1);
97  contract_order.insert(
98  contract_order.end(),
99  contraction_order.begin(), contraction_order.end());
100  for (int64_t i = 0; i < max_cycles; ++i) {
101  int64_t front = contract_order.front();
102  debug << "Starting cycle " << i+1 << "\n";
103  contract_order.pop_front();
104  contract_order.push_back(front);
105  front = contract_order.front();
106  while (front != -1) {
107  switch (front) {
108  case -1:
109  debug << "Finished cycle " << i+1 << std::endl;
110  break;
111  default:
112  debug << "contraction "<< front
113  << " asked" << std::endl;
114  if (front == 1) {
115 #ifndef NDEBUG
116  debug << "Graph before dead end contraction"
117  << std::endl;
118  graph.print_graph(debug);
119  debug << "Performing dead end contraction"
120  << std::endl;
121 #endif
122  perform_deadEnd(graph, forbidden_vertices, debug);
123 #ifndef NDEBUG
124  debug << "Graph after dead end contraction"
125  << std::endl;
126  graph.print_graph(debug);
127 #endif
128  } else if (front == 2) {
129 #ifndef NDEBUG
130  debug << "Graph before linear contraction"
131  << std::endl;
132  graph.print_graph(debug);
133  debug << "Performing linear contraction"
134  << std::endl;
135 #endif
136  perform_linear(graph, forbidden_vertices, debug);
137 #ifndef NDEBUG
138  debug << "Graph after linear contraction"
139  << std::endl;
140  graph.print_graph(debug);
141 #endif
142  }
143  contract_order.pop_front();
144  contract_order.push_back(front);
145  front = contract_order.front();
146  }
147  }
148  }
149  remaining_vertices = graph.get_changed_vertices();
150  debug << "Printing shortcuts\n";
151  for (auto shortcut : graph.shortcuts) {
152  debug << shortcut;
153  shortcut_edges.push_back(shortcut);
154  }
155  }
void perform_deadEnd(G &graph, Identifiers< V > forbidden_vertices, std::ostringstream &debug)
void perform_linear(G &graph, Identifiers< V > &forbidden_vertices, std::ostringstream &debug)

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 51 of file pgr_contract.hpp.

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 >::Pgr_contract().

53  {
54  Pgr_deadend<G> deadendContractor;
55  debug << "Setting forbidden_vertices";
56  deadendContractor.setForbiddenVertices(forbidden_vertices);
57 
58  deadendContractor.calculateVertices(graph);
59  try {
60  deadendContractor.doContraction(graph);
61  }
62  catch ( ... ) {
63  debug << "Caught unknown exception!\n";
64  }
65  }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 68 of file pgr_contract.hpp.

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

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

70  {
71  std::ostringstream linear_debug;
72  Pgr_linear<G> linearContractor;
73  linearContractor.setForbiddenVertices(forbidden_vertices);
74  linearContractor.calculateVertices(graph);
75  try {
76  linearContractor.doContraction(graph);
77  }
78  catch ( ... ) {
79  linear_debug << "Caught unknown exception!\n";
80  }
81  debug << linear_debug.str().c_str() << "\n";
82  }

Here is the call graph for this function:

Here is the caller graph for this function:


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