src/work/marci/graph_wrapper.h
author athos
Fri, 02 Apr 2004 14:53:05 +0000
changeset 276 b38f4cfa76cf
parent 269 07af3069c0b8
child 279 be43902fadb7
permissions -rw-r--r--
suurballe fordulo es segfaultolo(!) valtozata
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@275
   684
    //FIXME ezeknek valojaban a GraphWrapper megfelelo dolgai kellene hogy 
marci@275
   685
    //legyenek, at kell irni
marci@275
   686
    typedef typename /*GraphWrapperSkeleton<GraphWrapper>*/
marci@275
   687
    GraphWrapper::Edge GraphEdge;
marci@275
   688
    typedef typename /*GraphWrapperSkeleton<GraphWrapper>*/ 
marci@275
   689
    GraphWrapper::OutEdgeIt GraphOutEdgeIt;
marci@275
   690
    typedef typename /*GraphWrapperSkeleton<GraphWrapper>*/ 
marci@275
   691
    GraphWrapper::InEdgeIt GraphInEdgeIt;
marci@158
   692
    //public:
marci@158
   693
marci@168
   694
    //UndirGraphWrapper() : graph(0) { }
marci@238
   695
    UndirGraphWrapper(GraphWrapper _gw) : 
marci@238
   696
      GraphWrapperSkeleton<GraphWrapper>(_gw) { }  
marci@238
   697
marci@238
   698
    //UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
marci@168
   699
marci@236
   700
    //void setGraph(Graph& _graph) { graph = &_graph; }
marci@236
   701
    //Graph& getGraph() const { return (*graph); }
marci@168
   702
  
marci@174
   703
    class Edge {
marci@236
   704
      friend class UndirGraphWrapper<GraphWrapper>;
marci@158
   705
      bool out_or_in; //true iff out
marci@158
   706
      GraphOutEdgeIt out;
marci@158
   707
      GraphInEdgeIt in;
marci@158
   708
    public:
marci@174
   709
      Edge() : out_or_in(), out(), in() { }
marci@174
   710
      Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
marci@174
   711
      operator GraphEdge() const {
marci@158
   712
	if (out_or_in) return(out); else return(in);
marci@158
   713
      }
marci@239
   714
//FIXME
marci@239
   715
//2 edges are equal if they "refer" to the same physical edge 
marci@239
   716
//is it good?
marci@174
   717
      friend bool operator==(const Edge& u, const Edge& v) { 
marci@174
   718
	if (v.out_or_in) 
marci@239
   719
	  if (u.out_or_in) return (u.out==v.out); else return (u.out==v.in);
marci@239
   720
	//return (u.out_or_in && u.out==v.out);
marci@174
   721
	else
marci@239
   722
	  if (u.out_or_in) return (u.out==v.in); else return (u.in==v.in);
marci@239
   723
	//return (!u.out_or_in && u.in==v.in);
marci@174
   724
      } 
marci@174
   725
      friend bool operator!=(const Edge& u, const Edge& v) { 
marci@174
   726
	if (v.out_or_in) 
marci@239
   727
	  if (u.out_or_in) return (u.out!=v.out); else return (u.out!=v.in);
marci@239
   728
	//return (!u.out_or_in || u.out!=v.out);
marci@174
   729
	else
marci@239
   730
	  if (u.out_or_in) return (u.out!=v.in); else return (u.in!=v.in);
marci@239
   731
	//return (u.out_or_in || u.in!=v.in);
marci@174
   732
      } 
marci@158
   733
    };
marci@158
   734
marci@174
   735
    class OutEdgeIt : public Edge {
marci@236
   736
      friend class UndirGraphWrapper<GraphWrapper>;
marci@158
   737
    public:
marci@174
   738
      OutEdgeIt() : Edge() { }
marci@174
   739
      OutEdgeIt(const Invalid& i) : Edge(i) { }
marci@236
   740
      OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n) 
marci@236
   741
	: Edge() { 
marci@239
   742
	out_or_in=true; _G.gw.first(out, n);
marci@239
   743
	if (!(_G.gw.valid(out))) { out_or_in=false; _G.gw.first(in, n);	}
marci@158
   744
      }
marci@158
   745
    };
marci@158
   746
marci@238
   747
    typedef OutEdgeIt InEdgeIt; 
marci@238
   748
marci@238
   749
    class EdgeIt : public Edge {
marci@238
   750
      friend class UndirGraphWrapper<GraphWrapper>;
marci@238
   751
    protected:
marci@238
   752
      NodeIt v;
marci@238
   753
    public:
marci@238
   754
      EdgeIt() : Edge() { }
marci@238
   755
      EdgeIt(const Invalid& i) : Edge(i) { }
marci@238
   756
      EdgeIt(const UndirGraphWrapper<GraphWrapper>& _G) 
marci@238
   757
	: Edge() { 
marci@238
   758
	out_or_in=true;
marci@238
   759
	//Node v;
marci@238
   760
	_G.first(v);
marci@238
   761
	if (_G.valid(v)) _G.gw.first(out); else out=INVALID;
marci@238
   762
	while (_G.valid(v) && !_G.gw.valid(out)) { 
marci@238
   763
	  _G.gw.next(v); 
marci@238
   764
	  if (_G.valid(v)) _G.gw.first(out); 
marci@238
   765
	}
marci@238
   766
      }
marci@238
   767
    };
marci@238
   768
marci@212
   769
    OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
marci@239
   770
      e.out_or_in=true; gw.first(e.out, n);
marci@239
   771
      if (!(gw.valid(e.out))) { e.out_or_in=false; gw.first(e.in, n); }
marci@158
   772
      return e;
marci@158
   773
    }
marci@158
   774
marci@238
   775
    EdgeIt& first(EdgeIt& e) const {
marci@238
   776
      e.out_or_in=true;
marci@238
   777
      //NodeIt v;
marci@238
   778
      first(e.v);
marci@238
   779
      if (valid(e.v)) gw.first(e.out, e.v); else e.out=INVALID;
marci@238
   780
      while (valid(e.v) && !gw.valid(e.out)) { 
marci@238
   781
	gw.next(e.v); 
marci@238
   782
	if (valid(e.v)) gw.first(e.out, e.v); 
marci@238
   783
      }
marci@238
   784
      return e;
marci@238
   785
    }
marci@238
   786
marci@265
   787
    template<typename I> I& first(I& i) const { gw.first(i); return i; }
marci@238
   788
    template<typename I, typename P> I& first(I& i, const P& p) const { 
marci@266
   789
      gw.first(i, p); return i; }
marci@238
   790
marci@158
   791
    OutEdgeIt& next(OutEdgeIt& e) const {
marci@158
   792
      if (e.out_or_in) {
marci@236
   793
	Node n=gw.tail(e.out);
marci@236
   794
	gw.next(e.out);
marci@239
   795
	if (!gw.valid(e.out)) { e.out_or_in=false; gw.first(e.in, n); }
marci@158
   796
      } else {
marci@236
   797
	gw.next(e.in);
marci@158
   798
      }
marci@158
   799
      return e;
marci@158
   800
    }
marci@158
   801
marci@238
   802
    EdgeIt& next(EdgeIt& e) const {
marci@238
   803
      //NodeIt v=tail(e);
marci@238
   804
      gw.next(e.out);
marci@238
   805
      while (valid(e.v) && !gw.valid(e.out)) { 
marci@238
   806
	next(e.v); 
marci@238
   807
	if (valid(e.v)) gw.first(e.out, e.v); 
marci@238
   808
      }
marci@238
   809
      return e;
marci@238
   810
    }
marci@158
   811
marci@238
   812
    template<typename I> I& next(I &i) const { return gw.next(i); }    
marci@265
   813
//    template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
marci@158
   814
marci@158
   815
    template< typename It > It first() const { 
marci@212
   816
      It e; first(e); return e; }
marci@158
   817
marci@174
   818
    template< typename It > It first(const Node& v) const { 
marci@212
   819
      It e; first(e, v); return e; }
marci@158
   820
marci@238
   821
//    Node head(const Edge& e) const { return gw.head(e); }
marci@238
   822
//    Node tail(const Edge& e) const { return gw.tail(e); }
marci@158
   823
marci@238
   824
//    template<typename I> bool valid(const I& i) const 
marci@238
   825
//      { return gw.valid(i); }
marci@158
   826
  
marci@238
   827
//    int nodeNum() const { return gw.nodeNum(); }
marci@238
   828
//    int edgeNum() const { return gw.edgeNum(); }
marci@158
   829
  
marci@174
   830
//     template<typename I> Node aNode(const I& e) const { 
marci@158
   831
//       return graph->aNode(e); }
marci@174
   832
//     template<typename I> Node bNode(const I& e) const { 
marci@158
   833
//       return graph->bNode(e); }
marci@238
   834
marci@238
   835
    Node aNode(const OutEdgeIt& e) const { 
marci@238
   836
      if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
marci@238
   837
    Node bNode(const OutEdgeIt& e) const { 
marci@238
   838
      if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
marci@158
   839
  
marci@238
   840
//    Node addNode() const { return gw.addNode(); }
marci@238
   841
marci@231
   842
// FIXME: ez igy nem jo, mert nem
marci@231
   843
//    Edge addEdge(const Node& tail, const Node& head) const { 
marci@231
   844
//      return graph->addEdge(tail, head); }
marci@158
   845
  
marci@238
   846
//    template<typename I> void erase(const I& i) const { gw.erase(i); }
marci@158
   847
  
marci@238
   848
//    void clear() const { gw.clear(); }
marci@158
   849
    
marci@238
   850
//     template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
marci@238
   851
//     public:
marci@238
   852
//       NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
marci@238
   853
// 	GraphWrapper::NodeMap<T>(_G.gw) { }
marci@238
   854
//       NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
marci@238
   855
// 	GraphWrapper::NodeMap<T>(_G.gw, a) { }
marci@238
   856
//     };
marci@168
   857
marci@238
   858
//     template<typename T> class EdgeMap : 
marci@238
   859
//       public GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T> { 
marci@238
   860
//     public:
marci@238
   861
//       EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
marci@238
   862
// 	GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T>(_G.gw) { }
marci@238
   863
//       EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
marci@238
   864
// 	GraphWrapper::EdgeMap<T>(_G.gw, a) { }
marci@238
   865
//     };
marci@238
   866
   };
marci@158
   867
marci@158
   868
marci@158
   869
marci@236
   870
marci@236
   871
marci@155
   872
//   template<typename Graph>
marci@155
   873
//   class SymGraphWrapper
marci@155
   874
//   {
marci@155
   875
//     Graph* graph;
marci@76
   876
  
marci@155
   877
//   public:
marci@155
   878
//     typedef Graph BaseGraph;
marci@155
   879
marci@174
   880
//     typedef typename Graph::Node Node;
marci@174
   881
//     typedef typename Graph::Edge Edge;
marci@174
   882
  
marci@155
   883
//     typedef typename Graph::NodeIt NodeIt;
marci@155
   884
    
marci@155
   885
//     //FIXME tag-ekkel megcsinalni, hogy abbol csinaljon
marci@155
   886
//     //iranyitatlant, ami van
marci@155
   887
//     //mert csak 1 dolgot lehet be typedef-elni
marci@155
   888
//     typedef typename Graph::OutEdgeIt SymEdgeIt;
marci@155
   889
//     //typedef typename Graph::InEdgeIt SymEdgeIt;
marci@155
   890
//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
marci@174
   891
//     typedef typename Graph::EdgeIt EdgeIt;
marci@155
   892
marci@155
   893
//     int nodeNum() const { return graph->nodeNum(); }
marci@155
   894
//     int edgeNum() const { return graph->edgeNum(); }
marci@155
   895
    
marci@212
   896
//     template<typename I> I& first(I& i) const { return graph->first(i); }
marci@212
   897
//     template<typename I, typename P> I& first(I& i, const P& p) const { 
marci@212
   898
//       return graph->first(i, p); }
marci@155
   899
//     //template<typename I> I next(const I i); { return graph->goNext(i); }
marci@155
   900
//     //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
marci@155
   901
marci@155
   902
//     template< typename It > It first() const { 
marci@212
   903
//       It e; first(e); return e; }
marci@155
   904
marci@174
   905
//     template< typename It > It first(Node v) const { 
marci@212
   906
//       It e; first(e, v); return e; }
marci@155
   907
marci@174
   908
//     Node head(const Edge& e) const { return graph->head(e); }
marci@174
   909
//     Node tail(const Edge& e) const { return graph->tail(e); }
marci@155
   910
  
marci@174
   911
//     template<typename I> Node aNode(const I& e) const { 
marci@155
   912
//       return graph->aNode(e); }
marci@174
   913
//     template<typename I> Node bNode(const I& e) const { 
marci@155
   914
//       return graph->bNode(e); }
marci@155
   915
  
marci@155
   916
//     //template<typename I> bool valid(const I i);
marci@155
   917
//     //{ return graph->valid(i); }
marci@155
   918
  
marci@155
   919
//     //template<typename I> void setInvalid(const I &i);
marci@155
   920
//     //{ return graph->setInvalid(i); }
marci@155
   921
  
marci@174
   922
//     Node addNode() { return graph->addNode(); }
marci@174
   923
//     Edge addEdge(const Node& tail, const Node& head) { 
marci@155
   924
//       return graph->addEdge(tail, head); }
marci@155
   925
  
marci@155
   926
//     template<typename I> void erase(const I& i) { graph->erase(i); }
marci@155
   927
  
marci@155
   928
//     void clear() { graph->clear(); }
marci@155
   929
  
marci@155
   930
//     template<typename T> class NodeMap : public Graph::NodeMap<T> { };
marci@155
   931
//     template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
marci@155
   932
  
marci@155
   933
//     void setGraph(Graph& _graph) { graph = &_graph; }
marci@155
   934
//     Graph& getGraph() { return (*graph); }
marci@155
   935
marci@155
   936
//     //SymGraphWrapper() : graph(0) { }
marci@155
   937
//     SymGraphWrapper(Graph& _graph) : graph(&_graph) { }
marci@155
   938
//   };
marci@155
   939
marci@155
   940
marci@266
   941
  template<typename GraphWrapper, typename Number, typename FlowMap, typename CapacityMap>
marci@266
   942
  class ResGraphWrapper : public GraphWrapperSkeleton<GraphWrapper>{
marci@76
   943
  public:
marci@259
   944
    //typedef Graph BaseGraph;
marci@266
   945
    //typedef TrivGraphWrapper<const Graph> GraphWrapper;
marci@266
   946
    typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
marci@266
   947
    typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
marci@155
   948
  private:
marci@275
   949
    typedef typename /*GraphWrapperSkeleton<GraphWrapper>*/
marci@275
   950
    GraphWrapper::OutEdgeIt OldOutEdgeIt;
marci@275
   951
    typedef typename /*GraphWrapperSkeleton<GraphWrapper>*/
marci@275
   952
    GraphWrapper::InEdgeIt OldInEdgeIt;
marci@199
   953
  protected:
marci@259
   954
    //const Graph* graph;
marci@266
   955
    //GraphWrapper gw;
marci@155
   956
    FlowMap* flow;
marci@155
   957
    const CapacityMap* capacity;
marci@155
   958
  public:
marci@168
   959
marci@266
   960
    ResGraphWrapper(const GraphWrapper& _gw, FlowMap& _flow, 
marci@266
   961
		    const CapacityMap& _capacity) : 
marci@266
   962
      GraphWrapperSkeleton<GraphWrapper>(_gw), 
marci@266
   963
      flow(&_flow), capacity(&_capacity) { }
marci@168
   964
marci@259
   965
    //void setGraph(const Graph& _graph) { graph = &_graph; }
marci@259
   966
    //const Graph& getGraph() const { return (*graph); }
marci@168
   967
marci@174
   968
    class Edge; 
marci@155
   969
    class OutEdgeIt; 
marci@174
   970
    friend class Edge; 
marci@155
   971
    friend class OutEdgeIt; 
marci@76
   972
marci@174
   973
    class Edge {
marci@266
   974
      friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
marci@155
   975
    protected:
marci@168
   976
      bool out_or_in; //true, iff out
marci@155
   977
      OldOutEdgeIt out;
marci@155
   978
      OldInEdgeIt in;
marci@155
   979
    public:
marci@174
   980
      Edge() : out_or_in(true) { } 
marci@174
   981
      Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
marci@168
   982
//       bool valid() const { 
marci@168
   983
// 	return out_or_in && out.valid() || in.valid(); }
marci@174
   984
      friend bool operator==(const Edge& u, const Edge& v) { 
marci@174
   985
	if (v.out_or_in) 
marci@174
   986
	  return (u.out_or_in && u.out==v.out);
marci@174
   987
	else
marci@174
   988
	  return (!u.out_or_in && u.in==v.in);
marci@174
   989
      } 
marci@174
   990
      friend bool operator!=(const Edge& u, const Edge& v) { 
marci@174
   991
	if (v.out_or_in) 
marci@174
   992
	  return (!u.out_or_in || u.out!=v.out);
marci@174
   993
	else
marci@174
   994
	  return (u.out_or_in || u.in!=v.in);
marci@174
   995
      } 
marci@155
   996
    };
marci@155
   997
marci@155
   998
marci@174
   999
    class OutEdgeIt : public Edge {
marci@266
  1000
      friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
marci@155
  1001
    public:
marci@155
  1002
      OutEdgeIt() { }
marci@168
  1003
      //FIXME
marci@174
  1004
      OutEdgeIt(const Edge& e) : Edge(e) { }
marci@174
  1005
      OutEdgeIt(const Invalid& i) : Edge(i) { }
marci@265
  1006
    protected:
marci@266
  1007
      OutEdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() { 
marci@259
  1008
	resG.gw.first(out, v);
marci@269
  1009
	while( resG.gw.valid(out) && !(resG.resCap(out)>0) ) { resG.gw.next(out); }
marci@259
  1010
	if (!resG.gw.valid(out)) {
marci@155
  1011
	  out_or_in=0;
marci@259
  1012
	  resG.gw.first(in, v);
marci@269
  1013
	  while( resG.gw.valid(in) && !(resG.resCap(in)>0) ) { resG.gw.next(in); }
marci@155
  1014
	}
marci@155
  1015
      }
marci@168
  1016
//     public:
marci@168
  1017
//       OutEdgeIt& operator++() { 
marci@168
  1018
// 	if (out_or_in) {
marci@174
  1019
// 	  Node v=/*resG->*/G->aNode(out);
marci@168
  1020
// 	  ++out;
marci@269
  1021
// 	  while( out.valid() && !(Edge::resCap()>0) ) { ++out; }
marci@168
  1022
// 	  if (!out.valid()) {
marci@168
  1023
// 	    out_or_in=0;
marci@212
  1024
// 	    G->first(in, v); 
marci@269
  1025
// 	    while( in.valid() && !(Edge::resCap()>0) ) { ++in; }
marci@168
  1026
// 	  }
marci@168
  1027
// 	} else {
marci@168
  1028
// 	  ++in;
marci@269
  1029
// 	  while( in.valid() && !(Edge::resCap()>0) ) { ++in; } 
marci@168
  1030
// 	}
marci@168
  1031
// 	return *this; 
marci@168
  1032
//       }
marci@155
  1033
    };
marci@155
  1034
marci@263
  1035
    //FIXME This is just for having InEdgeIt
marci@263
  1036
    typedef void InEdgeIt;
marci@263
  1037
marci@174
  1038
    class EdgeIt : public Edge {
marci@266
  1039
      friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
marci@265
  1040
      NodeIt v; 
marci@155
  1041
    public:
marci@174
  1042
      EdgeIt() { }
marci@174
  1043
      //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
marci@174
  1044
      EdgeIt(const Invalid& i) : Edge(i) { }
marci@266
  1045
      EdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG) : Edge() { 
marci@259
  1046
	resG.gw.first(v);
marci@269
  1047
	if (resG.gw.valid(v)) resG.gw.first(out, v); else out=INVALID;
marci@269
  1048
	while (resG.gw.valid(out) && !(resG.resCap(out)>0) ) { resG.gw.next(out); }
marci@259
  1049
	while (resG.gw.valid(v) && !resG.gw.valid(out)) { 
marci@259
  1050
	  resG.gw.next(v); 
marci@259
  1051
	  if (resG.gw.valid(v)) resG.gw.first(out, v); 
marci@269
  1052
	  while (resG.gw.valid(out) && !(resG.resCap(out)>0) ) { resG.gw.next(out); }
marci@155
  1053
	}
marci@259
  1054
	if (!resG.gw.valid(out)) {
marci@155
  1055
	  out_or_in=0;
marci@259
  1056
	  resG.gw.first(v);
marci@269
  1057
	  if (resG.gw.valid(v)) resG.gw.first(in, v); else in=INVALID;
marci@269
  1058
	  while (resG.gw.valid(in) && !(resG.resCap(in)>0) ) { resG.gw.next(in); }
marci@259
  1059
	  while (resG.gw.valid(v) && !resG.gw.valid(in)) { 
marci@259
  1060
	    resG.gw.next(v); 
marci@259
  1061
	    if (resG.gw.valid(v)) resG.gw.first(in, v); 
marci@269
  1062
	    while (resG.gw.valid(in) && !(resG.resCap(in)>0) ) { resG.gw.next(in); }
marci@155
  1063
	  }
marci@155
  1064
	}
marci@155
  1065
      }
marci@174
  1066
//       EdgeIt& operator++() { 
marci@168
  1067
// 	if (out_or_in) {
marci@168
  1068
// 	  ++out;
marci@269
  1069
// 	  while (out.valid() && !(Edge::resCap()>0) ) { ++out; }
marci@168
  1070
// 	  while (v.valid() && !out.valid()) { 
marci@168
  1071
// 	    ++v; 
marci@212
  1072
// 	    if (v.valid()) G->first(out, v); 
marci@269
  1073
// 	    while (out.valid() && !(Edge::resCap()>0) ) { ++out; }
marci@168
  1074
// 	  }
marci@168
  1075
// 	  if (!out.valid()) {
marci@168
  1076
// 	    out_or_in=0;
marci@212
  1077
// 	    G->first(v);
marci@212
  1078
// 	    if (v.valid()) G->first(in, v); else in=OldInEdgeIt();
marci@269
  1079
// 	    while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
marci@168
  1080
// 	    while (v.valid() && !in.valid()) { 
marci@168
  1081
// 	      ++v; 
marci@212
  1082
// 	      if (v.valid()) G->first(in, v); 
marci@269
  1083
// 	      while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
marci@168
  1084
// 	    }  
marci@168
  1085
// 	  }
marci@168
  1086
// 	} else {
marci@168
  1087
// 	  ++in;
marci@269
  1088
// 	  while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
marci@168
  1089
// 	  while (v.valid() && !in.valid()) { 
marci@168
  1090
// 	    ++v; 
marci@212
  1091
// 	    if (v.valid()) G->first(in, v); 
marci@269
  1092
// 	    while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
marci@168
  1093
// 	  }
marci@168
  1094
// 	}
marci@168
  1095
// 	return *this;
marci@168
  1096
//       }
marci@155
  1097
    };
marci@155
  1098
marci@266
  1099
    NodeIt& first(NodeIt& v) const { gw.first(v); return v; }
marci@212
  1100
    OutEdgeIt& first(OutEdgeIt& e, Node v) const { 
marci@168
  1101
      e=OutEdgeIt(*this, v); 
marci@174
  1102
      return e;
marci@155
  1103
    }
marci@212
  1104
    EdgeIt& first(EdgeIt& e) const { 
marci@174
  1105
      e=EdgeIt(*this); 
marci@174
  1106
      return e;
marci@155
  1107
    }
marci@155
  1108
   
marci@259
  1109
    NodeIt& next(NodeIt& n) const { return gw.next(n); }
marci@155
  1110
marci@155
  1111
    OutEdgeIt& next(OutEdgeIt& e) const { 
marci@155
  1112
      if (e.out_or_in) {
marci@259
  1113
	Node v=gw.aNode(e.out);
marci@259
  1114
	gw.next(e.out);
marci@269
  1115
	while( gw.valid(e.out) && !(resCap(e.out)>0) ) { gw.next(e.out); }
marci@259
  1116
	if (!gw.valid(e.out)) {
marci@155
  1117
	  e.out_or_in=0;
marci@259
  1118
	  gw.first(e.in, v); 
marci@269
  1119
	  while( gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); }
marci@155
  1120
	}
marci@155
  1121
      } else {
marci@259
  1122
	gw.next(e.in);
marci@269
  1123
	while( gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); } 
marci@155
  1124
      }
marci@155
  1125
      return e;
marci@155
  1126
    }
marci@155
  1127
marci@174
  1128
    EdgeIt& next(EdgeIt& e) const { 
marci@155
  1129
      if (e.out_or_in) {
marci@259
  1130
	gw.next(e.out);
marci@269
  1131
	while (gw.valid(e.out) && !(resCap(e.out)>0) ) { gw.next(e.out); }
marci@259
  1132
	  while (gw.valid(e.v) && !gw.valid(e.out)) { 
marci@259
  1133
	    gw.next(e.v); 
marci@259
  1134
	    if (gw.valid(e.v)) gw.first(e.out, e.v); 
marci@269
  1135
	    while (gw.valid(e.out) && !(resCap(e.out)>0) ) { gw.next(e.out); }
marci@155
  1136
	  }
marci@259
  1137
	  if (!gw.valid(e.out)) {
marci@155
  1138
	    e.out_or_in=0;
marci@259
  1139
	    gw.first(e.v);
marci@269
  1140
	    if (gw.valid(e.v)) gw.first(e.in, e.v); else e.in=INVALID;
marci@269
  1141
	    while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); }
marci@259
  1142
	    while (gw.valid(e.v) && !gw.valid(e.in)) { 
marci@259
  1143
	      gw.next(e.v); 
marci@259
  1144
	      if (gw.valid(e.v)) gw.first(e.in, e.v); 
marci@269
  1145
	      while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); }
marci@155
  1146
	    }  
marci@155
  1147
	  }
marci@155
  1148
	} else {
marci@259
  1149
	  gw.next(e.in);
marci@269
  1150
	  while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); }
marci@259
  1151
	  while (gw.valid(e.v) && !gw.valid(e.in)) { 
marci@259
  1152
	    gw.next(e.v); 
marci@259
  1153
	    if (gw.valid(e.v)) gw.first(e.in, e.v); 
marci@269
  1154
	    while (gw.valid(e.in) && !(resCap(e.in)>0) ) { gw.next(e.in); }
marci@155
  1155
	  }
marci@155
  1156
	}
marci@155
  1157
	return e;
marci@155
  1158
      }
marci@76
  1159
    
marci@76
  1160
marci@155
  1161
    template< typename It >
marci@155
  1162
    It first() const { 
marci@155
  1163
      It e;
marci@212
  1164
      first(e);
marci@155
  1165
      return e; 
marci@155
  1166
    }
marci@76
  1167
marci@155
  1168
    template< typename It >
marci@174
  1169
    It first(Node v) const { 
marci@155
  1170
      It e;
marci@212
  1171
      first(e, v);
marci@155
  1172
      return e; 
marci@155
  1173
    }
marci@76
  1174
marci@174
  1175
    Node tail(Edge e) const { 
marci@259
  1176
      return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); }
marci@174
  1177
    Node head(Edge e) const { 
marci@259
  1178
      return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
marci@76
  1179
marci@174
  1180
    Node aNode(OutEdgeIt e) const { 
marci@259
  1181
      return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); }
marci@174
  1182
    Node bNode(OutEdgeIt e) const { 
marci@259
  1183
      return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
marci@76
  1184
marci@263
  1185
    int nodeNum() const { return gw.nodeNum(); }
marci@263
  1186
    //FIXME
marci@263
  1187
    //int edgeNum() const { return gw.edgeNum(); }
marci@263
  1188
marci@263
  1189
marci@259
  1190
    int id(Node v) const { return gw.id(v); }
marci@155
  1191
marci@259
  1192
    bool valid(Node n) const { return gw.valid(n); }
marci@174
  1193
    bool valid(Edge e) const { 
marci@259
  1194
      return e.out_or_in ? gw.valid(e.out) : gw.valid(e.in); }
marci@155
  1195
marci@174
  1196
    void augment(const Edge& e, Number a) const {
marci@168
  1197
      if (e.out_or_in)  
marci@168
  1198
	flow->set(e.out, flow->get(e.out)+a);
marci@168
  1199
      else  
marci@168
  1200
	flow->set(e.in, flow->get(e.in)-a);
marci@168
  1201
    }
marci@168
  1202
marci@269
  1203
    Number resCap(const Edge& e) const { 
marci@168
  1204
      if (e.out_or_in) 
marci@168
  1205
	return (capacity->get(e.out)-flow->get(e.out)); 
marci@168
  1206
      else 
marci@168
  1207
	return (flow->get(e.in)); 
marci@168
  1208
    }
marci@168
  1209
marci@269
  1210
    Number resCap(OldOutEdgeIt out) const { 
marci@168
  1211
      return (capacity->get(out)-flow->get(out)); 
marci@168
  1212
    }
marci@168
  1213
    
marci@269
  1214
    Number resCap(OldInEdgeIt in) const { 
marci@168
  1215
      return (flow->get(in)); 
marci@168
  1216
    }
marci@168
  1217
marci@266
  1218
//     template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
marci@266
  1219
//     public:
marci@266
  1220
//       NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G) 
marci@266
  1221
// 	: GraphWrapper::NodeMap<T>(_G.gw) { }
marci@266
  1222
//       NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G, 
marci@266
  1223
// 	      T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }
marci@266
  1224
//     };
marci@155
  1225
marci@155
  1226
//     template <typename T>
marci@155
  1227
//     class NodeMap {
marci@155
  1228
//       typename Graph::NodeMap<T> node_map; 
marci@155
  1229
//     public:
marci@174
  1230
//       NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(*(_G.graph)) { }
marci@174
  1231
//       NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(*(_G.graph), a) { }
marci@174
  1232
//       void set(Node nit, T a) { node_map.set(nit, a); }
marci@174
  1233
//       T get(Node nit) const { return node_map.get(nit); }
marci@155
  1234
//     };
marci@155
  1235
marci@155
  1236
    template <typename T>
marci@155
  1237
    class EdgeMap {
marci@259
  1238
      typename GraphWrapper::EdgeMap<T> forward_map, backward_map; 
marci@155
  1239
    public:
marci@266
  1240
      EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }
marci@266
  1241
      EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }
marci@174
  1242
      void set(Edge e, T a) { 
marci@155
  1243
	if (e.out_or_in) 
marci@155
  1244
	  forward_map.set(e.out, a); 
marci@155
  1245
	else 
marci@155
  1246
	  backward_map.set(e.in, a); 
marci@155
  1247
      }
marci@174
  1248
      T get(Edge e) { 
marci@155
  1249
	if (e.out_or_in) 
marci@155
  1250
	  return forward_map.get(e.out); 
marci@155
  1251
	else 
marci@155
  1252
	  return backward_map.get(e.in); 
marci@155
  1253
      }
marci@155
  1254
    };
marci@168
  1255
  };
marci@168
  1256
marci@269
  1257
  //Subgraph on the same node-set and partial edge-set
marci@269
  1258
  template<typename GraphWrapper, typename FirstOutEdgesMap>
marci@269
  1259
  class ErasingFirstGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
marci@269
  1260
  protected:
marci@269
  1261
    FirstOutEdgesMap* first_out_edges;
marci@269
  1262
  public:
marci@269
  1263
    typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
marci@269
  1264
    typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
marci@269
  1265
    typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge Edge;
marci@269
  1266
    typedef typename GraphWrapperSkeleton<GraphWrapper>::EdgeIt EdgeIt;
marci@269
  1267
    typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt InEdgeIt;
marci@269
  1268
    typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt OutEdgeIt;
marci@269
  1269
marci@269
  1270
    ErasingFirstGraphWrapper(GraphWrapper _gw, FirstOutEdgesMap& _first_out_edges) : 
marci@269
  1271
      GraphWrapperSkeleton<GraphWrapper>(_gw), first_out_edges(&_first_out_edges) { }  
marci@269
  1272
marci@269
  1273
    template<typename I> I& first(I& i) const { 
marci@269
  1274
      gw.first(i); 
marci@269
  1275
      //while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
marci@269
  1276
      return i;
marci@269
  1277
    }
marci@269
  1278
    OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
marci@269
  1279
      e=first_out_edges->get(n);
marci@269
  1280
      return e;
marci@269
  1281
    }
marci@269
  1282
    template<typename I, typename P> I& first(I& i, const P& p) const { 
marci@269
  1283
      gw.first(i, p); 
marci@269
  1284
      //while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
marci@269
  1285
      return i;
marci@269
  1286
    }
marci@269
  1287
    
marci@269
  1288
    //template<typename I> I getNext(const I& i) const { 
marci@269
  1289
    //  return gw.getNext(i); 
marci@269
  1290
    //}
marci@269
  1291
    template<typename I> I& next(I &i) const { 
marci@269
  1292
      gw.next(i); 
marci@269
  1293
      //while (gw.valid(i) && !filter_map->get(i)) { gw.next(i); }
marci@269
  1294
      return i;
marci@269
  1295
    }
marci@269
  1296
    
marci@269
  1297
    template< typename It > It first() const { 
marci@269
  1298
      It e; this->first(e); return e; }
marci@269
  1299
    
marci@269
  1300
    template< typename It > It first(const Node& v) const { 
marci@269
  1301
      It e; this->first(e, v); return e; }
marci@269
  1302
marci@269
  1303
    void erase(const OutEdgeIt& e) const {
marci@269
  1304
      OutEdgeIt f=e;
marci@269
  1305
      this->next(f);
marci@269
  1306
      first_out_edges->set(this->tail(e), f);
marci@269
  1307
    }
marci@269
  1308
  };
marci@269
  1309
marci@266
  1310
//   template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
marci@266
  1311
//   class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
marci@266
  1312
//   protected:
marci@266
  1313
//     ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
marci@266
  1314
//     //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
marci@266
  1315
//   public:
marci@266
  1316
//     ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow, 
marci@266
  1317
// 			   const CapacityMap& _capacity) : 
marci@266
  1318
//       ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), 
marci@266
  1319
//       first_out_edges(*this) /*, dist(*this)*/ { 
marci@266
  1320
//       for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
marci@266
  1321
// 	OutEdgeIt e;
marci@266
  1322
// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
marci@266
  1323
// 	first_out_edges.set(n, e);
marci@266
  1324
//       }
marci@266
  1325
//     }
marci@168
  1326
marci@266
  1327
//     //void setGraph(Graph& _graph) { graph = &_graph; }
marci@266
  1328
//     //Graph& getGraph() const { return (*graph); }
marci@168
  1329
  
marci@266
  1330
//     //TrivGraphWrapper() : graph(0) { }
marci@266
  1331
//     //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
marci@168
  1332
marci@266
  1333
//     //typedef Graph BaseGraph;
marci@168
  1334
marci@266
  1335
//     //typedef typename Graph::Node Node;
marci@266
  1336
//     //typedef typename Graph::NodeIt NodeIt;
marci@168
  1337
marci@266
  1338
//     //typedef typename Graph::Edge Edge;
marci@266
  1339
//     //typedef typename Graph::OutEdgeIt OutEdgeIt;
marci@266
  1340
//     //typedef typename Graph::InEdgeIt InEdgeIt;
marci@266
  1341
//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
marci@266
  1342
//     //typedef typename Graph::EdgeIt EdgeIt;
marci@168
  1343
marci@266
  1344
//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
marci@266
  1345
//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
marci@168
  1346
marci@266
  1347
//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
marci@266
  1348
//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
marci@266
  1349
//     //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
marci@266
  1350
//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
marci@266
  1351
//     //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
marci@168
  1352
marci@266
  1353
//     NodeIt& first(NodeIt& n) const { 
marci@266
  1354
//       return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
marci@266
  1355
//     }
marci@168
  1356
marci@266
  1357
//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { 
marci@266
  1358
//       e=first_out_edges.get(n);
marci@266
  1359
//       return e;
marci@266
  1360
//     }
marci@168
  1361
    
marci@266
  1362
//     //ROSSZ template<typename I> I& first(I& i) const { return first(i); }
marci@266
  1363
//     //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const { 
marci@266
  1364
//     //  return first(i, p); }
marci@168
  1365
    
marci@266
  1366
//     //template<typename I> I getNext(const I& i) const { 
marci@266
  1367
//     //  return gw.getNext(i); }
marci@266
  1368
//     //template<typename I> I& next(I &i) const { return gw.next(i); }    
marci@168
  1369
marci@266
  1370
//     template< typename It > It first() const { 
marci@266
  1371
//       It e; first(e); return e; }
marci@168
  1372
marci@266
  1373
//     template< typename It > It first(const Node& v) const { 
marci@266
  1374
//       It e; first(e, v); return e; }
marci@168
  1375
marci@266
  1376
//     //Node head(const Edge& e) const { return gw.head(e); }
marci@266
  1377
//     //Node tail(const Edge& e) const { return gw.tail(e); }
marci@168
  1378
marci@266
  1379
//     //template<typename I> bool valid(const I& i) const 
marci@266
  1380
//     //  { return gw.valid(i); }
marci@168
  1381
  
marci@266
  1382
//     //int nodeNum() const { return gw.nodeNum(); }
marci@266
  1383
//     //int edgeNum() const { return gw.edgeNum(); }
marci@168
  1384
  
marci@266
  1385
//     //template<typename I> Node aNode(const I& e) const { 
marci@266
  1386
//     //  return gw.aNode(e); }
marci@266
  1387
//     //template<typename I> Node bNode(const I& e) const { 
marci@266
  1388
//     //  return gw.bNode(e); }
marci@168
  1389
  
marci@266
  1390
//     //Node addNode() const { return gw.addNode(); }
marci@266
  1391
//     //Edge addEdge(const Node& tail, const Node& head) const { 
marci@266
  1392
//     //  return gw.addEdge(tail, head); }
marci@168
  1393
  
marci@266
  1394
//     //void erase(const OutEdgeIt& e) {
marci@266
  1395
//     //  first_out_edge(this->tail(e))=e;
marci@266
  1396
//     //}
marci@266
  1397
//     void erase(const Edge& e) {
marci@266
  1398
//       OutEdgeIt f(e);
marci@266
  1399
//       next(f);
marci@266
  1400
//       first_out_edges.set(this->tail(e), f);
marci@266
  1401
//     }
marci@266
  1402
//     //template<typename I> void erase(const I& i) const { gw.erase(i); }
marci@168
  1403
  
marci@266
  1404
//     //void clear() const { gw.clear(); }
marci@168
  1405
    
marci@266
  1406
//     template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 
marci@266
  1407
//     public:
marci@266
  1408
//       NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 
marci@266
  1409
// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
marci@266
  1410
//       NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 
marci@266
  1411
// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
marci@266
  1412
//     };
marci@168
  1413
marci@266
  1414
//     template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 
marci@266
  1415
//     public:
marci@266
  1416
//       EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 
marci@266
  1417
// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
marci@266
  1418
//       EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 
marci@266
  1419
// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
marci@266
  1420
//     };
marci@266
  1421
//   };
marci@168
  1422
marci@266
  1423
//   template<typename GraphWrapper> 
marci@266
  1424
//   class FilterGraphWrapper {
marci@266
  1425
//   };
marci@168
  1426
marci@266
  1427
//   template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
marci@266
  1428
//   class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
marci@168
  1429
marci@266
  1430
//     //Graph* graph;
marci@168
  1431
  
marci@266
  1432
//   public:
marci@266
  1433
//     //typedef Graph BaseGraph;
marci@168
  1434
marci@266
  1435
//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
marci@266
  1436
//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
marci@168
  1437
marci@266
  1438
//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
marci@266
  1439
//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
marci@266
  1440
//     //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
marci@266
  1441
//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
marci@266
  1442
//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
marci@168
  1443
marci@266
  1444
//     //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
marci@168
  1445
    
marci@266
  1446
//   public:
marci@266
  1447
//     FilterGraphWrapper(const Graph& _G, FlowMap& _flow, 
marci@266
  1448
// 			   const CapacityMap& _capacity) : 
marci@266
  1449
//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) { 
marci@266
  1450
//     }
marci@168
  1451
marci@266
  1452
//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
marci@266
  1453
//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
marci@266
  1454
//       while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e)))) 
marci@266
  1455
// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
marci@266
  1456
//       return e;
marci@266
  1457
//     }
marci@168
  1458
marci@266
  1459
//     NodeIt& next(NodeIt& e) const {
marci@266
  1460
//       return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
marci@266
  1461
//     }
marci@168
  1462
marci@266
  1463
//     OutEdgeIt& next(OutEdgeIt& e) const {
marci@266
  1464
//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
marci@266
  1465
//       while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e)))) 
marci@266
  1466
// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
marci@266
  1467
//       return e;
marci@266
  1468
//     }
marci@168
  1469
marci@266
  1470
//     NodeIt& first(NodeIt& n) const {
marci@266
  1471
//       return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
marci@266
  1472
//     }
marci@168
  1473
marci@266
  1474
//     void erase(const Edge& e) {
marci@266
  1475
//       OutEdgeIt f(e);
marci@266
  1476
//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
marci@266
  1477
//       while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f)))) 
marci@266
  1478
// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
marci@266
  1479
//       first_out_edges.set(this->tail(e), f);
marci@266
  1480
//     }
marci@168
  1481
marci@266
  1482
//     //TrivGraphWrapper() : graph(0) { }
marci@266
  1483
//     //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
marci@168
  1484
marci@266
  1485
//     //void setGraph(Graph& _graph) { graph = &_graph; }
marci@266
  1486
//     //Graph& getGraph() const { return (*graph); }
marci@168
  1487
    
marci@266
  1488
//     //template<typename I> I& first(I& i) const { return gw.first(i); }
marci@266
  1489
//     //template<typename I, typename P> I& first(I& i, const P& p) const { 
marci@266
  1490
//     //  return gw.first(i, p); }
marci@168
  1491
    
marci@266
  1492
//     //template<typename I> I getNext(const I& i) const { 
marci@266
  1493
//     //  return gw.getNext(i); }
marci@266
  1494
//     //template<typename I> I& next(I &i) const { return gw.next(i); }    
marci@168
  1495
marci@266
  1496
//     template< typename It > It first() const { 
marci@266
  1497
//       It e; first(e); return e; }
marci@168
  1498
marci@266
  1499
//     template< typename It > It first(const Node& v) const { 
marci@266
  1500
//       It e; first(e, v); return e; }
marci@168
  1501
marci@266
  1502
//     //Node head(const Edge& e) const { return gw.head(e); }
marci@266
  1503
//     //Node tail(const Edge& e) const { return gw.tail(e); }
marci@168
  1504
marci@266
  1505
//     //template<typename I> bool valid(const I& i) const 
marci@266
  1506
//     //  { return gw.valid(i); }
marci@168
  1507
  
marci@266
  1508
//     //template<typename I> void setInvalid(const I &i);
marci@266
  1509
//     //{ return gw.setInvalid(i); }
marci@168
  1510
marci@266
  1511
//     //int nodeNum() const { return gw.nodeNum(); }
marci@266
  1512
//     //int edgeNum() const { return gw.edgeNum(); }
marci@168
  1513
  
marci@266
  1514
//     //template<typename I> Node aNode(const I& e) const { 
marci@266
  1515
//     //  return gw.aNode(e); }
marci@266
  1516
//     //template<typename I> Node bNode(const I& e) const { 
marci@266
  1517
//     //  return gw.bNode(e); }
marci@168
  1518
  
marci@266
  1519
//     //Node addNode() const { return gw.addNode(); }
marci@266
  1520
//     //Edge addEdge(const Node& tail, const Node& head) const { 
marci@266
  1521
//     //  return gw.addEdge(tail, head); }
marci@168
  1522
  
marci@266
  1523
//     //template<typename I> void erase(const I& i) const { gw.erase(i); }
marci@168
  1524
  
marci@266
  1525
//     //void clear() const { gw.clear(); }
marci@168
  1526
    
marci@266
  1527
//     template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 
marci@266
  1528
//     public:
marci@266
  1529
//       NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 
marci@266
  1530
// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
marci@266
  1531
//       NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 
marci@266
  1532
// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
marci@266
  1533
//     };
marci@168
  1534
marci@266
  1535
//     template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 
marci@266
  1536
//     public:
marci@266
  1537
//       EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 
marci@266
  1538
// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
marci@266
  1539
//       EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 
marci@266
  1540
// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
marci@266
  1541
//     };
marci@168
  1542
marci@266
  1543
//   public:
marci@266
  1544
//     ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
marci@155
  1545
marci@266
  1546
//   };
marci@76
  1547
marci@76
  1548
marci@148
  1549
marci@148
  1550
// // FIXME: comparison should be made better!!!
marci@148
  1551
//   template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
marci@148
  1552
//   class ResGraphWrapper
marci@148
  1553
//   {
marci@148
  1554
//     Graph* graph;
marci@76
  1555
  
marci@148
  1556
//   public:
marci@148
  1557
//     typedef Graph BaseGraph;
marci@76
  1558
marci@174
  1559
//     typedef typename Graph::Node Node;
marci@174
  1560
//     typedef typename Graph::Edge Edge;
marci@174
  1561
  
marci@148
  1562
//     typedef typename Graph::NodeIt NodeIt;
marci@76
  1563
   
marci@148
  1564
//     class OutEdgeIt {
marci@148
  1565
//     public:
marci@174
  1566
//       //Graph::Node n;
marci@148
  1567
//       bool out_or_in;
marci@148
  1568
//       typename Graph::OutEdgeIt o;
marci@148
  1569
//       typename Graph::InEdgeIt i;   
marci@148
  1570
//     };
marci@148
  1571
//     class InEdgeIt {
marci@148
  1572
//     public:
marci@174
  1573
//       //Graph::Node n;
marci@148
  1574
//       bool out_or_in;
marci@148
  1575
//       typename Graph::OutEdgeIt o;
marci@148
  1576
//       typename Graph::InEdgeIt i;   
marci@148
  1577
//     };
marci@148
  1578
//     typedef typename Graph::SymEdgeIt SymEdgeIt;
marci@174
  1579
//     typedef typename Graph::EdgeIt EdgeIt;
marci@76
  1580
marci@259
  1581
//     int nodeNum() const { return gw.nodeNum(); }
marci@259
  1582
//     int edgeNum() const { return gw.edgeNum(); }
marci@76
  1583
marci@259
  1584
//     Node& first(Node& n) const { return gw.first(n); }
marci@76
  1585
marci@174
  1586
//     // Edge and SymEdge  is missing!!!!
marci@174
  1587
//     // Edge <-> In/OutEdgeIt conversion is missing!!!!
marci@76
  1588
marci@148
  1589
//     //FIXME
marci@212
  1590
//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const 
marci@148
  1591
//       {
marci@148
  1592
// 	e.n=n;
marci@259
  1593
// 	gw.first(e.o,n);
marci@259
  1594
// 	while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
marci@259
  1595
// 	  gw.goNext(e.o);
marci@259
  1596
// 	if(!gw.valid(e.o)) {
marci@259
  1597
// 	  gw.first(e.i,n);
marci@259
  1598
// 	  while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
marci@259
  1599
// 	    gw.goNext(e.i);
marci@148
  1600
// 	}
marci@148
  1601
// 	return e;
marci@148
  1602
//       }
marci@148
  1603
// /*
marci@148
  1604
//   OutEdgeIt &goNext(OutEdgeIt &e)
marci@148
  1605
//   {
marci@259
  1606
//   if(gw.valid(e.o)) {
marci@259
  1607
//   while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
marci@259
  1608
//   gw.goNext(e.o);
marci@259
  1609
//   if(gw.valid(e.o)) return e;
marci@259
  1610
//   else gw.first(e.i,e.n);
marci@148
  1611
//   }
marci@148
  1612
//   else {
marci@259
  1613
//   while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
marci@259
  1614
//   gw.goNext(e.i);
marci@148
  1615
//   return e;
marci@148
  1616
//   }
marci@148
  1617
//   }
marci@148
  1618
//   OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
marci@148
  1619
// */
marci@259
  1620
//     //bool valid(const OutEdgeIt e) { return gw.valid(e.o)||gw.valid(e.i);}
marci@76
  1621
marci@148
  1622
//     //FIXME
marci@212
  1623
//     InEdgeIt& first(InEdgeIt& e, const Node& n) const 
marci@148
  1624
//       {
marci@148
  1625
// 	e.n=n;
marci@259
  1626
// 	gw.first(e.i,n);
marci@259
  1627
// 	while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
marci@259
  1628
// 	  gw.goNext(e.i);
marci@259
  1629
// 	if(!gw.valid(e.i)) {
marci@259
  1630
// 	  gw.first(e.o,n);
marci@259
  1631
// 	  while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
marci@259
  1632
// 	    gw.goNext(e.o);
marci@148
  1633
// 	}
marci@148
  1634
// 	return e;
marci@148
  1635
//       }
marci@148
  1636
// /*
marci@148
  1637
//   InEdgeIt &goNext(InEdgeIt &e)
marci@148
  1638
//   {
marci@259
  1639
//   if(gw.valid(e.i)) {
marci@259
  1640
//   while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
marci@259
  1641
//   gw.goNext(e.i);
marci@259
  1642
//   if(gw.valid(e.i)) return e;
marci@259
  1643
//   else gw.first(e.o,e.n);
marci@148
  1644
//   }
marci@148
  1645
//   else {
marci@259
  1646
//   while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
marci@259
  1647
//   gw.goNext(e.o);
marci@148
  1648
//   return e;
marci@148
  1649
//   }
marci@148
  1650
//   }
marci@148
  1651
//   InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
marci@148
  1652
// */
marci@259
  1653
//     //bool valid(const InEdgeIt e) { return gw.valid(e.i)||gw.valid(e.o);}
marci@76
  1654
marci@259
  1655
//     //template<typename I> I &goNext(I &i); { return gw.goNext(i); }
marci@259
  1656
//     //template<typename I> I next(const I i); { return gw.goNext(i); }
marci@76
  1657
marci@148
  1658
//     template< typename It > It first() const { 
marci@212
  1659
//       It e; first(e); return e; }
marci@76
  1660
marci@174
  1661
//     template< typename It > It first(Node v) const { 
marci@212
  1662
//       It e; first(e, v); return e; }
marci@76
  1663
marci@259
  1664
//     Node head(const Edge& e) const { return gw.head(e); }
marci@259
  1665
//     Node tail(const Edge& e) const { return gw.tail(e); }
marci@76
  1666
  
marci@174
  1667
//     template<typename I> Node aNode(const I& e) const { 
marci@259
  1668
//       return gw.aNode(e); }
marci@174
  1669
//     template<typename I> Node bNode(const I& e) const { 
marci@259
  1670
//       return gw.bNode(e); }
marci@76
  1671
  
marci@148
  1672
//     //template<typename I> bool valid(const I i);
marci@259
  1673
//     //{ return gw.valid(i); }
marci@76
  1674
  
marci@148
  1675
//     //template<typename I> void setInvalid(const I &i);
marci@259
  1676
//     //{ return gw.setInvalid(i); }
marci@76
  1677
  
marci@259
  1678
//     Node addNode() { return gw.addNode(); }
marci@174
  1679
//     Edge addEdge(const Node& tail, const Node& head) { 
marci@259
  1680
//       return gw.addEdge(tail, head); }
marci@76
  1681
  
marci@259
  1682
//     template<typename I> void erase(const I& i) { gw.erase(i); }
marci@76
  1683
  
marci@259
  1684
//     void clear() { gw.clear(); }
marci@76
  1685
  
marci@148
  1686
//     template<typename S> class NodeMap : public Graph::NodeMap<S> { };
marci@148
  1687
//     template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
marci@76
  1688
  
marci@148
  1689
//     void setGraph(Graph& _graph) { graph = &_graph; }
marci@148
  1690
//     Graph& getGraph() { return (*graph); }
marci@76
  1691
marci@148
  1692
//     //ResGraphWrapper() : graph(0) { }
marci@148
  1693
//     ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
marci@148
  1694
//   };
marci@76
  1695
alpar@105
  1696
} //namespace hugo
marci@76
  1697
marci@259
  1698
#endif //HUGO_GRAPH_WRAPPER_H
marci@76
  1699