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::_rand_lab_free_trees

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 get_tree () noexcept
 Generates uniformly at random a labelled rooted tree.
 

Protected Member Functions

void init (uint32_t seed=0) noexcept
 Sets the size of the labelled trees to generate.
 

Protected Attributes

const uint32_t m_n
 Number of nodes of the tree.
 
std::mt19937 m_gen
 Random number generator.
 
std::uniform_int_distribution< uint32_t > m_unif
 Distribution of the numbers.
 
internal::data_array< uint32_t > m_Prufer_seq
 Prüfer sequence.
 

Detailed Description

Uniformly random generation of labelled rooted trees.

Users should refrain from using this class. The generation of random labelled trees should be done using the wrapper class rand_lab_rooted_trees. This class, however, contains the actual code to generate labelled rooted trees uniformly at random.

These trees are generated by first generating uniformly at random a free labelled tree. Then, a node of the generated tree is chosen uniformly at random. This node plays the role of the root of the rooted labelled tree. The edges are oriented away from the root.

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.

◆ _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 ( )
inlinenoexcept

Generates uniformly at random a labelled rooted tree.

Returns
A labelled tree generated uniformly at random. The tree is rooted at vertex 0.

◆ init()

void lal::generate::_rand_lab_rooted_trees::init ( uint32_t seed = 0)
inlineprotectednoexcept

Sets the size of the labelled trees to generate.

Initialises the random number generator.

Parameters
seedInteger value used to seed the random number generator.

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