27#ifndef LIBSEMIGROUPS_PATHS_HPP_
28#define LIBSEMIGROUPS_PATHS_HPP_
41#include "constants.hpp"
43#include "exception.hpp"
45#include "paths-count.hpp"
48#include "word-graph-helpers.hpp"
49#include "word-graph.hpp"
50#include "word-range.hpp"
52#include "detail/containers.hpp"
53#include "detail/path-iterators.hpp"
64 using algorithm [[deprecated]] = v4::paths::algorithm;
112 template <
typename Node1,
typename Node2>
118 return detail::const_pilo_iterator<Node1>(&wg,
source,
min,
max);
138 template <
typename Node>
141 return detail::const_pilo_iterator<Node>();
190 template <
typename Node1,
typename Node2>
196 return detail::const_pislo_iterator<Node1>(&wg,
source,
min,
max);
217 template <
typename Node>
220 return detail::const_pislo_iterator<Node>();
264 template <
typename Node1,
typename Node2>
271 if (!v4::word_graph::is_reachable(wg,
source,
target)) {
294 template <
typename Node>
297 return detail::const_pstilo_iterator<Node>();
343 template <
typename Node1,
typename Node2>
350 if (!v4::word_graph::is_reachable(wg,
source,
target)) {
375 template <
typename Node>
378 return detail::const_pstislo_iterator<Node>();
397 template <
typename Node1,
typename Node2>
398 [[deprecated]] [[nodiscard]] paths::algorithm
400 return v4::paths::count_algorithm(wg,
source);
428 template <
typename Node1,
typename Node2>
429 [[deprecated]] [[nodiscard]] uint64_t
431 return v4::paths::count(wg,
source);
458 template <
typename Node1,
typename Node2>
459 [[deprecated]] [[nodiscard]] paths::algorithm
464 return v4::paths::count_algorithm(wg,
source,
min,
max);
514 template <
typename Node1,
typename Node2>
520 v4::paths::algorithm lgrthm = v4::paths::algorithm::automatic) {
550 template <
typename Node1,
typename Node2>
551 [[deprecated]] [[nodiscard]] paths::algorithm
608 template <
typename Node1,
typename Node2>
615 v4::paths::algorithm lgrthm = v4::paths::algorithm::automatic) {
657 template <
typename Node>
678 using const_iterator = std::variant<detail::const_pstislo_iterator<Node>,
679 detail::const_pstilo_iterator<Node>,
680 detail::const_pislo_iterator<Node>,
681 detail::const_pilo_iterator<Node>>;
690 mutable const_iterator _current;
691 mutable const_iterator _end;
692 mutable bool _current_valid;
694 bool set_iterator_no_checks()
const;
796 set_iterator_no_checks();
798 [](
auto& it) ->
auto const& {
return *it; }, _current);
811 std::visit([](
auto& it) { ++it; }, _current);
825 if (!set_iterator_no_checks()) {
828 return _current == _end;
857 [[nodiscard]] uint64_t
count()
const {
861 static constexpr bool is_finite =
true;
862 static constexpr bool is_idempotent =
true;
1015 return min(
this, val);
1044 return max(
this, val);
1072 return order(
this, val);
1098 return *_word_graph;
1102 template <
typename Sub
class>
1104 _current_valid &= (src == _source);
1109 template <
typename Sub
class>
1111 _current_valid &= (trgt == _target);
1116 template <
typename Sub
class>
1118 _current_valid &= (
min == _min);
1123 template <
typename Sub
class>
1125 _current_valid &= (
max == _max);
1130 template <
typename Sub
class>
1138 template <
typename Node>
1145 template <
typename Node>
1160 template <
typename Node>
auto cbegin_pstilo(WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min=0, size_t max=POSITIVE_INFINITY)
Definition paths.hpp:265
Paths(WordGraph< Node > &&) -> Paths< Node >
void next()
Advance to the next path in the range.
Definition paths.hpp:808
typename WordGraph< uint32_t >::size_type size_type
Definition paths.hpp:670
uint32_t node_type
Definition paths.hpp:665
size_type min() const noexcept
Get the minimum length of path in the range.
Definition paths.hpp:1027
word_type const & output_type
Definition paths.hpp:675
Paths(WordGraph< Node > const &) -> Paths< Node >
auto cend_pstilo(WordGraph< Node > const &wg)
Definition paths.hpp:295
Paths(Paths const &)
Default copy constructor.
WordGraph< Node > const & word_graph() const noexcept
The underlying WordGraph.
Definition paths.hpp:1097
Paths(Paths &&)
Default move constructor.
auto cend_pilo(WordGraph< Node > const &wg)
Definition paths.hpp:139
Paths & min(size_type val) noexcept
Definition paths.hpp:1014
paths::algorithm number_of_paths_algorithm(WordGraph< Node1 > const &wg, Node2 source) noexcept
Definition paths.hpp:399
std::string to_human_readable_repr(Paths< Node > const &p)
Return a human readable representation of a Paths object.
Paths(WordGraph< Node > const &wg)
Construct from a WordGraph.
Definition paths.hpp:746
auto cbegin_pislo(WordGraph< Node1 > const &wg, Node2 source, size_t min=0, size_t max=POSITIVE_INFINITY)
Definition paths.hpp:191
auto cend_pstislo(WordGraph< Node > const &wg)
Definition paths.hpp:376
Paths & max(size_type val) noexcept
Definition paths.hpp:1043
Paths & operator=(Paths const &)
Default copy assignment operator.
node_type source() const noexcept
Get the current source node of every path in the range.
Definition paths.hpp:923
uint64_t number_of_paths(WordGraph< Node1 > const &wg, Node2 source)
Definition paths.hpp:430
node_type current_target() const
Get the current target node of the path labelled by get.
size_type max() const noexcept
Get the maximum length of path in the range.
Definition paths.hpp:1056
bool at_end() const
Check if the range is exhausted.
Definition paths.hpp:824
Paths & source(node_type n)
Definition paths.hpp:909
void throw_if_source_undefined() const
Throw an exception if the source node has not been defined (using source).
uint64_t number_of_paths(WordGraph< Node1 > const &wg, Node2 source, size_t min, size_t max, v4::paths::algorithm lgrthm=v4::paths::algorithm::automatic)
Definition paths.hpp:515
Paths & operator=(Paths &&)
Default move assignment operator.
output_type get() const
Get the current path in the range.
Definition paths.hpp:795
Paths & target_no_checks(node_type n) noexcept
Set the target node of every path in the range.
Definition paths.hpp:947
uint64_t count() const
Get the size of the range.
Definition paths.hpp:857
node_type target() const noexcept
Get the current target node of every path in the range.
Definition paths.hpp:984
paths::algorithm number_of_paths_algorithm(WordGraph< Node1 > const &wg, Node2 source, size_t min, size_t max)
Definition paths.hpp:460
Order order() const noexcept
Get the order of the paths in the range.
Definition paths.hpp:1084
uint64_t number_of_paths(WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min, size_t max, v4::paths::algorithm lgrthm=v4::paths::algorithm::automatic)
Definition paths.hpp:609
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).
Definition paths.hpp:113
Paths & target(node_type n)
Definition paths.hpp:968
paths::algorithm number_of_paths_algorithm(WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min, size_t max)
Definition paths.hpp:552
auto cend_pislo(WordGraph< Node > const &wg)
Definition paths.hpp:218
auto cbegin_pstislo(WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min=0, size_t max=POSITIVE_INFINITY)
Definition paths.hpp:344
Paths & order(Order val)
Set the order of the paths in the range.
Definition paths.hpp:1071
uint64_t size_hint() const
Get the size of the range.
Paths & init(WordGraph< Node > const &wg)
Reinitialize a Paths object.
Definition paths.hpp:766
Paths & source_no_checks(node_type n) noexcept
Set the source node of every path in the range.
Definition paths.hpp:888
Class for representing word graphs.
Definition word-graph.hpp:83
std::size_t size_type
Unsigned integer type.
Definition word-graph.hpp:105
Undefined const UNDEFINED
Value for something undefined.
PositiveInfinity const POSITIVE_INFINITY
Value for positive infinity.
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:99
Order
The possible orderings of words and strings.
Definition order.hpp:54
Namespace containing helper functions for the Paths class.
Definition paths.hpp:62
void throw_if_node_out_of_bounds(WordGraph< Node1 > const &wg, Node2 n)
Throws if a node is out of bounds.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44