LEARN MORE ABOUT SHORTEST PATHS AND DIJKSTRA'S ALGORITHM!
STEPS ON HOW TO PERFORM DIJKSTRA'S ALGORITHM
Start at the node at which you are starting. Set its distance to 0. For all other vertices in the graph, set their initial distance to infinity. Also, create a set of all unvisited nodes.
Visit the unvisited node with the smallest known distance from the start node (initially, this would be the start node itself) and mark it as "visited".Â
For the current node, consider all of its unvisited neighbors. Calculate their tentative distances from the start node. If the newly calculated tentative distance is less than the current assigned value, update the shortest distance.
If there are unvisited nodes, go to the one with the smallest known distance and repeat the process from step 3. If there are no unvisited nodes left or if the destination node has been marked visited, the algorithm has finished.
At the end of the algorithm, the shortest path from the start node to any other node in the graph can be determined by backtracking from the destination node to the start node, always moving to the node with the next shortest distance.