1.1 --- a/lemon/full_graph.h Thu Nov 25 22:45:29 2010 +0100
1.2 +++ b/lemon/full_graph.h Thu Dec 01 09:05:47 2011 +0100
1.3 @@ -651,6 +651,30 @@
1.4 bool operator<(const Node& node) const {return _id < node._id;}
1.5 };
1.6
1.7 + class RedNode : public Node {
1.8 + friend class FullBpGraphBase;
1.9 + protected:
1.10 +
1.11 + explicit RedNode(int pid) : Node(pid) {}
1.12 +
1.13 + public:
1.14 + RedNode() {}
1.15 + RedNode(const RedNode& node) : Node(node) {}
1.16 + RedNode(Invalid) : Node(INVALID){}
1.17 + };
1.18 +
1.19 + class BlueNode : public Node {
1.20 + friend class FullBpGraphBase;
1.21 + protected:
1.22 +
1.23 + explicit BlueNode(int pid) : Node(pid) {}
1.24 +
1.25 + public:
1.26 + BlueNode() {}
1.27 + BlueNode(const BlueNode& node) : Node(node) {}
1.28 + BlueNode(Invalid) : Node(INVALID){}
1.29 + };
1.30 +
1.31 class Edge {
1.32 friend class FullBpGraphBase;
1.33 protected:
1.34 @@ -717,6 +741,9 @@
1.35 bool red(Node n) const { return n._id < _red_num; }
1.36 bool blue(Node n) const { return n._id >= _red_num; }
1.37
1.38 + static RedNode asRedNodeUnsafe(Node n) { return RedNode(n._id); }
1.39 + static BlueNode asBlueNodeUnsafe(Node n) { return BlueNode(n._id); }
1.40 +
1.41 Node source(Arc a) const {
1.42 if (a._id & 1) {
1.43 return Node((a._id >> 1) % _red_num);
1.44 @@ -732,11 +759,11 @@
1.45 }
1.46 }
1.47
1.48 - Node redNode(Edge e) const {
1.49 - return Node(e._id % _red_num);
1.50 + RedNode redNode(Edge e) const {
1.51 + return RedNode(e._id % _red_num);
1.52 }
1.53 - Node blueNode(Edge e) const {
1.54 - return Node(e._id / _red_num + _red_num);
1.55 + BlueNode blueNode(Edge e) const {
1.56 + return BlueNode(e._id / _red_num + _red_num);
1.57 }
1.58
1.59 static bool direction(Arc a) {
1.60 @@ -755,20 +782,20 @@
1.61 --node._id;
1.62 }
1.63
1.64 - void firstRed(Node& node) const {
1.65 + void first(RedNode& node) const {
1.66 node._id = _red_num - 1;
1.67 }
1.68
1.69 - static void nextRed(Node& node) {
1.70 + static void next(RedNode& node) {
1.71 --node._id;
1.72 }
1.73
1.74 - void firstBlue(Node& node) const {
1.75 + void first(BlueNode& node) const {
1.76 if (_red_num == _node_num) node._id = -1;
1.77 else node._id = _node_num - 1;
1.78 }
1.79
1.80 - void nextBlue(Node& node) const {
1.81 + void next(BlueNode& node) const {
1.82 if (node._id == _red_num) node._id = -1;
1.83 else --node._id;
1.84 }
1.85 @@ -842,15 +869,9 @@
1.86 }
1.87 }
1.88
1.89 - static int id(Node v) { return v._id; }
1.90 - int redId(Node v) const {
1.91 - LEMON_DEBUG(v._id < _red_num, "Node has to be red");
1.92 - return v._id;
1.93 - }
1.94 - int blueId(Node v) const {
1.95 - LEMON_DEBUG(v._id >= _red_num, "Node has to be blue");
1.96 - return v._id - _red_num;
1.97 - }
1.98 + static int id(const Node& v) { return v._id; }
1.99 + int id(const RedNode& v) const { return v._id; }
1.100 + int id(const BlueNode& v) const { return v._id - _red_num; }
1.101 static int id(Arc e) { return e._id; }
1.102 static int id(Edge e) { return e._id; }
1.103
1.104 @@ -868,19 +889,19 @@
1.105 return e._id >= 0 && e._id < _edge_num;
1.106 }
1.107
1.108 - Node redNode(int index) const {
1.109 - return Node(index);
1.110 + RedNode redNode(int index) const {
1.111 + return RedNode(index);
1.112 }
1.113
1.114 - int redIndex(Node n) const {
1.115 + int index(RedNode n) const {
1.116 return n._id;
1.117 }
1.118
1.119 - Node blueNode(int index) const {
1.120 - return Node(index + _red_num);
1.121 + BlueNode blueNode(int index) const {
1.122 + return BlueNode(index + _red_num);
1.123 }
1.124
1.125 - int blueIndex(Node n) const {
1.126 + int index(BlueNode n) const {
1.127 return n._id - _red_num;
1.128 }
1.129
1.130 @@ -1000,7 +1021,7 @@
1.131 /// structure is completely static, the red nodes can be indexed
1.132 /// with integers from the range <tt>[0..redNum()-1]</tt>.
1.133 /// \sa redIndex()
1.134 - Node redNode(int index) const { return Parent::redNode(index); }
1.135 + RedNode redNode(int index) const { return Parent::redNode(index); }
1.136
1.137 /// \brief Returns the index of the given red node.
1.138 ///
1.139 @@ -1009,7 +1030,7 @@
1.140 /// integers from the range <tt>[0..redNum()-1]</tt>.
1.141 ///
1.142 /// \sa operator()()
1.143 - int redIndex(Node node) const { return Parent::redIndex(node); }
1.144 + int index(RedNode node) const { return Parent::index(node); }
1.145
1.146 /// \brief Returns the blue node with the given index.
1.147 ///
1.148 @@ -1017,7 +1038,7 @@
1.149 /// structure is completely static, the blue nodes can be indexed
1.150 /// with integers from the range <tt>[0..blueNum()-1]</tt>.
1.151 /// \sa blueIndex()
1.152 - Node blueNode(int index) const { return Parent::blueNode(index); }
1.153 + BlueNode blueNode(int index) const { return Parent::blueNode(index); }
1.154
1.155 /// \brief Returns the index of the given blue node.
1.156 ///
1.157 @@ -1026,7 +1047,7 @@
1.158 /// integers from the range <tt>[0..blueNum()-1]</tt>.
1.159 ///
1.160 /// \sa operator()()
1.161 - int blueIndex(Node node) const { return Parent::blueIndex(node); }
1.162 + int index(BlueNode node) const { return Parent::index(node); }
1.163
1.164 /// \brief Returns the edge which connects the given nodes.
1.165 ///