Floyd-Warshall Algorithm
Implementing the Floyd-Warshall algorithm to calculate the distance matrix for a given graph.
To complete this task, you need to follow the following steps:
Step 1: Create a 2D array named ZMatrix.
Step 2: Write the code to input the weight matrix.
Step 3: Implement the following Floyd-Warshall algorithm:
ALGORITHM Floyd(W):
Let D be the weight matrix with no negative-length cycle.
for k from 1 to n:
for i from 1 to n:
for j from 1 to n:
D[i][j] = min(D[i][j], D[i][k] + D[k][j])
Step 4: Write code to print out the distance matrix D in the output console.
Exercise:
Run the developed code on the following graph:
Input:
[insert input graph here]