The stop goes in the outer loop
transcript
You need every pair distance. Not from one source. Searching for each pair repeats work. Questions about many pairs are common. Build one table instead, and read it.
Allow one stop at a time. Ask: is it shorter through the stop? Keep the shorter route.
The direct link costs nine. Stop one adds nothing. Stop two makes it six. Stop three adds nothing. Six is final.
The stop is the outer loop. Each pass builds on the last. A stop inside misses routes.
The build costs n cubed. A hundred vertices make a million steps.
Put the stop innermost. Each pair sees each stop once. The shorter routes may not exist yet. So a route with two stops is missed.
Every vertex is zero from itself. Start the table with that. Unlinked pairs start large. Add large values with care.
Build the table once. Allow one stop at a time. Keep the stop outermost. Full breakdown in the lecture.