Run Floyd-Warshall on 4 vertices, show distance matrices
Analyze the run floyd-warshall on 4 vertices, show distance matrices.
Examples
Input: "test_input_1"
Output: "output_1"
Input: "test_input_2"
Output: "output_2"
Hints
Recall that the Floyd-Warshall algorithm computes the All-Pairs Shortest Path (APSP) by iteratively improving an estimate on the shortest path between two vertices, considering each vertex as an intermediate point in the path.
For a graph with 4 vertices, initialize the distance matrix with direct edge weights (or infinity if no edge exists) and zero for diagonal entries (distance from a vertex to itself).
After each iteration k (where k ranges from 1 to 4), update the distance matrix by checking if the path from i to j through k (i → k → j) is shorter than the currently known path from i to j. Show the distance matrix after each iteration.
Run Floyd-Warshall on 4 vertices, show distance matrices
Analyze the run floyd-warshall on 4 vertices, show distance matrices.