Bellman-Ford algorithm
The Bellman-Ford algorithm is a method used in computer science to find the shortest paths from a single source vertex to all other vertices in a weighted graph. It can handle graphs with negative weight edges, making it more versatile than some other algorithms like Dijkstra's algorithm.
The algorithm works by repeatedly relaxing the edges of the graph, which means it updates the shortest path estimates. It performs this relaxation for a total of |V| - 1 times, where |V| is the number of vertices. After these iterations, it can also detect negative weight cycles, which indicate that no shortest path exists.