arXiv:2610.20062cs.DSOct 2026

Manuscript Offprint

arXiv:2610.20062

Towards Dynamic Top-kk Simple Shortest Paths

Gianlorenzo D'Angelo, Andrea D'Ascenzo, Mattia D'Emidio, Gabriele Di Stefano, Marta Innamorati

Abstract

Computing the top-k simple shortest paths between two vertices of a graph, i.e., solving the P-KSSP problem, is a fundamental primitive in graph analytics. In modern scenarios, however, queries are rarely one-shot: parameters change as applications adapt their information needs, and recomputing a solution from scratch at every request quickly becomes a bottleneck. We study P-KSSP in a dynamic setting, focusing on changes of the parameter kk: given a top-k solution for a pair of vertices and a new value k′k', the goal is to compute a top- k′k' solution reusing the previously computed paths. Our approach rests on the pseudo-tree, a compact representation of a collection of simple s-t paths: we show that building it from an arbitrary, unstructured solution amounts to trie construction, and give two constructions running in time linear in the size of the collection, in expectation and, up to an additive term linear in the number of vertices, in the worst case. On top of it, we design UPD, a dynamic algorithm that updates a solution upon a change of kk; we prove its correctness, analyze its complexity, and show that it is a general, solver-agnostic scheme, which starts from the paths alone, is parametric in the routine that generates candidate paths and combinable with known preprocessing techniques, as well as with an online pruning rule that we formalize. While a worst-case update is asymptotically comparable to recomputing from scratch, an extensive experimental evaluation shows that a variant of UPD is the fastest method in the large majority of tested configurations, often by a wide margin (with speedups over recomputation that grow with kk and k′k' and exceed 60×60\times), yielding a practical recipe for the configuration to deploy.

1 Introduction

Computing shortest paths is one of the most fundamental operations on graph data, serving applications that range from communication protocols [21] and trip planning [10] to vehicle routing [4] and network design [5, 7]. A natural, long-studied generalization is the k shortest paths problem, which asks for a collection of top-k paths in non-decreasing order of weight [17, 33, 34]. It supports all tasks requiring several alternative connections between two vertices (e.g., adaptive motion planning, secure multi-hop communication, fraud detection, and natural language processing [2, 13, 26–28]), and top-k paths are widely employed as a measure of distance and similarity between vertices in graph learning and network analytics [2, 12, 17]. When the sought paths are required to be simple (i.e., loopless), the problem becomes computationally harder [1]; we focus on its single-pair version, the Single-Pair Top-k Simple Shortest Paths problem (P-KSSP for short).

∗^{*}A preliminary version of this paper appears in the proceedings of the 14th International Symposium on Computing and Networking (CANDAR 2026). Partially supported by the MUR (Italy) Department of Excellence 2023–2027 and by the National Group for Scientific Computation of Istituto Nazionale di Alta Matematica (GNCS-INdAM).

For P-KSSP on general graphs, the most efficient known algorithm remains Yen’s [33], running in O(kn(m+nlog⁡n))\mathcal{O}(kn(m + n \log n)) time on an n-vertex, m-edge graph; no asymptotic improvement is known [20, 23, 34], better bounds exist only for special graph classes [22, 29], and conditional lower bounds tie the problem to all-pairs shortest paths [32]. In practice, however, the node-classification algorithm [20], the sidetrack-based method [23], the postponed node classification (PNC) algorithm [34], and the recent PEEK framework [18] all match Yen’s worst-case complexity yet run substantially faster on practically relevant inputs, with PNC providing the largest speedups in most cases without increasing space occupancy (the others pay a high memory overhead [23] or rely on parallelism [18]). Still, on massive graphs even such carefully engineered methods are expensive to run.

A further source of difficulty is that inputs and parameters are rarely static: real-world graphs evolve over time [2, 9, 12], and the parameters of the queries themselves change as applications adapt their information needs [2, 11]. Recomputing from scratch at every request is wasteful and, at scale, impractical, which has motivated a large body of work on dynamic algorithms that update previously computed structures more efficiently than recomputation [11–13]. For k shortest paths this has only recently begun to be addressed [12], and, to the best of our knowledge, the dynamic computation of top-k simple shortest paths is still unexplored.

In this paper we take a step in this direction by studying P-KSSP under changes of the parameter kk: given a previously computed top-k solution for a pair s,ts, t and a new value k′k', compute a top- k′k' solution reusing, as much as possible, the paths already at hand. Increases of the parameter ( k′>kk' > k) arise whenever only a few paths are initially computed, typically to meet a time budget, and more are needed later, e.g., to offer further routing alternatives, as journey planners do when a user asks for more routes [27], or to improve path-based features in graph learning. A notable instance is the common heuristic for top-k queries with diversity, which seek kk short yet mutually dissimilar paths (an NP-hard problem, addressed by exact, approximate, and heuristic methods [8, 27, 28]): one computes a top-k solution, filters it by a dissimilarity criterion and, if fewer than the required paths survive, asks for a top- k′k' solution with k′≫kk' \gg k, repeating until enough dissimilar paths are found [8]. One might object that a from-scratch algorithm such as YEN could simply be suspended after the kk-th path and resumed on demand. This is viable only in a narrow setting: the initial solution must have been produced by that very algorithm, and its whole internal state (notably, the priority queue of candidate deviations) must be retained per queried pair, a footprint that largely exceeds the solution's and is prohibitive when many pairs are queried. Moreover, the available paths may not have been computed by a single-pair algorithm at all. A concrete instance arises in the single-source variant of the problem (S-KSSP): the recent algorithm of [16] obtains, as a by-product of its single-source enumeration, k^<k\hat{k} < k top simple shortest paths for specific pairs and must complete them to top-k solutions; lacking a dynamic procedure, it recomputes them from scratch, as no single-pair solver state exists to resume. The update must thus start from the previously computed paths alone, regardless of how they were obtained: this is precisely our setting. Decreases ( k′<kk' < k) arise when fewer paths turn out to suffice and the excess is discarded to save space. The values of kk relevant in these scenarios are often in the hundreds or beyond: diversity queries discard most of the top-k paths as too similar [8], path-based features in graph learning and network analytics aggregate over large sets of alternatives [2, 12, 17], in S-KSSP every pair inherits the (possibly large) kk of the single-source query [16], and robust routing in communication networks explores many near-shortest alternatives [21]; accordingly, experimental studies of P-KSSP routinely evaluate kk in the thousands, up to 10410^4 [18, 23, 34].

References (31)