LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
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 Types

typedef std::conditional_t< std::is_base_of_v< graphs::free_tree, graphs::rooted_tree >, graphs::free_tree, graphs::rooted_treetree_type_t
 Shorthand for the type of tree this class returns.
 

Public Member Functions

 rand_lab_rooted_trees (uint32_t n, uint32_t seed=0) noexcept
 Constructor with size of tree and seed for the random number generator.
 
 rand_lab_rooted_trees (const rand_lab_rooted_trees &Gen)=default
 Copy constructor.
 
 rand_lab_rooted_trees (rand_lab_rooted_trees &&Gen)=default
 Move constructor.
 
 ~rand_lab_rooted_trees ()=default
 Default destructor.
 
graphs::rooted_tree yield_tree () noexcept
 Yields a tree, advancing the generator if necessary.
 
tree_type_t 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_normalise_tree (bool v) noexcept
 Should trees be normalised?
 
void set_calculate_size_subtrees (bool v) noexcept
 Should the size of the subtrees be calculated?
 
void set_calculate_tree_type (bool v) noexcept
 Should the tree be classified into types?
 

Protected Member Functions

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

Protected Attributes

_rand_lab_rooted_trees m_Gen
 See _rand_lab_rooted_trees for details.
 
const uint32_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:144
Rooted tree graph class.
Definition rooted_tree.hpp:107

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 ( uint32_t n,
uint32_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, std::is_base_of_v<graphs::free_tree, 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, std::is_base_of_v<graphs::free_tree, 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()

tree_type_t lal::generate::_tree_generator< graphs::rooted_tree, std::is_base_of_v<graphs::free_tree, 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.

◆ set_calculate_size_subtrees()

void lal::generate::_tree_generator< graphs::rooted_tree, std::is_base_of_v<graphs::free_tree, 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, std::is_base_of_v<graphs::free_tree, 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, std::is_base_of_v<graphs::free_tree, 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.

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


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