A DP method, take the edge as last path, if it decrease the shortest path, then add it to the pred array and decrease the shortest array