Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
adt2amas
Manage
Activity
Members
Labels
Plan
Issues
9
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PARTIES
tools
adt2amas
Commits
97feb47b
Commit
97feb47b
authored
6 years ago
by
Giann Karlo Aguirre Samboní
Browse files
Options
Downloads
Patches
Plain Diff
Get info tree implementation but not ready
parent
85beebca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/ad_tree.cpp
+21
-0
21 additions, 0 deletions
src/ad_tree.cpp
src/ad_tree.hpp
+3
-1
3 additions, 1 deletion
src/ad_tree.hpp
src/adt2amas.cpp
+2
-1
2 additions, 1 deletion
src/adt2amas.cpp
src/tree_node.cpp
+2
-2
2 additions, 2 deletions
src/tree_node.cpp
with
28 additions
and
4 deletions
src/ad_tree.cpp
+
21
−
0
View file @
97feb47b
...
...
@@ -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
){
...
...
This diff is collapsed.
Click to expand it.
src/ad_tree.hpp
+
3
−
1
View file @
97feb47b
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/adt2amas.cpp
+
2
−
1
View file @
97feb47b
...
...
@@ -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();
...
...
This diff is collapsed.
Click to expand it.
src/tree_node.cpp
+
2
−
2
View file @
97feb47b
...
...
@@ -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_
child
ren
()
+
"; "
;
info_node
+=
"Children = "
+
this
->
get_
pa
ren
ts
()
+
")"
;
info_node
+=
"Parents = "
+
this
->
get_
pa
ren
ts
()
+
"; "
;
info_node
+=
"Children = "
+
this
->
get_
child
ren
()
+
")"
;
return
info_node
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment