43# ifndef GENERATE_TREE_H
44# define GENERATE_TREE_H
58 return to_str(p->get_key());
69 template <
typename Node,
class Write>
73 const size_t & current_level,
78 <<
"Allocated size for deway array has been exceeded";
82 for (
size_t i = 0; i < current_level; ++i)
86 if (i < current_level - 1)
89 output <<
" \"" <<
Write()(node) <<
"\" " << std::endl;
91 Node *child =
static_cast<Node *
>(node->get_left_child());
92 for (
int i = 0; child !=
nullptr;
93 i++, child =
static_cast<Node *
>(child->get_right_sibling()))
95 deway[current_level + 1] = i;
127 template <
typename Node,
class Write = Dft_Write<Node>>
132 out <<
"Root \"" <<
Write()(
root) <<
"\" " << std::endl;
136 constexpr int level = 0;
140 Node *child =
static_cast<Node *
>(
root->get_left_child());
141 for (
int i = 0; child !=
nullptr;
142 i++, child =
static_cast<Node *
>(child->get_right_sibling()))
173 template <
typename Node,
class Write = Dft_Write<Node>>
178 for (
int i = 0; tree !=
nullptr; i++, tree = tree->get_right_sibling())
206 template <
typename Node,
class Write>
209 out <<
"start-prefix ";
Exception handling system with formatted messages for Aleph-w.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
WeightedDigraph::Node Node
void deway(Tree_Node< int > *p, int prefix[], const int &len, const size_t &dim)
Recursively compute and print Deway numbering for a tree node.
__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)
void generate_btree(Node *root, std::ostream &out)
Generate a binary tree specification for the btreepic drawing tool.
void generate_forest(Node *root, std::ostream &out)
Generate a forest specification for the ntreepic drawing tool.
void generate_tree(Node *root, std::ostream &out, const int &tree_number=0)
Generate a tree specification for the ntreepic drawing tool.
Main namespace for Aleph-w library functions.
constexpr size_t Max_Tree_Node_Depth
size_t size(Node *root) noexcept
std::string to_str(const double d)
Convert double to a std::string with maximum round-trip precision.
static void __generate_tree(Node *node, int deway[], const size_t ¤t_level, const size_t &size, std::ostream &output)
DynList< T > maps(const C &c, Op op)
Classic map operation.
std::string operator()(Node *p)
Utility functions for binary tree operations.
General tree (n-ary tree) node.