Dynamic Programming Shortest Path Algorithm Python Template