Tải bản đầy đủ (.ppt) (20 trang)

04demo dijkstra 100520132102 phpapp02

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (106.33 KB, 20 trang )

Dijkstra's Shortest Path Algorithm
Find shortest path from s to t.

24

2

9

s

3

18
14

6
30

11

5

5

15

4

19


6
16

20

7

6

2

44

t


Dijkstra's Shortest Path Algorithm
S={ }
PQ = { s, 2, 3, 4, 5, 6, 7, t
}



0
s

24

2


9

18
14




30



11

5

5

15



4

19

6
16

20


7

6

2

6

distance
label

3

44

t




Dijkstra's Shortest Path Algorithm
S={ }
PQ = { s, 2, 3, 4, 5, 6, 7, t
}
delmin





0
s

24

2

9

18
14




30



11

5

5

15



4


19

6
16

20

7

6

2

6

distance
label

3

44

t




Dijkstra's Shortest Path Algorithm
S={s}

PQ = { 2, 3, 4, 5, 6, 7, t }
decrease key



X 9

0
s

24

2

9

18

X 14


14


30



11


5

5

15

X
 15

4

19

6
16

20

7

6

2

6

distance
label

3


44

t




Dijkstra's Shortest Path Algorithm
S={s}
PQ = { 2, 3, 4, 5, 6, 7, t }

delmin



X 9

0
s

24

2

9

18

X 14



14


30



11

5

5

15

X
 15

4

19

6
16

20

7


6

2

6

distance
label

3

44

t




Dijkstra's Shortest Path Algorithm
S = { s, 2 }
PQ = { 3, 4, 5, 6, 7, t }



X 9

0
s


24

2

9

3

18

X 14


14

6


30



11

5

5

15


X
 15

4

19

6
16

20

7

6

2

44

t




Dijkstra's Shortest Path Algorithm
S = { s, 2 }
PQ = { 3, 4, 5, 6, 7, t }
decrease key
X

 33

X 9

0
s

24

2

9

3

18

X 14


14

6


30



11


5

5

15

X
 15

4

19

6
16

20

7

6

2

44

t





Dijkstra's Shortest Path Algorithm
S = { s, 2 }
PQ = { 3, 4, 5, 6, 7, t }

X
 33

X 9

0
s

24

2

9

3

delmin
18

X 14


14


6


30



11

5

5

15

X
 15

4

19

6
16

20

7

6


2

44

t




Dijkstra's Shortest Path Algorithm
S = { s, 2, 6 }
PQ = { 3, 4, 5, 7, t }
32
X
X
 33

X 9

0
s

24

2

9

3


18

X 14


14

6
30



44
X


11

5

5

15

X
 15

4


19

6
16

20

7

6

2

44

t




Dijkstra's Shortest Path Algorithm
S = { s, 2, 6 }
PQ = { 3, 4, 5, 7, t }
32
X
X
 33

X 9


0
s

24

2

9

3

18

X 14


14

6
30



44
X


11

5


5

15

4

19

6
16

20

7
X
 15

6

2

44

delmin

t





Dijkstra's Shortest Path Algorithm
S = { s, 2, 6, 7 }
PQ = { 3, 4, 5, t }
32
X
X
 33

X 9

0
s

24

2

9

3

18

X 14


14

6

30

44
X 35
X

5

5

15

X
 15


11

4

19

6
16

20

7

6


2

44

t


59 X


Dijkstra's Shortest Path Algorithm
S = { s, 2, 6, 7 }
PQ = { 3, 4, 5, t }

delmin
32
X
X
 33

X 9

0
s

24

2


9

3

18

X 14


14

6
30

44
X 35
X

5

5

15

X
 15


11


4

19

6
16

20

7

6

2

44

t


59 X


Dijkstra's Shortest Path Algorithm
S = { s, 2, 3, 6, 7 }
PQ = { 4, 5, t }
32
X
X
 33


X 9

0
s

24

2

9

3

18

X 14


14

6
30

44
X 34
X 35
X

5


5

15

X
 15


11

4

19

6
16

20

7

6

2

44

t
51 59

X X



Dijkstra's Shortest Path Algorithm
S = { s, 2, 3, 6, 7 }
PQ = { 4, 5, t }
32
X
X
 33

X 9

0
s

24

2

9

3

18

X 14



14

6
30

X
 15


11

4

19

6
20

7

44
X 34
X 35
X

5

5

15


6

2

delmin
44

16

t
51 59
X X



Dijkstra's Shortest Path Algorithm
S = { s, 2, 3, 5, 6, 7 }
PQ = { 4, t }
32
X
X
 33

X 9

0
s

24


2

9

3

18

X 14


14

6
30

44
X 34
X 35
X

5

5

15

X
 15


11

45 X

4

19

6
16

20

7

6

2

44

t
50 51
X 59
X X



Dijkstra's Shortest Path Algorithm

S = { s, 2, 3, 5, 6, 7 }
PQ = { 4, t }
32
X
X
 33

X 9

0
s

24

2

9

3

18

X 14


14

6
30


44
X 34
X 35
X

5

5

15

X
 15

11

45 X

4

19

delmin
6
16

20

7


6

2

44

t
50 51
X 59
X X



Dijkstra's Shortest Path Algorithm
S = { s, 2, 3, 4, 5, 6, 7 }
PQ = { t }
32
X
X
 33

X 9

0
s

24

2


9

3

18

X 14


14

6
30

44
X 34
X 35
X

5

5

15

X
 15

11


45 X

4

19

6
16

20

7

6

2

44

t
50 51
X 59
X X



Dijkstra's Shortest Path Algorithm
S = { s, 2, 3, 4, 5, 6, 7 }
PQ = { t }
32

X
X
 33

X 9

0
s

24

2

9

3

18

X 14


14

6
30

44
X 34
X 35

X

5

5

15

X
 15

11

45 X

4

19

6
16

20

7

6

2


t

44

delmin

50 51
X 59
X X



Dijkstra's Shortest Path Algorithm
S = { s, 2, 3, 4, 5, 6, 7,
t}
PQ = { }
32
X
X
 33

X 9

0
s

24

2


9

3

18

X 14


14

6
30

44
X 34
X 35
X

5

5

15

X
 15

11


45 X

4

19

6
16

20

7

6

2

44

t
50 51
X 59
X X



Dijkstra's Shortest Path Algorithm
S = { s, 2, 3, 4, 5, 6, 7,
t}
PQ = { }

32
X
X
 33

X 9

0
s

24

2

9

3

18

X 14


14

6
30

44
X 34

X 35
X

5

5

15

X
 15

11

45 X

4

19

6
16

20

7

6

2


44

t
50 51
X 59
X X




×