lemon/ugraph_adaptor.h
author klao
Fri, 10 Mar 2006 19:34:47 +0000
changeset 2005 84ec2948eb1f
parent 1991 d7442141d9ef
child 2031 080d51024ac5
permissions -rw-r--r--
unionfind_test: double erase is not supported anymore
deba@1979
     1
/* -*- C++ -*-
deba@1979
     2
 *
deba@1979
     3
 * This file is a part of LEMON, a generic C++ optimization library
deba@1979
     4
 *
deba@1979
     5
 * Copyright (C) 2003-2006
deba@1979
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@1979
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@1979
     8
 *
deba@1979
     9
 * Permission to use, modify and distribute this software is granted
deba@1979
    10
 * provided that this copyright notice appears in all copies. For
deba@1979
    11
 * precise terms see the accompanying LICENSE file.
deba@1979
    12
 *
deba@1979
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@1979
    14
 * express or implied, and with no claim as to its suitability for any
deba@1979
    15
 * purpose.
deba@1979
    16
 *
deba@1979
    17
 */
deba@1979
    18
deba@1979
    19
#ifndef LEMON_UGRAPH_ADAPTOR_H
deba@1979
    20
#define LEMON_UGRAPH_ADAPTOR_H
deba@1979
    21
deba@1979
    22
///\ingroup graph_adaptors
deba@1979
    23
///\file
deba@1979
    24
///\brief Several graph adaptors.
deba@1979
    25
///
deba@1979
    26
///This file contains several useful ugraph adaptor functions.
deba@1979
    27
///
deba@1979
    28
///\author Balazs Dezso
deba@1979
    29
deba@1993
    30
#include <lemon/bits/invalid.h>
deba@1979
    31
#include <lemon/maps.h>
deba@1979
    32
deba@1979
    33
#include <lemon/bits/graph_adaptor_extender.h>
deba@1979
    34
deba@1993
    35
#include <lemon/bits/traits.h>
deba@1979
    36
deba@1979
    37
#include <iostream>
deba@1979
    38
deba@1979
    39
namespace lemon {
deba@1979
    40
deba@1979
    41
  /// \ingroup graph_adaptors
deba@1979
    42
  ///
deba@1979
    43
  /// \brief Base type for the Graph Adaptors
deba@1979
    44
  ///
deba@1979
    45
  /// This is the base type for most of LEMON graph adaptors. 
deba@1979
    46
  /// This class implements a trivial graph adaptor i.e. it only wraps the 
deba@1979
    47
  /// functions and types of the graph. The purpose of this class is to 
deba@1979
    48
  /// make easier implementing graph adaptors. E.g. if an adaptor is 
deba@1979
    49
  /// considered which differs from the wrapped graph only in some of its 
deba@1979
    50
  /// functions or types, then it can be derived from GraphAdaptor, and only 
deba@1979
    51
  /// the differences should be implemented.
deba@1979
    52
  ///
deba@1979
    53
  /// \author Balazs Dezso 
deba@1979
    54
  template<typename _UGraph>
deba@1979
    55
  class UGraphAdaptorBase {
deba@1979
    56
  public:
deba@1979
    57
    typedef _UGraph Graph;
deba@1979
    58
    typedef Graph ParentGraph;
deba@1979
    59
deba@1979
    60
  protected:
deba@1979
    61
    Graph* graph;
deba@1979
    62
deba@1979
    63
    UGraphAdaptorBase() : graph(0) {}
deba@1979
    64
deba@1979
    65
    void setGraph(Graph& _graph) { graph=&_graph; }
deba@1979
    66
deba@1979
    67
    Graph& getGraph() { return *graph; }
deba@1979
    68
    const Graph& getGraph() const { return *graph; }
deba@1979
    69
deba@1979
    70
  public:
deba@1979
    71
    UGraphAdaptorBase(Graph& _graph) : graph(&_graph) {}
deba@1979
    72
 
deba@1979
    73
    typedef typename Graph::Node Node;
deba@1979
    74
    typedef typename Graph::Edge Edge;
deba@1979
    75
    typedef typename Graph::UEdge UEdge;
deba@1979
    76
   
deba@1979
    77
    void first(Node& i) const { graph->first(i); }
deba@1979
    78
    void first(Edge& i) const { graph->first(i); }
deba@1979
    79
    void first(UEdge& i) const { graph->first(i); }
deba@1979
    80
    void firstIn(Edge& i, const Node& n) const { graph->firstIn(i, n); }
deba@1979
    81
    void firstOut(Edge& i, const Node& n ) const { graph->firstOut(i, n); }
deba@1979
    82
    void firstInc(UEdge &i, bool &d, const Node &n) const {
deba@1979
    83
      graph->firstInc(i, d, n);
deba@1979
    84
    }
deba@1979
    85
deba@1979
    86
    void next(Node& i) const { graph->next(i); }
deba@1979
    87
    void next(Edge& i) const { graph->next(i); }
deba@1979
    88
    void next(UEdge& i) const { graph->next(i); }
deba@1979
    89
    void nextIn(Edge& i) const { graph->nextIn(i); }
deba@1979
    90
    void nextOut(Edge& i) const { graph->nextOut(i); }
deba@1979
    91
    void nextInc(UEdge &i, bool &d) const { graph->nextInc(i, d); }
deba@1979
    92
deba@1979
    93
    Node source(const UEdge& e) const { return graph->source(e); }
deba@1979
    94
    Node target(const UEdge& e) const { return graph->target(e); }
deba@1979
    95
deba@1979
    96
    Node source(const Edge& e) const { return graph->source(e); }
deba@1979
    97
    Node target(const Edge& e) const { return graph->target(e); }
deba@1979
    98
deba@1979
    99
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
deba@1979
   100
    int nodeNum() const { return graph->nodeNum(); }
deba@1979
   101
    
deba@1979
   102
    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
deba@1979
   103
    int edgeNum() const { return graph->edgeNum(); }
deba@1979
   104
deba@1979
   105
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
deba@1979
   106
    Edge findEdge(const Node& source, const Node& target, 
deba@1979
   107
		  const Edge& prev = INVALID) {
deba@1979
   108
      return graph->findEdge(source, target, prev);
deba@1979
   109
    }
deba@1979
   110
    UEdge findUEdge(const Node& source, const Node& target, 
deba@1979
   111
                    const UEdge& prev = INVALID) {
deba@1979
   112
      return graph->findUEdge(source, target, prev);
deba@1979
   113
    }
deba@1979
   114
  
deba@1979
   115
    Node addNode() const { return graph->addNode(); }
deba@1979
   116
    UEdge addEdge(const Node& source, const Node& target) const { 
deba@1979
   117
      return graph->addEdge(source, target); 
deba@1979
   118
    }
deba@1979
   119
deba@1979
   120
    void erase(const Node& i) const { graph->erase(i); }
deba@1979
   121
    void erase(const Edge& i) const { graph->erase(i); }
deba@1979
   122
  
deba@1979
   123
    void clear() const { graph->clear(); }
deba@1979
   124
    
deba@1979
   125
    int id(const Node& v) const { return graph->id(v); }
deba@1979
   126
    int id(const UEdge& e) const { return graph->id(e); }
deba@1979
   127
deba@1979
   128
    bool direction(const Edge& e) const { return graph->direction(e); }
deba@1979
   129
    Edge direct(const UEdge& e, bool d) const { return graph->direct(e, d); }
deba@1991
   130
deba@1991
   131
    int maxNodeId() const {
deba@1991
   132
      return graph->maxNodeId();
deba@1979
   133
    }
deba@1979
   134
deba@1991
   135
    int maxEdgeId() const {
deba@1991
   136
      return graph->maxEdgeId();
deba@1979
   137
    }
deba@1979
   138
deba@1991
   139
    int maxUEdgeId() const {
deba@1991
   140
      return graph->maxEdgeId();
deba@1979
   141
    }
deba@1979
   142
deba@1991
   143
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
deba@1991
   144
deba@1991
   145
    NodeNotifier& getNotifier(Node) const {
deba@1991
   146
      return graph->getNotifier(Node());
deba@1991
   147
    } 
deba@1991
   148
deba@1991
   149
    typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier;
deba@1991
   150
deba@1991
   151
    EdgeNotifier& getNotifier(Edge) const {
deba@1991
   152
      return graph->getNotifier(Edge());
deba@1991
   153
    } 
deba@1991
   154
deba@1991
   155
    typedef typename ItemSetTraits<Graph, UEdge>::ItemNotifier UEdgeNotifier;
deba@1991
   156
deba@1991
   157
    UEdgeNotifier& getNotifier(UEdge) const {
deba@1991
   158
      return graph->getNotifier(UEdge());
deba@1991
   159
    } 
deba@1979
   160
deba@1979
   161
    template <typename _Value>
deba@1979
   162
    class NodeMap : public Graph::template NodeMap<_Value> {
deba@1979
   163
    public:
deba@1979
   164
      typedef typename Graph::template NodeMap<_Value> Parent;
deba@1979
   165
      explicit NodeMap(const UGraphAdaptorBase<Graph>& ga) 
deba@1979
   166
	: Parent(*ga.graph) {}
deba@1979
   167
      NodeMap(const UGraphAdaptorBase<Graph>& ga, const _Value& value)
deba@1979
   168
	: Parent(*ga.graph, value) {}
deba@1979
   169
deba@1979
   170
      NodeMap& operator=(const NodeMap& cmap) {
deba@1979
   171
	return operator=<NodeMap>(cmap);
deba@1979
   172
      }
deba@1979
   173
deba@1979
   174
      template <typename CMap>
deba@1979
   175
      NodeMap& operator=(const CMap& cmap) {
deba@1979
   176
	checkConcept<concept::ReadMap<Node, _Value>, CMap>();
deba@1979
   177
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1979
   178
	Node it;
deba@1979
   179
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1979
   180
	  Parent::set(it, cmap[it]);
deba@1979
   181
	}
deba@1979
   182
	return *this;
deba@1979
   183
      }
deba@1979
   184
    };
deba@1979
   185
deba@1979
   186
    template <typename _Value>
deba@1979
   187
    class EdgeMap : public Graph::template EdgeMap<_Value> {
deba@1979
   188
    public:
deba@1979
   189
      typedef typename Graph::template EdgeMap<_Value> Parent;
deba@1979
   190
      explicit EdgeMap(const UGraphAdaptorBase<Graph>& ga) 
deba@1979
   191
	: Parent(*ga.graph) {}
deba@1979
   192
      EdgeMap(const UGraphAdaptorBase<Graph>& ga, const _Value& value)
deba@1979
   193
	: Parent(*ga.graph, value) {}
deba@1979
   194
deba@1979
   195
      EdgeMap& operator=(const EdgeMap& cmap) {
deba@1979
   196
	return operator=<EdgeMap>(cmap);
deba@1979
   197
      }
deba@1979
   198
deba@1979
   199
      template <typename CMap>
deba@1979
   200
      EdgeMap& operator=(const CMap& cmap) {
deba@1979
   201
	checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
deba@1979
   202
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1979
   203
	Edge it;
deba@1979
   204
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1979
   205
	  Parent::set(it, cmap[it]);
deba@1979
   206
	}
deba@1979
   207
	return *this;
deba@1979
   208
      }
deba@1979
   209
    };
deba@1979
   210
deba@1979
   211
    template <typename _Value>
deba@1979
   212
    class UEdgeMap : public Graph::template UEdgeMap<_Value> {
deba@1979
   213
    public:
deba@1979
   214
      typedef typename Graph::template UEdgeMap<_Value> Parent;
deba@1979
   215
      explicit UEdgeMap(const UGraphAdaptorBase<Graph>& ga) 
deba@1979
   216
	: Parent(*ga.graph) {}
deba@1979
   217
      UEdgeMap(const UGraphAdaptorBase<Graph>& ga, const _Value& value)
deba@1979
   218
	: Parent(*ga.graph, value) {}
deba@1979
   219
deba@1979
   220
      UEdgeMap& operator=(const UEdgeMap& cmap) {
deba@1979
   221
	return operator=<UEdgeMap>(cmap);
deba@1979
   222
      }
deba@1979
   223
deba@1979
   224
      template <typename CMap>
deba@1979
   225
      UEdgeMap& operator=(const CMap& cmap) {
deba@1979
   226
	checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
deba@1979
   227
	const typename Parent::Graph* graph = Parent::getGraph();
deba@1979
   228
	UEdge it;
deba@1979
   229
	for (graph->first(it); it != INVALID; graph->next(it)) {
deba@1979
   230
	  Parent::set(it, cmap[it]);
deba@1979
   231
	}
deba@1979
   232
	return *this;
deba@1979
   233
      }
deba@1979
   234
    };
deba@1979
   235
deba@1979
   236
  };
deba@1979
   237
deba@1979
   238
  /// \ingroup graph_adaptors
deba@1979
   239
  template <typename _UGraph>
deba@1979
   240
  class UGraphAdaptor 
deba@1979
   241
    : public UGraphAdaptorExtender< UGraphAdaptorBase<_UGraph> > { 
deba@1979
   242
  public:
deba@1979
   243
    typedef _UGraph Graph;
deba@1979
   244
    typedef UGraphAdaptorExtender<UGraphAdaptorBase<_UGraph> > Parent;
deba@1979
   245
  protected:
deba@1979
   246
    UGraphAdaptor() : Parent() {}
deba@1979
   247
deba@1979
   248
  public:
deba@1979
   249
    explicit UGraphAdaptor(Graph& _graph) { setGraph(_graph); }
deba@1979
   250
  };
deba@1979
   251
deba@1979
   252
  template <typename _UGraph, typename NodeFilterMap, 
deba@1979
   253
	    typename UEdgeFilterMap, bool checked = true>
deba@1979
   254
  class SubUGraphAdaptorBase : public UGraphAdaptorBase<_UGraph> {
deba@1979
   255
  public:
deba@1979
   256
    typedef _UGraph Graph;
deba@1979
   257
    typedef UGraphAdaptorBase<_UGraph> Parent;
deba@1979
   258
  protected:
deba@1979
   259
deba@1979
   260
    NodeFilterMap* node_filter_map;
deba@1979
   261
    UEdgeFilterMap* uedge_filter_map;
deba@1979
   262
deba@1979
   263
    SubUGraphAdaptorBase() 
deba@1979
   264
      : Parent(), node_filter_map(0), uedge_filter_map(0) { }
deba@1979
   265
deba@1979
   266
    void setNodeFilterMap(NodeFilterMap& _node_filter_map) {
deba@1979
   267
      node_filter_map=&_node_filter_map;
deba@1979
   268
    }
deba@1979
   269
    void setUEdgeFilterMap(UEdgeFilterMap& _uedge_filter_map) {
deba@1979
   270
      uedge_filter_map=&_uedge_filter_map;
deba@1979
   271
    }
deba@1979
   272
deba@1979
   273
  public:
deba@1979
   274
deba@1979
   275
    typedef typename Parent::Node Node;
deba@1979
   276
    typedef typename Parent::Edge Edge;
deba@1979
   277
    typedef typename Parent::UEdge UEdge;
deba@1979
   278
deba@1979
   279
    void first(Node& i) const { 
deba@1979
   280
      Parent::first(i); 
deba@1979
   281
      while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
deba@1979
   282
    }
deba@1979
   283
deba@1979
   284
    void first(Edge& i) const { 
deba@1979
   285
      Parent::first(i); 
deba@1979
   286
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   287
	     || !(*node_filter_map)[Parent::source(i)]
deba@1979
   288
	     || !(*node_filter_map)[Parent::target(i)])) Parent::next(i); 
deba@1979
   289
    }
deba@1979
   290
deba@1979
   291
    void first(UEdge& i) const { 
deba@1979
   292
      Parent::first(i); 
deba@1979
   293
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   294
	     || !(*node_filter_map)[Parent::source(i)]
deba@1979
   295
	     || !(*node_filter_map)[Parent::target(i)])) Parent::next(i); 
deba@1979
   296
    }
deba@1979
   297
deba@1979
   298
    void firstIn(Edge& i, const Node& n) const { 
deba@1979
   299
      Parent::firstIn(i, n); 
deba@1979
   300
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   301
	     || !(*node_filter_map)[Parent::source(i)])) Parent::nextIn(i); 
deba@1979
   302
    }
deba@1979
   303
deba@1979
   304
    void firstOut(Edge& i, const Node& n) const { 
deba@1979
   305
      Parent::firstOut(i, n); 
deba@1979
   306
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   307
	     || !(*node_filter_map)[Parent::target(i)])) Parent::nextOut(i); 
deba@1979
   308
    }
deba@1979
   309
deba@1979
   310
    void firstInc(UEdge& i, bool& d, const Node& n) const { 
deba@1979
   311
      Parent::firstInc(i, d, n); 
deba@1979
   312
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   313
            || !(*node_filter_map)[Parent::target(i)])) Parent::nextInc(i, d); 
deba@1979
   314
    }
deba@1979
   315
deba@1979
   316
    void next(Node& i) const { 
deba@1979
   317
      Parent::next(i); 
deba@1979
   318
      while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
deba@1979
   319
    }
deba@1979
   320
deba@1979
   321
    void next(Edge& i) const { 
deba@1979
   322
      Parent::next(i); 
deba@1979
   323
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   324
	     || !(*node_filter_map)[Parent::source(i)]
deba@1979
   325
	     || !(*node_filter_map)[Parent::target(i)])) Parent::next(i); 
deba@1979
   326
    }
deba@1979
   327
deba@1979
   328
    void next(UEdge& i) const { 
deba@1979
   329
      Parent::next(i); 
deba@1979
   330
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   331
	     || !(*node_filter_map)[Parent::source(i)]
deba@1979
   332
	     || !(*node_filter_map)[Parent::target(i)])) Parent::next(i); 
deba@1979
   333
    }
deba@1979
   334
deba@1979
   335
    void nextIn(Edge& i) const { 
deba@1979
   336
      Parent::nextIn(i); 
deba@1979
   337
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   338
	     || !(*node_filter_map)[Parent::source(i)])) Parent::nextIn(i); 
deba@1979
   339
    }
deba@1979
   340
deba@1979
   341
    void nextOut(Edge& i) const { 
deba@1979
   342
      Parent::nextOut(i); 
deba@1979
   343
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   344
	     || !(*node_filter_map)[Parent::target(i)])) Parent::nextOut(i); 
deba@1979
   345
    }
deba@1979
   346
deba@1979
   347
    void nextInc(UEdge& i, bool& d) const { 
deba@1979
   348
      Parent::nextInc(i, d); 
deba@1979
   349
      while (i!=INVALID && (!(*uedge_filter_map)[i] 
deba@1979
   350
            || !(*node_filter_map)[Parent::source(i)])) Parent::nextInc(i, d); 
deba@1979
   351
    }
deba@1979
   352
deba@1979
   353
    ///\e
deba@1979
   354
deba@1979
   355
    /// This function hides \c n in the graph, i.e. the iteration 
deba@1979
   356
    /// jumps over it. This is done by simply setting the value of \c n  
deba@1979
   357
    /// to be false in the corresponding node-map.
deba@1979
   358
    void hide(const Node& n) const { node_filter_map->set(n, false); }
deba@1979
   359
deba@1979
   360
    ///\e
deba@1979
   361
deba@1979
   362
    /// This function hides \c e in the graph, i.e. the iteration 
deba@1979
   363
    /// jumps over it. This is done by simply setting the value of \c e  
deba@1979
   364
    /// to be false in the corresponding edge-map.
deba@1979
   365
    void hide(const UEdge& e) const { uedge_filter_map->set(e, false); }
deba@1979
   366
deba@1979
   367
    ///\e
deba@1979
   368
deba@1979
   369
    /// The value of \c n is set to be true in the node-map which stores 
deba@1979
   370
    /// hide information. If \c n was hidden previuosly, then it is shown 
deba@1979
   371
    /// again
deba@1979
   372
     void unHide(const Node& n) const { node_filter_map->set(n, true); }
deba@1979
   373
deba@1979
   374
    ///\e
deba@1979
   375
deba@1979
   376
    /// The value of \c e is set to be true in the edge-map which stores 
deba@1979
   377
    /// hide information. If \c e was hidden previuosly, then it is shown 
deba@1979
   378
    /// again
deba@1979
   379
    void unHide(const UEdge& e) const { uedge_filter_map->set(e, true); }
deba@1979
   380
deba@1979
   381
    /// Returns true if \c n is hidden.
deba@1979
   382
    
deba@1979
   383
    ///\e
deba@1979
   384
    ///
deba@1979
   385
    bool hidden(const Node& n) const { return !(*node_filter_map)[n]; }
deba@1979
   386
deba@1979
   387
    /// Returns true if \c n is hidden.
deba@1979
   388
    
deba@1979
   389
    ///\e
deba@1979
   390
    ///
deba@1979
   391
    bool hidden(const UEdge& e) const { return !(*uedge_filter_map)[e]; }
deba@1979
   392
deba@1979
   393
    typedef False NodeNumTag;
deba@1979
   394
    typedef False EdgeNumTag;
deba@1991
   395
deba@1991
   396
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
deba@1991
   397
    Edge findEdge(const Node& source, const Node& target, 
deba@1991
   398
		  const Edge& prev = INVALID) {
deba@1991
   399
      if (!(*node_filter_map)[source] || !(*node_filter_map)[target]) {
deba@1991
   400
        return INVALID;
deba@1991
   401
      }
deba@1991
   402
      Edge edge = Parent::findEdge(source, target, prev);
deba@1991
   403
      while (edge != INVALID && !(*uedge_filter_map)[edge]) {
deba@1991
   404
        edge = Parent::findEdge(source, target, edge);
deba@1991
   405
      }
deba@1991
   406
      return edge;
deba@1991
   407
    }
deba@1991
   408
    UEdge findUEdge(const Node& source, const Node& target, 
deba@1991
   409
		  const UEdge& prev = INVALID) {
deba@1991
   410
      if (!(*node_filter_map)[source] || !(*node_filter_map)[target]) {
deba@1991
   411
        return INVALID;
deba@1991
   412
      }
deba@1991
   413
      UEdge uedge = Parent::findUEdge(source, target, prev);
deba@1991
   414
      while (uedge != INVALID && !(*uedge_filter_map)[uedge]) {
deba@1991
   415
        uedge = Parent::findUEdge(source, target, uedge);
deba@1991
   416
      }
deba@1991
   417
      return uedge;
deba@1991
   418
    }
deba@1979
   419
  };
deba@1979
   420
deba@1979
   421
  template <typename _UGraph, typename NodeFilterMap, typename UEdgeFilterMap>
deba@1979
   422
  class SubUGraphAdaptorBase<_UGraph, NodeFilterMap, UEdgeFilterMap, false> 
deba@1979
   423
    : public UGraphAdaptorBase<_UGraph> {
deba@1979
   424
  public:
deba@1979
   425
    typedef _UGraph Graph;
deba@1979
   426
    typedef UGraphAdaptorBase<_UGraph> Parent;
deba@1979
   427
  protected:
deba@1979
   428
    NodeFilterMap* node_filter_map;
deba@1979
   429
    UEdgeFilterMap* uedge_filter_map;
deba@1979
   430
    SubUGraphAdaptorBase() : Parent(), 
deba@1979
   431
			    node_filter_map(0), uedge_filter_map(0) { }
deba@1979
   432
deba@1979
   433
    void setNodeFilterMap(NodeFilterMap& _node_filter_map) {
deba@1979
   434
      node_filter_map=&_node_filter_map;
deba@1979
   435
    }
deba@1979
   436
    void setUEdgeFilterMap(UEdgeFilterMap& _uedge_filter_map) {
deba@1979
   437
      uedge_filter_map=&_uedge_filter_map;
deba@1979
   438
    }
deba@1979
   439
deba@1979
   440
  public:
deba@1979
   441
deba@1979
   442
    typedef typename Parent::Node Node;
deba@1979
   443
    typedef typename Parent::Edge Edge;
deba@1979
   444
    typedef typename Parent::UEdge UEdge;
deba@1979
   445
deba@1979
   446
    void first(Node& i) const { 
deba@1979
   447
      Parent::first(i); 
deba@1979
   448
      while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
deba@1979
   449
    }
deba@1979
   450
deba@1979
   451
    void first(Edge& i) const { 
deba@1979
   452
      Parent::first(i); 
deba@1979
   453
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::next(i); 
deba@1979
   454
    }
deba@1979
   455
deba@1979
   456
    void first(UEdge& i) const { 
deba@1979
   457
      Parent::first(i); 
deba@1979
   458
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::next(i); 
deba@1979
   459
    }
deba@1979
   460
deba@1979
   461
    void firstIn(Edge& i, const Node& n) const { 
deba@1979
   462
      Parent::firstIn(i, n); 
deba@1979
   463
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextIn(i); 
deba@1979
   464
    }
deba@1979
   465
deba@1979
   466
    void firstOut(Edge& i, const Node& n) const { 
deba@1979
   467
      Parent::firstOut(i, n); 
deba@1979
   468
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextOut(i); 
deba@1979
   469
    }
deba@1979
   470
deba@1979
   471
    void firstInc(UEdge& i, bool& d, const Node& n) const { 
deba@1979
   472
      Parent::firstInc(i, d, n); 
deba@1979
   473
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextInc(i, d); 
deba@1979
   474
    }
deba@1979
   475
deba@1979
   476
    void next(Node& i) const { 
deba@1979
   477
      Parent::next(i); 
deba@1979
   478
      while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
deba@1979
   479
    }
deba@1979
   480
    void next(Edge& i) const { 
deba@1979
   481
      Parent::next(i); 
deba@1979
   482
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::next(i); 
deba@1979
   483
    }
deba@1979
   484
    void next(UEdge& i) const { 
deba@1979
   485
      Parent::next(i); 
deba@1979
   486
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::next(i); 
deba@1979
   487
    }
deba@1979
   488
    void nextIn(Edge& i) const { 
deba@1979
   489
      Parent::nextIn(i); 
deba@1979
   490
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextIn(i); 
deba@1979
   491
    }
deba@1979
   492
deba@1979
   493
    void nextOut(Edge& i) const { 
deba@1979
   494
      Parent::nextOut(i); 
deba@1979
   495
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextOut(i); 
deba@1979
   496
    }
deba@1979
   497
    void nextInc(UEdge& i, bool& d) const { 
deba@1979
   498
      Parent::nextInc(i, d); 
deba@1979
   499
      while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextInc(i, d); 
deba@1979
   500
    }
deba@1979
   501
deba@1979
   502
    ///\e
deba@1979
   503
deba@1979
   504
    /// This function hides \c n in the graph, i.e. the iteration 
deba@1979
   505
    /// jumps over it. This is done by simply setting the value of \c n  
deba@1979
   506
    /// to be false in the corresponding node-map.
deba@1979
   507
    void hide(const Node& n) const { node_filter_map->set(n, false); }
deba@1979
   508
deba@1979
   509
    ///\e
deba@1979
   510
deba@1979
   511
    /// This function hides \c e in the graph, i.e. the iteration 
deba@1979
   512
    /// jumps over it. This is done by simply setting the value of \c e  
deba@1979
   513
    /// to be false in the corresponding edge-map.
deba@1979
   514
    void hide(const UEdge& e) const { uedge_filter_map->set(e, false); }
deba@1979
   515
deba@1979
   516
    ///\e
deba@1979
   517
deba@1979
   518
    /// The value of \c n is set to be true in the node-map which stores 
deba@1979
   519
    /// hide information. If \c n was hidden previuosly, then it is shown 
deba@1979
   520
    /// again
deba@1979
   521
     void unHide(const Node& n) const { node_filter_map->set(n, true); }
deba@1979
   522
deba@1979
   523
    ///\e
deba@1979
   524
deba@1979
   525
    /// The value of \c e is set to be true in the edge-map which stores 
deba@1979
   526
    /// hide information. If \c e was hidden previuosly, then it is shown 
deba@1979
   527
    /// again
deba@1979
   528
    void unHide(const UEdge& e) const { uedge_filter_map->set(e, true); }
deba@1979
   529
deba@1979
   530
    /// Returns true if \c n is hidden.
deba@1979
   531
    
deba@1979
   532
    ///\e
deba@1979
   533
    ///
deba@1979
   534
    bool hidden(const Node& n) const { return !(*node_filter_map)[n]; }
deba@1979
   535
deba@1979
   536
    /// Returns true if \c n is hidden.
deba@1979
   537
    
deba@1979
   538
    ///\e
deba@1979
   539
    ///
deba@1979
   540
    bool hidden(const UEdge& e) const { return !(*uedge_filter_map)[e]; }
deba@1979
   541
deba@1979
   542
    typedef False NodeNumTag;
deba@1979
   543
    typedef False EdgeNumTag;
deba@1991
   544
deba@1991
   545
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
deba@1991
   546
    Edge findEdge(const Node& source, const Node& target, 
deba@1991
   547
		  const Edge& prev = INVALID) {
deba@1991
   548
      Edge edge = Parent::findEdge(source, target, prev);
deba@1991
   549
      while (edge != INVALID && !(*uedge_filter_map)[edge]) {
deba@1991
   550
        edge = Parent::findEdge(source, target, edge);
deba@1991
   551
      }
deba@1991
   552
      return edge;
deba@1991
   553
    }
deba@1991
   554
    UEdge findUEdge(const Node& source, const Node& target, 
deba@1991
   555
		  const UEdge& prev = INVALID) {
deba@1991
   556
      UEdge uedge = Parent::findUEdge(source, target, prev);
deba@1991
   557
      while (uedge != INVALID && !(*uedge_filter_map)[uedge]) {
deba@1991
   558
        uedge = Parent::findUEdge(source, target, uedge);
deba@1991
   559
      }
deba@1991
   560
      return uedge;
deba@1991
   561
    }
deba@1979
   562
  };
deba@1979
   563
deba@1979
   564
  /// \ingroup graph_adaptors
deba@1979
   565
  ///
deba@1979
   566
  /// \brief A graph adaptor for hiding nodes and edges from an undirected 
deba@1979
   567
  /// graph.
deba@1979
   568
  /// 
deba@1979
   569
  /// SubUGraphAdaptor shows the undirected graph with filtered node-set and 
deba@1979
   570
  /// edge-set. If the \c checked parameter is true then it filters the edgeset
deba@1979
   571
  /// to do not get invalid edges without source or target.
deba@1979
   572
  /// 
deba@1979
   573
  /// If the \c checked template parameter is false then we have to note that 
deba@1979
   574
  /// the node-iterator cares only the filter on the node-set, and the 
deba@1979
   575
  /// edge-iterator cares only the filter on the edge-set.
deba@1979
   576
  /// This way the edge-map
deba@1979
   577
  /// should filter all edges which's source or target is filtered by the 
deba@1979
   578
  /// node-filter.
deba@1979
   579
  ///
deba@1979
   580
  /// Note that \c n is of type \c SubGA::NodeIt, but it can be converted to
deba@1979
   581
  /// \c Graph::Node that is why \c g.id(n) can be applied.
deba@1979
   582
  /// 
deba@1979
   583
  template<typename _UGraph, typename NodeFilterMap, 
deba@1979
   584
	   typename UEdgeFilterMap, bool checked = true>
deba@1979
   585
  class SubUGraphAdaptor : 
deba@1979
   586
    public UGraphAdaptorExtender<
deba@1979
   587
    SubUGraphAdaptorBase<_UGraph, NodeFilterMap, UEdgeFilterMap, checked> > {
deba@1979
   588
  public:
deba@1979
   589
    typedef _UGraph Graph;
deba@1979
   590
    typedef UGraphAdaptorExtender<
deba@1979
   591
      SubUGraphAdaptorBase<_UGraph, NodeFilterMap, UEdgeFilterMap> > Parent;
deba@1979
   592
  protected:
deba@1979
   593
    SubUGraphAdaptor() { }
deba@1979
   594
  public:
deba@1979
   595
    SubUGraphAdaptor(Graph& _graph, NodeFilterMap& _node_filter_map, 
deba@1979
   596
		    UEdgeFilterMap& _uedge_filter_map) { 
deba@1979
   597
      setGraph(_graph);
deba@1979
   598
      setNodeFilterMap(_node_filter_map);
deba@1979
   599
      setUEdgeFilterMap(_uedge_filter_map);
deba@1979
   600
    }
deba@1979
   601
  };
deba@1979
   602
deba@1980
   603
  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
deba@1980
   604
  SubUGraphAdaptor<const UGraph, NodeFilterMap, EdgeFilterMap>
deba@1980
   605
  subUGraphAdaptor(const UGraph& graph, 
deba@1980
   606
                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
deba@1980
   607
    return SubUGraphAdaptor<const UGraph, NodeFilterMap, EdgeFilterMap>
deba@1980
   608
      (graph, nfm, efm);
deba@1980
   609
  }
deba@1980
   610
deba@1980
   611
  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
deba@1980
   612
  SubUGraphAdaptor<const UGraph, const NodeFilterMap, EdgeFilterMap>
deba@1980
   613
  subUGraphAdaptor(const UGraph& graph, 
deba@1980
   614
                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
deba@1980
   615
    return SubUGraphAdaptor<const UGraph, const NodeFilterMap, EdgeFilterMap>
deba@1980
   616
      (graph, nfm, efm);
deba@1980
   617
  }
deba@1980
   618
deba@1980
   619
  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
deba@1980
   620
  SubUGraphAdaptor<const UGraph, NodeFilterMap, const EdgeFilterMap>
deba@1980
   621
  subUGraphAdaptor(const UGraph& graph, 
deba@1980
   622
                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
deba@1980
   623
    return SubUGraphAdaptor<const UGraph, NodeFilterMap, const EdgeFilterMap>
deba@1980
   624
      (graph, nfm, efm);
deba@1980
   625
  }
deba@1980
   626
deba@1980
   627
  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
deba@1980
   628
  SubUGraphAdaptor<const UGraph, const NodeFilterMap, const EdgeFilterMap>
deba@1980
   629
  subUGraphAdaptor(const UGraph& graph, 
deba@1980
   630
                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
deba@1980
   631
    return SubUGraphAdaptor<const UGraph, const NodeFilterMap, 
deba@1980
   632
      const EdgeFilterMap>(graph, nfm, efm);
deba@1980
   633
  }
deba@1980
   634
deba@1979
   635
  /// \ingroup graph_adaptors
deba@1979
   636
  ///
deba@1980
   637
  /// \brief An adaptor for hiding nodes from an undirected graph.
deba@1979
   638
  ///
deba@1979
   639
  /// An adaptor for hiding nodes from an undirected graph.
deba@1979
   640
  /// This adaptor specializes SubUGraphAdaptor in the way that only
deba@1979
   641
  /// the node-set 
deba@1979
   642
  /// can be filtered. In usual case the checked parameter is true, we get the
deba@1979
   643
  /// induced subgraph. But if the checked parameter is false then we can only
deba@1979
   644
  /// filter only isolated nodes.
deba@1979
   645
  template<typename _UGraph, typename NodeFilterMap, bool checked = true>
deba@1979
   646
  class NodeSubUGraphAdaptor : 
deba@1979
   647
    public SubUGraphAdaptor<_UGraph, NodeFilterMap, 
deba@1979
   648
                            ConstMap<typename _UGraph::UEdge, bool>, checked> {
deba@1979
   649
  public:
deba@1979
   650
    typedef SubUGraphAdaptor<_UGraph, NodeFilterMap, 
deba@1979
   651
                             ConstMap<typename _UGraph::UEdge, bool> > Parent;
deba@1979
   652
    typedef _UGraph Graph;
deba@1979
   653
  protected:
deba@1985
   654
    ConstMap<typename _UGraph::UEdge, bool> const_true_map;
deba@1991
   655
deba@1991
   656
    NodeSubUGraphAdaptor() : const_true_map(true) {
deba@1991
   657
      Parent::setUEdgeFilterMap(const_true_map);
deba@1991
   658
    }
deba@1991
   659
deba@1979
   660
  public:
deba@1979
   661
    NodeSubUGraphAdaptor(Graph& _graph, NodeFilterMap& _node_filter_map) : 
deba@1979
   662
      Parent(), const_true_map(true) { 
deba@1979
   663
      Parent::setGraph(_graph);
deba@1979
   664
      Parent::setNodeFilterMap(_node_filter_map);
deba@1979
   665
      Parent::setUEdgeFilterMap(const_true_map);
deba@1979
   666
    }
deba@1979
   667
  };
deba@1979
   668
deba@1979
   669
  template<typename UGraph, typename NodeFilterMap>
deba@1979
   670
  NodeSubUGraphAdaptor<const UGraph, NodeFilterMap>
deba@1979
   671
  nodeSubUGraphAdaptor(const UGraph& graph, NodeFilterMap& nfm) {
deba@1979
   672
    return NodeSubUGraphAdaptor<const UGraph, NodeFilterMap>(graph, nfm);
deba@1979
   673
  }
deba@1979
   674
deba@1979
   675
  template<typename UGraph, typename NodeFilterMap>
deba@1979
   676
  NodeSubUGraphAdaptor<const UGraph, const NodeFilterMap>
deba@1979
   677
  nodeSubUGraphAdaptor(const UGraph& graph, const NodeFilterMap& nfm) {
deba@1979
   678
    return NodeSubUGraphAdaptor<const UGraph, const NodeFilterMap>(graph, nfm);
deba@1979
   679
  }
deba@1979
   680
deba@1979
   681
deba@1979
   682
  /// \brief An adaptor for hiding undirected edges from an undirected graph.
deba@1979
   683
  ///
deba@1979
   684
  /// \warning Graph adaptors are in even more experimental state
deba@1979
   685
  /// than the other parts of the lib. Use them at you own risk.
deba@1979
   686
  ///
deba@1979
   687
  /// An adaptor for hiding undirected edges from an undirected graph.
deba@1979
   688
  /// This adaptor specializes SubUGraphAdaptor in the way that
deba@1979
   689
  /// only the edge-set 
deba@1979
   690
  /// can be filtered.
deba@1979
   691
  template<typename _UGraph, typename UEdgeFilterMap>
deba@1979
   692
  class EdgeSubUGraphAdaptor : 
deba@1979
   693
    public SubUGraphAdaptor<_UGraph, ConstMap<typename _UGraph::Node,bool>, 
deba@1979
   694
                            UEdgeFilterMap, false> {
deba@1979
   695
  public:
deba@1979
   696
    typedef SubUGraphAdaptor<_UGraph, ConstMap<typename _UGraph::Node,bool>, 
deba@1979
   697
                             UEdgeFilterMap, false> Parent;
deba@1979
   698
    typedef _UGraph Graph;
deba@1979
   699
  protected:
deba@1979
   700
    ConstMap<typename Graph::Node, bool> const_true_map;
deba@1991
   701
deba@1991
   702
    EdgeSubUGraphAdaptor() : const_true_map(true) {
deba@1991
   703
      Parent::setNodeFilterMap(const_true_map);
deba@1991
   704
    }
deba@1991
   705
deba@1979
   706
  public:
deba@1979
   707
    EdgeSubUGraphAdaptor(Graph& _graph, UEdgeFilterMap& _uedge_filter_map) : 
deba@1979
   708
      Parent(), const_true_map(true) { 
deba@1979
   709
      Parent::setGraph(_graph);
deba@1979
   710
      Parent::setNodeFilterMap(const_true_map);
deba@1979
   711
      Parent::setUEdgeFilterMap(_uedge_filter_map);
deba@1979
   712
    }
deba@1979
   713
  };
deba@1979
   714
deba@1979
   715
  template<typename UGraph, typename EdgeFilterMap>
deba@1979
   716
  EdgeSubUGraphAdaptor<const UGraph, EdgeFilterMap>
deba@1979
   717
  edgeSubUGraphAdaptor(const UGraph& graph, EdgeFilterMap& efm) {
deba@1979
   718
    return EdgeSubUGraphAdaptor<const UGraph, EdgeFilterMap>(graph, efm);
deba@1979
   719
  }
deba@1979
   720
deba@1979
   721
  template<typename UGraph, typename EdgeFilterMap>
deba@1979
   722
  EdgeSubUGraphAdaptor<const UGraph, const EdgeFilterMap>
deba@1979
   723
  edgeSubUGraphAdaptor(const UGraph& graph, const EdgeFilterMap& efm) {
deba@1979
   724
    return EdgeSubUGraphAdaptor<const UGraph, const EdgeFilterMap>(graph, efm);
deba@1979
   725
  }
deba@1979
   726
deba@1979
   727
  template <typename _UGraph, typename _DirectionMap>
deba@1980
   728
  class DirUGraphAdaptorBase {
deba@1979
   729
  public:
deba@1979
   730
    
deba@1979
   731
    typedef _UGraph Graph;
deba@1979
   732
    typedef _DirectionMap DirectionMap;
deba@1979
   733
deba@1979
   734
    typedef typename _UGraph::Node Node;
deba@1979
   735
    typedef typename _UGraph::UEdge Edge;
deba@1979
   736
   
deba@1991
   737
    void reverseEdge(const Edge& edge) {
deba@1991
   738
      direction->set(edge, !(*direction)[edge]);
deba@1991
   739
    }
deba@1991
   740
deba@1979
   741
    void first(Node& i) const { graph->first(i); }
deba@1979
   742
    void first(Edge& i) const { graph->first(i); }
deba@1979
   743
    void firstIn(Edge& i, const Node& n) const {
deba@1979
   744
      bool d;
deba@1979
   745
      graph->firstInc(i, d, n);
deba@1979
   746
      while (i != INVALID && d == (*direction)[i]) graph->nextInc(i, d);
deba@1979
   747
    }
deba@1979
   748
    void firstOut(Edge& i, const Node& n ) const { 
deba@1979
   749
      bool d;
deba@1979
   750
      graph->firstInc(i, d, n);
deba@1979
   751
      while (i != INVALID && d != (*direction)[i]) graph->nextInc(i, d);
deba@1979
   752
    }
deba@1979
   753
deba@1979
   754
    void next(Node& i) const { graph->next(i); }
deba@1979
   755
    void next(Edge& i) const { graph->next(i); }
deba@1979
   756
    void nextIn(Edge& i) const {
deba@1979
   757
      bool d = !(*direction)[i];
deba@1979
   758
      graph->nextInc(i, d);
deba@1979
   759
      while (i != INVALID && d == (*direction)[i]) graph->nextInc(i, d);
deba@1979
   760
    }
deba@1979
   761
    void nextOut(Edge& i) const {
deba@1979
   762
      bool d = (*direction)[i];
deba@1979
   763
      graph->nextInc(i, d);
deba@1979
   764
      while (i != INVALID && d != (*direction)[i]) graph->nextInc(i, d);
deba@1979
   765
    }
deba@1979
   766
deba@1979
   767
    Node source(const Edge& e) const { 
deba@1979
   768
      return (*direction)[e] ? graph->source(e) : graph->target(e); 
deba@1979
   769
    }
deba@1979
   770
    Node target(const Edge& e) const { 
deba@1979
   771
      return (*direction)[e] ? graph->target(e) : graph->source(e); 
deba@1979
   772
    }
deba@1979
   773
deba@1979
   774
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
deba@1979
   775
    int nodeNum() const { return graph->nodeNum(); }
deba@1979
   776
    
deba@1979
   777
    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
deba@1979
   778
    int edgeNum() const { return graph->uEdgeNum(); }
deba@1979
   779
deba@1979
   780
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
deba@1979
   781
    Edge findEdge(const Node& source, const Node& target, 
deba@1979
   782
		  const Edge& prev = INVALID) {
deba@1979
   783
      Edge edge = prev;
deba@1979
   784
      bool d = edge == INVALID ? true : (*direction)[edge];
deba@1979
   785
      if (d) {
deba@1979
   786
        edge = graph->findUEdge(source, target, edge);
deba@1979
   787
        while (edge != INVALID && !(*direction)[edge]) {
deba@1979
   788
          graph->findUEdge(source, target, edge);
deba@1979
   789
        }
deba@1979
   790
        if (edge != INVALID) return edge;
deba@1979
   791
      }
deba@1979
   792
      graph->findUEdge(target, source, edge);
deba@1979
   793
      while (edge != INVALID && (*direction)[edge]) {
deba@1979
   794
        graph->findUEdge(source, target, edge);
deba@1979
   795
      }
deba@1979
   796
      return edge;
deba@1979
   797
    }
deba@1979
   798
  
deba@1979
   799
    Node addNode() const { 
deba@1979
   800
      return Node(graph->addNode()); 
deba@1979
   801
    }
deba@1979
   802
deba@1979
   803
    Edge addEdge(const Node& source, const Node& target) const {
deba@1979
   804
      Edge edge = graph->addEdge(source, target);
deba@1979
   805
      (*direction)[edge] = graph->source(edge) == source;
deba@1979
   806
      return edge; 
deba@1979
   807
    }
deba@1979
   808
deba@1979
   809
    void erase(const Node& i) const { graph->erase(i); }
deba@1979
   810
    void erase(const Edge& i) const { graph->erase(i); }
deba@1979
   811
  
deba@1979
   812
    void clear() const { graph->clear(); }
deba@1979
   813
    
deba@1979
   814
    int id(const Node& v) const { return graph->id(v); }
deba@1979
   815
    int id(const Edge& e) const { return graph->id(e); }
deba@1979
   816
deba@1991
   817
    int maxNodeId() const {
deba@1991
   818
      return graph->maxNodeId();
deba@1979
   819
    }
deba@1979
   820
deba@1991
   821
    int maxEdgeId() const {
deba@1991
   822
      return graph->maxEdgeId();
deba@1991
   823
    }
deba@1991
   824
deba@1991
   825
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
deba@1991
   826
deba@1991
   827
    NodeNotifier& getNotifier(Node) const {
deba@1991
   828
      return graph->getNotifier(Node());
deba@1991
   829
    } 
deba@1991
   830
deba@1991
   831
    typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier;
deba@1991
   832
deba@1991
   833
    EdgeNotifier& getNotifier(Edge) const {
deba@1991
   834
      return graph->getNotifier(Edge());
deba@1991
   835
    } 
deba@1991
   836
deba@1979
   837
    template <typename _Value>
deba@1979
   838
    class NodeMap : public _UGraph::template NodeMap<_Value> {
deba@1979
   839
    public:
deba@1979
   840
      typedef typename _UGraph::template NodeMap<_Value> Parent;
deba@1980
   841
      explicit NodeMap(const DirUGraphAdaptorBase& ga) 
deba@1979
   842
	: Parent(*ga.graph) { }
deba@1980
   843
      NodeMap(const DirUGraphAdaptorBase& ga, const _Value& value)
deba@1979
   844
	: Parent(*ga.graph, value) { }
deba@1979
   845
    };
deba@1979
   846
deba@1979
   847
    template <typename _Value>
deba@1979
   848
    class EdgeMap : public _UGraph::template UEdgeMap<_Value> {
deba@1979
   849
    public:
deba@1980
   850
      typedef typename _UGraph::template UEdgeMap<_Value> Parent;
deba@1980
   851
      explicit EdgeMap(const DirUGraphAdaptorBase& ga) 
deba@1979
   852
	: Parent(*ga.graph) { }
deba@1980
   853
      EdgeMap(const DirUGraphAdaptorBase& ga, const _Value& value)
deba@1979
   854
	: Parent(*ga.graph, value) { }
deba@1979
   855
    };
deba@1979
   856
deba@1979
   857
    
deba@1979
   858
deba@1979
   859
  protected:
deba@1979
   860
    Graph* graph;
deba@1979
   861
    DirectionMap* direction;
deba@1979
   862
deba@1979
   863
    void setDirectionMap(DirectionMap& _direction) {
deba@1979
   864
      direction = &_direction;
deba@1979
   865
    }
deba@1979
   866
deba@1979
   867
    void setGraph(Graph& _graph) {
deba@1979
   868
      graph = &_graph;
deba@1979
   869
    }
deba@1979
   870
deba@1979
   871
  };
deba@1979
   872
deba@1979
   873
deba@1980
   874
  /// \ingroup graph_adaptors
deba@1991
   875
  ///
deba@1991
   876
  /// \brief A directed graph is made from an undirected graph by an adaptor
deba@1980
   877
  ///
deba@1980
   878
  /// This adaptor gives a direction for each uedge in the undirected graph.
deba@1980
   879
  /// The direction of the edges stored in the DirectionMap. This map is
deba@1980
   880
  /// a bool map on the undirected edges. If the uedge is mapped to true
deba@1980
   881
  /// then the direction of the directed edge will be the same as the
deba@1980
   882
  /// default direction of the uedge. The edges can be easily reverted
deba@1980
   883
  /// by the reverseEdge member in the adaptor.  
deba@1980
   884
  template<typename _Graph, 
deba@1980
   885
           typename DirectionMap = typename _Graph::template UEdgeMap<bool> > 
deba@1980
   886
  class DirUGraphAdaptor : 
deba@1979
   887
    public GraphAdaptorExtender<
deba@1980
   888
    DirUGraphAdaptorBase<_Graph, DirectionMap> > {
deba@1979
   889
  public:
deba@1979
   890
    typedef _Graph Graph;
deba@1979
   891
    typedef GraphAdaptorExtender<
deba@1980
   892
      DirUGraphAdaptorBase<_Graph, DirectionMap> > Parent;
deba@1979
   893
  protected:
deba@1980
   894
    DirUGraphAdaptor() { }
deba@1979
   895
  public:
deba@1980
   896
    DirUGraphAdaptor(_Graph& _graph, DirectionMap& _direction_map) { 
deba@1979
   897
      setGraph(_graph);
deba@1979
   898
      setDirectionMap(_direction_map);
deba@1979
   899
    }
deba@1979
   900
  };
deba@1979
   901
deba@1979
   902
  template<typename UGraph, typename DirectionMap>
deba@1980
   903
  DirUGraphAdaptor<const UGraph, DirectionMap>
deba@1980
   904
  dirUGraphAdaptor(const UGraph& graph, DirectionMap& dm) {
deba@1980
   905
    return DirUGraphAdaptor<const UGraph, DirectionMap>(graph, dm);
deba@1979
   906
  }
deba@1979
   907
deba@1979
   908
  template<typename UGraph, typename DirectionMap>
deba@1980
   909
  DirUGraphAdaptor<const UGraph, const DirectionMap>
deba@1980
   910
  dirUGraphAdaptor(const UGraph& graph, const DirectionMap& dm) {
deba@1980
   911
    return DirUGraphAdaptor<const UGraph, const DirectionMap>(graph, dm);
deba@1979
   912
  }
deba@1979
   913
deba@1979
   914
}
deba@1979
   915
deba@1979
   916
#endif