48#include <lal/graphs/rooted_tree.hpp>
49#include <lal/generate/tree_generator.hpp>
50#include <lal/numeric/integer.hpp>
51#include <lal/detail/data_array.hpp>
126 void init(uint64_t n, uint64_t seed = 0) noexcept {
131 if (
m_n <= 1) {
return; }
135 std::random_device rd;
136 m_gen = std::mt19937(rd());
139 m_gen = std::mt19937(seed);
141 m_unif = std::uniform_real_distribution<double>(0, 1);
191 std::uniform_real_distribution<
double>
m_unif;
198 std::vector<numeric::integer>
m_rn;
225 (uint64_t n, uint64_t lr, uint64_t nt) noexcept;
231 std::vector<numeric::integer>{
354 void init(uint64_t n, uint64_t seed = 0) noexcept {
Uniformly random generation of unlabelled rooted trees.
Definition: rand_ulab_rooted_trees.hpp:67
void init_rn() noexcept
Initialiases m_rn with values from the OEIS (see ).
Definition: rand_ulab_rooted_trees.hpp:228
_rand_ulab_rooted_trees(const _rand_ulab_rooted_trees &Gen)=default
Copy constructor.
std::pair< uint64_t, uint64_t > ranrut(uint64_t n, uint64_t lr, uint64_t nt) noexcept
Generates uniformly at random a rooted unlabelled tree of n nodes.
virtual ~_rand_ulab_rooted_trees()=default
Destructor.
_rand_ulab_rooted_trees & operator=(const _rand_ulab_rooted_trees &g) noexcept=default
Copy assignment operator.
void init(uint64_t n, uint64_t seed=0) noexcept
Sets the size of the unlabelled trees to generate.
Definition: rand_ulab_rooted_trees.hpp:126
_rand_ulab_rooted_trees() noexcept
Empty constructor.
Definition: rand_ulab_rooted_trees.hpp:72
std::vector< numeric::integer > m_rn
The number of unlabelled rooted trees.
Definition: rand_ulab_rooted_trees.hpp:198
_rand_ulab_rooted_trees(uint64_t n, uint64_t seed=0) noexcept
Constructor with size of tree and seed for the random number generator.
Definition: rand_ulab_rooted_trees.hpp:85
const numeric::integer & get_rn(uint64_t n) noexcept
Computes all the values for .
std::pair< uint64_t, uint64_t > choose_jd_from_T(uint64_t n) noexcept
Chooses uniformly at random a pair , according to some probability.
_rand_ulab_rooted_trees(_rand_ulab_rooted_trees &&Gen)=default
Move constructor.
std::mt19937 m_gen
Random number generator.
Definition: rand_ulab_rooted_trees.hpp:189
graphs::rooted_tree get_tree() noexcept
Generates uniformly at random a free unlabelled tree.
std::uniform_real_distribution< double > m_unif
Distribution of the numbers.
Definition: rand_ulab_rooted_trees.hpp:191
uint64_t m_n
Number of nodes of the tree.
Definition: rand_ulab_rooted_trees.hpp:186
detail::data_array< uint64_t > m_head_vector
The head vector of the tree under construction.
Definition: rand_ulab_rooted_trees.hpp:209
void clear() noexcept
Clears the memory used.
Definition: rand_ulab_rooted_trees.hpp:166
Base class for tree generators.
Definition: tree_generator.hpp:123
void init(uint64_t n) noexcept
Initializes the tree generator.
Definition: tree_generator.hpp:159
void clear() noexcept
Clears the memory used by the generator.
Definition: tree_generator.hpp:165
graphs::rooted_tree get_tree() noexcept
Retrieve the generated tree.
Definition: tree_generator.hpp:195
Uniformly random generation of unlabelled rooted trees.
Definition: rand_ulab_rooted_trees.hpp:311
graphs::rooted_tree yield_tree() noexcept
Yields a tree, advancing the generator if necessary.
Definition: rand_ulab_rooted_trees.hpp:365
void init(uint64_t n, uint64_t seed=0) noexcept
Initialise the generator.
Definition: rand_ulab_rooted_trees.hpp:354
rand_ulab_rooted_trees(uint64_t n, uint64_t seed=0) noexcept
Constructor with size of tree and seed for the random number generator.
Definition: rand_ulab_rooted_trees.hpp:326
rand_ulab_rooted_trees(rand_ulab_rooted_trees &&Gen)=default
Move constructor.
~rand_ulab_rooted_trees() noexcept=default
Default destructor.
rand_ulab_rooted_trees(const rand_ulab_rooted_trees &Gen)=default
Copy constructor.
void clear() noexcept
Clear the memory used by the generator.
Definition: rand_ulab_rooted_trees.hpp:360
graphs::rooted_tree __get_tree() noexcept
Returns an unlabelled rooted tree chosen uniformly at random.
Definition: rand_ulab_rooted_trees.hpp:376
_rand_ulab_rooted_trees m_Gen
See _rand_ulab_rooted_trees for details.
Definition: rand_ulab_rooted_trees.hpp:380
rand_ulab_rooted_trees() noexcept
Empty constructor.
Definition: rand_ulab_rooted_trees.hpp:316
Rooted tree graph class.
Definition: rooted_tree.hpp:103
Arbitrary precision integer.
Definition: integer.hpp:60
Main namespace of the library.
Definition: basic_types.hpp:50
void resize(std::size_t new_size) noexcept
Resize the array.
Definition: data_array.hpp:175
void clear() noexcept
Clear the contents of the array.
Definition: data_array.hpp:162