Skip to content
START WITH A QUESTION

What would you like to understand?

Find an answer. See the moment it becomes clear. Follow the idea further.

← Concept directory

Answers for “'prev' 数组在 Dijkstra 算法中的作用是什么?”

1 keyword matches

Understanding your question. You can explore the search results below now.

Meet the concept

↗

The pseudocode initializes distances to infinity and predecessors to nil, sets the source distance to 0, and uses a priority queue H. It repeatedly extracts the vertex u with the minimum distance, relaxes all outgoing edges (u,v), updating dist(v) and prev(v) if a shorter path is found, and decreases the key of v in H.

Conditions: Input: Graph G=(V,E)G = (V, E), directed or undirected.; Positive edge lengths {lel_e : e∈Ee \in E}.; Source vertex s∈Vs \in V.; Output: dist(u) is the shortest distance from s to u for all reachable u.