Floyd-Warshall algorithm for finding shortest paths in a graph.
(graph)
| 1 | def floyd_warshall(graph): |
| 2 | """ |
| 3 | Floyd-Warshall algorithm for finding shortest paths in a graph. |
| 4 | """ |
| 5 | dist = graph |
| 6 | n = len(graph) |
| 7 | for k in range(n): |
| 8 | for i in range(n): |
| 9 | for j in range(n): |
| 10 | dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) |
| 11 | return dist |
nothing calls this directly
no outgoing calls
no test coverage detected