shortest path first algorithm

See SPF.