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