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

Random generation of arrangements of any graph. More...

#include <rand_arrangements.hpp>

Public Member Functions

 rand_arrangements (const graphs::graph &g, const uint64_t seed=0) noexcept
 Constructor with graph.
 
 rand_arrangements (const rand_arrangements &Gen) noexcept=default
 Default copy constructor.
 
 rand_arrangements (rand_arrangements &&Gen) noexcept=default
 Default move constructor.
 
 rand_arrangements (const uint64_t n, const uint64_t seed=0) noexcept
 Constructor with number of vertices.
 
const linear_arrangementget_arrangement () noexcept
 Returns a linear arrangement constructed uniformly at random.
 
const linear_arrangementyield_arrangement () noexcept
 Returns a linear arrangement constructed uniformly at random.
 

Private Attributes

const uint64_t m_n
 Number of vertices.
 
std::mt19937 m_gen
 Random number generator.
 
linear_arrangement m_arr
 The arrangement generated by this class.
 

Detailed Description

Random generation of arrangements of any graph.

This class generates linear arrangements uniformly at random. Unlike other random generators (e.g., lal::generate::rand_projective_arrangements) the arrangements are not generated from a graph since the graph structure is not required at all.

This class is a simple wrapper over C++'s std::shuffle algorithm.

A possible usage of this class is the following:

// given a tree T (or any other graph)
for (int i = 0; i < 100; ++i) {
const lal::linear_arrangement& arr = Gen.get_arrangement();
// ...
}
Random generation of arrangements of any graph.
Definition rand_arrangements.hpp:83
Linear arrangement of vertices.
Definition linear_arrangement.hpp:103

Equivalently,

// given a tree T (or any other graph)
lal::generate::rand_arrangements Gen(T.get_num_nodes());
for (int i = 0; i < 100; ++i) {
const lal::linear_arrangement& arr = Gen.yield_arrangement();
// ...
}

Constructor & Destructor Documentation

◆ rand_arrangements() [1/4]

lal::generate::rand_arrangements::rand_arrangements ( const graphs::graph & g,
const uint64_t seed = 0 )
inlinenoexcept

Constructor with graph.

Parameters
gInput graph. Only its number of vertices is used.
seedSeed of the random number generator. When 0, a random seed is used.

◆ rand_arrangements() [2/4]

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

Default copy constructor.

Parameters
GenRandom arrangement generator.

◆ rand_arrangements() [3/4]

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

Default move constructor.

Parameters
GenRandom arrangement generator.

◆ rand_arrangements() [4/4]

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

Constructor with number of vertices.

Parameters
nNumber of vertices of the arrangements.
seedSeed of the random number generator. When 0, a random seed is used.

Member Data Documentation

◆ m_arr

linear_arrangement lal::generate::rand_arrangements::m_arr
private

The arrangement generated by this class.

Actually, generated by the std::next_permutation algorithm.


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