Two-phase algorithms for the parametric shortest path problem

Similar documents
Luby s Alg. for Maximal Independent Sets using Pairwise Independence

1 Example 1: Axis-aligned rectangles

Recurrence. 1 Definitions and main statements

v a 1 b 1 i, a 2 b 2 i,..., a n b n i.

The Greedy Method. Introduction. 0/1 Knapsack Problem

8.5 UNITARY AND HERMITIAN MATRICES. The conjugate transpose of a complex matrix A, denoted by A*, is given by

Generalizing the degree sequence problem

Support Vector Machines

Ring structure of splines on triangulations

benefit is 2, paid if the policyholder dies within the year, and probability of death within the year is ).

What is Candidate Sampling

BERNSTEIN POLYNOMIALS

We are now ready to answer the question: What are the possible cardinalities for finite fields?

8 Algorithm for Binary Searching in Trees

The OC Curve of Attribute Acceptance Plans

The Development of Web Log Mining Based on Improve-K-Means Clustering Analysis

Project Networks With Mixed-Time Constraints

To Fill or not to Fill: The Gas Station Problem

n + d + q = 24 and.05n +.1d +.25q = 2 { n + d + q = 24 (3) n + 2d + 5q = 40 (2)

1. Math 210 Finite Mathematics

Institute of Informatics, Faculty of Business and Management, Brno University of Technology,Czech Republic

Graph Calculus: Scalable Shortest Path Analytics for Large Social Graphs through Core Net

Sngle Snk Buy at Bulk Problem and the Access Network

Module 2 LOSSLESS IMAGE COMPRESSION SYSTEMS. Version 2 ECE IIT, Kharagpur

INSTITUT FÜR INFORMATIK

SPEE Recommended Evaluation Practice #6 Definition of Decline Curve Parameters Background:

Thursday, December 10, 2009 Noon - 1:50 pm Faraday 143

How Sets of Coherent Probabilities May Serve as Models for Degrees of Incoherence

A Novel Methodology of Working Capital Management for Large. Public Constructions by Using Fuzzy S-curve Regression

Feature selection for intrusion detection. Slobodan Petrović NISlab, Gjøvik University College

Practical Issues and Algorithms for Analyzing Terrorist Networks 1

Calculation of Sampling Weights

An Alternative Way to Measure Private Equity Performance

) of the Cell class is created containing information about events associated with the cell. Events are added to the Cell instance

Logical Development Of Vogel s Approximation Method (LD-VAM): An Approach To Find Basic Feasible Solution Of Transportation Problem

1. Fundamentals of probability theory 2. Emergence of communication traffic 3. Stochastic & Markovian Processes (SP & MP)

Linear Circuits Analysis. Superposition, Thevenin /Norton Equivalent circuits

Causal, Explanatory Forecasting. Analysis. Regression Analysis. Simple Linear Regression. Which is Independent? Forecasting

PERRON FROBENIUS THEOREM

Forecasting the Direction and Strength of Stock Market Movement

CS 2750 Machine Learning. Lecture 3. Density estimation. CS 2750 Machine Learning. Announcements

Joint Scheduling of Processing and Shuffle Phases in MapReduce Systems

NPAR TESTS. One-Sample Chi-Square Test. Cell Specification. Observed Frequencies 1O i 6. Expected Frequencies 1EXP i 6

Power-of-Two Policies for Single- Warehouse Multi-Retailer Inventory Systems with Order Frequency Discounts

Lecture 2: Single Layer Perceptrons Kevin Swingler

A Probabilistic Theory of Coherence

Availability-Based Path Selection and Network Vulnerability Assessment

A Lyapunov Optimization Approach to Repeated Stochastic Games

Production. 2. Y is closed A set is closed if it contains its boundary. We need this for the solution existence in the profit maximization problem.

where the coordinates are related to those in the old frame as follows.

How To Calculate An Approxmaton Factor Of 1 1/E

Fisher Markets and Convex Programs

Implementation of Deutsch's Algorithm Using Mathcad

An Analysis of Central Processor Scheduling in Multiprogrammed Computer Systems

J. Parallel Distrib. Comput.

THE DISTRIBUTION OF LOAN PORTFOLIO VALUE * Oldrich Alfons Vasicek

Matrix Multiplication I

From Selective to Full Security: Semi-Generic Transformations in the Standard Model

A hybrid global optimization algorithm based on parallel chaos optimization and outlook algorithm

Energies of Network Nastsemble

Formulating & Solving Integer Problems Chapter

General Auction Mechanism for Search Advertising

Rate Monotonic (RM) Disadvantages of cyclic. TDDB47 Real Time Systems. Lecture 2: RM & EDF. Priority-based scheduling. States of a process

Product-Form Stationary Distributions for Deficiency Zero Chemical Reaction Networks

Extending Probabilistic Dynamic Epistemic Logic

THE METHOD OF LEAST SQUARES THE METHOD OF LEAST SQUARES

On Lockett pairs and Lockett conjecture for π-soluble Fitting classes

This circuit than can be reduced to a planar circuit

Logistic Regression. Lecture 4: More classifiers and classes. Logistic regression. Adaboost. Optimization. Multiple class classification

POLYSA: A Polynomial Algorithm for Non-binary Constraint Satisfaction Problems with and

Quantization Effects in Digital Filters

Loop Parallelization

Calculating the high frequency transmission line parameters of power cables

Period and Deadline Selection for Schedulability in Real-Time Systems

Fault tolerance in cloud technologies presented as a service

Complete Fairness in Secure Two-Party Computation

Stochastic Games on a Multiple Access Channel

Minimal Coding Network With Combinatorial Structure For Instantaneous Recovery From Edge Failures

How To Solve A Problem In A Powerline (Powerline) With A Powerbook (Powerbook)

Efficient Reinforcement Learning in Factored MDPs

PSYCHOLOGICAL RESEARCH (PYC 304-C) Lecture 12

NON-CONSTANT SUM RED-AND-BLACK GAMES WITH BET-DEPENDENT WIN PROBABILITY FUNCTION LAURA PONTIGGIA, University of the Sciences in Philadelphia

A Secure Password-Authenticated Key Agreement Using Smart Cards

Enabling P2P One-view Multi-party Video Conferencing

1. Measuring association using correlation and regression

Research Article Enhanced Two-Step Method via Relaxed Order of α-satisfactory Degrees for Fuzzy Multiobjective Optimization

An MILP model for planning of batch plants operating in a campaign-mode

Data Broadcast on a Multi-System Heterogeneous Overlayed Wireless Network *

Energy Efficient Routing in Ad Hoc Disaster Recovery Networks

Software project management with GAs

The Geometry of Online Packing Linear Programs

Using Series to Analyze Financial Situations: Present Value

Optimal resource capacity management for stochastic networks

Abteilung für Stadt- und Regionalentwicklung Department of Urban and Regional Development

OPTIMAL INVESTMENT POLICIES FOR THE HORSE RACE MODEL. Thomas S. Ferguson and C. Zachary Gilstein UCLA and Bell Communications May 1985, revised 2004

Schedulability Bound of Weighted Round Robin Schedulers for Hard Real-Time Systems

Section 5.4 Annuities, Present Value, and Amortization

"Research Note" APPLICATION OF CHARGE SIMULATION METHOD TO ELECTRIC FIELD CALCULATION IN THE POWER CABLES *

Performance Analysis of Energy Consumption of Smartphone Running Mobile Hotspot Application

Answer: A). There is a flatter IS curve in the high MPC economy. Original LM LM after increase in M. IS curve for low MPC economy

Transcription:

Two-phase algorthms for the parametrc shortest path problem Sourav Chakraborty 1, Eldar Fscher 1, Oded Lachsh 2, and Raphael Yuster 3 1 Department of Computer Scence, Technon, Hafa 32000, Israel {eldar,sourav}@cs.technon.ac.l Research supported n part by an ERC-2007-StG grant number 202405-2 2 Centre for Dscrete Mathematcs and ts Applcatons, Unversty of Warwck, Coventry, UK oded@dcs.warwck.ac.uk 3 Department of Mathematcs, Unversty of Hafa, Hafa 31905, Israel raphy@math.hafa.ac.l Abstract. A parametrc weghted graph s a graph whose edges are labeled wth contnuous real functons of a sngle common varable. For any nstantaton of the varable, one obtans a standard edgeweghted graph. Parametrc weghted graph problems are generalzatons of weghted graph problems, and arse n varous natural scenaros. Parametrc weghted graph algorthms consst of two phases. A preprocessng phase whose nput s a parametrc weghted graph, and whose output s a data structure, the advce, that s later used by the nstantaton phase, where a specfc value for the varable s gven. The nstantaton phase outputs the soluton to the (standard) weghted graph problem that arses from the nstantaton. The goal s to have the runnng tme of the nstantaton phase supersede the runnng tme of any algorthm that solves the weghted graph problem from scratch, by takng advantage of the advce. In ths paper we construct several parametrc algorthms for the shortest path problem. For the case of lnear functon weghts we present an algorthm for the sngle source shortest path problem. Its preprocessng phase runs n Õ(V 4 ) tme, whle ts nstantaton phase runs n only O(E + V log V ) tme. The fastest standard algorthm for sngle source shortest path runs n O(V E) tme. For the case of weght functons defned by degree d polynomals, we present an algorthm wth sub-exponental preprocessng tme O(V (1+log f(d)) log V ) and nstantaton tme only Õ(V ). In fact, for any par of vertces u, v, the nstantaton phase computes the dstance from u to v n only O(log 2 V ) tme. Fnally, for lnear functon weghts, we present a randomzed algorthm whose preprocessng tme s Õ(V 3.5 ) and so that for any par of vertces u, v and any nstantaton varable, the nstantaton phase computes, n O(1) tme, a length of a path from u to v that s at most (addtvely) ɛ larger than the length of a shortest path. In partcular, an all-pars shortest path soluton, up to an addtve constant error, can be computed n O(V 2 ) tme. 1 Introducton A functon-weghted graph s a graph whose edges are labeled wth contnuous real functons. When all the functons are unvarate (and all have the same varable), the graph s called a parametrc weghted graph. In other words, the graph s G = (V, E, W ) where W : E F and F s the space of all real contnuous functons wth the varable x. If G s a parametrc weghted graph, and r R s any real number, then G(r) s the standard weghted graph where the weght of an edge e s defned to be (W (e))(r). We say that G(r) s an nstantaton of G, snce the varable x n each functon s nstantated by the value r. Parametrc weghted graphs, are, therefore, a generc nstance of nfntely many nstances of weghted graphs. How can we beneft from modelng problems by a parametrc weghted graph? If we can take advantage of the generc nstance G, and use t to precompute some general generc nformaton I(G), t s plausble that for any gven nstantaton G(r), we wll be able to use the precomputed nformaton I(G) n order to speed up the tme to solve the gven problem on G(r), faster than just solvng the problem on G(r) from scratch. Let us make ths noton more precse. A parametrc weghted graph algorthm (or, for brevty, parametrc algorthm) conssts of two phases. A preprocessng phase whose nput s a parametrc weghted graph G, and whose output s a data structure (the advce) that s later used by the nstantaton phase, where a specfc value r for the varable s gven. The nstantaton phase outputs the soluton to the (standard) weghted

graph problem on the weghted graph G(r). Naturally, the goal s to have the runnng tme of the nstantaton phase sgnfcantly smaller than the runnng tme of any algorthm that solves the weghted graph problem from scratch, by takng advantage of the advce constructed n the preprocessng phase. Parametrc algorthms are therefore evaluated by a par of runnng tmes, the preprocessng tme and the nstantaton tme. In ths paper we show that parametrc algorthms are benefcal for one of the most natural combnatoral optmzaton problems: the shortest path problem n drected graphs. Recall that gven a drected real-weghted graph G, and two vertces u, v of G, the dstance from u to v, denoted by δ(u, v), s the length of a shortest path from u to v. The sngle par shortest path problem seeks to compute δ(u, v) and construct a shortest path from u to v. Lkewse, the sngle source shortest path problem seeks to compute the dstances and shortest paths from a gven vertex to all other vertces, and the all pars verson seeks to compute dstances and shortest paths between all ordered pars of vertces. In some of our algorthms we forgo the calculaton of the path tself to acheve a shorter nstantaton tme. In all those cases the algorthms can be easly modfed to also output a shortest path, n whch case ther nstantaton tme s the sum of the tme t takes to calculate the dstance and a tme lnear n the sze of the path to be output. Our frst algorthm s a parametrc algorthm for sngle source shortest path, n the case where the weghts are lnear functons. That s, each edge e s labeled wth a functon a e x + b e where a e and b e are reals. Such lnear parametrzaton has practcal mportance. Indeed, n many problems the cost of an edge s composed from some constant term plus a term whch s a factor of some commodty, whose cost vares (e.g. bank commssons, tax fares, vehcle mantenance costs, and so on). Our parametrc algorthm has preprocessng tme Õ(n4 ) and nstantaton tme O(m + n log n) (throughout ths paper n and m denote the number of vertces and edges of a graph, respectvely). We note that the fastest algorthm for the sngle source shortest path n real weghted drected graphs requres O(nm) tme; the Bellman-Ford algorthm [2]. The dea of our preprocessng stage s to precompute some other lnear functons, on the vertces, so that for every nstantaton r, one can quckly determne whether G(r) has a negatve cycle and otherwse use these functons to quckly produce a reweghng of the graph so as to obtan only nonnegatve weghts smlar to the weghts obtaned by Johnson s algorthm [11]. In other words, we avod the need to run the Bellman-Ford algorthm n the nstantaton phase. The Õ(n4 ) tme n the preprocessng phase comes from the use of an nteror pont algorthm that we need n order to compute the lnear vertex functons. Theorem 1. There exsts a parametrc algorthm for sngle source shortest path n graphs weghted by lnear functons, whose preprocessng tme s Õ(n4 ) and whose nstantaton tme s O(m + n log n). Our next algorthm apples to a more general settng where the weghts are polynomals of degree at most d. Furthermore, n ths case our goal s to have the nstantaton phase answer dstance queres between any two vertces n sublnear tme. Notce frst that f we allow exponental preprocessng tme, ths goal can be easly acheved. Ths s not hard to see by the fact that the overall possble number of shortest paths (when x vares over the reals) s O(n!), or from Fredman s decson tree for shortest paths whose heght s O(n 2.5 ) [8]. But can we settle for sub-exponental preprocessng tme and stll be able to have sublnear nstantaton tme? Our next result acheves ths goal. Theorem 2. There exsts a parametrc algorthm for the sngle par shortest path problem n graphs weghted by degree d polynomals, whose preprocessng tme s O(n (O(1)+log f(d)) log n ) and nstantaton tme O(log 2 n), where f(d) s the tme requred to compute the ntersecton ponts of two degree d polynomals. The sze of the advce that the preprocessng algorthm produces s O(n (O(1)+log d) log n ).

The practcal and theoretcal mportance of shortest path problems lead several researchers to consder fast algorthms that settle for an approxmate shortest path. For the general case (of real weghted dgraphs) most of the algorthms guarantee an α-stretch factor. Namely, they compute a path whose length s at most αδ(u, v). We menton here the (1 + ɛ)-stretch algorthm of Zwck for the all-pars shortest path problem, that runs n Õ(nω ) tme when the weghts are non-negatve reals [16]. Here ω < 2.376 s the matrx multplcaton exponent [5]. Here we consder probablstc addtve-approxmaton algorthms, or surplus algorthms, that work for lnear weghts whch may have postve and negatve values (as long as there s no negatve weght cycle). We say that a shortest path algorthm has an ɛ-surplus f t computes paths whose lengths are at most δ(u, v)+ɛ. We are unaware of any truly subcubc algorthm that guarantees an ɛ- surplus approxmaton, and whch outperforms the fastest general all-pars shortest path algorthm [4]. In the lnear-parametrc settng, t s easy to obtan ɛ-surplus parametrc algorthms whose preprocessng tme s O(n 4 ) tme, and whose nstantaton tme, for any ordered par of quered vertces u, v s constant. It s assumed nstantatons are taken from some nterval I whose length s ndependent of n. Indeed, we can partton I nto O(n) subntervals I 1, I 2,... of sze O(1/n) each, and solve, n cubc tme (say, usng [7]), the exact all-pars soluton for any nstantaton r that s an endpont of two consecutve ntervals. Then, gven any r I j = (a j, b j ), we smply look at the soluton for b j and notce that we are (addtvely) off from the rght answer only by O(1). Standard scalng arguments can make the surplus smaller than ɛ. But do we really need to spend O(n 4 ) tme for preprocessng? In other words, can we nvest (sgnfcantly) less than O(n 4 ) tme and stll be able to answer nstantated dstance queres n O(1) tme? The followng result gves a postve answer to ths queston. Theorem 3. Let ɛ > 0, let [α, β] be any fxed nterval and let γ be a fxed constant. Suppose G s a lnear-parametrc graph that has no negatve weght cycles n the nterval [α, β], and for whch every edge weght a e + xb e satsfes a e γ. There s a parametrc randomzed algorthm for the ɛ-surplus shortest path problem, whose preprocessng tme s Õ(n3.5 ) and whose nstantaton tme s O(1) for a sngle par, and hence O(n 2 ) for all pars. We note that ths algorthm works n the restrcted addton-comparson model. We also note that gven an ordered par u, v and r [α, β], the algorthm outputs, n O(1) tme, a weght of an actual path from u to v n G(r), and ponts to a lnked lst representng that path. Naturally, f one wants to output the vertces of ths path then the tme for ths s lnear n the length of the path. The rest of ths paper s organzed as follows. The next subsecton shortly surveys related research on parametrc shortest path problems. In the three sectons followng t we prove Theorems 1,2 and 3. Secton 5 contans some concludng remarks and open problems. 1.1 Related research Karp and Orln [13], and, later, Young, Tarjan, and Orln [15] consdered a specal case of the lnear-parametrc shortest path problem. In ther case, each edge weght e s ether some fxed constant b e or s of the form b e x. It s not too dffcult to prove that for any gven vertex v, when x vares from to the largest x 0 for whch G(x 0 ) has no negatve weght cycle (possbly x 0 = ), then there are at most O(n 2 ) dstnct shortest path trees from v to all other vertces. Namely, for each r [, x 0 ] one of the trees n ths famly s a soluton for sngle-source shortest path n G(r). The results n [13, 15] cleverly and compactly compute all these trees, and the latter does t n O(nm + n 2 log n) tme. However, for general lnear functons, Carstensen [3] showed that there are constructons for whch the number of shortest path changes whle x vares over the reals s n Ω(log n). In fact, n her example each lnear functon s of the form a e + xb e and both a e and b e are postve, and x vares

n [0, ]. Carstensen also proved that ths s tght. In other words, for any lnear-parametrc graph the number of changes n the shortest paths s n O(log n). A smpler proof was obtaned by Nkolova et al. [14], that also supply an n O(log n) tme algorthm to compute the path breakponts. Ther method, however, does not apply to the case where the functons are not lnear, such as n the case of degree d polynomals. Gusfeld [10] studed algorthms for functon-weghted graphs but n the context of program module dstrbuton. 2 Proof of Theorem 1 The proof of Theorem 1 follows from the followng two lemmas. Lemma 1. Gven a lnear-weghted graph G = (V, E, W ), there exst α, β R { } {+ } such that G(r) has no negatve cycles f and only f α r β. Moreover α and β can be found n Õ(n 4 ) tme. Lemma 2. Let G = (V, E, W ) be a lnear-weghted graph. Also let α, β R { } {+ } be such that at least one of them s fnte and for all α r β the graph G(r) has no negatve cycle. Then for every vertex v V there exsts a lnear functon g v [α,β] such that f the new weght functon W s gven by W ((u, v)) = W ((u, v)) + g [α,β] u g [α,β] v then the new lnear-weghted graph G = (V, E, W ) has the property that for any real α r β all the edges n G (r) are non-negatve. Moreover the functons g v [α,β] for all v V can be found n O(mn) tme. So gven a lnear-weghted graph G, we frst use Lemma 1 to compute α and β. If at least one of α and β s fnte then usng Lemma 2 we compute the n lnear functons g v [α,β], one for each v V. If α = and β = +, then usng Lemma 2 we compute the 2n lnear functons g v [α,0] and g v [0,β]. These lnear functons wll be the advce that the preprocessng algorthm produces. The above lemmas guarantee us that the advce can be computed n tme Õ(n4 ), that s the preprocessng tme s Õ(n4 ). Now when computng the sngle source shortest path problem from vertex v for the graph G(r) our algorthm proceeds as follows: 1. If r < α or r > β output as there exsts a negatve cycle (such nstances are consdered nvald). 2. If α r β and at least one of α or β s fnte then compute g u (r) for all u V. Use these to re-weght the edges n the graph as n Johnson s algorthm [11]. If α = and β = + then f r 0 compute g [α,0] u (r) for all u V and f r 0 compute g u [0,β] (r) for all u V. Notce that after the reweghng we have an nstance of G (r). 3. Use Djkstra s algorthm [6] to solve the sngle source shortest path problem n G (r). Djkstra s algorthm apples snce G (r) has no negatve weght edges. The shortest paths tree returned by Djkstra s algorthms appled to G (r) s also the shortest paths tree n G(r). As n Johnson s algorthm, we use the results d (v, u) of G (r) to deduce d(v, u) n G(r) snce, by Lemma 2 d(v, u) = d (v, u) g v (r) + g u (r). The runnng tme of the nstantaton phase s domnated by the runnng tme of Djkstra s algorthm whch s O(m + n log n) [9].

2.1 Proof of Lemma 1 Snce the weght on the edges of the graph G are lnear functons, we have that the weght of any drected cycle n the graph s also a lnear functon. Let C 1, C 2,..., C T be the set of all drected cycles n the graph. The lnear weght functon of a cycle C wll be denoted by wt(c ). If wt(c ) s not the constant functon, then let γ be the real number for whch the lnear equaton wt(c ) evaluates to 0. Let α and β be defned as follows: Note that f wt(c ) has a postve slope then α = max {γ wt(c ) has a postve slope}. β = mn {γ wt(c ) has a negatve slope}. γ = mn x {wt(c )(x) 0}. Thus for all x γ the value of wt(c ) evaluated at x s non-negatve. So by defnton for all x α the value of the wt(c ) s non-negatve f the slope of wt(c ) s postve, and for any x < α there exsts a cycle C such that wt(c ) has postve slope and wt(c )(x) s negatve. Smlarly, for all x β the value of the wt(c ) s non-negatve f the slope of wt(c ) s negatve and for any x > β there exsts a cycle C such that wt(c ) has negatve slope and wt(c )(x) s negatve. Ths proves the exstence of α and β. There are, however, two bad cases that we wsh to exclude. Notce that f α > β ths means that for any evaluaton at x, the resultng graph has a negatve weght cycle. The same holds f there s some cycle for whch wt(c ) s constant and negatve. Let us now show how α and β can be effcently computed whenever these bad cases do not hold. Indeed, α s the soluton to the followng Lnear Program (LP), whch has a feasble soluton f and only f the bad cases do not hold. Mnmze x under the constrants, wt(c )(x) 0. Ths s an LP on one varable, but the number of constrants can be exponental. Luckly, however, the set of constrants can be presented n a compact form: our functon-weghted graph. In other words, for any gven x, one can use the Bellman-Ford algorthm to produce a constrant that s volated (f there s one), that s produce a cycle that has negatve weght. Thus, our LP has an effcent separaton oracle. As ths LP has only one varable, and ts sze s only O(n 2 ) (n ths context the sze s defned by the length of the parameters of the separaton oracle, n our case the lnearly weghted graph), t can be solved n Õ(n4 ) tme [12]. Notce that β can be computed usng the analogous maxmzaton lnear program. In case one (and hence both) of the lnear programs has no feasble soluton we just set α = β =. 2.2 Proof of Lemma 2 Let α and β be the two numbers such that for all α r β the graph G(r) has no negatve cycles and at least one of α and β s fnte. Frst let us consder the case when both α and β are fnte. Recall that, gven any number r, Johnson s algorthm assocates a weght functon h r : V R such that, for any edge (u, v) E, W (u,v) (r) + h r (u) h r (v) 0.

(Johnson s algorthm computes ths weght functon by runnng the Bellman-Ford algorthm over G(r)). Defne the weght functon g v [α,β] as ( h g v [α,β] β (v) h α ) ( (v) h (x) = x + h α β (v) h α ) (v) (v) α. β α β α Ths s actually the equaton of the lne jonng (α, h α (v)) and (β, h β (v)) n R 2. Now we need to prove that for every α r β and for every (u, v) V, W (u,v) (r) + g u [α,β] (r) g v [α,β] (r) 0. Snce α r β, one can wrte r = (1 δ)α + δβ where 1 δ 0. Then for all v V, Snce W (u,v) (r) s a lnear functon we can wrte g [α,β] v (r) = (1 δ)h α (v) + δh β (v). W (u,v) (r) = (1 δ)w (u,v) (α) + δw (u,v) (β). So after re-weghtng the weght of the edge (u, v) s (1 δ)w (u,v) (α) + δw (u,v) (β) + (1 δ)h α (u) + δh β (u) (1 δ)h α (v) δh β (v). Now ths s non-negatve as by the defnton of h β and h α we know that both W (u,v) (β) + h β (u) h β (v) and W (u,v) (α) + h α (u) h α (v) are non-negatve. We now consder the case when one of α or β s not fnte. We wll prove t for the case where β = +. The case α = follows smlarly. Consder the smple weghted graph G = (V, E, W ) where the weght functon W s defned as: f the weght of the edge e s W (e) = a e x + b e then W (e) = a e. We run the Johnson s algorthm on the graph G. Let h (v) denote the weght that Johnson s algorthm assocates wth the vertex v. Then defne the weght functon g v [α, ] as g [α, ] v (x) = h α (v) + (x α)h (v). We need to prove that for every α r and for every (u, v) V, W (u,v) (r) + g u [α, ] (r) g v [α, ] (r) = W (u,v) (r) + h α (u) + (r α)h (u) h α (v) (r α)h (v) 0. Let r = α + δ where δ 0. By the lnearty of W we can wrte W (u,v) (r) = W (u,v) (α) + δa (u,v), where W (u,v) (r) = a (u,v) r + b (u,v). So the above nequalty can be restated as W (u,v) (α) + δa (u,v) + h α (u) + δh (u) h α (v) δh (v) 0. Ths now follows from the fact that both W (u,v) (α) + h α (u) h α (v) and a (u,v) + h (u) h (v) are non-negatve. Snce the runnng tme of the reweghng part of Johnson s algorthm takes O(mn) tme, the overall runnng tme of computng the functons g v [α,β] s O(mn), as clamed. 3 Proof of Theorem 2 In ths secton we construct a parametrc algorthm that computes the dstance δ(u, v) between a gven par of vertces. If one s nterested n the actual path realzng ths dstance, then t can be found wth some extra book-keepng that we omt n the proof.

The processng algorthm wll output the followng advce: for any par (u, v) V V the advce conssts of a set of ncreasng real numbers = b 0 < b 1 < < b t < b t+1 = and an ordered set of degree-d polynomals p 0, p 1,..., p t, such that for all b r b +1 the weght of a shortest path n G(r) from u to v s p (r). Note that each p corresponds to the weght of a path from u to v. Thus f we are nterested n computng the exact path then we need to keep track of the path correspondng to each p. Gven r, the nstantaton algorthm has to fnd the such that b r b +1 and then output p (r). So the output algorthm runs n tme O(log t). To prove our result we need to show that for any (u, v) V V we can fnd the advce n tme O(f(d)n) log n. In partcular ths wll prove that t = O(dn) log n and hence the result wll follow. Defnton 1. A mnbase s a sequence of ncreasng real numbers = b 0 < b 1 < < b t < b t+1 = and an ordered set of degree-d polynomals p 0, p 1,..., p t, such that for all b r b +1 and all j, p (r) p j (r). We call the sequence of real numbers the breaks. We call each nterval [b, b +1 ] the -th nterval of the mnbase and the polynomal p the -th polynomal. The sze of the mnbase s t. The fnal advce that the preprocessng algorthm produces s a mnbase for every par (u, v) V V where the -th polynomal has the property that p (r) s the dstance from u to v n G(r) for each b r b +1. Defnton 2. A mnbase l (u, v) s a mnbase correspondng to the ordered par u, v, where the -th polynomal p has the property that for r [b, b +1 ], p (r) s the length of a shortest path from u to v n G(r), that s taken among all paths that use at most 2 l edges. A mnbase l (u, w, v) s a mnbase correspondng to the ordered trple (u, w, v) where the -th polynomal p has the property that for each r [b, b +1 ], p (r) s the sum of the lengths of a shortest path from u to w n G(r), among all paths that use at most 2 l edges, and a shortest path from w to v n G(r), among all paths that use at most 2 l edges. Note that n both of the above defntons some of the polynomals can be + or. Defnton 3. If B 1 and B 2 are two mnbases (not necessarly of the same sze), wth polynomals p 1 and p 2 j, we say that another mnbase wth breaks b k and polynomals p k s mn(b 1 + B 2 ) f the followng holds. 1. For all k there exst, j such that p k = p1 + p2 j, and 2. For b k r b k+1 and for all, j we have p k (r) p1 (r) + p2 j (r). Defnton 4. If B 1, B 2,..., B s are s mnbases (not necessarly of the same sze), wth polynomals p 1 1, p 2 2,..., p s s, another mnbase wth breaks b k and polynomals p k s mn{b 1, B 2,..., B s } f the followng holds. 1. For all k there exst q such that p k = pq q, and 2. For b k r b k+1 and for all 1 q s and all q, we have p k (r) pq q (r). Note that usng the above defnton we can wrte the followng two equatons: { } mnbase l+1 (u, v) = mn mnbase l (u, w, v). (1) w V ( ) mnbase l (u, w, v) = mn mnbase l (u, w) + mnbase l (w, v). (2) The followng clam wll prove the result. The proof of the clam s n the Appendx, Secton 6.

Clam 1. If B 1 and B 2 are two mnbases of szes t 1 and t 2 respectvely, then (a) mn(b 1 + B 2 ) can be computed from B 1 and B 2 n tme O(t 1 + t 2 ). (b) mn{b 1, B 2 } can be computed from B 1 and B 2 n tme O(f(d)(t 1 + t 2 )), where f(d) s the tme requred to compute the ntersecton ponts of two degree-d polynomals. The sze of mn{b 1, B 2 } s O(d(t 1 + t 2 )). In order to compute mn{b 1,..., B s } one recursvely computes X = mn{b 1,..., B s/2 } and Y = mn{b s/2+1,..., B s } and then takes takes mn{x, Y }. If there are no negatve cycles, then the advce that the nstantaton algorthm needs from the preprocessng algorthm conssts of mnbase log n (u, v). To deal wth negatve cycles, both mnbase log n (u, v) and mnbase log n +1 (u, v) are produced, and the nstantaton algorthm compares them. f they are not equal, then the correct output s. Also note that mnbase 0 (u, v) s the trval mnbase where the breaks are and + and the polynomal s weght W ((u, v)) assocated to the edge (u, v) f (u, v) E and + otherwse. If the sze of mnbase l (u, v) s s l, then by (1), (2), and by Clam 1 the tme to compute mnbase l+1 (u, v) s O(f(d)) log n s l and the sze of mnbase l+1 (u, v) s O(d) log n s l. Thus one can compute the advce for u and v n tme (O(f(d)) log n ) log n = O(n (O(1)+log f(d)) log n ), and the length of the advce strng s O(n (O(1)+log d) log n ). 4 Proof of Theorem 3 Gven the lnear-weghted graph G = (V, E, W ), our preprocessng phase begns by verfyng that for all r [α, β], G(r) has no negatve weght cycles. From the proof of Lemma 2 we know that ths holds f and only f both G(α) and G(β) have no negatve weght cycles. Ths, n turn, can be verfed n O(mn) tme usng the Bellman-Ford algorthm. We may now assume that G(r) has no negatve cycles for any r [α, β]. Moreover, snce our preprocessng algorthm wll solve a large set of shortest path problems, each of them on a specfc nstantaton of G, we wll frst compute the reweghng functons g v [α,β] of Lemma 2 whch wll enable us to apply, n some cases, algorthms that assume nonnegatve edge weghts. Recall that by Lemma 2, the functons g v [α,β] for all v V are computed n O(mn) tme. The advce constructed by the preprocessng phase s composed of two dstnct parts, whch we respectvely call the crude-short advce and the refned-long advce. We now descrbe each of them. For each edge e E, the weght s a lnear functon w e = a e + xb e. Set K = 8(β α) max e a e. Let N 0 = K n ln n/ɛ and let N 1 = Kn/ɛ. For = 0, 1 we wll use N to defne N + 1 ponts n [α, β] and solve certan varants of shortest path problems nstantated n these ponts. Consder frst the case of splttng [α, β] nto N 0 ntervals. Let ρ 0 = (β α)/n 0 and consder the ponts α + ρ 0 for = 0,..., N 0. The crude-short part of the preprocessng algorthm solves N 0 + 1 lmted all-pars shortest path problems n G(α + ρ 0 ) for = 0,..., N 0. Set t = 4 n ln n, and let d (u, v) denote the length of a shortest path from u to v n G(α + ρ 0 ) that s chosen among all paths contanng at most t vertces (possbly d (u, v) = f no such path exsts). Notce that d (u, v) s not necessarly the dstance from u to v n G(α + ρ 0 ), snce the latter may requre more than t vertces. It s straghtforward to compute shortest paths lmted to at most k vertces (for any 1 k n) n a real-weghted drected graph wth n vertces n tme O(n 3 log k) tme, by the repeated squarng technque. In fact, they can be computed n O(n 3 ) tme (savng the log k factor) usng the method from [1], pp. 204 206. Ths algorthm also constructs the predecessor data structure that represents the actual paths. It follows that for each ordered par of vertces u, v and

for each = 0,..., N 0, we can compute d (u, v) and a path p (u, v) yeldng d (u, v) n G(α + ρ 0 ) n O(n 3 N 0 ) tme whch s O(n 3.5 ln n). We also mantan, at no addtonal cost, lnear functons f (u, v) whch sum the lnear functons of the edges of p (u, v). Note also that f d (u, v) = then p (u, v) and f (u, v) are undefned. Consder next the case of splttng [α, β] nto N 1 ntervals. Let ρ 1 = (β α)/n 1 and consder the ponts α + ρ 1 for = 0,..., N 1. However, unlke the crude-short part, the refned-long part of the preprocessng algorthm cannot afford to solve an all-pars shortest path algorthm for each G(α + ρ 1 ), as the overall runnng tme wll be too large. Instead, we randomly select a set H V of (at most) n vertces. H s constructed by performng n ndependent trals, where n each tral, one vertex of V s chosen to H unformly at random (notce that snce the same vertex can be selected to H more than once H n). For each h H and for each = 0,..., N 1, we solve the sngle source shortest path problem n G(α + ρ 1 ) from h, and also (by reversng the edges) solve the sngle-destnaton shortest path toward h. Notce that by usng the reweghng functons we can solve all of these sngle source problems usng Djkstra s algorthm. So, for all h H and = 0,..., N 1 the overall runnng tme s g [α,β] v O( N 1 H (m + n log n)) = O(n 1.5 m + n 2.5 log n) = O(n 3.5 ). We therefore obtan, for each h H and for each = 0,..., N 1, a shortest path tree T (h), together wth dstances d (h, v) from h to each other vertex v V, whch s the dstance from h to v n G(α + ρ 1 ). We also mantan the functons f (h, v) that sum the lnear equatons on the path n T (h) from h to v. Lkewse, we obtan a reversed shortest path tree S (h), together wth dstances d (v, h) from each v V to h, whch s the dstance from v to h n G(α + ρ 1). Smlarly, we mantan the functons f (v, h) that sum the lnear equatons on the path n S (h) from v to h. Fnally, for each ordered par of vertces u, v and for each = 0,..., N 1 we compute a vertex h u,v, H whch attans mn h H d (u, h) + d (h, u). Notce that the tme to construct the h u,v, for all ordered pars u, v and for all = 0,..., N 1 s O(n 3.5 ). Ths concludes the descrpton of the preprocessng algorthm. Its overall runtme s thus O(n 3.5 ln n). We now descrbe the nstantaton phase. Gven u, v V and r [α, β] we proceed as follows. Let be the ndex for whch the number of the form α + ρ 0 s closest to r. As we have the advce f (u, v), we let w 0 = f (u, v)(r) (recall that f (u, v) s a functon). Lkewse, let j be the ndex for whch the number of the form α + jρ 1 s closest to r. As we have the advce h = h u,v,j, we let w 1 = fj (u, h)(r) + f j (h, u)(r). Fnally, our answer s z = mn{w 0, w 1 }. Clearly, the nstantaton tme s O(1). Notce that f we also wsh to output a path of weght z n G(r) we can easly do so by usng ether p (u, v), n the case where z = w 0 or usng Sj (h) and T j (h) (we take the path from u to h n Sj (h) and concatenate t wth the path from h to v n T j (h)) n the case where z = w 1. It remans to show that, wth very hgh probablty, the result z that we obtan from the nstantaton phase s at most ɛ larger than the dstance from u to v n G(r). For ths purpose, we frst need to prove that the random set H possesses some httng set propertes, wth very hgh probablty. For every par of vertces u and v and parameter r, let p u,v,r be a shortest path n G(r) among all smple paths from u to v contanng at least t = 4 n ln n vertces (f G s strongly connected then such a path always exst, and otherwse we can just put + for all u, v pars for whch no such path exsts). The followng smple lemma s used n an argument smlar to one used n [16]. Lemma 3. For fxed u, v and r, wth probablty at least 1 o(1/n 3 ) the path p u,v,r contans a vertex from H.

Proof. Indeed, the path from p u,v,r by ts defnton has at least 4 n ln n vertces. The probablty that all of the n ndependent selectons to H faled to choose a vertex from ths path s therefore at most ( 1 4 ) n n ln n < e 4 ln n < 1 n n 4 = o(1/n3 ). Let us return to the proof of Theorem 3. Suppose that the dstance from u to v n G(r) s δ. We wll prove that wth probablty 1 o(1), H s such that for every u, v and r we have z δ + ɛ (clearly z δ as t s the precse length of some path n G(r) from u to v). Assume frst that there s a path p of length δ n G(r) that uses less than 4 n ln n edges. Consder the length of p n G(α + ρ 0 ). When gong from r to α + ρ 0, each edge e wth weght a e x + b e changed ts length by at most a e ρ 0. By the defnton of K, ths s at most ρ 0 K/(8(β α)). Thus, p changed ts weght by at most (4 K n ln n) ρ 0 8(β α) = (4 n ln n) K < ɛ 8N 0 2. It follows that the length of p n G(α + ρ 0 ) s less than δ + ɛ/2. But p (u, v) s a shortest path from u to v n G(α +ρ 0 ) of all the paths that contan at most t vertces. In partcular, d (u, v) δ +ɛ/2. Consder the length of p (u, v) n G(r). The same argument shows that the length of p (u, v) n G(r) changed by at most ɛ/2. But w 0 = f (u, v)(r) s that weght, and hence w 0 δ + ɛ. In partcular, z δ + ɛ. Assume next that every path of length δ n G(r) uses at least 4 n ln n edges. Let p be one such path. When gong from r to r = α + jρ 1, each edge e wth weght a e x + b e changed ts length by at most a e ρ 1. By the defnton of K, ths s at most ρ 1 K/(8(β α)). Thus, p changed ts weght by at most K n ρ 1 8(β α) = n K < ɛ 8N 1 8. In partcular, the length of p u,v,r s not more than the length of p n G(r ), whch, n turn, s at most δ + ɛ/8. By Lemma 3, wth probablty 1 o(1/n 3 ), some vertex of h appears on p u,v,r. Moreover, by the unon bound, wth probablty 1 o(1) all paths of the type p u,v,r (remember that r can hold one of O(n) possble values) are thus covered by the set H. Let h be a vertex of H appearng n p u,v,r. We therefore have d j (u, h ) + d j (h, v) δ + ɛ/8. Snce h = h u,v,j s taken as the vertex whch mnmzes these sums, we have, n partcular, d j (u, h) + d j (h, v) δ + ɛ/8. Consder the path q n G(α + jρ 1 ) realzng d j (u, h) + d j (h, v). The same argument shows that the length of q n G(r) changed by at most ɛ/8. But w 1 = fj (u, h)(r) + f j (h, v)(r) s that weght, and hence w 1 δ + ɛ/4. In partcular, z δ + ɛ/4. 5 Concludng remarks We have constructed several parametrc shortest path algorthms, whose common feature s that they preprocess the generc nstance and produce an advce that enables partcular nstantatons to be solved faster than runnng the standard weghted dstance algorthm from scratch. It would be of nterest to mprove upon any of these algorthms, ether n ther preprocessng tme or n ther nstantaton tme, or both. Perhaps the most challengng open problem s to mprove the preprocessng tme of Theorem 2 to a polynomal one, or, alternatvely, prove an hardness result for ths task. Perhaps less ambtous s the preprocessng tme n Theorem 1. The only bottleneck that prevents reducng the Õ(n4 ) tme to O(nm) s the need to solve the LP usng nteror pont methods n order to compute the range of non-negatve cycles. Perhaps ths could be crcumvented. Fnally, parametrc algorthms are of practcal mportance for other combnatoral optmzaton problems as well. It would be nterestng to fnd applcatons where, ndeed, a parametrc algorthm can be truly benefcal, as t s n the case of shortest path problems.

Acknowledgment We thank Oren Wemann and Shay Mozes for useful comments. References 1. A. V. Aho, J. E. Hopcroft, and J. Ullman, The Desgn and Analyss of Computer Algorthms, Addson-Wesley Longman Publshng Co., Boston, MA, 1974. 2. R. Bellman, On a routng problem, Quarterly of Appled Mathematcs 16 (1958), 87 90. 3. P. Carstensen, The complexty of some problems n parametrc lnear and combnatoral programmng, Ph.D. Thess, Mathematcs Dept., U. of Mchgan, Ann Arbor, Mch., 1983. 4. T. M. Chan, More Algorthms for All-Pars Shortest Paths n Weghted Graphs, Proceedngs of the 39 th ACM Symposum on Theory of Computng (STOC), ACM Press (2007), 590 598. 5. D. Coppersmth and S. Wnograd, Matrx multplcaton va arthmetc progressons, Journal of Symbolc Computaton 9 (1990), 251 280. 6. E. W. Djkstra, A note on two problems n connecton wth graphs, Numersche Mathematk 1 (1959), 269 271. 7. R. W. Floyd, Algorthm 97: shortest path Communcatons of the ACM 5 (1962), 345. 8. M. L. Fredman, New bounds on the complexty of the shortest path problem, SIAM Journal on Computng 5 (1976), 49 60. 9. M. L. Fredman and R. E. Tarjan, Fbonacc heaps and ther uses n mproved network optmzaton algorthms, Journal of the ACM 34 (1987), 596 615. 10. D. Gusfeld Parametrc combnatoral computng and a problem of program module dstrbuton, Journal of the ACM 30(3) (1983), 551 563. 11. D. B. Johnson, Effcent algorthms for shortest paths n sparse graphs, Journal of the ACM 24 (1977), 1 13. 12. N. Karmarkar, A New Polynomal Tme Algorthm for Lnear Programmng, Combnatorca 4 (1984), 373-396. 13. R. M. Karp and J. B. Orln, Parametrc shortest path algorthms for wth an applcaton to cycle staffng, Dscrete Appled Mathematcs 3 (1981), 37 45. 14. E. Nkolova, J. A. Kelner, M. Brand and M. Mtzenmacher, Stochastc Shortest Paths Va Quas-convex Maxmzaton, Proceedngs of the 14 th Annual European Symposum on Algorthms (ESA), LNCS (2006), 552 563. 15. N. E. Young, R. E. Tarjan and J. B. Orln, Faster parametrc shortest path and mnmum-balance algorthms, Networks 21 (1991), 205 221. 16. U. Zwck, All-pars shortest paths usng brdgng sets and rectangular matrx multplcaton, Journal of the ACM 49 (2002), 289 317. Appendx 6 Proof of Clam 1 The Clam 1 s the followng: Clam 2. If B 1 and B 2 are two mnbases of szes t 1 and t 2 respectvely, then (a) mn(b 1 + B 2 ) can be computed from B 1 and B 2 n tme O(t 1 + t 2 ). (b) mn{b 1, B 2 } can be computed from B 1 and B 2 n tme O(f(d)(t 1 + t 2 )), where f(d) s the tme requred to compute the ntersecton ponts of two degree-d polynomals. The sze of mn{b 1, B 2 } s O(d(t 1 + t 2 )). Proof (Proof of Clam 1). Let break 1 = {b 1 0, b1 1,..., b1 t 1, b 1 t 1 +1 } and break 2 = {b 2 0, b2 1,..., b2 t 2, b 2 t 2 +1 } be the set of breaks of B 1 and B 2 respectvely. Also let {p 1 0, p1 1,..., p1 t 1 } and {p 2 0, p2 1,..., p2 t 2 } be the ordered set of polynomals for B 1 and B 2 respectvely. Proof of Part (a): Consder the sequence of breaks whose elements are break 1+2 = break 1 break 2 after sortng. Let break 1+2 = {b 1+2 0 1,... t 1 +t 2 t 1 +t 2 +1 there exsts a p 1 1 such that p 1 1 p 1 j }. Now for an nterval [b1+2 +1 ] for all j. Smlarly for the nterval [b1+2 +1 ] there exsts a p2 2

such that p 2 2 p 2 j for all j. Thus n the nterval [b1+2 +1 ] the polynomal p1 1 + p 2 2 s less than or equal to p 1 j + p2 k for all j, k. Thus break1+2 can be a set of breaks correspondng to mn(b 1 + B 2 ) and p 1 1 + p 2 2 s the polynomal correspondng to the nterval [b 1+2 +1 ]. Thus mn(b 1 + B 2 ) can be computed n tme O(t 1 + t 2 ). Proof of Part (b): Just lke n the proof of Part (a) consder the sequence of breaks whose elements are break 1+2 = break 1 break 2. Let break 1+2 = {b 1+2 0 1,... t 1 +t 2 t 1 +t 2 +1 }. Now for an nterval [b 1+2 +1 ] there exsts a p1 1 such that p 1 1 p 1 j for all j. Smlarly for the nterval [b 1+2 +1 ] there exsts a p2 2 such that p 2 2 p 2 j for all j. Now n the nterval [b 1+2 +1 ] the two polynomals p1 1 and p 2 2 can ntersect each other at most d tmes, because they are degree d-polynomals. Let b 1, 2 1 < b 1, 2 2 < < b 1, 2 c for c d be the set of ponts where p 1 1 and p 2 2 ntersect wthn the nterval [b 1+2 +1 ]. Thus n the subntervals [b 1, 2 k, b 1, 2 k+1 ] ether p1 1 or p 2 2 s smaller and they are smaller than all other polynomals p 1 j and p2 j n ths nterval. Thus break 1+2 along wth all the ntersecton ponts of p 1 1 and p 2 2 n each nterval [b 1+2 +1 ] can be a set of breaks for mn{b 1, B 2 } and the polynomals can also be computed easly. So mn{b 1, B 2 } can be computed n tme O(f(d)(t 1 + t 2 )) where f(d) s the tme taken to compute the ntersecton ponts of two degree d polynomals. The sze of mn{b 1, B 2 } s O(d(t 1 + t 2 )).