gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Fix the usage of tags in adaptors.h (#67) There are separate tags for arcs and edges now.
0 1 0
default
1 file changed with 33 insertions and 20 deletions:
↑ Collapse diff ↑
Ignore white space 192 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

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

	
22 22
/// \ingroup graph_adaptors
23 23
/// \file
24 24
/// \brief Several graph adaptors
25 25
///
26 26
/// This file contains several useful adaptors for digraphs and graphs.
27 27

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

	
32 32
#include <lemon/bits/graph_adaptor_extender.h>
33 33
#include <lemon/tolerance.h>
34 34

	
35 35
#include <algorithm>
36 36

	
37 37
namespace lemon {
38 38

	
39 39
  template<typename _Digraph>
40 40
  class DigraphAdaptorBase {
41 41
  public:
42 42
    typedef _Digraph Digraph;
43 43
    typedef DigraphAdaptorBase Adaptor;
44 44
    typedef Digraph ParentDigraph;
45 45

	
46 46
  protected:
47 47
    Digraph* _digraph;
48 48
    DigraphAdaptorBase() : _digraph(0) { }
49 49
    void setDigraph(Digraph& digraph) { _digraph = &digraph; }
50 50

	
51 51
  public:
52 52
    DigraphAdaptorBase(Digraph& digraph) : _digraph(&digraph) { }
53 53

	
54 54
    typedef typename Digraph::Node Node;
55 55
    typedef typename Digraph::Arc Arc;
56 56

	
57 57
    void first(Node& i) const { _digraph->first(i); }
58 58
    void first(Arc& i) const { _digraph->first(i); }
59 59
    void firstIn(Arc& i, const Node& n) const { _digraph->firstIn(i, n); }
60 60
    void firstOut(Arc& i, const Node& n ) const { _digraph->firstOut(i, n); }
61 61

	
62 62
    void next(Node& i) const { _digraph->next(i); }
63 63
    void next(Arc& i) const { _digraph->next(i); }
64 64
    void nextIn(Arc& i) const { _digraph->nextIn(i); }
65 65
    void nextOut(Arc& i) const { _digraph->nextOut(i); }
66 66

	
67 67
    Node source(const Arc& a) const { return _digraph->source(a); }
68 68
    Node target(const Arc& a) const { return _digraph->target(a); }
69 69

	
70 70
    typedef NodeNumTagIndicator<Digraph> NodeNumTag;
71 71
    int nodeNum() const { return _digraph->nodeNum(); }
72 72

	
73
    typedef EdgeNumTagIndicator<Digraph> EdgeNumTag;
73
    typedef ArcNumTagIndicator<Digraph> ArcNumTag;
74 74
    int arcNum() const { return _digraph->arcNum(); }
75 75

	
76
    typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
76
    typedef FindArcTagIndicator<Digraph> FindArcTag;
77 77
    Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
78 78
      return _digraph->findArc(u, v, prev);
79 79
    }
80 80

	
81 81
    Node addNode() { return _digraph->addNode(); }
82 82
    Arc addArc(const Node& u, const Node& v) { return _digraph->addArc(u, v); }
83 83

	
84 84
    void erase(const Node& n) const { _digraph->erase(n); }
85 85
    void erase(const Arc& a) const { _digraph->erase(a); }
86 86

	
87 87
    void clear() const { _digraph->clear(); }
88 88

	
89 89
    int id(const Node& n) const { return _digraph->id(n); }
90 90
    int id(const Arc& a) const { return _digraph->id(a); }
91 91

	
92 92
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
93 93
    Arc arcFromId(int ix) const { return _digraph->arcFromId(ix); }
94 94

	
95 95
    int maxNodeId() const { return _digraph->maxNodeId(); }
96 96
    int maxArcId() const { return _digraph->maxArcId(); }
97 97

	
98 98
    typedef typename ItemSetTraits<Digraph, Node>::ItemNotifier NodeNotifier;
99 99
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
100 100

	
101 101
    typedef typename ItemSetTraits<Digraph, Arc>::ItemNotifier ArcNotifier;
102 102
    ArcNotifier& notifier(Arc) const { return _digraph->notifier(Arc()); }
103 103

	
104 104
    template <typename _Value>
105 105
    class NodeMap : public Digraph::template NodeMap<_Value> {
106 106
    public:
107 107

	
108 108
      typedef typename Digraph::template NodeMap<_Value> Parent;
109 109

	
110 110
      explicit NodeMap(const Adaptor& adaptor)
111 111
        : Parent(*adaptor._digraph) {}
112 112

	
113 113
      NodeMap(const Adaptor& adaptor, const _Value& value)
114 114
        : Parent(*adaptor._digraph, value) { }
115 115

	
116 116
    private:
117 117
      NodeMap& operator=(const NodeMap& cmap) {
118 118
        return operator=<NodeMap>(cmap);
119 119
      }
120 120

	
121 121
      template <typename CMap>
122 122
      NodeMap& operator=(const CMap& cmap) {
123 123
        Parent::operator=(cmap);
124 124
        return *this;
125 125
      }
126 126

	
127 127
    };
128 128

	
129 129
    template <typename _Value>
130 130
    class ArcMap : public Digraph::template ArcMap<_Value> {
131 131
    public:
132 132

	
133 133
      typedef typename Digraph::template ArcMap<_Value> Parent;
134 134

	
135 135
      explicit ArcMap(const Adaptor& adaptor)
136 136
        : Parent(*adaptor._digraph) {}
137 137

	
138 138
      ArcMap(const Adaptor& adaptor, const _Value& value)
139 139
        : Parent(*adaptor._digraph, value) {}
140 140

	
141 141
    private:
142 142
      ArcMap& operator=(const ArcMap& cmap) {
143 143
        return operator=<ArcMap>(cmap);
144 144
      }
145 145

	
146 146
      template <typename CMap>
147 147
      ArcMap& operator=(const CMap& cmap) {
148 148
        Parent::operator=(cmap);
149 149
        return *this;
150 150
      }
151 151

	
152 152
    };
153 153

	
154 154
  };
155 155

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

	
162 162
  protected:
163 163
    Graph* _graph;
164 164

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

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

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

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

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

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

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

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

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

	
201
    typedef ArcNumTagIndicator<Graph> ArcNumTag;
202
    int arcNum() const { return _graph->arcNum(); }
203

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

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

	
212
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
209 213
    Edge findEdge(const Node& u, const Node& v, const Edge& prev = INVALID) {
210 214
      return _graph->findEdge(u, v, prev);
211 215
    }
212 216

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

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

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

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

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

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

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

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

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

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

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

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

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

	
265 269
    };
266 270

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

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

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

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

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

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

	
309 313
  };
310 314

	
311 315
  template <typename _Digraph>
312 316
  class ReverseDigraphBase : public DigraphAdaptorBase<_Digraph> {
313 317
  public:
314 318
    typedef _Digraph Digraph;
315 319
    typedef DigraphAdaptorBase<_Digraph> Parent;
316 320
  protected:
317 321
    ReverseDigraphBase() : Parent() { }
318 322
  public:
319 323
    typedef typename Parent::Node Node;
320 324
    typedef typename Parent::Arc Arc;
321 325

	
322 326
    void firstIn(Arc& a, const Node& n) const { Parent::firstOut(a, n); }
323 327
    void firstOut(Arc& a, const Node& n ) const { Parent::firstIn(a, n); }
324 328

	
325 329
    void nextIn(Arc& a) const { Parent::nextOut(a); }
326 330
    void nextOut(Arc& a) const { Parent::nextIn(a); }
327 331

	
328 332
    Node source(const Arc& a) const { return Parent::target(a); }
329 333
    Node target(const Arc& a) const { return Parent::source(a); }
330 334

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

	
333
    typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
337
    typedef FindArcTagIndicator<Digraph> FindArcTag;
334 338
    Arc findArc(const Node& u, const Node& v,
335 339
                const Arc& prev = INVALID) {
336 340
      return Parent::findArc(v, u, prev);
337 341
    }
338 342

	
339 343
  };
340 344

	
341 345
  /// \ingroup graph_adaptors
342 346
  ///
343 347
  /// \brief A digraph adaptor which reverses the orientation of the arcs.
344 348
  ///
345 349
  /// ReverseDigraph reverses the arcs in the adapted digraph. The
346 350
  /// SubDigraph is conform to the \ref concepts::Digraph
347 351
  /// "Digraph concept".
348 352
  ///
349 353
  /// \tparam _Digraph It must be conform to the \ref concepts::Digraph
350 354
  /// "Digraph concept". The type can be specified to be const.
351 355
  template<typename _Digraph>
352 356
  class ReverseDigraph :
353 357
    public DigraphAdaptorExtender<ReverseDigraphBase<_Digraph> > {
354 358
  public:
355 359
    typedef _Digraph Digraph;
356 360
    typedef DigraphAdaptorExtender<
357 361
      ReverseDigraphBase<_Digraph> > Parent;
358 362
  protected:
359 363
    ReverseDigraph() { }
360 364
  public:
361 365

	
362 366
    /// \brief Constructor
363 367
    ///
364 368
    /// Creates a reverse digraph adaptor for the given digraph
365 369
    explicit ReverseDigraph(Digraph& digraph) {
366 370
      Parent::setDigraph(digraph);
367 371
    }
368 372
  };
369 373

	
370 374
  /// \brief Just gives back a reverse digraph adaptor
371 375
  ///
372 376
  /// Just gives back a reverse digraph adaptor
373 377
  template<typename Digraph>
374 378
  ReverseDigraph<const Digraph> reverseDigraph(const Digraph& digraph) {
375 379
    return ReverseDigraph<const Digraph>(digraph);
376 380
  }
377 381

	
378 382
  template <typename _Digraph, typename _NodeFilterMap,
379 383
            typename _ArcFilterMap, bool _checked = true>
380 384
  class SubDigraphBase : public DigraphAdaptorBase<_Digraph> {
381 385
  public:
382 386
    typedef _Digraph Digraph;
383 387
    typedef _NodeFilterMap NodeFilterMap;
384 388
    typedef _ArcFilterMap ArcFilterMap;
385 389

	
386 390
    typedef SubDigraphBase Adaptor;
387 391
    typedef DigraphAdaptorBase<_Digraph> Parent;
388 392
  protected:
389 393
    NodeFilterMap* _node_filter;
390 394
    ArcFilterMap* _arc_filter;
391 395
    SubDigraphBase()
392 396
      : Parent(), _node_filter(0), _arc_filter(0) { }
393 397

	
394 398
    void setNodeFilterMap(NodeFilterMap& node_filter) {
395 399
      _node_filter = &node_filter;
396 400
    }
397 401
    void setArcFilterMap(ArcFilterMap& arc_filter) {
398 402
      _arc_filter = &arc_filter;
399 403
    }
400 404

	
401 405
  public:
402 406

	
403 407
    typedef typename Parent::Node Node;
404 408
    typedef typename Parent::Arc Arc;
405 409

	
406 410
    void first(Node& i) const {
407 411
      Parent::first(i);
408 412
      while (i != INVALID && !(*_node_filter)[i]) Parent::next(i);
409 413
    }
410 414

	
411 415
    void first(Arc& i) const {
412 416
      Parent::first(i);
413 417
      while (i != INVALID && (!(*_arc_filter)[i]
414 418
                              || !(*_node_filter)[Parent::source(i)]
415 419
                              || !(*_node_filter)[Parent::target(i)]))
416 420
        Parent::next(i);
417 421
    }
418 422

	
419 423
    void firstIn(Arc& i, const Node& n) const {
420 424
      Parent::firstIn(i, n);
421 425
      while (i != INVALID && (!(*_arc_filter)[i]
422 426
                              || !(*_node_filter)[Parent::source(i)]))
423 427
        Parent::nextIn(i);
424 428
    }
425 429

	
426 430
    void firstOut(Arc& i, const Node& n) const {
427 431
      Parent::firstOut(i, n);
428 432
      while (i != INVALID && (!(*_arc_filter)[i]
429 433
                              || !(*_node_filter)[Parent::target(i)]))
430 434
        Parent::nextOut(i);
431 435
    }
432 436

	
433 437
    void next(Node& i) const {
434 438
      Parent::next(i);
435 439
      while (i != INVALID && !(*_node_filter)[i]) Parent::next(i);
436 440
    }
437 441

	
438 442
    void next(Arc& i) const {
439 443
      Parent::next(i);
440 444
      while (i != INVALID && (!(*_arc_filter)[i]
441 445
                              || !(*_node_filter)[Parent::source(i)]
442 446
                              || !(*_node_filter)[Parent::target(i)]))
443 447
        Parent::next(i);
444 448
    }
445 449

	
446 450
    void nextIn(Arc& i) const {
447 451
      Parent::nextIn(i);
448 452
      while (i != INVALID && (!(*_arc_filter)[i]
449 453
                              || !(*_node_filter)[Parent::source(i)]))
450 454
        Parent::nextIn(i);
451 455
    }
452 456

	
453 457
    void nextOut(Arc& i) const {
454 458
      Parent::nextOut(i);
455 459
      while (i != INVALID && (!(*_arc_filter)[i]
456 460
                              || !(*_node_filter)[Parent::target(i)]))
457 461
        Parent::nextOut(i);
458 462
    }
459 463

	
460 464
    void hide(const Node& n) const { _node_filter->set(n, false); }
461 465
    void hide(const Arc& a) const { _arc_filter->set(a, false); }
462 466

	
463 467
    void unHide(const Node& n) const { _node_filter->set(n, true); }
464 468
    void unHide(const Arc& a) const { _arc_filter->set(a, true); }
465 469

	
466 470
    bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
467 471
    bool hidden(const Arc& a) const { return !(*_arc_filter)[a]; }
468 472

	
469 473
    typedef False NodeNumTag;
470
    typedef False EdgeNumTag;
471

	
472
    typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
474
    typedef False ArcNumTag;
475

	
476
    typedef FindArcTagIndicator<Digraph> FindArcTag;
473 477
    Arc findArc(const Node& source, const Node& target,
474 478
                const Arc& prev = INVALID) {
475 479
      if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
476 480
        return INVALID;
477 481
      }
478 482
      Arc arc = Parent::findArc(source, target, prev);
479 483
      while (arc != INVALID && !(*_arc_filter)[arc]) {
480 484
        arc = Parent::findArc(source, target, arc);
481 485
      }
482 486
      return arc;
483 487
    }
484 488

	
485 489
    template <typename _Value>
486 490
    class NodeMap : public SubMapExtender<Adaptor,
487 491
      typename Parent::template NodeMap<_Value> > {
488 492
    public:
489 493
      typedef _Value Value;
490 494
      typedef SubMapExtender<Adaptor, typename Parent::
491 495
                             template NodeMap<Value> > MapParent;
492 496

	
493 497
      NodeMap(const Adaptor& adaptor)
494 498
        : MapParent(adaptor) {}
495 499
      NodeMap(const Adaptor& adaptor, const Value& value)
496 500
        : MapParent(adaptor, value) {}
497 501

	
498 502
    private:
499 503
      NodeMap& operator=(const NodeMap& cmap) {
500 504
        return operator=<NodeMap>(cmap);
501 505
      }
502 506

	
503 507
      template <typename CMap>
504 508
      NodeMap& operator=(const CMap& cmap) {
505 509
        MapParent::operator=(cmap);
506 510
        return *this;
507 511
      }
508 512
    };
509 513

	
510 514
    template <typename _Value>
511 515
    class ArcMap : public SubMapExtender<Adaptor,
512 516
      typename Parent::template ArcMap<_Value> > {
513 517
    public:
514 518
      typedef _Value Value;
515 519
      typedef SubMapExtender<Adaptor, typename Parent::
516 520
                             template ArcMap<Value> > MapParent;
517 521

	
518 522
      ArcMap(const Adaptor& adaptor)
519 523
        : MapParent(adaptor) {}
520 524
      ArcMap(const Adaptor& adaptor, const Value& value)
521 525
        : MapParent(adaptor, value) {}
522 526

	
523 527
    private:
524 528
      ArcMap& operator=(const ArcMap& cmap) {
525 529
        return operator=<ArcMap>(cmap);
526 530
      }
527 531

	
528 532
      template <typename CMap>
529 533
      ArcMap& operator=(const CMap& cmap) {
530 534
        MapParent::operator=(cmap);
531 535
        return *this;
532 536
      }
533 537
    };
534 538

	
535 539
  };
536 540

	
537 541
  template <typename _Digraph, typename _NodeFilterMap, typename _ArcFilterMap>
538 542
  class SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, false>
539 543
    : public DigraphAdaptorBase<_Digraph> {
540 544
  public:
541 545
    typedef _Digraph Digraph;
542 546
    typedef _NodeFilterMap NodeFilterMap;
543 547
    typedef _ArcFilterMap ArcFilterMap;
544 548

	
545 549
    typedef SubDigraphBase Adaptor;
546 550
    typedef DigraphAdaptorBase<Digraph> Parent;
547 551
  protected:
548 552
    NodeFilterMap* _node_filter;
549 553
    ArcFilterMap* _arc_filter;
550 554
    SubDigraphBase()
551 555
      : Parent(), _node_filter(0), _arc_filter(0) { }
552 556

	
553 557
    void setNodeFilterMap(NodeFilterMap& node_filter) {
554 558
      _node_filter = &node_filter;
555 559
    }
556 560
    void setArcFilterMap(ArcFilterMap& arc_filter) {
557 561
      _arc_filter = &arc_filter;
558 562
    }
559 563

	
560 564
  public:
561 565

	
562 566
    typedef typename Parent::Node Node;
563 567
    typedef typename Parent::Arc Arc;
564 568

	
565 569
    void first(Node& i) const {
566 570
      Parent::first(i);
567 571
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
568 572
    }
569 573

	
570 574
    void first(Arc& i) const {
571 575
      Parent::first(i);
572 576
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::next(i);
573 577
    }
574 578

	
575 579
    void firstIn(Arc& i, const Node& n) const {
576 580
      Parent::firstIn(i, n);
577 581
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextIn(i);
578 582
    }
579 583

	
580 584
    void firstOut(Arc& i, const Node& n) const {
581 585
      Parent::firstOut(i, n);
582 586
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i);
583 587
    }
584 588

	
585 589
    void next(Node& i) const {
586 590
      Parent::next(i);
587 591
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
588 592
    }
589 593
    void next(Arc& i) const {
590 594
      Parent::next(i);
591 595
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::next(i);
592 596
    }
593 597
    void nextIn(Arc& i) const {
594 598
      Parent::nextIn(i);
595 599
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextIn(i);
596 600
    }
597 601

	
598 602
    void nextOut(Arc& i) const {
599 603
      Parent::nextOut(i);
600 604
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i);
601 605
    }
602 606

	
603 607
    void hide(const Node& n) const { _node_filter->set(n, false); }
604 608
    void hide(const Arc& e) const { _arc_filter->set(e, false); }
605 609

	
606 610
    void unHide(const Node& n) const { _node_filter->set(n, true); }
607 611
    void unHide(const Arc& e) const { _arc_filter->set(e, true); }
608 612

	
609 613
    bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
610 614
    bool hidden(const Arc& e) const { return !(*_arc_filter)[e]; }
611 615

	
612 616
    typedef False NodeNumTag;
613
    typedef False EdgeNumTag;
614

	
615
    typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
617
    typedef False ArcNumTag;
618

	
619
    typedef FindArcTagIndicator<Digraph> FindArcTag;
616 620
    Arc findArc(const Node& source, const Node& target,
617 621
                const Arc& prev = INVALID) {
618 622
      if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
619 623
        return INVALID;
620 624
      }
621 625
      Arc arc = Parent::findArc(source, target, prev);
622 626
      while (arc != INVALID && !(*_arc_filter)[arc]) {
623 627
        arc = Parent::findArc(source, target, arc);
624 628
      }
625 629
      return arc;
626 630
    }
627 631

	
628 632
    template <typename _Value>
629 633
    class NodeMap : public SubMapExtender<Adaptor,
630 634
      typename Parent::template NodeMap<_Value> > {
631 635
    public:
632 636
      typedef _Value Value;
633 637
      typedef SubMapExtender<Adaptor, typename Parent::
634 638
                             template NodeMap<Value> > MapParent;
635 639

	
636 640
      NodeMap(const Adaptor& adaptor)
637 641
        : MapParent(adaptor) {}
638 642
      NodeMap(const Adaptor& adaptor, const Value& value)
639 643
        : MapParent(adaptor, value) {}
640 644

	
641 645
    private:
642 646
      NodeMap& operator=(const NodeMap& cmap) {
643 647
        return operator=<NodeMap>(cmap);
644 648
      }
645 649

	
646 650
      template <typename CMap>
647 651
      NodeMap& operator=(const CMap& cmap) {
648 652
        MapParent::operator=(cmap);
649 653
        return *this;
650 654
      }
651 655
    };
652 656

	
653 657
    template <typename _Value>
654 658
    class ArcMap : public SubMapExtender<Adaptor,
655 659
      typename Parent::template ArcMap<_Value> > {
656 660
    public:
657 661
      typedef _Value Value;
658 662
      typedef SubMapExtender<Adaptor, typename Parent::
659 663
                             template ArcMap<Value> > MapParent;
660 664

	
661 665
      ArcMap(const Adaptor& adaptor)
662 666
        : MapParent(adaptor) {}
663 667
      ArcMap(const Adaptor& adaptor, const Value& value)
664 668
        : MapParent(adaptor, value) {}
665 669

	
666 670
    private:
667 671
      ArcMap& operator=(const ArcMap& cmap) {
668 672
        return operator=<ArcMap>(cmap);
669 673
      }
670 674

	
671 675
      template <typename CMap>
672 676
      ArcMap& operator=(const CMap& cmap) {
673 677
        MapParent::operator=(cmap);
674 678
        return *this;
675 679
      }
676 680
    };
677 681

	
678 682
  };
679 683

	
680 684
  /// \ingroup graph_adaptors
681 685
  ///
682 686
  /// \brief An adaptor for hiding nodes and arcs in a digraph
683 687
  ///
684 688
  /// SubDigraph hides nodes and arcs in a digraph. A bool node map
685 689
  /// and a bool arc map must be specified, which define the filters
686 690
  /// for nodes and arcs. Just the nodes and arcs with true value are
687 691
  /// shown in the subdigraph. The SubDigraph is conform to the \ref
688 692
  /// concepts::Digraph "Digraph concept". If the \c _checked parameter
689 693
  /// is true, then the arcs incident to filtered nodes are also
690 694
  /// filtered out.
691 695
  ///
692 696
  /// \tparam _Digraph It must be conform to the \ref
693 697
  /// concepts::Digraph "Digraph concept". The type can be specified
694 698
  /// to const.
695 699
  /// \tparam _NodeFilterMap A bool valued node map of the the adapted digraph.
696 700
  /// \tparam _ArcFilterMap A bool valued arc map of the the adapted digraph.
697 701
  /// \tparam _checked If the parameter is false then the arc filtering
698 702
  /// is not checked with respect to node filter. Otherwise, each arc
699 703
  /// is automatically filtered, which is incident to a filtered node.
700 704
  ///
701 705
  /// \see FilterNodes
702 706
  /// \see FilterArcs
703 707
  template<typename _Digraph,
704 708
           typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>,
705 709
           typename _ArcFilterMap = typename _Digraph::template ArcMap<bool>,
706 710
           bool _checked = true>
707 711
  class SubDigraph
708 712
    : public DigraphAdaptorExtender<
709 713
      SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, _checked> > {
710 714
  public:
711 715
    typedef _Digraph Digraph;
... ...
@@ -842,399 +846,405 @@
842 846
    void first(Node& i) const {
843 847
      Parent::first(i);
844 848
      while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i);
845 849
    }
846 850

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	
937 941
    typedef False NodeNumTag;
942
    typedef False ArcNumTag;
938 943
    typedef False EdgeNumTag;
939 944

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

	
958
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
952 959
    Edge findEdge(const Node& u, const Node& v,
953 960
                  const Edge& prev = INVALID) {
954 961
      if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
955 962
        return INVALID;
956 963
      }
957 964
      Edge edge = Parent::findEdge(u, v, prev);
958 965
      while (edge != INVALID && !(*_edge_filter_map)[edge]) {
959 966
        edge = Parent::findEdge(u, v, edge);
960 967
      }
961 968
      return edge;
962 969
    }
963 970

	
964 971
    template <typename _Value>
965 972
    class NodeMap : public SubMapExtender<Adaptor,
966 973
      typename Parent::template NodeMap<_Value> > {
967 974
    public:
968 975
      typedef _Value Value;
969 976
      typedef SubMapExtender<Adaptor, typename Parent::
970 977
                             template NodeMap<Value> > MapParent;
971 978

	
972 979
      NodeMap(const Adaptor& adaptor)
973 980
        : MapParent(adaptor) {}
974 981
      NodeMap(const Adaptor& adaptor, const Value& value)
975 982
        : MapParent(adaptor, value) {}
976 983

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

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

	
989 996
    template <typename _Value>
990 997
    class ArcMap : public SubMapExtender<Adaptor,
991 998
      typename Parent::template ArcMap<_Value> > {
992 999
    public:
993 1000
      typedef _Value Value;
994 1001
      typedef SubMapExtender<Adaptor, typename Parent::
995 1002
                             template ArcMap<Value> > MapParent;
996 1003

	
997 1004
      ArcMap(const Adaptor& adaptor)
998 1005
        : MapParent(adaptor) {}
999 1006
      ArcMap(const Adaptor& adaptor, const Value& value)
1000 1007
        : MapParent(adaptor, value) {}
1001 1008

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

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

	
1014 1021
    template <typename _Value>
1015 1022
    class EdgeMap : public SubMapExtender<Adaptor,
1016 1023
      typename Parent::template EdgeMap<_Value> > {
1017 1024
    public:
1018 1025
      typedef _Value Value;
1019 1026
      typedef SubMapExtender<Adaptor, typename Parent::
1020 1027
                             template EdgeMap<Value> > MapParent;
1021 1028

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

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

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

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

	
1040 1047
  };
1041 1048

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

	
1055 1062
    void setNodeFilterMap(NodeFilterMap& node_filter_map) {
1056 1063
      _node_filter_map=&node_filter_map;
1057 1064
    }
1058 1065
    void setEdgeFilterMap(EdgeFilterMap& edge_filter_map) {
1059 1066
      _edge_filter_map=&edge_filter_map;
1060 1067
    }
1061 1068

	
1062 1069
  public:
1063 1070

	
1064 1071
    typedef typename Parent::Node Node;
1065 1072
    typedef typename Parent::Arc Arc;
1066 1073
    typedef typename Parent::Edge Edge;
1067 1074

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

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

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

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

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

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

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

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

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

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

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

	
1133 1140
    typedef False NodeNumTag;
1141
    typedef False ArcNumTag;
1134 1142
    typedef False EdgeNumTag;
1135 1143

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

	
1154
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
1145 1155
    Edge findEdge(const Node& u, const Node& v,
1146 1156
                  const Edge& prev = INVALID) {
1147 1157
      Edge edge = Parent::findEdge(u, v, prev);
1148 1158
      while (edge != INVALID && !(*_edge_filter_map)[edge]) {
1149 1159
        edge = Parent::findEdge(u, v, edge);
1150 1160
      }
1151 1161
      return edge;
1152 1162
    }
1153 1163

	
1154 1164
    template <typename _Value>
1155 1165
    class NodeMap : public SubMapExtender<Adaptor,
1156 1166
      typename Parent::template NodeMap<_Value> > {
1157 1167
    public:
1158 1168
      typedef _Value Value;
1159 1169
      typedef SubMapExtender<Adaptor, typename Parent::
1160 1170
                             template NodeMap<Value> > MapParent;
1161 1171

	
1162 1172
      NodeMap(const Adaptor& adaptor)
1163 1173
        : MapParent(adaptor) {}
1164 1174
      NodeMap(const Adaptor& adaptor, const Value& value)
1165 1175
        : MapParent(adaptor, value) {}
1166 1176

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

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

	
1179 1189
    template <typename _Value>
1180 1190
    class ArcMap : public SubMapExtender<Adaptor,
1181 1191
      typename Parent::template ArcMap<_Value> > {
1182 1192
    public:
1183 1193
      typedef _Value Value;
1184 1194
      typedef SubMapExtender<Adaptor, typename Parent::
1185 1195
                             template ArcMap<Value> > MapParent;
1186 1196

	
1187 1197
      ArcMap(const Adaptor& adaptor)
1188 1198
        : MapParent(adaptor) {}
1189 1199
      ArcMap(const Adaptor& adaptor, const Value& value)
1190 1200
        : MapParent(adaptor, value) {}
1191 1201

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

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

	
1204 1214
    template <typename _Value>
1205 1215
    class EdgeMap : public SubMapExtender<Adaptor,
1206 1216
      typename Parent::template EdgeMap<_Value> > {
1207 1217
    public:
1208 1218
      typedef _Value Value;
1209 1219
      typedef SubMapExtender<Adaptor, typename Parent::
1210 1220
                             template EdgeMap<Value> > MapParent;
1211 1221

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

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

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

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

	
1230 1240
  };
1231 1241

	
1232 1242
  /// \ingroup graph_adaptors
1233 1243
  ///
1234 1244
  /// \brief A graph adaptor for hiding nodes and edges in an
1235 1245
  /// undirected graph.
1236 1246
  ///
1237 1247
  /// SubGraph hides nodes and edges in a graph. A bool node map and a
1238 1248
  /// bool edge map must be specified, which define the filters for
1239 1249
  /// nodes and edges. Just the nodes and edges with true value are
1240 1250
  /// shown in the subgraph. The SubGraph is conform to the \ref
... ...
@@ -1753,215 +1763,219 @@
1753 1763
    void firstIn(Arc &a, const Node &n) const {
1754 1764
      _digraph->firstOut(a, n);
1755 1765
      if (static_cast<const Edge&>(a) != INVALID ) {
1756 1766
        a._forward = false;
1757 1767
      } else {
1758 1768
        _digraph->firstIn(a, n);
1759 1769
        a._forward = true;
1760 1770
      }
1761 1771
    }
1762 1772
    void nextIn(Arc &a) const {
1763 1773
      if (!a._forward) {
1764 1774
        Node n = _digraph->source(a);
1765 1775
        _digraph->nextOut(a);
1766 1776
        if( static_cast<const Edge&>(a) == INVALID ) {
1767 1777
          _digraph->firstIn(a, n);
1768 1778
          a._forward = true;
1769 1779
        }
1770 1780
      }
1771 1781
      else {
1772 1782
        _digraph->nextIn(a);
1773 1783
      }
1774 1784
    }
1775 1785

	
1776 1786
    void firstInc(Edge &e, bool &d, const Node &n) const {
1777 1787
      d = true;
1778 1788
      _digraph->firstOut(e, n);
1779 1789
      if (e != INVALID) return;
1780 1790
      d = false;
1781 1791
      _digraph->firstIn(e, n);
1782 1792
    }
1783 1793

	
1784 1794
    void nextInc(Edge &e, bool &d) const {
1785 1795
      if (d) {
1786 1796
        Node s = _digraph->source(e);
1787 1797
        _digraph->nextOut(e);
1788 1798
        if (e != INVALID) return;
1789 1799
        d = false;
1790 1800
        _digraph->firstIn(e, s);
1791 1801
      } else {
1792 1802
        _digraph->nextIn(e);
1793 1803
      }
1794 1804
    }
1795 1805

	
1796 1806
    Node u(const Edge& e) const {
1797 1807
      return _digraph->source(e);
1798 1808
    }
1799 1809

	
1800 1810
    Node v(const Edge& e) const {
1801 1811
      return _digraph->target(e);
1802 1812
    }
1803 1813

	
1804 1814
    Node source(const Arc &a) const {
1805 1815
      return a._forward ? _digraph->source(a) : _digraph->target(a);
1806 1816
    }
1807 1817

	
1808 1818
    Node target(const Arc &a) const {
1809 1819
      return a._forward ? _digraph->target(a) : _digraph->source(a);
1810 1820
    }
1811 1821

	
1812 1822
    static Arc direct(const Edge &e, bool d) {
1813 1823
      return Arc(e, d);
1814 1824
    }
1815 1825
    Arc direct(const Edge &e, const Node& n) const {
1816 1826
      return Arc(e, _digraph->source(e) == n);
1817 1827
    }
1818 1828

	
1819 1829
    static bool direction(const Arc &a) { return a._forward; }
1820 1830

	
1821 1831
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
1822 1832
    Arc arcFromId(int ix) const {
1823 1833
      return direct(_digraph->arcFromId(ix >> 1), bool(ix & 1));
1824 1834
    }
1825 1835
    Edge edgeFromId(int ix) const { return _digraph->arcFromId(ix); }
1826 1836

	
1827 1837
    int id(const Node &n) const { return _digraph->id(n); }
1828 1838
    int id(const Arc &a) const {
1829 1839
      return  (_digraph->id(a) << 1) | (a._forward ? 1 : 0);
1830 1840
    }
1831 1841
    int id(const Edge &e) const { return _digraph->id(e); }
1832 1842

	
1833 1843
    int maxNodeId() const { return _digraph->maxNodeId(); }
1834 1844
    int maxArcId() const { return (_digraph->maxArcId() << 1) | 1; }
1835 1845
    int maxEdgeId() const { return _digraph->maxArcId(); }
1836 1846

	
1837 1847
    Node addNode() { return _digraph->addNode(); }
1838 1848
    Edge addEdge(const Node& u, const Node& v) {
1839 1849
      return _digraph->addArc(u, v);
1840 1850
    }
1841 1851

	
1842 1852
    void erase(const Node& i) { _digraph->erase(i); }
1843 1853
    void erase(const Edge& i) { _digraph->erase(i); }
1844 1854

	
1845 1855
    void clear() { _digraph->clear(); }
1846 1856

	
1847 1857
    typedef NodeNumTagIndicator<Digraph> NodeNumTag;
1848 1858
    int nodeNum() const { return 2 * _digraph->arcNum(); }
1849
    typedef EdgeNumTagIndicator<Digraph> EdgeNumTag;
1859

	
1860
    typedef ArcNumTagIndicator<Digraph> ArcNumTag;
1850 1861
    int arcNum() const { return 2 * _digraph->arcNum(); }
1862

	
1863
    typedef ArcNumTag EdgeNumTag;
1851 1864
    int edgeNum() const { return _digraph->arcNum(); }
1852 1865

	
1853
    typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
1866
    typedef FindArcTagIndicator<Digraph> FindArcTag;
1854 1867
    Arc findArc(Node s, Node t, Arc p = INVALID) const {
1855 1868
      if (p == INVALID) {
1856 1869
        Edge arc = _digraph->findArc(s, t);
1857 1870
        if (arc != INVALID) return direct(arc, true);
1858 1871
        arc = _digraph->findArc(t, s);
1859 1872
        if (arc != INVALID) return direct(arc, false);
1860 1873
      } else if (direction(p)) {
1861 1874
        Edge arc = _digraph->findArc(s, t, p);
1862 1875
        if (arc != INVALID) return direct(arc, true);
1863 1876
        arc = _digraph->findArc(t, s);
1864 1877
        if (arc != INVALID) return direct(arc, false);
1865 1878
      } else {
1866 1879
        Edge arc = _digraph->findArc(t, s, p);
1867 1880
        if (arc != INVALID) return direct(arc, false);
1868 1881
      }
1869 1882
      return INVALID;
1870 1883
    }
1871 1884

	
1885
    typedef FindArcTag FindEdgeTag;
1872 1886
    Edge findEdge(Node s, Node t, Edge p = INVALID) const {
1873 1887
      if (s != t) {
1874 1888
        if (p == INVALID) {
1875 1889
          Edge arc = _digraph->findArc(s, t);
1876 1890
          if (arc != INVALID) return arc;
1877 1891
          arc = _digraph->findArc(t, s);
1878 1892
          if (arc != INVALID) return arc;
1879 1893
        } else if (_digraph->s(p) == s) {
1880 1894
          Edge arc = _digraph->findArc(s, t, p);
1881 1895
          if (arc != INVALID) return arc;
1882 1896
          arc = _digraph->findArc(t, s);
1883 1897
          if (arc != INVALID) return arc;
1884 1898
        } else {
1885 1899
          Edge arc = _digraph->findArc(t, s, p);
1886 1900
          if (arc != INVALID) return arc;
1887 1901
        }
1888 1902
      } else {
1889 1903
        return _digraph->findArc(s, t, p);
1890 1904
      }
1891 1905
      return INVALID;
1892 1906
    }
1893 1907

	
1894 1908
  private:
1895 1909

	
1896 1910
    template <typename _Value>
1897 1911
    class ArcMapBase {
1898 1912
    private:
1899 1913

	
1900 1914
      typedef typename Digraph::template ArcMap<_Value> MapImpl;
1901 1915

	
1902 1916
    public:
1903 1917

	
1904 1918
      typedef typename MapTraits<MapImpl>::ReferenceMapTag ReferenceMapTag;
1905 1919

	
1906 1920
      typedef _Value Value;
1907 1921
      typedef Arc Key;
1908 1922

	
1909 1923
      ArcMapBase(const Adaptor& adaptor) :
1910 1924
        _forward(*adaptor._digraph), _backward(*adaptor._digraph) {}
1911 1925

	
1912 1926
      ArcMapBase(const Adaptor& adaptor, const Value& v)
1913 1927
        : _forward(*adaptor._digraph, v), _backward(*adaptor._digraph, v) {}
1914 1928

	
1915 1929
      void set(const Arc& a, const Value& v) {
1916 1930
        if (direction(a)) {
1917 1931
          _forward.set(a, v);
1918 1932
        } else {
1919 1933
          _backward.set(a, v);
1920 1934
        }
1921 1935
      }
1922 1936

	
1923 1937
      typename MapTraits<MapImpl>::ConstReturnValue
1924 1938
      operator[](const Arc& a) const {
1925 1939
        if (direction(a)) {
1926 1940
          return _forward[a];
1927 1941
        } else {
1928 1942
          return _backward[a];
1929 1943
        }
1930 1944
      }
1931 1945

	
1932 1946
      typename MapTraits<MapImpl>::ReturnValue
1933 1947
      operator[](const Arc& a) {
1934 1948
        if (direction(a)) {
1935 1949
          return _forward[a];
1936 1950
        } else {
1937 1951
          return _backward[a];
1938 1952
        }
1939 1953
      }
1940 1954

	
1941 1955
    protected:
1942 1956

	
1943 1957
      MapImpl _forward, _backward;
1944 1958

	
1945 1959
    };
1946 1960

	
1947 1961
  public:
1948 1962

	
1949 1963
    template <typename _Value>
1950 1964
    class NodeMap : public Digraph::template NodeMap<_Value> {
1951 1965
    public:
1952 1966

	
1953 1967
      typedef _Value Value;
1954 1968
      typedef typename Digraph::template NodeMap<Value> Parent;
1955 1969

	
1956 1970
      explicit NodeMap(const Adaptor& adaptor)
1957 1971
        : Parent(*adaptor._digraph) {}
1958 1972

	
1959 1973
      NodeMap(const Adaptor& adaptor, const _Value& value)
1960 1974
        : Parent(*adaptor._digraph, value) { }
1961 1975

	
1962 1976
    private:
1963 1977
      NodeMap& operator=(const NodeMap& cmap) {
1964 1978
        return operator=<NodeMap>(cmap);
1965 1979
      }
1966 1980

	
1967 1981
      template <typename CMap>
... ...
@@ -2131,196 +2145,196 @@
2131 2145
      ForwardMap* _forward;
2132 2146
      BackwardMap* _backward;
2133 2147

	
2134 2148
    };
2135 2149

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

	
2145 2159
    template <typename ForwardMap, typename BackwardMap>
2146 2160
    static CombinedArcMap<const ForwardMap, BackwardMap>
2147 2161
    combinedArcMap(const ForwardMap& forward, BackwardMap& backward) {
2148 2162
      return CombinedArcMap<const ForwardMap,
2149 2163
        BackwardMap>(forward, backward);
2150 2164
    }
2151 2165

	
2152 2166
    template <typename ForwardMap, typename BackwardMap>
2153 2167
    static CombinedArcMap<ForwardMap, const BackwardMap>
2154 2168
    combinedArcMap(ForwardMap& forward, const BackwardMap& backward) {
2155 2169
      return CombinedArcMap<ForwardMap,
2156 2170
        const BackwardMap>(forward, backward);
2157 2171
    }
2158 2172

	
2159 2173
    template <typename ForwardMap, typename BackwardMap>
2160 2174
    static CombinedArcMap<const ForwardMap, const BackwardMap>
2161 2175
    combinedArcMap(const ForwardMap& forward, const BackwardMap& backward) {
2162 2176
      return CombinedArcMap<const ForwardMap,
2163 2177
        const BackwardMap>(forward, backward);
2164 2178
    }
2165 2179

	
2166 2180
  };
2167 2181

	
2168 2182
  /// \brief Just gives back an undirected view of the given digraph
2169 2183
  ///
2170 2184
  /// Just gives back an undirected view of the given digraph
2171 2185
  template<typename Digraph>
2172 2186
  Undirector<const Digraph>
2173 2187
  undirector(const Digraph& digraph) {
2174 2188
    return Undirector<const Digraph>(digraph);
2175 2189
  }
2176 2190

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

	
2181 2195
    typedef _Graph Graph;
2182 2196
    typedef _DirectionMap DirectionMap;
2183 2197

	
2184 2198
    typedef typename Graph::Node Node;
2185 2199
    typedef typename Graph::Edge Arc;
2186 2200

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

	
2191 2205
    void first(Node& i) const { _graph->first(i); }
2192 2206
    void first(Arc& i) const { _graph->first(i); }
2193 2207
    void firstIn(Arc& i, const Node& n) const {
2194 2208
      bool d;
2195 2209
      _graph->firstInc(i, d, n);
2196 2210
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2197 2211
    }
2198 2212
    void firstOut(Arc& i, const Node& n ) const {
2199 2213
      bool d;
2200 2214
      _graph->firstInc(i, d, n);
2201 2215
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2202 2216
    }
2203 2217

	
2204 2218
    void next(Node& i) const { _graph->next(i); }
2205 2219
    void next(Arc& i) const { _graph->next(i); }
2206 2220
    void nextIn(Arc& i) const {
2207 2221
      bool d = !(*_direction)[i];
2208 2222
      _graph->nextInc(i, d);
2209 2223
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2210 2224
    }
2211 2225
    void nextOut(Arc& i) const {
2212 2226
      bool d = (*_direction)[i];
2213 2227
      _graph->nextInc(i, d);
2214 2228
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2215 2229
    }
2216 2230

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

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

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

	
2230
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
2244
    typedef FindEdgeTagIndicator<Graph> FindArcTag;
2231 2245
    Arc findArc(const Node& u, const Node& v,
2232 2246
                const Arc& prev = INVALID) {
2233 2247
      Arc arc = prev;
2234 2248
      bool d = arc == INVALID ? true : (*_direction)[arc];
2235 2249
      if (d) {
2236 2250
        arc = _graph->findEdge(u, v, arc);
2237 2251
        while (arc != INVALID && !(*_direction)[arc]) {
2238 2252
          _graph->findEdge(u, v, arc);
2239 2253
        }
2240 2254
        if (arc != INVALID) return arc;
2241 2255
      }
2242 2256
      _graph->findEdge(v, u, arc);
2243 2257
      while (arc != INVALID && (*_direction)[arc]) {
2244 2258
        _graph->findEdge(u, v, arc);
2245 2259
      }
2246 2260
      return arc;
2247 2261
    }
2248 2262

	
2249 2263
    Node addNode() {
2250 2264
      return Node(_graph->addNode());
2251 2265
    }
2252 2266

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

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

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

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

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

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

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

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

	
2279 2293
    template <typename _Value>
2280 2294
    class NodeMap : public _Graph::template NodeMap<_Value> {
2281 2295
    public:
2282 2296

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

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

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

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

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

	
2302 2316
    };
2303 2317

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

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

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

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

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

	
2321 2335
      template <typename CMap>
2322 2336
      ArcMap& operator=(const CMap& cmap) {
2323 2337
        Parent::operator=(cmap);
2324 2338
        return *this;
2325 2339
      }
2326 2340
    };
... ...
@@ -2791,203 +2805,202 @@
2791 2805

	
2792 2806
    void firstIn(Arc& e, const Node& n) const {
2793 2807
      if (!n._in) {
2794 2808
        e._item.setSecond(n);
2795 2809
      } else {
2796 2810
        e._item.setFirst();
2797 2811
        _digraph->firstIn(e._item.first(), n);
2798 2812
      }
2799 2813
    }
2800 2814

	
2801 2815
    void nextIn(Arc& e) const {
2802 2816
      if (!e._item.firstState()) {
2803 2817
        e._item.setFirst(INVALID);
2804 2818
      } else {
2805 2819
        _digraph->nextIn(e._item.first());
2806 2820
      }
2807 2821
    }
2808 2822

	
2809 2823
    Node source(const Arc& e) const {
2810 2824
      if (e._item.firstState()) {
2811 2825
        return Node(_digraph->source(e._item.first()), false);
2812 2826
      } else {
2813 2827
        return Node(e._item.second(), true);
2814 2828
      }
2815 2829
    }
2816 2830

	
2817 2831
    Node target(const Arc& e) const {
2818 2832
      if (e._item.firstState()) {
2819 2833
        return Node(_digraph->target(e._item.first()), true);
2820 2834
      } else {
2821 2835
        return Node(e._item.second(), false);
2822 2836
      }
2823 2837
    }
2824 2838

	
2825 2839
    int id(const Node& n) const {
2826 2840
      return (_digraph->id(n) << 1) | (n._in ? 0 : 1);
2827 2841
    }
2828 2842
    Node nodeFromId(int ix) const {
2829 2843
      return Node(_digraph->nodeFromId(ix >> 1), (ix & 1) == 0);
2830 2844
    }
2831 2845
    int maxNodeId() const {
2832 2846
      return 2 * _digraph->maxNodeId() + 1;
2833 2847
    }
2834 2848

	
2835 2849
    int id(const Arc& e) const {
2836 2850
      if (e._item.firstState()) {
2837 2851
        return _digraph->id(e._item.first()) << 1;
2838 2852
      } else {
2839 2853
        return (_digraph->id(e._item.second()) << 1) | 1;
2840 2854
      }
2841 2855
    }
2842 2856
    Arc arcFromId(int ix) const {
2843 2857
      if ((ix & 1) == 0) {
2844 2858
        return Arc(_digraph->arcFromId(ix >> 1));
2845 2859
      } else {
2846 2860
        return Arc(_digraph->nodeFromId(ix >> 1));
2847 2861
      }
2848 2862
    }
2849 2863
    int maxArcId() const {
2850 2864
      return std::max(_digraph->maxNodeId() << 1,
2851 2865
                      (_digraph->maxArcId() << 1) | 1);
2852 2866
    }
2853 2867

	
2854 2868
    static bool inNode(const Node& n) {
2855 2869
      return n._in;
2856 2870
    }
2857 2871

	
2858 2872
    static bool outNode(const Node& n) {
2859 2873
      return !n._in;
2860 2874
    }
2861 2875

	
2862 2876
    static bool origArc(const Arc& e) {
2863 2877
      return e._item.firstState();
2864 2878
    }
2865 2879

	
2866 2880
    static bool bindArc(const Arc& e) {
2867 2881
      return e._item.secondState();
2868 2882
    }
2869 2883

	
2870 2884
    static Node inNode(const DigraphNode& n) {
2871 2885
      return Node(n, true);
2872 2886
    }
2873 2887

	
2874 2888
    static Node outNode(const DigraphNode& n) {
2875 2889
      return Node(n, false);
2876 2890
    }
2877 2891

	
2878 2892
    static Arc arc(const DigraphNode& n) {
2879 2893
      return Arc(n);
2880 2894
    }
2881 2895

	
2882 2896
    static Arc arc(const DigraphArc& e) {
2883 2897
      return Arc(e);
2884 2898
    }
2885 2899

	
2886 2900
    typedef True NodeNumTag;
2887

	
2888 2901
    int nodeNum() const {
2889 2902
      return  2 * countNodes(*_digraph);
2890 2903
    }
2891 2904

	
2892
    typedef True EdgeNumTag;
2905
    typedef True ArcNumTag;
2893 2906
    int arcNum() const {
2894 2907
      return countArcs(*_digraph) + countNodes(*_digraph);
2895 2908
    }
2896 2909

	
2897
    typedef True FindEdgeTag;
2910
    typedef True FindArcTag;
2898 2911
    Arc findArc(const Node& u, const Node& v,
2899 2912
                const Arc& prev = INVALID) const {
2900 2913
      if (inNode(u)) {
2901 2914
        if (outNode(v)) {
2902 2915
          if (static_cast<const DigraphNode&>(u) ==
2903 2916
              static_cast<const DigraphNode&>(v) && prev == INVALID) {
2904 2917
            return Arc(u);
2905 2918
          }
2906 2919
        }
2907 2920
      } else {
2908 2921
        if (inNode(v)) {
2909 2922
          return Arc(::lemon::findArc(*_digraph, u, v, prev));
2910 2923
        }
2911 2924
      }
2912 2925
      return INVALID;
2913 2926
    }
2914 2927

	
2915 2928
  private:
2916 2929

	
2917 2930
    template <typename _Value>
2918 2931
    class NodeMapBase
2919 2932
      : public MapTraits<typename Parent::template NodeMap<_Value> > {
2920 2933
      typedef typename Parent::template NodeMap<_Value> NodeImpl;
2921 2934
    public:
2922 2935
      typedef Node Key;
2923 2936
      typedef _Value Value;
2924 2937

	
2925 2938
      NodeMapBase(const Adaptor& adaptor)
2926 2939
        : _in_map(*adaptor._digraph), _out_map(*adaptor._digraph) {}
2927 2940
      NodeMapBase(const Adaptor& adaptor, const Value& value)
2928 2941
        : _in_map(*adaptor._digraph, value),
2929 2942
          _out_map(*adaptor._digraph, value) {}
2930 2943

	
2931 2944
      void set(const Node& key, const Value& val) {
2932 2945
        if (Adaptor::inNode(key)) { _in_map.set(key, val); }
2933 2946
        else {_out_map.set(key, val); }
2934 2947
      }
2935 2948

	
2936 2949
      typename MapTraits<NodeImpl>::ReturnValue
2937 2950
      operator[](const Node& key) {
2938 2951
        if (Adaptor::inNode(key)) { return _in_map[key]; }
2939 2952
        else { return _out_map[key]; }
2940 2953
      }
2941 2954

	
2942 2955
      typename MapTraits<NodeImpl>::ConstReturnValue
2943 2956
      operator[](const Node& key) const {
2944 2957
        if (Adaptor::inNode(key)) { return _in_map[key]; }
2945 2958
        else { return _out_map[key]; }
2946 2959
      }
2947 2960

	
2948 2961
    private:
2949 2962
      NodeImpl _in_map, _out_map;
2950 2963
    };
2951 2964

	
2952 2965
    template <typename _Value>
2953 2966
    class ArcMapBase
2954 2967
      : public MapTraits<typename Parent::template ArcMap<_Value> > {
2955 2968
      typedef typename Parent::template ArcMap<_Value> ArcImpl;
2956 2969
      typedef typename Parent::template NodeMap<_Value> NodeImpl;
2957 2970
    public:
2958 2971
      typedef Arc Key;
2959 2972
      typedef _Value Value;
2960 2973

	
2961 2974
      ArcMapBase(const Adaptor& adaptor)
2962 2975
        : _arc_map(*adaptor._digraph), _node_map(*adaptor._digraph) {}
2963 2976
      ArcMapBase(const Adaptor& adaptor, const Value& value)
2964 2977
        : _arc_map(*adaptor._digraph, value),
2965 2978
          _node_map(*adaptor._digraph, value) {}
2966 2979

	
2967 2980
      void set(const Arc& key, const Value& val) {
2968 2981
        if (Adaptor::origArc(key)) {
2969 2982
          _arc_map.set(key._item.first(), val);
2970 2983
        } else {
2971 2984
          _node_map.set(key._item.second(), val);
2972 2985
        }
2973 2986
      }
2974 2987

	
2975 2988
      typename MapTraits<ArcImpl>::ReturnValue
2976 2989
      operator[](const Arc& key) {
2977 2990
        if (Adaptor::origArc(key)) {
2978 2991
          return _arc_map[key._item.first()];
2979 2992
        } else {
2980 2993
          return _node_map[key._item.second()];
2981 2994
        }
2982 2995
      }
2983 2996

	
2984 2997
      typename MapTraits<ArcImpl>::ConstReturnValue
2985 2998
      operator[](const Arc& key) const {
2986 2999
        if (Adaptor::origArc(key)) {
2987 3000
          return _arc_map[key._item.first()];
2988 3001
        } else {
2989 3002
          return _node_map[key._item.second()];
2990 3003
        }
2991 3004
      }
2992 3005

	
2993 3006
    private:
0 comments (0 inline)