Problem Solving

Shortest Path

Students compare highlighted routes on a classroom map.

Shortest Path definition

A shortest path between two vertices is a path with the smallest total length among paths joining them.

In Spanish
camino más corto
Topic
Graph algorithms and networks

Shortest Path in a picture

Shortest Path diagramA route of two edges weighing 2 and 3 is shorter than one direct edge weighing 7.Direct path: A to CIt has weight 7Via B: A to B to CIts edge weights add to 2 + 3Choose total weight 5It beats the direct path’s weight 7
A route of two edges weighing 2 and 3 is shorter than one direct edge weighing 7.

How it works

In an unweighted graph, length counts edges. In a weighted graph, add the weights of the edges used. The path can be tied with another route, and no path exists when the destination is unreachable from the start.

Worked examples

A route has weights 4, 2, and 1. What is its length?

7.

In an unweighted graph, which is shorter: two edges or three?

Two edges.

Can there be two different shortest routes?

Yes. Two paths can have the same minimum total weight.

Common mistake

Count edges only in an unweighted graph or when every edge has the same positive cost.

Quick check

Which route is shorter: one edge of weight 8, or two edges of weights 3 and 2?

What if no path reaches the destination?

Show answer

There is no shortest path to it.

Can direction change which routes are possible?

Show answer

Yes, in a directed graph.

Sources

Flashcard

Shortest Path

Reveal the definition

A shortest path between two vertices is a path with the smallest total length among paths joining them.

Effortless Math. “Shortest Path.” Math Dictionary.