algorithm - 证明 Dijkstra 算法中提取的距离值是非递减的?

标签 algorithm computer-science dijkstra proof

我正在复习我的旧算法笔记,并且遇到了这个证明。这是我的一项作业,我做对了,但我觉得证据确实不足。

题目是证明Dijkstra算法中从优先级队列中取出的距离值是一个非递减序列。

我的证明如下:

Proof by contradiction. Fist, assume that we pull a vertex from Q with d-value 'i'. Next time, we pull a vertex with d-value 'j'. When we pulled i, we have finalised our d-value and computed the shortest-path from the start vertex, s, to i. Since we have positive edge weights, it is impossible for our d-values to shrink as we add vertices to our path. If after pulling i from Q, we pull j with a smaller d-value, we may not have a shortest path to i, since we may be able to reach i through j. However, we have already computed the shortest path to i. We did not check a possible path. We no longer have a guaranteed path. Contradiction.

如何改进这个证明?或者更好的是,是否有不同的方法?它看起来很弱:)

编辑:抱歉,在这种情况下我的优先级队列是用最小堆实现的

最佳答案

让我们建立这些(这些都是真的,因为它们基本上是算法的定义):

  1. The Priority Queue in Dijkstra's algorithm will give you the node with the lowest d-value in each iteration of the algorithm.
  2. There are no negative edge weights.
  3. Once a node has been dequeued, it will never return to the queue.
  4. The d-value of a node that has been dequeued is final, and will not change from that point on.

继续 (1),假设 (2) 适用,该出队节点的 d 值将至少等于先前提取的 d 值,因为每个节点的 d 值取决于 d 值在它之前出队的节点的数量,这是一种递归定义。由于 (3) 和 (4) 是正确的,这个递归定义结束于 d 值为 0 的起始节点。
因此,如果每个节点的 d 值至少等于他之前的 d 值,并且 (1) 仍然适用,则从优先级队列中提取的 d 值集是非递减.

(看完这个和你写的,基本一样,但我觉得表现得更好一点)

关于algorithm - 证明 Dijkstra 算法中提取的距离值是非递减的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2634460/

相关文章:

C++ - 如何有效地找出 vector 中的任何字符串是否可以从一组字母中组装出来

computer-science - 熵的计算机科学定义是什么?

c++ - Dijkstra 算法 w/Adjacency List Map c++

algorithm - Dijkstra 的最短路径算法如果存在距离相同的路径怎么办?

C中的凯撒密码,大写和小写

c++ - 从 x 到 y 算法打印素数

查找多个字符串匹配的算法

c++ - 如何使用主 C++ 程序构建声音相关库(不使用任何第三方库)

algorithm - 二进制搜索与线性搜索(数据结构和算法)

java - Dijkstra 用于邻接矩阵、最短且最便宜的路径、单一源、单一目标