1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
/*PGR-GNU*****************************************************************
File: edgeInfo.hpp
Copyright (c) 2017-2026 pgRouting developers
Mail: project@pgrouting.org
------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/
#ifndef INCLUDE_TRSP_EDGEINFO_HPP_
#define INCLUDE_TRSP_EDGEINFO_HPP_
#include <vector>
#include <cstdint>
#include "cpp_common/edge_t.hpp"
#include "cpp_common/assert.hpp"
namespace pgrouting {
namespace trsp {
class EdgeInfo {
public:
EdgeInfo() = default;
EdgeInfo(
Edge_t edgeIn,
size_t edgeIndex);
inline size_t idx() const {return m_edgeIndex;}
inline int64_t startNode() const {
return m_edge.source;
}
inline int64_t endNode() const {
return m_edge.target;}
inline int64_t edgeID() const {return m_edge.id;}
inline double cost() const {return m_edge.cost;}
inline double r_cost() const {return m_edge.reverse_cost;}
inline double get_cost(int64_t node) const {
pgassert(node == startNode() || node == endNode());
return node == startNode() ?
cost() :
r_cost();
}
void connect_endEdge(size_t edge_idx) {
m_endConnectedEdge.push_back(edge_idx);
}
void connect_startEdge(size_t edge_idx) {
m_startConnectedEdge.push_back(edge_idx);
}
std::vector<size_t> endConnectedEdge() const {
return m_endConnectedEdge;
}
std::vector<size_t> startConnectedEdge() const {
return m_startConnectedEdge;
}
std::vector<size_t> get_idx(bool isStart) const {
return isStart ?
startConnectedEdge() :
endConnectedEdge();
}
private:
Edge_t m_edge;
size_t m_edgeIndex;
std::vector<size_t> m_startConnectedEdge;
std::vector<size_t> m_endConnectedEdge;
};
} // namespace trsp
} // namespace pgrouting
#endif // INCLUDE_TRSP_EDGEINFO_HPP_
|