attempting Dijkstra's algorithm