Finding the Dijkstra shortest path with NetworkX in pure Python