|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Generator for uniformly random trees. More...
#include <random_tree.H>
Public Member Functions | |
| RandTree (unsigned long seed) | |
| Construct generator with specified seed. | |
| RandTree () | |
| Construct generator with time-based seed. | |
| ~RandTree () | |
| Destructor releases GSL resources. | |
| Tree_Node< T > * | operator() (size_t n) |
| Generate a random tree with n nodes. | |
Private Member Functions | |
| BinNode< T > * | random (unsigned long n) |
| Recursively generate random binary tree. | |
Private Attributes | |
| gsl_rng * | r = nullptr |
| GSL random number generator. | |
Generator for uniformly random trees.
Uses the GSL Mersenne Twister (MT19937) random number generator to create uniformly distributed random trees with a specified number of nodes.
| T | Type of data stored in tree nodes (not used for generation) |
Definition at line 112 of file random_tree.H.
Construct generator with specified seed.
| seed | Random seed for reproducibility |
| std::bad_alloc | if GSL allocation fails |
Definition at line 143 of file random_tree.H.
References ah_bad_alloc_if, Aleph::maps(), and RandTree< T >::r.
|
inline |
Construct generator with time-based seed.
Uses current time as seed for non-reproducible random trees.
Definition at line 156 of file random_tree.H.
Destructor releases GSL resources.
Definition at line 161 of file random_tree.H.
References Aleph::maps(), and RandTree< T >::r.
Generate a random tree with n nodes.
| n | Number of nodes in the tree (must be > 0) |
Definition at line 184 of file random_tree.H.
References Aleph::bin_to_tree(), Aleph::destroyRec(), l, Aleph::maps(), RandTree< T >::random(), and root().
Recursively generate random binary tree.
| n | Number of nodes in the subtree |
Definition at line 122 of file random_tree.H.
References Aleph::LLINK(), Aleph::maps(), RandTree< T >::r, RandTree< T >::random(), Aleph::RLINK(), and root().
Referenced by RandTree< T >::operator()(), and RandTree< T >::random().
GSL random number generator.
Definition at line 114 of file random_tree.H.
Referenced by RandTree< T >::RandTree(), RandTree< T >::~RandTree(), and RandTree< T >::random().