Skip to content
All worked examples

Dijkstra's algorithm

Algorithms on graphs
A-level Further Maths (9FM0) · Decision 1
ORIGINAL

Order of labelling, final values, working values — then trace the route back from the destination.

Board and spec code confirmed against Edexcel 9FM0 · registry checked 2026-07-17How this checking works

Question

1.

A network has vertices A,B,C,D,E,FA, B, C, D, E, F and weighted edges AB=4AB = 4, AC=2AC = 2, BC=1BC = 1, BD=5BD = 5, CD=8CD = 8, CE=10CE = 10, DE=2DE = 2, DF=6DF = 6, EF=3EF = 3. Use Dijkstra's algorithm to find the shortest route from AA to FF and state its length.

Every step worked, with the reasoning.

  1. 1
    Label AA: order 1, final value 00. Working values: B=4B = 4, C=2C = 2.

    Start at AA; each vertex joined directly to it gets a working value equal to the edge weight.

  2. 2
    Label CC: order 2, final value 22. Update B=min⁡(4, 2+1)=3B = \min(4,\ 2 + 1) = 3, D=2+8=10D = 2 + 8 = 10, E=2+10=12E = 2 + 10 = 12.

    Make the smallest working value permanent, then replace a neighbour's working value only if the new route is shorter.

  3. 3
    Label BB: order 3, final value 33. Update D=min⁡(10, 3+5)=8D = \min(10,\ 3 + 5) = 8.

    BB now has the smallest working value; its only unlabelled neighbour is DD.

  4. 4
    Label DD: order 4, final value 88. Update E=min⁡(12, 8+2)=10E = \min(12,\ 8 + 2) = 10, F=8+6=14F = 8 + 6 = 14.

    Both of DD's unlabelled neighbours get new working values.

  5. 5
    Label EE: order 5, final value 1010. Update F=min⁡(14, 10+3)=13F = \min(14,\ 10 + 3) = 13. Label FF: order 6, final value 1313.

    Stop once the destination FF is permanently labelled.

  6. 6
    Trace back from FF: 13−3=1013 - 3 = 10 (EE), 10−2=810 - 2 = 8 (DD), 8−5=38 - 5 = 3 (BB), 3−1=23 - 1 = 2 (CC), 2−2=02 - 2 = 0 (AA).

    Edge XYXY lies on the route when (final value at YY) −- (final value at XX) == weight of XYXY.

Answer: Shortest route ACBDEFACBDEF, length 1313

Stuck on Dijkstra's algorithm?

Everything here stays free. If Dijkstra's algorithm is where the marks keep going, I teach it one to one from the mark schemes. Free intro call, then a free first lesson.