algorithm - 在 Dijkstra 算法中每次迭代将选择具有最小距离值的顶点的引理是什么?

标签 algorithm

这是来自维基百科的伪代码:

 1  function Dijkstra(Graph, source):
 2
 3      create vertex set Q
 4
 5      for each vertex v in Graph:             // Initialization
 6          dist[v] ← INFINITY                  // Unknown distance from source to v
 7          prev[v] ← UNDEFINED                 // Previous node in optimal path from source
 8          add v to Q                          // All nodes initially in Q (unvisited nodes)
 9
10      dist[source] ← 0                        // Distance from source to source
11      
12      while Q is not empty:
13          u ← vertex in Q with min dist[u]    // Node with the least distance will be selected first
14          remove u from Q 
15          
16          for each neighbor v of u:           // where v is still in Q.
17              alt ← dist[u] + length(u, v)
18              if alt < dist[v]:               // A shorter path to v has been found
19                  dist[v] ← alt 
20                  prev[v] ← u 
21
22      return dist[], prev[]

这是一个贪婪的过程。令我困惑的是第 13 行:为什么必须先选择距离最小的节点?它背后的理论或引理是什么?

修改:

在u从Q中提取之前,dist[u]是INFINITY,或者对应Yonggoo Noh提到的论文中u的“估计距离”

最佳答案

您可以轻松找到 Dijkstra 算法的证明。

其中一个是:http://web.cs.ucdavis.edu/~amenta/w10/dijkstra.pdf

在该链接中,

Lemma 2 Let v_m be an outside vertex in V−S such that d_m is minimum. Then d_md_j , for all j ∈ V−S. That is, the estimated distance to v_m is a lower bound on the length of the shortest path from s to any vertex in V−S.

有关 Dijkstra 的详细证明,请参阅该链接。

关于algorithm - 在 Dijkstra 算法中每次迭代将选择具有最小距离值的顶点的引理是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45580061/

相关文章:

algorithm - O(n) 和带波浪号的 O(n) 有什么区别

algorithm - 一次将多个值插入 B+树

c - 读取一串以逗号分隔的数字

algorithm - 轮廓矢量形状算法

python - 从社区共现矩阵到每个节点的社区索引

performance - 分析嵌套for循环的运行时间

algorithm - 用于降雨预报的滑动窗口算法

algorithm - 如何解决条件线性递归?

java - 如何使用显式链接(使用三重链接数据结构)实现优先级队列?

python - Python 中的 3n+1 编程挑战