Seed every start
transcript
A warehouse floor has several charging stations. Every cell wants its nearest one. Do not search from every cell. There is a better way.
On a thirty by thirty floor, that is slow. A search from every cell makes 596,165 visits. One seeded search makes 900.
Charging stations are many starts. The docks of two teams are many starts. Put every source in the queue at once.
Put every station in the queue first. Give each one distance zero. Then spread one ring at a time.
Stations at both ends. The first ring is distance one. The next rings meet in the middle.
The queue holds distance d, then d plus one. So the first visit is the shortest. And each cell joins only once.
Put every start in first. Spread one ring at a time. The queue keeps cells in order. The first visit is shortest. Full breakdown in the lecture.