190 likes | 310 Views
Efficient algorithms on sets of permutations, dominance, and real-weighted APSP. Raphael Yuster. University of Haifa. Permutations and matrix products.
E N D
Efficient algorithms on sets of permutations, dominance, and real-weighted APSP Raphael Yuster University of Haifa
Permutations and matrix products • This work consists of several algorithms and applications that involve the manipulation of sets of permutations via matrix multiplicationtechniques. • 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:
An interesting open problem • Let P be a set of p permutations of Sn . • P2 = {ij| i P , j P} • Task: compute |P2| in less than trivial p2n time. • Example: P = {4231, 3124, 1243} answer: 7P2 = {1234, 4123, 3241, 3421, 2314, 4213, 3142} • Say, e.g., p=n, then computing it in n3 time is trivial. • With fast matrix multiplication we can show an O(n2.38)randomized algorithm. • Can we solve it in O(n3-)deterministically?
All-Pairs Shortest Paths APSPalgorithm n by ndistancematrix Input:An edge-weighted directed graph G=(V,E), where |V|=n(weights are arbitrary reals) Output: An nn distance matrix. Can be solved in:O(n3 (loglog n)3 / log2n) time [Chan ‘07] .
New result • APSP algorithm that is truly sub-cubic as long as theset of distinct weights emanating from each vertex is nottoo large (but still much larger than a constant). • For vV, let W(v) be the set of distinct weights of edges emanating from v and let k(G)=maxv |W(v)|. • Our algorithm: sub-cubic when k(G) < n0.338. • Note: this allows for up to n1.338distinct weights.
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 whichM(nr,ns,nt) = 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(n3-γ/2+ρ/2)where γ solves ω(1+ρ,1,1+ γ)=3+ρ- γ. • If ρ=0 then γ=0.3165 implying vertex-weighted APSP in O(n2.842). Slightly improves O(n2.844)[Chan ‘07] .
An interesting special caseof the APSP problem A B 20 17 30 2 23 10 5 20 Distance product
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 AB 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.
For each row u of A, let W(u)={wu,1,…,wu,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) = 1iffA(u,v)=wu,j. • “Example”: n=4, k=2
Let u be a permutation so that u(i) < u(j)implies B(i,u) B(j,u). We can construct 1,... ,nin O(n2log 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 iffv(u) [1+(j-1)(n/s) , … , jn/s] . • “Example”: n=4, s=2 (we will actually choose s=nγ) 3=(3 2 1 4)
we compute C'=A'B' in O(nω(1+ ρ,1,1+γ))time. • We can deduce D =AB from C'. • Fixing u and v, we show how to compute D(u,v) in O(k(s+n/s)) time, and hence D iscomputed in O(n2k(s+n/s)) = O(n3+ρ-γ) = O(nω(1+ ρ,1,1+γ)) time.
For each i=1,…,k, let ji be the smallest index so thatC((i,u),(ji,v))=1 (if no such index exists, set ji=0). • If ji 0, we know that we have at least one index z so that A'((i,u),z)=1 andB'(z,(ji,v))=1. • This means that v(z) [1+(ji- 1)(n/s) , … , jin/s]. • We wish to locate that zi for which v(z)is minimal. We use v to locate zi in O(n/s) time. • We know that A(u,zi)+B(zi,v) is the minimum sum whenever the first term has weight wu,i. • Taking the minimum of A(u,zi)+B(zi,v) ranging over all plausible i we obtain D(u,v).
3=(3 2 1 4) Belongs to block 2: j1=2 j1=2 j2=1 3(1),3(4) {3,4} 3(2),3(3) {1,2} Belongs to block 1:j2=1 z=1 z=4 relevant z=2 z=3 relevant z1=1 7+8=15 z2=3 1+4=5
From distance product to APSP • G=(V,E,w) is a weighted digraph with n vertices • For vV, 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. • di(u,v) shortest distance from u to v using at most iedges. Clearly, d(u,v)=dn-1(u,v). d1(u,v)=w(u,v). • Di - the matrix recording all the values di(u,v). Thus, D1 is our input. • Notice : Di = D1 Di-1.
From distance product to APSP • Each row of D1 has at most k = nρdistinct values.Thus, Di is computed from D1 Di-1 inO(n3+ρ-γ) =O(nω(1+ ρ,1,1+γ)) time. • Hence Dt is computed in O( t n3+ρ-γ) . • We already know that Dt(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] .
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=u0,u1,…,us=v} realizing d1.5t(u,v) where some vertex ui is from B and i (s-t … t). s 0 s-t t u v • 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 Bdeterministically in O(n2.5) time). • Having found a t-bridging set B, we compute a matrix which is (better than) D1.5tas follows:
From distance product to APSP Dt(B) DtT(B) D1.5t • Time: O(n3/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(n3-γ/2+ρ/2)as claimed .