Changeset 1025:c8fa41fcc4a7 in lemon-main for lemon/concepts/graph_components.h
- Timestamp:
- 12/01/11 09:05:47 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/concepts/graph_components.h
r1018 r1025 318 318 /// \brief Class to represent red nodes. 319 319 /// 320 /// This class represents the red nodes of the graph. It does 321 /// not supposed to be used directly, because the nodes can be 322 /// represented as Node instances. This class can be used as 323 /// template parameter for special map classes. 320 /// This class represents the red nodes of the graph. The red 321 /// nodes can be used also as normal nodes. 324 322 class RedNode : public Node { 325 323 typedef Node Parent; … … 345 343 /// \sa Invalid for more details. 346 344 RedNode(Invalid) {} 347 348 /// \brief Constructor for conversion from a node.349 ///350 /// Constructor for conversion from a node. The conversion can351 /// be invalid, since the Node can be member of the blue352 /// set.353 RedNode(const Node&) {}354 345 }; 355 346 356 347 /// \brief Class to represent blue nodes. 357 348 /// 358 /// This class represents the blue nodes of the graph. It does 359 /// not supposed to be used directly, because the nodes can be 360 /// represented as Node instances. This class can be used as 361 /// template parameter for special map classes. 349 /// This class represents the blue nodes of the graph. The blue 350 /// nodes can be used also as normal nodes. 362 351 class BlueNode : public Node { 363 352 typedef Node Parent; … … 405 394 /// 406 395 /// Gives back the red end node of the edge. 407 Node redNode(const Edge&) const { returnNode(); }396 RedNode redNode(const Edge&) const { return RedNode(); } 408 397 409 398 /// \brief Gives back the blue end node of the edge. 410 399 /// 411 400 /// Gives back the blue end node of the edge. 412 Node blueNode(const Edge&) const { return Node(); } 401 BlueNode blueNode(const Edge&) const { return BlueNode(); } 402 403 /// \brief Converts the node to red node object. 404 /// 405 /// This class is converts unsafely the node to red node 406 /// object. It should be called only if the node is from the red 407 /// partition or INVALID. 408 RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); } 409 410 /// \brief Converts the node to blue node object. 411 /// 412 /// This class is converts unsafely the node to blue node 413 /// object. It should be called only if the node is from the red 414 /// partition or INVALID. 415 BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); } 416 417 /// \brief Converts the node to red node object. 418 /// 419 /// This class is converts safely the node to red node 420 /// object. If the node is not from the red partition, then it 421 /// returns INVALID. 422 RedNode asRedNode(const Node&) const { return RedNode(); } 423 424 /// \brief Converts the node to blue node object. 425 /// 426 /// This class is converts unsafely the node to blue node 427 /// object. If the node is not from the blue partition, then it 428 /// returns INVALID. 429 BlueNode asBlueNode(const Node&) const { return BlueNode(); } 430 431 /// \brief Convert the node to either red or blue node. 432 /// 433 /// If the node is from the red partition then it is returned in 434 /// first and second is INVALID. If the node is from the blue 435 /// partition then it is returned in second and first is 436 /// INVALID. If the node INVALID then both first and second are 437 /// INVALID in the return value. 438 std::pair<RedNode, BlueNode> asRedBlueNode(const Node&) const { 439 return std::make_pair(RedNode(), BlueNode()); 440 } 413 441 414 442 template <typename _BpGraph> … … 426 454 { 427 455 Node n; 428 RedNode rn = n; 429 BlueNode bn = bn; 456 RedNode rn; 457 BlueNode bn; 458 Node rnan = rn; 459 Node bnan = bn; 430 460 Edge e; 431 461 bool b; 432 b = bpgraph.red(n); 433 b = bpgraph.blue(n); 434 ignore_unused_variable_warning(b); 435 n = bpgraph.redNode(e); 436 n = bpgraph.blueNode(e); 437 rn = n; 438 bn = n; 462 b = bpgraph.red(rnan); 463 b = bpgraph.blue(bnan); 464 rn = bpgraph.redNode(e); 465 bn = bpgraph.blueNode(e); 466 rn = bpgraph.asRedNodeUnsafe(rnan); 467 bn = bpgraph.asBlueNodeUnsafe(bnan); 468 rn = bpgraph.asRedNode(rnan); 469 bn = bpgraph.asBlueNode(bnan); 470 std::pair<RedNode, BlueNode> p = bpgraph.asRedBlueNode(rnan); 471 ignore_unused_variable_warning(b,p); 439 472 } 440 473 } … … 600 633 /// 601 634 /// Return a unique integer id for the given node in the red set. 602 int redId(const Node&) const { return -1; }603 604 /// \brief Return the same value as redId().605 ///606 /// Return the same value as redId().607 635 int id(const RedNode&) const { return -1; } 608 636 … … 610 638 /// 611 639 /// Return a unique integer id for the given node in the blue set. 612 int blueId(const Node&) const { return -1; }613 614 /// \brief Return the same value as blueId().615 ///616 /// Return the same value as blueId().617 640 int id(const BlueNode&) const { return -1; } 618 641 … … 639 662 typename _BpGraph::RedNode red; 640 663 typename _BpGraph::BlueNode blue; 641 int rid = bpgraph.redId(node); 642 int bid = bpgraph.blueId(node); 643 rid = bpgraph.id(red); 644 bid = bpgraph.id(blue); 664 int rid = bpgraph.id(red); 665 int bid = bpgraph.id(blue); 645 666 rid = bpgraph.maxRedId(); 646 667 bid = bpgraph.maxBlueId(); … … 1138 1159 typedef BAS Base; 1139 1160 typedef typename Base::Node Node; 1161 typedef typename Base::RedNode RedNode; 1162 typedef typename Base::BlueNode BlueNode; 1140 1163 typedef typename Base::Arc Arc; 1141 1164 typedef typename Base::Edge Edge; 1142 1143 1165 1144 1166 typedef IterableBpGraphComponent BpGraph; 1145 1167 1168 using IterableGraphComponent<BAS>::first; 1169 using IterableGraphComponent<BAS>::next; 1170 1146 1171 /// \name Base Iteration 1147 1172 /// … … 1153 1178 /// 1154 1179 /// This function gives back the first red node in the iteration order. 1155 void first Red(Node&) const {}1180 void first(RedNode&) const {} 1156 1181 1157 1182 /// \brief Return the next red node. 1158 1183 /// 1159 1184 /// This function gives back the next red node in the iteration order. 1160 void next Red(Node&) const {}1185 void next(RedNode&) const {} 1161 1186 1162 1187 /// \brief Return the first blue node. 1163 1188 /// 1164 1189 /// This function gives back the first blue node in the iteration order. 1165 void first Blue(Node&) const {}1190 void first(BlueNode&) const {} 1166 1191 1167 1192 /// \brief Return the next blue node. 1168 1193 /// 1169 1194 /// This function gives back the next blue node in the iteration order. 1170 void next Blue(Node&) const {}1195 void next(BlueNode&) const {} 1171 1196 1172 1197 … … 1182 1207 /// 1183 1208 /// This iterator goes through each red node. 1184 typedef GraphItemIt<BpGraph, Node> RedIt;1209 typedef GraphItemIt<BpGraph, RedNode> RedIt; 1185 1210 1186 1211 /// \brief This iterator goes through each blue node. 1187 1212 /// 1188 1213 /// This iterator goes through each blue node. 1189 typedef GraphItemIt<BpGraph, Node> BlueIt;1214 typedef GraphItemIt<BpGraph, BlueNode> BlueIt; 1190 1215 1191 1216 /// @} … … 1196 1221 checkConcept<IterableGraphComponent<Base>, _BpGraph>(); 1197 1222 1198 typename _BpGraph::Node node(INVALID); 1199 bpgraph.firstRed(node); 1200 bpgraph.nextRed(node); 1201 bpgraph.firstBlue(node); 1202 bpgraph.nextBlue(node); 1203 1204 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::Node>, 1223 typename _BpGraph::RedNode rn(INVALID); 1224 bpgraph.first(rn); 1225 bpgraph.next(rn); 1226 typename _BpGraph::BlueNode bn(INVALID); 1227 bpgraph.first(bn); 1228 bpgraph.next(bn); 1229 1230 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::RedNode>, 1205 1231 typename _BpGraph::RedIt>(); 1206 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph:: Node>,1232 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::BlueNode>, 1207 1233 typename _BpGraph::BlueIt>(); 1208 1234 } … … 1791 1817 { // int map test 1792 1818 typedef typename _BpGraph::template RedMap<int> IntRedMap; 1793 checkConcept<GraphMap<_BpGraph, typename _BpGraph:: Node, int>,1819 checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, int>, 1794 1820 IntRedMap >(); 1795 1821 } { // bool map test 1796 1822 typedef typename _BpGraph::template RedMap<bool> BoolRedMap; 1797 checkConcept<GraphMap<_BpGraph, typename _BpGraph:: Node, bool>,1823 checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, bool>, 1798 1824 BoolRedMap >(); 1799 1825 } { // Dummy map test 1800 1826 typedef typename _BpGraph::template RedMap<Dummy> DummyRedMap; 1801 checkConcept<GraphMap<_BpGraph, typename _BpGraph:: Node, Dummy>,1827 checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, Dummy>, 1802 1828 DummyRedMap >(); 1803 1829 } … … 1805 1831 { // int map test 1806 1832 typedef typename _BpGraph::template BlueMap<int> IntBlueMap; 1807 checkConcept<GraphMap<_BpGraph, typename _BpGraph:: Node, int>,1833 checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, int>, 1808 1834 IntBlueMap >(); 1809 1835 } { // bool map test 1810 1836 typedef typename _BpGraph::template BlueMap<bool> BoolBlueMap; 1811 checkConcept<GraphMap<_BpGraph, typename _BpGraph:: Node, bool>,1837 checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, bool>, 1812 1838 BoolBlueMap >(); 1813 1839 } { // Dummy map test 1814 1840 typedef typename _BpGraph::template BlueMap<Dummy> DummyBlueMap; 1815 checkConcept<GraphMap<_BpGraph, typename _BpGraph:: Node, Dummy>,1841 checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, Dummy>, 1816 1842 DummyBlueMap >(); 1817 1843 } … … 1924 1950 typedef BAS Base; 1925 1951 typedef typename Base::Node Node; 1952 typedef typename Base::RedNode RedNode; 1953 typedef typename Base::BlueNode BlueNode; 1926 1954 typedef typename Base::Edge Edge; 1927 1955 … … 1929 1957 /// 1930 1958 /// This function adds a red new node to the digraph. 1931 Node addRedNode() {1959 RedNode addRedNode() { 1932 1960 return INVALID; 1933 1961 } … … 1936 1964 /// 1937 1965 /// This function adds a blue new node to the digraph. 1938 Node addBlueNode() {1966 BlueNode addBlueNode() { 1939 1967 return INVALID; 1940 1968 } … … 1945 1973 /// of the graph. The first node has to be a red node, and the 1946 1974 /// second one a blue node. 1947 Edge addEdge(const Node&, constNode&) {1975 Edge addEdge(const RedNode&, const BlueNode&) { 1948 1976 return INVALID; 1949 1977 } 1978 Edge addEdge(const BlueNode&, const RedNode&) { 1979 return INVALID; 1980 } 1950 1981 1951 1982 template <typename _BpGraph> … … 1953 1984 void constraints() { 1954 1985 checkConcept<Base, _BpGraph>(); 1955 typename _BpGraph::Node red_node, blue_node; 1986 typename _BpGraph::RedNode red_node; 1987 typename _BpGraph::BlueNode blue_node; 1956 1988 red_node = bpgraph.addRedNode(); 1957 1989 blue_node = bpgraph.addBlueNode(); 1958 1990 typename _BpGraph::Edge edge; 1959 1991 edge = bpgraph.addEdge(red_node, blue_node); 1992 edge = bpgraph.addEdge(blue_node, red_node); 1960 1993 } 1961 1994
Note: See TracChangeset
for help on using the changeset viewer.