美文网首页
25. The Bellman-Ford Algorithm

25. The Bellman-Ford Algorithm

作者: 何大炮 | 来源:发表于2017-10-16 11:54 被阅读0次

The Bellman-Ford algorithm solves the single-source shortest paths problem in more general settings.

  1. Unlike Dijkstra’s algorithm, it allows edges of negative length. However, it takes a much longer time.
  2. Unlike Dijkstra’s algorithm that adopts the greedy policy, the Bellman-Ford algorithm adopts the Dynamic Programming technique, progressively decreasing the estimate of v. d the distance from s to node v until the estimate is precise

The algorithm returns true if and only if the graph does not contain any negative cycles that are reachable from the source.

Because we want to obtain the minimum value of weight of path, so this path can be |V| vertices long, which means that we need to do |V| iterations.

时间复杂度是O(V*E)

Single-Source Shortest Paths in DAGs

For a directed acyclic graph (DAG), we can relax the edges according to the topological order of their start vertices, from left to right.
Determine the topological order of each vertex v ∈ V , using the DFS technique.
The time complexity of algorithm DAG Shortest Paths is O(|V|+|E|).

相关文章

网友评论

      本文标题:25. The Bellman-Ford Algorithm

      本文链接:https://www.haomeiwen.com/subject/kdrkuxtx.html