Split graph folder into graph and tree
This commit is contained in:
@@ -112,7 +112,7 @@ TEST_SUITE("Algorithm") {
|
||||
{5, {7}}
|
||||
};
|
||||
|
||||
CHECK_EQ(tree.adjMatrix, exp);
|
||||
CHECK_EQ(tree, exp);
|
||||
}
|
||||
|
||||
TEST_CASE("Roditty Zwick A1 T1 ") {
|
||||
|
||||
41
test/tree_test.cc
Normal file
41
test/tree_test.cc
Normal file
@@ -0,0 +1,41 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user