libsemigroups  v3.1.2
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
libsemigroups::forest Namespace Reference

This page contains the documentation of some helper functions for the Forest class.

Functions

size_t depth (Forest const &f, Forest::node_type n)
 Returns the depth of a node in the forest, i.e. the distance, in terms of the number of edges, from a root.
 
size_t depth_no_checks (Forest const &f, Forest::node_type n)
 Returns the depth of a node in the forest, n.e. the distance, in terms of the number of edges, from a root.
 
bool is_root (Forest const &f, Forest::node_type n)
 Check if a node is the root of any tree in the Forest.
 
bool is_root_no_checks (Forest const &f, Forest::node_type n)
 Check if a node is the root of any tree in the Forest.
 
word_type path_from_root (Forest const &f, Forest::node_type n)
 Returns a word containing the labels of the edges on the path from a root node to n.
 
void path_from_root (Forest const &f, word_type &w, Forest::node_type n)
 Modifies w to contain the labels of the edges on the path from a root node to n.
 
word_type path_from_root_no_checks (Forest const &f, Forest::node_type n)
 Returns a word containing the labels of the edges on the path from a root node to n.
 
void path_from_root_no_checks (Forest const &f, word_type &w, Forest::node_type n)
 Modifies w to contain the labels of the edges on the path from a root node to n.
 
word_type path_to_root (Forest const &f, Forest::node_type n)
 Returns a word containing the labels of the edges on the path to a root node from n.
 
void path_to_root (Forest const &f, word_type &w, Forest::node_type n)
 Modifies w to contain the labels of the edges on the path to a root node from n.
 
word_type path_to_root_no_checks (Forest const &f, Forest::node_type n)
 Returns a word containing the labels of the edges on the path to a root node from n.
 
void path_to_root_no_checks (Forest const &f, word_type &w, Forest::node_type n)
 Modifies w to contain the labels of the edges on the path to a root node from n.
 

Function Documentation

◆ depth()

size_t depth ( Forest const & f,
Forest::node_type n )
inlinenodiscard

This function returns the length of the word returned by path_to_root_no_checks and path_from_root_no_checks.

Parameters
fthe Forest.
nthe node.
Returns
The depth of n.
Exceptions
LibsemigroupsExceptionif n is out of bounds (i.e. it is greater than or equal to number_of_nodes).

◆ depth_no_checks()

size_t depth_no_checks ( Forest const & f,
Forest::node_type n )
nodiscard

This function returns the length of the word returned by path_to_root_no_checks and path_from_root_no_checks.

Parameters
fthe Forest.
nthe node.
Returns
The depth of n.
Warning
No checks are performed on the arguments of this function.

◆ is_root()

bool is_root ( Forest const & f,
Forest::node_type n )
inlinenodiscard

This function returns true if the node n in the Forest f is a root node, and false if it is not.

Parameters
fthe Forest.
nthe node.
Returns
Whether or not n is a root of f.
Exceptions
LibsemigroupsExceptionif n is out of bounds (i.e. it is greater than or equal to number_of_nodes).

◆ is_root_no_checks()

bool is_root_no_checks ( Forest const & f,
Forest::node_type n )
inlinenodiscard

This function returns true if the node n in the Forest f is a root node, and false if it is not.

Parameters
fthe Forest.
nthe node.
Returns
Whether or not n is a root of f.
Warning
No checks are performed on the arguments of this function. In particular it is not checked whether or not n is a node of f.

◆ path_from_root() [1/2]

word_type path_from_root ( Forest const & f,
Forest::node_type n )
nodiscard

This function returns a word containing the labels of the edges on the path from a root node to the node n.

Parameters
fthe forest.
nthe node.
Returns
The word labelling the path from a root node to n.
Exceptions
LibsemigroupsExceptionif n is greater than or equal to number_of_nodes.

◆ path_from_root() [2/2]

void path_from_root ( Forest const & f,
word_type & w,
Forest::node_type n )

This function modifies its first argument w in-place to contain the labels of the edges on the path from a root node to the node n.

Parameters
fthe forest.
wvalue to contain the result.
nthe node.
Exceptions
LibsemigroupsExceptionif n is greater than or equal to number_of_nodes.

◆ path_from_root_no_checks() [1/2]

word_type path_from_root_no_checks ( Forest const & f,
Forest::node_type n )
nodiscard

This function returns a word containing the labels of the edges on the path from a root node to the node n.

Parameters
fthe forest.
nthe node.
Returns
The word labelling the path from a root node to n.
Warning
No checks are performed on the arguments of this function.

◆ path_from_root_no_checks() [2/2]

void path_from_root_no_checks ( Forest const & f,
word_type & w,
Forest::node_type n )

This function modifies its first argument w in-place to contain the labels of the edges on the path from a root node to the node n.

Parameters
fthe forest.
wvalue to contain the result.
nthe node.
Warning
No checks are performed on the arguments of this function.

◆ path_to_root() [1/2]

word_type path_to_root ( Forest const & f,
Forest::node_type n )
nodiscard

This function returns a word containing the labels of the edges on the path to a root node from node n.

Parameters
fthe forest.
nthe node.
Returns
The word labelling the path from a root node to n.
Exceptions
LibsemigroupsExceptionif n is greater than or equal to number_of_nodes.

◆ path_to_root() [2/2]

void path_to_root ( Forest const & f,
word_type & w,
Forest::node_type n )

This function modifies its first argument w in-place to contain the labels of the edges on the path to a root node from node n.

Parameters
fthe forest.
wvalue to contain the result.
nthe node.
Exceptions
LibsemigroupsExceptionif n is greater than or equal to number_of_nodes.

◆ path_to_root_no_checks() [1/2]

word_type path_to_root_no_checks ( Forest const & f,
Forest::node_type n )
nodiscard

This function returns a word containing the labels of the edges on the path to a root node from node n.

Parameters
fthe forest.
nthe node.
Returns
The word labelling the path from a root node to n.
Warning
No checks are performed on the arguments of this function.

◆ path_to_root_no_checks() [2/2]

void path_to_root_no_checks ( Forest const & f,
word_type & w,
Forest::node_type n )

This function modifies its first argument w in-place to contain the labels of the edges on the path to a root node from node n.

Parameters
fthe forest.
wvalue to contain the result.
nthe node.
Warning
No checks are performed on the arguments of this function.