Step by step
The question
Question: find the shortest path from A to F.
1 Draw the graph
The numbers on the edges are lengths: how far it is along each edge.
2 Start the table
A table: a column for each vertex.
Each cell holds how far it is from A so far, and, small, the vertex we came from.
A is 0 from itself.
The others are not reached yet: ∞, as far as can be.
Careful!
Fewer edges is not the same as shorter.
We must add the lengths.
3 Round 1
The smallest open number is A: 0.
Nothing can beat it any more, so A is final.
B: 0 plus 6 is 6.
C: 0 plus 8 is 8.
F: 0 plus 15 is 15.
The next row: the new numbers, the rest copied down.
4 Round 2
The smallest open number is B: 6.
Nothing can beat it any more, so B is final.
C: 6 plus 9 is 15, not less than 8.
Keep 8.
D: 6 plus 14 is 20.
The next row: the new numbers, the rest copied down.
5 Round 3
The smallest open number is C: 8.
Nothing can beat it any more, so C is final.
D: 8 plus 10 is 18, less than 20.
Change it.
F: 8 plus 3 is 11, less than 15.
Change it.
The next row: the new numbers, the rest copied down.
6 Round 4
The smallest open number is F: 11.
Nothing can beat it any more, so F is final.
E: 11 plus 8 is 19.
7 The route back
Go back with the small letters: F from C, C from A.
That is the route.
The shortest path is A, C, F, length 11.
8 Check
Add the lengths along the route: 8 + 3 = 11.
Right!
The route with the fewest edges, A, F, is 15: longer.
Right!
Let's look back.
First: draw the graph.
Then: start the table.
Then: round 1.
Then: round 2.
Then: round 3.
Then: round 4.
Then: the route back.
Last: check.