Put root of BFS tree as constructor parameter

This commit is contained in:
stefiosif
2022-07-12 14:41:18 +03:00
parent 77dee72317
commit e7ad824116
2 changed files with 13 additions and 16 deletions

View File

@@ -1,8 +1,8 @@
#ifndef BREADTH_FIRST_TREE_H_
#define BREADTH_FIRST_TREE_H_
#include "algorithm/bfs.h"
#include "out_tree.h"
#include "algorithm/breadth_first_search.h"
using namespace graph;
namespace tree {
@@ -12,16 +12,15 @@ class BreadthFirstTree : public OutTree<T> {
public:
BreadthFirstTree() = default;
BreadthFirstTree(Digraph<T> G);
BreadthFirstTree(Digraph<T> G, T root);
BreadthFirstTree(std::map<T, std::set<T>> G)
: OutTree<T>::OutTree(G) {}
};
template<typename T>
BreadthFirstTree<T>::BreadthFirstTree(Digraph<T> G) {
auto bfs = algo::BFS<T>(G).run(1);
BreadthFirstTree<T>::BreadthFirstTree(Digraph<T> G, T root) {
auto bfs = algo::BreadthFirstSearch<T>(G).execute(root);
Graph<T>::adjMatrix = bfs;
}