void _print_tree(Leaf *leaf, int indent) { // Prints the tree opening to the right via recursion. if(leaf != NULL) { _print_tree(leaf->right, indent + 2); print_indent(indent); printf("%d\n", leaf->data); _print_tree(leaf->left, indent + 2); } }
void trie_tree::print_tree(std::ostream& os)const{ auto root = get_root(); if (root == NULL) os << "the trie_tree is empty!" << std::endl; for (auto cit = root->map_childs.cbegin(); cit != root->map_childs.cend(); ++cit) _print_tree(os, cit->second, string()); }
void trie_tree::_print_tree(std::ostream& os, const node_ptr& up, string word)const{ word += up->data; if (up->is_a_word) os << word << std::endl; for (auto cit = up->map_childs.cbegin(); cit != up->map_childs.cend(); ++cit){ _print_tree(os, cit->second, word); } }
void c_MorphTree::print_tree() { vector<c_MorphNode> cur; _print_tree(root, cur); for (unsigned i=0; i<res.size(); i++) { cerr << i+1 << ". "; copy(res[i].begin(), res[i].end(), ostream_iterator<c_MorphNode>(cerr, " ")); cerr << endl; } }
void c_MorphTree::_print_tree(const c_MorphNode & node, vector<c_MorphNode>& cur) { //if (node.inf.morph) cerr << *(node.inf.morph) << " "; if (node.inf.morph) cur.push_back(node); for (unsigned i=0; i<node.nodes.size(); i++) { _print_tree(node.nodes[i], cur); cur.pop_back(); } if (!node.nodes.size()) { //for (unsigned j=0; j<cur.size(); j++) { // cerr << cur[j] << " "; //} //cerr << endl; res.push_back(cur); } }
void Node::print_tree() { _print_tree(this); }
void print_tree(Tree *tree) { // Figured out a great way to print trees. if(tree != NULL) _print_tree(tree->root, 0); }