LAL: Linear Arrangement Library 23.01.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lal::generate::rand_lab_rooted_trees Class Reference

Uniformly random generation of labelled rooted trees. More...

#include <rand_lab_rooted_trees.hpp>

Inheritance diagram for lal::generate::rand_lab_rooted_trees:
lal::generate::_tree_generator< graphs::rooted_tree >

Public Member Functions

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

Protected Member Functions

graphs::rooted_tree __get_tree () noexcept
 Returns a labelled rooted tree chosen uniformly at random. More...
 

Protected Attributes

_rand_lab_rooted_trees m_Gen
 See _rand_lab_rooted_trees for details.
 
uint64_t m_n
 Number of vertices.
 
bool m_normalise_tree
 Normalise 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.
 

Detailed Description

Uniformly random generation of labelled rooted trees.

This is a wrapper class of _rand_lab_rooted_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::rooted_tree T = Gen.get_tree();
// ...
}
Uniformly random generation of labelled rooted trees.
Definition: rand_lab_rooted_trees.hpp:153
Rooted tree graph class.
Definition: rooted_tree.hpp:103

Equivalently,

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

Constructor & Destructor Documentation

◆ rand_lab_rooted_trees() [1/3]

lal::generate::rand_lab_rooted_trees::rand_lab_rooted_trees ( uint64_t  n,
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_rooted_trees() [2/3]

lal::generate::rand_lab_rooted_trees::rand_lab_rooted_trees ( const rand_lab_rooted_trees Gen)
default

Copy constructor.

Parameters
GenRandom labelled rooted tree generator.

◆ rand_lab_rooted_trees() [3/3]

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

Move constructor.

Parameters
GenRandom labelled rooted tree generator.

Member Function Documentation

◆ __get_tree()

graphs::rooted_tree lal::generate::rand_lab_rooted_trees::__get_tree ( )
inlineprotectedvirtualnoexcept

Returns a labelled rooted tree chosen uniformly at random.

See _rand_lab_rooted_trees::get_tree for details.

Returns
A labelled rooted tree chosen uniformly at random.

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

◆ activate_all_postprocessing_actions()

void lal::generate::_tree_generator< graphs::rooted_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::rooted_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::rooted_tree lal::generate::_tree_generator< graphs::rooted_tree , >::get_tree ( )
inlinenoexceptinherited

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_rooted_trees::init ( uint64_t  n,
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::rooted_tree , >::set_calculate_size_subtrees ( bool  v)
inlinenoexceptinherited

Should the size of the subtrees be calculated?

Parameters
vBoolean value.

◆ set_calculate_tree_type()

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

Should the tree be classified into types?

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

Parameters
vBoolean value.

◆ set_normalise_tree()

void lal::generate::_tree_generator< graphs::rooted_tree , >::set_normalise_tree ( bool  v)
inlinenoexceptinherited

Should trees be normalised?

Parameters
vBoolean value.

◆ yield_tree()

graphs::rooted_tree lal::generate::rand_lab_rooted_trees::yield_tree ( )
inlinevirtualnoexcept

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::rooted_tree >.


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