Lably
Skip to content

Shortest path problem

Computational problem of graph theory

  • 12 min read
  • 10 chapters

Related on Lably

Through Graph (discrete mathematics), Sequence and Function (mathematics)

The problem of finding the shortest path between two intersections on a road map may be modeled as a special case of the shortest path problem in graphs, where the vertices correspond to intersections and the edges correspond to road segments, each weighted by the length or distance of each segment.

Definition

The shortest path problem can be defined for graphs whether undirected, directed, or mixed. The definition for undirected graphs states that every edge can be traversed in either direction. Directed graphs require that consecutive vertices be connected by an appropriate directed edge.

Two vertices are adjacent when they are both incident to a common edge. A path in an undirected graph is a sequence of vertices P=(v1,v2,…,vn)∈V×V×⋯×V such that vi is adjacent to vi+1 for 1≤i<n. Such a path P is called a path of length n−1 from v1 to vn. (The vi are variables; their numbering relates to their position in the sequence and need not relate to a canonical labeling.)

Let E={ei,j} where ei,j is the edge incident to both vi and vj. Given a real-valued weight function f:E→R, and an undirected (simple) graph G, the shortest path from v to v′ is the path P=(v1,v2,…,vn) (where v1=v and vn=v′) that over all possible n minimizes the sum ∑i=1n−1f(ei,i+1). When each edge in the graph has unit weight or f:E→{1}, this is equivalent to finding the path with fewest edges.

The problem is also sometimes called the single-pair shortest path problem, to distinguish it from the following variations:

  • The single-source shortest path problem, in which we have to find shortest paths from a source vertex v to all other vertices in the graph.
  • The single-destination shortest path problem, in which we have to find shortest paths from all vertices in the directed graph to a single destination vertex v. This can be reduced to the single-source shortest path problem by reversing the arcs in the directed graph.
  • The all-pairs shortest path problem, in which we have to find shortest paths between every pair of vertices v, v' in the graph.

These generalizations have significantly more efficient algorithms than the simplistic approach of running a single-pair shortest path algorithm on all relevant pairs of vertices.

Sign in to keep reading

9 more chapters are free with a Lably account.

More in Discrete mathematics