|
Aleph-w 7.10.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 (const RandTree &)=delete | |
| Not copyable: a copy compiled, and both freed the same generator. | |
| RandTree & | operator= (const RandTree &)=delete |
| Not assignable, as it is not copyable. | |
| 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_Compatible_Rng_Owner | r |
| The generator, in dynamic memory. | |
Generator for uniformly random trees.
Uses a Gsl_Compatible_Rng, the Mersenne Twister (MT19937) with the numbers of GSL, 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 115 of file random_tree.H.
|
inline |
Construct generator with specified seed.
| seed | Random seed for reproducibility |
| std::bad_alloc | if there is not enough memory for the generator |
Definition at line 146 of file random_tree.H.
|
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.
Not copyable: a copy compiled, and both freed the same generator.
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(), Aleph::BinNode< Key >::getL(), l, RandTree< T >::random(), and root().
Not assignable, as it is not copyable.
Recursively generate random binary tree.
| n | Number of nodes in the subtree |
Definition at line 125 of file random_tree.H.
References LLINK, RandTree< T >::r, RandTree< T >::random(), RLINK, root(), and Aleph::Gsl_Compatible_Rng::uniform_int().
Referenced by RandTree< T >::operator()(), and RandTree< T >::random().
|
private |
The generator, in dynamic memory.
Definition at line 117 of file random_tree.H.
Referenced by RandTree< T >::random().