@@ -23,26 +23,26 @@ const FloydWarshall = (dist) => {
2323 return dist
2424}
2525
26- const main = ( ) => {
27- // For the following graph (edge weights are shown in brackets)
28- // 4 1 dist[1][2] = dist[2][1] = 1
29- // \ (2)/ \ dist[1][3] = dist[3][1] = 2
30- // \ / \(1) dist[1][4] = dist[4][1] = Infinity
31- // (1)\ / \ dist[3][4] = dist[4][3] = 1
32- // 3 2 dist[2][4] = dist[4][2] = Infinity
33- // dist[2][3] = dist[3][2] = Infinity
34- // Output should be:
35- // [ [0, 1, 2, 3],
36- // [1, 0, 3, 4],
37- // [2, 3, 0, 1],
38- // [3, 4, 1, 0] ]
39- console . log ( FloydWarshall (
40- [ [ 0 , 1 , 2 , Infinity ] ,
41- [ 1 , 0 , Infinity , Infinity ] ,
42- [ 2 , Infinity , 0 , 1 ] ,
43- [ Infinity , Infinity , 1 , 0 ]
44- ]
45- ) )
46- }
26+ export { FloydWarshall }
27+
28+ // For the following graph (edge weights are shown in brackets)
29+ // 4 1 dist[1][2] = dist[2][1] = 1
30+ // \ (2)/ \ dist[1][3] = dist[3][1] = 2
31+ // \ / \(1) dist[1][4] = dist[4][1] = Infinity
32+ // (1)\ / \ dist[3][4] = dist[4][3] = 1
33+ // 3 2 dist[2][4] = dist[4][2] = Infinity
34+ // dist[2][3] = dist[3][2] = Infinity
35+ // Output should be:
36+ // [ [0, 1, 2, 3],
37+ // [1, 0, 3, 4],
38+ // [2, 3, 0, 1],
39+ // [3, 4, 1, 0] ]
40+
41+ // FloydWarshall(
42+ // [[0, 1, 2, Infinity],
43+ // [1, 0, Infinity, Infinity],
44+ // [2, Infinity, 0, 1],
45+ // [Infinity, Infinity, 1, 0]
46+ // ]
47+ // )
4748
48- main ( )
0 commit comments