LearnViz Math
Expert ⛓ Discrete Math & Number Theory Topic 58 of 103

Shortest Paths (Dijkstra)

Find least-cost routes from a source.

Key idea

Find least-cost routes from a source.

In depth

Dijkstra’s algorithm repeatedly finalises the unvisited vertex with the smallest tentative distance and relaxes its neighbours. It works because all edge weights are non-negative, so a finalised distance cannot be improved later.

Worked example

From A: to B costs 4, to C costs 1, C → B costs 2, so B’s best distance is 3.

Real-world uses

Common mistake

Using it with negative edge weights.

How to learn this

  1. Read the key idea and say it in your own words.
  2. Work through the worked example, then try a similar problem.
  3. Use the interactive lesson’s visual and mini-quiz to check the pattern.

Frequently asked questions

What is Shortest Paths (Dijkstra)?

Find least-cost routes from a source. It is a topic at the expert level in Discrete Math & Number Theory.

Where is Shortest Paths (Dijkstra) used in real life?

Real-world examples: Finding the quickest route in a satellite navigation app or the cheapest flight path.

What should I learn before Shortest Paths (Dijkstra)?

Make sure you are comfortable with Minimum Spanning Trees, the previous topic in Discrete Math & Number Theory.

What is a common mistake with Shortest Paths (Dijkstra)?

Using it with negative edge weights.

How can I practise Shortest Paths (Dijkstra)?

Open the interactive lesson, play with the visual, then answer the three-question mini-quiz. Getting two right marks the topic complete.

What comes after Shortest Paths (Dijkstra)?

Move on to Breadth- and Depth-First Search next.

Related expert topics in Discrete Math & Number Theory