49#include <lal/graphs/rooted_tree.hpp>
50#include <lal/generate/tree_generator.hpp>
51#include <lal/numeric/integer.hpp>
52#include <lal/detail/array.hpp>
127 void init(
const uint64_t n,
const uint64_t seed = 0) noexcept {
132 if (
m_n <= 1) {
return; }
136 std::random_device rd;
137 m_gen = std::mt19937(rd());
140 m_gen = std::mt19937(seed);
142 m_unif = std::uniform_real_distribution<double>(0, 1);
192 std::uniform_real_distribution<
double>
m_unif;
199 std::vector<numeric::integer>
m_rn;
236 [[nodiscard]] std::pair<uint64_t,uint64_t>
ranrut
248 std::vector<numeric::integer>{
285 for (uint64_t n = 1; n <
m_rn.size(); ++n) {
300 [[nodiscard]]
bool has_rn(
const uint64_t n)
const noexcept {
return m_rn.size() >= n + 1; }
382 void init(const uint64_t n, const uint64_t seed = 0) noexcept {
Uniformly random selection of unlabelled rooted trees.
Definition rand_ulab_rooted_trees.hpp:68
void init(const uint64_t n, const uint64_t seed=0) noexcept
Sets the size of the unlabelled trees to generate.
Definition rand_ulab_rooted_trees.hpp:127
head_vector m_head_vector
The head vector of the tree under construction.
Definition rand_ulab_rooted_trees.hpp:221
void init_rn() noexcept
Initialiases m_rn with values from the OEIS (see OEIS_A000081).
Definition rand_ulab_rooted_trees.hpp:245
_rand_ulab_rooted_trees(const _rand_ulab_rooted_trees &Gen)=default
Copy constructor.
virtual ~_rand_ulab_rooted_trees()=default
Destructor.
_rand_ulab_rooted_trees(const uint64_t n, const uint64_t seed=0) noexcept
Constructor with size of tree and seed for the random number generator.
Definition rand_ulab_rooted_trees.hpp:86
_rand_ulab_rooted_trees & operator=(const _rand_ulab_rooted_trees &g) noexcept=default
Copy assignment operator.
std::pair< uint64_t, uint64_t > choose_jd_from_T(const uint64_t n) noexcept
Chooses uniformly at random a pair , according to some probability.
_rand_ulab_rooted_trees() noexcept
Empty constructor.
Definition rand_ulab_rooted_trees.hpp:73
std::vector< numeric::integer > m_rn
The number of unlabelled rooted trees.
Definition rand_ulab_rooted_trees.hpp:199
std::pair< uint64_t, uint64_t > ranrut(const uint64_t n, const uint64_t lr, uint64_t nt) noexcept
Generates uniformly at random a rooted unlabelled tree of n nodes.
bool has_rn(const uint64_t n) const noexcept
Returns whether or not the value (m_rn) has been computed.
Definition rand_ulab_rooted_trees.hpp:300
_rand_ulab_rooted_trees(_rand_ulab_rooted_trees &&Gen)=default
Move constructor.
std::vector< numeric::integer > m_rn_times_n
The number of unlabelled rooted trees times number of vertices.
Definition rand_ulab_rooted_trees.hpp:206
std::mt19937 m_gen
Random number generator.
Definition rand_ulab_rooted_trees.hpp:190
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:192
std::vector< numeric::integer > m_rn_times_n_minus_1
The number of unlabelled rooted trees times number of vertices minus 1.
Definition rand_ulab_rooted_trees.hpp:212
const numeric::integer & get_rn(const uint64_t n) noexcept
Computes all the values for .
uint64_t m_n
Number of nodes of the tree.
Definition rand_ulab_rooted_trees.hpp:187
void clear() noexcept
Clears the memory used.
Definition rand_ulab_rooted_trees.hpp:167
Base class for tree generators.
Definition tree_generator.hpp:123
void clear() noexcept
Clears the memory used by the generator.
Definition tree_generator.hpp:166
void init(const uint64_t n) noexcept
Initializes the tree generator.
Definition tree_generator.hpp:160
graphs::rooted_tree get_tree() noexcept
Definition tree_generator.hpp:196
Uniformly random selection of unlabelled rooted trees.
Definition rand_ulab_rooted_trees.hpp:339
rand_ulab_rooted_trees(const uint64_t n, const uint64_t seed=0) noexcept
Constructor with size of tree and seed for the random number generator.
Definition rand_ulab_rooted_trees.hpp:354
graphs::rooted_tree yield_tree() noexcept
Yields a tree, advancing the generator if necessary.
Definition rand_ulab_rooted_trees.hpp:393
~rand_ulab_rooted_trees() noexcept=default
Default destructor.
rand_ulab_rooted_trees(rand_ulab_rooted_trees &&Gen) noexcept=default
Move constructor.
void clear() noexcept
Clear the memory used by the generator.
Definition rand_ulab_rooted_trees.hpp:388
void init(const uint64_t n, const uint64_t seed=0) noexcept
Initialize the generator.
Definition rand_ulab_rooted_trees.hpp:382
graphs::rooted_tree __get_tree() noexcept
Returns an unlabelled rooted tree chosen uniformly at random.
Definition rand_ulab_rooted_trees.hpp:404
rand_ulab_rooted_trees(const rand_ulab_rooted_trees &Gen) noexcept=default
Copy constructor.
_rand_ulab_rooted_trees m_Gen
See _rand_ulab_rooted_trees for details.
Definition rand_ulab_rooted_trees.hpp:408
rand_ulab_rooted_trees() noexcept
Empty constructor.
Definition rand_ulab_rooted_trees.hpp:344
Rooted tree graph class.
Definition rooted_tree.hpp:109
Arbitrary precision integer.
Definition integer.hpp:60
Main namespace of the library.
Definition basic_types.hpp:48
std::vector< uint64_t > head_vector
See Head vector page for further details.
Definition basic_types.hpp:58