We introduce and study Dijkstra's algorithm. This algorithm is an example of a greedy algorithm. It finds the shortest distance from a source to all other nodes or vertices in a graph. By the end of this section, you will come to understand why it is classified as a greedy algorithm.

Consider the following graph:

By inspection, the first answer to the question of finding the shortest path between node **A** and node **D** that comes to mind is the edge with value or distance 9. From the diagram, it would seem that the straight path from node **A** to **D** would also yield the shortest route between the two nodes. But the ...