Video summary

Dijkstras Shortest Path Algorithm Explained | With Example | Graph Theory

Main summary

Key takeaways

Educational

Summary

Dijkstra’s algorithm finds the shortest distance from one starting node to every other node in a weighted graph. The video demonstrates the algorithm on a graph starting at node A, using a city-and-route analogy.

Method

  1. Track visited and unvisited nodes. Initially, every node is unvisited, and the visited list is empty.
  2. Set tentative distances and predecessors. Assign the starting node a distance of 0 and every other node a distance of infinity. Keep a predecessor for each node so the route can later be reconstructed; initially, these are blank.
  3. Explore the current node’s unvisited neighbors. Add the current node’s tentative distance to the weight of each edge leading to an unvisited neighbor. If the result is smaller than that neighbor’s recorded distance, update its distance and set the current node as its predecessor.
  4. Mark the current node visited. Once its unvisited neighbors have been checked, move it from the unvisited list to the visited list.
  5. Choose the next current node. Select the unvisited node with the smallest tentative distance, then repeat the neighbor checks and updates. Continue until all nodes have been processed.

Example results

Starting from A, the algorithm proceeds through the unvisited nodes with the lowest distances and eventually finds these shortest distances:

  • A: 0
  • B: 2
  • D: 7
  • E: 8
  • F: 9
  • C: 12

To reconstruct the shortest route from A to C, follow the predecessors backward from C: C ← F ← D ← B ← A. Reversing that sequence gives A → B → D → F → C, with a total distance of 12.

Predecessor records are useful not only for finding the shortest distances, but also for recovering the paths that achieve them.

Speakers or sources

  • Speaker: One narrator presents the explanation.
  • Other sources: No additional speakers or sources are featured.

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video