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

30
tree/breadth_first_tree.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef BREADTH_FIRST_TREE_H_
#define BREADTH_FIRST_TREE_H_
#include "algorithm/bfs.h"
#include "out_tree.h"
using namespace graph;
namespace tree {
template<typename T>
class BreadthFirstTree : public OutTree<T> {
public:
BreadthFirstTree() = default;
BreadthFirstTree(Digraph<T> G);
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);
Graph<T>::adjMatrix = bfs;
}
} // namespace tree
#endif

View File

@@ -0,0 +1,20 @@
#ifndef DIRECTED_ROOTED_TREE_H_
#define DIRECTED_ROOTED_TREE_H_
#include "tree.h"
using namespace graph;
namespace tree {
template<typename T>
class DirectedRootedTree : public Tree<T> {
public:
DirectedRootedTree() = default;
DirectedRootedTree(std::map<T, std::set<T>> G)
: Tree<T>::Tree(G) {}
};
} // namespace tree
#endif

20
tree/in_tree.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef IN_TREE_H_
#define IN_TREE_H_
#include "directed_rooted_tree.h"
using namespace graph;
namespace tree {
template<typename T>
class InTree : public DirectedRootedTree<T> {
public:
InTree() = default;
InTree(std::map<T, std::set<T>> G)
: DirectedRootedTree<T>::DirectedRootedTree(G) {}
};
} // namespace tree
#endif

20
tree/out_tree.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef OUT_TREE_H_
#define OUT_TREE_H_
#include "directed_rooted_tree.h"
using namespace graph;
namespace tree {
template<typename T>
class OutTree : public DirectedRootedTree<T> {
public:
OutTree() = default;
OutTree(std::map<T, std::set<T>> G)
: DirectedRootedTree<T>::DirectedRootedTree(G) {}
};
} // namespace tree
#endif

19
tree/tree.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef TREE_H_
#define TREE_H_
#include "graph/digraph.h"
using namespace graph;
namespace tree {
template<typename T>
class Tree : public Digraph<T> {
public:
Tree() = default;
Tree(std::map<T, std::set<T>> G) : Digraph<T>::Digraph(G) {}
};
} // namespace tree
#endif