1.1 --- a/src/work/alpar/gwrapper.h Sun Apr 17 18:57:22 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,412 +0,0 @@
1.4 -// -*-mode: c++; -*-
1.5 -#ifndef GRAPH_WRAPPER_H
1.6 -#define GRAPH_WRAPPER_H
1.7 -
1.8 -namespace lemon {
1.9 -
1.10 -template<typename G>
1.11 -class TrivGraphWrapper
1.12 -{
1.13 - G *graph;
1.14 -
1.15 -public:
1.16 - typedef G BaseGraph;
1.17 -
1.18 - typedef typename G::EdgeIt EdgeIt;
1.19 -
1.20 - typedef typename G::InEdgeIt InEdgeIt;
1.21 - typedef typename G::OutEdgeIt OutEdgeIt;
1.22 - typedef typename G::SymEdgeIt SymEdgeIt;
1.23 - typedef typename G::EachEdgeIt EachEdgeIt;
1.24 -
1.25 - typedef typename G::NodeIt NodeIt;
1.26 -
1.27 - template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
1.28 - template<typename I,typename P> I &getFirst(I &i,const P &p);
1.29 - { return graph->getFirst(i,p); }
1.30 - template<typename I> I next(const I i); { return graph->goNext(i); }
1.31 - template<typename I> I &goNext(I &i); { return graph->goNext(i); }
1.32 -
1.33 - NodeIt target(const EdgeIt &e);
1.34 - { return graph->target(e); }
1.35 - NodeIt source(const EdgeIt &e);
1.36 - { return graph->source(e); }
1.37 -
1.38 - template<typename I> NodeIt aNode(const I e);
1.39 - { return graph->aNode(e); }
1.40 - template<typename I> NodeIt bNode(const I e);
1.41 - { return graph->bNode(e); }
1.42 -
1.43 - template<typename I> bool valid(const I i);
1.44 - { return graph->valid(i); }
1.45 -
1.46 - template<typename I> void setInvalid(const I &i);
1.47 - { return graph->setInvalid(i); }
1.48 -
1.49 - NodeIt addNode(); { return graph->addNode(); }
1.50 - EdgeIt addEdge(const NodeIt from,const NodeIt to);
1.51 - { return graph->addEdge(ftom,to); }
1.52 -
1.53 - template<I> void delete(I i); { graph->delete(i); }
1.54 -
1.55 - void clean(); { graph->clean(); }
1.56 -
1.57 - template<class T> class NodeMap : public typename G::NodeMap<T>;
1.58 - template<class T> class EdgeMap : public typename G::EdgeMap<T>;
1.59 -
1.60 - void SetG(G &g) {graph = &g;}
1.61 -
1.62 - TrivGraphWrapper() {graph = NULL;}
1.63 - TrivGraphWrapper(G &g) {graph = &g;}
1.64 -};
1.65 -
1.66 -template<typename G>
1.67 -class RevGraphWrapper
1.68 -{
1.69 - G *graph;
1.70 -
1.71 -public:
1.72 - typedef G BaseGraph;
1.73 -
1.74 - typedef typename G::EdgeIt EdgeIt;
1.75 -
1.76 - typedef typename G::InEdgeIt OutEdgeIt;
1.77 - typedef typename G::OutEdgeIt InEdgeIt;
1.78 - typedef typename G::SymEdgeIt SymEdgeIt;
1.79 - typedef typename G::EachEdgeIt EachEdgeIt;
1.80 -
1.81 - typedef typename G::NodeIt NodeIt;
1.82 -
1.83 - template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
1.84 - template<typename I,typename P> I &getFirst(I &i,const P &p);
1.85 - { return graph->getFirst(i,p); }
1.86 - template<typename I> I next(const I i); { return graph->goNext(i); }
1.87 - template<typename I> I &goNext(I &i); { return graph->goNext(i); }
1.88 -
1.89 - NodeIt target(const EdgeIt &e);
1.90 - { return graph->source(e); }
1.91 - NodeIt source(const EdgeIt &e);
1.92 - { return graph->target(e); }
1.93 -
1.94 - template<typename I> NodeIt aNode(const I e);
1.95 - { return graph->aNode(e); }
1.96 - template<typename I> NodeIt bNode(const I e);
1.97 - { return graph->bNode(e); }
1.98 -
1.99 - template<typename I> bool valid(const I i);
1.100 - { return graph->valid(i); }
1.101 -
1.102 - template<typename I> void setInvalid(const I &i);
1.103 - { return graph->setInvalid(i); }
1.104 -
1.105 - NodeIt addNode(); { return graph->addNode(); }
1.106 - EdgeIt addEdge(const NodeIt from,const NodeIt to);
1.107 - { return graph->addEdge(to,from); }
1.108 -
1.109 - template<I> void delete(I i); { graph->delete(i); }
1.110 -
1.111 - void clean(); { graph->clean(); }
1.112 -
1.113 - template<class T> class NodeMap : public typename G::NodeMap<T>;
1.114 - template<class T> class EdgeMap : public typename G::EdgeMap<T>;
1.115 -
1.116 - void SetG(G &g) {graph = &g;}
1.117 -
1.118 - RevGraphWrapper() {graph = NULL;}
1.119 - RevGraphWrapper(G &g) {graph = &g;}
1.120 -};
1.121 -
1.122 -template<typename G>
1.123 -class RevGraphExt : public G
1.124 -{
1.125 -public:
1.126 - // typedef G BaseGraph;
1.127 -
1.128 - typedef typename G::EdgeIt EdgeIt;
1.129 -
1.130 - typedef typename G::InEdgeIt OutEdgeIt;
1.131 - typedef typename G::OutEdgeIt InEdgeIt;
1.132 - typedef typename G::SymEdgeIt SymEdgeIt;
1.133 - typedef typename G::EachEdgeIt EachEdgeIt;
1.134 -
1.135 - typedef typename G::NodeIt NodeIt;
1.136 -
1.137 -// template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
1.138 -// template<typename I,typename P> I &getFirst(I &i,const P &p);
1.139 -// { return graph->getFirst(i,p); }
1.140 -// template<typename I> I next(const I i); { return graph->goNext(i); }
1.141 -// template<typename I> I &goNext(I &i); { return graph->goNext(i); }
1.142 -
1.143 - NodeIt target(const EdgeIt &e);
1.144 - { return G::source(e); }
1.145 - NodeIt source(const EdgeIt &e);
1.146 - { return G::target(e); }
1.147 -
1.148 -// template<typename I> NodeIt aNode(const I e);
1.149 -// { return graph->aNode(e); }
1.150 -// template<typename I> NodeIt bNode(const I e);
1.151 -// { return graph->bNode(e); }
1.152 -
1.153 -// template<typename I> bool valid(const I i);
1.154 -// { return graph->valid(i); }
1.155 -
1.156 -// template<typename I> void setInvalid(const I &i);
1.157 -// { return graph->setInvalid(i); }
1.158 -
1.159 -// NodeIt addNode(); { return graph->addNode(); }
1.160 -
1.161 - EdgeIt addEdge(const NodeIt from,const NodeIt to);
1.162 - { return G::addEdge(to,from); }
1.163 -
1.164 -// template<I> void delete(I i); { graph->delete(i); }
1.165 -
1.166 -// void clean(); { graph->clean(); }
1.167 -
1.168 -// template<class T> class NodeMap : public typename G::NodeMap<T>;
1.169 -// template<class T> class EdgeMap : public typename G::EdgeMap<T>;
1.170 -
1.171 -// void SetG(G &g) {graph = &g;}
1.172 -
1.173 -// RevGraphWrapper() {graph = NULL;}
1.174 -// RevGraphWrapper(G &g) {graph = &g;}
1.175 -};
1.176 -
1.177 -template<typename G>
1.178 -class SymGraphWrapper
1.179 -{
1.180 - G *graph;
1.181 -
1.182 -public:
1.183 - typedef G BaseGraph;
1.184 -
1.185 - typedef typename G::EdgeIt EdgeIt;
1.186 -
1.187 - typedef typename G::SymEdgeIt InEdgeIt;
1.188 - typedef typename G::SymEdgeIt OutEdgeIt;
1.189 - typedef typename G::SymEdgeIt SymEdgeIt;
1.190 - typedef typename G::EachEdgeIt EachEdgeIt;
1.191 -
1.192 - typedef typename G::NodeIt NodeIt;
1.193 -
1.194 - template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
1.195 - template<typename I,typename P> I &getFirst(I &i,const P &p);
1.196 - { return graph->getFirst(i,p); }
1.197 - template<typename I> I next(const I i); { return graph->goNext(i); }
1.198 - template<typename I> I &goNext(I &i); { return graph->goNext(i); }
1.199 -
1.200 - NodeIt target(const EdgeIt &e);
1.201 - { return graph->target(e); }
1.202 - NodeIt source(const EdgeIt &e);
1.203 - { return graph->source(e); }
1.204 -
1.205 - template<typename I> NodeIt aNode(const I e);
1.206 - { return graph->aNode(e); }
1.207 - template<typename I> NodeIt bNode(const I e);
1.208 - { return graph->bNode(e); }
1.209 -
1.210 - template<typename I> bool valid(const I i);
1.211 - { return graph->valid(i); }
1.212 -
1.213 - template<typename I> void setInvalid(const I &i);
1.214 - { return graph->setInvalid(i); }
1.215 -
1.216 - NodeIt addNode(); { return graph->addNode(); }
1.217 - EdgeIt addEdge(const NodeIt from,const NodeIt to);
1.218 - { return graph->addEdge(to,from); }
1.219 -
1.220 - template<I> void delete(I i); { graph->delete(i); }
1.221 -
1.222 - void clean(); { graph->clean(); }
1.223 -
1.224 - template<class T> class NodeMap : public typename G::NodeMap<T>;
1.225 - template<class T> class EdgeMap : public typename G::EdgeMap<T>;
1.226 -
1.227 - void SetG(G &g) {graph = &g;}
1.228 -
1.229 - RevGraphWrapper() {graph = NULL;}
1.230 - RevGraphWrapper(G &g) {graph = &g;}
1.231 -};
1.232 -
1.233 -
1.234 -
1.235 -
1.236 -
1.237 -
1.238 -
1.239 -
1.240 -
1.241 -
1.242 -
1.243 -
1.244 -
1.245 -
1.246 -
1.247 -
1.248 -
1.249 -
1.250 -
1.251 -// FIXME: comparison should be made better!!!
1.252 -template<typename G, typename lomap, typename fmap, typename himap>
1.253 -class ResGraphWrapper
1.254 -{
1.255 - G *graph;
1.256 -
1.257 -public:
1.258 - typedef G BaseGraph;
1.259 -
1.260 - typedef typename G::EdgeIt EdgeIt;
1.261 -
1.262 - class InEdgeIt
1.263 - {
1.264 - public:
1.265 - G::NodeIt n;
1.266 - G::InEdgeIt i;
1.267 - G::OutEdgeIt o;
1.268 - }
1.269 - class OutEdgeIt
1.270 - {
1.271 - public:
1.272 - G::NodeIt n;
1.273 - G::InEdgeIt i;
1.274 - G::OutEdgeIt o;
1.275 - }
1.276 - typedef typename G::SymEdgeIt SymEdgeIt;
1.277 - typedef typename G::EachEdgeIt EachEdgeIt;
1.278 -
1.279 - typedef typename G::NodeIt NodeIt;
1.280 -
1.281 - NodeIt &getFirst(NodeIt &n); { return graph->getFirst(n); }
1.282 -
1.283 - // EachEdge and SymEdge is missing!!!!
1.284 - // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
1.285 -
1.286 - InEdgeIt &getFirst(InEdgeIt &e,const NodeIt &n)
1.287 - {
1.288 - e.n=n;
1.289 - graph->getFirst(e.i,n);
1.290 - while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
1.291 - graph->goNext(e.i);
1.292 - if(!graph->valid(e.i)) {
1.293 - graph->getFirst(e.o,n);
1.294 - while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
1.295 - graph->goNext(e.o);
1.296 - }
1.297 - return e;
1.298 - }
1.299 - InEdgeIt &goNext(InEdgeIt &e)
1.300 - {
1.301 - if(graph->valid(e.i)) {
1.302 - while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
1.303 - graph->goNext(e.i);
1.304 - if(graph->valid(e.i)) return e;
1.305 - else graph->getFirst(e.o,e.n);
1.306 - }
1.307 - else {
1.308 - while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
1.309 - graph->goNext(e.o);
1.310 - return e;
1.311 - }
1.312 - }
1.313 - InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
1.314 - bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
1.315 -
1.316 - OutEdgeIt &getFirst(OutEdgeIt &e,const NodeIt &n)
1.317 - {
1.318 - e.n=n;
1.319 - graph->getFirst(e.o,n);
1.320 - while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
1.321 - graph->goNext(e.o);
1.322 - if(!graph->valid(e.o)) {
1.323 - graph->getFirst(e.i,n);
1.324 - while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
1.325 - graph->goNext(e.i);
1.326 - }
1.327 - return e;
1.328 - }
1.329 - OutEdgeIt &goNext(OutEdgeIt &e)
1.330 - {
1.331 - if(graph->valid(e.o)) {
1.332 - while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
1.333 - graph->goNext(e.o);
1.334 - if(graph->valid(e.o)) return e;
1.335 - else graph->getFirst(e.i,e.n);
1.336 - }
1.337 - else {
1.338 - while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
1.339 - graph->goNext(e.i);
1.340 - return e;
1.341 - }
1.342 - }
1.343 - OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
1.344 - bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
1.345 -
1.346 - template<typename I> I &goNext(I &i); { return graph->goNext(i); }
1.347 - template<typename I> I next(const I i); { return graph->goNext(i); }
1.348 -
1.349 - NodeIt target(const EdgeIt &e);
1.350 - { return graph->target(e); }
1.351 - NodeIt source(const EdgeIt &e);
1.352 - { return graph->source(e); }
1.353 -
1.354 - template<typename I> NodeIt aNode(const I e);
1.355 - { return graph->aNode(e); }
1.356 - template<typename I> NodeIt bNode(const I e);
1.357 - { return graph->bNode(e); }
1.358 -
1.359 - template<typename I> bool valid(const I i);
1.360 - { return graph->valid(i); }
1.361 -
1.362 - template<typename I> void setInvalid(const I &i);
1.363 - { return graph->setInvalid(i); }
1.364 -
1.365 - NodeIt addNode(); { return graph->addNode(); }
1.366 - EdgeIt addEdge(const NodeIt from,const NodeIt to);
1.367 - { return graph->addEdge(to,from); }
1.368 -
1.369 - template<I> void delete(I i); { graph->delete(i); }
1.370 -
1.371 - void clean(); { graph->clean(); }
1.372 -
1.373 - template<class T> class NodeMap : public typename G::NodeMap<T>;
1.374 - template<class T> class EdgeMap : public typename G::EdgeMap<T>;
1.375 -
1.376 - void SetG(G &g) {graph = &g;}
1.377 -
1.378 - RevGraphWrapper() {graph = NULL;}
1.379 - RevGraphWrapper(G &g) {graph = &g;}
1.380 -};
1.381 -
1.382 -
1.383 -
1.384 -// NodeIt &getFirst(NodeIt &n) { return graph->getFirst(n); }
1.385 -// InEdgeIt &getFirst(InEdgeIt &e,const NodeIt &n);
1.386 -// { return graph->getFirst(e,n); }
1.387 -// OutEdgeIt &getFirst(OutEdgeIt &e,const NodeIt &n);
1.388 -// { return graph->getFirst(e,n); }
1.389 -// SymEdgeIt &getFirst(SymEdgeIt &e,const NodeIt &n);
1.390 -// { return graph->getFirst(e,n); }
1.391 -// EachEdgeIt &getFirst(EachEdgeIt &e);
1.392 -// { return graph->getFirst(e); }
1.393 -
1.394 -// NodeIt next(const NodeIt &n);
1.395 -// { return graph->next(n); }
1.396 -// InEdgeIt next(const InEdgeIt &e);
1.397 -// { return graph->next(e); }
1.398 -// OutEdgeIt next(const OutEdgeIt &e);
1.399 -// { return graph->next(e); }
1.400 -// SymEdgeIt next(const SymEdgeIt &e);
1.401 -// { return graph->next(e); }
1.402 -// EachEdgeIt next(const EachEdgeIt &e);
1.403 -// { return graph->next(e); }
1.404 -
1.405 -// NodeIt &goNext(NodeIt &n);
1.406 -// { return graph->goNext(n); }
1.407 -// InEdgeIt &goNext(InEdgeIt &e);
1.408 -// { return graph->goNext(e); }
1.409 -// OutEdgeIt &goNext(OutEdgeIt &e);
1.410 -// { return graph->goNext(e); }
1.411 -// SymEdgeIt &goNext(SymEdgeIt &e);
1.412 -// { return graph->goNext(e); }
1.413 -// EachEdgeIt &goNext(EachEdgeIt &e);
1.414 -// { return graph->goNext(e); }
1.415 -