Simple Bellman-Ford algorithm.