0% found this document useful (0 votes)
99 views13 pages

Dijkstra's Algorithm Step-by-Step Guide

Dijkstra's algorithm is demonstrated on a graph to find the shortest path between two nodes. [1] The algorithm initializes all nodes with temporary distance labels and repeatedly selects the node with the minimum label to update its neighbors. [2] It traces through the example step-by-step, updating distance labels and predecessors after each selection. [3] Finally, it finds the shortest path from node 1 to node 6 by tracing back through the predecessors.

Uploaded by

api-3839714
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views13 pages

Dijkstra's Algorithm Step-by-Step Guide

Dijkstra's algorithm is demonstrated on a graph to find the shortest path between two nodes. [1] The algorithm initializes all nodes with temporary distance labels and repeatedly selects the node with the minimum label to update its neighbors. [2] It traces through the example step-by-step, updating distance labels and predecessors after each selection. [3] Finally, it finds the shortest path from node 1 to node 6 by tracing back through the predecessors.

Uploaded by

api-3839714
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

15.082 and 6.

855J

Dijkstra’s Algorithm
An Example

∞ ∞
2 4 4
2 2
0
2
1 1 3 6 ∞
4 2

3 3 5
∞ ∞

Initialize
Select the node with
the minimum temporary
distance label.
2
Update Step

2
∞ ∞
2 4 4
2 2
0
2
1 1 3 6 ∞
4 2

3 3 5
∞ ∞
4

3
Choose Minimum Temporary Label

2 ∞
2 4 4
2 2
0
2
1 1 3 6 ∞
4 2

3 3 5

4 ∞

4
Update Step

6
2 ∞
2 4 4
2 2
0
2
1 1 3 6 ∞
4 2

3 3 5

4 ∞
3 4

The predecessor
of node 3 is now
node 2
5
Choose Minimum Temporary Label

2 6
2 4 4
2 2
0
2
1 1 3 6 ∞
4 2

3 3 5
3 4

6
Update

2 6
2 4 4
2 2
0
2
1 1 3 6 ∞
4 2

3 3 5
3 4

d(5) is not changed.

7
Choose Minimum Temporary Label

2 6
2 4 4
2 2
0
2
1 1 3 6 ∞
4 2

3 3 5
3 4

8
Update

2 6
2 4 4
2 2
0
2 6
1 1 3 6 ∞
4 2

3 3 5
3 4

d(4) is not changed

9
Choose Minimum Temporary Label

2 6
2 4 4
2 2
0
1 2 3
1 6 6
4 2

3 3 5
3 4

10
Update

2 6
2 4 4
2 2
0
1 2 3
1 6 6
4 2

3 3 5
3 4

d(6) is not updated

11
Choose Minimum Temporary Label

2 6
2 4 4
2 2
0
1 2 3
1 6 6
4 2

3 3 5
3 4

There is nothing to update

12
End of Algorithm

2 6
2 4 4
2 2
0
1 2 3
1 6 6
4 2

3 3 5
3 4

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 13

You might also like