# HG changeset patch
# User Balazs Dezso <deba@inf.elte.hu>
# Date 1326318230 -3600
# Node ID 37d179a450778255e09c55e8758b09668a10ffef
# Parent d248eca9ca25b2dc0a185c45ea9a3934dedca484
Remove asRedBludeNode() function
diff -r d248eca9ca25 -r 37d179a45077 lemon/bits/graph_extender.h
|
a
|
b
|
|
| 840 | 840 | } |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | | std::pair<RedNode, BlueNode> asRedBlueNode(const Node& node) const { |
| 844 | | if (node == INVALID) { |
| 845 | | return std::make_pair(RedNode(INVALID), BlueNode(INVALID)); |
| 846 | | } else if (Parent::red(node)) { |
| 847 | | return std::make_pair(Parent::asRedNodeUnsafe(node), BlueNode(INVALID)); |
| 848 | | } else { |
| 849 | | return std::make_pair(RedNode(INVALID), Parent::asBlueNodeUnsafe(node)); |
| 850 | | } |
| 851 | | } |
| 852 | | |
| 853 | 843 | // Alterable extension |
| 854 | 844 | |
| 855 | 845 | typedef AlterationNotifier<BpGraphExtender, Node> NodeNotifier; |
diff -r d248eca9ca25 -r 37d179a45077 lemon/concepts/bpgraph.h
|
a
|
b
|
|
| 800 | 800 | /// returns INVALID. |
| 801 | 801 | BlueNode asBlueNode(const Node&) const { return BlueNode(); } |
| 802 | 802 | |
| 803 | | /// \brief Convert the node to either red or blue node. |
| 804 | | /// |
| 805 | | /// If the node is from the red partition then it is returned in |
| 806 | | /// first and second is INVALID. If the node is from the blue |
| 807 | | /// partition then it is returned in second and first is |
| 808 | | /// INVALID. If the node INVALID then both first and second are |
| 809 | | /// INVALID in the return value. |
| 810 | | std::pair<RedNode, BlueNode> asRedBlueNode(const Node&) const { |
| 811 | | return std::make_pair(RedNode(), BlueNode()); |
| 812 | | } |
| 813 | | |
| 814 | 803 | /// \brief Gives back the red end node of the edge. |
| 815 | 804 | /// |
| 816 | 805 | /// Gives back the red end node of the edge. |
diff -r d248eca9ca25 -r 37d179a45077 lemon/concepts/graph_components.h
|
a
|
b
|
|
| 423 | 423 | /// returns INVALID. |
| 424 | 424 | BlueNode asBlueNode(const Node&) const { return BlueNode(); } |
| 425 | 425 | |
| 426 | | /// \brief Convert the node to either red or blue node. |
| 427 | | /// |
| 428 | | /// If the node is from the red partition then it is returned in |
| 429 | | /// first and second is INVALID. If the node is from the blue |
| 430 | | /// partition then it is returned in second and first is |
| 431 | | /// INVALID. If the node INVALID then both first and second are |
| 432 | | /// INVALID in the return value. |
| 433 | | std::pair<RedNode, BlueNode> asRedBlueNode(const Node&) const { |
| 434 | | return std::make_pair(RedNode(), BlueNode()); |
| 435 | | } |
| 436 | | |
| 437 | 426 | template <typename _BpGraph> |
| 438 | 427 | struct Constraints { |
| 439 | 428 | typedef typename _BpGraph::Node Node; |
| … |
… |
|
| 463 | 452 | bn = bpgraph.asBlueNodeUnsafe(bnan); |
| 464 | 453 | rn = bpgraph.asRedNode(rnan); |
| 465 | 454 | bn = bpgraph.asBlueNode(bnan); |
| 466 | | std::pair<RedNode, BlueNode> p = bpgraph.asRedBlueNode(rnan); |
| 467 | 455 | } |
| 468 | 456 | } |
| 469 | 457 | |
diff -r d248eca9ca25 -r 37d179a45077 lemon/core.h
|
a
|
b
|
|
| 1209 | 1209 | typedef typename To::Node Value; |
| 1210 | 1210 | |
| 1211 | 1211 | Value operator[](const Key& key) const { |
| 1212 | | std::pair<RedNode, BlueNode> red_blue_pair = _from.asRedBlueNode(key); |
| 1213 | | if (red_blue_pair.first != INVALID) { |
| 1214 | | return _red_node_ref[red_blue_pair.first]; |
| | 1212 | if (_from.red(key)) { |
| | 1213 | return _red_node_ref[_from.asRedNodeUnsafe(key)]; |
| 1215 | 1214 | } else { |
| 1216 | | return _blue_node_ref[red_blue_pair.second]; |
| | 1215 | return _blue_node_ref[_from.asBlueNodeUnsafe(key)]; |
| 1217 | 1216 | } |
| 1218 | 1217 | } |
| 1219 | 1218 | |
diff -r d248eca9ca25 -r 37d179a45077 test/graph_test.h
|
a
|
b
|
|
| 52 | 52 | check(G.asRedNodeUnsafe(nn) == n,"Wrong node conversion."); |
| 53 | 53 | check(G.asRedNode(nn) == n,"Wrong node conversion."); |
| 54 | 54 | check(G.asBlueNode(nn) == INVALID,"Wrong node conversion."); |
| 55 | | std::pair<typename Graph::RedNode, typename Graph::BlueNode> rbn = |
| 56 | | G.asRedBlueNode(nn); |
| 57 | | check(rbn.first == n,"Wrong node conversion."); |
| 58 | | check(rbn.second == INVALID,"Wrong node conversion."); |
| 59 | 55 | ++n; |
| 60 | 56 | } |
| 61 | 57 | check(n==INVALID,"Wrong red Node list linking."); |
| … |
… |
|
| 74 | 70 | check(G.asBlueNodeUnsafe(nn) == n,"Wrong node conversion."); |
| 75 | 71 | check(G.asBlueNode(nn) == n,"Wrong node conversion."); |
| 76 | 72 | check(G.asRedNode(nn) == INVALID,"Wrong node conversion."); |
| 77 | | std::pair<typename Graph::RedNode, typename Graph::BlueNode> rbn = |
| 78 | | G.asRedBlueNode(nn); |
| 79 | | check(rbn.first == INVALID,"Wrong node conversion."); |
| 80 | | check(rbn.second == n,"Wrong node conversion."); |
| 81 | 73 | ++n; |
| 82 | 74 | } |
| 83 | 75 | check(n==INVALID,"Wrong blue Node list linking."); |