LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
|
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_tree & | m_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? | |
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:
Alternatively, this class can be used in a for loop:
This class also has method yield_arrangement() which is aimed at simplifying this class' usage:
|
noexcept |
Constructor with constant reference to a free tree.
T | Input free tree |
|
noexcept |
Constructor with rooted tree.
This constructor transforms the input rooted tree into a free tree.
T | Input rooted tree |
|
defaultnoexcept |
Default copy constructor.
Gen | Exhaustive planar arrangement generator. |
|
defaultnoexcept |
Default move constructor.
Gen | Exhaustive planar arrangement generator. |
|
inlinenodiscardnoexcept |
Returns whether there are more arrangements to generate.
|
nodiscardnoexcept |
|
noexcept |
Generates the next arrangement.
Modifies the internal state so that the next arrangement can be retrieved using method get_arrangement.
|
inlinenodiscardnoexcept |
Constructs the current arrangement.
|
private |
A copy of a free tree.
Used only when this class is constructed with a rooted tree.