PGROUTING  3.2
pgrouting::functions::Pgr_breadthFirstSearch< G > Class Template Reference

#include "pgr_breadthFirstSearch.hpp"

Public Types

typedef G::B_G B_G
 
typedef G::E E
 
typedef G::V V
 

Public Member Functions

std::vector< pgr_mst_rtbreadthFirstSearch (G &graph, std::vector< int64_t > start_vertex, int64_t depth)
 

Private Member Functions

template<typename T >
std::vector< pgr_mst_rtget_results (T order, int64_t source, int64_t max_depth, const G &graph)
 

Detailed Description

template<class G>
class pgrouting::functions::Pgr_breadthFirstSearch< G >

Definition at line 42 of file pgr_breadthFirstSearch.hpp.

Member Typedef Documentation

◆ B_G

template<class G >
typedef G::B_G pgrouting::functions::Pgr_breadthFirstSearch< G >::B_G

Definition at line 46 of file pgr_breadthFirstSearch.hpp.

◆ E

template<class G >
typedef G::E pgrouting::functions::Pgr_breadthFirstSearch< G >::E

Definition at line 45 of file pgr_breadthFirstSearch.hpp.

◆ V

template<class G >
typedef G::V pgrouting::functions::Pgr_breadthFirstSearch< G >::V

Definition at line 44 of file pgr_breadthFirstSearch.hpp.

Member Function Documentation

◆ breadthFirstSearch()

template<class G >
std::vector<pgr_mst_rt> pgrouting::functions::Pgr_breadthFirstSearch< G >::breadthFirstSearch ( G &  graph,
std::vector< int64_t >  start_vertex,
int64_t  depth 
)
inline

Definition at line 49 of file pgr_breadthFirstSearch.hpp.

52  {
53  std::vector<pgr_mst_rt> results;
54  using bfs_visitor = visitors::Edges_order_bfs_visitor<E>;
55 
56  for (auto source : start_vertex) {
57  std::vector<E> visited_order;
58 
59  if (graph.has_vertex(source)) {
60  results.push_back({source, 0, source, -1, 0.0, 0.0});
61  boost::breadth_first_search(graph.graph,
62  graph.get_V(source),
63  visitor(bfs_visitor(visited_order)));
64 
65  auto single_source_results = get_results(visited_order, source, depth, graph);
66  results.insert(results.end(), single_source_results.begin(), single_source_results.end());
67 
68  /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
69  CHECK_FOR_INTERRUPTS();
70  }
71  }
72  return results;
73  }

References pgrouting::functions::Pgr_breadthFirstSearch< G >::get_results().

Referenced by pgr_breadthFirstSearch().

◆ get_results()

template<class G >
template<typename T >
std::vector<pgr_mst_rt> pgrouting::functions::Pgr_breadthFirstSearch< G >::get_results ( order,
int64_t  source,
int64_t  max_depth,
const G &  graph 
)
inlineprivate

Definition at line 77 of file pgr_breadthFirstSearch.hpp.

81  {
82  std::vector<pgr_mst_rt> results;
83 
84  std::vector<double> agg_cost(graph.num_vertices(), 0);
85  std::vector<int64_t> depth(graph.num_vertices(), 0);
86 
87  for (const auto edge : order) {
88  auto u = graph.source(edge);
89  auto v = graph.target(edge);
90 
91  agg_cost[v] = agg_cost[u] + graph[edge].cost;
92  depth[v] = depth[u] + 1;
93 
94  if (max_depth >= depth[v]) {
95  results.push_back({
96  source,
97  depth[v],
98  graph[v].id,
99  graph[edge].id,
100  graph[edge].cost,
101  agg_cost[v]
102  });
103  }
104  }
105  return results;
106  }

Referenced by pgrouting::functions::Pgr_breadthFirstSearch< G >::breadthFirstSearch().


The documentation for this class was generated from the following file:
edge
Definition: trsp.h:41
pgrouting::functions::Pgr_breadthFirstSearch::get_results
std::vector< pgr_mst_rt > get_results(T order, int64_t source, int64_t max_depth, const G &graph)
Definition: pgr_breadthFirstSearch.hpp:77