Graph/floyd_warshall library
🌐 Floyd-Warshall (All-Pairs Shortest Paths)
Computes the shortest distances between every pair of nodes. Supports negative edge weights but not negative cycles.
- Input:
nodesset and directededges - Time complexity: O(V^3)
- Space complexity: O(V^2)
Example:
final nodes = {'A','B','C'};
final edges = [
WeightedEdge('A','B',3),
WeightedEdge('A','C',10),
WeightedEdge('B','C',1),
];
final dist = floydWarshall(nodes, edges);
// dist['A']['C'] == 4
Functions
-
floydWarshall<
T> (Set< T> nodes, List<WeightedEdge< edges) → Map<T> >T, Map< T, num> >