![]() |
libsemigroups
v3.0.0
C++ library for semigroups and monoids
|
Defined in forest.hpp
.
This class represents the collection of spanning trees of the strongly connected components of a word graph.
Public Types | |
using | label_type = size_t |
Alias for the type of edge labels in a forest. | |
using | node_type = size_t |
Alias for the type of nodes in a forest. | |
Public Member Functions | |
Forest (Forest &&)=default | |
Default move constructor. | |
Forest (Forest const &)=default | |
Default copy constructor. | |
Forest (size_t n=0) | |
Constructs a forest with n nodes. | |
Forest & | add_nodes (size_t n) |
Add nodes to the Forest. | |
bool | empty () const noexcept |
Check if there are any nodes in the forest. | |
Forest & | init (size_t n=0) |
Reinitialize an existing Forest object. | |
label_type | label (node_type i) const |
Returns the label of the edge from a node to its parent. | |
label_type | label_no_checks (node_type i) const |
Returns the label of the edge from a node to its parent. | |
std::vector< label_type > const & | labels () const noexcept |
Returns a const reference to the vector of edge labels. | |
size_t | number_of_nodes () const noexcept |
Returns the number of nodes in the forest. | |
bool | operator!= (Forest const &that) const |
Compare Forest objects for inequality. | |
Forest & | operator= (Forest &&)=default |
Default move assignment constructor. | |
Forest & | operator= (Forest const &)=default |
Default copy assignment constructor. | |
bool | operator== (Forest const &that) const |
Compare Forest objects for equality. | |
node_type | parent (node_type i) const |
Returns the parent of a node. | |
node_type | parent_no_checks (node_type i) const |
Returns the parent of a node. | |
std::vector< node_type > const & | parents () const noexcept |
Returns a const reference to the vector of parents. | |
template<typename Iterator> | |
Iterator | path_to_root_no_checks (Iterator d_first, node_type i) const |
Store the labels of the edges on the path to a root node from i . | |
Forest & | set_parent_and_label (node_type node, node_type parent, label_type gen) |
Set the parent and edge label for a node. | |
Forest & | set_parent_and_label_no_checks (node_type node, node_type parent, label_type gen) |
Set the parent and edge label for a node. | |
void | throw_if_node_out_of_bounds (node_type v) const |
Throw an exception if a node is out of bound. | |
Related Symbols | |
(Note that these are not member symbols.) | |
std::string | to_human_readable_repr (Forest const &f) |
Return a human readable representation of a Forest object. | |
|
inlineexplicit |
Forest & add_nodes | ( | size_t | n | ) |
This function adds n
nodes to the forest, but no edges.
n | the number of nodes to add. |
this
is guaranteed not to be modified (strong exception guarantee).number_of_nodes() + n
.this
, any iterators, pointers or references pointing into this
may be invalidated by a call to this function.
|
inlinenodiscardnoexcept |
This function returns true
if there are 0 nodes in the forest, and false
otherwise.
bool
.noexcept
and is guaranteed never to throw.Forest & init | ( | size_t | n = 0 | ) |
This function reinitializes an existing Forest object so that it is in the same state as if it had just be constructed as Forest(n)
.
n | the number of nodes, defaults to 0 . |
this
.
|
inlinenodiscard |
This function returns the label of the edge from the parent of i
to the node i
. The value UNDEFINED is returned if i
has no parent, i.e. when i
is a root node.
i | the node whose label is sought. |
LibsemigroupsException | if i exceeds number_of_nodes() . |
|
inlinenodiscard |
This function returns the label of the edge from the parent of i
to the node i
. The value UNDEFINED is returned if i
has no parent, i.e. when i
is a root node.
i | the node whose label is sought. |
|
inlinenodiscardnoexcept |
Returns a const reference to the vector of edge labels in the Forest. The value in position i
of this vector is the label of the edge from the parent of node i
to i
. If the parent equals UNDEFINED, then node i
is a root node.
noexcept
and is guaranteed never to throw.
|
inlinenodiscardnoexcept |
Returns the number of nodes in the forest.
size_t
.noexcept
and is guaranteed never to throw.
|
inlinenodiscard |
|
inlinenodiscard |
This function returns the parent of the node i
in the forest. The value UNDEFINED is returned if i
has no parent, i.e. when i
is a root node.
i | the node whose parent is sought. |
LibsemigroupsException | if i exceeds number_of_nodes() . |
|
inlinenodiscardnoexcept |
Returns a const reference to the vector of parents in the Forest. The value in position i
of this vector is the parent of node i
. If the parent equals UNDEFINED, then node i
is a root node.
noexcept
and is guaranteed never to throw.
|
inline |
This function writes labels of the edges on the path to a root node from node i
to the iterator d_first
.
Iterator | The type of the parameter, and the return type. |
d_first | the output iterator. |
i | the node. |
Iterator
pointing one beyond the last letter inserted into d_first
.
|
inline |
This function sets the parent of node
to be parent
, and the associated edge-label to be gen
.
node | the node whose parent and label to set. |
parent | the parent node. |
gen | the label of the edge from parent to node . |
*this
.LibsemigroupsException | if node or parent exceeds number_of_nodes(). |
gen
can be arbitrary, and so this argument is never checked.
|
inline |
This function defines the parent and the label of the edge from that parent to the node node
to be parent
and gen
respectively.
node | the node whose parent and label to set. |
parent | the parent node. |
gen | the label of the edge from parent to node . |
LibsemigroupsException | if node or parent exceeds number_of_nodes(). |
gen
can be arbitrary, and so this argument is never checked.node
or parent
is greater than or equal to number_of_nodes, then bad things may happen. void throw_if_node_out_of_bounds | ( | node_type | v | ) | const |
This function throws an exception if the node v
is out of points.
v | the node. |
|
Return a human readable representation of a Forest object.
f | the Forest. |