Dynamic Programming Shortest Path Algorithm Python Code