Untitled Document
Untitled Document
● Dijkstra's algorithm finds the shortest path from one vertex to all
other vertices.
● It does so by repeatedly selecting the nearest unvisited vertex and
calculating the distance to all the unvisited neighboring vertices.
● Dijkstra's shortest path algorithm was invented in 1956 by the
Dutch computer scientist Edsger W. Dijkstra during a twenty
minutes coffee break, while out shopping with his fiancée in
Amsterdam.
● The reason for inventing the algorithm was to test a new computer
called ARMAC.
● Dijkstra's algorithm is often considered to be the most
straightforward algorithm for solving the shortest path problem.
● Dijkstra's algorithm is used for solving single-source shortest path
problems for directed or undirected paths.
● Single-source means that one vertex is chosen to be the start, and
the algorithm will find the shortest path from that vertex to all other
vertices.
● Dijkstra's algorithm does not work for graphs with negative edges.
● To find the shortest path, Dijkstra's algorithm needs to know which
vertex is the source.
Each Vertex in this Algorithm will have two properties defined for it:
1. Visited Property
2. Path Property
Visited Property:
1. The 'visited' property signifies whether or not the node has been visited.
2. We are using this property so that we do not revisit any node.
3. A node is marked visited only when the shortest path has been found.
Path Property:
1. The 'path' property stores the value of the current minimum path to the
node.
2. The current minimum path implies the shortest way we have reached this
node till now.
3. This property is revised when any neighbor of the node is visited.