The Floyd Warshall Algorithm solves the problem of finding the shortest path between all pairs of vertices in a weighted, directed graph.
The graph is given as an n × n
adjacency matrix matrix
, where matrix[i][j]
represents the weight of the edge from node i
to node j
. A value of -1
indicates that there is no direct edge between the two nodes.
Your task is to compute the shortest distances between every pair of nodes. If there is no path between two nodes, the corresponding distance should remain -1
.