
Bellman-Ford algorithm
The Bellman-Ford algorithm finds the shortest paths from a starting point to all other points in a network, even if some path costs are negative. It works by repeatedly relaxing edges, meaning it updates the shortest known distances to each node by checking if a shorter route exists through neighboring nodes. This process is done multiple times, ensuring the shortest paths are accurately calculated. Additionally, Bellman-Ford can detect if there's a cycle with negative total weight, which would mean infinitely decreasing path costs. It's useful in routing and network analysis where negative values may occur.