Changeset 565:18787f6db0db in lemon0.x for src/hugo
 Timestamp:
 05/07/04 08:33:02 (20 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@740
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/hugo/graph_wrapper.h
r561 r565 598 598 friend class ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>; 599 599 protected: 600 bool forward; //true, iff forward600 bool backward; //true, iff backward 601 601 // typename Graph::Edge e; 602 602 public: 603 603 Edge() { } 604 Edge(const typename Graph::Edge& _e, bool _ forward) :605 Graph::Edge(_e), forward(_forward) { }606 Edge(const Invalid& i) : Graph::Edge(i), forward(false) { }604 Edge(const typename Graph::Edge& _e, bool _backward) : 605 Graph::Edge(_e), backward(_backward) { } 606 Edge(const Invalid& i) : Graph::Edge(i), backward(true) { } 607 607 //the unique invalid iterator 608 608 friend bool operator==(const Edge& u, const Edge& v) { 609 return (v. forward==u.forward &&609 return (v.backward==u.backward && 610 610 static_cast<typename Graph::Edge>(u)== 611 611 static_cast<typename Graph::Edge>(v)); 612 612 } 613 613 friend bool operator!=(const Edge& u, const Edge& v) { 614 return (v. forward!=u.forward 614 return (v.backward!=u.backward  615 615 static_cast<typename Graph::Edge>(u)!= 616 616 static_cast<typename Graph::Edge>(v)); … … 623 623 typename Graph::OutEdgeIt out; 624 624 typename Graph::InEdgeIt in; 625 bool forward;625 bool backward; 626 626 public: 627 627 OutEdgeIt() { } 628 628 //FIXME 629 629 // OutEdgeIt(const Edge& e) : Edge(e) { } 630 OutEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { }630 OutEdgeIt(const Invalid& i) : out(i), in(i), backward(true) { } 631 631 //the unique invalid iterator 632 632 OutEdgeIt(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& resG, Node v) { 633 forward=true;633 backward=false; 634 634 resG.graph>first(out, v); 635 635 while( resG.graph>valid(out) && !(resG.resCap(*this)>0) ) { resG.graph>next(out); } 636 636 if (!resG.graph>valid(out)) { 637 forward=false;637 backward=true; 638 638 resG.graph>first(in, v); 639 639 while( resG.graph>valid(in) && !(resG.resCap(*this)>0) ) { resG.graph>next(in); } … … 645 645 // if (this>forward) e=out; else e=in; 646 646 // return e; 647 if (this> forward)648 return Edge( out, this>forward);647 if (this>backward) 648 return Edge(in, this>backward); 649 649 else 650 return Edge( in, this>forward);650 return Edge(out, this>backward); 651 651 } 652 652 }; … … 657 657 typename Graph::OutEdgeIt out; 658 658 typename Graph::InEdgeIt in; 659 bool forward;659 bool backward; 660 660 public: 661 661 InEdgeIt() { } 662 662 //FIXME 663 663 // OutEdgeIt(const Edge& e) : Edge(e) { } 664 InEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { }664 InEdgeIt(const Invalid& i) : out(i), in(i), backward(true) { } 665 665 //the unique invalid iterator 666 666 InEdgeIt(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& resG, Node v) { 667 forward=true;667 backward=false; 668 668 resG.graph>first(in, v); 669 669 while( resG.graph>valid(in) && !(resG.resCap(*this)>0) ) { resG.graph>next(in); } 670 670 if (!resG.graph>valid(in)) { 671 forward=false;671 backward=true; 672 672 resG.graph>first(out, v); 673 673 while( resG.graph>valid(out) && !(resG.resCap(*this)>0) ) { resG.graph>next(out); } … … 679 679 // if (this>forward) e=out; else e=in; 680 680 // return e; 681 if (this> forward)682 return Edge( in, this>forward);681 if (this>backward) 682 return Edge(out, this>backward); 683 683 else 684 return Edge( out, this>forward);684 return Edge(in, this>backward); 685 685 } 686 686 }; … … 690 690 protected: 691 691 typename Graph::EdgeIt e; 692 bool forward;692 bool backward; 693 693 public: 694 694 EdgeIt() { } 695 EdgeIt(const Invalid& i) : e(i), forward(false) { }695 EdgeIt(const Invalid& i) : e(i), backward(true) { } 696 696 EdgeIt(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& resG) { 697 forward=true;697 backward=false; 698 698 resG.graph>first(e); 699 699 while (resG.graph>valid(e) && !(resG.resCap(*this)>0)) resG.graph>next(e); 700 700 if (!resG.graph>valid(e)) { 701 forward=false;701 backward=true; 702 702 resG.graph>first(e); 703 703 while (resG.graph>valid(e) && !(resG.resCap(*this)>0)) resG.graph>next(e); … … 705 705 } 706 706 operator Edge() const { 707 return Edge(e, this> forward);707 return Edge(e, this>backward); 708 708 } 709 709 }; … … 727 727 // NodeIt& next(NodeIt& n) const { GraphWrapper<Graph>::next(n); return n; } 728 728 OutEdgeIt& next(OutEdgeIt& e) const { 729 if ( e.forward) {729 if (!e.backward) { 730 730 Node v=this>graph>aNode(e.out); 731 731 this>graph>next(e.out); … … 733 733 this>graph>next(e.out); } 734 734 if (!this>graph>valid(e.out)) { 735 e. forward=false;735 e.backward=true; 736 736 this>graph>first(e.in, v); 737 737 while( this>graph>valid(e.in) && !(resCap(e)>0) ) { … … 747 747 // FIXME Not tested 748 748 InEdgeIt& next(InEdgeIt& e) const { 749 if ( e.forward) {749 if (!e.backward) { 750 750 Node v=this>graph>aNode(e.in); 751 751 this>graph>next(e.in); … … 753 753 this>graph>next(e.in); } 754 754 if (!this>graph>valid(e.in)) { 755 e. forward=false;755 e.backward=true; 756 756 this>graph>first(e.out, v); 757 757 while( this>graph>valid(e.out) && !(resCap(e)>0) ) { … … 766 766 } 767 767 EdgeIt& next(EdgeIt& e) const { 768 if ( e.forward) {768 if (!e.backward) { 769 769 this>graph>next(e.e); 770 770 while( this>graph>valid(e.e) && !(resCap(e)>0) ) { 771 771 this>graph>next(e.e); } 772 772 if (!this>graph>valid(e.e)) { 773 e. forward=false;773 e.backward=true; 774 774 this>graph>first(e.e); 775 775 while( this>graph>valid(e.e) && !(resCap(e)>0) ) { … … 785 785 786 786 Node tail(Edge e) const { 787 return (( e.forward) ? this>graph>tail(e) : this>graph>head(e)); }787 return ((!e.backward) ? this>graph>tail(e) : this>graph>head(e)); } 788 788 Node head(Edge e) const { 789 return (( e.forward) ? this>graph>head(e) : this>graph>tail(e)); }789 return ((!e.backward) ? this>graph>head(e) : this>graph>tail(e)); } 790 790 791 791 Node aNode(OutEdgeIt e) const { 792 return (( e.forward) ? this>graph>aNode(e.out) :792 return ((!e.backward) ? this>graph>aNode(e.out) : 793 793 this>graph>aNode(e.in)); } 794 794 Node bNode(OutEdgeIt e) const { 795 return (( e.forward) ? this>graph>bNode(e.out) :795 return ((!e.backward) ? this>graph>bNode(e.out) : 796 796 this>graph>bNode(e.in)); } 797 797 798 798 Node aNode(InEdgeIt e) const { 799 return (( e.forward) ? this>graph>aNode(e.in) :799 return ((!e.backward) ? this>graph>aNode(e.in) : 800 800 this>graph>aNode(e.out)); } 801 801 Node bNode(InEdgeIt e) const { 802 return (( e.forward) ? this>graph>bNode(e.in) :802 return ((!e.backward) ? this>graph>bNode(e.in) : 803 803 this>graph>bNode(e.out)); } 804 804 … … 817 817 } 818 818 819 bool forward(const Edge& e) const { return e.forward; }820 bool backward(const Edge& e) const { return !e.forward; }819 bool forward(const Edge& e) const { return !e.backward; } 820 bool backward(const Edge& e) const { return e.backward; } 821 821 822 822 void augment(const Edge& e, Number a) const { 823 if ( e.forward)823 if (!e.backward) 824 824 // flow>set(e.out, flow>get(e.out)+a); 825 825 flow>set(e, (*flow)[e]+a); … … 830 830 831 831 Number resCap(const Edge& e) const { 832 if ( e.forward)832 if (!e.backward) 833 833 // return (capacity>get(e.out)flow>get(e.out)); 834 834 return ((*capacity)[e](*flow)[e]); … … 855 855 EdgeMap(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& _G, T a) : forward_map(*(_G.graph), a), backward_map(*(_G.graph), a) { } 856 856 void set(Edge e, T a) { 857 if ( e.forward)857 if (!e.backward) 858 858 forward_map.set(e.out, a); 859 859 else … … 861 861 } 862 862 T operator[](Edge e) const { 863 if ( e.forward)863 if (!e.backward) 864 864 return forward_map[e.out]; 865 865 else
Note: See TracChangeset
for help on using the changeset viewer.