Changeset 1193:c8fa41fcc4a7 in lemon for lemon/list_graph.h
- Timestamp:
- 12/01/11 09:05:47 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/list_graph.h
r1189 r1193 1648 1648 }; 1649 1649 1650 class RedNode : public Node { 1651 friend class ListBpGraphBase; 1652 protected: 1653 1654 explicit RedNode(int pid) : Node(pid) {} 1655 1656 public: 1657 RedNode() {} 1658 RedNode(const RedNode& node) : Node(node) {} 1659 RedNode(Invalid) : Node(INVALID){} 1660 }; 1661 1662 class BlueNode : public Node { 1663 friend class ListBpGraphBase; 1664 protected: 1665 1666 explicit BlueNode(int pid) : Node(pid) {} 1667 1668 public: 1669 BlueNode() {} 1670 BlueNode(const BlueNode& node) : Node(node) {} 1671 BlueNode(Invalid) : Node(INVALID){} 1672 }; 1673 1650 1674 class Edge { 1651 1675 friend class ListBpGraphBase; … … 1693 1717 bool blue(Node n) const { return !nodes[n.id].red; } 1694 1718 1719 static RedNode asRedNodeUnsafe(Node n) { return RedNode(n.id); } 1720 static BlueNode asBlueNodeUnsafe(Node n) { return BlueNode(n.id); } 1721 1695 1722 int maxNodeId() const { return nodes.size()-1; } 1696 1723 int maxRedId() const { return max_red; } … … 1702 1729 Node target(Arc e) const { return Node(arcs[e.id].target); } 1703 1730 1704 Node redNode(Edge e) const { return Node(arcs[2 * e.id].target); } 1705 Node blueNode(Edge e) const { return Node(arcs[2 * e.id + 1].target); } 1731 RedNode redNode(Edge e) const { 1732 return RedNode(arcs[2 * e.id].target); 1733 } 1734 BlueNode blueNode(Edge e) const { 1735 return BlueNode(arcs[2 * e.id + 1].target); 1736 } 1706 1737 1707 1738 static bool direction(Arc e) { … … 1721 1752 } 1722 1753 1723 void first Red(Node& node) const {1754 void first(RedNode& node) const { 1724 1755 node.id = first_red; 1725 1756 } 1726 1757 1727 void next Red(Node& node) const {1758 void next(RedNode& node) const { 1728 1759 node.id = nodes[node.id].partition_next; 1729 1760 } 1730 1761 1731 void first Blue(Node& node) const {1762 void first(BlueNode& node) const { 1732 1763 node.id = first_blue; 1733 1764 } 1734 1765 1735 void next Blue(Node& node) const {1766 void next(BlueNode& node) const { 1736 1767 node.id = nodes[node.id].partition_next; 1737 1768 } … … 1836 1867 1837 1868 static int id(Node v) { return v.id; } 1838 int redId(Node v) const { 1839 LEMON_DEBUG(nodes[v.id].red, "Node has to be red"); 1840 return nodes[v.id].partition_index; 1841 } 1842 int blueId(Node v) const { 1843 LEMON_DEBUG(!nodes[v.id].red, "Node has to be blue"); 1844 return nodes[v.id].partition_index; 1845 } 1869 int id(RedNode v) const { return nodes[v.id].partition_index; } 1870 int id(BlueNode v) const { return nodes[v.id].partition_index; } 1846 1871 static int id(Arc e) { return e.id; } 1847 1872 static int id(Edge e) { return e.id; } … … 1866 1891 } 1867 1892 1868 Node addRedNode() {1893 RedNode addRedNode() { 1869 1894 int n; 1870 1895 … … 1891 1916 nodes[n].first_out = -1; 1892 1917 1893 return Node(n);1894 } 1895 1896 Node addBlueNode() {1918 return RedNode(n); 1919 } 1920 1921 BlueNode addBlueNode() { 1897 1922 int n; 1898 1923 … … 1919 1944 nodes[n].first_out = -1; 1920 1945 1921 return Node(n);1946 return BlueNode(n); 1922 1947 } 1923 1948 … … 2030 2055 protected: 2031 2056 2032 void changeRed(Edge e, Node n) { 2033 LEMON_DEBUG(nodes[n].red, "Node has to be red"); 2057 void changeRed(Edge e, RedNode n) { 2034 2058 if(arcs[(2 * e.id) | 1].next_out != -1) { 2035 2059 arcs[arcs[(2 * e.id) | 1].next_out].prev_out = … … 2053 2077 } 2054 2078 2055 void changeBlue(Edge e, Node n) { 2056 LEMON_DEBUG(nodes[n].red, "Node has to be blue"); 2057 if(arcs[2 * e.id].next_out != -1) { 2079 void changeBlue(Edge e, BlueNode n) { 2080 if(arcs[2 * e.id].next_out != -1) { 2058 2081 arcs[arcs[2 * e.id].next_out].prev_out = arcs[2 * e.id].prev_out; 2059 2082 } … … 2120 2143 /// This function adds a red new node to the graph. 2121 2144 /// \return The new node. 2122 Node addRedNode() { return Parent::addRedNode(); }2145 RedNode addRedNode() { return Parent::addRedNode(); } 2123 2146 2124 2147 /// \brief Add a new blue node to the graph. … … 2126 2149 /// This function adds a blue new node to the graph. 2127 2150 /// \return The new node. 2128 Node addBlueNode() { return Parent::addBlueNode(); }2151 BlueNode addBlueNode() { return Parent::addBlueNode(); } 2129 2152 2130 2153 /// \brief Add a new edge to the graph. … … 2134 2157 /// node \c v. 2135 2158 /// \return The new edge. 2136 Edge addEdge(Node u, Node v) { 2159 Edge addEdge(RedNode u, BlueNode v) { 2160 return Parent::addEdge(u, v); 2161 } 2162 Edge addEdge(BlueNode v, RedNode u) { 2137 2163 return Parent::addEdge(u, v); 2138 2164 } … … 2189 2215 ///\warning This functionality cannot be used together with the 2190 2216 ///Snapshot feature. 2191 void changeRed(Edge e, Node n) {2192 Parent::changeRed(e, n);2217 void changeRed(Edge e, RedNode n) { 2218 Parent::changeRed(e, n); 2193 2219 } 2194 2220 /// \brief Change the blue node of an edge. … … 2203 2229 ///\warning This functionality cannot be used together with the 2204 2230 ///Snapshot feature. 2205 void changeBlue(Edge e, Node n) {2206 Parent::changeBlue(e, n);2231 void changeBlue(Edge e, BlueNode n) { 2232 Parent::changeBlue(e, n); 2207 2233 } 2208 2234
Note: See TracChangeset
for help on using the changeset viewer.