Measuring Shortest Routes by Edge Count
In a graph where each permitted step has equal cost, a shortest route minimizes the number of edges traversed.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Read a route with intermediates
A, B, C, D has four vertices and three edges. If there is a link A–D, that direct route has length one. The source itself has length zero. Paths and walks describe which sequences qualify.
Choose the correct traversal
A depth-first route might reach D via the long branch first. A breadth-first trace reaches vertices in distance order for equal-cost edges, giving the shorter route under that model.[1]
Count steps instead of deciding by drawing length
Roads A–B, A–C, C–D, B–E and E–D provide routes from A to D with two and three edges. The route through C is shortest in the unweighted model regardless of the geometric length of each road on a drawing. See breadth-first search.
Distance 0: A
Distance 1: B,C
Distance 2: D,E
Route A–C–D uses two edges
Distinguish distance from a route witness
Several shortest routes can share the same distance. If a caller wants the actual path, retain predecessors. Distances are defined only for reachable targets unless the interface uses a documented infinity sentinel.