An implementation of Dijkstra's Algorithm