![]() |
libsemigroups
v3.0.0
C++ library for semigroups and monoids
|
Defined in paths.hpp
.
This class represents a range object that facilitates iterating through the paths in a WordGraph from a given source node (possible to a target node) in a particular order.
Node | the type of the nodes in the underlying WordGraph. |
So that the Paths class can be used efficiently with the functionality of rx::ranges, the usual naming conventions in libsemigroups
are not used for the member functions:
of Paths. In particular, none of these member functions check their arguments, but they do not have the suffix _no_checks
.
For a Paths object to be valid it must have its source node defined (using source), both the source (set using source) and target (set using target) nodes must belong to the underlying WordGraph (word_graph). This can be verified by checking source() != UNDEFINED
. The functions listed above (get, next, at_end, size_hint, count) should only be called if source() != UNDEFINED
, and it is the responsibility of the caller to ensure that this is the case.
Changing the value of source, target, min, max, or order resets the Paths object to point at the first word in the specified range.
Public Types | |
using | node_type = Node |
The template parameter Node , the type of the nodes in the underlying WordGraph. | |
using | output_type = word_type const& |
Alias for const reference to a word_type. | |
using | size_type = typename WordGraph<Node>::size_type |
Unsigned integer for indexing. | |
Public Member Functions | |
Paths (Paths &&) | |
Default move constructor. | |
Paths (Paths const &) | |
Default copy constructor. | |
Paths (WordGraph< Node > const &wg) | |
Construct from a WordGraph. | |
bool | at_end () const |
Check if the range is exhausted. | |
uint64_t | count () const |
Get the size of the range. | |
node_type | current_target () const |
Get the current target node of the path labelled by get. | |
output_type | get () const |
Get the current path in the range. | |
Paths & | init (WordGraph< Node > const &wg) |
Reinitialize a Paths object. | |
size_type | max () const noexcept |
Get the maximum length of path in the range. | |
Paths & | max (size_type val) noexcept |
Set the maximum length of path in the range. | |
size_type | min () const noexcept |
Get the minimum length of path in the range. | |
Paths & | min (size_type val) noexcept |
Set the minimum length of path in the range. | |
void | next () |
Advance to the next path in the range. | |
Paths & | operator= (Paths &&) |
Default move assignment operator. | |
Paths & | operator= (Paths const &) |
Default copy assignment operator. | |
Order | order () const noexcept |
Get the order of the paths in the range. | |
Paths & | order (Order val) |
Set the order of the paths in the range. | |
uint64_t | size_hint () const |
Get the size of the range. | |
node_type | source () const noexcept |
Get the current source node of every path in the range. | |
Paths & | source (node_type n) |
Set the source node of every path in the range. | |
Paths & | source_no_checks (node_type n) noexcept |
Set the source node of every path in the range. | |
node_type | target () const noexcept |
Get the current target node of every path in the range. | |
Paths & | target (node_type n) |
Set the target node of every path in the range. | |
Paths & | target_no_checks (node_type n) noexcept |
Set the target node of every path in the range. | |
void | throw_if_source_undefined () const |
Throw an exception if the source node has not been defined (using source). | |
WordGraph< Node > const & | word_graph () const noexcept |
The underlying WordGraph. | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename Node> | |
Paths (WordGraph< Node > &&) -> Paths< Node > | |
template<typename Node> | |
Paths (WordGraph< Node > const &) -> Paths< Node > | |
template<typename Node1, typename Node2> | |
auto | cbegin_pilo (WordGraph< Node1 > const &wg, Node2 source, size_t min=0, size_t max=POSITIVE_INFINITY) |
Returns an iterator for pilo (Path And Node In Lex Order). | |
template<typename Node1, typename Node2> | |
auto | cbegin_pislo (WordGraph< Node1 > const &wg, Node2 source, size_t min=0, size_t max=POSITIVE_INFINITY) |
template<typename Node1, typename Node2> | |
auto | cbegin_pstilo (WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min=0, size_t max=POSITIVE_INFINITY) |
template<typename Node1, typename Node2> | |
auto | cbegin_pstislo (WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min=0, size_t max=POSITIVE_INFINITY) |
template<typename Node> | |
auto | cend_pilo (WordGraph< Node > const &wg) |
template<typename Node> | |
auto | cend_pislo (WordGraph< Node > const &wg) |
template<typename Node> | |
auto | cend_pstilo (WordGraph< Node > const &wg) |
template<typename Node> | |
auto | cend_pstislo (WordGraph< Node > const &wg) |
template<typename Node1, typename Node2> | |
uint64_t | number_of_paths (WordGraph< Node1 > const &wg, Node2 source) |
template<typename Node1, typename Node2> | |
uint64_t | number_of_paths (WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min, size_t max, paths::algorithm lgrthm=paths::algorithm::automatic) |
template<typename Node1, typename Node2> | |
uint64_t | number_of_paths (WordGraph< Node1 > const &wg, Node2 source, size_t min, size_t max, paths::algorithm lgrthm=paths::algorithm::automatic) |
template<typename Node1, typename Node2> | |
paths::algorithm | number_of_paths_algorithm (WordGraph< Node1 > const &wg, Node2 source) noexcept |
template<typename Node1, typename Node2> | |
paths::algorithm | number_of_paths_algorithm (WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min, size_t max) |
template<typename Node1, typename Node2> | |
paths::algorithm | number_of_paths_algorithm (WordGraph< Node1 > const &wg, Node2 source, size_t min, size_t max) |
template<typename Node> | |
std::string | to_human_readable_repr (Paths< Node > const &p) |
Return a human readable representation of a Paths object. | |
using node_type = Node |
The template parameter Node
, the type of the nodes in the underlying WordGraph.
using output_type = word_type const& |
The output type of this type of range.
Unsigned integer for indexing.
|
inlinenodiscard |
This function returns true
if there are no more paths in the range, and false
otherwise.
source() != UNDEFINED
before calling this function.
|
inlinenodiscard |
This function returns the number of paths in the range. The output is identical to that of size_hint, and is included for compatibility with rx::ranges.
source() != UNDEFINED
before calling this function.
|
nodiscard |
This function returns the current target node of the path labelled by get. If there is no such path (because, for example, the source node hasn't been defined, then UNDEFINED is returned).
|
inline |
Get the current path in the range.
source() != UNDEFINED
before calling this function.
|
inlinenodiscardnoexcept |
This function returns the current maximum length of paths in the range. The initial value is POSITIVE_INFINITY.
noexcept
and is guaranteed never to throw. This function can be used to set the maximum length of path that will be contained in the range. If this function is not called, then the range will contain paths of unbounded length (possibly infinitely many).
val | the maximum path length. |
*this
.noexcept
and is guaranteed never to throw.
|
inlinenodiscardnoexcept |
This function returns the current minimum length of paths in the range. The initial value is 0
.
noexcept
and is guaranteed never to throw. This function can be used to set the minimum length of paths that will be contained in the range. If this function is not called, then the range will contain paths starting with length 0
.
val | the minimum path length. |
*this
.noexcept
and is guaranteed never to throw.
|
inline |
Default copy assignment operator.
|
inlinenodiscardnoexcept |
This function returns the current order of the paths in the range defined by a Paths object. The initial value is Order::shortlex.
noexcept
and is guaranteed never to throw. This function can be used to set the order of the paths in the range defined by a Paths object. The initial value is Order::shortlex.
val | the order of the paths in the range. |
*this
.LibsemigroupsException | if val is not Order::shortlex or Order::lex. |
|
nodiscard |
This function returns the number of paths in the range. The output is identical to that of count, and is included for compatibility with rx::ranges.
source() != UNDEFINED
before calling this function.
|
inlinenodiscardnoexcept |
This function can be used to set the source node (or the "from" node) of all of the paths in the range.
n | the source node. |
*this
.LibsemigroupsException | if n is not a node in the underlying WordGraph (word_graph). |
This function can be used to set the source node (or the "from" node) of all of the paths in the range.
n | the source node. |
*this
.noexcept
and is guaranteed never to throw.n
is a node in the underlying WordGraph (word_graph).
|
inlinenodiscardnoexcept |
This function can be used to set the target node (or the "to" node) of all of the paths in the range. It is not necessary to set this value. If the target node is set to UNDEFINED, then the range will contain every path from source to every possible target in the underlying WordGraph (word_graph).
n | the target node. |
*this
.LibsemigroupsException | if n is not a node in the underlying WordGraph (word_graph) and n is not UNDEFINED. |
This function can be used to set the target node (or the "to" node) of all of the paths in the range. It is not necessary to set this value. If the target node is set to UNDEFINED, then the range will contain every path from source to every possible target in the underlying WordGraph (word_graph).
n | the target node. |
*this
.noexcept
and is guaranteed never to throw.n
is a node in the underlying WordGraph (word_graph). void throw_if_source_undefined | ( | ) | const |
This function throws an exception if the source node of the paths in the range has not been specified (using source).
|
inlinenodiscardnoexcept |
Deduction guide to construct a Paths<Node> from a WordGraph<Node> rvalue reference.
Deduction guide to construct a Paths<Node> from a WordGraph<Node> const reference.
|
Returns a forward iterator pointing to a pair consisting of the edge labels of the first path (in lexicographical order) starting at source
with length in the range \([min, max)\) and the last node of that path.
If incremented, the iterator will point to the next least edge labelling of a path (in lexicographical order), and its last node, with length in the range \([min, max)\). Iterators of the type returned by this function are equal whenever they point to equal objects.
wg | the WordGraph. |
source | the source node. |
min | the minimum length of a path to enumerate (defaults to 0 ). |
max | the maximum length of a path to enumerate (defaults to POSITIVE_INFINITY). |
it
of type const_pilo_iterator
pointing to a std::pair
where:
LibsemigroupsException | if source is not a node in the word graph. |
++it
the returned iterator it
significantly cheaper than postfix incrementing it++
.this
contains a cycle that is reachable from source
, then there are infinitely many paths starting at source
, and so max
should be chosen with some care.
|
Returns an iterator for pislo (Path And Node In Short Lex Order).
Returns a forward iterator pointing to a pair consisting of the edge labels of the first path (in short-lex order) starting at source
with length in the range \([min, max)\) and the last node of that path.
If incremented, the iterator will point to the next least edge labelling of a path (in short-lex order), and its last node, with length in the range \([min, max)\). Iterators of the type returned by this function are equal whenever they point to equal objects.
wg | the WordGraph. |
source | the source node. |
min | the minimum length of a path to enumerate (defaults to 0 ). |
max | the maximum length of a path to enumerate (defaults to POSITIVE_INFINITY). |
it
of type detail::const_pislo_iterator
pointing to a std::pair
where:
LibsemigroupsException | if source is not a node in the word graph. |
++it
the returned iterator it
significantly cheaper than postfix incrementing it++
.this
contains a cycle that is reachable from source
, then there are infinitely many paths starting at source
, and so max
should be chosen with some care.
|
Returns an iterator for PSTILO (Path Source Target In Lex Order).
Returns a forward iterator pointing to the edge labels of the first path (in lexicographical order) starting at the node source
and ending at the node target
with length in the range \([min, max)\).
If incremented, the iterator will point to the next least edge labelling of a path (in lexicographical order). Iterators of the type returned by this function are equal whenever they point to equal objects.
wg | the WordGraph. |
source | the first node. |
target | the last node. |
min | the minimum length of a path to enumerate (defaults to 0 ). |
max | the maximum length of a path to enumerate (defaults to POSITIVE_INFINITY). |
it
of type detail::const_pstilo_iterator
pointing to a word_type consisting of the edge labels of the first path (in lexicographical order) from the node source
to the node target
with length in the range \([min, max)\) (if any).LibsemigroupsException | if target or source is not a node in the word graph. |
++it
the returned iterator it
significantly cheaper than postfix incrementing it++
.this
contains a cycle that is reachable from source
, then there may be infinitely many paths starting at source
, and so max
should be chosen with some care.
|
Returns an iterator for PSTISLO (Path Source Target In Short Lex Order).
Returns a forward iterator pointing to the edge labels of the first path (in short-lex order) starting at the node source
and ending at the node target
with length in the range \([min, max)\).
If incremented, the iterator will point to the next least edge labelling of a path (in short-lex order). Iterators of the type returned by this function are equal whenever they point to equal objects.
wg | the WordGraph. |
source | the first node. |
target | the last node. |
min | the minimum length of a path to enumerate (defaults to 0 ). |
max | the maximum length of a path to enumerate (defaults to POSITIVE_INFINITY). |
it
of type detail::const_pstislo_iterator
pointing to a word_type consisting of the edge labels of the first path (in short-lex order) from the node source
to the node target
with length in the range \([min, max)\) (if any).LibsemigroupsException | if target or source is not a node in the word graph. |
++it
the returned iterator it
significantly cheaper than postfix incrementing it++
.this
contains a cycle that is reachable from source
, then there may be infinitely many paths starting at source
, and so max
should be chosen with some care.
|
Returns an iterator for pilo (Path And Node In Lex Order).
Returns a forward iterator pointing to one after the last path from any node in the word graph.
The iterator returned by this function may still dereferenceable and incrementable, but may not point to a path in the correct range.
|
Returns an iterator for pislo (Path And Node In Short Lex Order).
Returns a forward iterator pointing to one after the last path from any node in the word graph.
The iterator returned by this function may still dereferenceable and incrementable, but may not point to a path in the correct range.
|
Returns an iterator for PSTILO (Path Source Target In Lex Order).
Returns a forward iterator pointing to one after the last path from any node in the word graph.
The iterator returned by this function may still dereferenceable and incrementable, but may not point to a path in the correct range.
|
Returns an iterator for PSTISLO (Path Source Target In Short Lex Order).
Returns a forward iterator pointing to one after the last path from any node in the word graph.
The iterator returned by this function may still dereferenceable and incrementable, but may not point to a path in the correct range.
|
Returns the number of paths from a source node.
wg | the WordGraph. |
source | the source node. |
uint64_t
.LibsemigroupsException | if source is not a node in the word graph. |
|
Returns the number of paths between a pair of nodes with length in a given range.
wg | the WordGraph. |
source | the first node. |
target | the last node. |
min | the minimum length of a path. |
max | the maximum length of a path. |
lgrthm | the algorithm to use (defaults to: paths::algorithm::automatic). |
uint64_t
.LibsemigroupsException | if:
|
lgrthm
as follows:source
max
.source
is acyclic)lgrthm
is paths::algorithm::automatic, then it is not always the case that the fastest algorithm is used.
|
Returns the number of paths starting at a given node with length in a given range.
wg | the WordGraph. |
source | the first node. |
min | the minimum length of a path. |
max | the maximum length of a path. |
lgrthm | the algorithm to use (defaults to: paths::algorithm::automatic). |
uint64_t
.LibsemigroupsException | if:
|
lgrthm
as follows:source
max
.source
is acyclic)lgrthm
is paths::algorithm::automatic, then it is not always the case that the fastest algorithm is used.
|
Returns the paths::algorithm used by number_of_paths().
wg | the WordGraph. |
source | the source node. |
noexcept
and is guaranteed never to throw.
|
Returns the algorithm used by number_of_paths().
Returns the algorithm used by number_of_paths() to compute the number of paths originating at the given source node and ending at the given target node with length in the range \([min, max)\).
wg | the WordGraph. |
source | the source node. |
target | the target node. |
min | the minimum length of paths to count. |
max | the maximum length of paths to count. |
|
Returns the paths::algorithm used by number_of_paths().
Returns the algorithm used by number_of_paths() to compute the number of paths originating at the given source node with length in the range \([min, max)\).
wg | the WordGraph. |
source | the source node. |
min | the minimum length of paths to count. |
max | the maximum length of paths to count. |
|
Return a human readable representation of a Paths object.
Node | the type of the nodes in the underlying WordGraph. |
p | the Paths object. |