Manuscript Offprint
arXiv:2610.18337A Deterministic Near-Linear Time Approximation Algorithm for Restricted Shortest Paths in Directed Graphs
Abstract
In the restricted shortest paths problem, we are given an -vertex -edge graph whose edges are assigned two non-negative weights (or resources) called lengths and costs, a source vertex , and a cost threshold . The goal is to find, for each target vertex , the length of the shortest -path whose total cost is at most .
[ABK25] gave the first randomized bicriteria -approximate algorithm on directed graphs running in sub-mn time, answering a problem posed by [Ber12]. We substantially improve this on two fronts, supplying a deterministic bicriteria -approximate algorithm running in near-linear time.
Our approach straightforwardly generalizes to more than two resources. For resources, a deterministic -approximate algorithm running in near-linear time is possible.
times
AI Statement. Some version of Theorem 1 was elicited through numerous discussions with GPT-6 Astra and older GPT models, under human guidance. The narrativization of the results is my own.
1 Introduction
The restricted shortest paths (RSP) problem puts a natural and practically relevant spin on a truly classical problem: shortest paths. In the shortest paths problem, we ask: how quickly can we get from s to t? This is well studied and, to any non-specialist, solved for all intents and purposes. The simple twist is to ask: how quickly and cheaply can we get from s to t?
In the RSP problem, we are given a graph equipped with exactly two non-negative functions assigning two unrelated weights (or resources) – called lengths and costs – to the edges of . For a source-target pair , and a cost threshold , the goal is to find the shortest length -path in whose total cost is no more than . While it is barely any harder a problem to state than shortest paths, RSP models real-world concerns much more potently, with applications spanning quality of service (QoS) routing [LO98, YF03], scheduling [BCL 10, NST07], and other areas of operations research (see, e.g., [GGT10]).
More generally, the paths we look for may be subject to numerous constraints. For example, when planning a long journey, there are many factors to take into account: the total price, number of transfers, trip length, carbon footprint, etc. Problems of this kind are collectively known as multi-constrained path problems (see, e.g., [GGT10, XZTT08]) or, in this paper, RSP with k resources when there is one objective and constraints, all of which must be simultaneously satisfied.
The cognoscenti, however, would see an abundance of open problems spanning negative weights [BNW22], negative real weights [Fin24], universal optimality [HHR 24], breaking sorting barriers [DMM 25], etc.
Unlike shortest paths, RSP is known to be NP-hard [GJ79], which motivates looking for approximate algorithms. Even with this concession, the complexity of approximation algorithms for RSP in its full generality is far from being settled [ABK25, Ber12, GRKL01, Has92, LR01, War87].
Definition 1.1. Let be the shortest -path with cost bounded by C in G. We say that an -path constitutes an -approximate solution to the RSP problem, if its length satisfies and its cost satisfies .
We call an RSP algorithm -approximate if it produces -approximate solutions.
[GRKL01] gave an -time -approximate algorithm for the single-source RSP problem. Their result leverages the observation that simple dynamic programming can, in fact, solve any instance of RSP with integral costs in time [Jok66], and combines it with cost rounding/scaling in a standard way. [LR01] showed a -approximate algorithm for the single-source single-target case running in time; this essentially follows by swapping the roles of lengths and costs and proceeding similarly to [GRKL01].
In the special case of undirected graph inputs, [Ber12] obtained a randomized -approximate single-source RSP algorithm running in time. Apart from the rounding/scaling DP, [Ber12] exploits an emulator construction that crucially relies on the input graph being undirected.
Recently, [ABK25] showed randomized -approximate single-source RSP algorithms running in time – near optimal for dense graphs – and time. Here, W is the aspect ratio of lengths. The techniques here use the so-called low diameter decomposition to define a frequency function that sparsifies the rounding/scaling DP table. Crucial to the completeness of the sparsified DP is to run it on the input graph with a so-called sparse approximate hopset, the best known of which has complexity (see [BW23], which includes the definition of hopsets), and for which any construction has complexity [BH23]. Without explaining the details, this means that pushing the techniques of [ABK25] to their limits would yield an time algorithm at best. This is the hopset barrier, which even more recent work approaches, giving a randomized time -approximate algorithm by using, surprisingly, techniques from parallel algorithms to sequentially construct a distance-cost hopset. At any rate, completely new ideas are needed to break the hopset barrier.
Our Results
The main result in this paper is a deterministic and near-linear time -approximate algorithm for RSP, resolving the complexity of RSP up to logarithmic factors.
Theorem 1. There is a deterministic -approximate algorithm for single-source RSP that runs in time, where W is the aspect ratio of lengths.
Throughout this paper, we use the notation to suppress factors polylogarithmic in , the notation to suppress factors in , and a combination of the two notations.
The algorithm of [LR01] requires some extra care to make it run in strongly polynomial time. This is also the reason for the single-target requirement.
Formally, the aspect ratio W is the quantity , where is the subset of edges with positive lengths. In particular, the zero lengths do not influence the aspect ratio.
Personal correspondence. We will reveal the authors in a future version when it is appropriate to do so.
Not only are our results nearly optimal, they come with the added bonus of being very natural and technically undemanding. Moreover, there is only one log n factor being suppressed. A routine modification of the ideas supplying Theorem 1 yields an analogous algorithm for RSP with k resources.
Theorem 2. For any fixed value of , let . There is a deterministic -approximate algorithm for single-source RSP with resources that runs in time, where is the aspect ratio of lengths.
While it remains open to give a strongly polynomial near-linear time algorithm (in fact, submn time), standard techniques applied to our results give strongly polynomial near-linear time algorithms for the single-source single-target variant (see [ABK25]). For expositional clarity, we did not try to optimize the dependence on ; it can certainly be improved.
Organization and Presentation
The focus of this paper is primarily to convey the ideas which supply Theorem 1. For this reason, we omit the details of Theorem 2; they do not involve any new ideas given those of our main result. A simplifying assumption we make in this paper is that lengths and costs are non-zero; this can be easily fixed by defining a Pois(0) random variable to be deterministically 0, and doing some minor extra bookkeeping. We also assume . The paper is organized as follows:
• Preliminaries are in Section 2.
• The high-concept explanation of our new ideas is provided in Section 3.
- The formal algorithm is in Section 4. This is a deterministic algorithm that outputs distances for each , and also outputs a data structure of size from which witness paths can be retrieved randomly.
• The analysis of the algorithm is in Section 5.
- While distances and the representation of paths are deterministically constructed, the random retrieval of paths suggests we have told a half-truth in claiming a deterministic algorithm. We show how to derandomize path retrieval in Section 6.
2 Preliminaries
Numbers and Sets. For a positive integer , we denote with . We use to denote .
Graphs. Throughout the paper, we consider directed graphs . When it is clear, we use and . We denote an edge directed from vertex to vertex with . A path is a sequence of vertices such that are edges for all ; we call a -path and we sometimes treat it as the (multi-) set of its edges. We concatenate a vertex to the start of by . If we write or and do not qualify them further, they stand for “source” and “target”, respectively.
The graphs in this paper will come equipped with lengths and costs . The lengths and costs of a path is written with and respectively.
Probability. We denote by if is a Poisson random variable with mean and if is an exponential random variable with rate . See [MU17] for more on these.
3 Technical Overview and Motivation
In this section we aim to show how you might have come up with the main idea by yourself, and why it is very natural. For clarity of exposition, we sacrifice some mathematical precision in the ensuing discussion.
The Sum Trick and the Shared Sum Stalemate
Consider the following simple near-linear time -approximate algorithm for RSP.
For guesses :
-
.
-
.
-
Run Dijkstra's algorithm from on with edge weights .
The distance estimate of is the smallest for which the Dijkstra execution found to have length-plus-cost distance .
The length-cost shared sum was shown to be a meaningful quantity in [ABK25], and here we can see why by noting:
(Completeness) If there is an -path with and then .
(Soundness) If then there is an -path with and .
It is also worth noting the following nice feature of this algorithm: witness paths are represented by a data structure of size , analogously to how shortest path algorithms produce a shortest path tree which witnesses all shortest paths. Indeed, if the distance estimate of is , then its witness path is the -path in the shortest path tree produced by the Dijkstra execution for guess . Some form of this will show up in our main result.
At any rate, a natural thing to try is to drive one of the approximation factors down by a weighted summation.
For guesses :
-
.
-
.
-
Run Dijkstra's algorithm from on with edge weights .
The distance estimate of is the smallest for which the Dijkstra execution found to have length-plus-cost distance .
Unfortunately, this kind of reweighting yields a -approximate algorithm. We can drive the length (resp. cost) approximation down arbitrarily close to , but this is at the expense of the cost (resp. length) approximation being driven up!
Breaking the Shared Sum Stalemate with Exploding Random Clocks
It turns out that the weighted shared sum is not the only way to drive an approximation factor down. There is in fact a much better way, which brings both approximation factors down. To see this, we first give a probabilistic interpretation to the -approximate algorithm. Assume for simplicity and , which in effect means that there is no need to normalize and in the -approximate algorithm; we just run Dijkstra's algorithm with a cutoff distance of 2. Now consider the following scenario:
• You hold on to two independent exponential clocks called the length-clock and cost-clock. The length-clock and cost-clock explode at times and respectively, which are independent random variables with .
• You can walk backwards across an edge uv, from v to u. Doing so will advance time underlying by and time underlying by .
• You stand initially upon t. The goal is to get back home to s safely (i.e. with not a single explosion).
By taking an -path (recall, backwards from to ), the probability of a deadly trip home is thus . This is just the length-cost shared sum weight of , passed through the function . What, then, does mean? This is the -rescaled probability of extinction by selecting an optimal route from to ! Thus, under this probabilistic lens, we accept all which have extinction probability .
A conceptual reason why this algorithm yields -approximate solutions is that taking the three distinct paths and and , where and , taking each of these paths yields the exact same survival probability of . If is indeed exactly optimal, and are -approximate. It stands to reason that increasing the survival probability of taking and decreasing the survival probability of taking and/or would result in a tighter approximation. To achieve this, we concentrate the clocks further on their mean of 1.
The time-to-explode for a clock can be modeled as a single tick of the clock. We can increase concentration by modeling the time-to-explode with a two-tick countdown, with both the first and second ticks being independently distributed according to Exp(2) where the second tick starts after the first. Here, the mean time for explosion (that is, the second tick) remains 1. Importantly, note how the survival probabilities of the three paths change. A routine calculation shows the survival probability of taking to be and and to be . Changing the extinction probability cutoff to (instead of the original cutoff of ) keeps but rules out and as escape routes.
By further concentrating times-to-explode to within a width window around their mean of 1 (we will need an -tick countdown to achieve this), we arrive at a -approximate algorithm. Having independent clocks gets the version for RSP with resources.
We temporarily discharge the assumption that lengths and costs are non-zero for this example.
4 The Algorithm
In this section we describe the algorithm which attains Theorem 1. Analysis of this algorithm is deferred to Section 5. We follow the same outer framework of the -approximate algorithm described in Section 3, where is guessed to be some power of . Henceforth, we fix in this section. The algorithm we formalize in this section decides a set of vertices satisfying the following conditions (which will be proved in Section 5):
(Completeness) If there is an -path with and then is in the set.
(Soundness) If is in the set then there is an -path with and .
The algorithm also outputs a table from which we can retrieve such witness paths, not unlike how a shortest path algorithm outputs a shortest path tree. By taking the smallest value of for which is accepted, we can retrieve a -approximate -path from the table constructed for that . By initially rescaling down by a sufficiently large constant factor, this is a -approximate -path. We now describe the inner framework (the Dijkstra execution of the -approximate algorithm).
Parameters. We model the length-clock and cost-clock to explode on the th tick, where . Let and . Finally, for each edge , define the independent random variables and ; these should not be confused with the fixed values and , which are not random.
Inner Algorithm. We build a DP table with states of the form where and . The state is meant to store the minimum extinction probability starting at vertex when the length-clock has already ticked exactly times and the cost-clock has already ticked exactly times. We initialize the boundary states: for all and all ; for all and all ; and for all and . The DP table also supplies pointers from states to the vertex index (i.e. first index) of parent states. This pointer is viewed as an instruction for which vertex to go to next – in totality, an escape plan –, which is the one that minimizes extinction probability. The inner algorithm is then formalized thusly.
RSP INNER ALGORITHM
Input: An -vertex -edge directed graph with edge lengths and edge costs , a source , a length threshold , a cost threshold .
Output: A set of vertices, and a DP table.
-
Initialize DP table boundary values.
-
For ranging down from to and ranging down from to :
(a) Initialize a min-priority queue .
(b) Add to with key 0.
(c) Add to with key for all .
points to with an additional label length (if is ) or cost (otherwise).
(d) While is not empty:
i. Let be the popped element from and set to be its key.
ii. For all edges ( still in ), update the key of to
(♣)
if strictly smaller than the current key.
points to if key is updated.
- Accept all with .
The first term in , the key update expression, is the probability of explosion while walking (backwards) on . The second term in calculates the extinction probabilities of disjoint events where and ticks elapse while crossing .
5 Analysis
In this section we prove the correctness and time complexity of the RSP inner algorithm and thence establish Theorem 1. First, note that
where the inequality holds since a fixed is a non-adaptive escape plan. One can see the faithfulness by using a simple argument on the execution of the RSP inner algorithm in the same way one traces the execution of Dijkstra to prove its correctness.
Completeness
We now show that there are no false-negative targets which can be reached by .
Lemma 5.1. Suppose there is an -path with and . Then is accepted by the RSP inner algorithm.
Proof. Consider walking backwards along such a path , exposing the randomness of and as we step across . We have
and so, by standard bounds (with ) and defining and ,
The probability of extinction walking along is therefore at most by a union bound, and is no larger.
Soundness
Before proving soundness, consider the following random process to produce an -path.
RANDOM PATH RETRIEVAL
Input: DP Table, .
Output: An -path (or explosion ).
-
.
-
and . These track ticks so far.
-
While where is the first vertex of :
(a) parent of .
(b) If :
i. If s label is length: .
ii. If s label is cost: .
(c) Else:
i. .
ii. using fresh randomness.
iii. using fresh randomness.
(d) If or : Return .
- Return .
We now show there are no false-positive targets which can be reached by .
Lemma 5.2. Suppose . Then there is an -path with and .
Proof. Consider the random path retrieval process from . We show that with positive probability, an -path with and is returned. Define
Pois( ) and . The probability that this does not happen is
(Union bound)
where the last inequality follows from standard bounds on the Poisson distribution (with ), and the stochastic dominance claim holds by coupling the length (resp. cost) suffix of the random output path with a Poisson point process with rate (resp. ) over an interval of size (resp. ). Consequently, a -approximate path must exist.
Worth noting in the above proof is that one can deduce that we need only try the random path retrieval process times to successfully extract a -approximate path with high probability.
Putting Everything Together
Finally, we can give the proof of our main result.
Proof of Theorem 1.
Correctness: By scaling , we have so it suffices to show a -approximate algorithm. Lemma 5.1 and Lemma 5.2 together, for an arbitrarily precise value of , yield a -approximate algorithm. Since has a resolution of , the combined framework of guessing and running the RSP inner algorithm gives a -approximate algorithm.
Time Complexity: The outer loop of the RSP inner algorithm iterates times. Each iteration runs Dijkstra's algorithm, but the candidate keys take time to compute since that is the number of summands. The inner algorithm thus takes time. This is executed times by the outer framework, completing the proof.
6 Derandomization of Path Retrieval
In this section we show how witness paths can be deterministically retrieved from the final DP tables, each of size . Our approach is to use the method of conditional expectations on the random path retrieval procedure, but caution must be taken. The randomness is clearly exposed by the 's and 's, but what score are we taking the expectation of? Naively, we could try to use – the extinction probability of the optimal escape plan – as a score which we try to minimize. But this incentivizes the derandomization to always choose zero ticks for the length-clock and cost-clock! We need to take the history of the walk so far into account in order to correct the unlikely situation where lots of length or cost has been spent with a disproportionately low number of clock ticks. In view of this, we define the potential function .
Potential. Let .
We will use the method of conditional expectations to minimize .
Path Retrieval. We are now ready to state the procedure for deterministically retrieving witness paths from the DP table.
DETERMINISTIC PATH RETRIEVAL
Input: DP Table, t. Output: An -path P.
-
.
-
and . These track ticks so far.
-
and . These track the second and third summands of where is the first vertex of .
-
While where is the first vertex of :
(a) parent of .
(b) If :
i. If 's label is length: and .
ii. If 's label is cost: and .
(c) Else:
i. .
ii. .
iii.
iv.
v.
vi.
vii.
- Return P.
Before we bound the length and cost of the output path P, we first show that a violation gives a signal in .
Observation 6.1. Let P be a path output by the deterministic path retrieval procedure.
• and ,
• and .
Proof. We prove the first item (the second is analogous). It suffices to show , where the left hand side comes from the second summand of .
(z < 1)
(PGF of Poisson distribution)
The last inequality follows from standard bounds (with and ).
We are finally ready to show length and cost bounds on the witness path extracted from the deterministic path retrieval procedure.
Lemma 6.2. Suppose . Then the deterministic path retrieval procedure produces an -path with and .
Proof.
Bounding the potential: The initial potential at the start of the retrieval procedure is .
We will show that the potential stays below 1. For this purpose, extend the DP table infinitely beyond its boundary, with values 1 at these new cells. Assume
and let be the parent of . We do a casework on (the second case is more interesting).
• If , then suppose without loss of generality that the label is length. Then,
(z < 1)
(By assumption and )
as claimed.
• If, on the other hand, , then
(By assumption)
There must therefore exist values and for which . The value of must necessarily be in or else the first summand of the potential is 1 (recall that we extended the DP table infinitely).
Establishing termination (some path P is output): Finally, note that the procedure terminates and outputs a path P since each step either simulates a clock tick (of which there can be no more than 2q total increments) or updates the front of the path to a vertex which was extracted earlier from the min-priority queue by the Dijkstra execution on the RSP inner algorithm.
Putting things together: Hence, by using Observation 6.1 with to bound and , the claim follows.
Acknowledgments. I thank Aaron Bernstein and Adam Karczmarz for the many illuminating discussions we had while working on [ABK25].
References
[ABK25] Vikrant Ashvinkumar, Aaron Bernstein, and Adam Karczmarz. Faster approximation algorithms for restricted shortest paths in directed graphs. In Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 5263–5277. SIAM, 2025. arXiv:2410.17179. 1, 2, 3, 4, 12
[BCL 10] Dirk Briskorn, Byung-Cheon Choi, Kangbok Lee, Joseph Y.-T. Leung, and Michael L. Pinedo. Complexity of single machine scheduling subject to nonnegative inventory constraints. European Journal of Operational Research, 207(2):605–619, 2010. 1
[Ber12] Aaron Bernstein. Near linear time -approximation for restricted shortest paths in undirected graphs. In Proceedings of the Twenty-Third Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 189–201. SIAM, 2012. 1, 2
[BH23] Greg Bodwin and Gary Hoppenworth. Folklore sampling is optimal for exact hopsets: Confirming the barrier. In 2023 IEEE 64th Annual Symposium on Foundations of Computer Science (FOCS), pages 701–720. IEEE, 2023. arXiv:2304.02193. 2
[BNW22] Aaron Bernstein, Danupon Nanongkai, and Christian Wulff-Nilsen. Negative-weight single-source shortest paths in near-linear time. In 2022 IEEE 63rd Annual Symposium on Foundations of Computer Science (FOCS), pages 600–611. IEEE, 2022. arXiv:2203.03456. 1
[BW23] Aaron Bernstein and Nicole Wein. Closing the gap between directed hopsets and shortcut sets. In Proceedings of the 2023 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 163–182. SIAM, 2023. arXiv:2207.04507. 2
[DMM 25] Ran Duan, Jiayi Mao, Xiao Mao, Xinkai Shu, and Longhui Yin. Breaking the sorting barrier for directed single-source shortest paths. In Proceedings of the 57th Annual ACM Symposium on Theory of Computing (STOC), pages 36–44. ACM, 2025. arXiv:2504.17033. 1
[Fin24] Jeremy T. Fineman. Single-source shortest paths with negative real weights in time. In Proceedings of the 56th Annual ACM Symposium on Theory of Computing (STOC), pages 3–14. ACM, 2024. arXiv:2311.02520. 1
[GGT10] Rosario Giuseppe Garroppo, Stefano Giordano, and Luca Tavanti. A survey on multi-constrained optimal path computation: Exact and approximate algorithms. Computer Networks, 54(17):3081–3107, 2010. 1
[GJ79] Michael R. Garey and David S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, 1979. 2
[GRKL01] Ashish Goel, Kajamalai G. Ramakrishnan, Deepak Kataria, and Dimitris Logothetis. Efficient computation of delay-sensitive routes from one source to all destinations. In Proceedings IEEE INFOCOM 2001: Twentieth Annual Joint Conference of the IEEE Computer and Communications Societies, volume 2, pages 854–858. IEEE, 2001. 2
[Has92] Refael Hassin. Approximation schemes for the restricted shortest path problem. Mathematics of Operations Research, 17(1):36–42, 1992. 2
[HHR 24] Bernhard Haeupler, Richard Hladík, Václav Rozhoň, Robert E. Tarjan, and Jakub Tětek. Universal optimality of Dijkstra via beyond-worst-case heaps. In 2024 IEEE 65th Annual Symposium on Foundations of Computer Science (FOCS), pages 2099–2130. IEEE, 2024. arXiv:2311.11793. 1
[Jok66] Hans C. Joksch. The shortest route problem with constraints. Journal of Mathematical Analysis and Applications, 14(2):191–197, 1966. 2
[LO98] Dean H. Lorenz and Ariel Orda. QoS routing in networks with uncertain parameters. IEEE/ACM Transactions on Networking, 6(6):768–778, 1998. 1
[LR01] Dean H. Lorenz and Danny Raz. A simple efficient approximation scheme for the restricted shortest path problem. Operations Research Letters, 28(5):213–219, 2001. 2
[MU17] Michael Mitzenmacher and Eli Upfal. Probability and Computing: Randomization and Probabilistic Techniques in Algorithms and Data Analysis. Cambridge University Press, second edition, 2017. 4
[NST07] Joseph Naor, Hadas Shachnai, and Tami Tamir. Real-time scheduling with a budget. Algorithmica, 47(3):343–364, 2007. 1
[War87] Arthur Warburton. Approximation of Pareto optima in multiple-objective, shortest-path problems. Operations Research, 35(1):70–79, 1987. 2
[XZTT08] Guoliang Xue, Weiyi Zhang, Jian Tang, and Krishnaiyan Thulasiraman. Polynomial time approximation algorithms for multi-constrained QoS routing. IEEE/ACM Transactions on Networking, 16(3):656–669, 2008. 1
[YF03] Ossama Younis and Sonia Fahmy. Constraint-based routing in the Internet: Basic principles and recent research. IEEE Communications Surveys & Tutorials, 5(1):2–13, 2003. 1