LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
|
Exhaustive enumeration of unlabelled rooted trees. More...
#include <all_ulab_rooted_trees.hpp>
Public Member Functions | |
all_ulab_rooted_trees () noexcept | |
Empty constructor. | |
all_ulab_rooted_trees (const uint64_t n) noexcept | |
Constructor with number of nodes. | |
all_ulab_rooted_trees (const all_ulab_rooted_trees &Gen) noexcept=default | |
Copy constructor. | |
all_ulab_rooted_trees (all_ulab_rooted_trees &&Gen) noexcept=default | |
Move constructor. | |
~all_ulab_rooted_trees () noexcept=default | |
Default destructor. | |
all_ulab_rooted_trees & | operator= (const all_ulab_rooted_trees &g) noexcept=default |
Copy assignment operator. | |
all_ulab_rooted_trees & | operator= (all_ulab_rooted_trees &&g) noexcept=default |
Move assignment operator. | |
void | init (const uint64_t n) noexcept |
Initializes the generator with a given number of vertices. | |
void | clear () noexcept |
Clears the memory used. | |
bool | end () const noexcept |
Returns true if the end of the iteration was reached. | |
void | next () noexcept |
Generates the next tree. | |
void | reset () noexcept |
Sets the generator to its initial state. | |
graphs::rooted_tree | yield_tree () noexcept |
Yields a tree, advancing the generator if necessary. | |
graphs::rooted_tree | get_tree () noexcept |
Retrieve the generated tree. | |
void | activate_all_postprocessing_actions () noexcept |
Activates all postprocessing actions. | |
void | deactivate_all_postprocessing_actions () noexcept |
Deactivates all postprocessing actions. | |
void | set_normalize_tree (const bool v) noexcept |
Should trees be normalized? | |
void | set_calculate_size_subtrees (const bool v) noexcept |
Should the size of the subtrees be calculated? | |
void | set_calculate_tree_type (const bool v) noexcept |
Should the tree be classified into types? | |
Protected Member Functions | |
graphs::rooted_tree | __get_tree () noexcept |
Constructs the current tree. | |
void | __reset () noexcept |
Sets the generator to its initial state. | |
Private Attributes | |
bool | m_is_last = false |
Is the current tree the last tree to be generated? | |
bool | m_is_first = false |
Is the current tree the first tree to be generated? | |
bool | m_reached_end = false |
Has the end of the generation been reached? | |
uint64_t | m_p = 0 |
Pointer as in the paper. | |
detail::array< node > | m_save |
Sequence SAVE. | |
detail::array< node > | m_prev |
Sequence PREV. | |
detail::array< node > | m_L |
Level sequence of the tree. | |
Static Private Attributes | |
static constexpr bool | is_free |
Helpful Boolean value to compact 'if constexpr' expressions. | |
Exhaustive enumeration of unlabelled rooted trees.
Generates all the unlabelled rooted trees of a given number of nodes. The algorithm implemented can be found in [14]. The definition of the public and private members of this class follow the notation in this work.
In order to use this class, users must provide the size \(n\) of the tree (number of nodes) in the constructor. Trees are generated internally, i.e., trees are encoded in the internal state of the generator. Said state is updated using method next(), which updates it to encode the next tree in the generation. In order to retrieve the tree, use method get_tree(). Upon initialisation, the generator encodes the first tree, which has to be retrieved using method get_tree().
All the unlabelled rooted trees will have been generated when method end() returns true. At this point, method get_tree() will always construct the last tree in the enumeration, whichever tree it is. In order to restart the generation of these trees, call method reset(). It is allowed to call this method at any time.
A possible usage of this class is the following:
Alternatively, this class can be used in a for loop:
Equivalently,
|
inlinenoexcept |
Constructor with number of nodes.
n | Number of nodes. |
|
defaultnoexcept |
Copy constructor.
Gen | Exhaustive unlabelled rooted tree generator. |
|
defaultnoexcept |
Move constructor.
Gen | Exhaustive unlabelled rooted tree generator. |
|
nodiscardprotectedvirtualnoexcept |
Constructs the current tree.
Implements lal::generate::_tree_generator< graphs::rooted_tree >.
|
inlinenoexceptinherited |
Activates all postprocessing actions.
The full list of postprocessing actions can be found in the documentation of this class.
|
inlinenoexcept |
|
inlinenoexceptinherited |
Deactivates all postprocessing actions.
The full list of postprocessing actions can be found in the documentation of this class.
|
inlinenodiscardnoexceptinherited |
Retrieve the generated tree.
This function first calls __get_tree and then modifies the generated tree according to the values:
|
inlinenoexcept |
Initializes the generator with a given number of vertices.
n | Number of vertices. |
|
noexcept |
Generates the next tree.
Modifies the internal state so that the next tree can be retrieved using method get_tree.
|
inlinenoexcept |
Sets the generator to its initial state.
Postprocessing actions are not modified.
|
inlinenoexceptinherited |
Should the size of the subtrees be calculated?
v | Boolean value. |
|
inlinenoexceptinherited |
Should the tree be classified into types?
See lal::graphs::tree_type for details on the classification.
v | Boolean value. |
|
inlinenoexceptinherited |
Should trees be normalized?
v | Boolean value. |
|
inlinenodiscardvirtualnoexcept |
Yields a tree, advancing the generator if necessary.
In case the class that inherits from this one is exhaustive then this function also moves the generator forward with its appropriate method. If the class is random, then it just calls get_tree().
Implements lal::generate::_tree_generator< graphs::rooted_tree >.