Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA > Class Template Reference

Compute the all-pairs shortest path distance matrix and the path reconstruction matrix for a graph g using the Floyd-Warshall algorithm. More...

#include <Floyd_Warshall.H>

Collaboration diagram for Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >:
[legend]

Public Member Functions

constexpr bool has_negative_cycle () const noexcept
 Check if the graph contains a negative cycle.
 
const DynMatrix< long > & get_path_mat () const noexcept
 Get the path reconstruction matrix.
 
const DynMatrix< Distance_Type > & get_dist_mat () const noexcept
 Get the distance matrix.
 
DynArray< Node * > get_nodes () const
 Get an owning copy of the graph nodes array.
 
const DynArray< Node * > & get_nodes_ref () const noexcept
 Get the array of graph nodes as a constant reference.
 
DynArray< Node * > get_nodes_copy () const
 Get an owning copy of the graph nodes array.
 
Node * select_node (long i) const noexcept
 Get the graph node at a given matrix index.
 
long index_node (Node *p) const
 Return the adjacency-matrix index corresponding to node p.
 
template<class D , std::enable_if_t< std::is_convertible_v< D, Distance >, int > = 0>
 Floyd_All_Shortest_Paths (const GT &__g, D &&__distance, SA __sa=SA())
 Construct Floyd-Warshall solver for all-pairs shortest paths.
 
 Floyd_All_Shortest_Paths (const GT &__g, SA &__sa)
 Construct Floyd-Warshall solver with a distance accessor built by Distance().
 
 Floyd_All_Shortest_Paths (const GT &g, SA &&sa=SA())
 Construct Floyd-Warshall solver with rvalue arc filter and a distance accessor built by Distance().
 
 Floyd_All_Shortest_Paths (const Floyd_All_Shortest_Paths &other)=default
 Copy the matrices of another solver, on the same graph.
 
 Floyd_All_Shortest_Paths (Floyd_All_Shortest_Paths &&other) noexcept(std::is_nothrow_move_constructible_v< SA > and std::is_nothrow_move_constructible_v< Distance > and std::is_nothrow_copy_constructible_v< Distance_Type >)
 Take the matrices of another solver, which is left without nodes, on the same graph.
 
std::string entry (const Distance_Type &e) const
 Convert a distance value to string representation.
 
Path< GT > get_min_path (const long src_idx, const long tgt_idx) const
 Reconstruct the shortest path between two nodes by matrix indices.
 
Path< GT > get_min_path (typename GT::Node *src, typename GT::Node *tgt) const
 Reconstruct the shortest path between two nodes.
 

Static Public Member Functions

static void print (const DynMatrix< Distance_Type > &dist)
 Print a distance matrix to standard output.
 

Private Types

typedef GT::Node Node
 
typedef GT::Arc Arc
 
typedef Distance::Distance_Type Distance_Type
 

Private Member Functions

decltype(auto) path_distance () const
 
template<class D >
void append_lightest_arc (Path< GT > &path, Node *p, Node *q, D &d) const
 
bool has_negative_diagonal () const
 

Private Attributes

DynArray< Node * > nodes
 
GT & g
 
long n
 
const Distance_Type Inf
 
bool negative_cycle = false
 
DynMatrix< long > path_mat
 
DynMatrix< Distance_Type > dist
 
SA sa
 
Distance distance
 

Related Symbols

(Note that these are not member symbols.)

template<AlephGraph GT, ArcDistance< GT > Distance, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
 Floyd_All_Shortest_Paths (const GT &, Distance, SA=SA()) -> Floyd_All_Shortest_Paths< GT, Distance, SA >
 The type of a distance given to the constructor is deduced from it: that of the constructor is not, since it is a parameter of its own.
 

Detailed Description

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
class Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >

Compute the all-pairs shortest path distance matrix and the path reconstruction matrix for a graph g using the Floyd-Warshall algorithm.

This class computes two matrices:

  1. dist: matrix of shortest-path costs between all node pairs. Each entry dist(i,j) stores the minimum total cost to go from the node with index i to the node with index j.
  2. path: path reconstruction matrix. Each entry path(i,j) stores the next node index on a shortest path from i to j. By iterating through path(k,j) you can reconstruct the path. The helper get_min_path() performs this reconstruction.

Floyd-Warshall supports negative edge weights. With a negative cycle there are no shortest distances: the solver stops as soon as it finds one, has_negative_cycle() is then true, the matrices do not hold distances, and get_min_path() throws.

Of the parallel arcs between two nodes, the lightest counts, and get_min_path() takes it. A loop counts only if it is negative: it is then a negative cycle. In a graph that is not directed, each arc counts in both directions.

The solver keeps copies of the distance accessor and of the arc filter. A distance passed to the constructor may have state, or no default constructor; the constructors that do not take one build it with Distance(). get_min_path(), which is const, measures the parallel arcs with the copy of the solver if the call operator of the distance is const, and with a copy of it otherwise, so that concurrent calls do not share the state of the distance.

Template parameters:

  1. GT: graph type.
  2. Distance<GT>: arc weight accessor that must provide:
    1. Distance<GT>::Distance_Type: the weight type.
    2. Distance_Type operator()(typename GT::Arc *a): returns the weight of arc a.
    3. Distance<GT>::Max_Distance: a sentinel maximum value that is treated as infinity.
    4. Distance<GT>::Zero_Distance: additive identity (usually 0).
  3. SA: arc filter.
See also
dijkstra_min_spanning_tree() dijkstra_min_path() find_path_depth_first() find_min_path() bellman_ford_min_spanning_tree() q_bellman_ford_min_spanning_tree()

Definition at line 167 of file Floyd_Warshall.H.

Member Typedef Documentation

◆ Arc

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
typedef GT::Arc Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Arc
private

Definition at line 170 of file Floyd_Warshall.H.

◆ Distance_Type

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
typedef Distance::Distance_Type Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Distance_Type
private

Definition at line 171 of file Floyd_Warshall.H.

◆ Node

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
typedef GT::Node Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Node
private

Definition at line 169 of file Floyd_Warshall.H.

Constructor & Destructor Documentation

◆ Floyd_All_Shortest_Paths() [1/5]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
template<class D , std::enable_if_t< std::is_convertible_v< D, Distance >, int > = 0>
Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths ( const GT &  __g,
D &&  __distance,
SA  __sa = SA() 
)
inline

Construct Floyd-Warshall solver for all-pairs shortest paths.

Computes shortest distances and path reconstruction matrices for all pairs of nodes in the graph using the Floyd-Warshall algorithm. Handles negative weights but detects negative cycles.

The type of the distance is a parameter of the constructor, so that braces, as in (g, {}), which give it no type, take the constructor with the filter.

Template Parameters
DType of the distance, which converts to Distance.
Parameters
[in]__gInput graph (will be treated as const).
[in]__distanceDistance accessor for the arc weights.
[in]__saArc filter for considering which arcs to include.
Exceptions
std::invalid_argumentif graph has no nodes.
std::bad_allocif memory allocation fails.
std::overflow_errorif, with an integer distance type, the sum of two distances is below lowest() before a negative cycle is found, which needs a weight below lowest() / (2 (n - 1)), with n nodes. A sum above max() does not count.

Definition at line 362 of file Floyd_Warshall.H.

References Aleph::DynArray< T >::access(), ah_invalid_argument_if, ah_overflow_error_if, Aleph::DynMatrix< T >::allocate(), Aleph::and, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::dist, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::distance, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::g, GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::has_negative_diagonal(), Aleph::in_place_sort(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::index_node(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Inf, GraphCommon< GT, Node, Arc >::is_digraph(), k, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::n, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::negative_cycle, Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::nodes, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::path_mat, Aleph::DynArray< T >::reserve(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::sa, and w.

◆ Floyd_All_Shortest_Paths() [2/5]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths ( const GT &  __g,
SA &  __sa 
)
inline

Construct Floyd-Warshall solver with a distance accessor built by Distance().

Parameters
[in]__gInput graph (will be treated as const).
[in]__saArc filter for considering which arcs to include.
Exceptions
std::invalid_argumentif graph has no nodes.
std::bad_allocif memory allocation fails.
std::overflow_erroras the first constructor.

Definition at line 479 of file Floyd_Warshall.H.

◆ Floyd_All_Shortest_Paths() [3/5]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths ( const GT &  g,
SA &&  sa = SA() 
)
inline

Construct Floyd-Warshall solver with rvalue arc filter and a distance accessor built by Distance().

Parameters
[in]gInput graph.
[in]saArc filter, which may be a temporary.
Exceptions
std::invalid_argumentif graph has no nodes.
std::bad_allocif memory allocation fails.
std::overflow_erroras the first constructor.

Definition at line 492 of file Floyd_Warshall.H.

◆ Floyd_All_Shortest_Paths() [4/5]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths ( const Floyd_All_Shortest_Paths< GT, Distance, SA > &  other)
default

Copy the matrices of another solver, on the same graph.

Parameters
[in]othersolver to copy.
Exceptions
std::bad_allocif there is no memory for the copy.

◆ Floyd_All_Shortest_Paths() [5/5]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths ( Floyd_All_Shortest_Paths< GT, Distance, SA > &&  other)
inlinenoexcept

Take the matrices of another solver, which is left without nodes, on the same graph.

The implicit move took the nodes and the matrices but copied their number: get_min_path() then passed its checks in the moved-from solver and read a matrix that it no longer had.

Parameters
[in,out]othersolver to move from.
Exceptions
whatcopying the infinity, which is const, or moving the filter or the distance throws; then other is left without nodes.
Note
The solver refers to its graph, so that it has no assignment.

Definition at line 514 of file Floyd_Warshall.H.

Member Function Documentation

◆ append_lightest_arc()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
template<class D >
void Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::append_lightest_arc ( Path< GT > &  path,
Node *  p,
Node *  q,
D &  d 
) const
inlineprivate

◆ entry()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
std::string Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::entry ( const Distance_Type &  e) const
inline

Convert a distance value to string representation.

Parameters
[in]eDistance value to convert.
Returns
String representation ("Inf" for infinite distances).

Definition at line 530 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Inf.

Referenced by TEST().

◆ get_dist_mat()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
const DynMatrix< Distance_Type > & Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_dist_mat ( ) const
inlinenoexcept

Get the distance matrix.

The distance matrix contains shortest distances between all pairs of nodes. Entry (i,j) contains the shortest distance from node i to node j. With a negative cycle it holds no distances: see has_negative_cycle().

Returns
Const reference to the distance matrix.

Definition at line 252 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::dist.

Referenced by compare_with_floyd(), Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::is_empty(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ get_min_path() [1/2]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Path< GT > Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_min_path ( const long  src_idx,
const long  tgt_idx 
) const
inline

Reconstruct the shortest path between two nodes by matrix indices.

Uses the path reconstruction matrix to build the shortest path from source to target node.

Parameters
[in]src_idxMatrix index of source node.
[in]tgt_idxMatrix index of target node.
Returns
Path object containing the shortest path.
Exceptions
std::out_of_rangeif indices are invalid.
std::domain_errorif the graph has a negative cycle.
Note
With a distance whose call operator is not const, it measures the parallel arcs with a copy of the distance of the solver.

Definition at line 578 of file Floyd_Warshall.H.

References ah_domain_error_if, ah_out_of_range_error_if, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::append_lightest_arc(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::dist, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::g, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Inf, k, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::n, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::negative_cycle, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::nodes, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::path_distance(), and Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::path_mat.

Referenced by Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_min_path(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TYPED_TEST(), TYPED_TEST(), and Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::use().

◆ get_min_path() [2/2]

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Path< GT > Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_min_path ( typename GT::Node *  src,
typename GT::Node *  tgt 
) const
inline

Reconstruct the shortest path between two nodes.

Convenience method that accepts node pointers instead of indices.

Parameters
[in]srcPointer to source node.
[in]tgtPointer to target node.
Returns
Path object containing the shortest path.
Exceptions
std::invalid_argumentif either node pointer is null.
std::domain_errorif either node is not found in the graph, or if the graph has a negative cycle.

Definition at line 623 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_min_path(), and Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::index_node().

◆ get_nodes()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
DynArray< Node * > Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_nodes ( ) const
inline

Get an owning copy of the graph nodes array.

Returns a copy of the sorted array of node pointers. This method is equivalent to get_nodes_copy() and provides a safe snapshot for long-term storage or when the Floyd_All_Shortest_Paths instance may be destroyed.

Note
This method returns a copy of the DynArray container; the Node* elements are borrowed from the graph and caller does not gain ownership of the nodes themselves. Pointer validity depends on the graph nodes remaining alive.
Returns
Owning copy of the node pointer array container.
See also
get_nodes_copy() for the same functionality with an explicit name
get_nodes_ref() for a constant reference (no copy)

Definition at line 274 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_nodes_copy().

Referenced by TEST(), and TEST().

◆ get_nodes_copy()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
DynArray< Node * > Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_nodes_copy ( ) const
inline

Get an owning copy of the graph nodes array.

Returns a copy of the sorted array of node pointers. This is safer for long-term storage or if the Floyd_All_Shortest_Paths instance is destroyed, but incurs an O(n) copy cost.

Warning
This method returns a copy of the node array. Modifying the returned array does not affect the internal state of the Floyd_All_Shortest_Paths instance.
The pointers are valid as long as the received graph is alive.
Returns
Owning copy of the node pointer array.

Definition at line 306 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::nodes.

Referenced by Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_nodes(), and TEST().

◆ get_nodes_ref()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
const DynArray< Node * > & Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_nodes_ref ( ) const
inlinenoexcept

Get the array of graph nodes as a constant reference.

Returns the sorted array of node pointers used for matrix indexing. This provides O(1) access to the underlying storage but requires the caller to ensure the Floyd_All_Shortest_Paths instance remains alive.

Warning
The returned reference and its contained pointers are valid only as long as the Floyd_All_Shortest_Paths instance and the underlying graph nodes exist. Not thread-safe if the container is mutated.
Returns
Const reference to the node pointer array.

Definition at line 289 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::nodes.

Referenced by Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::is_empty(), TEST(), and Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::use().

◆ get_path_mat()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
const DynMatrix< long > & Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_path_mat ( ) const
inlinenoexcept

Get the path reconstruction matrix.

The path matrix contains intermediate nodes for shortest path reconstruction. Entry (i,j) contains the next node index on the shortest path from i to j. With a negative cycle it holds no paths: see has_negative_cycle().

Returns
Const reference to the path reconstruction matrix.

Definition at line 241 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::path_mat.

Referenced by Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::is_empty(), and TEST().

◆ has_negative_cycle()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
constexpr bool Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::has_negative_cycle ( ) const
inlineconstexprnoexcept

Check if the graph contains a negative cycle.

Returns
true if a negative cycle was detected, false otherwise. If it was, the solver stopped there, and the matrices do not hold distances.

Definition at line 230 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::negative_cycle.

Referenced by Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::is_empty(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TYPED_TEST().

◆ has_negative_diagonal()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
bool Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::has_negative_diagonal ( ) const
inlineprivate

◆ index_node()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
long Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::index_node ( Node *  p) const
inline

Return the adjacency-matrix index corresponding to node p.

Find the matrix index corresponding to a graph node.

Parameters
[in]pPointer to the node to find.
Returns
Matrix index of the node.
Exceptions
std::domain_errorif the node is not found.

Definition at line 324 of file Floyd_Warshall.H.

References ah_domain_error_if, ah_invalid_argument_if, Aleph::binary_search(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::nodes, and Aleph::DynArray< T >::size().

Referenced by Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Floyd_All_Shortest_Paths(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::get_min_path(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ path_distance()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
decltype(auto) Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::path_distance ( ) const
inlineprivate

◆ print()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
static void Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::print ( const DynMatrix< Distance_Type > &  dist)
inlinestatic

Print a distance matrix to standard output.

Prints the distance matrix in a readable format, showing "inf" for infinite distances and numeric values otherwise.

Parameters
[in]distDistance matrix to print.

Definition at line 548 of file Floyd_Warshall.H.

References Aleph::DynMatrix< T >::access(), Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::dist, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::Inf, Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::n, and Aleph::DynMatrix< T >::rows().

◆ select_node()

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Node * Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::select_node ( long  i) const
inlinenoexcept

Get the graph node at a given matrix index.

Parameters
[in]iMatrix index (must be in range [0, n)).
Returns
Pointer to the node at index i.

Definition at line 314 of file Floyd_Warshall.H.

References Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::nodes.

Referenced by TEST(), and Moved_From_Case< Floyd_All_Shortest_Paths< Dgraph > >::use().

Friends And Related Symbol Documentation

◆ Floyd_All_Shortest_Paths()

template<AlephGraph GT, ArcDistance< GT > Distance, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Floyd_All_Shortest_Paths ( const GT &  ,
Distance  ,
SA  = SA() 
) -> Floyd_All_Shortest_Paths< GT, Distance, SA >
related

The type of a distance given to the constructor is deduced from it: that of the constructor is not, since it is a parameter of its own.

Member Data Documentation

◆ dist

◆ distance

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
Distance Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::distance
private

◆ g

◆ Inf

◆ n

◆ negative_cycle

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
bool Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::negative_cycle = false
private

◆ nodes

◆ path_mat

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
DynMatrix<long> Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::path_mat
private

◆ sa

template<AlephGraph GT, ArcDistance< GT > Distance = Dft_Dist<GT>, ArcFilter< GT > SA = Dft_Show_Arc<GT>>
SA Aleph::Floyd_All_Shortest_Paths< GT, Distance, SA >::sa
private

The documentation for this class was generated from the following file: