Floyd-Warshall algorithm s t x y z t x 1 s 0 10 5 - - PowerPoint PPT Presentation

floyd warshall algorithm
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

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 The shortest path from u to v that passes none vertex 2

slide-3
SLIDE 3

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 The shortest path from u to v that passes none vertex 2

slide-4
SLIDE 4

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 The shortest path from u to v that passes none vertex 2

slide-5
SLIDE 5

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 The shortest path from u to v that passes none vertex 2

slide-6
SLIDE 6

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 12 The shortest path from u to v that passes none vertex 2

slide-7
SLIDE 7

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 12 The shortest path from u to v that passes none vertex 2

slide-8
SLIDE 8

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 12 7 The shortest path from u to v that passes none vertex 2

slide-9
SLIDE 9

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 12 7 The shortest path from u to v that passes none vertex 2

slide-10
SLIDE 10

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 12 7 The shortest path from u to v that may passes s 2

slide-11
SLIDE 11

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 12 7 The shortest path from u to v that may passes s 2

slide-12
SLIDE 12

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 12 7 The shortest path from u to v that may passes s 11 2

slide-13
SLIDE 13

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 12 7 The shortest path from u to v that may passes s 11 4 2

slide-14
SLIDE 14

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 12 7 The shortest path from u to v that may passes s 11 4 2

slide-15
SLIDE 15

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 12 7 The shortest path from u to v that may passes s, t 11 4 2

slide-16
SLIDE 16

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 12 7 The shortest path from u to v that may passes s, t 11 4 2

slide-17
SLIDE 17

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 12 7 The shortest path from u to v that may passes s, t 11 15 4 2

slide-18
SLIDE 18

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 12 7 The shortest path from u to v that may passes s, t 11 15 5 4 2

slide-19
SLIDE 19

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 12 7 The shortest path from u to v that may passes s, t 11 15 5 4 2

slide-20
SLIDE 20

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 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 4 2

slide-21
SLIDE 21

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 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 4 2

slide-22
SLIDE 22

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 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 2

slide-23
SLIDE 23

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 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 4 2

slide-24
SLIDE 24

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 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 10 4 2

slide-25
SLIDE 25

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 12 7 The shortest path from u to v that may passes s, t, x 11 15 5 7 4 10 4 8 2

slide-26
SLIDE 26

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 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

slide-27
SLIDE 27

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 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

slide-28
SLIDE 28

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 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

slide-29
SLIDE 29

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 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

slide-30
SLIDE 30

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 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

slide-31
SLIDE 31

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 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

slide-32
SLIDE 32

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 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

slide-33
SLIDE 33

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 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

slide-34
SLIDE 34

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 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

slide-35
SLIDE 35

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 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

slide-36
SLIDE 36

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 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