src/hugo/graph_wrapper.h
author marci
Tue, 21 Sep 2004 11:54:20 +0000
changeset 892 004636791dd7
parent 891 74589d20dbc3
child 906 17f31d280385
permissions -rw-r--r--
graph_wrappers now pass the tests.
marci@556
     1
// -*- c++ -*-
marci@556
     2
#ifndef HUGO_GRAPH_WRAPPER_H
marci@556
     3
#define HUGO_GRAPH_WRAPPER_H
marci@556
     4
marci@556
     5
///\ingroup gwrappers
marci@556
     6
///\file
marci@556
     7
///\brief Several graph wrappers.
marci@556
     8
///
marci@556
     9
///This file contains several useful graph wrapper functions.
marci@556
    10
///
marci@556
    11
///\author Marton Makai
marci@556
    12
marci@556
    13
#include <hugo/invalid.h>
marci@650
    14
#include <hugo/maps.h>
alpar@774
    15
#include <iostream>
marci@556
    16
marci@556
    17
namespace hugo {
marci@556
    18
marci@556
    19
  // Graph wrappers
marci@556
    20
marci@556
    21
  /// \addtogroup gwrappers
marci@556
    22
  /// A main parts of HUGOlib are the different graph structures, 
marci@556
    23
  /// generic graph algorithms, graph concepts which couple these, and 
marci@556
    24
  /// graph wrappers. While the previous ones are more or less clear, the 
marci@556
    25
  /// latter notion needs further explanation.
marci@556
    26
  /// Graph wrappers are graph classes which serve for considering graph 
marci@556
    27
  /// structures in different ways. A short example makes the notion much 
marci@556
    28
  /// clearer. 
marci@556
    29
  /// Suppose that we have an instance \c g of a directed graph
marci@556
    30
  /// type say \c ListGraph and an algorithm 
marci@556
    31
  /// \code template<typename Graph> int algorithm(const Graph&); \endcode 
marci@556
    32
  /// is needed to run on the reversely oriented graph. 
marci@556
    33
  /// It may be expensive (in time or in memory usage) to copy 
marci@556
    34
  /// \c g with the reverse orientation. 
marci@556
    35
  /// Thus, a wrapper class
marci@556
    36
  /// \code template<typename Graph> class RevGraphWrapper; \endcode is used. 
marci@556
    37
  /// The code looks as follows
marci@556
    38
  /// \code
marci@556
    39
  /// ListGraph g;
marci@556
    40
  /// RevGraphWrapper<ListGraph> rgw(g);
marci@556
    41
  /// int result=algorithm(rgw);
marci@556
    42
  /// \endcode
marci@556
    43
  /// After running the algorithm, the original graph \c g 
marci@556
    44
  /// remains untouched. Thus the graph wrapper used above is to consider the 
marci@556
    45
  /// original graph with reverse orientation. 
marci@556
    46
  /// This techniques gives rise to an elegant code, and 
marci@556
    47
  /// based on stable graph wrappers, complex algorithms can be 
marci@556
    48
  /// implemented easily. 
marci@556
    49
  /// In flow, circulation and bipartite matching problems, the residual 
marci@556
    50
  /// graph is of particular importance. Combining a wrapper implementing 
marci@556
    51
  /// this, shortest path algorithms and minimum mean cycle algorithms, 
marci@556
    52
  /// a range of weighted and cardinality optimization algorithms can be 
marci@556
    53
  /// obtained. For lack of space, for other examples, 
marci@556
    54
  /// the interested user is referred to the detailed documentation of graph 
marci@556
    55
  /// wrappers. 
marci@556
    56
  /// The behavior of graph wrappers can be very different. Some of them keep 
marci@556
    57
  /// capabilities of the original graph while in other cases this would be 
marci@556
    58
  /// meaningless. This means that the concepts that they are a model of depend 
marci@556
    59
  /// on the graph wrapper, and the wrapped graph(s). 
marci@556
    60
  /// If an edge of \c rgw is deleted, this is carried out by 
marci@556
    61
  /// deleting the corresponding edge of \c g. But for a residual 
marci@556
    62
  /// graph, this operation has no sense. 
marci@556
    63
  /// Let we stand one more example here to simplify your work. 
marci@556
    64
  /// wrapper class
marci@556
    65
  /// \code template<typename Graph> class RevGraphWrapper; \endcode 
marci@556
    66
  /// has constructor 
marci@556
    67
  /// <tt> RevGraphWrapper(Graph& _g)</tt>. 
marci@556
    68
  /// This means that in a situation, 
marci@556
    69
  /// when a <tt> const ListGraph& </tt> reference to a graph is given, 
marci@556
    70
  /// then it have to be instantiated with <tt>Graph=const ListGraph</tt>.
marci@556
    71
  /// \code
marci@556
    72
  /// int algorithm1(const ListGraph& g) {
marci@556
    73
  ///   RevGraphWrapper<const ListGraph> rgw(g);
marci@556
    74
  ///   return algorithm2(rgw);
marci@556
    75
  /// }
marci@556
    76
  /// \endcode
marci@556
    77
marci@556
    78
  /// \addtogroup gwrappers
marci@556
    79
  /// @{
marci@556
    80
marci@556
    81
  ///Base type for the Graph Wrappers
marci@556
    82
alpar@879
    83
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
    84
  ///parts of the lib. Use them at you own risk.
alpar@879
    85
  ///
marci@556
    86
  ///This is the base type for the Graph Wrappers.
marci@556
    87
  ///\todo Some more docs... 
marci@556
    88
  ///
marci@612
    89
  ///\author Marton Makai 
marci@556
    90
  template<typename Graph>
marci@556
    91
  class GraphWrapper {
marci@556
    92
  protected:
marci@556
    93
    Graph* graph;
marci@556
    94
    GraphWrapper() : graph(0) { }
marci@556
    95
    void setGraph(Graph& _graph) { graph=&_graph; }
marci@556
    96
marci@556
    97
  public:
marci@556
    98
    typedef Graph BaseGraph;
marci@556
    99
    typedef Graph ParentGraph;
marci@556
   100
marci@556
   101
    GraphWrapper(Graph& _graph) : graph(&_graph) { }
alpar@774
   102
    GraphWrapper(const GraphWrapper<Graph>& gw) : graph(gw.graph) { }
marci@556
   103
 
alpar@774
   104
    typedef typename Graph::Node Node;
alpar@774
   105
    class NodeIt : public Node { 
alpar@774
   106
      const GraphWrapper<Graph>* gw;
marci@556
   107
      friend class GraphWrapper<Graph>;
marci@556
   108
     public:
marci@556
   109
      NodeIt() { }
alpar@774
   110
      NodeIt(Invalid i) : Node(i) { }
alpar@774
   111
      NodeIt(const GraphWrapper<Graph>& _gw) : 
alpar@774
   112
	Node(typename Graph::NodeIt(*(_gw.graph))), gw(&_gw) { }
alpar@774
   113
      NodeIt(const GraphWrapper<Graph>& _gw, const Node& n) : 
alpar@774
   114
	Node(n), gw(&_gw) { }
alpar@774
   115
      NodeIt& operator++() { 
alpar@774
   116
	*(static_cast<Node*>(this))=
alpar@774
   117
	  ++(typename Graph::NodeIt(*(gw->graph), *this));
alpar@774
   118
	return *this; 
alpar@774
   119
      }
marci@556
   120
    };
alpar@774
   121
    typedef typename Graph::Edge Edge;
alpar@774
   122
    class OutEdgeIt : public Edge { 
alpar@774
   123
      const GraphWrapper<Graph>* gw;
marci@556
   124
      friend class GraphWrapper<Graph>;
alpar@774
   125
     public:
alpar@774
   126
      OutEdgeIt() { }
alpar@774
   127
      OutEdgeIt(Invalid i) : Edge(i) { }
alpar@774
   128
      OutEdgeIt(const GraphWrapper<Graph>& _gw, const Node& n) : 
alpar@774
   129
	Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
alpar@774
   130
      OutEdgeIt(const GraphWrapper<Graph>& _gw, const Edge& e) : 
alpar@774
   131
	Edge(e), gw(&_gw) { }
alpar@774
   132
      OutEdgeIt& operator++() { 
alpar@774
   133
	*(static_cast<Edge*>(this))=
alpar@774
   134
	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
alpar@774
   135
	return *this; 
alpar@774
   136
      }
marci@556
   137
    };
alpar@774
   138
    class InEdgeIt : public Edge { 
alpar@774
   139
      const GraphWrapper<Graph>* gw;
marci@556
   140
      friend class GraphWrapper<Graph>;
alpar@774
   141
     public:
marci@556
   142
      InEdgeIt() { }
alpar@774
   143
      InEdgeIt(Invalid i) : Edge(i) { }
alpar@774
   144
      InEdgeIt(const GraphWrapper<Graph>& _gw, const Node& n) : 
alpar@774
   145
	Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
alpar@774
   146
      InEdgeIt(const GraphWrapper<Graph>& _gw, const Edge& e) : 
alpar@774
   147
	Edge(e), gw(&_gw) { }
alpar@774
   148
      InEdgeIt& operator++() { 
alpar@774
   149
	*(static_cast<Edge*>(this))=
alpar@774
   150
	  ++(typename Graph::InEdgeIt(*(gw->graph), *this));
alpar@774
   151
	return *this; 
alpar@774
   152
      }
marci@556
   153
    };
alpar@774
   154
    class EdgeIt : public Edge { 
alpar@774
   155
      const GraphWrapper<Graph>* gw;
marci@556
   156
      friend class GraphWrapper<Graph>;
alpar@774
   157
     public:
marci@556
   158
      EdgeIt() { }
alpar@774
   159
      EdgeIt(Invalid i) : Edge(i) { }
alpar@774
   160
      EdgeIt(const GraphWrapper<Graph>& _gw) : 
alpar@774
   161
	Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { }
alpar@774
   162
      EdgeIt(const GraphWrapper<Graph>& _gw, const Edge& e) : 
marci@777
   163
	Edge(e), gw(&_gw) { }
alpar@774
   164
      EdgeIt& operator++() { 
alpar@774
   165
	*(static_cast<Edge*>(this))=
alpar@774
   166
	  ++(typename Graph::EdgeIt(*(gw->graph), *this));
alpar@774
   167
	return *this; 
alpar@774
   168
      }
marci@556
   169
    };
marci@556
   170
   
marci@556
   171
    NodeIt& first(NodeIt& i) const { 
marci@556
   172
      i=NodeIt(*this); return i;
marci@556
   173
    }
marci@556
   174
    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
marci@556
   175
      i=OutEdgeIt(*this, p); return i;
marci@556
   176
    }
marci@556
   177
    InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
marci@556
   178
      i=InEdgeIt(*this, p); return i;
marci@556
   179
    }
marci@556
   180
    EdgeIt& first(EdgeIt& i) const { 
marci@556
   181
      i=EdgeIt(*this); return i;
marci@556
   182
    }
marci@556
   183
marci@556
   184
    Node tail(const Edge& e) const { 
marci@556
   185
      return Node(graph->tail(static_cast<typename Graph::Edge>(e))); }
marci@556
   186
    Node head(const Edge& e) const { 
marci@556
   187
      return Node(graph->head(static_cast<typename Graph::Edge>(e))); }
marci@556
   188
marci@556
   189
    int nodeNum() const { return graph->nodeNum(); }
marci@556
   190
    int edgeNum() const { return graph->edgeNum(); }
marci@556
   191
  
marci@556
   192
    Node addNode() const { return Node(graph->addNode()); }
marci@556
   193
    Edge addEdge(const Node& tail, const Node& head) const { 
marci@556
   194
      return Edge(graph->addEdge(tail, head)); }
marci@556
   195
marci@556
   196
    void erase(const Node& i) const { graph->erase(i); }
marci@556
   197
    void erase(const Edge& i) const { graph->erase(i); }
marci@556
   198
  
marci@556
   199
    void clear() const { graph->clear(); }
marci@556
   200
    
alpar@736
   201
    bool forward(const Edge& e) const { return graph->forward(e); }
alpar@736
   202
    bool backward(const Edge& e) const { return graph->backward(e); }
marci@739
   203
marci@739
   204
    int id(const Node& v) const { return graph->id(v); }
marci@739
   205
    int id(const Edge& e) const { return graph->id(e); }
marci@650
   206
    
marci@738
   207
    Edge opposite(const Edge& e) const { return Edge(graph->opposite(e)); }
marci@650
   208
marci@556
   209
deba@877
   210
    IMPORT_NODE_MAP(Graph, *(gw.graph), GraphWrapper, gw);    
deba@877
   211
    IMPORT_EDGE_MAP(Graph, *(gw.graph), GraphWrapper, gw);
deba@877
   212
    
deba@877
   213
marci@556
   214
  };
marci@556
   215
marci@569
   216
marci@569
   217
marci@556
   218
  /// A graph wrapper which reverses the orientation of the edges.
marci@556
   219
alpar@879
   220
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
   221
  ///parts of the lib. Use them at you own risk.
alpar@879
   222
  ///
marci@556
   223
  /// A graph wrapper which reverses the orientation of the edges.
marci@612
   224
  /// Thus \c Graph have to be a directed graph type.
marci@556
   225
  ///
marci@556
   226
  ///\author Marton Makai
marci@556
   227
  template<typename Graph>
marci@556
   228
  class RevGraphWrapper : public GraphWrapper<Graph> {
marci@650
   229
  public:
marci@650
   230
    typedef GraphWrapper<Graph> Parent; 
marci@556
   231
  protected:
marci@612
   232
    RevGraphWrapper() : GraphWrapper<Graph>() { }
marci@556
   233
  public:
marci@556
   234
    RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }  
alpar@774
   235
    RevGraphWrapper(const RevGraphWrapper<Graph>& gw) : Parent(gw) { }
marci@556
   236
marci@556
   237
    typedef typename GraphWrapper<Graph>::Node Node;
marci@556
   238
    typedef typename GraphWrapper<Graph>::Edge Edge;
marci@792
   239
    //remark: OutEdgeIt and InEdgeIt cannot be typedef-ed to each other
marci@792
   240
    //because this does not work is some of them are not defined in the 
marci@792
   241
    //original graph. The problem with this is that typedef-ed stuff 
marci@792
   242
    //are instantiated in c++.
alpar@774
   243
    class OutEdgeIt : public Edge { 
alpar@774
   244
      const RevGraphWrapper<Graph>* gw;
marci@556
   245
      friend class GraphWrapper<Graph>;
alpar@774
   246
     public:
marci@556
   247
      OutEdgeIt() { }
alpar@774
   248
      OutEdgeIt(Invalid i) : Edge(i) { }
alpar@774
   249
      OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : 
alpar@774
   250
	Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
alpar@774
   251
      OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : 
alpar@774
   252
	Edge(e), gw(&_gw) { }
alpar@774
   253
      OutEdgeIt& operator++() { 
alpar@774
   254
	*(static_cast<Edge*>(this))=
alpar@774
   255
	  ++(typename Graph::InEdgeIt(*(gw->graph), *this));
alpar@774
   256
	return *this; 
alpar@774
   257
      }
marci@556
   258
    };
alpar@774
   259
    class InEdgeIt : public Edge { 
alpar@774
   260
      const RevGraphWrapper<Graph>* gw;
marci@556
   261
      friend class GraphWrapper<Graph>;
alpar@774
   262
     public:
marci@556
   263
      InEdgeIt() { }
alpar@774
   264
      InEdgeIt(Invalid i) : Edge(i) { }
alpar@774
   265
      InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : 
alpar@774
   266
	Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
alpar@774
   267
      InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : 
alpar@774
   268
	Edge(e), gw(&_gw) { }
alpar@774
   269
      InEdgeIt& operator++() { 
alpar@774
   270
	*(static_cast<Edge*>(this))=
alpar@774
   271
	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
alpar@774
   272
	return *this; 
alpar@774
   273
      }
marci@556
   274
    };
marci@556
   275
marci@556
   276
    using GraphWrapper<Graph>::first;
marci@556
   277
    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
marci@556
   278
      i=OutEdgeIt(*this, p); return i;
marci@556
   279
    }
marci@556
   280
    InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
marci@556
   281
      i=InEdgeIt(*this, p); return i;
marci@556
   282
    }
marci@556
   283
marci@556
   284
    Node tail(const Edge& e) const { 
marci@556
   285
      return GraphWrapper<Graph>::head(e); }
marci@556
   286
    Node head(const Edge& e) const { 
marci@556
   287
      return GraphWrapper<Graph>::tail(e); }
marci@556
   288
deba@891
   289
    //    KEEP_MAPS(Parent, RevGraphWrapper);
deba@877
   290
marci@556
   291
  };
marci@556
   292
marci@775
   293
marci@775
   294
marci@612
   295
  /// A graph wrapper for hiding nodes and edges from a graph.
marci@556
   296
  
alpar@879
   297
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
   298
  ///parts of the lib. Use them at you own risk.
alpar@879
   299
  ///
marci@556
   300
  /// This wrapper shows a graph with filtered node-set and 
marci@838
   301
  /// edge-set. Given a bool-valued map on the node-set and one on 
marci@838
   302
  /// the edge-set of the graphs, the iterators shows only the objects 
marci@838
   303
  /// having true value. 
marci@838
   304
  /// The quick brown fox iterators jump over 
marci@838
   305
  /// the lazy dog nodes or edges if their values for are false in the 
marci@838
   306
  /// corresponding bool maps. 
marci@556
   307
  ///
marci@556
   308
  ///\author Marton Makai
marci@556
   309
  template<typename Graph, typename NodeFilterMap, 
marci@556
   310
	   typename EdgeFilterMap>
marci@556
   311
  class SubGraphWrapper : public GraphWrapper<Graph> {
marci@650
   312
  public:
marci@650
   313
    typedef GraphWrapper<Graph> Parent;
marci@556
   314
  protected:
marci@556
   315
    NodeFilterMap* node_filter_map;
marci@556
   316
    EdgeFilterMap* edge_filter_map;
marci@556
   317
marci@612
   318
    SubGraphWrapper() : GraphWrapper<Graph>(), 
marci@556
   319
			node_filter_map(0), edge_filter_map(0) { }
marci@556
   320
    void setNodeFilterMap(NodeFilterMap& _node_filter_map) {
marci@556
   321
      node_filter_map=&_node_filter_map;
marci@556
   322
    }
marci@556
   323
    void setEdgeFilterMap(EdgeFilterMap& _edge_filter_map) {
marci@556
   324
      edge_filter_map=&_edge_filter_map;
marci@556
   325
    }
marci@556
   326
    
marci@556
   327
  public:
marci@556
   328
    SubGraphWrapper(Graph& _graph, NodeFilterMap& _node_filter_map, 
marci@556
   329
		    EdgeFilterMap& _edge_filter_map) : 
marci@556
   330
      GraphWrapper<Graph>(_graph), node_filter_map(&_node_filter_map), 
marci@556
   331
      edge_filter_map(&_edge_filter_map) { }  
marci@556
   332
marci@556
   333
    typedef typename GraphWrapper<Graph>::Node Node;
marci@775
   334
    class NodeIt : public Node { 
marci@775
   335
      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
marci@556
   336
      friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
marci@775
   337
    public:
marci@556
   338
      NodeIt() { }
marci@775
   339
      NodeIt(Invalid i) : Node(i) { }
marci@775
   340
      NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : 
marci@854
   341
	Node(typename Graph::NodeIt(*(_gw.graph))), gw(&_gw) { 
marci@854
   342
	while (*static_cast<Node*>(this)!=INVALID && 
marci@861
   343
	       !(*(gw->node_filter_map))[*this]) 
marci@854
   344
	  *(static_cast<Node*>(this))=
marci@854
   345
	    ++(typename Graph::NodeIt(*(gw->graph), *this));
marci@854
   346
      }
marci@775
   347
      NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
marci@775
   348
	     const Node& n) : 
marci@775
   349
	Node(n), gw(&_gw) { }
marci@775
   350
      NodeIt& operator++() { 
marci@775
   351
	*(static_cast<Node*>(this))=
marci@775
   352
	  ++(typename Graph::NodeIt(*(gw->graph), *this));
marci@775
   353
	while (*static_cast<Node*>(this)!=INVALID && 
marci@775
   354
	       !(*(gw->node_filter_map))[*this]) 
marci@775
   355
	  *(static_cast<Node*>(this))=
marci@775
   356
	    ++(typename Graph::NodeIt(*(gw->graph), *this));
marci@775
   357
	return *this; 
marci@556
   358
      }
marci@556
   359
    };
marci@556
   360
    typedef typename GraphWrapper<Graph>::Edge Edge;
marci@775
   361
    class OutEdgeIt : public Edge { 
marci@775
   362
      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
marci@556
   363
      friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
marci@556
   364
    public:
marci@556
   365
      OutEdgeIt() { }
marci@775
   366
      OutEdgeIt(Invalid i) : Edge(i) { }
marci@775
   367
      OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
marci@854
   368
	Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { 
marci@854
   369
	while (*static_cast<Edge*>(this)!=INVALID && 
marci@854
   370
	       !(*(gw->edge_filter_map))[*this]) 
marci@854
   371
	  *(static_cast<Edge*>(this))=
marci@854
   372
	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@854
   373
      }
marci@775
   374
      OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
marci@775
   375
	     const Edge& e) : 
marci@775
   376
	Edge(e), gw(&_gw) { }
marci@775
   377
      OutEdgeIt& operator++() { 
marci@775
   378
	*(static_cast<Edge*>(this))=
marci@775
   379
	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@775
   380
	while (*static_cast<Edge*>(this)!=INVALID && 
marci@775
   381
	       !(*(gw->edge_filter_map))[*this]) 
marci@775
   382
	  *(static_cast<Edge*>(this))=
marci@775
   383
	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@775
   384
	return *this; 
marci@556
   385
      }
marci@556
   386
    };
marci@775
   387
    class InEdgeIt : public Edge { 
marci@775
   388
      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
marci@556
   389
      friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
marci@556
   390
    public:
marci@556
   391
      InEdgeIt() { }
marci@775
   392
      //      InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }
marci@775
   393
      InEdgeIt(Invalid i) : Edge(i) { }
marci@775
   394
      InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
marci@854
   395
	Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { 
marci@854
   396
	while (*static_cast<Edge*>(this)!=INVALID && 
marci@854
   397
	       !(*(gw->edge_filter_map))[*this]) 
marci@854
   398
	  *(static_cast<Edge*>(this))=
marci@854
   399
	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@854
   400
      }
marci@775
   401
      InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
marci@775
   402
	     const Edge& e) : 
marci@775
   403
	Edge(e), gw(&_gw) { }
marci@775
   404
      InEdgeIt& operator++() { 
marci@775
   405
	*(static_cast<Edge*>(this))=
marci@775
   406
	  ++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@775
   407
	while (*static_cast<Edge*>(this)!=INVALID && 
marci@775
   408
	       !(*(gw->edge_filter_map))[*this]) 
marci@775
   409
	  *(static_cast<Edge*>(this))=
marci@775
   410
	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@775
   411
	return *this; 
marci@556
   412
      }
marci@556
   413
    };
marci@775
   414
    class EdgeIt : public Edge { 
marci@775
   415
      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
marci@556
   416
      friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
marci@556
   417
    public:
marci@556
   418
      EdgeIt() { }
marci@775
   419
      EdgeIt(Invalid i) : Edge(i) { }
marci@775
   420
      EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : 
marci@854
   421
	Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { 
marci@854
   422
	while (*static_cast<Edge*>(this)!=INVALID && 
marci@854
   423
	       !(*(gw->edge_filter_map))[*this]) 
marci@854
   424
	  *(static_cast<Edge*>(this))=
marci@854
   425
	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@854
   426
      }
marci@775
   427
      EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
marci@775
   428
	     const Edge& e) : 
marci@775
   429
	Edge(e), gw(&_gw) { }
marci@775
   430
      EdgeIt& operator++() { 
marci@775
   431
	*(static_cast<Edge*>(this))=
marci@775
   432
	  ++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@775
   433
	while (*static_cast<Edge*>(this)!=INVALID && 
marci@775
   434
	       !(*(gw->edge_filter_map))[*this]) 
marci@775
   435
	  *(static_cast<Edge*>(this))=
marci@775
   436
	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@775
   437
	return *this; 
marci@556
   438
      }
marci@556
   439
    };
marci@556
   440
marci@556
   441
    NodeIt& first(NodeIt& i) const { 
marci@556
   442
      i=NodeIt(*this); return i;
marci@556
   443
    }
marci@556
   444
    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
marci@556
   445
      i=OutEdgeIt(*this, p); return i;
marci@556
   446
    }
marci@556
   447
    InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
marci@556
   448
      i=InEdgeIt(*this, p); return i;
marci@556
   449
    }
marci@556
   450
    EdgeIt& first(EdgeIt& i) const { 
marci@556
   451
      i=EdgeIt(*this); return i;
marci@556
   452
    }
marci@556
   453
    
marci@561
   454
    /// This function hides \c n in the graph, i.e. the iteration 
marci@561
   455
    /// jumps over it. This is done by simply setting the value of \c n  
marci@561
   456
    /// to be false in the corresponding node-map.
marci@556
   457
    void hide(const Node& n) const { node_filter_map->set(n, false); }
marci@561
   458
marci@561
   459
    /// This function hides \c e in the graph, i.e. the iteration 
marci@561
   460
    /// jumps over it. This is done by simply setting the value of \c e  
marci@561
   461
    /// to be false in the corresponding edge-map.
marci@556
   462
    void hide(const Edge& e) const { edge_filter_map->set(e, false); }
marci@556
   463
marci@561
   464
    /// The value of \c n is set to be true in the node-map which stores 
marci@561
   465
    /// hide information. If \c n was hidden previuosly, then it is shown 
marci@561
   466
    /// again
marci@561
   467
     void unHide(const Node& n) const { node_filter_map->set(n, true); }
marci@561
   468
marci@561
   469
    /// The value of \c e is set to be true in the edge-map which stores 
marci@561
   470
    /// hide information. If \c e was hidden previuosly, then it is shown 
marci@561
   471
    /// again
marci@556
   472
    void unHide(const Edge& e) const { edge_filter_map->set(e, true); }
marci@556
   473
marci@561
   474
    /// Returns true if \c n is hidden.
marci@561
   475
    bool hidden(const Node& n) const { return !(*node_filter_map)[n]; }
marci@561
   476
marci@561
   477
    /// Returns true if \c n is hidden.
marci@561
   478
    bool hidden(const Edge& e) const { return !(*edge_filter_map)[e]; }
marci@593
   479
marci@792
   480
    /// \warning This is a linear time operation and works only if 
marci@792
   481
    /// \c Graph::NodeIt is defined.
marci@593
   482
    int nodeNum() const { 
marci@593
   483
      int i=0;
marci@792
   484
      for (NodeIt n(*this); n!=INVALID; ++n) ++i;
marci@593
   485
      return i; 
marci@593
   486
    }
marci@593
   487
marci@792
   488
    /// \warning This is a linear time operation and works only if 
marci@792
   489
    /// \c Graph::EdgeIt is defined.
marci@593
   490
    int edgeNum() const { 
marci@593
   491
      int i=0;
marci@792
   492
      for (EdgeIt e(*this); e!=INVALID; ++e) ++i;
marci@593
   493
      return i; 
marci@593
   494
    }
marci@593
   495
deba@891
   496
    //    KEEP_MAPS(Parent, SubGraphWrapper);
marci@556
   497
  };
marci@556
   498
marci@569
   499
marci@569
   500
marci@556
   501
  template<typename Graph>
marci@556
   502
  class UndirGraphWrapper : public GraphWrapper<Graph> {
marci@650
   503
  public:
marci@650
   504
    typedef GraphWrapper<Graph> Parent; 
marci@556
   505
  protected:
marci@556
   506
    UndirGraphWrapper() : GraphWrapper<Graph>() { }
marci@556
   507
    
marci@556
   508
  public:
marci@556
   509
    typedef typename GraphWrapper<Graph>::Node Node;
marci@556
   510
    typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
marci@556
   511
    typedef typename GraphWrapper<Graph>::Edge Edge;
marci@556
   512
    typedef typename GraphWrapper<Graph>::EdgeIt EdgeIt;
marci@556
   513
marci@556
   514
    UndirGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }  
marci@556
   515
marci@556
   516
    class OutEdgeIt {
marci@556
   517
      friend class UndirGraphWrapper<Graph>;
marci@556
   518
      bool out_or_in; //true iff out
marci@556
   519
      typename Graph::OutEdgeIt out;
marci@556
   520
      typename Graph::InEdgeIt in;
marci@556
   521
    public:
marci@556
   522
      OutEdgeIt() { }
marci@556
   523
      OutEdgeIt(const Invalid& i) : Edge(i) { }
marci@556
   524
      OutEdgeIt(const UndirGraphWrapper<Graph>& _G, const Node& _n) {
marci@556
   525
	out_or_in=true; _G.graph->first(out, _n);
marci@556
   526
	if (!(_G.graph->valid(out))) { out_or_in=false; _G.graph->first(in, _n);	}
marci@556
   527
      } 
marci@556
   528
      operator Edge() const { 
marci@556
   529
	if (out_or_in) return Edge(out); else return Edge(in); 
marci@556
   530
      }
marci@556
   531
    };
marci@556
   532
marci@556
   533
    typedef OutEdgeIt InEdgeIt; 
marci@556
   534
marci@556
   535
    using GraphWrapper<Graph>::first;
marci@556
   536
    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
marci@556
   537
      i=OutEdgeIt(*this, p); return i;
marci@556
   538
    }
marci@556
   539
marci@556
   540
    using GraphWrapper<Graph>::next;
alpar@878
   541
marci@556
   542
    OutEdgeIt& next(OutEdgeIt& e) const {
marci@556
   543
      if (e.out_or_in) {
marci@556
   544
	typename Graph::Node n=this->graph->tail(e.out);
marci@556
   545
	this->graph->next(e.out);
marci@556
   546
	if (!this->graph->valid(e.out)) { 
marci@556
   547
	  e.out_or_in=false; this->graph->first(e.in, n); }
marci@556
   548
      } else {
marci@556
   549
	this->graph->next(e.in);
marci@556
   550
      }
marci@556
   551
      return e;
marci@556
   552
    }
marci@556
   553
marci@556
   554
    Node aNode(const OutEdgeIt& e) const { 
marci@556
   555
      if (e.out_or_in) return this->graph->tail(e); else 
marci@556
   556
	return this->graph->head(e); }
marci@556
   557
    Node bNode(const OutEdgeIt& e) const { 
marci@556
   558
      if (e.out_or_in) return this->graph->head(e); else 
marci@556
   559
	return this->graph->tail(e); }
deba@877
   560
deba@891
   561
    //    KEEP_MAPS(Parent, UndirGraphWrapper);
deba@877
   562
marci@556
   563
  };
marci@556
   564
  
marci@612
   565
  /// \brief An undirected graph template.
marci@612
   566
  ///
alpar@879
   567
  ///\warning Graph wrappers are in even more experimental state than the other
deba@891
   568
  ///parts of the lib. Use them at your own risk.
alpar@879
   569
  ///
marci@612
   570
  /// An undirected graph template.
marci@612
   571
  /// This class works as an undirected graph and a directed graph of 
marci@612
   572
  /// class \c Graph is used for the physical storage.
marci@612
   573
  /// \ingroup graphs
marci@556
   574
  template<typename Graph>
marci@556
   575
  class UndirGraph : public UndirGraphWrapper<Graph> {
marci@556
   576
    typedef UndirGraphWrapper<Graph> Parent;
marci@556
   577
  protected:
marci@556
   578
    Graph gr;
marci@556
   579
  public:
marci@556
   580
    UndirGraph() : UndirGraphWrapper<Graph>() { 
marci@556
   581
      Parent::setGraph(gr); 
marci@556
   582
    }
deba@877
   583
deba@891
   584
    //    KEEP_MAPS(Parent, UndirGraph);
marci@556
   585
  };
marci@556
   586
marci@569
   587
marci@650
   588
marci@650
   589
  ///\brief A wrapper for composing a subgraph of a 
marci@792
   590
  /// bidirected graph made from a directed one. 
marci@612
   591
  ///
alpar@879
   592
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
   593
  ///parts of the lib. Use them at you own risk.
alpar@879
   594
  ///
marci@792
   595
  /// Suppose that for a directed graph $G=(V, A)$, 
marci@792
   596
  /// two predicates on the edge-set, $forward_filter$, and $backward_filter$ 
marci@792
   597
  /// is given, and we are dealing with the directed graph
marci@792
   598
  /// a $G'=(V, \{uv : uv\in A \mbox{ and } forward_filter(uv) \mbox{ is true}\}+\{vu : uv\in A \mbox{ and } backward_filter(uv) \mbox{ is true}\})$. 
marci@792
   599
  /// The purpose of writing + instead of union is because parallel 
marci@792
   600
  /// edges can arose. 
marci@792
   601
  /// In other words, a subgraph of the bidirected graph obtained, which 
marci@792
   602
  /// is given by orienting the edges of the original graph in both directions.
marci@792
   603
  /// An example for such a construction is the \c RevGraphWrapper where the 
marci@792
   604
  /// forward_filter is everywhere false and the backward_filter is 
marci@792
   605
  /// everywhere true. We note that for sake of efficiency, 
marci@792
   606
  /// \c RevGraphWrapper is implemented in a different way. 
marci@792
   607
  /// But BidirGraphWrapper is obtained from 
marci@792
   608
  /// SubBidirGraphWrapper by considering everywhere true 
marci@792
   609
  /// predicates both forward_filter and backward_filter. 
marci@792
   610
  /// Finally, one of the most important applications of SubBidirGraphWrapper 
marci@792
   611
  /// is ResGraphWrapper, which stands for the residual graph in directed 
marci@792
   612
  /// flow and circulation problems. 
marci@792
   613
  /// As wrappers usually, the SubBidirGraphWrapper implements the 
marci@792
   614
  /// above mentioned graph structure without its physical storage, 
marci@792
   615
  /// that is the whole stuff eats constant memory. 
marci@792
   616
  /// As the oppositely directed edges are logical different, 
marci@792
   617
  /// the maps are able to attach different values for them. 
marci@650
   618
  template<typename Graph, 
marci@650
   619
	   typename ForwardFilterMap, typename BackwardFilterMap>
marci@650
   620
  class SubBidirGraphWrapper : public GraphWrapper<Graph> {
marci@650
   621
  public:
marci@650
   622
    typedef GraphWrapper<Graph> Parent; 
marci@569
   623
  protected:
marci@650
   624
    ForwardFilterMap* forward_filter;
marci@650
   625
    BackwardFilterMap* backward_filter;
marci@650
   626
marci@792
   627
    SubBidirGraphWrapper() : GraphWrapper<Graph>() { }
marci@650
   628
    void setForwardFilterMap(ForwardFilterMap& _forward_filter) {
marci@650
   629
      forward_filter=&_forward_filter;
marci@650
   630
    }
marci@650
   631
    void setBackwardFilterMap(BackwardFilterMap& _backward_filter) {
marci@650
   632
      backward_filter=&_backward_filter;
marci@650
   633
    }
marci@569
   634
marci@569
   635
  public:
marci@569
   636
marci@650
   637
    SubBidirGraphWrapper(Graph& _graph, ForwardFilterMap& _forward_filter, 
marci@650
   638
			 BackwardFilterMap& _backward_filter) : 
marci@650
   639
      GraphWrapper<Graph>(_graph), 
marci@650
   640
      forward_filter(&_forward_filter), backward_filter(&_backward_filter) { }
alpar@774
   641
    SubBidirGraphWrapper(const SubBidirGraphWrapper<Graph, 
alpar@774
   642
			 ForwardFilterMap, BackwardFilterMap>& gw) : 
alpar@774
   643
      Parent(gw), 
alpar@774
   644
      forward_filter(gw.forward_filter), 
alpar@774
   645
      backward_filter(gw.backward_filter) { }
marci@569
   646
marci@569
   647
    class Edge; 
marci@569
   648
    class OutEdgeIt; 
marci@569
   649
    friend class Edge; 
marci@569
   650
    friend class OutEdgeIt; 
marci@569
   651
marci@621
   652
    template<typename T> class EdgeMap;
marci@621
   653
marci@569
   654
    typedef typename GraphWrapper<Graph>::Node Node;
marci@621
   655
alpar@774
   656
    typedef typename Graph::Edge GraphEdge;
marci@792
   657
    /// SubBidirGraphWrapper<..., ..., ...>::Edge is inherited from 
marci@792
   658
    /// Graph::Edge. It contains an extra bool flag which shows if the 
marci@792
   659
    /// edge is the backward version of the original edge.
marci@569
   660
    class Edge : public Graph::Edge {
marci@650
   661
      friend class SubBidirGraphWrapper<Graph, 
marci@650
   662
					ForwardFilterMap, BackwardFilterMap>;
marci@621
   663
      template<typename T> friend class EdgeMap;
marci@569
   664
    protected:
marci@569
   665
      bool backward; //true, iff backward
marci@569
   666
    public:
marci@569
   667
      Edge() { }
marci@792
   668
      /// \todo =false is needed, or causes problems?
marci@792
   669
      /// If \c _backward is false, then we get an edge corresponding to the 
marci@792
   670
      /// original one, otherwise its oppositely directed pair is obtained.
alpar@774
   671
      Edge(const typename Graph::Edge& e, bool _backward/*=false*/) : 
alpar@774
   672
	Graph::Edge(e), backward(_backward) { }
alpar@774
   673
      Edge(Invalid i) : Graph::Edge(i), backward(true) { }
alpar@774
   674
      bool operator==(const Edge& v) const { 
alpar@774
   675
	return (this->backward==v.backward && 
alpar@774
   676
		static_cast<typename Graph::Edge>(*this)==
marci@569
   677
		static_cast<typename Graph::Edge>(v));
marci@569
   678
      } 
alpar@774
   679
      bool operator!=(const Edge& v) const { 
alpar@774
   680
	return (this->backward!=v.backward || 
alpar@774
   681
		static_cast<typename Graph::Edge>(*this)!=
marci@569
   682
		static_cast<typename Graph::Edge>(v));
alpar@774
   683
      }
marci@569
   684
    };
marci@569
   685
alpar@774
   686
    class OutEdgeIt : public Edge {
marci@650
   687
      friend class SubBidirGraphWrapper<Graph, 
marci@650
   688
					ForwardFilterMap, BackwardFilterMap>;
marci@569
   689
    protected:
alpar@774
   690
      const SubBidirGraphWrapper<Graph, 
alpar@774
   691
				 ForwardFilterMap, BackwardFilterMap>* gw;
marci@569
   692
    public:
marci@569
   693
      OutEdgeIt() { }
alpar@774
   694
      OutEdgeIt(Invalid i) : Edge(i) { }
marci@650
   695
      OutEdgeIt(const SubBidirGraphWrapper<Graph, 
alpar@774
   696
		ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) : 
alpar@774
   697
	Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), false), gw(&_gw) { 
alpar@774
   698
	while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   699
	       !(*(gw->forward_filter))[*this]) 
alpar@774
   700
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   701
	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@775
   702
	if (*static_cast<GraphEdge*>(this)==INVALID) {
alpar@774
   703
	  *static_cast<Edge*>(this)=
alpar@774
   704
	    Edge(typename Graph::InEdgeIt(*(_gw.graph), n), true);
marci@775
   705
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
marci@775
   706
		 !(*(gw->backward_filter))[*this]) 
marci@775
   707
	    *(static_cast<GraphEdge*>(this))=
marci@775
   708
	      ++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@775
   709
	}
alpar@774
   710
      }
alpar@774
   711
      OutEdgeIt(const SubBidirGraphWrapper<Graph, 
alpar@774
   712
		ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : 
alpar@774
   713
	Edge(e), gw(&_gw) { }
alpar@774
   714
      OutEdgeIt& operator++() { 
alpar@774
   715
	if (!this->backward) {
alpar@774
   716
	  Node n=gw->tail(*this);
alpar@774
   717
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   718
	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
alpar@774
   719
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   720
		 !(*(gw->forward_filter))[*this]) 
alpar@774
   721
	    *(static_cast<GraphEdge*>(this))=
alpar@774
   722
	      ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@775
   723
	  if (*static_cast<GraphEdge*>(this)==INVALID) {
alpar@774
   724
	    *static_cast<Edge*>(this)=
alpar@774
   725
	      Edge(typename Graph::InEdgeIt(*(gw->graph), n), true);
marci@775
   726
	    while (*static_cast<GraphEdge*>(this)!=INVALID && 
marci@775
   727
		   !(*(gw->backward_filter))[*this]) 
marci@775
   728
	      *(static_cast<GraphEdge*>(this))=
marci@775
   729
		++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@775
   730
	  }
alpar@774
   731
	} else {
alpar@774
   732
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   733
	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
alpar@774
   734
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   735
		 !(*(gw->backward_filter))[*this]) 
alpar@774
   736
	    *(static_cast<GraphEdge*>(this))=
alpar@774
   737
	      ++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@569
   738
	}
alpar@774
   739
	return *this;
marci@569
   740
      }
marci@569
   741
    };
marci@569
   742
alpar@774
   743
    class InEdgeIt : public Edge {
marci@650
   744
      friend class SubBidirGraphWrapper<Graph, 
marci@650
   745
					ForwardFilterMap, BackwardFilterMap>;
marci@569
   746
    protected:
alpar@774
   747
      const SubBidirGraphWrapper<Graph, 
alpar@774
   748
				 ForwardFilterMap, BackwardFilterMap>* gw;
marci@569
   749
    public:
marci@569
   750
      InEdgeIt() { }
alpar@774
   751
      InEdgeIt(Invalid i) : Edge(i) { }
marci@650
   752
      InEdgeIt(const SubBidirGraphWrapper<Graph, 
alpar@774
   753
	       ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) : 
alpar@774
   754
	Edge(typename Graph::InEdgeIt(*(_gw.graph), n), false), gw(&_gw) { 
alpar@774
   755
	while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   756
	       !(*(gw->forward_filter))[*this]) 
alpar@774
   757
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   758
	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@775
   759
	if (*static_cast<GraphEdge*>(this)==INVALID) {
alpar@774
   760
	  *static_cast<Edge*>(this)=
alpar@774
   761
	    Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), true);
marci@775
   762
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
marci@775
   763
		 !(*(gw->backward_filter))[*this]) 
marci@775
   764
	    *(static_cast<GraphEdge*>(this))=
marci@775
   765
	      ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@775
   766
	}
alpar@774
   767
      }
alpar@774
   768
      InEdgeIt(const SubBidirGraphWrapper<Graph, 
alpar@774
   769
	       ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : 
alpar@774
   770
	Edge(e), gw(&_gw) { }
alpar@774
   771
      InEdgeIt& operator++() { 
alpar@774
   772
	if (!this->backward) {
marci@775
   773
	  Node n=gw->tail(*this);
alpar@774
   774
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   775
	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
alpar@774
   776
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   777
		 !(*(gw->forward_filter))[*this]) 
alpar@774
   778
	    *(static_cast<GraphEdge*>(this))=
alpar@774
   779
	      ++(typename Graph::InEdgeIt(*(gw->graph), *this));
marci@775
   780
	  if (*static_cast<GraphEdge*>(this)==INVALID) {
alpar@774
   781
	    *static_cast<Edge*>(this)=
alpar@774
   782
	      Edge(typename Graph::OutEdgeIt(*(gw->graph), n), true);
marci@775
   783
	    while (*static_cast<GraphEdge*>(this)!=INVALID && 
marci@775
   784
		   !(*(gw->backward_filter))[*this]) 
marci@775
   785
	      *(static_cast<GraphEdge*>(this))=
marci@775
   786
		++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@775
   787
	  }
alpar@774
   788
	} else {
alpar@774
   789
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   790
	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
alpar@774
   791
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   792
		 !(*(gw->backward_filter))[*this]) 
alpar@774
   793
	    *(static_cast<GraphEdge*>(this))=
alpar@774
   794
	      ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@569
   795
	}
alpar@774
   796
	return *this;
marci@569
   797
      }
marci@569
   798
    };
marci@569
   799
alpar@774
   800
    class EdgeIt : public Edge {
marci@650
   801
      friend class SubBidirGraphWrapper<Graph, 
marci@650
   802
					ForwardFilterMap, BackwardFilterMap>;
marci@569
   803
    protected:
alpar@774
   804
      const SubBidirGraphWrapper<Graph, 
alpar@774
   805
				 ForwardFilterMap, BackwardFilterMap>* gw;
marci@569
   806
    public:
marci@569
   807
      EdgeIt() { }
alpar@774
   808
      EdgeIt(Invalid i) : Edge(i) { }
marci@650
   809
      EdgeIt(const SubBidirGraphWrapper<Graph, 
marci@775
   810
	     ForwardFilterMap, BackwardFilterMap>& _gw) : 
marci@892
   811
	Edge(typename Graph::EdgeIt(*(_gw.graph)), false), gw(&_gw) { 
alpar@774
   812
	while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   813
	       !(*(gw->forward_filter))[*this]) 
alpar@774
   814
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   815
	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@775
   816
	if (*static_cast<GraphEdge*>(this)==INVALID) {
alpar@774
   817
	  *static_cast<Edge*>(this)=
alpar@774
   818
	    Edge(typename Graph::EdgeIt(*(_gw.graph)), true);
marci@775
   819
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
marci@775
   820
		 !(*(gw->backward_filter))[*this]) 
marci@775
   821
	    *(static_cast<GraphEdge*>(this))=
marci@775
   822
	      ++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@775
   823
	}
alpar@774
   824
      }
alpar@774
   825
      EdgeIt(const SubBidirGraphWrapper<Graph, 
alpar@774
   826
	     ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : 
alpar@774
   827
	Edge(e), gw(&_gw) { }
alpar@774
   828
      EdgeIt& operator++() { 
alpar@774
   829
	if (!this->backward) {
alpar@774
   830
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   831
	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
alpar@774
   832
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   833
		 !(*(gw->forward_filter))[*this]) 
alpar@774
   834
	    *(static_cast<GraphEdge*>(this))=
alpar@774
   835
	      ++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@775
   836
	  if (*static_cast<GraphEdge*>(this)==INVALID) {
alpar@774
   837
	    *static_cast<Edge*>(this)=
alpar@774
   838
	      Edge(typename Graph::EdgeIt(*(gw->graph)), true);
marci@775
   839
	    while (*static_cast<GraphEdge*>(this)!=INVALID && 
marci@775
   840
		   !(*(gw->backward_filter))[*this]) 
marci@775
   841
	      *(static_cast<GraphEdge*>(this))=
marci@775
   842
		++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@775
   843
	  }
alpar@774
   844
	} else {
alpar@774
   845
	  *(static_cast<GraphEdge*>(this))=
alpar@774
   846
	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
alpar@774
   847
	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
alpar@774
   848
		 !(*(gw->backward_filter))[*this]) 
alpar@774
   849
	    *(static_cast<GraphEdge*>(this))=
alpar@774
   850
	      ++(typename Graph::EdgeIt(*(gw->graph), *this));
marci@569
   851
	}
alpar@774
   852
	return *this;
marci@569
   853
      }
marci@569
   854
    };
marci@569
   855
marci@569
   856
    using GraphWrapper<Graph>::first;
marci@569
   857
    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
marci@569
   858
      i=OutEdgeIt(*this, p); return i;
marci@569
   859
    }
marci@569
   860
    InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
marci@569
   861
      i=InEdgeIt(*this, p); return i;
marci@569
   862
    }
marci@569
   863
    EdgeIt& first(EdgeIt& i) const { 
marci@569
   864
      i=EdgeIt(*this); return i;
marci@569
   865
    }
marci@556
   866
  
marci@569
   867
marci@569
   868
    Node tail(Edge e) const { 
marci@569
   869
      return ((!e.backward) ? this->graph->tail(e) : this->graph->head(e)); }
marci@569
   870
    Node head(Edge e) const { 
marci@569
   871
      return ((!e.backward) ? this->graph->head(e) : this->graph->tail(e)); }
marci@569
   872
marci@572
   873
    /// Gives back the opposite edge.
marci@572
   874
    Edge opposite(const Edge& e) const { 
marci@572
   875
      Edge f=e;
marci@572
   876
      f.backward=!f.backward;
marci@572
   877
      return f;
marci@572
   878
    }
marci@572
   879
marci@792
   880
    /// \warning This is a linear time operation and works only if 
marci@792
   881
    /// \c Graph::EdgeIt is defined.
marci@792
   882
    int edgeNum() const { 
marci@792
   883
      int i=0;
marci@792
   884
      for (EdgeIt e(*this); e!=INVALID; ++e) ++i;
marci@792
   885
      return i; 
marci@792
   886
    }
marci@569
   887
marci@569
   888
    bool forward(const Edge& e) const { return !e.backward; }
marci@569
   889
    bool backward(const Edge& e) const { return e.backward; }
marci@569
   890
marci@569
   891
marci@569
   892
    template <typename T>
marci@792
   893
    /// \c SubBidirGraphWrapper<..., ..., ...>::EdgeMap contains two 
marci@792
   894
    /// Graph::EdgeMap one for the forward edges and 
marci@792
   895
    /// one for the backward edges.
marci@569
   896
    class EdgeMap {
deba@891
   897
      template <typename TT> friend class EdgeMap;
marci@569
   898
      typename Graph::template EdgeMap<T> forward_map, backward_map; 
marci@569
   899
    public:
marci@623
   900
      typedef T ValueType;
marci@623
   901
      typedef Edge KeyType;
deba@891
   902
marci@650
   903
      EdgeMap(const SubBidirGraphWrapper<Graph, 
alpar@774
   904
	      ForwardFilterMap, BackwardFilterMap>& g) : 
alpar@774
   905
	forward_map(*(g.graph)), backward_map(*(g.graph)) { }
deba@891
   906
marci@650
   907
      EdgeMap(const SubBidirGraphWrapper<Graph, 
alpar@774
   908
	      ForwardFilterMap, BackwardFilterMap>& g, T a) : 
alpar@774
   909
	forward_map(*(g.graph), a), backward_map(*(g.graph), a) { }
deba@891
   910
deba@891
   911
      template <typename TT>
deba@891
   912
      EdgeMap(const EdgeMap<TT>& copy) 
deba@891
   913
	: forward_map(copy.forward_map), backward_map(copy.backward_map) {}
deba@891
   914
deba@891
   915
      template <typename TT>
deba@891
   916
      EdgeMap& operator=(const EdgeMap<TT>& copy) {
deba@891
   917
	forward_map = copy.forward_map;
deba@891
   918
	backward_map = copy.backward_map;
deba@891
   919
	return *this;
deba@891
   920
      }
deba@891
   921
      
marci@569
   922
      void set(Edge e, T a) { 
marci@569
   923
	if (!e.backward) 
marci@792
   924
	  forward_map.set(e, a); 
marci@569
   925
	else 
marci@792
   926
	  backward_map.set(e, a); 
marci@569
   927
      }
deba@891
   928
deba@891
   929
      typename Graph::template EdgeMap<T>::ConstReferenceType 
deba@891
   930
      operator[](Edge e) const { 
marci@569
   931
	if (!e.backward) 
marci@792
   932
	  return forward_map[e]; 
marci@569
   933
	else 
marci@792
   934
	  return backward_map[e]; 
marci@569
   935
      }
deba@891
   936
deba@891
   937
      typename Graph::template EdgeMap<T>::ReferenceType 
deba@891
   938
      operator[](Edge e) { 
deba@891
   939
	if (!e.backward) 
deba@891
   940
	  return forward_map[e]; 
deba@891
   941
	else 
deba@891
   942
	  return backward_map[e]; 
deba@891
   943
      }
deba@891
   944
marci@625
   945
      void update() { 
marci@625
   946
	forward_map.update(); 
marci@625
   947
	backward_map.update();
marci@625
   948
      }
marci@569
   949
    };
deba@877
   950
deba@877
   951
deba@891
   952
    //    KEEP_NODE_MAP(Parent, SubBidirGraphWrapper);
deba@877
   953
marci@569
   954
  };
marci@569
   955
marci@650
   956
marci@650
   957
  ///\brief A wrapper for composing bidirected graph from a directed one. 
marci@650
   958
  ///
alpar@879
   959
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
   960
  ///parts of the lib. Use them at you own risk.
alpar@879
   961
  ///
marci@650
   962
  /// A wrapper for composing bidirected graph from a directed one. 
marci@650
   963
  /// A bidirected graph is composed over the directed one without physical 
marci@650
   964
  /// storage. As the oppositely directed edges are logically different ones 
marci@650
   965
  /// the maps are able to attach different values for them.
marci@650
   966
  template<typename Graph>
marci@650
   967
  class BidirGraphWrapper : 
marci@650
   968
    public SubBidirGraphWrapper<
marci@650
   969
    Graph, 
marci@650
   970
    ConstMap<typename Graph::Edge, bool>, 
marci@650
   971
    ConstMap<typename Graph::Edge, bool> > {
marci@650
   972
  public:
marci@650
   973
    typedef  SubBidirGraphWrapper<
marci@650
   974
      Graph, 
marci@650
   975
      ConstMap<typename Graph::Edge, bool>, 
marci@650
   976
      ConstMap<typename Graph::Edge, bool> > Parent; 
marci@650
   977
  protected:
marci@650
   978
    ConstMap<typename Graph::Edge, bool> cm;
marci@650
   979
marci@655
   980
    BidirGraphWrapper() : Parent(), cm(true) { 
marci@655
   981
      Parent::setForwardFilterMap(cm);
marci@655
   982
      Parent::setBackwardFilterMap(cm);
marci@655
   983
    }
marci@650
   984
  public:
marci@650
   985
    BidirGraphWrapper(Graph& _graph) : Parent() { 
marci@650
   986
      Parent::setGraph(_graph);
marci@650
   987
      Parent::setForwardFilterMap(cm);
marci@650
   988
      Parent::setBackwardFilterMap(cm);
marci@650
   989
    }
marci@738
   990
marci@738
   991
    int edgeNum() const { 
marci@738
   992
      return 2*this->graph->edgeNum();
marci@738
   993
    }
deba@891
   994
    //    KEEP_MAPS(Parent, BidirGraphWrapper);
marci@650
   995
  };
marci@650
   996
marci@650
   997
marci@612
   998
  /// \brief A bidirected graph template.
marci@612
   999
  ///
alpar@879
  1000
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
  1001
  ///parts of the lib. Use them at you own risk.
alpar@879
  1002
  ///
marci@612
  1003
  /// A bidirected graph template.
marci@612
  1004
  /// Such a bidirected graph stores each pair of oppositely directed edges 
marci@612
  1005
  /// ones in the memory, i.e. a directed graph of type 
marci@612
  1006
  /// \c Graph is used for that.
marci@612
  1007
  /// As the oppositely directed edges are logically different ones 
marci@612
  1008
  /// the maps are able to attach different values for them.
marci@612
  1009
  /// \ingroup graphs
marci@612
  1010
  template<typename Graph>
marci@612
  1011
  class BidirGraph : public BidirGraphWrapper<Graph> {
marci@650
  1012
  public:
marci@612
  1013
    typedef UndirGraphWrapper<Graph> Parent;
marci@612
  1014
  protected:
marci@612
  1015
    Graph gr;
marci@612
  1016
  public:
marci@612
  1017
    BidirGraph() : BidirGraphWrapper<Graph>() { 
marci@612
  1018
      Parent::setGraph(gr); 
marci@612
  1019
    }
deba@891
  1020
    //    KEEP_MAPS(Parent, BidirGraph);
marci@612
  1021
  };
marci@569
  1022
marci@556
  1023
marci@650
  1024
marci@650
  1025
  template<typename Graph, typename Number,
marci@650
  1026
	   typename CapacityMap, typename FlowMap>
marci@658
  1027
  class ResForwardFilter {
marci@658
  1028
    //    const Graph* graph;
marci@650
  1029
    const CapacityMap* capacity;
marci@650
  1030
    const FlowMap* flow;
marci@650
  1031
  public:
marci@658
  1032
    ResForwardFilter(/*const Graph& _graph, */
marci@658
  1033
		     const CapacityMap& _capacity, const FlowMap& _flow) :
marci@658
  1034
      /*graph(&_graph),*/ capacity(&_capacity), flow(&_flow) { }
marci@658
  1035
    ResForwardFilter() : /*graph(0),*/ capacity(0), flow(0) { }
marci@656
  1036
    void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
marci@656
  1037
    void setFlow(const FlowMap& _flow) { flow=&_flow; }
marci@650
  1038
    bool operator[](const typename Graph::Edge& e) const {
marci@738
  1039
      return (Number((*flow)[e]) < Number((*capacity)[e]));
marci@650
  1040
    }
marci@650
  1041
  };
marci@650
  1042
marci@650
  1043
  template<typename Graph, typename Number,
marci@650
  1044
	   typename CapacityMap, typename FlowMap>
marci@658
  1045
  class ResBackwardFilter {
marci@650
  1046
    const CapacityMap* capacity;
marci@650
  1047
    const FlowMap* flow;
marci@650
  1048
  public:
marci@658
  1049
    ResBackwardFilter(/*const Graph& _graph,*/ 
marci@658
  1050
		      const CapacityMap& _capacity, const FlowMap& _flow) :
marci@658
  1051
      /*graph(&_graph),*/ capacity(&_capacity), flow(&_flow) { }
marci@658
  1052
    ResBackwardFilter() : /*graph(0),*/ capacity(0), flow(0) { }
marci@656
  1053
    void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
marci@656
  1054
    void setFlow(const FlowMap& _flow) { flow=&_flow; }
marci@650
  1055
    bool operator[](const typename Graph::Edge& e) const {
marci@738
  1056
      return (Number(0) < Number((*flow)[e]));
marci@650
  1057
    }
marci@650
  1058
  };
marci@650
  1059
marci@653
  1060
  
marci@653
  1061
  /// A wrapper for composing the residual graph for directed flow and circulation problems.
marci@650
  1062
alpar@879
  1063
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
  1064
  ///parts of the lib. Use them at you own risk.
alpar@879
  1065
  ///
marci@653
  1066
  /// A wrapper for composing the residual graph for directed flow and circulation problems.
marci@650
  1067
  template<typename Graph, typename Number, 
marci@650
  1068
	   typename CapacityMap, typename FlowMap>
marci@653
  1069
  class ResGraphWrapper : 
marci@650
  1070
    public SubBidirGraphWrapper< 
marci@650
  1071
    Graph, 
marci@658
  1072
    ResForwardFilter<Graph, Number, CapacityMap, FlowMap>,  
marci@658
  1073
    ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> > {
marci@650
  1074
  public:
marci@650
  1075
    typedef SubBidirGraphWrapper< 
marci@650
  1076
      Graph, 
marci@658
  1077
      ResForwardFilter<Graph, Number, CapacityMap, FlowMap>,  
marci@658
  1078
      ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> > Parent;
marci@650
  1079
  protected:
marci@650
  1080
    const CapacityMap* capacity;
marci@650
  1081
    FlowMap* flow;
marci@658
  1082
    ResForwardFilter<Graph, Number, CapacityMap, FlowMap> forward_filter;
marci@658
  1083
    ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> backward_filter;
marci@658
  1084
    ResGraphWrapper() : Parent(), 
marci@658
  1085
 			capacity(0), flow(0) { }
marci@658
  1086
    void setCapacityMap(const CapacityMap& _capacity) {
marci@658
  1087
      capacity=&_capacity;
marci@658
  1088
      forward_filter.setCapacity(_capacity);
marci@658
  1089
      backward_filter.setCapacity(_capacity);
marci@658
  1090
    }
marci@658
  1091
    void setFlowMap(FlowMap& _flow) {
marci@658
  1092
      flow=&_flow;
marci@658
  1093
      forward_filter.setFlow(_flow);
marci@658
  1094
      backward_filter.setFlow(_flow);
marci@658
  1095
    }
marci@650
  1096
  public:
marci@653
  1097
    ResGraphWrapper(Graph& _graph, const CapacityMap& _capacity, 
marci@650
  1098
		       FlowMap& _flow) : 
marci@650
  1099
      Parent(), capacity(&_capacity), flow(&_flow), 
marci@658
  1100
      forward_filter(/*_graph,*/ _capacity, _flow), 
marci@658
  1101
      backward_filter(/*_graph,*/ _capacity, _flow) {
marci@650
  1102
      Parent::setGraph(_graph);
marci@650
  1103
      Parent::setForwardFilterMap(forward_filter);
marci@650
  1104
      Parent::setBackwardFilterMap(backward_filter);
marci@650
  1105
    }
marci@650
  1106
marci@660
  1107
    typedef typename Parent::Edge Edge;
marci@660
  1108
marci@660
  1109
    void augment(const Edge& e, Number a) const {
marci@650
  1110
      if (Parent::forward(e))  
marci@650
  1111
	flow->set(e, (*flow)[e]+a);
marci@650
  1112
      else  
marci@650
  1113
	flow->set(e, (*flow)[e]-a);
marci@650
  1114
    }
marci@650
  1115
marci@660
  1116
    /// \brief Residual capacity map.
marci@660
  1117
    ///
marci@792
  1118
    /// In generic residual graphs the residual capacity can be obtained as a map. Not tested.
marci@660
  1119
    class ResCap {
marci@660
  1120
    protected:
marci@660
  1121
      const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>* res_graph;
marci@660
  1122
    public:
marci@660
  1123
      typedef Number ValueType;
marci@660
  1124
      typedef Edge KeyType;
marci@888
  1125
      ResCap(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& 
marci@888
  1126
	     _res_graph) : res_graph(&_res_graph) { }
marci@660
  1127
      Number operator[](const Edge& e) const { 
marci@660
  1128
	if (res_graph->forward(e)) 
marci@660
  1129
	  return (*(res_graph->capacity))[e]-(*(res_graph->flow))[e]; 
marci@660
  1130
	else 
marci@660
  1131
	  return (*(res_graph->flow))[e]; 
marci@660
  1132
      }
marci@660
  1133
    };
marci@660
  1134
deba@891
  1135
    //    KEEP_MAPS(Parent, ResGraphWrapper);
marci@650
  1136
  };
marci@650
  1137
marci@650
  1138
marci@612
  1139
  /// For blocking flows.
marci@556
  1140
alpar@879
  1141
  ///\warning Graph wrappers are in even more experimental state than the other
alpar@879
  1142
  ///parts of the lib. Use them at you own risk.
alpar@879
  1143
  ///
marci@792
  1144
  /// This graph wrapper is used for on-the-fly 
marci@792
  1145
  /// Dinits blocking flow computations.
marci@612
  1146
  /// For each node, an out-edge is stored which is used when the 
marci@612
  1147
  /// \code 
marci@612
  1148
  /// OutEdgeIt& first(OutEdgeIt&, const Node&)
marci@612
  1149
  /// \endcode
marci@612
  1150
  /// is called. 
marci@556
  1151
  ///
marci@792
  1152
  /// \author Marton Makai
marci@556
  1153
  template<typename Graph, typename FirstOutEdgesMap>
marci@556
  1154
  class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
marci@650
  1155
  public:
marci@650
  1156
    typedef GraphWrapper<Graph> Parent; 
marci@556
  1157
  protected:
marci@556
  1158
    FirstOutEdgesMap* first_out_edges;
marci@556
  1159
  public:
marci@556
  1160
    ErasingFirstGraphWrapper(Graph& _graph, 
marci@556
  1161
			     FirstOutEdgesMap& _first_out_edges) : 
marci@556
  1162
      GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }  
marci@556
  1163
marci@556
  1164
    typedef typename GraphWrapper<Graph>::Node Node;
marci@556
  1165
    typedef typename GraphWrapper<Graph>::Edge Edge;
marci@777
  1166
    class OutEdgeIt : public Edge { 
marci@556
  1167
      friend class GraphWrapper<Graph>;
marci@556
  1168
      friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
marci@777
  1169
      const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
marci@556
  1170
    public:
marci@556
  1171
      OutEdgeIt() { }
marci@777
  1172
      OutEdgeIt(Invalid i) : Edge(i) { }
marci@777
  1173
      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
marci@777
  1174
		const Node& n) : 
marci@777
  1175
	Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
marci@777
  1176
      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
marci@777
  1177
		const Edge& e) : 
marci@777
  1178
	Edge(e), gw(&_gw) { }
marci@777
  1179
      OutEdgeIt& operator++() { 
marci@777
  1180
	*(static_cast<Edge*>(this))=
marci@777
  1181
	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
marci@777
  1182
	return *this; 
marci@777
  1183
      }
marci@556
  1184
    };
marci@556
  1185
marci@556
  1186
    using GraphWrapper<Graph>::first;
marci@556
  1187
    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
marci@556
  1188
      i=OutEdgeIt(*this, p); return i;
marci@556
  1189
    }
marci@777
  1190
    void erase(const Edge& e) const {
marci@777
  1191
      Node n=tail(e);
deba@844
  1192
      typename Graph::OutEdgeIt f(*Parent::graph, n);
marci@777
  1193
      ++f;
marci@777
  1194
      first_out_edges->set(n, f);
marci@556
  1195
    }
deba@877
  1196
deba@891
  1197
    //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
marci@556
  1198
  };
marci@556
  1199
marci@556
  1200
  ///@}
marci@556
  1201
marci@556
  1202
} //namespace hugo
marci@556
  1203
marci@556
  1204
#endif //HUGO_GRAPH_WRAPPER_H
marci@556
  1205