PGROUTING  3.2
pgr_boyerMyrvold.hpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: pgr_boyerMyrvold.hpp
3 
4 Copyright (c) 2020 pgRouting developers
6 
7 Copyright (c) 2020 Himanshu Raj
9 
10 ------
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 ********************************************************************PGR-GNU*/
23 
24 #ifndef INCLUDE_PLANAR_PGR_BOYERMYRVOLD_HPP_
25 #define INCLUDE_PLANAR_PGR_BOYERMYRVOLD_HPP_
26 #pragma once
27 
28 #include <boost/graph/adjacency_list.hpp>
29 #include <boost/graph/properties.hpp>
30 #include <boost/graph/graph_traits.hpp>
31 #include <boost/property_map/property_map.hpp>
32 #include <boost/graph/boyer_myrvold_planar_test.hpp>
33 #include <boost/graph/is_kuratowski_subgraph.hpp>
34 #include <boost/ref.hpp>
35 
36 #include <vector>
37 
41 #include "c_types/pgr_boyer_t.h"
42 //******************************************
43 namespace pgrouting {
44 namespace functions {
45 
46 template < class G >
48  public:
49  typedef typename G::V V;
50  typedef typename G::E E;
51  typedef typename G::E_i E_i;
52  std::vector<pgr_boyer_t> boyerMyrvold(G &graph) {
53  return generateboyerMyrvold(graph);
54  }
55 
56  bool isPlanar(G &graph) {
57  /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
58  CHECK_FOR_INTERRUPTS();
59  try {
60  return (boost::boyer_myrvold_planarity_test(graph.graph));
61  } catch (boost::exception const& ex) {
62  (void)ex;
63  throw;
64  } catch (std::exception &e) {
65  (void)e;
66  throw;
67  } catch (...) {
68  throw;
69  }
70  return false;
71  }
72 
73  private:
74  std::vector< pgr_boyer_t >generateboyerMyrvold(const G &graph ) {
75  std::vector< pgr_boyer_t > results;
76  auto check = boost::boyer_myrvold_planarity_test(graph.graph);
77  if (check) {
78  E_i ei, ei_end;
79  for (boost::tie(ei, ei_end) = edges(graph.graph); ei != ei_end; ++ei) {
80  int64_t src = graph[graph.source(*ei)].id;
81  int64_t tgt = graph[graph.target(*ei)].id;
82  double cost = graph[*ei].cost;
83  pgr_boyer_t tmp;
84  tmp.source = src;
85  tmp.target = tgt;
86  tmp.cost = cost;
87  results.push_back(tmp);
88  }
89  }
90  return results;
91  }
92 };
93 } // namespace functions
94 } // namespace pgrouting
95 
96 #endif // INCLUDE_PLANAR_PGR_BOYERMYRVOLD_HPP_
pgrouting::Pgr_messages
Definition: pgr_messages.h:39
interruption.h
pgr_base_graph.hpp
pgr_messages.h
pgrouting::functions::Pgr_boyerMyrvold::V
G::V V
Definition: pgr_boyerMyrvold.hpp:49
pgrouting::functions::Pgr_boyerMyrvold::isPlanar
bool isPlanar(G &graph)
Definition: pgr_boyerMyrvold.hpp:56
pgrouting::functions::Pgr_boyerMyrvold::E_i
G::E_i E_i
Definition: pgr_boyerMyrvold.hpp:51
pgrouting::alphashape::E
boost::graph_traits< BG >::edge_descriptor E
Definition: pgr_alphaShape.h:57
pgr_boyer_t
Definition: pgr_boyer_t.h:37
pgrouting::functions::Pgr_boyerMyrvold::generateboyerMyrvold
std::vector< pgr_boyer_t > generateboyerMyrvold(const G &graph)
Definition: pgr_boyerMyrvold.hpp:74
pgr_boyer_t.h
pgrouting::alphashape::G
graph::Pgr_base_graph< BG, XY_vertex, Basic_edge > G
Definition: pgr_alphaShape.h:56
pgrouting::functions::Pgr_boyerMyrvold::E
G::E E
Definition: pgr_boyerMyrvold.hpp:50
pgr_boyer_t::cost
double cost
Definition: pgr_boyer_t.h:40
pgr_boyer_t::target
int64_t target
Definition: pgr_boyer_t.h:39
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
pgrouting::functions::Pgr_boyerMyrvold
Definition: pgr_boyerMyrvold.hpp:47
pgrouting::functions::Pgr_boyerMyrvold::boyerMyrvold
std::vector< pgr_boyer_t > boyerMyrvold(G &graph)
Definition: pgr_boyerMyrvold.hpp:52
pgr_boyer_t::source
int64_t source
Definition: pgr_boyer_t.h:38