Add C++ testcases from Python
This commit is contained in:
parent
f652a08d43
commit
d539e5cfbb
|
@ -327,6 +327,42 @@ BOOST_AUTO_TEST_CASE(test51_augment_blossom_nested)
|
|||
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test52_augment_blossom_nested2)
|
||||
{
|
||||
/*
|
||||
*
|
||||
* [4]--15 19--[2]
|
||||
* | \ / |
|
||||
* 16 [1] 21
|
||||
* | / \ |
|
||||
* [5]--17 19--[3]
|
||||
* |
|
||||
* 10
|
||||
* |
|
||||
* [6]
|
||||
*/
|
||||
EdgeVectorLong edges = {
|
||||
{1, 2, 19}, {1, 3, 19}, {1, 4, 15}, {1, 5, 17}, {2, 3, 21}, {4, 5, 16}, {5, 6, 10}};
|
||||
Matching expect = {{1, 4}, {2, 3}, {5, 6}};
|
||||
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test61_triangles_n9)
|
||||
{
|
||||
/*
|
||||
* t.f 9 nodes
|
||||
*
|
||||
* [1]------[4] [7]
|
||||
* | \ | \ | \
|
||||
* | [3] | [6] | [9]
|
||||
* | / | / | /
|
||||
* [2] [5]------[8]
|
||||
*/
|
||||
EdgeVectorLong edges = {
|
||||
{1, 2, 1}, {1, 3, 1}, {2, 3, 1}, {4, 5, 1}, {4, 6, 1}, {5, 6, 1}, {7, 8, 1}, {7, 9, 1}, {8, 9, 1}, {1, 4, 1}, {5, 8, 1}};
|
||||
BOOST_TEST(mwmatching::maximum_weight_matching(edges).size() == 4);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_fail_bad_input)
|
||||
{
|
||||
EdgeVectorDouble inf_weight = {{1, 2, std::numeric_limits<double>::infinity()}};
|
||||
|
@ -734,3 +770,72 @@ BOOST_AUTO_TEST_CASE(test_blossom_not_full)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
|
||||
/* ********** Test graphs that force big values for dual / slack ********** */
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_value_range)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_big_blossom_dual)
|
||||
{
|
||||
/*
|
||||
* Force modified blossom dual close to 2*maxweight.
|
||||
*
|
||||
* [3]
|
||||
* / \
|
||||
* W-4/ \W
|
||||
* 7 / \
|
||||
* [1]-----[2]-----[4]
|
||||
* | W-4
|
||||
* 5|
|
||||
* | 1
|
||||
* [5]-----[6]
|
||||
*/
|
||||
long w = std::numeric_limits<long>::max() / 6;
|
||||
EdgeVectorLong edges = {{1, 2, 7}, {2, 3, w - 4}, {2, 4, w - 4}, {2, 5, 5}, {3, 4, w}, {5, 6, 1}};
|
||||
Matching expect = {{1, 2}, {3, 4}, {5, 6}};
|
||||
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_negative_blossom_dual)
|
||||
{
|
||||
/*
|
||||
* Force modified blossom dual close to -maxweight.
|
||||
*
|
||||
* [3]
|
||||
* / \
|
||||
* 5/ \7
|
||||
* 1 / \
|
||||
* [1]-----[2]-----[4]
|
||||
* | 5
|
||||
* 1|
|
||||
* | W
|
||||
* [5]-----[6]
|
||||
*/
|
||||
long w = std::numeric_limits<long>::max() / 6;
|
||||
EdgeVectorLong edges = {{1, 2, 1}, {2, 3, 5}, {2, 4, 5}, {2, 5, 1}, {3, 4, 7}, {5, 6, w}};
|
||||
Matching expect = {{1, 2}, {3, 4}, {5, 6}};
|
||||
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_big_edge_slack)
|
||||
{
|
||||
/*
|
||||
* Force modified edge slack close to 3*maxweight.
|
||||
*
|
||||
* 6 W W-2 5
|
||||
* [1]-----[2]-----[3]-----[4]-----[5]
|
||||
* | |
|
||||
* |1 |1
|
||||
* | |
|
||||
* [6]-----[7]-----[8]-----[9]-----[10]
|
||||
* 6 W W-2 5
|
||||
*/
|
||||
long w = std::numeric_limits<long>::max() / 6;
|
||||
EdgeVectorLong edges = {{1, 2, 6}, {1, 6, 1}, {2, 3, w}, {3, 4, w - 2}, {3, 8, 1}, {4, 5, 5},
|
||||
{6, 7, 6}, {7, 8, w}, {8, 9, w - 2}, {9, 10, 5}};
|
||||
Matching expect = {{1, 6}, {2, 3}, {4, 5}, {7, 8}, {9, 10}};
|
||||
BOOST_TEST(mwmatching::maximum_weight_matching(edges) == expect);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Reference in New Issue