|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Namespace for shortest path algorithm implementation details. More...
Classes | |
| struct | Beyond_Max_Error |
The std::overflow_error of a painting that leaves out a node whose distance does not fit. More... | |
Functions | |
| template<typename T > | |
| T | checked_add (const T &a, const T &b) |
| Safely add two distance values with overflow checking. | |
| template<typename T > | |
| bool | add_if_fits (const T &a, const T &b, T &out) |
| Adds two distance values when the sum fits. | |
Namespace for shortest path algorithm implementation details.
|
inline |
Adds two distance values when the sum fits.
As checked_add(), for a second operand that is not negative, but a sum beyond max() of an integral type gives false instead of throwing. A floating sum always fits.
| T | Distance type (integral or floating-point). |
| a | First operand. | |
| b | Second operand, not negative. | |
| [out] | out | The sum, when it fits; else untouched. |
Definition at line 151 of file shortest_path_common.H.
References Aleph::and, and out.
Referenced by Aleph::k_shortest_paths_detail::build_suffix_index_digraph(), Aleph::k_shortest_paths_detail::build_suffix_index_with_itor(), Aleph::k_shortest_paths_detail::cost_of_arcs_if_fits(), and Aleph::k_shortest_paths_detail::generate_general_deviation_candidates().
|
inline |
Safely add two distance values with overflow checking.
For integral types, checks for overflow/underflow before performing the addition. For floating-point types, performs regular addition.
| T | Distance type (integral or floating-point). |
| a | First operand. |
| b | Second operand. |
| std::overflow_error | If integer overflow/underflow would occur. |
Definition at line 124 of file shortest_path_common.H.
References ah_overflow_error_if, and Aleph::and.
Referenced by Aleph::Shortest_Path_Base< GT, Distance, Itor, SA, HeapT >::checked_add(), Aleph::negative_cycles_detail::cycle_cost(), Aleph::find_disjoint_negative_cycles(), Aleph::k_shortest_paths_detail::generate_general_deviation_candidates(), Aleph::min_mean_cycle_detail::karp_answer(), Aleph::min_mean_cycle_detail::karp_table(), Aleph::most_negative_cycle_bounded(), and Aleph::negative_cycles_detail::offer_simple_components().