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