Table of Contents
Fetching ...

A Polynomial-Time Algorithm for the Next-to-Shortest Path Problem on Positively Weighted Directed Graphs

Kuowen Chen, Nicole Wein, Yiran Zhang

TL;DR

This work resolves the long-standing open question of whether a next-to-shortest $s\to t$ path can be found in polynomial time for directed graphs with positive edge weights by introducing a reduction to $(s,t)$-layered graphs and proving a central Key Lemma. The approach decomposes any not-shortest $s\to t$ path into a middle subpath flanked by two forward-disjoint paths, enabling a construction that combines two forward paths with a shortest middle segment to yield a next-to-shortest path. The authors develop a layered-graph algorithm NextSP-Layered, with a complexity bound of $O(|V|^4|E|^3\log |V|)$, and provide a reduction pipeline through $(s,t)$-straight graphs to layered graphs, ensuring polynomial-time solvability for all positively weighted directed graphs. This advances the theory of near-shortest paths and provides a practical framework for computing strictly second-shortest paths in directed, positively weighted networks. The results have implications for network design and routing where near-optimal alternatives are required efficiently, and they settle a nearly 30-year-old open problem in the affirmative under $P\neq NP$-style assumptions.

Abstract

Given a graph and a pair of terminals $s$, $t$, the next-to-shortest path problem asks for an $s\!\to \!t$ (simple) path that is shortest among all not shortest $s\!\to \!t$ paths (if one exists). This problem was introduced in 1996, and soon after was shown to be NP-complete for directed graphs with non-negative edge weights, leaving open the case of positive edge weights. Subsequent work investigated this open question, and developed polynomial-time algorithms for the cases of undirected graphs and planar directed graphs. In this work, we resolve this nearly 30-year-old open problem by providing an algorithm for the next-to-shortest path problem on directed graphs with positive edge weights.

A Polynomial-Time Algorithm for the Next-to-Shortest Path Problem on Positively Weighted Directed Graphs

TL;DR

This work resolves the long-standing open question of whether a next-to-shortest path can be found in polynomial time for directed graphs with positive edge weights by introducing a reduction to -layered graphs and proving a central Key Lemma. The approach decomposes any not-shortest path into a middle subpath flanked by two forward-disjoint paths, enabling a construction that combines two forward paths with a shortest middle segment to yield a next-to-shortest path. The authors develop a layered-graph algorithm NextSP-Layered, with a complexity bound of , and provide a reduction pipeline through -straight graphs to layered graphs, ensuring polynomial-time solvability for all positively weighted directed graphs. This advances the theory of near-shortest paths and provides a practical framework for computing strictly second-shortest paths in directed, positively weighted networks. The results have implications for network design and routing where near-optimal alternatives are required efficiently, and they settle a nearly 30-year-old open problem in the affirmative under -style assumptions.

Abstract

Given a graph and a pair of terminals , , the next-to-shortest path problem asks for an (simple) path that is shortest among all not shortest paths (if one exists). This problem was introduced in 1996, and soon after was shown to be NP-complete for directed graphs with non-negative edge weights, leaving open the case of positive edge weights. Subsequent work investigated this open question, and developed polynomial-time algorithms for the cases of undirected graphs and planar directed graphs. In this work, we resolve this nearly 30-year-old open problem by providing an algorithm for the next-to-shortest path problem on directed graphs with positive edge weights.

Paper Structure

This paper contains 26 sections, 20 theorems, 27 equations, 7 figures.

Key Result

Theorem 1.1

Given a directed graph $G=(V,E,w)$, where $w: E\rightarrow \mathbb{R}_{>0}$ assigns the edge weights, and two vertices $s,t\in V$, there exists an $O(|V|^4|E|^3\log |V|)$-time algorithm that determines if there exists a next-to-shortest path from $s$ to $t$, and if so, outputs such a path.

Figures (7)

  • Figure 1: Illustration of the reduction: (a) a subgraph of $G$, and (b) the corresponding subgraph in $G'$ obtained by modification.
  • Figure 2: An illustration of Back-Edge Decomposition.
  • Figure 3: An illustration of $(X',X),(Y',Y)$ and $P^{*}$ in \ref{['lem:key']}
  • Figure 4: An example of \ref{['def:updown']}. $P$ is a path from $u_1$ to $u_7$, and $V^{\operatorname{inter}}(P_1^{*},P_2^{*};P)=\lbrace u_1,u_2,\ldots,u_7\rbrace$. $P_{u_1\to u_2},P_{u_2\to u_3},P_{u_3\to u_4}$ and $P_{u_5\to u_6}$ are gap-paths. However, $P_{u_2\to u_3}$ and $P_{u_3\to u_4}$ contain no gap-vertices. $P_{u_4\to u_5}$ is a down-path. $P_{u_6\to u_7}$ is an up-path.
  • Figure 5: An illustration of proof for \ref{['lem:up-vertex-only']}.
  • ...and 2 more figures

Theorems & Definitions (43)

  • Theorem 1.1
  • Definition 3.1: $s\!\!\to\!\! t$ Not-Shortest and Next-to-Shortest Paths
  • Definition 3.2: The Next-to-Shortest Path Problem
  • Lemma 3.1
  • proof
  • Lemma 3.2: tholey2012linear
  • Definition 4.1: $(s,t)$-Layered Graph
  • Theorem 4.1
  • Definition 4.2: Shortcut Edge
  • Definition 4.3: $\pi$
  • ...and 33 more