LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
lal::generate::_tree_generator< tree_type, is_free, > Class Template Referenceabstract

Base class for tree generators. More...

#include <tree_generator.hpp>

Public Types

typedef std::conditional_t< is_free, graphs::free_tree, graphs::rooted_treetree_type_t
 Shorthand for the type of tree this class returns.
 

Public Member Functions

 _tree_generator (uint32_t n) noexcept
 Constructor with number of nodes.
 
 _tree_generator (const _tree_generator &Gen)=default
 Default copy constructor.
 
 _tree_generator (_tree_generator &&Gen)=default
 Default move constructor.
 
virtual ~_tree_generator ()=default
 Default destructor.
 
_tree_generatoroperator= (const _tree_generator &Gen)=default
 Default copy assignment operator.
 
_tree_generatoroperator= (_tree_generator &&Gen)=default
 Default move assignment operator.
 
tree_type_t get_tree () noexcept
 Retrieve the generated tree.
 
virtual tree_type_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_normalise_tree (bool v) noexcept
 Should trees be normalised?
 
void set_calculate_size_subtrees (bool v) noexcept
 Should the size of the subtrees be calculated?
 
void set_calculate_tree_type (bool v) noexcept
 Should the tree be classified into types?
 

Protected Member Functions

virtual tree_type_t __get_tree () noexcept=0
 Retrieve the generated tree.
 

Protected Attributes

const uint32_t m_n
 Number of vertices.
 
bool m_normalise_tree = true
 Normalise the generated tree.
 
bool m_calculate_size_subtrees = true
 Calculate the size of the subtrees of the generated rooted tree.
 
bool m_calculate_tree_type = true
 Calculate the type of tree of the generated tree.
 

Detailed Description

template<class tree_type, bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
class lal::generate::_tree_generator< tree_type, is_free, >

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:

lal::generate::all_2_3_trees Gen(10);
while (not Gen.end()) {
const auto T = Gen.get_tree();
// ...
Gen.next();
}
for (lal::generate::all_2_3_trees Gen(10); not Gen.end(); Gen.next()) {
const auto T = Gen.get_tree();
// ...
}
lal::generate::all_2_3_trees Gen(10);
while (not Gen.end()) {
const auto T = Gen.yield_tree();
// ...
}

Random classes are a bit simpler to use, with, basically, two different usages:

lal::generate::rand_2_3_trees Gen(10);
for (int i = 0; i < N; ++i) {
const auto T = Gen.get_tree();
// ...
}
lal::generate::rand_2_3_trees Gen(10);
for (int i = 0; i < N; ++i) {
const auto T = Gen.yield_tree();
// ...
}
Template Parameters
TType of tree.

Constructor & Destructor Documentation

◆ _tree_generator() [1/3]

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
lal::generate::_tree_generator< tree_type, is_free, >::_tree_generator ( uint32_t n)
inlinenoexcept

Constructor with number of nodes.

Parameters
nNumber of nodes

◆ _tree_generator() [2/3]

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
lal::generate::_tree_generator< tree_type, is_free, >::_tree_generator ( const _tree_generator< tree_type, is_free, > & Gen)
default

Default copy constructor.

Parameters
GenGenerator of the same type.

◆ _tree_generator() [3/3]

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
lal::generate::_tree_generator< tree_type, is_free, >::_tree_generator ( _tree_generator< tree_type, is_free, > && Gen)
default

Default move constructor.

Parameters
GenGenerator of the same type.

Member Function Documentation

◆ __get_tree()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
virtual tree_type_t lal::generate::_tree_generator< tree_type, is_free, >::__get_tree ( )
protectedpure virtualnoexcept

◆ activate_all_postprocessing_actions()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
void lal::generate::_tree_generator< tree_type, is_free, >::activate_all_postprocessing_actions ( )
inlinenoexcept

Activates all postprocessing actions.

The full list of postprocessing actions can be found in the documentation of this class.

◆ deactivate_all_postprocessing_actions()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
void lal::generate::_tree_generator< tree_type, is_free, >::deactivate_all_postprocessing_actions ( )
inlinenoexcept

Deactivates all postprocessing actions.

The full list of postprocessing actions can be found in the documentation of this class.

◆ get_tree()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
tree_type_t lal::generate::_tree_generator< tree_type, is_free, >::get_tree ( )
inlinenoexcept

Retrieve the generated tree.

This function first calls __get_tree and then modifies the generated tree according to the values:

Returns
A free/rooted tree depending on the type of the class inheriting from this. The type of generation of tree differs from one type of class to another.

◆ operator=() [1/2]

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
_tree_generator & lal::generate::_tree_generator< tree_type, is_free, >::operator= ( _tree_generator< tree_type, is_free, > && Gen)
default

Default move assignment operator.

Parameters
GenGenerator of the same type.

◆ operator=() [2/2]

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
_tree_generator & lal::generate::_tree_generator< tree_type, is_free, >::operator= ( const _tree_generator< tree_type, is_free, > & Gen)
default

Default copy assignment operator.

Parameters
GenGenerator of the same type.

◆ set_calculate_size_subtrees()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
void lal::generate::_tree_generator< tree_type, is_free, >::set_calculate_size_subtrees ( bool v)
inlinenoexcept

Should the size of the subtrees be calculated?

Parameters
vBoolean value.

◆ set_calculate_tree_type()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
void lal::generate::_tree_generator< tree_type, is_free, >::set_calculate_tree_type ( bool v)
inlinenoexcept

Should the tree be classified into types?

See lal::graphs::tree_type for details on the classification.

Parameters
vBoolean value.

◆ set_normalise_tree()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
void lal::generate::_tree_generator< tree_type, is_free, >::set_normalise_tree ( bool v)
inlinenoexcept

Should trees be normalised?

Parameters
vBoolean value.

◆ yield_tree()

template<class tree_type , bool is_free = std::is_base_of_v<graphs::free_tree, tree_type>, std::enable_if_t< std::is_base_of_v< graphs::free_tree, tree_type >||std::is_base_of_v< graphs::rooted_tree, tree_type >, bool > = true>
virtual tree_type_t lal::generate::_tree_generator< tree_type, is_free, >::yield_tree ( )
pure 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().

Returns
A free/rooted tree depending on the type of the class inheriting from this. The type of generation of tree differs from one type of class to another.

Implemented in lal::generate::all_lab_free_trees, lal::generate::all_lab_rooted_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.


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