gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Fix bug #83 in graph concept, extender and smart graph
0 4 0
default
4 files changed with 17 insertions and 17 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -358,39 +358,39 @@
358 358
      return Parent::nodeFromId(id);
359 359
    }
360 360

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

	
365 365
    Edge fromId(int id, Edge) const {
366 366
      return Parent::edgeFromId(id);
367 367
    }
368 368

	
369 369
    Node oppositeNode(const Node &n, const Edge &e) const {
370
      if( n == Parent::source(e))
371
	return Parent::target(e);
372
      else if( n == Parent::target(e))
373
	return Parent::source(e);
370
      if( n == Parent::u(e))
371
	return Parent::v(e);
372
      else if( n == Parent::v(e))
373
	return Parent::u(e);
374 374
      else
375 375
	return INVALID;
376 376
    }
377 377

	
378 378
    Arc oppositeArc(const Arc &arc) const {
379 379
      return Parent::direct(arc, !Parent::direction(arc));
380 380
    }
381 381

	
382 382
    using Parent::direct;
383 383
    Arc direct(const Edge &edge, const Node &node) const {
384
      return Parent::direct(edge, Parent::source(edge) == node);
384
      return Parent::direct(edge, Parent::u(edge) == node);
385 385
    }
386 386

	
387 387
    // Alterable extension
388 388

	
389 389
    typedef AlterationNotifier<GraphExtender, Node> NodeNotifier;
390 390
    typedef AlterationNotifier<GraphExtender, Arc> ArcNotifier;
391 391
    typedef AlterationNotifier<GraphExtender, Edge> EdgeNotifier;
392 392

	
393 393

	
394 394
  protected:
395 395

	
396 396
    mutable NodeNotifier node_notifier;
... ...
@@ -577,31 +577,31 @@
577 577
    /// \brief Running node of the iterator
578 578
    ///
579 579
    /// Returns the running node (ie. the source in this case) of the
580 580
    /// iterator
581 581
    Node runningNode(const InArcIt &arc) const {
582 582
      return Parent::source(static_cast<const Arc&>(arc));
583 583
    }
584 584

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

	
598 598
    // Mappable extension
599 599

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

	
607 607
      NodeMap(const Graph& graph) 
Ignore white space 6 line context
... ...
@@ -458,29 +458,29 @@
458 458
        ///\e
459 459
        ArcMap(const Digraph&, T) { }
460 460
        ///Copy constructor
461 461
        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
462 462
        ///Assignment operator
463 463
        template <typename CMap>
464 464
        ArcMap& operator=(const CMap&) { 
465 465
          checkConcept<ReadMap<Arc, T>, CMap>();
466 466
          return *this; 
467 467
        }
468 468
      };
469 469

	
470
      template <typename RDigraph>
470
      template <typename _Digraph>
471 471
      struct Constraints {
472 472
        void constraints() {
473
          checkConcept<IterableDigraphComponent<>, Digraph>();
474
	  checkConcept<IDableDigraphComponent<>, Digraph>();
475
          checkConcept<MappableDigraphComponent<>, Digraph>();
473
          checkConcept<IterableDigraphComponent<>, _Digraph>();
474
	  checkConcept<IDableDigraphComponent<>, _Digraph>();
475
          checkConcept<MappableDigraphComponent<>, _Digraph>();
476 476
        }
477 477
      };
478 478

	
479 479
    };
480 480
    
481 481
  } //namespace concepts  
482 482
} //namespace lemon
483 483

	
484 484

	
485 485

	
486 486
#endif // LEMON_CONCEPT_DIGRAPH_H
Ignore white space 24 line context
... ...
@@ -722,28 +722,28 @@
722 722
      /// Returns the base node of the iterator
723 723
      Node baseNode(IncEdgeIt) const {
724 724
	return INVALID;
725 725
      }
726 726
      
727 727
      /// \brief Running node of the iterator
728 728
      ///
729 729
      /// Returns the running node of the iterator
730 730
      Node runningNode(IncEdgeIt) const {
731 731
	return INVALID;
732 732
      }
733 733

	
734
      template <typename Graph>
734
      template <typename _Graph>
735 735
      struct Constraints {
736 736
	void constraints() {
737
	  checkConcept<IterableGraphComponent<>, Graph>();
738
	  checkConcept<IDableGraphComponent<>, Graph>();
739
	  checkConcept<MappableGraphComponent<>, Graph>();
737
	  checkConcept<IterableGraphComponent<>, _Graph>();
738
	  checkConcept<IDableGraphComponent<>, _Graph>();
739
	  checkConcept<MappableGraphComponent<>, _Graph>();
740 740
	}
741 741
      };
742 742

	
743 743
    };
744 744

	
745 745
  }
746 746

	
747 747
}
748 748

	
749 749
#endif
Ignore white space 6 line context
... ...
@@ -461,26 +461,26 @@
461 461

	
462 462
    SmartGraphBase()
463 463
      : nodes(), arcs() {}
464 464

	
465 465
    
466 466
    int maxNodeId() const { return nodes.size()-1; } 
467 467
    int maxEdgeId() const { return arcs.size() / 2 - 1; }
468 468
    int maxArcId() const { return arcs.size()-1; }
469 469

	
470 470
    Node source(Arc e) const { return Node(arcs[e._id ^ 1].target); }
471 471
    Node target(Arc e) const { return Node(arcs[e._id].target); }
472 472

	
473
    Node source(Edge e) const { return Node(arcs[2 * e._id].target); }
474
    Node target(Edge e) const { return Node(arcs[2 * e._id + 1].target); }
473
    Node u(Edge e) const { return Node(arcs[2 * e._id].target); }
474
    Node v(Edge e) const { return Node(arcs[2 * e._id + 1].target); }
475 475

	
476 476
    static bool direction(Arc e) {
477 477
      return (e._id & 1) == 1;
478 478
    }
479 479

	
480 480
    static Arc direct(Edge e, bool d) {
481 481
      return Arc(e._id * 2 + (d ? 1 : 0));
482 482
    }
483 483

	
484 484
    void first(Node& node) const { 
485 485
      node._id = nodes.size() - 1;
486 486
    }
0 comments (0 inline)