22#ifndef LIBSEMIGROUPS_GABOW_HPP_
23#define LIBSEMIGROUPS_GABOW_HPP_
32#include "constants.hpp"
34#include "exception.hpp"
37#include "word-graph.hpp"
60 template <
typename Node>
75 mutable bool _finished;
77 mutable Forest _bckwd_forest;
78 mutable bool _bckwd_forest_defined;
79 mutable Forest _forwd_forest;
80 mutable bool _forwd_forest_defined;
183 throw_if_node_out_of_range(n);
228 throw_if_scc_index_out_of_range(i);
274 return _comps.size();
293 return (rx::iterator_range(_comps.cbegin(), _comps.cend())
294 | rx::transform([](
auto const& comp) { return comp[0]; }));
365 throw_if_node_out_of_range(n);
366 return _comps[_id[n]];
391 return _comps[_id[n]];
458 void reset() const noexcept;
460 void throw_if_node_out_of_range(
node_type n) const;
461 void throw_if_scc_index_out_of_range(
size_t i) const;
467 template <typename Node>
484 template <typename Node>
Class representing a collection of spanning trees of a word graph.
Definition forest.hpp:42
Forest const & spanning_forest() const
Returns a spanning forest of the strongly connected components.
Node node_type
Type of the nodes in the underlying WordGraph.
Definition gabow.hpp:64
Gabow & operator=(Gabow &&)=default
Default move assignment operator.
WordGraph< Node > const & word_graph() const noexcept
Returns a const reference to the underlying word graph.
Definition gabow.hpp:439
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.
Definition gabow.hpp:363
std::string to_human_readable_repr(Gabow< uint32_t > const &g)
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.
Definition gabow.hpp:226
Gabow(WordGraph< uint32_t > const &) -> Gabow< uint32_t >
size_t number_of_components() const
Returns the number of strongly connected components.
Definition gabow.hpp:272
size_type id(node_type n) const
Returns the id-number of the strongly connected component of a node.
Definition gabow.hpp:181
bool has_components() const noexcept
Check whether the strongly connected components have been found.
Definition gabow.hpp:453
Gabow & operator=(Gabow const &)=default
Default copy assignment operator.
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.
Definition gabow.hpp:254
std::vector< std::vector< node_type > > const & components() const
Returns a const reference to a vector of vectors containing the strongly connected components.
Definition gabow.hpp:203
size_t size_type
Size type used for indices of strongly connected components.
Definition gabow.hpp:70
Gabow(Gabow &&)=default
Default move constructor.
Gabow(WordGraph< node_type > const &wg)
Construct from WordGraph.
Definition gabow.hpp:121
Gabow & init(WordGraph< node_type > const &wg)
Reinitialize a Gabow object.
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.
Definition gabow.hpp:389
size_type id_no_checks(node_type n) const
Get the id of a strongly connected component of a node.
Definition gabow.hpp:160
typename WordGraph< node_type >::label_type label_type
Type of the edge labels in the underlying WordGraph.
Definition gabow.hpp:67
auto roots() const
Returns a range object consisting of roots of the strongly connected components.
Definition gabow.hpp:291
node_type root_of(node_type n) const
Returns the root of the strongly connected component containing a given node.
Definition gabow.hpp:316
Forest const & reverse_spanning_forest() const
Returns a reverse spanning forest of the strongly connected components (if they are not already known...
Gabow(Gabow const &)=default
Default copy constructor.
node_type root_of_no_checks(node_type n) const
Returns the root of the strongly connected component containing a given node.
Definition gabow.hpp:341
Class for representing word graphs.
Definition word-graph.hpp:82
Node label_type
The type of edge labels in a word graph.
Definition word-graph.hpp:101
Namespace for everything in the libsemigroups library.
Definition action.hpp:44