Visit once is wrong for 0 and 1
transcript
Links cost zero or one. A plain search looks fine. It is wrong.
There is a paid link from zero to two. There are free links through page one. The search finds the paid one first. It returns one. The truth is zero.
The search settles a page once. Later routes are ignored. Even a cheaper one.
A free link puts the page at the front. A paid link puts it at the back. Update a page when you find a cheaper cost.
A hundred thousand pages, two hundred thousand links. The deque keeps it linear. No heap is needed.
Build a long free route. Build a short paid route beside it. The free one must win.
Write a slow twin that relaxes every link, n times. It cannot be fooled by the order of discovery. Compare both on small random graphs.
Use a deque for zero and one. Free links go first. Full breakdown in the lecture.