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