Contents · 0% complete
Shortest Paths
Dijkstra's algorithm finds the shortest route from one start vertex: give each vertex a working value, permanently label the smallest, update its neighbours, repeat. Trace back using edges where label difference equals edge weight. Floyd's algorithm finds shortest distances between every pair using a table, one vertex at a time.
Learning objectives
- Apply Dijkstra's algorithm with working values and order of labelling.
- Trace back the shortest route.
- Apply Floyd's algorithm to distance and route matrices.
Your sat nav finds the fastest route among millions. Why doesn't it try every possible route?
Core idea
Your sat nav doesn't try every road. It spreads out from where you are, settling the true shortest distance to one junction at a time, nearest first. That's Dijkstra's algorithm.
Dijkstra: give the start label ; repeatedly make permanent the smallest working value, then update its neighbours with label edge. Trace the route back using edges where label difference equals weight.
1. Dijkstra
Network used below: , , , , , , .
Find the shortest route from to .
- Goal
- Route and length.
- Strategy
- Label in order of smallest working value.
- Neighbours of .
- Update from .
- Update from .
- Last labels.
- The vertex about to be made permanent.
- Every alternative leaves the labelled set somewhere.
- had the smallest working value.
- Adding non-negative weights can't make it shorter.
2. Floyd (all pairs)
, , . Update using .
- Goal
- New .
- Strategy
- .
- Going via is better.
- Update both tables.
Repeat until every vertex is permanent.
If closes, what is the shortest to ?
Summary
- Smallest working value → permanent.
- Update with label edge.
- Trace back by differences.
- Floyd for all pairs.
- Working value
- Best distance found so far.
- Permanent label
- Confirmed shortest distance.
Key formulae
Worked examples
Explore the graph
- Vertices: , , , , . Weights: , , , , , , .
- Final labels from : , , , , .
Shortest : , .
Common mistakes
Every route from A to E
Dijkstra: I'll check five, thanks.
Exam tip
Guided practice
Practice questions
More questions on every skill in this subtopic are in the question bank under Practise.
Challenge
Summary
- Label the smallest working value.
- Update neighbours.
- Trace back by differences.
- Floyd: all pairs.
Quick quiz
Same topic, different board
- Specification
- A level Further Mathematics 9FM0
- Where
- Decision 1 · Algorithms on graphs (Dijkstra) and Algorithms on graphs II (Floyd)
- Expected
- Dijkstra's algorithm with working values and order of labelling; tracing back the route; Floyd's algorithm with distance and route tables.
- Calculator
- Permitted; show enough working to earn the method marks.
- Typical style
- Edexcel often opens with a routine part and builds to a "show that" or "prove" part.
- Open in
- YMA01 · WDM119FM0 · Option
Past paper questions
No past paper questions are tagged to this subtopic yet. We add papers every week.
Browse past papersSalam Academy original content · Content status: reviewed and published. Syllabus mapping: Pearson Edexcel YMA01, 2018 specification (official specification).