Files
reachability-algorithms/test/tree_test.cc
2022-07-10 15:32:13 +03:00

41 lines
793 B
C++

#include <doctest/doctest.h>
#include "graph/scc.h"
#include "graph/digraph.h"
#include "algorithm/tarjan.h"
#include "tree/breadth_first_tree.h"
#include <vector>
using namespace graph;
using namespace tree;
TEST_SUITE("Tree") {
TEST_CASE("Breadth First Tree") {
// 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);
BreadthFirstTree<std::uint16_t> tree(G);
std::map<std::uint16_t, std::set<std::uint16_t>> exp = {
{1, {2, 4}},
{2, {5}},
{4, {3, 6}},
{5, {7}}
};
CHECK_EQ(tree.adjMatrix, exp);
}
}