Add tests for DecrementalSCC::query and DecrementalSCC::remove

This commit is contained in:
stefiosif
2022-07-26 20:42:02 +03:00
parent 46cdadc758
commit 48de05174a

View File

@@ -7,7 +7,7 @@ using namespace graph;
TEST_SUITE("Roditty and Zwick") { TEST_SUITE("Roditty and Zwick") {
TEST_CASE("Roditty Zwick A1 T1 ") { TEST_CASE("DecrementalSCC 1") {
// 1 --> 2 --> 5 --> 7 --> 2 // 1 --> 2 --> 5 --> 7 --> 2
// 1 --> 4 --> 3 --> 1 // 1 --> 4 --> 3 --> 1
// 4 --> 6 --> 3 // 4 --> 6 --> 3
@@ -22,22 +22,146 @@ TEST_SUITE("Roditty and Zwick") {
G.insert(6, 3); G.insert(6, 3);
G.insert(7, 2); G.insert(7, 2);
REQUIRE_EQ(G.adjMatrix.size(), 7);
algo::DecrementalSCC<std::uint16_t> rz(G); algo::DecrementalSCC<std::uint16_t> rz(G);
rz.init(); rz.init();
std::vector<std::vector<std::uint16_t>> exp = { SUBCASE("DecrementalSCC::query") {
{2, 5, 7}, CHECK_EQ(rz.query(1, 2), false);
{1, 3, 4, 6} CHECK_EQ(rz.query(1, 3), true);
}; CHECK_EQ(rz.query(1, 7), false);
CHECK_EQ(rz.query(2, 3), false);
CHECK_EQ(rz.query(2, 5), true);
CHECK_EQ(rz.query(5, 7), true);
}
CHECK_EQ(rz.query(1, 2), false); SUBCASE("DecrementalSCC::remove") {
CHECK_EQ(rz.query(1, 3), true); rz.remove(4,3);
CHECK_EQ(rz.query(1, 7), false); CHECK_EQ(rz.query(4, 3), true);
CHECK_EQ(rz.query(2, 3), false);
CHECK_EQ(rz.query(2, 5), true);
CHECK_EQ(rz.query(5, 7), true);
//CHECK_EQ(rz.query(1, 2), true); rz.remove(2, 5);
CHECK_EQ(rz.query(5, 7), false);
}
}
TEST_CASE("DecrementalSCC 2") {
// 1 --> 2 --> 3 --> 1
// 3 --> 4 --> 5 --> 3
// 2 --> 6 --> 7 --> 8 --> 6
// 6 --> 9 --> 10 --> 11 --> 12 --> 13 --> 9
// 12 --> 10
Digraph<std::uint16_t> G;
G.insert(1, 2);
G.insert(2, 3);
G.insert(3, 1);
G.insert(3, 4);
G.insert(4, 5);
G.insert(5, 3);
G.insert(2, 6);
G.insert(6, 7);
G.insert(7, 8);
G.insert(7, 9);
G.insert(8, 6);
G.insert(6, 9);
G.insert(9, 10);
G.insert(10, 11);
G.insert(11, 12);
G.insert(12, 13);
G.insert(13, 9);
G.insert(12, 10);
REQUIRE_EQ(G.adjMatrix.size(), 13);
algo::DecrementalSCC<std::uint16_t> rz(G);
rz.init();
SUBCASE("DecrementalSCC::query") {
CHECK_EQ(rz.query(1, 2), true);
CHECK_EQ(rz.query(1, 3), true);
CHECK_EQ(rz.query(1, 7), false);
CHECK_EQ(rz.query(2, 3), true);
CHECK_EQ(rz.query(2, 13), false);
CHECK_EQ(rz.query(11, 9), true);
}
SUBCASE("DecrementalSCC::remove") {
rz.remove(12, 10);
CHECK_EQ(rz.query(12, 10), true);
rz.remove(3, 4);
CHECK_EQ(rz.query(2, 5), false);
CHECK_EQ(rz.query(1, 3), true);
}
}
TEST_CASE("DecrementalTC 1") {
// 1 --> 2 --> 5 --> 7 --> 2
// 1 --> 4 --> 3 --> 1
// 4 --> 6 --> 3
Digraph<std::uint16_t> G;
G.insert(1, 2);
G.insert(1, 4);
G.insert(2, 5);
G.insert(3, 1);
G.insert(4, 3);
G.insert(4, 6);
G.insert(5, 7);
G.insert(6, 3);
G.insert(7, 2);
REQUIRE_EQ(G.adjMatrix.size(), 7);
algo::DecrementalTC<std::uint16_t> rz(G);
rz.init();
SUBCASE("DecrementalTC::query") {
}
SUBCASE("DecrementalTC::remove") {
}
}
TEST_CASE("DecrementalTC 2") {
// 1 --> 2 --> 3 --> 1
// 3 --> 4 --> 5 --> 3
// 2 --> 6 --> 7 --> 8 --> 6
// 6 --> 9 --> 10 --> 11 --> 12 --> 13 --> 9
// 12 --> 10
Digraph<std::uint16_t> G;
G.insert(1, 2);
G.insert(2, 3);
G.insert(3, 1);
G.insert(3, 4);
G.insert(4, 5);
G.insert(5, 3);
G.insert(2, 6);
G.insert(6, 7);
G.insert(7, 8);
G.insert(7, 9);
G.insert(8, 6);
G.insert(6, 9);
G.insert(9, 10);
G.insert(10, 11);
G.insert(11, 12);
G.insert(12, 13);
G.insert(13, 9);
G.insert(12, 10);
REQUIRE_EQ(G.adjMatrix.size(), 13);
algo::DecrementalTC<std::uint16_t> rz(G);
rz.init();
SUBCASE("DecrementalTC::query") {
}
SUBCASE("DecrementalTC::remove") {
}
} }
} }