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

Exhaustive enumeration of planar arrangements of a free tree. More...

#include <all_planar_arrangements.hpp>

Public Member Functions

 all_planar_arrangements (const graphs::free_tree &T) noexcept
 Constructor with constant reference to a free tree.
 
 all_planar_arrangements (const graphs::rooted_tree &T) noexcept
 Constructor with rooted tree.
 
 all_planar_arrangements (const all_planar_arrangements &Gen) noexcept=default
 Default copy constructor.
 
 all_planar_arrangements (all_planar_arrangements &&Gen) noexcept=default
 Default move constructor.
 
 ~all_planar_arrangements () noexcept=default
 Default destructor.
 
bool end () const noexcept
 Returns whether there are more arrangements to generate.
 
linear_arrangement get_arrangement () const noexcept
 Constructs the current arrangement.
 
void next () noexcept
 Generates the next arrangement.
 
void reset () noexcept
 Sets the generator to its initial state.
 
linear_arrangement yield_arrangement () noexcept
 Constructs the current arrangement.
 

Private Member Functions

void initialize_intervals_tree () noexcept
 Initiales the interval of every node of the tree.
 
void initialize_interval_node (const node v, const node parent) noexcept
 Initialize the interval of node v, whose parent vertex is parent.
 

Private Attributes

graphs::free_tree m_T_copy
 A copy of a free tree.
 
const graphs::free_treem_T
 Constant reference to free tree.
 
node m_root
 Vertex at which we root the tree.
 
detail::array< std::vector< node > > m_intervals
 The interval of every node of the tree.
 
detail::array< char > m_memory_bit_sort
 Array for the bit sort algorithm.
 
bool m_reached_end = false
 Has the end of the generation been reached?
 

Detailed Description

Exhaustive enumeration of planar arrangements of a free tree.

The arrangements generated do not take into account the symmetrical arrangements produced by swapping leaves of the tree connected to the same vertex. That is, the arrangements produced can be seen as arrangements of labelled trees. Therefore, this class will generate \(n!\) arrangements for a star tree of \(n\) vertices.

In order to use this class, you must first provide the tree object in the constructor. Arrangements are generated internally, i.e., they are encoded in the internal state of the generator. Said state is updated using method next(), which updates it to encode the next arrangement in the generation. In order to retrieve an arrangement, use method get_arrangement(). Upon initialisation, the generator encodes the first arrangement, which has to be retrieved using method get_arrangement().

This class implements the algorithm in [4].

A possible usage of this class is the following:

lal::generate::all_planar_arrangements Gen(t); // t is a free tree
while (not Gen.end()) {
const lal::linear_arrangement& arr = Gen.get_arrangement();
// ...
Gen.next();
}
Exhaustive enumeration of planar arrangements of a free tree.
Definition all_planar_arrangements.hpp:101
Linear arrangement of vertices.
Definition linear_arrangement.hpp:103

Alternatively, this class can be used in a for loop:

for (lal::generate::all_planar_arrangements Gen(t); not Gen.end(); Gen.next()) {
const lal::linear_arrangement& arr = Gen.get_arrangement();
// ...
}
bool end() const noexcept
Returns whether there are more arrangements to generate.
Definition all_planar_arrangements.hpp:139

This class also has method yield_arrangement() which is aimed at simplifying this class' usage:

lal::generate::all_planar_arrangements Gen(t); // t is a free tree
while (not Gen.end()) {
const lal::linear_arrangement& arr = Gen.yield_arrangement();
// ...
}

Constructor & Destructor Documentation

◆ all_planar_arrangements() [1/4]

lal::generate::all_planar_arrangements::all_planar_arrangements ( const graphs::free_tree & T)
noexcept

Constructor with constant reference to a free tree.

Parameters
TInput free tree
Precondition
The object T is a valid tree (see lal::graphs::free_tree::is_tree).

◆ all_planar_arrangements() [2/4]

lal::generate::all_planar_arrangements::all_planar_arrangements ( const graphs::rooted_tree & T)
noexcept

Constructor with rooted tree.

This constructor transforms the input rooted tree into a free tree.

Parameters
TInput rooted tree
Precondition
The object T is a valid tree (see lal::graphs::rooted_tree::is_tree).

◆ all_planar_arrangements() [3/4]

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

Default copy constructor.

Parameters
GenExhaustive planar arrangement generator.

◆ all_planar_arrangements() [4/4]

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

Default move constructor.

Parameters
GenExhaustive planar arrangement generator.

Member Function Documentation

◆ end()

bool lal::generate::all_planar_arrangements::end ( ) const
inlinenodiscardnoexcept

Returns whether there are more arrangements to generate.

Returns
True if there are still more arrangements to generate. Returns false if all arrangements have been generated.

◆ get_arrangement()

linear_arrangement lal::generate::all_planar_arrangements::get_arrangement ( ) const
nodiscardnoexcept

Constructs the current arrangement.

Returns
Returns the arrangement generated with method next().
Precondition
Method next must have been called at least once.

◆ next()

void lal::generate::all_planar_arrangements::next ( )
noexcept

Generates the next arrangement.

Modifies the internal state so that the next arrangement can be retrieved using method get_arrangement.

◆ yield_arrangement()

linear_arrangement lal::generate::all_planar_arrangements::yield_arrangement ( )
inlinenodiscardnoexcept

Constructs the current arrangement.

Returns
The current arrangement.
Postcondition
This generator is moved to the next arrangement.

Member Data Documentation

◆ m_T_copy

graphs::free_tree lal::generate::all_planar_arrangements::m_T_copy
private

A copy of a free tree.

Used only when this class is constructed with a rooted tree.


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