|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Floyd-Warshall algorithm for all-pairs shortest paths. More...
#include <sstream>#include <iostream>#include <limits>#include <ahFunction.H>#include <ahSort.H>#include <tpl_indexArc.H>#include <tpl_dynMat.H>#include <tpl_graph.H>#include <tpl_graph_utils.H>#include <ah-errors.H>Go to the source code of this file.
Classes | |
| 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. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Floyd-Warshall algorithm for all-pairs shortest paths.
This file implements the Floyd-Warshall algorithm, a dynamic programming approach to compute the shortest paths between all pairs of vertices in a weighted graph.
Floyd-Warshall works by iteratively improving path estimates. For each intermediate vertex k, it checks if going through k provides a shorter path between any pair (i, j).
| Metric | Value |
|---|---|
| Time | O(V³) |
| Space | O(V²) for matrices |
For sparse graphs or single-source queries, consider:
Definition in file Floyd_Warshall.H.