538 Edge() : out_or_in(), out(), in() { } |
538 Edge() : out_or_in(), out(), in() { } |
539 Edge(const Invalid& i) : out_or_in(false), out(), in(i) { } |
539 Edge(const Invalid& i) : out_or_in(false), out(), in(i) { } |
540 operator GraphEdge() const { |
540 operator GraphEdge() const { |
541 if (out_or_in) return(out); else return(in); |
541 if (out_or_in) return(out); else return(in); |
542 } |
542 } |
|
543 //FIXME |
|
544 //2 edges are equal if they "refer" to the same physical edge |
|
545 //is it good? |
543 friend bool operator==(const Edge& u, const Edge& v) { |
546 friend bool operator==(const Edge& u, const Edge& v) { |
544 if (v.out_or_in) |
547 if (v.out_or_in) |
545 return (u.out_or_in && u.out==v.out); |
548 if (u.out_or_in) return (u.out==v.out); else return (u.out==v.in); |
|
549 //return (u.out_or_in && u.out==v.out); |
546 else |
550 else |
547 return (!u.out_or_in && u.in==v.in); |
551 if (u.out_or_in) return (u.out==v.in); else return (u.in==v.in); |
|
552 //return (!u.out_or_in && u.in==v.in); |
548 } |
553 } |
549 friend bool operator!=(const Edge& u, const Edge& v) { |
554 friend bool operator!=(const Edge& u, const Edge& v) { |
550 if (v.out_or_in) |
555 if (v.out_or_in) |
551 return (!u.out_or_in || u.out!=v.out); |
556 if (u.out_or_in) return (u.out!=v.out); else return (u.out!=v.in); |
|
557 //return (!u.out_or_in || u.out!=v.out); |
552 else |
558 else |
553 return (u.out_or_in || u.in!=v.in); |
559 if (u.out_or_in) return (u.out!=v.in); else return (u.in!=v.in); |
|
560 //return (u.out_or_in || u.in!=v.in); |
554 } |
561 } |
555 }; |
562 }; |
556 |
563 |
557 class OutEdgeIt : public Edge { |
564 class OutEdgeIt : public Edge { |
558 friend class UndirGraphWrapper<GraphWrapper>; |
565 friend class UndirGraphWrapper<GraphWrapper>; |
559 public: |
566 public: |
560 OutEdgeIt() : Edge() { } |
567 OutEdgeIt() : Edge() { } |
561 OutEdgeIt(const Invalid& i) : Edge(i) { } |
568 OutEdgeIt(const Invalid& i) : Edge(i) { } |
562 OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n) |
569 OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n) |
563 : Edge() { |
570 : Edge() { |
564 out_or_in=true; |
571 out_or_in=true; _G.gw.first(out, n); |
565 _G.gw.first(out, n); |
572 if (!(_G.gw.valid(out))) { out_or_in=false; _G.gw.first(in, n); } |
566 if (!(_G.gw.valid(out))) { |
|
567 out_or_in=false; |
|
568 _G.gw.first(in, n); |
|
569 } |
|
570 } |
573 } |
571 }; |
574 }; |
572 |
575 |
573 typedef OutEdgeIt InEdgeIt; |
576 typedef OutEdgeIt InEdgeIt; |
574 |
577 |
641 } |
637 } |
642 return e; |
638 return e; |
643 } |
639 } |
644 |
640 |
645 template<typename I> I& next(I &i) const { return gw.next(i); } |
641 template<typename I> I& next(I &i) const { return gw.next(i); } |
646 |
642 template<typename I> I getNext(const I& i) const { return gw.getNext(i); } |
647 template<typename I> I getNext(const I& i) const { |
|
648 return gw.getNext(i); } |
|
649 |
643 |
650 template< typename It > It first() const { |
644 template< typename It > It first() const { |
651 It e; first(e); return e; } |
645 It e; first(e); return e; } |
652 |
646 |
653 template< typename It > It first(const Node& v) const { |
647 template< typename It > It first(const Node& v) const { |