marci@174
|
1 |
// -*- c++ -*-
|
marci@76
|
2 |
#ifndef GRAPH_WRAPPER_H
|
marci@76
|
3 |
#define 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@212
|
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@212
|
106 |
GraphWrapperSkeleton(GraphWrapper& _gw) : gw(_gw) { }
|
marci@212
|
107 |
|
marci@212
|
108 |
void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); }
|
marci@212
|
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@76
|
163 |
template<typename Graph>
|
marci@76
|
164 |
class RevGraphWrapper
|
marci@76
|
165 |
{
|
marci@199
|
166 |
protected:
|
marci@76
|
167 |
Graph* graph;
|
marci@76
|
168 |
|
marci@76
|
169 |
public:
|
marci@76
|
170 |
typedef Graph BaseGraph;
|
marci@76
|
171 |
|
marci@174
|
172 |
typedef typename Graph::Node Node;
|
marci@174
|
173 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
174 |
|
marci@174
|
175 |
typedef typename Graph::Edge Edge;
|
marci@76
|
176 |
typedef typename Graph::OutEdgeIt InEdgeIt;
|
marci@76
|
177 |
typedef typename Graph::InEdgeIt OutEdgeIt;
|
marci@155
|
178 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
179 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@168
|
180 |
|
marci@168
|
181 |
//RevGraphWrapper() : graph(0) { }
|
marci@168
|
182 |
RevGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@168
|
183 |
|
marci@168
|
184 |
void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@168
|
185 |
Graph& getGraph() const { return (*graph); }
|
marci@76
|
186 |
|
marci@212
|
187 |
template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@212
|
188 |
template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
189 |
return graph->first(i, p); }
|
marci@155
|
190 |
|
marci@155
|
191 |
template<typename I> I getNext(const I& i) const {
|
marci@155
|
192 |
return graph->getNext(i); }
|
marci@155
|
193 |
template<typename I> I& next(I &i) const { return graph->next(i); }
|
marci@76
|
194 |
|
marci@76
|
195 |
template< typename It > It first() const {
|
marci@212
|
196 |
It e; first(e); return e; }
|
marci@76
|
197 |
|
marci@174
|
198 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
199 |
It e; first(e, v); return e; }
|
marci@76
|
200 |
|
marci@174
|
201 |
Node head(const Edge& e) const { return graph->tail(e); }
|
marci@174
|
202 |
Node tail(const Edge& e) const { return graph->head(e); }
|
marci@76
|
203 |
|
marci@155
|
204 |
template<typename I> bool valid(const I& i) const
|
marci@155
|
205 |
{ return graph->valid(i); }
|
marci@155
|
206 |
|
marci@155
|
207 |
//template<typename I> void setInvalid(const I &i);
|
marci@155
|
208 |
//{ return graph->setInvalid(i); }
|
marci@155
|
209 |
|
marci@174
|
210 |
template<typename I> Node aNode(const I& e) const {
|
marci@76
|
211 |
return graph->aNode(e); }
|
marci@174
|
212 |
template<typename I> Node bNode(const I& e) const {
|
marci@76
|
213 |
return graph->bNode(e); }
|
marci@155
|
214 |
|
marci@174
|
215 |
Node addNode() const { return graph->addNode(); }
|
marci@174
|
216 |
Edge addEdge(const Node& tail, const Node& head) const {
|
marci@76
|
217 |
return graph->addEdge(tail, head); }
|
marci@76
|
218 |
|
marci@155
|
219 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@155
|
220 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
221 |
|
marci@155
|
222 |
template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@76
|
223 |
|
marci@155
|
224 |
void clear() const { graph->clear(); }
|
marci@155
|
225 |
|
marci@155
|
226 |
template<typename T> class NodeMap : public Graph::NodeMap<T> {
|
marci@155
|
227 |
public:
|
marci@155
|
228 |
NodeMap(const RevGraphWrapper<Graph>& _G) :
|
marci@158
|
229 |
Graph::NodeMap<T>(_G.getGraph()) { }
|
marci@155
|
230 |
NodeMap(const RevGraphWrapper<Graph>& _G, T a) :
|
marci@158
|
231 |
Graph::NodeMap<T>(_G.getGraph(), a) { }
|
marci@155
|
232 |
};
|
marci@168
|
233 |
|
marci@155
|
234 |
template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
|
marci@155
|
235 |
public:
|
marci@155
|
236 |
EdgeMap(const RevGraphWrapper<Graph>& _G) :
|
marci@158
|
237 |
Graph::EdgeMap<T>(_G.getGraph()) { }
|
marci@155
|
238 |
EdgeMap(const RevGraphWrapper<Graph>& _G, T a) :
|
marci@158
|
239 |
Graph::EdgeMap<T>(_G.getGraph(), a) { }
|
marci@155
|
240 |
};
|
marci@76
|
241 |
};
|
marci@76
|
242 |
|
marci@155
|
243 |
|
marci@158
|
244 |
template<typename Graph>
|
marci@158
|
245 |
class UndirGraphWrapper {
|
marci@199
|
246 |
protected:
|
marci@158
|
247 |
Graph* graph;
|
marci@158
|
248 |
|
marci@158
|
249 |
public:
|
marci@158
|
250 |
typedef Graph BaseGraph;
|
marci@158
|
251 |
|
marci@174
|
252 |
typedef typename Graph::Node Node;
|
marci@158
|
253 |
typedef typename Graph::NodeIt NodeIt;
|
marci@158
|
254 |
|
marci@174
|
255 |
//typedef typename Graph::Edge Edge;
|
marci@158
|
256 |
//typedef typename Graph::OutEdgeIt OutEdgeIt;
|
marci@158
|
257 |
//typedef typename Graph::InEdgeIt InEdgeIt;
|
marci@158
|
258 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
259 |
//typedef typename Graph::EdgeIt EdgeIt;
|
marci@158
|
260 |
|
marci@158
|
261 |
//private:
|
marci@174
|
262 |
typedef typename Graph::Edge GraphEdge;
|
marci@158
|
263 |
typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
|
marci@158
|
264 |
typedef typename Graph::InEdgeIt GraphInEdgeIt;
|
marci@158
|
265 |
//public:
|
marci@158
|
266 |
|
marci@168
|
267 |
//UndirGraphWrapper() : graph(0) { }
|
marci@168
|
268 |
UndirGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@168
|
269 |
|
marci@168
|
270 |
void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@168
|
271 |
Graph& getGraph() const { return (*graph); }
|
marci@168
|
272 |
|
marci@174
|
273 |
class Edge {
|
marci@158
|
274 |
friend class UndirGraphWrapper<Graph>;
|
marci@158
|
275 |
bool out_or_in; //true iff out
|
marci@158
|
276 |
GraphOutEdgeIt out;
|
marci@158
|
277 |
GraphInEdgeIt in;
|
marci@158
|
278 |
public:
|
marci@174
|
279 |
Edge() : out_or_in(), out(), in() { }
|
marci@174
|
280 |
Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
|
marci@174
|
281 |
operator GraphEdge() const {
|
marci@158
|
282 |
if (out_or_in) return(out); else return(in);
|
marci@158
|
283 |
}
|
marci@174
|
284 |
friend bool operator==(const Edge& u, const Edge& v) {
|
marci@174
|
285 |
if (v.out_or_in)
|
marci@174
|
286 |
return (u.out_or_in && u.out==v.out);
|
marci@174
|
287 |
else
|
marci@174
|
288 |
return (!u.out_or_in && u.in==v.in);
|
marci@174
|
289 |
}
|
marci@174
|
290 |
friend bool operator!=(const Edge& u, const Edge& v) {
|
marci@174
|
291 |
if (v.out_or_in)
|
marci@174
|
292 |
return (!u.out_or_in || u.out!=v.out);
|
marci@174
|
293 |
else
|
marci@174
|
294 |
return (u.out_or_in || u.in!=v.in);
|
marci@174
|
295 |
}
|
marci@158
|
296 |
};
|
marci@158
|
297 |
|
marci@174
|
298 |
class OutEdgeIt : public Edge {
|
marci@158
|
299 |
friend class UndirGraphWrapper<Graph>;
|
marci@158
|
300 |
public:
|
marci@174
|
301 |
OutEdgeIt() : Edge() { }
|
marci@174
|
302 |
OutEdgeIt(const Invalid& i) : Edge(i) { }
|
marci@174
|
303 |
OutEdgeIt(const UndirGraphWrapper& _G, const Node& n) : Edge() {
|
marci@174
|
304 |
out_or_in=true;
|
marci@212
|
305 |
_G.graph->first(out, n);
|
marci@158
|
306 |
if (!(_G.graph->valid(out))) {
|
marci@158
|
307 |
out_or_in=false;
|
marci@212
|
308 |
_G.graph->first(in, n);
|
marci@158
|
309 |
}
|
marci@158
|
310 |
}
|
marci@158
|
311 |
};
|
marci@158
|
312 |
|
marci@212
|
313 |
OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
|
marci@158
|
314 |
e.out_or_in=true;
|
marci@212
|
315 |
graph->first(e.out, n);
|
marci@158
|
316 |
if (!(graph->valid(e.out))) {
|
marci@158
|
317 |
e.out_or_in=false;
|
marci@212
|
318 |
graph->first(e.in, n);
|
marci@158
|
319 |
}
|
marci@158
|
320 |
return e;
|
marci@158
|
321 |
}
|
marci@158
|
322 |
|
marci@158
|
323 |
OutEdgeIt& next(OutEdgeIt& e) const {
|
marci@158
|
324 |
if (e.out_or_in) {
|
marci@174
|
325 |
Node n=graph->tail(e.out);
|
marci@158
|
326 |
graph->next(e.out);
|
marci@158
|
327 |
if (!graph->valid(e.out)) {
|
marci@158
|
328 |
e.out_or_in=false;
|
marci@212
|
329 |
graph->first(e.in, n);
|
marci@158
|
330 |
}
|
marci@158
|
331 |
} else {
|
marci@158
|
332 |
graph->next(e.in);
|
marci@158
|
333 |
}
|
marci@158
|
334 |
return e;
|
marci@158
|
335 |
}
|
marci@158
|
336 |
|
marci@174
|
337 |
Node aNode(const OutEdgeIt& e) const {
|
marci@158
|
338 |
if (e.out_or_in) return graph->tail(e); else return graph->head(e); }
|
marci@174
|
339 |
Node bNode(const OutEdgeIt& e) const {
|
marci@158
|
340 |
if (e.out_or_in) return graph->head(e); else return graph->tail(e); }
|
marci@158
|
341 |
|
marci@158
|
342 |
typedef OutEdgeIt InEdgeIt;
|
marci@158
|
343 |
|
marci@212
|
344 |
template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@212
|
345 |
// template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
346 |
// return graph->first(i, p); }
|
marci@158
|
347 |
|
marci@158
|
348 |
template<typename I> I getNext(const I& i) const {
|
marci@158
|
349 |
return graph->getNext(i); }
|
marci@158
|
350 |
template<typename I> I& next(I &i) const { return graph->next(i); }
|
marci@158
|
351 |
|
marci@158
|
352 |
template< typename It > It first() const {
|
marci@212
|
353 |
It e; first(e); return e; }
|
marci@158
|
354 |
|
marci@174
|
355 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
356 |
It e; first(e, v); return e; }
|
marci@158
|
357 |
|
marci@174
|
358 |
Node head(const Edge& e) const { return graph->head(e); }
|
marci@174
|
359 |
Node tail(const Edge& e) const { return graph->tail(e); }
|
marci@158
|
360 |
|
marci@158
|
361 |
template<typename I> bool valid(const I& i) const
|
marci@158
|
362 |
{ return graph->valid(i); }
|
marci@158
|
363 |
|
marci@158
|
364 |
//template<typename I> void setInvalid(const I &i);
|
marci@158
|
365 |
//{ return graph->setInvalid(i); }
|
marci@158
|
366 |
|
marci@158
|
367 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@158
|
368 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@158
|
369 |
|
marci@174
|
370 |
// template<typename I> Node aNode(const I& e) const {
|
marci@158
|
371 |
// return graph->aNode(e); }
|
marci@174
|
372 |
// template<typename I> Node bNode(const I& e) const {
|
marci@158
|
373 |
// return graph->bNode(e); }
|
marci@158
|
374 |
|
marci@174
|
375 |
Node addNode() const { return graph->addNode(); }
|
marci@174
|
376 |
Edge addEdge(const Node& tail, const Node& head) const {
|
marci@158
|
377 |
return graph->addEdge(tail, head); }
|
marci@158
|
378 |
|
marci@158
|
379 |
template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@158
|
380 |
|
marci@158
|
381 |
void clear() const { graph->clear(); }
|
marci@158
|
382 |
|
marci@158
|
383 |
template<typename T> class NodeMap : public Graph::NodeMap<T> {
|
marci@158
|
384 |
public:
|
marci@158
|
385 |
NodeMap(const UndirGraphWrapper<Graph>& _G) :
|
marci@158
|
386 |
Graph::NodeMap<T>(_G.getGraph()) { }
|
marci@158
|
387 |
NodeMap(const UndirGraphWrapper<Graph>& _G, T a) :
|
marci@158
|
388 |
Graph::NodeMap<T>(_G.getGraph(), a) { }
|
marci@158
|
389 |
};
|
marci@168
|
390 |
|
marci@158
|
391 |
template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
|
marci@158
|
392 |
public:
|
marci@158
|
393 |
EdgeMap(const UndirGraphWrapper<Graph>& _G) :
|
marci@158
|
394 |
Graph::EdgeMap<T>(_G.getGraph()) { }
|
marci@158
|
395 |
EdgeMap(const UndirGraphWrapper<Graph>& _G, T a) :
|
marci@158
|
396 |
Graph::EdgeMap<T>(_G.getGraph(), a) { }
|
marci@158
|
397 |
};
|
marci@158
|
398 |
};
|
marci@158
|
399 |
|
marci@158
|
400 |
|
marci@158
|
401 |
|
marci@155
|
402 |
// template<typename Graph>
|
marci@155
|
403 |
// class SymGraphWrapper
|
marci@155
|
404 |
// {
|
marci@155
|
405 |
// Graph* graph;
|
marci@76
|
406 |
|
marci@155
|
407 |
// public:
|
marci@155
|
408 |
// typedef Graph BaseGraph;
|
marci@155
|
409 |
|
marci@174
|
410 |
// typedef typename Graph::Node Node;
|
marci@174
|
411 |
// typedef typename Graph::Edge Edge;
|
marci@174
|
412 |
|
marci@155
|
413 |
// typedef typename Graph::NodeIt NodeIt;
|
marci@155
|
414 |
|
marci@155
|
415 |
// //FIXME tag-ekkel megcsinalni, hogy abbol csinaljon
|
marci@155
|
416 |
// //iranyitatlant, ami van
|
marci@155
|
417 |
// //mert csak 1 dolgot lehet be typedef-elni
|
marci@155
|
418 |
// typedef typename Graph::OutEdgeIt SymEdgeIt;
|
marci@155
|
419 |
// //typedef typename Graph::InEdgeIt SymEdgeIt;
|
marci@155
|
420 |
// //typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
421 |
// typedef typename Graph::EdgeIt EdgeIt;
|
marci@155
|
422 |
|
marci@155
|
423 |
// int nodeNum() const { return graph->nodeNum(); }
|
marci@155
|
424 |
// int edgeNum() const { return graph->edgeNum(); }
|
marci@155
|
425 |
|
marci@212
|
426 |
// template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@212
|
427 |
// template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
428 |
// return graph->first(i, p); }
|
marci@155
|
429 |
// //template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@155
|
430 |
// //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@155
|
431 |
|
marci@155
|
432 |
// template< typename It > It first() const {
|
marci@212
|
433 |
// It e; first(e); return e; }
|
marci@155
|
434 |
|
marci@174
|
435 |
// template< typename It > It first(Node v) const {
|
marci@212
|
436 |
// It e; first(e, v); return e; }
|
marci@155
|
437 |
|
marci@174
|
438 |
// Node head(const Edge& e) const { return graph->head(e); }
|
marci@174
|
439 |
// Node tail(const Edge& e) const { return graph->tail(e); }
|
marci@155
|
440 |
|
marci@174
|
441 |
// template<typename I> Node aNode(const I& e) const {
|
marci@155
|
442 |
// return graph->aNode(e); }
|
marci@174
|
443 |
// template<typename I> Node bNode(const I& e) const {
|
marci@155
|
444 |
// return graph->bNode(e); }
|
marci@155
|
445 |
|
marci@155
|
446 |
// //template<typename I> bool valid(const I i);
|
marci@155
|
447 |
// //{ return graph->valid(i); }
|
marci@155
|
448 |
|
marci@155
|
449 |
// //template<typename I> void setInvalid(const I &i);
|
marci@155
|
450 |
// //{ return graph->setInvalid(i); }
|
marci@155
|
451 |
|
marci@174
|
452 |
// Node addNode() { return graph->addNode(); }
|
marci@174
|
453 |
// Edge addEdge(const Node& tail, const Node& head) {
|
marci@155
|
454 |
// return graph->addEdge(tail, head); }
|
marci@155
|
455 |
|
marci@155
|
456 |
// template<typename I> void erase(const I& i) { graph->erase(i); }
|
marci@155
|
457 |
|
marci@155
|
458 |
// void clear() { graph->clear(); }
|
marci@155
|
459 |
|
marci@155
|
460 |
// template<typename T> class NodeMap : public Graph::NodeMap<T> { };
|
marci@155
|
461 |
// template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
|
marci@155
|
462 |
|
marci@155
|
463 |
// void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@155
|
464 |
// Graph& getGraph() { return (*graph); }
|
marci@155
|
465 |
|
marci@155
|
466 |
// //SymGraphWrapper() : graph(0) { }
|
marci@155
|
467 |
// SymGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@155
|
468 |
// };
|
marci@155
|
469 |
|
marci@155
|
470 |
|
marci@155
|
471 |
template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
|
marci@155
|
472 |
class ResGraphWrapper {
|
marci@76
|
473 |
public:
|
marci@76
|
474 |
typedef Graph BaseGraph;
|
marci@174
|
475 |
typedef typename Graph::Node Node;
|
marci@155
|
476 |
typedef typename Graph::NodeIt NodeIt;
|
marci@155
|
477 |
private:
|
marci@155
|
478 |
typedef typename Graph::OutEdgeIt OldOutEdgeIt;
|
marci@155
|
479 |
typedef typename Graph::InEdgeIt OldInEdgeIt;
|
marci@199
|
480 |
protected:
|
marci@174
|
481 |
const Graph* graph;
|
marci@155
|
482 |
FlowMap* flow;
|
marci@155
|
483 |
const CapacityMap* capacity;
|
marci@155
|
484 |
public:
|
marci@168
|
485 |
|
marci@155
|
486 |
ResGraphWrapper(const Graph& _G, FlowMap& _flow,
|
marci@155
|
487 |
const CapacityMap& _capacity) :
|
marci@174
|
488 |
graph(&_G), flow(&_flow), capacity(&_capacity) { }
|
marci@168
|
489 |
|
marci@168
|
490 |
void setGraph(const Graph& _graph) { graph = &_graph; }
|
marci@174
|
491 |
const Graph& getGraph() const { return (*graph); }
|
marci@168
|
492 |
|
marci@174
|
493 |
class Edge;
|
marci@155
|
494 |
class OutEdgeIt;
|
marci@174
|
495 |
friend class Edge;
|
marci@155
|
496 |
friend class OutEdgeIt;
|
marci@76
|
497 |
|
marci@174
|
498 |
class Edge {
|
marci@155
|
499 |
friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
|
marci@155
|
500 |
protected:
|
marci@168
|
501 |
bool out_or_in; //true, iff out
|
marci@155
|
502 |
OldOutEdgeIt out;
|
marci@155
|
503 |
OldInEdgeIt in;
|
marci@155
|
504 |
public:
|
marci@174
|
505 |
Edge() : out_or_in(true) { }
|
marci@174
|
506 |
Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
|
marci@168
|
507 |
// bool valid() const {
|
marci@168
|
508 |
// return out_or_in && out.valid() || in.valid(); }
|
marci@174
|
509 |
friend bool operator==(const Edge& u, const Edge& v) {
|
marci@174
|
510 |
if (v.out_or_in)
|
marci@174
|
511 |
return (u.out_or_in && u.out==v.out);
|
marci@174
|
512 |
else
|
marci@174
|
513 |
return (!u.out_or_in && u.in==v.in);
|
marci@174
|
514 |
}
|
marci@174
|
515 |
friend bool operator!=(const Edge& u, const Edge& v) {
|
marci@174
|
516 |
if (v.out_or_in)
|
marci@174
|
517 |
return (!u.out_or_in || u.out!=v.out);
|
marci@174
|
518 |
else
|
marci@174
|
519 |
return (u.out_or_in || u.in!=v.in);
|
marci@174
|
520 |
}
|
marci@155
|
521 |
};
|
marci@155
|
522 |
|
marci@155
|
523 |
|
marci@174
|
524 |
class OutEdgeIt : public Edge {
|
marci@155
|
525 |
friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
|
marci@155
|
526 |
public:
|
marci@155
|
527 |
OutEdgeIt() { }
|
marci@168
|
528 |
//FIXME
|
marci@174
|
529 |
OutEdgeIt(const Edge& e) : Edge(e) { }
|
marci@174
|
530 |
OutEdgeIt(const Invalid& i) : Edge(i) { }
|
marci@155
|
531 |
private:
|
marci@174
|
532 |
OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
|
marci@212
|
533 |
resG.graph->first(out, v);
|
marci@174
|
534 |
while( resG.graph->valid(out) && !(resG.free(out)>0) ) { resG.graph->next(out); }
|
marci@174
|
535 |
if (!resG.graph->valid(out)) {
|
marci@155
|
536 |
out_or_in=0;
|
marci@212
|
537 |
resG.graph->first(in, v);
|
marci@174
|
538 |
while( resG.graph->valid(in) && !(resG.free(in)>0) ) { resG.graph->next(in); }
|
marci@155
|
539 |
}
|
marci@155
|
540 |
}
|
marci@168
|
541 |
// public:
|
marci@168
|
542 |
// OutEdgeIt& operator++() {
|
marci@168
|
543 |
// if (out_or_in) {
|
marci@174
|
544 |
// Node v=/*resG->*/G->aNode(out);
|
marci@168
|
545 |
// ++out;
|
marci@174
|
546 |
// while( out.valid() && !(Edge::free()>0) ) { ++out; }
|
marci@168
|
547 |
// if (!out.valid()) {
|
marci@168
|
548 |
// out_or_in=0;
|
marci@212
|
549 |
// G->first(in, v);
|
marci@174
|
550 |
// while( in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
551 |
// }
|
marci@168
|
552 |
// } else {
|
marci@168
|
553 |
// ++in;
|
marci@174
|
554 |
// while( in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
555 |
// }
|
marci@168
|
556 |
// return *this;
|
marci@168
|
557 |
// }
|
marci@155
|
558 |
};
|
marci@155
|
559 |
|
marci@174
|
560 |
class EdgeIt : public Edge {
|
marci@155
|
561 |
friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
|
marci@174
|
562 |
typename Graph::NodeIt v;
|
marci@155
|
563 |
public:
|
marci@174
|
564 |
EdgeIt() { }
|
marci@174
|
565 |
//EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
|
marci@174
|
566 |
EdgeIt(const Invalid& i) : Edge(i) { }
|
marci@174
|
567 |
EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() {
|
marci@212
|
568 |
resG.graph->first(v);
|
marci@212
|
569 |
if (resG.graph->valid(v)) resG.graph->first(out, v); else out=OldOutEdgeIt(INVALID);
|
marci@174
|
570 |
while (resG.graph->valid(out) && !(resG.free(out)>0) ) { resG.graph->next(out); }
|
marci@174
|
571 |
while (resG.graph->valid(v) && !resG.graph->valid(out)) {
|
marci@174
|
572 |
resG.graph->next(v);
|
marci@212
|
573 |
if (resG.graph->valid(v)) resG.graph->first(out, v);
|
marci@174
|
574 |
while (resG.graph->valid(out) && !(resG.free(out)>0) ) { resG.graph->next(out); }
|
marci@155
|
575 |
}
|
marci@174
|
576 |
if (!resG.graph->valid(out)) {
|
marci@155
|
577 |
out_or_in=0;
|
marci@212
|
578 |
resG.graph->first(v);
|
marci@212
|
579 |
if (resG.graph->valid(v)) resG.graph->first(in, v); else in=OldInEdgeIt(INVALID);
|
marci@174
|
580 |
while (resG.graph->valid(in) && !(resG.free(in)>0) ) { resG.graph->next(in); }
|
marci@174
|
581 |
while (resG.graph->valid(v) && !resG.graph->valid(in)) {
|
marci@174
|
582 |
resG.graph->next(v);
|
marci@212
|
583 |
if (resG.graph->valid(v)) resG.graph->first(in, v);
|
marci@174
|
584 |
while (resG.graph->valid(in) && !(resG.free(in)>0) ) { resG.graph->next(in); }
|
marci@155
|
585 |
}
|
marci@155
|
586 |
}
|
marci@155
|
587 |
}
|
marci@174
|
588 |
// EdgeIt& operator++() {
|
marci@168
|
589 |
// if (out_or_in) {
|
marci@168
|
590 |
// ++out;
|
marci@174
|
591 |
// while (out.valid() && !(Edge::free()>0) ) { ++out; }
|
marci@168
|
592 |
// while (v.valid() && !out.valid()) {
|
marci@168
|
593 |
// ++v;
|
marci@212
|
594 |
// if (v.valid()) G->first(out, v);
|
marci@174
|
595 |
// while (out.valid() && !(Edge::free()>0) ) { ++out; }
|
marci@168
|
596 |
// }
|
marci@168
|
597 |
// if (!out.valid()) {
|
marci@168
|
598 |
// out_or_in=0;
|
marci@212
|
599 |
// G->first(v);
|
marci@212
|
600 |
// if (v.valid()) G->first(in, v); else in=OldInEdgeIt();
|
marci@174
|
601 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
602 |
// while (v.valid() && !in.valid()) {
|
marci@168
|
603 |
// ++v;
|
marci@212
|
604 |
// if (v.valid()) G->first(in, v);
|
marci@174
|
605 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
606 |
// }
|
marci@168
|
607 |
// }
|
marci@168
|
608 |
// } else {
|
marci@168
|
609 |
// ++in;
|
marci@174
|
610 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
611 |
// while (v.valid() && !in.valid()) {
|
marci@168
|
612 |
// ++v;
|
marci@212
|
613 |
// if (v.valid()) G->first(in, v);
|
marci@174
|
614 |
// while (in.valid() && !(Edge::free()>0) ) { ++in; }
|
marci@168
|
615 |
// }
|
marci@168
|
616 |
// }
|
marci@168
|
617 |
// return *this;
|
marci@168
|
618 |
// }
|
marci@155
|
619 |
};
|
marci@155
|
620 |
|
marci@212
|
621 |
NodeIt& first(NodeIt& v) const { return graph->first(v); }
|
marci@212
|
622 |
OutEdgeIt& first(OutEdgeIt& e, Node v) const {
|
marci@168
|
623 |
e=OutEdgeIt(*this, v);
|
marci@174
|
624 |
return e;
|
marci@155
|
625 |
}
|
marci@212
|
626 |
EdgeIt& first(EdgeIt& e) const {
|
marci@174
|
627 |
e=EdgeIt(*this);
|
marci@174
|
628 |
return e;
|
marci@155
|
629 |
}
|
marci@155
|
630 |
|
marci@174
|
631 |
NodeIt& next(NodeIt& n) const { return graph->next(n); }
|
marci@155
|
632 |
|
marci@155
|
633 |
OutEdgeIt& next(OutEdgeIt& e) const {
|
marci@155
|
634 |
if (e.out_or_in) {
|
marci@174
|
635 |
Node v=graph->aNode(e.out);
|
marci@174
|
636 |
graph->next(e.out);
|
marci@174
|
637 |
while( graph->valid(e.out) && !(free(e.out)>0) ) { graph->next(e.out); }
|
marci@174
|
638 |
if (!graph->valid(e.out)) {
|
marci@155
|
639 |
e.out_or_in=0;
|
marci@212
|
640 |
graph->first(e.in, v);
|
marci@174
|
641 |
while( graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); }
|
marci@155
|
642 |
}
|
marci@155
|
643 |
} else {
|
marci@174
|
644 |
graph->next(e.in);
|
marci@174
|
645 |
while( graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); }
|
marci@155
|
646 |
}
|
marci@155
|
647 |
return e;
|
marci@155
|
648 |
}
|
marci@155
|
649 |
|
marci@174
|
650 |
EdgeIt& next(EdgeIt& e) const {
|
marci@155
|
651 |
if (e.out_or_in) {
|
marci@174
|
652 |
graph->next(e.out);
|
marci@174
|
653 |
while (graph->valid(e.out) && !(free(e.out)>0) ) { graph->next(e.out); }
|
marci@174
|
654 |
while (graph->valid(e.v) && !graph->valid(e.out)) {
|
marci@174
|
655 |
graph->next(e.v);
|
marci@212
|
656 |
if (graph->valid(e.v)) graph->first(e.out, e.v);
|
marci@174
|
657 |
while (graph->valid(e.out) && !(free(e.out)>0) ) { graph->next(e.out); }
|
marci@155
|
658 |
}
|
marci@174
|
659 |
if (!graph->valid(e.out)) {
|
marci@155
|
660 |
e.out_or_in=0;
|
marci@212
|
661 |
graph->first(e.v);
|
marci@212
|
662 |
if (graph->valid(e.v)) graph->first(e.in, e.v); else e.in=OldInEdgeIt(INVALID);
|
marci@174
|
663 |
while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); }
|
marci@174
|
664 |
while (graph->valid(e.v) && !graph->valid(e.in)) {
|
marci@174
|
665 |
graph->next(e.v);
|
marci@212
|
666 |
if (graph->valid(e.v)) graph->first(e.in, e.v);
|
marci@174
|
667 |
while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); }
|
marci@155
|
668 |
}
|
marci@155
|
669 |
}
|
marci@155
|
670 |
} else {
|
marci@174
|
671 |
graph->next(e.in);
|
marci@174
|
672 |
while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); }
|
marci@174
|
673 |
while (graph->valid(e.v) && !graph->valid(e.in)) {
|
marci@174
|
674 |
graph->next(e.v);
|
marci@212
|
675 |
if (graph->valid(e.v)) graph->first(e.in, e.v);
|
marci@174
|
676 |
while (graph->valid(e.in) && !(free(e.in)>0) ) { graph->next(e.in); }
|
marci@155
|
677 |
}
|
marci@155
|
678 |
}
|
marci@155
|
679 |
return e;
|
marci@155
|
680 |
}
|
marci@76
|
681 |
|
marci@76
|
682 |
|
marci@155
|
683 |
template< typename It >
|
marci@155
|
684 |
It first() const {
|
marci@155
|
685 |
It e;
|
marci@212
|
686 |
first(e);
|
marci@155
|
687 |
return e;
|
marci@155
|
688 |
}
|
marci@76
|
689 |
|
marci@155
|
690 |
template< typename It >
|
marci@174
|
691 |
It first(Node v) const {
|
marci@155
|
692 |
It e;
|
marci@212
|
693 |
first(e, v);
|
marci@155
|
694 |
return e;
|
marci@155
|
695 |
}
|
marci@76
|
696 |
|
marci@174
|
697 |
Node tail(Edge e) const {
|
marci@174
|
698 |
return ((e.out_or_in) ? graph->aNode(e.out) : graph->aNode(e.in)); }
|
marci@174
|
699 |
Node head(Edge e) const {
|
marci@174
|
700 |
return ((e.out_or_in) ? graph->bNode(e.out) : graph->bNode(e.in)); }
|
marci@76
|
701 |
|
marci@174
|
702 |
Node aNode(OutEdgeIt e) const {
|
marci@174
|
703 |
return ((e.out_or_in) ? graph->aNode(e.out) : graph->aNode(e.in)); }
|
marci@174
|
704 |
Node bNode(OutEdgeIt e) const {
|
marci@174
|
705 |
return ((e.out_or_in) ? graph->bNode(e.out) : graph->bNode(e.in)); }
|
marci@76
|
706 |
|
marci@174
|
707 |
int id(Node v) const { return graph->id(v); }
|
marci@155
|
708 |
|
marci@174
|
709 |
bool valid(Node n) const { return graph->valid(n); }
|
marci@174
|
710 |
bool valid(Edge e) const {
|
marci@174
|
711 |
return e.out_or_in ? graph->valid(e.out) : graph->valid(e.in); }
|
marci@155
|
712 |
|
marci@174
|
713 |
void augment(const Edge& e, Number a) const {
|
marci@168
|
714 |
if (e.out_or_in)
|
marci@168
|
715 |
flow->set(e.out, flow->get(e.out)+a);
|
marci@168
|
716 |
else
|
marci@168
|
717 |
flow->set(e.in, flow->get(e.in)-a);
|
marci@168
|
718 |
}
|
marci@168
|
719 |
|
marci@174
|
720 |
Number free(const Edge& e) const {
|
marci@168
|
721 |
if (e.out_or_in)
|
marci@168
|
722 |
return (capacity->get(e.out)-flow->get(e.out));
|
marci@168
|
723 |
else
|
marci@168
|
724 |
return (flow->get(e.in));
|
marci@168
|
725 |
}
|
marci@168
|
726 |
|
marci@168
|
727 |
Number free(OldOutEdgeIt out) const {
|
marci@168
|
728 |
return (capacity->get(out)-flow->get(out));
|
marci@168
|
729 |
}
|
marci@168
|
730 |
|
marci@168
|
731 |
Number free(OldInEdgeIt in) const {
|
marci@168
|
732 |
return (flow->get(in));
|
marci@168
|
733 |
}
|
marci@168
|
734 |
|
marci@155
|
735 |
template<typename T> class NodeMap : public Graph::NodeMap<T> {
|
marci@155
|
736 |
public:
|
marci@155
|
737 |
NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G)
|
marci@158
|
738 |
: Graph::NodeMap<T>(_G.getGraph()) { }
|
marci@155
|
739 |
NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G,
|
marci@158
|
740 |
T a) : Graph::NodeMap<T>(_G.getGraph(), a) { }
|
marci@155
|
741 |
};
|
marci@155
|
742 |
|
marci@155
|
743 |
// template <typename T>
|
marci@155
|
744 |
// class NodeMap {
|
marci@155
|
745 |
// typename Graph::NodeMap<T> node_map;
|
marci@155
|
746 |
// public:
|
marci@174
|
747 |
// NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(*(_G.graph)) { }
|
marci@174
|
748 |
// NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(*(_G.graph), a) { }
|
marci@174
|
749 |
// void set(Node nit, T a) { node_map.set(nit, a); }
|
marci@174
|
750 |
// T get(Node nit) const { return node_map.get(nit); }
|
marci@155
|
751 |
// };
|
marci@155
|
752 |
|
marci@155
|
753 |
template <typename T>
|
marci@155
|
754 |
class EdgeMap {
|
marci@155
|
755 |
typename Graph::EdgeMap<T> forward_map, backward_map;
|
marci@155
|
756 |
public:
|
marci@158
|
757 |
EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.getGraph()), backward_map(_G.getGraph()) { }
|
marci@158
|
758 |
EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.getGraph(), a), backward_map(_G.getGraph(), a) { }
|
marci@174
|
759 |
void set(Edge e, T a) {
|
marci@155
|
760 |
if (e.out_or_in)
|
marci@155
|
761 |
forward_map.set(e.out, a);
|
marci@155
|
762 |
else
|
marci@155
|
763 |
backward_map.set(e.in, a);
|
marci@155
|
764 |
}
|
marci@174
|
765 |
T get(Edge e) {
|
marci@155
|
766 |
if (e.out_or_in)
|
marci@155
|
767 |
return forward_map.get(e.out);
|
marci@155
|
768 |
else
|
marci@155
|
769 |
return backward_map.get(e.in);
|
marci@155
|
770 |
}
|
marci@155
|
771 |
};
|
marci@168
|
772 |
};
|
marci@168
|
773 |
|
marci@168
|
774 |
template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
|
marci@168
|
775 |
class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
|
marci@168
|
776 |
protected:
|
marci@168
|
777 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
|
marci@168
|
778 |
//ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
|
marci@168
|
779 |
public:
|
marci@168
|
780 |
ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow,
|
marci@168
|
781 |
const CapacityMap& _capacity) :
|
marci@168
|
782 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity),
|
marci@168
|
783 |
first_out_edges(*this) /*, dist(*this)*/ {
|
marci@174
|
784 |
for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
|
marci@168
|
785 |
OutEdgeIt e;
|
marci@212
|
786 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
|
marci@168
|
787 |
first_out_edges.set(n, e);
|
marci@168
|
788 |
}
|
marci@168
|
789 |
}
|
marci@168
|
790 |
|
marci@168
|
791 |
//void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@168
|
792 |
//Graph& getGraph() const { return (*graph); }
|
marci@168
|
793 |
|
marci@168
|
794 |
//TrivGraphWrapper() : graph(0) { }
|
marci@168
|
795 |
//ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@168
|
796 |
|
marci@168
|
797 |
//typedef Graph BaseGraph;
|
marci@168
|
798 |
|
marci@174
|
799 |
//typedef typename Graph::Node Node;
|
marci@168
|
800 |
//typedef typename Graph::NodeIt NodeIt;
|
marci@168
|
801 |
|
marci@174
|
802 |
//typedef typename Graph::Edge Edge;
|
marci@168
|
803 |
//typedef typename Graph::OutEdgeIt OutEdgeIt;
|
marci@168
|
804 |
//typedef typename Graph::InEdgeIt InEdgeIt;
|
marci@168
|
805 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
806 |
//typedef typename Graph::EdgeIt EdgeIt;
|
marci@168
|
807 |
|
marci@174
|
808 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
|
marci@168
|
809 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
|
marci@168
|
810 |
|
marci@174
|
811 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
|
marci@168
|
812 |
typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
|
marci@168
|
813 |
//typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
|
marci@168
|
814 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
815 |
//typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
|
marci@168
|
816 |
|
marci@212
|
817 |
NodeIt& first(NodeIt& n) const {
|
marci@212
|
818 |
return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
|
marci@168
|
819 |
}
|
marci@168
|
820 |
|
marci@212
|
821 |
OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
|
marci@168
|
822 |
e=first_out_edges.get(n);
|
marci@168
|
823 |
return e;
|
marci@168
|
824 |
}
|
marci@168
|
825 |
|
marci@212
|
826 |
//ROSSZ template<typename I> I& first(I& i) const { return first(i); }
|
marci@212
|
827 |
//ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
828 |
// return first(i, p); }
|
marci@168
|
829 |
|
marci@168
|
830 |
//template<typename I> I getNext(const I& i) const {
|
marci@168
|
831 |
// return graph->getNext(i); }
|
marci@168
|
832 |
//template<typename I> I& next(I &i) const { return graph->next(i); }
|
marci@168
|
833 |
|
marci@168
|
834 |
template< typename It > It first() const {
|
marci@212
|
835 |
It e; first(e); return e; }
|
marci@168
|
836 |
|
marci@174
|
837 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
838 |
It e; first(e, v); return e; }
|
marci@168
|
839 |
|
marci@174
|
840 |
//Node head(const Edge& e) const { return graph->head(e); }
|
marci@174
|
841 |
//Node tail(const Edge& e) const { return graph->tail(e); }
|
marci@168
|
842 |
|
marci@168
|
843 |
//template<typename I> bool valid(const I& i) const
|
marci@168
|
844 |
// { return graph->valid(i); }
|
marci@168
|
845 |
|
marci@168
|
846 |
//int nodeNum() const { return graph->nodeNum(); }
|
marci@168
|
847 |
//int edgeNum() const { return graph->edgeNum(); }
|
marci@168
|
848 |
|
marci@174
|
849 |
//template<typename I> Node aNode(const I& e) const {
|
marci@168
|
850 |
// return graph->aNode(e); }
|
marci@174
|
851 |
//template<typename I> Node bNode(const I& e) const {
|
marci@168
|
852 |
// return graph->bNode(e); }
|
marci@168
|
853 |
|
marci@174
|
854 |
//Node addNode() const { return graph->addNode(); }
|
marci@174
|
855 |
//Edge addEdge(const Node& tail, const Node& head) const {
|
marci@168
|
856 |
// return graph->addEdge(tail, head); }
|
marci@168
|
857 |
|
marci@168
|
858 |
//void erase(const OutEdgeIt& e) {
|
marci@168
|
859 |
// first_out_edge(this->tail(e))=e;
|
marci@168
|
860 |
//}
|
marci@174
|
861 |
void erase(const Edge& e) {
|
marci@168
|
862 |
OutEdgeIt f(e);
|
marci@168
|
863 |
next(f);
|
marci@168
|
864 |
first_out_edges.set(this->tail(e), f);
|
marci@168
|
865 |
}
|
marci@168
|
866 |
//template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@168
|
867 |
|
marci@168
|
868 |
//void clear() const { graph->clear(); }
|
marci@168
|
869 |
|
marci@168
|
870 |
template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
|
marci@168
|
871 |
public:
|
marci@168
|
872 |
NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
|
marci@168
|
873 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
874 |
NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
|
marci@168
|
875 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
876 |
};
|
marci@168
|
877 |
|
marci@168
|
878 |
template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
|
marci@168
|
879 |
public:
|
marci@168
|
880 |
EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
|
marci@168
|
881 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
882 |
EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
|
marci@168
|
883 |
ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
884 |
};
|
marci@168
|
885 |
};
|
marci@168
|
886 |
|
marci@168
|
887 |
template<typename GraphWrapper>
|
marci@168
|
888 |
class FilterGraphWrapper {
|
marci@168
|
889 |
};
|
marci@168
|
890 |
|
marci@168
|
891 |
template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
|
marci@168
|
892 |
class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
|
marci@168
|
893 |
|
marci@168
|
894 |
//Graph* graph;
|
marci@168
|
895 |
|
marci@168
|
896 |
public:
|
marci@168
|
897 |
//typedef Graph BaseGraph;
|
marci@168
|
898 |
|
marci@174
|
899 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
|
marci@168
|
900 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
|
marci@168
|
901 |
|
marci@174
|
902 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
|
marci@168
|
903 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
|
marci@168
|
904 |
//typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
|
marci@168
|
905 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
906 |
typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
|
marci@168
|
907 |
|
marci@168
|
908 |
//FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
|
marci@168
|
909 |
|
marci@168
|
910 |
public:
|
marci@168
|
911 |
FilterGraphWrapper(const Graph& _G, FlowMap& _flow,
|
marci@168
|
912 |
const CapacityMap& _capacity) :
|
marci@199
|
913 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, graph->nodeNum()) {
|
marci@168
|
914 |
}
|
marci@168
|
915 |
|
marci@212
|
916 |
OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
|
marci@212
|
917 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
|
marci@199
|
918 |
while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e))))
|
marci@168
|
919 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@168
|
920 |
return e;
|
marci@168
|
921 |
}
|
marci@168
|
922 |
|
marci@174
|
923 |
NodeIt& next(NodeIt& e) const {
|
marci@168
|
924 |
return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@168
|
925 |
}
|
marci@168
|
926 |
|
marci@168
|
927 |
OutEdgeIt& next(OutEdgeIt& e) const {
|
marci@168
|
928 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@199
|
929 |
while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e))))
|
marci@168
|
930 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
|
marci@168
|
931 |
return e;
|
marci@168
|
932 |
}
|
marci@168
|
933 |
|
marci@212
|
934 |
NodeIt& first(NodeIt& n) const {
|
marci@212
|
935 |
return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
|
marci@168
|
936 |
}
|
marci@168
|
937 |
|
marci@174
|
938 |
void erase(const Edge& e) {
|
marci@168
|
939 |
OutEdgeIt f(e);
|
marci@168
|
940 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
|
marci@199
|
941 |
while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f))))
|
marci@168
|
942 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
|
marci@168
|
943 |
first_out_edges.set(this->tail(e), f);
|
marci@168
|
944 |
}
|
marci@168
|
945 |
|
marci@168
|
946 |
//TrivGraphWrapper() : graph(0) { }
|
marci@168
|
947 |
//TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@168
|
948 |
|
marci@168
|
949 |
//void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@168
|
950 |
//Graph& getGraph() const { return (*graph); }
|
marci@168
|
951 |
|
marci@212
|
952 |
//template<typename I> I& first(I& i) const { return graph->first(i); }
|
marci@212
|
953 |
//template<typename I, typename P> I& first(I& i, const P& p) const {
|
marci@212
|
954 |
// return graph->first(i, p); }
|
marci@168
|
955 |
|
marci@168
|
956 |
//template<typename I> I getNext(const I& i) const {
|
marci@168
|
957 |
// return graph->getNext(i); }
|
marci@168
|
958 |
//template<typename I> I& next(I &i) const { return graph->next(i); }
|
marci@168
|
959 |
|
marci@168
|
960 |
template< typename It > It first() const {
|
marci@212
|
961 |
It e; first(e); return e; }
|
marci@168
|
962 |
|
marci@174
|
963 |
template< typename It > It first(const Node& v) const {
|
marci@212
|
964 |
It e; first(e, v); return e; }
|
marci@168
|
965 |
|
marci@174
|
966 |
//Node head(const Edge& e) const { return graph->head(e); }
|
marci@174
|
967 |
//Node tail(const Edge& e) const { return graph->tail(e); }
|
marci@168
|
968 |
|
marci@168
|
969 |
//template<typename I> bool valid(const I& i) const
|
marci@168
|
970 |
// { return graph->valid(i); }
|
marci@168
|
971 |
|
marci@168
|
972 |
//template<typename I> void setInvalid(const I &i);
|
marci@168
|
973 |
//{ return graph->setInvalid(i); }
|
marci@168
|
974 |
|
marci@168
|
975 |
//int nodeNum() const { return graph->nodeNum(); }
|
marci@168
|
976 |
//int edgeNum() const { return graph->edgeNum(); }
|
marci@168
|
977 |
|
marci@174
|
978 |
//template<typename I> Node aNode(const I& e) const {
|
marci@168
|
979 |
// return graph->aNode(e); }
|
marci@174
|
980 |
//template<typename I> Node bNode(const I& e) const {
|
marci@168
|
981 |
// return graph->bNode(e); }
|
marci@168
|
982 |
|
marci@174
|
983 |
//Node addNode() const { return graph->addNode(); }
|
marci@174
|
984 |
//Edge addEdge(const Node& tail, const Node& head) const {
|
marci@168
|
985 |
// return graph->addEdge(tail, head); }
|
marci@168
|
986 |
|
marci@168
|
987 |
//template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@168
|
988 |
|
marci@168
|
989 |
//void clear() const { graph->clear(); }
|
marci@168
|
990 |
|
marci@168
|
991 |
template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
|
marci@168
|
992 |
public:
|
marci@168
|
993 |
NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
|
marci@168
|
994 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
995 |
NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
|
marci@168
|
996 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
997 |
};
|
marci@168
|
998 |
|
marci@168
|
999 |
template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
|
marci@168
|
1000 |
public:
|
marci@168
|
1001 |
EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
|
marci@168
|
1002 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
|
marci@168
|
1003 |
EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
|
marci@168
|
1004 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
|
marci@168
|
1005 |
};
|
marci@168
|
1006 |
|
marci@168
|
1007 |
public:
|
marci@168
|
1008 |
ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
|
marci@155
|
1009 |
|
marci@76
|
1010 |
};
|
marci@76
|
1011 |
|
marci@76
|
1012 |
|
marci@148
|
1013 |
|
marci@148
|
1014 |
// // FIXME: comparison should be made better!!!
|
marci@148
|
1015 |
// template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
|
marci@148
|
1016 |
// class ResGraphWrapper
|
marci@148
|
1017 |
// {
|
marci@148
|
1018 |
// Graph* graph;
|
marci@76
|
1019 |
|
marci@148
|
1020 |
// public:
|
marci@148
|
1021 |
// typedef Graph BaseGraph;
|
marci@76
|
1022 |
|
marci@174
|
1023 |
// typedef typename Graph::Node Node;
|
marci@174
|
1024 |
// typedef typename Graph::Edge Edge;
|
marci@174
|
1025 |
|
marci@148
|
1026 |
// typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
1027 |
|
marci@148
|
1028 |
// class OutEdgeIt {
|
marci@148
|
1029 |
// public:
|
marci@174
|
1030 |
// //Graph::Node n;
|
marci@148
|
1031 |
// bool out_or_in;
|
marci@148
|
1032 |
// typename Graph::OutEdgeIt o;
|
marci@148
|
1033 |
// typename Graph::InEdgeIt i;
|
marci@148
|
1034 |
// };
|
marci@148
|
1035 |
// class InEdgeIt {
|
marci@148
|
1036 |
// public:
|
marci@174
|
1037 |
// //Graph::Node n;
|
marci@148
|
1038 |
// bool out_or_in;
|
marci@148
|
1039 |
// typename Graph::OutEdgeIt o;
|
marci@148
|
1040 |
// typename Graph::InEdgeIt i;
|
marci@148
|
1041 |
// };
|
marci@148
|
1042 |
// typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@174
|
1043 |
// typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
1044 |
|
marci@148
|
1045 |
// int nodeNum() const { return graph->nodeNum(); }
|
marci@148
|
1046 |
// int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
1047 |
|
marci@212
|
1048 |
// Node& first(Node& n) const { return graph->first(n); }
|
marci@76
|
1049 |
|
marci@174
|
1050 |
// // Edge and SymEdge is missing!!!!
|
marci@174
|
1051 |
// // Edge <-> In/OutEdgeIt conversion is missing!!!!
|
marci@76
|
1052 |
|
marci@148
|
1053 |
// //FIXME
|
marci@212
|
1054 |
// OutEdgeIt& first(OutEdgeIt& e, const Node& n) const
|
marci@148
|
1055 |
// {
|
marci@148
|
1056 |
// e.n=n;
|
marci@212
|
1057 |
// graph->first(e.o,n);
|
marci@148
|
1058 |
// while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@148
|
1059 |
// graph->goNext(e.o);
|
marci@148
|
1060 |
// if(!graph->valid(e.o)) {
|
marci@212
|
1061 |
// graph->first(e.i,n);
|
marci@148
|
1062 |
// while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@148
|
1063 |
// graph->goNext(e.i);
|
marci@148
|
1064 |
// }
|
marci@148
|
1065 |
// return e;
|
marci@148
|
1066 |
// }
|
marci@148
|
1067 |
// /*
|
marci@148
|
1068 |
// OutEdgeIt &goNext(OutEdgeIt &e)
|
marci@148
|
1069 |
// {
|
marci@148
|
1070 |
// if(graph->valid(e.o)) {
|
marci@148
|
1071 |
// while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@148
|
1072 |
// graph->goNext(e.o);
|
marci@148
|
1073 |
// if(graph->valid(e.o)) return e;
|
marci@212
|
1074 |
// else graph->first(e.i,e.n);
|
marci@148
|
1075 |
// }
|
marci@148
|
1076 |
// else {
|
marci@148
|
1077 |
// while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@148
|
1078 |
// graph->goNext(e.i);
|
marci@148
|
1079 |
// return e;
|
marci@148
|
1080 |
// }
|
marci@148
|
1081 |
// }
|
marci@148
|
1082 |
// OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
|
marci@148
|
1083 |
// */
|
marci@148
|
1084 |
// //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
|
marci@76
|
1085 |
|
marci@148
|
1086 |
// //FIXME
|
marci@212
|
1087 |
// InEdgeIt& first(InEdgeIt& e, const Node& n) const
|
marci@148
|
1088 |
// {
|
marci@148
|
1089 |
// e.n=n;
|
marci@212
|
1090 |
// graph->first(e.i,n);
|
marci@148
|
1091 |
// while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@148
|
1092 |
// graph->goNext(e.i);
|
marci@148
|
1093 |
// if(!graph->valid(e.i)) {
|
marci@212
|
1094 |
// graph->first(e.o,n);
|
marci@148
|
1095 |
// while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@148
|
1096 |
// graph->goNext(e.o);
|
marci@148
|
1097 |
// }
|
marci@148
|
1098 |
// return e;
|
marci@148
|
1099 |
// }
|
marci@148
|
1100 |
// /*
|
marci@148
|
1101 |
// InEdgeIt &goNext(InEdgeIt &e)
|
marci@148
|
1102 |
// {
|
marci@148
|
1103 |
// if(graph->valid(e.i)) {
|
marci@148
|
1104 |
// while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@148
|
1105 |
// graph->goNext(e.i);
|
marci@148
|
1106 |
// if(graph->valid(e.i)) return e;
|
marci@212
|
1107 |
// else graph->first(e.o,e.n);
|
marci@148
|
1108 |
// }
|
marci@148
|
1109 |
// else {
|
marci@148
|
1110 |
// while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@148
|
1111 |
// graph->goNext(e.o);
|
marci@148
|
1112 |
// return e;
|
marci@148
|
1113 |
// }
|
marci@148
|
1114 |
// }
|
marci@148
|
1115 |
// InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
|
marci@148
|
1116 |
// */
|
marci@148
|
1117 |
// //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
|
marci@76
|
1118 |
|
marci@148
|
1119 |
// //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@148
|
1120 |
// //template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@76
|
1121 |
|
marci@148
|
1122 |
// template< typename It > It first() const {
|
marci@212
|
1123 |
// It e; first(e); return e; }
|
marci@76
|
1124 |
|
marci@174
|
1125 |
// template< typename It > It first(Node v) const {
|
marci@212
|
1126 |
// It e; first(e, v); return e; }
|
marci@76
|
1127 |
|
marci@174
|
1128 |
// Node head(const Edge& e) const { return graph->head(e); }
|
marci@174
|
1129 |
// Node tail(const Edge& e) const { return graph->tail(e); }
|
marci@76
|
1130 |
|
marci@174
|
1131 |
// template<typename I> Node aNode(const I& e) const {
|
marci@148
|
1132 |
// return graph->aNode(e); }
|
marci@174
|
1133 |
// template<typename I> Node bNode(const I& e) const {
|
marci@148
|
1134 |
// return graph->bNode(e); }
|
marci@76
|
1135 |
|
marci@148
|
1136 |
// //template<typename I> bool valid(const I i);
|
marci@148
|
1137 |
// //{ return graph->valid(i); }
|
marci@76
|
1138 |
|
marci@148
|
1139 |
// //template<typename I> void setInvalid(const I &i);
|
marci@148
|
1140 |
// //{ return graph->setInvalid(i); }
|
marci@76
|
1141 |
|
marci@174
|
1142 |
// Node addNode() { return graph->addNode(); }
|
marci@174
|
1143 |
// Edge addEdge(const Node& tail, const Node& head) {
|
marci@148
|
1144 |
// return graph->addEdge(tail, head); }
|
marci@76
|
1145 |
|
marci@148
|
1146 |
// template<typename I> void erase(const I& i) { graph->erase(i); }
|
marci@76
|
1147 |
|
marci@148
|
1148 |
// void clear() { graph->clear(); }
|
marci@76
|
1149 |
|
marci@148
|
1150 |
// template<typename S> class NodeMap : public Graph::NodeMap<S> { };
|
marci@148
|
1151 |
// template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
|
marci@76
|
1152 |
|
marci@148
|
1153 |
// void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@148
|
1154 |
// Graph& getGraph() { return (*graph); }
|
marci@76
|
1155 |
|
marci@148
|
1156 |
// //ResGraphWrapper() : graph(0) { }
|
marci@148
|
1157 |
// ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@148
|
1158 |
// };
|
marci@76
|
1159 |
|
alpar@105
|
1160 |
} //namespace hugo
|
marci@76
|
1161 |
|
marci@76
|
1162 |
#endif //GRAPH_WRAPPER_H
|
marci@76
|
1163 |
|