Search from the target
transcript
Find the smallest-numbered shortest route. A search from the source meets ties early. Turn it round.
Search from the target instead. Every server gets a hop count. Servers two and three are one hop away.
Start at the source. Take the smallest neighbour that is one hop closer. Repeat until you reach the target.
Every step goes one hop closer. So the whole route is shortest. Taking the smallest neighbour decides every tie.
One search from the target. One walk from the source. Both are linear in the graph.
If the source is the target, return the source alone. If the source is unreached, return an empty list. Repeated links change nothing.
A hundred thousand servers, two hundred thousand links. Listing every shortest route is far too slow. Two linear passes are enough.
Write a slow twin that lists every shortest route. Run both on tiny random graphs. Pick the smallest list, and compare.
Hop counts first. Then walk with the smallest. Full breakdown in the lecture.