Tweaked Bellman-Ford, added exceptions.
Rewritten Dijkstra's algorithm from scratch.