Dijkastra’s Algorithms! (SPF-hortest Path Finder Algorithm!)
April 27, 2021Posted by on
Steps to perform Algorithm:
- Mark all nodes as un-Visited.
- Set values to all nodes, Set zero for Initial-Node/First-Node, and infinity for all other nodes.
- Visit all adjacent-Nodes and update the assigned values if new-found-Value is less than already assigned value.
- When completed visit of all adjacent nodes for current-node Mark current Node as Visited and Remove it from UnVisited List.
- If the destination node has been marked visited (when planning a route between two specific nodes) or if the smallest tentative distance among the nodes in the unvisited set is infinity (when planning a complete traversal; occurs when there is no connection between the initial node and remaining unvisited nodes), then stop. The algorithm has finished.
- Otherwise, select the unvisited node that is marked with the smallest tentative distance, set it as the new “current node”, and go back to step 3.