Explanation

- **Bellman-Ford Algorithm** is a dynamic programming algorithm used for finding the shortest path in graphs, even with negative weight edges. It also detects negative weight cycles.

-

  • Steps:

    • Initialize distances to all vertices as infinity, and set the distance to the source vertex as 0.
    • Relax all edges V-1 times (where V is the number of vertices).
    • Check for negative weight cycles by attempting to relax all edges once more.
  • Time Complexity:

    • O(V * E), where V is the number of vertices and E is the number of edges.