Split graph folder into graph and tree

This commit is contained in:
stefiosif
2022-07-10 15:32:13 +03:00
parent 3fa6935b84
commit b9cd1a1cbd
11 changed files with 176 additions and 25 deletions

View File

@@ -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
View 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);
}
}