Understanding Dijkstra's algorithm
Dijkstra's algorithm is a single-source shortest path finding algorithm that can solve this problem for graphs with non-negative edge weights. It is a generalized form of breadth-first search, using the same idea but generalizing the order of visiting nodes. The breadth-first search algorithm determines the order of nodes to visit based on their depth from the source node, whereas Dijkstra's algorithm does the same based on the distance from the source node.
The depth of a node is the minimum number of edges between itself and the source, whereas the distance is the minimum sum of edge weights between itself and the source. For an unweighted graph or a graph where all edge weights are the same, depth and distance mean the same thing and as we will see later, Dijkstra's algorithm will visit them in the same order as the breadth-first search
Definition of distance for unweighted and weighted graphs
Liking the course? Check our discounted plans to continue learning.