95# ifndef FLOYD_WARSHALL_H
96# define FLOYD_WARSHALL_H
225 <<
"Floyd_All_Shortest_Paths::index_node() node not found";
251 for (
typename GT::Node_Iterator it(
g); it.has_curr(); it.next_ne())
259 for (
long i = 0; i <
n; ++i)
260 for (
long j = 0; j <
n; ++j)
263 for (
long i = 0; i <
n; ++i)
266 for (
long j = 0; j <
n; ++j)
276 Arc *arc =
arcs.search_directed(src, tgt);
289 for (
long k = 0;
k <
n; ++
k)
290 for (
long i = 0; i <
n; ++i)
293 for (
long j = 0; j <
n; ++j)
307 if constexpr (std::numeric_limits<Distance_Type>::is_integer)
309 if constexpr (std::numeric_limits<Distance_Type>::is_signed)
337 for (
long idx = 0; idx <
n; ++idx)
338 if (
dist(idx, idx) < 0)
365 std::stringstream
ss;
382 for (
int i = 0; i <
n; ++i)
384 for (
int j = 0; j <
n; ++j)
408 <<
"Source index out of range";
410 <<
"Target index out of range";
Exception handling system with formatted messages for Aleph-w.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
Standard functor implementations and comparison objects.
High-level sorting functions for Aleph containers.
Default distance accessor for arc weights.
size_t size() const noexcept
Return the current dimension of array.
T & access(const size_t i) const noexcept
Fast access without checking allocation and bound_min_clock checking.
void reserve(const size_t l, const size_t r)
Allocate a range of entries.
Dynamic matrix with sparse storage.
void allocate()
Pre-allocate memory for the entire matrix.
constexpr size_t rows() const noexcept
Get the number of rows.
T & access(const size_t i, const size_t j)
Direct access to an allocated entry.
Compute the all-pairs shortest path distance matrix and the path reconstruction matrix for a graph g ...
DynMatrix< Distance_Type > dist
Path< GT > get_min_path(const long src_idx, const long tgt_idx) const
Reconstruct the shortest path between two nodes by matrix indices.
DynMatrix< long > path_mat
const DynMatrix< Distance_Type > & get_dist_mat() const noexcept
Get the distance matrix.
Node * select_node(long i) const noexcept
Get the graph node at a given matrix index.
constexpr bool has_negative_cycle() const noexcept
Check if the graph contains a negative cycle.
std::string entry(const Distance_Type &e) const
Convert a distance value to string representation.
Path< GT > get_min_path(typename GT::Node *src, typename GT::Node *tgt) const
Reconstruct the shortest path between two nodes.
Distance::Distance_Type Distance_Type
Floyd_All_Shortest_Paths(const GT &g, SA &&sa=SA())
Construct Floyd-Warshall solver with rvalue arc filter.
Floyd_All_Shortest_Paths(const GT &__g, SA &__sa)
Construct Floyd-Warshall solver for all-pairs shortest paths.
const DynMatrix< long > & get_path_mat() const noexcept
Get the path reconstruction matrix.
long index_node(Node *p) const
Return the adjacency-matrix index corresponding to node p.
DynArray< Node * > get_nodes() const noexcept
Get the array of graph nodes.
static void print(const DynMatrix< Distance_Type > &dist)
Print a distance matrix to standard output.
Index for fast arc lookup by its endpoint nodes.
void append_directed(Node *p)
Append a node to a directed path.
List_Graph< Graph_Node< int >, Graph_Arc< int > > GT
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_max_function > > max(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
DynArray< Graph::Arc * > arcs
Main namespace for Aleph-w library functions.
DynArray< T > & in_place_sort(DynArray< T > &c, Cmp cmp=Cmp())
Sorts a DynArray in place.
bool binary_search(Itor beg, Itor end, const T &value)
Binary search for a value.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Default filter for filtered iterators on arcs.
Arc of graph implemented with double-linked adjacency lists.
Dynamic matrix with lazy allocation.
Generic graph and digraph implementations.
Utility algorithms and operations for graphs.
Arc indexing for fast lookup by endpoint nodes.