gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Fix and uniform the usage of Graph and Parent typedefs (#268) - Rename Graph typedefs to GraphType in the implementation of graph maps and MapExtender to prevent conflicts (especially using VS). They are not public. - Make Parent typedefs private in all classes. - Replace Digraph with Graph in some places (fix faulty renamings of the script). - Use Graph and Digraph typedefs (more) consequently.
0 19 0
default
19 files changed with 298 insertions and 277 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -80,96 +80,92 @@
80 80
    int arcNum() const { return _digraph->arcNum(); }
81 81

	
82 82
    typedef FindArcTagIndicator<DGR> FindArcTag;
83 83
    Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) const {
84 84
      return _digraph->findArc(u, v, prev);
85 85
    }
86 86

	
87 87
    Node addNode() { return _digraph->addNode(); }
88 88
    Arc addArc(const Node& u, const Node& v) { return _digraph->addArc(u, v); }
89 89

	
90 90
    void erase(const Node& n) { _digraph->erase(n); }
91 91
    void erase(const Arc& a) { _digraph->erase(a); }
92 92

	
93 93
    void clear() { _digraph->clear(); }
94 94

	
95 95
    int id(const Node& n) const { return _digraph->id(n); }
96 96
    int id(const Arc& a) const { return _digraph->id(a); }
97 97

	
98 98
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
99 99
    Arc arcFromId(int ix) const { return _digraph->arcFromId(ix); }
100 100

	
101 101
    int maxNodeId() const { return _digraph->maxNodeId(); }
102 102
    int maxArcId() const { return _digraph->maxArcId(); }
103 103

	
104 104
    typedef typename ItemSetTraits<DGR, Node>::ItemNotifier NodeNotifier;
105 105
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
106 106

	
107 107
    typedef typename ItemSetTraits<DGR, Arc>::ItemNotifier ArcNotifier;
108 108
    ArcNotifier& notifier(Arc) const { return _digraph->notifier(Arc()); }
109 109

	
110 110
    template <typename V>
111 111
    class NodeMap : public DGR::template NodeMap<V> {
112
      typedef typename DGR::template NodeMap<V> Parent;
113

	
112 114
    public:
113

	
114
      typedef typename DGR::template NodeMap<V> Parent;
115

	
116 115
      explicit NodeMap(const Adaptor& adaptor)
117 116
        : Parent(*adaptor._digraph) {}
118

	
119 117
      NodeMap(const Adaptor& adaptor, const V& value)
120 118
        : Parent(*adaptor._digraph, value) { }
121 119

	
122 120
    private:
123 121
      NodeMap& operator=(const NodeMap& cmap) {
124 122
        return operator=<NodeMap>(cmap);
125 123
      }
126 124

	
127 125
      template <typename CMap>
128 126
      NodeMap& operator=(const CMap& cmap) {
129 127
        Parent::operator=(cmap);
130 128
        return *this;
131 129
      }
132 130

	
133 131
    };
134 132

	
135 133
    template <typename V>
136 134
    class ArcMap : public DGR::template ArcMap<V> {
135
      typedef typename DGR::template ArcMap<V> Parent;
136

	
137 137
    public:
138

	
139
      typedef typename DGR::template ArcMap<V> Parent;
140

	
141 138
      explicit ArcMap(const DigraphAdaptorBase<DGR>& adaptor)
142 139
        : Parent(*adaptor._digraph) {}
143

	
144 140
      ArcMap(const DigraphAdaptorBase<DGR>& adaptor, const V& value)
145 141
        : Parent(*adaptor._digraph, value) {}
146 142

	
147 143
    private:
148 144
      ArcMap& operator=(const ArcMap& cmap) {
149 145
        return operator=<ArcMap>(cmap);
150 146
      }
151 147

	
152 148
      template <typename CMap>
153 149
      ArcMap& operator=(const CMap& cmap) {
154 150
        Parent::operator=(cmap);
155 151
        return *this;
156 152
      }
157 153

	
158 154
    };
159 155

	
160 156
  };
161 157

	
162 158
  template<typename GR>
163 159
  class GraphAdaptorBase {
164 160
  public:
165 161
    typedef GR Graph;
166 162

	
167 163
  protected:
168 164
    GR* _graph;
169 165

	
170 166
    GraphAdaptorBase() : _graph(0) {}
171 167

	
172 168
    void initialize(GR& graph) { _graph = &graph; }
173 169

	
174 170
  public:
175 171
    GraphAdaptorBase(GR& graph) : _graph(&graph) {}
... ...
@@ -226,219 +222,222 @@
226 222

	
227 223
    void erase(const Node& i) { _graph->erase(i); }
228 224
    void erase(const Edge& i) { _graph->erase(i); }
229 225

	
230 226
    void clear() { _graph->clear(); }
231 227

	
232 228
    bool direction(const Arc& a) const { return _graph->direction(a); }
233 229
    Arc direct(const Edge& e, bool d) const { return _graph->direct(e, d); }
234 230

	
235 231
    int id(const Node& v) const { return _graph->id(v); }
236 232
    int id(const Arc& a) const { return _graph->id(a); }
237 233
    int id(const Edge& e) const { return _graph->id(e); }
238 234

	
239 235
    Node nodeFromId(int ix) const { return _graph->nodeFromId(ix); }
240 236
    Arc arcFromId(int ix) const { return _graph->arcFromId(ix); }
241 237
    Edge edgeFromId(int ix) const { return _graph->edgeFromId(ix); }
242 238

	
243 239
    int maxNodeId() const { return _graph->maxNodeId(); }
244 240
    int maxArcId() const { return _graph->maxArcId(); }
245 241
    int maxEdgeId() const { return _graph->maxEdgeId(); }
246 242

	
247 243
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
248 244
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
249 245

	
250 246
    typedef typename ItemSetTraits<GR, Arc>::ItemNotifier ArcNotifier;
251 247
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
252 248

	
253 249
    typedef typename ItemSetTraits<GR, Edge>::ItemNotifier EdgeNotifier;
254 250
    EdgeNotifier& notifier(Edge) const { return _graph->notifier(Edge()); }
255 251

	
256 252
    template <typename V>
257 253
    class NodeMap : public GR::template NodeMap<V> {
254
      typedef typename GR::template NodeMap<V> Parent;
255

	
258 256
    public:
259
      typedef typename GR::template NodeMap<V> Parent;
260 257
      explicit NodeMap(const GraphAdaptorBase<GR>& adapter)
261 258
        : Parent(*adapter._graph) {}
262 259
      NodeMap(const GraphAdaptorBase<GR>& adapter, const V& value)
263 260
        : Parent(*adapter._graph, value) {}
264 261

	
265 262
    private:
266 263
      NodeMap& operator=(const NodeMap& cmap) {
267 264
        return operator=<NodeMap>(cmap);
268 265
      }
269 266

	
270 267
      template <typename CMap>
271 268
      NodeMap& operator=(const CMap& cmap) {
272 269
        Parent::operator=(cmap);
273 270
        return *this;
274 271
      }
275 272

	
276 273
    };
277 274

	
278 275
    template <typename V>
279 276
    class ArcMap : public GR::template ArcMap<V> {
277
      typedef typename GR::template ArcMap<V> Parent;
278

	
280 279
    public:
281
      typedef typename GR::template ArcMap<V> Parent;
282 280
      explicit ArcMap(const GraphAdaptorBase<GR>& adapter)
283 281
        : Parent(*adapter._graph) {}
284 282
      ArcMap(const GraphAdaptorBase<GR>& adapter, const V& value)
285 283
        : Parent(*adapter._graph, value) {}
286 284

	
287 285
    private:
288 286
      ArcMap& operator=(const ArcMap& cmap) {
289 287
        return operator=<ArcMap>(cmap);
290 288
      }
291 289

	
292 290
      template <typename CMap>
293 291
      ArcMap& operator=(const CMap& cmap) {
294 292
        Parent::operator=(cmap);
295 293
        return *this;
296 294
      }
297 295
    };
298 296

	
299 297
    template <typename V>
300 298
    class EdgeMap : public GR::template EdgeMap<V> {
299
      typedef typename GR::template EdgeMap<V> Parent;
300

	
301 301
    public:
302
      typedef typename GR::template EdgeMap<V> Parent;
303 302
      explicit EdgeMap(const GraphAdaptorBase<GR>& adapter)
304 303
        : Parent(*adapter._graph) {}
305 304
      EdgeMap(const GraphAdaptorBase<GR>& adapter, const V& value)
306 305
        : Parent(*adapter._graph, value) {}
307 306

	
308 307
    private:
309 308
      EdgeMap& operator=(const EdgeMap& cmap) {
310 309
        return operator=<EdgeMap>(cmap);
311 310
      }
312 311

	
313 312
      template <typename CMap>
314 313
      EdgeMap& operator=(const CMap& cmap) {
315 314
        Parent::operator=(cmap);
316 315
        return *this;
317 316
      }
318 317
    };
319 318

	
320 319
  };
321 320

	
322 321
  template <typename DGR>
323 322
  class ReverseDigraphBase : public DigraphAdaptorBase<DGR> {
323
    typedef DigraphAdaptorBase<DGR> Parent;
324 324
  public:
325 325
    typedef DGR Digraph;
326
    typedef DigraphAdaptorBase<DGR> Parent;
327 326
  protected:
328 327
    ReverseDigraphBase() : Parent() { }
329 328
  public:
330 329
    typedef typename Parent::Node Node;
331 330
    typedef typename Parent::Arc Arc;
332 331

	
333 332
    void firstIn(Arc& a, const Node& n) const { Parent::firstOut(a, n); }
334 333
    void firstOut(Arc& a, const Node& n ) const { Parent::firstIn(a, n); }
335 334

	
336 335
    void nextIn(Arc& a) const { Parent::nextOut(a); }
337 336
    void nextOut(Arc& a) const { Parent::nextIn(a); }
338 337

	
339 338
    Node source(const Arc& a) const { return Parent::target(a); }
340 339
    Node target(const Arc& a) const { return Parent::source(a); }
341 340

	
342 341
    Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
343 342

	
344 343
    typedef FindArcTagIndicator<DGR> FindArcTag;
345 344
    Arc findArc(const Node& u, const Node& v,
346 345
                const Arc& prev = INVALID) const {
347 346
      return Parent::findArc(v, u, prev);
348 347
    }
349 348

	
350 349
  };
351 350

	
352 351
  /// \ingroup graph_adaptors
353 352
  ///
354 353
  /// \brief Adaptor class for reversing the orientation of the arcs in
355 354
  /// a digraph.
356 355
  ///
357 356
  /// ReverseDigraph can be used for reversing the arcs in a digraph.
358 357
  /// It conforms to the \ref concepts::Digraph "Digraph" concept.
359 358
  ///
360 359
  /// The adapted digraph can also be modified through this adaptor
361 360
  /// by adding or removing nodes or arcs, unless the \c GR template
362 361
  /// parameter is set to be \c const.
363 362
  ///
364 363
  /// \tparam DGR The type of the adapted digraph.
365 364
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
366 365
  /// It can also be specified to be \c const.
367 366
  ///
368 367
  /// \note The \c Node and \c Arc types of this adaptor and the adapted
369 368
  /// digraph are convertible to each other.
370 369
  template<typename DGR>
371 370
#ifdef DOXYGEN
372 371
  class ReverseDigraph {
373 372
#else
374 373
  class ReverseDigraph :
375 374
    public DigraphAdaptorExtender<ReverseDigraphBase<DGR> > {
376 375
#endif
376
    typedef DigraphAdaptorExtender<ReverseDigraphBase<DGR> > Parent;
377 377
  public:
378 378
    /// The type of the adapted digraph.
379 379
    typedef DGR Digraph;
380
    typedef DigraphAdaptorExtender<ReverseDigraphBase<DGR> > Parent;
381 380
  protected:
382 381
    ReverseDigraph() { }
383 382
  public:
384 383

	
385 384
    /// \brief Constructor
386 385
    ///
387 386
    /// Creates a reverse digraph adaptor for the given digraph.
388 387
    explicit ReverseDigraph(DGR& digraph) {
389 388
      Parent::initialize(digraph);
390 389
    }
391 390
  };
392 391

	
393 392
  /// \brief Returns a read-only ReverseDigraph adaptor
394 393
  ///
395 394
  /// This function just returns a read-only \ref ReverseDigraph adaptor.
396 395
  /// \ingroup graph_adaptors
397 396
  /// \relates ReverseDigraph
398 397
  template<typename DGR>
399 398
  ReverseDigraph<const DGR> reverseDigraph(const DGR& digraph) {
400 399
    return ReverseDigraph<const DGR>(digraph);
401 400
  }
402 401

	
403 402

	
404 403
  template <typename DGR, typename NF, typename AF, bool ch = true>
405 404
  class SubDigraphBase : public DigraphAdaptorBase<DGR> {
405
    typedef DigraphAdaptorBase<DGR> Parent;
406 406
  public:
407 407
    typedef DGR Digraph;
408 408
    typedef NF NodeFilterMap;
409 409
    typedef AF ArcFilterMap;
410 410

	
411 411
    typedef SubDigraphBase Adaptor;
412
    typedef DigraphAdaptorBase<DGR> Parent;
413 412
  protected:
414 413
    NF* _node_filter;
415 414
    AF* _arc_filter;
416 415
    SubDigraphBase()
417 416
      : Parent(), _node_filter(0), _arc_filter(0) { }
418 417

	
419 418
    void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
420 419
      Parent::initialize(digraph);
421 420
      _node_filter = &node_filter;
422 421
      _arc_filter = &arc_filter;      
423 422
    }
424 423

	
425 424
  public:
426 425

	
427 426
    typedef typename Parent::Node Node;
428 427
    typedef typename Parent::Arc Arc;
429 428

	
430 429
    void first(Node& i) const {
431 430
      Parent::first(i);
432 431
      while (i != INVALID && !(*_node_filter)[i]) Parent::next(i);
433 432
    }
434 433

	
435 434
    void first(Arc& i) const {
436 435
      Parent::first(i);
437 436
      while (i != INVALID && (!(*_arc_filter)[i]
438 437
                              || !(*_node_filter)[Parent::source(i)]
439 438
                              || !(*_node_filter)[Parent::target(i)]))
440 439
        Parent::next(i);
441 440
    }
442 441

	
443 442
    void firstIn(Arc& i, const Node& n) const {
444 443
      Parent::firstIn(i, n);
... ...
@@ -480,124 +479,126 @@
480 479
                              || !(*_node_filter)[Parent::target(i)]))
481 480
        Parent::nextOut(i);
482 481
    }
483 482

	
484 483
    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
485 484
    void status(const Arc& a, bool v) const { _arc_filter->set(a, v); }
486 485

	
487 486
    bool status(const Node& n) const { return (*_node_filter)[n]; }
488 487
    bool status(const Arc& a) const { return (*_arc_filter)[a]; }
489 488

	
490 489
    typedef False NodeNumTag;
491 490
    typedef False ArcNumTag;
492 491

	
493 492
    typedef FindArcTagIndicator<DGR> FindArcTag;
494 493
    Arc findArc(const Node& source, const Node& target,
495 494
                const Arc& prev = INVALID) const {
496 495
      if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
497 496
        return INVALID;
498 497
      }
499 498
      Arc arc = Parent::findArc(source, target, prev);
500 499
      while (arc != INVALID && !(*_arc_filter)[arc]) {
501 500
        arc = Parent::findArc(source, target, arc);
502 501
      }
503 502
      return arc;
504 503
    }
505 504

	
506 505
  public:
507 506

	
508 507
    template <typename V>
509 508
    class NodeMap 
510 509
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 
511 510
	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
511
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
512
	LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
513

	
512 514
    public:
513 515
      typedef V Value;
514
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
515
	    LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
516 516

	
517 517
      NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor)
518 518
        : Parent(adaptor) {}
519 519
      NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value)
520 520
        : Parent(adaptor, value) {}
521 521

	
522 522
    private:
523 523
      NodeMap& operator=(const NodeMap& cmap) {
524 524
        return operator=<NodeMap>(cmap);
525 525
      }
526 526

	
527 527
      template <typename CMap>
528 528
      NodeMap& operator=(const CMap& cmap) {
529 529
        Parent::operator=(cmap);
530 530
        return *this;
531 531
      }
532 532
    };
533 533

	
534 534
    template <typename V>
535 535
    class ArcMap 
536 536
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
537 537
	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
538
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
539
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
540

	
538 541
    public:
539 542
      typedef V Value;
540
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
541
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
542 543

	
543 544
      ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor)
544 545
        : Parent(adaptor) {}
545 546
      ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value)
546 547
        : Parent(adaptor, value) {}
547 548

	
548 549
    private:
549 550
      ArcMap& operator=(const ArcMap& cmap) {
550 551
        return operator=<ArcMap>(cmap);
551 552
      }
552 553

	
553 554
      template <typename CMap>
554 555
      ArcMap& operator=(const CMap& cmap) {
555 556
        Parent::operator=(cmap);
556 557
        return *this;
557 558
      }
558 559
    };
559 560

	
560 561
  };
561 562

	
562 563
  template <typename DGR, typename NF, typename AF>
563 564
  class SubDigraphBase<DGR, NF, AF, false>
564 565
    : public DigraphAdaptorBase<DGR> {
566
    typedef DigraphAdaptorBase<DGR> Parent;
565 567
  public:
566 568
    typedef DGR Digraph;
567 569
    typedef NF NodeFilterMap;
568 570
    typedef AF ArcFilterMap;
569 571

	
570 572
    typedef SubDigraphBase Adaptor;
571
    typedef DigraphAdaptorBase<Digraph> Parent;
572 573
  protected:
573 574
    NF* _node_filter;
574 575
    AF* _arc_filter;
575 576
    SubDigraphBase()
576 577
      : Parent(), _node_filter(0), _arc_filter(0) { }
577 578

	
578 579
    void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
579 580
      Parent::initialize(digraph);
580 581
      _node_filter = &node_filter;
581 582
      _arc_filter = &arc_filter;      
582 583
    }
583 584

	
584 585
  public:
585 586

	
586 587
    typedef typename Parent::Node Node;
587 588
    typedef typename Parent::Arc Arc;
588 589

	
589 590
    void first(Node& i) const {
590 591
      Parent::first(i);
591 592
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
592 593
    }
593 594

	
594 595
    void first(Arc& i) const {
595 596
      Parent::first(i);
596 597
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::next(i);
597 598
    }
598 599

	
599 600
    void firstIn(Arc& i, const Node& n) const {
600 601
      Parent::firstIn(i, n);
601 602
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextIn(i);
602 603
    }
603 604

	
... ...
@@ -621,94 +622,96 @@
621 622

	
622 623
    void nextOut(Arc& i) const {
623 624
      Parent::nextOut(i);
624 625
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i);
625 626
    }
626 627

	
627 628
    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
628 629
    void status(const Arc& a, bool v) const { _arc_filter->set(a, v); }
629 630

	
630 631
    bool status(const Node& n) const { return (*_node_filter)[n]; }
631 632
    bool status(const Arc& a) const { return (*_arc_filter)[a]; }
632 633

	
633 634
    typedef False NodeNumTag;
634 635
    typedef False ArcNumTag;
635 636

	
636 637
    typedef FindArcTagIndicator<DGR> FindArcTag;
637 638
    Arc findArc(const Node& source, const Node& target,
638 639
                const Arc& prev = INVALID) const {
639 640
      if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
640 641
        return INVALID;
641 642
      }
642 643
      Arc arc = Parent::findArc(source, target, prev);
643 644
      while (arc != INVALID && !(*_arc_filter)[arc]) {
644 645
        arc = Parent::findArc(source, target, arc);
645 646
      }
646 647
      return arc;
647 648
    }
648 649

	
649 650
    template <typename V>
650 651
    class NodeMap 
651 652
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
652 653
          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
654
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 
655
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
656

	
653 657
    public:
654 658
      typedef V Value;
655
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 
656
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
657 659

	
658 660
      NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor)
659 661
        : Parent(adaptor) {}
660 662
      NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value)
661 663
        : Parent(adaptor, value) {}
662 664

	
663 665
    private:
664 666
      NodeMap& operator=(const NodeMap& cmap) {
665 667
        return operator=<NodeMap>(cmap);
666 668
      }
667 669

	
668 670
      template <typename CMap>
669 671
      NodeMap& operator=(const CMap& cmap) {
670 672
        Parent::operator=(cmap);
671 673
        return *this;
672 674
      }
673 675
    };
674 676

	
675 677
    template <typename V>
676 678
    class ArcMap 
677 679
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
678 680
          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
681
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
682
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
683

	
679 684
    public:
680 685
      typedef V Value;
681
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
682
          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
683 686

	
684 687
      ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor)
685 688
        : Parent(adaptor) {}
686 689
      ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value)
687 690
        : Parent(adaptor, value) {}
688 691

	
689 692
    private:
690 693
      ArcMap& operator=(const ArcMap& cmap) {
691 694
        return operator=<ArcMap>(cmap);
692 695
      }
693 696

	
694 697
      template <typename CMap>
695 698
      ArcMap& operator=(const CMap& cmap) {
696 699
        Parent::operator=(cmap);
697 700
        return *this;
698 701
      }
699 702
    };
700 703

	
701 704
  };
702 705

	
703 706
  /// \ingroup graph_adaptors
704 707
  ///
705 708
  /// \brief Adaptor class for hiding nodes and arcs in a digraph
706 709
  ///
707 710
  /// SubDigraph can be used for hiding nodes and arcs in a digraph.
708 711
  /// A \c bool node map and a \c bool arc map must be specified, which
709 712
  /// define the filters for nodes and arcs.
710 713
  /// Only the nodes and arcs with \c true filter value are
711 714
  /// shown in the subdigraph. The arcs that are incident to hidden
712 715
  /// nodes are also filtered out.
713 716
  /// This adaptor conforms to the \ref concepts::Digraph "Digraph" concept.
714 717
  ///
... ...
@@ -834,71 +837,71 @@
834 837
             NF& node_filter, AF& arc_filter) {
835 838
    return SubDigraph<const DGR, NF, AF>
836 839
      (digraph, node_filter, arc_filter);
837 840
  }
838 841

	
839 842
  template<typename DGR, typename NF, typename AF>
840 843
  SubDigraph<const DGR, const NF, AF>
841 844
  subDigraph(const DGR& digraph,
842 845
             const NF& node_filter, AF& arc_filter) {
843 846
    return SubDigraph<const DGR, const NF, AF>
844 847
      (digraph, node_filter, arc_filter);
845 848
  }
846 849

	
847 850
  template<typename DGR, typename NF, typename AF>
848 851
  SubDigraph<const DGR, NF, const AF>
849 852
  subDigraph(const DGR& digraph,
850 853
             NF& node_filter, const AF& arc_filter) {
851 854
    return SubDigraph<const DGR, NF, const AF>
852 855
      (digraph, node_filter, arc_filter);
853 856
  }
854 857

	
855 858
  template<typename DGR, typename NF, typename AF>
856 859
  SubDigraph<const DGR, const NF, const AF>
857 860
  subDigraph(const DGR& digraph,
858 861
             const NF& node_filter, const AF& arc_filter) {
859 862
    return SubDigraph<const DGR, const NF, const AF>
860 863
      (digraph, node_filter, arc_filter);
861 864
  }
862 865

	
863 866

	
864 867
  template <typename GR, typename NF, typename EF, bool ch = true>
865 868
  class SubGraphBase : public GraphAdaptorBase<GR> {
869
    typedef GraphAdaptorBase<GR> Parent;
866 870
  public:
867 871
    typedef GR Graph;
868 872
    typedef NF NodeFilterMap;
869 873
    typedef EF EdgeFilterMap;
870 874

	
871 875
    typedef SubGraphBase Adaptor;
872
    typedef GraphAdaptorBase<GR> Parent;
873 876
  protected:
874 877

	
875 878
    NF* _node_filter;
876 879
    EF* _edge_filter;
877 880

	
878 881
    SubGraphBase()
879 882
      : Parent(), _node_filter(0), _edge_filter(0) { }
880 883

	
881 884
    void initialize(GR& graph, NF& node_filter, EF& edge_filter) {
882 885
      Parent::initialize(graph);
883 886
      _node_filter = &node_filter;
884 887
      _edge_filter = &edge_filter;
885 888
    }
886 889

	
887 890
  public:
888 891

	
889 892
    typedef typename Parent::Node Node;
890 893
    typedef typename Parent::Arc Arc;
891 894
    typedef typename Parent::Edge Edge;
892 895

	
893 896
    void first(Node& i) const {
894 897
      Parent::first(i);
895 898
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
896 899
    }
897 900

	
898 901
    void first(Arc& i) const {
899 902
      Parent::first(i);
900 903
      while (i!=INVALID && (!(*_edge_filter)[i]
901 904
                            || !(*_node_filter)[Parent::source(i)]
902 905
                            || !(*_node_filter)[Parent::target(i)]))
903 906
        Parent::next(i);
904 907
    }
... ...
@@ -987,151 +990,154 @@
987 990
    typedef False EdgeNumTag;
988 991

	
989 992
    typedef FindArcTagIndicator<Graph> FindArcTag;
990 993
    Arc findArc(const Node& u, const Node& v,
991 994
                const Arc& prev = INVALID) const {
992 995
      if (!(*_node_filter)[u] || !(*_node_filter)[v]) {
993 996
        return INVALID;
994 997
      }
995 998
      Arc arc = Parent::findArc(u, v, prev);
996 999
      while (arc != INVALID && !(*_edge_filter)[arc]) {
997 1000
        arc = Parent::findArc(u, v, arc);
998 1001
      }
999 1002
      return arc;
1000 1003
    }
1001 1004

	
1002 1005
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
1003 1006
    Edge findEdge(const Node& u, const Node& v,
1004 1007
                  const Edge& prev = INVALID) const {
1005 1008
      if (!(*_node_filter)[u] || !(*_node_filter)[v]) {
1006 1009
        return INVALID;
1007 1010
      }
1008 1011
      Edge edge = Parent::findEdge(u, v, prev);
1009 1012
      while (edge != INVALID && !(*_edge_filter)[edge]) {
1010 1013
        edge = Parent::findEdge(u, v, edge);
1011 1014
      }
1012 1015
      return edge;
1013 1016
    }
1014 1017

	
1015 1018
    template <typename V>
1016 1019
    class NodeMap 
1017 1020
      : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1018 1021
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
1022
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1023
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
1024

	
1019 1025
    public:
1020 1026
      typedef V Value;
1021
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1022
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
1023 1027

	
1024 1028
      NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor)
1025 1029
        : Parent(adaptor) {}
1026 1030
      NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value)
1027 1031
        : Parent(adaptor, value) {}
1028 1032

	
1029 1033
    private:
1030 1034
      NodeMap& operator=(const NodeMap& cmap) {
1031 1035
        return operator=<NodeMap>(cmap);
1032 1036
      }
1033 1037

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

	
1041 1045
    template <typename V>
1042 1046
    class ArcMap 
1043 1047
      : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1044 1048
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
1049
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1050
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
1051

	
1045 1052
    public:
1046 1053
      typedef V Value;
1047
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1048
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
1049 1054

	
1050 1055
      ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor)
1051 1056
        : Parent(adaptor) {}
1052 1057
      ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value)
1053 1058
        : Parent(adaptor, value) {}
1054 1059

	
1055 1060
    private:
1056 1061
      ArcMap& operator=(const ArcMap& cmap) {
1057 1062
        return operator=<ArcMap>(cmap);
1058 1063
      }
1059 1064

	
1060 1065
      template <typename CMap>
1061 1066
      ArcMap& operator=(const CMap& cmap) {
1062 1067
        Parent::operator=(cmap);
1063 1068
        return *this;
1064 1069
      }
1065 1070
    };
1066 1071

	
1067 1072
    template <typename V>
1068 1073
    class EdgeMap 
1069 1074
      : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1070 1075
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
1076
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1077
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
1078

	
1071 1079
    public:
1072 1080
      typedef V Value;
1073
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1074
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
1075 1081

	
1076 1082
      EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor)
1077 1083
        : Parent(adaptor) {}
1078 1084

	
1079 1085
      EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value)
1080 1086
        : Parent(adaptor, value) {}
1081 1087

	
1082 1088
    private:
1083 1089
      EdgeMap& operator=(const EdgeMap& cmap) {
1084 1090
        return operator=<EdgeMap>(cmap);
1085 1091
      }
1086 1092

	
1087 1093
      template <typename CMap>
1088 1094
      EdgeMap& operator=(const CMap& cmap) {
1089 1095
        Parent::operator=(cmap);
1090 1096
        return *this;
1091 1097
      }
1092 1098
    };
1093 1099

	
1094 1100
  };
1095 1101

	
1096 1102
  template <typename GR, typename NF, typename EF>
1097 1103
  class SubGraphBase<GR, NF, EF, false>
1098 1104
    : public GraphAdaptorBase<GR> {
1105
    typedef GraphAdaptorBase<GR> Parent;
1099 1106
  public:
1100 1107
    typedef GR Graph;
1101 1108
    typedef NF NodeFilterMap;
1102 1109
    typedef EF EdgeFilterMap;
1103 1110

	
1104 1111
    typedef SubGraphBase Adaptor;
1105
    typedef GraphAdaptorBase<GR> Parent;
1106 1112
  protected:
1107 1113
    NF* _node_filter;
1108 1114
    EF* _edge_filter;
1109 1115
    SubGraphBase() 
1110 1116
	  : Parent(), _node_filter(0), _edge_filter(0) { }
1111 1117

	
1112 1118
    void initialize(GR& graph, NF& node_filter, EF& edge_filter) {
1113 1119
      Parent::initialize(graph);
1114 1120
      _node_filter = &node_filter;
1115 1121
      _edge_filter = &edge_filter;
1116 1122
    }
1117 1123

	
1118 1124
  public:
1119 1125

	
1120 1126
    typedef typename Parent::Node Node;
1121 1127
    typedef typename Parent::Arc Arc;
1122 1128
    typedef typename Parent::Edge Edge;
1123 1129

	
1124 1130
    void first(Node& i) const {
1125 1131
      Parent::first(i);
1126 1132
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
1127 1133
    }
1128 1134

	
1129 1135
    void first(Arc& i) const {
1130 1136
      Parent::first(i);
1131 1137
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::next(i);
1132 1138
    }
1133 1139

	
1134 1140
    void first(Edge& i) const {
1135 1141
      Parent::first(i);
1136 1142
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::next(i);
1137 1143
    }
... ...
@@ -1182,120 +1188,123 @@
1182 1188

	
1183 1189
    bool status(const Node& n) const { return (*_node_filter)[n]; }
1184 1190
    bool status(const Edge& e) const { return (*_edge_filter)[e]; }
1185 1191

	
1186 1192
    typedef False NodeNumTag;
1187 1193
    typedef False ArcNumTag;
1188 1194
    typedef False EdgeNumTag;
1189 1195

	
1190 1196
    typedef FindArcTagIndicator<Graph> FindArcTag;
1191 1197
    Arc findArc(const Node& u, const Node& v,
1192 1198
                const Arc& prev = INVALID) const {
1193 1199
      Arc arc = Parent::findArc(u, v, prev);
1194 1200
      while (arc != INVALID && !(*_edge_filter)[arc]) {
1195 1201
        arc = Parent::findArc(u, v, arc);
1196 1202
      }
1197 1203
      return arc;
1198 1204
    }
1199 1205

	
1200 1206
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
1201 1207
    Edge findEdge(const Node& u, const Node& v,
1202 1208
                  const Edge& prev = INVALID) const {
1203 1209
      Edge edge = Parent::findEdge(u, v, prev);
1204 1210
      while (edge != INVALID && !(*_edge_filter)[edge]) {
1205 1211
        edge = Parent::findEdge(u, v, edge);
1206 1212
      }
1207 1213
      return edge;
1208 1214
    }
1209 1215

	
1210 1216
    template <typename V>
1211 1217
    class NodeMap 
1212 1218
      : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1213 1219
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
1220
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1221
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
1222

	
1214 1223
    public:
1215 1224
      typedef V Value;
1216
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1217
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
1218 1225

	
1219 1226
      NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor)
1220 1227
        : Parent(adaptor) {}
1221 1228
      NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value)
1222 1229
        : Parent(adaptor, value) {}
1223 1230

	
1224 1231
    private:
1225 1232
      NodeMap& operator=(const NodeMap& cmap) {
1226 1233
        return operator=<NodeMap>(cmap);
1227 1234
      }
1228 1235

	
1229 1236
      template <typename CMap>
1230 1237
      NodeMap& operator=(const CMap& cmap) {
1231 1238
        Parent::operator=(cmap);
1232 1239
        return *this;
1233 1240
      }
1234 1241
    };
1235 1242

	
1236 1243
    template <typename V>
1237 1244
    class ArcMap 
1238 1245
      : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1239 1246
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
1247
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1248
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
1249

	
1240 1250
    public:
1241 1251
      typedef V Value;
1242
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1243
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
1244 1252

	
1245 1253
      ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor)
1246 1254
        : Parent(adaptor) {}
1247 1255
      ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value)
1248 1256
        : Parent(adaptor, value) {}
1249 1257

	
1250 1258
    private:
1251 1259
      ArcMap& operator=(const ArcMap& cmap) {
1252 1260
        return operator=<ArcMap>(cmap);
1253 1261
      }
1254 1262

	
1255 1263
      template <typename CMap>
1256 1264
      ArcMap& operator=(const CMap& cmap) {
1257 1265
        Parent::operator=(cmap);
1258 1266
        return *this;
1259 1267
      }
1260 1268
    };
1261 1269

	
1262 1270
    template <typename V>
1263 1271
    class EdgeMap 
1264 1272
      : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1265 1273
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
1274
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1275
	LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
1276

	
1266 1277
    public:
1267 1278
      typedef V Value;
1268
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1269
		  LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
1270 1279

	
1271 1280
      EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor)
1272 1281
        : Parent(adaptor) {}
1273 1282

	
1274 1283
      EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value)
1275 1284
        : Parent(adaptor, value) {}
1276 1285

	
1277 1286
    private:
1278 1287
      EdgeMap& operator=(const EdgeMap& cmap) {
1279 1288
        return operator=<EdgeMap>(cmap);
1280 1289
      }
1281 1290

	
1282 1291
      template <typename CMap>
1283 1292
      EdgeMap& operator=(const CMap& cmap) {
1284 1293
        Parent::operator=(cmap);
1285 1294
        return *this;
1286 1295
      }
1287 1296
    };
1288 1297

	
1289 1298
  };
1290 1299

	
1291 1300
  /// \ingroup graph_adaptors
1292 1301
  ///
1293 1302
  /// \brief Adaptor class for hiding nodes and edges in an undirected
1294 1303
  /// graph.
1295 1304
  ///
1296 1305
  /// SubGraph can be used for hiding nodes and edges in a graph.
1297 1306
  /// A \c bool node map and a \c bool edge map must be specified, which
1298 1307
  /// define the filters for nodes and edges.
1299 1308
  /// Only the nodes and edges with \c true filter value are
1300 1309
  /// shown in the subgraph. The edges that are incident to hidden
1301 1310
  /// nodes are also filtered out.
... ...
@@ -1456,135 +1465,138 @@
1456 1465
  /// arcs/edges incident to nodes both with \c true filter value are shown
1457 1466
  /// in the subgraph. This adaptor conforms to the \ref concepts::Digraph
1458 1467
  /// "Digraph" concept or the \ref concepts::Graph "Graph" concept
1459 1468
  /// depending on the \c GR template parameter.
1460 1469
  ///
1461 1470
  /// The adapted (di)graph can also be modified through this adaptor
1462 1471
  /// by adding or removing nodes or arcs/edges, unless the \c GR template
1463 1472
  /// parameter is set to be \c const.
1464 1473
  ///
1465 1474
  /// \tparam GR The type of the adapted digraph or graph.
1466 1475
  /// It must conform to the \ref concepts::Digraph "Digraph" concept
1467 1476
  /// or the \ref concepts::Graph "Graph" concept.
1468 1477
  /// It can also be specified to be \c const.
1469 1478
  /// \tparam NF The type of the node filter map.
1470 1479
  /// It must be a \c bool (or convertible) node map of the
1471 1480
  /// adapted (di)graph. The default type is
1472 1481
  /// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>".
1473 1482
  ///
1474 1483
  /// \note The \c Node and <tt>Arc/Edge</tt> types of this adaptor and the
1475 1484
  /// adapted (di)graph are convertible to each other.
1476 1485
#ifdef DOXYGEN
1477 1486
  template<typename GR, typename NF>
1478 1487
  class FilterNodes {
1479 1488
#else
1480 1489
  template<typename GR,
1481 1490
           typename NF = typename GR::template NodeMap<bool>,
1482 1491
           typename Enable = void>
1483 1492
  class FilterNodes :
1484 1493
    public DigraphAdaptorExtender<
1485 1494
      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >,
1486 1495
                     true> > {
1487 1496
#endif
1488
  public:
1489

	
1490
    typedef GR Digraph;
1491
    typedef NF NodeFilterMap;
1492

	
1493 1497
    typedef DigraphAdaptorExtender<
1494 1498
      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 
1495 1499
                     true> > Parent;
1496 1500

	
1501
  public:
1502

	
1503
    typedef GR Digraph;
1504
    typedef NF NodeFilterMap;
1505

	
1497 1506
    typedef typename Parent::Node Node;
1498 1507

	
1499 1508
  protected:
1500 1509
    ConstMap<typename Digraph::Arc, Const<bool, true> > const_true_map;
1501 1510

	
1502 1511
    FilterNodes() : const_true_map() {}
1503 1512

	
1504 1513
  public:
1505 1514

	
1506 1515
    /// \brief Constructor
1507 1516
    ///
1508 1517
    /// Creates a subgraph for the given digraph or graph with the
1509 1518
    /// given node filter map.
1510 1519
    FilterNodes(GR& graph, NF& node_filter) 
1511 1520
      : Parent(), const_true_map()
1512 1521
    {
1513 1522
      Parent::initialize(graph, node_filter, const_true_map);
1514 1523
    }
1515 1524

	
1516 1525
    /// \brief Sets the status of the given node
1517 1526
    ///
1518 1527
    /// This function sets the status of the given node.
1519 1528
    /// It is done by simply setting the assigned value of \c n
1520 1529
    /// to \c v in the node filter map.
1521 1530
    void status(const Node& n, bool v) const { Parent::status(n, v); }
1522 1531

	
1523 1532
    /// \brief Returns the status of the given node
1524 1533
    ///
1525 1534
    /// This function returns the status of the given node.
1526 1535
    /// It is \c true if the given node is enabled (i.e. not hidden).
1527 1536
    bool status(const Node& n) const { return Parent::status(n); }
1528 1537

	
1529 1538
    /// \brief Disables the given node
1530 1539
    ///
1531 1540
    /// This function disables the given node, so the iteration
1532 1541
    /// jumps over it.
1533 1542
    /// It is the same as \ref status() "status(n, false)".
1534 1543
    void disable(const Node& n) const { Parent::status(n, false); }
1535 1544

	
1536 1545
    /// \brief Enables the given node
1537 1546
    ///
1538 1547
    /// This function enables the given node.
1539 1548
    /// It is the same as \ref status() "status(n, true)".
1540 1549
    void enable(const Node& n) const { Parent::status(n, true); }
1541 1550

	
1542 1551
  };
1543 1552

	
1544 1553
  template<typename GR, typename NF>
1545 1554
  class FilterNodes<GR, NF,
1546 1555
                    typename enable_if<UndirectedTagIndicator<GR> >::type> :
1547 1556
    public GraphAdaptorExtender<
1548 1557
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
1549 1558
                   true> > {
1550 1559

	
1551
  public:
1552
    typedef GR Graph;
1553
    typedef NF NodeFilterMap;
1554 1560
    typedef GraphAdaptorExtender<
1555 1561
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
1556 1562
                   true> > Parent;
1557 1563

	
1564
  public:
1565

	
1566
    typedef GR Graph;
1567
    typedef NF NodeFilterMap;
1568

	
1558 1569
    typedef typename Parent::Node Node;
1570

	
1559 1571
  protected:
1560 1572
    ConstMap<typename GR::Edge, Const<bool, true> > const_true_map;
1561 1573

	
1562 1574
    FilterNodes() : const_true_map() {}
1563 1575

	
1564 1576
  public:
1565 1577

	
1566 1578
    FilterNodes(GR& graph, NodeFilterMap& node_filter) :
1567 1579
      Parent(), const_true_map() {
1568 1580
      Parent::initialize(graph, node_filter, const_true_map);
1569 1581
    }
1570 1582

	
1571 1583
    void status(const Node& n, bool v) const { Parent::status(n, v); }
1572 1584
    bool status(const Node& n) const { return Parent::status(n); }
1573 1585
    void disable(const Node& n) const { Parent::status(n, false); }
1574 1586
    void enable(const Node& n) const { Parent::status(n, true); }
1575 1587

	
1576 1588
  };
1577 1589

	
1578 1590

	
1579 1591
  /// \brief Returns a read-only FilterNodes adaptor
1580 1592
  ///
1581 1593
  /// This function just returns a read-only \ref FilterNodes adaptor.
1582 1594
  /// \ingroup graph_adaptors
1583 1595
  /// \relates FilterNodes
1584 1596
  template<typename GR, typename NF>
1585 1597
  FilterNodes<const GR, NF>
1586 1598
  filterNodes(const GR& graph, NF& node_filter) {
1587 1599
    return FilterNodes<const GR, NF>(graph, node_filter);
1588 1600
  }
1589 1601

	
1590 1602
  template<typename GR, typename NF>
... ...
@@ -1600,74 +1612,75 @@
1600 1612
  /// FilterArcs adaptor can be used for hiding arcs in a digraph.
1601 1613
  /// A \c bool arc map must be specified, which defines the filter for
1602 1614
  /// the arcs. Only the arcs with \c true filter value are shown in the
1603 1615
  /// subdigraph. This adaptor conforms to the \ref concepts::Digraph
1604 1616
  /// "Digraph" concept.
1605 1617
  ///
1606 1618
  /// The adapted digraph can also be modified through this adaptor
1607 1619
  /// by adding or removing nodes or arcs, unless the \c GR template
1608 1620
  /// parameter is set to be \c const.
1609 1621
  ///
1610 1622
  /// \tparam DGR The type of the adapted digraph.
1611 1623
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
1612 1624
  /// It can also be specified to be \c const.
1613 1625
  /// \tparam AF The type of the arc filter map.
1614 1626
  /// It must be a \c bool (or convertible) arc map of the
1615 1627
  /// adapted digraph. The default type is
1616 1628
  /// \ref concepts::Digraph::ArcMap "DGR::ArcMap<bool>".
1617 1629
  ///
1618 1630
  /// \note The \c Node and \c Arc types of this adaptor and the adapted
1619 1631
  /// digraph are convertible to each other.
1620 1632
#ifdef DOXYGEN
1621 1633
  template<typename DGR,
1622 1634
           typename AF>
1623 1635
  class FilterArcs {
1624 1636
#else
1625 1637
  template<typename DGR,
1626 1638
           typename AF = typename DGR::template ArcMap<bool> >
1627 1639
  class FilterArcs :
1628 1640
    public DigraphAdaptorExtender<
1629 1641
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >,
1630 1642
                     AF, false> > {
1631 1643
#endif
1644
    typedef DigraphAdaptorExtender<
1645
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 
1646
                     AF, false> > Parent;
1647

	
1632 1648
  public:
1649

	
1633 1650
    /// The type of the adapted digraph.
1634 1651
    typedef DGR Digraph;
1635 1652
    /// The type of the arc filter map.
1636 1653
    typedef AF ArcFilterMap;
1637 1654

	
1638
    typedef DigraphAdaptorExtender<
1639
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 
1640
                     AF, false> > Parent;
1641

	
1642 1655
    typedef typename Parent::Arc Arc;
1643 1656

	
1644 1657
  protected:
1645 1658
    ConstMap<typename DGR::Node, Const<bool, true> > const_true_map;
1646 1659

	
1647 1660
    FilterArcs() : const_true_map() {}
1648 1661

	
1649 1662
  public:
1650 1663

	
1651 1664
    /// \brief Constructor
1652 1665
    ///
1653 1666
    /// Creates a subdigraph for the given digraph with the given arc
1654 1667
    /// filter map.
1655 1668
    FilterArcs(DGR& digraph, ArcFilterMap& arc_filter)
1656 1669
      : Parent(), const_true_map() {
1657 1670
      Parent::initialize(digraph, const_true_map, arc_filter);
1658 1671
    }
1659 1672

	
1660 1673
    /// \brief Sets the status of the given arc
1661 1674
    ///
1662 1675
    /// This function sets the status of the given arc.
1663 1676
    /// It is done by simply setting the assigned value of \c a
1664 1677
    /// to \c v in the arc filter map.
1665 1678
    void status(const Arc& a, bool v) const { Parent::status(a, v); }
1666 1679

	
1667 1680
    /// \brief Returns the status of the given arc
1668 1681
    ///
1669 1682
    /// This function returns the status of the given arc.
1670 1683
    /// It is \c true if the given arc is enabled (i.e. not hidden).
1671 1684
    bool status(const Arc& a) const { return Parent::status(a); }
1672 1685

	
1673 1686
    /// \brief Disables the given arc
... ...
@@ -1709,74 +1722,75 @@
1709 1722
  /// FilterEdges adaptor can be used for hiding edges in a graph.
1710 1723
  /// A \c bool edge map must be specified, which defines the filter for
1711 1724
  /// the edges. Only the edges with \c true filter value are shown in the
1712 1725
  /// subgraph. This adaptor conforms to the \ref concepts::Graph
1713 1726
  /// "Graph" concept.
1714 1727
  ///
1715 1728
  /// The adapted graph can also be modified through this adaptor
1716 1729
  /// by adding or removing nodes or edges, unless the \c GR template
1717 1730
  /// parameter is set to be \c const.
1718 1731
  ///
1719 1732
  /// \tparam GR The type of the adapted graph.
1720 1733
  /// It must conform to the \ref concepts::Graph "Graph" concept.
1721 1734
  /// It can also be specified to be \c const.
1722 1735
  /// \tparam EF The type of the edge filter map.
1723 1736
  /// It must be a \c bool (or convertible) edge map of the
1724 1737
  /// adapted graph. The default type is
1725 1738
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
1726 1739
  ///
1727 1740
  /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the
1728 1741
  /// adapted graph are convertible to each other.
1729 1742
#ifdef DOXYGEN
1730 1743
  template<typename GR,
1731 1744
           typename EF>
1732 1745
  class FilterEdges {
1733 1746
#else
1734 1747
  template<typename GR,
1735 1748
           typename EF = typename GR::template EdgeMap<bool> >
1736 1749
  class FilterEdges :
1737 1750
    public GraphAdaptorExtender<
1738 1751
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, 
1739 1752
                   EF, false> > {
1740 1753
#endif
1754
    typedef GraphAdaptorExtender<
1755
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 
1756
                   EF, false> > Parent;
1757

	
1741 1758
  public:
1759

	
1742 1760
    /// The type of the adapted graph.
1743 1761
    typedef GR Graph;
1744 1762
    /// The type of the edge filter map.
1745 1763
    typedef EF EdgeFilterMap;
1746 1764

	
1747
    typedef GraphAdaptorExtender<
1748
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 
1749
                   EF, false> > Parent;
1750

	
1751 1765
    typedef typename Parent::Edge Edge;
1752 1766

	
1753 1767
  protected:
1754 1768
    ConstMap<typename GR::Node, Const<bool, true> > const_true_map;
1755 1769

	
1756 1770
    FilterEdges() : const_true_map(true) {
1757 1771
      Parent::setNodeFilterMap(const_true_map);
1758 1772
    }
1759 1773

	
1760 1774
  public:
1761 1775

	
1762 1776
    /// \brief Constructor
1763 1777
    ///
1764 1778
    /// Creates a subgraph for the given graph with the given edge
1765 1779
    /// filter map.
1766 1780
    FilterEdges(GR& graph, EF& edge_filter) 
1767 1781
      : Parent(), const_true_map() {
1768 1782
      Parent::initialize(graph, const_true_map, edge_filter);
1769 1783
    }
1770 1784

	
1771 1785
    /// \brief Sets the status of the given edge
1772 1786
    ///
1773 1787
    /// This function sets the status of the given edge.
1774 1788
    /// It is done by simply setting the assigned value of \c e
1775 1789
    /// to \c v in the edge filter map.
1776 1790
    void status(const Edge& e, bool v) const { Parent::status(e, v); }
1777 1791

	
1778 1792
    /// \brief Returns the status of the given edge
1779 1793
    ///
1780 1794
    /// This function returns the status of the given edge.
1781 1795
    /// It is \c true if the given edge is enabled (i.e. not hidden).
1782 1796
    bool status(const Edge& e) const { return Parent::status(e); }
... ...
@@ -2082,120 +2096,120 @@
2082 2096
          _forward.set(a, value);
2083 2097
        } else {
2084 2098
          _backward.set(a, value);
2085 2099
        }
2086 2100
      }
2087 2101

	
2088 2102
      ConstReturnValue operator[](const Arc& a) const {
2089 2103
        if (direction(a)) {
2090 2104
          return _forward[a];
2091 2105
        } else {
2092 2106
          return _backward[a];
2093 2107
        }
2094 2108
      }
2095 2109

	
2096 2110
      ReturnValue operator[](const Arc& a) {
2097 2111
        if (direction(a)) {
2098 2112
          return _forward[a];
2099 2113
        } else {
2100 2114
          return _backward[a];
2101 2115
        }
2102 2116
      }
2103 2117

	
2104 2118
    protected:
2105 2119

	
2106 2120
      MapImpl _forward, _backward;
2107 2121

	
2108 2122
    };
2109 2123

	
2110 2124
  public:
2111 2125

	
2112 2126
    template <typename V>
2113 2127
    class NodeMap : public DGR::template NodeMap<V> {
2128
      typedef typename DGR::template NodeMap<V> Parent;
2129

	
2114 2130
    public:
2115

	
2116 2131
      typedef V Value;
2117
      typedef typename DGR::template NodeMap<Value> Parent;
2118 2132

	
2119 2133
      explicit NodeMap(const UndirectorBase<DGR>& adaptor)
2120 2134
        : Parent(*adaptor._digraph) {}
2121 2135

	
2122 2136
      NodeMap(const UndirectorBase<DGR>& adaptor, const V& value)
2123 2137
        : Parent(*adaptor._digraph, value) { }
2124 2138

	
2125 2139
    private:
2126 2140
      NodeMap& operator=(const NodeMap& cmap) {
2127 2141
        return operator=<NodeMap>(cmap);
2128 2142
      }
2129 2143

	
2130 2144
      template <typename CMap>
2131 2145
      NodeMap& operator=(const CMap& cmap) {
2132 2146
        Parent::operator=(cmap);
2133 2147
        return *this;
2134 2148
      }
2135 2149

	
2136 2150
    };
2137 2151

	
2138 2152
    template <typename V>
2139 2153
    class ArcMap
2140
      : public SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> >
2141
    {
2154
      : public SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> > {
2155
      typedef SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> > Parent;
2156

	
2142 2157
    public:
2143 2158
      typedef V Value;
2144
      typedef SubMapExtender<Adaptor, ArcMapBase<V> > Parent;
2145 2159

	
2146 2160
      explicit ArcMap(const UndirectorBase<DGR>& adaptor)
2147 2161
        : Parent(adaptor) {}
2148 2162

	
2149 2163
      ArcMap(const UndirectorBase<DGR>& adaptor, const V& value)
2150 2164
        : Parent(adaptor, value) {}
2151 2165

	
2152 2166
    private:
2153 2167
      ArcMap& operator=(const ArcMap& cmap) {
2154 2168
        return operator=<ArcMap>(cmap);
2155 2169
      }
2156 2170

	
2157 2171
      template <typename CMap>
2158 2172
      ArcMap& operator=(const CMap& cmap) {
2159 2173
        Parent::operator=(cmap);
2160 2174
        return *this;
2161 2175
      }
2162 2176
    };
2163 2177

	
2164 2178
    template <typename V>
2165 2179
    class EdgeMap : public Digraph::template ArcMap<V> {
2180
      typedef typename Digraph::template ArcMap<V> Parent;
2181

	
2166 2182
    public:
2167

	
2168 2183
      typedef V Value;
2169
      typedef typename Digraph::template ArcMap<V> Parent;
2170 2184

	
2171 2185
      explicit EdgeMap(const UndirectorBase<DGR>& adaptor)
2172 2186
        : Parent(*adaptor._digraph) {}
2173 2187

	
2174 2188
      EdgeMap(const UndirectorBase<DGR>& adaptor, const V& value)
2175 2189
        : Parent(*adaptor._digraph, value) {}
2176 2190

	
2177 2191
    private:
2178 2192
      EdgeMap& operator=(const EdgeMap& cmap) {
2179 2193
        return operator=<EdgeMap>(cmap);
2180 2194
      }
2181 2195

	
2182 2196
      template <typename CMap>
2183 2197
      EdgeMap& operator=(const CMap& cmap) {
2184 2198
        Parent::operator=(cmap);
2185 2199
        return *this;
2186 2200
      }
2187 2201

	
2188 2202
    };
2189 2203

	
2190 2204
    typedef typename ItemSetTraits<DGR, Node>::ItemNotifier NodeNotifier;
2191 2205
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
2192 2206

	
2193 2207
    typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier;
2194 2208
    EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
2195 2209
    
2196 2210
    typedef EdgeNotifier ArcNotifier;
2197 2211
    ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); }
2198 2212

	
2199 2213
  protected:
2200 2214

	
2201 2215
    UndirectorBase() : _digraph(0) {}
... ...
@@ -2209,68 +2223,68 @@
2209 2223
  };
2210 2224

	
2211 2225
  /// \ingroup graph_adaptors
2212 2226
  ///
2213 2227
  /// \brief Adaptor class for viewing a digraph as an undirected graph.
2214 2228
  ///
2215 2229
  /// Undirector adaptor can be used for viewing a digraph as an undirected
2216 2230
  /// graph. All arcs of the underlying digraph are showed in the
2217 2231
  /// adaptor as an edge (and also as a pair of arcs, of course).
2218 2232
  /// This adaptor conforms to the \ref concepts::Graph "Graph" concept.
2219 2233
  ///
2220 2234
  /// The adapted digraph can also be modified through this adaptor
2221 2235
  /// by adding or removing nodes or edges, unless the \c GR template
2222 2236
  /// parameter is set to be \c const.
2223 2237
  ///
2224 2238
  /// \tparam DGR The type of the adapted digraph.
2225 2239
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
2226 2240
  /// It can also be specified to be \c const.
2227 2241
  ///
2228 2242
  /// \note The \c Node type of this adaptor and the adapted digraph are
2229 2243
  /// convertible to each other, moreover the \c Edge type of the adaptor
2230 2244
  /// and the \c Arc type of the adapted digraph are also convertible to
2231 2245
  /// each other.
2232 2246
  /// (Thus the \c Arc type of the adaptor is convertible to the \c Arc type
2233 2247
  /// of the adapted digraph.)
2234 2248
  template<typename DGR>
2235 2249
#ifdef DOXYGEN
2236 2250
  class Undirector {
2237 2251
#else
2238 2252
  class Undirector :
2239 2253
    public GraphAdaptorExtender<UndirectorBase<DGR> > {
2240 2254
#endif
2255
    typedef GraphAdaptorExtender<UndirectorBase<DGR> > Parent;
2241 2256
  public:
2242 2257
    /// The type of the adapted digraph.
2243 2258
    typedef DGR Digraph;
2244
    typedef GraphAdaptorExtender<UndirectorBase<DGR> > Parent;
2245 2259
  protected:
2246 2260
    Undirector() { }
2247 2261
  public:
2248 2262

	
2249 2263
    /// \brief Constructor
2250 2264
    ///
2251 2265
    /// Creates an undirected graph from the given digraph.
2252 2266
    Undirector(DGR& digraph) {
2253 2267
      initialize(digraph);
2254 2268
    }
2255 2269

	
2256 2270
    /// \brief Arc map combined from two original arc maps
2257 2271
    ///
2258 2272
    /// This map adaptor class adapts two arc maps of the underlying
2259 2273
    /// digraph to get an arc map of the undirected graph.
2260 2274
    /// Its value type is inherited from the first arc map type (\c FW).
2261 2275
    /// \tparam FW The type of the "foward" arc map.
2262 2276
    /// \tparam BK The type of the "backward" arc map.
2263 2277
    template <typename FW, typename BK>
2264 2278
    class CombinedArcMap {
2265 2279
    public:
2266 2280

	
2267 2281
      /// The key type of the map
2268 2282
      typedef typename Parent::Arc Key;
2269 2283
      /// The value type of the map
2270 2284
      typedef typename FW::Value Value;
2271 2285

	
2272 2286
      typedef typename MapTraits<FW>::ReferenceMapTag ReferenceMapTag;
2273 2287

	
2274 2288
      typedef typename MapTraits<FW>::ReturnValue ReturnValue;
2275 2289
      typedef typename MapTraits<FW>::ConstReturnValue ConstReturnValue;
2276 2290
      typedef typename MapTraits<FW>::ReturnValue Reference;
... ...
@@ -2420,93 +2434,93 @@
2420 2434
    Node addNode() {
2421 2435
      return Node(_graph->addNode());
2422 2436
    }
2423 2437

	
2424 2438
    Arc addArc(const Node& u, const Node& v) {
2425 2439
      Arc arc = _graph->addEdge(u, v);
2426 2440
      _direction->set(arc, _graph->u(arc) == u);
2427 2441
      return arc;
2428 2442
    }
2429 2443

	
2430 2444
    void erase(const Node& i) { _graph->erase(i); }
2431 2445
    void erase(const Arc& i) { _graph->erase(i); }
2432 2446

	
2433 2447
    void clear() { _graph->clear(); }
2434 2448

	
2435 2449
    int id(const Node& v) const { return _graph->id(v); }
2436 2450
    int id(const Arc& e) const { return _graph->id(e); }
2437 2451

	
2438 2452
    Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
2439 2453
    Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
2440 2454

	
2441 2455
    int maxNodeId() const { return _graph->maxNodeId(); }
2442 2456
    int maxArcId() const { return _graph->maxEdgeId(); }
2443 2457

	
2444 2458
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
2445 2459
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
2446 2460

	
2447 2461
    typedef typename ItemSetTraits<GR, Arc>::ItemNotifier ArcNotifier;
2448 2462
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
2449 2463

	
2450 2464
    template <typename V>
2451 2465
    class NodeMap : public GR::template NodeMap<V> {
2466
      typedef typename GR::template NodeMap<V> Parent;
2467

	
2452 2468
    public:
2453 2469

	
2454
      typedef typename GR::template NodeMap<V> Parent;
2455

	
2456 2470
      explicit NodeMap(const OrienterBase<GR, DM>& adapter)
2457 2471
        : Parent(*adapter._graph) {}
2458 2472

	
2459 2473
      NodeMap(const OrienterBase<GR, DM>& adapter, const V& value)
2460 2474
        : Parent(*adapter._graph, value) {}
2461 2475

	
2462 2476
    private:
2463 2477
      NodeMap& operator=(const NodeMap& cmap) {
2464 2478
        return operator=<NodeMap>(cmap);
2465 2479
      }
2466 2480

	
2467 2481
      template <typename CMap>
2468 2482
      NodeMap& operator=(const CMap& cmap) {
2469 2483
        Parent::operator=(cmap);
2470 2484
        return *this;
2471 2485
      }
2472 2486

	
2473 2487
    };
2474 2488

	
2475 2489
    template <typename V>
2476 2490
    class ArcMap : public GR::template EdgeMap<V> {
2491
      typedef typename Graph::template EdgeMap<V> Parent;
2492

	
2477 2493
    public:
2478 2494

	
2479
      typedef typename Graph::template EdgeMap<V> Parent;
2480

	
2481 2495
      explicit ArcMap(const OrienterBase<GR, DM>& adapter)
2482 2496
        : Parent(*adapter._graph) { }
2483 2497

	
2484 2498
      ArcMap(const OrienterBase<GR, DM>& adapter, const V& value)
2485 2499
        : Parent(*adapter._graph, value) { }
2486 2500

	
2487 2501
    private:
2488 2502
      ArcMap& operator=(const ArcMap& cmap) {
2489 2503
        return operator=<ArcMap>(cmap);
2490 2504
      }
2491 2505

	
2492 2506
      template <typename CMap>
2493 2507
      ArcMap& operator=(const CMap& cmap) {
2494 2508
        Parent::operator=(cmap);
2495 2509
        return *this;
2496 2510
      }
2497 2511
    };
2498 2512

	
2499 2513

	
2500 2514

	
2501 2515
  protected:
2502 2516
    Graph* _graph;
2503 2517
    DM* _direction;
2504 2518

	
2505 2519
    void initialize(GR& graph, DM& direction) {
2506 2520
      _graph = &graph;
2507 2521
      _direction = &direction;
2508 2522
    }
2509 2523

	
2510 2524
  };
2511 2525

	
2512 2526
  /// \ingroup graph_adaptors
... ...
@@ -2517,75 +2531,77 @@
2517 2531
  /// get a digraph. A \c bool edge map of the underlying graph must be
2518 2532
  /// specified, which define the direction of the arcs in the adaptor.
2519 2533
  /// The arcs can be easily reversed by the \c reverseArc() member function
2520 2534
  /// of the adaptor.
2521 2535
  /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
2522 2536
  ///
2523 2537
  /// The adapted graph can also be modified through this adaptor
2524 2538
  /// by adding or removing nodes or arcs, unless the \c GR template
2525 2539
  /// parameter is set to be \c const.
2526 2540
  ///
2527 2541
  /// \tparam GR The type of the adapted graph.
2528 2542
  /// It must conform to the \ref concepts::Graph "Graph" concept.
2529 2543
  /// It can also be specified to be \c const.
2530 2544
  /// \tparam DM The type of the direction map.
2531 2545
  /// It must be a \c bool (or convertible) edge map of the
2532 2546
  /// adapted graph. The default type is
2533 2547
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
2534 2548
  ///
2535 2549
  /// \note The \c Node type of this adaptor and the adapted graph are
2536 2550
  /// convertible to each other, moreover the \c Arc type of the adaptor
2537 2551
  /// and the \c Edge type of the adapted graph are also convertible to
2538 2552
  /// each other.
2539 2553
#ifdef DOXYGEN
2540 2554
  template<typename GR,
2541 2555
           typename DM>
2542 2556
  class Orienter {
2543 2557
#else
2544 2558
  template<typename GR,
2545 2559
           typename DM = typename GR::template EdgeMap<bool> >
2546 2560
  class Orienter :
2547 2561
    public DigraphAdaptorExtender<OrienterBase<GR, DM> > {
2548 2562
#endif
2563
    typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent;
2549 2564
  public:
2550 2565

	
2551 2566
    /// The type of the adapted graph.
2552 2567
    typedef GR Graph;
2553 2568
    /// The type of the direction edge map.
2554 2569
    typedef DM DirectionMap;
2555 2570

	
2556
    typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent;
2557 2571
    typedef typename Parent::Arc Arc;
2572

	
2558 2573
  protected:
2559 2574
    Orienter() { }
2575

	
2560 2576
  public:
2561 2577

	
2562 2578
    /// \brief Constructor
2563 2579
    ///
2564 2580
    /// Constructor of the adaptor.
2565 2581
    Orienter(GR& graph, DM& direction) {
2566 2582
      Parent::initialize(graph, direction);
2567 2583
    }
2568 2584

	
2569 2585
    /// \brief Reverses the given arc
2570 2586
    ///
2571 2587
    /// This function reverses the given arc.
2572 2588
    /// It is done by simply negate the assigned value of \c a
2573 2589
    /// in the direction map.
2574 2590
    void reverseArc(const Arc& a) {
2575 2591
      Parent::reverseArc(a);
2576 2592
    }
2577 2593
  };
2578 2594

	
2579 2595
  /// \brief Returns a read-only Orienter adaptor
2580 2596
  ///
2581 2597
  /// This function just returns a read-only \ref Orienter adaptor.
2582 2598
  /// \ingroup graph_adaptors
2583 2599
  /// \relates Orienter
2584 2600
  template<typename GR, typename DM>
2585 2601
  Orienter<const GR, DM>
2586 2602
  orienter(const GR& graph, DM& direction) {
2587 2603
    return Orienter<const GR, DM>(graph, direction);
2588 2604
  }
2589 2605

	
2590 2606
  template<typename GR, typename DM>
2591 2607
  Orienter<const GR, const DM>
... ...
@@ -2837,68 +2853,69 @@
2837 2853
        : _adaptor(&adaptor) {}
2838 2854

	
2839 2855
      /// Returns the value associated with the given residual arc
2840 2856
      Value operator[](const Arc& a) const {
2841 2857
        return _adaptor->residualCapacity(a);
2842 2858
      }
2843 2859

	
2844 2860
    };
2845 2861

	
2846 2862
    /// \brief Returns a residual capacity map
2847 2863
    ///
2848 2864
    /// This function just returns a residual capacity map.
2849 2865
    ResidualCapacity residualCapacity() const {
2850 2866
      return ResidualCapacity(*this);
2851 2867
    }
2852 2868

	
2853 2869
  };
2854 2870

	
2855 2871
  /// \brief Returns a (read-only) Residual adaptor
2856 2872
  ///
2857 2873
  /// This function just returns a (read-only) \ref ResidualDigraph adaptor.
2858 2874
  /// \ingroup graph_adaptors
2859 2875
  /// \relates ResidualDigraph
2860 2876
    template<typename DGR, typename CM, typename FM>
2861 2877
  ResidualDigraph<DGR, CM, FM>
2862 2878
  residualDigraph(const DGR& digraph, const CM& capacity_map, FM& flow_map) {
2863 2879
    return ResidualDigraph<DGR, CM, FM> (digraph, capacity_map, flow_map);
2864 2880
  }
2865 2881

	
2866 2882

	
2867 2883
  template <typename DGR>
2868 2884
  class SplitNodesBase {
2885
    typedef DigraphAdaptorBase<const DGR> Parent;
2886

	
2869 2887
  public:
2870 2888

	
2871 2889
    typedef DGR Digraph;
2872
    typedef DigraphAdaptorBase<const DGR> Parent;
2873 2890
    typedef SplitNodesBase Adaptor;
2874 2891

	
2875 2892
    typedef typename DGR::Node DigraphNode;
2876 2893
    typedef typename DGR::Arc DigraphArc;
2877 2894

	
2878 2895
    class Node;
2879 2896
    class Arc;
2880 2897

	
2881 2898
  private:
2882 2899

	
2883 2900
    template <typename T> class NodeMapBase;
2884 2901
    template <typename T> class ArcMapBase;
2885 2902

	
2886 2903
  public:
2887 2904

	
2888 2905
    class Node : public DigraphNode {
2889 2906
      friend class SplitNodesBase;
2890 2907
      template <typename T> friend class NodeMapBase;
2891 2908
    private:
2892 2909

	
2893 2910
      bool _in;
2894 2911
      Node(DigraphNode node, bool in)
2895 2912
        : DigraphNode(node), _in(in) {}
2896 2913

	
2897 2914
    public:
2898 2915

	
2899 2916
      Node() {}
2900 2917
      Node(Invalid) : DigraphNode(INVALID), _in(true) {}
2901 2918

	
2902 2919
      bool operator==(const Node& node) const {
2903 2920
        return DigraphNode::operator==(node) && _in == node._in;
2904 2921
      }
... ...
@@ -3199,95 +3216,95 @@
3199 3216
        if (SplitNodesBase<DGR>::origArc(key)) {
3200 3217
          _arc_map.set(static_cast<const DigraphArc&>(key), val);
3201 3218
        } else {
3202 3219
          _node_map.set(static_cast<const DigraphNode&>(key), val);
3203 3220
        }
3204 3221
      }
3205 3222

	
3206 3223
      ReturnValue operator[](const Arc& key) {
3207 3224
        if (SplitNodesBase<DGR>::origArc(key)) {
3208 3225
          return _arc_map[static_cast<const DigraphArc&>(key)];
3209 3226
        } else {
3210 3227
          return _node_map[static_cast<const DigraphNode&>(key)];
3211 3228
        }
3212 3229
      }
3213 3230

	
3214 3231
      ConstReturnValue operator[](const Arc& key) const {
3215 3232
        if (SplitNodesBase<DGR>::origArc(key)) {
3216 3233
          return _arc_map[static_cast<const DigraphArc&>(key)];
3217 3234
        } else {
3218 3235
          return _node_map[static_cast<const DigraphNode&>(key)];
3219 3236
        }
3220 3237
      }
3221 3238

	
3222 3239
    private:
3223 3240
      ArcImpl _arc_map;
3224 3241
      NodeImpl _node_map;
3225 3242
    };
3226 3243

	
3227 3244
  public:
3228 3245

	
3229 3246
    template <typename V>
3230 3247
    class NodeMap
3231
      : public SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> >
3232
    {
3248
      : public SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> > {
3249
      typedef SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> > Parent;
3250

	
3233 3251
    public:
3234 3252
      typedef V Value;
3235
      typedef SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<Value> > Parent;
3236 3253

	
3237 3254
      NodeMap(const SplitNodesBase<DGR>& adaptor)
3238 3255
        : Parent(adaptor) {}
3239 3256

	
3240 3257
      NodeMap(const SplitNodesBase<DGR>& adaptor, const V& value)
3241 3258
        : Parent(adaptor, value) {}
3242 3259

	
3243 3260
    private:
3244 3261
      NodeMap& operator=(const NodeMap& cmap) {
3245 3262
        return operator=<NodeMap>(cmap);
3246 3263
      }
3247 3264

	
3248 3265
      template <typename CMap>
3249 3266
      NodeMap& operator=(const CMap& cmap) {
3250 3267
        Parent::operator=(cmap);
3251 3268
        return *this;
3252 3269
      }
3253 3270
    };
3254 3271

	
3255 3272
    template <typename V>
3256 3273
    class ArcMap
3257
      : public SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> >
3258
    {
3274
      : public SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> > {
3275
      typedef SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> > Parent;
3276

	
3259 3277
    public:
3260 3278
      typedef V Value;
3261
      typedef SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<Value> > Parent;
3262 3279

	
3263 3280
      ArcMap(const SplitNodesBase<DGR>& adaptor)
3264 3281
        : Parent(adaptor) {}
3265 3282

	
3266 3283
      ArcMap(const SplitNodesBase<DGR>& adaptor, const V& value)
3267 3284
        : Parent(adaptor, value) {}
3268 3285

	
3269 3286
    private:
3270 3287
      ArcMap& operator=(const ArcMap& cmap) {
3271 3288
        return operator=<ArcMap>(cmap);
3272 3289
      }
3273 3290

	
3274 3291
      template <typename CMap>
3275 3292
      ArcMap& operator=(const CMap& cmap) {
3276 3293
        Parent::operator=(cmap);
3277 3294
        return *this;
3278 3295
      }
3279 3296
    };
3280 3297

	
3281 3298
  protected:
3282 3299

	
3283 3300
    SplitNodesBase() : _digraph(0) {}
3284 3301

	
3285 3302
    DGR* _digraph;
3286 3303

	
3287 3304
    void initialize(Digraph& digraph) {
3288 3305
      _digraph = &digraph;
3289 3306
    }
3290 3307

	
3291 3308
  };
3292 3309

	
3293 3310
  /// \ingroup graph_adaptors
... ...
@@ -3295,67 +3312,68 @@
3295 3312
  /// \brief Adaptor class for splitting the nodes of a digraph.
3296 3313
  ///
3297 3314
  /// SplitNodes adaptor can be used for splitting each node into an
3298 3315
  /// \e in-node and an \e out-node in a digraph. Formaly, the adaptor
3299 3316
  /// replaces each node \f$ u \f$ in the digraph with two nodes,
3300 3317
  /// namely node \f$ u_{in} \f$ and node \f$ u_{out} \f$.
3301 3318
  /// If there is a \f$ (v, u) \f$ arc in the original digraph, then the
3302 3319
  /// new target of the arc will be \f$ u_{in} \f$ and similarly the
3303 3320
  /// source of each original \f$ (u, v) \f$ arc will be \f$ u_{out} \f$.
3304 3321
  /// The adaptor adds an additional \e bind \e arc from \f$ u_{in} \f$
3305 3322
  /// to \f$ u_{out} \f$ for each node \f$ u \f$ of the original digraph.
3306 3323
  ///
3307 3324
  /// The aim of this class is running an algorithm with respect to node
3308 3325
  /// costs or capacities if the algorithm considers only arc costs or
3309 3326
  /// capacities directly.
3310 3327
  /// In this case you can use \c SplitNodes adaptor, and set the node
3311 3328
  /// costs/capacities of the original digraph to the \e bind \e arcs
3312 3329
  /// in the adaptor.
3313 3330
  ///
3314 3331
  /// \tparam DGR The type of the adapted digraph.
3315 3332
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
3316 3333
  /// It is implicitly \c const.
3317 3334
  ///
3318 3335
  /// \note The \c Node type of this adaptor is converible to the \c Node
3319 3336
  /// type of the adapted digraph.
3320 3337
  template <typename DGR>
3321 3338
#ifdef DOXYGEN
3322 3339
  class SplitNodes {
3323 3340
#else
3324 3341
  class SplitNodes
3325 3342
    : public DigraphAdaptorExtender<SplitNodesBase<const DGR> > {
3326 3343
#endif
3344
    typedef DigraphAdaptorExtender<SplitNodesBase<const DGR> > Parent;
3345

	
3327 3346
  public:
3328 3347
    typedef DGR Digraph;
3329
    typedef DigraphAdaptorExtender<SplitNodesBase<const DGR> > Parent;
3330 3348

	
3331 3349
    typedef typename DGR::Node DigraphNode;
3332 3350
    typedef typename DGR::Arc DigraphArc;
3333 3351

	
3334 3352
    typedef typename Parent::Node Node;
3335 3353
    typedef typename Parent::Arc Arc;
3336 3354

	
3337 3355
    /// \brief Constructor
3338 3356
    ///
3339 3357
    /// Constructor of the adaptor.
3340 3358
    SplitNodes(const DGR& g) {
3341 3359
      Parent::initialize(g);
3342 3360
    }
3343 3361

	
3344 3362
    /// \brief Returns \c true if the given node is an in-node.
3345 3363
    ///
3346 3364
    /// Returns \c true if the given node is an in-node.
3347 3365
    static bool inNode(const Node& n) {
3348 3366
      return Parent::inNode(n);
3349 3367
    }
3350 3368

	
3351 3369
    /// \brief Returns \c true if the given node is an out-node.
3352 3370
    ///
3353 3371
    /// Returns \c true if the given node is an out-node.
3354 3372
    static bool outNode(const Node& n) {
3355 3373
      return Parent::outNode(n);
3356 3374
    }
3357 3375

	
3358 3376
    /// \brief Returns \c true if the given arc is an original arc.
3359 3377
    ///
3360 3378
    /// Returns \c true if the given arc is one of the arcs in the
3361 3379
    /// original digraph.
Ignore white space 6 line context
... ...
@@ -18,109 +18,113 @@
18 18

	
19 19
#ifndef LEMON_BITS_ARRAY_MAP_H
20 20
#define LEMON_BITS_ARRAY_MAP_H
21 21

	
22 22
#include <memory>
23 23

	
24 24
#include <lemon/bits/traits.h>
25 25
#include <lemon/bits/alteration_notifier.h>
26 26
#include <lemon/concept_check.h>
27 27
#include <lemon/concepts/maps.h>
28 28

	
29 29
// \ingroup graphbits
30 30
// \file
31 31
// \brief Graph map based on the array storage.
32 32

	
33 33
namespace lemon {
34 34

	
35 35
  // \ingroup graphbits
36 36
  //
37 37
  // \brief Graph map based on the array storage.
38 38
  //
39 39
  // The ArrayMap template class is graph map structure that automatically
40 40
  // updates the map when a key is added to or erased from the graph.
41 41
  // This map uses the allocators to implement the container functionality.
42 42
  //
43 43
  // The template parameters are the Graph, the current Item type and
44 44
  // the Value type of the map.
45 45
  template <typename _Graph, typename _Item, typename _Value>
46 46
  class ArrayMap
47 47
    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
48 48
  public:
49 49
    // The graph type.
50
    typedef _Graph Graph;
50
    typedef _Graph GraphType;
51 51
    // The item type.
52 52
    typedef _Item Item;
53 53
    // The reference map tag.
54 54
    typedef True ReferenceMapTag;
55 55

	
56 56
    // The key type of the map.
57 57
    typedef _Item Key;
58 58
    // The value type of the map.
59 59
    typedef _Value Value;
60 60

	
61 61
    // The const reference type of the map.
62 62
    typedef const _Value& ConstReference;
63 63
    // The reference type of the map.
64 64
    typedef _Value& Reference;
65 65

	
66
    // The map type.
67
    typedef ArrayMap Map;
68

	
66 69
    // The notifier type.
67 70
    typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
68 71

	
72
  private:
73
  
69 74
    // The MapBase of the Map which imlements the core regisitry function.
70 75
    typedef typename Notifier::ObserverBase Parent;
71 76

	
72
  private:
73 77
    typedef std::allocator<Value> Allocator;
74 78

	
75 79
  public:
76 80

	
77 81
    // \brief Graph initialized map constructor.
78 82
    //
79 83
    // Graph initialized map constructor.
80
    explicit ArrayMap(const Graph& graph) {
84
    explicit ArrayMap(const GraphType& graph) {
81 85
      Parent::attach(graph.notifier(Item()));
82 86
      allocate_memory();
83 87
      Notifier* nf = Parent::notifier();
84 88
      Item it;
85 89
      for (nf->first(it); it != INVALID; nf->next(it)) {
86 90
        int id = nf->id(it);;
87 91
        allocator.construct(&(values[id]), Value());
88 92
      }
89 93
    }
90 94

	
91 95
    // \brief Constructor to use default value to initialize the map.
92 96
    //
93 97
    // It constructs a map and initialize all of the the map.
94
    ArrayMap(const Graph& graph, const Value& value) {
98
    ArrayMap(const GraphType& graph, const Value& value) {
95 99
      Parent::attach(graph.notifier(Item()));
96 100
      allocate_memory();
97 101
      Notifier* nf = Parent::notifier();
98 102
      Item it;
99 103
      for (nf->first(it); it != INVALID; nf->next(it)) {
100 104
        int id = nf->id(it);;
101 105
        allocator.construct(&(values[id]), value);
102 106
      }
103 107
    }
104 108

	
105 109
  private:
106 110
    // \brief Constructor to copy a map of the same map type.
107 111
    //
108 112
    // Constructor to copy a map of the same map type.
109 113
    ArrayMap(const ArrayMap& copy) : Parent() {
110 114
      if (copy.attached()) {
111 115
        attach(*copy.notifier());
112 116
      }
113 117
      capacity = copy.capacity;
114 118
      if (capacity == 0) return;
115 119
      values = allocator.allocate(capacity);
116 120
      Notifier* nf = Parent::notifier();
117 121
      Item it;
118 122
      for (nf->first(it); it != INVALID; nf->next(it)) {
119 123
        int id = nf->id(it);;
120 124
        allocator.construct(&(values[id]), copy.values[id]);
121 125
      }
122 126
    }
123 127

	
124 128
    // \brief Assign operator.
125 129
    //
126 130
    // This operator assigns for each item in the map the
Ignore white space 6 line context
... ...
@@ -9,68 +9,68 @@
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_BITS_BASE_EXTENDER_H
20 20
#define LEMON_BITS_BASE_EXTENDER_H
21 21

	
22 22
#include <lemon/core.h>
23 23
#include <lemon/error.h>
24 24

	
25 25
#include <lemon/bits/map_extender.h>
26 26
#include <lemon/bits/default_map.h>
27 27

	
28 28
#include <lemon/concept_check.h>
29 29
#include <lemon/concepts/maps.h>
30 30

	
31 31
//\ingroup digraphbits
32 32
//\file
33 33
//\brief Extenders for the graph types
34 34
namespace lemon {
35 35

	
36 36
  // \ingroup digraphbits
37 37
  //
38 38
  // \brief BaseDigraph to BaseGraph extender
39 39
  template <typename Base>
40 40
  class UndirDigraphExtender : public Base {
41
    typedef Base Parent;
41 42

	
42 43
  public:
43 44

	
44
    typedef Base Parent;
45 45
    typedef typename Parent::Arc Edge;
46 46
    typedef typename Parent::Node Node;
47 47

	
48 48
    typedef True UndirectedTag;
49 49

	
50 50
    class Arc : public Edge {
51 51
      friend class UndirDigraphExtender;
52 52

	
53 53
    protected:
54 54
      bool forward;
55 55

	
56 56
      Arc(const Edge &ue, bool _forward) :
57 57
        Edge(ue), forward(_forward) {}
58 58

	
59 59
    public:
60 60
      Arc() {}
61 61

	
62 62
      // Invalid arc constructor
63 63
      Arc(Invalid i) : Edge(i), forward(true) {}
64 64

	
65 65
      bool operator==(const Arc &that) const {
66 66
        return forward==that.forward && Edge(*this)==Edge(that);
67 67
      }
68 68
      bool operator!=(const Arc &that) const {
69 69
        return forward!=that.forward || Edge(*this)!=Edge(that);
70 70
      }
71 71
      bool operator<(const Arc &that) const {
72 72
        return forward<that.forward ||
73 73
          (!(that.forward<forward) && Edge(*this)<Edge(that));
74 74
      }
75 75
    };
76 76

	
... ...
@@ -251,66 +251,67 @@
251 251
      } else {
252 252
        Edge arc = Parent::findArc(t, s, p);
253 253
        if (arc != INVALID) return direct(arc, false);
254 254
      }
255 255
      return INVALID;
256 256
    }
257 257

	
258 258
    Edge findEdge(Node s, Node t, Edge p = INVALID) const {
259 259
      if (s != t) {
260 260
        if (p == INVALID) {
261 261
          Edge arc = Parent::findArc(s, t);
262 262
          if (arc != INVALID) return arc;
263 263
          arc = Parent::findArc(t, s);
264 264
          if (arc != INVALID) return arc;
265 265
        } else if (Parent::s(p) == s) {
266 266
          Edge arc = Parent::findArc(s, t, p);
267 267
          if (arc != INVALID) return arc;
268 268
          arc = Parent::findArc(t, s);
269 269
          if (arc != INVALID) return arc;
270 270
        } else {
271 271
          Edge arc = Parent::findArc(t, s, p);
272 272
          if (arc != INVALID) return arc;
273 273
        }
274 274
      } else {
275 275
        return Parent::findArc(s, t, p);
276 276
      }
277 277
      return INVALID;
278 278
    }
279 279
  };
280 280

	
281 281
  template <typename Base>
282 282
  class BidirBpGraphExtender : public Base {
283
    typedef Base Parent;
284

	
283 285
  public:
284
    typedef Base Parent;
285 286
    typedef BidirBpGraphExtender Digraph;
286 287

	
287 288
    typedef typename Parent::Node Node;
288 289
    typedef typename Parent::Edge Edge;
289 290

	
290 291

	
291 292
    using Parent::first;
292 293
    using Parent::next;
293 294

	
294 295
    using Parent::id;
295 296

	
296 297
    class Red : public Node {
297 298
      friend class BidirBpGraphExtender;
298 299
    public:
299 300
      Red() {}
300 301
      Red(const Node& node) : Node(node) {
301 302
        LEMON_DEBUG(Parent::red(node) || node == INVALID,
302 303
                    typename Parent::NodeSetError());
303 304
      }
304 305
      Red& operator=(const Node& node) {
305 306
        LEMON_DEBUG(Parent::red(node) || node == INVALID,
306 307
                    typename Parent::NodeSetError());
307 308
        Node::operator=(node);
308 309
        return *this;
309 310
      }
310 311
      Red(Invalid) : Node(INVALID) {}
311 312
      Red& operator=(Invalid) {
312 313
        Node::operator=(INVALID);
313 314
        return *this;
314 315
      }
315 316
    };
316 317

	
Ignore white space 64 line context
... ...
@@ -124,58 +124,59 @@
124 124
  template <typename _Graph, typename _Item>
125 125
  struct DefaultMapSelector<_Graph, _Item, double> {
126 126
    typedef VectorMap<_Graph, _Item,  double> Map;
127 127
  };
128 128

	
129 129

	
130 130
  // long double
131 131
  template <typename _Graph, typename _Item>
132 132
  struct DefaultMapSelector<_Graph, _Item, long double> {
133 133
    typedef VectorMap<_Graph, _Item, long double> Map;
134 134
  };
135 135

	
136 136

	
137 137
  // pointer
138 138
  template <typename _Graph, typename _Item, typename _Ptr>
139 139
  struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
140 140
    typedef VectorMap<_Graph, _Item, _Ptr*> Map;
141 141
  };
142 142

	
143 143
// #else
144 144

	
145 145
//   template <typename _Graph, typename _Item, typename _Value>
146 146
//   struct DefaultMapSelector {
147 147
//     typedef DebugMap<_Graph, _Item, _Value> Map;
148 148
//   };
149 149

	
150 150
// #endif
151 151

	
152 152
  // DefaultMap class
153 153
  template <typename _Graph, typename _Item, typename _Value>
154 154
  class DefaultMap
155 155
    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
156
    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
157

	
156 158
  public:
157
    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
158 159
    typedef DefaultMap<_Graph, _Item, _Value> Map;
159

	
160
    typedef typename Parent::Graph Graph;
160
    
161
    typedef typename Parent::GraphType GraphType;
161 162
    typedef typename Parent::Value Value;
162 163

	
163
    explicit DefaultMap(const Graph& graph) : Parent(graph) {}
164
    DefaultMap(const Graph& graph, const Value& value)
164
    explicit DefaultMap(const GraphType& graph) : Parent(graph) {}
165
    DefaultMap(const GraphType& graph, const Value& value)
165 166
      : Parent(graph, value) {}
166 167

	
167 168
    DefaultMap& operator=(const DefaultMap& cmap) {
168 169
      return operator=<DefaultMap>(cmap);
169 170
    }
170 171

	
171 172
    template <typename CMap>
172 173
    DefaultMap& operator=(const CMap& cmap) {
173 174
      Parent::operator=(cmap);
174 175
      return *this;
175 176
    }
176 177

	
177 178
  };
178 179

	
179 180
}
180 181

	
181 182
#endif
Ignore white space 6 line context
... ...
@@ -5,67 +5,68 @@
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_BITS_EDGE_SET_EXTENDER_H
20 20
#define LEMON_BITS_EDGE_SET_EXTENDER_H
21 21

	
22 22
#include <lemon/core.h>
23 23
#include <lemon/error.h>
24 24
#include <lemon/bits/default_map.h>
25 25
#include <lemon/bits/map_extender.h>
26 26

	
27 27
//\ingroup digraphbits
28 28
//\file
29 29
//\brief Extenders for the arc set types
30 30
namespace lemon {
31 31

	
32 32
  // \ingroup digraphbits
33 33
  //
34 34
  // \brief Extender for the ArcSets
35 35
  template <typename Base>
36 36
  class ArcSetExtender : public Base {
37
    typedef Base Parent;
38

	
37 39
  public:
38 40

	
39
    typedef Base Parent;
40 41
    typedef ArcSetExtender Digraph;
41 42

	
42 43
    // Base extensions
43 44

	
44 45
    typedef typename Parent::Node Node;
45 46
    typedef typename Parent::Arc Arc;
46 47

	
47 48
    int maxId(Node) const {
48 49
      return Parent::maxNodeId();
49 50
    }
50 51

	
51 52
    int maxId(Arc) const {
52 53
      return Parent::maxArcId();
53 54
    }
54 55

	
55 56
    Node fromId(int id, Node) const {
56 57
      return Parent::nodeFromId(id);
57 58
    }
58 59

	
59 60
    Arc fromId(int id, Arc) const {
60 61
      return Parent::arcFromId(id);
61 62
    }
62 63

	
63 64
    Node oppositeNode(const Node &n, const Arc &e) const {
64 65
      if (n == Parent::source(e))
65 66
	return Parent::target(e);
66 67
      else if(n==Parent::target(e))
67 68
	return Parent::source(e);
68 69
      else
69 70
	return INVALID;
70 71
    }
71 72

	
... ...
@@ -189,131 +190,129 @@
189 190
    Node baseNode(const OutArcIt &e) const {
190 191
      return Parent::source(static_cast<const Arc&>(e));
191 192
    }
192 193
    // \brief Running node of the iterator
193 194
    //
194 195
    // Returns the running node (ie. the target in this case) of the
195 196
    // iterator
196 197
    Node runningNode(const OutArcIt &e) const {
197 198
      return Parent::target(static_cast<const Arc&>(e));
198 199
    }
199 200

	
200 201
    // \brief Base node of the iterator
201 202
    //
202 203
    // Returns the base node (ie. the target in this case) of the iterator
203 204
    Node baseNode(const InArcIt &e) const {
204 205
      return Parent::target(static_cast<const Arc&>(e));
205 206
    }
206 207
    // \brief Running node of the iterator
207 208
    //
208 209
    // Returns the running node (ie. the source in this case) of the
209 210
    // iterator
210 211
    Node runningNode(const InArcIt &e) const {
211 212
      return Parent::source(static_cast<const Arc&>(e));
212 213
    }
213 214

	
214 215
    using Parent::first;
215 216

	
216 217
    // Mappable extension
217 218
    
218 219
    template <typename _Value>
219 220
    class ArcMap 
220 221
      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
221
    public:
222
      typedef ArcSetExtender Digraph;
223 222
      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
224 223

	
224
    public:
225 225
      explicit ArcMap(const Digraph& _g) 
226 226
	: Parent(_g) {}
227 227
      ArcMap(const Digraph& _g, const _Value& _v) 
228 228
	: Parent(_g, _v) {}
229 229

	
230 230
      ArcMap& operator=(const ArcMap& cmap) {
231 231
	return operator=<ArcMap>(cmap);
232 232
      }
233 233

	
234 234
      template <typename CMap>
235 235
      ArcMap& operator=(const CMap& cmap) {
236 236
        Parent::operator=(cmap);
237 237
	return *this;
238 238
      }
239 239

	
240 240
    };
241 241

	
242 242

	
243 243
    // Alteration extension
244 244

	
245 245
    Arc addArc(const Node& from, const Node& to) {
246 246
      Arc arc = Parent::addArc(from, to);
247 247
      notifier(Arc()).add(arc);
248 248
      return arc;
249 249
    }
250 250
    
251 251
    void clear() {
252 252
      notifier(Arc()).clear();
253 253
      Parent::clear();
254 254
    }
255 255

	
256 256
    void erase(const Arc& arc) {
257 257
      notifier(Arc()).erase(arc);
258 258
      Parent::erase(arc);
259 259
    }
260 260

	
261 261
    ArcSetExtender() {
262 262
      arc_notifier.setContainer(*this);
263 263
    }
264 264

	
265 265
    ~ArcSetExtender() {
266 266
      arc_notifier.clear();
267 267
    }
268 268

	
269 269
  };
270 270

	
271 271

	
272 272
  // \ingroup digraphbits
273 273
  //
274 274
  // \brief Extender for the EdgeSets
275 275
  template <typename Base>
276 276
  class EdgeSetExtender : public Base {
277
    typedef Base Parent;
277 278

	
278 279
  public:
279 280

	
280
    typedef Base Parent;
281
    typedef EdgeSetExtender Digraph;
281
    typedef EdgeSetExtender Graph;
282 282

	
283 283
    typedef typename Parent::Node Node;
284 284
    typedef typename Parent::Arc Arc;
285 285
    typedef typename Parent::Edge Edge;
286 286

	
287

	
288 287
    int maxId(Node) const {
289 288
      return Parent::maxNodeId();
290 289
    }
291 290

	
292 291
    int maxId(Arc) const {
293 292
      return Parent::maxArcId();
294 293
    }
295 294

	
296 295
    int maxId(Edge) const {
297 296
      return Parent::maxEdgeId();
298 297
    }
299 298

	
300 299
    Node fromId(int id, Node) const {
301 300
      return Parent::nodeFromId(id);
302 301
    }
303 302

	
304 303
    Arc fromId(int id, Arc) const {
305 304
      return Parent::arcFromId(id);
306 305
    }
307 306

	
308 307
    Edge fromId(int id, Edge) const {
309 308
      return Parent::edgeFromId(id);
310 309
    }
311 310

	
312 311
    Node oppositeNode(const Node &n, const Edge &e) const {
313 312
      if( n == Parent::u(e))
314 313
	return Parent::v(e);
315 314
      else if( n == Parent::v(e))
316 315
	return Parent::u(e);
317 316
      else
318 317
	return INVALID;
319 318
    }
... ...
@@ -321,282 +320,280 @@
321 320
    Arc oppositeArc(const Arc &e) const {
322 321
      return Parent::direct(e, !Parent::direction(e));
323 322
    }
324 323

	
325 324
    using Parent::direct;
326 325
    Arc direct(const Edge &e, const Node &s) const {
327 326
      return Parent::direct(e, Parent::u(e) == s);
328 327
    }
329 328

	
330 329
    typedef AlterationNotifier<EdgeSetExtender, Arc> ArcNotifier;
331 330
    typedef AlterationNotifier<EdgeSetExtender, Edge> EdgeNotifier;
332 331

	
333 332

	
334 333
  protected:
335 334

	
336 335
    mutable ArcNotifier arc_notifier;
337 336
    mutable EdgeNotifier edge_notifier;
338 337

	
339 338
  public:
340 339

	
341 340
    using Parent::notifier;
342 341
    
343 342
    ArcNotifier& notifier(Arc) const {
344 343
      return arc_notifier;
345 344
    }
346 345

	
347 346
    EdgeNotifier& notifier(Edge) const {
348 347
      return edge_notifier;
349 348
    }
350 349

	
351 350

	
352 351
    class NodeIt : public Node { 
353
      const Digraph* digraph;
352
      const Graph* graph;
354 353
    public:
355 354

	
356 355
      NodeIt() {}
357 356

	
358 357
      NodeIt(Invalid i) : Node(i) { }
359 358

	
360
      explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
359
      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
361 360
	_graph.first(static_cast<Node&>(*this));
362 361
      }
363 362

	
364
      NodeIt(const Digraph& _graph, const Node& node) 
365
	: Node(node), digraph(&_graph) {}
363
      NodeIt(const Graph& _graph, const Node& node) 
364
	: Node(node), graph(&_graph) {}
366 365

	
367 366
      NodeIt& operator++() { 
368
	digraph->next(*this);
367
	graph->next(*this);
369 368
	return *this; 
370 369
      }
371 370

	
372 371
    };
373 372

	
374 373

	
375 374
    class ArcIt : public Arc { 
376
      const Digraph* digraph;
375
      const Graph* graph;
377 376
    public:
378 377

	
379 378
      ArcIt() { }
380 379

	
381 380
      ArcIt(Invalid i) : Arc(i) { }
382 381

	
383
      explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
382
      explicit ArcIt(const Graph& _graph) : graph(&_graph) {
384 383
	_graph.first(static_cast<Arc&>(*this));
385 384
      }
386 385

	
387
      ArcIt(const Digraph& _graph, const Arc& e) : 
388
	Arc(e), digraph(&_graph) { }
386
      ArcIt(const Graph& _graph, const Arc& e) : 
387
	Arc(e), graph(&_graph) { }
389 388

	
390 389
      ArcIt& operator++() { 
391
	digraph->next(*this);
390
	graph->next(*this);
392 391
	return *this; 
393 392
      }
394 393

	
395 394
    };
396 395

	
397 396

	
398 397
    class OutArcIt : public Arc { 
399
      const Digraph* digraph;
398
      const Graph* graph;
400 399
    public:
401 400

	
402 401
      OutArcIt() { }
403 402

	
404 403
      OutArcIt(Invalid i) : Arc(i) { }
405 404

	
406
      OutArcIt(const Digraph& _graph, const Node& node) 
407
	: digraph(&_graph) {
405
      OutArcIt(const Graph& _graph, const Node& node) 
406
	: graph(&_graph) {
408 407
	_graph.firstOut(*this, node);
409 408
      }
410 409

	
411
      OutArcIt(const Digraph& _graph, const Arc& arc) 
412
	: Arc(arc), digraph(&_graph) {}
410
      OutArcIt(const Graph& _graph, const Arc& arc) 
411
	: Arc(arc), graph(&_graph) {}
413 412

	
414 413
      OutArcIt& operator++() { 
415
	digraph->nextOut(*this);
414
	graph->nextOut(*this);
416 415
	return *this; 
417 416
      }
418 417

	
419 418
    };
420 419

	
421 420

	
422 421
    class InArcIt : public Arc { 
423
      const Digraph* digraph;
422
      const Graph* graph;
424 423
    public:
425 424

	
426 425
      InArcIt() { }
427 426

	
428 427
      InArcIt(Invalid i) : Arc(i) { }
429 428

	
430
      InArcIt(const Digraph& _graph, const Node& node) 
431
	: digraph(&_graph) {
429
      InArcIt(const Graph& _graph, const Node& node) 
430
	: graph(&_graph) {
432 431
	_graph.firstIn(*this, node);
433 432
      }
434 433

	
435
      InArcIt(const Digraph& _graph, const Arc& arc) : 
436
	Arc(arc), digraph(&_graph) {}
434
      InArcIt(const Graph& _graph, const Arc& arc) : 
435
	Arc(arc), graph(&_graph) {}
437 436

	
438 437
      InArcIt& operator++() { 
439
	digraph->nextIn(*this);
438
	graph->nextIn(*this);
440 439
	return *this; 
441 440
      }
442 441

	
443 442
    };
444 443

	
445 444

	
446 445
    class EdgeIt : public Parent::Edge { 
447
      const Digraph* digraph;
446
      const Graph* graph;
448 447
    public:
449 448

	
450 449
      EdgeIt() { }
451 450

	
452 451
      EdgeIt(Invalid i) : Edge(i) { }
453 452

	
454
      explicit EdgeIt(const Digraph& _graph) : digraph(&_graph) {
453
      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
455 454
	_graph.first(static_cast<Edge&>(*this));
456 455
      }
457 456

	
458
      EdgeIt(const Digraph& _graph, const Edge& e) : 
459
	Edge(e), digraph(&_graph) { }
457
      EdgeIt(const Graph& _graph, const Edge& e) : 
458
	Edge(e), graph(&_graph) { }
460 459

	
461 460
      EdgeIt& operator++() { 
462
	digraph->next(*this);
461
	graph->next(*this);
463 462
	return *this; 
464 463
      }
465 464

	
466 465
    };
467 466

	
468 467
    class IncEdgeIt : public Parent::Edge {
469 468
      friend class EdgeSetExtender;
470
      const Digraph* digraph;
469
      const Graph* graph;
471 470
      bool direction;
472 471
    public:
473 472

	
474 473
      IncEdgeIt() { }
475 474

	
476 475
      IncEdgeIt(Invalid i) : Edge(i), direction(false) { }
477 476

	
478
      IncEdgeIt(const Digraph& _graph, const Node &n) : digraph(&_graph) {
477
      IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
479 478
	_graph.firstInc(*this, direction, n);
480 479
      }
481 480

	
482
      IncEdgeIt(const Digraph& _graph, const Edge &ue, const Node &n)
483
	: digraph(&_graph), Edge(ue) {
481
      IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n)
482
	: graph(&_graph), Edge(ue) {
484 483
	direction = (_graph.source(ue) == n);
485 484
      }
486 485

	
487 486
      IncEdgeIt& operator++() {
488
	digraph->nextInc(*this, direction);
487
	graph->nextInc(*this, direction);
489 488
	return *this; 
490 489
      }
491 490
    };
492 491

	
493 492
    // \brief Base node of the iterator
494 493
    //
495 494
    // Returns the base node (ie. the source in this case) of the iterator
496 495
    Node baseNode(const OutArcIt &e) const {
497 496
      return Parent::source(static_cast<const Arc&>(e));
498 497
    }
499 498
    // \brief Running node of the iterator
500 499
    //
501 500
    // Returns the running node (ie. the target in this case) of the
502 501
    // iterator
503 502
    Node runningNode(const OutArcIt &e) const {
504 503
      return Parent::target(static_cast<const Arc&>(e));
505 504
    }
506 505

	
507 506
    // \brief Base node of the iterator
508 507
    //
509 508
    // Returns the base node (ie. the target in this case) of the iterator
510 509
    Node baseNode(const InArcIt &e) const {
511 510
      return Parent::target(static_cast<const Arc&>(e));
512 511
    }
513 512
    // \brief Running node of the iterator
514 513
    //
515 514
    // Returns the running node (ie. the source in this case) of the
516 515
    // iterator
517 516
    Node runningNode(const InArcIt &e) const {
518 517
      return Parent::source(static_cast<const Arc&>(e));
519 518
    }
520 519

	
521 520
    // Base node of the iterator
522 521
    //
523 522
    // Returns the base node of the iterator
524 523
    Node baseNode(const IncEdgeIt &e) const {
525 524
      return e.direction ? u(e) : v(e);
526 525
    }
527 526
    // Running node of the iterator
528 527
    //
529 528
    // Returns the running node of the iterator
530 529
    Node runningNode(const IncEdgeIt &e) const {
531 530
      return e.direction ? v(e) : u(e);
532 531
    }
533 532

	
534 533

	
535 534
    template <typename _Value>
536 535
    class ArcMap 
537
      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
536
      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
537
      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
538

	
538 539
    public:
539
      typedef EdgeSetExtender Digraph;
540
      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
541

	
542
      ArcMap(const Digraph& _g) 
540
      ArcMap(const Graph& _g) 
543 541
	: Parent(_g) {}
544
      ArcMap(const Digraph& _g, const _Value& _v) 
542
      ArcMap(const Graph& _g, const _Value& _v) 
545 543
	: Parent(_g, _v) {}
546 544

	
547 545
      ArcMap& operator=(const ArcMap& cmap) {
548 546
	return operator=<ArcMap>(cmap);
549 547
      }
550 548

	
551 549
      template <typename CMap>
552 550
      ArcMap& operator=(const CMap& cmap) {
553 551
        Parent::operator=(cmap);
554 552
	return *this;
555 553
      }
556 554

	
557 555
    };
558 556

	
559 557

	
560 558
    template <typename _Value>
561 559
    class EdgeMap 
562
      : public MapExtender<DefaultMap<Digraph, Edge, _Value> > {
560
      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
561
      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
562

	
563 563
    public:
564
      typedef EdgeSetExtender Digraph;
565
      typedef MapExtender<DefaultMap<Digraph, Edge, _Value> > Parent;
566

	
567
      EdgeMap(const Digraph& _g) 
564
      EdgeMap(const Graph& _g) 
568 565
	: Parent(_g) {}
569 566

	
570
      EdgeMap(const Digraph& _g, const _Value& _v) 
567
      EdgeMap(const Graph& _g, const _Value& _v) 
571 568
	: Parent(_g, _v) {}
572 569

	
573 570
      EdgeMap& operator=(const EdgeMap& cmap) {
574 571
	return operator=<EdgeMap>(cmap);
575 572
      }
576 573

	
577 574
      template <typename CMap>
578 575
      EdgeMap& operator=(const CMap& cmap) {
579 576
        Parent::operator=(cmap);
580 577
	return *this;
581 578
      }
582 579

	
583 580
    };
584 581

	
585 582

	
586 583
    // Alteration extension
587 584

	
588 585
    Edge addEdge(const Node& from, const Node& to) {
589 586
      Edge edge = Parent::addEdge(from, to);
590 587
      notifier(Edge()).add(edge);
591 588
      std::vector<Arc> arcs;
592 589
      arcs.push_back(Parent::direct(edge, true));
593 590
      arcs.push_back(Parent::direct(edge, false));
594 591
      notifier(Arc()).add(arcs);
595 592
      return edge;
596 593
    }
597 594
    
598 595
    void clear() {
599 596
      notifier(Arc()).clear();
600 597
      notifier(Edge()).clear();
601 598
      Parent::clear();
602 599
    }
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-2009
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_BITS_GRAPH_ADAPTOR_EXTENDER_H
20 20
#define LEMON_BITS_GRAPH_ADAPTOR_EXTENDER_H
21 21

	
22 22
#include <lemon/core.h>
23 23
#include <lemon/error.h>
24 24

	
25 25
namespace lemon {
26 26

	
27 27
  template <typename _Digraph>
28 28
  class DigraphAdaptorExtender : public _Digraph {
29
    typedef _Digraph Parent;
30

	
29 31
  public:
30 32

	
31
    typedef _Digraph Parent;
32 33
    typedef _Digraph Digraph;
33 34
    typedef DigraphAdaptorExtender Adaptor;
34 35

	
35 36
    // Base extensions
36 37

	
37 38
    typedef typename Parent::Node Node;
38 39
    typedef typename Parent::Arc Arc;
39 40

	
40 41
    int maxId(Node) const {
41 42
      return Parent::maxNodeId();
42 43
    }
43 44

	
44 45
    int maxId(Arc) const {
45 46
      return Parent::maxArcId();
46 47
    }
47 48

	
48 49
    Node fromId(int id, Node) const {
49 50
      return Parent::nodeFromId(id);
50 51
    }
51 52

	
52 53
    Arc fromId(int id, Arc) const {
53 54
      return Parent::arcFromId(id);
54 55
    }
55 56

	
56 57
    Node oppositeNode(const Node &n, const Arc &e) const {
57 58
      if (n == Parent::source(e))
58 59
        return Parent::target(e);
59 60
      else if(n==Parent::target(e))
60 61
        return Parent::source(e);
61 62
      else
62 63
        return INVALID;
63 64
    }
... ...
@@ -144,67 +145,68 @@
144 145
        : _adaptor(&adaptor) {
145 146
        _adaptor->firstIn(*this, node);
146 147
      }
147 148

	
148 149
      InArcIt(const Adaptor& adaptor, const Arc& arc) :
149 150
        Arc(arc), _adaptor(&adaptor) {}
150 151

	
151 152
      InArcIt& operator++() {
152 153
        _adaptor->nextIn(*this);
153 154
        return *this;
154 155
      }
155 156

	
156 157
    };
157 158

	
158 159
    Node baseNode(const OutArcIt &e) const {
159 160
      return Parent::source(e);
160 161
    }
161 162
    Node runningNode(const OutArcIt &e) const {
162 163
      return Parent::target(e);
163 164
    }
164 165

	
165 166
    Node baseNode(const InArcIt &e) const {
166 167
      return Parent::target(e);
167 168
    }
168 169
    Node runningNode(const InArcIt &e) const {
169 170
      return Parent::source(e);
170 171
    }
171 172

	
172 173
  };
173 174

	
174 175
  template <typename _Graph>
175 176
  class GraphAdaptorExtender : public _Graph {
177
    typedef _Graph Parent;
178

	
176 179
  public:
177 180

	
178
    typedef _Graph Parent;
179 181
    typedef _Graph Graph;
180 182
    typedef GraphAdaptorExtender Adaptor;
181 183

	
182 184
    typedef typename Parent::Node Node;
183 185
    typedef typename Parent::Arc Arc;
184 186
    typedef typename Parent::Edge Edge;
185 187

	
186 188
    // Graph extension
187 189

	
188 190
    int maxId(Node) const {
189 191
      return Parent::maxNodeId();
190 192
    }
191 193

	
192 194
    int maxId(Arc) const {
193 195
      return Parent::maxArcId();
194 196
    }
195 197

	
196 198
    int maxId(Edge) const {
197 199
      return Parent::maxEdgeId();
198 200
    }
199 201

	
200 202
    Node fromId(int id, Node) const {
201 203
      return Parent::nodeFromId(id);
202 204
    }
203 205

	
204 206
    Arc fromId(int id, Arc) const {
205 207
      return Parent::arcFromId(id);
206 208
    }
207 209

	
208 210
    Edge fromId(int id, Edge) const {
209 211
      return Parent::edgeFromId(id);
210 212
    }
Ignore white space 6 line context
... ...
@@ -8,67 +8,68 @@
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_BITS_GRAPH_EXTENDER_H
20 20
#define LEMON_BITS_GRAPH_EXTENDER_H
21 21

	
22 22
#include <lemon/core.h>
23 23

	
24 24
#include <lemon/bits/map_extender.h>
25 25
#include <lemon/bits/default_map.h>
26 26

	
27 27
#include <lemon/concept_check.h>
28 28
#include <lemon/concepts/maps.h>
29 29

	
30 30
//\ingroup graphbits
31 31
//\file
32 32
//\brief Extenders for the graph types
33 33
namespace lemon {
34 34

	
35 35
  // \ingroup graphbits
36 36
  //
37 37
  // \brief Extender for the digraph implementations
38 38
  template <typename Base>
39 39
  class DigraphExtender : public Base {
40
    typedef Base Parent;
41

	
40 42
  public:
41 43

	
42
    typedef Base Parent;
43 44
    typedef DigraphExtender Digraph;
44 45

	
45 46
    // Base extensions
46 47

	
47 48
    typedef typename Parent::Node Node;
48 49
    typedef typename Parent::Arc Arc;
49 50

	
50 51
    int maxId(Node) const {
51 52
      return Parent::maxNodeId();
52 53
    }
53 54

	
54 55
    int maxId(Arc) const {
55 56
      return Parent::maxArcId();
56 57
    }
57 58

	
58 59
    Node fromId(int id, Node) const {
59 60
      return Parent::nodeFromId(id);
60 61
    }
61 62

	
62 63
    Arc fromId(int id, Arc) const {
63 64
      return Parent::arcFromId(id);
64 65
    }
65 66

	
66 67
    Node oppositeNode(const Node &node, const Arc &arc) const {
67 68
      if (node == Parent::source(arc))
68 69
        return Parent::target(arc);
69 70
      else if(node == Parent::target(arc))
70 71
        return Parent::source(arc);
71 72
      else
72 73
        return INVALID;
73 74
    }
74 75

	
... ...
@@ -189,93 +190,91 @@
189 190
    // \brief Base node of the iterator
190 191
    //
191 192
    // Returns the base node (i.e. the source in this case) of the iterator
192 193
    Node baseNode(const OutArcIt &arc) const {
193 194
      return Parent::source(arc);
194 195
    }
195 196
    // \brief Running node of the iterator
196 197
    //
197 198
    // Returns the running node (i.e. the target in this case) of the
198 199
    // iterator
199 200
    Node runningNode(const OutArcIt &arc) const {
200 201
      return Parent::target(arc);
201 202
    }
202 203

	
203 204
    // \brief Base node of the iterator
204 205
    //
205 206
    // Returns the base node (i.e. the target in this case) of the iterator
206 207
    Node baseNode(const InArcIt &arc) const {
207 208
      return Parent::target(arc);
208 209
    }
209 210
    // \brief Running node of the iterator
210 211
    //
211 212
    // Returns the running node (i.e. the source in this case) of the
212 213
    // iterator
213 214
    Node runningNode(const InArcIt &arc) const {
214 215
      return Parent::source(arc);
215 216
    }
216 217

	
217 218

	
218 219
    template <typename _Value>
219 220
    class NodeMap
220 221
      : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
221
    public:
222
      typedef DigraphExtender Digraph;
223 222
      typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
224 223

	
224
    public:
225 225
      explicit NodeMap(const Digraph& digraph)
226 226
        : Parent(digraph) {}
227 227
      NodeMap(const Digraph& digraph, const _Value& value)
228 228
        : Parent(digraph, value) {}
229 229

	
230 230
    private:
231 231
      NodeMap& operator=(const NodeMap& cmap) {
232 232
        return operator=<NodeMap>(cmap);
233 233
      }
234 234

	
235 235
      template <typename CMap>
236 236
      NodeMap& operator=(const CMap& cmap) {
237 237
        Parent::operator=(cmap);
238 238
        return *this;
239 239
      }
240 240

	
241 241
    };
242 242

	
243 243
    template <typename _Value>
244 244
    class ArcMap
245 245
      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
246
    public:
247
      typedef DigraphExtender Digraph;
248 246
      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
249 247

	
248
    public:
250 249
      explicit ArcMap(const Digraph& digraph)
251 250
        : Parent(digraph) {}
252 251
      ArcMap(const Digraph& digraph, const _Value& value)
253 252
        : Parent(digraph, value) {}
254 253

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

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

	
267 266

	
268 267
    Node addNode() {
269 268
      Node node = Parent::addNode();
270 269
      notifier(Node()).add(node);
271 270
      return node;
272 271
    }
273 272

	
274 273
    Arc addArc(const Node& from, const Node& to) {
275 274
      Arc arc = Parent::addArc(from, to);
276 275
      notifier(Arc()).add(arc);
277 276
      return arc;
278 277
    }
279 278

	
280 279
    void clear() {
281 280
      notifier(Arc()).clear();
... ...
@@ -301,67 +300,68 @@
301 300
      Parent::firstIn(arc, node);
302 301
      while (arc != INVALID ) {
303 302
        erase(arc);
304 303
        Parent::firstIn(arc, node);
305 304
      }
306 305

	
307 306
      notifier(Node()).erase(node);
308 307
      Parent::erase(node);
309 308
    }
310 309

	
311 310
    void erase(const Arc& arc) {
312 311
      notifier(Arc()).erase(arc);
313 312
      Parent::erase(arc);
314 313
    }
315 314

	
316 315
    DigraphExtender() {
317 316
      node_notifier.setContainer(*this);
318 317
      arc_notifier.setContainer(*this);
319 318
    }
320 319

	
321 320

	
322 321
    ~DigraphExtender() {
323 322
      arc_notifier.clear();
324 323
      node_notifier.clear();
325 324
    }
326 325
  };
327 326

	
328 327
  // \ingroup _graphbits
329 328
  //
330 329
  // \brief Extender for the Graphs
331 330
  template <typename Base>
332 331
  class GraphExtender : public Base {
332
    typedef Base Parent;
333

	
333 334
  public:
334 335

	
335
    typedef Base Parent;
336 336
    typedef GraphExtender Graph;
337 337

	
338 338
    typedef True UndirectedTag;
339 339

	
340 340
    typedef typename Parent::Node Node;
341 341
    typedef typename Parent::Arc Arc;
342 342
    typedef typename Parent::Edge Edge;
343 343

	
344 344
    // Graph extension
345 345

	
346 346
    int maxId(Node) const {
347 347
      return Parent::maxNodeId();
348 348
    }
349 349

	
350 350
    int maxId(Arc) const {
351 351
      return Parent::maxArcId();
352 352
    }
353 353

	
354 354
    int maxId(Edge) const {
355 355
      return Parent::maxEdgeId();
356 356
    }
357 357

	
358 358
    Node fromId(int id, Node) const {
359 359
      return Parent::nodeFromId(id);
360 360
    }
361 361

	
362 362
    Arc fromId(int id, Arc) const {
363 363
      return Parent::arcFromId(id);
364 364
    }
365 365

	
366 366
    Edge fromId(int id, Edge) const {
367 367
      return Parent::edgeFromId(id);
... ...
@@ -572,118 +572,115 @@
572 572
    // \brief Base node of the iterator
573 573
    //
574 574
    // Returns the base node (ie. the target in this case) of the iterator
575 575
    Node baseNode(const InArcIt &arc) const {
576 576
      return Parent::target(static_cast<const Arc&>(arc));
577 577
    }
578 578
    // \brief Running node of the iterator
579 579
    //
580 580
    // Returns the running node (ie. the source in this case) of the
581 581
    // iterator
582 582
    Node runningNode(const InArcIt &arc) const {
583 583
      return Parent::source(static_cast<const Arc&>(arc));
584 584
    }
585 585

	
586 586
    // Base node of the iterator
587 587
    //
588 588
    // Returns the base node of the iterator
589 589
    Node baseNode(const IncEdgeIt &edge) const {
590 590
      return edge._direction ? u(edge) : v(edge);
591 591
    }
592 592
    // Running node of the iterator
593 593
    //
594 594
    // Returns the running node of the iterator
595 595
    Node runningNode(const IncEdgeIt &edge) const {
596 596
      return edge._direction ? v(edge) : u(edge);
597 597
    }
598 598

	
599 599
    // Mappable extension
600 600

	
601 601
    template <typename _Value>
602 602
    class NodeMap
603 603
      : public MapExtender<DefaultMap<Graph, Node, _Value> > {
604
    public:
605
      typedef GraphExtender Graph;
606 604
      typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
607 605

	
606
    public:
608 607
      NodeMap(const Graph& graph)
609 608
        : Parent(graph) {}
610 609
      NodeMap(const Graph& graph, const _Value& value)
611 610
        : Parent(graph, value) {}
612 611

	
613 612
    private:
614 613
      NodeMap& operator=(const NodeMap& cmap) {
615 614
        return operator=<NodeMap>(cmap);
616 615
      }
617 616

	
618 617
      template <typename CMap>
619 618
      NodeMap& operator=(const CMap& cmap) {
620 619
        Parent::operator=(cmap);
621 620
        return *this;
622 621
      }
623 622

	
624 623
    };
625 624

	
626 625
    template <typename _Value>
627 626
    class ArcMap
628 627
      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
629
    public:
630
      typedef GraphExtender Graph;
631 628
      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
632 629

	
630
    public:
633 631
      ArcMap(const Graph& graph)
634 632
        : Parent(graph) {}
635 633
      ArcMap(const Graph& graph, const _Value& value)
636 634
        : Parent(graph, value) {}
637 635

	
638 636
    private:
639 637
      ArcMap& operator=(const ArcMap& cmap) {
640 638
        return operator=<ArcMap>(cmap);
641 639
      }
642 640

	
643 641
      template <typename CMap>
644 642
      ArcMap& operator=(const CMap& cmap) {
645 643
        Parent::operator=(cmap);
646 644
        return *this;
647 645
      }
648 646
    };
649 647

	
650 648

	
651 649
    template <typename _Value>
652 650
    class EdgeMap
653 651
      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
654
    public:
655
      typedef GraphExtender Graph;
656 652
      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
657 653

	
654
    public:
658 655
      EdgeMap(const Graph& graph)
659 656
        : Parent(graph) {}
660 657

	
661 658
      EdgeMap(const Graph& graph, const _Value& value)
662 659
        : Parent(graph, value) {}
663 660

	
664 661
    private:
665 662
      EdgeMap& operator=(const EdgeMap& cmap) {
666 663
        return operator=<EdgeMap>(cmap);
667 664
      }
668 665

	
669 666
      template <typename CMap>
670 667
      EdgeMap& operator=(const CMap& cmap) {
671 668
        Parent::operator=(cmap);
672 669
        return *this;
673 670
      }
674 671

	
675 672
    };
676 673

	
677 674
    // Alteration extension
678 675

	
679 676
    Node addNode() {
680 677
      Node node = Parent::addNode();
681 678
      notifier(Node()).add(node);
682 679
      return node;
683 680
    }
684 681

	
685 682
    Edge addEdge(const Node& from, const Node& to) {
686 683
      Edge edge = Parent::addEdge(from, to);
687 684
      notifier(Edge()).add(edge);
688 685
      std::vector<Arc> ev;
689 686
      ev.push_back(Parent::direct(edge, true));
Ignore white space 6 line context
... ...
@@ -7,323 +7,322 @@
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_BITS_MAP_EXTENDER_H
20 20
#define LEMON_BITS_MAP_EXTENDER_H
21 21

	
22 22
#include <iterator>
23 23

	
24 24
#include <lemon/bits/traits.h>
25 25

	
26 26
#include <lemon/concept_check.h>
27 27
#include <lemon/concepts/maps.h>
28 28

	
29 29
//\file
30 30
//\brief Extenders for iterable maps.
31 31

	
32 32
namespace lemon {
33 33

	
34 34
  // \ingroup graphbits
35 35
  //
36 36
  // \brief Extender for maps
37 37
  template <typename _Map>
38 38
  class MapExtender : public _Map {
39
    typedef _Map Parent;
40
    typedef typename Parent::GraphType GraphType;
41

	
39 42
  public:
40 43

	
41
    typedef _Map Parent;
42 44
    typedef MapExtender Map;
43

	
44

	
45
    typedef typename Parent::Graph Graph;
46 45
    typedef typename Parent::Key Item;
47 46

	
48 47
    typedef typename Parent::Key Key;
49 48
    typedef typename Parent::Value Value;
50 49
    typedef typename Parent::Reference Reference;
51 50
    typedef typename Parent::ConstReference ConstReference;
52 51

	
53 52
    class MapIt;
54 53
    class ConstMapIt;
55 54

	
56 55
    friend class MapIt;
57 56
    friend class ConstMapIt;
58 57

	
59 58
  public:
60 59

	
61
    MapExtender(const Graph& graph)
60
    MapExtender(const GraphType& graph)
62 61
      : Parent(graph) {}
63 62

	
64
    MapExtender(const Graph& graph, const Value& value)
63
    MapExtender(const GraphType& graph, const Value& value)
65 64
      : Parent(graph, value) {}
66 65

	
67 66
  private:
68 67
    MapExtender& operator=(const MapExtender& cmap) {
69 68
      return operator=<MapExtender>(cmap);
70 69
    }
71 70

	
72 71
    template <typename CMap>
73 72
    MapExtender& operator=(const CMap& cmap) {
74 73
      Parent::operator=(cmap);
75 74
      return *this;
76 75
    }
77 76

	
78 77
  public:
79 78
    class MapIt : public Item {
79
      typedef Item Parent;
80

	
80 81
    public:
81 82

	
82
      typedef Item Parent;
83 83
      typedef typename Map::Value Value;
84 84

	
85 85
      MapIt() {}
86 86

	
87 87
      MapIt(Invalid i) : Parent(i) { }
88 88

	
89 89
      explicit MapIt(Map& _map) : map(_map) {
90 90
        map.notifier()->first(*this);
91 91
      }
92 92

	
93 93
      MapIt(const Map& _map, const Item& item)
94 94
        : Parent(item), map(_map) {}
95 95

	
96 96
      MapIt& operator++() {
97 97
        map.notifier()->next(*this);
98 98
        return *this;
99 99
      }
100 100

	
101 101
      typename MapTraits<Map>::ConstReturnValue operator*() const {
102 102
        return map[*this];
103 103
      }
104 104

	
105 105
      typename MapTraits<Map>::ReturnValue operator*() {
106 106
        return map[*this];
107 107
      }
108 108

	
109 109
      void set(const Value& value) {
110 110
        map.set(*this, value);
111 111
      }
112 112

	
113 113
    protected:
114 114
      Map& map;
115 115

	
116 116
    };
117 117

	
118 118
    class ConstMapIt : public Item {
119
      typedef Item Parent;
120

	
119 121
    public:
120 122

	
121
      typedef Item Parent;
122

	
123 123
      typedef typename Map::Value Value;
124 124

	
125 125
      ConstMapIt() {}
126 126

	
127 127
      ConstMapIt(Invalid i) : Parent(i) { }
128 128

	
129 129
      explicit ConstMapIt(Map& _map) : map(_map) {
130 130
        map.notifier()->first(*this);
131 131
      }
132 132

	
133 133
      ConstMapIt(const Map& _map, const Item& item)
134 134
        : Parent(item), map(_map) {}
135 135

	
136 136
      ConstMapIt& operator++() {
137 137
        map.notifier()->next(*this);
138 138
        return *this;
139 139
      }
140 140

	
141 141
      typename MapTraits<Map>::ConstReturnValue operator*() const {
142 142
        return map[*this];
143 143
      }
144 144

	
145 145
    protected:
146 146
      const Map& map;
147 147
    };
148 148

	
149 149
    class ItemIt : public Item {
150
      typedef Item Parent;
151

	
150 152
    public:
151 153

	
152
      typedef Item Parent;
153

	
154 154
      ItemIt() {}
155 155

	
156 156
      ItemIt(Invalid i) : Parent(i) { }
157 157

	
158 158
      explicit ItemIt(Map& _map) : map(_map) {
159 159
        map.notifier()->first(*this);
160 160
      }
161 161

	
162 162
      ItemIt(const Map& _map, const Item& item)
163 163
        : Parent(item), map(_map) {}
164 164

	
165 165
      ItemIt& operator++() {
166 166
        map.notifier()->next(*this);
167 167
        return *this;
168 168
      }
169 169

	
170 170
    protected:
171 171
      const Map& map;
172 172

	
173 173
    };
174 174
  };
175 175

	
176 176
  // \ingroup graphbits
177 177
  //
178 178
  // \brief Extender for maps which use a subset of the items.
179 179
  template <typename _Graph, typename _Map>
180 180
  class SubMapExtender : public _Map {
181
    typedef _Map Parent;
182
    typedef _Graph GraphType;
183

	
181 184
  public:
182 185

	
183
    typedef _Map Parent;
184 186
    typedef SubMapExtender Map;
185

	
186
    typedef _Graph Graph;
187

	
188 187
    typedef typename Parent::Key Item;
189 188

	
190 189
    typedef typename Parent::Key Key;
191 190
    typedef typename Parent::Value Value;
192 191
    typedef typename Parent::Reference Reference;
193 192
    typedef typename Parent::ConstReference ConstReference;
194 193

	
195 194
    class MapIt;
196 195
    class ConstMapIt;
197 196

	
198 197
    friend class MapIt;
199 198
    friend class ConstMapIt;
200 199

	
201 200
  public:
202 201

	
203
    SubMapExtender(const Graph& _graph)
202
    SubMapExtender(const GraphType& _graph)
204 203
      : Parent(_graph), graph(_graph) {}
205 204

	
206
    SubMapExtender(const Graph& _graph, const Value& _value)
205
    SubMapExtender(const GraphType& _graph, const Value& _value)
207 206
      : Parent(_graph, _value), graph(_graph) {}
208 207

	
209 208
  private:
210 209
    SubMapExtender& operator=(const SubMapExtender& cmap) {
211 210
      return operator=<MapExtender>(cmap);
212 211
    }
213 212

	
214 213
    template <typename CMap>
215 214
    SubMapExtender& operator=(const CMap& cmap) {
216 215
      checkConcept<concepts::ReadMap<Key, Value>, CMap>();
217 216
      Item it;
218 217
      for (graph.first(it); it != INVALID; graph.next(it)) {
219 218
        Parent::set(it, cmap[it]);
220 219
      }
221 220
      return *this;
222 221
    }
223 222

	
224 223
  public:
225 224
    class MapIt : public Item {
225
      typedef Item Parent;
226

	
226 227
    public:
227

	
228
      typedef Item Parent;
229 228
      typedef typename Map::Value Value;
230 229

	
231 230
      MapIt() {}
232 231

	
233 232
      MapIt(Invalid i) : Parent(i) { }
234 233

	
235 234
      explicit MapIt(Map& _map) : map(_map) {
236 235
        map.graph.first(*this);
237 236
      }
238 237

	
239 238
      MapIt(const Map& _map, const Item& item)
240 239
        : Parent(item), map(_map) {}
241 240

	
242 241
      MapIt& operator++() {
243 242
        map.graph.next(*this);
244 243
        return *this;
245 244
      }
246 245

	
247 246
      typename MapTraits<Map>::ConstReturnValue operator*() const {
248 247
        return map[*this];
249 248
      }
250 249

	
251 250
      typename MapTraits<Map>::ReturnValue operator*() {
252 251
        return map[*this];
253 252
      }
254 253

	
255 254
      void set(const Value& value) {
256 255
        map.set(*this, value);
257 256
      }
258 257

	
259 258
    protected:
260 259
      Map& map;
261 260

	
262 261
    };
263 262

	
264 263
    class ConstMapIt : public Item {
264
      typedef Item Parent;
265

	
265 266
    public:
266 267

	
267
      typedef Item Parent;
268

	
269 268
      typedef typename Map::Value Value;
270 269

	
271 270
      ConstMapIt() {}
272 271

	
273 272
      ConstMapIt(Invalid i) : Parent(i) { }
274 273

	
275 274
      explicit ConstMapIt(Map& _map) : map(_map) {
276 275
        map.graph.first(*this);
277 276
      }
278 277

	
279 278
      ConstMapIt(const Map& _map, const Item& item)
280 279
        : Parent(item), map(_map) {}
281 280

	
282 281
      ConstMapIt& operator++() {
283 282
        map.graph.next(*this);
284 283
        return *this;
285 284
      }
286 285

	
287 286
      typename MapTraits<Map>::ConstReturnValue operator*() const {
288 287
        return map[*this];
289 288
      }
290 289

	
291 290
    protected:
292 291
      const Map& map;
293 292
    };
294 293

	
295 294
    class ItemIt : public Item {
295
      typedef Item Parent;
296

	
296 297
    public:
297 298

	
298
      typedef Item Parent;
299

	
300 299
      ItemIt() {}
301 300

	
302 301
      ItemIt(Invalid i) : Parent(i) { }
303 302

	
304 303
      explicit ItemIt(Map& _map) : map(_map) {
305 304
        map.graph.first(*this);
306 305
      }
307 306

	
308 307
      ItemIt(const Map& _map, const Item& item)
309 308
        : Parent(item), map(_map) {}
310 309

	
311 310
      ItemIt& operator++() {
312 311
        map.graph.next(*this);
313 312
        return *this;
314 313
      }
315 314

	
316 315
    protected:
317 316
      const Map& map;
318 317

	
319 318
    };
320 319

	
321 320
  private:
322 321

	
323
    const Graph& graph;
322
    const GraphType& graph;
324 323

	
325 324
  };
326 325

	
327 326
}
328 327

	
329 328
#endif
Ignore white space 6 line context
... ...
@@ -27,103 +27,107 @@
27 27

	
28 28
#include <lemon/concept_check.h>
29 29
#include <lemon/concepts/maps.h>
30 30

	
31 31
//\ingroup graphbits
32 32
//
33 33
//\file
34 34
//\brief Vector based graph maps.
35 35
namespace lemon {
36 36

	
37 37
  // \ingroup graphbits
38 38
  //
39 39
  // \brief Graph map based on the std::vector storage.
40 40
  //
41 41
  // The VectorMap template class is graph map structure that automatically
42 42
  // updates the map when a key is added to or erased from the graph.
43 43
  // This map type uses std::vector to store the values.
44 44
  //
45 45
  // \tparam _Graph The graph this map is attached to.
46 46
  // \tparam _Item The item type of the graph items.
47 47
  // \tparam _Value The value type of the map.
48 48
  template <typename _Graph, typename _Item, typename _Value>
49 49
  class VectorMap
50 50
    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
51 51
  private:
52 52

	
53 53
    // The container type of the map.
54 54
    typedef std::vector<_Value> Container;
55 55

	
56 56
  public:
57 57

	
58 58
    // The graph type of the map.
59
    typedef _Graph Graph;
59
    typedef _Graph GraphType;
60 60
    // The item type of the map.
61 61
    typedef _Item Item;
62 62
    // The reference map tag.
63 63
    typedef True ReferenceMapTag;
64 64

	
65 65
    // The key type of the map.
66 66
    typedef _Item Key;
67 67
    // The value type of the map.
68 68
    typedef _Value Value;
69 69

	
70 70
    // The notifier type.
71 71
    typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
72 72

	
73 73
    // The map type.
74 74
    typedef VectorMap Map;
75
    // The base class of the map.
76
    typedef typename Notifier::ObserverBase Parent;
77 75

	
78 76
    // The reference type of the map;
79 77
    typedef typename Container::reference Reference;
80 78
    // The const reference type of the map;
81 79
    typedef typename Container::const_reference ConstReference;
82 80

	
81
  private:
82

	
83
    // The base class of the map.
84
    typedef typename Notifier::ObserverBase Parent;
85

	
86
  public:
83 87

	
84 88
    // \brief Constructor to attach the new map into the notifier.
85 89
    //
86 90
    // It constructs a map and attachs it into the notifier.
87 91
    // It adds all the items of the graph to the map.
88
    VectorMap(const Graph& graph) {
92
    VectorMap(const GraphType& graph) {
89 93
      Parent::attach(graph.notifier(Item()));
90 94
      container.resize(Parent::notifier()->maxId() + 1);
91 95
    }
92 96

	
93 97
    // \brief Constructor uses given value to initialize the map.
94 98
    //
95 99
    // It constructs a map uses a given value to initialize the map.
96 100
    // It adds all the items of the graph to the map.
97
    VectorMap(const Graph& graph, const Value& value) {
101
    VectorMap(const GraphType& graph, const Value& value) {
98 102
      Parent::attach(graph.notifier(Item()));
99 103
      container.resize(Parent::notifier()->maxId() + 1, value);
100 104
    }
101 105

	
102 106
  private:
103 107
    // \brief Copy constructor
104 108
    //
105 109
    // Copy constructor.
106 110
    VectorMap(const VectorMap& _copy) : Parent() {
107 111
      if (_copy.attached()) {
108 112
        Parent::attach(*_copy.notifier());
109 113
        container = _copy.container;
110 114
      }
111 115
    }
112 116

	
113 117
    // \brief Assign operator.
114 118
    //
115 119
    // This operator assigns for each item in the map the
116 120
    // value mapped to the same item in the copied map.
117 121
    // The parameter map should be indiced with the same
118 122
    // itemset because this assign operator does not change
119 123
    // the container of the map.
120 124
    VectorMap& operator=(const VectorMap& cmap) {
121 125
      return operator=<VectorMap>(cmap);
122 126
    }
123 127

	
124 128

	
125 129
    // \brief Template assign operator.
126 130
    //
127 131
    // The given parameter should conform to the ReadMap
128 132
    // concecpt and could be indiced by the current item set of
129 133
    // the NodeMap. In this case the value for each item
Ignore white space 6 line context
... ...
@@ -151,76 +151,79 @@
151 151
      }
152 152

	
153 153
      template <typename _Digraph>
154 154
      struct Constraints {
155 155
        typedef typename _Digraph::Node Node;
156 156
        typedef typename _Digraph::Arc Arc;
157 157

	
158 158
        void constraints() {
159 159
          checkConcept<GraphItem<'n'>, Node>();
160 160
          checkConcept<GraphItem<'a'>, Arc>();
161 161
          {
162 162
            Node n;
163 163
            Arc e(INVALID);
164 164
            n = digraph.source(e);
165 165
            n = digraph.target(e);
166 166
            n = digraph.oppositeNode(n, e);
167 167
          }
168 168
        }
169 169

	
170 170
        const _Digraph& digraph;
171 171
      };
172 172
    };
173 173

	
174 174
    /// \brief Base skeleton class for undirected graphs.
175 175
    ///
176 176
    /// This class describes the base interface of undirected graph types.
177 177
    /// All graph %concepts have to conform to this class.
178 178
    /// It extends the interface of \ref BaseDigraphComponent with an
179 179
    /// \c Edge type and functions to get the end nodes of edges,
180 180
    /// to convert from arcs to edges and to get both direction of edges.
181 181
    class BaseGraphComponent : public BaseDigraphComponent {
182 182
    public:
183

	
184
      typedef BaseGraphComponent Graph;
185

	
183 186
      typedef BaseDigraphComponent::Node Node;
184 187
      typedef BaseDigraphComponent::Arc Arc;
185 188

	
186 189
      /// \brief Undirected edge class of the graph.
187 190
      ///
188 191
      /// This class represents the undirected edges of the graph.
189 192
      /// Undirected graphs can be used as directed graphs, each edge is
190 193
      /// represented by two opposite directed arcs.
191 194
      class Edge : public GraphItem<'e'> {
192
      public:
193 195
        typedef GraphItem<'e'> Parent;
194 196

	
197
      public:
195 198
        /// \brief Default constructor.
196 199
        ///
197 200
        /// Default constructor.
198 201
        /// \warning The default constructor is not required to set
199 202
        /// the item to some well-defined value. So you should consider it
200 203
        /// as uninitialized.
201 204
        Edge() {}
202 205

	
203 206
        /// \brief Copy constructor.
204 207
        ///
205 208
        /// Copy constructor.
206 209
        Edge(const Edge &) : Parent() {}
207 210

	
208 211
        /// \brief Constructor for conversion from \c INVALID.
209 212
        ///
210 213
        /// Constructor for conversion from \c INVALID.
211 214
        /// It initializes the item to be invalid.
212 215
        /// \sa Invalid for more details.
213 216
        Edge(Invalid) {}
214 217

	
215 218
        /// \brief Constructor for conversion from an arc.
216 219
        ///
217 220
        /// Constructor for conversion from an arc.
218 221
        /// Besides the core graph item functionality each arc should
219 222
        /// be convertible to the represented edge.
220 223
        Edge(const Arc&) {}
221 224

	
222 225
        /// \brief Assign an arc to an edge.
223 226
        ///
224 227
        /// This function assigns an arc to an edge.
225 228
        /// Besides the core graph item functionality each arc should
226 229
        /// be convertible to the represented edge.
... ...
@@ -962,199 +965,197 @@
962 965
      /// Edge alteration notifier class.
963 966
      typedef AlterationNotifier<AlterableGraphComponent, Edge>
964 967
      EdgeNotifier;
965 968

	
966 969
      /// \brief Return the edge alteration notifier.
967 970
      ///
968 971
      /// This function gives back the edge alteration notifier.
969 972
      EdgeNotifier& notifier(Edge) const {
970 973
        return EdgeNotifier();
971 974
      }
972 975

	
973 976
      template <typename _Graph>
974 977
      struct Constraints {
975 978
        void constraints() {
976 979
          checkConcept<AlterableDigraphComponent<Base>, _Graph>();
977 980
          typename _Graph::EdgeNotifier& uen
978 981
            = graph.notifier(typename _Graph::Edge());
979 982
          ignore_unused_variable_warning(uen);
980 983
        }
981 984

	
982 985
        const _Graph& graph;
983 986
      };
984 987
    };
985 988

	
986 989
    /// \brief Concept class for standard graph maps.
987 990
    ///
988 991
    /// This class describes the concept of standard graph maps, i.e.
989 992
    /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 
990 993
    /// graph types, which can be used for associating data to graph items.
991 994
    /// The standard graph maps must conform to the ReferenceMap concept.
992 995
    template <typename GR, typename K, typename V>
993 996
    class GraphMap : public ReferenceMap<K, V, V&, const V&> {
997
      typedef ReferenceMap<K, V, V&, const V&> Parent;
998

	
994 999
    public:
995 1000

	
996
      typedef ReadWriteMap<K, V> Parent;
997

	
998
      /// The graph type of the map.
999
      typedef GR Graph;
1000 1001
      /// The key type of the map.
1001 1002
      typedef K Key;
1002 1003
      /// The value type of the map.
1003 1004
      typedef V Value;
1004 1005
      /// The reference type of the map.
1005 1006
      typedef Value& Reference;
1006 1007
      /// The const reference type of the map.
1007 1008
      typedef const Value& ConstReference;
1008 1009

	
1009 1010
      // The reference map tag.
1010 1011
      typedef True ReferenceMapTag;
1011 1012

	
1012 1013
      /// \brief Construct a new map.
1013 1014
      ///
1014 1015
      /// Construct a new map for the graph.
1015
      explicit GraphMap(const Graph&) {}
1016
      explicit GraphMap(const GR&) {}
1016 1017
      /// \brief Construct a new map with default value.
1017 1018
      ///
1018 1019
      /// Construct a new map for the graph and initalize the values.
1019
      GraphMap(const Graph&, const Value&) {}
1020
      GraphMap(const GR&, const Value&) {}
1020 1021

	
1021 1022
    private:
1022 1023
      /// \brief Copy constructor.
1023 1024
      ///
1024 1025
      /// Copy Constructor.
1025 1026
      GraphMap(const GraphMap&) : Parent() {}
1026 1027

	
1027 1028
      /// \brief Assignment operator.
1028 1029
      ///
1029 1030
      /// Assignment operator. It does not mofify the underlying graph,
1030 1031
      /// it just iterates on the current item set and set the  map
1031 1032
      /// with the value returned by the assigned map.
1032 1033
      template <typename CMap>
1033 1034
      GraphMap& operator=(const CMap&) {
1034 1035
        checkConcept<ReadMap<Key, Value>, CMap>();
1035 1036
        return *this;
1036 1037
      }
1037 1038

	
1038 1039
    public:
1039 1040
      template<typename _Map>
1040 1041
      struct Constraints {
1041 1042
        void constraints() {
1042 1043
          checkConcept
1043 1044
            <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
1044 1045
          _Map m1(g);
1045 1046
          _Map m2(g,t);
1046 1047
          
1047 1048
          // Copy constructor
1048 1049
          // _Map m3(m);
1049 1050

	
1050 1051
          // Assignment operator
1051 1052
          // ReadMap<Key, Value> cmap;
1052 1053
          // m3 = cmap;
1053 1054

	
1054 1055
          ignore_unused_variable_warning(m1);
1055 1056
          ignore_unused_variable_warning(m2);
1056 1057
          // ignore_unused_variable_warning(m3);
1057 1058
        }
1058 1059

	
1059 1060
        const _Map &m;
1060
        const Graph &g;
1061
        const GR &g;
1061 1062
        const typename GraphMap::Value &t;
1062 1063
      };
1063 1064

	
1064 1065
    };
1065 1066

	
1066 1067
    /// \brief Skeleton class for mappable directed graphs.
1067 1068
    ///
1068 1069
    /// This class describes the interface of mappable directed graphs.
1069 1070
    /// It extends \ref BaseDigraphComponent with the standard digraph 
1070 1071
    /// map classes, namely \c NodeMap and \c ArcMap.
1071 1072
    /// This concept is part of the Digraph concept.
1072 1073
    template <typename BAS = BaseDigraphComponent>
1073 1074
    class MappableDigraphComponent : public BAS  {
1074 1075
    public:
1075 1076

	
1076 1077
      typedef BAS Base;
1077 1078
      typedef typename Base::Node Node;
1078 1079
      typedef typename Base::Arc Arc;
1079 1080

	
1080 1081
      typedef MappableDigraphComponent Digraph;
1081 1082

	
1082 1083
      /// \brief Standard graph map for the nodes.
1083 1084
      ///
1084 1085
      /// Standard graph map for the nodes.
1085 1086
      /// It conforms to the ReferenceMap concept.
1086 1087
      template <typename V>
1087 1088
      class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
1088
      public:
1089 1089
        typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
1090 1090

	
1091
      public:
1091 1092
        /// \brief Construct a new map.
1092 1093
        ///
1093 1094
        /// Construct a new map for the digraph.
1094 1095
        explicit NodeMap(const MappableDigraphComponent& digraph)
1095 1096
          : Parent(digraph) {}
1096 1097

	
1097 1098
        /// \brief Construct a new map with default value.
1098 1099
        ///
1099 1100
        /// Construct a new map for the digraph and initalize the values.
1100 1101
        NodeMap(const MappableDigraphComponent& digraph, const V& value)
1101 1102
          : Parent(digraph, value) {}
1102 1103

	
1103 1104
      private:
1104 1105
        /// \brief Copy constructor.
1105 1106
        ///
1106 1107
        /// Copy Constructor.
1107 1108
        NodeMap(const NodeMap& nm) : Parent(nm) {}
1108 1109

	
1109 1110
        /// \brief Assignment operator.
1110 1111
        ///
1111 1112
        /// Assignment operator.
1112 1113
        template <typename CMap>
1113 1114
        NodeMap& operator=(const CMap&) {
1114 1115
          checkConcept<ReadMap<Node, V>, CMap>();
1115 1116
          return *this;
1116 1117
        }
1117 1118

	
1118 1119
      };
1119 1120

	
1120 1121
      /// \brief Standard graph map for the arcs.
1121 1122
      ///
1122 1123
      /// Standard graph map for the arcs.
1123 1124
      /// It conforms to the ReferenceMap concept.
1124 1125
      template <typename V>
1125 1126
      class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
1126
      public:
1127 1127
        typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
1128 1128

	
1129
      public:
1129 1130
        /// \brief Construct a new map.
1130 1131
        ///
1131 1132
        /// Construct a new map for the digraph.
1132 1133
        explicit ArcMap(const MappableDigraphComponent& digraph)
1133 1134
          : Parent(digraph) {}
1134 1135

	
1135 1136
        /// \brief Construct a new map with default value.
1136 1137
        ///
1137 1138
        /// Construct a new map for the digraph and initalize the values.
1138 1139
        ArcMap(const MappableDigraphComponent& digraph, const V& value)
1139 1140
          : Parent(digraph, value) {}
1140 1141

	
1141 1142
      private:
1142 1143
        /// \brief Copy constructor.
1143 1144
        ///
1144 1145
        /// Copy Constructor.
1145 1146
        ArcMap(const ArcMap& nm) : Parent(nm) {}
1146 1147

	
1147 1148
        /// \brief Assignment operator.
1148 1149
        ///
1149 1150
        /// Assignment operator.
1150 1151
        template <typename CMap>
1151 1152
        ArcMap& operator=(const CMap&) {
1152 1153
          checkConcept<ReadMap<Arc, V>, CMap>();
1153 1154
          return *this;
1154 1155
        }
1155 1156

	
1156 1157
      };
1157 1158

	
1158 1159

	
1159 1160
      template <typename _Digraph>
1160 1161
      struct Constraints {
... ...
@@ -1192,67 +1193,67 @@
1192 1193
          } { // Dummy map test
1193 1194
            typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
1194 1195
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
1195 1196
              DummyArcMap >();
1196 1197
          }
1197 1198
        }
1198 1199

	
1199 1200
        const _Digraph& digraph;
1200 1201
      };
1201 1202
    };
1202 1203

	
1203 1204
    /// \brief Skeleton class for mappable undirected graphs.
1204 1205
    ///
1205 1206
    /// This class describes the interface of mappable undirected graphs.
1206 1207
    /// It extends \ref MappableDigraphComponent with the standard graph 
1207 1208
    /// map class for edges (\c EdgeMap).
1208 1209
    /// This concept is part of the Graph concept.
1209 1210
    template <typename BAS = BaseGraphComponent>
1210 1211
    class MappableGraphComponent : public MappableDigraphComponent<BAS>  {
1211 1212
    public:
1212 1213

	
1213 1214
      typedef BAS Base;
1214 1215
      typedef typename Base::Edge Edge;
1215 1216

	
1216 1217
      typedef MappableGraphComponent Graph;
1217 1218

	
1218 1219
      /// \brief Standard graph map for the edges.
1219 1220
      ///
1220 1221
      /// Standard graph map for the edges.
1221 1222
      /// It conforms to the ReferenceMap concept.
1222 1223
      template <typename V>
1223 1224
      class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
1224
      public:
1225 1225
        typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
1226 1226

	
1227
      public:
1227 1228
        /// \brief Construct a new map.
1228 1229
        ///
1229 1230
        /// Construct a new map for the graph.
1230 1231
        explicit EdgeMap(const MappableGraphComponent& graph)
1231 1232
          : Parent(graph) {}
1232 1233

	
1233 1234
        /// \brief Construct a new map with default value.
1234 1235
        ///
1235 1236
        /// Construct a new map for the graph and initalize the values.
1236 1237
        EdgeMap(const MappableGraphComponent& graph, const V& value)
1237 1238
          : Parent(graph, value) {}
1238 1239

	
1239 1240
      private:
1240 1241
        /// \brief Copy constructor.
1241 1242
        ///
1242 1243
        /// Copy Constructor.
1243 1244
        EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1244 1245

	
1245 1246
        /// \brief Assignment operator.
1246 1247
        ///
1247 1248
        /// Assignment operator.
1248 1249
        template <typename CMap>
1249 1250
        EdgeMap& operator=(const CMap&) {
1250 1251
          checkConcept<ReadMap<Edge, V>, CMap>();
1251 1252
          return *this;
1252 1253
        }
1253 1254

	
1254 1255
      };
1255 1256

	
1256 1257

	
1257 1258
      template <typename _Graph>
1258 1259
      struct Constraints {
Ignore white space 6 line context
... ...
@@ -1007,95 +1007,94 @@
1007 1007
  /// for(Arc e = findArc(g,u,v); e != INVALID; e = findArc(g,u,v,e)) {
1008 1008
  ///   ...
1009 1009
  /// }
1010 1010
  ///\endcode
1011 1011
  ///
1012 1012
  /// \note \ref ConArcIt provides iterator interface for the same
1013 1013
  /// functionality.
1014 1014
  ///
1015 1015
  ///\sa ConArcIt
1016 1016
  ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp
1017 1017
  template <typename Graph>
1018 1018
  inline typename Graph::Arc
1019 1019
  findArc(const Graph &g, typename Graph::Node u, typename Graph::Node v,
1020 1020
          typename Graph::Arc prev = INVALID) {
1021 1021
    return _core_bits::FindArcSelector<Graph>::find(g, u, v, prev);
1022 1022
  }
1023 1023

	
1024 1024
  /// \brief Iterator for iterating on parallel arcs connecting the same nodes.
1025 1025
  ///
1026 1026
  /// Iterator for iterating on parallel arcs connecting the same nodes. It is
1027 1027
  /// a higher level interface for the \ref findArc() function. You can
1028 1028
  /// use it the following way:
1029 1029
  ///\code
1030 1030
  /// for (ConArcIt<Graph> it(g, src, trg); it != INVALID; ++it) {
1031 1031
  ///   ...
1032 1032
  /// }
1033 1033
  ///\endcode
1034 1034
  ///
1035 1035
  ///\sa findArc()
1036 1036
  ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp
1037 1037
  template <typename GR>
1038 1038
  class ConArcIt : public GR::Arc {
1039
    typedef typename GR::Arc Parent;
1040

	
1039 1041
  public:
1040 1042

	
1041
    typedef GR Graph;
1042
    typedef typename Graph::Arc Parent;
1043

	
1044
    typedef typename Graph::Arc Arc;
1045
    typedef typename Graph::Node Node;
1043
    typedef typename GR::Arc Arc;
1044
    typedef typename GR::Node Node;
1046 1045

	
1047 1046
    /// \brief Constructor.
1048 1047
    ///
1049 1048
    /// Construct a new ConArcIt iterating on the arcs that
1050 1049
    /// connects nodes \c u and \c v.
1051
    ConArcIt(const Graph& g, Node u, Node v) : _graph(g) {
1050
    ConArcIt(const GR& g, Node u, Node v) : _graph(g) {
1052 1051
      Parent::operator=(findArc(_graph, u, v));
1053 1052
    }
1054 1053

	
1055 1054
    /// \brief Constructor.
1056 1055
    ///
1057 1056
    /// Construct a new ConArcIt that continues the iterating from arc \c a.
1058
    ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
1057
    ConArcIt(const GR& g, Arc a) : Parent(a), _graph(g) {}
1059 1058

	
1060 1059
    /// \brief Increment operator.
1061 1060
    ///
1062 1061
    /// It increments the iterator and gives back the next arc.
1063 1062
    ConArcIt& operator++() {
1064 1063
      Parent::operator=(findArc(_graph, _graph.source(*this),
1065 1064
                                _graph.target(*this), *this));
1066 1065
      return *this;
1067 1066
    }
1068 1067
  private:
1069
    const Graph& _graph;
1068
    const GR& _graph;
1070 1069
  };
1071 1070

	
1072 1071
  namespace _core_bits {
1073 1072

	
1074 1073
    template <typename Graph, typename Enable = void>
1075 1074
    struct FindEdgeSelector {
1076 1075
      typedef typename Graph::Node Node;
1077 1076
      typedef typename Graph::Edge Edge;
1078 1077
      static Edge find(const Graph &g, Node u, Node v, Edge e) {
1079 1078
        bool b;
1080 1079
        if (u != v) {
1081 1080
          if (e == INVALID) {
1082 1081
            g.firstInc(e, b, u);
1083 1082
          } else {
1084 1083
            b = g.u(e) == u;
1085 1084
            g.nextInc(e, b);
1086 1085
          }
1087 1086
          while (e != INVALID && (b ? g.v(e) : g.u(e)) != v) {
1088 1087
            g.nextInc(e, b);
1089 1088
          }
1090 1089
        } else {
1091 1090
          if (e == INVALID) {
1092 1091
            g.firstInc(e, b, u);
1093 1092
          } else {
1094 1093
            b = true;
1095 1094
            g.nextInc(e, b);
1096 1095
          }
1097 1096
          while (e != INVALID && (!b || g.v(e) != v)) {
1098 1097
            g.nextInc(e, b);
1099 1098
          }
1100 1099
        }
1101 1100
        return e;
... ...
@@ -1130,178 +1129,182 @@
1130 1129
  /// as it follows.
1131 1130
  ///\code
1132 1131
  /// for(Edge e = findEdge(g,u,v); e != INVALID; e = findEdge(g,u,v,e)) {
1133 1132
  ///   ...
1134 1133
  /// }
1135 1134
  ///\endcode
1136 1135
  ///
1137 1136
  /// \note \ref ConEdgeIt provides iterator interface for the same
1138 1137
  /// functionality.
1139 1138
  ///
1140 1139
  ///\sa ConEdgeIt
1141 1140
  template <typename Graph>
1142 1141
  inline typename Graph::Edge
1143 1142
  findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
1144 1143
            typename Graph::Edge p = INVALID) {
1145 1144
    return _core_bits::FindEdgeSelector<Graph>::find(g, u, v, p);
1146 1145
  }
1147 1146

	
1148 1147
  /// \brief Iterator for iterating on parallel edges connecting the same nodes.
1149 1148
  ///
1150 1149
  /// Iterator for iterating on parallel edges connecting the same nodes.
1151 1150
  /// It is a higher level interface for the findEdge() function. You can
1152 1151
  /// use it the following way:
1153 1152
  ///\code
1154 1153
  /// for (ConEdgeIt<Graph> it(g, u, v); it != INVALID; ++it) {
1155 1154
  ///   ...
1156 1155
  /// }
1157 1156
  ///\endcode
1158 1157
  ///
1159 1158
  ///\sa findEdge()
1160 1159
  template <typename GR>
1161 1160
  class ConEdgeIt : public GR::Edge {
1161
    typedef typename GR::Edge Parent;
1162

	
1162 1163
  public:
1163 1164

	
1164
    typedef GR Graph;
1165
    typedef typename Graph::Edge Parent;
1166

	
1167
    typedef typename Graph::Edge Edge;
1168
    typedef typename Graph::Node Node;
1165
    typedef typename GR::Edge Edge;
1166
    typedef typename GR::Node Node;
1169 1167

	
1170 1168
    /// \brief Constructor.
1171 1169
    ///
1172 1170
    /// Construct a new ConEdgeIt iterating on the edges that
1173 1171
    /// connects nodes \c u and \c v.
1174
    ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g), _u(u), _v(v) {
1172
    ConEdgeIt(const GR& g, Node u, Node v) : _graph(g), _u(u), _v(v) {
1175 1173
      Parent::operator=(findEdge(_graph, _u, _v));
1176 1174
    }
1177 1175

	
1178 1176
    /// \brief Constructor.
1179 1177
    ///
1180 1178
    /// Construct a new ConEdgeIt that continues iterating from edge \c e.
1181
    ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
1179
    ConEdgeIt(const GR& g, Edge e) : Parent(e), _graph(g) {}
1182 1180

	
1183 1181
    /// \brief Increment operator.
1184 1182
    ///
1185 1183
    /// It increments the iterator and gives back the next edge.
1186 1184
    ConEdgeIt& operator++() {
1187 1185
      Parent::operator=(findEdge(_graph, _u, _v, *this));
1188 1186
      return *this;
1189 1187
    }
1190 1188
  private:
1191
    const Graph& _graph;
1189
    const GR& _graph;
1192 1190
    Node _u, _v;
1193 1191
  };
1194 1192

	
1195 1193

	
1196 1194
  ///Dynamic arc look-up between given endpoints.
1197 1195

	
1198 1196
  ///Using this class, you can find an arc in a digraph from a given
1199 1197
  ///source to a given target in amortized time <em>O</em>(log<em>d</em>),
1200 1198
  ///where <em>d</em> is the out-degree of the source node.
1201 1199
  ///
1202 1200
  ///It is possible to find \e all parallel arcs between two nodes with
1203 1201
  ///the \c operator() member.
1204 1202
  ///
1205 1203
  ///This is a dynamic data structure. Consider to use \ref ArcLookUp or
1206 1204
  ///\ref AllArcLookUp if your digraph is not changed so frequently.
1207 1205
  ///
1208 1206
  ///This class uses a self-adjusting binary search tree, the Splay tree
1209 1207
  ///of Sleator and Tarjan to guarantee the logarithmic amortized
1210 1208
  ///time bound for arc look-ups. This class also guarantees the
1211 1209
  ///optimal time bound in a constant factor for any distribution of
1212 1210
  ///queries.
1213 1211
  ///
1214 1212
  ///\tparam GR The type of the underlying digraph.
1215 1213
  ///
1216 1214
  ///\sa ArcLookUp
1217 1215
  ///\sa AllArcLookUp
1218 1216
  template <typename GR>
1219 1217
  class DynArcLookUp
1220 1218
    : protected ItemSetTraits<GR, typename GR::Arc>::ItemNotifier::ObserverBase
1221 1219
  {
1222
  public:
1223 1220
    typedef typename ItemSetTraits<GR, typename GR::Arc>
1224 1221
    ::ItemNotifier::ObserverBase Parent;
1225 1222

	
1226 1223
    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
1224

	
1225
  public:
1226

	
1227
    /// The Digraph type
1227 1228
    typedef GR Digraph;
1228 1229

	
1229 1230
  protected:
1230 1231

	
1231 1232
    class AutoNodeMap : public ItemSetTraits<GR, Node>::template Map<Arc>::Type {
1233
      typedef typename ItemSetTraits<GR, Node>::template Map<Arc>::Type Parent;
1234

	
1232 1235
    public:
1233 1236

	
1234
      typedef typename ItemSetTraits<GR, Node>::template Map<Arc>::Type Parent;
1235

	
1236 1237
      AutoNodeMap(const GR& digraph) : Parent(digraph, INVALID) {}
1237 1238

	
1238 1239
      virtual void add(const Node& node) {
1239 1240
        Parent::add(node);
1240 1241
        Parent::set(node, INVALID);
1241 1242
      }
1242 1243

	
1243 1244
      virtual void add(const std::vector<Node>& nodes) {
1244 1245
        Parent::add(nodes);
1245 1246
        for (int i = 0; i < int(nodes.size()); ++i) {
1246 1247
          Parent::set(nodes[i], INVALID);
1247 1248
        }
1248 1249
      }
1249 1250

	
1250 1251
      virtual void build() {
1251 1252
        Parent::build();
1252 1253
        Node it;
1253 1254
        typename Parent::Notifier* nf = Parent::notifier();
1254 1255
        for (nf->first(it); it != INVALID; nf->next(it)) {
1255 1256
          Parent::set(it, INVALID);
1256 1257
        }
1257 1258
      }
1258 1259
    };
1259 1260

	
1260
    const Digraph &_g;
1261
    AutoNodeMap _head;
1262
    typename Digraph::template ArcMap<Arc> _parent;
1263
    typename Digraph::template ArcMap<Arc> _left;
1264
    typename Digraph::template ArcMap<Arc> _right;
1265

	
1266 1261
    class ArcLess {
1267 1262
      const Digraph &g;
1268 1263
    public:
1269 1264
      ArcLess(const Digraph &_g) : g(_g) {}
1270 1265
      bool operator()(Arc a,Arc b) const
1271 1266
      {
1272 1267
        return g.target(a)<g.target(b);
1273 1268
      }
1274 1269
    };
1275 1270

	
1271
  protected: 
1272

	
1273
    const Digraph &_g;
1274
    AutoNodeMap _head;
1275
    typename Digraph::template ArcMap<Arc> _parent;
1276
    typename Digraph::template ArcMap<Arc> _left;
1277
    typename Digraph::template ArcMap<Arc> _right;
1278

	
1276 1279
  public:
1277 1280

	
1278 1281
    ///Constructor
1279 1282

	
1280 1283
    ///Constructor.
1281 1284
    ///
1282 1285
    ///It builds up the search database.
1283 1286
    DynArcLookUp(const Digraph &g)
1284 1287
      : _g(g),_head(g),_parent(g),_left(g),_right(g)
1285 1288
    {
1286 1289
      Parent::attach(_g.notifier(typename Digraph::Arc()));
1287 1290
      refresh();
1288 1291
    }
1289 1292

	
1290 1293
  protected:
1291 1294

	
1292 1295
    virtual void add(const Arc& arc) {
1293 1296
      insert(arc);
1294 1297
    }
1295 1298

	
1296 1299
    virtual void add(const std::vector<Arc>& arcs) {
1297 1300
      for (int i = 0; i < int(arcs.size()); ++i) {
1298 1301
        insert(arcs[i]);
1299 1302
      }
1300 1303
    }
1301 1304

	
1302 1305
    virtual void erase(const Arc& arc) {
1303 1306
      remove(arc);
1304 1307
    }
1305 1308

	
1306 1309
    virtual void erase(const std::vector<Arc>& arcs) {
1307 1310
      for (int i = 0; i < int(arcs.size()); ++i) {
... ...
@@ -1601,66 +1604,69 @@
1601 1604
            a = _parent[a];
1602 1605
            const_cast<DynArcLookUp&>(*this).splay(a);
1603 1606
          }
1604 1607
        }
1605 1608
        if (_g.target(a) == t) return a;
1606 1609
        else return INVALID;
1607 1610
      }
1608 1611
    }
1609 1612

	
1610 1613
  };
1611 1614

	
1612 1615
  ///Fast arc look-up between given endpoints.
1613 1616

	
1614 1617
  ///Using this class, you can find an arc in a digraph from a given
1615 1618
  ///source to a given target in time <em>O</em>(log<em>d</em>),
1616 1619
  ///where <em>d</em> is the out-degree of the source node.
1617 1620
  ///
1618 1621
  ///It is not possible to find \e all parallel arcs between two nodes.
1619 1622
  ///Use \ref AllArcLookUp for this purpose.
1620 1623
  ///
1621 1624
  ///\warning This class is static, so you should call refresh() (or at
1622 1625
  ///least refresh(Node)) to refresh this data structure whenever the
1623 1626
  ///digraph changes. This is a time consuming (superlinearly proportional
1624 1627
  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
1625 1628
  ///
1626 1629
  ///\tparam GR The type of the underlying digraph.
1627 1630
  ///
1628 1631
  ///\sa DynArcLookUp
1629 1632
  ///\sa AllArcLookUp
1630 1633
  template<class GR>
1631 1634
  class ArcLookUp
1632 1635
  {
1636
    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
1637

	
1633 1638
  public:
1634
    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
1639

	
1640
    /// The Digraph type
1635 1641
    typedef GR Digraph;
1636 1642

	
1637 1643
  protected:
1638 1644
    const Digraph &_g;
1639 1645
    typename Digraph::template NodeMap<Arc> _head;
1640 1646
    typename Digraph::template ArcMap<Arc> _left;
1641 1647
    typename Digraph::template ArcMap<Arc> _right;
1642 1648

	
1643 1649
    class ArcLess {
1644 1650
      const Digraph &g;
1645 1651
    public:
1646 1652
      ArcLess(const Digraph &_g) : g(_g) {}
1647 1653
      bool operator()(Arc a,Arc b) const
1648 1654
      {
1649 1655
        return g.target(a)<g.target(b);
1650 1656
      }
1651 1657
    };
1652 1658

	
1653 1659
  public:
1654 1660

	
1655 1661
    ///Constructor
1656 1662

	
1657 1663
    ///Constructor.
1658 1664
    ///
1659 1665
    ///It builds up the search database, which remains valid until the digraph
1660 1666
    ///changes.
1661 1667
    ArcLookUp(const Digraph &g) :_g(g),_head(g),_left(g),_right(g) {refresh();}
1662 1668

	
1663 1669
  private:
1664 1670
    Arc refreshRec(std::vector<Arc> &v,int a,int b)
1665 1671
    {
1666 1672
      int m=(a+b)/2;
... ...
@@ -1717,85 +1723,88 @@
1717 1723
      for(e=_head[s];
1718 1724
          e!=INVALID&&_g.target(e)!=t;
1719 1725
          e = t < _g.target(e)?_left[e]:_right[e]) ;
1720 1726
      return e;
1721 1727
    }
1722 1728

	
1723 1729
  };
1724 1730

	
1725 1731
  ///Fast look-up of all arcs between given endpoints.
1726 1732

	
1727 1733
  ///This class is the same as \ref ArcLookUp, with the addition
1728 1734
  ///that it makes it possible to find all parallel arcs between given
1729 1735
  ///endpoints.
1730 1736
  ///
1731 1737
  ///\warning This class is static, so you should call refresh() (or at
1732 1738
  ///least refresh(Node)) to refresh this data structure whenever the
1733 1739
  ///digraph changes. This is a time consuming (superlinearly proportional
1734 1740
  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
1735 1741
  ///
1736 1742
  ///\tparam GR The type of the underlying digraph.
1737 1743
  ///
1738 1744
  ///\sa DynArcLookUp
1739 1745
  ///\sa ArcLookUp
1740 1746
  template<class GR>
1741 1747
  class AllArcLookUp : public ArcLookUp<GR>
1742 1748
  {
1743 1749
    using ArcLookUp<GR>::_g;
1744 1750
    using ArcLookUp<GR>::_right;
1745 1751
    using ArcLookUp<GR>::_left;
1746 1752
    using ArcLookUp<GR>::_head;
1747 1753

	
1748 1754
    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
1749
    typedef GR Digraph;
1750 1755

	
1751
    typename Digraph::template ArcMap<Arc> _next;
1756
    typename GR::template ArcMap<Arc> _next;
1752 1757

	
1753 1758
    Arc refreshNext(Arc head,Arc next=INVALID)
1754 1759
    {
1755 1760
      if(head==INVALID) return next;
1756 1761
      else {
1757 1762
        next=refreshNext(_right[head],next);
1758 1763
        _next[head]=( next!=INVALID && _g.target(next)==_g.target(head))
1759 1764
          ? next : INVALID;
1760 1765
        return refreshNext(_left[head],head);
1761 1766
      }
1762 1767
    }
1763 1768

	
1764 1769
    void refreshNext()
1765 1770
    {
1766 1771
      for(NodeIt n(_g);n!=INVALID;++n) refreshNext(_head[n]);
1767 1772
    }
1768 1773

	
1769 1774
  public:
1775

	
1776
    /// The Digraph type
1777
    typedef GR Digraph;
1778

	
1770 1779
    ///Constructor
1771 1780

	
1772 1781
    ///Constructor.
1773 1782
    ///
1774 1783
    ///It builds up the search database, which remains valid until the digraph
1775 1784
    ///changes.
1776 1785
    AllArcLookUp(const Digraph &g) : ArcLookUp<GR>(g), _next(g) {refreshNext();}
1777 1786

	
1778 1787
    ///Refresh the data structure at a node.
1779 1788

	
1780 1789
    ///Build up the search database of node \c n.
1781 1790
    ///
1782 1791
    ///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em> is
1783 1792
    ///the number of the outgoing arcs of \c n.
1784 1793
    void refresh(Node n)
1785 1794
    {
1786 1795
      ArcLookUp<GR>::refresh(n);
1787 1796
      refreshNext(_head[n]);
1788 1797
    }
1789 1798

	
1790 1799
    ///Refresh the full data structure.
1791 1800

	
1792 1801
    ///Build up the full search database. In fact, it simply calls
1793 1802
    ///\ref refresh(Node) "refresh(n)" for each node \c n.
1794 1803
    ///
1795 1804
    ///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is
1796 1805
    ///the number of the arcs in the digraph and <em>D</em> is the maximum
1797 1806
    ///out-degree of the digraph.
1798 1807
    void refresh()
1799 1808
    {
1800 1809
      for(NodeIt n(_g);n!=INVALID;++n) refresh(_head[n]);
1801 1810
    }
Ignore white space 6 line context
... ...
@@ -4,65 +4,64 @@
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_EDGE_SET_H
20 20
#define LEMON_EDGE_SET_H
21 21

	
22 22
#include <lemon/core.h>
23 23
#include <lemon/bits/edge_set_extender.h>
24 24

	
25 25
/// \ingroup semi_adaptors
26 26
/// \file
27 27
/// \brief ArcSet and EdgeSet classes.
28 28
///
29 29
/// Graphs which use another graph's node-set as own.
30 30
namespace lemon {
31 31

	
32 32
  template <typename GR>
33 33
  class ListArcSetBase {
34 34
  public:
35 35

	
36
    typedef GR Graph;
37 36
    typedef typename GR::Node Node;
38 37
    typedef typename GR::NodeIt NodeIt;
39 38

	
40 39
  protected:
41 40

	
42 41
    struct NodeT {
43 42
      int first_out, first_in;
44 43
      NodeT() : first_out(-1), first_in(-1) {}
45 44
    };
46 45

	
47 46
    typedef typename ItemSetTraits<GR, Node>::
48 47
    template Map<NodeT>::Type NodesImplBase;
49 48

	
50 49
    NodesImplBase* _nodes;
51 50

	
52 51
    struct ArcT {
53 52
      Node source, target;
54 53
      int next_out, next_in;
55 54
      int prev_out, prev_in;
56 55
      ArcT() : prev_out(-1), prev_in(-1) {}
57 56
    };
58 57

	
59 58
    std::vector<ArcT> arcs;
60 59

	
61 60
    int first_arc;
62 61
    int first_free_arc;
63 62

	
64 63
    const GR* _graph;
65 64

	
66 65
    void initalize(const GR& graph, NodesImplBase& nodes) {
67 66
      _graph = &graph;
68 67
      _nodes = &nodes;
... ...
@@ -179,211 +178,206 @@
179 178
    void nextOut(Arc& arc) const {
180 179
      arc.id = arcs[arc.id].next_out;
181 180
    }
182 181

	
183 182
    void firstIn(Arc& arc, const Node& node) const {
184 183
      arc.id = (*_nodes)[node].first_in;
185 184
    }
186 185

	
187 186
    void nextIn(Arc& arc) const {
188 187
      arc.id = arcs[arc.id].next_in;
189 188
    }
190 189

	
191 190
    int id(const Node& node) const { return _graph->id(node); }
192 191
    int id(const Arc& arc) const { return arc.id; }
193 192

	
194 193
    Node nodeFromId(int ix) const { return _graph->nodeFromId(ix); }
195 194
    Arc arcFromId(int ix) const { return Arc(ix); }
196 195

	
197 196
    int maxNodeId() const { return _graph->maxNodeId(); };
198 197
    int maxArcId() const { return arcs.size() - 1; }
199 198

	
200 199
    Node source(const Arc& arc) const { return arcs[arc.id].source;}
201 200
    Node target(const Arc& arc) const { return arcs[arc.id].target;}
202 201

	
203 202
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
204 203

	
205 204
    NodeNotifier& notifier(Node) const {
206 205
      return _graph->notifier(Node());
207 206
    }
208 207

	
209 208
    template <typename V>
210 209
    class NodeMap : public GR::template NodeMap<V> {
210
      typedef typename GR::template NodeMap<V> Parent;
211

	
211 212
    public:
212 213

	
213
      typedef typename GR::template NodeMap<V> Parent;
214

	
215 214
      explicit NodeMap(const ListArcSetBase<GR>& arcset)
216 215
        : Parent(*arcset._graph) {}
217 216

	
218 217
      NodeMap(const ListArcSetBase<GR>& arcset, const V& value)
219 218
        : Parent(*arcset._graph, value) {}
220 219

	
221 220
      NodeMap& operator=(const NodeMap& cmap) {
222 221
        return operator=<NodeMap>(cmap);
223 222
      }
224 223

	
225 224
      template <typename CMap>
226 225
      NodeMap& operator=(const CMap& cmap) {
227 226
        Parent::operator=(cmap);
228 227
        return *this;
229 228
      }
230 229
    };
231 230

	
232 231
  };
233 232

	
234 233
  /// \ingroup semi_adaptors
235 234
  ///
236 235
  /// \brief Digraph using a node set of another digraph or graph and
237 236
  /// an own arc set.
238 237
  ///
239 238
  /// This structure can be used to establish another directed graph
240 239
  /// over a node set of an existing one. This class uses the same
241 240
  /// Node type as the underlying graph, and each valid node of the
242 241
  /// original graph is valid in this arc set, therefore the node
243 242
  /// objects of the original graph can be used directly with this
244 243
  /// class. The node handling functions (id handling, observing, and
245 244
  /// iterators) works equivalently as in the original graph.
246 245
  ///
247 246
  /// This implementation is based on doubly-linked lists, from each
248 247
  /// node the outgoing and the incoming arcs make up lists, therefore
249 248
  /// one arc can be erased in constant time. It also makes possible,
250 249
  /// that node can be removed from the underlying graph, in this case
251 250
  /// all arcs incident to the given node is erased from the arc set.
252 251
  ///
253 252
  /// \param GR The type of the graph which shares its node set with
254 253
  /// this class. Its interface must conform to the
255 254
  /// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph"
256 255
  /// concept.
257 256
  ///
258 257
  /// This class fully conforms to the \ref concepts::Digraph
259 258
  /// "Digraph" concept.
260 259
  template <typename GR>
261 260
  class ListArcSet : public ArcSetExtender<ListArcSetBase<GR> > {
261
    typedef ArcSetExtender<ListArcSetBase<GR> > Parent;
262 262

	
263 263
  public:
264 264

	
265
    typedef ArcSetExtender<ListArcSetBase<GR> > Parent;
266

	
267 265
    typedef typename Parent::Node Node;
268 266
    typedef typename Parent::Arc Arc;
269 267

	
270
    typedef GR Graph;
271

	
272

	
273 268
    typedef typename Parent::NodesImplBase NodesImplBase;
274 269

	
275 270
    void eraseNode(const Node& node) {
276 271
      Arc arc;
277 272
      Parent::firstOut(arc, node);
278 273
      while (arc != INVALID ) {
279 274
        erase(arc);
280 275
        Parent::firstOut(arc, node);
281 276
      }
282 277

	
283 278
      Parent::firstIn(arc, node);
284 279
      while (arc != INVALID ) {
285 280
        erase(arc);
286 281
        Parent::firstIn(arc, node);
287 282
      }
288 283
    }
289 284

	
290 285
    void clearNodes() {
291 286
      Parent::clear();
292 287
    }
293 288

	
294 289
    class NodesImpl : public NodesImplBase {
295
    public:
296 290
      typedef NodesImplBase Parent;
297 291

	
292
    public:
298 293
      NodesImpl(const GR& graph, ListArcSet& arcset)
299 294
        : Parent(graph), _arcset(arcset) {}
300 295

	
301 296
      virtual ~NodesImpl() {}
302 297

	
303 298
    protected:
304 299

	
305 300
      virtual void erase(const Node& node) {
306 301
        _arcset.eraseNode(node);
307 302
        Parent::erase(node);
308 303
      }
309 304
      virtual void erase(const std::vector<Node>& nodes) {
310 305
        for (int i = 0; i < int(nodes.size()); ++i) {
311 306
          _arcset.eraseNode(nodes[i]);
312 307
        }
313 308
        Parent::erase(nodes);
314 309
      }
315 310
      virtual void clear() {
316 311
        _arcset.clearNodes();
317 312
        Parent::clear();
318 313
      }
319 314

	
320 315
    private:
321 316
      ListArcSet& _arcset;
322 317
    };
323 318

	
324 319
    NodesImpl _nodes;
325 320

	
326 321
  public:
327 322

	
328 323
    /// \brief Constructor of the ArcSet.
329 324
    ///
330 325
    /// Constructor of the ArcSet.
331 326
    ListArcSet(const GR& graph) : _nodes(graph, *this) {
332 327
      Parent::initalize(graph, _nodes);
333 328
    }
334 329

	
335 330
    /// \brief Add a new arc to the digraph.
336 331
    ///
337 332
    /// Add a new arc to the digraph with source node \c s
338 333
    /// and target node \c t.
339 334
    /// \return The new arc.
340 335
    Arc addArc(const Node& s, const Node& t) {
341 336
      return Parent::addArc(s, t);
342 337
    }
343 338

	
344 339
    /// \brief Erase an arc from the digraph.
345 340
    ///
346 341
    /// Erase an arc \c a from the digraph.
347 342
    void erase(const Arc& a) {
348 343
      return Parent::erase(a);
349 344
    }
350 345

	
351 346
  };
352 347

	
353 348
  template <typename GR>
354 349
  class ListEdgeSetBase {
355 350
  public:
356 351

	
357
    typedef GR Graph;
358 352
    typedef typename GR::Node Node;
359 353
    typedef typename GR::NodeIt NodeIt;
360 354

	
361 355
  protected:
362 356

	
363 357
    struct NodeT {
364 358
      int first_out;
365 359
      NodeT() : first_out(-1) {}
366 360
    };
367 361

	
368 362
    typedef typename ItemSetTraits<GR, Node>::
369 363
    template Map<NodeT>::Type NodesImplBase;
370 364

	
371 365
    NodesImplBase* _nodes;
372 366

	
373 367
    struct ArcT {
374 368
      Node target;
375 369
      int prev_out, next_out;
376 370
      ArcT() : prev_out(-1), next_out(-1) {}
377 371
    };
378 372

	
379 373
    std::vector<ArcT> arcs;
380 374

	
381 375
    int first_arc;
382 376
    int first_free_arc;
383 377

	
384 378
    const GR* _graph;
385 379

	
386 380
    void initalize(const GR& graph, NodesImplBase& nodes) {
387 381
      _graph = &graph;
388 382
      _nodes = &nodes;
389 383
    }
... ...
@@ -608,209 +602,204 @@
608 602
    }
609 603

	
610 604
    static Arc direct(Edge edge, bool dir) {
611 605
      return Arc(edge.id * 2 + (dir ? 1 : 0));
612 606
    }
613 607

	
614 608
    int id(const Node& node) const { return _graph->id(node); }
615 609
    static int id(Arc e) { return e.id; }
616 610
    static int id(Edge e) { return e.id; }
617 611

	
618 612
    Node nodeFromId(int id) const { return _graph->nodeFromId(id); }
619 613
    static Arc arcFromId(int id) { return Arc(id);}
620 614
    static Edge edgeFromId(int id) { return Edge(id);}
621 615

	
622 616
    int maxNodeId() const { return _graph->maxNodeId(); };
623 617
    int maxEdgeId() const { return arcs.size() / 2 - 1; }
624 618
    int maxArcId() const { return arcs.size()-1; }
625 619

	
626 620
    Node source(Arc e) const { return arcs[e.id ^ 1].target; }
627 621
    Node target(Arc e) const { return arcs[e.id].target; }
628 622

	
629 623
    Node u(Edge e) const { return arcs[2 * e.id].target; }
630 624
    Node v(Edge e) const { return arcs[2 * e.id + 1].target; }
631 625

	
632 626
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
633 627

	
634 628
    NodeNotifier& notifier(Node) const {
635 629
      return _graph->notifier(Node());
636 630
    }
637 631

	
638 632
    template <typename V>
639 633
    class NodeMap : public GR::template NodeMap<V> {
634
      typedef typename GR::template NodeMap<V> Parent;
635

	
640 636
    public:
641 637

	
642
      typedef typename GR::template NodeMap<V> Parent;
643

	
644 638
      explicit NodeMap(const ListEdgeSetBase<GR>& arcset)
645 639
        : Parent(*arcset._graph) {}
646 640

	
647 641
      NodeMap(const ListEdgeSetBase<GR>& arcset, const V& value)
648 642
        : Parent(*arcset._graph, value) {}
649 643

	
650 644
      NodeMap& operator=(const NodeMap& cmap) {
651 645
        return operator=<NodeMap>(cmap);
652 646
      }
653 647

	
654 648
      template <typename CMap>
655 649
      NodeMap& operator=(const CMap& cmap) {
656 650
        Parent::operator=(cmap);
657 651
        return *this;
658 652
      }
659 653
    };
660 654

	
661 655
  };
662 656

	
663 657
  /// \ingroup semi_adaptors
664 658
  ///
665 659
  /// \brief Graph using a node set of another digraph or graph and an
666 660
  /// own edge set.
667 661
  ///
668 662
  /// This structure can be used to establish another graph over a
669 663
  /// node set of an existing one. This class uses the same Node type
670 664
  /// as the underlying graph, and each valid node of the original
671 665
  /// graph is valid in this arc set, therefore the node objects of
672 666
  /// the original graph can be used directly with this class. The
673 667
  /// node handling functions (id handling, observing, and iterators)
674 668
  /// works equivalently as in the original graph.
675 669
  ///
676 670
  /// This implementation is based on doubly-linked lists, from each
677 671
  /// node the incident edges make up lists, therefore one edge can be
678 672
  /// erased in constant time. It also makes possible, that node can
679 673
  /// be removed from the underlying graph, in this case all edges
680 674
  /// incident to the given node is erased from the arc set.
681 675
  ///
682 676
  /// \param GR The type of the graph which shares its node set
683 677
  /// with this class. Its interface must conform to the
684 678
  /// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph"
685 679
  /// concept.
686 680
  ///
687 681
  /// This class fully conforms to the \ref concepts::Graph "Graph"
688 682
  /// concept.
689 683
  template <typename GR>
690 684
  class ListEdgeSet : public EdgeSetExtender<ListEdgeSetBase<GR> > {
685
    typedef EdgeSetExtender<ListEdgeSetBase<GR> > Parent;
691 686

	
692 687
  public:
693 688

	
694
    typedef EdgeSetExtender<ListEdgeSetBase<GR> > Parent;
695

	
696 689
    typedef typename Parent::Node Node;
697 690
    typedef typename Parent::Arc Arc;
698 691
    typedef typename Parent::Edge Edge;
699 692

	
700
    typedef GR Graph;
701

	
702

	
703 693
    typedef typename Parent::NodesImplBase NodesImplBase;
704 694

	
705 695
    void eraseNode(const Node& node) {
706 696
      Arc arc;
707 697
      Parent::firstOut(arc, node);
708 698
      while (arc != INVALID ) {
709 699
        erase(arc);
710 700
        Parent::firstOut(arc, node);
711 701
      }
712 702

	
713 703
    }
714 704

	
715 705
    void clearNodes() {
716 706
      Parent::clear();
717 707
    }
718 708

	
719 709
    class NodesImpl : public NodesImplBase {
720
    public:
721 710
      typedef NodesImplBase Parent;
722 711

	
712
    public:
723 713
      NodesImpl(const GR& graph, ListEdgeSet& arcset)
724 714
        : Parent(graph), _arcset(arcset) {}
725 715

	
726 716
      virtual ~NodesImpl() {}
727 717

	
728 718
    protected:
729 719

	
730 720
      virtual void erase(const Node& node) {
731 721
        _arcset.eraseNode(node);
732 722
        Parent::erase(node);
733 723
      }
734 724
      virtual void erase(const std::vector<Node>& nodes) {
735 725
        for (int i = 0; i < int(nodes.size()); ++i) {
736 726
          _arcset.eraseNode(nodes[i]);
737 727
        }
738 728
        Parent::erase(nodes);
739 729
      }
740 730
      virtual void clear() {
741 731
        _arcset.clearNodes();
742 732
        Parent::clear();
743 733
      }
744 734

	
745 735
    private:
746 736
      ListEdgeSet& _arcset;
747 737
    };
748 738

	
749 739
    NodesImpl _nodes;
750 740

	
751 741
  public:
752 742

	
753 743
    /// \brief Constructor of the EdgeSet.
754 744
    ///
755 745
    /// Constructor of the EdgeSet.
756 746
    ListEdgeSet(const GR& graph) : _nodes(graph, *this) {
757 747
      Parent::initalize(graph, _nodes);
758 748
    }
759 749

	
760 750
    /// \brief Add a new edge to the graph.
761 751
    ///
762 752
    /// Add a new edge to the graph with node \c u
763 753
    /// and node \c v endpoints.
764 754
    /// \return The new edge.
765 755
    Edge addEdge(const Node& u, const Node& v) {
766 756
      return Parent::addEdge(u, v);
767 757
    }
768 758

	
769 759
    /// \brief Erase an edge from the graph.
770 760
    ///
771 761
    /// Erase the edge \c e from the graph.
772 762
    void erase(const Edge& e) {
773 763
      return Parent::erase(e);
774 764
    }
775 765

	
776 766
  };
777 767

	
778 768
  template <typename GR>
779 769
  class SmartArcSetBase {
780 770
  public:
781 771

	
782
    typedef GR Graph;
783
    typedef typename Graph::Node Node;
784
    typedef typename Graph::NodeIt NodeIt;
772
    typedef typename GR::Node Node;
773
    typedef typename GR::NodeIt NodeIt;
785 774

	
786 775
  protected:
787 776

	
788 777
    struct NodeT {
789 778
      int first_out, first_in;
790 779
      NodeT() : first_out(-1), first_in(-1) {}
791 780
    };
792 781

	
793 782
    typedef typename ItemSetTraits<GR, Node>::
794 783
    template Map<NodeT>::Type NodesImplBase;
795 784

	
796 785
    NodesImplBase* _nodes;
797 786

	
798 787
    struct ArcT {
799 788
      Node source, target;
800 789
      int next_out, next_in;
801 790
      ArcT() {}
802 791
    };
803 792

	
804 793
    std::vector<ArcT> arcs;
805 794

	
806 795
    const GR* _graph;
807 796

	
808 797
    void initalize(const GR& graph, NodesImplBase& nodes) {
809 798
      _graph = &graph;
810 799
      _nodes = &nodes;
811 800
    }
812 801

	
813 802
  public:
814 803

	
815 804
    class Arc {
816 805
      friend class SmartArcSetBase<GR>;
... ...
@@ -871,150 +860,147 @@
871 860
    void nextOut(Arc& arc) const {
872 861
      arc.id = arcs[arc.id].next_out;
873 862
    }
874 863

	
875 864
    void firstIn(Arc& arc, const Node& node) const {
876 865
      arc.id = (*_nodes)[node].first_in;
877 866
    }
878 867

	
879 868
    void nextIn(Arc& arc) const {
880 869
      arc.id = arcs[arc.id].next_in;
881 870
    }
882 871

	
883 872
    int id(const Node& node) const { return _graph->id(node); }
884 873
    int id(const Arc& arc) const { return arc.id; }
885 874

	
886 875
    Node nodeFromId(int ix) const { return _graph->nodeFromId(ix); }
887 876
    Arc arcFromId(int ix) const { return Arc(ix); }
888 877

	
889 878
    int maxNodeId() const { return _graph->maxNodeId(); };
890 879
    int maxArcId() const { return arcs.size() - 1; }
891 880

	
892 881
    Node source(const Arc& arc) const { return arcs[arc.id].source;}
893 882
    Node target(const Arc& arc) const { return arcs[arc.id].target;}
894 883

	
895 884
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
896 885

	
897 886
    NodeNotifier& notifier(Node) const {
898 887
      return _graph->notifier(Node());
899 888
    }
900 889

	
901 890
    template <typename V>
902 891
    class NodeMap : public GR::template NodeMap<V> {
892
      typedef typename GR::template NodeMap<V> Parent;
893

	
903 894
    public:
904 895

	
905
      typedef typename GR::template NodeMap<V> Parent;
906

	
907 896
      explicit NodeMap(const SmartArcSetBase<GR>& arcset)
908 897
        : Parent(*arcset._graph) { }
909 898

	
910 899
      NodeMap(const SmartArcSetBase<GR>& arcset, const V& value)
911 900
        : Parent(*arcset._graph, value) { }
912 901

	
913 902
      NodeMap& operator=(const NodeMap& cmap) {
914 903
        return operator=<NodeMap>(cmap);
915 904
      }
916 905

	
917 906
      template <typename CMap>
918 907
      NodeMap& operator=(const CMap& cmap) {
919 908
        Parent::operator=(cmap);
920 909
        return *this;
921 910
      }
922 911
    };
923 912

	
924 913
  };
925 914

	
926 915

	
927 916
  /// \ingroup semi_adaptors
928 917
  ///
929 918
  /// \brief Digraph using a node set of another digraph or graph and
930 919
  /// an own arc set.
931 920
  ///
932 921
  /// This structure can be used to establish another directed graph
933 922
  /// over a node set of an existing one. This class uses the same
934 923
  /// Node type as the underlying graph, and each valid node of the
935 924
  /// original graph is valid in this arc set, therefore the node
936 925
  /// objects of the original graph can be used directly with this
937 926
  /// class. The node handling functions (id handling, observing, and
938 927
  /// iterators) works equivalently as in the original graph.
939 928
  ///
940 929
  /// \param GR The type of the graph which shares its node set with
941 930
  /// this class. Its interface must conform to the
942 931
  /// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph"
943 932
  /// concept.
944 933
  ///
945 934
  /// This implementation is slightly faster than the \c ListArcSet,
946 935
  /// because it uses continuous storage for arcs and it uses just
947 936
  /// single-linked lists for enumerate outgoing and incoming
948 937
  /// arcs. Therefore the arcs cannot be erased from the arc sets.
949 938
  ///
950 939
  /// \warning If a node is erased from the underlying graph and this
951 940
  /// node is the source or target of one arc in the arc set, then
952 941
  /// the arc set is invalidated, and it cannot be used anymore. The
953 942
  /// validity can be checked with the \c valid() member function.
954 943
  ///
955 944
  /// This class fully conforms to the \ref concepts::Digraph
956 945
  /// "Digraph" concept.
957 946
  template <typename GR>
958 947
  class SmartArcSet : public ArcSetExtender<SmartArcSetBase<GR> > {
948
    typedef ArcSetExtender<SmartArcSetBase<GR> > Parent;
959 949

	
960 950
  public:
961 951

	
962
    typedef ArcSetExtender<SmartArcSetBase<GR> > Parent;
963

	
964 952
    typedef typename Parent::Node Node;
965 953
    typedef typename Parent::Arc Arc;
966 954

	
967
    typedef GR Graph;
968

	
969 955
  protected:
970 956

	
971 957
    typedef typename Parent::NodesImplBase NodesImplBase;
972 958

	
973 959
    void eraseNode(const Node& node) {
974 960
      if (typename Parent::InArcIt(*this, node) == INVALID &&
975 961
          typename Parent::OutArcIt(*this, node) == INVALID) {
976 962
        return;
977 963
      }
978 964
      throw typename NodesImplBase::Notifier::ImmediateDetach();
979 965
    }
980 966

	
981 967
    void clearNodes() {
982 968
      Parent::clear();
983 969
    }
984 970

	
985 971
    class NodesImpl : public NodesImplBase {
986
    public:
987 972
      typedef NodesImplBase Parent;
988 973

	
974
    public:
989 975
      NodesImpl(const GR& graph, SmartArcSet& arcset)
990 976
        : Parent(graph), _arcset(arcset) {}
991 977

	
992 978
      virtual ~NodesImpl() {}
993 979

	
994 980
      bool attached() const {
995 981
        return Parent::attached();
996 982
      }
997 983

	
998 984
    protected:
999 985

	
1000 986
      virtual void erase(const Node& node) {
1001 987
        try {
1002 988
          _arcset.eraseNode(node);
1003 989
          Parent::erase(node);
1004 990
        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
1005 991
          Parent::clear();
1006 992
          throw;
1007 993
        }
1008 994
      }
1009 995
      virtual void erase(const std::vector<Node>& nodes) {
1010 996
        try {
1011 997
          for (int i = 0; i < int(nodes.size()); ++i) {
1012 998
            _arcset.eraseNode(nodes[i]);
1013 999
          }
1014 1000
          Parent::erase(nodes);
1015 1001
        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
1016 1002
          Parent::clear();
1017 1003
          throw;
1018 1004
        }
1019 1005
      }
1020 1006
      virtual void clear() {
... ...
@@ -1033,65 +1019,64 @@
1033 1019
    /// \brief Constructor of the ArcSet.
1034 1020
    ///
1035 1021
    /// Constructor of the ArcSet.
1036 1022
    SmartArcSet(const GR& graph) : _nodes(graph, *this) {
1037 1023
      Parent::initalize(graph, _nodes);
1038 1024
    }
1039 1025

	
1040 1026
    /// \brief Add a new arc to the digraph.
1041 1027
    ///
1042 1028
    /// Add a new arc to the digraph with source node \c s
1043 1029
    /// and target node \c t.
1044 1030
    /// \return The new arc.
1045 1031
    Arc addArc(const Node& s, const Node& t) {
1046 1032
      return Parent::addArc(s, t);
1047 1033
    }
1048 1034

	
1049 1035
    /// \brief Validity check
1050 1036
    ///
1051 1037
    /// This functions gives back false if the ArcSet is
1052 1038
    /// invalidated. It occurs when a node in the underlying graph is
1053 1039
    /// erased and it is not isolated in the ArcSet.
1054 1040
    bool valid() const {
1055 1041
      return _nodes.attached();
1056 1042
    }
1057 1043

	
1058 1044
  };
1059 1045

	
1060 1046

	
1061 1047
  template <typename GR>
1062 1048
  class SmartEdgeSetBase {
1063 1049
  public:
1064 1050

	
1065
    typedef GR Graph;
1066 1051
    typedef typename GR::Node Node;
1067 1052
    typedef typename GR::NodeIt NodeIt;
1068 1053

	
1069 1054
  protected:
1070 1055

	
1071 1056
    struct NodeT {
1072 1057
      int first_out;
1073 1058
      NodeT() : first_out(-1) {}
1074 1059
    };
1075 1060

	
1076 1061
    typedef typename ItemSetTraits<GR, Node>::
1077 1062
    template Map<NodeT>::Type NodesImplBase;
1078 1063

	
1079 1064
    NodesImplBase* _nodes;
1080 1065

	
1081 1066
    struct ArcT {
1082 1067
      Node target;
1083 1068
      int next_out;
1084 1069
      ArcT() {}
1085 1070
    };
1086 1071

	
1087 1072
    std::vector<ArcT> arcs;
1088 1073

	
1089 1074
    const GR* _graph;
1090 1075

	
1091 1076
    void initalize(const GR& graph, NodesImplBase& nodes) {
1092 1077
      _graph = &graph;
1093 1078
      _nodes = &nodes;
1094 1079
    }
1095 1080

	
1096 1081
  public:
1097 1082

	
... ...
@@ -1220,149 +1205,146 @@
1220 1205
    }
1221 1206

	
1222 1207
    static Arc direct(Edge edge, bool dir) {
1223 1208
      return Arc(edge.id * 2 + (dir ? 1 : 0));
1224 1209
    }
1225 1210

	
1226 1211
    int id(Node node) const { return _graph->id(node); }
1227 1212
    static int id(Arc arc) { return arc.id; }
1228 1213
    static int id(Edge arc) { return arc.id; }
1229 1214

	
1230 1215
    Node nodeFromId(int id) const { return _graph->nodeFromId(id); }
1231 1216
    static Arc arcFromId(int id) { return Arc(id); }
1232 1217
    static Edge edgeFromId(int id) { return Edge(id);}
1233 1218

	
1234 1219
    int maxNodeId() const { return _graph->maxNodeId(); };
1235 1220
    int maxArcId() const { return arcs.size() - 1; }
1236 1221
    int maxEdgeId() const { return arcs.size() / 2 - 1; }
1237 1222

	
1238 1223
    Node source(Arc e) const { return arcs[e.id ^ 1].target; }
1239 1224
    Node target(Arc e) const { return arcs[e.id].target; }
1240 1225

	
1241 1226
    Node u(Edge e) const { return arcs[2 * e.id].target; }
1242 1227
    Node v(Edge e) const { return arcs[2 * e.id + 1].target; }
1243 1228

	
1244 1229
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
1245 1230

	
1246 1231
    NodeNotifier& notifier(Node) const {
1247 1232
      return _graph->notifier(Node());
1248 1233
    }
1249 1234

	
1250 1235
    template <typename V>
1251 1236
    class NodeMap : public GR::template NodeMap<V> {
1237
      typedef typename GR::template NodeMap<V> Parent;
1238

	
1252 1239
    public:
1253 1240

	
1254
      typedef typename GR::template NodeMap<V> Parent;
1255

	
1256 1241
      explicit NodeMap(const SmartEdgeSetBase<GR>& arcset)
1257 1242
        : Parent(*arcset._graph) { }
1258 1243

	
1259 1244
      NodeMap(const SmartEdgeSetBase<GR>& arcset, const V& value)
1260 1245
        : Parent(*arcset._graph, value) { }
1261 1246

	
1262 1247
      NodeMap& operator=(const NodeMap& cmap) {
1263 1248
        return operator=<NodeMap>(cmap);
1264 1249
      }
1265 1250

	
1266 1251
      template <typename CMap>
1267 1252
      NodeMap& operator=(const CMap& cmap) {
1268 1253
        Parent::operator=(cmap);
1269 1254
        return *this;
1270 1255
      }
1271 1256
    };
1272 1257

	
1273 1258
  };
1274 1259

	
1275 1260
  /// \ingroup semi_adaptors
1276 1261
  ///
1277 1262
  /// \brief Graph using a node set of another digraph or graph and an
1278 1263
  /// own edge set.
1279 1264
  ///
1280 1265
  /// This structure can be used to establish another graph over a
1281 1266
  /// node set of an existing one. This class uses the same Node type
1282 1267
  /// as the underlying graph, and each valid node of the original
1283 1268
  /// graph is valid in this arc set, therefore the node objects of
1284 1269
  /// the original graph can be used directly with this class. The
1285 1270
  /// node handling functions (id handling, observing, and iterators)
1286 1271
  /// works equivalently as in the original graph.
1287 1272
  ///
1288 1273
  /// \param GR The type of the graph which shares its node set
1289 1274
  /// with this class. Its interface must conform to the
1290 1275
  /// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph"
1291 1276
  ///  concept.
1292 1277
  ///
1293 1278
  /// This implementation is slightly faster than the \c ListEdgeSet,
1294 1279
  /// because it uses continuous storage for edges and it uses just
1295 1280
  /// single-linked lists for enumerate incident edges. Therefore the
1296 1281
  /// edges cannot be erased from the edge sets.
1297 1282
  ///
1298 1283
  /// \warning If a node is erased from the underlying graph and this
1299 1284
  /// node is incident to one edge in the edge set, then the edge set
1300 1285
  /// is invalidated, and it cannot be used anymore. The validity can
1301 1286
  /// be checked with the \c valid() member function.
1302 1287
  ///
1303 1288
  /// This class fully conforms to the \ref concepts::Graph
1304 1289
  /// "Graph" concept.
1305 1290
  template <typename GR>
1306 1291
  class SmartEdgeSet : public EdgeSetExtender<SmartEdgeSetBase<GR> > {
1292
    typedef EdgeSetExtender<SmartEdgeSetBase<GR> > Parent;
1307 1293

	
1308 1294
  public:
1309 1295

	
1310
    typedef EdgeSetExtender<SmartEdgeSetBase<GR> > Parent;
1311

	
1312 1296
    typedef typename Parent::Node Node;
1313 1297
    typedef typename Parent::Arc Arc;
1314 1298
    typedef typename Parent::Edge Edge;
1315 1299

	
1316
    typedef GR Graph;
1317

	
1318 1300
  protected:
1319 1301

	
1320 1302
    typedef typename Parent::NodesImplBase NodesImplBase;
1321 1303

	
1322 1304
    void eraseNode(const Node& node) {
1323 1305
      if (typename Parent::IncEdgeIt(*this, node) == INVALID) {
1324 1306
        return;
1325 1307
      }
1326 1308
      throw typename NodesImplBase::Notifier::ImmediateDetach();
1327 1309
    }
1328 1310

	
1329 1311
    void clearNodes() {
1330 1312
      Parent::clear();
1331 1313
    }
1332 1314

	
1333 1315
    class NodesImpl : public NodesImplBase {
1334
    public:
1335 1316
      typedef NodesImplBase Parent;
1336 1317

	
1318
    public:
1337 1319
      NodesImpl(const GR& graph, SmartEdgeSet& arcset)
1338 1320
        : Parent(graph), _arcset(arcset) {}
1339 1321

	
1340 1322
      virtual ~NodesImpl() {}
1341 1323

	
1342 1324
      bool attached() const {
1343 1325
        return Parent::attached();
1344 1326
      }
1345 1327

	
1346 1328
    protected:
1347 1329

	
1348 1330
      virtual void erase(const Node& node) {
1349 1331
        try {
1350 1332
          _arcset.eraseNode(node);
1351 1333
          Parent::erase(node);
1352 1334
        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
1353 1335
          Parent::clear();
1354 1336
          throw;
1355 1337
        }
1356 1338
      }
1357 1339
      virtual void erase(const std::vector<Node>& nodes) {
1358 1340
        try {
1359 1341
          for (int i = 0; i < int(nodes.size()); ++i) {
1360 1342
            _arcset.eraseNode(nodes[i]);
1361 1343
          }
1362 1344
          Parent::erase(nodes);
1363 1345
        } catch (const typename NodesImplBase::Notifier::ImmediateDetach&) {
1364 1346
          Parent::clear();
1365 1347
          throw;
1366 1348
        }
1367 1349
      }
1368 1350
      virtual void clear() {
Ignore white space 6 line context
... ...
@@ -2,65 +2,65 @@
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
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_FULL_GRAPH_H
20 20
#define LEMON_FULL_GRAPH_H
21 21

	
22 22
#include <lemon/core.h>
23 23
#include <lemon/bits/graph_extender.h>
24 24

	
25 25
///\ingroup graphs
26 26
///\file
27 27
///\brief FullGraph and FullDigraph classes.
28 28

	
29 29
namespace lemon {
30 30

	
31 31
  class FullDigraphBase {
32 32
  public:
33 33

	
34
    typedef FullDigraphBase Graph;
34
    typedef FullDigraphBase Digraph;
35 35

	
36 36
    class Node;
37 37
    class Arc;
38 38

	
39 39
  protected:
40 40

	
41 41
    int _node_num;
42 42
    int _arc_num;
43 43

	
44 44
    FullDigraphBase() {}
45 45

	
46 46
    void construct(int n) { _node_num = n; _arc_num = n * n; }
47 47

	
48 48
  public:
49 49

	
50 50
    typedef True NodeNumTag;
51 51
    typedef True ArcNumTag;
52 52

	
53 53
    Node operator()(int ix) const { return Node(ix); }
54 54
    int index(const Node& node) const { return node._id; }
55 55

	
56 56
    Arc arc(const Node& s, const Node& t) const {
57 57
      return Arc(s._id * _node_num + t._id);
58 58
    }
59 59

	
60 60
    int nodeNum() const { return _node_num; }
61 61
    int arcNum() const { return _arc_num; }
62 62

	
63 63
    int maxNodeId() const { return _node_num - 1; }
64 64
    int maxArcId() const { return _arc_num - 1; }
65 65

	
66 66
    Node source(Arc arc) const { return arc._id / _node_num; }
... ...
@@ -140,133 +140,134 @@
140 140
    void nextIn(Arc& arc) const {
141 141
      arc._id -= _node_num;
142 142
      if (arc._id < 0) arc._id = -1;
143 143
    }
144 144

	
145 145
  };
146 146

	
147 147
  typedef DigraphExtender<FullDigraphBase> ExtendedFullDigraphBase;
148 148

	
149 149
  /// \ingroup graphs
150 150
  ///
151 151
  /// \brief A full digraph class.
152 152
  ///
153 153
  /// This is a simple and fast directed full graph implementation.
154 154
  /// From each node go arcs to each node (including the source node),
155 155
  /// therefore the number of the arcs in the digraph is the square of
156 156
  /// the node number. This digraph type is completely static, so you
157 157
  /// can neither add nor delete either arcs or nodes, and it needs
158 158
  /// constant space in memory.
159 159
  ///
160 160
  /// This class fully conforms to the \ref concepts::Digraph
161 161
  /// "Digraph concept".
162 162
  ///
163 163
  /// The \c FullDigraph and \c FullGraph classes are very similar,
164 164
  /// but there are two differences. While this class conforms only
165 165
  /// to the \ref concepts::Digraph "Digraph" concept, the \c FullGraph
166 166
  /// class conforms to the \ref concepts::Graph "Graph" concept,
167 167
  /// moreover \c FullGraph does not contain a loop arc for each
168 168
  /// node as \c FullDigraph does.
169 169
  ///
170 170
  /// \sa FullGraph
171 171
  class FullDigraph : public ExtendedFullDigraphBase {
172
    typedef ExtendedFullDigraphBase Parent;
173

	
172 174
  public:
173 175

	
174
    typedef ExtendedFullDigraphBase Parent;
175

	
176 176
    /// \brief Constructor
177 177
    FullDigraph() { construct(0); }
178 178

	
179 179
    /// \brief Constructor
180 180
    ///
181 181
    /// Constructor.
182 182
    /// \param n The number of the nodes.
183 183
    FullDigraph(int n) { construct(n); }
184 184

	
185 185
    /// \brief Resizes the digraph
186 186
    ///
187 187
    /// Resizes the digraph. The function will fully destroy and
188 188
    /// rebuild the digraph. This cause that the maps of the digraph will
189 189
    /// reallocated automatically and the previous values will be lost.
190 190
    void resize(int n) {
191 191
      Parent::notifier(Arc()).clear();
192 192
      Parent::notifier(Node()).clear();
193 193
      construct(n);
194 194
      Parent::notifier(Node()).build();
195 195
      Parent::notifier(Arc()).build();
196 196
    }
197 197

	
198 198
    /// \brief Returns the node with the given index.
199 199
    ///
200 200
    /// Returns the node with the given index. Since it is a static
201 201
    /// digraph its nodes can be indexed with integers from the range
202 202
    /// <tt>[0..nodeNum()-1]</tt>.
203 203
    /// \sa index()
204 204
    Node operator()(int ix) const { return Parent::operator()(ix); }
205 205

	
206 206
    /// \brief Returns the index of the given node.
207 207
    ///
208 208
    /// Returns the index of the given node. Since it is a static
209 209
    /// digraph its nodes can be indexed with integers from the range
210 210
    /// <tt>[0..nodeNum()-1]</tt>.
211 211
    /// \sa operator()
212 212
    int index(const Node& node) const { return Parent::index(node); }
213 213

	
214 214
    /// \brief Returns the arc connecting the given nodes.
215 215
    ///
216 216
    /// Returns the arc connecting the given nodes.
217 217
    Arc arc(const Node& u, const Node& v) const {
218 218
      return Parent::arc(u, v);
219 219
    }
220 220

	
221 221
    /// \brief Number of nodes.
222 222
    int nodeNum() const { return Parent::nodeNum(); }
223 223
    /// \brief Number of arcs.
224 224
    int arcNum() const { return Parent::arcNum(); }
225 225
  };
226 226

	
227 227

	
228 228
  class FullGraphBase {
229
    int _node_num;
230
    int _edge_num;
231 229
  public:
232 230

	
233 231
    typedef FullGraphBase Graph;
234 232

	
235 233
    class Node;
236 234
    class Arc;
237 235
    class Edge;
238 236

	
239 237
  protected:
240 238

	
239
    int _node_num;
240
    int _edge_num;
241

	
241 242
    FullGraphBase() {}
242 243

	
243 244
    void construct(int n) { _node_num = n; _edge_num = n * (n - 1) / 2; }
244 245

	
245 246
    int _uid(int e) const {
246 247
      int u = e / _node_num;
247 248
      int v = e % _node_num;
248 249
      return u < v ? u : _node_num - 2 - u;
249 250
    }
250 251

	
251 252
    int _vid(int e) const {
252 253
      int u = e / _node_num;
253 254
      int v = e % _node_num;
254 255
      return u < v ? v : _node_num - 1 - v;
255 256
    }
256 257

	
257 258
    void _uvid(int e, int& u, int& v) const {
258 259
      u = e / _node_num;
259 260
      v = e % _node_num;
260 261
      if  (u >= v) {
261 262
        u = _node_num - 2 - u;
262 263
        v = _node_num - 1 - v;
263 264
      }
264 265
    }
265 266

	
266 267
    void _stid(int a, int& s, int& t) const {
267 268
      if ((a & 1) == 1) {
268 269
        _uvid(a >> 1, s, t);
269 270
      } else {
270 271
        _uvid(a >> 1, t, s);
271 272
      }
272 273
    }
... ...
@@ -508,68 +509,68 @@
508 509
        _uvid(edge._id, v, u);
509 510
        --v;
510 511
        edge._id = (v != -1 ? _eid(v, u) : -1);
511 512
      }
512 513
    }
513 514

	
514 515
  };
515 516

	
516 517
  typedef GraphExtender<FullGraphBase> ExtendedFullGraphBase;
517 518

	
518 519
  /// \ingroup graphs
519 520
  ///
520 521
  /// \brief An undirected full graph class.
521 522
  ///
522 523
  /// This is a simple and fast undirected full graph
523 524
  /// implementation. From each node go edge to each other node,
524 525
  /// therefore the number of edges in the graph is \f$n(n-1)/2\f$.
525 526
  /// This graph type is completely static, so you can neither
526 527
  /// add nor delete either edges or nodes, and it needs constant
527 528
  /// space in memory.
528 529
  ///
529 530
  /// This class fully conforms to the \ref concepts::Graph "Graph concept".
530 531
  ///
531 532
  /// The \c FullGraph and \c FullDigraph classes are very similar,
532 533
  /// but there are two differences. While the \c FullDigraph class
533 534
  /// conforms only to the \ref concepts::Digraph "Digraph" concept,
534 535
  /// this class conforms to the \ref concepts::Graph "Graph" concept,
535 536
  /// moreover \c FullGraph does not contain a loop arc for each
536 537
  /// node as \c FullDigraph does.
537 538
  ///
538 539
  /// \sa FullDigraph
539 540
  class FullGraph : public ExtendedFullGraphBase {
541
    typedef ExtendedFullGraphBase Parent;
542

	
540 543
  public:
541 544

	
542
    typedef ExtendedFullGraphBase Parent;
543

	
544 545
    /// \brief Constructor
545 546
    FullGraph() { construct(0); }
546 547

	
547 548
    /// \brief Constructor
548 549
    ///
549 550
    /// Constructor.
550 551
    /// \param n The number of the nodes.
551 552
    FullGraph(int n) { construct(n); }
552 553

	
553 554
    /// \brief Resizes the graph
554 555
    ///
555 556
    /// Resizes the graph. The function will fully destroy and
556 557
    /// rebuild the graph. This cause that the maps of the graph will
557 558
    /// reallocated automatically and the previous values will be lost.
558 559
    void resize(int n) {
559 560
      Parent::notifier(Arc()).clear();
560 561
      Parent::notifier(Edge()).clear();
561 562
      Parent::notifier(Node()).clear();
562 563
      construct(n);
563 564
      Parent::notifier(Node()).build();
564 565
      Parent::notifier(Edge()).build();
565 566
      Parent::notifier(Arc()).build();
566 567
    }
567 568

	
568 569
    /// \brief Returns the node with the given index.
569 570
    ///
570 571
    /// Returns the node with the given index. Since it is a static
571 572
    /// graph its nodes can be indexed with integers from the range
572 573
    /// <tt>[0..nodeNum()-1]</tt>.
573 574
    /// \sa index()
574 575
    Node operator()(int ix) const { return Parent::operator()(ix); }
575 576

	
Ignore white space 6 line context
... ...
@@ -40,64 +40,65 @@
40 40
#include<lemon/bits/bezier.h>
41 41
#include<lemon/error.h>
42 42

	
43 43

	
44 44
///\ingroup eps_io
45 45
///\file
46 46
///\brief A well configurable tool for visualizing graphs
47 47

	
48 48
namespace lemon {
49 49

	
50 50
  namespace _graph_to_eps_bits {
51 51
    template<class MT>
52 52
    class _NegY {
53 53
    public:
54 54
      typedef typename MT::Key Key;
55 55
      typedef typename MT::Value Value;
56 56
      const MT &map;
57 57
      int yscale;
58 58
      _NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {}
59 59
      Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);}
60 60
    };
61 61
  }
62 62

	
63 63
///Default traits class of GraphToEps
64 64

	
65 65
///Default traits class of \ref GraphToEps.
66 66
///
67 67
///\param GR is the type of the underlying graph.
68 68
template<class GR>
69 69
struct DefaultGraphToEpsTraits
70 70
{
71 71
  typedef GR Graph;
72
  typedef GR Digraph;
72 73
  typedef typename Graph::Node Node;
73 74
  typedef typename Graph::NodeIt NodeIt;
74 75
  typedef typename Graph::Arc Arc;
75 76
  typedef typename Graph::ArcIt ArcIt;
76 77
  typedef typename Graph::InArcIt InArcIt;
77 78
  typedef typename Graph::OutArcIt OutArcIt;
78 79

	
79 80

	
80 81
  const Graph &g;
81 82

	
82 83
  std::ostream& os;
83 84

	
84 85
  typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType;
85 86
  CoordsMapType _coords;
86 87
  ConstMap<typename Graph::Node,double > _nodeSizes;
87 88
  ConstMap<typename Graph::Node,int > _nodeShapes;
88 89

	
89 90
  ConstMap<typename Graph::Node,Color > _nodeColors;
90 91
  ConstMap<typename Graph::Arc,Color > _arcColors;
91 92

	
92 93
  ConstMap<typename Graph::Arc,double > _arcWidths;
93 94

	
94 95
  double _arcWidthScale;
95 96

	
96 97
  double _nodeScale;
97 98
  double _xBorder, _yBorder;
98 99
  double _scale;
99 100
  double _nodeBorderQuotient;
100 101

	
101 102
  bool _drawArrows;
102 103
  double _arrowLength, _arrowWidth;
103 104

	
... ...
@@ -212,64 +213,65 @@
212 213
  using T::_nodePsTexts;
213 214
  using T::_nodePsTextsPreamble;
214 215

	
215 216
  using T::_undirected;
216 217

	
217 218
  using T::_pleaseRemoveOsStream;
218 219

	
219 220
  using T::_scaleToA4;
220 221

	
221 222
  using T::_title;
222 223
  using T::_copyright;
223 224

	
224 225
  using T::NodeTextColorType;
225 226
  using T::CUST_COL;
226 227
  using T::DIST_COL;
227 228
  using T::DIST_BW;
228 229
  using T::_nodeTextColorType;
229 230
  using T::_nodeTextColors;
230 231

	
231 232
  using T::_autoNodeScale;
232 233
  using T::_autoArcWidthScale;
233 234

	
234 235
  using T::_absoluteNodeSizes;
235 236
  using T::_absoluteArcWidths;
236 237

	
237 238

	
238 239
  using T::_negY;
239 240
  using T::_preScale;
240 241

	
241 242
  // dradnats ++C eht yb deriuqer si ti eveileb t'naC
242 243

	
243 244
  typedef typename T::Graph Graph;
245
  typedef typename T::Digraph Digraph;
244 246
  typedef typename Graph::Node Node;
245 247
  typedef typename Graph::NodeIt NodeIt;
246 248
  typedef typename Graph::Arc Arc;
247 249
  typedef typename Graph::ArcIt ArcIt;
248 250
  typedef typename Graph::InArcIt InArcIt;
249 251
  typedef typename Graph::OutArcIt OutArcIt;
250 252

	
251 253
  static const int INTERPOL_PREC;
252 254
  static const double A4HEIGHT;
253 255
  static const double A4WIDTH;
254 256
  static const double A4BORDER;
255 257

	
256 258
  bool dontPrint;
257 259

	
258 260
public:
259 261
  ///Node shapes
260 262

	
261 263
  ///Node shapes.
262 264
  ///
263 265
  enum NodeShapes {
264 266
    /// = 0
265 267
    ///\image html nodeshape_0.png
266 268
    ///\image latex nodeshape_0.eps "CIRCLE shape (0)" width=2cm
267 269
    CIRCLE=0,
268 270
    /// = 1
269 271
    ///\image html nodeshape_1.png
270 272
    ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
271 273
    SQUARE=1,
272 274
    /// = 2
273 275
    ///\image html nodeshape_2.png
274 276
    ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
275 277
    DIAMOND=2,
Ignore white space 6 line context
... ...
@@ -470,68 +470,68 @@
470 470
  ///
471 471
  /// \brief Grid graph class
472 472
  ///
473 473
  /// This class implements a special graph type. The nodes of the
474 474
  /// graph can be indexed by two integer \c (i,j) value where \c i is
475 475
  /// in the \c [0..width()-1] range and j is in the \c
476 476
  /// [0..height()-1] range.  Two nodes are connected in the graph if
477 477
  /// the indexes differ exactly on one position and exactly one is
478 478
  /// the difference. The nodes of the graph can be indexed by position
479 479
  /// with the \c operator()() function. The positions of the nodes can be
480 480
  /// get with \c pos(), \c col() and \c row() members. The outgoing
481 481
  /// arcs can be retrieved with the \c right(), \c up(), \c left()
482 482
  /// and \c down() functions, where the bottom-left corner is the
483 483
  /// origin.
484 484
  ///
485 485
  /// \image html grid_graph.png
486 486
  /// \image latex grid_graph.eps "Grid graph" width=\textwidth
487 487
  ///
488 488
  /// A short example about the basic usage:
489 489
  ///\code
490 490
  /// GridGraph graph(rows, cols);
491 491
  /// GridGraph::NodeMap<int> val(graph);
492 492
  /// for (int i = 0; i < graph.width(); ++i) {
493 493
  ///   for (int j = 0; j < graph.height(); ++j) {
494 494
  ///     val[graph(i, j)] = i + j;
495 495
  ///   }
496 496
  /// }
497 497
  ///\endcode
498 498
  ///
499 499
  /// This graph type fully conforms to the \ref concepts::Graph
500 500
  /// "Graph concept".
501 501
  class GridGraph : public ExtendedGridGraphBase {
502
    typedef ExtendedGridGraphBase Parent;
503

	
502 504
  public:
503 505

	
504
    typedef ExtendedGridGraphBase Parent;
505

	
506 506
    /// \brief Map to get the indices of the nodes as dim2::Point<int>.
507 507
    ///
508 508
    /// Map to get the indices of the nodes as dim2::Point<int>.
509 509
    class IndexMap {
510 510
    public:
511 511
      /// \brief The key type of the map
512 512
      typedef GridGraph::Node Key;
513 513
      /// \brief The value type of the map
514 514
      typedef dim2::Point<int> Value;
515 515

	
516 516
      /// \brief Constructor
517 517
      ///
518 518
      /// Constructor
519 519
      IndexMap(const GridGraph& graph) : _graph(graph) {}
520 520

	
521 521
      /// \brief The subscript operator
522 522
      ///
523 523
      /// The subscript operator.
524 524
      Value operator[](Key key) const {
525 525
        return _graph.pos(key);
526 526
      }
527 527

	
528 528
    private:
529 529
      const GridGraph& _graph;
530 530
    };
531 531

	
532 532
    /// \brief Map to get the column of the nodes.
533 533
    ///
534 534
    /// Map to get the column of the nodes.
535 535
    class ColMap {
536 536
    public:
537 537
      /// \brief The key type of the map
Ignore white space 6 line context
... ...
@@ -265,68 +265,68 @@
265 265
    int index(Node node) const {
266 266
      return node._id;
267 267
    }
268 268

	
269 269
    Node operator()(int ix) const {
270 270
      return Node(ix);
271 271
    }
272 272

	
273 273
  private:
274 274
    int _dim;
275 275
    int _node_num, _edge_num;
276 276
  };
277 277

	
278 278

	
279 279
  typedef GraphExtender<HypercubeGraphBase> ExtendedHypercubeGraphBase;
280 280

	
281 281
  /// \ingroup graphs
282 282
  ///
283 283
  /// \brief Hypercube graph class
284 284
  ///
285 285
  /// This class implements a special graph type. The nodes of the graph
286 286
  /// are indiced with integers with at most \c dim binary digits.
287 287
  /// Two nodes are connected in the graph if and only if their indices
288 288
  /// differ only on one position in the binary form.
289 289
  ///
290 290
  /// \note The type of the indices is chosen to \c int for efficiency
291 291
  /// reasons. Thus the maximum dimension of this implementation is 26
292 292
  /// (assuming that the size of \c int is 32 bit).
293 293
  ///
294 294
  /// This graph type fully conforms to the \ref concepts::Graph
295 295
  /// "Graph concept".
296 296
  class HypercubeGraph : public ExtendedHypercubeGraphBase {
297
    typedef ExtendedHypercubeGraphBase Parent;
298

	
297 299
  public:
298 300

	
299
    typedef ExtendedHypercubeGraphBase Parent;
300

	
301 301
    /// \brief Constructs a hypercube graph with \c dim dimensions.
302 302
    ///
303 303
    /// Constructs a hypercube graph with \c dim dimensions.
304 304
    HypercubeGraph(int dim) { construct(dim); }
305 305

	
306 306
    /// \brief The number of dimensions.
307 307
    ///
308 308
    /// Gives back the number of dimensions.
309 309
    int dimension() const {
310 310
      return Parent::dimension();
311 311
    }
312 312

	
313 313
    /// \brief Returns \c true if the n'th bit of the node is one.
314 314
    ///
315 315
    /// Returns \c true if the n'th bit of the node is one.
316 316
    bool projection(Node node, int n) const {
317 317
      return Parent::projection(node, n);
318 318
    }
319 319

	
320 320
    /// \brief The dimension id of an edge.
321 321
    ///
322 322
    /// Gives back the dimension id of the given edge.
323 323
    /// It is in the [0..dim-1] range.
324 324
    int dimension(Edge edge) const {
325 325
      return Parent::dimension(edge);
326 326
    }
327 327

	
328 328
    /// \brief The dimension id of an arc.
329 329
    ///
330 330
    /// Gives back the dimension id of the given arc.
331 331
    /// It is in the [0..dim-1] range.
332 332
    int dimension(Arc arc) const {
Ignore white space 6 line context
... ...
@@ -294,80 +294,80 @@
294 294
        arcs[arcs[e.id].prev_out].next_out = arcs[e.id].next_out;
295 295
      else nodes[arcs[e.id].source].first_out = arcs[e.id].next_out;
296 296
      if (nodes[n.id].first_out != -1) {
297 297
        arcs[nodes[n.id].first_out].prev_out = e.id;
298 298
      }
299 299
      arcs[e.id].source = n.id;
300 300
      arcs[e.id].prev_out = -1;
301 301
      arcs[e.id].next_out = nodes[n.id].first_out;
302 302
      nodes[n.id].first_out = e.id;
303 303
    }
304 304

	
305 305
  };
306 306

	
307 307
  typedef DigraphExtender<ListDigraphBase> ExtendedListDigraphBase;
308 308

	
309 309
  /// \addtogroup graphs
310 310
  /// @{
311 311

	
312 312
  ///A general directed graph structure.
313 313

	
314 314
  ///\ref ListDigraph is a simple and fast <em>directed graph</em>
315 315
  ///implementation based on static linked lists that are stored in
316 316
  ///\c std::vector structures.
317 317
  ///
318 318
  ///It conforms to the \ref concepts::Digraph "Digraph concept" and it
319 319
  ///also provides several useful additional functionalities.
320 320
  ///Most of the member functions and nested classes are documented
321 321
  ///only in the concept class.
322 322
  ///
323 323
  ///\sa concepts::Digraph
324 324

	
325 325
  class ListDigraph : public ExtendedListDigraphBase {
326
    typedef ExtendedListDigraphBase Parent;
327

	
326 328
  private:
327 329
    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
328 330

	
329 331
    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
330 332
    ///
331 333
    ListDigraph(const ListDigraph &) :ExtendedListDigraphBase() {};
332 334
    ///\brief Assignment of ListDigraph to another one is \e not allowed.
333 335
    ///Use copyDigraph() instead.
334 336

	
335 337
    ///Assignment of ListDigraph to another one is \e not allowed.
336 338
    ///Use copyDigraph() instead.
337 339
    void operator=(const ListDigraph &) {}
338 340
  public:
339 341

	
340
    typedef ExtendedListDigraphBase Parent;
341

	
342 342
    /// Constructor
343 343

	
344 344
    /// Constructor.
345 345
    ///
346 346
    ListDigraph() {}
347 347

	
348 348
    ///Add a new node to the digraph.
349 349

	
350 350
    ///Add a new node to the digraph.
351 351
    ///\return The new node.
352 352
    Node addNode() { return Parent::addNode(); }
353 353

	
354 354
    ///Add a new arc to the digraph.
355 355

	
356 356
    ///Add a new arc to the digraph with source node \c s
357 357
    ///and target node \c t.
358 358
    ///\return The new arc.
359 359
    Arc addArc(const Node& s, const Node& t) {
360 360
      return Parent::addArc(s, t);
361 361
    }
362 362

	
363 363
    ///\brief Erase a node from the digraph.
364 364
    ///
365 365
    ///Erase a node from the digraph.
366 366
    ///
367 367
    void erase(const Node& n) { Parent::erase(n); }
368 368

	
369 369
    ///\brief Erase an arc from the digraph.
370 370
    ///
371 371
    ///Erase an arc from the digraph.
372 372
    ///
373 373
    void erase(const Arc& a) { Parent::erase(a); }
... ...
@@ -764,65 +764,65 @@
764 764
    };
765 765

	
766 766
  };
767 767

	
768 768
  ///@}
769 769

	
770 770
  class ListGraphBase {
771 771

	
772 772
  protected:
773 773

	
774 774
    struct NodeT {
775 775
      int first_out;
776 776
      int prev, next;
777 777
    };
778 778

	
779 779
    struct ArcT {
780 780
      int target;
781 781
      int prev_out, next_out;
782 782
    };
783 783

	
784 784
    std::vector<NodeT> nodes;
785 785

	
786 786
    int first_node;
787 787

	
788 788
    int first_free_node;
789 789

	
790 790
    std::vector<ArcT> arcs;
791 791

	
792 792
    int first_free_arc;
793 793

	
794 794
  public:
795 795

	
796
    typedef ListGraphBase Digraph;
796
    typedef ListGraphBase Graph;
797 797

	
798 798
    class Node;
799 799
    class Arc;
800 800
    class Edge;
801 801

	
802 802
    class Node {
803 803
      friend class ListGraphBase;
804 804
    protected:
805 805

	
806 806
      int id;
807 807
      explicit Node(int pid) { id = pid;}
808 808

	
809 809
    public:
810 810
      Node() {}
811 811
      Node (Invalid) { id = -1; }
812 812
      bool operator==(const Node& node) const {return id == node.id;}
813 813
      bool operator!=(const Node& node) const {return id != node.id;}
814 814
      bool operator<(const Node& node) const {return id < node.id;}
815 815
    };
816 816

	
817 817
    class Edge {
818 818
      friend class ListGraphBase;
819 819
    protected:
820 820

	
821 821
      int id;
822 822
      explicit Edge(int pid) { id = pid;}
823 823

	
824 824
    public:
825 825
      Edge() {}
826 826
      Edge (Invalid) { id = -1; }
827 827
      bool operator==(const Edge& edge) const {return id == edge.id;}
828 828
      bool operator!=(const Edge& edge) const {return id != edge.id;}
... ...
@@ -1147,85 +1147,85 @@
1147 1147

	
1148 1148
      if (nodes[n.id].first_out != -1) {
1149 1149
        arcs[nodes[n.id].first_out].prev_out = ((2 * e.id) | 1);
1150 1150
      }
1151 1151
      arcs[2 * e.id].target = n.id;
1152 1152
      arcs[(2 * e.id) | 1].prev_out = -1;
1153 1153
      arcs[(2 * e.id) | 1].next_out = nodes[n.id].first_out;
1154 1154
      nodes[n.id].first_out = ((2 * e.id) | 1);
1155 1155
    }
1156 1156

	
1157 1157
  };
1158 1158

	
1159 1159
  typedef GraphExtender<ListGraphBase> ExtendedListGraphBase;
1160 1160

	
1161 1161

	
1162 1162
  /// \addtogroup graphs
1163 1163
  /// @{
1164 1164

	
1165 1165
  ///A general undirected graph structure.
1166 1166

	
1167 1167
  ///\ref ListGraph is a simple and fast <em>undirected graph</em>
1168 1168
  ///implementation based on static linked lists that are stored in
1169 1169
  ///\c std::vector structures.
1170 1170
  ///
1171 1171
  ///It conforms to the \ref concepts::Graph "Graph concept" and it
1172 1172
  ///also provides several useful additional functionalities.
1173 1173
  ///Most of the member functions and nested classes are documented
1174 1174
  ///only in the concept class.
1175 1175
  ///
1176 1176
  ///\sa concepts::Graph
1177 1177

	
1178 1178
  class ListGraph : public ExtendedListGraphBase {
1179
    typedef ExtendedListGraphBase Parent;
1180

	
1179 1181
  private:
1180 1182
    ///ListGraph is \e not copy constructible. Use copyGraph() instead.
1181 1183

	
1182 1184
    ///ListGraph is \e not copy constructible. Use copyGraph() instead.
1183 1185
    ///
1184 1186
    ListGraph(const ListGraph &) :ExtendedListGraphBase()  {};
1185 1187
    ///\brief Assignment of ListGraph to another one is \e not allowed.
1186 1188
    ///Use copyGraph() instead.
1187 1189

	
1188 1190
    ///Assignment of ListGraph to another one is \e not allowed.
1189 1191
    ///Use copyGraph() instead.
1190 1192
    void operator=(const ListGraph &) {}
1191 1193
  public:
1192 1194
    /// Constructor
1193 1195

	
1194 1196
    /// Constructor.
1195 1197
    ///
1196 1198
    ListGraph() {}
1197 1199

	
1198
    typedef ExtendedListGraphBase Parent;
1199

	
1200 1200
    typedef Parent::OutArcIt IncEdgeIt;
1201 1201

	
1202 1202
    /// \brief Add a new node to the graph.
1203 1203
    ///
1204 1204
    /// Add a new node to the graph.
1205 1205
    /// \return The new node.
1206 1206
    Node addNode() { return Parent::addNode(); }
1207 1207

	
1208 1208
    /// \brief Add a new edge to the graph.
1209 1209
    ///
1210 1210
    /// Add a new edge to the graph with source node \c s
1211 1211
    /// and target node \c t.
1212 1212
    /// \return The new edge.
1213 1213
    Edge addEdge(const Node& s, const Node& t) {
1214 1214
      return Parent::addEdge(s, t);
1215 1215
    }
1216 1216

	
1217 1217
    /// \brief Erase a node from the graph.
1218 1218
    ///
1219 1219
    /// Erase a node from the graph.
1220 1220
    ///
1221 1221
    void erase(const Node& n) { Parent::erase(n); }
1222 1222

	
1223 1223
    /// \brief Erase an edge from the graph.
1224 1224
    ///
1225 1225
    /// Erase an edge from the graph.
1226 1226
    ///
1227 1227
    void erase(const Edge& e) { Parent::erase(e); }
1228 1228
    /// Node validity check
1229 1229

	
1230 1230
    /// This function gives back true if the given node is valid,
1231 1231
    /// ie. it is a real node of the graph.
Ignore white space 6 line context
... ...
@@ -1809,64 +1809,65 @@
1809 1809
  inline LoggerBoolMap<Iterator> loggerBoolMap(Iterator it) {
1810 1810
    return LoggerBoolMap<Iterator>(it);
1811 1811
  }
1812 1812

	
1813 1813
  /// @}
1814 1814

	
1815 1815
  /// \addtogroup graph_maps
1816 1816
  /// @{
1817 1817

	
1818 1818
  /// \brief Provides an immutable and unique id for each item in a graph.
1819 1819
  ///
1820 1820
  /// IdMap provides a unique and immutable id for each item of the
1821 1821
  /// same type (\c Node, \c Arc or \c Edge) in a graph. This id is 
1822 1822
  ///  - \b unique: different items get different ids,
1823 1823
  ///  - \b immutable: the id of an item does not change (even if you
1824 1824
  ///    delete other nodes).
1825 1825
  ///
1826 1826
  /// Using this map you get access (i.e. can read) the inner id values of
1827 1827
  /// the items stored in the graph, which is returned by the \c id()
1828 1828
  /// function of the graph. This map can be inverted with its member
1829 1829
  /// class \c InverseMap or with the \c operator() member.
1830 1830
  ///
1831 1831
  /// \tparam GR The graph type.
1832 1832
  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
1833 1833
  /// \c GR::Edge).
1834 1834
  ///
1835 1835
  /// \see RangeIdMap
1836 1836
  template <typename GR, typename K>
1837 1837
  class IdMap : public MapBase<K, int> {
1838 1838
  public:
1839 1839
    /// The graph type of IdMap.
1840 1840
    typedef GR Graph;
1841
    typedef GR Digraph;
1841 1842
    /// The key type of IdMap (\c Node, \c Arc or \c Edge).
1842 1843
    typedef K Item;
1843 1844
    /// The key type of IdMap (\c Node, \c Arc or \c Edge).
1844 1845
    typedef K Key;
1845 1846
    /// The value type of IdMap.
1846 1847
    typedef int Value;
1847 1848

	
1848 1849
    /// \brief Constructor.
1849 1850
    ///
1850 1851
    /// Constructor of the map.
1851 1852
    explicit IdMap(const Graph& graph) : _graph(&graph) {}
1852 1853

	
1853 1854
    /// \brief Gives back the \e id of the item.
1854 1855
    ///
1855 1856
    /// Gives back the immutable and unique \e id of the item.
1856 1857
    int operator[](const Item& item) const { return _graph->id(item);}
1857 1858

	
1858 1859
    /// \brief Gives back the \e item by its id.
1859 1860
    ///
1860 1861
    /// Gives back the \e item by its id.
1861 1862
    Item operator()(int id) { return _graph->fromId(id, Item()); }
1862 1863

	
1863 1864
  private:
1864 1865
    const Graph* _graph;
1865 1866

	
1866 1867
  public:
1867 1868

	
1868 1869
    /// \brief This class represents the inverse of its owner (IdMap).
1869 1870
    ///
1870 1871
    /// This class represents the inverse of its owner (IdMap).
1871 1872
    /// \see inverse()
1872 1873
    class InverseMap {
... ...
@@ -1900,64 +1901,65 @@
1900 1901

	
1901 1902
  /// \brief General cross reference graph map type.
1902 1903

	
1903 1904
  /// This class provides simple invertable graph maps.
1904 1905
  /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap"
1905 1906
  /// and if a key is set to a new value then store it
1906 1907
  /// in the inverse map.
1907 1908
  ///
1908 1909
  /// The values of the map can be accessed
1909 1910
  /// with stl compatible forward iterator.
1910 1911
  ///
1911 1912
  /// \tparam GR The graph type.
1912 1913
  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
1913 1914
  /// \c GR::Edge).
1914 1915
  /// \tparam V The value type of the map.
1915 1916
  ///
1916 1917
  /// \see IterableValueMap
1917 1918
  template <typename GR, typename K, typename V>
1918 1919
  class CrossRefMap
1919 1920
    : protected ItemSetTraits<GR, K>::template Map<V>::Type {
1920 1921
  private:
1921 1922

	
1922 1923
    typedef typename ItemSetTraits<GR, K>::
1923 1924
      template Map<V>::Type Map;
1924 1925

	
1925 1926
    typedef std::map<V, K> Container;
1926 1927
    Container _inv_map;
1927 1928

	
1928 1929
  public:
1929 1930

	
1930 1931
    /// The graph type of CrossRefMap.
1931 1932
    typedef GR Graph;
1933
    typedef GR Digraph;
1932 1934
    /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge).
1933 1935
    typedef K Item;
1934 1936
    /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge).
1935 1937
    typedef K Key;
1936 1938
    /// The value type of CrossRefMap.
1937 1939
    typedef V Value;
1938 1940

	
1939 1941
    /// \brief Constructor.
1940 1942
    ///
1941 1943
    /// Construct a new CrossRefMap for the given graph.
1942 1944
    explicit CrossRefMap(const Graph& graph) : Map(graph) {}
1943 1945

	
1944 1946
    /// \brief Forward iterator for values.
1945 1947
    ///
1946 1948
    /// This iterator is an stl compatible forward
1947 1949
    /// iterator on the values of the map. The values can
1948 1950
    /// be accessed in the <tt>[beginValue, endValue)</tt> range.
1949 1951
    class ValueIterator
1950 1952
      : public std::iterator<std::forward_iterator_tag, Value> {
1951 1953
      friend class CrossRefMap;
1952 1954
    private:
1953 1955
      ValueIterator(typename Container::const_iterator _it)
1954 1956
        : it(_it) {}
1955 1957
    public:
1956 1958

	
1957 1959
      ValueIterator() {}
1958 1960

	
1959 1961
      ValueIterator& operator++() { ++it; return *this; }
1960 1962
      ValueIterator operator++(int) {
1961 1963
        ValueIterator tmp(*this);
1962 1964
        operator++();
1963 1965
        return tmp;
... ...
@@ -2103,64 +2105,65 @@
2103 2105

	
2104 2106
  /// \brief Provides continuous and unique ID for the
2105 2107
  /// items of a graph.
2106 2108
  ///
2107 2109
  /// RangeIdMap provides a unique and continuous
2108 2110
  /// ID for each item of a given type (\c Node, \c Arc or
2109 2111
  /// \c Edge) in a graph. This id is
2110 2112
  ///  - \b unique: different items get different ids,
2111 2113
  ///  - \b continuous: the range of the ids is the set of integers
2112 2114
  ///    between 0 and \c n-1, where \c n is the number of the items of
2113 2115
  ///    this type (\c Node, \c Arc or \c Edge).
2114 2116
  ///  - So, the ids can change when deleting an item of the same type.
2115 2117
  ///
2116 2118
  /// Thus this id is not (necessarily) the same as what can get using
2117 2119
  /// the \c id() function of the graph or \ref IdMap.
2118 2120
  /// This map can be inverted with its member class \c InverseMap,
2119 2121
  /// or with the \c operator() member.
2120 2122
  ///
2121 2123
  /// \tparam GR The graph type.
2122 2124
  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
2123 2125
  /// \c GR::Edge).
2124 2126
  ///
2125 2127
  /// \see IdMap
2126 2128
  template <typename GR, typename K>
2127 2129
  class RangeIdMap
2128 2130
    : protected ItemSetTraits<GR, K>::template Map<int>::Type {
2129 2131

	
2130 2132
    typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Map;
2131 2133

	
2132 2134
  public:
2133 2135
    /// The graph type of RangeIdMap.
2134 2136
    typedef GR Graph;
2137
    typedef GR Digraph;
2135 2138
    /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
2136 2139
    typedef K Item;
2137 2140
    /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge).
2138 2141
    typedef K Key;
2139 2142
    /// The value type of RangeIdMap.
2140 2143
    typedef int Value;
2141 2144

	
2142 2145
    /// \brief Constructor.
2143 2146
    ///
2144 2147
    /// Constructor.
2145 2148
    explicit RangeIdMap(const Graph& gr) : Map(gr) {
2146 2149
      Item it;
2147 2150
      const typename Map::Notifier* nf = Map::notifier();
2148 2151
      for (nf->first(it); it != INVALID; nf->next(it)) {
2149 2152
        Map::set(it, _inv_map.size());
2150 2153
        _inv_map.push_back(it);
2151 2154
      }
2152 2155
    }
2153 2156

	
2154 2157
  protected:
2155 2158

	
2156 2159
    /// \brief Adds a new key to the map.
2157 2160
    ///
2158 2161
    /// Add a new key to the map. It is called by the
2159 2162
    /// \c AlterationNotifier.
2160 2163
    virtual void add(const Item& item) {
2161 2164
      Map::add(item);
2162 2165
      Map::set(item, _inv_map.size());
2163 2166
      _inv_map.push_back(item);
2164 2167
    }
2165 2168

	
2166 2169
    /// \brief Add more new keys to the map.
... ...
@@ -2465,65 +2468,66 @@
2465 2468

	
2466 2469
  /// This function just returns a \c BackwardMap class.
2467 2470
  /// \relates BackwardMap
2468 2471
  template <typename GR>
2469 2472
  inline BackwardMap<GR> backwardMap(const GR& graph) {
2470 2473
    return BackwardMap<GR>(graph);
2471 2474
  }
2472 2475

	
2473 2476
  /// \brief Map of the in-degrees of nodes in a digraph.
2474 2477
  ///
2475 2478
  /// This map returns the in-degree of a node. Once it is constructed,
2476 2479
  /// the degrees are stored in a standard \c NodeMap, so each query is done
2477 2480
  /// in constant time. On the other hand, the values are updated automatically
2478 2481
  /// whenever the digraph changes.
2479 2482
  ///
2480 2483
  /// \warning Besides \c addNode() and \c addArc(), a digraph structure 
2481 2484
  /// may provide alternative ways to modify the digraph.
2482 2485
  /// The correct behavior of InDegMap is not guarantied if these additional
2483 2486
  /// features are used. For example the functions
2484 2487
  /// \ref ListDigraph::changeSource() "changeSource()",
2485 2488
  /// \ref ListDigraph::changeTarget() "changeTarget()" and
2486 2489
  /// \ref ListDigraph::reverseArc() "reverseArc()"
2487 2490
  /// of \ref ListDigraph will \e not update the degree values correctly.
2488 2491
  ///
2489 2492
  /// \sa OutDegMap
2490 2493
  template <typename GR>
2491 2494
  class InDegMap
2492 2495
    : protected ItemSetTraits<GR, typename GR::Arc>
2493 2496
      ::ItemNotifier::ObserverBase {
2494 2497

	
2495 2498
  public:
2496 2499
    
2497
    /// The digraph type
2500
    /// The graph type of InDegMap
2501
    typedef GR Graph;
2498 2502
    typedef GR Digraph;
2499 2503
    /// The key type
2500 2504
    typedef typename Digraph::Node Key;
2501 2505
    /// The value type
2502 2506
    typedef int Value;
2503 2507

	
2504 2508
    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
2505 2509
    ::ItemNotifier::ObserverBase Parent;
2506 2510

	
2507 2511
  private:
2508 2512

	
2509 2513
    class AutoNodeMap
2510 2514
      : public ItemSetTraits<Digraph, Key>::template Map<int>::Type {
2511 2515
    public:
2512 2516

	
2513 2517
      typedef typename ItemSetTraits<Digraph, Key>::
2514 2518
      template Map<int>::Type Parent;
2515 2519

	
2516 2520
      AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
2517 2521

	
2518 2522
      virtual void add(const Key& key) {
2519 2523
        Parent::add(key);
2520 2524
        Parent::set(key, 0);
2521 2525
      }
2522 2526

	
2523 2527
      virtual void add(const std::vector<Key>& keys) {
2524 2528
        Parent::add(keys);
2525 2529
        for (int i = 0; i < int(keys.size()); ++i) {
2526 2530
          Parent::set(keys[i], 0);
2527 2531
        }
2528 2532
      }
2529 2533

	
... ...
@@ -2594,65 +2598,66 @@
2594 2598
      }
2595 2599
    }
2596 2600
  private:
2597 2601

	
2598 2602
    const Digraph& _digraph;
2599 2603
    AutoNodeMap _deg;
2600 2604
  };
2601 2605

	
2602 2606
  /// \brief Map of the out-degrees of nodes in a digraph.
2603 2607
  ///
2604 2608
  /// This map returns the out-degree of a node. Once it is constructed,
2605 2609
  /// the degrees are stored in a standard \c NodeMap, so each query is done
2606 2610
  /// in constant time. On the other hand, the values are updated automatically
2607 2611
  /// whenever the digraph changes.
2608 2612
  ///
2609 2613
  /// \warning Besides \c addNode() and \c addArc(), a digraph structure 
2610 2614
  /// may provide alternative ways to modify the digraph.
2611 2615
  /// The correct behavior of OutDegMap is not guarantied if these additional
2612 2616
  /// features are used. For example the functions
2613 2617
  /// \ref ListDigraph::changeSource() "changeSource()",
2614 2618
  /// \ref ListDigraph::changeTarget() "changeTarget()" and
2615 2619
  /// \ref ListDigraph::reverseArc() "reverseArc()"
2616 2620
  /// of \ref ListDigraph will \e not update the degree values correctly.
2617 2621
  ///
2618 2622
  /// \sa InDegMap
2619 2623
  template <typename GR>
2620 2624
  class OutDegMap
2621 2625
    : protected ItemSetTraits<GR, typename GR::Arc>
2622 2626
      ::ItemNotifier::ObserverBase {
2623 2627

	
2624 2628
  public:
2625 2629

	
2626
    /// The digraph type
2630
    /// The graph type of OutDegMap
2631
    typedef GR Graph;
2627 2632
    typedef GR Digraph;
2628 2633
    /// The key type
2629 2634
    typedef typename Digraph::Node Key;
2630 2635
    /// The value type
2631 2636
    typedef int Value;
2632 2637

	
2633 2638
    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
2634 2639
    ::ItemNotifier::ObserverBase Parent;
2635 2640

	
2636 2641
  private:
2637 2642

	
2638 2643
    class AutoNodeMap
2639 2644
      : public ItemSetTraits<Digraph, Key>::template Map<int>::Type {
2640 2645
    public:
2641 2646

	
2642 2647
      typedef typename ItemSetTraits<Digraph, Key>::
2643 2648
      template Map<int>::Type Parent;
2644 2649

	
2645 2650
      AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
2646 2651

	
2647 2652
      virtual void add(const Key& key) {
2648 2653
        Parent::add(key);
2649 2654
        Parent::set(key, 0);
2650 2655
      }
2651 2656
      virtual void add(const std::vector<Key>& keys) {
2652 2657
        Parent::add(keys);
2653 2658
        for (int i = 0; i < int(keys.size()); ++i) {
2654 2659
          Parent::set(keys[i], 0);
2655 2660
        }
2656 2661
      }
2657 2662
      virtual void build() {
2658 2663
        Parent::build();
Ignore white space 6 line context
... ...
@@ -26,65 +26,65 @@
26 26
#include <vector>
27 27

	
28 28
#include <lemon/core.h>
29 29
#include <lemon/error.h>
30 30
#include <lemon/bits/graph_extender.h>
31 31

	
32 32
namespace lemon {
33 33

	
34 34
  class SmartDigraph;
35 35
  ///Base of SmartDigraph
36 36

	
37 37
  ///Base of SmartDigraph
38 38
  ///
39 39
  class SmartDigraphBase {
40 40
  protected:
41 41

	
42 42
    struct NodeT
43 43
    {
44 44
      int first_in, first_out;
45 45
      NodeT() {}
46 46
    };
47 47
    struct ArcT
48 48
    {
49 49
      int target, source, next_in, next_out;
50 50
      ArcT() {}
51 51
    };
52 52

	
53 53
    std::vector<NodeT> nodes;
54 54
    std::vector<ArcT> arcs;
55 55

	
56 56
  public:
57 57

	
58
    typedef SmartDigraphBase Graph;
58
    typedef SmartDigraphBase Digraph;
59 59

	
60 60
    class Node;
61 61
    class Arc;
62 62

	
63 63
  public:
64 64

	
65 65
    SmartDigraphBase() : nodes(), arcs() { }
66 66
    SmartDigraphBase(const SmartDigraphBase &_g)
67 67
      : nodes(_g.nodes), arcs(_g.arcs) { }
68 68

	
69 69
    typedef True NodeNumTag;
70 70
    typedef True ArcNumTag;
71 71

	
72 72
    int nodeNum() const { return nodes.size(); }
73 73
    int arcNum() const { return arcs.size(); }
74 74

	
75 75
    int maxNodeId() const { return nodes.size()-1; }
76 76
    int maxArcId() const { return arcs.size()-1; }
77 77

	
78 78
    Node addNode() {
79 79
      int n = nodes.size();
80 80
      nodes.push_back(NodeT());
81 81
      nodes[n].first_in = -1;
82 82
      nodes[n].first_out = -1;
83 83
      return Node(n);
84 84
    }
85 85

	
86 86
    Arc addArc(Node u, Node v) {
87 87
      int n = arcs.size();
88 88
      arcs.push_back(ArcT());
89 89
      arcs[n].source = u._id;
90 90
      arcs[n].target = v._id;
... ...
@@ -166,66 +166,64 @@
166 166
    void firstOut(Arc& arc, const Node& node) const {
167 167
      arc._id = nodes[node._id].first_out;
168 168
    }
169 169

	
170 170
    void nextOut(Arc& arc) const {
171 171
      arc._id = arcs[arc._id].next_out;
172 172
    }
173 173

	
174 174
    void firstIn(Arc& arc, const Node& node) const {
175 175
      arc._id = nodes[node._id].first_in;
176 176
    }
177 177

	
178 178
    void nextIn(Arc& arc) const {
179 179
      arc._id = arcs[arc._id].next_in;
180 180
    }
181 181

	
182 182
  };
183 183

	
184 184
  typedef DigraphExtender<SmartDigraphBase> ExtendedSmartDigraphBase;
185 185

	
186 186
  ///\ingroup graphs
187 187
  ///
188 188
  ///\brief A smart directed graph class.
189 189
  ///
190 190
  ///This is a simple and fast digraph implementation.
191 191
  ///It is also quite memory efficient, but at the price
192 192
  ///that <b> it does support only limited (only stack-like)
193 193
  ///node and arc deletions</b>.
194 194
  ///It fully conforms to the \ref concepts::Digraph "Digraph concept".
195 195
  ///
196 196
  ///\sa concepts::Digraph.
197 197
  class SmartDigraph : public ExtendedSmartDigraphBase {
198
  public:
199

	
200 198
    typedef ExtendedSmartDigraphBase Parent;
201 199

	
202 200
  private:
203 201

	
204 202
    ///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead.
205 203

	
206 204
    ///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead.
207 205
    ///
208 206
    SmartDigraph(const SmartDigraph &) : ExtendedSmartDigraphBase() {};
209 207
    ///\brief Assignment of SmartDigraph to another one is \e not allowed.
210 208
    ///Use DigraphCopy() instead.
211 209

	
212 210
    ///Assignment of SmartDigraph to another one is \e not allowed.
213 211
    ///Use DigraphCopy() instead.
214 212
    void operator=(const SmartDigraph &) {}
215 213

	
216 214
  public:
217 215

	
218 216
    /// Constructor
219 217

	
220 218
    /// Constructor.
221 219
    ///
222 220
    SmartDigraph() {};
223 221

	
224 222
    ///Add a new node to the digraph.
225 223

	
226 224
    /// Add a new node to the digraph.
227 225
    /// \return The new node.
228 226
    Node addNode() { return Parent::addNode(); }
229 227

	
230 228
    ///Add a new arc to the digraph.
231 229

	
... ...
@@ -391,65 +389,65 @@
391 389
      ///
392 390
      ///\note After you restored a state, you cannot restore
393 391
      ///a later state, in other word you cannot add again the arcs deleted
394 392
      ///by restore().
395 393
      void restore()
396 394
      {
397 395
        _graph->restoreSnapshot(*this);
398 396
      }
399 397
    };
400 398
  };
401 399

	
402 400

	
403 401
  class SmartGraphBase {
404 402

	
405 403
  protected:
406 404

	
407 405
    struct NodeT {
408 406
      int first_out;
409 407
    };
410 408

	
411 409
    struct ArcT {
412 410
      int target;
413 411
      int next_out;
414 412
    };
415 413

	
416 414
    std::vector<NodeT> nodes;
417 415
    std::vector<ArcT> arcs;
418 416

	
419 417
    int first_free_arc;
420 418

	
421 419
  public:
422 420

	
423
    typedef SmartGraphBase Digraph;
421
    typedef SmartGraphBase Graph;
424 422

	
425 423
    class Node;
426 424
    class Arc;
427 425
    class Edge;
428 426

	
429 427
    class Node {
430 428
      friend class SmartGraphBase;
431 429
    protected:
432 430

	
433 431
      int _id;
434 432
      explicit Node(int id) { _id = id;}
435 433

	
436 434
    public:
437 435
      Node() {}
438 436
      Node (Invalid) { _id = -1; }
439 437
      bool operator==(const Node& node) const {return _id == node._id;}
440 438
      bool operator!=(const Node& node) const {return _id != node._id;}
441 439
      bool operator<(const Node& node) const {return _id < node._id;}
442 440
    };
443 441

	
444 442
    class Edge {
445 443
      friend class SmartGraphBase;
446 444
    protected:
447 445

	
448 446
      int _id;
449 447
      explicit Edge(int id) { _id = id;}
450 448

	
451 449
    public:
452 450
      Edge() {}
453 451
      Edge (Invalid) { _id = -1; }
454 452
      bool operator==(const Edge& arc) const {return _id == arc._id;}
455 453
      bool operator!=(const Edge& arc) const {return _id != arc._id;}
... ...
@@ -602,83 +600,83 @@
602 600
      arcs[n | 1].target = v._id;
603 601

	
604 602
      arcs[n].next_out = nodes[v._id].first_out;
605 603
      nodes[v._id].first_out = n;
606 604

	
607 605
      arcs[n | 1].next_out = nodes[u._id].first_out;
608 606
      nodes[u._id].first_out = (n | 1);
609 607

	
610 608
      return Edge(n / 2);
611 609
    }
612 610

	
613 611
    void clear() {
614 612
      arcs.clear();
615 613
      nodes.clear();
616 614
    }
617 615

	
618 616
  };
619 617

	
620 618
  typedef GraphExtender<SmartGraphBase> ExtendedSmartGraphBase;
621 619

	
622 620
  /// \ingroup graphs
623 621
  ///
624 622
  /// \brief A smart undirected graph class.
625 623
  ///
626 624
  /// This is a simple and fast graph implementation.
627 625
  /// It is also quite memory efficient, but at the price
628 626
  /// that <b> it does support only limited (only stack-like)
629 627
  /// node and arc deletions</b>.
630 628
  /// It fully conforms to the \ref concepts::Graph "Graph concept".
631 629
  ///
632 630
  /// \sa concepts::Graph.
633 631
  class SmartGraph : public ExtendedSmartGraphBase {
632
    typedef ExtendedSmartGraphBase Parent;
633

	
634 634
  private:
635 635

	
636 636
    ///SmartGraph is \e not copy constructible. Use GraphCopy() instead.
637 637

	
638 638
    ///SmartGraph is \e not copy constructible. Use GraphCopy() instead.
639 639
    ///
640 640
    SmartGraph(const SmartGraph &) : ExtendedSmartGraphBase() {};
641 641

	
642 642
    ///\brief Assignment of SmartGraph to another one is \e not allowed.
643 643
    ///Use GraphCopy() instead.
644 644

	
645 645
    ///Assignment of SmartGraph to another one is \e not allowed.
646 646
    ///Use GraphCopy() instead.
647 647
    void operator=(const SmartGraph &) {}
648 648

	
649 649
  public:
650 650

	
651
    typedef ExtendedSmartGraphBase Parent;
652

	
653 651
    /// Constructor
654 652

	
655 653
    /// Constructor.
656 654
    ///
657 655
    SmartGraph() {}
658 656

	
659 657
    ///Add a new node to the graph.
660 658

	
661 659
    /// Add a new node to the graph.
662 660
    /// \return The new node.
663 661
    Node addNode() { return Parent::addNode(); }
664 662

	
665 663
    ///Add a new edge to the graph.
666 664

	
667 665
    ///Add a new edge to the graph with node \c s
668 666
    ///and \c t.
669 667
    ///\return The new edge.
670 668
    Edge addEdge(const Node& s, const Node& t) {
671 669
      return Parent::addEdge(s, t);
672 670
    }
673 671

	
674 672
    /// \brief Node validity check
675 673
    ///
676 674
    /// This function gives back true if the given node is valid,
677 675
    /// ie. it is a real node of the graph.
678 676
    ///
679 677
    /// \warning A removed node (using Snapshot) could become valid again
680 678
    /// when new nodes are added to the graph.
681 679
    bool valid(Node n) const { return Parent::valid(n); }
682 680

	
683 681
    /// \brief Arc validity check
684 682
    ///
0 comments (0 inline)