Changeset 2076:10681ee9d8ae in lemon0.x for lemon/list_graph.h
 Timestamp:
 05/12/06 11:51:45 (14 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2739
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/list_graph.h
r2031 r2076 567 567 /**************** Undirected List Graph ****************/ 568 568 569 typedef UGraphExtender<U GraphBaseExtender<570 ListGraphBase> >ExtendedListUGraphBase;569 typedef UGraphExtender<UndirGraphExtender<ListGraphBase> > 570 ExtendedListUGraphBase; 571 571 572 572 /// \addtogroup graphs … … 652 652 }; 653 653 654 struct EdgeT {654 struct UEdgeT { 655 655 int aNode, prev_out, next_out; 656 656 int bNode, prev_in, next_in; … … 660 660 std::vector<NodeT> bNodes; 661 661 662 std::vector< EdgeT> edges;662 std::vector<UEdgeT> edges; 663 663 664 664 int first_anode; … … 686 686 }; 687 687 688 class Edge {688 class UEdge { 689 689 friend class ListBpUGraphBase; 690 690 protected: 691 691 int id; 692 692 693 explicit Edge(int _id) { id = _id;}693 explicit UEdge(int _id) { id = _id;} 694 694 public: 695 Edge() {}696 Edge (Invalid) { id = 1; }697 bool operator==(const Edge i) const {return id==i.id;}698 bool operator!=(const Edge i) const {return id!=i.id;}699 bool operator<(const Edge i) const {return id<i.id;}695 UEdge() {} 696 UEdge (Invalid) { id = 1; } 697 bool operator==(const UEdge i) const {return id==i.id;} 698 bool operator!=(const UEdge i) const {return id!=i.id;} 699 bool operator<(const UEdge i) const {return id<i.id;} 700 700 }; 701 701 … … 741 741 } 742 742 743 void first( Edge& edge) const {743 void first(UEdge& edge) const { 744 744 int aNodeId = first_anode; 745 745 while (aNodeId != 1 && aNodes[aNodeId].first_edge == 1) { … … 753 753 } 754 754 } 755 void next( Edge& edge) const {755 void next(UEdge& edge) const { 756 756 int aNodeId = edges[edge.id].aNode >> 1; 757 757 edge.id = edges[edge.id].next_out; … … 771 771 } 772 772 773 void first Out(Edge& edge, const Node& node) const {773 void firstFromANode(UEdge& edge, const Node& node) const { 774 774 LEMON_ASSERT((node.id & 1) == 0, NodeSetError()); 775 775 edge.id = aNodes[node.id >> 1].first_edge; 776 776 } 777 void next Out(Edge& edge) const {777 void nextFromANode(UEdge& edge) const { 778 778 edge.id = edges[edge.id].next_out; 779 779 } 780 780 781 void first In(Edge& edge, const Node& node) const {781 void firstFromBNode(UEdge& edge, const Node& node) const { 782 782 LEMON_ASSERT((node.id & 1) == 1, NodeSetError()); 783 783 edge.id = bNodes[node.id >> 1].first_edge; 784 784 } 785 void next In(Edge& edge) const {785 void nextFromBNode(UEdge& edge) const { 786 786 edge.id = edges[edge.id].next_in; 787 787 } … … 798 798 } 799 799 800 static int id(const Edge& edge) {800 static int id(const UEdge& edge) { 801 801 return edge.id; 802 802 } 803 static Edge edgeFromId(int id) {804 return Edge(id);805 } 806 int max EdgeId() const {803 static UEdge uEdgeFromId(int id) { 804 return UEdge(id); 805 } 806 int maxUEdgeId() const { 807 807 return edges.size(); 808 808 } … … 828 828 } 829 829 830 Node aNode(const Edge& edge) const {830 Node aNode(const UEdge& edge) const { 831 831 return Node(edges[edge.id].aNode); 832 832 } 833 Node bNode(const Edge& edge) const {833 Node bNode(const UEdge& edge) const { 834 834 return Node(edges[edge.id].bNode); 835 835 } … … 875 875 } 876 876 877 Edge addEdge(const Node& source, const Node& target) {877 UEdge addEdge(const Node& source, const Node& target) { 878 878 LEMON_ASSERT(((source.id ^ target.id) & 1) == 1, NodeSetError()); 879 879 int edgeId; … … 883 883 } else { 884 884 edgeId = edges.size(); 885 edges.push_back( EdgeT());885 edges.push_back(UEdgeT()); 886 886 } 887 887 if ((source.id & 1) == 0) { … … 904 904 } 905 905 bNodes[edges[edgeId].bNode >> 1].first_edge = edgeId; 906 return Edge(edgeId);906 return UEdge(edgeId); 907 907 } 908 908 … … 919 919 } 920 920 921 void erase(const Edge& edge) {921 void erase(const UEdge& edge) { 922 922 if (edges[edge.id].prev_out != 1) { 923 923 edges[edges[edge.id].prev_out].next_out = edges[edge.id].next_out; … … 954 954 955 955 956 typedef BpUGraphExtender< BpUGraphBaseExtender< 957 ListBpUGraphBase> > ExtendedListBpUGraphBase; 956 typedef BpUGraphExtender< ListBpUGraphBase > ExtendedListBpUGraphBase; 958 957 959 958 /// \ingroup graphs
Note: See TracChangeset
for help on using the changeset viewer.