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

first presentation adtrees

parent 97feb47b
No related branches found
No related tags found
No related merge requests found
......@@ -164,6 +164,7 @@ int ADtree::empty_tree(TreeNode *node){
// Printing tree...
/* Implementin this !!! */
string ADtree::get_info_inorder(TreeNode *node, string info){
//node = (node == nullptr && info == "") ? this->root_ : node;
/* TreeNode* tmp_node = new TreeNode();
......
......@@ -19,36 +19,49 @@ int main(){
// Adding...
tree->add_child(node_two, node_one);
tree->add_child(node_three, node_one);
/* tree->add_child(node_three, node_one);
tree->add_child(node_four, node_one);
tree->add_child(node_five, node_one);
tree->add_child(node_five, node_one); */
tree->add_child(node_six, node_one);
tree->add_parent(node_two, node_six);
tree->add_child(node_seven, node_six);
/*tree->add_child(node_seven, node_six);
tree->add_child_pos(node_eight, node_one, 5);
tree->add_parent(node_three, node_six);
tree->add_parent_pos(node_nine, node_six, 3);
tree->add_child(node_six, node_six); // probably doesn't make sense
tree->add_parent(node_one, node_one); // probably doesn't make sense
tree->add_parent(node_one, node_one); // probably doesn't make sense */
//cout << *(node_one->get_associated_ids().begin()) << endl;
cout << "first parent of node six: " << node_six->get_first_parent()->get_id() << endl;
/* cout << "first parent of node six: " << node_six->get_first_parent()->get_id() << endl;
cout << "second parent of node six: " << node_six->get_first_parent()->get_next_pibling()->get_id() << endl;
cout << "third parent of node six: " << node_six->get_first_parent()->get_next_pibling()->get_next_pibling()->get_id() << endl;
cout << "first parent of node eight: " << node_eight->get_first_parent()->get_id() << endl;
cout << "last child of node one: " << node_one->get_first_child()->get_next_sibling()->get_next_sibling()->get_next_sibling()->get_next_sibling()->get_next_sibling()->get_id() << endl;
cout << "fourth parent of node six: " << node_six->get_first_parent()->get_next_pibling()->get_next_pibling()->get_next_pibling()->get_id() << endl;
cout << "fourth parent of node six: " << node_six->get_first_parent()->get_next_pibling()->get_next_pibling()->get_next_pibling()->get_id() << endl; */
cout << node_one->get_info() << endl;
cout << node_two->get_info() << endl;
cout << node_three->get_info() << endl;
cout << node_four->get_info() << endl;
cout << node_five->get_info() << endl;
cout << node_six->get_info() << endl;
cout << node_seven->get_info() << endl;
cout << node_eight->get_info() << endl;
cout << node_nine->get_info() << endl;
cout << node_ten->get_info() << endl;
// Removing...
tree->remove_child(node_six, node_one);
tree->remove_parent_pos(0, node_six);
/* tree->remove_child(node_six, node_one);
tree->remove_parent_pos(0, node_six); */
//tree->remove_child_pos(0, node_ten);
// Lineage printing...
cout << "child associated ids of node one:" << endl;
/* cout << "child associated ids of node one:" << endl;
for (auto& i : node_one->get_child_associated_ids()) // reference to The C++ Programming Language book, p. 899
cout << i << ' ';
cout << endl << "parent associated ids of node one:" << endl;
std::cout << endl; */
/* cout << endl << "parent associated ids of node one:" << endl;
for (auto& i : node_one->get_parent_associated_ids()) // reference to The C++ Programming Language book, p. 899
cout << i << ' ';
cout << endl << "parent associated ids of node four:" << endl;
......@@ -59,28 +72,39 @@ int main(){
cout << i << ' ';
cout << endl << "parent associated ids of node six:" << endl;
for (auto& i : node_six->get_parent_associated_ids()) // reference to The C++ Programming Language book, p. 899
cout << i << ' ';
cout << i << ' '; */
/*
set<int> tmp_set = node_one->get_child_associated_ids();
for(auto it = (tmp_set).cbegin() ; it != (tmp_set).cend() && *it != cur_child->get_id(); it++){
std::cout << *it << ' ';
} */
std::cout << endl;
cout << node_six->get_parents() << endl;
cout << node_six->get_children() << endl;
/* cout << node_six->get_parents() << endl;
cout << node_six->get_children() << endl; */
cout << "Removing ..." << endl;
//cout << node_six->get_info() << endl;
cout << tree->get_info_inorder() << endl;
/* cout << tree->get_info_inorder() << endl; */
/*tree->preorder_print();
tree->inorder_print();
tree->postorder_print();
tree->postorder_print();*/
cout << node_one->get_info() << endl;
cout << node_two->get_info() << endl;
cout << node_three->get_info() << endl;
cout << node_four->get_info() << endl;
cout << node_five->get_info() << endl;
cout << node_six->get_info() << endl;
cout << node_seven->get_info() << endl;
cout << node_eight->get_info() << endl;
cout << node_nine->get_info() << endl;
cout << node_ten->get_info() << endl;
tree->get_root()->set_goal("Hola Giann Karlo");*/
delete tree;
NodeType nodeTest{NodeType::Attack};
cout << "node type = " << to_string(nodeTest) << endl;
/* NodeType nodeTest{NodeType::Attack};
cout << "node type = " << to_string(nodeTest) << endl; */
return 0;
}
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