Sample input: , , . Edges: , , . Initialize : dist[1][2] = dist[2][1] = 5, dist[1][3] = dist[3][1] = 9, dist[2][3] = dist[3][2] = 3, rest infinity. After Floyd-Warshall: dist[1][3] = 8 (route ).
Query returns . This shows how Floyd-Warshall discovers indirect paths that are shorter than direct edges. The algorithm found a better path by routing through vertex .