7 #ifndef GRAPHGEN_FOREST_H_
8 #define GRAPHGEN_FOREST_H_
19 using eq_type = std::map<std::string, std::string>;
27 auto it = find(begin(ps), end(ps), p);
29 eq_[it->name_] = p.name_;
36 eq_type::iterator
it_;
38 operator bool() {
return it_ != end(
eq_); }
39 operator std::string() {
return it_->second; }
42 return {
eq_,
eq_.find(s) };
47 static std::vector<size_t> DEFAULT_VECTOR;
69 CreateReducedTreesRec(bd_.
roots_[0], constr);
80 auto ft =
eq_.Find(n->data.condition);
83 CreateReducedTreesRec(n->left, constrNew);
86 CreateReducedTreesRec(n->right, constrNew);
103 void RemoveUselessConditions();
104 void RemoveEndTreesUselessConditions();
109 bool RemoveEqualTrees();
110 bool RemoveEquivalentTrees();
115 bool RemoveEqualEndTrees();
116 bool RemoveEquivalentEndTrees();
126 bool RemoveEqualEndTreesSeparately();
127 bool RemoveEqualEndTreesJointly();
129 void RebuildDisjointTrees();
130 void RebuildDisjointEndTrees();
134 std::vector<size_t>& next_tree,
136 bool are_end_trees =
false,
137 std::vector<size_t>& mapping = DEFAULT_VECTOR);
void AddRoot(node *r)
Adds a new root to the vector of roots.
std::vector< node * > roots_
std::map< std::string, int > constraints
FindType(const eq_type &eq, eq_type::iterator it)
std::map< std::string, std::string > eq_type
FindType Find(const std::string &s)
Equivalences(const pixel_set &ps)
Creates forest of trees pruning original tree.
void CreateReducedTreesRec(const BinaryDrag< conact >::node *n, const constraints &constr)
const BinaryDrag< conact > & bd_
BinaryDrag< conact > & f_
CreateReducedDrag(const BinaryDrag< conact > &bd, BinaryDrag< conact > &f, const pixel_set &ps)
Generates all the forests needed to handle one line of the image.
void CreateReducedTrees(const BinaryDrag< conact > &t, const constraints &initial_constr)
std::vector< size_t > next_tree_
std::vector< std::vector< size_t > > main_end_tree_mapping_
std::vector< BinaryDrag< conact > > end_forests_
void CreateReducedTreesRec(const BinaryDrag< conact >::node *n, const constraints &constr={})
std::vector< std::vector< size_t > > end_next_tree_