The document contains a Java implementation of the Floyd-Warshall algorithm, which calculates the shortest paths between all pairs of nodes in a weighted graph. It initializes a distance matrix with given distances and applies the algorithm through three nested loops to update the distances. Finally, it prints the resulting shortest distance matrix, indicating infinite distances with 'INF'.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
0 views
FloydWarshalAlgoUsingMatrix
The document contains a Java implementation of the Floyd-Warshall algorithm, which calculates the shortest paths between all pairs of nodes in a weighted graph. It initializes a distance matrix with given distances and applies the algorithm through three nested loops to update the distances. Finally, it prints the resulting shortest distance matrix, indicating infinite distances with 'INF'.