LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
lal::generate::rand_lab_free_trees Class Reference

Uniformly random selection of labelled free trees. More...

#include <rand_lab_free_trees.hpp>

Inheritance diagram for lal::generate::rand_lab_free_trees:
lal::generate::_tree_generator< graphs::free_tree >

Public Member Functions

 rand_lab_free_trees () noexcept
 Empty constructor.
 
 rand_lab_free_trees (const uint64_t n, const uint64_t seed=0) noexcept
 Constructor with size of tree and seed for the random number generator.
 
 rand_lab_free_trees (const rand_lab_free_trees &Gen)=default
 Copy constructor.
 
 rand_lab_free_trees (rand_lab_free_trees &&Gen)=default
 Move constructor.
 
 ~rand_lab_free_trees ()=default
 Default destructor.
 
rand_lab_free_treesoperator= (const rand_lab_free_trees &g) noexcept=default
 Copy assignment operator.
 
rand_lab_free_treesoperator= (rand_lab_free_trees &&g) noexcept=default
 Move assignment operator.
 
void init (const uint64_t n, const uint64_t seed=0) noexcept
 Initializes the generator with the number of nodes and a seed.
 
void clear () noexcept
 Clear the memory used by the generator.
 
graphs::free_tree yield_tree () noexcept
 Yields a tree, advancing the generator if necessary.
 
void init (const uint64_t n) noexcept
 Initializes the tree generator.
 
graphs::free_tree get_tree () noexcept
 Retrieve the generated tree.
 
void activate_all_postprocessing_actions () noexcept
 Activates all postprocessing actions.
 
void deactivate_all_postprocessing_actions () noexcept
 Deactivates all postprocessing actions.
 
void set_normalize_tree (const bool v) noexcept
 Should trees be normalized?
 
void set_calculate_size_subtrees (const bool v) noexcept
 Should the size of the subtrees be calculated?
 
void set_calculate_tree_type (const bool v) noexcept
 Should the tree be classified into types?
 

Protected Member Functions

graphs::free_tree __get_tree () noexcept
 Returns a labelled free tree chosen uniformly at random.
 

Protected Attributes

_rand_lab_free_trees m_Gen
 See _rand_lab_free_trees.
 
uint64_t m_n
 Number of vertices.
 
bool m_normalize_tree
 Normalize the generated tree.
 
bool m_calculate_size_subtrees
 Calculate the size of the subtrees of the generated rooted tree.
 
bool m_calculate_tree_type
 Calculate the type of tree of the generated tree.
 

Static Private Attributes

static constexpr bool is_free
 Helpful Boolean value to compact 'if constexpr' expressions.
 

Detailed Description

Uniformly random selection of labelled free trees.

This is a wrapper class of _rand_lab_free_trees. Users should refrain from using said class. However, users will find the implementation details (as for algorithms and citations) in the documentation of said class.

An example of usage of this class is

for (int i = 0; i < 100; ++i) {
const lal::graphs::free_tree T = Gen.make_rand_tree();
// ...
}
Uniformly random selection of labelled free trees.
Definition rand_lab_free_trees.hpp:178
Free tree graph class.
Definition free_tree.hpp:60

Equivalently,

for (int i = 0; i < 100; ++i) {
const lal::graphs::free_tree T = Gen.yield_tree();
// ...
}

Constructor & Destructor Documentation

◆ rand_lab_free_trees() [1/3]

lal::generate::rand_lab_free_trees::rand_lab_free_trees ( const uint64_t n,
const uint64_t seed = 0 )
inlinenoexcept

Constructor with size of tree and seed for the random number generator.

In case the seed given is '0', a random seed will be generated.

Parameters
nNumber of nodes.
seedThe seed used for the random generator. If the seed is 0 then a random seed is generated and used.

◆ rand_lab_free_trees() [2/3]

lal::generate::rand_lab_free_trees::rand_lab_free_trees ( const rand_lab_free_trees & Gen)
default

Copy constructor.

Parameters
GenRandom labelled free tree generator.

◆ rand_lab_free_trees() [3/3]

lal::generate::rand_lab_free_trees::rand_lab_free_trees ( rand_lab_free_trees && Gen)
default

Move constructor.

Parameters
GenRandom labelled free tree generator.

Member Function Documentation

◆ __get_tree()

graphs::free_tree lal::generate::rand_lab_free_trees::__get_tree ( )
inlinenodiscardprotectedvirtualnoexcept

Returns a labelled free tree chosen uniformly at random.

See _rand_lab_free_trees::get_tree for details.

Returns
A labelled free tree chosen uniformly at random.

Implements lal::generate::_tree_generator< graphs::free_tree >.

◆ activate_all_postprocessing_actions()

void lal::generate::_tree_generator< graphs::free_tree, >::activate_all_postprocessing_actions ( )
inlinenoexceptinherited

Activates all postprocessing actions.

The full list of postprocessing actions can be found in the documentation of this class.

◆ deactivate_all_postprocessing_actions()

void lal::generate::_tree_generator< graphs::free_tree, >::deactivate_all_postprocessing_actions ( )
inlinenoexceptinherited

Deactivates all postprocessing actions.

The full list of postprocessing actions can be found in the documentation of this class.

◆ get_tree()

graphs::free_tree lal::generate::_tree_generator< graphs::free_tree, >::get_tree ( )
inlinenodiscardnoexceptinherited

Retrieve the generated tree.

This function first calls __get_tree and then modifies the generated tree according to the values:

Returns
A free/rooted tree depending on the type of the class inheriting from this. The type of generation of tree differs from one type of class to another.

◆ init()

void lal::generate::rand_lab_free_trees::init ( const uint64_t n,
const uint64_t seed = 0 )
inlinenoexcept

Initializes the generator with the number of nodes and a seed.

Parameters
nNumber of nodes.
seedThe seed used for the random generator. If the seed is 0 then a random seed is generated and used.

◆ set_calculate_size_subtrees()

void lal::generate::_tree_generator< graphs::free_tree, >::set_calculate_size_subtrees ( const bool v)
inlinenoexceptinherited

Should the size of the subtrees be calculated?

Parameters
vBoolean value.

◆ set_calculate_tree_type()

void lal::generate::_tree_generator< graphs::free_tree, >::set_calculate_tree_type ( const bool v)
inlinenoexceptinherited

Should the tree be classified into types?

See lal::graphs::tree_type for details on the classification.

Parameters
vBoolean value.

◆ set_normalize_tree()

void lal::generate::_tree_generator< graphs::free_tree, >::set_normalize_tree ( const bool v)
inlinenoexceptinherited

Should trees be normalized?

Parameters
vBoolean value.

◆ yield_tree()

graphs::free_tree lal::generate::rand_lab_free_trees::yield_tree ( )
inlinenodiscardvirtualnoexcept

Yields a tree, advancing the generator if necessary.

In case the class that inherits from this one is exhaustive then this function also moves the generator forward with its appropriate method. If the class is random, then it just calls get_tree().

Returns
A free/rooted tree depending on the type of the class inheriting from this. The type of generation of tree differs from one type of class to another.
Postcondition
The generator advances to the next tree.

Implements lal::generate::_tree_generator< graphs::free_tree >.


The documentation for this class was generated from the following file: