Algorithm for Dijkstra’s Algorithm
- Mark the source node with a current distance of 0 and the rest with infinity.
- Set the non-visited node with the smallest current distance as the current node.
- For each neighbor, N of the current node adds the current distance of the adjacent node with the weight of the edge connecting 0->1. If it is smaller than the current distance of Node, set it as the new current distance of N.
- Mark the current node 1 as visited.
- Go to step 2 if there are any nodes are unvisited.
What is Dijkstra’s Algorithm? | Introduction to Dijkstra’s Shortest Path Algorithm
In this article, we will be discussing one of the most commonly known shortest-path algorithms i.e. Dijkstra’s Shortest Path Algorithm which was developed by Dutch computer scientist Edsger W. Dijkstra in 1956. Moreover, we will do a complexity analysis for this algorithm and also see how it differs from other shortest-path algorithms.
Table of Content
- Dijkstra’s Algorithm
- Need for Dijkstra’s Algorithm (Purpose and Use-Cases)
- Can Dijkstra’s Algorithm work on both Directed and Undirected graphs?
- Algorithm for Dijkstra’s Algorithm
- How does Dijkstra’s Algorithm works?
- Pseudo Code for Dijkstra’s Algorithm
- Implemention of Dijkstra’s Algorithm:
- Dijkstra’s Algorithms vs Bellman-Ford Algorithm
- Dijkstra’s Algorithm vs Floyd-Warshall Algorithm
- Dijkstra’s Algorithm vs A* Algorithm
- Practice Problems on Dijkstra’s Algorithm
- Conclusion: