marci@76
|
1 |
// -*-mode: c++; -*-
|
marci@76
|
2 |
#ifndef GRAPH_WRAPPER_H
|
marci@76
|
3 |
#define GRAPH_WRAPPER_H
|
marci@76
|
4 |
|
alpar@105
|
5 |
namespace hugo {
|
marci@76
|
6 |
|
marci@76
|
7 |
template<typename Graph>
|
marci@76
|
8 |
class TrivGraphWrapper {
|
marci@76
|
9 |
Graph* graph;
|
marci@76
|
10 |
|
marci@76
|
11 |
public:
|
marci@76
|
12 |
typedef Graph BaseGraph;
|
marci@76
|
13 |
|
marci@76
|
14 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
15 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
16 |
|
marci@76
|
17 |
typedef typename Graph::EachNodeIt EachNodeIt;
|
marci@76
|
18 |
|
marci@76
|
19 |
typedef typename Graph::OutEdgeIt OutEdgeIt;
|
marci@76
|
20 |
typedef typename Graph::InEdgeIt InEdgeIt;
|
marci@76
|
21 |
typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@76
|
22 |
typedef typename Graph::EachEdgeIt EachEdgeIt;
|
marci@76
|
23 |
|
marci@76
|
24 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@76
|
25 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
26 |
|
marci@76
|
27 |
template<typename I> I& getFirst(I& i) const { return graph->getFirst(i); }
|
marci@76
|
28 |
template<typename I, typename P> I& getFirst(I& i, const P& p) const {
|
marci@76
|
29 |
return graph->getFirst(i, p); }
|
marci@76
|
30 |
//template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@76
|
31 |
//template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@76
|
32 |
|
marci@76
|
33 |
template< typename It > It first() const {
|
marci@76
|
34 |
It e; getFirst(e); return e; }
|
marci@76
|
35 |
|
marci@76
|
36 |
template< typename It > It first(NodeIt v) const {
|
marci@76
|
37 |
It e; getFirst(e, v); return e; }
|
marci@76
|
38 |
|
marci@76
|
39 |
NodeIt head(const EdgeIt& e) const { return graph->head(e); }
|
marci@76
|
40 |
NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
|
marci@76
|
41 |
|
marci@76
|
42 |
template<typename I> NodeIt aNode(const I& e) const {
|
marci@76
|
43 |
return graph->aNode(e); }
|
marci@76
|
44 |
template<typename I> NodeIt bNode(const I& e) const {
|
marci@76
|
45 |
return graph->bNode(e); }
|
marci@76
|
46 |
|
marci@76
|
47 |
//template<typename I> bool valid(const I& i)
|
marci@76
|
48 |
//{ return graph->valid(i); }
|
marci@76
|
49 |
|
marci@76
|
50 |
//template<typename I> void setInvalid(const I &i);
|
marci@76
|
51 |
//{ return graph->setInvalid(i); }
|
marci@76
|
52 |
|
marci@76
|
53 |
NodeIt addNode() const { return graph->addNode(); }
|
marci@76
|
54 |
EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) const {
|
marci@76
|
55 |
return graph->addEdge(tail, head); }
|
marci@76
|
56 |
|
marci@76
|
57 |
template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@76
|
58 |
|
marci@76
|
59 |
void clear() const { graph->clear(); }
|
marci@76
|
60 |
|
marci@76
|
61 |
template<typename T> class NodeMap : public Graph::NodeMap<T> {
|
marci@76
|
62 |
public:
|
marci@76
|
63 |
NodeMap(const Graph& _G) : Graph::NodeMap<T>(_G) { }
|
marci@76
|
64 |
NodeMap(const Graph& _G, T a) : Graph::NodeMap<T>(_G, a) { }
|
marci@76
|
65 |
};
|
marci@76
|
66 |
template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
|
marci@76
|
67 |
|
marci@76
|
68 |
void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@76
|
69 |
Graph& getGraph() { return (*graph); }
|
marci@76
|
70 |
|
marci@76
|
71 |
//TrivGraphWrapper() : graph(0) { }
|
marci@76
|
72 |
TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@76
|
73 |
};
|
marci@76
|
74 |
|
marci@76
|
75 |
template<typename Graph>
|
marci@76
|
76 |
class ConstTrivGraphWrapper {
|
marci@76
|
77 |
const Graph* graph;
|
marci@76
|
78 |
|
marci@76
|
79 |
public:
|
marci@76
|
80 |
typedef Graph BaseGraph;
|
marci@76
|
81 |
|
marci@76
|
82 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
83 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
84 |
|
marci@76
|
85 |
typedef typename Graph::EachNodeIt EachNodeIt;
|
marci@76
|
86 |
|
marci@76
|
87 |
typedef typename Graph::OutEdgeIt OutEdgeIt;
|
marci@76
|
88 |
typedef typename Graph::InEdgeIt InEdgeIt;
|
marci@76
|
89 |
typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@76
|
90 |
typedef typename Graph::EachEdgeIt EachEdgeIt;
|
marci@76
|
91 |
|
marci@76
|
92 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@76
|
93 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
94 |
|
marci@76
|
95 |
template<typename I> I& getFirst(I& i) const { return graph->getFirst(i); }
|
marci@76
|
96 |
template<typename I, typename P> I& getFirst(I& i, const P& p) const {
|
marci@76
|
97 |
return graph->getFirst(i, p); }
|
marci@76
|
98 |
//template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@76
|
99 |
//template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@76
|
100 |
|
marci@76
|
101 |
template< typename It > It first() const {
|
marci@76
|
102 |
It e; getFirst(e); return e; }
|
marci@76
|
103 |
|
marci@76
|
104 |
template< typename It > It first(NodeIt v) const {
|
marci@76
|
105 |
It e; getFirst(e, v); return e; }
|
marci@76
|
106 |
|
marci@76
|
107 |
NodeIt head(const EdgeIt& e) const { return graph->head(e); }
|
marci@76
|
108 |
NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
|
marci@76
|
109 |
|
marci@76
|
110 |
template<typename I> NodeIt aNode(const I& e) const {
|
marci@76
|
111 |
return graph->aNode(e); }
|
marci@76
|
112 |
template<typename I> NodeIt bNode(const I& e) const {
|
marci@76
|
113 |
return graph->bNode(e); }
|
marci@76
|
114 |
|
marci@76
|
115 |
//template<typename I> bool valid(const I& i)
|
marci@76
|
116 |
//{ return graph->valid(i); }
|
marci@76
|
117 |
|
marci@76
|
118 |
//template<typename I> void setInvalid(const I &i);
|
marci@76
|
119 |
//{ return graph->setInvalid(i); }
|
marci@76
|
120 |
|
marci@76
|
121 |
NodeIt addNode() const { return graph->addNode(); }
|
marci@76
|
122 |
EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) const {
|
marci@76
|
123 |
return graph->addEdge(tail, head); }
|
marci@76
|
124 |
|
marci@76
|
125 |
template<typename I> void erase(const I& i) const { graph->erase(i); }
|
marci@76
|
126 |
|
marci@76
|
127 |
void clear() const { graph->clear(); }
|
marci@76
|
128 |
|
marci@76
|
129 |
template<typename T> class NodeMap : public Graph::NodeMap<T> {
|
marci@76
|
130 |
public:
|
marci@76
|
131 |
NodeMap(const Graph& _G) : Graph::NodeMap<T>(_G) { }
|
marci@76
|
132 |
NodeMap(const Graph& _G, T a) : Graph::NodeMap<T>(_G, a) { }
|
marci@76
|
133 |
};
|
marci@76
|
134 |
template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
|
marci@76
|
135 |
|
marci@76
|
136 |
void setGraph(const Graph& _graph) { graph = &_graph; }
|
marci@76
|
137 |
const Graph& getGraph() { return (*graph); }
|
marci@76
|
138 |
|
marci@76
|
139 |
//ConstTrivGraphWrapper() : graph(0) { }
|
marci@76
|
140 |
ConstTrivGraphWrapper(const Graph& _graph) : graph(&_graph) { }
|
marci@76
|
141 |
};
|
marci@76
|
142 |
|
marci@76
|
143 |
|
marci@76
|
144 |
template<typename Graph>
|
marci@76
|
145 |
class RevGraphWrapper
|
marci@76
|
146 |
{
|
marci@76
|
147 |
Graph* graph;
|
marci@76
|
148 |
|
marci@76
|
149 |
public:
|
marci@76
|
150 |
typedef Graph BaseGraph;
|
marci@76
|
151 |
|
marci@76
|
152 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
153 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
154 |
|
marci@76
|
155 |
typedef typename Graph::EachNodeIt EachNodeIt;
|
marci@76
|
156 |
|
marci@76
|
157 |
typedef typename Graph::OutEdgeIt InEdgeIt;
|
marci@76
|
158 |
typedef typename Graph::InEdgeIt OutEdgeIt;
|
marci@76
|
159 |
typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@76
|
160 |
typedef typename Graph::EachEdgeIt EachEdgeIt;
|
marci@76
|
161 |
|
marci@76
|
162 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@76
|
163 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
164 |
|
marci@76
|
165 |
template<typename I> I& getFirst(I& i) const { return graph->getFirst(i); }
|
marci@76
|
166 |
template<typename I, typename P> I& getFirst(I& i, const P& p) const {
|
marci@76
|
167 |
return graph->getFirst(i, p); }
|
marci@76
|
168 |
//template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@76
|
169 |
//template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@76
|
170 |
|
marci@76
|
171 |
template< typename It > It first() const {
|
marci@76
|
172 |
It e; getFirst(e); return e; }
|
marci@76
|
173 |
|
marci@76
|
174 |
template< typename It > It first(NodeIt v) const {
|
marci@76
|
175 |
It e; getFirst(e, v); return e; }
|
marci@76
|
176 |
|
marci@76
|
177 |
NodeIt head(const EdgeIt& e) const { return graph->tail(e); }
|
marci@76
|
178 |
NodeIt tail(const EdgeIt& e) const { return graph->head(e); }
|
marci@76
|
179 |
|
marci@76
|
180 |
template<typename I> NodeIt aNode(const I& e) const {
|
marci@76
|
181 |
return graph->aNode(e); }
|
marci@76
|
182 |
template<typename I> NodeIt bNode(const I& e) const {
|
marci@76
|
183 |
return graph->bNode(e); }
|
marci@76
|
184 |
|
marci@76
|
185 |
//template<typename I> bool valid(const I i);
|
marci@76
|
186 |
//{ return graph->valid(i); }
|
marci@76
|
187 |
|
marci@76
|
188 |
//template<typename I> void setInvalid(const I &i);
|
marci@76
|
189 |
//{ return graph->setInvalid(i); }
|
marci@76
|
190 |
|
marci@76
|
191 |
NodeIt addNode() { return graph->addNode(); }
|
marci@76
|
192 |
EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) {
|
marci@76
|
193 |
return graph->addEdge(tail, head); }
|
marci@76
|
194 |
|
marci@76
|
195 |
template<typename I> void erase(const I& i) { graph->erase(i); }
|
marci@76
|
196 |
|
marci@76
|
197 |
void clear() { graph->clear(); }
|
marci@76
|
198 |
|
marci@76
|
199 |
template<typename T> class NodeMap : public Graph::NodeMap<T> { };
|
marci@76
|
200 |
template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
|
marci@76
|
201 |
|
marci@76
|
202 |
void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@76
|
203 |
Graph& getGraph() { return (*graph); }
|
marci@76
|
204 |
|
marci@76
|
205 |
//RevGraphWrapper() : graph(0) { }
|
marci@76
|
206 |
RevGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@76
|
207 |
};
|
marci@76
|
208 |
|
marci@76
|
209 |
template<typename Graph>
|
marci@76
|
210 |
class SymGraphWrapper
|
marci@76
|
211 |
{
|
marci@76
|
212 |
Graph* graph;
|
marci@76
|
213 |
|
marci@76
|
214 |
public:
|
marci@76
|
215 |
typedef Graph BaseGraph;
|
marci@76
|
216 |
|
marci@76
|
217 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
218 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
219 |
|
marci@76
|
220 |
typedef typename Graph::EachNodeIt EachNodeIt;
|
marci@76
|
221 |
|
marci@76
|
222 |
//FIXME tag-ekkel megcsinalni, hogy abbol csinaljon
|
marci@76
|
223 |
//iranyitatlant, ami van
|
marci@76
|
224 |
//mert csak 1 dolgot lehet be typedef-elni
|
marci@76
|
225 |
typedef typename Graph::OutEdgeIt SymEdgeIt;
|
marci@76
|
226 |
//typedef typename Graph::InEdgeIt SymEdgeIt;
|
marci@76
|
227 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@76
|
228 |
typedef typename Graph::EachEdgeIt EachEdgeIt;
|
marci@76
|
229 |
|
marci@76
|
230 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@76
|
231 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
232 |
|
marci@76
|
233 |
template<typename I> I& getFirst(I& i) const { return graph->getFirst(i); }
|
marci@76
|
234 |
template<typename I, typename P> I& getFirst(I& i, const P& p) const {
|
marci@76
|
235 |
return graph->getFirst(i, p); }
|
marci@76
|
236 |
//template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@76
|
237 |
//template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@76
|
238 |
|
marci@76
|
239 |
template< typename It > It first() const {
|
marci@76
|
240 |
It e; getFirst(e); return e; }
|
marci@76
|
241 |
|
marci@76
|
242 |
template< typename It > It first(NodeIt v) const {
|
marci@76
|
243 |
It e; getFirst(e, v); return e; }
|
marci@76
|
244 |
|
marci@76
|
245 |
NodeIt head(const EdgeIt& e) const { return graph->head(e); }
|
marci@76
|
246 |
NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
|
marci@76
|
247 |
|
marci@76
|
248 |
template<typename I> NodeIt aNode(const I& e) const {
|
marci@76
|
249 |
return graph->aNode(e); }
|
marci@76
|
250 |
template<typename I> NodeIt bNode(const I& e) const {
|
marci@76
|
251 |
return graph->bNode(e); }
|
marci@76
|
252 |
|
marci@76
|
253 |
//template<typename I> bool valid(const I i);
|
marci@76
|
254 |
//{ return graph->valid(i); }
|
marci@76
|
255 |
|
marci@76
|
256 |
//template<typename I> void setInvalid(const I &i);
|
marci@76
|
257 |
//{ return graph->setInvalid(i); }
|
marci@76
|
258 |
|
marci@76
|
259 |
NodeIt addNode() { return graph->addNode(); }
|
marci@76
|
260 |
EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) {
|
marci@76
|
261 |
return graph->addEdge(tail, head); }
|
marci@76
|
262 |
|
marci@76
|
263 |
template<typename I> void erase(const I& i) { graph->erase(i); }
|
marci@76
|
264 |
|
marci@76
|
265 |
void clear() { graph->clear(); }
|
marci@76
|
266 |
|
marci@76
|
267 |
template<typename T> class NodeMap : public Graph::NodeMap<T> { };
|
marci@76
|
268 |
template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
|
marci@76
|
269 |
|
marci@76
|
270 |
void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@76
|
271 |
Graph& getGraph() { return (*graph); }
|
marci@76
|
272 |
|
marci@76
|
273 |
//SymGraphWrapper() : graph(0) { }
|
marci@76
|
274 |
SymGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@76
|
275 |
};
|
marci@76
|
276 |
|
marci@76
|
277 |
|
marci@76
|
278 |
// FIXME: comparison should be made better!!!
|
marci@76
|
279 |
template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
|
marci@76
|
280 |
class ResGraphWrapper
|
marci@76
|
281 |
{
|
marci@76
|
282 |
Graph* graph;
|
marci@76
|
283 |
|
marci@76
|
284 |
public:
|
marci@76
|
285 |
typedef Graph BaseGraph;
|
marci@76
|
286 |
|
marci@76
|
287 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
288 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
289 |
|
marci@76
|
290 |
typedef typename Graph::EachNodeIt EachNodeIt;
|
marci@76
|
291 |
|
marci@76
|
292 |
class OutEdgeIt {
|
marci@76
|
293 |
public:
|
marci@76
|
294 |
//Graph::NodeIt n;
|
marci@76
|
295 |
bool out_or_in;
|
marci@76
|
296 |
typename Graph::OutEdgeIt o;
|
marci@76
|
297 |
typename Graph::InEdgeIt i;
|
marci@76
|
298 |
};
|
marci@76
|
299 |
class InEdgeIt {
|
marci@76
|
300 |
public:
|
marci@76
|
301 |
//Graph::NodeIt n;
|
marci@76
|
302 |
bool out_or_in;
|
marci@76
|
303 |
typename Graph::OutEdgeIt o;
|
marci@76
|
304 |
typename Graph::InEdgeIt i;
|
marci@76
|
305 |
};
|
marci@76
|
306 |
typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@76
|
307 |
typedef typename Graph::EachEdgeIt EachEdgeIt;
|
marci@76
|
308 |
|
marci@76
|
309 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@76
|
310 |
int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
311 |
|
marci@76
|
312 |
NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }
|
marci@76
|
313 |
|
marci@76
|
314 |
// EachEdge and SymEdge is missing!!!!
|
marci@76
|
315 |
// EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
|
marci@76
|
316 |
|
marci@76
|
317 |
//FIXME
|
marci@76
|
318 |
OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const
|
marci@76
|
319 |
{
|
marci@76
|
320 |
e.n=n;
|
marci@76
|
321 |
graph->getFirst(e.o,n);
|
marci@76
|
322 |
while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@76
|
323 |
graph->goNext(e.o);
|
marci@76
|
324 |
if(!graph->valid(e.o)) {
|
marci@76
|
325 |
graph->getFirst(e.i,n);
|
marci@76
|
326 |
while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@76
|
327 |
graph->goNext(e.i);
|
marci@76
|
328 |
}
|
marci@76
|
329 |
return e;
|
marci@76
|
330 |
}
|
marci@76
|
331 |
/*
|
marci@76
|
332 |
OutEdgeIt &goNext(OutEdgeIt &e)
|
marci@76
|
333 |
{
|
marci@76
|
334 |
if(graph->valid(e.o)) {
|
marci@76
|
335 |
while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@76
|
336 |
graph->goNext(e.o);
|
marci@76
|
337 |
if(graph->valid(e.o)) return e;
|
marci@76
|
338 |
else graph->getFirst(e.i,e.n);
|
marci@76
|
339 |
}
|
marci@76
|
340 |
else {
|
marci@76
|
341 |
while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@76
|
342 |
graph->goNext(e.i);
|
marci@76
|
343 |
return e;
|
marci@76
|
344 |
}
|
marci@76
|
345 |
}
|
marci@76
|
346 |
OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
|
marci@76
|
347 |
*/
|
marci@76
|
348 |
//bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
|
marci@76
|
349 |
|
marci@76
|
350 |
//FIXME
|
marci@76
|
351 |
InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const
|
marci@76
|
352 |
{
|
marci@76
|
353 |
e.n=n;
|
marci@76
|
354 |
graph->getFirst(e.i,n);
|
marci@76
|
355 |
while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@76
|
356 |
graph->goNext(e.i);
|
marci@76
|
357 |
if(!graph->valid(e.i)) {
|
marci@76
|
358 |
graph->getFirst(e.o,n);
|
marci@76
|
359 |
while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@76
|
360 |
graph->goNext(e.o);
|
marci@76
|
361 |
}
|
marci@76
|
362 |
return e;
|
marci@76
|
363 |
}
|
marci@76
|
364 |
/*
|
marci@76
|
365 |
InEdgeIt &goNext(InEdgeIt &e)
|
marci@76
|
366 |
{
|
marci@76
|
367 |
if(graph->valid(e.i)) {
|
marci@76
|
368 |
while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@76
|
369 |
graph->goNext(e.i);
|
marci@76
|
370 |
if(graph->valid(e.i)) return e;
|
marci@76
|
371 |
else graph->getFirst(e.o,e.n);
|
marci@76
|
372 |
}
|
marci@76
|
373 |
else {
|
marci@76
|
374 |
while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@76
|
375 |
graph->goNext(e.o);
|
marci@76
|
376 |
return e;
|
marci@76
|
377 |
}
|
marci@76
|
378 |
}
|
marci@76
|
379 |
InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
|
marci@76
|
380 |
*/
|
marci@76
|
381 |
//bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
|
marci@76
|
382 |
|
marci@76
|
383 |
//template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@76
|
384 |
//template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@76
|
385 |
|
marci@76
|
386 |
template< typename It > It first() const {
|
marci@76
|
387 |
It e; getFirst(e); return e; }
|
marci@76
|
388 |
|
marci@76
|
389 |
template< typename It > It first(NodeIt v) const {
|
marci@76
|
390 |
It e; getFirst(e, v); return e; }
|
marci@76
|
391 |
|
marci@76
|
392 |
NodeIt head(const EdgeIt& e) const { return graph->head(e); }
|
marci@76
|
393 |
NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
|
marci@76
|
394 |
|
marci@76
|
395 |
template<typename I> NodeIt aNode(const I& e) const {
|
marci@76
|
396 |
return graph->aNode(e); }
|
marci@76
|
397 |
template<typename I> NodeIt bNode(const I& e) const {
|
marci@76
|
398 |
return graph->bNode(e); }
|
marci@76
|
399 |
|
marci@76
|
400 |
//template<typename I> bool valid(const I i);
|
marci@76
|
401 |
//{ return graph->valid(i); }
|
marci@76
|
402 |
|
marci@76
|
403 |
//template<typename I> void setInvalid(const I &i);
|
marci@76
|
404 |
//{ return graph->setInvalid(i); }
|
marci@76
|
405 |
|
marci@76
|
406 |
NodeIt addNode() { return graph->addNode(); }
|
marci@76
|
407 |
EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) {
|
marci@76
|
408 |
return graph->addEdge(tail, head); }
|
marci@76
|
409 |
|
marci@76
|
410 |
template<typename I> void erase(const I& i) { graph->erase(i); }
|
marci@76
|
411 |
|
marci@76
|
412 |
void clear() { graph->clear(); }
|
marci@76
|
413 |
|
marci@76
|
414 |
template<typename S> class NodeMap : public Graph::NodeMap<S> { };
|
marci@76
|
415 |
template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
|
marci@76
|
416 |
|
marci@76
|
417 |
void setGraph(Graph& _graph) { graph = &_graph; }
|
marci@76
|
418 |
Graph& getGraph() { return (*graph); }
|
marci@76
|
419 |
|
marci@76
|
420 |
//ResGraphWrapper() : graph(0) { }
|
marci@76
|
421 |
ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
|
marci@76
|
422 |
};
|
marci@76
|
423 |
|
marci@76
|
424 |
|
marci@76
|
425 |
// FIXME: comparison should be made better!!!
|
marci@76
|
426 |
template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
|
marci@76
|
427 |
class ConstResGraphWrapper
|
marci@76
|
428 |
{
|
marci@76
|
429 |
const Graph* graph;
|
marci@76
|
430 |
const LowerMap* low;
|
marci@76
|
431 |
FlowMap* flow;
|
marci@76
|
432 |
const UpperMap* up;
|
marci@76
|
433 |
public:
|
marci@76
|
434 |
typedef Graph BaseGraph;
|
marci@76
|
435 |
|
marci@76
|
436 |
typedef typename Graph::NodeIt NodeIt;
|
marci@76
|
437 |
typedef typename Graph::EdgeIt EdgeIt;
|
marci@76
|
438 |
|
marci@76
|
439 |
typedef typename Graph::EachNodeIt EachNodeIt;
|
marci@76
|
440 |
|
marci@76
|
441 |
class OutEdgeIt {
|
marci@76
|
442 |
public:
|
marci@76
|
443 |
//Graph::NodeIt n;
|
marci@76
|
444 |
bool out_or_in;
|
marci@76
|
445 |
typename Graph::SymEdgeIt sym;
|
marci@76
|
446 |
};
|
marci@76
|
447 |
class InEdgeIt {
|
marci@76
|
448 |
public:
|
marci@76
|
449 |
//Graph::NodeIt n;
|
marci@76
|
450 |
bool out_or_in;
|
marci@76
|
451 |
typename Graph::OutEdgeIt sym;
|
marci@76
|
452 |
};
|
marci@76
|
453 |
//typedef typename Graph::SymEdgeIt SymEdgeIt;
|
marci@76
|
454 |
//typedef typename Graph::EachEdgeIt EachEdgeIt;
|
marci@76
|
455 |
|
marci@76
|
456 |
int nodeNum() const { return graph->nodeNum(); }
|
marci@76
|
457 |
//int edgeNum() const { return graph->edgeNum(); }
|
marci@76
|
458 |
|
marci@76
|
459 |
NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }
|
marci@76
|
460 |
|
marci@76
|
461 |
// EachEdge and SymEdge is missing!!!!
|
marci@76
|
462 |
// EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
|
marci@76
|
463 |
|
marci@76
|
464 |
|
marci@76
|
465 |
//FIXME
|
marci@76
|
466 |
OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const
|
marci@76
|
467 |
{
|
marci@76
|
468 |
e.n=n;
|
marci@76
|
469 |
graph->getFirst(e.o,n);
|
marci@76
|
470 |
while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@76
|
471 |
graph->goNext(e.o);
|
marci@76
|
472 |
if(!graph->valid(e.o)) {
|
marci@76
|
473 |
graph->getFirst(e.i,n);
|
marci@76
|
474 |
while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@76
|
475 |
graph->goNext(e.i);
|
marci@76
|
476 |
}
|
marci@76
|
477 |
return e;
|
marci@76
|
478 |
}
|
marci@76
|
479 |
/*
|
marci@76
|
480 |
OutEdgeIt &goNext(OutEdgeIt &e)
|
marci@76
|
481 |
{
|
marci@76
|
482 |
if(graph->valid(e.o)) {
|
marci@76
|
483 |
while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
|
marci@76
|
484 |
graph->goNext(e.o);
|
marci@76
|
485 |
if(graph->valid(e.o)) return e;
|
marci@76
|
486 |
else graph->getFirst(e.i,e.n);
|
marci@76
|
487 |
}
|
marci@76
|
488 |
else {
|
marci@76
|
489 |
while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
|
marci@76
|
490 |
graph->goNext(e.i);
|
marci@76
|
491 |
return e;
|
marci@76
|
492 |
}
|
marci@76
|
493 |
}
|
marci@76
|
494 |
OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
|
marci@76
|
495 |
*/
|
marci@76
|
496 |
//bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
|
marci@76
|
497 |
|
marci@76
|
498 |
//FIXME
|
marci@76
|
499 |
InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const
|
marci@76
|
500 |
{
|
marci@76
|
501 |
e.n=n;
|
marci@76
|
502 |
graph->getFirst(e.i,n);
|
marci@76
|
503 |
while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@76
|
504 |
graph->goNext(e.i);
|
marci@76
|
505 |
if(!graph->valid(e.i)) {
|
marci@76
|
506 |
graph->getFirst(e.o,n);
|
marci@76
|
507 |
while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@76
|
508 |
graph->goNext(e.o);
|
marci@76
|
509 |
}
|
marci@76
|
510 |
return e;
|
marci@76
|
511 |
}
|
marci@76
|
512 |
/*
|
marci@76
|
513 |
InEdgeIt &goNext(InEdgeIt &e)
|
marci@76
|
514 |
{
|
marci@76
|
515 |
if(graph->valid(e.i)) {
|
marci@76
|
516 |
while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
|
marci@76
|
517 |
graph->goNext(e.i);
|
marci@76
|
518 |
if(graph->valid(e.i)) return e;
|
marci@76
|
519 |
else graph->getFirst(e.o,e.n);
|
marci@76
|
520 |
}
|
marci@76
|
521 |
else {
|
marci@76
|
522 |
while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
|
marci@76
|
523 |
graph->goNext(e.o);
|
marci@76
|
524 |
return e;
|
marci@76
|
525 |
}
|
marci@76
|
526 |
}
|
marci@76
|
527 |
InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
|
marci@76
|
528 |
*/
|
marci@76
|
529 |
//bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
|
marci@76
|
530 |
|
marci@76
|
531 |
//template<typename I> I &goNext(I &i); { return graph->goNext(i); }
|
marci@76
|
532 |
//template<typename I> I next(const I i); { return graph->goNext(i); }
|
marci@76
|
533 |
|
marci@76
|
534 |
template< typename It > It first() const {
|
marci@76
|
535 |
It e; getFirst(e); return e; }
|
marci@76
|
536 |
|
marci@76
|
537 |
template< typename It > It first(NodeIt v) const {
|
marci@76
|
538 |
It e; getFirst(e, v); return e; }
|
marci@76
|
539 |
|
marci@76
|
540 |
NodeIt head(const EdgeIt& e) const { return graph->head(e); }
|
marci@76
|
541 |
NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
|
marci@76
|
542 |
|
marci@76
|
543 |
template<typename I> NodeIt aNode(const I& e) const {
|
marci@76
|
544 |
return graph->aNode(e); }
|
marci@76
|
545 |
template<typename I> NodeIt bNode(const I& e) const {
|
marci@76
|
546 |
return graph->bNode(e); }
|
marci@76
|
547 |
|
marci@76
|
548 |
//template<typename I> bool valid(const I i);
|
marci@76
|
549 |
//{ return graph->valid(i); }
|
marci@76
|
550 |
|
marci@76
|
551 |
//template<typename I> void setInvalid(const I &i);
|
marci@76
|
552 |
//{ return graph->setInvalid(i); }
|
marci@76
|
553 |
|
marci@76
|
554 |
NodeIt addNode() { return graph->addNode(); }
|
marci@76
|
555 |
EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) {
|
marci@76
|
556 |
return graph->addEdge(tail, head); }
|
marci@76
|
557 |
|
marci@76
|
558 |
template<typename I> void erase(const I& i) { graph->erase(i); }
|
marci@76
|
559 |
|
marci@76
|
560 |
void clear() { graph->clear(); }
|
marci@76
|
561 |
|
marci@76
|
562 |
template<typename S> class NodeMap : public Graph::NodeMap<S> { };
|
marci@76
|
563 |
template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
|
marci@76
|
564 |
|
marci@76
|
565 |
void setGraph(const Graph& _graph) { graph = &_graph; }
|
marci@76
|
566 |
const Graph& getGraph() { return (*graph); }
|
marci@76
|
567 |
|
marci@76
|
568 |
//ConstResGraphWrapper() : graph(0) { }
|
marci@76
|
569 |
ConstResGraphWrapper(const Graph& _graph) : graph(&_graph) { }
|
marci@76
|
570 |
};
|
marci@76
|
571 |
|
marci@76
|
572 |
|
marci@76
|
573 |
|
marci@76
|
574 |
|
marci@76
|
575 |
|
alpar@105
|
576 |
} //namespace hugo
|
marci@76
|
577 |
|
marci@76
|
578 |
#endif //GRAPH_WRAPPER_H
|
marci@76
|
579 |
|
marci@76
|
580 |
|
marci@76
|
581 |
// NodeIt &getFirst(NodeIt &n) { return graph->getFirst(n); }
|
marci@76
|
582 |
// InEdgeIt &getFirst(InEdgeIt &e,const NodeIt &n);
|
marci@76
|
583 |
// { return graph->getFirst(e,n); }
|
marci@76
|
584 |
// OutEdgeIt &getFirst(OutEdgeIt &e,const NodeIt &n);
|
marci@76
|
585 |
// { return graph->getFirst(e,n); }
|
marci@76
|
586 |
// SymEdgeIt &getFirst(SymEdgeIt &e,const NodeIt &n);
|
marci@76
|
587 |
// { return graph->getFirst(e,n); }
|
marci@76
|
588 |
// EachEdgeIt &getFirst(EachEdgeIt &e);
|
marci@76
|
589 |
// { return graph->getFirst(e); }
|
marci@76
|
590 |
|
marci@76
|
591 |
// NodeIt next(const NodeIt &n);
|
marci@76
|
592 |
// { return graph->next(n); }
|
marci@76
|
593 |
// InEdgeIt next(const InEdgeIt &e);
|
marci@76
|
594 |
// { return graph->next(e); }
|
marci@76
|
595 |
// OutEdgeIt next(const OutEdgeIt &e);
|
marci@76
|
596 |
// { return graph->next(e); }
|
marci@76
|
597 |
// SymEdgeIt next(const SymEdgeIt &e);
|
marci@76
|
598 |
// { return graph->next(e); }
|
marci@76
|
599 |
// EachEdgeIt next(const EachEdgeIt &e);
|
marci@76
|
600 |
// { return graph->next(e); }
|
marci@76
|
601 |
|
marci@76
|
602 |
// NodeIt &goNext(NodeIt &n);
|
marci@76
|
603 |
// { return graph->goNext(n); }
|
marci@76
|
604 |
// InEdgeIt &goNext(InEdgeIt &e);
|
marci@76
|
605 |
// { return graph->goNext(e); }
|
marci@76
|
606 |
// OutEdgeIt &goNext(OutEdgeIt &e);
|
marci@76
|
607 |
// { return graph->goNext(e); }
|
marci@76
|
608 |
// SymEdgeIt &goNext(SymEdgeIt &e);
|
marci@76
|
609 |
// { return graph->goNext(e); }
|
marci@76
|
610 |
// EachEdgeIt &goNext(EachEdgeIt &e);
|
marci@76
|
611 |
// { return graph->goNext(e); }
|
marci@76
|
612 |
|