Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
GraphDecorator.hpp
Go to the documentation of this file.
1#pragma once
4namespace fishnet::graph{
12template<class DecoratorImpl, class G, Edge E = typename G::edge_type>
14{
15protected:
16 G g;
17 using N = G::node_type;
18 GraphDecorator() requires std::is_default_constructible_v<G> = default;
19 GraphDecorator(G && source):g(std::move(source)){};
20 GraphDecorator(typename G::adj_container_type && adjContainer):g(std::move(adjContainer)){}
21 GraphDecorator(util::forward_range_of<N> auto && nodes):g(std::forward<decltype(nodes)>(nodes)){};
22public:
23 using edge_type = E;
24 using adj_container_type = G::adj_container_type;
25 using node_type = N;
26
27 bool addNode(N & node){
28 return g.addNode(node);
29 }
30
31 bool addNode( N && node){
32 return g.addNode(node);
33 }
34
35 template<typename... Args>
36 bool addNode(const N & node, Args... args){
37 return g.addNode(node,args...);
38 }
39
40 template<typename... Args>
41 bool addNode(N && node, Args... args){
42 return g.addNode(std::move(node),args...);
43 }
44
46 return g.addNodes(nodes);
47 }
48
50 return g.addNodes(nodes);
51 }
52
53 bool containsNode(const N & node) const noexcept {
54 return g.containsNode(node);
55 }
56
57 void removeNode(const N & node) {
58 g.removeNode(node);
59 }
60
61 bool addEdge(const N & from, const N & to){
62 return g.addEdge(from,to);
63 }
64
65 bool addEdge(N && from, N && to){
66 return g.addEdge(std::move(from),std::move(to));
67 }
68
69 bool addEdge(const E & edge){
70 return g.addEdge(edge);
71 }
72
73 void addEdges(util::forward_range_of<std::pair<N,N>> auto && edges){
74 g.addEdges(edges);
75 }
76
77 void addEdges(util::forward_range_of<E> auto && edges) {
78 g.addEdges(edges);
79 }
80
81 bool containsEdge(const N & from, const N & to) const noexcept{
82 return g.containsEdge(from,to);
83 }
84
85 bool containsEdge(const E & edge) const noexcept {
86 return g.containsEdge(edge);
87 }
88
89 void removeEdge(const N & from, const N & to){
90 g.removeEdge(from,to);
91 }
92
93 void removeEdge(const E & edge){
94 g.removeEdge(edge);
95 }
96
97 inline E makeEdge(const N & from, const N & to) const {
98 return g.makeEdge(from,to);
99 }
100
101 auto getNodes() const noexcept{
102 return g.getNodes();
103 }
104
105 auto getEdges() const {
106 return g.getEdges();
107 }
108
109 auto getNeighbours(const N & node) const noexcept {
110 return g.getNeighbours(node);
111 }
112
113 auto getReachableFrom(const N & node) const noexcept {
114 return g.getReachableFrom(node);
115 }
116
117 auto getOutboundEdges(const N & node) const {
118 return g.getOutboundEdges(node);
119 }
120
121 auto getInboundEdges(const N & node) const {
122 return g.getInboundEdges(node);
123 }
124
125 const auto & getAdjacencyContainer() const {
126 return g.getAdjacencyContainer();
127 }
128
129 void clear(){
130 g.clear();
131 }
132
133 virtual ~GraphDecorator() = default;
134};
135}
Abstract Graph Decorator using CRTP.
Definition GraphDecorator.hpp:14
void addEdges(util::forward_range_of< std::pair< N, N > > auto &&edges)
Definition GraphDecorator.hpp:73
G::adj_container_type adj_container_type
Definition GraphDecorator.hpp:24
G g
Definition GraphDecorator.hpp:16
bool addNode(N &&node, Args... args)
Definition GraphDecorator.hpp:41
N node_type
Definition GraphDecorator.hpp:25
void removeNode(const N &node)
Definition GraphDecorator.hpp:57
bool addEdge(const N &from, const N &to)
Definition GraphDecorator.hpp:61
E makeEdge(const N &from, const N &to) const
Definition GraphDecorator.hpp:97
void removeEdge(const N &from, const N &to)
Definition GraphDecorator.hpp:89
bool addEdge(N &&from, N &&to)
Definition GraphDecorator.hpp:65
bool addNodes(util::forward_range_of< N > auto &&nodes)
Definition GraphDecorator.hpp:49
G::node_type N
Definition GraphDecorator.hpp:17
bool addNodes(util::forward_range_of< N > auto &nodes)
Definition GraphDecorator.hpp:45
void addEdges(util::forward_range_of< E > auto &&edges)
Definition GraphDecorator.hpp:77
void clear()
Definition GraphDecorator.hpp:129
bool containsNode(const N &node) const noexcept
Definition GraphDecorator.hpp:53
const auto & getAdjacencyContainer() const
Definition GraphDecorator.hpp:125
auto getNeighbours(const N &node) const noexcept
Definition GraphDecorator.hpp:109
bool addNode(const N &node, Args... args)
Definition GraphDecorator.hpp:36
bool addNode(N &&node)
Definition GraphDecorator.hpp:31
bool containsEdge(const E &edge) const noexcept
Definition GraphDecorator.hpp:85
auto getReachableFrom(const N &node) const noexcept
Definition GraphDecorator.hpp:113
auto getNodes() const noexcept
Definition GraphDecorator.hpp:101
GraphDecorator(util::forward_range_of< N > auto &&nodes)
Definition GraphDecorator.hpp:21
auto getOutboundEdges(const N &node) const
Definition GraphDecorator.hpp:117
auto getEdges() const
Definition GraphDecorator.hpp:105
void removeEdge(const E &edge)
Definition GraphDecorator.hpp:93
GraphDecorator(typename G::adj_container_type &&adjContainer)
Definition GraphDecorator.hpp:20
E edge_type
Definition GraphDecorator.hpp:23
virtual ~GraphDecorator()=default
bool containsEdge(const N &from, const N &to) const noexcept
Definition GraphDecorator.hpp:81
auto getInboundEdges(const N &node) const
Definition GraphDecorator.hpp:121
bool addEdge(const E &edge)
Definition GraphDecorator.hpp:69
bool addNode(N &node)
Definition GraphDecorator.hpp:27
Definition CollectionConcepts.hpp:27
Definition AdjacencyContainer.hpp:4
STL namespace.