PGROUTING  3.2
edgeInfo.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: edgeInfo.h
4 
5 Copyright (c) 2017 pgRouting developers
7 
8 ------
9 
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14 
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 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 
24  ********************************************************************PGR-GNU*/
25 
26 #ifndef INCLUDE_TRSP_EDGEINFO_H_
27 #define INCLUDE_TRSP_EDGEINFO_H_
28 
29 #include <vector>
30 
31 
32 #include "c_types/pgr_edge_t.h"
33 #include "cpp_common/pgr_assert.h"
34 
35 namespace pgrouting {
36 namespace trsp {
37 
38 
39 class EdgeInfo {
40  public:
41  EdgeInfo() = default;
42 
43  EdgeInfo(
44  pgr_edge_t edgeIn,
45  size_t edgeIndex);
46 
47  inline size_t idx() const {return m_edgeIndex;}
48 
49  inline int64_t startNode() const {
50  pgassert(m_edge.source >= 0);
51  return m_edge.source;
52  }
53  inline int64_t endNode() const {
54  pgassert(m_edge.target >= 0);
55  return m_edge.target;}
56 
57  inline int64_t edgeID() const {return m_edge.id;}
58  inline double cost() const {return m_edge.cost;}
59  inline double r_cost() const {return m_edge.reverse_cost;}
60  inline double get_cost(int64_t node) const {
61  pgassert(node == startNode() || node == endNode());
62  return node == startNode() ?
63  cost() :
64  r_cost();
65  }
66 
67  void connect_endEdge(size_t edge_idx) {
68  m_endConnectedEdge.push_back(edge_idx);
69  }
70  void connect_startEdge(size_t edge_idx) {
71  m_startConnectedEdge.push_back(edge_idx);
72  }
73 
74  std::vector<size_t> endConnectedEdge() const {
75  return m_endConnectedEdge;
76  }
77 
78  std::vector<size_t> startConnectedEdge() const {
79  return m_startConnectedEdge;
80  }
81 
82  std::vector<size_t> get_idx(bool isStart) const {
83  return isStart ?
86  }
87 
88 
89  private:
91  size_t m_edgeIndex;
92  std::vector<size_t> m_startConnectedEdge;
93  std::vector<size_t> m_endConnectedEdge;
94 };
95 
96 } // namespace trsp
97 } // namespace pgrouting
98 
99 #endif // INCLUDE_TRSP_EDGEINFO_H_
pgr_edge_t::cost
double cost
Definition: pgr_edge_t.h:41
pgr_edge_t
Definition: pgr_edge_t.h:37
pgrouting::trsp::EdgeInfo
Definition: edgeInfo.h:39
pgrouting::trsp::EdgeInfo::startConnectedEdge
std::vector< size_t > startConnectedEdge() const
Definition: edgeInfo.h:78
pgr_edge_t::source
int64_t source
Definition: pgr_edge_t.h:39
pgrouting::trsp::EdgeInfo::edgeID
int64_t edgeID() const
Definition: edgeInfo.h:57
pgr_edge_t::target
int64_t target
Definition: pgr_edge_t.h:40
pgrouting::trsp::EdgeInfo::connect_endEdge
void connect_endEdge(size_t edge_idx)
Definition: edgeInfo.h:67
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
pgrouting::trsp::EdgeInfo::connect_startEdge
void connect_startEdge(size_t edge_idx)
Definition: edgeInfo.h:70
pgrouting::trsp::EdgeInfo::m_endConnectedEdge
std::vector< size_t > m_endConnectedEdge
Definition: edgeInfo.h:93
pgrouting::trsp::EdgeInfo::r_cost
double r_cost() const
Definition: edgeInfo.h:59
pgr_edge_t::reverse_cost
double reverse_cost
Definition: pgr_edge_t.h:42
pgr_assert.h
An assert functionality that uses C++ throw().
pgrouting::trsp::EdgeInfo::m_edgeIndex
size_t m_edgeIndex
Definition: edgeInfo.h:91
pgrouting::trsp::EdgeInfo::EdgeInfo
EdgeInfo()=default
pgrouting::trsp::EdgeInfo::m_startConnectedEdge
std::vector< size_t > m_startConnectedEdge
Definition: edgeInfo.h:92
pgrouting::trsp::EdgeInfo::endNode
int64_t endNode() const
Definition: edgeInfo.h:53
pgrouting::trsp::EdgeInfo::get_cost
double get_cost(int64_t node) const
Definition: edgeInfo.h:60
pgrouting::trsp::EdgeInfo::idx
size_t idx() const
Definition: edgeInfo.h:47
pgrouting::trsp::EdgeInfo::get_idx
std::vector< size_t > get_idx(bool isStart) const
Definition: edgeInfo.h:82
pgrouting::trsp::EdgeInfo::m_edge
pgr_edge_t m_edge
Definition: edgeInfo.h:90
pgrouting::trsp::EdgeInfo::endConnectedEdge
std::vector< size_t > endConnectedEdge() const
Definition: edgeInfo.h:74
pgr_edge_t::id
int64_t id
Definition: pgr_edge_t.h:38
pgrouting::trsp::EdgeInfo::cost
double cost() const
Definition: edgeInfo.h:58
pgr_edge_t.h
pgrouting::trsp::EdgeInfo::startNode
int64_t startNode() const
Definition: edgeInfo.h:49
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56