src/GRAPHGEN/forest2dag.cpp
// Recursively searches for equal subtrees inside the forest. It starts from a root of the forest
// and explore its subtrees. For each subtree, if there is an equal subtree (i.e. sp_ hash table
// contains the tree identifier string) the function updates the link, otherwise it updates the 
// hash table with the "new" subtree. This must be repeated for every root of the forest (see Forest2Dag) 
Recursively searches for equal subtrees inside the forest. It starts from a root of the forest
and explore its subtrees. For each subtree, if there is an equal subtree  the function updates the link, otherwise it updates the
hash table with the "new" subtree. This must be repeated for every root of the forest
Recursively searches for equal subtrees inside the forest . It starts from a root of the forest and explore its subtrees . For each subtree if there is an equal subtree the function updates the link otherwise it updates the hash table with the " new " subtree . This must be repeated for every root of the forest
void Forest2Dag::FindAndLink(BinaryDrag<conact>::node* n) {
	if (!n->isleaf()) {
		auto s = Tree2String(n->left);
		auto it = sp_.find(s);
		if (it == end(sp_)) {
			sp_[s] = n->left;
			FindAndLink(n->left);
		}
		else {
			n->left = it->second;
		}
		s = Tree2String(n->right);
		it = sp_.find(s);
		if (it == end(sp_)) {
			sp_[s] = n->right;
			FindAndLink(n->right);
		}
		else {
			n->right = it->second;
		}
	}
}
void Forest2Dag :: FindAndLink ( BinaryDrag < conact > :: node * n ) { if ( ! n -> isleaf ( ) ) { auto s = Tree2String ( n -> left ) ; auto it = sp_ . find ( s ) ; if ( it == end ( sp_ ) ) { sp_ [ s ] = n -> left ; FindAndLink ( n -> left ) ; } else { n -> left = it -> second ; } s = Tree2String ( n -> right ) ; it = sp_ . find ( s ) ; if ( it == end ( sp_ ) ) { sp_ [ s ] = n -> right ; FindAndLink ( n -> right ) ; } else { n -> right = it -> second ; } } }
Recursively searches for equal subtrees inside the forest.
Recursively searches for equal subtrees inside the forest .