LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
|
Base class for tree generators. More...
#include <tree_generator.hpp>
Public Member Functions | |
_tree_generator () noexcept=default | |
Default constructor. | |
_tree_generator (const uint64_t n) noexcept | |
Constructor with number of nodes. | |
_tree_generator (const _tree_generator &Gen) noexcept=default | |
Default copy constructor. | |
_tree_generator (_tree_generator &&Gen) noexcept=default | |
Default move constructor. | |
virtual | ~_tree_generator () noexcept=default |
Default destructor. | |
void | init (const uint64_t n) noexcept |
Initializes the tree generator. | |
void | clear () noexcept |
Clears the memory used by the generator. | |
_tree_generator & | operator= (const _tree_generator &Gen)=default |
Default copy assignment operator. | |
_tree_generator & | operator= (_tree_generator &&Gen)=default |
Default move assignment operator. | |
tree_t | get_tree () noexcept |
Retrieve the generated tree. | |
virtual tree_t | yield_tree () noexcept=0 |
Yields a tree, advancing the generator if necessary. | |
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 | |
virtual tree_t | __get_tree () noexcept=0 |
Retrieve the generated tree. | |
Static Private Attributes | |
static constexpr bool | is_free = std::is_base_of_v<graphs::free_tree, tree_t> |
Helpful Boolean value to compact 'if constexpr' expressions. | |
Base class for tree generators.
This class is simply a helper for postprocessing a generated tree. The postprocessing actions applied to the tree depends on whether said tree is a rooted tree or a free tree.
The list of methods that govern postprocessing actions are:
Users can deactivate all postprocessing actions with deactivate_all_postprocessing_actions and activate all of them with activate_all_postprocessing_actions.
There are two types of classes inheriting from this base class. The exhaustive classes, and the random classes. The former provide an exhaustive enumeration of a given type of trees ( \(\{\text{labeled}/\text{unlabeled}\} \times \{\text{rooted}/\text{free}\}\)); the latter generate a given type of tree (the aforementioned four combinations), uniformly at random.
The names of the classes inheriting from this follow one very simple pattern. This is explained in the documentation of the lal::generate namespace (or, if you are a Python user, lal.generate module).
The exhaustive classes have three different usages:
Random classes are a bit simpler to use, with, basically, two different usages:
tree_t | Type of tree. |
|
inlinenoexcept |
Constructor with number of nodes.
n | Number of nodes |
|
defaultnoexcept |
Default copy constructor.
Gen | Generator of the same type. |
|
defaultnoexcept |
Default move constructor.
Gen | Generator of the same type. |
|
nodiscardprotectedpure virtualnoexcept |
Retrieve the generated tree.
See the documentation of each child class to see the correct usage of this method.
Implemented in lal::generate::all_lab_free_trees, lal::generate::all_lab_rooted_trees, lal::generate::all_ulab_free_bistar_trees, lal::generate::all_ulab_free_trees, lal::generate::all_ulab_rooted_trees, lal::generate::rand_lab_free_trees, lal::generate::rand_lab_rooted_trees, lal::generate::rand_ulab_free_trees, and lal::generate::rand_ulab_rooted_trees.
|
inlinenoexcept |
Activates all postprocessing actions.
The full list of postprocessing actions can be found in the documentation of this class.
|
inlinenoexcept |
Deactivates all postprocessing actions.
The full list of postprocessing actions can be found in the documentation of this class.
|
inlinenodiscardnoexcept |
Retrieve the generated tree.
This function first calls __get_tree and then modifies the generated tree according to the values:
|
default |
Default move assignment operator.
Gen | Generator of the same type. |
|
default |
Default copy assignment operator.
Gen | Generator of the same type. |
|
inlinenoexcept |
Should the size of the subtrees be calculated?
v | Boolean value. |
|
inlinenoexcept |
Should the tree be classified into types?
See lal::graphs::tree_type for details on the classification.
v | Boolean value. |
|
inlinenoexcept |
Should trees be normalized?
v | Boolean value. |
|
nodiscardpure virtualnoexcept |
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().
Implemented in lal::generate::all_lab_free_trees, lal::generate::all_lab_rooted_trees, lal::generate::all_ulab_free_bistar_trees, lal::generate::all_ulab_free_trees, lal::generate::all_ulab_rooted_trees, lal::generate::rand_lab_free_trees, lal::generate::rand_lab_rooted_trees, lal::generate::rand_ulab_free_trees, and lal::generate::rand_ulab_rooted_trees.