Skip to content

Commit 36281d9

Browse files
committed
fix wrong variable name in proof
Closes cp-algorithms#680
1 parent 1694330 commit 36281d9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/graph/dijkstra.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ The proof is done by induction. For the first iteration this statement is obviou
5252

5353
Consider the shortest path $P$ to the vertex $v$. This path can be split into two parts: $P_1$ which consists of only marked nodes (at least the starting vertex $s$ is part of $P_1$), and the rest of the path $P_2$ (it may include a marked vertex, but it always starts with an unmarked vertex). Let's denote the first vertex of the path $P_2$ as $p$, and the last vertex of the path $P_1$ as $q$.
5454

55-
First we prove our statement for the vertex $p$, i.e. let's prove that $d[p] = l[p]$. This is almost obvious: on one of the previous iterations we chose the vertex $q$ and performed relaxation from it. Since (by virtue of the choice of vertex $p$) the shortest path to $p$ is the shortest path to $q$ plus edge $(p,q)$, the relaxation from $q$ set the value of $d[p]$ to the length of the shortest path $l[q]$.
55+
First we prove our statement for the vertex $p$, i.e. let's prove that $d[p] = l[p]$.
56+
This is almost obvious: on one of the previous iterations we chose the vertex $q$ and performed relaxation from it.
57+
Since (by virtue of the choice of vertex $p$) the shortest path to $p$ is the shortest path to $q$ plus edge $(p,q)$, the relaxation from $q$ set the value of $d[p]$ to the length of the shortest path $l[p]$.
5658

5759
Since the edges' weights are non-negative, the length of the shortest path $l[p]$ (which we just proved to be equal to $d[p]$) does not exceed the length $l[v]$ of the shortest path to the vertex $v$. Given that $l[v] \le d[v]$ (because Dijkstra's algorithm could not have found a shorter way than the shortest possible one), we get the inequality:
5860

0 commit comments

Comments
 (0)