Dynamic Programming Shortest Path Algorithm In Python