![]() |
libsemigroups
v3.0.0
C++ library for semigroups and monoids
|
Defined in gabow.hpp
.
This page contains class implements Gabow's algorithm [23] for computing the strongly connected components of a WordGraph.
Instances of this class can be used to compute, and provide information about, the strongly connected components of the WordGraph used to construct the instance. The strongly connected components are lazily evaluated when triggered by a relevant member function. The complexity of Gabow's algorithm is at most \(O(mn)\) where m
is WordGraph::number_of_nodes() and n
is out_degree().
Node | the type of the nodes of the underlying WordGraph. |
Public Types | |
using | label_type = typename WordGraph<node_type>::label_type |
Type of the edge labels in the underlying WordGraph. | |
using | node_type = Node |
Type of the nodes in the underlying WordGraph. | |
using | size_type = size_t |
Size type used for indices of strongly connected components. | |
Public Member Functions | |
Gabow ()=delete | |
Deleted. | |
Gabow (Gabow &&)=default | |
Default move constructor. | |
Gabow (Gabow const &)=default | |
Default copy constructor. | |
Gabow (WordGraph< node_type > const &wg) | |
Construct from WordGraph. | |
std::vector< node_type > const & | component (size_type i) const |
Returns a const reference to a vector containing the strongly connected component with given index. | |
std::vector< node_type > | component_no_checks (size_type i) const |
Returns a const reference to a vector containing the strongly connected component with given index. | |
std::vector< node_type > const & | component_of (node_type n) const |
Returns a const reference to a vector containing the strongly connected component of a given node. | |
std::vector< node_type > const & | component_of_no_checks (node_type n) const |
Returns a const reference to a vector containing the strongly connected component of a given node. | |
std::vector< std::vector< node_type > > const & | components () const |
Returns a const reference to a vector of vectors containing the strongly connected components. | |
bool | has_components () const noexcept |
Check whether the strongly connected components have been found. | |
size_type | id (node_type n) const |
Returns the id-number of the strongly connected component of a node. | |
size_type | id_no_checks (node_type n) const |
Get the id of a strongly connected component of a node. | |
Gabow & | init (WordGraph< node_type > const &wg) |
Reinitialize a Gabow object. | |
size_t | number_of_components () const |
Returns the number of strongly connected components. | |
Gabow & | operator= (Gabow &&)=default |
Default move assignment operator. | |
Gabow & | operator= (Gabow const &)=default |
Default copy assignment operator. | |
Forest const & | reverse_spanning_forest () const |
Returns a reverse spanning forest of the strongly connected components (if they are not already known). | |
node_type | root_of (node_type n) const |
Returns the root of the strongly connected component containing a given node. | |
node_type | root_of_no_checks (node_type n) const |
Returns the root of the strongly connected component containing a given node. | |
auto | roots () const |
Returns a range object consisting of roots of the strongly connected components. | |
Forest const & | spanning_forest () const |
Returns a spanning forest of the strongly connected components. | |
WordGraph< Node > const & | word_graph () const noexcept |
Returns a const reference to the underlying word graph. | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename Node> | |
Gabow (WordGraph< Node > const &) -> Gabow< Node > | |
Deduction guide for Gabow objects. | |
template<typename Node> | |
std::string | to_human_readable_repr (Gabow< Node > const &g) |
Return a human readable representation of a Gabow object. | |
|
delete |
|
inlinenodiscard |
This function returns a const reference to a vector containing the strongly connected components with index i
of the WordGraph (word_graph) used to construct the Gabow instance.
i | the index of a strongly connected component. |
LibsemigroupsException | if i is greater than or equal to number_of_components. |
|
inlinenodiscard |
This function returns a const reference to a vector containing the strongly connected components with index i
of the WordGraph (word_graph) used to construct the Gabow instance.
i | the index of a strongly connected component. |
i
.
|
inlinenodiscard |
This function returns a const reference to a vector containing the strongly connected components of the node n
of the WordGraph (returned by word_graph) used to construct the Gabow instance.
n | the node. |
LibsemigroupsException | if n is greater than or equal to word_graph().number_of_nodes() . |
|
inlinenodiscard |
This function returns a const reference to a vector containing the strongly connected components of the node n
of the WordGraph (returned by word_graph) used to construct the Gabow instance.
n | the node. |
n
.
|
inlinenodiscard |
This function returns a const reference to a vector of vectors containing all of the strongly connected components of the WordGraph (word_graph) used to construct the Gabow instance.
|
inlinenodiscardnoexcept |
This function returns true
if the strongly connected components of a Gabow object have already been computed and false
if not.
bool
.noexcept
and is guaranteed never to throw. This function can be used to determine the id-number of a node in the underlying graph of a Gabow instance.
n | the node. |
n
.LibsemigroupsException | if n is greater than or equal to word_graph().number_of_nodes() . |
This function can be used to determine the id-number of a node in the underlying graph of a Gabow instance.
n | the node. |
n
.n
is actually a node of the underlying word graph. This function re-initializes a Gabow object so that it is in the same state as if it had just been constructed from wg
.
*this
.
|
inlinenodiscard |
This function returns the number of strongly connected components of the underlying WordGraph (returned by word_graph).
size_t
.Default move assignment operator.
Default copy assignment operator.
Forest const & reverse_spanning_forest | ( | ) | const |
This function returns a Forest comprised of spanning trees for each strongly connected component of a Gabow object, rooted on the minimum node of that component, with edges oriented towards the root.
This function returns the root of the strongly connected component containing the node n
of the underlying WordGraph. Two nodes a
and b
belong to the same strongly connected component if and only if root_of(a) == root_of(b)
.
n | the node. |
n
, a value of node_type.LibsemigroupsException | if n is greater than or equal to WordGraph::number_of_nodes of the underlying word graph. |
This function returns the root of the strongly connected component containing the node n
of the underlying WordGraph. Two nodes a
and b
belong to the same strongly connected component if and only if root_of_no_checks(a) == root_of_no_checks(b)
.
n | the node. |
n
, a value of node_type.n
.
|
inlinenodiscard |
This function returns a range object consisting of roots of the strongly connected components; see Ranges for more details.
Forest const & spanning_forest | ( | ) | const |
This function returns a Forest comprised of spanning trees for each strongly connected component of a Gabow object, rooted on the minimum node of that component, with edges oriented away from the root.
|
inlinenoexcept |
This function returns a const reference to the underlying word graph.
noexcept
and is guaranteed never to throw.
|
Return a human readable representation of a Gabow object.
Node | the type of the nodes in the underlying WordGraph. |
g | the Gabow object. |
g
.