PGROUTING  2.6-dev
edgeInfo.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: edgeInfo.h
4 
5 Copyright (c) 2017 pgRouting developers
6 Mail: project@pgrouting.org
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 aint64_t 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_
double cost() const
Definition: edgeInfo.h:58
double reverse_cost
Definition: pgr_edge_t.h:63
std::vector< size_t > get_idx(bool isStart) const
Definition: edgeInfo.h:82
int64_t endNode() const
Definition: edgeInfo.h:53
int64_t source
Definition: pgr_edge_t.h:60
int64_t target
Definition: pgr_edge_t.h:61
void connect_endEdge(size_t edge_idx)
Definition: edgeInfo.h:67
std::vector< size_t > startConnectedEdge() const
Definition: edgeInfo.h:78
void connect_startEdge(size_t edge_idx)
Definition: edgeInfo.h:70
int64_t edgeID() const
Definition: edgeInfo.h:57
std::vector< size_t > m_startConnectedEdge
Definition: edgeInfo.h:92
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
int64_t id
Definition: pgr_edge_t.h:59
double cost
Definition: pgr_edge_t.h:62
int64_t startNode() const
Definition: edgeInfo.h:49
std::vector< size_t > m_endConnectedEdge
Definition: edgeInfo.h:93
double get_cost(int64_t node) const
Definition: edgeInfo.h:60
Book keeping class for swapping orders between vehicles.
Definition: basic_edge.cpp:28
Assertions Handling.
double r_cost() const
Definition: edgeInfo.h:59
size_t idx() const
Definition: edgeInfo.h:47
std::vector< size_t > endConnectedEdge() const
Definition: edgeInfo.h:74