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