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"
63 using algorithm [[deprecated]] = v4::paths::algorithm;
111 template <
typename Node1,
typename Node2>
117 return detail::const_pilo_iterator<Node1>(&wg,
source,
min,
max);
137 template <
typename Node>
140 return detail::const_pilo_iterator<Node>();
189 template <
typename Node1,
typename Node2>
195 return detail::const_pislo_iterator<Node1>(&wg,
source,
min,
max);
216 template <
typename Node>
219 return detail::const_pislo_iterator<Node>();
263 template <
typename Node1,
typename Node2>
270 if (!v4::word_graph::is_reachable(wg,
source,
target)) {
293 template <
typename Node>
296 return detail::const_pstilo_iterator<Node>();
342 template <
typename Node1,
typename Node2>
349 if (!v4::word_graph::is_reachable(wg,
source,
target)) {
374 template <
typename Node>
377 return detail::const_pstislo_iterator<Node>();
396 template <
typename Node1,
typename Node2>
397 [[deprecated]] [[nodiscard]] paths::algorithm
399 return v4::paths::count_algorithm(wg,
source);
427 template <
typename Node1,
typename Node2>
428 [[deprecated]] [[nodiscard]] uint64_t
430 return v4::paths::count(wg,
source);
457 template <
typename Node1,
typename Node2>
458 [[deprecated]] [[nodiscard]] paths::algorithm
463 return v4::paths::count_algorithm(wg,
source,
min,
max);
513 template <
typename Node1,
typename Node2>
519 v4::paths::algorithm lgrthm = v4::paths::algorithm::automatic) {
549 template <
typename Node1,
typename Node2>
550 [[deprecated]] [[nodiscard]] paths::algorithm
607 template <
typename Node1,
typename Node2>
614 v4::paths::algorithm lgrthm = v4::paths::algorithm::automatic) {
656 template <
typename Node>
677 using const_iterator = std::variant<detail::const_pstislo_iterator<Node>,
678 detail::const_pstilo_iterator<Node>,
679 detail::const_pislo_iterator<Node>,
680 detail::const_pilo_iterator<Node>>;
689 mutable const_iterator _current;
690 mutable const_iterator _end;
691 mutable bool _current_valid;
693 bool set_iterator_no_checks()
const;
795 set_iterator_no_checks();
797 [](
auto& it) ->
auto const& {
return *it; }, _current);
810 std::visit([](
auto& it) { ++it; }, _current);
824 if (!set_iterator_no_checks()) {
827 return _current == _end;
856 [[nodiscard]] uint64_t
count()
const {
860 static constexpr bool is_finite =
true;
861 static constexpr bool is_idempotent =
true;
1014 return min(
this, val);
1043 return max(
this, val);
1071 return order(
this, val);
1097 return *_word_graph;
1101 template <
typename Sub
class>
1103 _current_valid &= (src == _source);
1108 template <
typename Sub
class>
1110 _current_valid &= (trgt == _target);
1115 template <
typename Sub
class>
1117 _current_valid &= (
min == _min);
1122 template <
typename Sub
class>
1124 _current_valid &= (
max == _max);
1129 template <
typename Sub
class>
1137 template <
typename Node>
1144 template <
typename Node>
1159 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:264
Paths(WordGraph< Node > &&) -> Paths< Node >
void next()
Advance to the next path in the range.
Definition paths.hpp:807
typename WordGraph< uint32_t >::size_type size_type
Definition paths.hpp:669
uint32_t node_type
Definition paths.hpp:664
size_type min() const noexcept
Get the minimum length of path in the range.
Definition paths.hpp:1026
word_type const & output_type
Definition paths.hpp:674
Paths(WordGraph< Node > const &) -> Paths< Node >
auto cend_pstilo(WordGraph< Node > const &wg)
Definition paths.hpp:294
Paths(Paths const &)
Default copy constructor.
WordGraph< Node > const & word_graph() const noexcept
The underlying WordGraph.
Definition paths.hpp:1096
Paths(Paths &&)
Default move constructor.
auto cend_pilo(WordGraph< Node > const &wg)
Definition paths.hpp:138
Paths & min(size_type val) noexcept
Definition paths.hpp:1013
paths::algorithm number_of_paths_algorithm(WordGraph< Node1 > const &wg, Node2 source) noexcept
Definition paths.hpp:398
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:745
auto cbegin_pislo(WordGraph< Node1 > const &wg, Node2 source, size_t min=0, size_t max=POSITIVE_INFINITY)
Definition paths.hpp:190
auto cend_pstislo(WordGraph< Node > const &wg)
Definition paths.hpp:375
Paths & max(size_type val) noexcept
Definition paths.hpp:1042
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:922
uint64_t number_of_paths(WordGraph< Node1 > const &wg, Node2 source)
Definition paths.hpp:429
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:1055
bool at_end() const
Check if the range is exhausted.
Definition paths.hpp:823
Paths & source(node_type n)
Definition paths.hpp:908
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:514
Paths & operator=(Paths &&)
Default move assignment operator.
output_type get() const
Get the current path in the range.
Definition paths.hpp:794
Paths & target_no_checks(node_type n) noexcept
Set the target node of every path in the range.
Definition paths.hpp:946
uint64_t count() const
Get the size of the range.
Definition paths.hpp:856
node_type target() const noexcept
Get the current target node of every path in the range.
Definition paths.hpp:983
paths::algorithm number_of_paths_algorithm(WordGraph< Node1 > const &wg, Node2 source, size_t min, size_t max)
Definition paths.hpp:459
Order order() const noexcept
Get the order of the paths in the range.
Definition paths.hpp:1083
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:608
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:112
Paths & target(node_type n)
Definition paths.hpp:967
paths::algorithm number_of_paths_algorithm(WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min, size_t max)
Definition paths.hpp:551
auto cend_pislo(WordGraph< Node > const &wg)
Definition paths.hpp:217
auto cbegin_pstislo(WordGraph< Node1 > const &wg, Node2 source, Node2 target, size_t min=0, size_t max=POSITIVE_INFINITY)
Definition paths.hpp:343
Paths & order(Order val)
Set the order of the paths in the range.
Definition paths.hpp:1070
uint64_t size_hint() const
Get the size of the range.
Paths & init(WordGraph< Node > const &wg)
Reinitialize a Paths object.
Definition paths.hpp:765
Paths & source_no_checks(node_type n) noexcept
Set the source node of every path in the range.
Definition paths.hpp:887
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:61
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