Changeset 1025:c8fa41fcc4a7 in lemon-main for lemon/full_graph.h
- Timestamp:
- 12/01/11 09:05:47 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/full_graph.h
r1024 r1025 652 652 }; 653 653 654 class RedNode : public Node { 655 friend class FullBpGraphBase; 656 protected: 657 658 explicit RedNode(int pid) : Node(pid) {} 659 660 public: 661 RedNode() {} 662 RedNode(const RedNode& node) : Node(node) {} 663 RedNode(Invalid) : Node(INVALID){} 664 }; 665 666 class BlueNode : public Node { 667 friend class FullBpGraphBase; 668 protected: 669 670 explicit BlueNode(int pid) : Node(pid) {} 671 672 public: 673 BlueNode() {} 674 BlueNode(const BlueNode& node) : Node(node) {} 675 BlueNode(Invalid) : Node(INVALID){} 676 }; 677 654 678 class Edge { 655 679 friend class FullBpGraphBase; … … 718 742 bool blue(Node n) const { return n._id >= _red_num; } 719 743 744 static RedNode asRedNodeUnsafe(Node n) { return RedNode(n._id); } 745 static BlueNode asBlueNodeUnsafe(Node n) { return BlueNode(n._id); } 746 720 747 Node source(Arc a) const { 721 748 if (a._id & 1) { … … 733 760 } 734 761 735 Node redNode(Edge e) const {736 return Node(e._id % _red_num);737 } 738 Node blueNode(Edge e) const {739 return Node(e._id / _red_num + _red_num);762 RedNode redNode(Edge e) const { 763 return RedNode(e._id % _red_num); 764 } 765 BlueNode blueNode(Edge e) const { 766 return BlueNode(e._id / _red_num + _red_num); 740 767 } 741 768 … … 756 783 } 757 784 758 void first Red(Node& node) const {785 void first(RedNode& node) const { 759 786 node._id = _red_num - 1; 760 787 } 761 788 762 static void next Red(Node& node) {789 static void next(RedNode& node) { 763 790 --node._id; 764 791 } 765 792 766 void first Blue(Node& node) const {793 void first(BlueNode& node) const { 767 794 if (_red_num == _node_num) node._id = -1; 768 795 else node._id = _node_num - 1; 769 796 } 770 797 771 void next Blue(Node& node) const {798 void next(BlueNode& node) const { 772 799 if (node._id == _red_num) node._id = -1; 773 800 else --node._id; … … 843 870 } 844 871 845 static int id(Node v) { return v._id; } 846 int redId(Node v) const { 847 LEMON_DEBUG(v._id < _red_num, "Node has to be red"); 848 return v._id; 849 } 850 int blueId(Node v) const { 851 LEMON_DEBUG(v._id >= _red_num, "Node has to be blue"); 852 return v._id - _red_num; 853 } 872 static int id(const Node& v) { return v._id; } 873 int id(const RedNode& v) const { return v._id; } 874 int id(const BlueNode& v) const { return v._id - _red_num; } 854 875 static int id(Arc e) { return e._id; } 855 876 static int id(Edge e) { return e._id; } … … 869 890 } 870 891 871 Node redNode(int index) const {872 return Node(index);873 } 874 875 int redIndex(Node n) const {892 RedNode redNode(int index) const { 893 return RedNode(index); 894 } 895 896 int index(RedNode n) const { 876 897 return n._id; 877 898 } 878 899 879 Node blueNode(int index) const {880 return Node(index + _red_num);881 } 882 883 int blueIndex(Node n) const {900 BlueNode blueNode(int index) const { 901 return BlueNode(index + _red_num); 902 } 903 904 int index(BlueNode n) const { 884 905 return n._id - _red_num; 885 906 } … … 1001 1022 /// with integers from the range <tt>[0..redNum()-1]</tt>. 1002 1023 /// \sa redIndex() 1003 Node redNode(int index) const { return Parent::redNode(index); }1024 RedNode redNode(int index) const { return Parent::redNode(index); } 1004 1025 1005 1026 /// \brief Returns the index of the given red node. … … 1010 1031 /// 1011 1032 /// \sa operator()() 1012 int redIndex(Node node) const { return Parent::redIndex(node); }1033 int index(RedNode node) const { return Parent::index(node); } 1013 1034 1014 1035 /// \brief Returns the blue node with the given index. … … 1018 1039 /// with integers from the range <tt>[0..blueNum()-1]</tt>. 1019 1040 /// \sa blueIndex() 1020 Node blueNode(int index) const { return Parent::blueNode(index); }1041 BlueNode blueNode(int index) const { return Parent::blueNode(index); } 1021 1042 1022 1043 /// \brief Returns the index of the given blue node. … … 1027 1048 /// 1028 1049 /// \sa operator()() 1029 int blueIndex(Node node) const { return Parent::blueIndex(node); }1050 int index(BlueNode node) const { return Parent::index(node); } 1030 1051 1031 1052 /// \brief Returns the edge which connects the given nodes.
Note: See TracChangeset
for help on using the changeset viewer.