Photo AI

Last Updated Sep 27, 2025

Dijkstra's Algorithm Simplified Revision Notes

Revision notes with simplified explanations to understand Dijkstra's Algorithm quickly and effectively.

user avatar
user avatar
user avatar
user avatar
user avatar

294+ students studying

10.4.1 Dijkstra's Algorithm

Dijkstra's algorithm is a method for finding the shortest path from a starting node (source) to all other nodes in a weighted graph. This algorithm is widely used in network routing and optimisation problems.

How Dijkstra's Algorithm Works

Step-by-Step Process

  • Initialisation
  • Explore Neighbours
  • Mark as Visited
  • Move to the Next Node
  • Termination

  1. Initialisation
  • Assign a tentative distance of 00 to the starting node and (infinity) to all other nodes.
  • Mark all nodes as unvisited and set the starting node as the current node.
  1. Explore Neighbours
  • For the current node, calculate the tentative distance to each of its unvisited neighbours: TentativeDistancetoNeighbourTentative Distance to Neighbour=DistancetoCurrentNode+WeightofEdgetoNeighbourTentative Distance to Neighbour=Distance to Current Node+Weight of Edge to NeighbourDistance to Current Node+Weight of Edge to Neighbour\text{Tentative Distance to Neighbour} = \text{Distance to Current Node} + \text{Weight of Edge to Neighbour}

  • If this calculated distance is less than the currently recorded tentative distance for that neighbour, update the neighbour's tentative distance.

  1. Mark as Visited
  • Once all neighbours of the current node have been examined, mark the current node as visited. A visited node will not be checked again.
  1. Move to the Next Node
  • Select the unvisited node with the smallest tentative distance as the new current node.
  • Repeat steps 2244 until all nodes have been visited or the shortest path to the target node is determined.
  1. Termination
  • The algorithm stops when the shortest path to the desired node is found (or when all nodes have been visited for a complete shortest-path map).

Worked Example

lightbulbExample

Example Find the shortest path from node AA to all other nodes in the weighted graph below:

Node PairWeight
A → B4
A → C2
B → C5
B → D10
C → D3
C → E4
D → E1

Initialisation

  • Tentative distances:
A: 0, B: ∞, C: ∞, D: ∞, E: ∞\text{A: 0, B: ∞, C: ∞, D: ∞, E: ∞}
  • Current node: AA

Step 1: Explore Neighbours of AA

  • Distance to BB:
0+4=40 + 4 = 4
  • Distance to CC:
0+2=20 + 2 = 2
  • Update tentative distances:
A: 0, B: 4, C: 2, D: ∞, E: ∞\text{A: 0, B: 4, C: 2, D: ∞, E: ∞}
  • Mark A A as visited.

Step 2**: Move to** CC (Smallest Tentative Distance)

  • Distance to BB via CC: (BB already has a shorter path: 44, so no change).
2+5=72 + 5 = 7
  • Distance to DD via CC:
2+3=52 + 3 = 5
  • Distance to EE via CC:
2+4=62 + 4 = 6
  • Update tentative distances:
A: 0, B: 4, C: 2, D: 5, E: 6\text{A: 0, B: 4, C: 2, D: 5, E: 6}
  • Mark CC as visited.

Step 3: Move to BB (Next Smallest Tentative Distance)

  • Distance to DD via BB: (DD already has a shorter path: 55, so no change).
4+10=144 + 10 = 14
  • Update tentative distances (no changes):
A: 0, B: 4, C: 2, D: 5, E: 6\text{A: 0, B: 4, C: 2, D: 5, E: 6}
  • Mark BB as visited.

Step 4**: Move to** DD

  • Distance to EE via DD: (EE already has a path of 66, so no change).
5+1=65 + 1 = 6
  • Update tentative distances (no changes):
A: 0, B: 4, C: 2, D: 5, E: 6\text{A: 0, B: 4, C: 2, D: 5, E: 6}
  • Mark D as visited.

Step 5**: Move to** EE

  • All nodes visited; algorithm terminates

Final Tentative Distances

A: 0, B: 4, C: 2, D: 5, E: 6\text{A: 0, B: 4, C: 2, D: 5, E: 6}

The shortest paths from AA are:

  • A → B: 4
  • A → C: 2
  • A → D: 5
  • A → E: 6

Note Summary

infoNote

Common Mistakes

  1. Incorrect Initialisation Forgetting to set the starting node's distance to 00 and all others to .

  2. Skipping Updates Failing to update the tentative distance of a node when a shorter path is found.

  3. Revisiting Visited Nodes Including already visited nodes in further calculations.

  4. Ignoring Edge Weights Treating all edges as having equal weight instead of using the given values.

  5. Stopping Prematurely Not exploring all nodes, leading to incomplete or incorrect paths.

infoNote

Key Formulas/Theorems

  1. Tentative Distance Update
Tentative Distance to Neighbour=Distance to Current Node+Edge Weight\text{Tentative Distance to Neighbour} = \text{Distance to Current Node} + \text{Edge Weight}
  1. Node Selection
Next Node=Unvisited Node with Smallest Tentative Distance\text{Next Node} = \text{Unvisited Node with Smallest Tentative Distance}
  1. Algorithm Termination Stops when all nodes have been visited or the shortest path to the desired target node is finalised.
Books

Only available for registered users.

Sign up now to view the full note, or log in if you already have an account!

500K+ Students Use These Powerful Tools to Master Dijkstra's Algorithm

Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!

30 flashcards

Flashcards on Dijkstra's Algorithm

Revise key concepts with interactive flashcards.

Try Further Maths Decision Maths 1 Flashcards

3 quizzes

Quizzes on Dijkstra's Algorithm

Test your knowledge with fun and engaging quizzes.

Try Further Maths Decision Maths 1 Quizzes

29 questions

Exam questions on Dijkstra's Algorithm

Boost your confidence with real exam questions.

Try Further Maths Decision Maths 1 Questions

27 exams created

Exam Builder on Dijkstra's Algorithm

Create custom exams across topics for better practice!

Try Further Maths Decision Maths 1 exam builder

50 papers

Past Papers on Dijkstra's Algorithm

Practice past papers to reinforce exam experience.

Try Further Maths Decision Maths 1 Past Papers

Other Revision Notes related to Dijkstra's Algorithm you should explore

Discover More Revision Notes Related to Dijkstra's Algorithm to Deepen Your Understanding and Improve Your Mastery

96%

114 rated

Shortest Path Algorithms

Floyd's Algorithm

user avatar
user avatar
user avatar
user avatar
user avatar

373+ studying

187KViews

96%

114 rated

Shortest Path Algorithms

Comparing Dijkstra's & Floyd's Algorithms

user avatar
user avatar
user avatar
user avatar
user avatar

342+ studying

187KViews
Load more notes

Join 500,000+ A-Level students using SimpleStudy...

Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!

97% of Students

Report Improved Results

98% of Students

Recommend to friends

500,000+

Students Supported

50 Million+

Questions answered