Xiaojuan Cai, School of Software, SJTU.
Floyd-Warshall algorithm
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 2
Floyd-Warshall algorithm s t x y z t x 1 s 0 10 5 - - PowerPoint PPT Presentation
Floyd-Warshall algorithm s t x y z t x 1 s 0 10 5 10 t 0 1 2 9 2 3 4 6 s 0 x 0 4 2 7 y 3 9 0 2 5
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that passes none vertex 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s 11 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s 11 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s 11 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t 11 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t 11 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t 11 15 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t 11 15 5 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t 11 15 5 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 10 4 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 10 4 8 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 10 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 10 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 11 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 11 4 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 11 4 14 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 11 4 14 6 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 11 4 14 6 6 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y 11 15 5 7 4 10 11 4 14 6 6 4 8 9 2
Xiaojuan Cai, School of Software, SJTU.
∞ ∞ ∞ ∞ 1 2 10 5 (a) 6 4 3 2 9 7 s t x y z
10 ∞ 5 ∞ ∞ 1 2 ∞ ∞ ∞ ∞ 4 ∞ 3 9 2 2 ∞ 6 ∞
s t x y z s t x y z 12 7 The shortest path from u to v that may passes s, t, x, y, z 11 15 5 7 4 10 11 4 14 6 6 4 8 9 2