A greedy algorithm where, given a source node and a weighted graph, returns the shortest path from the source to all the other vertices in the given graph. It solves the single source shortest path problem.

Restrictions

Abstract

Keep a list of all unvisited nodes and the distances from each node to the initial node. Repeatedly visit an unvisited node with the shortest distance to the source node. Then it repeatedly attempts the process of ==expansion==. The algorithm checks if using the current node as an intermediary (pit stop), will result in a quicker path to it’s neighbours. If it does result in a faster path, it will set the distance to the neighbour node through the intermediary as the new shorter distance.

Performance

  • Time complexity:

Visualisation

Implementation

Proof

unsure if correct please check #K

let represent the shortest distance from node to node that the algorithm has found so far. let represent the actual shortest distance from node to node . Let be the statement that Dijkstra’s gives the correct shortest path for a graph with nodes. Let be starting node.

Prove

Let there be a graph with a singular node Thus is true.

Assume is True

Prove

For graph with nodes, when algorithm completes up to -th iteration. As is assumed to be true:

If number of edges in diameter of is less than or if not one of the endpoints for any diameter; the longest possible ‘shortest path’ consists of less than edges. Then the shortest distances would have already been found, and would not be affected by further calculations.

Thus is True given above condition.

However if number of edges in diameter of is , and is one of the endpoints of this diameter, the longest ‘shortest path’ and the only path not found after -th iterations, consists of edges and nodes. Need to prove for this case.

Prove for the latter case:

Need to prove the algorithm can find this longest ‘shortest path’. Let be a list of nodes, where is the source node, that represent the aforementioned longest possible ‘shortest path’ that runs along the diameter of the graph.

After the -th iteration, by our assumption of : for all .

Before the -th iteration: , and .

During the -th iteration: Thus by now .

As such for a graph with nodes, by the -th iteration, all paths consisting of or less edges would have been found and computed.

Conclusion