Add roditty and zwick class
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "graph/scc.h"
|
||||
#include "algorithm/tarjan.h"
|
||||
#include "algorithm/bfs.h"
|
||||
#include "algorithm/roditty_zwick.h"
|
||||
|
||||
using namespace graph;
|
||||
|
||||
@@ -91,8 +92,8 @@ TEST_SUITE("Algorithm") {
|
||||
G.insert(6, 3);
|
||||
G.insert(7, 2);
|
||||
|
||||
algo::BFS<std::uint16_t> bfs(G, 1);
|
||||
auto tree = bfs.run();
|
||||
algo::BFS<std::uint16_t> bfs(G);
|
||||
auto tree = bfs.run(1);
|
||||
|
||||
/*std::map<std::uint16_t, std::set<std::uint16_t>> exp = {
|
||||
{1, {2, 4}},
|
||||
@@ -111,6 +112,25 @@ TEST_SUITE("Algorithm") {
|
||||
{5, {7}}
|
||||
};
|
||||
|
||||
CHECK_EQ(tree, exp);
|
||||
CHECK_EQ(tree.adjMatrix, exp);
|
||||
}
|
||||
|
||||
TEST_CASE("Roditty Zwick A1 T1 ") {
|
||||
// 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);
|
||||
|
||||
algo::RodittyZwick<std::uint16_t> rz(G);
|
||||
rz.sccDecrementalMaintenance();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user