gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Reorganication of graph adaptors and doc improvements (#67) - Moving to one file, lemon/adaptors.h - Renamings - Doc cleanings
2 5 1
default
8 files changed with 1505 insertions and 1836 deletions:
↑ Collapse diff ↑
Show white space 2 line context
... ...
@@ -62,2 +62,75 @@
62 62
/**
63
@defgroup graph_adaptors Adaptor Classes for graphs
64
@ingroup graphs
65
\brief This group contains several adaptor classes for digraphs and graphs
66

	
67
The main parts of LEMON are the different graph structures, generic
68
graph algorithms, graph concepts which couple these, and graph
69
adaptors. While the previous notions are more or less clear, the
70
latter one needs further explanation. Graph adaptors are graph classes
71
which serve for considering graph structures in different ways.
72

	
73
A short example makes this much clearer.  Suppose that we have an
74
instance \c g of a directed graph type say ListDigraph and an algorithm
75
\code
76
template <typename Digraph>
77
int algorithm(const Digraph&);
78
\endcode
79
is needed to run on the reverse oriented graph.  It may be expensive
80
(in time or in memory usage) to copy \c g with the reversed
81
arcs.  In this case, an adaptor class is used, which (according
82
to LEMON digraph concepts) works as a digraph.  The adaptor uses the
83
original digraph structure and digraph operations when methods of the
84
reversed oriented graph are called.  This means that the adaptor have
85
minor memory usage, and do not perform sophisticated algorithmic
86
actions.  The purpose of it is to give a tool for the cases when a
87
graph have to be used in a specific alteration.  If this alteration is
88
obtained by a usual construction like filtering the arc-set or
89
considering a new orientation, then an adaptor is worthwhile to use.
90
To come back to the reverse oriented graph, in this situation
91
\code
92
template<typename Digraph> class ReverseDigraph;
93
\endcode
94
template class can be used. The code looks as follows
95
\code
96
ListDigraph g;
97
ReverseDigraph<ListGraph> rg(g);
98
int result = algorithm(rg);
99
\endcode
100
After running the algorithm, the original graph \c g is untouched.
101
This techniques gives rise to an elegant code, and based on stable
102
graph adaptors, complex algorithms can be implemented easily.
103

	
104
In flow, circulation and bipartite matching problems, the residual
105
graph is of particular importance. Combining an adaptor implementing
106
this, shortest path algorithms and minimum mean cycle algorithms,
107
a range of weighted and cardinality optimization algorithms can be
108
obtained. For other examples, the interested user is referred to the
109
detailed documentation of particular adaptors.
110

	
111
The behavior of graph adaptors can be very different. Some of them keep
112
capabilities of the original graph while in other cases this would be
113
meaningless. This means that the concepts that they are models of depend
114
on the graph adaptor, and the wrapped graph(s).
115
If an arc of \c rg is deleted, this is carried out by deleting the
116
corresponding arc of \c g, thus the adaptor modifies the original graph.
117

	
118
But for a residual graph, this operation has no sense.
119
Let us stand one more example here to simplify your work.
120
RevGraphAdaptor has constructor
121
\code
122
ReverseDigraph(Digraph& digraph);
123
\endcode
124
This means that in a situation, when a <tt>const ListDigraph&</tt>
125
reference to a graph is given, then it have to be instantiated with
126
<tt>Digraph=const ListDigraph</tt>.
127
\code
128
int algorithm1(const ListDigraph& g) {
129
  RevGraphAdaptor<const ListDigraph> rg(g);
130
  return algorithm2(rg);
131
}
132
\endcode
133
*/
134

	
135
/**
63 136
@defgroup semi_adaptors Semi-Adaptor Classes for Graphs
Show white space 2 line context
... ...
@@ -18,2 +18,3 @@
18 18
lemon_HEADERS += \
19
	lemon/adaptors.h \
19 20
        lemon/arg_parser.h \
Show white space 2 line context
1
/* -*- C++ -*-
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library
3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
... ...
@@ -18,4 +18,4 @@
18 18

	
19
#ifndef LEMON_DIGRAPH_ADAPTOR_H
20
#define LEMON_DIGRAPH_ADAPTOR_H
19
#ifndef LEMON_ADAPTORS_H
20
#define LEMON_ADAPTORS_H
21 21

	
... ...
@@ -23,5 +23,5 @@
23 23
///\file
24
///\brief Several digraph adaptors.
24
/// \brief Several graph adaptors
25 25
///
26
///This file contains several useful digraph adaptor classes.
26
/// This file contains several useful adaptors for digraphs and graphs.
27 27

	
... ...
@@ -31,5 +31,3 @@
31 31

	
32
#include <lemon/bits/base_extender.h>
33 32
#include <lemon/bits/graph_adaptor_extender.h>
34
#include <lemon/bits/graph_extender.h>
35 33
#include <lemon/tolerance.h>
... ...
@@ -157,5 +155,159 @@
157 155

	
156
  template<typename _Graph>
157
  class GraphAdaptorBase {
158
  public:
159
    typedef _Graph Graph;
160
    typedef Graph ParentGraph;
161

	
162
  protected:
163
    Graph* _graph;
164

	
165
    GraphAdaptorBase() : _graph(0) {}
166

	
167
    void setGraph(Graph& graph) { _graph = &graph; }
168

	
169
  public:
170
    GraphAdaptorBase(Graph& graph) : _graph(&graph) {}
171

	
172
    typedef typename Graph::Node Node;
173
    typedef typename Graph::Arc Arc;
174
    typedef typename Graph::Edge Edge;
175

	
176
    void first(Node& i) const { _graph->first(i); }
177
    void first(Arc& i) const { _graph->first(i); }
178
    void first(Edge& i) const { _graph->first(i); }
179
    void firstIn(Arc& i, const Node& n) const { _graph->firstIn(i, n); }
180
    void firstOut(Arc& i, const Node& n ) const { _graph->firstOut(i, n); }
181
    void firstInc(Edge &i, bool &d, const Node &n) const {
182
      _graph->firstInc(i, d, n);
183
    }
184

	
185
    void next(Node& i) const { _graph->next(i); }
186
    void next(Arc& i) const { _graph->next(i); }
187
    void next(Edge& i) const { _graph->next(i); }
188
    void nextIn(Arc& i) const { _graph->nextIn(i); }
189
    void nextOut(Arc& i) const { _graph->nextOut(i); }
190
    void nextInc(Edge &i, bool &d) const { _graph->nextInc(i, d); }
191

	
192
    Node u(const Edge& e) const { return _graph->u(e); }
193
    Node v(const Edge& e) const { return _graph->v(e); }
194

	
195
    Node source(const Arc& a) const { return _graph->source(a); }
196
    Node target(const Arc& a) const { return _graph->target(a); }
197

	
198
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
199
    int nodeNum() const { return _graph->nodeNum(); }
200

	
201
    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
202
    int arcNum() const { return _graph->arcNum(); }
203
    int edgeNum() const { return _graph->edgeNum(); }
204

	
205
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
206
    Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
207
      return _graph->findArc(u, v, prev);
208
    }
209
    Edge findEdge(const Node& u, const Node& v, const Edge& prev = INVALID) {
210
      return _graph->findEdge(u, v, prev);
211
    }
212

	
213
    Node addNode() { return _graph->addNode(); }
214
    Edge addEdge(const Node& u, const Node& v) { return _graph->addEdge(u, v); }
215

	
216
    void erase(const Node& i) { _graph->erase(i); }
217
    void erase(const Edge& i) { _graph->erase(i); }
218

	
219
    void clear() { _graph->clear(); }
220

	
221
    bool direction(const Arc& a) const { return _graph->direction(a); }
222
    Arc direct(const Edge& e, bool d) const { return _graph->direct(e, d); }
223

	
224
    int id(const Node& v) const { return _graph->id(v); }
225
    int id(const Arc& a) const { return _graph->id(a); }
226
    int id(const Edge& e) const { return _graph->id(e); }
227

	
228
    Node nodeFromId(int ix) const { return _graph->nodeFromId(ix); }
229
    Arc arcFromId(int ix) const { return _graph->arcFromId(ix); }
230
    Edge edgeFromId(int ix) const { return _graph->edgeFromId(ix); }
231

	
232
    int maxNodeId() const { return _graph->maxNodeId(); }
233
    int maxArcId() const { return _graph->maxArcId(); }
234
    int maxEdgeId() const { return _graph->maxEdgeId(); }
235

	
236
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
237
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
238

	
239
    typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier;
240
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
241

	
242
    typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier;
243
    EdgeNotifier& notifier(Edge) const { return _graph->notifier(Edge()); }
244

	
245
    template <typename _Value>
246
    class NodeMap : public Graph::template NodeMap<_Value> {
247
    public:
248
      typedef typename Graph::template NodeMap<_Value> Parent;
249
      explicit NodeMap(const GraphAdaptorBase<Graph>& adapter)
250
        : Parent(*adapter._graph) {}
251
      NodeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
252
        : Parent(*adapter._graph, value) {}
253

	
254
    private:
255
      NodeMap& operator=(const NodeMap& cmap) {
256
        return operator=<NodeMap>(cmap);
257
      }
258

	
259
      template <typename CMap>
260
      NodeMap& operator=(const CMap& cmap) {
261
        Parent::operator=(cmap);
262
        return *this;
263
      }
264

	
265
    };
266

	
267
    template <typename _Value>
268
    class ArcMap : public Graph::template ArcMap<_Value> {
269
    public:
270
      typedef typename Graph::template ArcMap<_Value> Parent;
271
      explicit ArcMap(const GraphAdaptorBase<Graph>& adapter)
272
        : Parent(*adapter._graph) {}
273
      ArcMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
274
        : Parent(*adapter._graph, value) {}
275

	
276
    private:
277
      ArcMap& operator=(const ArcMap& cmap) {
278
        return operator=<ArcMap>(cmap);
279
      }
280

	
281
      template <typename CMap>
282
      ArcMap& operator=(const CMap& cmap) {
283
        Parent::operator=(cmap);
284
        return *this;
285
      }
286
    };
287

	
288
    template <typename _Value>
289
    class EdgeMap : public Graph::template EdgeMap<_Value> {
290
    public:
291
      typedef typename Graph::template EdgeMap<_Value> Parent;
292
      explicit EdgeMap(const GraphAdaptorBase<Graph>& adapter)
293
        : Parent(*adapter._graph) {}
294
      EdgeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
295
        : Parent(*adapter._graph, value) {}
296

	
297
    private:
298
      EdgeMap& operator=(const EdgeMap& cmap) {
299
        return operator=<EdgeMap>(cmap);
300
      }
301

	
302
      template <typename CMap>
303
      EdgeMap& operator=(const CMap& cmap) {
304
        Parent::operator=(cmap);
305
        return *this;
306
      }
307
    };
308

	
309
  };
158 310

	
159 311
  template <typename _Digraph>
160
  class RevDigraphAdaptorBase : public DigraphAdaptorBase<_Digraph> {
312
  class ReverseDigraphBase : public DigraphAdaptorBase<_Digraph> {
161 313
  public:
... ...
@@ -164,3 +316,3 @@
164 316
  protected:
165
    RevDigraphAdaptorBase() : Parent() { }
317
    ReverseDigraphBase() : Parent() { }
166 318
  public:
... ...
@@ -178,2 +330,4 @@
178 330

	
331
    Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
332

	
179 333
    typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
... ...
@@ -186,3 +340,2 @@
186 340
    
187

	
188 341
  ///\ingroup graph_adaptors
... ...
@@ -191,48 +344,11 @@
191 344
  ///
192
  /// If \c g is defined as
193
  ///\code
194
  /// ListDigraph dg;
195
  ///\endcode
196
  /// then
197
  ///\code
198
  /// RevDigraphAdaptor<ListDigraph> dga(dg);
199
  ///\endcode
200
  /// implements the digraph obtained from \c dg by 
201
  /// reversing the orientation of its arcs.
345
  /// ReverseDigraph reverses the arcs in the adapted digraph. The
346
  /// SubDigraph is conform to the \ref concepts::Digraph
347
  /// "Digraph concept".
202 348
  ///
203
  /// A good example of using RevDigraphAdaptor is to decide whether
204
  /// the directed graph is strongly connected or not. The digraph is
205
  /// strongly connected iff each node is reachable from one node and
206
  /// this node is reachable from the others. Instead of this
207
  /// condition we use a slightly different, from one node each node
208
  /// is reachable both in the digraph and the reversed digraph. Now
209
  /// this condition can be checked with the Dfs algorithm and the
210
  /// RevDigraphAdaptor class.
211
  ///
212
  /// The implementation:
213
  ///\code
214
  /// bool stronglyConnected(const Digraph& digraph) {
215
  ///   if (NodeIt(digraph) == INVALID) return true;
216
  ///   Dfs<Digraph> dfs(digraph);
217
  ///   dfs.run(NodeIt(digraph));
218
  ///   for (NodeIt it(digraph); it != INVALID; ++it) {
219
  ///     if (!dfs.reached(it)) {
220
  ///       return false;
221
  ///     }
222
  ///   }
223
  ///   typedef RevDigraphAdaptor<const Digraph> RDigraph;
224
  ///   RDigraph rdigraph(digraph);
225
  ///   DfsVisit<RDigraph> rdfs(rdigraph);
226
  ///   rdfs.run(NodeIt(digraph));
227
  ///   for (NodeIt it(digraph); it != INVALID; ++it) {
228
  ///     if (!rdfs.reached(it)) {
229
  ///       return false;
230
  ///     }
231
  ///   }
232
  ///   return true;
233
  /// }
234
  ///\endcode
349
  /// \tparam _Digraph It must be conform to the \ref concepts::Digraph
350
  /// "Digraph concept". The type can be specified to be const.
235 351
  template<typename _Digraph>
236
  class RevDigraphAdaptor : 
237
    public DigraphAdaptorExtender<RevDigraphAdaptorBase<_Digraph> > {
352
  class ReverseDigraph :
353
    public DigraphAdaptorExtender<ReverseDigraphBase<_Digraph> > {
238 354
  public:
... ...
@@ -240,5 +356,5 @@
240 356
    typedef DigraphAdaptorExtender<
241
      RevDigraphAdaptorBase<_Digraph> > Parent;
357
      ReverseDigraphBase<_Digraph> > Parent;
242 358
  protected:
243
    RevDigraphAdaptor() { }
359
    ReverseDigraph() { }
244 360
  public:
... ...
@@ -247,4 +363,4 @@
247 363
    ///
248
    /// Creates a reverse graph adaptor for the given digraph
249
    explicit RevDigraphAdaptor(Digraph& digraph) { 
364
    /// Creates a reverse digraph adaptor for the given digraph
365
    explicit ReverseDigraph(Digraph& digraph) {
250 366
      Parent::setDigraph(digraph); 
... ...
@@ -257,5 +373,4 @@
257 373
  template<typename Digraph>
258
  RevDigraphAdaptor<const Digraph>
259
  revDigraphAdaptor(const Digraph& digraph) {
260
    return RevDigraphAdaptor<const Digraph>(digraph);
374
  ReverseDigraph<const Digraph> reverseDigraph(const Digraph& digraph) {
375
    return ReverseDigraph<const Digraph>(digraph);
261 376
  }
... ...
@@ -263,4 +378,4 @@
263 378
  template <typename _Digraph, typename _NodeFilterMap, 
264
	    typename _ArcFilterMap, bool checked = true>
265
  class SubDigraphAdaptorBase : public DigraphAdaptorBase<_Digraph> {
379
            typename _ArcFilterMap, bool _checked = true>
380
  class SubDigraphBase : public DigraphAdaptorBase<_Digraph> {
266 381
  public:
... ...
@@ -270,3 +385,3 @@
270 385

	
271
    typedef SubDigraphAdaptorBase Adaptor;
386
    typedef SubDigraphBase Adaptor;
272 387
    typedef DigraphAdaptorBase<_Digraph> Parent;
... ...
@@ -275,3 +390,3 @@
275 390
    ArcFilterMap* _arc_filter;
276
    SubDigraphAdaptorBase() 
391
    SubDigraphBase()
277 392
      : Parent(), _node_filter(0), _arc_filter(0) { }
... ...
@@ -299,3 +414,4 @@
299 414
	     || !(*_node_filter)[Parent::source(i)]
300
	     || !(*_node_filter)[Parent::target(i)])) Parent::next(i); 
415
                              || !(*_node_filter)[Parent::target(i)]))
416
        Parent::next(i);
301 417
    }
... ...
@@ -305,3 +421,4 @@
305 421
      while (i != INVALID && (!(*_arc_filter)[i] 
306
	     || !(*_node_filter)[Parent::source(i)])) Parent::nextIn(i); 
422
                              || !(*_node_filter)[Parent::source(i)]))
423
        Parent::nextIn(i);
307 424
    }
... ...
@@ -311,3 +428,4 @@
311 428
      while (i != INVALID && (!(*_arc_filter)[i] 
312
	     || !(*_node_filter)[Parent::target(i)])) Parent::nextOut(i); 
429
                              || !(*_node_filter)[Parent::target(i)]))
430
        Parent::nextOut(i);
313 431
    }
... ...
@@ -323,3 +441,4 @@
323 441
	     || !(*_node_filter)[Parent::source(i)]
324
	     || !(*_node_filter)[Parent::target(i)])) Parent::next(i); 
442
                              || !(*_node_filter)[Parent::target(i)]))
443
        Parent::next(i);
325 444
    }
... ...
@@ -329,3 +448,4 @@
329 448
      while (i != INVALID && (!(*_arc_filter)[i] 
330
	     || !(*_node_filter)[Parent::source(i)])) Parent::nextIn(i); 
449
                              || !(*_node_filter)[Parent::source(i)]))
450
        Parent::nextIn(i);
331 451
    }
... ...
@@ -335,3 +455,4 @@
335 455
      while (i != INVALID && (!(*_arc_filter)[i] 
336
	     || !(*_node_filter)[Parent::target(i)])) Parent::nextOut(i); 
456
                              || !(*_node_filter)[Parent::target(i)]))
457
        Parent::nextOut(i);
337 458
    }
... ...
@@ -416,3 +537,3 @@
416 537
  template <typename _Digraph, typename _NodeFilterMap, typename _ArcFilterMap>
417
  class SubDigraphAdaptorBase<_Digraph, _NodeFilterMap, _ArcFilterMap, false> 
538
  class SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, false>
418 539
    : public DigraphAdaptorBase<_Digraph> {
... ...
@@ -423,3 +544,3 @@
423 544

	
424
    typedef SubDigraphAdaptorBase Adaptor;
545
    typedef SubDigraphBase Adaptor;
425 546
    typedef DigraphAdaptorBase<Digraph> Parent;
... ...
@@ -428,3 +549,3 @@
428 549
    ArcFilterMap* _arc_filter;
429
    SubDigraphAdaptorBase() 
550
    SubDigraphBase()
430 551
      : Parent(), _node_filter(0), _arc_filter(0) { }
... ...
@@ -560,42 +681,23 @@
560 681
  ///
561
  /// \brief A digraph adaptor for hiding nodes and arcs from a digraph.
682
  /// \brief An adaptor for hiding nodes and arcs in a digraph
562 683
  /// 
563
  /// SubDigraphAdaptor shows the digraph with filtered node-set and 
564
  /// arc-set. If the \c checked parameter is true then it filters the arc-set
565
  /// respect to the source and target.
684
  /// SubDigraph hides nodes and arcs in a digraph. A bool node map
685
  /// and a bool arc map must be specified, which define the filters
686
  /// for nodes and arcs. Just the nodes and arcs with true value are
687
  /// shown in the subdigraph. The SubDigraph is conform to the \ref
688
  /// concepts::Digraph "Digraph concept". If the \c _checked parameter
689
  /// is true, then the arcs incident to filtered nodes are also
690
  /// filtered out.
566 691
  /// 
567
  /// If the \c checked template parameter is false then the
568
  /// node-iterator cares only the filter on the node-set, and the
569
  /// arc-iterator cares only the filter on the arc-set.  Therefore
570
  /// the arc-map have to filter all arcs which's source or target is
571
  /// filtered by the node-filter.
572
  ///\code
573
  /// typedef ListDigraph Digraph;
574
  /// DIGRAPH_TYPEDEFS(Digraph);
575
  /// Digraph g;
576
  /// Node u=g.addNode(); //node of id 0
577
  /// Node v=g.addNode(); //node of id 1
578
  /// Arc a=g.addArc(u, v); //arc of id 0
579
  /// Arc f=g.addArc(v, u); //arc of id 1
580
  /// BoolNodeMap nm(g, true);
581
  /// nm.set(u, false);
582
  /// BoolArcMap am(g, true);
583
  /// am.set(a, false);
584
  /// typedef SubDigraphAdaptor<Digraph, BoolNodeMap, BoolArcMap> SubDGA;
585
  /// SubDGA ga(g, nm, am);
586
  /// for (SubDGA::NodeIt n(ga); n!=INVALID; ++n)
587
  ///   std::cout << g.id(n) << std::endl;
588
  /// for (SubDGA::ArcIt a(ga); a!=INVALID; ++a) 
589
  ///   std::cout << g.id(a) << std::endl;
590
  ///\endcode
591
  /// The output of the above code is the following.
592
  ///\code
593
  /// 1
594
  /// 1
595
  ///\endcode
596
  /// Note that \c n is of type \c SubDGA::NodeIt, but it can be converted to
597
  /// \c Digraph::Node that is why \c g.id(n) can be applied.
692
  /// \tparam _Digraph It must be conform to the \ref
693
  /// concepts::Digraph "Digraph concept". The type can be specified
694
  /// to const.
695
  /// \tparam _NodeFilterMap A bool valued node map of the the adapted digraph.
696
  /// \tparam _ArcFilterMap A bool valued arc map of the the adapted digraph.
697
  /// \tparam _checked If the parameter is false then the arc filtering
698
  /// is not checked with respect to node filter. Otherwise, each arc
699
  /// is automatically filtered, which is incident to a filtered node.
598 700
  /// 
599
  /// For other examples see also the documentation of
600
  /// NodeSubDigraphAdaptor and ArcSubDigraphAdaptor.
701
  /// \see FilterNodes
702
  /// \see FilterArcs
601 703
  template<typename _Digraph, 
... ...
@@ -603,6 +705,6 @@
603 705
	   typename _ArcFilterMap = typename _Digraph::template ArcMap<bool>, 
604
	   bool checked = true>
605
  class SubDigraphAdaptor : 
606
    public DigraphAdaptorExtender<
607
    SubDigraphAdaptorBase<_Digraph, _NodeFilterMap, _ArcFilterMap, checked> > {
706
           bool _checked = true>
707
  class SubDigraph
708
    : public DigraphAdaptorExtender<
709
      SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, _checked> > {
608 710
  public:
... ...
@@ -613,3 +715,3 @@
613 715
    typedef DigraphAdaptorExtender<
614
      SubDigraphAdaptorBase<Digraph, NodeFilterMap, ArcFilterMap, checked> >
716
      SubDigraphBase<Digraph, NodeFilterMap, ArcFilterMap, _checked> >
615 717
    Parent;
... ...
@@ -620,3 +722,3 @@
620 722
  protected:
621
    SubDigraphAdaptor() { }
723
    SubDigraph() { }
622 724
  public:
... ...
@@ -625,5 +727,5 @@
625 727
    ///
626
    /// Creates a sub-digraph-adaptor for the given digraph with
728
    /// Creates a subdigraph for the given digraph with
627 729
    /// given node and arc map filters.
628
    SubDigraphAdaptor(Digraph& digraph, NodeFilterMap& node_filter, 
730
    SubDigraph(Digraph& digraph, NodeFilterMap& node_filter,
629 731
		      ArcFilterMap& arc_filter) { 
... ...
@@ -676,10 +778,9 @@
676 778

	
677
  /// \brief Just gives back a sub-digraph-adaptor
779
  /// \brief Just gives back a subdigraph
678 780
  ///
679
  /// Just gives back a sub-digraph-adaptor
781
  /// Just gives back a subdigraph
680 782
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
681
  SubDigraphAdaptor<const Digraph, NodeFilterMap, ArcFilterMap>
682
  subDigraphAdaptor(const Digraph& digraph, 
683
		    NodeFilterMap& nfm, ArcFilterMap& afm) {
684
    return SubDigraphAdaptor<const Digraph, NodeFilterMap, ArcFilterMap>
783
  SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap>
784
  subDigraph(const Digraph& digraph, NodeFilterMap& nfm, ArcFilterMap& afm) {
785
    return SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap>
685 786
      (digraph, nfm, afm);
... ...
@@ -688,6 +789,6 @@
688 789
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
689
  SubDigraphAdaptor<const Digraph, const NodeFilterMap, ArcFilterMap>
690
  subDigraphAdaptor(const Digraph& digraph, 
691
                   NodeFilterMap& nfm, ArcFilterMap& afm) {
692
    return SubDigraphAdaptor<const Digraph, const NodeFilterMap, ArcFilterMap>
790
  SubDigraph<const Digraph, const NodeFilterMap, ArcFilterMap>
791
  subDigraph(const Digraph& digraph,
792
             const NodeFilterMap& nfm, ArcFilterMap& afm) {
793
    return SubDigraph<const Digraph, const NodeFilterMap, ArcFilterMap>
693 794
      (digraph, nfm, afm);
... ...
@@ -696,6 +797,6 @@
696 797
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
697
  SubDigraphAdaptor<const Digraph, NodeFilterMap, const ArcFilterMap>
698
  subDigraphAdaptor(const Digraph& digraph, 
699
                   NodeFilterMap& nfm, ArcFilterMap& afm) {
700
    return SubDigraphAdaptor<const Digraph, NodeFilterMap, const ArcFilterMap>
798
  SubDigraph<const Digraph, NodeFilterMap, const ArcFilterMap>
799
  subDigraph(const Digraph& digraph,
800
             NodeFilterMap& nfm, const ArcFilterMap& afm) {
801
    return SubDigraph<const Digraph, NodeFilterMap, const ArcFilterMap>
701 802
      (digraph, nfm, afm);
... ...
@@ -704,11 +805,427 @@
704 805
  template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap>
705
  SubDigraphAdaptor<const Digraph, const NodeFilterMap, const ArcFilterMap>
706
  subDigraphAdaptor(const Digraph& digraph, 
707
                   NodeFilterMap& nfm, ArcFilterMap& afm) {
708
    return SubDigraphAdaptor<const Digraph, const NodeFilterMap, 
806
  SubDigraph<const Digraph, const NodeFilterMap, const ArcFilterMap>
807
  subDigraph(const Digraph& digraph,
808
             const NodeFilterMap& nfm, const ArcFilterMap& afm) {
809
    return SubDigraph<const Digraph, const NodeFilterMap,
709 810
      const ArcFilterMap>(digraph, nfm, afm);
710

	
711
  }
712

	
713

	
811
  }
812

	
813

	
814
  template <typename _Graph, typename NodeFilterMap,
815
            typename EdgeFilterMap, bool _checked = true>
816
  class SubGraphBase : public GraphAdaptorBase<_Graph> {
817
  public:
818
    typedef _Graph Graph;
819
    typedef SubGraphBase Adaptor;
820
    typedef GraphAdaptorBase<_Graph> Parent;
821
  protected:
822

	
823
    NodeFilterMap* _node_filter_map;
824
    EdgeFilterMap* _edge_filter_map;
825

	
826
    SubGraphBase()
827
      : Parent(), _node_filter_map(0), _edge_filter_map(0) { }
828

	
829
    void setNodeFilterMap(NodeFilterMap& node_filter_map) {
830
      _node_filter_map=&node_filter_map;
831
    }
832
    void setEdgeFilterMap(EdgeFilterMap& edge_filter_map) {
833
      _edge_filter_map=&edge_filter_map;
834
    }
835

	
836
  public:
837

	
838
    typedef typename Parent::Node Node;
839
    typedef typename Parent::Arc Arc;
840
    typedef typename Parent::Edge Edge;
841

	
842
    void first(Node& i) const {
843
      Parent::first(i);
844
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i);
845
    }
846

	
847
    void first(Arc& i) const {
848
      Parent::first(i);
849
      while (i!=INVALID && (!(*_edge_filter_map)[i]
850
                            || !(*_node_filter_map)[Parent::source(i)]
851
                            || !(*_node_filter_map)[Parent::target(i)]))
852
        Parent::next(i);
853
    }
854

	
855
    void first(Edge& i) const {
856
      Parent::first(i);
857
      while (i!=INVALID && (!(*_edge_filter_map)[i]
858
                            || !(*_node_filter_map)[Parent::u(i)]
859
                            || !(*_node_filter_map)[Parent::v(i)]))
860
        Parent::next(i);
861
    }
862

	
863
    void firstIn(Arc& i, const Node& n) const {
864
      Parent::firstIn(i, n);
865
      while (i!=INVALID && (!(*_edge_filter_map)[i]
866
                            || !(*_node_filter_map)[Parent::source(i)]))
867
        Parent::nextIn(i);
868
    }
869

	
870
    void firstOut(Arc& i, const Node& n) const {
871
      Parent::firstOut(i, n);
872
      while (i!=INVALID && (!(*_edge_filter_map)[i]
873
                            || !(*_node_filter_map)[Parent::target(i)]))
874
        Parent::nextOut(i);
875
    }
876

	
877
    void firstInc(Edge& i, bool& d, const Node& n) const {
878
      Parent::firstInc(i, d, n);
879
      while (i!=INVALID && (!(*_edge_filter_map)[i]
880
                            || !(*_node_filter_map)[Parent::u(i)]
881
                            || !(*_node_filter_map)[Parent::v(i)]))
882
        Parent::nextInc(i, d);
883
    }
884

	
885
    void next(Node& i) const {
886
      Parent::next(i);
887
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i);
888
    }
889

	
890
    void next(Arc& i) const {
891
      Parent::next(i);
892
      while (i!=INVALID && (!(*_edge_filter_map)[i]
893
                            || !(*_node_filter_map)[Parent::source(i)]
894
                            || !(*_node_filter_map)[Parent::target(i)]))
895
        Parent::next(i);
896
    }
897

	
898
    void next(Edge& i) const {
899
      Parent::next(i);
900
      while (i!=INVALID && (!(*_edge_filter_map)[i]
901
                            || !(*_node_filter_map)[Parent::u(i)]
902
                            || !(*_node_filter_map)[Parent::v(i)]))
903
        Parent::next(i);
904
    }
905

	
906
    void nextIn(Arc& i) const {
907
      Parent::nextIn(i);
908
      while (i!=INVALID && (!(*_edge_filter_map)[i]
909
                            || !(*_node_filter_map)[Parent::source(i)]))
910
        Parent::nextIn(i);
911
    }
912

	
913
    void nextOut(Arc& i) const {
914
      Parent::nextOut(i);
915
      while (i!=INVALID && (!(*_edge_filter_map)[i]
916
                            || !(*_node_filter_map)[Parent::target(i)]))
917
        Parent::nextOut(i);
918
    }
919

	
920
    void nextInc(Edge& i, bool& d) const {
921
      Parent::nextInc(i, d);
922
      while (i!=INVALID && (!(*_edge_filter_map)[i]
923
                            || !(*_node_filter_map)[Parent::u(i)]
924
                            || !(*_node_filter_map)[Parent::v(i)]))
925
        Parent::nextInc(i, d);
926
    }
927

	
928
    void hide(const Node& n) const { _node_filter_map->set(n, false); }
929
    void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
930

	
931
    void unHide(const Node& n) const { _node_filter_map->set(n, true); }
932
    void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
933

	
934
    bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
935
    bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
936

	
937
    typedef False NodeNumTag;
938
    typedef False EdgeNumTag;
939

	
940
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
941
    Arc findArc(const Node& u, const Node& v,
942
                const Arc& prev = INVALID) {
943
      if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
944
        return INVALID;
945
      }
946
      Arc arc = Parent::findArc(u, v, prev);
947
      while (arc != INVALID && !(*_edge_filter_map)[arc]) {
948
        arc = Parent::findArc(u, v, arc);
949
      }
950
      return arc;
951
    }
952
    Edge findEdge(const Node& u, const Node& v,
953
                  const Edge& prev = INVALID) {
954
      if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
955
        return INVALID;
956
      }
957
      Edge edge = Parent::findEdge(u, v, prev);
958
      while (edge != INVALID && !(*_edge_filter_map)[edge]) {
959
        edge = Parent::findEdge(u, v, edge);
960
      }
961
      return edge;
962
    }
963

	
964
    template <typename _Value>
965
    class NodeMap : public SubMapExtender<Adaptor,
966
      typename Parent::template NodeMap<_Value> > {
967
    public:
968
      typedef _Value Value;
969
      typedef SubMapExtender<Adaptor, typename Parent::
970
                             template NodeMap<Value> > MapParent;
971

	
972
      NodeMap(const Adaptor& adaptor)
973
        : MapParent(adaptor) {}
974
      NodeMap(const Adaptor& adaptor, const Value& value)
975
        : MapParent(adaptor, value) {}
976

	
977
    private:
978
      NodeMap& operator=(const NodeMap& cmap) {
979
        return operator=<NodeMap>(cmap);
980
      }
981

	
982
      template <typename CMap>
983
      NodeMap& operator=(const CMap& cmap) {
984
        MapParent::operator=(cmap);
985
        return *this;
986
      }
987
    };
988

	
989
    template <typename _Value>
990
    class ArcMap : public SubMapExtender<Adaptor,
991
      typename Parent::template ArcMap<_Value> > {
992
    public:
993
      typedef _Value Value;
994
      typedef SubMapExtender<Adaptor, typename Parent::
995
                             template ArcMap<Value> > MapParent;
996

	
997
      ArcMap(const Adaptor& adaptor)
998
        : MapParent(adaptor) {}
999
      ArcMap(const Adaptor& adaptor, const Value& value)
1000
        : MapParent(adaptor, value) {}
1001

	
1002
    private:
1003
      ArcMap& operator=(const ArcMap& cmap) {
1004
        return operator=<ArcMap>(cmap);
1005
      }
1006

	
1007
      template <typename CMap>
1008
      ArcMap& operator=(const CMap& cmap) {
1009
        MapParent::operator=(cmap);
1010
        return *this;
1011
      }
1012
    };
1013

	
1014
    template <typename _Value>
1015
    class EdgeMap : public SubMapExtender<Adaptor,
1016
      typename Parent::template EdgeMap<_Value> > {
1017
    public:
1018
      typedef _Value Value;
1019
      typedef SubMapExtender<Adaptor, typename Parent::
1020
                             template EdgeMap<Value> > MapParent;
1021

	
1022
      EdgeMap(const Adaptor& adaptor)
1023
        : MapParent(adaptor) {}
1024

	
1025
      EdgeMap(const Adaptor& adaptor, const Value& value)
1026
        : MapParent(adaptor, value) {}
1027

	
1028
    private:
1029
      EdgeMap& operator=(const EdgeMap& cmap) {
1030
        return operator=<EdgeMap>(cmap);
1031
      }
1032

	
1033
      template <typename CMap>
1034
      EdgeMap& operator=(const CMap& cmap) {
1035
        MapParent::operator=(cmap);
1036
        return *this;
1037
      }
1038
    };
1039

	
1040
  };
1041

	
1042
  template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap>
1043
  class SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap, false>
1044
    : public GraphAdaptorBase<_Graph> {
1045
  public:
1046
    typedef _Graph Graph;
1047
    typedef SubGraphBase Adaptor;
1048
    typedef GraphAdaptorBase<_Graph> Parent;
1049
  protected:
1050
    NodeFilterMap* _node_filter_map;
1051
    EdgeFilterMap* _edge_filter_map;
1052
    SubGraphBase() : Parent(),
1053
                     _node_filter_map(0), _edge_filter_map(0) { }
1054

	
1055
    void setNodeFilterMap(NodeFilterMap& node_filter_map) {
1056
      _node_filter_map=&node_filter_map;
1057
    }
1058
    void setEdgeFilterMap(EdgeFilterMap& edge_filter_map) {
1059
      _edge_filter_map=&edge_filter_map;
1060
    }
1061

	
1062
  public:
1063

	
1064
    typedef typename Parent::Node Node;
1065
    typedef typename Parent::Arc Arc;
1066
    typedef typename Parent::Edge Edge;
1067

	
1068
    void first(Node& i) const {
1069
      Parent::first(i);
1070
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i);
1071
    }
1072

	
1073
    void first(Arc& i) const {
1074
      Parent::first(i);
1075
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i);
1076
    }
1077

	
1078
    void first(Edge& i) const {
1079
      Parent::first(i);
1080
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i);
1081
    }
1082

	
1083
    void firstIn(Arc& i, const Node& n) const {
1084
      Parent::firstIn(i, n);
1085
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextIn(i);
1086
    }
1087

	
1088
    void firstOut(Arc& i, const Node& n) const {
1089
      Parent::firstOut(i, n);
1090
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextOut(i);
1091
    }
1092

	
1093
    void firstInc(Edge& i, bool& d, const Node& n) const {
1094
      Parent::firstInc(i, d, n);
1095
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d);
1096
    }
1097

	
1098
    void next(Node& i) const {
1099
      Parent::next(i);
1100
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i);
1101
    }
1102
    void next(Arc& i) const {
1103
      Parent::next(i);
1104
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i);
1105
    }
1106
    void next(Edge& i) const {
1107
      Parent::next(i);
1108
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i);
1109
    }
1110
    void nextIn(Arc& i) const {
1111
      Parent::nextIn(i);
1112
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextIn(i);
1113
    }
1114

	
1115
    void nextOut(Arc& i) const {
1116
      Parent::nextOut(i);
1117
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextOut(i);
1118
    }
1119
    void nextInc(Edge& i, bool& d) const {
1120
      Parent::nextInc(i, d);
1121
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d);
1122
    }
1123

	
1124
    void hide(const Node& n) const { _node_filter_map->set(n, false); }
1125
    void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
1126

	
1127
    void unHide(const Node& n) const { _node_filter_map->set(n, true); }
1128
    void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
1129

	
1130
    bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
1131
    bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
1132

	
1133
    typedef False NodeNumTag;
1134
    typedef False EdgeNumTag;
1135

	
1136
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
1137
    Arc findArc(const Node& u, const Node& v,
1138
                const Arc& prev = INVALID) {
1139
      Arc arc = Parent::findArc(u, v, prev);
1140
      while (arc != INVALID && !(*_edge_filter_map)[arc]) {
1141
        arc = Parent::findArc(u, v, arc);
1142
      }
1143
      return arc;
1144
    }
1145
    Edge findEdge(const Node& u, const Node& v,
1146
                  const Edge& prev = INVALID) {
1147
      Edge edge = Parent::findEdge(u, v, prev);
1148
      while (edge != INVALID && !(*_edge_filter_map)[edge]) {
1149
        edge = Parent::findEdge(u, v, edge);
1150
      }
1151
      return edge;
1152
    }
1153

	
1154
    template <typename _Value>
1155
    class NodeMap : public SubMapExtender<Adaptor,
1156
      typename Parent::template NodeMap<_Value> > {
1157
    public:
1158
      typedef _Value Value;
1159
      typedef SubMapExtender<Adaptor, typename Parent::
1160
                             template NodeMap<Value> > MapParent;
1161

	
1162
      NodeMap(const Adaptor& adaptor)
1163
        : MapParent(adaptor) {}
1164
      NodeMap(const Adaptor& adaptor, const Value& value)
1165
        : MapParent(adaptor, value) {}
1166

	
1167
    private:
1168
      NodeMap& operator=(const NodeMap& cmap) {
1169
        return operator=<NodeMap>(cmap);
1170
      }
1171

	
1172
      template <typename CMap>
1173
      NodeMap& operator=(const CMap& cmap) {
1174
        MapParent::operator=(cmap);
1175
        return *this;
1176
      }
1177
    };
1178

	
1179
    template <typename _Value>
1180
    class ArcMap : public SubMapExtender<Adaptor,
1181
      typename Parent::template ArcMap<_Value> > {
1182
    public:
1183
      typedef _Value Value;
1184
      typedef SubMapExtender<Adaptor, typename Parent::
1185
                             template ArcMap<Value> > MapParent;
1186

	
1187
      ArcMap(const Adaptor& adaptor)
1188
        : MapParent(adaptor) {}
1189
      ArcMap(const Adaptor& adaptor, const Value& value)
1190
        : MapParent(adaptor, value) {}
1191

	
1192
    private:
1193
      ArcMap& operator=(const ArcMap& cmap) {
1194
        return operator=<ArcMap>(cmap);
1195
      }
1196

	
1197
      template <typename CMap>
1198
      ArcMap& operator=(const CMap& cmap) {
1199
        MapParent::operator=(cmap);
1200
        return *this;
1201
      }
1202
    };
1203

	
1204
    template <typename _Value>
1205
    class EdgeMap : public SubMapExtender<Adaptor,
1206
      typename Parent::template EdgeMap<_Value> > {
1207
    public:
1208
      typedef _Value Value;
1209
      typedef SubMapExtender<Adaptor, typename Parent::
1210
                             template EdgeMap<Value> > MapParent;
1211

	
1212
      EdgeMap(const Adaptor& adaptor)
1213
        : MapParent(adaptor) {}
1214

	
1215
      EdgeMap(const Adaptor& adaptor, const _Value& value)
1216
        : MapParent(adaptor, value) {}
1217

	
1218
    private:
1219
      EdgeMap& operator=(const EdgeMap& cmap) {
1220
        return operator=<EdgeMap>(cmap);
1221
      }
1222

	
1223
      template <typename CMap>
1224
      EdgeMap& operator=(const CMap& cmap) {
1225
        MapParent::operator=(cmap);
1226
        return *this;
1227
      }
1228
    };
1229

	
1230
  };
714 1231

	
... ...
@@ -716,33 +1233,39 @@
716 1233
  ///
717
  ///\brief An adaptor for hiding nodes from a digraph.
1234
  /// \brief A graph adaptor for hiding nodes and edges in an
1235
  /// undirected graph.
718 1236
  ///
719
  ///An adaptor for hiding nodes from a digraph.  This adaptor
720
  ///specializes SubDigraphAdaptor in the way that only the node-set
721
  ///can be filtered. In usual case the checked parameter is true, we
722
  ///get the induced subgraph. But if the checked parameter is false
723
  ///then we can filter only isolated nodes.
724
  template<typename _Digraph, 
725
	   typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, 
726
	   bool checked = true>
727
  class NodeSubDigraphAdaptor : 
728
    public SubDigraphAdaptor<_Digraph, _NodeFilterMap, 
729
			     ConstMap<typename _Digraph::Arc, bool>, checked> {
1237
  /// SubGraph hides nodes and edges in a graph. A bool node map and a
1238
  /// bool edge map must be specified, which define the filters for
1239
  /// nodes and edges. Just the nodes and edges with true value are
1240
  /// shown in the subgraph. The SubGraph is conform to the \ref
1241
  /// concepts::Graph "Graph concept". If the \c _checked parameter is
1242
  /// true, then the edges incident to filtered nodes are also
1243
  /// filtered out.
1244
  ///
1245
  /// \tparam _Graph It must be conform to the \ref
1246
  /// concepts::Graph "Graph concept". The type can be specified
1247
  /// to const.
1248
  /// \tparam _NodeFilterMap A bool valued node map of the the adapted graph.
1249
  /// \tparam _EdgeFilterMap A bool valued edge map of the the adapted graph.
1250
  /// \tparam _checked If the parameter is false then the edge filtering
1251
  /// is not checked with respect to node filter. Otherwise, each edge
1252
  /// is automatically filtered, which is incident to a filtered node.
1253
  ///
1254
  /// \see FilterNodes
1255
  /// \see FilterEdges
1256
  template<typename _Graph, typename NodeFilterMap,
1257
           typename EdgeFilterMap, bool _checked = true>
1258
  class SubGraph
1259
    : public GraphAdaptorExtender<
1260
      SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap, _checked> > {
730 1261
  public:
731

	
732
    typedef _Digraph Digraph;
733
    typedef _NodeFilterMap NodeFilterMap;
734

	
735
    typedef SubDigraphAdaptor<Digraph, NodeFilterMap, 
736
			      ConstMap<typename Digraph::Arc, bool>, checked> 
737
    Parent;
1262
    typedef _Graph Graph;
1263
    typedef GraphAdaptorExtender<
1264
      SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent;
738 1265

	
739 1266
    typedef typename Parent::Node Node;
1267
    typedef typename Parent::Edge Edge;
740 1268

	
741 1269
  protected:
742
    ConstMap<typename Digraph::Arc, bool> const_true_map;
743

	
744
    NodeSubDigraphAdaptor() : const_true_map(true) {
745
      Parent::setArcFilterMap(const_true_map);
746
    }
747

	
1270
    SubGraph() { }
748 1271
  public:
... ...
@@ -751,9 +1274,9 @@
751 1274
    ///
752
    /// Creates a node-sub-digraph-adaptor for the given digraph with
753
    /// given node map filter.
754
    NodeSubDigraphAdaptor(Digraph& _digraph, NodeFilterMap& node_filter) : 
755
      Parent(), const_true_map(true) { 
756
      Parent::setDigraph(_digraph);
757
      Parent::setNodeFilterMap(node_filter);
758
      Parent::setArcFilterMap(const_true_map);
1275
    /// Creates a subgraph for the given graph with given node and
1276
    /// edge map filters.
1277
    SubGraph(Graph& _graph, NodeFilterMap& node_filter_map,
1278
             EdgeFilterMap& edge_filter_map) {
1279
      setGraph(_graph);
1280
      setNodeFilterMap(node_filter_map);
1281
      setEdgeFilterMap(edge_filter_map);
759 1282
    }
... ...
@@ -762,3 +1285,3 @@
762 1285
    ///
763
    /// This function hides \c n in the digraph, i.e. the iteration 
1286
    /// This function hides \c n in the graph, i.e. the iteration
764 1287
    /// jumps over it. This is done by simply setting the value of \c n  
... ...
@@ -767,2 +1290,9 @@
767 1290

	
1291
    /// \brief Hides the edge of the graph
1292
    ///
1293
    /// This function hides \c e in the graph, i.e. the iteration
1294
    /// jumps over it. This is done by simply setting the value of \c e
1295
    /// to be false in the corresponding edge-map.
1296
    void hide(const Edge& e) const { Parent::hide(e); }
1297

	
768 1298
    /// \brief Unhides the node of the graph
... ...
@@ -774,2 +1304,9 @@
774 1304

	
1305
    /// \brief Unhides the edge of the graph
1306
    ///
1307
    /// The value of \c e is set to be true in the edge-map which stores
1308
    /// hide information. If \c e was hidden previuosly, then it is shown
1309
    /// again
1310
    void unHide(const Edge& e) const { Parent::unHide(e); }
1311

	
775 1312
    /// \brief Returns true if \c n is hidden.
... ...
@@ -780,12 +1317,172 @@
780 1317

	
1318
    /// \brief Returns true if \c e is hidden.
1319
    ///
1320
    /// Returns true if \c e is hidden.
1321
    ///
1322
    bool hidden(const Edge& e) const { return Parent::hidden(e); }
781 1323
  };
782 1324

	
783

	
784
  /// \brief Just gives back a  node-sub-digraph adaptor
1325
  /// \brief Just gives back a subgraph
785 1326
  ///
786
  /// Just gives back a node-sub-digraph adaptor
1327
  /// Just gives back a subgraph
1328
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
1329
  SubGraph<const Graph, NodeFilterMap, ArcFilterMap>
1330
  subGraph(const Graph& graph, NodeFilterMap& nfm, ArcFilterMap& efm) {
1331
    return SubGraph<const Graph, NodeFilterMap, ArcFilterMap>(graph, nfm, efm);
1332
  }
1333

	
1334
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
1335
  SubGraph<const Graph, const NodeFilterMap, ArcFilterMap>
1336
  subGraph(const Graph& graph,
1337
           const NodeFilterMap& nfm, ArcFilterMap& efm) {
1338
    return SubGraph<const Graph, const NodeFilterMap, ArcFilterMap>
1339
      (graph, nfm, efm);
1340
  }
1341

	
1342
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
1343
  SubGraph<const Graph, NodeFilterMap, const ArcFilterMap>
1344
  subGraph(const Graph& graph,
1345
           NodeFilterMap& nfm, const ArcFilterMap& efm) {
1346
    return SubGraph<const Graph, NodeFilterMap, const ArcFilterMap>
1347
      (graph, nfm, efm);
1348
  }
1349

	
1350
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
1351
  SubGraph<const Graph, const NodeFilterMap, const ArcFilterMap>
1352
  subGraph(const Graph& graph,
1353
           const NodeFilterMap& nfm, const ArcFilterMap& efm) {
1354
    return SubGraph<const Graph, const NodeFilterMap, const ArcFilterMap>
1355
      (graph, nfm, efm);
1356
  }
1357

	
1358
  /// \ingroup graph_adaptors
1359
  ///
1360
  /// \brief An adaptor for hiding nodes from a digraph or a graph.
1361
  ///
1362
  /// FilterNodes adaptor hides nodes in a graph or a digraph. A bool
1363
  /// node map must be specified, which defines the filters for
1364
  /// nodes. Just the unfiltered nodes and the arcs or edges incident
1365
  /// to unfiltered nodes are shown in the subdigraph or subgraph. The
1366
  /// FilterNodes is conform to the \ref concepts::Digraph
1367
  /// "Digraph concept" or \ref concepts::Graph "Graph concept" depending
1368
  /// on the \c _Digraph template parameter. If the \c _checked
1369
  /// parameter is true, then the arc or edges incident to filtered nodes
1370
  /// are also filtered out.
1371
  ///
1372
  /// \tparam _Digraph It must be conform to the \ref
1373
  /// concepts::Digraph "Digraph concept" or \ref concepts::Graph
1374
  /// "Graph concept". The type can be specified to be const.
1375
  /// \tparam _NodeFilterMap A bool valued node map of the the adapted graph.
1376
  /// \tparam _checked If the parameter is false then the arc or edge
1377
  /// filtering is not checked with respect to node filter. In this
1378
  /// case just isolated nodes can be filtered out from the
1379
  /// graph.
1380
#ifdef DOXYGEN
1381
  template<typename _Digraph,
1382
           typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>,
1383
           bool _checked = true>
1384
#else
1385
  template<typename _Digraph,
1386
           typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>,
1387
           bool _checked = true,
1388
           typename Enable = void>
1389
#endif
1390
  class FilterNodes
1391
    : public SubDigraph<_Digraph, _NodeFilterMap,
1392
                        ConstMap<typename _Digraph::Arc, bool>, _checked> {
1393
  public:
1394

	
1395
    typedef _Digraph Digraph;
1396
    typedef _NodeFilterMap NodeFilterMap;
1397

	
1398
    typedef SubDigraph<Digraph, NodeFilterMap,
1399
                       ConstMap<typename Digraph::Arc, bool>, _checked>
1400
    Parent;
1401

	
1402
    typedef typename Parent::Node Node;
1403

	
1404
  protected:
1405
    ConstMap<typename Digraph::Arc, bool> const_true_map;
1406

	
1407
    FilterNodes() : const_true_map(true) {
1408
      Parent::setArcFilterMap(const_true_map);
1409
    }
1410

	
1411
  public:
1412

	
1413
    /// \brief Constructor
1414
    ///
1415
    /// Creates an adaptor for the given digraph or graph with
1416
    /// given node filter map.
1417
    FilterNodes(Digraph& _digraph, NodeFilterMap& node_filter) :
1418
      Parent(), const_true_map(true) {
1419
      Parent::setDigraph(_digraph);
1420
      Parent::setNodeFilterMap(node_filter);
1421
      Parent::setArcFilterMap(const_true_map);
1422
    }
1423

	
1424
    /// \brief Hides the node of the graph
1425
    ///
1426
    /// This function hides \c n in the digraph or graph, i.e. the iteration
1427
    /// jumps over it. This is done by simply setting the value of \c n
1428
    /// to be false in the corresponding node map.
1429
    void hide(const Node& n) const { Parent::hide(n); }
1430

	
1431
    /// \brief Unhides the node of the graph
1432
    ///
1433
    /// The value of \c n is set to be true in the node-map which stores
1434
    /// hide information. If \c n was hidden previuosly, then it is shown
1435
    /// again
1436
    void unHide(const Node& n) const { Parent::unHide(n); }
1437

	
1438
    /// \brief Returns true if \c n is hidden.
1439
    ///
1440
    /// Returns true if \c n is hidden.
1441
    ///
1442
    bool hidden(const Node& n) const { return Parent::hidden(n); }
1443

	
1444
  };
1445

	
1446
  template<typename _Graph, typename _NodeFilterMap, bool _checked>
1447
  class FilterNodes<_Graph, _NodeFilterMap, _checked,
1448
                    typename enable_if<UndirectedTagIndicator<_Graph> >::type>
1449
    : public SubGraph<_Graph, _NodeFilterMap,
1450
                      ConstMap<typename _Graph::Edge, bool>, _checked> {
1451
  public:
1452
    typedef _Graph Graph;
1453
    typedef _NodeFilterMap NodeFilterMap;
1454
    typedef SubGraph<Graph, NodeFilterMap,
1455
                     ConstMap<typename Graph::Edge, bool> > Parent;
1456

	
1457
    typedef typename Parent::Node Node;
1458
  protected:
1459
    ConstMap<typename Graph::Edge, bool> const_true_map;
1460

	
1461
    FilterNodes() : const_true_map(true) {
1462
      Parent::setEdgeFilterMap(const_true_map);
1463
    }
1464

	
1465
  public:
1466

	
1467
    FilterNodes(Graph& _graph, NodeFilterMap& node_filter_map) :
1468
      Parent(), const_true_map(true) {
1469
      Parent::setGraph(_graph);
1470
      Parent::setNodeFilterMap(node_filter_map);
1471
      Parent::setEdgeFilterMap(const_true_map);
1472
    }
1473

	
1474
    void hide(const Node& n) const { Parent::hide(n); }
1475
    void unHide(const Node& n) const { Parent::unHide(n); }
1476
    bool hidden(const Node& n) const { return Parent::hidden(n); }
1477

	
1478
  };
1479

	
1480

	
1481
  /// \brief Just gives back a FilterNodes adaptor
1482
  ///
1483
  /// Just gives back a FilterNodes adaptor
787 1484
  template<typename Digraph, typename NodeFilterMap>
788
  NodeSubDigraphAdaptor<const Digraph, NodeFilterMap>
789
  nodeSubDigraphAdaptor(const Digraph& digraph, NodeFilterMap& nfm) {
790
    return NodeSubDigraphAdaptor<const Digraph, NodeFilterMap>(digraph, nfm);
1485
  FilterNodes<const Digraph, NodeFilterMap>
1486
  filterNodes(const Digraph& digraph, NodeFilterMap& nfm) {
1487
    return FilterNodes<const Digraph, NodeFilterMap>(digraph, nfm);
791 1488
  }
... ...
@@ -793,6 +1490,5 @@
793 1490
  template<typename Digraph, typename NodeFilterMap>
794
  NodeSubDigraphAdaptor<const Digraph, const NodeFilterMap>
795
  nodeSubDigraphAdaptor(const Digraph& digraph, const NodeFilterMap& nfm) {
796
    return NodeSubDigraphAdaptor<const Digraph, const NodeFilterMap>
797
      (digraph, nfm);
1491
  FilterNodes<const Digraph, const NodeFilterMap>
1492
  filterNodes(const Digraph& digraph, const NodeFilterMap& nfm) {
1493
    return FilterNodes<const Digraph, const NodeFilterMap>(digraph, nfm);
798 1494
  }
... ...
@@ -803,129 +1499,14 @@
803 1499
  ///
804
  ///An adaptor for hiding arcs from a digraph. This adaptor
805
  ///specializes SubDigraphAdaptor in the way that only the arc-set
806
  ///can be filtered. The usefulness of this adaptor is demonstrated
807
  ///in the problem of searching a maximum number of arc-disjoint
808
  ///shortest paths between two nodes \c s and \c t. Shortest here
809
  ///means being shortest with respect to non-negative
810
  ///arc-lengths. Note that the comprehension of the presented
811
  ///solution need's some elementary knowledge from combinatorial
812
  ///optimization.
1500
  /// FilterArcs adaptor hides arcs in a digraph. A bool arc map must
1501
  /// be specified, which defines the filters for arcs. Just the
1502
  /// unfiltered arcs are shown in the subdigraph. The FilterArcs is
1503
  /// conform to the \ref concepts::Digraph "Digraph concept".
813 1504
  ///
814
  ///If a single shortest path is to be searched between \c s and \c
815
  ///t, then this can be done easily by applying the Dijkstra
816
  ///algorithm. What happens, if a maximum number of arc-disjoint
817
  ///shortest paths is to be computed. It can be proved that an arc
818
  ///can be in a shortest path if and only if it is tight with respect
819
  ///to the potential function computed by Dijkstra.  Moreover, any
820
  ///path containing only such arcs is a shortest one.  Thus we have
821
  ///to compute a maximum number of arc-disjoint paths between \c s
822
  ///and \c t in the digraph which has arc-set all the tight arcs. The
823
  ///computation will be demonstrated on the following digraph, which
824
  ///is read from the dimacs file \c sub_digraph_adaptor_demo.dim.
825
  ///The full source code is available in \ref
826
  ///sub_digraph_adaptor_demo.cc.  If you are interested in more demo
827
  ///programs, you can use \ref dim_to_dot.cc to generate .dot files
828
  ///from dimacs files.  The .dot file of the following figure was
829
  ///generated by the demo program \ref dim_to_dot.cc.
830
  ///
831
  ///\dot
832
  ///digraph lemon_dot_example {
833
  ///node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];
834
  ///n0 [ label="0 (s)" ];
835
  ///n1 [ label="1" ];
836
  ///n2 [ label="2" ];
837
  ///n3 [ label="3" ];
838
  ///n4 [ label="4" ];
839
  ///n5 [ label="5" ];
840
  ///n6 [ label="6 (t)" ];
841
  ///arc [ shape=ellipse, fontname=Helvetica, fontsize=10 ];
842
  ///n5 ->  n6 [ label="9, length:4" ];
843
  ///n4 ->  n6 [ label="8, length:2" ];
844
  ///n3 ->  n5 [ label="7, length:1" ];
845
  ///n2 ->  n5 [ label="6, length:3" ];
846
  ///n2 ->  n6 [ label="5, length:5" ];
847
  ///n2 ->  n4 [ label="4, length:2" ];
848
  ///n1 ->  n4 [ label="3, length:3" ];
849
  ///n0 ->  n3 [ label="2, length:1" ];
850
  ///n0 ->  n2 [ label="1, length:2" ];
851
  ///n0 ->  n1 [ label="0, length:3" ];
852
  ///}
853
  ///\enddot
854
  ///
855
  ///\code
856
  ///Digraph g;
857
  ///Node s, t;
858
  ///LengthMap length(g);
859
  ///
860
  ///readDimacs(std::cin, g, length, s, t);
861
  ///
862
  ///cout << "arcs with lengths (of form id, source--length->target): " << endl;
863
  ///for(ArcIt e(g); e!=INVALID; ++e) 
864
  ///  cout << g.id(e) << ", " << g.id(g.source(e)) << "--" 
865
  ///       << length[e] << "->" << g.id(g.target(e)) << endl;
866
  ///
867
  ///cout << "s: " << g.id(s) << " t: " << g.id(t) << endl;
868
  ///\endcode
869
  ///Next, the potential function is computed with Dijkstra.
870
  ///\code
871
  ///typedef Dijkstra<Digraph, LengthMap> Dijkstra;
872
  ///Dijkstra dijkstra(g, length);
873
  ///dijkstra.run(s);
874
  ///\endcode
875
  ///Next, we consrtruct a map which filters the arc-set to the tight arcs.
876
  ///\code
877
  ///typedef TightArcFilterMap<Digraph, const Dijkstra::DistMap, LengthMap> 
878
  ///  TightArcFilter;
879
  ///TightArcFilter tight_arc_filter(g, dijkstra.distMap(), length);
880
  ///
881
  ///typedef ArcSubDigraphAdaptor<Digraph, TightArcFilter> SubGA;
882
  ///SubGA ga(g, tight_arc_filter);
883
  ///\endcode
884
  ///Then, the maximum nimber of arc-disjoint \c s-\c t paths are computed 
885
  ///with a max flow algorithm Preflow.
886
  ///\code
887
  ///ConstMap<Arc, int> const_1_map(1);
888
  ///Digraph::ArcMap<int> flow(g, 0);
889
  ///
890
  ///Preflow<SubGA, ConstMap<Arc, int>, Digraph::ArcMap<int> > 
891
  ///  preflow(ga, const_1_map, s, t);
892
  ///preflow.run();
893
  ///\endcode
894
  ///Last, the output is:
895
  ///\code  
896
  ///cout << "maximum number of arc-disjoint shortest path: " 
897
  ///     << preflow.flowValue() << endl;
898
  ///cout << "arcs of the maximum number of arc-disjoint shortest s-t paths: " 
899
  ///     << endl;
900
  ///for(ArcIt e(g); e!=INVALID; ++e) 
901
  ///  if (preflow.flow(e))
902
  ///    cout << " " << g.id(g.source(e)) << "--"
903
  ///         << length[e] << "->" << g.id(g.target(e)) << endl;
904
  ///\endcode
905
  ///The program has the following (expected :-)) output:
906
  ///\code
907
  ///arcs with lengths (of form id, source--length->target):
908
  /// 9, 5--4->6
909
  /// 8, 4--2->6
910
  /// 7, 3--1->5
911
  /// 6, 2--3->5
912
  /// 5, 2--5->6
913
  /// 4, 2--2->4
914
  /// 3, 1--3->4
915
  /// 2, 0--1->3
916
  /// 1, 0--2->2
917
  /// 0, 0--3->1
918
  ///s: 0 t: 6
919
  ///maximum number of arc-disjoint shortest path: 2
920
  ///arcs of the maximum number of arc-disjoint shortest s-t paths:
921
  /// 9, 5--4->6
922
  /// 8, 4--2->6
923
  /// 7, 3--1->5
924
  /// 4, 2--2->4
925
  /// 2, 0--1->3
926
  /// 1, 0--2->2
927
  ///\endcode
1505
  /// \tparam _Digraph It must be conform to the \ref concepts::Digraph
1506
  /// "Digraph concept". The type can be specified to be const.
1507
  /// \tparam _ArcFilterMap A bool valued arc map of the the adapted
1508
  /// graph.
928 1509
  template<typename _Digraph, typename _ArcFilterMap>
929
  class ArcSubDigraphAdaptor : 
930
    public SubDigraphAdaptor<_Digraph, ConstMap<typename _Digraph::Node, bool>, 
1510
  class FilterArcs :
1511
    public SubDigraph<_Digraph, ConstMap<typename _Digraph::Node, bool>,
931 1512
			     _ArcFilterMap, false> {
... ...
@@ -935,3 +1516,3 @@
935 1516

	
936
    typedef SubDigraphAdaptor<Digraph, ConstMap<typename Digraph::Node, bool>, 
1517
    typedef SubDigraph<Digraph, ConstMap<typename Digraph::Node, bool>,
937 1518
			      ArcFilterMap, false> Parent;
... ...
@@ -943,3 +1524,3 @@
943 1524

	
944
    ArcSubDigraphAdaptor() : const_true_map(true) {
1525
    FilterArcs() : const_true_map(true) {
945 1526
      Parent::setNodeFilterMap(const_true_map);
... ...
@@ -951,5 +1532,5 @@
951 1532
    ///
952
    /// Creates a arc-sub-digraph-adaptor for the given digraph with
1533
    /// Creates a FilterArcs adaptor for the given graph with
953 1534
    /// given arc map filter.
954
    ArcSubDigraphAdaptor(Digraph& digraph, ArcFilterMap& arc_filter) 
1535
    FilterArcs(Digraph& digraph, ArcFilterMap& arc_filter)
955 1536
      : Parent(), const_true_map(true) { 
... ...
@@ -962,5 +1543,5 @@
962 1543
    ///
963
    /// This function hides \c a in the digraph, i.e. the iteration 
1544
    /// This function hides \c a in the graph, i.e. the iteration
964 1545
    /// jumps over it. This is done by simply setting the value of \c a
965
    /// to be false in the corresponding arc-map.
1546
    /// to be false in the corresponding arc map.
966 1547
    void hide(const Arc& a) const { Parent::hide(a); }
... ...
@@ -982,9 +1563,9 @@
982 1563

	
983
  /// \brief Just gives back an arc-sub-digraph adaptor
1564
  /// \brief Just gives back an FilterArcs adaptor
984 1565
  ///
985
  /// Just gives back an arc-sub-digraph adaptor
1566
  /// Just gives back an FilterArcs adaptor
986 1567
  template<typename Digraph, typename ArcFilterMap>
987
  ArcSubDigraphAdaptor<const Digraph, ArcFilterMap>
988
  arcSubDigraphAdaptor(const Digraph& digraph, ArcFilterMap& afm) {
989
    return ArcSubDigraphAdaptor<const Digraph, ArcFilterMap>(digraph, afm);
1568
  FilterArcs<const Digraph, ArcFilterMap>
1569
  filterArcs(const Digraph& digraph, ArcFilterMap& afm) {
1570
    return FilterArcs<const Digraph, ArcFilterMap>(digraph, afm);
990 1571
  }
... ...
@@ -992,6 +1573,85 @@
992 1573
  template<typename Digraph, typename ArcFilterMap>
993
  ArcSubDigraphAdaptor<const Digraph, const ArcFilterMap>
994
  arcSubDigraphAdaptor(const Digraph& digraph, const ArcFilterMap& afm) {
995
    return ArcSubDigraphAdaptor<const Digraph, const ArcFilterMap>
996
      (digraph, afm);
1574
  FilterArcs<const Digraph, const ArcFilterMap>
1575
  filterArcs(const Digraph& digraph, const ArcFilterMap& afm) {
1576
    return FilterArcs<const Digraph, const ArcFilterMap>(digraph, afm);
1577
  }
1578

	
1579
  /// \ingroup graph_adaptors
1580
  ///
1581
  /// \brief An adaptor for hiding edges from a graph.
1582
  ///
1583
  /// FilterEdges adaptor hides edges in a digraph. A bool edge map must
1584
  /// be specified, which defines the filters for edges. Just the
1585
  /// unfiltered edges are shown in the subdigraph. The FilterEdges is
1586
  /// conform to the \ref concepts::Graph "Graph concept".
1587
  ///
1588
  /// \tparam _Graph It must be conform to the \ref concepts::Graph
1589
  /// "Graph concept". The type can be specified to be const.
1590
  /// \tparam _EdgeFilterMap A bool valued edge map of the the adapted
1591
  /// graph.
1592
  template<typename _Graph, typename _EdgeFilterMap>
1593
  class FilterEdges :
1594
    public SubGraph<_Graph, ConstMap<typename _Graph::Node,bool>,
1595
                    _EdgeFilterMap, false> {
1596
  public:
1597
    typedef _Graph Graph;
1598
    typedef _EdgeFilterMap EdgeFilterMap;
1599
    typedef SubGraph<Graph, ConstMap<typename Graph::Node,bool>,
1600
                     EdgeFilterMap, false> Parent;
1601
    typedef typename Parent::Edge Edge;
1602
  protected:
1603
    ConstMap<typename Graph::Node, bool> const_true_map;
1604

	
1605
    FilterEdges() : const_true_map(true) {
1606
      Parent::setNodeFilterMap(const_true_map);
1607
    }
1608

	
1609
  public:
1610

	
1611
    /// \brief Constructor
1612
    ///
1613
    /// Creates a FilterEdges adaptor for the given graph with
1614
    /// given edge map filters.
1615
    FilterEdges(Graph& _graph, EdgeFilterMap& edge_filter_map) :
1616
      Parent(), const_true_map(true) {
1617
      Parent::setGraph(_graph);
1618
      Parent::setNodeFilterMap(const_true_map);
1619
      Parent::setEdgeFilterMap(edge_filter_map);
1620
    }
1621

	
1622
    /// \brief Hides the edge of the graph
1623
    ///
1624
    /// This function hides \c e in the graph, i.e. the iteration
1625
    /// jumps over it. This is done by simply setting the value of \c e
1626
    /// to be false in the corresponding edge-map.
1627
    void hide(const Edge& e) const { Parent::hide(e); }
1628

	
1629
    /// \brief Unhides the edge of the graph
1630
    ///
1631
    /// The value of \c e is set to be true in the edge-map which stores
1632
    /// hide information. If \c e was hidden previuosly, then it is shown
1633
    /// again
1634
    void unHide(const Edge& e) const { Parent::unHide(e); }
1635

	
1636
    /// \brief Returns true if \c e is hidden.
1637
    ///
1638
    /// Returns true if \c e is hidden.
1639
    ///
1640
    bool hidden(const Edge& e) const { return Parent::hidden(e); }
1641

	
1642
  };
1643

	
1644
  /// \brief Just gives back a FilterEdges adaptor
1645
  ///
1646
  /// Just gives back a FilterEdges adaptor
1647
  template<typename Graph, typename EdgeFilterMap>
1648
  FilterEdges<const Graph, EdgeFilterMap>
1649
  filterEdges(const Graph& graph, EdgeFilterMap& efm) {
1650
    return FilterEdges<const Graph, EdgeFilterMap>(graph, efm);
1651
  }
1652

	
1653
  template<typename Graph, typename EdgeFilterMap>
1654
  FilterEdges<const Graph, const EdgeFilterMap>
1655
  filterEdges(const Graph& graph, const EdgeFilterMap& efm) {
1656
    return FilterEdges<const Graph, const EdgeFilterMap>(graph, efm);
997 1657
  }
... ...
@@ -999,6 +1659,6 @@
999 1659
  template <typename _Digraph>
1000
  class UndirDigraphAdaptorBase { 
1660
  class UndirectorBase {
1001 1661
  public:
1002 1662
    typedef _Digraph Digraph;
1003
    typedef UndirDigraphAdaptorBase Adaptor;
1663
    typedef UndirectorBase Adaptor;
1004 1664

	
... ...
@@ -1010,3 +1670,3 @@
1010 1670
    class Arc : public Edge {
1011
      friend class UndirDigraphAdaptorBase;
1671
      friend class UndirectorBase;
1012 1672
    protected:
... ...
@@ -1371,3 +2031,3 @@
1371 2031

	
1372
    UndirDigraphAdaptorBase() : _digraph(0) {}
2032
    UndirectorBase() : _digraph(0) {}
1373 2033

	
... ...
@@ -1383,52 +2043,20 @@
1383 2043
  ///
1384
  /// \brief A graph is made from a directed digraph by an adaptor
2044
  /// \brief Undirect the graph
1385 2045
  ///
1386 2046
  /// This adaptor makes an undirected graph from a directed
1387
  /// graph. All arc of the underlying digraph will be showed in the
1388
  /// adaptor as an edge. Let's see an informal example about using
1389
  /// this adaptor.
2047
  /// graph. All arcs of the underlying digraph will be showed in the
2048
  /// adaptor as an edge. The Orienter adaptor is conform to the \ref
2049
  /// concepts::Graph "Graph concept".
1390 2050
  ///
1391
  /// There is a network of the streets of a town. Of course there are
1392
  /// some one-way street in the town hence the network is a directed
1393
  /// one. There is a crazy driver who go oppositely in the one-way
1394
  /// street without moral sense. Of course he can pass this streets
1395
  /// slower than the regular way, in fact his speed is half of the
1396
  /// normal speed. How long should he drive to get from a source
1397
  /// point to the target? Let see the example code which calculate it:
1398
  ///
1399
  /// \todo BadCode, SimpleMap does no exists
1400
  ///\code
1401
  /// typedef UndirDigraphAdaptor<Digraph> Graph;
1402
  /// Graph graph(digraph);
1403
  ///
1404
  /// typedef SimpleMap<LengthMap> FLengthMap;
1405
  /// FLengthMap flength(length);
1406
  ///
1407
  /// typedef ScaleMap<LengthMap> RLengthMap;
1408
  /// RLengthMap rlength(length, 2.0);
1409
  ///
1410
  /// typedef Graph::CombinedArcMap<FLengthMap, RLengthMap > ULengthMap;
1411
  /// ULengthMap ulength(flength, rlength);
1412
  /// 
1413
  /// Dijkstra<Graph, ULengthMap> dijkstra(graph, ulength);
1414
  /// std::cout << "Driving time : " << dijkstra.run(src, trg) << std::endl;
1415
  ///\endcode
1416
  ///
1417
  /// The combined arc map makes the length map for the undirected
1418
  /// graph. It is created from a forward and reverse map. The forward
1419
  /// map is created from the original length map with a SimpleMap
1420
  /// adaptor which just makes a read-write map from the reference map
1421
  /// i.e. it forgets that it can be return reference to values. The
1422
  /// reverse map is just the scaled original map with the ScaleMap
1423
  /// adaptor. The combination solves that passing the reverse way
1424
  /// takes double time than the original. To get the driving time we
1425
  /// run the dijkstra algorithm on the graph.
2051
  /// \tparam _Digraph It must be conform to the \ref
2052
  /// concepts::Digraph "Digraph concept". The type can be specified
2053
  /// to const.
1426 2054
  template<typename _Digraph>
1427
  class UndirDigraphAdaptor 
1428
    : public GraphAdaptorExtender<UndirDigraphAdaptorBase<_Digraph> > {
2055
  class Undirector
2056
    : public GraphAdaptorExtender<UndirectorBase<_Digraph> > {
1429 2057
  public:
1430 2058
    typedef _Digraph Digraph;
1431
    typedef GraphAdaptorExtender<UndirDigraphAdaptorBase<Digraph> > Parent;
2059
    typedef GraphAdaptorExtender<UndirectorBase<Digraph> > Parent;
1432 2060
  protected:
1433
    UndirDigraphAdaptor() { }
2061
    Undirector() { }
1434 2062
  public:
... ...
@@ -1437,5 +2065,5 @@
1437 2065
    ///
1438
    /// Constructor
1439
    UndirDigraphAdaptor(_Digraph& _digraph) { 
1440
      setDigraph(_digraph);
2066
    /// Creates a undirected graph from the given digraph
2067
    Undirector(_Digraph& digraph) {
2068
      setDigraph(digraph);
1441 2069
    }
... ...
@@ -1445,3 +2073,3 @@
1445 2073
    /// This class adapts two original digraph ArcMap to
1446
    /// get an arc map on the adaptor.
2074
    /// get an arc map on the undirected graph.
1447 2075
    template <typename _ForwardMap, typename _BackwardMap>
... ...
@@ -1461,7 +2089,2 @@
1461 2089
      /// Constructor      
1462
      CombinedArcMap() : _forward(0), _backward(0) {}
1463

	
1464
      /// \brief Constructor      
1465
      ///
1466
      /// Constructor      
1467 2090
      CombinedArcMap(ForwardMap& forward, BackwardMap& backward) 
... ...
@@ -1505,16 +2128,2 @@
1505 2128

	
1506
      /// \brief Sets the forward map
1507
      ///
1508
      /// Sets the forward map
1509
      void setForwardMap(ForwardMap& forward) {
1510
        _forward = &forward;
1511
      }
1512

	
1513
      /// \brief Sets the backward map
1514
      ///
1515
      /// Sets the backward map
1516
      void setBackwardMap(BackwardMap& backward) {
1517
        _backward = &backward;
1518
      }
1519

	
1520 2129
    protected:
... ...
@@ -1526,12 +2135,271 @@
1526 2135

	
2136
    /// \brief Just gives back a combined arc map
2137
    ///
2138
    /// Just gives back a combined arc map
2139
    template <typename ForwardMap, typename BackwardMap>
2140
    static CombinedArcMap<ForwardMap, BackwardMap>
2141
    combinedArcMap(ForwardMap& forward, BackwardMap& backward) {
2142
      return CombinedArcMap<ForwardMap, BackwardMap>(forward, backward);
2143
    }
2144

	
2145
    template <typename ForwardMap, typename BackwardMap>
2146
    static CombinedArcMap<const ForwardMap, BackwardMap>
2147
    combinedArcMap(const ForwardMap& forward, BackwardMap& backward) {
2148
      return CombinedArcMap<const ForwardMap,
2149
        BackwardMap>(forward, backward);
2150
    }
2151

	
2152
    template <typename ForwardMap, typename BackwardMap>
2153
    static CombinedArcMap<ForwardMap, const BackwardMap>
2154
    combinedArcMap(ForwardMap& forward, const BackwardMap& backward) {
2155
      return CombinedArcMap<ForwardMap,
2156
        const BackwardMap>(forward, backward);
2157
    }
2158

	
2159
    template <typename ForwardMap, typename BackwardMap>
2160
    static CombinedArcMap<const ForwardMap, const BackwardMap>
2161
    combinedArcMap(const ForwardMap& forward, const BackwardMap& backward) {
2162
      return CombinedArcMap<const ForwardMap,
2163
        const BackwardMap>(forward, backward);
2164
    }
2165

	
1527 2166
  };
1528 2167

	
1529
  /// \brief Just gives back an undir digraph adaptor
2168
  /// \brief Just gives back an undirected view of the given digraph
1530 2169
  ///
1531
  /// Just gives back an undir digraph adaptor
2170
  /// Just gives back an undirected view of the given digraph
1532 2171
  template<typename Digraph>
1533
  UndirDigraphAdaptor<const Digraph>
1534
  undirDigraphAdaptor(const Digraph& digraph) {
1535
    return UndirDigraphAdaptor<const Digraph>(digraph);
1536
  }
2172
  Undirector<const Digraph>
2173
  undirector(const Digraph& digraph) {
2174
    return Undirector<const Digraph>(digraph);
2175
  }
2176

	
2177
  template <typename _Graph, typename _DirectionMap>
2178
  class OrienterBase {
2179
  public:
2180

	
2181
    typedef _Graph Graph;
2182
    typedef _DirectionMap DirectionMap;
2183

	
2184
    typedef typename Graph::Node Node;
2185
    typedef typename Graph::Edge Arc;
2186

	
2187
    void reverseArc(const Arc& arc) {
2188
      _direction->set(arc, !(*_direction)[arc]);
2189
    }
2190

	
2191
    void first(Node& i) const { _graph->first(i); }
2192
    void first(Arc& i) const { _graph->first(i); }
2193
    void firstIn(Arc& i, const Node& n) const {
2194
      bool d;
2195
      _graph->firstInc(i, d, n);
2196
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2197
    }
2198
    void firstOut(Arc& i, const Node& n ) const {
2199
      bool d;
2200
      _graph->firstInc(i, d, n);
2201
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2202
    }
2203

	
2204
    void next(Node& i) const { _graph->next(i); }
2205
    void next(Arc& i) const { _graph->next(i); }
2206
    void nextIn(Arc& i) const {
2207
      bool d = !(*_direction)[i];
2208
      _graph->nextInc(i, d);
2209
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2210
    }
2211
    void nextOut(Arc& i) const {
2212
      bool d = (*_direction)[i];
2213
      _graph->nextInc(i, d);
2214
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2215
    }
2216

	
2217
    Node source(const Arc& e) const {
2218
      return (*_direction)[e] ? _graph->u(e) : _graph->v(e);
2219
    }
2220
    Node target(const Arc& e) const {
2221
      return (*_direction)[e] ? _graph->v(e) : _graph->u(e);
2222
    }
2223

	
2224
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
2225
    int nodeNum() const { return _graph->nodeNum(); }
2226

	
2227
    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
2228
    int arcNum() const { return _graph->edgeNum(); }
2229

	
2230
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
2231
    Arc findArc(const Node& u, const Node& v,
2232
                const Arc& prev = INVALID) {
2233
      Arc arc = prev;
2234
      bool d = arc == INVALID ? true : (*_direction)[arc];
2235
      if (d) {
2236
        arc = _graph->findEdge(u, v, arc);
2237
        while (arc != INVALID && !(*_direction)[arc]) {
2238
          _graph->findEdge(u, v, arc);
2239
        }
2240
        if (arc != INVALID) return arc;
2241
      }
2242
      _graph->findEdge(v, u, arc);
2243
      while (arc != INVALID && (*_direction)[arc]) {
2244
        _graph->findEdge(u, v, arc);
2245
      }
2246
      return arc;
2247
    }
2248

	
2249
    Node addNode() {
2250
      return Node(_graph->addNode());
2251
    }
2252

	
2253
    Arc addArc(const Node& u, const Node& v) {
2254
      Arc arc = _graph->addArc(u, v);
2255
      _direction->set(arc, _graph->source(arc) == u);
2256
      return arc;
2257
    }
2258

	
2259
    void erase(const Node& i) { _graph->erase(i); }
2260
    void erase(const Arc& i) { _graph->erase(i); }
2261

	
2262
    void clear() { _graph->clear(); }
2263

	
2264
    int id(const Node& v) const { return _graph->id(v); }
2265
    int id(const Arc& e) const { return _graph->id(e); }
2266

	
2267
    Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
2268
    Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
2269

	
2270
    int maxNodeId() const { return _graph->maxNodeId(); }
2271
    int maxArcId() const { return _graph->maxEdgeId(); }
2272

	
2273
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
2274
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
2275

	
2276
    typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier;
2277
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
2278

	
2279
    template <typename _Value>
2280
    class NodeMap : public _Graph::template NodeMap<_Value> {
2281
    public:
2282

	
2283
      typedef typename _Graph::template NodeMap<_Value> Parent;
2284

	
2285
      explicit NodeMap(const OrienterBase& adapter)
2286
        : Parent(*adapter._graph) {}
2287

	
2288
      NodeMap(const OrienterBase& adapter, const _Value& value)
2289
        : Parent(*adapter._graph, value) {}
2290

	
2291
    private:
2292
      NodeMap& operator=(const NodeMap& cmap) {
2293
        return operator=<NodeMap>(cmap);
2294
      }
2295

	
2296
      template <typename CMap>
2297
      NodeMap& operator=(const CMap& cmap) {
2298
        Parent::operator=(cmap);
2299
        return *this;
2300
      }
2301

	
2302
    };
2303

	
2304
    template <typename _Value>
2305
    class ArcMap : public _Graph::template EdgeMap<_Value> {
2306
    public:
2307

	
2308
      typedef typename Graph::template EdgeMap<_Value> Parent;
2309

	
2310
      explicit ArcMap(const OrienterBase& adapter)
2311
        : Parent(*adapter._graph) { }
2312

	
2313
      ArcMap(const OrienterBase& adapter, const _Value& value)
2314
        : Parent(*adapter._graph, value) { }
2315

	
2316
    private:
2317
      ArcMap& operator=(const ArcMap& cmap) {
2318
        return operator=<ArcMap>(cmap);
2319
      }
2320

	
2321
      template <typename CMap>
2322
      ArcMap& operator=(const CMap& cmap) {
2323
        Parent::operator=(cmap);
2324
        return *this;
2325
      }
2326
    };
2327

	
2328

	
2329

	
2330
  protected:
2331
    Graph* _graph;
2332
    DirectionMap* _direction;
2333

	
2334
    void setDirectionMap(DirectionMap& direction) {
2335
      _direction = &direction;
2336
    }
2337

	
2338
    void setGraph(Graph& graph) {
2339
      _graph = &graph;
2340
    }
2341

	
2342
  };
2343

	
2344
  /// \ingroup graph_adaptors
2345
  ///
2346
  /// \brief Orients the edges of the graph to get a digraph
2347
  ///
2348
  /// This adaptor orients each edge in the undirected graph. The
2349
  /// direction of the arcs stored in an edge node map.  The arcs can
2350
  /// be easily reverted by the \c reverseArc() member function in the
2351
  /// adaptor. The Orienter adaptor is conform to the \ref
2352
  /// concepts::Digraph "Digraph concept".
2353
  ///
2354
  /// \tparam _Graph It must be conform to the \ref concepts::Graph
2355
  /// "Graph concept". The type can be specified to be const.
2356
  /// \tparam _DirectionMap A bool valued edge map of the the adapted
2357
  /// graph.
2358
  ///
2359
  /// \sa orienter
2360
  template<typename _Graph,
2361
           typename DirectionMap = typename _Graph::template EdgeMap<bool> >
2362
  class Orienter :
2363
    public DigraphAdaptorExtender<OrienterBase<_Graph, DirectionMap> > {
2364
  public:
2365
    typedef _Graph Graph;
2366
    typedef DigraphAdaptorExtender<
2367
      OrienterBase<_Graph, DirectionMap> > Parent;
2368
    typedef typename Parent::Arc Arc;
2369
  protected:
2370
    Orienter() { }
2371
  public:
2372

	
2373
    /// \brief Constructor of the adaptor
2374
    ///
2375
    /// Constructor of the adaptor
2376
    Orienter(Graph& graph, DirectionMap& direction) {
2377
      setGraph(graph);
2378
      setDirectionMap(direction);
2379
    }
2380

	
2381
    /// \brief Reverse arc
2382
    ///
2383
    /// It reverse the given arc. It simply negate the direction in the map.
2384
    void reverseArc(const Arc& a) {
2385
      Parent::reverseArc(a);
2386
    }
2387
  };
2388

	
2389
  /// \brief Just gives back a Orienter
2390
  ///
2391
  /// Just gives back a Orienter
2392
  template<typename Graph, typename DirectionMap>
2393
  Orienter<const Graph, DirectionMap>
2394
  orienter(const Graph& graph, DirectionMap& dm) {
2395
    return Orienter<const Graph, DirectionMap>(graph, dm);
2396
  }
2397

	
2398
  template<typename Graph, typename DirectionMap>
2399
  Orienter<const Graph, const DirectionMap>
2400
  orienter(const Graph& graph, const DirectionMap& dm) {
2401
    return Orienter<const Graph, const DirectionMap>(graph, dm);
2402
  }
2403

	
2404
  namespace _adaptor_bits {
1537 2405

	
... ...
@@ -1563,8 +2431,2 @@
1563 2431

	
1564
    ResForwardFilter(const Tolerance& tolerance = Tolerance()) 
1565
      : _capacity(0), _flow(0), _tolerance(tolerance)  { }
1566

	
1567
    void setCapacity(const CapacityMap& capacity) { _capacity = &capacity; }
1568
    void setFlow(const FlowMap& flow) { _flow = &flow; }
1569

	
1570 2432
    bool operator[](const typename Digraph::Arc& a) const {
... ...
@@ -1600,7 +2462,2 @@
1600 2462
      : _capacity(&capacity), _flow(&flow), _tolerance(tolerance) { }
1601
    ResBackwardFilter(const Tolerance& tolerance = Tolerance())
1602
      : _capacity(0), _flow(0), _tolerance(tolerance) { }
1603

	
1604
    void setCapacity(const CapacityMap& capacity) { _capacity = &capacity; }
1605
    void setFlow(const FlowMap& flow) { _flow = &flow; }
1606 2463

	
... ...
@@ -1611,2 +2468,3 @@
1611 2468

	
2469
  }
1612 2470
  
... ...
@@ -1618,29 +2476,23 @@
1618 2476
  ///An adaptor for composing the residual graph for directed flow and
1619
  ///circulation problems.  Let \f$ G=(V, A) \f$ be a directed digraph
1620
  ///and let \f$ F \f$ be a number type. Let moreover \f$ f,c:A\to F
1621
  ///\f$, be functions on the arc-set.
2477
  /// circulation problems.  Let \f$ G=(V, A) \f$ be a directed graph
2478
  /// and let \f$ F \f$ be a number type. Let moreover \f$ f,c:A\to F \f$,
2479
  /// be functions on the arc-set.
1622 2480
  ///
1623
  ///In the appications of ResDigraphAdaptor, \f$ f \f$ usually stands
1624
  ///for a flow and \f$ c \f$ for a capacity function.  Suppose that a
1625
  ///graph instance \c g of type \c ListDigraph implements \f$ G \f$.
2481
  /// Then Residual implements the digraph structure with
2482
  /// node-set \f$ V \f$ and arc-set \f$ A_{forward}\cup A_{backward} \f$,
2483
  /// where \f$ A_{forward}=\{uv : uv\in A, f(uv)<c(uv)\} \f$ and
2484
  /// \f$ A_{backward}=\{vu : uv\in A, f(uv)>0\} \f$, i.e. the so
2485
  /// called residual graph.  When we take the union
2486
  /// \f$ A_{forward}\cup A_{backward} \f$, multiplicities are counted,
2487
  /// i.e.  if an arc is in both \f$ A_{forward} \f$ and
2488
  /// \f$ A_{backward} \f$, then in the adaptor it appears in both
2489
  /// orientation.
1626 2490
  ///
1627
  ///\code 
1628
  ///  ListDigraph g;
1629
  ///\endcode 
1630
  ///
1631
  ///Then ResDigraphAdaptor implements the digraph structure with
1632
  /// node-set \f$ V \f$ and arc-set \f$ A_{forward}\cup A_{backward}
1633
  /// \f$, where \f$ A_{forward}=\{uv : uv\in A, f(uv)<c(uv)\} \f$ and
1634
  /// \f$ A_{backward}=\{vu : uv\in A, f(uv)>0\} \f$, i.e. the so
1635
  /// called residual graph.  When we take the union \f$
1636
  /// A_{forward}\cup A_{backward} \f$, multilicities are counted,
1637
  /// i.e.  if an arc is in both \f$ A_{forward} \f$ and \f$
1638
  /// A_{backward} \f$, then in the adaptor it appears twice. The
1639
  /// following code shows how such an instance can be constructed.
1640
  ///
1641
  ///\code 
1642
  ///  typedef ListDigraph Digraph; 
1643
  ///  IntArcMap f(g), c(g);
1644
  ///  ResDigraphAdaptor<Digraph, int, IntArcMap, IntArcMap> ga(g); 
1645
  ///\endcode
2491
  /// \tparam _Digraph It must be conform to the \ref concepts::Digraph
2492
  /// "Digraph concept". The type is implicitly const.
2493
  /// \tparam _CapacityMap An arc map of some numeric type, it defines
2494
  /// the capacities in the flow problem. The map is implicitly const.
2495
  /// \tparam _FlowMap An arc map of some numeric type, it defines
2496
  /// the capacities in the flow problem.
2497
  /// \tparam _Tolerance Handler for inexact computation.
1646 2498
  template<typename _Digraph, 
... ...
@@ -1649,8 +2501,11 @@
1649 2501
           typename _Tolerance = Tolerance<typename _CapacityMap::Value> >
1650
  class ResDigraphAdaptor : 
1651
    public ArcSubDigraphAdaptor< 
1652
    UndirDigraphAdaptor<const _Digraph>, 
1653
    typename UndirDigraphAdaptor<const _Digraph>::template CombinedArcMap<
1654
      ResForwardFilter<const _Digraph, _CapacityMap, _FlowMap>,  
1655
      ResBackwardFilter<const _Digraph, _CapacityMap, _FlowMap> > > {
2502
  class Residual :
2503
    public FilterArcs<
2504
    Undirector<const _Digraph>,
2505
    typename Undirector<const _Digraph>::template CombinedArcMap<
2506
      _adaptor_bits::ResForwardFilter<const _Digraph, _CapacityMap,
2507
                                      _FlowMap, _Tolerance>,
2508
      _adaptor_bits::ResBackwardFilter<const _Digraph, _CapacityMap,
2509
                                       _FlowMap, _Tolerance> > >
2510
  {
1656 2511
  public:
... ...
@@ -1663,3 +2518,3 @@
1663 2518
    typedef typename CapacityMap::Value Value;
1664
    typedef ResDigraphAdaptor Adaptor;
2519
    typedef Residual Adaptor;
1665 2520

	
... ...
@@ -1667,14 +2522,14 @@
1667 2522

	
1668
    typedef UndirDigraphAdaptor<const Digraph> UndirDigraph;
1669

	
1670
    typedef ResForwardFilter<const Digraph, CapacityMap, FlowMap> 
1671
    ForwardFilter;
1672

	
1673
    typedef ResBackwardFilter<const Digraph, CapacityMap, FlowMap> 
1674
    BackwardFilter;
1675

	
1676
    typedef typename UndirDigraph::
2523
    typedef Undirector<const Digraph> Undirected;
2524

	
2525
    typedef _adaptor_bits::ResForwardFilter<const Digraph, CapacityMap,
2526
                                            FlowMap, Tolerance> ForwardFilter;
2527

	
2528
    typedef _adaptor_bits::ResBackwardFilter<const Digraph, CapacityMap,
2529
                                             FlowMap, Tolerance> BackwardFilter;
2530

	
2531
    typedef typename Undirected::
1677 2532
    template CombinedArcMap<ForwardFilter, BackwardFilter> ArcFilter;
1678 2533

	
1679
    typedef ArcSubDigraphAdaptor<UndirDigraph, ArcFilter> Parent;
2534
    typedef FilterArcs<Undirected, ArcFilter> Parent;
1680 2535

	
... ...
@@ -1683,3 +2538,3 @@
1683 2538

	
1684
    UndirDigraph _graph;
2539
    Undirected _graph;
1685 2540
    ForwardFilter _forward_filter;
... ...
@@ -1688,14 +2543,2 @@
1688 2543

	
1689
    void setCapacityMap(const CapacityMap& capacity) {
1690
      _capacity = &capacity;
1691
      _forward_filter.setCapacity(capacity);
1692
      _backward_filter.setCapacity(capacity);
1693
    }
1694

	
1695
    void setFlowMap(FlowMap& flow) {
1696
      _flow = &flow;
1697
      _forward_filter.setFlow(flow);
1698
      _backward_filter.setFlow(flow);
1699
    }
1700

	
1701 2544
  public:
... ...
@@ -1704,5 +2547,5 @@
1704 2547
    ///
1705
    /// Constructor of the residual graph. The parameters are the digraph type,
2548
    /// Constructor of the residual graph. The parameters are the digraph,
1706 2549
    /// the flow map, the capacity map and a tolerance object.
1707
    ResDigraphAdaptor(const Digraph& digraph, const CapacityMap& capacity, 
2550
    Residual(const Digraph& digraph, const CapacityMap& capacity,
1708 2551
                    FlowMap& flow, const Tolerance& tolerance = Tolerance()) 
... ...
@@ -1722,20 +2565,20 @@
1722 2565
    /// Gives back the residual capacity of the arc.
1723
    Value rescap(const Arc& arc) const {
1724
      if (UndirDigraph::direction(arc)) {
1725
        return (*_capacity)[arc] - (*_flow)[arc]; 
2566
    Value residualCapacity(const Arc& a) const {
2567
      if (Undirected::direction(a)) {
2568
        return (*_capacity)[a] - (*_flow)[a];
1726 2569
      } else {
1727
        return (*_flow)[arc];
1728
      }
1729
    } 
1730

	
1731
    /// \brief Augment on the given arc in the residual digraph.
2570
        return (*_flow)[a];
2571
      }
2572
    }
2573

	
2574
    /// \brief Augment on the given arc in the residual graph.
1732 2575
    ///
1733
    /// Augment on the given arc in the residual digraph. It increase
2576
    /// Augment on the given arc in the residual graph. It increase
1734 2577
    /// or decrease the flow on the original arc depend on the direction
1735 2578
    /// of the residual arc.
1736
    void augment(const Arc& e, const Value& a) const {
1737
      if (UndirDigraph::direction(e)) {
1738
        _flow->set(e, (*_flow)[e] + a);
2579
    void augment(const Arc& a, const Value& v) const {
2580
      if (Undirected::direction(a)) {
2581
        _flow->set(a, (*_flow)[a] + v);
1739 2582
      } else {  
1740
        _flow->set(e, (*_flow)[e] - a);
2583
        _flow->set(a, (*_flow)[a] - v);
1741 2584
      }
... ...
@@ -1746,4 +2589,4 @@
1746 2589
    /// Returns true when the arc is same oriented as the original arc.
1747
    static bool forward(const Arc& e) {
1748
      return UndirDigraph::direction(e);
2590
    static bool forward(const Arc& a) {
2591
      return Undirected::direction(a);
1749 2592
    }
... ...
@@ -1753,4 +2596,4 @@
1753 2596
    /// Returns true when the arc is opposite oriented as the original arc.
1754
    static bool backward(const Arc& e) {
1755
      return !UndirDigraph::direction(e);
2597
    static bool backward(const Arc& a) {
2598
      return !Undirected::direction(a);
1756 2599
    }
... ...
@@ -1760,4 +2603,4 @@
1760 2603
    /// Gives back the forward oriented residual arc.
1761
    static Arc forward(const typename Digraph::Arc& e) {
1762
      return UndirDigraph::direct(e, true);
2604
    static Arc forward(const typename Digraph::Arc& a) {
2605
      return Undirected::direct(a, true);
1763 2606
    }
... ...
@@ -1767,4 +2610,4 @@
1767 2610
    /// Gives back the backward oriented residual arc.
1768
    static Arc backward(const typename Digraph::Arc& e) {
1769
      return UndirDigraph::direct(e, false);
2611
    static Arc backward(const typename Digraph::Arc& a) {
2612
      return Undirected::direct(a, false);
1770 2613
    }
... ...
@@ -1773,5 +2616,5 @@
1773 2616
    ///
1774
    /// In generic residual digraphs the residual capacity can be obtained 
2617
    /// In generic residual graph the residual capacity can be obtained
1775 2618
    /// as a map. 
1776
    class ResCap {
2619
    class ResidualCapacity {
1777 2620
    protected:
... ...
@@ -1779,9 +2622,13 @@
1779 2622
    public:
2623
      /// The Key type
1780 2624
      typedef Arc Key;
2625
      /// The Value type
1781 2626
      typedef typename _CapacityMap::Value Value;
1782 2627

	
1783
      ResCap(const Adaptor& adaptor) : _adaptor(&adaptor) {}
1784
      
1785
      Value operator[](const Arc& e) const {
1786
        return _adaptor->rescap(e);
2628
      /// Constructor
2629
      ResidualCapacity(const Adaptor& adaptor) : _adaptor(&adaptor) {}
2630

	
2631
      /// \e
2632
      Value operator[](const Arc& a) const {
2633
        return _adaptor->residualCapacity(a);
1787 2634
      }
... ...
@@ -1793,3 +2640,3 @@
1793 2640
  template <typename _Digraph>
1794
  class SplitDigraphAdaptorBase {
2641
  class SplitNodesBase {
1795 2642
  public:
... ...
@@ -1798,3 +2645,3 @@
1798 2645
    typedef DigraphAdaptorBase<const _Digraph> Parent;
1799
    typedef SplitDigraphAdaptorBase Adaptor;
2646
    typedef SplitNodesBase Adaptor;
1800 2647

	
... ...
@@ -1814,3 +2661,3 @@
1814 2661
    class Node : public DigraphNode {
1815
      friend class SplitDigraphAdaptorBase;
2662
      friend class SplitNodesBase;
1816 2663
      template <typename T> friend class NodeMapBase;
... ...
@@ -1842,3 +2689,3 @@
1842 2689
    class Arc {
1843
      friend class SplitDigraphAdaptorBase;
2690
      friend class SplitNodesBase;
1844 2691
      template <typename T> friend class ArcMapBase;
... ...
@@ -2206,3 +3053,3 @@
2206 3053

	
2207
    SplitDigraphAdaptorBase() : _digraph(0) {}
3054
    SplitNodesBase() : _digraph(0) {}
2208 3055

	
... ...
@@ -2218,12 +3065,12 @@
2218 3065
  ///
2219
  /// \brief Split digraph adaptor class
3066
  /// \brief Split the nodes of a directed graph
2220 3067
  /// 
2221
  /// This is an digraph adaptor which splits all node into an in-node
2222
  /// and an out-node. Formaly, the adaptor replaces each \f$ u \f$
2223
  /// node in the digraph with two node, \f$ u_{in} \f$ node and 
2224
  /// \f$ u_{out} \f$ node. If there is an \f$ (v, u) \f$ arc in the 
2225
  /// original digraph the new target of the arc will be \f$ u_{in} \f$ and
2226
  /// similarly the source of the original \f$ (u, v) \f$ arc will be
2227
  /// \f$ u_{out} \f$.  The adaptor will add for each node in the 
2228
  /// original digraph an additional arc which will connect 
3068
  /// The SplitNodes adaptor splits each node into an in-node and an
3069
  /// out-node. Formaly, the adaptor replaces each \f$ u \f$ node in
3070
  /// the digraph with two nodes(namely node \f$ u_{in} \f$ and node
3071
  /// \f$ u_{out} \f$). If there is a \f$ (v, u) \f$ arc in the
3072
  /// original digraph the new target of the arc will be \f$ u_{in} \f$
3073
  /// and similarly the source of the original \f$ (u, v) \f$ arc
3074
  /// will be \f$ u_{out} \f$.  The adaptor will add for each node in
3075
  /// the original digraph an additional arc which connects
2229 3076
  /// \f$ (u_{in}, u_{out}) \f$.
... ...
@@ -2232,59 +3079,13 @@
2232 3079
  /// algorithm can use directly just arc costs. In this case we should use
2233
  /// a \c SplitDigraphAdaptor and set the node cost of the digraph to the
2234
  /// bind arc in the adapted digraph.
3080
  /// a \c SplitNodes and set the node cost of the graph to the
3081
  /// bind arc in the adapted graph.
2235 3082
  /// 
2236
  /// For example a maximum flow algorithm can compute how many arc
2237
  /// disjoint paths are in the digraph. But we would like to know how
2238
  /// many node disjoint paths are in the digraph. First we have to
2239
  /// adapt the digraph with the \c SplitDigraphAdaptor. Then run the flow
2240
  /// algorithm on the adapted digraph. The bottleneck of the flow will
2241
  /// be the bind arcs which bounds the flow with the count of the
2242
  /// node disjoint paths.
2243
  ///
2244
  ///\code
2245
  ///
2246
  /// typedef SplitDigraphAdaptor<SmartDigraph> SDigraph;
2247
  ///
2248
  /// SDigraph sdigraph(digraph);
2249
  ///
2250
  /// typedef ConstMap<SDigraph::Arc, int> SCapacity;
2251
  /// SCapacity scapacity(1);
2252
  ///
2253
  /// SDigraph::ArcMap<int> sflow(sdigraph);
2254
  ///
2255
  /// Preflow<SDigraph, SCapacity> 
2256
  ///   spreflow(sdigraph, scapacity, 
2257
  ///            SDigraph::outNode(source), SDigraph::inNode(target));
2258
  ///                                            
2259
  /// spreflow.run();
2260
  ///
2261
  ///\endcode
2262
  ///
2263
  /// The result of the mamixum flow on the original digraph
2264
  /// shows the next figure:
2265
  ///
2266
  /// \image html arc_disjoint.png
2267
  /// \image latex arc_disjoint.eps "Arc disjoint paths" width=\textwidth
2268
  /// 
2269
  /// And the maximum flow on the adapted digraph:
2270
  ///
2271
  /// \image html node_disjoint.png
2272
  /// \image latex node_disjoint.eps "Node disjoint paths" width=\textwidth
2273
  ///
2274
  /// The second solution contains just 3 disjoint paths while the first 4.
2275
  /// The full code can be found in the \ref disjoint_paths_demo.cc demo file.
2276
  ///
2277
  /// This digraph adaptor is fully conform to the 
2278
  /// \ref concepts::Digraph "Digraph" concept and
2279
  /// contains some additional member functions and types. The 
2280
  /// documentation of some member functions may be found just in the
2281
  /// SplitDigraphAdaptorBase class.
2282
  ///
2283
  /// \sa SplitDigraphAdaptorBase
3083
  /// \tparam _Digraph It must be conform to the \ref concepts::Digraph
3084
  /// "Digraph concept". The type can be specified to be const.
2284 3085
  template <typename _Digraph>
2285
  class SplitDigraphAdaptor 
2286
    : public DigraphAdaptorExtender<SplitDigraphAdaptorBase<_Digraph> > {
3086
  class SplitNodes
3087
    : public DigraphAdaptorExtender<SplitNodesBase<_Digraph> > {
2287 3088
  public:
2288 3089
    typedef _Digraph Digraph;
2289
    typedef DigraphAdaptorExtender<SplitDigraphAdaptorBase<Digraph> > Parent;
3090
    typedef DigraphAdaptorExtender<SplitNodesBase<Digraph> > Parent;
2290 3091

	
... ...
@@ -2299,3 +3100,3 @@
2299 3100
    /// Constructor of the adaptor.
2300
    SplitDigraphAdaptor(Digraph& g) {
3101
    SplitNodes(Digraph& g) {
2301 3102
      Parent::setDigraph(g);
... ...
@@ -2417,5 +3218,5 @@
2417 3218

	
2418
    /// \brief Just gives back a combined node map.
3219
    /// \brief Just gives back a combined node map
2419 3220
    /// 
2420
    /// Just gives back a combined node map.
3221
    /// Just gives back a combined node map
2421 3222
    template <typename InNodeMap, typename OutNodeMap>
... ...
@@ -2445,6 +3246,6 @@
2445 3246

	
2446
    /// \brief ArcMap combined from an original ArcMap and NodeMap
3247
    /// \brief ArcMap combined from an original ArcMap and a NodeMap
2447 3248
    ///
2448
    /// This class adapt an original digraph ArcMap and NodeMap to
2449
    /// get an arc map on the adapted digraph.
3249
    /// This class adapt an original ArcMap and a NodeMap to get an
3250
    /// arc map on the adapted digraph
2450 3251
    template <typename DigraphArcMap, typename DigraphNodeMap>
... ...
@@ -2500,5 +3301,5 @@
2500 3301
                    
2501
    /// \brief Just gives back a combined arc map.
3302
    /// \brief Just gives back a combined arc map
2502 3303
    /// 
2503
    /// Just gives back a combined arc map.
3304
    /// Just gives back a combined arc map
2504 3305
    template <typename DigraphArcMap, typename DigraphNodeMap>
... ...
@@ -2533,9 +3334,9 @@
2533 3334

	
2534
  /// \brief Just gives back a split digraph adaptor
3335
  /// \brief Just gives back a node splitter
2535 3336
  ///
2536
  /// Just gives back a split digraph adaptor
3337
  /// Just gives back a node splitter
2537 3338
  template<typename Digraph>
2538
  SplitDigraphAdaptor<Digraph>
2539
  splitDigraphAdaptor(const Digraph& digraph) {
2540
    return SplitDigraphAdaptor<Digraph>(digraph);
3339
  SplitNodes<Digraph>
3340
  splitNodes(const Digraph& digraph) {
3341
    return SplitNodes<Digraph>(digraph);
2541 3342
  }
... ...
@@ -2545,3 +3346,2 @@
2545 3346

	
2546
#endif //LEMON_DIGRAPH_ADAPTOR_H
2547

	
3347
#endif //LEMON_ADAPTORS_H
1
/* -*- C++ -*-
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library
3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
... ...
@@ -26,11 +26,4 @@
26 26

	
27

	
28
///\ingroup digraphbits
29
///\file
30
///\brief Extenders for the digraph adaptor types
31 27
namespace lemon {
32 28

	
33
  /// \ingroup digraphbits
34
  ///
35
  /// \brief Extender for the DigraphAdaptors
36 29
  template <typename _Digraph>
... ...
@@ -166,5 +159,2 @@
166 159

	
167
    /// \brief Base node of the iterator
168
    ///
169
    /// Returns the base node (ie. the source in this case) of the iterator
170 160
    Node baseNode(const OutArcIt &e) const {
... ...
@@ -172,6 +162,2 @@
172 162
    }
173
    /// \brief Running node of the iterator
174
    ///
175
    /// Returns the running node (ie. the target in this case) of the
176
    /// iterator
177 163
    Node runningNode(const OutArcIt &e) const {
... ...
@@ -180,5 +166,2 @@
180 166

	
181
    /// \brief Base node of the iterator
182
    ///
183
    /// Returns the base node (ie. the target in this case) of the iterator
184 167
    Node baseNode(const InArcIt &e) const {
... ...
@@ -186,6 +169,2 @@
186 169
    }
187
    /// \brief Running node of the iterator
188
    ///
189
    /// Returns the running node (ie. the source in this case) of the
190
    /// iterator
191 170
    Node runningNode(const InArcIt &e) const {
... ...
@@ -397,5 +376,2 @@
397 376

	
398
    /// \brief Base node of the iterator
399
    ///
400
    /// Returns the base node (ie. the source in this case) of the iterator
401 377
    Node baseNode(const OutArcIt &a) const {
... ...
@@ -403,6 +379,2 @@
403 379
    }
404
    /// \brief Running node of the iterator
405
    ///
406
    /// Returns the running node (ie. the target in this case) of the
407
    /// iterator
408 380
    Node runningNode(const OutArcIt &a) const {
... ...
@@ -411,5 +383,2 @@
411 383

	
412
    /// \brief Base node of the iterator
413
    ///
414
    /// Returns the base node (ie. the target in this case) of the iterator
415 384
    Node baseNode(const InArcIt &a) const {
... ...
@@ -417,6 +386,2 @@
417 386
    }
418
    /// \brief Running node of the iterator
419
    ///
420
    /// Returns the running node (ie. the source in this case) of the
421
    /// iterator
422 387
    Node runningNode(const InArcIt &a) const {
... ...
@@ -425,5 +390,2 @@
425 390

	
426
    /// Base node of the iterator
427
    ///
428
    /// Returns the base node of the iterator
429 391
    Node baseNode(const IncEdgeIt &e) const {
... ...
@@ -431,5 +393,2 @@
431 393
    }
432
    /// Running node of the iterator
433
    ///
434
    /// Returns the running node of the iterator
435 394
    Node runningNode(const IncEdgeIt &e) const {
Show white space 2 line context
1
/* -*- C++ -*-
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library
3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
Show white space 2 line context
1
/* -*- C++ -*-
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library
3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
... ...
@@ -27,4 +27,3 @@
27 27

	
28
#include<lemon/digraph_adaptor.h>
29
#include<lemon/graph_adaptor.h>
28
#include<lemon/adaptors.h>
30 29

	
... ...
@@ -39,7 +38,7 @@
39 38

	
40
void checkRevDigraphAdaptor() {
41
  checkConcept<concepts::Digraph, RevDigraphAdaptor<concepts::Digraph> >();
39
void checkReverseDigraph() {
40
  checkConcept<concepts::Digraph, ReverseDigraph<concepts::Digraph> >();
42 41

	
43 42
  typedef ListDigraph Digraph;
44
  typedef RevDigraphAdaptor<Digraph> Adaptor;
43
  typedef ReverseDigraph<Digraph> Adaptor;
45 44

	
... ...
@@ -80,5 +79,5 @@
80 79

	
81
void checkSubDigraphAdaptor() {
80
void checkSubDigraph() {
82 81
  checkConcept<concepts::Digraph, 
83
    SubDigraphAdaptor<concepts::Digraph, 
82
    SubDigraph<concepts::Digraph,
84 83
    concepts::Digraph::NodeMap<bool>,
... ...
@@ -89,3 +88,3 @@
89 88
  typedef Digraph::ArcMap<bool> ArcFilter;
90
  typedef SubDigraphAdaptor<Digraph, NodeFilter, ArcFilter> Adaptor;
89
  typedef SubDigraph<Digraph, NodeFilter, ArcFilter> Adaptor;
91 90

	
... ...
@@ -177,5 +176,5 @@
177 176

	
178
void checkNodeSubDigraphAdaptor() {
177
void checkFilterNodes1() {
179 178
  checkConcept<concepts::Digraph, 
180
    NodeSubDigraphAdaptor<concepts::Digraph, 
179
    FilterNodes<concepts::Digraph,
181 180
      concepts::Digraph::NodeMap<bool> > >();
... ...
@@ -184,3 +183,3 @@
184 183
  typedef Digraph::NodeMap<bool> NodeFilter;
185
  typedef NodeSubDigraphAdaptor<Digraph, NodeFilter> Adaptor;
184
  typedef FilterNodes<Digraph, NodeFilter> Adaptor;
186 185

	
... ...
@@ -249,5 +248,5 @@
249 248

	
250
void checkArcSubDigraphAdaptor() {
249
void checkFilterArcs() {
251 250
  checkConcept<concepts::Digraph, 
252
    ArcSubDigraphAdaptor<concepts::Digraph, 
251
    FilterArcs<concepts::Digraph,
253 252
    concepts::Digraph::ArcMap<bool> > >();
... ...
@@ -256,3 +255,3 @@
256 255
  typedef Digraph::ArcMap<bool> ArcFilter;
257
  typedef ArcSubDigraphAdaptor<Digraph, ArcFilter> Adaptor;
256
  typedef FilterArcs<Digraph, ArcFilter> Adaptor;
258 257

	
... ...
@@ -323,7 +322,7 @@
323 322

	
324
void checkUndirDigraphAdaptor() {
325
  checkConcept<concepts::Graph, UndirDigraphAdaptor<concepts::Digraph> >();
323
void checkUndirector() {
324
  checkConcept<concepts::Graph, Undirector<concepts::Digraph> >();
326 325

	
327 326
  typedef ListDigraph Digraph;
328
  typedef UndirDigraphAdaptor<Digraph> Adaptor;
327
  typedef Undirector<Digraph> Adaptor;
329 328

	
... ...
@@ -373,5 +372,5 @@
373 372

	
374
void checkResDigraphAdaptor() {
373
void checkResidual() {
375 374
  checkConcept<concepts::Digraph, 
376
    ResDigraphAdaptor<concepts::Digraph, 
375
    Residual<concepts::Digraph,
377 376
    concepts::Digraph::ArcMap<int>, 
... ...
@@ -381,3 +380,3 @@
381 380
  typedef Digraph::ArcMap<int> IntArcMap;
382
  typedef ResDigraphAdaptor<Digraph, IntArcMap> Adaptor;
381
  typedef Residual<Digraph, IntArcMap> Adaptor;
383 382

	
... ...
@@ -482,3 +481,4 @@
482 481
    for (Path<Adaptor>::ArcIt a(p); a != INVALID; ++a) {
483
      if (adaptor.rescap(a) < min) min = adaptor.rescap(a);
482
      if (adaptor.residualCapacity(a) < min)
483
        min = adaptor.residualCapacity(a);
484 484
    }
... ...
@@ -495,7 +495,7 @@
495 495

	
496
void checkSplitDigraphAdaptor() {
497
  checkConcept<concepts::Digraph, SplitDigraphAdaptor<concepts::Digraph> >();
496
void checkSplitNodes() {
497
  checkConcept<concepts::Digraph, SplitNodes<concepts::Digraph> >();
498 498

	
499 499
  typedef ListDigraph Digraph;
500
  typedef SplitDigraphAdaptor<Digraph> Adaptor;
500
  typedef SplitNodes<Digraph> Adaptor;
501 501

	
... ...
@@ -551,5 +551,5 @@
551 551

	
552
void checkSubGraphAdaptor() {
552
void checkSubGraph() {
553 553
  checkConcept<concepts::Graph, 
554
    SubGraphAdaptor<concepts::Graph, 
554
    SubGraph<concepts::Graph,
555 555
    concepts::Graph::NodeMap<bool>,
... ...
@@ -560,3 +560,3 @@
560 560
  typedef Graph::EdgeMap<bool> EdgeFilter;
561
  typedef SubGraphAdaptor<Graph, NodeFilter, EdgeFilter> Adaptor;
561
  typedef SubGraph<Graph, NodeFilter, EdgeFilter> Adaptor;
562 562

	
... ...
@@ -686,5 +686,5 @@
686 686

	
687
void checkNodeSubGraphAdaptor() {
687
void checkFilterNodes2() {
688 688
  checkConcept<concepts::Graph, 
689
    NodeSubGraphAdaptor<concepts::Graph, 
689
    FilterNodes<concepts::Graph,
690 690
      concepts::Graph::NodeMap<bool> > >();
... ...
@@ -693,3 +693,3 @@
693 693
  typedef Graph::NodeMap<bool> NodeFilter;
694
  typedef NodeSubGraphAdaptor<Graph, NodeFilter> Adaptor;
694
  typedef FilterNodes<Graph, NodeFilter> Adaptor;
695 695

	
... ...
@@ -785,5 +785,5 @@
785 785

	
786
void checkEdgeSubGraphAdaptor() {
786
void checkFilterEdges() {
787 787
  checkConcept<concepts::Graph, 
788
    EdgeSubGraphAdaptor<concepts::Graph, 
788
    FilterEdges<concepts::Graph,
789 789
    concepts::Graph::EdgeMap<bool> > >();
... ...
@@ -792,3 +792,3 @@
792 792
  typedef Graph::EdgeMap<bool> EdgeFilter;
793
  typedef EdgeSubGraphAdaptor<Graph, EdgeFilter> Adaptor;
793
  typedef FilterEdges<Graph, EdgeFilter> Adaptor;
794 794

	
... ...
@@ -887,5 +887,5 @@
887 887

	
888
void checkDirGraphAdaptor() {
888
void checkOrienter() {
889 889
  checkConcept<concepts::Digraph, 
890
    DirGraphAdaptor<concepts::Graph, concepts::Graph::EdgeMap<bool> > >();
890
    Orienter<concepts::Graph, concepts::Graph::EdgeMap<bool> > >();
891 891

	
... ...
@@ -893,3 +893,3 @@
893 893
  typedef ListGraph::EdgeMap<bool> DirMap;
894
  typedef DirGraphAdaptor<Graph> Adaptor;
894
  typedef Orienter<Graph> Adaptor;
895 895

	
... ...
@@ -969,14 +969,14 @@
969 969

	
970
  checkRevDigraphAdaptor();
971
  checkSubDigraphAdaptor();
972
  checkNodeSubDigraphAdaptor();
973
  checkArcSubDigraphAdaptor();
974
  checkUndirDigraphAdaptor();
975
  checkResDigraphAdaptor();
976
  checkSplitDigraphAdaptor();
970
  checkReverseDigraph();
971
  checkSubDigraph();
972
  checkFilterNodes1();
973
  checkFilterArcs();
974
  checkUndirector();
975
  checkResidual();
976
  checkSplitNodes();
977 977

	
978
  checkSubGraphAdaptor();
979
  checkNodeSubGraphAdaptor();
980
  checkEdgeSubGraphAdaptor();
981
  checkDirGraphAdaptor();
978
  checkSubGraph();
979
  checkFilterNodes2();
980
  checkFilterEdges();
981
  checkOrienter();
982 982

	
Show white space 2 line context
1
/* -*- C++ -*-
2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library
4
 *
5
 * Copyright (C) 2003-2008
6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8
 *
9
 * Permission to use, modify and distribute this software is granted
10
 * provided that this copyright notice appears in all copies. For
11
 * precise terms see the accompanying LICENSE file.
12
 *
13
 * This software is provided "AS IS" with no warranty of any kind,
14
 * express or implied, and with no claim as to its suitability for any
15
 * purpose.
16
 *
17
 */
18

	
19
#ifndef LEMON_GRAPH_ADAPTOR_H
20
#define LEMON_GRAPH_ADAPTOR_H
21

	
22
///\ingroup graph_adaptors
23
///\file
24
///\brief Several graph adaptors.
25
///
26
///This file contains several useful undirected graph adaptor classes.
27

	
28
#include <lemon/core.h>
29
#include <lemon/maps.h>
30
#include <lemon/bits/graph_adaptor_extender.h>
31

	
32
namespace lemon {
33

	
34
  template<typename _Graph>
35
  class GraphAdaptorBase {
36
  public:
37
    typedef _Graph Graph;
38
    typedef Graph ParentGraph;
39

	
40
  protected:
41
    Graph* _graph;
42

	
43
    GraphAdaptorBase() : _graph(0) {}
44

	
45
    void setGraph(Graph& graph) { _graph = &graph; }
46

	
47
  public:
48
    GraphAdaptorBase(Graph& graph) : _graph(&graph) {}
49
 
50
    typedef typename Graph::Node Node;
51
    typedef typename Graph::Arc Arc;
52
    typedef typename Graph::Edge Edge;
53
   
54
    void first(Node& i) const { _graph->first(i); }
55
    void first(Arc& i) const { _graph->first(i); }
56
    void first(Edge& i) const { _graph->first(i); }
57
    void firstIn(Arc& i, const Node& n) const { _graph->firstIn(i, n); }
58
    void firstOut(Arc& i, const Node& n ) const { _graph->firstOut(i, n); }
59
    void firstInc(Edge &i, bool &d, const Node &n) const {
60
      _graph->firstInc(i, d, n);
61
    }
62

	
63
    void next(Node& i) const { _graph->next(i); }
64
    void next(Arc& i) const { _graph->next(i); }
65
    void next(Edge& i) const { _graph->next(i); }
66
    void nextIn(Arc& i) const { _graph->nextIn(i); }
67
    void nextOut(Arc& i) const { _graph->nextOut(i); }
68
    void nextInc(Edge &i, bool &d) const { _graph->nextInc(i, d); }
69

	
70
    Node u(const Edge& e) const { return _graph->u(e); }
71
    Node v(const Edge& e) const { return _graph->v(e); }
72

	
73
    Node source(const Arc& a) const { return _graph->source(a); }
74
    Node target(const Arc& a) const { return _graph->target(a); }
75

	
76
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
77
    int nodeNum() const { return _graph->nodeNum(); }
78
    
79
    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
80
    int arcNum() const { return _graph->arcNum(); }
81
    int edgeNum() const { return _graph->edgeNum(); }
82

	
83
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
84
    Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
85
      return _graph->findArc(u, v, prev);
86
    }
87
    Edge findEdge(const Node& u, const Node& v, const Edge& prev = INVALID) {
88
      return _graph->findEdge(u, v, prev);
89
    }
90
  
91
    Node addNode() { return _graph->addNode(); }
92
    Edge addEdge(const Node& u, const Node& v) { return _graph->addEdge(u, v); }
93

	
94
    void erase(const Node& i) { _graph->erase(i); }
95
    void erase(const Edge& i) { _graph->erase(i); }
96
  
97
    void clear() { _graph->clear(); }
98
    
99
    bool direction(const Arc& a) const { return _graph->direction(a); }
100
    Arc direct(const Edge& e, bool d) const { return _graph->direct(e, d); }
101

	
102
    int id(const Node& v) const { return _graph->id(v); }
103
    int id(const Arc& a) const { return _graph->id(a); }
104
    int id(const Edge& e) const { return _graph->id(e); }
105

	
106
    Node nodeFromId(int ix) const { return _graph->nodeFromId(ix); }
107
    Arc arcFromId(int ix) const { return _graph->arcFromId(ix); }
108
    Edge edgeFromId(int ix) const { return _graph->edgeFromId(ix); }
109

	
110
    int maxNodeId() const { return _graph->maxNodeId(); }
111
    int maxArcId() const { return _graph->maxArcId(); }
112
    int maxEdgeId() const { return _graph->maxEdgeId(); }
113

	
114
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
115
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); } 
116

	
117
    typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier;
118
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); } 
119

	
120
    typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier;
121
    EdgeNotifier& notifier(Edge) const { return _graph->notifier(Edge()); } 
122

	
123
    template <typename _Value>
124
    class NodeMap : public Graph::template NodeMap<_Value> {
125
    public:
126
      typedef typename Graph::template NodeMap<_Value> Parent;
127
      explicit NodeMap(const GraphAdaptorBase<Graph>& adapter) 
128
	: Parent(*adapter._graph) {}
129
      NodeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
130
	: Parent(*adapter._graph, value) {}
131

	
132
    private:
133
      NodeMap& operator=(const NodeMap& cmap) {
134
	return operator=<NodeMap>(cmap);
135
      }
136

	
137
      template <typename CMap>
138
      NodeMap& operator=(const CMap& cmap) {
139
        Parent::operator=(cmap);
140
        return *this;
141
      }
142
      
143
    };
144

	
145
    template <typename _Value>
146
    class ArcMap : public Graph::template ArcMap<_Value> {
147
    public:
148
      typedef typename Graph::template ArcMap<_Value> Parent;
149
      explicit ArcMap(const GraphAdaptorBase<Graph>& adapter) 
150
	: Parent(*adapter._graph) {}
151
      ArcMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
152
	: Parent(*adapter._graph, value) {}
153

	
154
    private:
155
      ArcMap& operator=(const ArcMap& cmap) {
156
	return operator=<ArcMap>(cmap);
157
      }
158

	
159
      template <typename CMap>
160
      ArcMap& operator=(const CMap& cmap) {
161
        Parent::operator=(cmap);
162
	return *this;
163
      }
164
    };
165

	
166
    template <typename _Value>
167
    class EdgeMap : public Graph::template EdgeMap<_Value> {
168
    public:
169
      typedef typename Graph::template EdgeMap<_Value> Parent;
170
      explicit EdgeMap(const GraphAdaptorBase<Graph>& adapter) 
171
	: Parent(*adapter._graph) {}
172
      EdgeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
173
	: Parent(*adapter._graph, value) {}
174

	
175
    private:
176
      EdgeMap& operator=(const EdgeMap& cmap) {
177
	return operator=<EdgeMap>(cmap);
178
      }
179

	
180
      template <typename CMap>
181
      EdgeMap& operator=(const CMap& cmap) {
182
        Parent::operator=(cmap);
183
        return *this;
184
      }
185
    };
186

	
187
  };
188

	
189
  template <typename _Graph, typename NodeFilterMap, 
190
	    typename EdgeFilterMap, bool checked = true>
191
  class SubGraphAdaptorBase : public GraphAdaptorBase<_Graph> {
192
  public:
193
    typedef _Graph Graph;
194
    typedef SubGraphAdaptorBase Adaptor;
195
    typedef GraphAdaptorBase<_Graph> Parent;
196
  protected:
197

	
198
    NodeFilterMap* _node_filter_map;
199
    EdgeFilterMap* _edge_filter_map;
200

	
201
    SubGraphAdaptorBase() 
202
      : Parent(), _node_filter_map(0), _edge_filter_map(0) { }
203

	
204
    void setNodeFilterMap(NodeFilterMap& node_filter_map) {
205
      _node_filter_map=&node_filter_map;
206
    }
207
    void setEdgeFilterMap(EdgeFilterMap& edge_filter_map) {
208
      _edge_filter_map=&edge_filter_map;
209
    }
210

	
211
  public:
212

	
213
    typedef typename Parent::Node Node;
214
    typedef typename Parent::Arc Arc;
215
    typedef typename Parent::Edge Edge;
216

	
217
    void first(Node& i) const { 
218
      Parent::first(i); 
219
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i); 
220
    }
221

	
222
    void first(Arc& i) const { 
223
      Parent::first(i); 
224
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
225
	     || !(*_node_filter_map)[Parent::source(i)]
226
	     || !(*_node_filter_map)[Parent::target(i)])) Parent::next(i); 
227
    }
228

	
229
    void first(Edge& i) const { 
230
      Parent::first(i); 
231
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
232
	     || !(*_node_filter_map)[Parent::u(i)]
233
	     || !(*_node_filter_map)[Parent::v(i)])) Parent::next(i); 
234
    }
235

	
236
    void firstIn(Arc& i, const Node& n) const { 
237
      Parent::firstIn(i, n); 
238
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
239
	     || !(*_node_filter_map)[Parent::source(i)])) Parent::nextIn(i); 
240
    }
241

	
242
    void firstOut(Arc& i, const Node& n) const { 
243
      Parent::firstOut(i, n); 
244
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
245
	     || !(*_node_filter_map)[Parent::target(i)])) Parent::nextOut(i); 
246
    }
247

	
248
    void firstInc(Edge& i, bool& d, const Node& n) const { 
249
      Parent::firstInc(i, d, n); 
250
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
251
            || !(*_node_filter_map)[Parent::u(i)]
252
            || !(*_node_filter_map)[Parent::v(i)])) Parent::nextInc(i, d); 
253
    }
254

	
255
    void next(Node& i) const { 
256
      Parent::next(i); 
257
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i); 
258
    }
259

	
260
    void next(Arc& i) const { 
261
      Parent::next(i); 
262
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
263
	     || !(*_node_filter_map)[Parent::source(i)]
264
	     || !(*_node_filter_map)[Parent::target(i)])) Parent::next(i); 
265
    }
266

	
267
    void next(Edge& i) const { 
268
      Parent::next(i); 
269
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
270
	     || !(*_node_filter_map)[Parent::u(i)]
271
	     || !(*_node_filter_map)[Parent::v(i)])) Parent::next(i); 
272
    }
273

	
274
    void nextIn(Arc& i) const { 
275
      Parent::nextIn(i); 
276
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
277
	     || !(*_node_filter_map)[Parent::source(i)])) Parent::nextIn(i); 
278
    }
279

	
280
    void nextOut(Arc& i) const { 
281
      Parent::nextOut(i); 
282
      while (i!=INVALID && (!(*_edge_filter_map)[i] 
283
	     || !(*_node_filter_map)[Parent::target(i)])) Parent::nextOut(i); 
284
    }
285

	
286
    void nextInc(Edge& i, bool& d) const { 
287
      Parent::nextInc(i, d); 
288
      while (i!=INVALID && (!(*_edge_filter_map)[i]
289
            || !(*_node_filter_map)[Parent::u(i)]
290
            || !(*_node_filter_map)[Parent::v(i)])) Parent::nextInc(i, d); 
291
    }
292

	
293
    void hide(const Node& n) const { _node_filter_map->set(n, false); }
294
    void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
295

	
296
    void unHide(const Node& n) const { _node_filter_map->set(n, true); }
297
    void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
298

	
299
    bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
300
    bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
301

	
302
    typedef False NodeNumTag;
303
    typedef False EdgeNumTag;
304

	
305
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
306
    Arc findArc(const Node& u, const Node& v, 
307
		  const Arc& prev = INVALID) {
308
      if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
309
        return INVALID;
310
      }
311
      Arc arc = Parent::findArc(u, v, prev);
312
      while (arc != INVALID && !(*_edge_filter_map)[arc]) {
313
        arc = Parent::findArc(u, v, arc);
314
      }
315
      return arc;
316
    }
317
    Edge findEdge(const Node& u, const Node& v, 
318
		  const Edge& prev = INVALID) {
319
      if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
320
        return INVALID;
321
      }
322
      Edge edge = Parent::findEdge(u, v, prev);
323
      while (edge != INVALID && !(*_edge_filter_map)[edge]) {
324
        edge = Parent::findEdge(u, v, edge);
325
      }
326
      return edge;
327
    }
328

	
329
    template <typename _Value>
330
    class NodeMap : public SubMapExtender<Adaptor, 
331
        typename Parent::template NodeMap<_Value> > {
332
    public:
333
      typedef _Value Value;
334
      typedef SubMapExtender<Adaptor, typename Parent::
335
                             template NodeMap<Value> > MapParent;
336
    
337
      NodeMap(const Adaptor& adaptor) 
338
	: MapParent(adaptor) {}
339
      NodeMap(const Adaptor& adaptor, const Value& value) 
340
	: MapParent(adaptor, value) {}
341

	
342
    private:
343
      NodeMap& operator=(const NodeMap& cmap) {
344
	return operator=<NodeMap>(cmap);
345
      }
346
    
347
      template <typename CMap>
348
      NodeMap& operator=(const CMap& cmap) {
349
        MapParent::operator=(cmap);
350
	return *this;
351
      }
352
    };
353

	
354
    template <typename _Value>
355
    class ArcMap : public SubMapExtender<Adaptor, 
356
	typename Parent::template ArcMap<_Value> > {
357
    public:
358
      typedef _Value Value;
359
      typedef SubMapExtender<Adaptor, typename Parent::
360
                             template ArcMap<Value> > MapParent;
361
    
362
      ArcMap(const Adaptor& adaptor) 
363
	: MapParent(adaptor) {}
364
      ArcMap(const Adaptor& adaptor, const Value& value) 
365
	: MapParent(adaptor, value) {}
366

	
367
    private:
368
      ArcMap& operator=(const ArcMap& cmap) {
369
	return operator=<ArcMap>(cmap);
370
      }
371
    
372
      template <typename CMap>
373
      ArcMap& operator=(const CMap& cmap) {
374
        MapParent::operator=(cmap);
375
	return *this;
376
      }
377
    };
378

	
379
    template <typename _Value>
380
    class EdgeMap : public SubMapExtender<Adaptor, 
381
        typename Parent::template EdgeMap<_Value> > {
382
    public:
383
      typedef _Value Value;
384
      typedef SubMapExtender<Adaptor, typename Parent::
385
                             template EdgeMap<Value> > MapParent;
386
    
387
      EdgeMap(const Adaptor& adaptor) 
388
	: MapParent(adaptor) {}
389

	
390
      EdgeMap(const Adaptor& adaptor, const Value& value) 
391
	: MapParent(adaptor, value) {}
392

	
393
    private:
394
      EdgeMap& operator=(const EdgeMap& cmap) {
395
	return operator=<EdgeMap>(cmap);
396
      }
397
    
398
      template <typename CMap>
399
      EdgeMap& operator=(const CMap& cmap) {
400
        MapParent::operator=(cmap);
401
	return *this;
402
      }
403
    };
404

	
405
  };
406

	
407
  template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap>
408
  class SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap, false> 
409
    : public GraphAdaptorBase<_Graph> {
410
  public:
411
    typedef _Graph Graph;
412
    typedef SubGraphAdaptorBase Adaptor;
413
    typedef GraphAdaptorBase<_Graph> Parent;
414
  protected:
415
    NodeFilterMap* _node_filter_map;
416
    EdgeFilterMap* _edge_filter_map;
417
    SubGraphAdaptorBase() : Parent(), 
418
			    _node_filter_map(0), _edge_filter_map(0) { }
419

	
420
    void setNodeFilterMap(NodeFilterMap& node_filter_map) {
421
      _node_filter_map=&node_filter_map;
422
    }
423
    void setEdgeFilterMap(EdgeFilterMap& edge_filter_map) {
424
      _edge_filter_map=&edge_filter_map;
425
    }
426

	
427
  public:
428

	
429
    typedef typename Parent::Node Node;
430
    typedef typename Parent::Arc Arc;
431
    typedef typename Parent::Edge Edge;
432

	
433
    void first(Node& i) const { 
434
      Parent::first(i); 
435
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i); 
436
    }
437

	
438
    void first(Arc& i) const { 
439
      Parent::first(i); 
440
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i); 
441
    }
442

	
443
    void first(Edge& i) const { 
444
      Parent::first(i); 
445
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i); 
446
    }
447

	
448
    void firstIn(Arc& i, const Node& n) const { 
449
      Parent::firstIn(i, n); 
450
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextIn(i); 
451
    }
452

	
453
    void firstOut(Arc& i, const Node& n) const { 
454
      Parent::firstOut(i, n); 
455
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextOut(i); 
456
    }
457

	
458
    void firstInc(Edge& i, bool& d, const Node& n) const { 
459
      Parent::firstInc(i, d, n); 
460
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d); 
461
    }
462

	
463
    void next(Node& i) const { 
464
      Parent::next(i); 
465
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i); 
466
    }
467
    void next(Arc& i) const { 
468
      Parent::next(i); 
469
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i); 
470
    }
471
    void next(Edge& i) const { 
472
      Parent::next(i); 
473
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i); 
474
    }
475
    void nextIn(Arc& i) const { 
476
      Parent::nextIn(i); 
477
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextIn(i); 
478
    }
479

	
480
    void nextOut(Arc& i) const { 
481
      Parent::nextOut(i); 
482
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextOut(i); 
483
    }
484
    void nextInc(Edge& i, bool& d) const { 
485
      Parent::nextInc(i, d); 
486
      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d); 
487
    }
488

	
489
    void hide(const Node& n) const { _node_filter_map->set(n, false); }
490
    void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
491

	
492
    void unHide(const Node& n) const { _node_filter_map->set(n, true); }
493
    void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
494

	
495
    bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
496
    bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
497

	
498
    typedef False NodeNumTag;
499
    typedef False EdgeNumTag;
500

	
501
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
502
    Arc findArc(const Node& u, const Node& v, 
503
		  const Arc& prev = INVALID) {
504
      Arc arc = Parent::findArc(u, v, prev);
505
      while (arc != INVALID && !(*_edge_filter_map)[arc]) {
506
        arc = Parent::findArc(u, v, arc);
507
      }
508
      return arc;
509
    }
510
    Edge findEdge(const Node& u, const Node& v, 
511
		  const Edge& prev = INVALID) {
512
      Edge edge = Parent::findEdge(u, v, prev);
513
      while (edge != INVALID && !(*_edge_filter_map)[edge]) {
514
        edge = Parent::findEdge(u, v, edge);
515
      }
516
      return edge;
517
    }
518

	
519
    template <typename _Value>
520
    class NodeMap : public SubMapExtender<Adaptor, 
521
        typename Parent::template NodeMap<_Value> > {
522
    public:
523
      typedef _Value Value;
524
      typedef SubMapExtender<Adaptor, typename Parent::
525
                             template NodeMap<Value> > MapParent;
526
    
527
      NodeMap(const Adaptor& adaptor) 
528
	: MapParent(adaptor) {}
529
      NodeMap(const Adaptor& adaptor, const Value& value) 
530
	: MapParent(adaptor, value) {}
531
    
532
    private:
533
      NodeMap& operator=(const NodeMap& cmap) {
534
	return operator=<NodeMap>(cmap);
535
      }
536
    
537
      template <typename CMap>
538
      NodeMap& operator=(const CMap& cmap) {
539
        MapParent::operator=(cmap);
540
	return *this;
541
      }
542
    };
543

	
544
    template <typename _Value>
545
    class ArcMap : public SubMapExtender<Adaptor, 
546
	typename Parent::template ArcMap<_Value> > {
547
    public:
548
      typedef _Value Value;
549
      typedef SubMapExtender<Adaptor, typename Parent::
550
                             template ArcMap<Value> > MapParent;
551
    
552
      ArcMap(const Adaptor& adaptor) 
553
	: MapParent(adaptor) {}
554
      ArcMap(const Adaptor& adaptor, const Value& value) 
555
	: MapParent(adaptor, value) {}
556

	
557
    private:
558
      ArcMap& operator=(const ArcMap& cmap) {
559
	return operator=<ArcMap>(cmap);
560
      }
561
    
562
      template <typename CMap>
563
      ArcMap& operator=(const CMap& cmap) {
564
        MapParent::operator=(cmap);
565
	return *this;
566
      }
567
    };
568

	
569
    template <typename _Value>
570
    class EdgeMap : public SubMapExtender<Adaptor, 
571
        typename Parent::template EdgeMap<_Value> > {
572
    public:
573
      typedef _Value Value;
574
      typedef SubMapExtender<Adaptor, typename Parent::
575
                             template EdgeMap<Value> > MapParent;
576
    
577
      EdgeMap(const Adaptor& adaptor) 
578
	: MapParent(adaptor) {}
579

	
580
      EdgeMap(const Adaptor& adaptor, const _Value& value) 
581
	: MapParent(adaptor, value) {}
582

	
583
    private:
584
      EdgeMap& operator=(const EdgeMap& cmap) {
585
	return operator=<EdgeMap>(cmap);
586
      }
587
    
588
      template <typename CMap>
589
      EdgeMap& operator=(const CMap& cmap) {
590
        MapParent::operator=(cmap);
591
	return *this;
592
      }
593
    };
594

	
595
  };
596

	
597
  /// \ingroup graph_adaptors
598
  ///
599
  /// \brief A graph adaptor for hiding nodes and edges from an
600
  /// undirected graph.
601
  /// 
602
  /// SubGraphAdaptor shows the graph with filtered node-set and
603
  /// edge-set. If the \c checked parameter is true then it filters
604
  /// the edge-set to do not get invalid edges which incident node is
605
  /// filtered.
606
  /// 
607
  /// If the \c checked template parameter is false then we have to
608
  /// note that the node-iterator cares only the filter on the
609
  /// node-set, and the edge-iterator cares only the filter on the
610
  /// edge-set.  This way the edge-map should filter all arcs which
611
  /// has filtered end node.
612
  template<typename _Graph, typename NodeFilterMap, 
613
	   typename EdgeFilterMap, bool checked = true>
614
  class SubGraphAdaptor : 
615
    public GraphAdaptorExtender<
616
    SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap, checked> > {
617
  public:
618
    typedef _Graph Graph;
619
    typedef GraphAdaptorExtender<
620
      SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent;
621

	
622
    typedef typename Parent::Node Node;
623
    typedef typename Parent::Edge Edge;
624

	
625
  protected:
626
    SubGraphAdaptor() { }
627
  public:
628
    
629
    /// \brief Constructor
630
    ///
631
    /// Creates a sub-graph-adaptor for the given graph with
632
    /// given node and edge map filters.
633
    SubGraphAdaptor(Graph& _graph, NodeFilterMap& node_filter_map, 
634
		    EdgeFilterMap& edge_filter_map) { 
635
      setGraph(_graph);
636
      setNodeFilterMap(node_filter_map);
637
      setEdgeFilterMap(edge_filter_map);
638
    }
639

	
640
    /// \brief Hides the node of the graph
641
    ///
642
    /// This function hides \c n in the digraph, i.e. the iteration 
643
    /// jumps over it. This is done by simply setting the value of \c n  
644
    /// to be false in the corresponding node-map.
645
    void hide(const Node& n) const { Parent::hide(n); }
646

	
647
    /// \brief Hides the edge of the graph
648
    ///
649
    /// This function hides \c e in the digraph, i.e. the iteration 
650
    /// jumps over it. This is done by simply setting the value of \c e
651
    /// to be false in the corresponding edge-map.
652
    void hide(const Edge& e) const { Parent::hide(e); }
653

	
654
    /// \brief Unhides the node of the graph
655
    ///
656
    /// The value of \c n is set to be true in the node-map which stores 
657
    /// hide information. If \c n was hidden previuosly, then it is shown 
658
    /// again
659
    void unHide(const Node& n) const { Parent::unHide(n); }
660

	
661
    /// \brief Unhides the edge of the graph
662
    ///
663
    /// The value of \c e is set to be true in the edge-map which stores 
664
    /// hide information. If \c e was hidden previuosly, then it is shown 
665
    /// again
666
    void unHide(const Edge& e) const { Parent::unHide(e); }
667

	
668
    /// \brief Returns true if \c n is hidden.
669
    ///
670
    /// Returns true if \c n is hidden.
671
    ///
672
    bool hidden(const Node& n) const { return Parent::hidden(n); }
673

	
674
    /// \brief Returns true if \c e is hidden.
675
    ///
676
    /// Returns true if \c e is hidden.
677
    ///
678
    bool hidden(const Edge& e) const { return Parent::hidden(e); }
679
  };
680

	
681
  /// \brief Just gives back a sub-graph adaptor
682
  ///
683
  /// Just gives back a sub-graph adaptor
684
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
685
  SubGraphAdaptor<const Graph, NodeFilterMap, ArcFilterMap>
686
  subGraphAdaptor(const Graph& graph, 
687
                   NodeFilterMap& nfm, ArcFilterMap& efm) {
688
    return SubGraphAdaptor<const Graph, NodeFilterMap, ArcFilterMap>
689
      (graph, nfm, efm);
690
  }
691

	
692
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
693
  SubGraphAdaptor<const Graph, const NodeFilterMap, ArcFilterMap>
694
  subGraphAdaptor(const Graph& graph, 
695
                   NodeFilterMap& nfm, ArcFilterMap& efm) {
696
    return SubGraphAdaptor<const Graph, const NodeFilterMap, ArcFilterMap>
697
      (graph, nfm, efm);
698
  }
699

	
700
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
701
  SubGraphAdaptor<const Graph, NodeFilterMap, const ArcFilterMap>
702
  subGraphAdaptor(const Graph& graph, 
703
                   NodeFilterMap& nfm, ArcFilterMap& efm) {
704
    return SubGraphAdaptor<const Graph, NodeFilterMap, const ArcFilterMap>
705
      (graph, nfm, efm);
706
  }
707

	
708
  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
709
  SubGraphAdaptor<const Graph, const NodeFilterMap, const ArcFilterMap>
710
  subGraphAdaptor(const Graph& graph, 
711
                   NodeFilterMap& nfm, ArcFilterMap& efm) {
712
    return SubGraphAdaptor<const Graph, const NodeFilterMap, 
713
      const ArcFilterMap>(graph, nfm, efm);
714
  }
715

	
716
  /// \ingroup graph_adaptors
717
  ///
718
  /// \brief An adaptor for hiding nodes from an graph.
719
  ///
720
  /// An adaptor for hiding nodes from an graph.  This
721
  /// adaptor specializes SubGraphAdaptor in the way that only the
722
  /// node-set can be filtered. In usual case the checked parameter is
723
  /// true, we get the induced subgraph. But if the checked parameter
724
  /// is false then we can filter only isolated nodes.
725
  template<typename _Graph, typename _NodeFilterMap, bool checked = true>
726
  class NodeSubGraphAdaptor : 
727
    public SubGraphAdaptor<_Graph, _NodeFilterMap, 
728
			   ConstMap<typename _Graph::Edge, bool>, checked> {
729
  public:
730
    typedef _Graph Graph;
731
    typedef _NodeFilterMap NodeFilterMap;
732
    typedef SubGraphAdaptor<Graph, NodeFilterMap, 
733
			    ConstMap<typename Graph::Edge, bool> > Parent;
734

	
735
    typedef typename Parent::Node Node;
736
  protected:
737
    ConstMap<typename Graph::Edge, bool> const_true_map;
738

	
739
    NodeSubGraphAdaptor() : const_true_map(true) {
740
      Parent::setEdgeFilterMap(const_true_map);
741
    }
742

	
743
  public:
744

	
745
    /// \brief Constructor
746
    ///
747
    /// Creates a node-sub-graph-adaptor for the given graph with
748
    /// given node map filters.
749
    NodeSubGraphAdaptor(Graph& _graph, NodeFilterMap& node_filter_map) : 
750
      Parent(), const_true_map(true) { 
751
      Parent::setGraph(_graph);
752
      Parent::setNodeFilterMap(node_filter_map);
753
      Parent::setEdgeFilterMap(const_true_map);
754
    }
755

	
756
    /// \brief Hides the node of the graph
757
    ///
758
    /// This function hides \c n in the digraph, i.e. the iteration 
759
    /// jumps over it. This is done by simply setting the value of \c n  
760
    /// to be false in the corresponding node-map.
761
    void hide(const Node& n) const { Parent::hide(n); }
762

	
763
    /// \brief Unhides the node of the graph
764
    ///
765
    /// The value of \c n is set to be true in the node-map which stores 
766
    /// hide information. If \c n was hidden previuosly, then it is shown 
767
    /// again
768
    void unHide(const Node& n) const { Parent::unHide(n); }
769

	
770
    /// \brief Returns true if \c n is hidden.
771
    ///
772
    /// Returns true if \c n is hidden.
773
    ///
774
    bool hidden(const Node& n) const { return Parent::hidden(n); }
775

	
776
  };
777

	
778
  /// \brief Just gives back a node-sub-graph adaptor
779
  ///
780
  /// Just gives back a node-sub-graph adaptor
781
  template<typename Graph, typename NodeFilterMap>
782
  NodeSubGraphAdaptor<const Graph, NodeFilterMap>
783
  nodeSubGraphAdaptor(const Graph& graph, NodeFilterMap& nfm) {
784
    return NodeSubGraphAdaptor<const Graph, NodeFilterMap>(graph, nfm);
785
  }
786

	
787
  template<typename Graph, typename NodeFilterMap>
788
  NodeSubGraphAdaptor<const Graph, const NodeFilterMap>
789
  nodeSubGraphAdaptor(const Graph& graph, const NodeFilterMap& nfm) {
790
    return NodeSubGraphAdaptor<const Graph, const NodeFilterMap>(graph, nfm);
791
  }
792

	
793
  /// \ingroup graph_adaptors
794
  ///
795
  /// \brief An adaptor for hiding edges from an graph.
796
  ///
797
  /// \warning Graph adaptors are in even more experimental state
798
  /// than the other parts of the lib. Use them at you own risk.
799
  ///
800
  /// An adaptor for hiding edges from an graph.
801
  /// This adaptor specializes SubGraphAdaptor in the way that
802
  /// only the arc-set 
803
  /// can be filtered.
804
  template<typename _Graph, typename _EdgeFilterMap>
805
  class EdgeSubGraphAdaptor : 
806
    public SubGraphAdaptor<_Graph, ConstMap<typename _Graph::Node,bool>, 
807
                           _EdgeFilterMap, false> {
808
  public:
809
    typedef _Graph Graph;
810
    typedef _EdgeFilterMap EdgeFilterMap;
811
    typedef SubGraphAdaptor<Graph, ConstMap<typename Graph::Node,bool>, 
812
			    EdgeFilterMap, false> Parent;
813
    typedef typename Parent::Edge Edge;
814
  protected:
815
    ConstMap<typename Graph::Node, bool> const_true_map;
816

	
817
    EdgeSubGraphAdaptor() : const_true_map(true) {
818
      Parent::setNodeFilterMap(const_true_map);
819
    }
820

	
821
  public:
822

	
823
    /// \brief Constructor
824
    ///
825
    /// Creates a edge-sub-graph-adaptor for the given graph with
826
    /// given node map filters.
827
    EdgeSubGraphAdaptor(Graph& _graph, EdgeFilterMap& edge_filter_map) : 
828
      Parent(), const_true_map(true) { 
829
      Parent::setGraph(_graph);
830
      Parent::setNodeFilterMap(const_true_map);
831
      Parent::setEdgeFilterMap(edge_filter_map);
832
    }
833

	
834
    /// \brief Hides the edge of the graph
835
    ///
836
    /// This function hides \c e in the digraph, i.e. the iteration 
837
    /// jumps over it. This is done by simply setting the value of \c e
838
    /// to be false in the corresponding edge-map.
839
    void hide(const Edge& e) const { Parent::hide(e); }
840

	
841
    /// \brief Unhides the edge of the graph
842
    ///
843
    /// The value of \c e is set to be true in the edge-map which stores 
844
    /// hide information. If \c e was hidden previuosly, then it is shown 
845
    /// again
846
    void unHide(const Edge& e) const { Parent::unHide(e); }
847

	
848
    /// \brief Returns true if \c e is hidden.
849
    ///
850
    /// Returns true if \c e is hidden.
851
    ///
852
    bool hidden(const Edge& e) const { return Parent::hidden(e); }
853

	
854
  };
855

	
856
  /// \brief Just gives back an edge-sub-graph adaptor
857
  ///
858
  /// Just gives back an edge-sub-graph adaptor
859
  template<typename Graph, typename EdgeFilterMap>
860
  EdgeSubGraphAdaptor<const Graph, EdgeFilterMap>
861
  edgeSubGraphAdaptor(const Graph& graph, EdgeFilterMap& efm) {
862
    return EdgeSubGraphAdaptor<const Graph, EdgeFilterMap>(graph, efm);
863
  }
864

	
865
  template<typename Graph, typename EdgeFilterMap>
866
  EdgeSubGraphAdaptor<const Graph, const EdgeFilterMap>
867
  edgeSubGraphAdaptor(const Graph& graph, const EdgeFilterMap& efm) {
868
    return EdgeSubGraphAdaptor<const Graph, const EdgeFilterMap>(graph, efm);
869
  }
870

	
871
  template <typename _Graph, typename _DirectionMap>
872
  class DirGraphAdaptorBase {
873
  public:
874
    
875
    typedef _Graph Graph;
876
    typedef _DirectionMap DirectionMap;
877

	
878
    typedef typename Graph::Node Node;
879
    typedef typename Graph::Edge Arc;
880
   
881
    /// \brief Reverse arc
882
    /// 
883
    /// It reverse the given arc. It simply negate the direction in the map.
884
    void reverseArc(const Arc& arc) {
885
      _direction->set(arc, !(*_direction)[arc]);
886
    }
887

	
888
    void first(Node& i) const { _graph->first(i); }
889
    void first(Arc& i) const { _graph->first(i); }
890
    void firstIn(Arc& i, const Node& n) const {
891
      bool d;
892
      _graph->firstInc(i, d, n);
893
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
894
    }
895
    void firstOut(Arc& i, const Node& n ) const { 
896
      bool d;
897
      _graph->firstInc(i, d, n);
898
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
899
    }
900

	
901
    void next(Node& i) const { _graph->next(i); }
902
    void next(Arc& i) const { _graph->next(i); }
903
    void nextIn(Arc& i) const {
904
      bool d = !(*_direction)[i];
905
      _graph->nextInc(i, d);
906
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
907
    }
908
    void nextOut(Arc& i) const {
909
      bool d = (*_direction)[i];
910
      _graph->nextInc(i, d);
911
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
912
    }
913

	
914
    Node source(const Arc& e) const { 
915
      return (*_direction)[e] ? _graph->u(e) : _graph->v(e); 
916
    }
917
    Node target(const Arc& e) const { 
918
      return (*_direction)[e] ? _graph->v(e) : _graph->u(e); 
919
    }
920

	
921
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
922
    int nodeNum() const { return _graph->nodeNum(); }
923
    
924
    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
925
    int arcNum() const { return _graph->edgeNum(); }
926

	
927
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
928
    Arc findArc(const Node& u, const Node& v, 
929
		  const Arc& prev = INVALID) {
930
      Arc arc = prev;
931
      bool d = arc == INVALID ? true : (*_direction)[arc];
932
      if (d) {
933
        arc = _graph->findEdge(u, v, arc);
934
        while (arc != INVALID && !(*_direction)[arc]) {
935
          _graph->findEdge(u, v, arc);
936
        }
937
        if (arc != INVALID) return arc;
938
      }
939
      _graph->findEdge(v, u, arc);
940
      while (arc != INVALID && (*_direction)[arc]) {
941
        _graph->findEdge(u, v, arc);
942
      }
943
      return arc;
944
    }
945
  
946
    Node addNode() { 
947
      return Node(_graph->addNode()); 
948
    }
949

	
950
    Arc addArc(const Node& u, const Node& v) {
951
      Arc arc = _graph->addArc(u, v);
952
      _direction->set(arc, _graph->source(arc) == u);
953
      return arc; 
954
    }
955

	
956
    void erase(const Node& i) { _graph->erase(i); }
957
    void erase(const Arc& i) { _graph->erase(i); }
958
  
959
    void clear() { _graph->clear(); }
960
    
961
    int id(const Node& v) const { return _graph->id(v); }
962
    int id(const Arc& e) const { return _graph->id(e); }
963

	
964
    Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
965
    Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
966

	
967
    int maxNodeId() const { return _graph->maxNodeId(); }
968
    int maxArcId() const { return _graph->maxEdgeId(); }
969

	
970
    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
971
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); } 
972

	
973
    typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier;
974
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); } 
975

	
976
    template <typename _Value>
977
    class NodeMap : public _Graph::template NodeMap<_Value> {
978
    public:
979

	
980
      typedef typename _Graph::template NodeMap<_Value> Parent;
981

	
982
      explicit NodeMap(const DirGraphAdaptorBase& adapter) 
983
	: Parent(*adapter._graph) {}
984

	
985
      NodeMap(const DirGraphAdaptorBase& adapter, const _Value& value)
986
	: Parent(*adapter._graph, value) {}
987

	
988
    private:
989
      NodeMap& operator=(const NodeMap& cmap) {
990
        return operator=<NodeMap>(cmap);
991
      }
992

	
993
      template <typename CMap>
994
      NodeMap& operator=(const CMap& cmap) {
995
        Parent::operator=(cmap);
996
        return *this;
997
      }
998

	
999
    };
1000

	
1001
    template <typename _Value>
1002
    class ArcMap : public _Graph::template EdgeMap<_Value> {
1003
    public:
1004

	
1005
      typedef typename Graph::template EdgeMap<_Value> Parent;
1006

	
1007
      explicit ArcMap(const DirGraphAdaptorBase& adapter) 
1008
	: Parent(*adapter._graph) { }
1009

	
1010
      ArcMap(const DirGraphAdaptorBase& adapter, const _Value& value)
1011
	: Parent(*adapter._graph, value) { }
1012

	
1013
    private:
1014
      ArcMap& operator=(const ArcMap& cmap) {
1015
        return operator=<ArcMap>(cmap);
1016
      }
1017

	
1018
      template <typename CMap>
1019
      ArcMap& operator=(const CMap& cmap) {
1020
        Parent::operator=(cmap);
1021
        return *this;
1022
      }
1023
    };
1024

	
1025
    
1026

	
1027
  protected:
1028
    Graph* _graph;
1029
    DirectionMap* _direction;
1030

	
1031
    void setDirectionMap(DirectionMap& direction) {
1032
      _direction = &direction;
1033
    }
1034

	
1035
    void setGraph(Graph& graph) {
1036
      _graph = &graph;
1037
    }
1038

	
1039
  };
1040

	
1041

	
1042
  /// \ingroup graph_adaptors
1043
  ///
1044
  /// \brief A directed graph is made from an graph by an adaptor
1045
  ///
1046
  /// This adaptor gives a direction for each edge in the undirected
1047
  /// graph. The direction of the arcs stored in the
1048
  /// DirectionMap. This map is a bool map on the edges. If
1049
  /// the edge is mapped to true then the direction of the directed
1050
  /// arc will be the same as the default direction of the edge. The
1051
  /// arcs can be easily reverted by the \ref
1052
  /// DirGraphAdaptorBase::reverseArc "reverseArc()" member in the
1053
  /// adaptor.
1054
  ///
1055
  /// It can be used to solve orientation problems on directed graphs.
1056
  /// For example how can we orient an graph to get the minimum
1057
  /// number of strongly connected components. If we orient the arcs with
1058
  /// the dfs algorithm out from the source then we will get such an 
1059
  /// orientation. 
1060
  ///
1061
  /// We use the \ref DfsVisitor "visitor" interface of the 
1062
  /// \ref DfsVisit "dfs" algorithm:
1063
  ///\code
1064
  /// template <typename DirMap>
1065
  /// class OrientVisitor : public DfsVisitor<Graph> {
1066
  /// public:
1067
  ///
1068
  ///   OrientVisitor(const Graph& graph, DirMap& dirMap)
1069
  ///     : _graph(graph), _dirMap(dirMap), _processed(graph, false) {}
1070
  ///
1071
  ///   void discover(const Arc& arc) {
1072
  ///     _processed.set(arc, true);
1073
  ///     _dirMap.set(arc, _graph.direction(arc));
1074
  ///   }
1075
  ///
1076
  ///   void examine(const Arc& arc) {
1077
  ///     if (_processed[arc]) return;
1078
  ///     _processed.set(arc, true);
1079
  ///     _dirMap.set(arc, _graph.direction(arc));
1080
  ///   }  
1081
  /// 
1082
  /// private:
1083
  ///   const Graph& _graph;  
1084
  ///   DirMap& _dirMap;
1085
  ///   Graph::EdgeMap<bool> _processed;
1086
  /// };
1087
  ///\endcode
1088
  ///
1089
  /// And now we can use the orientation:
1090
  ///\code
1091
  /// Graph::EdgeMap<bool> dmap(graph);
1092
  ///
1093
  /// typedef OrientVisitor<Graph::EdgeMap<bool> > Visitor;
1094
  /// Visitor visitor(graph, dmap);
1095
  ///
1096
  /// DfsVisit<Graph, Visitor> dfs(graph, visitor);
1097
  ///
1098
  /// dfs.run();
1099
  ///
1100
  /// typedef DirGraphAdaptor<Graph> DGraph;
1101
  /// DGraph dgraph(graph, dmap);
1102
  ///
1103
  /// LEMON_ASSERT(countStronglyConnectedComponents(dgraph) == 
1104
  ///              countBiArcConnectedComponents(graph), "Wrong Orientation");
1105
  ///\endcode
1106
  ///
1107
  /// The number of the bi-connected components is a lower bound for
1108
  /// the number of the strongly connected components in the directed
1109
  /// graph because if we contract the bi-connected components to
1110
  /// nodes we will get a tree therefore we cannot orient arcs in
1111
  /// both direction between bi-connected components. In the other way
1112
  /// the algorithm will orient one component to be strongly
1113
  /// connected. The two relations proof that the assertion will
1114
  /// be always true and the found solution is optimal.
1115
  ///
1116
  /// \sa DirGraphAdaptorBase
1117
  /// \sa dirGraphAdaptor
1118
  template<typename _Graph, 
1119
           typename DirectionMap = typename _Graph::template EdgeMap<bool> > 
1120
  class DirGraphAdaptor : 
1121
    public DigraphAdaptorExtender<DirGraphAdaptorBase<_Graph, DirectionMap> > {
1122
  public:
1123
    typedef _Graph Graph;
1124
    typedef DigraphAdaptorExtender<
1125
      DirGraphAdaptorBase<_Graph, DirectionMap> > Parent;
1126
    typedef typename Parent::Arc Arc;
1127
  protected:
1128
    DirGraphAdaptor() { }
1129
  public:
1130
    
1131
    /// \brief Constructor of the adaptor
1132
    ///
1133
    /// Constructor of the adaptor
1134
    DirGraphAdaptor(Graph& graph, DirectionMap& direction) { 
1135
      setGraph(graph);
1136
      setDirectionMap(direction);
1137
    }
1138

	
1139
    /// \brief Reverse arc
1140
    /// 
1141
    /// It reverse the given arc. It simply negate the direction in the map.
1142
    void reverseArc(const Arc& a) {
1143
      Parent::reverseArc(a);
1144
    }
1145
  };
1146

	
1147
  /// \brief Just gives back a DirGraphAdaptor
1148
  ///
1149
  /// Just gives back a DirGraphAdaptor
1150
  template<typename Graph, typename DirectionMap>
1151
  DirGraphAdaptor<const Graph, DirectionMap>
1152
  dirGraphAdaptor(const Graph& graph, DirectionMap& dm) {
1153
    return DirGraphAdaptor<const Graph, DirectionMap>(graph, dm);
1154
  }
1155

	
1156
  template<typename Graph, typename DirectionMap>
1157
  DirGraphAdaptor<const Graph, const DirectionMap>
1158
  dirGraphAdaptor(const Graph& graph, const DirectionMap& dm) {
1159
    return DirGraphAdaptor<const Graph, const DirectionMap>(graph, dm);
1160
  }
1161

	
1162
}
1163

	
1164
#endif
0 comments (0 inline)