Answering distance queries in directed graphs using fast matrix multiplication Raphael Yuster Haifa University Uri Zwick Tel Aviv University.

Slides:



Advertisements
Similar presentations
Graph Algorithms - 3 Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 13Feb 12, 2014Carnegie Mellon University.
Advertisements

Surender Baswana Department of CSE, IIT Kanpur. Surender Baswana Department of CSE, IIT Kanpur.
Single Source Shortest Paths
all-pairs shortest paths in undirected graphs
Approximate Distance Oracles and Spanners with sublinear surplus Mikkel Thorup AT&T Research Uri Zwick Tel Aviv University.
1 Efficient algorithms on sets of permutations, dominance, and real-weighted APSP Raphael Yuster University of Haifa.
Noga Alon Institute for Advanced Study and Tel Aviv University
Matrix sparsification (for rank and determinant computations) Raphael Yuster University of Haifa.
1 Directed Graphs: Victoria Road Problem. 2 Update: Edge is deleted; Edge is inserted Edge weight is changed F A Directed graph problems.
All-Pairs shortest paths via fast matrix multiplication Uri Zwick Tel Aviv University Otwarte wykłady dla doktorantów informatyki Instytut Informatyki.
1 Algorithms for Large Data Sets Ziv Bar-Yossef Lecture 8 May 4, 2005
1 On Dynamic Shortest Paths Problems Liam Roditty Uri Zwick Tel Aviv University ESA 2004.
1 Fast Sparse Matrix Multiplication Raphael Yuster Haifa University (Oranim) Uri Zwick Tel Aviv University ESA 2004.
1 Finding cycles using rectangular matrix multiplication and dynamic programming Raphael Yuster Haifa Univ. - Oranim Uri Zwick Tel Aviv University Uri.
Towards Communication Avoiding Fast Algorithm for Sparse Matrix Multiplication Part I: Minimizing arithmetic operations Oded Schwartz CS294, Lecture #21.
Answering Distance Queries in directed graphs using fast matrix multiplication Seminar in Algorithms Prof. Haim Kaplan Lecture by Lior Eldar 1/07/2007.
Tirgul 13. Unweighted Graphs Wishful Thinking – you decide to go to work on your sun-tan in ‘ Hatzuk ’ beach in Tel-Aviv. Therefore, you take your swimming.
Randomness in Computation and Communication Part 1: Randomized algorithms Lap Chi Lau CSE CUHK.
1 Exact and Approximate Distances in Graphs – A Survey Uri Zwick Tel Aviv University.
CS 473 All Pairs Shortest Paths1 CS473 – Algorithms I All Pairs Shortest Paths.
1 A fast algorithm for Maximum Subset Matching Noga Alon & Raphael Yuster.
All-Pairs Bottleneck Paths in Vertex Weighted graphs Asaf Shapira Microsoft Research Raphael Yuster University of Haifa Uri Zwick Tel-Aviv University.
Edge-disjoint induced subgraphs with given minimum degree Raphael Yuster 2012.
Distance sensitivity oracles in weighted directed graphs Raphael Yuster University of Haifa Joint work with Oren Weimann Weizmann inst.
Matrix Multiplication and Graph Algorithms Uri Zwick Tel Aviv University.
Shortest Paths.
Dijkstra’s Algorithm SSSP, non-neg Edge weights = w(x,y)
Improved Randomized Algorithms for Path Problems in Graphs
Algorithm Analysis Fall 2017 CS 4306/03
Haim Kaplan and Uri Zwick
Randomized Algorithms
June 2017 High Density Clusters.
Yuval Peres Dmitry Sotnikov Benny Sudakov Uri Zwick (武熠)
All-Pairs Shortest Paths (26.0/25)
David Wilson – Microsoft Research Uri Zwick – Tel Aviv Univ.
Minimum Spanning Tree Verification
Greedy Algorithms / Dijkstra’s Algorithm Yin Tat Lee
Randomized Algorithms CS648
Analysis of Algorithms
Shortest Paths.
Haim Kaplan and Uri Zwick
CS200: Algorithm Analysis
CSCE 411 Design and Analysis of Algorithms
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Analysis and design of algorithm
Shortest-Paths Trees Kun-Mao Chao (趙坤茂)
Autumn 2015 Lecture 10 Minimum Spanning Trees
Shortest Path Algorithms
Analysis of Algorithms
Raphael Yuster Haifa University Uri Zwick Tel Aviv University
Floyd’s Algorithm (shortest-path problem)
CSCE 411 Design and Analysis of Algorithms
Fast Sparse Matrix Multiplication
Algorithms (2IL15) – Lecture 7
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Exact and Approximate Distances in Graphs – A Survey
Chapter 24: Single-Source Shortest Paths
Autumn 2016 Lecture 10 Minimum Spanning Trees
Shortest Paths.
Chapter 24: Single-Source Shortest Paths
CSE 417: Algorithms and Computational Complexity
Parallel Graph Algorithms
Matrix Addition, C = A + B Add corresponding elements of each matrix to form elements of result matrix. Given elements of A as ai,j and elements of B as.
Negative-Weight edges:
Major Design Strategies
Analysis of Algorithms
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Analysis of Algorithms
Applied Discrete Mathematics Week 4: Functions
Lecture 22 Complexity and Reductions
Presentation transcript:

Answering distance queries in directed graphs using fast matrix multiplication Raphael Yuster Haifa University Uri Zwick Tel Aviv University

Answering distance queries Generalizes both SSSP and APSP Preprocessing: data structure u,v δ(u,v) Query answering:

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. Mn2.38 vs. mn0.5log M

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]

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) !!!

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) !!!

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]

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]

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. Mn2.38 vs. mn0.5log M

An interesting special case of the APSP problem 20 17 30 2 23 10 5 20 Min-Plus product

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))

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

Using matrix multiplication to compute min-plus products

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  =

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

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

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|

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

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) !!!

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

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] } }

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] }

Twice Sampled Distance Products |B| |B| n

The query answering algorithm δ(u,v)  D[{u},V]*D[V,{v}] u v Query time: O(n)

The preprocessing algorithm: Correctness Let Bi be the i-th sample. B1 B2  B3  … Invariant: After the i-th iteration, if u Bi or vBi 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

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

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?