What is the rule for selecting the next vertex to process in Dijkstra's algorithm?
The rule is to select the uncircled vertex with the smallest tentative distance label. This vertex is then circled to mark it as settled, and a predecessor arrow is drawn from the vertex that supplied this smallest distance. This greedy choice ensures that the shortest path to the selected vertex is finalized.
Conditions
- There are uncircled vertices with assigned distance labels.
- The algorithm is in the selection phase after updating neighbors.
Reasoning, step by step
- Scan all uncircled vertices for their tentative distance labels.
- Identify the smallest label among them.
- Select the vertex corresponding to this smallest label.
- Circle this vertex to mark it as settled.
- Draw an arrow from its predecessor to record the path.
- Proceed to update the neighbors of this newly settled vertex.
Example
In the video, after initializing home, the uncircled vertices are and . The smallest is 2 at A, so A is circled. Later, among uncircled vertices , , , , the smallest is 3 at C, so C is circled. The speaker says: "Now we look for the smallest uncircled number that we've written on our graph. In this case it's two, so we're going to circle that..."
Common misconceptions
- Selecting the vertex with the largest distance.
- Selecting a vertex that is already circled.
- Ignoring the distance labels and choosing randomly.
Watch the explanation
0:41 – 0:54Watch this moment ↗
Explore next
- How do you update the neighbors of the current circled vertex in Dijkstra's algorithm?
- Why does Dijkstra's algorithm not finalize the destination label 7 at university immediately when it first appears?
- What do the numeric labels and blue circles at the vertices represent in the Dijkstra's algorithm demonstration?
Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.