marci@174
|
1 |
// -*- c++ -*-
|
marci@259
|
2 |
#ifndef HUGO_GRAPH_WRAPPER_H
|
marci@259
|
3 |
#define HUGO_GRAPH_WRAPPER_H
|
marci@76
|
4 |
|
marci@174
|
5 |
#include <invalid.h>
|
marci@174
|
6 |
|
alpar@105
|
7 |
namespace hugo {
|
marci@76
|
8 |
|
marci@76
|
9 |
template<typename Graph>
|
marci@76
|
10 |
class TrivGraphWrapper {
|
marci@199
|
11 |
protected:
|
marci@76
|
12 |
Graph* graph;
|
marci@76
|
13 |
|
marci@76
|
14 |
public:
|
marci@76
|
15 |
typedef Graph BaseGraph;
|
marci@76
|
16 |
|
marci@174
|
17 |
typedef typename Graph::Node Node;
|
marci@76
|
18 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
19 |
|
marci@174
|
20 |
typedef typename Graph::Edge Edge;
|
marci@76
|
21 |
typedef typename Graph::OutEdgeIt OutEdgeIt;
|
marci@76
|
22 |
typedef typename Graph::InEdgeIt InEdgeIt;
|
marci@155
|
23 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
24 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@168
|
25 |
|
marci@168
|
26 |
//TrivGraphWrapper() : graph(0) { }
|
marci@168
|
27 |
TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@168
|
28 |
|
marci@168
|
29 |
void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@168
|
30 |
Graph& getGraph() const { return (*graph); }
|
marci@76
|
31 |
|
marci@212
|
32 |
template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@212
|
33 |
template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
34 |
return graph->first(i, p); }
|
marci@155
|
35 |
|
marci@155
|
36 |
template<typename I> I getNext(const I& i) const {
|
marci@155
|
37 |
return graph->getNext(i); }
|
marci@155
|
38 |
template<typename I> I& next(I &i) const { return graph->next(i); }
|
marci@76
|
39 |
|
marci@76
|
40 |
template< typename It > It first() const {
|
marci@212
|
41 |
It e; first(e); return e; }
|
marci@76
|
42 |
|
marci@174
|
43 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
44 |
It e; first(e, v); return e; }
|
marci@76
|
45 |
|
marci@174
|
46 |
Node head(const Edge& e) const { return graph->head(e); }
|
marci@174
|
47 |
Node tail(const Edge& e) const { return graph->tail(e); }
|
marci@155
|
48 |
|
marci@155
|
49 |
template<typename I> bool valid(const I& i) const
|
marci@155
|
50 |
{ return graph->valid(i); }
|
marci@155
|
51 |
|
marci@155
|
52 |
//template<typename I> void setInvalid(const I &i);
|
marci@155
|
53 |
//{ return graph->setInvalid(i); }
|
marci@155
|
54 |
|
marci@155
|
55 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@155
|
56 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
57 |
|
marci@174
|
58 |
template<typename I> Node aNode(const I& e) const {
|
marci@76
|
59 |
return graph->aNode(e); }
|
marci@174
|
60 |
template<typename I> Node bNode(const I& e) const {
|
marci@76
|
61 |
return graph->bNode(e); }
|
marci@76
|
62 |
|
marci@174
|
63 |
Node addNode() const { return graph->addNode(); }
|
marci@174
|
64 |
Edge addEdge(const Node& tail, const Node& head) const {
|
marci@76
|
65 |
return graph->addEdge(tail, head); }
|
marci@76
|
66 |
|
marci@76
|
67 |
template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@76
|
68 |
|
marci@76
|
69 |
void clear() const { graph->clear(); }
|
marci@155
|
70 |
|
marci@76
|
71 |
template<typename T> class NodeMap : public Graph::NodeMap<T> {
|
marci@76
|
72 |
public:
|
marci@155
|
73 |
NodeMap(const TrivGraphWrapper<Graph>& _G) :
|
marci@158
|
74 |
Graph::NodeMap<T>(_G.getGraph()) { }
|
marci@155
|
75 |
NodeMap(const TrivGraphWrapper<Graph>& _G, T a) :
|
marci@158
|
76 |
Graph::NodeMap<T>(_G.getGraph(), a) { }
|
marci@76
|
77 |
};
|
marci@168
|
78 |
|
marci@155
|
79 |
template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
|
marci@155
|
80 |
public:
|
marci@155
|
81 |
EdgeMap(const TrivGraphWrapper<Graph>& _G) :
|
marci@158
|
82 |
Graph::EdgeMap<T>(_G.getGraph()) { }
|
marci@155
|
83 |
EdgeMap(const TrivGraphWrapper<Graph>& _G, T a) :
|
marci@158
|
84 |
Graph::EdgeMap<T>(_G.getGraph(), a) { }
|
marci@155
|
85 |
};
|
marci@76
|
86 |
};
|
marci@76
|
87 |
|
marci@212
|
88 |
template<typename GraphWrapper>
|
marci@212
|
89 |
class GraphWrapperSkeleton {
|
marci@212
|
90 |
protected:
|
marci@212
|
91 |
GraphWrapper gw;
|
marci@212
|
92 |
|
marci@212
|
93 |
public:
|
marci@263
|
94 |
//typedef typename GraphWrapper::BaseGraph BaseGraph;
|
marci@212
|
95 |
|
marci@212
|
96 |
typedef typename GraphWrapper::Node Node;
|
marci@212
|
97 |
typedef typename GraphWrapper::NodeIt NodeIt;
|
marci@212
|
98 |
|
marci@212
|
99 |
typedef typename GraphWrapper::Edge Edge;
|
marci@212
|
100 |
typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
|
marci@212
|
101 |
typedef typename GraphWrapper::InEdgeIt InEdgeIt;
|
marci@212
|
102 |
//typedef typename GraphWrapper::SymEdgeIt SymEdgeIt;
|
marci@212
|
103 |
typedef typename GraphWrapper::EdgeIt EdgeIt;
|
marci@212
|
104 |
|
marci@212
|
105 |
//GraphWrapperSkeleton() : gw() { }
|
marci@230
|
106 |
GraphWrapperSkeleton(GraphWrapper _gw) : gw(_gw) { }
|
marci@212
|
107 |
|
marci@263
|
108 |
//void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); }
|
marci@263
|
109 |
//BaseGraph& getGraph() const { return gw.getGraph(); }
|
marci@212
|
110 |
|
marci@212
|
111 |
template<typename I> I& first(I& i) const { return gw.first(i); }
|
marci@212
|
112 |
template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
113 |
return gw.first(i, p); }
|
marci@212
|
114 |
|
marci@212
|
115 |
template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
|
marci@212
|
116 |
template<typename I> I& next(I &i) const { return gw.next(i); }
|
marci@212
|
117 |
|
marci@212
|
118 |
template< typename It > It first() const {
|
marci@212
|
119 |
It e; this->first(e); return e; }
|
marci@212
|
120 |
|
marci@212
|
121 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
122 |
It e; this->first(e, v); return e; }
|
marci@212
|
123 |
|
marci@212
|
124 |
Node head(const Edge& e) const { return gw.head(e); }
|
marci@212
|
125 |
Node tail(const Edge& e) const { return gw.tail(e); }
|
marci@212
|
126 |
|
marci@212
|
127 |
template<typename I> bool valid(const I& i) const { return gw.valid(i); }
|
marci@212
|
128 |
|
marci@212
|
129 |
//template<typename I> void setInvalid(const I &i);
|
marci@212
|
130 |
//{ return graph->setInvalid(i); }
|
marci@212
|
131 |
|
marci@212
|
132 |
int nodeNum() const { return gw.nodeNum(); }
|
marci@212
|
133 |
int edgeNum() const { return gw.edgeNum(); }
|
marci@212
|
134 |
|
marci@212
|
135 |
template<typename I> Node aNode(const I& e) const { return gw.aNode(e); }
|
marci@212
|
136 |
template<typename I> Node bNode(const I& e) const { return gw.bNode(e); }
|
marci@212
|
137 |
|
marci@212
|
138 |
Node addNode() const { return gw.addNode(); }
|
marci@212
|
139 |
Edge addEdge(const Node& tail, const Node& head) const {
|
marci@212
|
140 |
return gw.addEdge(tail, head); }
|
marci@212
|
141 |
|
marci@212
|
142 |
template<typename I> void erase(const I& i) const { gw.erase(i); }
|
marci@212
|
143 |
|
marci@212
|
144 |
void clear() const { gw.clear(); }
|
marci@212
|
145 |
|
marci@212
|
146 |
template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
|
marci@212
|
147 |
public:
|
marci@212
|
148 |
NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
|
marci@212
|
149 |
GraphWrapper::NodeMap<T>(_G.gw) { }
|
marci@212
|
150 |
NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) :
|
marci@212
|
151 |
GraphWrapper::NodeMap<T>(_G.gw, a) { }
|
marci@212
|
152 |
};
|
marci@212
|
153 |
|
marci@212
|
154 |
template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> {
|
marci@212
|
155 |
public:
|
marci@212
|
156 |
EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
|
marci@212
|
157 |
GraphWrapper::EdgeMap<T>(_G.gw) { }
|
marci@212
|
158 |
EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) :
|
marci@212
|
159 |
GraphWrapper::EdgeMap<T>(_G.gw, a) { }
|
marci@212
|
160 |
};
|
marci@212
|
161 |
};
|
marci@212
|
162 |
|
marci@230
|
163 |
// template<typename Graph>
|
marci@230
|
164 |
// class RevGraphWrapper
|
marci@230
|
165 |
// {
|
marci@230
|
166 |
// protected:
|
marci@230
|
167 |
// Graph* graph;
|
marci@230
|
168 |
|
marci@230
|
169 |
// public:
|
marci@230
|
170 |
// typedef Graph BaseGraph;
|
marci@230
|
171 |
|
marci@230
|
172 |
// typedef typename Graph::Node Node;
|
marci@230
|
173 |
// typedef typename Graph::NodeIt NodeIt;
|
marci@230
|
174 |
|
marci@230
|
175 |
// typedef typename Graph::Edge Edge;
|
marci@230
|
176 |
// typedef typename Graph::OutEdgeIt InEdgeIt;
|
marci@230
|
177 |
// typedef typename Graph::InEdgeIt OutEdgeIt;
|
marci@230
|
178 |
// //typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@230
|
179 |
// typedef typename Graph::EdgeIt EdgeIt;
|
marci@230
|
180 |
|
marci@230
|
181 |
// //RevGraphWrapper() : graph(0) { }
|
marci@230
|
182 |
// RevGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@230
|
183 |
|
marci@230
|
184 |
// void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@230
|
185 |
// Graph& getGraph() const { return (*graph); }
|
marci@230
|
186 |
|
marci@230
|
187 |
// template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@230
|
188 |
// template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@230
|
189 |
// return graph->first(i, p); }
|
marci@230
|
190 |
|
marci@230
|
191 |
// template<typename I> I getNext(const I& i) const {
|
marci@230
|
192 |
// return graph->getNext(i); }
|
marci@230
|
193 |
// template<typename I> I& next(I &i) const { return graph->next(i); }
|
marci@230
|
194 |
|
marci@230
|
195 |
// template< typename It > It first() const {
|
marci@230
|
196 |
// It e; first(e); return e; }
|
marci@230
|
197 |
|
marci@230
|
198 |
// template< typename It > It first(const Node& v) const {
|
marci@230
|
199 |
// It e; first(e, v); return e; }
|
marci@230
|
200 |
|
marci@230
|
201 |
// Node head(const Edge& e) const { return graph->tail(e); }
|
marci@230
|
202 |
// Node tail(const Edge& e) const { return graph->head(e); }
|
marci@230
|
203 |
|
marci@230
|
204 |
// template<typename I> bool valid(const I& i) const
|
marci@230
|
205 |
// { return graph->valid(i); }
|
marci@230
|
206 |
|
marci@230
|
207 |
// //template<typename I> void setInvalid(const I &i);
|
marci@230
|
208 |
// //{ return graph->setInvalid(i); }
|
marci@230
|
209 |
|
marci@230
|
210 |
// template<typename I> Node aNode(const I& e) const {
|
marci@230
|
211 |
// return graph->aNode(e); }
|
marci@230
|
212 |
// template<typename I> Node bNode(const I& e) const {
|
marci@230
|
213 |
// return graph->bNode(e); }
|
marci@230
|
214 |
|
marci@230
|
215 |
// Node addNode() const { return graph->addNode(); }
|
marci@230
|
216 |
// Edge addEdge(const Node& tail, const Node& head) const {
|
marci@230
|
217 |
// return graph->addEdge(tail, head); }
|
marci@230
|
218 |
|
marci@230
|
219 |
// int nodeNum() const { return graph->nodeNum(); }
|
marci@230
|
220 |
// int edgeNum() const { return graph->edgeNum(); }
|
marci@230
|
221 |
|
marci@230
|
222 |
// template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@230
|
223 |
|
marci@230
|
224 |
// void clear() const { graph->clear(); }
|
marci@230
|
225 |
|
marci@230
|
226 |
// template<typename T> class NodeMap : public Graph::NodeMap<T> {
|
marci@230
|
227 |
// public:
|
marci@230
|
228 |
// NodeMap(const RevGraphWrapper<Graph>& _G) :
|
marci@230
|
229 |
// Graph::NodeMap<T>(_G.getGraph()) { }
|
marci@230
|
230 |
// NodeMap(const RevGraphWrapper<Graph>& _G, T a) :
|
marci@230
|
231 |
// Graph::NodeMap<T>(_G.getGraph(), a) { }
|
marci@230
|
232 |
// };
|
marci@230
|
233 |
|
marci@230
|
234 |
// template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
|
marci@230
|
235 |
// public:
|
marci@230
|
236 |
// EdgeMap(const RevGraphWrapper<Graph>& _G) :
|
marci@230
|
237 |
// Graph::EdgeMap<T>(_G.getGraph()) { }
|
marci@230
|
238 |
// EdgeMap(const RevGraphWrapper<Graph>& _G, T a) :
|
marci@230
|
239 |
// Graph::EdgeMap<T>(_G.getGraph(), a) { }
|
marci@230
|
240 |
// };
|
marci@230
|
241 |
// };
|
marci@230
|
242 |
|
marci@235
|
243 |
// template<typename /*Graph*/GraphWrapper
|
marci@235
|
244 |
// /*=typename GraphWrapperSkeleton< TrivGraphWrapper<Graph>*/ >
|
marci@235
|
245 |
// class RevGraphWrapper :
|
marci@235
|
246 |
// public GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/ {
|
marci@235
|
247 |
// protected:
|
marci@235
|
248 |
// //Graph* graph;
|
marci@230
|
249 |
|
marci@235
|
250 |
// public:
|
marci@235
|
251 |
// //typedef Graph BaseGraph;
|
marci@235
|
252 |
|
marci@235
|
253 |
// //typedef typename Graph::Node Node;
|
marci@235
|
254 |
// //typedef typename Graph::NodeIt NodeIt;
|
marci@235
|
255 |
|
marci@235
|
256 |
// //typedef typename Graph::Edge Edge;
|
marci@235
|
257 |
// typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/::OutEdgeIt InEdgeIt;
|
marci@235
|
258 |
// typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/::InEdgeIt OutEdgeIt;
|
marci@235
|
259 |
// //typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@235
|
260 |
// //typedef typename Graph::EdgeIt EdgeIt;
|
marci@235
|
261 |
|
marci@235
|
262 |
// //RevGraphWrapper() : graph(0) { }
|
marci@235
|
263 |
// RevGraphWrapper(GraphWrapper _gw/*BaseGraph& _graph*/) : GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/(_gw/*TrivGraphWrapper<Graph>(_graph)*/) { }
|
marci@235
|
264 |
|
marci@235
|
265 |
// //void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@235
|
266 |
// //Graph& getGraph() const { return (*graph); }
|
marci@235
|
267 |
|
marci@235
|
268 |
// //template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@235
|
269 |
// //template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@235
|
270 |
// // return graph->first(i, p); }
|
marci@235
|
271 |
|
marci@235
|
272 |
// //template<typename I> I getNext(const I& i) const {
|
marci@235
|
273 |
// // return graph->getNext(i); }
|
marci@235
|
274 |
// //template<typename I> I& next(I &i) const { return graph->next(i); }
|
marci@235
|
275 |
|
marci@235
|
276 |
// //template< typename It > It first() const {
|
marci@235
|
277 |
// // It e; first(e); return e; }
|
marci@235
|
278 |
|
marci@235
|
279 |
// //template< typename It > It first(const Node& v) const {
|
marci@235
|
280 |
// // It e; first(e, v); return e; }
|
marci@235
|
281 |
|
marci@235
|
282 |
// //Node head(const Edge& e) const { return graph->tail(e); }
|
marci@235
|
283 |
// //Node tail(const Edge& e) const { return graph->head(e); }
|
marci@235
|
284 |
|
marci@235
|
285 |
// //template<typename I> bool valid(const I& i) const
|
marci@235
|
286 |
// // { return graph->valid(i); }
|
marci@235
|
287 |
|
marci@235
|
288 |
// //template<typename I> void setInvalid(const I &i);
|
marci@235
|
289 |
// //{ return graph->setInvalid(i); }
|
marci@235
|
290 |
|
marci@235
|
291 |
// //template<typename I> Node aNode(const I& e) const {
|
marci@235
|
292 |
// // return graph->aNode(e); }
|
marci@235
|
293 |
// //template<typename I> Node bNode(const I& e) const {
|
marci@235
|
294 |
// // return graph->bNode(e); }
|
marci@235
|
295 |
|
marci@235
|
296 |
// //Node addNode() const { return graph->addNode(); }
|
marci@235
|
297 |
// //Edge addEdge(const Node& tail, const Node& head) const {
|
marci@235
|
298 |
// // return graph->addEdge(tail, head); }
|
marci@235
|
299 |
|
marci@235
|
300 |
// //int nodeNum() const { return graph->nodeNum(); }
|
marci@235
|
301 |
// //int edgeNum() const { return graph->edgeNum(); }
|
marci@235
|
302 |
|
marci@235
|
303 |
// //template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@235
|
304 |
|
marci@235
|
305 |
// //void clear() const { graph->clear(); }
|
marci@235
|
306 |
|
marci@235
|
307 |
// template<typename T> class NodeMap :
|
marci@235
|
308 |
// public GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>
|
marci@235
|
309 |
// {
|
marci@235
|
310 |
// public:
|
marci@235
|
311 |
// NodeMap(const RevGraphWrapper<GraphWrapper>& _gw) :
|
marci@235
|
312 |
// GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>(_gw) { }
|
marci@235
|
313 |
// NodeMap(const RevGraphWrapper<GraphWrapper>& _gw, T a) :
|
marci@235
|
314 |
// GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>(_gw, a) { }
|
marci@235
|
315 |
// };
|
marci@235
|
316 |
|
marci@235
|
317 |
// template<typename T> class EdgeMap :
|
marci@235
|
318 |
// public GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T> {
|
marci@235
|
319 |
// public:
|
marci@235
|
320 |
// EdgeMap(const RevGraphWrapper<GraphWrapper>& _gw) :
|
marci@235
|
321 |
// GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T>(_gw) { }
|
marci@235
|
322 |
// EdgeMap(const RevGraphWrapper<GraphWrapper>& _gw, T a) :
|
marci@235
|
323 |
// GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T>(_gw, a) { }
|
marci@235
|
324 |
// };
|
marci@235
|
325 |
// };
|
marci@235
|
326 |
|
marci@235
|
327 |
|
marci@235
|
328 |
template<typename GraphWrapper>
|
marci@235
|
329 |
class RevGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
|
marci@230
|
330 |
public:
|
marci@237
|
331 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
|
marci@237
|
332 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge Edge;
|
marci@235
|
333 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt InEdgeIt;
|
marci@235
|
334 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OutEdgeIt;
|
marci@237
|
335 |
|
marci@238
|
336 |
RevGraphWrapper(GraphWrapper _gw) :
|
marci@238
|
337 |
GraphWrapperSkeleton<GraphWrapper>(_gw) { }
|
marci@238
|
338 |
|
marci@237
|
339 |
Node head(const Edge& e) const
|
marci@237
|
340 |
{ return GraphWrapperSkeleton<GraphWrapper>::tail(e); }
|
marci@237
|
341 |
Node tail(const Edge& e) const
|
marci@237
|
342 |
{ return GraphWrapperSkeleton<GraphWrapper>::head(e); }
|
marci@76
|
343 |
};
|
marci@76
|
344 |
|
marci@263
|
345 |
//Subgraph on the same node-set and partial edge-set
|
marci@263
|
346 |
template<typename GraphWrapper, typename EdgeFilterMap>
|
marci@263
|
347 |
class SubGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
|
marci@263
|
348 |
protected:
|
marci@263
|
349 |
EdgeFilterMap* filter_map;
|
marci@263
|
350 |
public:
|
marci@263
|
351 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
|
marci@263
|
352 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
|
marci@263
|
353 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge Edge;
|
marci@263
|
354 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::EdgeIt EdgeIt;
|
marci@263
|
355 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt InEdgeIt;
|
marci@263
|
356 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt OutEdgeIt;
|
marci@263
|
357 |
|
marci@263
|
358 |
SubGraphWrapper(GraphWrapper _gw, EdgeFilterMap& _filter_map) :
|
marci@263
|
359 |
GraphWrapperSkeleton<GraphWrapper>(_gw), filter_map(&_filter_map) { }
|
marci@263
|
360 |
|
marci@263
|
361 |
template<typename I> I& first(I& i) const {
|
marci@263
|
362 |
gw.first(i);
|
marci@263
|
363 |
while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
|
marci@263
|
364 |
return i;
|
marci@263
|
365 |
}
|
marci@263
|
366 |
template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@263
|
367 |
gw.first(i, p);
|
marci@263
|
368 |
while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
|
marci@263
|
369 |
return i;
|
marci@263
|
370 |
}
|
marci@263
|
371 |
|
marci@263
|
372 |
//template<typename I> I getNext(const I& i) const {
|
marci@263
|
373 |
// return gw.getNext(i);
|
marci@263
|
374 |
//}
|
marci@263
|
375 |
template<typename I> I& next(I &i) const {
|
marci@263
|
376 |
gw.next(i);
|
marci@263
|
377 |
while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
|
marci@263
|
378 |
return i;
|
marci@263
|
379 |
}
|
marci@263
|
380 |
|
marci@263
|
381 |
template< typename It > It first() const {
|
marci@263
|
382 |
It e; this->first(e); return e; }
|
marci@263
|
383 |
|
marci@263
|
384 |
template< typename It > It first(const Node& v) const {
|
marci@263
|
385 |
It e; this->first(e, v); return e; }
|
marci@263
|
386 |
};
|
marci@155
|
387 |
|
marci@238
|
388 |
// template<typename GraphWrapper>
|
marci@236
|
389 |
// class UndirGraphWrapper {
|
marci@236
|
390 |
// protected:
|
marci@238
|
391 |
// //Graph* graph;
|
marci@238
|
392 |
// GraphWrapper gw;
|
marci@238
|
393 |
|
marci@236
|
394 |
// public:
|
marci@238
|
395 |
// typedef GraphWrapper BaseGraph;
|
marci@236
|
396 |
|
marci@238
|
397 |
// typedef typename GraphWrapper::Node Node;
|
marci@238
|
398 |
// typedef typename GraphWrapper::NodeIt NodeIt;
|
marci@236
|
399 |
|
marci@236
|
400 |
// //typedef typename Graph::Edge Edge;
|
marci@236
|
401 |
// //typedef typename Graph::OutEdgeIt OutEdgeIt;
|
marci@236
|
402 |
// //typedef typename Graph::InEdgeIt InEdgeIt;
|
marci@236
|
403 |
// //typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@236
|
404 |
// //typedef typename Graph::EdgeIt EdgeIt;
|
marci@236
|
405 |
|
marci@236
|
406 |
// //private:
|
marci@238
|
407 |
// typedef typename GraphWrapper::Edge GraphEdge;
|
marci@238
|
408 |
// typedef typename GraphWrapper::OutEdgeIt GraphOutEdgeIt;
|
marci@238
|
409 |
// typedef typename GraphWrapper::InEdgeIt GraphInEdgeIt;
|
marci@236
|
410 |
// //public:
|
marci@236
|
411 |
|
marci@236
|
412 |
// //UndirGraphWrapper() : graph(0) { }
|
marci@238
|
413 |
// UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
|
marci@236
|
414 |
|
marci@238
|
415 |
// //void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@238
|
416 |
// //Graph& getGraph() const { return (*graph); }
|
marci@236
|
417 |
|
marci@236
|
418 |
// class Edge {
|
marci@238
|
419 |
// friend class UndirGraphWrapper<GraphWrapper>;
|
marci@236
|
420 |
// bool out_or_in; //true iff out
|
marci@236
|
421 |
// GraphOutEdgeIt out;
|
marci@236
|
422 |
// GraphInEdgeIt in;
|
marci@236
|
423 |
// public:
|
marci@236
|
424 |
// Edge() : out_or_in(), out(), in() { }
|
marci@236
|
425 |
// Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
|
marci@236
|
426 |
// operator GraphEdge() const {
|
marci@236
|
427 |
// if (out_or_in) return(out); else return(in);
|
marci@236
|
428 |
// }
|
marci@236
|
429 |
// friend bool operator==(const Edge& u, const Edge& v) {
|
marci@236
|
430 |
// if (v.out_or_in)
|
marci@236
|
431 |
// return (u.out_or_in && u.out==v.out);
|
marci@236
|
432 |
// else
|
marci@236
|
433 |
// return (!u.out_or_in && u.in==v.in);
|
marci@236
|
434 |
// }
|
marci@236
|
435 |
// friend bool operator!=(const Edge& u, const Edge& v) {
|
marci@236
|
436 |
// if (v.out_or_in)
|
marci@236
|
437 |
// return (!u.out_or_in || u.out!=v.out);
|
marci@236
|
438 |
// else
|
marci@236
|
439 |
// return (u.out_or_in || u.in!=v.in);
|
marci@236
|
440 |
// }
|
marci@236
|
441 |
// };
|
marci@236
|
442 |
|
marci@236
|
443 |
// class OutEdgeIt : public Edge {
|
marci@238
|
444 |
// friend class UndirGraphWrapper<GraphWrapper>;
|
marci@236
|
445 |
// public:
|
marci@236
|
446 |
// OutEdgeIt() : Edge() { }
|
marci@236
|
447 |
// OutEdgeIt(const Invalid& i) : Edge(i) { }
|
marci@238
|
448 |
// OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n)
|
marci@238
|
449 |
// : Edge() {
|
marci@236
|
450 |
// out_or_in=true;
|
marci@238
|
451 |
// _G.gw.first(out, n);
|
marci@238
|
452 |
// if (!(_G.gw.valid(out))) {
|
marci@236
|
453 |
// out_or_in=false;
|
marci@238
|
454 |
// _G.gw.first(in, n);
|
marci@236
|
455 |
// }
|
marci@236
|
456 |
// }
|
marci@236
|
457 |
// };
|
marci@236
|
458 |
|
marci@236
|
459 |
// OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
|
marci@236
|
460 |
// e.out_or_in=true;
|
marci@238
|
461 |
// gw.first(e.out, n);
|
marci@238
|
462 |
// if (!(gw.valid(e.out))) {
|
marci@236
|
463 |
// e.out_or_in=false;
|
marci@238
|
464 |
// gw.first(e.in, n);
|
marci@236
|
465 |
// }
|
marci@236
|
466 |
// return e;
|
marci@236
|
467 |
// }
|
marci@236
|
468 |
|
marci@236
|
469 |
// OutEdgeIt& next(OutEdgeIt& e) const {
|
marci@236
|
470 |
// if (e.out_or_in) {
|
marci@238
|
471 |
// Node n=gw.tail(e.out);
|
marci@238
|
472 |
// gw.next(e.out);
|
marci@238
|
473 |
// if (!gw.valid(e.out)) {
|
marci@236
|
474 |
// e.out_or_in=false;
|
marci@238
|
475 |
// gw.first(e.in, n);
|
marci@236
|
476 |
// }
|
marci@236
|
477 |
// } else {
|
marci@238
|
478 |
// gw.next(e.in);
|
marci@236
|
479 |
// }
|
marci@236
|
480 |
// return e;
|
marci@236
|
481 |
// }
|
marci@236
|
482 |
|
marci@236
|
483 |
// Node aNode(const OutEdgeIt& e) const {
|
marci@238
|
484 |
// if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
|
marci@236
|
485 |
// Node bNode(const OutEdgeIt& e) const {
|
marci@238
|
486 |
// if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
|
marci@236
|
487 |
|
marci@236
|
488 |
// typedef OutEdgeIt InEdgeIt;
|
marci@236
|
489 |
|
marci@238
|
490 |
// template<typename I> I& first(I& i) const { return gw.first(i); }
|
marci@236
|
491 |
// // template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@236
|
492 |
// // return graph->first(i, p); }
|
marci@236
|
493 |
|
marci@236
|
494 |
// template<typename I> I getNext(const I& i) const {
|
marci@238
|
495 |
// return gw.getNext(i); }
|
marci@238
|
496 |
// template<typename I> I& next(I &i) const { return gw.next(i); }
|
marci@236
|
497 |
|
marci@236
|
498 |
// template< typename It > It first() const {
|
marci@236
|
499 |
// It e; first(e); return e; }
|
marci@236
|
500 |
|
marci@236
|
501 |
// template< typename It > It first(const Node& v) const {
|
marci@236
|
502 |
// It e; first(e, v); return e; }
|
marci@236
|
503 |
|
marci@238
|
504 |
// Node head(const Edge& e) const { return gw.head(e); }
|
marci@238
|
505 |
// Node tail(const Edge& e) const { return gw.tail(e); }
|
marci@236
|
506 |
|
marci@236
|
507 |
// template<typename I> bool valid(const I& i) const
|
marci@238
|
508 |
// { return gw.valid(i); }
|
marci@236
|
509 |
|
marci@236
|
510 |
// //template<typename I> void setInvalid(const I &i);
|
marci@236
|
511 |
// //{ return graph->setInvalid(i); }
|
marci@236
|
512 |
|
marci@238
|
513 |
// int nodeNum() const { return gw.nodeNum(); }
|
marci@238
|
514 |
// int edgeNum() const { return gw.edgeNum(); }
|
marci@236
|
515 |
|
marci@236
|
516 |
// // template<typename I> Node aNode(const I& e) const {
|
marci@236
|
517 |
// // return graph->aNode(e); }
|
marci@236
|
518 |
// // template<typename I> Node bNode(const I& e) const {
|
marci@236
|
519 |
// // return graph->bNode(e); }
|
marci@236
|
520 |
|
marci@238
|
521 |
// Node addNode() const { return gw.addNode(); }
|
marci@236
|
522 |
// // FIXME: ez igy nem jo, mert nem
|
marci@236
|
523 |
// // Edge addEdge(const Node& tail, const Node& head) const {
|
marci@236
|
524 |
// // return graph->addEdge(tail, head); }
|
marci@236
|
525 |
|
marci@238
|
526 |
// template<typename I> void erase(const I& i) const { gw.erase(i); }
|
marci@236
|
527 |
|
marci@238
|
528 |
// void clear() const { gw.clear(); }
|
marci@236
|
529 |
|
marci@238
|
530 |
// template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
|
marci@236
|
531 |
// public:
|
marci@238
|
532 |
// NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
|
marci@238
|
533 |
// GraphWrapper::NodeMap<T>(_G.gw) { }
|
marci@238
|
534 |
// NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
|
marci@238
|
535 |
// GraphWrapper::NodeMap<T>(_G.gw, a) { }
|
marci@236
|
536 |
// };
|
marci@236
|
537 |
|
marci@238
|
538 |
// template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> {
|
marci@236
|
539 |
// public:
|
marci@238
|
540 |
// EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
|
marci@238
|
541 |
// GraphWrapper::EdgeMap<T>(_G.gw) { }
|
marci@238
|
542 |
// EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
|
marci@238
|
543 |
// GraphWrapper::EdgeMap<T>(_G.gw, a) { }
|
marci@236
|
544 |
// };
|
marci@236
|
545 |
// };
|
marci@236
|
546 |
|
marci@236
|
547 |
|
marci@236
|
548 |
template<typename GraphWrapper>
|
marci@238
|
549 |
class UndirGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
|
marci@199
|
550 |
protected:
|
marci@238
|
551 |
// GraphWrapper gw;
|
marci@236
|
552 |
|
marci@158
|
553 |
public:
|
marci@238
|
554 |
//typedef GraphWrapper BaseGraph;
|
marci@158
|
555 |
|
marci@238
|
556 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
|
marci@238
|
557 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
|
marci@158
|
558 |
|
marci@158
|
559 |
//private:
|
marci@238
|
560 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge GraphEdge;
|
marci@238
|
561 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt GraphOutEdgeIt;
|
marci@238
|
562 |
typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt GraphInEdgeIt;
|
marci@158
|
563 |
//public:
|
marci@158
|
564 |
|
marci@168
|
565 |
//UndirGraphWrapper() : graph(0) { }
|
marci@238
|
566 |
UndirGraphWrapper(GraphWrapper _gw) :
|
marci@238
|
567 |
GraphWrapperSkeleton<GraphWrapper>(_gw) { }
|
marci@238
|
568 |
|
marci@238
|
569 |
//UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
|
marci@168
|
570 |
|
marci@236
|
571 |
//void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@236
|
572 |
//Graph& getGraph() const { return (*graph); }
|
marci@168
|
573 |
|
marci@174
|
574 |
class Edge {
|
marci@236
|
575 |
friend class UndirGraphWrapper<GraphWrapper>;
|
marci@158
|
576 |
bool out_or_in; //true iff out
|
marci@158
|
577 |
GraphOutEdgeIt out;
|
marci@158
|
578 |
GraphInEdgeIt in;
|
marci@158
|
579 |
public:
|
marci@174
|
580 |
Edge() : out_or_in(), out(), in() { }
|
marci@174
|
581 |
Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
|
marci@174
|
582 |
operator GraphEdge() const {
|
marci@158
|
583 |
if (out_or_in) return(out); else return(in);
|
marci@158
|
584 |
}
|
marci@239
|
585 |
//FIXME
|
marci@239
|
586 |
//2 edges are equal if they "refer" to the same physical edge
|
marci@239
|
587 |
//is it good?
|
marci@174
|
588 |
friend bool operator==(const Edge& u, const Edge& v) {
|
marci@174
|
589 |
if (v.out_or_in)
|
marci@239
|
590 |
if (u.out_or_in) return (u.out==v.out); else return (u.out==v.in);
|
marci@239
|
591 |
//return (u.out_or_in && u.out==v.out);
|
marci@174
|
592 |
else
|
marci@239
|
593 |
if (u.out_or_in) return (u.out==v.in); else return (u.in==v.in);
|
marci@239
|
594 |
//return (!u.out_or_in && u.in==v.in);
|
marci@174
|
595 |
}
|
marci@174
|
596 |
friend bool operator!=(const Edge& u, const Edge& v) {
|
marci@174
|
597 |
if (v.out_or_in)
|
marci@239
|
598 |
if (u.out_or_in) return (u.out!=v.out); else return (u.out!=v.in);
|
marci@239
|
599 |
//return (!u.out_or_in || u.out!=v.out);
|
marci@174
|
600 |
else
|
marci@239
|
601 |
if (u.out_or_in) return (u.out!=v.in); else return (u.in!=v.in);
|
marci@239
|
602 |
//return (u.out_or_in || u.in!=v.in);
|
marci@174
|
603 |
}
|
marci@158
|
604 |
};
|
marci@158
|
605 |
|
marci@174
|
606 |
class OutEdgeIt : public Edge {
|
marci@236
|
607 |
friend class UndirGraphWrapper<GraphWrapper>;
|
marci@158
|
608 |
public:
|
marci@174
|
609 |
OutEdgeIt() : Edge() { }
|
marci@174
|
610 |
OutEdgeIt(const Invalid& i) : Edge(i) { }
|
marci@236
|
611 |
OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n)
|
marci@236
|
612 |
: Edge() {
|
marci@239
|
613 |
out_or_in=true; _G.gw.first(out, n);
|
marci@239
|
614 |
if (!(_G.gw.valid(out))) { out_or_in=false; _G.gw.first(in, n); }
|
marci@158
|
615 |
}
|
marci@158
|
616 |
};
|
marci@158
|
617 |
|
marci@238
|
618 |
typedef OutEdgeIt InEdgeIt;
|
marci@238
|
619 |
|
marci@238
|
620 |
class EdgeIt : public Edge {
|
marci@238
|
621 |
friend class UndirGraphWrapper<GraphWrapper>;
|
marci@238
|
622 |
protected:
|
marci@238
|
623 |
NodeIt v;
|
marci@238
|
624 |
public:
|
marci@238
|
625 |
EdgeIt() : Edge() { }
|
marci@238
|
626 |
EdgeIt(const Invalid& i) : Edge(i) { }
|
marci@238
|
627 |
EdgeIt(const UndirGraphWrapper<GraphWrapper>& _G)
|
marci@238
|
628 |
: Edge() {
|
marci@238
|
629 |
out_or_in=true;
|
marci@238
|
630 |
//Node v;
|
marci@238
|
631 |
_G.first(v);
|
marci@238
|
632 |
if (_G.valid(v)) _G.gw.first(out); else out=INVALID;
|
marci@238
|
633 |
while (_G.valid(v) && !_G.gw.valid(out)) {
|
marci@238
|
634 |
_G.gw.next(v);
|
marci@238
|
635 |
if (_G.valid(v)) _G.gw.first(out);
|
marci@238
|
636 |
}
|
marci@238
|
637 |
}
|
marci@238
|
638 |
};
|
marci@238
|
639 |
|
marci@212
|
640 |
OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
|
marci@239
|
641 |
e.out_or_in=true; gw.first(e.out, n);
|
marci@239
|
642 |
if (!(gw.valid(e.out))) { e.out_or_in=false; gw.first(e.in, n); }
|
marci@158
|
643 |
return e;
|
marci@158
|
644 |
}
|
marci@158
|
645 |
|
marci@238
|
646 |
EdgeIt& first(EdgeIt& e) const {
|
marci@238
|
647 |
e.out_or_in=true;
|
marci@238
|
648 |
//NodeIt v;
|
marci@238
|
649 |
first(e.v);
|
marci@238
|
650 |
if (valid(e.v)) gw.first(e.out, e.v); else e.out=INVALID;
|
marci@238
|
651 |
while (valid(e.v) && !gw.valid(e.out)) {
|
marci@238
|
652 |
gw.next(e.v);
|
marci@238
|
653 |
if (valid(e.v)) gw.first(e.out, e.v);
|
marci@238
|
654 |
}
|
marci@238
|
655 |
return e;
|
marci@238
|
656 |
}
|
marci@238
|
657 |
|
marci@238
|
658 |
template<typename I> I& first(I& i) const { return gw.first(i); }
|
marci@238
|
659 |
template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@238
|
660 |
return graph->first(i, p); }
|
marci@238
|
661 |
|
marci@158
|
662 |
OutEdgeIt& next(OutEdgeIt& e) const {
|
marci@158
|
663 |
if (e.out_or_in) {
|
marci@236
|
664 |
Node n=gw.tail(e.out);
|
marci@236
|
665 |
gw.next(e.out);
|
marci@239
|
666 |
if (!gw.valid(e.out)) { e.out_or_in=false; gw.first(e.in, n); }
|
marci@158
|
667 |
} else {
|
marci@236
|
668 |
gw.next(e.in);
|
marci@158
|
669 |
}
|
marci@158
|
670 |
return e;
|
marci@158
|
671 |
}
|
marci@158
|
672 |
|
marci@238
|
673 |
EdgeIt& next(EdgeIt& e) const {
|
marci@238
|
674 |
//NodeIt v=tail(e);
|
marci@238
|
675 |
gw.next(e.out);
|
marci@238
|
676 |
while (valid(e.v) && !gw.valid(e.out)) {
|
marci@238
|
677 |
next(e.v);
|
marci@238
|
678 |
if (valid(e.v)) gw.first(e.out, e.v);
|
marci@238
|
679 |
}
|
marci@238
|
680 |
return e;
|
marci@238
|
681 |
}
|
marci@158
|
682 |
|
marci@238
|
683 |
template<typename I> I& next(I &i) const { return gw.next(i); }
|
marci@239
|
684 |
template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
|
marci@158
|
685 |
|
marci@158
|
686 |
template< typename It > It first() const {
|
marci@212
|
687 |
It e; first(e); return e; }
|
marci@158
|
688 |
|
marci@174
|
689 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
690 |
It e; first(e, v); return e; }
|
marci@158
|
691 |
|
marci@238
|
692 |
// Node head(const Edge& e) const { return gw.head(e); }
|
marci@238
|
693 |
// Node tail(const Edge& e) const { return gw.tail(e); }
|
marci@158
|
694 |
|
marci@238
|
695 |
// template<typename I> bool valid(const I& i) const
|
marci@238
|
696 |
// { return gw.valid(i); }
|
marci@158
|
697 |
|
marci@238
|
698 |
// int nodeNum() const { return gw.nodeNum(); }
|
marci@238
|
699 |
// int edgeNum() const { return gw.edgeNum(); }
|
marci@158
|
700 |
|
marci@174
|
701 |
// template<typename I> Node aNode(const I& e) const {
|
marci@158
|
702 |
// return graph->aNode(e); }
|
marci@174
|
703 |
// template<typename I> Node bNode(const I& e) const {
|
marci@158
|
704 |
// return graph->bNode(e); }
|
marci@238
|
705 |
|
marci@238
|
706 |
Node aNode(const OutEdgeIt& e) const {
|
marci@238
|
707 |
if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
|
marci@238
|
708 |
Node bNode(const OutEdgeIt& e) const {
|
marci@238
|
709 |
if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
|
marci@158
|
710 |
|
marci@238
|
711 |
// Node addNode() const { return gw.addNode(); }
|
marci@238
|
712 |
|
marci@231
|
713 |
// FIXME: ez igy nem jo, mert nem
|
marci@231
|
714 |
// Edge addEdge(const Node& tail, const Node& head) const {
|
marci@231
|
715 |
// return graph->addEdge(tail, head); }
|
marci@158
|
716 |
|
marci@238
|
717 |
// template<typename I> void erase(const I& i) const { gw.erase(i); }
|
marci@158
|
718 |
|
marci@238
|
719 |
// void clear() const { gw.clear(); }
|
marci@158
|
720 |
|
marci@238
|
721 |
// template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
|
marci@238
|
722 |
// public:
|
marci@238
|
723 |
// NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
|
marci@238
|
724 |
// GraphWrapper::NodeMap<T>(_G.gw) { }
|
marci@238
|
725 |
// NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
|
marci@238
|
726 |
// GraphWrapper::NodeMap<T>(_G.gw, a) { }
|
marci@238
|
727 |
// };
|
marci@168
|
728 |
|
marci@238
|
729 |
// template<typename T> class EdgeMap :
|
marci@238
|
730 |
// public GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T> {
|
marci@238
|
731 |
// public:
|
marci@238
|
732 |
// EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
|
marci@238
|
733 |
// GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T>(_G.gw) { }
|
marci@238
|
734 |
// EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
|
marci@238
|
735 |
// GraphWrapper::EdgeMap<T>(_G.gw, a) { }
|
marci@238
|
736 |
// };
|
marci@238
|
737 |
};
|
marci@158
|
738 |
|
marci@158
|
739 |
|
marci@158
|
740 |
|
marci@236
|
741 |
|
marci@236
|
742 |
|
marci@155
|
743 |
// template<typename Graph>
|
marci@155
|
744 |
// class SymGraphWrapper
|
marci@155
|
745 |
// {
|
marci@155
|
746 |
// Graph* graph;
|
marci@76
|
747 |
|
marci@155
|
748 |
// public:
|
marci@155
|
749 |
// typedef Graph BaseGraph;
|
marci@155
|
750 |
|
marci@174
|
751 |
// typedef typename Graph::Node Node;
|
marci@174
|
752 |
// typedef typename Graph::Edge Edge;
|
marci@174
|
753 |
|
marci@155
|
754 |
// typedef typename Graph::NodeIt NodeIt;
|
marci@155
|
755 |
|
marci@155
|
756 |
// //FIXME tag-ekkel megcsinalni, hogy abbol csinaljon
|
marci@155
|
757 |
// //iranyitatlant, ami van
|
marci@155
|
758 |
// //mert csak 1 dolgot lehet be typedef-elni
|
marci@155
|
759 |
// typedef typename Graph::OutEdgeIt SymEdgeIt;
|
marci@155
|
760 |
// //typedef typename Graph::InEdgeIt SymEdgeIt;
|
marci@155
|
761 |
// //typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
762 |
// typedef typename Graph::EdgeIt EdgeIt;
|
marci@155
|
763 |
|
marci@155
|
764 |
// int nodeNum() const { return graph->nodeNum(); }
|
marci@155
|
765 |
// int edgeNum() const { return graph->edgeNum(); }
|
marci@155
|
766 |
|
marci@212
|
767 |
// template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@212
|
768 |
// template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
769 |
// return graph->first(i, p); }
|
marci@155
|
770 |
// //template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@155
|
771 |
// //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@155
|
772 |
|
marci@155
|
773 |
// template< typename It > It first() const {
|
marci@212
|
774 |
// It e; first(e); return e; }
|
marci@155
|
775 |
|
marci@174
|
776 |
// template< typename It > It first(Node v) const {
|
marci@212
|
777 |
// It e; first(e, v); return e; }
|
marci@155
|
778 |
|
marci@174
|
779 |
// Node head(const Edge& e) const { return graph->head(e); }
|
marci@174
|
780 |
// Node tail(const Edge& e) const { return graph->tail(e); }
|
marci@155
|
781 |
|
marci@174
|
782 |
// template<typename I> Node aNode(const I& e) const {
|
marci@155
|
783 |
// return graph->aNode(e); }
|
marci@174
|
784 |
// template<typename I> Node bNode(const I& e) const {
|
marci@155
|
785 |
// return graph->bNode(e); }
|
marci@155
|
786 |
|
marci@155
|
787 |
// //template<typename I> bool valid(const I i);
|
marci@155
|
788 |
// //{ return graph->valid(i); }
|
marci@155
|
789 |
|
marci@155
|
790 |
// //template<typename I> void setInvalid(const I &i);
|
marci@155
|
791 |
// //{ return graph->setInvalid(i); }
|
marci@155
|
792 |
|
marci@174
|
793 |
// Node addNode() { return graph->addNode(); }
|
marci@174
|
794 |
// Edge addEdge(const Node& tail, const Node& head) {
|
marci@155
|
795 |
// return graph->addEdge(tail, head); }
|
marci@155
|
796 |
|
marci@155
|
797 |
// template<typename I> void erase(const I& i) { graph->erase(i); }
|
marci@155
|
798 |
|
marci@155
|
799 |
// void clear() { graph->clear(); }
|
marci@155
|
800 |
|
marci@155
|
801 |
// template<typename T> class NodeMap : public Graph::NodeMap<T> { };
|
marci@155
|
802 |
// template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
|
marci@155
|
803 |
|
marci@155
|
804 |
// void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@155
|
805 |
// Graph& getGraph() { return (*graph); }
|
marci@155
|
806 |
|
marci@155
|
807 |
// //SymGraphWrapper() : graph(0) { }
|
marci@155
|
808 |
// SymGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@155
|
809 |
// };
|
marci@155
|
810 |
|
marci@155
|
811 |
|
marci@155
|
812 |
template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
|
marci@155
|
813 |
class ResGraphWrapper {
|
marci@76
|
814 |
public:
|
marci@259
|
815 |
//typedef Graph BaseGraph;
|
marci@174
|
816 |
typedef typename Graph::Node Node;
|
marci@155
|
817 |
typedef typename Graph::NodeIt NodeIt;
|
marci@155
|
818 |
private:
|
marci@155
|
819 |
typedef typename Graph::OutEdgeIt OldOutEdgeIt;
|
marci@155
|
820 |
typedef typename Graph::InEdgeIt OldInEdgeIt;
|
marci@199
|
821 |
protected:
|
marci@259
|
822 |
//const Graph* graph;
|
marci@259
|
823 |
typedef TrivGraphWrapper<const Graph> GraphWrapper;
|
marci@259
|
824 |
GraphWrapper gw;
|
marci@155
|
825 |
FlowMap* flow;
|
marci@155
|
826 |
const CapacityMap* capacity;
|
marci@155
|
827 |
public:
|
marci@168
|
828 |
|
marci@155
|
829 |
ResGraphWrapper(const Graph& _G, FlowMap& _flow,
|
marci@155
|
830 |
const CapacityMap& _capacity) :
|
marci@259
|
831 |
gw(_G), flow(&_flow), capacity(&_capacity) { }
|
marci@168
|
832 |
|
marci@259
|
833 |
//void setGraph(const Graph& _graph) { graph = &_graph; }
|
marci@259
|
834 |
//const Graph& getGraph() const { return (*graph); }
|
marci@168
|
835 |
|
marci@174
|
836 |
class Edge;
|
marci@155
|
837 |
class OutEdgeIt;
|
marci@174
|
838 |
friend class Edge;
|
marci@155
|
839 |
friend class OutEdgeIt;
|
marci@76
|
840 |
|
marci@174
|
841 |
class Edge {
|
marci@155
|
842 |
friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
|
marci@155
|
843 |
protected:
|
marci@168
|
844 |
bool out_or_in; //true, iff out
|
marci@155
|
845 |
OldOutEdgeIt out;
|
marci@155
|
846 |
OldInEdgeIt in;
|
marci@155
|
847 |
public:
|
marci@174
|
848 |
Edge() : out_or_in(true) { }
|
marci@174
|
849 |
Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
|
marci@168
|
850 |
// bool valid() const {
|
marci@168
|
851 |
// return out_or_in && out.valid() || in.valid(); }
|
marci@174
|
852 |
friend bool operator==(const Edge& u, const Edge& v) {
|
marci@174
|
853 |
if (v.out_or_in)
|
marci@174
|
854 |
return (u.out_or_in && u.out==v.out);
|
marci@174
|
855 |
else
|
marci@174
|
856 |
return (!u.out_or_in && u.in==v.in);
|
marci@174
|
857 |
}
|
marci@174
|
858 |
friend bool operator!=(const Edge& u, const Edge& v) {
|
marci@174
|
859 |
if (v.out_or_in)
|
marci@174
|
860 |
return (!u.out_or_in || u.out!=v.out);
|
marci@174
|
861 |
else
|
marci@174
|
862 |
return (u.out_or_in || u.in!=v.in);
|
marci@174
|
863 |
}
|
marci@155
|
864 |
};
|
marci@155
|
865 |
|
marci@155
|
866 |
|
marci@174
|
867 |
class OutEdgeIt : public Edge {
|
marci@155
|
868 |
friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
|
marci@155
|
869 |
public:
|
marci@155
|
870 |
OutEdgeIt() { }
|
marci@168
|
871 |
//FIXME
|
marci@174
|
872 |
OutEdgeIt(const Edge& e) : Edge(e) { }
|
marci@174
|
873 |
OutEdgeIt(const Invalid& i) : Edge(i) { }
|
marci@155
|
874 |
private:
|
marci@174
|
875 |
OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
|
marci@259
|
876 |
resG.gw.first(out, v);
|
marci@259
|
877 |
while( resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
|
marci@259
|
878 |
if (!resG.gw.valid(out)) {
|
marci@155
|
879 |
out_or_in=0;
|
marci@259
|
880 |
resG.gw.first(in, v);
|
marci@259
|
881 |
while( resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); }
|
marci@155
|
882 |
}
|
marci@155
|
883 |
}
|
marci@168
|
884 |
// public:
|
marci@168
|
885 |
// OutEdgeIt& operator++() {
|
marci@168
|
886 |
// if (out_or_in) {
|
marci@174
|
887 |
// Node v=/*resG->*/G->aNode(out);
|
marci@168
|
888 |
// ++out;
|
marci@174
|
889 |
// while( out.valid() && !(Edge::free()>0) ) { ++out; }
|
marci@168
|
890 |
// if (!out.valid()) {
|
marci@168
|
891 |
// out_or_in=0;
|
marci@212
|
892 |
// G->first(in, v);
|
marci@174
|
893 |
// while( in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
894 |
// }
|
marci@168
|
895 |
// } else {
|
marci@168
|
896 |
// ++in;
|
marci@174
|
897 |
// while( in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
898 |
// }
|
marci@168
|
899 |
// return *this;
|
marci@168
|
900 |
// }
|
marci@155
|
901 |
};
|
marci@155
|
902 |
|
marci@263
|
903 |
//FIXME This is just for having InEdgeIt
|
marci@263
|
904 |
typedef void InEdgeIt;
|
marci@263
|
905 |
|
marci@174
|
906 |
class EdgeIt : public Edge {
|
marci@155
|
907 |
friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
|
marci@174
|
908 |
typename Graph::NodeIt v;
|
marci@155
|
909 |
public:
|
marci@174
|
910 |
EdgeIt() { }
|
marci@174
|
911 |
//EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
|
marci@174
|
912 |
EdgeIt(const Invalid& i) : Edge(i) { }
|
marci@174
|
913 |
EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() {
|
marci@259
|
914 |
resG.gw.first(v);
|
marci@259
|
915 |
if (resG.gw.valid(v)) resG.gw.first(out, v); else out=/*OldOutEdgeIt*/(INVALID);
|
marci@259
|
916 |
while (resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
|
marci@259
|
917 |
while (resG.gw.valid(v) && !resG.gw.valid(out)) {
|
marci@259
|
918 |
resG.gw.next(v);
|
marci@259
|
919 |
if (resG.gw.valid(v)) resG.gw.first(out, v);
|
marci@259
|
920 |
while (resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
|
marci@155
|
921 |
}
|
marci@259
|
922 |
if (!resG.gw.valid(out)) {
|
marci@155
|
923 |
out_or_in=0;
|
marci@259
|
924 |
resG.gw.first(v);
|
marci@259
|
925 |
if (resG.gw.valid(v)) resG.gw.first(in, v); else in=/*OldInEdgeIt*/(INVALID);
|
marci@259
|
926 |
while (resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); }
|
marci@259
|
927 |
while (resG.gw.valid(v) && !resG.gw.valid(in)) {
|
marci@259
|
928 |
resG.gw.next(v);
|
marci@259
|
929 |
if (resG.gw.valid(v)) resG.gw.first(in, v);
|
marci@259
|
930 |
while (resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); }
|
marci@155
|
931 |
}
|
marci@155
|
932 |
}
|
marci@155
|
933 |
}
|
marci@174
|
934 |
// EdgeIt& operator++() {
|
marci@168
|
935 |
// if (out_or_in) {
|
marci@168
|
936 |
// ++out;
|
marci@174
|
937 |
// while (out.valid() && !(Edge::free()>0) ) { ++out; }
|
marci@168
|
938 |
// while (v.valid() && !out.valid()) {
|
marci@168
|
939 |
// ++v;
|
marci@212
|
940 |
// if (v.valid()) G->first(out, v);
|
marci@174
|
941 |
// while (out.valid() && !(Edge::free()>0) ) { ++out; }
|
marci@168
|
942 |
// }
|
marci@168
|
943 |
// if (!out.valid()) {
|
marci@168
|
944 |
// out_or_in=0;
|
marci@212
|
945 |
// G->first(v);
|
marci@212
|
946 |
// if (v.valid()) G->first(in, v); else in=OldInEdgeIt();
|
marci@174
|
947 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
948 |
// while (v.valid() && !in.valid()) {
|
marci@168
|
949 |
// ++v;
|
marci@212
|
950 |
// if (v.valid()) G->first(in, v);
|
marci@174
|
951 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
952 |
// }
|
marci@168
|
953 |
// }
|
marci@168
|
954 |
// } else {
|
marci@168
|
955 |
// ++in;
|
marci@174
|
956 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
957 |
// while (v.valid() && !in.valid()) {
|
marci@168
|
958 |
// ++v;
|
marci@212
|
959 |
// if (v.valid()) G->first(in, v);
|
marci@174
|
960 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
961 |
// }
|
marci@168
|
962 |
// }
|
marci@168
|
963 |
// return *this;
|
marci@168
|
964 |
// }
|
marci@155
|
965 |
};
|
marci@155
|
966 |
|
marci@259
|
967 |
NodeIt& first(NodeIt& v) const { return gw.first(v); }
|
marci@212
|
968 |
OutEdgeIt& first(OutEdgeIt& e, Node v) const {
|
marci@168
|
969 |
e=OutEdgeIt(*this, v);
|
marci@174
|
970 |
return e;
|
marci@155
|
971 |
}
|
marci@212
|
972 |
EdgeIt& first(EdgeIt& e) const {
|
marci@174
|
973 |
e=EdgeIt(*this);
|
marci@174
|
974 |
return e;
|
marci@155
|
975 |
}
|
marci@155
|
976 |
|
marci@259
|
977 |
NodeIt& next(NodeIt& n) const { return gw.next(n); }
|
marci@155
|
978 |
|
marci@155
|
979 |
OutEdgeIt& next(OutEdgeIt& e) const {
|
marci@155
|
980 |
if (e.out_or_in) {
|
marci@259
|
981 |
Node v=gw.aNode(e.out);
|
marci@259
|
982 |
gw.next(e.out);
|
marci@259
|
983 |
while( gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); }
|
marci@259
|
984 |
if (!gw.valid(e.out)) {
|
marci@155
|
985 |
e.out_or_in=0;
|
marci@259
|
986 |
gw.first(e.in, v);
|
marci@259
|
987 |
while( gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
|
marci@155
|
988 |
}
|
marci@155
|
989 |
} else {
|
marci@259
|
990 |
gw.next(e.in);
|
marci@259
|
991 |
while( gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
|
marci@155
|
992 |
}
|
marci@155
|
993 |
return e;
|
marci@155
|
994 |
}
|
marci@155
|
995 |
|
marci@174
|
996 |
EdgeIt& next(EdgeIt& e) const {
|
marci@155
|
997 |
if (e.out_or_in) {
|
marci@259
|
998 |
gw.next(e.out);
|
marci@259
|
999 |
while (gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); }
|
marci@259
|
1000 |
while (gw.valid(e.v) && !gw.valid(e.out)) {
|
marci@259
|
1001 |
gw.next(e.v);
|
marci@259
|
1002 |
if (gw.valid(e.v)) gw.first(e.out, e.v);
|
marci@259
|
1003 |
while (gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); }
|
marci@155
|
1004 |
}
|
marci@259
|
1005 |
if (!gw.valid(e.out)) {
|
marci@155
|
1006 |
e.out_or_in=0;
|
marci@259
|
1007 |
gw.first(e.v);
|
marci@259
|
1008 |
if (gw.valid(e.v)) gw.first(e.in, e.v); else e.in=/*OldInEdgeIt*/(INVALID);
|
marci@259
|
1009 |
while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
|
marci@259
|
1010 |
while (gw.valid(e.v) && !gw.valid(e.in)) {
|
marci@259
|
1011 |
gw.next(e.v);
|
marci@259
|
1012 |
if (gw.valid(e.v)) gw.first(e.in, e.v);
|
marci@259
|
1013 |
while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
|
marci@155
|
1014 |
}
|
marci@155
|
1015 |
}
|
marci@155
|
1016 |
} else {
|
marci@259
|
1017 |
gw.next(e.in);
|
marci@259
|
1018 |
while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
|
marci@259
|
1019 |
while (gw.valid(e.v) && !gw.valid(e.in)) {
|
marci@259
|
1020 |
gw.next(e.v);
|
marci@259
|
1021 |
if (gw.valid(e.v)) gw.first(e.in, e.v);
|
marci@259
|
1022 |
while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
|
marci@155
|
1023 |
}
|
marci@155
|
1024 |
}
|
marci@155
|
1025 |
return e;
|
marci@155
|
1026 |
}
|
marci@76
|
1027 |
|
marci@76
|
1028 |
|
marci@155
|
1029 |
template< typename It >
|
marci@155
|
1030 |
It first() const {
|
marci@155
|
1031 |
It e;
|
marci@212
|
1032 |
first(e);
|
marci@155
|
1033 |
return e;
|
marci@155
|
1034 |
}
|
marci@76
|
1035 |
|
marci@155
|
1036 |
template< typename It >
|
marci@174
|
1037 |
It first(Node v) const {
|
marci@155
|
1038 |
It e;
|
marci@212
|
1039 |
first(e, v);
|
marci@155
|
1040 |
return e;
|
marci@155
|
1041 |
}
|
marci@76
|
1042 |
|
marci@174
|
1043 |
Node tail(Edge e) const {
|
marci@259
|
1044 |
return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); }
|
marci@174
|
1045 |
Node head(Edge e) const {
|
marci@259
|
1046 |
return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
|
marci@76
|
1047 |
|
marci@174
|
1048 |
Node aNode(OutEdgeIt e) const {
|
marci@259
|
1049 |
return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); }
|
marci@174
|
1050 |
Node bNode(OutEdgeIt e) const {
|
marci@259
|
1051 |
return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
|
marci@76
|
1052 |
|
marci@263
|
1053 |
int nodeNum() const { return gw.nodeNum(); }
|
marci@263
|
1054 |
//FIXME
|
marci@263
|
1055 |
//int edgeNum() const { return gw.edgeNum(); }
|
marci@263
|
1056 |
|
marci@263
|
1057 |
|
marci@259
|
1058 |
int id(Node v) const { return gw.id(v); }
|
marci@155
|
1059 |
|
marci@259
|
1060 |
bool valid(Node n) const { return gw.valid(n); }
|
marci@174
|
1061 |
bool valid(Edge e) const {
|
marci@259
|
1062 |
return e.out_or_in ? gw.valid(e.out) : gw.valid(e.in); }
|
marci@155
|
1063 |
|
marci@174
|
1064 |
void augment(const Edge& e, Number a) const {
|
marci@168
|
1065 |
if (e.out_or_in)
|
marci@168
|
1066 |
flow->set(e.out, flow->get(e.out)+a);
|
marci@168
|
1067 |
else
|
marci@168
|
1068 |
flow->set(e.in, flow->get(e.in)-a);
|
marci@168
|
1069 |
}
|
marci@168
|
1070 |
|
marci@174
|
1071 |
Number free(const Edge& e) const {
|
marci@168
|
1072 |
if (e.out_or_in)
|
marci@168
|
1073 |
return (capacity->get(e.out)-flow->get(e.out));
|
marci@168
|
1074 |
else
|
marci@168
|
1075 |
return (flow->get(e.in));
|
marci@168
|
1076 |
}
|
marci@168
|
1077 |
|
marci@168
|
1078 |
Number free(OldOutEdgeIt out) const {
|
marci@168
|
1079 |
return (capacity->get(out)-flow->get(out));
|
marci@168
|
1080 |
}
|
marci@168
|
1081 |
|
marci@168
|
1082 |
Number free(OldInEdgeIt in) const {
|
marci@168
|
1083 |
return (flow->get(in));
|
marci@168
|
1084 |
}
|
marci@168
|
1085 |
|
marci@259
|
1086 |
template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
|
marci@155
|
1087 |
public:
|
marci@155
|
1088 |
NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G)
|
marci@259
|
1089 |
: GraphWrapper::NodeMap<T>(_G.gw) { }
|
marci@155
|
1090 |
NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G,
|
marci@259
|
1091 |
T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }
|
marci@155
|
1092 |
};
|
marci@155
|
1093 |
|
marci@155
|
1094 |
// template <typename T>
|
marci@155
|
1095 |
// class NodeMap {
|
marci@155
|
1096 |
// typename Graph::NodeMap<T> node_map;
|
marci@155
|
1097 |
// public:
|
marci@174
|
1098 |
// NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(*(_G.graph)) { }
|
marci@174
|
1099 |
// NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(*(_G.graph), a) { }
|
marci@174
|
1100 |
// void set(Node nit, T a) { node_map.set(nit, a); }
|
marci@174
|
1101 |
// T get(Node nit) const { return node_map.get(nit); }
|
marci@155
|
1102 |
// };
|
marci@155
|
1103 |
|
marci@155
|
1104 |
template <typename T>
|
marci@155
|
1105 |
class EdgeMap {
|
marci@259
|
1106 |
typename GraphWrapper::EdgeMap<T> forward_map, backward_map;
|
marci@155
|
1107 |
public:
|
marci@259
|
1108 |
EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }
|
marci@259
|
1109 |
EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }
|
marci@174
|
1110 |
void set(Edge e, T a) {
|
marci@155
|
1111 |
if (e.out_or_in)
|
marci@155
|
1112 |
forward_map.set(e.out, a);
|
marci@155
|
1113 |
else
|
marci@155
|
1114 |
backward_map.set(e.in, a);
|
marci@155
|
1115 |
}
|
marci@174
|
1116 |
T get(Edge e) {
|
marci@155
|
1117 |
if (e.out_or_in)
|
marci@155
|
1118 |
return forward_map.get(e.out);
|
marci@155
|
1119 |
else
|
marci@155
|
1120 |
return backward_map.get(e.in);
|
marci@155
|
1121 |
}
|
marci@155
|
1122 |
};
|
marci@168
|
1123 |
};
|
marci@168
|
1124 |
|
marci@168
|
1125 |
template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
|
marci@168
|
1126 |
class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
|
marci@168
|
1127 |
protected:
|
marci@168
|
1128 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
|
marci@168
|
1129 |
//ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
|
marci@168
|
1130 |
public:
|
marci@168
|
1131 |
ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow,
|
marci@168
|
1132 |
const CapacityMap& _capacity) :
|
marci@168
|
1133 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity),
|
marci@168
|
1134 |
first_out_edges(*this) /*, dist(*this)*/ {
|
marci@174
|
1135 |
for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
|
marci@168
|
1136 |
OutEdgeIt e;
|
marci@212
|
1137 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
|
marci@168
|
1138 |
first_out_edges.set(n, e);
|
marci@168
|
1139 |
}
|
marci@168
|
1140 |
}
|
marci@168
|
1141 |
|
marci@168
|
1142 |
//void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@168
|
1143 |
//Graph& getGraph() const { return (*graph); }
|
marci@168
|
1144 |
|
marci@168
|
1145 |
//TrivGraphWrapper() : graph(0) { }
|
marci@168
|
1146 |
//ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@168
|
1147 |
|
marci@168
|
1148 |
//typedef Graph BaseGraph;
|
marci@168
|
1149 |
|
marci@174
|
1150 |
//typedef typename Graph::Node Node;
|
marci@168
|
1151 |
//typedef typename Graph::NodeIt NodeIt;
|
marci@168
|
1152 |
|
marci@174
|
1153 |
//typedef typename Graph::Edge Edge;
|
marci@168
|
1154 |
//typedef typename Graph::OutEdgeIt OutEdgeIt;
|
marci@168
|
1155 |
//typedef typename Graph::InEdgeIt InEdgeIt;
|
marci@168
|
1156 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
1157 |
//typedef typename Graph::EdgeIt EdgeIt;
|
marci@168
|
1158 |
|
marci@174
|
1159 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
|
marci@168
|
1160 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
|
marci@168
|
1161 |
|
marci@174
|
1162 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
|
marci@168
|
1163 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
|
marci@168
|
1164 |
//typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
|
marci@168
|
1165 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
1166 |
//typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
|
marci@168
|
1167 |
|
marci@212
|
1168 |
NodeIt& first(NodeIt& n) const {
|
marci@212
|
1169 |
return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
|
marci@168
|
1170 |
}
|
marci@168
|
1171 |
|
marci@212
|
1172 |
OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
|
marci@168
|
1173 |
e=first_out_edges.get(n);
|
marci@168
|
1174 |
return e;
|
marci@168
|
1175 |
}
|
marci@168
|
1176 |
|
marci@212
|
1177 |
//ROSSZ template<typename I> I& first(I& i) const { return first(i); }
|
marci@212
|
1178 |
//ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
1179 |
// return first(i, p); }
|
marci@168
|
1180 |
|
marci@168
|
1181 |
//template<typename I> I getNext(const I& i) const {
|
marci@259
|
1182 |
// return gw.getNext(i); }
|
marci@259
|
1183 |
//template<typename I> I& next(I &i) const { return gw.next(i); }
|
marci@168
|
1184 |
|
marci@168
|
1185 |
template< typename It > It first() const {
|
marci@212
|
1186 |
It e; first(e); return e; }
|
marci@168
|
1187 |
|
marci@174
|
1188 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
1189 |
It e; first(e, v); return e; }
|
marci@168
|
1190 |
|
marci@259
|
1191 |
//Node head(const Edge& e) const { return gw.head(e); }
|
marci@259
|
1192 |
//Node tail(const Edge& e) const { return gw.tail(e); }
|
marci@168
|
1193 |
|
marci@168
|
1194 |
//template<typename I> bool valid(const I& i) const
|
marci@259
|
1195 |
// { return gw.valid(i); }
|
marci@168
|
1196 |
|
marci@259
|
1197 |
//int nodeNum() const { return gw.nodeNum(); }
|
marci@259
|
1198 |
//int edgeNum() const { return gw.edgeNum(); }
|
marci@168
|
1199 |
|
marci@174
|
1200 |
//template<typename I> Node aNode(const I& e) const {
|
marci@259
|
1201 |
// return gw.aNode(e); }
|
marci@174
|
1202 |
//template<typename I> Node bNode(const I& e) const {
|
marci@259
|
1203 |
// return gw.bNode(e); }
|
marci@168
|
1204 |
|
marci@259
|
1205 |
//Node addNode() const { return gw.addNode(); }
|
marci@174
|
1206 |
//Edge addEdge(const Node& tail, const Node& head) const {
|
marci@259
|
1207 |
// return gw.addEdge(tail, head); }
|
marci@168
|
1208 |
|
marci@168
|
1209 |
//void erase(const OutEdgeIt& e) {
|
marci@168
|
1210 |
// first_out_edge(this->tail(e))=e;
|
marci@168
|
1211 |
//}
|
marci@174
|
1212 |
void erase(const Edge& e) {
|
marci@168
|
1213 |
OutEdgeIt f(e);
|
marci@168
|
1214 |
next(f);
|
marci@168
|
1215 |
first_out_edges.set(this->tail(e), f);
|
marci@168
|
1216 |
}
|
marci@259
|
1217 |
//template<typename I> void erase(const I& i) const { gw.erase(i); }
|
marci@168
|
1218 |
|
marci@259
|
1219 |
//void clear() const { gw.clear(); }
|
marci@168
|
1220 |
|
marci@168
|
1221 |
template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
|
marci@168
|
1222 |
public:
|
marci@168
|
1223 |
NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
|
marci@168
|
1224 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
1225 |
NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
|
marci@168
|
1226 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
1227 |
};
|
marci@168
|
1228 |
|
marci@168
|
1229 |
template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
|
marci@168
|
1230 |
public:
|
marci@168
|
1231 |
EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
|
marci@168
|
1232 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
1233 |
EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
|
marci@168
|
1234 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
1235 |
};
|
marci@168
|
1236 |
};
|
marci@168
|
1237 |
|
marci@168
|
1238 |
template<typename GraphWrapper>
|
marci@168
|
1239 |
class FilterGraphWrapper {
|
marci@168
|
1240 |
};
|
marci@168
|
1241 |
|
marci@168
|
1242 |
template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
|
marci@168
|
1243 |
class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
|
marci@168
|
1244 |
|
marci@168
|
1245 |
//Graph* graph;
|
marci@168
|
1246 |
|
marci@168
|
1247 |
public:
|
marci@168
|
1248 |
//typedef Graph BaseGraph;
|
marci@168
|
1249 |
|
marci@174
|
1250 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
|
marci@168
|
1251 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
|
marci@168
|
1252 |
|
marci@174
|
1253 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
|
marci@168
|
1254 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
|
marci@168
|
1255 |
//typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
|
marci@168
|
1256 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
1257 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
|
marci@168
|
1258 |
|
marci@168
|
1259 |
//FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
|
marci@168
|
1260 |
|
marci@168
|
1261 |
public:
|
marci@168
|
1262 |
FilterGraphWrapper(const Graph& _G, FlowMap& _flow,
|
marci@168
|
1263 |
const CapacityMap& _capacity) :
|
marci@259
|
1264 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) {
|
marci@168
|
1265 |
}
|
marci@168
|
1266 |
|
marci@212
|
1267 |
OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
|
marci@212
|
1268 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
|
marci@199
|
1269 |
while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e))))
|
marci@168
|
1270 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@168
|
1271 |
return e;
|
marci@168
|
1272 |
}
|
marci@168
|
1273 |
|
marci@174
|
1274 |
NodeIt& next(NodeIt& e) const {
|
marci@168
|
1275 |
return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@168
|
1276 |
}
|
marci@168
|
1277 |
|
marci@168
|
1278 |
OutEdgeIt& next(OutEdgeIt& e) const {
|
marci@168
|
1279 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@199
|
1280 |
while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e))))
|
marci@168
|
1281 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@168
|
1282 |
return e;
|
marci@168
|
1283 |
}
|
marci@168
|
1284 |
|
marci@212
|
1285 |
NodeIt& first(NodeIt& n) const {
|
marci@212
|
1286 |
return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
|
marci@168
|
1287 |
}
|
marci@168
|
1288 |
|
marci@174
|
1289 |
void erase(const Edge& e) {
|
marci@168
|
1290 |
OutEdgeIt f(e);
|
marci@168
|
1291 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
|
marci@199
|
1292 |
while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f))))
|
marci@168
|
1293 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
|
marci@168
|
1294 |
first_out_edges.set(this->tail(e), f);
|
marci@168
|
1295 |
}
|
marci@168
|
1296 |
|
marci@168
|
1297 |
//TrivGraphWrapper() : graph(0) { }
|
marci@168
|
1298 |
//TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@168
|
1299 |
|
marci@168
|
1300 |
//void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@168
|
1301 |
//Graph& getGraph() const { return (*graph); }
|
marci@168
|
1302 |
|
marci@259
|
1303 |
//template<typename I> I& first(I& i) const { return gw.first(i); }
|
marci@212
|
1304 |
//template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@259
|
1305 |
// return gw.first(i, p); }
|
marci@168
|
1306 |
|
marci@168
|
1307 |
//template<typename I> I getNext(const I& i) const {
|
marci@259
|
1308 |
// return gw.getNext(i); }
|
marci@259
|
1309 |
//template<typename I> I& next(I &i) const { return gw.next(i); }
|
marci@168
|
1310 |
|
marci@168
|
1311 |
template< typename It > It first() const {
|
marci@212
|
1312 |
It e; first(e); return e; }
|
marci@168
|
1313 |
|
marci@174
|
1314 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
1315 |
It e; first(e, v); return e; }
|
marci@168
|
1316 |
|
marci@259
|
1317 |
//Node head(const Edge& e) const { return gw.head(e); }
|
marci@259
|
1318 |
//Node tail(const Edge& e) const { return gw.tail(e); }
|
marci@168
|
1319 |
|
marci@168
|
1320 |
//template<typename I> bool valid(const I& i) const
|
marci@259
|
1321 |
// { return gw.valid(i); }
|
marci@168
|
1322 |
|
marci@168
|
1323 |
//template<typename I> void setInvalid(const I &i);
|
marci@259
|
1324 |
//{ return gw.setInvalid(i); }
|
marci@168
|
1325 |
|
marci@259
|
1326 |
//int nodeNum() const { return gw.nodeNum(); }
|
marci@259
|
1327 |
//int edgeNum() const { return gw.edgeNum(); }
|
marci@168
|
1328 |
|
marci@174
|
1329 |
//template<typename I> Node aNode(const I& e) const {
|
marci@259
|
1330 |
// return gw.aNode(e); }
|
marci@174
|
1331 |
//template<typename I> Node bNode(const I& e) const {
|
marci@259
|
1332 |
// return gw.bNode(e); }
|
marci@168
|
1333 |
|
marci@259
|
1334 |
//Node addNode() const { return gw.addNode(); }
|
marci@174
|
1335 |
//Edge addEdge(const Node& tail, const Node& head) const {
|
marci@259
|
1336 |
// return gw.addEdge(tail, head); }
|
marci@168
|
1337 |
|
marci@259
|
1338 |
//template<typename I> void erase(const I& i) const { gw.erase(i); }
|
marci@168
|
1339 |
|
marci@259
|
1340 |
//void clear() const { gw.clear(); }
|
marci@168
|
1341 |
|
marci@168
|
1342 |
template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
|
marci@168
|
1343 |
public:
|
marci@168
|
1344 |
NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
|
marci@168
|
1345 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
1346 |
NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
|
marci@168
|
1347 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
1348 |
};
|
marci@168
|
1349 |
|
marci@168
|
1350 |
template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
|
marci@168
|
1351 |
public:
|
marci@168
|
1352 |
EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
|
marci@168
|
1353 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
1354 |
EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
|
marci@168
|
1355 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
1356 |
};
|
marci@168
|
1357 |
|
marci@168
|
1358 |
public:
|
marci@168
|
1359 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
|
marci@155
|
1360 |
|
marci@76
|
1361 |
};
|
marci@76
|
1362 |
|
marci@76
|
1363 |
|
marci@148
|
1364 |
|
marci@148
|
1365 |
// // FIXME: comparison should be made better!!!
|
marci@148
|
1366 |
// template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
|
marci@148
|
1367 |
// class ResGraphWrapper
|
marci@148
|
1368 |
// {
|
marci@148
|
1369 |
// Graph* graph;
|
marci@76
|
1370 |
|
marci@148
|
1371 |
// public:
|
marci@148
|
1372 |
// typedef Graph BaseGraph;
|
marci@76
|
1373 |
|
marci@174
|
1374 |
// typedef typename Graph::Node Node;
|
marci@174
|
1375 |
// typedef typename Graph::Edge Edge;
|
marci@174
|
1376 |
|
marci@148
|
1377 |
// typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
1378 |
|
marci@148
|
1379 |
// class OutEdgeIt {
|
marci@148
|
1380 |
// public:
|
marci@174
|
1381 |
// //Graph::Node n;
|
marci@148
|
1382 |
// bool out_or_in;
|
marci@148
|
1383 |
// typename Graph::OutEdgeIt o;
|
marci@148
|
1384 |
// typename Graph::InEdgeIt i;
|
marci@148
|
1385 |
// };
|
marci@148
|
1386 |
// class InEdgeIt {
|
marci@148
|
1387 |
// public:
|
marci@174
|
1388 |
// //Graph::Node n;
|
marci@148
|
1389 |
// bool out_or_in;
|
marci@148
|
1390 |
// typename Graph::OutEdgeIt o;
|
marci@148
|
1391 |
// typename Graph::InEdgeIt i;
|
marci@148
|
1392 |
// };
|
marci@148
|
1393 |
// typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
1394 |
// typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
1395 |
|
marci@259
|
1396 |
// int nodeNum() const { return gw.nodeNum(); }
|
marci@259
|
1397 |
// int edgeNum() const { return gw.edgeNum(); }
|
marci@76
|
1398 |
|
marci@259
|
1399 |
// Node& first(Node& n) const { return gw.first(n); }
|
marci@76
|
1400 |
|
marci@174
|
1401 |
// // Edge and SymEdge is missing!!!!
|
marci@174
|
1402 |
// // Edge <-> In/OutEdgeIt conversion is missing!!!!
|
marci@76
|
1403 |
|
marci@148
|
1404 |
// //FIXME
|
marci@212
|
1405 |
// OutEdgeIt& first(OutEdgeIt& e, const Node& n) const
|
marci@148
|
1406 |
// {
|
marci@148
|
1407 |
// e.n=n;
|
marci@259
|
1408 |
// gw.first(e.o,n);
|
marci@259
|
1409 |
// while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@259
|
1410 |
// gw.goNext(e.o);
|
marci@259
|
1411 |
// if(!gw.valid(e.o)) {
|
marci@259
|
1412 |
// gw.first(e.i,n);
|
marci@259
|
1413 |
// while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@259
|
1414 |
// gw.goNext(e.i);
|
marci@148
|
1415 |
// }
|
marci@148
|
1416 |
// return e;
|
marci@148
|
1417 |
// }
|
marci@148
|
1418 |
// /*
|
marci@148
|
1419 |
// OutEdgeIt &goNext(OutEdgeIt &e)
|
marci@148
|
1420 |
// {
|
marci@259
|
1421 |
// if(gw.valid(e.o)) {
|
marci@259
|
1422 |
// while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@259
|
1423 |
// gw.goNext(e.o);
|
marci@259
|
1424 |
// if(gw.valid(e.o)) return e;
|
marci@259
|
1425 |
// else gw.first(e.i,e.n);
|
marci@148
|
1426 |
// }
|
marci@148
|
1427 |
// else {
|
marci@259
|
1428 |
// while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@259
|
1429 |
// gw.goNext(e.i);
|
marci@148
|
1430 |
// return e;
|
marci@148
|
1431 |
// }
|
marci@148
|
1432 |
// }
|
marci@148
|
1433 |
// OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
|
marci@148
|
1434 |
// */
|
marci@259
|
1435 |
// //bool valid(const OutEdgeIt e) { return gw.valid(e.o)||gw.valid(e.i);}
|
marci@76
|
1436 |
|
marci@148
|
1437 |
// //FIXME
|
marci@212
|
1438 |
// InEdgeIt& first(InEdgeIt& e, const Node& n) const
|
marci@148
|
1439 |
// {
|
marci@148
|
1440 |
// e.n=n;
|
marci@259
|
1441 |
// gw.first(e.i,n);
|
marci@259
|
1442 |
// while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@259
|
1443 |
// gw.goNext(e.i);
|
marci@259
|
1444 |
// if(!gw.valid(e.i)) {
|
marci@259
|
1445 |
// gw.first(e.o,n);
|
marci@259
|
1446 |
// while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@259
|
1447 |
// gw.goNext(e.o);
|
marci@148
|
1448 |
// }
|
marci@148
|
1449 |
// return e;
|
marci@148
|
1450 |
// }
|
marci@148
|
1451 |
// /*
|
marci@148
|
1452 |
// InEdgeIt &goNext(InEdgeIt &e)
|
marci@148
|
1453 |
// {
|
marci@259
|
1454 |
// if(gw.valid(e.i)) {
|
marci@259
|
1455 |
// while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@259
|
1456 |
// gw.goNext(e.i);
|
marci@259
|
1457 |
// if(gw.valid(e.i)) return e;
|
marci@259
|
1458 |
// else gw.first(e.o,e.n);
|
marci@148
|
1459 |
// }
|
marci@148
|
1460 |
// else {
|
marci@259
|
1461 |
// while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@259
|
1462 |
// gw.goNext(e.o);
|
marci@148
|
1463 |
// return e;
|
marci@148
|
1464 |
// }
|
marci@148
|
1465 |
// }
|
marci@148
|
1466 |
// InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
|
marci@148
|
1467 |
// */
|
marci@259
|
1468 |
// //bool valid(const InEdgeIt e) { return gw.valid(e.i)||gw.valid(e.o);}
|
marci@76
|
1469 |
|
marci@259
|
1470 |
// //template<typename I> I &goNext(I &i); { return gw.goNext(i); }
|
marci@259
|
1471 |
// //template<typename I> I next(const I i); { return gw.goNext(i); }
|
marci@76
|
1472 |
|
marci@148
|
1473 |
// template< typename It > It first() const {
|
marci@212
|
1474 |
// It e; first(e); return e; }
|
marci@76
|
1475 |
|
marci@174
|
1476 |
// template< typename It > It first(Node v) const {
|
marci@212
|
1477 |
// It e; first(e, v); return e; }
|
marci@76
|
1478 |
|
marci@259
|
1479 |
// Node head(const Edge& e) const { return gw.head(e); }
|
marci@259
|
1480 |
// Node tail(const Edge& e) const { return gw.tail(e); }
|
marci@76
|
1481 |
|
marci@174
|
1482 |
// template<typename I> Node aNode(const I& e) const {
|
marci@259
|
1483 |
// return gw.aNode(e); }
|
marci@174
|
1484 |
// template<typename I> Node bNode(const I& e) const {
|
marci@259
|
1485 |
// return gw.bNode(e); }
|
marci@76
|
1486 |
|
marci@148
|
1487 |
// //template<typename I> bool valid(const I i);
|
marci@259
|
1488 |
// //{ return gw.valid(i); }
|
marci@76
|
1489 |
|
marci@148
|
1490 |
// //template<typename I> void setInvalid(const I &i);
|
marci@259
|
1491 |
// //{ return gw.setInvalid(i); }
|
marci@76
|
1492 |
|
marci@259
|
1493 |
// Node addNode() { return gw.addNode(); }
|
marci@174
|
1494 |
// Edge addEdge(const Node& tail, const Node& head) {
|
marci@259
|
1495 |
// return gw.addEdge(tail, head); }
|
marci@76
|
1496 |
|
marci@259
|
1497 |
// template<typename I> void erase(const I& i) { gw.erase(i); }
|
marci@76
|
1498 |
|
marci@259
|
1499 |
// void clear() { gw.clear(); }
|
marci@76
|
1500 |
|
marci@148
|
1501 |
// template<typename S> class NodeMap : public Graph::NodeMap<S> { };
|
marci@148
|
1502 |
// template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
|
marci@76
|
1503 |
|
marci@148
|
1504 |
// void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@148
|
1505 |
// Graph& getGraph() { return (*graph); }
|
marci@76
|
1506 |
|
marci@148
|
1507 |
// //ResGraphWrapper() : graph(0) { }
|
marci@148
|
1508 |
// ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@148
|
1509 |
// };
|
marci@76
|
1510 |
|
alpar@105
|
1511 |
} //namespace hugo
|
marci@76
|
1512 |
|
marci@259
|
1513 |
#endif //HUGO_GRAPH_WRAPPER_H
|
marci@76
|
1514 |
|