5

In the proof of the correctness of Dijkstra algorithm, there is a lemma stating as follow:

Let u be v's predecessor on a shortest path P: s->...->u->v from s to v. Then, If d(u) = δ(s,u) and edge (u, v) is relaxed, we have d(v) = δ(s,v), where funciton δ(x, y) denotes the minimum path weight from x to y.

I wonder why we need the condition d(u) = δ(s,u) in this lemma. If Path P: s->...->u->v is a shortest path from s to v, then by the property of optimal substructure, the subpath s->...->u of P must also be a shortest path from s to u. Therefore, d(u) must equal to δ(s,u).

Does there exist the case that d(u) ≠ δ(s,u) but P: s->...->u->v is a shortest from s to v? If it does, can someone offer an example here.

Any help will be appreciated.

sundaycat
  • 162
  • 7
  • I'm voting to close this question as off-topic because Stack Overflow is for coding problems; this is foundations of computing. Code implementations are independent of whether the coder understands details of a particular proof. – Prune Jan 10 '19 at 21:54
  • Hi, @Prune. Thank you for the comment, would you please also tell me where I should post this question on this website? – sundaycat Jan 10 '19 at 21:57
  • @SundayCat https://cs.stackexchange.com/questions/ – merlyn Jan 10 '19 at 22:03
  • 3
    @Prune I disagree - questions about algorithms are *explicitly* on-topic here. The [on-topic guide](https://stackoverflow.com/help/on-topic) states: "We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers… a software algorithm..., then you're in the right place to ask your question!" This is a specific question about a specific algorithm, so it's on-topic here. In fact, I think it's a well-formulated question and upvoted it. – EJoshuaS - Stand with Ukraine Jan 11 '19 at 14:32
  • Disagreement is fine; that's how we evolve and refine the site charter. This question asks about the *rationale* behind a step in the *correctness proof* of a well-established algorithm. I personally feel that this is one step beyond the Stack Overflow charter, although well within the range of other Stack Exchange groups. Obviously, I'm in the minority here. – Prune Jan 11 '19 at 17:47
  • There are different formulations of the Dijkstra algorithm. Can you add your formulation to your post? The formulation i know does not fit with the proof :-) – Christian H. Kuhn Aug 13 '19 at 21:33

1 Answers1

0

Yes, we must need that lemma. When we are running the algorithm, distance to u is changing until we got a shortest distance to u. For example, if u is reached by some node a, and distance from s to u via a is d(u) but not optimal, and later in the algorithm. We found out that from s to u via b is the shortest path. So at this point, d(u) becomes the optimal.

Hope this helps.

Shizhen Li
  • 11
  • 1