Python, Graph, Algorithms.
algorithm at vertex A, we first set the distance to A as 0 and the distance to all other vertices as infinity. Then, we relax all edges |V| — 1 times. After the first iteration, the distances are -1 to B, infinity to C, infinity to D, and infinity to E. After the second iteration, the distances are