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

Uniformly random selection of projective arrangements of a rooted tree. More...

#include <rand_projective_arrangements.hpp>

Public Member Functions

 rand_projective_arrangements (const graphs::rooted_tree &rT, const uint64_t seed=0) noexcept
 Constructor with tree.
 
 rand_projective_arrangements (const rand_projective_arrangements &Gen) noexcept=default
 Default copy constructor.
 
 rand_projective_arrangements (rand_projective_arrangements &&Gen) noexcept=default
 Default move constructor.
 
 ~rand_projective_arrangements ()=default
 Default destructor.
 
linear_arrangement get_arrangement () noexcept
 Make a random projective arrangement of a rooted tree.
 
linear_arrangement yield_arrangement () noexcept
 Returns a random projective arrangement.
 

Private Attributes

const graphs::rooted_treem_rT
 The rooted tree of which we are making projective arrangements uniformly at random.
 
detail::array< detail::array< node > > m_rdata
 The random data for all vertices.
 
std::mt19937 m_gen
 Random number generator.
 

Detailed Description

Uniformly random selection of projective arrangements of a rooted tree.

This class does not take into account the symmetries between arrangements produced by swapping leaves of the tree connected to the same parent. That is, the arrangements are select from the can be seen as arrangements of labelled trees. Therefore, this class will select u.a.r. one of the \(n!\) arrangements for a star tree of \(n\) vertices.

See Types of arrangements for the definition of projective arrangements.

An example of usage of this class is

// given a rooted tree T
lal::generate::rand_projective_arrgements Gen(T);
for (int i = 0; i < 100; ++i) {
const lal::linear_arrangement& arr = Gen.get_arrangement();
// ...
}
Linear arrangement of vertices.
Definition linear_arrangement.hpp:103

Equivalently,

// given a rooted tree T
for (int i = 0; i < 100; ++i) {
const lal::linear_arrangement& arr = Gen.yield_arrangement();
// ...
}
Uniformly random selection of projective arrangements of a rooted tree.
Definition rand_projective_arrangements.hpp:86

Constructor & Destructor Documentation

◆ rand_projective_arrangements() [1/3]

lal::generate::rand_projective_arrangements::rand_projective_arrangements ( const graphs::rooted_tree & rT,
const uint64_t seed = 0 )
noexcept

Constructor with tree.

Parameters
rTInput rooted tree
seedThe seed used for the random generator. If the seed is 0 then a random seed is generated and used.
Precondition
The object t must be a rooted tree (see lal::graphs::rooted_tree::is_rooted_tree).

◆ rand_projective_arrangements() [2/3]

lal::generate::rand_projective_arrangements::rand_projective_arrangements ( const rand_projective_arrangements & Gen)
defaultnoexcept

Default copy constructor.

Parameters
GenRandom projective arrangement generator.

◆ rand_projective_arrangements() [3/3]

lal::generate::rand_projective_arrangements::rand_projective_arrangements ( rand_projective_arrangements && Gen)
defaultnoexcept

Default move constructor.

Parameters
GenRandom projective arrangement generator.

Member Function Documentation

◆ get_arrangement()

linear_arrangement lal::generate::rand_projective_arrangements::get_arrangement ( )
nodiscardnoexcept

Make a random projective arrangement of a rooted tree.

Returns
A projective arrangement chosen uniformly at random chosen amongst all projective arrangements of t.

Member Data Documentation

◆ m_rdata

detail::array<detail::array<node> > lal::generate::rand_projective_arrangements::m_rdata
private

The random data for all vertices.

This is a member of the class to avoid its initialisation at every call to get_arrangement.


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