Question: Create a priority queue and add starting vertex (source) with distance of 0 Add remaining n-1 vertices to priority queue with distance of infinity
Create a priority queue and add starting vertex (source) with distance of 0 Add remaining n-1 vertices to priority queue with distance of infinity (i.e. sys.maxsize) Iterate over each item in the priority queue remove item from the priority queue get distances between this item and its adjacent vertices (plus current dist to source) if this distance is less than current distance to source, then update it continue until priority queue is empty
Step by Step Solution
3.49 Rating (156 Votes )
There are 3 Steps involved in it
It seems like youre describing the process of implementing Dijkstras algorithm for finding the shortest path in a weighted graph Ill break down your i... View full answer
Get step-by-step solutions from verified subject matter experts
