Stop early in Bellman-Ford

If the current iteration finds no shorter paths, then it is safe to stop. This optimization also makes it possible to include the extra iteration in the main loop.