Ref #9, Dijkstra's algorithm implementation, part 1