|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Index of the simple cycles of bounded length of a digraph. More...
#include <Bounded_Cycle_Index.H>
Classes | |
| struct | Marks |
| struct | Number_Table |
| struct | Path |
| struct | Shape |
Public Types | |
| using | Arc = typename GT::Arc |
The type of the arcs, const on a view. | |
Public Member Functions | |
| template<class Arc_Less > requires StrictWeakOrder<Arc_Less, Arc *> | |
| Bounded_Cycle_Index (const GT &g, std::initializer_list< size_t > lengths, Arc_Less less, const size_t max_cycles=Default_Max_Cycles) | |
Build the index of the cycles of g with the lengths given, with the arcs in the order of a comparison. | |
| Bounded_Cycle_Index (const GT &g, std::initializer_list< size_t > lengths, const size_t max_cycles=Default_Max_Cycles) | |
Build the index of the cycles of g with the lengths given, with the arcs in the order of the arc iterator of g. | |
| template<class Arc_Less > requires StrictWeakOrder<Arc_Less, Arc *> | |
| Bounded_Cycle_Index (const GT &g, const Array< size_t > &lengths, Arc_Less less, const size_t max_cycles=Default_Max_Cycles) | |
Build the index of the cycles of g with the lengths of an array, with the arcs in the order of a comparison. | |
| Bounded_Cycle_Index (const GT &g, const Array< size_t > &lengths, const size_t max_cycles=Default_Max_Cycles) | |
Build the index of the cycles of g with the lengths of an array, with the arcs in the order of the arc iterator of g. | |
| Bounded_Cycle_Index (const Bounded_Cycle_Index &other) | |
| Copy an index: its catalog, its weights, its stamps and its clock. | |
| Bounded_Cycle_Index (Bounded_Cycle_Index &&other) noexcept | |
| Take the index of another, in constant time and without failing. | |
| Bounded_Cycle_Index & | operator= (const Bounded_Cycle_Index &other) |
| Make the index a copy of another. | |
| Bounded_Cycle_Index & | operator= (Bounded_Cycle_Index &&other) noexcept |
| Take the index of another, in constant time besides freeing what the index had, and without failing. | |
| size_t | num_arcs () const noexcept |
| The number of arcs of the graph when the index was built. | |
| size_t | arc_number (const Arc *a) const |
| The number of an arc of the graph, in O(1) expected. | |
| Arc * | arc (const size_t number) const |
| The arc with a number. | |
| size_t | num_cycles () const noexcept |
| The number of cycles of the catalog. | |
| size_t | num_cycles (const size_t length) const noexcept |
| The number of cycles of a length. | |
| size_t | num_cycles_up_to (const size_t max_length) const noexcept |
The number of cycles whose length is at most max_length: the size of the prefix of the catalog that they are. | |
| bool | has_length (const size_t length) const noexcept |
Return true if length is one of the lengths of the index. | |
| size_t | longest_length () const noexcept |
| The longest length of the set of the index. | |
| size_t | length (const size_t position) const |
| The length of a cycle. | |
| std::span< const uint32_t > | cycle_arcs (const size_t position) const |
| The arcs of a cycle, by their numbers, in its canonical rotation: from the arc of least number, in the order of the cycle. | |
| std::span< const uint32_t > | cycles_of (const size_t arc) const |
| The cycles that go through an arc, by their positions, in ascending order. | |
| void | set_weight (const size_t arc, const double w) |
| Change the weight of an arc, without looking at its cycles. | |
| double | weight (const size_t arc) const |
| The weight of an arc. | |
| double | weight_sum (const size_t position) const |
| The weight of a cycle: the sum of the weights of its arcs, in the order of its canonical rotation. | |
| template<class Op > requires std::invocable<Op &, size_t, double> | |
| size_t | update (const size_t arc, const double w, const double bound, const size_t max_length, Op &&op) |
| Change the weight of an arc and hand the cycles through it whose weight is below a bound. | |
| template<class Op > requires std::invocable<Op &, size_t, double> | |
| size_t | for_each_cycle_below (const Array< size_t > &arcs, const double bound, const size_t max_length, Op &&op) |
| Hand the cycles through any of some arcs whose weight is below a bound, each cycle once. | |
| template<class Op > requires std::invocable<Op &, size_t, double> | |
| size_t | for_each_cycle_below (std::initializer_list< size_t > arcs, const double bound, const size_t max_length, Op &&op) |
| Hand the cycles through any of the arcs of a list whose weight is below a bound, each cycle once. | |
| template<class Op > requires std::invocable<Op &, size_t, double> | |
| size_t | for_each_cycle_below (const double bound, const size_t max_length, Op &&op) const |
| Hand the cycles of the catalog whose weight is below a bound. | |
| uint64_t | clock () const noexcept |
The number of writes of a weight so far: each set_weight(), update() and touch() adds one. | |
| uint64_t | stamp (const size_t arc) const |
The value of clock() when an arc was last written. | |
| void | touch (const size_t arc) |
| Mark an arc as written without changing its weight, for what the caller keeps of its cycles and depends on more than the weight. | |
| bool | is_stale (const size_t position, const uint64_t computed_at) const |
| Return true if an arc of a cycle was written after a moment: what was computed of the cycle then is old. | |
| void | swap (Bounded_Cycle_Index &other) noexcept |
| Exchange two indexes in constant time, without failing: how to replace an index by another built apart, with another set of lengths. | |
Static Public Member Functions | |
| static constexpr double | sum_error_bound (const size_t k, const double max_abs_weight) noexcept |
| A bound of the rounding error of the sum of the weights of a cycle. | |
Static Public Attributes | |
| static constexpr size_t | Max_Length = 8 |
| The longest length of a cycle that an index can hold. | |
| static constexpr size_t | Default_Max_Cycles = size_t(1) << 24 |
| The number of cycles that an index holds, when no other is given. | |
Private Member Functions | |
| template<class Arc_Less > | |
| void | build (const GT &g, const uint32_t lengths, Arc_Less &less, const size_t max_cycles) |
| size_t | length_of (const size_t position) const noexcept |
| size_t | first_arc_of (const size_t position, const size_t k) const noexcept |
| size_t | checked_arc (const size_t arc) const |
| size_t | checked_position (const size_t position) const |
| size_t | longest_up_to (const size_t max_length) const noexcept |
| double | sum_at (const size_t first, const size_t k) const noexcept |
| template<class Number , class Op > | |
| size_t | look_at (const Array< Number > &block, const size_t arc, const double bound, const size_t max_length, const bool skip, Op &op) const |
| template<class Op > | |
| size_t | look_at (const size_t arc, const double bound, const size_t max_length, const bool skip, Op &op) const |
| template<class Op > | |
| size_t | look_at_each (const size_t *arcs, const size_t n, const double bound, const size_t max_length, Op &op) |
Static Private Member Functions | |
| template<class On_Cycle > | |
| static void | extend (const Shape &shape, Path &path, const uint32_t node, On_Cycle &on_cycle) |
| template<class On_Cycle > | |
| static void | enumerate (const Shape &shape, On_Cycle &&on_cycle) |
| template<class It > | |
| static uint32_t | length_bits (It first, const It last) |
| static void | check_weight (const double w) |
| static void | check_bound (const double bound) |
Private Attributes | |
| Number_Table | arc_numbers_ |
| Array< Arc * > | arcs_ |
| uint32_t | lengths_ = 0 |
| size_t | longest_ = 0 |
| size_t | length_first_ [Stride] = {} |
| size_t | arcs_before_ [Stride] = {} |
| Array< uint32_t > | cycle_arcs_ |
| Array< uint32_t > | member_first_ |
| Array< uint32_t > | members_ |
| Array< uint32_t > | group_member_ |
| Array< size_t > | group_first_ |
| Array< uint16_t > | narrow_ |
| Array< uint32_t > | wide_ |
| Array< double > | weight_ |
| Array< uint64_t > | stamp_ |
| uint64_t | clock_ = 0 |
| Array< unsigned char > | done_ |
Static Private Attributes | |
| static constexpr uint32_t | Not_Found = std::numeric_limits<uint32_t>::max() |
| static constexpr size_t | Stride = Max_Length + 2 |
Index of the simple cycles of bounded length of a digraph.
See the description of the file for the catalog, the weights, the filter and its margin.
The index is built in \(O(V + E \log E + C k^2)\) time, with the sort of the arcs at its expected cost, besides the search, which walks each simple path of fewer arcs than the longest length whose first arc is its least one; C is the number of cycles and k their length. It takes \(O(E + C k^2)\) memory: for each arc, the arcs of each of its cycles are kept contiguous, so that a change of the arc reads them in a row. update() takes \(O(c\,k)\) for an arc that is in c cycles.
An index can be copied, assigned, moved and exchanged with swap(). A copy is another index of the same graph, with the weights, the stamps and the clock of the first. An index that is moved from is left without arcs and without cycles.
| GT | the type of the digraph: a graph class of Aleph or a Const_Graph_View of one. |
Definition at line 183 of file Bounded_Cycle_Index.H.
| using Aleph::Bounded_Cycle_Index< GT >::Arc = typename GT::Arc |
The type of the arcs, const on a view.
Definition at line 186 of file Bounded_Cycle_Index.H.
|
inline |
Build the index of the cycles of g with the lengths given, with the arcs in the order of a comparison.
| [in] | g | the digraph, or a view of it. It must outlive the index, with the nodes and the arcs that it has now. |
| [in] | lengths | the lengths of the cycles, each from 1 to Max_Length. |
| [in] | less | the order of the arcs: less(a, b) is true if the arc a takes a number before b. It must be a strict weak order; the arcs that it does not tell apart keep the order of the arc iterator of g. What it throws goes to the caller, and no index is built. |
| [in] | max_cycles | the most cycles that the index may hold. |
| std::domain_error | if g is not directed, if a length is not from 1 to Max_Length or if there is no length. |
| std::length_error | if g has more than max_cycles cycles of those lengths, or more nodes, arcs or arcs of cycles than fit in 32 bits. |
| std::bad_alloc | if there is no memory. |
Definition at line 730 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::build(), and Aleph::Bounded_Cycle_Index< GT >::length_bits().
|
inline |
Build the index of the cycles of g with the lengths given, with the arcs in the order of the arc iterator of g.
| [in] | g | the digraph, or a view of it. It must outlive the index, with the nodes and the arcs that it has now. |
| [in] | lengths | the lengths of the cycles, each from 1 to Max_Length. |
| [in] | max_cycles | the most cycles that the index may hold. |
| std::domain_error | if g is not directed, if a length is not from 1 to Max_Length or if there is no length. |
| std::length_error | if g has more than max_cycles cycles of those lengths, or more nodes, arcs or arcs of cycles than fit in 32 bits. |
| std::bad_alloc | if there is no memory. |
Definition at line 751 of file Bounded_Cycle_Index.H.
|
inline |
Build the index of the cycles of g with the lengths of an array, with the arcs in the order of a comparison.
| [in] | g | the digraph, or a view of it. It must outlive the index, with the nodes and the arcs that it has now. |
| [in] | lengths | the lengths of the cycles, each from 1 to Max_Length. |
| [in] | less | the order of the arcs, a strict weak order; the arcs that it does not tell apart keep the order of the arc iterator of g. What it throws goes to the caller, and no index is built. |
| [in] | max_cycles | the most cycles that the index may hold. |
| std::domain_error | if g is not directed, if a length is not from 1 to Max_Length or if there is no length. |
| std::length_error | if g has more than max_cycles cycles of those lengths, or more nodes, arcs or arcs of cycles than fit in 32 bits. |
| std::bad_alloc | if there is no memory. |
Definition at line 776 of file Bounded_Cycle_Index.H.
References ah_domain_error_if, Aleph::bits(), Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::length_bits(), and Aleph::Array< T >::size().
|
inline |
Build the index of the cycles of g with the lengths of an array, with the arcs in the order of the arc iterator of g.
| [in] | g | the digraph, or a view of it. It must outlive the index, with the nodes and the arcs that it has now. |
| [in] | lengths | the lengths of the cycles, each from 1 to Max_Length. |
| [in] | max_cycles | the most cycles that the index may hold. |
| std::domain_error | if g is not directed, if a length is not from 1 to Max_Length or if there is no length. |
| std::length_error | if g has more than max_cycles cycles of those lengths, or more nodes, arcs or arcs of cycles than fit in 32 bits. |
| std::bad_alloc | if there is no memory. |
Definition at line 802 of file Bounded_Cycle_Index.H.
|
inline |
Copy an index: its catalog, its weights, its stamps and its clock.
The copy is another index of the same graph, which must outlive it too. It is in no query: a copy made by the function that receives the cycles of for_each_cycle_below() hands every cycle that it is asked for afterwards.
| [in] | other | the index to copy. |
| std::bad_alloc | if there is no memory. |
Definition at line 818 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arcs_before_, k, Aleph::Bounded_Cycle_Index< GT >::length_first_, and Aleph::Bounded_Cycle_Index< GT >::Stride.
|
inlinenoexcept |
Take the index of another, in constant time and without failing.
| [in,out] | other | the index to take. It is left without arcs and without cycles: it can be asked, assigned and destroyed. |
Definition at line 841 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arcs_before_, k, Aleph::Bounded_Cycle_Index< GT >::length_first_, and Aleph::Bounded_Cycle_Index< GT >::Stride.
|
inline |
The arc with a number.
| [in] | number | the number of an arc. |
| std::out_of_range | if there is no arc with that number. |
Definition at line 915 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arcs_, and Aleph::Bounded_Cycle_Index< GT >::checked_arc().
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::checked_arc(), Aleph::Bounded_Cycle_Index< GT >::cycles_of(), Aleph::Bounded_Cycle_Index< GT >::extend(), Aleph::Bounded_Cycle_Index< GT >::is_stale(), Aleph::Bounded_Cycle_Index< GT >::look_at(), Aleph::Bounded_Cycle_Index< GT >::look_at(), Aleph::Bounded_Cycle_Index< GT >::set_weight(), Aleph::Bounded_Cycle_Index< GT >::stamp(), TEST(), TEST(), Aleph::Bounded_Cycle_Index< GT >::touch(), TYPED_TEST(), Aleph::Bounded_Cycle_Index< GT >::update(), and Aleph::Bounded_Cycle_Index< GT >::weight().
|
inline |
The number of an arc of the graph, in O(1) expected.
| [in] | a | an arc of the graph of the index. |
num_arcs() - 1. | std::domain_error | if a was not an arc of the graph. |
Definition at line 901 of file Bounded_Cycle_Index.H.
References ah_domain_error_if, Aleph::Bounded_Cycle_Index< GT >::arc_numbers_, Aleph::Bounded_Cycle_Index< GT >::Number_Table::find(), and Aleph::Bounded_Cycle_Index< GT >::Not_Found.
Referenced by TEST().
|
inlineprivate |
Definition at line 392 of file Bounded_Cycle_Index.H.
References ah_domain_error_if, ah_length_error_if, Aleph::and, Aleph::Array< T >::append(), Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::arc_numbers_, arcs, Aleph::Bounded_Cycle_Index< GT >::arcs_, Aleph::Bounded_Cycle_Index< GT >::arcs_before_, Aleph::count(), Aleph::Array< T >::create_reserved(), Aleph::Bounded_Cycle_Index< GT >::cycle_arcs_, Aleph::Bounded_Cycle_Index< GT >::done_, Aleph::Bounded_Cycle_Index< GT >::enumerate(), Aleph::Bounded_Cycle_Index< GT >::first_arc_of(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), Aleph::Bounded_Cycle_Index< GT >::group_first_, Aleph::Bounded_Cycle_Index< GT >::group_member_, GraphCommon< GT, Node, Arc >::is_digraph(), k, Aleph::Bounded_Cycle_Index< GT >::length_first_, Aleph::Bounded_Cycle_Index< GT >::Shape::lengths, Aleph::Bounded_Cycle_Index< GT >::lengths_, Aleph::Bounded_Cycle_Index< GT >::Shape::longest, Aleph::Bounded_Cycle_Index< GT >::longest_, Aleph::Bounded_Cycle_Index< GT >::Max_Length, Aleph::Bounded_Cycle_Index< GT >::member_first_, Aleph::Bounded_Cycle_Index< GT >::members_, Aleph::Bounded_Cycle_Index< GT >::narrow_, Aleph::next(), nodes, Aleph::Bounded_Cycle_Index< GT >::Not_Found, Aleph::Bounded_Cycle_Index< GT >::num_cycles(), Aleph::Bounded_Cycle_Index< GT >::Shape::out_arcs, Aleph::Bounded_Cycle_Index< GT >::Shape::out_first, Aleph::Bounded_Cycle_Index< GT >::Number_Table::put(), Aleph::quicksort_op(), Aleph::Bounded_Cycle_Index< GT >::Shape::source, Aleph::Bounded_Cycle_Index< GT >::stamp_, Aleph::Bounded_Cycle_Index< GT >::Stride, Aleph::Bounded_Cycle_Index< GT >::Shape::target, V, Aleph::Bounded_Cycle_Index< GT >::weight_, and Aleph::Bounded_Cycle_Index< GT >::wide_.
Referenced by Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), and Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index().
|
inlinestaticprivate |
Definition at line 590 of file Bounded_Cycle_Index.H.
References ah_domain_error_if.
Referenced by Aleph::Bounded_Cycle_Index< GT >::for_each_cycle_below(), Aleph::Bounded_Cycle_Index< GT >::look_at_each(), and Aleph::Bounded_Cycle_Index< GT >::update().
|
inlinestaticprivate |
Definition at line 584 of file Bounded_Cycle_Index.H.
References ah_domain_error_if, and w.
Referenced by Aleph::Bounded_Cycle_Index< GT >::set_weight().
|
inlineprivate |
Definition at line 570 of file Bounded_Cycle_Index.H.
References ah_out_of_range_error_if, Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::arcs_, and Aleph::Array< T >::size().
Referenced by Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::cycles_of(), Aleph::Bounded_Cycle_Index< GT >::look_at_each(), Aleph::Bounded_Cycle_Index< GT >::set_weight(), Aleph::Bounded_Cycle_Index< GT >::stamp(), Aleph::Bounded_Cycle_Index< GT >::touch(), and Aleph::Bounded_Cycle_Index< GT >::weight().
|
inlineprivate |
Definition at line 577 of file Bounded_Cycle_Index.H.
References ah_out_of_range_error_if, and Aleph::Bounded_Cycle_Index< GT >::num_cycles().
Referenced by Aleph::Bounded_Cycle_Index< GT >::cycle_arcs(), Aleph::Bounded_Cycle_Index< GT >::length(), and Aleph::Bounded_Cycle_Index< GT >::weight_sum().
|
inlinenoexcept |
The number of writes of a weight so far: each set_weight(), update() and touch() adds one.
Definition at line 1191 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::clock_.
Referenced by TEST().
|
inline |
The arcs of a cycle, by their numbers, in its canonical rotation: from the arc of least number, in the order of the cycle.
| [in] | position | the position of a cycle in the catalog. |
swap() takes that memory to the other index. | std::out_of_range | if there is no cycle at that position. |
Definition at line 973 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::checked_position(), Aleph::Bounded_Cycle_Index< GT >::cycle_arcs_, Aleph::Bounded_Cycle_Index< GT >::first_arc_of(), k, and Aleph::Bounded_Cycle_Index< GT >::length_of().
Referenced by Aleph::Bounded_Cycle_Index< GT >::is_stale(), TEST(), TEST(), TYPED_TEST(), TYPED_TEST(), and TYPED_TEST().
|
inline |
The cycles that go through an arc, by their positions, in ascending order.
| [in] | arc | the number of an arc. |
swap() takes that memory to the other index. | std::out_of_range | if there is no arc with that number. |
Definition at line 989 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::checked_arc(), Aleph::Bounded_Cycle_Index< GT >::member_first_, and Aleph::Bounded_Cycle_Index< GT >::members_.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TYPED_TEST(), and TYPED_TEST().
|
inlinestaticprivate |
Definition at line 354 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::Path::arcs, Aleph::Bounded_Cycle_Index< GT >::extend(), Aleph::Bounded_Cycle_Index< GT >::Shape::lengths, Aleph::Bounded_Cycle_Index< GT >::Shape::longest, Aleph::Bounded_Cycle_Index< GT >::Path::n, Aleph::Bounded_Cycle_Index< GT >::Path::nodes, Aleph::Bounded_Cycle_Index< GT >::num_arcs(), Aleph::Array< T >::size(), Aleph::Bounded_Cycle_Index< GT >::Shape::source, and Aleph::Bounded_Cycle_Index< GT >::Shape::target.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build().
|
inlinestaticprivate |
Definition at line 316 of file Bounded_Cycle_Index.H.
References Aleph::and, Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::Path::arcs, Aleph::Bounded_Cycle_Index< GT >::extend(), Aleph::Bounded_Cycle_Index< GT >::Shape::lengths, Aleph::Bounded_Cycle_Index< GT >::Shape::longest, Aleph::Bounded_Cycle_Index< GT >::Path::n, Aleph::Bounded_Cycle_Index< GT >::Path::nodes, Aleph::Bounded_Cycle_Index< GT >::Shape::out_arcs, Aleph::Bounded_Cycle_Index< GT >::Shape::out_first, and Aleph::Bounded_Cycle_Index< GT >::Shape::target.
Referenced by Aleph::Bounded_Cycle_Index< GT >::enumerate(), and Aleph::Bounded_Cycle_Index< GT >::extend().
|
inlineprivatenoexcept |
Definition at line 565 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arcs_before_, k, and Aleph::Bounded_Cycle_Index< GT >::length_first_.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::cycle_arcs(), Aleph::Bounded_Cycle_Index< GT >::for_each_cycle_below(), and Aleph::Bounded_Cycle_Index< GT >::weight_sum().
|
inline |
Hand the cycles through any of some arcs whose weight is below a bound, each cycle once.
It is how to look at the cycles after set_weight() has changed several arcs: no cycle is seen with only a part of the changes. op(position, sum) is called once for each cycle that goes through any of the arcs, whose length is at most max_length and whose sum is below bound: by arc, in the order given, and by ascending position among those of an arc. It must not change the index. If it throws, the cycles that were not reached are not handed, and the index is ready for another query.
| [in] | arcs | the numbers of the arcs; a number may be repeated. |
| [in] | bound | a cycle is handed if its sum is less than it. |
| [in] | max_length | the longest length of the cycles to look at. |
| [in] | op | the function that receives each cycle. |
| std::out_of_range | if there is no arc with one of the numbers; no cycle is handed then. |
| std::domain_error | if bound is not a number. |
op takes, for n arcs given and the c cycles of at most max_length arcs, of k arcs each, counted once for each different arc given that they go through: a cycle through several of those arcs is read for each of them and handed once. An arc that is given again costs \(O(1)\). Definition at line 1099 of file Bounded_Cycle_Index.H.
References arcs, and Aleph::Bounded_Cycle_Index< GT >::look_at_each().
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), and TYPED_TEST().
|
inline |
Hand the cycles of the catalog whose weight is below a bound.
op(position, sum) is called for each cycle whose length is at most max_length and whose sum is below bound, in ascending order of position. If it throws, the cycles that were not reached are not handed.
| [in] | bound | a cycle is handed if its sum is less than it. |
| [in] | max_length | the longest length of the cycles to look at. |
| [in] | op | the function that receives each cycle. |
| std::domain_error | if bound is not a number. |
op takes, for the C cycles of the catalog of at most max_length arcs, of k arcs each. Definition at line 1151 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::check_bound(), Aleph::Bounded_Cycle_Index< GT >::first_arc_of(), k, Aleph::Bounded_Cycle_Index< GT >::length_first_, Aleph::Bounded_Cycle_Index< GT >::longest_up_to(), Aleph::sum(), and Aleph::Bounded_Cycle_Index< GT >::sum_at().
|
inline |
Hand the cycles through any of the arcs of a list whose weight is below a bound, each cycle once.
It is for_each_cycle_below() for an array of arcs, with the arcs written in the call: for_each_cycle_below({a, b}, bound, m, op).
| [in] | arcs | the numbers of the arcs; a number may be repeated. |
| [in] | bound | a cycle is handed if its sum is less than it. |
| [in] | max_length | the longest length of the cycles to look at. |
| [in] | op | the function that receives each cycle. |
| std::out_of_range | if there is no arc with one of the numbers; no cycle is handed then. |
| std::domain_error | if bound is not a number. |
op takes, as with an array of arcs: n arcs given, and c cycles of k arcs counted once for each different arc given that they go through. Definition at line 1126 of file Bounded_Cycle_Index.H.
References arcs, and Aleph::Bounded_Cycle_Index< GT >::look_at_each().
|
inlinenoexcept |
Return true if length is one of the lengths of the index.
Definition at line 944 of file Bounded_Cycle_Index.H.
References Aleph::and, Aleph::Bounded_Cycle_Index< GT >::length(), Aleph::Bounded_Cycle_Index< GT >::lengths_, and Aleph::Bounded_Cycle_Index< GT >::Max_Length.
Referenced by TEST().
|
inline |
Return true if an arc of a cycle was written after a moment: what was computed of the cycle then is old.
| [in] | position | the position of a cycle in the catalog. |
| [in] | computed_at | the value of clock() at that moment. |
stamp() of one of its arcs is greater. | std::out_of_range | if there is no cycle at that position. |
Definition at line 1222 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::cycle_arcs(), and Aleph::Bounded_Cycle_Index< GT >::stamp_.
|
inline |
The length of a cycle.
| [in] | position | the position of a cycle in the catalog. |
| std::out_of_range | if there is no cycle at that position. |
Definition at line 958 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::checked_position(), and Aleph::Bounded_Cycle_Index< GT >::length_of().
Referenced by Aleph::Bounded_Cycle_Index< GT >::has_length(), Aleph::Bounded_Cycle_Index< GT >::num_cycles(), TYPED_TEST(), and TYPED_TEST().
|
inlinestaticprivate |
Definition at line 376 of file Bounded_Cycle_Index.H.
References ah_domain_error_if, Aleph::bits(), k, and Aleph::Bounded_Cycle_Index< GT >::Max_Length.
Referenced by Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), and Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index().
|
inlineprivatenoexcept |
Definition at line 556 of file Bounded_Cycle_Index.H.
References k, and Aleph::Bounded_Cycle_Index< GT >::length_first_.
Referenced by Aleph::Bounded_Cycle_Index< GT >::cycle_arcs(), Aleph::Bounded_Cycle_Index< GT >::length(), and Aleph::Bounded_Cycle_Index< GT >::weight_sum().
|
inlinenoexcept |
The longest length of the set of the index.
Definition at line 950 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::longest_.
Referenced by TEST().
|
inlineprivatenoexcept |
Definition at line 596 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::longest_.
Referenced by Aleph::Bounded_Cycle_Index< GT >::for_each_cycle_below(), Aleph::Bounded_Cycle_Index< GT >::look_at_each(), and Aleph::Bounded_Cycle_Index< GT >::update().
|
inlineprivate |
Definition at line 616 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::done_, Aleph::Bounded_Cycle_Index< GT >::group_first_, Aleph::Bounded_Cycle_Index< GT >::group_member_, k, Aleph::Bounded_Cycle_Index< GT >::members_, Aleph::Bounded_Cycle_Index< GT >::Stride, Aleph::sum(), and Aleph::Bounded_Cycle_Index< GT >::weight_.
Referenced by Aleph::Bounded_Cycle_Index< GT >::look_at(), Aleph::Bounded_Cycle_Index< GT >::look_at_each(), and Aleph::Bounded_Cycle_Index< GT >::update().
|
inlineprivate |
Definition at line 664 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::look_at(), Aleph::Bounded_Cycle_Index< GT >::narrow_, Aleph::Array< T >::size(), and Aleph::Bounded_Cycle_Index< GT >::wide_.
|
inlineprivate |
Definition at line 688 of file Bounded_Cycle_Index.H.
References arcs, Aleph::Bounded_Cycle_Index< GT >::check_bound(), Aleph::Bounded_Cycle_Index< GT >::checked_arc(), Aleph::Bounded_Cycle_Index< GT >::done_, Aleph::Bounded_Cycle_Index< GT >::longest_up_to(), and Aleph::Bounded_Cycle_Index< GT >::look_at().
Referenced by Aleph::Bounded_Cycle_Index< GT >::for_each_cycle_below(), and Aleph::Bounded_Cycle_Index< GT >::for_each_cycle_below().
|
inlinenoexcept |
The number of arcs of the graph when the index was built.
Definition at line 893 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arcs_, and Aleph::Array< T >::size().
Referenced by Aleph::Bounded_Cycle_Index< GT >::enumerate(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TYPED_TEST(), TYPED_TEST(), and TYPED_TEST().
|
inlinenoexcept |
The number of cycles of the catalog.
Definition at line 918 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::length_first_, and Aleph::Bounded_Cycle_Index< GT >::Max_Length.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::checked_position(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TYPED_TEST(), and TYPED_TEST().
|
inlinenoexcept |
The number of cycles of a length.
| [in] | length | a length. |
Definition at line 926 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::length(), Aleph::Bounded_Cycle_Index< GT >::length_first_, and Aleph::Bounded_Cycle_Index< GT >::Max_Length.
|
inlinenoexcept |
The number of cycles whose length is at most max_length: the size of the prefix of the catalog that they are.
| [in] | max_length | a length. |
Definition at line 938 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::length_first_, and Aleph::Bounded_Cycle_Index< GT >::Max_Length.
|
inlinenoexcept |
Take the index of another, in constant time besides freeing what the index had, and without failing.
| [in,out] | other | the index to take. It is left without arcs and without cycles. |
Definition at line 886 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::swap().
|
inline |
Make the index a copy of another.
The copy is made apart and then exchanged with the index: if there is no memory for it, the index keeps all that it had. For a moment both are in memory.
| [in] | other | the index to copy. |
| std::bad_alloc | if there is no memory; the index does not change. |
Definition at line 872 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::swap().
|
inline |
Change the weight of an arc, without looking at its cycles.
| [in] | arc | the number of an arc. |
| [in] | w | its weight; \(+\infty\) for an arc that cannot be used. |
| std::out_of_range | if there is no arc with that number. |
| std::domain_error | if w is not a number or is \(-\infty\). |
Definition at line 1005 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::check_weight(), Aleph::Bounded_Cycle_Index< GT >::checked_arc(), Aleph::Bounded_Cycle_Index< GT >::clock_, Aleph::Bounded_Cycle_Index< GT >::stamp_, w, and Aleph::Bounded_Cycle_Index< GT >::weight_.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TYPED_TEST(), TYPED_TEST(), and Aleph::Bounded_Cycle_Index< GT >::update().
|
inline |
The value of clock() when an arc was last written.
| [in] | arc | the number of an arc. |
| std::out_of_range | if there is no arc with that number. |
Definition at line 1199 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::checked_arc(), and Aleph::Bounded_Cycle_Index< GT >::stamp_.
Referenced by TEST().
|
inlineprivatenoexcept |
Definition at line 603 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::cycle_arcs_, k, Aleph::sum(), and Aleph::Bounded_Cycle_Index< GT >::weight_.
Referenced by Aleph::Bounded_Cycle_Index< GT >::for_each_cycle_below(), and Aleph::Bounded_Cycle_Index< GT >::weight_sum().
|
inlinestaticconstexprnoexcept |
A bound of the rounding error of the sum of the weights of a cycle.
The sum of k weights of magnitude at most max_abs_weight, as the index adds them, is within this of their exact sum, provided that k * max_abs_weight is finite. It says nothing of the error of each weight, which is of who computes it.
| [in] | k | the number of arcs of the cycle. |
| [in] | max_abs_weight | a bound of the magnitude of each weight. |
Definition at line 1174 of file Bounded_Cycle_Index.H.
References k.
Referenced by TEST().
|
inlinenoexcept |
Exchange two indexes in constant time, without failing: how to replace an index by another built apart, with another set of lengths.
The ranges that cycle_arcs() and cycles_of() gave go with their memory: those of this index are of other afterwards.
| [in,out] | other | the other index. |
Definition at line 1239 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc_numbers_, Aleph::Bounded_Cycle_Index< GT >::arcs_, Aleph::Bounded_Cycle_Index< GT >::arcs_before_, Aleph::Bounded_Cycle_Index< GT >::clock_, Aleph::Bounded_Cycle_Index< GT >::cycle_arcs_, Aleph::Bounded_Cycle_Index< GT >::done_, Aleph::Bounded_Cycle_Index< GT >::group_first_, Aleph::Bounded_Cycle_Index< GT >::group_member_, Aleph::Bounded_Cycle_Index< GT >::length_first_, Aleph::Bounded_Cycle_Index< GT >::lengths_, Aleph::Bounded_Cycle_Index< GT >::longest_, Aleph::Bounded_Cycle_Index< GT >::member_first_, Aleph::Bounded_Cycle_Index< GT >::members_, Aleph::Bounded_Cycle_Index< GT >::narrow_, Aleph::Bounded_Cycle_Index< GT >::stamp_, Aleph::Array< T >::swap(), Aleph::Bounded_Cycle_Index< GT >::Number_Table::swap(), Aleph::Bounded_Cycle_Index< GT >::weight_, and Aleph::Bounded_Cycle_Index< GT >::wide_.
Referenced by Aleph::Bounded_Cycle_Index< GT >::operator=(), Aleph::Bounded_Cycle_Index< GT >::operator=(), TEST(), and TEST().
|
inline |
Mark an arc as written without changing its weight, for what the caller keeps of its cycles and depends on more than the weight.
| [in] | arc | the number of an arc. |
| std::out_of_range | if there is no arc with that number. |
Definition at line 1208 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::checked_arc(), Aleph::Bounded_Cycle_Index< GT >::clock_, and Aleph::Bounded_Cycle_Index< GT >::stamp_.
|
inline |
Change the weight of an arc and hand the cycles through it whose weight is below a bound.
op(position, sum) is called for each cycle of the arc whose length is at most max_length and whose sum is below bound, in ascending order of position. It must not change the index. If it throws, the weight is changed and the cycles that were not reached are not handed.
| [in] | arc | the number of an arc. |
| [in] | w | its weight; \(+\infty\) for an arc that cannot be used. |
| [in] | bound | a cycle is handed if its sum is less than it; see the description of the file for its margin. |
| [in] | max_length | the longest length of the cycles to look at. |
| [in] | op | the function that receives each cycle. |
| std::out_of_range | if there is no arc with that number. |
| std::domain_error | if w is not a number or is \(-\infty\), or if bound is not a number. |
op takes, for the c cycles of the arc of at most max_length arcs, of k arcs each: the weight of each of their arcs is read. Definition at line 1062 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::check_bound(), Aleph::Bounded_Cycle_Index< GT >::longest_up_to(), Aleph::Bounded_Cycle_Index< GT >::look_at(), Aleph::Bounded_Cycle_Index< GT >::set_weight(), and w.
Referenced by TEST(), TEST(), TEST(), TEST(), and TYPED_TEST().
|
inline |
The weight of an arc.
| [in] | arc | the number of an arc. |
| std::out_of_range | if there is no arc with that number. |
Definition at line 1018 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::arc(), Aleph::Bounded_Cycle_Index< GT >::checked_arc(), and Aleph::Bounded_Cycle_Index< GT >::weight_.
Referenced by TEST(), TEST(), TEST(), and TYPED_TEST().
|
inline |
The weight of a cycle: the sum of the weights of its arcs, in the order of its canonical rotation.
It is the number that update() and for_each_cycle_below() hand for the cycle, with the same weights.
| [in] | position | the position of a cycle in the catalog. |
| std::out_of_range | if there is no cycle at that position. |
Definition at line 1030 of file Bounded_Cycle_Index.H.
References Aleph::Bounded_Cycle_Index< GT >::checked_position(), Aleph::Bounded_Cycle_Index< GT >::first_arc_of(), k, Aleph::Bounded_Cycle_Index< GT >::length_of(), and Aleph::Bounded_Cycle_Index< GT >::sum_at().
Referenced by TEST(), TEST(), TEST(), and TYPED_TEST().
|
private |
Definition at line 289 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::arc_number(), Aleph::Bounded_Cycle_Index< GT >::build(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
|
private |
Definition at line 294 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::first_arc_of(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 310 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::clock(), Aleph::Bounded_Cycle_Index< GT >::set_weight(), Aleph::Bounded_Cycle_Index< GT >::swap(), and Aleph::Bounded_Cycle_Index< GT >::touch().
|
private |
Definition at line 295 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::cycle_arcs(), Aleph::Bounded_Cycle_Index< GT >::sum_at(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
staticconstexpr |
The number of cycles that an index holds, when no other is given.
Definition at line 192 of file Bounded_Cycle_Index.H.
|
private |
Definition at line 311 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::look_at(), Aleph::Bounded_Cycle_Index< GT >::look_at_each(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 304 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::look_at(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 303 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::look_at(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 293 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::first_arc_of(), Aleph::Bounded_Cycle_Index< GT >::for_each_cycle_below(), Aleph::Bounded_Cycle_Index< GT >::length_of(), Aleph::Bounded_Cycle_Index< GT >::num_cycles(), Aleph::Bounded_Cycle_Index< GT >::num_cycles(), Aleph::Bounded_Cycle_Index< GT >::num_cycles_up_to(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 291 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::has_length(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 292 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::longest_length(), Aleph::Bounded_Cycle_Index< GT >::longest_up_to(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
staticconstexpr |
The longest length of a cycle that an index can hold.
Definition at line 189 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::has_length(), Aleph::Bounded_Cycle_Index< GT >::length_bits(), Aleph::Bounded_Cycle_Index< GT >::num_cycles(), Aleph::Bounded_Cycle_Index< GT >::num_cycles(), and Aleph::Bounded_Cycle_Index< GT >::num_cycles_up_to().
|
private |
Definition at line 296 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::cycles_of(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 297 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::cycles_of(), Aleph::Bounded_Cycle_Index< GT >::look_at(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
private |
Definition at line 305 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::look_at(), and Aleph::Bounded_Cycle_Index< GT >::swap().
|
staticconstexprprivate |
Definition at line 198 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::arc_number(), Aleph::Bounded_Cycle_Index< GT >::build(), and Aleph::Bounded_Cycle_Index< GT >::Number_Table::find().
|
private |
Definition at line 309 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::is_stale(), Aleph::Bounded_Cycle_Index< GT >::set_weight(), Aleph::Bounded_Cycle_Index< GT >::stamp(), Aleph::Bounded_Cycle_Index< GT >::swap(), and Aleph::Bounded_Cycle_Index< GT >::touch().
|
staticconstexprprivate |
Definition at line 199 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), Aleph::Bounded_Cycle_Index< GT >::Bounded_Cycle_Index(), Aleph::Bounded_Cycle_Index< GT >::build(), and Aleph::Bounded_Cycle_Index< GT >::look_at().
|
private |
Definition at line 308 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::look_at(), Aleph::Bounded_Cycle_Index< GT >::set_weight(), Aleph::Bounded_Cycle_Index< GT >::sum_at(), Aleph::Bounded_Cycle_Index< GT >::swap(), and Aleph::Bounded_Cycle_Index< GT >::weight().
|
private |
Definition at line 306 of file Bounded_Cycle_Index.H.
Referenced by Aleph::Bounded_Cycle_Index< GT >::build(), Aleph::Bounded_Cycle_Index< GT >::look_at(), and Aleph::Bounded_Cycle_Index< GT >::swap().