The shortest path problem seeks to find the shortest path (a.k.a. graph geodesic) connecting two specific vertices of a directed or undirected graph. The length of the graph geodesic between these points
is called the graph distance
between
and
. Common algorithms for solving the shortest path problem
include the Bellman-Ford algorithm and
Dijkstra's algorithm.
This problem is central to route planning and pathfinding applications, where vertices and edges may represent intersections and roads in a weighted transportation network. When travel times depend on edge flows, each route used at equilibrium is a shortest path for the travel times induced by those flows. Adding an edge can raise the equilibrium travel time, as in Braess's paradox.
The Wolfram Language function FindShortestPath[g,
u, v] can be used to find one (of possibly mutiple) shortest path between
vertices
and
in a graph
.
The so-called reaching algorithm can solve the shortest path problem on an -edge graph in
steps for an acyclic digraph
although it allows edges to be traversed opposite their direction and given a negative
length.
Gholami and Hajiaghayi (2026) report an exact randomized single-source algorithm for undirected graphs with nonnegative real edge lengths in the comparison-addition
model. On a graph with vertices and
edges, its expected time is
. It terminates almost surely and every
terminating run returns exact distances and a shortest-path tree on reachable vertices.
GPT Astra assisted proof development. The released Lean model uses named external
assumptions for static tree queries.
A customizable contraction hierarchy separates preprocessing of a fixed graph from the choice of nonnegative edge weights (Dibbelt et al. 2016). For an undirected graph, choose a vertex order and eliminate vertices in that order, adding shortcut edges to connect each pair of remaining neighbors of an eliminated vertex. For each choice of input weights, initialize new edges with infinite weight. Then process vertices in the same order, using each two-edge walk through the current vertex to lower the weight of the corresponding shortcut or original edge whenever the walk is shorter.
Each finite edge weight after customization is the length of a walk in the original graph. Conversely, a shortest path can be made to increase in rank and then decrease by replacing each interior local minimum in rank with its shortcut. Thus a query can run Dijkstra's algorithm from each endpoint, following edges toward higher ranks, and minimize the sum of the two distances over common reachable vertices. A recursive ordering by vertex separators places each separator after the components it separates (Dibbelt et al. 2016).