can i apply same algo for undirected graph?
Can i apply same algo for undirected graph?
Yes you can.
Specify the edges (u, v), twice (u, v) and (v, u).
Also any edge with a negative weight will count as a loop. As the Bellman-Ford algo works on graphs that don’t contain any cycles with negative weights, hence your un-directed graph should not contain any edges with negative weight.