Home >  Term: Bellman-Ford algorithm
Bellman-Ford algorithm

An efficient algorithm to solve the single-source shortest-path problem. Weights may be negative. The algorithm initializes the distance to the source vertex to 0 and all other vertices to ∞. It then does V-1 passes (V is the number of vertices) over all edges relaxing, or updating, the distance to the destination of each edge. Finally it checks each edge again to detect negative weight cycles, in which case it returns false. The time complexity is O(VE), where E is the number of edges.

0 0

Penulis

  • GeorgeV
  •  (Gold) 1123 poin
  • 100% positive feedback
© 2024 CSOFT International, Ltd.