PGROUTING  3.2
dfs_visitor_with_root.hpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: Dfs_visitor_with_root.hpp
3 
4 Copyright (c) 2015 pgRouting developers
6 
7 Copyright (c) 2018 Aditya Pratap Singh
9 
10 ------
11 
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 
26  ********************************************************************PGR-GNU*/
27 
28 #ifndef INCLUDE_VISITORS_DFS_VISITOR_WITH_ROOT_HPP_
29 #define INCLUDE_VISITORS_DFS_VISITOR_WITH_ROOT_HPP_
30 #pragma once
31 
32 #include <boost/graph/depth_first_search.hpp>
33 
34 #include <vector>
35 
36 #include "visitors/found_goals.hpp"
37 
38 namespace pgrouting {
39 namespace visitors {
40 
41 template <typename V, typename E>
42 class Dfs_visitor_with_root : public boost::default_dfs_visitor {
43  public:
45  V root,
46  std::vector<E> &data) :
47  m_data(data),
48  m_roots(root) {}
49  template <typename B_G>
50  void tree_edge(E e, const B_G&) {
51  m_data.push_back(e);
52  }
53  template <typename B_G>
54  void start_vertex(V v, const B_G&) {
55  if (v != m_roots) throw found_goals();
56  }
57 
58  private:
59  std::vector<E> &m_data;
61 };
62 
63 
64 } // namespace visitors
65 } // namespace pgrouting
66 
67 #endif // INCLUDE_VISITORS_DFS_VISITOR_WITH_ROOT_HPP_
pgrouting::visitors::Dfs_visitor_with_root
Definition: dfs_visitor_with_root.hpp:42
pgrouting::visitors::Dfs_visitor_with_root::Dfs_visitor_with_root
Dfs_visitor_with_root(V root, std::vector< E > &data)
Definition: dfs_visitor_with_root.hpp:44
found_goals.hpp
pgrouting::visitors::Dfs_visitor_with_root::start_vertex
void start_vertex(V v, const B_G &)
Definition: dfs_visitor_with_root.hpp:54
pgrouting::visitors::Dfs_visitor_with_root::m_data
std::vector< E > & m_data
Definition: dfs_visitor_with_root.hpp:59
pgrouting::visitors::Dfs_visitor_with_root::m_roots
V m_roots
Definition: dfs_visitor_with_root.hpp:60
pgrouting::alphashape::E
boost::graph_traits< BG >::edge_descriptor E
Definition: pgr_alphaShape.h:57
pgrouting::visitors::Dfs_visitor_with_root::tree_edge
void tree_edge(E e, const B_G &)
Definition: dfs_visitor_with_root.hpp:50
pgrouting::found_goals
exception for visitor termination
Definition: found_goals.hpp:33
pgrouting::alphashape::V
boost::graph_traits< BG >::vertex_descriptor V
Definition: pgr_alphaShape.h:58
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56