# 1 Efficient algorithms on sets of permutations, dominance, and real-weighted APSP Raphael Yuster University of Haifa.

## Presentation on theme: "1 Efficient algorithms on sets of permutations, dominance, and real-weighted APSP Raphael Yuster University of Haifa."— Presentation transcript:

1 Efficient algorithms on sets of permutations, dominance, and real-weighted APSP Raphael Yuster University of Haifa

2 Permutations and matrix products This work consists of several algorithms and applications that involve the manipulation of sets of permutations via matrix multiplication techniques. In this talk we shall only focus on one of these algorithms which, together with other ingredients implies a sub-cubic APSP algorithm for arbitrary real weighted graphs, where there are not too many distinct weights emanating from each vertex. But before that:

3 An interesting open problem Let P be a set of p permutations of S n. P 2 = {  i  j |  i  P,  j  P} Task: compute |P 2 | in less than trivial p 2 n time. Example: P = {4231, 3124, 1243} answer: 7 P 2 = {1234, 4123, 3241, 3421, 2314, 4213, 3142} Say, e.g., p=n, then computing it in n 3 time is trivial. With fast matrix multiplication we can show an O(n 2.38 ) randomized algorithm. Can we solve it in O(n 3-  ) deterministically?

4 APSP algorithm All-Pairs Shortest Paths n by n distance matrix Input: An edge-weighted directed graph G=(V,E), where |V|=n (weights are arbitrary reals) Output: An n  n distance matrix. Can be solved in: O(n 3 (loglog n) 3 / log 2 n) time [Chan ‘07].

5 New result APSP algorithm that is truly sub-cubic as long as the set of distinct weights emanating from each vertex is not too large (but still much larger than a constant). For v  V, let W(v) be the set of distinct weights of edges emanating from v and let k(G)=max v |W(v)|. Our algorithm: sub-cubic when k(G) < n 0.338. Note: this allows for up to n 1.338 distinct weights.

6 Matrix multiplication exponents M(a,b,c) : “time” to multiply an a × b matrix by a b × c matrix over an arbitrary field. ω(r,s,t) : smallest exponent for which M(n r,n s,n t ) = O(n ω(r,s,t) ). ω(1,1,1) < 2.376 [Coppersmith-Winograd ‘90]. μ : solution to ω(1+μ,1,1+μ) =3. μ > 0.338. If k(G) = n ρ and ρ< μ then the algorithm runs in time O(n 3- γ/2+ρ/2 ) where γ solves ω(1+ ρ,1,1+ γ)=3+ρ- γ. If ρ=0 then γ=0.3165 implying vertex-weighted APSP in O(n 2.842 ). Slightly improves O(n 2.844 ) [Chan ‘07].

7 An interesting special case of the APSP problem AB 17 23 Distance product 2 5 10 20 30 20

8 Distance Products

9 A way to compute a distance product Let A and B be two distance matrices, where:  each row of A has at most k = n ρ distinct values  B is arbitrary Then A  B can be computed in time O(n ω(1+ ρ,1,1+ γ) ) where γ solves ω(1+ ρ,1,1+ γ)=3+ρ- γ. Proof: We reduce the problem to the problem of computing “permutation dominance” which, in turn, can be reduced to Boolean matrix multiplication.

10 For each row u of A, let W(u)={w u,1,…,w u,k } be the distinct values appearing in it. Let A' be the Boolean matrix of order nk × n indexed by the row set [k] × [n] and the column set [n]. We set A'((j,u),v) = 1 iff A(u,v)=w u,j. “Example”: n=4, k=2

 3 =(3 2 1 4) 11 Let  u be a permutation so that  u (i) <  u (j) implies B(i,u)  B(j,u). We can construct  1,...,  n in O(n 2 log n) time by sorting each column of B. Let B' be the Boolean matrix of order n × ns indexed by the row set [n] and the column set [s] × [n]. We set B'(u,(j,v))=1 iff  v (u)  [1+(j-1)(n/s), …, jn/s]. “Example”: n=4, s=2 (we will actually choose s=n γ )

we compute C'=A'B' in O(n ω(1+ ρ,1,1+γ) ) time. We can deduce D = A  B from C'. Fixing u and v, we show how to compute D(u,v) in O(k(s+n/s)) time, and hence D is computed in O(n 2 k(s+n/s)) = O(n 3+ρ-γ ) = O(n ω(1+ ρ,1,1+γ) ) time. 12

For each i=1,…,k, let j i be the smallest index so that C((i,u),(j i,v))=1 (if no such index exists, set j i =0). If j i  0, we know that we have at least one index z so that A'((i,u),z)=1 and B'(z,(j i,v))=1. This means that  v (z)  [1+(j i - 1)(n/s), …, j i n/s]. We wish to locate that z i for which  v (z) is minimal. We use  v to locate z i in O(n/s) time. We know that A(u,z i )+B(z i,v) is the minimum sum whenever the first term has weight w u,i. Taking the minimum of A(u,z i )+B(z i,v) ranging over all plausible i we obtain D(u,v). 13

14  3 =(3 2 1 4) j 1 =2 Belongs to block 2: j 1 =2 Belongs to block 1: j 2 =1  3 (1),  3 (4)  {3,4} z=1 z=4 relevant z 1 =1 7+8=15 j 2 =1  3 (2),  3 (3)  {1,2} z=2 z=3 relevant z 2 =3 1+4=5

15 From distance product to APSP G=(V,E,w) is a weighted digraph with n vertices For v  V, W(v) are the emanating weights. |W(v)|  k. t - a parameter (to be chosen later). c(u,v) min. # of edges on shortest path from u to v. d i (u,v) shortest distance from u to v using at most i edges. Clearly, d(u,v)=d n-1 (u,v). d 1 (u,v)=w(u,v). D i - the matrix recording all the values d i (u,v). Thus, D 1 is our input. Notice : D i = D 1  D i-1.

16 From distance product to APSP Each row of D 1 has at most k = n ρ distinct values. Thus, D i is computed from D 1  D i-1 in O(n 3+ρ-γ ) = O(n ω(1+ ρ,1,1+γ) ) time. Hence D t is computed in O( t n 3+ρ-γ ). We already know that D t (u,v)=D(u,v) for all pairs with c(u,v)  t. We need to worry about pairs for which c(u,v) > t. For this, we shall use the bridging sets technique of [Zwick ‘02].

17 From distance product to APSP A set of vertices B is a t-bridging set if for each u,v with  > c(u,v) > t, there exists a shortest path p ={u=u 0,u 1,…,u s =v} realizing d 1.5t (u,v) where some vertex u i is from B and i  (s-t … t). Easy to show: a random set B of size  (n log n / t) is a t-bridging set. (Zwick has shown how to find such a B deterministically in O(n 2.5 ) time). Having found a t-bridging set B, we compute a matrix which is (better than) D 1.5t as follows: 0 s-tt s u v

18 From distance product to APSP Time: O(n 3 /t) (straightforward product). We now have D(u,v) for all pairs with c(u,v)  1.5t. Repeated squaring O(log n) time we get the final D. Choosing t= n γ/2-ρ/2 we obtain that: The overall running time is O(n 3- γ/2+ρ/2 ) as claimed. Dt(B)Dt(B) DtT(B)DtT(B)  D 1.5t 

19 Thanks

Download ppt "1 Efficient algorithms on sets of permutations, dominance, and real-weighted APSP Raphael Yuster University of Haifa."

Similar presentations