47 cout <<
" [" << index <<
"] " << string(2 * level,
' ') << node->
get_data() <<
'\n';
52 auto *child =
new Node(name);
53 parent->insert_rightmost_child(child);
59 for (
Node *child = node->get_left_child(); child !=
nullptr;
60 child = child->get_right_sibling())
62 const bool is_last = child->get_right_sibling() ==
nullptr;
63 cout <<
prefix << (is_last ?
"`-- " :
"|-- ") << child->get_data() <<
'\n';
70 cout <<
root->get_data() <<
'\n';
82 cout << string(2 * level,
' ') <<
dewey <<
" " << node->get_data() <<
'\n';
84 size_t child_index = 0;
85 for (
Node *child = node->get_left_child(); child !=
nullptr;
86 child = child->get_right_sibling(), ++child_index)
113 cout <<
"Aleph-w data-structure tree\n"
114 <<
"===========================\n";
117 cout <<
"\nDewey-numbered view\n"
118 <<
"--------------------\n";
121 cout <<
"\nPreorder traversal\n";
124 cout <<
"\nPostorder traversal\n";
130 cout <<
"\nDewey path 0.1.0.2 points to: " <<
treap->get_data() <<
'\n';
134 cout <<
"Clone verification: passed\n";
Exception handling system with formatted messages for Aleph-w.
WeightedDigraph::Node Node
Forward declaration used by CRTP helpers before the full node definition.
T & get_data() noexcept
Returns a modifiable reference to the node contents.
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
void destroy_tree(Node *root)
Destroys (frees memory) the tree whose root is root.
void tree_postorder_traversal(Node *root, void(*visitFct)(Node *, int, int))
Postorder traversal of a tree.
bool are_tree_equal(Node *t1, Node *t2, Eq &eq)
Returns true if t1 is equal to t2.
void tree_preorder_traversal(Node *root, void(*visitFct)(Node *, int, int))
Preorder traversal of a tree.
Node * deway_search(Node *root, int path[], const size_t &size)
Returns a node of a forest given its Dewey number.
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
static void prefix(Node *root, DynList< Node * > &acc)
static void clone_tree(Node *src, Node *tgt)
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
static void print_dewey_view(Node *node, const string &dewey, size_t level)
Print every node with its Dewey number and depth indentation.
static Node * append_child(Node *parent, const string &name)
static void draw_children(Node *node, const string &prefix)
static void print_node(Node *node, int level, int index)
static void draw_tree(Node *root)
Lazy and scalable dynamic array implementation.
General tree (n-ary tree) node.