Skip to content
Snippets Groups Projects
Commit 97feb47b authored by Giann Karlo Aguirre Samboní's avatar Giann Karlo Aguirre Samboní
Browse files

Get info tree implementation but not ready

parent 85beebca
No related branches found
No related tags found
No related merge requests found
......@@ -162,6 +162,27 @@ int ADtree::empty_tree(TreeNode *node){
/* Others methods*/
// Printing tree...
string ADtree::get_info_inorder(TreeNode *node, string info){
//node = (node == nullptr && info == "") ? this->root_ : node;
/* TreeNode* tmp_node = new TreeNode();
tmp_node = this->root_;
info += to_string(tmp_node->get_id()); */
//cout << to_string(node->get_id()) << endl;
if(node != nullptr){
info += get_info_inorder(node->get_first_child(), info) + "\n";
if(node->get_first_child() != nullptr)
info += get_info_inorder(node->get_first_child()->get_next_sibling(), info) + "\n";
info += node->get_info() + "\n";
}
return info;
}
string ADtree::get_info_inorder(){
return get_info_inorder(this->root_, "");
}
// Adding children or parents...
void ADtree::add_child(TreeNode *new_child, TreeNode *parent){
......
......@@ -42,7 +42,9 @@ class ADtree{
void preorder_print();
int empty_tree(TreeNode *node);
//Printing...
string get_info_inorder(TreeNode *node, string info);
string get_info_inorder();
//Adding...
void add_child(TreeNode *new_child, TreeNode *parent);
......
......@@ -68,7 +68,8 @@ int main(){
std::cout << endl;
cout << node_six->get_parents() << endl;
cout << node_six->get_children() << endl;
cout << node_six->get_info() << endl;
//cout << node_six->get_info() << endl;
cout << tree->get_info_inorder() << endl;
/*tree->preorder_print();
tree->inorder_print();
tree->postorder_print();
......
......@@ -146,8 +146,8 @@ string TreeNode::get_info (){
info_node += "Node type = " + to_string(this->node_type_) + "; ";
info_node += "Goal = " + this->goal_ + "; ";
info_node += "Value = " + to_string(this->value_) + "; ";
info_node += "Parents = " + this->get_children() + "; ";
info_node += "Children = " + this->get_parents() + ")";
info_node += "Parents = " + this->get_parents() + "; ";
info_node += "Children = " + this->get_children() + ")";
return info_node;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment