Complexity Theory of Polynomial-Time Problems Lecture 4: The polynomial method Part II: All-pairs shortest paths Sebastian Krinninger
Overview on APSP Algorithms โข Floyd-Warshall algorithm: ๐(๐ 3 ) Inserts one node at a time ๐ iterations, each taking time ๐(๐ 2 ) โข Faster algorithms for sparse graphs โข Directed graphs: โข Single-source shortest paths: ๐(๐ + ๐ log ๐) (Dijkstra with Fibonacci heap/Hollow heap) โข โ All-pairs shortest paths: ๐(๐๐ + ๐ 2 log ๐) , improved to ๐(๐๐ + ๐ 2 log log ๐) [Pettie 02] โข Undirected graphs: โข Single-source shortest paths: ๐(๐) [Thorup 97] โข โ All-pairs shortest paths: ๐(๐๐) โข Pseudopolynomial algorithms โข Today: Fastest โgeneral - purposeโ algorithm
History of slightly subcubic algorithms Running Time Author(s) Year(s) ๐ 3 Floyd, Warshall 1962 ๐ 3 / log 1/3 ๐ Fredman 1975 ๐ 3 / log 1/2 ๐ Dobosiewicz, Takaoka 1990, 1991 ๐ 3 / log 5/7 ๐ Han 2004 ๐ 3 / log ๐ Takaoka, Zwick, Chan 2004, 2005 ๐ 3 / log 5/4 ๐ Han 2006 ๐ 3 / log 2 ๐ Chan, Han/Takaoka 2007, 2012 ๐ 3 /2 ฮฉ log ๐ 1/2 Williams 2014 Grows faster than any polylogarithmic factor
Problem definition: desired output โข Can create instances such that for every pair of nodes ๐ฃ, ๐ค shortest path from ๐ฃ to ๐ค consists of ฮฉ(๐) nodes โข โ Cannot output all shortest paths explicitly in time ๐(๐ 3 ) โข Distance matrix: output size ๐ 2 โข Shortest path matrix ๐๐ : output size ๐ 2 For every pair of nodes ๐ฃ, ๐ค , SP ๐ฃ, ๐ค = next node on shortest path from ๐ฃ to ๐ค
Machine model: Real RAM Floyd-Warshall: ๐(๐ 3 ) with only additions and comparisons ฮฉ(๐ 3 ) lower bound if only additions and comparisons allowed [Kerr 70] Real RAM: โข Additions and comparisons of reals: unit cost โข Other operations: logarithmic cost
Tools
Tool 1: Razborov-Smolensky Represent AND of ๐ variables ๐ฆ 1 โง โฏ โง ๐ฆ ๐ by low-degree polynomial โข Parameter ๐ 1 โข For every ๐ = 1, โฆ , ๐ , ๐ = 1, โฆ , ๐ : Set ๐ ๐,๐ = 0 or 1 with probability 2 ๐ ๐ ๐ต ๐ฆ 1 , โฆ , ๐ฆ ๐ = 1 โ ๐ ๐,๐ โ ๐ฆ ๐ โ 1 ๐=1 ๐=1 1 Lemma : Pr ๐ ๐,๐ ๐ต ๐ฆ 1 , โฆ , ๐ฆ ๐ = ๐ฆ 1 โง โฏ โง ๐ฆ ๐ โฅ 1 โ 2 ๐ By distributive law , ๐ต can be written as XOR of 1 + ๐ ๐ monomials
๐ ๐ ๐ต ๐ฆ 1 , โฆ , ๐ฆ ๐ = 1 โ ๐ ๐,๐ โ ๐ฆ ๐ โ 1 ๐=1 ๐=1 ๐ ๐,๐ ๐ต ๐ฆ 1 , โฆ , ๐ฆ ๐ = ๐ฆ 1 โง โฏ โง ๐ฆ ๐ โฅ 1 โ 1 Lemma : Pr 2 ๐ Proof: ๐ฆ 1 โง โฏ โง ๐ฆ ๐ = 1 : Each ๐ฆ ๐ must be 1 . Clearly, ๐ต ๐ฆ 1 , โฆ , ๐ฆ ๐ = 1 Observation : For every set ๐ , ๐ฆ 1 โง โฏ โง ๐ฆ ๐ = 0 : First, fix some ๐ #odd subsets = #even subsets (by binary encoding of the 2 |๐| ๐ : subsets of ๐ฆ ๐ โs that are 0 subsets) ๐โฒ : subsets of ๐ฆ ๐ โs that are 0 and additionally ๐ ๐,๐ = 1 Bad event: ๐ -th component of outer AND is 1 โ |๐ โฒ | is even Each subset of ๐ has same probability of being picked as ๐ โฒ Pr |๐ โฒ | is odd = Pr |๐ โฒ | is even = 1 2 ๐ต ๐ฆ 1 , โฆ , ๐ฆ ๐ = 1 only if bad event happens for each component of outer AND โ Error probability โค 1 2 ๐
Tool 2: Fast rectangular matrix multiplication ร = ๐ ๐ 0.1 Theorem : There is an algorithm for multiplying an ๐ ร ๐ 0.17 matrix with an ๐ 0.17 ร ๐ matrix in time ๐(๐ 2 log 2 ๐) . Also works for finite fields such as ๐บ 2 !
Fast evaluation of polynomial Given: Polynomial ๐(๐ฆ[1], โฆ , ๐ฆ[๐], ๐ง[1], โฆ , ๐ง[๐]) over ๐บ 2 โข With ๐ โค ๐ 0.1 monomials โข Two sets of inputs: ๐ = ๐ฆ 1 , โฆ , ๐ฆ ๐ โ 0,1 ๐ ๐ = ๐ง 1 , โฆ , ๐ง ๐ โ 0,1 ๐ ( ๐ฆ ๐ = ๐ฆ ๐ [1], โฆ , ๐ฆ ๐ [๐] ) ( ๐ง ๐ = ๐ง ๐ [1], โฆ , ๐ง ๐ [๐] ) Lemma : There is an algorithm for evaluating ๐ on all pairs ๐ฆ ๐ , ๐ง ๐ โ ๐ ร ๐ (simultaneously) in time ๐ ๐ 2 poly log ๐ .
Restrictions of monomials Shape of polynomial ๐ : โข ๐ = ๐ 1 + โฏ + ๐ ๐ โข each ๐ ๐ is a monomial Define โข ๐ ๐ |๐ฆ : restriction of ๐ -th monomial to variables ๐ฆ[1], โฆ , ๐ฆ[๐] โข ๐ ๐ |๐ง : restriction of ๐ -th monomial to variables ๐ง[1], โฆ , ๐ง[๐] โข (empty product = 1 ) โInner productโ โข ๐ = ๐ 1 ๐ฆ โ ๐ 1 ๐ง + โฏ + ๐ ๐ ๐ฆ โ ๐ ๐ ๐ง
Reduction to matrix multiplication ๐ฆ 1 ๐ 0.1 monomials โฎ ร ๐ฆ ๐ ๐ง 1 โฆ ๐ง ๐ Entry ๐, ๐ : Evaluation of ๐ ๐ |๐ง ๐ ๐ 0.1 monomials Entry ๐, ๐ : Evaluation of ๐ ๐ |๐ฆ ๐ Result matrix ๐[๐, ๐] : Evaluation of ๐ under ๐ฆ ๐ = ๐ฆ ๐ [1], โฆ , ๐ฆ ๐ [๐] and ๐ง ๐ = ๐ง ๐ [1], โฆ , ๐ง ๐ [๐]
Tool 3: Union Bound and Chernoff Bound Union Bound: Pr ๐ต โช ๐ถ โค Pr ๐ต + Pr ๐ถ (Variant of) Chernoff Bound: Let ๐ 1 , โฆ , ๐ ๐ be independent 0/1-valued random variables such that 0 < ๐น ๐ ๐ < 1 . ๐ Then, the random variable ๐ = ๐=1 ๐ ๐ satisfies: Pr ๐ < 1 โ ๐ ๐น[๐] โค ๐ โ๐ 2 ๐น[๐]/2 for every 0 โค ๐ โค 1
Solving the Problem
Min-plus matrix product We give an algorithm for the following problem: โข Given: ๐ ร ๐ integer matrix ๐ต and ๐ ร ๐ integer matrix ๐ถ โข Output: ๐ ร ๐ matrix ๐ท such that ๐ท ๐, ๐ = ๐โ{1,โฆ,๐} (๐ต ๐, ๐ + ๐ถ ๐, ๐ ) min Matrix multiplication in min-plus semiring: โข min is addition โข + is multiplication โข 0 is 1 -element โข โ is 0 -element ๐ โ such that ๐ต ๐, ๐ โ + ๐ถ ๐ โ , ๐ = ๐โ{1,โฆ,๐} (๐ต ๐, ๐ + ๐ถ ๐, ๐ ) is a witness for ๐, ๐ min
Tripartite graph for min-plus product ๐ท ๐, ๐ = min 1โค๐โค๐ (๐ต ๐, ๐ + ๐ถ ๐, ๐ ) ๐ โฎ ๐ ๐ โฎ โฎ ๐ฅ ๐, ๐ = ๐ต[๐, ๐] ๐ฅ ๐, ๐ = ๐ถ[๐, ๐] (no edge if weight is โ) 1. Min-plus product = APSP in tripartite graph 2. If ๐ต = ๐ถ = ๐ป : ๐ป ร ๐ป = matrix of 2 -hop distances
APSP and min- plus product are โequivalentโ In general: ๐ป ๐ = matrix distances using exactly ๐ hops Distance matrix ๐ธ : ๐ธ = ๐ฝ + ๐ป + ๐ป 2 + โฏ + ๐ป ๐โ1 = ๐ป + ๐ฝ ๐โ1 + is entry-wise minimum Identity matrix ๐ฝ : 0 at diagonal, โ otherwise Repeated squaring: Compute ๐ป + ๐ฝ 2 , ๐ป + ๐ฝ 4 , ๐ป + ๐ฝ 8 , โฆ, โ ๐(log ๐) min-plus products for distances, shortest paths through witnesses Even stronger relationship known: Theorem : APSP on ๐ nodes can be solved in time ๐(๐ ๐ ) if and only min-plus product on ๐ ร ๐ matrices can be solved in time ๐(๐ ๐ ) .
Step 1: : Divide into subproblems
Overall algorithm ๐ต ๐ถ Set ๐ = 2 log ๐/100 ๐ 1. ๐ต 1 ๐ต ๐/๐ ๐ถ 1 ๐ 2. Divide problem into ๐ subproblems 3. Solve each subproblem in time ๐ ๐ 2 poly log ๐ ๐ถ ๐/๐ Merge solutions in time ๐ ๐ 3 /๐ 4. ๐ For every ๐ = 1, โฆ , ๐ : โข Compute product ๐ท ๐ of ๐ต ๐ and ๐ถ ๐ Total time: ( ๐ ร ๐ matrix with ๐ ร ๐ matrix) ๐ 3 = ๐ 3 /2 ฮฉ log ๐ 1/2 ๐ ๐ poly log ๐ Return: min ๐ท 1 , โฆ , ๐ท ๐/๐ (entry-wise minimum)
Subproblem We solve the following subproblem: โข Given: ๐ ร ๐ matrix ๐ต and ๐ ร ๐ matrix ๐ถ โข Output: ๐ ร ๐ matrix ๐ of witnesses such that ๐ ๐, ๐ = arg min (๐ต ๐, ๐ + ๐ถ ๐, ๐ ) ๐โ{1,โฆ,๐} From witnesses in ๐ we can easily reconstruct values of min-plus ๐โ{1,โฆ,๐} (๐ต ๐, ๐ + ๐ถ ๐, ๐ ) in time ๐ ๐ 2 min product
Step 2: : Preprocess input of subproblem
Enforce unique minimum For every entry ๐, ๐ of ๐ต : Running time: ๐ต โ ๐, ๐ โถ= ๐ต ๐, ๐ โ ๐ + 1 + ๐ ๐(log ๐) additions per entry (add to itself for ๐(log ๐) times) For every entry ๐, ๐ of ๐ถ ๐ถ โ ๐, ๐ โถ= ๐ถ ๐, ๐ โ ๐ + 1 โ ๐ ๐๐ log ๐ Fix some pair ๐, ๐ and define ๐ โ as smallest ๐ โฒ โ {1, โฆ , ๐} such that ๐ต ๐, ๐ โฒ + ๐ถ ๐ โฒ , ๐ = ๐โ{1,โฆ,๐} ๐ต ๐, ๐ + ๐ถ ๐, ๐ min Claim: ๐ โ is unique minimum of ๐ต โ ๐, ๐ + ๐ถ โ ๐, ๐ over ๐ โ โ {1, โฆ , ๐} โ Work with ๐ต โ and ๐ถ โ instead of ๐ต and ๐ถ to ensure unique minima
Recommend
More recommend