FloydWarshallAlgorithmus
The Floyd-Warshall algorithm is a dynamic programming method for finding shortest paths between all pairs of vertices in a weighted graph. It supports graphs with negative edge weights but requires that no negative-weight cycle be present to yield finite shortest paths for all pairs. The algorithm can be applied to directed or undirected graphs and can also be used to compute transitive closure with a simple modification.
The standard formulation uses a distance matrix dist where dist[i][j] is the weight of the shortest known
The algorithm runs in O(n^3) time and uses O(n^2) space, where n is the number of vertices.
Historically, the method is attributed to Robert Floyd, building on earlier work by Stephen Warshall. It remains