Add BFS tree
This commit is contained in:
@@ -3,15 +3,18 @@
|
||||
#include "graph/graph.h"
|
||||
using namespace graph;
|
||||
#include "algorithm/tarjan.h"
|
||||
#include "algorithm/bfs.h"
|
||||
|
||||
TEST_SUITE("Algorithms") {
|
||||
TEST_SUITE("Algorithm.") {
|
||||
|
||||
TEST_CASE("Tarjan T_1") {
|
||||
|
||||
// 1 --> 2 --> 4 --> 1
|
||||
// 2 --> 3 --> 5 --> 7 --> 3
|
||||
// 5 --> 9 --> 6 --> 8 --> 9
|
||||
Graph<std::uint16_t> G;
|
||||
G.insert(1, 2);
|
||||
G.insert(2, 4);
|
||||
G.insert(2, 3);
|
||||
G.insert(2, 4);
|
||||
G.insert(3, 5);
|
||||
G.insert(4, 1);
|
||||
G.insert(5, 7);
|
||||
@@ -41,10 +44,12 @@ TEST_SUITE("Algorithms") {
|
||||
}
|
||||
|
||||
TEST_CASE("Tarjan T_2") {
|
||||
|
||||
// 1 --> 2 --> 5 --> 7 --> 2
|
||||
// 1 --> 4 --> 3 --> 1
|
||||
// 4 --> 6 --> 3
|
||||
Graph<std::uint16_t> G;
|
||||
G.insert(1, 4);
|
||||
G.insert(1, 2);
|
||||
G.insert(1, 4);
|
||||
G.insert(2, 5);
|
||||
G.insert(3, 1);
|
||||
G.insert(4, 3);
|
||||
@@ -70,4 +75,23 @@ TEST_SUITE("Algorithms") {
|
||||
|
||||
CHECK_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_CASE("BFS T_1") {
|
||||
// 1 --> 2 --> 5 --> 7 --> 2
|
||||
// 1 --> 4 --> 3 --> 1
|
||||
// 4 --> 6 --> 3
|
||||
Graph<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::BFS<std::uint16_t> bfs(G, 1);
|
||||
auto bfsTree = bfs.run();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user