Download presentation
Presentation is loading. Please wait.
Published byΕυγένεια Αγγελοπούλου Modified over 5 years ago
1
Answering distance queries in directed graphs using fast matrix multiplication
Raphael Yuster Haifa University Uri Zwick Tel Aviv University
2
Answering distance queries
Generalizes both SSSP and APSP Preprocessing: data structure u,v δ(u,v) Query answering:
3
New result: Answering distance queries
Directed graphs. Edge weights in {−M,…,0,…M} Preprocessing time Query time Authors Mn2.38 n [Yuster-Zwick ’05] In particular, any Mn1.38 distances can be computed in Mn2.38 time. For dense enough graphs with small enough edge weights, this improves on Goldberg’s SSSP algorithm. Mn vs. mn0.5log M
4
Single-source Shortest Paths in directed graphs with real edge weights
Non-negative edge weights Running time Authors m + n log n [Dijkstra ’59] [Fredman-Tarjan ’86] Positive and negative edge weights Running time Authors mn [Bellman ’58] [Ford ’58]
5
Single-source Shortest Paths in directed graphs with integer edge weights
Positive and negative edge weights greater than –N Running time Authors mn1/2log(nN) [Gabow-Tarjan ’89] mn1/2logN [Goldberg ’95] For dense graphs, the running time is O(n2.5) !!!
6
All-Pairs Shortest Paths in directed graphs with real edge weights
Running time Authors mn + n2 log n [Dijkstra ’59], [Johnson ’77] [Fredman-Tarjan ’86] mn + n2 log log n ([Thorup ’99] [Hagerup ’00]) [Pettie ’02] For dense graphs, the running time is O(n3) !!!
7
All-Pairs Shortest Paths in graphs with small integer weights
Undirected graphs. Edge weights in {0,1,…M} Running time Authors Mn2.38 [Shoshan-Zwick ’99] Improves results of [Alon-Galil-Margalit ’91] [Seidel ’95]
8
All-Pairs Shortest Paths in graphs with small integer weights
Directed graphs. Edge weights in {−M,…,0,…M} Running time Authors M0.68 n2.58 [Zwick ’98] Improves results of [Alon-Galil-Margalit ’91] [Takaoka ’98]
9
New result: Answering distance queries
Directed graphs. Edge weights in {−M,…,0,…M} Preprocessing time Query time Authors Mn2.38 n [Yuster-Zwick ’05] In particular, any Mn1.38 distances can be computed in Mn2.38 time. For dense enough graphs with small enough edge weights, this improves on Goldberg’s SSSP algorithm. Mn vs. mn0.5log M
10
An interesting special case of the APSP problem
20 17 30 2 23 10 5 20 Min-Plus product
11
Solving the APSP problem by repeated squaring
If W is an n by n matrix containing the edge weights of a graph. Then Wn is the distance matrix. D W for i 1 to log2n do D D*D Thus: APSP(n) MPP(n) log n Actually: APSP(n) = O(MPP(n))
12
O(n2.38) [Strassen ’69] … [Coppersmith- Winograd ’90]
Min-Plus Product Algebraic Product O(n2.38) [Strassen ’69] … [Coppersmith- Winograd ’90] The fast algebraic algorithms cannot be used, as the min operation has no inverse
13
Using matrix multiplication to compute min-plus products
14
Using matrix multiplication to compute min-plus products
Assume: 0 ≤ aij , bij ≤ M M operations per polynomial product Mn2.38 operations per max-plus product n2.38 polynomial products =
15
Trying to implement the repeated squaring algorithm
Consider an easy case: all weights are 1. * Iteration Max size of elements Cost 1 n2.38 2 2·n2.38 i 2i 2i·n2.38 log n n n·n2.38
16
Sampled Repeated Squaring (Z ’98)
D W for i 1 to log3/2n do { s (3/2)i+1 B rand( V , (9n ln n)/s ) D min{ D , D[V,B]*D[B,V] } } Choose a subset of V of size (9n ln n)/s Select the columns of D whose indices are in B Select the rows of D whose indices are in B With high probability, all distances are correct! The is also a slightly more complicated deterministic algorithm
17
Sampled Distance Products (Z ’98)
In the i-th iteration, the set B is of size n ln n / s, where s = (3/2)i n The matrices get smaller and smaller but the elements get larger and larger n |B|
18
Sampled Repeated Squaring - Correctness
Invariant: After the i-th iteration, distances that are attained using at most (3/2)i edges are correct. D W for i 1 to log3/2n do { s (3/2)i+1 B rand(V,(9 ln n)/s) D min{ D , D[V,B]*D[B,V] } } Consider a shortest path that uses at most (3/2)i+1 edges at most Failure probability : Let s = (3/2)i+1
19
Rectangular Matrix multiplication
= n p Naïve complexity: n2p [Coppersmith ’97]: n1.85p0.54+n2+o(1) For p ≤ n0.29, complexity = n2+o(1) !!!
20
Complexity of APSP algorithm
The i-th iteration: n n ln n / s s=(3/2)i+1 The elements are of absolute value at most Ms
21
The new preprocessing algorithm
D W ; B V for i 1 to log3/2n do { s (3/2)i+1 B rand(B,(9n ln n)/s) D[V,B] min{D[V,B] , D[V,B]*D[B,B] } D[B,V] min{D[B,V] , D[B,B]*D[B,V] } }
22
The old algorithm D W for i 1 to log3/2n do { s (3/2)i+1
B rand(V,(9nln n)/s) } D min{ D , D[V,B]*D[B,V] }
23
Twice Sampled Distance Products
|B| |B| n
24
The query answering algorithm
δ(u,v) D[{u},V]*D[V,{v}] u v Query time: O(n)
25
The preprocessing algorithm: Correctness
Let Bi be the i-th sample. B1 B2 B3 … Invariant: After the i-th iteration, if u Bi or vBi and there is a shortest path from u to v that uses at most (3/2)i edges, then D(u,v)=δ(u,v). Consider a shortest path that uses at most (3/2)i+1 edges at most
26
The query answering algorithm: Correctness
Suppose that the shortest path from u to v uses between (3/2)i and (3/2)i+1 edges at most u v
27
Open problems An O(n3-ε) algorithm for the APSP problem with edge weights in {1,2,…,n}? More generally, an O(n3-ε(log M)c) algorithm for the APSP problem? An O(n2.5-ε) algorithm for the SSSP problem with edge weights in {0,±1, ±2,…, ±n}? More generally, an O(n2.5-ε(log M)c) algorithm for the SSSP problem?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.