PGROUTING  3.2
pgrouting::visitors::Dfs_visitor< V, E, G > Class Template Reference

#include "dfs_visitor.hpp"

Inheritance diagram for pgrouting::visitors::Dfs_visitor< V, E, G >:
Collaboration diagram for pgrouting::visitors::Dfs_visitor< V, E, G >:

Public Member Functions

 Dfs_visitor (V root, std::vector< E > &data, int64_t max_depth, std::vector< boost::default_color_type > &colors, G &graph)
 
template<typename B_G >
void examine_edge (E e, const B_G &)
 
template<typename B_G >
void start_vertex (V v, const B_G &)
 
template<typename B_G >
void tree_edge (E e, const B_G &)
 

Private Attributes

std::vector< boost::default_color_type > & m_colors
 
std::vector< E > & m_data
 
std::vector< int64_t > m_depth
 
G & m_graph
 
int64_t m_max_depth
 
m_roots
 

Detailed Description

template<typename V, typename E, typename G>
class pgrouting::visitors::Dfs_visitor< V, E, G >

Definition at line 45 of file dfs_visitor.hpp.

Constructor & Destructor Documentation

◆ Dfs_visitor()

template<typename V , typename E , typename G >
pgrouting::visitors::Dfs_visitor< V, E, G >::Dfs_visitor ( root,
std::vector< E > &  data,
int64_t  max_depth,
std::vector< boost::default_color_type > &  colors,
G &  graph 
)
inline

Definition at line 47 of file dfs_visitor.hpp.

52  :
53  m_roots(root),
54  m_data(data),
55  m_max_depth(max_depth),
56  m_colors(colors),
57  m_graph(graph) {
58  m_depth.resize(m_graph.num_vertices(), 0);
59  }

References pgrouting::visitors::Dfs_visitor< V, E, G >::m_depth, and pgrouting::visitors::Dfs_visitor< V, E, G >::m_graph.

Member Function Documentation

◆ examine_edge()

template<typename V , typename E , typename G >
template<typename B_G >
void pgrouting::visitors::Dfs_visitor< V, E, G >::examine_edge ( e,
const B_G &   
)
inline

Definition at line 67 of file dfs_visitor.hpp.

67  {
68  auto source = m_graph.source(e), target = m_graph.target(e);
69  // If the target has not been visited before
70  if (m_depth[target] == 0 && target != m_roots)
71  m_depth[target] = m_depth[source] + 1;
72 
73  // If the max_depth is reached, mark the target as visited, and push the corresponding edge
74  if (m_depth[target] == m_max_depth && m_colors[target] != 4) {
75  m_colors[target] = boost::black_color;
76  m_data.push_back(e);
77  }
78  }

References pgrouting::visitors::Dfs_visitor< V, E, G >::m_colors, pgrouting::visitors::Dfs_visitor< V, E, G >::m_data, pgrouting::visitors::Dfs_visitor< V, E, G >::m_depth, pgrouting::visitors::Dfs_visitor< V, E, G >::m_graph, pgrouting::visitors::Dfs_visitor< V, E, G >::m_max_depth, and pgrouting::visitors::Dfs_visitor< V, E, G >::m_roots.

◆ start_vertex()

template<typename V , typename E , typename G >
template<typename B_G >
void pgrouting::visitors::Dfs_visitor< V, E, G >::start_vertex ( v,
const B_G &   
)
inline

Definition at line 61 of file dfs_visitor.hpp.

61  {
62  // exception for visitor termination
63  if (v != m_roots) throw found_goals();
64  m_depth[v] = 0;
65  }

References pgrouting::visitors::Dfs_visitor< V, E, G >::m_depth, and pgrouting::visitors::Dfs_visitor< V, E, G >::m_roots.

◆ tree_edge()

template<typename V , typename E , typename G >
template<typename B_G >
void pgrouting::visitors::Dfs_visitor< V, E, G >::tree_edge ( e,
const B_G &   
)
inline

Definition at line 80 of file dfs_visitor.hpp.

80  {
81  m_data.push_back(e);
82  }

References pgrouting::visitors::Dfs_visitor< V, E, G >::m_data.

Member Data Documentation

◆ m_colors

template<typename V , typename E , typename G >
std::vector<boost::default_color_type>& pgrouting::visitors::Dfs_visitor< V, E, G >::m_colors
private

◆ m_data

template<typename V , typename E , typename G >
std::vector<E>& pgrouting::visitors::Dfs_visitor< V, E, G >::m_data
private

◆ m_depth

template<typename V , typename E , typename G >
std::vector<int64_t> pgrouting::visitors::Dfs_visitor< V, E, G >::m_depth
private

◆ m_graph

template<typename V , typename E , typename G >
G& pgrouting::visitors::Dfs_visitor< V, E, G >::m_graph
private

◆ m_max_depth

template<typename V , typename E , typename G >
int64_t pgrouting::visitors::Dfs_visitor< V, E, G >::m_max_depth
private

◆ m_roots

template<typename V , typename E , typename G >
V pgrouting::visitors::Dfs_visitor< V, E, G >::m_roots
private

The documentation for this class was generated from the following file:
pgrouting::visitors::Dfs_visitor::m_colors
std::vector< boost::default_color_type > & m_colors
Definition: dfs_visitor.hpp:88
pgrouting::visitors::Dfs_visitor::m_graph
G & m_graph
Definition: dfs_visitor.hpp:89
pgrouting::visitors::Dfs_visitor::m_max_depth
int64_t m_max_depth
Definition: dfs_visitor.hpp:87
pgrouting::visitors::Dfs_visitor::m_depth
std::vector< int64_t > m_depth
Definition: dfs_visitor.hpp:90
pgrouting::visitors::Dfs_visitor::m_roots
V m_roots
Definition: dfs_visitor.hpp:85
pgrouting::visitors::Dfs_visitor::m_data
std::vector< E > & m_data
Definition: dfs_visitor.hpp:86