libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
template<typename Node>
class libsemigroups::Paths< Node >

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.

Template Parameters
Nodethe 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.
 
Pathsinit (WordGraph< Node > const &wg)
 Reinitialize a Paths object.
 
size_type max () const noexcept
 Get the maximum length of path in the range.
 
Pathsmax (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.
 
Pathsmin (size_type val) noexcept
 Set the minimum length of path in the range.
 
void next ()
 Advance to the next path in the range.
 
Pathsoperator= (Paths &&)
 Default move assignment operator.
 
Pathsoperator= (Paths const &)
 Default copy assignment operator.
 
Order order () const noexcept
 Get the order of the paths in the range.
 
Pathsorder (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.
 
Pathssource (node_type n)
 Set the source node of every path in the range.
 
Pathssource_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.
 
Pathstarget (node_type n)
 Set the target node of every path in the range.
 
Pathstarget_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.
 

Member Typedef Documentation

◆ node_type

template<typename Node>
using node_type = Node

The template parameter Node, the type of the nodes in the underlying WordGraph.

◆ output_type

template<typename Node>
using output_type = word_type const&

The output type of this type of range.

◆ size_type

template<typename Node>
using size_type = typename WordGraph<Node>::size_type

Unsigned integer for indexing.

Constructor & Destructor Documentation

◆ Paths() [1/3]

template<typename Node>
Paths ( Paths< Node > const & )

Default copy constructor.

◆ Paths() [2/3]

template<typename Node>
Paths ( Paths< Node > && )

Default move constructor.

◆ Paths() [3/3]

template<typename Node>
Paths ( WordGraph< Node > const & wg)
inlineexplicit

This function constructs a Paths object from the WordGraph wg.

Parameters
wgthe word graph.
Warning
It is also necessary to set the source node using source before the object is valid.
The Paths object only holds a reference to the underlying WordGraph wg, and so wg must outlive any Paths object constructed from it.

Member Function Documentation

◆ at_end()

template<typename Node>
bool at_end ( ) const
inlinenodiscard

This function returns true if there are no more paths in the range, and false otherwise.

Returns
Whether or not the range is exhausted.
Warning
It is the responsibility of the caller to ensure that source() != UNDEFINED before calling this function.

◆ count()

template<typename Node>
uint64_t count ( ) const
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.

Returns
the number of paths in the range.
Warning
It is the responsibility of the caller to ensure that source() != UNDEFINED before calling this function.

◆ current_target()

template<typename Node>
node_type current_target ( ) const
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).

Returns
The current target node of the path labelled by get or UNDEFINED.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ get()

template<typename Node>
output_type get ( ) const
inline

Get the current path in the range.

Returns
The current path, a value of output_type.
Warning
It is the responsibility of the caller to ensure that source() != UNDEFINED before calling this function.

◆ init()

template<typename Node>
Paths & init ( WordGraph< Node > const & wg)
inline

This function puts a Paths object back into the same state as if it had been newly constructs from the WordGraph wg.

Parameters
wgthe word graph.
Returns
A reference to *this.
Warning
It is also necessary to set the source node using source before the object is valid.
The Paths object only holds a reference to the underlying WordGraph wg, and so wg must outlive any Paths object constructed from wg.

◆ max() [1/2]

template<typename Node>
size_type max ( ) const
inlinenodiscardnoexcept

This function returns the current maximum length of paths in the range. The initial value is POSITIVE_INFINITY.

Returns
The maximum length of paths in the range.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ max() [2/2]

template<typename Node>
Paths & max ( size_type val)
inlinenoexcept

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).

Parameters
valthe maximum path length.
Returns
A reference to *this.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ min() [1/2]

template<typename Node>
size_type min ( ) const
inlinenodiscardnoexcept

This function returns the current minimum length of paths in the range. The initial value is 0.

Returns
The minimum length of paths in the range.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ min() [2/2]

template<typename Node>
Paths & min ( size_type val)
inlinenoexcept

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.

Parameters
valthe minimum path length.
Returns
A reference to *this.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ next()

template<typename Node>
void next ( )
inline

Advance to the current path in the range. If at_end returns true, then this function does nothing.

Warning
It is the responsibility of the caller to ensure that source() != UNDEFINED before calling this function.

◆ operator=() [1/2]

template<typename Node>
Paths & operator= ( Paths< Node > && )

Default move assignment operator.

◆ operator=() [2/2]

template<typename Node>
Paths & operator= ( Paths< Node > const & )

Default copy assignment operator.

◆ order() [1/2]

template<typename Node>
Order order ( ) const
inlinenodiscardnoexcept

This function returns the current order of the paths in the range defined by a Paths object. The initial value is Order::shortlex.

Returns
The order of the paths in the range.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ order() [2/2]

template<typename Node>
Paths & order ( Order val)
inline

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.

Parameters
valthe order of the paths in the range.
Returns
A reference to *this.
Exceptions
LibsemigroupsExceptionif val is not Order::shortlex or Order::lex.

◆ size_hint()

template<typename Node>
uint64_t size_hint ( ) const
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.

Returns
the number of paths in the range.
Warning
It is the responsibility of the caller to ensure that source() != UNDEFINED before calling this function.

◆ source() [1/2]

template<typename Node>
node_type source ( ) const
inlinenodiscardnoexcept

This function returns the current source node of the every path in the range defined by a Paths object. This initial value is UNDEFINED.

Returns
The current source node.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ source() [2/2]

template<typename Node>
Paths & source ( node_type n)
inline

This function can be used to set the source node (or the "from" node) of all of the paths in the range.

Parameters
nthe source node.
Returns
A reference to *this.
Exceptions
LibsemigroupsExceptionif n is not a node in the underlying WordGraph (word_graph).
Note
Changing the value of the source node resets the Paths object to point at the first word in the specified range.
Warning
It is necessary to set the source node using source before a Paths object is valid.

◆ source_no_checks()

template<typename Node>
Paths & source_no_checks ( node_type n)
inlinenoexcept

This function can be used to set the source node (or the "from" node) of all of the paths in the range.

Parameters
nthe source node.
Returns
A reference to *this.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
Changing the value of the source node resets the Paths object to point at the first word in the specified range.
Warning
The source node must be defined for a Paths object to be valid.
This function does not verify that the argument n is a node in the underlying WordGraph (word_graph).

◆ target() [1/2]

template<typename Node>
node_type target ( ) const
inlinenodiscardnoexcept

This function returns the target node of the every path in the range defined by a Paths object. This initial value is UNDEFINED.

Returns
The target node.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ target() [2/2]

template<typename Node>
Paths & target ( node_type n)
inline

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).

Parameters
nthe target node.
Returns
A reference to *this.
Exceptions
LibsemigroupsExceptionif n is not a node in the underlying WordGraph (word_graph) and n is not UNDEFINED.
Note
Changing the value of the target node resets the Paths object to point at the first word in the specified range.

◆ target_no_checks()

template<typename Node>
Paths & target_no_checks ( node_type n)
inlinenoexcept

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).

Parameters
nthe target node.
Returns
A reference to *this.
Exceptions
This function is noexcept and is guaranteed never to throw.
Note
Changing the value of the target node resets the Paths object to point at the first word in the specified range.
Warning
This function does not verify that the argument n is a node in the underlying WordGraph (word_graph).

◆ throw_if_source_undefined()

template<typename Node>
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).

◆ word_graph()

template<typename Node>
WordGraph< Node > const & word_graph ( ) const
inlinenodiscardnoexcept

This function returns underlying WordGraph of the Paths object. This is the WordGraph defining the paths in the range.

Returns
The underlying WordGraph.
Exceptions
This function is noexcept and is guaranteed never to throw.

Friends And Related Symbol Documentation

◆ Paths() [1/2]

template<typename Node>
Paths ( WordGraph< Node > && ) -> Paths< Node >
related

Deduction guide to construct a Paths<Node> from a WordGraph<Node> rvalue reference.

◆ Paths() [2/2]

template<typename Node>
Paths ( WordGraph< Node > const & ) -> Paths< Node >
related

Deduction guide to construct a Paths<Node> from a WordGraph<Node> const reference.

◆ cbegin_pilo()

template<typename Node1, typename Node2>
auto cbegin_pilo ( WordGraph< Node1 > const & wg,
Node2 source,
size_t min = 0,
size_t max = POSITIVE_INFINITY )
related

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.

Parameters
wgthe WordGraph.
sourcethe source node.
minthe minimum length of a path to enumerate (defaults to 0).
maxthe maximum length of a path to enumerate (defaults to POSITIVE_INFINITY).
Returns
An iterator it of type const_pilo_iterator pointing to a std::pair where:
  • it->first is a word_type consisting of the edge labels of the first path (in lexicographical order) from source of length in the range \([min, max)\); and
  • it->second is the last node on the path from source labelled by it->first, a value of node_type.
Exceptions
LibsemigroupsExceptionif source is not a node in the word graph.
Warning
Copying iterators of this type is expensive. As a consequence, prefix incrementing ++it the returned iterator it significantly cheaper than postfix incrementing it++.
If the word graph represented by 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.
See also
cend_pilo

◆ cbegin_pislo()

template<typename Node1, typename Node2>
auto cbegin_pislo ( WordGraph< Node1 > const & wg,
Node2 source,
size_t min = 0,
size_t max = POSITIVE_INFINITY )
related

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.

Parameters
wgthe WordGraph.
sourcethe source node.
minthe minimum length of a path to enumerate (defaults to 0).
maxthe maximum length of a path to enumerate (defaults to POSITIVE_INFINITY).
Returns
An iterator it of type detail::const_pislo_iterator pointing to a std::pair where:
  • it->first is a word_type consisting of the edge labels of the first path (in short-lex order) from source of length in the range \([min, max)\); and
  • it->second is the last node on the path from source labelled by it->first, a value of node_type.
Exceptions
LibsemigroupsExceptionif source is not a node in the word graph.
Warning
Copying iterators of this type is expensive. As a consequence, prefix incrementing ++it the returned iterator it significantly cheaper than postfix incrementing it++.
If the word graph represented by 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.
See also
cend_pislo

◆ cbegin_pstilo()

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 )
related

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.

Parameters
wgthe WordGraph.
sourcethe first node.
targetthe last node.
minthe minimum length of a path to enumerate (defaults to 0).
maxthe maximum length of a path to enumerate (defaults to POSITIVE_INFINITY).
Returns
An iterator 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).
Exceptions
LibsemigroupsExceptionif target or source is not a node in the word graph.
Warning
Copying iterators of this type is expensive. As a consequence, prefix incrementing ++it the returned iterator it significantly cheaper than postfix incrementing it++.
If the word graph represented by 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.
See also
cend_pstilo

◆ cbegin_pstislo()

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 )
related

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.

Parameters
wgthe WordGraph.
sourcethe first node.
targetthe last node.
minthe minimum length of a path to enumerate (defaults to 0).
maxthe maximum length of a path to enumerate (defaults to POSITIVE_INFINITY).
Returns
An iterator 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).
Exceptions
LibsemigroupsExceptionif target or source is not a node in the word graph.
Warning
Copying iterators of this type is expensive. As a consequence, prefix incrementing ++it the returned iterator it significantly cheaper than postfix incrementing it++.
If the word graph represented by 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.
See also
cend_pstislo

◆ cend_pilo()

template<typename Node>
auto cend_pilo ( WordGraph< Node > const & wg)
related

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.

See also
cbegin_pilo

◆ cend_pislo()

template<typename Node>
auto cend_pislo ( WordGraph< Node > const & wg)
related

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.

See also
cbegin_pislo

◆ cend_pstilo()

template<typename Node>
auto cend_pstilo ( WordGraph< Node > const & wg)
related

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.

See also
cbegin_pstilo

◆ cend_pstislo()

template<typename Node>
auto cend_pstislo ( WordGraph< Node > const & wg)
related

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.

See also
cbegin_pstislo

◆ number_of_paths() [1/3]

template<typename Node1, typename Node2>
uint64_t number_of_paths ( WordGraph< Node1 > const & wg,
Node2 source )
related

Returns the number of paths from a source node.

Parameters
wgthe WordGraph.
sourcethe source node.
Returns
A value of type uint64_t.
Exceptions
LibsemigroupsExceptionif source is not a node in the word graph.
Complexity
At worst \(O(nm)\) where \(n\) is the number of nodes and \(m\) is the out-degree of the word graph.
Warning
If the number of paths exceeds 2 ^ 64, then return value of this function will not be correct.

◆ number_of_paths() [2/3]

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 )
related

Returns the number of paths between a pair of nodes with length in a given range.

Parameters
wgthe WordGraph.
sourcethe first node.
targetthe last node.
minthe minimum length of a path.
maxthe maximum length of a path.
lgrthmthe algorithm to use (defaults to: paths::algorithm::automatic).
Returns
A value of type uint64_t.
Exceptions
LibsemigroupsExceptionif:
  • source is not a node in the word graph.
  • target is not a node in the word graph.
  • the algorithm specified by lgrthm is not applicable.
Complexity
The complexity depends on the value of lgrthm as follows:
  • paths::algorithm::dfs: \(O(r)\) where \(r\) is the number of paths in the word graph starting at source
  • paths::algorithm::matrix: at worst \(O(n ^ 3 k)\) where \(n\) is the number of nodes and \(k\) equals max.
  • paths::algorithm::acyclic: at worst \(O(nm)\) where \(n\) is the number of nodes and \(m\) is the out-degree of the word graph (only valid if the subgraph induced by the nodes reachable from source is acyclic)
  • paths::algorithm::trivial: constant (only valid in some circumstances)
  • paths::algorithm::automatic: attempts to select the fastest algorithm of the preceding algorithms and then applies that.
Warning
If lgrthm is paths::algorithm::automatic, then it is not always the case that the fastest algorithm is used.
If the number of paths exceeds 2 ^ 64, then return value of this function will not be correct.

◆ number_of_paths() [3/3]

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 )
related

Returns the number of paths starting at a given node with length in a given range.

Parameters
wgthe WordGraph.
sourcethe first node.
minthe minimum length of a path.
maxthe maximum length of a path.
lgrthmthe algorithm to use (defaults to: paths::algorithm::automatic).
Returns
A value of type uint64_t.
Exceptions
LibsemigroupsExceptionif:
  • source is not a node in the word graph.
  • the algorithm specified by lgrthm is not applicable.
Complexity
The complexity depends on the value of lgrthm as follows:
  • paths::algorithm::dfs: \(O(r)\) where \(r\) is the number of paths in the word graph starting at source
  • paths::algorithm::matrix: at worst \(O(n ^ 3 k)\) where \(n\) is the number of nodes and \(k\) equals max.
  • paths::algorithm::acyclic: at worst \(O(nm)\) where \(n\) is the number of nodes and \(m\) is the out-degree of the word graph (only valid if the subgraph induced by the nodes reachable from source is acyclic)
  • paths::algorithm::trivial: at worst \(O(nm)\) where \(n\) is the number of nodes and \(m\) is the out-degree of the word graph (only valid in some circumstances)
  • paths::algorithm::automatic: attempts to select the fastest algorithm of the preceding algorithms and then applies that.
Warning
If lgrthm is paths::algorithm::automatic, then it is not always the case that the fastest algorithm is used.
If the number of paths exceeds 2 ^ 64, then return value of this function will not be correct.

◆ number_of_paths_algorithm() [1/3]

template<typename Node1, typename Node2>
paths::algorithm number_of_paths_algorithm ( WordGraph< Node1 > const & wg,
Node2 source )
related

Returns the paths::algorithm used by number_of_paths().

Parameters
wgthe WordGraph.
sourcethe source node.
Returns
A value of type paths::algorithm.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant

◆ number_of_paths_algorithm() [2/3]

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 )
related

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)\).

Parameters
wgthe WordGraph.
sourcethe source node.
targetthe target node.
minthe minimum length of paths to count.
maxthe maximum length of paths to count.
Returns
A value of type algorithm.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst \(O(nm)\) where \(n\) is the number of nodes and \(m\) is the out-degree of the word graph.

◆ number_of_paths_algorithm() [3/3]

template<typename Node1, typename Node2>
paths::algorithm number_of_paths_algorithm ( WordGraph< Node1 > const & wg,
Node2 source,
size_t min,
size_t max )
related

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)\).

Parameters
wgthe WordGraph.
sourcethe source node.
minthe minimum length of paths to count.
maxthe maximum length of paths to count.
Returns
A value of type paths::algorithm.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst \(O(nm)\) where \(n\) is the number of nodes and \(m\) is the out-degree of the word graph.

◆ to_human_readable_repr()

template<typename Node>
std::string to_human_readable_repr ( Paths< Node > const & p)
related

Return a human readable representation of a Paths object.

Template Parameters
Nodethe type of the nodes in the underlying WordGraph.
Parameters
pthe Paths object.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

The documentation for this class was generated from the following file: