forked from AutoProving/3TST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree.hpp
38 lines (31 loc) · 931 Bytes
/
tree.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <iostream>
#include <stack>
#include "graph.hpp"
using namespace std;
class treeNode {
public:
Vertex parent;
Weight weight;
set<Vertex> children;
treeNode() : parent{-2}, weight{0} {};
int pruneLeaves(const vector<int> &terminalsMap);
void remove(Vertex v);
};
class Tree {
public:
Vertex root;
vector<treeNode> tree;
Tree(const Graph &G, istream &input);
Tree(const Graph &G, Vertex root);
void print(); // Recursively prints the tree
void print(const map<pair<Vertex, Vertex>, vector<Vertex>>
&hash); // Recursively prints the tree
void pruneRoot(const vector<int> &terminalsMap); // Prune the root if it's not
// a terminal node
bool check(const Graph &G);
Weight pruneLeaves(
const vector<int>
&terminalsMap); // Prune useless leaves and return the size of the tree
int size();
};