src/GRAPHGEN/forest2dag.cpp
// Converts a tree into unique string exploiting memoization 
Converts a tree into unique string exploiting memoization
Converts a tree into unique string exploiting memoization
string Forest2Dag::Tree2String(BinaryDrag<conact>::node* n) {
	auto it = ps_.find(n);
	if (it != end(ps_))
		return it->second;
	string s;
	if (n->isleaf()) {
		stringstream ss;
		ss << setfill('0') << setw(3) << n->data.next;
		s = n->data.action.to_string() + ss.str();
	}
	else
		s = n->data.condition + Tree2String(n->left) + Tree2String(n->right);
	ps_[n] = s;
	return s;
}
string Forest2Dag :: Tree2String ( BinaryDrag < conact > :: node * n ) { auto it = ps_ . find ( n ) ; if ( it != end ( ps_ ) ) return it -> second ; string s ; if ( n -> isleaf ( ) ) { stringstream ss ; ss << setfill ( ' ' ) << setw ( 3 ) << n -> data . next ; s = n -> data . action . to_string ( ) + ss . str ( ) ; } else s = n -> data . condition + Tree2String ( n -> left ) + Tree2String ( n -> right ) ; ps_ [ n ] = s ; return s ; }
Converts a tree into unique string exploiting memoization
Converts a tree into unique string exploiting memoization
//char a_action[sizeof(n->data.action) + 1] = { 0 }; //memcpy(a_action, reinterpret_cast<char*>(&n->data.action), sizeof(n->data.action));