15.082 and 6.855j

13
1 15.082 and 6.855J Dijkstra’s Algorithm with simple buckets (also known as Dial’s algorithm)

Upload: irene-miles

Post on 31-Dec-2015

18 views

Category:

Documents


2 download

DESCRIPTION

15.082 and 6.855J. Dijkstra’s Algorithm with simple buckets (also known as Dial’s algorithm). . . 0. . 1. . . . 2. 0. 1. 2. 3. 4. 5. 6. 7. 3. 4. 5. 6. An Example. Initialize distance labels. 4. 2. 4. 2. 2. Initialize buckets. 2. 1. 3. 1. 6. 4. 2. 3. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 15.082 and 6.855J

1

15.082 and 6.855J

Dijkstra’s Algorithm with simple buckets

(also known as Dial’s algorithm)

Page 2: 15.082 and 6.855J

2

An Example

1

2

3

4

5

6

2

4

2 1

3

4

2

3

2

Initialize distance labels

1

0

Select the node with the minimum temporary distance label.

0 1 2 3 4 5 6 7

1

23456

Initialize buckets.

Page 3: 15.082 and 6.855J

3

Update Step

2

3

4

5

6

2

4

2 1

3

4

2

3

2

2

4

0

1

0 1 2 3 4 5 6 7

1

23456

2 3

Page 4: 15.082 and 6.855J

4

Choose Minimum Temporary Label

1

3

4

5

6

2

4

2 1

3

4

2

3

2

2

4

0

2

0 1 2 3 4 5 6 7

4562 3

Find Min by starting at the leftmost bucket and scanning right till there is a non-empty bucket.

Page 5: 15.082 and 6.855J

5

Update Step

1

2

3

4

5

6

2

4

2 1

3

4

2

3

2

2

4

6

43

0

0 1 2 3 4 5 6 7

4562 33 4

5

Page 6: 15.082 and 6.855J

6

Choose Minimum Temporary Label

1

2 4

5

6

2

4

2 1

3

4

2

3

2

2

3

6

4

0

3

0 1 2 3 4 5 6 7

63 45

Find Min by starting at the leftmost bucket and scanning right till there is a non-empty bucket.

Page 7: 15.082 and 6.855J

7

Update

1

2 4

5

6

2

4

2 1

3

4

2

3

2

0

3

2

3

6

4

0 1 2 3 4 5 6 7

63 45

Page 8: 15.082 and 6.855J

8

Choose Minimum Temporary Label

1

2 4

6

2

4

2 1

3

4

2

3

2

0

3

2

3

6

4

5

0 1 2 3 4 5 6 7

645

Page 9: 15.082 and 6.855J

9

Update

1

2 4

6

2

4

2 1

3

4

2

3

2

0

3

2

3

6

4

5

6

0 1 2 3 4 5 6 7

6456

Page 10: 15.082 and 6.855J

10

Choose Minimum Temporary Label

1

2

6

2

4

2 1

3

4

2

3

2

0

3

2

3

6

4

5

6

4

0 1 2 3 4 5 6 7

46

Page 11: 15.082 and 6.855J

11

Update

1

2

6

2

4

2 1

3

4

2

3

2

0

3

2

3

6

4

5

6

4

0 1 2 3 4 5 6 7

46

Page 12: 15.082 and 6.855J

12

Choose Minimum Temporary Label

1

2

2

4

2 1

3

4

2

3

2

0

3

2

3

6

4

5

6

4

6

0 1 2 3 4 5 6 7

6

There is nothing to update

Page 13: 15.082 and 6.855J

13

End of Algorithm

1

2

2

4

2 1

3

4

2

3

2

0

3

2

3

6

4

5

6

4

6

All nodes are now permanent

The predecessors form a tree

The shortest path from node 1 to node 6 can be found by tracing back predecessors