Dynamic Programming Shortest Path Algorithm Explanation