29 lines
644 B
C++
29 lines
644 B
C++
#ifndef BREADTH_FIRST_TREE_H_
|
|
#define BREADTH_FIRST_TREE_H_
|
|
|
|
#include "directed_rooted_tree.h"
|
|
#include "algorithm/breadth_first_search.h"
|
|
using namespace graph;
|
|
|
|
namespace tree {
|
|
|
|
template<typename T>
|
|
class BreadthFirstTree : public DirectedRootedTree<T> {
|
|
public:
|
|
BreadthFirstTree() = default;
|
|
|
|
BreadthFirstTree(Digraph<T> G, T root);
|
|
|
|
BreadthFirstTree(std::map<T, std::set<T>> G)
|
|
: DirectedRootedTree<T>::DirectedRootedTree(G) {}
|
|
};
|
|
|
|
template<typename T>
|
|
BreadthFirstTree<T>::BreadthFirstTree(Digraph<T> G, T root) {
|
|
auto bfs = algo::BreadthFirstSearch<T>(G).execute(root);
|
|
this->adjMatrix = bfs;
|
|
}
|
|
|
|
} // namespace tree
|
|
|
|
#endif |