paper_id
stringlengths
9
16
version
stringclasses
26 values
yymm
stringclasses
311 values
created
timestamp[s]
title
stringlengths
6
335
secondary_subfield
sequencelengths
1
8
abstract
stringlengths
25
3.93k
primary_subfield
stringclasses
124 values
field
stringclasses
20 values
fulltext
stringlengths
0
2.84M
1912.03824
1
1912
2019-12-09T02:57:12
Approximating the Determinant of Well-Conditioned Matrices by Shallow Circuits
[ "cs.DS", "cs.CC", "cs.DC" ]
The determinant can be computed by classical circuits of depth $O(\log^2 n)$, and therefore it can also be computed in classical space $O(\log^2 n)$. Recent progress by Ta-Shma [Ta13] implies a method to approximate the determinant of Hermitian matrices with condition number $\kappa$ in quantum space $O(\log n + \log \kappa)$. However, it is not known how to perform the task in less than $O(\log^2 n)$ space using classical resources only. In this work, we show that the condition number of a matrix implies an upper bound on the depth complexity (and therefore also on the space complexity) for this task: the determinant of Hermitian matrices with condition number $\kappa$ can be approximated to inverse polynomial relative error with classical circuits of depth $\tilde O(\log n \cdot \log \kappa)$, and in particular one can approximate the determinant for sufficiently well-conditioned matrices in depth $\tilde{O}(\log n)$. Our algorithm combines Barvinok's recent complex-analytic approach for approximating combinatorial counting problems [Bar16] with the Valiant-Berkowitz-Skyum-Rackoff depth-reduction theorem for low-degree arithmetic circuits [Val83].
cs.DS
cs
Approximating the Determinant of Well-Conditioned Matrices by Shallow Circuits Enric Boix-Adser`a *, Lior Eldar †, Saeed Mehraban ‡ December 10, 2019 Abstract The determinant can be computed by classical circuits of depth O(log2n), and therefore it can also be computed in classical space O(log2n). Recent progress by [24] implies a method to approximate the determinant of Hermitian matrices with condition number κ in quantum space O(logn + logκ). However, it is not known how to perform the task in less than O(log2n) space using classical resources only. In this work, we show that the condition number of a matrix implies an upper bound on the depth complexity (and therefore also on the space com- plexity) for this task: the determinant of Hermitian matrices with condition number κ can be approximated to inverse polynomial relative error with classical circuits of depth O(logn·logκ), and in particular one can approximate the determinant for sufficiently well-conditioned ma- trices in depth O(logn). Our algorithm combines Barvinok's recent complex-analytic approach for approximating combinatorial counting problems [2] with the depth-reduction theorem for low-degree arithmetic circuits [26]. 1 Introduction 1.1 Background 1.1.1 Exact computation of the determinant Computing the determinant of a matrix is arguably one of the most basic operations in nu- merical linear algebra and is ubiquitous in many areas of science and engineering. As such, it has been intensively researched over the years with landmark results that have reduced its complexity, improved its numerical stability and increased its parallelism (see for example a survey at [14]). Today, we know that given an n × n matrix we can compute the determinant in time O(nω) where ω < 2.373 is such that O(nω) is the cost of matrix multiplication [27, 15]. One can also try to parallelize the computation of the determinant using many processors. We know that the computation of the determinant is in NC2 [6] -- that is, it can be computed by circuits of depth O(log2n). While this implies that the determinant is parallelizable, it is a major open question whether or not the determinant can be parallelized even further - namely, for instance, whether the determinant lies in NC1, meaning that it can be computed by circuits of *MIT EECS, [email protected][email protected] ‡IQIM Caltech, [email protected] 1 depth O(log(n)). Letting DET denote the class of problems that are NC1-reducible to computing the determinant of an integer-valued matrix, we know that NC1 ⊆ L ⊆ RL ⊆ NL ⊆ DET ⊆ NC2. [9, 8] In particular, a O(log(n))-depth circuit for the determinant would imply NC1 = L = RL = NL, which would be a major breakthrough in our understanding of space-bounded computation. Furthermore, since the class DET captures many fundamental linear-algebraic tasks such as matrix powering, matrix inversion, and solving systems of linear equations, a faster algorithm for exact computation of the determinant would have far-reaching applications [8]. 1.1.2 Approximate Computation of the Determinant In this paper, instead of exact computation, we consider the problem of approximately comput- ing the determinant up to a (1 + 1/poly(n)) multiplicative factor. The purpose of this section is to provide an overview of known bounds on the complexity of this task prior to this paper. The approximation problem is trivially reducible to DET and hence is contained in NC2. Interestingly, it turns out that merely computing the sign of the determinant is complete for the complexity class probabilistic logspace (PL) [1]. PL is the logspace analog of the class PP, contains NL and is contained in NC2. As a result, similarly to exact computation, providing an L algorithm for determinant approximation would imply surprising statements such as L = NL = PL. Hence, we would like to ask a more fine-grained question: Can the determinant be approximated using small space or depth on special inputs? The answer turns out to concretely depend on the degree to which a matrix is singular. In more precise terms, it depends on condition number of the input matrix, which is the largest-to- smallest singular value ratio of the matrix. Computing the sign of the determinant is complete for PL if the matrix is allowed to be arbitrary, in which case the condition number can be exponentially large. However, a result of Ta-Shma [24] shows that inverting a matrix with polynomially large condition number is contained the complexity class BQL. As we describe in Appendix A, the techniques of Ta-Shma imply that BQL can approximate the determinant for matrices with polynomially large condition numbers. One may conjecture that the determinant approximation problem for polynomially-conditioned matrices is complete for BQL. An item of evidence in favor of this conjecture is a result of Fefferman and Lin [12], who show that inverting polynomially-conditioned matrices is complete for the class BQL.1 If a polynomially-conditioned matrix has certain special structure, then the absolute value of its determinant may be approximable by a weaker classical machine. This follows from an NC1-reduction that we give in Appendix A from approximating the absolute value of the determinant to approximate matrix inversion. Implications of our reduction include: • if A is a poly(n)-conditioned symmetric diagonally dominant (SDD) matrix, then Det(A) = Det(A) can be approximated in near-L, because there is a nearly-logspace SDD solver for A [19]. • if A is a poly(n)-conditioned Hermitian stochastic matrix, then Det(A) can be approx- imated in BPL. This follows by combining the BPL-algorithm of Doron et al. [10] for approximating powers of A with a parallelized version of the gradient descent algorithm for solving Ax = b. • if A is a κ-conditioned matrix, then Det(A) can be approximated in O(log(n) · log(κ)) depth, because equations of the form Ax = b can be solved in O(log(n) · log(κ)) depth using parallelized gradient descent. 1And while it is known that approximate inversion is NC1-reducible to determinant approximation through Cramer's rule, this reduction does not immediately work within the class of well-conditioned matrices considered by Fefferman and Lin. 2 Details on the reduction from approximate calculation of Det(A) to approximate inversion of A are given in Appendix A, but we note that an important barrier to this technique is the computation of the sign of the determinant, even for a Hermitian matrix. It is a priori unclear how to compute the signed determinant Det(A) with a classical algorithm running in space less than log2(n), even if it has condition number κ = O(1). The main contribution of this paper is to surmount this barrier in computing the sign. For example, we show that the signed determinant of polylog(n)-conditioned matrices can be com- puted in nearly-logarithmic depth or nearly-logarithmic space if either the matrices are Her- mitian or Hurwitz stable (Hurwitz stable matrices are defined as those that matrices that have eigenvalues with negative real parts). 1.2 Main Results In this work we improve on prior art by proposing an algorithm for computing the determinant of well-conditioned n × n Hermitian or Hurwitz stable matrices with condition number κ that runs in depth O(log(n) · log(κ)) A matrix is Hurwitz stable if the real parts of its eigenvalues are negative. Theorem 1. (sketch) Let A be an n × n Hermitian or Hurwitz stable matrix with condition number κ. There exists a Boolean circuit for approximating Det(A) to multiplicative error 1 + 1/poly(n) that has O(log(n) · log(κ)) depth. The circuits for this algorithm can be computed by a Turing machine using log(n)-space. A direct corollary is the following: Corollary 2. (sketch) Let A be an n × n Hermitian or Hurwitz stable matrix with condition number κ. There exists an algorithm for approximating Det(A) to multiplicative error 1 + 1/poly(n) that uses O(log(n) · log(κ)) space. 1.3 Proof Overview Our algorithm is inspired by the Taylor-series approach to computing a multiplicative approx- imation of the permanent, pioneered by Barvinok [2]. In this approach, the permanent is re- duced from a degree-n polynomial in its entries to a univariate polynomial as follows: gA(z) = Per((1 − z) · J + z · A), where J is the all ones matrix. The polynomial gA(z) admits a Taylor series decomposition which converges to the true value of the function, and in particular at z = 1 -- namely Per(A) = gA(1) which is our target -- whenever all the roots of gA(z) are bounded away from the unit disk. In order to compute a multiplicative approximation of Per(A), Barvinok considers fA(z) = log(gA(z)) and computes an additive approximation of fA(z) at z = 1 for any matrix A for which the roots of gA(z) are bounded away from the unit disk. For this algorithm, the Taylor series of f (z) needs to contain only O(log(n)) terms in order to provide a 1/poly(n) additive approximation error for log(Per(A)). The algorithm then computes all low-order derivatives of g(z) in time 2O(log2(n)), uses them to compute all low-order derivatives of f (z) at z = 0, and then computes f (1) as a Taylor-series approximation and finally returns ef (1). Barvinok's approach was used in recent years to show a quasi-polynomial-time algorithm for computing the permanent of special cases of matrices [3, 4, 2], and to provide better ap- proximations of partition functions [20, 17, 16, 18, 13]. In particular, authors 2 and 3 of this 3 paper showed how to approximate the permanent of most Gaussian matrices by considering a random ensemble of such matrices with a vanishing, non-zero mean [11]. The determinant is an n-variate polynomial that is very similar to the permanent, at least as a syntactic polynomial, with permutation signs multiplying each monomial. Hence it is natural to consider the determinant as a candidate for applying the Taylor-series approach. However, a polynomial-time algorithm is already known for the determinant and this approach will not do any better. Our goal, instead, is to focus on the depth complexity of the algorithm, which we then use to conclude a space-efficient log-space algorithm for approximating the determinant, by the folklore connection between space and depth complexity. To recap, the main logical steps of the Taylor series meta-algorithm are: 1. Define a polynomial g(z) that interpolates between an easy-to-compute determinant at z = 0 and the determinant of our target matrix A. 2. Choose the polynomial g(z) so that for a large natural class of matrices we have that g(z) satisfies the condition that all its roots are bounded-away from the unit disk. 3. Demonstrate a low-depth algorithm for computing all low-order derivatives of g(z). Notably, the first two steps all appeared in works on the permanent [4, 2, 11]. However, the third step is required for the case of the determinant, where our goal is to construct a low-depth circuit. In this work, we solve these requirements in the following way: 1. We set g(z) = Det((1 − z) · I + z · A). Clearly g(0) = Det(I) which is easy to compute and g(1) = Det(A). 2. The polynomial g(z) is reminiscent of the characteristic function of A χ(A) ≡ Det(λI − A) One can easily check that if A is a Hermitian matrix that is well-conditioned the roots of g(z) are all bounded away from either z = 0 or z = 1, and that they are all real. 3. In order to compute the derivatives of g(z) using shallow circuits we build upon the fact that (contrary to the permanent) we do in fact have a polynomial-time algorithm for the determinant. We use that algorithm, in conjunction with the algorithm for parallelizing computation of low-degree polynomials due to Valiant et al. [26], to show that any order-t derivative of g(z) can be computed by a circuit of depth O(log(n) · log(t)). In order to compute a multiplicative approximation of the determinant of the input matrix, several additional steps must be added that can compute the derivatives of f (z) = logg(z) from those of g(z), and making sure that one can implement the arithmetic circuits for these polyno- mials using Boolean circuits with small overhead (which is one of the reasons that our space is not precisely logarithmic but rather has extra loglog(n) factors.) We summarize the main steps of the parallel algorithm here and refer the reader to section 5 for a detailed description of the computational steps. 1. Input: κ ≤ poly(n), and an n × n Hermitian or Hurwitz stable matrix A such that I/κ (cid:22) A (cid:22) I. 2. Round each entry to O(κlog(n)) bits of precision. 3. Compute the first k = (logn) · (κloglogn)O(loglogκ) derivatives of g(z) = Det((1 − z)I + zA) at z = 0 using a dynamic program that is attached to the Samuelson- Berkowitz algorithm [6, 21]. This dynamic program can be parallelized to depth O(log(n) · log(k)) = O(log(n) · log(κ)) by the algorithm for parallelizing low-degree arithmetic circuits due to Valiant-Skyum-Berkowitz-Rackoff [26]. 4 4. Using Bell polynomials, compute the first k derivatives of f (z) = log(g(z)) at z = 0 as in [2]. Also parallelize this step to depth O(log(n) · log(κ)) using [26]. 5. Use CAC interpolation, introduced in [11], to compute the value of f (1) by con- structing an interpolation path that avoids the roots of g(z) (or poles of f (z)). Again parallelize CAC interpolation to depth O(log(n) · log(κ)) using [26]. 6. Return ef (1). 1.4 Discussion and Future Work Our result implies that the determinant of a large class of matrices, namely polylogarithmically well-conditioned Hermitian or Hurwitz stable matrices, can be approximated to inverse poly- nomial relative error in space which is nearly logarithmic in the matrix size. A natural next step would be to try to extend our algorithm to run in logarithmic space or depth for matrices with polynomial condition number, which could then amount to an NC1 algorithm for "almost" any matrix in the Wigner ensemble [25]. Another direction could be to try to show that approxi- mating the determinants of polynomially-conditioned matrices is BQL-complete, as discussed in Section 1.1.2. We note that proving both the algorithm and the completeness result would imply the de-quantization of BQL. 2 Preliminaries 2.1 Basics Given a complex matrix A ∈ Cn×n, let A† denote its conjugate transpose. A is Hermitian if A = A†, in which case the eigenvalues of A are real. A is positive semi-definite (PSD) if it is Hermitian and has nonnegative eigenvalues. We write A (cid:23) 0 if A is PSD. For Hermitian matri- ces A and B, we write A (cid:23) B if A − B (cid:23) 0, and we note that (cid:23) defines a valid partial ordering. The absolute value of A is defined as A = √A†A. The singular values 0 ≤ sn(A) ≤ ··· ≤ s1(A) of A are the eigenvalues si(A) = λi(A) of A. The spectral norm kAk2, is the maximum sin- gular value s1(A). The max-norm kAkmax = maxi,j Ai,j is the maximum absolute value of an entry in A. Definition 3 (Condition number). The condition number of A is κ(A) := s1(A)/sn(A). In this paper, we will focus on well-conditioned Hermitian and Hurwitz stable matrices that are normalized to have spectral norm at most 1: Definition 4 (Well-conditioned matrices). Let 0 ≤ δ ≤ 1. (1) The class of well-conditioned Hermitian matrices with parameter δ is defined as Hδ = {A ∈ Cn×n : A = A†, δ · I (cid:22) A (cid:22) I}. (2) The class of well-conditioned Hurwitz stable matrices with parameter δ is defined as Sδ = {A ∈ Cn×n : ∀i,ℜ(λi(A)) < 0, δ · I (cid:22) A (cid:22) I}. Note that a matrix A ∈ Hδ ∪ Sδ has condition number κ ≤ 1/δ. One of the main complexity classes discussed in this paper is NC defined as the following. Definition 5 (Nick's class). NC[h(n)] is the class of {0, 1}n → {0, 1}∗ Boolean functions computable by a logspace-uniform family of Boolean circuits, with polynomial size, depth O(h), and fan-in 2. NCi := NC[login]. 5 2.2 Arithmetic circuits Definition 6 (Polynomials). Let g ∈ F[x1, . . . , xN ], be a multivariate polynomial in variables x1, . . . , xN , over field F. The degree of a monomial of g is the total number of variables in the monomial (counting with multiplicity). The total degree of g (deg g) is the maximum degree of a monomial in g. Definition 7 (Arithmetic circuits). An arithmetic circuit is a directed acyclic graph on nodes v1, . . . , vs, called gates. If a node has indegree 0, it is called an input gate, and is labelled with a either a field element in F or a variable in {x1, . . . , xN}. Otherwise v is labelled as either an addition or a multiplication gate. Finally, vs is the "output" gate of the circuit. Each gate v recursively computes a polynomial pv ∈ F[x1, . . . , xN ]. If v is an input gate, then pv is its label. Otherwise, let w1, . . . , wt be the children of v. If v is an addition gate then it computes i=1 pwi. Overall, the i=1 pwi, and if v is a multiplication gate then it computes pv = Qt arithmetic circuit is said to compute the polynomial pvs computed at its output gate. pv = Pt If all gates have indegree 0 or indegree 2, then the circuit is said to have fan-in 2. Except when explicitly stated otherwise, all arithmetic circuits in this paper have fan-in 2. In this paper, we will use two fundamental algorithms from the arithmetic circuit litera- ture. The first algorithm, which can be traced back to Strassen [23], allows us to efficiently convert an arithmetic circuit C computing a polynomial p(x1, . . . , xN , z) ∈ F[x1, . . . , xN , z] into an arithmetic circuit C′ computing the coefficient of zk in p (which itself is a polynomial in F[x1, . . . , xN ]). Formally: Definition 8. For any polynomial g(z, x1, . . . , xN ) ∈ F[z, x1, . . . , xN ] and integer k ≥ 0, let denote the coefficient of zk in g: i.e., [zk]g(z, x1, . . . , xN ) ∈ F[x1, . . . , xN ] g(z, x1, . . . , xN ) = ∞ Xi=0 ([zk]g(z, x1, . . . , xN )) · zk Note that up to a factor of k!, the polynomial [zk]g is the same as the kth partial derivative of g with respect to z, evaluated at z = 0: k! · [zk]g(z, x1, . . . , xN ) = ∂k ∂zk g(z, x1, . . . , xN )z=0. The result that we use is stated below. Lemma 9 (Computing the single-variable derivative of an arithmetic circuit, [23]). Let g(z, x1, . . . , xN ) ∈ F[z, x1, . . . , xN ] be a polynomial computed by a fan-in-2 arithmetic circuit C of height h. Then, for any k ≥ 0, [zk]g(z, x1, . . . , xN ) can be computed by a fan-in-2 arithmetic circuit C′ of size C′ = O(k2 · C) and depth (k + 1)h. Moreover, C′ can be computed from C and k in logarithmic space. Proof. For each node v of the circuit C, let pv(x1, . . . , xN , z) denote the polynomial computed at v. We construct a circuit C′ computing [zk] with a dynamic program based on C: 1. For each gate v of C and each integer 0 ≤ i ≤ k, add a gate (v, i) to C′. We will guarantee (v,i) computed at (v, i) equals [zi]pv(z, x1, . . . , xN ). that the polynomial p′ 2. For each (v, i) such that v is an input gate of C, let (v, i) be an input gate of C′ and label it by p′ (v,i) = [zi]pv ∈ F ∪ {x1, . . . , xN}. 6 3. For each (v, i) such that v is an addition gate of C with inputs w1, w2, let p′ (v,i) = p′ (w1,i) + p′ (w2,i). 4. For each (v, i) such that v is a multiplication gate of C with inputs w1, w2, let p′ Pi j=0 p′ (v,i) = (w2,i−j). This can be implemented by adding at most 2i ≤ 2k intermediate addition and multiplication gates. (w1,j) · p′ By induction on the depth, the polynomial p′ (v,i) computed at each gate (v, i) equals [zi]pv. Let the output gate of C′ be (vs, k), where vs is the output gate of C. Therefore C′ correctly computes [zk]pvs . This entire construction can be implemented in logarithmic space. Finally, C′ = O(k2C) because for each gate v in C at most 2k(k + 1) gates are added in the construction of C′. And C′ has depth (k + 1)h because each gate is replaced with a gadget of height at most k + 1. The second classical result that we require is the depth-reduction theorem of Valiant-Skyum- Berkowitz-Rackoff for fast parallel computation of low-degree polynomials. Informally, this theorem states that if a low-degree polynomial can be computed by a small arithmetic circuit, then it can also be computed in low parallel complexity: Theorem 10 (Depth reduction for arithmetic circuits, [26]). Let g(x1, . . . , xN ) ∈ F[x1, . . . , xN ] be a multivariate polynomial of total degree d computed by a fan-in-2 arithmetic circuit C of size s. Then there is an arithmetic circuit D(C) of size poly(sd) and depth O(logd) that computes g. Moreover, D(C) can be computed from C in logarithmic space, each multiplication gate of D(C) has fan-in 2, and each addition gate of D(C) has fan-in poly(sd). In particular, by replacing each addition gate by a O(log(sd))-depth tree of fan-in 2 addition gates, D(C) can be transformed into a O((logd) · (logs + logd))-depth arithmetic circuit of size poly(sd) and fan-in 2. Let us illustrate this result with an example application to the exact computation of the de- terminant. We know that the determinant Det(A) = Pσ∈Sn Qi∈[n] sgn(σ)Aiσ(i) is a degree-n polynomial in the entries of A, and that it has an arithmetic circuit of size poly(n)2. Therefore, Theorem 10 implies that there is a O(poly(sd)) = O(poly(n))-size and O((logd) · (logsd)) = O((logn)2)-depth arithmetic circuit computing Det(A). This result was mentioned in the intro- duction. An O((logn)2)-depth circuit for the exact computation of Det(A) is not sufficient for our purposes. Recall that our goal is instead to multiplicatively approximate Det(A) using depth O((logn)·(logκ)), which scales with the condition number κ of A. Hence, when A is particularly well-conditioned (e.g., κ = O(polylog(n))), then our circuit will have o((logn)2) depth. At a high level, in order to achieve this result we will also apply Theorem 10. However, instead of applying the theorem directly to Det(A) we will apply it to a poly(n)-size-computable degree- O(poly(κ)) polynomial that approximates Det(A). Assuming without loss of generality that κ = O(poly(n)), this will give a O((logn) · (logκ))-depth arithmetic circuit for the polynomial approximating A. 2.3 From arithmetic circuits to Boolean circuits In this paper we use arithmetic circuits to represent and manipulate low-degree polynomials over C. In order to evaluate low-depth arithmetic circuits, we have to translate them into low- depth Boolean circuits. This takes some care, because, when we convert arithmetic circuits into Boolean circuits, we cannot represent the values computed at each gate up to arbitrary precision. 2For example, this small circuit can be constructed from a division-free variant of Gaussian elimination. 7 Our approach is to Booleanize an arithmetic circuit C on variables x1, . . . , xN by rounding every input to r bits of precision and then replacing each arithmetic operation in the circuit with the corresponding exact Boolean implementation, assuming that the inputs x are such that maxi xi is bounded by some number M . The resulting Boolean circuit is denoted by Br,M (C). In order to ensure that Br,M (C) remains small and low-depth, we have to bound the number of bits used to represent the intermediate values in the computation. In order to ensure that Br,M (C) is accurate, we also have to bound the error incurred by the rounding step. These correctness guarantees are provided by the following lemma: Lemma 11. Let ε > 0, and let C be a circuit over C of depth h, computing a polynomial g(x1, . . . , xN ) of degree d. Suppose that each multiplication gate of C is of fan-in 2, and each addition gate is of fan-in at most m. For technical reasons, suppose that all input gates of C are labelled by a variable in {x1, . . . , xN} (i.e., there are no input gates labelled by a constant in C). If r > (2hd2⌈log(m)⌉ + 1)log2(4N M d/ε), then Br,M (C) is a logspace-uniform Boolean circuit of size poly(Cdhr(logm)log(M )) and depth O(h · log(dhrmM )). Moreover, Br,M (C) computes a function g(x1, . . . , xN ) such that for all a1, . . . , aN ∈ C with maxi xi ≤ M , g(a1, . . . , an) − g(a1, . . . , gn) < ε. Note that Lemma 11 requires that each of the input gates of C be labelled with an input variable: in other words, none of the input gate labels are constants from C. We place this tech- nical restriction so that we can conveniently bound the bit complexity of the values computed by the circuit. This is not an important restriction in our case, because for all of the arithmetic circuits considered in this paper, the degree of the polynomial computed by the circuit does not significantly change if we replace each input gate constant c ∈ C with a variable yc whose value will eventually be hard-coded to c. The proof of Lemma 11 is deferred to Appendix C. 3 Determinants and Complex Polynomials The determinant of an n × n matrix can be computed efficiently by a well-known result of Samuelson and Berkowitz: Theorem 12 (Samuelson-Berkowitz [6, 21]). The determinant of an n × n matrix can be computed by an arithmetic circuit of size poly(n) and fan-in 2. Similarly to the line of work pioneered by Barvinok [2], we analyze this problem using tools for analyzing complex polynomials: Definition 13 (Disks, sleeves and root-free area). For a polynomial g : C → C and S ⊆ C, g is root free inside S if z ∈ S =⇒ g(z) 6= 0. In this work we will use three specific kinds of regions S: 1. Open disk: denote an open disk of radius r ≥ 0 around c ∈ C by D(c, r) = {z ∈ C : z − c < r}. 2. Unit sleeve: The unit sleeve with width δ is denoted with Sδ := {z ∈ C : ℑ(z) < δ and − δ < ℜ(z) < 1 + δ}. 3. Half-plane: The left-hand side of a point x ∈ R is defined as Px := {z ∈ C : ℜ(z) < x}. 3.1 The determinant interpolation polynomial Let gA(z) = Det(I(1 − z) + zA). Therefore gA(0) = 1, gA(1) = Det(A). 8 Lemma 14 (Derivatives of gA). The k-th derivative of gA(z) = Det(I(1 − z) + zA) at z = 0 is a polynomial of degree k in the entries of A. Proof. We use the notation B →k A to denote B is a k × k principal sub-matrix of A. We show that the k-th derivative of gA(z) at z = 0 is g(k)(0) = PB→kA Det(B − I): g(k)(0) = Xσ∈Sn sgn(σ) Xi1<...<ik Yj /∈{i1,...,ik} δj,σ(j) Yj∈{i1,...,ik} (aj,σ(j) − δj,σ(j)) = Xi1<...<ik Xσ∈S{i1,...,ik} = XB→kA Det(B − I). sgn(σ) Yj∈{i1,...,ik} (aj,σ(j) − δj,σ(j)) Each summand Det(B − I) is a polynomial of degree k in the entries of B and hence degree k in the entries of A. Theorem 15 (Roots vs. eigenvalues). Let 0 < δ < 1. (1) (Hermitian) If A ∈ Hδ then gA is root-free inside D(0, 1/2) ∪ D(1, (2) (Hurwitz stable) If A ∈ Sδ then g−A is root-free inside P1/2 ∪ D(1/2, 1/2) ∪ D(1, Proof. Let ω1, . . . , ωn be the eigenvalues of A. Then δ 1+δ ). δ 1+δ ). gA(z) = Det(I(1 − z) + zA) = Yi∈[n] ((1 − z) + zωi). 1−ωi is a root of gA. Also if A has a unit eigenvalue that does not introduce For any ωi 6= 1, zi := 1 a root for gA. (1) First, since −1 ≤ ωi implies that zi ≥ 1/2 this establishes D(0, 1/2) as a root-free disk. 1−δ or ωi ≥ δ which implies ∀i ∈ [n], either zi ≥ 1 (2) When A ∈ Sδ the eigenvalues of −A lie inside Λ = {ω ∈ C : δ ≤ ω ≤ 1,ℜ(ω) > 0}. We 1−ω through the following observations: δ 1+δ ) as a root-free disk. 1+δ . This establishes D(1, Second, δ · I (cid:22) A implies ∀i ∈ [n], zi ≤ 1 compute the image of Λ under the map z = 1 (i) ω ≥ δ ⇔ z − 1 ≥ δ · z ⇒ z − 1 ≥ δ(1 − 1 − z) ⇔ 1 − z ≥ δ 1+δ , (ii) ω ≤ 1 ⇔ z − 1 ≤ z ⇔ ℜ(z) ≥ 1/2, (iii) ℜ(ω) ≥ 0 ⇔ 1 + ω ≥ 1 − ω ⇔ 2z − 1 ≥ 1 ⇔ z − 1/2 ≥ 1/2. Items (i), (ii) and (iii) establish root-freeness inside D(1, spectively. δ 1+δ ), P1/2 and D(1/2, 1/2), re- 4 Computational Analytic-Continuation 4.1 Improved analysis for CAC In [11] a subset of the authors has outlined an algorithmic technique called CAC for interpo- lating the value of a complex function given sufficiently many derivatives at some origin. In this work, we require slightly stronger conditions on the performance of the algorithm so we present a refined analysis thereof. We begin by rewriting the algorithm with slightly modified parameters: 9 Algorithm 16 (Computational analytic continuation). 1. Input: Integer m0 ≥ 1. An oracle Og that takes a number m0 as input and outputs the first m0 derivatives of g at z = 0, where g(0) = 1. t complex numbers ∆1, . . . , ∆t. A number 0 < θ ≤ 1. 2. Fixed parameters: j=1 ∆j for each 1 ≤ i ≤ t 3. Variables: (a) s0 = 0 and si = s0 +Pi (a) mi for 0 ≤ i ≤ t (b) f (l) i for 0 ≤ l ≤ mi and 0 ≤ i ≤ t 4. Main: % the number of derivatives at each point si. % the l'th derivative of f at si. (a) Query Og(m0) to obtain g(0)(0), . . . , g(m0)(0) (b) Using derivatives from step 4a compute f (l) (c) For each i = 0, . . . , t − 1: 0 ← f (l)(s0) for 1 ≤ l ≤ m. • Set: mi+1 = ⌈θmi/(2log mi)⌉. f (l) • Compute ∀0 ≤ l ≤ mi+1, i+1 = Pmi−l p=0 f (p+l) i p! ∆p i . 5. Output: Let f := f (0) t and return O = e f . Lemma 17 (Correctness of algorithm 16). Let g(z) be a polynomial of degree at most n such that g(0) = 1, and let f (z) = log(g(z)). Suppose the inputs to algorithm 16 satisfy the following conditions: 1. Non-increasing sequence of segments: ∆i ≤ ∆i−1 for all i ≥ 1. 2. Root avoidance: For each i the ratio between the distance from the closest root of g(z) to si and the step size ∆i+1 is at least β = eθ for 0 < θ ≤ 1. Then, for small enough ε > 0, letting m0 ≥ 10 (log(n/εθ)) (10t(logt + loglog(n/εθ)))t , (1) Algorithm 16 outputs an ε-additive approximation to f (st). Prior to establishing the correctness of the algorithm, we define shifted versions of g(z) as follows: and ∀i ∈ [t] gi(z) = g(z + si), fi(z) = log(gi(z)), (2) (3) and denote f (l) proof: i = f (l) i (0). We need the following elementary fact, which we leave without Lemma 18. If the closest root of g to the point si in the complex plane is λ, then the closest root of gi to z = 0 is also λ. We now prove correctness of the algorithm: 10 Proof of Lemma 17. Let f (z) := log(g(z)). It is sufficient to show that (cid:12)(cid:12)(cid:12) f − f (st)(cid:12)(cid:12)(cid:12) ≤ ε Let f (k) i denote the approximation of the k'th derivative of f at point si obtained by the algorithm. Using oracle Og for 0 ≤ l ≤ m0 we can compute precisely the derivatives of g at s0 = 0 and using Lemma 19 (whose statement and proof we momentarily defer) we can compute the derivatives of f precisely at s0: For i = 1, . . . , t (in order) algorithm 16 computes the lowest mi derivatives at si using the first mi−1 derivatives at si−1 as follows: f (l) 0 ← f (l)(s0). (5) ∀0 ≤ l ≤ mi, f (l) i = mi−1−l Xp=0 f (p+l) i−1 p! ∆p i . (6) By assumption 2 and Lemma 18 for each 1 ≤ i ≤ t the function fi−1 is analytical about point 0 in a disk of radius β∆i. Hence, we can write the ℓ-th derivative of fi(z) as the infinite Taylor-series expansion of the ℓ-th derivative of fi−1(z) evaluated at point ∆i: f (ℓ) i := f (l) i (0) = ∞ Xp=0 f (p+l) i−1 (0) p! ∆p i . (7) i denote the additive approximation error of the l-th derivative at step i ∈ [t] and 0 ≤ Let E (l) l ≤ mi. (4) (8) (10) (11) (12) Using the triangle inequality to bound the difference between equations (6) and (7), we get: i − f (l) f (l) i E (l) i := (cid:12)(cid:12)(cid:12) ∀0 ≤ l ≤ mi , (cid:12)(cid:12)(cid:12) i−1 − f (p+l) f (p+l) i−1 p! ∀i ∈ [t], 0 ≤ l ≤ mi, E (l) i ≤ = =: mi−1−l Xp=0 mi−1−l Xp=0 mi−1−l Xp=0 E (p+l) i−1 p! E (p+l) i−1 p! ∆ip + κi,l, f (p+l) i−1 p! ∆ip, (9) ∆ip + ∞ ∞ Xp=mi−1−l+1 f (l+p) i−1 p! ∆ip, ∆ip + Xp=mi−1−l+1 where κi,l := ∞ Xp=mi−1−l+1 f (p+l) i−1 p! ∞ ∆ip = Xp=mi−1−l+1 f (p+l) i−1 (0) p! ∆ip. At this point, we focus on placing an upper bound on κi,l. Fix any index i and let z1, . . . , zn be the roots of the shifted function gi−1. Then gi−1(z) = gi−1(0)(cid:18)1 − z z1(cid:19) . . .(cid:18)1 − z zn(cid:19) . (13) 11 We can write the derivatives of fi−1(z) = log(gi−1(z)) in terms of z1, . . . , zn: ∀k > 0, f (k) i−1(0) = − n Xj=1 (k − 1)! zk j . (14) Using these derivatives and the triangle inequality we can bound equation (12) for all 0 ≤ l ≤ mi, κi,l ≤ n ∞ n ∞ Xp=mi−1−l+1 Xj=1 Xj=1 Xp=mi−1−l+1 Xp=mi−1−l+1 ∞ ≤ e · ≤ ≤ ≤ en ∆il en ∆il ( ∆il ( en (l + p − 1)! p! ∆ip zjp+l (p/e)l( l + p p )p+l ∆ip zjp+l (p/e)l( )p+l 1 βp+l l + p p ∞ mi−1 + 1 mi−1 − l + 1 mi−1 + 1 mi−1 − l + 1 )l )l Xp=mi−1−l+1 Xp=mi−1−l+1 ∞ (1 + l/p)p(p/e)l 1 βp+l pl 1 βp+l (15) using Lemma 31 (16) (17) (18) (19) In order to bound this quantity, we prove a lower-bound on mi for all 0 ≤ i ≤ t. Since the update rule for mi is mi+1 = ⌈θmi/(2logmi)⌉, and x/log(x) is increasing for x > 10, in order to prove the lower bound on mi we can without loss of generality assume m0 = ⌈10 (log(n/εθ)) (10t(logt + loglog(n/εθ)))t⌉. The following facts immediately follow. For all 0 ≤ i < t, log(mi) ≤ log(m0) ≤ log(11) + loglog(n/εθ) + tlog(10t) + tlogloglog(n/εθ) + tloglog(t) ≤ 2tlog(t) + 2tloglog(n/εθ), , and therefore for all 0 ≤ i ≤ t mi ≥ 10(log(n/εθ))(10t(logt + loglog(n/εθ)))t−i5i and in particular So mi ≥ 10(log(n/εθ)) · 5t ≥ 10(t + log(n/εθ)). mi−1 = 2milog(mi−1)/θ by construction ≥ (milog(mi−1) + mi)/θ ≥ (milog(mi−1) + 10t + 10log(n/εθ))/θ ≥ (milog(mi−1) + log(e3net/εθ))/θ using (25) (20) (21) (22) (23) (24) (25) (26) (27) (28) (29) Also, by the lower bound (25) on mi−1 the algorithm chooses mi−1 ≥ 3mi/θ ≥ mi·(1+2/θ), (30) so since l ≤ mi it follows that mi−1 − l + 1 > 2l/θ. 12 Therefore we may apply the bound of technical lemma 32 to (19), mi−1 + 1 mi−1 − l + 1 )l (mi−1 + 1)l (mi−1 − l + 1)l βmi−1+1(1 − β−1el/(mi−1−l+1)) κi,l ≤ ≤ ≤ ≤ ≤ ≤ en ∆il ( en ∆il e2n θ∆il e2n θ∆il e3n θ∆il εe−t ∆il βmi−1+1(1 − β−1/2) (mi−1 + 1)l eθmi−1 (mi−1 + 1)mi eθmi−1 (mi−1)mi eθmi−1 using Lemma 32 (31) using (30) (32) using β = eθ, 0 < θ ≤ 1 using l ≤ mi using mi ≤ mi−1/3 (33) (34) (35) using (29) (36) (38) (39) (40) We now complete the error analysis in Equation (11). Using the above equation E (l) i ≤ Xp=0 i = E (l) We do the change of variable F (l) ( ∆i ∆i−1 F (l) i ≤ F (p+l) Xp=0 i−1 p! mi−1−l )p+l + εe−t mi−1−l E (p+l) i−1 p! ∆ip + εe−t ∆il . (37) · ∆il. Using this notation this bound becomes i mi−1−l ≤ Xp=0 F (p+l) i−1 p! + εe−t using ∆i ≤ ∆i−1 Now define Fi = maxl F (l) i . From the above, Fi ≤ e · Fi−1 + εe−t. The boundary condition is F0 = 0 since the derivatives are computed exactly at the first e−1 · εe−t. We conclude segment. Using (40), by induction on i ∈ [t] one can show that Fi ≤ ei−1 that the output additive error is E (0) t ≤ Ft ≤ ε · e−t · et = ε. · ∆t0 = F (0) t = F (0) t 4.2 Shallow Circuits for CAC In this section we establish that in fact Algorithm 16 can be computed by shallow circuits. To do that, we first note that the k lowest derivatives of log(g(z)) can be computed efficiently from the lowest k derivatives of g(z): Lemma 19. Let g(z) be an analytic function that is root-free in an open set U containing 0, and let g(0) = 1. Let f (z) = log(g(z)). Then for each k > 0, there is an arithmetic circuit of fan-in 2 that receives as input the first k derivatives of g at 0, and computes f (k)(0). Moreover, the circuit is of size poly(k), logspace-uniform, and computes a poly- nomial of degree k. g(0)(0), . . . , g(k)(0), 13 Proof. The Bruno di Fa`a formula, which generalizes the chain rule to higher-order derivatives, states that given a composition of two functions f (z) = h(g(z)), the derivative f (k)(0) depends only on the first k derivatives of h at z = g(0) = 1 and g at z = 0. In particular, we may define and h(z) = log(z), h(z) = k Xi=1 (−1)i+1 i · (z − 1)i g(z) = 1 + k Xi=1 g(i)(0) i! · zi, and by Bruno di Fa`a, f (z) = h(g(z)) will have the same kth derivative as f (z) = h(g(z)): f (k)(0) = f (k)(0). Since f (z) has a size-O(k2) logspace-uniform arithmetic circuit in g(0)(0), . . . , g(k)(0), z, it follows by the derivative calculation lemma (Lemma 9) that f (k)(0) = f (k)(0) has a size-poly(k) logspace-uniform arithmetic circuit in g(0)(0), . . . , g(k)(0). Moreover, f (k)(0) is clearly of degree at most k in g(0)(0), . . . , g(k)(0). We now use this lemma to establish that CAC can be computed by small circuits of low degree: Lemma 20 (Low-degree circuits for CAC). Under the conditions of Lemma 17, Algorithm 16 can be implemented by a logspace-uniform arithmetic circuit of size poly(m0) that computes a polynomial of degree O(m2 0) in g(0)(0), . . . , g(m0)(0), ∆1, . . . , ∆t. Proof. Construct arithmetic circuits for f (0)(0), . . . , f (m0)(0), the first m0 derivatives of f at 0, using the procedure from Lemma 19. These circuits are logspace-uniform, and are of size at most poly(m0) and degree at most m0. For each 0 ≤ i ≤ t and 0 ≤ j ≤ mi, construct a size-(1 + 10im3 0) arithmetic circuit computing , with degree at most m0 − j + 1 in the variables f (0)(0), . . . , f (m0)(0), ∆1, . . . , ∆k. This 0 = f (j)(0). using step 4c i 0 gates. Moreover + p ≤ (m0 − (p + j) + 1 + p) = m0 − j + 1 by the f (j) i construction is performed inductively on i. The base case i = 0 is clear because f (j) For the inductive step, f (0) i of Algorithm 16, which can be implemented at an extra cost of 10m3 each f (j) inductive hypothesis. i+1 has degree max0≤p≤mi−j deg f (p+j) can all be computed from f (0) i+1, . . . , f (mi+1) i+1 i ≤ 10m3 , . . . , f (mi) i Let C′′ be the degree-(m0 + 1), size-(1 + 10tm3 0) circuit computing f (0) t in terms of f (0)(0), . . . , f (m0)(0), and ∆1, . . . , ∆t. Compose C′ with the degree-m0, size-poly(m0) circuits computing f (0)(0), . . . , f (m0)(0) in terms of g(0)(0), . . . , g(m0)(0) in order to obtain a degree-O(m2 0) size-poly(t, m0) = poly(m0) circuit C′ computing f (0) in terms of g(0)(0), . . . , g(m0)(0), ∆1, . . . , ∆t. t Combining Lemma 20 with Theorem 10 (the depth-reduction theorem for arithmetic cir- cuits) implies that the CAC algorithm can be computed by arithmetic circuits of poly(m0) size, fan-in 2, and depth O((logm0)2). We will use this observation in the proof of the main theorem. 14 5 Main results 5.1 Theorem Statement Our main theorem is that for O(κ)-conditioned Hermitian or Hurwitz stable matrices one can compute a 1 + 1/poly(n) approximation to the determinant using an arithmetic circuit of depth O(log(κ)· log(n)). Furthermore, this circuit can be implemented as a logspace-uniform Boolean circuit of polynomial size and O(log(κ) · log(n)) depth as well as O(log(κ) · log(n)) space: Theorem 21 (Approximation of the determinant of Hδ and Sδ matrices in near-NC1). For every n and ε, δ > 0 there exists a logspace-uniform Boolean circuit of size poly(n) and depth O((logn) · (log(1/δ) + loglog(1/ε))) such that for every input A ∈ Hδ it approximates Det(A) to multiplicative error 1 + ε. In particular, for δ = 1/polylog(n), this circuit can be implemented in depth O(log(n)). The same result holds for Sδ in place of Hδ. A direct corollary of Theorem 21 is the following: Corollary 22 (Approximation of the determinant of Hδ and Sδ matrices in near-L). For every n and ε, δ > 0, and A ∈ Hδ, there is a O((logn) · (log(1/δ) + loglog(1/ε))-depth algorithm that approximates Det(A) to multiplicative error 1 + ε. The same result holds for Sδ in place of Hδ. 5.2 CAC interpolation points Recall the definition of the determinant interpolation polynomial gA(z) = Det((1 − z)I + zA). The proof of Theorem 21 will proceed by using Computational Anaytic Continuation (CAC) to approximate the value of gA(1) = Det(A) from the low-order derivatives of gA(z) at z = 0. Lemma 23 (Interpolating segments for well-conditioned Hermitian matrices). Let δ > 0, let A ∈ Hδ, and let gA(z) = Det((1 − z)I + zA). Then there exist t + 1 = O(log(1/δ)) CAC points s0, . . . , st ∈ C satisfying the conditions of Lemma 17 with respect to gA, with parameter θ > 0.4. Proof. Since A is Hermitian, the roots of gA(z) for A ∈ Hδ all lie on the real line. And by δ Theorem 15 we have that gA(z) is root-free in D(0, 1/2) ∪ D(1, 1+δ ). Consider CAC segments of 2 types: 1. Cross over: We cross from 0 to 1 + i/2 above the real line using 6 segments: s0 = 0 → s1 = 0.25i → s2 = 0.5i → s3 = 0.5i + 0.25 → s4 = 0.5i + 0.5 → s5 = 0.5i + 0.75 → s6 = 0.5i + 1 2. Decelerate: We shuttle down from s6 = 1 + i/2 to st = 1 via a sequence of O(log1/δ) decreasing intervals. As we shuttle down, we reduce the interpolation disk radius on each step by a constant multiplicative factor. Let t = log3(1/δ) + O(1), r0 = 1/3 and b = 3. We navigate s6 = 1 + i/2 → s7 = s6 − ir0 → s8 = s7 − ir0/b → . . . → st−1 = st−2 − r0/bt−8. More formally, for 6 ≤ j ≤ t − 1, we have sj = 1 + i/2 − i At the end, move one more step from st−1 to st = 1. Note that in order to do this and still satisfy the CAC requirements we use 0 ≤ ℑ(st−1) ≤ δ/5. 2 (1 − (1/3)j−6) 15 We note that for each j the polynomial is root-free in the disk D(sj , (3/2) · sj+1 − sj). In particular, for j ≥ 6 we have sj+1 − sj = (1/3)j−5, but the closest root to si is on the real line, at least (3/2)(1/3)j−5 distance away. For the segment from st−1 = 1 − icδ (for 0 ≤ c ≤ 1/5) to st = 1, we use that gA is root-free in D(1, 9δ/10) Since log(3/2) > 0.4, the bound on θ holds. Also, the segments are of non-increasing length and gA(0) = 1, satisfying the other conditions of Lemma 17. Lemma 24 (Interpolating segments for well-conditioned Hurwitz stable matrices). Let δ > 0, let A ∈ Sδ, and let g−A(z) = Det((1 − z)I − zA). Then there exist t + 1 = O(log(1/δ)) CAC points s0, . . . , st ∈ C satisfying the conditions of Lemma 17 with respect to g−A, with parameter θ > 0.4. Proof. The proof is very similar to the proof of Lemma 23 we just presented. We first move to z = 1/2. This is doable because P1/2 = {x : ℜ(x) < 1/2} and D(1/2, 1/2) are root free by Theorem 15. Then, since D(1/2, 1/2) and D(1, δ/(1 + δ)) are root free, we take a sequence of decelerating segments from z = 0 to z = 1/2 with lengths shrinking by a constant factor at each step. Here is a way of doing this. Pick t = log3(1/δ) + O(1): s0 = 0 → s1 = 1/6 → s2 = 1/3 → s3 = 1/2 → s4 = 1/2 + 1/6 → s5 = 1/2 + 1/3 → s6 = 1/2 + 1/3 + 1/32 → ··· → st−1 = 1/2 + 1/3 + . . . + 1/3t−5 ≥ 1 − δ/5 → st = 1. More formally, for 5 ≤ j ≤ t − 1, we have sj = 1/2 + 1 We note that for each j the polynomial is root-free in the disk D(sj, (3/2) · sj+1 − sj). In particular, for j ≥ 5 we have sj+1 − sj = (1/3)j−5, but the closest root to si lies outside D(1/2, 1/2), at least (3/2)(1/3)j−5 distance away. For the segment from st−1 ≥ 1− δ/5 to st = 1 we use that gA is root-free in D(1, 9δ/10). Since log(3/2) > 0.4, the bound on θ holds. Also, the segments are of non-increasing length and g−A(0) = 1, satisfying the other conditions of Lemma 17. 2 (1 − (1/3)j−4). 5.3 Proof of Theorem 21 Consider the following algorithm Algorithm 25. 1. Input: δ > 0, matrix A ∈ Hδ or A ∈ Sδ. 2. Fixed parameters: (a) θ = 0.4 % parameter in the CAC algorithm (b) t = O(log(1/δ)) % number of CAC segments from z = 0 to z = 1 (c) k = ⌈40 (log(n/εθ)) (40t(logt + loglog(n/εθ)))t⌉ % number of derivatives CAC uses (d) r = k14 % number of bits to which to round A (e) M = k! % size of the maximum constant used in the arithmetic circuits 3. Main (for Hermitian A ∈ Hδ): (a) If k ≥ n, return the NC2-circuit exactly computing the determinant. Otherwise perform (b) Construct CSB, the Samuelson-Berkowitz circuit (Theorem 12) computing the following steps: gA(z) = Det((1 − z) · I + z · A). 16 (c) For each 0 ≤ i ≤ k construct Ci = Hi(CSB), the arithmetic circuit computing the derivative g(i) A (0) (using Lemma 9). (d) Construct the circuit CCAC = CCAC(C0, . . . , Ck, ∆1, . . . , ∆t) doing Computational Analytic Continuation from z = 0 to z = 1 as in Algorithm 16 with steps ∆1, . . . , ∆t, parameter θ and using the first m0 := k derivatives of gA at z = 0. (Lemma 20) (e) Reduce the depth of the CAC circuit Clow-depth = D(CCAC ). (Theorem 10) (f) Hard-code ∆1, . . . , ∆t to get the CAC points from Lemma 23. (g) Compute the Booleanization of the circuit Cbool = Br,M (Clow-depth). (Lemma 11) (h) Return the Boolean circuit Cout = exp(Cbool). 4. Main (for Hurwitz stable A ∈ Sδ): The algorithm is essentially the same if A ∈ Sδ, but we use g−A(z) instead of gA(z), the interpolating segments are given by Lemma 24 instead of Lemma 23, and we return (−1)n · exp(Cbool) instead of exp(Cbool), because g−A(1) = Det(−A) = (−1)nDet(A). In order to prove correctness of Algorithm 25, we first prove the following technical lemma: Lemma 26 (Clow-depth has low depth). If k < n, then Clow-depth has size poly(n), degree O(k3), and depth O(logk). Each multiplication gate has fan-in 2 and each addition gate has fan-in at most poly(n). Proof. The Samuelson-Berkowitz circuit CSB constructed using Theorem 12 is an arithmetic circuit of size poly(n). By Lemma 9, for all 0 ≤ i ≤ k the circuit Ci is of size poly(n). Since Ci computes the derivative of order i ≤ n w.r.t. the variable z of gA(z) at z = 0, Ci has degree O(k) in the entries of A, by Lemma 14. Therefore, by Lemma 20, CCAC is of size poly(n) and has degree O(k3) in the entries of A and in ∆1, . . . , ∆t. It follows by Theorem 10 (depth-reduction) that Clow-depth is of size poly(nk) = poly(n) and of depth O(logk), and that each multiplication gate has fan-in 2 and each addition gate has fan-in poly(n). Lemma 27 (The circuit outputted by Algorithm 25 approximates the determinant of A). Algo- rithm 25 computes a circuit Cout that satisfies: Cout(A) = Det(A) · (1 + E), E ≤ ε Proof. If k ≥ n, then the algorithm computes the determinant exactly. Otherwise, by the error bound for CAC in Lemma 17, CCAC outputs an ε/4 additive approximation to log(Det(A)) when the CAC segments from Lemma 23 (respectively, Lemma 24) are hard-coded. Applying depth reduction (Theorem 10) does not change the output of CCAC, and therefore Clow-depth also computes an ε/4 additive approximation. We note that the constants used in the arithmetic circuit all have magnitude at most k! = M (the largest constants are in the calculations of the derivatives by Lemma 9), and the input variables have magnitude ≤ 1. And by Lemma 26, Clow-depth is of size poly(n), degree O(k3), depth O(logk), has multiplication gates with fan-in 2, and addition gates with fan-in at most n. These are the preconditions to apply the Booleanization procedure (Lemma 11). Since r = k14 ≥ k10· (logn/ε)2log(k!) = ω(k9log(k)log(n) + 1)log(nk/ε)(logM )), by the error bound in Lemma 11 we may conclude that the Booleanization procedure yields a Boolean circuit Cbool that approximates CCAC up to additive ε/4 error when the CAC points s1, . . . , st are hard- coded. Hence overall Cout is a exp(ε/2) relative-error approximation of Det(A). 17 Lemma 28. Algorithm 25 computes a poly(n)-size Boolean circuit of depth O(log(n) · (log(1/δ) + loglog(1/ε))). Proof. If k ≥ n, then the algorithm returns a size-poly(n), depth-O((logn)2) circuit. In this case, log(k) ≥ log(n), so tlog(t) + loglog(1/ε) = Ω(log(n)), and since t = Θ(log(1/δ)), the claim holds in this case. In the case k < n, we also have δ > 1/n. By Lemma 26 and Lemma 11, we have that Cbool is a circuit of size poly(nrk(logk)(logk!)) = poly(n) and depth O((logk) · log(k(logk)rn)) = O((logn)·(logk)) = O((logn)·(tlog(t)+loglog(n)+loglog(ε))) = O((logn)·(log(1/δ)+loglog(1/ε))). The final exponentiation operation is applied to a poly(log(n/ε)/δ)-bit number, and by the results of [5, 7] it can be implemented by a logspace-uniform poly(n)-size circuit of depth O(log(1/δ) + loglog(n/ε)) depth, which is negligible overhead. Lemma 29. The circuit Cout can be computed by Algorithm 25 in space O(log(n)). Proof. This follows from the fact that all of the operations involved can be done in logspace: computing CBS (Theorem 12), taking derivatives (Lemma 9), CAC interpolation (Lemma 17), Booleanization (Lemma 11), and, by [5, 7], taking the exponential. Theorem 21 follows from Lemmas 27, 28, and 29. References [1] E. Allender and M. Ogihara. Relationships among PL, sharp-L, and the determinant. RAIRO-Theoretical Informatics and Applications, 30(1):1 -- 21, 1996. [2] A. Barvinok. Approximating permanents and hafnians. Journal of Discrete Analysis. [3] A. Barvinok. Computing the partition function for cliques in a graph. Theory of Computing, 11(13):339 -- 355, 2015. [4] A. Barvinok. Computing the permanent of (some) complex matrices. Foundations of Com- putational Mathematics, 16(2):329 -- 342, Apr 2016. [5] P. W. Beame, S. A. Cook, and H. J. Hoover. Log depth circuits for division and related problems. SIAM Journal on Computing, 15(4):994 -- 1003, 1986. [6] S. J. Berkowitz. On computing the determinant in small parallel time using a small num- ber of processors. Information processing letters, 18(3):147 -- 150, 1984. [7] A. Chiu, G. Davida, and B. Litow. Division in logspace-uniform nc. RAIRO-Theoretical Informatics and Applications, 35(3):259 -- 275, 2001. [8] S. A. Cook. A taxonomy of problems with fast parallel algorithms. Information and control, 64(1-3):2 -- 22, 1985. [9] L. Csanky. Fast parallel matrix inversion algorithms. pages 11 -- 12, 1975. [10] D. Doron, A. Sarid, and A. Ta-Shma. On approximating the eigenvalues of stochastic matrices in probabilistic logspace. computational complexity, 26(2):393 -- 420, 2017. [11] L. Eldar and S. Mehraban. Approximating the permanent of a random matrix with van- ishing mean. In 59th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2018, Paris, France, October 7-9, 2018, pages 23 -- 34, 2018. [12] B. Fefferman and C. Y.-Y. Lin. A complete characterization of unitary quantum space. arXiv preprint arXiv:1604.01384, 2016. 18 [13] A. Harrow, S. Mehraban, and M. Soleimanifar. Classical algorithms, correlation decay, and complex zeros of partition functions of quantum many-body systems. arXiv preprint arXiv:1910.09071, 2019. [14] E. Kaltofen and G. Villard. Computing the sign or the value of the determinant of an Journal of Computational and Applied Mathematics, integer matrix, a complexity survey. 162(1):133 -- 146, 2004. Proceedings of the International Conference on Linear Algebra and Arithmetic 2001. [15] F. Le Gall. Powers of tensors and fast matrix multiplication. In Proceedings of the 39th international symposium on symbolic and algebraic computation, pages 296 -- 303. ACM, 2014. [16] J. Liu, A. Sinclair, and P. Srivastava. Fisher zeros and correlation decay in the Ising model. Journal of Mathematical Physics, 60(10):103304, 2019. [17] J. Liu, A. Sinclair, and P. Srivastava. The Ising partition function: Zeros and deterministic approximation. Journal of Statistical Physics, 174(2):287 -- 315, 2019. [18] R. L. Mann and M. J. Bremner. Approximation algorithms for complex-valued Ising mod- els on bounded degree graphs. Quantum, 3:162, 2019. [19] J. Murtagh, O. Reingold, A. Sidford, and S. Vadhan. Derandomization beyond connectiv- ity: Undirected Laplacian systems in nearly logarithmic space. In 2017 IEEE 58th Annual Symposium on Foundations of Computer Science (FOCS), pages 801 -- 812. IEEE, 2017. [20] V. Patel and G. Regts. Deterministic polynomial-time approximation algorithms for parti- tion functions and graph polynomials. SIAM Journal on Computing, 46(6):1893 -- 1919, 2017. [21] P. A. Samuelson. A method of determining explicitly the coefficients of the characteristic equation. The Annals of Mathematical Statistics, 13(4):424 -- 429, 1942. [22] J. R. Shewchuk. An introduction to the conjugate gradient method without the agonizing pain, 1994. [23] V. Strassen. Vermeidung von divisionen. Journal f ur die reine und angewandte Mathematik, 264:184 -- 202, 1973. [24] A. Ta-Shma. Inverting well conditioned matrices in quantum logspace. In Proceedings of the Forty-fifth Annual ACM Symposium on Theory of Computing, STOC '13, pages 881 -- 890, New York, NY, USA, 2013. ACM. [25] T. Tao and V. Vu. Random matrices: the universality phenomenon for Wigner ensembles. Modern aspects of random matrix theory, 72:121 -- 172, 2012. [26] L. Valiant, S. Skyum, S. Berkowitz, and C. Rackoff. Fast parallel computation of polyno- mials using few processors. SIAM Journal on Computing, 12(4):641 -- 644, 1983. [27] V. V. Williams. Multiplying matrices faster than Coppersmith-Winograd. In STOC, vol- ume 12, pages 887 -- 898. Citeseer, 2012. A Reduction from approximating Det(A) to approximate lin- ear system solving In this section, we prove a near-NC1 reduction for approximating Det(A) based on approx- imately solving linear systems. Some implications of this reduction were mentioned in the introduction, but we go into more detail here. In contrast to the main result of this paper, this reduction does not recover the sign of Det(A). The reduction from approximating Det(A) to approximately solving linear systems is based on the following proposition: 19 Proposition 30. Let 0 ≺ A (cid:22) I be a positive definite n × n matrix. Let A(1), . . . , A(n) denote the principal submatrices of A: i.e., A(i) is the i × i submatrix consisting of the first i rows and columns of A. Finally let v1, . . . , vn be approximations to eT i (A(i))−1ei such that for each i, Then, for small enough ε > 0, Qn i (A(i+1))−1ei ≤ ε/(2n). vi − eT i=1 vi is a (1 + ε)-multiplicative approximation to Det(A). Proof. By Cauchy's interlacing theorem, A(1), . . . , A(n) have eigenvalues between λn(A) > 0 and λ1(A) ≤ 1. In particular, A(1), . . . , A(n) are non-singular, so we can write the telescoping product Det(A) = Det(A(n)) = A1,1 · Det(A(n)) Det(A(1)) n−1 = A1,1 · Yi=1 Det(A(i+1)) Det(A(i)) = n Yi=1 1 eT i (A(i))−1ei , where the last equality is by Cramer's rule. For each i the eigenvalues A(i) lie in of (A(i))−1 i (A(i))−1ei ≥ 1, so vi is a (1 − ε/2n)- lie in [1,∞), by the Courant-Fischer min-max principle eT multiplicative approximation of eT i (A(i))−1ei. This concludes the proof. Suppose we are given a positive definite matrix A and an algorithm that approximately solves systems of equations when the coefficient matrices are A(1), . . . , A(n), the principal sub- matrices of A. Then by Proposition 30 we can approximate eT i (A(i))−1ei in parallel for all i ∈ [n], and multiply them together to approximate Det(A) with only near-NC1 overall over- head. A.1 Example applications of Proposition 30 We now review certain structured classes of well-conditioned matrices for which one can solve these systems of equations in low complexity: Symmetric Diagonally Dominant (SDD) [19] gives a nearly-logspace solver for Sym- metric Diagonally Dominant (SDD) matrices, a subclass of PSD matrices. If A is SDD, then so are A(1), . . . , A(n). Therefore, if A is a poly(n)-conditioned symmetric diagonally dominant (SDD) matrix, Proposition 30 implies that Det(A) can be approximated in nearly-logspace. Since A is PSD, in fact Det(A) = Det(A) in this case. Well-conditioned A is a κ-conditioned matrix, then B = A†A is PSD and κ2-conditioned. Moreover, by Cauchy's interlacing theorem, B(1), . . . , B(n) are also PSD and κ2-conditioned. It suffices to show how to efficiently solve systems of linear equations with κ2-conditioned PSD coefficient matrices. In general, given a κ2-conditioned PSD matrix B, then systems of equations Bx = b can be approximately solved using gradient descent by outputting the approximation x = Pk−1 i=0 α(1− αA)ib, where α = 1/κ2 [22]. By repeated squaring, x can be computed with a circuit of depth O((logn) · (logκ)). So, using Proposition 30, Det(B) = Det(A)2 can be approximated in O((logn) · (logκ)) depth, and therefore so can Det(A). 20 Hermitian stochastic If A is a poly(n)-conditioned Hermitian stochastic matrix, then B = A†A is PSD and stochastic. Moreover, we have kB(i)k∞ ≤ 1 for all i ∈ [n]. (Here kBk∞ = maxiPn j=1 Bij.) For such PSD matrices B with kBk∞ ≤ 1 the powers Bk for k = poly(n) can be approximated in BPL [10]. Therefore the gradient descent algorithm for solving Bx = b can be run in BPL. Hence by Proposition 30, Det(B) = Det(A)2 can be approximated in BPL, and therefore so can Det(A). A.2 Quantum algorithm We also mention a quantum algorithm that outperforms the above classical algorithms for the case of Hermitian well-conditioned matrices: Hermitian well-conditioned (quantum algorithm) In [24], an algorithm for approxi- mating the spectrum of κ-conditioned Hermitian matrices is given that runs in quantum space O(log(n) + log(κ)). In this case, the guarantee of the approximation is strong enough that sim- ply multiplying the approximate eigenvalues gives a (1 + 1/poly(n)) approximation to Det(A) in quantum space O(log(n) + log(κ)). B Technical Estimates Lemma 31. For any l, p ∈ Z>0, (l + p − 1)! p! ≤ e · (p/e)l( p + l p )p+l Proof. (l + p − 1)! p! ≤ (l + p − 1)l+p el+p−2 (l + p − 1)l+p 1 p! · ep−1 pp · ≤ ≤ e · (p/e)l( el+p−2 p + l )p+l p Lemma 32. For all β > 1 and m > l/logβ ∞ Xk=m β−k · kl ≤ mlβ−m · Proof. Let ak = β−k · kl. For k ≥ m we have ak+1 ak using n! ≤ using n! ≥ nn+1 en−1 nn en−1 1 (41) (42) (43) (44) 1 − β−1 · el/m = 1 β (1 + 1/k)l ≤ 1 1 β el/m =: α. Therefore, ∞ Xk=m β−k · kl ≤ am · ∞ Xk=0 αk ≤ mlβ−m · 1 − β−1 · el/m . 21 C Booleanization details Recall that given an arithmetic circuit C over C on variables x1, . . . , xN , the Booleanization Br,M (C) is the Boolean circuit constructed by assuming that all inputs x1, . . . , xN have magni- tude xi ≤ M , and rounding them to r bits of precision using the operation:3 Rr(z) := ⌊2r · z⌋/2r. In this section, we will prove Lemma 11, restated below: Lemma 33. Let ε > 0, and let C be a circuit over C of depth h, computing a polynomial g(x1, . . . , xN ) of degree d. Suppose that each multiplication gate of C is of fan-in 2, and each addition gate is of fan-in at most m. For technical reasons, suppose that all input gates of C are labelled by a variable in {x1, . . . , xN} (i.e., there are no input gates labelled by a constant in C). If r > (2hd2⌈log(m)⌉ + 1)log2(4N M d/ε), then Br,M (C) is a logspace-uniform Boolean circuit of size poly(Cdhr(logm)log(M )) and depth-O(h · log(dhrmM )). Moreover, Br,M (C) computes a function g(x1, . . . , xN ) such that for all a1, . . . , aN ∈ C with maxi xi ≤ M , g(a1, . . . , an) − g(a1, . . . , gn) < ε. Proof. This follows from Lemmas 35 and 38, which are proved in Subsections C.2 and C.1. In Subsection C.1, we ensure that the function computed by Br,M (C) is a good approxima- tion of the polynomial computed by C. And in Subsection C.2 we bound the depth of Br,M (C). This requires bounding the number of bits required to represent the values in the intermediate computation. In both Subsections C.1 and C.2, we will use the following lemma: Lemma 34 (Bound on circuit value). Let C be an arithmetic circuit over C. Suppose that each mul- tiplication gate of C is of fan-in 2, and each addition gate is of fan-in at most m. For technical reasons, suppose that all input gates of C are all labelled with variables in {x1, . . . , xN} (i.e., there are no con- stants from C in the input gates). For each node v at height h(v) in C, let pv(x1, . . . , xN ) denote the polynomial of degree d(v) com- puted at v. Then if maxi xi ≤ M , pv(x1, . . . , xN ) ≤ f (d(v), h(v)) := (2M )d(v)h(v)⌈log2(m)⌉+1. (45) Proof. First we note that we may assume that m = 2 without loss of generality, because each fan-in-m addition gate can be replaced by a depth-⌈logm⌉ tree of fan-in-2 addition gates, in- creasing the depth of the circuit by at most a factor of ⌈logm⌉. The proof is by induction on h(v), the height of v. For the base case, v is an input gate and h(v) = 0, d(v) = 1, since pv = xi for some xi ≤ M , pv(x1, . . . , xN ) ≤ xi ≤ (2M )d(v)h(v)+1. (46) For the inductive step, if v is not an input gate, let w1 and w2 be its children at heights h(w1), h(w2) ≤ h(v) − 1. If v is a multiplication gate, then pv(x) = pw1(x) · pw2(x) ≤ (2M )d(w1)h(w1)+1 · (2M )d(w2)h(w2)+1 ≤ (2M )d(w1)(h(v)−1)+1+d(w2)(h(v)−1)+1 = (2M )d(v)h(v)+2−d(v) ≤ (2M )d(v)h(v)+1. 3The floor function is applied to the real and imaginary parts separately. 22 (Using d(w1) + d(w2) = d(v)) And if v is an addition gate then pv(x) = pw1(x) + pw2(x) ≤ (2M )d(w1)h(w1)+1 + (2M )d(w2)h(w2)+1 ≤ 2 · (2M )d(v)(h(v)−1)+1 ≤ (2M )d(v)h(v)+1. (By h(w1), h(w2) ≤ h(v) and d(w1), d(w2) ≤ d(v)) C.1 Bounding the error from rounding A corollary to this lemma is that we can round the input values to a low number of bits of precision, and incur only a small additive error. Lemma 35 (Bound on rounding error). Let C be an arithmetic circuit over C of depth h and degree d such that all input gates are labelled by input variables {x1, . . . , xN} and not constants in C. Suppose that each multiplication gate of C is of fan-in 2, and each addition gate is of fan-in at most m. Let g(x1, . . . , xN ) ∈ C[x1, . . . , xN ] be the polynomial computed by C. Let M > 0, 0 ≤ ε < 1, a1, . . . , an ∈ C and b1, . . . , bn ∈ C be such that max i bi − ai ≤ ε, and max i ai ≤ M, , max i bi ≤ M. g(a1, . . . , an) − g(b1, . . . , bn) ≤ N dε(2M )2hd2⌈logm⌉+1 Then . Proof. Assume m = 2 without loss of generality, because each fan-in-m addition gate can be replaced by a tree of addition gates of depth ⌈logm⌉. For each i ∈ [N ] and 0 ≤ j ≤ d, consider the polynomial [xj i ]g(x1, . . . , xN ) ∈ C[x1, . . . , xi−1, xi+1, . . . , xN ]. By Lemma 9, there is a depth-(2hd) arithmetic circuit Ci,j computing [xj i ]g. Moreover, the con- struction in Lemma 9 does not add any field elements from C to the input gates. Therefore, by Lemma 34 we have the following inequality: [xj i ]g(a1, . . . , ai−1, ai+1, . . . , aN ) ≤ (2M )2hd2+1 Therefore, for all i ∈ [N ], defining ∆i := g(a1, . . . , ai, bi+1, . . . , bN ) − g(a1, . . . , ai−1, bi, . . . , bN ), we have ∆i ≤ d Xj=0 bi − aij · [xj i ]g(a1, . . . , ai−1, bi+1, . . . , bN ) ≤ dε(2M )2hd2+1. So g(a1, . . . , an) − g(b1, . . . , bn) = Xi∈[N ] ∆i ≤ Xi∈[N ] ∆i ≤ N dε(2M )2hd2+1. A corollary of Lemma 35 is the following: 23 Corollary 36. Let ε, M > 0, and let g(x1, . . . , xN ) be as in the statement of Lemma 35. (10hd3⌈logm⌉ + 1)log2(4N dM/ε), then for x1, . . . , xN ∈ C such that maxi xi ≤ M , If r > g(Rr(x1), . . . , Rr(xN )) − g(x1, . . . , xN ) ≤ 2−r+1 · N d(2M )10hd3⌈logm⌉+1 ≤ ε. For example, if m = 2 and the degree of g is polylog(N ) and the height is polylog(N ), then Corollary 36 implies that we can round the inputs of the circuit down to polylog(N ) · log(M ) bits of precision and still obtain a 1/poly(N ) overall approximation to the true value. C.2 Bounding the depth of the Booleanization In this subsection, we show that replacing each arithmetic operation in an arithmetic circuit with its fixed-precision Boolean analogue does not increase the depth of the circuit significantly. The parallel Boolean complexity of the basic arithmetic operations is a folklore result: Lemma 37 (Boolean complexity of addition, multiplication and exponentiation). Complex mul- tiplication and iterated addition are contained in NC1. That is, i=1 ai can be computed using a bounded fan-in Boolean logspace-uniform circuit of size poly(t) and depth O(logt). 1. If a1, . . . , at ∈ C are t complex numbers in t bits thenPt 2. If a, b ∈ C are complex numbers in t bits, then a × b can be computed using a bounded fan-in Boolean logspace-uniform circuit of size poly(t) and depth O(logt). Recall that Br,M (C) is defined to be the Boolean circuit formed by rounding the input vari- ables to r bits of precision, and replacing each arithmetic operation with a Boolean operation, assuming that at the input gates we have maxi xi ≤ M . Lemma 38. Let r > 0, and let C be an arithmetic circuit over C of depth h and degree d such that the input gates are labelled by variables {x1, . . . , xN} and not constants in C. Suppose that each multipli- cation gate of C is of fan-in 2, and each addition gate is of fan-in at most m. Then Br,M (C) has depth O(hlog(dhrmM )). Proof. We will prove this lemma by bounding the bit complexity of the values at the interme- diate gates v of the arithmetic circuit by B = O(d3hr(logm)(logM )). This will suffice, because when the number of bits at each gate is bounded by B then replacing each addition or multi- plication operation with the Boolean implementation adds only log(mB) depth to the circuit by Lemma 37. Thus the total depth is O(hlog(mB)) = O(hlog(dhrmM )), as claimed. For each node v in C, let pv(x1, . . . , xN ) be the polynomial computed at v. Write pv(x1, . . . , xN ) = d Xi=0 pv,i(x1, . . . , xN ), where for each 0 ≤ i ≤ d, pv,i is a homogeneous polynomial of degree i (i.e., each of its monomials is of degree i). By arithmetic circuit homogenization (cf. Lemma 9), for each 0 ≤ i ≤ d there is an arithmetic circuit of depth h(d + 1) computing pi,v such that all input gates are labelled by variables in {x1, . . . , xN}. We apply Lemma 34 to pv,i(x1 · 2r, . . . , xN · 2r) = pv,i(x1, . . . , xN ) · 2ir, and conclude that pv,i(x1·2r, . . . , xN ·2r) ≤ (2M )(r+1)(2d2⌈log2(m)⌉h+1). Since 2rdpv,i(x1, . . . , xN ) is a Gaussian in- teger, we conclude that only O((r+1)(d3h+1)(logM )) bits of precision are required to represent pv,i(x1·2r, . . . , xN ·2r). Hence only O(d(v)·(r+1)(d2h+1)(logM )) bits are required to represent pv(x1, . . . , xN ). So overall, all intermediate values in Br,M (B) can indeed be represented with B = O(d3hr(logm)(logM )) bits of precision. 24
1808.05458
1
1808
2018-08-16T13:18:43
Shared-memory Exact Minimum Cuts
[ "cs.DS" ]
The minimum cut problem for an undirected edge-weighted graph asks us to divide its set of nodes into two blocks while minimizing the weight sum of the cut edges. In this paper, we engineer the fastest known exact algorithm for the problem. State-of-the-art algorithms like the algorithm of Padberg and Rinaldi or the algorithm of Nagamochi, Ono and Ibaraki identify edges that can be contracted to reduce the graph size such that at least one minimum cut is maintained in the contracted graph. Our algorithm achieves improvements in running time over these algorithms by a multitude of techniques. First, we use a recently developed fast and parallel \emph{inexact} minimum cut algorithm to obtain a better bound for the problem. Then we use reductions that depend on this bound, to reduce the size of the graph much faster than previously possible. We use improved data structures to further improve the running time of our algorithm. Additionally, we parallelize the contraction routines of Nagamochi, Ono and Ibaraki. Overall, we arrive at a system that outperforms the fastest state-of-the-art solvers for the \emph{exact} minimum cut problem significantly.
cs.DS
cs
Shared-memory Exact Minimum Cuts ∗ Monika Henzinger † Alexander Noe ‡ Christian Schulz§ 8 1 0 2 g u A 6 1 ] S D . s c [ 1 v 8 5 4 5 0 . 8 0 8 1 : v i X r a Abstract The minimum cut problem for an undirected edge- weighted graph asks us to divide its set of nodes into two blocks while minimizing the weight sum of the cut edges. In this paper, we engineer the fastest known exact algorithm for the problem. State-of-the-art algorithms like the algorithm of Padberg and Rinaldi or the algorithm of Nagamochi, Ono and Ibaraki identify edges that can be contracted to reduce the graph size such that at least one mini- mum cut is maintained in the contracted graph. Our algorithm achieves improvements in running time over these algorithms by a multitude of techniques. First, we use a recently developed fast and parallel inexact minimum cut algorithm to obtain a better bound for the problem. Then we use reductions that depend on this bound, to reduce the size of the graph much faster than previously possible. We use improved data struc- tures to further improve the running time of our al- gorithm. Additionally, we parallelize the contraction routines of Nagamochi, Ono and Ibaraki. Overall, we arrive at a system that outperforms the fastest state- of-the-art solvers for the exact minimum cut problem significantly. 1 Introduction Given an undirected graph with non-negative edge weights, the minimum cut problem is to partition the vertices into two sets so that the sum of edge weights between the two sets is minimized. A minimum cut is often also referred to as the edge connectivity of a graph [24, 14]. The problem has applications in many fields. In particular, for network reliability [16, 30], assuming equal failure probability edges, the smallest edge cut in the network has the highest chance to ∗The research leading to these results has received funding from the European Research Council under the European Com- munity's Seventh Framework Programme (FP7/2007-2013) /ERC grant agreement No. 340506 of Vienna, Vienna, Austria. [email protected] of Vienna, Vienna, Austria. †University ‡University §University [email protected] [email protected] of Vienna, Vienna, Austria. disconnect the network; in VLSI design [21], a minimum cut can be used to minimize the number of connections between microprocessor blocks; and it is further used as a subproblem in the branch-and-cut algorithm for solving the Traveling Salesman Problem and other combinatorial problems [27]. As the minimum cut problem has many applications and is often used as a subproblem for complex problems, it is highly important to have algorithms that are able solve the problem in reasonable time on huge data sets. As data sets are growing substantially faster than pro- cessor speeds, a good way to achieve this is efficient par- allelization. While there is a multitude of algorithms, which solve the minimum cut problem exactly on a sin- gle core [12, 14, 17, 24], to the best of our knowledge, there exists only one parallel exact algorithm for the minimum cut problem: Karger and Stein [17] present a parallel variant for their random contraction algo- rithm [17] which computes a minimum cut with high probability in polylogarithmic time using n2 processors. This is however unfeasible for large instances. There has been a MPI implementation of this algorithm by Gian- inazzi et al. [9]. However, there have been no parallel implementations of the algorithms of Hao et al. [12] and Nagamochi et al. [24, 25], which outperformed other ex- act algorithms by orders of magnitude [7, 13, 15], both in real-world and generated networks. All algorithms that solve the minimum cut prob- lem exactly have non-linear running times, currently the fastest being the deterministic algorithm of Hen- [14] with running time O(log2 n log log2 n). zinger et al. There is a linear time approximation algorithm, namely the (2 + ε)-approximation algorithm by Matula [23] and a linear time heuristic minimum cut algorithm by Hen- zinger et al. [13] based on the label propagation algo- rithm [29]. The latter paper also contains a shared- memory parallel implementation of their algorithm. 1.1 Contribution. We engineer the fastest known exact minimum cut algorithm for the problem. We do so by (1) incorporating recently proposed inexact methods and (2) by using better suited data structures and other optimizations as well as (3) parallelization. Algorithms like the algorithm of Padberg and Ri- naldi or the algorithm of Nagamochi, Ono and Ibaraki identify edges that can be contracted to reduce the graph size such that at least one minimum cut is main- tained in the contracted graph. Our algorithm achieves improvements in running time by a multitude of tech- niques. First, we use a recently developed fast and par- allel inexact minimum cut algorithm [13] to obtain a better approximate bound λ for the problem. As know graph reduction techniques depend on this bound, the better bound enables us to apply more reductions and reduce the size of the graph much faster. For exam- ple, edges whose incident vertices have a connectivity of at least λ, can be contracted without the contraction affecting the minimum cut. Using better suited data structures as well as incorporating observations that help to save a significantly amount of work in the con- traction routine of Nagamochi, Ono and Ibaraki [25] fur- ther reduce the running time of our algorithm. For ex- ample, we observe a significantly higher performance on some graphs when using a FIFO bucket priority queue, bounded priority queues as well as better bounds λ. Ad- ditionally, we give a parallel variant of the contraction routines of Nagamochi, Ono and Ibaraki [25]. Overall, we arrive at a system that outperforms the state-of- the-art by a factor of up to 2.5 already sequentially, and when run in parallel by a factor of up to 12.9 us- ing 12 cores. The rest of the paper is organized as follows. Chap- ter 2 gives preliminaries, an overview over related work and details of the algorithms of Nagamochi et al. [24, 25] and Henzinger et al. [13], as we make use of their re- sults. Our shared-memory parallel exact algorithm for the minimum cut problem is detailed in Chapter 3. In Chapter 4 we give implementation details and extensive experiments both on real-world and generated graphs. We conclude the paper in Chapter 5. 2 Preliminaries (cid:80) 2.1 Basic Concepts. Let G = (V, E, c) be a weighted undirected graph with vertex set V , edge set E ⊂ V × V and non-negative edge weights c : E → N. We extend c to a set of edges E(cid:48) ⊆ E by summing the weights of the edges; that is, c(E(cid:48)) := e={u,v}∈E(cid:48) c(u, v). We apply the same notation for single nodes and sets of nodes. Let n = V be the number of vertices and m = E be the number of edges in G. The neighborhood N (v) of a vertex v is the set of vertices adjacent to v. The weighted degree of a vertex is the sum of the weight of its incident edges. For brevity, we simply call this the degree of the vertex. For a set of vertices A ⊆ V , we denote by E[A] := {(u, v) ∈ E u ∈ A, v ∈ V \ A}; that is, the set of edges in E that start in A and end in its complement. A cut (A, V \ A) is a partitioning of the vertex set V is c(A) =(cid:80) into two non-empty partitions A and V \ A, each being called a side of the cut. The capacity of a cut (A, V \ A) (u,v)∈E[A] c(u, v). A minimum cut is a cut (A, V \ A) that has smallest weight c(A) among all cuts in G. We use λ(G) (or simply λ, when its meaning is clear) to denote the value of the minimum cut over all A ⊂ V . For two vertices s and t, we denote λ(G, s, t) as the smallest cut of G, where s and t are on different sides of the cut. The connectivity λ(G, e) of an edge e = (s, t) is defined as λ(G, s, t), the connectivity of its incident vertices. This is also known as the minimum s-t-cut of the graph or the connectivity or vertices s and t. At any point in the execution of a minimum cut al- gorithm, λ(G) (or simply λ) denotes the lowest upper bound of the minimum cut that an algorithm discovered until that point. For a vertex u ∈ V with minimum ver- tex degree, the size of the trivial cut ({u}, V \ {u}) is equal to the vertex degree of u. Hence, the minimum vertex degree δ(G) can serve as initial bound. Many algorithms tackling the minimum cut prob- lem use graph contraction. Given an edge (u, v) ∈ E, we define G/(u, v) to be the graph after contracting edge (u, v). In the contracted graph, we delete vertex v and all edges incident to this vertex. For each edge (v, w) ∈ E, we add an edge (u, w) with c(u, w) = c(v, w) to G or, if the edge already exists, we give it the edge weight c(u, w) + c(v, w). 2.2 Related Work. We review algorithms for the global minimum cut and related problems. A closely related problem is the minimum s-t-cut problem, which asks for a minimum cut with nodes s and t in different partitions. Ford and Fulkerson [8] proved that minimum s-t-cut is equal to maximum s-t-flow. Gomory and Hu [11] observed that the (global) minimum cut can be computed with n−1 minimum s-t-cut computations. For the following decades, this result by Gomory and Hu was used to find better algorithms for global minimum cut using improved maximum flow algorithms [17]. One of the fastest known maximum flow algorithms is the push-relabel algorithm [10] by Goldberg and Tarjan. Hao and Orlin [12] adapt the push-relabel algorithm to pass information to future flow computations. When a push-relabel iteration is finished, they implicitly merge the source and sink to form a new sink and find a new source. Vertex heights are maintained over multiple iterations of push-relabel. With these techniques they achieve a total running time of O(mn log n2 m ) for a graph with n vertices and m edges, which is asymptotically equal to a single run of the push-relabel algorithm. Padberg and Rinaldi [26] give a set of heuristics for edge contraction. Chekuri et al. [7] give an implemen- tation of these heuristics that can be performed in time linear in the graph size. Using these heuristics it is pos- sible to sparsify a graph while preserving at least one minimum cut in the graph. If their algorithm does not find an edge to contract, it performs a maximum flow computation, giving the algorithm worst case running time O(n4). However, the heuristics can also be used to improve the expected running time of other algorithms by applying them on interim graphs [7]. Nagamochi et al. [24, 25] give a minimum cut algo- rithm which does not use any flow computations. In- stead, their algorithm uses maximum spanning forests to find a non-empty set of contractible edges. This con- traction algorithm is run until the graph is contracted into a single node. The algorithm has a running time of O(mn + n2 log n). Stoer and Wagner [33] give a sim- pler variant of the algorithm of Nagamochi, Ono and Ibaraki [25], which has a the same asymptotic time complexity. The performance of this algorithm on real- world instances, however, is significantly worse than the performance of the algorithms of Nagamochi, Ono and Ibaraki or Hao and Orlin, as shown in experiments con- ducted by Junger et al. [15]. Both the algorithms of Hao and Orlin, and Nagamochi, Ono and Ibaraki achieve close to linear running time on most benchmark in- stances [7, 15]. To the best of our knowledge, there are no parallel implementation of either algorithm. Both of the algorithms do not have a straightforward paral- lel implementation. Kawarabayashi and Thorup [18] give a determin- istic near-linear time algorithm for the minimum cut problem, which runs in O(m log12 n). Their algorithm works by growing contractible regions using a vari- ant of PageRank [28]. It was later improved by Hen- zinger et al. [14] to run in O(m log2 n log log2 n) time. Based on the algorithm of Nagamochi, Ono and Ibaraki, Matula [23] gives a (2 + ε)-approximation al- gorithm for the minimum cut problem. The algorithm contracts more edges than the algorithm of Nagamochi, Ono and Ibaraki to guarantee a linear time complexity while still guaranteeing a (2 + ε)-approximation factor. Karger and Stein [17] give a randomized Monte Carlo algorithm based on random edge contractions. This al- gorithm returns the minimum cut with high probability and a larger cut otherwise. In experiments, the algo- rithm was often outperformed by Nagamochi et al. and Hao and Orlin by orders of magnitude [7, 13, 15]. 2.3 Nagamochi, Ono and Ibaraki's Algorithm. We discuss the algorithm by Nagamochi, Ono and Ibaraki [24, 25] in greater detail since our work makes use of the tools proposed by those authors. The intuition behind the algorithm is as follows: imagine you have an unweighted graph with minimum cut value exactly one. Then any spanning tree must contain at least one edge of each of the minimum cuts. Hence, after computing a spanning tree, every remaining edge can be contracted without losing the minimum cut. Nagamochi, Ono and Ibaraki extend this idea to the case where the graph can have edges with positive weight as well as the case in which the minimum cut is bounded by λ. The first observation is the following: assume that you already found a cut in the current graph of size λ and you want to find a out whether there is a cut of size < λ. Then the contraction process only needs to ensure that the contracted graph contains all cuts having a value strictly smaller than λ. To do so, Nagamochi, Ono and Ibaraki build edge-disjoint maximum spanning forests and contract all edges that are not in one of the λ − 1 first spanning forests, as those connect vertices that have connectivity at least λ. Note that the edge-disjoint maximum spanning forest certifies for any edge e = {u, v} that is not in the forest that the minimum cut between u and v is at least λ. Hence, the edge can be "safely" contracted. As weights are integer, this guarantees that the contracted graph still contains all cuts that are strictly smaller than λ. Since it would be inefficient to directly compute λ − 1 edge disjoint maximum spanning trees, the authors give a modified algorithm to be able to detect contractable edges faster. This is done by computing a lower bound on the connectivity of the endpoints of an edge which serves as a certificate for a edge to be contractable. The algorithm has worst case running time O(cid:0)mn + n2 log n(cid:1). In experimental evaluations [7, 15, 13] it is one of the fastest exact minimum cut algorithms, both on real-world and generated instances. We now dive into more details of the algorithm. To find contractable edges, the algorithm uses a modified breadth-first graph traversal (BFS) algorithm [24, 25]. More precisely, the algorithm starts at an arbitrary vertex. In each step, the algorithm visits (scans) the vertex v that is most strongly connected to the already visited vertices. For this purpose a priority queue Q is used, in which the connectivity strength of each vertex r : V → R to the already discovered vertices is used as a key. When scanning a vertex v, the value r(w) is kept up to date for every unscanned neighbor w of v by setting i.e. r(w) := r(w) + c(e). Moreover, for each such edge e = (v, w), the algorithm computes a lower bound q(e) for the connectivity, i.e. the smallest cut λ(G, v, w), which places v and w on different sides of the cut. More precisely, as shown by [25, 24], if the vertices are scanned in a certain order (the order used by the algorithm), then r(w) is a lower bound on λ(G, v, w). For an edge that has connectivity λ(G, v, w) ≥ λ, we know that there is no cut smaller than λ that places v and w in different partitions. If an edge e is not in a given cut (A, V \ A), it can be contracted without affecting the cut. Thus, we can contract edges with connectivity at least λ without losing any cuts smaller than λ. As q(e) ≤ λ(G, u, v) (lower bound), all edges with q(e) ≥ λ are contracted. Afterwards, the algorithm continues on the con- tracted graph. A single iteration of the subroutine can be performed in O(m + n log n). The authors show that in each BFS run, at least one edge of the graph can be contracted [24]. This yields a total running time of O(mn + n2 log n). However, in practice the number of iterations is typically much less than n − 1, often it is proportional to log n. 2.4 Inexact Shared-Memory Minimum Cuts. VieCut is a multilevel algorithm that uses a shared- memory parallel implementation of the label propaga- tion algorithm [29] to find clusters with a strong intra- cluster connectivity. The algorithm then contracts these clusters as it is assumed that the minimum cut does not split a cluster, as the vertices in a cluster are strongly interconnected with each other. This contraction is followed by a linear-work shared memory run of the Padberg-Rinaldi local tests for contractible edges [26]. This whole process is repeated until the graph has only a constant amount of vertices left and can be solved by the algorithm of Nagamochi et al. [25] exactly. While VieCut can not guarantee optimality or even a small approximation ratio, in practice the algorithm finds near-optimal minimum cuts, often even the exact minimum cut, very quickly and in parallel. The algo- rithm can be implemented to have sequential running time O(n + m). 3 Fast Exact Minimum Cuts In this section we detail our shared-memory algo- rithm for the minimum cut problem that is based on the algorithms of Nagamochi et al. [24, 25] and Hen- zinger et al. [13]. We aim to modify the algorithm of Nagamochi et al. [25] in order to find exact mini- mum cuts faster and in parallel. Their algorithm uses a routine described above in Section 2.3, called CAP- FOREST in their original work, in order to compute a lower bound q(e) of the connectivity λ(G, u, v) for each edge e = (u, v). If the connectivity between two vertices is larger than the current upper bound for the minimum cut, then it can be contracted. That also means that edges e with q(e) ≥ λ can be safely contracted, The algorithm is guaranteed to find at least one such edge. We start this section with optimizations to the sequential algorithm. First we use a recently published inexact algorithm to lower the minimum cut upper bound λ. This enables us to save work and to perform contractions more quickly. We then give different implementations of the priority queue Q and detail the effects of the choice of queue on the algorithm. We show that the algorithm remains correct, even if we limit the priorities in the queue to λ, meaning that elements in the queue having a key larger than that will not be updated. This significantly lowers the amount of priority queue operations necessary. Then we adapt the algorithm so that we are able to detect contractible edges in parallel efficiently. Lastly, we put it everything together and present a full system description. 3.1 Sequential Optimizations 3.1.1 Lowering the Upper Bound λ. Note that the upper bound λ for the minimum cut is an important parameter for exact contraction based algorithms such as the algorithm NOI of Nagamochi et al. [25]. The algorithm computes a lower bound for the connectivity of the two incident vertices of each edge and contracts all edges whose incident vertices have a connectivity of at least λ. Thus it is possible to contract more edges if we manage to lower λ beforehand. A trivial upper bound λ for the minimum cut is the minimum vertex degree, as it represents the trivial cut which separates the minimum degree vertex from all other vertices. We run VieCut to lower λ in order to allow us to find more edges to contract. Although VieCut is an inexact algorithm, in most cases it already finds the minimum cut [13] of the graph. As there are by definition no cuts smaller than the minimum cut, the result of VieCut is guaranteed to be at least as large as the minimum cut λ. As we set λ to the result of VieCut when running NOI, we can therefore guarantee a correct result. A similar idea is employed by the linear time (2 + )-approximation algorithm of Matula [23], which initializes the algorithm of Nagamochi et al. [25] with λ = ( 1 2 − )×min degree. 3.1.2 Bounded Priority Queues. Whenever we visit a vertex, we update the priority of all of its neighbors in Q by adding the respective edge weight. Thus, in total we perform E priority queue increase- weight operations. In practice, many vertices reach priority values much higher than λ and perform many priority increases until they reach their final value. We limit the values in the priority queue by λ, i.e. we do not update priorities that are already λ. Lemma 3.1 shows that this does not affect correctness of the algorithm. Let qG(e) be the value q(e) assigned to e in the modified algorithm on graph G and let rG(x) be the r-value of a node x in the modified algorithm on G. holds that rG(x) = rG(cid:48)(x). We show this claim by the induction on i. Lemma 3.1. Limiting the values in the priority queue Q used in the CAPFOREST routine to a maximum of λ does not interfere with the correctness of the algorithm. For every edge e = (v, w) with qG(e) ≥ λ, it holds that λ(G, e) ≥ λ. Therefore the edge can be contracted. Proof. As we limit the priority queue Q to a maximum value of λ, we can not guarantee that we always pop the element with highest value r(v) if there are multiple elements that have values r(v) ≥ λ in Q. However, we know that the vertex x that is popped from Q is either maximal or has r(x) ≥ λ. We prove Lemma 3.1 by creating a graph G(cid:48) = (V, E, c(cid:48)) by lowering edge weights (possibly to 0, ef- fectively removing the edge) while running the algo- rithm, so that CAPFOREST on G(cid:48) visits vertices in the same order (assuming equal tie breaking) and as- signs the same q values as the modified algorithm on G. We first describe the construction of G(cid:48). We initial- ize the weight of all edges in graph G(cid:48) with the weight of the respective edge in G and run CAPFOREST on G(cid:48). Whenever we check an edge e = (x, y) and update a value rG(cid:48)(y) , we check whether we would set rG(cid:48)(y) > λ. If this is the case, i.e. when rG(cid:48)(y) + c(e) > λ, we set c(cid:48)(e) in G(cid:48) to c(e) − (rG(cid:48)(y) − λ), which is lower by ex- actly the value by which rG(y) is larger than λ, and non-negative. Thus, rG(cid:48)(y) = λ. As we scan every edge exactly once in a run of CAPFOREST, the weights of edges already scanned remain constant afterwards. This completes the construction of G(cid:48) Note that during the construction of G(cid:48) edge weights were only decreased and never increased. Thus it holds that λ(G(cid:48), x, y) ≤ λ(G, x, y) for any pair of nodes (x, y). If we ran the unmodified CAPFOREST algorithm on G(cid:48) each edge would be assigned a value qG(cid:48)(e) with qG(cid:48)(e) ≤ λ(G(cid:48), e). Thus for every edge e it holds that qG(cid:48)(e) ≤ λ(G(cid:48), e) ≤ λ(G, e). Below we will show that qG(e) = qG(cid:48)(e) for all edges It then follows that for all edges e it holds that e. qG(e) ≤ λ(G, e). This implies that if qG(e) ≥ λ then λ(G, e) ≥ λ, which is what we needed to show. It remains to show for all edges e that qG(e) = qG(cid:48)(e). To show this claim we will show the following stronger claim. For any i with 1 ≤ i ≤ m after the (i− 1)th and before the ith scan of an edge the modified algorithm on g and the original algorithm on G(cid:48) with the same tie breaking have visited all nodes and scanned all edges up to now in the same order and for all edges e it holds that qG(e) = qG(cid:48)(e) (we assume that before scanning an edge e, q(e) = 0) and for all nodes x it For i = 1 observe that before the first edge scan qG(e) = qG(cid:48)(e) = 0 for all edges e and the same node is picked as first node due to identical tie breaking and the fact that G = G(cid:48) at that point. Now for i > 1 assume that the claim holds for i − 1 and consider the scan of the (i − 1)th edge. If for the (i − 1)th edge scan a new node needs to be chosen from the priority queue by one of the algorithms then note that both algorithms will have to choose a node and they pick the same node y as rG(x) = rG(cid:48)(x) for all nodes x. Then both algorithms scan the same incident edge of y as in both algorithms the set of unscanned neighbors of y is identical. If neither algorithm has to pick a new node then both have scanned the same edges of the same current node y and due to identical tie breaking will pick the same next edge to scan. Let this edge be (y, w). By induction rG(w) = rG(cid:48)(w) at this time. As (y, w) is unscanned c(cid:48)(y, w) = c(y, w) which implies that rG(w) + c(y, w) = rG(cid:48)(w) + c(cid:48)(y, w). If rG(w) + c(y, w) ≤ λ then the modified algorithm on G and the original algorithm on G(cid:48) will set the r value of w to the same value, namely rG(w) + c(y, w). If rG(w) + c(y, w) > λ, then rG(w) is set to λ and c(cid:48)(y, w) is set to c(y, w) − (rG(cid:48)(w) − λ), which leads to rG(cid:48)(w) being set to λ. Thus rG(w) = rG(cid:48)(w) and by induction rG(x) = rG(cid:48)(x) for all x. Additionally the modified algorithm on G sets qG(y, w) = rG(w) and the original algorithm on G(cid:48) sets qG(cid:48)(y, w) = rG(cid:48)(w). It follows that qG(y, w) = qG(cid:48)(y, w) and, thus, by induction qG(e) = qG(cid:48)(e) for all e. This completes the proof of the claim. Lemma 3.1 allows us to considerably lower the amount of priority queue operations, as we do not need to update priorities that are bigger than λ. This optimization has even more benefit in combination with running VieCut to lower the upper bound λ, as we directly lower the amount of priority queue operations. 3.1.3 Priority Queue Implementations. Nag- amochi et al. [25] use an addressable priority queue Q in their algorithm to find contractible edges. In this section we now address variants for the implementation of the priority queue. As the algorithm often has many elements with maximum priority in practice, the imple- mentation of this priority queue can have major impact on the order of vertex visits and thus also on the edges that will be marked contractible. Bucket Priority Queue. As our algorithm limits the values the priority queue to a maximum of λ, we observe integer priorities in the range of [0, λ]. Hence, we can use a bucket queue that is implemented as an array with λ buckets. In addition, the data structure keeps the id of the highest non-empty bucket, also known as the top bucket, and stores the position of each vertex in the priority queue. Priority updates can be implemented by deleting an element from its bucket and pushing it to the bucket with the updated priority. This allows constant time access for all operations except for deletions of the maximum priority element, which have to check all buckets between the prior top bucket to the new top bucket, possibly up to λ checks. We give two possible implementations to implement the buckets so that they can store all elements with a given priority. The first implementation, BStack uses a dynamic array (std::vector) as the container for all elements in a bucket. When we add a new element to the vector, we push it to the back of the array. Q.pop max() returns the last element of the top bucket. Thus our algorithm will always next visit the element whose priority it just increased. The algorithm therefore does not fully explore all vertices in a local region. The other implementation, BQueue uses a double ended queue (std::deque) as the container instead. A new element is pushed to the back of the queue and Q.pop max() returns the first element of the top bucket. This results in a variant of our algorithm, which performs closer to a breadth-first search in that it first explores the vertices that have been discovered earlier, i.e. are closer to the source vertex in the graph. Bottom-Up Binary Heap. A binary heap [36] is a binary tree (implemented as an array, where element i has its children in index 2i and 2i + 1) which fulfills the heap property, i.e. each element has priority that is not lower than either of its children. Thus the element with highest priority is the root of the tree. The tree can be made addressable by using an array of indices, in which we save the position of each vertex. We use a binary heap using the bottom-up heuristics [35], in which we sift down holes that were created by the deletion of the top priority vertex. Priority changes are implemented by sifting the addressed element up or down in the tree. Operations have a running time of up to O(log n) to sift an element up or down to fix the heap property. In Q.pop max(), the Heap priority queue does not favor either old or new elements in the priority queue and therefore this implementation can be seen as a middle ground between the two bucket priority queues. 3.2 Parallel CAPFOREST. We modify the algo- rithm in order to quickly find contractible edges us- ing shared-memory parallelism. The pseudocode can be found in Algorithm 1. Pseudocode for the original CAPFOREST algorithm can be found in Algorithm 3 in Appendix A.2. The proofs in this section show that the Figure 1: Example run of Algorithm 1. Every process starts at a random vertex and scans region around the start vertex. These regions do not overlap. modifications do not violate the correctness of the al- gorithm. Detailed proofs for the original CAPFOREST algorithm and the modifications of Nagamochi et al. for weighted graphs can be found in [25]. The idea of the our algorithm is as follows: We aim to find contractible edges using shared-memory parallelism. Every processor selects a random vertex and runs Algorithm 1, which is a modified version of CAPFOREST [24, 25] where the priority values are limited to λ, the current upper bound of the size of the minimum cut. We want to find contractible edges without requiring that every process looks at the whole graph. To achieve this, every vertex will only be visited by one process. Compared to limiting the amount of vertices each process visits this has the advantage that we also scan the vertices in sparse regions of the graph which might otherwise not be scanned by any process. Figure 1 shows an example run of Algorithm 1 with p = 5. Every process randomly chooses a start vertex and performs Algorithm 1 on it to "grow a region" of scanned vertices. As we want to employ shared-memory parallelism to speed up the algorithm, we share an array T between all processes to denote whether a vertex has already been visited. Every process has a blacklist B to mark nodes which were already scanned by another process and therefore not explored by this process. For every vertex v we keep a value r(v), which denotes the total weight of edges connecting v to already scanned vertices. Over the course of a run of the algorithm, every edge e = (v, w) is given a value q(e) (equal to r(w) right after scanning e) which is a lower bound for the smallest cut λ(G, v, w). We mark an edge e as contractible (more accurately, we union the incident vertices in the shared concurrent union-find data structure [1]), if q(e) ≥ λ. Note that this does not modify the graph, it just remembers which nodes to collapse. The actual node collapsing happens in a postprocessing step. Nagamochi Algorithm 1 Parallel CAPFOREST Input: G = (V, E, c) ← undirected graph λ ← upper bound for minimum cut, T ← shared array of vertex visits Output: U ← union-find data structure to mark contractible edges 1: Label all vertices v ∈ V "unvisited", blacklist B empty 2: ∀v ∈ V : r(v) ← 0 3: ∀e ∈ E : q(e) ← 0 4: Q ← empty priority queue 5: Insert random vertex into Q 6: while Q not empty do x ← Q.pop max() Mark x "visited" if T (x) = True then B(x) ← True T (x) ← True (cid:46) Choose unvisited vertex with highest priority (cid:46) Every vertex is visited only once else 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: end if α ← α + c(x) − 2r(x) λ ← min(λ, α) for e = (x, y) ← edge to vertex y not in B and not visited do if r(y) < λ ≤ r(y) + c(e) then U.union(x,y) end if r(y) ← r(y) + c(e) q(e) ← r(y) Q(y) ← min(r(y), λ) (cid:46) Mark edge e to contract end for 23: 24: end while and Ibaraki showed [25] that contracting only the edges that fulfill the condition in line 17 is equivalent. If a vertex v has already been visited by another process, it will not be visited by any other workers. A process that tries to visit v after it has already been visited locally blacklists v by setting B(v) to true and does not visit the vertex. Subsequently, no more edges incident to v will be marked contractible by this process. This is necessary to ensure correctness of the algorithm. As the set of disconnected edges is different depending on the start vertex, we looked into visiting every vertex by a number of processes up to a given parameter to find more contractible edges. However, this did generally result in higher total running times and thus we only visit every vertex once. After all processes are finished, every vertex was visited exactly once (or possibly zero times, if the graph is disconnected). On average, every process has visited roughly n p vertices and all processes finish at the same time. We do not perform any form of locking of the elements of T , as this would come with a running time penalty for every write and the worst that can happen with concurrent writes is that a vertex is visited more often, which does not affect correctness of the algorithm. However, as we terminate early and no process visits every vertex, we can not guarantee anymore that the algorithm actually finds a contractible edge. However, in practice, this only happens if the graph is already very small (< 50 vertices in all of our experiments). We can then run the CAPFOREST routine which is guaranteed to find at least one edge to contract. In line 14 and 15 of Algorithm 1 we compute the value of the cut between the scanned and unscanned vertices and update λ if this cut is smaller than it. For more details on this we refer the reader to [25]. In practice, many vertices reach values of r(y) that are much higher than λ and therefore need to update their priority in Q often. As previously detailed, we limit the values in the priority queue by λ and do not update priorities that are already greater or equal to λ. This allows us to considerably lower the amount of priority queue operations per vertex. Theorem 3.1. Algorithm 1 is correct. Algorithm 1 is correct. As Algorithm 1 is a modified variant of CAPFOREST [24, 25], we use the correctness of their algorithm and show that our modifications can not result in incorrect results. In order to show this we need the following lemmas: Lemma 3.2. 1) Multiple instances of Algorithm 1 can instances sharing a be run in parallel with all parallel union-find data structure. 2) Early termination does not affect correctness 3) For every edge e = (v, w), where neither v nor w are blacklisted, q(e) is a lower bound for the connectivity λ(G, v, w), even if the set of blacklisted vertices B is not empty. 4) When limiting the priority of a vertex in Q to λ, it still holds that the vertices incident to an edge e = (x, y) with q(e) ≥ λ have connectivity λ(G, x, y) ≥ λ. Proof. A run of the CAPFOREST algorithm finds a non-empty set of edges that can be contracted without contracting a cut with value less than λ [24]. We show that none of our modifications can result in incorrect results: 1) The CAPFOREST routine can be started from an arbitrary vertex and finds a set of edges that can be contracted without affecting the minimum cut λ. This is true for any vertex v ∈ V . As we do not change the underlying graph but just mark contractible edges, the correctness is obviously upheld when running the algorithm multiple times starting at different vertices. This is also true when running the different iterations in parallel, as long as the underlying graph is not changed. Marking the edge e = (u, v) as contractible is equivalent to performing a Union of vertices u and v. The Union operation in a union-find data structure is commutative and therefore the order of unions is irrelevant for the final result. Thus performing the iterations successively has the same result as performing them in parallel. 2) Over the course of the algorithm we set a value q(e) for each edge e and we maintain a value λ that never increases. We contract edges that have value q(e) ≥ λ at the time when q(e) is set. For every edge, this value is set exactly once. If we terminate the algorithm prior to setting q(e) for all edges, the set of contracted edges is a subset of the set of edges that would be contracted in a full run and all contracted edges e fulfill q(e) ≥ λ at termination. Thus, no edge contraction contracts a cut that is smaller than λ. 3) Let e = (v, w) be an edge and let Be be the set of nodes blacklisted at the time when e is scanned. We show that for an edge e = (v, w), q(e) ≤ λ( ¯G, v, w), where ¯G = ( ¯V , ¯E) with vertices ¯V = V \Be and edges ¯E = {e = (u, v) ∈ E : u (cid:54)∈ Be and v (cid:54)∈ Be} is the graph G with all blacklisted vertices and their incident edges removed. As the removal of vertices and edges can not increase edge connectivities q ¯G(e) ≤ λ( ¯G, v, w) ≤ λ(G, v, w) and e is a contractible edge. Whenever we visit a vertex b, we decide whether we blacklist the vertex. If we blacklist the vertex b, we immediately leave the vertex and do not change any values r(v) or q(e) for any other vertex or edge. As vertex b is marked as blacklisted, we will not visit the vertex again and the edges incident to b only affect r(b). As edges incident to any of the vertices in Be do not affect q(e), the value of q(e) in the algorithm with the blacklisted in G is equal to the value of q(e) in ¯G, which does not contain the blacklisted vertices in Be and their incident edges. On ¯G this is equivalent to a run of CAPFOREST without blacklisted vertices and due to the correctness of CAPFOREST [25] we know that for every edge e ∈ ¯E : q ¯G(e) ≤ λ( ¯G, v, w) ≤ λ(G, v, w). Note that in ¯G we only exclude the vertices that are in Be. It is possible that a node y that was unvisited when e was scanned might get blacklisted later, however, this does not affect the value of q(e) as the value q(e) is set when an edge is scanned and never modified afterwards. 4) Proof in Lemma 3.1. We can combine the sub-proofs (3) and (4) by cre- ating the graph ¯G(cid:48), in which we remove all edges inci- dent to blacklisted vertices and decrease edge weights to make sure no q(e) is strictly larger than λ. As we only lowered edge weights and removed edges, for ev- ery edge between two not blacklisted vertices e = (u, v), qG(e) ≤ λ( ¯G(cid:48), x, y) ≤ λ(G, x, y) or qG(e) > λ and thus we only contract contractible edges. As none of our modifications can result in the contraction of edges that should not be contracted, Algorithm 1 is correct. Parallel Graph Contraction. After using Algo- rithm 1 to find contractible edges, we use a concur- rent hash table [22] to generate the contracted graph GC = (VC, EC), in which each block in U is represented by a single vertex: first we assign each block a ver- tex ID in the contracted graph in [0,VC). For each Algorithm 2 Parallel Minimum Cut Input: G = (V, E, c) 1: λ ← VieCut(G), GC ← G 2: while GC has more than 2 vertices do λ ← Parallel CAPFOREST(GC, λ) 3: if no edges marked contractible then 4: 5: 6: λ ← CAPFOREST(GC, λ) end if GC, λ ← Parallel Graph Contract(GC) 7: 8: end while 9: return λ edge e = (u, v), we compute a hash of the block IDs of u and v to uniquely identify the edge in EC. We use this identifier to compute the weights of all edges between blocks. If there are two blocks that each contain many vertices, there might be many edges between them and if so, the hash table spends considerable time for syn- chronization. We thus compute the weight of the edge connecting the two heavy blocks locally on each process and sum them up afterwards to reduce synchronization overhead. If the collapsed graph GC has a minimum de- gree of less than λ, we update λ to the value of this cut. 3.3 Putting Things Together. Algorithm 2 shows the overall structure of the algorithm. We first run VieCut to find a good upper bound λ for the minimum cut. Afterwards, we run Algorithm 1 to find contractible edges. In the unlikely case that none were found, we run CAPFOREST [25] sequentially to find at least one contractible edge. We create a new contracted graph using parallel graph contraction, as shown in Section 3.2. This process is repeated until the graph has only two vertices left. Whenever we encounter a collapsed vertex with a degree of lower than λ, we update the upper bound. We return the smallest cut we encounter in this process. If we also want to output the minimum cut, for each collapsed vertex vC in GC we store which vertices of G are included in vC. When we update λ, we store which vertices are contained in the minimum cut. This allows us to see which vertices are on one side of the cut. 4 Experiments and Results 4.1 Experimental Setup and Methodology. We implemented the algorithms using C++-17 and compiled all codes using g++-7.1.0 with full optimization (-O3). Our experiments are conducted on a machine with two Intel Xeon E5-2643 v4 with 3.4GHz with 6 CPU cores each and 1.5 TB RAM in total. We perform five repe- titions per instance and report average running time. Performance plots relate the fastest running time to the running time of each other algorithm on a per- instance basis. For each algorithm, these ratios are sorted in increasing order. The plots show the ratio tbest/talgorithm on the y-axis. A point close to zero indicates that the running time of the algorithm was considerably worse than the fastest algorithm on the same instance. A value of one therefore indicates that the corresponding algorithm was one of the fastest algorithms to compute the solution. Thus an algorithm is considered to outperform another algorithm if its corresponding ratio values are above those of the other algorithm. In order to include instances that were too big for an algorithm, i.e. some implementations are limited to 32bit integers, we set the corresponding ratio below zero. Algorithms. There have been multiple experimental studies that compare exact algorithms for the minimum cut problem [7, 13, 15]. All of these studies report that the algorithm of Nagamochi et al. and the algorithm of Hao and Orlin outperform other algorithms, such as the algorithms of Karger and Stein [17] or the al- gorithm of Stoer and Wagner [33], often by multiple orders of magnitude. Among others, we compare our- selfs against two available implementations of the se- ] ) s n ( [ e g d E r e p i e m T g n i n n u R 27 26 25 Average Node Degree: 25 Average Node Degree: 26 Average Node Degree: 27 Average Node Degree: 28 27 26 25 225 220 27 26 25 225 220 222 221 224 Number of Vertices 223 27 26 25 225 220 222 221 224 Number of Vertices 223 222 221 224 Number of Vertices 223 HO-CGKLS NOI-CGKLS NOIλ-BStack NOIλ-BQueue NOI-HNSS NOIλ-Heap NOI-HNSS-VieCut NOIλ-Heap-VieCut 225 220 222 221 224 Number of Vertices 223 Figure 2: Total running time in nanoseconds per edge in RHG graphs. Figure 3: Total running time in real-world graphs, normalized by the running time of NOIλ-Heap-VieCut. preliminary experiments on small graphs which can be solved by NOI-HNSS, NOI-CGKLS and HO-CGKLS in less than 3 seconds. On these graphs, their implementation using 24 processes took more than 5 minutes, which matches other studies [7, 15, 13] that report bad real- world performance of (other implementations of) the algorithm of Karger and Stein. Gianinazzi et al. report a running time of 5 seconds for RMAT graphs with n = 16000 and an average degree of 4000, using 1536 cores. As NOI can find the minimum cut on RMAT graphs [19] of equal size in less than 2 seconds using a single core, we do not include the implementation in [9] in our experiments. As our algorithm solves the minimum cut problem exactly, we do not include the (2 + )-approximation algorithm of Matula [23] and the inexact algorithm VieCut in the experiments. Instances. We use a set of graph instances from the experimental study of Henzinger et al. [13]. The set of instances contains k-cores [3] of large undirected real- world graphs taken from the 10th DIMACS Implemen- tation Challenge [2] as well as the Laboratory for Web Algorithmics [4, 5]. Additionally it contains large ran- dom hyperbolic graphs [20, 34] with n = 220 − 225 and m = 224 − 232. A detailed description of the graph instances is given in Appendix A. These graphs are un- weighted, however contracted graphs that are created in the course of the algorithm have edge weights. 4.2 Sequential Experiments. We limit the values in the priority queue Q to λ, in order to significantly lower the amount of priority queue operations needed Figure 4: shared with Figure 3 above). Performance plot for all graphs (legend quential algorithm of Nagamochi et al. [24, 25]. Hen- [13] give an implementation of the al- zinger et al. gorithm of Nagamochi et al. [24, 25], written in in C++ (NOI-HNSS) that uses a binary heap. We use this algorithm with small optimizations in the priority queue as a base of our implementation. Chekuri et al. [7] give an implementation of the flow-based algorithm of Hao and Orlin using all optimizations given in the paper (variant ho in [7]), implemented in C, in our experi- ments denoted as HO-CGKLS. They also give an imple- mentation of the algorithm of Nagamochi et al. [24, 25], denoted as NOI-CGKLS, which uses a heap as its prior- ity queue data structure (variant ni-nopr in [7]). As their implementations use signed integers as edge ids, we include their algorithms only for graphs that have less than 231 edges. Most of our discussions focus on comparisons to the NOI-HNSS implementation as this outperforms the implementations by Chekuri et al. Gianinazzi et al. [9] give a MPI implementation of the algorithm of Karger and Stein [17]. We performed 20212223108109Slow DownNumber of EdgesHO−CGKLSNOI−CGKLSNOI−HNSSNOIl−HeapNOIl−BStackNOIl−BQueueNOI−HNSS−VieCutNOIl−Heap−VieCut20212223102103Slow DownAverage Degree020406080# InstancesToo large00.20.40.60.81tbest/talgo 10 8 6 4 2 l a i t n e u q e S o t p u d e e p S l a i t n e u q e S o t p u d e e p S 6 4 2 gsh-2015-host, k = 10 (λ = 1) uk-2007-05, k = 10 (λ = 1) twitter-2010, k = 50 (λ = 3) rhg 25 8 1 (λ = 118) rhg 25 8 2 (λ = 73) 10 8 6 4 2 6 4 2 6 4 2 6 4 2 12 4 8 12 24 12 4 8 12 24 12 4 8 12 24 12 4 8 12 24 12 4 8 12 24 3 2 1 10 8 6 4 2 6 4 2 0 12 4 8 12 24 12 4 8 12 24 12 4 8 12 24 12 4 8 12 24 Number of Processes Number of Processes Number of Processes Number of Processes 10 5 0 12 4 8 12 24 Number of Processes ParCutλ-BStack ParCutλ-BQueue ParCutλ-Heap ParCutλ-BStack ParCutλ-BQueue ParCutλ-Heap NOI-HNSS NOIλ-Heap NOIλ-BStack Figure 5: Scaling plots for four large graphs. Top: Scalability. Bottom: Speedup compared to NOI-HNSS and fastest sequential algorithm (first 3 graphs: NOIλ-BStack¸ last 2 graphs: NOIλ-Heap). to run the contraction routine. In this experiment, we want to examine the effects of different priority queue implementations and limiting priority queue values have on sequential minimum cut computations. We also include variants which run VieCut first to lower λ. We start with sequential experiments using the implementation of NOI-HNSS. We use two variants: NOIλ limits values in the priority queue to λ while NOI-HNSS allows arbitrarily large values in Q. For NOIλ, we test the three priority queue implementations, BQueue, Heap and BStack. As the priority queue for NOI-HNSS has priorities of up to the maximum degree of the graph and the contracted graphs can have very large degrees, the bucket priority queues are not suitable for NOI-HNSS. Therefore we only use the implementation of NOI-HNSS [13]. The variants NOI-HNSS-VieCut and NOIλ-Heap-VieCut first run the shared-memory parallel algorithm VieCut using all 24 threads to lower λ before running the respective sequential algorithm. We report the total running time, e.g. the sum of VieCut and NOI. Priority Queue Implementations. Figure 2 shows the results for RHG graphs and Figure 3 shows the results for real-world graphs, normalized by the running time of NOIλ-Heap-VieCut. Figure 4 gives performance plots for all graphs. We can see that in nearly all sequential runs, NOIλ-BStack is 5−10% faster than NOIλ-BQueue. This can be explained as this pri- ority queue uses std::vector instead of std::deque as its underlying data structure and thus has lower ac- cess times to add and remove elements. As all vertices are visited by the only thread, the scan order does not greatly influence how many edges are contracted. In the RHG graphs, nearly no vertices in NOI-HNSS reach priorities in Q that are much larger than λ. Usually, less than 5% of edges do not incur an update in Q. Thus, NOI-HNSS and NOIλ-Heap have practically the same running time. NOIλ-BStack is usually 5% slower. As the real-world graphs are social network and web graphs, they contain vertices with very high degrees. In these vertices, NOI-HNSS often reaches priority values of much higher than λ and NOIλ can actually save priority queue operations. Thus, NOIλ-Heap is up to 1.83 times faster than NOI-HNSS with an average (geometric) speedup factor of 1.35. Also, in contrast to the RHG graphs, NOIλ-BStack is faster than NOI-HNSS on real-world graphs. Due to the low diameter of web and social graphs, the number of vertices in Q is very large. This favors the BStack priority queue, as it has constant access times. The average geometric speedup of NOIλ-BStack compared to NOIλ-Heap is 1.22. Reduction of λ by VieCut. Now we reduce λ by VieCut before running NOI. While the other algorithms are slower for denser RHG graphs, NOI-HNSS-VieCut and NOIλ-Heap-VieCut are faster in these graphs with higher density. This happens as the variants without VieCut find less contractible edges and therefore need more rounds of CAPFOREST. The highest speedup compared to NOIλ-Heap is reached in RHG graphs with n = 223 and an average density of 28, where NOIλ-Heap-VieCut has a speedup of factor 4. NOIλ-Heap-VieCut is fastest on most real-world graphs, however when the minimum degree is very close to the minimum cut λ, running VieCut can not significantly lower λ. Thus, the extra work to run VieCut takes longer than the time saved by lowering the upper bound λ. The average geometric speedup factor of NOIλ-Heap-VieCut on all graphs compared to the variant without VieCut is 1.34. In the performance plots in Figure 4 we can see that NOIλ-Heap-VieCut is fastest or close to the fastest algo- rithm in all but the very sparse graphs, in which the al- gorithm of Nagamochi et al. [25] is already very fast [13] and therefore using VieCut cannot sufficiently lower λ and thus the running time of the algorithm. NOI-CGKLS and HO-CGKLS are outperformed on all graphs. 4.3 Shared-memory parallelism. We run experi- ments on 5 of the largest graphs in the data sets using up to 24 threads on 12 cores. First, we compare the per- formance of Algorithm 2 using different priority queues: ParCutλ-Heap, ParCutλ-BStack and ParCutλ-BQueue all limit the priorities to λ, the result of VieCut. Figure 5 shows the results of these scaling experi- ments. The top row shows how well the algorithms scale with increased amounts of processors. The lower row shows the speedup compared to the fastest sequential al- gorithm of Section 4.2. On all graphs, ParCutλ-BQueue has the highest speedup when using 24 threads. On real-world graphs, ParCutλ-BQueue also has the low- est total running time. In the large RHG graphs, in which the priority queue is usually only filled with up to 1000 elements, the worse constants of the double- ended queue cause the variant to be slightly slower than ParCutλ-Heap also even when running with 24 threads. In the two large real-world graphs that have a minimum degree of 10, the sequential algorithm NOIλ-BStack con- tracts most edges in a single run of CAPFOREST - due to the low minimum degree, the priority queue opera- tions per vertex are also very low. Thus, ParCutλ using only a single thread has a significantly higher running time, as it runs VieCut first and performs graph contrac- tion using a concurrent hash table, as described in Sec- tion 3.2, which is slower than sequential graph contrac- tion when using just one thread. In graphs with higher minimum degree, NOI needs to perform multiple runs of CAPFOREST. By lowering λ using VieCut we can contract significantly more edges and achieve a speedup factor of up to 12.9 compared to the fastest sequen- tial algorithm NOIλ-Heap. On twitter-2010, k = 50, ParCutλ-BQueue has a speedup of 10.3 to NOI-HNSS, 16.8 to NOI-CGKLS and a speedup of 25.5 to HO-CGKLS. The other graphs have more than 231 edges and are thus too large for NOI-CGKLS and HO-CGKLS. 5 Conclusion We presented a shared-memory parallel exact algorithm for the minimum cut problem. Our algorithm is based [24, 25] and of on the algorithms of Nagamochi et al. Henzinger et al. [13]. We use different data structures and optimizations to decrease the running time of the algorithm of Nagamochi et al. by a factor of up to 2.5. Using additional shared-memory parallelism we further increase the speedup factor to up to 12.9. Future work includes checking whether our sequential optimizations and parallel implementation can be applied to the (2 + )-approximation algorithm of Matula [23]. References [1] R. J. Anderson and H. Woll. Wait-free parallel algo- rithms for the union-find problem. In Proceedings of the Twenty-Third Annual ACM Symposium on Theory of Computing, STOC '91, pages 370 -- 380. ACM, 1991. [2] D. Bader, A. Kappes, H. Meyerhenke, P. Sanders, C. Schulz, and D. Wagner. Benchmarking for Graph Clustering and Partitioning. In Encyclopedia of Social Network Analysis and Mining. Springer, 2014. [3] V. Batagelj and M. Zaversnik. An O(m) algorithm for cores decomposition of networks. arXiv preprint cs/0310049, 2003. [4] P. Boldi, M. Rosa, M. Santini, and S. Vigna. Layered label propagation: A multiresolution coordinate-free ordering for compressing social networks. In S. Srini- vasan, K. Ramamritham, A. Kumar, M. P. Ravindra, E. Bertino, and R. Kumar, editors, Proceedings of the 20th International Conference on World Wide Web, pages 587 -- 596. ACM Press, 2011. [5] P. Boldi and S. Vigna. The WebGraph framework I: Compression techniques. In Proceedings of the Thirteenth International World Wide Web Conference (WWW 2004), pages 595 -- 601, Manhattan, USA, 2004. ACM Press. [6] D. Chakrabarti and C. Faloutsos. Graph mining: Laws, generators, and algorithms. ACM Computing Surveys, 38(1):2, 2006. [7] C. S. Chekuri, A. V. Goldberg, D. R. Karger, M. S. Levine, and C. Stein. Experimental study of minimum cut algorithms. In Proceedings of the 8th Annual ACM- SIAM Symposium on Discrete Algorithms (SODA '97), pages 324 -- 333. SIAM, 1997. [8] L. R. Ford and D. R. Fulkerson. Maximal flow through a network. Canadian Journal of Mathematics, 8(3):399 -- 404, 1956. [9] L. Gianinazzi, P. Kalvoda, A. De Palma, M. Besta, and T. Hoefler. Communication-avoiding parallel min- imum cuts and connected components. In Proceedings of the 23rd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, pages 219 -- 232. ACM, 2018. [10] A. V. Goldberg and R. E. Tarjan. A new approach to the maximum-flow problem. Journal of the ACM, 35(4):921 -- 940, 1988. [11] R. E. Gomory and T. C. Hu. Multi-terminal network flows. Journal of the Society for Industrial and Applied Mathematics, 9(4):551 -- 570, 1961. [12] J. Hao and J. B. Orlin. A faster algorithm for finding the minimum cut in a graph. In Proceedings of the 3rd Annual ACM-SIAM Symposium on Discrete Algorithms, pages 165 -- 174. Society for Industrial and Applied Mathematics, 1992. [13] M. Henzinger, A. Noe, C. Schulz, and D. Strash. Prac- tical minimum cut algorithms. In 2018 Proceedings of the Twentieth Workshop on Algorithm Engineering and Experiments (ALENEX), pages 48 -- 61. SIAM, 2018. [14] M. Henzinger, S. Rao, and D. Wang. Local flow partitioning for faster edge connectivity. In Proceedings of the 28th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1919 -- 1938. SIAM, 2017. [15] M. Junger, G. Rinaldi, and S. Thienel. Practical per- formance of efficient minimum cut algorithms. Algo- rithmica, 26(1):172 -- 195, 2000. [16] D. R. Karger. A randomized fully polynomial time approximation scheme for the all-terminal network reliability problem. SIAM Review, 43(3):499 -- 522, 2001. [17] D. R. Karger and C. Stein. A new approach to Journal of the ACM, the minimum cut problem. 43(4):601 -- 640, 1996. [18] K.-i. Kawarabayashi and M. Thorup. Deterministic global minimum cut of a simple graph in near-linear time. In Proceedings of the 47th Annual ACM Sympo- sium on Theory of Computing, pages 665 -- 674. ACM, 2015. [19] F. Khorasani, R. Gupta, and L. N. Bhuyan. Scalable simd-efficient graph processing on gpus. In Proceedings of the 24th International Conference on Parallel Archi- tectures and Compilation Techniques, PACT '15, pages 39 -- 50, 2015. [20] D. Krioukov, F. Papadopoulos, M. Kitsak, A. Vahdat, and M. Bogun´a. Hyperbolic geometry of complex networks. Physical Review E, 82(3):036106, 2010. [21] B. Krishnamurthy. An improved min-cut algorithm IEEE Transactions for partitioning VLSI networks. on Computers, 33(5):438 -- 446, 1984. [22] T. Maier, P. Sanders, and R. Dementiev. Concurrent hash tables: Fast and general?(!). In ACM SIGPLAN Notices, volume 51, page 34. ACM, 2016. [23] D. W. Matula. A linear time 2 + ε approximation In Proceedings of algorithm for edge connectivity. the 4th annual ACM-SIAM Symposium on Discrete Algorithms, pages 500 -- 504. SIAM, 1993. [24] H. Nagamochi and T. Ibaraki. Computing edge- connectivity in multigraphs and capacitated graphs. SIAM Journal on Discrete Mathematics, 5(1):54 -- 66, 1992. [25] H. Nagamochi, T. Ono, and T. Ibaraki. Implementing an efficient minimum capacity cut algorithm. Mathe- matical Programming, 67(1):325 -- 341, 1994. [26] M. Padberg and G. Rinaldi. An efficient algorithm for the minimum capacity cut problem. Mathematical Programming, 47(1):19 -- 36, 1990. [27] M. Padberg and G. Rinaldi. A branch-and-cut algo- rithm for the resolution of large-scale symmetric trav- eling salesman problems. SIAM Review, 33(1):60 -- 100, 1991. [28] L. Page, S. Brin, R. Motwani, and T. Winograd. The PageRank citation ranking: Bringing order to the web. Technical report, Stanford InfoLab, 1999. [29] U. N. Raghavan, R. Albert, and S. Kumara. Near lin- ear time algorithm to detect community structures in large-scale networks. Physical Review E, 76(3):036106, 2007. [30] A. Ramanathan and C. J. Colbourn. Counting almost minimum cutsets with reliability applications. Mathe- matical Programming, 39(3):253 -- 261, 1987. [31] S. B. Seidman. Network structure and minimum degree. Social Networks, 5(3):269 -- 287, 1983. [32] C. L. Staudt, A. Sazonovs, and H. Meyerhenke. Net- worKit: An interactive tool suite for high-performance network analysis. CoRR, abs/1403.3005, 2014. [33] M. Stoer and F. Wagner. A simple min-cut algorithm. Journal of the ACM, 44(4):585 -- 591, 1997. [34] M. von Looz, H. Meyerhenke, and R. Prutkin. Gener- ating random hyperbolic graphs in subquadratic time. In Proceedings of the 26th International Symposium on Algorithms and Computation (ISAAC 2015), volume 9472 of LNCS, pages 467 -- 478. Springer, 2015. [35] I. Wegener. Bottom-up-heapsort, a new variant of heapsort beating, on an average, quicksort (if n is not very small). Theoretical Computer Science, 118(1):81 -- 98, 1993. [36] J. W. J. Williams. Heapsort. Communications of the ACM, 7(6):347 -- 348, 1964. A Instances and Capforest Pseudocode A.1 Random Hyperbolic Graphs (RHG) [20]. Random hyperbolic graphs replicate many features of real-world networks [6]: the degree distribution follows a power law, they often exhibit a community structure and have a small diameter. In denser hyperbolic graphs, the minimum cut is often equal to the minimum degree, which results in a trivial minimum cut. In order to prevent trivial minimum cuts, we use a power law exponent of 5. We use the generator of von Looz et al. [34], which is a part of NetworKit [32], to generate unweighted random hyperbolic graphs with 220 to 225 vertices and an average vertex degree of 25 to 28. These graphs generally have very few small cuts and the minimum cut has two partitions with similar sizes. A.2 Real-world Graphs. We use large real-world web graphs and social networks from [2, 4, 5], detailed in Table 1. The minimum cut problem on these web and social graphs can be seen as a network reliability problem. As these graphs are generally disconnected and contain vertices with very low degree, we use a k- graph hollywood-2011 [4, 5] n m 2.2M 114M com-orkut [4, 5] uk-2002 [2, 4, 5] 3.1M 117M 18M 262M twitter-2010 [4, 5] 42M 1.2B gsh-2015-host [4, 5] 69M 1.8B uk-2007-05 [2, 4, 5] 106M 3.3B k 20 60 100 200 16 95 98 100 10 30 50 100 25 30 50 60 10 50 100 1000 10 50 100 1000 n m λ 1.3M 109M 1 87M 6 576K 328K 71M 77 139K 47M 27 2.4M 112M 14 18M 89 114K 17M 76 107K 103K 17M 70 9M 226M 1 2.5M 115M 1 51M 1 783K 98K 11M 1 13M 958M 1 10M 884M 1 4.3M 672M 3 3.5M 625M 3 25M 1.3B 1 5.3M 944M 1 2.6M 778M 1 104K 188M 1 1 68M 3.1B 16M 1.7B 1 3.9M 862M 1 222K 183M 1 δ 20 60 100 200 16 95 98 100 10 30 50 100 25 30 50 60 10 50 100 1000 10 50 100 1000 Table 1: Statistics of real-world web graphs used in experiments. Original graph size and k-cores used in experiments with their respective minimum cuts core decomposition [31, 3] to generate versions of the graphs with a minimum degree of k. The k-core of a graph G = (V, E) is the maximum subgraph G(cid:48) = (V (cid:48), E(cid:48)) with V (cid:48) ⊆ V and E(cid:48) ⊆ E, which fulfills the condition that every vertex in G(cid:48) has a degree of at least k. We perform our experiments on the largest connected component of G(cid:48). For every real-world graph we use, we compute a set of 4 different k-cores, in which the minimum cut is not equal to the minimum degree. We generate a diverse set of graphs with differ- ent sizes. On the large graphs gsh-2015-host and uk-2007-05, we use cores with k in 10, 50, 100 and 1000. In the smaller graphs we use cores with k in 10, 30, 50 and 100. twitter-2010 and com-orkut only had few cores where the minimum cut is not trivial. There- fore we used those cores. As hollywood-2011 is very dense, we multiplied the k value of all cores by a factor of 2. Algorithm 3 CAPFOREST Input: G = (V, E, c) ← undirected graph with integer edge weights, λ ← upper bound for minimum cut Output: T ← forest of contractible edges 1: Label all vertices v ∈ V "unvisited", blacklist B empty 2: ∀v ∈ V : r(v) ← 0 3: ∀e ∈ E : q(e) ← 0 4: Q ← empty priority queue 5: Insert random vertex into Q 6: while Q not empty do x ← Q.pop max() α ← α + c(x) − 2r(x) λ ← min(λ, α) for e = (x, y) ← edge to vertex y not in B and not visited do 9: 10: (cid:46) Choose unvisited vertex with highest priority if r(y) < λ ≤ r(y) + c(e) then (cid:46) Mark edge e to contract 7: 8: 11: 12: 13: 14: T ← T ∪ e end if r(y) ← r(y) + c(e) q(e) ← r(y) Q(y) ← r(y) 15: 16: 17: 18: 19: end while end for Mark x "visited"
1910.02569
1
1910
2019-10-07T01:03:59
Understanding Zadimoghaddam's Edge-weighted Online Matching Algorithm: Unweighted Case
[ "cs.DS", "cs.GT" ]
This article identifies a key algorithmic ingredient in the edge-weighted online matching algorithm by Zadimoghaddam (2017) and presents a simplified algorithm and its analysis to demonstrate how it works in the unweighted case.
cs.DS
cs
Understanding Zadimoghaddam's Edge-weighted Online Matching Algorithm: Unweighted Case Zhiyi Huang∗ Runzhou Tao† Last Update: October 2019 Abstract This article identifies a key algorithmic ingredient in the edge-weighted online matching algorithm by Zadimoghaddam (2017) and presents a simplified algorithm and its analysis to demonstrate how it works in the unweighted case. 1 Introduction Online edge-weighted bipartite matching is a major open problem in the area of online algorithms. Consider a bipartite graph G = (L, R, E) where L and R denote the sets of left-hand-side (LHS) and right-hand-side (RHS) vertices and E ⊆ L × R denotes the set of edges. Further, the graph is edge-weighted; every edge e ∈ E is associated with a nonnegative weight w(e) ≥ 0. The LHS is given upfront, while vertices on on the RHS arrive online one at a time. On the arrival of an online vertex j ∈ L, the algorithm observes the set of edges adjacent to j and, thus, the set of offline neighbors of j, denoted as N (j). The algorithm needs to immediately decide whether to match j to an offline neighbor, and if so which one. The algorithm is allow to match multiple online vertices and, thus, the corresponding edges to the same offline vertex, but only the one with the largest edge weight counts. This is equivalent to assuming that the algorithm can rematch an offline vertex to a new online vertex, disposing its previously matched online neighbor. Hence, it is also referred to as the free disposal model. The goal is to maximize the total weight of the matching. This problem generalizes the unweighted online bipartite matching problem by Karp et al. (1990) and the vertex-weighted problem by Aggarwal et al. (2011), both of which ∗The University of Hong Kong. Email: [email protected] †Columbia University. This work was done while the author was at IIIS, Tsinghua University. Email: [email protected] 1 admit online algorithms with the optimal 1− 1 e ratio also serves as an upper bound for the competitive ratio of any online algorithm for the edge-weighted problem considered in this article. e competitive ratio. The 1− 1 On the other hand, it is folklore that a simple greedy algorithm, which matches each online vertex to the offline neighbor that provides the maximum marginal gain (e.g., the weight of the new edge minus that of the previous one), is 1 2-competitive. Pinning down the optimal competitive ratio for the edge-weighted online bipartite match- ing problem between 1 e has been an open problem since at least Feldman et al. (2009). They study a variant that counts the heaviest n > 1 edges matched to each offline vertex; it can be viewed as a fractional version of the problem. 2 and 1 − 1 Zadimoghaddam (2017) introduces an algorithm and gives a competitive ratio that beats the 1 2 barrier; however, it is difficult to fully understand the algorithm and its analysis even for experts. We seek to provide an alternative and more accessible exposition of the algorithm and analysis by Zadimoghaddam (2017), fixing any minor bugs therein. To this end, this article identifies one technical ingredient in the original paper that we believe to be the key of breaking the 1 2 barrier. This ingredient is the only thing that we keep from the original paper by Zadimoghaddam (2017), with minor changes; we take the liberty to change everything else wherever we see fit to improve the exposition. This article is devoted to introducing this technical ingredient and explaining how it works in the special case of unweighted graphs, i.g., all edges have unit weight. Generalization to the weighted case will be covered in a follow-up article. Finally, due to the nature of this article, we will generally prioritize for simplicity of the algorithm and analysis rather than optimality of the competitive ratio. 2 Online Primal Dual This section presents a brief introduction of the online primal dual framework for analyzing the competitive ratios of online matching algorithms. It is widely used in the literature of online algorithms in general, and is developed for online matching in a series of papers by Buchbinder et al. (2007), Devanur and Jain (2012), Devanur et al. (2013), Wang and Wong (2015), Devanur et al. (2016), Huang et al. (2018a), Huang et al. (2018b), Huang et al. (2019). See Devanur et al. (2013) for an in-depth discussion on this topic. Recall that this article focuses on the special case of unweighted graphs. Consider the 2 following standard matching linear program (LP): maximize subject to (cid:88) (cid:88) (cid:88) (i,j)∈E j∈N (i) i∈N (j) xij ≥ 0 xij xij ≤ 1 xij ≤ 1 ∀i ∈ L ∀j ∈ R ∀(i, j) ∈ E In the offline problem, xij is the indicator of whether edge (i, j) is in the matching. Recall that we allow an offline vertices to be matched multiple times in the online problem, but each offline vertex contributes at most 1 in the objective. Further, the online algorithm may be randomized. To this end, we may informally interpret xij as the probability that edge (i, j) is the first edge matched to vertex i by the online algorithm. Next, consider the following dual LP: (cid:88) (cid:88) minimize αi + j∈R subject to αi + βj ≥ 1 i∈L βj ∀(i, j) ∈ E ∀i ∈ L ∀j ∈ R αi ≥ 0 βj ≥ 0 Let P and D denote the values of the primal and dual objectives respectively. Let A denote the expected objective of the algorithm. An online primal dual analysis maintains a pair of nonnegative primal and dual assignments at all time satisfying a set of conditions formulated in the next lemma. Lemma 1. Suppose for some 0 < Γ ≤ 1, the following conditions hold at all time: 1. (Objectives) A ≥ P ≥ D. 2. (Approximate Dual Feasibility) For any edge (i, j) ∈ E that has arrived, we have: Then, the algorithm is Γ-competitive. αi + βj ≥ Γ . 3 Proof. Since the conditions hold at all time, they hold at the end of the algorithm. By the second condition, dividing the dual assignment by Γ gives a feasible dual. Hence, Γ−1 · D is the objective of a feasible dual. By weak duality of LP, it is an upper bound of the optimal. Putting together with the first condition proves the lemma. A canonical online primal dual analysis usually sets the primal faithfully according to the matching maintained by the online algorithm: let xij be the probability that edge (i, j) is the first edge matched to vertex j. Then, we have the first inequality in the objective condition holds with equality, i.e., A = P. Further, the typical way of setting the dual can be viewed as a gain splitting process. Whenever an edge (i, j) is chosen by the online algorithm and it is the first edge matched to the offline vertex i, the primal objective increases by 1 and, thus, a total gain of 1 is split between αi and βj. That is, αi and βj are increase by their respectively amounts which sum to 1. If the algorithm is randomized, the dual variables will be the expected share that the vertices get in the gain splitting process. The gain splitting process needs to be tailored for the problem and algorithm at hand to satisfy the approximate dual feasibility condition. Then, the increment in the primal objective always matches that in the dual objective and, thus, the second inequality in the objective condition also holds with equality, i.e., P = D. 3 Thought Experiments This section presents two failing algorithms as thought experiments in order to build up the intuition that leads to the final algorithm. The online primal dual analysis in this section follows the aforementioned canonical format. 3.1 Two-choice Greedy Let us start with a simple greedy algorithm that always matches to the neighbor(s) with the largest marginal gain, which equals the probability that the neighbor is still unmatched, over the randomness in previous rounds. To be consistent with the subsequent discussions, we consider a greedy algorithm that, in the presence of at least two neighbors both with the largest marginal gain, picks two of them as candidates, say, lexicographically, and matches to them with equal probabilities. We say that such a round that manages to find two candidates is randomized ; a round that finds only one candidate is deterministic. If all neighbors have already been matched with certainty, it is an unmatched round. On the one hand, the marginal gain of a vertex i ∈ L becomes 0 once it gets involved in a deterministic round and, thus, is no longer relevant in future rounds. On the other hand, the 4 Algorithm 1 Two-choice Greedy State variables: • ki ≥ 0, number of randomized rounds in which an offline vertex i has been chosen; ki = ∞ if it has been chosen in a deterministic round. On the arrival of an online vertex j ∈ R: 1. Let B(j) = arg mini∈N (j) ki be the set of neighbors of j with the smallest finite ki. 2. If B(j) ≥ 2, pick two neighbors i1, i2 ∈ B(j), say, lexicographically; match j to i1 (randomized round) or i2 each with probability 1 2. 3. If B(j) = 1, let i ∈ B(j); match j to i. 4. If B(j) = 0, leave j unmatched. 5. Update ki's accordingly. (deterministic round) (unmatched round) marginal gain of a vertex i ∈ L decreases by half every time it gets involved in a randomized round. Hence, the neighbors with the largest marginal gain are those that are never involved in any deterministic round, and are involved in the fewest number of randomized rounds. See Algorithm 1 for a formal definition. Theorem 1. Two-choice greedy is 1 2-competitive and it is tight for the algorithm. 3.1.1 Competitive Ratio: Lower Bound Experts may skip this subsection. It merely serves as a warm-up case for other readers to get familiar with the online primal dual framework. that edge (i, j) is the first edge matched to vertex i by the algorithm. Let xi =(cid:80) Consider the following online primal dual analysis. At all time, let xij be the probability j∈N (i) xij be the probability that an offline vertex i is matched. For each online vertex j ∈ R, update the primal and dual variables as follows by splitting the gain equally between the two endpoints for every edge (xij's are 0 by default unless stated otherwise). • Randomized rounds: Suppose it is a randomized round, with kmin = mini∈N (j) ki at the time of the match. Suppose i1 and i2 are the chosen neighbors. Then, let xij be 2−kmin−1 and, thus, increase xi by the same amount, for i = i1, i2. Increase αi by 2−kmin−2 for i = i1, i2, and let βj = 2−kmin−1. • Deterministic rounds: Suppose it is a deterministic round, with kmin = mini∈N (j) ki at the time of the match, and i is the chosen neighbor. Then, let xij be 2−kmin and, thus, increase xi by the same amount (after which it equals 1). Increase αi by 2−kmin−1 (after which it equals 1 2), and let βj = 2−kmin−1. 5 • Unmatched rounds: Suppose it is an unmatched round. Then, let βj = 0. The next few lemmas follow straightforwardly by how the variables are updated above. Lemma 2. For any offline vertex i, we have at all time: xi = 1 − 2−ki . Lemma 3. For any offline vertex i, we have at all time: 1 − 2−ki 2 . αi = Lemma 4. The primal and dual objectives are equal at all time. It remains to analyze approximate dual feasibility, as stated in the next lemma. Lemma 5. For any edge (i, j) ∈ E, we have the following at the end of the algorithm: αi + βj ≥ 1 2 . Proof. Consider the moment when vertex j arrives and the value of ki then. By Lemma 3, we have: 1 − 2ki αi = . 2 Further, let kmin = arg mini(cid:48)∈N (j) ki(cid:48) at the time. Note that kmin ≤ ki. If it is a randomized round or a deterministic round, we have: βj = 2−kmin−1 ≥ 2−ki−1 . Thus, together with the above bound of αi, we get the inequality stated in the lemma. If it is an unmatched round, we have ki = kmin = ∞, and βi = 0. The contribution from αi alone satisfies the inequality stated in the lemma. 3.1.2 Competitive Ratio: Upper Bound For ease of presentation, we consider a version of the algorithm which picks neighbors in the reverse lexicographical order in randomized rounds. Consider the following instance. Example 1. Consider a bipartite graph with n = 3k vertices on both sides for some large 3 = 3k−1 online vertices are connected to all offline vertices. Then, the integer k. The first n 3 = 2 · 3k−2 of them in total, are first one third of the remaining online vertices, i.e., 1 3 · 2n 6 connected to the last 2n one third of the last(cid:0) 2 to the last(cid:0) 2 3 = 2 · 3k−1 offline vertices. In general, for any 0 ≤ i < k, the first (cid:1)in = 2i · 3k−i vertices, i.e., 2i · 3k−i−1 of them in total, are connected (cid:1)in = 2i · 3k−i offline vertices. Finally, let there be a perfect matching between 3 3 the last 2k offline vertices and the last 2k online vertices. First, note that there is a perfect matching, with the i-the online vertex matching to the i-th offline vertex. Hence, the optimal is n. Next, consider the performance of the online algorithm. The first n 3 = 3k−1 vertices are connected to all offline vertices. They are matched to the last 2 3 fraction of the offline vertices in randomized rounds. That is, their correct neighbors in the perfect matching are left unmatched, while other offline vertices are matched by half. Then, the first one third of 3 = 2 · 3k−2 of them in total, are matched to the last the remaining online vertices, i.e., 1 ( 2 3)2 fraction of the offline vertices in randomized rounds. That is, their correct neighbors in the perfect matching are left matched by only half, while the correct neighbors of subsequent online vertices are now matched by three quarters. The argument goes on recursively. 3 · 2n Therefore, omitting a lower order term due to the last 2k = nlog3 2 vertices on both sides, the expected size of the matching is: (cid:18) 1 · 1 3 + 1 2 · 2 9 + ··· + (cid:18)1 2 (cid:19)k · 2k 3k+1 + ··· (cid:19) (cid:18)1 3 . n 2 n = = (cid:19) n + 1 9 + ··· + 1 3k+1 + ··· 3.2 Greedy with Perfect Negative Correlation Next, we consider an imaginary version of the two-choice greedy algorithm that is almost identical to the original version, except that the random bits associated with the same offline vertex in different randomized rounds have perfect negative correlation: if an offline vertex i is not matched the first time it is chosen in a randomized round, it will be matched the second time. It is in general impossible to achieve such perfect negative correlations in the online setting. See Section 3.2.3 for a brief discussion. Nevertheless, this subsection presents an online primal dual analysis of this algorithm assuming its feasibility as a thought experiment, to demonstrate that negative correlations lead to a competitive ratio better than 1 2. Theorem 2. Two-choice greedy with perfect negative correlation, if feasible, is 5 and it is tight for the algorithm. 9-competitive 7 3.2.1 Competitive Ratio: Lower Bound first edge matched to vertex i in the algorithm. Let xi =(cid:80) Let Γ = 5 9. We will show that greedy with perfect negative correlation is Γ-competitive via an online primal dual argument as follows. Let xij be the probability that edge (i, j) is the j∈N (i) xij be the probability that an offline vertex i is matched. For each online vertex j ∈ R, update the primal and dual variables as follows. • Randomized rounds: Suppose it is a randomized round, with kmin = mini∈N (j) ki at the time of the match, and i1 and i2 are the chosen neighbors. Then, let xij be 1 2 and, thus, increase xi by the same amount, for i = i1, i2. If kmin = 0, i.e., it is the first time i1 and i2 are chosen in randomized rounds, increase αi by 1−Γ for i = i1, i2, and let βj = Γ. If kmin = 1, i.e., it is the second time i1 and i2 are chosen in randomized rounds, increase αi by 3(1−Γ) for i = i1, i2, and let βj = 3Γ−1 . 2 4 2 • Deterministic rounds: Suppose it is a deterministic round, with kmin = mini∈N (j) ki at the time of the match, and i is the chosen neighbor. Then, let xij be 2−kmin and, thus increase xi by the same amount (after which it equals 1). If kmin = 0, i.e., vertex i has never been chosen in randomized rounds, increase αi by Γ, and let βj = 1 − Γ. If kmin = 1, i.e., vertex i was chosen in a randomized round before j's arrival, increase αi by 3(1−Γ) , and let βj = 3Γ−1 . 4 4 • Unmatched rounds: Suppose it is an unmatched round. Then, let βj = 0. Note that for any offline vertex i, the value of xi is either 0, or 1 2, or 1. Concretely, xi = 0 if it has never been chosen in any randomized or deterministic rounds; xi = 1 2 if it is chosen in exactly one randomized round but not in any deterministic rounds; xi = 1 if either it is chosen in two randomized rounds, or it is chosen in a deterministic round. We first present the lower bounds of αi for different values of xi. Lemma 6. For any offline vertex i: αi =  0 1−Γ 2 Γ if xi = 0; if xi = 1 2; if xi = 1. Proof. The first two cases follow by definition. The last case also follows by definition if xi directly changes from 0 to 1 in a deterministic round. If xi first increases from 0 to 1 2 in a randomized round and then further increases to 1 either in a deterministic round or a 8 randomized round, the value of αi is: 1 − Γ 2 + 3(1 − Γ) 4 = 5(1 − Γ) 4 = Γ . where the second equality follows by Γ = 5 9. The next lemma follows by the definition of the online primal and dual updates. Lemma 7. The primal and dual objectives are equal at all time. It remains to analyze approximate dual feasibility, as stated in the next lemma. Lemma 8. For any edge (i, j) ∈ E, we have the following at the end of the algorithm: αi + βj ≥ Γ . Proof. Consider the moment when vertex j arrives and the value of ki then. Case 1: ki = 0. In this case, we have xi = 0 and αi = 0 at the time when j arrives. If it is a randomized round, we get that βj = Γ and, thus, the inequality follows. If it is a deterministic round, it must be the case that j is matched to i and, thus, αi + βj = 1. In this case, we have xi = 1 Case 2: ki = 1. If it is a randomized round, we have βj = Γ if kmin = 0, and 3Γ−1 deterministic round with kmin = 0, we have βj = 1 − Γ. Therefore: 2 = 2 2 9 at the time when j arrives. if kmin = 1. If it is a 2 and αi = 1−Γ (cid:27) (cid:26)5 = min (cid:27) 1 3 , 4 9 , 9 = 1 3 . (cid:26) 3Γ − 1 2 Γ, , 1 − Γ βj ≥ min Hence, we get that: αi + βj ≥ 2 9 + 1 3 = 5 9 = Γ . If it is a deterministic round with kmin = 1, on the other hand, it must be the case that 9 before the arrival of j, αi and βj j is matched to i. As a result, on top of having αi = 2 further split the gain of 1 2 due to j. In total, we have: αi + βj = 2 9 + 1 2 > Γ . Case 3: ki = 2 or ∞. In this case, we have αi = Γ and, thus, the inequality follows. 9 3.2.2 Competitive Ratio: Upper Bound Consider the same instance for the vanilla version, but keeping only the first two rounds. Concretely, let there be a bipartite graph with 9 vertices on each side, denoted as i1, i2, . . . , i9 and j1, j2, . . . , j9, and a perfect matching with ik matched to jk for k = 1, 2, . . . , 9. The first three online vertices, j1, j2, and j3, are connected to all offline vertices. After their arrivals, i1, i2, and i3 are unmatched while the remaining 6 offline vertices are matched by half. Then, the next two online vertices, j4 and j5, are connected to the last 6 offline vertices, i.e., j4 to j9. After their arrival, i4 and i5 remain matched by half, while i6 to i9 are fully matched. 2 · 2 + 1 · 4 = 5 in expectation, while the Therefore, the algorithm finds a matching of size 1 optimal matching has size 9. The ratio is 5 9, matching the lower bound that we show. 3.2.3 Infeasibility This subsection presents an example demonstrating that two-choice greedy with perfect negative correlation is infeasible in the online setting. Consider a graph with 4 offline vertices, denoted as 1 to 4. The first online vertex, denoted as 5, is connected to 1 and 2. The second online vertex, denoted as 6, is connected to 3 and 4. The third online vertex, denoted as 7, has two possibilities: it is connected with either 1 and 3, or 1 and 4. In the former case, the following pairs of edges have perfect negative correlations: (1, 5) and (2, 5), (1, 7) and (3, 7), (1, 5) and (1, 7), and (3, 6) and (3, 7). The first two pairs are due to having the same online vertex; the last two pairs are due to having the same offline vertex. Hence, we can deduce that (2, 5) and (3, 6) have perfect positive correlation. In the latter case, however, a similar argument gives that (2, 5) and (3, 6) have perfect negative correlation. An online algorithm cannot handle both cases simultaneously since the correlation between (2, 5) and (3, 6) are determined before the arrival of vertex 7 in the online setting. 4 Greedy with Partial Negative Correlation This section presents the actual algorithm and its analysis. For any (cid:96) ∈ {1, 2}, let −(cid:96) denote the other element in {1, 2}, i.e., 3 − (cid:96). 4.1 Online Correlated Selection The main ingredient is a subroutine which we will refer to as the online correlated selection (OCS). See Algorithm 2. Informally, the OCS ensures that (1) the marginal distribution of any particular round is uniform over the candidates, and (2) for any fixed offline vertex, the randomness in the 10 Algorithm 2 Online Correlated Selection (OCS) State variables: • τi ∈(cid:8)matched, unmatched, unknown(cid:9) for each offline vertex i ∈ L; initially, let τi = unknown. On receiving 2 candidate offline vertices i1 and i2 (for an online vertex j ∈ R): 1. With probability 1 2, let it be an oblivious step: (a) Draw (cid:96), m ∈ {1, 2} uniformly at random. (b) Let τi−m = unknown. (c) If m = (cid:96), let τim = matched; otherwise, let τim = unmatched. 2. Otherwise (i.e., with probability 1 2), let it be an adaptive step: (a) Draw m ∈ {1, 2} uniformly at random. (b) If τim = matched, let (cid:96) = −m; if τim = unmatched, let (cid:96) = m; if τim = unknown, draw (cid:96) ∈ {1, 2} uniformly at random. (c) Let τi1 = τi2 = unknown. 3. Return i(cid:96). rounds in which it is a candidate is partially negatively correlated. Therefore, the probability that a vertex is matched after k randomized rounds is strictly greater than 1 − 2−k for any k ≥ 2. See Lemma 9 for a precise statement. We now demonstrate how it works. It maintains a state variable τi for each offline vertex i ∈ L. If the state τi is equal to matched or unmatched, it reflects the matching status of i the last time when i is an candidate, and indicates that the information can be used the next time when i is a candidate. If the state τi is equal to unknown, it means that the matching status of offline vertex i cannot be used the next time when i is a candidate. For each randomized round in the two-choice greedy algorithm, where i1 and i2 are the candidates, the OCS picks one of the two candidates as follows. First, it decides whether this is an oblivious step, or an adaptive step uniformly at random. In an oblivious step, it uses a fresh random bit to determines its choice i(cid:96), (cid:96) ∈ {1, 2}, to be returned in this round. Then, it draws m ∈ {1, 2} uniformly at random and sets τim to reflect its matching status in this round; τi−m is set to unknown. That is, the OCS forwards the random bit in this round to subsequent rounds for only one of the two candidates, chosen uniformly at random. In an adaptive step, on the other hand, the OCS seeks to use the previous matching status of the candidates to determine its choice of i(cid:96). First, it draws m ∈ {1, 2} uniformly 11 at random, and checks the state variable of im. To achieve negative correlation, the OCS let the matching status of im in this round to be the opposite of the state. That is, if the state was matched, indicating that im was matched the last time when it was a candidate, the OCS would choose i−m this time, and vice versa; if the state variable was equal to unknown, the OCS would use a fresh random bit to determine i(cid:96). In either case, reset the states of both i1 and i2 to be unknown. Lemma 9. For any fixed sequence of pairs of candidates, any offline vertex i, and any k ≥ 0, the OCS ensures that after being a candidate k times, i is matched with probability at least 1 − 2−k · fk, where fk is defined recursively as: (1) 1 fk = 2}, P 2 = {i2 1, i2 1, i1 fk−1 − 1 16fk−2 2}, . . . , P T = {iT k = 0, 1 k ≥ 2 2 } be the sequence of pairs of candi- Proof. Let P 1 = {i1 date offline vertices. We start with an interpretation of the OCS in the language of graphs. First, consider a graph Gex-ante = (V, Eex-ante) as follows which we shall refer to as the ex- ante dependence graph. To make a distinction with the vertices and edges in the matching problem, we shall refer to the vertices and edges in the dependence graph as nodes and arcs respectively. Let there be a node for each pair of candidates; we will refer to them as 1 ≤ t ≤ T , i.e.: 1 , iT V =(cid:8)t : 1 ≤ t ≤ T(cid:9) . Further, for any fixed offline vertex i, let there be a directed arc from t1 to t2 for any two consecutive times in which i is a candidate, i.e.: Eex-ante =(cid:8)(t1, t2) : t1 < t2;∃i ∈ L s.t. i ∈ P t1, i ∈ P t2, and ∀t1 < t < t2, i /∈ P t(cid:9) . See Figure 1a for an example. Each arc in the ex-ante dependence graph represents two steps in the sequence in which the OCS may use the same random bit to determine the offline vertices it returns. There are at most 2 outgoing arcs and at most 2 incoming arcs for each node by definition. In particular, consider any arc (t1, t2) in the ex-ante dependence graph, with i being the common candidate. If the randomness used by the OCS is such that (1) step t1 is an oblivious step, (2) im = i in step t1, (3) step t2 is an adaptive step, and (4) im = i in step t2, the matching status of i would be perfectly negatively correlated in the sense that i is chosen in exactly one of the two steps. Each of the 4 events happens independently with 12 (a) Ex-ante dependence graph (b) Ex-post dependence graph (bold and solid edges) (c) Dependence subgraph associated with a fixed candidate offline vertex, e.g., vertex a Figure 1: An example with 5 offline vertices and a sequence of 7 pairs probability 1 2. The ex-post dependence graph Gex-post = (V, Eex-post) is a subgraph of the ex-ante depen- dence graph, keeping the arcs which correspond to the pairs of time steps that are perfectly negatively correlated, given the realization of whether each step is oblivious or adaptive, and the value of m therein. Equivalently, the ex-post dependence graph is realized as follows. Over the randomness with which the OCS decides whether each step is oblivious or adap- tive, and the value of m, each node in the ex-ante dependence graph picks at most one of its incident arcs, each with probability 1 4; an arc is realized in the ex-post graph if both incident nodes pick it. With this interpretation, we get that the ex-post graph is a matching. The OCS may be viewed as a randomized online algorithm that picks a matching of the ex-ante graph, such that each arc in the ex-ante graph is chosen with probability lower bounded by 13 4235167()=+,-(.=-,/(0=+,/(1=+,2(3=+,/(4=-,2(5=2,64235167()=+,-(.=-,/(0=+,/(1=+,2(3=+,/(4=-,2(5=2,6()=+,-(.=-,/(0=+,/(1=+,2(3=+,/(4=-,2(5=2,64235167 a constant. See Figure 1b for an example. Finally, we lower bound the probability that an offline vertex i remains unmatched after being a candidate in k steps in the sequence. Let t1 < t2 < . . . be the time steps in which i is a candidate. We will use offline vertex a and k = 4 in Figure 1c as a running example, where t1 = 1, t2 = 3, t3 = 5, t4 = 7 and the relevant arcs in the dependence graphs are (1, 3), (3, 5), (3, 7), and (5, 7). If at least one of the arcs among t1 < t2 < ··· < tk are realized in the ex-post dependence graph, vertex i must be matched after step tk. This is because the randomness (related to the choice of (cid:96) in the OCS) is perfectly negatively correlated in the two incident nodes of the arc and thus, i is chosen exactly once in these two steps. For example, given that the arc (3, 7) is realized in Figure 1c, vertex a must be matched after step 7. On the other hand, if none of these arcs are realized, the random bits used in the k steps t1 < t2 < ··· < tk are independent. For example, consider vertex a and k = 3 in Figure 1c; vertex a is chosen independently with probability 1 2 in steps t1 = 1, t2 = 3, and t3 = 5, given that neither (1, 3) nor (3, 5) is realized. Importantly, even if some of these steps are adaptive in that the matching decisions are based on the random bits realized earlier in some oblivious steps, from i's viewpoint, they are still independent of the random bits in the other rounds that i is involved in. For example, from c's viewpoint in Figure 1c, even though the matching decision in step 2 is determined by that in step 1, it is independent of the matching decisions in steps 3 and 7 that c is involved in. Putting together, the probability that i is unmatched after steps t1 < t2 < ··· < tk is equal to (1) the probability that none of the arcs among these steps is realized, times (2) all k independent random bits are against i. The latter is equal to 2−k. It remains to analyze the former; we shall upper bound it by the probability that none of the arcs (t1, t2), (t2, t3), . . . , (tk−1, tk) is realized. Denote this event as Fk and its probability as fk. Trivially, we have f0 = f1 = 1. To prove that the stated recurrence in Eqn. (1) governs fk, we further divide the event Fk into two subevents. Let Ak the event that none of the arcs (t1, t2), (t2, t3), . . . , (tk−1, tk) is realized, and step tk picks arc (tk, tk+1) in realizing the ex-post dependence graph. Let Bk be the event that none of the arcs is realized and step tk does not pick arc (tk, tk+1). Let ak and bk be the probability of Ak and Bk respectively. We have that Ak and Bk form a partition of Fk, and thus: fk = ak + bk . If step tk picks arc (tk, tk+1), which happens with probability 1 4, arc (tk−1, tk) must not 14 be realized by definition. Therefore, conditioned on the choice of tk, Ak happens if and only if the choices made by steps t1, t2, . . . tk−1 is such that none of (t1, t2), . . . , (tk−2, tk−1) is realized, i.e., when Fk−1 happens. That is: ak = 1 4 fk−1 . On the other hand, if step tk does not pick (tk, tk+1), there are two possibilities. The first case is when tk picks (tk−1, tk), which happens with probability 1 In this case, the 4. choices made by t1, . . . , tk−1 must be such that none of (t1, t2), . . . , (tk−2, tk−1) is realized, and tk−1 does not pick (tk−1, tk), i.e., Bk−1 happens. The second case is when tk picks neither (tk−1, tk) nor (tk, tk+1), which happens with probability 1 2. In this case, the choices made by t1, . . . , tk−1 must be such that none of (t1, t2), . . . , (tk−2, tk−1) is realized, i.e., Fk−1 happens. Putting together, we have: bk = 1 4 bk−1 + 1 2 fk−1 . Eliminating ak's and bk's by combining the above three equations, we get the recurrence stated in Eqn. (1). In fact, we can show a stronger version, which will be useful in the weighted case. We say that t1 < t2 < ··· < tk is a consecutive sequence of rounds in which i is involved if i is a candidate in these rounds, but in no other rounds in between. Lemma 10. For any fixed sequence of pairs of candidates, any fixed candidate i, and any disjoint consecutive sequences of rounds of lengths k1, k2, . . . , km ≥ 1 in which i is involved, the OCS in Algorithm 2 ensures that i is chosen in at least one of the rounds with probability at least: 1 − m(cid:89) (cid:96)=1 2−k(cid:96) · fk(cid:96) . 1 < t(cid:96) 2 < . . . , t(cid:96) k(cid:96) (cid:96)=1 k(cid:96) random bits are against i. The latter is (cid:81)m Proof. Let t(cid:96) be the (cid:96)-th consecutive sequence of round in which i is involved, for any 1 ≤ (cid:96) ≤ m. The probability that i is never chosen is equal to (1) the probability that none of the arcs among the steps in these sequences is realized, times (2) the probability (cid:96)=1 2−k(cid:96). We upper bound the former with the probability that for any 1 ≤ (cid:96) ≤ m, none of the arcs (t(cid:96) k(cid:96)−1t(cid:96) ) k(cid:96) is realized. Further, note that the events are independent for different (cid:96), as each event only relies on the choice made by the nodes in the corresponding subsequence. Hence, it is at 1, t(cid:96) 2), . . . , (t(cid:96) that all (cid:80)m most(cid:81)m (cid:96)=1 fk(cid:96). 15 4.2 Beating 1 2 Using the OCS Finally, we show that the two-choice greedy algorithm is strictly better than 1 2-competitive when it is combined with the OCS to have partial negative correlation in the randomized rounds. Theorem 3. Two-choice greedy, with the randomized rounds implemented using the OCS, is at least Γ = 0.505-competitive. Proof. We will maintain xi = 1 − 2−ki · fki for each offline vertex i as a lower bound of the probability that i is matched. For each online vertex j, let xij be the increment in xi due to j. Then, we have: (cid:88) i∈L P = xi . Recall that A denote the expected objective given by the algorithm. The choices of B(j)'s by the two-choice greedy algorithm is independent of the random bits used by the OCS. Therefore, the sequence of pairs of candidates in the randomized rounds, which are sent to the OCS, is fixed. By Lemma 9, we have: A ≥ P . To prove the stated competitive ratio, it remains to explain how to maintain a dual assignment such that (1) the dual objective is no more than the primal one, i.e., D ≤ P, and (2) it is approximately feasible up to a Γ factor, i.e., αi + βj ≥ Γ for every edge (i, j). Dual Updates It is based on the solution to the LP in the following lemma, whose proof is deferred to the end of the subsection. Lemma 11. The optimal value of the LP below is at least 0.505: maximize Γ subject to ∆α(k) + β(k) ≤ 2−k · fk − 2−k−1 · fk+1 1 2 k−1(cid:88) ∆α((cid:96)) + β(k) ≥ Γ (cid:96)=0 β(k) ≥ β(k + 1) ∆α(k), β(k) ≥ 0 16 ∀k ≥ 0 ∀k ≥ 0 ∀k ≥ 0 ∀k ≥ 0 (2) (3) (4) Consider an online vertex j ∈ R. Let kmin = mini∈N (j) ki be the minimum number of randomized rounds in which a fixed neighbor of j is a candidate. Suppose it is a randomized round. Then, we have ki = kmin for both i ∈ B(j). For both i ∈ B(j), xi increases by 2−kmin ·fkmin −2−kmin−1·fkmin+1. In the dual, increase αi by ∆α(kmin) for both i ∈ B(j), and let βj = β(kmin). Suppose it is a deterministic round. Let i be the only vertex in B(j). Then, xi increases by 2−kmin · fkmin. In the dual, increase αi by(cid:80) No update is needed in an unmatched round, as P remains the same. Objective Comparisons (cid:96)≥kmin ∆α((cid:96)), and let βj = β(kmin + 1). Next, we show that the increment in the dual objective D is at most that in the primal objective P. In a randomized round, it follows by Eqn. (2). In a deterministic round, it follows by a sequence of inequalities below: (cid:88) (cid:96)≥ki ∆α((cid:96)) + β(ki + 1) ≤(cid:88) ≤(cid:88) ≤(cid:88) (cid:96)≥ki (cid:96)≥ki (cid:96)≥ki 1 2 β(ki + 1) 1 2 β(ki) + ∆α((cid:96)) + (cid:0)∆α((cid:96)) + β((cid:96))(cid:1) (cid:0)2−(cid:96) · f(cid:96) − 2−(cid:96)−1 · f(cid:96)+1 1 2 (cid:1) (Eqn. (4)) (Eqn. (2)) = 2−ki · fki . Approximate Dual Feasibility. We first summarize the following invariants which follow by the definition of the dual updates. • For any offline vertex i ∈ L, αi =(cid:80)ki−1 (cid:96)=0 ∆α((cid:96)). • For any online vertex j, βj = β(k) if it is matched either in a randomized round to neighbors with ki = k, or in a deterministic round to a neighbor with ki = k − 1. 17 For any edge (i, j) ∈ E, consider the value of ki at the time when j arrives. If ki = ∞, the value of αi alone ensures approximately dual feasibility because: αi = ∆α((cid:96)) (cid:88) (cid:96)≥0 k−1(cid:88) (cid:96)=0 = lim k→∞ ∆α((cid:96)) ≥ Γ − lim k→∞ β(k) (Eqn. (3)) = Γ . (Eqn. (2), whose RHS tends to 0) Otherwise, by the definition of the two-choice greedy algorithm, j is matched either in a randomized round to two vertices with ki(cid:48) ≤ ki, or in a deterministic round to a vertex with ki(cid:48) < ki. In both cases, we have: Approximate dual feasibility now follows by αi =(cid:80)ki−1 βj ≥ β(ki) . (cid:96)=0 ∆α((cid:96)) and Eqn. (3). Proof of Lemma 11. Consider a restricted version of the LP which is finite. For some positive kmax, let ∆α(k) = β(k) = 0 for all k > kmax. Then, it becomes: maximize Γ subject to ∆α(k) + β(k) ≤ 2−k · fk − 2−k−1 · fk+1 0 ≤ k ≤ kmax 1 2 k−1(cid:88) kmax(cid:88) (cid:96)=0 ∆α((cid:96)) + β(k) ≥ Γ ∆α((cid:96)) ≥ Γ (cid:96)=0 β(k) ≥ β(k + 1) ∆α(k), β(k) ≥ 0 0 ≤ k ≤ kmax 0 ≤ k < kmax 0 ≤ k ≤ kmax See Table 1 for an approximately optimal solution for the relaxed LP with kmax = 7. It gives an objective Γ ≈ 0.5051. 18 k 0 1 2 3 4 5 6 7 fk 1.00000000 1.00000000 0.93750000 0.87500000 0.81640625 0.76171875 0.71069336 0.66308594 ∆α(k) 0.24744702 0.13679553 0.06456829 0.03020205 0.01417514 0.00674016 0.00333533 0.00184246 β(k) 0.50510596 0.25765895 0.12086342 0.05629513 0.02609308 0.01191794 0.00517779 0.00184246 Table 1: An approximately optimal solution to the restricted LP for kmax = 7, rounded to the 8-th digit after the decimal point, whose Γ ≈ 0.5051. References Gagan Aggarwal, Gagan Goel, Chinmay Karande, and Aranyak Mehta. Online vertex- weighted bipartite matching and single-bid budgeted allocations. In Proceedings of the 22nd Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1253 -- 1264. SIAM, 2011. Niv Buchbinder, Kamal Jain, and Joseph Seffi Naor. Online primal-dual algorithms for maximizing ad-auctions revenue. In European Symposium on Algorithms, pages 253 -- 264. Springer, 2007. Nikhil R Devanur and Kamal Jain. Online matching with concave returns. In Proceedings of the 44th Annual ACM Symposium on Theory of Computing, pages 137 -- 144. ACM, 2012. Nikhil R Devanur, Kamal Jain, and Robert D Kleinberg. Randomized primal-dual analysis of ranking for online bipartite matching. In Proceedings of the 24th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 101 -- 107. SIAM, 2013. Nikhil R Devanur, Zhiyi Huang, Nitish Korula, Vahab S Mirrokni, and Qiqi Yan. Whole-page optimization and submodular welfare maximization with online bidders. ACM Transac- tions on Economics and Computation (TEAC), 4(3):14, 2016. Jon Feldman, Nitish Korula, Vahab Mirrokni, S. Muthukrishnan, and Martin P´al. Online ad assignment with free disposal. In Proceedings of the 5th International Workshop on Internet and Network Economics, pages 374 -- 385. Springer Berlin Heidelberg, 2009. Zhiyi Huang, Ning Kang, Zhihao Gavin Tang, Xiaowei Wu, Yuhao Zhang, and Xue Zhu. How to match when all vertices arrive online. In Proceedings of the 50th Annual ACM Symposium on Theory of Computing, pages 17 -- 29. ACM, 2018a. 19 Zhiyi Huang, Zhihao Gavin Tang, Xiaowei Wu, and Yuhao Zhang. Online vertex-weighted bipartite matching: beating 1− 1 e with random arrivals. In Proceedings of the 45th Interna- tional Colloquium on Automata, Languages, and Programming. Schloss Dagstuhl-Leibniz- Zentrum fuer Informatik, 2018b. Zhiyi Huang, Binghui Peng, Zhihao Gavin Tang, Runzhou Tao, Xiaowei Wu, and Yuhao Zhang. Tight competitive ratios of classic matching algorithms in the fully online model. In Proceedings of the 30th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 2875 -- 2886. SIAM, 2019. Richard M Karp, Umesh V Vazirani, and Vijay V Vazirani. An optimal algorithm for on-line bipartite matching. In Proceedings of the 22nd ACM Symposium on Theory of Computing, pages 352 -- 358. ACM, 1990. Yajun Wang and Sam Chiu-wai Wong. Two-sided online bipartite matching and vertex cover: Beating the greedy algorithm. In International Colloquium on Automata, Languages, and Programming, pages 1070 -- 1081. Springer, 2015. Morteza Zadimoghaddam. Online weighted matching: beating the 1 2 barrier. arXiv preprint arXiv:1704.05384, 2017. 20
1912.13286
1
1912
2019-12-31T12:16:28
Graph Realizations: Maximum and Minimum Degree in Vertex Neighborhoods
[ "cs.DS", "cs.DM" ]
The classical problem of degree sequence realizability asks whether or not a given sequence of $n$ positive integers is equal to the degree sequence of some $n$-vertex undirected simple graph. While the realizability problem of degree sequences has been well studied for different classes of graphs, there has been relatively little work concerning the realizability of other types of information profiles, such as the vertex neighborhood profiles. In this paper, we initiate the study of neighborhood degree profiles. We focus on the natural problem of realizing maximum and minimum neighborhood degrees. More specifically, we ask the following question: Given a sequence $D$ of $n$ non-negative integers $0\leq d_1\leq \cdots \leq d_n$, does there exist a simple graph with vertices $v_1,\ldots, v_n$ such that for every $1\le i \le n$, the maximum (resp. minimum) degree in the neighborhood of $v_i$ is exactly $d_i$? We provide in this work various results for both maximum as well as minimum neighborhood degree for general $n$ vertex graphs. Our results are first of its kind that studies extremal neighborhood degree profiles. For maximum neighborhood degree profiles, we provide a {\em complete realizability criteria}. In comparison, we observe that the minimum neighborhood profiles are not so well-behaved, for these our necessary and sufficient conditions for realizability {\em differ by a factor of at most two}.
cs.DS
cs
Graph Realizations: Maximum and Minimum Degree in Vertex Neighborhoods Amotz Bar-Noy∗, Keerti Choudhary†, David Peleg‡, Dror Rawitz§ Abstract The classical problem of degree sequence realizability asks whether or not a given sequence of n positive integers is equal to the degree sequence of some n-vertex undirected simple graph. While the realizability problem of degree sequences has been well studied for different classes of graphs, there has been relatively little work concerning the realizability of other types of information profiles, such as the vertex neighborhood profiles. In this paper, we initiate the study of neighborhood degree profiles, wherein, our focus is on the natural problem of realizing maximum and minimum neighborhood degrees. More specifically, we ask the following question: "Given a sequence D of n non-negative integers 0 ≤ d1 ≤ ··· ≤ dn, does there exist a simple graph with vertices v1, . . . , vn such that for every 1 ≤ i ≤ n, the maximum (resp. minimum) degree in the neighborhood of vi is exactly di?" We provide in this work various results for both maximum as well as minimum neighborhood degree for general n vertex graphs. Our results are first of its kind that studies extremal neighborhood degree profiles. For maximum neighborhood degree profiles, we provide a complete realizability criteria. In comparison, we observe that the minimum neighborhood profiles are not so well-behaved, for these our necessary and sufficient conditions for realizability differ by a factor of at most two. 1 Introduction In many application domains involving networks, it is common to view vertex degrees as a central parameter, providing useful information concerning the relative significance (and in certain cases, centrality) of each vertex with respect to the rest of the network, and consequently useful for understanding the network's basic properties. Given an n-vertex graph G with adjacency matrix Adj(G), its degree sequence is a sequence consisting of its vertex degrees, DEG(G) = (d1, . . . , dn). Given a graph G or its adjacency matrix, it is easy to extract the degree sequence. An interesting dual problem, sometimes referred to as the realization problem, concerns a situation where given a sequence of nonnegative integers D, we are asked whether there exists a graph whose degree sequence conforms to D. A sequence for which there exists a realization is called a graphic sequence. Erdos and Gallai [9] gave a necessary and sufficient condition for deciding whether a given sequence of integers is graphic (also implying an O(n) decision algorithm). Havel and Hakimi [10, 11] gave a recursive algorithm that given a sequences of integers computes in O(m) time a realizing m-edge graph, or proves that the sequence is not graphic. ∗City University of New York (CUNY), USA. E-mail: [email protected] †Tel Aviv University, Israel. E-mail: [email protected] ‡Weizmann Institute of Science, Israel. E-mail: [email protected] §Bar Ilan University, Israel. E-mail: [email protected] 1 Over the years, various extensions of the degree realization problem were studied as well, cf. [1, 3, 19], concerning different characterizations of degree-profiles. The motivation underlying the current paper is rooted in the observation that realization questions of a similar nature pose themselves naturally in a large variety of other application contexts, where given some type of information profile specifying the desired vertex properties (be it concerning degrees, distances, centrality, or any other property of significance), it can be asked whether there exists a graph conforming to the specified profile. Broadly speaking, this type of investigation may arise, and find potential applications, both in scientific contexts, where the information profile reflects measurement results obtained from some natural network of unknown structure, and the goal is to obtain a model that may explain these measurements, and in engineering contexts, where the informa- tion profile represents a specification with some desired properties, and the goal is to find an implementation in the form of a network conforming to that specification. This basic observation motivates a vast research direction, which was little studied over the last five decades. In this paper we make a step towards a systematic study of one specific type of information profiles, concerning neighborhood degree profiles. Such profiles are of theoretical interest in context of social networks (where degrees often reflect influence and centrality, and consequently neighboring degrees reflect "closeness to power"). Neighborhood degrees were considered before in [5], where the profile associated with each vertex i is the list of degrees of all vertices in i's neighborhood. In contrast, we focus here on "single parameter" profiles, where the information associated with each vertex relates to a single degree in its neighborhood. Two first natural problems in this direction concern the maximum and minimum degrees in the vertex neighborhoods. For each vertex i, let d′i (respectively, d′′i ) denote the maximum (resp., minimum) vertex degree in i's neighborhood. Then MAXNDEG(G) = (d′1, . . . , d′n) (resp., MINNDEG(G) = (d′′1, . . . , d′′n)) is the maximum (resp., minimum) neighborhood degree profile of G. The same realizability questions asked above for degree sequences can be posed for neighborhood degree profiles as well. This brings us to the following central question of our work: Question. Can we efficiently compute for a given sequence D = (d1, . . . , dn) of nonnegative integers an n- vertex graph G (if exists) such that the maximum (resp. minimum) degree in the neighborhood of i-th vertex in G is exactly equal to di? Moreover, is there a closed-form characterization for all n-length realizable sequences? ℓ ,··· , dn1 Our Contributions For simplicity, we represent the input vector D alternatively in a more compact format as σ = (dnℓ i=1 ni = n; here the specification requires that G contains exactly ni vertices whose minimum (resp. maximum) degree in neighborhood is di. We may assume that dℓ > dℓ−1 > ··· > d1 ≥ 1 (noting that vertices with max/min degree zero are necessarily singletons and can be handled separately). 1 ), where ni's are positive integers with Pℓ (a) Minimum Neighborhood degree: In Section 3 we show the following necessary and sufficient conditions for σ = (dnℓ ℓ ,··· , dn1 1 ) to be MINNDEG realizable. The necessary condition is that for each i ∈ [1, ℓ], di ≤ n1 + n2 + . . . + ni − 1 , dℓ ≤ j n1d1 d1 + 1k +j n2d2 The sufficient condition is that for each i ∈ [1, ℓ], d1 + 1k +j n2d2 di ≤ j n1d1 and d2 + 1k + . . . +j nℓdℓ dℓ + 1k . d2 + 1k + . . . +j nidi di + 1k . 2 (NC1) (NC2) (SC) Remark 1. For any sequence σ = (dnℓ quence σγ = (d⌈γnℓ⌉ necessary and sufficient conditions differ by a factor of at most 2 in the ni's. 1 ) satisfying the first necessary condition (NC1), the se- ), where γ = (d1 + 1)/d1 satisfies the sufficient condition (SC), thus our ℓ ,··· , dn1 , . . . , d⌈γn1⌉ 1 ℓ Remark 2. For ℓ bounded by 3, we show that σ = (dnℓ along with (NC1) and (NC2) following is satisfied: ℓ ,··· , dn1 1 ) is MINNDEG-realizable if and only if Either d2 ≤ j n1d1 d1 + 1k +j n2d2 d2 + 1k, or d3 + 1 ≤ n1 + n2 + n3 −(cid:16)1 +(cid:24) d2 − n2 d1 (cid:25)(cid:17) (NC3) We leave it as an open question to resolve the problem in general. Open Question. Does there exist a closed-form characterization for realizing MINNDEG profiles for gen- eral graphs? (b) Maximum Neighborhood degree: We perform an extensive study of maximum neighborhood degree profiles. 1. In Section 4, we obtain the necessary and sufficient conditions for σ = (dnℓ ℓ ,··· , dn1 1 ) to be MAXNDEG realizable. For general graphs we obtain the following characterization. dℓ ≤ nℓ − 1, and d1 ≥ 2 or n1 is even We also study the version of the problem in which the realization is required to be connected. Our characterization is as follows. dℓ ≤ nℓ − 1, and d1 ≥ 2 or σ = (12) . 2. Further, we consider the open neighborhoods, wherein a vertex is not counted in its own neighbor- hood. These are more involved and are discussed in Section 5. Our results for open neighborhood are summarised in Table 1. Graph Complete characterisation Connected Graphs dℓ ≤ min{nℓ, n − 1} d1 ≥ 2 or σ = (dd, 11) or σ = (12) σ 6= (ddℓ+1 ℓ , 21) σ can be split1 into two profiles σ1 and σ2 such that General graphs (i) σ1 has a connected MAXNDEG-open realization, and (ii) σ2 = (12α) or σ2 = (dd, 12α+1), for integers d ≥ 2, α ≥ 0. Table 1: Max-neighbouring-degree realizability for open neighborhood. 1 A profile σ = (dnℓ ℓ , · · · , dn1 1 ) is said to be split into two profiles σ1 = (dpℓ ℓ , · · · , dp1 1 ) and σ2 = (dqℓ ℓ , · · · , dq1 1 ) if ni = pi+qi for each i ∈ [1, ℓ]. 3 3. Enumerating realizable maximum neighborhood degree profiles: The simplicity of above characterizations enables us to enumerate and count the number of realizable profiles. This gives a way to sample uniformly a random MAXNDEG realizable profile. In contrast, counting and sampling are open problems for the traditional degree sequence realizability problem. In Appendix, we show that the number of realizable profiles of length n is ⌈(2n−1 + (−1)n)/3⌉ for general graphs and 2n−3 for connected graphs. In comparison, the total number of non-increasing sequences of length n on the numbers 1, . . . , n − 1 is Θ(4n/√n). In Section 6, we discuss the apparent difference in difficulty between MAXNDEG and MINNDEG pro- files and propose a possible explanation. Further Related Work Many works have addressed related questions such as finding all the (non-isomorphic) graphs that realize a given degree sequence, counting all the (non-isomorphic) realizing graphs of a given degree sequence, sampling a random realization for a given degree sequence as uniformly as possible, or determining the conditions under which a given degree sequence defines a unique realizing graph (a.k.a. the graph reconstruction problem), cf. [7, 9, 10, 11, 12, 15, 16, 17, 18, 20]. Other works such as [6, 8, 13] studied interesting applications in the context of social networks. To the best of our knowledge, the MAXNDEG and MINNDEG realization problems have not been explored so far. There are only two related problems that we are aware of. The first is the shotgun assembly problem [14], where the characteristic associated with the vertex i is some description of its neighborhood up to radius r. The second is the neighborhood degree lists problem [5], where the characteristic associated with the vertex i is the list of degrees of all vertices in i's neighborhood. We point out that in contrast to these studies, our MAXNDEG and MINNDEG problem applies to a more restricted profile (with a single number characterizing each vertex), and the techniques involves are totally different from those of [5, 14]. Several other realization problems are surveyed in [2, 4]. 2 Preliminaries Let H be an undirected graph. We use V (H) and E(H) to respectively denote the vertex set and the edge set of graph H. For a vertex x ∈ V (H), let degH (x) denote the degree of x in H. Let NH[x] = {x} ∪ {y (x, y) ∈ E(H)} be the (closed) neighborhood of x in H. For a set W ⊆ V (H), we denote by NH(W ), the set of all the vertices lying outside set W that are adjacent to some vertex in W , that is, NH(W ) = (Sw∈W N [w]) \ W . Given a vertex v in H, the minimum (resp. maximum) degree in the neighborhood of v, namely MINNDEGH(v) (resp. MAXNDEGH(v)), is defined to be the maximum over the degrees of all the vertices in the neighborhood of v. Given a set of vertices A in a graph H, we denote by H[A] the subgraph of H induced by the vertices of A. For a set A and a vertex x ∈ V (H), we denote by A ∪ x and A \ x, respectively, the sets A ∪ {x} and A \ {x}. When the graph is clear from context, for simplicity, we omit the subscripts H in all our notations. Finally, given two integers i ≤ j, we define [i, j] = {i, i + 1, . . . , j}. 2 2 3 2 1 Figure 1: A MAXNDEG realization of (34, 21) and a MINNDEG realization of (23, 12). 4 A profile σ = (dnℓ ℓ ,··· , dn1 1 ) satisfying dℓ > dℓ−1 > ··· > d1 > 0 is said to be MINNDEG realizable (resp. MAXNDEG realizable) if there exists a graph G on n = n1 + ··· + nℓ vertices that for each i ∈ [1, ℓ] contains exactly ni vertices whose MINNDEG (resp. MAXNDEG) is di. Equivalently, {v ∈ V (G) : MINNDEG(v) = di} = ni (resp. {v ∈ V (G) : MAXNDEG(v) = di} = ni). The figure depicts a MAXNDEG realization of (34, 21) and a MINNDEG realization of (23, 12). (The numbers in the vertices represent their degrees.) Note that in the open neighborhoods model, the corresponding MAXNDEG and MINNDEG profiles become (33, 22) and (24, 11), respectively. 3 Realizing minimum neighborhood degree profiles 3.1 Leaders and followers Let G = (V, E) be any graph. For any vertex v ∈ V , we define leader(v) to be a vertex in N [v] of minimum In other words, leader(v) = degree, if there are more than one choices we pick the leader arbitrarily. arg min{deg(w) w ∈ N [v]}. Next let σ = (dnℓ 1 ) be the min-degree sequence of G. We define Vi to be set of those vertices in G whose minimum-degree in the closed neighborhood is exactly di, so Vi = ni. Also, let Li be set of those vertices in G who are leader of at least one vertex in Vi, equivalently, Li = {leader(v) v ∈ Vi}, and denote by L = ∪ℓ i=1Li the set of all the leaders in G. Observe that the sets V1, . . . , Vℓ forms a partition of the vertex-set of G. ··· dn1 ℓ A vertex v in G is said to a follower, if leader(v) 6= v. Let Fi = {v ∈ Vi v 6= leader(v)} be the set of i=1Fi to all the followers in Vi. Finally we define R = V \ L to be the set of all the non-leaders, and F = ∪ℓ be the set of all the followers. v1 v2 v3 v4 v5 v6 Figure 2: The unique MINNDEG-realization of the sequence σ = (332112). Observe that min-deg(v1) = min-deg(v2) = deg(v1) = 1, min-deg(v3) = deg(v2) = 2, and min-deg(vi) = 3, for i ∈ {4, 5, 6}. Since leader(v2) = v1 and leader(v3) = v2, here v2 is a leader as well as a follower. We point here that there exist realizable sequences σ for which any graph G realizing σ and any leader function over G, the sets L and F have non-empty intersection. For example, consider the sequence σ = (122133) in Figure 2. It can be easily checked that σ has only one realizing graph, and in this graph, the leader-set and the follower-set are not disjoint. We classify the sequences that admit disjoint leader and follower sets as follows. Definition 1. A sequence σ = (dnℓ 1 ) is said to admit a Disjoint Leader-Follower (DLF) MINNDEG- ℓ realization if there exists a graph G realizing σ and a leader function under which the sets L and F are mutually disjoint, that is, L ∩ F = ∅. ··· dn1 3.2 Realizing uniform sequences Lemma 1. For a sequence σ = (dnℓ ℓ ··· dn1 1 ) to be MINNDEG-realizable it is necessary that d1 + 1 ≤ n1. 5 Proof. Suppose σ is MINNDEG-realizable by a graph G, then there exists at least one vertex, say w, of degree exactly d1 in G. Now N [w] = d1 + 1, this implies that the number of vertices v in graph G with min-deg(v) = d1 must be at least d1 + 1. Thus n1 ≥ d1 + 1. Lemma 2. The sequence σ = (dn), is MINNDEG-realizable if and only if n ≥ d + 1. Proof. By Lemma 1, if the sequence σ = (dn) is realizable then n must be at least d + 1. To prove the converse, we give a realization for σ assuming n ≥ d + 1. Let q ≥ 1 and r ∈ [0, d] be integers satisfying n = (q)(d + 1) − r. Take a set A of q vertices, namely Li (i ∈ [1, q]), and another set B of dq vertices, namely bij (i ∈ [1, q], j ∈ [1, d]). Connect each Li to vertices bi1, . . . , bid. So vertices in A have degree exactly d and vertices in B have in their neighborhood a vertex of degree d. Next if r > 0, then we merge b1j with b2j , for j ∈ [1, r], thereby reducing r vertices in B. (Notice that b1j and b2j exists because r > 0 only if q ≥ 2). Thus A + R = n and each vertex in A still has degree exactly d. So A = n+r d+1 = (cid:6) n d+1(cid:7) and R = n − A = (cid:4) nd d+1(cid:5) ≥ d. Finally, we add edges between each pair of vertices in B to make it a clique of size at least d; this will imply that the vertices in set B have degree at least d. It is easy to check that min-deg(v) for each v ∈ A ∪ B in our constructed graph is d. Remark 3. Henceforth, we will use GRAPH(n, d, A, B) to denote the function that returns the edges of the graph constructed by Lemma 2 whenever n ≥ d + 1 and A = (cid:6) n d+1(cid:7), and R = (cid:4) nd d+1(cid:5). 3.3 Necessary and sufficient conditions for MINNDEG profiles We start with the following theorem. dj +1k, for Theorem 1 (Sufficient condition SC). Any sequence σ = (dnℓ ℓ i ∈ [1, ℓ], is MINNDEG-realizable by a graph G such that L ∩ F = ∅ with respect to some leader function defined over G. 1 ) satisfying di ≤ Pi j=1j nj dj ··· dn1 Proof. We initialize G to be an empty graph. Our algorithm proceeds in ℓ rounds. (See Algorithm 1 for a pseudo-code). In each round, we first add to G a set Vi of ni new vertices and partition Vi into two sets Li di+1(cid:7) and(cid:4) nidi and Ri of sizes respectively (cid:6) ni di+1(cid:5). Now if ni > di + 1, then we solve this round independently by adding to G all the edges returned by GRAPH(ni, di, Li, Ri). Notice that if ni ≤ di + 1, then Li will contain only one vertex, say ai. In such a case, we add edges between ai and all the vertices in set Ri. Also, we add edges between ai and any arbitrarily chosen di + 1 − ni vertices in ∪j<iRj. This is possible since dj +1(cid:5) = Pi−1 di + 1 − ni = di − (cid:4) nidi j=1 Rj. Finally, after the ℓ rounds are completed, we add edges between each pair of vertices in set R = ∪ℓ i=1Ri to make it a clique. di+1(cid:5) ≤ Pi−1 j=1(cid:4) nj dj Let us now show bounds on the degree of vertices in sets Li and Ri. 1. Each vertex in Li has degree exactly di : Recall we add edges to vertices in Li only in the ith iteration of for loop. If ni > di + 1, then by Lemma 2, the degree of each vertex in Li is exactly di. If Li = 1, or equivalently, ni ≤ di + 1, then Ri = ni − Li = ni − 1, and so degree of vertex ai ∈ Li is (ni − 1) + (di + 1 − ni) = di. 2. Vertices in R have degree at least dℓ : For any i ∈ [1, ℓ], if ni > di + 1, then by Lemma 2, di+1(cid:7) = (cid:6) nidi Ri = (cid:6) nidi di+1(cid:7). Thus R = Pℓ di+1(cid:7) which is bounded below by di. Since R ≥ dℓ, and each vertex in R is adjacent to at least one vertex in ∪iLi, the degree of vertices in R is at least dℓ. di+1(cid:7), and even in the case ni ≤ di + 1, we have Ri = ni − Li = ni −(cid:6) ni i=1 Ri = Pℓ i=1(cid:6) nidi 6 Input: A sequence σ = (dnℓ ℓ ··· dn1 1 Initialize G to be an empty graph. 2 for i = 1 to ℓ do 3 Add to G a set Vi of ni new vertices. 1 ) satisfying di ≤ Pi j=1⌊ nj dj dj +1⌋, for 1 ≤ i ≤ ℓ. 4 5 6 7 8 9 Partition Vi in two sets Li, Ri such that Li = (cid:6) ni if (ni > di + 1, or equivalently, Li > 1) then else if (Li = 1) then Add to G all the edges returned by GRAPH(ni, di, Li, Ri). di+1(cid:7) and Ri = (cid:4) nidi di+1(cid:5). Let ai be the only vertex in Li. Connect ai to all vertices in Ri, and any arbitrary di + 1 − ni vertices in ∪j<iRj . 10 Add edges between each pair of vertices in R = ∪ℓ i=1Ri to make it a clique. 11 Output G. Algorithm 1: Computing a MINNDEG-realization for a given special σ. We next show that for any vertex v ∈ Vi, min-deg(v) = di, where i ∈ [1, ℓ]. If v ∈ Li, then min-deg(v) = di, since each vertex in Li has degree di, and is adjacent to only vertices in R which have degree at least dℓ ≥ di. If v ∈ Ri, then also min-deg(v) = di, since each vertex in Ri is adjacent to at least one vertex in Li, and N [v] is contained in the set R ∪ (∪j≥iLj), whose vertices have degree at least di. i=1Li, we set leader(v) = v, and for each v ∈ Ri, we set leader(v) to any arbitrary neighbour of v in Li. Since each vertex in L = ∪ℓ i=1Li = {leader(v) v ∈ V } is a leader of itself, the set L of leader and the set F of followers must be mutually disjoint. The leader function over V is as follows. For each v ∈ ∪ℓ We now provide a lower bound on the size of the leader set Li. Lemma 3. For each i ∈ [1, ℓ], we have Li ≥ l ni Proof. Consider any vertex a ∈ Li. Since N (a) = di + 1, vertex a can serve as leader for at most di + 1 vertices. This shows that Li ≥ ni Theorem 2 (Necessary condition). For any MINNDEG-realizable sequence σ = (dnℓ ℓ di+1 . The claim follows from the fact that Li is an integer. ··· dn1 di + 1m. 1 ), we have (NC1) di ≤ (cid:0)Pi (NC2) dℓ ≤ j=1 nj(cid:1) − 1, for i ∈ [1, ℓ] Xi=1 j nidi di + 1k. ℓ implying condition (NC1). Proof. Let G be a realization for σ. Let w be any vertex in G such that deg(w) = di. Then w as well as all the neighbours of w must be contained in ∪i j=1 nj, j=1 Vj = Pi contain vertices of degree less than dℓ, so N [w]∩Li = ∅, for each i < ℓ. Therefore, N [w] ≤ n−Pℓ−1 To prove condition (NC2), suppose w is a vertex in G such that min-deg(w) = dℓ. Then N [w] cannot i=1 Li. j=1Vj , therefore, di + 1 = N [w] ≤ ∪i Also deg(w) must be at least dℓ. We thus get, dℓ + 1 ≤ N [w] ≤ n − ℓ−1 Xi=1 Li = nℓ + ℓ−1 Xi=1 (ni − Li) ≤ nℓ + ℓ Xi=1 j nidi di + 1k, 7 where the last inequality follows from Lemma 3. If nℓ ≤ dℓ, then nℓ − 1 = (cid:4) nℓdℓ dℓ+1(cid:5), and so dℓ ≤ Pℓ implies dℓ ≤ (cid:4) nℓdℓ dℓ+1(cid:5) since dℓ is integral. As a corollary of the above results, the following is immediate. i=1(cid:4) nidi di+1(cid:5). If nℓ ≥ dℓ + 1, then nℓdℓ dℓ+1 ≥ dℓ which Corollary 1. The sequence σ = (dn2 d1+1(cid:5) +(cid:4) n2d2 (cid:4) n1d1 d2+1(cid:5). d1 ≤ (cid:4) n1d1 Proof. Suppose σ = (dn2 2 dn1 d1+1(cid:5), and (ii) dℓ = d2 ≤ (cid:4) n1d1 ℓ ,··· , dn1 For a sequence σ = (dnℓ we also have the following. 2 dn1 1 ) is MINNDEG-realizable if and only if d1 ≤ (cid:4) n1d1 d1+1(cid:5) and d2 ≤ 1 ) is realizable. Then Theorem 2 implies (i) n1 ≥ d1 + 1 which implies d2+1(cid:5). The converse follows from Theorem 1. d1+1(cid:5) +(cid:4) n2d2 1 ), let γ = (d1+1)/d1. As ⌊ γn1d1 d1+1 ⌋+. . .+⌊ γnidi di+1 ⌋ ≥ n1+···+ni ≥ di, Corollary 2. For any sequence σ = (dnℓ sequence σγ = (d⌈γnℓ⌉ , . . . , d⌈γn1⌉ ℓ ,··· , dn1 ℓ 1 ) satisfies the sufficient condition (SC). 1 ) satisfying the first necessary condition (NC1), the 3.4 MINNDEG realization of tri-sequences We here consider the scenario when a sequence has only three distinct degrees. Specifically, we provide a complete characterization of sequences σ = (dn3 3 dn2 2 dn1 1 ). 3 dn2 1 ) when ℓ = 3 is Theorem 3. The necessary and sufficient conditions for MINNDEG-realizability of the sequence σ = (dnℓ ℓ ,··· , dn1 1. d1 + 1 ≤ n1, 2. d2 + 1 ≤ n1 + n2, d1+1(cid:5) +(cid:4) n2d2 3. d3 ≤ (cid:4) n1d1 4. either d2 ≤ (cid:4) n1d1 d2+1(cid:5), or d3 + 1 ≤ n1 + n2 + n3 −(cid:0)1 +l d2−n2 d1+1(cid:5) +(cid:4) n2d2 2 dn1 d2+1(cid:5) +(cid:4) n3d3 d3+1(cid:5), and Proof. Suppose σ = (dn3 stated above are necessary. To prove that all four conditions are necessary, we are left to show that if d2 (cid:13) (cid:4) n1d1 1 ) is realizable, then by Theorem 2, it follows that the first three conditions d2+1(cid:5), then d1 m(cid:1). We consider a graph G that realizes σ. Let V1, V2, V3 be the d3 + 1 ≤ n1 + n2 + n3 − (cid:0)1 + l d2−n2 partition of V (G) as defined in Section 3. Consider a vertex w ∈ V2. Observe that leader(w) must lie in V1, because if L2 ∩ V2 is non-empty, then Lemma 4 implies d2 ≤ (cid:4) n1d1 d2+1(cid:5). We first show that d1 m. The set N (w) ∩ V1 has size at least d2 − n2. Each vertex x ∈ L1 can serve as a leader of L1 ≥ l d2−n2 at most d1 vertices in open-neighborhood of w. Indeed, if x ∈ N (w) then it can not count w (lying outside N (w)), and if x /∈ N (w) then it can not count itself (again lying outside N (w)). Thus to cover the set d1 m. Now consider a vertex N (w) ∩ V1 at least l d2−n2 y ∈ V3, note that N [y] excludes w (as degree of w is d2), as well as L1 (as vertices in L1 have degree d1). Therefore, we obtain the following relation. d1 m leaders are required, thereby, showing L1 ≥ l d2−n2 d1+1(cid:5) + (cid:4) n2d2 d1+1(cid:5) +(cid:4) n2d2 d1 m(cid:1). d3 + 1 = N [y] ≤ V1 \ L1 + V2 \ w + V3 ≤ n1 + n2 + n3 −(cid:16)1 +(cid:24) d2 − n2 d1 (cid:25)(cid:17) 8 d1+1(cid:5) +(cid:4) n2d2 d1+1(cid:5) + (cid:4) n2d2 We now prove the sufficiency claims. If d2 ≤ (cid:4) n1d1 d2+1(cid:5), then the conditions 1-4 are sufficient by Theorem 1. So let us focus on the scenario when d2 (cid:13) (cid:4) n1d1 d2+1(cid:5). Let N = n1 + n2 + n3 −(cid:0)1 + d1 m(cid:1). The vertex-set of our realized graph G = (V, E) will be a union of three disjoint sets L1, L2 = l d2−n2 {w}, and Z of size respectivelyl d2−n2 d1 m, 1, and N . Initially, the edge-set E is an empty-set. Between vertex d3+1k). pairs in Z, we add edges so that the induced graph G[Z] is identical to GRAPH(N, d3,l N This step is possible since d3 + 1 ≤ N , and ensures that MINNDEGG[Z](z) = d3, for z ∈ Z. Let L3 denote the set of those vertices in Z whose degree is equal to d3. We connect w to arbitrary N − n3 = n2 + (n1 − L1 ∪ L2) vertices in Z \ L3, and any arbitrary α := d2 − (n1 + n2 − L1 ∪ L2) vertices in L1. Since degG(w) = d2, this step ensures that MINNDEG of exactly n2 vertices in Z decreases to d2. Let Y be a subset of arbitrary (n1 − L1 ∪ L2) neighbours of w in Z. Finally, we connect each x ∈ L1 ∩ N [w] to arbitrary d1 − 1 vertices in Y , and each x′ ∈ L1 \ N [w] to arbitrary d1 vertices in Y , so as to ensure each vertex in Y is adjacent to at least one leader in L1. Since vertices in L1 have degree d1, this ensures MINNDEGG(x) = d1, for each x ∈ {w} ∪ Y ∪ L1. This completes the construction of G. d3+1m ,j N d3 Looking at the complexity of the above characterization, we leave it as an open question to solve the problem in general. Open Question. Does there exist a polynomial-time algorithm, or a closed-form characterization, for real- izing MINNDEG profiles for general graphs? 3.5 Complete characterization for sequences admitting disjoint leader-follower sets We conclude by providing a complete characterization for special class of MINNDEG-sequences that admit a disjoint leader-follower sets. Lemma 4. Let G be a graph and σ(G) = (ndℓ ℓ . . . dn1 1 ). For any leader function defined over G and for any j=1j nj dj dj +1k. i ∈ [1, ℓ], if Li ∩ Vi is non-empty then di ≤ Pi Proof. Let w be any vertex lying in Li ∩ Vi, so min-deg(w) = deg(w) = di. Recall for each j < i, vertices in the set Lj have degree strictly less than di. Since N [w] cannot contain vertices of degree less than di, thus for each j < i, N [w] ∩ Lj = ∅. Also vertices in Vi+1 ∪ . . . ∪ Vℓ cannot be adjacent to any vertex in {w} ∪(cid:0) ∪i−1 j=1 Lj(cid:1), therefore, N [w] as well as ∪i−1 j=1Lj are contained in union ∪i Lj(cid:12)(cid:12)(cid:12) di + 1 = N [w] ≤ (cid:12)(cid:12)(cid:12) j=1(cid:4) nj dj dj +1(cid:5). If ni ≥ di + 1, then the bound trivially holds since nidi where the last inequality follows from Lemma 3. If ni ≤ di, then ni − 1 = ni − (cid:6) ni so di ≤ Pi that di is integral implies di ≤ (cid:4) nidi di+1(cid:5). Theorem 4. A sequence σ = (ndℓ ℓ . . . dn1 1 ) is MINNDEG-realizable by a graph G having disjoint leader- set (L) and follower-set (F ) with respect to some leader function, if and only if, for each i ∈ [1, ℓ], di ≤ j=1(cid:4) nj dj Pi dj +1(cid:5). di+1(cid:5), and di+1 ≥ di which from the fact Xj=1j njdj dj + 1k, di+1(cid:7) = (cid:4) nidi (ni − Lj) ≤ ni + j=1Vj. We thus get, i [j=1 Vj(cid:12)(cid:12)(cid:12) −(cid:12)(cid:12)(cid:12) i−1 [j=1 = ni + i−1 Xj=1 i−1 9 Proof. Let us suppose there exists a leader function over G for which L ∩ F = ∅, then for each i ∈ [1, ℓ], Li ⊆ Vi. This is because if for some i, there exists w ∈ Li \ Vi, then deg(w) = di 6= min-deg(di), which implies that w is a leader as well as a follower. Since Li ⊆ Vi, by Lemma 4, di ≤ Pi dj +1(cid:5), for each i ∈ [1, ℓ]. The converse claim follows from Theorem 1. j=1(cid:4) nj dj 4 Realizing maximum neighborhood degree profiles In this section, we provide a complete characterization of MAXNDEG profiles. For simplicity, we first discuss the uniform scenario of σ = (dk). Observe that a star graph K1,d is MAXNDEG realization of the profile (dd+1). We show in the following lemma that, by identifying together vertices in different copies of K1,d, it is always possible to realize the profile (dk), whenever k ≥ d + 1. Lemma 5. For any positive integers d and k, the profile σ = (dk) is MAXNDEG realizable whenever k ≥ d + 1. Moreover, we can always compute in O(k) time a connected realization that has an independent set, say S, of size d such that all vertices in S have degree at most 2, and at least two vertices in S have degree 1. Proof. Let α be the smallest integer such that k ≤ 2 + α(d − 1). We first construct a caterpillar2 T as follows. Take a path P = (s0, s1, . . . , sα, sα+1) of length α + 1. Connect each internal vertex si (here i ∈ [1, α]) with a set of d − 2 new vertices, so that the degree of si is d. (See Figure 3). Note that the MAXNDEG of each vertex v ∈ T is d. s1 1 s2 1 s3 1 s1 2 s2 2 s3 2 s1 3 s2 3 s3 3 s0 s1 s2 s3 s4 Figure 3: A caterpillar for d = 5 and α = 3. If k = 12, then r = 2, and we merge (i) s1 and s2 2. 1 and s1 2, and (ii) s2 1 j Now if k = 2 + α(d− 1), then T serves as our required realizing graph. If k < 2 + α(d− 1), then α ≥ 2 since k ≥ d + 1. The tree T is "almost" a realizing graph for the profile, except that it has too many vertices. Let r = 2 + α(d− 1)− k denote the number of excess vertices in T that need to be removed. The r vertices can be removed as follows. Take any two distinct internal vertices si and sj on P , and let s1 and j , . . . , sd−2 s1 , respectively, denote the neighbors of si and sj not lying on P . Let G be the graph obtained by merging vertices sℓ j into a single vertex for ℓ ∈ [1, r]. (See Figure 3). Since the number of vertices was decreased by r, G now contains exactly n vertices. The degree of vertices s1, s2, . . . , sα remains d, and the degree of all other vertices is at most 2, therefore MAXNDEG(v) = d for each v ∈ G, so G is a realization of the profile σ. Finally, in the resultant graph G, the end points of P (i.e. s0 and sα+1) have degree 1, and there are ), that have degree bounded by 2. Therefore we d − 2 other vertices, namely s1 set S to these d vertices. It is easy to verify that S is indeed an independent set. j , . . . , sd−2 i , . . . , sd−2 i , . . . , sd−2 i i and sℓ (or s1 i j 2A caterpillar is a tree in which all the vertices are within distance one of a central path. 10 4.1 An incremental procedure for computing MAXNDEG realizations We explain here our main building block, procedure ADDLAYER, that will be useful in incrementally build- ing graph realizations in a decreasing order of maximum degrees. Given a partially computed connected graph H and integers d and k satisfying d ≥ 2 and k ≥ 1, the procedure adds to H a set W of k new vertices such that MAXNDEG(w) = d, for each w ∈ W . The reader may assume that MAXNDEG(v) ≥ d, for each existing vertex v ∈ V (H). The procedure takes in as an input a sufficiently large vertex list L (of size d− 1) that forms an independent set in H, and whose vertices have small degree (that is, at most d− 1). Moreover, in order to accommodate its iterative use, each invocation of the procedure also generates and outputs a new list, to be used in the further iterations. Procedure ADDLAYER The input to procedure ADDLAYER (H, L, k, d) is a connected graph H and a list L = (a1, . . . , ad−1) of vertices in H whose degree is bounded above by d − 1. The first step is to add to H a set of k new vertices W = {w1, w2, . . . , wk}. Next, the new vertices are connected to the vertices of L and to themselves so as to ensure that MAXNDEG(w) = d for every w ∈ W . Depending upon whether or not k < d, there are two separate cases. (Refer to Algorithm 2 for pseudocode). Let us first consider the case k ≤ d − 1. In this case we add edges from vertices in W to a subset of vertices from L such that those vertices in L will have degree d and therefore will imply MAXNDEG(w) = d, for every w ∈ W . We initialize two variables, count and i, respectively, to k and d−1. The variable count holds, at any instant of time, the number of vertices in W that still need to be connected to vertices in L. While count > 0, the procedure performs the following steps: (i) compute r = min{d − deg(ai), count}, the maximum number of vertices in W that can be connected to vertex ai; (ii) connect ai to following r vertices in W : wcount−(r−1), wcount−(r−2), . . . , wcount−1, wcount; and (iii) decrease count by r, and i by 1. When count = 0, the vertices ai, ai+1, . . . , ad−1 are connected to at least one vertex in W (this implies d − i ≤ k). It is also easy to verify that at this stage, deg(ad−1) = deg(ad−2) = ··· = deg(ai+1) = d, and deg(ai) ≤ d. Since the input graph H was connected, in the beginning of the execution deg(ai) ≥ 1, and by connecting ai to at least one vertex in W , specifically to w1, its degree is increased at least by one. So at most d − 2 edges need to be added to ai to ensure that its degree is exactly d. The procedure performs the following operation for each j ∈ [d − 1, d − 2, . . . , 2, 1] (in the given order) until deg(ai) = d: (i) if j < i then add edge (aj, ai) to H, and (ii) if j > i then add an edge between ai and an arbitrary neighbor of aj lying in W . Since deg(ai) = deg(ai+1) = ··· = deg(ad−1) = d, and deg(w) ≤ 2 for every w ∈ W , it follows that MAXNDEG(w) = d, for each w ∈ W . In the end, we set a new list L containing the first d − 2 vertices in the sequence (w1, w2, . . . , wk, a1, a2, . . . , ai−1). This is possible since k + i − 1 ≥ d − 2 due to the fact that d − i ≤ k. (Later on we bound the degrees of the vertices in the new list.) Now we consider the case k ≥ d. The procedure uses Lemma 5 to compute over the independent set W ∪ {a1} a graph ¯H realizing the profile (dk+1) such that deg ¯H(a1) = 1. Notice that in the beginning of the execution, deg(a1) ∈ [1, d − 1], and it is increased by one by adding ¯H over the set W ∪ {a1}. So now deg(a1) ∈ [2, d]. To ensure deg(a1) = d, at most d − 2 more edges need to be added to a1. Edges are added between a1 and any arbitrary d − deg(a1) vertices in set {a2, a3, . . . , ad−1}. This ensures that every w ∈ W has MAXNDEG(w) = d. By Lemma 5, ¯H \ {a1} contains an independent set of d − 1 vertices, say b1, . . . , bd−1, such that 1 = deg ¯H(b1) ≤ deg ¯H(b2) ≤ ··· ≤ deg ¯H(bd−1) ≤ 2. In the end, the procedure creates a new list L = (b1, b2, . . . , bd−2). For sake of better understanding, in the rest of paper, we denote by Hold, Lold and Hnew, Lnew re- spectively the graph and the list before and after the execution of Procedure ADDLAYER. Observe that V (Hnew) = V (Hold) ∪ W . The following two lemmas follow from the description of algorithm. Lemma 6. Each w ∈ W satisfies MAXNDEG(w) = d, and N (w) ⊆ W ∪ Lold. 11 1 Let the list L be (a1, a2, . . . , ad−1). 2 Add to H a set W = {w1, . . . , wk} of k new vertices. 3 case (k < d) do 4 Set count = k and i = d − 1. while (count 6= 0) do Let r = min{d − deg(ai), count}. Add edges (ai, wcount−t) to H for t ∈ [0, r − 1]. Decrement i by 1 and count by r. foreach j ∈ [d − 1, . . . , 2, 1] do If deg(ai) = d then break the for loop. If (j < i) then add edge (aj, ai) to H. If (j > i) then add an edge between ai and an arbitrary vertex in N (aj) ∩ W . 5 6 7 8 9 10 11 12 13 15 16 17 18 14 case (k ≥ d) do Set L to be prefix of (w1, w2, . . . , wk, a1, a2, . . . , ai−1) of size d − 2. Use Lemma 5 to compute over independent set (W ∪ {a1}) the graph, say ¯H, realizing the profile (dk+1) such that deg ¯H(a1) = 1. Add edges between a1 and any arbitrary d − deg(a1) vertices in set {a2, a3, . . . , ad−1}. Let b1, . . . , bd−1 ∈ ¯H \ a1 be such that 1 = deg ¯H (b1) ≤ ··· ≤ deg ¯H(bd−1) ≤ 2. Set L = (b1, b2, . . . , bd−2). 19 Output L. Algorithm 2: ADDLAYER (H, L, k, d) ℓ ,··· , dn1 Input: A sequence σ = (dnℓ 1 Initialize G to be the graph obtained from Lemma 5 that realizes the profile (dnℓ 2 Let Lℓ−1 be a valid list in G of size dℓ−1 − 1. 3 for (i = ℓ − 1 to 1) do 1 ) satisfying dℓ ≤ nℓ − 1 and d1 ≥ 2. Li−1 ← ADDLAYER (G, Li, ni, di). Truncate list Li−1 to contain only the first di−1 − 1(≤ di − 2) vertices. 4 5 ℓ ). 6 Output G. Algorithm 3: MAXNDEG realization of σ = (dnℓ ℓ , . . . , dn1 1 ) Lemma 7. Each a ∈ Lold\Lnew satisfies degHnew (a) ≤ d, and each a ∈ Lold∩Lnew satisfies degHnew (a) ≤ degHold(a) + 1. It is also easy to verify that the total execution time of Procedure ADDLAYER is O(k + d). The Inheritance Property Till now, we showed that given an independent list of d − 1 vertices of degree at most d − 1 in a graph H, we can add k ≥ 1 vertices to H such that the MAXNDEG of these k vertices is d. In order to iteratively use this algorithm to add vertices of smaller MAXNDEG values ((cid:12) d) we require that the list Lnew computed by Procedure ADDLAYER should satisfy following three constraints: (i) The size of Lnew should be d − 2; (ii) the vertices of Lnew should form an independent set; and most importantly, (iii) the vertices in Lnew should have degree at most d − 2. In order to ensure these constraints on Lnew, we further impose the constraint that the list Lold is a valid 12 list; this is formally defined as below. Definition 2 (Valid List). A list L = (a1, a2, . . . , at) in a graph G is said to be "valid" with respect to G if the following two conditions hold: (i) for each i ∈ [1, t], deg(ai) ≤ i, and (ii) the vertices of L form an independent set in G. We next prove the inheritance property of our procedure. Lemma 8 (Inheritance property). If the input list Lold in Procedure ADDLAYER is valid, then the output list Lnew is valid as well. Proof. We first consider the case k ≤ d− 1. Let i be the smallest index such that vertices ai, ai+1, . . . , ad−1 are adjacent to some vertex of W in Hnew. (That is, i is the index when Procedure ADDLAYER exits the while loop). Recall that in the graph Hnew, w1 ∈ W is a neighbor of ai. Also, to increase the degree of ai to d, we connect ai to some/all vertices in a1, . . . , ai−1, and some/all neighbors of ai+1, . . . , ad−1 lying in W . Therefore the vertex set W ∪ {a1, . . . , ai−1} is independent in Hnew. Also, its size at least d − 1, as we showed that k ≥ d − i. Since the list Lold = (a1, a2, . . . , ad−1) is valid in the beginning of the execution of Procedure ADDLAYER, it follows that in Hold, deg(aj) ≤ j for j ∈ [1, d − 1]. So by Lemma 7, in Hnew, (i) deg(aj) ≤ j + 1 for j ∈ [1, i − 1], (ii) deg(w1) = 1, and (iii) the degree of each other vertex in W \ w1 is at most 2. Consequently, (w1,··· , wk) is a valid list of length at least d − i ≥ 1. Since deg(aj) ≤ j + 1 for j ∈ [1, i − 1], the list (w1,··· , wk, a1, . . . , ai−1) is valid and has length at least d − 1. Truncating this to length d − 2 again gives us a valid list. We now consider the case k ≥ d. By Lemma 5, H[W ∪ {a1}] = ¯H contains an independent set {b1, b2, . . . , bd−1} ⊆ W such that deg(b1) = 1 and deg(bj) ≤ 2 for j ∈ [2, d − 1]. Therefore, (b1, b2, . . . , bd−2) is a valid list of length d − 2 in Hnew. The following proposition summarizes the above discussion. Proposition 1. For any integers d ≥ 2, k ≥ 1, and any connected graph H containing a valid list L of size d − 1, procedure ADDLAYER adds to H in O(k + d) time, a set W of k new vertices such that MAXNDEG(w) = d, for every w ∈ W . All the edges added to H lie in W × (W ∪ L). Moreover, degH(a) ≤ d, for every a ∈ L, and the updated graph remains connected and contains a new valid list of size d − 2. 4.2 The main algorithm We now present the main algorithm for computing the realizing graph using Procedure ADDLAYER. Let σ = (dnℓ ℓ ,··· , dn1 1 ) be any profile satisfying dℓ ≤ nℓ − 1 and d1 ≥ 2. The construction of a connected graph realizing σ is as follows (refer to Algorithm 3 for pseudocode). We first use Lemma 5 to initialize G to be the graph realizing the profile (dnℓ ℓ ). Recall G contains an independent set, say W = {w1, w2, . . . , wdℓ}, satisfying the condition that the degree of the first two vertices is one, and the degree of the remaining vertices is at most two. Set Lℓ−1 = (w1, w2, . . . , wdℓ−1−1) (notice that dℓ−1 − 1 ≤ dℓ). It is easy to verify that this list is valid. Next, for each i = ℓ − 1 to 1, perform the following steps: (i) Taking as input the valid list Li of size di − 1, execute Procedure ADDLAYER (G, Li, ni, di) to add ni (ii) Truncate the list Li−1 to contain only the first di−1 − 1(≤ di − 2) vertices. The truncated list remains new vertices to G. The procedure returns a valid list Li−1 of size di − 2. valid since any prefix of a valid list is valid. 13 Proof of Correctness Let Vℓ denote the set of vertices in graph G initialized in step 1, and for i ∈ [1, ℓ − 1], let Vi denote the set of ni new vertices added to graph G in iteration i of the for loop. Also for i ∈ [1, ℓ], let Gi be the graph induced by vertices Vi ∪···∪ Vℓ. The following lemma proves the correctness. Lemma 9. For any i ∈ [1, ℓ], graph Gi is a MAXNDEG realization of profile (dnℓ i ), and for any j ∈ [i, ℓ] and any v ∈ Vj , degGi(v) ≤ MAXNDEGGi(v) = dj . Proof. We prove the claim by induction on the iterations of the for loop. The base case is for index ℓ, and by Lemma 5 we have that degGℓ(v) ≤ MAXNDEGGℓ(v) = dℓ, for every v ∈ Vℓ. For the inductive step, we assume that the claim holds for i + 1, and prove the claim for i. Consider any vertex v in Gi. We have two cases. ℓ ,··· , dni 1. v ∈ Vi 2. v ∈ Vj, for j > i : In this case by Proposition 1 we have that degGi(v) ≤ MAXNDEGGi(v) = di. : We first show that for any vertex w ∈ NGi[v], degGi(w) ≤ dj . If w ∈ Vi, then we already showed degGi(w) ≤ di. So let us consider the case w ∈ Vi+1 ∪ ··· ∪ Vℓ. Now if w ∈ Li participates in Procedure ADDLAYER (G, Li, ni, di), then by Proposition 1, in the up- dated graph degGi(w) ≤ di (cid:12) dj . If w 6∈ Li, then the degree of w is unaltered in the ith itera- tion, and thus degGi(w) = degGi+1(w) ≤ MAXNDEGGi+1(v) = dj by the inductive hypothesis. It follows that MAXNDEG(v) remains unaltered due to iteration i, and thus MAXNDEGGi(v) = MAXNDEGGi+1(v) = dj. The execution time of the algorithm is O(cid:0)Pℓ i=1(ni + di)(cid:1). This is also optimal. Indeed, any connected graph realizing σ must contain Ω(n1 + n2 +··· + nℓ) edges as the degrees of all vertices must be non-zero. Also, the graph must contain at least one vertex of each of the degrees d1, d2, . . . , dℓ, and therefore must have Ω(d1 +d2+···+dℓ) edges. In other words, any realizing graph must contain Ω(cid:0)Pℓ i=1(ni +di)(cid:1) edges, and thus the computation time must be at least Ω(cid:0)Pℓ i=1(ni + di)(cid:1). The following theorem is immediate 1 ) satisfying dℓ ≤ nℓ − 1 and Theorem 5. There exists an algorithm that given any profile σ = (dnℓ d1 ≥ 2 computes in optimal time a connected MAXNDEG realization of σ. from the above discussions. ℓ , . . . , dn1 4.3 A complete characterization for MAXNDEG realizable profiles The necessary conditions for MAXNDEG realizability is as follows. Lemma 10. A necessary condition for a profile σ = (dnℓ nℓ − 1. Proof. Suppose σ is MAXNDEG realizable by a graph G. Then G must contain a vertex, say w, of degree dℓ in G. Since dℓ is the maximum degree in G, the MAXNDEG of all the dℓ + 1 vertices in N [w] must be dℓ. Thus nℓ ≥ dℓ + 1. 1 ) to be MAXNDEG realizable is dℓ ≤ ℓ ,··· , dn1 ℓ ,··· , dn1 Consider a profile σ = (dnℓ 1 ) realizable by a connected graph. If d1 = 1, then the graph must contain a vertex, say v, of degree 1, and the vertices in N [v] must also have degree 1. The only possibility for such a graph is a single edge graph on two vertices. Thus in this case σ = (12). If d1 ≥ 2, then by Lemma 10, for σ to be realizable in this case we need that nℓ ≥ dℓ + 1. Also, by Theorem 5, under these two conditions σ is always realizable. We thus have the following theorem. Theorem 6. For a profile σ = (dnℓ necessary and sufficient condition is that either (i) nℓ ≥ dℓ + 1 and d1 ≥ 2, or (ii) σ = (12). 1 ) to be MAXNDEG realizable by a connected graph the ℓ ,··· , dn1 14 Now if d1 = 1, then n1 must be even, since the vertices v with MAXNDEG(v) = 1 must form a disjoint union of exactly n1/2 edges. So for general graphs we have the following theorem. Theorem 7. For a profile σ = (dnℓ and sufficient conditions are that dℓ ≥ nℓ − 1, and either n1 is even or d1 ≥ 2. ℓ ,··· , dn1 1 ) to be MAXNDEG realizable by a general graph the necessary 5 Realizing maximum open neighborhood-degree profiles We start by formally defining the realizable profiles for maximum degree in open neighborhood. Definition 3 (MAXNDEG− realizable profile). A profile σ = (dnℓ 1 ) is said to be MAXNDEG− realizable if there exists a graph G on n = n1 + ··· + nℓ vertices that for each i ∈ [1, ℓ] contains exactly ni vertices whose MAXNDEG− is di. Equivalently, {v ∈ V (G) : MAXNDEG−(v) = di} = ni ℓ ,··· , dn1 3. 2 2 2 3 2 1 2 3 2 1 (a) (b) Figure 4: A comparison of the MAXNDEG realization of (34, 21) and a MAXNDEG− realization of (33, 22). Observe that in the case of MAXNDEG− profiles, unfortunately, the nice sub-structure property (see Section 6) does not always hold. For example, for the graph considered in Figure 4, the profile σ = (33, 22) is MAXNDEG− realizable, however, the subsequence (33) is not MAXNDEG− realizable. 5.1 Pseudo-valid List We begin by stating the following lemmas that are an extension of Lemma 5 and Proposition 1 presented in Section 4 for MAXNDEG profiles. Lemma 11. For any positive integers d and k, the profile σ = (dk) is MAXNDEG− realizable whenever k ≥ d + 2. Moreover, we can always compute in O(k) time a connected realization that contains an independent set having (i) two vertices of degree 1, and (ii) d − 2 other vertices of degree at most 2. Proposition 2. For any integers d ≥ 2, k ≥ 1, and any connected graph H containing a valid list L of size d − 1, procedure ADDLAYER adds to H in O(k + d) time, a set W of k new vertices such that MAXNDEG−(w) = d, for every w ∈ W . All the edges added to H lie in W × (W ∪ L). Moreover, degH(a) ≤ d, for every a ∈ L, and the updated graph remains connected and contains a new valid list of size d − 2. It is important to note that though the Proposition 2 holds for the open-neighborhoods it can not be directly used to incrementally compute the realizations. This is due to the reason that for the profiles σ = (ddℓ+1 ) unlike the scenario of MAXNDEG realization, there is no MAXNDEG− realization that contains a valid list (See Lemma 13 for further details). ℓ This motivates us to define pseudo-valid lists. 3For a vertex v in H, the maximum degree in the open neighborhood (NH [v] \ v) of vertex v, namely MAXNDEG − H (v) is defined to be the maximum over the degrees of all the vertices present in the open neighborhood of v. 15 Definition 4. A list L = (a1, a2, . . . , at) in a graph H is said to be "pseudo-valid" with respect to H if (i) for each i ∈ [1, t], deg(ai) = 2, and (ii) the vertices of L form an independent set. Note that the only deviation that prevents L from being a valid list is that deg(a1) is 2 instead of 1. We next state two lemmas that are crucial in obtaining MAXNDEG− realizations in the scenarios nℓ = dℓ and nℓ = dℓ + 1. Lemma 12. For any integers d > ¯d ≥ 2, the profile σ = (dd, ¯d1) is MAXNDEG− realizable. Moreover, in O(d) time we can compute a connected realization that contains a valid list of size d − 1. Proof. The construction of G is as follows. Take a vertex z and connect it to d−1 other vertices v1, . . . , vd−1. Next take another vertex y and connect to v1, . . . , v ¯d−1 (recall 2 ≤ ¯d < d). Also connect z to y. In the resulting graph G, deg(z) = d, deg(y) = ¯d, and deg(vi) ≤ 2 for i ∈ [1, d − 1]. Also, vd−1 is not adjacent to y as ¯d < d, thus deg(vd−1) = 1. Therefore, MAXNDEG−(z) = ¯d, MAXNDEG−(y) = d, and MAXNDEG−(vi) = d, for i ∈ [1, d − 1]. It is also easy to verify that (vd−1, . . . , v ¯d−1, . . . , v2, v1) is a valid list in G. Lemma 13. For any integer d ≥ 2, the profile σ = (dd+1) is MAXNDEG− realizable. Moreover, a connected realization that contains an independent set having d − 1 vertices of degree 2 can be compute in O(d) time. However, none of the graphs realizing σ can contain a vertex of degree 1. Proof. The construction of graph G realizing σ is very similar to the previous lemma. Take two vertex-sets, namely, U = {u1, u2} and W = {w1, . . . , wd−1}. Add to G the edge (u1, u2), and for each i ∈ [1, d − 1], add to G the edges (u1, wi) and (u2, wi). This ensures that deg(u1) = deg(u2) = d and deg(wi) = 2 for i ∈ [1, d − 1]. So G contains d + 1 vertices with MAXNDEG− equal to d. Also, W is an independent set of size d − 1 in G and deg(wi) = 2, for every vertex wi ∈ W . Next, let H be any MAXNDEG− realizing graph of σ. Then H must contain two vertices, say x and y, of degree d, since a single vertex of degree d in H can guarantee MAXNDEG− = d for at most d vertices. Next notice that N [x] = N [y], because otherwise H will contain more than d + 1 vertices. This implies that all the vertices in H, other than x and y, are adjacent to both x and y. Therefore, each of the vertices in H must have degree at least two. The next lemma shows that ADDLAYER outputs a valid list, even when the input list is pseudo-valid. Lemma 14. In procedure ADDLAYER, the list Lnew is valid even when the list Lold is pseudo-valid and the parameter d satisfies d ≥ 3. Proof. We borrow notations from the proof of Lemma 8. As before, we have two separate cases depend- ing on whether or not k < d. We first consider the case k ≤ d − 1. We showed in Lemma 8 that (w1,··· , wk, a1, . . . , ai−1) is a valid list of length at least d − 1 when degHold(a1) = 1. We now con- sider the scenario when Lold is pseudo-valid, and degHold(a1) = 2. The list Lnew is still valid if k ≥ 2, since the degree of a1 in Hnew is at most 3 and its position in Lnew is also 3 or greater. So the non-trivial case is k = 1. In such a case i = d − 1, as the only vertex w1 belonging to W is connected to ad−1 in Al- gorithm 2. Also, degHold(ad−1) = 2, and ad−1 is connected to vertex w1, so to ensure that deg(ad−1) = d, in the for loop in step 9 of Algorithm 2, it is connected to only d − 3 vertices, namely, a2, a3, . . . , ad−2. Since ad−1 is never connected to vertex a1, degHnew (a1) = degHold(a1) = 2. This shows that the sequence (w1,··· , wk, a1, . . . , ai−1) = (w1, a1, . . . , ad−2) is a valid list of length exactly d − 1. Truncating it to In case k ≥ d, a1's degree does not play any role, so the length d − 2 again yields a valid sequence. argument from the proof of Lemma 8 works as is. 16 Remark 4. The condition d ≥ 3 is necessary in Lemma 14 because in a pseudo-valid list all the vertices have degree 2. However, Procedure ADDLAYER works only in the case when the degree of each vertex in the list is at most d − 1, which does not hold true for a pseudo-valid list when d = 2. So we provide a different analysis for the profile (dd+1, 2k). 5.2 MAXNDEG− realization of the profile σ = (dd+1, 2k) The following lemmas shows that σ = (dd+1, 21), for d ≥ 3, is not MAXNDEG− realizable when d ≥ 3; and σ = (dd+1, 2k) is MAXNDEG− realizable when d ≥ 3 and k ≥ 2. Lemma 15. For any integer d ≥ 3, the profile σ = (dd+1, 21) is not MAXNDEG− realizable. Proof. Let us assume on the contrary that σ is MAXNDEG− realizable by a graph G, and let w ∈ V (G) be a vertex such that MAXNDEG−(w) = 2. The graph G must contain at least two vertices, say x and y, of degree d, since a single vertex of degree d can guarantee MAXNDEG− of d for at most d vertices in the graph. Consider the following two cases. (i) N [x] = N [y]: In this case the MAXNDEG− of all the vertices in N [x] = N [y] is at least d ≥ 3, as they are adjacent to either x or y. Thus w /∈ N [x], which implies that V (G) = N [x] ∪ {w} since N [x] = d + 1 and V (G) = d + 2. Also, w cannot be adjacent to any vertex in N [x], because if w is adjacent to a vertex w0 ∈ N [x], then deg(w0) must be 3, in contradiction to the assumption MAXNDEG−(w) = 2. Thus the only possibility left is that w is a singleton vertex, which is again a contradiction. (ii) N [x] 6= N [y]: In this case the vertex set of G is equal to N [x] ∪ N [y] since size of N [x] ∪ N [y] must be at least d + 2 (as N [x] ∩ N [y] ≤ d) and is also at most V (G) = d + 2. This implies that all the vertices of G are adjacent to either x or y, which contradicts the fact that MAXNDEG−(w) = 2, since deg(x) = deg(y) = d ≥ 3. Lemma 16. For any integers d ≥ 3 and k ≥ 2, the profile σ = (dd+1, 2k) is MAXNDEG− realizable. Moreover, we can compute a connected realization in O(d + k) time. Proof. The construction of G is as follows. Take a vertex u1 and connect it to d other vertices v1, . . . , vd. Next, take another vertex u2 and connect it to vertices v2, . . . , vd, and a new vertex vd+1. Finally, take a path (a1, a2, . . . , aα) on α = k−2 new vertices, and connect a1 to vd+1. In the graph G, deg(u1) = deg(u2) = d, and deg(vi), deg(aj) ≤ 2, for i ∈ [1, d + 1] and j ∈ [1, k − 2]. Vertices u1 and u2 has maximum degree in their neighborhood 2, thus MAXNDEG−(u1) = MAXNDEG−(u2) = 2. Each vi is adjacent to u1, u2, for i ∈ [1, d + 1], so its MAXNDEG− is d. And, the MAXNDEG− of vertices on the path (a1, a2, . . . , aα) is 2, since they have a neighbour of degree 2. 5.3 Algorithm ℓ We now explain the construction of a graph realizing the profile σ = (dnℓ , 21) that satisfies the conditions (i) dℓ ≤ min{nℓ, n − 1}, and (ii) d1 ≥ 2 , where n = n1 + ··· + nℓ. If σ is equal to (ddℓ+1 , 2k), for some k ≥ 2, we use Lemma 16 to realize σ. If not, then depending upon the value of nℓ, we initialize G differently as follows. (Refer to Algorithm 4 for the pseudocode). 1. If nℓ ≥ dℓ + 2, we use Lemma 11 to initialize G to be a MAXNDEG− realization of the profile (dnℓ ℓ ). Recall G contains an independent set, say W = {w1, w2, . . . , wdℓ}, satisfying the condition that the degree of first two vertices is one, and the degree of the remaining vertices is at most two. We set Lℓ−1 to be the list (w1, w2, . . . , wdℓ−1−1) (notice dℓ−1 − 1 < dℓ). It is easy to verify that this list is valid. 1 ) 6= (ddℓ+1 ℓ ,··· , dn1 ℓ 17 Input: A sequence σ = (dnℓ ℓ ,··· , dn1 1 ) 6= (dℓ dℓ+121) satisfying dℓ ≤ min{n − 1, nℓ} and d1 ≥ 2. , 2k) for some k ≥ 2 then Use Lemma 16 to compute a realization G for profile σ. 1 if σ = (ddℓ+1 2 3 else ℓ 4 5 6 7 8 9 10 11 12 13 14 15 16 case nℓ ≥ dℓ + 2 do case nℓ = dℓ + 1 do case nℓ = dℓ do Initialize G to be the graph obtained from Lemma 11 that realizes the profile (dnℓ Set Lℓ−1 to be a valid list in G of size dℓ−1 − 1. Initialize G to be the graph obtained from Lemma 12 that realizes the profile (ddℓ+1 Set Lℓ−1 to be a pseudo-valid list in G of size dℓ−1 − 1. Initialize G to be the graph obtained from Lemma 13 that realizes the profile (ddℓ Set Lℓ−1 to be a valid list in G of size dℓ−1 − 1. Decrement nℓ−1 by 1. ℓ ). ℓ ). ℓ dℓ−1). for (i = ℓ − 1 to 1) do Li−1 ← ADDLAYER (G, Li, ni, di). Truncate list Li−1 to contain only the first di−1 − 1(≤ di − 2) vertices. 17 Output G. Algorithm 4: MAXNDEG− realization of σ = (dnℓ ℓ , . . . , dn1 1 ) ℓ ℓ 2. If nℓ = dℓ + 1, then a realization of (ddℓ+1 3. If nℓ = dℓ, then the sequence ddℓ ℓ ) does not contains a valid list. So we use Lemma 13 to initialize G to be a MAXNDEG− realization of the profile (ddℓ+1 ) that contains a pseudo-valid list. This is possible since we showed G contains an independent set, say W = {w1, w2, . . . , wdℓ−1}, such that degree of each w ∈ W is two. We set Lℓ−1 to be the list (w1, w2, . . . , wdℓ−1−1) (again notice dℓ−1 − 1 < dℓ − 1). is not realizable (see Lemma 18). So we initialize G to be the graph realization of (dnℓ ℓ , dℓ−1) as obtained from Lemma 12. We set Lℓ−1 be a valid list in G of size dℓ−1 − 1. Also we decrement nℓ−1 by one as G already contain a vertex whose MAXNDEG− is dℓ−1. Next for each i = ℓ − 1 to 1 we perform following steps. (i) We take as an input the valid list Li of size di − 1, and execute Procedure ADDLAYER (G, Li, ni, di) to add ni new vertices to G. The procedure returns a valid list Li−1 of size di − 2. (ii) Truncate list Li−1 to contain only the first di−1 − 1(≤ di − 2) vertices. The truncated list remains valid since it is a prefix of a valid list. Correctness. Let ¯Vℓ denote the set of vertices in graph G initialized in steps 5, 8, or 11 of Algorithm 4, and for i ∈ [1, ℓ − 1], let ¯Vi denote the set of new vertices added to graph G in iteration i of for loop. For i ∈ [1, ℓ], let Gi be the graph induced by vertices ¯Vi ∪ ··· ∪ ¯Vℓ. Recall that if nℓ = dℓ, then the graph is initialized in step 11 and contains nℓ + 1 vertices, of which one vertex, say z, has MAXNDEG−(z) = dℓ−1, and the remaining vertices have MAXNDEG− = dℓ. If nℓ = dℓ, then let Z = {z}, otherwise let Z = ∅. We set Vℓ = ¯Vℓ \ Z, Vℓ−1 = ¯Vℓ−1 ∪ Z, and Vi = ¯Vi for i ∈ [1, ℓ − 2]. Thus Vi = ni, for i ∈ [1, ℓ]. The following lemma proves the correctness. Lemma 17. For any i ∈ [1, ℓ], graph Gi is a MAXNDEG− realization of profile (dnℓ the case nℓ = dℓ in which Gℓ is MAXNDEG− realization of profile (dnℓ i ), except for ℓ , dℓ−1). Moreover, for any j ∈ [i, ℓ], ℓ ,··· , dni 18 we have 1. For every v ∈ Vj \ Z, degGi(v) ≤ MAXNDEG−Gi(v) = dj. 2. If nℓ = dℓ, then degGi(z) = dℓ and MAXNDEG−Gi(z) = dℓ−1. Proof. We prove the claim by induction on the iterations of the for loop. The base case is for index ℓ, and the claim follows from Lemmas 11, 12, and 13. Specifically, notice that every vertex v ∈ Vℓ that is included in G in step 5, 8, or 11 of the algorithm has MAXNDEG−(v) = dℓ. In the case nℓ = dℓ, the vertex z ∈ Vℓ−1 included in step 11 of algorithm has MAXNDEG−(z) = dℓ−1. Also, in both the cases, Vℓ ∪ Z is the vertex set of G, and degree of all the vertices in this set is bounded by dℓ. For the inductive step, we assume that the claim holds for i + 1, and prove the claim for i. Consider any vertex v in Gi. We have two cases. 1. v ∈ Vi \ Z : In this case by Proposition 2 and Lemma 14, degGi(v) ≤ MAXNDEG−Gi(v) = di. 2. v ∈ Vj \ Z, for j > i : In this case we first show that for any vertex w ∈ N (v), degGi(w) ≤ dj . If w ∈ Vi \ Z, then we already showed degGi(w) ≤ di. So we next consider the case w ∈ (Vi+1 ∪ ··· ∪ Vℓ) \ Z. Now if w ∈ Li participates in Procedure ADDLAYER(G, Li, ni, di), then by Proposition 2 in the updated graph degGi(w) ≤ di ≤ dj . If w 6∈ Li, then the degree of w is unaltered in the ith iteration, and thus degGi(w) = degGi+1(w) ≤ dj by the inductive hypothesis. If nℓ = dℓ and w = z ∈ Z, then also degGi(w) = degGi+1(w) since vertex z never participates in procedure ADDLAYER. It follows that MAXNDEG−(v) remains unaltered due to iteration i, and thus MAXNDEG−Gi(v) = MAXNDEG−Gi+1(v) = dj . Now when nℓ = dℓ, then degGℓ(z) = dℓ and MAXNDEG−Gℓ (z) = dℓ−1. The degree of vertex z never changes since it does not participates in procedure ADDLAYER. The MAXNDEG− of z never changes from the same reasoning as above. The following theorem is immediate from the above discussions. The execution time of algorithm takes O(cid:0)Pℓ i=1(ni+di)(cid:1) time, which can be easily shown to be optimal. Theorem 8. There exists an algorithm that given any profile σ = (dnℓ dℓ+121) with n = n1+···+nℓ satisfying dℓ ≤ min{n−1, nℓ} and d1 ≥ 2, computes in optimal time a connected MAXNDEG− realization of σ. 1 ) 6= (dℓ ℓ , . . . , dn1 5.4 Complete characterization of MAXNDEG− profiles. We first give the sufficient conditions for a profile to be MAXNDEG− realizable. Lemma 18. A necessary condition for the profile σ = (dnℓ MAXNDEG− realizable is dℓ ≤ min{nℓ, n − 1}. Proof. Suppose σ is MAXNDEG− realizable by a graph H. Then there exists at least one vertex, say u, of degree exactly dℓ in H. Now N (u) = dℓ and N [u] = dℓ + 1, which implies that the number of vertices in H whose MAXNDEG− is dℓ must be at least dℓ, so nℓ ≥ dℓ. Also, the number of vertices in the graph H, n, must be at least dℓ + 1. 1 ) with n = n1 + ··· + nℓ to be ℓ ,··· , dn1 ℓ ,··· , dn1 Consider a profile σ = (dnℓ 1 ) realizable by a connected graph. If d1 = 1, then the realizing graph must contain a vertex, say u, such that each vertex in N (u) has degree 1. Let d = deg(u), and v1, . . . , vd be the neighbours of u. Then deg(v1) = ··· = deg(vd) = 1. So in this case the realizing graph is a star graph K1,d with MAXNDEG− profile σ = (dd, 11). If d1 ≥ 2, then by Lemma 18, for σ to be realizable in this case, we need that dℓ ≤ min{nℓ, n − 1}. Also, Lemma 15 implies that σ must not be (dd+1, 21). By Theorem 8, under these conditions σ is always realizable. We thus have the following theorem. 19 Theorem 9. The necessary and sufficient condition for a profile σ = (dnℓ 1 ) 6= (dd+1, 21) with n = n1 + ··· + nℓ to be MAXNDEG− realizable by a connected graph is (i) dℓ ≤ min{nℓ, n − 1} and d1 ≥ 2; or (ii) σ = (dd, 11) for some positive integer d > 1; or (iii) σ = (12). ℓ ,··· , dn1 For general graphs we have the following theorem. 2 if δ2 = δ1, or (ii) a connected MAXNDEG− realization of profile (δδ2 Theorem 10. The necessary and sufficient condition for a profile σ to be MAXNDEG− realizable by a general graph is that σ can be split into two profiles σ1 and σ2 such that (i) σ1 has a connected MAXNDEG− realization, and (ii) σ2 = (12α) or σ2 = (dd, 12α+1) for some integers d ≥ 2, α ≥ 0. Proof. Suppose σ is realizable by graph G. Let C(G) be a set consisting of all those components in G that contain a vertex of MAXNDEG− equal to 1 but is not an edge. As a long as C(G) > 1, we per- form following modifications to G. Take any two components C1, C2 ∈ C(G), and let σ1 and σ2 be their MAXNDEG− profiles. For i = 1, 2, component Ci must be of form K1,δi and contain δi(≥ 2) vertices of MAXNDEG− equal to δi, and a single vertex of MAXNDEG− equal to 1. Let us assume δ2 ≥ δ1. We replace C1 and C2 in G by two different components, namely, an edge and (i) a connected MAXNDEG− realization of profile δδ1+δ2 1 ) if δ2 > δ1. In each iteration we decrease C(G) by a value two. In the end if C(G) is non-empty we denote the only component in it by C0. Next let ¯C1, . . . , ¯Ck be all those components in G that contain only the vertices of MAXNDEG− strictly greater than 1. Also let σ1, . . . , σk be their MAXNDEG− profiles. If k > 0, we replace the components ¯C1, . . . , ¯Ck by a single connected component, say ¯C0, that realizes the profile σ1 + ··· + σk. It is easy to verify from Theorem 8 that σ1 + ··· + σk will be MAXNDEG− realizable. The final graph G contains (i) at most one component, namely ¯C0, having all vertices of MAXNDEG− greater than 1, (ii) at most one component, namely C0, having exactly one vertex of MAXNDEG− equal to 1, and (iii) a union of some α ≥ 0 disjoint edges. This shows that σ can be split into two profiles σ1 and σ2 such that (i) σ1 has a connected MAXNDEG− realization, and (ii) σ2 = (12α) or σ2 = (dd, 12α+1) for some integers d ≥ 2, α ≥ 0. To prove the converse notice that σ2 = (12α) is realizable by a disjoint union of α ≥ 0 edges, and σ2 = (dd, 12α+1) is realizable by a disjoint union of α edges and the star graph K1,d. Thus any σ that can be split into two profiles σ1 and σ2 such that (i) σ1 has a connected MAXNDEG− realization, and (ii) σ2 = (12α) or σ2 = (dd, 12α+1) for some integers d ≥ 2, α ≥ 0 is MAXNDEG− realizable. 2 , δδ1 6 Concluding remarks on extremal neighborhood degree profiles Our work focuses on two similar neighborhood profiles, MAXNDEG and MINNDEG, which capture two opposing extremes of the neighborhood, but yet exhibit a surprising difference in structure. The realizability of MAXNDEG profiles depends only on their prefix; in contrast, the realizability characterization of MIN- NDEG profiles is incomplete and depends on the entire profile. Let us conclude with a brief discussion exploring the reasons behind this structural difference. Let us first consider the MAXNDEG profile σ = (dnℓ 1 ) for a graph G = (V, E). For 1 ≤ i ≤ ℓ, let Wi ⊆ V be the set of vertices whose MAXNDEG in G is at least di. Note that for any vertex v ∈ Wi, a vertex having maximum degree in NG[v] (say x) must be contained in Wi. Moreover, all the neighbors of x must also lie in Wi. It follows that the degree of x remains unaltered when restricted to the induced subgraph G[Wi], and MAXNDEGG(v) = MAXNDEGG[Wi](v). Hence, MAXNDEG profiles satisfy the following nice substructure property, which also justifies the incremental algorithm for computing their realizations given in Section 4: ℓ ,··· , dn1 3 A profile σ = (dnℓ ℓ , · · · , dn1 1 ) is said to be split into two profiles σ1 = (dpℓ ℓ , · · · , dp1 1 ) and σ2 = (dqℓ ℓ , · · · , dq1 1 ) if ni = pi+qi for each i ∈ [1, ℓ]. 20 i ), for each 1 ≤ i ≤ ℓ. Substructure Property. The induced graph Gi = G[Wi] is a MAXNDEG realization of the partial profile (dnℓ ℓ ,··· , dni A natural question is whether a similar property holds for MINNDEG profiles. Unfortunately, in this case the answer is negative. To see why, consider the MINNDEG profile σ = (dnℓ 1 ) for G = (V, E). If MINNDEGG(v) is di (for some i and v), and x = arg min{deg(x) x ∈ N [v]} is a leader of v, then the MINNDEG of all vertices in N [x] is at most di. But if we take Wi to be the set of all vertices whose MINNDEG in G is at most di, and drop the vertices z with MINNDEGG(z) > di, i.e., look at the induced graph G[Wi], then the degrees of v's neighbors might decrease, so its leader might change. Hence the sub- structure property does not hold, which renders an incremental construction impossible, and contributes to the intricacy of realizing MINNDEG profiles. ℓ ,··· , dn1 Nevertheless, in this work we obtain a simple 2-approximate bound on the achievable ni's. The problem of obtaining an exact characterization for MINNDEG profiles is left as an interesting open question for future research. References [1] Martin Aigner and Eberhard Triesch. Realizability and uniqueness in graphs. Discrete Mathematics, 136:3 -- 20, 1994. [2] Amotz Bar-Noy, Keerti Choudhary, David Peleg, and Dror Rawitz. Realizability of graph specifi- cations: Characterizations and algorithms. In 25th SIROCCO, volume 11085 of LNCS, pages 3 -- 13, 2018. [3] Amotz Bar-Noy, Keerti Choudhary, David Peleg, and Dror Rawitz. Efficiently realizing interval se- quences. In 30th International Symposium on Algorithms and Computation, ISAAC 2019, December 8-11, 2019, Shanghai University of Finance and Economics, Shanghai, China, pages 47:1 -- 47:15, 2019. [4] Amotz Bar-Noy, Keerti Choudhary, David Peleg, and Dror Rawitz. Graph profile realizations and applications to social networks. In 13th WALCOM, volume 11355 of LNCS, pages 1 -- 12, 2019. [5] Michael D. Barrus and Elizabeth A. Donovan. Neighborhood degree lists of graphs. Discrete Mathe- matics, 341(1):175 -- 183, 2018. [6] Joseph K. Blitzstein and Persi Diaconis. A sequential importance sampling algorithm for generating random graphs with prescribed degrees. Internet Mathematics, 6(4):489 -- 522, 2011. [7] Sheshayya A. Choudum. A simple proof of the Erdos-Gallai theorem on graph sequences. Bulletin of the Australian Mathematical Society, 33(1):67 -- 70, 1991. [8] Brian Cloteaux. Fast sequential creation of random realizations of degree sequences. Internet Mathe- matics, 12(3):205 -- 219, 2016. [9] Paul Erdos and Tibor Gallai. Graphs with prescribed degrees of vertices [hungarian]. Matematikai Lapok, 11:264 -- 274, 1960. [10] S. Louis Hakimi. On realizability of a set of integers as degrees of the vertices of a linear graph -- I. SIAM J. Appl. Math., 10(3):496 -- 506, 1962. [11] V. Havel. A remark on the existence of finite graphs [in Czech]. Casopis Pest. Mat., 80:477 -- 480, 1955. 21 [12] P.J. Kelly. A congruence theorem for trees. Pacific J. Math., 7:961 -- 968, 1957. [13] Milena Mihail and Nisheeth Vishnoi. On generating graphs with prescribed degree sequences for com- plex network modeling applications. 3rd Workshop on Approximation and Randomization Algorithms in Communication Networks, 2002. [14] Elchanan Mossel and Nathan Ross. Shotgun assembly of labeled graphs. CoRR, abs/1504.07682, 2015. [15] Peter V. O'Neil. Ulam's conjecture and graph reconstructions. Amer. Math. Monthly, 77:35 -- 43, 1970. [16] Gerard Sierksma and Han Hoogeveen. Seven criteria for integer sequences being graphic. Journal of Graph Theory, 15(2):223 -- 231, 1991. [17] Amitabha Tripathi and Himanshu Tyagi. A simple criterion on degree sequences of graphs. Discrete Applied Mathematics, 156(18):3513 -- 3517, 2008. [18] S.M. Ulam. A collection of mathematical problems. Wiley, 1960. [19] D.L. Wang and D.J. Kleitman. On the existence of n-connected graphs with prescribed degrees (n > 2). Networks, 3:225 -- 239, 1973. [20] N.C. Wormald. Models of random regular graphs. Surveys in combinatorics, 267:239 -- 298, 1999. 22 Appendix A Counting the Number of Realizable MaxNDeg Sequences We use the characterizations of the variants of MAXNDEG in order to count the number of realizable se- quences. Our results are summarized in the following theorem. Theorem 11. For n ≥ 5 with any graph in the open neighborhood model. • There are 2n−3 realizable sequences with connected graph in the closed neighborhood model. • There are 2n−2 − 1 realizable sequences with connected graph in the open neighborhood model. • There are l 2n−1+(−1)n m realizable sequences with any graph in the closed neighborhood model. • There are at least (cid:6) 2n−2 3 (cid:7) − (cid:6) n−4 2 (cid:7) realizable sequences and at most 2n−1 − 1 realizable sequences There are (n− 1)n unordered sequences (dn, . . . , d1) of length n on the integers 1, . . . , n− 1. We count the number of non-increasing such sequences denoted by Sn. Let f (i, j, k) be the number of non-increasing sequences of length k on the integers i, . . . , j. By definition, Sn = f (1, n − 1, n). Observation 1. f (i, j, k) = (cid:0)k+j−i (cid:1). Proof. This is equivalent to counting the number of ways of placing k balls into j− i+ 1 ordered bins which is equivalent to inserting j − i dividers among a line of k balls. Corollary 3. Sn ≈ 4n−1 √πn Proof. Sn = (cid:0)2n−2 n (cid:1) by Observation 1. Stirling's formula implies the following approximation for the central binomial coefficient (cid:0)2n Θ(√Sn). Theorem 11 and Corollary 3 imply that the number of realizable sequences in all variants is roughly n(cid:1) ≈ 4n √πn . The corollary follows since (2n n ) (2n−2 n ) = 4 + 2 n−1 . k 3 . A.1 Connected Graphs in the Closed Neighborhood Model Let CCON(n) be the number of length n sequences that are MAXNDEG realizable with a connected graph in the closed neighborhood model. Recall that by Theorem 6 the sequence σ = (dnℓ 1 ) ∈ Sn can be realized with a connected graph in the closed neighborhood model if and only if one of the following holds: ℓ , . . . , dn1 (i) n = 2: σ = (12). (ii) n ≥ 3: nℓ ≥ dℓ − 1 and d1 ≥ 2. Lemma 19. CCON(2) = 1 and CCON(n) = 2n−3, for n ≥ 3. Proof. By the first part of the characterization, CCON(2) = 1. Assume n ≥ 3. Let d = dℓ. By the second part of the characterization, the first d + 1 values in any realizable sequence must be equal to d. The suffix of length n − d − 1 is a non-increasing sequence on the numbers 2, . . . , d. By the definition of f (i, j, k) with i = 2, j = d, and k = n − d − 1 and by Observation 1 the number of such sequences is f (2, d, n − d − 1) = (cid:18)(n − d − 1) + d − 2 (cid:19) = (cid:18)n − 3 d − 2(cid:19) . n − d − 1 23 The value of d ranges from 2 to n − 1. Hence, the total number of realizable sequences is CCON(n) = n−1 Xd=2 (cid:18)n − 3 d − 2(cid:19) = n−3 Xi=0 (cid:18)n − 3 i (cid:19) = 2n−3 . A.2 Connected Graphs in the Open Neighborhood Model Let OCON(n) be the number of length n sequences that are MAXNDEG realizable with a connected graph in the open neighborhood model. Recall that by Theorem 9 a sequence σ = (dnℓ 1 ) ∈ Sn can be realized with a connected graph in the open neighborhood model if and only if one of the following holds: ℓ , . . . , dn1 (i) n = 2: σ = (12). (ii) n ≥ 3: σ = ((n − 1)n−1, 11). (iii) n ≥ 3: dℓ ≤ nℓ, d1 ≥ 2, and σ 6= ((n − 2)n−1, 21). Note that the sequence in item 2 is the only sequence in which one vertex has a maximum degree 1 in its open neighborhood. It is realizable by the star graph. Lemma 20. OCON(2) = 1, OCON(3) = 2, OCON(4) = 4, and OCON(n) = 2n−2 − 1, for n ≥ 5. Proof. Following the characterization, one could verify the following: fore OCON(4) = 4. • (1, 1) is the only realizable sequence of length 2. Therefore, OCON(2) = 1. • (2, 2, 2) and (2, 2, 1) are the only realizable sequences of length 3. Therefore, OCON(2) = 2. • (3, 3, 3, 3), (3, 3, 3, 2), (3, 3, 3, 1), and (2, 2, 2, 2) are the only realizable sequences of length 4. There- Assume n ≥ 5. Let d = dℓ. For the sake of counting, we assume that ((n − 2)n−1, 21) should be counted while ((n − 1)n−1, 11) should not. Hence, we need to count the sequences for which dℓ ≤ nℓ and d1 ≥ 2. It follows that the number of realizable sequences with d = dℓ is the number of sequences in which the first d values are equal to d and the suffix of length n − d is a non-increasing sequence on the numbers 2, . . . , d. By Observation 1 with i = 2, j = d, and k = n − d the number of such sequences is f (2, d, n − d) = (cid:18)(n − d) + d − 2 n − d (cid:19) = (cid:18)n − 2 d − 2(cid:19) . The value of d ranges from 2 to n − 1. Hence, the total number of realizable sequences is OCON(n) = n−1 Xd=2 (cid:18)n − 2 d − 2(cid:19) = n−3 Xi=0 (cid:18)n − 2 i (cid:19) = 2n−2 − 1 . Observe that OCON ≈ 2 · CCON(n). This is due to the more relaxed constraint on nℓ. A.3 General Graphs in the Closed Neighborhood Model Let CGEN(n) be the number of length n sequences that are MAXNDEG realizable with a general graph in the closed neighborhood model. By Theorem 7 the sequence σ = (dnℓ 1 ) ∈ Sn can be realized with a general graph (without isolated vertices) in the closed neighborhood model if and only if the following holds for n ≥ 2: dℓ ≤ nℓ − 1, and either d1 ≥ 2 or n1 is even. ℓ , . . . , dn1 24 Lemma 21. For n ≥ 2, CGEN(n) = (2n−1 + (−1)n)/3. Proof. There are no realizable sequences of length 1 and therefore CGEN(1) = 0. The only realizable sequence of length 2 is (1, 1) and therefore CGEN(2) = 1. Assume n ≥ 3. The first part of the characterization covers all the realizations with connected graphs while the second part of the characterization covers all the realizations with n − 2 vertices plus an isolated edge. As a result, we get the following recursive formula, CGEN(n) = CGEN(n − 2) + CCON(n) = CGEN(n − 2) + 2n−3 . We prove by induction that the lemma follows from this recursion. The claim holds for the two base cases n = 1 and n = 2 since (20 + (−1)1)/3 = 0 and (21 + (−1)2)/3 = 1. Assume that the claim is correct for n− 2, that is that CGEN(n− 2) = (2n−3 + (−1)n−2)/3. It follows that CGEN(n) = (2n−3 + (−1)n−2)/3+ 2n−3 = (2n−1 + (−1)n)/3. A.4 General Graphs in the Open Neighborhood Model Let OGEN(n) be the number of length n sequences that are MAXNDEG realizable with a general graph in the open neighborhood model. We do not know how to compute the exact value of OGEN(n) based on our complete characterization. The main reason is that we do not know how to avoid counting more than once a sequence that has several realizations with one star graph where in each realization the size of the star is different. For example, consider the sequence (36, 22, 11). It can be realized with a 3-regular graph of size 6 whose MAXNDEG sequence is (36) and a star of size 3 whose MAXNDEG sequence is (22, 11). It can also be realized by a cycle of size 4 that is connected to a vertex of degree 1 whose MAXNDEG sequence is (33, 22) and a star of size 4 whose MAXNDEG sequence is (33, 11). The problem is that the strategy of extracting the star and counting the number of realizations for the remaining sequence would count more than once sequences from which we can extract stars of different sizes. Instead we provide characterizations for under and over counting. On one hand, we count most of the sequences that can be realized and on the other hand, we count all the realizable sequences, but also some sequences that cannot be realized. Specifically, we show two functions OGENL(n) and OGENU(n) such that OGENL(n) ≤ OGEN(n) ≤ OGENU(n), for n ≥ 2. Let OGENL(n) be the number of sequences σ = (dnℓ 1 ) ∈ Sn that can be realized with a general graph in the open neighborhood model if one of the following holds for n ≥ 2: (i) dℓ ≤ nℓ and d1 ≥ 2. (ii) dℓ ≤ nℓ, d1 = 1, and n1 is even. Lemma 22. OGENL(n) ≤ OGEN(n), for every n ≥ 1. Proof. OGENL(n) counts all the realizations with one connected component and a collection of isolated edges. The connected component could be a star. However, sequences that can be realized with a connected component, a star and a collection of isolated edges are not counted. ℓ , . . . , dn1 Lemma 23. OGENL(2) = 1 and OGENL(n) = ⌈(2n − 2)/3⌉ − ⌈(n − 4)/2⌉, for n ≥ 3. Proof. One can verify the following: 1. The sequence (1, 1) is the only realizable sequence and therefore OGENL(2) = 1. 2. The sequences (2, 2, 2) and (2, 2, 1) are realizable and therefore we can set OGENL(3) = 2. 3. The sequences (3, 3, 3, 3), (3, 3, 3, 2), (3, 3, 3, 1), (2, 2, 2, 2), and (1, 1, 1, 1), are realizable and there- fore we can set OGENL(4) = 5. 25 Lemma 22 implies the following recessive formula for n ≥ 4, OGEN(n) = OGENL(n − 2) + OCON(n) = OGENL(n − 2) + (2n−2 − 1) . We prove by induction that the lemma follows from this recursion. The claim holds for the two base cases n = 3 and n = 4 since (cid:6)(23 − 2)/3(cid:7) − ⌈(3 − 4)/2⌉ = 2 and (cid:6)(24 − 2)/3(cid:7) − ⌈(4 − 4)/2⌉ = 5. The induction hypothesis for n − 2 implies that OGENL(n) = (cid:6)(2n−2 − 2)/3(cid:7) − ⌈(n − 6)/2⌉ + (2n−2 − 1). For an even n, we have OGENL(n) = 2n−2 − 1 3 n − 6 2 − + (2n−2 − 1) = 2n − 1 3 − n − 4 2 = (cid:24) 2n − 2 3 (cid:25) −(cid:24) n − 4 2 (cid:25) , and for an odd n, OGENL(n) = 2n−2 − 2 3 n − 5 2 − + (2n−2 − 1) = 2n − 2 3 − n − 3 2 = (cid:24) 2n − 2 3 (cid:25) −(cid:24) n − 4 2 (cid:25) . Let OGENU(n) be the number of non-increasing sequences σ = (dnℓ ℓ , . . . , dn1 1 ) ∈ Sn that satisfy dℓ ≤ nℓ for n ≥ 2. Lemma 24. OGENU(n) ≥ OGEN(n), for every n ≥ 1. Proof. By Theorem 10 In any realizable sequence, dℓ cannot be larger than min{nℓ, n − 1}. Lemma 25. OGENU(2) = 1 and OGENU(n) = 2n−1 − 1, for n ≥ 2. Proof. For n = 2, (1, 1) is the only sequence and therefore OGENU(2) = 1. Assume n ≥ 2. Let d = dℓ. The first d values in any realizable sequence must be equal to d. The suffix of length n−d is a non-increasing sequence on the numbers 1, . . . , d. By Observation 1 with i = 1, j = d, and k = n − d the number of such sequences is f (1, d, n − d) = (cid:18)(n − d) + d − 1 n − d (cid:19) = (cid:18)n − 1 d − 1(cid:19) . The value of d ranges from 1 to n − 1. Hence, the total number of realizable sequences is OGENU(n) = n−1 Xd=1 (cid:18)n − 1 d − 1(cid:19) = n−2 Xi=0 (cid:18)n − 1 i (cid:19) = 2n−1 − 1 . Observe that the ratio between the upper bound and the lower bound is about 3/2. 26
1106.6342
1
1106
2011-06-30T19:04:18
Quadratic-time Algorithm for the String Constrained LCS Problem
[ "cs.DS" ]
The problem of finding a longest common subsequence of two main sequences with some constraint that must be a substring of the result (STR-IC-LCS) was formulated recently. It is a variant of the constrained longest common subsequence problem. As the known algorithms for the STR-IC-LCS problem are cubic-time, the presented quadratic-time algorithm is significantly faster.
cs.DS
cs
Quadratic-time Algorithm for the String Constrained LCS Problem Sebastian Deorowicz September 5, 2018 Abstract The problem of finding a longest common subsequence of two main sequences with some constraint that must be a substring of the result (STR-IC-LCS) was formulated recently. It is a variant of the constrained longest common subsequence problem. As the known algorithms for the STR-IC-LCS problem are cubic-time, the presented quadratic-time algorithm is significantly faster. Keywords: sequence similarity, longest common subsequence, constrained longest com- mon subsequence 1 Introduction One of the most popular ways of measuring sequence similarity is computation of their longest common subsequence (LCS) [7], in which we are interested in a subsequence that is common to all sequences and has the maximal possible length. It is well known that for two sequences of length n and m an LCS can be found in O(nm) time, which is a lower bound of time complexity in the comparison-based computing model for this problem [1]. In the more practical, RAM model of computations, the asymptotically fastest algorithm is the one by Masek and Paterson which runs in O(nm/ log n) time for bounded and O(mn log log n/ log n) for unbounded alphabet [8]. One family of LCS-related problems considers one or more constraining sequences, such that (in some variants) must be included, or (in other problem variants) are forbidden as part of the resulting sequence [3, 9]. The motivation for these generalizations came from bioinformatics in which some prior knowledge is often available and one can specify some requirements on the result [9, 5]. In this work, we consider the problem called STR-IC-LCS, introduced in [3], in which a constraining sequence of length r must be included as a substring of a common subsequence of two main sequences and the length of the result must be maximal. In [3] an O(nmr)-time algorithm was given for it. Farhana et al. [6] proposed finite-automata-based algorithms for the STR-IC-LCS, CLCS, and two other problems defined by Chen and Chao [3]. The authors claim that the algorithms work in O(r(n + m) + (n + m) log(n + m)) time in the worst case. It seems to be a breakthrough as it means also that the LCS problem could be solved in 1 O(n log n) time. Unfortunately, the time complexity analysis are based on the claim from [2] that a directed acyclic subsequence graph (DASG) for two sequences of lengths n and m contains O(n + m) states and can be built in O((n + m) log(n + m)) time. As was shown by Crochemore et al. [4] this result was wrong and such a DASG contains Ω(nm) states in the worst case, so its construction time cannot be lower. Thus, the algorithms by Farhana et al. [6] work in Ω(nmr) time for the variants of the CLCS problem and Ω(nm) for the LCS problem. Moreover, these complexities are under assumption that the alphabet size is constant, otherwise they should be multiplied by its size. In this paper, we propose the first quadratic-time algorithm for the STR-IC-LCS problem and show also further possible improvements of the time complexity. We also present how this algorithm can be extended to many main input sequences. The paper is organized as follows. In Section 2, some definitions are given and the problem is formally stated. Section 3 describes our algorithm. Extension to the case of many main sequences and some improvements of the algorithm are given in Section 4. The last section concludes. 2 Definitions Let us have two main sequences A = a1a2 . . . an and B = b1b2 . . . bm and one constraining sequence P = p1p2 . . . pr. W.l.o.g. we can assume that r ≤ m ≤ n. Each sequence is composed of symbols from alphabet Σ of size σ. The length (or size) of any sequence X is the number of elements it is composed of and is denoted as X. A sequence X ⋆ is a subsequence of X if it can be obtained from X by removing zero or more symbols. The LCS problem for A and B is to find a subsequence C of both A and B of the maximal possible length. The LCS length for A and B is denoted by LLCS (A, B). A sequence β is a substring of X if X = αβγ for some, possibly empty, sequences α, β, γ. An appearance of sequence X = x1x2 . . . xX in sequence Y = y1y2 . . . yY starting at position j is a sequence of indexes i1, i2, . . . , iX such that i1 = j, and X = yi1 . . . yiX. A compact appearance of a sequence X in Y starting at position j is the appearance of the smallest last index, iX. A match for sequences A and B is a pair (i, j) such that ai = bj. The total number of matches for A and B is denoted by d. It is obvious that d ≤ mn. The STR-IC-LCS problem for the main sequences A, B, and the constraining sequence P is to find a subsequence C of both A and B of the maximal possible length containing P as its substring. (In the CLCS problem, C must be a subsequence of P .) 3 The algorithm The algorithm we propose is based on dynamic programming with some preprocessing. To show its correctness it is necessary to prove some lemma. Let C = c1c2 . . . cℓ be a longest common subsequence with substring constraint for A, B, and P . Let also I = (i1, j1), (i2, j2), . . . , (iℓ, jℓ) be a sequence of indexes of C symbols in A and B, i.e., C = ai1ai2 . . . aiℓ and C = bj1bj2 . . . bjℓ. From the problem statement, there must exists such q ∈ [1, ℓ − r + 1] that P = aiq aiq+1 . . . aiq+r−1 and P = bjqbjq+1 . . . bjq+r−1. 2 q = iq and for all t ∈ [1, r − 1], i′ Lemma 1. Let i′ i′ q+t−1, index in A such that aiq+t = ai′ (i′ q, jq), (i′ sequence of A and B with string constraint P equal C. q+t be the smallest possible, but larger than q+t The sequence of indexes I ′ = (i1, j1), . . . , (iq−1, jq−1), q+r−1, jq+r−1), (iq+r, jq+r), . . . , (iℓ, jℓ) defines a longest common sub- q+1, jq+1), . . . , (i′ q = iq, and i′ Proof. From the definition of indexes i′ q+t it is obvious that they form an increasing sequence, since i′ q+r−1 is of course a compact appearance of P in A starting at iq. Therefore, both components of I ′ pairs form increasing u, so sequence I ′ defines an STR-IC-LCS C ′ equal C. sequences and for any (i′ q+r−1 ≤ iq+r−1. The sequence i′ q, . . . , i′ u, j′ u), ai′ u = bj′ A similar lemma can be formulated for j-th component of sequence I. Thus, it is easy to conclude that when looking for an STR-IC-LCS, instead of checking any common sub- sequences of A and B it suffices to check only such common subsequences that contain compact appearances of P both in A and B. (This is a direct consequence of the fact that LLCS (X, Y ) ≤ LLCS (X, αY ) for any sequence α.) The number of different compact appearances of P in A and B will be denoted by dA and dB, respectively. It is easy to notice that dAdB ≤ d, since a pair (i, j) defines a compact appearance of P in A starting at i-th position and compact appearance of P in B starting at j-th position only for some matches. The algorithm computing an STR-IC-LCS (Fig. 1) consists of three main stages. In the first stage, both main sequences are preprocessed to determine for each occurrence of the first symbol of P , the index of the last symbol of a compact appearance of P . In the second stage, two DP matrices are computed: the forward one and the reverse one. The recurrence is exactly as for the LCS computation. In the last stage, the result is determined. To this end for each match (i, j) for A and B the ends (i′, j′) of compact appearances of P in A starting at i-th position and in B starting at j-th position are read. The length of an STR-IC-LCS containing these appearances of P is determined as a sum of the LCS length of prefixes of A and B ending at i-th and j-th positions, respectively, the LCS length of suffixes of A and B starting at i′-th and j′-th positions, respectively, and the constraint length. Since, the first and last constraint symbol was summed twice, the final result is decreased by 2. According to the F and R matrices, backtracking can be used to obtain the subsequence, not only its length. Lemma 2. The STR-IC-LCS algorithm (Fig. 1) correctly computes an STR-IC-LCS. Proof. The algorithm considers all pairs of compact appearances of P in A and B. Each such a pair divides the problem into two independent LCS length-computing subproblems. According to the precomputed F and R matrices it is easy to solve these subproblems (lines 18 -- 20) in constant time. The length of an STR-IC-LCS must be a sum of the found lengths of LCSs and the constraint length subtracted by 2. Lemma 3. The worst-case time complexity of the proposed algorithm is O(mn). Proof. The preprocessing stage can be done in O((n + m)r) worst-case time. The main stage consists of computation of two DP matrices which needs O(mn) time. In the final stage, the DP matrix is traversed and for each match a constant number of operations is performed, so these stages consumes O(mn) time. Summing these up gives O(mn) time. 3 STR-IC-LCS(A, B, P ) {Preprocessing} for i ← 1 to n do if ai = p1 then M A[i] ← smallest q such that p1 . . . pr is a subsequence of ai . . . aq for j ← 1 to m do if bi = p1 then M B[j] ← smallest q such that p1 . . . pr is a subsequence of bj . . . bq {Computation of forward and reverse DP matrices} for i ← 0 to n + 1 do F [i, 0] ← 0; R[i, m + 1] ← 0 for j ← 0 to m + 1 do F [0, j] ← 0; R[n + 1, j] ← 0 for i ← 1 to n do for j ← 1 to m do if ai = bj then F [i, j] = F [i − 1, j − 1] + 1 else F [i, j] = max(F [i − 1, j], F [i, j − 1]) for i ← n downto 1 do for j ← m downto 1 do if ai = bj then R[i, j] = R[i + 1, j + 1] + 1 else F [i, j] = max(R[i + 1, j], R[i, j + 1]) {Determination of the result} ℓ ← 0; i⋆ ← 0; j⋆ ← 0 for i ← 1 to n do for j ← 1 to m do if ai = bj and F [i, j] + R[M A[i], M B[j]] + r − 2 > ℓ then 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ℓ ← F [i, j] + R[M A[i], M B[j]] + r − 2 i⋆ ← i; j⋆ ← j 20 21 Backtrack from (i⋆, j⋆) according to F and obtain S1 22 Backtrack from (M A[i⋆], M b[j⋆]) according to R and obtain S2 23 return ℓ and S1p2p3 . . . pr−1S2 Figure 1: A pseudocode of the STR-IC-LCS computing algorithm for two main sequences and one constraining sequence Lemma 4. The space consumption of the algorithm is O(mn). 4 Improvements and extensions If one is interested only in the STR-IC-LCS length, it is easy to notice that F and R matrices can be computed row-by-row which means that only O(m) words are necessary for them. The values of F and R for matches of symbols equal p1 in F and pr in R must, however, be stored explicitly, so the space for them is O(d⋆) (where d⋆ = O(mn) is the number of such matches). This gives the total space O(n + d⋆). If also the subsequence is requested, the cells for all matches must be stored to allow backtracking, so the space is O(n + d) (in the worst case d = O(mn)). As the only cells that are necessary to be stored explicitly are those for matches, the Hunt -- Szymanski method [7] can be used to speed up the computation of F and R matrices if the number of matches is small. Therefore, the second stage can be completed in O(d log log m + 4 n) time if σ = O(n) and O(d log log n + n log n) otherwise. The time complexity of the final stage is O(d). Adding the time for the preprocessing we obtain the worst case time complexities: O(d log log m + nr) for σ = O(n) and O(d log log n + n(r + log n)) otherwise. The generalization of the LCS problem for many sequences is direct, but the time com- plexity of the exact algorithm computing the multidimensional DP matrix is O(2znz), where z is the number of sequences of length O(n) each [7]. It is easy to notice that according to Lemma 1 the STR-IC-LCS problem generalizes in the same way and the worst-case time complexity is also O(2znz). 5 Conclusions We investigated the STR-IC-LCS problem introduced recently. The fastest algorithms solv- ing this problem known to date needed cubic time in case of two main and one constraining sequences. Our algorithm is faster, as its time complexity is only quadratic. Moreover, the algorithm uses an LCS-computation procedure as a component and any progresses in the LCS computation can improve the time complexities of the proposed method. We also showed an irrecoverable flaw in [6], in which the algorithm of better than cubic time complexity was recently proposed, i.e., we proved this algorithm is supercubic in the worst case. Acknowledgments The author thanks Szymon Grabowski for reading preliminary versions of the paper and suggesting improvements. References [1] A.V. Aho, D.S. Hirschberg, and J.D. Ullman. Bounds on the complexity of the longest common subsequence problem. Journal of the ACM, 23(1):1 -- 12, 1976. [2] R.A. Baeza-Yates. Searching subsequences. Theoretical Computer Science, 78:363 -- 376, 1991. [3] Y.-C. Chen and K.-M. Chao. On the generalized constrained longest common subse- quence problems. Journal of Combinatorial Optimization, 21:383 -- 392, 2011. [4] M. Crochemore, B. Melichar, and Z. Tron´ıcek. Directed acyclic subsequence graph -- overview. Journal of Discrete Algorithms, 1:255 -- 280, 2003. [5] S. Deorowicz. Bit-parallel algorithm for the constrained longest common subsequence problem. Fundamenta Informaticae, 99(4):409 -- 433, 2010. [6] E. Farhana, J. Ferdous, T. Moosa, and M.S. Rahman. Finite automata based algorithm for the generalized constrained longest common subsequence problems. LNCS, 6393:243 -- 249, 2010. 5 [7] D. Gusfield. Algorithms on Strings, Trees and Sequences: Computer Science and Com- putational Biology. Cambridge University Press, 1997. [8] W.J. Masek and M.S. Paterson. A faster algorithm computing string edit distances. Journal of Computer System Science, 20(1):18 -- 31, 1980. [9] Y.-T. Tsai. The constrained common subsequence problem. Information Processing Letters, 88:173 -- 176, 2003. 6
1801.04641
4
1801
2019-02-09T19:47:26
Strategies for Stable Merge Sorting
[ "cs.DS" ]
We introduce new stable natural merge sort algorithms, called $2$-merge sort and $\alpha$-merge sort. We prove upper and lower bounds for several merge sort algorithms, including Timsort, Shivers' sort, $\alpha$-stack sorts, and our new $2$-merge and $\alpha$-merge sorts. The upper and lower bounds have the forms $c \cdot n \log m$ and $c \cdot n \log n$ for inputs of length~$n$ comprising $m$~monotone runs. For Timsort, we prove a lower bound of $(1.5 - o(1)) n \log n$. For $2$-merge sort, we prove optimal upper and lower bounds of approximately $(1.089 \pm o(1))n \log m$. We prove similar asymptotically matching upper and lower bounds for $\alpha$-merge sort, when $\varphi < \alpha < 2$, where $\varphi$ is the golden ratio. Our bounds are in terms of merge cost; this upper bounds the number of comparisons and accurately models runtime. The merge strategies can be used for any stable merge sort, not just natural merge sorts. The new $2$-merge and $\alpha$-merge sorts have better worst-case merge cost upper bounds and are slightly simpler to implement than the widely-used Timsort; they also perform better in experiments. We report also experimental comparisons with algorithms developed by Munro-Wild and Jug\'e subsequently to the results of the present paper.
cs.DS
cs
Strategies for Stable Merge Sorting Sam Buss [email protected] Alexander Knop [email protected] Department of Mathematics Department of Mathematics University of California, San Diego University of California, San Diego La Jolla, CA, USA La Jolla, CA, USA February 12, 2019 Abstract We introduce new stable natural merge sort algorithms, called 2-merge sort and α-merge sort. We prove upper and lower bounds for several merge sort algorithms, including Timsort, Shivers' sort, α-stack sorts, and our new 2-merge and α-merge sorts. The upper and lower bounds have the forms c · n log m and c · n log n for inputs of length n comprising m monotone runs. For Timsort, we prove a lower bound of (1.5 − o(1))n log n. For 2-merge sort, we prove optimal upper and lower bounds of approximately (1.089 ± o(1))n log m. We prove similar asymptotically matching upper and lower bounds for α-merge sort, when ϕ < α < 2, where ϕ is the golden ratio. Our bounds are in terms of merge cost; this upper bounds the number of comparisons and accurately models runtime. The merge strategies can be used for any stable merge sort, not just natural merge sorts. The new 2-merge and α-merge sorts have better worst-case merge cost upper bounds and are slightly simpler to implement than the widely-used Timsort; they also perform better in experiments. We report also experimental comparisons with algorithms developed by Munro-Wild and Jug´e subsequently to the results of the present paper. 1 Introduction This paper studies stable merge sort algorithms, especially natural merge sorts. We will propose new strategies for the order in which merges are performed, and prove upper and lower bounds on the cost of several merge strategies. The first merge sort algorithm was proposed by von Neumann [17, p.159]: it works by splitting the input list into sorted sublists, initially possibly lists of length one, and then iteratively merging pairs of sorted lists, until the entire input is sorted. A sorting algorithm is stable if it preserves the relative order of elements which are not distinguished by the sort order. There are several methods of splitting the input into sorted sublists before starting the merging; a merge sort is called natural it finds the sorted sublists by detecting consecutive runs of entries in the input which are already in sorted order. Natural merge sorts were first proposed by Knuth [17, p.160]. Like most sorting algorithms, the merge sort is comparison-based in that it works by comparing the relative order of pairs of entries in the input list. Information-theoretic considerations imply 1The present paper is an expansion of an earlier conference paper [4]. It includes the contents of [4] plus a new easy, direct proof of an O(n log m) upper bound for α-merge sort (Theorem 15), the proof of the tight upper bounds for α-merge sort (Theorem 23), and experimental comparisons with the algorithms of Munro-Wild [25] and Jug´e [16] that were developed after this paper was first circulated. 1 that any comparison-based sorting algorithm must make at least log2(n!) ≈ n log2 n comparisons in the worst case. However, in many practical applications, the input is frequently already partially sorted. There are many adaptive sort algorithms which will detect this and run faster on inputs which are already partially sorted. Natural merge sorts are adaptive in this sense: they detect sorted sublists (called "runs") in the input, and thereby reduce the cost of merging sublists. One very popular stable natural merge sort is the eponymous Timsort of Tim Peters [26]. Timsort is extensively used, as it is included in Python, in the Java standard library, in GNU Octave, and in the Android operating system. Timsort has worst-case runtime O(n log n), but is designed to run substantially faster on inputs which are partially pre-sorted by using intelligent strategies to determine the order in which merges are performed. There is extensive literature on adaptive sorts: e.g., for theoretical foundations see [22, 10, 27, 24] and for more applied investigations see [7, 13, 6, 32, 28]. The present paper will consider only stable, natural merge sorts. As exemplified by the wide deployment of Timsort, these are certainly an important class of adaptive sorts. We will consider the Timsort algorithm [26, 8], and related sorts due to Shivers [29] and Auger-Nicaud-Pivoteau [2]. We will also introduce new algorithms, the "2-merge sort" and the "α-merge sort" for ϕ < α < 2 where ϕ is the golden ratio. The main contribution of the present paper is the definition of new stable merge sort algorithms, called 2-merge and α-merge sort. These have better worst-case run times than Timsort, are slightly easier to implement than Timsort, and perform better in our experiments. We focus on natural merge sorts, since they are so widely used. However, our central contribu- tion is analyzing merge strategies and our results are applicable to any stable sorting algorithm that generates and merges runs, including patience sorting [6], melsort [30, 21], and split sorting [20]. All the merge sorts we consider will use the following framework. (See Algorithm 1.) The input is a list of n elements. The first logical stage of the algorithm (following [26]) identifies maximal length subsequences of consecutive entries which are in sorted order, either ascending or descending. The descending subsequences are reversed, and this partitions the input into "runs" R1, . . . , Rm of entries sorted in non-decreasing order. The number of runs is m; the number of elements in a with linear number of comparisons. run R is R. Thus Pi Ri = n. It is easy to see that these runs may be formed in linear time and Merge sort algorithms process the runs in left-to-right order starting with R1. This permits runs to be identified on-the-fly, only when needed. This means there is no need to allocate Θ(m) additional memory to store the runs. This also may help reduce cache misses. On the other hand, it means that the value m is not known until the final run is formed; thus, the natural sort algorithms do not use m except as a stopping condition. The runs Ri are called original runs. The second logical stage of the natural merge sort algo- rithms repeatedly merges runs in pairs to give longer and longer runs. (As already alluded to, the first and second logical stages are interleaved in practice.) Two runs A and B can be merged in linear time; indeed with only A + B − 1 many comparisons and A + B many movements of elements. The merge sort stops when all original runs have been identified and merged into a single run. Our mathematical model for the run time of a merge sort algorithm is the sum, over all merges of pairs of runs A and B, of A + B. We call the quantity the merge cost. In most situations, the run time of a natural sort algorithm can be linearly bounded in terms of its merge cost. Our main theorems are lower and upper bounds on the merge cost of several stable natural merge sorts. Note that if the runs are merged in a balanced fashion, using a binary tree of height ⌈log m⌉, then the total merge cost ≤ n⌈log m⌉. (We use log to denote logarithms base 2.) Using a balanced binary tree of merges gives a good worst-case merge cost, but it does not take into account savings that 2 are available when runs have different lengths.2 The goal is find adaptive stable natural merge sorts which can take advantage of different run lengths to reduce the merge cost even below n log m, but which are guaranteed to never be much worse than the binary tree. Therefore, our preferred upper bounds on merge costs are stated in the form c · n log m for some constant c, rather than in the form c · n log n. The merge cost ignores the O(n) cost of forming the original runs Ri: this does not affect the asymptotic limit of the constant c. Algorithm 1 shows the framework for all the merge sort algorithms we discuss. This is similar to what Auger et al. [2] call the "generic" algorithm. The input S is a sequence of integers which is partitioned into monotone runs of consecutive members. The decreasing runs are inverted, so S is expressed as a list R of increasing original runs R1, . . . , Rm called "original runs". The algorithm maintains a stack Q of runs Q1, . . . , Qℓ, which have been formed from R1, . . . , Rk. Each time through the loop, it either pushes the next original run, Rk+1, onto the stack Q, or it chooses a pair of adjacent runs Qi and Qi+1 on the stack and merges them. The resulting run replaces Qi and Qi+1 and becomes the new Qi, and the length of the stack decreases by one. The entries of the runs Qi are stored in-place, overwriting the elements of the array which held the input S. Therefore, the stack needs to hold only the positions pi (for i = 0, . . . , ℓ+1) in the input array where the runs Qi start, and thereby implicitly the lengths Qi of the runs. We have p1 = 0, pointing to the beginning of the input array, and for each i, we have Qi = pi+1 − pi. The unprocessed part of S in the input array starts at position pℓ+1 = pℓ + Qℓ. If pℓ+1 < n, then it will be the starting position of the next original run pushed onto Q. Algorithm 1 The basic framework for all our merge sort algorithms. S is a sequence of integers of length n. R is the list of m runs formed from S. Q is a stack of ℓ runs, Q1, Q2, . . . , Qℓ. The top member of the stack Q is Qℓ. k1 and k2 are fixed (small) integers. The algorithm is (k1, k2)-aware. Upon termination, Q contains a single run Q1 which is the sorted version of S. 1: procedure MergeSortFramework(S, n) 2: R ← list of runs forming S Q ← empty stack while R 6= ∅ or Q has > 1 member do 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: choose to do either (A) or (Bi) for some ℓ − k2 < i < ℓ, based on whether R is empty and on the values Qj for ℓ − k1 < j ≤ ℓ (A) Remove the next run R from R and push it onto Q. This increments ℓ = Q by 1. (Bi) Replace Qi and Qi+1 in Q with Merge(Qi, Qi+1). This decrements ℓ = Q by 1. end choose end while Return Q1 as the sorted version of S. 13: 14: end procedure Algorithm 1 is called (k1, k2)-aware since its choice of what to do is based on just the lengths of the runs in the top k1 members of the stack Q, and since merges are only applied to runs in the top k2 members of Q. ([2] used the terminology "degree" instead of "aware".) In all our applications, 2[12] gives a different method of achieving merge cost O(n log m). Like the binary tree method, their method is not adaptive. 3 k1 and k2 are small numbers, so it is appropriate to store the runs in a stack. Usually k1 = k2, and we write "k-aware" instead of "(k, k)-aware". Table 1 shows the awareness values for the algorithms considered in this paper. To improve readability (and following [2]), we use the letters W, X, Y, Z to denote the top four runs on the stack, Qℓ−3, Qℓ−2, Qℓ−1, Qℓ respectively, (if they exist).3 Algorithm Timsort (original) [26] Timsort (corrected) [8] Awareness 3-aware (4,3)-aware α-stack sort [2] Shivers sort [29] 2-merge sort α-merge sort (ϕ<α<2) 2-aware 2-aware 3-aware 3-aware Table 1: Awareness levels for merge sort algorithms In all the sorting algorithms we consider, the height of the stack Q will be small, namely ℓ = O(log n). Since the stack needs only store the ℓ+1 values p1, . . . , pℓ+1, the memory requirements for the stack are minimal. Another advantage of Algorithm 1 is that runs may be identified on the fly and that merges occur only near the top of the stack: this may help reduce cache misses. (See [19] for other methods for reducing cache misses.) Merge(A, B) is the run obtained by stably merging A and B. Since it takes only linear time to extract the runs R from S, the computation time of Algorithm 1 is dominated by the time needed for merging runs. As already mentioned, we use A + B as the mathematical model for the runtime of a (stable) merge. The usual algorithm for merging A and B uses an auxiliary buffer to hold the smaller of A and B, and then merging directly into the combined buffer: this has runtime proportional to A + B. Timsort [26] uses a variety of techniques to speed up merges, in particular "galloping"; this also still takes time proportional to A + B in general. It is possible to perform (stable) merges in-place with no additional memory [18, 23, 14, 31, 11]; these algorithms also require time Θ(A + B). More complicated data structures can perform merges in sublinear time in some situations; see for instance [5, 12]. These methods do not seem to be useful in practical applications, and of course still have worst-case run time Θ(A + B). If A and B have very unequal lengths, there are (stable) merge algorithms which use fewer than Θ(A + B) comparisons [15, 31, 11]. Namely, if A ≤ B, then it is possible to merge A and B in time O(A + B) but using only O(A(1 + log(B/A))) comparisons. Nonetheless, we feel that the cost A + B is the best way to model the runtime of merge sort algorithms. Indeed, the main strategies for speeding up merge sort algorithms try to merge runs of approximate equal length as much as possible; thus A and B are very unequal only in special cases. Of course, all our upper bounds on merge cost are also upper bounds on number of comparisons. Definition 1. The merge cost of a merge sort algorithm on an input S is the sum of A + B taken over all merge operations Merge(A, B) performed. For Qi a run on the stack Q during the computation, the merge cost of Qi is the sum of A + B taken over all merges Merge(A, B) used to combine runs that form Qi. Our definition of merge cost is motivated primarily by analyzing the run time of sequential algorithms. Nonetheless, the constructions may be applicable to distributed sorting algorithms, 3[26] used "A, B, C" for "X, Y, Z". 4 such as in MapReduce [9]. A distributed sorting algorithm typically performs sorts on subsets of the input on multiple processors: each of these can take advantage of a faster sequential merge sort algorithm. Applications to distributed sorting are beyond the scope of the present paper however. In later sections, the notation wQi is used to denote the merge cost of the i-th entry Qi on the stack at a given time. Here "w" stands for "weight". The notation Qi denotes the length of the run Qi. We use mQi to denote the number of original runs which were merged to form Qi. All of the optimizations used by Timsort mentioned above can be used equally well with any of the merge sort algorithms discussed in the present paper. In addition, they can be used with other sorting algorithms that generate and merge runs. These other algorithms include patience sort [6], melsort [30] (which is an extension of patience sort), the hybrid quicksort-melsort algorithm of [21], and split sort [20]. The merge cost as defined above applies equally well to all these algorithms. Thus, it gives a runtime measurement which applies to a broad range of sort algorithms that incorporate merges and which is largely independent of which optimizations are used. Algorithm 1, like all the algorithms we discuss, only merges adjacent elements, Qi and Qi+1, on the stack. This is necessary for the sort to be stable: If i < i′′ < i′ and two non-adjacent runs Qi and Qi′ were merged, then we would not know how to order members occurring in both Qi′′ and Qi ∪ Qi′. The patience sort, melsort, and split sort can all readily be modified to be stable, and our results on merge costs can be applied to them. Our merge strategies do not apply to non-stable merging, but Barbay and Navarro [3] have given an optimal method -- based on Huffmann codes -- of merging for non-stable merge sorts in which merged runs do not need to be adjacent. The known worst-case upper and lower bounds on stable natural merge sorts are listed in Table 2. The table expresses bounds in the strongest forms known. Since m ≤ n, it is generally preferable to have upper bounds in terms of n log m, and lower bounds in terms of n log n. Algorithm Upper bound Lower bound Timsort4 (cid:26) O(n log n) [1, 2] O(n log m) [1] (cid:27) α-stack sort O(n log n) [2] Shivers sort (cid:26) 2-merge sort n log n [29] See also Theorem 11 (cid:27) c2 · n log m [Theorem 24] 1.5 · n log n [Theorem 3] (cid:26) cα · n log n [Theorem 8] [Theorem 9] ω(n log m) ω(n log m) [Theorem 10] c2 · n log n [Theorem 17] α-merge sort cα · n log m [Theorem 23] cα · n log n [Theorem 16] Table 2: Upper and lower bounds on the merge cost of various algorithms. For more precise statements, see the theorems. The results hold for ϕ < α ≤ 2; for these values, cα is defined by In particular, c2 = 3/ log(27/4) ≈ 1.08897. All equation (2) and satisfies 1.042 < cα < 1.089. bounds are asymptotic; that is, they are correct up to a multiplicative factor of 1 ± o(1). For this reason, the upper and lower bounds in the last two lines of the the table are not exactly matching. The table lists 2-merge sort and α-merge sort on separate lines since 2-merge sort is slightly simpler than α-merge sort. In addition, our proof of the upper bound for 2-merge sort is substantially simpler than our proof for α-merge sort. 4When the first draft of the present paper was circulated, the question of an O(n log m) upper bound for Timsort was still open; this was subsequently resolved by [1]. 5 The main results of the paper are those listed in the final two lines of Table 2. Theorem 24 proves that the merge cost of 2-merge sort is at most (d2 + c2 log m) · n, where d2 ≈ 1.911 and c2 ≈ 1.089: these are very tight bounds, and the value for c2 is optimal by Theorem 17. It is also substantially better than the worst-case merge cost for Timsort proved in Theorem 3. Similarly for ϕ < α < 2, Theorem 24 proves an upper bound of (dα + cα log m) · n. The values for cα are optimal by Theorem 16; however, our values for dα have unbounded limit limα→ϕ+ dα and we conjecture this is not optimal. We only analyze α-merge sorts with α > ϕ. For ϕ < α ≤ 2, the α-merge sorts improve on Timsort, by virtue of having better run time bounds and by being slightly easier to implement. In addition, they perform better in the experiments reported in Section 6. It is an open problem to extend our algorithms to the case of α < ϕ; we expect this will require k-aware algorithms with k > 3. Table 2 does not include two new stable merge sorts that were developed by Munro-Wild [25] and Jug´e [16] subsequently to the circulation of the first draft of the present paper. Jug´e's "adaptive Shivers" sort is 3-aware. Munro and Wild's "powersort" algorithm is 3-aware except that it requires knowing the value of n ahead of time. Both of these sorting alorithms have asymptotic lower and upper bounds on running time of n log m. The outline of the paper is as follows. Section 2 describes Timsort, and proves the lower bound on its merge cost. Section 3 discusses the α-stack sort algorithms, and gives lower bounds on their merge cost. Section 4 describes the Shivers sort, and gives a simplified proof of the n log n upper bound of [29]. Section 5 is the core of the paper and describes the new 2-merge sort and α-merge sort. We first a simple O(n log m) upper bound on their merge cost. After that, we prove the lower bounds on their merge costs, and finally prove the corresponding sharp upper bounds. Section 6 gives some experimental results on two kinds of randomly generated data. It includes experimental comparisons also with the recent adaptive Shivers sort of Jug´e and powersort of Munro and Wild. All these sections can be read independently of each other. The paper concludes with discussion of open problems. We thank the referees of [4] for useful comments and suggestions, and Vincent Jug´e for sharing information on his unpublished work. 2 Timsort lower bound Algorithm 2 is the Timsort algorithm as defined by [8] improving on [26]. Recall that W, X, Y, Z are the top four elements on the stack Q. A command "Merge Y and Z" creates a single run which replaces both Y and Z in the stack; at the same time, the current third member on the stack, X, becomes the new second member on the stack and is now designated Y . Similarly, the current W becomes the new X, etc. Likewise, the command "Merge X and Y " merges the second and third elements at the top of Q; those two elements are removed from Q and replaced by the result of the merge. Timsort was designed so that the stack has size O(log n), and the total running time is O(n log n). These bounds were first proved by [2]; simplified proofs were given by [1] who also strengthed the upper bound to O(n log m). Theorem 2 ([1, 2]). The merge cost of Timsort is O(n log n), and even O(n log m). The proof in Auger et al. [2] did not compute the constant implicit in their proof of the upper bound of Theorem 2; but it is approximately equal to 3/ log ϕ ≈ 4.321. The proofs in [1] also do not quantify the constants in the big-O notation, but they are comparable or slightly larger. We prove a corresponding lower bound. 6 Algorithm 2 The Timsort algorithm. W, X, Y, Z denote the top four elements of the stack Q. A test involving a stack member that does not exist evaluates as "False". For example, X < Z evaluates as false when Q < 3 and X does not exist. 1: procedure TimSort(S, n) 2: R ← run decomposition of S Q ← ∅ while R 6= ∅ do 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: Remove the next run R from R and push it onto Q loop if X < Z then Merge X and Y else if X ≤ Y + Z then Merge Y and Z else if W ≤ X + Y then Merge Y and Z else if Y ≤ Z then Merge Y and Z else Break out of the loop end if end loop end while while Q ≥ 1 do Merge Y and Z end while 22: 23: end procedure 7 Theorem 3. The worst-case merge cost of the Timsort algorithm on inputs of length n which decompose into m original runs is ≥ (1.5 − o(1)) · n log n. Hence it is also ≥ (1.5 − o(1)) · n log m. In other words, for any c < 1.5, there are inputs to Timsort with arbitrarily large values for n (and m) so that Timsort has merge cost > c · n log n. We conjecture that Theorem 2 is nearly optimal: Conjecture 4. The merge cost of Timsort is bounded by (1.5 + o(1)) · n log m. Vincent Jug´e [personal communication, November 2018] has recently succeeded in proving this conjecture. lengths so that Rtim(n) equals hn1, n2 . . . , nmi where each ni > 0 and Pm Proof of Theorem 3. We must define inputs that cause Timsort to take time close to 1.5n log n. As always, n ≥ 1 is the length of the input S to be sorted. We define Rtim(n) to be a sequence of run i=1 ni = n. Furthermore, we will have m ≤ n ≤ 3m, so that log n = log m + O(1). The notation Rtim is reminiscent of R, but R is a sequence of runs whereas Rtim is a sequence of run lengths. Since the merge cost of Timsort depends only on the lengths of the runs, it is more convenient to work directly with the sequence of run lengths. The sequence Rtim(n), for 1 ≤ n, is defined as follows.5 First, for n ≤ 3, Rtim(n) is the sequence hni, i.e., representing a single run of length n. Let n′ = ⌊n/2⌋. For even n ≥ 4, we have n = 2n′ and define Rtim(n) to be the concatenation of Rtim(n′), Rtim(n′ − 1) and h1i. For odd n ≥ 4, we have n = 2n′ + 1 and define Rtim(n) to be the concatenation of Rtim(n′), Rtim(n′ − 1) and h2i. We claim that for n ≥ 4, Timsort operates with run lengths Rtim(n) as follows: The first phase processes the runs from Rtim(n′) and merges them into a single run of length n′ which is the only element of the stack Q. The second phase processes the runs from Rtim(n′ − 1) and merges them also into a single run of length n′ − 1; at this point the stack contains two runs, of lengths n′ and n′ − 1. Since n′ − 1 < n′, no further merge occurs immediately. Instead, the final run is loaded onto the stack: it has length n′′ equal to either 1 or 2. Now n′ ≤ n′ − 1 + n′′ and the test X ≤ Y + Z on line 9 of Algorithm 2 is triggered, so Timsort merges the top two elements of the stack, and then the test Y ≤ Z causes the merge of the final two elements of the stack. This claim follows from Claim 5. We say that the stack Q is stable if none of the tests on lines 7, 9, 11, 13, of Algorithm 2 hold. Claim 5. Suppose that Rtim(n) is the initial subsequence of a sequence R′ of run lengths, and that Timsort is initially started with run lengths R′ either (a) with the stack Q empty or (b) with the top element of Q a run of length n0 > n and the second element of Q (if it exists) a run of length n1 > n0 + n. Then Timsort will start by processing exactly the runs whose lengths are those of Rtim(n), merging them into a single run which becomes the new top element of Q. Timsort will do this without performing any merge of runs that were initially in Q and without (yet) processing any of the remaining runs in R′. Claim 5 is proved by induction on n. The base case, where n ≤ 3, is trivial since with Q stable, Timsort immediately reads in the first run from R′. The case of n ≥ 4 uses the induction hypothesis twice, since Rtim(n) starts off with Rtim(n′) followed by Rtim(n′ − 1). The induction hypothesis applied to n′ implies that the runs of Rtim(n′) are first processed and merged to become 5For purposes of this proof, we allow run lengths to equal 1. Strictly speaking, this cannot occur since all original runs will have length at least 2. This is unimportant for the proof however, as the run lengths Rtim(n) could be doubled and the asymptotic analysis needed for the proof would be essentially unchanged. 8 the top element of Q. The stack elements X, Y, Z have lengths n1, n0, n′ (if they exist), so the stack is now stable. Now the induction hypothesis for n′ − 1 applies, so Timsort next loads and merges the runs of Rtim(n′ − 1). Now the top stack elements W, X, Y, Z have lengths n1, n0, n′, n′ − 1 and Q is again stable. Finally, the single run of length n′′ is loaded onto the stack. This triggers the test X ≤ Y + Z, so the top two elements are merged. Then the test Y ≤ Z is triggered, so the top two elements are again merged. Now the top elements of the stack (those which exist) are runs of length n1, n0, n, and Claim 5 is proved. Let c(n) be the merge cost of the Timsort algorithm on the sequence Rtim(n) of run lengths. The two merges described at the end of the proof of Claim 5 have merge cost (n′ − 1) + n′′ plus n′ + (n′ − 1) + n′′ = n. Therefore, for n > 3, c(n) satisfies c(n) = (c(n′) + c(n′ − 1) + 3 c(n′) + c(n′ − 1) + 3 2 n 2 n + 1 2 if n is even if n is odd. (1) Also, c(1) = c(2) = c(3) = 0 since no merges are needed. Equation (1) can be summarized as c(n) = c(⌊n/2⌋) + c(⌊n/2⌋ − 1) + 3 2 n + 1 2 (n mod 2). The function n 7→ 3 for n ≥ 3. Hence c(⌊n/2⌋) > c(⌊n/2⌋ − 1), and thus c(n) ≥ 2c(⌊n/2⌋ − 1) + 3 2 (n mod 2) is strictly increasing. So, by induction, c(n) is strictly increasing 2 n+ 1 2 n for all n > 3. For x ∈ R, define b(x) = c(⌊x − 3⌋). Since c(n) is nondecreasing, so is b(x). Then b(x) = c(⌊x − 3⌋) ≥ 2c(⌊(x − 3)/2⌋ − 1) + 3 2 (x − 3) ≥ 2c(⌊x/2⌋ − 3) + 3 2 (x − 3) = 2b(x/2) + 3 2 (x − 3). Claim 6. For all x ≥ 3, b(x) ≥ 3 2 · [x(⌊log x⌋ − 2) − x + 3]. We prove the claim by induction, namely by induction on n that it holds for all x < n. The base case is when 3 ≤ x < 8 and is trivial since the lower bound is negative and b(x) ≥ 0. For the induction step, the claim is known to hold for x/2. Then, since log(x/2) = (log x) − 1, b(x) ≥ 2 · b(x/2) + 3 2 (x − 3) ≥ 2 ·(cid:16) 3 2 3 2 = · [x(⌊log x⌋ − 2) − x + 3] ·(cid:2)(x/2)(⌊log x⌋ − 3) − x/2 + 3(cid:3)(cid:17) + 3 2 (x − 3) proving the claim. Claim 6 implies that c(n) = b(n + 3) ≥ ( 3 2 − o(1)) · n log n. This proves Theorem 3. 3 The α-stack sort Augur-Nicaud-Pivoteau [2] introduced the α-stack sort as a 2-aware stable merge sort; it was inspired by Timsort and designed to be simpler to implement and to have a simpler analysis. (The algorithm (e2) of [32] is the same as α-stack sort with α = 2.) Let α > 1 be a constant. The α-stack sort is shown in Algorithm 3. It makes less effort than Timsort to optimize the order of merges: up until the run decomposition is exhausted, its only merge rule is that Y and Z are merged whenever Y ≤ αZ. An O(n log n) upper bound on its runtime is given by the next theorem. 9 Algorithm 3 The α-stack sort. α is a constant > 1. 1: procedure α-stack(S, n) 2: R ← run decomposition of S Q ← ∅ while R 6= ∅ do 3: 4: 5: 6: 7: 8: 9: 10: 11: Remove the next run R from R and push it onto Q while Y ≤ αZ do Merge Y and Z end while end while while Q ≥ 1 do Merge Y and Z end while 12: 13: end procedure Theorem 7 ([2]). Fix α > 1. The merge cost for α-stack sort is O(n log n). [2] did not explicitly mention the constant implicit in this upper bound, but their proof estab- lishes a constant equal to approximately (1 + α)/ log α. For instance, for α = 2, the merge cost is bounded by (3 + o(1))n log n. The constant is minimized at α ≈ 3.591, where is it approximately 2.489. Theorem 8. Let 1 < α. The worst-case merge cost of α-stack sort on inputs of length n is ≥ (cα − o(1)) · n log n, where cα equals (α+1) log(α+1)−α log(α) . α+1 The proof of Theorem 8 is postponed until Theorem 16 proves a stronger lower bound for α- merge sorts; the same construction works to prove both theorems. The value cα is quite small, e.g., c2 ≈ 1.089; this is is discussed more in Section 5. The lower bound of Theorem 8 is not very strong since the constant is close to 1. In fact, since a binary tree of merges gives a merge cost of n⌈log m⌉, it is more relevant to give upper bounds in terms of O(n log m) instead of O(n log n). The next theorem shows that α-stack sort can be very far from optimal in this respect. Theorem 9. Let 1 < α. The worst-case merge cost of α-stack sort on inputs of length n which decompose into m original runs is ω(n log m). In other words, for any c > 0, there are inputs with arbitrarily large values for n and m so that α-stack sort has merge cost > c · n log m. Proof. Let s be the least integer such that 2s ≥ α. Let Rαst(m) be the sequence of run lengths h 2(m−1)·s − 1, 2(m−2)·s − 1, . . . , 23s − 1, 22s − 1, 2s − 1, 2m·si. Rαst(m) describes m runs whose lengths sum to n = 2m·s +Pm−1 The total cost of the merges is (m − 1) · 2ms +Pm−1 i=1 (2i·s − 1), so 2m·s < n < 2m·s+1. Since 2s ≥ α, the test Y ≤ αZ on line 6 of Algorithm 3 is triggered only when the run of length 2ms is loaded onto the stack Q; once this happens the runs are all merged in order from right-to-left. i=1 i · (2i·s − 1) which is certainly greater than (m − 1) · 2ms. Indeed, that comes from the fact that the final run in Rαst(m) is involved in m − 1 merges. Since n < 2 · 2m·s, the total merge cost is greater than n 2 (m − 1), which is ω(n log m). 10 4 The Shivers merge sort The 2-aware Shivers sort [29], shown in Algorithm 4, is similar to 2-stack sort, but with a mod- ification that makes a surprising improvement in the bounds on its merge cost. Although never published, this algorithm was presented in 1999. Algorithm 4 The Shivers sort. 1: procedure ssort(S, n) 2: R ← run decomposition of S Q ← ∅ while R 6= ∅ do 3: 4: 5: 6: 7: 8: 9: 10: 11: Remove the next run R from R and push it onto Q while 2⌊log Y ⌋ ≤ Z do Merge Y and Z end while end while while Q ≥ 1 do Merge Y and Z end while 12: 13: end procedure The only difference between the Shivers sort and 2-stack sort is the test used to decide when to merge. Namely, line 6 tests 2⌊log Y ⌋ ≤ Z instead of Y ≤ 2 · Z. Since 2⌊log Y ⌋ is Y rounded down to the nearest power of two, this is somewhat like an α-sort with α varying dynamically in the range [1, 2). The Shivers sort has the same undesirable lower bound as 2-stack sort in terms of ω(n log m): Theorem 10. The worst-case merge cost of the Shivers sort on inputs of length n which decompose into m original runs is ω(n log m). Proof. This is identical to the proof of Theorem 9. We now let Rsh(m) be the sequence of run lengths h 2m−1 − 1, 2m−2 − 1, . . . , 7, 3, 1, 2mi, and argue as before. Theorem 11 ([29]). The merge cost of Shivers sort is (1 + o(1))n log n. We present a proof which is simpler than that of [29]. The proof of Theorem 11 assumes that at a given point in time, the stack Q has ℓ elements Q1, . . . , Qℓ, and uses wQi to denote the merge cost of Qi. We continue to use the convention that W, X, Y, Z denote Qℓ−3, Qℓ−2, Qℓ−1, Qℓ if they exist. Proof. Define kQi to equal ⌊log Qi⌋. Obviously, Qi ≥ 2kQi . The test on line 6 works to maintain the invariant that each Qi+1 < 2kQi or equivalently ki+1 < ki. Thus, for i < ℓ − 1, we always have Qi+1 < 2kQi and ki+1 < ki. This condition can be momentarily violated for i = ℓ − 1, i.e. if Z ≥ 2kY and kY ≤ kZ , but then the Shivers sort immediately merges Y and Z. As a side remark, since each ki+1 < ki for i ≤ ℓ − 1, since 2k1 ≤ Q1 ≤ n, and since Qℓ−1 ≥ 1 = 20, the stack height ℓ is ≤ 2 + log n. (In fact, a better analysis shows it is ≤ 1 + log n.) Claim 12. Throughout the execution of the main loop (lines 4-9), the Shivers sort satisfies 11 a. wQi ≤ kQi · Qi, for all i ≤ ℓ, b. wZ ≤ kY · Z i.e., wQℓ ≤ kQℓ−1 · Qℓ, if ℓ > 1. When i = ℓ, a. says wZ ≤ kZZ. Since kZ can be less than or greater than kY , this neither implies, nor is implied by, b. The lemma is proved by induction on the number of updates to the stack Q during the loop. Initially Q is empty, and a. and b. hold trivially. There are two induction cases to consider. The first case is when an original run is pushed onto Q. Since this run, namely Z, has never been merged, its weight is wZ = 0. So b. certainly holds. For the same reason and using the induction hypothesis, a. holds. The second case is when 2kY ≤ Z, so kY ≤ kZ , and Y and Z are merged; here ℓ will decrease by 1. The merge cost wYZ of the combination of Y and Z equals Y +Z+wY +wZ , so we must establish two things: a′. Y + Z + wY + wZ ≤ kYZ · (Y + Z), where kYZ = ⌊log(Y + Z)⌋. b′. Y + Z + wY + wZ ≤ kX · (Y + Z), if ℓ > 2. By induction hypotheses wY ≤ kY Y and wZ ≤ kY Z. Thus the lefthand sides of a′. and b′. are ≤ (kY + 1) · (Y + Z). As already discussed, kY < kX , therefore condition b. implies that b′. holds. And since 2kY ≤ Z, kY < kYZ , so condition a. implies that a′. also holds. This completes the proof of Claim 12. Claim 12 implies that the total merge cost incurred at the end of the main loop incurred is ≤Pi wQi ≤Pi kiQi. Since Pi Qi = n and each ki ≤ log n, the total merge cost is ≤ n log n. We now upper bound the total merge cost incurred during the final loop on lines 10-12. When first reaching line 10, we have ki+1 < ki for all i ≤ ℓ − 1 hence ki < k1 + 1 − i and Qi < 2k1+2−i for all i ≤ ℓ. The final loop then performs ℓ− 1 merges from right to left. Each Qi for i < ℓ participates in i merge operations and Qℓ participates in ℓ − 1 merges. The total merge cost of this is less than i=1 i · Qi. Note that Pℓ i · Qi < 2k1+2 · ℓ Xi=1 ℓ Xi=1 i · 2−i < 2k1+2 · 2 = 8 · 2k1 ≤ 8n, where the last inequality follows by 2k1 ≤ Q1 ≤ n. Thus, the final loop incurs a merge cost O(n), which is o(n log n). Therefore the total merge cost for the Shivers sort is bounded by n log n + o(n log n). 5 The 2-merge and α-merge sorts This section introduces our new merge sorting algorithms, called the "2-merge sort" and the "α- merge sort", where ϕ < α < 2 is a fixed parameter. These sorts are 3-aware, and this enables us to get algorithms with merge costs (cα ± o(1))n log m. The idea of the α-merge sort is to combine the construction of 2-stack sort, with the idea from Timsort of merging X and Y instead of Y and Z whenever X < Z. But unlike the Timsort algorithm shown in Algorithm 2, we are able to use a 3-aware algorithm instead of a 4-aware algorithm. In addition, our merging rules are simpler, and our provable upper bounds are tighter. Indeed, our upper bounds for ϕ < α ≤ 2 are of the form (cα + o(1)) · n log m with cα ≤ c2 ≈ 1.089, but Theorem 3 proves a lower bound 1.5 · n log m for Timsort. Algorithms 5 and 6 show the 2-merge sort and α-merge sort algorithms. Note that 2-merge sort is almost, but not quite, the specialization of α-merge sort to the case α = 2. The difference 12 is that line 6 of 2-merge sort has a simpler while test than the corresponding line in the α-merge sort algorithm. As will be shown by the proof of Theorem 24, the fact that Algorithm 5 uses this simpler while test makes no difference to which merge operations are performed; in other words, it would be redundant to test the condition X < 2Y . The 2-merge sort can also be compared to the α-stack sort shown in Algorithm 3. The main difference is that the merge of Y and Z on line 7 of the α-stack sort algorithm has been replaced by the lines lines 7-11 of the 2-merge sort algorithm which conditionally merge Y with either X or Z. For 2-merge sort (and α-merge sort), the run Y is never merged with Z if it could instead be merged with a shorter X. The other, perhaps less crucial, difference is that the weak inequality test on line 6 in the α-stack sort algorithm has been replaced with a strict inequality test on line 6 in the α-merge sort algorithm. We have made this change since it seems to make 2-merge sort more efficient, for instance when all original runs have the same length. Algorithm 5 The 2-merge sort. 1: procedure 2-merge(S, n) 2: R ← run decomposition of S Q ← ∅ while R 6= ∅ do 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: Remove the next run R from R and push it onto Q while Y < 2Z do if X < Z then Merge X and Y else Merge Y and Z end if end while end while while Q ≥ 1 do Merge Y and Z end while 16: 17: end procedure We will concentrate mainly on the cases for ϕ < α ≤ 2 where ϕ ≈ 1.618 is the golden ratio. Values for α > 2 do not seem to give useful merge sorts; our upper bound proof does not work for α ≤ ϕ. Definition 13. Let α ≥ 1, the constant cα is defined by cα = α + 1 (α + 1) log(α + 1) − α log(α) . (2) For α = 2, c2 = 3/ log(27/4) ≈ 1.08897. For α = ϕ, cϕ ≈ 1.042298. For α > 1, cα is strictly increasing as a function of α. Thus, 1.042 < cα < 1.089 when ϕ < α ≤ 2. Sections 5.2-5.5 give nearly matching upper and lower bounds for the worst-case running time of 2-merge sort and α-merge sort for ϕ < α < 2. As discussed earlier (see also Table 2) the upper and lower bounds are asymptotically equal to c2 · n log m. The tight upper bound proofs for Theorems 23 and 24 involve a lot of technical details, so as a warmup, Section 5.1 gives a weaker upper bound with a much simpler proof. 13 Algorithm 6 The α-merge sort. α is a constant such that ϕ < α < 2. 1: procedure α-merge(S, n) 2: R ← run decomposition of S Q ← ∅ while R 6= ∅ do 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: Remove the next run R from R and push it onto Q while Y < αZ or X < αY do if X < Z then Merge X and Y else Merge Y and Z end if end while end while while Q ≥ 1 do Merge Y and Z 15: 16: 17: end procedure end while 5.1 Simple upper bounds for 2-merge sort and α-merge sort This section proves O(n log n) upper bounds on the merge costs for the 2-merge and α-merge sorts. The proofs are in spirit of techniques used by [1, 16]. First, Theorem 14 establishes an upper bound on the size of the stack. Theorem 14. Let ϕ < α < 2. For α-merge sort on inputs of length n, the size Q of the stack is always < 1 + ⌊logα n⌋ = 1 + ⌊(log n)/(log α)⌋. For 2-merge sort, the size of the stack is always ≤ 1 + ⌊log n⌋. Proof. The main loop of the 2-merge and α-merge sorts first pushes a new run onto the stack and then does zero or more merges. Since merges reduce the stack height, the maximum stack height is obtained when a run is pushed onto the stack. Such a newly pushed run is denoted either Z or Qℓ, where the stack height is ℓ. We claim that for both 2-merge sort and α-merge sort, when a new run is pushed onto the stack, Qi−1 ≥ αQi holds for all i < ℓ (taking α = 2 in the inequality for 2-merge sort). For α-merge sort, this claim follows from the following three observations: (a) Each merge acts on two of the top three elements of the stack, i.e., either X and Y are merged or Y and Z are merged. Each merge decreases the height of the stack by 1; this decreases the value of ℓ by 1. (b) The condition that Qi−1 ≥ αQi holds for all i < ℓ − 1 is maintained after merging two of the top three stack members. This fact is essentially trivial: If Y and Z are merged they become the new top element of the stack; and if X and Y are merged they become the second element of the stack. But the top two elements are Qℓ−1 and Qℓ, and thus do not affect the conditions Qi−1 ≥ αQi for i < ℓ − 1. (c) Merging continues until both X ≥ αY and Y ≥ αZ hold. Proving the claim for 2-merge sort requires an extra argument since line 6 of Algorithm 5 lacks a 14 test for X < 2Y . Instead, we argue that as 2-merge sort performs merges, we have Qi−1 ≥ 2Qi for all i < ℓ − 1 and either (i) Qℓ−2 ≥ 2Qℓ−1, or (ii) Qℓ−2 > Qℓ−1 and Qℓ−1 < 2Qℓ. The condition Qi−1 ≥ 2Qi for i < ℓ − 1 is an invariant just because each step either merges X and Y or merges Y and Z (just as argued in (b) above). For conditions (i) and (ii), consider separately whether X and Y are merged, or Y and Z are merged. In either case, ℓ is decreased by one by the merge. When Y and Z are merged, we trivially have that condition (i) holds after the merge (as argued in (b) above). When X < Z, and X and Y are merged, we have Qℓ−3 ≥ 2Qℓ−2 > Qℓ−2 + Qℓ−1, so the first part of condition (ii) still holds after the merge. In addition, Z > X means the same as Qℓ > Qℓ−2, so 2Qℓ > Qℓ−2 + Qℓ−1 so the second part of condition (ii) also holds after the merge. The merging stops when Qℓ−1 ≥ 2Qℓ. Merging cannot stop while condition (ii) holds, so it must stop while condition (i) holds. The claim for 2-merge sort follows immediately. For both 2-merge sort and α-merge sort, the claim implies that when a new run Qℓ is pushed onto the stack, the other ℓ − 1 runs Q1, . . . , Qℓ−1 have run lengths totaling ℓ−1 ℓ−2 Qi ≥ Qℓ−1 · αi = αℓ−1 − 1 α − 1 · Qℓ−1 Xi=0 Xi=1 Therefore, the total run length of all ℓ runs on the stack at least αℓ−1−1 α−1 + 1. This must be ≤ n. Therefore, since α ≤ 2, we have αℓ−1 ≤ n. Thus ℓ ≤ 1 + ⌊logα n⌋. The inequalities are strict if α < 2 since then α − 1 < 1. Theorem 15. Let 1 < α ≤ 2. The merge cost of α-merge sort on inputs of length n is O(n log n). Proof. We introduce a special real-valued counter C which initially is equal to 0. Every time we load a run Qℓ to the stack Q, we add (2 + α) · ℓ · Qℓ to C. Every time we merge two runs Qi and Qi+1, we subtract Qi + Qi+1 from C. We claim that the following invariant holds throughout the execution of α-merge sort: ℓ C ≥ (2 + α)iQi. Xi=1 (3) We also claim this holds with α = 2 for 2-merge sort. This claim will suffice to prove Theo- rem 15. First, by Theorem 14, the total of the increases in C caused by adding new runs is ≤ (2 + α)(1 + logα(n)). Second, the total decreases in C equal the total merge cost. By (3), C is always non-negative, whence Theorem 15 follows. The invariant (3) holds initially, and it clearly is maintained by loading a new run to the top of the stack. Let us consider what happens when we make a merge. We need to consider several cases below. Only the first case is needed for 2-merge sort as 2-merge sort does not check the condition X < 2Y to decide whether to perform a merge. Cases 2. and 3. below apply only to α-merge sort. 1. If Y < αZ then we merge Y with the smaller of Z and X, and subtract at most Y + Z from C. The merge reduces the stack height by 1, so considering just the elements of Z, the righthand side of the inequality (3) decreases by at least (2 + α)Z. This decrease is ≥ (2 + α)Z ≥ Y + Z by the assumption that Y < αZ. Thus the condition (3) is preserved in this case. 15 2. If a merge is triggerd by X < αY , there are several cases to consider. Consider first the case where X < Z so we merge X and Y . In this case, the merge cost is X + Y , so C decreases by X + Y . On the other hand, the righthand side of the inequality (3) decreases by (2 + α)(Y + Z) since the elements of the runs Y and Z both have the stack height below them decrease by 1. Since Z < X, the condition (3) is maintained. 3. Now suppose a merge is triggered by X < αY and X ≥ Z. In this case we merge Y and Z to form a run, denoted Y Z, of length Y + Z, and C decreases by Y + Z. Now this step might not preserve the condition (3). However, after merging Y and Z, there must immediately be another merge due to the fact that X ≤ α(Y + Z). This next merge will either (a) merge W with X if W < Y + Z or (b) merge X with Y Z if W ≥ Y + Z. Consider the case (b) where X is merged with Y Z. In this case, C has decreased by a total of X + 2Y + 2Z during the two merges. At the same time, the stack heights below the members of Y and Z decreased by 1 and 2, respectively. Therefore, the righthand side of (3) decreased by (2 + α)(Y + 2Z). Since X ≤ αY , this is clearly greater than the decrease X + 2Y + 2Z in C. Thus the inequality (3) is maintained in this case. Now consider the case (a) where W and X are merged. In this case, C decreases by W + X + Y + Z from the two merges. Since W < Y + Z, this means that C decreases by less than X + 2Y + 2Z. On the other hand, the reductions in stack height means that the righthand side of (3) decreases by (2 + α)(X + Y + 2Z). This again implies that the inequality (3) is maintained. 5.2 Lower bound for 2-merge sort and α-merge sort Theorem 16. Fix α > 1. The worst-case merge cost of α-merge sort is ≥ (cα − o(1))n log n. The corresponding theorem for α = 2 is: Theorem 17. The worst-case merge cost of 2-merge sort is ≥ (c2 − o(1))n log n, where c2 = 3/ log(27/4) ≈ 1.08897. The proof of Theorem 16 also establishes Theorem 8, as the same lower bound construction works for both α-stack sort and α-merge sort. The only difference is that part d. of Claim 19 is used instead of part c. In addition, the proof of Theorem 16 also establishes Theorem 17; indeed, exactly the same proof applies verbatim, just uniformly replacing "α" with "2". Proof of Theorem 16. Fix α > 1. For n ≥ 1, we define a sequence Rαm(n) of run lengths that will establish the lower bound. Define N0 to equal 3 · ⌈α + 1⌉. For n < N0, set Rαm to be the sequence hni, containing a single run of length n. For n ≥ N0, define n′′′ = ⌊ n α+1 ⌋ + 1 and n∗ = n − n′′′. Thus n′′′ is the least integer greater than n/(α + 1). Similarly define n′′ = ⌊ n∗ α+1 ⌋ + 1 and n′ = n∗ − n′′. These four values can be equivalently uniquely characterized as satisfying n′′′ = 1 α+1 n + ǫ1 n′′ = α (α+1)2 n − 1 α+1 ǫ1 + ǫ2 and and n∗ = α α+1 n − ǫ1 n′ = α2 (α+1)2 n − α α+1 ǫ1 − ǫ2 (4) (5) for some ǫ1, ǫ2 ∈ (0, 1]. The sequence Rαm(n) of run lengths is inductively defined to be the concatenation of Rαm(n′), Rαm(n′′) and Rαm(n′′′). 16 Claim 18. Let n ≥ N0. a. n = n′ + n′′ + n′′′ and n∗ = n′ + n′′. b. α(n′′′ − 3) ≤ n∗ < αn′′′. c. α(n′′ − 3) ≤ n′ < αn′′. d. n′′′ ≥ 3. e. n′ ≥ 1 and n′′ ≥ 1. Part a. of the claim is immediate from the definitions. Part b. is immediate from the equali- ties (4) since 0 < ǫ1 ≤ 1 and α > 1. Part c. is similarly immediate from (5) since also 0 < ǫ2 ≤ 1. Part d. follows from (4) and n ≥ N0 ≥ 3(α + 1). Part e. follows by (5), α > 1, and n ≥ N0. Claim 19. Let Rαm(n) be as defined above. a. The sums of the run lengths in Rαm(n) is n. b. If n ≥ N0, then the final run length in Rαm(n) is ≥ 3. c. Suppose that Rαm(n) is the initial subsequence of a sequence R′ of run lengths and that α- merge sort is initially started with run lengths R′ and (a) with the stack Q empty or (b) with the top element of Q a run of length ≥ α(n − 3). Then α-merge sort will start by processing exactly the runs whose lengths are those of Rαm(n), merging them into single run which becomes the new top element of Q. This will be done without merging any runs that were initially in Q and without (yet) processing any of the remaining runs in R′. d. The property c. also holds for α-stack sort. Part a. is immediate from the definitions using induction on n. Part b. is a consequence of Claim 18(d.) and the fact that the final entry of Rαm is a value n′′′ < N0 for some n. Part c. is proved by induction on n, similarly to the proof of Claim 5. It is trivial for the base case n < N0. For n ≥ N0, Rαm(n) is the concatenation of Rαm(n′), Rαm(n′′), Rαm(n′′′). Applying the induction hypothesis to Rαm(n′) yields that these runs are initially merged into a single new run of length n′ at the top of the stack. Then applying the induction hypothesis to Rαm(n′′) shows that those runs are merged to become the top run on the stack. Since the last member of Rαm(n′′) is a run of length ≥ 3, every intermediate member placed on the stack while merging the runs of Rαm(n′′) has length ≤ n′′ − 3. And, by Claim 18(c.), these cannot cause a merge with the run of length n′ already in Q. Next, again by Claim 18(c.), the top two members of the stack are merged to form a run of length n∗ = n′ + n′′. Applying the induction hypothesis a third time, and arguing similarly with Claim 18(b.), gives that the runs of Rαm(n′′′) are merged into a single run of length n′′′, and then merged with the run of length n∗ to obtain a run of length n. This proves part c. of Claim 19. Part d. is proved exactly like part c.; the fact that α-stack sort is only 2-aware and never merges X and Y makes the argument slightly easier in fact. This completes the proof of Claim 19. Claim 20. Let c(x) equal the merge cost of α-merge sort on an input sequence with run lengths given by Rαm(n). Then c(n) = 0 for n < N0. For n ≥ N0, c(n) = c(n′) + c(n′′) + c(n′′′) + 2n′ + 2n′′ + n′′′ = c(n′) + c(n′′) + c(n′′′) + n + n′ + n′′. (6) (7) For n ≥ N0, c(n) is strictly increasing as a function of n. 17 The first equality of Equation (6) is an immediate consequence of the proof of part c. of Claim 19; the second follows from n = n′ + n′′ + n′′′. To see that c(n) is increasing for n ≥ N0, let (n + 1)′, (n + 1)′′, (n + 1)′′′ indicate the three values such that Rαm(n + 1) is the concatenation of Rαm((n + 1)′), Rαm((n + 1)′′) and Rαm((n + 1)′′′). Note that (n + 1)′ ≥ n′, (n + 1)′′ ≥ n′′, and (n + 1)′′′ ≥ n′′′. An easy proof by induction now shows that c(n + 1) > c(n) for n ≥ N0, and Claim 20 is proved. Let δ = ⌈2(α + 1)2/(2α + 1)⌉. (For 1 < α ≤ 2, we have δ ≤ 4.) We have δ ≤ N0 − 1 for all α > 1. For real x ≥ N0, define b(x) = c(⌊x⌋ − δ). Since c(n) is increasing, b(x) is nondecreasing. Claim 21. a. 1 α+1 n − δ ≤ (n − δ)′′′. b. c. α (α+1)2 n − δ ≤ (n − δ)′′. (α+1)2 n − δ ≤ (n − δ)′. α2 d. If x ≥ N0 + δ, then b(x) ≥ b( α2 (α+1)2 x) + b( α (α+1)2 x) + b( 1 α+1 x) + 2α+1 α+1 (x − δ − 1) − 1. For a., (4) implies that (n − δ)′′′ ≥ n−δ α+1 , so a. follows from −δ ≤ −δ/(α + 1). This holds as δ > 0 and α > 1. For b., (5) implies that (n − δ)′′ ≥ α α+1 , so after simplification, b. follows from δ ≥ (α+1)/(α2 +α+1); it is easy to verify that this holds by choice of δ. For c., (5) also implies that (n − δ)′ ≥ α2 (α+1)2 (n − δ) − 2, so after simplification, c. follows from δ ≥ 2(α + 1)2/(2α + 1). (α+1)2 (n − δ) − 1 To prove part d., letting n = ⌊x⌋ and using parts a., b. and c., equations (4) and (5), and the fact that b(x) and c(n) are nondecreasing, we have b(x) = c(n − δ) = c((n − δ)′) + c((n − δ)′′) + c((n − δ)′′′) + (n − δ) + (n − δ)′ + (n − δ)′′ ≥ c(⌊ α2 (α+1)2 n⌋ − δ) + c(⌊ α+1 n⌋ − δ) + (α+1)2 + α +(cid:0)1 + α2 − α α+1 ǫ1 − ǫ2 − 1 α (α+1)2 n⌋ − δ) + c(⌊ 1 (α+1)2(cid:1) · (n − δ) α+1 ǫ1 + ǫ2 ≥ b( α2 (α+1)2 x) + b( α (α+1)2 x) + b( 1 α+1 x) + 2α+1 α+1 (x − δ − 1) − 1. Claim 21(d.) gives us the basic recurrence needed to lower bound b(x) and hence c(n). Claim 22. For all x ≥ δ + 1, b(x) ≥ cα · x log x − Bx + A, (8) where A = 2α+1 2α+2 (δ + 1) + 1 2 and B = A δ+1 + cα log(max{N0 + δ + 1,l (δ+1)(α+1)2 α m}). The claim is proved by induction, namely we prove by induction on n that (8) holds for all x < n. The base case is for x < n = max{N0 + δ + 1,l (δ+1)(α+1)2 the righthand side of (8) is ≤ 0 by choice of B. Thus (8) holds trivially. m}. In this case b(x) is non-negative, and α For the induction step, we may assume n − 1 ≤ x < n and have δ + 1 ≤ α (α+1)2 x < α2 (α+1)2 x < 1 α+1 x < n − 1. The first of these inequalities follows from x ≥ (δ+1)(α+1)2 ; the remaining inequalities follow from 1 < α < 2 and x < n and n ≥ N0 ≥ 6. Therefore, the induction hypothesis implies that the α 18 bound (8) holds for b( α2 (α+1)2 x), b( α (α+1)2 x), and b( 1 α+1 x). So by Claim 21(d.), b(x) ≥ cα (α+1)2 − B α2 (α+1)2 x + 2α+1 2α+2 (δ + 1) + 1 2 αx (α+1)2 − B α (α+1)2 x + 2α+1 2α+2 (δ + 1) + 1 2 α+1 − B 1 α+1 x + 2α+1 2α+2 (δ + 1) + 1 2 α+1 (δ + 1) − 1 α α2 (α+1)2 x log α2x +cα (α+1)2 x log α+1 x log x 1 α+1 x − 2α+1 = cαx log x − Bx + A (α+1)2 log +cα + 2α+1 +cαxh α2 The quantity in square brackets is equal to α2 (α+1)2 + α (α+1)2 log α (α+1)2 + 1 α+1 log 1 α+1i + 2α+1 α+1 x. (α+1)2 + 2α (α+1)2 + 1 α+1(cid:17) log(α + 1) log(α + 1) (cid:16) 2α2 (α+1)2 + α = α(2α+1) (α+1)2(cid:17) log α −(cid:16) 2α2 (α+1)2 log α − 2α2+3α+1 (α+1)2 log α − 2α+1 = α log α−(α+1) log(α+1) = α(2α+1) (α+1)2 · 2α+1 α+1 . α+1 α+1 log(α + 1) Since cα = (α + 1)/((α + 1) log(α + 1) − α log α), we get that b(x) ≥ cαx log x − Bx + A. This completes the induction step and proves Claim 22. Since A and B are constants, this gives b(x) ≥ (cα − o(1))x log x. Therefore c(n) = b(n + δ) ≥ (cα − o(1))n log n. This completes the proofs of Theorems 8, 16 and 17. 5.3 Upper bound for 2-merge sort and α-merge sort -- preliminaries We next prove upper bounds on the worst-case runtime of 2-merge sort and α-merge sort for ϕ < α < 2. The upper bounds will have the form n · (dα + cα log n), with no hidden or missing constants. cα was already defined in (2). For α = 2, cα ≈ 1.08897 and the constant dα is d2 = 6 − c2 · (3 log 6 − 2 log 4) = 6 − c2 · ((3 log 3) − 1) ≈ 1.91104. (9) For ϕ < α < 2, first define k0(α) = min{ℓ ∈ N : α2−α−1 α−1 ≥ 1 αℓ }. Note k0(α) ≥ 1. Then set, for ϕ < α < 2, dα = 2k0(α)+1 · max{(k0(α) + 1), 3} · (2α − 1) α − 1 + 1. (10) (11) Our proof for α = 2 is substantially simpler than the proof for general α: it also gives the better constant d2. The limits limα→ϕ+ k(α) and limα→ϕ+ dα are both equal to ∞; we suspect this is not optimal.6 However, by Theorems 16 and 17, the constant cα is optimal. Theorem 23. Let ϕ < α < 2. The merge cost of α-merge sort on inputs of length n composed of m runs is ≤ n · (dα + cα log m). 6Already the term 2k0(α)+1 is not optimal as the proof of Theorem 23 shows that the base 2 could be replaced by √α + 1; we conjecture however, that in fact it is not necessary for the limit of dα to be infinite. 19 The corresponding upper bound for α = 2 is: Theorem 24. The merge cost of 2-merge sort on inputs of length n composed of m runs is ≤ n · (d2 + c2 log m) ≈ n · (1.91104 + 1.08897 log m). Proving Theorems 23 and 24 requires handling three situations: First, the algorithm may have top stack element Z which is not too much larger than Y (so Z ≤ αY ): in this case either Y and Z are merged or Z is small compared to Y and no merge occurs. This first case will be handled by case (A) of the proofs. Second, the top stack element Z may be much larger than Y (so Z > αY ): in this case, the algorithm will repeatedly merge X and Y until Z ≤ X. This is the most complicated case of the argument, and is handled by cases (C) and (D) of the proofs. (Case (D) is not needed when α = 2.) In the third case, the original runs in R have been exhausted and the final loop on lines 14-16 repeatedly merges Y and Z. The third case is handled by case (B) of the proofs. The next four technical lemmas are key for the proofs. Lemma 25 is used for case (A) of the proofs; the constant cα is exactly what is needed to make this hold. Lemma 26 is used for case (B) of the proofs. Lemma 27 is used for case (C), and Lemma 28 is used in case (D) when α < 2. Lemma 25. Let α > 1. Let A, B, a, b be positive integers such that A ≤ αB and B ≤ αA. Then A · cα log a + B · cα log b + A + B ≤ (A + B) · cα log(a + b). (12) Lemma 26. Let α > 1. Let A, B, a, b be positive integers such that (α − 1)B ≤ A. Then A · cα log a + B · (1 + cα log b) + A + B ≤ (A + B) · (1 + cα log(a + b)). (13) Lemma 27. Let ϕ < α ≤ 2 and A, B, a, b be positive integers. (a) (For α = 2.) If a ≥ 2 and A ≤ 2B, then A · (d2 + c2 log(a − 1)) + A + B ≤ (A + B) · (d2 − 1 + c2 log(a + b)). (b) If ϕ < α < 2 and A ≤ α α−1 · B, then A · (dα + cα log a) + A + B ≤ (A + B) · (dα − 1 + cα log(a + b)). Lemma 28. Let ϕ < α < 2. Let A, B, C, a, b, and k be positive integers such that k ≤ k0(α) + 1 and 2k(2α−1) α−1 C ≥ A + B + C. Then A · (dα + cα log a) + B · (dα + cα log b)) + k · C + 2B + A ≤ A · (dα − 1 + cα log a) + (B + C) · (dα − 1 + cα log(b + 1)). (14) Proof of Lemma 25. The inequality (12) is equivalent to A · (cα log a − cα log(a + b) + 1) ≤ B · (cα log(a + b) − cα log b − 1) and hence to a Setting t = b/(a + b), this is the same as A ·(cid:16)1 + cα log a + b(cid:17) ≤ B ·(cid:16)−1 − cα log b a + b(cid:17). A · (1 + cα log(1 − t)) ≤ B · (−1 − cα log t). (15) 20 Let t0 = 1 − 2−1/cα. Since cα > 1, we have t0 < 1/2, so t0 < 1 − t0. The lefthand side of (15) is positive iff t < t0. Likewise, the righthand side is positive iff t < 1 − t0. Thus (15) certainly holds when t0 ≤ t ≤ 1 − t0 where the lefthand side is ≤ 0 and the righthand side is ≥ 0. Suppose 0 < t < t0, so 1 + cα log(1 − t) and −1 − cα log t are both positive. Since A ≤ αB, to prove (15) it will suffice to prove α(1 + cα log(1 − t)) ≤ −1 − cα log t, or equivalently that −1−α ≥ cα log(t(1−t)α). The derivative of log(t(1−t)α) is (1−(1+α)t)/(t(1−t)); so log(t(1−t)α) is maximized at t = 1/(1 + α) with value α log α − (α + 1) log(α + 1). Thus the desired inequality holds by the definition of cα, so (15) holds in this case. Now suppose 1−t0 < t < 1, so 1+cα log(1−t) and −1−cα log t are both negative. Since B ≤ αA, it suffices to prove 1+ cα log(1− t) ≤ α(−1− cα log t) or equivalently that −1− α ≥ cα log(tα(1− t)). This is identical to the situation of the previous paragraph, but with t replaced by 1 − t, so (15) holds in this case also. Proof of Lemma 26. The inequality (13) is equivalent to B · (1 + cα log b − cα log(a + b)) ≤ A · (cα log(a + b) − cα log a). Since log(a + b) − log a > 0 and (α − 1)B ≤ A, it suffices to prove 1 + cα log b − cα log(a + b) ≤ (α − 1) · (cα log(a + b) − cα log a). This is equivalent to cα log b + (α − 1) · cα log(a) − α · cα log(a + b) ≤ − 1. Letting t = b/(a + b), we must show −1 ≥ cα log(t(1 − t)α−1). Similarly to the previous proof, taking the first derivative shows that the righthand side is maximized with t = 1/α, so it will suffice to show that −1 ≥ cα log((α − 1)α−1/αα), i.e., that cα · (α log α − (α − 1) log(α − 1)) ≥ 1. Numerical examination shows that this is true for α > 1.29. Proof of Lemma 27. We assume w.l.o.g. that b = 1. The inequality of part (a) is equivalent to A · (2 + c2 log(a − 1) − c2 log(a + 1)) ≤ B · (d2 − 2 + c2 log(a + 1)). Since the righthand side is positive and A ≤ 2B, we need to prove 2 · (2 + c2 log(a − 1) − c2 log(a + 1)) ≤ d2 − 2 + c2 log(a + 1). This is easily seen to be the same as 6 − d2 ≤ c2 log((a + 1)3/(a − 1)2). With a > 1 an integer, the quantity (a + 1)3/(a − 1)2 is minimized when a = 5. Thus, we must show that d2 ≥ 6 − c2 log(63/42) = 6 − c2(3 log 6 − 2 log 4). In fact, d2 was defined so that equality holds. Thus (a) holds. Arguing similarly for part (b), we must show 2α α − 1 + 2 − dα ≤ c2 log((a + 1)α/(α−1)/a). This holds trivially, as dα ≥ 12 for α < 2 so the lefthand side is negative and the righthand side is positive. 21 Proof of Lemma 28. The inequality (14) is equivalent to 2A + B · (3 + cα log b − cα log(b + 1)) + k · C ≤ C · (dα − 1 + cα log(b + 1)). Since 2k(2α−1) α−1 C ≥ A + B + C, it is enough to prove This is equivalent to max(k, 3) · 2k(2α − 1) α − 1 C ≤ (dα − 1) · C. dα ≥ 2k · max{k, 3} · (2α − 1) α − 1 + 1. This holds by the definition of dα, since k ≤ k0(α) + 1. The proofs of Theorems 23 and 24 use two functions Gα and Hα to bound the merge cost of runs stored on the stack. Definition 29. For α = 2, define For α < 2, G2(n, m) = n · (d2 − 1 + c2 log m) H2(n, m) = (cid:26) n · (d2 + c2 log(m − 1)) 0 if m ≥ 2 if m = 1. Gα(n, m) = n · (dα − 1 + cα log m) Hα(n, m) = n · (dα + cα log m). Recall that mX is the number of original runs merged to form a run X. For the proof of Theorem 24 in the next section, upper bounding the merge cost of 2-merge sort, the idea is that for most runs X on the stack Q, the merge cost of X will be bounded by G2(X, mX ). However, many of the runs formed by merges in cases (B) and (C) will instead have merge cost bounded by H2(X, mX ). A similar intuition applies to the proof of Theorem 23 for ϕ < α < 2, in Section 5.5. However, the situation is more complicated as that proof will bound the total merge cost instead of individual merge costs wQi. The next lemma is the crucial property of G2 and Gα that is needed for both Theorems 24 and 23. The lemma is used to bound the merge costs incurred when merging two runs which differ in size by at most a factor α. The constant cα is exactly what is needed to make this lemma hold. Lemma 30. Suppose n1, n2, m1, m2 are positive integers, and ϕ < α ≤ 2. Also suppose n1 ≤ αn2 and n2 ≤ αn1. Then, Gα(n1, m1) + Gα(n2, m2) + n1 + n2 ≤ Gα(n1 + n2, m1 + m2). Proof. The inequality expresses that n1 · (dα − 1 + cα log m1) + n2 · (dα − 1 + cα log m2) + n1 + n2 ≤ (n1 + n2) · (dα − 1 + cα log(m1 + m2)). This is an immediate consequence of Lemma 25 with A, B, a, b replaced with n1, n2, m1, m2. 22 5.4 Upper bound proof for 2-merge sort This section gives the proof of Theorem 24. Lemma 31 states some properties of G2 and H2 which follow from Lemmas 26 and 27(a). Lemma 31. Suppose n1, n2, m1, m2 are positive integers. (a) If n2 ≤ n1, then G2(n1, m1) + H2(n2, m2) + n1 + n2 ≤ H2(n1 + n2, m1 + m2). (b) If n1 ≤ 2n2, then H2(n1, m1) + n1 + n2 ≤ G2(n1 + n2, m1 + m2). Proof. If m2 ≥ 2, part (a) states that n1 · (d2 − 1 + c2 log m1) + n2 · (d2 + c2 log(m2 − 1)) + n1 + n2 ≤ (n1 + n2) · (d2 + c2 log(m2 + m2 − 1)). This is an immediate consequence of Lemma 26. If m2 = 1, then part (a) states n1 · (d2 − 1 + c2 log m1) + n1 + n2 ≤ (n1 + n2) · (d2 + c2 log m1). This holds since d2 ≥ 1 and n2 > 0 and m1 ≥ 1. When m1 ≥ 2, part (b) states that n1 · (d2 + c2 log(m1 − 1)) + n1 + n2 ≤ (n1 + n2) · (d2 − 1 + c2 log(m1 + m2)); this is exactly Lemma 27(a). When m1 = 1, (b) states n1 + n2 ≤ (n1 + n2)(d2 − 1 + c2 log(m2 + 1)), and this is trivial since c2 + d2 ≥ 2 and m2 ≥ 1. We next prove Theorem 24. We use the convention that the 2-merge sort algorithm maintains a stack Q containing runs Q1, Q2, . . . , Qℓ. The last four runs are denoted W , X, Y , Z. Each Qi is a run of Qi many elements. Recall that mQi and wQi denote the number of original runs that were merged to form Qi and the merge cost of Qi (respectively). If Qi is an original run, then mQi = 1 and wQi = 0. If mQi = 2, then Qi was formed by a single merge, so wQi = Qi. To avoid handling the special cases for ℓ ≤ 2, we adopt the convention that there is a virtual initial run Q0 with infinite length, so Q0 = ∞. Lemma 32. Suppose Qi is a run in Q and that wQi ≤ G2(Qi, mQi). Then wQi ≤ H2(Qi, mQi). If mQi = 2, then it holds since wQi = If mQi > 2, then it holds since c2 log(mQi/(mQi − 1)) < 1 and hence G2(Qi, mQi) < Proof. If mQi = 1, the lemma holds since wX = 0. Qi. H2(Qi, mQi). Proof of Theorem 24. We describe the 2-merge algorithm by using three invariants (A), (B), (C) for the stack; and analyzing what action is taken in each situation. Initially, the stack contains a single original Q1, so ℓ = 1 and mQ1 = 1 and wQ1 = 0, and case (A) applies. (A): Normal mode. The stack satisfies (A-1) Qi ≥ 2 · Qi+1 for all i < ℓ − 1. This includes X ≥ 2Y if ℓ ≥ 2. (A-2) 2 · Y ≥ Z; i.e. 2Qℓ−1 ≥ Qℓ. (A-3) wQi ≤ G2(Qi, mQi) for all i ≤ ℓ. 23 If ℓ ≥ 2, (A-1) and (A-2) imply X ≥ Z, i.e. Qℓ−2 ≥ Qℓ. The α-merge algorithm does one of the following: • If 2Z ≤ Y and there are no more original runs to load, then it goes to case (B). We claim the four conditions of (B) hold (see below). The condition (B-2) holds by Y ≥ 2Z, and (B-1) and (B-3) hold by (A-1) and (A-3). Condition (B-4) holds by (A-3) and Lemma 32. • If 2Z ≤ Y and there is another original run to load, then the algorithm loads the next run as Qℓ+1. ◦ If Qℓ+1 ≤ 2Qℓ, then we claim that case (A) still holds with ℓ incremented by one. In particular, (A-1) will hold since Y ≥ 2Z is the same as 2Qℓ ≤ Qℓ−1. Condition (A-2) will hold by the assumed bound on Qℓ+1. Condition (A-3) will still hold since Qℓ+1 is an original run so mQℓ+1 = 1 and wQℓ+1 = 0. ◦ Otherwise Qℓ+1 > 2Qℓ, and we claim that case (C) below holds with ℓ incremented by one. (C-1) and (C-4) will hold by (A-1) and (A-3). For (C-2), we need Qℓ−1 ≥ Qℓ; i.e. Y ≥ Z: this follows trivially from Y ≥ 2Z. (C-5) holds by (A-3) and Lemma 32. (C-3) holds since 2Qℓ < Qℓ+1. (C-6) holds since Qℓ+1 is an original run. • If 2Z > Y , then the algorithm merges the two runs Y and Z. We claim the resulting stack satisfies condition (A) with ℓ decremented by one. (A-1) clearly will still hold. For (A-2) to still hold, we need 2X ≥ Y + Z: this follows from 2Y ≤ X and Z ≤ X. (A-3) will clearly still hold for all i < ℓ − 1. For i = ℓ − 1, since merging Y and Z added Y + Z to the merge cost, (A-3) implies that the new top stack element will have merge cost at most By (A-2) and Lemma 30, this is ≤ G2(Y + Z, mY + mZ ), so (A-3) holds. G2(Y , mY ) + G2(Z, mZ ) + Y + Z. (B): Wrapup mode, lines 15-18 of Algorithm 6. There are no more original runs to process. The entire input has been combined into the runs Q1, . . . , Qℓ and they satisfy: (B-1) Qi ≥ 2 · Qi+1 for all i < ℓ − 1. This includes X ≥ 2Y if ℓ ≥ 2. (B-2) Y ≥ Z; i.e., Qℓ−1 ≥ Qℓ. (B-3) wQi ≤ G2(Qi, mQi) for all i ≤ ℓ − 1, (B-4) wZ ≤ H2(Z, mZ ). If ℓ = 1, the run Z = Q1 contains the entire input in sorted order and the algorithm terminates. The total merge cost is ≤ H2(Z, mZ ). This is < n · (d2 + c2 log m) as needed for Theorem 24. Otherwise ℓ > 1, and Y and Z are merged.7 We claim the resulting stack of runs satisfies case (B), now with ℓ decremented by one. It is obvious that (B-1) and (B-3) still hold. (B-4) will still hold since by (B-3) and (B-4) the merge cost of the run formed by merging Y and Z is at most Y + Z + G2(Y , mY ) + H2(Z, mZ ), and this is ≤ H2(Y + Z, mY + mZ) by Lemma 31(a). To show (B-2) still holds, we must show that X ≥ Y + Z. To prove this, note that 1 2 X ≥ Y by (B-1); thus from (B-2), also 1 (C): Encountered long run Z. When case (C) is first entered, the final run Z is long relative to Y . The algorithm will repeatedly merge X and Y until Z ≤ X, at which point it merges Y and Z and returns to case (A). (The merge of Y and Z must eventually occur by the convention that Q0 has infinite length.) The following conditions hold with ℓ ≥ 2: 2 X ≥ Z. Hence X ≥ Y + Z. 7 Note that in this case, if ℓ ≥ 2, Z < X, since (B-1) and (B-2) imply that X ≥ 2Y ≥ 2Z > Z. This is the reason why Algorithm 5 does not check for the condition X < Z in lines 14-16 (unlike what is done on line 7). 24 (C-1) Qi ≥ 2Qi+1 for all i < ℓ − 2. If ℓ ≥ 3, this includes W ≥ 2X. (C-2) X ≥ Y ; i.e., Qℓ−2 ≥ Qℓ−1. (C-3) Y < 2Z; i.e., Qℓ−1 < 2Qℓ. (C-4) wQi ≤ G2(Qi, mQi) for all i ≤ ℓ − 2. (C-5) wY ≤ H2(Y , mY ). (C-6) mZ = 1 and wZ = 0, because Z is an original run and has not undergone a merge. By (C-3), the test on line 6 of Algorithm 5 will now trigger a merge, either of Y and Z or of X and Y , depending on the relative sizes of X and Z. We handle separately the cases Z > X and Z ≤ X. • Suppose Z > X. Then ℓ ≥ 3 and the algorithm merges X and Y . We claim that case (C) still holds, now with ℓ decremented by 1. It is obvious that (C-1), (C-4) and (C-6) still hold. (C-5) will still hold, since by (C-4) and (C-5), the merge cost of the run obtained by merging X and Y is at most X+Y +G2(X, mX )+H2(Y , mY ), and this is ≤ H2(X+Y , mX +mY ) by Lemma 31(a) since X ≥ Y . To see that (C-2) still holds, we argue exactly as in case (B) to show that W ≥ X + Y . To prove this, note that 1 2 W ≥ X by (C-1); thus from (C-2), 1 2 W ≥ Y . Hence W ≥ X + Y . To establish that (C-3) still holds, we must prove that X + Y < 2Z. By the assumption that Z > X, this follows from Y ≤ X, which holds by (C-2). • Otherwise, Z ≤ X and Y and Z are merged. We claim that now case (A) will hold. (A-1) will hold by (C-1). To show (A-2) will hold, we need Y + Z ≤ 2X: this holds by (C-2) and Z ≤ X. (A-3) will hold for i < ℓ − 1 by (C-4). For i = ℓ − 1, the merge cost wYZ of the run obtained by merging Y and Z is ≤ H2(Y , mY ) + Y + Z by (C-5) and (C-6). By (C-3) and Lemma 31(b) this is ≤ G2(Y + Z, mY + mZ). Hence (A-3) will hold with i = ℓ − 1. That completes the proof of Theorem 24. Examination of the above proof shows why the 2-merge Algorithm 5 does not need to test the condition X < 2Y on line 6; in contrast to what the α-merge Algorithm 6 does. In cases (A) and (B), the test will fail by conditions (A-1) and (B-1). In case (C), condition (C-3) gives Y < 2Z, so an additional test would be redundant. 5.5 Upper bound proof for α-merge sort This section gives the proof Theorem 23. The general outline of the proof is similar to that of Theorem 24; however, we must handle a new, and fairly difficult, case (D). It is also necessary to bound the total merge cost Pi wQi of all the runs in the stack Q, instead of bounding each individual merge cost wQi. We first prove a lemma stating properties of Gα and Hα which follow from Lemmas 26, 27(b) and 28. Parts (a) and (b) of the lemma generalize Lemma 31. Lemma 33. Suppose n1, n2, m1, m2 are positive integers, and ϕ < α < 2. (a) If (α − 1)n2 ≤ n1, then Gα(n1, m1) + Hα(n2, m2) + n1 + n2 ≤ Hα(n1 + n2, m1 + m2). (b) If n1 ≤ α α−1 · n2, then Hα(n1, m1) + n1 + n2 ≤ Gα(n1 + n2, m1 + m2). 25 (c) If n1 ≤ α α−1 n2, then Hα(n1, m1) ≤ Gα(n1, m1) + Gα(n2, 1). (d) If k ≤ k0(α) + 1 and 2k(2α−1) α−1 n3 ≥ n1 + n2 + n3, then Hα(n1, m1) + Hα(n2, m2) + k · n3 + n1 + 2n2 ≤ Gα(n1 + n2 + n3, m1 + m2 + 1). Proof. Part (a) states that n1 · (dα − 1 + cα log m1) + n2 · (dα + cα log m2) + n1 + n2 ≤ (n1 + n2) · (dα + cα log(m2 + m2)). This is an immediate consequence of Lemma 26. Part (b) states that n1 · (dα + cα log m1)) + n1 + n2 ≤ (n1 + n2) · (dα − 1 + cα log(m1 + m2)). This is exactly Lemma 27(b). The inequality of part (c) states n1 · (dα + cα log m1) ≤ n1 · (dα − 1 + cα log m1) + n2 · (dα − 1 + 0). After cancelling common terms, this is the same as n1 ≤ n2 · (dα − 1). To establish this, it suffices to show that dα − 1 ≥ α α−1 + 1. And, since α > 1, we have 12(2α − 1) > α. Therefore dα − 1 > α α−1 . Since k0(α) ≥ 1, we have dα ≥ 12(2α−1) α−1 , and (c) is proved. Part (d) states that n1 · (dα + cα log m1) + n2 · (dα + cα log m2) + k · n3 + n1 + 2n2 ≤ (n1 + n2 + n3) · (dα − 1 + cα log(m1 + m2 + 1)). (16) Lemma 28 implies that n1 · (dα + cα log m1) + n2 · (dα + cα log m2) + k · n3 + n1 + 2n2 ≤ n1 · (dα − 1 + cα log m1) + (n2 + n3) · (dα − 1 + cα log(m2 + 1)). The desired inequality (16) follows easily. We now prove Theorem 23. Proof of Theorem 23. We describe the α-merge algorithm using four invariants (A), (B), (C), (D) for the stack; and analyze what action is taken in each situation. Initially, the stack contains a single original Q1, so ℓ = 1 and mQ1 = 1 and wQ1 = 0, and case (A) applies. (A): Normal mode. The stack satisfies (A-1) Qi ≥ αQi+1 for all i < ℓ − 1. This includes X ≥ αY if ℓ ≥ 2. (A-2) αY ≥ Z; i.e. αQℓ−1 ≥ Qℓ. (A-3) Pℓ i=1 wQi ≤ Pℓ i=1 Gα(Qi, mQi). If ℓ ≥ 2, (A-1) and (A-2) imply X ≥ Z, i.e. Qℓ−2 ≥ Qℓ. The α-merge algorithm does one of the following: 26 • If αZ ≤ Y and there are no more original runs to load, then it goes to case (B). Condition (B-1) holds by (A-1). (B-3) holds by (A-3) since Gα(Qℓ, mQℓ) ≤ Hα(Qℓ, mQℓ). Condition (B-2) states that (α − 1)Z ≤ Y and this holds since αZ ≤ Y . • If αZ ≤ Y and there is another original run to load, then the algorithm loads the next run as Qℓ+1. ◦ If Qℓ+1 ≤ αQℓ, then we claim that case (A) still holds after ℓ is incremented by one. In particular, (A-1) and αZ ≤ Y imply that (A-1) will still hold since αZ ≤ Y is the same as αQℓ ≤ Qℓ−1. (A-2) still holds by the assumed bound on Qℓ+1. Condition (A-3) still holds since Qℓ+1 is an original run so mQℓ+1 = 1 and wQℓ+1 = 0. ◦ Otherwise Qℓ+1 > αQℓ, and we claim that case (C) below holds with ℓ incremented by one. (C-1) holds by (A-1). For (C-2), we need Qℓ−1 ≥ (α − 1)Qℓ, i.e. Y ≥ (α − 1)Z: this follows trivially from Y ≥ αZ. (C-4) holds by (A-3), since Gα(Qℓ, mQℓ ) ≤ Hα(Qℓ, mQℓ) and since Qℓ+1 is an original run so mQℓ+1 = 1 and wQℓ+1 = 0. To have (C-3) hold, we need Z ≤ α (α−1) Qℓ+1. This follows from the hypothesis Qℓ+1 > αZ and α > 1. Finally, (C-5) will hold since Qℓ+1 is an original run. • If αZ > Y , then ℓ ≥ 2 . In this case, since Z ≤ X, the algorithm merges the two runs Y and Z. We claim the resulting stack satisfies case (A) with ℓ decremented by one. It is obvious that (A-1) still holds. (A-3) still holds by Lemma 30. For (A-2), we need Y + Z ≤ αX; this follows from Y ≤ 1 α X and Z ≤ X and 1 + 1 α < α as ϕ < α. (B): Wrapup mode, lines 15-18 of Algorithm 6. There are no more original runs to process. The entire input has been combined into the runs Q1, . . . , Qℓ and they satisfy: (B-1) Qi ≥ αQi+1 for all i < ℓ − 1. This includes X ≥ αY if ℓ ≥ 2. (B-2) Y ≥ (α − 1)Z; i.e., Qℓ−1 ≥ (α − 1)Qℓ. (B-3) Pℓ i=1 wQi ≤ Pℓ−1 i=1 Gα(Qi, mQi) + Hα(Qℓ, mQℓ). If ℓ = 1, the run Z = Q1 contains the entire input in sorted order and the algorithm terminates. The total merge cost is ≤ Hα(Z, mZ ). This is n · (dα + cα log m) as needed for Theorem 23. If ℓ > 1, then Y and Z are merged.8 We claim that the resulting stack of runs satisfies (B), now with ℓ decremented by one. It is obvious that (B-1) will still holds. (B-3) will still hold since merging Y and Z adds Y + Z to the total merge cost and since G(Y , mY ) + H(Z, mZ ) + Y + Z ≤ H(Y + Z, mY + mZ ) 1 α(α−1) X ≥ Z. This gives (cid:0) 1 α + 1 by Lemma 33(a) since Y ≥ (α − 1)Z by (B-2). To show (B-2) will still hold, we must show that X ≥ (α − 1)(Y + Z). To prove this, note that 1 α X ≥ Y by (B-1); thus from (B-2), α(α−1)(cid:1)X ≥ Y + Z; hence X ≥ (α − 1)(Y + Z). (C): Encountered long run Z. When case (C) is first entered, the final run Z is long relative to Y . The algorithm will repeatedly merge X and Y as long as Z < X, staying in case (C). Once Z ≤ X, as discussed below, there are several possibilities. First, it may be that case (A) already applies. Otherwise, Y and Z are merged, and the algorithm proceeds to either case (A) or case (D). Formally, the following conditions hold during case (C) with ℓ ≥ 2: 8 Note that in this case, if ℓ ≥ 2, Z < X since (B-1) and (B-2) imply that X ≥ αY ≥ α(α − 1)Z and α2 − α > 1 since ϕ < α. This is the reason why Algorithm 6 does not check for the condition X < Z in lines 14-16 (unlike what is done on line 7). 27 (C-1) Qi ≥ αQi+1 for all i < ℓ − 2. If ℓ ≥ 4, this includes W ≥ αX. (C-2) X ≥ (α − 1)Y ; i.e., Qℓ−2 ≥ (α − 1)Qℓ−1. (C-3) Y ≤ α (α−1) Z; i.e., Qℓ−1 ≤ α (α−1) Qℓ. (C-4) Pℓ i=1 wQi ≤Pℓ−2 (C-5) Z is an original run, so mZ = 1 and wZ = 0. i=1 Gα(Qi, mQi) + Hα(Y , mY ). It is possible that no merge is needed, namely if X ≥ αY and Y ≥ αZ. In this case we claim that case (A) holds. Indeed, (A-1) will hold by (C-1) and since X ≥ αY . Condition (A-2) holds by Y ≥ αZ. Condition (A-3) follows from (C-4) and the fact that, using (C-3), Lemma 33(c) gives the inequality Hα(Y , mY ) ≤ Gα(Y , mY ) + Gα(Z, 1).9 Otherwise, a merge occurs. The cases Z > X and Z ≤ X are handled separately: • Suppose Z > X. We have ℓ ≥ 3 by the convention that Q0 = ∞, and the algorithm merges X and Y . We claim that case (C) still holds, now with ℓ decremented by 1. It is obvious that (C-1) and (C-5) will still hold. (C-4) will still hold since merging X and Y adds X + Y to the total merge cost, and since Gα(X, mX ) + Hα(Y , mY ) + X + Y ≤ Hα(X + Y , mX + mY ) by Lemma 33(a) since X ≥ (α − 1)Y by (C-3). To see that (C-2) still holds, we argue exactly as in case (B): We must show that W ≥ (α − 1)(X+Y ). To prove this, note that 1 α(α−1) W ≥ Y . α W ≥ X by (C-1); thus from (C-2), 1 α + 1 This gives (cid:16) 1 α(α−1)(cid:17) W ≥ X + Y ; hence W ≥ (α − 1)(X + Y ). To establish that (C-3) still holds, we must prove that X + Y ≤ α it suffices to show X + Y ≤ α α−1 X, or equivalently Y ≤ 1 α−1 Z. Since Z > X, α−1 X. This holds by (C-2). • Otherwise Z ≤ X, so ℓ ≥ 2, and Y and Z are merged. The analysis splits into two cases, depending on whether Y + Z ≤ αX holds. First, suppose Y + Z ≤ αX. Then we claim that, after the merge of Y and Z, case (A) holds. Indeed, (A-1) will hold by (C-1). (A-2) will hold by Y + Z ≤ αX. Condition (A-3) will hold by (C-4) and (C-5) and the fact that, using (C-3), Lemma 33(b) gives the inequality Hα(Y , mY ) + Y + Z ≤ Gα(Y + Z, mY + 1). Second, suppose Y + Z > αX and thus ℓ ≥ 3. We claim that, after the merge of Y and Z, case (D) holds. (D-1) holds by (C-1). (D-2) holds with k = 0 so Z1 is the empty run, and with Z2 and Z3 equal to the just-merged runs Y and Z (respectively). (D-3) holds since k = 0 and X ≥ Z. (D-4) holds by (C-2) and the choice of Z1 and Z2. (D-5) holds by (C-3). (D-6) holds since is the same as the assumption that Y + Z > αX. (D-7) holds α−1 Z. Finally, we claim that (D-8) holds by (C-4). To see this, note that with k = 0, the quantity "(k + 1)Z3 + Z2" of (D-8) is equal to the cost Y + Z of merging Y and Z, and that the quantities "mZ − 1" and "Z1 + Z2" of (D-8) are the same as our mY and Y . since, by (C-3), Y + Z ≤ (cid:16) α α−1 + 1(cid:17)Z = 2α−1 9 It is this step which requires us to bound the total merge cost Pi wQi instead of the individual merge costs wQi . Specifically, Gα(Y , mY ) may not be an upper bound for wY . 28 (D): Wrapping up handling a long run. In case (D), the original long run, which was earlier called "Z" during case (C), is now called "Z3" and has been merged with runs at the top of the stack to form the current top stack element Z. This Z is equal to the merge of three runs Z1, Z2 and Z3. The runs Z2 and Z3 are the two runs Y and Z which were merged when leaving case (C) to enter case (D). The run Z1 is equal to the merge of k many runs Uk, . . . , U1 which were just below the top of the stack when leaving case (C) to enter case (D). Initially k = 0, so Z1 is empty. The runs Z2 and Z3 do not change while the algorithm is in case (D). Since Z3 was an original run, mZ3 = 1. In other words, mZ − 1 = mZ1 + mZ2. There are two possibilities for how the merge algorithm proceeds in case (D). In the simpler case, it merges Y and Z, and either goes to case (A) or stays in case (D). If it stays in case (D), k is incremented by 1. In the more complicated case, it merges X and Y, then merges the resulting run with Z, and then again either goes to (A) or stays in (D). In this case, if it stays in (D), k is incremented by 2. Thus k is equal to the number of merges that have been performed. We will show that k < k0(α) must always hold. Formally, there is an integer k < k0(α) and there exists runs Z1, Z2 and Z3 (possibly Z1 is empty) such that ℓ ≥ 2 and the following hold: (D-1) Qi ≥ αQi+1 for all i < ℓ − 1. This includes X ≥ αY . (D-2) Z is equal to the merge of three runs Z1, Z2, Z3. (D-3) Y ≥ αkZ3. (D-4) Y ≥ (α − 1)(Z1 + Z2). (D-5) Z3 ≥ α−1 (D-6) αY < Z. (D-7) Z ≤ 2k(2α−1) α Z2. Z3. α−1 i=1 Gα(Qi, mQi) + (k + 1)Z3 + Z2 + Hα(Z1 + Z2, mZ − 1). (D-8) Pℓ i=1 wQi ≤ Pℓ−1 We claim that conditions (D-3), (D-4) and (D-6) imply that k < k0(α). To prove this, suppose k ≥ k0(α). From the definition of k0, this implies that α ≥ 1 αk Y ≥ Z3; (D-4) gives α−1 . (D-3) gives 1 1 α−1 Y ≥ Z1 + Z2. With (D-6) and Z = Z1 + Z2 + Z3, these imply αk + 1 Z > αY ≥ (cid:16) 1 αk + which is a contradiction. 1 α − 1(cid:17)Y ≥ Z1 + Z2 + Z3 = Z, By (D-6) and the test in line 6 of Algorithm 6, the algorithm must perform a merge, either of X and Y or of Y and Z, depending on the relative sizes of X and Z. The cases of Z ≤ X and Z > X are handled separately. • Suppose Z ≤ X. Therefore, the algorithm merges Y and Z. In addition, suppose that αX ≥ Y +Z. We claim that this implies case (A) holds after the merge. Indeed, (D-1) implies that condition (A-1) holds. The assumption αX ≥ Y + Z gives that (A-2) will hold. For (A-3), we argue by applying Lemma 33(d) with n1 = Y and n2 = Z1 + Z2 and n3 = Z3 and with k + 2 in place of k. For this, we need k + 2 ≤ k0(α) + 1 as was already proved and also need 2k+2(2α − 1) α − 1 Z3 ≥ Y + Z. 29 This is true by (D-7) since Y + Z < (1 + 1/α)Z by (D-6) and since 1 + 1/α < 4. We also have mZ − 1 = mZ1 + mZ2 > 0. Thus, Lemma 33(d) implies Hα(Y , mY )+Hα(Z1+Z2, mZ−1)+(k+2)·Z3+Y +2(Z1+Z2) ≤ Gα(Y +Z, mY +mZ). Since α < 2, Gα(Y , mY ) ≤ Hα(Y , mY ). Therefore, since Z = Z1 + Z2 + Z3, Gα(Y , mY )+(k+1)Z3+Z2+Hα(Z1+Z2, mZ −1)+Y +Z ≤ Gα(Y +Z, mY +mZ). Since the cost of merging Y and Z is equal to Y + Z, this inequality plus the bound (D-8) implies that (A-3) will hold after the merge. Alternately, suppose αX < Y +Z. In this case, Y and Z are merged: k will be incremented by 1 and Y will become part of Z1. We claim that case (D) still holds after the merge. Clearly (D-1) still holds. (D-2) still holds with Z1 now including Y . (That is, Y becomes Uk+1.) (D- 1) and (D-3) imply X ≥ αY ≥ αk+1Z3, so (D-3) will still hold. (D-4) implies Y α−1 ≥ Z1 + Z2. Therefore, (D-1) gives X α − 1 ≥ αY α − 1 = Y + Y α − 1 ≥ Y + Z1 + Z2. Thus (D-4) will still hold after the merge (since, after the merge, Y becomes part of Z1). The hypothesis αX < Y + Z implies (D-6) will still hold. By (D-6) we have Z > αY > Y , so (D-7) gives Z + Y ≤ 2Z ≤ 2k+1(2α − 1) α − 1 Z3. Thus (D-7) will still hold. Finally, by (D-4), we may apply Lemma 33(a) with n1 = Y and n2 = Z1 + Z2 to obtain Gα(Y , mY )+Hα(Z1+Z2, mZ−1)+Y +Z1+Z2+Z3 ≤ Hα(Y +Z1+Z2, mY +mZ−1)+Z3. Since the cost of merging Y and Z is Y + Z1 + Z2 + Z3 and since k is incremented by 1 after the merge, this implies that (D-8) will still hold after the merge. • Now suppose Z > X, so ℓ ≥ 3. In this case, algorithm merges X and Y ; the result becomes the second run on the stack, which we denote (XY ). We claim that immediately after this, the algorithm merges the combination (XY ) of X and Y with the run Z. Indeed, since ϕ < α, we have α > 1 + 1/α and therefore by (D-6) and by the assumed bound on X αZ > 1 α Z + Z > Y + X. Thus, the test on line 6 of Algorithm 6 triggers a second merge operation. Furthermore, since ϕ < α, we have 1 > 1 α2(α−1) and thus, using (D-1), (D-3) and (D-4), α2 + 1 W > 1 αk+2 W + 1 α2(α − 1) W ≥ 1 αk Y + 1 α − 1 Y ≥ Z1 + Z2 + Z3 = Z. With W > Z, the second merge acts to merge (XY ) and Z instead of W and (XY ). After the second merge, the top three runs X, Y, Z on the stack have been merged, with an additional merge cost of 2X + 2Y + Z. As we argue next, the algorithm now either transitions to case (A) or stays in case (D), depending whether αW ≥ X + Y + Z holds. 30 First, suppose that αW ≥ X + Y + Z. We claim that this implies case (A) holds after the two merges. Indeed, (D-1) implies that condition (A-1) will hold. The assumption αW ≥ X + Y + Z gives that (A-2) will hold. For (A-3), we argue as follows. We apply Lemma 33(d) with n1 = X + Y and n2 = Z1 + Z2 and n3 = Z3 and with k + 2 in place of k. For this, we need k + 2 ≤ k0(α) + 1 as was already proved and also need 2k+2(2α − 1) α − 1 Z3 ≥ X + Y + Z. (17) To prove (17), first note that that X + Y + Z < (2 + 1/α)Z by (D-6) and the assumption that Z > X; then (17) follows from (D-7) and the fact that 2 + 1/α < 4. We have mZ − 1 = mZ1 + mZ2 > 0. Thus, Lemma 33(d) implies Hα(X + Y , mX + mY ) + Hα(Z1 + Z2, mZ − 1) + (k + 2) · Z3 + X + Y + 2(Z1 + Z2) ≤ Gα(X + Y + Z, mX + mY + mZ ). (18) By (D-1), we have (α − 1)Y < αY ≤ X. Thus Lemma 33(a), with n1 = X and n2 = Y and m1 = mX and m2 = mY gives Gα(X, mX ) + Hα(Y , mY ) + X + Y ≤ Hα(X + Y , mX + mY ). (19) Since α < 2, Gα(Y , mY ) < Hα(Y , mY ). So, using Z = Z1 + Z2 + Z3, (18) and (19) imply Gα(X, mX ) + Gα(Y , mY ) + (k + 1)Z3 + Z2 + Hα(Z1 + Z2, mZ − 1) + 2X + 2Y + Z ≤ Gα(X + Y + Z, mX + mY + mZ ). Since the cost of the two merges combining X, Y , and Z was 2X + 2Y + Z, the last inequality and (D-8) imply that (A-3) will hold after the two merges. Alternately, suppose αW < X + Y + Z. This implies ℓ ≥ 4. We claim that in this case (D) still holds after the two merges combining X, Y and Z, and with k incremented by 2. Certainly, (D-1) still holds. (D-2) is also still true: Z2 and Z3 are unchanged, and Z1 will include X and Y (as Uk+2 and Uk+1). (D-1) and (D-3) imply W ≥ αX ≥ α2Y ≥ αk+2Z3, so (D-3) will still hold. (D-4) implies Y α−1 ≥ Z1 + Z2. Hence, (D-1) and (D-4) give W α − 1 ≥ αX α − 1 = X α − 1 + X ≥ αY α − 1 ≥ (X + Y + Z1) + Z2; + X = X + Y + Y α − 1 i.e., (D-4) will still hold. (D-5) is obviously still true. αW < X + Y + Z implies (D-6) will still hold. The already proved equation (17) implies that (D-7) will still hold. Finally, we need to establish (D-8). By (D-4), Y ≥ (α − 1)(Z1 + Z2); and thus by (D-1) and (D-3), X ≥ αY ≥ (α − 1)(Y + Z1 + Z2) Therefore, we can apply Lemma 33(a) twice, first with n1 = Y and n2 = Z1 + Z2 and then with n1 = X and n3 = Y + Z1 + Z2, to obtain Gα(X, mX ) + Gα(Y , my) + Hα(Z1 + Z2, mZ − 1) + 2X + 2Y + Z < Gα(X, mX ) + Gα(Y , my) + Hα(Z1 + Z2, mZ − 1) + X + 2Y + 2Z ≤ Gα(X, mX ) + Hα(Y + Z1 + Z2, mY + mZ − 1) + X + Y + Z + Z3 ≤ Hα(X + Y + Z1 + Z2, mX + mY + mZ − 1) + 2Z3 31 where the first inequality uses the assumption X < Z and the other two inequalities use Lemma 33(a) and Z = Z1 + Z2 + Z3. From this, it is easily seen that (D-8) will still hold after the two merges combining X, Y and Z: this is because the additional merge cost is 2X + 2Y + Z and since k will be incremented by 2. This completes the proof of Theorem 23. 6 Experimental results This section reports some computer experiments comparing the α-stack sorts, the α-merge sorts, Timsort, Shivers sort, adaptive Shivers sort and powersort. The test sequences use the following model. We only measure merge costs, so the inputs to the sorts are sequences of run lengths (not arrays to be sorted). Let µ be a distribution over integers. A sequence of m run lengths is chosen by choosing each of the m lengths independently according to the distribution µ. We consider two types of distributions for µ: 1. The uniform distribution over numbers between 1 and 100, 2. A mixture of the uniform distribution over integers between 1 and 100 and the uniform distribution over integers between 10000 and 100000, with mixture weights 0.95 and 0.05. This distribution was specially tailored to work better with 3-aware algorithms while still being formulated in a general way that avoids favoring any particular algorithm. We also experimented with power law distributions. However, they gave very similar results to the uniform distributions so we do not report these results here. In Figures 1 and Figure 2, we estimate the "best" α values for the α-merge and α-stack sorts under the uniform distribution. The experiments show that the best value for α for both types of algorithms is around the golden ratio, or even slightly lower. For α at or below ϕ, the results start to show oscillation, albeit within a small range. We discuss oscillation for other sorts below, but we do not know why the results α-merge sort oscillate for small values of α. Next we compared all the stable merge sorts discussed in the paper, plus the adaptive Shivers sort of Jug´e [16] and the powersort of Munro-Wild [25]. Figure 3 reports on comparisons using the uniform distribution. It shows that 1.62-merge sort performs slightly better than 1.62-stack sort; and they perform better than Timsort, 2-stack sort and 2-merge sort. The Shivers sort and the adaptive Shivers sort performed comparably to the 1.62-stack and 1.62-merge sorts, but exhibited a great deal of oscillation in performance. This is discussed below, but this is presumably due to the Shivers and adaptive Shivers sorts rounding to powers of two. The powersort algorithm performed the best in this test. The powersort knows the total length n of the input to be sorted; this allows it to make decisions on merges that approximate better a binary merge tree over n inputs. Figure 4 considers the mixed distribution. This is the situation that is more meaningful for our stable merge sorts. As expected, 1.62-stack sort, 2-stack sort, and Shivers sort performed the least well, approximately 15% or 20% worse than the other algorithms. The other algorithms' perfor- mances were closer to each other. The Timsort and 2-merge sort were marginally worse than the remaining three algorithms. The 1.62-merge sort and the adaptive Shivers performed comparably, with the adaptive Shivers sort exhibiting oscillatory behavior. The powersort performed the best, presumably because its use of the value n allowed it to make merge decisions that were globally optimal. The figures show that in many cases the merge cost oscillates periodically with the number of runs; this was true in many other test cases not reported here. This seems to be due in part 32 2-merge sort 1.7-merge sort 1.62-merge sort 1.5-merge sort 1.2-merge sort t s o c e g r e m d e z i l a m r o n 1.1 1.08 1.06 1.04 1.02 1 1000 2000 3000 4000 5000 6000 7000 8000 number of runs Figure 1: Comparison between α-merge sorts for different α on uniform distribution over integers between 1 and 100. For all our figures, the x-axis shows the "number of runs", namely the number of presorted subsequences (ascending or descending) in the input sequence. The y-axis shows the "normalized merge cost", namely the ratio of the total merge cost and n log m. The data points reported in Figures 1-4, are the average of 100 random trials. 2-stack sort 1.7-stack sort 1.62-stack sort 1.5-stack sort 1.2-stack sort t s o c e g r e m d e z i l a m r o n 1.1 1.08 1.06 1.04 1.02 1 1000 2000 3000 4000 5000 6000 7000 8000 number of runs Figure 2: Comparison between α-stack sorts for different α on uniform distribution over integers between 1 and 100. 33 Shivers sort adaptive Shivers sort Timsort 1.62-merge sort 1.62-stack sort 2-merge sort 2-stack sort power sort t s o c e g r e m d e z i l a m r o n 1.07 1.06 1.05 1.04 1.03 1.02 1.01 1 0.99 0.98 1000 2000 3000 4000 5000 6000 7000 8000 number of runs Figure 3: Comparison between sorting algorithms using the uniform distribution over integers between 1 and 100. Shivers sort adaptive Shivers sort Timsort 1.62-merge sort 1.62-stack sort 2-merge sort 2-stack sort power sort t s o c e g r e m d e z i l a m r o n 0.9 0.85 0.8 0.75 0.7 0.65 0.6 0.55 0.5 1000 2000 3000 4000 5000 6000 7000 8000 number of runs Figure 4: Comparison between sorting algorithms using a mixture of the uniform distribution over integers between 1 and 100 and the uniform distribution over integers between 10000 and 100000, with mixture weights 0.95 and 0.05 34 von Neumann sort Shivers sort t s o c e g r e m d e z i l a m r o n 2 1.9 1.8 1.7 1.6 1.5 1.4 1.3 1.2 1.1 1 0.9 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 number of runs Figure 5: The performance of the von Neumann merge sort (nonadaptive merge sort) on the uniform distribution of run lengths between 1 and 100. The random run lengths affect the total input length n, but the von Neumann sort ignores the runs in the initial runs in the input sequence, and greedily builds binary trees of merges. Unlike the other graphs, the data points on this graph are the result of averaging 10 tests. to the fact that some of the sorts with this behavior (notably Shivers sort and adaptive Shivers sort) base their merge decisions using powers of two, and do not take into account the number n of elements being sorted. In fact, the same behavior is exhibited by the simple von Neumann sort, namely the non-adaptive sort that greedily builds binary merge trees. This is seen in Figure 5 using the uniform distribution. In this figure, for each value of m, the input sequences were chosen under the uniform distribution; these have a fixed number, m, of runs, but different total input lengths n. That is, for fixed m, the input length n is a random variable;he von Neumann sort ignores runs, and its merge cost depends only on n. The oscillations in the von Neumann and Shivers sorts are clearly very similar, so we expect they have similar causes. Under the mixed distribution (not shown), the oscillation with the von Neumann sort was not present, presumably to the larger relative variance of n. It is still present for the Shivers and adaptive Shivers sort in the mixed distribution, presumably because of their sensitivity to longer runs. 7 Conclusion and open questions Theorem 23 analyzed α-merge sort only for α > ϕ. This leaves several open questions: Question 34. For α ≤ ϕ, does α-merge sort run in time cα(1 + ωm(1))n log m? It is likely that when α < ϕ, α-merge sort could be improved by making it 4-aware, or more generally, as α → 1, making it k-aware for even larger k's. Question 35. Is it necessary that the constants dα → ∞ as α approaches ϕ? An augmented Shivers sort can defined by replacing the inner while loop on lines 6-8 of the Shivers sort with the code: 35 while 2⌊log Y ⌋ ≤ Z do if Z ≤ X then Merge Y and Z else Merge X and Y end if end while The idea is to incorporate the 3-aware features of 2-merge sort into the Shivers sort method. The hope is that this might give an improved worst-case upper bound: Question 36. Does the augmented Shivers sort run in time O(n log m)? Does it run in time (1 + om(1))n log m? The notation om(1) is intended to denote a value that tends to zero as m → ∞. Jug´e's adaptive Shivers sort [16] is similar to the above augmented Shivers sort, and it does have run time (1 + om(1))n log m. In fact it is asymptotically optimal in a rather strong sense: It has run time asymptotically equal to the entropy-based lower bounds of Barbay and Navarro [3]. This also answered the open Question 4 in [4] about the existence of asymptotically optimal k-aware algorithms. The powersort algorithm of Munro and Wild [25] has similar asymptotic run time bounds. Our experiments indicate that 1.62-merge sort, the adaptive Shivers sort, and powersort are all strong contenders for the "best" adaptive merge sort in practice. The powersort was the best in our experiments by a small margin, but it uses a more complicated algorithm to decide when to merge, and this will increase the running time. (It potentially will use O(log n) time per merge decision, although this can be improved on.) The adaptive Shivers sort has better theoretical worst-case upper bounds than 1.62-merge sort, but this probably only arises in rare cases and it is a small difference in any event. The adaptive Shivers sort also exhibited some oscillation. Both of these algorithms are easy to implement; neither has a clear edge in our experiments. Our experiments used random distributions that probably do not do a very good job of modeling real-world data. Is it possible to create better models for real-world data? Finally, it might be beneficial to run experiments with actual real-world data, e.g., by modifying deployed sorting algorithms to calculate statistics based on run lengths that arise in actual practice. References [1] N. Auger, V. Jug´e, C. Nicaud, and C. Pivoteau, On the worst-case complexity of TimSort. arXiv:1805.08612, 2018. [2] N. Auger, C. Nicaud, and C. Pivoteau, Merge strategies: from merge sort to Timsort. HAL technical report: hal-01212839, 2015. [3] Barbay and Navarro, On compressing permutations and adaptive sorting, Theoretical Com- puter Science, 513 (2013), pp. 109 -- 123. [4] S. Buss and A. Knop, Strategies for stable merge sort, in Proc. 13th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA'19), 2019, pp. 1272 -- 1290. [5] S. Carlsson, C. Levcopoulos, and O. Petersson, Sublinear merging and natural merge- sort, Algorithmica, 9 (1993), pp. 629 -- 648. 36 [6] B. Chandramouli and J. Goldstein, Patience is a virtue: Revisiting merge and sort on modern processors, in Proc. ACM SIGMOD Conference on Management of Data, 2014, pp. 731 -- 742. [7] C. R. Cook and D. J. Kim, Best sorting algorithm for nearly sorted lists, Communications of the ACM, 23 (1980), pp. 620 -- 624. [8] S. de Gouw, J. Rot, F. S. D. Boer, R. Bubel, and R. Hahnle, OpenJDK's java.util.Collection.sort() is broken: The good, the bad, and the worst case, in Proc. Interna- tional Conference on Computer Aided Verification (CAV), Lecture Notes in Computer Science 9206, Springer, 2015, pp. 273 -- 289. [9] J. Dean and S. Ghemawat, MapReduce: Simplified data processing on large clusters, Com- munications of the ACM, 51 (2008), pp. 107 -- 113. [10] V. Estivill-Castro and D. Wood, A survey of adaptive sorting algorithms, ACM Com- puting Surveys, 24 (1992), pp. 441 -- 476. [11] V. Geffert, J. Katajainen, and T. Pasanen, Asyptoptotically efficient in-place merging, Theoretical Computer Science, 237 (2000), pp. 159 -- 181. [12] H. Hamamura, J. Miyao, and S. Wakabayashi, An optimal sorting algorithm for presorted sequences, RIMS Kokyuroku, 754 (1991), pp. 247 -- 256. [13] J. D. Harris, Sorting unsorted and partially sorted lists using the natural merge sort, Software -- Practice and Experience, 11 (1981), pp. 1339 -- 1340. [14] B.-C. Huang and M. A. Langston, Practical in-place merging, Communications of the ACM, 31 (1988), pp. 348 -- 352. [15] F. K. Hwang and S. Lin, A simple algorithm for merging two disjoint linearly ordered sets, SIAM J. on Computing, 1 (1972), pp. 31 -- 39. [16] V. Jug´e, Adaptive Shivers sort: An alternative sorting algorithm. Preprint, arXiv:1809.08411 [cs.DS], September 2018. [17] D. E. Knuth, The Art of Computer Programming, Volume III: Sorting and Searching, Addison-Wesley, second ed., 1998. [18] M. A. Kronrod, Optimal ordering algorithm without a field of operation, Soviet Math. Dokl., 10 (1969), pp. 744 -- 746. Russian original in Dokl. Akad. Nauk SSSR 186, 6 (1969) pp. 1256- 1258. [19] A. LaMarca and R. E. Ladner, The influence of caches on the performance of sorting, Journal of Algorithms, 31 (1999), pp. 66 -- 104. [20] C. Levcopoulos and O. Petersson, Splitsort -- an adaptive sorting algorithm, Information Processing Letters, 39 (1991), pp. 205 -- 211. [21] , Sorting shuffled monotone sequences, Information and Computation, 112 (1994), pp. 37 -- 50. [22] H. Mannila, Measures of presorteness and optimal sorting algorithms, IEEE Transactions on Computers, C-34 (1985), pp. 318 -- 325. 37 [23] H. Mannila and E. Ukkonen, A simple linear-time algorithm for in situ merging, Informa- tion Processing Letters, 18 (1984), pp. 203 -- 208. [24] P. McIlroy, Optimistic sorting and information theoretic complexity, in Proc. 4th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), 1993, pp. 467 -- 474. [25] J. I. Munro and S. Wild, Nearly-optimal mergesorts: Fast, practical sorting methods that optimally adapt to existing runs. arXiv:1805.04154, 2018. [26] T. Peters, [Python-Dev] Sorting. Python Developers Mailinglist. Retrieved from https://mail.python.org/pipermail/python-dev/2002-July/026837.html on July 5, 2017, July 2002. [27] O. Petersson and A. Moffat, An overview of adaptive sorting, Australian Computer Journal, 24 (1992), pp. 70 -- 77. [28] M. L. Rocca and D. Cantone, NeatSort -- a practical adaptive algorithm. arXiv:1407:6183, July 2014. [29] O. Shivers, A simple and efficient natural merge sort. Unpublished, presented at IFIP WG 2.8 Workshop on Function Programming, St. Malo, France. Retrieved from https://www.cs.tufts.edu/∼nr/cs257/archive/olin-shivers/msort.ps on July 25, 2017, 1999. [30] S. S. Skiena, Encroaching lists as a measure of presortedness, BIT Numerical Mathematics, 28 (1988), pp. 755 -- 784. [31] A. Symvonis, Optimal stable matching, The Computer Journal, 38 (1995), pp. 681 -- 690. [32] H. Zhang, B. Meng, and Y. Liang, Sort race. arXiv:1609.04471, September 2015. 38
1407.1209
3
1407
2015-05-28T00:30:26
A Bit-Parallel Russian Dolls Search for a Maximum Cardinality Clique in a Graph
[ "cs.DS" ]
Finding the clique of maximum cardinality in an arbitrary graph is an NP-Hard problem that has many applications, which has motivated studies to solve it exactly despite its difficulty. The great majority of algorithms proposed in the literature are based on the Branch and Bound method. In this paper, we propose an exact algorithm for the maximum clique problem based on the Russian Dolls Search method. When compared to Branch and Bound, the main difference of the Russian Dolls method is that the nodes of its search tree correspond to decision subproblems, instead of the optimization subproblems of the Branch and Bound method. In comparison to a first implementation of this Russian Dolls method from the literature, several improvements are presented. Some of them are adaptations of techniques already employed successfully in Branch and Bound algorithms, like the use of approximate coloring for pruning purposes and bit-parallel operations. Two different coloring heuristics are tested: the standard greedy and the greedy with recoloring. Other improvements are directly related to the Russian Dolls scheme: the adoption of recursive calls where each subproblem (doll) is solved itself via the same principles than the Russian Dolls Search and the application of an elimination rule allowing not to generate a significant number of dolls. Results of computational experiments show that the algorithm outperforms the best exact combinatorial algorithms in the literature for the great majority of the dense graphs tested, being more than twice faster in several cases.
cs.DS
cs
A Bit-Parallel Russian Dolls Search for a Maximum Cardinality Clique in a Graph∗ Ricardo C. Correa Philippe Michelon Universidade Federal Rural do Rio de Janeiro, Universit´e d'Avignon et des Pays du Vaucluse, Departamento de Ciencia da Computa¸cao, Laboratoire d'Informatique d'Avignon, Av. Governador Roberto Silveira S/N, F-84911 Avignon, Cedex 9, France 26020-740 Nova Igua¸cu - RJ, Brazil Bertrand Le Cun, Thierry Mautor Diego Delle Donne Universit´e de Versailles Saint Quentin, Sciences Institute, 45 Avenue des Etats Unis, 78035 Versailles, France National University of General Sarmiento, J. M. Guti´errez 1150, Malvinas Argentinas, (1613) Buenos Aires, Argentina September 15, 2018 Abstract Finding the clique of maximum cardinality in an arbitrary graph is an NP-Hard problem that has many applications, which has motivated studies to solve it exactly despite its difficulty. The great majority of algorithms proposed in the literature are based on the Branch and Bound method. In this paper, we propose an exact algorithm for the maximum clique problem based on the Russian Dolls Search method. When compared to Branch and Bound, the main difference of the Russian Dolls method is that the nodes of its search tree correspond to decision subproblems, instead of the optimization subproblems of the Branch and Bound method. In comparison to a first implementation of this Russian Dolls method from the literature, several improvements are presented. Some of them are adaptations of techniques already employed successfully in Branch and Bound algorithms, like the use of approximate coloring for pruning purposes and bit-parallel operations. Two different coloring heuristics are tested: the standard greedy and the greedy with recoloring. Other improvements are directly related to the Russian Dolls scheme: the adoption of recursive calls where each subproblem (doll) is solved itself via the same principles than the Russian Dolls Search and the application of an elimination rule allowing not to generate a significant number of dolls. Results of computational experiments show that the algorithm outperforms the best exact combinatorial algorithms in the literature for the great majority of the dense graphs tested, being more than twice faster in several cases. ∗This work has been partially supported by the Stic/AmSud joint program by CAPES (Brazil), CNRS and MAE (France), CONICYT (Chile) and MINCYT (Argentina) -- project STABLE -- and the Pronem program by FUNCAP/CNPq (Brazil) -- project ParGO. The first author was with Universidade Federal do Cear´a, Departamento de Computa¸cao, Brazil, when this work was done. The second author has been partially granted by the "Pesquisador Visitante Especial" (CNPq program) process 313831/2013-0. 1 1 Introduction 1.1 Problem Statement Let G = (V, E) be a simple and undirected graph, with V being its set of vertices and E its set of edges. A clique of G is a subset (of V ) of pairwise adjacent vertices. We consider the CLIQUE problem, which consists in finding in G a clique of maximum size ω(G), which in turn is called the clique number of G. In addition to its many practical applications (see for instance [1, 2, 3]), it is algorithmically equivalent to the maximum stable set and the minimum vertex cover problems (S ⊆ V is a stable set of G if it is a clique in the complement of G and a vertex cover if every edge in E has at least one endpoint in S). The CLIQUE problem is in NP-hard [4] and is even hard to approximate by a reasonable factor [5], unless the graph is restricted to have a special structure. In this paper we deal with exact algorithms for determining the clique number of arbitrary graphs. Before going into the details of the problem and its algorithms, let us state some notation. • V = {1, 2, . . . , n}, for some n ∈ N. • N (u) = {v ∈ V (u, v) ∈ E} is the neighborhood of a vertex u in G whose members are neighbors of u. • If U ⊆ V , then G[U ] = (U, E[U ]) denotes the subgraph of G induced by U . • If v ∈ V , then U + v and U − v stands for U ∪ {v} and U \v, respectively. • An ℓ-coloring of G is an assignment of a color from {1, . . . , ℓ} to every vertex of G such that the endpoints of any edge get different colors. It can be characterized by ℓ disjoint subsets C1, . . . , Cℓ such that ∪ℓ i=1Ci = V and G[Ci] is a stable set for all i ∈ {1, . . . , ℓ}. 1.2 Exact Algorithms via Branch and Bound Several Branch and Bound (B&B) algorithms have been proposed to solve the CLIQUE problem exactly (for an overview, see [6]). As usual, such algorithms perform a search in a tree. A node in this tree is a pair (Cq, Cd) of disjoint subsets of V , where Cq is a clique of G and Cd is a set of candidate vertices, e.g. vertices that can extend Cq to a larger clique of G. In this manner, a node of the search tree can be alternatively seen as the root of the search tree of a smaller instance of the CLIQUE problem, more specifically the one defined on the subgraph G′ of G induced by Cd. In addition to this recursive view of the search, some of the former algorithms employ relatively sophisticated procedures to obtain upper bounds for ω(G′) as tight as possible in the hope of pruning the enumeration considerably [7, 8, 9]. Since the computation of such a bound is generally applied at numerous nodes of the search tree, the most recent developments were achieved with the use of simpler and faster, but still effective bounding procedures. In this vein, the most successful approach involves the use of approximate colorings of selected subgraphs of G. This bound, whose application for the CLIQUE problem was first proposed in [10], is based on the following remark: Remark 1 (Upper bound from vertex coloring). If G admits an ℓ-coloring, then ω(G) ≤ ℓ. A direct consequence of this remark is that any heuristic that provides a proper coloring of G gives an upper bound for ω(G), in special the so called greedy coloring heuristic: enumerate the elements of V in some pre-defined order, assigning to each vertex the smallest available color. 2 The algorithm MCR proposed in [11] is very representative of this approach. When a node of the search tree is explored, the greedy coloring heuristic is applied considering that the corresponding candidate vertices are stored in an array, say R. The order of the vertices in R defines the order of enumeration of the greedy coloring heuristic. The resulting coloring is then used to resort R in a non-decreasing order of colors. After that, the color c(i) of R[i] is an upper bound for the clique number of G[{R[1], . . . , R[i]}] by Remark 1. Hence, vertex R[i] produces a branching only if c(i)+(the size of the clique defining the current node) is greater than the best clique found so far. A branching of R[i] consists in the generation of the node defined by the addition of R[i] to the current clique and the set of candidates {R[1], . . . , R[i − 1]} ∩ N (R[i]). Experiments with this algorithm show that it attains a good tradeoff between time spent computing approximate colorings and number of nodes explored in the search tree. It was shown with computational experiments that MCR clearly outperformed other existing algorithms in finding a maximum clique. However, some improvements not too time-consuming in comparison with the reduction in the search space thereby obtained have been performed in this basic algorithm. In [12], a more judicious ordering of the vertices in the nodes of the search tree is proposed, improving the bounds obtained with the greedy coloring heuristic. In [13] (algorithm MCS), the algorithm is modified in two points related to the coloring heuristic: first, a static order similar to the one proposed in [12] is adopted; second, a color exchange strategy is employed to try to recolor a vertex v getting a large color with a smaller one that could avoid the branching of v. Studies of the impact of vertex ordering in the coloring based strategies mentioned above can be found in [14, 15]. In [16] and [17], an heuristic is applied first: the Iterated Local Search (ILS) heuristic proposed in [18] to obtain an initial high-quality solution that allows to prune early branches of the search tree. 1.3 Bit-Level Parallelism Another improvement of the MCR algorithm is accomplished by means of the encoding of the graph as a bitmap and the incorporation of bit-parallel operations. A leading algorithm in this direction, referred to as BBMC, is described in [19, 20]. A bitmap is a data structure for set encoding which stores individual elements of the set in a compact form while allows for direct address of each element. Still more interesting is its ability to benefit from the potential bit-level parallelism available in hardware to perform collective set operations through fast bit-masking operations (intersection of two sets is a typical example detailed in Section 4.1). However, to exploit this potential parallelism in practice to improve overall efficiency is not a trivial task since the manipulation of bitmaps turns out to be less efficient when the enumeration of elements is relevant [21]. The use of bit-masking operations occurs in the BBMC algorithm in two points, namely the branching and the greedy coloring heuristic. Branching corresponds to determining the set intersec- tion {R[1], . . . , R[i − 1]} ∩ N (R[i]), whereas a greedy coloring can be built as successive operations of set difference of the neigborhood of selected vertices with a set of candidates. In this sense, set intersection and set difference are the essential operations in the BBMC algorithm. These are set operations that are efficiently performed by means of bit-masking operations if the sets involved are stored as bitmaps. For this reason, bit-level parallelism has been proved to be a powerful tool in efficient implementations of the branching and bounding rules of the BBMC algorithm. Naturally, this requires that the input graph and the nodes of the search tree are stored as bitmaps. A modification of the BBMC to encompass the recoloring strategy of the MCS algorithm and 3 to further reduce the time spent in the coloring based bounding procedure are the contributions in [22]. The reduction in the coloring computation time is accomplished as follows. Let us consider (Cq, Cd) as the current node and M AX as the size of the best known solution found so far. The improved bounding procedure consists in determining a maximal subgraph of G[Cd] that is k- partite, for k = M AX − Cq, with a partial coloring greedy heuristic. The vertices so colored are not considered for branching. Specific rules are used to sort and select uncolored vertices for branching. Experimental results show that the number of nodes visited is almost always greater than BBMC, but significant improvement in performance occurs for a certain number of graphs. 1.4 An Exact Algorithm via the Russian Dolls Method An alternative method, called Russian Dolls (RD) in its original description in [23], has also been used to solve the CLIQUE problem. When compared to B&B, the main difference of the RD method is that the nodes of its search tree correspond to decision subproblems, instead of the optimization subproblems of the B&B method. In general terms, the method consists in iteratively solving larger and larger subproblems (also referred to as dolls) to optimality until the global problem is solved. During this iterative process, the optimum value of each doll is taken into account when solving larger subproblems. As far as we are aware, the original application of this method to the CLIQUE problem is the algorithm proposed in [24], in which subproblems are associated with subgraphs Gi = (Vi, Ei), i ∈ {1, ..., n}, where V1 = {1}, Vi+1 = Vi ∪ {i + 1}, Ei = E[Vi], and Gn = G (for the sake of convenience, we use a slight modification of the notation used in [24]). An optimum solution of the doll of index i is a clique of maximum size in the associated subgraph Gi, which means that ω(Gi) is known after solving doll of index i. Thus, searching for a maximum clique in Gi+1 corresponds to decide whether ω(Gi+1) = ω(Gi) or ω(Gi+1) = ω(Gi) + 1. Moreover, ω(Gi+1) can be equal to ω(Gi) + 1 only if the unique vertex i + 1 in Vi+1 \ Vi appears in every maximum clique of Gi+1. For this reason, doll of index i + 1 is handled only once Gi is solved by solving the decision subproblem of deciding whether G[Vi ∩ N (i + 1)] contains a clique of size ω(Gi) or not. Every decision subproblem is an instance of an NP-Complete problem, but hopefully of small or moderate size. In the absence of effective strategies to reduce the search space, the time required to solve "no" decision subproblems can become prohibitively high, even for moderately sized instances. In order to try to circumvent this drawback, there are two pruning rules devised in [24] to cut a "no" decision subproblem associated with the set Vi ∩ N (i + 1) of candidates, as follows: 1. Vi ∩ N (i + 1) < ω(Gi): in this situation, Vi ∩ N (i + 1) does not contain enough candidates to build a clique of size ω(Gi); and 2. there exists no j ∈ Vi ∩N (i+1) such that ω(Gj) = ω(Gi): this is equivalent to say that ω(Gj), for all j ∈ Vi, is such that ω(Gj) < ω(Gi) (recall that ω(Gj ) has been already computed). Since ω(Gj) is an upper bound for ω(G[Vj ∩ N (i + 1)]), we can conclude that no clique in G[Vi ∩ N (i + 1)] has size ω(Gi). It is worth remarking that rule 2 does not imply rule 1. The effectiveness of rule 2 on pruning "no" decision subproblems depends on how Vj ∩ N (i + 1) differs from Vj. More specifically, when there exists j ∈ Vi ∩ N (i + 1) such that ω(Gj) = ω(Gi) and ω(G[Vj ∩ N (i + 1)]) < ω(Gj), the pruning rule 2 fails to prune Gj. In this sense, a contribution of the algorithm proposed in this paper with respect to the one in [24] is the use of more effective bounding heuristics. 4 1.5 Our Contributions In this paper, we propose a new exact algorithm for the CLIQUE problem based on the RD method. The goal is to provide the basic algorithm in [24] with an alternative pruning rule which allows to skip a larger number of dolls. As a result, the number of "no" decision subproblems examined is significantly reduced. For this purpose, we incorporate procedures that have already shown their effectiveness with the B&B method but, as far as we know, their performance have not yet been checked with a RD framework. These procedures need to be adapted having in mind that simplicity is very important to make the computation overhead as low as possible. In this sense, we suggest the following improvements to the original implementation of the RD algorithm presented in [24]: • The use of partial coloring heuristics to establish the sequence of dolls hG1 = (V1, E1), . . . , Gn = (Vn, En)i. In our algorithm, contrary to the one in [24], the sequence hv1, . . . , vni of vertices defining V1 = {v1} and Vi = Vi−1 ∪ {vi}, for i ∈ {2, . . . , n}, is not determined beforehand. Instead, the order in which the vertices are considered is established during the execution of the algorithm in order to eliminate as many dolls as possible. For this purpose, once a decision subproblem Gi, i ∈ {1, . . . , n − 1}, is solved, the choice of the next doll to handle is made depending on the answer of Gi. If Gi is a "no" instance, then we choose vi+1 as the smallest vertex in V \Vi. Otherwise, Gi is a "yes" instance, which means that the current best solution is incremented as a result of solving Gi. Thus, we apply the following elimination rule, based on Remark 1. Let C be the clique of size ω(Gi) found in Gi. We first apply a greedy heuristic to extend C to a maximal clique C ′ of G by adding k = (C ′ − C + 1) vertices from V \ Vi. Then, we search for a maximal k-partite induced subgraph of G[V \ Vi]. Let us say that L is the set of vertices found in this search, with L = ℓ. We set Vi+ℓ = Vi ∪ L and choose vi+ℓ+1 as the smallest vertex in V \ Vi+ℓ. This corresponds to eliminate the decision subproblems Gi+1, . . . , Gi+ℓ. We tested variations of the coloring heuristics used in MCR and MCS to find k-partite induced subgraphs, namely: the "standard greedy" [25] and the greedy with recoloring [13]. • Each decision subproblem Gi+1 is itself solved through a recursive enumeration based on the same principles of the RD method. More precisely, the search is performed in larger and larger subdolls of G[Vi ∩ N (i + 1)] until either a clique of size ω(Gi) is found or it is proved that no such clique exists. However, a particularity of this enumeration is that it follows its own sequence of subdolls in the sense that the associated sequence of vertices is not (necessarily) a subsequence of hv1, . . . , vii. The reason is that the pruning rule described in the previous item is applied as an initial step to determine (and prune) an (ω(Gi) − 1)-partite induced subgraph H of G[Vi ∩ N (i + 1)]. The sequence hw1, . . . , wVi∩N (vi+1)i of subdolls is such that V (H) = {w1, . . . , wV (H)} and, for every j > V (H), wj is the smallest vertex of (Vi ∩ N (i + 1)) \ {w1, . . . , wj−1}. As a consequence, the coloring based pruning rule enhances pruning rules 1 and 2. We give more details of this fact in Section 2. • A bitmap encoding of G and an optimized implementation of several procedures to benefit from 128-bit parallelism available in the Streaming SIMD Extensions CPU instruction set. This requires the reformulation of the RD method as an appropriate sequence of set opera- tions. When compared with the B&B implementations described in [19, 20, 22], we adopt the same principle of using bitmaps, but we describe the sequence of set operations in order not to need to use arrays of integers. Consequently, our implementation requires less memory 5 space for these data structures. Extensive computational experiments have been carried out to compare our algorithm, called RDMC, with effective algorithms from the literature. The algorithms chosen for comparison pur- poses were MCR, MCS, and recent versions of BBMC because it has been showed in previous works that they clearly outperform the algorithm in [24]. We use in our analyses a specific imple- mentation of MCR, MCS, and BBMC inspired in [22]. In particular, we add a slight improvement that contributes to further reduce the number of explored subproblems. The same basic routines for set operations are used in all our implementations. All the computational experiments were ran in the same computational platform. This aims at avoiding the imprecision resulting from experiments with distinct codes or computational platforms, as pointed out in [14]. Results show that our implementations outperform the best exact combinatorial algorithms in the literature. In addition, our implementation of RDMC is often more efficient than the B&B counterparts for graphs with density above 80%, being more than twice faster in several cases. The remainder sections are organized as follows. In Section 2, we give an overall description of our RD algorithm, describing its main elements. The details of the algorithm is the subject of Section 4. This section includes the description of the different improvements and specific features listed above. Finally, experimental results and analyses are presented in Section 5. The paper is closed with some concluding remarks in Section 6. 2 Overall Description of the Algorithm In this section, we give a general overview of our RD algorithm. The main elements of this algorithm, which are outlined in Alg. 1, are the iterative procedure for decision subproblem generation and applications of the pruning rule. In what follows, we describe these main elements. We postpone the details on how these elements are implemented until Section 4.1. Algorithm 1 RD for the CLIQUE problem 1: M AX ← 0, R ← ∅, S ← V 2: while S 6= ∅ do 3: 4: 5: 6: 7: 8: 9: 10: else S ← S − v, R ← R + v Let v be the smallest vertex in S Cq ← ∅ if decide(G, R ∩ N (v), M AX, Cq) then k ← extendClique(G, S, Cq) + 1 maxPartiteSubgraph(G, S, R, k) M AX ← M AX + k 2.1 Decision Subproblems Enumeration Recall that the general description of the RD method establishes that, for every i ∈ {1, . . . , n}, Vi stands for the subset of vertices defining a subgraph Gi and, thus, a decision subproblem. In Alg. 1, variables R and S are used to store the current decision subproblem defining set Vi and its complement V \ Vi, respectively. Their initial states correspond to an empty decision subproblem. Another set variable, Cq, is used to store the current clique of G, whereas the integer variable M AX 6 contains the size of the maximum clique found so far. The enumeration is performed iteratively in the while loop between lines 2 -- 10. The first step in an iteration is the choice, at line 3, of the vertex v (which is called vi+1 in the general description of the method) to be moved from S to R in order to define the new current doll. It is worth remarking that the choice of v determines the enumeration order. It follows that the choice of v as the smallest vertex in R depends not only on the vertex numbering but also on the result of the application of the pruning rule in previous iterations. After executing line 3, we have to decide (with the recursive function decide) whether the decision subproblem G[R ∩ N (v)] has a clique of size M AX = ω(G[R]). If this search fails, then ω(G[R + v]) = ω(G[R]) and we go to the next iteration. Otherwise, there exists a clique of G[R + v] containing v that gives ω(G[R + v]) = ω(G[R]) + 1 = M AX + 1, which enables the application of the pruning rule. Function decide gets four parameters as input, namely the graph G, a subset R of candidate vertices, an integer ℓ, and an empty clique Cq. It returns TRUE if and only if G[R] contains a clique of size ℓ, in which case Cq contains such a clique. Otherwise, it returns FALSE. 2.2 Enhanced Pruning Rule A decision subproblem can be pruned from the search when it can be proved in the function call decide(G, R, ℓ, Cq) that it does not contain any clique of the desired size ℓ. The enhanced pruning rule of our RD algorithm is applied at lines 6 and 7. For line 6, it can be noticed that the clique Cq of G[R ∩ N (v)] obtained when the call decide(G, R ∩ N (v), M AX, Cq) returns TRUE is not necessarily maximal in G. So, we make it maximal with call extendClique(G, S, Cq), which returns the number k of vertices of S added to Cq. Since we have M AX + k as the new lower bound for the optimum solution, we can prune subproblems corresponding to vertices in S based on a generalization of Remark 1. The basic property used in this pruning is that, in a stable set, at most one vertex can belong to the maximum clique: indeed two vertices that are not linked cannot belong conjointly to a clique. More fundamentally, we use the following property: Property 1. Let R, R′ ⊆ V , R ⊆ R′ be such that G[R′ \ R] admits an k-coloring, k ≥ 1. Then, ω(R′) ≤ ω(R) + k. Proof. Since R′ = R ∪ (R′ \ R), we have ω(G[R′]) ≤ ω(G[R]) + ω(G[R′ \ R]). In addition, since at most one vertex of each color can be in a clique, ω(G[R′ \ R]) ≤ k and the result follows. A consequence of Property 1 is that R′ is built from R by the addition of vertices from S defining a k-partite subgraph of G. Then, ω(G[R′]) is at most the new lower bound M AX + k. For this purpose, we make call maxPartiteSubgraph(G, S, R, k), which moves a maximal k-partite subgraph of G[S] from S to R. Note that the vertices that have been added to Cq by the previous call to function extendClique do not need to be moved from S to R. Note also that the iterations corresponding to the vertices removed from R are skipped from the enumeration. A particular application of this pruning rule occurs at the first iteration of Alg. 1. In this case, decide(G, ∅, 0, ∅) returns TRUE. So, the algorithm begins by determining a maximal clique of G, of size k, which leads the call maxPartiteSubgraph(G, S, R, k) to provide a maximal k-partite subgraph of G, of cardinality, say, ℓ. The corresponding ℓ iterations are skipped and the RD process starts on Gℓ+1. 7 2.3 Sequence of Dolls The sequence hv1, . . . , vni of vertices defining V1 = {v1} and Vi = Vi−1 ∪ {vi}, for i ∈ {2, . . . , n}, and, consequently, the sequence of dolls hG1 = (V1, E1), . . . , Gn = (Vn, En)i, is determined during the execution of Alg. 1 in the following way. Due to the pruning rule, the vertices v1, . . . , vr are of two types with respect to the way they have entered R: there are those moved from S (i) at line 10 and (ii) by a call to function maxPartiteSubgraph at line 7. Let it(v), v ∈ V , be the iteration in which v is inserted in R (we assume that the first iteration has rank 1). Then, for every i, j ∈ {1, . . . , n}, i < j, the following conditions hold: 1. it(vi) < it(vj), or 2. it(vi) = it(vj) (this means that both vi and vj are of type (ii)) and there exists an ordering hC1, . . . , Cki of the k stable sets determined in the call to maxPartiteSubgraph at iteration it(vi) such that vi ∈ Cc(vi) and vj ∈ Cc(vj ) yields c(vi) ≤ c(vj). Besides determining the sequence of dolls, the application of the enhanced pruning rule has the effect that the only information available at any iteration of Alg. 1 about some previous dolls is an upper bound for their optimum, and not their exact value. To make it more precise, let mi = 0, if i = 0, and, for i ∈ {1, . . . , n}, let mi be mi−1 if vi is of type (i), or c(vi) plus the value of M AX at the begining of iteration it(vi) if vi is of type (ii). Clearly, hm1, . . . , mri is a nondecreasing sequence and mi is equal to ω(Gi) if vi is of type (i) or an upper bound for ω(Gi), if vi is of type (ii). In addition, the dolls corresponding to vertices of type (i) have the following property. Property 2. Let v be the vertex selected at line 3 at the current iteration of Alg. 1. Then, for all b ∈ {1, . . . , M AX}, there exists vt ∈ R ∩ N (v) such that mt = b. Proof. First note that, by definition, vertex vj ∈ R having mj = b with smallest index j is of type (ii), which means that vj is included in the stabe set Cc(vj ) at iteration it(vj). Since Cc(vj ) is maximal with respect to S ∪ Cc(vj) and Cc(vj) ⊆ R, the set R ∩ N (v) contains a neighbor vt of v with mt = b. A final remark with respect to the sequence of dolls established by Alg. 1 is that an adaptation of pruning rule 2 to be used with mj in the role of ω(Gj ) is useless. Property 2 with b = ω(Gi) implies that the adapted pruning rule 2 would not eliminate the decision subproblem R ∩ N (v). 3 A Comparative Example The main differences between RD and B&B algorithms, both using partial colorings for pruning purposes, are illustrated in this section by means of an example. Indeed, as one may see with this example, the differences between the two approaches make them complementary to each other. We show the executions of Alg. 1 and an improved version of the algorithm in [22] for the graph of Fig. 1. In both cases, we consider that the same greedy heuristics for clique and partial coloring generation are used. In these heuristics, vertices are examined in an increasing order of vertex identity. In Fig. 2, the iterations of Alg. 1 are represented by the decision subproblems generated and the states of the two sets R and S attained during its manipulations. In the first iteration, the corresponding decision subproblem is related to the empty subgraph of G and M AX = 0. Since it is 8 3 2 5 4 6 1 9 0 7 8 Figure 1: Graph a "yes" instance, an extended clique (starting with clique {0}) and a partial coloring are construted, generating the states depicted in Fig. 2(a). Extending {0} in an increasing order of vertex indices gives the maximal clique {0, 1}. Thus, M AX is incremented by 2, which leads to a partial coloring of the vertices in S with the 2 colors C1 = {0, 2, 5} and C2 = {1, 3, 9}, pruning the so colored vertices by moving them to R. It is straightforward to check that, as predicted by Property 1, the subgraph induced by the colored vertices does not contain any clique of size larger than 2. In the second iteration (Fig. 2(b)), when selected, the smallest vertex in S (vertex 4) generates a "no" decision subproblem. Note that, according to Property 2, this decision subproblem cannot be eliminated because m5 = 2, for v5 = 3. Finally, in the third iteration of Fig. 2(c), M AX is incremented by 2 again, which prunes all remaining vertices in S. In summary, the execution has the characteristics shown in Table 1. Decision subprolem solved ∅ = ∅ ∩ N (0) {0, 3, 5} = {0, 1, 2, 3, 5, 9} ∩ N (4) New solution found {0, 1} -- extended {0, 1} -- {2, 3, 6} {0, 2, 3, 5} = {0, 1, 2, 3, 4, 5, 9} ∩ N (6) Colors constructed by calls to maxPartiteSubgraph: {0, 2, 5}, {1, 3, 9}, {6, 8}, and {7} Uncolored vertex: 4 {2, 3, 6, 7} M AX incremented by 2 -- 2 Table 1: Summary of execution at Fig. 2. The version of the B&B algorithm in [22] that we use to compare with Alg. 1 is outlined in Alg. 2. In this algorithm, R is the set of colored vertices, S is the set of uncolored candidate vertices, and CU R is the size of the clique defining the current node of the search tree. The point to be highlighted is the call optimize(G, (R ∪ S) ∩ N (v), CU R + 1) at line 6. In comparison with call decide(G, R ∩ N (v), M AX, Cq) at line 5 of Alg. 1, we can observe two differences. First, contrary to the RD algorithm, the subgraph involved in the B&B version includes the vertices in R ∩ N (v). As a consequence, the second difference is that the subproblem is an optimization problem. In Fig. 3, the execution of the call optimize(G, V , 0) is shown. The main idea behind the recursive function optimize is the same as the BBMC algorithm. With respect to the algorithm described in Subsection 1.2, there is a modification originally proposed in [22]. It consists in the 9 S = R = Cq = S = R = Cq = 0 0 0 0 2 3 4 5 6 7 8 9 1 1 After extendClique(G, {0 -- 9}, ∅) 4 6 7 8 2 3 5 9 1 1 After maxPartiteSubgraph(G, {0 -- 9}, ∅, 2) (a) First iteration. Vertex selected is 0. Two states attained after call decide(G, ∅, 0, ∅). At the end, M AX = 2. S = R = Cq = 0 0 1 2 3 4 5 9 6 7 8 (b) Second iteration. Vertex selected is 4. A state at- tained after call decide(G, {0, 3, 5}, 2, ∅). S = R = Cq = S = R = Cq = 0 1 2 2 3 3 4 5 6 6 7 7 8 9 After extendClique(G, {6, 7, 8}, {2, 3}) 0 1 2 2 3 3 4 5 6 6 7 7 8 9 After maxPartiteSubgraph(G, {6, 7, 8}, {0 -- 5, 9}, 2) (c) Third iteration. Vertex selected is 6. Two states attained after call decide(G, {2, 3, 5}, 2, ∅). At the end, M AX = 4. Figure 2: Execution of Alg. 1 for the graph of Fig. 1, with initial state S = {0, . . . , 9}, R = ∅, and M AX = 0. The sequence of dolls corresponds to h0, 2, 5, 1, 3, 9, 4, 6, 8, 7i. use of a partial coloring of the set of unexplored vertices, as indicated in line 3 of Alg. 2, with the purpose of determining the vertices that can be pruned from the search due to their upper bounds. For the vertices that remain uncolored after line 3, the corresponding optimization subproblems are generated and solved recursively. As an additional improvement, we introduce line 8 to prune additional vertices whenever the current best solution value is incremented during the recursive call. Algorithm 2 Partial coloring B&B R ← ∅, M AX ← max{M AX, CU R}, k ← M AX − CU R maxPartiteSubgraph(G, S, R, k) while S 6= ∅ do 1: function optimize(G, S, CU R) 2: 3: 4: 5: 6: 7: 8: 9: Let v be the greatest vertex in S optimize(G, (R ∪ S) ∩ N (v), CU R + 1) S ← S − v maxPartiteSubgraph(G, S, R, M AX − CU R − k) k ← M AX − CU R The execution of the partial coloring B&B algorithm results in the generation of three opti- mization subproblems, corresponding to the three recursive calls represented in figures 3(a), 3(b), and 3(c). The execution is summarized in Table 2. There are some relevant remarks with respect to the subproblems generated during the execution of Alg. 1 and Alg. 2. First, the optimization subproblems tend to be defined by larger subgraphs 10 than the decision subproblems as a consequence of the complementary selection strategies (lines 3 of Alg. 1 and line 5 of Alg. 2). Second, the upper bound used to prune nodes tends to be tighter with the selection strategy of Alg. 1. For instance, the upper bound for the subgraph induced by {0, 1, 2, 3, 4, 5} obtained in the second iteration of Alg. 1 (Fig. 2(b)) is 2, whereas the upper bound for the same subgraph is 3 in second optimization subproblem (Fig. 3(b)). On the other hand, the choice of the greatest vertex in line 5 of Alg. 2, complementary to the choice of the smallest one in Alg. 1, tends to generate better lower bounds faster. One example occurs in figures 2(b) and 3(b), in which cases the lower bounds are 2 and 3, respectively. S = R = 4 6 7 8 0 1 2 3 5 After maxPartiteSubgraph(G, {0 -- 8}, ∅, 2) (a) First optimization subproblem. Vertex selected is 9. State attained after call optimize(G, {0, 8}, 1). At the end, M AX = 2. S = R = After maxPartiteSubgraph(G, {4, 6, 7}, {0 -- 3, 5}, 1) 7 2 0 1 6 3 4 5 optimization (b) Second tex selected is 8. optimize(G, {1, 2, 4, 7}, 1). At the end, M AX = 3. Ver- State attained after call subproblem. S = R = 0 1 2 3 4 5 6 After maxPartiteSubgraph(G, ∅, {0 -- 6}, 1) optimization (c) Third tex selected is 7. optimize(G, {2, 3, 6}, 1). At the end, M AX = 4. Ver- State attained after call subproblem. Figure 3: Execution of Alg. 2 corresponding to the call optimize(G, V, 0), where G is the graph of Fig. 1. Decision subprolem solved New solution found M AX incremented by {0, 8} = {0, 1, 2, 3, 4, 5, 6, 7, 8} ∩ N (9) {1, 2, 4, 7} = {0, 1, 2, 3, 4, 5, 6, 7} ∩ N (8) {2, 3, 6} = {0, 1, 2, 3, 4, 5, 6} ∩ N (7) {0, 9} {1, 2, 8} {2, 3, 6, 7} 2 1 1 Colors constructed by calls to maxPartiteSubgraph: {0, 2, 5}, {1, 3}, and {4, 6} Uncolored vertices: 6, 7, 8 Table 2: Summary of execution at Fig. 3. 4 New Features We give in this section more details on the originalities of Alg. 1 with respect to the original RD algorithm proposed in [24]. As mentioned in the Introduction, some of these new features appear in B&B algorithms in the literature. In subsections 4.1 and 4.2, we give details on how we adapted them to the RD method. 4.1 Bit-Parallelism Exploiting bit-level parallelism in sets encoded as bitmaps is central in our algorithm due to its ability to speedup some operations that are executed very often during the search. Its effectiveness 11 has already been proved in B&B algorithms [19, 22]. In this subsection, we describe the bitmap data structure and the notation adopted for its elementary operations. The application of such operations in our algorithm is left to next subsections. A bitmap Bn is a special encoding of a directly addressed set B ⊆ [n] whose elements are represented as bits in an array. In such an encoding, for every i ∈ [n], bit indexed i in Bn is 1 if and only if i is an element of B. For example, the subset {1, 3, 6} of [8] is encoded as 01010010. Naturally, instead of being viewed as an array of bits, a bitmap is stored as an array of bitmap nodes (or simply nodes), each of the same size (in bits), denoted by w. If we take w = 4 in the previous example, the bitmap consists of an array of two nodes: node of index 0 in the array has value 0101, and the one of index 1 is 0010. Typically, the size w of a node corresponds to the number of bits of a CPU register. We assume that w is a power of 2 (which is a reasonable assumption since it equals 32, 64, 128, 256, or 512 in nowadays computers). The size, in nodes, of Bn is ⌈n/w⌉ and accessing an element i of the set stored in Bn implies finding first the correct node and then addressing the exact bit in this node. Formulas of bit displacement allow this: for instance i ≫ log2w gives the node index corresponding to the i's bit in the bitmap. Typical applications of bitmaps occur in problems involving the manipulation of sets of vertices or edges of a graph. In our algorithms, bitmaps are used to store the lines of the adjacency matrix of G. For the sake of notation, the bitmap containing the neighborhood of a vertex v (which is composed by ⌈n/w⌉ nodes) is written neig(G, v). In addition, bitmaps are used to store working sets, as detailed in next subsections. Some of the operations performed on bitmaps involve only one element of the set at hand and cannot benefit from bit-parallelism. Some of them arise in our algorithms, namely: • add(Bn, v): adds the element v < n to bitmap Bn (determine the node containing v and set in this node the corresponding bit to 1). • rem(Bn, v): removes the element v < n from bitmap Bn (determine the node containing v and set in this node the corresponding bit to 0). • fsb(Bn, i, n): returns the smallest element in {i, . . . , n − 1} ∩ B (which corresponds to the index of the least significant bit greater than or equal to i that equals 1 in bitmap Bn). Such an operation is more time consuming with respect to the previous ones since it could incur a search in several nodes of the bitmap. The search in a node e is done by means of the special function lsb(e) returning the least significant bit of node e (a negative number is returned if the value of e is zero). In many nowadays processors, such a function is provided by the assembler set of instructions. For details on efficient implementations of lsb(e), we refer the reader to [19] and references therein. Bit-parallelism is particularly effective in classical set operations that occur often in our algorithm. The notation for these operations is the following: • inter(Bn, B′ n, n): the intersection of the two bitmap encoded sets B and B′ is computed (by making a logical & on each pair of corresponding nodes of Bn and B′ n) and returned. • diff(Bn, B′ n, n): the difference B \ B′ of two bitmap encoded sets is computed (by making the call inter(Bn, ¯B′ n, n)) and returned. 12 4.2 Upper Bounds by Vertex Coloring We have studied two different partial coloring heuristics to implement the generic function max- PartiteSubgraph in our algorithm. Their descriptions and bit-parallel implementations are given below. Both are direct adaptations of greedy heuristics used in B&B algorithms like [19, 11, 13]. 4.2.1 Greedy Coloring This first heuristic is the adaptation of the very classical and simple greedy heuristic where the vertices are considered sequentially, each vertex being colored with the smallest possible color. However, two characteristics of our implementation depicted in Alg. 3 have to be mentioned. First, the coloring is done by colors, as in [20], and not by vertices as in classical implementations of this heuristic ([11] for instance). The final coloring is the same but this approach is better suited to bit-parallelism. Second, bit-parallelism is exploited in the set operations at lines 4 (copy of a set) and 7 (set difference). Also, vertices still candidates for the current color d′ are enumerated in an increasing order of vertex indices by the use of function fsb (called at lines 5 and 11). Algorithm 3 Bit-parallel greedy coloring heuristic d′ ← 0 while d′ < d and R 6= ∅ do S ← a copy of R v ← fsb(S, 0, n) while v ≥ 0 do 1: function greedyColoring(G, S, R, d) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: S ← diff(S, neig(G, v), n) rem(S, v) rem(R, v) add(C, v) v ← fsb(S, v + 1, n) 12: d′ ← d′ + 1 4.2.2 Recoloring mcsColoring is a method to improve a greedy coloring successfully employed in [13]. The idea is to try to assign a lower color to nodes whose initial color is greater than a given value (based on the value of the maximum clique found so far). In our case, this can be done by applying first the function greedyColoring and then trying to give one of the d first colors to the remaining nodes, belonging to R at the end of Alg. 3. To do so, iteratively for each v ∈ S we search for a color i ∈ [d] such that v has only one neighbour -- say u -- in the corresponding color class (it has at least one neighbour, otherwise v would have been colored with color i). If such a color does not exist, we skip the current vertex v and go to the next one in S. Otherwise, N (v) ∩ R[i] = {u} and u has at least one neighbor in every color smaller than i. Thus, we search for a color j, i < j < d, that could accommodate u. If such a color is found, move u to color j and v to color i and insert v in S. So, the number of vertices colored (in one of the d first colors) has been increased. We do not detail the algorithm but, again, the operations fsb, add, rem, and inter have to be applied allowing to benefit from bit parallelism. 13 4.3 Recursive Russian Dolls Searches Another originality of Alg. 1 is that each decision subproblem is solved itself with the same principles of the RD method in function decide specified in Subsection 2.1 and detailed in Alg. 4. In special, at line 4, a partial (ℓ − 1)-coloring of G[S] is performed (moving the colored vertices from S to R). If G[S] admits an (ℓ − 1)-coloring (i.e., S = ∅ after this call), then it can be concluded that the decision subproblem at hand is a "no" subproblem without any recursive call. Otherwise, if S 6= ∅ after line 4, then R is the set of vertices pruned by the pruning rule. In this case, the vertices that remain in S are the candidates used to generate the recursive calls. So, at each iteration of the loop starting at line 5, a vertex v is chosen from the set of remaining vertices to be added to R and a recursive call looks for a clique of size (ℓ − 1) on G[R ∩ N (v)]. If such a clique is found, then v is added to this clique and the function returns TRUE. If not, the procedure is repeated until there are no vertices left in S. Algorithm 4 Decision subproblem if S = ∅ then R ← ∅ maxPartiteSubgraph(G, S, R, ℓ − 1) while S 6= ∅ do v ← fsb(S, 0, n) newS ← inter(R, neig(G, v), n) if decide(G, newS, ℓ − 1, Cq) then 1: function decide(G, S, ℓ, Cq) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: add(Cq, v) return TRUE add(R, v) rem(S, v) 13: return TRUE if ℓ = 0, and FALSE otherwise 4.4 Fiding Good Solutions Faster The effectiveness of Alg. 1 depends on the number of executions of line 8 of Alg. 4 or, equivalently, the number of recursive calls to function decide when exploring the generated dolls. In our implementation, we adopt the following strategy to try to reduce this number of recursive calls. Let us consider that a doll, say Gi, is generated at line 5 of Alg. 1. Also, let a recursive call in the search associated with Gi be characterized by a pair (Cq, newS) of a clique Cq of Gi and a set newS ⊆ Vi of candidates. Since ω(Gi) ≤ M AX + 1, the search in Gi can be interrupted at any point if a better clique of G, i.e. a clique of size at least M AX + 1, exist. For the purpose of possibly interrupting the search in Gi, we perform calls to extendClique(G, newS ∪ (V \ Vi), Cq) to some selected pairs (Cq, newS). Such a call occurs just before line 8 of Alg. 4 and determines a clique Cq′ which contains Cq and vertices from newS or V \ Vi. If Cq′ > M AX, then the search in Gi is interrupted and M AX gets Cq′. Otherwise, the search in Gi continues. In order to avoid the overhead of an excessive number of calls to extendClique, they are only performed when Cq ≥ M AX/2. 14 5 Experimental Results In this section we provide and analyze results of extensive computational experiments. Our main goal is to assess whether the Russian Dolls method is effective at exploiting bit-parallelism and partial colorings to accelerate the search for a maximum clique when compared to Branch and Bound. To this end, the computational experiments were carried out with implementations in the C programming language of Alg. 1 and of Alg. 2. They are called RDMC and PBBMC, respectively. The same routines describer in subsections 4.1 and 4.2, for bit-parallel operations and for partial colorings, respectively, are used in both implementations. This methodology aims at avoiding the influence of programming settings (such as the programming language adopted or strategies for memory management) in the analysis of the algorithms. Moreover, we also compare our results with calibration times of previous experiments in the literature. Even being imprecise in nature, this allows checking if the computation times of our implementations are compatible with previous works. Four versions of each implementation have been tested to compare the effectiveness of different partial coloring heuristics and vertex orderings. For each implementation, the notation X/Y stands for the combination coloring heuristic (X) and vertex ordering (Y ). The partial coloring heuristics tested were greedyColoring (X = 1) and MCScoloring (X = 2). At the beginning of each implementation, vertices of G are renumbered according to a specific order. This renumbering fixes the order employed in all executions of partial coloring heuristics and determines the selection strategies. The orders tested were the one given by the MCR initial vertex sorting in [11] (Y = 3) and the one by nonincreasing degree (Y = 4). We do not apply an Iterated Local Search as in [16] since we are interested in studying the behavior of the search procedure, including its ability to find good solutions fast. The results were obtained with experiments on a computer running a 64-bit Linux operating system and gcc as the C compiler (with compiling options -m64 -O3 -msse4.2). All bit-parallel operations are implemented with the Streaming SIMD Extensions Instructions for 128 bits. We ran all of our implementations with DIMACS challenge [26] and BHOSHLIB (in particular, subset frb30-15) [27] benchmark graphs and with randomly generated graphs. For the sake of comparison, experimental results presented in [13] (algorithms MCR and MCS), and [22] (algorithms DEF and RECOL N), were adjusted according to the usual DIMACS challenge methodology [26] (adopted, for instance, in [13]). The average values (T1/T2 and T1/T3) of the user times in [13] (T2) and [22] (T3) with our user times (T1) are shown in Table 3. Instance r100.5 r200.5 r300.5 r400.5 r500.5 T1 - 0.04 0.39 2.41 9.18 T2 [13] T1/T2 T3 [22] T1/T3 0.00 0.042 0.359 2.21 8.47 - 0.95 1.09 1.09 1.08 0.00 0.003 0.203 1.186 4.587 - 13.33 1.92 2.03 2.00 Table 3: User times used to compute the average factors of T1/T2 = 1.09 and T1/T3 = 1.98 with the benchmark program dfmax and the machine benchmark graphs r300.5, r400.5 e r500.5. The selection of benchmark graphs is shown in Table 4. This selection was made avoiding instances with running times too small or too large. In Table 5, the selection of random graphs n p 15 is shown, where n is the number of vertices and p/100 is the probability that each pair of vertices is picked to define an edge. These graphs were generated having between 200 and 15000 vertices, and probabilities from 0.1 up to 0.998. For each configuration, five graphs were generated. Instance brock200 1 brock400 1 brock400 2 brock400 3 brock400 4 brock800 1 brock800 2 brock800 3 brock800 4 C250.9 DSJC1000.5 DSJC500.5 frb30-15-1 frb30-15-2 frb30-15-3 frb30-15-4 n 200 400 400 400 400 800 800 800 800 250 1000 500 450 450 450 450 dens. 0.750 0.750 0.750 0.750 0.750 0.650 0.650 0.650 0.650 0.900 0.500 0.500 0.820 0.820 0.820 0.820 ω(G) 21 27 29 31 33 23 24 25 26 44 15 13 30 30 30 30 Instance frb30-15-5 gen200 p0.9 44 gen400 p0.9 55 gen400 p0.9 65 MANN a27 MANN a45 p hat1000-1 p hat1000-2 p hat1500-1 p hat300-3 p hat700-2 p hat700-3 san400 0.9 1 sanr200 0.9 sanr400 0.5 sanr400 0.7 n 450 200 400 400 378 1035 1000 1000 1500 300 700 700 400 200 400 400 dens. 0.820 0.900 0.900 0.900 0.990 1.000 0.245 0.490 0.253 0.740 0.500 0.750 0.900 0.890 0.500 0.700 ω(G) 30 44 55 65 126 345 10 46 12 36 44 62 100 42 13 21 Table 4: Selected benchmark graphs and their numbers of vertices, densities, and clique numbers. Instance 200 70 200 80 200 90 200 95 300 65 300 70 300 80 300 98 500 50 500 60 500 65 n 200 200 200 200 300 300 300 300 500 500 500 dens. 0.700 0.800 0.900 0.950 0.650 0.700 0.800 0.980 0.500 0.600 0.650 ω(G) 18 25 -- 26 40 60 -- 62 17 20 28 -- 29 116 -- 121 13 17 19 -- 20 Instance 500 70 500 994 1000 30 1000 40 1000 50 1000 998 5000 10 5000 20 5000 30 10000 10 15000 10 n 500 500 1000 1000 1000 1000 5000 5000 5000 10000 15000 dens. 0.700 0.994 0.300 0.400 0.500 0.998 0.100 0.200 0.300 0.100 0.100 ω(G) 22 -- 23 263 -- 270 9 12 15 606 -- 613 7 9 12 7 -- 8 8 Table 5: Selected random graphs n p and their clique numbers. For every configuration, the smallest and greatest clique numbers among the several instances considered are given. Tables 7 (for benchmark graphs) and 8 (for random graphs) show two measures related to the total number of function calls performed to determine the initial coloring of decision (line 4 of Alg. 4) or optimization (line 3 of Alg. 2) subproblems. The first one is its total number (referred to as "all") and the second, the number of calls that result in nonempty sets of uncolored vertices (or, equivalently, the number of nonleaf nodes of the corresponding search tree, referred to as "ne"). Also the CPU user times (in seconds) measured in the experiments are shown in these tables. The rows are sorted in a nondecreasing order of graph density. For each graph, the results with the four possible X/Y configurations (lines 1/3, 1/4, 2/3, 2/4) of each implementation (columns PBBMC or RDMC) are given. Computation times available in [13] and [22] are also presented. In particular, computation times extracted from [22] are the ones corresponding to the versions DEF and RECOL N. The times spent in the renumbering procedure are not included in the reported computation times for our implementations. The symbol in the last column indicates the 16 Instance Time 5000 10 10000 10 15000 10 5000 20 5000 30 1000 998 3 27.39 92.60 9.80 20.39 1.20 Table 6: Cases in which the renumbering time for the MCR order is significant with respect to computation time. relative performance s = (PBBMC computation time/RDMC computation time), as follows: " -- " for s ∈ (0.95, 1.05); "⋆", "⋆⋆", and "⋆⋆⋆" for the cases when s is in the intervals [1.05, 1.5), [1.5, 2), and [2, ∞), respectively; and "◦", "◦◦", and "◦◦◦" for the cases when s belongs to (0.67, 0.95], (0.5, 0.67], and (0, 0.5], respectively. In the results with our implementations, we observe that the order in which the vertices are considered has a great impact on the computation time in several cases. There are two parameters that influences this fact. First, with respect to the renumbering procedure, it has small influence for graphs with density below 75%. However, the ordering of vertices by noincreasing degree tends to perform better than the MCR one with a few exceptions for graphs of density at least 70%. The more remarkable examples are frb30-15-3, frb30-15-4, frb30-15-5, 300 98, 500 994, and 1000 998. In addition, the time spent in the renumbering procedure is negligible for the noincreasing degree order, but this is not the case for the MCR in the cases shown in Table 6. Second, with respect to the coloring heuristic adopted, the version with recoloring is effective in determining better partial coloring and, thus, in reducing the number of explored nodes. This behavior is expected and has already been observed in [13] and [22]. However, even if the recoloring procedure is applied only for the nodes in the M AX/4 highest levels of the search tree (which is the case in our experiments), its computation time is too high if the graph is not sufficiently dense. It is worth remarking that the benefits of the bit-parallelism are severely reduced when the recoloring procedure is used. A time comparison with leading previous works indicates that our implementation of PBBMC is competitive. In almost all cases, the computation times of our implementation are much smaller than the calibrated times from the literature. Even if this comparison suffers from factors due to the programming environment like programming language, compiler, register length, operating system and so on, there are convincing evidences that our implementation is very efficient. The comparison between PBBMC and RDMC is the main objective of the experiments. Since both B&B and RD approaches employ a depth-first strategy, there is a number of explored nodes of the corresponding search trees whose upper bound obtainable with the coloring heuristics are smaller than the optimum value ω(G). This may occur only while the optimum value is not found. For this reason, the smaller is the number of explored nodes until the optimum value is found the better is the relative performance of the algorithm. An evidence of this phenomenon is that there exists a one-to-one correspondence between leading implementations (PBBMC or RDMC) and smaller number of explored subproblems, with the only exception of the version 1/3 for san400 0.9 1. We can observe that C250.9, p hat300-3, p hat700-3, and p hat1000-2 are 17 instances of DIMACS benchmark graphs whose running times of RDMC are significantly faster, which shows its effectiveness when the density is at least 80%. Moreover, there are the special cases gen400 0.9 55 and gen400 0.9 65 for which only RDMC is able to finish execution within the time limit of 18000 seconds. This conclusion is corroborated by the results with random graphs, in which cases the best ratios of improvement are achieved. In spite of this, it should be noticed that brock800 X are cases with large running times for which PBBMC is faster than RDMC. Table 7: Comparison of the number of generated subproblems and run- ning times of our implementations on benchmark graphs. Execution times from [13, 22] are adjusted according to the respective factors listed in Table 3. The computation times for [22] correspond to the version DEF and RECOL N. A blank entry means "information not available." Instance Graph p hat1000-1 p hat1500-1 p hat1000-2 DSJC1000.5 DSJC500.5 p hat700-2 sanr400 0.5 brock800 1 N. of subps ×10−3 PBBMC RDMC 1/3-all 1/4-all 2/3-all 2/4-all 169.0 142.6 176.7 151.9 1056 951.1 1487 1398 22973 14598 39574 24645 76070 70427 79916 74569 1084 846.3 1183 950.5 231.3 162.5 741.3 504.8 250.9 196.9 266.0 212.7 1924228 1327872 2149229 1546067 1/3-ne 1/4-ne 2/3-ne 2/4-ne 38.23 30.01 37.97 30.31 147.8 125.7 220.6 205.9 6017 3305 11504 6402 16081 15331 16289 15578 275.7 193.8 287.7 211.8 57.09 33.74 207.9 123.7 62.11 39.25 63.91 41.94 451474 277754 487116 316388 1/3-all 1/4-all 2/3-all 2/4-all 164.3 139.0 174.1 149.7 1451 1377 1128 1033 13559 8690 20594 12895 74259 68479 82514 76987 1012 779.7 1102 874.3 231.3 162.5 345.5 238.6 236.2 185.3 204.4 164.0 3544359 2488522 3891822 2861531 1/3-ne 1/4-ne 2/3-ne 2/4-ne 36.59 28.70 37.20 29.58 229.1 220.1 175.6 154.6 3451 1899 5789 3217 15532 14768 16969 16257 255.9 173.3 266.0 189.3 57.09 33.74 95.32 57.25 57.57 34.02 44.12 26.29 904788 600952 964831 682516 Computation Time (sec.) PBBMC 1/3 1/4 2/3 2/4 0.141 0.165 0.146 0.171 1.30 1.51 1.70 1.93 77.43 80.93 127.7 133.3 87.69 96.28 92.39 100.9 0.774 0.951 0.846 1.03 0.738 0.839 2.10 2.39 0.175 0.216 0.185 0.230 2975 3073 3367 3491 [13] [22] -- -- 0.506 0.584 5.55 4.25 5.08 5.44 2653 240.8 284.1 245.7 441.4 319.3 295.4 333.8 4.57 3.37 2.13 2.51 48.39 6.10 5.30 5.08 -- -- 0.433 0.520 19390 10188 9303 9497 RDMC 1/3 1/4 2/3 2/4 0.140 0.164 0.147 0.172 1.65 1.87 1.36 1.63 48.64 50.65 71.43 74.08 88.53 96.12 96.76 104.6 0.764 0.915 0.838 0.998 0.769 0.856 1.09 1.23 0.174 0.207 0.159 0.190 5194 5321 5673 5901 -- -- -- -- ◦ ◦ ⋆ ⋆ ⋆⋆ ⋆⋆ ⋆⋆ ⋆⋆ -- -- -- -- -- -- -- -- -- -- ⋆⋆ ⋆⋆ -- -- ⋆ ⋆ ◦◦ ◦◦ ◦◦ ◦◦ 18 Instance Graph brock800 2 brock800 3 brock800 4 sanr400 0.7 p hat300-3 brock200 1 brock400 1 brock400 2 brock400 3 brock400 4 p hat700-3 Table 7: (continued) N. of subps ×10−3 PBBMC RDMC 1/3-all 1/4-all 2/3-all 2/4-all 1654952 1172568 2063020 1522715 1065164 757036 1228395 909264 679270 480282 2242760 1695941 55258 35267 64523 43415 407.5 243.8 762.1 458.6 307.2 181.7 391.0 254.1 178635 104981 203454 127091 70985 45361 122378 82234 127946 75133 168342 105186 60763 35907 68010 43000 166590 92589 306990 174538 1/3-ne 1/4-ne 2/3-ne 2/4-ne 387936 251211 474353 326797 240368 159313 269984 187194 145266 96096 536283 403075 16573 9666 18819 11697 127.4 69.22 258.4 142.7 101.7 54.92 129.2 77.52 53031 29024 58646 34221 20478 12912 35356 23157 39572 21945 50294 29763 17870 9813 19515 11533 42760 21232 84282 43336 1/3-all 1/4-all 2/3-all 2/4-all 4459555 3189649 4460120 3325413 1912833 1299528 1951966 1395656 2833636 1996967 2641180 1935412 55275 35240 67641 45552 154.2 93.78 242.7 149.9 460.0 271.5 482.5 306.3 218166 123173 182531 109789 163578 92685 157131 95762 119906 66964 113363 69544 65939 36382 51187 31194 96961 54109 151510 86027 1/3-ne 1/4-ne 2/3-ne 2/4-ne 1155932 806701 1118033 816754 464107 280306 454995 295756 734803 497131 649939 458605 16581 9656 19935 12459 44.19 22.74 75.07 40.95 160.5 86.64 164.6 95.91 66623 34472 52453 28684 51435 27352 45587 25701 37436 19342 34720 20137 20557 10389 15660 8985 24375 12126 40865 20922 19 Computation Time (sec.) PBBMC 1/3 1/4 2/3 2/4 2599 2679 3200 3338 1719 1774 1973 2068 1171 1200 3315 3475 55.48 64.46 64.34 75.22 0.607 0.758 1.07 1.36 0.214 0.286 0.269 0.365 216.6 237.4 245.5 276.4 92.61 99.46 151.8 166.8 146.8 162.5 193.2 216.9 74.73 81.78 83.50 93.54 649.4 670.1 1173 1231 [13] [22] 17492 9121 8533 8378 11829 6272 5574 5396 8217 4356 3987 3913 413.1 197.2 129.9 139.1 11.77 2.72 1.79 1.94 1.87 0.937 0.495 0.546 1930 755.3 495 501.5 791.3 323.7 210.4 210.8 1308 510.1 332.0 342.9 696.5 270.3 206.5 213.2 74323 2607 2578 2296 RDMC 1/3 1/4 2/3 2/4 6448 6636 6388 6700 2968 3013 3051 3135 4082 4261 3886 4096 57.18 64.91 68.74 79.03 0.260 0.317 0.402 0.489 0.312 0.424 0.328 0.456 265.8 284.9 232.4 251.2 197.2 208.9 198.4 214.9 143.9 153.8 133.6 146.7 81.08 85.50 61.72 67.48 403.3 408.4 622.0 644.7 ◦◦◦ ◦◦◦ ◦◦ ◦◦◦ ◦◦ ◦◦ ◦◦ ◦◦ ◦◦◦ ◦◦◦ ◦ ◦ -- -- ◦ -- ⋆⋆⋆ ⋆⋆⋆ ⋆⋆⋆ ⋆⋆⋆ ◦ ◦ ◦ ◦ ◦ ◦ ⋆ ⋆ ◦◦◦ ◦◦◦ ◦ ◦ -- ⋆ ⋆ ⋆ ◦ -- ⋆ ⋆ ⋆⋆ ⋆⋆ ⋆⋆ ⋆⋆ Instance Graph frb30-15-1 frb30-15-2 frb30-15-3 frb30-15-4 frb30-15-5 sanr200 0.9 C250.9 gen200 p0.9 44 gen400 p0.9 55 gen400 p0.9 65 san400 0.9 1 Table 7: (continued) N. of subps ×10−3 PBBMC RDMC 1/3-all 1/4-all 2/3-all 2/4-all 561752 297794 501918 304227 564777 323762 512867 323978 448754 243166 163409 111497 1781554 998141 1125727 753613 664074 334927 342092 239928 11607 3465 14729 6079 991805 316861 1137737 459609 197.1 66.56 329.5 142.2 -- -- -- -- -- -- -- -- 377.0 52.64 5275 1957 1/3-ne 1/4-ne 2/3-ne 2/4-ne 195532 106338 173172 106217 196671 115112 183336 120593 156829 87841 59582 41752 627424 364563 399811 277360 235213 123988 126432 91485 4539 1439 5710 2367 388397 131958 445366 182377 82.04 30.46 146.1 66.60 -- -- -- -- -- -- -- -- 159.1 26.83 2194 909.4 1/3-all 1/4-all 2/3-all 2/4-all 403867 227680 583655 358024 587228 337370 672671 436865 741805 415467 319548 216080 843752 440556 483553 297691 995328 522826 623818 457648 10304 2993 14528 5874 781787 245797 972115 390771 687.2 205.6 966.1 361.4 2364038 666569 -- -- 536110 116621 -- -- 302.0 28.50 30308 5088 1/3-ne 1/4-ne 2/3-ne 2/4-ne 141579 81421 205002 128089 205260 120645 240659 162446 268482 156231 121538 84317 287111 153258 163851 103577 360589 198063 236143 177749 3998 1233 5683 2325 302033 100860 378289 154130 286.7 93.02 427.7 167.3 910227 261728 -- -- 193972 44894 -- -- 83.82 9.85 11794 2170 Computation Time (sec.) RDMC PBBMC 1/3 1/3 1/4 1/4 2/3 2/3 2/4 2/4 727.8 970.4 639.4 809.7 1057 899.3 961.4 824.4 1039 967.5 899.1 865.0 1193 897.5 1052 810.9 1282 779.7 1028 652.5 557.2 294.2 482.2 276.3 1540 2961 1259 2548 901.6 1905 789.2 1746 1754 1170 1329 897.5 1075 601.5 963.2 546.5 13.18 14.69 12.28 13.67 18.34 18.22 20.66 20.76 1183 1240 1032 1271 1303 1474 1553 1666 0.976 0.259 0.891 0.218 1.39 0.432 1.22 0.437 6289 > 18000 3691 > 18000 > 18000 > 18000 > 18000 > 18000 1527 > 18000 > 18000 749.1 > 18000 > 18000 > 18000 > 18000 1.00 0.312 71.00 32.82 0.745 0.340 13.36 8.58 [13] [22] -- -- 2361 3057 -- -- 2725 2102 -- -- 1551 991.3 -- -- 4694 3263 -- -- 3412 2166 315.0 44.69 27.16 21.60 48193 3550 2361 1964 5.87 0.512 0.766 0.493 6373176 63689 -- -- -- 165240 -- -- 3.70 0.109 60.44 15.54 ⋆ ⋆ ◦ ◦ ◦ -- ◦ ◦ ◦◦ ◦◦ ◦◦ ◦◦ ⋆⋆ ⋆⋆⋆ ⋆⋆⋆ ⋆⋆⋆ ◦◦ ◦ ◦◦ ◦◦ ⋆ ⋆ -- -- -- ⋆ ⋆ ⋆ ◦◦◦ ◦◦◦ ◦◦◦ ◦◦◦ ⋆⋆⋆ ⋆⋆⋆ -- -- ⋆⋆⋆ ⋆⋆⋆ -- -- ◦ ⋆ ◦◦◦ ◦◦◦ 20 Instance Graph MANN a27 MANN a45 Table 7: (continued) N. of subps ×10−3 PBBMC RDMC 1/3-all 1/4-all 2/3-all 2/4-all 37.90 8.92 37.90 8.92 2952 242.9 2952 242.9 1/3-ne 1/4-ne 2/3-ne 2/4-ne 18.30 4.67 18.30 4.67 1081 118.7 1081 118.7 1/3-all 1/4-all 2/3-all 2/4-all 40.40 9.94 40.40 9.94 3827 452.9 3827 452.9 1/3-ne 1/4-ne 2/3-ne 2/4-ne 19.39 5.32 19.39 5.32 1485 225.6 1485 225.6 Computation Time (sec.) PBBMC 1/3 1/4 2/3 2/4 0.194 0.123 0.178 0.142 71.05 18.40 63.46 18.10 [13] [22] 2.72 0.872 0.453 0.310 3368 306.2 220.7 53.16 RDMC 1/3 1/4 2/3 2/4 0.213 0.139 0.198 0.163 94.25 31.73 84.82 39.18 ◦ ◦ ◦ ◦ ◦ ◦◦ ◦ ◦◦◦ Table 8: Comparison of the number of generated subproblems and run- ning times of our implementations on benchmark graphs. Execution times from [13, 22] are adjusted according to the respective factors listed in Table 3. The computation times for [22] correspond to the version DEF and RECOL N. A blank entry means "information not available." Instance Graph 5000 10 10000 10 15000 10 5000 20 1000 30 5000 30 N. of subps ×10−3 PBBMC RDMC 1/3-all 1/4-all 2/3-all 2/4-all 522.8 521.9 532.4 531.4 4707 4645 4833 4778 20829 18372 21468 19115 29361 28493 29663 28825 328.9 289.5 345.5 308.5 1229261 1104626 1268906 1151697 1/3-ne 1/4-ne 2/3-ne 2/4-ne 9.95 9.86 10.91 10.80 673.4 629.4 688.9 650.5 2648 1825 2631 1857 1657 1526 1605 1481 51.80 42.00 50.80 42.14 142458 114531 140585 115171 1/3-all 1/4-all 2/3-all 2/4-all 542.7 542.0 555.9 555.3 5159 5128 5056 5014 20553 18072 22900 20783 30267 29571 31406 30539 387.7 343.6 396.4 355.4 1355238 1262710 1354901 1258607 1/3-ne 1/4-ne 2/3-ne 2/4-ne 8.77 8.73 10.72 10.66 832.3 812.7 769.4 740.1 3106 2369 3290 2711 1705 1582 1708 1584 61.98 52.08 59.59 50.57 159621 141777 152294 133535 21 Computation Time (sec.) PBBMC RDMC 1/3 1/4 2/3 2/4 1.23 1.25 1.26 1.29 21.92 22.04 22.00 22.15 116.2 116.5 123.3 123.7 67.16 70.12 70.07 72.86 0.313 0.358 0.320 0.364 3538 3622 3607 3696 1/3 1/4 2/3 2/4 1.22 1.24 1.25 1.27 21.84 21.98 22.34 22.50 121.0 120.3 124.0 123.6 66.75 69.22 68.39 70.74 0.273 0.316 0.286 0.328 3335 3409 3479 3552 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ◦ ◦ ◦ ◦ ◦ ◦ -- -- [13] [22] 5.77 3.59 2.89 3.28 109 65.40 49.85 51.59 556.9 356.4 284.3 290.2 214.7 150.4 167.7 186.8 -- -- 0.986 1.12 9448 6341 -- -- Instance Graph 1000 40 500 50 1000 50 500 60 300 65 500 65 300 70 500 70 200 80 300 80 200 90 Table 8: (continued) N. of subps ×10−3 PBBMC RDMC 1/3-all 1/4-all 2/3-all 2/4-all 3727 3110 3908 3304 949.9 738.9 968.8 769.7 75966 70375 79196 73931 11912 8649 13189 9861 1205 836.8 1397 1008 65250 50299 72288 57809 3726 2466 3881 2660 492014 334038 574019 412843 1187 619.0 1469 833.0 135194 69045 169699 95146 17527 5738 22919 9620 1/3-ne 1/4-ne 2/3-ne 2/4-ne 768.7 494.0 777.7 520.4 238.7 162.3 232.3 162.6 16108 15366 16216 15515 3134 1973 3363 2216 360.6 224.5 405.3 264.4 17831 14163 19074 15643 1152 720.3 1156 732.4 143505 97140 162193 117343 422.3 208.6 511.8 274.4 46638 23123 57512 31331 6956 2407 9091 3885 1/3-all 1/4-all 2/3-all 2/4-all 3699 3059 3906 3289 849.5 653.1 973.1 768.0 74069 68292 76319 70916 11318 8140 12640 9378 1104 757.9 1318 942.9 62803 47488 72730 57619 3067 1925 4234 2917 465416 312075 536902 381648 1172 602.5 1458 820.7 107192 52842 152912 83660 13913 4493 20974 8772 1/3-ne 1/4-ne 2/3-ne 2/4-ne 776.0 497.8 794.6 538.8 211.9 136.2 236.5 163.1 15553 14806 15397 14683 2965 1803 3216 2063 325.9 197.8 379.4 242.4 17193 13239 19320 15642 932.2 519.3 1284 831.1 135411 89662 151032 107110 424.5 207.3 516.2 275.8 36505 17118 51628 27077 5501 1879 8393 3573 22 Computation Time (sec.) PBBMC RDMC 1/3 1/4 2/3 2/4 3.78 4.14 3.98 4.36 0.644 0.771 0.731 0.874 87.25 95.10 90.52 98.36 10.32 12.06 11.51 13.47 0.935 1.09 1.05 1.29 62.16 71.74 71.68 82.29 2.67 3.25 3.58 4.39 512.1 582.6 594.2 671.1 0.976 1.22 1.20 1.55 120.7 132.8 170.4 192.6 17.59 17.88 26.33 30.39 1/3 1/4 2/3 2/4 3.74 4.21 3.91 4.40 0.686 0.838 0.711 0.868 87.07 95.01 91.14 99.12 10.42 12.55 11.57 13.90 0.931 1.15 1.07 1.33 62.30 73.04 69.25 80.83 3.04 3.79 3.21 4.00 521.4 597.0 610.6 699.2 0.971 1.23 1.18 1.54 143.5 161.3 180.1 206.7 21.03 21.89 27.85 32.52 -- -- -- -- ⋆ ⋆ -- -- -- -- -- -- -- -- -- -- -- ⋆ -- -- -- -- -- -- ⋆ ⋆ ◦ ◦ -- -- -- -- -- -- -- -- ⋆ ⋆ ⋆ ⋆ ⋆ ⋆ ⋆ ⋆ [13] [22] 17.54 14.38 12.33 13.93 3.92 3.05 1.75 2.05 430.5 316.1 294.8 326.3 68.67 43.60 28.96 32.74 -- -- -- -- -- -- -- -- 25.07 13.08 7.04 7.88 3562 1677 1427 1417 13.40 4.90 2.59 2.75 1377 429.4 296.6 290.8 705.2 80.66 51.89 41.38 Table 8: (continued) Instance N. of subps ×10−3 PBBMC RDMC Graph 200 95 300 98 500 994 1000 998 1/3-all 1/4-all 2/3-all 2/4-all 13572 2811 13901 4563 207249 16007 181164 36249 9999 140.9 21386 710.0 5002 9.61 13315 185.8 1/3-ne 1/4-ne 2/3-ne 2/4-ne 6072 1429 6515 2249 101342 9236 97100 21256 5460 88.76 15619 512.7 3186 7.40 10803 151.2 1/3-all 1/4-all 2/3-all 2/4-all 8592 1666 9125 3016 115876 9045 72846 15543 5475 53.91 1055 113.7 2491 6.04 5816 92.64 1/3-ne 1/4-ne 2/3-ne 2/4-ne 3778 836.1 4211 1468 55630 5174 38568 9107 2867 33.06 723.0 81.42 1589 4.49 4841 75.04 Computation Time (sec.) PBBMC RDMC 1/3 1/4 2/3 2/4 15.69 12.06 17.25 19.14 513.8 207.6 329.9 401.8 56.35 7.56 10.73 32.02 78.99 9.46 177.7 337.2 1/3 1/4 2/3 2/4 23.40 18.99 25.00 27.38 868.2 358.0 752.8 926.6 95.88 22.51 191.0 226.7 153.8 12.82 394.5 803.3 [13] [22] 1386 64.31 126.6 70.74 308379 2859 -- -- -- 42.51 -- -- -- 50.14 -- -- ⋆ ⋆⋆ ⋆ ⋆ ⋆⋆ ⋆⋆ ⋆⋆⋆ ⋆⋆⋆ ⋆⋆ ⋆⋆⋆ ⋆⋆⋆ ⋆⋆⋆ ⋆⋆ ⋆ ⋆⋆⋆ ⋆⋆⋆ 6 Concluding Remarks In this paper, we propose a new Russian Dolls Search algorithm, improving another implementation by Ostergard [24] in several directions like the use of approximate colorings for subproblems pruning, an effective use of bit-level parallelism, and the application of an enhanced elimination rule. These improvements allow the algorithm to further reduce the running times of the faster previously published combinatorial algorithms in several instances. The computational experiments aiming at checking whether the proposed algorithm is competitive with respect to the more efficient ones in the literature were accomplished. Results show the effectiveness of the combination of techniques employed in RDMC for hard instances (graphs with a high density). In particular, for graphs of density beyond 0.8, our algorithm is more than twice faster in several graphs tested. These results show that, for some combinatorial optimization problems, the Russian Dolls method can constitute a very interesting alternative to classical Branch and Bound approaches. References [1] I. Bomze, M. Budinich, P. Pardalos, and M. Pelillo. The maximum clique problem, pages 1 -- 74. Kluwer Academic Publishers, Dordrecht, 1999. [2] S. Butenko and W.E. Wilhelm. Clique-detection models in computational biochemestry and genomics. European Journal of Operational Research, 173(1):1 -- 17, 2006. [3] E. Tomita, T. Akutsu, and T. Matsunaga. Biomedical Engineering, Trends in Electronics, Communications and Software, chapter Efficient Algorithms for Finding Maximum and Max- imal Cliques: Effective Tools for Bioinformatics. InTech, 2011. 23 [4] R. Karp. Reducibility among combinatorial problems. In R. E. Miller and J. W. Thatcher, editors, Complexity of Computer Computations, pages 85 -- 103. Plenum, New York, 1972. [5] S. Arora and S. Safra. Probabilistic checking of proofs: a new characterization of NP. Journal of the ACM, 45(1):70 -- 122, 1998. [6] Q. Wu and J.-K. Hao. A review on algorithms for maximum clique problems. European Journal of Operational Research, 242(3):693 -- 709, 2015. [7] E. Balas and C. S. Yu. Finding a maximum clique in an arbitrary graph. SIAM Journal on Computing, 15(4):1054 -- 1068, 1986. [8] R. Carraghan and P.M. Pardalos. An exact algorithm for the maximum clique problem. Operations Research Letters, 9(6):375 -- 382, 1990. [9] C. Mannino and A. Sassano. An exact algorithm for the maximum stable set problem. Journal of Combinatorial Optimization and Applications, 3:243 -- 258, 1994. [10] T. Fahle. Simple and fast: improving a branch-and-bound algorithm for maximum clique. In 10th Annual European Symposium on Algorithms (ESA-02), pages 485 -- 498. Springer, London, 2002. [11] E. Tomita and T. Kameda. An efficient branch-and-bound algorithm for finding a maximum clique with computational experiments. Journal of Global Optimization, 37:95 -- 111, 2007. [12] J. Konc and D. Janezic. An improved branch and bound algorithm for the maximum clique problem. Communications in Mathematical and in Computer Chemistry, 58:569 -- 590, 2007. [13] E. Tomita, Y. Sutani, T. Higashi, S. Takahashi, and M. Wakatsuki. A simpler and faster branch-and-bound algorithm for finding a maximum clique. IEICE Transactions on Informa- tion and Systems, E96-D:1286 -- 1298, 2013. [14] P. Prosser. Exact algorithms for maximum clique: A computational study. Algorithms, 5(4):545 -- 587, 2012. [15] P. Segundo, A. Lopez, and M. Batsyn. Initial sorting of vertices in the maximum clique problem reviewed. In Panos M. Pardalos, Mauricio G.C. Resende, Chrysafis Vogiatzis, and Jose L. Walteros, editors, Learning and Intelligent Optimization, Lecture Notes in Computer Science, pages 111 -- 120. Springer International Publishing, 2014. [16] M. Batsyn, B. Goldengorin, E. Maslov, and P. Pardalos. Improvements to mcs algorithm for the maximum clique problem. Journal of Combinatorial Optimization, 26:1 -- 20, 2013. [17] E. Maslov, M. Batsyn, and P. Pardalos. Speeding up branch and bound algorithms for solving the maximum clique problem. Journal of Global Optimization, 56:1 -- 20, 2013. [18] D. Andrade, M. Resende, and R. Werneck. Fast local search for the maximum independent set problem. Journal of Heuristics, 18(4):525 -- 547, 2012. [19] P. Segundo, D. Rodriguez-Losada, and A. Jimenez. An exact bit-parallel algorithm for the maximum clique problem. Computers & Operations Research, 38:571 -- 581, 2011. 24 [20] P. S. Segundo, F. Matia, D. Rodriguez-Losada, and M. Hernando. An improved bit parallel exact maximum clique algorithm. Optimization Letters, 7(3):467 -- 479, 2013. [21] P. Segundo, D. Rodriguez-Losada, and C. Rossi. Tools in Artificial Intelligence, chapter Recent Developments in Bit-Parallel Algorithms, pages 348 -- 368. InTech, 2008. [22] P. Segundo and C. Tapia. Relaxed approximate coloring in exact maximum clique search. Computers & Operations Research, 44:185 -- 192, 2014. [23] G. Verfaillie, M. Lematre, and T. Schiex. Russian doll search for solving constraint optimization problems. In 13th National Conference on Artificial Intelligence (AIII-96), pages 181 -- 187. AIII Press, Menlo Park, 1996. [24] P. Ostergard. A fast algorithm for the maximum clique problem. Discrete Applied Mathematics, 120:197 -- 207, 2002. [25] E. Tomita and T. Seki. An efficient branch-and-bound algorithm for finding a maximum clique. In 4th international conference on discrete mathematics and theoretical computer science (DMTCS'03), pages 278 -- 289. Springer-Verlag, Berlin, 2003. [26] M. Trick. Second DIMACS Challenge test problems, pages 653 -- 657. in Discrete Math. and Th. Comp. Science. AMS, 1996. ries ftp://dimacs.rutgers.edu/pub/challenge/graph/benchmarks/clique. DIMACS Se- Also available at [27] K. Xu. Problems http://www.nlsde.buaa.edu.cn/ kexu/benchmarks/graph-benchmarks.htm. BHOSLIB: Benchmarks with Hidden Optimum Solutions in Random Graphs. -- Hiding Exact Solutions for Graph at Available 25
1707.04428
3
1707
2019-07-31T01:21:25
Satiation in Fisher Markets and Approximation of Nash Social Welfare
[ "cs.DS", "cs.GT" ]
We study linear Fisher markets with satiation. In these markets, sellers have earning limits and buyers have utility limits. Beyond natural applications in economics, these markets arise in the context of maximizing Nash social welfare when allocating indivisible items to agents. In contrast to markets with either earning or utility limits, markets with both limits have not been studied before. They turn out to have fundamentally different properties. In general, the existence of competitive equilibria is not guaranteed. We identify a natural property of markets (termed money clearing) that implies existence. We show that the set of equilibria is not always convex, answering a question of Cole et al. [EC'17]. We design an FPTAS to compute an approximate equilibrium and prove that the problem of computing an exact equilibrium lies in the intersection of complexity classes PLS and PPAD. For a constant number of buyers or goods, we give a polynomial-time algorithm to compute an exact equilibrium. We show how (approximate) equilibria can be rounded and provide the first constant-factor approximation algorithm (with a factor of 2.404) for maximizing Nash social welfare when agents have budget-additive valuations. Finally, we significantly improve the approximation hardness for additive valuations to \sqrt{8/7} > 1.069 (over 1.00008 by Lee [IPL'17]).
cs.DS
cs
Satiation in Fisher Markets and Approximation of Nash Social Welfare Jugal Garg∗ Martin Hoefer† Kurt Mehlhorn‡ [email protected] [email protected] [email protected] Abstract We study linear Fisher markets with satiation. In these markets, sellers have earning limits and buyers have utility limits. Beyond natural applications in economics, these markets arise in the context of maximizing Nash social welfare when allocating indivisible items to agents. In contrast to markets with either earning or utility limits, markets with both limits have not been studied before. They turn out to have fundamentally different properties. In general, existence of competitive equilibria is not guaranteed. We identify a natural property of markets (termed money clearing) that implies existence. We show that the set of equilibria is not always convex, answering a question of [15]. We design an FPTAS to compute an approximate equilibrium and prove that the problem of computing an exact equilibrium lies in the intersection of complexity classes PLS and PPAD. For a constant number of buyers or goods, we give a polynomial- time algorithm to compute an exact equilibrium. We show how (approximate) equilibria can be rounded and provide the first constant-factor approximation algorithm (with a factor of 2.404) for maximizing Nash social welfare when agents have budget-additive valuations. Finally, we significantly improve the approximation hardness for additive valuations to p8/7 > 1.069 (over 1.00008 in [38]). 1 Introduction The Fisher market model was introduced by Irving Fisher in 1891 [8], and it has been a prominent approach to study market properties ever since. A Fisher market consists of a set of buyers and a set of divisible goods. Buyers come to the market with money and have utility functions over allocations of goods. We assume that each good is brought by a seller and comes in unit supply. Given prices of goods, each buyer demands a bundle of goods that maximizes her utility. In a market equilibrium, the prices are such that all goods are fully sold. Market equilibrium is a central solution concept in economics that has found many surprising applications even in non-market settings, which do not involve an exchange of money. The reason is that market equilibria exhibit remarkable fairness and efficiency properties -- the most prominent example is the popular fairness notion of competitive equilibrium with equal incomes (CEEI) [42]. In a linear Fisher market model, each buyer has a linear utility function. Linear market models have been extensively studied since 1950s [25, 28]. Recently, two natural generalizations of linear Fisher markets, based on satiation, are introduced to model real-life preferences. In these models either i) buyers have utility limits or ii) sellers have earning limits. In the first model, each buyer has an upper limit on the amount of utility that they want to derive. Each buyer spends the least amount of money to purchase a bundle of goods that maximizes their utility up to the limit. She takes back any unused part of her money. These utility functions with limits are also known as budget-additive utility functions, which arise naturally in cases where agents ∗University of Illinois at Urbana-Champaign. Supported by NSF CRII Award 1755619. †Institut fur Informatik, Goethe-Universitat Frankfurt/Main ‡Max-Planck-Institut fur Informatik 1 have an intrinsic upper bound on their utility. For example, if the goods are food and the utility of a food item for a particular buyer is its calorie content, calories above a certain threshold do not increase the utility of the buyer. In addition, there are a variety of further applications in adword auctions and revenue maximization problems; see [6] for details. Equilibrium in this model always exists and can be captured by a convex program [15, 6], and there is a combinatorial polynomial-time algorithm to find it [6]. In the second model, each seller has an upper limit on the amount of money that they want to earn. Each seller sells the least amount of their good to earn the maximum amount of money up to the limit. He takes back any unsold portion of the good. This is a natural property in many settings, e.g., when sellers have revenue targets; see [15] for further applications. Equilibrium in this model may not always exist. However, a necessary and sufficient condition for the existence, a convex programming formulation, and combinatorial polynomial-time algorithms for computation of equilibrium when it exists have been obtained [15, 7]. The natural generalization of the two models, where both buyers and sellers have limits, was only briefly introduced in [15]. The authors posed an intriguing open question of obtaining a convex programming formulation for equilibria in this model. Markets with both utility and earning limits are the main subject of our paper. We study markets of this class that satisfy the sufficient condition for existence in the context of earning limits. In this class of markets, we show that the set of equilibria can be non-convex, thereby answering the question of [15]. We design an FPTAS to compute an approximate equilibrium and prove that the problem of computing an exact equilibrium lies in the intersection of the complexity classes PLS (Polynomial Local Search) and PPAD (Polynomial Parity Arguments on Directed Graphs). For a constant number of buyers or goods, we give a polynomial time algorithm to compute an exact equilibrium. To the best of our knowledge, this is the first market equilibrium problem which lies in PPAD ∩ PLS and for which no polynomial-time algorithm is known. Beyond the economic interest in modeling buyers and sellers' preferences, generalized Fisher markets have also found further applications, especially for approximating the maximum Nash social welfare when allocating indivisible items to a set of agents. The Nash social welfare is defined as the geometric mean of agents' valuations, which provides an interesting trade-off between the extremal objectives of social welfare and max-min welfare. In social welfare, the objective is to maximize the sum of valuations, while in max-min welfare, the objective is to maximize the minimum of valuations. The Nash social welfare objective has been proposed in the classic game theory literature by Nash [43] when solving the bargaining problem. It is closely related to the notion of proportional fairness studied in networking [37]. Nash social welfare satisfies a set of desirable axioms such as independence of unconcerned agents, the Pigou-Dalton transfer principle, and independence of common utility scale (see, e.g., [36, 41]). The latter implies that, in contrast to both social welfare and max-min fairness, it is invariant to individual scaling of each agent valuation with a possibly different constant factor. The problem of maximizing the Nash social welfare objective is known to be APX-hard [38], even for additive valuations. As a remarkable result, Cole and Gkatzelis [16] gave the first constant-factor approximation algorithm for additive valuations. The constant was subsequently improved to 2 [15]. The algorithm computes and rounds an equilibrium of a Fisher market where sellers have earning limits. Moreover, the approach has been extended to provide a 2-approximation in multi-unit markets with agent valuations, which remain additive-separable over items [7], but might be concave in the number of copies received for each item [2]. In this paper, we show that (approximate and exact) market equilibria that are computed by our algorithms can be rounded to give the first constant-factor approximation algorithm for maximizing the Nash social welfare when agents have budget-additive valuation functions. These are a class of non-separable submodular valuation functions. The analysis of budget-additive valuations significantly advances our understanding beyond additive and towards submodular ones. Moreover, budget-additive valuations are of interest in a variety of applications, most prominently in online advertising [40, 39]. 2 They have been studied frequently in the literature, e.g., for offline social welfare maximization [3, 4, 49, 12, 35], online algorithms [9, 21], mechanism design [10], Walrasian equilibrium [47, 26], and market equilibrium [6, 15]. Finally, we also strengthen the existing hardness results for approximating Nash social welfare. We provide a new inapproximability bound of 1.069 that applies even in the case of additive valuations. This significantly improves the constant over 1.00008 in [38]. 1.1 Contribution and Techniques Money-Clearing Markets and an FPTAS We study Fisher markets with additive valuations that have earning and utility limits. In markets with utility limits, a market equilibrium always exists. For markets with earning limits, equilibria exist if and only if the market satisfies a natural condition on budgets and earning limits (which we term money clearing). This condition holds, in particular, for all market instances that arise in the context of computing approximate solutions for the Nash social welfare problem. In both markets models with either earning or utility limits, the set of equilibria is always convex. For both earning and utility limits, we also concentrate on markets with the money-clearing con- dition, which we show is sufficient (but not necessary) for the existence of an equilibrium. We prove that the set of market equilibria can be non-convex. Hence, in contrast to the above cases, the toolbox for solving convex programs (e.g., ellipsoid [15] or scaling algorithms [16, 6]) is not directly applicable for computing an equilibrium. Our main result is a new algorithm to compute an approximate equilibrium. Based on a constant ε > 0, it perturbs the valuations and rounds the parameters vij up to the next power of (1 + ε). Then it computes an exact equilibrium of the perturbed market in polynomial time, which represents an approximate equilibrium in the original market. This yields a novel FPTAS for markets with earning and utility limits. We note that the non-convexity of equilibria also applies to perturbed markets, which is surprising since we show an exact polynomial-time algorithm for computing an equilibrium. To compute an exact equilibrium in the perturbed market, we first obtain an equilibrium (prices p, allocation x) of a market that results from ignoring all utility limits [15, 7]. This is not an equilibrium of the market with both limits, because some buyers may be overspending. Let the surplus of a buyer be the money spent minus the money needed to earn the optimal utility, and similarly let the surplus of a good be the target earning minus the actual earning. Let S be the set of buyers who have positive surplus at prices p. Our idea is to pick a buyer, say k, in S and decrease the prices of goods in a coordinated fashion. The goal is to make k's surplus zero while maintaining the surpluses of all goods and all buyers not in S to be zero. We show that after a polynomial number of iterations of price decrease, either the surplus of buyer k becomes zero or we discover a good with price 0 in equilibrium. Picking a particular buyer is crucial in the analysis, because we rely on this buyer to show that a certain parameter strictly decreases. This implies substantial price decrease of goods and polynomial running time. Complexity of Exact Equilibria In addition to the FPTAS, we examine the complexity of com- puting an exact equilibrium in money-clearing markets. We show that this problem lies in PPAD ∩ PLS. For membership in PLS we first design a finite-time algorithm to compute an exact equilibrium. We define a finite configuration space such that the algorithm proceeds through a sequence of configura- tions. We show that configurations in the sequence do not repeat and the algorithm terminates with an equilibrium. By defining a suitable potential function over configurations, we show that the problem is in PLS. As a refinement, for a constant number of buyers or sellers, we show that the number of configurations is polynomially bounded using a cell decomposition technique. This implies that our algorithm computes an equilibrium in polynomial time if the number of buyers or goods is constant. 3 For membership in PPAD we first derive a formulation as a linear complementarity problem (LCP). It captures all equilibria, but it also has non-equilibrium solutions. To discard the non-equilibrium solutions, we incorporate a positive lower bound on several variables. This turns out to be a non- trivial adjustment, because a subset of prices may be zero at all equilibria, so we must be careful not to discard equilibrium solutions. Then, we suitably add an auxiliary variable to the LCP and apply Lemke's algorithm [17]. Under the money clearing condition, we can show that the algorithm is guaranteed to converge to an exact equilibrium. This, with a result of Todd [50], proves the problem lies in PPAD. Approximating Nash Social Welfare Finally, we consider the problem of maximizing Nash social welfare when allocating indivisible items to agents. We design an approximation algorithm that com- putes an equilibrium in a money-clearing market and rounds it to an integral allocation. Here we study the problem for agents with budget-additive valuation functions. For these instances, money-clearing markets with earning and utility limits represent a natural fractional relaxation. We use our algorithms to compute an exact equilibrium (in the FPTAS with respect to perturbed valuations). Given an exact equilibrium (with respect to either perturbed or original valuations), we provide a rounding algorithm that turns the fractional allocation into an integral one. While the algorithm exploits a tree structure of the equilibrium allocation as in [16], the rounding becomes much more challenging, and we must be careful to correctly treat agents that reach their utility limits in the equilibrium. In particular, we first conduct several initial assignment steps to arrive at a solution where we have a set of rooted trees on agents and items, and each item j has exactly one child agent i who gets at least half of its fractional valuation from j. In the main step of the rounding algorithm, we need to ensure that the root agent r receives one of its child items. Here we pick a child item j that generates the most value for r. A problem arises at the child agent i of j, since r receiving j could decrease i's valuation by a lot more than a factor of 2. Recursively, we again need to enforce an allocation for the root agent, thereby "stealing" fractional value from one of its grandchildren agents. This approach may seem hopeless to yield any reasonable approximation guarantee, but we show that overall the agents only suffer by a small constant factor. Our analysis of this rounding procedure provides a lower bound on the Nash social welfare obtained by the algorithm, which is complemented with an upper bound on the optimum solution. Both bounds crucially exploit the properties of agents (goods) that reach the utility (earning) limits in the market equilibrium. These bounds imply an approximation factor of 2e1/(2e) < 2.404. Since the equilibrium conditions apply with respect to perturbed valuations, we obtain a (2e1/(2e) + ε)-approximation in polynomial time, for any constant ε > 0. In terms of lower bounds, we strengthen the inapproximability bound to p8/7 > 1.069. Our improvement is based on a construction for hardness of social welfare maximization for budget-additive valuations from [12]. For the Nash social welfare objective, we observe how to drop the utility limits and apply the construction even for additive valuations. A preliminary version of this paper appeared at the 29th ACM-SIAM Symposium on Discrete Algorithms (SODA 2018) [29]. 1.2 Related Work Market Equilibria The problem of computing market equilibria is an intensely studied problem, so we restrict to previous work that appears most relevant. For linear Fisher markets, equilibria are captured by the Eisenberg-Gale convex program [25]. Later, Shmyrev [48] obtained another convex program for this problem. Cole et al. [15] provide a dual connection between these and other convex programs. A combinatorial polynomial-time algorithm for computing an equilibrium in this model was obtained by Devanur et al. [22]. Orlin [45] gave the first 4 strongly polynomial-time algorithm using a scaling technique. More recently, V´egh [51] gave another strongly-polynomial algorithm using a different scaling-based algorithm. Fisher markets are a special case of more general Arrow-Debreu exchange markets. There are many convex programming formulations for linear exchange markets; see [20] for details. The first polynomial time algorithm was obtained by Jain [34] based on the ellipsoid method. Ye [52] obtained a polynomial time algorithm based on the interior-point method. The first combinatorial polynomial-time algorithm was developed by Duan and Mehlhorn [24], and it was later improved in [23]. More recently, Garg and V´egh [33] obtained the first strongly polynomial-time algorithm for this problem. Linear Fisher markets with either utility or earning limits were studied only recently [15, 6, 7], and equilibria in these models can be captured by extensions of Eisenberg-Gale and Shmyrev convex programs, respectively. In markets with utility limits, combinatorial polynomial time algorithms are obtained [6, 51], the set of equilibria forms a lattice, and equilibria with maximum or minimum prices can also be obtained efficiently [6]. In markets with earning limits, combinatorial polynomial-time algorithms are obtained in [16, 7]. Any equilibrium can be refined to one with minimal or maximal prices in polynomial time [7]. Nash Social Welfare The Nash social welfare is a classic objective for allocation of goods to agents. It was proposed by Nash [43] for the bargaining problem as the unique objective that satisfies a collection of natural axioms. Since then it has received significant attention in the literature on social choice and fair division (see, e.g. [11, 18, 46, 27] for a subset of notable recent work, and the references therein). For divisible items, the problem of maximizing the Nash social welfare is solved by competitive equilibria with equal incomes (CEEI) [42]. However, CEEI can provide significantly more value in terms of Nash social welfare than optimal solutions for indivisible items. To obtain an improved bound on the indivisible optimum, Cole and Gkatzelis [16] introduced and rounded spending-restricted equilibria, i.e., equilibria in markets with an earning limit of 1 for every good. More generally, equilibria in linear markets with earning limits can be described by a convex program [15] similar to the one by Shmyrev. For indivisible items and general non-negative valuations, the problem of maximizing the Nash social welfare is hard to approximate within any finite factor [44]. For additive valuations, the problem is APX-hard [38], and efficient 2-approximation algorithms based on market equilibrium [16, 15] and stable polynomials [1, 2] exist. These algorithms have been extended to give a 2-approximation also in markets with multiple copies per item [7] and additive-separable concave valuations [2]. Barman et al. [5] introduced another technique based on limited envy and obtained a 1.45-approximation for additive valuations. Very recently, Chaudhury et al. [13] generalized this result to obtain a 1.45- approximation for a common generalization of both budget-additive and additive-separable concave valuations. 1.3 Outline The rest of the paper is structured as follows. We introduce notation and preliminaries in the following Section 2. In Section 3.1 we discuss the existence of market equilibria under the money clearing condition. The FPTAS for perturbed markets is discussed in Section 3.2. The following sections contain our results on computing exact equilibria -- membership in PLS (Section 3.3), the polynomial- time algorithms for a constant number of buyers or goods (Section 3.4), and membership in PPAD (Section 3.5). The rounding algorithm for maximizing the Nash social welfare and the analysis of its approximation factor are presented in Section 4.1. In Section 4.2 we present the improved hardness bound for approximation of Nash social welfare with additive valuations. Finally, we conclude in Section 5 with a discussion of directions for future research. 5 2 Preliminaries In such a market, there is a set B of n buyers Fisher Markets with Earning and Utility Limits and a set G of m divisible goods. Each good is owned by a separate seller and comes in unit supply. Each buyer i ∈ B has a value uij ≥ 0 for a unit of good j ∈ G and an endowment mi ≥ 0 of money. Suppose buyer i receives a bundle of goods xi = (xij)j∈G with xij ∈ [0, 1], then the utility function is budget-additive ui(xi) = min(cid:16)ci,Pj uijxij(cid:17), where ci > 0 is the utility cap. The vector x = (xi)i∈B withPi∈B xij = 1 for every j ∈ G denotes a (fractional) allocation of goods to buyers. For an allocation, we call i a capped buyer if ui(xi) = ci. We also maintain a vector p = (p1, . . . , pm) of prices for the goods. Given price pj for good j, a buyer needs to pay xijpj when getting xij allocation of good j ∈ G. Given a vector of prices p, a demand bundle x∗ i of buyer i is a bundle of goods that maximizes the utility of buyer i for its budget, i.e., x∗ For price vector p and buyer i, we use λi = minj pj/uij and denote by αi = 1/λi the maximum bang- per-buck (MBB) ratio (where we assume 0/0 = 0). Given prices p and allocation x, the money flow fij from buyer i to seller j is given by fij = pjxij. If price pj > 0, then xij uniquely determines fij and vice versa. i ∈ arg maxxinui(xi) Pj pjxij ≤ mio. For the sellers, let xj =Pi xij, then the seller utility is uj(xj, pj) = min(dj, pjxj) = min (dj,Pi fij), where dj > 0 is the earning or income cap. We call seller j a capped seller if uj(xj, pj) = dj. An optimal supply e∗ j allows seller j to obtain the highest utility, i.e., e∗ j ∈ arg max {uj(ej, pj) ej ≤ 1}. We consider three natural properties for allocation and supply vectors: every demand bundle is modest. For capped buyers, a modest bundle of goods xi is such that 1. An allocation xi for buyer i is called modest ifPj uijxij ≤ ci. By definition, for uncapped buyers ci =Pj uijxij. 2. A demand bundle xi is called thrifty or MBB if it consists only of MBB goods: xij > 0 only if uij/pj = αi. For uncapped buyers every demand bundle is MBB. 3. A supply ej for seller j is called modest if ej = min(1, dj /pj). Given a set of prices, a thrifty and modest demand bundle for buyer i minimizes the amount of money required to obtain optimal utility. A modest supply for seller j minimizes the amount of supply required to obtain optimal utility in equilibrium. Our interest lies in market equilibria that have thrifty and modest demands and modest supply. Note that they also emerge when earning and utility caps are not satiation points but limits in the form of hard constraints on the utility in equilibrium (c.f. [15]). Definition 2.1 (Thrifty and Modest Equilibrium). A thrifty and modest (market) equilibrium is a pair (x, p), where x is an allocation and p a vector of prices such that the following conditions hold: (1) p ≥ 0 (prices are nonnegative), (2) ej is a modest supply for every j ∈ G, (3) xj ≤ ej for every j ∈ G (no overallocation), (4) xi is a thrifty and modest demand bundle for every i ∈ B, and (5) Walras' law holds: pj(ej − xj) = 0 for every j ∈ G. Note that in equilibrium, if xj < ej, then pj = 0, due to Walras law. Moreover, we assume that all parameters of the market uij, ci, dj and mi for all i ∈ B and j ∈ G are non-negative integers. Let U = maxi∈B,j∈G{uij, mi, ci, dj } be the largest integer in the representation of the market. Consider the following condition termed money clearing: For each subset of buyers and the goods these buyers are interested in, there must be a feasible allocation of the buyer money that does not violate the earning caps. More formally, let B ⊆ B be a set of buyers, and N ( B) = {j ∈ G uij > 0 for some i ∈ B} be the set of goods such that there is at least one buyer in B with positive utility for the good. 6 Definition 2.2 (Money Clearing). A market is money clearing if ∀ B ⊆ B, Xi∈ B mi ≤ Xj∈N ( B) dj . (1) When there are only earning limits, money clearing is a precise characterization of markets that have thrifty and modest equilibria [7]. For markets with both limits, it is sufficient for existence (see Section 3.1). Perturbed Markets Our FPTAS in Section 3.2 computes a thrifty and modest equilibrium in a perturbed market M. Definition 2.3 (Perturbed Utility, Perturbed Market). For a market M and a parameter ε > 0, the such that perturbed utility of buyer i is given by ui(xi) = Pj uijxij, where uij ∈ {0, (1 + ε)k integer k ≥ 0} (2) The perturbed market M is exactly the market M, in which every buyer i ∈ B has perturbed utilities ui. uij/(1 + ε) ≤ uij ≤ uij, ∀i ∈ B, j ∈ G. In Section 3.2 we observe that an exact equilibrium in M represents an ε-approximate equilibrium for the unperturbed market M. Nash Social Welfare There is a set B of n agents and a set G of m indivisible items, where we assume m ≥ n. We allocate the items to the agents, and we represent an allocation S = (S1, . . . , Sn) using a characteristic vector xS with xS ij = 1 iff j ∈ Si and 0 otherwise. Agent i ∈ B has a value vij ≥ 0 for item j and a global utility cap ci > 0. The budget-additive valuation of agent i for an allocation S of items is vi(xS optimal Nash social welfare, i.e., the optimal geometric mean of valuations i ) = min(cid:16)ci,Pj∈G vijxS ij(cid:17). The goal is to find an allocation that approximates the S Yi∈B max vi(xS i )!1/n . Our approximation algorithm in Section 4 relies on rounding an equilibrium for a linear Fisher market with earning and utility limits. Our rounding algorithm loses a constant factor in the Nash social welfare. More precisely, we round an exact equilibrium of the perturbed market M. The fact that this equilibrium satisfies the properties in Definition 2.1 with respect to perturbed utilities deteriorates the approximation factor only by a small constant (see Section 4.1.3). 3 Computing Equilibria 3.1 Existence and Structure of Equilibria In this section, we briefly discuss existence and structure of thrifty and modest equilibria in markets with utility and earning limits. The set of equilibria in these markets has interesting and non-trivial structure. For markets with utility limits, an equilibrium always exists [6]. For markets with earning limits, an equilibrium may not exist, because uncapped buyers always spend all their money. In these markets, the money-clearing condition is necessary and sufficient for the existence of a thrifty and modest equilibrium [7] (see also [15] for the case that uij > 0 for all i ∈ B, j ∈ G). We observe that in a market M with both limits, money clearing is sufficient but not necessary for the existence of a thrifty and modest equilibrium. Our FPTAS below gives an ε-approximate 7 equilibrium in money-clearing markets, for arbitrarily small ε. Since market parameters are finite integers, for sufficiently small ε this implies existence of an exact equilibrium. This is interesting since the structure of equilibria in such markets can be quite complex. For example, in money-clearing markets M there can be no convex program describing thrifty and modest equilibria. This holds even if we restrict to the ones that are Pareto-optimal with respect to the set of all thrifty and modest equilibria. Equilibria for the corresponding markets without caps, or with either earning or utility caps might not remain equilibria in the market with both sets of caps. Hence, existence of a thrifty and modest equilibrium in money-clearing markets M follows neither from a convex program nor by a direct application of existing algorithms for markets with only one set of either utility or earning caps. The following proposition summarizes our observations. Proposition 3.1. There are markets M with utility and earning limits such that the following holds: 1. M is not money-clearing and has a thrifty and modest equilibrium. 2. M is money-clearing, and the set of thrifty and modest equilibria is not convex. Among these equilibria, there are multiple Pareto-optimal equilibria, and their set is also not convex. 3. For a money-clearing market M and the three related markets -- (1) with only utility caps, (2) with only earning caps, (3) without any caps -- the sets of equilibria are mutually disjoint. Proof. We provide an example market for each of the three properties. Property 1: Consider a linear market with one buyer and one good. The buyer has m1 = 2, utility u11 = 2, and utility cap c1 = 1. The good has earning cap d1 = 1. The unique thrifty and modest equilibrium has price p1 = 2 and allocation x11 = 1/2. Both seller and buyer exactly reach their cap. The active budget ma i = 1 equals the earning cap. Conversely, due to price 2, the supply is 1/2, for which the achieved utility equals the utility cap. Note that the money clearing condition (1) is violated. Property 2: Consider the following example. There are two buyers and two goods. The buyer budgets are m1 = 2 and m2 = 32. The utility caps are c1 = ∞, c2 = 32, the earning caps are d1 = 8, d2 = 26. The linear utilities are given by the parameters u11 = u22 = 32, u12 = 128, and u21 = 2. If we ignore all caps, the unique equilibrium has prices (2, 32) and buyer utilities (32, 32). If we ignore the utility caps and consider only earning caps, the equilibrium prices are (8y, 128y) and buyer utilities are (8/y, 8/y), for y ≥ 1. If we ignore the earning caps and consider only utility caps, the equilibrium prices are (2, x) and buyer utilities are (32, 32), for x ∈ [8, 32]. With all caps, the equilibria form two disjoint convex sets: either prices (2, x) and buyer utilities (32, 32), for x ∈ [8, 26]; or prices (8y, 128y) and buyer utilities (8/y, 8/y), for y ≥ 1. Note that (2, x) for x ∈ (26, 32] are not equilibrium prices, since this would violate the earning cap of seller 2. Observe that there are exactly two Pareto-optimal equilibria: prices (1, 6) (which also represents income for the sellers) and buyer utilities (1, 1); and prices (5, 50) (with income (3, 6) for the sellers) and buyer utilities (1/5, 1/5). The first equilibrium is strictly better for both buyers, the second one strictly better for seller 1. Property 3: Consider the following market with 2 buyers and 2 goods. The buyer budgets are m1 = 100 and m2 = 11. The utility caps are c1 = 0.9, c2 = ∞. The earning caps are d1 = 9, d2 = ∞. The utilities are u11 = u22 = u12 = u21 = 1. If we ignore all caps, the unique equilibrium prices are (55.5, 55.5). If we ignore the buyer caps and consider only seller caps, the unique equilibrium prices are (102, 102). If we ignore the seller caps and consider only buyer caps, the unique equilibrium prices are (10, 10). For both buyer and seller caps, the unique equilibrium prices are (20, 20). 8 Algorithm 1: FPTAS for M with Earning and Utility Caps Input : Market M given by budgets mi, utility caps ci, earning caps dj, utilities uij, ∀i ∈ B, j ∈ G, approximation parameter ε; Output: Equilibrium (x, p) of the perturbed market M 1 Construct M by increasing each non-zero uij to the next-larger power of (1 + ǫ), set U ← maxij uij, and run the rest of the algorithm on M 2 (f , p) ← equilibrium of M when ignoring all utility caps 3 Z ← {i ∈ B s(i) = 0} 4 while Z 6= B do k ← a buyer in B \ Z while (s(k) > 0) and (minj∈G:pj>0 pj > 1/n U n) do // set of zero surplus buyers // s(k) > 0 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 B ← {k} ∪ {i ∈ B i can reach k in the MBB residual graph} G ← {j ∈ G j can reach k in the MBB residual graph} p′ ← p and γ ← 1 Define pj ← γ · pj, ∀j ∈ G, and adjust active prices and budgets accordingly as a function of γ Decrease γ continuously down from 1 until one of these events occurs: Event 1: A new MBB edge appears Event 2: γ = MinFactor(p′, f , B, G, Z) f ← FeasibleFlow(p, Z) if minj:pj>0 pj ≤ 1/n U n then Choose any good ℓ ∈ arg min{pj pj > 0} G ← {ℓ} ∪ {j ∈ G j is connected to ℓ in the MBB graph } B ← {i ∈ B uij > 0 for some j ∈ G} Assign (xi)i∈ B according to f s(i) ← 0, ∀i ∈ B and pj ← 0, ∀j ∈ G Z ← Z ∪ {i ∈ B s(i) = 0} // Algorithm 2 // Algorithm 3 22 Assign xi according to f for all buyers i ∈ B that have not been assigned yet. 23 return (x, p) 3.2 Computing Equilibria in Perturbed Markets In this section, we describe and analyze Algorithm 1, an FPTAS for computing an approximate equi- librium in money-clearing markets M. The input parameters for such a market are uij, mi, ci, dj, ∀i ∈ B, j ∈ G, where uij is the utility derived by buyer i for a unit amount of good j, mi is the budget of buyer i, ci is the utility cap of buyer i, and dj is the earning cap of seller j. For any ε > 0, Algorithm 1 computes an exact equilibrium in a perturbed market M, where we increase every non-zero parameter uij to the next-larger power of (1 + ε). Additional Concepts Our algorithm steers prices and money flow towards equilibrium by moni- toring the surplus of buyers and sellers. Note that a buyer i is capped if miαi ≥ ci. i = min(mi, ci/αi), the active supply of seller j is ea Definition 3.1 (Active Budget, Active Price, Surplus). Given prices p and flow f , the active budget of buyer i is ma j = min(1, dj /pj), and the active price is pa j = pjea i , and the surplus of good j is s(j) = pa j = min(pj, dj). The surplus of buyer i is s(i) = Pj∈G fij − ma j −Pi∈B fij. 9 Algorithm 2: MinFactor Input : Prices p, flow f , set of buyers B, set of goods G, set of zero-surplus buyers Z Output: Minimum price decrease consistent with the input configuration 1 E ← Set of MBB edges at prices p between B and G 2 Gc ← Set of goods from G that are capped at (f , p) 3 Bc ← Set of buyers from B that are capped at (f , p) 4 λi ← mink∈G pk/uik, ∀i ∈ B 5 Set up the following LP in flow variables g and γ: min γ ∀j ∈ Gc ∀j ∈ G \ Gc Pi∈ B gij = dj, Pi∈ B gij = γpj, Pj∈ G gij = γciλi, ∀i ∈ Bc ∩ Z Pj∈ G gij ≥ γciλi, ∀i ∈ Bc \ Z Pj∈ G gij = mi, Pj∈ G gij ≥ mi, ∀i ∈ ( B \ Bc) ∩ Z ∀i ∈ ( B \ Bc) \ Z ∀(i, j) 6∈ E ∀i ∈ B, j ∈ G gij = 0, gij ≥ 0, 6 return Optimal solution γ of above LP Several graphs connected to the MBB ratio are useful here. As argued in [45, 23], we can assume w.l.o.g. that the MBB graph is non-degenerate, i.e., it is a forest. Definition 3.2 (MBB edge, MBB graph, MBB residual graph). Given prices p, an undirected pair {i, j} is an MBB edge if i ∈ B, j ∈ G, and uij/pj = αi. The MBB graph G(p) = (B ∪ G, E) is an undirected graph that contains exactly the MBB edges. Given prices p and money flow f , the MBB residual graph Gr(f , p) = (B ∪ G, A) is a directed graph with the following arcs: If {i, j} is MBB, then (i, j) is an arc in A; if {i, j} is MBB and fij > 0, then (j, i) is an arc in A. Let us also define a reverse flow network N −(p, Z) by adding a sink t to the MBB graph. The network has nodes G ∪ B ∪ {t}, edges (i, t) for i ∈ B \ Z, and the reverse MBB edges (j, i) if (i, j) is an MBB edge. All edges have infinite capacity. The supply at node j ∈ G is pa j , demand at node i ∈ B is ma i . The flow in the network corresponds to money. Given a money flow f in the network N −(p, Z), the surplus of buyer i ∈ B \ Z corresponds to flow on (i, t) i , and demand at node t is Pj pa j −Pi ma s(i) = Xj∈G fij − ma i = fit . Buyers in Z do not have edges to the sink. Hence, their surplus is fixed to 0 at every feasible flow. Algorithm and Analysis Algorithm 1 computes an exact equilibrium of M. For convenience, it maintains a money flow f . For goods with non-zero price, f is equivalent to an allocation x. When the algorithm encounters a set of goods with price 0, the buyers interested in these goods must be capped, and the algorithm determines a suitable allocation for them by solving a system of linear equations. The algorithm first calls a subroutine to compute a market equilibrium ignoring the utility caps of the buyers. Such an equilibrium exists because the market is money-clearing, can be computed in polynomial time [15, 7], and consists of a pair (f , p) of flow and prices such that the outflow of every good j is pa j and the inflow of every buyer i is mi. Given this equilibrium, the algorithm then initializes Z to the set of buyers with surplus zero in (f , p). 10 Algorithm 3: FeasibleFlow Input : Perturbed market M, prices p, and set of zero-surplus buyers Z Output: Feasible flow consistent with the input configuration 1 E ← Set of MBB edges at prices p 2 λi ← mink∈G pk/uik, ∀i ∈ B 3 Bc ← Set of capped buyers at p 4 Gc ← Set of capped goods at p 5 Set up the following feasibility LP in flow variables f : ∀j ∈ Gc ∀j ∈ G \ Gc Pi∈ B fij = dj, Pi∈ B fij = pj, Pj∈ G fij = ciλi, ∀i ∈ Bc ∩ Z Pj∈ G fij ≥ ciλi, ∀i ∈ Bc \ Z Pj∈ G fij = mi, Pj∈ G fij ≥ mi, ∀i ∈ (B \ Bc) ∩ Z ∀i ∈ (B \ Bc) \ Z ∀(i, j) 6∈ E ∀i ∈ B, j ∈ G fij = 0, fij ≥ 0, 6 return Feasible solution f of above LP The following Invariants are maintained during the run of Algorithm 1: • no price ever increases. • if s(i) = 0 for a buyer i, it remains 0. Z is monotonically increasing. • N −(p, Z) allows a feasible flow, i.e., s(i) ≥ 0 for every buyer i ∈ B and s(j) = 0 for every good j ∈ G. More formally, the algorithm uses a descending-price approach. There is always a flow in N −(p, Z) with outflow of a good j ∈ G equal to pa i , and in-flow into buyer i ∈ B \ Z at least ma i . Descending prices imply that if a good (buyer) becomes uncapped (capped), it remains uncapped (capped). j , in-flow into buyer i ∈ B ∩ Z equal to ma The algorithm ends when Z = B, i.e., all buyers have surplus zero, and hence (f , p) is an equilibrium of M. In the body of the outer while-loop, we first pick a buyer k whose surplus is positive. The inner while loop ends when either the surplus of k becomes zero or the minimum positive price of a good, say ℓ, is at most 1/n U n, where U is the maximum parameter value of the perturbed utilities. In the former case, the size of Z increases (in line 21). In the latter case, we obtain a set G of goods connected to ℓ through MBB edges and a set B of buyers who have non-zero utility for some good in G. Since the price of each good in G is so low and their surplus is zero, each buyer in B must be capped. Hence we fix the allocation of buyers in B according to the current money flow f , and set the prices of all goods in G and surplus of all buyers in B to zero. Since the algorithm maintains goods with price 0 and buyers with surplus 0, the inner-while loop is executed at most m + n times. In the body of inner while-loop, we construct the set B of buyers and G of goods that can reach buyer k in the MBB residual graph (see Definition 3.2). We then continuously decrease the prices of all goods in G by a common factor γ, starting from γ = 1. This may destroy MBB edges connecting buyers in B with goods in G \ G. However, by definition of G there is no flow on such edges. For uncapped goods in G (capped buyers in B), this decreases the active price (budget) by a factor of γ. We stop if one of the two events happens: (1) a new MBB edge appears, and (2) γ is equal to the minimum factor possible that allows a feasible flow with the current MBB edges, i.e., in-flow into a good j ∈ G is equal to pa i , and out-flow of a buyer in B \ Z j , out-flow of a buyer in B ∩ Z is equal to ma 11 is at least ma i . While the value of γ for event (1) results from ratios of uij, the value of γ for event (2) is found by Algorithm 2 based on a linear program (LP). Observe that the flow f and γ = 1 are a feasible initial solution for the LP. After the event happened, we update to a new feasible flow f using Algorithm 3. For prices p and the set Z of zero-surplus buyers, the in-flow into a good j ∈ G must be equal to pa j , out-flow of a buyer i , and out-flow of a buyer in B \ Z must be at least ma in Z must be equal to ma i . Algorithm 3 sets up a feasibility LP to find such a feasible flow. Observe that this feasibility set is non-empty due to Event 2. The following lemma is straightforward, we omit the proof. Lemma 3.1. The Invariants hold during the run of Algorithm 1. Next we bound the running time of Algorithm 1. Event 1 provides a new MBB edge between a buyer in B \ B and a good in G. Event 2 restricts the price decrease in γ such that the Invariants are maintained. The event happens only if (1) at the value of γ there is a subset of buyers S ⊆ B such that j , where Γ(S) is the set of goods to which buyers in S have MBB edges, and (2) further decrease of prices would make the total active budget of buyers in S more than the total active prices of Γ(S). This condition would violate the invariant that N −(p, Z) has a feasible flow where the surplus of each good is zero. i =Pj∈Γ(S) pa Pi∈S ma If the subset S is equal to B or S contains buyer k, then the surplus of k in every feasible flow is zero at such a minimum γ, and hence the inner-while loop ends. Otherwise, the MBB edges between buyers in B \ S and goods in Γ(S) will become non-MBB in the next iteration. So in each event of the inner-while loop, either a new MBB edge evolves or an existing MBB edge vanishes. Next, we show that for a given buyer k, the total number of iterations of the inner-while loop is polynomially bounded. For this, we first show that price of a good strictly decreases during each iteration of inner-while loop. Lemma 3.2. In each iteration of inner-while loop, the MBB ratio of buyer k strictly increases. Proof. Each iteration of the inner while-loop ends with one of the two events. Clearly, Event 1 can occur only when the prices of goods in G strictly decrease, and this implies that the MBB of buyer k strictly increases. In case of Event 2, as argued above, there is a subset S ⊆ B of buyers such that i =Pj∈Γ(S) pa j , where Γ(S) is the set of goods to which S have MBB edges. Pi∈S ma If k ∈ S, then s(k) = 0 in this iteration. This implies that Pi∈S ma j at the beginning of this iteration, and since equality emerges, prices must have strictly decreased and the MBB of k strictly increased. i <Pj∈Γ(S) pa If k 6∈ S, then S 6= B and flow on all MBB edges from B \ S to Γ(S) has become zero. Note that there is at least one such edge due to the construction of B and G. Using the fact that there was a j at the beginning of this iteration, we conclude non-zero flow on these edges andPi∈S ma i <Pj∈Γ(S) pa that prices of goods must have strictly decreased and the MBB of k strictly increased. Next we show that the price of a good substantially decreases after a certain number of iterations. For this, we partition the iterations into phases, where every phase has n2 iterations of the inner while-loop. Lemma 3.3. Let p and p′ be the prices at the beginning and end of a phase, respectively. Then p′ j ≤ pj, ∀j ∈ G, and there exists a good ℓ such that p′ j ≤ pj, ∀j ∈ G. For the second part, note that B always contains Proof. Due to Lemma 3.1, we have p′ buyer k during an entire run of inner while-loop. Since prices monotonically decrease, the MBB αk of buyer k monotonically increases. Further, if there is a MBB path from buyer k to a good j, then we have, for some (i1, j1), . . . , (ia, ja), (i′ ℓ ≤ pℓ/(1 + ε). b) and an integer c 1), . . . , (i′ 1, j′ b, j′ αkpj = Q ui1j1 . . . uiaja . . . ui′ bj′ 1j′ 1 b Q ui′ 12 = (1 + ε)c . In each iteration, either a new MBB edge evolves or an existing MBB edge vanishes. When a new MBB edge evolves, a new MBB path from buyer k to a good j gets established. When an existing MBB edge vanishes, then an old MBB path from k to a good j gets destroyed. Further, if there is an MBB path from a good j to buyer k, then price of good j monotonically decreases. If there is no MBB path from a good j to buyer k, then price of good j does not decrease. After O(n) events, there has to be a good j such that initially there is an MBB path from k to j, then no MBB path between them for some iterations, then again an MBB path between them. Let pj be the price of good j at the time when there is no path between k and j, and let αk and α′ k be the MBB for buyer k at the time the MBB path between j and k was broken and when it was later again established, respectively. Since pj does not change unless there is a path between k and j, we have αkpj = (1 + ε)c1 and α′ kpj = (1 + ε)c2, for some integers c1 and c2. Since α′ and let pl and p′ it was later established. This implies k > αk due to Lemma 3.2, we have α′ k ≥ αk(1 + ε). Let good l give the MBB to buyer k at α′ k, l be the prices of good l when the MBB path between j and k was broken and when uil/p′ l = α′ k ≥ αk(1 + ε) ≥ (1 + ε)uil/pl, and p′ l ≤ pl/(1 + ε). Proof. From Lemma 3.3, in each phase the price of a good decreases by a factor of (1 + ε). The If a price be- comes at most 1/n U n, the inner while-loop ends for a particular buyer k. Hence, the number of Lemma 3.4. The number of iterations of inner while-loop of Algorithm 1 is O(n3 log1+ε(n U nPi mi)). number of iterations in a phase is O(n2). The starting price is at most Pi mi. phases is at most n log1+ε n U nPi mi, and the number of iterations of the inner while-loop is at most O(n3 log1+ε n U nPi mi). Theorem 3.1. For every ε > 0, Algorithm 1 computes a thrifty and modest equilibrium in the perturbed market M in time polynomial in n, U and 1/ε. Proof. From Lemma 3.1, all invariants are maintained throughout the algorithm. Hence, the surplus of each good is 0, the surplus of each buyer is non-negative, and prices decrease monotonically. The algorithm ends when surplus of all buyers is zero. During the algorithm, when the price of a good, say ℓ, becomes at most 1/n U n, where U is the largest perturbed utility parameter, then the price of all the goods connected to ℓ by MBB edges is at most 1/n. Since the minimum budget of a buyer is at least 1, all buyers buying these goods have to be capped. That implies that there is an equilibrium where prices of these goods are zero. Lemma 3.4 shows that there are at most O(n3 log1+ε n U nPi mi) iterations, which can be upper bounded by O(n4/ε log(nU )). Each iteration can be implemented in polynomial time. Approximate Equilibrium Our algorithm computes an exact equilibrium in M in polynomial time. We show that such an exact equilibrium of M represents an ε-approximate equilibrium of M, thereby obtaining an FPTAS for the problem. Based on ε, let us define the precise notion of ε-approximate market equilibrium, which is based on a notion of ε-approximate demand bundle. Definition 3.3 (Approximate Demand). For a vector p of prices, consider a demand bundle x∗ i for buyer i. An allocation xi for buyer i is called an ε-approximate (thrifty and modest) demand bundle if (1) Pj uijxij ≤ ci, (2) Pj xijpj ≤ ma i , and (3) ui(xi) ≥ (1 − ε)ui(x∗ i ). An ε-approximate (thrifty and modest) equilibrium differs from an exact equilibrium only by a relaxation of condition (4) to ε-approximate demand (c.f. Definition 2.1) 13 Definition 3.4 (Approximate Equilibrium). An ε-approximate (thrifty and modest) equilibrium is a pair (x, p), where x is an allocation and p a vector of prices such that conditions (1)-(3), (5) from Definition 2.1 hold, and (4) xi is an ε-approximate demand bundle for every i ∈ B. Note that our definition is rather demanding, since there are many further relaxations (e.g., we require exact market clearing, modest supplies, exact earning and utility caps, etc), some of which are found in other notions of approximate equilibrium in the literature. Lemma 3.5. An exact equilibrium (x, p) of M is an ε-approximate equilibrium of M. Proof. Let αi and αi be the MBB of buyer i at prices p w.r.t. utility ui and perturbed utility ui, respectively. Formally, αi = maxk∈G uik/pk and αi = maxk∈G uik/pk. At prices p, let u∗ i be the maximum utility buyer i can obtain in M and M, respectively. Clearly u∗ i = min{ci, miαi}, and u∗ i = min{ci, mi αi}. maxk∈G uik/pk. Further, using (2) we get αi(1 + ε) > αi, ∀i. This implies that u∗ Since (x, p) is an exact equilibrium of M, the MBB condition implies that xij > 0 only if uij/pj = i (1 − i , ∀i. In addition, since (x, p) is an exact equilibrium i and u∗ i > u∗ i /(1 + ε) ≥ u∗ ε). Further, since uij ≥ uij, we havePj xijpj = ma for M, we obtain Pi xij = min{1, pa proves the claim. j /pj}, ∀{j ∈ G pj > 0} and Pi xij ≤ 1, ∀{j ∈ G pj = 0}. This Corollary 3.1. Algorithm 1 is an FPTAS for computing an ε-approximate equilibrium for money- clearing markets with earning and utility limits. 3.3 Membership in PLS In this section we show that the problem of computing an exact equilibrium in a money-clearing market M is in the class PLS. We first design Algorithm 4, a finite-time descending-price algorithm. It again relies on the reverse flow network N −(p) = N −(p, ∅) defined in the previous section where Z is an empty set. The algorithm starts by computing a market equilibrium ignoring the utility caps of the buyers. This equilibrium exists since the market is money-clearing. It is a pair (f , p) of flow and prices for which the outflow of good j is equal to pa j and the inflow into buyer node i is mi. We will maintain the following Invariants during the while-loop in Algorithm 4: − No price ever increases. − N −(p) allows a feasible flow. In other words, our algorithm is descending-price, and there is always a flow in N −(p) with out-flow of good j ∈ G equal to pa i . The first invariant implies that once a good becomes uncapped, it remains uncapped, and once a buyer becomes capped, it remains capped. j and in-flow into buyer i ∈ B at least ma In the body of the while-loop, we first compute a balanced flow f . A balanced flow is a maximum feasible flow in N −(p) which minimizes the 2-norm of surplus vector s = (s(1), s(2), . . . , s(B)). The notion of balanced flow was introduced in [22] for equilibrium computation in linear Fisher markets. It can be computed by n maxflow computations. Consider two buyers i and k with different surplus, say s(i) > s(k). If there is a good j connected to i and k by MBB edges, then there is no flow from j to i. Otherwise, we could decrease fji, increase fjk by the same amount, and thus decrease the 2-norm of the surplus vector. Let δ be the maximum surplus of any buyer, and let B be the set of buyers with surplus δ. We let G be the set of goods k that have non-zero flow to some buyer in B. We then decrease the prices of all goods in G by a common factor γ. Starting with γ = 1, we decrease it continuously. This may destroy MBB edges connecting buyers in B with goods in G\ G, but, by definition of G, there is no flow on such edges. For uncapped goods and capped buyers, this decreases the active price, respectively budget by 14 Algorithm 4: Finite-Time Algorithm for Money-Clearing Markets Input : Market M given by budgets mi, utility caps ci, earning caps dj, utilities uij, ∀i ∈ B, j ∈ G; Output: Equilibrium prices p and allocation x 1 (f , p) ← equilibrium of M when ignoring all utility caps 2 while Pi s(i) > 0 do 3 f ← balanced flow in N −(p) δ ← maxi s(i) B ← Set of buyers with surplus δ G ← {k ∈ G fki > 0, i ∈ B} Set γ ← 1, define pj ← γ · pj, ∀j ∈ G, and adjust active prices and budgets accordingly as a function of γ Decrease γ continuously down from 1 until one of these events occurs: // surpluses change similarly // δ > 0 Event 1: An uncapped buyer becomes capped Event 2: A capped good becomes uncapped Event 3: A new MBB edge appears Event 4: A subset of B becomes tight f ← feasible flow in N −(p) (f , p) ← MinPrices(f , p) // N −(p) is feasible 4 5 6 7 8 9 10 11 12 13 14 15 x ← FindAllocation(f , p) 16 return (x, p) a factor of γ. We stop if one of four events happens: (1) an uncapped buyer becomes capped, (2) a capped good becomes uncapped, (3) a new MBB edge appears, and (4) a subset of B becomes tight. j , where Γ(T ) ⊆ G is the set of goods connected to T in the MBB graph. Observe that there is a feasible flow in N −(p) iff we have A subset T of buyers is called tight with respect to prices p ifPi∈T ma i =Pj∈Γ(T ) pa Xi∈S ma i ≤ Xj∈Γ(S) pa j , ∀S ⊆ B. Next we obtain a feasible flow f in N −(p), which is guaranteed by Event 4. We then use an LP (Algorithm 5) to compute the pair (g, q) of flow and prices which minimizes Pj qj subject to the constraints that (1) the same buyers are capped, (2) the same goods are capped, and (3) the same edges are MBB as with respect to (f , p). Since the ratio of any two prices in a connected component of the MBB graph is constant and f is a feasible solution to the LP, q ≤ p component-wise. These observations imply: Lemma 3.6. The Invariants hold during the run of Algorithm 4. Finally, we find an equilibrium allocation using Algorithm 6. Here, we first obtain the set G of zero-priced goods and the set B of buyers who have non-zero utilities for some good in G. Clearly, the buyers of B must be capped. For the buyers and goods in B and G respectively, we find an allocation by solving a feasibility LP which allocates each buyer i a bundle of goods worth ci amount of utility. Note that this feasibility LP is non-empty, because we always maintain all the Invariants (Lemma 3.6) throughout the algorithm. We call the tuple (E, Bc, Gc) a configuration, where E ⊆ B × G is a set of MBB edges, Bc ⊆ B is a set of capped buyers, and Gc ⊆ G is a set of capped sellers. At the beginning of each iteration, we have a configuration based on the current prices. The following lemma ensures that our algorithm makes progress towards an equilibrium. 15 Algorithm 5: MinPrices Input : Market M, prices p, flow f Output: Minimum prices consistent with input configuration, feasible money flow 1 E ← Set of MBB edges at prices p 2 Gc ← Set of capped goods at (f , p) 3 Bc ← Set of capped buyers at (f , p) 4 Solve the following LP in price variables q and flow variables g: minPj qj uijqk = uikqj, uijqk ≥ uikqj, qj ≤ dj, qj ≥ dj, for each pair of edges (i, j), (i, k) ∈ E for each pair of edges (i, j) ∈ E and (i, k) 6∈ E ∀j ∈ G \ Gc ∀j ∈ Gc ∀j ∈ Gc ∀j ∈ G \ Gc ∀i ∈ B \ Bc Pi gij = dj, Pi gij = qj, Pj gij ≥ mi, Pj gij ≥ ciqj/uij, ∀i ∈ Bc where (i, j) ∈ E ∀i ∈ Bc where (i, j) ∈ E ∀(i, j) 6∈ E ∀i ∈ B, j ∈ G mi ≥ ciqj/uij, gij = 0, qj ≥ 0; gij ≥ 0 5 return Optimal solution (g∗, q∗) of above LP Lemma 3.7. During the run of Algorithm 4, no configuration repeats. Proof. An iteration ending with Event 1 or 2 grows the set Bc of capped buyers or the set Gc of capped goods. Since these sets never loose members, no preceding configuration can repeat. If the sum of prices is strictly decreased before an event, i.e., γ < 1, none of the preceding configuration can repeat, since we find the minimum possible prices for the current configuration at the end of each iteration. We will show below that prices of the goods in G are strictly decreased when an iteration ends with Event 3 or 4. In case of Event 3, a new MBB edge appears from a buyer k in B \ B to a good j in G. For such an edge to become MBB, γ must be strictly less than 1: Since k 6∈ B, s(k) < δ in the balanced flow. Suppose γ = 1 then using this MBB edge from k to j, we can increase the surplus of k and decrease the surplus of a buyer in B. This decreases the 2-norm of the surplus vector, a contradiction. Algorithm 6: FindAllocation Input : Market M, prices p, flow f Output: Allocation x 1 G ← {j ∈ G pj = 0} 2 B ← {i ∈ B uij > 0, j ∈ G} 3 Solve the following feasibility LP in allocation variables (xij)i∈ B,j∈ G: Pj∈ G uijxij = ci, ∀i ∈ B Pi∈ B xij ≤ 1, xij ≥ 0 ∀j ∈ G ∀i ∈ B, j ∈ G 4 xij ← fij/pj, ∀i ∈ B \ B, j ∈ G \ G 5 return x 16 Next consider an iteration that ends due to Event 4, and suppose prices of goods in G are not decreased. Note that the surplus of each buyer in B is δ > 0 and the surplus of each good is 0. Hence, before we decrease prices in lines 8-12 of Algorithm 4, we have Xj∈ G pa j −Xi∈ B ma i = δ · B . When Event 4 occurs, a subset T ⊆ B becomes tight, i.e., Pj∈Γ(T ) pa the set of goods connected to T . However, δ ·T =Pi∈T s(i)+Pj∈Γ(T ) s(j) =Pj∈Γ(T ) pa Pi6∈T,j∈Γ(T ) fji = −Pi6∈T,j∈Γ(T ) fji, which is a contradiction. j −Pi∈T ma Theorem 3.2. Algorithm 4 computes in exponential time a thrifty and modest equilibrium in money- clearing markets. i = 0, where Γ(T ) is i − j −Pi∈T ma Proof. In each iteration, the balanced flow can be obtained in polynomial time [22]. Consider the maximum γ at which an event occurs. The maximum γ for the first three events can be easily obtained in polynomial time. For Event 4, we need to find the maximum γ when a set of buyers become tight, which can be computed using at most a linear number of max-flow computations [22, 6]. Finally, the LP in Algorithm 5 can be solved in polynomial time, hence each iteration can be implemented such that it needs only polynomial time. Due to Lemma 3.7, we have a different configuration at the beginning of each iteration. The number of distinct configurations is finite, so Algorithm 4 terminates with an equilibrium. The running time depends polynomially on n, m, U , and the number of distinct configurations, which is at most 2O(n·m·(nm)). Observe that our algorithm constructs an initial configuration in polynomial time. Then, for each configuration, we can interpret the sum of consistent prices as objective function, which can be found by algorithm MinPrices. Furthermore, we can define a suitable neighborhood among configurations. Algorithm 4 can be adapted to efficiently search the neighborhood for a configuration that decreases the sum of consistent prices. Also, we can compute in polynomial time an equilibrium for a market Ms as a starting configuration for our algorithm. As such, our algorithm implements the oracles for the class PLS. Corollary 3.2. The problem of computing a thrifty and modest equilibrium in money-clearing markets is in the class PLS. Proof. We call a configuration feasible if the LP in Algorithm 5 is feasible and its output makes the feasibility-LP of Algorithm 6 non-empty. Otherwise, we call the configuration infeasible. For membership in PLS, we construct polynomial-time computable neighborhood and cost functions on the set of configurations such that the following property holds: A configuration has lowest cost among all its neighbors (local optimum) if and only if it is an equilibrium. For each feasible configuration, let the cost be the optimum value of the corresponding LP. For each infeasible configuration, we define its cost to be prohibitively high (n + m)U n+m+1Pi∈B mi. Each infeasible configuration has a unique neighbor the starting configuration of Algorithm 4 (in line 1). Observe that we can take any feasible configuration as the starting configuration in Algorithm 4. Hence, we define the unique neighbor of each feasible configuration C as the next configuration in Algorithm 4 when it is started with C. Clearly, both cost and neighborhood functions are polynomial- time computable, and a configuration is a local optimum if and only if it is a thrifty and modest equilibrium. This proves the claim. Remark 3.3. It is not clear how to use Algorithm 1 to show membership in class PLS. The difficulty lies in defining a suitable configuration space and a potential function. 17 3.4 Constant Number of Buyers or Goods In this section, we show that Algorithm 4 runs in polynomial time when either the number of buyers or the number of sellers is constant. Consider the number of MBB graphs for a fixed set of capped buyers and capped sellers. Using a cell decomposition technique, we show it is polynomial when B or G is constant. We create regions in a constant dimensional space by introducing polynomially many hyperplanes. The number of non-empty regions formed by N hyperplanes in Rd is O(N d). Thus, we get a polynomial bound on the number of regions. Next we show that each MBB graph maps to a particular region thus created. Since the number of regions is polynomial, we get a polynomial bound on the number of different MBB graphs. This implies that for any given set of capped buyers and capped sellers, Algorithm 4 examines only polynomially many configurations. Since the set of capped buyers only grows and the set of capped sellers only shrinks, this implies a polynomial running time for Algorithm 4. Theorem 3.4. Algorithm 4 computes in polynomial time a thrifty and modest equilibrium in money- clearing markets with constant number of buyers or sellers. Proof. For constant number of goods, consider the following set of hyperplanes in (p1, . . . , pG)-space, where pj denotes the price of good j. uijpj′ − uij′pj = 0, ∀i ∈ B, ∀j, j′ ∈ G. These hyperplanes partition the space into cells, and each cell has one of the signs <, =, > for each hyperplane. Further, each MBB graph (B ∪ G, E) satisfies the following constraints in p variables: ∀(i, j), (i, j′) ∈ E : uijpj′ − uij′pj = 0 ∀(i, j) ∈ E & ∀(i, j′) 6∈ E : uijpj′ − uij′pj ≥ 0. Now, for constant number of buyers consider the following set of hyperplanes in (λ1, . . . , λB)-space, where 1/λi denotes the MBB of buyer i. λiuij − λi′ui′j = 0, ∀i, i′ ∈ B, ∀j ∈ G. These hyperplanes partition the space into cells, and each cell has one of the signs <, =, > for each hyperplane. Further, each MBB graph (B ∪ G, E) satisfies the following constraints in λ variables: ∀(i, j), (i′, j) ∈ E : λiuij − λi′ui′j = 0 ∀(i, j) ∈ E & ∀(i′, j) 6∈ E : λiuij − λi′ui′j ≥ 0 In both cases, each MBB graph maps to a particular cell in the cell decomposition. Since the number of cells are polynomially bounded for constant G or B, this implies a polynomial bound on the number of different MBB graphs. Thus, since the set of capped buyers only grows and the set of capped sellers only shrinks, we get a polynomial running time for Algorithm 4. 3.5 Membership in PPAD In this section, we show that computing a thrifty and modest equilibrium in money-clearing markets M is in the class PPAD. We first derive a formulation as a linear complementarity problem (LCP). It captures all thrifty and modest equilibria of M, but also has non-equilibrium solutions. To discard the non-equilibrium solutions, we incorporate a positive lower bound on variables representing prices of goods and MBB of buyers. This turns out to be a non-trivial adjustment, because a subset of prices may be zero at all equilibria, so we must be careful not to discard equilibrium solutions. Our approach 18 is based on our previous work [6], in which we gave a polynomial-time algorithm for markets Mb with utility limits (and without earning limits) to find an equilibrium, whose prices are coordinate-wise smallest among all equilibria. Our approach can be summarized as follows. Consider a money-clearing market M. Now suppose we remove all earning caps to obtain a market Mb. To this market we apply the algorithm of [6] and obtain a min-price equilibrium (xmin, pmin). We show that using pmin, the market M can be partitioned into two separate markets M1 and M2. Market M1 consists of all goods with price 0 in pmin and all buyers having non-zero utility for these goods. M2 consists of the remaining buyers and goods. Since all buyers in M2 have no utility for goods in M1, we have that M2 is money clearing if and only if M is money clearing. Based on these two markets, we show that there is1 an equilibrium of M that is an equilibrium of M1 and an equilibrium of M2. We already know an equilibrium for M1 with price of 0 for every good. For M2 we show that at every equilibrium, the price of a good j is at least pmin . Using this lower bound on the equilibrium prices in M2, we construct a modified LCP formulation M-LCP which exactly captures all equilibria of M2. We suitably add an auxiliary scalar variable to M-LCP and apply Lemke's algorithm. If M2 is money clearing, we show that Lemke's algorithm is guaranteed to converge to an equilibrium of M2. Composing this with the equilibrium of M1 gives an equilibrium of M. Further, using a result of Todd [50], this proves that computing an equilibrium in money-clearing markets M is in PPAD. j 3.5.1 LCP Formulation We start our analysis by deriving an LCP formulation to capture equilibria of M. The LCP has the following variables • p = (pj)j∈G, where pj is the price of good j, • f = (fij)i∈B,j∈G, where fij is the money spent on good j by buyer i, • λ = (λi)i∈B, where 1/λi is the MBB of buyer i at prices p, • δ = (δi)i∈B, where (mi − δi) is the active budget of buyer i, • β = (βj)j∈G, where (pj − βj) is the active price of good j. Let ⊥ denote a complementarity constraint between the inequality and the variable (e.g., uijλi−pj ≤ 0 ⊥ fij ≥ 0 is a shorthand for uijλi − pj ≤ 0; fij ≥ 0; fij(uijλi − pj) = 0). ∀(i, j) ∈ (B, G) : ∀i ∈ B : uijλi − pj ≤ 0 δi ≥ mi − ciλi ⊥ fij ≥ 0 ⊥ δi ≥ 0 ∀i ∈ B : −Pj fij ≤ −(mi − δi) ⊥ λi ≥ 0 βj ≥ pj − dj ⊥ βj ≥ 0 ⊥ pj ≥ 0 ∀j ∈ G : ∀j ∈ G : Pi fij ≤ pj − βj Lemma 3.8. The LCP defined by (3)-(7) captures all equilibria of M. (3) (4) (5) (6) (7) Proof. Let (f , p) be an equilibrium of M. Let 1/λi capture the MBB of buyer i at prices p. Clearly, λi = minj:uij>0 pj/uij. From the optimal bundle constraint, it is clear that fij > 0 only if uijλi −pj = 0. This implies that (p, f , λ) satisfies (3). The active budget ma i of buyer i is min{mi, ciλi} and we have i = mi − δi, and j . Setting i . Setting δi = max{0, mi − ciλi} satisfies (4). This further implies that ma we get (5). Similarly, the active price pa Pj fij = ma j of good j is min{pj, dj} and we have Pi fij = pa 1In fact, it can be shown that every equilibrium of M has this property, but this is not necessary for membership in PPAD. 19 βj = max{0, pj − dj} satisfies (6). This further implies that pa proves the claim. j = pj − βj and we also get (7). This Lemma 3.8 shows that all equilibria of M are captured by the LCP (3)-(7). However, there are solutions to this LCP which are not market equilibria, e.g., λi = pj = βj = fij = 0, ∀i, ∀j, and δi = mi, ∀i is an LCP solution but not an equilibrium. To discard these non-equilibrium solutions in the LCP, we strive to include a positive lower bound to all pj and λi. Remark 3.5. Previous constructions [30, 32] of LCPs for market equilibria use only a positive lower bound of 1 to the prices. In our case this is not sufficient, since there are solutions where λi = fij = 0, ∀(i, j), and δi = mi, ∀i. As a consequence, we need to establish positive lower bounds to all λi. Another difficulty arises from the fact that a positive constant cannot be used as a lower bound, because there might be prices that are zero in all equilibria. A positive lower bound for these prices would discard all equilibria as solutions of the LCP. To handle these difficulties we use our polynomial-time algorithm [6] for markets Mb with utility caps. Consider market M and disregard all earning caps. The resulting market is a market Mb, for which our algorithm from [6] can compute a price vector pmin = (pmin )j∈G of a min-price equilibrium. A min-price equilibrium has coordinate-wise smallest prices, i.e., for every good j the price pmin is the smallest price of good j in all equilibria. As a consequence, the set S = {j ∈ G pmin j = 0} includes all goods that have price zero in every equilibrium of market Mb. Let Γ(S) be the set of buyers who derive non-zero utility from goods in S, i.e., Γ(S) = {i ∈ B uij > 0, j ∈ S}. j j We partition the market into two disjoint markets. Market M1 includes exactly the goods of S and the buyers in Γ(S). Market M2 has the remaining goods and buyers. By definition uij = 0 for every j ∈ S and i 6∈ Γ(S) and hence no buyer in M2 will ever spend on goods in M1. The min-price equilibrium (xmin, pmin) yields an equilibrium for M1, since all utility caps for all i ∈ Γ(S) are reached and all earning caps for all j ∈ S are satisfied. We will next establish that there is an equilibrium for M2 in which every good j 6∈ S has a price pj ≥ pmin for all j 6∈ S. Then no buyer M1 will ever spend on goods from M2, justifying the separation of the markets. j Lemma 3.9. In every equilibrium for market M2, pj ≥ pmin j , ∀j 6∈ S. Proof. Suppose there is an equilibrium of M2 where the price of some good j is pj < pmin . Note that at pmin, the sum of prices of goods in M2 is exactly equal to the sum of active budgets of buyers in M2. Since (xmin, pmin) is a min-price equilibrium, there is an uncapped buyer in every MBB component of M2. Let γ = mink∈G pk/pmin j = γ. Now consider an MBB component C containing good j at p. Since γ < 1 and there is an uncapped buyer in every MBB component of M2 at pmin, we can conclude that the total prices of goods in C will be less than the total active budgets of buyers in C, which is a contradiction. and let j be a good for which pj/pmin k j Next we derive an LCP for market M2 using the lower bound on the price of each good as given in Lemma 3.9. At this point, we need to solve the equilibrium problem for M2 only, so let B2 = B \ Γ(S) and G2 = G \ S denote the sets of buyers and goods in M2, respectively. For the lower bound on λi's we define def = 1/2 Λ min i∈B2,j∈G2: uij >0 {pmin j /uij}. (8) 20 Consider the following modified LCP in variables (λ, p′, f , δ, β), where price of good j is p′ j + pmin j : ∀(i, j) ∈ (B2, G2) : uij(λi + Λ) − (p′ ∀j ∈ G2 : ∀i ∈ B2 : ∀i ∈ B2 : ∀j ∈ G2 : j + pmin j j + pmin j − βj Pi fij ≤ p′ −Pj fij ≤ −(mi − δi) δi ≥ mi − ci(λi + Λ) βj ≥ p′ j − dj j + pmin ) ≤ 0 ⊥ fij ≥ 0 ⊥ p′ j ≥ 0 ⊥ λi ≥ 0 ⊥ δi ≥ 0 ⊥ βj ≥ 0 (9) (10) (11) (12) (13) The constraints (9)-(13) represent the M-LCP. Next we show that this LCP exactly captures all market equilibria of M2. Lemma 3.10. A solution of M-LCP is a thrifty and modest equilibrium of M2 and vice-versa. Proof. Lemmas 3.8 and 3.9 show that every equilibrium of M2 is a solution of M-LCP. For the other direction, consider a solution (λ, p′, f , δ, β) of M-LCP. The active price pa j − βj and the active budget ma i of buyer i is mi − δi. Clearly, ma i > 0, ∀i ∈ B2 and pa j of good j is p′ j > 0, ∀j ∈ G2. j + pmin Next we claim that λi > 0, ∀i. Suppose λi = 0 for a buyer i, then fij = 0, ∀j due to (9) and (8) which violates the left inequality of (11). Hence λi > 0, ∀i ∈ B2. j + pmin The constraints (9) ensure that fij > 0 then uij/(p′ j ) = maxk∈G2 uik/(p′ k + pmin k ), which implies that each buyer buys an optimal bundle. Further, the constraints (11) together with the fact that λi > 0, ∀i ensure that each buyer spends its entire active budget. Now we only need to show that each good receives money equal to its active price, i.e., Pi fij = pa j , ∀j ∈ G2. Note that the prices pmin impose an equilibrium for M2 without the earning caps. Let S′ = {j ∈ G2 p′ j , ∀j ∈ G2 \ S′ due to (10). Let Γ(S′) be the set of buyers having at least one MBB good in S′ at prices pmin. Since pmin is the min-price equilibrium without earning caps, j = 0}. Clearly, Pi fij = pa Now suppose we set prices pj = p′ , ∀j ∈ G2 \ S′ and , ∀j ∈ S′, buyers in Γ(S′) have all their MBB goods in S′ at prices p and the active budget the total active budget of buyers in Γ(S′) is at least the total prices of goods in S′, i.e., Pj∈S′ pmin of the buyers in Γ(S′) is at least Pj pmin Xj∈S′ j ≤ Xi∈Γ(S′) , ∀j ∈ G2. Since pj > pmin . Thus, we have pj = pmin j + pmin ≥ pmin pmin ma i . (14) . j j j j j j Further, summing the left hand side inequality of constraints (10) and (11) for buyers in Γ(S′) and using the fact that λi > 0, ∀i, we get Xi∈Γ(S′) ma i = Xi∈Γ(S′),j∈S′ fij ≤ Xj∈S′ pa j = Xj∈S′ pmin j − Xj∈S′ βj The above with (14) imply that βj = 0, ∀j ∈ S′ and all inequalities are equalities. Hence we have j , ∀j ∈ G2. Pi fij = pa 3.5.2 Lemke's Algorithm In this section, we apply Lemke's algorithm (see Appendix A for details) on the M-LCP. For this, we first add an auxiliary, non-negative, scalar variable z in (5) and consider fij − z ≤ −(mi − δi) ⊥ λi ≥ 0 and z ≥ 0 (15) −Xj 21 We denote by M-LCP2 the constraints (9-10), (15), (12-13). The primary ray of M-LCP2 is z ≥ mi − δi, ∀i. The other variables are set to λ = 0, p′ = 0, f = 0, δi = max{0, mi − Λci}, ∀i and βj = max{0, pmin j − dj}, ∀j. In the proof of the following theorem we show that under the money- clearing condition, there are no secondary rays in M-LCP2. Hence, applied to this LCP Lemke's algorithm will converge to an equilibrium. Theorem 3.6. Lemke's algorithm applied to M-LCP2 converges to an equilibrium in money-clearing markets. Proof. We prove the result by contradiction. Suppose Lemke's algorithm converges on a secondary ray R, which starts at a vertex (λ∗, p′ i.e., ∗, f∗, δ∗, β∗, z∗) where z∗ > 0 and the direction vector is (λo, p′ o, fo, δo, βo, zo), R = {(λ∗, p′ ∗, f∗, δ∗, β∗, z∗) + α(λo, p′ o, fo, δo, βo, zo), ∀α ≥ 0}. Observe that (λo, p′ them. o, fo, δo, βo, zo) ≥ 0. We consider three cases and show a contradiction in each of Case 1: In this case p′ , dj}, pa j + pmin j j − βj = min{p′ j , ∀j on R. Note that if λi = 0, then fij = 0, ∀j due to (3). This further implies that fij > 0 only if λi > 0. Hence, using (15) we get o > 0, i.e., all prices are increasing on R. Since pa j = dj, ∀j on R. Further, Pi fij = pa Pi∈S(mi − δi) − zS = Pj dj, where S = {i ∈ B2 λi > 0}. By money clearing (1), z = 0 and hence z∗ = 0; a contradiction. j = p′ j + pmin Case 2: In this case p′ 0 = 0, i.e., all prices are constant on R. Since p′ o = 0, we have λo = 0 and fo = 0 due to (3) and (7), respectively. This further implies that δo = 0 and βo = 0. Together, they imply that zo > 0 because the direction vector cannot be 0. Since zo > 0, we get λ∗ = 0 due to (15), which subsequently implies f∗ = 0, p′ ∗ = 0, (δ∗)i = max{0, mi − ciΛ}, and (β∗)j = max{0, pmin j − dj}. This means that the secondary ray is a primary ray; a contradiction. Case 3: In this case p′ o ≯ 0 and p′ o 6= 0, i.e., some prices are increasing and some are constant on R. o)j > 0}. This implies that pa Let S′ = {j ∈ G2 (p′ Prices of goods in S′ are increasing to infinity on R, and these goods are sold upto their maximum possible revenue. Hence, the buyers who buy these goods have zero utility for the goods outside S′, because each buyer buys an optimal bundle, and the prices of goods outside S′ are constant on R. Let Γ(S′) be the set of buyers buying goods in S′ on R. This implies that λi > 0, ∀i ∈ Γ(S′) j = dj and Pi fij = dj ∀j ∈ S′ due to (10). due to (3). Using (15) we get that Pi∈Γ(S′)(mi − δi) − zΓ(S′) = Pj∈S′ dj. This implies that z = 0 using the money-clearing condition for the buyers in Γ(S′); a contradiction. Corollary 3.3. The problem of computing a thrifty and modest equilibrium in money-clearing markets is in the class PPAD. Proof. By Theorem 3.6, Lemke's algorithm must converge to an equilibrium for money-clearing markets M. Note that Lemke's algorithm traces a path on the 1-skeleton of a polyhedron. Let v be a vertex on the path found by Lemke's algorithm. To prove membership in PPAD, we need to show that the unique predecessor and successor of v on this path can be found efficiently. Clearly, these two vertices, say u and w, can be found simply by pivoting. To determine which vertex leads to the start of the path, i.e., the primary ray, and which leads to the end, we use a result by Todd [50] on the orientability of the path followed by a complementary pivot algorithm. It shows that the signs of the sub-determinants of tight constraints satisfied by the vertices u, v and w provide the orientation of the path. This concludes the proof of membership in PPAD. 22 Remark 3.7. We note that a money-clearing market M can be reduced to a more general Leontief-free market [31]. However, the agents in the reduced market remain satiated because buyers and sellers in M are thrifty. The results for Leontief-free markets in [31] (such as membership in PPAD) require non-satiation of agents. Hence, these results are not directly applicable to markets M via such a reduction. 4 Approximating the Nash Social Welfare 4.1 Constant-Factor Approximation for Budget-Additive Valuations In this section, we present a (2e1/(2e) + ε)-approximation algorithm for maximizing Nash social welfare with budget-additive valuations, for every constant ε > 0. Consider maximization of Nash social welfare for allocation of a set G of indivisible items to a set B of agents with budget-additive valuations. As a first step, we execute a simple adjustment to the valuation functions. Note that if for some agent i ∈ B and some item j ∈ G we have vij ≥ ci, we can equivalently assume that vij = ci since the valuation of i can be at most ci. More formally, let v′ ij = min(vij, ci) and v′ proof is omitted. ij(cid:17). The following lemma is straightforward and its i ) = min(cid:16)ci,Pj∈G v′ i(xS ijxS Lemma 4.1. For every integral allocation x we have v′ i(x) = vi(x). Henceforth, we will assume that vij ≤ ci, for all i ∈ B, j ∈ G. To solve the integral maximization problem, consider the following convex program that describes a natural fractional relaxation. 1/n  Xj∈G vijxij    Max.  Yi∈B s.t. Xj∈G Xi∈B vijxij ≤ ci i ∈ B (16) xij ≤ 1 j ∈ G xij ≥ 0 i ∈ B, j ∈ G The optimal solution to this program is the allocation vector of a thrifty and modest equilibrium in a Fisher market, in which agent i has a linear utility with uij = vij, a utility limit ci and a budget mi = 1 (for details, see, e.g. [6, 15]). Unfortunately, the optimal fractional allocation of this program can be significantly better in terms of the Nash social welfare than any integral solution with all xij ∈ {0, 1} (see [16] for an example, in which the ratio is exponential in B). Hence, similar to [7, 15, 16], we introduce additional earning limits dj = 1 for all j ∈ G into the Fisher market. We will see that this lowers the achievable objective function value in equilibrium and allows us to round the fractional equilibrium allocation to an integral one that approximates the optimal Nash social welfare. Consider the resulting Fisher market M with utility and earning limits. Our first observation is that non-trivial instances of the Nash social welfare problem give rise to a market M that is money clearing. Lemma 4.2. Consider the Fisher market M resulting from an instance of the Nash social welfare problem. If the market M is not money clearing, then the maximum Nash social welfare for indivisible items is 0. 23 Proof. Obviously, if market M is not money clearing, then there exists a subset B′ of buyers such that the sum of earning caps of goods in Γ(B′) = {j vij > 0, i ∈ B′} is less than the sum of budgets of buyers in B′. This implies that Γ(B′) < B′. Hence, there is no allocation where each agent in B′ gets at least one item of positive valuation. Thus, the Nash social welfare must always be 0. When the market is not money clearing, every integral allocation has the optimal Nash social welfare. It is easy to check condition (1) by a max-flow computation. Hence, for the remainder of this section, we assume that the instance of the Nash social welfare problem is non-trivial, i.e., the resulting Fisher market is money clearing. We have seen in Section 3.1 above that a money-clearing market M always has a thrifty and modest equilibrium. Suppose we are given such an equilibrium (x, p). The Nash social welfare objective allows scaling the valuation function of every agent i by any factor γi > 0. This adjustment does neither change the equilibrium, the integral optimum solution of the Nash social welfare problem, nor the approximation factor. Given the equilibrium (x, p), we want to normalize the valuation function for agent i based on the MBB ratio αi of buyer i in the market equilibrium. In equilibrium, there can be a set of goods G0 = {j pj = 0}. All buyers B0 = {i uij > 0 for some j ∈ G0} interested in any good j ∈ G0 have infinite MBB ratio. Due to our equilibrium conditions, every i ∈ B0 must be capped and receive allocation only from G0, i.e., ui(x) = ci and xij > 0 only if j ∈ G0 and uij > 0. Moreover, since no buyer i ∈ B \ B0 has positive utility for any of the goods G0, these goods are allocated only to B0. Therefore, we can treat items G0 and agents B0 separately in the analysis. For all i ∈ B \ B0, we normalize v′ i = ci/αi. This does not change the demand bundle for buyer i, and thus (x, p) remains an equilibrium. In the resulting instance, every such buyer has MBB of 1 in (x, p). Consequently, v′ ij ≤ pj for all i ∈ B \ B0, j ∈ G, where equality holds if and only if j is an MBB good of buyer i. For simplicity we assume that v and c fulfill these conditions directly, i.e., vij = v′ i. Together with the fact that vij ≤ ci, ∀(i, j) this implies ij = vij/αi and c′ ij and ci = c′ vij ≤ min(pj, ci), for all i ∈ B \ B0, j ∈ G . (17) The following lemma is a helpful insight on the structure of equilibria. Lemma 4.3. Consider a money-clearing Fisher market M with mi = 1, dj = 1, and vij ≤ ci, for all i ∈ B, j ∈ G. Suppose we normalize the utilities based on a thrifty and modest equilibrium (x, p). Then the following properties hold. (a) A buyer i ∈ B \ B0 spends ma i = min(1, ci) units of money. Its valuation vi(x) is equal to ma i . If i is capped, ci ≤ 1. (b) If i is capped, it is allocated at least one unit of goods. (c) If i is capped and j is an MBB good for buyer i. Then pj ≤ 1. (d) If pj < 1, j is completely sold. (e) The money spent on good j is pa j = min(pj, 1). Proof. An uncapped buyer i ∈ B \ B0 spends his entire budget as otherwise xi would not be a demand bundle. Since MBB = 1, the valuation vi(x) is equal to the money spent by i. If i is capped, its valuation is equal to ci and hence the money spent is equal to ci. Since vij ≤ ci always and ci = vi(x) for a capped agent, we have ci = vi(x) ≤ ciPj xij and hence If j is an MBB good for a capped buyer i, then pj = vij ≤ min(pj, ci) according to (17) and hence Pj xij ≥ 1. pj ≤ ci ≤ 1, where the last inequality was established in (a). If 0 < pj < 1, the supply ej = min(1, dj /pj) = min(1, 1/pj ) = 1. Thus j is completely sold. Finally, the money spent on j is pjej = pj min(1, 1/pj ) = min(pj, 1) = pa j . 24 Our subsequent analysis proceeds as follows. First, in the following Section 4.1.1, we describe an upper bound on the optimal Nash social welfare of any integral solution. The upper bound is based on the properties of any thrifty and modest equilibrium described above. In Section 4.1.2 we then show how to round an equilibrium and obtain an integral solution that is a 2e1/(2e)-approximation for the optimal Nash social welfare. Finally, since our FPTAS from Section 3.2 computes an exact equilibrium in a perturbed market, we discuss in Section 4.1.3 the impact of perturbing the market on the approximation guarantee. 4.1.1 Upper Bound In this section, we describe an upper bound on the optimal Nash social welfare when valuations are normalized based on an equilibrium (x, p). The bound relates to prices and utility caps of the capped buyers in (x, p). We denote by Bc and Bu the set of capped and uncapped buyers in (x, p), respectively. Recall that since (x, p) is a thrifty and modest equilibrium, buyers may not spend their entire budget and sellers may not sell their entire supply. We denote by ma i = min(1, ci) the active budget of buyer i and by pa j = min(pj, dj) the active price of good j. The following result is a generalization of a similar bound shown in [16]. The main difference is to carefully account for the contribution of capped buyers. Theorem 4.1. For valuations v and caps c normalized according to equilibrium prices p, we have vi(x∗)!1/n Yi∈B ≤ Yi∈Bc ci Yj:pj>1 1/n , pj  where x∗ is an integral allocation that maximizes the Nash social welfare. Proof. Consider an integral allocation x∗ that maximizes the Nash social welfare. For the agents i ∈ B0 ⊆ Bc, a simple upper bound is Qi∈B0 vi(x∗) ≤ Qi∈B0 ci. To obtain an upper bound on Qi∈B\B0 vi(x∗), we have to work harder. We denote by Gc the set of goods allocated to agents in ij = 1 for some i ∈ Bu} the set of items with price more u} be the Bc \ B0 in x∗ and by G1 than 1 that are assigned in x∗ to buyers in Bu. Let B1 set of buyers from Bu that receive an item of G1 ij = 1 for some j ∈ G1 u ≤ G1 u = {i ∈ Bu x∗ u in x∗. Note that B1 u = {j ∈ G pj > 1; x∗ u. We will construct a fractional allocation x with Qi∈B\B0 vi(x∗) ≤ Qi∈B\B0 vi(x) and then bound the latter product. A key step in the construction of x is to bound Pi∈Bu\B1 ij ≤ Xj∈G\(Gc∪G1 u − Xj∈Gc u − Xi∈Bc\B0 vi(x∗) ≤ Xi∈Bu\B1 = Xi∈Bc\B0 ≤ Xi∈Bc\B0 u Xj∈G\(Gc∪G1 Xi∈Bu\B1 vi(x∗). We have ci + Bu − G1 ci + Bu − G1 vi(x∗) . pj x∗ (18) pa j u u) pj u) u The first inequality holds since vij ≤ min(ci, pj) for all i and j and the goods in Gc and G1 allocated to the agents in Bc and B1 pa j + G1 u are u, respectively. The second line follows since the total money u) pj and the total money flow out of the agents pa j . This holds since vi(x∗) ≤ ci ≤ 1 for every i ∈ Bc \ B0 and hence any good j ∈ Gc can contribute at most min(ci, pj) ≤ min(1, pj) = pa flow into the goods is Pj∈Gc is Pi∈Bc\B0 ci + Bu. The last line follows from Pi∈Bc\B0 vi(x∗) ≤ Pj∈Gc u +Pj∈G\(Gc∪G1 j to vi(x∗). We now take a fractional improvement step and relax the integrality condition on x∗ for buyers in u ∪ B0) and redistribute them fractionally among u ∪ B0). We take the goods assigned to B \ (B1 B \ (B1 25 these buyers. However, we require that the fractional solution respects the upper bound (18). We denote by x the best solution obtained in this improvement step. Note that the Nash social welfare can only increase. Further, note that x is integral for the buyers in B1 u. Since x satisfies (18), Xi∈Bu\B1 u vi(x) ≤ Bu − G1 u + Xi∈Bc\B0 ci − Xi∈Bc\B0 vi(x) . (19) We want to bound Yi∈B\B0 vi(x) = Yi∈Bc\B0 ≤ Yi∈Bc\B0 u vi(x) · Yi∈B1 vi(x) · Yi∈B1 u vi(x) vi(x) · Yi∈Bu\B1 vi(x) · Pi∈Bu\B1 u u Bu \ B1 u vi(x) u !Bu\B1 . We will show that the maximum value is obtained when each buyer i ∈ Bc \ B0 gets value ci, each buyer i ∈ B1 u gets value 1. This will prove the claim. u, and each buyer i ∈ Bu \ B1 u gets exactly one good of G1 u, i.e., B1 u = G1 Assume first that Pi∈Bu\B1 u. Then there must be a buyer i ∈ Bc \ B0 that gets value less than ci and hence less than one and a buyer i′ ∈ Bu \ B1 u that gets value more than one. Since x is allowed to be fractional for buyers in Bc \ B0 and Bu \ B1 u, we can reallocate some amount of good from i′ to i. This increases the Nash social welfare, a contradiction. We now have vi(x) > Bu \ B1 u Each buyer in i ∈ B1 u. Suppose now that at x we have B1 u gets at least one good j with price pj > 1 in x. Since vij = min(ci, pj) > 1, we have vi(x) > 1 for all i ∈ B1 u gets at least two goods of G1 u and hence there is an i ∈ Bu \ B1 u with vi(x) < 1 or there is an i ∈ Bc \ B0 that gets value less than ci and hence less than one or both. Since x is allowed to be fractional for buyers in Bc \ B0 and Bu \ B1 u, we can reallocate one entire good from i′ to i. This increases the Nash social welfare, a contradiction. We now have B1 u, i.e., the goods of price higher than one are in one-to-one correspondence to the buyers in B1 u. Then (19) implies that either Pi∈Bu\B1 u < G1 vi(x) < Bu \ B1 u, i.e., a buyer i′ ∈ B1 u = G1 u. Thus u vi(x) ≤ Bu \ B1 u. Pi∈Bu\B1 u Yi∈B\B0 vi(x) = Yi∈Bc\B0 ci · Yj:pj>1 pj · (1)Bu\B1 u . 4.1.2 Rounding Equilibria In this section, we give an algorithm to round a fractional allocation of a thrifty and modest equilibrium (x, p) to an integral one. Without loss of generality, we may assume that the allocation graph (B∪G, E) with E = {{i, j} ∈ B × G xij > 0} is a forest [45, 23]. In the following, we only discuss how to round the trees in (B \ B0) × (G \ G0). For trees in B0 × G0, the rounding and the analysis are very similar, but independent of prices and slightly simpler (see Appendix B). Consider the following procedure: Preprocessing: It consists of three substeps. (a) For each tree component of the allocation graph, assign some agent to be a root node. (b) For every good j keep at most one child agent. This child-agent i must buy the largest amount of j among the child agents (ties are broken arbitrarily) and must have an active budget which is less than twice the price of j, i.e., ma i /2 < pj. In other words, child agent i is cut off from good j if a sibling buys more of good j (ties are broken arbitrarily) or if pj ≤ ma i /2. Note that if a sibling buys more of good j, it also spends more on good j. 26 (c) Agents whose connection to their parent-good is severed in step (b) become roots. Rounding: It consists of two substeps. (a) Goods with no child agent are assigned to their parent agent. (b) For each non-trivial tree component, do the following recursively: Assign the root agent a child good j that gives him the maximum value (among all children goods) in the fractional solution. Except in the subtree rooted at j, assign each good to its child agent in the remaining tree. Make the child agent of good j the root node of the newly created tree. Lemma 4.4. After preprocessing, the valuation of each root agent r is at least vr(x)/2. For all other agents i the valuation is at least vi(x). If good j has child agents and pj > 1, then j keeps a child agent. Proof. Whenever an agent i loses allocation because the connection to its parent-good j is cut, a new tree component is being created and i becomes its root node. Since vij ≤ ci, ∀(i, j), each capped agent needs to buy in total at least one unit of goods, and each uncapped agent spends his entire budget. If i is cut from j, then xij ≤ 1/2 or pj ≤ ma In the former case, we distinguish cases. Since the total spending on good j is at most one and a sibling of i spends at least as much on j as i, i spends at most 1/2 on j. Thus, if i is uncapped, it receives at most half of its utility from j. If i is capped, vijxij ≤ ci/2 = vi(x)/2, i.e., i receives at most half of its utility from j. In the latter case, vijxij ≤ min{ci, pj} ≤ pj ≤ ma i /2 = vi(x)/2, i.e., i receives at most half of its utility from j. i /2. For a good j with child agents and pj > 1, the child agent i that buys most of j is kept as a child since pj > 1/2 = ma i /2. Lemma 4.5. After step (a) of rounding, each tree component T has kT + 1 agents and kT goods for some kT ≥ 0. Suppose agent i in T is assigned a good j with pj > 1 during step (a) of rounding. Then i spends all its money on j, and i is the only agent that spends money on j. Moreover, the valuation of i after rounding is pj, and Bc ∩ T = ∅. Proof. The first part is straightforward since after step (a) of rounding, every remaining good has exactly one parent agent and one child agent. For the second part, consider any good j with price pj > 1. If j has children-agents, the one that spends most on j stays as a child. Thus j is not assigned during preprocessing. If j is a leaf of the initial forest, only its parent agent spends money on it, call it i. Since the money inflow into j is one and i has only one unit to spend, only i spends on j and i spends one unit on j. Thus i is not capped in the equilibrium and vij = pj since j is an MBB-good for i and hence pj ≤ ci by (17). Thus the valuation of i after rounding is pj and Bc ∩ T = ∅. Lemma 4.6. After rounding, each agent i that is assigned its parent good obtains a valuation of at least vi(x)/2. Proof. Consider any good j in the tree in the rounding step. Since j was not assigned to its parent agent during preprocessing, its price is at least half of the active budget of its child agent, i.e., pj ≥ ma i /2. Since j is MBB for i, vij = pj and hence from this good the child-agent obtains a valuation of at least half of the valuation in the equilibrium. Consider a tree T at the beginning of the step (b) of rounding with kT + 1 agents and kT goods. Assume kT ≥ 1 first. Let a1, g1, a2, g2, . . . , al, gℓ, aℓ+1 be the recursion path in T starting from the root agent a1 and ending at the leaf agent aℓ+1 such that a1, . . . , aℓ+1 became root agents of the trees formed recursively during the rounding step, and good gi is assigned to ai in this process, for 1 ≤ i ≤ ℓ. Note that aℓ+1 is not assigned any good in step (b) of rounding. However, as the proof of the following Lemma shows, it must have been assigned some good during step (a) of rounding. We denote by ki the number of children for agent ai, for 1 ≤ i ≤ ℓ. If kT = 0, then ℓ = 0 and a1 = aℓ+1 is the root of a tree containing no goods after step (a) of rounding. 27 Lemma 4.7. The product of the valuations of agents in T in the rounded solution is at least 2(cid:19)kT −ℓ+1 (cid:18) 1 · 1 k1 · · · kℓ · Yi∈T ∩Bc ci Yj∈T :pj>1 pj . Proof. Let ¯ci = min{1, ci}, ∀i ∈ B. We first deal with the case kT = 0. Then ℓ = 0. If a good j of price pj > 1 is assigned to a1 during step (a) of rounding, then the valuation of a1 after rounding is pj and Bc ∩ T = ∅ by Lemma 4.5. This establishes the claim even without the leading factor 1/2. If all goods assigned to a1 during step (a) of rounding have price at most one then {j ∈ T : pj > 1} = ∅ and T ∩ Bc ⊆ {a1}. Moreover, the value of a1 after preprocessing is at least va1(x)/2 = ¯ca1 /2. Rounding does not decrease the value. We turn to the case kT ≥ 1. Let qi = xai,gi > 0 be the amount of good gi bought by agent ai in the equilibrium, for 1 ≤ i ≤ l. Then ai spends qipi on good gi. In the market equilibrium, the root agent a1 receives at least half of its valuation from its children. Thus q1p1 ≥ ¯c1/(2k1). We next show that agent ai, 2 ≤ i ≤ ℓ + 1, receives at least value qi−1 max(¯ci, pi−1) from its children in the market equilibrium. Agent i can spend at most ¯ci − qi−1pi−1 on good i − 1. Thus it must spend qi−1pi−1 on its children in the market equilibrium. This establishes the claim if ¯ci ≤ pi−1. So assume pi−1 < ¯ci. Agent i can receive at most a fraction 1 − qi−1 of good i − 1. Hence the value it receives from this good is at most (1 − qi−1)pi−1 ≤ (1 − qi−1)¯ci. Thus it must receive value at least qi−1¯ci from its children goods. qipi ≥ qi−1 max(¯ci, pi−1)/ki for 2 ≤ i ≤ ℓ, since agent ai spends qipi on good gi and this is at least a fraction 1/ki of what it spends totally on its children. The product of the valuations of a1 to aℓ+1 in the rounded solution is at least p1 . . . pℓ ·qℓ max(¯cℓ, pℓ). This holds since gi is assigned to ai for 1 ≤ i ≤ ℓ and aℓ+1 receives a value at least qℓ max(¯cℓ, pℓ) from its children in the market equilibrium. Since these children are assigned to aℓ+1 during step (a) of rounding, it receives at least this value in the rounded solution. Combining the arguments above we obtain p1 · · · pℓ·qℓ max(¯cℓ, pℓ) ¯c1 q1 max(¯c2, p1) q2k2 · · · qℓ−1 max(¯cℓ, pℓ−1) qℓkℓ · qℓ max(¯cℓ+1, pℓ) ≥ = ≥ 2q1k1 1 2(cid:18) 2(cid:18) 1 1 k1 . . . kl(cid:19) ¯c1 · Y2≤i≤ℓ+1 k1 . . . kl(cid:19) Y1≤i≤ℓ+1 1 max(¯ci, pi−1) ¯ci · Y1≤i≤ℓ;pi>1 pi, where the last inequality follows from max(¯ci, pi−1) ≥ ¯ci · max(1, pi−1) for all i. Each of the remaining kT − ℓ agents in T get a value at least max(vi(x)/2, p), where p is the price of the parent-good. Finally, since at most one good is assigned to each agent during the rounding step, each capped good is assigned to a separate agent, the product of the valuations of agents in T in the rounded solution is at least 2(cid:19)k−l+1(cid:18) (cid:18) 1 1 k1 . . . kl(cid:19) Yi∈T ∩Bc ci Yj∈T :pj>1 pj . Theorem 4.2. The rounding procedure gives a 2e1/2e-approximation for the optimal Nash social welfare with budget-additive valuations. Note that 2e1/2e < 2.404. 28 Proof. Suppose there are trees T 1, T 2, . . . , T a at the beginning of the rounding. Let ki + 1 and ki be the number of agents and goods in tree T i, respectively. Let li + 1 be the number of agents on the path in T i traced during the rounding step, and let ki be the degrees of the number of children goods for agents along that path. 1, . . . , ki li The bound in Lemma 4.7 for trees T ⊆ (B \ B0) × (G \ G0) can also be obtained for our rounding of trees T ⊆ B0 × G0 (Lemma B.4 in the Appendix). Thus, the Nash social welfare of the rounded solution is at least  2(cid:19)Pa i=1(ki−li+1)(cid:18) (cid:18) 1 i=1 li/n · · 2Pa 1 2 i=1 li 1 2 2Pa i=1Pli Pa j=1 ki = ≥ k1 1 . . . k1 l1k2 l2 . . . ka 1 . . . ka 1 1 . . . k2 1 j=1 ki j!1/n Yi∈Bc i=1Qli Qa j!Pa i=1 li/n ci Yj:pj>1 Yi∈Bc ci Yj:pj>1 pj  1/n ci Yj:pj>1 1/n pj  1/n la(cid:19) Yi∈Bc pj  1/n . pj  1 ≥ 2e1/2e  ci Yj:pj>1 Yi∈Bc j(cid:17)1/ Pi li j, i.e., (cid:16)QiQj ki arithmetic and geometric mean applied to the set of all ki The first equation usesPi(ki + 1) = n. The subsequent inequality follows from the standard relation of j/Pi li. The last inequality uses Pa j ≤ n and the fact that (2x)x is minimum at x = 1/2e. ≤ PiPj ki i=1Pli j=1 ki 4.1.3 Rounding Equilibria of Perturbed Markets Given a parameter ε′ > 0, our FPTAS in Section 3.2 computes an exact equilibrium for a perturbed market, which results when agents have perturbed valuations vi(x) = min(cid:16)ci,Pj vijxij(cid:17) with the same caps ci and vij ≥ vij ≥ vij/(1 + ε′). Suppose we apply our rounding algorithm to the exact equilibrium for v. It obtains an allocation S such that vi(xS i )!1/n Yi ≥ ≥ ≥ 1 (1 + ε′) Yi 1 (1 + ε′) · 1 1 vi(xS i )!1/n 2e1/2e Yi · Yi vi(x∗)!1/n vi(x∗)!1/n . (1 + ε′) · 2e1/2e If we apply the FPTAS with ε′, then this yields an approximation ratio of at most 2e1/2e + ε for ε = 2e1/(2e)ε′. We summarize our main result: Corollary 4.1. For every ε > 0 there is an algorithm with running time polynomial in n, m, log maxi,j{vij, ci}, and 1/ε that computes an allocation which represents a (2e1/2e + ε)-approximation for the optimal Nash social welfare. 4.2 Hardness of Approximation In this section, we provide a result on the hardness of approximation of the maximum Nash social welfare with additive valuations. The best previous bound was a factor of 1.00008 [38]. Our improved 29 budget-additive valuations. lower bound of p8/7 > 1.069 follows by adapting a construction in [12] for (sum) social welfare with Theorem 4.3. For every constant δ > 0, there is no (p8/7 − δ)-approximation algorithm for maxi- mizing Nash social welfare with additive valuations unless P=NP. For clarity, we first describe the proof for budget-additive valuations with caps. Subsequently, we show how to drop the assumption of caps and apply the proof even for additive valuations. Lemma 4.8. For every constant δ > 0, there is no (p8/7−δ)-approximation algorithm for maximizing Nash social welfare with budget-additive valuations unless P=NP. Proof. Chakrabarty and Goel [12] show hardness for (sum) social welfare by reducing from MAX-E3- LIN-2. An instance of this problem consists of n variables and m linear equations over GF(2). Each equation consists of 3 distinct variables. For the Nash social welfare objective, we require slightly more control over the behavior of the optimal assignments. Therefore, we consider the stronger problem variant Ek-OCC-MAX-E3-LIN-2, in which each variable occurs exactly k times in the equations. Theorem 4.4 ([14]). For every constant ε ∈ (0, 1 4 ) there is a constant k(ε) and a class of instances of Ek-OCC-MAX-E3-LIN-2 with k ≥ k(ε), for which we cannot decide if the optimal variable assignment fulfills more than (1 − ε)m equations or less than (1/2 + ε)m equations, unless P=NP. Our reduction follows the construction in [12]. We only sketch the main properties here. For more details see [12, Section 4]. For each variable xi we introduce two agents hxi : 0i and hxi : 1i. Each of these agents has a cap of ci = 4k, where k is the number of occurrences of xi in the equations. Since in Ek-OCC-MAX-E3-LIN-2 every variable occurs exactly k times, we have ci = 4k for all agents. Moreover, for each variable xi there is a switch item. The switch item has value 4k for agents hxi : 0i and hxi : 1i, and value 0 for every other agent. It serves to capture the assignment of the variable -- if xi is set to xi = 1, the switch item is given to hxi : 0i (for xi = 0, the switch item goes to hxi : 1i). When given a switch item, an agent cannot generate value for any additional equation items defined as follows. For each equation xi + xj + xk = α with α ∈ {0, 1}, we introduce 4 classes of equation items -- one class for each satisfying assignment. In particular, we get class hxi : α; xj : α; xk : αi as well as classes hxi : ¯α, xj : ¯α, xk : αi, hxi : ¯α, xj : α, xk : ¯αi and hxi : α, xj : ¯α, xk : ¯αi. For each of these classes, we introduce three items. Hence, for each equation we introduce 12 items in total. An item h< xi : αi, xj : αj, xk : αki has a value of 1 for the three agents hxi : αii, hxj : αji, and hxk : αki, and value 0 for every other agent. It is easy to see that w.l.o.g. every optimal assignment of items to agents assigns all switch items. Hence, every optimal assignment yields some variable assignment for the underlying instance of Ek- OCC-MAX-E3-LIN-2. Consider an equation xi + xj + xk = α that becomes satisfied by setting the variables (xi, xj, xk) = (αi, αj, αk). Then none of the agents hxi : αii, hxj : αji, and hxk : αki gets a switch item, and we can assign exactly 4 equation items to each of these agents (for details see [12]). Hence, all 12 equation items generate additional value. In particular, it follows that if xi is involved in a satisfied equation, one of its agent gets a switch item, and the other one can receive at least 3 equation items. Consider an equation xi+xj +xk = α that becomes unsatisfied by setting the variables (xi, xj, xk) = (αi, αj, αk). Then for one class of equation items, all agents that value these items have already received switch items (for details see [12]). This class of items cannot generate additional value. Hence, at most 9 equation items generate additional value. They can assigned to the agents that did not receive switch items such that each agent receives 3 items. In particular, it follows that if xi is involved in an unsatisfied equation, one of its agents gets a switch item, and the other one can receive at least 3 30 equation items. Hence, we can ensure that in every optimal solution the overall Nash social welfare is never 0. We now derive a lower bound on the optimal Nash social welfare when (1 − ε)m equations can be satisfied. In this case, we obtain value 4k for n agents that receive the switch items. Moreover, we get an additional total value of 12m(1 − ε) + 9mε generated by the equation items. Note that m = kn/3. We strive to lower bound the Nash social welfare of an optimal assignment in this case. For this, it suffices to consider the assignment indicated above -- for each satisfied equation, all incident agents without switch items get 4 equation items. For each unsatisfied equation, all incident agents without switch items get 3 equation items. To obtain a lower bound on the Nash social welfare, we assume a value of 4k for a maximum of n(1 − ε) agents, while the others get a value of 3k. Therefore, when an assignment of items to agents generates Nash social welfare of more than (cid:16)(4k)n · (4k)n(1−ε) · (3k)nε(cid:17)−2n = k · 4 1 2 · 4 1 2 · (3/4) ε 2 , we take this as an indicator that at least m(1 − ε) equations can be fulfilled. In contrast, now suppose only (1/2 + ε)m equations can be fulfilled. In this case, we obtain value 4k for n agents that receive the switch items. Moreover, we get an additional total value of at most 12m(1/2 + ε) + 9m(1/2 − ε) = 10.5m + 3εm generated by the equation items. We strive to upper bound the Nash social welfare of such an assignment. For this, we assume that all agents that do not receive a switch item get an equal share of the value generated by equation items, i.e., a share of 3.5k + kε. Therefore, when an assignment of items to agents generates Nash social welfare of less than ((4k)n · (k(3.5 + ε))n)−2n = k · 4 1 2 · (3.5 + ε) 1 2 , we take this as an indicator that at most m(1/2 + ε) equations can be fulfilled. Hence, if we can approximate the optimal Nash social welfare by at most a factor of 1 2 · (3/4) 4 ε 2 (3.5 + ε) 1 2 =(cid:18) 4 · (3/4)ε 3.5 + ε (cid:19) 1 2 , we can decide whether the instance of Ek-OCC-MAX-E3-LIN-2 has an optimal assignment with at least m(1 − ε) or at most m(1/2 + ε) satisfied equations. This shows that we cannot approximate Nash social welfare with a factor of p8/7 > 1.069 unless P=NP. Having established the result for budget-additive valuations, we now show how to adjust the con- struction for additive valuations. Proof of Theorem 4.3. We use the same construction as in Lemma 4.8 with the following adjustments. Switch items have a large value M ≫ 4k for the respective agents. All agent valuations are additive and have no caps (i.e., all ci = ∞). First, we again establish the lower bound on the optimal Nash social welfare when (1−ε)m equations can be satisfied. Then 12m(1−ε)+9mε equation items can be given to the agents without switch items. The remaining 3mε equation could be assigned to agents with switch items. Instead, to construct a lower bound, we simply drop these items from consideration. Therefore, when an assignment of items to agents generates Nash social welfare of more than (cid:16)M n · (4k)n(1−ε) · 3knε(cid:17)−2n = k 1 2 · M 1 2 · 4 1 2 · (3/4) ε 2 we take this as an indicator that at least m(1 − ε) equations can be fulfilled. Now suppose only (1/2 + ε)m equations can be fulfilled. To construct an upper bound on the optimal Nash social welfare, we apply the reasoning above. n agents receive switch items according to 31 an optimal variable assignment. The 12m(1/2 + ε) + 9m(1/2 − ε) = 10.5m + 3εm equation items are assigned in equal shares to agents without switch items. The remaining 3m(1/2 − ε) items are assigned equal shares to agents with switch items. Therefore, when an assignment of items to agents generates Nash social welfare of less than (cid:18)(cid:18)M + k(cid:18) 1 2 − ε(cid:19)(cid:19)n · (k(3.5 + ε))n(cid:19)−2n = k 1 2 ·(cid:18)M + k(cid:18) 1 2 1 2 − ε(cid:19)(cid:19) · (3.5 + ε) 1 2 we take this as an indicator that at most m(1/2 + ε) equations can be fulfilled. Hence, if we can approximate the optimal Nash social welfare by at most a factor of 1 2 ! 1 2 ·(cid:18) 4 · (3/4)ε 3.5 + ε (cid:19) M M + k(cid:0) 1 2 − ε(cid:1) we can decide whether the instance of Ek-OCC-MAX-E3-LIN-2 has an optimal assignment with at least m(1 − ε) or at most m(1/2 + ε) satisfied equations. The second fraction clearly grows to p8/7 as ε → 1. For a fixed number M , the first fraction decreases, since k = k(ε) increases with decreasing ε. However, we can choose a number M = o(k) since k is the number of occurrences of a single variable and, thus, the input size is polynomial in k. For example, with M = kk the first term approaches 1 rapidly as ε → 0 (and k → ∞). This shows that we cannot approximate Nash social welfare with a factor of p8/7 > 1.069 unless P=NP, even for additive valuations. 5 Future Directions There are many interesting questions arising from our work. Equilibria in linear Fisher markets with both earning and utility limits turn out to have intriguing structure. Although equilibrium may not always exist in these markets, we showed that it always exists when the market satisfies the money clearing condition, i.e., money clearing is a (polynomial-time checkable) sufficiency condition for existence. While existence is guaranteed in this case, the set of equilibria is non-convex. Nevertheless, we managed to obtain an FPTAS to compute an approximate equilibrium. Beyond money-clearing markets, however, even deciding existence is not well-understood -- is it NP-hard, or can it be tightly characterized by a simple condition that can be checked in polynomial time? In addition to deciding existence, can we efficiently find exact equilibria in general (if they exist) or in money-clearing markets? Is the problem of finding equilibria for money-clearing markets in the class CLS (Continuous Local Search) [19]? We showed that an approximate equilibrium can be rounded to obtain a constant-factor approx- imation of Nash social welfare for allocating indivisible goods among agents with budget-additive valuations. This shows that in order to obtain a constant-factor approximation algorithm for the Nash social welfare problem, we only need a constant-factor approximate equilibrium of an appropriate Fisher market. It would be interesting to see if Fisher markets with limits can yield good approxima- tion algorithms for the Nash social welfare problem also beyond budget-additive and additive-separable concave valuations. A The Linear Complementarity Problem and Lemke's Algorithm Given an n × n matrix M , and a vector q, the linear complementarity problem2 asks for a vector y satisfying the following conditions: M y ≤ q, y ≥ 0 and y · (q − M y) = 0. (20) 2We refer the reader to [17] for a comprehensive treatment of notions presented in this section. 32 The problem is interesting only when q 6≥ 0, since otherwise y = 0 is a trivial solution. Let us introduce slack variables v to obtain the equivalent formulation. M y + v = q, y ≥ 0, v ≥ 0 and y · v = 0. (21) The reason for imposing non-negativity on the slack variables is that the first condition in (20) implies q − M y ≥ 0. Let P be the polyhedron in 2n dimensional space defined by the first three conditions; we will assume that P is non-degenerate3. Under this condition, any solution to (21) will be a vertex of P, since it must satisfy 2n equalities. Note that the set of solutions may be disconnected. An ingenious idea of Lemke was to introduce a new variable and consider the system, which is called the augmented LCP: M y + v − z1 = q, y ≥ 0, v ≥ 0, z ≥ 0 and y · v = 0. (22) Let P ′ be the polyhedron in 2n + 1 dimensional space defined by the first four conditions of the augmented LCP; again we will assume that P ′ is non-degenerate. Since any solution to (22) must still satisfy 2n equalities, the set of solutions, say S, will be a subset of the one-skeleton of P ′, i.e., it will consist of edges and vertices of P ′. Any solution to the original system must satisfy the additional condition z = 0 and hence will be a vertex of P ′. Now S turns out to have some nice properties. Any point of S is fully labeled in the sense that for each i, yi = 0 or vi = 0.4 We will say that a point of S has double label i if yi = 0 and vi = 0 are both satisfied at this point. Clearly, such a point will be a vertex of P ′ and it will have only one double label. Since there are exactly two ways of relaxing this double label, this vertex must have exactly two edges of S incident at it. Clearly, a solution to the original system (i.e., satisfying z = 0) will be a vertex of P ′ that does not have a double label. On relaxing z = 0, we get the unique edge of S incident at this vertex. As a result of these observations, it follows that S consists of paths and cycles. Of these paths, Lemke's algorithm explores a special one. An unbounded edge of S such that the vertex of P ′ it is incident on has z > 0 is called a ray. Among the rays, one is special -- the one on which y = 0. This is called the primary ray and the rest are called secondary rays. Now Lemke's algorithm explores, via pivoting, the path starting with the primary ray. This path must end either in a vertex satisfying z = 0, i.e., a solution to the original system, or a secondary ray. In the latter case, the algorithm is unsuccessful in finding a solution to the original system; in particular, the original system may not have a solution. Remark: Observe that z1 can be replaced by za, where vector a has a 1 in each row in which q is negative and has either a 0 or a 1 in the remaining rows, without changing its role; in our algorithm, we will set a row of a to 1 if and only if the corresponding row of q is negative. As mentioned above, if q has no negative components, (20) has the trivial solution y = 0. Additionally, in this case Lemke's algorithm cannot be used for finding a non-trivial solution, since it is simply not applicable. However, Lemke-Howson scheme is applicable for such a case; it follows a complementary path in the original polyhedron (21) starting at y = 0, and guarantees termination at a non-trivial solution if the polyhedron is bounded. B Rounding Trees with Zero Price Goods In this section, we give an algorithm to round trees T0 ⊆ B0 × G0 of the equilibrium (x, p) to an integral allocation. Recall that in such trees, all goods have price pj = 0 and all buyers reach their cap 3A polyhedron in n-dimension is said to be non-degenerate if on its d-dimensional faces exactly n − d of its constraints hold with equality. For example on vertices (0-dimensional face) exactly n constraints hold with equality. There are many other equivalent ways to describe this notion. 4These are also known as almost complementary solutions in the literature. 33 ci. Consider the following procedure which is similar to the procedure in Section 4.1.2. It uses only the allocation x and does not rely on prices. In particular, the only price-based assignment rule is in the preprocessing step, and it can be replaced here with an equivalent, more direct criterion: Preprocessing: It consists of three substeps. (a) For each zero-price tree component of the allocation graph, assign some agent to be a root node. (b) For every good j keep at most one child agent. This child agent i must buy the largest amount of j among the child agents (ties are broken arbitrarily) and must receive a utility that is at least half of the total utility, i.e., uijxij > ci/2. In other words, child agent i is cut off from good j if a sibling buys more of good j (ties are broken arbitrarily) or if uijxij ≤ ci/2. (c) Agents whose connection to their parent good is severed in step (b) become roots. Rounding: It consists of two substeps. (a) Goods with no child agent are assigned to their parent agent. (b) For each non-trivial zero-price tree component, do the following recursively: Assign the root agent a child good j that gives him the maximum value (among all children goods) in the fractional solution. Except in the subtree rooted at j, assign each good to its child agent in the remaining tree. Make the child agent of good j the root node of the newly created tree. Prices pj play a role in exactly two places in Section 4.1.2. First, when we assign a good j to the parent and drop the child agent i with pj ≤ ma i /2, this ensures that the valuation of agent i in the newly created tree is at least half of the original valuation. We use this fact to prove Lemmas 4.4 and 4.6. In case of zero price goods, our choice of assigning a good j to the parent and dropping the child agent i if uijxij ≤ ci/2 is an equivalent notion in terms of allocation. Second, in Lemmas 4.5 and 4.7 we argue that a good with price more than 1 is only assigned to an uncapped agent i which gives agent i at least pj amount of value. Since each agent of B0 is capped, we do not need this property in Lemmas B.2 and B.4. As a result, the proofs of the following lemmas are almost completely identical to the proofs of Lemmas 4.4-4.7, respectively, and hence are omitted. Lemma B.1. After preprocessing, the valuation of each root agent r is at least cr/2. For all other agents i the valuation is at least ci. Lemma B.2. After step (a) of rounding, each tree component T has kT + 1 agents and kT goods for some kT ≥ 0. Lemma B.3. After rounding, each agent i that is assigned its parent good obtains a valuation of at least ci/2. Consider a zero-price tree T at the beginning of the step (b) of rounding with kT + 1 agents and kT goods. Assume kT ≥ 1 first. Let a1, g1, a2, g2, . . . , al, gℓ, aℓ+1 be the recursion path in T starting from the root agent a1 and ending at the leaf agent aℓ+1 such that a1, . . . , aℓ+1 became root agents of the trees formed recursively during the rounding step, and good gi is assigned to ai in this process, for 1 ≤ i ≤ ℓ. Note that aℓ+1 is not assigned any good in step (b) of rounding. However, it must have been assigned some good during step (a) of rounding. We denote by ki the number of children for agent ai, for 1 ≤ i ≤ ℓ. If kT = 0, then ℓ = 0 and a1 = aℓ+1 is the root of a tree containing no goods after step (a) of rounding. Lemma B.4. The product of the valuations of agents in T in the rounded solution is at least 2(cid:19)kT −ℓ+1 (cid:18) 1 · 1 k1 · · · kℓ ci . ·Yi∈T 34 References [1] N. Anari, S. O. Gharan, A. Saberi, and M. Singh. Nash social welfare, matrix permanent, and stable polynomials. In Proc. 8th Symp. Innovations in Theoret. Comput. Sci. (ITCS), 2017. [2] N. Anari, T. Mai, S. O. Gharan, and V. Vazirani. Nash social welfare for indivisible items under separable, piecewise-linear concave utilities. In Proc. 29th Symp. Discrete Algorithms (SODA), pages 2274 -- 2290, 2018. [3] N. Andelman and Y. Mansour. Auctions with budget constraints. In Proc. 9th Scandinavian Workshop Algorithm Theory (SWAT), pages 26 -- 38, 2004. [4] Y. Azar, B. Birnbaum, A. Karlin, C. Mathieu, and C. T. Nguyen. Improved approximation algorithms for budgeted allocations. In Proc. 35th Intl. Coll. Automata, Languages & Programming (ICALP), volume 1, pages 186 -- 197, 2008. [5] S. Barman, S. K. Krishnamurthy, and R. Vaish. Finding fair and efficient allocations. In Proc. 19th Conf. Econom. Comput. (EC), pages 557 -- 574, 2018. [6] X. Bei, J. Garg, M. Hoefer, and K. Mehlhorn. Computing equilibria in markets with budget- additive utilities. In Proc. 24th European Symp. Algorithms (ESA), pages 8:1 -- 8:14, 2016. [7] X. Bei, J. Garg, M. Hoefer, and K. Mehlhorn. Earning limits in Fisher markets with spending- constraint utilities. In Proc. 10th Symp. Algorithmic Game Theory (SAGT), pages 67 -- 79, 2017. [8] W. Brainard and H. Scarf. How to compute equilibrium prices in 1891. Cowles Foundation Discussion Paper, 1270, 2000. [9] N. Buchbinder, K. Jain, and J. Naor. Online primal-dual algorithms for maximizing ad-auctions revenue. In Proc. 15th European Symp. Algorithms (ESA), pages 253 -- 264, 2007. [10] D. Buchfuhrer, S. Dughmi, H. Fu, R. Kleinberg, E. Mossel, C. Papadimitriou, M. Schapira, In Proc. Inapproximability for VCG-based combinatorial auctions. Y. Singer, and C. Umans. 21st Symp. Discrete Algorithms (SODA), pages 518 -- 536, 2010. [11] I. Caragiannis, D. Kurokawa, H. Moulin, A. Procaccia, N. Shah, and J. Wang. The unreasonable fairness of maximum Nash welfare. In Proc. 17th Conf. Econom. Comput. (EC), pages 305 -- 322, 2016. [12] D. Chakrabarty and G. Goel. On the approximability of budgeted allocations and improved lower bounds for submodular welfare maximization and GAP. SIAM J. Comput., 39(6):2189 -- 2211, 2010. [13] B. Chaudhury, Y. K. Cheung, J. Garg, N. Garg, M. Hoefer, and K. Mehlhorn. On fair division for indivisible items. In Proc. 38th Conf. Foundations of Software Tech. and Theoret. Comput. Sci. (FSTTCS), pages 25:1 -- 25:17, 2018. [14] M. Chleb´ık and J. Chleb´ıkov´a. Approximation hardness for small occurrence instances of NP-hard problems. In Proc. 5th Intl. Conf. Algorithms and Complexity (CIAC), pages 152 -- 164, 2003. Full version ECCC-TR02-073, 2002. [15] R. Cole, N. Devanur, V. Gkatzelis, K. Jain, T. Mai, V. Vazirani, and S. Yazdanbod. Convex program duality, Fisher markets, and Nash social welfare. In Proc. 18th Conf. Econom. Comput. (EC), pages 459 -- 460, 2017. 35 [16] R. Cole and V. Gkatzelis. Approximating the Nash social welfare with indivisible items. SIAM J. Comput., 47(3):1211 -- 1236, 2018. [17] R. Cottle, J.-S. Pang, and R. Stone. The Linear Complementarity Problem. Academic Press, Boston, 1992. [18] A. Darmann and J. Schauer. Maximizing Nash product social welfare in allocating indivisible goods. Europ. J. Oper. Res., 247(2):548 -- 559, 2015. [19] C. Daskalakis and C. Papadimitriou. Continuous local search. In Symp. Discrete Algorithms (SODA), pages 790 -- 804, 2011. [20] N. Devanur, J. Garg, and L. V´egh. A rational convex program for linear Arrow-Debreu markets. ACM Trans. Econom. Comput., 5(1):6:1 -- 6:13, 2016. [21] N. Devanur, K. Jain, B. Sivan, and C. Wilkens. Near optimal online algorithms and fast approxi- mation algorithms for resource allocation problems. J. ACM, 66(1):7:1 -- 7:41, 2019. [22] N. Devanur, C. Papadimitriou, A. Saberi, and V. Vazirani. Market equilibrium via a primal -- dual algorithm for a convex program. J. ACM, 55(5):22:1 -- 22:18, 2008. [23] R. Duan, J. Garg, and K. Mehlhorn. An improved combinatorial polynomial algorithm for the linear Arrow-Debreu market. In Proc. 27th Symp. Discrete Algorithms (SODA), pages 90 -- 106, 2016. [24] R. Duan and K. Mehlhorn. A combinatorial polynomial algorithm for the linear Arrow-Debreu market. Inf. Comput., 243:112 -- 132, 2015. [25] E. Eisenberg and D. Gale. Consensus of subjective probabilities: The Pari-Mutuel method. Ann. Math. Stat., 30(1):165 -- 168, 1959. [26] M. Feldman, N. Gravin, and B. Lucier. Combinatorial Walrasian equilibrium. SIAM J. Comput., 45(1):29 -- 48, 2016. [27] R. Freeman, S. Zahedi, and V. Conitzer. Fair and efficient social choice in dynamic settings. In Proc. 26th Intl. Joint Conf. Artif. Intell. (IJCAI), pages 4580 -- 4587, 2017. [28] D. Gale. Theory of Linear Economic Models. McGraw Hill, 1960. [29] J. Garg, M. Hoefer, and K. Mehlhorn. Approximating the Nash social welfare with budget-additive valuations. In Proc. 29th Symp. Discrete Algorithms (SODA), pages 2326 -- 2340, 2018. [30] J. Garg, R. Mehta, M. Sohoni, and V. Vazirani. A complementary pivot algorithm for market equilibrium under separable, piecewise-linear concave utilities. SIAM J. Comput., 44(6):1820 -- 1847, 2015. [31] J. Garg, R. Mehta, and V. Vazirani. Dichotomies in equilibrium computation, and complementary pivot algorithms for a new class of non-separable utility functions. In Proc. 46th Symp. Theory of Comput. (STOC), pages 525 -- 534, 2014. [32] J. Garg, R. Mehta, and V. Vazirani. Substitution with satiation: A new class of utility functions and a complementary pivot algorithm. Math. Oper. Res., 43(3):996 -- 1024, 2018. [33] J. Garg and L. V´egh. A strongly polynomial algorithm for linear exchange markets. In Proc. 51st Symp. Theory of Comput. (STOC), 2019. To appear. 36 [34] K. Jain. A polynomial time algorithm for computing the Arrow-Debreu market equilibrium for linear utilities. SIAM J. Comput., 37(1):306 -- 318, 2007. [35] C. Kalaitzis. An improved approximation guarantee for the maximum budgeted allocation prob- lem. In Proc. 27th Symp. Discrete Algorithms (SODA), pages 1048 -- 1066, 2016. [36] M. Kaneko and K. Nakamura. The Nash social welfare function. Econometrica, 47(2):423 -- 436, 1979. [37] F. Kelly. Charging and rate control for elastic traffic. European Transactions on Telecommunica- tions, 8:33 -- 37, 1997. [38] E. Lee. APX-hardness of maximizing Nash social welfare with indivisible items. Inf. Process. Lett., 122:17 -- 20, 2017. [39] A. Mehta. Online matching and ad allocation. Foundations and Trends in Theoretical Computer Science, 8(4):265 -- 368, 2012. [40] A. Mehta, A. Saberi, U. Vazirani, and V. Vazirani. Adwords and generalized online matching. J. ACM, 54(5), 2007. [41] H. Moulin. Axioms of Cooperative Decision Making. Cambridge University Press, 1988. [42] H. Moulin. Fair Division and Collective Welfare. MIT Press, 2003. [43] J. Nash. The bargaining problem. Econometrica, 18(2):155 -- 162, 1950. [44] N. Nguyen, T. T. Nguyen, M. Roos, and J. Rothe. Computational complexity and approximability of social welfare optimization in multiagent resource allocation. Autonom. Agents & Multi-Agent Syst., 28(2):256 -- 289, 2014. [45] J. Orlin. Improved algorithms for computing Fisher's market clearing prices. In Proc. 42nd Symp. Theory of Comput. (STOC), pages 291 -- 300, 2010. [46] S. Ramezani and U. Endriss. Nash social welfare in multiagent resource allocation. In Agent- Mediated Electronic Commerce. Designing Trading Strategies and Mechanisms for Electronic Mar- kets, pages 117 -- 131. Springer Verlag, 2010. [47] T. Roughgarden and I. Talgam-Cohen. Why prices need algorithms. In Proc. 16th Conf. Econom. Comput. (EC), pages 19 -- 36, 2015. [48] V. Shmyrev. An algorithm for finding equilibrium in the linear exchange model with fixed budgets. J. Appl. Indust. Math., 3(4):505 -- 518, 2009. [49] A. Srinivasan. Budgeted allocations in the full-information setting. In Proc. 11th Workshop Approximation Algorithms for Combinatorial Optimization Problems (APPROX), pages 247 -- 253, 2008. [50] M. Todd. Orientation in complementary pivot algorithms. Math. Oper. Res., 1(1):54 -- 66, 1976. [51] L. V´egh. Concave generalized flows with applications to market equilibria. Math. Oper. Res., 39(2):573 -- 596, 2014. [52] Y. Ye. Exchange market equilibria with Leontief's utility: Freedom of pricing leads to rationality. Theoret. Comput. Sci., 378(2):134 -- 142, 2007. 37
1903.06601
1
1903
2019-03-15T15:31:47
Dynamic Planar Point Location in External Memory
[ "cs.DS" ]
In this paper we describe a fully-dynamic data structure for the planar point location problem in the external memory model. Our data structure supports queries in $O(\log_B n(\log\log_B n)^3))$ I/Os and updates in $O(\log_B n(\log\log_B n)^2))$ amortized I/Os, where $n$ is the number of segments in the subdivision and $B$ is the block size. This is the first dynamic data structure with almost-optimal query cost. For comparison all previously known results for this problem require $O(\log_B^2 n)$ I/Os to answer queries. Our result almost matches the best known upper bound in the internal-memory model.
cs.DS
cs
Dynamic Planar Point Location in External Memory J. Ian Munro∗ Yakov Nekrich† Abstract In this paper we describe a fully-dynamic data structure for the planar point location problem in the external memory model. Our data structure supports queries in O(logB n(log logB n)3)) I/Os and updates in O(logB n(log logB n)2)) amortized I/Os, where n is the number of seg- ments in the subdivision and B is the block size. This is the first dynamic data structure with almost-optimal query cost. For comparison all previously known results for this problem require O(log2 B n) I/Os to answer queries. Our result almost matches the best known upper bound in the internal-memory model. 9 1 0 2 r a M 5 1 ] S D . s c [ 1 v 1 0 6 6 0 . 3 0 9 1 : v i X r a ∗Cheriton School of Computer Science, University of Waterloo. Email [email protected]. †Cheriton School of Computer Science, University of Waterloo. Email: [email protected]. 1 Introduction Planar point location is a classical computational geometry problem with a number of important applications. In this problem we keep a polygonal subdivision Π of the two-dimensional plane in a data structure; for an arbitrary query point q, we must be able to find the face of Π that contains q. In this paper we study the dynamic version of this problem in the external memory model. We show that a planar subdivision can be maintained under insertions and deletions of edges, so that the cost of queries and updates is close to O(logB n), where n is the number of segments in the subdivision and B is the block size. Planar point location problem was studied extensively in different computational models. Dy- namic internal-memory data structures for general subdivisions were described by Bentley [11], Cheng and Janardan [16], Baumgarten et al. [9], Arge et al. [3], and Chan and Nekrich [13]. Ta- ble 1 lists previous results. We did not include in this table many other results for special cases of the point location problem, such as the data structures for monotone, convex, and orthogonal subdivisions, e.g., [26, 27, 18, 17, 21, 20, 14]. The currently best data structure [13] achieves1 O(log n) query time and O(log1+ε n) update time or O(log1+ε n) query time and O(log n) update time; the best query-update trade-off described in [13] is O(log n log log n) randomized query time and O(log n log log n) update time. See Table 1. In the external memory model [2] the data can be stored in the internal memory of size M or on the external disk. Arithmetic operations can be performed only on data in the internal memory. Every input/output operation (I/O) either reads a block of B contiguous words from the disk into the internal memory or writes B words from the internal memory into disk. Measures of efficiency in this model are the number of I/Os needed to solve a problem and the amount of used disk space. Goodrich et al. [22] presented a linear-space static external data structure for point location in a monotone subdivision with O(logB n) query cost. Arge et al. [5] designed a data structure for a general subdivison with the same query cost. Data structures for answering a batch of point location queries were considered in [22] and [8]. Only three external-memory results are known for the dynamic case. The data structure of Agarwal, Arge, Brodal, and Vitter [1] supports queries on monotone subdivisions in O(log2 B n) I/Os amortized. Arge and Vahrenhold [7] considered the case of general subdivisons; they retain the same cost for queries and insertions as [1] and reduce the deletion cost to O(logB n). Arge, Brodal, and Rao [4] reduced the insertion cost to O(logB n). Thus all previous dynamic data structures did not break O(log2 B n) query cost barrier. For comparison the first internal-memory data structure with query time close to logarithmic was presented by Baumgarten et al [9] in 1994. See Table 2. All previous data structures use O(n) words of space (or O(n/B) blocks of B words2). B n) I/Os and updates in O(log2 In this paper we show that it is possible to break the O(log2 B n) barrier for the dynamic point location problem. Our data structure answers queries in O(logB n(log logB n)3) I/Os, supports updates in O(logB n(log logB n)2) I/Os amortized, and uses linear space. Thus we achieve close to logarithmic query cost and a query-update trade-off almost matching the state-of-the-art upper bounds in the internal memory model. Our result is within double-logarithmic factors from optimal. Additionally we describe a data structure that supports point location queries in an orthogonal subdivision with O(logB n log logB n) query cost and O(logB n log logB n) amortized update cost. 1In this paper log n denotes the binary logarithm of n when the logarithm base is not specified. 2Space usage of external-memory data structures is frequently measured in disk blocks of B words. In this paper we measure the space usage in words. But the space usage of O(n) words is equivalent to O(n/B) blocks of space. 1 Reference Bentley [11] Cheng -- Janardan [16] Baumgarten et al. [9] Arge et al. [3] Arge et al. [3] Chan and Nekrich [13] Chan and Nekrich [13] Chan and Nekrich [13] Chan and Nekrich [13] Chan and Nekrich [13] Space Query Time n log n log2 n log2 n log n log log n log n log n log n(log log n)2 log n log n log1+ε n log n log log n n n n n n n n n n Insertion Time log2 n log n log n log log n log1+ε n log n(log log n)1+ε log n log log n log1+ε n log1+ε n log n log n log log n Deletion Time log2 n log n log2 n log2+ε n log2 n/ log log n log n log log n log1+ε n log n(log log n)1+ε log n log n log log n † † †‡∗ ∗ ‡∗ Table 1: Previous results on dynamic planar point location in internal memory. Entries marked † and ‡ require amortization and (Las Vegas) randomization respectively, ε > 0 is an arbitrarily small constant. Results marked ∗ are in the RAM model, all other results are in the pointer machine model. Space usage is measured in words. Reference Space Query Cost Agarwal et al [1] Arge and Vahrenhold [7] Arge et al [4] This paper This paper n n n n n B n B n B n log2 log2 log2 logB n(log logB n)3 logB n log logB n Insertion Cost log2 B n log2 B n logB n logB n(log logB n)2 logB n log logB n Deletion Cost log2 M B n G logB n logB n G logB n(log logB n)2 G logB n log logB n O Table 2: Previous and new results on dynamic planar point location in external memory. G denotes most general subdivisions, M denotes monotone subdivision, and O denotes orthogonal subdivision. Space usage is measured in words and update cost is amortized. The computational model used in this paper is the standard external memory model [2]. 2 Overview 2.1 Overall Structure As in the previous works, we concentrate on answering vertical ray shooting queries. The successor segment of a point q in a set S of non-intersecting segments is the first segment that is hit by a ray emanating from q in the +y-direction. Symmetrically, the predecessor segment of q in S is the first segment hit by a ray emanating from q in the −y direction. A vertical ray shooting query for a point q on a set of segments S asks for the successor segment of q in S. If we know the successor segment or the predecessor segment of q among all segments of a subdivision Π, then we can answer a point location query on Π (i.e., identify the face of Π containing q) in O(logB n) I/Os [7]. In the rest of this paper we will show how to answer vertical ray shooting queries on a dynamic set of non-intersecting segments. Our base data structure is a variant of the segment tree. Let S be a set of segments. We store a tree T on x-coordinates of segment endpoints. Every leaf contains Θ(B) segment endpoints and every internal node has r = Θ(Bδ) children for δ = 1/8. Thus the height of T is O(logB n). We 2 Figure 1: Segment s is assigned to node u. The trimmed segment [pf , pl] is stored in C(u). associate a vertical slab with every node u of T . The slab of the root node is [xmin, xmax]×R, where xmin and xmax denote the x-coordinates of the leftmost and the rightmost segment endpoints. The slab of an internal node u is divided into Θ(Bδ) slabs that correspond to the children of u. A segment s spans the slab of a node u (or simply spans u) if it crosses its vertical boundaries. A segment s is assigned to an internal node u, if s spans at least one child ui of u but does not span u. We assign s to a leaf node (cid:96) if at least one endpoint of s is stored in (cid:96). All segments assigned to a node u are trimmed to slab boundaries of children and stored in a multi-slab data structure C(u): Suppose that a segment s is assigned to u and it spans the children uf , . . ., ul of u. Then we store the segment su = [pf , pl] in C(u), where pf is the point where s intersect the left slab boundary of uf and pl is the point where s intersects the right boundary of ul. See Fig. 1. Each segment is assigned to O(logB n) nodes of T . In order to answer a vertical ray shooting query for a point q, we identify the leaf (cid:96) such that the slab of (cid:96) contains q. Then we visit all nodes u on the path π(cid:96) from the root of T to (cid:96) and answer vertical ray shooting queries in multi-slab structures C(u). 2.2 Our Approach Thus our goal is to answer O(logB n) ray shooting queries in multi-slab structures along a path in the segment tree T with as few I/Os as possible. Segments stored in a multi-slab are not comparable in the general case; see Fig. 2. It is possible to impose a total order ≺ on all segments in the following sense: let l be a vertical line that intersects segments s1 and s2; if the intersection of l with s1 is above the intersection of l with s2, then s2 ≺ s1. We can find such a total order in O((K/B) logM/B K) I/Os, where K is the number of segments [8, Lemma 3]. But this ordering is not stable under updates: even a single deletion and a single insertion can lead to significant changes in the order of segments. See Fig. 2. Therefore it is hard to apply standard techniques, such as fractional cascading [15, 25], in order to speed-up ray shooting queries. Previous external- memory solutions in [1, 4] essentially perform O(logB n) independent searches in the nodes of a segment tree or an interval tree in order to answer a query. Each search takes O(logB n) I/Os, hence the total query cost is O(log2 B n). Internal memory data structures achieve O(log n) query cost using dynamic fractional cascad- ing [15, 25]. Essentially the difference with external memory is as follows: since we aim for O(log2 n) 3 pfplu1u2u3u4u5us Figure 2: Left: example of segment order in a multi-slab; s1≺ s2≺ s3≺ s4≺ s5≺ s6≺ s7≺ s8≺ s9. Right: a deletion and an insertion of one new segment in a multi-slab changes the order of segments to s7≺ s8≺ s9≺ s0≺ s1≺ s2≺ s3≺ s4≺ s5. query cost in internal memory, we can afford to use base tree T with small node degree. In this special case the segments stored in sets C(u), u ∈ T , can be ordered resp. divided into a small number of ordered sets. When the order of segments in C(u) is known, we can apply the fractional cascading technique [15, 25] to speed up queries. Unfortunately dynamic fractional cascading does not work in the case when the total order of segments in C(u) is not known. Hence we cannot use previous internal memory solutions of the point location problem [16, 9, 3, 13] to decrease the query cost in external memory. In this paper we propose a different approach. Searching in a multi-slab structure C(u) is based on a weighted search among segments of C(u). Weights of segments are chosen in such way that the total cost of searching in all multi-slab structures along a path π is logarithmic. We also use fractional cascading, but this technique plays an auxiliary role: we apply fractional cascading to compute the weights of segments and to navigate between the tree nodes. Interestingly, fractional cascading is usually combined with the union-split-find data structure, which is not used in our construction. This paper is structured as follows. In Section 3 we show how our new technique, that will be henceforth called weighted telescoping search, can be used to solve the static vertical ray shooting problem. Next we turn to the dynamic case. In our exposition we assume, for simplicity, that the set of segment x-coordinates is fixed, i.e., the tree T does not change. We also assume that the block size B is sufficiently large, B > log8 n. We show how our static data structure from Section 3 can be modified to support insertions in Section 4. To maintain the order of segments in a multi-slab under insertions we pursue the following strategy: when a new segment is inserted into the multi-slab structure C(u), we split it into a number of unit segments, such that every unit segment spans exactly one child of u. Unit segments can be inserted into a multi-slab so that the order of other segments is not affected. The number of unit segments per inserted segment can be large; however we can use buffering to reduce the cost of updates.3 We need to make some further changes in our data structure in order to support deletions; the fully-dynamic solution for large B is described in Section 5. The main result of Section 5, summed up in Lemma 2, is 3As a side remark, this approach works with weighted telescoping search, but it would not work with the standard fractional cascading used in internal-memory solutions [16, 9, 3, 13]. The latter technique relies on a union-split-find data structure (USF) and it is not known how to combine buffering with USF. 4 s9s8s7s6s5s4s3s2s1s9s8s7s5s4s3s2s1s0 the data structure that answers queries in O(logB n log logB n) I/Os; insertions and deletions are supported in O(log2 B n) and O(logB n) amortized I/Os respectively. We show how to reduce the cost of insertions and the space usage in Sections 6 and Appendix A respectively. We address some missing technical details and consider the case of small block size B in Section 7. The special case of vertical ray shooting among horizontal segments is studied in Appendix B. Appendix C provides an alternative introduction to the weighted telescoping search by explaining how this technique works in a simplified scenario. This section is not used in the rest of the paper; the sole purpose of Appendix C is to provide an additional explanation for the weighted telescoping search. 3 Ray Shooting: Static Structure In this section we show how the weighted telescoping search can be used to solve the static point location problem. Let T be the tree, defined in Section 2.1, with node degree r = Bδ for δ = 1/8. Let C(u) be the set of segments that span at least one child of u but do not span u. Augmented Catalogs. We keep augmented catalogs AC(u) ⊃ C(u) in every node u. Each AC(u) is divided into subsets ACij(u) for 1 ≤ i ≤ j ≤ r; ACij(u) contains segments that span children ui, . . ., uj of u and only those children. Augmented catalogs AC(u) satisfy the following properties: (i) If a segment s ∈ (AC(u) \ C(u)), then s ∈ C(v) for an ancestor v of u and s spans u. (ii) Let Ei(u) = AC(u)∩ AC(ui) for a child ui of u. For any f and l, f ≤ i ≤ l, there are at most (iii) If i (cid:54)= j, then Ei(u) ∩ Ej(u) = ∅. d = O(r4) elements of ACf l(u) between any two consecutive elements of Ei(u). Elements of Ei(u) for some 1 ≤ i ≤ r will be called down-bridges; elements of the set U P (u) = AC(u) ∩ AC(par (u)), where par (u) denotes the parent node of u, are called up-bridges. We will say that a sub-list of a catalog AC(u) bounded by two up-bridges is a portion of AC(u). We refer to e.g., [3] or [13] for an explanation how we can construct and maintain AC(u). We assume in this section that all segments in every catalog AC(u) are ordered. We can easily order a set ACf l(u) or any set of segments that cross the same vertical line (cid:96): the order of segments is determined by (y-coordinates of) intersection points of segments and (cid:96). Therefore we will speak of e.g., the largest/smallest segments in such a set. bridge in Ei(u) that is (strictly) larger than s; we let W (s1, s2, ui) =(cid:80) example. We set weight(s, u) = (cid:80)l Element weights. We assign the weight to each element of AC(u) in a bottom-to-top manner: All segments in a set AC((cid:96)) for every leaf node (cid:96) are assigned weight 1. Consider a segment s ∈ ACf l(u), i.e., a segment that spans children uf , . . ., ul of some internal node u. For f ≤ i ≤ l let s1 denote the largest bridge in Ei(u) that is (strictly) smaller than s and let s2 denote the smallest weight(s(cid:48), ui), where the sum is over all segments s(cid:48) ∈ AC(ui) and weighti(s, u) = W (s1, s2, ui)/d. See Fig. 3 for an i=f weighti(s, u). We keep a weighted search tree for every portion P(u) of the list AC(u) By a slight misuse of notation this tree will also be denoted by P(u). Thus every catalog AC(u) is stored in a forest of weighted trees Pj(u) where every tree corresponds to a portion of AC(u) 4. We also store a data structure supporting finger searches on AC(u). s1<s(cid:48)<s2 4In most cases we will omit the subindex and will speak of a weighted tree P(u) because it will be clear from the context what portion of AC(u) is used. 5 Figure 3: Computation of segment weights. Left: segments s1 and s2 are down-bridges from E2(u). Segments s3, s4, s5, s6, and s7 are in AC(u)\E2(u). For 3 ≤ j ≤ 7, weight2(sj, u) = W (s1, s2, u2)/d. Right: portion of AC(u2) for the child u2 of u. W (s1, s2, u2) is equal to the total weight of all segments between s1 and s2. If u2 is a leaf node, then W (s1, s2, u2) equals the total number of segments in AC(u2) that are situated between s2 and s1. Weighted Trees. Each weighted search tree is implemented as a biased (a, b)-tree with param- eters a = Bδ/2 and b = Bδ [10, 19]. The depth of a leaf λ in a biased (Bδ/2, Bδ)-tree is bounded by O(logB(W/wλ)), where wλ is the weight of an element in the leaf λ and W is the total weight of all elements in the tree. Every internal node ν has Bδ children and every leaf holds Θ(B) segments5. In each internal node ν we keep B3δ segments ν. maxjk[i]. For every child νi of ν and for all j and k, 1 ≤ j ≤ k ≤ r, ν. maxjk[i] is the highest segment from ACjk in the subtree of νi ; if there are no segments from ACjk in the subtree of νi, then ν. maxjk[i] = NULL. Using values of ν. max we can find, for any node ν of the biased search tree, the child νi of ν that holds the successor segment of the query point q. Hence we can find the smallest segment n(u) in a portion P(u) that is above a query point q in O(logB(WP /ωn)) I/Os where WP is the total weight of all segments in P(u) and ωn is the weight of n(u). Additional Structures. When the segment n(u) is known, we will need to find the bridges that are closest to n(u) in order to continue the search. We keep a list Vi(u) ⊆ AC(u) for each node u and for every i, 1 ≤ i ≤ r. Vi(u) contains all segments of Ei(u) and some additional segments chosen as follows: AC(u) is divided into groups so that each group consists of Θ(r6) consecutive segments; the only exception is the last group in AC(u) that contains O(r6) segments (here we use the fact that segments in AC(u) are ordered). We choose the constant in such way that every group but the last one contains d · r2 segments. If a group G contains a segment that spans ui, then we select the highest segment from G that spans ui and the lowest segment from G that spans ui; we store both segments in Vi. See Fig. 4. For every segment in Vi we also store a pointer to its group in AC(u). We keep Vi in a B-tree that supports finger search queries. Suppose that we know the successor segment n(u) of a query point q in AC(u). We can find the successor segment bn(u) of q in Ei(u) using Vi: Let G denote the group that contains n(u). We search in G for the segment bn(u) ≥ n(u) using finger search. If bn(u) is not in G, we consider 5In the standard biased (a, b)-tree [10, 19], every leaf holds one element. But we can modify it so that every leaf holds Θ(B) different elements (segments). The weight of a leaf λ is the total weight of all segments stored in λ. 6 s7s6s5s4s3s1s2s1s2 Figure 4: Segments in a group. Segments s1, s2, and s3 are stored in V2: s1 and s2 are the highest and the lowest segments that span the second child u2; s3 is a bridge segment from E2(u). the highest segment s1 ∈ G that spans ui. By definition of AC(u), there are at most dr2 segments between n(u) and bn(u). We can find bn(u) in O(logB(dr2)) = O(1) I/Os by finger search on Vi using s1 as the finger. Using a similar procedure, we can find the highest bridge segment bp(u) ≤ n(u) in Ei(u). Queries. A vertical ray shooting query for a point q = (qx, qy) is answered as follows. Let (cid:96) denote the leaf such that the slab of (cid:96) contains q. We visit all nodes v0, v1, . . ., vh on the root-to-leaf path π((cid:96)) where v0 is the root node and vh = (cid:96). We find the segment n(vi) in every visited node, where n(vi) is the successor segment of q in AC(vi). Suppose that vi+1 is the j-th child of vi; n(vi) spans the j-th child of vi. First we search for n(v0) in the weighted tree of AC(v0). Next, using the list Vj, we identify the smallest bridge bn(v0) ∈ Ej(v0) such that bn(v0) ≥ n(v0) and the largest bridge segment bp(v0) ∈ Ej(v0) such that bp(v0) ≤ n(v0). The index j is chosen so that v1 is the j-th child of v0. We execute the same operations in nodes v1, . . ., vh. When we are in a node vi we consider the portion P(vi) between bridges bp(vi−1) and bn(vi−1); we search in the weighted tree of P(vi) for the successor segment n(vi) of q. Then we identify the lowest bridge bn(vi) ≥ n(vi) and the highest bridge bp(vi) ≤ n(vi). When all n(vi) are computed, we find the lowest segment n∗ among n(vi). Since ∪h The cost of a ray shooting query can be estimated as follows. Let ωi denote the weight of n(vi). Let Wi denote the total weight of all segments of P(vi) (we assume that P(v0) = AC(v0)). Search for n(vi) in the weighted tree P(vi) takes O(logB(Wi/ωi)) I/Os. By definition of weights, ωi ≥ Wi+1/d. Hence h(cid:88) h−1(cid:88) (logB Wi+1 − logB ωi) − logB ωh ≤ logB(W0/ωh) + 2(h + 1) logB r. logB(Wi/ωi) = logB W0 + i=0AC(vi) = ∪h i=0C(vi), n∗ is the successor segment of a query point q. i=0 i=0 We have ωh = 1 and we will show below that W0 ≤ n. Since r = Bδ, h = O(logB n) and logB r = O(1). Hence the sum above can be bounded by O(logB n). When n(vi) is known, we can find bp(vi) and bn(vi) in O(1) I/Os, as described above. Hence the total cost of answering a query is O(logB n). Since every segment is stored in O(logB n) lists AC(u), the total space usage is O(n logB n). It remains to prove that W0 ≤ n. We will show by induction that the total weight of all elements 7 s2s3s1 Figure 5: Example from Fig. 2 revisited. Left: original segment order s1≺ s2≺ s3≺ s4≺ s5≺ s6≺ s7≺ s8≺ s9. Right: segment s6 is deleted, the new inserted segment s0 is split into unit segments. The new segment order is e.g., s0,3≺ s1≺ s2≺ s4≺ s5≺ s0,2≺ s7≺ s8≺ s9≺ s0,1. Thus new unit segments are inserted, but the relative order of other segments does not change. on every level of T is bounded by n: Every element in a leaf node has weight 1; hence their total weight does not exceed n. Suppose that, for some k ≥ 1, the total weight of all elements on level k− 1 does not exceed n. Consider an arbitrary node v on level k, let v1, . . ., vr be the children of v, and let mi denote the total weight of elements in AC(vi). Every element in AC(vi) contributes 1/d e∈AL(v) weighti(v) ≤ mi i=1 mi. Hence, for any level k ≥ 1, the total weight of AC(v) for all nodes v on level k does not exceed n. Hence the total weight of AC(u0) for the root node u0 is also bounded by n. fraction of its weight to at most d different elements in AC(v). Hence(cid:80) and the total weight of all elements in AC(v) does not exceed(cid:80)r Lemma 1 There exists an O(n logB n)-space static data structure that supports point location queries on n non-intersecting segments in O(logB n) I/Os. The result of Lemma 1 is not new. However we will show below that the data structure described in this section can be dynamized. 4 Semi-Dynamic Ray Shooting for B ≥ log8 n: Main Idea In Sections 4 and 5 we will assume6 that B ≥ log8 n. Now we turn to the dynamic problem. Overview. The main challenge in dynamizing the static data structure from Section 3 is the order of segments. Deletions and insertions of segments can lead to significant changes in the segment order, as explained in Section 2. However segment insertions within a slab are easy to handle in one special case. We will say that a segment s ∈ AC(u) is a unit segment if s ∈ ACii(u) for some 1 ≤ i ≤ r. In other words a unit segment spans exactly one child ui of u. Let Li(u) = ∪f≤i≤lACf l(u) denote the conceptual list of all segments that span ui. When a unit segment s ∈ ACii(u) is inserted, we find the segments sp and sn that precede and follow s in Li(u); we insert s at an arbitrary position in AC(u) so that sp < s < sn. It is easy to see that the correct order of segments is maintained: the correct order is maintained for the segments that span ui and other segments are not affected. 6Probably a smaller power of log can be used, but we consider B ≥ log8 n to simplify the analysis. 8 s9s8s7s6s5s4s3s2s1s9s8s7s5s4s3s2s1s0s0,3s0,2s0,1 An arbitrary segment s that is to be inserted into AC(u) can be represented as Bδ unit segments. See Fig. 5 for an example. However we cannot afford to spend Bδ operations for an insertion. To solve this problem, we use bufferization: when a segment is inserted, we split it into Bδ unit segments and insert them into a buffer B. A complete description of the update procedure is given below. Buffered Insertions. We distinguish between two categories of segments, old segments and new segments. We know the total order in the set of old segments in the portion P(u) (and in the list AC(u)). New segments are represented as a union of up to r unit segments. When the number of new segments in a portion P(u) exceeds the threshold that will be specified below, we re-build P(u): we compute the order of old and new segments and declare all segments in P(u) to be old. As explained in Section 3 every portion P(u) of AC(u) is stored in a biased search tree data structure. Each node of P(u) has a buffer B(ν) that can store up to B3δ segments. When a new segment is inserted into P(u), we split it into unit segments and add them to the insertion buffer of νr, where νr is the root node of P(u). When the buffer of an internal node ν is full, we flush it, i.e., we move all segments from B(ν) to buffers in the children of ν. We keep values ν. maxkj[i], defined in Section 3, for all internal nodes ν. All ν. maxkl[·] and all segments in B(ν) fit into one block of memory; hence we can flush the buffer of an internal node in O(Bδ) I/Os. When the buffer of an internal node is flushed, we do not change the shape of the tree. When the buffer B(λ) of a leaf node λ is full, we insert segments from B(λ) into the set of segments stored in λ. If necessary we create a new leaf λ(cid:48) and update the weights of λ and λ(cid:48). We can update the biased search tree P(u) in O(log n) time. We also update data structures Vi for i = 1, . . ., r. Since a leaf node contains the segments from at most two different groups, we can update all Vi in O(r) I/Os. The biased tree is updated in O(log n) I/Os. The total amortized cost of a segment insertion into a portion P(u) is O(1 + log n+r When the number of new segments in P(u) is equal to nold/r, where nold is the number of old segments in P(u), we rebuild P(u). Using the method from [8], we order all segments in P(u) and update the biased tree. Sorting of segments takes O((nold/B) logM/B nold) = o(nold) I/Os. We can re-build the weighted tree P(u) in O((nold/B3δ) log nold) = o(nold) I/Os by computing the weights of leaves and inserting the leaves into the new tree one-by-one. When a new segment s is inserted, we identify all nodes ui where s must be stored. For every corresponding list AC(ui), we find the portion P(ui) where s must be stored. This takes O(log2 B n) I/Os in total. Then we insert the trimmed segment s into each portion as described above. The total insertion cost is O(log2 B n). Queries are supported in the same way as in the static data structure described in Section 3. The only difference is that biased tree nodes have associated buffers. Many technical aspects are not addressed in this section. We fill in the missing details and provide the description of the data structure that also supports deletions in Section 5. B2δ ) = O(1) because Bδ > log n. B3δ + logB n 5 Ray Shooting for B ≥ log8 n: Fully-Dynamic Structure Now we give a complete description of the fully-dynamic data structure for vertical ray shooting queries. Deletions are also implemented using bufferization: deleted segments are inserted into deletion buffers D(ν) that are kept in the nodes of trees P(u). Deletion buffers are processed similarly to the insertion buffers. There are, however, a number of details that were not addressed in the previous section. When a new bridge Ei is inserted we need to change weights for a number of segments. When the segment n(u) is found, we need to find the bridges bp(u) and bn(u). The 9 complete solution that addresses all these issues is more involved. First, we apply weighted search only to segments from E(u) = ∪r i=1Ei(u). We complete the search and find the successor segment in AC(u) using some auxiliary sets stored in the nodes of P(u). Second, we use a special data structure to find the bridges bp(u) and bn(u). We start by describing the changed structure of weighted trees P(u). Segments stored in the leaves of P(u) are divided into weighted and unweighted segments. Weighted segments are segments from E(u), i.e., weighted segments are used as down-bridges. All other segments are unweighted. Every leaf contains Θ(r2) weighted segments. There are at Ω(r2) and O(r4) unweighted segments between any two weighted segments. Hence the total number of segments in a leaf is between Ω(r4) and O(r6). Only weighted segments in a leaf have non-zero weights. Weights of weighted segments are computed in the same way as explained in Section 3. Hence the weight of a leaf λ is the total weight of all weighted segments in λ. The search for a successor of q in P(u) is organized in such way that it ends in the leaf holding the successor of q in E(u). Then we can find the successor of q in AC(u) using auxiliary data stored in the nodes of P(u). We keep the following auxiliary sets and buffers in nodes ν of every weighted tree P(u). Let ACf l(u, ν) denote the set of segments from ACf l(u) that are stored in leaf descendants of a node ν. (i) Sets Maxf l(ν) and Minf l(ν) for all f, l such that 1 ≤ f ≤ l ≤ r and for all nodes ν. Maxf l(ν) (Minf l(ν)) contains min(r4,ACf l(u, ν)) highest (lowest) segments from ACf l(u, ν). For ev- ery segment s in sets Maxf l(ν) and Minf l(ν) we record the index i such that s ∈ Ei(u) (or NULL if s is not a bridge segment). (ii) The set Nav(ν) for an internal node ν is the union of all sets Maxf l(νi) and Minf l(νi) for all f l(ν), 1 ≤ f ≤ l ≤ r contains highest segments from ACf l(u, ν) that are not (iii) The set Max(cid:48) f l(ν) holds at least r4 and at f l(ρ) for all descendants f l(·) are organized as external priority search trees [6]. f l(ν) is defined in the same way with respect to the lowest segments. We use children νi of ν. stored in any set Max(cid:48)(u, µ) for an ancestor µ of ν. Either Max(cid:48) most 2r4 segments or Max(cid:48) ρ of ν are empty. In other words, Max(cid:48) The set Min(cid:48) Max(cid:48) and Min(cid:48) to maintain sets Max and Min. f l(ν) holds less than r4 segments and Max(cid:48) (iv) Finally we keep an insertion buffer B(ν) and a deletion buffer D(ν) in every node ν. Deletions. If an old segment s is deleted, we insert it into the deletion buffer D(νR) of the root node νR. If a new segment s is deleted, we split s into O(r) unit segments and insert them into D(νR). When one or more segments are inserted into D(νr), we also update sets Maxf l(νR) and Minf l(νR). For any node ν ∈ P(u), when the number of segments in D(ν) exceeds r3, we flush both D(ν) and B(ν) using the following procedure. First we identify segments s ∈ B(ν)∩D(ν) and remove such s from both B(ν) and D(ν). Next we move segments from B(ν) and D(ν) to buffers B(νi) and D(νi) in the children νi of ν. For every child νi of ν, first we update sets M ax(cid:48) f l(νi) by removing segments from D(νi) (resp. inserting segments from B(νi)) if necessary. Then we take care that the size of Max(cid:48) f l(νi) contains less than r4 segments and more than 0 segments, we move up segments from the children of νi into νi, so that the total size f l(·) of Max(cid:48) f l(·) in each child of νi using the in the children of νi into Max(cid:48) same procedure. f l(νi) becomes equal to 2r4 or all segments are moved from the corresponding sets Max(cid:48) f l(νi) is not too small. If some Max(cid:48) f l(νi). We recursively update Max(cid:48) 10 r3 r3 ) = o(1). f l(ν) or from Max(cid:48) Next, we update sets Maxf l(νi). We compute Mf l = ∪ Max(cid:48) f l(µ) where the union is taken over all proper ancestors µ of ν. Every segment in Maxf l(ν) is either from Max(cid:48) f l(µ) for a proper ancestor µ of ν. Hence we can compute all Maxf l(νi) when Mf l and Max(cid:48) f l(νi) are known. Sets Min(cid:48) f l(νi) and Minf l(νi) are updated in the same way. Finally we update the set Nav(ν) by collecting segments from Maxf l(νi) and Minf l(νi). All segments needed to re-compute sets after flushing buffers D(ν) and B(ν) fit into one block of space. Hence we can compute the set M in O(logB n) = O(r) I/Os and all sets in each node νi in O(1) I/Os. The set Nav(ν) is updated in O(r) I/Os. Since each node has O(r) children, the total number of I/Os needed to flush a buffer is O(r). Every segment can be divided into up to r unit segments and each unit segment can contribute to logB n buffer flushes. Hence the total amortized cost per segment is O( r2 logB n ) = O(1). We did not yet take into account the cost of refilling the buffers Max(cid:48); using the analysis similar to the analysis in [12, Section 4], we can estimate the cost of re-filling Max(cid:48) as O( logB n We do not store buffers in the leaf nodes. Let S(λ) be the set of segments kept in a leaf λ and let SW (λ) be the set of weighted segments stored in λ. When we move segments from B(ν) or D(ν) to its leaf child λ, we update S(λ) accordingly. This operation changes the weight of λ. Hence we need to update the weighted tree P(u) in O(log n) I/Os. Sets Maxf l(·) and Minf l(·) are also updated. After an insertion of new segments into a leaf node, we may have to insert or remove some bridges in Ei(u) for 1 ≤ i ≤ r. When we insert a new bridge b into Ei(u), we must split some portion P(ui) into two new portions, P1(ui) and P2(ui). Additionally we must change the weights of the bridge segments in Ei(u) that precede and follow b. The cost of splitting P(ui) is O(log n). We also need O(log n) I/Os to change the weights of two neighbor bridges. Hence the total cost of inserting a new bridge is O(log n). We insert a bridge at most once per O(r) insertions into AC(u) because every new segment is divided into up to r unit segments. We remove a bridge at most once after O(r) deletions. See [13] for the description of the method to maintain bridges in catalogs AC(u). Thus the total amortized cost incurred by a bridge insertion or deletion is O( log n r ) = O(1). Insertions. Insertions are executed in a similar way. A new inserted segment is split into O(r) unit segments that are inserted into the buffer B(νR) for the root node νR. The buffers and auxiliary sets are updated and flushed in the same way as in the case of deletions. When the number of new segments in some portion P(u) is equal to nold/r, where nold is the number of old segments in P(u), we rebuild P(u). As explained in Section 4, rebuilding of P(u) incurs an amortized cost of o(1). Queries. The search for the successor segment n(u) in the weighted tree P(u) consists of two stages. Suppose that the query point q is in the slab of the i-th child ui of u. First we find the successor bn(u) of q in Ei(u) by searching in P(u). We traverse the path from the root to the leaf λn holding bn(u). In every node ν we select its leftmost child νj, such that Maxf l(νj) for some f ≤ i ≤ l contains a segment s that is above q and s is not deleted (i.e., s (cid:54)∈ D(µ) for all ancestors µ of ν). The size of each set Maxf l(νk) is larger than the total size of all D(µ) in all ancestors µ of ν. Hence every Maxf l(νi) contains some elements that are not deleted unless the set Cf l(u, νi) is empty. Therefore we select the correct child νj in every node. Since P(u) is a biased search tree [10, 19], the total cost of finding the leaf λn is bounded by O(log(WP /ωλ)) = O(log(WP /ωn)) where ωλ is the total weight of all segments in λn and ωn ≤ ωλ is the weight of the bridge segment bn(u). During the second stage we need to find the successor segment n(u) of q in AC(u). The distance 11 between n(u) and bn(u) in AC(u) can be arbitrarily large. Nevertheless n(u) is stored in one of the sets Nav(µ) for some ancestor µ of λn. Suppose that n(u) is an unweighted segment stored in a leaf λ(cid:48) of P(u) and let µ denote the lowest common ancestor of λ and λ(cid:48). Let µk be the child of µ that is an ancestor of λ(cid:48). There are at most r4 segments in ACf l(u) between n(u) and bn(u). Hence, n(u) is stored in the set Maxf l(µk). Hence, n(u) is also stored in Nav(µ). We visit all ancestors µ of λn and compute D = ∪µD(µ). Then we visit all ancestors one more time and find the successor of q in Nav(µ) \ D. The asymptotic query cost remains the same because we only visit the nodes between λn and the root and each node is visited a constant number of times. We need to consider one additional special case. It is possible that there are no bridge segments s ∈ Ei(u) stored in the leaves of P(u). In this case there are at most r2 segments in ACf l(u) for every pair f, l, satisfying f ≤ i ≤ l, stored in the leaves of P(u). For each portion P(u), if there are at most r2 segments in ACf l(u) ∩ P(u), we keep the list of all such segments. All such lists fit into one block of memory. We also keep the list of indexes i, such that Ei(u) ∩ P(u) is empty.Suppose that we need to find the successor of q and P(u) ∩ Ei(u) is empty. Then we simply examine all segments in ACf l(u) ∩ P(u) for all f ≤ i ≤ l and find the successor of q in O(1) I/Os. When n(u) is known, we need to find bp(u) and bn(u), if bn(u) was not computed at the previous step. It is not always possible to find these bridges using P(u) because bp(u) and bn(u) can be outside of P(u). To this end, we use the data structure for colored union-split-find problem on a list (list-CUSF) that will be described in Section B.1. We keep the list V (u) containing all down- bridges from Ei(u), for 1 ≤ i ≤ r, and all up-bridges from U P (u). Each segment in e ∈ V (u) is associated to an interval; a segment e ∈ Vi(u) is associated to an interval [i, i] and a segment from U P (u) is associated to a dummy interval [−1,−1]. For any segment e ∈ V (u) we can find the preceding/following segment associated to an interval [i, i] for any i, 1 ≤ i ≤ r, in O(log logB n) I/Os. Updates of V (u) are supported in O(log logB n) I/Os. Since we insert or remove bridge segments once per r2 updates, the amortized cost of maintaining the list-CUSF structure is O(1). Summing up. By the same argument as in Section 3, weighted searches in all nodes take O(logB n) I/Os in total. Additionally we spend (log logB n) I/Os in every node with a query to list-CUSF. Thus the total query cost is O(logB n log logB n). When a segment is deleted, we remove it from O(logB n) lists AC(u) and from secondary structures (weighted trees etc.) in these nodes. The deletions take O(1) I/Os per node or O(logB n) I/Os in total. When a segment is inserted, it must be inserted into O(logB n) lists AC(u). We first have to spend O(logB n) I/Os to find the portion P(u) of each AC(u) where it must be stored. When P(u) is known, an insertion takes O(1) amortized I/Os as described above. The total cost of an insertion is O(log2 B n) I/Os. Since every segment is stored in O(logB n) lists, the total space is O(n logB n). Lemma 2 If B > log8 n, then there exists an O(n logB n) space data structure that supports vertical ray shooting queries on a dynamic set of n non-intersecting segments in O(logB n log logB n) I/Os. Insertions and deletions of segments are supported in O(log2 B n) and O(logB n) amortized I/Os respectively. 6 Faster Insertions When a new segment s is inserted into our data structure, we need to find the position of s in O(logB n) lists AC(u) (to be precise, we need to know the portion P(u) of AC(u) that contains s). When positions of s in AC(u) are known, we can finish the insertion in O(logB n) I/Os. 12 In order to speed-up insertions, we use the multi-colored segment tree of Chan and Nekrich [13]. Segments in lists C(u) are assigned colors χ, so that the total number of different colors is O(log H) where H = O(logB n) is the height of the segment tree. Let Cχ(u) denote the set of segments of color χ in C(u). We apply the technique of Sections 3- 5 to each color separately. That is, we create augmented lists ACχ(u) and construct weighted search trees Pχ(u) for each color separately. The query cost is increased by factor O(log H), the number of colors. The deletion cost is also increased by O(log H) factor because we update the data structure for each color separately. When a new segment s is inserted, we insert it into some lists ACχi(ui) where ui is the node such that s spans ui but does not span its parent and χi is some color (the same segment can be assigned different colors χi in different nodes ui). We can find the position of s in all ACχi(ui) with O(logB n log H + H · tusf) = O(logB n log logB n) I/Os where tusf = O(log logB n) is the query cost in a union-split-find data structure in the external memory model. See [13] for a detailed description. Lemma 3 If B > log8 n, then there exists an O(n logB n) space data structure that supports vertical ray shooting queries on a dynamic set of non-intersecting segments in O(logB n(log logB n)2) I/Os. Insertions and deletions of segments can be supported in O(logB n log logB n) amortized I/Os. 7 Missing Details Using the method from [13] we can reduce the space usage of our data structure to linear at the cost of increasing the query and update complexity by O(log logB n) factor.The resulting data structure supports queries in O(logB n(log logB n)2) I/Os and updates in O(logB n(log logB n)3) amortized I/Os. See Section A for a more detailed description. In our exposition we assumed for simplicity that the tree T does not change, i.e., the set of x-coordinates of segment endpoints is fixed and known in advance. To support insertions of new x-coordinate, we can replace the static tree T with a weight-balanced tree with node degree Θ(r) = Θ(Bδ). We also assumed that the block size B is large, B > log8 n. If B ≤ log8 n, the linear-space in- ternal memory data structure [13] achieves O(log n(log log n)2) = O(logB n(log logB n)3) query cost and O(log n log log n) = O(logB n(log logB n)2) update cost because log n = O(logB n log logB n) and log log n = O(log logB n) for B ≤ log8 n. Thus we obtain our main result. Theorem 1 There exists an O(n) space data structure that supports vertical ray shooting queries on a dynamic set of n non-intersecting segments in O(logB n(log logB n)3) I/Os. Insertions and deletions of segments are supported in O(logB n(log logB n)2) amortized I/Os. References [1] Pankaj K. Agarwal, Lars Arge, Gerth Stølting Brodal, and Jeffrey Scott Vitter. I/O-efficient dynamic point location in monotone planar subdivisions. In Proc. 10th Annual ACM-SIAM Symposium on Discrete Algorithms, (SODA), pages 11 -- 20, 1999. [2] Alok Aggarwal and Jeffrey Scott Vitter. The Input/Output complexity of sorting and related problems. Commun. ACM, 31(9):1116 -- 1127, 1988. 13 [3] Lars Arge, Gerth Stølting Brodal, and Loukas Georgiadis. Improved dynamic planar point location. In Proceedings of the 47th Annual IEEE Symposium on Foundations of Computer Science, pages 305 -- 314, 2006. [4] Lars Arge, Gerth Stølting Brodal, and S. Srinivasa Rao. External memory planar point location with logarithmic updates. Algorithmica, 63(1-2):457 -- 475, 2012. [5] Lars Arge, Andrew Danner, and Sha-Mayn Teh. I/O-efficient point location using persistent B-trees. ACM Journal of Experimental Algorithmics, 8, 2003. [6] Lars Arge, Vasilis Samoladas, and Jeffrey Scott Vitter. On two-dimensional indexability and optimal range search indexing. In Proc. 18th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (PODS), pages 346 -- 357, 1999. [7] Lars Arge and Jan Vahrenhold. I/O-efficient dynamic planar point location. Computational Geometry, 29(2):147 -- 162, 2004. [8] Lars Arge, Darren Erik Vengroff, and Jeffrey Scott Vitter. External-memory algorithms for processing line segments in geographic information systems. Algorithmica, 47(1):1 -- 25, 2007. [9] Hanna Baumgarten, Hermann Jung, and Kurt Mehlhorn. Dynamic point location in general subdivisions. J. Algorithms, 17(3):342 -- 380, 1994. [10] Samuel W. Bent, Daniel Dominic Sleator, and Robert Endre Tarjan. Biased search trees. SIAM J. Comput., 14(3):545 -- 568, 1985. [11] Jon Louis Bentley. Algorithms for Klee's rectangle problems. Unpublished manuscript, De- partment of Computer Science, Carnegie-Mellon University, 1977. [12] Gerth Stølting Brodal. External memory three-sided range reporting and top-k queries with sublogarithmic updates. In Proc. 33rd Symposium on Theoretical Aspects of Computer Science (STACS), pages 23:1 -- 23:14, 2016. [13] Timothy M. Chan and Yakov Nekrich. Towards an optimal method for dynamic planar point location. In Proc. 56th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 390 -- 409, 2015. [14] Timothy M. Chan and Konstantinos Tsakalidis. Dynamic planar orthogonal point location in sublogarithmic time. In Bettina Speckmann and Csaba D. T´oth, editors, 34th International Symposium on Computational Geometry (SoCG 2018), volume 99 of LIPIcs, pages 25:1 -- 25:15. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2018. [15] Bernard Chazelle and Leonidas J. Guibas. Fractional cascading: I. A data structuring tech- nique. Algorithmica, 1(2):133 -- 162, 1986. [16] Siu-Wing Cheng and Ravi Janardan. New results on dynamic planar point location. SIAM J. Comput., 21(5):972 -- 999, 1992. [17] Yi-Jen Chiang, Franco P. Preparata, and Roberto Tamassia. A unified approach to dynamic point location, ray shooting, and shortest paths in planar maps. SIAM J. Comput., 25(1):207 -- 233, 1996. 14 [18] Yi-Jen Chiang and Roberto Tamassia. Dynamization of the trapezoid method for planar point location in monotone subdivisions. Int. J. Comput. Geometry Appl., 2(3):311 -- 333, 1992. [19] Joan Feigenbaum and Robert Endre Tarjan. Two new kinds of biased search trees. Bell Systems Technical Journal, 62(10):3139 -- 3158, 1983. [20] Yoav Giora and Haim Kaplan. Optimal dynamic vertical ray shooting in rectilinear planar subdivisions. ACM Transactions on Algorithms, 5(3):28, 2009. [21] Michael T. Goodrich and Roberto Tamassia. Dynamic trees and dynamic point location. SIAM J. Comput., 28(2):612 -- 636, 1998. [22] Michael T. Goodrich, Jyh-Jong Tsay, Darren Erik Vengroff, and Jeffrey Scott Vitter. External- memory computational geometry (preliminary version). In Proc. 34th Annual Symposium on Foundations of Computer Science (FOCS), pages 714 -- 723, 1993. [23] Leonidas J. Guibas, Edward M. McCreight, Michael F. Plass, and Janet R. Roberts. A new representation for linear lists. In Proceedings of the 9th Annual ACM Symposium on Theory of Computing, pages 49 -- 60, 1977. [24] Alon Itai, Alan G. Konheim, and Michael Rodeh. A sparse table implementation of priority queues. In Proc. 8th Colloquium on Automata, Languages and Programming (ICALP), pages 417 -- 431, 1981. [25] Kurt Mehlhorn and Stefan Naher. Dynamic fractional cascading. Algorithmica, 5(2):215 -- 241, 1990. [26] Franco P. Preparata and Roberto Tamassia. Fully dynamic point location in a monotone subdivision. SIAM J. Comput., 18(4):811 -- 830, 1989. [27] Franco P. Preparata and Roberto Tamassia. Efficient point location in a convex spatial cell- complex. SIAM J. Comput., 21(2):267 -- 280, 1992. [28] Dan E. Willard. A density control algorithm for doing insertions and deletions in a sequentially ordered file in good worst-case time. Inf. Comput., 97(2):150 -- 204, 1992. A Saving Space We use another method from [13] to reduce the space usage of the data structure in Lemma 3 to linear. Lemma 4 ([13], Lemma 3.1) Consider a decomposable search problem, where (i) there is an S(n)-space fully dynamic data structure with Q(n) query cost and U (n) update cost, and (ii) there is an SD(n)-space deletion-only data structure with QD(n) query cost, UD(n) update cost, and PD(n) preprocessing cost. Then there is an O(S(n/z) + SD(n))-space fully dynamic data structure with O(Q(n/z)+QD(n) log z) query cost and O(U (n/z)+UD(n)+(PD(n)/n) log z) amortized update cost for any given parameter z (assuming that PD(n)/n is nondecreasing). 15 Lemma 5 ([13], Lemma 3.1) If there is a deletion-only data structure for vertical ray shooting queries for n horizontal segments with Sorth(n) space, Qorth(n) query cost, Uorth(n) update cost, and Porth(n) preprocessing cost, then there is a deletion-only data structure for vertical ray shooting queries for n arbitrary non-intersecting segments with SD(n) = Sorth(n) + O(n) space, QD(n) = Qorth(n) + O(log n) query cost, UD(n) = Uorth(n) + O(1) update cost, and PD(n) = Porth(n) + O(n logB n) preprocessing cost. The two above lemmata are obtained by a straightforward extension of Lemmata 3.1 and 3.2 from [13] to the external memory model. We will describe in Section B.3 a data structure that supports vertical ray shooting queries on a set of horizontal segments in O(logB n log logB n) I/Os and updates within the same amortized bounds. If we plug this result into Lemma 5, we obtain a deletion-only data structure for ray shooting queries in a set of n arbitrary non-intersecting segments with QD(n) = O(logB n log logB n) query cost, UD(n) = O(logB n log logB n) deletion cost, and PD(n) = O(n logB n log logB n) preprocessing cost. Recall that the structure of Lemma 3 has query cost Q(n) = O(logB n(log logB n)2), update cost U (n) = O(logB n log logB n) I/Os amortized, and space usage O(n logB n). We apply Lemma 4 to the structure of Lemma 3 and the deletion-only structure described above. We obtain the following lemma. Lemma 6 If B > log8 n, then there exists an O(n) space data structure that supports vertical ray shooting queries on a dynamic set of n non-intersecting segments in O(logB n(log logB n)3) I/Os. Insertions and deletions of segments are supported in O(logB n(log logB n)2) amortized I/Os. B Ray Shooting on Horizontal Segments In this section we describe a data structure for vertical ray shooting queries in a dynamic set of horizontal segments. A data structure for this problem can be used to answer dynamic point location queries in an orthogonal subdivision. The special case of horizontal segments is much simpler than the ray shooting among arbitrary segments because it is easy to maintain the order among horizontal segments. Our solution is based on a colored variant of the predecessor search, described in Section B.1. We describe how this data structure can be combined with the segment tree to answer ray shooting queries in Section B.2. We show that the space usage of our data structure can be reduced from O(n logB n) to O(n) in Section B.3. B.1 Colored Predecessor Search in External Memory In the colored predecessor searching problem, every element e = (ve, Ie) has a value ve and color interval Ie = [c1, c2], 1 ≤ c1 ≤ c2 ≤ C. We assume that color intervals are disjoint for elements with the same value, i.e., if va = vb for two elements a and b, then Ia ∩ Ib = ∅. The answer to a colored predecessor query (vq,Cq) for vq ∈ [1, V ] and Cq ⊂ [1, C] is the largest (with respect to its value ve) element e, such that ve ≤ vq and Cq ∩ Ie (cid:54)= ∅. We say than an element e is colored with a color c if c ∈ Ie. First, we show how colored search queries for a small set of elements can be answered with a constant number of I/Os. Then, we will describe a data structure for an arbitrarily large set of elements. Lemma 7 Let δ > 0 and 0 < f ≤ 1 − δ. The colored predecessor searching problem for a set Sl, such that colors of elements belong to [1, C] for C ≤ Bf , can be solved in O(logB Sl) I/Os using a O(Sl) space data structure that supports updates in O(logB Sl) I/Os. 16 Proof : We sort the elements in Sl by their values (elements with the same value are sorted by the smallest colors that belong to their color intervals) and store them in the leaves of a tree Tl. Each leaf contains Θ(B) elements of Sl and each internal node has ρ = Θ(Bδ) children. We say that an internal node u contains an element s if s is stored in a leaf descendant of u. In every internal node u, we store a table Ru: for each c ∈ [1, C] and each 1 ≤ i ≤ ρ, Ru[c, i] = 1 iff the i-th child of u contains at least one element with color c. For every (c, i) such that Ru[c, i] = 1, we also store the maximal and the minimal elements colored with c that belong to the i-th child of v. Every table Ru fits into O(1) blocks. There are O(Sl/B) internal nodes in Tl; hence, all Ru use O(Sl) words of space. The search for (xq, cq) starts at the root of Tl. In each visited node u of T , we identify the rightmost child ui such that Ru[cq, i] = 1 for some cq ∈ Cq and the minimal element colored with cq in ui is not greater than xq. If such ui does not exist, then Sl contains no element colored with cq ∈ Cq that is smaller than or equal to xq. Otherwise, the search continues in ui. The height of Tl is O(logB Sl) and the search takes O(logB Sl) I/Os. When a new element is inserted into Sl, we insert it into a leaf u of Tl. Then, we visit all ancestors u(cid:48) of u and update the tables Ru(cid:48). The tree Tl can be rebalanced in a standard way. (cid:3) Deletions are processed with a symmetric procedure. Lemma 8 Let 0 < f < 1/2. A colored searching problem for a set of K elements, such that values of elements belong to the universe [1, V ] and colors belong to the interval [1, C] for C ≤ Bf , can be solved in O(log logB V ) I/Os using a O(max(V, K) log logB V ) space data structure that supports updates in O(log logB V ) amortized I/Os. Proof : To simplify the description, we introduce a new set of interval colors M: for each interval [c1, c2], 1 ≤ c1 ≤ c2 ≤ C, there is an interval color c12 ∈ M. Thus each interval color corresponds to a color interval Ie. Obviously, for each original color ci there is the interval color that corresponds to the interval [ci, ci]. An element e is colored with a color from a set Cq if and only if e is colored with an interval color from a set Mq = { cij ∃c ∈ Cq, ci ≤ c ≤ cj }. For every set of colors Cq the equivalent set of interval colors Mq can be constructed in O(1) I/Os. While each element e is colored with colors from an interval Ie, each e is colored with only one interval color. The data structure can be defined recursively. If max(K, V ) ≤ B2, we can use the data structure of Lemma 7 and answer queries in O(1) I/Os. If max(K, V ) > B2, then we divide the interval [1, V ] into subintervals of size7 Bh for h = (logB V )/2. The array A[r] contains two tables min[i, j] and max[i, j] for each subinterval. The table A[r]. min[i, j] (A[r]. max[i, j]) contains the minimal (maximal) element in the r-th subinterval colored with an interval color cij. If there is no such element in the r-th subinterval, then A[r]. min[i, j] = A[r]. max[i, j] = NULL. Let S[r][i, j] be the set of elements whose values belong to the subinterval [(r− 1)Bh + 1, rBh] and whose interval color is [i, j]. If S[r][i, j] ≤ 2, the values of elements from S[r][i, j] are already stored in A[r]. min[i, j] and A[r]. max[i, j]. If S[r][i, j] ≥ 3 for at least one pair i, j, we construct a recursively defined data structure D[r] for S[r]. All values of elements in D[r] are specified relative to the left end of the r-th subinterval; thus values of all elements in D[r] belong to [1, Bh]. The data structure Dtop supports colored predecessor searching in the array A: if A[r]. min[i, j] (cid:54)= NULL, then Dtop contains an element e with ve = r and Ie = {cij}, i.e. e is colored with an interval color cij. Values of elements in Dtop also belong to the interval [1, Bh]. All tables min[] and max[] in the array A have 7For ease of description we assume that h is an integer. 17 O(BlogB V /2· B2f ) entries. Therefore A uses O(max(K, V )) words of space. Since values of elements in Dtop and Dr belong to [1, BlogB V /2], there are at most O(log logB V ) recursion levels. Hence, the total space usage is O((max(K, V )/B) log logB V ). A query (vq,Cq) is processed as follows. Let Mq be the set of interval colors that is equivalent to Cq. If K ≤ B2, the query is answered in O(1) I/Os by Lemma 7. Otherwise we check whether there is at least one pair i, j such that A[v(cid:48) q denotes the index of the subinterval that contains vq. This condition can be tested in O(1) I/Os because each entry of A[] fits into one block of memory. If such a pair exists, the search continues in the data structure D[v(cid:48) q such that r(cid:48) is colored with a color cij ∈ Mq. The answer to the query is the maximal element among all A[r(cid:48)]. max[i, j] such that cij ∈ Mq. Suppose that max(V, K) ≥ B2 and an element e = (ve, [ie, je]) is inserted. We update the values of A[r]. min[i, j] and A[r]. max[i, j] for r = ve/Bh if necessary. If S[r][i, j] ≥ 3 after the insertion of e, we insert an element (v, [i, j]), such that v (cid:54)= A[r]. min[i, j] and v (cid:54)= A[r]. max[i, j] into D[r]. If S[r][i, j] = 1 after the insertion of e, we insert an element (r, [i, j]) into the data structure Dtop. (cid:3) Deletions are symmetric to insertions. q]. Otherwise, we use the data structure Dtop to find the largest r(cid:48) < v(cid:48) q]. min[i, j] ≤ vq and [i, j] ∩ Cq (cid:54)= ∅; here v(cid:48) In the colored union-split-find (CUSF) problem we put an additional restriction on queries: only queries (vq,Cq), such that there is an element e ∈ S with value ve = vq, are allowed. Moreover, we assume that a pointer to such an element e ∈ S is provided with a query. When an element e is deleted or inserted, we assume that the position of e is known. Lemma 9 The CUSF problem for a set of K elements and C ≤ B1−f , 0 < f < 1, colors can be solved in O(log logB K) I/Os using a O(K) space data structure that supports updates in O(log logB K) amortized I/Os. Proof : We can transform the general searching data structure into a CUSF data structure using the same principle as in [20]. The set of K elements is divided into chunks of size Θ(g). If B ≥ log2 K, then we set g = B1+2f . Otherwise, we set g = log4 B K. We assign to each chunk m an ordered label lab(m) ∈ [1, O(K)]: if the chunk m1 follows m2, then lab(m1) > lab(m2). Labels can be maintained according to the algorithm of [24, 28]: when a new chunk is inserted or when a chunk is deleted, O(log2 K) labels must be changed. The set of interval colors M is defined exactly as in the proof of Lemma 8. The data structure Dv contains an element (lab(m), cij) if and only if the chunk m contains an element with color interval Ie = [ci, cj]. By Lemma 8, Dv uses O(K) words of space. We also store a data structure Dm for each chunk that supports colored predecessor searching queries in this chunk. We implement the data structure Dm as described in Lemma 7, so that colored searching queries are supported in O(logB g) = O(logB logB K) I/Os. All data structures Dm use space O(K). Consider a query (vq,Cq). Suppose that some element e ∈ S with ve = vq belongs to a chunk me. First, we find the largest chunk m, such that m contains at least one interval color cij and [ci, cj] ∩ Cq (cid:54)= ∅. The set of colors Mq = { cij ∃c ∈ Cq, ci ≤ c ≤ cj } can be constructed with O(1) I/Os. Using Dv, we can answer the colored search query for (me,Mq) and find the chunk m in O(log logB K) I/Os. The largest element e with ve ≤ vq and Ie ∩ Cq (cid:54)= ∅ belongs to the chunk m. The cost of finding e using the data structure for the chunk m is O(logB logB K); hence, a query can be answered with O(log logB K) I/Os. When a new element e is inserted, we insert it into a chunk me in O(1) I/Os. If the data structure Dv does not contain the element (lab(me), Ie), then we insert this element into Dv in 18 O(log logB K) I/Os. If the number of elements in a block equals 2g we distribute the elements of m between two chunks m1 and m2. It takes O(g logB g) I/Os to delete the data structure Dm and insert the elements of m into data structures Dm1 and Dm2. We assign new labels to chunks m1 and m2 and update the set of labels. This leads to changing the labels of O(log2 2 K) chunks. The data structure Dv contains O(B2f ) labels for each chunk. Hence, the total number of updates in Dv 2 K, then B1+2f > B2f log2 K. incurred by updating the set of labels is O(B2f log2 K). If B > log2 If B ≤ log2 K, then log4 2 K) insertions, the amortized cost of an insertion is O(log logB K). Deletions are performed in the same (cid:3) way. Thus the total cost of an update is O(log logB K). 2 K). Since labels are changed after Θ(g) = Ω(B2f log2 B K = Ω(B2f log2 We remark that, in fact, the values of elements are not necessary. Using the same method, we can store a list of elements, such that each element e in the list is assigned an interval of colors Ie. Given a pointer to a list element e and a color interval Cq, we ask for the first element e(cid:48) that follows e in the list and Cq ∩ Ie(cid:48) (cid:54)= ∅. We will call this problem list CUSF. Lemma 10 The list CUSF problem for a set of K elements and C ≤ B1−f , 0 < f < 1, colors can be solved in O(log logB K) I/Os using a O(K) space data structure that supports updates in O(log logB K) amortized I/Os. This result can be proved in the same way as Lemma 9; we use it in Section 5. B.2 Ray Shooting on Horizontal Segments Structure. All segments are stored in a tree T with node degree Bc for some constant c < 1/2. The leaves of T contain x-coordinates of segment endpoints; every leaf contains Θ(B) elements. The tree is organized as a variant of the segment tree, in the same way as in Section 2.1. We start by introducing some additional notation. The range of a leaf node vl is the interval [al, bl], where al and bl are the minimal and the maximal values stored in vl. The range of an internal node v is the interval [a, b], so that a and b are the minimal and maximal values stored in leaf descendants of v. We say that a segment s = (x1, x2; y) covers an interval [a, b] if x1 ≤ a and b ≤ x2; a segment covers a if it covers an interval [a, a]. Thus a segment spans a node v if it covers the range of v. We implement T in the same way as before: a segment s = (x1, x2; y) is associated with a node v if and only if s spans at least one child vi of v, but s does not span the node v. Thus each segment is associated with O(logB n) nodes. Let C(v) be the set of segments associated with a node v. For simplicity, we sometimes will not distinguish between a segment and its y-coordinate. For any point q = (qx, qy), let π denote search path for qx in the tree T . Each segment s = (x1, x2; ys), x1 ≤ qx ≤ x2, is stored in a list C(v), v ∈ π. If s ∈ C(v) covers qx and v is an internal node, then s spans the child vi of v, vi ∈ π. Hence, we can identify the predecessor segment sq of q by finding the highest segment s ∈ C(v), v ∈ π, such that s spans some node v(cid:48) ∈ π and ys ≤ qy. Our method is based on Lemma 9 and the fractional cascading technique [25] applied to sets C(v). We construct augmented catalogs AC(v) ⊃ C(v) for all nodes v of T . For a leaf node vl, AC(vl) = C(vl). Every list AC(v) is divided into groups G1(v), G2(v), . . ., so that each group contains between logB n/2 and 2 logB n segments. We guarantee that AC(v) for an internal node v contains one segment from a group Gj(vi) for every child vi of v and every group Gj(vi). Moreover, AC(v) contains all segments from C(v). If copies of the same segment s are stored in augmented 19 lists for a node v and for a child vi of v, then the two copies of s in AC(v) and AC(vi) are connected by pointers, called bridges. Thus there are O(logB n) elements of AC(vi) between any two consecutive bridges from AC(v) to AC(vi). The data structure D(v) contains the colored set of (y-coordinates of) all segments in AC(v): if a segment s = (x1, x2; ys) ∈ C(v) spans children vi, vi+1, . . . , vj of v, then an element es = (ys, [i, j]) with value ys and colors Ie = [i, j] is stored in D(v); if a segment s does not span any child vi of v (i.e., s belongs to AC(v)\C(v)), then es is colored with a dummy color cd. The data structure E(v) also contains a colored set of segments in AC(v), but segments are colored according to a different rule. All segments from C(v) are colored with a dummy color cd; for any segment s ∈ AC(v)\ C(v), the set of colors for s contains all values i such that s belongs to AC(vi) for a child vi of v. Both D(v) and E(v) are implemented as described in Lemma 9. Queries. The search procedure visits all nodes on the path π starting at the root. In every internal node v ∈ π, we identify the predecessor s(v) of q.y in AC(v). Then we identify the highest segment s(cid:48)(v) in AC(v) such that s(cid:48)(v) is below s(v) and s(cid:48)(v) spans the child vi of v, vi ∈ π. Finally, we examine all segments in the leaf vl ∈ π and find the predecessor segment s(cid:48)(vl) of q stored in C(vl). The predecessor segment of q in S is the highest segment among all s(cid:48)(v) for v ∈ π. We can identify s(v) for the root of T in O(logB n) I/Os using a standard B-tree. Suppose that s(v) for a node v is known. We will show how to find s(cid:48)(v) and s(vi) for the child vi ∈ π of v. The highest segment s(cid:48)(v) ∈ AC(v), such that s(cid:48)(v) is below s(v) = (x1, x2; ys) ∈ AC(v) and s(cid:48)(v) spans a child vi of v can be found by answering the query (ys, i) to a data structure D(v). The segment s(vi) can be identified as follows. The highest segment s1(v), such that s1(v) is below s(v) and s1(v) belongs to AC(vi) can be found in O(log logB n) I/Os using E(v). Suppose that the copy of s1(v) belongs to a group Gj(vi) in AC(vi). Since s1(v) is the highest segment below q in AC(v) ∩ AC(vi), s(vi) either belongs to the group Gj(vi) or to the next group Gj+1(vi). If we store y-coordinates of all segments from each group Gl in a B-tree, then we can search in Gl in O(logB logB n) I/Os because each Gl contains O(logB n) segments. Thus the segment s(vi) can be found in O(logB logB n) I/Os if s1(v) is known. Since the search procedure spends O(log logB n) I/Os in every node of π, the total cost of the search is O(logB n log logB n). Updates. Every segment belongs to O(logB n) lists C(v). Every insertion into a list C(v) can be handled as follows. All nodes v such that s belongs to C(v) are situated on at most two root-to-leaf paths π. We can identify positions of the y-coordinate of s in all AC(v) that belong to some path π in O(logB n log logB n) I/Os as described in the search procedure. When we know the position of s in a list AC(v), we insert s into data structures D(v) and E(v) in O(log logB n) I/Os. We also insert s into the B-tree for its group Gj in C(v). If the number of elements in Gj exceeds 2 logB n, Gj is split into two groups G(cid:48) j (v). The list AC(w) for the parent w of v already contains one element from either G(cid:48) j (v). A representative sr of another group must be inserted into AC(w). The position of sr in AC(w) can be found in O(log logB n) I/Os; after that, sr is inserted into AC(w) in O(log logB n) I/Os as described above. It can be shown that an insertion into a catalog AC(v) leads to O(1/ logB n) insertions into augmented lists of ancestors of v [25]. Hence, the total cost of an insertion is O(logB n log logB n). Deletions can be handled in the same way. Since every segment is stored in O(logB n) nodes, the total space usage is O(n logB n). j(v) and G(cid:48)(cid:48) j(v) or G(cid:48)(cid:48) Lemma 11 There exists a O(n logB n) space data structure that supports ray shooting queries on horizontal segments in O(logB n log logB n) I/Os and updates in O(logB n log logB n) amortized I/Os. 20 We can reduce the space usage to linear using the same approach as in [9, 20]. For completeness, we provide the proof in Section B.3. Theorem 2 There exists a O(n) space data structure that supports ray shooting queries on hori- zontal segments in O(logB n log logB n) I/Os and updates in O(logB n log logB n) amortized I/Os. B.3 Reducing Space to Linear We follow the same approach as in [9, 20]. For a segment s = (xf , xe; ys), let vs be the lowest common ancestor of the leaves in which xf and xe are stored. The node vs is the lowest node such that the range of v contains [xf , xe], but [xf , xe] does not span v. Suppose that s spans the children vi, . . . , vj of v. We represent s as a union of three segments: sm = (ai, bj; ys), sl = (xf , ai; ys), and sr = (bj, xe; ys), where rng(vi) = [ai, bi] and rng(vj) = [aj, bj]. Segments sm, sl and sr are stored in sets Sm(v), Sl(vi−1), and Sr(vj+1) respectively. Let Πm = ∪v∈T Sm(v), Πl = ∪v∈T Sl(v), and Πr = ∪v∈T Sr(v). A ray shooting query can be answered by answering a ray shooting query for Πm, Πr, and Πl. We can identify the predecessor segment of q in Πm by storing all segments s ∈ Πm in the data structure of section B.2. Since every segment is stored only once the total space usage is O(n). Now we describe the data structure for Πr. A query on Πl can be answered using a symmetrically defined data structure. Each set Sr(v) is divided into blocks W, so that each block contains Θ(logB n) segments. We denote by win(W) the segment in a block W with the largest x-coordinate of the right endpoint. The segments win(W) for all blocks W and all sets Sr(u) are stored in a data structure Dr imple- mented as in section B.2. Since the total number of segments in Dr is O(n/ logB n), Dr needs O(n) words. We denote by Yr(u) the set of y-coordinates of all segments in Sr(u). The data structure Dy is defined on all sets Yr(u). Let ui denote the nodes that lie on some root-to-leaf path of T . Using Dy, we can search in all sets Yr(ui) in O(log logB n) I/Os per node. To implement Dy, we apply the construction of section B.2, i.e., the augmented sets and CUSF structures, to sets Yr(u). Finally, for each block W we store a data structure that supports queries on segments of W in O(logB(W)) I/Os. This data structure uses the fact that the left endpoints of all segments in W lie on the same vertical line and is very similar to an external memory priority search tree [6]. A point location query for q = (qx, qy) on Πr can be answered as follows. We start by identifying the successor segment s+ of q in Dr and the predecessor segment s− of q in Dr. Let y+ and y− denote the y coordinates of s+ and s−. Then, we use the data structure Dy and find y1(u) = pred(y−, Y (u)) and y2(u) = succ(y+, Y (u)) for every node u ∈ π, where π is the search path for qx in T . The following fact is proved in [20]. Fact 1 Let W1(u) and W2(u) be the blocks in Sr(u) that contain segments with y-coordinates y1(u) and y2(u) respectively. Let s∗ be the predecessor segment of q in Πr. Then s∗ belongs to a block W1(u) or W2(u) for some u ∈ π. We can complete the search by querying all W1(u) and W2(u), u ∈ π, in O(logB n logB logB n) I/Os and selecting the highest segment among all answers. When a new segment is inserted, we identify the node vs in O(logB n) I/Os. Insertion of sm into Πm is handled as in section B.2. Insertion of sr starts with identifying the child vr of vs such that rng(vr) intersects with [xf , xe] but s does not span vr. Let Ws be the block of Sr(vr) into which s must be inserted. If the x-coordinate of the right endpoint of s is larger than the x-coordinate of 21 win(Ws), then we remove win(Ws) from Dr and insert s into Dr. We also insert the y-coordinate of s into Dy. Finally, if the number of elements in Ws after an insertion equals 2 logB n, then Ws is split into two blocks that contain logB n segments each. We can show using standard methods that the amortized cost of splitting a block is O(logB logB n). An insertion into Πl is symmetric. Hence, the total cost of an insertion is O(logB n log logB n). Deletions can be implemented in the same way. C Weighted Telescoping Search: Simplified Scenario In this section we provide a simple alternative description of our main technique, the weighted telescoping search. This section is not necessary in order to understand the material in the rest of this paper; the only purpose of this section is to provide a simple description of the weighted telescoping search. To introduce our technique, we digress from the point location problem and consider the following more simple scenario. Suppose that we are given a balanced tree T of node degree r and we keep a list (or catalog) L(u) in every node u of T . We assume that elements of L(u) are numbers. The successor of q in a set S is the smallest element e in S that is larger than or equal to q, succ(q, S) = min{ e ∈ S e ≥ q }. Suppose that we want to traverse a path π((cid:96)) from the root of T to a leaf (cid:96) and search for the successor of some q in the union of all lists L(u) along the path. In other words, for any element q and any leaf (cid:96) we want to quickly find succ(q,∪u∈π((cid:96))L(u)). This problem can be solved using the standard fractional cascading technique [15] within the same time, but in this paper we describe an alternative solution. We also believe that this general technique can be used in other scenarios when the standard fractional cascading is hard to apply. Unlike the rest of this paper, in this section we describe the solution for the internal memory model. Our solution is based on assigning weights to elements of L(u) and maintaining a forest of weighted trees on each list L(u) for every node u ∈ T . Roughly speaking, we choose the weights in such a way that the weight of an element e ∈ L(u) gives us an estimate on the number of elements e(cid:48), such that e(cid:48) is stored in L(v) for some descendant v of u and pred(e, L(u)) ≤ e(cid:48) ≤ e. We keep augmented catalogs AL(u) ⊇ L(u) in order to compute and maintain element weights. catalogs are supersets of L(u), AL(u) ⊇ L(u), that satisfy the following properties: Augmented Lists. We maintain an augmented catalog AL(u) in every node u. Augmented (i) If e ∈ (AL(u) \ L(u)), then e ∈ L(v) for an ancestor v of u. (ii) Let a subset Ei(u) of AL(u) be defined as Ei(u) = AL(u) ∩ AL(ui) for a child ui of u. There are at most d = O(r2) elements of AL(u) between any two consecutive elements of Ei(u). Elements of Ei(u) for some 1 ≤ i ≤ r will be called down-bridges; elements of the set U P (u) = AL(u) ∩ AL(par (u)), where par (u) denotes the parent node of u, are called up-bridges. We will say that a sub-list of a catalog AL(u) bounded by two up-bridges is a portion of AL(u). We can create and maintain augmented lists AL(u) using the fractional cascading technique [15, 25]. The main idea is to copy selected elements from L(u) and store the copies in lists AL(v) for descendants v of u; see e.g., [13] for a detailed description. If the same element e is stored in lists AL(u) and AL(par (u)), where par (u) is the parent node of u, then we assume that there are pointers between instances of e in AL(u) and AL(par (u)). Element weights. We assign the weight to each element of AL(u) in a bottom-to-top manner: for a leaf node (cid:96) every element e ∈ AL((cid:96)) is assigned weight 1. Consider an internal node u with children u1, . . ., ur. We associate values weighti(e, u) with each e ∈ AL(u) for every i, 22 weighti(e, u) = W (e1, e2, ui)/d. 1 ≤ i ≤ r. Let e1 and e2 denote two consecutive bridge elements in Ei(u). Let W (e1, e2, u) = weight(e(cid:48), u) denote the total weight of all elements e(cid:48) ∈ AL(u) such that e1 < e(cid:48) ≤ e2. Every element e ∈ AL(u) that satisfies e1 < e ≤ e2 is assigned the same value of e1≤e(cid:48)≤e2 (cid:80) The weight of e ∈ AL(u) is defined8 as weight(e, u) =(cid:80)r where WP =(cid:80) i=1 weighti(e, u). Telescoping Search. Consider a sub-list P(u) of the augmented catalog AL(u) bounded by two up-bridges. All elements of P(u) are stored in a weighted search tree satisfying the following property: The depth of a leaf holding an element e ∈ P(u) is bounded by O(log(WP /weight(e))) e(cid:48)∈P(u) weight(e(cid:48)) is the total weight of all elements in P(u). We can use e.g. biased search trees [10, 19] for this purpose. Now suppose that we want to find, for some number q and some leaf (cid:96) of T , the successor of q in ∪u∈π((cid:96))L(u) where π((cid:96)) is the path from the root to (cid:96). We start in the root node u0 and identify n(u0) = succ(q, AL(u0)). Suppose that u1 is the j-th child of u0. We find the largest down-bridge bp(u0) ≤ n(u0) and the smallest down-bridge bn(u0) ≥ n(u0) where bp ∈ Ej(u0) and bn ∈ Ej(u0). We use finger search [23] in AL(u0) with n(u0) as a finger to find bn(u0) and bp(u0) in O(log r) time. Next we identify the portion P(u1) bounded by bp(u0) and bn(u0). We find n(u1) = succ(q, AL(u1)) by searching in the weighted tree for P(u1). We then find the largest bp(u1) ≤ n(u1) and the smallest bn(u1) ≥ n(u1) where bp ∈ Eg(u1), bn ∈ Eg(u1) and u2 is the g-th child of u1. Again we use finger search and find bn(u1), bp(u1) in O(log r) time. We continue in the same way until the leaf node is reached. See Fig. 6. When we know succ(q, AL(ui)) for every node ui ∈ π((cid:96)), n∗ = succ(q,∪ui∈π((cid:96))AL(ui)) can be computed. Every element e ∈ AL(u) is either from the set L(u) or from the set L(w) for some ancestor w of u. Hence ∪u∈π((cid:96))AL(u) = ∪u∈π((cid:96))L(u). Hence n∗ is the successor of q in ∪u∈π((cid:96))L(u). The total time can be estimated as follows. Let ωi denote the weight of n(ui). We can find the element en(u0) in time log(W0/ω0), where W0 is the total weight of all elements in AL(u0). Down-bridges bp(u0) and bn(u0) can be found in O(log r) time by finger search in AL(u0). When we know bp(ui) and bn(ui), we can compute n(ui+1) in time O(log(Wi+1/ωi+1)) where Wi+1 is the total weight of all elements in P(ui+1). When n(ui+1) is known, we can compute bp(ui+1) and i=0 log(Wi/ωi)) where h is the tree height. Since ωi ≥ Wi+1/r2, we have bn(ui+1) in O(log r) time. The total time needed to compute all n(ui) is O((cid:80)h h(cid:88) h−1(cid:88) log(Wi/ωi) = log W0 + (log Wi+1 − log ωi) − log ωh ≤ log(W0/ωh) + 2(h + 1) log r. i=0 i=0 By definition, ωh = 1. We will show below that W0 ≤ n. Since h = logr n, 2(h + 1) log r = O(log n) and the sum above can be bounded by O(log n). All finger searches also take O(log n) time. It remains to prove that W0 ≤ n. We will show by induction that the total weight of all elements on every level of T is bounded by n: Every element in a leaf node has weight 1; hence their total weight does not exceed n. Suppose that, for some k ≥ 1, the total weight of all elements on level k− 1 does not exceed n. Consider an arbitrary node v on level k, let v1, . . ., vr be the children of v, and let mi denote the total weight of elements in AL(vi). Every element in AL(vi) contributes 1/d e∈AL(v) weighti(v) ≤ mi fraction of its weight to at most d different elements in AL(v). Hence (cid:80) 8We observe that the same element e can be assigned different weights weight(e, u) in different nodes u. 23 Figure 6: Telescoping Search. Left: tree T with arity r = 2 and a path π = u0, u1, u2 in T . Right: Example of the telescoping search. We are searching for the predecessor of q in AL(u0)∪ AL(u1)∪ AL(u2). Down-bridges are shown with squares, other nodes are shown with circles. n(ui) are shown with filled circles, bn(ui) and bp(ui) are shown with gray squares. Only relevant down-bridges and relevant parts of AL(ui) are shown. and the total weight of all elements in AL(v) does not exceed(cid:80)r i=1 mi. Hence, for any level k ≥ 1, the total weight of AL(v) for all nodes v on level k does not exceed n. Hence the total weight of AL(u0) for the root node u0 is also bounded by n. Thus we have shown the following result. Lemma 12 Suppose that we store a sorted list L(u) in every node u of a balanced degree-r tree T . Then it is possible to find succ(q,∪u∈πL(u)) for any q and for any root-to-leaf path π in O(log n) time, where n is the total size of all lists L(u). The underlying data structure uses space O(n). It is possible to extend the result of this section to the external memory model and to dynamize our data structure. However Lemma 12 cannot be used to answer vertical ray shooting queries because in the scenario of this Lemma lists L(u) contain numbers. 24 u0u1u2AC(u0)AC(u1)AC(u2)qn(u0)n(u1)n(u2)bn(u0)bp(u0)bn(u1)bp(u1)
1705.03385
1
1705
2017-05-09T15:26:46
Optimal Computation of Overabundant Words
[ "cs.DS" ]
The observed frequency of the longest proper prefix, the longest proper suffix, and the longest infix of a word $w$ in a given sequence $x$ can be used for classifying $w$ as avoided or overabundant. The definitions used for the expectation and deviation of $w$ in this statistical model were described and biologically justified by Brendel et al. (J Biomol Struct Dyn 1986). We have very recently introduced a time-optimal algorithm for computing all avoided words of a given sequence over an integer alphabet (Algorithms Mol Biol 2017). In this article, we extend this study by presenting an $\mathcal{O}(n)$-time and $\mathcal{O}(n)$-space algorithm for computing all overabundant words in a sequence $x$ of length $n$ over an integer alphabet. Our main result is based on a new non-trivial combinatorial property of the suffix tree $\mathcal{T}$ of $x$: the number of distinct factors of $x$ whose longest infix is the label of an explicit node of $\mathcal{T}$ is no more than $3n-4$. We further show that the presented algorithm is time-optimal by proving that $\mathcal{O}(n)$ is a tight upper bound for the number of overabundant words. Finally, we present experimental results, using both synthetic and real data, which justify the effectiveness and efficiency of our approach in practical terms.
cs.DS
cs
Optimal Computation of Overabundant Words Yannis Almirantis1, Panagiotis Charalampopoulos2, Jia Gao2, Costas S. Iliopoulos2, Manal Mohamed2, Solon P. Pissis2, and Dimitris Polychronopoulos3 1National Center for Scientific Research Demokritos, Athens, Greece, [email protected] 2Department of Informatics, King's College London, UK, [panagiotis.charalampopoulos,jia.gao,costas.iliopoulos, manal.mohamed,solon.pissis]@kcl.ac.uk 3Computational Regulatory Genomics, Institute of Clinical Sciences (ICS), Faculty of Medicine, Imperial College London, Du Cane Road, London W12 0NN, [email protected] Abstract The observed frequency of the longest proper prefix, the longest proper suffix, and the longest infix of a word w in a given sequence x can be used for classifying w as avoided or overabundant. The definitions used for the expectation and deviation of w in this statistical model were described and biologically justified by Brendel et al. (J Biomol Struct Dyn 1986). We have very recently introduced a time-optimal algorithm for computing all avoided words of a given sequence over an integer alphabet (Algorithms Mol Biol 2017). In this article, we extend this study by presenting an O(n)-time and O(n)-space algorithm for computing all overabundant words in a sequence x of length n over an integer alphabet. Our main result is based on a new non-trivial combinatorial property of the suffix tree T of x: the number of distinct factors of x whose longest infix is the label of an explicit node of T is no more than 3n − 4. We further show that the presented algorithm is time-optimal by proving that O(n) is a tight upper bound for the number of overabundant words. Finally, we present experimental results, using both synthetic and real data, which justify the effectiveness and efficiency of our approach in practical terms. 1 Introduction Brendel et al. in [6] initiated research into the linguistics of nucleotide sequences that focused on the concept of words in continuous languages -- languages devoid of blanks -- and introduced an operational definition of words. The authors suggested a method to measure, for each possible word w of length k, the deviation of its observed frequency f (w) from the expected frequency E(w) in a given sequence x. The observed frequency of the longest proper prefix, the longest proper suffix, and the longest infix of w in x were used to measure E(w). The values of the deviation, denoted by dev(w), were then used to identify words that are avoided or overabundant among all possible words of length k. The typical length of avoided (or of overabundant) words of the nucleotide language was found to range from 3 to 5 (tri- to pentamers). The statistical significance of the avoided words was shown to reflect their biological importance. That work, however, was based on the very limited sequence data available at the time: only DNA sequences from two viral and one bacterial genomes were considered. Also note that the range of typical word length k might change when considering eukaryotic genomes, the complex dynamics and function of which are expected to impose more demanding roles to avoided or overabundant words of nucleotides. To this end, in [1], we presented an O(n)-time and O(n)-space algorithm for computing all avoided words of length k in a sequence of length n over a fixed-sized alphabet. For words over an integer alphabet of size σ, the algorithm requires time O(σn), which is optimal for sufficiently large σ. We also presented a time-optimal 1 O(σn)-time algorithm to compute all avoided words (of any length) in a sequence of length n over an integer alphabet of size σ. We provided a tight asymptotic upper bound for the number of avoided words over an integer alphabet and the expected length of the longest one. We also proved that the same asymptotic upper bound is tight for the number of avoided words of fixed length k when the alphabet is sufficiently large. The authors in [3, 2, 4] studied a similar notion of unusual words -- based on different definitions than the ones Brendel et al. use for expectation and deviation -- focusing on the factors of a sequence; based on Brendel et al.'s definitions, we focus on any word over the alphabet. More recently, space-efficient detection of unusual words has also been considered [5]; such avoidances is becoming an interesting line of research [18]. In this article, we wish to complement our study in [1] by focusing on overabundant words. The moti- vation comes from molecular biology. Genome dynamics, i.e. the molecular mechanisms generating random mutations in the evolving genome, are quite complex, often presenting self-enhancing features. Thus, it is expected to often give rise to words of nucleotides which will be overabundant, i.e. being present at higher amounts than expected on the basis of their longest proper prefix, longest proper suffix, and longest infix frequencies. One specific such mechanism, which might generate overabundant words, is the following: it is well-known that in a genomic sequence of an initially random composition, the existing relatively long homonucleotide tracts present a higher frequency of further elongation than the frequency expected on the basis of single nucleotide mutations [15]; that is, they present a sort of autocatalytic self-elongation. This feature, in combination with the much higher frequency of transition vs. transversion mutation events, gen- erates overabundant words which are homopurinic or homopurimidinic tracts. It is also anticipated that the overabundance of homonucleotide tracts will strongly differentiate between conserved and non-conserved parts of the genome. While this phenomenon is largely free to act within the non-conserved genomic regions, and thus it is expected to generate there large amounts of overabundant words, it is hindered in the conserved genomic regions due to selective constraints. Our Contributions. Analogously to avoided words [6, 11, 1], many different models and algorithms exist for identifying words that are in abundance in a given sequence; see for instance [7, 9]. In this article, we make use of the biologically justified model introduced by Brendel et al. [6] and, by proving non-trivial combinatorial properties, we show that it admits efficient computation for overabundant words as well. We also present experimental results, using both synthetic and real data, which further highlight the effectiveness of this model. The computational problem can be described as follows. Given a sequence x of length n and a real number ρ > 0, compute the set of ρ-overabundant words, i.e. all words w for which dev(w) ≥ ρ. We present an O(n)-time and O(n)-space algorithm for computing all ρ-overabundant words (of any length) in a sequence x of length n over an integer alphabet. This result is based on a combinatorial property of the suffix tree T of x that we prove here: the number of distinct factors of x whose longest infix is the label of an explicit node of T is no more than 3n− 4. We further show that the presented algorithm is time-optimal by proving that O(n) is a tight upper bound for the number of ρ-overabundant words. Finally, we pose an open question of combinatorial nature on the maximum number OW(n, σ) of overabundant words that a sequence of length n over an alphabet of size σ > 1 can contain. 2 Terminology and Technical Background 2.1 Definitions and Notation We begin with basic definitions and notation, generally following [8]. Let x = x[0]x[1] . . x[n− 1] be a word of length n = x over a finite ordered alphabet Σ of size σ, i.e. σ = Σ. In particular, we consider the case of an integer alphabet ; in this case each letter is replaced by its rank such that the resulting word consists of integers in the range {1, . . . , n}. In what follows we assume without loss of generality that Σ = {0, 1, . . . , σ − 1}. We also define Σx to be the alphabet of word x and σx = Σx. For two positions i and j on x, we denote by x[i . . j] = x[i] . . x[j] the factor (sometimes called subword ) of x that starts at position i and ends at position j (it is empty if j < i), and by ε the empty word, word of length 0. We recall that a prefix of x is a factor that starts at position 0 (x[0 . . j]) and a suffix is a factor that ends at position n − 1 (x[i . . n − 1]), and that a factor of x is a proper factor if it is not x itself. A factor of x that is neither a prefix nor a suffix of x is 2 number of words O(σn) O((σn)2) O(n) ρ1 ρ2 dev(w) Figure 1: For a word x, the words for which dev(w) is defined are the ones of the form w = aub, where u is a factor of x and a, b ∈ Σ, not necessarily distinct. There are O(n2) distinct factors in a word of length n and for each of these we obtain σ2 words of this form. We have shown that the ρ1-avoided words are O(σn) [1]. In this article, we show that the ρ2-overabundant ones are O(n). called an infix of x. We denote the reverse word of x by rev(x), i.e. rev(x) = x[n − 1]x[n − 2] . . x[1]x[0]. We say that x is a power of a word y if there exists a positive integer k, k > 1, such that x is expressed as k consecutive concatenations of y; we denote that by x = yk. Let w = w[0]w[1] . . w[m − 1] be a word, 0 < m ≤ n. We say that there exists an occurrence of w in x, or, more simply, that w occurs in x, if w is a factor of x, which we denote by w (cid:22) x. Every occurrence of w can be characterised by a starting position in x. Thus we say that w occurs at position i in x when w = x[i . . i + m − 1]. Further, let f (w) denote the observed frequency, that is, the number of occurrences of a non-empty word w in word x. If f (w) = 0 for some word w, then w is called absent (which is denoted by w 6(cid:22) x), otherwise, w is called occurring. By f (wp), f (ws), and f (wi) we denote the observed frequency of the longest proper prefix wp, suffix ws, and infix wi of w in x, respectively. We can now define the expected frequency of word w, w > 2, in x as in Brendel et al. [6]: E(w) = f (wp) × f (ws) f (wi) , if f (wi) > 0; else E(w) = 0. (1) f (wi) . Although these two events are not always independent, the product f (wp) The above definition can be explained intuitively as follows. Suppose we are given f (wp), f (ws), and f (wi). Given an occurrence of wi in x, the probability of it being preceded by w[0] is f (wp) f (wi) as w[0] precedes exactly f (wp) of the f (wi) occurrences of wi. Similarly, this occurrence of wi is also an occurrence of ws with probability f (ws) f (wi) gives a good approximation of the probability that an occurrence of wi at position j implies an occurrence of w at position j − 1. It can be seen then that by multiplying this product by the number of occurrences of wi we get the above formula for the expected frequency of w. Moreover, to measure the deviation of the observed frequency of a word w from its expected frequency in x, we define the deviation (χ2 test) of w as: f (wi) × f (ws) dev(w) = f (w) − E(w) max{pE(w), 1} . (2) For more details on the biological justification of these definitions see [6] and [1]. Using the above definitions and two given thresholds, we can classify a word w as either avoided, common, or overabundant in x. In particular, for two given thresholds ρ1 < 0 and ρ2 > 0, a word w is called ρ1-avoided if dev(w) ≤ ρ1, ρ2-overabundant if dev(w) ≥ ρ2, and (ρ1, ρ2)-common otherwise (see Figure 1). We have very recently shown that the number of ρ1-avoided words is O(σn), and have introduced a time-optimal algorithm for computing all of them in a given sequence over an integer alphabet [1]. In this article, we show that the number of ρ2-overabundant words is O(n), and study the following computational problem. 3 AllOverabundantWordsComputation Input: A word x of length n and a real number ρ > 0 Output: All ρ-overabundant words in x 2.2 Suffix Trees In our algorithms, suffix trees are used extensively as computational tools. For a general introduction to suffix trees see [8]. The suffix tree T (x) of a non-empty word x of length n is a compact trie representing all suffixes of x. The nodes of the trie which become nodes of the suffix tree are called explicit nodes, while the other nodes are called implicit. Each edge of the suffix tree can be viewed as an upward maximal path of implicit nodes starting with an explicit node. Moreover, each node belongs to a unique path of that kind. Then, each node of the trie can be represented in the suffix tree by the edge it belongs to and an index within the corresponding path. We use L(v) to denote the path-label of a node v, i.e., the concatenation of the edge labels along the path from the root to v. We say that v is path-labelled L(v). Additionally, D(v) = L(v) is used to denote the word-depth of node v. Node v is a terminal node if and only if L(v) = x[i . . n − 1], 0 ≤ i < n; here v is also labelled with index i. It should be clear that each occurring word w in x is uniquely represented by either an explicit or an implicit node of T (x). The suffix-link of a node v with path-label L(v) = αy is a pointer to the node path-labelled y, where α ∈ Σ is a single letter and y is a word. The suffix-link of v exists if v is a non-root internal node of T (x). In any standard implementation of the suffix tree, we assume that each node of the suffix tree is able to access its parent. Note that once T (x) is constructed, it can be traversed in a depth-first manner to compute the word-depth D(v) for each node v. Let u be the parent of v. Then the word-depth D(v) is computed by adding D(u) to the length of the label of edge (u, v). If v is the root then D(v) = 0. Additionally, a depth-first traversal of T (x) allows us to count, for each node v, the number of terminal nodes in the subtree rooted at v, denoted by C(v), as follows. When internal node v is visited, C(v) is computed by adding up C(u) of all the nodes u, such that u is a child of v, and then C(v) is incremented by 1 if v itself is a terminal node. If a node v is a leaf then C(v) = 1. We assume that the terminal nodes of T (x) have suffix-links as well. We can either store them while building T (x) or just traverse it once and construct an array node[0 . . n − 1] such that node[i] = v if L(v) = x[i . . n− 1]. We further denote by Parent(v) the parent of a node v in T (x) and by Child(v, α) the explicit node that is obtained from v by traversing the outgoing edge whose label starts with α ∈ Σ. A batch of q Child(v, α) queries can be answered off-line in time O(n + q) for a word x over an integer alphabet (via radix sort). 3 Combinatorial Properties In this section, we prove some properties that are useful for designing the time-optimal algorithm presented in the next section. Fact 1. Given a word x of length n over an alphabet of size σ, the number of words w for which dev(w) is defined is O((σn)2). Proof. For a word w over Σ, dev(w) is only defined if wi (cid:22) x. Hence the words w for which dev(w) is defined are of the form aub for some non-empty u (cid:22) x and a, b ∈ Σ. For each distinct factor u 6= ε of x there are σ2 words of the form aub, a, b ∈ Σ. Since there are O(n2) distinct factors in a word of length n, the fact follows. Fact 2. Every word w that does not occur in x and for which dev(w) is defined has dev(w) ≤ 0. Proof. For such a word we have that E(w) ≥ 0 and that f (w) = 0 and hence dev(w) = f (w)−E(w) max{√E(w),1} ≤ 0. 4 Naıve algorithm. By using Fact 2, we can compute dev(w), for each factor w of x, thus solving Prob- lem AllOverabundantWordsComputation. There are O(n2) such factors, however, which make this computation inefficient. Fact 3. Given a factor w of a word x, if wi corresponds to an implicit node in the suffix tree T (x), then so does wp. Proof. A factor w′ of x corresponds to an implicit node T (x) if and only if every occurrence of it in x is followed by the same unique letter b ∈ Σ. Hence, since wp = awi for some a ∈ Σ, if wi is always followed by, say, b ∈ Σ, every occurrence of wp in x must also always be followed by b. Thus wp corresponds to an implicit node as well. Lemma 1. If w is a factor of a word x and wi corresponds to an implicit node in T (x), then dev(w) = 0. Proof. If a word w′ (cid:22) x corresponds to an implicit node along the edge (u, v) in T (x) and L(v) = w then the number of occurrences of w′ in x is equal to that of w. If wi corresponds to an implicit node on edge (u, v) it follows immediately that f (wi) = f (ws), as either ws also corresponds to an implicit node in the same edge or ws = L(v). In addition, from Fact 3 we have that wp is an implicit node as well and it similarly follows that f (wp) = f (w). We thus have E(w) = f (wp)×f (ws) = f (w) and hence dev(w) = f (w)−E(w) max{√E(w),1} f (wi) = 0. Based on these properties, the aim of the algorithm in the next section is to find the factors of x whose longest infix corresponds to an explicit node and check if they are ρ-overabundant. More specifically, for each explicit node v in T (x), such that L(v) = y, we aim at identifying the factors of x that have y as their longest infix (i.e. factors of the form ayb, a, b ∈ Σ). We will do that by identifying the factors of x that have y as their longest proper suffix (i.e. factors of the form ay, a ∈ Σ) and then checking for each of these the different letters that succeed it in x. Then we can check in time O(1) if each of these words is ρ-overabundant. Note that the algorithm presented in Section 4 is fundamentally different and in a sense more involved than the one presented in [1] for the computation of occurring ρ-avoided words (note that a ρ-avoided word can be absent). This is due to the fact that for occurring ρ-avoided words we have the stronger property that wp must correspond to an explicit node. Theorem 1. Given a word x of length n, the number of distinct factors of x of the form ayb, where a, b ∈ Σ and y 6= ε is the label of an explicit node of T (x), is no more than 3n − 2 − 2σx. Proof. Let S be the set of all explicit or implicit nodes in T (x) of the form yb such that y is represented by an explicit node other than the root. We have at most 2n − 2 − σx of them; there are at most 2n − 2 edges in T (x), but σx of them are outgoing from the root. For such a word yb, the number of factors of x of the form ayb is equal to the degree of the node representing rev(yb) in T (rev(x)). For every node in S, we obtain a distinct node in T (rev(x)). Let us suppose that k1 of these nodes are non-root internal explicit nodes, k2 are leaves, and the rest 2n − 2 − σx − k1 − k2 are implicit nodes. Each internal explicit node u contributes at most deg(u), each leaf contributes 0, and each implicit node contributes at most 1. Hence the number of such words would be maximised if we obtained all the non-root internal explicit nodes and no leaves. Let T (rev(x)) have m non-root internal explicit nodes. The resulting upper bound then is Pu∈T (rev(x))\{root} deg(u) + (2n − 2 − σx − m) ≤ n + m − σx + (2n − 2 − σx − m) = 3n − 2 − 2σx. Note that Pu∈T (rev(x))\{root} deg(u) ≤ n + m − σx since there are at most n edges from explicit internal nodes to leaves and m edges to other internal nodes; σx of these are outgoing from the root. Corollary 2. The ρ-overabundant words in a word x of length n are at most 3n − 2 − 2σx. 5 Proof. By Fact 2, Lemma 1, and symmetry, it follows that the ρ-overabundant words in x are factors of x of the form ayb, where a, b ∈ Σ, such that y 6= ε is represented by an explicit node in T (x) and rev(y) represented by an explicit node in T (rev(x)). Hence they are a subset of the set of words considered in Theorem 1. Lemma 2. The ρ-overabundant words in a word x of length n over a binary alphabet (e.g. Σ = {a, b}) are no more than 2n − 4. Proof. For every internal explicit node u of T (x), other than the root, let deg′(u) be deg(u) + 1 if node u is terminal and deg(u) otherwise. The sum of deg′(u) over the internal explicit non-root nodes of T (x) is no more than 2n − 4 (ignoring the case when x = αn, α ∈ Σ).We will show that, for each such node, the ρ-overabundant words with wi = L(u) as their longest proper infix are at most deg′(u). • Case I: deg′(u) = 2. -- Subcase 1: deg(u) = 1. Node u is terminal and it has an edge with label α. We can then have at most 2 ρ-overabundant words with wi as their longest proper infix: awiα and bwiα. -- Subcase 2: deg(u) = 2. Node u is not terminal and it has an edge with label a and an edge with label b. If only one of awi and bwi occurs in x we are done. If both of them occur in x we argue as follows (irrespective of whether wi is also a prefix of x): If awia is ρ-overabundant, then f (awia)−f (awi)×f (wia)/f (wi) ≥ ρ > 0 ⇒ f (awia)/f (awi) > f (wia)/f (wi) ⇔ 1−f (awia)/f (awi) < 1 − f (wia)/f (wi) ⇔ f (awib)/f (awi) < f (wib)/f (wi) ⇔ f (awib) − f (awi) × f (wib)/f (wi) < 0 and hence awib is not ρ-overabundant. (Similarly for bwia and bwib.) • Case II: deg′(u) = 3. Node u is terminal and it has an edge with label a and an edge with label b. If only one of awi and bwi occurs in x or if both of them occur in x, but wi is not a prefix of x, we can have at most 2 ρ-overabundant words with wi as the proper longest infix; this can be seen by looking at the node representing rev(wi) in T (rev(x)), which falls in Case I. So we only have to consider the case where both awi and bwi occur in x and wi is a prefix of x. For this case, we assume without loss of generality that awi is a suffix of x. If awia is ρ-overabundant, then f (awia)−f (awi)×f (wia)/f (wi) ≥ ρ > 0 ⇒ f (awia)/f (awi) > f (wia)/f (wi) ⇔ 1−f (awia)/f (awi) < 1−f (wia)/f (wi) ⇔ (f (awib)+1)/f (awi) < (f (wib)+1)/f (wi) ⇒ f (awib)/f (awi) < (f (wib)/f (wi) ⇔ f (awib) − f (awi) × f (wib)/f (wi) < 0 and hence awib is not ρ-overabundant. Thus in this case we can have at most 3 = deg′(u) ρ- overabundant words. We can thus have at most deg′(u) ρ-overabundant words for each internal explicit non-root node of T (x). This concludes the proof. Lemma 3. The ρ-overabundant words in a word of length n are O(n) and this bound is tight. There exists a word over the binary alphabet with 2n − 6 ρ-overabundant words. Proof. The asymptotic bound follows directly from Corollary 2. The tightness of the asymptotic bound can be seen by considering word x = ban−2b, a, b ∈ Σ, of length n and some ρ such that 0 < ρ < 1/n. Then for every prefix w of x of the form bak or for every suffix w of x of the form akb, 2 ≤ k ≤ n − 2, we have that f (wp) = f (w) = 1, f (ws) = n − k − 1, and f (wi) = n − k. Hence for any w we have dev(w) = 1 − 1×(n−k−1) n−k > ρ. For instance, for w = ban−2, we have dev(w) = 1/2. There are 2n − 6 = Ω(n) such factors and hence at least these many ρ-overabundant words in x. Corollary 3. The (ρ1, ρ2)-common words in a word of length n over an alphabet of size σ are O((σn)2). Proof. By Fact 1 we know that dev(w) is defined for O((σn)2) words. The ρ1-avoided ones are O(σn) [1], while the ρ2-overabundant are O(n) by Corollary 2. Hence the (ρ1, ρ2)-common words are O((σn)2). = 1 n−k 6 4 Algorithm Based on Fact 2 and Lemma 1 all ρ-overabundant words of a word x are factors of x of the form ayb, where a, b ∈ Σ and y is the label of an explicit node of T (x). It thus suffices to consider these words and check for each of them whether it is ρ-overabundant. We can find the ones that have their longest proper prefix represented by an explicit node in T (x) easily, by taking the suffix-link from that node during a traversal of the tree. To find the ones that have their longest proper prefix represented by an implicit node we use the following fact, which follows directly from the definition of the suffix-links of the suffix tree. Fact 4. Suppose aw, where a ∈ Σ and w ∈ Σ∗, is a factor of a word x. Further suppose that w is represented by an explicit node v in T (x), while aw by an implicit node along the edge (u1, u2) in T (x). Then, the suffix- link from u2 points to a node in the subtree of T (x) rooted at v. ⊲ prefix node ⊲ infix node ⊲ y is a terminal node Algorithm 1 Compute all ρ-overabundant words 1: procedure ComputeOverabundantWords(word x, real number ρ) 2: T (x) ← BuildSuffixTree(x) for each node v ∈ T (x) do D(v) ← word-depth of v C(v) ← number of terminal nodes in the subtree rooted at v for each node v ∈ T (x) do ⊲ Report ρ-overabundant words w such that wp is explicit u ← suffix-link[v] if D(v) > 1 and IsInternal(v) then fp ← C(v), fi ← C(u) if fi > fp and u 6= Root(T (x)) then for each child y of node v do 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: if not(IsTerminal(y) and D(y) = D(v) + 1) then fw ← C(y) α ← L(y)[D(v) + 1] fs ← C(Child(u, α)) E ← fp × fs/fi if (fw − E)/(max{1, √E}) ≥ ρ then Report(L(y)[0 . .D(v)]) ⊲ Report ρ-overabundant words w such that wp is implicit for each child y of node v do if D(y) > D(v) + 1 then if IsInternal(y) then else z ← suffix-link[y] i ← label[y] z ← node[i + 1] if D(z) = D(Parent(z)) + 1 then z ← Parent(z) fw ← fp ← C(y) while Parent(z) 6= u do fi ← C(Parent(z)) fs ← C(z) E ← fp × fs/fi if (fw − E)/(max{1,√E}) ≥ ρ then z ← Parent(z) Report(L(y)[0 . .D[Parent(z)] + 1]) 7 node v u = suffix-link[v] node v u = suffix-link[v] q = Child(v, α) z = suffix-link[q] q = Child(v, α), label[q] = i label[z] = i + 1 Figure 2: The above figures illustrate the nodes (implicit or explicit) considered in a step (lines 6-37) of Algorithm 1. The figure on the left presents the case where Child(v, α) is an internal node, while the right one the case that it is a leaf. Black nodes represent implicit nodes along the edge (v, q) that we have to consider as potential wp, and the red dotted line joins them with the respective (white) explicit node that represents the longest suffix of this wp, i.e. wi. The algorithm first builds the suffix tree of word x, which can be done in time and space O(n) for words over an integer alphabet [10]. It is also easy to compute D(v) and C(v), for each node v of T (x), within the same time complexity (lines 2 − 5 in Algorithm 1). The algorithm then performs a traversal of T (x). When it first reaches a node v, it considers L(v) as a potential longest proper prefix of ρ-overabundant words -- i.e. L(v) = wp = awi, where a ∈ Σ. By following the suffix-link to node u, which represents the respective wi, and based on the first letter of the label of each outgoing edge (v, q) from v, it computes the deviation for all possible factors of x of the form wpb, where b ∈ Σ. (Note that we can answer all the Child(u, α) queries off-line in time O(n) in total for integer alphabets.) It is clear that this procedure can be implemented in time O(n) in total (lines 7 − 19). Then, while on node v and based on Fact 4, the algorithm considers for every outgoing edge (v, q), the implicit nodes along this edge that correspond to words (potential wp's) whose proper longest suffix (the respective wi) is represented by an explicit node in T (x). Hence, when D(q) − D(v) > 1 the algorithm follows the suffix-link from node q to node z. It then checks whether Parent(z) = u. If not, then the word L(q)[0 . . D(Parent(z))] is represented by an implicit node along the edge (v, q) and hence L(q)[0 . .D(Parent(z)) + 1] has to be checked as a potential ρ-overabundant word. After the check is completed, the algorithm sets z = Parent(z) and iterates until Parent(z) = u. This is illustrated in Figure 2. By Theorem 1, the Parent(z) = u check will fail O(n) times in total. All other operations take time O(1) and hence this procedure takes time O(n) in total (lines 20 − 37). We formalise this procedure in Algorithm 1, where we assume that the suffix tree of x$ is built, where $ is a special letter, $ /∈ Σ. This forces all terminal nodes in T (x) to be leaf nodes. We thus obtain the following result; optimality follows directly from Lemma 3. Theorem 4. Algorithm 1 solves problem AllOverabundantWordsComputation in time and space O(n), and this is time-optimal. 8 5 Experimental Results: Effectiveness, Efficiency, and Applica- tions Algorithm 1 was implemented as a program to compute the ρ-overabundant words in one or more input sequences. The program was implemented in the C++ programming language. Our program makes use of the implementation of the compressed suffix tree available in the Succinct Data Structure Library [12]. The input parameters are a (Multi)FASTA file with the input sequence(s) and a real number ρ > 0. The output is a file with the set of ρ-overabundant words per input sequence. The implementation is distributed under the GNU General Public License, and it is available at http://github.com/solonas13/aw. The experiments were conducted on a Desktop PC using one core of Intel Core i5-4690 CPU at 3.50GHz. The program was compiled with g++ version 4.8.4 at optimisation level 3 (-O3). We also implemented a brute-force approach to confirm the correctness of our implementation. Experiment I. (Effectiveness) In the first experiment, our task was to establish the effectiveness of the statistical model in identifying overabundant words. To this end, we generated 25 random sequences of length n = 80, 000 over the DNA alphabet Σ = {A, C, G, T} (uniform distribution). Then for each of these sequences, we inserted a random word w of length m = 6 in t random positions. We varied the value of t based on the fact that in a random sequence of length n over an alphabet of size σ = Σ, where letters are independent, identically uniformly distributed random variables, a specific word of length m is expected to occur roughly r = n/σm times. We hence considered t equal to r, 2r, 4r, 8r, and 16r. We then ran our program for each resulting sequence to identify the ρ-overabundant words with ρ = 0.000001, and output the deviation of the inserted word w, as well as the word wmax with the maximum deviation. The inserted word w was reported as a ρ-overabundant word in all cases. Furthermore, in many cases the word with the maximum deviation was w itself and in many other cases one of its factors; this was true in all cases for t ≥ 80 ≈ 4r. Hence, the model is effective in identifying words that are overabundant. The full results of this experiment are presented in Table 1. Experiment II. (Efficiency) Our task here was to establish the fact that the elapsed time of the imple- mentation grows linearly with n, the length of the input sequence. As input datasets, for this experiment, we used synthetic DNA (σ = 4) and proteins (σ = 20) sequences ranging from 1 to 128 M (Million letters). For each sequence we used a constant value of ρ = 10. The results are plotted in Fig. 3. It becomes evident from the results that the elapsed time of the program grows linearly with n. The longer time required for the proteins sequences compared to the DNA sequences for increasing n is explained by the dependence of the time required to answer queries of the from Child(v, α) on the size of the alphabet (σ = 20 vs. σ = 4) in the implementation of the compressed suffix tree we used. Experiment III. (Real Application) Here we proceed to the examination of seven collections of Conserved Non-coding Elements (CNEs) obtained through multiple sequence alignment between the human and other genomes. Despite being located at the non-coding part of genomes, CNEs can be extremely conserved on the sequence level across organisms. Their genesis, functions and evolutionary dynamics still remain enig- matic [16, 13]. The detailed description of how those CNEs were identified can be found in [17]. For each CNE of these datasets, a sequence stretch (surrogate sequence) of non-coding DNA of equal length and equal GC content was taken at random from the repeat-masked human genome. The CNEs of each collection were concatenated into a single long sequence and the same procedure was followed for the corresponding surro- gates. We have determined through the proposed algorithm the overabundant words for k = 10 (decamers) and ρ = 3 for these fourteen datasets and the results are presented in Table 2. Likewise, in Table 3, we show all overabundant words (i.e. k > 2) for ρ = 3. The first five CNE collections have been composed through multiple sequence alignment of the same set of genomes (human vs. chicken; mapped on the human genome) and they differ only in the thresholds of sequence similarity applied between the considered genomes: from 75% to 80% (the least conserved CNEs, which thus are expected to serve less demanding functional roles) to 95 -- 100% which represent the extremely conserved non-coding elements (UCNEs or CNEs 95 -- 100) [17]. The remaining two collections have been composed under different constraints and have been derived after alignment of Mammalian and Amniotic genomes. In Tables 2 and 3, the last line shows the ratios formed by the numbers of overabundant words 9 Times t of inserting w 20 40 80 160 320 AAACAG w dev(w) wmax dev(wmax) w dev(w) wmax dev(wmax) w dev(w) wmax dev(wmax) w dev(w) wmax dev(wmax) w dev(w) wmax dev(wmax) TTACAA 2.233313 CTCCTATG 3.354102 AATCTG 2.034233 ATTGGGG 3.265609 GTACCA 2.187170 TCTGTGCG 3.548977 CCATAG 2.470681 CAGTGGTC 3.333333 TCGACA 1.531083 CTTTGCT 3.308195 GTGCCC CACTTT AGTTAC 4.143015 5.623615 6.010327 5.674220 GTGCCC 4.143015 AGTCGA 2.888529 TCTGTATG 3.272727 GGCGTG 3.658060 ACGATACC 4.000000 GTTGAT 2.467858 TTTTCCT 3.368226 CGCTTT CACTTT 5.623615 GAAGTC 4.456468 GAAGTC AGTTA 6.900740 TATCTT ACAG 9.617803 CAAAAA 5.073860 11.071170 ATCTT CAAAAA 4.456468 6.115612 11.071170 AAGGAT GGGTCC TTCCGG 4.428189 5.467296 5.256409 AAGGAT GGTCC TTCCG 4.428189 6.787771 9.105009 TGAGCG ACATTT CTTGTA 4.214544 5.755475 5.362435 TGAGC ACATT TTGTA 5.072968 6.376277 9.467110 TACAAC TATTAG TGAGAT 2.789220 3.552902 4.959926 5.124976 ATTACC ACAAC ATTAG GACAT 3.322163 5.653479 6.837628 10.012316 Table 1: The deviation of the randomly generated inserted word w, as well as the word wmax with the maximum deviation. The length of each of the 25 randomly generated sequences over Σ = {A, C, G, T} was n = 80, 000, the length of w was m = 6, and ρ = 0.000001. In green are the cases when the word with the maximum deviation was w itself or one of its factors. 2000 1500 ] s [ e m T i 1000 500 0 DNA Proteins 2x107 4x107 6x107 Length n 8x107 1x108 1.2x108 Figure 3: Elapsed time of Algorithm 1 using synthetic DNA (σ = 4) and proteins (σ = 20) sequences of length 1M to 128M. 10 k = 10, ρ = 3 Surr CNEs Ratio CNEs 75-80 1,144 331 3.46 CNEs 80-85 718 181 3.97 CNEs 85-90 473 100 4.73 CNEs 90-95 297 59 5.03 CNEs 95-100 469 71 6.61 Mammalian Amniotic 15,470 491 31.51 2,874 149 19.29 Table 2: Number of overabundant words for k = 10 and ρ = 3. k > 2, ρ = 3 Surr CNEs Ratio CNEs 75-80 5,925 1,373 4.32 CNEs 80-85 3,798 778 4.88 CNEs 85-90 2,770 512 5.41 CNEs 90-95 1,948 390 4.99 CNEs 95-100 2,405 403 5.97 Mammalian Amniotic 69,022 7,549 9.14 12,913 1,401 9.22 Table 3: Number of overabundant words for k > 2 and ρ = 3. of each concatenate of surrogates divided by the numbers of overabundant words of the corresponding CNE dataset. Two immediate results stem from inspection of Tables 2 and 3: 1. In all cases, the number of overabundant words from the surrogate concatenate of sequences far exceeds the corresponding number derived from the CNE dataset. 2. In the case of datasets with increasing degree of similarity between aligned genomes (from 75-80 to 95-100), the ratios of the numbers of overabundant words show a clear, increasing trend. Both these findings can be understood on the basis of the difference in functionality between CNE and surrogate datasets. As we briefly describe in Section 1, this systematic difference (finding 1 above) is expected on the basis of the self-enhancing elongation of relatively long homonucleotide tracts [14, 15], which occurs mainly in the non-constrained parts of the genome, here the surrogate datasets. Moreover, finding 2 corroborates the proposed mechanism of overabundance, as in CNE datasets 1-5 depletion in overabundant words quantitatively follows the degree of sequence conservation. Inspection of the individual overabundant words found in the surrogate datasets verifies that they largely consist of short repeats of the types described in [14] and in [15]. There is an analogy of this finding with a corresponding one, concerning the occurrence of avoided words in the same sequence sets, which was described in [1]. 6 Final Remarks By Lemmas 2 and 3, we know that the maximum number OW(n, σ) of overabundant words in any sequence of length n over an alphabet of size σ > 1 lies between 2n− 6 ≤ OW(n, σ) ≤ 3n− 2− 2σ. We have conducted computational experiments, and for σ > 2 we obtained sequences with more than 2n overabundant words. An open problem is to find OW(n, σ). References [1] Yannis Almirantis, Panagiotis Charalampopoulos, Jia Gao, Costas S. Iliopoulos, Manal Mohamed, Solon P. Pissis, and Dimitris Polychronopoulos. On avoided words, absent words, and their application to biological sequence analysis. Algorithms for Molecular Biology, 12(1):5, 2017. 11 [2] Alberto Apostolico, Mary Ellen Bock, and Stefano Lonardi. Monotony of surprise and large-scale quest for unusual words. Journal of Computational Biology, 10(3-4):283 -- 311, 2003. [3] Alberto Apostolico, Mary Ellen Bock, Stefano Lonardi, and Xuyan Xu. Efficient detection of unusual words. Journal of Computational Biology, 7(1-2):71 -- 94, 2000. [4] Alberto Apostolico, Fang-Cheng Gong, and Stefano Lonardi. Verbumculus and the discovery of unusual words. Journal of Computer Science and Technology, 19(1):22 -- 41, 2004. [5] Djamal Belazzougui and Fabio Cunial. Space-efficient detection of unusual words. In SPIRE, volume 9309 of LNCS, pages 222 -- 233. Springer, 2015. [6] Volker Brendel, Jacques S Beckmann, and Edward N Trifonov. Linguistics of nucleotide sequences: morphology and comparison of vocabularies. Journal of Biomolecular Structure and Dynamics, 4(1):11 -- 21, 1986. [7] Chris Burge, Allan M. Campbello, and Samuel Karlin. Over- and under-representation of short oligonu- cleotides in DNA sequences. Proc Natl Acad Sci USA, 89(4):1358 -- 1362, 1992. [8] Maxime Crochemore, Christophe Hancart, and Thierry Lecroq. Algorithms on strings. 2007. [9] Alain Denise, Mireille R´egnier, and Mathias Vandenbogaert. Assessing the statistical significance of over- represented oligonucleotides. In WABI, volume 2149 of LNCS, pages 85 -- 97. Springer Berlin Heidelberg, 2001. [10] Martin Farach. Optimal suffix tree construction with large alphabets. In FOCS, pages 137 -- 143. IEEE, 1997. [11] Mikhail S. Gelfand and Eugene V. Koonin. Avoidance of palindromic words in bacterial and archaeal genomes: a close connection with restriction enzymes. Nucleic Acids Research, 25(12):2430 -- 2439, 1997. [12] Simon Gog, Timo Beller, Alistair Moffat, and Matthias Petri. From theory to practice: Plug and play with succinct data structures. In SEA, volume 8504 of LNCS, pages 326 -- 337. Springer, 2014. [13] Nathan Harmston, Anja Baresi´c, and Boris Lenhard. The mystery of extreme non-coding conservation. Phil. Trans. R. Soc. B, 368(1632):20130021, 2013. [14] Suzanne E. Hile and Kristin A. Eckert. Positive correlation between DNA polymerase α-primase paus- ing and mutagenesis within polypyrimidine/polypurine microsatellite sequences. Journal of Molecular Biology, 335(3):745 -- 759, 2004. [15] G. Levinson and G. A. Gutman. Slipped-strand mispairing: a major mechanism for DNA sequence evolution. Molecular Biology and Evolution, 4(3):203 -- 221, 1987. [16] Dimitris Polychronopoulos, Diamantis Sellis, and Yannis Almirantis. Conserved noncoding elements follow power-law-like distributions in several genomes as a result of genome dynamics. PloS One, 9(5):e95437, 2014. [17] Dimitris Polychronopoulos, Emanuel Weitschek, Slavica Dimitrieva, Philipp Bucher, Giovanni Felici, and Yannis Almirantis. Classification of selectively constrained DNA elements using feature vectors and rule-based classifiers. Genomics, 104(2):79 -- 86, 2014. [18] Ivan Rusinov, Anna Ershova, Anna Karyagina, Sergey Spirin, and Andrei Alexeevski. Lifespan of restriction-modification systems critically affects avoidance of their recognition sites in host genomes. BMC Genomics, 16(1):1, 2015. 12
1005.0513
1
1005
2010-05-04T13:05:16
Maximum flow is approximable by deterministic constant-time algorithm in sparse networks
[ "cs.DS" ]
We show a deterministic constant-time parallel algorithm for finding an almost maximum flow in multisource-multitarget networks with bounded degrees and bounded edge capacities. As a consequence, we show that the value of the maximum flow over the number of nodes is a testable parameter on these networks.
cs.DS
cs
Maximum flow is approximable by deterministic constant-time algorithm in sparse networks Endre Cs´oka Eotvos Lor´and University, Budapest, Hungary Abstract We show a deterministic constant-time parallel algorithm for finding an almost maximum flow in multisource-multitarget networks with bounded degrees and bounded edge capacities. As a consequence, we show that the value of the maximum flow over the number of nodes is a testable parameter on these networks. 1 Introduction In the last decade it became apparent that a large number of the most interesting structures and phenomena of the world can be described by networks which are so large that the data about them can be collected only by indirect means like random local sampling. This yielded the motivation of property testing and parameter testing, which became an intensively studied field recently (see [3], [12] and all references). There are two special cases that have been treated in most papers. One is the dense graphs, where a positive fraction of all pairs of nodes are connected. The other is the sparse graphs, these are mostly graphs with bounded degrees. In this paper, we deal only with parameter testing of bounded-degree graphs. A parameter tester of bounded-degree graphs means an algorithm which chooses a constant numb er of random nodes, and to these constant radius neighbourhoods, assigns an estimation (a number) which is at most ε far from the true parameter with at least 1 − ε probability. We call a parameter testable if there exists a tester with arbitrary small errors. There is a strongly connected concept called constant-time algorithm, intro- duced by Nguyen and Onak[14]. For example, consider the maximum matching problem. Here, a constant-time algorithm is a "local function" that decides about each edge that whether it chooses to the mathing or not, so that the chosen edges form a matching, and its size is at most εn less than the size of the maximum matching, with at least 1 − ε probability. Locality means that it depends only on the constant-size neighbourhood of the edge, including some random numbers, as follows. Randomization is strictly required to break sym- metry, for example in a regular large-girth graph. The idea of Nguyen and Onak was to assign independent random numbers to the nodes uniformly from [0, 1], 1 and the neighbourhood consists not only of the induced subgraph of nodes at most constant far from the chosen node, but also of the random numbers of these nodes. In that paper, they showed a constant-time algorithm for this and some other problems. About the connection of the two concepts, notice that if we have a constant- time algorithm producing the maximum matching then the ratio of the size of the maximum matching and the number of nodes is a testable parameter. Because we can make a tester which simply calculates the probability that the chosen random node would be covered by the matching produced by the constant-time algorithm, and the average of these probabilities is a good ap- proximation. In this paper, we show a constant-time deterministic algorithm for a version of the maximum flow problem. This determinism means that we will get the analogous result using no random numbers. If we delete all edges from all sources or targets then the value of the max- imum flow decreases to 0 while the distribution of the local neighbourhoods remains asymptotically the same. That is why the value of the maximum flow in a graph with 1, or even with o(n) sources or targets cannot be tested in any reasonable way. Similarly, one new edge with high capacity between a source and a target would increase the value of the maximum flow by this arbitrary large value. These are some reasons why we will deal only with multiple sources and targets and bounded capacities. 2 Model and results There is an input graph G with degrees bounded by d. Its vertices are separated into the disjoint union of the colour sets R (regular), S (source) and T (target). Each edge of the graph is considered as two directed edge in the two directions, and we have a capacity function c : ~E(G) → [0, M ] of the directed edges. The word "graph" will include these two structures and we handle d and M as global constants throughout the paper. Let V (G) = n, denote by out(v) the set of edges starting from a node v, and for an e ∈ ~E(G), let −e denote the edge e in the opposite direction. We define the flow as a function f : ~E(G) → R for which ∀e ∈ ~E(G) satisfies f (−e) = −f (e) and f (e) ≤ c(e) and ∀v ∈ S : X f (e) ≥ e∈out(v) 0 and ∀v ∈ T : X f (e) ≤ 0 and ∀v ∈ R : X f (e) = 0. The value of a e∈out(v) e∈out(v) flow f is f = X s∈S; e∈out(s) f (e). Denote a maximum flow by f ∗ = f ∗(G). The rooted neighbourhood of a vertex v or edge e of radius r, denoted by hr(v) and hr(e), means the induced subgraph (with colours and edge weights) of the vertices at a distance at most r from v or e, with a mark at v or e. The set of all possible neighbourhoods are denoted by H (1) . A local (flow) assignment means a function L : H (2) r → R for which the function e → L(hr(e)) and H (2) r r 2 is a flow for each graph. Theorem 1. For each ε > 0 there exists a constant-time algorithm producing a flow with value ≥ f ∗ − εn. We emphasize that Theorem 1 is about not a stochastic but a deterministic assignment. So from this aspect, Theorem 1 is stronger than necessary to prove Theorem 2. We get this determinism only by averaging on all random labellings, since the space of flows is a convex set and the values of flows is a linear function. Theorem 2. f ∗(G) is testable, namely, for all ε > 0 there exist k, r ∈ N and a function g : (H (1) )k → R satisfying that if the vertices v1, v2, ... vk are chosen independently with uniform distribution then E(f ∗(G)/n − g(hr(v1), hr(v2), ... hr(vn))) < ε. r We note that for all ε > 0, having an approximation with expectedly < εn error is stronger but ofter equivalent to having this with < εn error with at least 1 − ε probability. 3 Proofs First we prove Theorem 1 using the following lemmas, and Theorem 2 will be an easy consequence of it. An augmenting path of a flow f is a directed path u = (e1, e2, ... ek) from S to T with f (ei) < c(ei) for each edge ei. The capacity of u means cap(u) = cap(u, f ) = min (c(ei) − f (ei)), and we identify an augmenting path u with the flow u : ~E(G) → R, u(e) = {1 if ∃i : e = ei; −1 if ∃i : e = −ei; 0 otherwise}, which we also call path-flow. Augmenting on such a path u means the incre- mentation of f by cap(u) · u. i Lemma 3. If for a flow f , there is no augmenting path with length at most l, then f ≥ f ∗ − dM l n. Proof. With the identically 2M capacity function, f ∗ − f is a flow, so we can split it into the sum of path-flows u1, u2, ... uq and a circulation u0 that follow the directions of the flow f ∗ − f , namely, ∀i ∈ {0, ... q}, e ∈ ~E(G) : sgn(ui(e)) ∈ {0, sgn((f ∗ − f )(e))}. Thus, f ∗ − f = f ∗ − f = q X i=1 ui = 1 2l q X i=1 2lui ≤ 1 2l q X i=1 X e∈ ~E(G) ui(e) = 1 2l X e∈ ~E(G) q X i=1 ui(e) ≤ 1 2l X e∈ ~E(G) 2M ≤ dnM l . Lemma 4. If for a flow f , there is no augmenting path shorter than k, then augmenting on a path with length k does not create a new augmenting path with length at most k. 3 Proof. Let the residual graph mean the graph without edge capacities Gf = (S(G), R(G), T (G), {e ∈ ~E(G)f (e) < c(e)}). Then the augmenting paths of G can be identified with the paths in Gf from S to T . So if the length of the shortest augmenting path of a flow is k then it means that the length of the shortest path in Gf from S to T is k. Let the movement of an edge in G mean the difference of the distances of its endpoint and starting point from S in Gf . Augmenting on a shortest path adds only such edges to the residual graph on which f decreases, which are the reverse edges of the path. All these edges have movement −1 (calculated before augmenting). So if a path becomes an augmenting path at this augmenting step then all its edges have movements at most 1 and contain an edge with movement −1, so its length is at least k+2. Let us label all paths u with length at most l with independent random variables x(u) chosen uniformly from [0, 1), forbidding any two labels to be equal. We define chain as a sequence u1, u2, ... us of such paths for which u1 + x(u1) > u2 + x(u2) > ... us + x(us) and ∀i ∈ {1, 2, ... s − 1} there exists a common undirected edge of ui and ui+1 (henceforth: these intersect each other). Lemma 5. For each l ∈ N and ε > 0 there exists a q = q(l, ε) ∈ N for which for every graph G (with degrees bounded by d) and its undirected edge e, with random labelling, the probability that there exists a chain u1, u2, ... uq for which u1 contains e is at most ε. Proof. There exists an upper bound z = z(l) for the number of paths with length at most l intersecting a given path of length at most l. Hence, there are at most zq sequences of paths u1, u2, ... uq for which e is in u1 and ∀i ∈ {1, 2, ... q − 1}, ui intersects ui+1. All such sequences contain ⌈q/l⌉ paths of the same length. The ordering of their labels the ⌈q/l⌉! permutations with the same probability, so the probablilty that the labels are decreasing is 1/⌈q/l⌉!. This event is necessary for the sequence to be a chain. Denote the number of chains in the lemma by the random variable X (with respect to the random labelling). We have P (X ≥ 1) ≤ E(X) ≤ zq ⌈ q l ⌉! → 0 where q → ∞, which proves the lemma for some large enough number q. Proof of Theorem 1. Consider the variant of the Edmonds -- Karp algorithm where we augment on the one of the shortest augmenting paths with the lowest label, and we stop the algorithm when no augmenting path with length at most l remains. In other words, we start from the empty flow, we take the paths u with length at most l in the increasing order of u + x(u), and with each path, we increase the actual flow f by cap(f, u) · u. We denote this algorithm by A1 and the resulting flow by f1 = f1(G, x). Consider now the variant of the previous algorithm where we skip augment- ing on each path which can be obtained as the first element of any chain 4 with length s. We denote this algorithm by A2 and the resulting flow by f2 = f2(G, x). The next lemma shows that f2(e) is a constant-time algorithm. Lemma 6. For each edge e and labelling x, f2(G, x)(e) = f2(hsl(e), (xV (hsl(e))))(e). Proof. Let us consider the run of the two algorithms in parallel so that when the first one takes a path u in G then if u is in hsl(e) then the second algorithm takes u as well, otherwise it does nothing. If at a point, the two flows differ at an edge e′ ∈ ~E(hsl(e)) then there must have been a path u through e′ on which the two algorithms augmented by different values. There are three possible reasons of it: 1. u is not in hsl(e); 2. u can be obtained as the first term of some chain in G with length s, but not in hsl(e); 3. u has an edge e′′ in hsl(e) at which the values of the two flows were different before taking u. Assume that at the end, the two flows are different on e. Using the previous observation initially with e′ = e, let us take a path u through e′ on which the two augmentations were different, and consider which of the three reasons occurred. As long as the third one, repeat the step with choosing e′ as the e′′ of the previous step. Since by each step we jump to an earlier point of the runs, we must get another reason sooner or later. Denote the paths considered during the process by u1, u2, ... ut. (Note that these are in reverse order on the augmenting timeline.) Consider the case when the reason for ut was the first reason. The set of all edges of all of these t paths is connected, it contains at most tl edges, it contains e and an edge at least sl away from e, so tl > sl, whence t > s. Thus u1, u2, ... us is a chain with a connected edge set with size at most sl, so this chain is in hsl(e), that is why neither runs should have been augmented on u1, contradicting with the definition of u1. On the other hand, if the reason for ut was the second reason then by ap- pending u1, u2, ... ut with the chain from ut with length s, as its subchain, we get a chain starting with u1 with length s, and it provides the same contradic- tion. We prove that if f2 is the output of A2 with l = 2dM/ε and using the function q of Lemma 5, with s = q(l, ε/(4dM )) satisfies the following inequality. E(f2) ≥ E(f1) − ε 2 n ≥ f ∗ − εn (1) f1 contains no augmenting path with length at most l, so using Lemma 3, f1 ≥ f ∗ − dM l n = f ∗ − dM 2dM ε n = f ∗ − ε 2 n. Consider now the first inequality. 5 Lemma 7. If f1(x)(e) 6= f2(x)(e) then there exists a path through e which is the first term of a chain with length s. Proof. Let us consider the run of A1 and A2 in parallel so that at the same time these take the same edge. If at a point of the runs, the two flows differ in an edge e′ then there must have been a path u through e′ on which the two algorithms augmented by different values. There are two possible reasons of it: 1. u is the first term of a chain with length s; 2. u has an edge e′′ on which the values of the two flows were different before taking u. Assume that at the end, the two flows are different at e. Using the previous observation, let us take a path u through e′ on which the two augmentation were different, and consider which of the two reasons occurred. As long as the latter one, repeat the step with choosing e′ as the e′′ of the previous step. Since by each step we jump to an earlier point of the runs, we must get the first reason in finite many steps. Denote the paths considered during the process by u1, u2, ... ut. Then appending u1, u2, ... ut with the chain from ut with length s, as its subchain, we get a chain starting with u1 with length s. If f1(x)(e) 6= f2(x)(e) then by Lemma 7, there exists a chain with length q(l, 4dM . But even 4dM ), and Lemma 5 says that this has probability at most if this occurs, f1(x) − f2(x) ≤ M − (−M ) = 2M . That is why, ε ε E(f1) − E(f2) = E(f1(x) − f2(x)) = E((f1(x) − f2(x)) = E( X f1(x)(e) − f2(x)(e)) ≤ X s∈S; e∈out(s) ≤ dn · ε 4dM s∈S; e∈out(s) ε 2 n. · 2M ≤ ε 4dM · 2M ≤ We are finished proving (1). Now, let ¯f2(e) = E(f2(x)(e)). It is a flow because it is easy to check that it satisfies all requirements, and ¯f2 = E(f2) ≥ f ∗ − εn. Furthermore, ¯f2(e) depends only on hsl(e), so it can be calculated by a constant-time algorithm. Consequently, this assignment satisfies the requirements of the theorem. Proof of Theorem 2. Let ¯f2 be the flow constructed by the constant-time al- gorithm of the previous proof with error bound ε/2, which therefore satisfies ¯f2 ∈ [f ∗ − ε 2 , f ∗], and let r be the radius used there plus 1. Using the notion I(b) = {1 if b is true, 0 if false} for an event b, let g(hr(v1), hr(v2), ... hr(vk)) = k X (I(vi ∈ S) X ¯f2(e)). (2) i=1 e∈out(vi) 1 k 6 As I(vi) Pe∈out(v) stochastically uniformly (with respect to G) converges to the following. ¯f2(e) ∈ [0, dM ], the Law of Large Numbers says that (2) 1 n X v∈V (G) (I(v ∈ S) X ¯f2(e)) = e∈out(v) 1 n X s∈S X ¯f2(e)) = ¯f2 ∈ [f ∗ − e∈out(v) ε 2 , f ∗]. This implies that, for a large enough k, these k, r and g satisfy the requirements. 4 Acknowledgement Thank you for L´aszl´o Lov´asz for the question and his help in making this paper. References [1] Alon, Shapira: A characterization of the (natural) graph properties testable with one-sided error ; SIAM Journal on Computing, vol. 37, no. 6, pp. 1703- 1727, 2008 [2] R Andersen, Y. Peres: Finding sparse cuts locally using evolving sets CoRR, vol. abs/0811.3779, 2008 [3] I Benjamini, O Schramm: Recurrence of distributional limits of finite planar graphs Electron. J. Probab. 6 no. 23, (2001) 13 pp. (electronic). [4] Benjamini, Schramm, Shapira: Every minorclosed property of sparse graphs is testable Symposium on Theory of Computing (STOC), 2008, pp. 393-402 [5] Bogdanov, Obata, Trevisan: A lower bound for testing 3-colorability in bounded-degree graphs; Foundations of Computer Science (FOCS) 2002, pp. 93-102 [6] Czumaj, Shapira, Sohler: Testing hereditary properties of nonexpanding bounded-degree graphs; SIAM Journal on Computing, vol. 38, no. 6, pp. 2499-2510, 2009 [7] G Elek: Parameter testing with bounded degree graphs of subexponential growth Random Structures and Algorithms (to appear) [8] G Elek, G Lippner: Borel Oracles. An analytical approach to constant-time algorithms Proceedings of the American Mathematical Society (to appear) [9] E Fischer: On the strength of comparisons in property testing Electronic Colloquium on Computational Complexity (ECCC) 8 (2001) 7 [10] O Goldreich, D Ron: Property testing in bounded degree graphs Algorithmica, vol. 32, no. 2, pp. 302-343, 2002 [11] Lenzen, Oswald, Wattenhofer: What can be approximated locally? Case study: Dominating sets in planar graphs; SPAA, 2008, pp. 46-54. [12] L Lov´asz: Very large graphs Current Developments in Mathematics, 2008 (2009), pp. 67-128 [13] Marko, Ron: Approximating the distance to properties in bounded-degree and general sparse graphs; ACM Transactions on Algorithms, vol. 5, no. 2, 2009 [14] Nguyen, Onak: Constant-Time Approximation Algorithms via Local Im- provements 49th Annual IEEE Symposium on Foundations of Computer Science, 2008, 327-336 [15] Parnas, Ron, Rubinfeld: Tolerant property testing and distance approxima- tion Journal of Computer and System Sciences, vol. 72, no. 6, pp. 1012-1042, 2006 [16] Yoshida, Yamamoto, Ito: An improved constant-time approximation al- gorithm for maximum matchings; Symposium on Theory of Computing (STOC), 2009 8
1911.08374
1
1911
2019-11-19T16:13:41
Concurrent Expandable AMQs on the Basis of Quotient Filters
[ "cs.DS" ]
A quotient filter is a cache efficient AMQ data structure. Depending on the fill degree of the filter most insertions and queries only need to access one or two consecutive cache lines. This makes quotient filters fast compared to the more commonly used Bloom filters that incur multiple cache misses. However, concurrent Bloom filters are easy to implement and can be implemented lock-free while concurrent quotient filters are not as simple. Usually concurrent quotient filters work by using an external array of locks -- each protecting a region of the table. Accessing this array incurs one additional cache miss per operation. We propose a new locking scheme that has no memory overhead. Using this new locking scheme we achieve 1.8 times higher speedups than with the common external locking scheme. Another advantage of quotient filters over Bloom filters is that a quotient filter can change its size when it is becoming full. We implement this growing technique for our concurrent quotient filters and adapt it in a way that allows unbounded growing while keeping a bounded false positive rate. We call the resulting data structure a fully expandable quotient filter. Its design is similar to scalable Bloom filters, but we exploit some concepts inherent to quotient filters to improve the space efficiency and the query speed. We also propose quotient filter variants that are aimed to reduce the number of status bits (2-status-bit variant) or to simplify concurrent implementations (linear probing quotient filter). The linear probing quotient filter even leads to a lock-free concurrent filter implementation. This is especially interesting, since we show that any lock-free implementation of another common quotient filter variant would incur significant overheads in the form of additional data fields or multiple passes over the accessed data.
cs.DS
cs
Concurrent Expandable AMQs on the Basis of Quotient Filters Tobias Maier, Peter Sanders, Robert Williger Karlsruhe Institute of Technology {t.maier, sanders}@kit.edu Abstract A quotient filter is a cache efficient Approximate Membership Query (AMQ) data structure. De- pending on the fill degree of the filter most inser- tions and queries only need to access one or two consecutive cache lines. This makes quotient fil- ters very fast compared to the more commonly used Bloom filters that incur multiple cache misses de- pending on the false positive rate. However, con- current Bloom filters are easy to implement and can be implemented lock-free while concurrent quotient filters are not as simple. Usually concurrent quo- tient filters work by using an external array of locks -- each protecting a region of the table. Accessing this array incurs one additional cache miss per op- eration. We propose a new locking scheme that has no memory overhead. Using this new locking scheme we achieve 1.8 times higher speedups than with the common external locking scheme. Another advantage of quotient filters over Bloom filters is that a quotient filter can change its size when it is becoming full. We implement this grow- ing technique for our concurrent quotient filters and adapt it in a way that allows unbounded growing while keeping a bounded false positive rate. We call the resulting data structure a fully expandable quo- tient filter. Its design is similar to scalable Bloom filters, but we exploit some concepts inherent to quotient filters to improve the space efficiency and the query speed. Additionally, we propose several quotient filter variants that are aimed to reduce the number of sta- tus bits (2-status-bit variant) or to simplify concur- rent implementations (linear probing quotient fil- ter). The linear probing quotient filter even leads to a lock-free concurrent filter implementation. This is especially interesting, since we show that any lock- free implementation of another common quotient filter variant would incur significant overheads in the form of additional data fields or multiple passes over the accessed data. 1 Introduction Approximate Membership Query (AMQ) data structures offer a simple interface to represent sets. Elements can be inserted, queried, and depending on the use case elements can also be removed. A query returns true if the element was previously in- serted. Querying an element might return true even if an element was not inserted. We call this a false positive. The probability that a non-inserted ele- ment leads to a false positive is called the false posi- tive rate of the filter. It can usually be chosen at the time of constructing the data structure. AMQ data structures have two main advantages over other set representations they are fast and space efficient. Similar to hash tables most AMQ data structures have to be initialized knowing a bound to their fi- nal size. This can be a problem for their space efficiency if no accurate bound is known. AMQ data structures have become an integral part of many complex data structures or data base applications. Their small size and fast accesses can be used to sketch large, slow data sets. The AMQ filter is used before accessing the data base to check whether a slow lookup is actually necessary. Some recent uses of AMQs include network analysis [1] and bio informatics [16]. These are two of the areas with the largest data sets available today, but given the current big data revolution we expect more and more research areas will have a need for the space efficiency and speedup potential of AMQs. The most common AMQ data structure in practice is still a Bloom filter even though a quotient filter would usually be significantly faster. One reason for this might be that concurrent Bloom filters are easy to implement -- even lock-free and well scaling im- plementations. This is important because well scal- ing implementations have become critical in today's multi-processor scenarios since single core perfor- mance stagnates and efficient multi-core computa- tion has become a necessity to handle growing data sets. We present a technique for concurrent quotient filters that uses local locking inside the table -- with- out an external array of locks. Instead of traditional locks we use the per-slot status bits that are inher- ent in quotient filters to lock local ranges of slots. As long as there is no contention on a single area of the table there is very little overhead to this lock- ing technique because the locks are placed in slots that would have been accessed anyways. An inter- esting advantage of quotient filters over Bloom fil- ters is that the capacity of a quotient filter can be increased without access to the original elements. However, because the false positive rate grows lin- early with the number of inserted elements, this is 1 only useful for a limited total growing factor. We implement this growing technique for our concur- rent quotient filters and extend it to allow large growing factors at a strictly bounded false positive rate. These fully expandable quotient filters com- bine growing quotient filters with the multi level approach of scalable Bloom filters [2]. in a sequential setting. Section 3 then describes our approach to concurrent quotient filters includ- ing the two variants: the lock-free linear probing quotient filter and the locally locked quotient filter. The dynamically growing quotient filter variant is described in Section 4. All presented data struc- tures are evaluated in Section 5. Afterwards, we draw our conclusions in Section 6. 1.1 Related Work Since quotient filters were first described in 2012 [3] there has been a steady stream of improvements. For example Pandey et al. [17] have shown how to reduce the memory overhead of quotient filters by using rank-select data structures. This also im- proves the performance when the table becomes full. Additionally, they show an idea that saves memory when insertions are skewed (some elements are inserted many times). They also mention the possibility for concurrent access using an external array of locks (see Section 5 for results). Recently, there was also a GPU-based implementation of quo- tient filters [9]. This is another indicator that there is a lot of interest in concurrent AMQs even in these highly parallel scenarios. Quotient filters are not the only AMQ data struc- tures that have received attention recently. Cuckoo filters [8, 13] and very recently Morton filters [4] (based on cuckoo filters) are two other examples of AMQ data structures. A cuckoo filter can be filled more densely than a quotient filter, thus, it can be more space efficient. Similar to cuckoo hash tables each access to a cuckoo filter needs to access multiple buckets -- leading to a worse performance when the table is not densely filled (a quotient filter only needs one access). It is also difficult to imple- ment concurrent cuckoo filters (similar to concur- rent cuckoo hash tables [11,14]); in particular, when additional memory overhead is unwanted, e.g., per- bucket locks. A scalable Bloom filter [2] allows unbounded growing. This works by adding additional levels of Bloom filters once one level becomes full. Each new filter is initialized with a higher capacity and a lower false positive rate than the last. The query time is dependent on the number of times the fil- ter has grown (usually logarithmic in the number of insertions). Additionally, later filters need more and more hash functions to achieve their false posi- tive rate making them progressively slower. In Sec- tion 4, we show a similar technique for fully expand- able quotient filters that mitigates some of these problems. 1.2 Overview In Section 2 we introduce the terminology and ex- plain basic quotient filters as well as our variations 2 Sequential Quotient Filter In this section we describe the basic sequential quo- tient filter as well as some variants to the main data structure. Throughout this paper, we use m for the number of slots in our data structure and n for the number of inserted elements. The fill degree of any given table is denoted by δ = n/m. Additionally, we use p+ to denote the probability of a false posi- tive query. 2.1 Basic Quotient Filter Quotient filters are approximate membership query data structures that were first described by Bender et al. [3] and build on an idea for space efficient hashing originally described by Cleary [6]. Quo- tient filters replace possibly large elements by fin- gerprints. The fingerprint f (x) of an element x is a number in a predefined range f : x (cid:55)→ {0, ..., 2k−1} (binary representation with exactly k digits). We commonly get a fingerprint of x by taking the k bot- tommost bits of a hash function value h(x) (using a common hash function like xxHash [7]). A quotient filter stores the fingerprints of all in- serted elements. When executing a query for an element x, the filter returns true if the finger- print f (x) was previously inserted and false oth- erwise. Thus, a query looking for an element that was inserted always returns true. A false posi- tive occurs when x was not inserted, but its fin- gerprint f (x) matches that of a previously inserted element. Given a fully random fingerprint function, the probability of two fingerprints being the same is 2−k. Therefore, the probability of a false positive is bounded by n· 2−k where n is the number of stored fingerprints. To achieve expected constant query times as well as to save memory, fingerprints are stored in a spe- cial data structure that is similar to a hash table with open addressing (specifically it is similar to robinhood hashing [5]). During this process, the fingerprint of an element x is split into two parts: the topmost q bits called the quotient quot(x) and the bottommost r bits called the remainder rem(x) (q + r = k). The quotient is used to address a table that consisting of m = 2q memory slots of r + 3 bits (it can store one remainder and three ad- ditional status bits). The quotient of each element 2 is only stored implicitly by the position of the ele- ment in the table. The remainder is stored explic- itly within one slot of the table. Similar to many hashing techniques, we try to store each element in one designated slot which we call its canonical slot (index quot(x)). With the help of the status bits we can reconstruct the quotient of each element even if it is not stored in its canonical slot. The main idea for resolving collisions is to find the next free slot -- similar to linear probing hash tables -- but to reorder the elements such that they are sorted by their fingerprints (see Figure 1). El- ements with the same quotient (the same canon- ical slot) are stored in consecutive slots, we call them a run. The canonical run of an element is the run associated with its canonical slot. The canoni- cal run of an element does not necessarily start in its canonical slot. It can be shifted by other runs. If a run starts in its canonical slot we say that it starts a cluster that contains all shifted runs after it. Multiple clusters that have no free slots between them form a supercluster. We use the 3 status bits that are part of each slot to distinguish between runs, clusters, and empty slots. For this we store the following information about the contents of the slot (further described in Table 1): Were elements hashed to this slot (is its run non-empty)? Does the element in this slot belong to the same run as the previous entry (used as a run-delimiter signal- ing where a new run starts)? Does the element in this slot belong to the same cluster as the previous entry (is it shifted)? During the query for an element x, all remainders stored in x's canonical run have to be compared to rem(x). First we look at the first status bit of the canonical slot. If this status bit is unset there is no run for this slot and we can return false. If there is a canonical run, we use the status bits to find it by iterating to the left until the start of a cluster (third status bit = 0). From there, we move to the right counting the number of non-empty runs to the left of the canonical run (slots with first status bit = 1 left of quot(x)) and the number of run starts (slots with second status bit = 0). This way, we can easily find the correct run and compare the appropriate remainders. An insert operation for element x proceeds sim- ilar to a query, until it either finds a free slot or a slot that contains a fingerprint that is ≥ f (x). The current slot is replaced with rem(x) shifting the fol- lowing slots to the right (updating the status bits appropriately). When the table fills up, operations become slow because the average cluster length increases. When the table is full, no more insertions are possible. In- stead, quotient filters can be migrated into a larger table -- increasing the overall capacity. To do this a new table is allocated with twice the size of the orig- inal table and one less bit per remainder. Address- ing the new table demands an additional quotient bit, since it is twice the size. This issue is solved by moving the uppermost bit from the remainder into the quotient (q(cid:48) = q + 1 and r(cid:48) = r − 1). The capacity exchange itself does not impact the false positive rate of the filter (fingerprint size and num- ber of elements remain the same). But the false positive rate still increases linearly with the num- ber of insertions (p+ = n · 2−k). Therefore, the false positive rate doubles when the table is filled again. We call this migration technique bounded growing, because to guarantee reasonable false pos- itive rates this method of growing should only be used a bounded number of times. 2.2 Variants We give a short explanation of counting quotient fil- ters using rank-and-select data structures [17]. Ad- ditionally, we introduce two previously unpublished quotient filter variants: the 2-status-bit quotient fil- ter and the linear probing quotient filter. (Counting) Quotient Filter Using Rank-and- Select. This quotient filter variant proposed by Pandey et al. [17] introduces two new features: the number of necessary status bits per slot is reduced to 2.125 by using a bitvector that supports rank- and-select queries and the memory footprint of mul- tisets is reduced by allowing counters to be stored in the table -- together with remainders. This quotient filter variant uses two status bits per slot the occupied-bit (first status bit in the de- scription above) and the run-end-bit (similar to the second bit). These are stored in two bitvectors that are split into 64 bit blocks (using 8 additional bits per block). To find a run, the rank of its occupied- bit is computed and the slot with the matching run- end-bit is selected. To reduce memory impact of repeated elements Pandey et al. use the fact that remainders are stored in increasing order. Whenever an element is inserted for a second time instead of doubling its remainder they propose to store a counter in the slot after its remainder this counter can be recog- nized as a counter because it does not fit into the increasing order (the counter starts at zero). As long as it remains smaller than the remainder this counter can count the number of occurrences of this remainder. Once the counter becomes too large an- other counter is inserted. Two-Status-Bit Quotient Filter. Pandey et al. [17] already proposed a 2 status bit variant of their counting filter. Their implementation however has average query and insertion times in Θ(n). The goal of our 2-status bit variant is to achieve running 3 1** 000 100 *01 *11 *10 this slot has a run empty slot cluster start run start continuation of a run -- (not used see 3.2) Table 1: Meaning of different sta- tus bit combinations. Figure 1: Section of the table with highlighted runs, clusters, and superclusters. Runs point to their canonical slot. times close to O(supercluster length). To achieve this, we change the definition of the fingerprint (only for this variant) such that no remainder can be zero f(cid:48) : x (cid:55)→ {0, ..., 2q − 1}×{1, ..., 2r − 1}. Ob- taining a non-zero remainder can easily be achieved by rehashing an element with different hash func- tions until the remainder is non-zero. This change to the fingerprint only has a minor impact on the false positive rate of the quotient filter (n/m·(2r−1) instead of n/m · 2r). Given this change to the fingerprint we can easily distinguish empty slots from filled ones. Each slot uses two status bits the occupied-bit (first status bit in the description above) and the new-run-bit (run-delimiter). Using these status bits we can find a particular run by going to the left until we find a free slot and then counting the number of occupied- and new-run-bits while moving right from there (Note: a cluster start within a larger supercluster cannot be recognized when moving left). Linear Probing Quotient Filter. This quo- tient filter is a hybrid between a linear probing hash table and a quotient filter. It uses no reordering of stored remainders and no status bits. To offset the removal of status bits we add three additional bits to the remainder (leading to a longer fingerprint). Similar to the two-status-bit quotient filter above we ensure no element x has rem(x) = 0 (by adapt- ing the fingerprint function). During the insertion of an element x the remain- der rem(x) is stored in the first empty slot after its canonical slot. Without status bits and reorder- ing it is impossible to reconstruct the fingerprint of each inserted element. Therefore, a query looking for an element x compares its remainder rem(x) with every remainder stored between x's canoni- cal slot and the next empty slot. There are po- tentially more remainders that are compared than during the same operation on a normal quotient filter. The increased remainder length however re- duces the chance of a single comparison to lead to a false positive by a factor of 8. Therefore, as long as the average number of compared remainders is less than 8 times more than before, the false posi- tive remains the same or improves. In our tests, we found this to be true for fill degrees up to ≈ 70%. The number of compared remainders corresponds to the number of slots probed by a linear probing hash table, this gives the bound below. Corollary 1 (p+ linear probing q.f.). The false positive rate of a linear probing quotient filter with δ = n/m (bound due to Knuth [10] chapter 6.4) is p+ = E[#comparisons] 2r+3 − 1 = 1 2 1 + 1 (1 − δ)2 (cid:18) (cid:19) · 1 2r+3 − 1 It should be noted that linear probing quotient filters cannot support deletions and the bounded growing technique. 3 Concurrent Quotient Filter From a theoretical point of view using an exter- nal array of locks should lead to a good concurrent quotient filter. As long as the number of locks is large enough to reduce contention (> p2) and the number of slots per lock is large enough to ensure that clusters don't span multiple locking regions. But there are multiple issues that complicate the implementation in practice. In this section we de- scribe the difficulties of implementing an efficient concurrent quotient filter, attributes of a success- ful concurrent quotient filter, and the concurrent variants we implemented. Problems with Concurrent Quotient Filters. The first consideration with every concurrent data structure should be correctness. The biggest prob- lem with implementing a concurrent quotient fil- ter is that multiple data entries have to be read in a consistent state for a query to succeed. All commonly known variants (except the linear prob- ing quotient filter) use at least two status bits per slot, i.e., the occupied-bit and some kind of run- delimiter-bit (the run-delimiter might take different forms). The remainders and the run-delimiter-bit that belong to one slot cannot reliably be stored close to their slot and its occupied-bit. Therefore, the occupied-bit and the run-delimiter-bit cannot be updated with one atomic operation. For this reason, implementing a lock-free quo- tient filter that uses status bits would cause signifi- cant overheads (i.e. additional memory or multiple 4 111111111111000000000000000superclusterstatusrem(·)clusterrun1a1b3c3d3e4f6g001:2:3:4:5:6:7:quot(·)8:0: passes over the accessed data). The problem is that reading parts of multiple different but individually consistent states of the quotient filter leads to an inconsistent perceived state. To show this we as- sume that insertions happen atomically and trans- fer the table from one consistent state directly into the new final consistent state. During a query we have to find the canonical run and scan the remain- ders within this run. To find the canonical run we have to compute its rank among non-empty runs using the occupied-bits (either locally by iterating over slots or globally using a rank-select-data struc- ture) and then find the run with the same rank using the run-delimiter-bits. There is no way to guarantee that the overall state has not changed between finding the rank of the occupied-bit bit and finding the appropriate run-delimiter. Specif- ically we might find a new run that was created by an insertion that shifted the actual canonical run. Similar things can happen when accessing the remainders especially when remainders are not stored interleaved with their corresponding status bits. Some of these issues can be fixed using multi- ple passes over the data but ABA problems might arise in particular when deletions are possible. To avoid these problems while maintaining per- formance we have two options: either comparing all following remainders and removing the status bits all-together (i.e. the linear probing quotient filter) or by using locks that protect the relevant range of the table. Goals for Concurrent Quotient Filters. Be- sides the correctness there are two main goals for any concurrent data structure: scalability and over- all performance. One major performance advan- tage of quotient filters over other AMQ data struc- tures is their cache efficiency. Any successful con- current quotient filter variant should attempt to preserve this advantage. Especially insertions into short or even empty clusters and (unsuccessful) queries with an empty canonical run lead to op- erations with only one or two accessed cache lines and at most one write operation. Any variant using external locks has an immediate disadvantage here. Concurrent Slot Storage. Whenever data is accessed by multiple threads concurrently, we have to think about the atomicity of operations. To be able to store all data connected to one slot together we alternate between status bits and remainders. The slots of a quotient filter can have arbitrary sizes that do not conform to the size of a standard atomic data type. Therefore, we have to take into account the memory that is wasted by using these basic data types inefficiently. It would be common to just use the smallest data type that can hold both the remainder and status bits and waste any excess memory. But quotient filters are designed to be space efficient. Therefore, we need a different method. We use the largest common atomic data type (64 bit) and pack as many slots as possible into one data element -- we call this packed construct a group (of slots). This way, the waste of multi- ple slots accumulates to encompass additional ele- ments. Furthermore, using this technique we can atomically read or write multiple slots at once -- al- lowing us to update in bulk and even avoid some locking. An alternative would have been not to waste any memory and store slots consecutively. However, this leads to slots that are split over the borders of the aligned common data types and might even cross the border between cache lines. While non- aligned atomic operations are possible on modern hardware, we decided against this method after a few preliminary experiments showed how inefficient they performed in practice. 3.1 Concurrent Linear Probing Quo- tient Filter Operations on a linear probing quotient filter (as described in Section 2.2) can be executed concur- rently similar to operations of a linear probing hash table [12]. The table is constructed out of merged atomic slots as described above. Each insertion changes the table atomically using a single compare and swap instruction. This implementation is even lock free, because at least one competing write op- eration on any given cell is successful. Queries find all remainders that were inserted into their canon- ical slot, because they are stored between their canonical slot and the next empty slot and the con- tents of a slot never change once something is stored within it. 3.2 Concurrent Quotient Filter with Local Locking In this section we introduce an easy way to imple- ment concurrent quotient filters without any mem- ory overhead and without increasing the number of cache lines that are accessed during operations. This concurrent implementation is based on the ba- sic (3-status-bit) quotient filter. The same ideas can also be implemented with the 2-status-bit vari- ant, but there are some problems discussed later in this section. Using status bits for local locking. To imple- ment our locking scheme we use two combinations of status bits that are impossible to naturally ap- pear in the table (see Table 1) -- 010 and 110. We use 110 to implement a write lock. In the beginning 5 Algorithm 1 Concurrent Insertion (quot, rem) ← f (key) // Block A: try a trivial insertion table section ← atomically load data around slot quot if insertion into table section is trivial then Algorithm 2 Concurrent Query (quot, rem) ← f (key) // Block F: try trivial query table section ← atomically load data around slot quot if answer can be determined from table section then finish that insertion with a CAS and return return this answer // Block B: write lock the supercluster scan right from it ← quot if it is write locked then wait until released and continue if it is empty then lock it with write lock and break if CAS unsuccessful re-examine it // Block C: read lock the cluster scan left from it ← quot if it is read locked then wait until released and retry this slot if it is cluster start then lock it with read lock and break if CAS unsuccessful re-examine it // Block D: find the correct run occ = 0; run = 0 scan right from it if it is occupied and it < canonical slot then occ++ if it is run start then run++ if occ = run and it ≥ canonical slot then break // Block E: insert into the run and shift scan right from it if it is read locked then wait until released store rem in correct slot shift content of following slots (keep groups consistent) break after overwriting the write lock unlock the read lock of each write operation, 110 is stored in the first free slot after the supercluster, see Block B Algorithm 1 (using a compare and swap operation). Insertions wait when encountering a write lock. This ensures that only one insert operation can be active per supercluster. The combination 010 is used as a read lock. All operations (both insertions Block C Algorithm 1 and queries Block G Algorithm 2) replace the sta- tus bits of the first element of their canonical clus- ter with 010. Additionally, inserting threads wait for each encountered read lock while moving ele- ments in the table, see Block E Algorithm 1. When moving elements during the insertion each encoun- tered cluster start is shifted and becomes part of the canonical cluster that is protected by the in- sertion's original read lock. This ensures, that no operation can change the contents of a cluster while it is protected with a read lock. Avoiding locks. Many instances of locking can be avoided, e.g., when the canonical slot for an in- sertion is empty (write the elements with a single compare and swap operation), when the canonical slot of a query either has no run (first status bit), or stores the wanted fingerprint. In addition to these trivial instances of lock elision, where the whole 6 // Block G: read lock the cluster scan left from it ← quot if it is read locked then wait until released and retry this slot if it is cluster start then lock it with read lock and break if CAS unsuccessful re-examine it // Block H: find the correct run occ = 0; run = 0 scan right from it if it is occupied and it < canonical slot then occ++ if it is run start then run++ if occ = run and it ≥ canonical slot then break // Block I: search remainder within the run scan right from it if it = rem unlock the read lock return contained if it is not continuation of this run unlock the read lock return not contained operation happens in one slot, we can also profit from our compressed atomic storage scheme (see Section 3). Since we store multiple slots together in one atomic data member, multiple slots can be changed at once. Each operation can act without acquiring a lock, if the whole operation can be com- pleted without loading another data element. The correctness of the algorithm is still guaranteed, be- cause the slots within one data element are always in a consistent state. Additionally, since the table is the same as it would be for the basic non-concurrent quotient fil- ter, queries can be executed without locking if there can be no concurrent write operations (e.g. dur- ing an algorithm that first constructs the table and then queries it repeatedly). This fact is actually used for the fully expandable variant introduced in Section 4. Deletions. Given our locking scheme deletions could be implemented in the following way (we did not do this since it has some impact on insertions). A thread executing a deletion first has to acquire a write lock on the supercluster then it has to scan to the left (to the canonical slot) to guarantee that there was no element removed while finding the cluster end. Then the read lock is acquired and the deletion is executed similar to the sequential case. During the deletion it is possible that new cluster starts are created due to elements shifting to the left into their canonical slot. Whenever this hap- pens, the cluster is created with read locked status bits (010). After the deletion all locks are unlocked. This implementation would impact some of the other operations. During a query, after acquiring the read lock when moving to the right, it would be possible to hit a new cluster start or an empty cell before reaching the canonical slot. In this case the previous read lock is unlocked and the operation is restarted. During an insertion after acquiring the write lock it is necessary to scan to the left to check that no element was removed after the canonical slot. 2-Status-Bit Concurrent Quotient Filter. In the 2-status-bit variant of the quotient filter there are no unused status bit combinations that can be used as read or write locks. But zero can never be a remainder when using this variant, therefore, a slot with an empty remainder but non-zero sta- tus bits cannot occur. We can use such a cell to represent a lock. Using this method, cluster starts within a larger supercluster cannot be recognized when scanning to the left ,i.e., in Blocks C and G (of Algorithms 1 and 2). Instead we can only rec- ognize supercluster starts (a non-empty cell to the right of an empty cell). To write lock a supercluster, we store 01 in the status bits of an otherwise empty slot after the su- percluster. To read lock a supercluster we remove the remainder from the table and store it locally until the lock is released (status bits 11). How- ever, this concurrent variant is not practical be- cause we have to ensure that the read-locked slot is still a supercluster start (the slot to its left re- mains empty). To do this we can atomically com- pare and swap both slots. However this is a problem since both slots might be stored in different atomic data types or even cache lines. The variant is still interesting from a theoretical perspective where a compare and swap operation changing two neigh- boring slots is completely reasonable (usually be- low 64 bits). However, we have implemented this variant when we did some preliminary testing with non-aligned compare and swap operations and it is non-competitive with the other implementations. Growing concurrently. The bounded growing technique (described in Section 2.1) can be used to increase the capacity of a concurrent quotient fil- ter similar to that of a sequential quotient filter. In the concurrent setting we have to consider two things: distributing the work of the migration be- tween threads and ensuring that no new elements are inserted into parts of the old table that were already migrated (otherwise they might be lost). To distribute the work of migrating elements, we use methods similar to those in Maier et al. [12]. After the migration is triggered, every thread that starts an operation first helps with the migration before executing the operation on the new table. Reducing interactions between threads during the migration is important for performance. There- fore, we migrate the table in blocks. Every thread acquires a block by incrementing a shared atomic variable. Each block has a constant size of 4096 slots. The migration of each block happens one su- percluster at a time. Each thread migrates all su- perclusters that begin in its block. This means that a thread does not migrate the first supercluster in its block, if it starts in the previous block. It also means that the thread migrates elements from the next block, if its last supercluster crosses the bor- der to that block. The order of elements does not change during the migration, because they remain ordered by their fingerprint. In general this means that most elements within one block of the original table are moved into one of two blocks in the tar- get table (block i is moved to 2i and 2i + 1). By assigning clusters depending on the starting slot of their supercluster, we enforce that there are no two threads accessing the same slot of the target table. Hence, no atomic operations or locks are necessary in the target table. As described before, we have to ensure that ongo- ing insert operations either finish correctly or help with the migration before inserting into the new ta- ble. Ongoing queries also have to finish to prevent deadlocks. To prevent other threads from insert- ing elements during the migration, we write lock each empty slot and each supercluster before it is migrated. These migration-write-locks are never re- leased. To differentiate migration-write-locks from the ones used in a normal insertions, we write lock a slot and store a non-zero remainder (write locks are usually only stored in empty slots). This way, an ongoing insertion recognizes that the encoun- tered write lock belongs to a migration. The in- serting thread first helps with the migration be- fore restarting the insertion after the table is fully migrated. Queries can happen concurrently with the migration, because the migration does not need read locks. 4 Fully Expandable QFs The goal of this fully expandable quotient filter is to offer a resizable quotient filter variant with a bounded false positive rate that works well even if there is no known bound to the number of elements inserted. Adding new fingerprint bits to existing entries is impossible without access to the inserted elements. We adapt a technique that was originally introduced for scalable Bloom filters [2]. Once a quotient filter is filled, we allocate a new additional quotient filter. Each subsequent quotient filter in- creases the fingerprint size. Overall, this ensures a bounded false positive rate. We show that even though this is an old idea, it offers some interesting possibilities when applied to 7 quotient filters, i.e., avoiding locks on lower levels, growing each level using the bounded growing tech- nique, higher fill degree through cascading inserts, and early rejection of queries also through cascad- ing inserts. 4.1 Architecture This new data structure starts out with one quo- tient filter, but over time, it may contain a set of quotient filters we call levels. At any point in time, only the newest (highest) level is active. Insertions operate on the active level. The data structure is initialized with two user-defined parameters the ex- pected capacity c and the upper bound for the false positive rate p+. The first level table is initialized with m0 slots where m0 = 2q0 is the first power of 2 where δgrow·m0 is larger than c, here δgrow is the fill ratio where growing is triggered and ni = δgrow · mi is the maximum number of elements level i can hold. The number of remainder bits r0 is chosen such that p+ > 2δgrow · 2−r0 . This first table uses k0 = q0 + r0 bits for its fingerprint. Queries have to check each level. Within the lower levels queries do not need any locks, because the elements there are finalized. The query perfor- mance depends on the number of levels. To keep the number of levels small, we have to increase the ca- pacity of each subsequent level. To also bound the false positive rate, we have to reduce the false pos- itive rate of each subsequent level. To achieve both of these goals, we increase the size of the fingerprint ki by two for each subsequent level (ki = 2 + ki−1). Using the longer fingerprint we can ensure that once the new table holds twice as many elements as the old one (ni = ni+1/2), it still has half the false pos- i+1 = 2·ni+1·2−ki+1). itive rate (p+ When one level reaches its maximum capacity ni we allocate a new level. Instead of allocating the new level to immediately have twice the number of slots as the old level, we allocate it with one 8th of the final size, and use the bounded growing algorithm (described in Section 2.1) to grow it to its final size (three growing steps). This way, the table has a higher average fill rate (at least 2/3 · δgrow instead of 1/3 · δgrow ). Theorem 2 (Bounded p+ in expandable QF). The fully expandable quotient filter holds the false posi- tive probability p+ set by the user independently of the number of inserted elements. i = ni·2−ki = 2p+ Proof. For the following analysis, we assume that fingerprints can potentially have an arbitrary length. The analysis of the overall false positive rate p+ is very similar to that of the scalable Bloom filter. A false positive occurs if one of the (cid:96) levels i ). This can be approximated with the Weierstrass inequal- i . When we insert the shrinking has a false positive p+ = 1 −(cid:81) ity p+ ≤ (cid:80)(cid:96) i(1 − p+ i=1 p+ false positive rates per level (p+ i /2) we ob- tain a geometric sum which is bounded by 2p+ 1 : i+1 = p+ (cid:80)(cid:96)−1 i=0 p+ i 2−i ≤ 2p+ 1 < p+. Using this growing scheme the number of filters is in O(log n/T ), therefore, the bounds for queries are similar to those in a broad tree data structure. But due to the necessary pointers tree data struc- tures take significantly more memory. Additionally, they are difficult to implement concurrently with- out creating contention on the root node. 4.2 Cascading Inserts The idea behind cascading inserts is to insert ele- ments on the lowest possible level. If the canonical slot in a lower level is empty, we insert the ele- ment into that level. This can be done using a sim- ple compare and swap operation (without acquir- ing a write lock). Queries on lower levels can still proceed without locking, because insertions cannot move existing elements. The main reason to grow the table before it is full is to improve the performance by shortening clusters. The trade-off for this is space utilization. For the space utilization it would be optimal to fill each table 100%. Using cascading inserts this can be achieved while still having a good performance on each level. Queries on the lower level tables have no significant slow down due to cascading in- serts, because the average cluster length remains small (cascading inserts lead to one-element clus- ters). Additionally, if we use cascading inserts, we can abort queries that encounter an empty canoni- cal slot in one of the lower level tables, because this slot would have been filled by an insertion. Cascading inserts do incur some overhead. Each insertion checks every level whether its canonical slot is empty. However, in some applications check- ing all levels is already necessary. For example in applications like element unification all lower levels are checked to prevent repeated insertions of one element. Applications like this often use combined query and insert operations that only insert if the element was not yet in the table. Here cascading inserts do not cost any overhead. 5 Experiments The performance evaluations described in this sec- tion consist of two parts: Some tests without grow- ing where we compare our implementation of con- current quotient filters to other AMQ data struc- tures, and some tests with dynamically growing quotient filter implementations. There we compare three different variants of growing quotient filters: bounded growing, our fully expandable multi level 8 approach, and the multi level approach with cas- cading inserts. All experiments were executed on a two socket Intel Xeon E5-2683 v4 machine with 16 cores per socket, each running at 2.1 GHz with 40MB cache size, and 512 GB main memory. The tests were compiled using gcc 7.4.0 and the operating system is Ubuntu 18.04.02. Each test was repeated 9 times using 3 different sequences of keys (same distribu- tion) -- 3 runs per sequence. Non-Growing Competitors I Linear probing quotient filter presented in Sec- tion 3.1 G Locally locked quotient filter presented in Sec- tion 3.2 (using status bits as locks) I Externally locked quotient filter using an array with one lock per 4096 slots  Counting quotient filter -- implementation by Pandey et al. [15, 17] L Bloom filter. Our implementation uses the same amount of memory as the quotient fil- ters we compared to (m· (r + 3) bits) and only 4 hash functions (⇒ better performance at a false positive rate comparable to our quotient filters). Speedup. The first test presented in Figure 2 shows the throughput of different data structures under a varying number of operating threads. We fill the table with 24M uniformly random elements through repeated insertions by all threads into a previously empty table of 225 ≈ 33.6M slots (δ ≈ 72%) using r = 10 remainder bits (13 for the lin- ear probing quotient filter). Then we execute 24M queries with uniformly random keys (none of which were previously inserted) this way we measure the performance of unsuccessful queries and the rate of false positives (not shown since it is independent of p). At last, we execute one query for each in- serted element. In each of these three phases we measure the throughput dependent on the number of processors. The base line for the speedups was measured using a sequential quotient filter, execut- ing the same test. We can see that all data structures scale close to linearly with the number of processors. There is only a small bend when the number of cores exceeds the first socket and once it reaches the number of physical cores. But, the data structures even seem to scale relatively well when using hyperthreading. The absolute performance is quite different between the data structures. In this test the linear probing quotient filter has by far the best throughput (ex- cluding the unsuccessful query performance of the Bloom filter). Compared to the locally locking vari- ant it performs 1.5 times better on inserts and 2.4 times better on successful queries (speedups of 30.6 vs. 20.5 on inserts and 51.3 vs 21.0 on successful queries at p = 32). Both the externally locking variant performs far worse (speedups below 12 for insertions). Inserting into the counting quotient fil- ter does not scale with the number of processors at all, instead, it starts out at about 2M inserts per second and gets worse from there. Both variants also perform worse on queries with a speedup of below 15 (p = 32). This is due to the fact that each operation incurs multiple cache faults -- one for locking and one for the table access. In the case of the counting quotient filter there is also the addi- tional work necessary for updating the rank-select bitvectors. The concurrent Bloom filter has very different throughputs depending on the operation type. It has by far the best throughput on unsuc- cessful queries (speedup of 46.8 at p = 32). The reason for this is that the described configuration with only 4 hash functions and more memory than a usual bloom filters (same memory as quotient fil- ters) leads to a sparse filter, therefore, it most un- successful queries can be aborted after one or two cache misses. In this test we fill a table with 225 ≈ Fill ratio. 33.6M slots and r = 10. Every 10% of the fill ra- tio, we execute a performance test. During this test each table operation is executed 100k times. The results can be seen in Figure 3. The throughput of all quotient filter variants decreases steadily with the increasing fill ratio, but the relative differences remain close to the same. Only the counting quo- tient filter and the Bloom filter have running times that are somewhat independent of the fill degree. On lower fill degrees the linear probing quotient filter and the locally locked quotient filter display their strengths. With about 236% and 157% higher insertion throughputs than the external locking quotient filter, and 358% and 210% higher success- ful query throughputs than the Bloom filter at 50% fill degree. Growing Benchmark In the benchmark shown in Figure 4, we insert 50M elements into each of our dynamically sized quotient filters bounded growing, fully expandable without cascading inserts (no ci), and fully expandable with cascading inserts (ci) (all based on the quotient filter using local locking). The filter was initialized with a capacity of only 219 ≈ 520k slots and a target false positive rate of p+ = 2−10. The inserted elements are split into 50 segments of 1M elements each. We measure the running time of inserting each segment as well as the query performance after each segment (using 1M successful and unsuccessful queries). 9 Figure 2: Throughput over the number of threads. Strong scaling measurement inserting 24M elements into a table with 225 ≈ 33.6M slots (72% fill degree). The speedup is measured compared to a sequential basic quotient filter. Note: the x-axis does not scale linearly past 32 threads. Figure 3: Throughput over fill degree. Using p = 32 threads and 225 ≈ 33.6M slots. Each point of the measurement was tested using 100k operations. As expected, the false positive rate grows linearly when we only use bounded growing, but each query still consists of only one table lookup -- resulting in a query performance similar to that of the non- growing benchmark. Both fully expandable vari- ants have a bounded false positive rate. But their query performance suffers due to the lower level look ups and the additional cache lines that have to be accessed with each additional table. Cascading inserts can improve query times by 13% for success- ful queries and 12% for unsuccessful queries (av- eraged over all segments), however, slowing down insertions significantly. 6 Conclusion Future Work. We already mentioned a way to implement deletions in our concurrent table Sec- tion 3.2. Additionally, one would probably want to add the same counting method used by Pandey et al. [17] this should be fairly straight forward, since the remainders in our implementation are also stored in increasing order. One large opportunity for improvement could be to use the local locking methods presented here as a backoff mechanism for a solution that uses hard- ware transactional memory. Transactional memory could also improve the memory usage by remov- ing the overheads introduced by the grouped stor- age method we proposed. Such an implementation might use unaligned compare and swap operations, but only if a previous transaction failed (this would hopefully be very rare). The fully expandable quotient filter could be adapted to specific use cases, e.g., one could use the normal insertion algorithm to fill a fully ex- pandable quotient filter. Then one could scan all 10 12481624324864threads0100200300400500performance (MOPS)successful containsBloom FilterLP Q-Filterext. locked Q-Filterloc. locked Q-Filtercounting Q-Filter12481624324864threads0200400600performance (MOPS)unsuccessful contains12481624324864threads0100200300400500performance (MOPS)insert01020304050speedup020406080speedup020406080speedup20406080fill degree (%)0100200300400500performance (MOPS)successful contains20406080fill degree (%)0100200300400500600performance (MOPS)unsuccessful containsBloom FilterLP Q-Filterext. locked Q-Filterloc. locked Q-Filtercounting Q-Filter20406080fill degree (%)0100200300400performance (MOPS)insert20406080fill degree (%)2172152132112927false positive ratefalse positive rate Figure 4: Throughput of the growing tables (all variants based on the local locking quotient filter). Using p = 32 threads 50 segments of 1M elements are inserted into a table initialized with 219 ≈ 520k slots. tables (in parallel) to move elements from later lev- els into earlier levels, if their slots are free. The resulting data structure could then be queried as if it was built with cascading inserts. Discussion. In this publication, we have shown a new technique for concurrent quotient filters that uses the status bits inherent to quotient filters for localized locking. Using this technique, no addi- tional cache lines are accessed (compared to a se- quential quotient filter). We were able to achieve a 1.8 times increase in insert performance over the external locking scheme (1.4 on queries; both at p = 32). Additionally, we proposed a simple lin- ear probing based filter that does not use any sta- tus bits and is lock-free. Using the same amount of memory, this filter achieves even better false positive rates up to a fill degree of 70% and also 1.5 times higher insertion speedups (than the local locking variant). We also propose to use the bounded growing technique available in quotient filters to refine the growing technique used in scalable Bloom filters. Using this combination of techniques guarantees that the overall data structure is always at least 2/3· δgrow filled (where δgrow is the fill degree where growing is triggered). Using cascading inserts, this can even be improved by filling lower level tables even further, while also improving query times by over 12%. Our tests show that there is no optimal AMQ data structure. Which data structure performs best depends on the use case and the expected workload. The linear probing quotient filter is very good, if the table is not densely filled. The locally locked quotient filter is also efficient on tables below a fill degree of 70%. But, it is also more flexible for ex- ample when the table starts out empty and is filled to above 70% (i.e., constructing the filter). Our growing implementations work well if the number of inserted elements is not known prior to the ta- ble's construction. The counting quotient filter per- forms well on query heavy workloads that operate on densely filled tables. References [1] Mohammad Al-hisnawi and Mahmood Ah- madi. Deep Packet Inspection using Quo- tient Filter. IEEE Communications Letters, 20(11):2217 -- 2220, Nov 2016. [2] Paulo S´ergio Almeida, Carlos Baquero, Nuno Pregui¸ca, and David Hutchison. Scalable Bloom Filters. Inf. Process. Lett., 101(6):255 -- 261, March 2007. [3] Michael A. Bender, Martin Farach-Colton, Rob Johnson, Russell Kraner, Bradley C. Kuszmaul, Dzejla Medjedovic, Pablo Montes, Pradeep Shetty, Richard P. Spillane, and Erez Zadok. Don't Thrash: How to cache your hash on flash. Proc. VLDB Endow., 5(11):1627 -- 1637, July 2012. [4] Alex D. Breslow and Nuwan S. Jayasena. Mor- ton filters: fast, compressed sparse cuckoo fil- ters. The VLDB Journal, Aug 2019. [5] Pedro Celis, Per-Ake Larson, and J Ian Munro. In 26th Annual Sym- Robin Hood Hashing. 11 01020304050elements (in millions)0100200300400performance (MOPS)successful contains01020304050elements (in millions)0200400600performance (MOPS)unsuccessful containsbounded growingfully expandable (ci)fully expandable (no ci)01020304050elements (in millions)050100150200250performance (MOPS)insert01020304050elements (in millions)213210272421false positive ratefalse positive rate [17] Prashant Pandey, Michael A. Bender, Rob Johnson, and Rob Patro. A General-Purpose Counting Filter: Making every bit count. In ACM Conference on Management of Data (SIGMOD), pages 775 -- 787, 2017. posium on Foundations of Computer Science (FOCS), pages 281 -- 288. IEEE, 1985. [6] J. G. Cleary. Compact hash tables using bidi- IEEE Transactions rectional linear probing. on Computers, C-33(9):828 -- 834, 1984. [7] Yan Collet. xxHash. https://github.com/ Cyan4973/xxHash. Accessed March 21, 2019. [8] Bin Fan, Dave G. Andersen, Michael Kamin- sky, and Michael D. Mitzenmacher. Cuckoo Filter: Practically better than Bloom. In 10th ACM International on Conference on Emerg- ing Networking Experiments and Technologies, pages 75 -- 88, 2014. [9] Afton Geil, Martin Farach-Colton, and John D. Owens. Quotient Filters: Approxi- mate membership queries on the GPU. In 2018 IEEE International Parallel and Distributed Processing Symposium (IPDPS), pages 451 -- 462, May 2018. [10] Donald Ervin Knuth. The art of computer pro- gramming: sorting and searching, volume 3. Pearson Education, 1997. [11] Xiaozhou Li, David G. Andersen, Michael Kaminsky, and Michael J. Freedman. Al- gorithmic Improvements for Fast Concurrent Cuckoo Hashing. In Proceedings of the 9th Eu- ropean Conference on Computer Systems, Eu- roSys '14, pages 27:1 -- 27:14, New York, NY, USA, 2014. ACM. [12] Tobias Maier, Peter Sanders, and Roman De- mentiev. Concurrent Hash Tables: Fast and general(?)! ACM Trans. Parallel Comput., 5(4):16:1 -- 16:32, February 2019. [13] Michael Mitzenmacher, Salvatore Pontarelli, and Pedro Reviriego. Adaptive Cuckoo Filters. In 2018 Proceedings of the Twentieth Work- shop on Algorithm Engineering and Experi- ments (ALENEX), pages 36 -- 47. SIAM, 2018. [14] Nhan Nguyen and Philippas Tsigas. Lock-free In 34th IEEE International cuckoo hashing. Conference on Distributed Computing Systems (ICDCS), pages 627 -- 636, June 2014. [15] Prashant Pandey. Counting quotient filter. Ac- https://github.com/splatlab/cqf. cessed August 07, 2019. [16] Prashant Pandey, Fatemeh Almodaresi, Michael A. Bender, Michael Ferdman, Rob Johnson, and Rob Patro. Mantis: A fast, small, and exact large-scale sequence-search index. Cell Systems, 7(2):201 -- 207.e4, 2018. 12
1702.03375
3
1702
2018-11-12T21:27:54
Derandomized Balanced Allocation
[ "cs.DS" ]
In this paper, we study the maximum loads of explicit hash families in the $d$-choice schemes when allocating sequentially $n$ balls into $n$ bins. We consider the \emph{Uniform-Greedy} scheme, which provides $d$ independent bins for each ball and places the ball into the bin with the least load, and its non-uniform variant --- the \emph{Always-Go-Left} scheme introduced by V\"ocking. We construct a hash family with $O(\log n \log \log n)$ random bits based on the previous work of Celis et al. and show the following results. 1. With high probability, this hash family has a maximum load of $\frac{\log \log n}{\log d} + O(1)$ in the \emph{Uniform-Greedy} scheme. 2. With high probability, it has a maximum load of $\frac{\log \log n}{d \log \phi_d} + O(1)$ in the \emph{Always-Go-Left} scheme for a constant $\phi_d>1.61$. The maximum loads of our hash family match the maximum loads of a perfectly random hash function in the \emph{Uniform-Greedy} and \emph{Always-Go-Left} scheme separately, up to the low order term of constants. Previously, the best known hash families matching the same maximum loads of a perfectly random hash function in $d$-choice schemes were $O(\log n)$-wise independent functions, which needs $\Theta(\log^2 n)$ random bits.
cs.DS
cs
Derandomized Balanced Allocation Xue Chen∗ Computer Science Department University of Texas at Austin [email protected] November 14, 2018 Abstract In this paper, we study the maximum loads of explicit hash families in the d-choice schemes when allocating sequentially n balls into n bins. We consider the Uniform-Greedy scheme [ABKU99], which provides d independent bins for each ball and places the ball into the bin with the least load, and its non-uniform variant -- the Always-Go-Left scheme introduced by Vocking [Voc03]. We construct a hash family with O(log n log log n) random bits based on the previous work of Celis et al. [CRSW13] and show the following results. 1. With high probability, this hash family has a maximum load of log log n log d + O(1) in the Uniform-Greedy scheme. 2. With high probability, it has a maximum load of log log n d log φd scheme for a constant φd > 1.61. + O(1) in the Always-Go-Left The maximum loads of our hash family match the maximum loads of a perfectly random hash function [ABKU99, Voc03] in the Uniform-Greedy and Always-Go-Left scheme sepa- rately, up to the low order term of constants. Previously, the best known hash families match- ing the same maximum loads of a perfectly random hash function in d-choice schemes were O(log n)-wise independent functions [Voc03], which needs Θ(log2 n) random bits. ∗Supported by NSF Grant CCF-1526952 and a Simons Investigator Award (#409864, David Zuckerman), part of this work was done while the author was visiting the Simons Institute. 1 Introduction We investigate explicit constructions of hash functions for the classical problem of placing balls into bins. The basic model is to hash n balls into n bins independently and uniformly at random, which we call 1- choice scheme. For the 1-choice scheme, it is well-known that each bin contains at most O( log n log log n ) balls with high probability. For convenience, we always use logarithm of base 2 in this work. Here, by high probability, we mean probability 1 − n−c for an arbitrary constant c. An alternative variant, which we call Uniform-Greedy, is to provide d ≥ 2 independent random choices for each ball and place the ball in the bin with the lowest load. In a seminal work, Azar et al. [ABKU99] showed that the Uniform-Greedy scheme with d independent random choices guarantees a maximum load of only log log n log d + O(1) with high probability for n balls, which significantly improved the load-balancing of 1-choice scheme even for d = 2. This scheme has various applications in many areas of computer science such as cryptography [ANSS16]. We refer to surveys [MRS00, Mit01, Wie17]) for a detailed discussion. Surprisingly, Vocking [Voc03] used an asymmetric scheme, called Always-Go-Left, to further improve + O(1) for d ≥ 2 choices, where φd > 1.61 is the constant satisfying the maximum load to log log n d log φd d = 1 + φd + ··· + φd−1 . This scheme partitions the n bins into d groups with equal size and uses an φd unfair tie-breaking mechanism such that the allocation process provides d independent choices from the d groups separately for each ball and always allocates it to the left-most bin with the least load. Moreover, Vocking [Voc03] showed this load balancing is optimal for any random scheme using d choices. For convenience, we always use d-choice schemes to denote both the Uniform-Greedy and Always-Go-Left scheme with d ≥ 2 choices in this work. d Traditional analysis of load balancing assumes a perfectly random hash function. A large body of re- search is dedicated to the removal of this assumption by designing explicit hash families using fewer random bits. In the 1-choice scheme, it is well known that O( log n log log n )-wise independent functions guarantee a max- imum load of O( log n log log n ). Recently, Celis et al. [CRSW13] designed a hash family with a description of O(log n log log n) random bits that achieves the same maximum load of O( log n log log n ) with high probability, which reduces the number of random bits to O( log2 n log log n ) as a perfectly random hash function. In this work, we are interested in the explicit constructions of hash families that achieve the same maximum loads as a perfectly random hash function in the d-choice schemes, i.e., log log n log d + O(1) in the Uniform-Greedy scheme [ABKU99, Voc03] and log log n + O(1) in the Always-Go-Left scheme [Voc03]. d log φd For these two schemes, O(log n)-wise independent hash functions achieve the same maximum loads from Vocking's argument [Voc03], which provides a hash family with Θ(log2 n) random bits. Recently, Rein- gold et al. [RRW14] showed that the hash family designed by Celis et al. [CRSW13] guarantees a maximum load of O(log log n) of n balls in the Uniform-Greedy scheme with O(log n log log n) random bits. 1.1 Our Contribution For multiple-choice schemes, we strengthen the hash family of Celis et al. [CRSW13] for the 1-choice scheme -- our hash family is O(log log n)-wise independent over n bins and "almost" O(log n)-wise inde- pendent over a fraction of poly(log n) bins. Then we prove that our hash family derandomizes Vocking's witness tree argument [Voc03] such that O(log n log log n) random bits could guarantee the same maximum loads as a perfectly random hash function in the multiple-choice schemes. We first show our hash family guarantees a maximum load of log log n log d + O(1) in the Uniform-Greedy scheme [ABKU99, Voc03] with d choices. We use U to denote the pool of balls and consider placing m = O(n) balls into n bins here. Without loss of generality, we always assume U = poly(n) and d is a 1 Then we show this hash family guarantees a load balancing of log log n d log φd constant at least 2 in this work. Theorem 1.1 (Informal version of Theorem 5.1) For any m = O(n), any constants c and d, there exists a hash family with O(log n log log n) random bits such that given any m balls in U, with probability at least 1 − n−c, the max-load of the Uniform-Greedy scheme with d independent choices of h is log log n log d + O(1). + O(1) in the Always-Go-Left d = 1 + φd + ··· + φd−1 scheme [Voc03] with d choices. Notice that the constant φd in equation φd satisfies 1.61 < φ2 < φ3 < φ4 < ··· < φd < 2. Compared to the Uniform-Greedy scheme, the Always- Go-Left scheme [Voc03] improves the load exponentially with regard to d. Even for d = 2, the Always- Go-Left scheme reduces the load from log log n + O(1) to 0.7 log log n + O(1). From the lower bound − O(1) on the load balancing of any random d-choice scheme shown by Vocking [Voc03], the load log log n d log φd of our hash family in the Always-Go-Left scheme is optimal among d-choice schemes up to the low order term of constants. Theorem 1.2 (Informal version of Theorem 6.3) For any m = O(n), any constants c and d, there exists a hash family with O(log n log log n) random bits such that given any m balls in U, with probability at least 1 − n−c, the max-load of the Always-Go-Left scheme with d independent choices of h is log log n At the same time, Our hash family has an evaluation time O(cid:0)(log log n)4(cid:1) in the RAM model based on the + O(1). d log φd d n + O((cid:112)log n · m algorithm designed by Meka et al. [MRRR14] for the hash family of Celis et al. [CRSW13]. Finally, we show our hash family guarantees the same maximum load as a perfectly random hash func- tion in the 1-choice scheme for m = n · poly(log n) balls. Given m > n log n balls in U, the maximum load of the 1-choice scheme becomes m n ) from the Chernoff bound. For convenience, we refer to this case of m ≥ n log n balls as a heavy load. In a recent breakthrough, Gopalan, Kane, and Meka [GKM15] designed a pseudorandom generator of seed length O(log n(log log n)2) that fools the Chernoff bound within polynomial error. Hence the pseudorandom generator [GKM15] provides a hash function with O(log n(log log n)2) random bits for the heavy load case. Compared to the hash function of [GKM15], we provide a simplified construction that achieves the same maximum load but only works for m = n · poly(log n) balls. Theorem 1.3 (Informal version of Theorem 7.1) For any constants c and a ≥ 1, there exist a hash func- tion generated by O(log n log log n) random bits such that for any m = loga n · n balls, with probability at least 1 − n−c, the max-load of the n bins in the 1-choice scheme with h is m log n ·(cid:112) m n + O(cid:0)√ (cid:1). n 1.2 Previous Work The 1-choice scheme. Natural explicit constructions of hash functions using a few random bits are k-wise independent functions, small-biased spaces, and k-wise small-biased spaces. For the 1-choice scheme with m = n balls, Alon et al. [ADM+99] showed the existence of a pairwise independent hash family that always log log n )-wise independent functions has a maximum load of achieve a maximum load of O( log n log log n ) random bits. Using O(log n)-wise small-biased spaces as milder restrictions, Celis et al. [CRSW13] designed a hash family with O(log n log log n) random bits achieving the same maximum load with high probability. log log n ) with high probability, which needs Θ( log2 n n. On the other hand, it is well known that O( log n √ n + O((cid:112)log n · m For the heavy load case in the 1-choice scheme, a perfectly random hash function guarantees a maximum n ) from the Chernoff bound. Hence any pseudorandom generator fooling the load of m Chernoff bound within polynomial small error is a hash family matching this maximum load. Schmidt 2 et al. [SSS95] showed that O(log n)-wise independence could derandomize the Chernoff bound, which provides a hash function with O(log2 n) random bits. In a recent breakthrough [GKM15], Gopolan, Kane, and Meka designed a pseudorandom generator with seed length O(log n(log log n)2) to fool halfspaces, the Chernoff bound, and many other classes, which provides a hash family of O(log n(log log n)2) bits. Multiple-choice schemes. For m = n balls in the d-choice schemes, the original argument of [ABKU99] adopts an inductive proof that relies on the assumption of full randomness. It is folklore (e.g., [RRW14, DKRT16]) that O(log n)-wise independent functions could derandomize Vocking's witness tree argument [Voc03] to achieve a maximum load of log log n log d +O(1) in the Uniform-Greedy scheme, which takes Θ(log2 n) random bits. Reingold et al. [RRW14] prove the hash family of [CRSW13] derandomizes Cuckoo hashing and achieves a maximum load of log log n + O(1) in the Uniform-Greedy scheme for n/C0 balls for any constant C0 > 2. This leaves a gap for m > n balls and d > 2 choices, where the guarantee of the maximum load in Reingold et al. [RRW14] becomes C0m n ·(cid:0) log log n + O(1)(cid:1). Vocking [Voc03] introduced Always-Go-Left scheme to further improve the maximum loads of d-choice schemes to log log n + O(1). In the same work, Vocking showed a lower bound to illustrate that the load d log φd log log n is optimal for random d-choice schemes. However, much less is known about the derandomiza- d log φd tion of the Always-Go-Left scheme except O(log n)-wise independent functions for Vocking's witness tree argument [Voc03], which is pointed out in [RRW14, DKRT16]. We summarize these results in Table 1. scheme 1-choice 1-choice Uniform-Greedy Uniform-Greedy Uniform-Greedy Uniform-Greedy Always-Go-Left Always-Go-Left log log n ) log log n ) reference maximum load well known [CRSW13] [ABKU99] [Voc03] [RRW14] this work [Voc03] this work O( log n O( log n log log n log d + O(1) log log n log d + O(1) O(log log n) log log n log d + O(1) log log n + O(1) d log φd log log n + O(1) d log φd number of random bits Θ( log2 n log log n ) O(log n log log n) full randomness Θ(log2 n) O(log n log log n) O(log n log log n) Θ(log2 n) O(log n log log n) Table 1: Previous work about the random bits and maximum loads of multiple-choice schemes with m = n balls Another line of research on hash families focuses on studying functions with a constant evaluation time despite the expense of the number of random bits. For O(log n)-wise independence, Siegel [Sie89] showed how to implement it in constant time. For multiple-choice schemes, Woelfel [Woe06] showed that the hash family of [DW03], which takes constant evaluation time and nΘ(1) random bits, guarantees the same maximum loads as a perfectly random hash functions in the multiple-choices schemes. Patras¸cu and Thorup [PT12] introduced simple tabulation hashing, a function with constant evaluation time and nΘ(1) random bits, that can replace the perfectly random hash functions in various applications. Recently, Dahlgaard et al. [DKRT16] prove that simple tabulation has the same expected load balancing as a fully random hash function for 2-choice scheme, which was generalized to the Uniform-Greedy and Always- Go-Left schemes by Aamand, Knudsen, and Thorup [AKT18]. However, Dahlgaard et al. [DKRT16] pointed out that for any constant C, with probability n−Θ(1), the max-load becomes C · log log n in the Uniform-Greedy with 2 choices. 3 For the hash family designed by Celis et al. [CRSW13], Meka et al. [MRRR14] improved the evaluation time of [CRSW13] to O((log log n)2). 1.3 Discussion In this work, we provide a hash family with O(log n log log n) random bits that matches the maximum loads of a perfectly random hash function in multiple-choice schemes. A natural question is to reduce the number of random bits to O(log n). A starting point would be to improve the hash families in the 1-choice scheme, where the best construction needs O(log n log log n) random bits from Celis et al. [CRSW13]. For the 1-choice scheme, the load of each bin is the summation of m random indicator variables, which allows us to use the pseudorandom generators for concentration bounds [SSS95,GKM15] and space- bounded computation [Nis92, NZ96, GKM15]. One interesting direction is to investigate the techniques of these two areas in the design of hash functions. At the same time, although Alon et al. [ADM+99] proved lower bounds of k-wise independent functions in the 1-choice scheme, it is still interesting to explore natural algebraic constructions such as the quadratic characters of modulo p for small-biased spaces in [AGHP90]. Our work is an application of the technique -- milder restrictions [CRSW13, GMR+12] in the design of pseudorandom generators. Even though k-wise independence and small-biased spaces fool variants of classes, these two tools will not provide optimal pseudorandom generators for basic classes such as the 1- choice scheme [ADM+99] or read-once CNFs [DETT10]. After Celis et al. [CRSW13] introduced milder restrictions, this technique has been successfully applied to construct almost optimal pseudorandom gen- erators with log n · poly(log log n) random bits for several classes such as 1-choice scheme [CRSW13], read-once CNFs [GMR+12], modulo p functions and halfspaces [GKM15]. It would be of great interest to investigate this technique to the design of pseudorandom generators for broader classes such as AC0 circuits and space-bounded computation. 1.4 Organization This paper is organized as follows. In Section 2, we introduce some notation and tools. We define witness trees and revisit Vocking's argument [Voc03] in Section 3. We show the construction of our hash family in Section 4 and sketch our derandomization in Section 4.1. Next we prove Theorem 1.1 in Section 5 and Theorem 1.2 in Section 6, which provide upper bounds on the maximum loads of the Uniform-Greedy scheme and the Always-Go-Left scheme separately. Finally, we prove Theorem 1.3 in Section 7 which shows a bound of the heavy load case in the 1-choice scheme. 2 Preliminaries We use U to denote the pool of balls, m to denote the numbers of balls in U, and n to denote the number of bins. We assume m ≥ n and n is a power of 2 in this work. We use 1E to denote the indicator function of the event E and Fp to denote the Galois field of size p for a prime power p. Definition 2.1 Given a prime power p, a distribution D on Fn character function χα in Fn A distribution D on Fn support size at most k, E x∼D p , E x∼D p is a k-wise δ-biased space if for any non-trivial character function χα in Fn [χα(x)] ≤ δ. p of [χα(x)] ≤ δ. p is a δ-biased space if for any non-trivial The seminal works [NN90, AGHP90] provide small-biased spaces with optimal seed length. 4 p with seed length O(log pn Lemma 2.2 ( [NN90,AGHP90]) For any prime power p and integer n, there exist explicit constructions of δ-biased spaces on Fn δ ) and explicit constructions of k-wise δ-biased spaces with seed length O(log kp log n Given two distributions D1 and D2 with the same support Fn p , we define the statistical distance to be (cid:107)D1 − D1(x)−D2(x). Vazirani [Vaz86] proved that small-biased spaces are close to the uniform D2(cid:107)1 =(cid:80) ) δ x∈Fn p p is δ · pn/2 close to the uniform distribution in statistical p is δ·pk/2 close to the uniform distribution distribution. Lemma 2.3 ( [Vaz86]) A δ-biased space on Fn distance. Given a subset S of size k in [n], a k-wise δ-biased space on Fn on S in statistical distance. n in Lemma 2.2 and summarize the discussion above. Given a distribution D on functions from U to [n], D is k-wise independent if for any k elements x1, . . . , xk in U, D(x1), . . . , D(xk) is a uniform distribution on [n]k. For small-biased spaces, we choose p = n and the space to be FU Lemma 2.4 Given k and n, a k-wise δ-biased space from U to [n] is δ·nk/2 close to the uniform distribution from U to [n] on any k balls, which needs O(log kn log n Remark 2.5 In this work, we always choose δ ≤ 1/n and k = poly(log n) in the small biased spaces such that the seed length is O(log 1 δ ). At the same time, we only use k-wise small-biased spaces rather than small biased spaces to improve the evaluation time from O(log n) to O(log log n)4. ) random bits. δ We state the Chernoff bound in k-wise independence by Schmidt et al. in [SSS95]. Lemma 2.6 (Theorem 5 (I) (b) in [SSS95]) If X is the sum of k-wise independent random variables, each of which is confined to the interval [0, 1] with µ = E[X], then for δ ≤ 1 and k ≥ δ2µ · e−1/3, Pr[X − µ ≥ δµ] ≤ e −δ2µ/3. 3 Witness Trees We first provide several notation and definitions in this section. Then we review the witness tree argument of Vocking [Voc03] for the Uniform-Greedy scheme. Definition 3.1 (Uniform-Greedy with d choices) Let h(1), . . . , h(d) be d hash functions from U to [n]. The process inserts balls in any fixed order as follows: for each ball i, the algorithm considers d bins {h(1)(i), . . . , h(d)(i)} and puts the ball i into the bin with the least load among {h(1)(i), . . . , h(d)(i)}. When there are several bins with the least load, it picks an arbitrary one. For convenience, given m balls b1,··· , bm ∈ [m], we fix the order to be b1 < b2 < ··· < bm in this work. We define the height of a ball to be the height of it on the bin allocated in the above process. Next we follow the notation of Vocking [Voc03] to define witness trees and pruned witness trees. Given the balls and d hash functions h(1), . . . , h(d) in the allocation process, we construct a symmetric witness tree for each ball in this process. 5 Definition 3.2 (Symmetric witness trees) Given a ball b and a parameter l less than the height of b, the symmetric witness tree T with height l for b is a complete d-ary tree of height l. Every node w in this tree corresponds to a ball T (w) ∈ [n]; and the root corresponds to the ball b. A ball u in T has a ball v as its ith child iff when we allocate u in the process, ball v is the top ball in the bin h(i)(cid:0)u(cid:1). Hence v < u and the bin h(i)(u) is in the subset(cid:8)h(1)(v), . . . , h(d)(v)(cid:9) of [n] when v is the ith child of u. Next we trim the repeated nodes in a witness trees such that there is no duplicate edge after the trimming. Definition 3.3 (Pruned witness trees and collisions) Given a witness tree T where nodes v1, . . . , vj in T correspond to the same ball, let v1 be the node among them in the most bottom level of T . Consider the following process: first remove v2, . . . , vj and their subtrees; then, redirect the edges of v2, . . . , vj from their parents to v1 and call these edges collisions. Given a symmetric witness tree T , we call the new tree without repeated nodes after the above process as the pruned witness tree of T . We call different witness trees with the same structure but different balls a configuration. For example, the configuration of symmetric witness trees with distinct nodes is a full d-ary tree without any collision. Figure 1: A witness tree with distinct balls and a pruned witness tree with 3 collisions Next we define the height and size of pruned witness trees. (cid:8)height(v)(cid:9) + 1, the height min v∈children(u) Definition 3.4 (Height of witness trees) Given any witness tree T , let the height of T be the length of the shortest path from the root of T to its leaves. Because height(u) = of the pruned witness tree equals the height of the original witness tree. At the same time, let T denote the number of vertices in T for any witness tree T and C denote the number of nodes in a configuration C. Remark 3.5 Given a ball b of height h and any h(cid:48) < h, we always consider the pruned witness tree of b with height h(cid:48) whose leaves have height at least h − h(cid:48). Finally we review the argument of Vocking [Voc03] for m = n balls. One difference between this proof and Vocking's original [Voc03] proof is an alternate argument for the case of witness trees with many collisions. Lemma 3.6 ( [Voc03]) For any constants c ≥ 2 and d, with probability at least 1−n−c, the max-load of the Always-Go-Left scheme with d independent choices from perfectly random hash functions is log log n log d +O(1). 6 1348111314182419262337424813613116124192619374248TrimT13611241926374248 (cid:0)(2 + 2c) log n(cid:1) + 3c + 5(cid:101) for the height of witness trees. In this proof, Proof. We fix a parameter l = (cid:100)logd we bound the probability that any symmetric witness tree of height l with leaves of height at least 4 exists in perfectly random hash functions. From the definition of witness trees, this also bounds the probability of a ball with height l + 4 in the d-choice Uniform-Greedy scheme. For symmetric witness trees of height l, it is sufficient to bound the probability that their pruned coun- terparts appear in perfectly random hash functions. We separate all pruned witness trees into two cases according to the number of edge collisions: pruned witness trees with at most 3c collisions and pruned witness trees with at least 3c collisions. Pruned witness trees with at most 3c collisions. Let us fix a configuration C with at most 3c collisions and consider the probability any pruned witness trees with configuration C appears in perfectly random hash functions. Because each node of this configuration C corresponds a distinct ball, there are at most nC possible ways to instantiate balls into C. Next, we fix one possible pruned witness tree T and bound the probability of the appearance of T in h(1), . . . , h(d). We consider the probability of two events: every edge (u, v) in the tree T appears during the allocation process; and every leaf of T has height at least 4. For the first event, an edge (u, v) holds during the process only if the hash functions satisfy h(1)(v), . . . , h(d)(v) (1) Secondly, the probability that a fixed leaf ball has height at least 4 is at most 3−d. A leaf ball of height 4 indicates that each bin in his choices has height at least 3. Because at most n/3 bins contain at least 3 balls at any moment, the probability that a random bin has height at least 3 is ≤ 1/3. Thus the probability that d random bins have height 3 is at most 3−d. , which happens with probability at most d n . We apply a union bound on the probability that any witness tree with the configuration C appears in h(i)(u) ∈(cid:110) (cid:111) perfectly random hash functions: n C · (cid:89) (u,v)∈C · (3 −d)number of leaves d n (2) We lower bound the number of edges in C by C − 1 because C is connected. Next we lower bound the number of leaves. Because C is a d-ary tree with at most 3c collisions, the number of leaves is at least C−3c . At the same time, C is trimmed from the d-ary symmetric witness tree of height l. Thus C ≥ (1 + d + ··· + dl−3c). From all discussion above, we bound (2) by C·( −d)dl−3c/2.5 ≤ n·(0.8)10(2+2c) log n ≤ n C−3c 2 ≤ n·(d2.5·3 C/2.5 ≤ n·(d2.5·3 C−1·(3 ) −2c−1. −d) −d) 2 d n Finally, we apply a union bound on all possible configurations with at most 3c collisions: the number of i=0(dl+1)2·i ≤ n such that the probability of any witness tree with height l and at most 3c collisions existing is at most n−c. n configurations is at most(cid:80)3c Pruned witness trees with at least 3c collisions. We use the extra 3c collisions with equation (1) instead of the number of leaves in this case. Given any configuration C with at least 3c collisions, we consider the first 3c collisions e1, . . . , e3c in the BFS of C. Let C(cid:48) be the induced subgraph of C that only contains nodes in e1, . . . , e3c and their ancestors in C. At the same time, the size C(cid:48) ≤ 3c(2l + 1) and the number of edges in C(cid:48) is C(cid:48) + 3c − 1. 7 Figure 2: An example of extracting C(cid:48) from C given two collisions. Because any pruned witness tree of C exists only if its corresponding counterpart of C(cid:48) exists in perfectly random hash functions, it is suffice to bound the probability of the latter event. There are at most nC(cid:48) instantiations of balls in C(cid:48). For each instantiation, we bound the probability that all edges survive by (1): We bound the probability that any pruned witness tree of configuration C(cid:48) survives in the perfectly ( d n )number of edges = ( C(cid:48)+3c−1. ) d n random hash function by ( d n C(cid:48)+3c−1 · n C(cid:48) ≤ ( ) )3c−1 · d(2l+2)·3c ≤ n −2c. 1 n Finally, we apply a union bound over all possible configurations C(cid:48): there are at most (1+d+···+dl)2·3c ≤ (cid:117)(cid:116) n configurations of 3c collisions. Remark 3.7 Because the sizes of all witness trees are bounded by dl+1 = O(log n), Oc,d(log n)-wise independent hash functions could adopt the above argument to prove a max-load of logd log n + O(d + c). 4 Hash functions We construct our hash family and show its properties for the derandomization of witness trees argument in this section. We sketch the derandomization of Lemma 3.6 of Vocking's argument in Section 4.1. Let ◦ denote the concatenation operation and ⊕ denote the bit-wise XOR operation. Construction 4.1 Given δ1 > 0, δ2 > 0, and two integers k, kg, let 1. hi : U → [n2−i 2. hk+1 : U → [n2−k ] denote a function generated by an O(log2 n)-wise δ1-biased space for each i ∈ [k], ] denote a function generated by an O(log2 n)-wise δ2-biased space such that (h1(x) ◦ h2(x) ◦ ··· ◦ hk(x) ◦ hk+1(x)) is a function by U to [n], 3. g : U → [n] denote a function from a kg-wise independent family from U to [n]. We define a random function h : U → [n] in our hash family H with parameters δ1, δ2, k and kg to be: h(x) =(cid:0)h1(x) ◦ h2(x) ◦ ··· ◦ hk(x) ◦ hk+1(x)(cid:1) ⊕ g(x). 8 ExtractC0fromC Hence the seed length of our hash family is O(k log n·log2 n·log U + kg log n). We always choose k ≤ log log n, kg = O(log log n), δ1 = 1/poly(n), and δ2 = (log n)−O(log n) such that the seed length is O(log n log log n). Remark 4.2 Our parameters of h1 ◦ ··· ◦ hk+1 are stronger than the parameters in [CRSW13]. While the last function hk+1 of [CRSW13] is still a δ1-biased space, we use δ2 = (δ1)O(k) in hk+1 to provide almost O(log n)-wise independence on (log n)O(log n) subsets of size O(log n) for our calculations. + log n·log2 n·log U δ1 δ2 Properties of h. We state the properties of h that will be used in the derandomization. Because of the kg-wise independence in g and the ⊕ operation, we have the same property for h. Property 4.3 h is kg-wise independent. 1 2i ], i.e., a hash function maps all balls into n1− 1 Then we fix g and discuss h1 ◦ ··· ◦ hk ◦ hk+1. For each i ∈ [k], it is natural to think of h1 ◦ ··· ◦ hi as a function from U to [n1− 1 2i bins. Celis et al. [CRSW13] showed that for every i ∈ [k], the number of balls in every bin of h1 ◦ ··· ◦ hi is close to its expectation 2i · m n Lemma 4.4 ( [CRSW13]) Given k = log2(log n/3 log log n) and β = (log n)−0.2, for any constant c > 0, there exists δ1 = 1/poly(n) such that given m = O(n) balls, with probability at least 1 − n−c, for all i ∈ [k], every bin in [n1− 1 2i ] contains at most (1 + β)in poly(n)-biased spaces. n balls under h1 ◦ ··· ◦ hi. 2i · m n in 1 1 For completeness, we provide a proof of Lemma 4.4 in Appendix A. In this work, we use the following version that after fixing g in the Construction 4.1, h1 ◦ h2 ◦ ··· ◦ hk still allocates the balls evenly. Corollary 4.5 For any constant c > 0, there exists δ1 = 1/poly(n) such that given m = O(n) balls and any function g0 : U → [n/ log3 n], with probability at least 1 − n−c over h1, . . . , hk, for any bin j ∈ [n1− 1 2k ] = [n/ log3 n], it contains at most 1.01 · log3 n · m n balls in the hash function(cid:0)h1(x) ◦ ··· ◦ hk(x)(cid:1) ⊕ g0(x). Next we discuss the last function hk+1 generated from a δ2-biased space on [log3 n]U . For a subset S ⊆ U, let h(S) denote the distribution of a random function h on S and U[log3 n](S) denote the uniform distribution over all maps from S → [log3 n]. From Lemma 2.3 and the union bound, we have the following claim. Claim 4.6 Given δ2 = (log n)−C log n, for a fixed subset S of size C to the uniform distribution on S, i.e., (cid:107)hk+1(S) − U[log3 n](S)(cid:107)1 ≤ (log n) 3 ·log n, hk+1(S) is (log n) − C 2 ·log n-close − C 2 ·log n. 3 · log n, we have 2 ·log n ≤ (log n) − C − C 6 ·log n. Then for m = (log n) C 3 ·log n subsets S1, . . . , Sm of size C (cid:107)hk+1(Si) − U[log3 n](Si)(cid:107)1 ≤ m · (log n) (cid:88) i∈[m] In another word, hk+1 is close to the uniform distribution on (log n) hk+1 (or h) is not close to log n-wise independence on n balls. C 3 log n subsets of size C 3 log n. However, Remark 4.7 (Evaluation time) Our hash function has an evaluation time O((log log n)4) in the RAM model. Because we use (log n)−O(log log n)-biased spaces in hk+1, we lose a factor of O(log log n)2 com- pared to the hash family of [CRSW13]. The reason is as follows. 9 g can be evaluated by a degree O(log log n) polynomial in the Galois field of size poly(n), which takes O(log log n) time. The first k hash functions h1, . . . , hk use 1/poly(n)-biased spaces, which have total evaluation time O(k · log log n) = O(log log n)2 in the RAM model from [MRRR14]. The last function hk+1 in the RAM model is a O(log n)-wise n−O(log log n)-biased space from U to [log3 n], which needs O(log log n) words in the RAM model. Thus the evaluation time becomes O(log log n) times the cost of a quadratic operation in the Galois field of size nO(log log n), which is O((log log n)4). 4.1 Proof Overview We sketch the derandomization of Lemma 3.6 in this section. Similar to the proof of Lemma 3.6, we bound the probability that any pruned witness tree of height l = logd log n + O(1) exists in h(1), . . . , h(d), where k+1(x)(cid:1) ⊕ g(i)(x). We use the property of h1 ◦ ··· ◦ hk+1 to derandomize the each h(i) =(cid:0)h(i) 1 (x) ◦ ··· ◦ h(i) case of pruned witness trees with at most 3c collisions and the property of g to derandomize the other case. d d (u,v)∈C Pruned witness trees with at most 3c collisions. We show how to derandomize the union bound (2) for a fixed configuration C with at most 3c collisions. There are two probabilities in (2): the second term n over all edges in C and the last term 3−d·number of leaves over all leaves. We focus on the first n in this discussion, because it contributes a smaller probability. Since C ∈ [dl−3c, dl+1] = Θ(log n), it needs O(log n)-wise independence over [n] bins for every possible witness trees in (2), which is impossible to support with o(log2 n) bits [Sti94]. (cid:81) term(cid:81) We omit {g(1), . . . , g(d)} and focus on the other part(cid:8)h(i) strategy is to first fix the prefixes in the d hash functions,(cid:8)h(i) (cid:12)(cid:12)i ∈ [d](cid:9) in this case. Our (cid:12)(cid:12)i ∈ [d](cid:9), then recalculate (2) using 1 ◦ ··· ◦ h(i) 1 ◦···◦ h(i) k ◦ h(i) (u,v)∈C the suffixes h(1) edge (u, v) in T , the prefixes of h(1)(v), . . . , h(d)(v) and h(i)(u) must satisfy k+1. Let T be a possible witness tree in the configuration C. To satisfy (1) for an k+1, . . . , h(d) k+1 k 1 (u) ◦ ··· ◦ h(i) h(i) 1 (v) ◦ ··· ◦ h(1) h(1) (3) After fixing the prefixes, let FT denote the subset of possible witness trees in the configuration C that satisfy the prefix condition (3) for every edge. Because each bin of [n/ log3 n] receives at most 1.01 log3 n balls from every prefix function h(j) k by Corollary 4.5, we could bound 1 ◦ h(j) k (v), . . . , h(d) k (v) . 1 (v) ◦ ··· ◦ h(d) k (u) ∈(cid:110) (cid:111) FT ≤ n(d · 1.01 log3 n) instead of nC in the original argument. 2 ◦ ··· ◦ h(j) C−1 = n · (1.01d) C · (log3 n) C−1 = (log n)O(log n) Now we consider all possible witness trees in FT under the suffixes h(1) k+1. We could treat k+1 as O(log n)-wise independent functions for all possible witness trees in FT from Claim 4.6, k+1, . . . , h(d) h(1) because C = O(log n) and FT = (log n)O(log n). In the next step, we use O(log n)-wise independence to rewrite (2) and finish the proof of this case. k+1, . . . , h(d) Pruned witness trees with at least 3c collisions. In our alternate argument of this case in Lemma 3.6, the subconfiguration C(cid:48) of C has at most 3c · (2l + 1) nodes and 3c · (2l + 1) + 3c edges. Since l = logd log n + O(1), the number of edges in C(cid:48) is O(log log n). By choosing kg = Θ(log log n) with a sufficiently large constant, h with kg-wise independence supports the argument in Lemma 3.6. 10 5 The Uniform Greedy scheme We prove our main result for the Uniform-Greedy scheme -- Theorem 1.1 in this section. Theorem 5.1 For any m = O(n), any constant c ≥ 2, and integer d, there exists a hash family H from Construction 4.1 with O(log n log log n) random bits that guarantees the max-load of the Uniform Greedy scheme with d independent choices from H is logd log n + O(cid:0)c + m (cid:1) with probability at least 1 − n−c for any m balls in U. Proof. We specify the parameters of H as follows: kg = 10c(logd log m + logd(2 + 2c) + 5 + 3c), k = 3 log log n, δ2 = log n−C log n for a large constant C, and δ1 = 1/poly(n) such that Corollary 4.5 holds log2 with probability at least 1− n−c−1. Let h(1), . . . , h(d) denote the d independent hash functions from H with the above parameters, where each log n n h(j)(x) =(cid:0)h(j) 1 (x) ◦ h(j) 2 (x) ◦ ··· ◦ h(j) k (x) ◦ h(j) k+1(x)(cid:1) ⊕ g(j)(x). i , . . . , h(d) i } in this proof. We use the notation g to denote {g(1), g(2), . . . , g(d)} in the d choices and hi to denote the group of hash functions {h(1) We bound the probability that any symmetric witness tree of height l = (cid:100)logd log m + logd(2 + 2c) + 5 + 3c(cid:101) with leaves of height at least b = 10d · m n + 1 exists in h(1), . . . , h(d). Similar to the proof of Lemma 3.6, we bound the probability of pruned witness trees of height l in h(1), . . . , h(d). We separate all pruned witness trees into two cases according to the number of edge collisions: pruned witness trees with at most 3c collisions and pruned witness trees with at least 3c collisions. Pruned witness trees with at least 3c collisions. We start with a configuration C of pruned witness trees with height l and at least 3c collisions. Let e1, . . . , e3c be the first 3c collisions in the BFS of C. Let C(cid:48) be the induced subgraph of C that only contains nodes in these edges e1, . . . , e3c and their ancestors in C. Therefore any pruned witness tree T of configuration C exists in h(1), . . . , h(d) only if the corresponding counterpart T (cid:48) of T with configuration C(cid:48) exists in h(1), . . . , h(d). The existence of T (cid:48) in h(1), . . . , h(d) indicates that for every edge (u, v) in T (cid:48), h(1), . . . , h(d) satsify h(i)(cid:0)T (u)(cid:1) ∈(cid:110) h(1)(cid:0)T (v)(cid:1), . . . , h(d)(cid:0)T (v)(cid:1)(cid:111) when v is the ith child of u. Notice that the number of edges in C(cid:48) and T (cid:48) is at most 3c · 2l + 3c = 2l(3c + 1) ≤ kg/2. Because h(1), . . . , h(d) are kg-wise independent, We bound the probability that all edges of T (cid:48) satisfy (4) (4) in h(1), . . . , h(d) by (cid:89) (u,v)∈T (cid:48) ( d n ) = ( d n C(cid:48)+3c−1. ) Now we apply a union bound over all choices of balls in C(cid:48). There are at most mC(cid:48) choices of balls in the nodes of C(cid:48). Therefore we bound the probability that any witness with at least 3c collisions survives in kg-wise independent functions by ( d n C(cid:48)+3c−1 · m ) C(cid:48) ≤ ( )3c−1 · ( · d) C(cid:48) ≤ ( )3c−1 · ( · d)3c·(2l+1) ≤ n −2c. d n m n d n m n Next we apply a union bound over all configurations C(cid:48). Because there are at most (1+d+···+dl)2·3c ≤ n configurations of 3c collisions, with probability at least 1 − n−c, there is no pruned witness trees with at least 3c collision and height l exists in h(1), . . . , h(d). 11 Pruned witness trees with at most 3c collisions. We fix a configuration C of pruned witness trees with height l and less than 3c collisions. Next we bound the probability that any pruned witness trees in this configuration C with leaves of height at least b exists in h(1), . . . , h(d). We extensively use the fact that after fixing g and h1 ◦ ··· ◦ hk, at most d(1.01 log3 n · m n ) elements in h(1), . . . , h(d) are mapped to any bin of [n/ log3 n] from Corollary 4.5. Another property is the number of leaves in C: because there are at most 3c collisions in C, C has at least dl−3c ∈ [d5(2 + 2c) log m, d6(2 + 2c) log m] leaves. On the other hand, the number of leaves is at least C−3c . For a pruned witness tree T with configuration C, T exists in h(1), . . . , h(d) only if 2 ∀(u, v) ∈ C, h(i)(cid:0)T (u)(cid:1) ∈(cid:110) h(1)(cid:0)T (v)(cid:1), . . . , h(d)(cid:0)T (v)(cid:1)(cid:111) h1(x) ◦ ··· ◦ hk(x) and hk+1(x) separately. Since h(i)(x) =(cid:0)h(i) (cid:0)h(i) k (bv)(cid:1) ⊕ g(1) k (bu)(cid:1)⊕g(i) (5) indicates that the prefixes of the balls bu = T (u) and bv = T (v) satisfy 1 (bv) ◦ ··· ◦ h(1) 1 (bu)◦···◦h(i) 1 (x) ◦ ··· ◦ h(i) p (bv), . . . ,(cid:0)h(d) We restate the above condition on the prefixes and suffixes of h(1), . . . , h(d) separately. Let gp(x) denote the first log n − 3 log log n bits of g(x) and gs(x) denote the last 3 log log n bits of g(x), which matches when v is the ith child of u. (5) k+1(x)(cid:1) ⊕ g(i)(x), property p (bu) ∈(cid:110)(cid:0)h(1) s (bu) ∈(cid:110) k (bv)(cid:1) ⊕ g(d) (6) (cid:111) p (bv) . 1 (bv) ◦ ··· ◦ h(d) (cid:111) and their suffixes satisfy k+1(bv) ⊕ g(d) k+1(bu) ⊕ g(i) h(i) k+1(bv) ⊕ g(1) h(1) C−1. (7) Let FT be the subset of witness trees in the configuration C whose edges satisfy the condition (6) in preffixes h(1), . . . , h(k), i.e., FT = {Tconfiguration(T ) = C and (u, v) satisfies (6) ∀(u, v) ∈ T}. We show that s (bv), . . . , h(d) s (bv) . FT ≤ m · (d · 1.01 log3 n · m n ) we have to satisfy the condition (6) for (u, v). For a fixed bin(cid:0)h(i) The reason is as follows. There are m choices of balls for the root u in C. For the ith child v of the root u, p (bu), there are at most 1.01 · log3 n · m n elements from each hash function h(j) mapped to this bin from Corollary 4.5. Hence there are at most d · 1.01 log3 n · m n choices for each child of u. Then we repeat this arguments for all non-leaf nodes in C. k (bu)(cid:1) ⊕ g(i) 1 (bu) ◦ ··· ◦ h(i) Next we consider the suffixes h(1) k+1, . . . , h(d) tree in FT survives in h(1) gs, for a possible witness tree T in FT , h(1) k+1, . . . , h(d) k+1. We first calculate the probability that any possible witness k+1 from t-wise independence for t = 5b · dl+2 = O(log n). After fixing k+1 satisfy (7) for every edge (u, v) ∈ C with probability k+1, . . . , h(d) in t/2-wise independent distributions because the number of edges in C is less than t/2. For each leaf v in T , we bound the probability that its height is at least b = 10d· m log3 n m )2d in (b · d + 1)-wise independence. Given a choice i ∈ [d] of leaf v, we fix the bin to be h(i)(v). Then we bound the probability that there are at least b− 1 balls w1, . . . , wb−1 in this bin excluding all balls in the tree by (cid:88) n + 1 by 2−3d2 · ( n (cid:88) (cid:88) d ··· w1:w1<v,w1 /∈T w2:w1<w2<v,w2 /∈T Pr[h(i)(v) = h(j1)(w1) = ··· = h(jb−1)(wb−1)] (cid:0)1.01d·log3 n· m (cid:1) n ≤ (1.01d · m (b − 1)! n )b−1 ≤ ( )b−1. 3 4 ≤ b−1 (log3 n)b−1 wb−1:wb−2<wb−1<v,wb−1 /∈T 12 For all d choices of this leaf v, this probability is at most ( 3 4 )(b−1)·d ≤ 2−3d2 · ( n m )2d. Because w1, . . . , wb are not in the tree T for every leaf, they are disjoint and independent with the events of (7) in T , which are over all edges in the tree. Hence we could multiply these two probability together in t-wise independence given t/2 ≥ (b · d + 1) · number of leaves. Then we apply a union bound over all possible pruned witness trees in FT to bound the probability (in the t-wise independence) that there is one witness tree of height l whose leaves have height at least 10d · m n + 1 by FT · ( d log3 n ) C−1 ·(cid:0)( (cid:18) )b·d(cid:1)number of leaves ≤m ≤m ·(cid:16) 3 4 (cid:19)C ·(cid:16) )2d(cid:17)C/3 ≤ m · 2 −3d2 · ( 2 n m )2d(cid:17) C−3c 2 1.01d · log3 n · m n · (cid:17)C ·(cid:16) d log3 n −3d2 · ( n m −C/3 ≤ n Finally we replace the t-wise independence by a δ2-biased space for δ2 = n−c−1 · (log3 n)−t/FT = (log n)−O(log n). We apply Claim 4.6 to all possible pruned witness tress in FT : in δ2-biased spaces, the probability of the existence of any height-l witness tree with leaves of height at least b = 10d · m n + 1 is at most 2d2 · m n 2 −c−1. −c−1 + FT · δ2 · (log3 n)t ≤ 2n −c−1. n Then we apply a union bound on all possible configurations with at most 3c collisions: (dl+1) 3c · 2n −c−1 ≤ 0.5n −c. From all discussion above, with probability at least 1− n−c, there is no ball of height more than l + b = (cid:117)(cid:116) logd log n + O(1). 6 The Always-Go-Left Scehme d . We define the Always-Go-Left scheme [Voc03] as follows: We show that the hash family in Section 4 with proper parameters also achieves a max-load of log log n d log φd in the Always-Go-Left scheme [Voc03] with d choices, where φd > 1 is the constant satisfying φd 1 + φd + ··· + φd−1 Definition 6.1 (Always-Go-Left with d choices) Our algorithm partitions the bins into d groups G1, . . . , Gd of the same size n/d. Let h(1), . . . , h(d) be d functions from U to G1, . . . , Gd separately. For each ball b, the algorithm considers d bins {h(1)(b) ∈ G1, . . . , h(d)(b) ∈ Gd} and chooses the bin with the least number of balls. If there are several bins with the least number of balls, our algorithm always chooses the bin with the smallest group number. +O(1) d = We define asymmetric witness trees for the Always-Go-Left mechanism such that a ball of height l + C in the Always-Go-Left scheme indicates that there is an asymmetric witness tree of height l whose leaves have height at least C. For an asymmetric witness tree T , the height of T is still the shortest distance from the root to its leaves. Definition 6.2 (Asymmetric Witness tree) The asymmetric witness tree T of height l in group Gi is a d- ary tree. The root has d children where the subtree of the jth child is an asymmetric witness tree in group Gj of height (l − 1j≥i). Given d functions h(1), . . . , h(d) from U to G1, . . . , Gd separately, a ball b with height more than l + C in a bin of group Gi indicates an asymmetric witness tree T of height l in Gi whose leaves have height at 13 least C. Each node of T corresponds to a ball, and the root of T corresponds to the ball b. A ball u in T has a ball v as its jth child iff when we insert the ball u in the Always-Go-Left mechanism, v is the top ball in the bin h(j)(u). Hence v < u and h(j)(u) = h(j)(v) when the jth child of u is v. For an asymmetric witness tree T of height l in group Gi, We use the height l and the group index i ∈ [d] to determine its size. Let f (l, i) be the size of a full asymmetric witness tree of height l in group Gi. From the definition, we have f (0, i) = 1 and i−1(cid:88) d(cid:88) Let g(cid:0)(l − 1) · d + i(cid:1) = f (l, i) such that f (l, i) = f (l, j) + j=1 j=i f (l − 1, j). g(n) = g(n − 1) + g(n − 2) + ··· + g(n − d). We know there exist c0 > 0, c1 = O(1), and φd > 1 satisfying Hence d = 1 + φd + ··· + φd−1 φd f (l, i) = g(cid:0)(l − 1) · d + i(cid:1) ∈ [c0 · φ(l−1)d+i such that g(n) ∈ [c0 · φn d d , c1 · φ(l−1)d+i d ]. d , c1 · φn d ]. Similar to the pruned witness tree of a symmetric witness tree, we use the same process in Definition 3.3 to obtain the pruned asymmetric witness tree of an asymmetric witness tree. Vocking in [Voc03] showed that in a perfectly random hash function, the maximum load is log log n d log φd + O(1) with high probability given any n balls. We outline Vocking's argument for distinct balls here: let b be a ball of height l + 4 for l = log log n+log(1+c) + 1. Without loss of generality, we assume that b is in the first group G1. By the definition of the asymmetric witness tree, there exists a tree T in G1 with root b and height l whose leaves have height at least 4. For each ball u and its ith ball v, the hash function h(i) satisfies h(i)(u) = h(i)(v). Similar to (2), we apply a union bound on all possible witness trees of height l in this configuration to bound the probability by nf (l,1) · ( d log φd 1 )f (l,1)−1 · ( which is less than n−c given f (l, 1) = Θ(φ(l−1)d+1 d n 3d )number of leaves in f (l,1), ) = Θ(cid:0)(1 + c) log n(cid:1). d We prove our derandomization of Vocking's argument here. Theorem 6.3 For any m = O(n), any constants c > 1 and d ≥ 2, there exist a constant φd ∈ (1.61, 2) and a hash family H in Construction 4.1 with O(log n log log n) random bits such that for any m balls in U, with probability at least 1 − n−c, the max-load of the Always-Go-Left mechanism with d independent choices from H is log log n + O(c + m n ). d log φd d ≥ 10(2 + 2c) log m and b = 10d · m Proof. Let l be the smallest integer such that c0φld n + 1. We bound the probability of a witness tree of height l+3c+1 whose leaves have height more than b in h(1), . . . , h(d) during the Always-Go-Left scheme. Notice that there is a ball of height l + b + 3c + 1 in any bin of G2, G3, . . . , Gd indicates that there is a ball of the same height in G1. We choose the parameters of H as follows: kg = 20c · d · (l + b + 1 + 3c) = O(log log n), k = log2(log n/3 log log n), δ1 = 1/poly(n) such that Corollary 4.5 happens with probability at most n−c−1, 14 h(j) =(cid:0)h(j) (cid:1) ⊕ g(j) and the bias δ2 = log n−O(log n) of hk+1 later. We set hk+1 to be a hash function from U to [log3 n/d] and g to be a function from U to [n/d] such that 1 ◦ ··· ◦ h(j) 1 ◦ h(j) is a map from U to Gj of [n/d] bins for each j ∈ d. We use h(1), . . . , h(d) to denote d independent hash functions from H with the above parameters. We i } in this proof. We assume use the notation of hi to denote the group of hash functions {h(1) Corollary 4.5 and follow the same argument in the proof of Theorem 5.1. We bound the probability of witness trees from 2 cases depending on the number of collisions. k ◦ h(j) , . . . , h(d) k+1 i Pruned witness trees with at least 3c collisions: Given a configuration C with at least 3c collisions, we consider the first 3c collisions e1, . . . , e3c in the BFS of C. Let C(cid:48) be the induced subgraph of C that only contains all vertices in e1, . . . , e3c and their ancestors in C. Therefore C survives under h(1), . . . , h(d) only if C(cid:48) survives under h(1), . . . , h(d). C(cid:48). For each instantiation T of C(cid:48), because kg ≥ 2 · number of edges = 2(C(cid:48) + 3c − 1), we bound the probability that any instantiation of C(cid:48) survives in h by Observe that C(cid:48) ≤ 3c · 2 ·(cid:0)d · height(T )(cid:1). There are at most mT (cid:48) possible instantiations of balls in C(cid:48) · ( m d n )number of edges = m C(cid:48) · ( d n C(cid:48)+3c−1 ≤ (dm/n) C(cid:48) · ( ) )3c−1 ≤ n −2c. d n At the same time, there are at most (T2)3c = poly(log n) configurations of C(cid:48). Hence we bound the probability of any witness with at least 3c collisions surviving by n−c. Pruned witness tree with less than 3c collisions: We fix a configuration C of witness tree in group G1 with height l + 1 + 3c and less than 3c collisions. Thus C ∈ [f (l + 1, 1), f (l + 1 + 3c, 1)]. Let FT be the subset of possible asymmetric witness tree with configuration C after fixing the prefixes h1, h2, . . . , hk. For any T ∈ FT , each edge (u, v) has to satisfy h(i)(cid:0)T (u)(cid:1) = h(i)(cid:0)T (v)(cid:1) in the Always- Go-Left scheme when v is the ith child of u. This indicates their prefixes are equal: (cid:0)T (u)(cid:1) ◦ ··· ◦ h(i) (cid:0)T (u)(cid:1) = h(i) (cid:0)T (v)(cid:1) ◦ ··· ◦ h(i) (cid:0)T (v)(cid:1). k 1 h(i) 1 k From the same argument in the proof of Theorem 5.1, we bound FT ≤ m · (1.01 log3 n · m n C−1 ) under h1, h2, . . . , hk from Corollary 4.5. We first consider hk+1 as a t-wise independent distribution from U to [log3 n/d] for t = 5bd· f (l + 3c + 1, 1) = O(log m) then move to δ2-biased spaces. For each asymmetric witness tree, every edge (u, v) maps to the same bin w.p. d/ log3 n in hk+1. For each leaf, its height is at least b if each bin in its choices has height at least b − 1, which happens with probability at most(cid:0)1.01·log3 n· m b−1 n (cid:1) (log3 n/d)b−1 d (cid:32) ≤ (cid:33)d (1.01d · m (b − 1)! n )b−1 15 ≤ 2 −3d2 · ( n m )2d from the proof of Theorem 5.1. asymmetric witness tree in FT exists in t-wise independent distributions over the suffixes is at most Because these two types of events are on disjoint subsets of balls, the probability that any possible (cid:18) d log3 n (cid:19)C−1 ·(cid:16) FT · )2d(cid:17) (d−1)(C−3c) d −3d2 · ( 2 n m ≤m ·(cid:16) ≤m · 2 (cid:17)C ·(cid:16) 1.01d · m n −f (l+1,1) ≤ n 2 −c−1. −3d2 · ( n m )2d(cid:17)C/3 We choose δ2 = n−c−1 · (log3 n/d)−t/FT = (log n)−O(log n) such that in δ2-biased spaces, any possible asymmetric witness tree in FT exists hk+1 is at most happens with probability at most n−c−1 + FT · δ2 · (log3 /d)bd·f (l+3c+1,1) ≤ 2n−c−1. At the same time, the number of possible configurations is at most (f (l + 3c + 1, 1)2)3c ≤ 0.1n. From all discussion above, with probability at most n−c, there exists a ball in the Always-Go-Left mech- (cid:117)(cid:116) anism with height at least l + b + 3c + 1 = log n log n d log φd + O(1). 7 Heavy load We consider the derandomization of the 1-choice scheme when we have m = n·poly(log n) balls and n bins. From the Chernoff bound, w.h.p, the max-load among n bins is m n m > n log n balls into n bins independently at random. We modify the hash function from [CRSW13] with proper parameters for m = poly(log n) · n balls and prove the max-load is still m We assume m = loga n · n for a constant a ≥ 1 in the rest of this section. Theorem 7.1 For any constant c > 0 and a ≥ 1, there exist a constant C and a hash function from U to [n] generated by O(log n log log n) random bits such that for any m = loga n · n balls, with probability at least 1 − n−c, the max-load of the n bins in the 1-choice scheme with the hash function h is at most m )(cid:1) when we throw log n ·(cid:112) n (cid:0)1 + O( m )(cid:1). log n ·(cid:112) n (cid:0)1 + O( √ √ n (cid:0)1 + C · √ log n ·(cid:112) n (cid:1). m m n log n (2a) log log n, We omit g in this section and change h1, . . . , hk+1 with different parameters. We choose k = log log n(cid:112) n ] for i ∈ [k], and hk+1 to denote a hash function from U to hi to denote a hash function from U to [n2−i ] = [log2a n] such that h1 ◦ h2 ◦ ··· ◦ hk ◦ hk+1 constitute a hash function from U to [n]. We set [n2−k √ m. For convenience, we still think h1 ◦ h2 ◦ ··· ◦ hi as a hash function maps to β = 4(c + 2) n1−2−i bins for any i ≤ k. In this section, we still use δ1-biased spaces on h1, . . . , hk and a δ2-biased space on hk+1 for δ1 = 1/poly(n) and δ2 = (log n)−O(log n). Claim 7.2 For any constant c > 0, there exists δ1 = 1/poly(n) such that given m = loga n · n balls, with (k+2−i)2 ) · probability 1 − n−c−1, for any i ∈ [k] and any bin b ∈ [n1−2−i n · n2−i balls in this bin. Proof. We still use induction on i. The base case is i = 0. Because there are at most m balls, the hypothesis is true. n n2−l ≤ n n2−l balls in this bin from the induction hypothesis. hl+1 maps these s balls to t = n2−(l+1) bins. (k+1−l)2 )s/t Suppose it is true for i = l. Now we fix a bin and assume there are s =(cid:81) (1 + β) m We will prove that with high probability, every bin in these t bins of hl+1 contains at most (1 + balls. ], there are less than(cid:81) (k+2−i)2 ) · m j≤i(1 + j≤l(1 + m β β β 16 We use Xi ∈ {0, 1} to denote whether ball i is in one fixed bin of [t] or not. Hence Pr[Xi = 1] = 1/t. Let Yi = Xi − E[Xi]. Therefore E[Yi] = 0 and E[Yil] ≤ 1/t for any l ≥ 2. Let b = β2l for a large constant β later. (cid:88) [ Pr Dδ1 i Xi > (1 + β (k + 1 − l)2 )s/t] ≤ EDδ1 (cid:80) ( i Yi)b] (k+1−l)2 s/t)b β [((cid:80) i1,...,ib EU [Yi1 ··· Yib] + δ1s2b (k+1−l)2 s/t)b ( β ≤ ≤ (cid:32) ≤ 2bb!(s/t)b/2 + δ1s2b β ( (k+1−l)2 s/t)b (cid:33)b/2 2b(s/t) β (k+1−l)2 s/t)2 ( + δ1 · s2b We use these bounds k = log (m/n)2 to simplify the above bound by log n (2l) log log n < log log n, b < β2k < β log n (2l) log log n and n2−l−1 ≥ n2k ≥ log2l n ≥ + δ1s2b (cid:33)b/2 b/2 β2  2 log n (cid:32) (log log n)4 · s/t 2 log2 n (cid:19)b/2 (cid:18) m ) · ( m (log n · n 1 n0.5·2−l−1 −0.5·2−l−1·β2l/2 + δ1 ≤n ≤ ≤ n n2−l−1) + δ1s2b (cid:18) 2m n + δ1s2b n2−l(cid:19)2β2l ≤ n −β/8 + δ1 · n6β. Hence we choose the two parameters β > 8(c + 2) and δ1 = n−6β−c−2 such that the above probability is (cid:117)(cid:116) bounded by 2n−c−2. Finally, we apply the union bound on i and all bins. β Proof of Theorem 7.1. We first apply Claim 7.2 to h1, . . . , hk. maps s < (cid:81) to [log2a n] is δ2 ·(cid:0)2 m In hk+1, we first consider it as a b = 16(c + 2)2 log n = O(log n)-wise independent distribution that n n2−k balls to t = n2−k bins. From Lemma 2.6 and Theorem 5 (I) j≤k(1 + in [SSS95], we bound the probability that one bin receives more than (1 + β)s/t by eβ2·E[s/t]/3 ≤ n−c−2 given b ≥ β2 E[s/t]. (k+2−i)2 ) · m Then we choose δ2 = (log n)−b·5a = (log n)−O(log n) such that any δ2-biased space from [2 m (cid:1) · (log2a n)b < n−c−2-close to a b-wise independent distribution. Hence in hk+1, with probability at most 2 · n−c−2, there is one bin that receives more than (1 + β)s/t balls. Overall, n log2a n] n log2a n ≤b 17 the number of balls in any bin of [n] is at most (1 + β (k + 2 − i)2 )(1 + β) ≤ (1 + m n (cid:89) i≤k (cid:88) i≤k+1 β (k + 2 − i)2 ) m n ≤ (1 + 2β) m n . (cid:117)(cid:116) Acknowledgement The author is grateful to David Zuckerman for his constant support and encouragement, as well as for many fruitful discussions. We thank Eric Price for introducing us to the multiple-choice schemes. We also thank the anonymous referee for the detailed feedback and comments. References [ABKU99] Yossi Azar, Andrei Z. Broder, Anna R. Karlin, and Eli Upfal. Balanced allocations. SIAM J. Comput., 29(1):180 -- 200, September 1999. [ADM+99] Noga Alon, Martin Dietzfelbinger, Peter Bro Miltersen, Erez Petrank, and G´abor Tardos. Lin- ear hash functions. J. ACM, 46(5):667 -- 683, September 1999. [AGHP90] N. Alon, O. Goldreich, J. Hastad, and R. Peralta. Simple construction of almost k-wise inde- pendent random variables. In Proceedings of the 31st Annual Symposium on Foundations of Computer Science. IEEE Computer Society, 1990. [AKT18] Anders Aamand, Mathias Baek Tejs Knudsen, and Mikkel Thorup. Power of d choices with simple tabulation. In 45th International Colloquium on Automata, Languages, and Program- ming, ICALP 2018, July 9-13, 2018, Prague, Czech Republic, pages 5:1 -- 5:14, 2018. [ANSS16] Gilad Asharov, Moni Naor, Gil Segev, and Ido Shahaf. Searchable symmetric encryption: Optimal locality in linear space via two-dimensional balanced allocations. In Proceedings of the Forty-eighth Annual ACM Symposium on Theory of Computing, STOC '16, pages 1101 -- 1114, 2016. [CRSW13] L. Elisa Celis, Omer Reingold, Gil Segev, and Udi Wieder. Balls and bins: Smaller hash families and faster evaluation. SIAM J. Comput., 42(3):1030 -- 1050, 2013. [DETT10] Anindya De, Omid Etesami, Luca Trevisan, and Madhur Tulsiani. Improved pseudorandom generators for depth 2 circuits. In RANDOM 2010, pages 504 -- 517, 2010. [DKRT16] Søren Dahlgaard, Mathias Baek Tejs Knudsen, Eva Rotenberg, and Mikkel Thorup. The power In Proceedings of the Twenty-Seventh Annual ACM- of two choices with simple tabulation. SIAM Symposium on Discrete Algorithms, SODA 2016, pages 1631 -- 1642, 2016. [DW03] Martin Dietzfelbinger and Philipp Woelfel. Almost random graphs with simple hash functions. In Proceedings of the Thirty-fifth Annual ACM Symposium on Theory of Computing, STOC '03, pages 629 -- 638, 2003. 18 [GKM15] Parikshit Gopalan, Daniek Kane, and Raghu Meka. Pseudorandomness via the discrete fourier transform. In IEEE 56th Annual Symposium on Foundations of Computer Science, FOCS 2015, pages 903 -- 922, 2015. [GMR+12] Parikshit Gopalan, Raghu Meka, Omer Reingold, Luca Trevisan, and Salil P. Vadhan. Bet- In 53rd Annual IEEE ter pseudorandom generators from milder pseudorandom restrictions. Symposium on Foundations of Computer Science, FOCS 2012, pages 120 -- 129, 2012. [Mit01] Michael Mitzenmacher. The power of two choices in randomized load balancing. IEEE Trans. Parallel Distrib. Syst., 12(10):1094 -- 1104, 2001. [MRRR14] Raghu Meka, Omer Reingold, Guy N. Rothblum, and Ron D. Rothblum. Fast pseudoran- domness for independence and load balancing - (extended abstract). In Automata, Languages, and Programming - 41st International Colloquium, ICALP 2014, Proceedings, pages 859 -- 870, 2014. [MRS00] Michael Mitzenmacher, Andrea W. Richa, and Ramesh Sitaraman. The power of two random choices: A survey of techniques and results. In in Handbook of Randomized Computing, pages 255 -- 312, 2000. [Nis92] [NN90] [NZ96] [PT12] Noam Nisan. Pseudorandom generators for space-bounded computation. Combinatorica, 12(4):449 -- 461, 1992. J. Naor and M. Naor. Small-bias probability spaces: Efficient constructions and applications. In Proceedings of the Twenty-second Annual ACM Symposium on Theory of Computing, STOC '90, pages 213 -- 223. ACM, 1990. Noam Nisan and David Zuckerman. Randomness is linear in space. J. Comput. Syst. Sci., 52(1):43 -- 52, 1996. Mihai Patras¸cu and Mikkel Thorup. The power of simple tabulation hashing. 59(3):14:1 -- 14:50, June 2012. J. ACM, [RRW14] Omer Reingold, Ron D. Rothblum, and Udi Wieder. Pseudorandom graphs in data structures. In Automata, Languages, and Programming - 41st International Colloquium, ICALP 2014, Proceedings, pages 943 -- 954, 2014. [Sie89] [SSS95] [Sti94] Alan Siegel. On universal classes of fast high performance hash functions, their time-space tradeoff, and their applications. In Proceedings of the 30th Annual Symposium on Foundations of Computer Science, FOCS 1989, pages 20 -- 25, 1989. Jeanette P. Schmidt, Alan Siegel, and Aravind Srinivasan. Chernoff-hoeffding bounds for ap- plications with limited independence. SIAM J. Discret. Math., 8(2):223 -- 250, May 1995. D. R. Stinson. Combinatorial techniques for universal hashing. Journal of Computer and System Sciences, 48(2):337 -- 346, 1994. [Voc03] Berthold Vocking. How asymmetry helps load balancing. J. ACM, 50(4):568 -- 589, July 2003. [Vaz86] Umesh Vazirani. Randomness, adversaries and computation. Berkeley, pages 458 -- 463. 1986. In Ph.D. Thesis, EECS, UC 19 [Wie17] [Woe06] Udi Wieder. Hashing, load balancing and multiple choice. Foundations and Trends in Theoret- ical Computer Science, 12(3-4):275 -- 379, 2017. Philipp Woelfel. Asymmetric balanced allocation with simple hash functions. In Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithm, SODA '06, pages 424 -- 433, 2006. A Proof of Lemma 4.4 Suppose it is true for i = l < d. For a fixed bin j ∈ [n1− 1 We apply an induction from i = 0 to i = k. The base case i = 0 is true because there are at most m balls. n balls. With n balls from the induction hypothesis. 2l ], there are at most (1 + β)ln out loss of generality, we assume there are exactly s = (1 + β)ln Under the hash function hl+1, we allocate these balls into t = n 2l · m 2l+1 bins. 2l · m 1 1 1 We fix one bin in hl+1 and prove that this bin receives at most 2l+1 · m n (1 + β)s/t = (1 + β) · (1 + β)ln 1 2l /n 1 = (1 + β)l+1n 1 2l+1 · m n balls with probability ≤ 2n−c−2 in a log3 n-wise δ1-biased space for δ1 = 1/poly(n) with a sufficiently i∈[s] Xi] = s/t. For convenience, we use Yi = Xi − E[Xi]. Hence Yi = 1 − 1/t w.p. 1/t, o.w. Yi = −1/t. Notice that large polynomial. We use Xi ∈ {0, 1} to denote the ith ball is in the bin or not. Hence E[(cid:80) We choose b = 2l · β = O(log n) for a large even number β and compute the bth moment of(cid:80) i ] ≤ 1/t for any l ≥ 2. E[Yi] = 0 and E[Y l i∈[s] Yi as follows. Pr[(cid:88) i∈[s] i Yi)b]/(βs/t)b (cid:88) Xi > (1 + β)s/t] ≤ Eδ1-biased[( ≤ EU [((cid:80) i Yi)b] + δ1 · s2btb (cid:80) (βs/t)b E[Yi1 · Yi2 · ··· · Yib] + δ1 · s3b (cid:0)b−j−1 (cid:80)b/2 ≤ ≤ 2b/2b! · (s/t)b/2 + δ1 · s3b (βs/t)b 2b/2 · sj(1/t)j + δ1 · s3b (βs/t)b (cid:1) · i1,...,ib j−1 ≤ j=1 b! 1 2k ≥ log3 n, b ≤ β2k ≤ β log n 3 log log n ≤ (s/t)1/3 and β = (log n)−0.2 < (s/t)0.1, we simplify Because s/t ≥ n it to (cid:18) 2b2 · s/t (cid:19)b/2 (cid:32) (βs/t)2 + δ1 · s3b ≤ =(s/t)(−0.1)·b/2 + δ1 · s3b ≤ (n 2(s/t)2/3 · s/t (s/t)1.8 −0.1·β2l 2 2l+1 ) + δ1(n + δ1 · s3b 2l )3β·2l 3 = n (βs/t)b (cid:33)b/2 Finally we choose β = 40(c + 2) = O(1) and δ1 = n−9β−c−2 to finish the proof. 20 −c−2 + δ1n9β ≤ 2n −c−2.
1801.04414
2
1801
2018-04-06T23:43:26
Tight Bounds for $\ell_p$ Oblivious Subspace Embeddings
[ "cs.DS" ]
An $\ell_p$ oblivious subspace embedding is a distribution over $r \times n$ matrices $\Pi$ such that for any fixed $n \times d$ matrix $A$, $$\Pr_{\Pi}[\textrm{for all }x, \ \|Ax\|_p \leq \|\Pi Ax\|_p \leq \kappa \|Ax\|_p] \geq 9/10,$$ where $r$ is the dimension of the embedding, $\kappa$ is the distortion of the embedding, and for an $n$-dimensional vector $y$, $\|y\|_p$ is the $\ell_p$-norm. Another important property is the sparsity of $\Pi$, that is, the maximum number of non-zero entries per column, as this determines the running time of computing $\Pi \cdot A$. While for $p = 2$ there are nearly optimal tradeoffs in terms of the dimension, distortion, and sparisty, for the important case of $1 \leq p < 2$, much less was known. In this paper we obtain nearly optimal tradeoffs for $\ell_p$ oblivious subspace embeddings for every $1 \leq p < 2$. We show for every $1 \leq p < 2$, any oblivious subspace embedding with dimension $r$ has distortion $\kappa = \Omega \left(\frac{1}{\left(\frac{1}{d}\right)^{1 / p} \cdot \log^{2 / p}r + \left(\frac{r}{n}\right)^{1 / p - 1 / 2}}\right).$ When $r = \mathrm{poly}(d)$ in applications, this gives a $\kappa = \Omega(d^{1/p}\log^{-2/p} d)$ lower bound, and shows the oblivious subspace embedding of Sohler and Woodruff (STOC, 2011) for $p = 1$ and the oblivious subspace embedding of Meng and Mahoney (STOC, 2013) for $1 < p < 2$ are optimal up to $\mathrm{poly}(\log(d))$ factors. We also give sparse oblivious subspace embeddings for every $1 \leq p < 2$ which are optimal in dimension and distortion, up to $\mathrm{poly}(\log d)$ factors. Oblivious subspace embeddings are crucial for distributed and streaming environments, as well as entrywise $\ell_p$ low rank approximation. Our results give improved algorithms for these applications.
cs.DS
cs
Tight Bounds for ℓp Oblivious Subspace Embeddings Ruosong Wang David P. Woodruff Carnegie Mellon University Carnegie Mellon University [email protected] [email protected] Abstract An ℓp oblivious subspace embedding is a distribution over r × n matrices Π such that for any fixed n × d matrix A, Pr Π [for all x, kAxkp ≤ kΠAxkp ≤ κkAxkp] ≥ 9/10, where r is the dimension of the embedding, κ is the distortion of the embedding, and for an n-dimensional vector y, kykp = (Pn i=1 yi)1/p is the ℓp-norm. Another important property is the sparsity of Π, that is, the maximum number of non-zero entries per column, as this determines the running time of computing Π· A. While for p = 2 there are nearly optimal tradeoffs in terms of the dimension, distortion, and sparsity, for the important case of 1 ≤ p < 2, much less was known. In this paper we obtain nearly optimal tradeoffs for ℓp oblivious subspace embeddings for every 1 ≤ p < 2. Our main results are as follows: 1. We show for every 1 ≤ p < 2, any oblivious subspace embedding with dimension r has n )1/p−1/2(cid:19) . When r = poly(d) ≪ n in applications, this distortion κ = Ω(cid:18) 1 d )1/p ( 1 ·log2/p r+( r gives a κ = Ω(d1/p log−2/p d) lower bound, and shows the oblivious subspace embedding of Sohler and Woodruff (STOC, 2011) for p = 1 and the oblivious subspace embedding of Meng and Mahoney (STOC, 2013) for 1 < p < 2 are optimal up to poly(log(d)) factors. 2. We give sparse oblivious subspace embeddings for every 1 ≤ p < 2 which are optimal in dimension and distortion, up to poly(log d) factors. Importantly for p = 1, we achieve r = O(d log d), κ = O(d log d) and s = O(log d) non-zero entries per column. The best previous construction with s ≤ poly(log d) is due to Woodruff and Zhang (COLT, 2013), giving κ = Ω(d2poly(log d)) or κ = Ω(d3/2√log n · poly(log d)) and r ≥ d · poly(log d); in contrast our r = O(d log d) and κ = O(d log d) are optimal up to poly(log(d)) factors even for dense matrices. We also give (1) nearly-optimal ℓp oblivious subspace embeddings with an expected 1+ε number of non-zero entries per column for arbitrarily small ε > 0, and (2) the first oblivious subspace embeddings for 1 ≤ p < 2 with O(1)-distortion and dimension independent of n. Oblivious subspace embeddings are crucial for distributed and streaming environments, as well as entrywise ℓp low rank approximation. Our results give improved algorithms for these applications. 1 Introduction An ℓp oblivious subspace embedding with distortion κ is a distribution over r×n matrices Π such that for any given A ∈ Rn×d, with constant probability, kAxkp ≤ kΠAxkp ≤ κkAxkp simultaneously for all x ∈ Rd. The goal is to minimize r, κ and the time to calculate ΠA. Oblivious subspace embeddings have proven to be an essential ingredient for approximately solving numerical linear algebra problems, such as regression and low-rank approximation. S´arlos [27] first used ℓ2 oblivious subspace embeddings to solve ℓ2-regression and Frobenius-norm low- rank approximation. To see the connection, suppose one wishes to solve the ℓ2-regression problem argminx kAx − bk2 in the overconstrained setting, i.e., A ∈ Rn×d and b ∈ Rn where n ≫ d. S´arlos showed that in order to solve this problem approximately, it suffices to solve a much smaller instance argminx kΠAx − Πbk2, provided Π is an ℓ2 oblivious subspace embedding. S´arlos further showed that using the Fast Johnson-Lindenstrauss Transform in [1] as the ℓ2 oblivious subspace embedding with κ = 1 + ε, one can get a (1 + ε)-approximate solution to the ℓ2-regression problem in O(nd log d) + poly(d/ε) time, which is a substantial improvement over the standard SVD-based approach which runs in O(nd2) time. Subsequent to the work of S´arlos, the "sketch and solve" approach became an important way to solve numerical linear algebra problems. We refer interested readers to the monograph of Woodruff [30] for recent developments. The bottleneck of S´arlos's approach is the step to calculate ΠA, which requires Ω(nd log d) time due to the structure of the Fast Johnson-Lindenstrauss Transform. Although this is already nearly-optimal for dense matrices, when A is large and sparse, one may wish to solve the problem faster than O(nd) time by exploiting the sparsity of A. Clarkson and Woodruff [12] showed that there exist ℓ2 oblivious subspace embeddings with r = poly(d/ε) rows, s = 1 non-zero entries per column, and κ = 1 + ε. The property that s = 1 is significant, since it implies calculating ΠA requires only O(nnz(A)) time, where nnz(A) is the number of non-zero entries of A. In fact, the oblivious subspace embedding they used is the CountSketch matrix from the data stream literature [8]. By using the the CountSketch embedding in [12], one can reduce an ℓ2-regression instance of size n × d into a smaller instance of size poly(d/ε) × d in O(nnz(A)) time. The original proof in [12] used a technique based on splitting coordinates by leverage scores. The number of rows can be further reduced to r = O((d/ε)2) using the same construction and a finer analysis based on second moment method, shown independently in [22] and [23]. One may wonder if it is possible to further reduce the number of rows in the CountSketch embedding, since this affects the size of the smaller instance to solve. In [24], Nelson and Nguyen showed that any ℓ2 oblivious subspace embedding with constant distortion and s = 1 non-zero entries per column requires Ω(d2) rows. Although this rules out the possibility of further reducing the number of rows in the CountSketch embedding, this lower bound can be circumvented by considering embeddings with s > 1 non-zero entries in each column. This idea is implemented by the same authors in [23], obtaining a result showing that for any B > 2, for r about B · d log8 d/ε2 and s about log3 B d/ε, one can achieve an ℓ2 oblivious subspace embedding with κ = 1 + ε. The bound on r and s was further improved in [13] (see also [6]), where Cohen showed that for any B > 2, it suffices to have r = O(B · d log d/ε2) and s = O(logB d/ε). Cohen's result matches the lower bound in [25] up to a multiplicative log d factor in the number of rows. Another line of research focused on the case when p 6= 2, as the corresponding regression and low rank approximation problems are often considered to be more robust, or less sensitive to outliers. Moreover, the p = 1 error measure for regression yields the maximum likelihood estimator under 1 Laplacian noise models. When p = 1, using Cauchy random variables, Sohler and Woodruff [28] showed there exist ℓ1 oblivious subspace embeddings with O(d log d) rows and κ = O(d log d). This approach was generalized by using p-stable random variables in work of Meng and Mahoney [22] to ℓp-norms when 1 < p < 2, where they showed there exist ℓp oblivious subspace embeddings with O(d log d) rows and κ = O(cid:0)(d log d)1/p(cid:1). Unlike the case when p = 2, due to the large distortion incurred in such upper bounds, one cannot directly get a (1 + ε)-approximate solution to the ℓp- regression problem by solving argminx kΠAx − Πbkp. A natural question then, is whether it is possible to obtain (1 + ε)-distortion with ℓp oblivious subspace embeddings; prior to our work there were no lower bounds ruling out the simplest of algorithms for p 6= 2: (1) compute ΠA and Πb, and (2) output argminx kΠAx − Πbkp. Although it was unknown if better oblivious subspace embeddings exist for p 6= 2 prior to our work, ℓp oblivious subspace embeddings still played a crucial role in solving ℓp-regression problems in earlier work, since they provide a way to precondition the matrix A, which enables one to further apply non-oblivious (sampling-based) subspace embeddings. We refer interested readers to Chapter 3 of [30] and references therein for further details. Recent developments in entrywise ℓp low- rank approximation [29] also used ℓp oblivious subspace embeddings as an important ingredient. Furthermore, such ℓ1 oblivious subspace embeddings are the only known way to achieve single- pass streaming algorithms for ℓ1-regression (see, e.g., Section 5 of [28], where it is shown how to implement the preconditioning and sampling in parallel in a single pass), a model that has received considerable interest for linear algebra problems (see, e.g., [11]). We note that recent algorithms for ℓp-regression based on Lewis weight sampling require at least Ω(log log n) passes in the streaming model. Due to these applications, speeding up the computation of ΠA for ℓp oblivious subspace embed- dings is an important goal. In [10], Clarkson et al. combined the idea of Cauchy random variables and Fast Johnson-Lindenstrauss Transforms to obtain a more structured family of subspace em- beddings, which enables one to calculate ΠA in O(nd log n) time. Meng and Mahoney [22] showed that when 1 ≤ p < 2, there exist ℓp oblivious subspace embeddings with r = eO(d5) rows and s = 1 non-zero entries per column, where the distortion κ = eO(d3/p). The structure of the embedding by Meng and Mahoney is very similar to the CountSketch embedding by Clarkson and Woodruff [12]. In fact, to prove the distortion bound, Meng and Mahoney also used techniques of splitting coordinates based on leverage scores. Inspired by the technique by Andoni in [2], which used exponential random variables to estimate the ℓp-norm of a data steam, Woodruff and Zhang [31] improved the embedding given in [22]. They showed there exist ℓ1 oblivious subspace embeddings with r = eO(d) rows and s = polylog(d) non-zero entries per column, where the distortion κ = min{eO(d2), eO(d1.5)√log n}. Note that to achieve such a small polylogarithmic sparsity, the distortion κ had to either increase to eO(d2) or to eO(d1.5)√log n, the latter also depending on n. the number of rows r = poly(d). Results in [28, 22] showed that κ = O(cid:0)(d log d)1/p(cid:1) is achievable. with dimension eO(d) and distortion κ = eO(cid:0)d1/p(cid:1). In this paper, we resolve these questions. The above works leave many gaps in our understanding on the tradeoffs between dimension, distortion, and sparsity for ℓp oblivious subspace embeddings. For instance, it is natural to ask what the optimal distortion bound for ℓp oblivious subspace embeddings is when 1 ≤ p < 2, provided that Is this optimal? Also, it is unknown whether there exist sparse ℓp oblivious subspace embeddings 2 1.1 Our Results Distortion Lower Bound. We first show a distortion lower bound for ℓp oblivious subspace embeddings, when 1 ≤ p < 2. Theorem 1.1. For 1 ≤ p < 2, if a distribution over r × n matrices Π is an ℓp oblivious subspace embedding, then the distortion κ = Ω 1 (cid:0) 1 d(cid:1)1/p · log2/p r +(cid:0) r n(cid:1)1/p−1/2! . When 1 ≤ p < 2 and r = poly(d), the denominator of the lower bound is dominated by the It is shown in [28] (for p = 1) and Theorem 6 in [22] (for 1 < p < 2) that there exist ℓp oblivious (cid:0) 1 d(cid:1)1/p· log2/p r term, provided n is large enough. In that case, our lower bound is Ω(d1/p log−2/p d). subspace embeddings with r = O(d log d) rows and distortion κ = O(cid:0)(d log d)1/p(cid:1). Our lower bound matches these results up to an O(cid:16)log3/p d(cid:17) factor. Thus, our lower bound is nearly-optimal for r = poly(d) (which is the main regime of interest in the above applications). The dependence on (r/n)1/p−1/2 reflects the fact that • When the number of rows r = n, one can get a trivial ℓp oblivious subspace embedding with κ = 1, i.e., the identity matrix I; • As p → 2, there exist ℓ2 oblivious subspace embeddings [27, 12, 22, 23, 6, 13] with κ = 1 + ε and r = poly(d/ε), where ε can be an arbitrarily small constant. It is possible that the log2/p r factor (in the (1/d)1/p·log2/p r term) could be somewhat improved. However, we show that some dependence on r is in fact necessary. Theorem 1.2 (Informal version of Theorem 3.5). For 1 ≤ p < 2, there exists an ℓp oblivious subspace embedding over exp(exp(O(d))) × n matrices Π, where the distortion κ is a constant. Even though Theorem 1.2 has a doubly exponential dependence on d in the number of rows, it is the first ℓp oblivious subspace embedding with constant distortion, when 1 ≤ p < 2 and r does not depend on n. This new embedding suggests that it is impossible to get a lower bound of κ = Ω 1 n(cid:1)1/p−1/2! , +(cid:0) r (cid:0) 1 d(cid:1)1/p term should have some dependence on r. i.e., the(cid:0) 1 d(cid:1)1/p New ℓp oblivious subspace embeddings. We next show there exist sparse ℓp oblivious sub- space embeddings with nearly-optimal distortion. Theorem 1.3 (Summary of Theorem 4.1, 4.2, 5.1 and 5.2.). For 1 ≤ p < 2, there exist ℓp oblivious subspace embeddings over r × n matrices Π with s non-zero entries per column and distortion κ, where 1. When p = 1, 3 (a) r = O(d2), s = 2 and κ = O(d); or (b) For sufficiently large B, r = O(B · d log d), s = O(logB d) and κ = O(d logB d). 2. When 1 < p < 2, κ = O(cid:0)(d log d)1/p(cid:1), (a) r = O(d2), s = 2; or (b) For sufficiently large B, r = O(B · d log d), s = O(logB d). Notably, the distortion of our embeddings is never worse than the dense constructions in [28, 22]. Also, when p = 1, if we set r = O(d2) (Case 1(a)) or r = O(d1+η) for any constant η > 0 (Case 1(b)), then the distortion can be further improved to O(d). This is the first known ℓ1 oblivious subspace embedding with r = poly(d) rows and distortion κ = o(d log d). We remark that by using the dense construction in [28], it is also possible to reduce the distortion to O(d) by increasing the number of rows. Similar to the OSNAP embedding in [23], our results in Case 1(b) and Case 2(b) provide a tradeoff between the number of rows and the number of non-zero entries in each column. Sparser ℓp oblivious subspace embeddings. Finally, we show that the sparsity of Case 1(a) and Case 2(a) in Theorem 1.3 can be further reduced by using two different approaches. The first approach is based on random sampling, which leads to the following theorem. Theorem 1.4 (Summary of Theorem 6.1 and 6.2). For 1 ≤ p < 2 and any constant 0 < ε < 1, there exists an ℓp oblivious subspace embedding over O(d2) × n matrices Π where each column of Π has at most two non-zero entries and 1 + ε non-zero entries in expectation, and the distortion κ = O(d) (when p = 1) or κ = O(cid:0)(d log d)1/p(cid:1) (when 1 < p < 2). The second approach is based on the construction in [22] and a truncation argument, which leads to the following theorem. Theorem 1.5 (Summary of Theorem 6.5 and 6.6). For 1 ≤ p < 2, there exists an ℓp oblivious subspace embedding over eO(d4)× n matrices Π where each column of Π has a single non-zero entry and distortion κ = eO(d1/p). It has been shown in [24] that for any distribution over r × n matrices Π with s = 1 non- zero entries per column, if for any fixed matrix A ∈ Rn×d, rank(ΠA) = rank(A) with constant probability, then Π should have r = Ω(d2) rows. Since oblivious subspace embeddings with finite distortion always preserve the rank, this lower bound can also be applied. We show also that this lower bound holds even if the columns of Π have 1 + ε non-zero entries in expectation for a constant 0 < ε < 1, thereby showing Theorem 1.4 is optimal. We leave it as an open question to obtain ℓp oblivious subspace embedding with r = O(d2) rows, or prove a stronger lower bound. If one insists on having s = 1 non-zero entries per column, then s = 1 non-zero entries in every column (as opposed to 1 + ε in expectation), and κ = eO(cid:0)d1/p(cid:1), Theorem 1.5 can be applied, at the cost of increasing the number of rows to eO(d4). 4 1.2 Comparison with Previous Work In order to compare our results with previous work, it is crucial to realize the difference between oblivious embeddings and non-oblivious embeddings. An oblivious subspace embedding Π is a universal distribution over Rr×n, which does not depend the given matrix A ∈ Rn×d. A non- oblivious subspace embedding, however, is a distribution that possibly depends on the given matrix A. Most known non-oblivious subspace embeddings involve importance sampling according to the leverage scores or Lewis weights of the rows, and so are inherently non-oblivious. We refer the interested reader to [20] for an excellent survey on leverage scores and [19, 14, 15] for recent developments on non-oblivious subspace embeddings. Previous impossibility results for dimension reduction in ℓ1 [18, 7, 9] are established by creating a set of O(n) points in Rn and showing that any (non-oblivious) embedding on them incurs a large distortion. In this paper, we focus on embedding a d-dimensional subspace of Rn into Rpoly(d) using oblivious embeddings. We stress that O(n) points in a d-dimensional subspace have a very different structure from O(n) arbitrary points in Rn. Previous results [15] showed that any d-dimensional subspace in Rn can be embedded into RO(d(log d)ε−2) with (1 + ε) distortion in ℓ1 using non-oblivious linear embeddings, where ε > 0 is an arbitrarily small constant. Here the subspace structure is critically used, since Charikar and Sahai [9] showed that there exist O(n) points such that any linear embedding Rn → Rd must incur a distortion of Ω(pn/d), even for non-oblivious linear embeddings. Our hardness result in Theorem 1.1 establishes a separation between oblivious and non-oblivious subspace embeddings in ℓp when 1 ≤ p < 2. This result suggests that in order to construct a subspace embedding with (1+ε) distortion, it is essential to use non-oblivious subspace embeddings. Although our main focus in this paper is to understand oblivious subspace embeddings, we remark that our technique for proving the hardness result in Theorem 1.1 can also be applied to embed any d points in Rn into Rpoly(d) in ℓp using oblivious linear embeddings, when 1 ≤ p < 2. In particular, it is possible to reproduce the result of [9] using our techniques, although in a weaker setting where the embeddings are oblivious. 1.3 Applications of Our Subspace Embeddings Using the sparse ℓp oblivious subspace embeddings in Theorem 1.3, we obtain improvements to many related problems. We list a few examples in this section. ℓp-regression in the distributed model. The ℓp-regression problem in the distributed model is studied in [31], where there are k clients C1, . . . , Ck and one central server. Each client has a disjoint subset of the rows of a matrix [A, b], where A ∈ Rn×d and b ∈ Rn. There is a 2-way communication channel between the central server and the clients, and the goal of the server is to communicate with the k clients to solve the ℓp-regression problem argminx kAx − bkp. In [31], when 1 ≤ p < 2, the authors devised an algorithm with total communication cost where η > 0 is an arbitrarily small constant. Using our new oblivious subspace embedding in Theorem 1.3, the total communication cost can be further reduced to O(cid:0)kd2+η + d5 log2 d + d3+p log(1/ε)/ε2(cid:1) , O(cid:16)kd2 log d + (d log d)2−p/2d3 + d3+p log(1/ε)/ε2(cid:17) , 5 while the total running time of the whole system remains unchanged. This leads to a (d log d)p/2 improvement to the second term of the communication cost. ℓp-regression in the streaming model. Using dense Cauchy embeddings and a sampling data structure from [3], a single-pass streaming algorithm for ℓ1-regression argminx kAx − bk1 was de- signed in [28]. In order to get a (1+ε)-approximate solution to the regression problem, the algorithm uses poly(dε−1 log n) bits of space, where A ∈ Rn×d and b ∈ Rn. The total running time of the algorithm, however, is O(nnz(A) · d + poly(dε−1 log n)). By replacing the dense Cauchy embedding with our new oblivious subspace embeddings in Theorem 1.3, the total running time can be further improved to eO(nnz(A)) + poly(dε−1 log n) while the space complexity remains unchanged. We note that using earlier sparse Cauchy embeddings [22] would also give such a running time, but with a significantly worse poly(dε−1 log n) factor. The same approach can also be applied to design input-sparsity time algorithms for ℓp-regression in the streaming model when 1 < p < 2. kA − bAk1 ≤ α · Entrywise ℓp low rank approximation. Given a matrix A ∈ Rn×d and approximation factor α, the goal of the ℓ1-low rank approximation problem is to output a matrix bA for which rank-k matrices A′ kA − A′k1, min where k · k1 is the entrywise ℓ1-norm. In [29], the authors devised an algorithm that runs in T = O (nnz(A) + (n + d) · poly(k)) time to solve this problem, with α = poly(k) · log d. The exact expression of the poly(k) factor in the approximation factor α and the running time T , depends on the number of rows r and the distortion κ of the ℓ1 oblivious subspace embedding used. Both poly(k) factors can be directly improved by replacing the sparse Cauchy embedding [22], which is originally used in [29], with our new oblivious subspace embeddings in Theorem 1.3. This improvement also propagates to other problems considered in [29] such as ℓp-low rank approximation, entrywise ℓp-norm CUR decomposition and ℓp-low rank approximation in distributed and streaming models. Quantile Regression. Given a matrix A ∈ Rn×d and b ∈ Rn, the goal of quantile regression is to solve where ρτ (b − Ax) =Pn argminx ρτ (b − Ax), i=1 ρτ ((b − Ax)i) and for any z ∈ R, ρτ (z) =(τ z (τ − 1)z z ≥ 0 z < 0 . Here τ is a parameter in (0, 1). An efficient algortihm to calculate a (1 + ε)-approximate solution to quantile regression was proposed in [32]. Using their approach, one can reduce a quantile regression instance of size n × d to a smaller instance of size O(poly(d)ε−2 log(1/ε)) × d in O(nnz(A)) + poly(d) time. By replacing the sparse Cauchy embedding, which is used in the conditioning step of their algorithm, with our new oblivious subspace embeddings in Theorem 1.3, the poly(d) term in the running time can be directly improved. 6 1.4 Our Techniques Distortion lower bound. We use the case when p = 1 to illustrate our main idea for proving our distortion lower bounds. We start with Yao's minimax principle which enables us to deal only with deterministic embeddings. Here our goal is to construct a distribution over matrices A ∈ Rn×d such that for any Π ∈ Rr×n, if 1 κkAxk1 ≤ kΠAxk1 ≤ kAxk1 (1) holds simultaneously for all x ∈ Rd with constant probability, then κ =eΩ(d). Roughly speaking, our proof is based on the crucial observation that, the histogram of the ℓ1- norm of columns in the deterministic embedding Π should look like that of a discretized standard Cauchy distribution. I.e., there are at most 2i columns in Π with ℓ1-norm larger than Θ((n/d)2−i). This is because if we choose a matrix A ∈ Rn×d such that each column contains (n/d)2−i non-zero entries at random positions and all these (n/d)2−i non-zero entries are i.i.d. sampled from the standard Gaussian distribution N (0, 1), then for each column in A, the ℓ1-norm of that column is Θ((n/d)2−i) with constant probability. On the other hand, if the embedding Π contains more than 2i columns with ℓ1-norm larger than Θ((n/d)2−i), then with constant probability, there exists some i ∈ [n] and j ∈ [d] such that Ai,j ∼ N (0, 1) and the i-th column of Π has ℓ1-norm larger than Θ((n/d)2−i). In that case, it can be shown that after projection by Π, the j-th column of A has ℓ1-norm larger than Θ((n/d)2−i), which violates the condition in (1). N (0, 1). With constant probability kck1 = Ω(n). On the other hand, we are able to show that the In order to prove κ = eΩ(d), let c ∈ Rn be a vector whose entries are all i.i.d. sampled from constraint we put on the histogram of the ℓ1-norm of columns in Π implies that kΠck1 = eO(n/d) and hence κ = eΩ(d). A more refined analysis in Section 3.1 shows that κ = Ω(d log−2 r) when n ≫ r. In order to show that the dependence on r in the lower bound is necessary, we construct an ℓ1 oblivious subspace embedding with exp(exp(O(d))) rows and constant distortion. The construction itself is the same as the dense construction in [28]. Unlike previous approaches [28, 22, 31], we do not use the existence of an Auerbach basis to prove the dilation bound. Our analysis is based on tighter tail bounds for sums of absolute values of independent standard Cauchy (and also p-stable) random variables in Lemma 2.10 and 2.12. Let {Xi} be R = exp(exp(O(d))) independent standard Cauchy random variables. Based on the tighter tail bounds, it can be shown that with probability 1 − exp(−Ω(d)), RXi=1 Xi = Θ(R log R), which enables us to now apply a standard net argument to prove the constant distortion bound. The formal analysis is given in Section 3.2. New ℓp oblivious subspace embeddings. For ease of notation, here we focus on p = 1. Before getting into our results, we first review the construction in [22] and its analysis. The sparse Cauchy embedding in [22] has eO(d5) rows. In each column, there is a single non-zero entry which is sampled from the standard Cauchy distribution. The eO(d) dilation bound follows the standard approach [28] of using the existence of an Auerbach basis and upper tail bounds for dependent standard Cauchy random variables. The contraction bound is based on the technique 7 of splitting coordinates, which was first proposed in [12] to analyze the CountSketch embedding. A coordinate is heavy if its ℓ1 leverage score is larger than 1/d and light otherwise. For any vector y = Ax, if light coordinates contribute more to the ℓ1-norm of y, then standard concentration bounds and Cauchy lower tail bounds imply a constant distortion. If heavy coordinates contribute more to the ℓ1-norm, since there will be at most O(d2) heavy coordinates and the embedding has follows by setting up a global event saying that the absolute values of all of the O(d2) standard Ω(d4) rows, all the heavy coordinates will be perfectly hashed. An Ω(cid:0)d−2(cid:1) contraction bound Cauchy random variables associated with the heavy coordinates are at least Ω(cid:0)d−2(cid:1), which holds Although the dilation bound seems to be tight, the contraction bound can be improved. Indeed, the ℓ1-norm of columns in the embedding of [22] almost follows the histogram predicted by our lower bound argument, except for the lower tail part. As predicted by our lower bound argument, for an with constant probability. embedding Π which has the optimal κ = eO(d) distortion, the ℓ1-norm of each column in Π should be larger than a constant. On the other hand, the standard Cauchy distribution is heavy-tailed in both directions1. This leads to the idea of truncation, which is formalized in Section 6.2. The rough idea is that we make sure the absolute values of the standard Cauchy random variables are never smaller than a constant and thus the contraction bound can be improved to be a constant. It is shown in Corollary 6.4 that standard Cauchy random variables are still "approximately 1-stable" after truncation, which enables one to use Cauchy tail inequalities to analyze the dilation bound. However, even though the distortion bound of this new embedding is nearly optimal, the number of rows is eO(d4), which seems difficult to improve. Our alternate approach is still based on the technique of splitting coordinates. Unlike the approach in [22] which is based on splitting coordinates according to the ℓ1 leverage scores, in this new approach, for any vector y = Ax, a coordinate i is heavy if yi ≥ 1 d2kyk1 and light otherwise. When light coordinates contribute more to the ℓ1-norm of y, we show that the sparse Cauchy embedding in [22] with only O(d log d) rows is already sufficient to deal with such vectors. This is due to a tighter analysis based on negative association theory [17] which also greatly simplifies the proof. When heavy coordinates contribute more to the ℓ1-norm of y, the idea is to use known ℓ2 oblivious subspace embeddings. The key observation is that when heavy coordinates contribute more to the ℓ1-norm, we have kyk2 ≥ Ω(cid:0) 1 with constant distortion will also be an ℓ1 oblivious subspace embedding with O(d) distortion. See Section 4 for a formal analysis and Section 5 for how to generalize this idea to ℓp-norms when 1 < p < 2. d(cid:1)kyk1 and thus any ℓ2 oblivious subspace embedding Our final embedding consists of two parts. The ℓ2 oblivious subspace embedding part could be the CountSketch embedding or the OSNAP embedding, which also provides a tradeoff between the number of non-zero entries per column and number of rows. For the sparse Cauchy part, although it would be sufficient to prove the O(d log d) distortion bound as long as this part has O(d log d) rows, an analysis based on a tighter Cauchy lower tail bound in Lemma 2.12 shows that it is possible to further reduce the dilation to O(d) by increasing the number of rows in this part. Using this approach, the sparsest embedding we can construct has O(d2) rows and two non- zero entries per column. We further show how to construct even sparser embeddings using random sampling. Since we only use the sparse Cauchy part to deal with vectors in which light coordinates contribute most of the ℓ1-norm, even if we zero out each coordinate with probability 1 − ε for 1This is also observed in [31], but the authors use exponential random variables there to remedy this issue instead of the idea of truncation that we use here. 8 a small constant ε, the resulting vector will still have a sufficiently ℓ1-norm, with large enough probability. Thus, if we zero out each standard Cauchy random variable in the sparse Cauchy part with probability 1 − ε, the resulting embedding will still have the same distortion bound, up to a constant factor. By doing so, there will be 1 + ε non-zero entries in expectation in each column of the new embedding. This idea is formalized in Section 6.1. 2 Preliminaries We use k · kp to denote the ℓp-norm of a vector or the entry-wise ℓp-norm of a matrix. The following lemma is a direct application of Holder's inequality. Lemma 2.1. For any x ∈ Rn and 1 ≤ p ≤ q ≤ 2, we have kxkq ≤ kxkp ≤ n1/p−1/qkxkq. For u ∈ Rn and 1 ≤ a ≤ b ≤ n, let ua:b denote the vector with i-th coordinate equal to ui when i ∈ [a, b], and zero otherwise. For a matrix S ∈ Rn×m, we use Si,∗ to denote the i-th row of S, and S∗,j to denote the j-th column of S. Definition 2.1. For p ∈ [1, 2], a distribution over r × n matrices Π is an ℓp oblivious subspace embedding, if for any fixed A ∈ Rn×d, Pr Π hkAxkp ≤ kΠAxkp ≤ κkAxkp,∀x ∈ Rdi ≥ 0.99. Here κ is the distortion of Π. Throughout the paper, we use X ≃ Y to mean that X and Y have the same distribution. We use X (cid:23) Y to denote stochastic dominance, i.e., X (cid:23) Y iff for any t ∈ R, Pr[X ≥ t] ≥ Pr[Y ≥ t]. 2.1 Stable Distribution Definition 2.2 (p-stable distribution). A distribution D is p-stable if for any n real numbers a1, a2, . . . , an, we have aiXi ≃ nXi=1 nXi=1 aip!1/p X. Here Xi are i.i.d. drawn from D and X ∼ D. p-stable distributions exist for any 0 < p ≤ 2 (see, e.g., [26]). We let Dp denote the p-stable It is also well known that the standard Cauchy distribution is 1-stable and the distribution. standard Gaussian distribution N (0, 1) is 2-stable. We use the following lemma due to Nolan [26] Lemma 2.2 (Theorem 1.12 in [26]). For 1 ≤ p < 2, let Xp ∼ Dp. As t → ∞, where cp > 0 is a constant which depends only on p. Pr[Xp > t] ∼ cpt−p, 9 The following lemma is established in [22] by using Lemma 2.2 Lemma 2.3 (Lemma 8 in [22]). For 1 ≤ p < 2, let Xp ∼ Dp. There exists a constant αp such that αpC (cid:23) Xpp, where C is a standard Cauchy random variable and αp is a constant which depends only on p. 2.2 Tail Inequalities We use the following standard form of the Chernoff bound and Bernstein's inequality. Lemma 2.4 (Chernoff Bound). Suppose X1, X2, . . . , Xn are independent random variables taking values in [0, 1]. Let X =Pn For any δ > 0 we have i=1 Xi. Pr [X > (1 + δ) E[X]] ≤ exp(−δ2 E[X]/3), Pr [X < (1 − δ) E[X]] ≤ exp(−δ2 E[X]/2). For t > 2e E[X] we have Lemma 2.5 (Bernstein's inequality). Suppose X1, X2, . . . , Xn are independent random variables i=1 Var[Xi] be the variance of X. For taking values in [0, b]. Let X = Pn any t > 0 we have Pr[X > E[X] + t] ≤ exp(cid:18)− t2 2 Var[X] + 2bt/3(cid:19) . Pr [X > t] ≤ 2−t. i=1 Xi and Var[X] = Pn The following Bernstein-type lower tail inequality is due to Maurer [21]. Lemma 2.6 ([21]). Suppose X1, X2, . . . , Xn are independent positive random variables that satisfy E[X 2 i=1 Xi. For any t > 0 we have i ] < ∞. Let X =Pn Pr[X ≤ E[X] − t] ≤ exp(cid:18)− t2 i=1 E[X 2 i ](cid:19) . 2Pn We use the following tail inequality of a Gaussian random vector. Its proof can be found in Appendix A. Lemma 2.7. Let (a1, a2, . . . , an) be a fixed vector. For i ∈ [n], let {Xi} be n possibly dependent standard Gaussian random variables. For any 1 ≤ p ≤ 2, we have Pr nXi=1 aiXip!1/p p kakp, Cpkakp(cid:3) ≥ 0.99. ∈(cid:2)C −1 Here Cp > 1 is an absolute constant which depends only on p. The following upper tail inequality for dependent standard Cauchy random variables is estab- lished in [22]. 10 Lemma 2.8 (Lemma 3 in [10]). For i ∈ [n], let {Xi} be n possibly dependent standard Cauchy random variables and γi > 0 with γ =Pi∈[n] γi. For any t ≥ 1 and n ≥ 3, The following corollary is a direct implication of Lemma 2.8 and Lemma 2.3. Corollary 2.9. For i ∈ [n], let {Xi} be n possibly dependent p-stable random variables and γi > 0 PrXi∈[n] with γ =Pi∈[n] γi. For any t ≥ 1 and n ≥ 3, PrXi∈[n] where αp is the constant in Lemma 2.3. γiXi > γt ≤ 2 log(nt) . t γiXip > αpγt ≤ 2 log(nt) t , For the sum of absolute values of independent standard Cauchy random variables, it is possible to prove an upper tail inequality stronger than that in Lemma 2.8. The proof of the following lemma can be found in Appendix A. Lemma 2.10. For i ∈ [n], let {Xi} be n independent standard Cauchy random variables. There exists a constant U1, such that for any n ≥ 3, The following corollary is a direct implication of Lemma 2.10 and Lemma 2.3. Corollary 2.11. Suppose 1 ≤ p < 2. For i ∈ [n], let {Xi} be n independent p-stable random variables. There exists a constant Up which depends only on p, such that for any n ≥ 3, Pr" nXi=1 Xi ≤ U1n log n# ≥ 1 − log log n log n . Pr" nXi=1 Xip ≤ Upn log n# ≥ 1 − log log n log n . We use the following lower tail inequality for the sum of absolute values of independent standard Cauchy random variables, whose proof can be found in Appendix A. Lemma 2.12. Suppose 1 ≤ p < 2. For i ∈ [n], let {Xi} be n independent p-stable random variables. There exists a constant Lp which depends only on p, such that for sufficiently large n and T , Pr" nXi=1 Xip ≥ Lpn log(cid:18) n log T(cid:19)# ≥ 1 − 1 T . 2.3 ε-nets We use the standard ε-net construction of a subspace in [5]. Definition 2.3. For any 1 ≤ p ≤ 2, for a given A ∈ Rn×d, let B = {Ax x ∈ Rd,kAxkp = 1}. We say N ⊆ B is an ε-net of B if for any y ∈ B, there exists a y ∈ N such that ky − ykp ≤ ε. Lemma 2.13 ([5]). For a given A ∈ Rn×d, there exists an ε-net N ⊆ B = {Ax x ∈ Rd,kAxkp = 1} with size N ≤ (3/ε)d. 11 2.4 Known ℓ2 Oblivious Subspace Embeddings In [12, 22, 23, 6, 13], a series of results on sparse ℓ2 oblivious subspace embedding are obtained. Lemma 2.14 (CountSketch [12, 22, 23]). There exists an ℓ2 oblivious subspace embedding over O(d2) × n matrices Π, where each column of Π has a single non-zero entry and the distortion κ = 2. Lemma 2.15 (OSNAP [23, 13]). For any B > 2, there exists an ℓ2 oblivious subspace embedding over O (B · d log d)× n matrices Π, where each column of Π has at most O (logB d) non-zero entries and the distortion κ = 2. For completeness we include the construction for CountSketch and OSNAP here. In the CountS- ketch embedding, each column is chosen to have s = 1 non-zero entries chosen in a uniformly random location and the non-zero value is uniformly chosen in {−1, 1}. In the OSNAP embedding, each column is chosen to have s = O(logB d) non-zero entries in random locations, each equal to ±s−1/2 uniformly at random. All other entries in both embeddings are set to zero. We need a few additional properties of the CountSketch embedding and the OSNAP embedding. The following lemma is a direct calculation of the operator ℓ1-norm of the matrices stated above. Lemma 2.16. For any y ∈ Rn, • kΠyk1 ≤ kyk1 if Π is sampled from the CountSketch embedding; • kΠyk1 ≤ O(log1/2 The following lemma deals with the ℓp-norm of a vector and its ℓp-norm after projection using B d)kyk1 if Π is sampled from the OSNAP embedding. CountSketch or OSNAP. Its proof can be found in Appendix A. Lemma 2.17. For any y ∈ Rn and sufficiently large ω, with probability 1 − exp(Ω(ωd log d)), • kΠ (y1:d2)kp ≤ (ωd log d)1−1/pkykp if Π is sampled from the CountSketch embedding; • kΠ (y1:d2)kp ≤ (O(logB d))1/p−1/2(ωd log d)1−1/pkykp if Π is sampled from the OSNAP embed- ding. 2.5 Well-conditioned Bases We recall the definition and some existential results on well-coditioned matrices with respect to ℓp-norms. Definition 2.4 ((α, β, p)-well-conditioning [16]). For a given matrix U ∈ Rn×d and p ∈ [1, 2], let q be the dual norm of p, i.e., 1/p + 1/q = 1. We say U is (α, β, p)-well-conditioned if (i) kUkp ≤ α and (ii) kxkq ≤ βkU xkp for any x ∈ Rd. Lemma 2.18 (Auerbach basis [4]). For any matrix A, there exists a basis matrix U of A such that U is (d1/p, 1, p)-well-conditioned. 12 3 Hardness Result 3.1 The Lower Bound The goal of this section is to prove Theorem 1.1. We restate it here for convenience. Theorem 1.1. (restated) For 1 ≤ p < 2, if a distribution over r × n matrices Π is an ℓp oblivious subspace embedding, then the distortion By Yao's minimax principle [33], it suffices to show that there exists a hard distribution A over Rn×d such that for any Π ∈ Rr×n, if (2) then 1 κ = Ω (cid:0) 1 d(cid:1)1/p · log2/p r +(cid:0) r n(cid:1)1/p−1/2! . A∼AhkAxkp ≤ kΠAxkp ≤ κkAxkp,∀x ∈ Rdi ≥ 0.99, n(cid:1)1/p−1/2! . d(cid:1)1/p · log2/p r +(cid:0) r (cid:0) 1 κ = Ω Pr 1 The columns in our construction of A consist of three parts: • The first column is a vector where all the n entries are i.i.d. variables. We call this column the D-column. standard Gaussian random • For the next d/4 columns, each column has 4n/d non-zero entries, where all these non-zero standard Gaussian random variables. The indices of the 4n/d non-zero entries are i.i.d. entries of the i-th column are (4n/d) · (i − 1) + 1, (4n/d) · (i − 1) + 2, . . . , (4n/d) · i. We call each such column an M-column. • We divide the next d/2 columns into log(n/d) blocks, where each block contains columns. For 0 ≤ i < log(n/d), columns in the i-th block contain 2i+1 non-zero entries and all of these non-zero entries are i.i.d. standard Gaussian random variables. For two different columns in the same block, the sets of indices of non-zero entries are disjoint. For the d d 2 log(n/d) columns in the i-th block, the indices of the sampled from {1, 2, . . . , n} without replacement. We call each such column an S-column. 2 log(n/d) · 2i+1 = d 2 log(n/d) log(n/d) 2i non-zero entries are d All entries in other columns are zero. This finishes our construction of A. The following lemma is a direct implication of Lemma 2.7 and our construction. Lemma 3.1. For each column c in A, with probability at least 0.99, the following holds: 1. If c is an S-column in the i-th block, then kckp ≤ Cp2(i+1)/p. 2. If c is an M-column, then kckp ≤ Cp(4n/d)1/p. 3. If c is a D-column, then kckp ≥ C −1 p n1/p. Here Cp is the constant in Lemma 2.7. 13 p κ(4n/d)1/p, where Cp is the constant in Lemma 2.7. Lemma 3.2. For any matrix Π ∈ Rr×n which satisfies the condition in (2), the ℓp-norm of each column of Π is at most C 2 Proof. Suppose for contradiction that there exists an i ∈ [n] for which the i-th column of Π has ℓp-norm larger than C 2 p κ(4n/d)1/p. Consider the vector Mj, which is the j-th M-column, whose i-th entry is a standard Gaussian random variable, i.e., (4n/d) · (j − 1) + 1 ≤ i ≤ (4n/d) · j. We first show that with probability at least 0.99, kΠMjkp > Cpκ(4n/d)1/p. According to the 2-stability of the standard Gaussian distribution, for any k ∈ [r], Since 1/2 N (0, 1). Π2 k,l 1/2 (ΠMj)k ∼  (4n/d)·jXl=(4n/d)·(j−1)+1 k,l (4n/d)·jXl=(4n/d)·(j−1)+1 Π2 ≥ Πk,i, according to Lemma 2.7, with probability at least 0.99, According to Lemma 3.1, with probability at least 0.99, kΠMjkp ≥ C −1 p kΠ∗,ikp > Cpκ(4n/d)1/p. kMjkp ≤ Cp(4n/d)1/p, which implies the condition in (2) is violated. Lemma 3.3. For any matrix Π ∈ Rr×n which satisfies the condition in (2), for any 0 ≤ i < log(n/d), the number of columns in Π with ℓp-norm larger than C 2 2−i, where Cp is the constant in Lemma 2.7. Proof. Suppose for contradiction that for some 0 ≤ i < log(n/d), the number of columns in Π with 2−i. Let Π1, Π2, . . . , Πd log−1(n/d)/2 be the ℓp-norm larger than C 2 p κ2(i+1)/p is at most n log(n/d) p κ2(i+1)/p is larger than n log(n/d) d log−1(n/d)/2 S-column in the i-th block. With probability at least 1−(cid:16)1 − log(n/d) 2−i(cid:17) ≥ d 1 − 1/e, there exists a j ∈ [d log−1(n/d)/2] and l ∈ [n] such that (i) kΠ∗,lkp ≥ C 2 p κ2(i+1)/p and (ii) Πj is a standard Gaussian random variable. According to Lemma 3.1, with probability at least l 0.99, kΠjkp ≤ Cp2(i+1)/p. Now we show that with probability at least 0.99, kΠΠjkp ≥ C −1 p kΠ∗,lkp > Cpκ2(i+1)/p. Suppose P ⊆ [n] is the set of indices at which Πj contains a standard Gaussian random variable. We know that l ∈ P . Thus, due to the 2-stability of the standard Gaussian distribution, for any k ∈ [r], log(n/d) 2i d d d Since k,m!1/2 according to Lemma 2.7, with probability at least 0.99, kΠΠjkp ≥ C −1 κkΠjkp, which implies the condition in (2) is violated. ≥ Πk,l, p kΠ∗,lkp > Cpκ2(i+1)/p ≥ k,m!1/2 Π2 N (0, 1). (ΠΠj)k ∼ Xm∈P Xm∈P Π2 14 Lemma 3.4. For any matrix Π ∈ Rr×n which satisfies the condition in (2), we have rXi=1 2!1/p kΠi,∗kp = O(cid:16)κ(n/d)1/p log2/p(n/d) + κr 1 p − 1 2√n(cid:17) . Proof. We partition the columns of Π into two parts. We let ΠL be the submatrix of Π formed by p κ and ΠH be the submatrix formed by columns with ℓp-norm columns with ℓp-norm at most 21/pC 2 larger than 21/pC 2 p κ. For ΠH, by Lemma 3.2 and Lemma 3.3 we have kΠH kΠH rXi=1 2!1/p i,∗kp p!1/p ≤ rXi=1 i,∗kp ≤ log(n/d)−1Xi=0 p κ)p · 2i+2 · =O(cid:16)κ(n/d)1/p log2/p(n/d)(cid:17) . (C 2 = kΠHkp = Xi kΠH n log(n/d) 2id + (C 2 p!1/p ∗,ikp p κ)p · (4n/d) · 2 log(n/d) 1/p For ΠL, since all the columns have ℓp-norm at most 21/pC 2 p κ, we have 1 p − 1 kΠL rXi=1 2 rXi=1 2 Xi 2!1/p i,∗kp 2!1/2 i,∗k2 kΠL p!1/2 ∗,ik2 kΠL 1 p − 1 ≤r ≤r 1 p − 1 2 Xi 2!1/2 ∗,ik2 kΠL 1 p − 1 = r 2kΠLk2 = r 2√n(cid:17) , p − 1 1 = O(cid:16)κr where the first inequality follows from Lemma 2.1 and the last equality follows from the fact that ΠL has at most n columns. Notice that for any 1 ≤ i ≤ r, kΠi,∗k2 ≤ kΠH i,∗k2, which implies rXi=1 2!1/p kΠi,∗kp ≤ rXi=1 2!1/p i,∗kp kΠH + rXi=1 = O(cid:16)κ(n/d)1/p log2/p(n/d) + κr 1 p − 1 2√n(cid:17) . i,∗k2 + kΠL 2!1/p i,∗kp kΠL Now consider the vector D, which is the D-column in A. According to Lemma 3.1, with proba- bility at least 0.99, kDkp = Ω(n1/p). Due to the 2-stability of the standard Gaussian distribution, (ΠD)i ∼ kΠi,∗k2N (0, 1). 15 According to Lemma 2.7, with probability at least 0.99, According to the condition in (2), we have which implies 1 p − 1 2√n(cid:17) . 2√n(cid:17) . 1 p − 1 kΠi,∗kp 2!1/p kΠDkp = O rXi=1 = O(cid:16)κ(n/d)1/p log2/p(n/d) + κr Ω(n1/p) = kDkp ≤ kΠDkp = O(cid:16)κ(n/d)1/p log2/p(n/d) + κr n(cid:1)1/p−1/2! . n(cid:1)1/p−1/2! . d(cid:1)1/p · log2/p(n/d) +(cid:0) r (cid:0) 1 κ = Ω d(cid:1)1/p · log2/p r +(cid:0) r (cid:0) 1 κ = Ω 1 1 Now we show that the lower bound can be further improved to (3) We first note that r should be at least d, otherwise if we take a full-rank matrix A ∈ Rn×d, rank(ΠA) < d = rank(A), which means we can find a non-zero vector y = Ax in the column space of A and Πy = 0, which implies the distortion κ is not finite. When n ≤ rd2/(2−p), log2/p(n/d) = O(log2/p r), which means the lower bound in (3) holds. When n > rd2/(2−p), we repeat the argument above but only consider the first rd2/(2−p) columns of Π. By doing so we get a lower bound of κ = Ω 1 d(cid:1)1/p · log2/p(rd2/(2−p)−1) +(cid:16) (cid:0) 1 d2/(2−p)(cid:17)1/p−1/2 = Ω(d1/p/ log2/p(r)), 1 which is always stronger than the lower bound of κ = Ω 1 d(cid:1)1/p · log2/p r +(cid:0) r (cid:0) 1 n(cid:1)1/p−1/2! . 3.2 Necessity of Dependence on r The goal of this section is to prove Theorem 3.5. Theorem 3.5. Let r = exp(cid:18)4 · 104 ·(cid:16)24(cid:0)UpL−1 p (cid:1)1/p(cid:17)2d(cid:19), where Up and Lp are the constants in Corollary 2.11 and Lemma 2.12, respectively. For 1 ≤ p < 2, there exists an ℓp oblivious subspace embedding over r × n matrices Π, where the distortion κ is a constant which depends only on p. Our construction for the embedding in Theorem 3.5 is actually the same as the dense p-stable embedding in [28] (for p = 1) and Theorem 6 in [22] (for 1 < p < 2), whose entries are i.i.d. sampled from the scaled p-stable distribution (r log r)−1/pDp. 16 For any given matrix A ∈ Rn×d and any x ∈ Rd, we show that Pr Π h(Lp/2)1/p kAxkp ≤ kΠAxkp ≤ U 1/p p kAxkpi ≥ 1 − 10−2(cid:16)24(cid:0)UpL−1 p (cid:1)1/p(cid:17)−d . According to the definition of the p-stable distribution in Definition 2.2, for any i ∈ [r], (ΠAx)i ∼ (r log r)−1/p kAxkpDp. Since the entries in Π are independent, the entries in the vector ΠAx are also independent. Thus according to Corollary 2.11, with probability at least 1 − log log r we have log r ≥ 1 − 200−1(cid:16)24(cid:0)UpL−1 p (cid:1)1/p(cid:17)−d , kΠAxkp p ≤ Up(r log r)−1kAxkp p · r log r = UpkAxkp p, which implies kΠAxkp ≤ U 1/p p kAxkp. On the other hand, according to Lemma 2.12, by setting T = 200(cid:16)24(cid:0)UpL−1 bility at least 1 − 1/T = 1 − 200−1(cid:16)24(cid:0)UpL−1 p (cid:1)1/p(cid:17)−d , we have p (cid:1)1/p(cid:17)d p · r log r log T ≥ Lp/2kAxkp p, , with proba- which implies kΠAxkp p ≥ Lp(r log r)−1kAxkp kΠAxkp ≥(cid:16)L1/p It follows by a union bound that for any x ∈ Rd, Π h(Lp/2)1/p kAxkp ≤ kΠAxkp ≤ U 1/p Pr kAxkp. p /2(cid:17)1/p p kAxkpi ≥ 1 − 10−2(cid:16)24(cid:0)UpL−1 p (cid:1)1/p(cid:17)−d . We build an ε-net N ⊆ B = {Ax x ∈ Rd,kAxkp = 1} by setting 1/ε = 8(cid:0)UpL−1 According to Lemma 2.13, N ≤ (3/ε)d = (cid:16)24(cid:0)UpL−1 probability at least 0.99, we have for any y ∈ N , p (cid:1)1/p(cid:17)d . Again by a union bound, with p (cid:1)1/p. (Lp/2)1/p kykp ≤ kΠykp ≤ U 1/p p kykp. Condition on the event stated above. Now we show that for any x ∈ Rd, p kAxkp. (Lp/4)1/p kAxkp ≤ kΠAxkp ≤ 2U 1/p For any x ∈ Rd, let y = Ax. By homogeneity we can assume kykp = 1. We claim y can be written as where for any i ≥ 0 we have (i) y = y0 + y1 + y2 + . . . , kyikp ∈ N and (ii) kyikp ≤ εi. yi According to the definition of an ε-net, there exists a vector y0 ∈ N for which ky − y0kp ≤ ε . Again we can and ky0kp = 1. If y = y0 then we stop. Otherwise we consider the vector ky−y0kp y−y0 17 and continue this process inductively. find a vector y1 ∈ N such that(cid:13)(cid:13)(cid:13) y−y0 kΠykp ≥ kΠy0k −Xi>0 It follows that ky−y0kp − y1(cid:13)(cid:13)(cid:13)p ≤ ε and ky1kp = 1. Here we set y1 = ky − y0kp · y1 kΠyik ≥ (Lp/2)1/p −Xi>0 kΠyik ≤Xi≥0 kΠykp ≤Xi≥0 p εi ≥ (Lp/2)1/p − 2U 1/p U 1/p ε ≥ (Lp/4)1/p p . and p εi ≤ 2U 1/p U 1/p Thus, Π is a valid ℓp oblivious subspace embedding with κ ≤ 2(cid:0)4UpL−1 that depends only on p. p p (cid:1)1/p, which is a constant 4 New Subspace Embeddings for ℓ1 In this section, we present new sparse ℓ1 oblivious subspace embeddings with nearly-optimal distortion. Theorem 4.1. For any given A ∈ Rn×d, let U be a (d, 1, 1)-well-conditioned basis of A. There exists an ℓ1 oblivious subspace embedding over O(d2) × n matrices Π where each column of Π has two non-zero entries and with probability 0.99, for any x ∈ Rd, Ω(log d)kU xk1 ≤ kΠU xk1 ≤ O(d log d)kU xk1. Theorem 4.2. For any given A ∈ Rn×d and sufficiently large B, let U be a (d, 1, 1)-well-conditioned basis of A. There exists an ℓ1 oblivious subspace embedding over O(B· d log d)× n matrices Π where each column of Π has O(logB d) non-zero entries and with probability 0.99, for any x ∈ Rd, Ω(log B)kU xk1 ≤ kΠU xk1 ≤ O(d log d)kU xk1. Our embedding for Theorem 4.1 and Theorem 4.2 can be written as Π = (Π1, Π2)T . For Theorem 4.1, Π1 is sampled from the CountSketch embedding in Lemma 2.14, scaled by a d log d factor. For Theorem 4.2, Π1 is sampled from the OSNAP embedding in Lemma 2.15 with O(B · d log d) rows, O(logB d) non-zero entries per column, and scaled by a d log B factor. Suppose Π1 has R1 rows. Let R2 = min{R1, d1.1}. Π2 can be written as ΦD : Rn → RR2 as follows: • h : [n] → [R2] is a random map so that for each i ∈ [n] and t ∈ [R2], h(i) = t with probability 1/R2. • Φ is an R2 × n binary matrix with Φh(i),i = 1 and all remaining entries 0. • D is an n × n random diagonal matrix where the diagonal entries are i.i.d. sampled from the standard Cauchy distribution. It is immediate to see that the number of rows in Π2 is at most that in Π1. Furthermore, Π2 has a single non-zero entry per column. In the remainder of this section, we prove the dilation bound in Section 4.1, and the contraction In the analysis we will define three events E1, E2 and E3, which we will bound in Section 4.2. condition on later in the analysis. We will prove that each of these events holds with probability at least 0.999. By a union bound, all of these events hold with probability at least 0.997. Thus, these conditions will not affect our overall failure probability by more than 0.003. 18 4.1 No Overestimation Let E1 be the event that kΠ2Uk ≤ O (d log d). We first prove that E1 holds with probability at least 0.999. Lemma 4.3. E1 holds with probability at least 0.999. Proof. R2Xi=1 dXj=1 kΠ2Uk1 = Uk,j(cid:12)(cid:12)(cid:12) Xi,j(cid:12)(cid:12)(cid:12) . Heren Xi,jo are dependent standard Cauchy random variables. Since U is a (d, 1, 1)-well-conditioned  Xkh(k)=i (Π2U )i,j = basis of A, we have R2Xi=1 dXj=1 (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) dXj=1 Xkh(k)=i  Xkh(k)=i dXj=1 ≃ Dk,kUk,j(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) R2Xi=1 Uk,j ≤ d. By Lemma 2.8 we have R2Xi=1 Taking t = ω log d where ω is a sufficiently large constant, we have Pr [kΠ2Uk1 > td] ≤ 2 log(R2td) t . Pr [kΠ2Uk1 ≤ td] ≥ 0.999. Lemma 4.4. Conditioned on E1, for any x ∈ Rd, we have kΠ2U xk1 ≤ O(d log d)kU xk1. Proof. kΠ2U xk1 ≤ kΠ2Uk1kxk∞ ≤ kΠ2Uk1kU xk1 ≤ O(d log d)kU xk1. The first inequality follows from Holder's inequality, and the second inequality follows from the definition of a (d, 1, 1)-well-conditioned basis. Since Π1 is the CountSketch embedding scaled by a d log d factor, or the OSNAP embedding scaled by a d log B factor, the following lemma is a direct implication of Lemma 2.16. Lemma 4.5. For any x ∈ Rd, we have Combining Lemma 4.4 and Lemma 4.5, we can bound the overall dilation of our embedding. kΠ1U xk1 ≤ O(d log d)kU xk1. Lemma 4.6. Conditioned on E1, for any x ∈ Rd, we have kΠU xk1 ≤ O(d log d)kU xk1. Proof. kΠU xk1 = kΠ1U xk1 + kΠ2U xk1 = O(d log d)kU xk1. 19 4.2 No Underestimation We let E2 be the event that for any x ∈ Rd, d log dkU xk2 ≤ kΠ1U xk2 ≤ 2d log d · kU xk2 (for Theorem 4.1) or d log BkU xk2 ≤ kΠ1U xk2 ≤ 2d log B · kU xk2 (for Theorem 4.2). Since Π1 is sampled from an ℓ2 oblivious subspace embedding with κ = 2 and scaled by a factor of d log d (for Theorem 4.1) or d log B (for Theorem 4.2), E2 holds with probability at least 0.999. Without loss of generality we assume x1 ≥ x2 ≥ x3 ≥ . . . ≥ xn. Of course, this order is unknown and is not used by our embedding. We first show that for any y = U x, if we can find a "heavy" part inside y, then the scaled ℓ2 oblivious subspace embedding Π1 also works well for ℓ1. Formally, we have the following lemma. Lemma 4.7. Conditioned on E2, for any x ∈ Rd, if k(U x)1:d2k1 2 ≥ 0.5kU xk1, then • kΠ1U xk1 ≥ Ω(log d)kU xk1 for Theorem 4.1; • kΠ1U xk1 ≥ Ω(log B)kU xk1 for Theorem 4.2. Proof. Notice that kU xk2 ≥ k(U x)1:d2k2 ≥ 1 dk(U x)1:d2k1 ≥ 1 2dkU xk1, where the second inequality follows from Lemma 2.1. Thus for Theorem 4.1, kΠ1U xk1 ≥ kΠ1U xk2 ≥ Ω(log d)kU xk1 since Π1 is sampled from an ℓ2 oblivious subspace embedding and scaled by a factor of d log d. For Theorem 4.2, kΠ1U xk1 ≥ kΠ1U xk2 ≥ Ω(log B)kU xk1 since Π1 is sampled from an ℓ2 oblivious subspace embedding and scaled by a factor of d log B. Now we analyze those vectors U x that do not contain a "heavy" part. We show that they can be handled by the Π2 part of our embedding. Lemma 4.8. For any x ∈ Rd, if k(U x)d2+1:nk1 ≥ 0.5kU xk1, then with probability at least 1 − exp(−32d log d), we have • kΠ2U xk1 ≥ Ω(log d)kU xk1 for Theorem 4.1; • kΠ2U xk1 ≥ Ω(log B)kU xk1 for Theorem 4.2. Proof. Let y = U x. By homogeneity we assume kyk1 = 1. According to the given condition we have kyd2+1:nk1 ≥ 0.5. Notice that kyd2+1:nk∞ ≤ 1/d2 since otherwise ky1:d2k1 > d2 · 1/d2 = 1. For i ∈ [R2], let Bi =Pd2<j≤n Bi,j where Bi,j =(yj if h(j) = i otherwise 0 . It follows thatPR2 i=1 Bi = kyd2+1:nk1 ≥ 0.5. 2Recall that for u ∈ Rn and 1 ≤ a ≤ b ≤ n, ua:b denotes the vector with i-th coordinate equal to ui when i ∈ [a, b], and zero otherwise. 20 Since kyd2+1:nk∞ ≤ 1/d2 and 1/2 ≤ kyd2+1:nk1 ≤ 1, for any i ∈ [R2] and j > d2 we have and Bi,j ≤ 1 d2 1 2R2 ≤ E[Bi] ≤ 1 R2 . Furthermore, by Holder's inequality we have Var[Bi] = nXj=1 Var[Bi,j] ≤ 1 R2 nXj=d2+1 y2 j ≤ 1 R2kyd2+1:nk∞ · kyd2+1:nk1 ≤ 1 R2d2 . Thus by Bernstein's inequality in Lemma 2.5, we have Pr[Bi ≥ 1/R2 + t] ≤ exp − t2 3d2! . 2 R2d2 + 2t (4) Let t = d0.2/R2. Since R2 ≤ d1.1, by (4) we have Pr[Bi > (d0.2 + 1)/R2] ≤ exp(cid:0)−3d2.2/4R2(cid:1) ≤ exp(cid:0)−3d1.1/4(cid:1) . By a union bound, with probability at least 1 − exp(cid:0)−3d1.1/4(cid:1) · R2 ≥ 1 − exp(−32d log d)/4, simultaneously for all i ∈ [R2] we have Bi ≤ (d0.2 + 1)/R2. Let t = 1/R2. Since R2 ≤ d1.1, by (4) we have Pr[Bi > 2/R2] ≤ exp(cid:0)−3d2/8R2(cid:1) ≤ exp(cid:0)−3d0.9/8(cid:1) . According to [17], Bi are negatively associated, which implies for any I ⊆ [R2] we have Pr[Bi ≥ ti, i ∈ I] ≤Yi∈I Pr[Bi ≥ ti]. Thus, the probability that the number of Bi which satisfy Bi > 2/R2 is larger than d0.2, is at most (cid:18) R2 d0.2(cid:19) exp(−3d0.9/8 · d0.2) < exp(−32d log d)/4. It follows that with probability at least 1 − exp(−32d log d)/2, for any i ∈ [R2] we have Bi ≤ (d0.2 + 1)/R2, and the number of Bi which satisfy Bi > 2/R2 is at most d0.2. In the rest of the proof we condition on this event. Since R2 ≥ d log d, Xi∈[R2]Bi≤2/R2 Bi ≥ 0.5 − d0.2 · (d0.2 + 1)/R2 ≥ 1/4. 21 Thus, the number of Bi which satisfy Bi ≥ 1 8R2 is at least R2/16, since otherwise Xi∈[R2]Bi≤2/R2 < R2/16 · 2/R2 + R2 · 1 8R2 = 1/4. Now consider Π2y. According to the 1-stability of the standard Cauchy distribution, (Π2y)i ≃ Xj∈[n]h(j)=i yj · Xi where {Xi} are independent standard Cauchy random variables. Notice that conditioned on the event stated above, the number of Bi which satisfy Bi ≥ 1 is at least R2/16. Furthermore, for any i ∈ [R2],Pj∈[n]h(j)=i yj ≥Pd2<j≤nh(j)=i yj = Bi. Thus, 8R2 R2Xi=1 (Π2y)i (cid:23) R2/16Xi=1 1 8R2X i, where(cid:8)X i(cid:9) are independent standard Cauchy random variables. According to Lemma 2.12, by setting T = 2 exp(32d log d), with probability at least 1− 1/T we have (Π2y)i ≥ L1 · R2/16 · log(R2/(16 log T )) · 1 8R2 = Ω(log(R2/ log T )). R2Xi=1 Thus, for Theorem 4.1, we have kΠ2yk1 ≥ Ω(log d) since R2 = d1.1 and log T = O(d log d). For Theorem 4.2, when R1 ≤ d1.1, we have kΠ2yk1 ≥ Ω(log B) since R2 = R1 = O(B · d log d) and log T = O(d log d). When R1 > d1.1, we have kΠ2yk1 ≥ Ω(log d) = Ω(log B) since R2 = d1.1 and log T = O(d log d). Set ε = 1/d2 and create an ε-net N ⊆ B = {U x x ∈ Rd and kU xk1 = 1}. According to Lemma 2.13, N ≤ (3d2)d. Let E3 be the event that for all y ∈ N , if kyd2+1:nk1 ≥ 0.5, then kΠ2yk1 ≥ Ω(log d)kyk1 (for Theorem 4.1) or kΠ2yk1 ≥ Ω(log B)kyk1 (for Theorem 4.2). Now we show that E3 holds with constant probability. Lemma 4.9. E3 holds with probability at least 0.999. Proof. According to Lemma 4.8, by using a union bound, we have Pr[E3 holds] ≥ 1 − N exp(−32d log d) > 0.999 We are now ready to prove the contraction bound. Lemma 4.10. Conditioned on E1, E2 and E3, for all x ∈ Rd, we have • kΠ2U xk1 ≥ Ω(log d)kU xk1 for Theorem 4.1; 22 • kΠ2U xk1 ≥ Ω(log B)kU xk1 for Theorem 4.2. Proof. By homogeneity we can assume kU xk1 = 1. According to Lemma 4.7, conditioned on E2 and E3, for all y ∈ N , we have kΠ2U xk1 ≥ Ω(log d)kU xk1 (for Theorem 4.1) or kΠ2U xk1 ≥ Ω(log B)kU xk1 (for Theorem 4.2). For any given y = U x where kyk1 = 1, there exists some y ∈ N for which ky − yk1 ≤ ε = 1/d2. Thus, conditioned on E1, notice that both y and y − y are in the column space of U , so according to Lemma 4.6, we have kΠyk1 ≥ kΠyk1 − kΠ(y − y)k1 ≥ Ω(log d) − 1/d2 · O(d log d) = Ω(log d) (for Theorem 4.1) or kΠyk1 ≥ kΠyk1 − kΠ(y − y)k1 ≥ Ω(log B) − 1/d2 · O(d log d) = Ω(log B) (for Theorem 4.2). 5 New Subspace Embeddings for ℓp In this section, we show how to generalize the constructions in Section 4 to ℓp-norms, for 1 < p < 2. Theorem 5.1. Suppose 1 ≤ p < 2. For any given A ∈ Rn×d, let U be a (d1/p, 1, p)-well-conditioned basis of A. There exists an ℓp oblivious subspace embedding over O(d2) × n matrices Π where each column of a matrix drawn from Π has two non-zero entries and with probability 0.99, for any x ∈ Rd, Ω(1)kU xkp ≤ kΠU xkp ≤ O(cid:16)(d log d)1/p(cid:17)kU xkp. Theorem 5.2. Suppose 1 ≤ p < 2. For any given A ∈ Rn×d and sufficiently large B, let U be a (d1/p, 1, p)-well-conditioned basis of A. There exists an ℓp oblivious subspace embedding over O(B · d log d)× n matrices Π where each column of a matrix drawn from Π has O(logB d) non-zero entries and with probability 0.99, for any x ∈ Rd, Ω(1)kU xkp ≤ kΠU xkp ≤ O(cid:16)(d log d)1/p(cid:17)kU xkp. Our embeddings for Theorem 5.1 and Theorem 5.2 can be written as Π = (Π1, Π2)T . Similar to the constructions in Section 4, for Theorem 5.1, Π1 is sampled from the CountSketch embedding in Lemma 2.14, scaled by a d2/p−1 factor. For Theorem 5.2, Π1 is sampled from the OSNAP embedding in Lemma 2.15 with O(B · d log d) rows and O(logB d) non-zero entries per column and also scaled by a d2/p−1 factor. The construction for Π2 is almost the same as that for Theorem 4.1 and 4.2, except for replacing the standard Cauchy random variables in the diagonal entries of D with p-stable random variables. Most parts of the proof for the distortion bound resemble that for Theorem 4.1 and 4.2. We will omit similar proofs. The following lemma can be proved in the same way as Lemma 4.3 and Lemma 4.4, except for replacing the upper tail inequality for standard Cauchy random variables in Lemma 2.8 with that for p-stable random variables in Corollary 2.9, and replacing the properties of a (d, 1, 1)-well- conditioned basis with those of a (d1/p, 1, p)-well-conditioned basis. 23 Lemma 5.3. Let E1 be the event that kΠ2Ukp ≤ O(cid:0)(d log d)1/p(cid:1). E1 holds with probability at least 0.999. Furthermore, conditioned on E1, for any x ∈ Rd, we have kΠ2U xkp ≤ O(cid:16)(d log d)1/p(cid:17)kU xkp. Let E2 be the event that for any x ∈ Rd, d2/p−1kU xk2 ≤ kΠ1U xk2 ≤ 2d2/p−1kU xk2. Without loss of generality we assume x1 ≥ x2 ≥ x3 ≥ . . . ≥ xn. Of course, this order is Since Π1 is sampled from an ℓ2 oblivious subspace embedding with κ = 2, and scaled by a factor of d2/p−1, E2 holds with probability at least 0.999. unknown and is not used by our embeddings. Lemma 5.4. Conditioned on E2, for any x ∈ Rd, we have kΠ1(U x)d2+1:nkp ≤ O(cid:16)(d log d)1/p(cid:17)kU xkp. Proof. By homogeneity we can assume kU xkp = 1. Notice that k(U x)d2+1:nk∞ ≤ d−2/p since otherwise kU xkp ≥ k(U x)1:d2kp > 1. By Holder's inequality, k(U x)d2+1:nk2 = nXi=d2+1 (U x)2 1/2 i ≤ nXi=d2+1 (U x)ip · max 1/2 d2+1≤i≤nU xi2−p ≤ d1−2/p. Thus, kΠ1(U x)d2+1:nkp ≤ R1/p−1/2 ≤O(d2/p−1) · 2d2/p−1k(U x)d2+1:nk2 = O(d2/p−1) = O(cid:16)(d log d)1/p(cid:17) . kΠ1(U x)d2+1:nk2 1 Here the first inequality follows from Lemma 2.1 and the fact that Π1U x has R1 rows, the second inequality holds since R1 ≤ O(d2) and E2 holds. Lemma 5.5. Conditioned on E2, for any x ∈ Rd, if k(U x)1:d2kp ≥ 0.5kU xkp, then kΠ1U xkp ≥ Ω(1)kU xkp. Proof. Notice that kU xk2 ≥ k(U x)1:d2k2 ≥ d1−2/pk(U x)1:d2kp ≥ d1−2/p/2kU xkp, where the second inequality follows from Lemma 2.1 and the third inequality follows from the condition that k(U x)1:d2kp ≥ 0.5kU xkp. Thus, kΠ1U xkp ≥ kΠ1U xk2 ≥ Ω(1)kU xkp since Π1 is sampled from an ℓ2 oblivious subspace embedding and scaled by a factor of d2/p−1. The proof of the following lemma is almost identical to that of Lemma 4.8. We omit the proof here. Lemma 5.6. For any x ∈ Rd, if k(U x)d2+1:nkp ≥ 0.5kU xkp, then with probability at least 1 − exp(−32d log d), we have kΠ2U xkp ≥ Ω(1)kU xkp. 24 Lemma 2.13, N ≤ (3d2)d. Set ε = 1/d2 and create an ε-net N ⊆ B = {U x x ∈ Rd and kU xkp = 1}. According to Let E3 be the event that for all y ∈ N , 1. if kyd2+1:nkp ≥ 0.5kykp, then kΠ2ykp ≥ Ω(1)kykp; 2. kΠ1 (y1:d2)kp ≤ O(cid:0)(d log d)1/p(cid:1)kykp. Lemma 5.7. E3 holds with probability at least 0.999. Proof. Notice that Π1 is sampled from the CountSketch embedding or the OSNAP embedding and scaled by a d2/p−1 factor. According to Lemma 2.17, by setting ω sufficiently large, with proba- bility 1 − exp(−32d log d) we have kΠ1 (y1:d2)kp ≤ d2/p−1 (O(logB d))1/p−1/2 (ωd log d)1−1/pkykp = O(cid:0)(d log d)1/p(cid:1)kykp. Combining this with Lemma 5.6 and a union bound, we have Pr[E3 holds] ≥ 1 − 2N exp(−32d log d) > 0.999 Lemma 5.8. Conditioned on E1, E2 and E3, for all x ∈ Rd, we have Ω(1)kU xkp ≤ kΠU xkp ≤ O(cid:16)(d log d)1/p(cid:17)kU xkp. Proof. For any x ∈ Rd, let y = U x. By homogeneity we can assume kykp = 1. As in the proof of Theorem 3.5, y can be written as y = y0 + y1 + y2 + . . . , where for any i ≥ 0 we have (i) kyikp ∈ N and (ii) kyikp ≤ εi. It follows by Lemma 5.3, Lemma 5.4 and Lemma 5.5 that yi kΠykp ≥ kΠy0kp −Xi>0 and kΠyikp ≥ Ω(1) −Xi>0 kΠyikp ≤Xi≥0 kΠykp ≤Xi≥0 O(cid:16)(d log d)1/p(cid:17) εi ≥ Ω(1) − O(cid:16)(d log d)1/p(cid:17) 2ε ≥ Ω(1) O(cid:16)(d log d)1/p(cid:17) εi ≤ O(cid:16)(d log d)1/p(cid:17) . 6 Subspace Embeddings with Improved Sparsity In this section, we present two approaches to constructing sparser ℓp oblivious subspace embed- dings for 1 ≤ p < 2. In Section 6.1 we present our first approach based on random sampling, which yields an ℓp oblivious subspace embedding where each column of the embedding has at most two non-zero entries and 1 + ε non-zero entries in expectation, where the number of rows r = O(d2). In Section 6.2, we present another approach based on the construction in [22] and a truncation argument, which yields an ℓp oblivious subspace embedding where each column of the embedding has a single non-zero entry, at the cost of increasing the number of rows r to eO(d4). 25 6.1 Improved Sparsity Based on Random Sampling In this section, we show how to further improve the sparsity in the constructions of Theorem 4.1 and Theorem 5.1. Theorem 6.1. For any given A ∈ Rn×d, let U be a (d, 1, 1)-well-conditioned basis of A. For any constant 0 < ε < 1, there exists an ℓ1 oblivious subspace embedding over O(d2) × n matrices Π where each column of Π has at most two non-zero entries and 1 + ε non-zero entries in expectation, such that with probability 0.99, for any x ∈ Rd, Ω(log d)kU xk1 ≤ kΠU xk1 ≤ O(d log d)kU xk1. Our embedding for Theorem 6.1 is almost identical to that for Theorem 4.1 except for the Π2 part. Recall that the Π2 part of the construction for Theorem 4.1 can be written as ΦD, where Φh(i),i = 1 and all remaining entries are 0. In the new construction for Π2, Φh(i),i are i.i.d. samples from the Bernoulli distribution Ber(ε). I.e., Φh(i),i = 1 with probability ε and 0 otherwise. All other parts of the construction are the same as in Theorem 4.1. We note that the proof for Theorem 4.1 can still go through for the new construction. The only difference occurs when proving Lemma 4.8. In fact, the Π2 part of the new construction for Theorem 6.1 can be viewed as the following equivalent two-step procedure. For any given vector y = U x, we first zero out each coordinate of y with probability 1− ε, which results in a new vector y, and then apply the Π2 part of the embedding in Theorem 4.1 on the new vector y. Now we show that with probability at least 1 − exp(cid:0)−Ω(d2ε)(cid:1), we have Notice that E[yi] = εyi and E[y2 kyd2+1:nk1 ≥ Ω(ǫ)kyd2+1:nk1. i ] = εy2 i , which implies and Xi>d2 E[y2 i ] = Xi>d2 E[kyd2+1:nk1] = ε · kyd2+1:nk1 εy2 i ≤ εkyd2+1:nk1 · kyd2+1:nk∞ = εd−2kyd2+1:nk2 1. Thus, by Maurer's inequality in Lemma 2.6, with probability at least 1 − exp(cid:0)−Ω(d2ε)(cid:1), we have kyd2+1:nk1 ≥ Ω(ǫ)kyd2+1:nk1. The rest of the proof is identical to the original proof for Lemma 4.8. Similarly, the same argument can also be applied to Theorem 5.1. Theorem 6.2. Suppose 1 ≤ p < 2. For any given A ∈ Rn×d, let U be a (d1/p, 1, p)-well-conditioned basis for A. For any constant 0 < ε < 1, there exists an ℓp oblivious subspace embedding over O(d2)× n matrices Π where each column of Π has at most two non-zero entries and 1 + ε non-zero entries in expectation, such that with probability 0.99, for any x ∈ Rd, Ω(1)kU xkp ≤ kΠU xkp ≤ O(cid:16)(d log d)1/p(cid:17)kU xkp. 26 The number of rows in Theorem 6.1 and Theorem 6.2 cannot be further reduced. It is shown in [24] (Theorem 16) that for any distribution over r × n matrices Π such that any matrix in its support has at most one non-zero entry per column, if rank(ΠA) = rank(A) holds with constant probability, then r = Ω(d2). Now we sketch how to generalize this lower bound to distributions over r × n matrices for which each column has at most 1 + ε non-zero entries in expectation, for any constant 0 < ε < 1. Notice that such a lower bound already implies the number of rows of Theorem 6.1 and Theorem 6.2 are optimal up to constant factors, since any oblivious subspace embedding preserves the rank with constant probability. For each column in the matrix Π, by Markov's inequality, with probability at least 1 − 1+ε 2 , there will be at most one non-zero entry in that column. By the Chernoff bound in Lemma 2.4, with probability 1 − exp(−Ω(n)), the number of columns in Π with at most one non-zero entry is Ω(n). Furthermore, the balls and bins analysis in the proof of Theorem 16 in [24] can be applied to distributions over r × n matrices such that for any matrix in the support of the distribution, the number of columns with at most one non-zero entry is Ω(n). Indeed, with constant probability the rank will drop if the embedding matrix has o(d2) rows. This establishes the desired lower bound of r = Ω(d2). 6.2 Improving Sparsity Based on Truncation In this section, we show how to use a truncation argument to improve the construction in [22]. Before formally stating the construction, we first define the truncation operation. For a given parameter α > 0, for any x ∈ R, define truncα(x) = if x ∈ [0, α] α −α if x ∈ [−α, 0) x otherwise . Here we note some elementary properties of the truncation operation. Lemma 6.3. For a given parameter α > 0, for any x ∈ R, we have • truncα(x) ≥ α. • truncα(x) − α ≤ x ≤ truncα(x) + α. When applying the truncation operation to standard Cauchy random variables, the following properties are direct implications of Lemma 6.3 and the 1-stability of standard Cauchy random variables. Corollary 6.4. For i ∈ [n], let {Xi} be n independent standard Cauchy random variables. The following holds. • truncα(Xi) ≥ α. • For any a = (a1, a2, . . . , an) ∈ Rn, kak1 · X − kak1 · α (cid:22) nXi=1 ai · truncα(Xi) (cid:22) kak1 · X + kak1 · α, where X is a standard Cauchy random variable. 27 Now we are ready to state the main result of this section. Our embedding for Theorem 6.5 is almost identical to the embedding for Theorem 2 in [22] and the Π2 part of the embedding for Theorem 4.1 and Theorem 4.2, except for replacing standard Theorem 6.5. There exists an ℓ1 oblivious subspace embedding over eO(d4) × n matrices Π where each column of Π has a single non-zero entry. The distortion κ = eO(d). Cauchy random variables with truncated standard Cauchy random variables. Let R = eO(d4) be the number of rows of Π. Here Π can be written as ΦD : Rn → RR, defined as follows: • h : [n] → [R] is a random map so that for each i ∈ [n] and t ∈ [R], h(i) = t with probability 1/R. • Φ is an R × n binary matrix with Φh(i),i = 1 and all remaining entries 0. • D is an n× n random diagonal matrix where Di,i = truncα(Xi). Here {Xi} are i.i.d. samples from the standard Cauchy distribution and α < 1/4 is a positive constant. Now we sketch how to modify the proof of Theorem 2 in [22] to prove the the distortion bound of our new embedding. In the proof of Theorem 2 in [22], the authors define five events: EU , EL, EH, EC and E L. Notice that for our new embedding, the event EC is no longer needed, since by Corollary 6.4, the absolute values of standard Cauchy random variables are never smaller than α after truncation, where α is a small constant. We also change the number of rows of Π to O(d4 log5 d), and the definition of the event E L is changed to kΠU Lk1 ≤ O(1/d log2 d) correspondingly. Lemma 16 and Lemma 22 in the proof for Theorem 2 in [22] show that EU and E L hold with constant probability. The proofs for these two lemmas almost remain unchanged, except for re- placing the 1-stability of standard Cauchy random variables with the upper bound part of the "approximate 1-stability" of truncated standard Cauchy random variables in Corollary 6.4. Lemma 13 is changed to the following: Given EL, for any fixed y ∈ Y L, we have Pr(cid:20)kΠyk1 ≤(cid:18) 1 4 − α(cid:19)kyk1(cid:21) ≤ exp(−Ω(d log d)). The proof of the new version of Lemma 13 is also similar to the original proof, except for replacing the 1-stability of standard Cauchy random variables with the lower bound part of the "approximate 1-stability" of truncated standard Cauchy random variables in Corollary 6.4. This also explains why we need α to be a constant smaller than 1/4. Similarly, the constant 1/8 in Lemma 14 also needs to be modified to reflect the changes in Lemma 13. Finally, since the absolute values of standard Cauchy random variables are never smaller than α after truncation, Lemma 15 is changed to the following: Given EH and E L, for any y ∈ Y H we have kΠyk1 ≥ Ω(α)kyk1. This finishes our modification to the proof of Theorem 2 in [22]. By applying the truncation argument to p-stable random variables, a similar result can be obtained for ℓp oblivious subspace embeddings. Theorem 6.6. For 1 ≤ p < 2, there exists an ℓp oblivious subspace embedding over eO(d4) × n matrices Π where each column of Π has a single non-zero entry. The distortion κ = eO(d1/p). 28 References [1] Nir Ailon and Bernard Chazelle. Approximate nearest neighbors and the fast johnson- lindenstrauss transform. In Proceedings of the thirty-eighth annual ACM symposium on Theory of computing, pages 557–563. ACM, 2006. [2] Alexandr Andoni. High frequency moments via max-stability. In Acoustics, Speech and Signal Processing (ICASSP), 2017 IEEE International Conference on, pages 6364–6368. IEEE, 2017. [3] Alexandr Andoni, Khanh Do Ba, Piotr Indyk, and David Woodruff. Efficient sketches for earth- mover distance, with applications. In Foundations of Computer Science, 2009. FOCS'09. 50th Annual IEEE Symposium on, pages 324–330. IEEE, 2009. [4] Herman Auerbach. On the area of convex curves with conjugate diameters. PhD thesis, PhD thesis, University of Lw´ow, 1930. [5] J. Bourgain, J. Lindenstrauss, and V. Milman. Approximation of zonoids by zonotopes. Acta mathematica, 162(1):73–141, 1989. [6] Jean Bourgain, Sjoerd Dirksen, and Jelani Nelson. Toward a unified theory of sparse dimen- sionality reduction in euclidean space. Geometric and Functional Analysis, 25(4):1009–1088, 2015. [7] Bo Brinkman and Moses Charikar. On the impossibility of dimension reduction in ℓ1. Journal of the ACM (JACM), 52(5):766–788, 2005. [8] Moses Charikar, Kevin Chen, and Martin Farach-Colton. Finding frequent items in data streams. Automata, languages and programming, pages 784–784, 2002. [9] Moses Charikar and Amit Sahai. Dimension reduction in the ℓ1 norm. In Foundations of Computer Science, 2002. Proceedings. The 43rd Annual IEEE Symposium on, pages 551–560. IEEE, 2002. [10] Kenneth L. Clarkson, Petros Drineas, Malik Magdon-Ismail, Michael W. Mahoney, Xiangrui Meng, and David P. Woodruff. The fast cauchy transform and faster robust linear regression. SIAM Journal on Computing, 45(3):763–810, 2016. [11] Kenneth L. Clarkson and David P. Woodruff. Numerical linear algebra in the streaming model. In Proceedings of the 41st Annual ACM Symposium on Theory of Computing, STOC 2009, Bethesda, MD, USA, May 31 - June 2, 2009, pages 205–214, 2009. [12] Kenneth L. Clarkson and David P. Woodruff. Low rank approximation and regression in input sparsity time. In Proceedings of the forty-fifth annual ACM symposium on Theory of computing, pages 81–90. ACM, 2013. [13] Michael B. Cohen. Nearly tight oblivious subspace embeddings by trace inequalities. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, pages 278–287. Society for Industrial and Applied Mathematics, 2016. 29 [14] Michael B. Cohen, Yin Tat Lee, Cameron Musco, Christopher Musco, Richard Peng, and Aaron Sidford. Uniform sampling for matrix approximation. In Proceedings of the 2015 Conference on Innovations in Theoretical Computer Science, pages 181–190. ACM, 2015. [15] Michael B. Cohen and Richard Peng. ℓp row sampling by lewis weights. In Proceedings of the forty-seventh annual ACM symposium on Theory of computing, pages 183–192. ACM, 2015. [16] Anirban Dasgupta, Petros Drineas, Boulos Harb, Ravi Kumar, and Michael W. Mahoney. Sampling algorithms and coresets for ℓp regression. SIAM Journal on Computing, 38(5):2060– 2078, 2009. [17] Devdatt Dubhashi and Desh Ranjan. Balls and bins: A study in negative dependence. BRICS Report Series, 3(25), 1996. [18] James R. Lee and Assaf Naor. Embedding the diamond graph in Lp and dimension reduction in L1. Geometric and Functional Analysis, 14(4):745–747, 2004. [19] Mu Li, Gary L. Miller, and Richard Peng. Iterative row sampling. In Foundations of Computer Science (FOCS), 2013 IEEE 54th Annual Symposium on, pages 127–136. IEEE, 2013. [20] Michael W. Mahoney. Randomized algorithms for matrices and data. Foundations and Trends R(cid:13) in Machine Learning, 3(2):123–224, 2011. [21] Andreas Maurer. A bound on the deviation probability for sums of non-negative random variables. J. Inequalities in Pure and Applied Mathematics, 4(1):15, 2003. [22] Xiangrui Meng and Michael W. Mahoney. Low-distortion subspace embeddings in input- In Proceedings of the forty-fifth sparsity time and applications to robust linear regression. annual ACM symposium on Theory of computing, pages 91–100. ACM, 2013. [23] Jelani Nelson and Huy L. Nguyen. OSNAP: Faster numerical linear algebra algorithms via sparser subspace embeddings. In Foundations of Computer Science (FOCS), 2013 IEEE 54th Annual Symposium on, pages 117–126. IEEE, 2013. [24] Jelani Nelson and Huy L. Nguyen. Sparsity lower bounds for dimensionality reducing maps. In Proceedings of the forty-fifth annual ACM symposium on Theory of computing, pages 101–110. ACM, 2013. [25] Jelani Nelson and Huy L. Nguyen. Lower bounds for oblivious subspace embeddings. In In- ternational Colloquium on Automata, Languages, and Programming, pages 883–894. Springer, 2014. [26] J. P. Nolan. Stable Distributions - Models for Heavy Tailed Data. Birkhauser, Boston, 2018. In progress, Chapter 1 online at http://fs2.american.edu/jpnolan/www/stable/stable.html. [27] Tamas Sarlos. Improved approximation algorithms for large matrices via random projections. In Foundations of Computer Science, 2006. FOCS'06. 47th Annual IEEE Symposium on, pages 143–152. IEEE, 2006. 30 [28] Christian Sohler and David P. Woodruff. Subspace embeddings for the l1-norm with appli- cations. In Proceedings of the forty-third annual ACM symposium on Theory of computing, pages 755–764. ACM, 2011. [29] Zhao Song, David P. Woodruff, and Peilin Zhong. Low rank approximation with entrywise ℓ1-norm error. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, pages 688–701. ACM, 2017. [30] David P. Woodruff. Sketching as a tool for numerical linear algebra. Foundations and Trends R(cid:13) in Theoretical Computer Science, 10(1–2):1–157, 2014. [31] David P. Woodruff and Qin Zhang. Subspace embeddings and ℓp-regression using exponential random variables. In Conference on Learning Theory, pages 546–567, 2013. [32] Jiyan Yang, Xiangrui Meng, and Michael Mahoney. Quantile regression for large-scale appli- cations. In International Conference on Machine Learning, pages 881–887, 2013. [33] Andrew Chi-Chin Yao. Probabilistic computations: Toward a unified measure of complexity. In Foundations of Computer Science, 1977., 18th Annual Symposium on, pages 222–227. IEEE, 1977. A Missing Proofs in Section 2 A.1 Proof of Lemma 2.7 Proof. E" nXi=1 aiXip# = nXi=1 aip E [Xip] = Ap nXi=1 aip, where Ap = E [Xip] is a constant which depends only on p. Thus, by Markov's inequality, with probability at least 0.995 nXi=1 aiXip!1/p ≤ (200Ap)1/pkakp. There exists a constant Bp, which depends only p, such that We let Yi be an indicator variable such that 1 400 . Pr[Xip < Bp] ≤ Yi =(1 if Xip < Bp 0 otherwise . We know that E[Yi] ≤ 1 inequality, with probability at least 0.995 we have i=1 aip · Yi] ≤ 1 400kakp p. Thus by Markov's 400 , which also implies E [Pn aip · Yi ≤ 1 2kakp p. nXi=1 31 Notice that aiXip ≥ Bp aip(1 − Yi) nXi=1 nXi=1 nXi=1 ≥(cid:18) Bp Thus, with probability at least 0.995, 2 (cid:19)1/p Thus, the lemma holds by taking Cp = max(cid:26)(200Ap)1/p,(cid:16) 2 aiXip!1/p kakp. Bp(cid:17)1/p(cid:27) and using a union bound. A.2 Proof of Lemma 2.10 Proof. Let Ei be the event that Xi ≤ n log n standard Cauchy distribution, we have log log n . According to the cumulative density function of the Pr[Ei] = 1 − 2 π arctan (n log n/ log log n) ≥ 1 − 2 log log n πn log n . Let E = Tn 1≤i Ei. By a union bound, E holds with probability at least 1 − 2 log log n π log n . Next we calculate E[Xi E]. Since the Xi are independent, by using the probability density function of the standard Cauchy distribution, E[Xi E] = E[Xi Ei] = 1 Pr[Ei] 1 π log(cid:16)1 + (n log n/ log log n)2(cid:17) = O(log n). Notice that conditioned on E, Xi are still independent. Furthermore, conditioned on E, for any i ∈ [n], Xi ∈ [0, n log n/ log log n]. Thus for sufficiently large U1, by applying the Chernoff bound in Lemma 2.4 on Xi log log n(n log n)−1, Thus for sufficiently large U1, Xi > U1n log n E# ≤ 2− U1n log n n log n/ log log n = 2−U1 log log n. Pr" nXi=1 Pr" nXi=1 ≥(cid:16)1 − 2−U1 log log n(cid:17) ·(cid:18)1 − Xi ≤ U1n log n# ≥ Pr" nXi=1 Xi ≤ U1n log n E# · Pr[E] 2 log log n π log n (cid:19) ≥ 1 − log log n log n . A.3 Proof of Lemma 2.12 Proof. According to Lemma 2.2, there exists a constant tp ≥ 1 which depends only on p, such that for any t ≥ tp, Pr[Xi > t] ≥ cp 2 t−p. 32 Thus for t ≥ tp p For i ≥ 0 and j ∈ [n], we let N i Pr[Xip > t] = Pr[Xi > t1/p] = 2 Pr[Xi > t1/p] ≥ cpt−1. j denote the indicator variable such that if Xjp > 2itp otherwise p N i j =(1 j ] ≥ 2−icpt−p 0 p j=1 N i and N i =Pn the Chernoff bound in Lemma 2.4 we have PrhN i ≥ n2−i−1cpt−p Let lmax be the largest i such that j . We have that E[N i and thus E[N i] ≥ n · 2−icpt−p p . According to p i ≥ 1 − exp(cid:16)−n · 2−i−3cpt−p p (cid:17). By a union bound, with probability at least exp(cid:0)−n2−i−3cpt−p p (cid:1) ≤ p (cid:17) ≥ 1 − 1/T, exp(cid:16)−n2−i−3cpt−p lmaxXi=0 simultaneously for all 0 ≤ i ≤ lmax, N i ≥ n2−i−1cpt−p p , which implies 1 − 1 2T . (5) Solving (5) and substituting the value of lmax, for sufficiently large T and n, with probability at least 1 − 1/T , nXi=1 Xip ≥ p · N i/2 ≥ cp/4 · lmax · n. 2itp lmaxXi=0 Xip ≥ Lpn log(cid:18) n log T(cid:19) , nXi=1 where Lp is a constant which depends only on p. A.4 Proof of Lemma 2.17 Proof. Suppose Π has R rows and s non-zero entries per column. For the CountSketch embedding we have R = O(d2) and s = 1, while for the OSNAP embedding we have R = O(B · d log d) and s = O(logB d). In either case we have R ≤ O(d2). For i ∈ [R], define Bi = {j j ≤ d2 and Πi,j 6= 0}. According to the Chernoff bound in Lemma 2.4, with probability at least 1 − exp(−Ω(ωd log d)), Bi ≤ ωd log d. It follows by a union bound that with probability at least 1 − exp(−Ω(ωd log d)) · R = 1 − exp(−Ω(ωd log d)), simultaneously for all i ∈ [R] we have Bi ≤ ωd log d. We condition on this event in the rest of the proof. Notice that (Π (y1:d2))ip ≤s−1/2Xj∈Bi ≤s−1/2(ωd log d)1−1/pXj∈Bi p yj 1/p yjp p 33 = s−p/2(ωd log d)p−1Xj∈Bi yjp . Here the second inequality follows from Lemma 2.1 and Bi ≤ ωd log d. For each j ∈ [d2], the number of i ∈ [R] for which j ∈ Bi is exactly s, which implies (Π (y1:d2))ip ≤ s−p/2(ωd log d)p−1 RXi=1 kΠ (y1:d2)kp ≤ s1/p−1/2(ωd log d)1−1/pky1:d2kp ≤ s1/p−1/2(ωd log d)1−1/pkykp. RXi=1 Xj∈Bi yjp = s1−p/2(ωd log d)p−1 yjp. d2Xj=1 Thus, 34
1601.08111
2
1601
2016-08-20T12:43:42
A Two-Phase Algorithm for Bin Stretching with Stretching Factor 1.5
[ "cs.DS" ]
Online Bin Stretching is a semi-online variant of bin packing in which the algorithm has to use the same number of bins as an optimal packing, but is allowed to slightly overpack the bins. The goal is to minimize the amount of overpacking, i.e., the maximum size packed into any bin. We give an algorithm for Online Bin Stretching with a stretching factor of 1.5 for any number of bins. We build on previous algorithms and use a two-phase approach. However, our analysis is technically more complicated and uses amortization over the bins with the help of two weight functions.
cs.DS
cs
A Two-Phase Algorithm for Bin Stretching with Stretching Factor 1.5 Martin Bohm1,(cid:63), Jir´ı Sgall1,(cid:63), Rob van Stee2 and Pavel Vesel´y1,(cid:63) 1 Computer Science Institute of Charles University, Prague, Czech Republic. {bohm,sgall,vesely}@iuuk.mff.cuni.cz. 2 Department of Computer Science, University of Leicester, Leicester, UK. [email protected]. Abstract. Online Bin Stretching is a semi-online variant of bin packing in which the algorithm has to use the same number of bins as an optimal packing, but is allowed to slightly overpack the bins. The goal is to minimize the amount of overpacking, i.e., the maximum size packed into any bin. We give an algorithm for Online Bin Stretching with a stretching factor of 1.5 for any number of bins. We build on previous algorithms and use a two-phase approach. However, our analysis is technically more complicated and uses amortization over the bins with the help of two weight functions. 1 Introduction The most famous algorithmic problem dealing with online assignment is arguably Online Bin Packing. In this problem, known since the 1970s, items of size between 0 and 1 arrive in a sequence and the goal is to pack these items into the least number of unit-sized bins, packing each item as soon as it arrives. Online Bin Stretching, which has been introduced by Azar and Regev in 1998 [3,4], deals with a similar online scenario. Again, items of size between 0 and 1 arrive in a sequence, and the algorithm needs to pack each item as soon as it arrives, but there are the following differences: (i) The packing algorithm knows m, the number of bins that an optimal offline algorithm would use, and must also use only at most m bins, and (ii) the packing algorithm can use bins of capacity R for some R ≥ 1. The goal is to minimize the stretching factor R. In general, the term "semi-online" refers to algorithms that, compared to online algorithms, have some additional global information about the instance of the problem or have another advantage. We have formulated Online Bin Stretching as a semi-online bin packing variant, where the algorithm has the additional information that the optimal number of bins is m and at the same time the algorithm has the advantage of using bins of larger capacity. Taking another view, Online Bin Stretching can also be thought of as a semi-online scheduling problem, in which we schedule jobs arriving one by one in an online manner on exactly m machines, with the objective to minimize the makespan, i.e., the length of the resulting schedule. Here the additional information is that the optimal offline algorithm could schedule all jobs with makespan 1. Our task is to present an algorithm with makespan being at most R. History. Online Bin Stretching has been proposed by Azar and Regev [3,4]. The original lower bound of 4/3 for three bins has appeared even before that, in [16], (cid:63) Supported by the project 14-10003S of GA CR and by the GAUK project 548214. 6 1 0 2 g u A 0 2 ] S D . s c [ 2 v 1 1 1 8 0 . 1 0 6 1 : v i X r a for two bins together with a matching algorithm. Azar and Regev extended the same lower bound to any number of bins and gave an online algorithm with a stretching factor 1.625. The problem has been revisited recently, with both lower bound improvements and new efficient algorithms. On the algorithmic side, Kellerer and Kotov [15] have achieved a stretching factor 11/7 ≈ 1.57 and Gabay et al. [12] have achieved 26/17 ≈ 1.53. There is still a considerable gap to the best known general lower bound of 4/3, shown by a simple argument in the original paper of Azar and Regev [3,4]. While the algorithms and the lower bound from the last paragraph work for any m ≥ 2, Online Bin Stretching has also been studied in the special case of a specific constant number of bins m. In some cases better algorithms and lower bounds are possible. Obviously, for m = 1, the problem is trivial, as the only possible algorithm has a stretching factor 1. For m = 2, it is easy to achieve a stretching factor 4/3, which is optimal. Thus the first interesting case is m = 3; the currently best algorithm given by the authors of this paper [7] has a stretching factor of 11/8 = 1.375. Interestingly, the setting with a small fixed number of bins allows better lower bounds on the stretching factor. The lower bounds cannot be easily translated into a lower bound for a larger m; for example, if we modify the instance by adding new bins and a corresponding number of items of size 1 (that must use exactly the new bins in the optimum), the semi-online algorithm still could use the additional capacity of R − 1 in the new bins to its advantage. The paper of Gabay et al. [10] showed a lower bound of 19/14 ≈ 1.357 for m = 3 using a computer search. Extending their methods, the authors of this paper were able to reach a lower bound of 15/11 = 1.36 for m = 3 in [7] as well as a bound of 19/14 for m = 4 and m = 5. The preprint [10] was updated in 2015 [11] to include a lower bound of 19/14 for m = 4 bins. For m > 5, the general lower bound of 4/3 is still the best currently known. Our contributions. We present a new algorithm for Online Bin Stretching with a stretching factor of 1.5. We build on the two-phase approach which appeared previously in [15,12]. In this approach, the first phase tries to fill some bins close to R − 1 and achieve a fixed ratio between these bins and empty bins, while the second phase uses the bins in blocks of fixed size and analyzes each block separately. To reach 1.5, we needed to significantly improve the analysis using amortization techniques (represented by a weight function in our presentation) to amortize among blocks and bins of different types. A preliminary version of this work appeared in [6]. Related work. The NP-hard problem Bin Packing was originally proposed by Ullman [18] and Johnson [14] in the 1970s. Since then it has seen major interest and progress, see the survey of Coffman et al. [8] for many results on classical Bin Packing and its variants. While our problem can be seen as a variant of Bin Packing, note that the algorithms cannot open more bins than the optimum and thus general results for Bin Packing do not translate to our setting. As noted, Online Bin Stretching can be formulated as online scheduling on m identical machines with known optimal makespan. Such algorithms were studied and are important in designing constant-competitive algorithms without the 2 additional knowledge, e.g., for scheduling in the more general model of uniformly related machines [2,5,9]. For scheduling, also other types of semi-online algorithms are studied. Historically first is the study of ordered sequences with non-decreasing processing times [13]. Most closely related is the variant with known sum of all processing times studied in [16]. If we know the optimal makespan, we can always pad the instance by small items at the end so that the optimal makespan remains the same and the sum of processing time equals m times the optimal makespan. Thus one could expect that these two quantities are interchangeable. However, when the sum of all processing times is known, the currently best results are a lower bound of 1.585 and an algorithm with ratio 1.6, both from [1]. This shows, somewhat surprisingly, that knowing the actual optimum gives a significantly bigger advantage to the semi-online algorithm over knowing just the sum of the processing times. See Pruhs et al. [17] for a survey of other results on (semi-)online scheduling. 1.1 Definitions and notation Our main problem, Online Bin Stretching, can be described as follows: Input: an integer m and a sequence of items I = i1, i2, . . . given online one by one. Each item has a size s(i) ∈ [0, 1] and must be packed immediately and irrevocably. Parameter: The stretching factor R ≥ 1. s(i) ≤ R for all j = 1, . . . , m. Guarantee: there exists a packing of all items in I into m bins of capacity 1. Goal: Design an online algorithm with the stretching factor R as small as possible which packs all input sequences satisfying the guarantee. Output: Partitioning (packing) of I into bins B1, . . . , Bm so that(cid:80)i∈Bj For a bin B, we define the size of the bin s(B) =(cid:80)i∈B s(i). Unlike s(i), s(B) can change during the course of the algorithm, as we pack more and more items into the bin. To easily differentiate between items, bins and lists of bins, we use lowercase letters for items (i, b, x), uppercase letters for bins and other sets of items (A, B, X), and calligraphic letters for lists of bins (A, C, L). 2 Algorithm We rescale the sizes of items and the capacities of bins so that the optimal bins have capacity 12 and the bins of the algorithm have capacity 18. We follow the general two-phase scheme of recent results [15,12] which we sketch now. In the first phase of the algorithm we try to fill the bins so that their size is at most 6, as this leaves space for an arbitrary item in each bin. Of course, if items larger than 6 arrive, we need to pack them differently, preferably in bins of size at least 12 (since that is the size of the optimal bins). We stop the first phase when the number of non-empty bins of size at most 6 is three times the number of empty bins. In the second phase, we work in blocks consisting of three non-empty bins and one empty bin. The goal is to show that we are able to fill the bins so that the average size is at least 12, which guarantees we are able to pack the total size of 12m which is the upper bound on the size of all items. 3 The limitation of the previous results using this scheme was that the volume achieved in a typical block of four bins is slightly less than four times the size of the optimal bin, which then leads to bounds strictly above 3/2. This is also the case in our algorithm: A typical block may have three bins with items of size just above 4 from the first phase plus one item of size 7 from the second phase, while the last bin contains two items, each of size 7, from the second phase -- a total of 47 instead of desired 4 · 12. However, we notice that such a block contains five items of size 7 which the optimum cannot fit into four bins. To take an advantage of this, we cannot analyze each block separately as in [15,12]. Instead, the rough idea of our improved method is to show that a bin with no item of size more than 6 typically has size at least 13 and amortize among the blocks of different types. Technically this is done using a weight function w that takes into account both the total size of items and the number of items larger than 6. This is the main new technical idea of our proof. There are other complications. We would like to ensure that a typical bin of size at most 6 has size at least 4 after the first phase. However, this is impossible to guarantee if the items packed there have size between 3 and 4. Larger items are fine, as one per bin is sufficient, and the smaller ones are fine as well as we can always fit at least two of them. It is crucial to consider the items with sizes between 3 and 4 very carefully. This motivates our classification of items: Only the regular items of size in (0, 3] ∪ (4, 6] are packed in the bins filled up to size 6. The medium items of size in (3, 4] are packed in their own bins (four or five per bin). Similarly, large items of size in (6, 9] are packed in pairs in their own bins. Finally, the huge items of size larger than 9 are handled similarly as in the previous papers: If possible, they are packed with the regular items, otherwise each in their own bin. The introduction of medium size items implies that we need to revisit the analysis of the first phase and also of the case when the first phase ends with no empty bin. These parts of the proof are similar to the previous works, but due to the new item type we need to carefully revisit it; it is now convenient to introduce another function v that counts the items according to their type; we call it a value, to avoid confusion with the main weight function w. The analysis of the second phase when empty bins are present is more complicated, as we need to take care of various degenerate cases, and it is also here where the novel amortization is used. Now we are ready to proceed with the formal definitions, statement of the algorithm, and the proof our main result. Theorem 2.1. There exists an algorithm for Online Bin Stretching with a stretching factor of 1.5 for an arbitrary number of bins. We take an instance with an optimal packing into m bins of size at most 12 and, assuming that our algorithm fails, we derive a contradiction. One way to get a contradiction is to show that the size of all items is larger than 12m. As stated above, we also use two bounds in the spirit of weight functions: weight w(i) and value v(i). The weight w(i) is a slightly modified size to account for items of size larger than 6. The value v(i) only counts the number of items with relatively large sizes. For our calculations, it is convenient to normalize the weight w(i) and value v(i) so that they are at most 0 for bins in the optimal packing (see Lemma 2.3). To 4 get a contradiction, it is then sufficient to prove that the total weight or value of all bins is positive. We classify the items based on their size s(i) and define their value v(i) as follows. s(i) type v(i) (9, 12] (6, 9] (3, 4] huge large medium 3 2 1 (0, 3] ∪ (4, 6] regular 0 Furthermore we define weight w(A) as follows. Let k(A) be the number of large and huge items in A. Then w(A) = s(A) + k(A) − 13. Definition 2.2. For a set of items A, we define the value v(A) = ((cid:80)i∈A v(i)) − 3. For a set of bins A we define v(A) = (cid:80)A∈A v(A), w(A) = (cid:80)A∈A w(A) and k(A) =(cid:80)A∈A k(A). Lemma 2.3. For any packing A of a valid input instance into m bins of an arbitrary capacity, we have w(A) ≤ 0 and v(A) ≤ 0. Proof. For the value v(A), no optimal bin can contain items with the sum of their values larger than 3. The bound follows by summing over all bins and the fact that the number of bins is the same for the optimum and the considered packing. For w(A), we have s(A) ≤ 12m and k(A) ≤ m, as the optimum packs all items in m bins of volume 12 and no bin can contain two items larger than 6. Thus w(A) = s(A) + k(A) − 13m ≤ 12m + m − 13m = 0. (cid:117)(cid:116) Fig. 1. An illustration of bin types during the first phase. First phase. During the first phase, our algorithm maintains the invariant that only bins of the following types exist. See Figure 1 for an illustration of the bin types. Definition 2.4. Given a bin A, we define the following bin types and introduce letters that typically denote those bins: -- Empty bins (E): bins that have no item. -- Complete bins (G): all bins that have w(A) ≥ 0 and s(A) ≥ 12; -- Huge-item bins (H): all bins that contain a huge item (plus possibly some other items) and have s(A) < 12; -- One large-item bin (L): a bin containing only a single large item; -- One medium-item bin (M): a non-empty bin with s(A) < 13 and only medium items; 5 G612MLTREH3 -- One tiny bin (T): a non-empty bin with s(A) ≤ 3; -- Regular bins (R): all other bins with s(A) ∈ (3, 6]; First-phase algorithm: During the algorithm, let e be the current number of empty bins and r the current number of regular bins. (1) While r < 3e, consider the next item i and pack it as follows, using bins of capacity 18; if more bins satisfy a condition, choose among them arbitrarily: (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) If i is regular: If there is a huge-item bin, pack i there. Else, if there is a regular bin A with s(A) + s(i) ≤ 6, pack it there. Else, if there is a tiny bin A with s(A) + s(i) ≤ 6, pack it there. If i is medium and there is a medium-item bin where i fits, pack it there. If i is large and there is a large-item bin where i fits, pack it there. If i is huge: If there is a regular bin, pack i there. Else, if there is a tiny bin, pack i there. If i is still not packed, pack it in an empty bin. First we observe that the algorithm described in the box above is properly defined. The stopping condition guarantees that the algorithm stops when no empty bin is available. Thus an empty bin is always available and each item i is packed. We now state the basic properties of the algorithm. Lemma 2.5. At any time during the first phase the following holds: (i) All bins used by the algorithm are of the types from Definition 2.4. (ii) All complete bins B have v(B) ≥ 0. (iii) If there is a huge-item bin, then there is no regular and no tiny bin. (iv) There is at most one large-item bin and at most one medium-item bin. (v) There is at most one tiny bin T . If T exists, then for any regular bin, s(T ) + s(R) > 6. There is at most one regular bin R with s(R) ≤ 4. (vi) At the end of the first phase 3e ≤ r ≤ 3e + 3. Proof. (i)-(v): We verify that these invariants are preserved when an item of each type arrives and also that the resulting bin is of the required type; the second part is always trivial when packing in an empty bin. If a huge item arrives and a regular bin exists, it always fits there, thus no huge-item bin is created and (iii) cannot become violated. Furthermore, the resulting size is more than 12, thus the resulting bin is complete. Otherwise, if a tiny bin exists, the huge item fits there and the resulting bin is either complete or huge. In either case, if the bin is complete, its value is 0 as it contains a huge item. If a large item arrives, it always fits in a large-item bin if it exists and makes it complete; its value is at least 1, as it contains two large items. Thus a second large-item bin is never created and (iv) is not violated. If a medium item arrives, it always fits in a medium-item bin if it exists; the bin is then complete if it has size at least 13 and then its value is at least 1, as it contains 4 or 5 medium items; otherwise the bin type is unchanged. Again, a second medium-item bin is never created and (iv) is not violated. 6 If a regular item arrives and a huge-item bin exists, it always fits there, thus no regular bin is created and (iii) cannot become violated. Furthermore, if the resulting size is at least 12, the bin becomes complete and its value is 0 as it contains a huge item; otherwise the bin type is unchanged. In the last case, a regular item arrives and no huge-item bin exists. The algorithm guarantees that the resulting bin has size at most 6, thus it is regular or tiny. We now proceed to verify (v). A new tiny bin T can be created only by packing an item of size at most 3 in an empty bin. First, this implies that no other tiny bin exists, as the item would be put there, thus there is always at most one tiny bin. Second, as the item is not put in any existing regular bin R, we have s(R) + s(T ) > 6 and this also holds later when more items are packed into any of these bins. A new regular bin R with s(R) ≤ 4 can be created only from a tiny bin; note that a bin created from an empty bin by a regular item is either tiny or has size in (4, 6]. If another regular bin with size at most 4 already exists, then both the size of the tiny bin and the size of the new item are larger than 2 and thus the new regular bin has size more than 4. This completes the proof of (v). (vi): Before an item is packed, the value 3e − r is at least 1 by the stopping condition. Packing an item may change e or r (or both) by at most 1. Thus after packing an item we have 3e − r ≥ 1 − 3 − 1 = −3, i.e., r ≤ 3e + 3. If in addition 3e ≤ r, the algorithm stops in the next step and (vi) holds. (cid:117)(cid:116) If the algorithm packs all items in the first phase, it stops. Otherwise according to Lemma 2.5(iii) we split the algorithm in two very different branches. If there is at least one huge-item bin, follow the second phase with huge-item bins below. If there is no huge-item bin, follow the second phase with regular bins. Any bin that is complete is not used in the second phase. In addition to complete bins and either huge-item bins, or regular and empty bins, there may exist at most three special bins denoted and ordered as follows: the large-item bin L, the medium-item bin M , and the tiny bin T . Second phase with huge-item bins. In this case, we assume that a huge-item bin exists when the first phase ends. By Lemma 2.5(iii), we know that no regular and tiny bins exist. There are no empty bins either, as we end the first phase with 3e ≤ r = 0. With only a few types of bins remaining, the algorithm for this phase is very simple: Algorithm for the second phase with huge-item bins: Let the list of bins L contain first all the huge-item bins, followed by the special bins L, M , in this order, if they exist. (1) For any incoming item i: (2) Pack i using First Fit on the list L, with all bins of capacity 18. Suppose that we have an instance that has a packing into bins of capacity 12 and on which our algorithm fails. We may assume that the algorithm fails on the last item f . By considering the total volume, there always exists a bin with size at most 12. Thus s(f ) > 6 and v(f ) ≥ 2. If during the second phase an item n with s(n) ≤ 6 is packed into the last bin in L, we know that all other bins have size more than 12, thus all the remaining items fit 7 into the last bin. Otherwise we consider v(L). Any complete bin B has v(B) ≥ 0 by Lemma 2.5(ii) and each huge-item bin gets nonnegative value, too. Also v(L) ≥ −1 if L exists. This shows that M must exist, since otherwise v(L) + v(f ) ≥ −1 + 2 ≥ 1, a contradiction. Now we know that M exists, furthermore it is the last bin and thus we also know that no regular item is packed in M . Therefore M contains only medium items from the first phase and possibly large and/or huge items from the second phase. We claim that v(M ) + v(f ) ≥ 2 using the fact that f does not fit into M and M contains no item a with v(a) = 0: If f is huge we have s(M ) > 6, thus M must contain either two medium items or at least one medium item together with one large or huge item and v(M ) ≥ −1. If f is large, we have s(M ) > 9; thus M contains either three medium items or one medium and one large or huge item and v(M ) ≥ 0. Thus we always have v(L) ≥ −1 + v(M ) + v(f ) ≥ 1, a contradiction. Second phase with regular bins. Let E resp. R be the set of empty resp. regular bins at the beginning of the second phase, and let e = E. Let λ ∈ {0, 1, 2, 3} be such that R = 3e + λ; Lemma 2.5(vi) implies that λ exists. Note that it is possible that R = ∅, in that case e = λ = 0. We organize the remaining non-complete bins into blocks Bi, and then order them into a list L, as follows: Definition 2.6. Denote the empty bins E1, E2, . . . , Ee. The regular bins are denoted by Ri,j, i = 1, ..., e + 1, j = 1, 2, 3. The ith block Bi consists of bins Ri,1, Ri,2, Ri,3, Ei in this order. There are several modifications to this rule: (1) The first block B1 contains only λ regular bins, i.e., it contains R1,1, . . . , R1,λ, E1 (2) The last block Be+1 has no empty bin, only exactly 3 regular bins. (3) If e = 0 and r = λ > 0 we define only a single block B1 which contains r = λ (4) If e = r = λ = 0, there is no block, as there are no empty and regular bins. (5) If r > 0, we choose as the first regular bin the one with size at most 4, if there is in this order; in particular, if λ = 0 then B1 contains only E1. regular bins R1,1, . . . , R1,λ. such a bin. Denote the first regular bin by Rfirst. If no regular bin exists (i.e., if r = 0), Rfirst is undefined. Note that Rfirst is either the first bin R1,1 in B1 if λ > 0 or the first bin R2,1 in B2 if λ = 0. By Lemma 2.5(v) there exists at most one regular bin with size at most 4, thus all the remaining Ri,j (cid:54)= Rfirst have s(Ri,j) > 4. Definition 2.7. The list of bins L we use in the second phase contains first the special bins and then all the blocks B1, . . . , Be+1. Thus the list L is (some or all of the first six bins may not exist): L, M, T, R1,1, R1,2, R1,3, E1, R2,1, R2,2, R2,3, E2, . . . , Ee, Re+1,1, Re+1,2, Re+1,3. Whenever we refer to the ordering of the bins, we mean the ordering in the list L. See Figure 2 for an illustration. 8 Fig. 2. A typical state of the algorithm after the first phase. The bin labels correspond to the particular bin types. G denotes complete bins, other labels are the initial letters of the bin types. The non-complete bins (other than G) are ordered as in the list L at the beginning of the second phase with regular bins. Algorithm for the second phase with regular bins: Let L be the list of bins as in Definition 2.7, with all bins of capacity 18. (1) For any incoming item i: (2) (3) If i is huge, pack it using First Fit on the reverse of the list L. In all other cases, pack i using First Fit on the normal list L. Suppose that we have an instance that has a packing into bins of capacity 12 and on which our algorithm fails. We may assume that the algorithm fails on the last item. Let us denote this item by f . We have s(f ) > 6, as otherwise all bins have size more than 12, contradicting the existence of optimal packing. Call the items that arrived in the second phase new (including f ), the items from the first phase are old. See Figure 3 for an illustration of a typical final situation (and also of notions that we introduce later). Our overall strategy is to obtain a contradiction by showing that w(L) + w(f ) > 0 . In some cases, we instead argue that v(L) + v(f ) > 0 or s(L) + s(f ) > 12L. Any of these is sufficient for a contradiction, as all complete bins have both value and weight nonnegative and size at least 12. Let H denote all the bins from L with a huge item, and let h = H mod 4. First we show that the average size of bins in H is large and exclude some degenerate cases; in particular, we exclude the case when no regular bin exists. R (cid:54)= ∅ and Rfirst is defined. Lemma 2.8. Let ρ be the total size of old items in Rfirst if R (cid:54)= ∅ and Rfirst ∈ H, otherwise set ρ = 4. (i) The bins H are a final segment of the list L and H (cid:40) E ∪ R. In particular, (ii) We have s(H) ≥ 12H + h + ρ − 4. (iii) If H does not include Rfirst, then s(H) ≥ 12H + h ≥ 12H. (iv) If H includes Rfirst, then s(H) ≥ 12H + h − 1 ≥ 12H − 1. Proof. First we make an easy observation used later in the proof. If E ∪ R ∪ {T} contains a bin B with no huge item, then no bin preceding B contains a huge item. Indeed, if a huge item does not fit into B, then B must contain a new item i of size at most 9. This item i was packed using First Fit on the normal list L, and therefore it did not fit into any previous bin. Thus the huge item also does not fit into any previous bin, and cannot be packed there. 9 G612GGGMLTRRRRRRRREE (cid:48) Let H (cid:48), (ii) for H We now prove the claims (ii) -- (iv) with H (cid:48) = H ∩ (E ∪ R). We begin proving our lemma for H (cid:48) and the h bins in R from the first block intersecting H (cid:48) and ρ = 4 otherwise. (cid:48) in place of H. That is, we ignore the special bins at this stage. The previous observation shows that H is a final segment of the list. (cid:48) in place of H. All bins Ri,j with a huge item have size at least 4 + 9 = 13, with a possible exception of Rfirst which has size at least ρ + 9 = 13 + ρ − 4, by the definition of ρ. Each Ei with a huge item has size at (cid:48), s(Ei) + s(Ri+1,1) + s(Ri+1,2) + s(Ri+1,3) ≥ 4· 12, least 9. Thus for each i with Ei ∈ H with a possible exception of i = 1 in the case when λ = 0. Summing over all i with (cid:48), and adjusting Ei ∈ H (cid:48) are an for Rfirst if Rfirst ∈ H immediate consequence as ρ > 3 if Rfirst ∈ H (cid:48) (cid:40) E ∪ R. Indeed, following the observation at the beginning of the proof, the existence of a bin in E ∪ R with no (cid:48) = H huge item implies that no special bin has a huge item, i.e., H is a final segment of L. Furthermore, the existence of a bin in E ∪ R together with 3e ≤ r implies that there exist at least one regular bin, thus also Rfirst is defined and (cid:48) = H and the fact that we have (i) follows. Claims (ii), (iii), and (iv) follow from H proved them for H (cid:48) (cid:40) E ∪ R. Suppose for a contradiction that Thus it remains to show that H (cid:48) = E ∪ R. H If T exists, let o be the total size of old items in T . If also Rfirst exists, Lemma 2.5(v) implies that o + ρ > 6 > 4, otherwise o + ρ > 4 trivially. In either case, summing with (ii) we obtain (cid:48) follows. The claims (iii) and (iv) for H We claim that the lemma for H follows if H (cid:48) = H, and also H (cid:48). (cid:48) (cid:48) o + s(H (1) (cid:48), i.e., Now we proceed to bound s(H). We have already shown claim (iv) for H (cid:48)) ≥ 12H − 1. If L or M has a huge item, the size of the bin is at least 12, as s(H there is an old large or medium item in it. If T has a huge item, then (1) implies (cid:48)) > 9 + o + s(H s(T ) + s(H . Summing these bounds we obtain (cid:48)) > 9 + 12H ) > 12H . (cid:48) (cid:48) s(H) > 12H − 3 . (2) We now derive a contradiction in each of the following four cases. Case 1: All special bins have a huge item. Then L = H and (2) together with s(f ) > 6 implies s(L) + s(f ) > 12L + 3, a contradiction. Case 2: There is one special bin with no huge item. Then its size together with f is more than 18, thus (2) together with s(f ) > 6 implies s(f ) + s(L) > 18 + 12H− 3 > 12L, a contradiction. Case 3: There are two special bins with no huge item and these bins are L and M . Suppose first that M contains a new item n. Then s(L) + s(n) > 18 by the First Fit packing rule. The bin M contains at least one old medium item. Thus, using (2), we get s(f ) + s(L) > 6 + s(L) + s(n) + 3 + 12H − 3 > 24 + 12H = 12L, a contradiction. If M has no new item, then either f is huge and M has at least two medium items, or f is large and M has at least three items. In both cases v(M ) + v(f ) ≥ 2. Also v(L) ≥ −1 since L has a large item, and v(H) ≥ 0 as each bin has a huge item. Altogether we get that the total value v(L) > 0, a contradiction. 10 Case 4: There are two or three special bins with no huge item, one of them is T . Observe that the bin T always contains a new item n, as the total size of all old items in it is at most 3. If there are two special bins with no huge item, denote the first one by B. As we observed at the beginning of the proof, if T exists and has no huge item, no special bin can contain a huge item, thus the third special bin cannot exist. We have s(B) + s(n) > 18, summing with (1) we obtain s(f ) + s(L) ≥ s(f ) + s(B) + s(n) + o + s(H If there are three special bins with no huge item, we have s(f ) + s(L) > 18 and (cid:48)) > s(M ) + s(n) > 18. Summing with (1) we obtain s(f ) + s(L) > 18 + 18 + o + s(H 36 + 12H (cid:117)(cid:116) Having proven Lemma 2.8, we can infer existence of the following two important = 12L, a contradiction. = 12L, a contradiction. (cid:48) (cid:48)) > 6 + 18 + 12H (cid:48) bins, which (as we will later see) split the instance into three logical blocks: Definition 2.9. -- Let F , the final bin be the last bin in L before H, or the last bin if H = ∅. -- Let C, the critical bin, be the first bin in L of size at most 12. First note that both F and C must exist: F exists by Lemma 2.8(i), which also shows that F ∈ E ∪ R. C exists, as otherwise the total size is more than 12m. To make our calculations easier, we modify the packing so that f is put into F , even though it exceeds the capacity of F . Thus s(F ) > 18 and f (a new item) as well as all the other new items packed in F or in some bin before F satisfy the property that they do not fit into any previous bin. See Figure 3 for an illustration of the definitions. We start by some easy observations. Each bin, possibly with the exception of L and M , contains a new item, as it enters the phase with size at most 6, and the algorithm failed. Only items of size at most 9 are packed in bins before F ; in F itself only the item f can be huge. The bin F always has at least two new items, one that did fit into it and f . All the new items in the bins after C are large, except for the new huge items in H and f which can be large or huge. (Note that at this point of the proof it is possible that C is after F ; we will exclude this possibility soon.) More observations are given in the next two lemmata. Lemma 2.10. (i) Let B be any bin before F . Then s(B) > 9. Furthermore, if B ∈ E then B contains at least two new items. (ii) Let B, B(cid:48), B(cid:48)(cid:48) be any three bins in this order before than or equal to F and let B(cid:48)(cid:48) contain at least two new items. Then s(B) + s(B(cid:48)) + s(B(cid:48)(cid:48)) > 36 + o, where o is the size of old items in B(cid:48)(cid:48). (iii) Let B be arbitrary and let B(cid:48) ∈ R be an arbitrary bin after B and before than (cid:54)= Rfirst then s(B) + s(B(cid:48)) > 22, in particular s(B) > 11 or s(B(cid:48)) > 11. or equal to F in L. If B(cid:48) If B(cid:48) = Rfirst then s(B) + s(B(cid:48)) > 21. Proof. F contains a new item n different from f . To prove (i), note that s(n) ≤ 9, and n does not fit into B. It follows that if B ∈ E, then B must contain at least two new items, as only items with size smaller than 9 are packed before F . 11 Fig. 3. A typical state of the algorithm after the second phase with regular bins. The gray (hatched) areas denote the old items (i.e., packed in the first phase), the red (solid) regions and rectangles denote the new items (i.e., packed in the second phase). The bins that are complete at the end of the first phase are not shown. The item f on which the algorithm fails is shown as packed into the final bin F and exceeding the capacity 18, following the convention introduced after Definition 2.9. and s(B(cid:48)) + s(n(cid:48)) > 18. it also has old items of size at least 3 or even 4 if B(cid:48) To prove (ii), let n, n(cid:48) be two new items in B(cid:48)(cid:48) and note that s(B) + s(n) > 18 To prove (iii), observe that B(cid:48) has a new item of size larger than 18 − s(B), and (cid:117)(cid:116) Lemma 2.11. The critical bin C is before F , there are at least two bins between C and F and C is not in the same block as F . (cid:54)= Rfirst. Proof. All bins before C have size larger than 12. Using Lemma 2.8 we have s(F ) + s(H) > 18 + 12H − 1 = 12(H + 1) + 5 . It remains to bound the sizes of the other bins. Note that F (cid:54)= C as s(F ) > 18. If C is after F , all bins before F have size more than 12, so all together s(L) > 12L + 5, a contradiction. If C is just before F , then by Lemma 2.10(i), s(C) > 9 = 12 − 3 and the total size of bins in s(L) > 12L + 5 − 3 > 12L, a contradiction. If there is a single bin B between C and F , then s(C) + s(B) plus the size of two new items in F is more than 36 by Lemma 2.10(ii). If F ∈ E then H starts with three bins in R, thus s(H) ≥ 12H + 2 using Lemma 2.8 with h = 3, and we get a contradiction. If F ∈ R then Rfirst /∈ H, thus Lemma 2.8 gives s(H) ≥ 12H, and we get a contradiction as well. The last case is when C and F are in the same block with two bins between them. Then F ∈ E, so h = 3, and C is the first bin of the three other bins from the same block, so Rfirst /∈ H. Then s(C) > 9, the remaining two bins together with F have size more than 36 by Lemma 2.10(ii) and we use s(H) ≥ 12H + 3 from Lemma 2.8 (cid:117)(cid:116) to get a contradiction. We now partition L into several parts (see Figure 3 for an illustration): Definition 2.12. -- Let F = Bi ∪ H, where F ∈ Bi. -- Let D be the set of all bins after C and before F. 12 FF→←HugeitemsFFCCD18126LMT -- Let C be the set of all bins before and including C. Lemma 2.11 shows that the parts are non-overlapping. We analyze the weight of the parts separately, essentially block by block. Recall that a weight of a bin is defined as w(A) = s(A) + k(A) − 13, where k(A) is the number of large and huge items packed in A. The proof is relatively straightforward if C is not special (and thus also F (cid:54)∈ B1), which is the most important case driving our choices for w. A typical block has nonnegative weight, we gain more weight in the block of F which exactly compensates the loss of weight in C, which occurs mainly in C itself. series of three lemmata. Let us formalize and prove the intuition stated in the previous paragraph in a Lemma 2.13. If F is not in the first block then w(F) > 5, otherwise w(F) > 4. Proof. All the new items in bins of F are large or huge. Each bin has a new item and the bin F has two new items. Thus k(F) ≥ F + 1. All that remains is to show that s(F) > 12F + 3, and s(F) > 12F + 4 if F is not in the first block. If F is the first bin in a block, the lemma follows as s(F ) > 18 and s(H) ≥ 12H − 1, thus s(F) = s(F ) + s(H) > 12F + 5. In the remaining cases there is a bin in R ∩ F before F . Lemma 2.8 gives s(H) ≥ 12H; moreover, if F ∈ E, then s(H) ≥ 12H + 3. If F is preceded by three bins from F ∩R, then F ∈ E and thus s(H) ≥ 12H + 3. Using Lemma 2.10(iii) twice, two of the bins in F ∩ R before F have size at least 11 and using Lemma 2.10(i) the remaining one has size 9. Thus the size of these four bins is more than 11 + 11 + 9 + 18 = 4 · 12 + 1, summing with the bound for H we get s(F) > 12F + 4. If F is preceded by two bins from F ∩ R, then by Lemma 2.10(i) the total size of these two bins and two new items in F is more than 36. If F ∈ R, the size of old items in F is at least 4 and with s(H) ≥ 12H we get s(F) > 12F + 4. If F ∈ E, which also implies that F is in the first block, then s(H) ≥ 12H + 3, thus s(F) > 12F + 3. If F is preceded by one bin R from F ∩R, then let n be a new item in F different from f . We have s(R) + s(n) > 18 and s(f ) > 6. We conclude the proof as in the (cid:117)(cid:116) previous case. Lemma 2.14. If C ∈ R then w(C) ≥ −6. If C ∈ E then w(C) ≥ −5. If C is a special bin then w(C) ≥ −4. Proof. For every bin B before C, s(B) > 12 and thus w(B) > −1 by the definition (cid:48) be the set of all bins B before C with w(B) ≤ 0. This implies that for of C. Let C (cid:48), s(B) ∈ (12, 13] and B has no large item. It follows that any new item in any B ∈ C bin after the first bin in C (cid:48) has size more than 5. We have (3) (cid:48) w(C) ≥ w(C (cid:48) ) + w(C) ≥ −C + w(C) . (cid:48) First we argue that either C (cid:48) so that B is before B(cid:48). If B(cid:48) ≤ 1 or C B, B(cid:48) ∈ C (cid:48) = {M, T}. Suppose that C > 1, choose ∈ E, either B(cid:48) has at most two (new) non-large (cid:48) 13 ∈ C ∈ C (cid:48). If B(cid:48) items and s(B(cid:48)) ≤ 6+6 = 12, or it has at least three items and s(B(cid:48)) > 5+5+5 = 15; both options are impossible for B(cid:48) ∈ R, it has old items of total size in (3, 6]. Either B(cid:48) has a single new item and s(B(cid:48)) ≤ 6 + 6 = 12, or it has at least two (cid:48). The new items and s(B(cid:48)) > 3 + 5 + 5 = 13; both options are impossible for B(cid:48) only remaining option is that B(cid:48) is a special bin. Since L has a large item, L (cid:54)∈ C (cid:48) (cid:48) = {M, T}. and C By Lemma 2.10(i), we have w(C) ≥ −4. The lemma follows by summing with (3) (cid:48) = ∅ and also (iii) if both C ∈ E and in the following three cases: (i) C ∈ R, (ii) if C (cid:48) C = 1. For the remaining cases, (3) implies that it is sufficient to show w(C) ≥ −3. (cid:48) = {M, T} then C contains two new items of size at least 5, thus If C ∈ E and C (cid:48) = {M} then C either has a large item, or it has two w(C) ≥ −3. If C = T and C new items: otherwise it would have size at most 3 of old items plus at most 6 from a single new item, total of at most 9, contradicting Lemma 2.10(i). Thus w(C) ≥ −3 (cid:117)(cid:116) in this case as well. (i) For every block Bi ⊆ D we have w(Bi) ≥ 0. Lemma 2.15. (ii) If there is no special bin in D, then w(D) ≥ 0. If also C ∈ R then w(D) ≥ 1. Proof. First we claim that for each block Bi ⊆ D with three bins in R, we have w(Bi) ≥ 0 . (4) By Lemma 2.10(iii), one of the bins in R∩Bi has size at least 11. By Lemma 2.10(ii), the remaining three bins have size at least 36. We get (4) by observing that k(Bi) ≥ 5, as all the new items placed after C and before F are large, each bin contains a new item and Ei contains two new items. Next, we consider an incomplete block, that is, a set of bins B with at most two bins from R ∩ D followed by a bin E ∈ E ∩ D. We claim w(B) ≥ 1 . (5) The bin E contains two large items, since it is after C. In particular, w(E) ≥ 1 and (5) follows if B = 1. If B = 2, the size of one item from E plus the previous bin is more than 18, the size of the other item is more than 6, thus s(B) ≥ 24; since k(B) ≥ 3, (5) follows. If B = 3, by Lemma 2.10(ii) we have s(B) ≥ 36; k(B) ≥ 4 and (5) follows as well. By definition, D ends by a bin in E (if nonempty). Thus the lemma follows by using (5) for the incomplete block, i.e., for C ∈ R or for B1 if it does not have three bins in R, and adding (4) for all the remaining blocks. Note that C ∈ R implies (cid:117)(cid:116) D (cid:54)= ∅. We are now ready to derive the final contradiction. If D does not contain a special bin, we add the appropriate bounds from Lemmata 2.14, 2.15 and 2.13. If C ∈ R then F is not in the first block and w(L) = w(C) + w(D) + w(F) > −6 + 1 + 5 = 0. If C ∈ E then F is not in the first block and w(L) = w(C) + w(D) + w(F) > −5 + 0 + 5 = 0. If C is the last special bin then w(L) = w(C) + w(D) + w(F) > −4 + 0 + 4 = 0. In all subcases w(L) > 0, a contradiction. 14 The rest of the proof deals with the remaining case when D does contain a special bin. This implies there are at least two special bins and C is not the last special bin. Since T is always the last special bin (if it exists), it must be the case that C (cid:54)= T and thus C = L or C = M . We analyze the special bins together with the first block, up to F if F belongs to it. First observe that the only bin possibly before C is L and in that case w(L) ≥ 0, so w(C) ≥ w(C). Let A denote F if F ∈ B1 or E1 if F (cid:54)∈ B1. As A = F or A ∈ E, we know that A contains at least two new items; denote two of these new items by n and n(cid:48). Since A is after C, we know that both n and n(cid:48) are large or huge. Let A be the set containing C and all bins between C and A, not including A. Thus A contains two or three special bins followed by at most three bins from R. We have k(A) ≥ A− 1 as each bin in A contains a large item, with a possible exception of C (if C = M ). Furthermore k(A) ≥ 2. The bound on k(A) and k(A) imply that (6) w(A) + w(A) ≥ s(A) + s(A) − 12A − 12 and thus it is sufficient to bound s(A) + s(A). The precise bound we need depends on what bin A is. In each case, we first determine a sufficient bound on s(A) + s(A) and argue that it implies contradiction. Afterwards we prove the bound. Typically, we bound the size by creating pairs of bins of size 21 or 22 by Lemma 2.10(iii). We also use that s(B) > 9 for any B ∈ A by Lemma 2.10(i) and that n, n(cid:48) together with any two bins in A have size at least 36 by Lemma 2.10(ii). Case A (cid:54)= F : Then F (cid:54)∈ B1 and A = E1. We claim that s(A) + s(A) ≥ 12A + 7 . (7) First we show that (7) implies a contradiction. Indeed, (7) together with (6) yields w(A) + w(A) ≥ −5 and summing this with all the other bounds, namely w(F) > 5 from Lemma 2.13 and w(Bi) ≥ 0 for whole blocks Bi ∈ D from Lemma 2.15, leads to w(L) > 0, which is a contradiction. Now we prove (7). The items n and n(cid:48) from A together with the first two special (cid:48) be the set of the remaining bins; it contains bins in A have size more than 36. Let A possibly T and at most three bins from R. It remains to show s(A − 5. (cid:48) (cid:48)) ≥ 12A (cid:48) has size more than 9 and this is sufficient. (cid:48) = 0 it holds trivially. For A (cid:48) If A = 1, the only bin in A (cid:48) > 1 we apply Lemma 2.10(iii) and pair as many bins from A For A (cid:48) (cid:48)) > 21 = 2 · 12 − 3. For A (cid:48) as possible; (cid:48) except possibly T are in R, so the assumptions of = 3 we get (cid:48)) > 22 + 9 = 3 · 12 − 5, since we can create a pair without Rfirst. Finally, if = 4 then s(A note that all the bins in A (cid:48) the lemma hold. If A s(A (cid:48) A Case A = F : We claim that it is sufficient to prove = 2, then s(A (cid:48)) > 22 + 21 = 4 · 12 − 5. s(A) + s(n) + s(n(cid:48) if F ∈ R and Rfirst ∈ A, if either F ∈ R or Rfirst ∈ A, 8 9 10 in all cases. (8) First we show that (7) implies a contradiction. ) > 12A + 15 If F = E1 we note that h = 3 (as H starts with 3 bins in R). Thus Lemma 2.8, items (iii) and (iv), together with w(H) ≥ s(H) − 12H yields w(H) ≥ 3 for Rfirst ∈ A or w(H) ≥ 2 for Rfirst (cid:54)∈ A. Summing this with w(A) + w(A) > −3 or w(A) + w(A) > −2, that are obtained from (6) and (8) in the respective cases, we obtain w(L) > 0, a contradiction. If F ∈ R then we know that F also contains old items of size at least 3 if Rfirst (cid:54)∈ A or even 4 if Rfirst ∈ A (and thus F (cid:54)= Rfirst). Summing this with the respective bound from (8) we obtain s(A) + s(F ) > 12A + 12. Summing this with s(H) ≥ 12H from Lemma 2.8(iii) now yields s(L) > 12L, a contradiction. Thus (7) always leads to a contradiction. We now distinguish subcases depending on A and in each case we either prove (8) or obtain a contradiction directly. Note that Rfirst ∈ A whenever A ≥ 4. Case A = 2: The two bins together with n and n(cid:48) have size more than 36. Thus s(A) + s(n) + s(n(cid:48)) > 36 = 12 · 2 + 12, which implies (8). Case A = 3: We have s(C) > 9 and the remaining two bins together with n and n(cid:48) have size more than 36. Thus s(A) + s(n) + s(n(cid:48)) > 12A + 9, which implies (8) in all cases except if F = E1 and Rfirst (cid:54)∈ A. In the remaining case, A = {L, M, T} and C = L, as A contains no bin from R and A = 3. We prove a contradiction directly. Let o be the size of old items in T . We apply Lemma 2.8(ii), using the fact that o + ρ > 6 by Lemma 2.5(v), where ρ is the total size of old items in Rfirst ∈ H, and h = 3. We get o + s(H) ≥ o + 12H + h + ρ− 4 > 12H + 5. Let n(cid:48)(cid:48) be a new item in T . Since n(cid:48)(cid:48) does not fit into M , s(M ) + s(n(cid:48)(cid:48)) > 18; also s(L) > 9 and s(F ) > 18. Summing all the bounds, we have s(L) ≥ o+s(H)+s(M )+s(n(cid:48)(cid:48))+s(L)+s(F ) > 12H+5+18+9+18 = 12L+2, a contradiction. Case A = 4: The last bin R ∈ A is in R. Together with any previous bin it has size more than 21, the remaining two bins together with n and n(cid:48) have size more than 36 by Lemma 2.10(ii). Thus s(A) + s(n) + s(n(cid:48)) > 21 + 36 = 4 · 12 + 9 which implies (8), since Rfirst ∈ A. Case A = 5: First consider the case F = E1. The last two bins of A are in R, we pair them with two previous bins to form pairs of size more than The remaining bin has size at least 9, since n does not fit into it and s(n) < 9. We also have s(F ) > 18. Thus s(A) + s(A) > 21 + 22 + 9 + 18 = 5 · 12 + 10, which implies (8). If F ∈ R then one of the last two bins of A has size more than 11 and the other forms a pair of size more than 21 with one special bin. The remaining two bins together with n and n(cid:48) have size more than 36 by Lemma 2.10(ii). Thus s(A) + s(n) + s(n(cid:48)) > 11 + 21 + 36 = 5 · 12 + 8 which implies (8), because Rfirst ∈ A. Case A = 6: Then A contains all three special bins and three bins from R, therefore also F = E1. We form three pairs of a special bin with a bin from R of total size more than 21+22+22. Since s(F ) > 18, we have s(A)+s(F ) > 21+22+22+18 = 6·12+11. Since in this case A = F = E1, we have s(H) ≥ 12H + 3 and s(L) > 12L, a contradiction. In all of the cases we can derive a contradiction, which implies that our algorithm (cid:117)(cid:116) cannot fail. This concludes the proof of Theorem 2.1. 16 3 Conclusions We note that the analysis of our algorithm is tight, i.e., if we reduce the capacity of the bins below 18, the algorithm fails. Consider the following instance. Send two items of size 6 which are in the first phase packed separately into two bins. Then send m − 1 items of size 12. One of them must be put into a bin with an item of size 6, i.e., one bin receives items of size 18, while all the items can be packed into m bins of size 12. To decrease the upper bound below 1.5 seems challenging. In particular, the instance above and its modifications with more items of size 6 or slightly smaller items at the beginning shows that these items need to be packed in pairs. This in turns creates difficulties that, in the current approach, lead to new item and bin types; at this point we do not know if such an approach is feasible. Another possible research direction is to improve the lower bounds, in particular for large m. It is quite surprising that there are no lower bounds for m > 5 larger than the easy bound of 4/3. Acknowledgment. The authors thank Emese Bittner for useful discussions during her visit to Charles University. We also thank to referees for many useful comments. References 1. S. Albers and M. Hellwig. Semi-online scheduling revisited. Theor. Comput. Sci., 443:1 -- 9, 2012. 2. J. Aspnes, Y. Azar, A. Fiat, S. Plotkin, and O. Waarts. On-line load balancing with applications to machine scheduling and virtual circuit routing. J. ACM, 44:486 -- 504, 1997. 3. Y. Azar and O. Regev. On-line bin-stretching. In Proc. of Randomization and Approximation Techniques in Computer Science (RANDOM), pages 71 -- 81. Springer, 1998. 4. Y. Azar and O. Regev. On-line bin-stretching. Theor. Comput. Sci. 268(1):17 -- 41, 2001. 5. P. Berman, M. Charikar, and M. Karpinski. On-line load balancing for related machines. J. Algorithms, 35:108 -- 121, 2000. 6. M. Bohm, J. Sgall, R. van Stee, and P. Vesel´y. Better algorithms for online bin stretching. In Proc. of the 12th Workshop on Approximation and Online Algorithms (WAOA 2014), Lecture Notes in Comput. Sci. 8952, pages 23-34, Springer, 2015. 7. M. Bohm, J. Sgall, R. van Stee, and P. Vesel´y. Online Bin Stretching with Three Bins. arXiv preprint arXiv:1404.5569v3. 2016. 8. E. Coffman Jr., J. Csirik, G. Galambos, S. Martello, and D. Vigo. Bin Packing Approximation In P. M. Pardalos, D.-Z. Du, and R. L. Graham, editors, Algorithms: Survey and Classification, Handbook of Combinatorial Optimization, pages 455 -- 531. Springer New York, 2013. 9. T. Ebenlendr, W. Jawor, and J. Sgall. Preemptive online scheduling: Optimal algorithms for all speeds. Algorithmica, 53:504 -- 522, 2009. 10. M. Gabay, N. Brauner, V. Kotov. Computing lower bounds for semi-online optimization problems: Application to the bin stretching problem. HAL preprint hal-00921663, version 2, 2013. 11. M. Gabay, N. Brauner, V. Kotov. Improved Lower Bounds for the Online Bin Stretching Problem. HAL preprint hal-00921663, version 3, 2015. 12. M. Gabay, V. Kotov, N. Brauner. Semi-online bin stretching with bunch techniques. HAL preprint hal-00869858, 2013. 13. R. L. Graham. Bounds on multiprocessing timing anomalies. SIAM J. Appl. Math., 17:263 -- 269, 1969. 14. D. Johnson. Near-optimal Bin Packing Algorithms. Massachusetts Institute of Technology, project MAC. Massachusetts Institute of Technology, 1973. 15. H. Kellerer and V. Kotov. An efficient algorithm for bin stretching. Operations Research Letters, 41(4):343 -- 346, 2013. 16. H. Kellerer, V. Kotov, M. G. Speranza, and Z. Tuza. Semi on-line algorithms for the partition problem. Oper. Res. Lett., 21:235 -- 242, 1997. 17. K. Pruhs, J. Sgall, and E. Torng. Online scheduling. In J. Y.-T. Leung, editor, Handbook of Scheduling: Algorithms, Models, and Performance Analysis, chapter 15, pages 15 -- 1 -- 15 -- 41. CRC Press, 2004. 18. J. Ullman. The Performance of a Memory Allocation Algorithm. Technical Report 100, 1971. 17
1507.06953
1
1507
2015-07-24T18:43:59
Pattern-avoiding access in binary search trees
[ "cs.DS", "math.CO" ]
The dynamic optimality conjecture is perhaps the most fundamental open question about binary search trees (BST). It postulates the existence of an asymptotically optimal online BST, i.e. one that is constant factor competitive with any BST on any input access sequence. The two main candidates for dynamic optimality in the literature are splay trees [Sleator and Tarjan, 1985], and Greedy [Lucas, 1988; Munro, 2000; Demaine et al. 2009] [..] Dynamic optimality is trivial for almost all sequences: the optimum access cost of most length-n sequences is Theta(n log n), achievable by any balanced BST. Thus, the obvious missing step towards the conjecture is an understanding of the "easy" access sequences. [..] The difficulty of proving dynamic optimality is witnessed by highly restricted special cases that remain unresolved; one prominent example is the traversal conjecture [Sleator and Tarjan, 1985], which states that preorder sequences (whose optimum is linear) are linear-time accessed by splay trees; no online BST is known to satisfy this conjecture. In this paper, we prove two different relaxations of the traversal conjecture for Greedy: (i) Greedy is almost linear for preorder traversal, (ii) if a linear-time preprocessing is allowed, Greedy is in fact linear. These statements are corollaries of our more general results that express the complexity of access sequences in terms of a pattern avoidance parameter k. [..] To our knowledge, these are the first upper bounds for Greedy that are not known to hold for any other online BST. To obtain these results we identify an input-revealing property of Greedy. Informally, this means that the execution log partially reveals the structure of the access sequence. This property facilitates the use of rich technical tools from forbidden submatrix theory. [Abridged]
cs.DS
cs
Pattern-avoiding access in binary search trees Parinya Chalermsook1, Mayank Goswami1, L´aszl´o Kozma2, Kurt Mehlhorn1, and Thatchaphol Saranurak∗3 1 Max-Planck Institute for Informatics, Germany. {parinya,gmayank,mehlhorn}@mpi-inf.mpg.de 2 Saarland University, Germany. [email protected] 3 KTH Royal Institute of Technology, Sweden. [email protected] Abstract The dynamic optimality conjecture is perhaps the most fundamental open question about binary search trees (BST). It postulates the existence of an asymptotically optimal online BST, i.e. one that is constant factor competitive with any BST on any input access sequence. The two main candidates for dynamic optimality in the literature are splay trees [Sleator and Tarjan, 1985], and Greedy [Lucas, 1988; Munro, 2000; Demaine et al. 2009]. Despite BSTs being among the simplest data structures in computer science, and despite extensive effort over the past three decades, the conjecture remains elusive. Dynamic optimality is trivial for almost all sequences: the optimum access cost of most length-n sequences is Θ(n log n), achievable by any balanced BST. Thus, the obvious missing step towards the conjecture is an understanding of the "easy" access sequences, and indeed the most fruitful research direction so far has been the study of specific sequences, whose "easiness" is captured by a parameter of interest. For instance, splay provably achieves the bound of O(nd) when d roughly measures the distances between consecutive accesses (dynamic finger), the average entropy (static optimality), or the delays between multiple accesses of an element (working set). The difficulty of proving dynamic optimality is witnessed by other highly restricted special cases that remain unresolved; one prominent example is the traversal conjecture [Sleator and Tarjan, 1985], which states that preorder sequences (whose optimum is linear) are linear-time accessed by splay trees; no online BST is known to satisfy this conjecture. In this paper, we prove two different relaxations of the traversal conjecture for Greedy: (i) Greedy is almost linear for preorder traversal, (ii) if a linear-time preprocessing1 is allowed, Greedy is in fact linear. These statements are corollaries of our more general results that express the complexity of access sequences in terms of a pattern avoidance parameter k. Pattern avoidance is a well-established concept in combinatorics, and the classes of input sequences thus defined are rich, e.g. the k = 3 case includes preorder sequences. For any sequence X with parameter k, our most general result shows that Greedy achieves the cost n2α(n)O(k) where α is the inverse Ackermann function. Furthermore, a broad subclass of parameter-k sequences has a natural combinatorial interpretation as k-decomposable sequences. For this class of inputs, we obtain an n2O(k2) bound for Greedy when preprocessing is allowed. For k = 3, these results imply (i) and (ii). To our knowledge, these are the first upper bounds for Greedy that are not known to hold for any other online BST. To obtain these results we identify an input-revealing property of Greedy. Informally, this means that the execution log partially reveals the structure of the access sequence. This property facilitates the use of rich technical tools from forbidden submatrix theory. Further studying the intrinsic complexity of k-decomposable sequences, we make several observations. First, in order to obtain an offline optimal BST, it is enough to bound Greedy on non-decomposable access sequences. Furthermore, we show that the optimal cost for k-decomposable sequences is Θ(n log k), which is well below the proven performance of all known BST algorithms. Hence, sequences in this class can be seen as a "candidate counterexample" to dynamic optimality. ∗Work partly done while at Saarland University. 1The purpose of preprocessing is to bring the data structure into a state of our choice. This state is independent of the actual input. This kind of preprocessing is implicit in the Demaine et al. definition of Greedy. i 1 Introduction The binary search tree (BST) model is one of the most fundamental and thoroughly studied data access models in computer science. In this model, given a sequence X ∈ [n]m of keys, we are interested in OPT(X), the optimum cost of accessing X by a binary search tree. When the tree does not change between accesses, OPT is well understood: both efficient exact algorithms (Knuth [22]) and a linear time approximation (Mehlhorn [26]) have long been known. By contrast, in the dynamic BST model (where restructuring of the tree is allowed between accesses) our understanding of OPT is very limited. No polynomial time exact or constant-approximation algorithms are known for computing OPT in the dynamic BST model. Theoretical interest in the dynamic BST model is partly due to the fact that it holds the possibility of a meaningful "instance optimality", i.e. of a BST algorithm that is constant factor competitive (in the amortized sense) with any other BST algorithm, even with those that are allowed to see into the future. The existence of such a "dynamically optimal" algorithm has been postulated in 1985 by Sleator and Tarjan [34]; they conjectured their splay tree to have this property. Later, Lucas [23] and independently Munro [27] proposed a greedy offline algorithm as another candidate for dynamic optimality. In 2009 Demaine, Harmon, Iacono, Kane, and Patra¸scu (DHIKP) [11] presented a geometric view of the BST model, in which the Lucas- Munro offline algorithm naturally turns into an online one (simply called Greedy). Both splay and Greedy are considered plausible candidates for achieving optimality. However, despite decades of research, neither of the two algorithms are known to be o(log n)-competitive (the best known approximation ratio for any BST is O(log log n) [12], but the algorithms achieving this bound are less natural). Thus, the dynamic optimality conjecture remains wide open. Why is dynamic optimality difficult to prove (or disprove)? For a vast majority of access sequences, the optimal access cost by any dynamic BST (online or offline) is2 Θ(m log n) and any static balanced tree can achieve this bound.3 Hence, dynamic optimality is almost trivial on most sequences. However, when an input sequence has complexity o(m log n), a candidate BST must "learn" and "exploit" the specific structure of the sequence, in order to match the optimum. This observation motivates the popular research direction that aims at understanding "easy" sequences, i.e. those with OPT = O(md) when d is a parameter that depends on the structure of the sequence; typically d = o(log n). Parameter d can be seen as a measure of "easiness", and the objective is to prove that a candidate algorithm achieves the absolute bound of O(md); note that this does not immediately imply that the algorithm matches the optimum. The splay tree is known to perform very well on many "easy" sequences: It achieves the access time of O(md) when d is a parameter that roughly captures the average distances between consecutive accesses [9,10], the average entropy, or the recentness of the previous accesses [34]; these properties are called dynamic finger, static optimality and working set bounds respectively (the latter two bounds are also satisfied by Greedy [15]). The notorious difficulty of dynamic optimality is perhaps witnessed by the fact that many other highly restricted special cases have resisted attempts and remain unresolved. These special cases stand as a roadblock to proving (or disproving) the optimality of any algorithm: proving that A is optimal requires proving that it performs well on the easy inputs; refuting the optimality of A requires a special "easy" subclass on which A is provably inefficient. In any case, a better understanding of easy sequences is needed, but currently lacking, as observed by several authors [11, 29]. One famous example of such roadblocks is the traversal conjecture, proposed by Sleator and Tarjan in 1985. This conjecture states that starting with an arbitrary tree T (called initial tree) and accessing its keys using the splay algorithm in the order given by the preorder sequence of another tree T (cid:48) takes linear time. Since the optimum of such preorder sequences is linear, any dynamically optimal algorithm must match this bound. After three decades, only very special cases of this conjecture are known to hold, namely when T (cid:48) is a monotone path (the so-called sequential access [36]) or when T (cid:48) = T [8].4 Prior to this work, no online BST algorithm was known to be linear on such access sequences. Motivated by well-established concepts in combinatorics [20, 21, 37], in this paper we initiate the study of the complexity of access sequences in terms of pattern avoidance parameters. Our main contributions are 2This observation appears to be folklore. We include a proof in Appendix F. 3As customary, we only consider successful accesses, we ignore inserts and deletes, and we assume that m ≥ n. 4This result implies an offline BST with O(n) cost for accessing a preorder sequence, by first rotating T to T (cid:48). 1 Static optimality Working set Dynamic finger Deque Structure low entropy temporal locality key-space locality n updates at min/max elements t=1 log(τt + 1)) t=2 log xt − xt−1) [9, 10] O(nα∗(n)) [29] splay bound i=1 fi(1 + log m fi O((cid:80)n O(m + n log n +(cid:80)m O(m +(cid:80)m [34] [34] Greedy bound )) same as splay [7, 15] same as splay [7, 15] ? O(n2α(n)) [6] O(n) [6, 15] n2α(n)O(1) [* Cor 1.2] O(n) [* Cor 1.5] n2O(k2) [* Thm 1.6] n2O(k2) [* Thm 1.4] n2α(n)O(k) [* Thm 1.1] Remark corollaries of Access Lemma [34] O(n) for multi-splay [38] from empty tree OPT = O(n) OPT = O(n) OPT = O(n log k) [* Cor 1.10] Best known lower bound is at most n2O(k) [* Thm 1.7] Sequential avoid (2, 1) O(n) [30, 36] Traversal Pattern- avoiding (new) avoid (2, 3, 1) avoid (2, 3, 1) with preprocessing avoid (k, . . . , 1) (k-increasing) avoid all simple perm. of size > k (k-decomposable) with preprocessing avoid an arbitrary perm. of size k ? ? ? ? ? Table 1: Easy sequences for BST and best known upper bounds. Results referenced as [∗] are new. The symbol "?" means that no nontrivial bound is known. In the first rows, fi is the number of times that i is accessed, xt is the element accessed at time t, and τt is the number of distinct accesses since the last access of xt). In the "Sequential", "Traversal", and "Pattern-avoiding" rows it is assumed that the access sequence is a permutation, i.e. m = n. two-fold (the precise statement of the results is in § 1.1, and the results are summarized in Table 1). (i) We study access sequences parametrized by pattern avoidance and analyze the access time of Greedy in terms of this parameter. As a by-product, we almost settle the traversal conjecture for Greedy in two orthogonal directions: (a) Greedy is "almost linear" for the traversal conjecture, and (b) if a linear-cost preprocessing is allowed, Greedy is in fact linear. This is perhaps the first evidence in support of Greedy as a candidate for dynamic optimality (all previously known properties of Greedy were subsumed by splay). These results are derived via an input-revealing property of Greedy, in the sense that the execution log of Greedy partially reveals the structure of the input sequence. (ii) We study a decomposability property of sequences and show that a wide subclass of the pattern- avoiding class satisfies this property. This allows us to (a) identify the core difficulty of designing an offline algorithm for dynamic optimality, (b) obtain a tight bound for the optimum of this input class, and (c) derive a simple proof that Cole's showcase sequence [10] is linear. 1.1 Our results We first define the pattern avoidance parameters. Let [n] = {1, . . . , n} be the set of keys. We represent a length-m sequence by an m-tuple X = (x1, . . . , xm) ∈ [n]m. Throughout the paper, we assume that X is a permutation, i.e. m = n and xi (cid:54)= xj for all i (cid:54)= j. This is justified by Theorem 2.1, but we remark that many of our results can be extended to non-permutation access sequences. Let Sk denote the set of all permutations in [k]k. Given X ∈ Sn, we say that X contains a permutation pattern π ∈ Sk, if there are indices 1 ≤ i1 < i2 < ··· ik ≤ n, such that (xi1, . . . , xik ) is order-isomorphic to π = (π1, . . . , πk). Otherwise we say that X avoids π, or that X is π-free. Two sequences of the same length are order-isomorphic if they have the same pairwise comparisons, e.g. (5, 8, 2) is order-isomorphic to (2, 3, 1) (Figure 1). As examples, we mention that (2, 1)-free and (2, 3, 1)-free sequences are exactly the sequential, respectively, preorder access sequences. For each permutation X, a pattern avoidance characteristic of X, denoted by ΣX , is the set of all patterns not contained in X, i.e. ΣX = {π ∈ S(cid:96) : (cid:96) ≥ 1 and X is π-free}. The pattern avoidance parameter of X, denoted by k(X), is the minimum k ∈ N for which Sk ∩ ΣX (cid:54)= ∅. 2 For each k ∈ N, the pattern avoidance class Ck contains all sequences X with pattern avoidance parameter k. This characterization is powerful and universal: Ci ⊆ Ci+1 for all i, and Cn+1 contains all sequences. Bounds for Greedy in terms of k. We study the access cost of Greedy in terms of the pattern holds for any access sequence in Ck avoidance parameter. Our most general upper bound of n2α(n)O(k) (Theorem 1.1). Later, we show a stronger bound of n2O(k2) for two broad subclasses of Ck that have intuitive geometric interpretation: k-decomposable sequences (Theorem 1.4), which generalize preorder sequences and k-increasing sequences (Theorem 1.6), which generalize sequential access. Theorem 1.1. Let X ∈ Ck be an access sequence of length n. The cost of accessing X using Greedy is at most n2α(n)O(k) . The following corollary simply follows from the fact that all preorder sequences X belong to C3 (plugging k = 3 into the theorem). Corollary 1.2 ("Almost" traversal conjecture for Greedy). The cost of accessing a preorder sequence of length n using Greedy, with arbitrary initial tree is at most n2α(n)O(1) . Next, we show sharper bounds for Greedy when some structural property of ΣX is assumed. First, we prove a bound when ΣX contains all "non-decomposable" permutations of length at least k + 1. We show that this property leads to a decomposition that has intuitive geometric meaning, which we describe below. Given a permutation σ = (σ1, . . . , σ(cid:96)) ∈ S(cid:96) we call a set [a, b] a block of σ, if {σa, σa+1, . . . , σb} = {c, c + 1, . . . , d} for some integers c, d ∈ [(cid:96)]. In words, a block corresponds to a contiguous interval that is mapped to a contiguous interval. We say that a permutation σ ∈ S(cid:96) is decomposable if there is a block of σ of size strictly betweeen 1 and (cid:96); otherwise, we say that it is non-decomposable (a.k.a. simple 5). such that each [ai, bi] is a block for X and ((cid:83) We say that an input sequence X is decomposable into k blocks if there exist disjoint [a1, b1], . . . , [ak, bk] i[ai, bi]) ∩ N = [n]. The recursive decomposition complexity of a sequence X is at most d if one can recursively decompose X into subblocks until singletons are obtained, and each step creates at most d blocks (equivalently we say that X is d-recursively decomposable, or simply d-decomposable). See Figure 1. It is easy to see that preorder sequences are 2-decomposable.6 The following lemma (proof in Lemma C.1) connects pattern avoidance and recursive decomposition complexity of a sequence. Lemma 1.3. Let X ∈ Sn. Then ΣX contains all simple permutations of length at least k + 1 if and only if X is k-decomposable. This lemma implies in particular that if X is k-decomposable, then X ∈ Ck+1 and Theorem 1.1 can be applied. The following theorem gives a sharper bound, when a preprocessing (independent of X) is performed. This yields another relaxed version of the traversal conjecture. Theorem 1.4. Let X be a k-decomposable access sequence. The cost of accessing X using Greedy, with a linear-cost preprocessing, is at most n2O(k2). Corollary 1.5 (Traversal conjecture for Greedy with preprocessing). The cost of accessing a preorder sequence using Greedy, with preprocessing, is linear. Our preprocessing step is done in the geometric view (explained in § 2) in order to "hide" the initial tree T from Greedy. In the corresponding tree-view, our algorithm preprocesses the initial tree T , turning it into another tree T (cid:48), independent of X, and then starts accessing the keys in X using the tree-view variant of Greedy (as defined in [11]). We mention that DHIKP [11] define Greedy without initial tree, and thus their algorithm (implicitly) performs this preprocessing. 5See [3] for a survey of this well-studied concept. The decomposition described here appears in the literature as substitution- decomposition. 6The entire set of 2-decomposable permutations is known as the set of separable permutations [2]. 3 As another natural special case, we look at ΣX ⊇ {(k, . . . , 1)}, for some value k. In words, X has no decreasing subsequence of length k (alternatively, X can be partitioned into at most k − 1 increasing subsequences7). Observe that the k = 2 case corresponds to sequential access. We call this the k-increasing property of X. Similarly, if ΣX ⊇ {(1, . . . , k)}, we say that X is k-decreasing. We obtain the following generalization of the sequential access theorem (this result holds for arbitrary initial tree). Theorem 1.6. Let X be a k-increasing or k-decreasing sequence. The cost of accessing X using Greedy is at most n2O(k2). All the aforementioned results are obtained via the input-revealing property of Greedy (the ideas are sketched in § 1.2). Bound for signed Greedy in terms of k. We further show the applicability of the input-revealing technique. Signed Greedy [11] (denoted SGreedy) is an algorithm similar to Greedy. It does not always produce a feasible BST solution, but its cost serves as a lower bound for the optimum. Let us denote by A(X) and OPT(X) the cost of an algorithm A on X, respectively the optimum cost of X. Then we have A(X) ≥ OPT(X), and OPT(X) = Ω(SGreedy(X)). Conjecture 1 (Wilber [39], using [11]). OPT(X) = Θ(SGreedy(X)) for all input sequences X. We show that our techniques can be used to upper bound the cost of SGreedy. Theorem 1.7. The cost of SGreedy on an access sequence X ∈ Ck is at most n2O(k). Corollary 1.8. Let A be an algorithm. If Conjecture 1 is true, then one of the following must hold: (i) The cost of accessing X using A is at most n2O(k), for all X ∈ Ck, for all k. In particular, the traversal (ii) A is not dynamically optimal. conjecture holds for A. Decomposability. Next, we prove a general theorem on the complexity of sequences with respect to the recursive decomposition. Let X ∈ Sn be an arbitrary access sequence. We represent the process of decomposing X into blocks until singletons are obtained by a tree T , where each node v in T is associated with a sequence Xv (see Figure 1). Theorem 1.9 (Decomposition theorem, informal). OPT(X) ≤(cid:80) v∈T Greedy(Xv) + O(n). Corollary 1.10. Let X be a k-decomposable sequence of length n (with k possibly depending on n). Then X has optimum cost OPT(X) ≤ O(n log k). This result is tight for all values of k, since for all k, there is a k-decomposable sequence whose complexity is Ω(n log k) (Proof in Appendix G.2). This result gives a broad range of input sequences whose optimum is well below the performance of all known BST algorithms. The class can thus be useful as "candidate counterexample" for dynamic optimality. (Since we know OPT, we only need to show that no online al- gorithm can match it.) We remark that Greedy asymptotically matches this bound when k is constant (Theorem 1.4). The following observation follows from the fact that the bound in Theorem 1.9 is achieved by our proposed offline algorithm, and the fact that OPT(X) ≥(cid:80) v∈T OPT(Xv) (see Lemma D.4). Corollary 1.11. If Greedy is constant competitive on non-decomposable sequences, then there is an offline O(1)-approximate algorithm on any sequence X. This corollary shows that, in some sense, non-decomposable sequences serve as the "core difficulty" of proving dynamic optimality, and understanding the behaviour of Greedy on them might be sufficient. 7This equivalence is proven in Lemma G.2. 4 Finally, Cole et al. [10] developed sophisticated technical tools for proving the dynamic finger theorem for splay trees. They introduced a "showcase" sequence to illustrate the power of their tools, and showed that splay has linear cost on such a sequence. Theorem 1.9 immediately gives an upper bound on the optimum access cost of this sequence. Corollary 1.12 (informal). Let X be Cole's showcase sequence. Then OPT(X) = O(n). Figure 1: From left to right: (i) plot of permutation σ = (6, 1, 3, 2, 8, 7, 4, 5) containing (2, 1, 3) (highlighted) and avoiding (4, 3, 2, 1), (ii) permutation σ, and (iii) its block decomposition tree; permutation (3, 1, 4, 2) at the root is obtained by contracting the four blocks into points, (iv) simple permutation (6, 1, 8, 4, 2, 7, 3, 5). 1.2 Overview of techniques We sketch the main technical ideas of our proofs. First, we define roughly the execution log matrix of Greedy. The log of executing Greedy on X ∈ [n]m is an n-by-m matrix GX such that GX (a, t) = 1 if and only if element a is touched by Greedy at time t. The cost of this execution is exactly the number of ones in GX , denoted by w(GX ) (we make this claim precise in § 2). A submatrix of GX is obtained by removing some rows and columns of GX . We say that GX contains a matrix B if there is a submatrix B(cid:48) of GX such that B(i, j) ≤ B(cid:48)(i, j) for all i, j (in words, any 'one' entry in B must also be a one in B(cid:48)). We say that an algorithm A is input-revealing if there is a constant-size matrix B such that any submatrix of an execution matrix of A containing B must contain an access point. When such a matrix B exists for an algorithm, we say that B is a capture gadget. The existence for Greedy of a capture gadget B allows us to observe that GX contains the pattern8 Q ⊗ B only if the input sequence contains the pattern defined by Q. So, if we execute Greedy on an input sequence X ∈ Ck that is Q-free for Q ∈ Sk, then GX cannot contain Q ⊗ B. Now, we can use results from forbidden submatrix theory for bounding w(GX ). In short, forbidden submatrix theory is a collection of theorems of the following type: Theorem 1.13. Let M and P be n-by-n and k-by-k matrices respectively, such that k ≤ n (mostly k should be thought of as constant). If M does not contain P , then w(M ) ≤ nfP (n, k). The function fP depends on the matrix P that is forbidden in M . For instance, if P contains at most one 1-entry per row and column, then fP (n, k) is only a function of k. If P contains at most one 1-entry per column but possibly multiple 1s per row, then fP (n, k) = 2α(n)O(k) . The tightness of the bounds we obtain depends on the structure of the capture gadget B. This is the reason we have a weaker bound for any X ∈ Ck and stronger bounds when X is more restricted. We also develop a different set of tools to study the intrinsic complexity of decomposable sequences. Here, in order to compute bounds on OPT, we decompose the execution matrix MX of an algorithm in a way that mirrors the recursive decomposition of the input sequence X. Unfortunately, the behaviour of Greedy is too capricious to afford such a clean decomposition. We therefore modify Greedy to reduce the interference between blocks in the input sequence. The modified algorithm might perform more work locally than Greedy, but globally it is more "robust". It is however, an offline algorithm; whether there exists an online algorithm competitive with our robust Greedy, is an interesting open question. 8⊗ denotes the tensor (Kronecker) product, to be defined later. 5 31421122112121111111 Related work. For an overview of results related to dynamic optimality, we refer to the survey of Ia- cono [19]. Besides Tango trees, other O(log log n)-competitive BST algorithms have been proposed, similarly using Wilber's first bound (multi-splay [38] and chain-splay [17]). Using [13], all the known bounds can be simultaneously achieved by combining several BST algorithms. Our study of the execution log of BST algorithms makes use of the geometric view of BST introduced by DHIKP [11]. Pattern avoidance in sequences has a large literature in combinatorics [20, 37], as well as in computer science [2, 4, 21, 32, 35]. The theory of forbidden submatrices can be traced back to a 1951 problem of Zarankiewicz, and its systematic study has been initiated by Furedi [16], and Bienstock and Gyori [1]. Our use of this theory is inspired by work of Pettie [29, 30], who applied forbidden pattern techniques to prove bounds about data structures (in particular he proves that splay trees achieve O(nα∗(n)) cost on deque- sequences, and he reproves the sequential access theorem for splay trees). There are marked differences in our use of the techniques compared with the work of Pettie. In particular, we look for patterns directly in the execution log of a BST algorithm, without any additional encoding step. Furthermore, instead of using fixed forbidden patterns, we make use of patterns that depend on the input. In § 2 we give a short description of the geometric view of the BST model Organization of the paper. (following DHIKP [11]), and we introduce concepts used in the subsequent sections. In § 3 we study the input- revealing property of Greedy, and prove our bounds for pattern-avoiding sequences. In § 4 we introduce a robust Greedy, state the decomposition theorem and its applications. Finally, § 5 is reserved for open questions. We defer the proofs of several results, as well as some auxilliary material to the Appendix. 2 Preliminaries The main object of study in this paper are {0, 1}-matrices (corresponding to the execution matrix of an algorithm). For geometric reasons, we write matrix entries bottom-to-top, i.e. the first row is the bottom- most. Thus, M (i, j) is the value in the i-th column (left-to-right) and the j-th row (bottom-to-top) of M . We simultaneously view M as a set of integral points in the plane. For a point p = (x, y), we say that p ∈ M , if M (x, y) = 1. We denote by p.x and p.y the x- and y-coordinates of point p respectively. Given a point set (matrix) M , let p and q be points not necessarily in M . Let (cid:3)pq be the closed rectangle whose two corners are p and q. Rectangle (cid:3)pq is empty if M ∩ (cid:3)pq \ {p, q} = ∅. Rectangle (cid:3)pq is satisfied if p, q have the same x or y coordinate, or there is another point r ∈ M ∩ (cid:3)pq \ {p, q}. A point set M is (arboreally) satisfied if (cid:3)pq is satisfied for any two points p, q ∈ M . Geometric setting for online BST. We describe the geometric model for analyzing online BST algo- rithms (or simply online BST). This model is essentially the same as [11], except for the fact that our model allows cost analysis of BST algorithms that start accessing an input sequence from arbitrary initial tree. For any access sequence X ∈ [n]m, we also refer to X as an n-by-m matrix, called access matrix, where there is a point (x, t) ∈ X iff an element x is accessed at time t. We call (x, t) the access point (or input point) at time t. We also refer to the x-th column of X as element x, and to the t-th row of X as time t. For any tree T of depth d, let d(x) be the depth of element x in T . We also refer to T as an n-by-d matrix, called initial tree matrix, where in each column x, there is a stack of points (x, 1), . . . , (x, d − d(x) + 1) ∈ T . See Figure 2 for an illustration. Observe that matrix T is satisfied. An online geometric BST A accessing sequence X starting with initial tree T works as follows. Given a the touch matrix of A on X with initial tree T . More precisely, A proceeds in an online fashion: At time t = 1, . . . , n, the algorithm A has access to T as well as to the first t rows of matrix X, and it must decide on (cid:3), where AT (X) ⊇ X is an n-by-m matrix called matrix(cid:2) X the t-th row of the output AT (X) which cannot be changed afterwards. Algorithm A is feasible if(cid:2) AT (X) (cid:3) (cid:3) as input, A outputs a satisfied matrix(cid:2) AT (X) T The matrix AT (X) can be thought of as the execution log of A, and points in AT (X) are called touch is satisfied. points; the cost of A is simply w(AT (X)), i.e. the number of points (ones) in AT (X). T T 6 An online algorithm with preprocessing is an online algorithm that is allowed to perform differently at time t = 0. The linear-cost preprocessing used in this paper, as well as in DHIKP [11], is to put all elements into a split tree (see [11] for the details of this data structure). The consequences of this preprocessing are that (i) in the geometric view the initial tree matrix can be removed, i.e. an algorithm A only gets X as input and outputs A(X), and (ii) in the tree-view, an input initial tree T is turned into another tree T (cid:48) independent of the input X, and then keys in X are accessed using the tree-view variant of Greedy. DHIKP [11] showed9 that online geometric BSTs are essentially equivalent to online BSTs (in tree-view). In particular, given any online geometric BST A, there is an online BST A(cid:48) where the cost of running A(cid:48) on any sequence X with any initial tree T is a constant factor away from w(AT (X)). Therefore, in this paper, we focus on online geometric BSTs and refer to them from now on simply as online BSTs. Unless explicitly stated otherwise, we assume that the access sequence X is a permutation, i.e. each element is accessed only once, and thus X and AT (X) are n-by-n matrices. This is justified by the following theorem (proof in Appendix E). Theorem 2.1. Assume that there is a c-competitive geometric BST Ap for all permutations. Then there is a 4c-competitive geometric BST A for all access sequences.10 Greedy and signed Greedy. Next, we describe the algorithms Greedy and signed Greedy [11] (de- noted as SGreedy). Consider the execution of an online BST A on sequence X with initial tree T just before time t. Let Ot−1 denote the output at time t − 1 (i.e. the initial tree T and the first t − 1 rows of AT (X)). Let τ (b, t− 1) = max{i (b, i) ∈ Ot−1} for any b ∈ [n]. In words, τ (b, t− 1) is the last time strictly before t when b is touched, otherwise it is a non-positive number defined by the initial tree. Let (a, t) ∈ X be the access point at time t. We define stairt(a) as the set of elements b ∈ [n] for which (cid:3)(a,t),(b,τ (b,t−1)) is not satisfied. Greedy touches element x ∈ [n] if and only if x ∈ stairt(a). See Figure 2 for an illustration of stairs. Figure 2: Tree-view and geometric view of initial tree. Search path and stair (at time 1) of element 5. We define stairLeftt(a) = {b ∈ stairt(a) b < a} and stairRightt(a) = {b ∈ stairt(a) b > a}. The algorithms GreedyLeft and GreedyRight are analogous to Greedy, but they only touch stairLeftt(a), respectively stairRightt(a) for every time t; SGreedy simply refers to the union of the GreedyLeft and GreedyRight outputs, which is not necessarily satisfied. It is known [11, 18] that SGreedy constant- approximates the independent rectangle bound which subsumes the two previously known lower bounds on OPT, called Wilber's first and second bounds [39]. Theorem 2.2 ( [11, 18, 39]). For any BST A (online or offline) that runs on sequence X with arbitrary initial tree T , w(AT (X)) = Ω(SGreedy(X)). A nice property of Greedy and SGreedy is that an element x can become "hidden" in some range in the sense that if we do not access in x's hidden range, then x will not be touched. Next, we formally define this concept, and list some cases when elements become hidden during the execution of Greedy and SGreedy. The concept is illustrated in Figure 3. 9with some minor additional argument about initial trees from Appendix B.1. 10The statement holds unconditionally for offline algorithms, and under a mild assumption if we require Ap and A to be online. 7 1 2 3 4 5 6 7 8 9 10 111 2 3 4 5 6 7 8 9 10 11 Figure 3: After time t, element x is hidden in (w, n] for Greedy, and in (w, x] for GreedyRight. After time t(cid:48), element x is hidden in (w, y) for Greedy; it is easy to verify that any access outside of [w, y] will never touch x. Definition 2.3 (Hidden). For any algorithm A, an element x is hidden in range [w, y] after t if, given that there is no access point p ∈ [w, y] × (t, t(cid:48)] for any t(cid:48) > t, then x will not be touched by A in time (t, t(cid:48)]. Lemma 2.4 (Proof in Appendix A.1). Let x be some element. (i) If there is an element w < x where τ (w, t) ≥ τ (x, t), then x is hidden in (w, n] and (w, x] after t for (ii) If there is an element y > x where τ (y, t) ≥ τ (x, t), then x is hidden in [1, y) and [x, y) after t for (iii) If there are elements w, y where w < x < y, and τ (w, t), τ (y, t) ≥ τ (x, t), then x is hidden in (w, y) Greedy and GreedyRight respectively. Greedy and GreedyLeft respectively. after t for Greedy. Forbidden submatrix theory. Let M be an n-by-m matrix. Given I ⊆ [n] and J ⊆ [m], a submatrix MI,J is obtained by removing columns in [n] \ I and rows in [m] \ J from M . Definition 2.5 (Forbidden submatrix). Given a matrix M and another matrix P of size c × d, we say that M contains P if there is a c × d submatrix M(cid:48) of M such that M(cid:48)(i, j) = 1 whenever P (i, j) = 1. We say that M avoids (forbids) P if M does not contain P . We often call an avoided (forbidden) matrix a "pattern". For any permutation π = (π1, . . . , πk) ∈ Sk, we also refer to π as a k-by-k matrix where (πi, i) ∈ π for all 1 ≤ i ≤ k. Permutation matrices have a single one-entry in every row and in every column. Relaxing this condition slightly, we call a matrix that has a single one in every column a light matrix. We make use of the following results. Lemma 2.6. Let M and P be n-by-n and k-by-k matrices such that M avoids P . (i) (Marcus, Tardos [25], Fox [14]) If P is a permutation, the number of ones in M is at most n2O(k). (ii) (Nivasch [28], Pettie [31]) If P is light, the number of ones in M is at most n2α(n)O(k) . We define the tensor product between matrices as follows: M ⊗ G is the matrix obtained by replacing each one-entry of M by a copy of G, and replacing each zero-entry of M by an all-zero matrix equal in size with G. Suppose that M contains P . A bounding box B of P is a minimal submatrix MI,J such that P is contained in B, and I and J are sets of consecutive columns, resp. rows. We denote min(I), max(I), min(J), max(J), as B.xmin, B.xmax , B.ymin, B.ymax , respectively. 3 Greedy is input-revealing In this section, we prove Theorems 1.1, 1.4, 1.6 and 1.7. We refer to § 1.1 for definitions of pattern-avoiding, k-decomposable and k-increasing permutations. To bound the cost of algorithm A, we show that AT (X) (or A(X) if preprocessing is allowed) avoids some pattern. In the following, Inck, Deck, and Altk are permutation matrices of size k, and Cap is a light matrix. These matrices will be defined later. 8 Lemma 3.1. Let X be an access sequence. (i) If X avoids a permutation P of size k, then for any initial tree T , GreedyRightT (X), GreedyLeftT (X) (ii) If X is k-increasing (k-decreasing), then for any initial tree T , GreedyT (X) avoids (k, . . . , 1)⊗Deck+1 (iii) If X is k-decomposable, then Greedy(X) avoids P ⊗ Altk+4 for all simple permutations P of size at and GreedyT (X) avoid P ⊗ (1, 2), P ⊗ (2, 1) and P ⊗ Cap respectively. ((1, . . . , k) ⊗ Inck+1). least k + 1. The application of Lemma 2.6 is sufficient to complete all the proofs, together with the observation that, for any permutation matrix P of size k × k, if G is a permutation (resp. light) matrix of size (cid:96) × (cid:96), then P ⊗ G is a permutation (resp. light) matrix of size k(cid:96) × k(cid:96). The rest of this section is devoted to the proof of Lemma 3.1. We need the definition of the input-revealing gadget which is a pattern whose existence in the touch matrix (where access points are indistinguishable from touch points) gives some information about the locations of access points. Definition 3.2 (Input-revealing gadgets). Let X be an access matrix, A be an algorithm and A(X) be the touch matrix of A running on X. -- Capture Gadget. A pattern P is a capture gadget for algorithm A if, for any bounding box B of P in A(X), there is an access point p ∈ B. -- Monotone Gadget. A pattern P is a k-increasing (k-decreasing) gadget for algorithm A if, for any bounding box B of P in A(X), either (i) there is an access point p ∈ B or, (ii) there are k access points p1, . . . , pk such that B.ymin ≤ p1.y < ··· < pk.y ≤ B.ymax and p1.x < ··· < pk.x < B.xmin (p1.x > ··· > pk.x > B.xmax ). In words, p1, . . . , pk form the pattern (1, . . . , k) (resp. (k, . . . , 1)). -- Alternating Gadget. A pattern P is a k-alternating gadget for algorithm A if, for any bounding box B of P in A(X), either (i) there is an access point p ∈ B or, (ii) there are k access points p1, . . . , pk such that B.ymin ≤ p1.y < ··· < pk.y ≤ B.ymax and B.xmax < pi.x for all odd i and pi.x < B.xmin for all even i. Notice that if we had a permutation capture gadget G for algorithm A, we would be done: If X avoids pattern Q, then AT (X) avoids Q⊗G and forbidden submatrix theory applies. With arbitrary initial tree T , it is impossible to construct a permutation capture gadget for Greedy even for 2-decomposable sequences (see Appendix G.1). Instead, we define a light capture gadget for Greedy for any sequence X and any initial tree T . Additionally, we construct permutation monotone and alternating gadgets. After a preprocessing step, we can use the alternating gadget to construct a permutation capture gadget for k-decomposable sequences. (i) (12) is a capture gadget for GreedyRight and (21) is a capture gadget for GreedyLeft. Lemma 3.3. (ii) Cap is a capture gadget for Greedy where Cap = ( (iii) Inck+1 (Deck+1) is a k-increasing (k-decreasing) gadget for Greedy where Inck = (k, . . . , 1) and •• • ). Deck = (1, 2, . . . , k). (iv) Deck+1 (Inck+1) is a capture gadget for Greedy that runs on k-increasing (k-decreasing) sequence. (v) Altk+1 is a k-alternating gadget for Greedy where Altk = ((cid:98)(k + 1)/2(cid:99) , k, 1, k − 1, 2, . . . ). (vi) Altk+4 is a capture gadget for Greedy that runs on k-decomposable sequence without initial tree. (cid:32) • • (cid:33) • • • For example, Alt5 = . We emphasize that only result (vi) requires a preprocessing. Given Lemma 3.3, and the fact that k-increasing, k-decreasing, and k-decomposable sequences avoid (k, . . . , 1), (1, . . . , k), resp. all simple permutations of size at least k + 1, Lemma 3.1 follows immediately. Proof. We only show the proofs for (i) and (ii) in order to convey the flavor of the arguments. The other proofs are more involved. See Appendix B.2 for proofs of (iii),(iv), and Appendix C.2 for proofs of (v),(vi). (i) We only prove for GreedyRight. Let a, b be touch points in GreedyRightT (X) such that a.y < b.y and form (1, 2) with a bounding box B. As a.y = τ (a.x, a.y) ≥ τ (b.x, a.y), by Lemma 2.4 (i), b.x is hidden in (a.x, b.x] after a.y. Suppose that there is no access point in B = (cid:3)ab, then b cannot be touched, which is a contradiction. 9 (ii) Let a, b, c be touch points in GreedyT (X) such that a.x < b.x < c.x and a, b, c form Cap with bounding box B. As τ (a.x, a.y), τ (c.x, a.y) ≥ τ (b.x, a.y), by Lemma 2.4 (iii), b.x is hidden in (a.x, c.x) after a.y. Suppose that there is no access point in B, then b cannot be touched, which is a contradiction. 4 Decomposition theorem and applications In this section, we take a deeper look at decomposable permutations and investigate whether Greedy is "decomposable", in the sense that one can bound the cost of Greedy on input sequences by summing over local costs on blocks. Proving such a property for Greedy seems to be prohibitively difficult (we illustrate this in Appendix G.1). Therefore, we propose a more "robust" but offline variant of Greedy which turns out to be decomposable. We briefly describe the new algorithm, and state the main theorems and three applications, leaving the details to Appendix D. Recursive decomposition. We refer the reader to § 1.1 for the definitions of blocks and recursive de- composition. Let S be a k-decomposable permutation access sequence, and let T be its (not necessarily unique) decomposition tree (of arity at most k). Let P be a block in the decomposition tree T of S. Consider the subblocks P1, P2, . . . , Pk of P , and let P denote the unique permutation of size [k] that is order-isomorphic to a sequence of arbitrary representative elements from the blocks P1, P2, . . . , Pk. We de- note P = P [P1, P2, . . . , Pk] a deflation of P , and we call P the skeleton of P . Visually, P is obtained from P by contracting each block Pi to a single point. We associate with each block P (i.e. each node in T ) both the corresponding rectangular region (in fact, a square), and the corresponding skeleton P (Figure 1). We denote the set of leaves and non-leaves of the tree T by L(T ) and N (T ) respectively. Consider the k subblocks P1, . . . , Pk of a block P in this decomposition, numbered by increasing y- coordinate. We partition the rectangular region of P into k2 rectangular regions, whose boundaries are aligned with those of P1, . . . , Pk. We index these regions as R(i, j) with i going left to right and j going bottom to top. In particular, the region R(i, j) is aligned (same y-coordinates) with Pj. A robust version of Greedy. The main difficulty in analyzing the cost of Greedy on decomposable ac- cess sequences is the "interference" between different blocks of the decomposition. Our RGreedy algorithm is an extension of Greedy. Locally it touches at least those points that Greedy would touch; additionally it may touch other points, depending on the recursive decomposition of the access sequence (this a priori knowledge of the decomposition tree is what makes RGreedy an offline algorithm). The purpose of touching extra points is to "seal off" the blocks, limiting their effect to the outside. We now define the concept of topwing. The topwing of a rectangular region R at a certain time in the execution of RGreedy contains a subset of the points in R (at most one in each column). A point is in the topwing if it forms an empty rectangle with the top left or the top right corner of R (this definition includes the topmost touch point of the leftmost and rightmost columns of R, if such points exist in R). When accessing an element at time t, RGreedy touches the projections to the timeline t of the topwings of all regions R(i, j) aligned with a block Pj ending at time t (this includes the region of Pj itself). Observe that multiple nested blocks might end at the same time, in this case we process them in increasing order of their size. See Figure 4 for an illustration of RGreedy. Theorem 4.1 (Decomposition theorem, Theorem D.2). For any decomposition tree T of a permutation P , the total cost of RGreedy is bounded as Greedy( P ) + Greedy(P ) + 3n. RGreedy(P ) ≤ 4 · (cid:88) P∈N (T ) (cid:88) P∈L(T ) can say that the cost of RGreedy on P is RGreedy(P ) ≤ 4 · Greedy( P ) +(cid:80) Application 1: Cole et al.'s "showcase" sequences. This sequence can be defined as a permutation P = P [P1, . . . , Pn/ log n] where each Pj is the permutation (1, . . . , log n), i.e. a sequential access. It is known that Greedy is linear on sequential access, so Greedy(Pj) = O(log n). Now, by applying Theorem 4.1, we Greedy(Pj) + O(n) ≤ log n O(log n) + O(n) = O(n). This implies the linear optima of this class of sequences. log n )) + n O( n log n · log( n j 10 Figure 4: Illustration of RGreedy. Left: region with points and topwing highlighted. Right: a sample run of RGreedy on a 2-decomposable input. Access points are dark circles, points touched by Greedy are gray circles, points touched by the RGreedy augmentation are gray squares. The access point in the topmost line completes the black square and also the enclosing gray square. The topwing of the black square consists of the black circle at position (1,6) and the gray circle at (3,5). Therefore the augmentation of the black square adds the gray square at (3,6). The topwing of R(2, 2) consists of the gray circle at (4,4) and hence the gray square at (4,6) is added. The topwing of the gray square consists of points (1,6) and (6,3); the point (4,4) does not belong to the topwing because (4,6) has already been added. Therefore, the gray square at (6,6) is added. Application 2: Simple permutations as the "core" difficulty of BST inputs. We prove that, if Greedy is c-competitive on simple permutations, then RGreedy is O(c)-approximate for all permutations. To prove this, we consider a block decomposition tree T in which the permutation corresponding to every node is simple. Using Theorem 4.1 and the hypothesis that Greedy is c-competitive for simple permutations: RGreedy(P ) ≤ 4c · (cid:88) OPT( P ) + c · (cid:88) P∈N (T ) P∈L(T ) OPT(P ) + 3n. that OPT(P ) ≥(cid:80) Now we decompose OPT into subproblems the same way as done for RGreedy. We prove in Lemma D.4 P∈T OPT(P )−2n. Combined with Theorem 4.1 this yields RGreedy(P ) ≤ 4c·OPT(P )+ (8c + 3)n. Using Theorem 2.1 we can extend this statement to arbitrary access sequences. sum(cid:80) Application 3: Recursively decomposable permutations. Let X be a k-decomposable permutation. Then there is a decomposition tree T of X in which each node is a permutation of size at most k. Each block P ∈ L(T ) ∪ N (T ) has Greedy(P ) = O(P log P) = O(P log k). By standard charging arguments, the P∈N (T )∪L(T ) P = O(n), so the total cost of RGreedy is O(n log k); see the full proof in Appendix D. We remark that the logarithmic dependence on k is optimal (Proof in Appendix G.2), and that Greedy asymptotically matches this bound when k is constant (Theorem 1.4). 11 5 Discussion and open questions Besides the long-standing open question of resolving dynamic optimality, our work raises several new ones in the context of pattern avoidance. We list some that are most interesting to us. Can the bound of Theorem 1.1 be improved? While our input-revealing techniques are unlikely to yield a linear bound (Appendix G.1), a slight improvement could come from strengthening Lemma 2.6(ii) for the special kind of light matrices that arise in our proof. √ An intriguing question is whether there is a natural characterization of all sequences with linear optimum. How big is the overlap between "easy inputs" and inputs with pattern avoidance properties? We have shown that avoidance of a small pattern makes sequences easy. The converse does not hold: There is a permutation X ∈ Sn with k(X) = n but for which Greedy(X) = O(n); see Appendix G.4. Note that our pattern-avoiding properties are incomparable with the earlier parametrizations (e.g. dynamic finger); see Appendix G.4. Is there a parameter that subsumes both pattern-avoidance and dynamic finger? A question directly related to our work is to close the gap between OPT = O(n log k) and n2O(k2) by Greedy on k-decomposable sequences (when k = ω(1)). Matching the optimum (if at all possible) likely requires novel techniques: splay is not even known to be linear on preorder sequences with preprocessing, and with forbidden-submatrix-arguments it seems impossible to obtain bounds beyond11 O(nk). We proved that if Greedy is optimal on simple permutations, then RGreedy is optimal on all access sequences. Can some property of simple permutations12 be algorithmically exploited? Can RGreedy be made online? Can our application for Cole's showcase sequence be extended in order to prove the dynamic finger property for Greedy? Finally, making further progress on the traversal conjecture will likely require novel ideas. We propose a simpler question that captures the barrier for three famous conjectures: traversal, deque, and split (Ap- pendix G.5). Given any initial tree T , access a preorder sequence defined by a path P (a BST where each non-leaf node has a single child). Prove a linear bound for your favorite online BST! 11An n-by-n matrix avoiding all permutations of size at least k can contain Ω(nk) ones. 12Note that simple permutations can have linear cost. In Appendix G.4 we show such an example. 12 References [1] Daniel Bienstock and Ervin Gyori. An extremal problem on sparse 0-1 matrices. SIAM J. Discrete Math., 4(1):17 -- 27, 1991. 6 [2] Prosenjit Bose, Jonathan F Buss, and Anna Lubiw. Pattern matching for permutations. Information Processing Letters, 65(5):277 -- 283, 1998. 3, 6 [3] Robert Brignall. A survey of simple permutations. CoRR, abs/0801.0963, 2008. 3, 20, 25 [4] Marie-Louise Bruner and Martin Lackner. The computational landscape of permutation patterns. CoRR, abs/1301.0340, 2013. 6 [5] Mihai Badoiu, Richard Cole, Erik D. Demaine, and John Iacono. A unified access bound on comparison- based dynamic dictionaries. Theoretical Computer Science, 382(2):86 -- 96, August 2007. Special issue of selected papers from the 6th Latin American Symposium on Theoretical Informatics, 2004. 33 [6] P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn, and T. Saranurak. Greedy is an almost optimal deque. WADS, 2015. 2 [7] P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn, and T. Saranurak. Self-adjusting binary search trees: What makes them tick? ESA, 2015. 2 [8] R. Chaudhuri and H. Hoft. Splaying a search tree in preorder takes linear time. SIGACT News, 24(2):88 -- 93, April 1993. 1 [9] R. Cole. On the dynamic finger conjecture for splay trees. part ii: The proof. SIAM Journal on Computing, 30(1):44 -- 85, 2000. 1, 2 [10] Richard Cole, Bud Mishra, Jeanette Schmidt, and Alan Siegel. On the dynamic finger conjecture for splay trees. part i: Splay sorting log n-block sequences. SIAM J. Comput., 30(1):1 -- 43, April 2000. 1, 2, 5, 25 [11] Erik D. Demaine, Dion Harmon, John Iacono, Daniel M. Kane, and Mihai Patrascu. The geometry of binary search trees. In SODA 2009, pages 496 -- 505, 2009. 1, 3, 4, 6, 7, 18 [12] Erik D. Demaine, Dion Harmon, John Iacono, and Mihai Patrascu. Dynamic optimality - almost. SIAM J. Comput., 37(1):240 -- 251, 2007. 1 [13] Erik D. Demaine, John Iacono, Stefan Langerman, and Ozgur Ozkan. Combining binary search trees. In Automata, Languages, and Programming - 40th International Colloquium, ICALP 2013, Riga, Latvia, July 8-12, 2013, Proceedings, Part I, pages 388 -- 399, 2013. 6 [14] Jacob Fox. Stanley-Wilf limits are typically exponential. CoRR, pages -- 1 -- 1, 2013. 8 [15] Kyle Fox. Upper bounds for maximally greedy binary search trees. In WADS 2011, pages 411 -- 422, 2011. 1, 2 [16] Zolt´an Furedi. The maximum number of unit distances in a convex n-gon. J. Comb. Theory, Ser. A, 55(2):316 -- 320, 1990. 6 [17] George F. Georgakopoulos. Chain-splay trees, or, how to achieve and prove loglogn-competitiveness by splaying. Inf. Process. Lett., 106(1):37 -- 43, 2008. 6 [18] Dion Harmon. New Bounds on Optimal Binary Search Trees. PhD thesis, Massachusetts Institute of Technology, 2006. 7 13 [19] John Iacono. In pursuit of the dynamic optimality conjecture. In Space-Efficient Data Structures, Streams, and Algorithms, volume 8066 of Lecture Notes in Computer Science, pages 236 -- 250. Springer Berlin Heidelberg, 2013. 6 [20] S. Kitaev. Patterns in Permutations and Words. Monographs in Theoretical Computer Science. An EATCS Series. Springer, 2011. 1, 6 [21] Donald E. Knuth. The Art of Computer Programming, Volume I: Fundamental Algorithms. Addison- Wesley, 1968. 1, 6 [22] Donald E. Knuth. Optimum binary search trees. Acta Informatica, 1(1):14 -- 25, 1971. 1 [23] Joan M. Lucas. Canonical forms for competitive binary search tree algorithms. Tech. Rep. DCS-TR-250, Rutgers University, 1988. 1 [24] Joan M. Lucas. On the competitiveness of splay trees: Relations to the union-find problem. On- line Algorithms, DIMACS Series in Discrete Mathematics and Theoretical Computer Science, 7:95 -- 124, 1991. 34 [25] Adam Marcus and G´abor Tardos. Excluded permutation matrices and the Stanley-Wilf conjecture. Journal of Combinatorial Theory, Series A, 107(1):153 -- 160, 2004. 8 [26] Kurt Mehlhorn. Nearly optimal binary search trees. Acta Informatica, 5(4):287 -- 295, 1975. 1 [27] J.Ian Munro. On the competitiveness of linear search. In Mike S. Paterson, editor, Algorithms - ESA 2000, volume 1879 of Lecture Notes in Computer Science, pages 338 -- 345. Springer Berlin Heidelberg, 2000. 1 [28] Gabriel Nivasch. Improved bounds and new techniques for davenport -- schinzel sequences and their generalizations. J. ACM, 57(3), 2010. 8 [29] Seth Pettie. Splay trees, Davenport-Schinzel sequences, and the deque conjecture. In Proceedings of the Nineteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '08, pages 1115 -- 1124, Philadelphia, PA, USA, 2008. Society for Industrial and Applied Mathematics. 1, 2, 6 [30] Seth Pettie. Applications of forbidden 0-1 matrices to search tree and path compression-based data structures. In Proceedings of the Twenty-First Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2010, Austin, Texas, USA, January 17-19, 2010, pages 1457 -- 1467. SIAM, 2010. 2, 6 [31] Seth Pettie. Sharp bounds on formation-free sequences. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2015, San Diego, CA, USA, January 4-6, 2015, pages 592 -- 604, 2015. 8 [32] Vaughan R. Pratt. Computing permutations with double-ended queues, parallel stacks and parallel In Proceedings of the Fifth Annual ACM Symposium on Theory of Computing, STOC '73, queues. pages 268 -- 277, New York, NY, USA, 1973. ACM. 6 [33] James H. Schmerl and William T. Trotter. Critically indecomposable partially ordered sets, graphs, tournaments and other binary relational structures. Discrete Mathematics, 113(13):191 -- 205, 1993. 20 [34] Daniel Dominic Sleator and Robert Endre Tarjan. Self-adjusting binary search trees. J. ACM, 32(3):652 -- 686, July 1985. 1, 2, 34 [35] Robert Endre Tarjan. Sorting using networks of queues and stacks. J. ACM, 19(2):341 -- 346, April 1972. 6 [36] Robert Endre Tarjan. Sequential access in splay trees takes linear time. Combinatorica, 5(4):367 -- 378, 1985. 1, 2, 34 14 [37] Vincent Vatter. Permutation classes. CoRR, abs/1409.5159, 2014. 1, 6 [38] Chengwen C. Wang, Jonathan C. Derryberry, and Daniel D. Sleator. O(log log n)-competitive dynamic binary search trees. In Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithm, SODA '06, pages 374 -- 383, Philadelphia, PA, USA, 2006. Society for Industrial and Applied Mathematics. 2, 6 [39] R. Wilber. Lower bounds for accessing binary search trees with rotations. SIAM Journal on Computing, 18(1):56 -- 67, 1989. 4, 7, 31 15 A Warmup: A direct proof for preorder sequences In this section we show that the cost of Greedy on an arbitrary preorder access sequence is linear. In other words, we give a direct proof of Corollary 1.5. We assume the preprocessing discussed in § 2, or equivalently, in geometric view we assume that Greedy runs with no initial tree13, i.e. initially all stairs are empty. The proof is intended as a warmup, to develop some intuition about the geometric model and to familiarize with the concepts of wings and hidden elements used in the subsequent proofs. We remark that an alternative proof of the same result (up to the same constants) can be obtained using forbidden submatrix arguments. Preorder sequences. The class PreOrdn of preorder sequences of length n can be defined recursively as follows. A permutation sequence X = (x1, . . . , xn) belongs to PreOrdn if (i)X = n = 1 or (ii) there is a number n(cid:48) < n, such that • L(X) = (x2, . . . , xn(cid:48)) ∈ PreOrdn(cid:48)−1, • R(X) = (xn(cid:48)+1, . . . , xn) ∈ PreOrdn−n(cid:48), • max{L(X)} < x1 < min{R(X)}. We remark again the well-known fact that preorder sequences are exactly the (2, 3, 1)-free permutations, and the easily verifiable fact that preorder sequences are 2-decomposable (see Figure 5 for an illustration). Figure 5: Preorder sequence with sets L and R, with wingL(a) highlighted. Observe that point a together with L can form a single block. We prove the following theorem. Theorem A.1. Let X ∈ PreOrdn. Then Greedy(X) ≤ 4n. A.1 Wings and hidden elements Let X ∈ PreOrdn. For an arbitrary element a ∈ X, let ta denote its access time. Let La denote the maximal contiguous subsequence of X immediately after a, that consists of elements smaller than a. Let ra ∈ X be the smallest element that is larger than a and precedes a in X. By convention, ra is ∞ if there are no elements larger than a that precede a in X. Let Ra denote the maximal contiguous subsequence after La of elements larger than a and smaller than ra. Let Ta be the concatenation of La and Ra. Let lca(b, c) denote the last element a, such that b, c ∈ Ta. We define wingL(a) to contain all elements b ∈ La such that the rectangle with corners (b, tb), (a, ta) contains no other access point. Symmetrically, we define wingR(a) to contain all elements b ∈ Ra such that the rectangle with corners (b, tb), (a, ta) contains no other access point (Figure 5). Lemma A.2. The sets {wingL(a)}a∈[n] are disjoint. Similarly, the sets {wingR(a)}a∈[n] are disjoint. 13Curiously, in the case of Greedy and preorder sequences this has the same effect as if the initial tree would be exactly the tree that generated the input sequence. 16 Proof. Assume for contradiction that there are two elements a, a(cid:48) ∈ [n] such that wingL(a)∩ wingL(a(cid:48)) (cid:54)= ∅. Assume w.l.o.g. that a < a(cid:48). By definition, wingL(a) only contains elements in La, so there must be an element b ∈ La ∩ La(cid:48), such that b < a < a(cid:48) and tb > ta and tb > t(cid:48) a. There are two possibilities: either ta > t(cid:48) a, contradicting the fact that the rectangle with corners (a(cid:48), t(cid:48) a), (b, tb) is empty, or ta < t(cid:48) a, in which case the subsequence (a, a(cid:48), b) is order-isomorphic to (2, 3, 1), contradicting the fact that X is a preorder sequence. The reader might find it instructive to see the corresponding situation in tree-view. Figure 6 shows a proof by picture in the tree corresponding to the preorder sequence X. Figure 6: BST corresponding to a preorder sequence. Left wings of elements indicated as shaded rectangles. Corollary A.3. (cid:80) a(wingL(a) + wingR(a)) ≤ 2n. Next we restate and prove Lemma 2.4 about hidden elements. Recall that τ (x, t − 1) denotes the last time strictly before t when x is touched. Definition A.4 (Definition 2.3). For any algorithm A, an element x is hidden in range [w, y] after t if, given that there is no access point a ∈ [w, y] × (t, t(cid:48)] for any t(cid:48) > t, then x will not be touched by A in time (t, t(cid:48)]. Greedy and GreedyRight respectively. Lemma A.5 (Lemma 2.4). Let x be some element. (i) If there is an element w < x where τ (w, t) ≥ τ (x, t), then x is hidden in (w, n] and (w, x] after t for (ii) If there is an element y > x where τ (y, t) ≥ τ (x, t), then x is hidden in [1, y) and [x, y) after t for (iii) If there are elements w, y where w < x < y, and τ (w, t), τ (y, t) ≥ τ (x, t), then x is hidden in (w, y) Greedy and GreedyLeft respectively. after t for Greedy. Proof. (i) Consider any t(cid:48) > t. For the case of Greedy, assume that there is no access point in (w, n] × (t, t(cid:48)]. Suppose x is touched in the time interval (t, t(cid:48)], and let (p, tp) be the first access point in this time interval that causes the touching of x. Then p ∈ [1, w], and tp ∈ (t, t(cid:48)]. As x is not touched in the time interval (t, tp) by the choice of p, we have that τ (x, tp − 1) = τ (x, t). If τ (w, t) ≥ τ (x, t), then the rectangle with corners (p, tp), and (x, τ (x, tp− 1)) contains the point (w, τ (w, t)), and thus it is satisfied before accessing p. Therefore, the accessing of p via Greedy does not touch x, a contradiction. It follows that x is hidden in (w, n] for Greedy after t. For the case of GreedyRight, assume that there is no access point in (w, x] × (t, t(cid:48)]. Suppose x is touched in the time interval (t, t(cid:48)], and let (p, tp) be the first access point in this time interval that causes the touching of x. Then p ∈ [1, w], and tp ∈ (t, t(cid:48)]. (The case p ∈ (x, n] is not possible for GreedyRight, since p < x must hold.) The remainder of the argument is the same as for Greedy. (ii) The argument is symmetric to (i). 17 (iii) Consider any t(cid:48) > t. Assume that there is no access point in (w, y)× (t, t(cid:48)]. Suppose x is touched in the time interval (t, t(cid:48)], and let (p, tp) be the first access point in this time interval that causes the touching of x. There are two cases. If p ∈ [1, w], we use the argument of (i). If p ∈ [y, n], we use the argument of (ii). A.2 Bounding the cost of Greedy Lemma A.6. For any element c ∈ La\wing L(a), a is not touched when accessing c using Greedy. Similarly for c ∈ Ra \ wingR(a). Proof. There must be an access point b, such that c < b < a and ta < tb < tc, for otherwise c would be in wing L(a). Since τ (b, tb) ≥ τ (a, tb), it follows that a is hidden in (b, n] after tb. All accesses in the interval (tb, tc] are in [c, b). Hence, a is not touched. Corollary A.7. Let a be any element. Greedy touches a when accessing elements in Ta at most wingL(a)+ wingR(a) times. Lemma A.8. Let a be any element. Greedy touches a when accessing elements outside Ta at most once. Proof. No element is touched before it is accessed. Since the elements in Ta are accessed consecutively, we only need to consider accesses after all elements in Ta have been accessed. All such accesses are to elements to the right of Ta. Let c be the first element accessed after the last access to an element in Ta and let b = lca(a, c). Then a ∈ Lb, and c is the first element in Rb. Since Tc contains all elements in (b, c], Greedy does not touch any element in (b, c] before time tc. Let d be the element in (a, b] with largest time τ (d, tc − 1). If there are several such d, let d be the rightmost such element. Since no element in (b, c] is accessed before time tc, d is also the rightmost element in (a, c] with largest time τ (d, tc − 1). The rectangle with corners (d, τ (d, tc − 1)) and (c, tc) contains no other point and hence d is touched at time tc. Clearly, τ (a, tc) ≤ tc = τ (d, tc). Thus a is hidden in [1, d) after time tc and hence a is not touched after wingR(a) + 1 times, so the total cost is at most(cid:80) Corollary A.7 and Lemma A.8 together imply that each element a is only touched at most wingL(a) + a∈[n](wingL(a) + wingR(a) + 2) ≤ 4n. This concludes time tc. the proof of Theorem A.1. B Access sequences with initial trees B.1 Initial trees. In the BST model, the initial tree is the state of the BST before the first element is accessed. In the tree-view of BST execution, we know the structure of the tree exactly in every time step, and hence the structure of the initial tree as well. This is less obvious, however, in the geometric view. In fact, according to the reduction of DHIKP, the initial tree is always a split tree [11], hidden from us in geometric view. We show how to "force" an arbitrary initial tree into the geometric view of BST execution. First, we observe a simple fact. Given a binary search tree T , we denote the search path of an element a in T as path(a, T ). It is easy to show that two BSTs T1 and T2, containing [n], have the same structure iff path(a, T1) = path(a, T2) as a set, for all a ∈ [n]. The stair of an element is, in some sense, the geometric view of the search path. Indeed, path(a, T ) = {b b is touched if a is accessed in T}. Similarly, stairt(a) = {b b is touched if a is accessed at time t}. Thus, to model an initial tree T into the geometric view, it is enough to enforce that stair1(a) = path(a, T ). We can achieve this in a straightforward way, by putting stacks of points in each column below the first row, corresponding to the structure of the initial tree T . More precisely, in column x we put a stack of height 18 d − d(x) + 1, where d(x) is the depth of element x in T , and d is the maximum depth of an element (Figure 2). One can easily show that stair1(a) = path(a, T) for all a ∈ [n]. We remark that the points representing the initial tree are not counted in the cost. B.2 k-increasing sequences We prove Lemma 3.3 (iii) and (iv). Lemma B.1 (Lemma 3.3(iii)). Inck+1 (Deck+1) is a k-increasing (k-decreasing) gadget for Greedy where Inck = (k, . . . , 1) and Deck = (1, 2, . . . , k). Proof. We only prove that Inck+1 is a k-increasing gadget. Let q0, . . . , qk be touch points in GreedyT (X) such that qi.y < qi+1.y for all i and form Inck+1 with bounding box B. Note that, for all 1 ≤ i ≤ k, we can assume that there is no touch point q(cid:48) i.y < qi.y, otherwise we can choose i instead of qi. So, for any t ∈ [qi−1.y, qi.y) we have that τ (qi−1.x, t) ≥ τ (qi.x, t) for all 1 ≤ i ≤ k. Suppose q(cid:48) that there is no access point in B. By Lemma 2.4 (ii), q1.x is hidden in [1, q0.x) after q0.y. So there must be an access point p1 ∈ [1, B.xmin)× (q0.y, q1.y], otherwise q1 cannot be touched. We choose such p1 where p1.x is maximized. If p1.y < q1.y, then τ (p1.x, p1.y), τ (q0.x, p1.y) ≥ τ (q1.x, p1.y). So by Lemma 2.4 (iii), q1.x is hidden in (p1.x, q0.x) after p1.y and hence q1 cannot be touched, which is a contradiction. So we have p1.y = q1.y and p1.x < B.xmin. i.x = qi.x and qi−1.y < q(cid:48) i where q(cid:48) Next, we prove by induction from i = 2 to k that, given the access point pi−1 where pi−1.y = qi−1.y and pi−1.x < B.xmin, there must be an access point pi where pi.y = qi.y and pi−1.x < pi.x < B.xmin. Again, by Lemma 2.4 (iii), there must be an access point pi ∈ (pi−1.x, qi−1.x)× (qi−1.y, qi.y] otherwise qi cannot be touched. We choose the point pi where pi.x is maximized. If pi.y < qi.y, then τ (pi.x, pi.y), τ (qi−1.x, pi.y) ≥ τ (qi.x, pi.y). So by Lemma 2.4 (iii), qi.x is hidden in (pi.x, qi−1.x) after pi.y and hence qi cannot be touched. So we have pi.y = qi.y and pi−1.x < pi.x < B.xmin. Therefore, we get p1.x < ··· < pk.x < B.xmin which concludes the proof. Lemma B.2 (Lemma 3.3(iv)). Deck+1 (Inck+1) is a capture gadget for Greedy that runs on k-increasing (k-decreasing) sequence. Proof. We only prove that Inck+1 is a capture gadget for Greedy running on k-decreasing sequence X. Since Inck+1 is an increasing gadget, if Inck+1 appears in GreedyT (X) with bounding box B, then either there is an access point in B or there are access points forming (1, 2, . . . , k). The latter case cannot happen because X avoids (1, 2, . . . , k). So Inck+1 is a capture gadget. C Access sequences without initial trees: k-decomposable permu- tations C.1 Pattern avoidance and recursive decomposability We restate and prove Lemma 1.3 that connects the k-decomposability of a permutation with pattern avoid- ance properties. Lemma C.1 (Extended form of Lemma 1.3). Let P be a permutation, and let k be an integer. The following statements are equivalent: (i) P is k-decomposable, (ii) P avoids all simple permutations of size at least k + 1, (iii) P avoids all simple permutations of size k + 1 and k + 2. 19 Proof. (ii) =⇒ (iii) is obvious. (iii) =⇒ (ii) follows from the result of Schmerl and Trotter [33] that every simple permutation of length n contains a simple permutation of length n − 1 or n − 2, and the simple observation that if P avoids Q, then P also avoids all permutations containing Q. (ii) =⇒ (i) follows from the observation that a permutation P contains all permutations in its block decomposition tree TP . Further, it is known [3] that every permutation P has a block decomposition tree TP in which all nodes are simple permutations. If P contains no simple permutation of size k + 1 or more, it must have a block decomposition tree in which all nodes are simple permutations of size at most k, it is therefore, k-decomposable. (i) =⇒ (ii): we show the contrapositive ¬(ii) =⇒ ¬(i). Indeed, if P contains a simple permutation Q of size at least k + 1, then any k-decomposition of P would induce a k-decomposition of Q, contradicting the fact that Q is simple. C.2 k-decomposable permutations We prove Lemma 3.3 (v) and (vi). We refer to § 3 for the necessary definitions. We show an example of the gadget Altk:  • • • •  . • • • Alt7 = Lemma C.2 (Lemma 3.3(v)). Altk+1 is a k-alternating gadget for Greedy where Altk = ((cid:98)(k + 1)/2(cid:99) , k, 1, k− 1, 2, . . . ). For odd i, by Lemma 2.4 (i), qi.x is hidden in (qi−1.x, n] after qi−1.y. So there must be an access point Proof. Let q0, . . . , qk be touch points in Greedy(X) such that qi.y < qi+1.y for all i and form Altk+1 with bounding box B. Suppose that there is no access point in B. We prove for i = 1, . . . , k, that there exists an access point pi ∈ (B.xmax , n]× (qi−1.y, qi.y] for odd i, and pi ∈ [1, B.xmin) × (qi−1.y, qi.y] for even i. pi ∈ (B.xmax , n] × (qi−1.y, qi.y], otherwise qi cannot be touched. pi ∈ [1, B.xmin) × (qi−1.y, qi.y], otherwise qi cannot be touched. For even i, by Lemma 2.4 (ii), qi.x is hidden in [1, qi−1.x) after qi−1.y. So there must be an access point Observe that p1, . . . , pk satisfy B.ymin ≤ p1.y < ··· < pk.y ≤ B.ymax and B.xmax < pi.x for all odd i and pi.x < B.xmin for all even i, fulfilling the condition of Definition 3.2. Hence, Altk+1 is a k-alternating gadget. Lemma C.3 (Lemma 3.3(vi)). Altk+4 is a capture gadget for Greedy that runs on k-decomposable sequence without initial tree. Proof. Let X be a k-decomposable permutation. Since Altk+4 is a (k + 3)-alternating gadget, if Altk+4 appears in Greedy(X) with bounding box B, then either there is an access point in B or there are access points p1, p2, . . . , pk+3, satisfying the conditions B.ymin ≤ p1.y < ··· < pk+3.y ≤ B.ymax and B.xmax < pi.x for odd i and pi.x < B.xmin for even i. Suppose there is no access point in B. Let q0, q1, . . . , qk+3 denote the points that form Altk+4 (where q0.y < q1.y < ··· < qk+3.y), and let us denote P = {p1, . . . , pk+3}. Let T be a block decomposition tree of X of arity at most k. We look at each block P ∈ T as a minimal rectangular region in the plane that contains all access points in the block. Let P ∗ be the smallest block in T that contains two distinct access points pi, pj ∈ P such that i is odd, Observe first that the bounding box of P ∗ must contain or intersect both vertical sides of B, otherwise it could not contain points on both sides of B. Furthermore, the bottom horizontal side of B must be contained entirely in the bounding box of P ∗: If that were not the case, then there would be no accesses below B, and j is even. (Observe that pi is to the right of B, and pj is to the left of B.) 20 and q0 (the lowest point of Altk+4) would not be touched by Greedy (since there is no initial tree). The following is the key observation of the proof. Lemma C.4. Let k(cid:48) be the largest integer such that P ∗ contains q0, . . . , qk(cid:48). Then, k(cid:48) < k + 1. In words, P ∗ contains at most the k + 1 lowest points of Altk+4. Proof. Let P ∗ = P (P1, . . . , Pk) be the decomposition of P ∗ into at most k blocks. We claim that each block Pj can contain at most one point from P. First, by the minimality of P ∗, each block Pj never contains two access points from P from different sides of B; and Pj cannot contain two points from P from the same side of B either, because assuming otherwise that Pj contains two points from P from the left of B, it would follow that there is another access point (a, t) ∈ P on the right of B outside of Pj such that (Pj).ymin < t < (Pj).ymax , contradicting that Pj is a block. Observe further that, except for the block containing p1, each block Pj cannot overlap with B. Since we have at most k such blocks in the decomposition, and because qi.y ≥ pi.y for all i, it follows that the top boundary of P ∗ must be below qk+1. Since the bounding box of P ∗ contains (at best) the first k+1 points of Altk+4, the three remaining points of Altk+4 need to be touched after the last access in P ∗. In the following we show that this is impossible. Let (L, tL) be the topmost access point inside P ∗ to the left of B, such that there is a touch point inside B at time tL. Let (R, tR) be the topmost access point inside P ∗ to the right of B, such that there is a touch point inside B at time tR. Let L(cid:48) be the rightmost element inside B touched at time tL, and let R(cid:48) be the leftmost element inside B touched at time of tR. Lemma C.5. After time tL, within the interval [B.xmin, L(cid:48)], only L(cid:48) can be touched. Similarly, after time tR, within the interval [R(cid:48), B.xmax ], only R(cid:48) can be touched. Proof. Let L(cid:48)(cid:48) be the rightmost touched element in [L, B.xmin) at time tL, and let R(cid:48)(cid:48) be the leftmost touched element in (B.xmax , R] at time tR. We have that τ (L(cid:48)(cid:48), tL), τ (L(cid:48), tL) ≥ τ (x, tL), for any x ∈ [B.xmin, L(cid:48)). Thus, any x ∈ [B.xmin, L(cid:48)) is hidden in (L(cid:48)(cid:48), L(cid:48)) after tL. Above P ∗ there can be no access to an element in [L(cid:48)(cid:48), L(cid:48)], since that would contradict the fact that P ∗ is a block. Within P ∗ after tL there can be no access to an element in (L(cid:48)(cid:48), B.xmin), as the first such access would necessarily cause the touching of a point inside B, a contradiction to the choice of (L, tL). An access within B is ruled out by our initial assumption. Thus, there is no access in (L(cid:48)(cid:48), L(cid:48))× (tL, n], and from Lemma 2.4(iii) it follows that any x ∈ [B.xmin, L(cid:48)) can not be touched after time tL. We argue similarly on the right side of B. As a corollary of Lemma C.5, note that above P ∗ only elements within [L(cid:48), R(cid:48)] can be touched within B. If L(cid:48) = R(cid:48), then only one element can be touched, and we are done. Therefore, we assume that L(cid:48) is strictly to the left of R(cid:48). We assume w.l.o.g. that tR > tL (the other case is symmetric). Let (Q, tQ) be the first access point left of B with tQ > tR such that there is a touch point inside B at time tQ. Observe that (Q, tQ) is outside of P ∗ by our choice of (L, tL). If no such Q exists, we are done, since we contradict the fact that Altk+4 is a (k + 3)-alternating gadget. Let (Z, tZ) denote the last touch point with the property that Z ∈ [(P ∗).xmin, L(cid:48)), and tZ ∈ [tL, tQ). If there are more such points in the same row, pick Z to be the leftmost. Note that (Z, tZ) might coincide with (L, tL). We have tZ ≤ tR because otherwise (Q, tQ) cannot exist. Note than tZ > tR would imply that elements in [L(cid:48), R(cid:48)] are hidden in (Z, R) after tR. Next, we make some easy observations. Lemma C.6. The following ranges are empty: 21 (i) [B.xmin, B.xmax ] × [tR + 1, tQ − 1], (ii) [1, Z − 1] × [tZ + 1, tR], (iii) [Q, Z − 1] × [tZ + 1, tQ − 1], (iv) [Q, R(cid:48) − 1] × [tR + 1, tQ − 1]. Proof. (i) It is clear that there can be no access point inside B by assumption. Suppose there is a touch point in [B.xmin, B.xmax ] × [tR + 1, tQ − 1], and let (Q(cid:48), tQ(cid:48)) be the first (lowest) such point. Denote the access point at time tQ(cid:48) as (Q(cid:48)(cid:48), tQ(cid:48)). Clearly tQ(cid:48) > (P ∗).ymax must hold, otherwise the choice of (L, tL) or (R, tR) would be contradicted. Also Q(cid:48)(cid:48) > (P ∗).xmax must hold, otherwise the choice of (Q, tQ) would be contradicted. But this is impossible, since Q(cid:48) ∈ [L(cid:48), R(cid:48)], and τ (Q(cid:48), tQ(cid:48) − 1) ≤ tR, and thus the rectangle with corners (Q(cid:48)(cid:48), tQ(cid:48)) and (Q(cid:48), τ (Q(cid:48), tQ(cid:48)−1)) contains the touch point (R, tR), contradicting the claim that Greedy touches Q(cid:48) at time tQ(cid:48). (ii) All elements in [1, Z − 1] are hidden in [1, Z − 1] after tZ. There can be no access points on the left of P ∗, due to the structure of the block decomposition, and there is no access point in [(P ∗).xmin, Z−1]× [tZ + 1, tQ − 1] due to the choice of Z. Hence there cannot be a touch points in [1, Z − 1]× [tZ + 1, tR]. (iii) First there is no access point in [Q, Z − 1] × [tZ + 1, (P ∗).ymax ] due to the choice of (Z, tZ) and the structure of block decomposition. Also, there is no access point in [Q, Z − 1] × ((P ∗).ymax , tQ − 1]: Assume there were such an access point (Q(cid:48), tQ(cid:48)). Then it must be the case that Q < Q(cid:48) < (P ∗).xmin and (P ∗).ymax < tQ(cid:48) < tQ. Any rectangle formed by (Q, tQ) and a point in P ∗ ∩ B would have contained (Q(cid:48), tQ(cid:48)), a contradiction to the fact that Greedy touches a point inside B at time tQ. Next, we argue that there is no non-access touch point (a, t) ∈ [Q, Z − 1] × [tZ + 1, tQ − 1]. There are three cases. -- (a, t) ∈ [(P ∗).xmin, Z − 1] × [tZ + 1, tQ − 1] contradicts the choice of (Z, tZ). -- (a, t) ∈ [Q, (P ∗).xmin)×[tZ +1, (P ∗).ymax ] contradicts the fact that all elements in [1, Z) are hidden in [1, Z) after tZ, and there is no access in [1, Z) in the time interval [tZ + 1, (P ∗).ymax ], since P ∗ is a block. -- (a, t) ∈ [Q, (P ∗).xmin)× ((P ∗).ymax , tQ − 1], contradicts the claim that at time tQ Greedy touches a point inside B, since any rectangle formed by (Q, tQ) and a point in P ∗ ∩ B would have contained (a, t). (iv) Given the previous claims, it remains only to prove that there is no touch point (a, t) ∈ [Z, B.xmin)×t ∈ [tR + 1, tQ − 1]. There cannot be such a touch point for t ≤ (P ∗).ymax due to the choice of (Z, tZ). For t > (P ∗).ymax , there cannot be souch an access point due to the structure of block decomposition. Remains the case when (a, t) is a non-access touch point in [Z, B.xmin) × ((P ∗).ymax , tQ − 1. This is also impossible, as any rectangle formed by (Q, tQ) and a point in P ∗ ∩ B would have contained (a, t), contradicting the choice of (Q, tQ). Lemma C.7. At time tQ we touch R(cid:48). Let L∗ be the leftmost element touched in [L(cid:48), R(cid:48)] at time tQ (it is possible that L∗ = R(cid:48)). After time tQ, only L∗ and R(cid:48) can be touched within [L(cid:48), R(cid:48)]. Proof. The first part follows from the emptiness of rectangles in Lemma C.6. That is, the lemma implies that the rectangle formed by (Q, tQ) and (R(cid:48), tR) is empty, so Greedy touches R(cid:48) at time tQ. The elements a ∈ (L∗, R(cid:48)) cannot be touched because they are hidden in (L∗, R(cid:48)) after tQ, and there is no access point in this range after tQ, due to the structure of the block decomposition. Suppose that some element a ∈ [L(cid:48), L∗) is touched (for the first time) at some time t > tQ by accessing element x. So the rectangle formed by (x, t) and (a, τ (a, t − 1)) is empty, and we know that τ (a, t − 1) < tR. Notice that 22 Figure 7: Illustration of the proof of Lemma 3.3(vi). x < (P ∗).xmin for otherwise (R, tR) would have been in the rectangle formed by (x, t) and (a, τ (a, t − 1)), a contradiction. Furthermore, τ (a, t−1) > tZ for otherwise, (Z, tZ) would have been in the rectangle formed by (x, t) and (a, τ (a, t− 1)), a contradiction. Now, since τ (a, t− 1) > tZ, Lemma C.6 implies that the rectangle formed by (Q, tQ) and (a, τ (a, t − 1)) must be empty, therefore a is touched at time tQ; this contradicts the choice of L∗. Lemma C.4, C.5, and C.7 together imply that in total at best the k + 3 lowest points of Altk+4 can be touched (out of the k + 4 needed). This means that our assumption that B is free of access points was false. Therefore Altk+4 is a capture gadget, finishing the proof of Lemma 3.3(vi). See Figure 7 for an illustration. D Decomposition theorem and applications D.1 Preliminaries Given a permutation σ : [n] → [n], we call a set [a, b]×[c, d], with the property that {σ(a), σ(a+1), . . . , σ(b)} = [c, d], a block of σ induced by the interval [a, b]. Let P be a block induced by interval I. Consider a partitioning of I into k intervals, denoted (left-to-right) as I1, I2, . . . , Ik, such that each interval induces a block, denoted respectively as P1, P2, . . . , Pk. Consider the unique permutation P of size [k] that is order- isomorphic to a sequence of arbitrary representative elements from the blocks P1, P2, . . . , Pk. We denote P = P [P1, P2, . . . , Pk] a deflation of P , and we call P the skeleton of P . Visually, P is obtained from P by contracting each block Pi to a single point (Figure 1). Deflation is analogously defined on permutations. Every permutation σ has the trivial deflations σ = σ[1, . . . , 1] and σ = 1[σ]. Permutations that have only the trivial deflations are called simple permutations. A block decomposition tree T of σ is a tree in which each node is a block of σ. We define T recursively as follows: The root of T is the block [n] × [n]. A node P of T is either a leaf, or it has children P1, P2, . . . corresponding to a nontrivial deflation P = P [P1, P2, . . . ]. To every non-leaf block P we associate its skeleton 23 P . For convenience, we assume that the blocks P1, . . . , Pk are ordered by their y-coordinates from bottom to top. We partition P into k2 rectangular regions whose boundaries are aligned with P1, . . . , Pk, and index them R(i, j) with i going left to right and j going bottom to top. In particular, the region R(i, j) is aligned with Pj (same y-coordinates). To every leaf block P = [a, b] × [c, d] we associate the unique permutation that is order-isomorphic to (σ(a), σ(a + 1), . . . , σ(b)). When there is no chance of confusion, we refer interchangeably to a block and its associated permutation. We denote the leaves and non-leaves of the tree T by L(T ) and N (T ) respectively. A permutation is k-decomposable if it has a block decomposition tree T in which every node has an associated permutation of size at most k. As an example, we observe that preorder sequences of binary search trees are 2-decomposable. D.2 A robust Greedy We augment Greedy with some additional steps and we obtain an offline algorithm (called RGreedy) with several desirable properties. We remark that in this section we always assume the preprocessing discussed in § 2 or equivalently, in geometric view we assume that RGreedy is executed without initial tree (since RGreedy is offline, this is a non-issue). Before describing the algorithm, we give some simple definitions. We denote the top left, respectively top right corner point of a rectangular region R as topleft(R), respectively topright(R). We define topwing(R) to be a subset of the points touched in R, that are the last touch points of their respective columns. A point q is in topwing(R) if at least one of the following properties is satisfied: -- The rectangle with corners q and topleft(R) is empty, -- The rectangle with corners q and topright(R) is empty, -- q is in the leftmost or rightmost column of R. Note that the set topwing(R) depends on the time point where we are in the execution of the algorithm, but for simplicity of notation, we omit the reference to a specific time (it will always be clear from the context). We can now describe how RGreedy processes an input point (a, t). First, it acts as Greedy would, i.e. for every empty rectangle with corners (a, t) and (b, t(cid:48)), it touches the point (b, t) on the current timeline. Let Yt be the points touched in this way (including the point (a, t)). Second, it touches additional points on the timeline. Let v1, v2 = parent(v1), . . . , v(cid:96) = parent(v(cid:96)−1) be the nodes of the decomposition tree such that the blocks associated with these nodes end at time t. Note that v1 is a leaf. Let v(cid:96)+1 = parent(v(cid:96)); v(cid:96)+1 exists except when the last input is processed. For h ∈ [2, (cid:96) + 1] in increasing order, we consider the deflation P [P1, . . . , Pk] associated with vh. Let (a, t) lie in Pj; note that j = k if h ≤ (cid:96) and j < k for h = (cid:96) + 1. For every sibling region R(i, j) of Pj, RGreedy touches the projection of topwing(R(i, j)) on the timeline t. Let Yh,t be the points touched. Figure 4 illustrates the definition of RGreedy. We need to argue that the augmentation step does not violate the feasibility of the solution. Lemma D.1. The output of RGreedy is feasible. Proof. Suppose for contradiction that at time t we have created an unsatisfied rectangle r with corners (a, t) and (x, y), where y < t. The point (a, t) is the result of projecting (a, t(cid:48)) onto the horizontal line t, where (a, t(cid:48)) ∈ topwing(R), for some region R processed at time t. Clearly t(cid:48) < t. Assume that before adding (a, t), the rectangle formed by the points (a, t(cid:48)) and topleft(R) is empty. A symmetric argument works if (a, t(cid:48)) formed an empty rectangle with topright(R). We have y > t(cid:48), for otherwise the point (a, t(cid:48)) would satisfy r. Let R = R(i, j). Since (x, y) lies in the time window of R, we have (x, y) ∈ R(i(cid:48), j) for some i(cid:48). Suppose first that i = i(cid:48). If x ≤ a, then the rectangle with corners (a, t(cid:48)) and topleft(R) contains (x, y), contradicting the fact that (a, t(cid:48)) was in topwing(R) before the augmentation. Therefore x > a holds. But then, if r is not satisfied, then the rectangle with corners (x, y) and topleft(R) had to be empty before the augmentation, and therefore (x, t) must have been touched in the augmentation step, making r satisfied. The case i (cid:54)= i(cid:48) remains. If i(cid:48) < i, then r contains the rectangle formed by (x, y) and the top right corner of R(i(cid:48), j). Either this rectangle is nonempty, or (x, y) was in topwing(R(i(cid:48), j)) before the augmentation, in 24 which case (x, t) was touched in the augmentation step. In both cases r must be satisfied. The case when i(cid:48) > i is symmetric, finishing the proof. Observe that RGreedy processes the input and emits the output line-by-line, in increasing order of time. It is, however, not an online algorithm, as it has a priori access to a block decomposition tree of the input. D.3 Decomposition theorem Our main technical contribution in this section is the following result: Theorem D.2 (Decomposition theorem for permutations). For any block decomposition tree T of a permu- tation P , the total cost of RGreedy is bounded as RGreedy(P ) ≤ 4 · (cid:88) We discuss applications of Theorem D.2. P∈N (T ) Greedy( P ) + Greedy(P ) + 3n. (cid:88) P∈L(T ) Application 1: Cole et al.'s "showcase" sequences. In Cole et al. [10], a showcase sequence is defined in order to introduce necessary technical tools for proving the dynamic finger theorem. This sequence can be defined (in our context) as a permutation P = P [P1, . . . , Pn/ log n] where each Pj is a sequence for which Greedy has linear linear access cost, i.e. Pj = log n, and Greedy(Pj) = O(log n). Now, by applying Theorem D.2, we can say that the cost of RGreedy on P is RGreedy(P ) ≤ 4 · Greedy( P ) + log n O(log n)+O(n) = O(n). This implies that our algorithm Greedy(Pj)+O(n) ≤ O( n (cid:80) log n ·log( n log n ))+ n j has linear access cost on this sequence. Application 2: Simple permutations as the "core" difficulty of BST inputs. We argue that whether RGreedy performs well on all sequences depends only on whether Greedy does well on simple permutation sequences. More formally, we prove the following theorem. Theorem D.3. If Greedy is c-competitive on simple permutations, then RGreedy is an O(1) approxi- mation algorithm for OPT(X) for all permutations X. Using Theorem 2.1 we can extend this statement from all permutations to all access sequences. To prove Theorem D.3 we use of the known easy fact [3] that every permutation P has a block de- composition tree T in which all permutations in L(T ) and all permutations in N (T ) are simple. Applying Theorem D.2 and the hypothesis that Greedy is c-competitive for simple permutations, we get the bound: RGreedy(P ) ≤ 4c · (cid:88) OPT( P ) + c · (cid:88) P∈N (T ) P∈L(T ) OPT(P ) + 3n. Now we need to decompose OPT into subproblems the same way as done for RGreedy. The following lemma finishes the proof (modulo the proof of Theorem D.2), since it implies that RGreedy(P ) ≤ 4c · OPT(P ) + (8c + 3)n. Lemma D.4. OPT(P ) ≥(cid:80) (cid:80)k Proof. We show that for an arbitrary permutation P = P [P1, . . . , Pk], it holds that OPT(P ) ≥ OPT( P ) + i=1 OPT(Pi) − k. The result then follows simply by iterating this operation for every internal node of the block decomposition tree T of P and observing that the numbers of children of each internal node add up to at most 2n. P∈T OPT(P ) − 2n. 25 out = Y ∗ \(cid:83)k i=1 Y ∗ i . Each Y ∗ out ≥ OP T ( P ) − k. i contained i must clearly be feasible for Pi, so we have Let Y ∗ be the set of points of the optimal solution for P . We partition Y ∗ into sets Y ∗ inside each block Pi, and we let Y ∗ Y ∗ i ≥ OPT(Pi). It remains to show that Y ∗ Again, consider the partitioning of P into k2 rectangular regions R(i, j), aligned with the blocks P1, . . . , Pk. Consider the contraction operation that replaces each region R(i, j) with a point (i, j) if and only if Y ∗∩R(i, j) is nonempty. We obtain a point set Y (cid:48) ∈ [k]× [k], and clearly Y (cid:48) ≤ Y ∗ out + P. We claim that the obtained point set Y (cid:48) is a satisfied superset of P , and therefore Y ∗ Indeed, suppose for contradiction that there is an unsatisfied rectangle with corner points p, q ∈ Y (cid:48). Suppose p is to the upper-left of q (the other cases are symmetric). Let Rp and Rq be the regions before the contraction that were mapped to p, respectively q. Since Y ∗ ∩ Rp is nonempty, we can consider p(cid:48) to be the lowest point in Y ∗ ∩ Rp and if there are several such points, we take p(cid:48) to be the rightmost. Similarly, since Y ∗ ∩ Rq is nonempty, we can take q(cid:48) to be the topmost point in Y ∗ ∩ Rq and if there are several such points, we take q(cid:48) to be the leftmost. Now, if the rectangle with corners p and q is unsatisfied in Y (cid:48), then the rectangle with corners p(cid:48) and q(cid:48) is unsatisfied in Y ∗, contradicting the claim that Y ∗ is a feasible solution. out ≥ OPT( P ) − k. Application 3: Recursively decomposable permutations. We generalize preorder access sequences to k-decomposable permutations, and show that RGreedy has linear access cost for all such permutations. Let k be a constant such that there is a tree decomposition T in which each node is a permutation of size at most k. Notice that a preorder sequence is 2-decomposable. Theorem D.5. The cost of RGreedy on any k-decomposable access sequence is at most O(n log k). Proof. Applying Theorem D.2, we obtain that RGreedy(P ) ≤ 4(cid:80) so we have (cid:80) (cid:80) most 2n, we have(cid:80) it follows that(cid:80) Greedy( P ) ≤(cid:80) Greedy(P ) ≤ O(n log k). P∈N (T ) O(n). First, notice that the elements that belong to the leaf blocks are induced by disjoint intervals, P∈L(T ) P = n. For each such leaf block, since Greedy is known to have logarithmic amortized cost, we have Greedy(P ) ≤ O(P log P) = O(P log k). Summing over all leaves, we have P∈L(T ) Next, we bound the cost of non-leaf blocks. Since the numbers of children of non-leaf blocks add up to at P∈N (T ) P ≤ 2n. Again, using the fact that Greedy has amortized logarithmic cost, Greedy( P )+(cid:80) P∈N (T ) P∈L(T ) Greedy(P )+ P∈N (T ) O( P log k) ≤ O(n log k). This completes the proof. We mention that the logarithmic dependence on k is essentially optimal, since there are simple per- mutations of size n with optimum cost Ω(n log n). In fact, for arbitrary k, the bound is tight, as shown in Appendix G.2. In Theorem 1.4 we proved that for arbitrary constant k, the linear upper bound for k-decomposable permutations is asymptotically matched by Greedy. D.4 Proof of Theorem D.2 We are now ready to prove the decomposition theorem. Let Y be the output of RGreedy on a permutation of P of size n, and let T be the block decomposition tree of P . We wish to bound Y . For each leaf block P ∈ L(T ), let YP be the points in P ∩ Y . For each non-leaf block P ∈ N (T ), with j Pj). In words, these are the points in block P that are not in any of its children (we do not want to overcount the cost). It is clear that we have already For each non-leaf block P ∈ N (T ), we show later that Y P ≤ 4·Greedy( P )+5degree( P )+junk ( P ), where P∈N (T ) junk ( P ) ≤ 2n. For each leaf block P , notice that apart from the RGreedy augmentation in the last row, the cost is exactly Greedy(P ). Including the extra points touched by RGreedy we have that YP = Greedy(P ) + topwing(P ). Since leaf blocks are induced by a partitioning of [n] into disjoint intervals, we have that children P1, . . . , Pk, let Y P be the set of points in Y ∩ ( P \(cid:83) accounted for all points in Y , i.e. Y =(cid:83) degree( P ) is the number of children of P , and the term junk ( P ) will be defined such that(cid:80) Greedy( P )+(cid:80) (cid:80) P∈L(T ) topwing(P ) ≤ n. So in total, the cost can be written as 4·(cid:80) 5n as desired. It remains to bound(cid:80) P∈T YP , so it suffices to bound(cid:80) P∈T YP. P∈N (T ) P∈N (T ) Y P. P∈L(T ) Greedy(P )+ 26 Consider any non-leaf block P . Define the rectangular regions R(i, j) as before. We split Y P into three be the subset of Y P consisting of points that are in the first row of some region R(i, j). be the subset of Y P consisting of points that are in the last row of some region R(i, j). Observe that ) be separate parts. Let Y 1 P Let Y 3 P any points possibly touched in an RGreedy augmentation step fall into Y 3 P the set of touch points that are not in the first or the last row of any region R(i, j). = Y P − (Y 1 . Let Y 2 P ∪ Y 3 P P Denote by left(R) and right(R) the leftmost, respectively rightmost column of a region R. Similarly, denote by top(R) and bottom(R) the topmost, respectively bottommost y-coordinate of a region R. Lemma D.6. If region R(i, j) has no block Pq below it, RGreedy touches no point in R(i, j). If R(i, j) has a block Pq below it, RGreedy touches only points in columns left(R(i, j)) and right(R(i, j)). Proof. If R(i, j) has no block Pq below it, then it is never touched. Assume therefore that R(i, j) is above (and aligned with) block Pq for some q < j. When RGreedy accessed the last element in Pq, it touched the left and right upper corners of Pq in the augmentation step (since the topmost element in the leftmost and rightmost columns belong to topwing(Pq)). As there are no more accesses after top(Pq) inside [left(Pq)+1, right(Pq)−1], all elements in this interval are hidden in [left(Pq) + 1, right(Pq) − 1], and therefore not touched again. (i, j) is touched by Greedy on input P . Notice that (cid:80) Let mi,j be the indicator variable of whether the region R(i, j) is touched by RGreedy. Consider the execution of Greedy on permutation P and define ni,j to be the indicator variable of whether the element i,j ni,j = Greedy( P ). We refer to the execution of Greedy on permutation P as the "execution on the contracted instance", to avoid confusion with the execution of RGreedy on block P . Lemma D.7. Before the augmentation of the last row of P by topwing( P ) the following holds: A rectangular area R(i, j) in block P is touched by RGreedy iff Greedy touches (i, j) in the contracted instance P ; in other words, mi,j = ni,j for all i, j. Lemma D.6 and Lemma D.7 together immediately imply the bounds Y 1 P ≤ 2 · Greedy( P ) + topwing( P ), since in the first or last row of a region R(i, j) that is not one of the Pj's at most two points are touched and no point is touched if Greedy does not touch the region. In the case of Y 3 P , RGreedy also touches the elements in topwing( P ) after the last access to a point in P . ≤ 2 · Greedy( P ), and Y 3 P Proof. We prove by induction on j that after Pj is processed, the rectangular area R(i, j) is touched by RGreedy if and only if (i, j) is touched by Greedy in the contracted instance. We consider the processing of Pj and argue that this invariant is maintained. When j = 1, the induction hypothesis clearly holds. There are no other touch points below the block P (due to the property of the decomposition), so when points in P1 are accessed, no points in P \ P1 are touched. Similarly, in the contracted instance when the first point in P is accessed by Greedy, no other points are touched. First we prove that Greedy touching (i, j) in the contracted instance implies that RGreedy touches R(i, j). Suppose Greedy touches point (i, j). Let pj be the access point in the contracted instance at time j. There has to be an access or touch point (i, j(cid:48)) where j(cid:48) < j such that the rectangle with corners (i, j(cid:48)), and p(cid:48) had no other points before adding (i, j) (the point (i, j(cid:48)) was on the stair of pj at time j). The induction hypothesis guarantees that R(i, j(cid:48)) is touched by RGreedy, so some point q is touched or accessed in this region. Choose q to be the topmost such point, and if there are more points in the same row, choose q to be as close to block Pj as possible. We claim that q is in the stair of the first access point p∗ of Pj, therefore touching R(i, j): If q was not in the stair, there would be another point q(cid:48) in the rectangle formed by p∗ and q. Observe that q(cid:48) cannot be in R(i, j(cid:48)), because it would contradict the choice of q being closest to p∗. So q(cid:48) is in some region R(i(cid:48)(cid:48), j(cid:48)(cid:48)) that lies inside the minimal rectangle embracing R(i, j(cid:48)), and the region immediately below Pj. By induction hypothesis, the fact that R(i(cid:48)(cid:48), j(cid:48)(cid:48)) contains point q(cid:48) implies that (i(cid:48)(cid:48), j(cid:48)(cid:48)) is touched by Greedy in the contracted instance, contradicting the claim that the rectangle with corners (i, j(cid:48)), pj is empty. Now we prove the other direction. Suppose RGreedy touches region R(i, j). This also implies that Greedy (without augmentation step) already touches R(i, j). But then Greedy must touch a point in 27 R(i, j) when accessing the first element p∗ in Pj. Assume w.l.o.g. that R(i, j) is to the right of Pj. It means that there is a point q in the stair of p∗, such that q is in some region R(i, j(cid:48)) for j(cid:48) < j. If in the contracted instance (i, j(cid:48)) is in the stair of the access point pj at time j, we would be done (because Greedy would add point (i, j)), so asssume otherwise that this is not the case. Let (i(cid:48)(cid:48), j(cid:48)(cid:48)) be the point that blocks (i, j(cid:48)), so the corresponding region R(i(cid:48)(cid:48), j(cid:48)(cid:48)) lies inside the minimal rectangle embracing both Pj and R(i, j(cid:48)). Also note that the region R(i(cid:48)(cid:48), j(cid:48)(cid:48)) cannot be vertically aligned with Pj because P is a permutation. Thus i < i(cid:48)(cid:48). The fact that (i(cid:48)(cid:48), j(cid:48)(cid:48)) is touched by Greedy implies, by induction hypothesis, the existence of a point q(cid:48) ∈ R(i(cid:48)(cid:48), j(cid:48)(cid:48)), and therefore the augmentation step of RGreedy touches some point q∗ on the top row of region R(i(cid:48)(cid:48), j(cid:48)(cid:48)). This point would prevent q from being on the stair of p∗, a contradiction. Lemma D.8. topwing( P ) ≤ 2 · degree( P ). Proof. topwing( P ) contains at most 2 points in block R(i, k) for every k. . P The only task left is to bound Y 2 P , the number of touch points in non-first and non-last rows of a region. This will be the junk term mentioned earlier, that sums to 2n over all blocks P ∈ N (T ). In particular we P∈N (T ) Y 2 show that every access point can contribute at most 2 to the entire sum(cid:80) observe, that every point touched at time tx inside P ∗ is accounted for already in the sum(cid:80) Consider any access point X = (x, tx), and let P ∗ denote the smallest block that contains X, and in which X is not the first access point (such a block exists for all but the very first access point of the input). Further P∈N (T ) Y 1 , P since these points are in the first row of some region inside P ∗. It remains to show that at time tx at most two points are touched outside of P ∗, excluding a possible RGreedy augmentation step (which we already accounted for). Let p∗ denote the first access point in P ∗, i.e. at time bottom(P ∗). At the time of accessing p∗ several points might be touched. Notice that all these points must be outside of P ∗, since no element is touched before being accessed. Let pleft and pright be the nearest of these touch points to p∗ on its left, respectively on its right. We claim that for all the access points in P ∗ other than the first access point p∗, only pleft and pright can be touched outside of P ∗. Since, by definition X is a non-first element of P ∗, it follows that at time tx at most two points are touched outside of P ∗, exactly what we wish to prove. Indeed, elements in the interval [1, pleft − 1], and in the interval [pright + 1, n] are hidden in [1, pleft − 1], respectively in [pright + 1, n], in the time interval [bottom(P ∗) + 1, top(P ∗)] and therefore cannot be touched when accessing non-first elements in P ∗. The case remains when pleft or pright or both are nonexistent. In this case it is easy to see that if on the corresponding side an element outside of P ∗ were to be touched at the time of a non-first access in P ∗, then it would have had to be touched at the time of p∗, a contradiction. This concludes the proof. E Proof of Theorem 2.1 In this section, we prove the following theorem. Theorem E.1 (Theorem 2.1). Assume that there is a c-competitive online geometric BST Ap for all per- mutations. Then there is a 4c-competitive online geometric BST A for all access sequences. Given a c-competitive online BST Ap that can serve a permutation access sequence, we construct a 4c-competitive online BST A that can serve any (not necessarily permutation) access sequences. We first sketch the outline of the proof. Let X ∈ [n]m be a (possibly non-permutation) access sequence, and let T be the initial tree on [n]. First we show that given any online BST B that can handle accesses, there is a canonical way to augment B and obtain an augmented Bins , that can also handle insertions of elements. Then, we show that given any access-only sequence X ∈ [n]m, initial tree T and an online augmented BST Ap,ins that can serve permutation access and insert sequences, we can construct a permutation sequence (comprising of both accesses and insertions) X p,ins ∈ [m]m to be fed to Ap,ins in an online manner. Then 28 there are two steps. First, we show that the execution of Ap,ins can define the execution of A that runs on X with initial tree T . Second, we show that the cost of Ap,ins can be bounded by O(OPT(X)). Now we formally describe the proof. Handling Insertion Given an online BST B, let Bins be an algorithm that works as follows. To access element x, just simulate B. To insert element x, try searching for x and miss, i.e. touching the search path of predecessor and successor of x in the tree. Then add x as a leaf. Then simulate B as if B is accessing the leaf x. E.1 Constructing the algorithm A In the following, we work on R × Z instead of the integer grid Z × Z in order to simplify the algorithm and the proof. We extend some notations and definitions accordingly. We use the words "y-coordinate" and "row" interchangeably. For any X, T ⊂ R× Z, by [ X T ], we mean the point set obtained by "putting X above T " while the x-coordinate of each element does not change. A point set X ⊂ R× Z is a permutation if there is at most one point in X for any fixed x-coordinate and any fixed y-coordinate. A satisfied set is defined in the usual no-empty-rectangle way. An online BST B, given [ X online manner. T ] ⊂ R × Z, outputs a satisfied(cid:2) BT (X) To describe the algorithm A for Theorem 2.1, we define two operations: split and merge. Given any access sequence X, we define split(X) as follows. Let  be an extremely small positive constant. For each point (x, y) ∈ X, we have (x + y, y) ∈ split(X) except if (x, y) is the first access point of element x (i.e. there is no (x(cid:48), y) ∈ X where x(cid:48) < x), in which case (x, y) ∈ split(X). The intention is to "tilt" the non-first accesses of all elements in the simplest way. Note that split(X) is a permutation. We define the reverse operation merge(S) = {((cid:98)x(cid:99) , y) (x, y) ∈ S} for any set S. For any (non-permutation) sequence X ∈ Z × Z, let X p,ins , X p = split(X) as a point set. All points in X p are access points. However, in X p,ins , only points with integral x-coordinate are access points, the remaining points are insertion points. That is, the first points of each element of X "become" access points in X p,ins , the remaining points "become" insertion points. (cid:3) in an T Given [ X T ] ∈ Z × Z as an input to A, we define: AT (X) = merge(Ap,ins Lemma E.2. If Ap is online, then A is an online process. Proof. Observe that split and merge fix y-coordinate. If Ap is online, then merge(Ap,ins computed row by row. Lemma E.3. For any (non-permutation) access sequence X, and initial tree T it holds that AT (X) ⊇ X (X p,ins )) can be (X p,ins )) T T and(cid:2) AT (X) (cid:3) is satisfied T Proof. To show that AT (X) ⊇ X, observe that X = merge(split(X)) as  is very small. Next, X p,ins ⊆ Ap,ins (X p,ins ) because Ap,ins is an online BST. Finally, as merge is monotone under inclusion, we have T To show that(cid:2) AT (X) (cid:104) Ap,ins T is satisfied, merge( T X = merge(split(X)) = merge(X p,ins ) ⊆ merge(Ap,ins (cid:3) is satisfied, we claim that merge preserves satisfiability. Therefore, as (X p,ins )) = AT (X). T (cid:104) Ap,ins T (cid:105) (X p,ins ) T It remains to prove the claim. Let S ⊂ R × Z be any satisfied set and S(cid:48) = merge(S). Consider any points p(cid:48), q(cid:48) ∈ S(cid:48) where p(cid:48).x < q(cid:48).x and choose the rightmost (leftmost) associated point p (q) of p(cid:48) (q(cid:48)) from S. As S is satisfied, there is a point r ∈ S \ {p, q} where r ∈ (cid:3)pq. In particular, p.x ≤ r.x ≤ q.x. Let r(cid:48) = ((cid:98)r.x(cid:99) , r.y) ∈ S(cid:48) be the image of r under merge, then we have r(cid:48) ∈ (cid:3)p(cid:48)q(cid:48) because (cid:98)p.x(cid:99) ≤ (cid:98)r.x(cid:99) ≤ (cid:98)q.x(cid:99) and merge does not affect y-coordinate. Moreover, r(cid:48) (cid:54)= p(cid:48), q(cid:48), otherwise p is not the rightmost associated (cid:105) (X p,ins ) T ) =(cid:2) AT (X) (cid:3) is satisfied. T 29 Figure 8: Illustration of S(cid:48) in the proof of Lemma E.5. The symbols × denote accesses and circles are touched points. point of p(cid:48), or similarly for q(cid:48). So we have identified r(cid:48) ∈ S(cid:48) \ {p(cid:48), q(cid:48)} where r(cid:48) ∈ (cid:3)p(cid:48)q(cid:48) and therefore S(cid:48) is satisfied. By Lemma E.2 and Lemma E.3, A is an online process where AT (X) ⊇ X and AT (X) is satisfied. Therefore, A is an online (geometric) BST for accessing arbitrary (non-permutation) sequences. E.2 Competitiveness The idea is to bound Ap,ins by the cost of the online BST running on X that only supports access. T (X p,ins ), which is the cost of the online BST which does both access and insert Let T p be a binary search tree with m elements corresponding to the distinct x-coordinates of points in X p. The elements with integral values in T p form a BST with exactly same structure as T . Between any two integral value elements v and v + 1, there will be a right path (each node has only right child) of size equal to the number of points from X p with x-coordinate from (v, v + 1). This tree is defined so that the following claim holds. Lemma E.4. Ap,ins Proof. We assume that Ap does not touch elements in the initial tree that have never been in any of the search paths for access or insert. By induction on time step t, if the point (x, t) ∈ X p,ins is an access point, then Ap,ins and Ap do the same thing by definition. If the point (x, t) ∈ X p,ins is an insertion point, then after Ap,ins adds x as a leaf, the structure of the tree excluding elements which are never touched is same. So Ap,ins and Ap do the same thing again. (X p,ins ) = Ap T p (X p). T Lemma E.5. For any access sequence (no insertions) X, and the corresponding access sequence split(X), OPT(split(X)) ≤ 4OPT(X). Proof. We show that given OPT(X), we can construct a satisfied set S(cid:48) of split(X) where S(cid:48) ≤ 2OPT(X) + 2m. We iteratively modify OPT(X) to obtain S(cid:48). Consider any column ci of OPT(X) which contains more than one access point, say mi access points. Suppose that ci contains pi ≥ mi touch points (thus pi − mi non-access touch points), and lies between ci−1 and ci+1. We "split" ci into mi columns ci1, ci2 , . . . cimi lying between ci−1 and ci+1. Columns ci1 and cimi have pi points in the same rows as ci; in ci1 the lowest of them is an access point, and all others above are touched, whereas in cimi the highest is an access point, and all others below are touched. The remaining columns ci2 ,··· , cimi−1 have two points each in them, one access and one touch point. The access point in column cij is in the same row as the jth access in original column ci, and the touch point in column cij is in the same row as the (j + 1)th access in ci. See Figure 8. It is easy to verify that, after placing these points, the set is still satisfied. The number of points placed in these columns is exactly 2pi + 2(mi − 2). Thus after applying this modification to every column ci, there are at most 2OPT(X) + 2m ≤ 4OPT(X) points. 30 Now we are ready to prove the main theorem. Proof of Theorem 2.1. First, we have that AT (X) ≤ Ap,ins number of points. We conclude that AT (X) ≤ Ap,ins (X p,ins ) = Ap T (X p,ins ) because merge never increases the T T p (X p) ≤ cOPT(split(X)) ≤ 4cOPT(X), where the second inequality follows from Lemma E.4, the third inequality follows from the assumption that Ap is c-competitive for only accessing on only permutations, and the last inequality follows from Lemma E.5, and hence A is a 4c-competitive online BST for any access sequence. (cid:3) F Random permutation is hard We prove that the cost of most permutations is Ω(n log n) for all BST algorithm. A similar result has been shown by Wilber [39] for random access sequences (that might not be permutations). More formally, we prove the following theorem. Theorem F.1. There is a positive constant c such that for any L > 0 only a fraction 1/2L of the permutations X have OPT(X) ≤ (log n! − L − n − 1)/c. Proof. We use Kolmogorov complexity. Observe that the shape of a tree on k nodes can be encoded by O(k) bits, e.g., by the preorder traversal. If the keys stored in the tree are clear from the context, the assignment of the keys to the nodes is unique. Let T be the initial tree, let X be any (permutation) access sequence, and let CX be the total cost of OPT on X. We encode the shape of the initial tree with O(n) bits. Consider now an access of cost k. It replaces an initial segment of the current search tree, the before-tree, by another tree on the same set of nodes, the after-tree. The before-tree must include the element accessed and has size O(k). We encode the before-tree and the after-tree with O(k) bits and use a special marker to designate the accessed element in the before-tree. In total, we need c · (n + CX ) bits for the encoding for some small constant c. Note that X can be reconstructed from the encoding. We first reconstruct the shape of the initial tree. Its labelling by keys is unique. Consider now any access. Since the position of the accessed element in the before-tree is marked and since the before- and the after-tree are on the same set of keys, the search tree after the access is determined. We conclude that we have an injective mapping from permutations X to bitstrings of length c · (n + CX ). Assume Cx ≤ (log n! − L − n − 1)/c. Then the encoding of X has at most log n! − L − 1 bits and hence X is in a set of at most n!/2L permutations. G Other claims G.1 Counterexamples for straightforward attempts Avoiding the same pattern is not enough. It might be tempting to conjecture that if X avoids P , then the Greedy touch matrix Greedy(X) avoids P as well (P refers both to a permutation pattern and its matrix representation). While this holds for the simple case P = (2, 3, 1) in the "no initial tree"-case (proof left as an exercise for the reader), in general it is not true. Figure 9 shows a counterexample (P = (3, 2, 1)). Greedy is not decomposable. One could prove a decomposition theorem similar to Theorem D.2 for Greedy, if Greedy were decompos- able. By this we mean that for a k-decomposable input sequence, considering a certain level P = P [P1, . . . , Pk] of the decomposition tree, Greedy touches a region R(i, j), iff the corresponding point (i, j) is touched by Greedy, when executed on the contracted instance P . Alas, this property does not hold for Greedy, as shown on Figure 10. 31 Figure 9: Access points are black circles, points touched by Greedy are gray circles. Input avoids (3,2,1), but output contains (3,2,1). Figure 10: Access points are black circles, points touched by Greedy are gray circles. Left: block decomposition of input, and Greedy execution. Top left region is touched. Right: Greedy execution on contracted instance. Top left point not touched. No permutation input-revealing gadget with initial trees. A permutation input-revealing gadget for Greedy would allow us to strengthen the bound in Theorem 1.1 from quasilinear to linear. In Figure 11 we sketch a construction that shows that such a gadget can not exist, if initial tree is allowed, even if the input is the preorder sequence of a path. G.2 Tightness of O(n log k) for k-decomposable permutations In this section, we show that the upper bound of OPT(X) = O(n log k) for k-decomposable permutations is tight, by arguing that there is a sequence that matches this bound. We will use the following claim, which is proved in § D.4, and restated here. Lemma G.1. Let X be any input sequence and T be its tree decomposition. Then OPT(X) ≥ (cid:88) P∈T OPT(P ) − 2n Let P (cid:48) be a sequence of size k where OPT(P (cid:48)) = Ω(k log k). Then we construct the tree T which is a complete degree-k tree of depth d, with each node v ∈ T having the template Pv = P (cid:48). Then n = kd, and each non-leaf node v ∈ N (T ) has OPT(Pv) = Ω(k log k). There are kd−1 = n/k non-leaf nodes, so we have OPT(X) ≥ Ω(k log k) · n k = Ω(n log k). G.3 Decomposition of k-increasing sequences Given a permutation X = (X1, . . . , Xn), a subsequence of X of size k is a sequence (Xi1 , . . . , Xik ), where 1 ≤ i1 < ··· < ik ≤ n. Lemma G.2. Let X ∈ Sn be an arbitrary permutation. The following statements are equivalent: (i) X is (k, . . . , 1)-free, 32 (ii) There exist pairwise disjoint subsequences Y1, Y2, . . . , Yk−1 of X, such that Yi is increasing for all i = 1, . . . , k − 1, and Y1 + ··· + Yk−1 = n. Proof. (ii) =⇒ (i): Let Y1, . . . , Yk−1 be increasing subsequences of X, as in the statement of the lemma, and suppose there exists a subsequence X(cid:48) = (Xi1, . . . , Xik ) of X order-isomorphic to the pattern (k, . . . , 1). Since X(cid:48) is decreasing, no two elements of X(cid:48) can be in the same subsequence Yi. This is a contradiction, since we have only k − 1 subsequences. Therefore, such an X(cid:48) cannot exist, and X is (k, . . . , 1)-free. (i) =⇒ (ii): Assume that X is (k, . . . , 1)-free. We construct the decomposition of X into increasing subsequences Y1, . . . , Yk−1 as follows. We look at the plot of permutation X, and we refer interchangeably to elements of X and points in the plot of X. Let Y1 be the "wing", i.e. the points in the plot of X that form an empty rectangle with the top left corner (by this definition, we have X1 ∈ Y1). Clearly, Y1 forms an increasing subsequence of X. We now remove the elements of Y1 from X and similarly find Y2 as the wing of the remaining points. We repeat the process, thereby finding Y1, Y2, . . . . We claim that we run out of points before reaching Yk, thus constructing a decomposition of X as required by the lemma. Suppose otherwise that we have reached Yk, and consider an arbitrary point Xik ∈ Yk. Since Xik was not chosen in Yk−1, the rectangle with corners Xik and the top-left corner has some point from Yk−1. Pick such a point, and denote it as Xik−1. Observe that Xik−1 > Xik , and ik−1 < ik. Since Xik−1 was not chosen in Yk−2, we can pick a suitable Xik−2 in Yk−2. Continuing in this fashion, we construct the subsequence Xi1 , ..., Xik of X that forms the forbidden pattern (k, . . . , 1), a contradiction. G.4 Comparing easy sequences Easy sequences not captured by any known bounds. √ n, and OPT(X) = O(n). By U B we denote We show a sequence X where U B(X) = Ω(n log n), k(X) = the "unified bound" [5] that subsumes both the working set, dynamic finger and entropy bounds. At this time, however, U B is not known to be matched by any online BST. U B can be seen as the sum of logs of "L1 distances". In other words, X is an easy sequence that is not captured by the known classes of easy sequences studied in the literature. √ √ √ Consider a point set P that is the perturbation of the n-by- n grid: Let (cid:96) = n, and P = {(i(cid:96) + (j − 1), j(cid:96) + i − 1) : i, j ∈ [(cid:96)]} . Denote the point (i(cid:96) + (j − 1), j(cid:96) + (i− 1)) by p(i, j). It is easy to check that there are no two points aligning on x or y coordinates: If p(i, j) agrees with p(i(cid:48), j(cid:48)) on one coordinate, it implies that i = i(cid:48) and j = j(cid:48). Therefore, this point set corresponds to a permutation X ∈ Sn. Figure 12(i) illustrates the construction. The following lemma shows that k(X) = √ n. Lemma G.3. X contains all patterns σ of size at most (cid:96). Proof. Pattern σ corresponds to point set {(σt, t)}k t=1, this is order-isomorphic to p(σ1, 1), p(σ2, 2), . . . , p(σk, k). Proposition G.4. U B(X) = Ω(n log n). Finally, we show that OPT(X) = O(n) by describing an offline algorithm that achieves this bound. Our algorithm is similar to Greedy, where we augment some extra steps. First, partition [n] into I1, . . . , I(cid:96) such that Ij = {(j − 1)(cid:96) + 1, j(cid:96)}. Notice that the access sequence starts by touching elements p(1, 1) ∈ I1, p(2, 1) ∈ I2, . . . , p((cid:96), 1) ∈ I(cid:96) and then back to p(2, 1) ∈ I1 and so on. This occurs for (cid:96) rounds. elements, it also touches the two boundaries of the interval Ii, i.e. (i − 1)(cid:96) + 1 and i(cid:96). Proposition G.5. The algorithm produces a feasible solution. The algorithm proceeds just like Greedy, except that, when accessing p(i, j), after touching the minimal 33 Proposition G.6. The cost of this algorithm is O(n). A slightly more involved inductive argument shows that Greedy too has linear cost on X. Proposition G.7. Greedy(X) = O(n). Pattern avoidance and dynamic finger. √ We show examples that k(X) and the dynamic finger bound (denoted by DF (X)) are not comparable. √ Figure 12(ii) illustrates a sequence X where DF (X) = O(n) and k(X) = Ω( n/ log n). First, the sequence n/ log n; then the sequence X starts with the perturbed grid construction of size f (n)-by-f (n) where f (n) = continues with a sequential access of length n − f (n)2. Notice that, in the first phase of the sequence, the distances between consecutive points are Xi+1 − Xi = O(f (n)), except for at most f (n) pairs, which have distance O(f (n)2). In the second phase, the distances are one. So DF (X) = O(f (n)2) log f (n) + √ O(n) = O(n). On the other hand, the f (n)-by-f (n) grid contains all permutations of size f (n), so we have k(X) = Ω( Figure 12(iii) illustrates a 2-recursively decomposable sequence (thus having k(X) = 3) whose dynamic finger bound is Ω(n log n); to see this, notice that Xi+1 − Xi ≥ n/2 for i = 1, . . . , n/2, so we have DF (X) ≥ n n/ log n). 2 log(n/2). Easy non-decomposable sequence. Figure 12(iv) shows the non-decomposable input sequence X = (n/2, n, 1, n − 1, 2, . . . ) on which Greedy achieves linear cost (to see this, observe that Greedy touches at most three elements in each row). G.5 Why is path the roadblock to deque, traversal, split The deque-, traversal- and split conjectures are originally stated for splay trees. We first state the conjectures for any online BST A. Conjecture 2 (Deque conjecture [36]). Starting with any initial tree T with n elements, the cost of A for inserting or deleting the current minimum or maximum elements m times is O(m + n) Conjecture 3 (Traversal conjecture [34]). Starting with any initial tree T with n elements, the cost of accessing a sequence X defined by the preorder sequence of some BST T (cid:48) is O(n). Conjecture 4 (Split conjecture [24]). Starting with any initial tree T with n elements, the cost of A for splitting T by any sequence of n splits is O(n). A split at element x is to delete x and to obtain two trees whose elements are smaller resp. larger than x, each subject to further splittings. Next, we state an easier conjecture which is implied by all three conjectures. Conjecture 5 (Path conjecture). Starting with any initial tree T with n elements, the cost of A for accessing a sequence X defined by the preorder sequence of some BST T (cid:48) which is a path is O(n). To express it in terms of pattern avoidance, the access sequences in the path conjecture avoid both (2, 3, 1) and (2, 1, 3), while the ones in traversal conjecture only avoid (2, 3, 1). Intuitively, the sequence in path conjecture is a sequence that starts from minimum or maximum and moves inwards towards the middle, for example, (1, 2, 3, 4, 10, 9, 5, 6, 8, 7). Theorem G.8. Let A be an online BST. (i) If A satisfies traversal conjecture, then A satisfies path conjecture. (ii) If A satisfies deque conjecture, then there is an online BST A(cid:48) that satisfies path conjecture. (iii) If A satisfies split conjecture, then there is an online BST A(cid:48) that satisfies path conjecture. 34 Proof. (i) This is clear from the statement. (ii) If A satisfies deque conjecture, then A can delete the current minimum or maximum element n times with cost O(n). Observe that the sequence of these deletions can be defined by a BST which is a path. Given A, we construct A(cid:48) that satisfies path conjecture. To access x = 1 or n, A(cid:48) simulates A by deleting x, but then before finishing, A(cid:48) brings x back by making x the root. To access other elements x from the "minimum" ("maximum") side, A(cid:48) also simulates A, but we can see that it must touch x − 1 (x + 1) as well. Again, instead of deleting x, A(cid:48) makes x as a root. For any time, the cost of A(cid:48) is at most the cost of A plus one. (iii) Splitting is equivalent to deleting when applied to the minimum or maximum element. Thus, if A satisfies split conjecture, then A satisfies deque conjecture without inserts. We can then use the argument of (ii). 35 Figure 11: A Greedy execution with initial tree. Access points and initial tree are shown with black circles, points touched by Greedy are gray circles. Black rectangle marks a region in which all permutations are contained, but there is no access point inside. Gray rectangle marks initial tree. 36 Figure 12: From left to right: (i) "perturbed grid" construction when (cid:96) = 5 with Greedy execution, (ii) example with low dynamic finger bound, but high pattern avoidance parameter, (iii) example with low pattern avoidance parameter and high dynamic finger bound, with Greedy execution, (iv) non-decomposable permutation with linear cost Greedy execution. 37
1909.10647
1
1909
2019-09-23T23:03:07
A characterization of graph properties testable for general planar graphs with one-sided error (It is all about forbidden subgraphs)
[ "cs.DS" ]
The problem of characterizing testable graph properties (properties that can be tested with a number of queries independent of the input size) is a fundamental problem in the area of property testing. While there has been some extensive prior research characterizing testable graph properties in the dense graphs model and we have good understanding of the bounded degree graphs model, no similar characterization has been known for general graphs, with no degree bounds. In this paper we take on this major challenge and consider the problem of characterizing all testable graph properties in general planar graphs. We consider the model in which a general planar graph can be accessed by the random neighbor oracle that allows access to any given vertex and access to a random neighbor of a given vertex. We show that, informally, a graph property $P$ is testable with one-sided error for general planar graphs if and only if testing $P$ can be reduced to testing for a finite family of finite forbidden subgraphs. While our presentation focuses on planar graphs, our approach extends easily to general minor-free graphs. Our analysis of the necessary condition relies on a recent construction of canonical testers in the random neighbor oracle model that is applied here to the one-sided error model for testing in planar graphs. The sufficient condition in the characterization reduces the problem to the task of testing $H$-freeness in planar graphs, and is the main and most challenging technical contribution of the paper: we show that for planar graphs (with arbitrary degrees), the property of being $H$-free is testable with one-sided error for every finite graph $H$, in the random neighbor oracle model.
cs.DS
cs
A characterization of graph properties testable for general planar graphs with one-sided error (It's all about forbidden subgraphs) Artur Czumaj ∗ Christian Sohler † Abstract The problem of characterizing testable graph properties (properties that can be tested with a number of queries independent of the input size) is a fundamental problem in the area of property testing. While there has been some extensive prior research characterizing testable graph properties in the dense graphs model and we have good understanding of the bounded degree graphs model, no similar characterization has been known for general graphs, with no degree bounds. In this paper we take on this major challenge and consider the problem of characterizing all testable graph properties in general planar graphs. We consider the model in which a general planar graph can be accessed by the random neighbor oracle that allows access to any given vertex and access to a random neighbor of a given vertex. We show that, informally, a graph property P is testable with one-sided error for general planar graphs if and only if testing P can be reduced to testing for a finite family of finite forbidden subgraphs. While our presentation focuses on planar graphs, our approach extends easily to general minor-free graphs. Our analysis of the necessary condition relies on a recent construction of canonical testers in the random neighbor oracle model that is applied here to the one-sided error model for testing in planar graphs. The sufficient condition in the characterization reduces the problem to the task of testing H- freeness in planar graphs, and is the main and most challenging technical contribution of the paper: we show that for planar graphs (with arbitrary degrees), the property of being H-free is testable with one-sided error for every finite graph H, in the random neighbor oracle model. 9 1 0 2 p e S 3 2 ] S D . s c [ 1 v 7 4 6 0 1 . 9 0 9 1 : v i X r a ∗Department of Computer Science and Centre for Discrete Mathematics and its Applications (DIMAP), University of Warwick. Email: [email protected]. Research partially supported by the Centre for Discrete Mathematics and its Applications (DIMAP), by IBM Faculty Award, and by EPSRC award EP/N011163/1. †Department of Computer Science, TU Dortmund. Email: [email protected]. Research supported by ERC grant No. 307696. 1 Introduction The fundamental problem in the area of graph property testing is for a given undirected graph G to distin- guish if G satisfies some graph property P or if G is ε-far from satisfying P, where G is said to be ε-far from satisfying P if an ε-fraction of its representation should be modified in order to make G satisfy P. The notion of testability of combinatorial structures and of graphs, has been introduced by Goldreich et al. [16], who have shown that many natural graph properties such as k-colorability or having a large clique are testable, that is, have a tester, whose query complexity, that is, the number of oracle queries to the input representation (in [16], to the graph adjacency matrix) can be upper bounded by a function that depends only on the property P and on ε, the proximity parameter of the test, and is independent of the size of the input graph G. This has been later extended to show that testability in the dense graph model (of [16]) is closely related to the graph regularity lemma as one can show that a property is testable (with two-sided error) if and only if it can be reduced to testing for a finite number of regular partitions [2]; for one-sided error testing, it has been shown that a property is testable if and only if it is hereditary or close to hereditary [6]. In particular, we know that subgraph freeness is testable with one-sided error in this model (see, e.g., [5]). We also know of similar logical characterization of families of testable graph properties (for example, every first-order graph property of type ∃∀ is testable, while there are first-order graph properties of type ∀∃ that are not testable [1]). While for many years the main efforts in property testing have been concentrated on the dense graph model, there has been also an increasing amount of research focusing on the bounded degree graph model introduced by Goldreich and Ron [17], the model more suitable for sparse graphs. For example, while it is trivial to test the subgraph freeness with one-sided error in this model, testing H-minor freeness is more complex, and is possible with constant query complexity only if H is cycle-free [10]; if H has a cycle, then n) queries are required and effectively sufficient [10, 14]. Among further highlights, it is known that √ (cid:102)Ωε( every hyperfinite property is testable with two-sided error [24] (see also earlier works in [8, 12, 18]). Rather surprisingly, much less is known for general graphs, that is, graphs with no bound for the max- imum degree (see, e.g., [15, Chapter 10]). The model has been initially studied by Kaufman et al. [21], Parnas and Ron [25], and Alon et al. [3], where the main goal was to study the trade-off between the com- plexity for sparse graphs with that for dense graphs (it should be noted though that these papers were using a slightly different access oracle to the input graph). These results show that most of even very basic prop- erties are not testable. Czumaj et al. [11] addressed a related question in this model, and show that in fact if one restricts the input graphs to be planar (but without any constraints on the maximum degree), then the benchmark problem of testing bipartiteness is testable in the random neighbor query model. In a similar vein, Ito [20] extended the framework from [24] and show that all graph properties are testable for a certain special class of multigraphs called hierarchical-scale-free multigraphs. Still, despite these few results and despite its natural importance, our understanding of graph property testing for degree-unconstrained graphs is very limited. In this paper we take on this major challenge and consider the problem of characterizing all testable graph properties in general planar graphs. We consider the model in which a general planar graph can be accessed by the random neighbor oracle that allows access to any given vertex and access to a random neighbor of a given vertex. We show that, informally, a graph property P is testable with one- sided error for general planar graphs if and only if testing P can be reduced to testing for a finite family of finite forbidden subgraphs. While our presentation focuses on planar graphs, our approach extends easily to general minor-free graphs. 1 Testing for subgraphs-freeness. The central combinatorial problem considered in this paper is that of subgraph detection. The question of identifying frequent subgraphs in big graphs is one of the most funda- mental problems in network analysis, extensively studied in the literature. It has been empirically shown that different classes of networks have the same frequent subgraphs and they differ for different network classes [23]. In this context, frequently occurring subgraphs are also known as network motifs [23]. This raises the question how quickly we can identify the motifs of a given network. Recent work approaches this question by approximating the number of occurrences of certain subgraphs using random sampling [13, 14, 19]. In this paper, we will study the corresponding property testing question: Can we distinguish a graph that has no copies of a predetermined subgraph H from a graph in which we need to remove more than an ε-fraction of its edges in order to obtain a graph that contains no copy of H. This question has received a lot of attention in the property testing setting and it is known that subgraph freeness can be tested with a constant number of queries both in the dense graph model (see, e.g., [5]) and in the bounded degree graph model, where testing subgraph freeness is simple. The problem of testing subgraph freeness has also been studied in the setting of general graphs [3], where the authors give a lower bound of Ω(n1/3) queries for testing triangle freeness, which can be extended to other non-bipartite subgraphs. They also give an upper bound of O(n6/7) queries. We continue this line of research, but will put our focus on sparse graphs, i.e., graphs with bounded average degree. Since it seems that for many properties we cannot hope for extremely efficient, that is, testing algorithms with a constant number of queries in general graphs (often a hard example is a clique n vertices), we focus our attention on planar graphs. It has been only recently shown that bipartiteness on in planar graphs can be tested with a constant number of queries [11]. Our result can be viewed as a major extension of that result: we prove that for every fixed graph H, the property of H-freeness can be tested with a constant number of queries. Our approach extends to general minor-free graphs. √ 1.1 Basic notation Before we proceed with detailed description of our results, let us begin with some basic definitions. Notation. Throughout the paper we use several constants depending on H (forbidden subgraph) and ε. We use lower case Greek letters to denote constants that are typically smaller than 1 (e.g., δi(ε, H)) and lower case Latin letters to denote constants that are usually larger than 1 (e.g., fi(ε, H)). All these constants are always positive. Furthermore, throughout the paper we use the asymptotic symbols Oε,H (·), Ωε,H (·), and Θε,H (·), which ignore multiplicative factors that depend only on H and ε and that are positive for ε > 0. Throughout the paper, for any set of edge-disjoint subgraphs S of G = (V, E), we write G[S] to denote the graph with vertex set V and edge set being the set of edges from the sets in S. 1.1.1 Property testing and H-freeness A graph property P is any family of graphs closed under isomorphism. (For example, bipartiteness is a graph property P defined by a family of all bipartite graphs.) We are interested in finding an algorithm (called tester) for testing a given graph property P, i.e., an algorithm that inspects only a very small part of the input graph G, and accepts if G satisfies P with probability at least 2 3, and rejects G if it is ε-far away from P with probability at least 2 3, where ε is a proximity parameter, 0 ≤ ε ≤ 1. We say a simple graph G is ε-far from P if one has to delete or insert more than εV edges from G to obtain a graph satisfying P1. 1Similarly as in [11], we notice that the standard definition of being ε-far (see, e.g., the definition in [15] or [21]) expresses the distance as the fraction of edges that must be modified in G to obtain a graph satisfying P; comparing this to our definition, instead of modifying εV edges, one modifies εE edges. In this paper we prefer to use the definition with εV edge modifications 2 The main focus of this paper is on the study of testers with one-sided error, that is, testers that always accept all graphs satisfying P and can err only for graphs ε-far from P. (In contrast, two-sided error testers can err (with probability at most 1 3) both for graphs ε-far from P and for graphs satisfying P.) The main graph properties considered in this paper are related to forbidden subgraphs. Throughout the entire paper we will fix H = (V (E), E(H)) to be an arbitrary, simple, finite undirected graph. The notion of a graph H being finite means that its size is constant, though we will allow the constant to be a function of ε, the proximity parameter for property testing, which will be clear from the context. (That is, for a given graph property P and a proximity parameter ε, 0 < ε < 1, we will say that a graph H is finite (for P and ε) if there is s = s(ε) = Oε(1), such that V (H) ≤ s for every n ∈ N.) We say that a given graph G is H-free if G does not contain a copy of H. Following the definition above, we say that a simple graph G is ε-far from H-free if one has to delete more than εV edges from G to obtain an H-free graph. Our definitions extends to families of forbidden graphs in a natural way. If H is a finite family of finite graphs, then a given graph G is H-free if for every H ∈ H, G is H-free. Similarly, G is ε-far from H-free if for every H ∈ H, G is ε-far from H-free. Further, notice that if H is a finite family of finite graphs then since each H ∈ H is of size Oε(1), so is the size of H; hence, H is also a finite family of finite graphs. In our paper we will also consider the following generalization of H-freeness. In what follows, for a given graph property P and n ∈ N, let Pn be the graph property P for n-vertex graphs. Definition 1. (Semi-subgraph-freeness) A graph property P = (Pn)n∈N is semi-subgraph-free if for every ε, 0 < ε < 1, and every n ∈ N, there is a finite family H of finite graphs such that the following hold: (i) any graph G satisfying Pn is H-free, and (ii) any graph G which is ε-far from satisfying Pn, is not H-free (contains a copy of some H ∈ H). Let us emphasize that in Definition 1 by a finite family H of finite graphs we mean that even though H may depend on n, the sizes of H and of any H ∈ H are always upper bounded by a function independent on n, H = Oε(1) and V (H) = Oε(1). 1.1.2 Oracle access model: random neighbor queries The access to the input graph is given by an oracle. We consider the random neighbor oracle, in which an algorithm is given n ∈ N and access to an input graph G = (V, E) by a query oracle, where V = {1, . . . , n}. The random neighbor query specifies a vertex v ∈ V and the oracle returns a vertex that is chosen i.u.r. (independently and uniformly at random) from the set of all neighbors of v. (Notice that in the random- neighbor model, since V = {1, . . . , n}, the algorithm can also trivially select a vertex from V i.u.r.) We believe that the random-neighbor model is the most natural model of computations in the property testing framework in the context of very fast algorithms, and therefore our main focus is on that model. Remark 2. We notice that all our results could be also presented in a variant of the model above in which we would allow only two types of queries: random vertex query, which returns a random vertex, and random neighbor query, which returns a random neighbor of a given vertex v. because our focus is on the study of sparse graphs, graphs with E = O(V ). Indeed, for any class of planar graphs or graphs with an excluded minor, which are the main classes of graphs studied in this paper, the number of edges in the graph is upper bounded by O(V ). Moreover, unless the graph is very sparse (i.e., most of its vertices are isolated, in which case even finding a single edge in the graph may take a large amount of time), the number of edges in the graph is Ω(V ). Thus, under the standard assumption that E = Ω(V ), the ε in our definition and the ε in the previous definitions remain within a constant factor. We use our definition of being ε-far for simplicity; our analysis can be extended to the standard definition in a straightforward way. 3 Each time we call the random neighbor oracle, the returned random vertex or its random neighbor is chosen independently and uniformly at random (i.u.r.). All vertices of the input graph are accessible and distinguishable by their IDs, and there is no requirement about the IDs other than that they are all distinct. Notice that in this model, the (cid:4) tester does not know n, the size of the input graph G. Query complexity. The query complexity of a tester is the number of oracle queries it makes. We say a graph property P is testable if it has a tester with constant query complexity, that is, for every ε, 0 < ε < 1, there is q = q(ε) such that for every n ∈ N the tester has query complexity upper bounded by q (the complexity may depend on P and ε, but not on the input graph nor its size). Other oracle access models. There are some natural variations of the random neighbor oracle model that have been considered in the literature and that can be relevant here. I. One could extend the random neighbor oracle model to the random distinct neighbor oracle model, where one allows for every vertex to query for distinct random neighbors (that is, each time we call the random distinct neighbor query for a given vertex v, the oracle returns a neighbor of v chosen i.u.r. among all neighbors not returned earlier); if all neighbors have been already returned then the oracle would return a special symbol. II. One could consider a model allowing two other types of queries: degree queries: for every vertex v ∈ V , one can query the degree of v, and neighbor queries: for every vertex v ∈ V , one can query its ith neighbor. Observe that by first querying the degree of a vertex, we can always ensure that the ith neighbor of the vertex exists in the second type of query. It should be noted that while our main focus is on the random neighbor oracle model, our testers (and their analysis) for H-freeness can be trivially modified to work in the other three oracle access models (in particular, Theorems 14, 38, and 40 hold in all these models). However, our main result, the characterization of testable properties in planar graphs cannot be extended to the other models (see Section 1.2.4), other than the variant of the random neighbor oracle discussed in Remark 2. For the sake of completeness, in Appendix A we recall some basic properties of planar graphs. 1.2 Our results In this paper we present a characterization of all testable graph properties for general planar graphs in the random neighbor oracle model, showing that, informally, a graph property P is testable with one-sided error for general planar graphs if and only if testing P can be reduced to testing for a finite family of finite forbidden subgraphs (see Theorem 5). Further, the results extend to general families of minor-free graphs G. The result is proven in two steps: First we apply a recent result from [9] (see Theorem 11) to argue in Theorem 12 the (easier) necessary condition, that • in the random neighbor oracle model, any graph property P testable with one-sided error can be reduced to testing for a finite family of forbidden subgraphs. Then we prove our main technical contribution, Theorem 14, that • for a given connected finite graph H, subgraph freeness is testable (can be tested with a constant number of queries) on any input planar graph G, assuming the access to G is via the random neighbor oracle. 4 This latter result extends to arbitrary (not necessarily connected) finite graphs H and to testing for H- freeness for any finite family H of finite graphs, see Theorem 38 in Section 8. By combining these results, we obtain in Theorem 5 • a characterization of graph properties testable with one-sided error for general planar graphs; this result extends to general minor-free graphs. While we believe that our general characterization of all testable graph properties of planar and minor- free graphs is a central problem in property testing and is the main contribution of this paper, we also hope that our constant query time tester for subgraph freeness will further advance our understanding of efficient algorithms for that fundamental problem. Our work is a continuation of our efforts to understand the complexity of testing basic graph properties in graphs with no bounds for the degrees. Indeed, while major efforts in the property testing community have been put to study dense graphs and bounded degree graphs (cf. [15, Chapter 8-9]), we have seen only limited advances in the study of arbitrary graphs, in particular, sparse graphs but without any bounds for the maximum degrees. We believe that this model is one of the most natural models, and it is also most relevant to computer science applications (see also the motivation in [15, Chapter 10.5.3]). While the understanding of testing in general graphs is still elusive, our work makes a major step forward towards understanding of testing properties for most extensively studied classes of graphs, in our case of planar and minor-free graphs. 1.2.1 Overview: Any testable property can be reduced to testing for forbidden subgraphs We begin with an easier part of our characterization (see Section 2 for details). Our approach follows the method of canonical testers for graph properties testable for general graphs developed recently in [9]. The intuition here is rather simple: if a graph property P is testable then all what the tester can do is for a given input graph G to randomly sample a constant number of vertices and then to explore their neighborhoods of constant size, and on the basis of the visited subgraph U of G to decide whether to accept the input graph or to reject it. Further, the assumption that we consider a one-sided error tester implies that the tester must always accept any graph G satisfying P. Therefore, in particular, if we define H as the family of all U for which the tester rejects any input graph G that contains U, then we can argue that any graph G satisfying P must be H-free. The analysis can be easily extended to hold for an arbitrary class of the input graphs, e.g., for planar graphs. (Notice that these arguments show only that any testable graph property P has a finite family H of finite graphs such that P is H-free. However, we do not say anything about any other properties of P; indeed, P may be not only H-free but also may have some other properties. A good example showing the sensitivity of this notion is testing bipartiteness. It has been shown [11] that for general planar graphs bipartiteness is testable with one-sided error, but clearly, bipartiteness cannot be defined as a property of H-freeness for a finite family H of forbidden graphs. However, one can easily show (cf. [10, Section 2.1]) that if an input graph G is ε-far from bipartitiness, then there must be an odd k = O(1/ε2), so that G is O(ε)-far from Ck-free, and this fact suffices to argue that bipartitiness for planar graphs is testable.) To turn this intuition into a formal proof, we need to do some additional work. We rely heavily on the canonical tester developed recently in [9] to argue that to test any testable graph property we can assume that the tester at hand is "oblivious" and works non-adaptively. This allows us to obtain a clean characterization of forbidden subgraphs for any given testable property P. Further, we lift this characterization to extend the analysis to semi-subgraph-free graph properties, which are graph properties defined as H-free or close to H-free, for some finite family H of finite graphs. The analysis is presented in Section 2 (see Theorem 12). 5 1.2.2 Overview: Testing for forbidden subgraphs in planar graphs and minor-free graphs The main technical contribution of this paper is a proof that for planar graphs, the property of being H-free is testable with one-sided error for every connected finite subgraph H, in the random neighbor oracle model, see Theorem 14. This result extends to arbitrary (not necessarily connected) finite graphs H and to testing for H-freeness for any finite family H of finite graphs, see Theorem 38. Further, the results extend to general families of minor-free graphs G, see Theorem 40. Let us first discuss the challenges of the task of testing H-freeness. It has been known for a long time that for bounded degree graphs one can test H-freeness with a constant number of queries using the following simple tester: randomly sample a constant number of vertices and check whether any of them belongs to a copy of H. This result relies on two properties of bounded degree graphs: (i) that it is easy to test whether a given vertex belongs to a copy of H (just run a BFS of depth V (H)), and (ii) that if a given graph is ε-far from H-free then it has many edge-disjoint copies of H that cover a total of a linear number of vertices. But both these properties fail to work for general graphs. For example, for (ii), consider an n-vertex graph G √ n vertices forming a clique. It is easy to see that G is ε-far from H-free n n) queries: one has to perform so many √ (for a sufficiently small ε with respect to the size of H), but all copies of H in G are covered only by vertices and as the result, testing H-freeness trivially requires Ω( queries (in expectation) to hit a first non-isolated vertex. √ with n−√ n isolated vertices and In our analysis, by focusing on planar (or minor-free) graphs, we are able to circumvent the latter obsta- cle (ii) (argued implicitly in Lemma 20), but the former obstacle (i) still persists. Our approach to cope with (i) is by devising a simple modification of BFS search, random bounded-breadth bounded-depth search. By bounding the breadth and depth of the graph exploration we are able to ensure that the complexity of the tester is bounded. However, then the main challenge in our analysis is to analyze this process, to show that indeed, it distinguishes between H-free graphs and graphs that are ε-far from H-free. Our approach relies on a proof that for any planar graph G that is ε-far from H-free there exists a set Q of edge-disjoint copies of H such that, (i) if we can find a copy of H in G[Q] with a constant number of queries, then also in G we can find a copy of H with a constant number of queries, and (ii) if the input graph was G[Q], then we could find a copy of H with a constant number of queries. The construction of the set Q is existential, and is performed by a process of gradually deleting edges of G so that after each round of edge deletions, (i) is maintained, and so that at the end, the structure of G[Q] is simple enough so that (ii) is easy. The process is controlled by a sequence of contractions: we reduce the problem of finding a copy of H in G to the problem of finding a copy of H with one vertex contracted, which in turn, we reduce to the problem of finding a copy of H with two vertices contracted, and so on so forth. The idea is that if at the end of this process, we have to find a copy of H contracted to single vertex, this task is easy to analyze. The main challenge of our analysis here is to carefully manage the contractions to have the analysis going through. In a similar context, the authors in [11] have been arguing that this task is already very complex for cycles in the analysis of constant-length random walks in planar graphs, that is, graphs with good separators and bad expansion. However, by using a sequence of self-reductions relying on contractions (and hence reducing testing Ck-freeness to testing Ck−1-freeness, where Ck is a cycle of length k), the authors in [11] were able to show there that for planar graphs, testing bipartiteness (implicitly, testing Ck-freeness for constant k) can be done with constant query complexity and with one-sided error. The approach presented in our paper can be seen as a major extension of the approach used for testing bipartiteness in [11] to test H-freeness, though the problem of testing H-freeness is significantly more com- plex. Indeed, the central tool used for bipartiteness, contractions of a path or a cycle, becomes problematic 6 when the forbidden graph H has vertices of degree higher than 2. The challenge here is that to contract ver- tices of higher degrees, the information about their neighbors is difficult to be maintained. Still, we follow a similar approach, but since we cannot perform the contraction in term of graphs, we do it via introducing hyperedges, to ensure that after contracting high degree vertices the information about their neighbors is memorized in a form of a hypergraph. This extension of the framework from graphs to hypergraphs makes the entire analysis significantly more complicated and one of our main technical contributions is to make the analysis work for this case. For example, one central challenge is to ensure that the input graph, originally planar, maintain some planarity properties even after applying a sequence of contractions. This task is not very difficult if the contractions were performed in graphs, but when we have to process hypergraphs, main- taining planarity seems to be entirely hopeless. Still, we will show how to efficiently model the connectivity information of the hypergraph using the concept of shadow graphs that are unions of planar graphs. The analysis is long, with many subtle fine points, and is presented in details in Sections 3 -- 7. Remark 3. While in our analysis we did not try to optimize the complexity of the H-freeness tester, focusing on the task of obtaining the query complexity of Oε,H (1), let us mention that in fact, with the analysis as it is now, without any optimization efforts, the complexity of our tester is doubly exponential in V (H)/ε. (cid:4) Remark 4. While our main focus is on the random neighbor oracle model, it is straightforward to extend our testers and their analysis for H-freeness and for H-freeness to the other two oracle access models presented in Section 1.1.2. (However, our main result, the characterization of testable properties in planar graphs (and Theorem 12), cannot be extended to the other models (cf. Section 1.2.4), except the variant of the random neighbor oracle from Remark 2.) (cid:4) 1.2.3 Characterization of graph properties testable with one-sided error for planar/minor-free graphs By combining the results sketched in Sections 1.2.1 and 1.2.2, the following characterization of graph prop- erties testable with one-sided error (in the random neighbor oracle model) for general planar graphs and for minor-free graphs follows: Theorem 5. A graph property P is testable with one-sided error in the random neighbor oracle model for planar graphs (and for minor-free graphs) if and only if P is semi-subgraph-free. The proof of Theorem 5 follows immediately from our Theorem 12 (necessary condition) and Theo- One can read this characterization informally as follows: rems 38 and 40 (sufficient condition). A graph property P is testable with one-sided error in the random neighbor oracle model for planar graphs (or for minor-free graphs) if and only if P can be described as a property of testing forbidden subgraphs of constant size (the maximum size of any forbidden subgraph can be a function of P and ε). 1.2.4 Remarks on the sensitivity and robustness of the oracle access models While our tester for H-freeness (Section 1.2.2) is robust, the characterization presented in Theorem 5 is very sensitive to the oracle model. For example, it might be natural to consider a variant of our random neighbor oracle model to allow for every vertex to query for distinct random neighbors. That is, each time we call the random distinct neighbor query for a given vertex v, the oracle will return a neighbor of v chosen i.u.r. among all neighbors not returned earlier. One important feature of this model is that after deg(v) + 1 queries for a random distinct neighbor of vertex v, we are able to detect the degree deg(v) of vertex v in the input graph. This makes this model more powerful than our random neighbor oracle model, and in particular, it allows to test some properties that cannot be reduced to testing for forbidden subgraphs. For example, 7 ε . Therefore, after randomly sampling 3 in that model one can test connectivity with O(1/ε3) queries and one-sided error (see, e.g., [17]). Indeed, if the input graph G is ε-far from being connected, then it is easy to see that G must have 1 2 εn connected components of size at most 2 ε vertices, with probability at least 2 3 one of the randomly sampled vertices will be in one of these small connected components. Since all vertices in this component must have degree at most 2 ε , we can run BFS algorithm to explore the entire connected component with O(1/ε2) random distinct neighbor queries and verify that this connected component is indeed small, proving that the input graph is ε-far from being connected. This can be easily formalized to obtain a one-sided error tester for connectivity with query complexity O(1/ε3) in the random distinct neighbor oracle model. However, this task cannot be efficiently performed in our random neighbor oracle model (since we can never confirm with a finite number of queries a degree of a given vertex, even if its degree is constant, even if it is 1), and indeed, connectivity testing cannot be reduced to testing for a finite family of forbidden subgraphs and is not is a semi-subgraph-free graph property, even in planar graphs. (This is in contrast to other characterizations presented earlier in the literature, e.g., in [6], where the tester for the dense graphs model reduces to testing for forbidden induced subgraphs, giving a complete characterization of properties testable with one-sided error in terms of hereditary properties.) And so, even for planar graphs, testing connectivity in the random neighbor oracle model is impossible with one-sided error!2 1.3 Organization of the paper We begin in Section 2 with a formal analysis showing the necessary part of our characterization of testable properties, that any testable property is semi-subgraph-free (cf. Theorem 12 in Section 2.4). Then, in Sections 3 -- 7, we present the main technical contribution of this paper, a complete analysis showing the sufficient part of our characterization of testable properties in planar graphs, that for any finite graph H, testing H-freeness is testable in planar graphs. The analysis here is split into several sections, with some auxiliary and technical results deferred to the appendix (Appendix C -- G). We begin in Section 3 with an outline of the proof of testing H-freeness, focusing on connected H. Then, in Section 4, we present our tester and define our framework. Section 5 gives the first (and easiest) step in our transformation and show that any graph that is ε-far from H-free has a linear number of edge-disjoint copies of H. Then, in Section 6, we show how the contractions (cf. Section 1.2.2) can be performed in hypergraphs, to ensure existence of a sought set Q of edge-disjoint copies of H in which we can detect a copy of H. The analysis is then completed in Section 7. Finally, in Section 8 we discuss the extension to families of arbitrary finite graphs and in Section 9 we discuss the extension to minor-free graphs. Some final conclusions are in Section 10. 2 Any testable property can be reduced to testing for forbidden subgraphs In this section we provide a formal proof of the necessary (and easier) condition in our characterization, Theorem 12, that any one-sided-error testable property for arbitrary graphs can be reduced to testing for forbidden subgraphs of constant size (this claims holds for any finite family of graphs, not only for planar graphs). It should be noted that each graph in the family of forbidden graphs may have size depending on ε, the proximity parameter of the tester. 2To see this, consider two planar graphs: a cycle Cn on n vertices, which is connected, and a perfect matching Mn on n 3 . But at the same time, vertices, which is ε-far from connected (for ε < 1 if we consider the tester on Cn (which must be accepted) then after performing q queries, with probability at least 2−q, and so with positive probability, it will see only a subgraph of Mn. Therefore, since we consider one-sided error testers which must accept Cn, we conclude that no one-sided error tester can reject Mn. 2 ). Any tester should reject Mn with probability at least 2 8 Our analysis critically relies on a recently developed in [9] canonical tester that shows that to test any testable graph property we can assume that the tester at hand is "oblivious" and works non-adaptively. This will allow us later to obtain a clean characterization of forbidden subgraphs for any given testable property P. 2.1 Bounded-breadth bounded-depth graph exploration and bounded-discs Our analysis relies on a random (BFS-like) bounded-breadth bounded-depth search, Bounded-BFS-Traverse below, an exploration algorithm similar to BFS of depth t. The algorithm runs from a given vertex a random BFS-like exploration of breadth d and of depth t using the random neighbor oracle (i.e., every vertex selects d of its neighbors i.u.r. and recursively continues the process from them, until depth t is reached). The main difference is that instead of visiting all neighbors of every vertex, like in the standard BFS algorithm, we visit only d neighbors chosen i.u.r., to limit the complexity of the search algorithm. Bounded-BFS-Traverse (G, v, d, t): • Let L0 = {v}. • For (cid:96) = 1 to t do: (cid:5) Let L(cid:96) = ∅ and E(cid:96) = ∅. (cid:5) For every u ∈ L(cid:96)−1 do: ◦ Choose d neighbors of u using d random neighbor queries; call them Γu. ◦ Let Eu = {(u, x) : x ∈ Γu}. ◦ Set L(cid:96) = L(cid:96) ∪ Γu and E(cid:96) = E(cid:96) ∪ Eu. (cid:5) L(cid:96) = L(cid:96) \(cid:83)(cid:96)−1 • Return the subgraph of G induced by the edges(cid:83)t i=0 Li. (cid:96)=1 E(cid:96). We use the notion of bounded-breadth/depth search Bounded-BFS-Traverse to define bounded discs. Definition 6. ((d, t)-bounded disc) For given d, t ∈ N, graph G = (V, E), and vertex v ∈ V , a (d, t)- bounded disc of v in G is any subgraph U of G that can be returned by Bounded-BFS-Traverse (G, v, d, t). Vertex v is called a root of the (d, t)-bounded disc U. Let us observe that, assuming that d ≥ 2, Bounded-BFS-Traverse (G, v, d, t) performs(cid:80)t queries to the input graphs. Accordingly, for d ≥ 2, any (d, t)-bounded disc has at most(cid:80)t vertices and at most(cid:80)t i=1 di ≤ 2dt edges. i=1 di ≤ 2dt i=0 di ≤ 2dt 2.2 Rooted graphs, their basic properties, and semi-rooted-subgraph-freeness In our analysis it will be sometimes useful to consider also rooted graphs, that is, graphs with some number of vertices distinguished as special vertices called roots. (For example, bounded discs from Definition 6 are rooted graphs.) To analyze similarities between rooted graphs, we will use the following definition. Definition 7. (Root-preserving isomorphism) Let Q = (V (Q), E(Q)) and Q(cid:48) = (V (Q(cid:48)), E(Q(cid:48))) be two rooted graphs. A root-preserving isomorphism between Q and Q(cid:48), denoted Q ∼=r Q(cid:48), is a bijection f : V (Q) → V (Q(cid:48)) such that u is the root of V (Q) if and only if f (u) is the root of V (Q(cid:48)), and (u, v) ∈ E(Q) if and only if (f (u), f (v)) ∈ E(Q(cid:48)). If Q ∼=r Q(cid:48), then we say that Q is root-preserving isomorphic to Q(cid:48). 9 We will extend this definition to compare a rooted graph with its occurrences (in a sense of root- preserving isomorphisms) in a large graph (which does not necessarily have to be rooted). Definition 8. Let G be an undirected graph and let Q be a rooted graph. A rooted copy of Q in G is a subgraph U of G such that one can assign the roots to U so that there is a root-preserving isomorphism between Q and the rooted version of U. For an arbitrary set Q of rooted graphs, we say that G is Q-rooted- free if for every Q ∈ Q, there is no rooted copy of Q in G. With these definitions, we are ready to present our auxiliary graph property notion. Definition 9. (Semi-rooted-subgraph-freeness) A graph property P is semi-rooted-subgraph-free if for every ε, 0 < ε < 1, and every n ∈ N, there is a finite family H of finite graphs such that the following hold: (i) any graph G satisfying Pn is H-rooted-free, and (ii) any graph G which is ε-far from satisfying Pn, is not H-rooted-free. Similarly as in Definition 1, the notion of a family H of finite graphs means that every graph H ∈ H is finite, i.e., V (H) = Oε(1). 2.3 Modeling forbidden subgraphs in rooted graphs While our analysis uses rooted graphs, their use is purely auxiliary because of the following simple fact. Lemma 10. If a graph property P is semi-rooted-subgraph-free then P is also semi-subgraph-free. Proof. This follows easily from the definitions of semi-rooted-subgraph-free and semi-subgraph-free prop- erties. For any rooted graph H, let H denote the same graph with removed roots (that is, we remove the labels defining the roots); similarly, for any family H of rooted graphs, let H = {H : H ∈ H}. Then we claim that for any graph G be an arbitrary graph and any family H of rooted graphs, (a) if G is H-rooted-free then G is also H-free, and (b) if G is not H-rooted-free, then G is also not H-free. Indeed, to see part (a), suppose, by contradiction, that G is not H-free, that is, there is H with H ∈ H such that H is a subgraph of G. But then G has a rooted copy of H, since we can take the roots of H and assign them to H, so that there is a root-preserving isomorphism between H and the rooted version of H. Since G has a rooted copy of H, we conclude that G is not H-rooted-free, which is contradiction. To see part (b), suppose, by contradiction, that G is H-free, that is, there is no H ∈ H such that G has a copy of H. But then, clearly, G is H-rooted-free, since otherwise, there would be H ∈ H such that G had a rooted copy of H, which would imply that H was a subgraph G; contradiction. Now, we are ready to complete the proof of Lemma 10. By Definition 9, if P is semi-rooted-subgraph- free then there exists a finite family H of finite rooted graphs such that (i) any graph G satisfying P is H- rooted-free, and (ii) any graph G which is ε-far from satisfying P, is not H-rooted-free. If we combine these properties with our claim above, then we obtain that for the finite family of finite graphs H = {H : H ∈ H}, (i') any graph G satisfying P is H-rooted-free, and thus (by (a)) also H-free, and (ii') any graph G which is ε-far from satisfying P, is not H-rooted-free, and thus (by (b)) also not H-free. (cid:4) Therefore P is semi-subgraph-free (cf. Definition 1). 10 2.4 Canonical testers and reduction to testing for forbidden subgraphs Next, our analysis follows the framework described in Section 1.2.1. We rely on the following Theorem 3.6 from [9] describing a canonical way of designing any tester in the random neighbor oracle model. Theorem 11 (Canonical tester [9]). Let P = (Pn)n∈N be a graph property that can be tested in the random neighbor oracle model with query complexity q = q(ε) and error probability at most 1 3. Then for every ε, there exists q(cid:48) = Θ(q), and an infinite sequence Q = (Qn)n∈N such that for every n ∈ N, • Qn is a set of rooted graphs such that each Q ∈ Qn is the union of q(cid:48) many (q(cid:48), q(cid:48))-bounded discs; • the property Pn on n-vertex graphs can be tested with error probability at most 1 3 by the following canonical tester (with query complexity qO(q)): (cid:5) sample a set (possibly, a multiset) S of q(cid:48) vertices chosen i.u.r.; (cid:5) for each sampled vertex v, run Bounded-BFS-Traverse (G, v, q(cid:48), q(cid:48)) to get a (q(cid:48), q(cid:48))-bounded disc Uv; (cid:5) reject if and only if there exists a root-preserving isomorphism between the union of the explored ∼=r Q. Furthermore, if P = (Pn)n∈N can be tested in the random neighbor oracle model with query complexity q(ε) with one-sided error, then the resulting canonical tester for P has one-sided error too. (q(cid:48), q(cid:48))-bounded discs and some element Q ∈ Qn, that is, there is Q ∈ Qn with(cid:83) v∈S Uv Theorem 11 from [9] shows that without loss of generality, we can assume that any testable graph property can be tested by a canonical tester with constant query complexity. With Theorem 11, Lemma 10, and Definitions 1 and 9 at hand, we are now ready to present the main result of this section. Theorem 12. If a graph property P is testable with one-sided error in the random neighbor oracle model then P is semi-subgraph-free. Proof. First, notice that thanks to Lemma 10, it is enough to show that if a graph property P is testable with one-sided error in the random neighbor oracle model then P is semi-rooted-subgraph-free (cf. Definition 9). Let us fix n ∈ N and ε, and suppose that Pn is a graph property on n-vertex graphs that can be tested in the random neighbor oracle model with query complexity q(ε) and one-sided error. By Theorem 11 from [9], we can assume that Pn is tested by a canonical tester T that satisfies the conditions of Theorem 11. In particular, let Qn be the family of forbidden rooted graphs for Pn (union of q(cid:48) many (q(cid:48), q(cid:48))-bounded discs) whose existence follows from Theorem 11. We will show that so defined family of rooted graphs satisfies the conditions in Definition 9, proving that P is semi-subgraph-free. Let us first notice that each rooted graph Qn has at most 2(q(cid:48))q(cid:48) edges, and so Qn is a finite family of finite rooted graphs. Let us next show item (i) of Definition 9, that any n-vertex graph G satisfying Pn is Qn-rooted-free (cf. Definition 8). The proof is by contradiction and so suppose that there is a graph G satisfying Pn which contains a rooted copy of Q ∈ Qn. Then, with a positive probability the canonical tester T on G will take that copy of Q ∈ Qn, and by the definition, it will reject G. This means that the tester has a nonzero probability of rejecting G, contradicting our assumption that the tester T is one-sided. Now, we want to prove item (ii) of Definition 9. Let G be an n-vertex graph that is ε-far from satisfying Pn. Any tester for Pn should reject G with nonzero probability. By definition of our canonical tester T, G is rejected by T only if G contains a rooted subgraph U such that if the tester T gets U from the oracle, then U ∼=r Q. By definition of T and Qn this means that Q ∈ Qn, which proves item (ii) of Definition 9. vertices and at most 2(q(cid:48))q(cid:48) 11 We have shown that if a graph property P is testable with one-sided error in the random neighbor oracle model then P is semi-rooted-subgraph-free. By Lemma 10, this yields that P is semi-subgraph-free, (cid:4) completing the proof. Remark 13. While Theorem 12 is presented for any general graphs, it is straightforward to extend it to hold also for (cid:4) infinite classes of graphs, for example, for planar graphs, or for the family of minor-closed graphs. 2.5 Uniform characterization using oblivious testers and forbidden subgraphs While Theorem 11 from [9] allows to simplify the analysis of testable properties, the analysis as in Theorem 12 obtains non-uniform testers, in the sense of the dependency on n. We could make our result uniform by considering a special class of uniform testers, which we call oblivious testers, that capture the essence of testers of testable properties in the flavor of Theorem 11 (see [6] for a similar notion in the context of testing dense graphs). We will discuss this characterization in Appendix B. 3 Testing H-freeness: high-level view We begin our analysis with fixing an arbitrary finite, connected, undirected, simple graph H = (V (E), E(H)).3 Our tester of H-freeness relies on a simple graph exploration. We first describe our algorithm for testing H-freeness of planar graphs with arbitrary degrees and provide the high level structure of its analysis. We defer most of technical details to Sections 4 -- 7 and Appendix. Our algorithm relies on a random bounded-breadth bounded-depth search, Random-Traverse below, which uses Bounded-BFS-Traverse (G, v, d, t) from Section 2.1. (Let us remind, cf. page 9, that Bounded- BFS-Traverse (G, v, d, t) is similar to BFS of depth t starting at vertex v, though instead of visiting all neighbors of every vertex, one visits only d neighbors chosen i.u.r., to limit the complexity of the algorithm.) Random-Traverse (G, d, t): • Pick a random vertex v ∈ V i.u.r. and run Bounded-BFS-Traverse (G, v, d, t). Our tester Random-Exploration runs f (ε, H) times our search algorithm Random-Traverse with pa- rameters d = h(ε, H), t = g(ε, H), each time checking if the graph induced by the visited edges contains a copy of H, or does not. The algorithm accepts G as H-free if and only if all calls found no copy of H in G. Tester: Random-Exploration (G, H, ε): (with three implicit parameters, integer functions f, g, h) • Repeat f (ε, H) times: (cid:5) Run Random-Traverse (G, h(ε, H), g(ε, H)) and let E be the resulted set of edges. (cid:5) If the subgraph of G induced by the edges E contains a copy of H, then reject. • If every subgraph explored is H-free, then accept. The following main theorem describes key properties of our tester. Theorem 14. Let H be connected. There are positive functions f, g, h, such that for any planar graph G: 3While our analysis here assumes that H is connected, this is clearly not required for the main result. If H is disconnected then with the coloring trick (cf. Section 4.1.1), one could have identical analysis and consider all connected components one by one, extending the results to arbitrary, not necessarily connected H. We will discuss this in details in Section 8. 12 • if G is H-free, then Random-Exploration(G, H, ε) accepts G, and • if G is ε-far from H-free, then Random-Exploration(G, H, ε) rejects G with probability at least 0.99. It is obvious that the first claim holds: if G is H-free, then so is every subgraph of G, and therefore Random-Exploration always accepts. Therefore, to prove our main result, Theorem 14, it suffices to show that if G is ε-far from H-free, then Random-Exploration rejects G with probability at least 0.99. In view of that, from now on, we assume that the input graph G is ε-far from H-free for some constant ε > 0. We note that it is enough to show that a single instance of the random bounded-breadth bounded-depth search (Random-Traverse) of breadth Oε,H (1) and depth Oε,H (1) finds a copy of H with probability Ωε,H (1). Indeed, for any functions f, g, and h, if Random-Traverse (G, d, t) with h(ε, H) = Oε,H (1) and g(ε, H) = Oε,H (1) finds a copy of H with probability at least 5/f (ε, H) = Ωε,H (1), then this implies that f (ε, H) = Oε,H (1) independent calls to Random-Traverse (G, d, t) detect at least one copy of H with probability at least 1 − (1 − 5/f (ε, H))f (ε,H) ≥ 1 − e−5 ≥ 0.99. Therefore, in the remainder of the paper, we analyze the following algorithm Tester(G, H, d, t). Tester (G, H, d, t): • Run Random-Traverse (G, d, t) and let E be the resulted set of edges. • If the subgraph of G induced by the edges E contains a copy of H, then reject. • If not, then accept. We will show the following central technical theorem. Theorem 15. Let H be a connected undirected graph. There are positive functions d = d(ε, H) = Oε,H (1) and t = t(ε, H) = Oε,H (1) such that for any planar graph G that is ε-far from H-free, Tester(G, H, d, t) finds a copy of H with probability Ωε,H (1). The query complexity of Tester(G, H, d, t) is O(dt) = Oε,H (1). Since by our discussion above Theorem 15 yields Theorem 14, we will focus on proving Theorem 15. We also notice that the query complexity of the tester follows directly from its definition, and so we will concentrate on showing that for d = Oε,H (1) and t = Oε,H (1), Tester(G, H, d, t) finds a copy of H with probability Ωε,H (1). 3.1 Outline of the proof of testing H-freeness In this subsection we outline the key ideas behind our proof of testing H-freeness. Since the proof is long and complex, we will give here mostly some underlying intuitions, leaving the details to Sections 4 -- 7. By our discussion above, it suffices to focus on the case when the input graph G is ε-far from H-free. Our analysis relies on the following result (shown in Lemma 17) that every simple planar graph G that is ε-far from H-free has a subgraph G satisfying the following: (a) if Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1), then Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1), and (b) Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1). Our first (and easy) step towards proving this property is to show that G contains a linear number of edge-disjoint copies of H (see Lemma 20). This follows by iteratively removing copies of H and observing 13 (a) (b) (c) Figure 1: (a) Consider a part of the input graph G with numbered vertices corresponding to the colored vertices in a copy of H in G and thick edges corresponding to the edges in that copy of H. (b) We have a subgraph H1 of H consisting of the vertices and edges marked by the grey area, with vertices {2, 3, 4, 6, 7} separating H1 from the rest of G. (c) The gadget obtained by removing internal vertices {1, 5} and replacing H1 by a hyperedge connecting vertices {2, 3, 4, 6, 7}. that by the definition of being ε-far from H-free, we have to remove εn edges to make G free of copies of H. In the following we will use Q to denote a set (of linear size) of edge-disjoint copies of H in G. We continue by showing that given Q, we can compute a subset Q(cid:48) of linear size such that the graph G[Q(cid:48)] (subgraph of G on vertex set V and with edge set being the union of the edges of the subgraphs in Q(cid:48)) satisfies the first property above. The proof essentially shows that one can remove copies from Q(cid:48) until every vertex in G[Q(cid:48)] has degree either 0 or a small positive constant times its degree in G. Next, we would like to define a sequence of sets Q = Q0 ⊇ Q1 ⊇ ··· ⊇ QV (H) with associated hypergraphs with the following interpretation. The hyperedges will be labelled in such a way that we are able to recover the set Qi from it. We will use hyperedges to replace certain subgraphs of H and their corresponding part in G. Hyperedges. We will now describe the use of hyperedges as replacements for copies of subgraphs of H in G. Let G∗ be a subgraph of G that has a copy of H. Consider a subgraph H1 of H and let u1, . . . , u(cid:96) be the vertices in the copy of H1 in G∗ that separate G \ H1 from H1, so that (cf. Figure 1): (a) every vertex from {u1, . . . , u(cid:96)} is adjacent in G∗ to some vertex H1 \ {u1, . . . , u(cid:96)}, (b) every vertex in H1 \ {u1, . . . , u(cid:96)} is adjacent in G∗ only to vertices from H1, and (c) {u1, . . . , u(cid:96)} forms an independent set in H1. Then, we can construct a gadget to represent that copy of H1 by removing from H1 all vertices and edges from H1 \ {u1, . . . , u(cid:96)} and replacing them by a single hyperedge {u1, . . . , u(cid:96)}. We will encode the structural information of the subgraph replaced by the hyperedge in a label, so that it may happen that we have parallel hyperedges with different labels. In addition to the above structural role we recall from the previous section that the idea of hyperedges was to encode that whenever (a hypergraph version of) Random-Traverse enters the hyperedge then it will reach all its vertices. Our final goal will be to construct a hypergraph that only consists of selfloops, so that we can argue easily that our tester finds a copy of H by finding a corresponding set of labelled selfloops. Vertex coloring. A major difficultly in applying our approach is to find subgraphs that can be replaced. One way to simplify this question is to color both the vertices of H and the vertices of G with V (H) colors, such that every vertex of H receives a distinct color and every copy of H in Q has the same coloring as H. We show in Lemma 20 that there is a coloring χ of G and H such that G contains a set Q containing 14 7 5 6 4 3 2 1 7 5 6 4 3 2 1 7 6 4 3 2 a linear number of such edge-disjoint colored copies of H. An important feature of this coloring, which will be very useful in finding vertices that can be replaced by hyperedges, is that every vertex has the same role in all subgraphs from Q it is contained in. Getting from Qi to Qi+1. Next we describe how we move from the set Qi to Qi+1. This is the main step in our reduction and it will be partitioned in a number of substeps. We start with an overview. In each round we perform the following high level process: • Select a vertex vi ∈ V (H). • Simultaneously, contract every vertex u ∈ V (Hi(Qi)) with χ(u) = χ(vi) as follows: (cid:5) for every colored copy h of H in Qi+1 that contains vertex u: ◦ add a new hyperedge consisting of vertices in N h the corresponding hypergraph) other than u (that is, u /∈ N h (cid:5) remove vertex u (with all incident edges from Hi(Qi)). i (cid:104)u(cid:105), where N h i (cid:104)u(cid:105)); i (cid:104)u(cid:105) is the set of neighbors of u in h (in We remark that our algorithm above ensures that no neighboring vertices are contracted since the col- oring χ has no monochromatic edges. This follows from the fact that every edge in G[Q] belongs to some copy of H and the coloring of H has no monochromatic edge. Thus, we can perform the contractions independently. In our construction we will require that the contracted vertices additionally satisfy some stronger prop- erties. This is to maintain (approximately) some basic properties of planar graphs. • We want to ensure that all contractions in Hi(Qi) corresponding to the contraction of vi are consistent, that is, the contraction of u is the same in every colored copy of H that contains u (that is, for every vertex u in with χ(u) = χ(vi), for any two colored copies h1, h2 of H in Qi+1 containing vertex u, we have N h1 i (cid:104)u(cid:105) = N h2 i (cid:104)u(cid:105)). The required property is captured in the following definition (see also Definition 26). Definition 16. (Safe vertices]) Let Qi be a set of edge-disjoint colored copies of H in G and let Q ⊆ Qi. We call a vertex u safe if for all colored copies h ∈ Q of H that contain u, the sets N h i (cid:104)u(cid:105) are the same. Finding safe vertices. Our next challenge is to show that we can find many (a linear number) safe vertices of the same color. In order to do so, we will delete elements from the current set Qi in a controlled way until we can guarantee that many safe vertices of the same color exist. An important concept that we define here is that of a shadow graph. A shadow graph is a union of V (H) planar graphs and it models the neighborhood relation of our hypergraph, such that two vertices are adjacent in the shadow graph if and only if they belong to the same edge in the hypergraph. The main use of shadow graphs is to show in the upcoming construction that our hypergraph still satisfies some near-planar properties that will be useful in the analysis. The concept of shadow graphs and the proof of their existence is one of the main new ideas in this paper. Using the existence of shadow graphs, we can properly implement the process of contractions via hyper- edges, proceed similarly as in an earlier paper about testing of bipartiteness in planar graphs [11], where the shadow graphs guarantee that we still approximately satisfy the properties of planar graphs that were used the previous paper [11]: We first prove that we can construct a subset Q of Qi of linear size such that every copy of H in Q has a vertex of constant degree in G[Q]. Then we use this claim in the proof of Lemma 32 to show how to construct a subset Q∗ of Qi such that every copy of H in Q∗ contains a safe vertex. 15 Wrapping things up. What remains to do is to prove that our construction satisfies the second required property of our tester: ⊗ Tester(G[Q], H, d, t) finds a copy of H in G[Q] with probability Ωε,H (1). We define Q to be the set QV (H) obtained in the final round of our reduction. We will then prove ⊗ by showing the following two properties (proven in Claims 36 and 37), where, informally, HTester is an extension of Tester to hypergraphs, Hi(Q) denotes the hypergraph corresponding to Qi, Mi is the hypergraph corresponding to H in round i, and Repi corresponds to the function assigning vertices contracted in the process to their representatives in the hypergraph Hi(Q). 1. the probability that HTester (HV (H)(Q), RepV (H),MV (H),V (H)2, 1) finds a copy of MV (H) is Ωε,H (1), and 2. for every i, 1 ≤ i < V (H), • if the probability that HTester (Hi+1(Q), Repi+1,Mi+1, d, t) finds a copy of Mi+1 is Ωε,H (1), • then the probability that HTester (Hi(Q), Repi,Mi,V (H) · d, 2t) finds a copy of Mi is Ωε,H (1). The proof of Claim 36 now exploits that MV (H) only consists of selfloops, which can easily be found and the proof of Claim 37 formalizes our idea that if our random walk enters a hyperedge in Hi+1(Q) then we perform with constant probability the same operation in Hi+1(Q) in two steps of our randomized process. Combining the results with our previous considerations yields our main statement: H-freeness in planar graphs is constant query-time testable. 4 Analysis of Tester when G is ε-far from H-free Because of the arguments from the previous section, the remainder of the paper deals with the main technical challenge of our result: proving Theorem 15 that in any simple planar graph G = (V, E) that is ε-far from H-free, our algorithm Tester finds with sufficient probability a copy of H. Our analysis relies on the following lemma showing the existence of a special subgraph G of G: Lemma 17. For every ε ∈ (0, 1), there are d = d(ε, H) and t = t(ε, H), such that for every simple planar graph G = (V, E) that is ε-far from H-free, there is a subgraph G of G with the following properties: (a) if Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1), then Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1), and (b) Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1). Observe that if such a subgraph G as promised in Lemma 17 always exists, then these properties imme- diately imply that Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1) and therefore, by the discussion above, Theorems 14 and 15 follow. In order to prove Lemma 17, we will show that for any simple planar graph G that is ε-far from H-free, there exists a set Q of edge-disjoint copies of H in G for which G[Q], the subgraph of G induced by the edges of Q, satisfies the properties of graph G in Lemma 17. The construction of the set Q and the analysis of its properties form the main technical contribution of our paper. While part (a) in Lemma 17 is rather easy to achieve and to analyze (thanks to Lemma 18 in Section 4.1.2), the main challenge of our construction is in 16 ensuring part (b) in Lemma 17. For that, we use a rather elaborate construction to gradually find a sequence Q1 ⊇ Q2 ⊇ ··· ⊇ QV (H) of sets of edge-disjoint copies of H in G, with QV (H) = Ωε,H (V ), such that the final set QV (H) is the set Q that defines G = G[QV (H)] in Lemma 17. The construction of the sequence Q1 ⊇ Q2 ⊇ ··· ⊇ QV (H) of sets of edge-disjoint copies of H in G, with QV (H) = Ωε,H (V ), for which we could easily argue that Tester(G[QV (H)], H, d, t) finds a copy of H in G[QV (H)] with probability Ωε,H (1), is the most challenging and technical contribution of our paper. We begin with a simple construction of Q1 which is a set of Ωε,H (V ) edge-disjoint copies of H in G (cf. Lemma 20). Then our construction is iterative: we design a reduction that takes set Qi of Ωε,H (n) edge-disjoint copies of H and we construct from it another set Qi+1 ⊆ Qi with Qi+1 = Ωε,H (Qi) for which we simplify the structure of G[Qi+1] with respect to that of G[Qi]. To guide our process, we associate with each Qi a certain hypergraph Hi(Qi) that is constructed from Qi by contracting vertices of H in a specific, consistent way (cf. Section 6.3). The purpose of Hi(Qi) is to model the copies of H by a hypergraph on a smaller number of vertices, by contracting vertices (and incident edges) which are known to be visited by Random-Traverse via other means. We will construct a sequence of hypergraphs H1(Q1),H2(Q2), . . . ,HV (H)(QV (H)) that correspond to sets Q1, Q2, . . . , QV (H), and a sequence of hypergraphs M1,M2, . . . ,MV (H) that are "shrunk" copies of H, each Mi with V (H) − i + 1 vertices, such that, informally, for our algorithm of selecting Q1, Q2, . . . , QV (H), the following conditions holds: • the probability of finding by Random-Traverse a copy of H in G[Q1] is the same as the probability of finding by Random-Traverse a copy of M1 in H1(Q1), • the probability of finding by Random-Traverse a copy of Mi+1 in Hi+1(Qi+1) is similar to the probability of finding by Random-Traverse a copy of Mi in Hi(Qi), and • using the fact that MV (H) has a single vertex, one can easily estimate the probability of finding by Random-Traverse a copy of MV (H) in HV (H)(QV (H)). With these three properties at hand, the main theorem will follow. One central feature of our analysis via the study of hypergraphs is to ensure that the underlying hyper- graphs have some basic planar graphs-like properties. (In particular, informally, in our analysis we would like to argue that there is always a constant fraction of low-degree vertices.) While we do not have a use- ful characterization of planar hypergraphs, we will be able to model some planarity-like properties of the hypergraphs using some special graph reduction (via shadow graphs), see Lemma 29 and Appendix F. In the following sections we will develop this framework in details, finalizing it in Section 7 that proves the desired properties above. 4.1 Auxiliary technical tools We begin with three auxiliary tools in our analysis, the study of the problem of finding colored copies of H in G (Section 4.1.1), a reduction simplifying condition (a) of Lemma 17 (Section 4.1.2), and extension of the testing and graph exploration framework to hypergraphs (Section 4.1.3). 4.1.1 Auxiliary tools: Finding colored copies of H in G To simplify the analysis, we will consider colored copies of H in G. Let us color all vertices of H using V (H) colors, one color for each vertex (without loss of generality, the colors are {1, 2, . . . ,V (H)}). While the coloring is not needed by the algorithm, it will simplify the analysis. With this in mind, in- stead of showing that our algorithm Tester finds with sufficient probability a copy of H, we will show (cf. 17 Lemma 20) that there is a coloring χ of vertices of G such that Tester finds (with sufficient probability) a colored copy of H, that is, a copy of H in G with colors of the vertices in the copy consistent with the coloring χ. (While this statement sounds trivial, since once we found a copy of H in G we can always color vertices of G to be consistent with the coloring of H, the colors will be helpful in our analysis.) Therefore, from now on, whenever we will aim to find a copy of H we will mean to find a colored copy of H consistent with given coloring χ. Let us notice one immediate implication of this assumption: if Qi and χ are fixed, then one can think about every edge e as a labeled edge, since the colors of its endpoints define a unique edge in H that e corresponds too. We will use this property implicitly throughout the paper, without mentioning it anymore. 4.1.2 Auxiliary tools: Simplifying condition (a) of Lemma 17: (via edge-disjoint copies of H) We show that one can simplify condition (a) of Lemma 17 for the special case when the subgraph G of G is a union of a linear number of edge-disjoined colored copies of H (a similar approach has been also used in [11]). That is, if there is a graph G[Q] with a linear number of edge-disjoint colored copies of H, then Lemma 18 shows that there is always a subset Q(cid:48) ⊆ Q with cardinality Q(cid:48) = Ωε,H (Q) such that the graph G[Q(cid:48)] satisfies property (a). Lemma 18. (Transformation to obtain property (a)) Let G = (V, E) be a simple planar graph. Let Q be a set of Ωε,H (V ) edge-disjoint colored copies of H in G. Then there exists a subset Q(cid:48) ⊆ Q, Q(cid:48) = Ωε,H (V ), such that the graph G[Q(cid:48)] satisfies condition (a) of Lemma 17. The proof of Lemma 18, as a natural extension of the approach from [11], is deferred to Appendix C. 4.1.3 Traversing hypergraphs and testing hypergraph M-freeness In Section 4, we described two central algorithms used for testing H-freeness: Random-Traverse, and Tester. Both these algorithms were presented in a form required to test H-freeness in a graph. However, in our transformations we will apply the same algorithms to hypergraphs, to test whether a hypergraph H (in a form of Hi(Qi), as defined in Section 6.3) is M-free, where M is a fixed hypergraph (which in our applications will be Mi, as defined in Section 6.2). While the modifications are rather straightforward, for the sake of completeness, we will describe below these algorithms to be run on a hypergraph. Furthermore, in our algorithms for hypergraphs we will have one additional parameter, a representative function Rep : V → V , which describes the way how the edges have been contracted (cf. Definition 34 and Appendix F). The idea behind the representative function Rep is that any vertex u that either is in the hypergraph H or which does not belong to any set of copies of H has Rep(u) = u, but any other vertex u from G that has been contracted and now does not appear in H, has Rep(u) equal to its representative in H. In the latter case, the intuition is that the representative is a vertex in H that with probability Ωε,H (1) can be reached from u in Oε,H (1) steps, if Random-Traverse (run in G) started at u. Remark 19. Let us remark that in HTester and Random-HTraverse below we use the input graph G implicitly, since in Random-HTraverse we directly refer here to the set V , which is the vertex set of G, and we do so indirectly via the use of Rep, whose domain and range are V . Further, in our applications we will always have that V (H) ⊆ V . (cid:4) 18 Random-HTraverse (H, Rep, d, t): • Pick a vertex v ∈ V i.u.r., and let L0 = {Rep(v)} (i.e., L0 has a randomly selected vertex, such that any u ∈ V is chosen with probability Rep(−1)(u) ). V • If v is a vertex of H then for (cid:96) = 1 to t do: ◦ Choose d edges incident to u in H i.u.r.; call them E(cid:96),u. ◦ Let Γu be the set of vertices in E(cid:96),u. ◦ Set L(cid:96) = L(cid:96) ∪ Γu and E(cid:96) = E(cid:96) ∪ E(cid:96),u. (cid:5) Let L(cid:96) = ∅ and E(cid:96) = ∅. (cid:5) For every u ∈ L(cid:96)−1 do: (cid:5) L(cid:96) = L(cid:96) \(cid:83)(cid:96)−1 • Return the edges(cid:83)t i=0 Li. (cid:96)=1 E(cid:96). HTester (H, Rep,M, d, t): • Run Random-HTraverse (H, Rep, d, t) and let E be the resulted set of edges. • If the sub-hypergraph of H induced by the edges E contains a copy of M, then reject. • If not, then accept. 5 Finding the first set Q1 of edge-disjoint colored copies of H We now proceed with a simple construction that for a given graph G that is ε-far from H-free, finds a set Q1 of Ωε,H (V ) edge-disjoint colored copies of H in G. Lemma 20. If G is ε-far from H-free, then one can color vertices of G with V (H) colors χ such that G has a set Q of at least E(H)·V (H)V (H) · V edge-disjoint colored copies of H. ε Proof. We first find the copies of H without considering the coloring of V and V (H), and then we will prove the existences of the relevant coloring χ. We find edge-disjoint copies of H in G one by one. Suppose that we have already found in G a set of k edge-disjoint copies of H, where k < εV E(H). Then, since G is ε-far from H-free, the graph obtained from G by removal of the k copies of H found already (which removes kE(H) < εV edges from G) cannot be H-free, and hence G must contain a copy of H. This copy would be edge-disjoint with all copies found before, what by induction shows that G has at least ε·V E(H) edge-disjoint copies of H. Let H1, . . . , H(cid:96) be the edge-disjoint copies of H in G, with (cid:96) ≥ ε·V has all vertices of the same color as in H; let X =(cid:80)(cid:96) V (H)V (H) . Therefore, E[X] = E[(cid:80)(cid:96) i=1 Xi] = (cid:80)(cid:96) V (H)V (H) ≥ E(H). Let us consider a uniformly random coloring of vertices of G (with V (H) colors) and let Xi be the indicator random variable that Hi i=1 Xi. Clearly, for every i, Pr[Xi = 1] = E[Xi] = V (H)V (H) . This implies that there is a i=1 E[Xi] = E(H)·V (H)V (H) edge-disjoint colored copies of coloring of vertices of G that has at least H. Therefore, there is a coloring χ with this property, that is, after we color vertices of G using χ, then G (cid:4) will have at least E(H)·V (H)V (H) edge-disjoint colored copies of H that form the required set Q. ε·V ε·V 1 (cid:96) (cid:96) 19 Using the result from Lemma 20, from now on, we will assume that the vertices of G are colored using χ (the coloring from Lemma 20) so that G has at least Ωε,H (V ) edge-disjoint colored copies of H. 6 Constructing Qi+1 from Qi The construction of Q1 from Section 5 is rather simple, but it is significantly more complex to define Q2, and then Q3, . . . , QV (H). In what follows, we will first present key intuitions in Section 6.1, then describe our framework in Sections 6.2 and 6.3, and present details of the construction of Qi+1 in Section 6.4. While our main focus is on the sets Qi of edge-disjoint colored copies of H in G, in our analysis we will analyze these sets and the relevant graphs G[Qi] via their suitable hypergraph representation. Indeed, to prove that Random-Traverse finds a copy of H, we will consider a hypergraph induced by "shrunk" copies of H defining Qi. The idea of this construction is two-folded: • on one hand, using the hypergraph representation it will be easier to argue a lower bound for the probability that a copy of H is found, and • on the other hand, the hypergraph representation will allow us to combine distinct colored copies of H (or the subgraph of H) that are undistinguishable to Random-Traverse. 6.1 Overview: Gadgets, hypergraph representation and their use Our analysis relies on special structures (gadgets) in the input graph and then representing these gadgets in a succinct way using hypergraphs. Let G∗ be a subgraph of G that has a copy of H. Consider a subgraph H1 of H and let u1, . . . , u(cid:96) be the vertices in the copy of H1 in G∗ that separate G \ H1 from H1, so that (cf. Figure 1): (a) every vertex from {u1, . . . , u(cid:96)} is adjacent in G∗ to some vertex H1 \ {u1, . . . , u(cid:96)}, (b) every vertex in H1 \ {u1, . . . , u(cid:96)} is adjacent in G∗ only to vertices from H1, and (c) {u1, . . . , u(cid:96)} forms an independent set in H1. Then, we can construct a gadget to represent that copy of H1 by removing from H1 all vertices and edges from H1 \ {u1, . . . , u(cid:96)} and replacing them by a single hyperedge {u1, . . . , u(cid:96)}. We will be using this construction of gadgets to model the following scenario: • when entering (in Random-Traverse) H1 via any single edge incident to any vertex from the separator u1, . . . , u(cid:96) is sufficient to visit (with constant probability) all edges in H1. Therefore, for the analysis, this will correspond to the situation that • there is a hyperedge {u1, . . . , u(cid:96)}, and by visiting this hyperedge (in the hypergraph), the algorithm will visit (with constant probability) all edges in H1 (in the original graph), and will be able to continue the search from all separating vertices u1, . . . , u(cid:96). Furthermore, the gadgets can be also helpful in the analysis of "substitutable" copies of a subgraph of H. Suppose that for a subgraph H1 of H, the separator (as defined above) is identical in multiple copies, that is, vertices u1, . . . , u(cid:96) form the separator in multiple edge-disjoint copies of H1. Then, we have multiple hyperedges {u1, . . . , u(cid:96)} and their multiplicity represents the fact that to find a copy of H1 it is enough to visit just one of the hyperedges {u1, . . . , u(cid:96)}. In particular, if u1 is incident to multiple copies of the identical hyperedge {u1, . . . , u(cid:96)}, then the probability that the process will visit H1 starting from u1 increases with 20 (a) (b) (c) Figure 2: Consider the input graph G in Figure (a) and consider the process of shrinking G, as described in Section 6.2. (b) presents contraction of vertex 1 and adding of hyperedge {5, 7, 8, 9} (with label {1}). (c) After contracting vertex 2 and adding hyperedge {3, 4} (with label {2}). this multiplicity. And so, if the multiplicity is of order degG(u1), then after reaching vertex u1, the Random- HTraverse algorithm (cf. Section 4.1.3) will visit the entire H1 with a constant probability. The central idea behind the gadgets as described above is to use them repeatedly to transform a subgraph of G into a sub-hypergraph representing a smaller subgraph of G for which we can easily analyze the Random-HTraverse algorithm. 6.2 The process of shrinking H and hypergraph representation of H by Mi We will begin with an iterative procedure that gradually shrinks H into a single vertex. This procedure processes H and its contractions in a form of a hypergraph. (See also Figures 2 -- 4.) Let us consider an arbitrary numbering of the vertices of H, v1, v2, . . . , vV (H); this order is not known in advance and is independent of the coloring of H (in fact, the order will be determined by the structure of G, and finding the right order v1, v2, . . . , vV (H) is the central part of our analysis in the next sections, final- ized in Lemma 33). In our analysis, we will perform a sequence of transformations on H, each transforma- tion converting some hypergraph Mi corresponding to H into some other hypergraph Mi+1 corresponding to H, 1 ≤ i ≤ V (H) − 1 (cf. Figures 2 -- 4), such that: • M1 := H, and • Mi+1 is obtained from Mi by contracting vertex vi to its neighbors as follows: (cid:5) let Ni be the set of all neighbors of vi in Mi; contract vi to its neighbors by removing vi from Mi and then adding a new hyperedge consisting of vertices in Ni. Ni obtained by contraction of vi will have label σ(Ni) = {vi} ∪(cid:83) We will want to maintain information about all vertices which have been contracted to create a given hyperedge (e.g., in Figure 1, these would be vertices {1, 5}) and so we will label the hyperedges. We will denote the label of an edge e by σ(e). A regular edge e (original edge from E(H)) has an empty label, i.e., σ(e) = ∅, and if Ei denotes the set of edges/hyperedges incident to vertex vi in Mi, then the new hyperedge σ(e) (i.e., its label is the union of {vi} and the union of the labels of the edges in Ei). Furthermore, we will also have colored label σ∗ of any edge e, defined as the set of the colors of the vertices defining the label of e, that is, σ∗(e) = {χ(u) : u ∈ σ(e)}. (Note that if σ(e) = ∅ then σ∗(e) = ∅.) e∈Ei We will also use the following notion. 21 1 10 9 8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 (d) Figure 3: Continuing the example from Figure 2: (d) After contracting vertex 3 and adding hyperedge {4, 8, 10} (with label {2, 3}). (e) After contracting vertex 4 and adding hyperedge {8, 10} (with label {2, 3, 4}). (f) After contracting vertex 5 and adding hyperedge {6, 7, 8, 9} (with label {1, 5}). (e) (f) (i) (h) (g) Figure 4: Continuing the example from Figures 2 and 3: (g) After contracting vertex 6 and adding hyperedge {7, 8, 9} (with label {1, 5, 6}). (h) After contracting vertex 7 and adding hyperedge {8, 9} (with label {1, 5, 6, 7}; note that as the result, we have two parallel edges between 8 and 9, but each of these edges is different, one corresponds to a direct edge between 8 and 9 with label ∅, and another corresponds to the gadget with separator {8, 9} and internal vertices {1, 5, 6, 7} (as shown by the label)). (i) After contracting vertex 8 and adding hyperedge {9, 10} (with label {1, 2, 3, 4, 5, 6, 7, 8}). (j) After contracting vertex 9 and hyperedge {10} (with label {1, 2, 3, 4, 5, 6, 7, 8, 9}). (j) Definition 21. If in our construction, in Mi, we had edges e1, . . . , e(cid:96) incident to vi, then we will say that the newly created hyperedge Ni in Mi+1 is modeled by edges e1, . . . , e(cid:96) in Mi. In Appendix D we will present some basic properties of the process of shrinking H and hypergraph representation of H by Mi, as defined in this section. Let us note that the construction above allows "selfloops," that is, hyperedges consisting of a single vertex, and that it allows multiple copies of hyperedges on the same vertex set (see, e.g., Figure 4 (h) or Figure 5, and one could have many copies of hyperedges even with more than two vertices). An important feature of the latter case is that all these hyperedges will be considered as different hyperedges, since they correspond to different subgraphs of H and have different labels. Note also that all labels are disjoint (i.e., σ(e1) ∩ σ(e2) = ∅ for any distinct hyperedges e1, e2 in Mi). 6.3 Shrinking copies of H in G (via safe vertices and consistent hypergraphs) The central idea of our analysis is to mimic the corresponding transformation of H (as described in Sec- tion 6.2) in all relevant copies of H in sets Q1, Q2, . . . , and then, instead of searching for a copy of H in G[Q1], G[Q2], . . . , to search for copies of M1,M2, . . . in the corresponding shrunk hypergraphs H1(Q1),H2(Q2), . . . . Then, we will argue that finding a copy of H in G is (almost) as easy as finding a copy of M1 in H1(Q1), which in turn can be reduced (by paying a small price) to finding a copy of M2 in H2(Q2), and so on, reducing everything to finding a copy of MV (H) in HV (H)(QV (H)). And then, since MV (H) has only a single vertex, we would hope that finding its copy in HV (H)(QV (H)) is easy. 22 10 9 8 7 6 5 4 10 9 8 7 6 5 10 9 8 7 6 10 9 8 7 10 9 8 10 9 10 (a) (b) (c) (d) Figure 5: Construction of hypergraphs (a) M1, (b) M2, (c) M3, (d) M4, with multiple hyperedges {4, 5}. In order to incorporate this approach, we will transform appropriate subgraphs of G into a sequence of hypergraphs, such that after i transformations, every relevant copy of H is shrunk into Mi+1. (Let us emphasize that this step relies on the choice of vertex vi -- which is the same in all copies of H -- to be determined by the structure of Qi, as described in Lemma 33.) In particular, we will mimic the corresponding transformation on Q1, Q2, . . . as follows. We consider a hypergraph, denoted by Hi(Qi), corresponding to Qi, which has • vertex set V (Hi(Qi)) = V \ {u ∈ V : χ(u) ∈ {χ(vj) : j < i}} (vertices4 in G that have colors of vertices {vi, . . . , vV (H)}, that is, that have not been contracted in Mi yet), and • edge set formed by an edge-disjoint collection of copies of Mi (we allow hyperedges to have some multiplicity). Then, for some carefully chosen set Qi+1 ⊆ Qi, a new hypergraph Hi+1(Qi+1) is obtained from Hi(Qi) by • removing all hyperedgescorresponding to the edge-disjoint copies of H in Qi \ Qi+1 and • then taking the set Qi+1 of copies of H and shrinking them, in the same way as Mi is transformed into Mi+1: • Select a vertex vi ∈ V (H). • Simultaneously, contract every vertex u ∈ V (Hi(Qi)) with χ(u) = χ(vi) as follows: (cid:5) for every colored copy h of H in Qi+1 that contains vertex u: ◦ add a new hyperedge consisting of vertices in N h h (in the hypergraph Hi(Qi)) other than u (that is, u /∈ N h (cid:5) remove vertex u (with all incident edges from Hi(Qi)). i (cid:104)u(cid:105), where N h i (cid:104)u(cid:105)); i (cid:104)u(cid:105) is the set of neighbors of u in Notice that in our construction of Hi+1(Qi+1) we are removing all vertices u ∈ V with color χ(u) = χ(vi). And so, in particular, V (Hi+1(Qi+1)) = V \ {u ∈ V : χ(u) ∈ {χ(vj) : j ≤ i}}. Furthermore, since we contract only vertices of color χ(vi) and since these vertices are independent in G[Qi+1] (indeed, since Qi+1 is the set of edge-disjoint colored copies of H, G[Qi+1] does not have monochromatic edges), the operation above is well defined and the contractions of all vertices of color χ(vi) can be performed independently in all copies of H in Qi+1. This yields an equivalent definition: 4Let us first remind that we are assuming that the vertices of G are colored using χ so that G has at least Ωε,H (V ) edge-disjoint colored copies of H, as promised by Lemma 20. 23 1 3 5 4 2 3 5 4 2 3 5 4 5 4 (a) (b) (c) Figure 6: Operation of contracting vertex of color 13 (numbers depicted correspond here to the colors) to define new hypergraph H14(Q14). (a) Describes the edges of a single copy of M13 incident to vertex of color 13 (in the center) in H13(Q13). (b) Describes the edges of two copies of M13 incident to vertex of color 13 in H13(Q13). (Notice that in this case, vertex of color 13 is not safe.) (c) Describes the situation of contracting vertex of color 13, which creates two new hyperedges, and removal of vertex of color 13 and all incident edges. This defines H14(Q14). Remark 22. The following is an equivalent definition of Hi+1(Qi+1): • Start with graph G[Qi+1]. • For every copy h of H in Qi+1, perform the shrinking of H into hypergraph Mi+1. • Combine all copies of Mi+1 obtained in that way. • Remove all vertices u with χ(u) = χ(vj) for j ≤ i that do not belong to any copy of Qi+1. j (cid:104)u(cid:105), then this construction can be performed independently for different copies of H. The fact that this description is correct follows from the fact that the shrinking of different copies of H can be per- formed independently because of vertex coloring, which ensures that if we contract a vertex u with χ(u) = χ(vj) and create a new edge N h Notice that (as formally proven in Claim 51 in Appendix E) because of the construction above, to define Hi+1(Qi+1), we do not need to consider the constructions of H1(Q1),H2(Q2), . . . ,Hi(Qi) one after another, but we could do it with the constructions of H1(Qi+1),H2(Qi+1), . . . ,Hi(Qi+1), and from Hi(Qi+1) to build Hi+1(Qi+1). (Note that the vertex set of Hi+1(Qi+1) is V (Hi+1(Qi+1)) = V \ {u ∈ V : χ(u) ∈ {χ(vj) : j ≤ i}}. Further, observe that Hi+1(Qi+1) may have (isolated) vertices u that do not belong to any copy of Qi+1.) (cid:4) The construction above maintains a relationship between edges in Hi(Qi) and edges in Mi. Definition 23. (Corresponding edges) If e is an edge in Hi(Qi) then the corresponding edge to e in Mi is edge e(cid:48) in Mi such that the colors of vertices in e are the same as the colors of vertices in e(cid:48) (i.e., {χ(x) : x ∈ e} = {χ(vj) : vj ∈ e(cid:48)}), and the colored labels of e and e(cid:48) are the same too (i.e., σ∗(e) = σ∗(e∗)). Notice that every edge in Hi(Qi) has a unique corresponding edge in Mi. Furthermore, for any edge e(cid:48) in Mi, the number of edges in Hi(Qi) corresponding to edge e(cid:48) in Mi is exactly Qi. Next, we can also mimic Definition 21 in the context of our construction here as follows: Definition 24. (Modeling edges in Hi+1(Qi+1) by edges in Hi(Qi)) Let u be a vertex in Hi(Qi) with χ(u) = χ(vi). Let h be a colored copy of H in Qi+1 that contains vertex u. Let e1, . . . , e(cid:96) be the edges incident to u Hi(Qi) corresponding to the copy h. Then, we will say that the newly created hyperedge i (cid:104)u(cid:105) in Hi+1(Qi+1) is modeled by edges e1, . . . , e(cid:96) in Hi(Qi). N h Now, we are ready to formalize the process of finding a colored copy of Mi in a hypergraph. 24 192815141713192815141928151417131928151419281514171319281514 (a) (b) Figure 7: Operation of contracting safe vertex of color 13 (numbers depicted in the vertices correspond to the col- ors, and number depicted next to the edges correspond to the colored labels of the edges) to define new hypergraph H14(Q14). (a) Describes the edges of a single copy of M13 incident to vertex of color 13 (in the center) in H13(Q13). Since we want vertex of color 13 to be safe, it is possible there are many more copies of M13 incident to that vertex, in which case all of them use identical edges as in the depicted single copy (here identical means: on the same vertex set, with the same colored labels, but with distinct labels). (b) Describes the situation after contracting vertex of color 13 in H14(Q14). Notice that the new edge in H14(Q14) has colored label {1, 2, 3, 5, 6, 8, 9, 11, 13} and is modeled by five edges in H13(Q13). Definition 25. (Finding a colored copy of Mi) Let vi, . . . , vV (H) be the vertices in Mi. We say that HTester (H, Rep,Mi, d, t) finds a colored copy of Mi in H if the corresponding algorithm Random- HTraverse (H, Rep, d, t) returns a set of edges E, such that • the sub-hypergraph of H induced by the edges E contains vertices xi, . . . , xV (H) such that for every edge/hyperedge e in Mi, E contains an edge corresponding to e, or equivalently, (cid:5) χ(xj) = χ(vj) for every j, i ≤ j ≤ V (H), and (cid:5) for every edge {vj1, . . . , vjr} in Mi, E contains edge {xj1, . . . , xjr}. 6.3.1 Adjusting for planar graphs: safe vertices and consistent hypergraphs In our construction we will require more properties from the contractions defining Hi+1(Qi+1). To maintain some basic properties of planar graphs (which are required by our analysis), we will want to model the operation of contraction of a vertex u as the standard vertex contraction of u to one of its neighbors, cf. Appendix F. For that, we will need an additional, stronger property: • we want to ensure that all contractions in Hi(Qi) corresponding to the contraction of vi in Mi are consistent, that is, the contraction of u is the same in every colored copy of H that contains u (that is, for every vertex u in with χ(u) = χ(vi), for any two colored copies h1, h2 of H in Qi+1 containing vertex u, we have N h1 i (cid:104)u(cid:105) = N h2 i (cid:104)u(cid:105)). To facilitate this property, we will use the following definitions. Definition 26. (Safe vertices) Let Qi be a set of edge-disjoint colored copies of H in G and let Q ⊆ Qi. We call a vertex u ∈ V (Hi(Qi)) safe (with respect to Q and Hi(Qi)) if for all colored copies h ∈ Q of H that contain u, the sets N h Remark 27. Note that Definition 26 means that for every safe vertex u with respect to Q and Hi(Qi), not only all edges incident to u correspond to the edges from Mi incident to vertex v in Mi with χ(u) = χ(v), but also, if u is incident to r edges in Hi(Qi) and v is incident to edges e1, . . . , e(cid:96) in Mi, then i (cid:104)u(cid:105) are the same. 25 192815171331,52,968,111928151713 i (cid:104)u(cid:105) = (cid:83)(cid:96) (ii) N h (iii) {χ(x) : x ∈ N h i (cid:104)u(cid:105)} = {χ(x) : x ∈(cid:83)(cid:96) j=1 ej \ {v}}. (i) we can partition the edges incident to u into (cid:96) groups, each group corresponding to one of the edges e1, . . . , e(cid:96) in Mi, each group of the same size r/(cid:96), such that two edges e(cid:48), e(cid:48)(cid:48) from the same group have the same colored label (i.e., σ∗(e(cid:48)) = σ∗(e(cid:48)(cid:48))) and are defined by the same vertices (i.e., for every vertex x, x ∈ e(cid:48) iff x ∈ e(cid:48)(cid:48)); j=1 ej \ {v}, that is, u has as many neighbors in Hi(Qi) as v has in Mi; (cid:4) Our next iterative definition extends the notion of safe vertices to the entire hypergraph. Definition 28. (Consistent hypergraphs) For any set Q1 of edge-disjoint colored copies of H in G, the hypergraph H1(Q1) (which is equal to the graph G[Q1]) is called consistent (for Q1). Let Qi be a set of edge-disjoint colored copies of H in G and let Qi+1 ⊆ Qi. If hypergraph Hi(Qi) is consistent for Qi, then hypergraph Hi+1(Qi+1) obtained from Hi(Qi) is called consistent (for Qi+1) if every vertex u ∈ V (Hi(Qi)) with χ(u) = χ(vi) is safe with respect to Qi+1 and Hi(Qi). In Appendix E we will show some basic properties of consistent hypergraphs used later in our analysis. 6.3.2 Central property of consistent hypergraphs via shadow graphs With the notion of safe vertices and consistent hypergraphs, we can now present the following central lemma that shows that the neighborhood of vertices in consistent hypergraphs can be modeled by some semi-planar structures, which we will call shadow graphs, that are a union of at most V (H) simple planar graphs. Lemma 29. Let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Then, there is a simple graph G(Hi(Qi)), (a) with the vertex set equal to the set of all non-isolated vertices in Hi(Qi), (b) that is a union of at most V (H) simple planar graphs, and (c) such that for any distinct x, y ∈ V (Hi(Qi)), x is adjacent to y in Hi(Qi) if and only if x is adjacent to y in G(Hi(Qi)). The simple graph G(Hi(Qi)) in Lemma 29 will be called the shadow graph of Hi(Qi). We consider the characterization provided in Lemma 29 to be one of the most interesting and highly non-trivial contributions of this paper. This is the key tool that allows us to facilitate the approach presented in the paper. To simply the flow of the paper though, the proof of Lemma 29 is deferred to Appendix F. 6.3.3 Finding many safe vertices of the same color The main use of Lemma 29 is to show that even though the use of the hypergraphs H1(Q1),H2(Q2), . . . looses some basic properties of planar graphs, our use of consistent hypergraphs allows us to apply Lemma 29 to maintain some weaker, but still similar properties of the hypergraphs H1(Q1),H2(Q2), . . . . We begin with the following lemma that shows that the hypergraphs will have a constant fraction of vertices of low degrees. The proof of our next Lemma 30 extends the approach used earlier in the context of planar graphs from [11]; we defer the proof to Appendix G. Lemma 30. Let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Then, there is a set Q ⊆ Qi of size at least 4V (H)+2 such that in the hypergraph Hi(Q), every copy of H in Q has a vertex with at most 6V (H) distinct neighbors. Qi 26 Our next lemma follows the arguments used in a related proof from [11] and shows that if there is a color with all vertices having a small number of neighbors in Hi(Q) for Q ⊆ Qi, then we can always find a large subset of Q with all vertices of that color being safe. Lemma 31. Let Qi be a set of edge-disjoint colored copies of H in G such that Hi(Qi) is a hypergraph consistent for Qi. Let c be a color of a vertex in {1, . . . ,V (H)} \ {χ(vj) : j < i}. Let Q ⊆ Qi such that every colored copy of H in Q has vertex of color c with at most 6V (H) distinct neighbors in Hi(Q). Then Q there is a subset Q(cid:48) ⊆ Q, Q(cid:48) ≥ (6V (H))V (H) , such that every colored copy h of H in Q(cid:48) has vertex of color c safe with respect to Q(cid:48) and Hi(Qi). Proof. Let c1, . . . , c(cid:96) be the colors of vertices adjacent to vertex of color c in Mi (notice that c may be among these colors). For each non-isolated vertex u in Hi(Q) of color c, for every color cs, 1 ≤ s ≤ (cid:96), select i.u.r. one of its neighbors u(cid:104)s(cid:105) in Hi(Q) of color cs. Next, remove from Q every copy of h of H in Hi(Q) containing vertex u unless the vertices from this copy incident to u are the selected (cid:96) neighbors u(cid:104)1(cid:105), u(cid:104)2(cid:105), . . . , u(cid:104)(cid:96)(cid:105). Let Q(cid:48) be the set of remaining copies of H in Hi(Q). Our construction ensures that every remaining non-isolated vertex u of color c is safe with respect to Q(cid:48) and Hi(Qi). Furthermore, since every vertex of color c has at most 6V (H) distinct neighbors (taking into account self-loops) in Hi(Q), the probability that a fixed copy of h in Q is not deleted by the process above is at least (6V (H))−(cid:96). Therefore the expected size of Q(cid:48) is at least (6V (H))−(cid:96) · Q, and therefore, there exists a set Q(cid:48) of that size that satisfies the lemma. (cid:4) With Lemmas 30 and 31 at hand, we are now ready to present the main result of this section. Qi Qi 4V (H)+2, such that every colored copy of H in Lemma 32. Let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Then, there is color c in {1, . . . ,V (H)} \ {χ(vj) : j < i} and a set Q∗ ⊆ Qi of size at Qi (6V (H))V (H)+2 such that every colored copy h of H in Q∗ has vertex of color c safe with respect to least Q∗ and Hi(Qi). Proof. By Lemma 30, there is a set (cid:98)Q ⊆ Qi, (cid:98)Q ≥ (cid:98)Q has a vertex with at most 6V (H) distinct neighbors in Hi((cid:98)Q). For a color c∗ ∈ {1, . . . ,V (H)} \ {χ(vj) : j < i}, let (cid:98)Qc∗ be the subset of (cid:98)Q such that every copy of H in (cid:98)Qc∗ has a vertex of color c∗ with at most 6V (H) distinct neighbors in the hypergraph Hi((cid:98)Q). Since(cid:83) c∗ (cid:98)Qc∗ = (cid:98)Q, there is one color c ∈ {1, . . . ,V (H)} \ {χ(vj) : j < i} such that (cid:98)Qc ≥ 1V (H) · (cid:98)Q ≥ every copy of H in (cid:98)Qc has a vertex of color c with at most 6V (H) distinct neighbors in Hi((cid:98)Q), and hence (4V (H)+2)·V (H) ≥ also in Hi((cid:98)Qc). Therefore, we can take such set(cid:98)Qc as set Q in Lemma 31, to conclude that there is a subset Q(cid:48) ⊆ (cid:98)Qc, Q(cid:48) ≥ (6V (H))V (H)+2 , such that every colored copy h of H in Q(cid:48) has vertex (cid:4) Qi of color c safe with respect to Q(cid:48) and Hi(Qi). 6.4 Constructing set Qi+1 of edge-disjoint colored copies of H and Hi+1(Qi+1) Now we are ready to define our construction of the set Qi+1 of edge-disjoint colored copies of H obtained as a subgraph of Qi, and with this, to define the hypergraph Hi+1(Qi+1) from Hi(Qi). Let Qi be a set of edge-disjoint colored copies of H in G, where Hi(Qi) is a hypergraph consistent for Qi. We apply Lemma 32 to choose color c in {1, . . . ,V (H)} \ {χ(vj) : j < i} and a set Q∗ ⊆ Qi of size (6V (H))V (H)+2 such that every colored copy h of H in Q∗ has vertex of color c safe with respect to at least Qi (6V (H))2 and (cid:98)Qc (6V (H))V (H) ≥ Qi 27 Q∗ and Hi(Qi) (that is, for every vertex u with χ(u) = c, all colored copies h ∈ Qi+1 of H that contain u have identical sets N h i (cid:104)u(cid:105) in Hi(Qi)). Then, we define Qi+1 := Q∗ and select vertex vi to be the vertex of color c in H. With so defined vertex vi, we can immediately construct the hypergraph Hi+1(Qi+1) (from the hyper- graph Hi(Qi)). The details of the construction have been presented in Section 6.3, and it required the choice of set Qi+1 and of vertex vi among the vertices in V (H) \ {v1, . . . , vi−1}. By Lemma 32 (cf. Definition 28 of consistent hypergraphs), this immediately gives the following lemma. Lemma 33. Let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Then, the choice of the set Qi+1 with the vertex vi, as described above, will ensure that Qi+1 ≥ (6V (H))V (H)+2 and that Hi+1(Qi+1) obtained from Hi(Qi) is consistent for Qi+1. Qi 6.4.1 Representatives Repi for Q and Hi(Q) In our analysis, we will be also using the concept of representatives to describe the scenario that a vertex from V has been contracted to some other vertices during the construction of Hi(Q) (in some moment, it has been deleted from Hj(Q), 1 ≤ j < i, and new hyperedges containing all neighbors of this ver- tex has been formed, in which case of these neighbors is used as a proxy). The canonical representative function plays an important role in our analysis and it is used explicitly in algorithms HTester and Random- (For the following definition, let us recall the construction of the hypergraph Hi(Qi) from HTraverse. Section 6.3. Let us also notice that the notion of canonical representatives is used solely in the analysis at the end of the process, and since it is not used for the construction of sets Q1, Q2, . . . , QV (H) and hyper- graphs H1(Q1),H2(Q2), . . . ,HV (H)(QV (H)) and is used only to model their behavior, it does rely on the final order v1, . . . , vV (H) of the vertices in H.) Definition 34. (Canonical representatives) Let Q be a set of edge-disjoint colored copies of H in G. Let v1, . . . , vV (H) be an arbitrary order of vertices of H such that for each i, 1 ≤ i ≤ V (H), the hypergraph Hi(Q) is consistent for Q. A canonical representative function is a sequence of functions Rep1, Rep2, . . . , RepV (H) : V → V such that for every i, 1 ≤ i ≤ V (H): • if u is an isolated vertex in G[Q], then Repi(u) = u for every i; • otherwise, if u is a vertex in Hi(Q) (i.e., χ(u) /∈ {χ(vj) : 1 ≤ j < i}), then Repi(u) = u; • otherwise, Repi(u) = x, where (i) x ∈ (cid:83) e:u∈σ(e) e and (ii) for any x, y ∈ (cid:83) e:u∈σ(e) e, if x (cid:54)= y, χ(x) = χ(vj1), and χ(y) = χ(vj2), then j1 < j2. We will denote any single Repi as a representative function. The notion of the canonical representative function Rep1, Rep2, . . . , RepV (H) : V → V describes the dependencies between the vertices from G in the construction of the sequence of the hypergraphs H1(Q),H2(Q), . . . ,HV (H)(Q). And so, Repi(u) = u unless vertex u has been contracted during the construction of Hj(Q) for j < i. If u has been contracted during the construction of Hj(Q), then for some colored copy h of H in Q containing u, we first added a new hyperedge consisting of vertices in N h j (cid:104)u(cid:105), and then removed vertex u (with all incident edges from Hj(Q)). In that case, we will define j (cid:104)u(cid:105) Repj(u) = x, 5where x is the vertex in N h 5Notice that this notion is well defined only since u is a safe vertex with respect to Q and Hj(Q), because in that case the j (cid:104)u(cid:105) that will be contracted first among all vertices in N h neighbors of u in Hj(Q) do not depend on the choice of the copy h of H in Q containing u we consider. 28 j (cid:104)u(cid:105) and χ(x) = χ(vr1) and χ(y) = χ(vr2), then r1 ≤ r2). Furthermore, if in some (that is, if x, y ∈ N h future iteration s > j vertex x = Repj(u) is contracted, then we will not only set Reps(x), but we will also update Reps(u) to be the same as Reps(x). In fact, we will maintain that for all k > j, if Repj(u) = x then Repk(u) = Repk(x).6 Remark 35. Equivalently, one can define Rep1, Rep2, . . . , RepV (H) : V → V recursively as follows: • if u is an isolated vertex in G[Q], then Repi(u) = u for every i; • otherwise: (cid:5) Rep1(u) = u for every vertex u ∈ V ; (cid:5) for any i, 2 ≤ i ≤ V (H), for every u ∈ V : (cid:63) if u is a vertex in Hi(Q), then Repi(u) = u; (cid:63) otherwise, ∗ if Repi−1(u) has color different than χ(vi−1)7, then Repi(u) = Repi−1(u); ∗ else, Repi(u) is equal to the neighbor of vertex Repi−1(u) in Hi−1(Q) with the lowest color (that is, Repi(u) is the neighbor x of Repi−1(u) in Hi−1(Q) that minimizes j with χ(x) = χ(vj)). Let us explain the choice of vertex x in the last case of the definition of Repi(u). First of all, the choice of Repi(u) to be a neighbor of vertex Repi−1(u) in Hi−1(Q) is to ensure that u will belong to the label of the newly created edge incident to that neighbor in Hi(Q). The choice of the neighbor with the "lowest color" is to ensure that that vertex will be the first to be contracted in the later procedure of shrinking Hj(Q), and thus, during that construction, the edge containing vertex u will be replaced by another edge. Therefore, our choosing x ensures that if χ(u) = χ(vr), then • for every i ≤ r, Repi(u) = u, and • for every i > r, Repi(u) is a vertex in Hi(Q) and there is a hyperedge e incident to vertex Repi(u) such that (cid:4) u ∈ e. 7 Completing the proof of Lemma 17, and of Theorems 14 and 15 We are now ready to complete the proof of Lemma 17, and with this of Theorems 14 and 15. Let G = (V, E) be a simple planar graph that is ε-far from H-free. By our analysis in the previous sec- tions (see Lemma 33), we know that we can order the vertices of H v1, . . . , vV (H) to define the hypergraphs M1, . . . ,MV (H), so that there are sets Q1, Q2, . . . , QV (H) of edge-disjoint colored copies of H in G with QV (H) ⊆ QV (H)−1 ⊆ ··· ⊆ Q1 and QV (H) = Ωε,H (V ), such that for each i, 1 ≤ i ≤ V (H), the hypergraph Hi(Qi) is consistent for Qi. Let us first apply Lemma 18 to the set QV (H) of edge-disjoint colored copies of H in G to obtain a subset Q ⊆ QV (H) with Q = Ωε,H (V ), such that the graph G[Q] satisfies condition (a) of Lemma 17. Therefore, we only have to show that condition (b) of Lemma 17 holds too, that is, we have to show that if G = (V, E) is a simple planar graph that is ε-far from H-free, then ⊗ Tester(G[Q], H, d, t) finds a copy of H in G[Q] with probability Ωε,H (1). Q is a set of edge-disjoint colored copies of H in G such that Q = Ωε,H (V ), and (by Claim 50) such that for each i, 1 ≤ i ≤ V (H), the hypergraph Hi(Q) is consistent for Q. Let us take the canonical representative function Rep1, Rep2, . . . , RepV (H) : V → V , cf. Definition 34. are formed by vertices u with Rep(−1) 6Note that function Repi defines a forest on V , where in each "tree" the root is a vertex u with Repi(u) = u, and the "leaves" 7That is, Repi−1(u) is not in Hi−1(Q). (u) (cid:54)= u (that is, for which there is no v with Repi(v) = u). i 29 We will prove ⊗ by showing the following two properties (proven below as Claims 36 and 37): 1. the probability that HTester (HV (H)(Q), RepV (H),MV (H),V (H)2, 1) finds a copy of MV (H) is Ωε,H (1), and 2. for every i, 1 ≤ i < V (H), • if the probability that HTester (Hi+1(Q), Repi+1,Mi+1, d, t) finds a copy of Mi+1 is Ωε,H (1), • then the probability that HTester (Hi(Q), Repi,Mi,V (H) · d, 2t) finds a copy of Mi is Ωε,H (1). Indeed, if Property 1 holds, then by iterating Property 2, we have that for some d∗, t∗ = Ωε,H (1), the probability that HTester (H1(Q), Rep1,M1, d∗, t∗) finds a copy of M1 is Ωε,H (1). Since Rep1 is the identity function Rep1(u) = u for every u ∈ V , and since H1(Q) ≡ G[Q], the behavior of Random- HTraverse (H1(Q), Rep1, d∗, t∗) is identical to the behavior of Random-Traverse (G[Q], d∗, t∗), and fur- ther, since M1 ≡ H, the behavior of HTester (H1(Q), Rep1,M1, d∗, t∗) is identical to the behavior of Tester (G[Q], H, d∗, t∗). Therefore, we obtain that the probability that Tester (G[Q], H, d∗, t∗) finds a copy of H is Ωε,H (1), what yields ⊗. What remains is to prove that Properties 1 and 2 hold, what we do in the following two central claims, whose proofs are deferred to Section 7.1 below. Claim 36. The probability that HTester (HV (H)(Q), RepV (H),MV (H),V (H)2, 1) finds a copy of MV (H) is Ωε,H (1). Claim 37. Let 1 ≤ i < V (H), d = d(ε, H) ≥ V (H), t = t(ε, H), d∗ = V (H) · d and t∗ = 2t. If the probability that HTester (Hi+1(Q), Repi+1,Mi+1, d, t) finds a copy of Mi+1 is Ωε,H (1), then the probability that HTester (Hi(Q), Repi,Mi, d∗, t∗) finds a copy of Mi is Ωε,H (1). With Claims 36 and 37 at hand, we obtain that Properties 1 and 2 hold, and therefore we can conclude (cid:4) the proof of the proof of Lemma 17, and with this of Theorems 14 and 15. 7.1 Proofs of central Claims 36 and 37 -- completing the proof of Lemma 17 In this section we give proofs of two our central results on which relies our proof of Lemma 17 (and with this of Theorems 14 and 15): Claims 36 and 37. We begin with the proof of Claim 36. {v1, . . . , vV (H)−1} (that is,(cid:83)s Claim 36. The probability that HTester (HV (H)(Q), RepV (H),MV (H),V (H)2, 1) finds a copy of MV (H) is Ωε,H (1). Proof. Our construction (see Section 6.2) ensures that MV (H) has some number s of hyperedges e1, . . . , es, each ej consisting of a single vertex vV (H), and with the labels of edges e1, . . . , es defining a partition of j=1 σ(ej) = {v1, . . . , vV (H)−1} and σ(ej1) ∩ σ(ej2) = ∅ for any j1 (cid:54)= j2). Similarly, our construction (see Section 6.3) ensures that HV (H)(Q) contains s · Q hyperedges, each hyperedge e in HV (H)(Q) consisting of a single vertex of color χ(vV (H)). Furthermore, each such hy- peredge e corresponds (cf. Definition 23) to a copy of one of the hyperedges e1, . . . , es from MV (H); let us denote by ind(e) the index of the copy eind(e) corresponding to e. Notice that σ∗(e) = σ∗(eind(e)) and {e in HV (H)(Q) : ind(e) = j} = Q for any j, 1 ≤ j ≤ s. ester (HV (H)(Q), RepV (H),MV (H), d∗, 1) finds a copy of MV (H) if, In view of the comments and the construction above, by Definition 25, HT- Let d∗ = V (H)2. 30 (1) in the call to Random-HTraverse (HV (H)(Q), RepV (H), d∗, 1), it selects the starting vertex u = RepV (H)(v) to be non-isolated in HV (H)(Q), and (2) vertex u chooses among its d∗ random incident edges all copies of e1, . . . , es. Our definition of Rep ensures that RepV (H)(x) is a non-isolated vertex in HV (H)(Q) if and only if x is a non-isolated vertex in G[Q]. Therefore we only have to show that G[Q] has Ωε,H (V ) non-isolated vertices. Let G∗[Q] be the subgraph of G[Q] induced by non-isolated vertices. Since G∗[Q] consists of Q edge-disjoint copies of H, G∗[Q] has Q · E(H) edges. Since G∗[Q] is a subgraph of a sim- 3Q · E(H) vertices ple planar graph, G∗[Q] is a simple planar graph too, and thus must have at least 1 (cf. Fact 43). Therefore, since Q = Ωε,H (V ), we conclude that G∗[Q] has Ωε,H (V ) vertices, or equivalently, that G[Q] has Ωε,H (V ) non-isolated vertices. Therefore, with probability Ωε,H (1) Random- HTraverse (HV (H)(Q), RepV (H), d∗, 1) selects a non-isolated as the starting vertex. Next, let us condition on the fact that the starting vertex u = RepV (H)(v) is non-isolated in HV (H)(Q). Analogously to the classic coupon collector's problem, we can argue that if u selects at least s2 (in fact, s ln(1 + s) would suffice too) times incident edges i.u.r., then with probability Ωε,H (1), the set E(cid:96),u will j) = j for every j, 1 ≤ j ≤ s. In this case, the set E(cid:96),u will contain s hyperedges e(cid:48) contain a copy of MV (H). (cid:4) By our arguments above, this yields the claim. s with ind(e(cid:48) 1, . . . , e(cid:48) We now move to the proof of Claim 37. Claim 37. Let 1 ≤ i < V (H), d = d(ε, H) ≥ V (H), t = t(ε, H), d∗ = V (H) · d and t∗ = 2t. If the probability that HTester (Hi+1(Q), Repi+1,Mi+1, d, t) finds a copy of Mi+1 is Ωε,H (1), then the probability that HTester (Hi(Q), Repi,Mi, d∗, t∗) finds a copy of Mi is Ωε,H (1). Proof. Let us refer to Definition 25 for the meaning of algorithm HTester (Hs(Q), Reps,Ms, d(cid:48), t(cid:48)) (and thus also of Random-HTraverse (Hs(Q), Reps, d(cid:48), t(cid:48))) finding a colored copy of Mr. The proof relies on two basic properties that hold with probability Ωε,H (1): • that a single step of Random-HTraverse (Hi+1(Q), Repi+1, d, t) can be simulated by 2 steps of Random-HTraverse (Hi(Q), Repi, d∗, t∗) with d∗ = V (H) · d and t∗ = 2t, and lated by 2 steps of Random-HTraverse (Hi(Q), Repi, d∗, t∗). • that if Random-HTraverse (Hi+1(Q), Repi+1, d, t) starts at a vertex u, then the same vertex u will be processed by Random-HTraverse (Hi(Q), Repi, d∗, t∗) in L0 ∪ L1 (i.e., in one of the first two rounds). Once these two claims hold, the proof of Claim 37 follows immediately. We begin with showing that a single step of Random-HTraverse (Hi+1(Q), Repi+1, d, t) can be simu- We begin with two auxiliary definitions. For any pair of edges e and e(cid:48), we say e and e(cid:48) are semi- equivalent if their vertex sets are the same and their colored labels are the same. Let e be an edge in Hi+1(Q) that is modeled by edges e1, . . . , er in Hi(Q) (cf. Definition 24). Then any r edges e(cid:48) r in Hi(Q) are called sub-equivalent to e if for every 1 ≤ j ≤ r, edges ej and e(cid:48) j are semi-equivalent. The first definition relates to the scenario when HTester (H, Rep,Mj, d, t) finds a colored copy of Mj in H that contains edge e in H. In that case, we claim that the algorithm would have found a copy of Mj also if instead of using edge e, it used any edge semi-equivalent to e. The second definition is used to describe the scenario when HTester (Hi+1(Q), Repi+1,Mi+1, d, t) finds a colored copy of Mi+1 by finding edges E in Hi+1(Q) matching Mi+1. In that case, to find a colored copy of Mi, it is enough 1, . . . , e(cid:48) 31 s in Hi(Q) that are sub-equivalent to e. that HTester (Hi(Q), Repi,Mi, d∗, t∗) finds only edges E(cid:48) such that for every e ∈ E, E(cid:48) contains edges 1, . . . , e(cid:48) e(cid:48) a vertex in L(cid:96)−1 with incident edge e. Let e belong to a copy he of Mi+1 in Hi+1(Q) and let(cid:98)e be the Let us consider a step of creating set L(cid:96) in Random-HTraverse (Hi+1(Q), Repi+1, d, t), and let u be corresponding edge in Mi+1. By our construction, edge e was either already present in Hi(Q), or is a result of a contraction in Hi(Q) of a vertex x with χ(x) = χ(vi). In the latter case, e is equal to N he i (cid:104)x(cid:105), the set of neighbors of x in he (in Hi(Qi)) other than x. In Random-HTraverse (Hi+1(Q), Repi+1, d, t), when vertex u selects d incident edges i.u.r., the prob- ability that u chooses e among its d incident edges in Random-HTraverse (Hi+1(Q), Repi+1, d, t) is pu,e = 1− (1− 1/ degHi+1(Q)(u))d, where degHi+1(Q)(u) is the number of edges incident to vertex u in Hi+1(Q). If edge e was already present in Hi(Q), then the probability that u chooses e among its d incident edges in Random-HTraverse (Hi(Q), Repi, d∗, t∗) is equal to 1 − (1 − 1/ degHi(Q)(u))d∗ . Next, we notice that for any vertex x in Hi+1(Q), degHi+1(Q)(u) ≤ degHi(Q)(u) ≤ V (H) degHi+1(Q)(u). (Indeed, for any colored copy h of H in Q that contains vertex x, if we contract in h a neighbor of x in Hi(Q), then we remove up to V (H) edges from Hi(Q) and add exactly one new edge.) This implies that with our setting d∗ = V (H) · d, we have 1 − (1 − 1/ degHi(Q)(u))d∗ ≥ 1 − (1 − 1/(V (H) · degHi+1(Q)(u)))V (H)·d = Ωε,H (1 − (1 − 1/ degHi+1(Q)(u))d). 8 Therefore, we can conclude that: Case 1: if edge e is present in Hi(Q) and in Random-HTraverse (Hi+1(Q), Repi+1, d, t), vertex u selects e among its d incident edges with probability pu,e, then in Random-HTraverse (Hi(Q), Repi, d∗, t∗), vertex u selects e among its d∗ incident edges with probability Ωε,H (pu,e). i (cid:104)x(cid:105), is more complicated. The case when edge e is not present in Hi(Q) and has been obtained as a contraction of vertex x with χ(x) = χ(vi), with e = N he Since Hi+1(Q) is consistent for Q, vertex x is safe with respect to Q and Hi(Q). Let x be incident to degHi(Q)(x) edges in Hi(Qi) and note that χ(x) = χ(vi). By Remark 27, we can group edges incident to x in Hi(Qi) into r groups of the same size each (equal to degHi(Q)(x)/r), each group corresponding to a copy of one of the r edges incident to vi in Mi, any two edges from the same group being semi-equivalent. After contracting vertex x, we will create s = degHi(Q)(x)/r new edges e1, . . . , es in Hi+1(Q), each new edge with the same vertex set Ni(cid:104)x(cid:105) that correspond to the set of neighbors of x in Hi(Qi), and having 1, . . . , e(cid:48) the same colored label. Thus all new edges e1, . . . , es are semi-equivalent. Furthermore, any e(cid:48) incident to x in Hi(Qi) that are from r different groups are sub-equivalent to every edge in e1, . . . , es. r We will compare the probability that after arriving at vertex u, Random-HTraverse (Hi+1(Q), Repi+1, d, t) visits any of the edges e1, e2, . . . , es, with the probability that after arriving at u, algorithm Random- HTraverse (Hi(Q), Repi, d∗, t∗) visits in Hi(Q) r edges that are incident to x in Hi(Qi) and that are from r different groups (and hence are sub-equivalent to every edge in e1, . . . , es). In Random-HTraverse, when vertex u selects d incident edges i.u.r., the probability that it chooses at least one of the edges e1, . . . , es among its d incident edges in Random-HTraverse (Hi+1(Q), Repi+1, d, t) is equal to pi+1 = 1 − (1 − s/ degHi+1(Q)(u))d. 8To see this, think about the following experiment. Choosing e in Hi+1(Q) is like choosing one out of degHi+1(Q)(u) incident edges, and repeating it d times; choosing e in Hi(Q) is like choosing one out of up to V (H) · degHi+1(Q)(u) incident edges, and repeating it d∗ times. Now, to choose e in Hi(Q) we can also split all edges incident to u in Hi(Q) into degHi+1(Q)(u) groups, each group of size approximately degHi(Q)(u)/ degHi+1(Q)(u). Then, the probability that we will choose an edge from the same group as e is pu,e (approximately, because of rounding) the same as the probability that we will choose edge e in Hi+1(Q). Therefore, with probability at most 1/V (H), we would then choose edge e in Hi(Q). If we repeat this V (H) time, we will get probability Ωε,H (pu,e). (Notice that we could also be happy with the probability pu,e/V (H), since this is Ωε,H (pu,e).) 32 Let us compare it to the probability that in Random-HTraverse (Hi(Q), Repi, d∗, t∗), when vertex u then one of these edges is incident to vertex x, and when in Random- selects d incident edges i.u.r. HTraverse (Hi(Q), Repi, d∗, t∗) vertex x selects d incident edges i.u.r. then at least one edge from each of the r groups of edges incident to x in Hi(Q) is chosen9. The first probability, that one of the incident edges selected by u is incident to x, is equal to pi ≥ 1 − (1 − s/ degHi(Q)(u))d∗ , since the number of edges containing both u and x in Hi(Q) is at least s. To estimate the second probability, similarly as we were al- ready arguing in the proof of Claim 36 and analogously to the classic coupon collector's problem, if x selects at least r2 (in fact, r ln(1 + r) would suffice too) times incident edges i.u.r. (and we have d∗ ≥ V (H)2), then with probability Ωε,H (1), the corresponding set E·,x will contain at least one edge from each of the r groups of edges incident to x in Hi(Q). Therefore, in summary, with probability Ωε,H (pi), if Random- HTraverse (Hi(Q), Repi, d∗, t∗) visits vertex u, then the algorithm will visit (until at most two rounds later) edges e(cid:48) Now we only have to match the probabilities of these events in Random-HTraverse (Hi(Q), Repi, d∗, t∗) and in Random-HTraverse (Hi+1(Q), Repi+1, d, t). Since, as we were arguing above, degHi+1(Q)(u) ≤ degHi(Q)(u) ≤ V (H) degHi+1(Q)(u), we note that with our setting d∗ = V (H) · d, we have pi+1 = 1 − (1 − s/ degHi+1(Q)(u))d = Ωε,H (pi), using the same arguments as before. This gives the following: Case 2: if edge e is not in Hi(Q), when Random-HTraverse (Hi+1(Q), Repi+1, d, t) arrives at vertex u, if pi+1 is the probability that u selects an edge semi-equivalent to e among its d incident edges, then when Random-HTraverse (Hi(Q), Repi, d∗, t∗) arrives at u (with u ∈ L(cid:96)), then with proba- j=1 Ej of selected edges until at most two rounds later contains edges e(cid:48) 1, . . . , e(cid:48) bility Ωε,H (pi+1) the set(cid:83)(cid:96)+2 r that are sub-equivalent to edges e1, . . . , es. r that are sub-equivalent to e. 1, . . . , e(cid:48) 1, . . . , e(cid:48) r that are sub-equivalent to e. then with probability Ωε,H (pi+1), either E(cid:96)+1 contains an edge semi-equivalent to e, or(cid:83)(cid:96)+2 Therefore, in summary, our analysis of Case 1 and Case 2 above implies our claim that a single step of algorithm Random-HTraverse (Hi+1(Q), Repi+1, d, t) can be simulated by 2 steps of algorithm Random- HTraverse (Hi(Q), Repi, d∗, t∗), with the success probability loss of Oε,H (1). That is, if one arrives at ver- tex u in step k of Random-HTraverse (Hi+1(Q), Repi+1, d, t) and the probability that one selects an edge semi-equivalent to e is pi+1, then if one arrives at vertex u in step (cid:96) of Random-HTraverse (Hi(Q), Repi, d∗, t∗), j=1 Ej contains edges e(cid:48) Choosing starting vertex. Let us recall that the probability to choose u ∈ V (Hi+1(Q)) as a starting vertex Repi+1(v) in Random-HTraverse (Hi+1(Q), Repi+1, d, t) is pi+1 = . Since we may contract many vertices into u during our construction, the probability of choosing u as a starting vertex in Random-HTraverse (Hi+1(Q), Repi+1, d, t) can be significantly larger than the probability of choosing u in Random-HTraverse (Hi(Q), Repi, d∗, t∗), which is pi = . However, our definition of Repi+1 ensures that Rep(−1) i+1 (u) V Rep(−1) V (u) i Rep(−1) i+1 (u) = Rep(−1) i (u) + x adjacent to u in Hi(Q):χ(x)=χ(vi) (cid:88) Rep(−1) (x) . i vertex in Random-HTraverse (Hi(Q), Repi, d∗, t∗), which happens with probability Let us notice that if a vertex x of color χ(vi) that is adjacent to u in Hi(Q) is selected as the starting , then since 9Let us notice that we do not assume that x will be processed in the next round in Random-HTraverse (Hi(Q), Repi, d∗, t∗), after vertex u is processed. This is because it is possible that vertex x has been processed before vertex u, for example, as the very first vertex in the call to Random-HTraverse (Hi(Q), Repi, d∗, t∗). Our arguments imply that both u and x will be processed (in the way we want them to be processed) not later than in the next round. Rep(−1) V (x) i 33 j=0 L(cid:48) j+1 for 0 ≤ j ≤ 2t. Notice that (cid:83)t (cf. Lemma 33) x is a safe vertex with respect to Q and Hi(Q), each copy of Mi in Hi(Q) containing vertex x has at least one edge containing also vertex u. Therefore, in Random-HTraverse (Hi(Q), Repi, d∗, t∗), we will not only have x ∈ L0, but also if d = Ωε,H (1) is sufficiently large (d > V (H) will suffice), then 2 we will have u ∈ L1. Summing up over all starting vertices (including u), we with probability at least 1 obtain that u is in L0 ∪ L1 with probability at least 1 Now we are ready to complete the analysis and prove Claim 37. Let us consider the random process Random-HTraverse (Hi+1(Q), Repi+1, d, t) selecting vertices and edges to define Lj and Ej+1 for 0 ≤ j ≤ t. Similarly, let us consider the random process of Random-HTraverse (Hi(Q), Repi, d∗, 2t) select- j=1 Ej = ing vertices and edges to define L(cid:48) j = Ωε,H (1). Suppose that HTester (Hi+1(Q), Repi+1,Mi+1, d, t) starts at a vertex u = Repi+1(v) and finds a copy of Mi+1 consisting of edges e1, . . . , ek in Hi+1(Q), where k = V (H) − i. Then, our analysis above gives that with at most a constant-factor probability loss, HT- 1, and then, for every edge ej, 1 ≤ j ≤ k, will either ester (Hi(Q), Repi,Mi, d∗, 2t) will have u in L(cid:48) , . . . , e(cid:48) jr are sub-equivalent to edges ej (this defines a proper coupling, properly taking care of multiple edges equivalent to ej). Now, since every edge ej (i) either corresponds to an edge in both Mi+1 and Mi, or Ωε,H (1), (cid:83)2t have ej ∈(cid:83)2t t or e(cid:48) (ii) corresponds to an edge(cid:98)e in Mi+1 that is modeled by(cid:99)e(cid:48) spond to the edges(cid:99)e(cid:48) jr corre- we can argue that in that case, HTester (Hi(Q), Repi,Mi, d∗, 2t) will find a copy of Mi (cf. Definition 25). Therefore, with only a constant-factor probability loss, if HTester (Hi+1(Q), Repi+1,Mi+1, d, t) finds a copy of Mi+1 then HTester (Hi(Q), Repi,Mi,V (H)d, 2t) finds a copy of Mi. (cid:4) j=0 Lj = Ωε,H (1), (cid:83)t 0 ∪ L(cid:48) t, where e(cid:48) in Mi, and edges e(cid:48) , . . . ,(cid:99)e(cid:48) , . . . , e(cid:48) j and E(cid:48) j=1 E(cid:48) j = Ωε,H (1), (cid:83)2t ∈(cid:83)2t , . . . ,(cid:99)e(cid:48) , . . . , e(cid:48) j1 jr , jr j1 t=1 E(cid:48) j1 jr j1 2 pi+1. t=1 E(cid:48) j1 8 Extension to families of arbitrary (not necessarily connected) finite graphs Our result in Theorem 14 can be easily extended to allow the forbidden finite graphs H to be arbitrary, that is, not necessarily connected. Furthermore, the analysis extends in a straightforward way to the case when one wants to test if for a given arbitrary finite family H of finite graphs, the input planar graph G is H-free, that is, contain no copy of any graph from H. Disconnected H. Notice that when H is not connected, Tester (G, H, d, t) may not be able to find a copy of H in G since it explores only a small connected neighborhood of the randomly sampled starting vertex v. However, one can easily extend the tester to be run separately on each connected component of H to do the job. Let us assume that H consists of connected components h1, h2, . . . , hr. As in Section 4.1.1, we color the vertices of H arbitrarily, using V (H) distinct colors {1, 2, . . . ,V (H)}, one color for each vertex. Our analysis in Section 4 starts with (an existential) Lemma 20 that if G is ε-far from H-free, then one can color vertices of G with V (H) colors χ such that G has a set of Ωε,H (V ) edge-disjoint colored copies of H. It is easy to see that Lemma 20 holds also for disconnected H. And so, in particular, for every connected component hi of H, there are Ωε,H (V ) edge-disjoint colored copies of hi with colors of the vertices consistent with the coloring χ of G. Furthermore, since all connected components h1, h2, . . . , hr use distinct colors in H, these copies will be edge-disjoint between the copies of h1, h2, . . . , hr. Then, for every connected component hi of H, we run Tester (G, hi, di, ti), and the identical analysis as in Sections 4 -- 7 concludes that Theorem 15 holds in the following way: there are positive functions di = di(ε, hi) = Oε,H (1) and ti = t(ε, hi) = Oε,H (1), such that for any planar graph G that is ε-far from H-free, Tester(G, hi, di, ti) 34 finds a colored copy of hi with probability Ωε,H (1). Since the colored copies of connected components h1, h2, . . . , hr are pairwise disjoint in G, this implies that if we run Tester (G, hi, di, ti) for 1 ≤ i ≤ r, with appropriate di = Oε,H (1) and ti = Oε,H (1), then for any planar graph G that is ε-far from H-free, we find a colored copy of H with probability Ωε,H (1). Therefore, if we repeat this process Oε,H (1) many times, we can amplify the error probability and obtain that for any planar graph G that is ε-far from H-free, we find a colored copy of H with probability at least 2 3. Forbidden family. Next, we extend our study to test if a given planar graph contains no copy of any forbidden graph from a given finite family of finite graphs. Let H be an arbitrary finite family of finite graphs (for a given ε > 0, we allow the size to be Oε(1)). We say a simple graph G is H-free if it is H-free for every H ∈ H; G is ε-far from H-free if one has to delete more than εV edges from G to obtain an H-free graph. This definition implies that since H is finite, if G is ε-far from H-free, then there is H ∈ H such that G is ε/H-far from H-free. Let us suppose that H is an arbitrary finite family of finite graphs. (Note that since H is a finite family of finite graphs, H = Oε(1).) Then our analysis above can be easily extended to test with a constant number of queries if a planar graph is H-free. Indeed, let us run a constant query-time ε/H-tester for every H ∈ H, and reject if any of the tests rejects. Notice that if G is H-free then this tester will accept, and if G is ε-far from H-free then since there is H ∈ H such that G is ε/H-far from H, the tester will reject G with probability at least 2 3. The discussion above can be summarized in the following theorem. Theorem 38. Let H be an arbitrary collection of (not necessarily connected) finite graphs. Then there is a one-sided error property tester that for any simple planar graph G performs a constant number of queries to the random neighbor oracle and accepts if G is H-free, and with probability at least 2 3 rejects if G is ε-far from H-free. Theorem 38 holds also if H varies with different ε. That is, if for a given ε > 0, the goal is to test if G is H-free or is ε-far from H-free, for a finite family of graphs H that may depend on ε. 9 Extending the analysis to minor-free graphs While throughout the paper we focused on testing H-freeness of planar graphs, our techniques can easily be extended to any class of minor-free graphs. Recall that a graph L is called a minor of a graph G if L can be obtained from G via a sequence of vertex and edge deletions, and edge contractions. For any graph L, a graph G is called L-minor-free if L is not a minor of G. (For example, by Kuratowski's Theorem, a graph is planar if and only if it is K3,3-minor-free and K5-minor-free.) Let us fix a graph L and consider the input graph G to be an L-minor-free graph. We now argue now that entire analysis presented in the previous sections easily extends to testing H-freeness of G. The key observation is that our analysis in Sections 3 -- 7 relies only on the following two properties of planar graphs: (i) every minor of a planar graph is planar (cf. Fact 42), (ii) the number of edges in a planar graph is O(n), where n is the number of vertices (cf. Fact 43). It is known that these two properties hold for any class of L-minor-free graphs (that is, the first property would be that every minor of an L-minor-free graph is L-minor-free). Therefore, we can proceed with nearly identical analysis for L-minor-free graphs and arrive at the following version of Theorem 14. 35 Theorem 39. Let L be a fixed graph. There are positive functions f, g, and h such that for any L-minor- free-graph G: • if G is H-free, then Random-Exploration (G, H, ε) accepts G, and • if G is ε-far from H-free, then Random-Exploration(G, H, ε) rejects G with probability at least 0.99. Furthermore, in the same way as in Section 8, we can extend Theorem 38 to obtain the following. 3 rejects if G is ε-far from H-free. Theorem 40. Let L be a fixed graph. Let H be an arbitrary collection of (not necessarily connected) finite graphs. Then there is a one-sided error property tester that for any L-minor-free-graph G performs a constant number of queries to the random neighbor oracle and accepts if G is H-free, and with probability at least 2 Remark 41. It should be noted that while our main focus is on the random neighbor oracle model, it is straightforward to extend our testers (and their analysis) for H-freeness to the other three oracle access model presented in Section 1.1.2. Indeed, since each of these models can trivially simulate the random neighbor oracle model without any loss in the query complexity, Theorem 40 (and also Theorems 14 and 38) holds also for all these oracle access models. However, our main result, the characterization of testable properties in planar graphs, as well as our reduction in (cid:4) Theorem 12, cannot be extended to the other models (see Section 1.2.4). 10 Conclusions The fundamental problem in the area of property testing is to understand the complexity of testing graph properties in all natural models. One of the central questions here is to provide characterizations of testable graph properties in these models, that is, to determine which graph properties can be tested with constant query complexity. While we have characterizations of graph properties testable in the dense graph model, and some understanding of testable graph properties in the bounded-degree graph model, finding such a characterization in a very natural case of general graphs, without any bounds for their maximum degrees, remains a challenging and elusive open problem. The main result of this paper, Theorem 5, resolves an important natural special case of this open problem, which concerns property testers for planar graphs and for minor-closed graphs with one-sided error in the random neighbor oracle model. Our main technical, algorithmic contribution significantly extend the approach from [11] to prove that H-freeness is testable with a constant number of queries for general planar graphs. Our result was proven via a new type of analysis of random exploration of planar graphs and their combination of the study of hypergraph representations of contractions in planar graphs. Our analysis easily carries over to classes of graphs defined by general fixed forbidden minors. Our work is a continuation of our efforts to understand the complexity of testing basic graph properties in graphs with no bounds for the degrees. Indeed, while major efforts in the property testing community have been put to study dense graphs and bounded degree graphs (cf. [15, Chapter 8-9]), we have seen only limited advances in the study of general graphs, in particular, sparse graphs but without any bounds for the maximum degrees. We believe that this model is one of the most natural models, and it is also most relevant to computer science applications. Similarly as it has been done in [15, Chapter 10.5.3], we would advocate further study of this model because of its importance, its applications, and the variety (and beauty) of techniques used to advance this topic. 36 References [1] N. Alon, E. Fischer, M. Krivelevich, and M. Szegedy. Efficient testing of large graphs. Combinatorica, 20:451 -- 476, 2000. [2] N. Alon, E. Fischer, I. Newman, and A. Shapira. A combinatorial characterization of the testable graph properties: it's all about regularity. SIAM Journal on Computing, 39:143 -- 167, 2009. [3] N. Alon, T. Kaufman, M. Krivelevich, and D. Ron. Testing triangle-freeness in general graphs. SIAM Journal on Discrete Mathematics, 22(2):786 -- 819, 2008. [4] N. Alon and M. Krivelevich. Testing k-colorability. SIAM Journal on Discrete Mathematics, 15(2):211 -- 227, 2002. [5] N. Alon and A. Shapira. Every monotone graph property is testable. SIAM Journal on Computing, 38(2):505 -- 522, 2008. [6] N. Alon and A. Shapira. A characterization of the (natural) graph properties testable with one-sided error. SIAM Journal on Computing, 37(6):1703 -- 1727, 2008. [7] N. Alon and A. Shapira. A separation theorem in property testing. Combinatorica, 28(3): 261 -- 281, 2008. [8] I. Benjamini, O. Schramm, and A. Shapira. Every minor-closed property of sparse graphs is testable. Advances in Mathematics, 223:2200 -- 2218, 2010. [9] A. Czumaj, H. Fichtenberger, P. Peng, and C. Sohler Testable properties in general graphs and random order streaming. CoRR abs/1905.01644, 2019. [10] A. Czumaj, O. Goldreich, D. Ron, C. Seshadhri, A. Shapira, and C. Sohler. Finding cycles and trees in sublinear time. Random Structures and Algorithms, 45(2): 139 -- 184, 2014. [11] A. Czumaj, M. Monemizadeh, K. Onak, and C. Sohler. Planar graphs: Random walks and bipartiteness testing. In Proceedings of the 52th IEEE Symposium on Foundations of Computer Science (FOCS), pp. 423 -- 432, 2011. [12] A. Czumaj, A. Shapira, and C. Sohler. Testing hereditary properties of nonexpanding bounded-degree graphs. SIAM Journal on Computing, 38(6): 2499 -- 2510, April 2009. [13] T. Eden, A. Levi, D. Ron, and C. Seshadhri. Approximately counting triangles in sublinear time. SIAM Journal on Computing, 46(5): 1603 -- 1646, 2017. [14] T. Eden, D. Ron, and C. Seshadhri. On approximating the number of k-cliques in sublinear time. In Proceedings of the 50th Annual ACM Symposium on Theory of Computing (STOC), pp. 722 -- 734, 2018. [15] O. Goldreich. Introduction to Property Testing. Cambridge University Press 2017. [16] O. Goldreich, S. Goldwasser, and D. Ron. Property testing and its connection to learning and approx- imation. Journal of the ACM, 45(4): 653 -- 750, July 1998. [17] O. Goldreich and D. Ron. Property testing in bounded degree graphs. Algorithmica, 32(2): 302 -- 343, 2002. 37 [18] O. Goldreich and D. Ron. A sublinear bipartiteness tester for bounded degree graphs. Combinatorica, 19(3):335 -- 373, 1999. [19] M. Gonen, D. Ron, and Y. Shavitt. Counting stars and other small subgraphs in sublinear-time. SIAM Journal on Discrete Mathematics, 25(3): 1365 -- 1411, 2011. [20] H. Ito. Every property is testable on a natural class of scale-free multigraphs. In Proceedings of the 24th Annual European Symposium on Algorithms (ESA), pp. 51:1 -- 12, 2016. [21] T. Kaufman, M. Krivelevich, and D. Ron. Tight bounds for testing bipartiteness in general graphs. SIAM Journal on Computing, 33(6): 1441 -- 1483, September 2004. [22] S. Marko and D. Ron. Approximating the distance to properties in bounded-degree and general sparse graphs. ACM Transactions on Algorithms, 5(2), Article No. 22, March 2009. [23] R. Milo, S. Shen-Orr, S. Itzkovitz, N. Kashtan, D. Chklovskii, and U. Alon. Network motifs: Simple building blocks of complex networks. Science, 298(5594): 824 -- 827 2002. [24] I. Newman and C. Sohler. Every property of hyperfinite graphs is testable. SIAM Journal on Comput- ing, 42(3): 1095 -- 1112, 2013. [25] M. Parnas and D. Ron. Testing the diameter of graphs. Random Structures & Algorithms, 20(2):165 -- 183, 2002. [26] R. Rubinfeld and M. Sudan. Robust characterization of polynomials with applications to program testing. SIAM Journal on Computing, 25(2):252 -- 271, 1996. 38 Appendix A Basic properties of planar graphs For the sake of completeness, we discuss here some basic (and well known) properties of planar graphs, as frequently used in our paper. The graph G(cid:48) = (V (cid:48), E(cid:48)) obtained by the contraction of an edge (u, v) ∈ E into vertex u is defined as follows: V (cid:48) = V \ {v} and E(cid:48) = {(x, y) ∈ E : x (cid:54)= v ∧ y (cid:54)= v} ∪ {(x, u) : (x, v) ∈ E ∧ x (cid:54)= u}. A graph G(cid:48) that can be obtained from a graph G via a sequence of edge removals, vertex removals, and edge contractions is called a minor of G. Equivalently, a graph G contains an h-vertex graph G(cid:48) as a minor if G contains (cid:96) pairwise disjoint vertex sets V1, . . . , V(cid:96) such that the graph induced by G on each of these sets is connected, and if (i, j) ∈ E(G(cid:48)) then G contains at least one edge connecting a vertex of Vi to a vertex of Vj. If G(cid:48) is not a minor of G, then G is said to be G(cid:48)-minor free. A graph property P is minor-closed if every minor of a graph in P is also in P , or equivalently if P is closed under removal of edges, removal of vertices and contraction of edges. We use the following well-known property of planar graphs. Fact 42. Any minor of a planar graph is planar. Furthermore, we use the following upper bound on the number of edges in a simple planar graph, which follows immediately from Euler's formula. Fact 43. For any simple planar graph G = (V, E) (with no self-loops or parallel edges), E ≤ 3V − 6. We remark that for any class of graphs G that is defined by a finite collection of forbidden minors similar statements are true, i.e., if G ∈ G, then any minor of G also belongs to G and if G = (V, E) ∈ G, then G has O(V ) edges (where the constant in the Big-Oh notation depends on the set of forbidden minors). B Uniform characterization using oblivious testers and forbidden subgraphs As mentioned in Section 2.5, while Theorem 11 from [9] allows to simplify the analysis of testable prop- erties, the analysis as in Theorem 12 obtains non-uniform testers, in the sense of the dependency on n. In this section, we consider a special class of uniform testers, which we call oblivious testers, that capture the essence of testers of testable properties in the flavor of Theorem 11 (see [6] for a similar notion in the context of testing dense graphs). Definition 44. (Oblivious tester) A tester (one-sided or two-sided) for a graph property P is said to be oblivious if it works as follows: Given an ε, 0 < ε < 1, the tester • computes an integer q = q(ε), • queries q times the random vertex oracle to obtain a set (possibly, a multiset) S of q random vertices, • from each vertex v ∈ S, runs Bounded-BFS-Traverse (G, v, q, q) to get a (q, q)-bounded disc Uv, • and then accepts or rejects (possibly randomly) according to ε and the visited graph(cid:83) v Uv. Notice that thanks to Theorem 11, Definition 44 captures the essence of property testing in the random neighbor oracle model, and in that context, it is natural to consider oblivious testers. 39 Remark 45. While oblivious testers seem to be quite natural in our setting, there are two major restrictions that Definition 44 imposes on an oblivious tester. The first is that such a tester cannot use the size of the input in order to determine the parameter q which is later used for the size of the sample set S and for the depth and breadth of the bounded discs. While this seems to be a rather simple assumption, it is not difficult to construct non-oblivious testers whose query complexity is Oε(1), upper bounded by a function of ε, but in fact it depends on the size of the graph (e.g., q(ε, n) = 1/ε + (−1)n). Though this seems like a non-important and annoying technicality, it has been noted in other property testing models (see, e.g., [7]) that this subtlety may have nontrivial implications. The second restriction on an oblivious tester is that it cannot use the size of the input in order to make its decisions after the q copies of (q, q)-bounded disc has been visited by the tester. (A similar phenomenon has been also noted earlier (cf. [6]).) For example, [6] gave the following simple example: A graph on an even number of vertices satisfies P if and only if it is bipartite, while a graph on an odd number of vertices satisfies P if and only if it is triangle-free. Any tester for P must (cid:4) use the size of the input graph in order to make its decision. Notice that in Definitions 1 and 9, the families of finite graphs H depend on the graph property P, ε, and n. If H is independent of n (that is, H depends only on P and ε), then we will call P in Definitions 1 and 9, respectively, uniformly semi-subgraph-free and uniformly semi-rooted-subgraph-free. With the definitions of oblivious testers, uniformly semi-subgraph-free and uniformly semi-rooted- subgraph-free properties, and Lemma 10 at hand, we can obtain a variant of Theorem 12 for oblivious testers. Theorem 46. If a graph property P has an oblivious one-sided error tester in the random neighbor oracle model then P is uniformly semi-subgraph-free. Proof. We follow the proof of Theorem 12. As before, thanks to Lemma 10, it is enough to show that if a graph property P has an oblivious one-sided error tester then P is uniformly semi-rooted-subgraph-free. Let P be a graph property that has an oblivious one-sided error tester T. Fix ε, 0 < ε < 1. We define H as a family of rooted graphs, such that a rooted graph H belongs to H, if for some input graph G, when the tester T is run on G with given ε, then with positive probability (i) T visits (exactly) a subgraph of G that is root-preserving isomorphic to H and (ii) T rejects G. Observe that H is independent of n. We will show that so defined family H of rooted graphs satisfies the conditions in Definition 9, proving that P is uniformly semi-subgraph-free. Let us first notice that each rooted graph H has at most 2(q(ε))q(ε) vertices and at most 2(q(ε))q(ε) edges, and so H is a finite family of finite rooted graphs. Let us next show item (i) of Definition 9, that any graph G satisfying P is H-rooted-free. The proof is by contradiction. Suppose that there is a graph G satisfying P which contains a rooted copy of H ∈ H. By definition of H, there must be an input graph G(cid:48), such that G(cid:48) has a rooted copy of H, and if T is run on G(cid:48) with the fixed ε, then with positive probability, T visits that rooted copy of H and then rejects G(cid:48). But this implies that if for that ε we run T on G, then also with positive probability T visits that rooted copy of H in G. But since on that basis T rejects G(cid:48) with positive probability, so it must do for G. This means that the tester has a nonzero probability of rejecting G, contradicting our assumption that the tester T is one-sided. Now, we want to prove item (ii) of Definition 1. Let G be a graph that is ε-far from satisfying P. Any tester for P should reject G with nonzero probability. By definition of an oblivious tester, G must contain a rooted subgraph H such that if the tester T gets H from the oracle, then it rejects G. By definition of H this means that H ∈ H, which proves item (ii) of Definition 1. We showed that if P has an oblivious one-sided error tester then P is uniformly semi-rooted-subgraph- free. By Lemma 10, this yields that P is uniformly semi-subgraph-free, completing the proof. (cid:4) 40 C Auxiliary tools: Simplifying condition (a) of Lemma 17 In this section we show how one can simplify condition (a) of Lemma 17 and prove Lemma 18. Let us recall that Lemma 18 states that if there is a graph G[Q] with a linear number of edge-disjoint colored copies of H, then there is always a subset Q(cid:48) ⊆ Q with cardinality Q(cid:48) = Ωε,H (Q) such that the graph G[Q(cid:48)] satisfies property (a). Our arguments follow the approach presented in [11]. We begin by showing that condition (a) of Lemma 17 is implied by a simple condition on the degrees of the vertices in G, namely, the degree of each vertex is either 0 or is a constant factor of its corresponding degree in G. Lemma 47 (Property (a')). Let G = (V, E) be a simple graph and let d, t = Θε,H (1). Let G be a subgraph of G on vertex set V such that the following property holds: (a') for every vertex v ∈ V , either degG(v) = 0 or degG(v) = Ωε,H (degG(v)). Then property (a) of Lemma 17 is satisfied, that is, if Tester(G, H, d, t) finds a copy of H in G with proba- bility Ωε,H (1), then Tester(G, H, d, t) finds a copy of H in G with probability Ωε,H (1). Proof. Take any set of edges E that can be found by a single call of Random-Traverse (G, d, t) such that the subgraph of G induced by the edges E contains a copy of H. Since G is a subgraph of G, Random- Traverse (G, d, t) can find (explore) the same edge set E. Now, we will estimate the relation between the probability that Random-Traverse (G, d, t) finds E and the probability that Random-Traverse (G, d, t) finds E. By the assumption of the lemma, every vertex visited during the finding of E must have degG(v) = Ωε,H (degG(v)) (since these vertices cannot be isolated in G). Therefore, at every step of the exploration algorithm Random-Traverse (G, d, t), the probability of following a single edge from E decreases in G by at most a factor of Oε,H (1), compared to G. Overall the probability of finding E in G versus finding it in G (cid:4) decreases by at most a factor of (Oε,H (1)) = (Oε,H (1))Oε,H (1) = Oε,H (1). E Lemma 47 provides a useful tool that simplifies the framework from Lemma 17, and Lemma 18 shows that in fact the condition on degrees can be always obtained by a simple reduction. That is, if there is a graph G[Q] with a linear number of edge-disjoint colored copies of H, then Lemma 18 shows that there is always a subset Q(cid:48) ⊆ Q with cardinality Q(cid:48) = Ωε,H (Q) such that the graph G[Q(cid:48)] satisfies property (a) via showing that it satisfies property (a'). Lemma 18. (Transformation to obtain property (a)) Let G = (V, E) be a simple planar graph. Let Q be a set of Ωε,H (V ) edge-disjoint colored copies of H in G. Then there exists a subset Q(cid:48) ⊆ Q, Q(cid:48) = Ωε,H (V ), such that the graph G[Q(cid:48)] satisfies condition (a) of Lemma 17. Proof. We will show that if Q is a set of Ωε,H (V ) edge-disjoint colored copies of H in G, then there exists a subset Q(cid:48) ⊆ Q, Q(cid:48) = Ωε,H (V ), such that the graph G[Q(cid:48)] satisfies condition (a') of Lemma 47 (that is, for every v ∈ V , either degG[Q(cid:48)](v) = 0 or degG[Q(cid:48)](v) = Ωε,H (degG(v))). By Lemma 47, this yields the proof of Lemma 18. We construct the subset Q(cid:48) by deleting some copies of H from Q. The process of deleting copies of H is based on the comparison of the original degree of the vertices with the current degree in G[Q(cid:48)]. To implement this scheme, we write degG(v) to denote the degree of v in the original graph G and we use the term current degree of a vertex v to denote its current degree in the graph G[Q(cid:48)] induced by the current set Q Q(cid:48) of copies of H (where "current" means at a given moment in the process). Let α = V = Ωε,H (1). 41 We repeat the following procedure as long as possible: if there is a non-isolated vertex v ∈ V with current degree in G[Q(cid:48)] at most α 12 degG(v), then we delete from Q(cid:48) all copies of H in the current Q(cid:48) incident to v. To estimate the number of copies of H deleted, we charge to v the number of deleted copies of H in each such operation. Observe that each v ∈ V will be processed not more than once. Indeed, once v has been 12 degG(v) copies of H from Q(cid:48) used, it becomes isolated, and hence it is not used again. Therefore, at most α v∈V degG(v) ≤ 6V by planarity of G[Q(cid:48)], implies that the total number of copies of H removed from Q to obtain Q(cid:48) is upper bounded by 2V = Ωε,H (V ). (cid:4) can be charged to any single vertex. This, together with the inequality(cid:80) (cid:80) 2V . Since Q = αV , we conclude that Q(cid:48) ≥ Q − α 12 degG(v) ≤ α 2V = α v∈V α D Some basic properties of the process of shrinking H and hypergraph rep- resentation of H by Mi (Section 6.2) In this section we present some basic properties of the process of shrinking H and hypergraph representation of H by Mi, as defined in Section 6.2. While not all of them are necessary for our analysis, we believe they are useful to better understand the ideas behind our approach. We begin with the following simple claim. Claim 48. For any i, 1 ≤ i ≤ V (H), • V (Mi) = {vi, vi+1, . . . , vV (H)}, • for every hyperedge e ∈ E(Mi), σ(e) ⊆ V (H) \ V (Mi), and • for any e ∈ E(Mi), every vertex in σ(e) is adjacent in H only to vertices in e ∪ σ(e). Proof. Let us first notice that the first fact that V (Mi) = {vi, vi+1, . . . , vV (H)} follows trivially from our construction, and so we focus on proving the other two claims. The proof of the other two parts is by induction on i. For i = 1 the claim is true since M1 = H and since in M1, we have σ(e) = ∅ for every e. Therefore, let us assume the claim for i < V (H), and consider it for i + 1. The construction of Mi+1 ensures that the only changes between Mi and Mi+1 are in vertex vi and in the edges/hyperedges incident to vi in Mi. To see the second part of the claim, note that(cid:83) e∈E(Mi) σ(e), and hence the claim that(cid:83) {vi}∪(cid:83) to vertex vi in Mi, then σ(Ni) = {vi} ∪(cid:83) Further, vertex vi is adjacent in H only to vertices in Ni and some of vertices in(cid:83) every vertex in σ(Ni) = {vi} ∪(cid:83) e∈E(Mi+1) σ(e) = e∈E(Mi+1) σ(e) = ∅ follows by induction. To see the third part of the claim, if e ∈ E(Mi) and e ∈ E(Mi+1), then the claim follows by induction. Otherwise, if e ∈ E(Mi+1) and e (cid:54)∈ E(Mi), then e = Ni. If Ei denotes the set of edges/hyperedges incident σ(e∗). Since by induction, for any e∗ ∈ Ei (which is an edge/hyperedge in Mi), every vertex in σ(e∗) is adjacent in H only to vertices in e∗ ∪ σ(e∗), the fact that e∗ ∪ σ(e∗) ⊆ Ni ∪ σ(Ni) implies that every vertex in σ(e∗) is adjacent in H only to vertices in Ni ∪ σ(Ni). σ(e∗). Therefore, (cid:4) σ(e∗) is adjacent in H only to vertices in Ni ∪ σ(Ni). Let us state the following property of our construction that follows from our discussion. e∈E(Mi+1) e =(cid:83) e∈E(Mi+1) e∩(cid:83) e∈E(Mi) e\{vi} and(cid:83) e∗∈Ei e∗∈Ei e∗∈Ei Claim 49. For every i, 1 ≤ i ≤ V (H), the hypergraph Mi contains vertices {vi, . . . , vV (H)} and two types of edges: 42 • "regular" edges: if (vj, v(cid:96)) ∈ E(H) with i ≤ j, (cid:96) ≤ V (H), then (vj, v(cid:96)) is an edge in Mi; • hyperedges: if there is j, 1 ≤ j < i, with Nj ∩ {vj+1, . . . , vi−1} = ∅ then Nj forms a hyperedge in Mi. Proof. The proof is by induction. The claim trivially holds for M1, since M1 = H. Therefore, let us assume the claim for Mi with i < V (H), and consider it for i + 1. The construction of Mi+1 ensures that its vertex set is {vi+1, . . . , vV (H)} and the only changes between Mi and Mi+1 are in vertex vi and in the edges/hyperedges incident to vi in Mi. Any regular edge (vj, v(cid:96)) ∈ E(H) with i ≤ j, (cid:96) ≤ V (H) in Mi stays as a regular edge in Mi+1 if j, (cid:96) > i. Therefore, if (vj, v(cid:96)) ∈ E(H) with i + 1 ≤ j, (cid:96) ≤ V (H), then (vj, v(cid:96)) is an edge in Mi+1. For hyperedges, a hyperedge Nj (1 ≤ j < i) in Mi stays as a hyperedge in Mi+1 only if vi /∈ Nj. Hence, any such Nj satisfies the property that Nj ∩ {vj+1, . . . , vi−1} = ∅ and that vi /∈ Nj, and therefore Nj ∩ {vj+1, . . . , vi} = ∅. Furthermore, our construction adds also a new single hyperedge Ni with all vertices in the hyperedge in {vi+1, . . . , vV (H)}. Therefore, such a new hyperedge Ni satisfies the property that Ni∩{vi+1, . . . , vi} = ∅. Hence, in either case, if there is j, 1 ≤ j < i + 1, with Nj ∩ {vj+1, . . . , vi} = ∅ then Nj forms a hyperedge in Mi+1, as required. (cid:4) E Basic properties of consistent hypergraphs In this section we will present some basic properties of consistent hypergraphs (as defined in Section 6.3.1) used in our analysis. Let us begin with the following simple claim. Claim 50. Let Qi be a set of edge-disjoint colored copies of H in G such that the hypergraph Hi(Qi) is consistent for Qi. Then for any Q ⊆ Qi, the hypergraph Hi(Q) is consistent for Q. Proof. By Remark 22, we can define the hypergraph Hi(Qi) independently for each copy of H in Qi. Thus, if Q ⊆ Qi then Hi(Q) is a sub-hypergraph of Hi(Qi), and hence all safe vertices in Hi(Qi) are also safe in Hi(Q), meaning that Hi(Q) is consistent for Q. (cid:4) Let us also state the following simple claim. Claim 51. Let Q1, Q2, . . . , Qi be a set of edge-disjoint colored copies of H in G with Qi ⊆ ··· ⊆ Q2 ⊆ Q1. Let H1(Q1),H2(Q2), . . . ,Hi(Qi) be the sequence of hypergraphs constructed by the algorithm above, with each Hj(Qj) consistent for Qj. Then the same hypergraph Hi(Qi) would be obtained if we applied the algorithm above for the sequence Qj = Qi, for every 1 ≤ j ≤ i. (cid:4) We will also use the following property of consistent hypergraphs. Claim 52. Let Qi be a set of edge-disjoint colored copies of H in G. Let H1(Qi),H2(Qi), . . . ,Hi(Qi) be the sequence of hypergraphs constructed by the algorithm above (cf. Section 6.3), with each Hj(Qi) being consistent for Qi, 1 ≤ j ≤ i. Then, for every j, 1 ≤ j ≤ i − 1, for any vertex u ∈ V (Hj(Qi)) with χ(u) = χ(vj), the neighbors in Hj(Qi) have distinct colors. Proof. The proof follows directly from the definition of safe vertices and consistent hypergraphs. Indeed, since Hj+1(Qi) is consistent for Qi, by definition, every vertex u ∈ V (Hj(Qi)) with χ(u) = χ(vj) is safe with respect to Qi and Hj(Qi). That is, from definition of being safe, for all colored copies h ∈ Qi of H j (cid:104)u(cid:105) is the set of neighbors of u in h in the hypergraph that contain u, the sets N h Hj(Qi). Since every copy h ∈ Qi of H consists of vertices of distinct colors, this yields the claim. (cid:4) j (cid:104)u(cid:105) are the same, where N h 43 F Lemma 29: Planarization of hypergraphs via shadow graphs In this section we show how to model hypergraphs Hi(Qi) using planar graphs (via the notion of shadow graphs) to establish the proof of Lemma 29. In what follows, for fixed i, we will mimic the construction of the hypergraph Hi(Qi) to construct color-col shadow graphs Gcol(Hi(Qi)), one for each relevant color col, such that each Gcol(Hi(Qi)) is planar and it maintains the neighborhood of all vertices of color col in Hi(Qi). With this construction at hand, Lemma 29 will easily follow. As in the conditions of Lemma 29, let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Let us recall how the hypergraph Hi(Qi) is built by our algorithm from Section 6.3. In the construction of Hi(Qi), we assume that we have already fixed v1, . . . , vi−1 (and we have not fixed the order of other vertices from H, since in fact, these choices will depend on our constructions of Hi(Qi),Hi+1(Qi+1), . . . ,HV (H)(QV (H))). The algorithm takes Hi−1(Qi−1) with Qi ⊆ Qi−1, and first removes all hyperedges corresponding to the edge-disjoint copies of H in Qi−1\Qi and then takes the set Qi of copies of H and shrink them, in the same way as Mi−1 is transformed into Mi. Let us note that by Claim 51, the hypergraph Hi(Qi) can be built by applying our algorithm above with all sets Qj = Qi for all j ≤ i. Before we proceed, let us introduce some useful notation. Fix i. Let Ξ = {1, . . . ,V (H)} \ {χ(vj) : j < i}, that is, Ξ is the set of the colors of vertices from Hi(Qi). Let us recall that since for any j ≤ i, the hypergraph Hj(Qi) is consistent for Qi, by Claim 52, every vertex u ∈ V (Hj−1(Qi)) with χ(u) = χ(vj−1) has all neighbors in Hj−1(Qi) with distinct colors. To facilitate this property, for any set X ⊆ V consisting of vertices of distinct colors (e.g., X = e for an edge/hyperedge in Hj(Qi)), if X has a vertex of color from outside Ξ (that is, {χ(x) : x ∈ X} \ Ξ (cid:54)= ∅), then we call a vertex y in X with χ(y) /∈ Ξ the lowest color vertex of X if it minimizes (cid:96) with χ(y) = χ(v(cid:96)) (that is, for any vertex z ∈ X with χ(z) ∈ {χ(vj) : j < i}, if χ(y) = χ(v(cid:96)) and χ(z) = χ(vs) then (cid:96) ≤ s). Let col be an arbitrary color from Ξ. We mimic the algorithm that builds Hi(Qi) to create a sequence of graphs Gcol 1 , . . . , Gcol i as follows: to be equal to the graph G[Qi] after removing all isolated vertices in G[Qi]. • Set Gcol • For j := 2 to i, build Gcol 1 j as follows: (cid:5) Take vertex vj−1 ∈ V (H). (cid:5) For every vertex u ∈ V (Hj−1(Qi)) with χ(u) = χ(vj−1): ◦ let Γj−1(u) be the set of all neighbors of u in Hj−1(Qi) (u /∈ Γj−1(u)); ◦ if Γj−1(u) has a vertex of color not from Ξ (i.e., {χ(x) : x ∈ Γj−1(u)} \ Ξ (cid:54)= ∅) then (cid:46) let w be a lowest color vertex in Γj−1(u); (cid:46) contract edge (u, w) into vertex w; ◦ else (i.e., {χ(x) : x ∈ Γj−1(u)} ⊆ Ξ), if there is w ∈ Γj−1(u) with χ(w) = col, then (cid:46) contract edge (u, w) into vertex w; ◦ else, remove vertex u. (cid:5) Remove all parallel edges and all self-loops. The graph Gcol by Gcol(Hi(Qi)). i will be called the color-col shadow graph of the hypergraph Hi(Qi) and will be denoted Observe that any Gcol j is a simple graph (contains no self-loops nor parallel edges). Furthermore, to argue that the algorithm above makes sense, we will have to ensure that every time we perform contraction 44 of an edge (u, w) into vertex w, we must have that (u, w) is an edge in Gcol j−1. Let us also notice that every time we refer to the lowest color vertex w in the algorithm, by Claim 52, this vertex is well defined (since all vertices from Γj−1(u) have distinct colors). In what follows, we will prove three keys properties of our construction, is planar, (1) that each Gcol j (2) that for every contraction of an edge (u, w) into vertex w, (u, w) is an edge in Gcol (3) that we maintain some partial neighborhoods of all vertices of color col and of vertices that later can be contracted to create new edges (note that all these vertices must have colors from outside Ξ, since vertices from Ξ will not be contracted in future iterations). Case (3) requires some additional care, so that if we contract an edge/hyperedge e in Hj(Qi) and if e has a vertex of color from outside Ξ, then we will maintain only the neighborhood of one vertex from this edge, the first one that will be later contracted in the algorithm -- which is the lowest color vertex of e. j−1, and F.1 Properties of color-col shadow graphs j and Gcol(Hi(Qi)). Let us begin with a characterization of the vertex sets in Gcol Claim 53. For every j, 1 ≤ j ≤ i, for every u ∈ V , vertex u is not in Gcol isolated vertex in G[Qi] or u (cid:54)∈ V (Hj(Qi)). Proof. The claim easily follows from our construction. Firstly, the first step of our construction removes all isolated vertices in G[Qi]. Secondly, the only other moment when one removes vertices is when one removes every vertex u ∈ V (Hj−1(Qi)) with χ(u) = χ(vj−1) and 2 ≤ j ≤ i. That is, one removes all non- isolated vertices u in G[Qi] with χ(u) ∈ {χ(vj) : j < i}, which are exactly all vertices u (cid:54)∈ V (Hi(Qi)). (cid:4) if and only if either u is an j Our next claim describes a key property of color-col shadow graphs. The construction of the color- col shadow graph mimics the construction of the hypergraph Hi(Qi) with one key difference: while to construct Hj(Qi) from Hj−1(Qi) we remove every vertex u of color χ(vj−1) from Hj−1(Qi) and add a new hyperedge "connecting" the neighbors of u in Hj−1(Qi), in the color-col shadow graph we perform a similar operation to define Gcol j , but instead of connecting the neighbors using a single hyperedge, we either connect them by adding edges from all neighbors to a single vertex (edge-contraction), or we do nothing. The following lemma shows that this construction properly maintains the neighborhoods of vertices of color col and our property (2) above. Lemma 54. Let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Let col be any color in Ξ. Then, (a) for any vertex u ∈ V (Hi(Qi)) of color col, if x ∈ V \ {u} is a neighbor of u in Hi(Qi), then x is also a neighbor of u in the color-col shadow graph Gcol(Hi(Qi)), and (b) every time to define Gcol (u, w) is an edge in Gcol j , j > 1, we perform contraction of an edge (u, w) into vertex w, we have that j−1. Proof. We first prove by induction on j the following invariant for every j, 1 ≤ j ≤ i: (1) if e is an edge in Hj(Qi) that contains at least one vertex with colors from outside Ξ, then for every x ∈ e \ {w}, Gcol j contains edge (x, w), where w is the lowest color vertex in Γj−1(u); 45 (2) if e is an edge in Hj(Qi) that contains only vertices with colors from Ξ and contains a vertex u of color col, then for every x ∈ e \ {u}, Gcol j contains edge (x, u); (3) every time to define Gcol j , j > 1, we perform contraction of an edge (u, w) into vertex w, we have that (u, w) is an edge in Gcol j−1. (Let us remark that the reason of special treatment of the edges/hyperedges e in Hj(Qi) containing only vertices with colors from Ξ \ col, is that our construction ensures that all such edges will stay unchanged , and hence, since they contain no vertices of color col, they are irrelevant for the set of in Gcol neighbors of any vertex u of color col.) 1 = G[Qi] = H1(Qi), all invariants trivially hold To prove the invariants, let us first note that since Gcol j+1, . . . , Gcol i for j = 1. Next, let us assume that j > 1. First, we observe that invariant (3) for j follows immediately from invariant (1) for j − 1. Indeed, let us consider a vertex u ∈ V (Hj−1(Qi)) with χ(u) = χ(vj−1). Then, every neighbor x of u will be adjacent to u via an edge/hyperedge in Hj−1(Qi) containing u. Since each edge has vertices of distinct colors, vertex u is the lowest color vertex in e. Therefore, by invariant (1), graph Gcol Next, we prove that invariants (1) and (2) hold for j > 1, assuming the invariants hold for j − 1. First, let us notice that any edge/hyperedge e in Hj−1(Qi) that contains no vertex of color χ(vj−1) will also be an edge in Hj(Qi), and hence invariants (1) and (2) will be satisfied. Therefore we only have to consider the case when a new hyperedge e is created in Hj(Qi). This edge e has been obtained by taking a vertex z ∈ V (Hj−1(Qi)) with χ(z) = χ(vj−1), and creating e to be equal to the set of all neighbors of z in Hj−1(Qi). Notice that by invariant (1) and because z is the lowest color vertex in every edge/hyperedge incident to z in Hj−1(Qi), vertex z is adjacent in Gcol j−1 to all of its neighbors in Hj−1(Qi), that is, e ⊆ Γj−1(z). Therefore, the operation of contracting any edge (z, y) in Gcol j−1 to vertex to every vertex from e \ {y}. Therefore, by the way y in Gcol chooses vertex w, we can conclude that invariants (1) and (2) hold how our algorithm constructing Gcol j for j. j will result in vertex y being adjacent in Gcol j j−1 contains edge (x, u). Now, once we have proven the invariants, we can conclude the proof of Lemma 54. Indeed, invariant (cid:4) (2) for j = i implies the proof of property (a) and invariant (3) yields property (b). Notice that property (b) of Lemma 54 together with the well-known fact that any number of edge- contractions of a planar graph leaves the graph planar (cf. Section A) yields the following. Claim 55. If G is a planar graph then so is Gcol i , for every i and col ∈ Ξ. Now we are ready to complete the proof of Lemma 29. Lemma 29. Let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Then, there is a simple graph G(Hi(Qi)), (a) with the vertex set equal to the set of all non-isolated vertices in Hi(Qi), (b) that is a union of at most V (H) simple planar graphs, and (c) such that for any distinct x, y ∈ V (Hi(Qi)), x is adjacent to y in Hi(Qi) if and only if x is adjacent to y in G(Hi(Qi)). Proof. Let us define a simple graph G∗ That is, its vertex set V ∗ i ) that is a union of graphs Gcol(Hi(Qi)) for col ∈ Ξ. is equal to the set of non-isolated vertices in Hi(Qi) (or equivalently, vertices of i = (V ∗ i , E∗ i 46 G[Qi] of colors from Ξ) and its edge set E∗ that is, i contains all edges from all graphs Gcol(Hi(Qi)) for col ∈ Ξ, i = {(x, y) ∈ V 2 : x (cid:54)= y and there exists col ∈ Ξ such that (x, y) ∈ E(Gcol(Hi(Qi)))} . E∗ i For any vertex u ∈ V , let NG∗ i and let NHi(Qi)(u) be the set of neighbors of vertex u in Hi(Qi). Notice that by Lemma 54, for any vertex u ∈ V , every neighbor x ∈ V \ {u} of u in Hi(Qi) is also a neighbor of u in G∗ (u) be the set of neighbors of vertex u in G∗ for every u ∈ V it holds that NHi(Qi)(u) \ {u} ⊆ NG∗ (u) . Now, we define the shadow graph G(Hi(Qi)) to be the maximal subgraph of G∗ (1) i for which (1) holds, i for which NHi(Qi)(u) \ {u} = NG(Hi(Qi))(u) for every u ∈ V . Clearly, since (cid:4) that is, a subgraph of G∗ G(Hi(Qi)) is a subgraph of G∗ i , this completes the proof of Lemma 29. i . That is, i Qi Qi G Proof of Lemma 30: Finding many copies of H with low-degree vertices In this section we prove Lemma 30, which states that for any set Qi of edge-disjoint colored copies of H in G with consistent Hi(Qi), there is a set Q ⊆ Qi of size at least 4V (H)+2 such that in the hypergraph Hi(Q), every copy of H in Q has a vertex with at most 6V (H) distinct neighbors. The proof of Lemma 30 follows closely the arguments from [11], though the analysis needs to be expanded to deal with the underlying hypergraphs rather than graphs, and to rely on a graph representation that is a union of several planar graphs, rather than a single simple planar graph. Lemma 30. Let Qi be a set of edge-disjoint colored copies of H in G and let Hi(Qi) be a hypergraph consistent for Qi. Then, there is a set Q ⊆ Qi of size at least 4V (H)+2 such that in the hypergraph Hi(Q), every copy of H in Q has a vertex with at most 6V (H) distinct neighbors. Proof. Our proof relies on Lemma 29, which ensures that in order to analyze the neighbors of any vertex in Hi(Qi) (or its sub-hypergraph Hi(Q) with Q ⊆ Qi) it is sufficient to consider the neighbors of that vertex in G(Hi(Qi)) (or its relevant subgraph). Notice that the vertex set of G(Hi(Qi)) is the set of all non-isolated vertices in Hi(Qi). Since G(Hi(Qi)) is a union of at most V (H) simple planar graphs, by Euler's formula, in any subgraph of G(Hi(Qi)) there exists a non-isolated vertex with at most 6 · V (H) − 1 neighbors; taking into account edges incident to u in Hi(Qi) that contain u itself, there is always a non-isolated vertex in Hi(Qi) with at most 6 · V (H) neighbors. We will rely on this property throughout the proof.10 In what follows, we will consider subsets of the input set Qi of copies of H and their representation in the subgraph of the shadow graph G(Hi(Qi)) (by using the properties from Lemma 29). Any copy h of H in Qi is represented by a subgraph of G(Hi(Qi)), such that if h corresponds to a copy of Mi in Hi(Qi), then for any vertex u ∈ V (Hi(Qi)) in that copy, the neighbors of u in that copy are also the neighbors of u in that subgraph of G(Hi(Qi)). This definition can be extended to the representation of any subset Q∗ ⊆ Qi of copies of H: Q∗ is represented by a subgraph of G(Hi(Qi)) with the edge set that is a union of all subgraphs corresponding to all copies of H in Q∗. This representation will allow to naturally define the operation of removal of some copies of H from Qi in the context of the subgraphs of G(Hi(Qi)). Let G be the shadow graph G(Hi(Qi)), as defined in Lemma 29. We find Q in two phases. 10To prove it, let (cid:98)G be a subgraph G(Hi(Qi)), and let V(cid:98)G be the set of non-isolated vertices in (cid:98)G. By Euler's formula (cf. Fact 43), (cid:98)G has at most V (H)·(3V(cid:98)G−6) < 3·V (H)·V(cid:98)G edges. Therefore, since(cid:80) deg(u) = 2·E((cid:98)G) < 6·V (H)·VG, there must be a vertex in V(cid:98)G with at most 6V (H) − 1 distinct neighbors. u∈V(cid:98)G 47 Phase 1: Let Q be initially set up to be the input set Qi of copies of H. We partition Q into levels, iteratively removing the copies of H until Q is empty. In the jth iteration, we choose an arbitrary vertex uj that belongs to at least one copy of H in Q and which has at most 6V (H) distinct neighbors in the current graph G representing Q. (Here Q refers to the current set Q, i.e., after the removal of the sets from the previous iterations of the repeat-loop.) Every copy h of H in Q that contains uj is removed from Q. If a copy h is removed in the jth iteration, then its level (cid:96)(h) is equal to j. Phase 2: We start again with Q being the input set Qi of copies of H. We iterate through the levels in decreasing order. For each level j, we let A(j) denote the current subset of copies of H in Q at level j. By definition of the level, all copies of H in A(j) must contain vertex uj. Furthermore, we define B(j) to be the subset of copies of H in Q that contain uj and have a level smaller than j. We observe that if we remove all copies of H in B(j) from Q, then every copy of H in A(j) contains a vertex (e.g., vertex uj) with at most 6V (H) distinct neighbors in G. The second phase relies on this observation, and for every j, we will decide whether we want to return in the final Q all copies of H in A(j), in which case we will remove all copies of H in B(j), or not. For that, we compare the size of A(j) to the size of B(j). If A(j) ≥ 2V (H) · B(j), then we keep A(j) and remove B(j) from Q; otherwise, we remove A(j). By our arguments above, the set Q ⊆ Qi obtained at the end will consist solely of copies of H that contain at least one vertex with at most 6V (H) distinct neighbors in G. Then, we only will have to prove below that Q ≥ Qi 1 4V (H)+2. We will now present more detailed arguments after describing a pseudocode of the process. Assigning-Levels (set Qi of copies of H and a shadow graph G(Hi(Qi))) • j = 1 Phase 1: • Q = Qi; G = G(Hi(Qi)) • Repeat until Q is empty: ◦ Let uj be a non-isolated vertex that has at most 6V (H) distinct neighbors in G ◦ For all copies of H h ∈ Q that contain uj, let (cid:96)(h) = j ◦ Remove from Q all copies of H that contain uj and update G accordingly ◦ j = j + 1 Phase 2: • Q = Qi • Repeat until j = 1: ◦ j = j − 1 ◦ A(j) = {h ∈ Q : (cid:96)(h) = j} ◦ B(j) = {h ∈ Q : (cid:96)(h) < j and h contains uj} ◦ if A(j) ≥ ◦ Update G accordingly 2V (H) · B(j) then Q = Q \ B(j) else Q = Q \ A(j) 1 • Return Q 48 In what follows we will prove the correctness of the algorithm. We first observe that Phase 1 terminates since G is a union of at most V (H) copies of planar graph and of self-loops, and therefore by Euler's formula, it has a non-isolated vertex with at most 6V (H) neighbors (this also holds during the execution of the algorithm since planarity is closed under edge removals). It remains to analyze Phase 2 of the algorithm. Every copy of H in Q: (a) is removed because it is contained in some set A(j) that is removed from Q in Phase 2, or (b) is removed because it is contained in some set B(j) that is removed from Q in Phase 2, or (c) is not removed and stays in the final set Q (and hence, by our arguments above, it contains at least one vertex with at most 6V (H) distinct neighbors in G, and thus in Hi(Q)). Let α, β, γ be the respective numbers of copies of H in the original Qi (notice that γ = Q). Clearly, 4V (H)+2 · Qi. We proceed in two 2Qi. Then we argue in 4V (H)+2 · Qi, Qi = α + β + γ and to prove Lemma 30 we have to show that γ ≥ steps. We first prove in Claim 56 that α ≤ 1 Claim 57 that 2V (H)γ ≥ β. This yields (2V (H) + 1)γ ≥ 1 completing the proof of Lemma 30. Claim 56. α ≤ 1 Proof. We charge the vertices from the removed sets A(j) to the sets B(j) and derive a bound on the sum of sizes of the sets B(j). Recall that every copy of H contains V (H) vertices. In every copy, one vertex is the vertex that has at most 6V (H) distinct neighbors in G, when the copy is removed in Phase 1 of the algorithm. Thus, every copy is contained in at most V (H) − 1 different sets B(j). It follows that 2Qi, which implies that β + γ ≥ 1 2Qi and hence Q = γ ≥ 2Qi. 1 1 B(j) ≤ (V (H) − 1) · Qi . (cid:88) j (cid:88) j∈R Let R denote the set of indices j such that A(j) is removed from Q during Phase 2. Observe that whenever we remove a set A(j), we have A(j) < 1 2V (H)B(j) by the condition in the process. It follows that 2V (H)B(j) ≤ V (H) − 1 2V (H) · Qi .(cid:4) · Qi < 1 2 1 (cid:88) j∈R α = A(j) < Claim 57. 2V (H)γ ≥ β. Proof. For every set B(j) removed from Q, we know that A(j) ≥ 2V (H)B(j). At the point of time when B(j) is removed from Q, the set A(j) remains in Q because A(j) and B(j) are disjoint. Since we are iterating downwards through the levels of the copies of H, the set A(j) is also disjoint from all sets B(j(cid:48)), j(cid:48) < j, and so it is not removed also in any future iteration of the repeat loop. Thus, in this case each copy of H from A(j) remains in Q until the end of the process and contributes to the value of γ. Let R(cid:48) be the set of indices j such that A(j) remains in Q during Phase 2 (and hence B(j) is removed from Q). Since each j∈R(cid:48) A(j) ≤ γ. copy of H in A(j), j ∈ R(cid:48), contributes to γ and since sets A(j) are disjoint, we obtain(cid:80) 1 Hence, 1 2V (H) β = 1 2V (H) (cid:88) j∈R(cid:48) B(j) ≤ (cid:88) j∈R(cid:48) A(j) ≤ γ , which implies the claim. (cid:4) 49 With Claims 56 -- 57 at hand, we obtain that the set Q (Q ⊆ Qi) contains copies of H such that • each copy of H in Q has a vertex with at most 6V (H) distinct neighbors in Hi(Q), and • Q = γ ≥ 4V (H)+2 · Qi. 1 This completes the proof of Lemma 30. (cid:4) 50
1805.04071
2
1805
2018-05-15T12:54:17
Energy Complexity of Distance Computation in Multi-hop Networks
[ "cs.DS", "cs.DC" ]
Energy efficiency is a critical issue for wireless devices operated under stringent power constraint (e.g., battery). Following prior works, we measure the energy cost of a device by its transceiver usage, and define the energy complexity of an algorithm as the maximum number of time slots a device transmits or listens, over all devices. In a recent paper of Chang et al. (PODC 2018), it was shown that broadcasting in a multi-hop network of unknown topology can be done in $\text{poly} \log n$ energy. In this paper, we continue this line of research, and investigate the energy complexity of other fundamental graph problems in multi-hop networks. Our results are summarized as follows. 1. To avoid spending $\Omega(D)$ energy, the broadcasting protocols of Chang et al. (PODC 2018) do not send the message along a BFS tree, and it is open whether BFS could be computed in $o(D)$ energy, for sufficiently large $D$. In this paper we devise an algorithm that attains $\tilde{O}(\sqrt{n})$ energy cost. 2. We show that the framework of the ${\Omega}(n)$ round lower bound proof for computing diameter in CONGEST of Abboud et al. (DISC 2017) can be adapted to give an $\tilde{\Omega}(n)$ energy lower bound in the wireless network model (with no message size constraint), and this lower bound applies to $O(\log n)$-arboricity graphs. From the upper bound side, we show that the energy complexity of $\tilde{O}(\sqrt{n})$ can be attained for bounded-genus graphs (which includes planar graphs). 3. Our upper bounds for computing diameter can be extended to other graph problems. We show that exact global minimum cut or approximate $s$--$t$ minimum cut can be computed in $\tilde{O}(\sqrt{n})$ energy for bounded-genus graphs.
cs.DS
cs
Energy Complexity of Distance Computation in Multi-hop Networks∗ Yi-Jun Chang University of Michigan Abstract Energy efficiency is a critical issue for wireless devices operated under stringent power constraint (e.g., battery). Following prior works, we measure the energy cost of a device by its transceiver usage, and define the energy complexity of an algorithm as the maximum number of time slots a device transmits or listens, over all devices. In a recent paper of Chang et al. (PODC 2018), it was shown that broadcasting in a multi-hop network of unknown topology can be done in poly log n energy. In this paper, we continue this line of research, and investigate the energy complexity of other fundamental graph problems in multi-hop networks. Our results are summarized as follows. Breadth-first search. To avoid spending Ω(D) energy, the broadcasting protocols of Chang et al. (PODC 2018) do not send the message along a BFS tree, and it is open whether BFS could be computed in o(D) energy, for sufficiently large D. In this paper we devise an algorithm that uses O(√n) energy.1 Diameter. We show that the framework of the Ω(n) round lower bound proof for computing diameter in CONGEST of Abboud et al. (DISC 2017) can be adapted to give an Ω(n) energy lower bound in the wireless network model (with no message size and runtime constraint), and this lower bound applies to O(log n)-arboricity graphs. From the upper bound side, we show that the energy complexity of O(√n) can be attained for bounded-genus graphs (which includes planar graphs). Minimum Cut. Our upper bound for computing diameter can be extended to other graph problems. We show that exact global minimum cut or approximate s -- t minimum cut can be computed in O(√n) energy for bounded-genus graphs. In contrast, there are Ω(n) energy lower bounds for computing the exact value of (i) a s -- t minimum cut (for planar graphs), and (ii) a global minimum cut (for unit disc graphs). 8 1 0 2 y a M 5 1 ] S D . s c [ 2 v 1 7 0 4 0 . 5 0 8 1 : v i X r a ∗Supported by NSF grants CCF-1514383 and CCF-1637546. E-mail: [email protected] 1The notation O(·) suppresses any poly log n factor. 1 Introduction In many wireless networks (e.g., sensor networks), devices are operated under a limited power constraint (e.g., capacity of the battery). To maximize the lifetime of a network, it is important that the devices operate in an energy efficient manner. For small devices, the majority of energy is often spent on radio transceiver usage (sending and receiving packets), and not on computation. Rather than assigning a different energy cost per each mode of operation, we simply assume that a device spends one unit of energy when it sends a message or listens to the channel. This is a common assumption; see, e.g., [8, 19, 20, 22, 21]. Wireless Network Models. A network is modeled as a connected undirected graph G = (V, E), where each vertex is a device, and each edge represents a communication link. We assume that the local clock of each device is synchronized to a global time (e.g., they can use GPS technology). Communication proceeds in synchronized rounds, and all devices agree on the same starting time. In each round, each device can listen to the channel, send a message to its neighbors, or be idle. We do not allow a device to simultaneously send and listen (i.e., we are in the half-duplex model). We assume that there is no message size constraint. The energy cost of a device is measured by the total number of channel accesses (i.e., the number of rounds that the device sends or listens). The energy cost of an algorithm is the maximum energy cost of a device, among all devices. In one round, if a device v listens to the channel, and exactly one device u in N (v) transmits a message, then v receives the message sent by u. If the number of transmitting devices in N (v) is not 1, then v receives a channel feedback which depends on the underlying model. Without Collision Detection: No-CD. If the number of transmitting devices in N (v) is not 1, then v receives "silence". With Collision Detection: CD. If the number of transmitting devices in N (v) is greater than 1, then v receives "noise". If the number of transmitting devices in N (v) is 0, then v receives "silence". Each transmitting or idle device does not receive any feedback from the communication channel. In particular, a transmitting device does not know whether its message is successfully received by its neighbors. Throughout the paper, unless otherwise stated, we are always in the randomized No-CD model. We assume that each device has access to an unlimited local random source, but there is no shared randomness between devices. We do not consider deterministic algorithms in this paper. The maximum allowed failure probability is, by default, f = 1/poly(n), and the term "with high probability" refers to probability of 1 − 1/poly(n). Note that randomized algorithms can generate private random bits to break symmetry, e.g., they can assign themselves O(log n)-bit IDs, which are distinct with high probability. Therefore, we may assume that each device already has a distinct ID of length O(log n). The graph topology of the underlying network G is initially unknown to all devices; but we assume that the two parameters n = V and ∆ = maxv deg(v) are initially known to everyone. Whether the assumption that transmitting and listening both cost one unit of energy is valid depends on the underlying wireless network technology. Note that, in general, there is also a difference between the energy consumption of receiving packets and that of idle listening (i.e., the transceiver circuits are active, but no message is received). There are examples of networks where the difference between these costs is small; see e.g., [31, Table 1]. In real world, a wireless device might be allowed to adjust the power of transmission, which affects the range that its message can reach. In this paper, we assume that all devices send with a fixed power. This is not an uncommon assumption; see e.g., [5]. Message-Passing Models. The LOCAL model considers the setting where there is no collision at all, and each message sent along each edge is successfully transmitted [27, 28]. The CONGEST model is a variant of the LOCAL model that requires each message to have length at most O(log n). 1.1 Related Works Energy saving is a critical issue for wireless networks, and there have been a lot of efforts in designing energy efficient algorithms in networking and systems research. In what follows, we briefly summarize prior works 1 in theory research that considered channel accesses as a complexity measure. Single-hop Networks. First, we consider an important special case where all devices are within a single hop (i.e., G is a clique), but the number of devices n is unknown. The computation model for single-hop networks is simpler than that of general mult-hop networks. Variants of the models that are often considered include: (i) whether or not a device can simultaneously send and listen (i.e., full duplex and half duplex), (ii) the ability to detect collision (i.e., CD and No-CD), (iii) whether to allow randomness. There has been a line of research on the energy complexity of fundamental problems such as leader election (all vertices in the network agree on a leader), and approximate counting (all vertices estimate the number of vertices within a constant factor) [19, 21, 22, 23, 4, 8]. In the randomized half-duplex model, both problems have energy complexity Θ(log(log∗ n)) and Θ(log∗ n), in CD and No-CD, respectively, for poly(n)-time algorithms that succeeds with probability 1 − 1/poly(n) [8]. Multi-hop Networks. Chang et al. [7] extended the above single-hop network model to the multi-hop setting, and they showed that broadcasting can be done in poly log n energy. They presented randomized algorithms for CD and No-CD using energy O( log n log log ∆ log log log ∆ ) and O(log ∆ log2 n), respectively, but it takes super-linear time to attain these energy complexities. There is a constant k0 > 0 such that for any k > k0, if one is allowed to spend O(logk n) energy, then broadcasting can be solved in D1+O(1/k) · O(logk n) time. They also showed three lower bounds: (i) an Ω(log(D)) lower bound, which applies to even the LOCAL model on path graphs, (ii) an Ω(log ∆ log n) lower bound for randomized No-CD, and (iii) an Ω(log n) lower bound for randomized CD. Klonowski and Pajak [25] investigated a variant of the model where only transmitting costs energy, and they showed that in No-CD, for any 1 ≤ ϕ ≤ O(log n/ log log n), broadcasting can be solved in O((D + ϕ)n1/ϕϕ) time using O(ϕ) transmission per vertex. Other than [7, 25], there are a number of works that studied energy efficiency of multi-hop networks from different perspectives. In wireless networks, the power of a signal received is proportional to O(1/dα), where d is the distance to the sender, and α is a constant related to environmental factors. Kirousis et al. [24] studied the optimization problem of assigning transmission ranges of devices subject to some connectivity and diameter constraints, and the goal is to minimize the total power consumption; see also [32, 9, 2] for related works. A major cost of energy loss is due to collision of multiple signals. A number of papers studied the problem of minimizing the number of rounds or transmissions to realize certain communication task [11, 30, 5]. In the setting of known network topology, Gsieniec et al. [15] designed a randomized protocol for broadcasting in O(D + kn1/(k−2) log2 n) rounds such that each device transmits at most k times. 1.2 Our Contribution As observed in [7], for graphs of bounded degree ∆ = O(1), all graph problems can be solved in O(log n) energy (we will see this in Section 2). Thus, the main challenge for achieving energy efficiency is to deal with "vertex congestion" at high degree vertices. If the energy budget is x, then only (at most) x messages can be transmitted across each vertex v. For comparison, the well-studied distributed CONGEST model only captures the issue of "edge congestion". For simpler problems like broadcasting, vertex congestion might not be a critical issue. For more complicated tasks like computing diameter, it might be necessary to have a large amount of messages sent across a vertex v to solve the problem. Our results are briefly summarized as follows. Breadth-first Search. In the BFS problem, we are given a specific source vertex s, and the goal is to let each vertex v learn dist(v, s). Note that the broadcasting protocols of Chang et al. [7] do not send the message along a BFS tree so as to avoid spending Ω(D) energy, and it is open whether BFS can be computed in o(D) energy, for sufficiently large D. In this paper, we show that there is a randomized algorithm for BFS in O(n1.5) time and O(√n) energy. For large D, this improves upon the trivial/standard approach (which constructs the BFS tree along the BFS tree itself) that takes O(D) time and energy. Our BFS algorithm for Theorem 3 is a result of a combination of some communication building blocks and a known approach in distributed and parallel shortest path algorithms [14, 18, 33, 10]. The algorithm 2 samples O(√n) distinguished vertices, each of them builds a local BFS tree of depth O(√n), and the final BFS tree rooted at s can be constructed by combining the local BFS trees. Diameter. We show that the framework of the CONGEST Ω(n) time lower bound for computing diameter of Abboud et al. [1] can be adapted to give an Ω(n) energy lower bound in the wireless network model, even allowing unbounded message size and runtime. This lower bound applies to even O(log n)-arboricity graphs. This adaptation is very specific to this lower bound proof and does not apply to other CONGEST lower bounds, in general. For instance, the Ω(√n) lower bounds in [29] do not seem to extend to the energy complexity in wireless networks (with no message size constraint), and we are not aware of any non-trivial Ω(√n) energy lower bound. Due to the Ω(n) energy lower bound for O(log n)-arboricity graphs, in order to design energy efficient algorithms for computing diameter, we have to consider graph classes that are "more specialized" than low arboricity graphs. Note that arboricity is a graph parameter that measures the density of the graph. A graph has arboricity k if its edge set can be partitioned into k forests. We show that the energy complexity of O(√n) can be attained for the class of bounded-genus graphs, which includes planar graphs. Our algorithm is based on a partition of vertices into a high degree part and a low degree part, and a classification of small degree components into three types. We show that for some small degree components, we only need to extract a small amount of information in order to compute the diameter. Minimum Cut. Our approach for computing diameter in bounded-genus graphs is sufficiently generic that it can be applied to other graph problems as well. In particular, we show that both exact global minimum cut and approximate s -- t minimum cut can be computed in O(√n) energy for bounded-genus graphs. In contrast, there are Ω(n) energy lower bounds for computing the exact value of (i) an s -- t minimum cut (for planar graphs), and (ii) a global minimum cut (for unit disc graphs). Remark. Our results about bounded-genus graphs also fit into a recent line of research on distributed computing for planar or near-planar graph classes. Ghaffari and Haeupler [13] showed that minimum span- ning tree can be computed in O(D) time for planar graphs via low-congestion short cuts. This approach has been extended to any graph class that can be characterized by an exclusion of a set of minors (which includes bounded-genus graphs) by Haeupler, Li, and Zuzic [16]. 2 Basic Building Blocks and a Simple BFS Algorithm In this section we present the basic tools that we use in our algorithms. Some of them are extensions of the techniques developed in [7]. Based on these building blocks, we devise a simple BFS algorithm that achieves O(√n) energy complexity. 2.1 SR-communication Let S and R be two not necessarily disjoint vertex sets. The task SR-comm [7] is defined as follows. Each vertex u ∈ S holds a message mu that it wishes to transmit, and each vertex v ∈ R wants to receive a message from vertices in N +(v) ∩ S, where N +(v) = N (v) ∪ {v} is the inclusive neighborhood of v. An algorithm for SR-comm guarantees that for each v ∈ R with N +(v) ∩ S 6= ∅, the vertex v receives a message mu from at least one vertex u ∈ N +(v) ∩ S, with high probability. Several variants of SR-comm are defined as follows. Finding Minimum: SR-commmin. The message mu sent from each vertex u ∈ S contains a key ku from the key space [K] = {1, 2, . . . , K}, and we require that w.h.p., every v ∈ R with N +(v)∩S 6= ∅ receives a message mu such that ku = minu′∈N +(v)∩S ku′ . We define SR-commmax analogously. Multiple Messages: SR-commmulti. Each vertex u ∈ S holds a set of messages Mu. For each message m, all vertices holding m have access to shared random bits (associated with m). We assume that for each v ∈ R, the number of distinct messages in Su∈N +(v)∩S Mu is upper bounded by a number M , 3 which is known to all vertices. We require that each vertex v ∈ R receives all distinct messages in Su∈N +(v)∩S Mu w.h.p. All Messages: SR-commall. Every v ∈ R needs to receive the message mu, for each u ∈ N +(v) ∩ S w.h.p. We let ∆′ be an upper bound on S ∩ N (v), for each v ∈ R. If ∆′ is unknown, then we can set ∆′ = ∆. Approximate Sum: SR-commapx. The message mu sent from each vertex u ∈ S is an integer within the mu within an range [W ]. Every v ∈ R needs to approximately learn the summation Pu∈N +(v)∩S (1 ± ǫ)-factor w.h.p. The following table summarizes the time and energy complexity of our algorithms for these tasks; see Appendix A for proofs. These algorithms serve as basic communication primitives in subsequent discussion. Note that we do not optimize some of the complexities. Time O(log ∆ log n) O(∆′ log n) Task SR-comm SR-commall SR-commmulti O(M log ∆ log2 n) SR-commmin SR-commapx Energy O(log ∆ log n) O(∆′ log n) O(M log ∆ log2 n) O(log K log ∆ log n) O(K log ∆ log n) O((1/ǫ6) log W log ∆ log n) O((1/ǫ6) log W log ∆ log n) For the special case of S ∩ R = ∅ and R ∩ N (v) ≤ 1 for each v ∈ S, the runtime of SR-commmin can be improved to O(log K log ∆ log n). 2.2 Vertex Labeling and Broadcasting A good labeling is a vertex labeling L : V (G) 7→ {0, . . . , n − 1} such that each vertex v with L(v) > 0 has a neighbor u with L(u) = L(v) − 1 [7]. A vertex v is called a layer-i vertex if L(v) = i. Note that if there is a unique layer-0 vertex r (which is also called the root), then L represents a tree T rooted at r. However, since a vertex could have multiple choices of its parent, the tree T might not be unique. The following lemma was proved in [7]. Lemma 1. A good labeling L with a unique layer-0 vertex r can be constructed in O(n log ∆ log2 n) time and O(log ∆ log2 n) energy. We are allowed to choose whether or not to designate a specific vertex r. A good labeling allows us to broadcast messages in an energy-efficient manner. In particular, we have the following lemma. Lemma 2. Suppose that we are given a good labeling L with a unique layer-0 vertex r. Then we can achieve the following. 1. It takes O(n∆ log n) time and O(∆ log n) energy for every vertex to broadcast a message to the entire network. 2. It takes O(nx log ∆ log n)) time and O(x log ∆ log n)) energy for x vertices to broadcast messages to the entire network. Proof. For the first task, consider the following algorithm. We relay the message of each vertex to the root r using the following converge cast algorithm. For i = n− 1 down to 1, do SR-commall with S being the set of all layer-i vertices, and R being the set of all layer-(i − 1) vertices. For each execution of SR-commall, each vertex in S transmits not only its message but also all other messages that it has received so far. Although we perform SR-commall n − 1 times, each vertex only participates at most twice. Thus, the cost is O(n∆ log n) time and O(∆ log n) energy. After that, the root r has gathered all messages. The root r then broadcasts this information to all vertices via the diverge cast algorithm, as follows. For i = 0 to n − 2, do SR-comm with S being the set of all layer-i vertices, and R being the set of all layer-(i + 1) vertices. Similarly, although we perform SR-comm for n − 1 times, each vertex only participates at most twice. Thus, the cost is O(n log ∆ log n) time and O(log ∆ log n) energy. 4 The second task can be solved similarly. Let X be a size-x set of vertices that attempt to broadcast a message. We present two different algorithms solving this task. Both of them take O(nx log ∆ log n) time and O(x log ∆ log n) energy. We can solve this task by first doing a converge cast (using SR-commmulti with M = x) to gather all x messages to the root, and then do a diverge cast (using SR-comm) to broadcast these messages from root to everyone. Note that in order to use SR-commmulti, the initial holder of each message m needs to first generate a sufficient amount of random bits and attach them to the message; these random bits serve as the shared randomness associated with the message m (which is needed in SR-commmulti). The cost of SR-commmulti with M = x is O(nx log ∆ log n) time and O(x log ∆ log n) energy. Alternatively, the task can be solved using only SR-comm. Consider the following procedure which broadcasts at least one message m among all x messages. Do a converge cast using SR-comm, and then it is guaranteed that at least one message m is reached to the root r. Next, we do a diverge cast using SR-comm to broadcast the message m to everyone. This takes O(n log ∆ log n) time and O(log ∆ log n) energy. To solve the task we repeat this procedure for x times, and so the total cost is O(nx log ∆ log n) time and O(x log ∆ log n) energy. A Note about Energy Efficiency for Small Degree Graphs. For the LOCAL model, it is possible to construct a good labeling L with a unique layer-0 vertex r in O(log n) energy [7]. Note that in LOCAL each vertex is able to gather the list of IDs of its neighbors in one round. Given L, the root r is able to gather the entire graph topology in O(1) energy in LOCAL (using a converge cast to relay the information to the root layer-by-layer). Thus, all graph problems in the LOCAL model can be solved using merely O(log n) energy. In [7], they also showed that we can simulate any LOCAL algorithm in the CD or No-CD models on bounded degree graphs (i.e., ∆ = O(1)) with only O(1)-factor overhead on both time and energy costs. Thus, all graph problems in wireless network models on bounded degree graphs can be solved using O(log n) energy. We can establish this result formally via Lemma 2(1). Note that we can let each vertex v learn the ID list of N (v) by doing SR-commall with S = R = V , where the message of each vertex is its ID; this takes O(∆ log n) time and energy. After each vertex knows the ID list of N (v), we apply Lemma 2(1) to let every vertex learn the entire network topology; it takes O(n∆ log n) time and O(∆ log n). In view of the above, in this work we only focus on unbounded degree graphs in wireless network models. 2.3 A Simple Breadth-first Search Algorithm In the BFS problem, we are given a specific source vertex s, and the goal is to let each vertex v learn It is straightforward to see that a BFS labeling can be constructed in O(D) time and energy dist(v, s). (using SR-comm to construct the BFS tree layer-by-layer). In this section, we show that BFS can be solved in O(√n) energy, for a general graph G = (V, E). This is more energy efficient than the trivial/standard method for large diameter graphs. Theorem 3. There is a randomized algorithm for BFS taking O(n1.5) time and O(√n) energy. The BFS algorithm for Theorem 3 is based on a combination of the building blocks and a known approach in distributed and parallel shortest path algorithms [14, 18, 33, 10]. More specifically, we sample a set U of distinguished vertices such that each vertex v 6= s joins U independently with probability log n/√n (and s ∈ U with probability 1). Note that U < 2√n log n with high probability (by a Chernoff bound). We have the following lemma, which first appeared in [33]. Lemma 4. Let s be a specified source vertex. Let U be a subset of vertices such that each vertex v 6= s joins U with probability log n/√n, and s joins U with probability 1. With probability 1 − n−Ω(C), the following is true. For each vertex t 6= s, there is an s -- t shortest path Ps,t that contains no C√n-vertex subpath P ′ such that P ′ ∩ U = ∅. Proof. Given any set S of C√n vertices, the probability that S ∩ U = 0 is at most (1 − log n/√n)C√n = n−Ω(C). The lemma follows by a union bound over n − 1 choices of t, and a union bound over at most O(n) choices of C√n-vertex subpaths of a given s -- t shortest path Ps,t. 5 In view of Lemma 4, if each vertex t knows (i) dist(t, v) for each v within distance C√n to t, and (ii) all-pair distances of vertices in U , then t has enough information to calculate dist(s, t). The reason is as follows. Let Ps,t be an s -- t shortest path. Then we can decompose P into subpaths (s, . . . , v1), (v1, . . . , v2), (v2, . . . , v3), . . ., (vk, . . . , t) such that s, v1, . . . , vk ∈ U , and each subpath has length at most C√n. Since t knows the length of all these subpaths, t can calculate its distance to s. In what follows, we show how to let each vertex t acquire this information. 1/poly(n). eδ (1+δ)1+δ (cid:17)1 Step 1: Local BFS Searches. At a high level, we let each u ∈ U initiate a distance-C√n local BFS-tree rooted at u, in parallel; we assign each local BFS search with a random starting time so as to minimize the amount of local contention. That is, we show that during the algorithm, for each time slot, and for each vertex v, the number of local BFS searches hitting v is small. The idea of using random starting time to schedule multiple algorithms is from [26], and this technique is later extended in [12]. Our goal in Step 1 is to let each vertex v ∈ V know dist(v, u) for each u ∈ U such that dist(v, u) ≤ C√n. We aim at devising an algorithm that takes O(√n) time and O(√n) energy. The algorithm consists of h = 2√n log n + C√n epochs. Each epoch consists of poly log n time slots, which is enough for executing SR-commmulti with M = O(log n/ log log n). Each vertex u ∈ U selects a number τu (indicating the starting epoch) uniformly at random from the numbers [2√n log n]; the following lemma is straightforward. Lemma 5. Suppose U < 2√n log n. For each vertex v, and for each integer d = 1, . . . , h, with high probability, the number of vertices u ∈ U such that τu + dist(u, v) = d is at most O(log n/ log log n). Proof. Given two vertices u ∈ U and v ∈ V , and a fixed number d, the probability that τu + dist(u, v) = d is at most 1/(2√n log n). Let X be the total number of u ∈ U such that τu + dist(u, v) = d. The expected value of X is at most µ = U/(2√n log n) < 1, since U < 2√n log n. By a Chernoff bound, for any δ > 0, we have Pr[X ≥ (1 + δ) · 1] < (cid:16) . As long as δ = Ω(log n/ log log n), we have Pr[X ≥ (1 + δ) · 1] = Each vertex u ∈ U starts its local BFS search at epoch τu. For each i = 0, . . . , C√n− 1, at the beginning of epoch τu + i, (by the inductive hypothesis) all vertices that are within distance i to u already know their distance to u; by the end of epoch τu + i, we require that all vertices that are within distance i + 1 to u know their distance to u. This can be achieved via an application of SR-commmulti with M = O(log n/ log log n). Recall (Lemma 5) that in one epoch each vertex v only needs to learn at most O(log n/ log log n) distances (each corresponds to a local BFS search initiated at a distinct vertex u ∈ U ), and so the number of distinct messages v needs to receive is at most O(log n/ log log n). In what follows, we describe the details of SR-commmulti in an epoch x. We set R = V . For each u ∈ U such that x = τu +i for some i ∈ {0, . . . , C√n−1}, the layer-i vertices {v ∈ V dist(u, v) = i−1} in the local BFS tree rooted at u are included in the set S, and these vertices transmit the same message containing the following three components: (i) the number i, (ii) the ID of u, and (iii) the (shared) random bits generated by u. Recall that SR-commmulti requires that all holders of the same message have shared randomness. That is, we need the vertices participating in the local BFS search initiated by u ∈ U to agree on the same choices of random bits. We let u generate all random bits needed at the beginning of the algorithm, and these random bits are sent to other vertices through SR-commmulti along the local BFS tree rooted at u. To summarize, we perform h = 2√n log n + C√n = O(√n) number of SR-commmulti with M = O(log n/ log log n), and the runtime for each SR-commmulti is O(1), and so the time complexity of Step 1 is O(√n). Step 2: Gathering Distance Information. Recall that by the end of the previous step, each vertex If we let each vertex v gather all information stored in all vertices in U , then v is able to locally calculate the all-pair distances among vertices in U . The task of letting all vertices in U broadcast a message can be done via Lemma 2(2) with v ∈ V knows dist(v, u) for each u ∈ U such that dist(v, u) ≤ C√n. x = 2√n log n > U. The cost is O(n1.5) time and O(√n) energy. 6 3 Diameter In this section, we show that the energy complexity of computing diameter is Ω(n/ log2 n) in both CD and No-CD, even for O(log n)-arboricity graphs. For the upper bound side, we show that for bounded-genus graphs, diameter can be computed in O(√n) energy. The genus of a graph G is the minimum number g such that G can be drawn on an oriented surface of g handles without crossing. A graph with genus g = O(1) is called bounded-genus. For example, planar graphs are genus-0 graphs; graphs that can be drawn on a torus without crossing have genus at most 1. Bounded-genus graphs is a much wider graph class than planar graphs. For instance, the 5-vertex complete graph K5 is not planar, but the genus of Kx is ⌈(x−3)(x−4)/12⌉; see [17, p. 118]. Theorem 6. There is a randomized algorithm for computing diameter in O(n1.5) time and O(√n) energy for bounded-genus graphs. Theorem 7. The energy complexity of computing diameter is Ω(n/ log2 n) in both CD and No-CD. This is true even for graphs of arboricity O(log n). Note that the lower bound proof naturally extends to the setting where the maximum degree is ∆. In this setting, computing diameter takes Ω(∆/ log2 ∆) energy. 3.1 A Partition of the Vertex Set Let G = (V, E) be a bounded-genus graph. Let VH be the set of vertices that have degree at least √n; let VL = V \ VH . We assume VH ≥ 1; since otherwise we can already solve all problems in O(√n) energy, in view of the discussion in Section 2.2. We divide the connected components induced by vertices in VL into three types. For each component S, denote G[S] as the subgraph induced by all edges that have at least one endpoint in S.2 Type 1. A connected component S induced by vertices in VL is of type-1 if S ≤ √n and Sw∈S N (w) ∩ VH = 1. For each vertex u ∈ VH , we write C(u) to denote the set of type-1 components S such that Sw∈S N (w) ∩ VH = {u}. Type 2. A connected component S induced by vertices in VL is of type-2 if S ≤ √n and Sw∈S N (w) ∩ VH = 2. For each pair of two distinct vertices {u, v} ⊆ VH , we write C(u, v) to denote the set of type-2 components S such that Sw∈S N (w) ∩ VH = {u, v}. Type 3. A connected component S induced by vertices in VL is of type-3 if it is neither of type-1 nor of type-2. Since G is of bounded-genus, we have E(G) = O(n), and so VH = O(√n). In what follows, we show that the number of type-3 components is also O(√n). Lemma 8. Let G be a bipartite graph with bipartition V = X ∪ Y and genus at most g. If deg(v) ≥ 3 for each v ∈ X, then X ≤ 2Y + 4(g − 1). Proof. Let E, V , and F be the edge set, vertex set, and face set of G. Note that in a bipartite graph, each face has at least 4 edges, and each edge appears in at most 2 faces, and so E ≥ 2F. Combining this inequality with Euler's polyhedral formula V − E + F ≥ 2 − 2g (note that the genus of G is at most g), we obtain that 2V − E ≥ 4(1 − g). Since deg(v) ≥ 3 for each v ∈ X, we have E ≥ 3X. Note that we also have V = X + Y , and so 2V − E ≤ 2(X + Y ) − 3X = 2Y − X. Therefore, 2Y − X ≥ 4(1 − g), as desired. Therefore, as long as G is of bounded-genus, we have X ≤ 2Y + O(1) by Lemma 8. The reader might wonder whether we can replace the bounded-genus requirement to the weaker requirement of being bounded-minor-free. It is not hard to see that being bounded-minor-free is in general not enough to guarantee X = O(Y ), as the complete bipartite graph K3,x does not contain K5 as a minor, for any x. 2In most of the literature, G[S] is used to denote the subgraph induced by S; but in this paper we write G[S] to denote the subgraph induced by Sv∈S N (v). 7 Lemma 9. Given that G is of bounded-genus, the number of type-3 components is at most O(√n). Proof. By its definition, if a type-3 component S satisfies Sw∈S N (w)∩ VH ≤ 2, then S > √n. Thus, the number of type-3 components S such that Sw∈S N (w) ∩ VH ≤ 2 is at most √n. Let X be the set of all type-3 components S such that Sw∈S N (w) ∩ VH > 2. Consider a bipartite graph G∗ with the bipartition X ∪ VH , where each S ∈ X is adjacent to all v ∈ Sw∈S N (w) ∩ VH . Note that deg(S) ≥ 3 for each S ∈ X. The property that the genus is at most k is closed under edge contraction and vertex removal. Note that G∗ can be obtained from G via a sequence of edge contractions and vertex removals, and so G∗ is of bounded-genus. By Lemma 8, we have X ≤ 2VH + O(1) = O(√n). We let GH be the graph defined by the vertex set VH and the edge set {{u, v} : C(u, v) > 0}. The following lemma is useful in subsequent discussion. Lemma 10. Given that G is of bounded-genus, the number of edges in GH is at most O(√n). Furthermore, there is an edge orientation of GH such that each vertex has out-degree O(1). Proof. The graph GH can be obtained from G via a sequence of edge contractions and vertex removals, and so GH is of bounded-genus. Note that bounded-genus graphs have arboricity O(1), and so the number of edges in GH is at most linear in the number of vertices in GH , which is O(√n), and we can orient the edges of GH in such a way that each vertex has out-degree of O(1). Note that the number of type-3 components is still O(√n) even if the graph genus is as high as O(√n), and so in a sense Lemma 10 is the bottleneck of our approach. 3.2 Computing Diameter via Graph Partition Before we proceed, we briefly discuss our proof idea. First of all, learning the entire graph topology of the subgraph induced by VH and all type-3 components is doable using O(√n) energy via Lemma 2; this is based on the following facts: (i) VH = O(√n), (ii) deg(v) = O(√n) for each v in a type-3 component, and (iii) the number of type-3 components is O(√n). More specifically, we can use SR-commapx to let each vertex v ∈ V approximately learn its degree. Then, we use SR-commall to let all vertices in VL learn the set of all its neighbors. Since VH = O(√n), we can do another SR-commall to let each v ∈ VH learn N (v) ∩ VH . For each component S of VL, we use Lemma 2(1) to let each vertex v ∈ S broadcast the IDs of vertices in N (v) to all vertices in S; after that, each vertex v ∈ S knows the topology of G[S]. Recall that (i) VH = O(√n) and (ii) the number of type-3 components is O(√n), and so we can use Lemma 2(2) with x = O(√n) to do the following. • Each v ∈ VH broadcasts the IDs of vertices in N (v) ∩ VH . • A representative of each type-3 component S broadcasts the topology of G[S]. At this point, all vertices know the topology of the subgraph induced by VH and all type-3 components. See Section 3.3 for details. It is much more difficult to extract information from type-1 and type-2 components. For example, a vertex u ∈ VH could be connected to Θ(n) type-1 components (i.e., C(u) = Θ(n)). Since the energy budget for u is O(√n), throughout the entire algorithm u can only receive information from at most O(√n) components in C(u). The challenge is to show that the diameter can still be calculated with limited amount of carefully chosen information about type-1 and type-2 components. The goal of this section is to define a set of parameters of type-1 and type-2 components, and to show that with these parameters, the diameter can be calculated. In subsequent discussion, denote eccentricity(u, S) as maxv∈S dist(u, v). By default, all distances are with respect to the underlying network G; we use subscript to indicate distances within a specific vertex set, edge set, or subgraph. 8 Parameters for Type-1 Components. We first consider type-1 components in C(u), for a vertex u ∈ VH . Ai[u], ai[u]: Denote A1[u] as a component S ∈ C(u) that maximizes eccentricity(u, S), and denote A2[u] as a component S ∈ C(u) \ {A1[u]} that maximizes eccentricity(u, S). For i ∈ {1, 2}, denote ai[u] = eccentricity(u, Ai[u]). B[u], b[u]: Denote B[u] as a component S ∈ C(u) that maximizes maxs,t∈S∪{u} dist(s, t), and denote b[u] as maxs,t∈B[u]∪{u} dist(s, t). Some of the above definitions are undefined when C(u) is too small. For example, if C(u) = 1, then In such a case, we set these parameters to their default values: zero for A2[u] and a2[u] are undefined. numerical parameter (e.g., a2[u] = 0), and empty set for vertex set parameter (A2[u] = ∅). It is also possible that there are multiple choices of a parameter, and we may break ties arbitrarily. Observe that any path connecting a vertex in SS∈C(u) S to the rest of the graph must passes the vertex u ∈ VH . We only need to extract the following information from C(u) for the calculation of diameter: • The longest distance between two vertices within SS∈C(u) S ∪{u}, and this is max{b[u], a1[u] + a2[u]}. • The longest distance between u and a vertex in SS∈C(u) S, and this is a1[u]. Thus, regardless of the size of C(u), we only need to learn a1[u], a2[u], and b[u] from the components of C(u). These parameters can be learned via SR-commmax, as follows. For each S ∈ C(u), there will be a representative vertex rS,u ∈ S responsible of communicating with u, and the vertex rS,u already knows the topology of G[S]. Then, u can learn one of the above parameters by doing one SR-commmax with S = {rS,u S ∈ C(u)} and R = {u}, and this takes only O(1) time. See Section 3.3 for details. Parameters for Type-2 Components. The issue about type-2 components is more complicated, as we need to extract O(√n) parameters from each C(u, v). We first describe the parameters, and later explain their purposes. Consider two distinct vertices u, v ∈ VH . R[u, v], r[u, v]: Let R[u, v] be a component S ∈ C(u, v) that minimizes distG[S](u, v), and we write r[u, v] = distG[R[u,v]](u, v). Intuitively, R[u, v] corresponds a component that offers the shortest route between u and v, among all components in C(u, v). Ak i [u, v], ak i [u, v]: For a component S ∈ C(u, v), denote Su,k as the set of vertices {w ∈ S distG[S](w, v) − distG[S](w, u) ≥ k}. Intuitively, Su,k is the set of all vertices in S whose distance to u (in the subgraph G[S]) is shorter than that to v by at least k units. Denote Ak Ak 2[u, v] as a component S ∈ C(u, v) \ {Ak ak i [u, v] = eccentricityG[Ak 1[u, v] as a component S ∈ C(u, v) that maximizes eccentricityG[S](u, Su,k), and denote 1[u, v]} that maximizes eccentricityG[S](u, Su,k). We write i [u, v]). We only consider k ∈ {−√n, . . . ,√n}. i [u,v]](u, Ak Bl[u, v], bl[u, v]: For a component S ∈ C(u, v), denote Gl[S] as the graph resulting from adding to G[S] a length-l path connecting u and v; and denote φl(S) as the maximum value of distGl[S](s, t) over all pairs of vertices s, t ∈ S ∪ {u, v}. A useful observation is that if distV \S(u, v) = l, then φl(S) equals the maximum value of distG(s, t) over all pairs of vertices s, t ∈ S ∪ {u, v}. Denote Bl[u, v] as a component S ∈ C(u, v) \ {R[u, v]} that maximizes φl(S), and write bl(u, v) = φl(Bl[u, v]). We only consider l ∈ {1, . . . ,√n}. i [u, v] and Ak Similar to parameters of type-1 components, all above parameters are set to their default values if undefined. Note that the definition of ak i [u, v] 6= ak i [v, u] and Ak We explain the relevance of the above parameters to the calculation of diameter. Let P = (s, . . . , t) be an s -- t shortest path in G whose length equals the diameter. Consider three possible ways that P involves vertices in SS∈C(u,v) S. i [v, u]. All remaining parameters for type-2 components are symmetric. i [u, v] are asymmetric in the sense that we might have ak i [u, v] 6= Ak • The two endpoints s and t are within G[S], for a component S ∈ C(u, v). In this case, if distV \S(u, v) = l, then the length of P equals φl(S) = bl(u, v). 9 • There is a subpath P ′ = (u, . . . , v) of P whose intermediate vertices are all in SS∈C(u,v) S; in this case, the length of P ′ equals r[u, v]. • Suppose s ∈ S for a component S ∈ C(u, v), but t is not in G[S]. Suppose P ′ = (s, . . . , u) is a subpath of P such that all vertices in P ′ \ {u} are all in S. If dist(t, v) − dist(t, u) = k, then we must have s ∈ Su,k, and so the length of P ′ equals ak 2[u, v] (for the case t ∈ Ak 1[u, v] (for the case t /∈ Ak 1[u, v]). 1[u, v]) or ak The above discussion also explains why we need to consider different values of l and k. For example, the choice of the vertex t and dist(t, v) − dist(t, u) are unknown to vertices in a component S ∈ C(u, v), and so there is a need to go over all possibilities to ensure that all candidate shortest paths are considered. Even though each C(u, v) is associated with O(√n) parameters, all these parameters can still be learned using O(√n) energy per vertex. By Lemma 10, there is an assignment F : E(GH ) 7→ VH mapping each pair {u, v} ∈ E(GH ) to one vertex in {u, v} such that each w ∈ VH is mapped at most O(1) times, and so we can let each w ∈ VH be responsible of learning at most O(√n) parameters. Learning one parameter can be done using SR-commmax or SR-commmin in O(1) time. See Section 3.3 for details. The Graph G⋆. To show that one can compute the diameter from a set of parameters extracted from type- 1 and type-2 components (and the topology of the subgraph induced by VH and all type-3 components), a plausible proof strategy is to classify all shortest paths into classes, and to show how to compute the longest path length in each class. This approach would probably end up being a long case analysis, and so we adopt a different approach, as follows. Since we have no message size constraint, instead of only learning the aforementioned distance parameters associated with type-1 and type-2 components, we also learn the topology of G[S] for each component S associated with these distance parameters. Define G⋆ as the subgraph induced by (i) VH , (ii) all type-3 components, (iii) A1[u], A2[u], and B[u], for i [v, u], Bl[u, v], and R[u, v], for each pair of distinct vertices {u, v} ⊆ VH , In the rest of this section, we prove that the diameter of G equals the diameter of G⋆, and so the task of each u ∈ VH , and (iv) Ak i ∈ {1, 2}, k ∈ {−√n, . . . ,√n}, and l ∈ {1, . . . ,√n}. i [u, v], Ak computing the diameter of G is reduced to learning the topology of G⋆. Lemma 11. The diameter of G equals the diameter of G⋆. Proof. The proof strategy is to show that the following two statements are correct. (S1) For each pair of vertices {s, t} in the graph G⋆, we have distG(s, t) = distG⋆(s, t); this is proved in Lemma 12. (S2) For each pair of vertices {s, t} in the graph G, there exists a pair of vertices {s′, t′} in the graph G⋆ satisfying distG(s, t) ≤ distG(s′, t′); this is proved in Lemma 14. The two statements together imply that G and G⋆ have the same diameter. Lemma 12. For any two vertices s and t in G⋆, we have distG(s, t) = distG⋆ (s, t). Proof. We choose P to be an s -- t path in G whose length is distG(s, t) that uses the minimum number of vertices not in G⋆. If P is entirely in G⋆, then we are done. In what follows, suppose that P is not entirely in G⋆. Then P contains a subpath P ′ = (u, . . . , v) whose intermediate vertices are all within a type-2 component S ∈ C(u, v) that is not included to G⋆. By the definition of R[u, v], the length of P ′ is not longer than the shortest path between u and v via R[u, v], which has length r[u, v]. Therefore, we can replace P ′ with a path via vertices in Rj[u, v] (which is within G⋆) without increasing the path length. This contradicts our choice of P . Lemma 13. Let P be a shortest path between two vertices s and t in G such that s ∈ S for some type-1 or type-2 component S not included in G⋆, and t does not reside in G[S]. Then there exists a vertex s′ in G⋆ such that distG(s′, t) ≥ distG(s, t). 10 Proof. Suppose that S ∈ C(u) is of type-1. Let i ∈ {1, 2} be an index such that t is not in Ai[u]. Consider the subpath P = (s, . . . , u) of P . The length of P must not be longer than ai[u], and there exists a vertex s′ ∈ Ai[u] such that the length of the shortest path between s′ and u is ai[u]. Thus, we have distG(s′, t) = distG(s′, u) + distG(u, t) ≥ distG(s, u) + distG(u, t) = distG(s, t). Let k = distG[S](s, v) − distG[S](s, u). Note that at least one of Ak Next, consider the case that S ∈ C(u, v) is of type-2. The path P must contain at least one of u and v. Without loss of generality, assume that u is in P , and there is a subpath P = (s, . . . , u) of P such that v is not in P . Note that all vertices in P other than u are in S, and so the length of P equals distG[S](s, u)+distG(u, t). 2[u, v] does not contain t. i [u, v] as any one of them that does not contain t. We choose s′ ∈ S′ as a vertex such that i [u, v] and distG[S ′](s′, v) − distG[S ′](s′, u) ≥ k. The existence of such s′ is guaranteed by i [u, v]. i [u, v] + distG(u, t). We choose S′ = Ak distG[S ′](s′, u) = ak the definition of Ak i [u, v] + distG(u, t) ≥ distG(s, t) and (ii) distG(s′, t) = ak 1[u, v] and Ak Our plan is to show that (i) ak Combining these two inequalities give us the desired result distG(s′, t) ≥ distG(s, t). Proof of (i). By the definition of Ak we have ak i [u, v], we must have distG[S ′](s′, u) = ak i [u, v] + distG(u, t) ≥ distG[S](s, u) + distG(u, t) = distG(s, t). i [u, v] ≥ distG[S](s, u), and so Proof of (ii). Suppose that (ii) is not true. Then any shortest path between s′ and t must contain a subpath P ′ = (s′, . . . , v) such that u is not in P ′, and so we have: distG(s′, t) = distG[S ′](s′, v) + distG(v, t) < distG[S ′](s′, u) + distG(u, t). Combining this inequality with the known fact distG[S ′](s′, v) − distG[S ′](s′, u) ≥ k, we have: distG(u, t) − distG(v, t) > distG[S ′](s′, v) − distG[S ′](s′, u) ≥ k, which implies that distG(v, t) < distG(u, t) − k (⋆). We calculate an upper bound of distG(s, t). distG(s, t) ≤ distG[S](s, v) + distG(v, t) = (k + distG[S](s, u)) + distG(v, t) < (k + distG[S](s, u)) + (distG(u, t) − k) = distG[S](s, u) + distG(u, t). by definition of k. by (⋆). This contradicts the fact that P is a shortest path between two vertices s and t in G, as the length of P equals distG[S](s, u) + distG(u, t). Lemma 14. For any two vertices s and t in the graph G, there exist two vertices s′ and t′ in the graph G⋆ such that distG(s, t) ≤ distG(s′, t′). Proof. If both s and t are already in G⋆, then we are done by setting s′ = s and t′ = t. In what follows, assume that at least one of s and t is not in G⋆. Case 1: Consider the case where s and t are within G[S], for a type-1 or a type-2 component S that is not included in G⋆. If S ∈ C(u) for some u ∈ VH , then in the component B[u] ∈ C(u) there reside two vertices s′ and t′ such that distG(s′, t′) = b[u] ≥ distG(s, t) according to the definition of B[u]. Next, consider the situation S ∈ C(u, v) for some u, v ∈ VH . Let l = distV \S(u, v). Note that l ≤ r[u, v], since S 6= R[u, v] and the existence of S guarantees that R[u, v] 6= ∅. Consider the component Bl[u, v] ∈ C(u, v). We also have l = distV \Bl[u,v](u, v), since the shortest u -- v path via R[u, v] is not longer than any u -- v path via S or Bl[u, v], according to our choice of R[u, v]; also note that our definition of Bl[u, v] prevents Bl[u, v] = R[u, v]. Since l = distV \Bl[u,v](u, v), by definition of Bl[u, v], there exist two vertices s′ and t′ in G[Bl[u, v]] such that distG(s′, t′) ≥ distG(s, t), since otherwise we would have selected Bl[u, v] = S. 11 Case 2: Next, consider the case where there s and t do not completely reside in the same subgraph G[S], for any type-1 or type-2 component S. If s is not in G⋆, we apply Lemma 13 to find a vertex s′ in G⋆ such that distG(s, t) ≤ distG(s′, t); otherwise we simply set s′ = s. If t is not in G⋆, we apply Lemma 13 again to find a vertex t′ in G⋆ such that distG(s′, t) ≤ distG(s′, t′); otherwise we simply set t′ = t. Our choice of s′ and t′ satisfies distG(s, t) ≤ distG(s′, t′). 3.3 Learning the Graph Topology of G⋆ In this section we show how to let all vertices learn the graph topology of G⋆. Throughout this section, we implicitly assume that the communication network G is of bounded-genus. Recall that GH is the graph C(u, v) > 0}, and we know that E(GH ) = O(√n) defined by the vertex set VH and the edge set {{u, v} : from Lemma 10. By Lemma 10, there exists an assignment F : E(GH ) 7→ VH mapping each pair {u, v} ∈ E(GH ) to one vertex in {u, v} such that each w ∈ VH is mapped at most O(1) times. Let A′ be any deterministic algorithm that finds such an assignment F , and we fix F ⋆ to be the outcome of A′ on the input GH . Note that if each vertex v ∈ V already knows the graph GH , then v can locally calculate F ⋆. To learn G⋆, we first let each vertex u ∈ V learn the following information. Note that I1(u) and I2(u) contain nothing if u ∈ VL. Basic Information I0(u): For each vertex u ∈ V , I0(u) contains the following information: (i) whether u ∈ VH or u ∈ VL, (ii) the list of vertices in N (u) ∩ VH , and (iii) the set of all pairs {u′, v′} ∈ E(GH ). If u is in a component S of VL, then I0(u) contains the following additional information: (i) the list of vertices in S, and (ii) the topology of the subgraph G[S]. Information about Type-1 Components I1(u): For each u ∈ VH , I1(u) contains the graph topology of G[S′], for each S′ = A1[u], A2[u], and B[u]. i [u, v], Ak Information about Type-2 Components I2(u): For each u ∈ VH , I2(u) contains the following infor- mation. For each pair {u, v} ∈ E(GH ) such that F ⋆({u, v}) = u, I2(u) includes the graph topology of i [v, u], Bl[u, v], and R[u, v], for each i ∈ {1, 2}, k ∈ {−√n, . . . ,√n}, G[S′], for each S′ = Ak and l ∈ {1, . . . ,√n}. Note that the information I0(u) allows each vertex u to calculate F ⋆ locally. The following lemma shows that letting each vertex u ∈ V learn I0(u), I1(u), and I2(u) is all we need. Lemma 15. Given that each u ∈ V already knows I0(u), I1(u), and I2(u), in O(n1.5) time and O(√n) energy, we can let each vertex in G learn the graph topology of G⋆. Proof. To learn G⋆, it suffices to know (i) I1(u) and I2(u) for each u ∈ VH , (ii) the graph topology of G[S] for each type-3 component S, and (iii) the graph topology of the subgraph induced by VH . For each type-3 component S, let rS be the smallest ID vertex in S. In view of the above, to let each vertex learn the topology of G⋆, it suffices to let the following vertices broadcast the following information: • For each u ∈ VH , u sends I1(u), I2(u), and the list of vertices N (u)∩ VH (which is contained in I0(u)). • For each u ∈ VL such that u = rS for a type-3 component S, u sends the graph topology of G[S]. Note that each vertex u ∈ VL can decide locally using information in I0(u) whether or not u itself is rS for a type-3 component S. Since VH = O(√n) and the number of type-3 components is also O(√n) by Lemma 9, the number of vertices that need to broadcast is O(√n). Thus, we can use Lemma 2(2) with x = O(√n) to broadcast all the above information. This is done in time O(n1.5), and energy O(√n). Next, we consider the task of learning the basic information I0(u). Lemma 16. In O(√n) time and energy, each vertex v is able to detect whether v ∈ VH or v ∈ VL. Moreover, if v ∈ VH , v learns the list of vertices in N (v) ∩ VH ; if v ∈ VL, v learns the two lists of vertices N (v) ∩ VL and N (v) ∩ VH . 12 Proof. First, use SR-commapx (with W = 1, ǫ = 1, S = R = V , and mu = 1 for each u ∈ S) to let each v ∈ V estimate deg(v) up to a factor of 2. This step takes O(1) time. Next, do SR-commall with S = V and R being the set of all vertices v whose estimate of deg(v) is at most 2√n. The message mv for each vertex v is its ID, and we use the bound ∆′ = 4√n for SR-commall. Recall that VL is the set of vertices of degree less than √n, and so we must have VL ⊆ R. After this step, each vertex v ∈ V has enough information to decide whether v ∈ VH or v ∈ VL. Furthermore, if v ∈ VL, then v knows the list of all vertices N (v). This step takes O(√n) time. Lastly, for each vertex to learn all the required vertex lists, do SR-commall again with a different setting. Let S = VH , and R = V . The message mv for each vertex v ∈ S is its ID. We use the bound ∆′ = √n ≥ VH. After SR-commall, each vertex v ∈ V knows the list of vertices in N (v)∩ VH . For each v ∈ VL, since v already knows the list of all vertices N (v), it can locally calculate the list N (v)∩VL. This step takes O(√n) time. Lemma 17. In O(n1.5) time and O(√n) energy, each vertex in each component S of VL is able to learn (i) the list of vertices in S, and (ii) the topology of the subgraph G[S]. Proof. First, apply Lemma 16 to let each vertex v ∈ S learn the two lists N (v) ∩ VL and N (v) ∩ VH . To let each vertex learn the required information, it suffices to let each v ∈ S broadcast the two lists N (v) ∩ VL and N (v) ∩ VH to all vertices in S. We use Lemma 1 to let each component S of VL compute a good labeling with one root vertex rS. Then, we invoke Lemma 2(1) to let each vertex v ∈ S broadcast the two lists N (v)∩VL and N (v)∩VH to all vertices in S. Recall that the degree of any vertex in VL is less than √n, and so the cost of applying Lemma 2(1) is O(n1.5) time and O(√n) energy. Recall that GH is the graph defined by the vertex set VH and the edge set {{u, v} : After executing the algorithm of Lemma 17, each vertex w ∈ S is able to determine the type of S. If S is of type-1, w knows the vertex u ∈ VH such that S ∈ C(u); if S is of type-2, w knows the two vertices u, v ∈ VH such that S ∈ C(u, v). C(u, v) > 0}, and we know that E(GH ) = O(√n) from Lemma 10. Lemma 18. Suppose that each vertex in each type-2 component S already knows (i) the list of vertices in S, and (ii) the topology of the subgraph G[S]. Then, in O(n1.5) time and O(√n) energy, all vertices in the graph can learn the set of all pairs {u, v} ∈ E(GH ). Proof. First of all, we let all vertices in VH agree on a fixed ordering VH = {v1, . . . , vH} as follows. We use Lemma 1 to compute a good labeling (on the entire graph) with one root vertex r. Then, we invoke Lemma 2(2) (with x = √n) to let each vertex v ∈ VH broadcast ID(v). Then we order VH = {v1, . . . , vH} by increasing ordering of ID. This step takes O(n1.5) time and O(√n) energy. Next, we show how to let each u ∈ VH learn the list of all v ∈ VH such that C(u, v) 6= ∅ via VH invocations of SR-comm. Given a type-2 component S ∈ C(u, v), define zu,S as the smallest ID vertex in N (v) ∩ S. The vertex zu,S will be responsible for letting v to know that C(u, v) 6= ∅. For i = 1 to VH, we do an SR-comm with S being the set of all vertices that are zvi,S for some type-2 component S (with vi ∈ G[S]), and R being the set of all vertices in VH . Note that a vertex u ∈ VH receives a message during the ith iteration if and only if C(u, vi) 6= ∅, i.e., {u, vi} ∈ E(GH ). This step takes VH· O(1) = O(√n) time. At this moment, each u ∈ VH knows the list of all v ∈ VH such that C(u, v) 6= ∅. Lastly, we apply Lemma 2(2) (with x = √n) to let each vertex u ∈ VH broadcast this information to all vertices. This step takes O(n1.5) time and O(√n) energy. Lemma 19. In O(n1.5) time and O(√n) energy, we can let each u ∈ V learn I0(u). Proof. This follows from Lemma 17 and Lemma 18. Next, we consider the task of learning I1(u) and I2(u). Each u ∈ VH needs to learn 3 parameters in I1(u) and O(√n) parameters in I2(u). Recall that for each u ∈ VH , the number of pairs {u, v} such that F ⋆({u, v}) = u is at most O(1). For each u ∈ VH , and for each type-1 component S ∈ C(u) or type-2 component S ∈ C(u, v) (for some v such that F ⋆({u, v}) = u), we let rS,u be the smallest ID vertex in the set S ∩ N (u). Intuitively, rS,u will be the one responsible of communicating with u about information associated with S. 13 A Generic Approach for Learning a Parameter in I1(u) and I2(u). We present a generic approach that lets a vertex u ∈ VH learn one parameter in I1(u) and I2(u). The cost of learning one parameter is O(1) time and energy for all vertices that are involved. For example, if we apply this approach to let u learn R[u, v], then the only vertices that are involved are u itself and rS,u for all S ∈ C(u, v). We only describe how to let each u ∈ VH learn A1[u] and A2[u]; the rest are similar. Learning A1[u]. Recall that A1[u] is a component S′ ∈ C(u) that maximizes eccentricity(u, S′). To learn A1[u], we use SR-commmax with S = {rS,u S ∈ C(u)} and R = {u}. The message of the vertex v = rS,u is mv = topology of G[S], and the key is kv = eccentricity(u, S). Since each type-1 and type-2 component satisfies S ≤ √n, the maximum possible value of eccentricity(u, S) is √n, and so the size of the key space for SR-commmax is K = √n. If C(u) > 0, the message that u receives from SR-commmax is the topology of G[S′], for a component S′ ∈ C(u) that attains the maximum value of eccentricity(u, S′) among all components in C(u), and so u sets A1[u] = S′. If C(u) = 0, the vertex u receives nothing from SR-commmax, and so u sets A1[u] = ∅. The cost of SR-commmax is O(log K log ∆ log n) = O(1). Learning A2[u]. The procedure for learning A2[u] is almost exactly the same as that for A1[u], with only one difference. Recall that A2[u] is a component S′ ∈ C(u)\ {A1[u]} that maximizes eccentricity(u, S′), and so we need to exclude the component A1[u] from participating. To do so, before we apply SR-commmax, we use one round to let u send ID(rA1[u],u) to all vertices {rS,u S ∈ C(u)}. This allows each rS,u to know whether or not S = A1[u]. Lemma 20. Suppose that each v ∈ V already knows I0(v). In O(n1.5) time and O(√n) energy we can let each vertex u ∈ VH learn I1(u) and I2(u). Proof. The total number of parameters needed to be learned in I1(u) and I2(u) over all u ∈ VH is at most E(GH ) · O(√n) = O(n). We fix any ordering of these parameters, and learn each of these parameters one by one using the above generic approach. The time and energy cost of learning one parameter is O(1). Since there are O(n) parameters to learn, the total time complexity is O(n)· O(1) = O(n). Each vertex is involved in learning at most O(√n) parameters, and so the total energy complexity is O(√n) · O(1) = O(√n). Combining Lemma 11, Lemma 15, Lemma 19, and Lemma 20, we conclude the proof of Theorem 6. 3.4 Lower Bound In this section, we prove Theorem 7. The proof is based on a reduction from the set-disjointness problem of communication complexity, which is defined as follows. Consider two players A and B, each of them holds a subset of {0, . . . , n}, and their task is to decide whether their subsets are disjoint. If the maximum allowed failure probability is f < 1/2, then they need to communicate Ω(n) bits [6]. This is true even if the two players have access to an infinite amount of public random bits. At a high level, our approach is similar to that of [1], which shows that computing diameter takes B log n(cid:17) time in the message-passing model Ω(n/ log2 n) time in the CONGEST model, or more generally Ω(cid:16) n with B-bit message size constraint. Note that a time lower bound in CONGEST does not in general transform to an energy lower bound in the wireless network model, if we make no message size constraint. The main challenge for proving Theorem 7 is that we allow messages of unbounded length. Lower Bound Graph Construction. Let SA = {a1, . . . , aα} and SB = {b1, . . . , bβ} be two subsets of {0, . . . , k} corresponding to an instance of set-disjointness problem. We assume that k = 2ℓ, for some positive integer ℓ, and so each element s ∈ SA ∪ SB is represented as a binary string of length ℓ = log k. We write Ones(s) ⊆ [ℓ] = {1, . . . , ℓ} to denote the set of indices i in [ℓ] such that s[i] = 1 (i.e., the ith bit of s is 1); similarly, Zeros(s) = [ℓ] \ Ones(s) is the set of indices i in [ℓ] such that s[i] = 0. For example, if the binary representation of s is 10110010 (ℓ = 8), then Ones(s) = {1, 3, 4, 7} and Zeros(s) = {2, 5, 6, 8}. Define the graph G = (V, E) as follows. The graph G has at most n = 2(k + 1) + 2 log k + 2 vertices, and the arboricity of G is O(log k) = O(log n). 14 Vertex Set. Define V = VA ∪ VB ∪ VC ∪ VD ∪ {u⋆, v⋆}, where VA = {u1, . . . , uα}, VB = {v1, . . . , vβ}, VC = {w1, . . . , wℓ}, and VD = {x1, . . . , xℓ}. Note that we have natural 1-1 correspondences VA ↔ SA, VB ↔ SB, VC ↔ [ℓ], and VD ↔ [ℓ]. Edge Set. The edge set E is constructed as follows. Initially E = ∅. For each vertex ui ∈ VA and each wj ∈ VC , add {ui, wj} to E if j ∈ Ones(ai). For each vertex ui ∈ VA and each xj ∈ VD, add {ui, xj} to E if j ∈ Zeros(ai). For each vertex vi ∈ VB and each wj ∈ VC , add {vi, wj} to E if j ∈ Zeros(bi). For each vertex vi ∈ VB and each xj ∈ VD, add {vi, xj} to E if j ∈ Ones(bi). Add an edge between u⋆ to all vertices in VA ∪ VC ∪ VD. Add an edge between v⋆ to all vertices in VB ∪ VC ∪ VD. A crucial observation is that if SA ∩ SB = ∅ (a yes-instance for the set-disjointness problem), then the diameter of G is 2; otherwise (a no-instance for the set-disjointness problem) the diameter of G is 3. This can be seen as follows. First of all, observe that we must have dist(s, t) ≤ 2, unless s ∈ VA and t ∈ VB (or s ∈ VB and t ∈ VA). Now suppose s = ui ∈ VA and t = vj ∈ VB. • Consider the case ai 6= bj. We show that dist(s, t) = 2. Note that there is an index l ∈ [ℓ] such that ai and bj differ at the lth bit. If the lth bit of ai is 0 and the lth bit of bj is 1, then (ui, xl, vj) is a length-2 path between s and t. If the lth bit of ai is 1 and the lth bit of bj is 0, then (ui, wl, vj) is a length-2 path between s and t. • Consider the case ai = bj. We show that dist(s, t) = 3. Note that there is no index l ∈ [ℓ] such that ai and bj differ at the lth bit. Thus, each wl ∈ VC and xl ∈ VD is adjacent to exactly one of {ui, vj}. Hence there is no length-2 path between s and t. Therefore, if SA ∩ SB = ∅, then dist(s, t) = 2 for all pairs {s, t}, and so the diameter is 2; otherwise, there exist s = ui ∈ VA and t = vj ∈ VB such that dist(s, t) = 3, and so the diameter is 3. Reduction. Suppose that there is a randomized distributed algorithm A that is able to compute the diameter with o(n/ log2 n) energy in CD or No-CD models, with failure probability f = 1/poly(n). We show that the algorithm A can be transformed into a randomized communication protocol that solves the set- disjointness problem with o(n) bits of communication, and with the same failure probability f = 1/poly(n). The main challenge in the reduction is that we do not impose any message size constraint. To deal with this issue, our strategy is to consider a modified computation model M′. We will endow the vertices in the modified computation model M′ with strictly more capabilities than the original wireless network model. Then, we argue that in the setting of M′, we can assume that each message has size O(log k). Modified Computation Model M′. We add the following extra powers to the vertices: (P1) All random bits used in all vertices are known to everyone at the beginning of the algorithm. That is, they have shared randomness, and they know the list of the IDs of all vertices. We assume that ID(wi) = i for each wi ∈ VC ; ID(xi) = ℓ + i for each xi ∈ VD; ID(u⋆) = 2ℓ + 1; ID(v⋆) = 2ℓ + 2. Thus, for each v ∈ VC ∪ VD ∪ {u⋆, v⋆}, its role can be inferred from ID(v). (P2) All messages successfully received by vertices in VC ∪ VD ∪ {u⋆, v⋆} are also delivered to all vertices. For example, if v ∈ VC ∪ VD ∪ {u⋆, v⋆} receives a message m from a vertex u ∈ V at time t, then by the end of time t all vertices in V know that "v receives m from u at time t". (P3) Each vertex v ∈ VA ∪ VB knows the list of the IDs of its neighbors initially. Next, we discuss the consequences of these extra powers. following assumptions about algorithms in this modified model M′. In particular, we show that we can make the 15 Vertices in VC ∪ VD ∪ {u⋆, v⋆} never transmit. The above (P1) and (P2) together imply that each vertex in the graph is able to locally simulate the actions of all vertices in VC ∪ VD ∪ {u⋆, v⋆} in each round. Intuitively, this means that all vertices in VC ∪ VD ∪ {u⋆, v⋆} do not need to transmit at all throughout the algorithm. Note that each vertex v ∈ V already knows the list of N (v) ∩ (VC ∪ VD ∪ {u⋆, v⋆}). If v ∈ VA ∪ VB, then v knows this information via (P3). If v ∈ VC ∪ VD ∪ {u⋆, v⋆}, then v knows this information via (P1); the role of each vertex in VC ∪ VD ∪ {u⋆, v⋆} can be inferred from its ID, which is a public to everyone. Thus, right before the beginning of each time t, each vertex v ∈ V already knows exactly which vertices in N (v) ∩ (VC ∪ VD ∪ {u⋆, v⋆}) will transmit at time t and their messages. Thus, in the modified model M′, we can simulate the execution of an algorithm which allows the vertices in VC ∪ VD ∪ {u⋆, v⋆} to transmit by another algorithm that forbid them to do so. Messages Sent by Vertices in VA ∪ VB Have Length O(log k). Next, we argue that we can assume that each message m sent by a vertex v′ ∈ VA ∪ VB can be replaced by another message m′ which contains only the list of all neighbors of v′, and this can be encoded as an O(log k)-bit message, as follows. Recall that N (v′) is a subset of VC ∪ VD ∪ {u⋆, v⋆}, and so we can encode N (v′) as a binary string of length VC ∪ VD ∪ {u⋆, v⋆} = 2ℓ + 2 = O(log k). The message m is a function of all information that v′ has. Since no vertex in VC ∪VD∪{u⋆, v⋆} transmits any message, v′ never receive a message, and so the information that v′ has consists of only the following components. • The shared randomness and the ID list of all vertices (due to (P1)). • The history of vertices in VC ∪ VD ∪ {u⋆, v⋆} (due to (P2)). • The list of neighbors of v′ (due to (P3)). The only private information that v′ has is its list of neighbors. If a vertex u′ ∈ V knows the list of neighbors of v′, then u′ is able to calculate m locally, and so v′ can just send its list of neighbors, and not send m. Algorithm A′. To sum up, given the algorithm A (in a wireless network model, CD or No-CD), we can transform it into another algorithm A′ in the modified computation model M′ that uses only O(log k)-bit messages, and A′ achieves what A does. Note that the energy cost of A′ is at most the energy cost A. Solving Set-Disjointness. Now we show how to transform A′ into a protocol for the set-disjointness problem using only o(k) bits of communication. The protocol for the set-disjointness problem is simply a simulation of A′. The shared random bits used in A′ are based on the public random bits available to the two players A and B. Each player X ∈ {A, B} is responsible for simulating vertices in VX . In view of above, vertices in VA and VB never receive messages, and so all we need to do is to let both players A and B know the messages sent to VC ∪ VD ∪ {u⋆, v⋆} (in view of (P2)). We show how to simulate one round τ of A′. We write Z(τ ) to denote the subset of vertices in VC ∪ VD ∪ {u⋆, v⋆} that listens at time τ . Recall that everyone can predict the action of every vertex in VC∪VD∪{u⋆, v⋆}. Consider a vertex u′ ∈ Z(τ ) that listens at time τ . Let QA be the number of vertices in N (u′) ∩ VA transmitting at time τ . We define mu′,τ,A as follows. mu′,τ,A = "0" "≥ 2" (v′, m′)   if QA = 0. if QA ≥ 2. if QA = 1, and v′ is the vertex in N (u′) ∩ VA sending (m′) at time τ . We define mu′,τ,B analogously. Note that the size of m′ must be O(log k). The protocol for simulating round τ is simply that A sends mu′,τ,A (for each u′ ∈ Z(τ )) to B, and B sends mu′,τ,B (for each u′ ∈ Z(τ )) to A. This offers enough information for both player to know the channel feedback (noise, silence, or a message m) received by each vertex in Z(τ ). Note that the number of bits exchanged by A and B due to the simulation of round τ is O(Z(τ ) log k). 16 Recall that the energy cost of each vertex in an execution of A′ is o(k/ log2 k), and we have VC ∪ VD ∪ {u⋆, v⋆} = O(log k). Thus, the total number of bits exchanged by the two players A and B is X τ O(Z(τ ) log2 k) = VC ∪ VD ∪ {u⋆, v⋆} · o(k/ log2 k) · O(log k) = o(k). 4 Minimum Cut The generic framework introduced in Section 3 can be applied to other graph problems as well. In this section, we show how to find (i) exact global minimum cut and (ii) approximate s -- t minimum cut of a bounded-genus graph in O(√n) energy. These results are complemented with two simple hardness proofs: It takes Ω(n) energy for any algorithm to find an exact solution of either (i) an s -- t minimum cut (for planar graphs), or (ii) a global minimum cut (for unit disc graphs). 4.1 Upper Bounds In this section we prove the upper bounds. Both upper bounds follow the same framework introduced in Section 3 via graph partition. That is, we decompose the vertices into VH and VL, and we categorize the connected components induced by VL into three types. The only difference is that since we deal with different graph problems, here we need to let the vertices learn different parameters from type-1 and type-2 components. That is, we need to define I1(u) and I2(u) differently. In subsequent discussion, we will mostly focus on describing the parameters that we need, and how they provide enough information to solve the underlying graph problems. The algorithmic details about finding these parameters can be done using the generic approach introduced in Section 3 via applications of SR-comm and its variants. For a cut C = (X, V \ X), the two vertex sets X 6= ∅ and V \ X 6= ∅ are called the two parts of C; the cut edges of C are defined as {{u, v} u ∈ X, v ∈ V \ X}. The value of C, which we denote as C, is the number of cut edges. A minimum cut of a graph is a cut C the minimizes C over all possible cuts. An s -- t minimum cut of a graph is a cut C the minimizes C over all possible cuts subject to the constraint that s and t belong to different parts. We define the following notations. c(S): For a type-1 component S, let c(S) be the minimum cut value of G[S]. c′(S): For a type-2 component S ∈ C(u, v), let c′(S) be the u -- v minimum cut value of G[S]. c′′(S): For a type-2 component S ∈ C(u, v), let c′′(S) be the minimum cut value of G[S] among all cuts such that both u and v are within one part. Lemma 21. Let C = (X, V \ X) be any minimum cut of G. Then the following is true. • For a vertex u ∈ VH , either (i) one part of the cut contains all vertices in SS∈C(u) S ∪ {u}, or (ii) the value of the cut is minS∈C(u) c(S). • For two distinct vertices u, v ∈ VH , either (i) one part of the cut contains all vertices in SS∈C(u,v) S ∪ {u, v}, or (ii) the value of the cut is minS∈C(u,v) c′′(S), or (iii) u and v are within different parts of the cut, and the number of cut edges that have at least one endpoint in SS∈C(u,v) S′ is PS∈C(u,v) c′(S). Proof. Consider the first statement. Suppose that (i) is not met. Then there exists a component S ∈ C(u) such that S ∪{u} is not entirely within one part of the cut. Then C′ = (X ∩ (S ∪{u}), (V \ X)∩ (S ∪{u})) is a cut of G[S], and we must have c(S) ≤ C′ ≤ C. Since C is a minimum cut of G, we have minS∈C[u] c(S) = c(S) = C. Consider the second statement. Suppose that (i) is not met. We first consider the case where u and v are in one part of the cut. Then there exists a component S ∈ C(u, v) such that S ∪ {u, v} is not entirely contained in one part of the cut. Then C′ = (X ∩ (S ∪ {u, v}), (V \ X) ∩ (S ∪ {u, v})) is a cut of G[S] where u and v are within one part. We must have c′′(S) ≤ C′ ≤ C. Since C is a minimum cut of G, we have minS∈C(u,v) c′′(S) = c′′(S) = C. Next, consider the case where u and v are in different parts of the cut. For each S ∈ C(u, v), we write ZS to denote the number of cut edges of C that have at least one endpoint in S. Then we must have 17 ZS = c′(S) (otherwise C is not a minimum cut). Thus, the number cut edges hat have at least one endpoint in SS∈C(u,v) S is PS∈C(u,v) c′(S). Theorem 22. There is a randomized algorithm for computing the exact global minimum cut value in O(n1.5) time and O(√n) energy for bounded-genus graphs. Proof. Since bounded-genus graphs have bounded arboricity, there is a constant k⋆ such that the minimum cut value of G is at most k⋆. We define the graph G⋆ as the result of applying the following operations. First, we remove all type-1 components. Then, for each pair {u, v} of distinct vertices in VH with C(u, v) > 0, replace C(u, v) by an edge with weight min{k⋆,PS∈C(u,v) c′(S)}. In view of Lemma 21, the minimum cut value of G is the minimum over the following numbers: • The minimum over all minS∈C(u) c(S) (for all u ∈ VH such that C(u) > 0). • The minimum over all minS∈C(u,v) c′′(S) (for all u, v ∈ VH such that C(u, v) > 0). • The minimum cut value of G⋆. For each u ∈ VH , let I1(u) contain the parameter minS∈C(u) c(S), and let I2(u) contain the two parameters minS∈C(u,v) c′′(S) and min{k⋆,PS∈C(u,v) c′(S)} for each pair {u, v} ∈ E(GH ) with F ⋆({u, v}) = u. The definition of I0(u) is the same as that in Section 3. We use the algorithms for Lemma 19 and Lemma 20 to let each vertex u ∈ V learn the information I0(u), I1(u), and I2(u). Note that the exact value of the parameter min{k⋆,PS∈C(u,v) c′(S)} can be learned by applying the generic approach of learning parameters described in Section 3, using SR-commapx with ǫ = 1/(k⋆ + 1) and W = k⋆. More specifically, during SR-commapx, we let the message of the representative of S be min{k⋆, c′(S)}. The minimum cut value of G can be calculated from the following information: (i) I1(u) and I2(u) for each u ∈ VH , (ii) the topology of G[S] for each type-3 component S, and (iii) the topology of the subgraph induced by VH . Using the algorithm of Lemma 15, we can let everyone learn this information in O(n1.5) time and O(√n) energy. Theorem 23. There is a randomized algorithm for computing an (1 ± ǫ)-approximate s -- t minimum cut value in O(n1.5) · poly(1/ǫ) time and O(√n) · poly(1/ǫ) energy for bounded-genus graphs. Proof. The proof is similar to that of Lemma 22. The main differences are the following. If s or t happens to be within a type-1 or a type-2 component S, then we additionally need to learn the topology of G[S]. Any type-1 component that does not contain s or t is irrelevant to the s -- t minimum cut value. For each x ∈ {s, t}, let Sx be the type-1 or type-2 component containing x; if x is not contained in any type-1 or type-2 component, then we let Sx = ∅. Define G⋆ as the result of the following operations. Remove all type-1 components except Ss and St. For each pair {u, v} of distinct vertices in VH with C(u, v) \ c′(S). {Ss, St} > 0, replace all components in C(u, v) \ {Ss, St} by an edge with weight PS∈C(u,v)\{Ss,St} It is straightforward to see that the minimum s -- t cut value in G⋆ is the same as the minimum s -- t cut value of G (via a proof similar to that of Lemma 21, detail is omitted). If the edge weights of G⋆ are off by a factor of at most 1 ± ǫ, then the minimum s -- t cut value in G⋆ is an (1 ± ǫ)-approximation of the minimum s -- t cut value of G. In view of the above, for each u ∈ VH , let I1(u) = ∅, and let I2(u) contain the parameter PS∈C(u,v) c′(S) for each pair {u, v} ∈ E(GH ) with F ⋆({u, v}) = u. To calculate the minimum s -- t cut value of G, it suffices to learn the parameters in I2(u) within an approximation factor of at most 1 ± ǫ, and this can be done by applying the generic approach of learning parameters described in Section 3, with SR-commapx. The rest of the proof is the same as that of Lemma 22. 4.2 Lower Bounds We first show that the randomized energy complexity of computing s -- t minimum cut is Ω(n) in both CD and No-CD, even for planar graphs. The lower bound graph is a complete bipartite graph K2,∆, with the vertex partition {s, t} and {v1, . . . , v∆}. It is clear that the exact s -- t minimum cut is ∆. We show that it takes Ω(n) energy for the graph to learn the exact value of ∆. 18 Theorem 24. The randomized energy complexity of computing exact s -- t minimum cut value is Ω(n) in both CD and No-CD. This is true even for complete bipartite graphs K2,∆. Proof. Let G be a complete bipartite graph with the vertex partition {s, t} and {v1, . . . , v∆}. Let G′ be G − v∆. It is clear that the s -- t minimum cut of G is ∆, and the s -- t minimum cut of G′ is ∆ − 1. In such graphs, the value of s -- t minimum cut is identical to deg(s). Let E = ∆/5. Suppose that there is a randomized algorithm A that is able to let the vertex s compute the s -- t minimum cut with (at most) E energy, then A is also able to let s distinguish between G and G′ with E energy. Consider an execution of A on G. Let S be the subset of {v1, . . . , v∆} such that vi ∈ S if there is a time slot τ where (i) vi transmits, (ii) the number of vertices in {v1, . . . , v∆} that transmit is at most 2, and (iii) at least one of s and t listens. We claim that S ≤ 4E = 4∆/5. Let T be the set of all time slots τ such that the above (i), (ii), and (iii) hold for at least one vi ∈ {v1, . . . , v∆}. Then we must have T ≥ S/2 (in view of (ii)). Note that if τ ∈ T , then at least one of s and t must listen at time τ . Thus, the energy cost of one of s and t must be at least T/2 ≥ S/4, and so we have the inequality E ≥ S/4. Let E be the event that v∆ /∈ S if we execute A on G. Note that whether or not E occurs depends only on the random bits associated with the vertices {s, t} and {v1, . . . , v∆}. Since S ≤ 4∆/5, we have Pr[E] ≥ (∆/5)/∆ = 1/5 Suppose that all vertices in {s, t} and {v1, . . . , v∆} have decided their random bits in advance; and then with probability 1/2 we run A on G; with probability 1/2 we run A on G′. Note that if E occurs, then the execution of A on both G and G′ gives identical results for all vertices (other than v∆). Therefore, given that the event E occurs, the probability that the vertex s correctly decide whether the underlying graph is G or G′ is at most 1/2 (i.e., s can only guess randomly). Since Pr[E] ≥ 1/5, the probability that the vertex s fails to correctly decide whether the underlying graph is G or G′ is at least (1/2) · (1/5) = 1/10, and so s fails to correctly calculate the s -- t minimum cut with probability at least 1/10. This contradicts the assumption that A is able to compute the s -- t minimum cut with high probability. For graphs of maximum degree ∆, the above proof gives us an Ω(∆) energy lower bound. It is important that we consider bipartite graphs. If the middle ∆ vertices form a clique, then the lower bound fails, as there exist an energy efficient algorithm for every vertices in a clique to broadcast a message. For example, consider an n-vertex single-hop network, where each vertex has a unique ID within [N ]; we assume N is known to everyone, but n ≤ N is unknown. There is a simple folklore O(log N )-energy deterministic algorithm [8, Section 4.2] that allows each vertex to broadcast a message to everyone. Next, we consider the task of finding an exact global minimum cut. The lower bound graphs in the proof are Kn and Kn − e. Note that these graphs are unit disc graphs. Theorem 25. The randomized energy complexity of computing an exact global minimum cut value is Ω(n) in both CD and No-CD. This is true even if the underlying graph is either (i) an n-vertex complete graph Kn, or (ii) an n-vertex complete graph minus one edge Kn − e. Proof. Throughout the proof, we consider the scenario where the underlying graph is Kn with probability 1/2, and is Kn−e with probability 1/2. The edge e is chosen uniformly at random. Let A be any randomized algorithm that solves the minimum cut problem using at most E = (n− 1)/8 energy. Note that the minimum cut of Kn is n − 1; and the minimum cut of Kn − e is n − 2, and so A is able to distinguish between Kn and Kn − e. We make the following assumptions which only increase the capability of the vertices. • Each vertex has a distinct ID from [n]. • All vertices have access to shared random bits. • By the end of each time slot t, each vertex knows the following information: (i) the IDs of the vertices transmitting at time t, (ii) the IDs of the vertices listening at time t, and (iii) the channel feedback (i.e., noise, silence, or a message m) for each listening vertex. 19 With the above extra capabilities, all vertices share the same history. Since the actions of the vertices at time t + 1 depend only on the shared history of all vertices and their shared random bits, by the end of time t all vertices are able to predict the actions (i.e., transmit a message m, listen, or idle) of all vertices at time t + 1. We say that time t is good for a pair {u, v} if the following conditions are met. Intuitively, if t is not good for {u, v}, then what happens at time t does not reveal any information as to whether {u, v} is an edge. • The number of transmitting vertices at time t is either 1 or 2, • One of the two vertices {u, v} listens at time t, and the other one transmits at time t. Given the shared random bits for all vertices, define Xbad as the set of pairs {u, v} such that there is no time t that is good for {u, v} in an execution of A on Kn; and define Xgood as the set of all remaining pairs. Note that Xbad and Xgood are determined solely by the shared random bits. We claim that Pr[{u, v} ∈ Xbad] ≥ 1/2, for each pair {u, v}. Recall that if a time t is good for some pair, then the number of transmitting vertices is at most 2. Thus, if t is good for x pairs, then at least x/2 vertices listen at time t, and so the summation of energy spent in all vertices in all time is at least Xgood/2, and so nE = n(n − 1)/8 ≥ Xgood/2, which implies Xbad ≥ n(n − 1)/4. Hence Pr[{u, v} ∈ Xbad] ≥ 1/2. Let E be the event e ∈ Xbad. Note that E depends only on (i) the random bits for choosing e, and (ii) the shared random bits for all vertices. Given that E occurs, the execution of A is identical on both Kn and Kn − e, and so the success probability of A is at most 1/2. Thus, A fails with probability at least (1/2) Pr[E] ≥ 1/4. This contradicts the assumption that A is able to compute the minimum cut with high probability. 5 Conclusion We have shown that for a variety of graph problems, the energy complexity O(√n) can be achieved. A good future work topic is to further investigate the landscape of energy complexity of fundamental graph problems. In particular, can we prove a lower bound for BFS that is higher than the known lower bounds for broadcasting? Another potential future work direction is to study graph classes that are more realistic, such as unit disc graphs. It is worth noted that several known energy lower bounds techniques rely on the bipartite graph structure, such as Theorem 7, Theorem 24, and some lower bounds for broadcasting in [7]; all these lower bounds do not apply to unit disc graphs. Acknowledgements. The author thanks Seth Pettie for helpful discussions and comments. References [1] A. Abboud, K. Censor-Hillel, and S. Khoury. Near-linear lower bounds for distributed distance compu- tations, even in sparse networks. In Cyril Gavoille and David Ilcinkas, editors, Distributed Computing (DISC), pages 29 -- 42. Springer Berlin Heidelberg, 2016. [2] C. Ambühl. An optimal bound for the MST algorithm to compute energy efficient broadcast trees in wireless networks. In L. Caires, G. F. Italiano, L. Monteiro, C. Palamidessi, and M. Yung, editors, Automata, Languages and Programming (ICALP), pages 1139 -- 1150. Springer Berlin Heidelberg, 2005. [3] R. Bar-Yehuda, O. Goldreich, and A. Itai. On the time-complexity of broadcast in multi-hop radio networks: An exponential gap between determinism and randomization. Journal of Computer and System Sciences, 45(1):104 -- 126, 1992. [4] M. A. Bender, T. Kopelowitz, S. Pettie, and M. Young. Contention resolution with log-logstar channel accesses. In Proceedings of the 48th Annual ACM Symposium on Theory of Computing (STOC), pages 499 -- 508, 2016. 20 [5] P. Berenbrink, Z. Hu, and C. Cooper. Energy efficient randomised communication in unknown adhoc networks. In Proceedings of the 19th Annual ACM Symposium on Parallel Algorithms and Architectures (SPAA), pages 250 -- 259, New York, NY, USA, 2007. ACM. [6] M. Braverman and A. Moitra. An information complexity approach to extended formulations. In Proceedings of the 45th Annual ACM Symposium on Theory of Computing (STOC), pages 161 -- 170, New York, NY, USA, 2013. ACM. [7] Y.-J. Chang, V. Dani, T. P. Hayes, Q. He, W. Li, and S. Pettie. The energy complexity of broadcast. In Proceedings of the 2018 ACM Symposium on Principles of Distributed Computing (PODC), 2018. [8] Y.-J. Chang, T. Kopelowitz, S. Pettie, R. Wang, and W. Zhan. Exponential separations in the energy complexity of leader election. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing (STOC), pages 771 -- 783, 2017. [9] A. E. F. Clementi, P. Crescenzi, P. Penna, G. Rossi, and P. Vocca. On the complexity of computing minimum energy consumption broadcast subgraphs. In Proceedings of the 18th Annual Symposium on Theoretical Aspects of Computer Science (STACS), pages 121 -- 131, London, UK, UK, 2001. Springer- Verlag. [10] M. Elkin. Distributed exact shortest paths in sublinear time. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing (STOC), pages 757 -- 770, New York, NY, USA, 2017. ACM. [11] A. Ephremides and T. V. Truong. Scheduling broadcasts in multihop radio networks. IEEE Transactions on Communications, 38(4):456 -- 460, Apr 1990. [12] M. Ghaffari. Near-optimal scheduling of distributed algorithms. In Proceedings of the 2015 ACM Symposium on Principles of Distributed Computing (PODC), pages 3 -- 12, New York, NY, USA, 2015. ACM. [13] M. Ghaffari and B. Haeupler. Distributed Algorithms for Planar Networks II: Low-Congestion Shortcuts, MST, and Min-Cut, pages 202 -- 219. 2016. [14] M. Ghaffari and J. Li. Improved distributed algorithms for exact shortest paths. In Proceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing (STOC), 2018. [15] L. Gsieniec, E. Kantor, D. R. Kowalski, D. Peleg, and C. Su. Energy and time efficient broadcasting in known topology radio networks. In Andrzej Pelc, editor, Distributed Computing, pages 253 -- 267, Berlin, Heidelberg, 2007. Springer Berlin Heidelberg. [16] B. Haeupler, J. Li, and G. Zuzic. Minor excluded network families admit fast distributed algorithms. In Proceedings of the 2018 ACM Symposium on Principles of Distributed Computing (PODC), 2018. [17] F. Harary. Graph theory. Addison-Wesley, Reading, MA, 1969. [18] C. C. Huang, D. Nanongkai, and T. Saranurak. Distributed exact weighted all-pairs shortest paths in O(n5/4) rounds. In IEEE 58th Annual Symposium on Foundations of Computer Science (FOCS), pages 168 -- 179, 2017. [19] T. Jurdzinski, M. Kutylowski, and J. Zatopianski. Efficient algorithms for leader election in radio networks. In Proceedings of the 21st Annual ACM Symposium on Principles of Distributed Computing (PODC), pages 51 -- 57, 2002. [20] T. Jurdzinski, M. Kutylowski, and J. Zatopianski. Energy-efficient size approximation of radio networks with no collision detection. In Proceedings of the 8th Annual International Conference on Computing and Combinatorics (COCOON), pages 279 -- 289, 2002. 21 [21] T. Jurdzinski, M. Kutylowski, and J. Zatopianski. Weak communication in radio networks. In Proceed- ings of the 8th International European Conference on Parallel Computing (Euro-Par), pages 965 -- 972, 2002. [22] T. Jurdzinski, M. Kutylowski, and J. Zatopianski. Weak communication in single-hop radio networks: adjusting algorithms to industrial standards. Concurrency and Computation: Practice and Experience, 15(11 -- 12):1117 -- 1131, 2003. [23] M. Kardas, M. Klonowski, and D. Pajak. Energy-efficient leader election protocols for single-hop radio networks. In Proceedings of the 42nd International Conference on Parallel Processing (ICPP), pages 399 -- 408, 2013. [24] L. M. Kirousis, E. Kranakis, D. Krizanc, and A. Pelc. Power consumption in packet radio networks. Theoretical Computer Science, 243(1):289 -- 305, 2000. [25] M. Klonowski and D. Pajak. Broadcast in radio networks: time vs. energy tradeoffs. CoRR, abs/1711.04149, 2017. [26] F. T. Leighton, B. M. Maggs, and S. B. Rao. Packet routing and job-shop scheduling in O(Congestion+ Dilation) steps. Combinatorica, 14(2):167 -- 186, Jun 1994. [27] N. Linial. Locality in distributed graph algorithms. SIAM J. Comput., 21(1):193 -- 201, 1992. [28] D. Peleg. Distributed Computing: A Locality-Sensitive Approach. SIAM, 2000. [29] A. Das Sarma, S. Holzer, L. Kor, A. Korman, D. Nanongkai, G. Pandurangan, D. Peleg, and R. Watten- hofer. Distributed verification and hardness of distributed approximation. SIAM Journal on Computing, 41(5):1235 -- 1265, 2012. [30] A. Sen and M. L. Huson. A new model for scheduling packet radio networks. Wirel. Netw., 3(1):71 -- 82, March 1997. [31] V. Shnayder, M. Hempstead, B.-R. Chen, G. W. Allen, and M. Welsh. Simulating the power consump- tion of large-scale sensor network applications. In Proceedings of the 2nd International Conference on Embedded Networked Sensor Systems (SenSys), pages 188 -- 200, New York, NY, USA, 2004. ACM. [32] H. Takagi and L. Kleinrock. Optimal transmission ranges for randomly distributed packet radio termi- nals. IEEE Transactions on Communications, 32(3):246 -- 257, Mar 1984. [33] J. D. Ullman and M. Yannakakis. High-probability parallel transitive-closure algorithms. SIAM Journal on Computing, 20(1):100 -- 125, 1991. A Algorithms for SR-communication In this section we present our algorithms for SR-comm and its variants. Lemma 26. SR-comm can be solved in time O(log ∆ log n) and energy O(log ∆ log n). Proof. This is a well-known result from [3]. Note that each v ∈ S ∩R is not required to receive any message from other vertices, since we already have v ∈ N +(v)∩S. Thus, in what follows, we assume that S ∩R = ∅. The algorithm is as follows. Repeat the following routine for Θ(log n) times. For i = 1 to log ∆, let each vertex u ∈ S sends with probability 2−i. Each v ∈ R is always listening throughout the procedure. Consider a vertex v ∈ R such that N (v)∩S 6= ∅. Let i⋆ be the largest integer i such that 2i ≤ 2N (v)∩S. Consider a time slot t where each vertex u ∈ S sends with probability 2−i⋆ . For notational simplicity, we write n′ = N (v) ∩ S and p′ = 2−i⋆ . Note that 1/n′ ≥ p′ ≥ 1/(2n′). The probability that exactly one vertex in the set N (v) ∩ S sends is n′p′(1 − p′)n′−1 ≥ 1/(2e). If this occurs, then v successfully receives a message mu from a vertex u ∈ N (v) ∩ S. The probability that v does not receive any message from vertices in N (v) ∩ S is at most (1 − 1/(2e))Θ(log n) = 1/poly(n). This algorithm is known as decay [3], and it has been used as a basic communication building block in various algorithms in wireless networks; see also [7]. 22 · (1/∆′) ≥ 1/(2e∆′). Lemma 27. SR-commall can be solved in time O(∆′ log n) and energy O(∆′ log n). Proof. Recall that ∆′ is an upper bound on S ∩ N (v), for each v ∈ R. The goal of SR-commall is to let each vertex in S ∩ N (v) deliver a message to v ∈ R, for each v ∈ R. Consider the algorithm which repeats the following routine for Θ(∆′ log n) rounds. In each round, each vertex u ∈ S sends mu with probability 1/∆′; for each u ∈ R, if u does not send in this round, then u listens. Let e = {u, v} be any edge with u ∈ S and v ∈ R. In one round of the above algorithm, u successfully sends a message to v if (i) all vertices in {v} ∪ (S ∩ N (v)) \ {u} do not send, and (ii) u sends. Thus occurs with probability at least (1 − 1/∆′)S∩N (v) · (1/∆′) ≥ (1 − 1/∆′)∆′ Therefore, the probability that u does not successfully send a message to v throughout the Θ(∆′ log n) rounds is at most (1 − 1/(2e∆′))Ω(∆′ log n) = 1/poly(n). Lemma 28. SR-commmulti can be solved in time O(M log ∆ log2 n) and energy O(M log ∆ log2 n). Proof. We repeat the following procedure for Θ(M log n) times. Do SR-comm with the sets (S′,R′) chosen as follows. Let R′ be a random subset of R such that each v ∈ R joins R′ with probability 1/2. Let S′ be a random subset of S \ R′ defined as follows. For each message m, all vertices in S \ R′ that hold m join S′ with probability 1/M (using the shared randomness for the message m). Before we proceed to the analysis, we clarify some possible ambiguities of the above algorithm. Note that a vertex u ∈ S \ R′ might have k ≥ 1 distinct messages, and in this case, u joins S′ with probability Pr[Binomial(k, 1/M ) ≥ 1]. That is, if the shared randomness associated with at least one message m ∈ Mu lets u to join S′, then u joins S′. Due to the shared randomness, if a vertex u joins S′ because of the shared randomness for message m, then all vertices w ∈ S \ R′ holding the message m also join S′. In what follows, we analyze the algorithm. Consider a vertex v ∈ R, and consider one iteration of the above algorithm. Let M be the set of distinct messages in Su∈N (v)∩S Mu \ Mv. Consider a message m ∈ M. Observe that v receives m if the following two events E1 and E2 occur: E1 is the event that all vertices w ∈ N (v) ∩ S′ hold the message m, and E2 is the event that v ∈ R′. The probability that E1 occurs is at least (1/2) · (1/M ) · (1 − 1/M )M−1. The probability that E2 occurs is 1/2. Thus, the probability that v receives m in one iteration is at least (1/4) · (1/M ) · (1 − 1/M )M−1 ≥ 1/(4eM ), and so the probability that v does not receive m in all iterations is at most (1−1/(4eM ))Ω(M log n) = 1/poly(n). Lemma 29. Each of SR-commmin and SR-commmax can be solved in time O(K log ∆ log n) and energy O(log K log ∆ log n). For the special case of S ∩ R = ∅ and R ∩ N (v) ≤ 1 for each v ∈ S, the runtime is reduced to O(log K log ∆ log n). Proof. We only consider SR-commmin, as the proof for SR-commmax is the same. The proof is analogous to the analysis of a deterministic version of SR-comm in [7]. Note that we can do SR-comm once to let each v ∈ R test whether or not N +(v) ∩ S 6= ∅. If a vertex v ∈ R knows that N +(v) ∩ S = ∅, then v can simply removes itself from R. Thus, in subsequent discussion, we assume N +(v) ∩ S 6= ∅ for each v ∈ R. Let v ∈ R, and we define fv = minu∈N +(v)∩S ku. The high level idea of our algorithm is to conduct a binary search to determine all log K bits of binary representation of fv. General Case. Suppose at some moment each vertex v ∈ R already knows the first x bits of fv. The following procedure allows each v ∈ R to learn the (x + 1)th bit of fv. For each (x + 1)-bit binary string s, we do SR-comm with (S′,R′), where S′ is the set of vertices u ∈ S such that ku = s, and R′ is the set of vertices v ∈ R such that the first x bits of fv equals the first x bits of s. Despite the fact that we perform 2x+1 times of SR-comm, each vertex only participates in at most 3 of them (join S′ at most once, join R′ at most twice). Thus, the procedure takes O(2x log ∆ log n) time and O(log ∆ log n) energy. O(2x log ∆ log n) = If we use the above approach to solve SR-commmin, the time complexity is Plog K−1 Note that for the last SR-comm that a vertex v ∈ R participates, the message mu that successfully sent O(K log ∆ log n); and the energy cost is Plog K−1 to v in that SR-comm must comes from a vertex u ∈ N +(v) ∩ S such that ku = fv = minw∈N +(v)∩S kw. x=0 O(log ∆ log n) = O(log K log ∆ log n). x=0 23 Special Case. Consider the special case of S ∩ R = ∅ and R ∩ N (u) ≤ 1 for each u ∈ S. For each v ∈ R, we simply let the set (S ∩ N (v)) ∪ {v} jointly conduct a binary search to determine all bits of fv = minu∈N (v)∩S ku. Note that the family of sets (S ∩ N (v)) ∪ {v} for all v ∈ R are disjoint. Suppose at some moment, for each vertex v ∈ R, all vertices in the set (S ∩ N (v)) ∪ {v} already know the first x bits of fv. We present an algorithm that allows all vertices in the set (S ∩ N (v)) ∪ {v} to learn the (x + 1)th bit of fv. Step 1. Do SR-comm with (S′,R′), where R′ = R, and S′ is the subset of S that contains vertices u ∈ S such that (i) first x bits of ku equals the first x bits of fv, where v is the unique vertex in R ∩ N (u), and (ii) the (x + 1)th bit of ku is 0. This step allows each v ∈ R to learn the (x + 1)th bit of fv. Step 2. Do SR-comm with (S′,R′), where R′ = S and S′ = R. The purpose of this SR-comm is to let each v ∈ R send the (x + 1)th bit of fv (learned in the previous step) to all vertices in S ∩ N (v). The runtime for this algorithm is asymptotically the same as the runtime of SR-comm, which is O(log ∆ log n). To determine all log K bits of binary representation of fv, for each v ∈ R, we run the above algorithm for O(log K) times, and so the total time is O(log K log ∆ log n). We need the following auxiliary lemma (note that ǫ can be either positive or negative). Lemma 30. There exist three universal constants 0 < ǫ0 < 1, N0 ≥ 1, and c0 ≥ 1 such that the following is true. For any pair of numbers (N, ǫ) such that N ≥ N0 and ǫ0 ≥ ǫ ≥ c0/√N , we have: e−1(1 − 0.51ǫ2) ≤ (1 + ǫ)(1 − (1 + ǫ)/N )N−1 ≤ e−1(1 − 0.49ǫ2). Before we present our algorithm for SR-commapx, we first consider a special case where W = 1, which corresponds to the "approximate counting" problem whose goal is to let each v ∈ R learn the number N +(v) ∩ S up to a small (1 ± ǫ)-factor error. Lemma 31. For the case of W = 1, SR-commapx can be solved in O((1/ǫ5) log ∆ log n) time and energy. Proof. In this proof we solve a slightly different task of estimating N (v) ∩ S for each v ∈ R. If each v ∈ R knows an estimate of N (v) ∩ S up to an (1 ± ǫ)-factor error, then v can locally calculate an estimate of N +(v) ∩ S with the same approximation ratio. Basic Setup: Let C be a sufficiently large constant. Let ǫ0, N0, and c0 be the constants in Lemma 30. We assume that ǫ ≤ ǫ0 (if not, then we reset ǫ = ǫ0). The algorithm consists of two phases. The algorithm for the first phase achieves the following. For each v ∈ R, either (i) v learns the number N (v) ∩ S exactly, or (ii) v detects that ǫ ≥ 10c0/pN (v) ∩ S. The algorithm for the second phase then solves SR-commapx for all remaining v ∈ R (each of them satisfies ǫ ≥ 10c0/pN (v) ∩ S). First Phase: We let Z = (10c0/ǫ)2. The algorithm consists of CZ log n rounds. In each round, each vertex u ∈ S ∪ R flips a biased coin that produces head with probability 1/Z. Each u ∈ S sends ID(u) if and only if its result is head; each vertex v ∈ R listens if and only if its result is tail. For each v ∈ R, if there is a vertex u ∈ N (v) ∩ S such that the number of messages v receive from u is less than 0.5 · (C log n)/e, then v decides that ǫ ≥ 10c0/pN (v) ∩ S (and proceed to the second phase); otherwise, we will later see that v must have learned the list of all IDs of vertices in N (v) ∩ S w.h.p. In what follows, we prove the correctness of the algorithm. Let e = {u, v} be any edge where u ∈ S and v ∈ R. In one round of the above algorithm, u successfully sends a message to v if and only if (i) the outcome of u's coin flip is head, and (ii) all vertices in (N (v) ∩ S) ∪ {v} \ {u} get tails. This occurs with probability p⋆ = (1 − 1/Z)N (v)∩S · (1/Z). Let X be the number of times v receives a message from u. To prove the correctness of the algorithm, it suffices to show the following: • If v ∈ R satisfies ǫ ≤ 10c0/pN (v) ∩ S, then Pr[X ≥ 0.8 · (C log n)/e] = 1 − n−Ω(C). • If v ∈ R satisfies ǫ ≥ 20c0/pN (v) ∩ S, then Pr[X ≤ 0.2 · (C log n)/e] = 1 − n−Ω(C). • If v ∈ R satisfies ǫ ≤ 20c0/pN (v) ∩ S, then Pr[X ≥ 1] = 1 − n−Ω(C). 24 Case 1: Suppose that the vertex v ∈ R satisfies ǫ ≤ 10c0/pN (v) ∩ S. We show that in this case the amount of messages v receive from u ∈ N (v) ∩ S is at least 0.8 · (C log n)/e, with probability 1 − n−Ω(C). In this case Z ≥ N (v) ∩ S, and also p⋆ ≥ 0.9/(eZ). The expected value of X is µ ≥ 0.9(C log n)/e. By a Chernoff bound, Pr[X ≤ 0.8 · (C log n)/e] ≤ exp(−Ω(C log n)) = n−Ω(C). Case 2: Suppose that the vertex v ∈ R satisfies ǫ ≥ 20c0/pN (v) ∩ S. We show that in this case the amount of messages v receive from u ∈ N (v) ∩ S is at most 0.2 · (C log n)/e, with probability 1 − n−Ω(C). In this case Z ≤ N (v) ∩ S/4, and also p⋆ ≤ 1.1/(e4Z). The expected value of X is µ ≤ 1.1(C log n)/e4 < 0.1(C log n)/e. By a Chernoff bound, Pr[X ≥ 0.2 · (C log n)/e] ≤ exp(−Ω(C log n)) = n−Ω(C). Case 3: Suppose that the vertex v ∈ R satisfies ǫ ≤ 20c0/pN (v) ∩ S. We show that in this case the amount of messages v receive from u ∈ N (v) ∩ S is at least 1, with probability 1 − n−Ω(C). In this case Z ≥ N (v) ∩ S/4, and also p⋆ ≥ 0.9/(e4Z). We have Pr[X < 1] ≤ (1 − 0.9/(e4Z))CZ log n = n−Ω(C). In what follows, we assume ǫ ≥ 10c0/pN (v) ∩ S for each v ∈ R. We consider the Second Phase: sequence of sending probabilities: p1 = 2/∆, and pi = max{1, pi−1 · (1 + ǫ)}. We let i⋆ = O((1/ǫ) log ∆) be the first index i such that pi = 1. The algorithm is as follows. For i = 1 to i⋆, we do the following for C log n/ǫ4 rounds. In each round, each vertex v ∈ S ∪ R flips a fair coin. If the outcome of v is head and v ∈ S, then v sends with probability pi. If the outcome of v is tail and v ∈ R, then v listens to the channel. After finishing the above procedure, each vertex v ∈ R finds an index i′ such that the number of messages v successfully received during the i′th iteration is the highest. Then v decides that the estimate of N (v) ∩ S is 2/pi′. Note that the runtime of the algorithm is O((1/ǫ5) log ∆ log n). Next, we analyze the correctness of the above algorithm. Consider a vertex v ∈ R in the ith iteration. We say that i is good for v if 2/pi is within an (1 ± 0.6ǫ)-factor of N (v) ∩ S; and we say that i is bad for v if 2/pi is not within an (1 ± ǫ)-factor of N (v) ∩ S. Note that there must be at least one good index i for each v ∈ R. to be the probability that v successfully receives a message in one round of the ith iteration. i = (1/2) · N (v) ∩ S(pi/2) · (1 − (pi/2))N (v)∩S−1. By Lemma 30, we have: It is clear that psuc psuc i ≥ pgood psuc i ≤ pbad = (1/2) · e−1(1 − 0.51(0.6ǫ)2) = (1/2) · e−1(1 − 0.49(ǫ)2) if i is good for v. if i is bad for v. def We write psuc i def Consider the ith iteration. Let X be the number of messages that v receives in the ith iteration. The following probability bounds follow by a Chernoff bound. Pr[X ≤ (1 − 0.01ǫ2)pgood · C log n/ǫ4] = exp(−Ω(ǫ4 · C log n/ǫ4)) = n−Ω(C) Pr[X ≥ (1 + 0.01ǫ2)pbad · C log n/ǫ4] = exp(−Ω(ǫ4 · C log n/ǫ4)) = n−Ω(C) if i is good for v. if i is bad for v. Since (1 − 0.01ǫ2)pgood > (1 + 0.01ǫ2)pbad, with high probability the index i′ selected by v must be good, and so the estimate calculated by v is within an (1 ± ǫ)-factor of N (v) ∩ S. Lemma 32. SR-commapx can be solved in O((1/ǫ6) log W log ∆ log n) time and energy. Proof. We let ǫ′ = Θ(ǫ) be chosen such that (1 + ǫ′)2 < 1 + ǫ and (1− ǫ′)2 > 1− ǫ. We consider the following sequence: w0 = 0, w1 = 1, and wi = min{W, (1 + ǫ′)wi−1}. Let i⋆ be the smallest index i such that wi = W . For i = 1 to i⋆, we run SR-commapx (using the algorithm of Lemma 31) with the following setting. We set S′ as the vertices u ∈ S with mu ∈ (wi−1, wi]; and the message for each v ∈ S′ is 1. We set R′ as R. The maximum allowed error for SR-commapx is ǫ′. For each v ∈ R, denote Ni as the number of vertices u ∈ N +(v) ∩ S such that mu ∈ (wi−1, wi]; and we write Ni to denote the result from the ith iteration. Note that Ni is an (1 ± ǫ′)-factor approximation of Ni, and Pi⋆ Ni (which can be i=1 Ni is an (1 ± ǫ′)-factor approximation of Pu∈N +(v)∩S calculated locally at v) is an (1 ± ǫ)-factor approximation of Pu∈N +(v)∩S number of iterations is i⋆ = O((1/ǫ) log W ). Thus, the total runtime is O((1/ǫ6) log W log ∆ log n). We calculate the cost of the algorithm. The time complexity for each iteration is O(log ∆ log n/ǫ5). The mu. Thus, Pi⋆ i=1 mu, as desired. 25
1605.08616
1
1605
2016-05-27T12:57:01
Maximum-expectation matching under recourse
[ "cs.DS" ]
This paper addresses the problem of maximizing the expected size of a matching in the case of unreliable vertices and/or edges. The assumption is that upon failure, remaining vertices that have not been matched may be subject to a new assignment. This process may be repeated a given number of times, and the objective is to end with the overall maximum number of matched vertices. The origin of this problem is in kidney exchange programs, going on in several countries, where a vertex is an incompatible patient-donor pair; the objective is to match these pairs so as to maximize the number of served patients. A new scheme is proposed for matching rearrangement in case of failure, along with a prototype algorithm for computing the optimal expectation for the number of matched vertices. Computational experiments reveal the relevance and limitations of the algorithm, in general terms and for the kidney exchange application.
cs.DS
cs
Maximum-expectation matching under recourse Joao Pedro Pedroso and Shiro Ikeda May 24, 2016 Abstract This paper addresses the problem of maximizing the expected size of a matching in the case of unreliable vertices and/or edges. The assumption is that upon failure, remaining vertices that have not been matched may be subject to a new assignment. This process may be repeated a given number of times, and the objective is to end with the overall maximum number of matched vertices. The origin of this problem is in kidney exchange programs, going on in several countries, where a vertex is an incompatible patient-donor pair; the objective is to match these pairs so as to maximize the number of served patients. A new scheme is proposed for matching rearrangement in case of failure, along with a prototype algorithm for computing the optimal expectation for the number of matched vertices. Computational experiments reveal the relevance and limitations of the algorithm, in general terms and for the kidney exchange application. 1 Introduction Algorithms for matching have recently raised interest as a research topic on a particular application: maximizing the number of transplants in kidney ex- change programs. These programs have been organized in several countries, in order to provide patients with kidney failure with an alternative to traditional treatment, in cases where they have a donor willing to provide a kidney, but the pair is not physiologically compatible (de Klerk et al., 2005; Biro et al., 2009; Saidman et al., 2006; Segev et al., 2005). These programmes are based on the concept of exchange between two patient-donor pairs: donors are allowed to provide a kidney to the other pair's patient, if compatibility exists, so that both patients benefit. Figure 1 (left) illustrates the simplest case with only two pairs, (P1, D1) and (P2, D2). Donor D1 of the first pair is allowed to give a kidney to patient P2 of the second pair, and patient P1 may get a kidney from donor D2. These graphs concern only preliminary compatibilities, which must be reassessed prior to actual transplant, by confirming the availability of the intervening persons and through additional medical exams. The situation depicted in Figure 1 may be extended to cycles with more than two vertices; typical programs may allow two to five vertices in an exchange, though smaller cycles are preferable due hospital logistics, and other reasons. The optimization problem underlying a standard kidney exchange usually con- siders maximizing the number of transplants (de Klerk et al., 2005; Segev et al., 1 D1 P1 D2 P2 1 2 1 2 Figure 1: An exchange between two incompatible pairs; arcs represent a pre- liminary assessment compatibility, and arrows define a possible exchange (left). Representation of this situation as a directed graph (center), and as a graph where an edge stands for a pair of opposite arcs between two nodes (right). 2005), though other criteria have been proposed; e.g., the overall weight assigned to each transplant (Li et al., 2014; Manlove and O'malley, 2015), and the ex- pected number of transplants for selected cycles (Pedroso, 2014) or subsets of vertices (Klimentova et al., 2016). The deterministic version of this problem, where all the elements of the graph are assumed reliable, is naturally modeled through integer optimization; a summary of models for the kidney exchange problem has been presented and analyzed by Constantino et al. (2013). Throughout this paper we will only consider the case of cycles of two vertices; in such a case, the directed graph representing an instance may be simplified, by replacing opposite arcs between two nodes by an edge, and ignoring all the other arcs. The relevant problem is maximum-weighted matching in a graph. Algorithms for finding a maximum matching in a graph have been proposed in the 1960's by Edmonds (1965a), based on some properties of maximal match- ings by Berge (1957). Maximum-weighted matching in a graph has been studied in Edmonds (1965b), who proposed an algorithm involving a formulation of the problem as a linear program, linear programming duality, and the previous algo- rithm for maximum matching. The complete algorithm is polynomial, solving the weighted matching problem in O(n4) time. An analysis of efficient algo- rithms and data structures for this problem is presented in Galil (1986). Here we study this problem under uncertainty, in a situation where vertices and/or edges may fail. This problem has been initially raised in Li et al. (2011) and Chen et al. (2012), which propose a simulation system for maximizing the expected utility when arcs are subject to failure, in dynamic version of the problem. Reconfiguration of the solution after a failure is observed has been ad- dressed in (Manlove and O'malley, 2015), where the number of effective 2-cycles is taken into account in the weights assigned to 3-cycles. Maximization of the expectation of the number of transplants, considering internal reconfiguration within a cycle's vertices, has been considered in Pedroso (2014). Reconfigura- tion involving vertices outside a cycle, in what has been called subset recourse, was considered in Klimentova et al. (2016). Here, we take a more general view: we consider that after a failure, any recourse solution may be chosen as long as it does not involve previously matched vertices. Recourse may be repeated an undetermined number of times, until the residual graph has no edges available. This is relevant in practice, as there are no natural obstacles limiting recourse to a single trial. This problem seems to be inherently intractable; we provide some examples, discuss how to specify and compute a solution, and analyze the behavior of the 2 proposed algorithm with some instances of a real-world situation where it can be applied, the kidney exchange problem. Our contributions are the following. In Section 2 we model and analyze matching with repeated recourse. An algorithm for tackling this problem is provided in Section 3, and its behavior is experimentally assessed in Section 4. We conclude with Section 5, which presents considerations on the applicability and limitations of the approach proposed. 2 Preliminaries and problem description The input to our problem is a graph G = (V, E). A matching M in G is a subset of E such that no two edges in M have a vertex in common. A maximal matching M has the property that no edge can be added to M (i.e., M is not a proper subset of any other matching in G). Vertices i ∈ V may fail with probability pi, and edges {i, j} (also denoted ij) may fail with probability pij. For the sake of simplicity, except if otherwise stated we will assume that only edges fail. In our setting, after a matching is proposed, the matched edges and vertices are observed ; a matched edge succeeds if neither the edge nor the incident ver- tices fail. If a matched edge succeeds, the incident vertices are "served" and the edge will no longer be considered. If a matched edge fails, the incident ver- tices are not served; the failure is permanent, and hence that edge is no longer considered either. The search for a posteriori attempts to serve more vertices is called recourse; it is similar to the original problem, except that is may not involve vertices that have been served already. After each observation, the graph is updated into a residual graph. Edges are eliminated at each observation as follows: • successful edges, and all edges at their endvertices, are removed; • edges that failed are removed; • edges at vertices that failed are removed. If a proposed matching is maximal and in the observation there are no failures, the residual graph will contain no edges. The objective is to find a matching such that the expectation for its car- dinality (or weight) is maximum. The basis for the efficiency of algorithms for maximum-weighted matching is that a maximum matching is also maximal. Unfortunately, this property does not hold in our context. Proposition 1. Under recourse, a maximum expectation matching may be non- maximal. Proof. By counterexample. Consider the graph C4, where the labels on edges correspond the their probability of failure. p34 3 4 p12 2 1 p23 p14 3 Assuming unitary weights on each edge, the expression of the expectation for the weight of the matching {{1, 2},{3, 4}} is the following: 4(1 − p12)(1 − p34) + 2(1 − p12)p34 + 2(1 − p34)p12 + p12p34(4(1 − p23)(1 − p14) + 2(1 − p14)p23 + 2(1 − p23)p14). The expression of the expectation for the weight of the non-maximal matching {{1, 2}} is the following: (1 − p12)(2 + 2(1 − p34)) + p12(4(1 − p23)(1 − p14) + 2p23(1 − p14) + 2p14(1 − p23) + p23p14(2(1 − p34))). The difference between the former and the latter expressions is: −2p12(1 − p14)(1 − p23)(1 − p34), which is negative or zero. Actually, if there is no limit on the number of observations allowed, there is no interest in taking matchings with more than one edge. Proposition 2. With no limit on the number of observations allowed, there is a maximum-expectation matching with one edge chosen per each observation. Proof. Any solution with more than one edge in a given step is still allowed with one edge per observation. The previous example puts in evidence that the maximum-expectation match- ing for that graph is one of {{1, 2}}, {{2, 3}}, {{3, 4}}, or {{1, 4}}. It becomes also clear that the complete specification of a solution involves the statement of the choices in the initial decision, followed by the choices at the second level (af- ter the first observation), and so on, until the set of edges in the residual graph becomes empty. In this example, it would be (assuming that the optimum is {{1, 2}}): At level 1: the matching {{1, 2}}; At level 2: • If {{1, 2}} succeeds in the observation: the matching {{3, 4}} • If {{1, 2}} fails in the observation: one must find the maximum- expectation matching in the residual graph 2 1 p23 p14 p34 3 4 This graph has four possible matchings: {{1, 4},{2, 3}} (maximal), or one of the non-maximal matchings {{1, 4}}, {{2, 3}}, or {{3, 4}}. It turns out that all of them are equivalent, with expectation p14(2 + 2p34) + (1 − p14)(2 − 2(1 − p23)(1 − p34)). For example, if at level 2 one chooses {{1, 4},{2, 3}}, then level 3 would be 4 residual graph will have no edges; -- If both {1, 4} and {2, 3} succeed in the observation, then the -- If {1, 4} succeeds and {2, 3} fails in the observation, then the -- If {1, 4} fails and {2, 3} succeeds in the observation, then the -- If both {1, 4} and {2, 3} fail in the observation, then the residual residual graph will have no edges; residual graph will have no edges; graph will be 2 3 p34 and the obvious choice at level 4 would be the matching {{3, 4}}. 1 4 The previous example shows that a complete specification of a solution in- volves predicting all the possible scenarios, and recursively finding the optimum for each of them. This problem is not in the nondeterministic polynomial time (NP) complexity class of the underlying maximum-weighted matching problem. Its recursive nature also prevents its classification in PSPACE, as for a matching with n edges one must check the 2n failure combinations; therefore, it is an intractable problem. Lemma 1. Max-expectation matching is not in EXPSPACE. Proof. As there is no advantage in choosing multiple edges simultaneously, we assume that they are chosen sequentially. The contribution of an edge to the value of the expectation of a matching is not known a priori, as it will depend on possible rearrangements with other edges. Consider a graph with m edges; in the worst case, we will need m steps for selecting a matching. For each selected edge, we must recursively check what happens if it succeeds and if it fails. Hence, in the first choice there are 2m cases to analyse; in the second choice, there are 2(m − 1) cases, and so on. The number of steps in the worst case is therefore 2mm!, which is not bounded by an exponential in m. We used the notation of Papadimitriou (1994) for complexity classes. Given this property, there is little hope of solving large instances. However, an algo- rithm for tackling this problem may still be useful for small real-world cases. Besides, limiting the number of observations allowed, as described in the next section, may allow improvements in the actual computational time required. The actual CPU time needed for solving a set of benchmark instances will be analyzed in Section 4. 2.1 Limited recourse In most situations, there is a limit in the allowed number of observations and recourse reconfigurations. We call N -recourse to a matching problem where the solution must be reached within N observations. If the limit N is zero, the problem falls back to standard matching, maximizing expectation based on failure probabilities, but without recourse; N = ∞ corresponds to the unlimited case previously described. 5 The difficulty of solving an N -recourse problem increases with N , being solvable in polynomial time for N = 0. Therefore, in terms of complexity, 0-recourse is in P (using, e.g., the algorithm proposed by Edmonds (1965a)), with complexity increasing with N , and ∞-recourse being intractable, as shown before. A practical approach to solving this problem consists of obtaining an initial solution for N = 0, and then incrementing the number of allowed observations N until the additional gain is considered acceptably low, or until the computational time becomes excessive. 3 Algorithm The basis for the method that we propose is the enumeration of all the match- ings in a graph. An interesting algorithm for enumerating all the minimum-cost perfect matchings (where the vertices in the graph are matched) has been pro- posed in Fukuda and Matsui (1992) for the case of bipartite graphs; to the best of our knowledge, there is no equivalent algorithm for more general cases. Al- gorithm 1 proposes a very simple recursive procedure for enumerating all the matchings in a graph. Algorithm 1: Algorithm for enumerating all matchings. Data: graph: • graph G = (V, E) with edges remaining for enumeration (initially, original graph); • matching m currently under construction (initially empty); • current set of matchings M (initially empty); Result:• list of all matchings in G = (V, E). 1 procedure Matchings(V, E, m, M ) 2 if E = ∅ then return M 3 4 5 6 7 8 9 10 ij ← arbitrary edge from E m(cid:48) ← m ∪ {ij} M ← M ∪ {m(cid:48)} E(cid:48) ← {ab ∈ E : {a, b} ∩ {i, j} = ∅} Matchings(V, E(cid:48), m(cid:48), M ) Matchings(V, E \ {ij}, m, M ) return M // case 1: add ij to current matching // case 2: don't add ij to current matching Determining the maximum-expectation matching involves an indirect recur- sion between the main function Solve, presented in Algorithm 2, and function EvaluateMatching, presented in Algorithm 3. The former starts by finding the connected components present in the graph; as the expectation for each of them is independent of the others, it may be computed separately. Then, each matching in a given component is evaluated with EvaluateMatching and the best of them is chosen. The evaluation of a matching involves listing all the patterns of success or failure of its edges. For each pattern, some bookkeeping is necessary for determining its probability of occurrence; this value is then multiplied by the number of edges for computing the associated contribution to the expectation. However, edges which did not fail and which were not involved with success in the current pattern (stored in variable R(cid:48)) are free for a rearrangement; this is 6 Algorithm 2: Algorithm for finding the maximum-expectation matching. Data:• instance: -- set of vertices V ; -- set of edges E; -- probabilities of failure pi for vertices i ∈ V and pij for edges ij ∈ E; • limit of observations allowed N . Result:• maximum-expectation value. 1 procedure Solve(V, E, p, N ) 2 z∗ ← 0 foreach C ∈ ConnectedComponents(V, E) do if C = 1 then continue (V (cid:48), E(cid:48)) ← subgraph induced on vertex set C z ← 0 foreach m ∈ Matchings(V (cid:48), E(cid:48)) do R ← E(cid:48) z(cid:48) ← EvaluateMatching(V (cid:48), E(cid:48), p, m, R, N ) if z(cid:48) ≥ z then 3 4 5 6 7 8 9 10 11 12 13 z ← z(cid:48) z∗ ← z∗ + z return z∗ the reason why Solve is called inside EvaluateMatching, for determining their contribution to the expectation under the current pattern. 4 Results Let us start by analyzing what differences may be expected between situations without and with recourse. Figure 2 shows the expectation for the number of matched vertices for a graph with four edges, for varying probability of failure p on edges (considered identical for all edges). The graphs considered, with four vertices, are a cycle (C4), and the complete graph (K4). With no recourse, the expectation is 4(1 − p)2 for both graphs. With recourse, we can observe a considerable improvement on graph C4, and further improvements on K4, especially for moderate probability of failure. This first result motivates for the use of recourse. 4.1 Results on general graphs This section reports results for the application of the algorithm in the worst scenario: unlimited number of observations, on possibly dense graphs. A more realistic experiment is presented in the next section. As expected, the exponen- tial growth of the time required for solving in terms of the number of edges is clearly observed in Figure 3, which plots the CPU time used as a function of the number of edges in the graph, for all graphs with up to six vertices. The points almost overlap, showing that there is virtually no influence of the number of vertices on the CPU time used; this behavior will no longer be observed in the more realistic cases of next section, where graphs are relatively sparse and have special structure. 7 Algorithm 3: Algorithm for evaluating a matching under recourse. Data:• instance: -- set of vertices V ; -- set of edges E; -- probabilities of failure for vertices pi, i ∈ V, and for egdes pij , ∀ij ∈ E. • matching m; • limit of observations allowed N . Result: • expectation considering all failure patterns. 1 procedure EvaluateMatching(V, E, p, m, R, N ) 2 if m, N was previously memoized then return TmN z ← 0 foreach b ∈ binary patterns of size m do 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 q ← 1 n ← 0 for k ← 1 to m do ij ← kth edge of matching m if bk = 0 then q ← q × pij R(cid:48) ← R \ {ij}; else q ← q × (1 − pij ) n ← n + 1 R(cid:48) ← {ab ∈ R : {a, b} ∩ {i, j} = ∅} if R(cid:48) (cid:54)= ∅ then z(cid:48) ← Solve(V, R(cid:48), p, N − 1) z ← z + q × (2n + z(cid:48)) memoize TmN ← z return z // edge ij fails in this pattern // edge ij succeeds in this pattern no recourse C4 K4 4 3.5 3 2.5 2 1.5 1 0.5 0 0 0.2 0.4 0.6 0.8 1 Figure 2: Expectation for varying probability of failure on edges. 8 Figure 3: Average CPU time required for solving instances for all graphs up to six vertices, as a function of the number of edges in the graph. Circles represent cases with no solution within 3600s. 4.2 Results on an application: kidney exchange We now turn to the usage of the algorithm proposed on its main application, i.e., in kidney exchange programs, using data provided in Constantino et al. (2013). These data's graphs have been randomly generated based on characteristics of real-world kidney exchange pools; probabilities have been randomly drawn with uniform distribution (Pedroso, 2014)1. These data are for the more general case of directed graphs G(cid:48) = (V, A), where exchanges may involve more than two pairs. Undirected graphs G = (V, E) are generated as mentioned above, with an edge {i, j} ∈ E for each 2-cycle (i, j) − (j, i) in the arc set A. For each edge {i, j} ∈ E we consider its probability of failure as pij = p(cid:48) ip(cid:48) ji, where p(cid:48) are jp(cid:48) the original probabilities for the directed graph. ijp(cid:48) Figure 4 shows the time required for solving each benchmark instance, for a number of pairs in the pool varying from 10 to 50; the actual number of vertices in the graph is typically smaller, after removing isolated vertices. Each point corresponds to a benchmark instance, representing the CPU time required for solving the it in terms of the number of vertices and edges in the graph, for a maximum number N of observations ranging from N = 0 (no recourse, top) to N = ∞ (no limit, bottom). Table 1 reports the number of successes, out of 50, for each instance size. As expected, increasing the number of allowed observations leads to a sharp raise on the CPU time required for solving an instance. Notice that when the number of observations allowed is zero, the problem can be easily solved for much larger instances with Edmonds algorithm, or even with a general-purpose mixed-integer optimization solver; as our implementation relies on enumerating all the matchings, it is inappropriate in this case. 5 Conclusions Dealing with unreliability is as issue with great importance in many applications involving optimization in graphs. In this paper we introduced a problem that 1Instances' data are available at http://www.dcc.fc.up.pt/~jpp/code/KEP. 9 Figure 4: CPU time required for solving realistic KEP instances terms of the number of vertices (left) and edges (right) in the graph, for a maximum number of observations ranging from 0 (top) to no limit (bottom). Smaller dots represent cases with no solution within 3600s. Instances N=0 N=1 N=2 N=3 N=inf 50 10 pairs 20 pairs 26 14 30 pairs 8 40 pairs 50 pairs 1 50 46 30 14 2 50 50 49 35 13 50 37 18 11 2 50 32 16 9 1 Table 1: Number of instances of each size (out of 50) successfully solved. 10 10-510-410-310-210-1100101102103104N = 0CPU used in terms of the number of verticesCPU used in terms of the number of edgesnumber of vertices10-510-410-310-210-1100101102103104N = 1number of edges10-510-410-310-210-1100101102103104N = 210-510-410-310-210-1100101102103104N = 30102030405010-510-410-310-210-1100101102103104N = inf01020304050607080Instance sizes10 pairs20 pairs30 pairs40 pairs50 pairs arises in kidney exchange programs, which are procedures that several coun- tries have made available in order to provide patients with kidney failure with an alternative to traditional treatment. In this context, failure is frequent: for example, data available show a rate of positive crossmatch (i.e., arc failure) of up to 44% (Glorie, 2012). Modeling failure has been addressed previously, though reconfiguration involving vertices outside a cycle has been dealt with only partially in Klimentova et al. (2016). Here, we extend the model to re- course solutions involving any vertex, as long as it had not been previously matched with success. Our model is based on successive observations of fail- ures on proposed matchings, and on recourse solutions being proposed on the remaining graph. The problem has been shown to be intractable, but small instance with practical relevance could be solved with our prototype implementation. Medium to large instances could not be solved with the current implementation; however, there is room for improvement, and small enhancements will have direct impact on the applicability of the method. As for the practical application of the method, one of the current limitations concerns the availability of data. Indeed, to our knowledge, currently there are no available data on probabilities, and their determination is not trivial; it will likely involve the usage of machine learning tools on related historical data, collected in running exchange programs. This implies that presently we cannot assess our model with real instances. Notice that the memory requirements of the implementation provided would make the solution process unthinkable only a few years ago. Hopefully, within some years the evolution in hardware and software will allow tackling larger instances. There are several interesting future directions for research in this field: the development of approximative algorithms for tackling this problem; considering also vertex failure, in addition to edge failure, which, even though conceptually simple, by increasing the number of possibilities on components that may fail, is a real challenge on the practical solution. Besides this extension, there are many challenges that must be overtaken for being able to solve larger instances, both on the improvement of the method and on its computational implementation. References C. Berge. Two theorems in graph theory. Proceedings of the National Academy of Sciences of the United States of America, 43(9):842, 1957. P. Biro, D. Manlove, and R. Rizzi. Maximum weight cycle packing in directed graphs, wiht application to kidney exchange programs. Discrete Mathematics, Algorithms and Applications, 1(4):499 -- 517, 2009. Y. Chen, Y. Li, J. D. Kalbfleisch, Y. Zhou, A. Leichtman, and P. X.-K. Song. Graph-based optimization algorithm and software on kidney exchanges. IEEE Trans. Biomed. Engineering, 59(7):1985 -- 1991, 2012. M. Constantino, X. Klimentova, A. Viana, and A. Rais. New insights on integer- programming models for the kidney exchange problem. European Journal of Operational Research, 231(1):57 -- 68, 2013. 11 M. de Klerk, K. Keizer, F. Claas, B. Haase-Kromwijk, and W. Weimar. The Dutch national living donor kidney exchange program. American Journal of Transplantation, 5:2302 -- 2305, 2005. J. Edmonds. Paths, trees, and flowers. Canadian Journal of Mathematics, 17 (3):449 -- 467, 1965a. J. Edmonds. Maximum matching and a polyhedron with 0, 1-vertices. J. Res. Nat. Bur. Standards B, 69(1965):125 -- 130, 1965b. K. Fukuda and T. Matsui. Finding all minimum-cost perfect matchings in bipartite graphs. Networks, 22(5):461 -- 468, 1992. Z. Galil. Efficient algorithms for finding maximum matching in graphs. ACM Comput. Surv., 18(1):23 -- 38, 1986. K. Glorie. Estimating the probability of positive crossmatch after negative virtual crossmatch. Econometric Institute report, (2012-25), 2012. X. Klimentova, J. P. Pedroso, and A. Viana. Maximising expectation of the number of transplants in kidney exchange programmes. Computers & Oper- ations Research, 2016. (Submitted to publication). Y. Li, J. Kalbfleisch, P. Song, Y. Zhou, A. Leichtman, and M. Rees. Optimiza- tion and simulation of an evolving kidney paired donation (KPD) program. Working Paper Series 90, Department of Biostatistics, University of Michigan, May 2011. http://www.bepress.com/umichbiostat/paper90. Y. Li, P. X.-K. Song, Y. Zhou, A. B. Leichtman, M. A. Rees, and J. D. Kalbfleisch. Optimal decisions for organ exchanges in a kidney paired do- nation program. Statistics in biosciences, 6(1):85 -- 104, 2014. D. F. Manlove and G. O'malley. Paired and altruistic kidney donation in the uk: Algorithms and experimentation. Journal of Experimental Algorithmics (JEA), 19:2 -- 6, 2015. C. Papadimitriou. Computational Complexity. Theoretical computer science. Addison-Wesley, 1994. ISBN 9780201530827. J. P. Pedroso. Maximizing expectation on vertex-disjoint cycle packing. In B. Murgante, S. Misra, A. M. A. Rocha, C. Torre, J. G. Rocha, M. I. Falcao, D. Taniar, B. O. Apduhan, and O. Gervasi, editors, Computational Science and Its Applications -- ICCSA 2014, volume 8580 of Lecture Notes in Com- puter Science, pages 32 -- 46. Springer International Publishing, 2014. ISBN 978-3-319-09128-0. S. Saidman, A. Roth, T. Sonmez, M. Unver, and F. Delmonico. Increasing the opportunity of live kidney donation by matching for two- and three-way exchanges. Transplantation, 81:773 -- 782, 2006. D. Segev, S. Gentry, D. Warren, B. Reeb, and R. Montgomery. Kidney paired donation and optimizing the use of live donor organs. The Journal of the American Medical Association, 293(15):1883 -- 1890, 2005. 12
1506.05981
1
1506
2015-06-19T12:54:41
On Euclid's Algorithm and Elementary Number Theory
[ "cs.DS", "cs.DM", "math.CO" ]
Algorithms can be used to prove and to discover new theorems. This paper shows how algorithmic skills in general, and the notion of invariance in particular, can be used to derive many results from Euclid's algorithm. We illustrate how to use the algorithm as a verification interface (i.e., how to verify theorems) and as a construction interface (i.e., how to investigate and derive new theorems). The theorems that we verify are well-known and most of them are included in standard number theory books. The new results concern distributivity properties of the greatest common divisor and a new algorithm for efficiently enumerating the positive rationals in two different ways. One way is known and is due to Moshe Newman. The second is new and corresponds to a deforestation of the Stern-Brocot tree of rationals. We show that both enumerations stem from the same simple algorithm. In this way, we construct a Stern-Brocot enumeration algorithm with the same time and space complexity as Newman's algorithm. A short review of the original papers by Stern and Brocot is also included.
cs.DS
cs
On Euclid's Algorithm and Elementary Number Theory Roland Backhouse, Joao F. Ferreira1 School of Computer Science, University of Nottingham, Nottingham, NG8 1BB, England Abstract Algorithms can be used to prove and to discover new theorems. This pa- per shows how algorithmic skills in general, and the notion of invariance in particular, can be used to derive many results from Euclid's algorithm. We illustrate how to use the algorithm as a verification interface (i.e., how to verify theorems) and as a construction interface (i.e., how to investigate and derive new theorems). The theorems that we verify are well-known and most of them are in- cluded in standard number-theory books. The new results concern distribu- tivity properties of the greatest common divisor and a new algorithm for efficiently enumerating the positive rationals in two different ways. One way is known and is due to Moshe Newman. The second is new and corresponds to a deforestation of the Stern-Brocot tree of rationals. We show that both enumerations stem from the same simple algorithm. In this way, we con- struct a Stern-Brocot enumeration algorithm with the same time and space complexity as Newman's algorithm. A short review of the original papers by Stern and Brocot is also included. Key words: number theory, calculational method, greatest common divisor, Euclid's algorithm, invariant, Eisenstein array, Eisenstein-Stern tree (aka Calkin-Wilf tree), Stern-Brocot tree, algorithm derivation, enumeration algorithm, rational number Email addresses: [email protected] (Roland Backhouse), [email protected] (Joao F. Ferreira) 1Funded by Funda¸cao para a Ciencia e a Tecnologia (Portugal) under grant SFRH/BD/24269/2005 Preprint submitted to Elsevier April 2, 2018 1. Introduction An algorithm is a sequence of instructions that can be systematically ex- ecuted in the solution of a given problem. Algorithms have been studied and developed since the beginning of civilisation, but, over the last 50 years, the unprecedented scale of programming problems and the consequent de- mands on precision and concision have made computer scientists hone their algorithmic problem-solving skills to a fine degree. Even so, and although much of mathematics is algorithmic in nature, the skills needed to formulate and solve algorithmic problems do not form an integral part of contemporary mathematics education; also, the teaching of computer-related topics at pre-university level focuses on enabling students to be effective users of information technology, rather than equip them with the skills to develop new applications or to solve new problems. A blatant example is the conventional treatment of Euclid's algorithm to compute the greatest common divisor (gcd) of two positive natural numbers, the oldest nontrivial algorithm that involves iteration and that has not been superseded by algebraic methods. (For a modern paraphrase of Euclid's original statement, see [1, pp. 335–336].) Most books on number theory include Euclid's algorithm, but rarely use the algorithm directly to reason about properties of numbers. Moreover, the presentation of the algorithm in such books has benefited little from the advances that have been made in our understanding of the basic principles of algorithm development. In an article such as this one, it is of course not the place to rewrite mathematics textbooks. Nevertheless, our goal in this paper is to demonstrate how a focus on algorithmic method can enrich and re-invigorate the teaching of mathematics. We use Euclid's algorithm to derive both old and well-known, and new and previously unknown, properties of the greatest common divisor and rational numbers. The leitmotiv is the notion of a loop invariant - how it can be used as a verification interface (i.e., how to verify theorems) and as a construction interface (i.e., how to investigate and derive new theorems). We begin the paper in section 2 with basic properties of the division rela- tion and the construction of Euclid's algorithm from its formal specification. In contrast to standard presentations of the algorithm, which typically as- sume the existence of the gcd operator with specific algebraic properties, our derivation gives a constructive proof of the existence of an infimum operator in the division ordering of natural numbers. The focus of section 3 is the systematic use of invariant properties of 2 Euclid's algorithm to verify known identities. Section 4, on the other hand, shows how to use the algorithm to derive new results related with the great- est common divisor: we calculate sufficient conditions for a natural-valued function2 to distribute over the greatest common divisor, and we derive an ef- ficient algorithm to enumerate the positive rational numbers in two different ways. Although the identities in section 3 are well-known, we believe that our derivations improve considerably on standard presentations. One example is the proof that the greatest common divisor of two numbers is a linear combi- nation of the numbers; by the simple device of introducing matrix arithmetic into Euclid's algorithm, it suffices to observe that matrix multiplication is associative in order to prove the theorem. This exemplifies the gains in our problem-solving skills that can be achieved by the right combination of pre- cision and concision. The introduction of matrix arithmetic at this early stage was also what enabled us to derive a previously unknown algorithm to enumerate the rationals in so-called Stern-Brocot order (see section 4), which is the primary novel result (as opposed to method) in this paper. Included in the appendix is a brief summary of the work of Stern and Brocot, the 19th century authors after whom the Stern-Brocot tree is named. It is interesting to review their work, particularly that of Brocot, because it is clearly motivated by practical, algorithmic problems. The review of Stern's paper is included in order to resolve recent misunderstandings about the origin of the Eisenstein-Stern and Stern-Brocot enumerations of the rationals. 2. Divisibility Theory Division is one of the most important concepts in number theory. This section begins with a short, basic account of the division relation. We ob- serve that division is a partial ordering on the natural numbers and pose the question whether the infimum, in the division ordering, of any pair of numbers exists. The algorithm we know as Euclid's gcd algorithm is then derived in order to give a positive (constructive) answer to this question. 2We call a function natural-valued if its range is the set of natural numbers. 3 2.1. Division Relation The division relation, here denoted by an infix "\" symbol, is the relation on integers defined to be the converse of the "is-a-multiple-of" relation3: [ m\n ≡ h∃k : k∈ZZ : n = k×mi ] . In words, an integer m divides an integer n (or n is divisible by m) if there exists some integer k such that n = k×m. In that case, we say that m is a divisor of n and that n is a multiple of m. The division relation plays a prominent role in number theory. So, we start by presenting some of its basic properties and their relation to addition and multiplication. First, it is reflexive because multiplication has a unit (i.e., m = 1×m) and it is transitive, since multiplication is associative. It is also (almost) preserved by linear combination because multiplication distributes over addition: (1) [ k\x ∧ k\y ≡ k\(x + a×y) ∧ k\y ] . (We leave the reader to verify this law; take care to note the use of the distributivity of multiplication over addition in its proof.) Reflexivity and transitivity make division a preorder on the integers. It is not anti-symmetric but the numbers equivalent under the preordering are given by [ m\n ∧ n\m ≡ abs.m = abs.n ] , 3The square so-called "everywhere" brackets are used to indicate that a boolean state- ment is "everywhere" true. That is, the statement has the value true for all instantiations of its free variables. Such statements are often called "facts", or "laws", or "theorems". When using the everywhere brackets, the domain of the free variables has to be made clear. This is particularly important here because sometimes the domain of a variable is the integers and sometimes it is the natural numbers. Usually, we rely on a convention for naming the variables, but sometimes we preface a law with a reminder of the domain. Also, we use a systematic notation for quantified expressions which has the form hL bv:range:termi. There are five components to the notation, which we explain in turn. The first component is the quantifier, in this case L. The second component is the dummy bv. The third component is the range of the dummy, a boolean-valued expression that determines a set of values of the dummy. The fourth component is the term. The final component of the notation is the angle brackets; they serve to delimit the scope of the dummy. For more details, see [2, chapter 11] and [3, chapter 8]. The symbol ≡ denotes boolean equality. In continued expressions ≡ is read associatively and = is read conjunctionally. For example, p ≡ q ≡ r is evaluated associatively -i.e. as (p ≡ q) ≡ r or p ≡ (q ≡ r), whichever is most convenient- whereas p = q = r is evaluated conjunctionally- i.e. p = q and q = r. 4 where abs is the absolute value function and the infix dot denotes function application. Each equivalence class thus consists of a natural number and its negation. If the division relation is restricted to natural numbers, division becomes anti-symmetric, since abs is the identity function on natural num- bers. This means that, restricted to the natural numbers, division is a partial order with 0 as the greatest element and 1 as the smallest element. 2.1.1. Infimum in the Division Ordering The first question that we consider is whether two arbitrary natural num- bers m and n have an infimum in the division ordering. That is, can we solve the following equation4? (2) x:: h∀k :: k\m ∧ k\n ≡ k\xi . The answer is not immediately obvious because the division ordering is par- tial. (With respect to a total ordering, the infimum of two numbers is their minimum; it is thus equal to one of them and can be easily computed by a case analysis.) If a solution to (2) exists, it is unique (because the division relation on natural numbers is reflexive and anti-symmetric). When it does have a solu- tion, we denote it by m▽n. That is, provided it can be established that (2) has a solution, (3) [ k\m ∧ k\n ≡ k \ (m▽n) ] . Because conjunction is idempotent, [ k\m ∧ k\m ≡ k\m ] . That is, m solves (2) when m and n are equal. Also, because [ k\0 ], [ k\m ∧ k\0 ≡ k\m ] . That is, m solves (2) when n is 0. So, m▽m exists as does m▽0, and both equal m: (4) [ m▽m = m▽0 = m ] . 4Unless indicated otherwise, the domain of all variables is IN, the set of natural numbers. Note that we include 0 in IN. The notation x:: E means that x is the unknown and the other free variables are parameters of the equation E. 5 Other properties that are easy to establish by exploiting the algebraic prop- erties of conjunction are, first, ▽ is symmetric (because conjunction is sym- metric) (5) [ m▽n = n▽m ] , and, second, ▽ is associative (because conjunction is associative) (6) [ (m▽n)▽p = m▽(n▽p) ] . Note that we choose infix notation for ▽, since it allows us to write m▽n▽p without having to choose between (m▽n)▽p or m▽(n▽p). The final property of ▽ that we deduce from (3) is obtained by exploiting (1), with x and y replaced by m and n, respectively : (7) [ (m + a×n)▽n = m▽n ] . 2.2. Constructing Euclid's Algorithm At this stage in our analysis, properties (5), (6) and (7) assume that equation (2) has a solution in the appropriate cases. For instance, (5) means that, if (2) has a solution for certain natural numbers m and n, it also has a solution when the values of m and n are interchanged. In view of properties (4) and (5), it remains to show that (2) has a solution when both m and n are strictly positive and unequal. We do this by providing an algorithm that computes the solution. Equation (2) does not directly suggest any algorithm, but the germ of an algorithm is suggested by observing that it is equivalent to (8) x, y:: x = y ∧ h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi . This new shape strongly suggests an algorithm that, initially, establishes the truth of h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi -which is trivially achieved by the assignment x,y := m,n- and then, reduces x and y in such a way that the property is kept invariant whilst making progress to a state satisfying x = y. When such a state is reached, we have found a solution to the equation (8), and the value of x (or y since 6 they are equal) is a solution of (2). Thus, the structure of the algorithm we are trying to develop is as follows5: { 0 < m ∧ 0 < n } x , y := m , n ; { Invariant: h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi } do x 6= y → x , y := A , B od { x = y ∧ h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi } Now we only have to define A and B in such a way that the assignment in the loop body leads to a state where x = y is satisfied while maintaining the invariant. Exploiting the transitivity of equality, the invariant is maintained by choosing A and B so that (9) h∀k:: k\x ∧ k\y ≡ k\A ∧ k\Bi . To ensure that we are making progress towards the termination condition, we have to define a bound function, which is a natural-valued function of the variables x and y that measures the size of the problem to be solved. A guarantee that the value of such a bound function is always decreased at each iteration is a guarantee that the number of times the loop body is executed is at most the initial value of the bound function. The definition of the bound function depends on the assignments we choose for A and B. At this point, we need to exploit properties specific to division. (Refer back to section 2.1 for a discussion of some of the properties.) Inspecting the shape of (9), we see that it is similar to the shape of property (1). This suggests that we can use (1), and in fact, considering this property, we have the corollary: (10) [ k\x ∧ k\y ≡ k\(x−y) ∧ k\y ] . 5We use the Guarded Command Language (GCL), a very simple programming language with just four programming constructs-assignment, sequential composition, conditionals, and loops. The GCL was introduced by Dijkstra [4]. The statement do S od is a loop that executes S repeatedly while at least one of S's guards is true. Expressions in curly brackets are assertions. 7 The relevance of this corollary is that our invariant is preserved by the as- signment x := x−y (leaving the value of y unchanged). (Compare (10) with (9).) Note that this also reduces the value of x when y is positive. This suggests that we strengthen the invariant by requiring that x and y remain positive; the assignment x := x−y is executed when x is greater than y and, symmetrically, the assignment y := y−x is executed when y is greater than x. As bound function we can take x+y. The algorithm becomes { 0 < m ∧ 0 < n } x , y := m , n ; { Invariant: 0<x ∧ 0<y ∧ h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi Bound function: x+y } do x 6= y → if y < x → x := x−y ✷ x < y → y := y−x fi od { 0<x ∧ 0<y ∧ x = y ∧ h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi } (We leave the reader to perform the standard steps used to verify the cor- rectness of the algorithm.) Finally, since (x < y ∨ y < x) ≡ x 6= y , we can safely remove the outer guard and simplify the algorithm, as shown below. { 0 < m ∧ 0 < n } x , y := m , n ; { Invariant: 0<x ∧ 0<y ∧ h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi Bound function: x+y } do y < x → x := x−y ✷ x < y → y := y−x 8 od { 0<x ∧ 0<y ∧ x = y ∧ h∀k:: k\m ∧ k\n ≡ k\x ∧ k\yi } The algorithm that we have constructed is Euclid's algorithm for computing the greatest common divisor of two positive natural numbers, the oldest non- trivial algorithm that has survived to the present day! (Please note that our formulation of the algorithm differs from Euclid's original version and from most versions found in number-theory books. While they use the property [ m▽n = n▽(m mod n) ], we use (10), i.e., [ m▽n = (m−n)▽n ]. For an encyclopedic account of Euclid's algorithm, we recommend [1, p. 334].) 2.3. Greatest Common Divisor In section 2.1.1, we described the problem we were tackling as establishing that the infimum of two natural numbers under the division ordering always exists; it was only at the end of the section that we announced that the algo- rithm we had derived is an algorithm for determining the greatest common divisor. This was done deliberately in order to avoid the confusion that can -and does- occur when using the words "greatest common divisor". In this section, we clarify the issue in some detail. Confusion and ambiguity occur when a set can be ordered in two differ- ent ways. The natural numbers can be ordered by the usual size ordering (denoted by the symbol ≤), but they can also be ordered by the division rela- tion. When the ordering is not made explicit (for instance, when referring to the "least" or "greatest" of a set of numbers), we might normally understand the size ordering, but the division ordering might be meant, depending on the context. In words, the infimum of two values in a partial ordering -if it exists- is the largest value (with respect to the ordering) that is at most both values (with respect to the ordering). The terminology "greatest lower bound" is often used instead of "infimum". Of course, "greatest" here is with respect to the partial ordering in question. Thus, the infimum (or greatest lower bound) of two numbers with respect to the division ordering -if it exists- is the largest number with respect to the division ordering that divides both of the numbers. Since, for strictly positive numbers, "largest with respect to the division ordering" implies "largest with respect to the size ordering" (equally, the division relation, restricted to strictly positive numbers, is a subset of the ≤ relation), the "largest number with respect to the division ordering that divides both of the numbers" is the same, for strictly positive 9 numbers, as the "largest number with respect to the size ordering that divides both of the numbers". Both these expressions may thus be abbreviated to the "greatest common divisor" of the numbers, with no problems caused by the ambiguity in the meaning of "greatest" - when the numbers are strictly positive. Ambiguity does occur, however, when the number 0 is included, because 0 is the largest number with respect to the division ordering, but the smallest number with respect to the size ordering. If "greatest" is taken to mean with respect to the division ordering on numbers, the greatest common divisor of 0 and 0 is simply 0. If, however, "greatest" is taken to mean with respect to the size ordering, there is no greatest common divisor of 0 and 0. This would mean that the gcd operator is no longer idempotent, since 0▽0 is undefined, and it is no longer associative, since, for positive m, (m▽0)▽0 is well-defined whilst m▽(0▽0) is not. Concrete evidence of the confusion in the standard mathematics literature is easy to find. We looked up the definition of greatest common divisor in three commonly used undergraduate mathematics texts, and found three non-equivalent definitions. The first [5, p. 30] defines "greatest" to mean with respect to the divides relation (as, in our view, it should be defined); the second [6, p. 21, def. 2.2] defines "greatest" to mean with respect to the ≤ relation (and requires that at least one of the numbers be non-zero). The third text [7, p. 78] excludes zero altogether, defining the greatest common divisor of strictly positive numbers as the generator of all linear combinations of the given numbers; the accompanying explanation (in words) of the terminology replaces "greatest" by "largest" but does not clarify with respect to which ordering the "largest" is to be determined. Now that we know that ▽ is the greatest common divisor, we could change the operator to gcd, i.e., replace m▽n by m gcd n. However, we stick to the "▽" notation because it makes the formulae shorter, and, so, easier to read. We also use "△" to denote the least common multiple operator. To remember which is which, just remember that infima (lower bounds) are indicated by downward -pointing symbols (eg. ↓ for minimum, and ∨ for disjunction) and suprema (upper bounds) by upward -pointing symbols. 3. Euclid's Algorithm as a Verification Interface In this section we show how algorithms and the notion of invariance can be used to prove theorems. In particular, we show that the exploitation of 10 Euclid's algorithm makes proofs related with the greatest common divisor simple and more systematic than the traditional ones. There is a clear pattern in all our calculations: everytime we need to prove a new theorem involving ▽, we construct an invariant that is valid initially (with x , y := m , n) and that corresponds to the theorem to be proved upon termination (with x = y = m▽n). Alternatively, we can construct an invariant that is valid on termination (with x = y = m▽n) and whose initial value corresponds to the theorem to be proved. The invariant in section 3.3 is such an example. Then, it remains to prove that the chosen invariant is valid after each iteration of the repeatable statement. We start with a minor change in the invariant that allows us to prove some well-known properties. Then, we explore how the shape of the theorems to be proved determine the shape of the invariant. We also show how to prove a geometrical property of ▽. 3.1. Exploring the invariant The invariant that we use in section 2.2 rests on the validity of the theorem [ k\m ∧ k\n ≡ k\(m−n) ∧ k\n ] . But, as Van Gasteren observed in [8, Chapter 11], we can use the more general and equally valid theorem [ k \ (c×m) ∧ k \ (c×n) ≡ k \ (c × (m−n)) ∧ k \ (c×n) ] to conclude that the following property is an invariant of Euclid's algorithm: h∀k, c:: k \ (c×m) ∧ k \ (c×n) ≡ k \ (c×x) ∧ k \ (c×y)i . In particular, the property is true on termination of the algorithm, at which point x and y both equal m▽n. That is, for all m and n, such that 0 < m and 0 < n, (11) [ k \ (c×m) ∧ k \ (c×n) ≡ k \ (c × (m▽n)) ] . In addition, theorem (11) holds when m < 0, since [ (−m)▽n = m▽n ] ∧ [ k \ (c×(−m)) ≡ k \ (c×m) ] , and it holds when m equals 0, since [ k\0 ]. Hence, using the symmetry between m and n we conclude that (11) is indeed valid for all integers m 11 and n. (m, n) 6= (0, 0).) (In Van Gasteren's presentation, this theorem only holds for all Theorem (11) can be used to prove a number of properties of the greatest common divisor. If, for instance, we replace k by m, we have [ m \ (c×n) ≡ m \ (c × (m▽n)) ] , and, as a consequence, we also have (12) [ (m \ (c×n) ≡ m\c) ⇐ m▽n = 1 ] . More commonly, (12) is formulated as the weaker [ m\c ⇐ m▽n = 1 ∧ m\(c×n) ] , and is known as Euclid's Lemma. Another significant property is (13) [ k \ (c × (m▽n)) ≡ k \ ((c×m)▽(c×n)) ] , which can be proved as: k \ (c × (m▽n)) = { (11) } k \ (c×m) ∧ k \ (c×n) = { (3) } k \ ((c×m)▽(c×n)) . From (13) we conclude (14) [ (c×m)▽(c×n) = c × (m▽n) ] . Property (14) states that multiplication by a natural number distributes over ▽. It is an important property that can be used to simplify arguments where both multiplication and the greatest common divisor are involved. An example is Van Gasteren's proof of the theorem (15) [ (m×p)▽n = m▽n ⇐ p▽n = 1 ] , which is as follows: 12 m▽n = { p▽n = 1 and 1 is the unit of multiplication } (m×(p▽n))▽n = { (14) } (m×p) ▽ (m×n) ▽ n = { (m×n)▽n = n } (m×p)▽n . 3.2. ▽ on the left side In the previous sections, we have derived a number of properties of the ▽ operator. However, where the divides relation is involved, the operator always occurs on the right side of the relation. (For examples, see (3) and (13).) Now we consider properties where the operator is on the left side of a divides relation. Our goal is to show that (16) [ (m▽n) \ k ≡ h∃a, b:: k = m×a + n×bi ] , where the range of a and b is the integers. Of course, if (16) is indeed true, then it is also true when k equals m▽n. That is, a consequence of (16) is (17) [ h∃a, b:: m▽n = m×a + n×bi ] . In words, m▽n is a linear combination of m and n. For example, 3▽5 = 1 = 3×2 − 5×1 = 5×2 − 3×3 . Vice-versa, if (17) is indeed true then (16) is a consequence. (The crucial fact is that multiplication distributes through addition.) It thus suffices to prove (17). We can establish (17) by constructing such a linear combination for given values of m and n. When n is 0, we have m▽0 = m = m×1 + 0×1 . (The multiple of 0 is arbitrarily chosen to be 1.) 13 When both m and n are non-zero, we need to augment Euclid's algorithm with a computation of the coefficients. The most effective way to establish the property is to establish that x and y are linear combinations of m and n is an invariant of the algorithm; this is best expressed using matrix arithmetic. In the algorithm below, the assignments to x and y have been replaced by equivalent assignments to the vector (x y). Also, an additional variable C, whose value is a 2×2 matrix of integers has been introduced into the program. Specifically, I, A and B are 2×2 matrices; I is the identity matrix 0 (cid:0) 1 0 1(cid:1) , A is the matrix (cid:0) 1 −1 (x y) := (x y)×A is equivalent to x , y := x−y , y, as can be easily checked.) 0 1(cid:1) and B is the matrix (cid:0) 1 0 −1 1 (cid:1). (The assignment { 0 < m ∧ 0 < n } (x y) , C := (m n) , I ; { Invariant: (x y) = (m n) × C } do y < x → (x y) , C := (x y) × A , C×A ✷ x < y → (x y) , C := (x y) × B , C×B od { (x y) = (m▽n m▽n) = (m n) × C } The invariant shows only the relation between the vectors (x y) and (m n); in words, (x y) is a multiple of (m n). It is straightforward to verify that the invariant is established by the initialising assignment, and maintained by the loop body. Crucial to the proof that it is maintained by the loop body is that multiplication (here of matrices) is associative. Had we expressed the assignments to C in terms of its four elements, verifying that the invariant is maintained by the loop body would have amounted to giving in detail the proof that matrix multiplication is associative. This is a pointless duplication of effort, avoiding which fully justifies the excursion into matrix arithmetic. (An exercise for the reader is to express the property that m and n are linear combinations of x and y. The solution involves observing that A and B are invertible. This will be exploited in section 4.2.) 3.3. A geometrical property In this section, we prove that in a Cartesian coordinate system, m▽n can be interpreted as the number of points with integral coordinates on the 14 straight line joining the points (0, 0) and (m, n), excluding (0, 0). Formally, with dummies s and t ranging over integers, we prove for all m and n: hΣs, t : m×t = n×s ∧ s ≤ m ∧ t ≤ n ∧ (0 < s ∨ 0 < t) : 1i (18) = m▽n . We begin by observing that (18) holds when m = 0 or when n = 0 (we leave the proof to the reader). When 0 < m and 0 < n, we can simplify the range of (18). First, we observe that (0 < s ≤ m ≡ 0 < t ≤ n) ⇐ m×t = n×s , since 0 < t ≤ n = { 0 < m } 0 < m×t ≤ m×n = { m×t = n×s } 0 < n×s ≤ m×n = { 0 < n, cancellation } 0 < s ≤ m . As a result, (18) can be written as (19) [ hΣs, t : m×t = n×s ∧ 0 < t ≤ n : 1i = m▽n ] . In order to use Euclid's algorithm, we need to find an invariant that allows us to conclude (19). If we use as invariant (20) hΣs, t : x×t = y×s ∧ 0 < t ≤ y : 1i = x▽y , its initial value is the property that we want to prove: hΣs, t : m×t = n×s ∧ 0 < t ≤ n : 1i = m▽n . Its value upon termination is hΣs, t : (m▽n)×t = (m▽n)×s ∧ 0 < t ≤ m▽n : 1i = (m▽n)▽(m▽n) , 15 which is equivalent (by cancellation of multiplication and idempotence of ▽) to hΣs, t : t = s ∧ 0 < t ≤ m▽n : 1i = m▽n . It is easy to see that the invariant reduces to true on termination (because the sum on the left equals m▽n), making its initial value also true. It is also easy to see that the righthand side of the invariant is unnecessary as it is the same initially and on termination. This motivates the generali- sation of the concept "invariant". "Invariants" in the literature are always boolean-valued functions of the program variables, but we see no reason why "invariants" shouldn't be of any type: for us, an invariant of a loop is simply a function of the program variables whose value is unchanged by execution of the loop body6. In this case, the value is a natural number. Therefore, we can simplify (20) and use as invariant (21) hΣs, t : x×t = y×s ∧ 0 < t ≤ y : 1i . Its value on termination is hΣs, t : (m▽n)×t = (m▽n)×s ∧ 0 < t ≤ m▽n : 1i , which is equivalent to hΣs, t : t = s ∧ 0 < t ≤ m▽n : 1i . As said above, this sum equals m▽n. Now, since the invariant (21) equals the lefthand side of (19) for the initial values of x and y, we only have to check if it remains constant after each iteration. This means that we have to prove (for y < x ∧ 0 < y): hΣs, t : x×t = y×s ∧ 0 < t ≤ y : 1i = hΣs, t : (x−y)×t = y×s ∧ 0 < t ≤ y : 1i , 6Some caution is needed here because our more general use of the word "invariant" does not completely coincide with its standard usage for boolean-valued functions. The standard meaning of an invariant of a statement S is a boolean-valued function of the program variables which, in the case that the function evaluates to true, remains true after execution of S. Our usage requires that, if the function evaluates to false before execution of S, it continues to evaluate to false after executing S. 16 which can be rewritten, for positive x and y, as: hΣs, t : (x+y)×t = y×s ∧ 0 < t ≤ y : 1i = hΣs, t : x×t = y×s ∧ 0 < t ≤ y : 1i . The proof is as follows: hΣs, t : (x+y)×t = y×s ∧ 0 < t ≤ y : 1i = { distributivity and cancellation } hΣs, t : x×t = y×(s−t) ∧ 0 < t ≤ y : 1i = { range translation: s := s+t } hΣs, t : x×t = y×s ∧ 0 < t ≤ y : 1i . Note that the simplification done in (19) allows us to apply the range trans- lation rule in the last step without having to relate the range of variable s with the possible values for variable t. 4. Euclid's Algorithm as a Construction Interface In this section we show how to use Euclid's algorithm to derive new theorems related with the greatest common divisor. We start by calculating reasonable sufficient conditions for a natural-valued function to distribute over the greatest common divisor. We also derive an efficient algorithm for enumerating the positive rational numbers in two different ways. 4.1. Distributivity properties In addition to multiplication by a natural number, there are other func- tions that distribute over ▽. The goal of this subsection is to determine sufficient conditions for a natural-valued function f to distribute over ▽, i.e., for the following property to hold: (22) [ f.(m▽n) = f.m ▽ f.n ] . For simplicity's sake, we restrict all variables to natural numbers. This im- plies that the domain of f is also restricted to the natural numbers. We explore (22) by identifying invariants of Euclid's algorithm involving the function f . To determine an appropriate loop invariant, we take the right-hand side of (22) and calculate: 17 f.m ▽ f.n = { the initial values of x and y are m and n, respectively } f.x ▽ f.y = { suppose that f.x ▽ f.y is invariant; on termination: x = m▽n ∧ y = m▽n } f.(m▽n) ▽ f.(m▽n) = { ▽ is idempotent } f.(m▽n) . Property (22) is thus established under the assumption that f.x▽f.y is an invariant of the loop body. (Please note that this invariant is of the more general form introduced in section 3.3.) The next step is to determine what condition on f guarantees that f.x▽f.y is indeed invariant. Noting the symmetry in the loop body between x and y, the condition is easily calculated to be [ f.(x−y) ▽ f.y = f.x ▽ f.y ⇐ 0 < y < x ] . Equivalently, by the rule of range translation (x := x+y), the condition can be written as (23) [ f.x ▽ f.y = f.(x+y) ▽ f.y ⇐ 0 < x ∧ 0 < y ] . Formally, this means that " f distributes over ▽ " ⇐ (23) . Incidentally, the converse of this property is also valid: (23) ⇐ " f distributes over ▽ " . The simple calculation proceeds as follows: f.(x+y) ▽ f.y = { f distributes over ▽ } f.((x+y)▽y) 18 = { (7) } f.(x▽y) = { f distributes over ▽ } f.x ▽ f.y . By mutual implication we conclude that " f distributes over ▽ " ≡ (23) . We have now reached a point where we can determine if a function distributes over ▽. However, since (23) still has two occurrences of ▽, we want to refine it into simpler properties. Towards that end we turn our attention to the condition f.x ▽ f.y = f.(x+y) ▽ f.y , and we explore simple ways of guaranteeing that it is everywhere true. For instance, it is immediately obvious that any function that distributes over addition distributes over ▽. (Note that multiplication by a natural number is such a function.) The proof is very simple: f.(x+y) ▽ f.y = { f distributes over addition } (f.x+f.y) ▽ f.y = { (7) } f.x ▽ f.y . In view of properties (7) and (15), we formulate the following lemma, which is a more general requirement: Lemma 24. All functions f that satisfy h∀x, y:: h∃a, b : a▽f.y = 1 : f.(x+y) = a × f.x + b × f.yii distribute over ▽. Proof 19 f.(x+y) ▽ f.y = { f.(x+y) = a × f.x + b × f.y } (a × f.x + b × f.y) ▽ f.y = { (7) } (a × f.x) ▽ f.y = { a ▽ f.y = 1 and (15) } f.x ▽ f.y . ✷ Note that since the discussion above is based on Euclid's algorithm, lemma 24 only applies to positive arguments. We now investigate the case where m or n is 0. We have, for m = 0 : f.(0▽n) = f.0 ▽ f.n = { [ 0▽m = m ] } f.n = f.0 ▽ f.n = { [ a\b ≡ a = b▽a ] } f.n \ f.0 ⇐ { obvious possibilities that make the expression valid are f.0 = 0, f.n = 1, or f.n = f.0; the first is the interesting case } f.0 = 0 . Hence, using the symmetry between m and n we have, for m = 0 or n = 0: (25) f.(m▽n) = f.m ▽ f.n ⇐ f.0 = 0 . The conclusion is that we can use (25) and lemma 24 to prove that a natural- valued function with domain IN distributes over ▽. We were unable to prove that the condition in lemma 24 is necessary for a function to distribute over ▽, but we do not know any function distributing over ▽ that does not satisfy the condition. 20 Example 0: the Fibonacci function In [9], Edsger Dijkstra proves that the Fibonacci function distributes over ▽ . He does not use lemma 24 explicitly, but he constructs the property (26) fib.(x+y) = fib.(y−1) × fib.x + fib.(x+1) × fib.y , and then, using the lemma fib.y ▽ fib.(y−1) = 1 , he concludes the proof. His calculation is the same as that in the proof of lemma 24 but for particular values of a and b and with f replaced by fib. Incidentally, if we don't want to construct property (26) we can easily verify it using induction - more details are given in [10]. An interesting application of this distributivity property is to prove that for any positive k, every kth number in the Fibonacci sequence is a multiple of the kth number in the Fibonacci sequence. More formally, the goal is to prove fib.(n×k) is a multiple of fib.k , for positive k and natural n. A concise proof is: fib.(n×k) is a multiple of fib.k = { definition } fib.k \ fib.(n×k) = { [ a\b ≡ a▽b = a ] , with a := fib.k and b := fib.(n×k) } fib.k ▽ fib.(n×k) = fib.k = { fib distributes over ▽ } fib.(k▽(n×k)) = fib.k = { k▽(n×k) = k and reflexivity } true . 21 Example 1: the Mersenne function We now prove that, for all integers k and m such that 0 < km, the function f defined as f.m = km−1 distributes over ▽. First, we observe that f.0 = 0. (Recall the discussion of (25).) Next, we use lemma 24. This means that we need to find integers a and b, such that km+n−1 = a×(km−1) + b×(kn−1) ∧ a▽(kn−1) = 1 . The most obvious instantiations for a are 1, kn and kn−2. (That two consec- utive numbers are coprime follows from (7).) Choosing a = 1, we calculate b: km+n−1 = (km−1) + b×(kn−1) = { arithmetic } km+n−km = b×(kn−1) = { multiplication distributes over addition } km×(kn−1) = b×(kn−1) ⇐ { Leibniz } km = b . We thus have km+n−1 = 1×(km−1) + km×(kn−1) ∧ 1▽(kn−1) = 1 and we use lemma 24 to conclude that f distributes over ▽: , [ (km−1) ▽ (kn−1) = k(m▽n)−1 ] . In particular, the Mersenne function, which maps m to 2m−1, distributes over ▽: (27) [ (2m−1) ▽ (2n−1) = 2(m▽n)−1 ] . A corollary of (27) is the property [ (2m−1)▽(2n−1) = 1 ≡ m▽n = 1 ] . In words, two numbers 2m−1 and 2n−1 are coprime is the same as exponents m and n are coprime. 22 4.2. Enumerating the Rationals A standard theorem of mathematics is that the rationals are "denumer- able", i.e. they can be put in one-to-one correspondence with the natural numbers. Another way of saying this is that it is possible to enumerate the rationals so that each appears exactly once. Recently, there has been a spate of interest in the construction of bijec- tions between the natural numbers and the (positive) rationals (see [11, 12, 13] and [14, pp. 94–97]). Gibbons et al [11] describe as "startling" the obser- vation that the rationals can be efficiently enumerated7 by "deforesting" the so-called "Calkin-Wilf" [13] tree of rationals. However, they claim that it is "not at all obvious" how to "deforest" the Stern-Brocot tree of rationals. In this section, we derive an efficient algorithm for enumerating the ratio- nals according to both orderings. The algorithm is based on a bijection be- tween the rationals and invertible 2×2 matrices. The key to the algorithm's derivation is the reformulation of Euclid's algorithm in terms of matrices (see section 3.2). The enumeration is efficient in the sense that it has the same time and space complexity as the algorithm credited to Moshe Newman in [12], albeit with a constant-fold increase in the number of variables and number of arithmetic operations needed at each iteration. Note that, in our view, it is misleading to use the name "Calkin-Wilf tree of rationals" because Stern [15] had already documented essentially the same structural characterisation of the rationals almost 150 years earlier than Calkin and Wilf. For more explanation, see the appendix in which we review in some detail the relevant sections of Stern's paper. Stern attributes the structure to Eisenstein, so henceforth we refer to the "Eisenstein-Stern" tree of rationals where recent publications (including our own [16]) would refer to the "Calkin-Wilf tree of rationals". Section 7 includes background information. For a comprehensive account of properties of the Stern-Brocot tree, including further relationships with Euclid's algorithm, see [10, pp. 116–118]. 4.2.1. Euclid's Algorithm A positive rational in so-called "lowest form" is an ordered pair of positive, n has unique lowest-form representation coprime integers. Every rational m 7By an efficient enumeration we mean a method of generating each rational without duplication with constant cost per rational in terms of arbitrary-precision simple arithmetic operations. 23 . For example, 2 m/(m▽n) n/(m▽n) rational, but not in lowest form. 3 is a rational in lowest form, whereas 4 6 is the same Because computing the lowest-form representation involves computing greatest common divisors, it seems sensible to investigate Euclid's algorithm to see whether it gives insight into how to enumerate the rationals. Indeed it does. Beginning with an arbitrary pair of positive integers m and n, the algo- rithm presented in section 3.2 calculates an invertible matrix C such that (m▽n m▽n) = (m n) × C . It follows that (28) (1 1) × C−1 = (m/(m▽n) n/(m▽n)) . Because the algorithm is deterministic, positive integers m and n uniquely define the matrix C. That is, there is a function from pairs of positive integers to finite products of the matrices A and B. Recall that A is the 0 1(cid:1) and B is the matrix (cid:0) 1 0 −1 1 (cid:1). matrix (cid:0) 1 −1 Also, because the matrices A and B are constant and invertible, C−1 is a finite product of the matrices A−1 and B−1 and (28) uniquely defines a rational m n . We may therefore conclude that there is a bijection between the rationals and the finite products of the matrices A−1 and B−1 provided that we can show that all such products are different. The finite products of matrices A−1 and B−1 form a binary tree with root the identity matrix (the empty product). Renaming A−1 as L and B−1 as R, the tree can be displayed with "L" indicating a left branch and "R" indicating a right branch. Fig. 1 displays the first few levels of the tree. That all matrices in the tree are different is proved by showing that the tree is a binary search tree (as formalised shortly). The key element of the proof8 is that the determinants of A and B are both equal to 1 and, hence, the determinant of any finite product of Ls and Rs is also 1. Formally, we define the relation ≺ on matrices that are finite products of 8The proof is an adaptation of the proof in [10, p. 117] that the rationals in the Stern- Brocot tree are all different. Our use of determinants corresponds to their use of "the fundamental fact" (4.31). Note that the definitions of L and R are swapped around in [10].) 24 (cid:0) 1 0 0 1 (cid:1) L R (cid:0) 1 1 0 1(cid:1) (cid:0) 1 0 1 1(cid:1) L R L R (cid:0) 1 2 0 1(cid:1) (cid:0) 1 1 1 2(cid:1) (cid:0) 2 1 1 1(cid:1) (cid:0) 1 0 2 1(cid:1) Figure 1: Tree of Products of L and R Ls and Rs by (cid:18)a c b d(cid:19) ≺ (cid:18)a′ b′ c′ d′(cid:19) ≡ a+c b+d < a′+c′ b′+d′ . (Note that the denominator in these fractions is strictly positive; this fact is easily proved by induction.) We prove that, for all such matrices X, Y and Z, (29) X×L×Y ≺ X ≺ X×R×Z . It immediately follows that there are no duplicates in the tree of matrices because the relation ≺ is clearly transitive and a subset of the inequality relation. (Property (29) formalises precisely what we mean by the tree of matrices forming a binary search tree: the entries are properly ordered by the relation ≺, with matrices in the left branch being "less than" the root matrix which is "less than" matrices in the right branch.) In order to show that (30) X×L×Y ≺ X , suppose X = (cid:0) a b calculated to be c d(cid:1) and Y = (cid:16) a′ b′ c′ d′(cid:17) . Then, since L = (cid:0) 1 1 0 1(cid:1), (30) is easily (a+c)×a′ + (c×b′) + (a+c)×c′ + (c×d′) (b+d)×a′ + (d×b′) + (b+d)×c′ + (d×d′) < a+c b+d . That this is true is also a simple, albeit longer, calculation (which exploits the monotonicity properties of multiplication and addition); as observed earlier, 25 the key property is that the determinant of X is 1, i.e. a×d − b×c = 1. The proof that X ≺ X×R×Z is similar. Of course, we can also express Euclid's algorithm in terms of transpose matrices. Instead of writing assignments to the vector (x y), we can write assignments to its transpose (cid:16) x transposition, the assignment y(cid:17). Noting that A and B are each other's (x y) , C := (x y) × A , C×A in the body of Euclid's algorithm becomes y(cid:19) , C := B × (cid:18)x (cid:18)x y(cid:19) , B×C . Similarly, the assignment (x y) , C := (x y) × B , C×B becomes y(cid:19) , C := A × (cid:18)x (cid:18)x y(cid:19) , A×C . On termination, the matrix C computed by the revised algorithm will of course be different; the pair (cid:16) m/(m▽n) 1(cid:19) = (cid:18) m/(m▽n) n/(m▽n)(cid:19) . C−1 × (cid:18)1 n/(m▽n) (cid:17) is recovered from it by the identity In this way, we get a second bijection between the rationals and the finite products of the matrices A−1 and B−1. This is the basis for our second method of enumerating the rationals. In summary, we have: Theorem 31. Define the matrices L and R by L = (cid:18)1 1 0 1(cid:19) and R = (cid:18) 1 0 1 1(cid:19) . Then the following algorithm computes a bijection between the (positive) rationals and the finite products of L and R. Specifically, the bijection is given by the function that maps the rational m n to the matrix D constructed by the algorithm together with the function from a finite product, D, of Ls and Rs to (1 1) × D. (The comments added to the algorithm supply the information needed to verify this assertion.) 26 { 0 < m ∧ 0 < n } (x y) , D := (m n) , I ; (m n) = (x y) × D } { Invariant: do y < x → (x y) , D := (x y) × L−1 , L×D ✷ x < y → (x y) , D := (x y) × R−1 , R×D od { (x y) = (m▽n m▽n) ∧ ( m/(m▽n) n/(m▽n) ) = (1 1) × D } Similarly, by applying the rules of matrix transposition to all expressions in the above, Euclid's algorithm constructs a second bijection between the rationals and finite products of the matrices L and R. Specifically, the bijection is given by the function that maps the rational m n to the matrix D constructed by the revised algorithm together with the function from finite products, D, of Ls and Rs to D × (cid:0) 1 1(cid:1). ✷ 4.2.2. Enumerating Products of L and R The problem of enumerating the rationals has been transformed to the problem of enumerating all finite products of the matrices L and R. As observed earlier, the matrices are naturally visualised as a tree -recall fig. 1- with left branching corresponding to multiplying (on the right) by L and right branching to multiplying (on the right) by R. By premultiplying each matrix in the tree by (1 1), we get a tree of rationals. (Premultiplying by (1 1) is accomplished by adding the elements in each column.) This tree is sometimes called the Calkin-Wilf tree [11, 14, 13]; we call it the Eisenstein-Stern tree of rationals. (See the appendix for an explanation.) The first four levels of the tree are shown in fig. 2. In this figure, the vector (x y) has been displayed as y x . (Note the order of x and y. This is to aid comparison with existing literature.) 1(cid:1), we also get a tree of 1(cid:1) is accomplished by adding the elements y(cid:17) has been displayed as x y . rationals. (Postmultiplying by (cid:0) 1 fig. 3. In this figure, the vector (cid:16) x Of course, if we can find an efficient way of enumerating the matrices in fig. 1, we immediately get an enumeration of the rationals as displayed in the By postmultiplying each matrix in the tree by (cid:0) 1 in each row.) This tree is called the Stern-Brocot tree [10, pp. 116–118]. See 27 1 1 1 2 2 1 3 2 2 3 4 3 3 5 5 2 2 5 5 3 3 4 Figure 2: Eisenstein-Stern Tree of Rationals (aka Calkin-Wilf Tree) 1 1 1 2 2 1 2 3 3 2 2 5 3 5 3 4 4 3 5 3 5 2 Figure 3: Stern-Brocot Tree of Rationals 3 1 3 1 4 1 4 1 1 3 1 3 1 4 1 4 Eisenstein-Stern tree and as displayed in the Stern-Brocot tree - as each matrix is enumerated, simply premultiply by (1 1) or postmultiply by (cid:0) 1 1(cid:1). Formally, the matrices are enumerated by enumerating all strings of Ls and Rs in lexicographic order, beginning with the empty string; each string is mapped to a matrix by the homomorphism that maps "L" to L, "R" to R, and string concatenation to matrix product. It is easy to enumerate all such strings; as we see shortly, converting strings to matrices is also not difficult, for the simple reason that L and R are invertible. The enumeration proceeds level-by-level. Beginning with the unit matrix (level 0), the matrices on each level are enumerated from left to right. There are 2k matrices on level k, the first of which is Lk. The problem is to deter- mine for a given matrix, which is the matrix "adjacent" to it. That is, given a matrix D, which is a finite product of L and R, and is different from Rk for all k, what is the matrix that is to the immediate right of D in fig. 1? Consider the lexicographic ordering on strings of Ls and Rs of the same length. The string immediately following a string s (that is not the last) is found by identifying the rightmost L in s. Supposing s is the string tLRj, where Rj is a string of j Rs, its successor is tRLj. It's now easy to see how to transform the matrix identified by s to its suc- 28 cessor matrix. Simply postmultiply by R−j × L−1 × R × Lj. This is because, for all T and j, (T × L × Rj) × (R−j × L−1 × R × Lj) = T × R × Lj . Also, it is easy to calculate R−j × L−1 × R × Lj. Specifically, R−j × L−1 × R × Lj = (cid:18)2j + 1 −1 1 0(cid:19) . (We omit the details. Briefly, by induction, Lj equals (cid:16) 1 j transpose of L.) 0 1(cid:17). Also, R is the The final task is to determine, given a matrix D, which is a finite product of Ls and Rs, and is different from Rk for all k, the unique value j such that D = T × L × Rj for some T. This can be determined by examining Euclid's algorithm once more. The matrix form of Euclid's algorithm discussed in theorem 31 computes it maintains the a matrix D given a pair of positive numbers m and n; invariant (m n) = (x y) × D . D is initially the identity matrix and x and y are initialised to m and n, respectively; immediately following the initialisation process, D is repeatedly premultiplied by R so long as x is less than y. Simultaneously, y is reduced by x. The number of times that D is premultiplied by R is thus the greatest number j such that j×m is less than n, which is (cid:4) n−1 input values m and n are coprime. Then, on termination of the algorithm, (1 1) × D equals ( m n ). That is, if m (cid:5). Now suppose the D = (cid:18) D00 D10 D01 D11(cid:19) , then, m (cid:23) = (cid:22) D01 + D11 − 1 (cid:22)n−1 D00 + D10 (cid:23) . It remains to decide how to keep track of the levels in the tree. For this purpose, it is not necessary to maintain a counter. It suffices to observe that 29 D is a power of R exactly when the rationals in the Eisenstein-Stern, or Stern-Brocot, tree are integers, and this integer is the number of the next level in the tree (where the root is on level 0). So, it is easy to test whether the last matrix on the current level has been reached. Equally, the first matrix on the next level is easily calculated. For reasons we discuss in the next section, we choose to test whether the rational in the Eisenstein-Stern tree is an integer; that is, we evaluate the boolean D00 + D10 = 1. In this way, we get the following (non-terminating) program which computes the successive values of D. D := I ; 1 0 do D00 + D10 = 1 → D := (cid:16) 1(cid:17) ✷ D00 + D10 6= 1 → j := j D01 + D11 − 1 D00 + D10 k ; D := D × (cid:0) 2j + 1 0(cid:1) D01+D11 −1 1 od A minor simplification of this algorithm is that the "− 1" in the assignment to j can be omitted. This is because (cid:4) n−1 n are coprime and m is different from 1. We return to this shortly. m(cid:5) are equal when m and m (cid:5) and (cid:4) n 4.2.3. The Enumerations As remarked earlier, we immediately get an enumeration of the rationals as displayed in the Eisenstein-Stern tree and as displayed in the Stern-Brocot tree - as each matrix is enumerated, simply premultiply by (1 1) or post- 1(cid:1), respectively. In the case of enumerating the Eisenstein-Stern tree, several optimisations are possible. First, it is immediate from our derivation that the value assigned multiply by (cid:0) 1 to the local variable j is a function of (1 1) × D. In turn, the matrix(cid:0) 2j + 1 is also a function of (1 1) × D. Let us name the function J, so that the assignment becomes 0(cid:1) −1 1 D := D × J.((1 1) × D) . Then, the Eisenstein-Stern enumeration iteratively evaluates (1 1) × (D × J.((1 1) × D)) . 30 Matrix multiplication is associative; so this is ((1 1) × D) × J.((1 1) × D) , which is also a function of (1 1) × D. Moreover -in anticipation of the current discussion- we have been careful to ensure that the test for a change in the level in the tree is also a function of (1 1) × D. Combined together, this means that, in order to enumerate the rationals in Eisenstein-Stern order, it is not necessary to compute D at each iteration, but only (1 1) × D. Naming the two components of this vector m and n, and simplifying the matrix multiplications, we get9 m,n := 1,1 ; do m = 1 → m,n := n+1 , m ✷ m 6= 1 → m,n := (2(cid:22)n − 1 m (cid:23) + 1) × m − n , m od At this point, a further simplification is also possible. We remarked earlier m (cid:5) equals (cid:4) n that (cid:4) n − 1 1. By good fortune, it is also the case that (2(cid:4) n m(cid:5) when m and n are coprime and m is different from m(cid:5) + 1) × m − n simplifies to n+1 when m is equal to 1. That is, the elimination of "− 1" in the evaluation of the floor function leads to the elimination of the entire case analysis! This is the algorithm attributed to Newman in [12]. m,n := 1,1 ; do m,n := (2j n mk + 1) × m − n , m od 4.2.4. Discussion Our construction of an algorithm for enumerating the rationals in Stern- Brocot order was motivated by reading two publications, [10, pp. 116–118] and [11]. Gibbons, Lester and Bird [11] show how to enumerate the elements of the Eisenstein-Stern tree, but claim that "it is not at all obvious how to do this for the Stern-Brocot tree". Specifically, they say10: 9Recall that, to comply with existing literature, the enumerated rational is n m and not m n . 10Recall that they attribute the tree to Calkin and Wilf rather than Eisenstein and Stern. 31 However, there is an even better compensation for the loss of the ordering property in moving from the Stern-Brocot to the Calkin- Wilf tree: it becomes possible to deforest the tree altogether, and generate the rationals directly, maintaining no additional state beyond the 'current' rational. This startling observation is due to Moshe Newman (Newman, 2003). In contrast, it is not at all obvious how to do this for the Stern-Brocot tree; the best we can do seems to be to deforest the tree as far as its levels, but this still entails additional state of increasing size. In this section, we have shown that it is possible to enumerate the rationals in Stern-Brocot order without incurring "additional state of increasing size". More importantly, we have presented one enumeration algorithm with two specialisations, one being the "Calkin-Wilf" enumeration they present, and the other being the Stern-Brocot enumeration that they described as being "not at all obvious". The optimisation of Eisenstein-Stern enumeration which leads to New- man's algorithm is not possible for Stern-Brocot enumeration. Nevertheless, the complexity of Stern-Brocot enumeration is the same as the complexity of Newman's algorithm, both in time and space. The only disadvantage of Stern-Brocot enumeration is that four variables are needed in place of two; the advantage is the (well-known) advantage of the Stern-Brocot tree over the Eisenstein-Stern tree - the rationals on a given level are in ascending order. Gibbons, Lester and Bird's goal seems to have been to show how the functional programming language Haskell implements the various construc- tions – the construction of the tree structures and Newman's algorithm. In doing so, they repeat the existing mathematical presentations of the algo- rithms as given in [10, 13, 12]. The ingredients for an efficient enumeration of the Stern-Brocot tree are all present in these publications, but the recipe is missing! The fact that expressing the rationals in "lowest form" is essential to the avoidance of duplication in any enumeration immediately suggests the relevance of Euclid's algorithm. The key to our exposition is that Euclid's algorithm can be expressed in terms of matrix multiplications, where - significantly- the underlying matrices are invertible. Transposition and in- version of the matrices capture the symmetry properties in a precise, calcu- lational framework. As a result, the bijection between the rationals and the 32 tree elements is immediate and we do not need to give separate, inductive proofs for both tree structures. Also, the determination of the next element in an enumeration of the tree elements has been reduced to one unifying construction. 5. Conclusion In our view, much of mathematics is inherently algorithmic; it is also clear that, in the modern age, algorithmic problem solving is just as important, if not much more so, than in the 19th century. Somehow, however, mathe- matical education in the 20th century lost sight of its algorithmic roots. We hope to have exemplified in this paper how a fresh approach to introductory number theory that focuses on the algorithmic content of the theory can com- bine practicality with mathematical elegance. By continuing this endeavour we believe that the teaching of mathematics can be enriched and given new vigour. References [1] D. E. Knuth, The Art of Computer Programming, volume 2 (3rd ed.): Seminumerical Algorithms, Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1997. [2] R. Backhouse, Program Construction. Calculating Implementations From Specifications., John Wiley & Sons, Ltd., 2003. [3] D. Gries, F. B. Schneider, A Logical Approach to Discrete Math, Springer-Verlag, 1993. [4] E. W. Dijkstra, Guarded commands, nondeterminacy and formal deriva- tion of programs, Communications of the ACM 18 (8) (1975) 453–457. [5] K. E. Hirst, Numbers, Sequences and Series, Edward Arnold, 1995. [6] D. M. Burton, Elementary Number Theory, 6th Edition, McGraw-Hill Higher Education, 2005. URL http://www.worldcat.org/isbn/0071244255 [7] J. B. Fraleigh, A First Course in Abstract Algebra, 6th Edition, Addison Wesley Longman Inc., 1998. 33 [8] A. van Gasteren, On the Shape of Mathematical Arguments, no. 445 in LNCS, Springer-Verlag, 1990. [9] E. W. Dijkstra, Fibonacci and the greatest common divisor (April 1990). URL http://www.cs.utexas.edu/users/EWD/ewd10xx/EWD1077.PDF [10] R. L. Graham, D. E. Knuth, O. Patashnik, Concrete Mathematics : a Foundation for Computer Science, 2nd Edition, Addison-Wesley Pub- lishing Company, 1994. [11] J. Gibbons, D. Lester, R. Bird, Enumerating the rationals, Journal of Functional Programming 16 (3) (2006) 281–291. [12] D. E. Knuth, C. Rupert, A. Smith, R. Stong, Recounting the rationals, continued, American Mathematical Monthly 110 (7) (2003) 642–643. [13] N. Calkin, H. S. Wilf, Recounting the rationals, The American Mathe- matical Monthly 107 (4) (2000) 360–363. [14] M. Aigner, G. Ziegler, Proofs From The Book, 3rd Edition, Springer- Verlag, 2004. [15] M. A. Stern, Ueber eine zahlentheoretische Funktion, Journal fur die reine und angewandte Mathematik 55 (1858) 193–220. [16] R. Backhouse, J. F. Ferreira, Recounting the rationals: Twice!, in: Mathematics of Program Construction, Vol. 5133 of LNCS, 2008, pp. 79–91. doi:10.1007/978-3-540-70594-9\_6. URL http://joaoff.com/publications/2008/rationals [17] A. Brocot, Calcul des nouvelle m´ethode, Revue Chronom´etrique 3 (1861) 186–194, available via http://joaoff.com/publications/2008/rationals/. rouages par approximation, [18] B. Hayes, On the teeth of wheels, American Scientist 88 (4) (2000) 296–300. URL http://www.americanscientist.org/issues/pub/2000/4/on-the-teeth-of-wheels [19] N. J. A. Sloane, The on-line encyclopedia of integer sequences. URL http://www.research.att.com/~njas/sequences/ 34 [20] R. Backhouse, J. F. Ferreira, On Euclid's algorithm and elementary number theory (2009). URL http://joaoff.com/publications/2009/euclid-alg Appendix: Historical Remarks The primary novel result of our paper is the construction given in section 4.2 of an algorithm to enumerate the rationals in Stern-Brocot order. Apart from minor differences, this section of our paper was submitted in April 2007 to the American Mathematical Monthly; it was rejected in November 2007 on the grounds that it was not of sufficient interest to readers of the Monthly. One (of two referees) did, however, recommend publication. The referee made the following general comment. Each of the two trees of rationals-the Stern-Brocot tree and the Calkin-Wilf tree-has some history. Since this paper now gives the definitive link between these trees, I encourage the authors, perhaps in their Discussion section, to also give the definitive his- tories of these trees, something in the same spirit as the Remarks at the end of the Calkin and Wilf paper. Since the publication of [16], we have succeeded in obtaining copies of the original papers and it is indeed interesting to briefly review the papers. But we do not claim to provide "definitive histories of these trees" - that is a task for a historian of mathematics. Section 6 is about the paper [15] published in 1858 by Stern. The surpris- ing fact that emerges from the review is that the so-called "Calkin-Wilf" tree of rationals, and not just the "Stern-Brocot" tree, is studied in detail in his paper. Moreover, of the two structures, the "Calkin-Wilf" tree is more read- ily recognised; the "Stern-Brocot" tree requires rather more understanding to identify. Brocot's paper [17], which we review in section 7, is interesting because it illustrates how 19th century mathematics was driven by practical, algorithmic problems. (For additional historical remarks, see also [18].) 6. Stern's Paper Earlier we have commented that the structure that has recently been referred to as the "Calkin-Wilf" tree was documented by Stern [15] in 1858. 35 In this section we review those sections of Stern's paper that are relevant to our own. 6.1. The Eisenstein Array Stern's paper is a detailed study of what has now become known as the "Eisenstein array" of numbers (see, for example, [19, sequence A064881]). (Stern's paper cites two papers written by the more famous mathematician Gotthold Eisenstein; we have not read these papers.) Given two natural numbers m and n, Stern describes a process (which he attributes to Eisen- stein) of generating an infinite sequence of rows of numbers. The zeroth row in the sequence ("nullte Entwickelungsreihe") is the given pair of numbers: m n . Subsequent rows are obtained by inserting between every pair of numbers the sum of the numbers. Thus the first row is m m+n n and the second row is m 2×m + n m+n m + 2×n n . The process of constructing such rows is repeated indefinitely. The sequence of numbers obtained by concatenating the individual rows in order is what is now called the Eisenstein array and denoted by Ei(m,n) (see, for example, [19, sequence A064881]) . Stern refers to each occurrence of a number in rows other than the zeroth row as either a sum element ("Summenglied") or a source element ("Stammglied"). The sum elements are the newly added numbers. For example, in the first row the number m+n is a sum element; in the second row the number m+n is a source element. 6.2. The Eisenstein-Stern Tree of Rationals A central element of Stern's analysis of the Eisenstein array is the consid- eration of subsequences of numbers in individual rows. He calls these groups ("Gruppen") and he records the properties of pairs of consecutive numbers (groups of size two - "zweigliedrige Gruppen") and triples of consecutive numbers (groups of size three - "dreigliedrige Gruppen"). In sections 5 thru 8 of his paper, Stern studies Ei(1,1), the Eisenstein array that begins with the pair (1, 1). He proves that all pairs of consecutive 36 numbers in a given row are coprime and every pair of coprime numbers appears exactly once as such a pair of consecutive numbers. He does not use the word "tree" -tree structures are most probably an invention of modern computing science- and he does not refer to "rational numbers" -he refers instead to relatively prime numbers ("relatieve Primzahlen")- but there is no doubt that, apart from the change in terminology, he describes the tree of rationals that in recent years has been referred to as the "Calkin-Wilf" tree of rationals. It is for this reason that we believe it is misleading to use the name "Calkin-Wilf tree" and prefer to use the name "Eisenstein-Stern tree". Fig. 4 shows the first four rows of Ei(1,1) and fig. 5 shows all pairs of consecutive numbers for each of the four rows. The pairs have been arranged so that the correspondence between fig. 2 and fig. 5 is clear. 1 1 1 3 5 2 2 2 1 3 5 1 3 1 4 1 3 4 1 Figure 4: First four rows of Ei(1,1) (1, 1) (1, 2) (2, 1) (1, 3) (3, 2) (2, 3) (3, 1) (1, 4) (4, 3) (3, 5) (5, 2) (2, 5) (5, 3) (3, 4) (4, 1) Figure 5: Pairs of consecutive numbers in the first four rows of Ei(1,1) Other sections of Stern's paper record additional properties of the tree, which we do not discuss here. For example, Stern discusses how often each number appears as a sum number. 37 6.3. The Stern-Brocot Tree of Rationals Identification of the so-called Stern-Brocot tree of rationals in Stern's paper is more demanding. Recall the process of constructing a sequence of rows of numbers from a given pair of numbers m and n. It is clear that every number is a linear combination of m and n. Stern studies the coefficients ("Coefficienten"), i.e. the pair of multiplicative factors of m and n, defined by the linear combination. Fig. 6 displays the coefficients in a way that allows direct comparison with the Stern-Brocot tree of rationals (fig. 3). (The reader may also wish to compare fig. 6 with Graham, Knuth and Patashnik's depiction of the tree [10, p. 117].) 1×m + 0×n 0×m + 1×n 1×m + 1×n 2×m + 1×n 1×m + 2×n 3×m + 1×n 3×m + 2×n 2×m + 3×n 1×m + 3×n 4×m + 1×n 3×m + 2×n 5×m + 2×n 3×m + 5×n 5×m + 3×n 2×m + 5×n 4×m + 3×n 1×m + 4×n Figure 6: Tree of "coefficients" of Ei(m,n) The numbers at the top-left and top-right of fig. 6 are the numbers m and n written as 1×m + 0×n and 0×m + 1×n, respectively, in order to make the coefficients clear. This, we recall, is the zeroth row in Stern's structure. In the subsequent levels of the tree, only the sum elements are displayed. The correspondence between fig. 6 and fig. 3 should be easy to see; the l number k×m + l×n in fig. 6 is displayed as the rational k in fig. 3. The "fundamental fact" (4.31) in [10] is observed by Stern [15, equation (8), p.207] and used immediately to infer that coefficients are relatively prime. In section 15 of his paper, Stern uses the (already proven) fact that the Eisenstein-Stern tree is a tree of (all) rationals to deduce that the Stern-Brocot tree is also a tree of rationals. 6.4. Newman's Algorithm An interesting question is whether Stern also documents the algorithm currently attributed to Moshe Newman for enumerating the elements of the Eisenstein array. This is a question we found difficult to answer because of 38 our limited understanding of German. However, the answer would appear to be: almost, but not quite! As remarked earlier, Stern documents a number of properties of groups of numbers in rows of the Eisenstein array, in particular groups of size three. Of course, a group of size three comprises two groups of size two. Since groups of size two in the Eisenstein array correspond to rationals in the Eisenstein-Stern tree, by studying groups of size three Stern is effectively studying consecutive rationals in the Eisenstein-Stern tree of rationals. It is important to note that Stern's focus is the sequence of rows of num- bers (in modern terminology, the tree of numbers) as opposed to the (flat- tened) sequence of numbers defined by Ei(m,n) - significantly, the last number in one row and the first number in the next row do not form a "group" according to Stern's definition. This means that, so far as we have been able to determine, he nowhere considers a triple of numbers that crosses a row boundary. Newman's algorithm (in the form we use in section 4.2.3) predicts that each triple of numbers in a given row of Ei(1,1) has the form a b (2ja bk + 1) × b − a (Variable names have been chosen to facilitate comparison with Stern's pa- per.) It follows immediately that the sum of the two outer elements of the triple is divisible by the middle element (that is, a + ((2(cid:4) a is divisible by b); this fact is observed by Stern (for triples in a given row) in section 4 of his paper. Importantly for what follows, Stern observes that the property holds for Ei(m,n) for arbitrary natural numbers m and n, and not just Ei(1,1). Stern observes further [15, (4) p.198] that each triple in Ei(m,n) has the form b(cid:5) + 1) × b − a) (32) a b (2t + 1) × b − a for some number t. Stern identifies t as the number of rows preceding the current row in which the number b occurs as a sum element. (In particular, if b is a sum element then t equals 0.) Stern shows how to calculate t from the position of b in the row - effectively by expressing the position as a binary numeral. (Note that "t" is the variable name used in Stern's paper; it has the same role as the variable "j" in our derivation of the algorithm in section 4.2.3.) 39 So far as we have been able to determine, Stern does not explicitly re- mark that t equals (cid:4) a b(cid:5) in the case of Ei(1,1), but he does so implicitly in section 10 where he relates the the continued fraction representation of a b to the row number in which the pair (a, b) occurs. He does not appear to suggest a similar method for computing t in the general case of enumerating Ei(m,n). However, it is straightforward to combine our derivation of New- man's algorithm with Stern's theorems to obtain an algorithm to enumerate the elements of Ei(m,n) for arbitrary natural numbers m and n. Interested readers may consult our website [20] where several implementations are dis- cussed. As stated at the beginning of this section, the conclusion is that Stern almost derives Newman's algorithm, but not quite. On the other hand, because his analysis is of the general case Ei(m,n) as opposed to Ei(1,1), his results are more general. 6.5. Stern-Brocot Enumeration We now turn to the question whether Stern also gives an algorithm for enumerating the rationals in Stern-Brocot order. To this end, we observe that the form (32) extends to the coefficients of each element of Ei(M,N), and hence to the elements of the Stern-Brocot tree. Specifically, triples in Ei(M,N) have the form n0M+m0N n1M+m1N ((2k + 1)n1 − n0)M + ((2k + 1)m1 − m0)N It is easy to exploit this formula directly to get an enumeration of the ratio- nals in Stern-Brocot order, just as we did above to obtain an enumeration of Ei(M,N). Just recall that the Stern-Brocot rationals are given by the co- efficients of the sum elements, and the sum elements are the odd-numbered elements in the rows of Ei(M,N) (where numbering starts from zero). The algorithm so obtained is the one we derived in section 4.2.3. In this sense, Stern does indeed provide an algorithm for enumerating the rationals in Stern-Brocot order, albeit implicitly. However, as with Newman's algorithm, he fails to observe the concise formula for the value of the variable k. Also, a major methodological difference is our exploitation of the concision and precision afforded by matrix algebra. Given the state of development of matrix algebra in 1858, Stern cannot be criticised for not doing the same. Finally, we remark that Stern returns to the properties of triples in section 19 of his paper. Unfortunately, we have been unable to fully understand this section. 40 7. Brocot, the Watchmaker Achille Brocot was a famous French watchmaker who, some years before the publication of his paper [17], had to fix some pendulums used for astro- nomical measurements. However, the device was incomplete and he did not know how to compute the number of teeth of cogs that were missing. He was unable to find any literature helpful to the solution of the problem, so, after some experiments, he devised a method to compute the numbers. In his paper, Brocot illustrates his method with the following example: A shaft turns once in 23 minutes. We want suitable cogs so that another shaft completes a revolution in 3 hours and 11 minutes, that is 191 minutes. The ratio between both speeds is 191 23 , so we can clearly choose a cog with 191 teeth, and another one with 23 teeth. But, as Brocot wrote, it was not possible, at that time, to create cogs with so many teeth. And because 191 and 23 are coprime, cogs with fewer teeth can only approximate the true ratio. Brocot's contribution was a method to compute approximations to the true ratios (hence the title of his paper, "Calculus of cogs by approximation"). He begins by observing that 191 1. If we choose the ratio 8 1, the error is −7 since 8×23 = 1×191 − 7. This means that if we choose this ratio, the slower cog completes its revolution seven minutes early, i.e., after 8×23 minutes. On the other hand, if we choose the ratio 9 1, the error is 16 since 9×23 = 1×191 + 16, meaning that the slower cog completes its revolution sixteen minutes late, i.e., after 9×23 minutes. 23 must be between the ratios 8 1 and 9 Accordingly, Brocot writes two rows: 8 9 1 1 -7 +16 His method consists in iteratively forming a new row, by adding the numbers in all three columns of the rows that produce the smallest error. Initially, we only have two rows, so we add the numbers in the three columns and we write the row of sums in the middle. 8 17 9 -7 +9 +16 1 2 1 41 2 = 191+ 9 (If we choose the ratio 17 2 , the slower cog completes its revolution 9 2 minutes later, since 17 .) Further approximations are constructed by adding a row adjacent to the row that minimises the error term. The process ends once we reach the error 0, which refers to the true ratio. The final state of the table is: 23 2 8 33 58 83 191 108 25 17 9 1 4 7 10 23 13 3 2 1 -7 -5 -3 -1 0 +1 +2 +9 +16 10 minutes faster) and 108 23 are ratios of 83 The conclusion is that the two closest approximations to 191 10 (which runs 1 13 minutes slower). We could continue this process, getting at each stage a closer approximation to 191 23 . In fact, Brocot refines the table shown above, in order to construct a multistage cog train (see [17, p. 191]). 13 (which runs 1 n and m′ n+n′ , where m At each step in Brocot's process we add a new ratio m+m′ n+n′ , which is usually called the mediant of m n′ . Similarly, each node in the Stern-Brocot tree is of the form m+m′ n is the nearest ancestor above and to the left, and m′ n′ is the nearest ancestor above and to the right. (Consider, for example, the rational 4 1 and its nearest ancestor above and to the right is 3 2.) Brocot's process can be used to construct the Stern-Brocot tree: first, create an array that contains initially the rationals 0 n+n′ between two adjacent fractions m n′ . In the first step we add only one rational to the array 3 in figure 3. Its nearest ancestor above and to the left is 1 0; then, insert the rational m+m′ 1 and 1 n and m′ 0 1 , 1 1 , 1 0 , but in the second step we add two new rationals: 0 1 , 1 2 , 1 1 , 2 1 , 1 0 . 42 Generally, in the nth step we add 2n−1 new rationals. Clearly, this array can be represented as an infinite binary tree, whose first four levels are repre- sented in figure 3 (we omit the fractions 0 The most interesting aspect to us of Brocot's paper is that it solves an algorithmic problem. Brocot was faced with the practical problem of how to approximate rational numbers in order to construct clocks of satisfactory accuracy and his solution is undisputably an algorithm. Stern's paper is closer to a traditional mathematical paper but, even so, it is an in-depth study of an algorithm for generating rows of numbers of increasing length. 1 and 1 0). 8. Conclusion There can be no doubt that what has been dubbed in recent years the "Calkin-Wilf" tree of rationals is, in fact, a central topic in Stern's 1858 paper. Calkin and Wilf [13] admit that in Stern's paper "there is a structure that is essentially our tree of fractions" but add "in a different garb" and do not clarify what is meant by "a different garb". It is unfortunate that the misleading name has now become prevalent; in order to avoid further misinterpretations of historical fact, it would be desirable for Stern's paper to be translated into English. We have not attempted to determine how the name "Stern-Brocot" tree came into existence. It has been very surprising to us how much easier it is to identify the Eisenstein-Stern tree in Stern's paper in comparison to identifying the Stern-Brocot tree. Acknowledgements. Thanks go to Christian Wuthrich for help in translating the most relevant parts of Stern's paper, and to Jeremy Gibbons for his comments on earlier drafts of this paper, and for help with TeX commands. Thanks also to our colleagues in the Nottingham Tuesday Morning Club for helping iron out omissions and ambiguities, and to Arjan Mooij and Jeremy Weissmann for their comments on section 4.1. This work is (partially) funded by ERDF - European Regional Devel- opment Fund through the COMPETE Programme (operational programme for competitiveness) and by National Funds through the FCT - the Por- tuguese Foundation for Science and Technology, within project FCOMP-01- 0124-FEDER-007254. 43
1504.03842
1
1504
2015-04-15T09:47:12
OBDDs and (Almost) $k$-wise Independent Random Variables
[ "cs.DS" ]
OBDD-based graph algorithms deal with the characteristic function of the edge set E of a graph $G = (V,E)$ which is represented by an OBDD and solve optimization problems by mainly using functional operations. We present an OBDD-based algorithm which uses randomization for the first time. In particular, we give a maximal matching algorithm with $O(\log^3 \vert V \vert)$ functional operations in expectation. This algorithm may be of independent interest. The experimental evaluation shows that this algorithm outperforms known OBDD-based algorithms for the maximal matching problem. In order to use randomization, we investigate the OBDD complexity of $2^n$ (almost) $k$-wise independent binary random variables. We give a OBDD construction of size $O(n)$ for $3$-wise independent random variables and show a lower bound of $2^{\Omega(n)}$ on the OBDD size for $k \geq 4$. The best known lower bound was $\Omega(2^n/n)$ for $k \approx \log n$ due to Kabanets. We also give a very simple construction of $2^n$ $(\varepsilon, k)$-wise independent binary random variables by constructing a random OBDD of width $O(n k^2/\varepsilon)$.
cs.DS
cs
OBDDs and (Almost) k-wise Independent Random Variables Marc Bury∗ TU Dortmund, LS2 Informatik, Germany OBDD-based graph algorithms deal with the characteristic function of the edge set E of a graph G = (V, E) which is represented by an OBDD and solve optimization problems by mainly using functional operations. We present an OBDD-based algorithm which uses randomization for the first time. In particular, we give a maximal matching algorithm with O(log3 V ) functional operations in expectation. This algorithm may be of independent interest. The experimental evaluation shows that this algorithm outperforms known OBDD-based algorithms for the maximal matching problem. In order to use randomization, we investigate the OBDD complexity of 2n (almost) k-wise independent binary random variables. We give a OBDD construction of size O(n) for 3-wise independent random variables and show a lower bound of 2Ω(n) on the OBDD size for k ≥ 4. The best known lower bound was Ω(2n/n) for k ≈ log n due to Kabanets [24]. We also give a very simple construction of 2n (ε, k)-wise independent binary random variables by constructing a random OBDD of width O(nk2/ε). 5 1 0 2 r p A 5 1 ] S D . s c [ 1 v 2 4 8 3 0 . 4 0 5 1 : v i X r a ∗Supported by Deutsche Forschungsgemeinschaft, grant BO 2755/1-2. 1 1 Introduction In times of Big Data, classical algorithms for optimization problems quickly exceed feasi- ble running times or memory requirements. For instance, the rapid growth of the Internet and social networks results in massive graphs which traditional algorithms cannot pro- cess in reasonable time or space. In order to deal with such graphs, implicit (symbolic) algorithms have been investigated where the input graph is represented by the character- istic function χE of the edge set and the nodes are encoded by binary numbers. Using Ordered Binary Decision Diagrams (OBDDs), which were introduced by Bryant [12], to represent χE can significantly decrease the space needed to store such graphs. Fur- thermore, using mainly functional operations, e. g., binary synthesis and quantifications, which are efficiently supported by the OBDD data structure, many optimization prob- lems can be solved on OBDD represented inputs ([17, 18, 20, 35, 36, 37, 42]). Implicit algorithms were successfully applied in many areas, e. g., model checking [13], integer linear programming [25] and logic minimization [15]. With one of the first implicit graph algorithms, Hachtel and Somenzi [20] were able to compute a maximum flow on 0-1-networks with up to 1036 edges and 1027 nodes in reasonable time. There are two main parameters influencing the actual running time of OBDD-based algorithms: the number of functional operations and the sizes of all intermediate OBDDs used during the computation. The size of OBDDs representing graphs was investigated for bipartite graphs [33], interval graphs [33, 19], cographs [33] and graphs with bounded tree- and clique-width [29]. Bounding the sizes of the other OBDDs, which can occur during the computation, is quite difficult and could only be proven for very structured input graphs like grid graphs [8, 42]. In terms of functional operations, Sawitzki [38] showed that the set of problems solved by an implicit algorithm using O(logk N ) func- tional operations and functions defined on O(log N ) variables is equal to the complexity class FNC, i. e., the class of all optimization problems that can be efficiently solved in parallel. Implicit algorithms with these properties were designed for instance for topological sorting [42], minimum spanning tree [6], metric TSP approximation [7] and maximal matching [10] where a matching M, i. e., a set of edges without a common ver- tex, is called maximal if M is no proper subset of another matching. However, Sawitzki's structural result yields neither a good transformation of parallel algorithms to implicit algorithms nor does it give a statement about the actual performance of the implicit algorithms. Nevertheless, designing implicit algorithms for optimization problems is not only an adaption of parallel algorithms but can give new insights into the problems. For example, Gentilini et al. [18] introduced a new notion of spine-sets in the context of implicit algorithms for connectivity related problems. When analyzing implicit algo- rithms, the actual running time can either be proven for very structured input graphs like [42] did for topological sorting and [8] for maximum matching or the running time is experimentally evaluated like in [20] for maximum flows and in [8, 19] for maximum matching on bipartite graphs or unit interval graphs. Overall there seems to be a trade-off: The number of operations is an important measure of difficulty [5] but decreasing the number of operations often results in an increase of the number of variables of the used functions. Since the worst case OBDD size 2 of a function f : {0, 1}n → {0, 1} is Θ(2n/n), the number of variables should be as small as possible to decrease the worst case running time. This trade-off was also empirically observed. For instance, an implicit algorithm computing the transitive closure that uses an iterative squaring approach and a polylogarithmic number of operations is often inferior to an implicit sequential algorithm, which needs a linear number of operations in worst case [5, 21]. Another example is the maximal matching algorithm (BP) of Bollig and Proger [10] that uses only O(log4 N ) functional operations on functions with at most 6 log N variables while the algorithm (HS) of Hachtel and Somenzi [20] uses O(N log N ) operations in the worst case on function with at most 3 log N variables. However, HS is clearly superior to BP on most instances (see Section 5). An additional reason might be its simplicity. Using randomization in an explicit algorithm often leads to simple and fast algorithms. Here, we propose the first attempt at using randomization to obtain algorithms which have both a small number of variables and a small expected number of functional op- erations. For this, we want to represent random functions fr : {0, 1}n → {0, 1} with Pr [fr(x) = 1] = p for every x ∈ {0, 1}n and some fixed probability 0 < p < 1 by OBDDs. Using random functions in implicit algorithms is difficult. We need to construct them efficiently but, obviously, if the function values are completely independent (and p is a constant), then the OBDD (and even the more general FBDD or read-once branching program) size of fr is exponentially large with an overwhelming probability [40]. Thus, we investigate the OBDD size and construction of (almost) k-wise independent random functions where the distribution induced on every k different function values is (almost) uniform. Related Work A succinct representation of 2n random bits, which are k-wise independent, was presented by Alon et al. [1] using (cid:98)k/2(cid:99)n + 1 independent random bits. This number of random bits is very close to the lower bound of Chor and Goldreich [14]. In order to reduce the number of random bits even further, Naor and Naor [31] introduced the notion of almost k-wise independence where the distribution on every k random bits is "close" to uniform. Constructions of almost k-wise independent random variables are also given in [2] and are using only at most 2(log n + log k + log(1/ε)) random bits where ε is a bound on the closeness to the uniform distribution. Looking for a simple representation of almost k-wise independent random variables, Savick´y [34] presented a Boolean formula of constant depth and polynomial size and used n log2 k log(1/ε) random bits. In all of these constructions, the running time of computing the i-th random bit with 0 ≤ i ≤ 2n − 1 depends on k and ε. Such small probability spaces can be used for a succinct representation of a random string of length 2n, e. g., in streaming algorithms [3], or for derandomization [1, 27]. The randomized parallel algorithms from [1, 27] compute a maximal independent set (MIS) of a graph, i. e., a subset I of V such that no two nodes of I are adjacent and any vertex in G is either in I or is adjacent to a node of I. The computation of a MIS has also been extensively studied in the area of distributed algorithms [4, 26]. An optimal 3 randomized distributed MIS algorithm was presented in [30] where the time and bit complexity (bits per channel) is O(log N ). Using completely independent random bits, Israeli and Itai [22] give a randomized parallel algorithm computing a maximal matching in time O(log N ). While we are looking for k-wise independent functions with small OBDD size, Ka- banets [24] constructed simple Boolean functions which are hard for FBDDs by inves- tigating (almost) Θ(n)-wise independent random functions and showed that the proba- bility tends to 1 as n grows that the size is Ω(2n/n). Our Contribution. In Section 3, we show that the OBDD and FBDD size is at least 2Ω(n+log(p(cid:48))) with p(cid:48) = 2p(1− p) if the function values of fr are k-wise independent with k ≥ 4. We give an efficient construction of OBDDs for 3-wise independent random functions which is based on the known construction of 3-wise independent random variables using BCH-schemes [1]. In Section 4 we investigate a simple construction of a random OBDD due to Bollig and Wegener [11] which generates almost k-wise independent random functions and has size O((kn)2/ε). Reading the actual value of the i-th random bit is just an evaluation of the function on input i which can be done in O(n) time, i. e., it is independent of both k and ε. This construction is used as an input distribution for our implicit algorithm in the experimental evaluation. In Section 5 we use pairwise independent random functions to design a simple maximal matching algorithm that uses only O(log3 N ) functional op- erations in expectation and functions with at most 3 log N variables. This algorithm can easily be extended to the MIS problem and can be implemented as a parallel algorithm using O(log N ) time in expectation or as a distributed algorithm with O(log N ) expected time and bit complexity (and is simpler than in [30]). To the best of our knowledge, this is the first (explicit or implicit) maximal matching (or independent set) algorithm that does not need any knowledge about the graph (like size or node degrees) as well as uses only pairwise independent random variables. Eventually, we evaluate this algorithm em- pirically and show that known implicit maximal matching algorithms are outperformed by the new randomized algorithm. 2 Preliminaries denote the value of x by x :=(cid:80)n−1 Binary Decision Diagrams We denote the set of Boolean functions f : {0, 1}n → {0, 1} by Bn. For x ∈ {0, 1}n i=0 xi · 2i. Further, for l ∈ N, we denote by [l]2 the corresponding binary number of l, i. e., [l]2 = l. In his seminal paper [12], Bryant introduced Ordered Binary Decision Diagrams (OBDDs), that allow a compact repre- sentation of not too few Boolean functions and also supports many functional operations efficiently. 4 Order. A variable order π on the input variables X = {x0, . . . , xn−1} of a Boolean Definition 2.1 (Ordered Binary Decision Diagram (OBDD)). function f ∈ Bn is a permutation of the index set I = {0, . . . , n − 1}. Representation. A π-OBDD is a directed, acyclic, and rooted graph G with two sinks labeled by the constants 0 and 1. Each inner node is labeled by an input variable from X and has exactly two outgoing edges labeled by 0 and 1. Each edge (xi, xj) has to respect the variable order π, i. e., π(i) < π(j). Evaluation. An assignment a ∈ {0, 1}n of the variables defines a path from the root to a sink by leaving each xi-node via the ai-edge. A π-OBDD Gf represents f iff for every a ∈ {0, 1}n the defined path ends in the sink with label f (a). Complexity. The size of a π-OBDD G, denoted by G, is the number of nodes in G. The π-OBDD size of a function f is the minimum size of a π-OBDD representing f . The OBDD size of f is the minimum π-OBDD size over all variable orders π. The width of G is the maximum number of nodes labeled by the same input variable. A simple function is the inner product IPn(x, y) =(cid:76)n−1 The more general read-once branching programs or Free Binary Decision Diagrams (FBDDs) were introduced by Masek [28]. In an FBDD every variable can only be read once on a path from the root to a sink (but the order is not restricted). i=0 xi ∧ yi of two vectors x, y ∈ {0, 1}n. Let π be a variable order where for every 0 ≤ i ≤ n, the variables xi and yi are consecutive. It is easy to see that the π-OBDD representing IPn has size O(n) and width 2. Notice that the π-OBDD size is still O(n) if we replace an input vector, e. g., y, by a constant vector r ∈ {0, 1}n. In the following we describe some important operations on Boolean functions which we will use in this paper (see, e. g., Section 3.3 in [41] for a detailed list). Let f and g be Boolean functions in Bn on the variable set X = {x0, . . . , xn−1}, π a fixed order and let Gf and Gg be π-OBDDs representing f and g, respectively. We denote the subfunction of f where xj for some 0 ≤ j ≤ n − 1 is replaced by a constant a ∈ {0, 1} by fxj =a. 1. Negation: Given Gf , compute a representation for the function f ∈ Bn. Time: O(1) 2. Replacement by constant: Given Gf , an index i ∈ {0, . . . , n−1}, and a Boolean constant ci ∈ {0, 1}, compute a representation for the subfunction fxi=ci. Time: O(Gf) 3. Equality test: Given Gf and Gg, decide whether f and g are equal. Time: O(1) in most implementations (when using so called Shared OBDDs, see [41]), otherwise O(Gf + Gg). 4. Synthesis: Given Gf and Gg and a binary Boolean operation ⊗ ∈ B2, compute a representation for the function h ∈ Bn defined as h := f ⊗ g. Time: O(Gf · Gg) 5. Quantification: Given Gf , an index i ∈ {1, . . . , n} and a quantifier Q ∈ {∃,∀}, compute a representation for the function h ∈ Bn defined as h := Qxi : f where 5 ∃xi : f := fxi=0 ∨ fxi=1 and ∀xi : f := fxi=0 ∧ fxi=1. Time: see replacement by constant and synthesis In addition to the operations mentioned above, in implicit graph algorithms (see the next section) the following operation (see, e. g., [37]) is useful to reverse the edges of a given graph. We will use this operation implicitly by writing for instance f (x, y) and f (y, x) in the pseudo code of our algorithm. Definition 2.2. Let k ∈ N, ρ be a permutation of {1, . . . , k} and f ∈ Bkn with input vectors x(1), . . . , x(k) ∈ {0, 1}n. The argument reordering Rρ(f ) ∈ Bkn with respect to ρ is defined by Rρ(f )(x(1), . . . , x(k)) := f (x(ρ(1)), . . . , x(ρ(k))). This operation can be computed by just renaming the variables and repairing the variable order using 3(k − 1)n functional operations (see [9]). A function f depends essentially on a variable xi iff fxi=0 (cid:54)= fxi=1. A characterization of minimal π-OBDDs due to Sieling and Wegener [39] can often be used to bound the OBDD size. Theorem 2.3 ([39]). Let f ∈ Bn and for all i = 0, . . . , n − 1 let si be the number of different subfunctions which result from replacing all variables xπ(j) with 0 ≤ j ≤ i− 1 by constants and which essentially depend on xπ(i). Then the minimal π-OBDD representing f has si nodes labeled by xπ(i). Lower bound techniques for FBDDs are similar but have to take into account that the order can change for different paths. The following property due to Jukna [23] can be used to show good lower bounds for the FBDD size. Definition 2.4. A function f ∈ Bn with input variables X = {x0, . . . , xn−1} is called r-mixed if for all V ⊆ X with V = r the 2r assignments to the variables in V lead to different subfunctions. Lemma 2.5 ([23]). The FBDD size of a r-mixed function is bounded below by 2r − 1. OBDD-Based Graph Algorithms Let G = (V, E) be a directed graph with node set V = {v0, . . . , vN−1} and edge set E ⊆ V × V . Here, an undirected graph is interpreted as a directed symmetric graph. Implicit algorithms work on the characteristic function χE ∈ B2n of E where n = (cid:100)log N(cid:101) is the number of bits needed to encode a node of V and χE(x, y) = 1 if and only if (vx, vy) ∈ E. Often it is also necessary to store the valid encodings of nodes by the characteristic function χV of V . Besides functional operations, OBDD-based algorithms can use O(polylog V ) additional time, e. g., for constructing OBDDs for a specific function (equality, greater than, inner product, ...). 6 Small probability spaces A succinct representation of our random function is essential for our randomized implicit algorithm. For this, we have to used random functions with limited independence. Definition 2.6 ((Almost) k-wise independence). Let X0, . . . , Xm−1 be m binary random variables. These variables are called k-wise independent with k ≤ m if and only if for all 0 ≤ i1 < . . . ik ≤ m − 1 and for all l1, . . . , lk ∈ {0, 1} Pr [Xi1 = l1 ∧ . . . ∧ Xik = lk] = 2−k and they are called (ε, k)-wise independent iff Pr [Xi1 = l1 ∧ . . . ∧ Xik = lk] − 2−k ≤ ε. (cid:0)r,(cid:2)[i]2 , [i3]2 , . . . ,(cid:2)i2l−1(cid:3) 2 1 ≤ j ≤ l be l uniformly random row vectors, and let the row vector r =(cid:2)r(1), . . . , r(l)(cid:3) ∈ (cid:3)(cid:1) ⊕ rn where i2j−1 for j = 1, . . . , l is computed in the The BCH scheme introduced by Alon et. al [1] is a construction of k-wise indepen- dent random variables X0, . . . , X2n−1 that only needs (cid:98)k/2(cid:99)n + 1 independent ran- dom bits and works as follows: Let rn ∈ {0, 1} be a random bit, r(j) ∈ {0, 1}n for {0, 1}ln+1 be the concatenation of the vectors. For 0 ≤ i ≤ 2n − 1 define Xi = IPln+1 finite field GF (2n). This scheme generates 2l + 1-wise independent random bits [1] (if we exclude X0 and if rn is dropped we obtain 2l-wise independence). We say a function fr : {0, 1}n → {0, 1} is a k-wise ((ε, k)-wise) independent random function iff the random variables Xi = fr([i]2) with 0 ≤ i ≤ 2n − 1 are k-wise ((ε, k)- wise) independent. The BCH scheme gives us an intuition of the complexity of an OBDD representing a k-wise independent function: For k ≤ 3 the random variables of the BCH scheme are Xi = IPln+1 (r, [i]2) ⊕ rn which is basically a simple inner product of two binary vectors. For k ≥ 4, i. e., l ≥ 2, we have to multiply in a finite field to generate the random variables. Since multiplication is hard for OBDDs it seems likely that k-wise independent functions for k ≥ 4 are also hard. 3 OBDD Size of k-wise Independent Random Functions We start with some upper bounds on the OBDD size of 3-wise independent random functions. Notice that by means of the BCH scheme it is not possible to construct a pairwise independent function (which is not 3-wise independent) since X0 = IP (r, 0n) = 0 for every r ∈ {0, 1}n. 7 x0 x2 x3 x5 x2 x3 x5 x0 y0 x1 y1 x1 y1 0 1 0 1 Figure 1: Two π-OBBDs with π = (x0, y0, . . . , xn−1, yn−1) for the functions IP6(x, y) where y is replaced by the constant vector (1, 0, 1, 1, 0, 1) and IP2(x, y). Theorem 3.1. Let ε > 0, n ∈ N, p be a probability with 1/2n ≤ p ≤ 1/2, and π be a variable order on the input variables {x0, . . . , xn−1}. Define p(x) := [fr(x) = 1]. Pr r∈{0,1}n+1 1. We can construct an π-OBDD representing a 3-wise independent function fr : {0, 1}n → {0, 1} in time O(n) such that p(x) = 1/2 for every x ∈ {0, 1}n, and the size of the π-OBDD is O(n) with width 2 for every r ∈ {0, 1}n+1 (see Algorithm 1). 2. We can construct an π-OBDD representing a 3-wise independent function fr : for every 2n p·ε) for every {0, 1}n → {0, 1} in time O( n 2n ≤ p(x) ≤ (1 + ε) · (cid:100)p·2n(cid:101) (cid:100)p·2n(cid:101) x ∈ {0, 1}n, and the size of the π-OBDD is bounded above by O( n r ∈ {0, 1}n+1. p·ε) such that 3. We can compute a function gA(x) : {0, 1}n ← {0, 1} for a random matrix using O(n) functional A ∈ {0, 1}n × {0, 1}n such that Pr operations. Furthermore, using also O(n) functional operations we can compute a priority function GTA(x, y), which is equal to 1 iff vx > vy, where vz ∈ {0, 1}n for all z ∈ {0, 1}n and (v0, . . . , v2n−1) is a pairwise independent random permuta- tion of {0, 1}n. Note: This construction is also possible using only 2n random bits by computing single bits of a0 + x · a1 in F2n. [gA(x) = 1] = A (cid:100)p · 2n(cid:101) 2n Proof. 1. This is an implication of the BCH scheme for 3-wise independent random bits. Recall that for random r = (r0, . . . , rn) ∈ {0, 1}n+1 the random variables Xi(r) = IP (r, [1, [i]2]) for 0 ≤ i ≤ 2n − 1 are 3-wise independent and Pr [Xi = 1] = 1/2 for every i. We define fr(x) = Xx(r) (see Algorithm 1). As described in the preliminaries, the function IP can be represented by an OBDD of width 2 and size O(n) for any variable order if one input vector is replaced by a constant vector. The construction of the OBDD 8 is straightforward (see, e. g., Fig. 1) and can be done in time O(n). 2. Let s ∈ {0, 1}n be the binary representation of (cid:100)p · 2n(cid:101), i. e., s = (cid:100)p · 2n(cid:101). In order to approximate the probability p, we compute t = (cid:100)− log p − log ε(cid:101) random n where the r(i) ∈ {0, 1}n and bits cn−1(x), . . . , cn−t(x) with ci(x) = IP (x, r(i)) ⊕ r(i) n ∈ {0, 1} are chosen independently uniformly at random. Now, our random function r(i) fr(x) is equal to 1 iff cn−1 ··· cn−t0n−t ≤ s. In order to construct the OBDD for fr, we simulate the t OBDDs representing ci on input x ∈ {0, 1}n in parallel: Since all OBDDs have width 2, we can represent the states of the OBDDs representing cn−1, . . . , cn−t after reading the same k input variables with at most 2t OBDD nodes for each 1 ≤ k ≤ n. After reading all n input bits, we know the values of cn−1(x), . . . , cn−t(x) and can easily decide whether cn−1 ··· cn−t0n−t ≤ s because s is a constant. Therefore, the overall OBDD size is O(n · 2t) = O( n p·ε). Each ci(x) is generated by a BCH scheme for 3-wise independent random bits and ci(x) and cj(x) are independent for i (cid:54)= j. Therefore, fr(x) is also 3-wise independent. Let p(cid:48) ∈ (0, 1) such that 2n · p(cid:48) is the value of the binary number consisting of the first t most significant bits of s followed by n − t ones, i. e., 2n · p(cid:48) = sn−1 ··· sn−t1n−t. The function fr ignores the n − t least significant bits of s, therefore, it is equivalent to choose a random vector v ∈ {0, 1}n and check whether v ≤ 2n · p(cid:48) which means that the probability of fr(x) = 1 is p(cid:48). It is s ≤ p(cid:48) · 2n ≤ s + 2n−t − 1 ≤ s + ε · p · 2n ≤ (1 + ε)s and thus (cid:100)p · 2n(cid:101) 2n ≤ Pr [fr(x) = 1] = p(cid:48) ≤ (1 + ε) · (cid:100)p · 2n(cid:101) . 2n 3. For a random matrix A ∈ {0, 1}n × {0, 1}n define ri(x) = aT i · x = IP (ai, x) where ai is the i-th column vector of A. Let fA(x, i) = 1 iff ri(x) = 1. An OBDD reading the bits of i first and then computing the corresponding value of ri(x) has a size of O(n2) since each ri(x) can be computed by an OBDD with width 2 (TODO: experiments suggest rather size of O(n)). This OBDD can also be constructed in time O(n2). Let vx = Ax for x ∈ {0, 1}n. Now define GTA(x, y) = 1 iff vx > vy, i. e., GTA(x, y) = ∃i : fA(x, i) ∧ fA(y, i) ∧ (∀j : (j > i) ⇒ (fA(x, i) ⇔ fA(y, i))). Since each component of vx and vy are pairwise independent, the entire random vectors are also pairwise independent. which is equal to the i-th bit of (cid:100)p · 2n(cid:101) and a negation of the resulting function. The function gA(x) can be constructed in the same way by replacing fA(y, i) with b(i) Can we also construct small OBDDs for k-wise independent random variables with k ≥ 4? Unfortunately, this is not possible. Theorem 3.2. Let X0, . . . , X2n−1 : S → {0, 1} be k-wise independent 0/1-random vari- ables over a sample space S with Pr [Xj = 1] = p for all 0 ≤ j ≤ 2n − 1 and k ≥ 4. For every s ∈ S let fs : {0, 1}n → {0, 1} be defined by fs(x) := Xx(s). Then, for a fixed variable order π, the expected π-OBDD size of fs is bounded below by Ω(2n/3 · (p(cid:48))(1/3)) with p(cid:48) = 2p(1 − p). 9 Algorithm 1 RandomFunc(x,n) Input: Variable vector x of length n ∈ N Output: 3-wise independent function r(x) Let r0, . . . , rn be n + 1 independent random bits i=0 (ri ∧ xi) ⊕ rn fr(x) =(cid:76)n−1 return fr(x) Proof. For the sake of simplicity we omit the index of the function fr. W.l.o.g. let π be the identity order, i.e. π(i) = i for all i = 0, . . . , n − 1. For l ∈ {1, . . . , n} and α ∈ {0, 1}l let fα : {0, 1}n−l → {0, 1} be the subfunction of f where the first l variables x0, . . . , xl−1 are fixed according to α, i.e. fα(z) := fx0=α0,...,xl−1=αl−1(z). Now we fix two different assignments α, α(cid:48) and define 2n−l random variables D(z) := Dα,α(cid:48)(z) such that D(z) = 1 iff fα(z) (cid:54)= fα(cid:48)(z). Since the function values of f are also k-wise independent, for every z ∈ {0, 1}n−l we have E [D(z)] = 2p(1 − p) := p(cid:48) and V ar [D(z)] = E [D(z)2] − E [D(z)]2 = E [D(z)] − E [D(z)]2 = p(cid:48)(1 − p(cid:48)). Let z D(z). We want to find an upper bound on the number of pairs (α, α(cid:48)) with fα = fα(cid:48). The probability that for fixed (α, α(cid:48)) the subfunctions are equal is bounded above by the probability that the difference between D and E [D] is at least E [D], i.e. Pr [fα = fα(cid:48)] = Pr [D = 0] ≤ Pr [D − E [D] ≥ E [D]]. Each random variable D(z) depends on two function values, i.e. these variables are k(cid:48) = (cid:98)k/2(cid:99)-wise independent. Since k(cid:48) ≥ 2 we can use Chebyshev´s inequality D = (cid:80) Pr [fα = fα(cid:48)] ≤ V ar [D] E [D]2 = z V ar [D(z)] (2n−l · p(cid:48))2 = 2n−l · p(cid:48) · (1 − p(cid:48)) (2n−l · p(cid:48))2 ≤ 1 2n−l · p(cid:48) (cid:80) 22l (cid:104) 2l tl (cid:113) 22l α is bounded above by (2l 2n−l·p(cid:48) ≤ Hence, the expected number of pairs (α, α(cid:48)) with fα = f(cid:48) 2 ) 2n−l·p(cid:48) . Therefore, the expected number tl of functions which are equal can be bounded 2l√ above by 2n−l·p(cid:48) . The number sl of different subfunctions fα is bounded below by 2l divided by an upper bound on the number tl of subfunctions fα which are equal, i. e., E [sl] ≥ E E[tl] where the last inequality is due to Jensen's inequality and the fact that g(x) = x−1 is convex on (0,∞). The expected number of equal subfunctions can be lower than 1, therefore we have to do a case study: (cid:105) ≥ 2l 2n−l·p(cid:48) = expectation). 2l(cid:112)2n−l · p(cid:48) ≤ 1 ⇔ l ≤ (1/3)(n + log(p(cid:48))): All 2l subfunctions are different (in 2l(cid:112)2n−l · p(cid:48) > 1: The number of different subfunctions is at least 2l· (cid:112)2n−l · p(cid:48). √ 2n−l·p(cid:48) 2l = 1. 2. 10 For the sake of simplicity, we assume that (1/3)(n + log(p(cid:48))) is an integer, since this does not affect the asymptotic behavior. Due to the first case, we know that the number of different subfunctions has to double after each input bit on the first (n/3) + log(p(cid:48))/3 + 1 levels, i. e., each node must have two outgoing edges to two different nodes which also means that the all subfunctions essentially depend on the next variable. Therefore, the π-OBDD has to be a complete binary tree on the first (n/3) + log(p(cid:48))/3 + 1 levels and the expected π-OBDD size is also Ω(2n/3 · (p(cid:48))1/3). If (cid:80)n−1 probability 1 −(cid:80)n−1 The following theorem shows that k-wise independent random functions with k ≥ 4 are hard even for FBDDs (and with it for OBDDs and all variable orders). The general strategy of the proof of the next theorem is similar to the proof in [40] where the OBDD size of completely independent random functions was analyzed: We bound the probability pl that there is a variable order such that the number of OBDD nodes on level l deviates too much from the expected value. l=0 pl < 1 holds, then with l=0 pl > 0 there is no such deviation in any level of the OBDD for all variable orders. The differences lie in the detail: In [40] the function values are completely independent and, therefore, the calculation can be done more directly and with better estimations. We have to take the detour over the number of subfunctions which are equal (as in Theorem 3.2) and can use only Markov's inequality to calculate the deviation of the expectation. Furthermore, because of the independence Wegener [40] was able to do a more subtle analysis of the OBDD size by investigating the effects of the OBDD minimization rules separately. Theorem 3.3. Let X0, . . . , X2n−1 : S → {0, 1} be k-wise independent 0/1-random vari- ables over a sample space S with Pr [Xj = 1] = p for all 0 ≤ j ≤ 2n − 1 and k ≥ 4. For every s ∈ S let fs : {0, 1}n → {0, 1} be defined by fs(x) := Xx(s). Then, there is an r-mixed function fs with r = Ω(n + log(p(cid:48)) − log n) with p(cid:48) = 2p(1 − p). Proof. First, we bound the probability that the number tl of subfunctions which are equal deviates by a factor of δl from the expectation. Second, as in Theorem 3.2, we show an upper bound on the level l for which the number of equal subfunctions is lower or equal than 1, i. e., the OBDD has to be a complete binary tree until this level. As we know, the expected number of pairs (α, α(cid:48)) with fα = f(cid:48) α is bounded above by 2n−l·p(cid:48) . Due to the dependencies, using Markov's inequality is the best we can do µl := 22l to bound the deviation from the expectation. Thus, we have Pr [No. pairs (α, α(cid:48)) with fα = f(cid:48) α ≥ δl · µl] ≤ 1 δl . Due to Theorem 2.3, the definition of the subfunctions corresponding to OBDD nodes on level l, i. e., the definition of the subfunctions fα, depends only on the first l variables with respect to the variable order. Thus, we have to distinguish only(cid:0)n choose these variables. Let δl :=(cid:0)n (cid:1) possibilities to (cid:1) · (n + 1). Then the probability, that for all levels and variable orders the number of pairs (α, α(cid:48)) with fα = fα(cid:48) is at most δl · µl is bounded l l 11 below by 1 − n/(n + 1) > 0. Note that this also implies that tl ≤ √ δl · µl for all levels l and variable orders. δlµl ≤ 1 and √ √ As in the proof of Theorem 3.2, the next step consists of the investigation of two √ δlµl > 1. Here, we focus only on the first case. In other words, cases: δlµl ≤ 1 or, equivalently, (1/2) log(δlµl) ≤ 0 we compute an upper bound T such that for all l ≤ T . For the calculations, we need a known bound for the binomial coefficient (cid:1) ≤ n · H(k/n) where H(x) = −x log(x) − (1 − x) log(1 − x) is the binary entropy log(cid:0)n k function. It holds 1 2 log(δlµl) ≤ 1 2 (3l − n + log(n) + 1 − log(p(cid:48)) + n · H n √ Let l = ε · n for some ε < 1/2. We want to maximize ε such that log( (cid:18) l (cid:19) ). δlµl) ≤ 0. 1 2 ⇔ (3(εn) − n + log(n) + 1 − log(p(cid:48)) + n · H(ε)) ≤ 0 3ε + H(ε) ≤ 1 − log(1/p(cid:48)) − 1 n − log n n n 1 Using ≤ 1 + 2x for 0 ≤ x ≤ 1/2 and log(1 + x) ≤ x for x > −1, we can bound √ 3ε + H(ε) by 6 ε (see Appendix for the details). Thus, if (cid:18)log(1/p(cid:48)) 1 − x ε ≤ √ √ δlµl) ≤ 0. Since l = ε·n and the maximal ε is in Ω ε ≤ 1 6 − 1 6 (cid:19) (cid:18) log n = Ω 1 n + + n n · (cid:19) , 1 − log(1/p(cid:48)) + log n (cid:16) (cid:17) 1 − log(1/p(cid:48))+log n n n such that it is log( √ log( δlµl) ≤ 0, there is a function fs which is r-mixed with r = Ω(n+log(p(cid:48))−log n). Due to Lemma 2.5, the last Theorem gives us an lower bound even for FBDDs. Corollary 3.4. Let X0, . . . , X2n−1 be k-wise independent 0/1-random variables over a sample space S with Pr [Xj = 1] = p for all 0 ≤ j ≤ 2n − 1 and k ≥ 4. For every s ∈ S let fs : {0, 1}n → {0, 1} be defined by fs(x) := Xx(s). Then, there is a function fs such that the FBDD size is at least 2Ω(n+log(p(cid:48))−log n). 4 Construction of Almost k-wise Independent Random Functions. The gap between the OBDD size of 3-wise independent random functions and 4-wise independent random functions is exponentially large. In order to see what kind of random functions have an OBDD size which is in between these bounds, we show that a construction of a random OBDD due to [11] of size O((nk)2/ε) generates (ε, k)-wise independent functions. The idea is to construct a random OBDD with fixed width w. If w is large enough, the function values of k different inputs are almost uniformly 12 distributed because the paths of the k inputs in the OBDD are likely to be almost independent. For 0 ≤ i ≤ n − 1 let layer Li consists of w nodes labeled by xi and layer Ln be the two sinks. For all 0 ≤ i ≤ n − 1 we choose the 0/1-successors of every node in layer Li independently and uniformly at random from the nodes in layer Li+1. Then we pick a random node in layer L0 as the root of the OBDD. Theorem 4.1. For w ≥ k + nk(k + 1)/ε the above random process generates (ε, k)-wise independent random functions. Proof. Let a1, . . . , ak ∈ {0, 1}n be k different inputs and p be the probability that the function values of these inputs are α1, . . . , αk ∈ {0, 1}. Let P1, . . . , Pk the k paths of a1, . . . , ak to the layer Ln−1, i. e., the paths end in a node labeled by xn−1. Let Di be the event that the paths P1, . . . , Pi end in different nodes. Since the inputs are different, every Pi has to use an edge which is not used by any other path and, therefore, it holds Pr [Di Di−1] ≥ (1− i−1 w )n. w/i−1 ≥ 1 − ε for w ≥ k + nk(k + 1)/ε ≥ k + nk(k + − n 1)(1/ ln( 1 If all paths end in different nodes, then the function values of the k inputs are independent and uniformly distributed, i. e., p ≥ 2−k · Pr [Dk] ≥ 2−k − ε and p ≤ 1 − (1 − 2−k) · Pr [Dk] ≤ 2−k + ε which completes the proof. Pr [Di Di−1] ≥ k(cid:81) w )n ≥ k(cid:81) w )n and with it Pr [Dk] = (1 − i−1 (1− i−1 i=2 k(cid:81) i=2 1−ε)). k(cid:81) i=2 We have e i=2 5 Randomized Implicit Algorithms Complexity Class Only a small modification is necessary to extend Sawitzki's simulation results from [36] and [38] to show that the set of problems which can solved by a randomized implicit algorithm is equal to the set of problems solved by a randomized parallel algorithm. In the implicit setting, we just add the possibility to construct random functions r : {0, 1}l → {0, 1} with l = O(log N ). Constructing such functions in parallel is easy. The other way round, i. e., simulating a randomized parallel algorithm by a randomized implicit algorithm, the only difference is the set of input variables of the circuit (which represents the (randomized) parallel algorithm). A deterministic circuit has only N input variables whereas the random circuit has additional O(N c) random inputs for a constant c. Assuming we can construct a random function r : {0, 1}l → {0, 1} with l = O(log N ), we can set the input variables correctly for the simulation (in the same way as in [38]). Randomized Maximal Matching Algorithm We use the construction of 3-wise independent random functions from the last section to design a randomized maximal matching algorithm. Here, the main drawback of our random construction is the missing possibility to use different probabilities for the nodes. 13 Algorithm 2 Randomized implicit maximal matching algorithm Input: Graph χE(x, y) Output: Maximal matching χM (x, y) χM (x, y) = 0 while χE(x, y) (cid:54)≡ 0 do χE(cid:48)(x, y) = χE(x, y) // Compute set of nodes with two or more incident edges T (x) = ∃z, y : (z (cid:54)= y) ∧ χE(cid:48)(x, y) ∧ χE(cid:48)(x, z) N ewEdges(x, y) = 0 while T (x) (cid:54)≡ 0 do // Initial matching // Construct 3-wise independent random functions (see Algorithm 1) fr1(x) = RandomF unc(x, n) and fr2(y) = RandomF unc(y, n) F (x, y) = (x > y) ∧ (fr1(x) ⊕ fr2(y)) F (x, y) = F (x, y) ∨ F (y, x) χE(cid:48)(x, y) = χE(cid:48)(x, y) ∧ F (x, y) T (x) = ∃z, y : (z (cid:54)= y) ∧ χE(cid:48)(x, y) ∧ χE(cid:48)(x, z) // Store isolated edges in NewEdges N ewEdges(x, y) = N ewEdges(x, y) ∨ (χE(cid:48)(x, y) ∧ T (x) ∧ T (y)) // Delete edges with probability 1/2 // Update T (x, y) end while χM (x, y) = χM (x, y) ∨ N ewEdges(x, y) M atched(x) = ∃y : χM (x, y) χE(x, y) = χE(x, y) ∧ M atched(x) ∧ M atched(y) matched nodes // Add edges to current matching // Delete edges incident to end while return χM (x, y) Randomized algorithms for maximal independent set using pairwise independence like in [1] or [27] choose a node with a probability proportional to the node degree. In order to simulate these selections by our construction, we delete each edge with probability 1/2 as long as there are other incident edges. Finally, we add the remaining isolated edges to the matching. Algorithm 2 shows the whole randomized implicit maximal matching algorithm. We realize the edge deletions of the inner loop in the following way: We construct two 3-wise independent random functions fr1(x), fr2(y) using Algorithm 1 and set F (x, y) = (x > y) ∧ (fr1(x) ⊕ fr2(y)). Since Pr [fr1(x) ⊕ fr2(y) = 1] = [fr1(x) (cid:54)= fr2(y)] = 1/4+1/4 = 1/2 for inputs x ≤ y the function F (x, y) deletes such Pr r1,r2 edges as required. Because we are dealing with undirected graphs, we want F (x, y) = F (y, x) for every (x, y). Therefore, we set F (x, y) = F (x, y) ∨ F (y, x) and delete the edges with the operation χE(x, y) = χE(x, y) ∧ F (x, y). We say that an edge e ∈ E(cid:48) (before the inner while-loop) survives iff e ∈ E(cid:48) after the r1,r2 inner while-loop of algorithm 2. 14 Lemma 5.1. For every e = {u, v} ∈ E with degE(u) > 1 or degE(v) > 1 before the inner 8·(degE (u)+degE (v)−2). while-loop in algorithm 2 the probability that e survives is at least Proof. Let e = {u, v} ∈ E be an edge before the inner while-loop and Re be the num- ber of rounds until edge e is deleted. The random bits in each iteration are 3-wise independent and the iterations themselves are completely independent. Thus, the vari- ables Re are also 3-wise independent. Denote by N (e) = {e(cid:48) ∈ E e ∩ e(cid:48) (cid:54)= ∅} the neighborhood of e, i. e., all edges incident to u or v. Then we have Pr [e survives] = 1 Pr [Re is unique maximum in {Re(cid:48) e(cid:48) ∈ N (e)}]. It is easy to see that Pr [Re = i] =(cid:0) 1 (cid:1)i (cid:1)z−1 . Therefore, for i ≥ 1. Let e(cid:48) ∈ N (e) and e(cid:48) dependent, we have Pr [Re(cid:48) ≥ z Re = z] = Pr [Re(cid:48) ≥ z] = the probability that there is an edge e(cid:48) ∈ N (e) \ e with Re(cid:48) ≥ z is at most , i. e., Re is unique maximum with probability at least 1 − N (e)−1 . This is greater 2z−1 than 0 for z ≥ log(N (e) − 1) + 2. Finally, we have Pr [Re is unique maximum] ≥ (cid:54)= e and z ≥ 1 be fixed. Since the Re are 3-wise in- (cid:1)i =(cid:0) 1 (cid:0) 1 2 N (e)−1 2z−1 ∞(cid:80) i=z 2 2 1 − N (e)−1 2log(N (e)−1)+1 8·(degE (u)+degE (v)−2) 1 (cid:1)log(N (e)−1)+2 ·(cid:16) (cid:0) 1 2 (cid:17) ≥ The number of deleted edges for a matching edge (u, v) that is added to the matching is deg(u) + deg(v) − 2 if we do not count the matching edge itself. Thus, the expected number of deleted edges is Ω(E) at the end of the outer loop. This gives us the final result. Theorem 5.2. Let G = (V, E) be a graph with N nodes. All functions used in algorithm 2 on the input χE depend on at most 3 log N variables. The expected number of operations is O(log3 N ). Proof. Each iteration of the inner-loop needs O(log N ) operations. Since we halve the number of edges in expectation in each iteration of this loop, the expected number of iterations is O(log N ). The edges surviving the inner loop are those that are added to the matching. After adding a set of edges to the matching, all edges that are incident to a matched node are deleted from the graph in the outer loop. The number deleted edges for a matching edge (u, v) that is added to the matching is deg(u) + deg(v) − 2 if we do not count the matching edge itself. Thus, by Lemma 3, the expected number of edges deleted in this step is at least (degE(u) + degE(v) − 2) · 1 8 · (degE(u) + degE(v) − 2) = E/8. (cid:88) e={u,v}∈E This implies that the expected number of iterations of the outer-loop is also bounded above by O(log N ). Application to the Maximal Independent Set Problem With a similar idea we are able to design a distributed MIS algorithm: Each node v draws a random bit until this bit is 0. Let rv be the number of bits drawn by node v. 15 We send rv to all neighbors and include node v to the independent set iff rv is a local minimum. The expected number of bits for each channel is 1. A similar analysis as before show that we have an maximal independent set after O(log N ) steps in expectation and the overall expected number of bits per channel is O(log N ). Experimental Results. All algorithms are implemented in C++ using the BDD framework CUDD 2.5.01 by F. Somenzi and were compiled with Visual Studio 2013 in the default 32-bit release configuration. All source files, scripts and random seeds will be publicly available2. The experiments were performed on a computer with a 2.5 GHz Intel Core i7 processor and 8 GB main memory running Windows 8.1. The runtime is measured by used processor time in seconds and the space usage of the implicit algorithm is given by the maximum SBDD size which came up during the computation, where an SBDD is a collection of OBDDs which can share nodes. Note that the maximum SBDD size is independent of the used computer system. For our results, we took the mean value over 50 runs on the same graph. Due to the small variance of these values, we only show the mean in the diagrams/tables. We omit the algorithm by Bollig and Proger [10] because the memory limitation was exceeded on every instance presented here. We choose three types of input instances: First, we used our construction from section 4 as an input distribution in the following way: If the 1 sink is chosen with probability p as a successor of nodes in layer Ln−1 the expected size of f−1(x) is p · 2n. For a fixed N = 217, we used p as a density parameter for our input graph and want to analyze how the density influences the running time of the algorithms. Second, we run the algorithms on some bipartite graphs from a real advertisement application within Google3 [32]. The motivation was to check whether the randomized algorithm is competitive or even better on instances where the algorithm by Hachtel and Somenzi (HS) [20] is running very well. Third, we use non-bipartite graphs from the university of Florida sparse matrix collection [16]. Since HS is designed for bipartite graphs, a preprocessing step computing a bipartition of these graphs are needed to compute a maximal matching (see, e. g., [10]) while our algorithm also works on general graphs. In the experiments we use the following implementation of our algorithm denoted by RM. In order to minimize the running time for computation of the set of nodes with two or more incident edges, we sparsify the graph at the beginning of the outer while loop by deleting each edge with probability 1/2 and repeating this D times. Initially, we set D = log E and decrease D by 1 at the end of the outer loop. Asymptotically, the running time does not change since after O(log N ) iterations, i. e., D = 0, it does exactly the same as original algorithm. Initial experiments showed that this is superior to the original algorithm. 1http://vlsi.colorado.edu/~fabio/CUDD/ 2http://ls2-www.cs.uni-dortmund.de/~gille/ 3Graph data files can be found at http://www.columbia.edu/~cs2035/bpdata/ 16 Instance 333SP adaptive as-Skitter hollywood-2009 roadNet-CA roadNet-PA roadNet-TX Nodes 3712815 6815744 1696415 1139905 1971281 1090920 1393383 Edges Time (sec) Space (SBDD size) 22217266 27248640 22190596 113891327 5533214 3083796 3843320 1140.54 403.82 337.53 418.36 136.18 75.26 92.62 66968594 22767094 32020282 62253086 13177668 7633318 9125438 Table 1: Running time and space usage of RM on the graphs from [16] Figure 2: Running times of HS and RM on the real world instances. On the random instances the running time and space usage of RM was more or less unaffected by the density of the graph while HS was very slow for small values of p and gets faster with increasing density. For p ≤ 0.2 RM was much faster than HS (see Fig. 3 4). In Fig. 2 we see that on the bipartite real world instances RM is similar to HS if the running time is negligibly small but on the largest instances (number 15 to 20) RM is much faster. the graphs from [16] were intentionally chosen to show the potential of RM and indeed do so: It was not possible to run HS on these graphs due to memory limitations whereas RM computed a matching in reasonable time and space (see Table 1). Both graphs from and [16] have very small density and the experiments on the random graphs seem to support the hypothesis that RM is a better choice than HS for such graphs. 17 0.01 0.1 1 10 0 2 4 6 8 10 12 14 16Seconds (logscaled)Graph NumberHSRM 0.01 0.1 1 10171921232527293133Seconds (logscaled)Graph Number Figure 3: Running times of HS and RM on the random instances. 18 0.20.40.60.8050100150200250300k = 4Prob.RuntimelllllllllllllllllllRMHS0.20.40.60.80100200300k = 5Prob.RuntimelllllllllllllllllllRMHS0.20.40.60.80100200300400k = 6Prob.RuntimelllllllllllllllllllRMHS0.20.40.60.80100200300400k = 7Prob.RuntimelllllllllllllllllllRMHS Figure 4: Space usage of HS and RM on the random instances. Further Applications. Extending our matching algorithm to the more general f -matching, where each node v is allowed to have at most f (v) incident matching edges, is an interesting question. Designing other randomized implicit algorithms, e. g., for minimum spanning tree, where random sampling of subgraphs are necessary, seems straightforward and initial exper- iments showed that this could lead to faster algorithms than the known deterministic ones. 19 0.20.40.60.85.0e+061.5e+072.5e+07k = 4Prob.SBDD sizelllllllllllllllllllRMHS0.20.40.60.81e+073e+075e+07k = 5Prob.SBDD sizelllllllllllllllllllRMHS0.20.40.60.82e+076e+07k = 6Prob.SBDD sizelllllllllllllllllllRMHS0.20.40.60.82e+076e+071e+08k = 7Prob.SBDD sizelllllllllllllllllllRMHS Acknowledgements I would like to thank Beate Bollig, Melanie Schmidt and Chris Schwiegelshohn for the valuable discussions and for their comments on the presentation of the paper. References [1] Alon, N., Babai, L., and Itai, A. A fast and simple randomized parallel algorithm for the maximal independent set problem. J. Algorithms 7, 4 (1986), 567 -- 583. [2] Alon, N., Goldreich, O., Hastad, J., and Peralta, R. Simple construction of almost k-wise independent random variables. Random Struct. Alg. 3, 3 (1992), 289 -- 304. [3] Alon, N., Matias, Y., and Szegedy, M. The space complexity of approx- imating the frequency moments. J. Comp. and System Sc. 58, 1 (1999), 137 -- 147. [4] Awerbuch, B., Goldberg, A. V., Luby, M., and Plotkin, S. A. Network decomposition and locality in distributed computation. In FOCS (1989), pp. 364 -- 369. [5] Bloem, R., Gabow, H. N., and Somenzi, F. An algorithm for strongly con- nected component analysis in nlogn symbolic steps. Formal Meth. in System Design 28, 1 (2006), 37 -- 56. [6] Bollig, B. On symbolic OBDD-based algorithms for the minimum spanning tree problem. Theor. Comput. Sci. 447 (2012), 2 -- 12. [7] Bollig, B., and Capelle, M. Priority functions for the approximation of the metric TSP. Inf. Proc. Letters 113, 14-16 (2013), 584 -- 591. [8] Bollig, B., Gill´e, M., and Proger, T. Implicit computation of maximum bipartite matchings by sublinear functional operations. In TAMC (2012), pp. 473 -- 486. [9] Bollig, B., Lobbing, M., and Wegener, I. On the effect of local changes in the variable ordering of ordered decision diagrams. Inf. Proc. Letters 59, 5 (1996), 233 -- 239. [10] Bollig, B., and Proger, T. An efficient implicit OBDD-based algorithm for maximal matchings. In LATA (2012), pp. 143 -- 154. [11] Bollig, B., and Wegener, I. personal communication, 2014. [12] Bryant, R. E. Graph-based algorithms for boolean function manipulation. IEEE Transactions on Computers 35, 8 (1986), 677 -- 691. 20 [13] Burch, J. R., Clarke, E. M., McMillan, K. L., Dill, D. L., and Hwang, L. J. Symbolic model checking: 1020 states and beyond. Inf. and Comp. 98, 2 (1992), 142 -- 170. [14] Chor, B., and Goldreich, O. On the power of two-point based sampling. J. Complexity 5, 1 (1989), 96 -- 106. [15] Coudert, O. Doing two-level logic minimization 100 times faster. In SODA (1995), pp. 112 -- 121. [16] Davis, T. A., and Hu, Y. The University of Florida Sparse Matrix Collection. ACM Trans. on Math. Soft. 38, 1 (Nov. 2011), 1:1 -- 1:25. [17] Gentilini, R., Piazza, C., and Policriti, A. Computing strongly connected components in a linear number of symbolic steps. In SODA (2003), pp. 573 -- 582. [18] Gentilini, R., Piazza, C., and Policriti, A. Symbolic graphs: Linear solu- tions to connectivity related problems. Algorithmica 50, 1 (2008), 120 -- 158. [19] Gill´e, M. OBDD-based representation of interval graphs. In WG, vol. 8165 of LNCS. Springer Berlin Heidelberg, 2013, pp. 286 -- 297. [20] Hachtel, G. D., and Somenzi, F. A symbolic algorithms for maximum flow in 0-1 networks. F. Meth. in Sys. Design 10, 2/3 (1997), 207 -- 219. [21] Hojati, R., Touati, H., Kurshan, R. P., and Brayton, R. K. Efficient ω-regular language containment. In Comp. Aided Verification, vol. 663 of LNCS. Springer, 1993, pp. 396 -- 409. [22] Israeli, A., and Itai, A. A fast and simple randomized parallel algorithm for maximal matching. Inf. Process. Lett. 22, 2 (1986), 77 -- 80. [23] Jukna, S. Entropy of contact circuits and lower bounds on their complexity. Theor. Comput. Sci. 57 (1988), 113 -- 129. [24] Kabanets, V. Almost k-wise independence and hard boolean functions. Theor. Comput. Sci. 297, 1-3 (2003), 281 -- 295. [25] Lai, Y., Pedram, M., and Vrudhula, S. B. K. EVBDD-based algorithms for integer linear programming, spectral transformation, and function decomposition. IEEE Trans. on CAD of Int. Circuits and Systems 13, 8 (1994), 959 -- 975. [26] Linial, N. Locality in distributed graph algorithms. SIAM J. Comput. 21, 1 (1992), 193 -- 201. [27] Luby, M. A simple parallel algorithm for the maximal independent set problem. SIAM Journal on Computing 15, 4 (1986), 1036 -- 1053. 21 [28] Masek, W. A fast algorithm for the string editing problem and decision graph complexity. Master's thesis, MIT, 1976. [29] Meer, K., and Rautenbach, D. On the OBDD size for graphs of bounded tree- and clique-width. Discrete Mathematics 309, 4 (2009), 843 -- 851. [30] M´etivier, Y., Robson, J. M., Saheb-Djahromi, N., and Zemmari, A. An optimal bit complexity randomized distributed MIS algorithm. Distributed Com- puting 23, 5-6 (2011), 331 -- 340. [31] Naor, J., and Naor, M. Small-bias probability spaces: Efficient constructions and applications. SIAM J. Comput. 22, 4 (1993), 838 -- 856. [32] Negruseri, C. S., Pasoi, M. B., Stanley, B., Stein, C., and Strat, C. G. Solving maximum flow problems on real world bipartite graphs. In ALENEX (2009), pp. 14 -- 28. [33] Nunkesser, R., and Woelfel, P. Representation of graphs by OBDDs. Dis- crete Applied Mathematics 157, 2 (2009), 247 -- 261. [34] Savick´y, P. Improved boolean formulas for the ramsey graphs. Random Struct. Algorithms 6, 4 (1995), 407 -- 416. [35] Sawitzki, D. Implicit flow maximization by iterative squaring. In SOFSEM (2004), pp. 301 -- 313. [36] Sawitzki, D. The complexity of problems on implicitly represented inputs. In SOFSEM (2006), pp. 471 -- 482. [37] Sawitzki, D. Exponential lower bounds on the space complexity of OBDD-based graph algorithms. In LATIN (2006), pp. 781 -- 792. [38] Sawitzki, D. Implicit simulation of FNC algorithms. Electronic Colloquium on Computational Complexity (ECCC) 14, 028 (2007). [39] Sieling, D., and Wegener, I. NC-algorithms for operations on binary decision diagrams. Parallel Processing Letters 3 (1993), 3 -- 12. [40] Wegener, I. The size of reduced OBDDs and optimal read-once branching pro- IEEE Trans. on Comp. 43, 11 (1994), grams for almost all boolean functions. 1262 -- 1269. [41] Wegener, I. Branching programs and binary decision diagrams. SIAM Mono- graphs on Discrete Mathematics and Applications, 2000. [42] Woelfel, P. Symbolic topological sorting with OBDDs. J. Disc. Alg. 4 (2006), 51 -- 71. 22 Proof of Theorem 3.3 √ Claim .3. Let ε ≤ 1/2. Then 3ε + H(ε) ≤ 6 ε. Proof. Recall that H(x) = −x log(x) − (1 − x) log(1 − x). Using 0 ≤ x ≤ 1/2 and log(1 + x) ≤ x for x > −1 we have 3ε + H(ε) = 3ε + ε log(1/ε) + (1 − ε) · log(1/(1 − ε)) ≤ 3ε + ε(cid:112)1/ε + log(1/(1 − ε)) 1 1 − x ≤ 1 + 2x for √ ε + 2ε ≤ 3ε + √ ≤ 6 ε. Experiments Number Running Time (RM) Running Time (HS) SBDD Size (RM) SBDD Size (HS) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0.243 0.264 0.256 0.059 0.055 0.042 0.064 0.042 0.055 0.09 0.099 0.105 0.067 0.058 0.091 2.565 0.475 0.571 0.567 0.066 0.041 0.043 0.067 0.073 0.072 0.12 0.11 0.17 0.052 0.07 0.066 6.259 567210 555968 553924 153300 161476 153300 196224 163520 169652 240170 237104 245280 236082 242214 284116 3115056 1346996 1394008 1394008 220752 194180 194180 252434 279006 279006 368942 368942 368942 245280 310688 328062 7887796 Table 2: Running times and space usage of RM and HS on real-world instances from [32]. 23 Number Running Time (RM) Running Time (HS) SBDD Size (RM) SBDD Size (HS) 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 2.545 4.002 1.112 0.913 0.828 0.073 0.059 0.095 0.043 0.037 0.058 0.203 0.188 0.244 0.632 0.568 0.458 6.167 6.329 1.81 2.043 1.931 0.036 0.046 0.036 0.022 0.021 0.018 0.331 0.348 0.305 1.176 1.114 0.568 3115056 3115056 2053198 2035824 2035824 182938 163520 162498 134904 135926 169652 346458 317842 319886 1314292 1280566 950460 7874510 7874510 2320962 2485504 2485504 231994 240170 240170 134904 135926 135926 731752 677586 677586 2100210 2104298 1410360 Table 3: Running times and space usage of RM and HS on real-world instances from [32]. 24 Figure 5: Standard deviations of the running times. 25 0.20.40.60.805101520253035k = 4Prob.SD of runtimelllllllllllllllllllRMHS0.20.40.60.805101520k = 5Prob.SD of runtimelllllllllllllllllllRMHS0.20.40.60.80510152025k = 6Prob.SD of runtimelllllllllllllllllllRMHS0.20.40.60.805101520253035k = 7Prob.SD of runtimelllllllllllllllllllRMHS Figure 6: Standard deviation of the space usage. 26 0.20.40.60.8050000015000002500000k = 4Prob.SD of spacelllllllllllllllllllRMHS0.20.40.60.850000015000003000000k = 5Prob.SD of spacelllllllllllllllllllRMHS0.20.40.60.80e+002e+064e+06k = 6Prob.SD of spacelllllllllllllllllllRMHS0.20.40.60.80e+002e+064e+066e+06k = 7Prob.SD of spacelllllllllllllllllllRMHS Number 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 U 136 137 137 40 41 41 125 86 86 289 290 290 50 51 51 164 W 18872 18872 18888 7086 7086 7093 7107 7117 7127 16653 16846 16904 13360 16264 21016 288826 Edges 222951 222951 222951 33609 33609 33609 33609 33609 33609 33051 33051 33051 50040 56577 56577 2523313 Number 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 31 U 165 165 196 197 197 40 41 41 35 36 36 934 935 935 125 126 126 W 288826 288858 89030 89044 89044 28489 28944 28944 11361 11588 11695 8752 8896 9028 55058 56858 57926 Edges 2523313 2523313 1080027 1080041 1080041 43629 43629 43629 22279 22279 22279 42711 42711 42711 844598 844598 477356 Table 4: Properties of the real-world instances from [32]. 27
1705.00997
1
1705
2017-05-02T14:29:54
Dynamic Space Efficient Hashing
[ "cs.DS" ]
We consider space efficient hash tables that can grow and shrink dynamically and are always highly space efficient, i.e., their space consumption is always close to the lower bound even while growing and when taking into account storage that is only needed temporarily. None of the traditionally used hash tables have this property. We show how known approaches like linear probing and bucket cuckoo hashing can be adapted to this scenario by subdividing them into many subtables or using virtual memory overcommitting. However, these rather straightforward solutions suffer from slow amortized insertion times due to frequent reallocation in small increments. Our main result is DySECT ({\bf Dy}namic {\bf S}pace {\bf E}fficient {\bf C}uckoo {\bf T}able) which avoids these problems. DySECT consists of many subtables which grow by doubling their size. The resulting inhomogeneity in subtable sizes is equalized by the flexibility available in bucket cuckoo hashing where each element can go to several buckets each of which containing several cells. Experiments indicate that DySECT works well with load factors up to 98\%. With up to 2.7 times better performance than the next best solution.
cs.DS
cs
Dynamic Space Efficient Hashing Tobias Maier and Peter Sanders Karlsruhe Institute of Technology, Karlsruhe, Germany {t.maier,sanders}@kit.edu Abstract We consider space efficient hash tables that can grow and shrink dynamically and are always highly space efficient, i.e., their space consumption is always close to the lower bound even while growing and when taking into account storage that is only needed tem- porarily. None of the traditionally used hash tables have this property. We show how known approaches like linear probing and bucket cuckoo hashing can be adapted to this scenario by subdividing them into many subtables or using virtual memory over- committing. However, these rather straightforward solutions suffer from slow amortized insertion times due to frequent reallocation in small increments. Our main result is DySECT (Dynamic Space Efficient Cuckoo Table) which avoids these prob- lems. DySECT consists of many subtables which grow by doubling their size. The resulting inhomo- geneity in subtable sizes is equalized by the flexibil- ity available in bucket cuckoo hashing where each element can go to several buckets each of which containing several cells. Experiments indicate that DySECT works well with load factors up to 98%. With up to 2.7 times better performance than the next best solution. 1 Introduction Dictionaries represented as hash tables are among the most frequently used data structures and often play a critical role in achieving high performance. Having several compatible implementations, which perform well under different conditions and can be interchanged freely, allows programmers to easily adapt known solutions to new circumstances. One aspect that has been subject to much in- vestigation is space efficiency [3, 4, 7, 8, 17, 19]. Modern space efficient hash tables work well even when filled to 95% and more. To reach filling de- grees like this, the table has to be initialized with the correct final capacity, thereby, requiring pro- grammers to know tight bounds on the maximum number of inserted elements. This is typically not re- alistic. For example, a frequent application of hash tables aggregates information about data elements by their key. Whenever the exact number of unique keys is not known a priori, we have to overestimate the initial capacity to guarantee good performance. Dynamic space efficient data structures are neces- sary to guarantee both good performance and low overhead independent of the circumstances. To visualize this, assume the following scenario. During a word count benchmark, we know an up- per bound nmax to the number of unique words. Therefore, we construct a hash table with at least nmax cells. If an instance only contains 0.7 · nmax unique words, no static hash table can fill ratios greater than 70%. Thus, dynamic space efficient hash tables are required to achieve guaranteed near- optimal memory usage. In scenarios where the final size is not known, the hash table has to grow closely with the actual number of elements. This cannot be achieved efficiently with any of the current tech- niques used for hashing and migration. Many libraries – even ones that implement space efficient hash tables – offer some kind of growing mechanism. However, all existing implementations either lose their space efficiency or suffer from de- graded performance once the table grows above its original capacity. Growing is commonly imple- mented either by creating additional hash tables – decreasing performance especially for lookups or by migrating all elements to a new table – losing the space efficiency by multiplying the original size. To avoid the memory overhead of full table mi- grations, during which both the new and the old table coexist, we propose an in-place growing tech- nique that can be adapted to most existing hashing schemes. However, frequent migrations with small relative size changes remain necessary to stay space efficient at all times. To avoid both of these pitfalls we propose a vari- ant of (multi-way) bucket cuckoo hashing [7, 8]. A 1 technique where each element can be stored in one of several associated constant sized buckets. When all of them are full, we move an element into one of its other buckets to make space. To solve the problem of efficient migration, we split the table into multiple subtables, each of which can grow independently of all others. Because the buckets associated with one element are spread over the different subtables, growing one subtable alleviates pressure from all others by allowing moves from a dense subtable to the newly-grown subtable. Doubling the size of one subtable increases the overall size only by a small factor while moving only a small number of elements. This makes the size changes easy to amortize. The size and occupancy imbalance between subtables (introduced by one subtable growing) is alleviated using displacement techniques common to cuckoo hashing. This allows our table to work efficiently at fill rates exceeding 95%. We begin our paper by presenting some previous work (Section 2). Then we go into some notations (Section 3) that are necessary to describe our main contribution DySECT (Section 4). In Section 5 we show our in-place migration techniques. Afterwards, we test all hash tables on multiple benchmarks (Sec- tion 6) and draw our conclusion (Section 7) 2 Related Work The use of hash tables and other hashing based algorithms has a long history in computer science. The classical methods and results are described in all major algorithm textbooks [14]. Over the last one and a half decades, the field has regained attention, both from theoretical and the practical point of view. The initial innovation that sparked this attention was the idea that storing an element in the less filled of two "random" chains leads to incredibly well balanced loads. This concept is called the power of two choices [16]. It led to the development of cuckoo hashing [19]. Cuckoo hashing extends the power of two choices by allowing to move elements within the table to create space for new elements (see Section 3.2 for a more elaborated explanation). Cuckoo hashing revitalized research into space efficient hash tables. Probabilistic bounds for the maximum fill degree [3, 4] and expected displacement distances [9, 10] are often highly non-trivial. Cuckoo hashing can be naturally generalized into two directions in order to make it more space effi- cient: allowing H choices [8] or extending cells in the table to buckets that can store B elements. We will summarize this under the term bucket cuckoo hashing. Further adaptations of cuckoo hashing in- clude:multiple concurrent implementations either powered by bucket locking, transactional mem- ory [15], or fully lock-less [18]; a de-amortization technique that provides provable worst case guaran- tees for insertions [1, 13]; and a variant that mini- mizes page-loads in a paged memory scenario [6]. Some non-cuckoo space efficient hash tables con- tinue to use linear probing variants. Robin Hood hashing is a technique that was originally introduced in 1985 [2]. The idea behind Robin Hood hashing is to move already stored elements during insertions in a way that minimizes the longest possible search distance. Robin Hood hashing has regained some popularity in recent years, mainly for its interesting theoretical properties and the possibility to reduce the inherent variance of linear probing. All these publications show that there is a clear interest in developing hash tables that can be more and more densely filled. Dynamic hash tables on the other hand seem to be considered a solved problem. One paper that takes on the problem of dynamic hash tables was written by Dietzfelbinger at al. [5]. It predates cuckoo hashing, and much of the atten- tion for space efficient hashing. All memory bounds presented are given without tight constant factors. The lack of implementations and theory about dense dynamic hash tables is where we pick up and of- fer a fast hash table implementation that supports dynamic growing with tight space bounds. 3 Preliminaries A hash table is a data structure for storing key- value-pairs ((cid:104)key, data(cid:105)) that offers the following functionality: insert – stores a given key-value pair or returns a reference to it, if it is already contained; find – given a key returns an reference to said element if it was stored, and ⊥ otherwise; and erase – removes a previously inserted element (if present). Throughout this paper n denotes the number of 2 elements and m the number of cells (m > n) in a hash table. We define the load factor as δ = n/m. Tables can usually only operate efficiently up to a certain maximum load factor. Above that, operations get slower or have a possibility to fail. When implementing a hash table one has to decide between storing elements directly in the hash table – Closed Hashing – or storing pointers to elements – Open Hashing. This has an immediate impact on the amount of memory required (closed : m · element and open: m · pointer + n · element). For large elements (i.e., much larger then the size of a pointer), one can use a non-space efficient hash table with open hashing to reduce the relevant memory factor. Therefore, we restrict ourselves to the common and more interesting case of elements whose size is close to that of a pointer. For our experiments we use 128bit elements (64bit keys and 64bit values). In this case, open hashing introduces a significant memory overhead (at least 1.5×). For this reason, we only consider closed hash tables. Their memory efficiency is directly dependent on the table's load. To reach high fill degrees with closed hashing tables, we have to employ open addressing techniques. This means that elements are not stored in predetermined cells, but can be stored in one of several possible places (e.g. linear probing, or cuckoo hashing). 3.1 α-Space Efficient Hash Tables Static. We call a hashing technique α-space efficient when it can work effectively using at most α· ncurr · size(element) + O(1) memory. In this case we define working efficiently as having average insertion times in O( 1 1−δ ). This is a natural estimation for insertion times, since it is the expected number of fully random probes needed to hit an empty cell (1 − δ is the fraction of empty cells). In many closed hashing techniques (e.g. linear probing, cuckoo hashing) cells are the same size as elements. Therefore, being α-space efficient is the same as operating with a load factor of δ = α−1. Because of this, we will mostly talk about the load factor of a table instead of its memory usage. Dynamic. The definition of a space efficient hashing technique given above is specifically tar- geted for statically sized hash tables. We call an implementation dynamically α-space efficient if an instantiated table can grow arbitrarily large over its original capacity while remaining smaller than α · nmax · size(element) + O(1) at all times. One problem for many implementations of space efficient hash tables is the migration. During a normal full table migration, both the original table and the new table are allocated. This requires mnew + mold cells. Therefore, a normal full table migration is never more than 2-space efficient. The only option for performing a full table migration with less memory is to increase the memory in-place (see Section 5). Similar to static α-space efficiency, we will mostly talk about the minimum load factor δmin = 1 α instead of α. 3.2 Cuckoo Hashing Cuckoo hashing is a technique to resolve hash con- flicts in a hash table using open addressing. Its main draw is that it guarantees constant lookup times even in densely filled tables. The distinguish- ing technique of cuckoo hashing is that H hash functions (h1, ..., hH ) are used to compute H inde- pendent positions. Each element is stored in one of its positions. Even if all positions are occupied one can often move elements to create space for the current element. We call this process displacing elements. Bucket cuckoo hashing is a variant where the cells of the hash table are grouped into buckets of size B (m/B buckets). Each element assigned to one bucket can be stored in any of the bucket's cells. Using buckets one can drastically increase the number of elements that can be displaced to make room for a new one, thus decreasing the expected length of displacement paths. Find and erase operations have a guaranteed constant running time. Independent from the table's density, there are H buckets – H · B cells – that have to be searched to find an element. During an insert the element is hashed to H buckets. We store the element in the bucket with the most free space. When all buckets are full we have to move elements within the table such that a free cell becomes available. To visualize the problem of displacing elements, one can think of the directed graph implicitly de- fined by the hash table. Each bucket corresponds to a node and each element induces an edge between the bucket it is stored in and its H − 1 alternate 3 buckets. To insert an element into the hash table we have to find a path from one of its associated buckets to a bucket that has free capacity. Then we move elements along this path to make room in the initial bucket. The two common techniques to find such paths are random walks and breadth first searches. 4 DySECT (Dynamic Space Efficient Cuckoo Table) A commonly used growing technique is to double the size of a hash table by migrating all its elements into a table with twice its capacity. This is of course not memory efficient. The idea behind our dynamic hashing scheme is to double only parts of the overall data structure. This increases the space in part of our data structure without changing the rest. We then use cuckoo displacement techniques to make this additional memory reachable from other parts of the hash table. 4.1 Overview Our DySECT hash table consists of T subtables (shown in Figure 1) that in turn consist of buckets, which can store B elements each. Each element has H associated buckets – similar to cuckoo hashing – which can be in the same or in different subtables. T , B, and H are constant that will not change during the lifetime of the table. Additionally, each table is initialized with a minimum fill ratio δmin. min · n cells once it The table will never exceed δ−1 begins to grow over its initial size. To find a bucket associated with an element e, we compute e's hash value using the appropriate hash function hi(e). The hash is then used to compute the subtable and the bucket within that subtable. To make this efficient we use powers of two for the number of subtables (T = 2t), as well as for the number of buckets per subtable (subtable size s = 2x · B). Since the number of subtables is constant, we can use the first t bits from the hashed key to find the appropriate subtable. From the remaining bits we compute the bucket within that subtable using a bitmask (hi(e) & (2x − 1) = hi(e) mod 2x). 4.2 Growing As soon as the (overall) table contains enough ele- ments such that the memory constraint can be kept during a subtable migration, we grow one subtable by migrating it into a table twice its size. We mi- grate subtables in order from first to last. This ensures that no subtable can be more than twice as large as any other. Assume that we have j large subtables (2s) than m = (T + j) · s. When δ−1 min · n > m + 2s we can grow the first subtable while obeying the size constraint (the newly allocated table will have 2s cells). Doubling the size of a subtable increases the global number of cells from mold = (T + j) · s to mnew = mold+s = (T +j+1)·s (grow factor T +j+1 T +j ). Note that all subsequent growing operations migrate one of the smaller tables until all tables have the same size. Therefore, each grow until then increases the overall capacity by the same absolute amount (smaller relative to the current size). The cost of growing a subtable is amortized by all insertions since the last subtable migration. There are δmin·s = Ω(s) insertions between two migrations. One migration takes Θ(s) time. Apart from being amortized, the migration is cache efficient since it accesses cells in a linear fashion. Even in the target table cells are accessed linearly. We assign elements to buckets by using bits from their hash value. In the grown table we use exactly one more bit than before (double the number of buckets). This ensures that all elements from one original bucket are split between two buckets in the target table. Therefore no bucket can overflow and no displacements are necessary. In the implicit graph model of the cuckoo table (Section 3.2), growing a subtable is equivalent to splitting each node that represents a bucket within that subtable. The resulting graph becomes more sparse, since the edges (elements) are not doubled, making it easier to insert subsequent elements. 4.3 Shrinking If shrinking is necessary it can work similarly to growing. We replace a subtable with a smaller one by migrating elements from one to the other. During this migration we join elements from two buckets into one. Therefore it is possible for a bucket to overfill. We reinsert these elements at the end of 4 Figure 1: Schematic Representation of a DySECT Table. the migration. Obviously, this can only affect at most half the migrated elements. When automatically triggering the size reduction, one has to make sure that the migration cost is amor- tized. Therefore, a grow operation cannot imme- diately follow a shrink operation. When shrinking is enabled we propose to shrink one subtable when min · n < m − s(cid:48) elements (s(cid:48) size of a large table, δ−1 mnew = mold − s(cid:48)/2). Alternatively, one could im- plement a shrink to size operation that is explicitly called by the user. 4.4 Difficulties for the Analysis of DySECT There are two factors specific to DySECT impacting its performance: inhomogeneous table resolution and element imbalance. Imbalance through Inhomogeneous Table Resolution. By growing subtables individually we introduce a size imbalance between subtables. Large subtables contain more buckets but the num- ber of elements hashed to a large subtable is not gen- erally higher than the number of elements that are hashed to a small subtable. This makes it difficult to spread elements evenly among buckets. Imbal- anced bucket fill ratios can lead to longer insertion times. Assume there are n elements in a hash table with T subtables, j of which have size 2s the others have size s. If elements are spread equally among buckets then all small tables have around n/(T +j) elements, and the bigger tables have 2n/(T + j) elements. For each table there are about Hn/T elements that have an associated bucket within that table. This shows that having more hash functions can lead to a better balance. For two hash functions (H = 2) and only one grown table (j = 1) this means that ≈ 2n/(T + 1) elements should be stored in the first table to achieve a balanced bucket distribution. Therefore, nearly all elements associated with a bucket in the first table (≈ 2n/T ) have to be stored there. This is one reason why H = 2 does not work well in practice. Imbalance through Size Changes. In addi- tion to the problem of inhomogeneous tables there is an inherent balancing problem introduced by re- sizing subtables. It is clear that a newly grown table is not filled as densely as other tables. Since we double the table size, grown tables can only be filled to about 50%. Assume the global table is filled close to 100% when the first table grows. Now there is capacity for s new elements but this capacity is only in the first table, elements that are not hashed to the first table, automatically trigger displacements leading to slow insertions. Notice that repeated insert and erase operations help to equalize this imbalance, because elements are more likely inserted into the sparser areas, and more likely to be deleted from denser areas. 5 Tsubtables2·scellsbucketwithBcellsoneelementwithHassociatedbucketsj-thtablescells 4.5 Implementation Details For our experiments (Section 6) we use three hash functions (H = 3) and a bucket size of (B = 8). These values have consistently outperformed other options both in maximum load factor and in insert performance (see Appendix A). T is set to 256 sub- tables for all our tests. To find displacement oppor- tunities we use breadth first search. In our tests it performed better than random walks, since it better uses the read cache lines from one bucket. The hash table itself is implemented as a constant sized array of pointers to subtables. We have to lookup the corresponding pointer whenever a sub- table is accessed. This does not impact performance much since all subtable pointers will be cached – at least if the hash table is a performance bottleneck. Reducing the Number of Computed Hash Functions. Evaluating hash functions is expen- sive, therefore, reducing the number of hash func- tions computed per operation can increase the per- formance of the table. The hash function we use computes 64bit hash values (i.e. xxHash1). We split the 64bit hash value into two 32bit values. All common bucket hash table sizes can be addressed using 32 bits (up to 232 buckets 235 ≈ 34 billion elements consuming 512GiB memory). When H > 2 we can use double hashing [11, 12] to further reduce the number of computed hash func- tions. Double hashing creates an arbitrary number of hash values using only two original hash functions h(cid:48) and h(cid:48)(cid:48). The additional values are linear com- binations computed from the original two values, hi(key) = h(cid:48)(key) + i · h(cid:48)(cid:48)(key). Combining both of these techniques, we can re- duce the number of computed hash functions to one 64bit hash function. This is especially important during large displacements where each encountered element has to be rehashed to find its alternative buckets. 5 (Ab)Using Virtual Memory In this section we show how one can use virtual memory and memory overcommitting, to eliminate the indirections from a DySECT hash table. The same technique also allows us to implement hash 1xxhash.com tables that can grow using an in-place full table migration. If we grow these tables in small incre- ments, they can grow while enforcing a strict size constraint. To explain these techniques, we first have to ex- plain how to use memory overcommitting and vir- tual memory to create a piece of memory that can grow in-place. Note that this technique violates best programming practices and is not fully portable to some systems. The idea is the following: the operating system will – if configured to do so – allow memory al- locations larger than the machine's main memory, with the anticipation that not all allocated memory will actually be used. Only memory pages that are actually used will be mapped from virtual to physi- cal memory pages. Thus, for the purpose of space efficiency the memory is not yet used. Initializing parts of this memory is similar to allocating and initializing new memory. 5.1 Improving DySECT Accessing a DySECT subtable usually takes one indirection. The pointer to the subtable has to be read from an array of pointers before accessing the actual subtable. Instead of using an array of pointers, we can implement the subtables as sections within one large allocation (size u). We choose u larger than the actual main memory, to allow all possible table sizes. This has the advantage that the offset for each table can be computed quickly (ti = u T · i), without looking it up from a table. The added advantage is that we can grow subta- bles in-place. To increase the size of a subtable, it is enough to initialize a consecutive section of the table (following the original subtable). Once this is done, we have to redistribute the table's elements. This allows us to grow a subtable without the space overhead of reallocation. Therefore, we can grow earlier, staying closer to the minimum load factor δmin. The in-place growing mechanism is easy in this case, since the subtable size is doubled. 5.2 Implementing other size con- strained tables Similarly to the technique above, we can implement any hash table using a large allocation, initializing only as much memory as the table initially needs. 6 The used hash table size can be increased in-place by initializing more memory. To use this additional memory for the hash table, we have to perform an in-place migration. To implement fast in-place migration, we need the correct addressing technique. There are two natural ways to map a hash value h(e) to a cell in the table (size s). Most programmers would use a slow modulo operation (h(e) mod s). This is the same as using the least significant digits when addressing a table whose size is a power of two. A better way is to use a scale factor ((cid:98)h(e) · This is similar to using the most significant bits to address a table whose size is a power of two. The second method has two important advantages, it is faster to compute and it helps to make the migration cache efficient. When we use the second method the elements in the hash table are close to being sorted by their hash value (in the absence of collisions they would be sorted). max(h)(cid:99)). s The main idea of all our in-place migration tech- niques is the following. If we use a scale factor for our mapping – in the new table – most elements will be mapped to a position that is larger than their position in the old table. Therefore, rehash- ing elements starting from the back of the original table creates very few conflicts. Elements that are mapped to a position earlier than their current po- sition are buffered and reinserted at the end of the migration. When using this technique, both the old and the new table, are accessed linearly in reverse order (from back to front). Making the migration cache efficient and easy to implement. For a table that was initialized with a min load factor δmin we trigger growing once the table is loaded more than δmin+1 . We then increase the min · n. Repeated migrations with capacity m to δ−1 small growing amounts are still inefficient, since each element has to be moved. 2 This blueprint can be used, to implement in-place growing variants of most if not all common hashing techniques. We used these same ideas to implement variants of linear probing, robin hood hashing, and bucket cuckoo hashing. Although some variants have their own optimized migration. Robin Hood hashing can be adapted such that the table is truly sorted by hash value (without much overhead) making the migration faster than repeated reinsertions. Bucket cuckoo hashing has a somewhat more complicated migration technique, since each element has multiple possible positions, and one bucket can overflow. The best strategy here is to try to reinsert each element with the hash function (h1, ..., hH ) that was previously used to store it. 6 Experiments There are many factors that impact hash table per- formance. To show that our ideas work in practice we use both micro-benchmarks and practical exper- iments. All reported numbers are averaged by running each experiment five times. The experiments were executed on a server with two Intel Xeon E5-2670 CPUs (2.3GHz base frequency) and 128GB RAM (using gcc 6.2.0 and Ubuntu 14.04).2 To put the performance of our DySECT table into perspective, we implement and test several other options for space efficient hashing using the method described in Section 5.2. We use our own implemen- tations, since no hash table found online supports our strict space-efficiency constraint. With the tech- nique described in Section 5.2, we implement and test hash tables with linear probing, robin hood hash- ing, and bucket cuckoo hashing (similar to DySECT we choose B = 8 and H = 3 see Appendix A for experiments with other parameter settings). For each table, we implemented an individually tuned cache efficient in-place migration algorithm. Without Virtual Memory/ Memory Over- implementations described committing. All above work with the trick described in Section 5. The usefulness of this technique is arguable, since abusing the concept of virtual memory in this way is problematic not only from a software design perspective. It directly violates best practices, and reduces portability to many systems. The only table that can achieve dynamic α-space efficiency without this technique is our DySECT hash table. It is notable that this implementation is never significantly worse than DySECT with overcommitting (this variant is displayed using a dashed line). For each competitor table, we also implemented a variant that uses subtables combined with normal 2Experiments on a desktop machine yielded similar re- sults. 7 migrations (small grow factor, similar to in-place variants). Elements are first hashed to subtables and then hashed within that table. They cannot move between subtables. These variants are not strictly space efficient. The subtables are gener- ally small (n/T ), therefore migrations will usually not violate the size constraint (too much). There can be larger subtables, since imbalances between subtables cannot be regulated. Throughout this section, we display these variants with dashed lines (similar to the DySECT variant without memory overcommitting). 6.1 Influence of Fill Ratio (Static Ta- ble Size) The following test was performed by initializing a ta- ble with m ≈ 25 000 000 cells (non-growing). Then elements are inserted until there is a failing inser- tion. At different stages, we measure the running time of new insertion (Figure 2), and find (Figure 3 and 4) operations (averaged over 1000 operations). Finds are measured using either randomly selected elements from within the table (successful), or by searching random elements from the whole key space (unsuccessful). We omit testing multi table variants of the competitor tables. They are not suitable for this test since forcing a static size limits the possi- bility to react to size imbalances between subtables (in the absence of displacements). As to be expected, the insertion performance of depends highly on the fill degree of the table. There- fore, we show it normalized with 1 1−δ which is the expected number of fully random probes to find a free cell and thus a natural estimate for the running time. We see that – up to a certain point – the inser- tion time behaves proportional to 1 1−δ for all tables. Close to the capacity limit of the table, the inser- tion time increases sharply. DySect has a smaller capacity limit than cuckoo due inhomogeneous table resolution (see Section 4.4). Figure 3 and 4 show the performance of find op- erations. Linear probing performs relatively well on successful find operations, up to a fill degree of over 95%. The reason for this is that many elements were inserted into the table when the table was still relatively empty. They have very short search dis- tances, thus improving find performance. Successful find performance can still be an issue in applica- tions. An element that is inserted when the table is 8 already decently filled can have an extremely long search distance. This leads to a high running time variance on find operations. Unsuccessful finds per- form really badly, since all cells until the next free cell have to be probed. Their performance is much more related to the filling degree of the hash table. Robin Hood hashing performs somewhat similar to linear probing. It worsens the successful find per- formance by moving previously inserted elements from their original position, in order to achieve bet- ter unsuccessful find performance on highly filled tables. Overall, Robin Hood hashing is objectively worse than both DySECT and classic cuckoo hash- ing. Cuckoo hashing and its variants like DySECT have guaranteed constant running times for all find operations – independent of their success and the table's filling degree. 6.2 Influence of Fill Ratio (Dynamic Table Size) In this test 20 000 000 elements are inserted into an initially empty table. The table is initialized expecting 50 000 elements, thus growing is necessary to fit all elements. The tables are configured to guarantee a load factor of at least δmin at all times. Figure 5 shows the performance in relation to the load factor. Insertion times are computed as average of all 20 000 000 insertions. They are normalized similar to Figure 2 (divided by ). 1 1−δmin We see that DySECT performs by far the best even with less filled tables at 85% load. Here we achieve a speedup of 1.6 over the next best solu- tion (299ns vs. linear probing 479ns). On denser instances with 97.5% load, we can increases these speedup to 2.7 (1580ns vs Cuckoo with subtables 4210ns). With growing load, we see the insertion times of our competitors degrade. The combination of long insertion times, and frequent growing phases slows them down. There are only few insertions be- tween two growing phases. Making the amortization of each growing phase challenging since each grow- ing phase has to move all elements. Any growing technique that uses a less cache efficient migration algorithm, would likely perform significantly worse. DySECT however remains close to O( ) even for fill degrees up to 97.5%. This is possible, because only very few elements are actually touched during each subtable migration (≈ n T ). 1−δmin We also measured the performance of find opera- 1 Figure 2: performance of insertions. To make insertion time more readable, we normalize it with top · (1 − δ). Insertions into a Static Table. Here we show the influence from the load factor, on the Figure 3: Performance of Successful Finds. DySECT's find performance is independent from the load factor. Figure 4: Performance of Unsuccessful Finds. DySECT's find performance is independent from the operations success. tions on the created tables, they are similar to the performance on the static table in Section 6.1 (see Figure 3 and 4), therefore, we omit displaying them for space reasons. 6.3 Word Count – a Practical use Case Word count and other aggregation algorithms are some of the most common use cases for hash tables. Data is aggregated according to its key, which in our case is a hash of the contained word. This is a common application, in which static hash tables can never be space efficient, since the final size of the hash table is usually unknown. Here we use the first block of the CommonCrawl dataset (commoncrawl. org/the-data/get-started) and compute a word count of the contained words, using our hash ta- bles. The chosen block has 4.2GB and contains around 240 000 000 words, with around 20 000 000 unique words. For the test, we hash each word to a 64 bit key and insert it together with a counter. 9 0.800.850.900.951.00020406080load factor dtime x (1-d) [ns]lllllllllllllllllllllllllllllllllllllllllDySECTCuckooLin ProbRobin Hood0.800.850.900.951.000100200300400load factor dtime [ns]lllllllllllllllllllllllllllllllllllllllllDySECTCuckooLin ProbRobin Hood0.800.850.900.951.000100200300400load factor dtime [ns]llllllllllllllllllllllllllllllllllllllll Figure 5: Insertions into a dynamic growing table enforcing a minimum load factor δmin. Figure 6: Word Count Benchmark. The benchmark behaves like a mix of insert and find operations. DySECT's performance is nearly independent form the load factor. Subsequent accesses to the same word increase this counter. Similar to the growing benchmark, we start with an empty table initialized for 50 000 elements. The performance results can be seen in Figure 6. We do not use any normalization since each word is repeated 12 times (on average). This means that most operations will actually behave more like successful find operations instead of inserting an element. When using our DySECT table, the run- ning time seems to be nearly independent from the fill degree. We experience little to no slowdown until around 97%. The tables using full table migra- tion however become very inefficient on high load degrees. For high load factors, the performance closely re- sembles that of the insertion benchmark (Figure 5). This indicates that insert performance can domi- nate running times even in find intensive workloads. To confirm this insight, we conducted some exper- iments with mixed operations (insert and find; insert and erase). They showed, that on a hash table with δmin = 0.95 DySECT outperforms linear probing for any workload containing more than 5% insertions (see Section 6.4). 6.4 Mixed Workloads In this test, we show how the hash tables behave under mixed workloads. For this test we fixed the minimum load factor to δ = 0.95. The test starts with a filled table containing 15 000 000 elements (95% filled). On this table we perform 10 000 000 operations mixed between insert and find/erase operations. As one might expect, the running time of a mixed work load can be estimated with a linear combina- tion of the used operations. In the insert/find benchmark (Figure 7), 10 0.850.900.951.00050150250enforced min load dmintime x (1-dmin) [ns]lllllllllllllllDySECTCuckooLin ProbRobin Hood0.850.900.951.000200400600800enforced min load dminTime per operation [ns]lllllllllllllllDySECTCuckooLin ProbRobin Hood Figure 7: Workload combining insertions with finds. Figure 8: Workloads combining insertions with erase. DySECT outperforms all other hash tables. This shows that fast insertions are important even in find intensive workloads. This is even more accentuated by the fact that all performed finds are successful finds which have usually better performance on hash tables using linear probing The measurements with deletions (Figure 8) show that deletions in linear probing tables are significantly slower than those in cuckoo tables. This makes sense, since linear probing tables have to move elements, to fix their invariants while cuckoo tables have guaranteed con- stant deletions. 6.5 Investigating Maximum Load Bounds We designed the following experiment, to give an in- dication for the theoretical load bounds DySECT is Figure 9: Maximum load bounds for different parameterizations (B/H) over a varying table size. Cuckoo's bound is indicated by a dashed line. able to support. To do this, we configured DySECT to grow only if there is an unsuccessful insertion – in our other tests the table grows in anticipation once the size-constraint allows it. To get even closer to the theoretical limits, we use T = 4096 subtables such that each grow has a smaller relative grow fac- tor. Additionally we increase the number of probes used to find a successful displacement path to 16384 probes (from 1024). We test different combinations of bucket size (B) and number of hash functions (H). The test consists of inserting 20 000 000 elements into a previously empty table initialized with 50 000 cells. When- ever the table has to grow we note its effective load (during the migration). The maximum load bound depends on the number of large subtables. There- fore, we show the achieved load factors over the table capacity (m). To give a perspective, of static table performance we show dashed lines with the performance of a cuckoo hash table. We measured cuckoo's performance by initializing a table with 20 000 000 cells and filling it until there was an error (using the same search distance of 16384). Figure 9 clearly shows the cyclical nature of DySECT's maximum load bound. The table can be filled the most, when its capacity is close to a power of two. Then, all subtables have the same size and the table behaves similar to a static cuckoo table of the. On some sizes DySECT even seems to outper- form cuckoo hashing. We are not sure why this is the case. We suspect that the bound measured for 11 0204060801000100020003000fraction of insert operations [%]time per operation [ns]lllllllllllllDySECTCuckooLin ProbRobin Hood50607080901000100020003000fraction of insert operations [%]time per operation [ns]llllllllllllnumber of cells mmax load d2162182202222240.90.990.99910.9780.9980.9970.99980.9270.9890.9670.9978/38/24/34/2 cuckoo hashing is not tight (cuckoo hashing bounds are only measured on one table size). This effect does not appear for the 8/3 parameterization that we use throughout the paper. Both parameterizations that are using only two hash functions (8/2 and 4/2) have a higher depen- dency on the table size. The reason for this is that additional hash functions help to reduce the im- balance introduced by varied subtable resolution described in Section 4.4. Overall, we reach load bounds that are close to those of static cuckoo hash- ing. 7 Conclusion We have shown that dynamically growing hash ta- bles can be implemented to always consume space close to the lower bound. We find it surprising that even our simple solutions based on linear probing seem to be new. DySECT is a sophisticated solu- tion that exploits the flexibility offered by bucket cuckoo hashing to significantly decrease the number of object migrations over more straightforward ap- proaches. When very high space efficiency is desired, it is up to 2.7 times better than simple solutions. For future work, a theoretical analysis of DySECT looks interesting. We expect that techniques pre- viously used to analyze bucket cuckoo hashing will be applicable in principle. However, the already very complex calculations have to be generalized to take all possible ratios of small versus large sub- tables into account. Even for the static case and classical bucket cuckoo hashing, it is a fascinating open question whether the observed proportional- ity of insertion time to 1/(1 − δ) can be proven. Previous results on insertion time show much more conservative bounds [8, 9, 10, 7]. On the practical side, DySECT looks interesting for concurrent hashing [15, 18] since it grows only small parts of the table at a time. References guages and Programming (ICALP), number 5555 in LNCS, pages 107–118. Springer, 2009. [2] Pedro Celis, Per-Ake Larson, and J. Ian Munro. In 26th Symposium Robin hood hashing. on Foundations of Computer Science (FOCS), pages 281–288, Oct 1985. [3] Luc Devroye and Pat Morin. Cuckoo hash- ing: Further analysis. Information Processing Letters, 86(4):215 – 219, 2003. [4] Martin Dietzfelbinger, Andreas Goerdt, Michael Mitzenmacher, Andrea Montanari, Rasmus Pagh, and Michael Rink. Tight thresholds for cuckoo hashing via XORSAT. In 27th International Conference on Automata, Languages and Programming (ICALP), pages 213–225, 2010. [5] Martin Dietzfelbinger, Anna Karlin, Kurt Mehlhorn, Friedhelm Meyer auf der Heide, Hans Rohnert, and Robert E. Tarjan. Dynamic perfect hashing: Upper and lower bounds. SIAM Journal on Computing, 23(4):738–761, 1994. [6] Martin Dietzfelbinger, Michael Mitzenmacher, and Michael Rink. Cuckoo hashing with pages. In 19th European Symposium on Algorithms (ESA), number 6942 in LNCS, pages 615–627. Springer, 2011. [7] Martin Dietzfelbinger and Christoph Wei- dling. Balanced allocation and dictionaries with tightly packed constant size bins. Theo- retical Computer Science, 380(1):47–68, 2007. [8] Dimitris Fotakis, Rasmus Pagh, Peter Sanders, and Paul Spirakis. Space efficient hash tables with worst case constant access time. Theory of Computing Systems, 38(2):229–248, 2005. [9] Nikolaos Fountoulakis, Konstantinos Pana- giotou, and Angelika Steger. On the inser- tion time of cuckoo hashing. SIAM Journal on Computing, 42(6):2156–2181, 2013. [1] Yuriy Arbitman, Moni Naor, and Gil Segev. De-amortized cuckoo hashing: Provable worst- case performance and experimental results. In International Conference on Automata, Lan- [10] Alan Frieze, Pll Melsted, and Michael Mitzen- macher. An analysis of random-walk cuckoo hashing. SIAM Journal on Computing, 40(2):291–308, 2011. 12 [11] Leo J. Guibas and Endre Szemeredi. The anal- ysis of double hashing. Journal of Computer and System Sciences, 16(2):226–274, 1978. A Parameterization of DySECT In this section, we show additional measurements, using the experiment described in Section 6.2. We insert 20 000 000 elements into a previously empty table – using a dynamic table size. We show the measurements for different parameterizations of DySECT and Cuckoo Tables. First we show differ- ent combinations for B and H, here we also show their find performance. Then we show different dis- placement techniques using (B = 8 and H = 3). For random walk displacements we test an optimistic, and a pessimistic variant. The measurements show, that the chosen param- eterization in Section 4.5 has the best maximum fill bounds and the best insert performance. Both 4/3 and 8/2 might achieve better performance on sparser tables, with find heavy workloads. [12] Adam Kirsch and Michael Mitzenmacher. Less hashing, same performance: Building a bet- ter bloom filter. In Yossi Azar and Thomas Erlebach, editors, 14th European Symposium on Algorithms (ESA), number 4168 in LNCS, pages 456–467. Springer, 2006. [13] Adam Kirsch and Michael Mitzenmacher. Us- ing a queue to de-amortize cuckoo hashing in hardware. In 45th Annual Allerton Conference on Communication, Control, and Computing, volume 75, 2007. [14] Donald E. Knuth. The Art of Computer Pro- gramming, Volume 3: (2nd Ed.) Sorting and Searching. Addison Wesley Longman Publish- ing Co., Inc., Redwood City, CA, USA, 1998. [15] Xiaozhou Li, David G. Andersen, Michael Kaminsky, and Michael J. Freedman. Algorith- mic improvements for fast concurrent cuckoo hashing. In 9th European Conference on Com- puter Systems, EuroSys '14, pages 27:1–27:14. ACM, 2014. [16] M. Mitzenmacher. The power of two choices in randomized load balancing. IEEE Trans- actions on Parallel and Distributed Systems, 12(10):1094–1104, Oct 2001. [17] Michael Mitzenmacher. Some open questions related to cuckoo hashing. In Amos Fiat and Peter Sanders, editors, 17th European Sym- posium on Algorithms (ESA), volume 5757 of LNCS, pages 1–10. Springer, 2009. [18] N. Nguyen and P. Tsigas. Lock-free cuckoo hashing. In 2014 IEEE 34th International Conference on Distributed Computing Systems (ICDCS), pages 627–636, June 2014. [19] Rasmus Pagh and Flemming Friche Rodler. Journal of Algorithms, Cuckoo hashing. 51(2):122–144, 2004. 13 Figure 10: Insertions with different B/H Parameterizations (left), and different Displacement techniques (using 8/3right). For each displacement, we perform up to 1024 probes for an empty bucket. Measurements end when errors occur. Figure 11: Finds with different B/H Parameterizations (successful left, unsuccessfulright). Solid lines represents DySECT. Dashed lines represent bucket cuckoo hashing. 14 0.850.900.951.00050150250enforced min load dmintime x (1-dmin) [ns]llllllllllllllllllllllll8/38/24/34/2lDySECTCuckoo0.850.900.951.00050150250enforced min load dmintime x (1-dmin) [ns]lllllllllllllllllllllbfsopt−rwalkpess−rwalklDySECTCuckoo0.850.900.951.0002060100140enforced min load dmintime per op [ns]llllllllllllllllllllllll8/38/24/34/2lDySECTCuckoo0.850.900.951.0002060100140enforced min load dmintime per op [ns]llllllllllllllllllllllll
1702.01719
1
1702
2017-02-06T17:38:26
A 2-Approximation for the Height of Maximal Outerplanar Graph Drawings
[ "cs.DS", "cs.CG" ]
In this paper, we study planar drawings of maximal outerplanar graphs with the objective of achieving small height. A recent paper gave an algorithm for such drawings that is within a factor of 4 of the optimum height. In this paper, we substantially improve the approximation factor to become 2. The main ingredient is to define a new parameter of outerplanar graphs (the so-called umbrella depth, obtained by recursively splitting the graph into graphs called umbrellas). We argue that the height of any poly-line drawing must be at least the umbrella depth, and then devise an algorithm that achieves height at most twice the umbrella depth.
cs.DS
cs
A 2-Approximation for the Height of Maximal Outerplanar Graph Drawings Philippe Demontigny† Therese Biedl∗ Abstract In this paper, we study planar drawings of maximal outerplanar graphs with the objective of achieving small height. A recent paper gave an algorithm for such drawings that is within a factor of 4 of the optimum height. In this paper, we substantially improve the approximation factor to become 2. The main ingredient is to define a new parameter of outerplanar graphs (the so-called umbrella depth, obtained by recursively splitting the graph into graphs called umbrellas). We argue that the height of any poly-line drawing must be at least the umbrella depth, and then devise an algorithm that achieves height at most twice the umbrella depth. 1 Introduction In Graph drawing is the art of creating a picture of a graph that is visually appealing. this paper, we are interested in drawings of so-called outer-planar graphs, i.e., graphs that can be drawn in the plane such that no two edges have a point in common (except at common endpoints) and all vertices are incident to the outer-face. All drawings are required to be planar, i.e., to have no crossing. The drawing model used is that of flat visibility representations where vertices are horizontal segments and edges are horizontal or vertical segments, but any such drawing can be transformed into a poly-line drawing (or even a straight-line drawings if the width is of no concern) without adding height [6]. Every planar graph has a straight-line drawing in an n × n-grid [18, 13]. Minimizing the area is NP-complete [16], even for outer-planar graphs [7]. In this paper, we focus on minimizing just one direction of a drawing (we use the height; minimizing the width is equivalent after rotation). It is not known whether minimizing the height of a planar drawing is NP-hard (the closest related result concerns minimizing the height if edges must connect adjacent rows [15]). Given the height H, testing whether a planar drawing of height H exists is fixed parameter tractable in H [10], but the run-time is exceeding large in H. As such, approximation algorithms for the height of planar drawings are of interest. ∗David R. Cheriton School of Computer Science, University of Waterloo, Waterloo, Ontario N2L 1A2, †[email protected]. Part of this work appeared as the author's Master's thesis at UWaterloo. Canada. [email protected]. Supported by NSERC. 1 It is known that any graph G with a planar drawing of height H has pw(G) ≤ H [11], where pw(G) is the so-called pathwidth of G. This makes the pathwidth a useful parameter for approximating the height of a planar graph drawing. For a tree T , Suderman gave 2pw(T )(cid:101) [19], making this an asymptotic an algorithm to draw T with height at most (cid:100) 3 3 2-approximation algorithm. It was discovered later that optimum-height drawings can be found efficiently for trees [17]. Approximation-algorithms for the height or width of order- preserving and/or upward tree drawing have also been investigated [1, 2, 8]. For outer-planar graphs, the first author gave two results that will be improved upon in this paper. In particular, every maximal outerplanar graph has a drawing of height at most 3 log n−1 [3] and of height 4pw(G)−3 [5]. Note that the second result gives a 4-approximation on the height of drawing outerplanar graphs, and improving this "4" is the main objective of the current paper. A number of results for drawing outer-planar graphs have been developed since paper [3]. In particular, any outerplanar graph with maximum degree ∆ admits a planar straight-line drawing with area O(∆n1.48) [14], or with area O(∆n log n) [12]. The former √ bound was improved to O(n1.48) area [9]. Also, every so-called balanced outer-planar graph can be drawn in an O( √ n) × O( n)-grid [9]. In this paper, we present a 2-approximation algorithm for the height of planar drawings of maximal outer-planar graphs. The key ingredient is to define the so-called umbrella depth ud(G) in Section 3. In Section 4, we show that any outerplanar graph G has a planar drawing of height at most 2ud(G) + 1. (We actually show a height of 2bd(G) + 1, where the bonnet depth bd(G) ≤ ud(G) is another newly defined graph parameter.) This algorithm is a relatively minor modification of the one in [5], albeit described differently. The bulk of the work for proving a better approximation factor hence lies in proving a better lower bound, which we do in Section 5: Any maximal outerplanar graph G with a planar drawing of height H has ud(G) ≤ H − 1. This proves that our result is a 2-approximation for the optimal height, which must fall in the range [ud(G) + 1, 2ud(G) + 1]. 2 Preliminaries Throughout this paper, we assume that G = (V, E) is a simple graph with n ≥ 3 vertices and m edges that is maximal outer-planar. Thus, G has a standard planar embedding in which all vertices are in the outer face (the infinite connected region outside the drawing) and form an n-cycle, and all interior faces are triangles. We call an edge (u, v) of G a cutting edge if G − {u, v} is disconnected, and a non-cutting edge otherwise.1 In an outer-planar graph, any cutting edge (u, v) has exactly two cut-components, i.e., there are two maximal outerplanar subgraphs G1, G2 of G such that G1 ∩ G2 = {u, v} and G1 ∪ G2 = G. The dual tree T of G is the weak dual graph of G in the standard embedding, i.e., T has a vertex for each interior face of G, and an edge between two vertices if their corresponding faces in G share an edge. An outerplanar path P is a maximal outerplanar graph whose dual 1The cutting edges are exactly those edges for which in the standard embedding both incident faces are interior, but we prefer to phrase this and the following definitions independent of the standard embedding since we do not necessarily draw the graph in the standard embedding. 2 (a) (b) Figure 1: (a) A straight-line drawing in the standard embedding, including the dual tree (dashed edges) and an outerplanar path (shaded) connecting ((cid:96)1, (cid:96)2) with (r1, r2). (b) A flat visibility representation. Both drawings have height 4. tree is a path. We say that P connects edges e and e(cid:48) if e is incident to f1 and e(cid:48) is incident to fk, where f1 and fk are the first and last face in the path that is the dual tree of P . An outerplanar path P with n = 3 is a triangle and connects any pair of its edges. Since any two interior faces are connected by a path in the dual tree, there exists an outerplanar path connecting e and e(cid:48) for any two edges e, e(cid:48). Graph drawing: A drawing of a graph consists of a point or an axis-aligned box for every vertex, and a polygonal curve for every edge. We only consider planar drawings where none of the points, boxes, or curves intersect unless the corresponding elements do in the original In this paper, a planar drawing is not required to reflect a graph's given planar graph. embedding. In a flat visibility representations vertices are represented by horizontal line segments, and edges are vertical or horizontal straight-line segments. (For ease of reading, draw vertices as boxes of small height in our illustrations.) In a poly-line drawing vertices are points and edges are polygonal curves, while in a straight-line drawing vertices are points and edges are line segments. In this paper, we only study planar flat visibility representations, but simply speak of a planar drawing, because it is known that any planar flat visibility representation can be converted into a planar straight-line drawing of the same height and vice versa [6]. We require that all defining features (points, endpoints of segments, bends) are placed at points with integer y-coordinates. A layer (or row) is a horizontal line with integer y- coordinate that intersects elements of the drawing, and the height is the number of layers. We do not enforce integer x-coordinates since we do not focus on minimizing the width. We can always achieve O(n) width (without adding height) for visibility representations and for the poly-line drawings obtained from them [6].) 3 (cid:96)1(cid:96)2r1r2(cid:96)2(cid:96)1r2r1(cid:96)1(cid:96)2r1r2(cid:96)2(cid:96)1r2r1 3 Umbrellas, bonnets and systems thereof In this section, we introduce a method of splitting maximal outerplanar graphs into systems of special outerplanar graphs called umbrellas and bonnets. Definition 1. Let G be a maximal outer-planar graph, let U be a subgraph of G with n ≥ 3, and let (u, v) be a non-cutting edge of G. We say that U is an umbrella with cap (u, v) if it can be written as the union of three outerplanar paths P , F1, and F2 such that: 1. P (the handle) connects (u, v) to some other non-cutting edge of G, 2. F1 (the fan at u) contains only u and neighbours of u. F2 (the fan at v) contains only v and neighbours of v. 3. F1 and F2 are edge-disjoint. F1 and P have exactly one edge (incident to u) in common; F2 and P have exactly one edge (incident to v) in common. 4. All neighbours of u and v belong to U . See also Figure 2(a). We allow the fans to be empty, but P must have at least one interior face (the one incident to (u, v)). Any edge (a, b) of U that is a cutting edge of G, but not of U , is called an anchor-edge of U in G. (In the standard embedding, such edges are on the outer-face of U but not on the outer-face of G.) The hanging subgraph with respect to anchor-edge (a, b) of U in G is the cut-component Sa,b of G with respect to cutting-edge (a, b) that does not contain the cap (u, v) of U . We often omit "of U in G" when umbrella and super-graph are clear from the context. Definition 2. Let G be a maximal outerplanar graph with n ≥ 3, and let (u, v) be a non- cutting edge of G. An umbrella system U on G with root-edge (u, v) is a collection U = {U0} ∪ U1 ∪ ··· ∪ Uk of subgraphs of G for some k ≥ 0 that satisfy the following: 1. U0 (the root umbrella) is an umbrella with cap (u, v), 2. U0 has k anchor-edges. We denote them by (ui, vi) for i = 1, . . . , k, and let Si be the hanging subgraph with respect to (ui, vi). 3. For i = 1, . . . , k, Ui (the hanging umbrella system) is an umbrella system of Si with root-edge (ui, vi). The depth of such an umbrella system is d(U) := 1 + maxi d(Ui). Define ud(G; u, v) (the (rooted) umbrella depth of G) to be the maximum depth over all umbrella systems with root-edge (u, v). Note that the umbrella depth depends on the choice of the root-edge; define the free umbrella depth udf ree(G) to be the minimum umbrella depth over all possible root-edges. (One can show that the free umbrella depth is at most one unit less than the rooted umbrella depth for any choice of root-edge; see the appendix.) Bonnets: A bonnet is a generalization of an umbrella that allows two handles, as long as they go to different sides of the face (u, v). Thus, condition (1) of the definition of an umbrella gets replaced by 4 (a) (b) Figure 2: (a) An umbrella system of depth 3. The root umbrella is shaded, with its handle darker shaded. (b) The same graph has a bonnet system of depth 2, with the root bonnet shaded and its ribbon darker shaded. (1') P (the ribbon) connects two non-cutting edges and contains u, v and their common neighbour. Other than that, bonnets are defined exactly like umbrellas. See also Figure 2(b). We can also define a bonnet system, root bonnet, etc., exactly as for an umbrella system, except that "bonnet" is substituted for "umbrella" everywhere. Let bd(G; u, v) (the rooted bonnet-depth of G) be the minimum possible depth of a bonnet system with root-edge (u, v), and let bdf ree(G) be the minimum bonnet-depth over all choices of root-edge. Since any umbrella is a bonnet, clearly bd(G; u, v) ≤ ud(G; u, v) for all root-edges (u, v). We would like to emphasize that the root bonnet U0 of a bonnet system must contain all edges incident to the ends u, v of the root-edge. If follows that no edge incident to u or v can be an anchor-edge of U0, else the hanging subgraph at it would contain further neighbours of u (resp. v). We note this trivial but useful fact for future reference: Observation 1. In a bonnet system with root-edge (u, v), no edge incident to u or v is an anchor-edge of the root bonnet. 4 From Bonnet System to Drawing In this chapter, we show how to create a flat visibility representation, given a maximal outerplanar graph G and a bonnet system of G. The drawings we create will not be in the standard embedding of G, as we will place drawings of hanging subgraphs inside an inner face of the root bonnet. For merging purposes, we draw the root-edge (u, v) in a special way: It spans the top layer, which means that u touches the top left corner of the drawing, and v touches the top right corner, or vice versa (see for example Figure 3(b)). We first explain how to draw the root bonnet. Lemma 1. Let U0 be the root bonnet of a bonnet system with root-edge (u, v). Then there exists a flat visibility representation Γ of U0 on three layers such that 5 uvabuv 1. (u, v) spans the top layer of Γ. 2. Any anchor-edge of U0 is drawn horizontally in the middle or bottom layer. Proof. As a first step, we draw the ribbon of U0 on 2 layers in such a way that (u, v) and all anchor-edges are drawn horizontally; see Figure 3(a) for an illustration. (This part is identical to [5].) Consider the standard embedding of P in which the dual tree is a path, say it consists of faces f1, . . . , fk. We draw k + 1 vertical edges between two layers, with the goal that the region between two consecutive ones belong to f1, . . . , fk in this order. Place u and v as segments in the top layer, and with an x-range such that they touch all the regions of faces that u and v are incident to. Similarly create segments for all other vertices. The placement for the vertices is uniquely determined by the standard planar embedding, except for the vertices incident to f1 and fk. We place those vertices such that the leftmost/rightmost vertical edge is not an anchor-edge. To see that this is possible, recall that P connects two non-cutting edges e1, e2 of G that are incident to f1 and fk. If e1 (cid:54)= (u, v), then choose the layer for the vertices of f1 such that e1 is drawn vertical. If e1 = (u, v), then one of its ends (say u) is the degree-2 vertex on f1 and drawn in the top-left corner. The other edge e(cid:48) incident to u is not an anchor-edge of U by Observation 1, and we draw e(cid:48) vertically. So the leftmost vertical edge is either a non-cutting edge (hence not an anchor-edge) or edge e(cid:48) (which is not an anchor-edge). We proceed similarly at fk so that the rightmost vertical edge is not an anchor-edge. Finally all other vertical edges are cutting edges of U0 and hence not anchor-edges. The drawing of P obtained in this first step has (u, v) in the top layer. As a second step, we now release (u, v) as in [5]. This operation can be applied to any edge that is drawn horizontally in the top layer of a flat visibility representation. It consists of adding a layer above the drawing, moving (u, v) into it, and re-routing edges by expanding vertical ones at u and v, and turning horizontal ones into vertical ones. In the result, (u, v) spans the top layer. See Figure 3(b) for an illustration and [5] for details. We now have a drawing of the ribbon P on 3 layers where (u, v) spans the top, say u is in the top left corner. As the third and final step, we add the remaining vertices of the two fans. Consider the fan F1 at u, and let (u, a(cid:96)) be the edge that it has in common with the ribbon P . We have two possible cases. If (u, a(cid:96)) is the leftmost vertical edge, then simply place the vertices of the fan to the left of a(cid:96) and extend u (see Figure 3(c)). Else, (u, a(cid:96)) was drawn horizontally in the drawing of the first step (because it reflects the planar embedding), and therefore after releasing (u, v) there is space to the right of a(cid:96). Into this space we insert the remaining vertices of the fan at u. The fan at v is added in a symmetric fashion. Figure 3(c) illustrates the second case for the fan at v. This finishes the construction of the drawing of U0. It remains to show that all anchor- edges are horizontal and in the bottom two layers. We ensured that this is the case in the first step. Releasing (u, v) adds more vertical edges, but all of them are incident to u or v and not anchor-edges by Observation 1. Likewise, all vertical edges added when inserting the fans are incident to u or v. The only horizontal edge in the top layer is (u, v), which is not an anchor-edge. This finished the proof of Lemma 1. 6 (a) Drawing the ribbon. (b) Releasing (u, v). (c) Adding the fans. (d) Merging hanging subgraphs. Figure 3: From bonnet system to drawing. Now we explain how to merge hanging subgraphs. Theorem 1. Any maximal outerplanar graph G has a planar flat visibility representation of height at most 2bdfree(G) + 1. Proof. We show by induction that any graph with a bonnet system U of depth H has a drawing Γ of height 2H + 1 where the root-edge (u, v) spans the top layer. This proves the theorem when applying it to a bonnet system U of depth bdf ree(G). Let U0 be the root bonnet of the bonnet system, and draw U0 on 3 layers using Lemma 1. Thus (u, v) spans the top and any anchor-edge (a, b) of U0 is drawn as a horizontal edge If H = 1 then we are done. Else add 2H − 2 layers to in the bottom two layers of Γ0. Γ0 between the middle and bottom layers. For each anchor-edge (a, b) of U0, the hanging subgraph Sa,b of U0 has a bonnet system of depth at most H − 1 with root-edge (a, b). By induction Sa,b has a drawing Γ1 on at most 2H − 1 layers with (a, b) spanning the top layer. If (a, b) is in the bottom layer of Γ0, then we can rotate (and reflect, if necessary) Γ1 so that (a, b) is in the bottom layer of Γ1 and the left-to-right order of a and b in Γ1 is the same as their left-to-right order in Γ0. This updated drawing of Γ1 can then be inserted in the space between (a, b) in Γ0. This fits because Γ1 has height at most 2H − 1, and in the insertion process we can re-use the layer spanned by (a, b). If (a, b) is in the middle layer of U0, then we can reflect Γ1 (if necessary) so that (a, b) has the same left-to-right order in Γ1 as in Γ0. This updated drawing of Γ1 can then be inserted in the space between (a, b) in Γ0. See Figure 3(d). Since we added 2H − 2 layers to a drawing of height 3, the total height of the final drawing is 2H + 1 as desired. Our proof is algorithmic, and finds a drawing, given a bonnet system, in linear time. One 7 vurestofPa(cid:96)bre2e(cid:48)f1f2f3f4vua(cid:96)brrestofPva(cid:96)brrestofPF1F2uvunewlayersabSa,bxySx,y can also show (see the appendix) that the rooted bonnet depth, and an associated bonnet system, can be found in linear time using dynamic programming. Hence the run-time to find this drawing is linear. Comparison to [5]: The algorithm in [5] has only two small difference. The main one is that it does not do the "third step" when drawing the root umbrella, thus it draws the ribbon but not the fans. Thus in the induction step our algorithm always draws at least as much as the one in [5]. Secondly, [5] uses a special construction if pw(G) = 1 to save a constant number of levels. This could easily be done for our algorithm as well in the case where pw(G) = 1 but bd(G) = 2. As such, our construction never has worse height (and frequently it is better). Comparison to [3]: One can argue that bd(G) ≤ log(n + 1) (see the appendix). Since [3] uses 3 log n − 1 levels while ours uses 2bd(G) + 1 ≤ 2 log(n + 1) + 1 levels, the upper bound on the height is better for n ≥ 9. 5 From Drawing to Umbrella System We now argue that any flat visibility representation of height H gives rise to an umbrella system of depth at most H − 1, proving a lower bound. We first briefly sketch the idea. We assume that we have a drawing such that for some non-cutting edge (u, v) we have an "escape path", i.e., a poly-line to the outerface that does not intersect the drawing. Now find an outerplanar path that connects the leftmost vertical edge (x, y) of the drawing with (u, v). This becomes the handle of an umbrella U with cap (u, v), and the fans consist of all remaining neighbours of u and v. One can now argue that any hanging subgraph of U is drawn with height at most H − 1, and furthermore, has an escape path from its anchor-edge. The claim then holds by induction. We first must clarify some definitions. Let Γ be a flat visibility representation, and let BΓ be a minimum-height bounding box of Γ. A vertex v ∈ G has a left escape path in Γ if there exists a polyline inside BΓ from v to a point on the left side of BΓ that is vertex-disjoint from Γ except at v, and for which all bends are on layers. We say that ((cid:96)1, (cid:96)2) is a left-free edge of Γ if it is vertical, and any layer intersected by ((cid:96)1, (cid:96)2) is empty to the left of ((cid:96)1, (cid:96)2). In particular, both (cid:96)1 and (cid:96)2 have a left escape path by going leftwards in their respective layers. Define right escape paths and right-free edges symmetrically; we use escape path for either a left escape path or a right escape path. See Figure 4(a). It is easy to see that any flat visibility representation has a left-free edge, presuming the graph has minimum degree at least 2. Let (v, w) be the leftmost vertical edge (breaking ties arbitrarily); there must be such an edge because the leftmost vertex in each layer has at most one horizontal incident edge, and therefore at least one vertical one. In any layer spanned by (v, w), no vertical edge is farther left by assumption. No vertex can be farther left either, else the incident vertical edge of the leftmost of them would be farther left. So (v, w) is left-free. For the proof of the lower bound, we use as handle an outerplanar path connecting to a left-free edge. Recall that the definition of handle requires that it connects to a non-cutting 8 (a) (b) Figure 4: Vertex w has a right escape path, ((cid:96)1, (cid:96)2) is left-free and (r1, r2) is right-free. After flipping the cutting component at ((cid:96)1, (cid:96)2), there is a non-cutting edge that is left-free. edge, so we need a left-free edge that is not a cutting edge. This does not exist in all drawings (see e.g. Figure 4(a)), but as we show now, we can modify the drawing without increasing height such that such an edge exists. To be able to apply it later, we must also show that this modification does not destroy a given escape path. Lemma 2. Let Γ be a flat visibility representation of a maximal outerplanar graph G. 1. Let (r1, r2) be a right-free edge of Γ, and let w be a vertex that has a right escape path. Then there exists a drawing Γ(cid:48) in which w has a right escape path, (r1, r2) is a right-free edge, and there exists a left-free edge that is not a cutting edge of G. 2. Let ((cid:96)1, (cid:96)2) be a left-free edge of Γ, and let w be a vertex that has a left escape path. Then there exists a drawing Γ(cid:48) in which w has a left escape path, ((cid:96)1, (cid:96)2) is a left-free edge, and there exists a right-free edge that is not a cutting edge of G. In either case, the y-coordinates of all vertices in Γ are unchanged in Γ(cid:48), and in particular both drawings have the same height. Proof. We prove the claim by induction on n and show only the first claim (the other is symmetric). Let ((cid:96)1, (cid:96)2) be the leftmost vertical edge of Γ; this is left-free as argued above. If ((cid:96)1, (cid:96)2) is not a cutting edge of G, then we are done with Γ(cid:48) = Γ. In particular, this is the case if n = 3 when G is a triangle and has no cutting edge. So assume n ≥ 4 and ((cid:96)1, (cid:96)2) is a cutting edge of G. Let A and B be the cut-components of ((cid:96)1, (cid:96)2), named such that w ∈ A. Let ΓA [resp. ΓB] be the drawing of A [B] induced by Γ. Edge ((cid:96)1, (cid:96)2) is left-free for both ΓA and ΓB. Reflect ΓB horizontally (this makes ((cid:96)1, (cid:96)2) right-free) to obtain Γ(cid:48) B in which ((cid:96)1, (cid:96)2) is right-free and there is a left-free edge ((cid:96)(cid:48) 2) that is not a cutting edge of B. We have 2) (cid:54)= ((cid:96)1, (cid:96)2), because the common neighbour of (cid:96)1, (cid:96)2 in B forces a vertex or edge to ((cid:96)(cid:48) 1, (cid:96)(cid:48) reside to the left of the right-free edge ((cid:96)1, (cid:96)2). So ((cid:96)(cid:48) 2) is not a cutting edge of G either. Create a new drawing that places Γ(cid:48)(cid:48) B to the left of ΓA and extends (cid:96)1 and (cid:96)2 to join the two copies; this is possible since ((cid:96)1, (cid:96)2) has the same y-coordinates in ΓA, Γ, ΓB and Γ(cid:48)(cid:48) B, and it is left-free in ΓA and right-free in Γ(cid:48)(cid:48) B. Also delete one copy of ((cid:96)1, (cid:96)2). See Figure 4(b). B. By induction, we can create a drawing Γ(cid:48)(cid:48) B from Γ(cid:48) 1, (cid:96)(cid:48) 1, (cid:96)(cid:48) 9 r1(cid:96)1(cid:96)2wr2r1(cid:96)1(cid:96)2wr2ΓA(cid:96)1(cid:96)2Γ(cid:48)B=Γ(cid:48)(cid:48)B(cid:96)(cid:48)1(cid:96)(cid:48)2 The drawing ΓA is unchanged, so w will have the same right escape path in Γ(cid:48) as in Γ, and Γ(cid:48) will have right-free edge (r1, r2) and left-free non-cutting edge ((cid:96)(cid:48) 2), as desired. 1, (cid:96)(cid:48) We are now ready to prove the lower bound if there is an escape path. Lemma 3. Let Γ be a flat visibility representation of a maximal outerplanar graph G with height H, and let (u, v) be a non-cutting edge of G. If there exists an escape path from u or v in Γ, then G has an umbrella system with root-edge (u, v) and depth at most H − 1. Proof. We proceed by induction on H. Assume without loss of generality that there exists a right escape path from v (all other cases are symmetric). Using Lemma 2, we can modify Γ without increasing the height so that v has a right escape path, and there is a left-free edge ((cid:96)1, (cid:96)2) in Γ that is a not a cutting edge of G. Let P be the outerplanar path that connects edge ((cid:96)1, (cid:96)2) and (u, v). Let U0 be the union of P , the neighbors of u, and the neighbors of v; we use U0 as the root umbrella of an umbrella system. We now must argue that all hanging subgraphs of U0 are drawn with height at most H − 1 and have escape paths from their anchor-edges; we can then find umbrella systems for them by induction and combining them with U0 gives the umbrella system for G as desired. To prove the height-bound, we define "dividing paths" as follows. The outer-face of U0 in the standard embedding contains ((cid:96)1, (cid:96)2) (since it is not a cutting edge) as well as v. Let P1 and P2 be the two paths from (cid:96)1 and (cid:96)2 to v along this outer-face in the standard embedding. Define the dividing path Πi (for i = 1, 2) to be the poly-line in Γ that consist of the left escape path from (cid:96)i, then the drawing of the path Pi (i.e., the vertical segments of its edges and parts of the horizontal segments of its vertices), and then the right escape path from v. See Figure 5. Figure 5: Extracting dividing paths from a flat visibility representation. P1/Π1 is dotted while P2/Π2 is dashed. Now consider any hanging subgraph Sa,b of U0 with anchor-edge (a, b). No edge incident to v is an anchor-edge, and neither is ((cid:96)1, (cid:96)2), since it is not a cutting edge. So (a, b) is an edge of P1 or P2 (say P1) that is not incident to v. Therefore (a, b) (and with it Sa,b) is vertex-disjoint from P2. In consequence, the drawing ΓS of Sa,b induced by Γ is disjoint from the dividing path Π2. Since Π2 connects a point on the left boundary with a point on the right boundary, therefore ΓS must be entirely above or entirely below Π2, say it is above. Since Π2 has all bends at points with integral y-coordinate, therefore the bottom layer of Γ is not available for ΓS. In consequence ΓS has height at most H − 1 as desired. 10 uvab(cid:96)1(cid:96)2Sa,bP1P2uvba(cid:96)1(cid:96)2Sa,bΠ2Π1 Recall that (a, b) belongs to P1 and is not incident to v. After possible renaming of a and b, we may assume that b is closer to (cid:96)1 along P1 than a. Then the sub-path of P1 from b to (cid:96)1 is interior-disjoint from Sa,b. This path, together with the left escape path from (cid:96)1, is a left escape path from b that resides within the top H − 1 layers, because it does not contain v and hence is disjoint from Π2. We can hence apply induction to Sa,b to obtain an umbrella system of depth at most H − 2 with root-edge (a, b). Repeating this for all hanging subgraphs, and combining the resulting umbrella systems with U0, gives the result. Theorem 2. Let G be a maximal outerplanar graph. If G has a flat visibility representation Γ of height H, then udfree(G) ≤ H − 1. Proof. Using Lemma 2, we can convert Γ into a drawing Γ(cid:48) of the same height in which some edge (u, v) is a right-free non-cutting edge. This implies that there is a right escape path from v, and by Lemma 3 we can find an umbrella system of G with root-edge (u, v) and depth H − 1. So udfree ≤ ud(G; u, r) ≤ H − 1. 6 Conclusions and Future Work We presented an algorithm for drawing maximal outerplanar graphs that is a 2-approximation for the optimal height. To this end, we introduced the umbrella depth as a new graph pa- rameter for maximal outerplanar graphs, and used as key result that any drawing of height H implies an umbrella-depth of at least H−1. Our result significantly improves the previous best result, which was based on the pathwidth and gave a 4-approximation. We close with some open problems: • Our result only holds for maximal outerplanar graphs. Can the algorithm be modified so that it works for all outerplanar graphs? Specifically, can we make an outerplanar graph maximal in such a way that the umbrella depth does not increase (much)? • The algorithm from Section 4 creates a drawing that does not place all vertices on the outer face. Can we create an algorithm that minimizes or approximates the optimal height when the standard planar embedding must be respected? • What is the width achieved by the algorithm from Section 4? Any visibility represen- tation can be modified without changing the height so that the width is at most m + n, where m is the number of edges and n is the number of vertices [6]. Thus the width is O(n), but what is the constant? • Is it possible to determine the optimal height for maximal outerplanar graphs in poly- nomial time? Finally, are there approximation algorithms for the height or the area of drawings for other, more general planar graph classes? 11 References [1] Md. J. Alam, Md. A.H. Samee, M. Rabbi, and Md. S. Rahman. Minimum-layer upward drawings of trees. J. Graph Algorithms Appl., 14(2):245 -- 267, 2010. [2] J. Batzill and T. Biedl. Order-preserving drawings of trees with approximately optimal height (and small width), 2016. CoRR 1606.02233 [cs.CG]. In submission. [3] T. Biedl. Drawing outer-planar graphs in O(n log n) area. In Graph Drawing (GD'01), volume 2528 of LNCS, pages 54 -- 65. Springer-Verlag, 2002. Full version appeared in [4]. [4] T. Biedl. Small drawings of outerplanar graphs, series-parallel graphs, and other planar graphs. Discrete and Computational Geometry, 45(1):141 -- 160, 2011. [5] T. Biedl. A 4-approximation algorithm for the height of drawing 2-connected outerpla- nar graph. In Workshop on Approximation and Online Algorithms (WAOA'12), volume 7846 of LNCS, pages 272 -- 285. Springer-Verlag, 2013. [6] T. Biedl. Height-preserving transformations of planar graph drawings. In Graph Drawing (GD'14), volume 8871 of LNCS, pages 380 -- 391. Springer, 2014. [7] T. Biedl. On area-optimal planar grid-drawings. In International Colloquium on Au- tomata, Languages and Programming (ICALP '14), volume 8572 of LNCS, pages 198 -- 210. Springer-Verlag, 2014. [8] T. Biedl. Ideal tree-drawings of approximately optimal width (and small height), 2015. CoRR 1502.02753 [cs.CG]. Conditionally accepted in JGAA. [9] G. Di Battista and F. Frati. Small area drawings of outerplanar graphs. Algorithmica, 54(1):25 -- 53, 2009. [10] V. Dujmovic, M. Fellows, M. Kitching, G. Liotta, C. McCartin, N. Nishimura, P. Ragde, F. Rosamond, S. Whitesides, and D. Wood. On the parameterized complexity of layered graph drawing. Algorithmica, 52:267 -- 292, 2008. [11] S. Felsner, G. Liotta, and S. Wismath. Straight-line drawings on restricted integer grids in two and three dimensions. J. Graph Alg. Appl, 7(4):335 -- 362, 2003. [12] F. Frati. Straight-line drawings of outerplanar graphs in O(dn log n) area. Comput. Geom., 45(9):524 -- 533, 2012. [13] H. de Fraysseix, J. Pach, and R. Pollack. How to draw a planar graph on a grid. Combinatorica, 10:41 -- 51, 1990. [14] A. Garg and A. Rusu. Area-efficient planar straight-line drawings of outerplanar graphs. Discrete Applied Mathematics, 155(9):1116 -- 1140, 2007. 12 [15] L.S. Heath and A.L. Rosenberg. Laying out graphs using queues. SIAM Journal on Computing, 21(5):927 -- 958, 1992. [16] M. Krug and D. Wagner. Minimizing the area for planar straight-line grid drawings. In Graph Drawing (GD'07), volume 4875 of LNCS, pages 207 -- 212. Springer-Verlag, 2007. [17] D. Mondal, Md. J. Alam, and Md. S. Rahman. Minimum-layer drawings of trees. In Algorithms and Computations (WALCOM 2011), volume 6552 of LNCS, pages 221 -- 232. Springer, 2011. [18] W. Schnyder. Embedding planar graphs on the grid. In ACM-SIAM Symposium on Discrete Algorithms (SODA '90), pages 138 -- 148, 1990. [19] M. Suderman. Pathwidth and layered drawings of trees. Intl. J. Comp. Geom. Appl, 14(3):203 -- 225, 2004. 13 A Computing the Depth We now introduce a dynamic programming algorithm for finding the rooted bonnet depth of a maximal outerplanar graph G, relative to a given fixed root-edge (u, v). (A very similar algorithm finds the umbrella depth; we leave those details to the reader.) As before, for any cutting edge (a, b) of G let Sa,b is the cut-component of G that does not contain (u, v). It will also be convenient to define Sa,b := {(a, b)} if (a, b) is a non-cutting edge with (a, b) (cid:54)= (u, v), and to define Su,v := G. We also use the notation ud(a, b) := ud(Sa,b; a, b) and define ud(a, b) = 0 if Sa,b is a single edge. We first sketch the overall idea. Consider one subgraph Sa,b and the root bonnet U0 used in the bonnet system of minimum depth. The ribbon of U0 is an outerplanar path connecting edges e1 and e2, but we can view it as two outerplanar paths, connecting the root-edge (a, b) to one of e1 and e2. If c is the common neighbour of a and b, then we can hence split the bonnet into two parts by removing the face {a, b, c}. Each part looks much like an umbrella, except that they are rooted at (a, c) and (c, b), respectively, and each of them has no fan at c. See also Figure 6(a). Therefore the minimum bonnet depth can be found by finding the minimum-depth in the two subgraphs Sa,c and Sb,c, under the restriction that the root bonnets in the corresponding systems are such partial umbrellas. We must repeat the argument for the partial umbrellas, breaking them into a fan and a handle, and hence end up computing 6 different types of depths for each anchor edge, but 6 types are enough and hence the overall run-time is linear. We now define these variants of bonnet-depth for Sa,b: • A handle is an outerplanar path that connects (a, b) to some non-cutting edge. See Figure 6(b). Define bdh(a, b) := 1 + min U h max (x,y) bd(x, y) (cid:110) (cid:110) (cid:111) (cid:111) where U h is a handle and (x, y) is a non-cutting edge of U h. • The full fan at a [resp. full fan at b] consists of a [b] and all neighbours of a [b]. See Figure 6(c). Define bdfa(a, b) := 1 + max (x,y) bd(x, y) where (x, y) is a non-cutting edge of the full fan at a. Symmetrically define bdfb(a, b) using the full fan at b. • A partial-a umbrella [resp. partial-b umbrella] is an umbrella with cap (a, b) that con- tains all neighbours of a [b] and in which the fan at b [a] is empty. See Figure 6(d). Define bdpa(a, b) := 1 + min U pa max (x,y) bd(x, y) where U pa is a partial-a umbrella and (x, y) is a non-cutting edge of U pa. Symmetrically define bdhb(a, b) using a partial-b umbrella. 14 (a) Bonnet. (b) Handle. (c) Full fan. (d) Partial umbrella. Figure 6: For the recursive formulas. Edges that may be anchor-edges are dashed. . Lemma 4. We have udt(a, b) = 0 if Sa,b is a single edge, where t ∈ {∅, h, fa, fb, pa, pb}. Else, letting c be the common neighbour of a and b, we have 1. bd(a, b) = max{bdpa(a, c), bdpb(c, b)} 2. bdh(a, b) = min(cid:2)max{bdh(a, c), 1 + bd(c, b)}, max{1 + bd(a, c), bdh(c, b)}(cid:3) 5. bdpa(a, b) = min(cid:2)max{bdpa(a, c), 1 + bd(c, b)}, max{bdfa(a, c), bdh(c, b)}(cid:3) 6. bdpb(a, b) = min(cid:2)max{1 + bd(a, c), bdpb(c, b)}, max{bdh(a, c), bdfb(c, b)}(cid:3) 3. bdfa(a, b) = max{bdfa(a, c), 1 + bd(c, b)} 4. bdfb(a, b) = max{1 + bd(a, c), bdfb(c, b)} Proof. All these formulas are proved in a similar way: Consider the root bonnet U0 of the bonnet system that achieves the depth on the left side. When splitting this bonnet into two by removing the face {a, b, c}, we obtain two bonnets for the two subgraphs Sa,c and Sc,b and can argue what type they are. (Sometimes there may be two possibilities, depending on which direction the handle of U0 went, in case of which the one that yields the smaller depth is used.) This proves "≥", and equality is easily shown by putting together bonnet systems of Sa,c and Sc,b of the appropriate type. We demonstrate this in detail for (5); see also Figure 6(d). So assume we have an umbrella system U with root-edge (a, b) that has depth bdpa(a, b) and where the root-bonnet U0 is a partial-a umbrella. So U0 consists of a handle P and a fan at a that includes all neighbours of a not in P . Since P is a handle, it connects to (a, b), therefore not both edges (a, c) and (c, b) can be cutting edges of P . 15 abcabcSc,bbacSa,cabcSc,babcSc,babcSc,babc We distinguish cases. In the first case, (c, b) is not a cutting edge of P . Since the fan at b is empty in U0, (c, b) is not a cutting edge of U0 either. Thus the formula for bdpa(a, b) includes the term 1 + ud(c, b) in the maximum. Furthermore, U0−{b} is a partial-a umbrella for Sa,c, and this, together with the subsystems of U for its hanging subgraphs, gives a bonnet system with depth at least bdpa(a, c). Therefore bdpa(a, b) ≥ max{bdpa(a, c), 1 + ud(c, b)} in the first case. In the second case, (a, c) is not a cutting edge of P . Therefore the fan of U0 at a consists of a and all neighbours of a except b, and thus is the full fan F at a in the subgraph Sa,c. The subsystems of U for hanging subgraphs of F give a bonnet system for Sa,c where the root bonnet is the full fan at a, hence it has depth at least bdfa(a, c). Furthermore, P − {a} is a handle for Sc,b. So U implies a bonnet system for Sc,b where the root is a handle, hence it has depth at least bdh(c, b). Therefore bdpa(a, b) ≥ max{bdfa(a, c), udh(c, b)} in the second case. One of the two cases must apply, and so bdpa(a, b) is at least as big as the smaller of the two bounds and "≥" holds. To show "≤", let us assume that the minimum is achieved at max{bdfa(a, c), udh(c, b)} (the other case is similar). Find a bonnet system U f of Sa,c of depth bdfa(a, c) where the root bonnet F is the full fan at a, and a bonnet system U h of Sc,b of depth udh(c, b) where the root bonnet U h is a handle. Then F ∪ U h ∪ {(a, b)} is a partial-a umbrella U0, and combining it with the subsystems of U f and U h gives a bonnet system of Sa,c whose depth is max{bdfa(a, c), udh(c, b)}. We can convert these formulas into a dynamic programming algorithm to compute the bonnet depth by using the standard bottom-up traversal in a tree. Given a maximal out- erplanar graph G, initialize udt(a, b) = 0 for all types t and for all non-cutting-edges (a, b) with the exception of (u, v). Root the dual tree T at the face incident to root-edge (u, v). Any node of T is associated with a cutting-edge of G by taking the dual of the arc that connects the node with its parent in T . Traversing T bottom up, when we encounter a node f of T (hence a face of G) we have obtained the bonnet depth values for two out of the three edges incident to f already, and can compute the bonnet depth values for the third using the above formulas. This takes O(1) time since there are 6 values and each formula can be evaluated in constant time. Finally we evaluate at the root of T , which gives bd(G; u, v). Since T has n − 3 nodes, the total run-time is O(n). Theorem 3. Given a non-cutting edge (u, v), there exists an O(n) algorithm to find the rooted umbrella depth ud(G; u, v) of a maximal outerplanar graph G with n vertices. A.1 Free vs. Rooted Umbrella/Bonnet Depth Note that our algorithm computes the rooted bonnet depth for G, since the root-edge (u, v) must be given. One way to instead find the free bonnet depth is to repeat the process described above for every choice of root-edge in G. This would give an O(n2) algorithm for finding the free bonnet depth. One could likely compute the free bonnet depth in O(n) time by initializing udt(a, b) = 0 for all non-cutting edges, then updating at the face where the 16 resulting bonnet depth is minimized, and using as root-edge one near where we update last. However, as we will show now, the free bonnet depth is at most one less than the rooted bonnet depth, and therefore it does not seem worth the minor improvement to work out the details of this approach. Lemma 5. Given a maximal outerplanar graph G, we have bdfree(G) = min (u,v) {bd(G, u, v)} ≤ max (u,v) {bd(G, u, v)} ≤ bdfree(G) + 1 where the minimum and maximum are taken over all non-cutting edges (u, v) of G. Proof. The first equality holds per definition, and the second inequality is obvious, so we focus on the third inequality. Let U∗ be a bonnet system on G with depth H := bdfree(G) and let (u∗, v∗) be its root-edge, which by definition is not a cutting edge. Let (u, v) be an arbitrary non-cutting edge; it suffices to show bd(G; u, v) ≤ bd(G; u∗, v∗) + 1 = H + 1. Let P be the outer-planar path that connects (u, v) and (u∗, v∗) and define a bonnet U with cap (u, v) to consist of P and the fans at u and v that include all neighbours of u, v not in P .2 We claim that any hanging subgraph Sa,b of U with anchor-edge (a, b) has rooted bonnet depth bd(Sa,b; a, b) ≤ H. Observe that (u∗, v∗) is not an edge of Sa,b, because (u∗, v∗) is not a cutting edge, and (u∗, v∗) ∈ U while Sa,b is disjoint from U except at cutting edge (a, b). Therefore the cutting edge (a, b) has the root-edge (u∗, v∗) of U∗ in one component and Sa,b in the other. One easily argues that therefore bd(Sa,b; a, b) ≤ d(U∗), because the bonnets of U∗ can be used to build a bonnet system US of Sa,b after trimming parts in G − Sa,b and expanding each bonnet as to include all neighbours of the ends of its cap. Thus Sa,b has an umbrella system US with depth at most d(U∗) = H. Combining the umbrella systems of these hanging subgraphs with U gives an umbrella system of G with root-edge (u, v) and depth at most H + 1 as desired. B Comparison with Other Graph Parameters In this section, we compare the bonnet depth and the umbrella depth to the pathwidth (the other graph parameter previously used for graph drawing purposes), as well as the so- called rooted pathwidth. We define these parameters first. Let T be a tree. The pathwidth pw(T ) of T is 0 if T is a single node, and 1 + minP maxT (cid:48)⊂T−P pw(T (cid:48)) otherwise. Here P is an arbitrary path in T , and T (cid:48) is any subtree that remains after deleting the vertices of P . Any path where the minimum is achieved is called a main path of T . See [19] for more details. The rooted pathwidth is quite similar, but forces the path to end at the root. Thus, let T be a rooted tree. The rooted pathwidth rpw(T ) is 0 if T is empty and 1 + minPr maxT (cid:48)⊂T−Pr rpw(T (cid:48)) otherwise. Here Pr is a path in T that ends at the root of T and T (cid:48) is any subtree that remains after deleting the vertices of Pr, where T (cid:48) is rooted as 2U is actually an umbrella, and indeed the same chain of inequalities holds if we replace 'bd' by 'ud' everywhere. 17 induced by the root of T . Any path where the minimum is achieved is called an rpw-main path. See [8] for more details. We write rpw(T, r) if the root r is not clear from the context, and define rpwfree(T ) := minr rpw(T, r). It is not hard to see that minr rpw(T, r) is attained at a leaf r, because for any interior node r we could have used an even longer rpw-main path to reach a leaf without making any subtree bigger. Lemma 6. Let G be a maximal outerplanar graph G with dual tree T ,. Then pw(T ) ≤ bdfree(G) ≤ udfree(G) ≤ rpwfree(T ) ≤ max{1, 2pw(T )}. 1 2 Proof. We first show that pw(T ) ≤ 2bd(G; u, v) for any choice of root-edge (u, v). Fix any bonnet system that has depth H := bd(G; u, v) and root-edge (u, v), and let U0 be its root- umbrella. Recall that U0 is split into the ribbon P , which is an outer-planar path, and the two fans F1, F2, which are also outer-planar paths. Use the dual tree P ∗ of P as main path i of Fi in the subtree Ti of T − P ∗ that contains for T , and for i = 1, 2, use the dual tree F ∗ i . Any subtree T (cid:48) of T − P ∗ − F ∗ F ∗ 2 corresponds to a hanging subgraph of U that has bonnet depth at most H − 1. By induction pw(T (cid:48)) ≤ 2H − 2, and pw(T ) ≤ 2H as desired. Since an umbrella is a bonnet, we have bd(G; u, v) ≤ ud(G; u, v) for all non-cutting edges 1 − F ∗ (u, v), and the second inequality holds. For the third inequality, assume that H := rpwfree(T ) is attained when rooting T at leaf r, and let (u, v) be a non-cutting edge of G incident to r. We claim that ud(G; u, v) ≤ rpw(T, r) = H. Let P ∗ be an rpw-main path of T ; without loss of generality we may assume that P ∗ connects from r to a leaf of T (else a longer path could be used). Let P be the outerplanar path whose dual tree is P ∗; it connects (u, v) to some non-cutting edge since P ∗ connects r to a leaf of T . Let U0 be the umbrella obtained by adding all other neighbours of u and v to P . For any hanging subgraph Sa,b of P , the dual tree TS is a subtree of T − P ∗, and therefore rpw(TS) ≤ H − 1. By induction, ud(Sa,b; a, b) ≤ H − 1, and combining the umbrella systems of the hanging subgraphs with U0 hence shows ud(G; u, v) ≤ H as desired. For the last inequality, we already know that rpw(T, r) ≤ 2pw(T ) + 1 for all choices of the root r [8]. To prove the slightly tighter bound, assume that P is a main path of T and let r be its end. Root T at r, and use P as rpw-main path. If T = P , then rpw(T ) = 1 and we are done. Else pw(T ) ≥ 1 and any subtree T (cid:48) of T − P has pw(T (cid:48)) ≤ pw(T )− 1. The bound in [8] gives rpw(T (cid:48)) ≤ 2pw(T ) − 1. Thus rpw(T, r) ≤ 1 + maxT (cid:48) rpw(T (cid:48)) ≤ 2pw(T ). It is known that rpw(T ) ≤ log(n + 1) [8], and therefore bdfree(G) ≤ log(n + 1) as claimed earlier. All bounds in Lemma 6 are tight, except for a '+1' term. Both graphs to show this are constructed as follows. Define a small graph G1 that has a marked root-edge (u, v) and some marked anchor-edges. Obtain graph Gi by starting with graph G1 and attaching copies of Gi−1 such that the root-edge of each Gi−1 is one of the anchor-edges of G1. Let Ti be the dual tree of graph Gi. We leave to the reader to verify the following claims: • For the construction using the graph in Figure 7(a), we have pw(Ti) ≥ 2i while ud(Gi; u, v) ≤ i. Therefore i ≤ 1 2 pw(Ti) ≤ bdfree(Gi) ≤ udfree(Gi) ≤ ud(Gi; u, v) ≤ i, 18 and the left two inequalities are tight. • For the construction using the graph in Figure 7(b), we have pw(Ti) ≤ i and ud(Gi; u, v) ≥ 2i. Therefore 2i ≤ ud(Gi; u, v) ≤ udfree(Gi) + 1 ≤ rpwfree(Gi) + 1 ≤ 2pw(Ti) + 1 ≤ 2i + 1, and the third and fourth inequality are tight up to a '+1' term. (a) (b) Figure 7: Constructions to prove tightness. 19 uva1a2a3b1b2b3b4a4c1c2c3uva'b'c'arbry'xyrcr
1104.1377
1
1104
2011-04-07T16:55:23
Fast Local Computation Algorithms
[ "cs.DS" ]
For input $x$, let $F(x)$ denote the set of outputs that are the "legal" answers for a computational problem $F$. Suppose $x$ and members of $F(x)$ are so large that there is not time to read them in their entirety. We propose a model of {\em local computation algorithms} which for a given input $x$, support queries by a user to values of specified locations $y_i$ in a legal output $y \in F(x)$. When more than one legal output $y$ exists for a given $x$, the local computation algorithm should output in a way that is consistent with at least one such $y$. Local computation algorithms are intended to distill the common features of several concepts that have appeared in various algorithmic subfields, including local distributed computation, local algorithms, locally decodable codes, and local reconstruction. We develop a technique, based on known constructions of small sample spaces of $k$-wise independent random variables and Beck's analysis in his algorithmic approach to the Lov{\'{a}}sz Local Lemma, which under certain conditions can be applied to construct local computation algorithms that run in {\em polylogarithmic} time and space. We apply this technique to maximal independent set computations, scheduling radio network broadcasts, hypergraph coloring and satisfying $k$-SAT formulas.
cs.DS
cs
Fast Local Computation Algorithms Ronitt Rubinfeld∗ Gil Tamir† Shai Vardi ‡ Ning Xie § Abstract For input x, let F (x) denote the set of outputs that are the "legal" answers for a computational problem F . Suppose x and members of F (x) are so large that there is not time to read them in their entirety. We propose a model of local computation algorithms which for a given input x, support queries by a user to values of specified locations yi in a legal output y ∈ F (x). When more than one legal output y exists for a given x, the local computation algorithm should output in a way that is consistent with at least one such y. Local computation algorithms are intended to distill the common features of several concepts that have appeared in various algorithmic subfields, including local distributed computation, local algorithms, locally decodable codes, and local reconstruction. We develop a technique, based on known constructions of small sample spaces of k-wise independent random variables and Beck's analysis in his algorithmic approach to the Lovász Local Lemma, which under certain conditions can be applied to construct local computation algorithms that run in polyloga- rithmic time and space. We apply this technique to maximal independent set computations, scheduling radio network broadcasts, hypergraph coloring and satisfying k-SAT formulas. 1 1 0 2 r p A 7 ] S D . s c [ 1 v 7 7 3 1 . 4 0 1 1 : v i X r a ∗CSAIL, MIT, Cambridge MA 02139 and School of Computer Science, Tel Aviv University. E-mail: [email protected]. Supported by NSF grants 0732334 and 0728645, Marie Curie Reintegration grant PIRG03- GA-2008-231077 and the Israel Science Foundation grant nos. 1147/09 and 1675/09. †School of Computer Science, Tel Aviv University. E-mail: [email protected]. Supported by Israel Science Foundation grant no. 1147/09. ‡School of Computer Science, Tel Aviv University. E-mail: [email protected]. Supported by Israel Science Founda- tion grant no. 1147/09. §CSAIL, MIT, Cambridge MA 02139. E-mail: [email protected]. Part of the work was done while visiting Tel Aviv University. Research supported in part by NSF Award CCR-0728645. 0 1 Introduction Classical models of algorithmic analysis assume that the algorithm reads an input, performs a computation and writes the answer to an output tape. On massive data sets, such computations may not be feasible, as both the input and output may be too large for a single processor to process. Approaches to such situations range from proposing alternative models of computation, such as parallel and distributed computation, to requiring that the computations achieve only approximate answers or other weaker guarantees, as in sublinear time and space algorithms. In this work, we consider the scenario in which only specific parts of the output y = (y1, . . . , ym) are needed at any point in time. For example, if y is a description of a maximal independent set (MIS) of a graph such that yi = 1 if i is in the MIS and yi = 0 otherwise, then it may be sufficient to determine yi1, . . . , yik for a small number of k vertices. To this end, we define a local computation algorithm, which supports queries of the form "yi =?" such that after each query by the user to a specified location i, the local computation algorithm is able to quickly outputs yi. For problems that allow for more than one possible output for an input x, as is often the case in combinatorial search problems, the local computation algorithm must answer in such a way that its current answer to the query is consistent with any past or future answers (in particular, there must always be at least one allowable output that is consistent with the answers of the local computation algorithm ). For a given problem, the hope is that the complexity of a local computation algorithm is proportional to the amount of the solution that is requested by the user. Local computation algorithms are especially adapted to computations of good solutions of combinatorial search problems (cf. [36, 30, 35]). Local computation algorithms are a formalization that describes concepts that are ubiquitous in the lit- erature, and arise in various algorithmic subfields, including local distributed computation, local algorithms, locally decodable codes and local reconstruction models. We subsequently describe the relation between these models in more detail, but for now, it suffices it to say that the aforementioned models are diverse in the computations that they apply to (for example, whether they apply to function computations, search prob- lems or approximation problems), the access to data that is allowed (for example, distributed computation models and other local algorithms models often specify that the input is a graph in adjacency list format), and the required running time bounds (whether the computation time is required to be independent of the problem size, or whether it is allowed to have computation time that depends on the problem size but has sublinear complexity). The model of local computation algorithms described here attempts to distill the essential common features of the aforementioned concepts into a unified paradigm. After formalizing our model, we develop a technique that is specifically suitable for constructing poly- logarithmic time local computation algorithms. This technique is based on Beck's analysis in his algorithmic approach to the Lovász Local Lemma (LLL) [11], and uses the underlying locality of the problem to con- struct a solution. All of our constructions must process the data somewhat so that Beck's analysis applies, and we use two main methods of performing this processing. For maximal independent set computations and scheduling radio network broadcasts, we use a reduction of Parnas and Ron [36], which shows that, given a distributed network in which the underlying graph has degree bounded by a constant D, and a distributed algorithm (which may be randomized and only guaranteed to output an approximate answer) using at most t rounds, the output of any specified node of the distributed network can be simulated by a single processor with query access to the input with O(Dt+1) queries. For our first phase, we apply this reduction to a constant number of rounds of Luby's maximal independent set distributed algorithm [29] in order to find a partial solution. After a large independent set is found, in the second phase, we use the techniques of Beck [11] to show 1 For hypergraph coloring and k-SAT, we show that Alon's parallel algorithm, which is guaranteed to find solutions by the Lovász Local Lemma [2], can be modified to run in polylogarithmic sequential time to answer queries regarding the coloring of a given node, or the setting of a given variable. For most of the queries, this is done by simulating the work of a processor and its neighbors within a small constant radius. For the remainder of the queries, we use Beck's analysis to show that the queries can be solved via the brute force algorithm on very small subproblems. Note that parallel O(log n) time algorithms do not directly yield local algorithms under the reduction of Parnas and Ron [36]. Thus, we do not know how to apply our techniques to all problems with fast parallel algorithms, including certain problems in the work of Alon whose solutions are guaranteed by the Lovász Local Lemma and which have fast parallel algorithms [2]. Recently Moser and Tardos [32, 33] gave, under some slight restrictions, parallel algorithms which find solutions of all problems for which the existence of a solution is guaranteed by the Lovász Local Lemma [11, 2]. It has not yet been resolved whether one can construct local computation algorithms based on these more powerful algorithms. 1.1 Related work Our focus on local computation algorithms is inspired by many existing works, which explicitly or implicitly construct such procedures. These results occur in a number of varied settings, including distributed systems, coding theory, and sublinear time algorithms. Local computation algorithms are a generalization of local algorithms, which for graph theoretic prob- lems represented in adjacency list format, produce a solution by adaptively examining only a constant sized portion of the input graph near a specified vertex. Such algorithms have received much attention in the dis- tributed computing literature under a somewhat different model, in which the number of rounds is bounded to constant time, but the computation is performed by all of the processors in the distributed network [34, 31]. Naor and Stockmeyer [34] and Mayer, Naor and Stockmeyer [31] investigate the question of what can be computed under these constraints, and show that there are nontrivial problems with such algorithms. Several more recent works investigate local algorithms for various problems, including coloring, maximal indepen- dent set, dominating set (some examples are in [25, 26, 24, 27, 23, 22, 39, 9, 10, 40]). Although all of these algorithms are distributed algorithms, those that use constant rounds yield (sequential) local computation algorithms via the previously mentioned reduction of Parnas and Ron [36].1 There has been much recent interest among the sublinear time algorithms community in devising local algorithms for problems on constant degree graphs and other sparse optimization problems. The goals of these algorithms have been to approximate quantities such as the optimal vertex cover, maximal matching, maximum matching, dominating set, sparse set cover, sparse packing and cover problems [36, 26, 30, 35, 18, 42]. One feature of these algorithms is that they show how to construct an oracle which for each vertex returns whether it part of the solution whose size is being approximated – for example, whether it is in the vertex cover or maximal matching. Their results show that this oracle can be implemented in time independent of the size of the graph (depending only on the maximum degree and the approximation parameter). However, because their goal is only to compute an approximation of their quantity, they can afford to err on a small fraction of their local computations. Thus, their oracle implementations give local computation algorithms for finding relaxed solutions to the the optimization problems that they are designed for. For example, constructing a local computation algorithm using the oracle designed for estimating the size of a maximal independent set in [30] yields a large independent set, but not necessarily a maximal 1Note that the parallel algorithms of Luby [29], Alon [2] and Moser and Tardos [33] do not automatically yield local algorithms via this transformation since their parallel running times are t = Ω(log n). 2 independent set. Constructing a local computation algorithm using the oracle designed for estimating the size of the vertex cover [36, 30, 35] yields a vertex cover whose size is guaranteed to be only slightly larger than what is given by the 2-approximate algorithm being emulated – namely, by a multiplicative factor of at most 2 + δ (for any δ > 0). Recently, local algorithms have been demonstrated to be applicable for computations on the web graph. In [19, 12, 38, 8, 7], local algorithms are given which, for a given vertex v in the web graph, computes an approximation to v's personalized PageRank vector and computes the vertices that contribute significantly to v's PageRank. In these algorithms, evaluations are made only to the nearby neighborhood of v, so that the running time depends on the accuracy parameters input to the algorithm, but there is no running time dependence on the size of the web-graph. Local graph partitioning algorithms have been presented in [41, 8] which find subsets of vertices whose internal connections are significantly richer than their external connections. The running time of these algorithms depends on the size of the cluster that is output, which can be much smaller than the size of the entire graph. Though most of the previous examples are for sparse graphs or other problems which have some sort of sparsity, local computation algorithms have also been provided for problems on dense graphs. The property testing algorithms of [17] use a small sample of the vertices (a type of a core-set) to define a good graph coloring or partition of a dense graph. This approach yields local computation algorithms for finding a large partition of the graph and a coloring of the vertices which has relatively few edge violations. The applicability of local computation algorithms is not restricted to combinatorial problems. One algebraic paradigm that has local computation algorithms is that of locally decodable codes [21], described by the following scenario: Suppose m is a string with encoding y = E(m). On input x, which is close in Hamming distance to y, the goal of locally decodable coding algorithms is to provide quick access to the requested bits of m. More generally, the reconstruction models described in [1, 13, 37] describe scenarios where a string that has a certain property, such as monotonicity, is assumed to be corrupted at a relatively small number of locations. Let P be the set of strings that have the property. The reconstruction algorithm gets as input a string x which is close (in L1 norm), to some string y in P . For various types of properties P , the above works construct algorithms which give fast query access to locations in y. 1.2 Followup work In a recently work, Alon et al. [6] further show that the local computation algorithms in this work can be modified to not only run in polylogarithmic time but also in polylogarithmic space. Basically, they show that all the problems studied in this paper can be solved in a unified local algorithmic framework as follows: first the algorithm generates some random bits on a read-only random tape of size at most polylogarithmic in the input, which may be thought as the "core" of a solution y ∈ F (x); then each bit of the solution y can be computed deterministically by first querying a few bits on the random tape and then performing some fast computations on these random bits. The main technical tools used in [6] are pseudorandomness, the random ordering idea of [35] and the theory of branching processes. 1.3 Organization The rest of the paper is organized as follows. In Section 2 we present our computation model. Some prelim- inaries and notations that we use throughout the paper appear in Section 3. We then give local computation algorithms for the maximal independent set problem and the radio network broadcast scheduling problem in Section 4 and Section 5, respectively. In Section 6 we show how to use the parallel algorithmic version of 3 the Lovász Local Lemma to give local computation algorithms for finding the coloring of nodes in a hyper- graph. Finally, in Section 7, we show how to find settings of variables according to a satisfying assignment of a k-CNF formula. 2 Local Computation Algorithms: the model We present our model of local computation algorithms for sequential computations of search problems, although computations of arbitrary functions and optimization functions also fall within our framework. 2.1 Model Definition We write n = x to denote the length of the input. Definition 2.1. For input x, let F (x) = {y y is a valid solution for input x}. The search problem is to find any y ∈ F (x). In this paper, the description of both x and y are assumed to be very large. Definition 2.2 ((t, s, δ)-local algorithms). Let x and F (x) be defined as above. A (t(n), s(n), δ(n))-local computation algorithm A is a (randomized) algorithm which implements query access to an arbitrary y ∈ F (x) and satisfies the following: A gets a sequence of queries i1, . . . , iq for any q > 0 and after each query ij it must produce an output yij satisfying that the outputs yi1, . . . , yiq are substrings of some y ∈ F (x). The probability of success over all q queries must be at least 1 − δ(n). A has access to a random tape and local computation memory on which it can perform current computations as well as store and retrieve information from previous computations. We assume that the input x, the local computation tape and any random bits used are all presented in the RAM word model, i.e., A is given the ability to access a word of any of these in one step. The running time of A on any query is at most t(n), which is sublinear in n, and the size of the local computation memory of A is at most s(n). Unless stated otherwise, we always assume that the error parameter δ(n) is at most some constant, say, 1/3. We say that A is a strongly local computation algorithm if both t(n) and s(n) are upper bounded by logc n for some constant c. Definition 2.3. Let SLC be the class of problems that have strongly local computation algorithms. Note that when F (x) > 1, the y according to which A outputs may depend on the previous queries to A as well as any random bits available to A. Also, we implicitly assume that the size of the output y is upper- bounded by some polynomial in x. The definition of local-computation algorithms rules out the possibility that the algorithms accomplish their computation by first computing the entire output. Analogous definitions can be made for a bit model. In principle, the model applies to general computations, including function computations, search problems and optimization problems of any type of object, and in particular, the input is not required by the model to be in a specific input format. The model presented here is intended be more general, and thus differs from other local computation models in the following ways. First, queries and processing time have the same cost. Second, the focus is on problems with slightly looser running time bound requirements – polylogarithmic dependence on the length of the input is desirable, but sublinear time in the length of the input is often nontrivial and can be acceptable. Third, the model places no restriction on the ability of the algorithm to access the input, as is the case in the distributed setting where the algorithm may only query nodes in its neighborhood (although such restrictions may be implied by the representation of the input). As such, the model may be less appropriate for certain distributed algorithms applications. 4 Definition 2.4 (Query oblivious). We say an LCA A is query order oblivious (query oblivious for short) if the outputs of A do not depend on the order of the queries but depend only on the input and the random bits generated by the random tape of A. Definition 2.5 (Parallelizable). We say an LCA A is parallelizable if A supports parallel queries. We remark that not all local algorithms in this paper are query oblivious or easily parallelizable. How- ever, this is remedied in [6]. 2.2 Relationship with other distributed and parallel models A question that immediately arises is to characterize the problems to which the local-computation algorithm model applies. In this subsection, we note the relationship between problems solvable with local computa- tion algorithms and those solvable with fast parallel or distributed algorithms. From the work of [36] it follows that problems computable by fast distributed algorithms also have local computation algorithms. Fact 2.6 ([36]). If F is computable in t(n) rounds on a distributed network in which the processor intercon- nection graph has bounded degree d, then F has a dt(n)-local computation algorithm. Parnas and Ron [36] show this fact by observing that for any vertex v, if we run a distributed algorithm A on the subgraph Gk,v (the vertices of distance at most k from v), then it makes the same decision about vertex v as it would if we would run D for k rounds on the whole graph G. They then give a reduction from randomized distributed algorithms to sublinear algorithms based on this observation. Similar relationships hold in other distributed and parallel models, in particular, for problems com- putable by low depth bounded fan-in circuits. Fact 2.7. If F is computable by a circuit family of depth t(n) and fan-in bounded by d(n), then F has a d(n)t(n)-local computation algorithm. Corollary 2.8. N C 0 ⊆ SLC. In this paper we show solutions to several problems N C 1 via local computation algorithms. However, this is not possible in general as: Proposition 2.9. N C 1 * SLC. Proof. Consider the problem n-XOR, the XOR of n inputs. This problem is in N C 1. However, no sublinear time algorithm can solve n-XOR because it is necessary to read all n inputs. In this paper, we give techniques which allow one to construct local computation algorithms based on algorithms for finding certain combinatorial structures whose existence is guaranteed by constructive proofs of the LLL in [11, 2]. It seems that our techniques do not extend to all such problems. An example of such a problem is Even cycles in a balanced digraph: find an even cycle in a digraph whose maximum in-degree is not much greater that the minimum out-degree. Alon [2] shows that, under certain restriction on the input parameters, the problem is in N C 1. The local analogue of this question is to determine whether a given edge (or vertex) is part of an even cycle in such a graph. It is not known how to solve this quickly. 5 2.3 Locality-preserving reductions In order to understand better which problems can be solved locally, we define locality-preserving reductions, which capture the idea that if problem B is locally computable, and problem A has a locality-preserving reduction to B then A is also locally computable. Definition 2.10. We say that A is (t′(n), s′(n))-locality-preserving reducible to B via reduction H : Σ∗ → Γ∗, where Σ and Γ are the alphabets of A and B respectively, if H satisfies: 1. x ∈ A ⇐⇒ H(x) ∈ B. 2. H is (t′(n), s′(n), 0)-locally computable; that is, every word of H(x) can be computed by querying at most t(n) words of x. Theorem 2.11. If A is (t′(n), s′(n), 0)-locality-preserving reducible to B and B is (t(n), s(n), δ(n))- locally computable, then A is (t(n) · t′(n), s(n) + s′(n), δ(n))-locally computable. Proof. As A is (t′(n), s′(n), 0)-locality-preserving reducible to B, to determine whether x ∈ A, it suffices to determine if H(x) ∈ B. Each word of H(x) can be computed in time t′(n) and using space s′(n), and we need to access at most t(n) such words to determine whether H(x) ∈ B. Note that we can reuse the space for computing H(x). 3 Preliminaries Unless stated otherwise, all logarithms in this paper are to the base 2. Let N = {0, 1, . . .} denote the set of natural numbers. Let n ≥ 1 be a natural number. We use [n] to denote the set {1, . . . , n}. Unless stated otherwise, all graphs are undirected. Let G = (V, E) be a graph. The distance between two vertices u and v in V (G), denoted by dG(u, v), is the length of a shortest path between the two vertices. We write NG(v) = {u ∈ V (G) : (u, v) ∈ E(G)} to denote the neighboring vertices of v. Furthermore, let N + G (v) = N (v) ∪ {v}. Let dG(v) denote the degree of a vertex v. Whenever there is no risk of confusion, we omit the subscript G from dG(u, v), dG(v) and NG(v). The celebrated Lovász Local Lemma plays an important role in our results. We will use the simple symmetric version of the lemma. Lemma 3.1 (Lovász Local Lemma [15]). Let A1, A2, . . . , An be events in an arbitrary probability space. Suppose that the probability of each of these n events is at most p, and suppose that each event Ai is mutually independent of all but at most d of other events Aj. If ep(d + 1) ≤ 1, then with positive probability none of the events Ai holds, i.e., Pr[∩n i=1 ¯Ai] > 0. Several of our proofs use the following graph theoretic structure: Definition 3.2 ([11]). Let G = (V, E) be an undirected graph. Define W ⊆ V (G) to be a 3-tree if the pairwise distances of all vertices in W are each at least 3 and the graph G∗ = (W, E∗) is connected, where E∗ is the set of edges between each pair of vertices whose distance is exactly 3 in G. 6 4 Maximal Independent Set An independent set (IS) of a graph G is a subset of vertices such that no two vertices are adjacent. An independent set is called a maximal independent set (MIS) if it is not properly contained in any other IS. It is well-known that a sequential greedy algorithm finds an MIS S in linear time: Order the vertices in G as 1, 2, · · · , n and initialize S to the empty set; for i = 1 to n, if vertex i is not adjacent to any vertex in S, add i to S. The MIS obtained by this algorithm is call the lexicographically first maximal independent set (LFMIS). Cook [14] showed that deciding if vertex n is in the LFMIS is P -complete with respect to logspace reducibility. On the other hand, fast randomized parallel algorithms for MIS were discovered in 1980's [20, 29, 3]. The best known distributed algorithm for MIS runs in O(log∗ n) rounds with a word-size of O(log n) [16]. By Fact 2.6, this implies a dO(log∗ n·log n) local computation algorithm. In this section, we give a query oblivious and parallelizable local computation algorithm for MIS based on Luby's algorithm as well as the techniques of Beck [11], and runs in time O(dO(d log d) · log n). Our local computation algorithm is partly inspired by the work of Marko and Ron [30]. There they simulate the distributed algorithm for MIS of Luby [29] in order to approximate the minimum number of edges one need to remove to make the input graph free of some fixed graph H. In addition, they show that similar algorithm can also approximate the size of a minimum vertex cover. We simulate Luby's algorithm to find an exact and consistent local solution for the MIS problem. Moreover, the ingredient of applying Beck's idea to run a second stage greedy algorithm on disconnected subgraphs seems to be new. 4.1 Overview of the algorithm Let G be an undirected graph on n vertices and with maximum degree d. On input a vertex v, our algorithm decides whether v is in a maximal independent set using two phases. In Phase 1, we simulate Luby's parallel algorithm for MIS [29] via the reduction of [36]. That is, in each round, v tries to put itself into the IS with some small probability. It succeeds if none of its neighbors also tries to do the same. We run our Phase 1 algorithm for O(d log d) rounds. As it turns out, after Phase 1, most vertices have been either added to the IS or removed from the graph due to one (or more) of their neighbors being in the IS. Our key observation is that – following a variant of the argument of Beck [11] – almost surely, all the connected components of the surviving vertices after Phase 1 have size at most O(log n). This enables us to perform the greedy algorithm for the connected component v lies in. Our main result in this section is the following. Theorem 4.1. Let G be an undirected graph with n vertices and maximum degree d. Then there is a (O(dO(d log d) · log n), O(n), 1/n)-local computation algorithm which, on input a vertex v, decides if v is in a maximal independent set. Moreover, the algorithm will give a consistent MIS for every vertex in G. 4.2 Phase 1: simulating Luby's parallel algorithm Figure 1 illustrates Phase 1 of our local computation algorithm for Maximal Independent Set. Our algorithm simulates Luby's algorithm for r = O(d log d) rounds. Every vertex v will be in one of three possible states: • "selected" - v is in the MIS; • "deleted" - one of v's neighbors is selected and v is deleted from the graph; and • "⊥" - v is not in either of the previous states. 7 Initially, every vertex is in state "⊥". Once a vertex becomes "selected" or "deleted" in some round, it remains in that state in all the subsequent rounds. The subroutine MIS(v, i) returns the state of a vertex v in round i. In each round, if vertex v is still in state "⊥", it "chooses" itself to be in the MIS with probability 1/2d. At the same time, all its neighboring vertices also flip random coins to decide if they should "choose" themselves.2 If v is the only vertex in N +(v) that is chosen in that round, we add v to the MIS ("select" v) and "delete" all the neighbors of v. However, the state of v in round i is determined not only by the random coin tosses of vertices in N +(v) but also by these vertices' states in round i − 1. Therefore, to compute MIS(v, i), we need to recursively call MIS(u, i − 1) for every u ∈ N +(v). 3 By induction, the total running time of simulating r rounds is dO(r) = dO(d log d). If after Phase 1 all vertices are either "selected" or "deleted" and no vertex remains in "⊥" state, then the resulting independent set is a maximal independent set. In fact, one of the main results in [29] is that this indeed is the case if we run Phase 1 for expected O(log n) rounds. Our main observation is, after simulating Luby's algorithm for only O(d log d) (a constant independent of the size n) rounds we are already not far from a maximal independent set. Specifically, if vertex v returns "⊥" after Phase 1 of the algorithm, we call it a surviving vertex. Now consider the subgraph induced on the surviving vertices. Following a variant of Beck's argument [11], we show that, almost surely, no connected component of surviving vertices is larger than poly(d) · log n. Let Av be the event that vertex v is a surviving vertex. Note that event Av depends on the random coin tosses v and v's neighborhood of radius r made during the first r rounds, where r = O(d log d). To get rid of the complication caused by this dependency, we consider another set of events generated by a related random process. Consider a variant of our algorithm MIS, which we call MISB as shown in Fig 2. In MISB, every vertex v has two possible states: "picked" and "⊥". Initially, every vertex is in state "⊥". Once a vertex becomes "picked" in some round, it remains in the "picked" state in all the subsequent rounds. MISB and MIS are identical except that, in MISB, if in some round a vertex v is the only vertex in N +(v) that is chosen in that round, the state of v becomes "picked", but we do not change the states of v's neighboring vertices. In the following rounds, v keeps flipping coins and tries to choose itself. Moreover, we assume that, for any vertex v and in every round, the randomness used in MIS and MISB are identical as long as v has not been "selected" or "deleted" in MIS. If v is "selected" or "deleted" in MIS, then we flip some additional coins for v in the subsequent rounds to run MISB. We let Bv be the event that v is in state "⊥" after running MISB for r rounds (that is, v is never get picked during all r rounds of MISB). Claim 4.2. Av ⊆ Bv for every vertex v.4 Proof. This follows from the facts that a necessary condition for Av to happen is v never get "selected" in any of the r rounds and deleting the neighbors of v from the graph can never decrease the probability that v gets "selected" in any round. Specifically, we will show that Bv ⊆ Av. Note that Bv = ∪r i=1B (i) v , where B (i) v is the event that v is picked for the first time in round i in MISB is the event (i) (i) v , where A v (v may get picked again in some subsequent rounds). Similarly, Av = ∪r i=1A 2We store all the randomness generated by each vertex in each round so that our answers will be consistent. However, we generate the random bits only when the state of corresponding vertex in that round is requested. 3A subtle point in the subroutine MIS(v, i) is that when we call MIS(v, i), we only check if vertex v is "selected" or not in round i. If v is "deleted" in round i, we will not detect this until we call MIS(v, i + 1), which checks if some neighboring vertex of v is selected in round i. However, such "delayed" decisions will not affect our analysis of the algorithm. 4Strictly speaking, the probability spaces in which Av and Bv live are different. Here the claim holds for any fixed outcomes of all the additional random coins MISB flips. 8 MAXIMAL INDEPENDENT SET: PHASE 1 Input: a graph G and a vertex v ∈ V Output: {"true", "false", "⊥"} For i from 1 to r = 20d log d (a) If MIS(v, i) = "selected" return "true" (b) Else if MIS(v, i) = "deleted" return "false" (c) Else return "⊥" MIS(v, i) Input: a vertex v ∈ V and a round number i Output: {"selected", "deleted", "⊥"} 1. If v is marked "selected" or "deleted" return "selected" or "deleted", respectively 2. For every u in N (v) If MIS(u, i − 1) = "selected" mark v as " deleted" and return "deleted" 3. v chooses itself independently with probability 1 2d If v chooses itself (i) For every u in N (v) If u is marked "⊥", u chooses itself independently with probability 1 2d (ii) If v has a chosen neighbor return "⊥" (iii) Else mark v as "selected" and return "selected" Else return "⊥" Figure 1: Local Computation Algorithm for MIS: Phase 1 MISB(v, i) Input: a vertex v ∈ V and a round number i Output: {"picked", "⊥"} 1. If v is marked "picked" return "picked" 2. v chooses itself independently with probability 1 2d If v chooses itself (i) For every u in N (v) u chooses itself independently with probability 1 2d (ii) If v has a chosen neighbor return "⊥" (iii) Else mark v as "picked" and return "picked" Else return "⊥" Figure 2: Algorithm MISB 9 that v is selected or deleted in round i in MIS. Hence, we can write, for every i, A where Sel(i) respectively. v ∪ Del(i) v , v are the events that, in MIS, v gets selected in round i and v get deleted in round i, v and Del(i) v = Sel(i) (i) We prove by induction on i that ∪i v = Sel(1) v . Assume it holds for all smaller values of i. Consider any fixed random coin tosses of all the vertices in the graph before round i such that v is not "selected" or "deleted" before round i. Then by induction hypothesis, v is not picked in MISB before round i either. Let N (i)(v) be the set of neighboring nodes of v that are in state "⊥" in round i in algorithm MISB. Clearly, N (i)(v) ⊆ N (v). (j) v . This is clearly true for i = 1 as B (j) v ⊆ ∪i j=1B j=1A (1) Now for the random coins tossed in round i, we have B (i) v = {v chooses itself in round i} ∩w∈N (v) {w does not chooses itself in round i} ⊆ {v chooses itself in round i} ∩w∈N (i)(v) {w does not chooses itself in round i} = Sel(i) v . Therefore, B claim. (i) v ⊆ Sel(i) v ⊆ A (i) v . This finishes the inductive step and thus completes the proof of the As a simple corollary, we immediately have Corollary 4.3. For any vertex set W ⊂ V (G), Pr[∩v∈W Av] ≤ Pr[∩v∈W Bv]. A graph H on the vertices V (G) is called a dependency graph for {Bv}v∈V (G) if for all v the event Bv is mutually independent of all Bu such that (u, v) /∈ H. Claim 4.4. The dependency graph H has maximum degree d2. Proof. Since for every vertex v, Bv depends only on the coin tosses of v and vertices in N (v) in each of the r rounds, the event Bv is independent of all Au such that dH (u, v) ≥ 3. The claim follows as there are at most d2 vertices at distance 1 or 2 from v. Claim 4.5. For every v ∈ V , the probability that Bv occurs is at most 1/8d3. Proof. The probability that vertex v is chosen in round i is 1 chosen in this round is (1 − 1 independent, the probability that v is selected in round i is at least 1 that Bv happens is at most (1 − 1 2d . The probability that none of its neighbors is 2d )d ≥ 1/2. Since the coin tosses of v and vertices in N (v) are 4d . We get that the probability 2d )d(v) ≥ (1 − 1 2 = 1 2d · 1 4d )20d log d ≤ 1 8d3 . Now we are ready to prove the main lemma for our local computation algorithm for MIS. Lemma 4.6. After Phase 1, with probability at least 1 − 1/n, all connected components of the surviving vertices are of size at most O(poly(d) · log n). Proof. Note that we may upper bound the probability that all vertices in W are surviving vertices by the probability that all the events {Bv}v∈W happen simultaneously: Pr[all vertices in W are surviving vertices] = Pr[∩v∈W Av] ≤ Pr[∩v∈W Bv]. 10 The rest of the proof is similar to that of Beck [11]. We bound the number of 3-trees in H (the dependency graph for events {Bv}) of 3-trees of size w as follows. Let H 3 denote the "distance-3" graph of H, that is, vertices u and v are connected in H 3 if their distance in H is exactly 3. We claim that, for any integer w > 0, the total number of 3-trees of size w in H 3 is at most n(4d3)w. To see this, first note that the number of non-isomorphic trees on w vertices is at most 4w (see e.g. [28]). Now fix one such tree and denote it by T . Label the vertices of T by v1, v2, . . . , vw in a way such that for any j > 1, vertex vj is adjacent to some vi with i < j in T . How many ways are there to choose v1, v2, . . . , vw from V (H) so that they can be the set of vertices in T ? There are n choices for v1. As H 3 has maximum degree D = d(d − 1)2 < d3, therefore there are at most D possible choices for v2. and by induction there are at most nDw−1 < nd3w possible vertex combinations for T . Since there can be at most 4w different T 's, it follows that there are at most n(4d3)w possible 3-trees in G. Since all vertices in W are at least 3-apart, all the events {Bv}v∈W are mutually independent. Therefore we may upper bound the probability that all vertices in W are surviving vertices as Pr[∩v∈W Bv] Pr[Bv] = Yv∈W ≤ (cid:18) 1 8d3(cid:19)w , where the last inequality follows from Claim 4.5. Now the expected number of 3-trees of size w is at most n(4d3)w(cid:18) 1 8d3(cid:19)w = n2−w ≤ 1/n, for w = c1 log n, where c1 is some constant. By Markov's inequality, with probability at least 1 − 1/n, there is no 3-tree of size larger than c1 log n. By a simple variant of the 4-tree Lemma in [11] (that is, instead of the "4-tree lemma", we need a "3-tree lemma" here), we see that a connected component of size s in H contains a 3-tree of size at least s/d3. Therefore, with probability at least 1 − 1/n, there is no connected surviving vertices of size at least O(poly(d) · log n) at the end of Phase 1 of our algorithm. 4.3 Phase 2: Greedy search in the connected component If v is a surviving vertex after Phase 1, we need to perform Phase 2 of the algorithm. In this phase, we first explore v's connected component, C(v), in the graph induced on G by all the vertices in state "⊥". If the size of C(v) is larger than c2 log n for some constant c2 which depends only on d, we abort and output "Fail". Otherwise, we perform the simple greedy algorithm described at the beginning of this section to find the MIS in C(v). To check if any single vertex is in state "⊥", we simply run our Phase 1 algorithm on this vertex and the running time is dO(d log d) for each vertex in C(v). Therefore the running time for Phase 2 is at most O(C(v)) · dO(d log d) ≤ O(dO(d log d) · log n). As this dominates the running time of Phase 1, it is also the total running time of our local computation algorithm for MIS. Finally, as we only need to store the random bits generated by each vertex during Phase 1 of the algorithm and bookkeep the vertices in the connected component during Phase 2 (which uses at most O(log n) space), the space complexity of the local computation algorithm is therefore O(n). 11 5 Radio Networks For the purposes of this section, a radio network is an undirected graph G = (V, E) with one processor at each vertex. The processors communicate with each other by transmitting messages in a synchronous fashion to their neighbors. In each round, a processor P can either receive a message, send messages to all of its neighbors, or do nothing. We will focus on the radio network that is referred to as a Type II network:5 in [2]. P receives a message from its neighbor Q if P is silent, and Q is the only neighbor of P that transmits in that round. Our goal is to check whether there is a two-way connection between each pair of adjacent vertices. To reach this goal, we would like to find a schedule such that each vertex in G broadcasts in one of the K rounds and K is as small as possible. Definition 5.1 (Broadcast function). Let G = (V, E) be an undirected graph. We say Fr : V → [K] is a broadcast function for the network G if the following holds: 1. Every vertex v broadcasts once and only once in round Fr(v) to all its neighboring vertices; 2. No vertex receives broadcast messages from more than one neighbor in any round; 3. For every edge (u, v) ∈ G, u and v broadcast in distinct rounds. Let ∆ be the maximum degree of G. Alon et. al. [4, 5] show that the minimum number of rounds K satisfies K = Θ(∆ log ∆). Furthermore, Alon [2] gives an N C1 algorithm that computes the broadcast function Fr with K = O(∆ log ∆). Here we give a local computation algorithm for this problem, i.e. given a degree-bounded graph G = (V, E) in the adjacency list form and a vertex v ∈ V , we output the round number in which v broadcasts in logarithmic time. Our solution is consistent in the sense that all answers our algorithm outputs to the various v ∈ V agree with some broadcast scheduling function Fr. Let G1,2 be the "square graph" of G; that is, u and v are connected in G1,2 if and only if their distance in G is either one or two. Our algorithm is based on finding an independent set cover of G1,2 which simulates Luby's Maximal Independent Set algorithm [29]. Note that if we denote the maximum degree of G1,2 by d, then d ≤ ∆2. Definition 5.2 (Independent Set Cover). Let H = (V, E) be an undirected graph. A collection of vertex subsets {S1, . . . , St} is an independent set cover (ISC) for H if these vertex sets are pairwise disjoint, each Si is an independent set in H and their union equals V . We call t the size of ISC {S1, . . . , St}. Fact 5.3. If {S1, . . . , St} is an ISC for G1,2, then the function defined by Fr(v) = i iff v ∈ Si is a broadcast function. Proof. First note that, since the union of {Si} equals V , Fr(v) is well-defined for every v ∈ G. That is, every v broadcasts in some round in [t], hence both directions of every edge are covered in some round. As v can only be in one IS, it only broadcasts once. Second, for any two vertices u and v, if d(u, v) ≥ 3, then N (u) ∩ N (v) = ∅. It follows that, if in each round all the vertices that broadcast are at least 3-apart from each other, no vertex will receive more than one message in any round. Clearly the vertices in an independent set of G1,2 have the property that all the pairwise distances are at least 3. The following is a simple fact about ISCs. 5The other model, Type I radio network, is more restrictive: A processor P receives a message from its neighbor Q in a given round only if P is silent, Q transmits and P chooses to receive from Q in that round. 12 Fact 5.4. For every undirected graph H on n vertices with maximum degree d, there is an ISC of size at most d. Moreover, such an ISC can be found by a greedy algorithm in time at most O(dn). Proof. We repeatedly apply the greedy algorithm that finds an MIS in order to find an ISC. Recall that the greedy algorithm repeats the following until the graph has no unmarked vertex: pick an unmarked vertex v, add it to the IS and mark off all the vertices in N (v). Clearly each IS found by the greedy algorithm has size at least n d+1. To partition the vertex set into an ISC, we run this greedy algorithm to find an IS which we call S1, and delete all the vertices in S1 from the graph. Then we run the greedy algorithm on the new graph again to get S2, and so on. After running at most d rounds (since each round reduces the maximum degree of the graph by at least one), we partition all the vertices into an ISC of size at most d and the total running time is at most O(dn). Our main result in this section is a local computation algorithm that computes an ISC of size O(d log d) for any graph of maximum degree d. On input a vertex v, our algorithm outputs the index i of a vertex subset Si to which v belongs, in an ISC of H. We will call i the round number of v in the ISC. By Fact 5.3, applying this algorithm to graph G1,2 gives a local computation algorithm that computes a broadcast function for G. 5.1 A local computation algorithm for ISC Our main result for computing an ISC is summarized in the following theorem. Theorem 5.5. Let H be an undirected graph on n vertices with maximum degree d. Then there is a (poly(d)· log n, O(n), 1/n)-local computation algorithm which, on input a vertex v, computes the round number of v in an ISC of size at most O(d log d). Moreover, the algorithm will give a consistent ISC for every vertex in H. On input a vertex v, our algorithm computes the round number of v in two phases. In Phase 1 we simulate Luby's algorithm for MIS [29] for O(d log d) rounds. At each round, v tries to put itself in the independent set generated in that round. That is, v chooses itself with probability 1/2d and if none of its neighbors choose themselves, then v is selected in that round and we output that round number for v. As we show shortly, after Phase 1, most vertices will be assigned a round number. We say v survives if it is not assigned a round number. We consider the connected component containing v after one deletes all vertices that do not survive from the graph. Following an argument similar to that of Beck [11], almost surely, all such connected components of surviving vertices after Phase 1 have size at most O(log n). This enables us, in Phase 2, to perform the greedy algorithm on v's connected component to deterministically compute the round number of v in time O(log n). 5.1.1 Phase 1 algorithm Phase 1 of our local computation algorithm for computing an ISC is shown in Figure 3. 6 For every v ∈ V , let Av be the event that vertex v returns "⊥", i.e. v is not selected after r rounds. We call such a v a surviving vertex. After deleting all v that do not survive from the graph, we are interested in bounding the size of the largest remaining connected component. Clearly event Av depends on the random coin tosses of v and v's neighboring vertices in all the r rounds. A graph H on the vertices V (H) (the indices 6In 2(b), we flip random coins for u even if u is selected in a previous round. We do this for the technical reason that we want to rid the dependency of v on nodes that are not neighbors to simplify our analysis. Thus our analysis is overly pessimistic since if selected neighbors stop choosing themselves, it only increases the chance of v being selected. 13 INDEPENDENT SET COVER: PHASE 1 Input: a graph H and a vertex v ∈ V Output: the round number of v in the ISC or "⊥" 1. 2. For i = 1 to r = 20d log d (a) If v is labeled "⊥" Initialize all vertices in N +(v) to state "⊥" v chooses itself independently with probability 1 2d (b) If v chooses itself (i) For every u ∈ N (v) (even if u is labeled "selected in round j" for some j < i, we still flip random coins for it) u chooses itself independently with probability 1 2d (ii) If v has a chosen neighbor, v unchooses itself (iii) Else v is labeled "selected in round i" return i 3. return "⊥" Figure 3: Algorithm for finding an Independent Set Cover: Phase 1. for the Av) is called a dependency graph for {Av}v∈V (H) if for all v the event Av is mutually independent of all Au with (u, v) /∈ H. The following two claims are identical to Claim 4.4 and Claim 4.5 in Section 4 respectively, we therefore omit the proofs. Claim 5.6. The dependency graph H has maximum degree d2. Claim 5.7. For every v ∈ V , the probability that Av occurs is at most 1/8d3. The following observation is crucial in our local computation algorithm. Lemma 5.8. After Phase 1, with probability at least 1 − 1/n, all connected components of the surviving vertices are of size at most O(poly(d) · log n). Proof. The proof is almost identical to that of Lemma 4.6 but is only simpler: we can directly upper bound the probability Pr[all vertices in W are surviving vertices] = Pr[∩v∈W Av] by way of Beck [11] without resorting to any other random process. We omit the proof. 5.1.2 Phase 2 algorithm If v is a surviving vertex after Phase 1, we perform Phase 2 of the algorithm. In this phase, we first explore the connected component, C(v), that the surviving vertex v lies in. If the size of C(v) is larger than c2 log n for some constant c2(d) depending only on d, we abort and output "Fail". Otherwise, we perform the simple greedy algorithm described in Fact 5.4 to partition C(v) into at most d subsets deterministically. The running time for Phase 2 is at most poly(d) · log n. Since any independent set of a connected component can be combined with independent sets of other connected components to form an IS for the surviving vertices, we conclude that the total size of ISC we find is O(d log d) + d = O(d log d). 14 5.2 Discussions Now a simple application of Theorem 5.5 to G1,2 gives a local computation algorithm for the broadcast function. Theorem 5.9. Given a graph G = (V, E) with n vertices and maximum degree ∆ and a vertex v ∈ V , there exists a (poly(∆) · log n, O(n), 1/n)-local computation algorithm that computes a broadcast function with at most O(∆2 log ∆) rounds. Furthermore, the broadcast function it outputs is consistent for all queries to the vertices of the graph. We note our round number bound is quadratically larger than that of Alon's parallel algorithm [2]. We do not know how to turn his algorithm into a local computation algorithm. 6 Hypergraph two-coloring A hypergraph H is a pair H = (V, E) where V is a finite set whose elements are called nodes or vertices, and E is a family of non-empty subsets of V , called hyperedges. A hypergraph is called k-uniform if each of its hyperedges contains precisely k vertices. A two-coloring of a hypergraph H is a mapping c : V → {red, blue} such that no hyperedge in E is monochromatic. If such a coloring exists, then we say H is two-colorable. We assume that each hyperedge in H intersects at most d other hyperedges. Let N be the number of hyperedges in H. Here we think of k and d as fixed constants and all asymptotic forms are with respect to N. By the Lovász Local Lemma, when e(d + 1) ≤ 2k−1, the hypergraph H is two-colorable. Let m be the total number of vertices in H. Note that m ≤ kN, so m = O(N ). For any vertex x ∈ V , we use E(x) to denote the set of hyperedges x belongs to. For convenience, for any hypergraph H = (V, E), we define an m-by-N vertex-hyperedge incidence matrix M such that, for any vertex x and hyperedge e, Mx,e = 1 if e ∈ E(x) and Mx,e = 0 otherwise. A natural representation of the input hypergraph H is this vertex-hyperedge incidence matrix M. Moreover, since we assume both k and d are constants, the incidence matrix M is necessarily very sparse. Therefore, we further assume that the matrix M is implemented via linked lists for each row (that is, vertex x) and each column (that is, hyperedge e). Let G be the dependency graph of the hyperedges in H. That is, the vertices of the undirected graph G are the N hyperedges of H and a hyperedge Ei is connected to another hyperedge Ej in G if Ei ∩ Ej 6= ∅. It is easy to see that if the input hypergraph is given in the above described representation, then we can find all the neighbors of any hyperedge Ei in the dependency graph G (there are at most d of them) in O(log N ) time. 6.1 Our main result A natural question to ask is: Given a two-colorable hypergraph H and a vertex v ∈ V (H), can we quickly compute the coloring of v? Here we would like the coloring to be consistent, meaning all the answers we pro- vide must come from the same valid two-coloring. Our main result in this section is, given a two-colorable hypergraph H whose two-coloring scheme is guaranteed by the Lovász Local Lemma (with slightly weaker parameters), we give a local computation algorithm which answers queries of the coloring of any single vertex in polylogN time, where N is the number of the hyperedges in H. The coloring returned by our oracle will agree with some two-coloring of the hypergraph with probability at least 1 − 1/N. 15 Theorem 6.1. Let d and k be such that there exist three positive integers k1, k2 and k3 such that the follow- ings hold: k1 + k2 + k3 = k, 16d(d − 1)3(d + 1) < 2k1, 16d(d − 1)3(d + 1) < 2k2, 2e(d + 1) < 2k3. Then there exists a (polylogN, O(N ), 1/N )-local computation algorithm which, given a hypergraph H and any sequence of queries to the colors of vertices (x1, x2, . . . , xs), returns a consistent coloring for all xi's which agrees with some 2-coloring of H. 6.2 Overview of the coloring algorithm Our local computation algorithm imitates the parallel coloring algorithm of Alon [2]. Recall that Alon's algorithm runs in three phases. In the first phase, we randomly color each vertex in the hypergraph following some arbitrary ordering of the vertices. If some hyperedge has k1 vertices in one color and no vertices in the other color, we call it a dangerous edge and mark all the remaining vertices in that hyperedge as troubled. These troubled vertices will not be colored in the first phase. If the queried vertex becomes a troubled vertex from the coloring process of some previously queried vertex, then we run the Phase 2 coloring algorithm. There we first delete all hyperedges which have been assigned both colors and call the remaining hyperedges surviving edges. Then we repeat the same process again for the surviving hyperedges, but this time a hyperedge becomes dangerous if k1 + k2 vertices are colored the same color and no vertices are colored by the other color. Finally, in the third phase, we do a brute-force search for a coloring in each of the connected components of the surviving vertices as they are of size O(log log N ) almost surely. A useful observation is, in the first phase of Alon's algorithm, we can color the vertices in arbitrary order. In particular, this order can be taken to be the order that queries to the local computation algorithm are made in. If the coloring of a vertex x can not be determined in the first phase, then we explore the dependency graph around the hyperedges containing x and find the connected component of the surviving hyperedges to perform the second phase coloring. To ensure that all the connected components of surviving hyperedges resulting from the second phase coloring are of small sizes, we repeat the second phase colorings independently many times until the connected components sizes are small enough. If that still can not decide the coloring of x, then we run the third (and final) phase of coloring, in which we exhaustively search for a two-coloring for vertices in some very small (i.e., of size at most O(log log N )) connected component in G as guaranteed by our second phase coloring. Following Alon's analysis, we show that with probability at least 1 − 1/N, the total running time of all these three phases for any vertex in H is polylogN. During the execution of the algorithm, each hyperedge will be in either initial, safe, unsafe-1, unsafe-2, dangerous-1 or dangerous-2 state. Vertices will be in either uncolored, red, blue, trouble-1 or trouble-2 state. The meanings of all these states should be clear from their names. Initially every hyperedge is in initial state and every vertex is in uncolored state. 6.3 Phase 1 coloring If x is already colored (that is, x is in either red or blue state), then we simply return that color. If x is in the trouble-1 state, we invoke Phase 2 coloring for vertex x. If x is in the trouble-2 state, we invoke Phase 3 coloring for vertex x. If x is uncolored, then we flip a fair coin to color x red or blue with equal 16 Phase 1 Coloring(x) Input: a vertex x ∈ V Output: a color in {red, blue} 1. If x is already colored Return the color of x If x is in trouble-1 state 2. Return Phase 2 Coloring(x) 3. If x is in trouble-2 state Return Phase 3 Coloring(x) 4. If x is in uncolored state (a) Uniformly at random choose a color c for x from {red, blue} (b) Update the states of all hyperedges in E(x) (c) Return color c Figure 4: Phase 1 coloring algorithm probability (that is, vertex x's state becomes red or blue, respectively). After that, we update the status of all the hyperedges in E(x). Specifically, if some Ei ∈ E(x) has k1 vertices in one color and no vertices in the other color, then we change Ei from initial into dangerous-1 state. Furthermore, all uncolored vertices in Ei will be changed to trouble-1 states. On the other hand, if both colors appear among the vertices of Ei, we update the state of Ei from initial to safe. If none of the vertices in a hyperedge is uncolored and the hyperedge is still in initial state (that is, it is neither safe or dangerous-1), then we change its state to unsafe-1. Note that if a hyperedge is unsafe-1 then all of its vertices are either colored or in trouble-1 state, and the colored vertices are monochromatic. Running time analysis. The running time of Phase 1 coloring for an uncolored vertex x is O(kd) = O(1) (recall that we assume both k and d are constants). This is because vertex x can belong to at most d + 1 hyperedges, hence there are at most k(d+1) vertices that need to be updated during Phase 1. If x is already a colored vertex, the running time is clearly O(1). Finally, the running time of Phase 1 coloring for a trouble-1 or trouble-2 vertex is O(1) plus the running time of Phase 2 coloring or O(1) plus the running time of Phase 3 coloring, respectively. 6.4 Phase 2 coloring During the second phase of coloring, given an input vertex x (which is necessarily a trouble-1), we first explore the dependency graph G of the hypergraph H by keep coloring some other vertices whose colors may have some correlation with the coloring of x. In doing so, we grow a connected component of surviving- 1 hyperedges containing x in G. Here, a hyperedge is called surviving-1 if it is either dangerous-1 or unsafe-1. We denote this connected component of surviving-1 hyperedges surrounding vertex x by C1(x). Growing the connected component. Specifically, in order to find out C1(x), we maintain a set of hyper- edges E1 and a set of vertices V1. Throughout the process of exploring G, V1 is the set of uncolored vertices that are contained in some hyperedge in E1. Initially E1 = E(x). Then we independently color each vertex in V1 red or blue uniformly at random. After coloring each vertex, we update the state of every hyperedge that contains the vertex. That is, if any hyperedge Ei ∈ V1 becomes safe, then we remove Ei from V1 and delete all the vertices that are only contained in Ei. On the other hand, once a hyperedge in V1 becomes dangerous-2 (it has k2 vertices, all the uncolored vertices in that hyperedge become trouble-2 and we skip the coloring of all such vertices. After the coloring of all vertices in V1, hyperedges in E1 are surviving 17 Phase 2 Coloring(x) Input: a trouble-1 vertex x ∈ V Output: a color in {red, blue} or FAIL 1. Start from E(x) to explore G in order to find the connected components of all the surviving-1 hyperedges around x 2. If the size of the component is larger than c1 log N Abort and return FAIL 3. Repeat the following O( log N log log N ) times and stop if a good coloring is found (a) Color all the vertices in C1(x) uniformly at random (b) Explore the dependency graph of GS1(x) (c) Check if the coloring is good 4. Return the color of x in the good coloring Figure 5: Phase 2 coloring algorithm hyperedges. Then we check all the hyperedges in G that are adjacent to the hyperedges in E1. If any of these hyperedges is not in the safe state, then we add it to E1 and also add all its uncolored vertices to V1. Now we repeat the coloring process described above for these newly added uncolored vertices. This exploration of the dependency graph terminates if, either there is no more hyperedge to color, or the number of surviving-1 hyperedges in E1 is greater than c1 log N, where c1 is some absolute constant. The following Lemma shows that, almost surely, the size of C1(x) is at most c1 log N. Lemma 6.2 ([2]). Let S ⊆ G be the set of surviving hyperedges after the first phase. Then with probability at least 1 − 1 2N (over the choices of random coloring), all connected components C1(x) of GS have sizes at most c1 log N . Random coloring. Since C1(x) is not connected to any surviving-1 hyperedges in H, we can color the vertices in the connected component C1(x) without considering any other hyperedges that are outside C1(x). Now we follow a similar coloring process as in Phase 1 to color the vertices in C1(x) uniformly at random and in an arbitrary ordering. The only difference is, we ignore all the vertices that are already colored red or blue, and if k1 + k2 vertices in a hyperedge get colored monochromatically, and all the rest of vertices in the hyperedge are in trouble-1 state, then this hyperedge will be in dangerous-2 state and all the uncolored vertices in it will be in trouble-2 state. Analogously we define unsafe-2 hyperedges as hyperedges whose vertices are either colored or in trouble-2 state and all the colored vertices are monochromatic. Finally, we say a hyperedge is a surviving-2 edge if it is in either dangerous-2 state or unsafe-2 state. Let S1(x) be the set of surviving hyperedges in C1(x) after all vertices in C1(x) are either colored or in trouble-2 state. Now we explore the dependency graph of S1(x) to find out all the connected components. ) (over the Another application of Lemma 6.2 to GS1(x) shows that with probability at least 1 − O( choices of random coloring), all connected components in GS1(x) have sizes at most c2 log log N, where c2 is some constant. We say a Phase 2 coloring is good if this condition is satisfied. Now if a random coloring is not good, then we erase all the coloring performed during Phase 2 and repeat the above coloring and exploring dependency graph process. We keep doing this until we find a good coloring. Therefore, after recoloring at most O( log N log log N ) times (and therefore with at most polylogN running time), we can, with probability at least 1 − 1/2N 2, color C1(x) such that each connected component in GS1(x) has size at most c2 log log N. By the union bound, with probability at least 1−1/2N, the Phase 2 colorings for all connected components find some good colorings. log2 N 1 18 Phase 3 Coloring(x) Input: a trouble-2 vertex x ∈ V Output: a color in {red, blue} 1. Start from E(x) to explore G in order to find the connected component of all the surviving-2 hyperedges around x 2. Go over all possible colorings of the connected component and color it using a feasible coloring. 3. Return the color c of x in this coloring. Figure 6: Phase 3 coloring algorithm Running time analysis. Combining the analysis above with an argument similar to the running time analysis of Phase 1 coloring gives Claim 6.3. Phase 2 coloring takes at most polylogN time. 6.5 Phase 3 coloring In Phase 3, given a vertex x (which is necessarily trouble-2), we grow a connected component which includes x as in Phase 2, but of surviving-2 hyperedges. Denote this connected component of surviving-2 hyperedges by C2(x). By our Phase 2 coloring, the size of C2(x) is no greater than c2 log log N. We then color the vertices in this connected component by exhaustive search. The existence of such a coloring is guaranteed by the Lovász Local Lemma (Lemma 3.1). Claim 6.4. The time complexity of Phase 3 coloring is at most polylogN . Proof. Using the same analysis as for Phase 2, in time O(log log N ) we can explore the dependency graph to grow our connected component of surviving-2 hyperedges. Exhaustive search of a valid two-coloring of all the vertices in C2(x) takes time at most 2O(C2(x)) = 2O(log log N ) = polylogN, as C2(x) ≤ c2 log log N and each hyperedge contains k vertices. Finally, we remark that using the same techniques as those in [2], we can make our local computation algorithm run in parallel and find an ℓ-coloring of a hypergraph for any ℓ ≥ 2 (an ℓ-coloring of a hypergraph is to color each vertex in one of the ℓ colors such that each color appears in every hyperedge). 7 k-CNF As another example, we show our hypergraph coloring algorithm can be easily modified to compute a satisfying assignment of a k-CNF formula, provided that the latter satisfies some specific properties. Let H be a k-CNF formula on m Boolean variables x1, . . . , xm. Suppose H has N clauses H = A1 ∧ · · · ∧ AN and each clause consists of exactly k distinct literals.7 We say two clauses Ai and Aj intersect with each other if they share some variable (or the negation of that variable). As in the case for hypergraph coloring, k and d are fixed constants and all asymptotics are with respect to the number of clauses N (and hence m, since m ≤ kN). Our main result is the following. 7 Our algorithm works for the case that each clause has at least k literals; for simplicity, we assume that all clauses have uniform size. 19 Theorem 7.1. Let H be a k-CNF formula with k ≥ 2. If each clause intersects no more than d other clauses and furthermore k and d are such that there exist three positive integers k1, k2 and k3 satisfying the followings relations: k1 + k2 + k3 = k, 8d(d − 1)3(d + 1) < 2k1, 8d(d − 1)3(d + 1) < 2k2, e(d + 1) < 2k3, then there exists a local computation algorithm that, given any sequence of queries to the truth assignments of variables (x1, x2, . . . , xs), with probability at least 1 − 1/N , returns a consistent truth assignment for all xi's which agrees with some satisfying assignment of the k-CNF formula H. Moreover, the algorithm answers each single query in O((log N )c) time, where c is some constant (depending only on k and d). Proof [Sketch]: We follow a similar algorithm to that of hypergraph two-coloring as presented in Section 6. Every clause will be in either initial, safe, unsafe-1, unsafe-2, dangerous-1 or dangerous-2 state. Every variable will be in either unassigned, true-1, false-1, trouble-1 or trouble-2 state. Initially every clause is in initial state and every variable is in unassigned state. Suppose we are asked about the value of a variable xi. If xi is in initial state, we randomly choose from {true, false} with equal probabilities and assign it to xi. Then we update all the clauses that contain either xi or ¯xi accordingly: If the clause is already evaluated to true by this assignment of xi, then we mark the literal as safe; if the clause is in initial state and is not safe yet and xi is the kth 1 literal in the clause that has been assigned values, then the clause is marked as dangerous-1 and all the remaining unassigned variables in that clause are now in trouble-1 state. We perform similar operations for clauses in other states as we do for the hypergraph coloring algorithm. The only difference is now we have Pr[Ai becomes dangerous-1] = 2−k1, instead of 21−k1 as in the hypergraph coloring case. Following the same analysis, almost surely, all connected components in the dependency graph of unsafe-1 clauses are of size at most O(log N ) and almost surely all connected components in the dependency graph of unsafe-2 clauses are of size at most O(log log N ), which enables us to do exhaustive search to find a satisfying assignment. 8 Concluding Remarks and Open Problems In this paper we propose a model of local computation algorithms and give some techniques which can be applied to construct local computation algorithms with polylogarithmic time and space complexities. It would be interesting to understand the scope of problems which can be solved with such algorithms and to develop other techniques that would apply in this setting. Acknowledgments We would like to thank Ran Canetti, Tali Kaufman, Krzysztof Onak and the anonymous referees for useful discussions and suggestions. We thank Johannes Schneider for his help with the references. 20 References [1] N. Ailon, B. Chazelle, S. Comandur, and D. Liu. Property-preserving data reconstruction. Algorith- mica, 51(2):160–182, 2008. [2] N. Alon. A parallel algorithmic version of the Local Lemma. Random Structures and Algorithms, 2:367–378, 1991. [3] N. Alon, L. Babai, and A. Itai. A fast and simple randomized algorithm for the maximal independent set problem. Journal of Algorithms, 7:567–583, 1986. [4] N. Alon, A. Bar-Noy, N. Linial, and D. Peleg. On the complexity of radio communication. In Proc. 21st Annual ACM Symposium on the Theory of Computing, pages 274–285, 1989. [5] N. Alon, A. Bar-Noy, N. Linial, and D. Peleg. Single round simulation on radio networks. Journal of Algorithms, 13:188–210, 1992. [6] N. Alon, R. Rubinfeld, S. Vardi, and N. Xie. Small-space local computation algorithms. Manuscript in preparation, 2011. [7] R. Andersen, C. Borgs, J. Chayes, J. Hopcroft, V. Mirrokni, and S. Teng. Local computation of pagerank contributions. Internet Mathematics, 5(1–2):23–45, 2008. [8] R. Andersen, F. Chung, and K. Lang. Local graph partitioning using pagerank vectors. In Proc. 47th Annual IEEE Symposium on Foundations of Computer Science, pages 475–486, 2006. [9] L. Barenboim and M. Elkin. Distributed (∆ + 1)-coloring in linear (in ∆) time. In Proc. 41st Annual ACM Symposium on the Theory of Computing, pages 111–120, 2009. [10] L. Barenboim and M. Elkin. Deterministic distributed vertex coloring in polylogarithmic time. In Proc. 29th ACM Symposium on Principles of Distributed Computing, pages 410–419, 2010. [11] J. Beck. An algorithmic approach to the Lovász Local Lemma. Random Structures and Algorithms, 2:343–365, 1991. [12] P. Berkhin. Bookmark-coloring algorithm for personalized pagerank computing. Internet Mathematics, 3(1):41–62, 2006. [13] B. Chazelle and C. Seshadhri. Online geometric reconstruction. In SoCG, pages 386 – 394, 2006. [14] S. Cook. A taxonomy of problem with fast parallel algorithms. Information and Control, 64(1–3):2– 22, 1985. [15] P. Erdös and L. Lovász. Problems and results on 3-chromatic hypergraphs and some related questions. In A. Hajnal et. al., editor, "Infinite and Finite Sets", Colloq. Math. Soc. J. Bolyai, volume 11, pages 609–627. North-Holland, 1975. [16] A. V. Goldberg, S. A. Plotkin, and G. Shannon. Parallel symmetry-breaking in sparse graphs. SIAM Journal on Discrete Mathematics, 1(4):434–446, 1988. [17] O. Goldreich, S. Goldwasser, and D. Ron. Property testing and its connection to learning and approx- imation. Journal of the ACM, 45:653–750, 1998. 21 [18] A. Hasidim, J. Kelner, H. N. Nguyen, and K. Onak. Local graph partitions for approximation and testing. In Proc. 50th Annual IEEE Symposium on Foundations of Computer Science, pages 22–31, 2009. [19] G. Jeh and J. Widom. Scaling personalized web search. In Proceedings of the 12th International Conference on World Wide Web, pages 271–279, 2003. [20] R. Karp and A. Wigderson. A fast parallel algorithm for the maximal independent set problem. Journal of the ACM, 32(4):762–773, 1985. [21] J. Katz and L. Trevisan. On the efficiency of local decoding procedures for error-correcting codes. In Proc. 32nd Annual ACM Symposium on the Theory of Computing, pages 80–86, 2000. [22] F. Kuhn. Local multicoloring algorithms: Computing a nearly-optimal tdma schedule in constant time. In STACS, pages 613–624, 2009. [23] F. Kuhn and T. Moscibroda. Distributed approximation of capacitated dominating sets. In SPAA, pages 161–170, 2007. [24] F. Kuhn, T. Moscibroda, T. Nieberg, and R. Wattenhofer. Fast deterministic distributed maximal inde- pendent set computation on growth-bounded graphs. In DISC, pages 273–287, 2005. [25] F. Kuhn, T. Moscibroda, and R. Wattenhofer. What cannot be computed locally! In Proc. 23rd ACM Symposium on Principles of Distributed Computing, pages 300–309, 2004. [26] F. Kuhn, T. Moscibroda, and R. Wattenhofer. The price of being near-sighted. In Proc. 17th ACM-SIAM Symposium on Discrete Algorithms, pages 980–989, 2006. [27] F. Kuhn and R. Wattenhofer. On the complexity of distributed graph coloring. In Proc. 25th ACM Symposium on Principles of Distributed Computing, pages 7–15, 2006. [28] L. Lovász. Combinatorial Problems and Exercises. Elsevier B.V., Amsterdam, The Netherlands, second edition, 1993. [29] M. Luby. A simple parallel algorithm for the maximal independent set problem. SIAM Journal on Computing, 15(4):1036–1053, 1986. Earlier version in STOC'85. [30] S. Marko and D. Ron. Distance approximation in bounded-degree and general sparse graphs. In APPROX-RANDOM'06, pages 475–486, 2006. [31] A. Mayer, S. Naor, and L. Stockmeyer. Local computations on static and dynamic graphs. In Proceed- ings of the 3rd Israel Symposium on Theory and Computing Systems (ISTCS), 1995. [32] R. Moser. A constructive proof of the general Lovász local lemma. In Proc. 41st Annual ACM Sym- posium on the Theory of Computing, pages 343–350, 2009. [33] R. Moser and G. Tardos. A constructive proof of the general Lovász local lemma. Journal of the ACM, 57(2):Article No. 11, 2010. [34] M. Naor and L. Stockmeyer. What can be computed locally? SIAM Journal on Computing, 24(6):1259–1277, 1995. 22 [35] H. N. Nguyen and K. Onak. Constant-time approximation algorithms via local improvements. In Proc. 49th Annual IEEE Symposium on Foundations of Computer Science, pages 327–336, 2008. [36] M. Parnas and D. Ron. Approximating the minimum vertex cover in sublinear time and a connection to distributed algorithms. Theoretical Computer Science, 381(1–3):183–196, 2007. [37] M. E. Saks and C. Seshadhri. Local monotonicity reconstruction. SIAM Journal on Computing, 39(7):2897–2926, 2010. [38] T. Sarlos, A. Benczur, K. Csalogany, D. Fogaras, and B. Racz. To randomize or not to randomize: Space optimal summaries for hyperlink analysis. In Proceedings of the 15th International Conference on World Wide Web, pages 297–306, 2006. [39] J. Schneider and R. Wattenhofer. A log-star distributed maximal independent set algorithm for growth- bounded graphs. In Proc. 27th ACM Symposium on Principles of Distributed Computing, pages 35–44, 2008. [40] J. Schneider and R. Wattenhofer. A new technique for distributed symmetry breaking. In Proc. 29th ACM Symposium on Principles of Distributed Computing, pages 257–266, 2010. [41] D. Spielman and S. Teng. Nearly-linear time algorithms for graph partitioning, graph sparsification, and solving linear systems. In Proc. 36th Annual ACM Symposium on the Theory of Computing, pages 81–90, 2004. [42] Y. Yoshida, Y. Yamamoto, and H. Ito. An improved constant-time approximation algorithm for maxi- mum matchings. In Proc. 41st Annual ACM Symposium on the Theory of Computing, pages 225–234, 2009. 23
1602.07210
4
1602
2016-08-12T15:08:46
Faster Algorithms for the Maximum Common Subtree Isomorphism Problem
[ "cs.DS", "cs.CC" ]
The maximum common subtree isomorphism problem asks for the largest possible isomorphism between subtrees of two given input trees. This problem is a natural restriction of the maximum common subgraph problem, which is ${\sf NP}$-hard in general graphs. Confining to trees renders polynomial time algorithms possible and is of fundamental importance for approaches on more general graph classes. Various variants of this problem in trees have been intensively studied. We consider the general case, where trees are neither rooted nor ordered and the isomorphism is maximum w.r.t. a weight function on the mapped vertices and edges. For trees of order $n$ and maximum degree $\Delta$ our algorithm achieves a running time of $\mathcal{O}(n^2\Delta)$ by exploiting the structure of the matching instances arising as subproblems. Thus our algorithm outperforms the best previously known approaches. No faster algorithm is possible for trees of bounded degree and for trees of unbounded degree we show that a further reduction of the running time would directly improve the best known approach to the assignment problem. Combining a polynomial-delay algorithm for the enumeration of all maximum common subtree isomorphisms with central ideas of our new algorithm leads to an improvement of its running time from $\mathcal{O}(n^6+Tn^2)$ to $\mathcal{O}(n^3+Tn\Delta)$, where $n$ is the order of the larger tree, $T$ is the number of different solutions, and $\Delta$ is the minimum of the maximum degrees of the input trees. Our theoretical results are supplemented by an experimental evaluation on synthetic and real-world instances.
cs.DS
cs
Faster Algorithms for the Maximum Common Subtree Isomorphism Problem∗ Andre Droschinsky1, Nils M. Kriege1, and Petra Mutzel1 1 Dept. of Computer Science, Technische Universität Dortmund, Germany {andre.droschinsky,nils.kriege,petra.mutzel}@tu-dortmund.de Abstract The maximum common subtree isomorphism problem asks for the largest possible isomorphism between subtrees of two given input trees. This problem is a natural restriction of the maximum common subgraph problem, which is NP-hard in general graphs. Confining to trees renders polynomial time algorithms possible and is of fundamental importance for approaches on more general graph classes. Various variants of this problem in trees have been intensively studied. We consider the general case, where trees are neither rooted nor ordered and the isomorphism is maximum w.r.t. a weight function on the mapped vertices and edges. For trees of order n and maximum degree ∆ our algorithm achieves a running time of O(n2∆) by exploiting the structure of the matching instances arising as subproblems. Thus our algorithm outperforms the best previously known approaches. No faster algorithm is possible for trees of bounded degree and for trees of unbounded degree we show that a further reduction of the running time would directly improve the best known approach to the assignment problem. Combining a polynomial- delay algorithm for the enumeration of all maximum common subtree isomorphisms with central ideas of our new algorithm leads to an improvement of its running time from O(n6 + T n2) to O(n3 + T n∆), where n is the order of the larger tree, T is the number of different solutions, and ∆ is the minimum of the maximum degrees of the input trees. Our theoretical results are supplemented by an experimental evaluation on synthetic and real-world instances. 1998 ACM Subject Classification F.2.2 Nonnumerical Algorithms and Problems Keywords and phrases MCS, maximum common subtree, enumeration algorithms, maximum weight bipartite matchings Digital Object Identifier 10.4230/LIPIcs..2016.1 Introduction 1 The maximum common subgraph isomorphism problem (MCS) asks for an isomorphism between induced subgraphs of two given graphs that is of maximum weight w.r.t. a weight function on the mapped vertices and edges. The problem is of fundamental importance in applications like pattern recognition [5] or bio- and cheminformatics [9, 18]. MCS naturally generalizes the subgraph isomorphism problem (SI), where the task is to decide if one graph is isomorphic to a subgraph of another graph. Both problems are known to be NP-hard for general graphs. It is not astonishing that these problems have been extensively studied for restricted graph classes. Polynomial time algorithms for SI and MCS in trees have been pioneered by Edmonds and Matula in the 1960s. They rely on solving a series of maximum bipartite ∗ This work was supported by the German Research Foundation (DFG), priority programme "Algorithms for Big Data" (SPP 1736). © Andre Droschinsky and Nils M. Kriege and Petra Mutzel; licensed under Creative Commons License CC-BY Leibniz International Proceedings in Informatics Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 6 1 0 2 g u A 2 1 ] S D . s c [ 4 v 0 1 2 7 0 . 2 0 6 1 : v i X r a 1:2 Faster Algorithms for the Maximum Common Subtree Isomorphism Problem matching instances, see [15]. These early results focused on the polynomial time complexity of the problem; since then considerable progress has been achieved in improving the running time of SI algorithms (also see [1] and references therein): Reyner [17, 23] and Matula [15] both showed a running time of O(n2.5) for rooted trees. Chung [4] later obtained the same bound for unrooted trees. Further improvements were made by Shamir and Tsur [19] who obtained time O(n2.5/ log n) and O(nω), where ω is the exponent of matrix multiplication. MCS on trees seems to be harder. For two rooted trees of size n, it is known that the problem can be solved, roughly speaking, in the same time as the associated maximum weight matching problem in a bipartite graph on n vertices: Gupta and Nishimura [11] presented an O(n2.5 log n) algorithm for MCS in rooted trees by assuming weights to be in O(n), which allows to employ a scaling approach to the matching problem [10]. The running time can be √ improved to O( ∆ ), where ∆ denotes the maximum degree [12]. Allowing a real weight function to determine the similarity of mapped vertices gives rise to bipartite matching instances with unrestricted weights. Solving these with the Hungarian method leads to cubic running time, see e.g. [22]. Since the the size of the matching instances is bounded by the maximum degree ∆, the result can be improved to O(n2∆) time [20]. Various related concepts for the comparison of rooted trees, either ordered or unordered, have been proposed and were studied in detail, see [22] and references therein, where the tree edit distance is a prominent example [3, 6]. ∆n2 log 2n In this article we consider the problem of finding a common subtree isomorphism in unrooted, unordered trees that is maximum w.r.t. a weight function on the mapped vertices and edges. This problem is directly relevant in various applications, where real-world objects like molecules or shapes are represented by (attributed) trees [16, 20]. Moreover, it forms the basis for several recent approaches to solve MCS in more general graph classes, see [2, 13, 14, 18]. Methods directly based on algorithms for rooted trees result in time O(n4∆) by considering all pairs of possible roots. An improvement to O(n3∆) has been reported in [20], which is limited to non-negative weight functions. Schietgat, Ramon and Bruynooghe [18] suggested an approach for MCS in outerplanar graphs, which solves the considered problem when applied to trees. The approach is stated to have a running time of O(n2.5), but in fact leads to a running time of Ω(n4) in the worst case.1 Our contribution. We show that for arbitrary weights a maximum common subtree iso- morphism between two trees G and H of order n with ∆(G) ≤ ∆(H) can be computed in time O(n2(∆(G) + log ∆(H)). We obtain the improvement by (i) considering only a specific subset of subproblems that we show to be sufficient to guarantee an optimal solution; (ii) exploiting the close relation between the emerging matching instances. We show that for general trees any further improvement of this time bound would allow to solve the assignment problem in o(n3), and hence improve over the best known approach to this famous problem for more than 30 years. For trees of bounded degree the running time bound of O(n2) is tight. We apply our new techniques to the problem of enumerating all maximum common subtree isomorphisms, thus improving the state-of-the-art running times. Finally, we present an experimental evaluation on synthetic and real-world instances showing that our new algorithm is faster than existing approaches. 1 The analysis of the algorithm appears to be flawed. An Erratum to [18] has been submitted to the Annals of Mathematics and Artificial Intelligence, see Appendix. Our experimental study of their implementation actually suggests a time bound of Ω(n5). A. Droschinsky and N. M. Kriege and P. Mutzel 1:3 Preliminaries W(M) :=P 2 In this paper, G = (V, E) is a simple undirected graph. We call v ∈ V a vertex and uv = vu ∈ E an edge of G. For a graph G = (V, E) we define V (G) := VG := V , E(G) := EG := E and G := V (G). For a subset of vertices V 0 ⊆ V the graph G[V 0] := (V 0, E0), E0 := {uv ∈ E u, v ∈ V 0}, is called induced subgraph. A connected graph with a unique path between any two vertices is a tree. A tree G with an explicit root vertex r ∈ VG is called rooted tree, denoted by Gr. In a rooted tree Gr we denote the children of a vertex v by C(v) and its parent by p(v), where p(r) = r. The depth depth(v) of a vertex v is the number of edges on the path from v to r. The neighbors of a vertex v are defined as N(v) := {u ∈ VG vu ∈ EG}. The degree of a vertex v ∈ VG is δ(v) := N(v), the degree ∆(G) of a graph G is the maximum degree of its vertices. For a graph G = (V, E) a matching M ⊆ E is a set of edges, such that no two edges share a vertex. A matching M of G is said to be perfect, if 2M = V . A weighted graph is a graph endowed with a function w : E → R. The weight of a matching M in a weighted graph is e∈M w(e). We call a matching M of a weighted bipartite graph G a maximum weight matching (MWM) if there is no other matching M0 of G with W(M0) > W(M). The assignment problem asks for a matching with maximum weight among all perfect matchings and we refer to a solution by MWPM. An isomorphism between two graphs G and H is a bijective function φ : VG → VH such that uv ∈ EG ⇔ φ(u)φ(v) ∈ EH; if such an isomorphism exists, G and H are said to be isomorphic. We call a graph G subgraph isomorphic to a graph H, if there is an induced subgraph H0 ⊆ H isomorphic to G. In this case, we write G (cid:22)φ H, where φ : VG → VH0 is an isomorphism between G and H0. A common subgraph of G and H is a graph I, such that I (cid:22)φ G and I (cid:22)φ0 H. The isomorphism ϕ := φ0 ◦ φ−1 is called common subgraph isomorphism (CSI). For a function f : X → Y let dom(f) := X be the domain of f. If there is no other CSI ϕ0 with dom(ϕ0) > dom(ϕ), we call ϕ maximum common subgraph isomorphism (MCSI). We generalize the above definitions to a pair of graphs G, H under a commutative weight- function ω : (VG × VH) ∪ (EG × EH) → R ∪ {−∞}. The weight W(φ) of an isomorphism φ between G and H under ω is the sum of the weights ω(v, φ(v)) and ω(vu, φ(v)φ(u)) of all vertices and edges mapped by φ. A maximum common subgraph isomorphism φ under a weight function is one of maximum weight W(φ) instead of maximum size dom(φ). Note, this is less restrictive than a common approach for isomorphisms on labeled graphs, where the labels must match. By defining ω such that mapped vertices and mapped edges add 1 and 0, respectively, to the weight, we obtain an isomorphism of maximum size. Therefore, in the following we consider graphs under a weight function unless stated otherwise and refer to the corresponding solution as MCSI. For convenience we replace the word graph by tree in the above definitions when appropriate. The maximum common subtree isomorphism problem (MCST) is to determine the weight of an MCSI, where the input graphs and the common subgraph are trees. We further define [1..k] := {1, . . . , k} for k ∈ N. Problem Decomposition and Fundamental Algorithms 3 We introduce the basic techniques for solving MCST following the ideas of Edmonds and Matula [15]. The approach requires to compute MWMs in bipartite graphs as a subroutine. We discuss the occurring matching instances in detail in Section 4. By fixing the roots of both trees we can develop an algorithm solving MCST on this restricted setting. It is easy to generalize this solution by considering all possible pairs of 1:4 Faster Algorithms for the Maximum Common Subtree Isomorphism Problem u c1 c2 r v s d1 d2 d3 c1 c2 d1 d2 d3 4 (a) Rooted subtree Gr u (b) Rooted subtree H s v (c) Matching problem 1 c1 c2 4 (d) MWM d1 d2 d3 Figure 1 Two rooted subtrees (a) and (b), the associated weighted matching instance (c), and an MWM on that instance (d). Light gray vertices and edges are not part of the rooted subtrees, root vertices are shown in solid black. The maximum weight matching is shown in blue. We assume a weight function ω with ω(u, v) = 1 for all (u, v) ∈ VG × VH and ω(e, f) = 0 for all (e, f) ∈ EG × EH. The edges without label in (c) have weight 1. roots. We then show that it is sufficient to fix the root of one tree while still obtaining a maximum solution. Rooted trees. We first consider the problem restricted to rooted trees under the assumption that the roots of the two trees must be mapped to each other. For a rooted tree Gr we u as the subtree induced by u and all its descendants in Gr that define the rooted subtree Gr is rooted at u, cf. Figures 1a and b. Note that Gr u both refer to the same subtree unless s is contained in Gr u. The key to solving MCST for two rooted trees Gr and H s is the following recursive formulation: r = Gr and that Gr u and Gs MCSroot(Gr, H s) = ω(r, s) + W(M), (1) where M is an MWM of the complete bipartite graph on the vertex set C(r) ] C(s) with v) for all u ∈ C(r) and v ∈ C(s). Hence, each weights w(uv) = ω(ru, sv) + MCSroot(Gr edge weight corresponds to the solution of a problem of the same type for a pair of smaller rooted subtrees and the recursion naturally stops at the leaves. Each subproblem, the initial one as well as those arising in recursive calls, is uniquely defined by a pair of rooted subtrees and essentially consists of solving a matching instance. u, H s u and H s Figure 1 illustrates the two rooted subtrees Gr v) depth(u) = depth(v)} have to be solved. In order to compute Eq. (1) the subproblems defined by the pairs of rooted subtrees v and the corresponding matching problem under the weight function as given in the figure. For rooted trees Gr and H s this problem arises on the second level in the recursion of Eq. (1). We obtain MCSroot(Gr v) = u, H s ω(u, v) + W(M) = 1 + 5 = 6, where M is an MWM of Figure 1c, depicted in Figure 1d. Sroot(Gr, H s) := {(Gr (cid:73) Proposition 1. A maximum common subtree isomorphism for two rooted trees Gr and H s can be computed in time O(n3), where n = G + H. Proof. The bipartite graph for the subproblem (Gr v) contains ku + lv vertices, where ku := C(u) and lv := C(v). For the total running time we distinguish the cases ku ≤ lv and ku > lv. For the first case we obtain a MWM in time O(kulv(ku + log lv)) according to Lemma 5. The second case is analog. Since Sroot(Gr, H s) ⊆ {(Gr v) u ∈ VG, v ∈ VH} the total running time is bounded by O(n3) as u, H s u, H s u, H s kulv(ku + log lv) ≤ X X ku u∈VG v∈VH X X u∈VG v∈VH ,ku≤lv lv(lv + log lv) ≤ n · 2n2 ∈ O(n3) (cid:74) A. Droschinsky and N. M. Kriege and P. Mutzel 1:5 Unrooted trees. We now consider the problem for unrooted trees. An immediate solution is to solve the rooted problem variant for all possible pairs of roots, i.e., by computing Rt(G) :=S MCS(G, H) := max {MCSroot(Gr, H s) r ∈ V (G), s ∈ V (H)} . r∈V (G) Rt(Gr). Note that we may uniquely associate the subtree Gr (2) Clearly, this yields the optimal solution in time O(n5) with Proposition 1. Note that several recursive calls involve solving the same subproblem. Repeated computation can easily be avoided by means of a lookup table. Let Rt(Gr) := {Gr u u ∈ V (G)} and u with Gp u, v ∈ Rt(G) either is the whole where p is the parent of u in Gr. Hence, each rooted subtree Gu tree G with root u = v or is the subtree rooted at v of some edge uv ∈ E(G), where u is not v v ∈ V (G) ∧ u ∈ N(v) ∪ {v}} is the set of all contained in the subtree. Thus, Rt(G) = {Gu rooted subtrees of G. In total the subproblems defined by S(G, H) := Rt(G) × Rt(H) have to be solved. However, ensuring that each subproblem is solved only once does not allow to improve the bound on the running time, since S(G, H) still may contain a quadratic number of subproblems of linear size: Let G and H be two star graphs on n vertices, i.e., trees with all but one vertex of degree one. Each of the (n − 1)2 pairs of leaves can be selected as root pair and leads to a different subproblem of size n − 1. We show that it is sufficient to consider only a subset of the subproblems to guarantee that an optimal solution is found. Let u, H s) u ∈ V (G), s ∈ V (H)} , MCSfast(Gr, H) := max {MCSroot(Gr (3) where r ∈ V (G) is an arbitrary but fixed root of G. To compute Eq. (3), only the subproblems Sfast(Gr, H) := Rt(Gr) × Rt(H) ⊆ S(G, H) need to be solved. (cid:73) Lemma 2. Let MCSfast and MCS be defined as above and r ∈ V (G) arbitrary but fixed, then MCSfast(Gr, H) = MCS(G, H) for all trees G, H. Proof. Let φ be an MCSI. If r is in the domain of φ, then ω(φ) = MCSroot(Gr, H φ(r)) = MCSfast(Gr, H). Otherwise the domain of φ is contained in the subtree rooted at one child of r. Let u be the unique vertex that is closest to r and mapped by φ. Then (cid:74) ω(φ) = MCSroot(Gr u, H φ(u)) = MCSfast(Gr, H). Algorithm 1 implements this strategy, where the postorder traversal on Gr (line 2) ensures that the solutions to smaller subproblems are always available when required (line 9). The lookup table contains one entry for each subproblem in Sfast(Gr, H) and hence requires space O(n2). Note that it is also possible to compute a concrete isomorphism from the MWMs associated with the computed optimal solution. The restriction of the considered subproblems allows to improve the bound on the running time. (cid:73) Proposition 3. Algorithm 1 solves the maximum common subtree isomorphism problem for two trees G and H in time O(n4), where n = G + H. Proof. According to Lemma 2 computing Eq. (3) yields the optimal solution and it suffices to solve the subproblems Sfast(Gr, H) as realized by Algorithm 1. Let ku be the number of v the number of children of v in H s, s ∈ V (H), and lv = N(v). For all children of u in Gr v ≤ lv. Similar to Proposition 1 the subproblems Sfast(G, H) can be solved in a s we have ls X X total time of X X ! u, ls ⊆ O(cid:0)n4(cid:1) . (kuls v)(min{ku, ls v} + log max{ku, ls ⊆ O ! v}) O u∈VG s∈VH v∈VH n3 s∈VH (cid:74) 1:6 Faster Algorithms for the Maximum Common Subtree Isomorphism Problem : Table D(u, s, v) storing solutions MCSroot(Gr u, H s v) of subproblems. Algorithm 1: Maximum Common Subtree Isomorphism : Trees G and H under a weight function ω Input Output : Weight of an MCSI between G and H. Data 1 Select an arbitrary root vertex r ∈ VG. 2 foreach u ∈ VG in postorder traversal on Gr do 3 4 5 6 7 8 9 foreach s ∈ N(v) ∪ {v} do V ← C(v) in H s if ω(u, v) 6= −∞ then U ← C(u) in Gr foreach v ∈ VH do foreach pair (u0, v0) ∈ U × V do w(u0v0) ← ω(uu0, vv0) + D(u0, v, v0) . All possible Gr u ∈ Rt(Gr) . All possible H s v ∈ Rt(H) 10 11 12 M ← MWM of the complete graph on U ] V with weights w. D(u, s, v) ← ω(u, v) + W(M) else D(u, s, v) ← −∞ 13 return the maximum entry in D Further improvement of the running time is possible by no longer considering the MWM subroutine as a black box. We pursue this direction in the next section. Our findings there yield the following theorem. (cid:73) Theorem 4. An MCSI between two unrooted trees G and H can be computed in time O(GH(min{∆(G), ∆(H)} + log max{∆(G), ∆(H)})). Proof. The MWM computations in Algorithm 1 are dominating, thus we obtain the above (cid:74) running time directly from Theorem 7 of the following section. Computing All Maximum Weight Matchings 4 In this section we improve the total time bound for solving all the matching instances arising in Algorithm 1. First, we provide a time bound to compute an MWM in a single bipartite graph (V ] U, E), where possibly V 6= U. In the following, we exploit the fact that during the run of our algorithm, we get sets of "similar" bipartite graph instances. After computing an MWM on one graph in one of the sets, we can derive MWMs for all the other bipartite graphs in that set very efficiently. Finally, we provide an upper bound to compute an MWM in all the occurring bipartite graphs. Computing an MWM is closely related to finding an MWPM and there is extensive literature on both problems [8]. Gabow and Tarjan [10] describe a reduction to solve the MWM problem using any algorithm for MWPM, without altering the algorithm's asymptotic time bound, which we will make use of. For computing an MWPM, we use the well known Hungarian method, which has at most n iterations in its outer loop and a total running time of O(n3) or O(n(m + n log n)) using Fibonacci heaps, where n and m denote the number of vertices and edges of the bipartite graph. We denote this algorithm by APM. The Hungarian method is a primal-dual algorithm. It starts with an empty matching and computes a new matching with one more edge in each iteration, maintaining a feasible dual solution of a primal linear program. The complementary slackness theorem ensures, that A. Droschinsky and N. M. Kriege and P. Mutzel 1:7 v1 v2 2 4 3 -1 3 u1 u2 u3 u4 4 3 4 3 2 3 4 3 4 3 2 3 4 3 4 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 3 4 2 3 3 4 3 4 2 3 3 (a) Input graph B (b) Reduced graph B0 (c) MWMs M0, M 3 (d) B0 4 2 4 3 4 with M0 4 Figure 2 Weighted bipartite graph B (a); reduced graph B0 with initial duals in green (vertices without label have dual value 0) and initial matching M00 in blue (b); MWM M0 of B0 in blue, M of B in thick blue c; B0 4 in blue (d). - cf. proofs of Lemma 5 and Lemma 6. 4 with matching M0 the obtained perfect matching after n iterations is a MWPM. Note, by using the reduction in [10], we always have at least one perfect matching. (cid:73) Lemma 5. Let B = (V ] U, E) be a bipartite graph with edge weights w : E → R. Let k := V , l := U, and k ≤ l. An MWM M on B can be computed in time O(kl(k + log l)). Proof. Let {v1, . . . , vk} = V,{u1, . . . , ul} = U be the two vertex sets of B. First, we remove all edges from B with negative edge weight, because they never contribute to an MWM. Then, we add a copy BC of B to the graph. For each vertex v ∈ V ] U we denote its copy vC and for each edge e ∈ E we denote its copy eC. We then copy the edge weights, i.e., w(eC) := w(e) for each edge e ∈ E. Next we insert a new edge of weight 0 between each vertex v ∈ V ] U and its copy vC. This graph is called reduced graph B0. Figures 2a and b show an example of B and B0. An MWPM M0 of B0 yields an MWM M of B: vu ∈ M ⇔ vu ∈ M0 and v ∈ V, u ∈ U. This follows from the construction of B0. In the following, we prove an upper time bound to compute M0. An initial feasible dual solution d : VB0 → R, i.e., d(v) + d(u) ≥ w(vu) for all edges vu ∈ EB0, including l matching edges vu with d(v) + d(u) = w(vu), is computed as follows: We set d(u) = 0 for all u ∈ U and d(v) := max{w(vu) u ∈ U} for all v ∈ V . Next, for each v ∈ V ] U the vertex vC obtains the dual value d(vC) := d(v). We define an initial matching M00 := {uuC u ∈ U}. Note, d(u) + d(uC) = 0 = w(uuC). The dual solution d is feasible and can be computed in time O(kl). Let n := VB0 = 2(k+l) ∈ Θ(l) and m := EB0 ≤ 2kl+k+l ∈ O(kl). Increasing the number of matching edges by one using a single iteration of APM is possible in time O(m + n log n) = O(l(k + log l)). To obtain an MWPM M0 form M00 in B0 we need to increase the number of matching edges by k, therefore the time to compute M0 and thus M is O(kl(k + log l)). (cid:74) (cid:73) Lemma 6. Let B = (V ] U, E) be a weighted bipartite graph with k := V , U = {u1, . . . , ul}, l ≥ 2. Let Bj := G[V ] U \ {uj}] for each j ∈ [1..l]. Computing MWMs for all graphs B, B1, . . . , Bl is possible in total time O(kl(min{k, l} + log max{k, l})). Proof. According to Lemma 5 we obtain an MWM M of B in time O(kl(min{k, l} + log max{k, l})). We compute an MWM on each Bj as follows: Let d be an optimal dual solution obtained while computing M0 (on B0, see proof of Lemma 5). If uj is not matched by M, i.e., uj /∈ e for all e ∈ M, then Mj := M is an MWM of Bj. Otherwise let B0 j be the reduced graph as explained in the proof of Lemma 5. We obtain a feasible dual solution dj on the bipartite graph B0 j by taking the dual values from d, i.e., dj(v) := d(v) for all 1:8 Faster Algorithms for the Maximum Common Subtree Isomorphism Problem Algorithm 2: Computing MWMs on B and Bj, cf. Lemmas 5, 6 . Dual values . Compute MWM M of B . Weights of additional edges : Bipartite graph B = (V ] U, E),U ≥ 2, U = {u1, u2, . . .} with edge weights w : E → R Input Output : MWMs M, Mj on B, Bj := G[V ] U \ {uj}] for each j ∈ [1..U]. 1 if V ≤ U then 2 Let B0 := (V 0, E0), where V 0 := V ∪ U ∪ {vC v ∈ V ∪ U} and E0 := E ∪ {eC e ∈ E} ∪ {vvC v ∈ V ∪ U}. w(eC) ← w(e) for all e ∈ E w(vvC) ← 0 for all v ∈ V ∪ U d(uC) ← d(u) ← 0 for all u ∈ U d(vC) ← d(v) ← max{w(vu) u ∈ U} for all v ∈ V M00 ← {uuC u ∈ U} . Initial matching edges Starting with M00 and d, compute an MWPM M0 on B0 using V iterations of APM M ← {vu vu ∈ M0, v ∈ V, u ∈ U} Exchange the vertices of V and U. Compute M as in lines 2 to 9 and exchange V and U back. 3 4 5 6 7 8 9 10 else 11 12 13 d ← The dual values obtained while computing M0. 14 foreach j ∈ [1..U] do 15 16 17 18 19 20 21 Mj ← M else j ← B0 \ {uj, uC j } B0 j ← M0 without the matching edges incident to uj, uC M0 Compute an MWPM M0 Mj ← {vu vu ∈ M0 j using d and a single iteration of APM. if uj is not matched by M then j on B0 j, v ∈ V, u ∈ U} . Initial matching j . MWMs Mj on Bj v ∈ V (B0 matching in B0 j). Note, we have 2(k + l) vertices in B0, and exactly two less in B0 j, i.e., a perfect j consists of k + l − 1 matching edges. j on B0 We can derive an initial matching M0 j with k+ l−2 edges from M0; M0 j contains the matching edges that are not incident to the two removed vertices from B0 to B0 j. Therefore only one more iteration of APM is needed, which is possible in time O(max{k, l}(min{k, l} + log max{k, l})), cf. proof of Lemma 5. We then obtain Mj from M0 j as previously described. The complementary slackness conditions ensure M0 j and therefore Mj is of maximum weight. An example of M0 and B0 We need to compute an MWM different from M for at most min{k, l} of the l graphs B1, . . . , Bl, because at most k vertices of U are matched by M, cf. Figure 2c: only u3 and u4 of U are matched by M. Therefore the time bound to compute MWMs for all the graphs B1, . . . , Bl is O(min{k, l} max{k, l}(min{k, l} + log max{k, l})) = O(kl(min{k, l} + log max{k, l})). (cid:74) j (j = 4) is shown in Figures 2c and d. We call B and the graphs Bj, j ∈ [1..l], a set of "similar" bipartite graph instances. Algorithm 2 shows how we compute an MWM for each graph in this set. Next, we apply Lemma 6 to Algorithm 1. For each pair u ∈ VG, v ∈ VH of vertices, selected in line 2 and 4, respectively, the algorithm computes up to N(v) + 1 MWMs, cf. lines 5, 10. A close look at Algorithm 1 reveals this as a set of "similar" bipartite graph instances. The first graph B A. Droschinsky and N. M. Kriege and P. Mutzel 1:9 is obtained by selecting s = v in line 5. The other graphs Bj are obtained by selecting all the vertices s ∈ N(v). This observation allows to prove the following theorem. (cid:73) Theorem 7. All the MWMs in Algorithm 1 can be computed in total time O(kl(min{∆(G), ∆(H)} + log max{∆(G), ∆(H)})), where k = G and l = H. Proof. For each pair (v, u) ∈ VG × VH we compute an MWM on each of the "similar" graphs, where B = (C(v) ] N(u), E) and edge weights as determined by Eq. (1). Let dmin := min{∆(G), ∆(H)} and dmax := max{∆(G), ∆(H)}. For all the pairs (v, u) we obtain a time complexity of ! δ(v)δ(u)(min{δ(v), δ(u)} + log max{δ(v), δ(u)}) O ⊆ O X X X δ(v)X (dmin + log dmax)X u u = O = O((dmin + log dmax)kl). v v v ! δ(u)(dmin + log dmax) ! δ(v)l 5 Lower Bounds on the Time Complexity and Optimality (cid:74) Providing a tight lower bound on the time complexity of a problem is generally a non-trivial task. We obtain this for trees of bounded degree and reason why the existence of an algorithm with subcubic running time for unrestricted trees is unlikely. In order to solve MCST with an arbitrary weight function ω for two trees G and H, all values ω(u, v) for u ∈ V (G) and v ∈ V (H) must be considered. This directly leads the lower bound of Ω(GH) for the time complexity of MCST. For trees of bounded degree our approach achieves running time O(GH) according to Theorem 4 and, thus, has an optimal worst-case running time in the considered setting. For unrestricted trees of order n our approach has a running time of O(n3) according to Theorem 4. In the next paragraph we present a linear time reduction from the assignment problem to MCST, which preserves the time complexity. Therefore solving MCST in time o(n3) yields an algorithm to solve the assignment problem in time o(n3). The Hungarian method solves the assignment problem in O(n3), which is the best known time bound for bipartite graphs with Θ(n2) edges of unrestricted weight for more than 30 years. Let B = (U ] V, E, w) be a weighted bipartite graph on which we want to solve the assignment problem, i.e., to find an MWPM. We assume weights to be non-negative, which can be achieved by adding a sufficiently large constant to every edge weight to obtain an assignment problem that is equivalent w.r.t. the MWPMs. We construct a star graph G with center c and leaves U and another star graph H with center c0 and leaves V . Let n = U = V and N = maxe∈E w(e). We define ω such that ω(u, v) = w(uv) + nN for all uv ∈ E, ω(c, c0) = nN and ω(u, v) = −∞ for all other pairs of vertices. For all pairs of edges we define ω(e, e0) = 0. Let φ be an MCSI between G and H w.r.t. w and p := dom(φ). It directly follows from the construction that M := {uv ∈ E φ(u) = v} is an MWM in B with W(M) = W(φ) − pnN. Furthermore, the incremented weights ensure that M is perfect, i.e., p = n + 1, whenever B admits a perfect matching. Therefore we obtain: 1:10 Faster Algorithms for the Maximum Common Subtree Isomorphism Problem (cid:73) Proposition 8. Only if we can solve the assignment problem on a graph with n vertices and Θ(n2) edges of unrestricted weight in time o(n3), we can solve MCST on two unrooted trees of order Θ(n) in time o(n3). 6 Output-Sensitive Algorithms for Listing All Solutions Algorithm 1 can easily be modified to not only output the weight of an MCSI, but also an associated isomorphism. Let D(u, s, v) be a maximum entry in D. Then φ(u) = v. Further mappings are defined by the matching edges occurring in Eq. (1). In the example of Figure 1d we obtain φ(c1) = d1 and φ(c2) = d3. Since in general there is no single unique MCSI, it is of interest to find and list all of them. In this section we show how our techniques can be combined with the enumeration algorithm from [7], which lists all the different MCSIs of two trees exactly once. We obtain the best known time bound for listing all solutions by an improved analysis. Since the number of MCSIs is not polynomially bounded in the size of the input trees, we cannot expect polynomial running time. An algorithm is said to be output-sensitive if its running time depends on the size of the output in addition to the size of the input. The basic idea to enumerate all MCSIs is to first compute the weight of an MCSI. Then for each maximum table entry D(u, v, v), u ∈ VG, v ∈ VH, all the different rooted MCSIs v are listed. Note, we omit maximum table entries D(u, s, v), on the rooted subtrees Gr where s 6= v. We do this, because every MCSI of Gr v . As an example let u be the root of G in Figure 1. Then D(u, v, v) = D(u, s, v) = 7. For both table entries we obtain the same MCSI φ with φ(u) = v, φ(r) = d1, φ(c1) = d2, φ(c2) = d3, . . .. v is also an MCSI of Gr u, H v u, H v u, H s We enumerate the MCSIs on a pair of rooted subtrees by enumerating all MWMs of the associated bipartite graphs of Eq. (1) and then expanding φ recursively along all the different MWMs of the mapped children. For the problem depicted in Figure 1c there are two different MWMs: M1 = {c1d1, c2d3} and M2 = {c1d2, c2d3}. Therefore we first expand along M1 as explained in the first paragraph of this section and then along M2. We do this recursively for each occurring matching instance. The enumerated isomorphisms of each maximum entry are pairwise different, based on the different MWMs. They are also pairwise different between two different maximum entries. The proof of the latter claim is similar to the proof of Lemma 2. Thus we do not enumerate an MCSI twice. Further we do not omit an MCSI, because we consider all necessary maximum table entries and their rooted subtrees, as well as all possible expansions along the MWMs. Note, the enumeration algorithm of [7] uses a somewhat different table to store maximum solutions. The basic idea to list all solutions is the same. For trees of sizes k := G and l := H, k ≤ l, their enumeration algorithm requires total time O(k2l4 + T l2), where T is the number of different MCSIs. The O(k2l4) term of the running time is caused by computing the weight of an MCSI in time O(kl4) and repeated deletions of single edges in one tree and recalculations of the weight of an MCSI to avoid outputting an MCSI twice. We have improved the time bound to compute the weight of an MCSI, cf. Theorem 4. Therefore we can improve the O(k2l4) term to O(kl(min{∆(G), ∆(H)} + log max{∆(G), ∆(H)})). The O(T l2) term in the original running time is caused by the enumeration of MWMs. For each MCSI φ several MWMs have to be enumerated, let this number be mφ. The time to do this can be bounded by O(l2), when using a variant of the enumeration algorithm for perfect matchings presented in [21]. The running time follows from the fact, that for each MWM two depth first searches (DFS) in a directed subgraph of B0, cf. Figure 2, are computed. The running time of DFS is linear in the number of edges and vertices. Let ki, li A. Droschinsky and N. M. Kriege and P. Mutzel 1:11 MWMs, i ∈ [1..mφ]. ThenP P i kili ≤P i ki ≤ k andP i ki∆(H) ≤ k∆(H) as well asP be the sizes of the disjoint vertex sets of the i-th bipartite graph, on which we enumerate the i li ≤ l, because all the vertices in all the mφ bipartite graphs are pairwise disjoint. The running time of DFS in the directed subgraphs of the i-th bipartite graph is O(kili), cf. Figure 2b or d. For all mφ DFS runs we have i ∆(G)li ≤ ∆(G)l. Hence, the time to enumerate φ is bounded by O(min{k∆(H), ∆(G)l}). i kili ≤P Both improvements combined together, the initial computation of the weight of an MCSI and the MWM enumeration, improve the enumeration time from O(n6 + T n2) to O(n3 + T n min{∆(G), ∆(H)}). More precisely we obtain the following theorem. (cid:73) Theorem 9. Enumerating all MCSIs of two unrooted trees G and H is possible in time O(GH ( min{∆(G), ∆(H)} + log max{∆(G), ∆(H)} ) + T( min{G∆(H), ∆(G)H} ) ), where T is the number of different MCSIs. 7 Experimental Comparison In this section we experimentally evaluate the running time of our approach (DKM) on synthetic and real-world instances. We compare our algorithm to the approach of [18] which also solves MCST when the input graphs are trees. The corrected analysis of the approach yields a running time of O(n4), see Appendix, which aligns better with our experimental findings of Ω(n5). The implementation was provided by the authors as part of the FOG package.2 Both algorithms were implemented in C++ and compiled with GCC v.4.8.4. Running times were measured on an Intel Core i7-3770 CPU with 16 GB of RAM using a single core only. We generated random trees by iteratively adding edges to a randomly chosen vertex and averaged over 40 to 100 pairs of instances depending on their size. The weight function ω was set to 1 for each pair of vertices and edges, i.e., we compute isomorphisms of maximum size. This matches the setting in FOG. Table 1 summarizes our results and we observe that the running time of our approach aligns with our theoretical analysis. In comparison, FOG's running time is much higher and increases to a larger extent with the input size. The running times of both algorithms show a low standard deviation for random trees, cf. Tables 1a, b. Table 1c shows the running time in star graphs, which are worst-case examples for some approaches, see Sec. 3. Our theoretical proven cubic running time matches the experimental results, while FOG's running time increases drastically. Table 1d summarizes the computation time under different weight functions. We defined ω such that different labels are simulated, i.e., vertices and edges with different labels have weight −∞, which again matches FOG's setting. Both algorithms clearly benefit from the fact that less MWMs have to be computed. The results on random trees are also shown in Figure 3. From a chemical database of thousands of molecules3 we extracted 100 pairs of graphs with block-cut trees (BC-trees) consisting of more than 40 vertices. BC-trees are a representation of graphs, where each maximal biconnected component is represented by a B-vertex. If two such components share a vertex, the corresponding B-vertices are connected through a C-vertex representing this shared vertex. The running time for MCST on BC-trees is an important factor for the total running time of MCS algorithms for outerplanar and series-parallel graphs like [2, 13, 18]. The average running time of our algorithm was 11.2 ms, 2 https://dtai.cs.kuleuven.be/software/PMCSFG 3 NCI Open Database, GI50, http://cactus.nci.nih.gov 1:12 Faster Algorithms for the Maximum Common Subtree Isomorphism Problem Order 20 40 80 160 320 FOG DKM q 40 ± 7% 0.9 ± 8% 44.1 221 ± 5% 3.5 ± 6% 62.7 1 286 ± 5% 15.2 ± 4% 84.8 58.9 ± 3% 8 342 ± 5% 141.7 237.4 ± 2% 63 327 ± 8% 266.9 (a) Random trees of the same order Order DKM 0.1 1 8.9 77.5 (c) Star graphs 10 20 40 80 FOG 18 489 18 722 929 784 q 117.6 458.5 2109.9 11 992.1 H 20 40 80 160 320 1 2 3 4 DKM FOG q 3.6 ± 8% 192 ± 4% 53.6 7.3 ± 7% 504 ± 4% 68.7 15.2 ± 4% 1 286 ± 5% 84.8 30 ± 9% 3080 ± 4% 103.3 59.5 ± 3% 6842 ± 4% 114.9 (b) Random trees with G = 80 fixed FOG #labels DKM 15.2 ± 4% 5.4 ± 8% 3.3 ± 7% 2.6 ± 8% q 1 286 ± 5% 84.8 217 ± 8% 40 118 ± 12% 36.1 83 ± 9% 31.9 (d) Different ω-functions, order 80 Table 1 Average running time in ms ± RSD in % and speedup factor q := FOG/DKM. Time in ms 400 300 200 100 10 20 30 40 50 60 70 80 90 100 Order Figure 3 Average running time in ms (y-axis) for MCSI computation on random trees of order n (x-axis). Black = Our implementation (DKM). Blue = FOG implementation. compared to FOG's 481.3 ms. The speedup factor ranges from 24 to 59, with an average of 43. This indicates that the above mentioned approaches could greatly benefit from the techniques presented in this paper. 8 Conclusions We have presented a novel algorithm for MCST which (i) considers only the subproblems required to guarantee that an optimal solution is found and (ii) solves groups of related matching instances efficiently in one pass. Rigorous analysis shows that the approach achieves cubic time in general trees and quadratic time in trees of bounded degree. Our analysis of the problem complexity reveals that there is only little room for possible further improvements. The practical efficiency is documented by an experimental comparison. If the weight function is restricted to integers of a bounded value, scaling approaches [8] to the corresponding matching problems become applicable. It remains future work to improve the running time for this case. A. Droschinsky and N. M. Kriege and P. Mutzel 1:13 References 1 Amir Abboud, Arturs Backurs, Thomas Dueholm Hansen, Virginia Vassilevska Williams, and Or Zamir. Subtree isomorphism revisited. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '16, pages 1256–1271. SIAM, 2016. 2 Tatsuya Akutsu and Takeyuki Tamura. A polynomial-time algorithm for computing the maximum common connected edge subgraph of outerplanar graphs of bounded degree. Algorithms, 6(1):119–135, 2013. doi:10.3390/a6010119. 3 Tatsuya Akutsu, Takeyuki Tamura, Avraham A. Melkman, and Atsuhiro Takasu. On the complexity of finding a largest common subtree of bounded degree. In Leszek Gasieniec and Frank Wolter, editors, Fundamentals of Computation Theory, volume 8070 of LNCS, pages 4–15. Springer, 2013. doi:10.1007/978-3-642-40164-0_4. 4 Moon Jung Chung. O(n2.5) time algorithms for the subgraph homeomorphism problem on trees. Journal of Algorithms, 8(1):106–112, 1987. doi:10.1016/0196-6774(87)90030-7. 5 Donatello Conte, Pasquale Foggia, Carlo Sansone, and Mario Vento. Thirty years of graph matching in pattern recognition. International Journal of Pattern Recognition and Artificial Intelligence, 2004. URL: http://dx.doi.org/10.1142/S0218001404003228, doi:10.1142/S0218001404003228. Erik D. Demaine, Shay Mozes, Benjamin Rossman, and Oren Weimann. An optimal decom- position algorithm for tree edit distance. ACM Trans. Algorithms, 6(1):2:1–2:19, December 2009. doi:10.1145/1644015.1644017. 6 7 Andre Droschinsky, Bernhard Heinemann, Nils Kriege, and Petra Mutzel. Enumeration In Hee-Kap Ahn of maximum common subtree isomorphisms with polynomial-delay. and Chan-Su Shin, editors, Algorithms and Computation (ISAAC), LNCS, pages 81–93. Springer, 2014. doi:10.1007/978-3-319-13075-0_7. 8 Ran Duan and Hsin-Hao Su. A scaling algorithm for maximum weight matching in bipartite graphs. In Proceedings of the Twenty-third Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '12, pages 1413–1424. SIAM, 2012. 9 Hans-Christian Ehrlich and Matthias Rarey. Maximum common subgraph isomorphism algorithms and their applications in molecular science: a review. Wiley Interdisciplinary Reviews: Computational Molecular Science, 1(1):68–79, 2011. URL: http://dx.doi.org/ 10.1002/wcms.5, doi:10.1002/wcms.5. 10 Harold N. Gabow and Robert Endre Tarjan. Faster scaling algorithms for network problems. SIAM J. Comput., 18(5):1013–1036, 1987. 11 Arvind Gupta and Naomi Nishimura. Finding largest subtrees and smallest supertrees. Algorithmica, 21:183–210, 1998. doi:10.1007/PL00009212. 12 Ming-Yang Kao, Tak-Wah Lam, Wing-Kin Sung, and Hing-Fung Ting. An even faster and more unifying algorithm for comparing trees via unbalanced bipartite matchings. Journal of Algorithms, 40(2):212–233, 2001. doi:10.1006/jagm.2001.1163. 13 Nils Kriege, Florian Kurpicz, and Petra Mutzel. On maximum common subgraph prob- In Kratochvíl Jan, Mirka Miller, and Dalibor Froncek, doi: lems in series-parallel graphs. editors, IWOCA 2014, volume 8986 of LNCS, pages 200–212. Springer, 2014. 10.1007/978-3-319-19315-1_18. 14 Nils Kriege and Petra Mutzel. Finding maximum common biconnected subgraphs in series- parallel graphs. In Erzsébet Csuhaj-Varjú, Martin Dietzfelbinger, and Zoltán Ésik, edit- ors, MFCS 2014, volume 8635 of LNCS, pages 505–516. Springer, 2014. doi:10.1007/ 978-3-662-44465-8_43. 15 David W. Matula. Subtree isomorphism in O(n5/2). In P. Hell B. Alspach and D.J. Miller, editors, Algorithmic Aspects of Combinatorics, volume 2 of Annals of Discrete Mathematics, pages 91–106. Elsevier, 1978. doi:10.1016/S0167-5060(08)70324-8. A. Droschinsky and N. M. Kriege and P. Mutzel 1:14 17 16 Matthias Rarey and J.Scott Dixon. Feature trees: A new molecular similarity measure based on tree matching. Journal of Computer-Aided Molecular Design, 12(5):471–490, 1998. doi:10.1023/A:1008068904628. Steven W. Reyner. An analysis of a good algorithm for the subtree problem. SIAM J. Comput., 6(4):730–732, 1977. Leander Schietgat, Jan Ramon, and Maurice Bruynooghe. A polynomial-time maximum common subgraph algorithm for outerplanar graphs and its application to chemoinform- atics. Annals of Mathematics and Artificial Intelligence, 69(4):343–376, 2013. doi: 10.1007/s10472-013-9335-0. 19 Ron Shamir and Dekel Tsur. Faster subtree isomorphism. Journal of Algorithms, 33(2):267– 18 280, 1999. doi:10.1006/jagm.1999.1044. 20 A. Torsello, D. Hidovic-Rowe, and M. Pelillo. Polynomial-time metrics for attributed trees. IEEE Transactions on Pattern Analysis and Machine Intelligence, 27(7):1087–1099, July 2005. doi:10.1109/TPAMI.2005.146. 21 Takeaki Uno. Algorithms for enumerating all perfect, maximum and maximal matchings in bipartite graphs. In Algorithms and Computation (ISAAC), volume 1350 of LNCS, pages 92–101. Springer, 1997. 22 Gabriel Valiente. Algorithms on Trees and Graphs. Springer-Verlag, Berlin, 2002. 23 Rakesh M. Verma and Steven W. Reyner. An analysis of a good algorithm for the subtree problem, corrected. SIAM J. Comput., 18(5):906–908, 1989. Erratumto:Apolynomial-timemaximumcommonsubgraphalgorithmforouterplanargraphsanditsapplicationtochemoinformaticsAndreDroschinskyNilsM.KriegePetraMutzelFebruary10,2016AbstractInthiserratumitisshownthatthearticlebySchietgat,Ramon,andBruynooghe[2013]containsthefollowingerrors:(i)Therunningtimeofthepresentedalgorithmforcomputingamaxi-mumcommonsubgraphunderblock-and-bridge-preservingsubgraphisomorphism(BBP-MCS)fortwographsofordernisΩ(n4)insteadofO(n2.5)asclaimedinthearticle.(ii)ThedissimilaritymeasurederivedfromBBP-MCSdoesnotalwaysfulfillthetriangleinequalityand,hence,isnotametric.Asaconsequence,stillnoalgorithmwithrunningtimeo(n4)isknown,neitherforBBP-MCSnorforthespecialcase,wherebothinputgraphsaretrees.Thedissimilaritymeasureshouldnotbeusedincombinationwithtechniquesthatrelyonorexploitthetriangleinequalityinanyway.1IntroductionThepolynomial-timealgorithmpresentedbySchietgatetal.[2013]solvesavariationofthemaximumcommonsubgraphprobleminouterplanargraphsandappliesthealgorithmtomoleculargraphs.Weassumetheterminologyandnotationintroducedintheoriginalarticleanddirectlyrefertothenumbereddefinitions,theoremsandalgorithmstherein.2ComplexityAnalysisTheorem2statesthatfortwoouterplanargraphsGandHtheproposedBBP-MCSalgorithmrunsintimeO(cid:16)V(G)·V(H)·(V(G)+V(H))12(cid:17),whichisO(n2.5)forV(G)=V(H)=n.Weshowthatthisboundcannotbeobtainedbythepresentedtechniques.1 cv1v2v3v4vn(a)AstargraphHcv1v2v3···vn(b)RootedgraphHccv1v2v3···vn(c)PartinBHFigure1:Astargraphofordern(a),thestargraphrootedatthecentervertex(b)andanelementarypartHc\{v2}(c)obtainedfromHv2,wherethegrayvertexwithitsincidentedgeisdeleted.2.1SolvingWeightedMaximalMatchingProblemsThealgorithmmakesuseofasubroutineforsolvingtheweightedmaximalmatchingprobleminbipartitegraphs,whereweightsarerealvalues,cf.Def-inition16.Thematchinginstancesarisinginthecourseofthealgorithmareconsideredtobecompletebipartitegraphs,seeproofofTheorem2.Hence,therunningtimesgiveninthefollowingrefertocompletebipartitegraphswithnverticesinordertoimprovereadability.Theauthorsproposetousetheal-gorithmbyHopcroftandKarp[1973]tosolveaninstanceoftheproblemintimeO(n2.5).Sincethisalgorithmcomputesamatchingofmaximalcardinal-ity,butisnotdesignedtotakeweightsintoaccount,itcannotbeappliedtotheinstancesthatoccur.Thebestknownalgorithmfortheproblemisthewell-knownHungarianmethod,whichrequirestimeO(n3)[PapadimitriouandSteiglitz,1982].Notethatbyassumingthatweightsareintegerswithintherangeof[0..N]scalingalgorithmwouldbecomeapplicablelike[DuanandSu,2012],whichsolvetheprobleminO(n2.5logN).However,thiswouldrequiretoalterthebasicdefinitionoftheproblem,whichstatesthatthesizeofacommonsubgraphisarealnumberdeterminedbythelabelsoftheverticesandedgesitcontains,cf.Definition2.Insummary,nobettertimeboundthanO(n3)onthesubproblemofsolvingweightedmaximalmatchingswithnverticescanbeassumed.2.2TheNumberofMatchingInstancesWeconsideraparticularlysimplecounterexampletoillustratetheflawregardingtheanalysisoftherunningtimeintheproofofTheorem2.WeshowthatfortwographsGandHoforderΘ(n)thepresentedalgorithmperformsΘ(n)callstothesubroutineforweightedmaximalmatching(MaxMatch,Algorithm2)withinstancesofsizeΘ(n).Assumingcubicrunningtimeforeachmatchingproblem,cf.Section2.1,thisyieldsalowerboundonthetotalrunningofthepresentedalgorithmofΩ(n4),contradictingTheorem2.LetthetwographsGandHbothbestargraphsofordern+1,i.e.,treeswithallbutonevertexofdegreeoneasdepictedinFigure1(a).Sincetreesinparticularareouterplanar,GandHarevalidinputgraphsforBBP-MCS.Thepresentedalgorithmgreatlysimplifies:Algorithm4andAlgorithm3,lines11-18,willnotberequiredtosolvetheproblemontrees.Thealgorithmreliesonadecompositionofthetwoinputgraphsintotheirparts.LetL(G)denotetheleafsofagraphG.FollowingDefinitions20,23,26weselectthecenter2 vertexofGasdistinguishedrootrandobtainthepartsParts(Gr)={Gr}{z}FG∪{({v},∅)vv∈L(G)}{z}LG,(1)whereLGarerootedsubgraphscontainingasingleleafofG,whicharetheele-mentarypartsofthecompound-rootBPSGr.WithDefinition27wedecomposeHintothepartsParts∗(H)={Hrr∈V(H)}{z}FH∪{({v},∅)vv∈L(H)}{z}LH∪{Hc\{v}v∈L(H)}{z}BH,(2)wherecistheuniquecentervertexofHandBHthesubgraphsrootedatcobtainedbydeletingasingleleafwithitsincidentedge,cf.Figure1(c).NotethattheelementsinFGandBHarecompound-rootgraphs.ConsequentlyFG×BH⊆Pairs(G,H)accordingtoDefinition28andAlgorithm1callsthesubproceduresRMCSandRMCScompoundforeachpair(P,Q)∈FG×BH.TheprocedureRMCScompound,seeAlgorithm2,constructsandsolvesaweightedmaximalmatchinginstanceofsizea+b,whereaandbarethenumberofelementarypartsofPandQ,respectively.ThenumberofelementarypartsofPinFGisLG=n,thenumberofelementarypartsofeachQinBHisn−1.Hence,eachofthesematchinginstanceshassize2n−1andrequirescubictime.ThenumberofsuchpairsisFG×BH=n.Therefore,thetotalrunningtimeofthealgorithmisΩ(n4)incontradictiontoTheorem2.Consequently,theremustbeanerrorintheproofofTheorem2:Intheproofitisclaimedthateveryvertexg∈V(G)andeveryvertexv∈V(H)hasatmostdeg(v)(resp.deg(h))elementarypartsinvolvedinamaximalmatching[Schietgatetal.,2013].Whilethisstatementiscorrectthesubsequentanalysisdoesnottakeintoaccountthattheremaybeuptodeg(v)matchinginstancesofthatsizeforavertexv∈V(H)asseenfromtheexampleabove,wheredeg(c)=nforthecentervertexc.3ViolationoftheTriangleInequalityBunkeandShearer[1998]haveshownthatd(G,H)=1−Mcs(G,H)max{G,H},(3)whereMcs(G,H)isthesizeofamaximumcommonsubgraph,isametricand,inparticular,fulfillsthetriangleinequality.ThearticlebySchietgatetal.[2013]suggeststhatthesizeofaBBP-MCScombinedwithEq.(3)isametric,too.Weshowthatthisisnotthecase.ConsidertheexampleshowninFigure2andletthesizefunctionofagraphGbedefinedasG=V(G)+E(G)following[Schietgatetal.,2013,Section3.2,p.364].EmployingBBP-MCS,weobtainMcs(G,H)=6,Mcs(H,F)=8andMcs(G,F)=1andaccordingly:dGHFG01/37/8H1/301/9F7/81/903 (a)G(b)H(c)FFigure2:OuterplanargraphsforwhichEq.(3)doesnotsatisfythetriangleinequalityunderBBP-MCS.Thetriangleinequalityisviolated,sinced(G,F)>d(G,H)+d(H,F).ReferencesHorstBunkeandKimShearer.Agraphdistancemetricbasedonthemaximalcommonsubgraph.PatternRecognitionLetters,19(3-4):255–259,1998.ISSN0167-8655.doi:DOI:10.1016/S0167-8655(97)00179-7.RanDuanandHsin-HaoSu.Ascalingalgorithmformaximumweightmatchinginbipartitegraphs.InProceedingsoftheTwenty-thirdAnnualACM-SIAMSymposiumonDiscreteAlgorithms,SODA'12,pages1413–1424.SIAM,2012.JohnE.HopcroftandRichardM.Karp.Ann5/2algorithmformaximummatchingsinbipartitegraphs.SIAMJ.Comput.,2(4):225–231,1973.doi:10.1137/0202019.ChristosH.PapadimitriouandKennethSteiglitz.CombinatorialOptimization:AlgorithmsandComplexity.Prentice-Hall,Inc.,UpperSaddleRiver,NJ,USA,1982.ISBN0-13-152462-3.LeanderSchietgat,JanRamon,andMauriceBruynooghe.Apolynomial-timemaximumcommonsubgraphalgorithmforouterplanargraphsanditsap-plicationtochemoinformatics.AnnalsofMathematicsandArtificialIntelli-gence,69(4):343–376,2013.ISSN1012-2443.doi:10.1007/s10472-013-9335-0.4
1704.04205
1
1704
2017-04-13T16:36:44
Hybridizing Non-dominated Sorting Algorithms: Divide-and-Conquer Meets Best Order Sort
[ "cs.DS" ]
Many production-grade algorithms benefit from combining an asymptotically efficient algorithm for solving big problem instances, by splitting them into smaller ones, and an asymptotically inefficient algorithm with a very small implementation constant for solving small subproblems. A well-known example is stable sorting, where mergesort is often combined with insertion sort to achieve a constant but noticeable speed-up. We apply this idea to non-dominated sorting. Namely, we combine the divide-and-conquer algorithm, which has the currently best known asymptotic runtime of $O(N (\log N)^{M - 1})$, with the Best Order Sort algorithm, which has the runtime of $O(N^2 M)$ but demonstrates the best practical performance out of quadratic algorithms. Empirical evaluation shows that the hybrid's running time is typically not worse than of both original algorithms, while for large numbers of points it outperforms them by at least 20%. For smaller numbers of objectives, the speedup can be as large as four times.
cs.DS
cs
Hybridizing Non-dominated Sorting Algorithms: Divide-and-Conquer Meets Best Order Sort Margarita Markina Maxim Buzdalov September 17, 2018 Abstract Many production-grade algorithms benefit from combining an asymp- totically efficient algorithm for solving big problem instances, by split- ting them into smaller ones, and an asymptotically inefficient algo- rithm with a very small implementation constant for solving small subproblems. A well-known example is stable sorting, where merge- sort is often combined with insertion sort to achieve a constant but noticeable speed-up. We apply this idea to non-dominated sorting. Namely, we combine the divide-and-conquer algorithm, which has the currently best known asymptotic runtime of O(N (log N )M−1), with the Best Order Sort algorithm, which has the runtime of O(N 2M ) but demonstrates the best practical performance out of quadratic algorithms. Empirical evaluation shows that the hybrid's running time is typi- cally not worse than of both original algorithms, while for large num- bers of points it outperforms them by at least 20%. For smaller num- bers of objectives, the speedup can be as large as four times. 1 Introduction Many real-world optimization problems are multiobjective, that is, they re- quire maximizing or minimizing several objectives, which are often conflict- ing. These problems most often do not have a single solution, but instead feature many incomparable solutions, which trade one objective for another. It is often not known a priori which solution will be chosen, as decisions of this sort are often recommended to be made late, as the decision maker can 1 learn more about the problem [1]. This encourages finding a set of diverse in- comparable solutions, which is a problem often approached by multiobjective evolutionary algorithms. In the realm of scaling-independent preference-less, and thus general- purpose, evolutionary multiobjective algorithms, three paradigms currently seem to prevail [1]: Pareto-based, indicator-based, and decomposition-based approaches. Although there exist well-known decomposition-based [22] and indicator-based [25,27,28] algorithms, the majority of modern algorithms are Pareto-based [4 -- 6, 26]. Most Pareto-based algorithms belong to one of big groups according to how solutions are selected or ranked: the algorithms which maintain non- dominated solutions [3,4,13], perform non-dominated sorting [5 -- 7], use domi- nation count [9], or domination strength [26]. In this research we concentrate on non-dominated sorting, as some popular algorithms make use of it [5, 6]. Non-dominated sorting assigns ranks to solutions in the following way: the non-dominated solutions get rank 0, and the solutions which are dom- inated only by solutions of rank at most i get rank i + 1. In the original work [20], this procedure was performed in O(N 3M ), where N is the popu- lation size and M is the number of objectives. This was later improved to be O(N 2M ) in [6]. As the quadratic complexity is still quite large, both from theoretical and practical points of view, many researchers concentrated on improving prac- tical running times [8, 11, 16, 19, 21, 23, 24], however, without improving the worst-case O(N 2M ) complexity. Jensen was the first to adapt the earlier re- sult of Kung et at. [14], who solved the problem of finding non-dominated so- lutions in O(N (log N )max(1,M−2)), to non-dominated sorting. This algorithm has the worst-case complexity of O(N (log N )M−1). However, this algorithm could not handle coinciding objective values, which was later corrected in subsequent works [2, 10]. A more efficient algorithm for non-dominated sort- ing, or finding layers of maxima, exists for three dimensions [17], whose complexity is O(N (log log N )2) with the use of randomized data structures, or O(N (log log N )3) for deterministic ones. However, whether this algorithm is useful in practice is still an open question. A large number of available algorithms for non-dominated sorting opens the question of algorithm selection [18]. What is more, a family of O(N 2M ) algorithms for non-dominated sorting resembles a family of quadratic algo- rithms for comparison based sorting, and the O(N (log N )M−1) non-dominated sorting algorithms seem to take up the niche of O(N log N ) sorting algorithms (such as mergesort, heapsort, and randomized versions of quicksort). For comparison-based sorting, the quadratic algorithms are often much simpler and demonstrate better performance on small data, while asymptot- 2 ically better algorithms take over starting from certain problem sizes. If the latter algorithm is built using a divide-and-conquer scheme, it becomes pos- sible to choose better algorithms for subproblems: if a subproblem, due to its size, can be solved faster using a quadratic algorithm, then it should be done, otherwise let the divide-and-conquer algorithm decompose the problem fur- ther. For example, most stable sorting algorithms from standard libraries are currently implemented using mergesort or TimSort, while for data fragments smaller than, for example, 32 in the current implementation of sorting in Java1, the quadratic insertion sort algorithm, with the binary search lookup, is used. This inspired us to apply the similar idea to non-dominated sorting. For the "outer" divide-and-conquer algorithm, we use the only available algo- rithm family of this sort [2, 10, 12]. For the quadratic algorithm to solve smaller subproblems, we adapt the Best Order Sort [19], as it was shown to typically outperform other quadratic algorithms. Our result is a hybrid algorithm which uses primarily the divide-and-conquer strategy and decides when to switch to Best Order Sort using a formula which depends on the number of points in the subproblem and the number of remaining objectives to consider. This is a full version of the paper with the same name which was accepted as a poster to the GECCO conference in 2017. The rest of the paper is structured as follows. In Section 2, we give the necessary definitions and describe the algorithms we put together: the divide-and-conquer algorithm and Best Order Sort. Section 3 describes our hybridizing approach, which includes the changes necessary to introduce to Best Order Sort to serve as the subproblem solver, and the analysis of pre- liminary experiments which established the formula used to switch between the algorithms. Section 4 gives the main body of our experimental studies, including their analysis. Section 5 concludes. 2 Preliminaries In the following, we assume that all points are different, which enables us to name any unordered collection of points a set. This is not true in general, however, all equal points will receive the same rank, so implementations are free, depending on their need, to either discard a point if there is an equal one, or to keep all equal points in a same entity and run algorithms on these entities instead, or to work directly with equal points with some 1http://grepcode.com/file_/repository.grepcode.com/java/root/jdk/ openjdk/8-b132/java/util/TimSort.java 3 additional algorithmic care. None of these precautions change the worst-case algorithmic complexity. 2.1 Definitions We use capital Latin letters to denote sets of points, as well as the global constants N (the number of points) and M (the number of objectives), while small Latin letters are used for single points, standalone objectives and rank values, and small Greek letters are used for mappings. The value of the i-th objective of a point p is denoted as pi. In the rest of the paper we assume, without losing generality, that we solve a multiobjective minimization problem with the number of objectives equal to M . In this case, the Pareto dominance relation is determined on two points in the objective space as follows: a ≺ b ↔ ∀i ∈ [1; M ] ai ≤ bi and ∃i ∈ [1; M ] ai < bi a (cid:22) b ↔ ∀i ∈ [1; M ] ai ≤ bi where a ≺ b is called the strict dominance and a (cid:22) b is the weak dominance. Non-dominated sorting is a procedure which, for a given set P of N points in the M -dimensional objective space, assigns each point p ∈ P an integer rank τ (p), such that: τ (p) = max{0} ∪ {1 + τ (q) q ∈ P, q ≺ p}. In other words, a rank of a point which is not dominated by any other point is zero, and a rank of any other point is one plus the maximum rank among the points which dominate it. Following the convention from [15], we call the set of all points with the given rank r a non-domination level Lr: Lr = {p ∈ P τ (p) = r}. 2.2 The Divide-and-Conquer Approach The divide-and-conquer approach dates back to 1975, when Kung et al. pro- posed a multidimensional divide-and-conquer algorithm for finding the max- ima of a set of vectors [14], which, in the realm of evolutionary computation, corresponds to the set of non-dominated points, or to points with rank zero. The complexity of this algorithm is O(min(N 2, N (log N )max(1,M−2)))), which we shorten to O(N (log N )M−2) for clarity. 4 This algorithm can be used to implement non-dominated sorting in the following manner: first we determine the points with rank zero, then we remove these points and run the algorithm again on the remaining points (which yields points with rank one), then we repeat it until no points left. However, the worst-case complexity of this approach is O(N 2(log N )M−2). In contrast, fast non-dominated sorting, shipped with the original NSGA-II of Deb et at. [6], has a better O(N 2M ) complexity. The divide-and-conquer approach has been generalized to perform non- dominated sorting by Jensen [12], shortly afterwards the NSGA-II arrived. The algorithm from [12] solves the problem in O(N (log N )M−1), which is much faster for small values of M , as well as for large values of N , than fast non-dominated sorting. However, this algorithm was designed with an assumption that no two points have equal objectives, which is often not the case, especially in discrete optimization, and is known to produce wrong re- sults when this assumption is violated. This problem was overcome by Fortin et al. [10], who proposed modifications of this algorithm to always produce correct results. The average complexity was proven to be the same, but the worst-case complexity was left at O(N 2M ). Finally, Buzdalov et al. [2] in- troduced further modifications to achieve the worst-case time complexity of O(N (log N )M−1). We shall now briefly illustrate the working principles of this approach. At any moment of time, the algorithm maintains, for every point p, a lower bound on its rank r(cid:48)(p), which are initially set to zero. The reason for this lower bound can be explained as follows: at any moment of time, we have performed a subset of necessary objective comparisons, which impose approximations of ranks of the affected points. These approximations are of course lower bounds of the real ranks. To ease the notation, in the following we do not use the term "lower bound of the rank", as well as the r(cid:48) symbol. Instead, we will say "current rank" for the current state of the lower bound of a certain point, which possibly coincides with the real rank, and "final rank" when we know that the lower bound coincides with the real rank. One of the main properties of the algorithm is that whenever a comparison of pm and qm is performed for the first time, where p and q are points and 1 ≤ m ≤ M is the objective, then the following holds: • for all objectives m(cid:48) such that m < m(cid:48) ≤ M , it holds that pm(cid:48) ≤ qm(cid:48), that is, p weakly dominates q in objectives [m(cid:48); M ]; • the rank of p is known and final, that is, all comparisons necessary to determine the rank of p have already been done. 5 The top-level concept is the procedure HelperA(S, m), which takes a set of points S sorted lexicographically (where non-zero lower bounds are possibly known for some of the points from S) and makes sure all necessary comparisons between the objectives [1; m] of these points are performed. This procedure is called only when all necessary comparisons of points p and q, such that q ∈ S and p /∈ S, have already been performed. To per- form non-dominated sorting of a set P with M objectives, one should run HelperA(P, M ). For m = 2, it calls a sweep line based algorithm SweepA(S), which runs in O(S log S), which we will cover later. If there are at most two points in S, it performs their direct comparisons and updates the rank of the second point if necessary. If all values of the objective m are the same in the entire S, it directly calls HelperA(S, m − 1). Otherwise, it divides S into three parts using the objective m: the SL part with lower values, the SM part with median values, and the SH part with higher values. It is clear that ranks of points in SL do not depend on ranks of points in neither SM nor SH, and SM also does not depend on SH. The algorithm first calls HelperA(SL, m), which results in finding the exact ranks in SL, because all necessary comparisons with points from SL on the right side and other points on the left side have been performed before this call. Next comes the set SM , but the ranks of these points still need to be updated using the set SL (and nothing more). To do this, the algorithm calls another procedure, HelperB(SL, SM , m − 1), whose meaning is to update the ranks of points from the second argument using the first argument and objectives in [1; m − 1]. Then it calls HelperA(SM , m − 1), as all other necessary comparisons have been done, and all values for the objective m are equal in SM . It then proceeds with HelperB(SL ∪ SM , SH, m − 1) and finishes with HelperA(SH, m). The HelperB(L, H, m) procedure, as follows from the short description above, shall perform all the necessary comparisons between points p ∈ L on the left and q ∈ H on the right, provided that in objectives [m+1; M ] it holds that p ≺ q, and all ranks in L are final. For m = 2, it, again, runs a sweep line procedure SweepB(L, H). If L = 1 or H = 1, a straightforward pairwise If the maximum value of the objective m in L comparison is performed. does not exceed the minimum value in H, it calls HelperB(L, H, m − 1). Otherwise, it chooses a median of the objective m in L∪H and then, similarly to HelperA, splits L into LL, LM and LH, and also splits H into HL, HM and HH. Following the same logic as in HelperA, it performs the following recursive calls: • HelperB(LL, HL, m); 6 Figure 1: Example iterations of the SweepA procedure. Gray points are those whose rank is determined, the darker ones constitute a binary search tree and thus connected with dotted lines. The numbers in white points are the lower bounds on ranks. The vertical dashed line is the sweep line. In (b), the representer of level 2 is removed as all possible remaining points dominated by that point are also dominated by the representer of level 3; similar thing happens in (c). • HelperB(LL, HM , m − 1); • HelperB(LM , HM , m − 1); • HelperB(LL ∪ LM , HH, m − 1); • HelperB(LH, HH, m). The remaining parts to explain are SweepA(S) and SweepB(L, H). The SweepA procedure utilizes a sweep line approach. Points from the set S are processed in lexicographical order using first two objectives. In the same time, the procedure maintains a binary search tree which contains the last seen representative points for each non-domination level. When the next point is processed, this binary search tree is traversed to determine the biggest number of the level which still dominates the point in question, and then the rank of this point is updated correspondingly. After that, this point is inserted in the tree: it becomes the last representative of its non- domination level and possibly throws out some of the other representatives, which have no more chance to determine rank of any point on their own. An example is shown in Fig. 1. The SweepB procedure works in a similar way. The sweep line goes over the union of sets, L∪ H, however, the tree is built of the points from L only, and rank updates are performed with points from H only. The running times of SweepA and SweepB are O(S log S) and O((L+ H) log L), respectively. From the well-known theory of solving recursive relations, and from the strategies of creating subproblems, it follows that the 7 11122331452(a)11122333452(b)11122333452(c)11122333456(d) running time of HelperB(L, H, m) is O((L + H) · (log(L + H))m−1), and of HelperA(S, m) it is O(S · (log S)m−1). 2.3 Best Order Sort The Best Order Sort algorithm was proposed in [19]. It aims at removing as many comparisons to be performed as possible. To do this, it sorts all points by all objectives, thus constructing M sorted lists of points L1 . . . LM , and processes the points in the following order: first, all first points in the lists (L1,1, . . . , LM,1), then all second points (L1,2, . . . , LM,2), then all third points, et cetera, until every point is processed at least once. When a point p is processed for the first time, assume it happens in the list of the m-th objective, its rank has to be determined. The key fact is that only the points which precede p in Lm can dominate p, because all other points have a greater value of the m-th objective. Thus, it makes sense to compare p with the points that precede it in Lm. To further decrease the number of comparisons, it is worth noting that, when a certain point p is processed in objective m, all subsequent new points, that is the points which will be processed for the first time, will have a value of the m-th objective which is not smaller than the one of p. This means that the objective m can be safely removed from the list of objectives to test when some other point q is checked for being dominated by p. The algorithm maintains a set of objectives to consider Op for every point p. Initially, Op ← {1, 2, . . . , M}. Whenever a point p is processed in the list of the m-th objective, it is removed from Op. Whenever a point q is checked for being dominated by p, only the objectives from Op need to be considered. Finally, to determine the rank using fewer comparisons, the points, which have been already considered in each objective list and have been assigned ranks, are stored in separate lists, where each list corresponds to a rank. To determine the rank of the next point, one can perform either a linear scan (starting with rank zero and increasing ranks by one) or binary search for the rank. As the number of points in rank lists cannot be non-trivially bounded, both ways have the worst-case complexity of a single search of O(LM ), where L is the number of points in all lists. Best Order Sort features two phases: the pre-sorting phase, which takes O(N M log N ), and the domination scanning phase. The complexity of the latter, in the worst case, is O(N 2M ), but can be smaller under various con- ditions. For instance, when all points are non-dominating, the points have a chance to arrange such that the first N processed points are unique, which means that every such point is tested against O(N/M ) points in average, which results in O(N 2) running time. 8 3 Hybridizing the Algorithms Our hybridization scheme is similar to that of production-grade sorting al- gorithms tuned for performance. As the top-level algorithm, we use the divide-and-conquer algorithm. For each subproblem it decides, using certain heuristic, whether to continue using the divide-and-conquer strategy or to run Best Order Sort for this subproblem. In turn, Best Order Sort runs uninterrupted until it solves the assigned subproblem. Two problems need to be solved for this scheme to work. First, the original Best Order Sort algorithm cannot be straightforwardly applied to solve subproblems, because subproblems may feature non-zero lower bounds for ranks of some points, which appear from comparisons of these points with other points, which are out of the scope of the current subproblem. It also does not support working with two point sets in order to serve as a back-end of HelperB. Second, the particular kind of heuristic to determine when to run Best Order Sort is unclear. The main problem with it is that it should have a low computation complexity: at most O(N ), because otherwise evaluation of this heuristic worsens the complexity of the divide-and-conquer algorithm. This means we cannot perform any complicated analysis, such as, for instance, principal component analysis, to predict which algorithm is best. In this section we address these two problems, which determines the shape of our hybridization approach. 3.1 Adaptation of Best Order Sort When working as a part of the divide-and-conquer algorithm, Best Order Sort can be called instead either HelperA or HelperB. In the first case, it needs to assign final ranks to a set of points S using first m objectives (m > 2, as SweepA, due to its simplicity, works faster than Best Order Sort under any conditions), provided that all other necessary comparisons have been already performed, and consequently every point p has a current rank τ (p), which is a lower bound of its real rank. The only difference to the original Best Order Sort is that some τ (p) can be non-zero. This is easily compensated by checking only rank lists with ranks greater than or equal to τ (p), and thus updating the rank only if the update is increasing. The HelperB case is slightly more involved. If Best Order Sort is called within HelperB(L, H, m), then ranks of points from L are already known, and it is necessary to perform comparisons between points from L and points from H to update the current ranks τ (p) of points p ∈ H using first m objectives. In this case, all points are merged and are processed altogether. 9 Figure 2: Example result of preliminary experiments on a dataset with 10 objectives and one non-domination level. The dataset has N = 105 points, all other points correspond to divide-and-conquer subproblems for this dataset. Tf is the running time of the divide-and-conquer algorithm, and Tb is the running time of Best Order Sort. The value of (Tb − Tf )/ max(Tf , Tb) is plotted. However, for points from L the rank is not updated (that is, the rank lists are never checked), instead they go directly to the corresponding rank lists. On the contrary, the rank update procedure is executed on points from H, but they are never added to rank lists. These changes are quite small, so the correctness of Best Order Search in the changed conditions follows straightforwardly from the correctness of the original algorithm [19]. The worst-case complexity of the HelperB case is O(M · L ∪ H · log L ∪ H, M · L · H). 3.2 Design of the Switch Heuristic To understand the possible kind of the heuristic algorithm to use for deciding whether to use Best Order Sort for a certain subproblem, we conducted a series of preliminary experiments. In these experiments, we considered a series of datasets, where every dataset had N = 105 points with M ∈ [3; 20] objectives and was generated either by uniformly random objective sampling (from the [0; 1]M hypercube) or by sampling from a hyperplane 10 Figure 3: Left bounds of the BOS-efficient range: actual bounds from datasets with three levels and the fitted curve (which yields a dataset with exactly one non-domination level). Then we ran the divide-and-conquer algorithm on each of these datasets and recorded all subproblems created during the run. After that, we measured the running times of both the divide-and-conquer algorithm and Best Order Sort on all these subproblems. Fig. 2 shows an example of such experiment. In this figure, the point above the abscissa axis means that for the corresponding subproblem the divide-and-conquer algorithm took less time than Best Order Sort, while a point below zero means the opposite. One can clearly see in Fig. 2 that Best Order Sort behaves best, compared to the divide-and-conquer algorithm, for N which are not too small and not too large. As the similar effect has been noticed for all other datasets as well, we attempted to deduce formulas for the left and right bounds of the higher efficiency range of Best Order Sort. The following empirically constructed formulas were found to fit our data rather well: nmin = m ln(m + 1) and nmax = 150m((ln(d + 1))0.9 − 1.5), where m is the current number of first objectives to consider, nmin is the left bound of the range, and nmax is the right bound. Fig. 3 shows the plot of the left bound formula and the actual left bounds in datasets with three non-domination levels, Fig. 4 does the same for the right bound formula and datasets with twenty levels. The fitting quality is the same for all other considered datasets. As a result, the hybrid algorithm switches to Best Order Sort whenever 11 Figure 4: Right bounds of the BOS-efficient range: actual bounds from datasets with twenty levels and the fitted curve the number of points n and the number of considered objectives m in the current subproblem satisfy: m ln(m + 1) ≤ n ≤ 150m · ((ln(d + 1))0.9 − 1.5). 4 Experiments The main part of experiments was organized as follows. For every combina- tion of: • numbers of points N = (cid:98)10n/4(cid:99) where n ∈ [8; 20]; • numbers of objectives M ∈ {3, 5, 7, 10, 15, 20, 25, 30}; • numbers of non-domination levels L ∈ {1, 2, 3, 5, 10, 20}; ten datasets were created, and running times of all considered algorithms (the divide-and-conquer algorithm, Best Order Sort, and the hybrid algorithm) were measured. The results are presented on pages 17 -- 24 as bar plots for all M and L. Each bar plot features a section corresponding to the value of N , consisting of the following three bars: TBOS/avg(TDC), TDC/avg(TDC), TH/avg(TDC), where TBOS is the running time of Best Order Sort, TDC is the running 12 time of the divide-and-conquer algorithm, and TH is the running time of the proposed hybrid algorithm. The bars for Best Order Sort are blue, and the bars for the hybrid algorithm are brown. Every bar has an average, minimum and maximum value (for the second bar plotting TDC, the average is always one). Whenever a bar's average is greater than one, that is, it points up, it means that the corresponding algorithm is slower than divide-and-conquer, and if it is faster, then the bar points down. From plots on pages 17 -- 24, one can immediately spot the characteris- tic behavior of Best Order Sort: it is typically better at smaller numbers of points, then it gradually becomes worse (for M = 7 and M = 10, this tendency is seen the best). For somwhat higher dimensions (M = 20 and M = 25), the lower bound of the Best Order Sort efficiency interval can be seen. For the highest considered dimension, M = 30, Best Order Sort demonstrates no significant improvement over the divide-and-conquer algo- rithm. The hybrid algorithm tends to perform at least as good as the best of the two algorithms up to M = 7. Starting from M = 10, it features a somewhat suboptimal performance at the middle problem sizes (N ∈ [103; 104]) while still capturing the best behavior at small sizes and getting better than all other algorithms close to N = 105. In fact, the hybrid is always better than its parts for big numbers of points. For N = 105, the average speedup compared to the best of the parts can be as large as 4.28 when M = 3, and never seen to get less than 1.198 in all other considered datasets. 5 Conclusion We presented a hybrid algorithm for non-dominated sorting which initially runs a divide-and-conquer algorithm, however, when the size of a certain subproblem seems to be suitable, it solves this subproblem using another approach, Best Order Sort. For this to work, we slightly adapted Best Order Sort, so that it can perform non-dominated sorting in a more general setup, which needs to solve the divide-and-conquer subproblems. We also composed a heuristic rule for when to switch to Best Order Sort, which is based solely on the dimensions of a subproblem. Our algorithm performs generally at least as well as its parts, except for certain ranges around the switchpoint between the algorithms at higher dimensions. This is an indicator that our heuristic on when to switch is not perfect yet and has a room for improvement. Nevertheless, for the wide range of testing data (3 to 30 objectives, 1 to 20 non-domination levels) our 13 algorithm performs at least 20% better than the best of its parts for large numbers of points (such as N = 105), and the speedup can be up to 4x for smaller M . In a sense, this means that our hybridization scheme is rather robust. References [1] D. Brockhoff and T. Wagner. Gecco 2016 tutorial on evolutionary mul- In Proceedings of Genetic and Evolutionary tiobjective optimization. Computation Conference Companion, pages 201 -- 227, 2016. [2] M. Buzdalov and A. Shalyto. A provably asymptotically fast version of the generalized Jensen algorithm for non-dominated sorting. In Parallel Problem Solving from Nature -- PPSN XIII, number 8672 in Lecture Notes in Computer Science, pages 528 -- 537. Springer, 2014. [3] C. Coello Coello and G. Toscano Pulido. A micro-genetic algorithm for multiobjective optimization. In Proceedings of International Conference on Evolutionary Multi-Criterion Optimization, number 1993 in Lecture Notes in Computer Science, pages 126 -- 140. 2001. [4] D. W. Corne, N. R. Jerram, J. D. Knowles, and M. J. Oates. PESA- II: Region-based selection in evolutionary multiobjective optimization. In Proceedings of Genetic and Evolutionary Computation Conference, pages 283 -- 290. Morgan Kaufmann Publishers, 2001. [5] K. Deb and H. Jain. An evolutionary many-objective optimization algo- rithm using reference-point-based nondominated sorting approach, part I: Solving problems with box constraints. IEEE Transactions on Evolu- tionary Computation, 18(4):577 -- 601, 2013. [6] K. Deb, A. Pratap, S. Agarwal, and T. Meyarivan. A fast and eli- tist multi-objective genetic algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6(2):182 -- 197, 2002. [7] M. Erickson, A. Mayer, and J. Horn. The niched Pareto genetic algorithm 2 applied to the design of groundwater remediation sys- tems. In Proceedings of International Conference on Evolutionary Multi- Criterion Optimization, number 1993 in Lecture Notes in Computer Sci- ence, pages 681 -- 695. 2001. 14 [8] H. Fang, Q. Wang, Y.-C. Tu, and M. F. Horstemeyer. An efficient non- dominated sorting method for evolutionary algorithms. Evolutionary Computation, 16(3):355 -- 384, 2008. [9] C. M. Fonseca and P. J. Fleming. Nonlinear system identification with multiobjective genetic algorithm. In Proceedings of the World Congress of the International Federation of Automatic Control, pages 187 -- 192, 1996. [10] F.-A. Fortin, S. Grenier, and M. Parizeau. Generalizing the improved run-time complexity algorithm for non-dominated sorting. In Proceed- ings of Genetic and Evolutionary Computation Conference, pages 615 -- 622. ACM, 2013. [11] P. Gustavsson and A. Syberfeldt. A new algorithm using the non- dominated tree to improve non-dominated sorting. Evolutionary Com- putation, Jan. 2017. Just Accepted publication. [12] M. T. Jensen. Reducing the run-time complexity of multiobjective EAs: The NSGA-II and other algorithms. IEEE Transactions on Evolutionary Computation, 7(5):503 -- 515, 2003. [13] J. D. Knowles and D. W. Corne. Approximating the nondominated front using the Pareto archived evolution strategy. Evolutionary Computation, 8(2):149 -- 172, 2000. [14] H. T. Kung, F. Luccio, and F. P. Preparata. On finding the maxima of a set of vectors. Journal of ACM, 22(4):469 -- 476, 1975. [15] K. Li, K. Deb, Q. Zhang, and S. Kwong. Efficient non-domination level update approach for steady-state evolutionary multiobjective optimiza- tion. Technical Report COIN 2014014, Michigan State University, 2014. [16] K. McClymont and E. Keedwell. Deductive sort and climbing sort: New methods for non-dominated sorting. Evolutionary computation, 20(1):1 -- 26, 2012. [17] Y. Nekrich. A fast algorithm for three-dimensional layers of maxima problem. In Algorithms and Data Structures, number 6844 in Lecture Notes in Computer Science, pages 607 -- 618. 2011. [18] J. R. Rice. The algorithm selection problem. Advances in Computers, 15:65 -- 118, 1976. 15 [19] P. C. Roy, M. M. Islam, and K. Deb. Best Order Sort: A new algorithm to non-dominated sorting for evolutionary multi-objective optimization. In Proceedings of Genetic and Evolutionary Computation Conference Companion, pages 1113 -- 1120, 2016. [20] N. Srinivas and K. Deb. Multiobjective optimization using non- dominated sorting in genetic algorithms. Evolutionary Computation, 2(3):221 -- 248, 1994. [21] H. Wang and X. Yao. Corner sort for pareto-based many-objective op- timization. IEEE Transactions on Cybernetics, 44(1):92 -- 102, 2014. [22] Q. Zhang and H. Li. MOEA/D: A multiobjective evolutionary algorithm based on decomposition. IEEE Transactions on Evolutionary Compu- tation, 11(6):712 -- 731, 2007. [23] X. Zhang, Y. Tian, R. Cheng, and Y. Jin. An efficient approach to non- dominated sorting for evolutionary multiobjective optimization. IEEE Transactions on Evolutionary Computation, 19(2):201 -- 213, 2015. [24] X. Zhang, Y. Tian, R. Cheng, and Y. Jin. A decision variable clustering- based evolutionary algorithm for large-scale many-objective optimiza- tion. IEEE Transactions on Evolutionary Computation, 2016. [25] E. Zitzler and S. Kunzli. Indicator-based selection in multiobjective search. In Parallel Problem Solving from Nature -- PPSN VIII, number 3242 in Lecture Notes in Computer Science, pages 832 -- 842. 2004. [26] E. Zitzler, M. Laumanns, and L. Thiele. SPEA2: Improving the strength pareto evolutionary algorithm for multiobjective optimization. In Pro- ceedings of the EUROGEN'2001 Conference, pages 95 -- 100, 2001. [27] E. Zitzler and L. Thiele. Multiobjective evolutionary algorithms: A comparative case study and the Strength Pareto approach. IEEE Trans- actions on Evolutionary Computation, 3(4):257 -- 271, 1999. [28] E. Zitzler, L. Thiele, M. Laumanns, C. M. Fonseca, and V. Grunert da Fonseca. Performance assessment of multiobjective optimizers: An anal- IEEE Transactions on Evolutionary Computation, ysis and review. 7(2):117 -- 132, 2003. 16 M = 3, one level M = 3, two levels M = 3, three levels M = 3, five levels M = 3, 10 levels M = 3, 20 levels 17 10210310410510−1100101102102103104105100101102102103104105100101102101102103104105100101102102103104105100101102102103104105100101 M = 5, one level M = 5, two levels M = 5, three levels M = 5, five levels M = 5, 10 levels M = 5, 20 levels 18 102103104105100101102103104105100101102103104105100101102103104105100101102103104105100101102103104105100101 M = 7, one level M = 7, two levels M = 7, three levels M = 7, five levels M = 7, 10 levels M = 7, 20 levels 19 102103104105100101102103104105100101102103104105100101102103104105100101102103104105100101102103104105100101 M = 10, one level M = 10, two levels M = 10, three levels M = 10, five levels M = 10, 10 levels M = 10, 20 levels 20 102103104105100101102103104105100101102103104105100101102103104105100101102103104105100101102103104105100101 M = 15, one level M = 15, two levels M = 15, three levels M = 15, five levels M = 15, 10 levels M = 15, 20 levels 21 102103104105100100.5102103104105100100.5102103104105100100.5102103104105100100.5102103104105100100.5102103104105100100.5 M = 20, one level M = 20, two levels M = 20, three levels M = 20, five levels M = 20, 10 levels M = 20, 20 levels 22 102103104105100100.5102103104105100100.5102103104105100100.5102103104105100100.5102103104105100100.5102103104105100100.5 M = 25, one level M = 25, two levels M = 25, three levels M = 25, five levels M = 25, 10 levels M = 25, 20 levels 23 10210310410510−0.2100100.2100.4100.6100.810210310410510−0.2100100.2100.4100.6100.810210310410510−0.2100100.2100.4100.610210310410510−0.2100100.2100.4100.6102103104105100100.2100.4100.610210310410510−0.2100100.2100.4100.6 M = 30, one level M = 30, two levels M = 30, three levels M = 30, five levels M = 30, 10 levels M = 30, 20 levels 24 10210310410510−0.2100100.2100.4100.610210310410510−0.2100100.2100.4100.610210310410510−0.2100100.2100.4100.6102103104105100100.2100.4100.610210310410510−0.2100100.2100.4100.610210310410510−0.2100100.2100.4100.6
1702.05570
1
1702
2017-02-18T04:49:13
Multi-way sparsest cut problem on trees with a control on the number of parts and outliers
[ "cs.DS" ]
Given a graph, the sparsest cut problem asks for a subset of vertices whose edge expansion (the normalized cut given by the subset) is minimized. In this paper, we study a generalization of this problem seeking for $ k $ disjoint subsets of vertices (clusters) whose all edge expansions are small and furthermore, the number of vertices remained in the exterior of the subsets (outliers) is also small. We prove that although this problem is $ NP-$hard for trees, it can be solved in polynomial time for all weighted trees, provided that we restrict the search space to subsets which induce connected subgraphs. The proposed algorithm is based on dynamic programming and runs in the worst case in $ O(k^2 n^3) $, when $ n $ is the number of vertices and $ k $ is the number of clusters. It also runs in linear time when the number of clusters and the number of outliers is bounded by a constant.
cs.DS
cs
Multi-way sparsest cut problem on trees with a control on the number of parts and outliers Ramin Javadi∗† Saleh Ashkboos‡ Abstract Given a graph, the sparsest cut problem asks for a subset of vertices whose edge ex- pansion (the normalized cut given by the subset) is minimized. In this paper, we study a generalization of this problem seeking for k disjoint subsets of vertices (clusters) whose all edge expansions are small and furthermore, the number of vertices remained in the exterior of the subsets (outliers) is also small. We prove that although this problem is N P−hard for trees, it can be solved in polynomial time for all weighted trees, provided that we restrict the search space to subsets which induce connected subgraphs. The proposed algorithm is based on dynamic programming and runs in the worst case in O(k2n3), when n is the number of vertices and k is the number of clusters. It also runs in linear time when the number of clusters and the number of outliers is bounded by a constant. Key words: sparsest cut problem, isoperimetric number, Cheeger constant, normalized cut, graph partitioning, computational complexity, weighted trees. Subject classification: 05C85, 68Q25, 68R10. 1 Introduction Data clustering is definitely among the main topics of modern computer science with an in- dispensable role in data mining, image and signal processing, network and data analysis, and data summarization (e.g. see [13] and references therein). Considering the current status of data science, one may name some fundamental challenges in this field, among many others, as follows: • Clustering huge and usually high-dimensional data. • Clustering in presence of outliers and anomalies. • Clustering non-geometric (usually non-Euclidean) data. • Clustering with no prior information about the number of clusters or other features of data (as model of the source etc.). ∗Corresponding author, Department of Mathematical Sciences, Isfahan University of Technology, P.O. Box: 84156-83111, Isfahan, Iran. School of Mathematics, Institute for Research in Fundamental Sciences (IPM), P.O. Box: 19395-5746, Tehran, Iran. Email Address: [email protected]. †This research was in part supported by a grant from IPM (No. ...). ‡Department of Computer Engineering, Isfahan University of Technology, P.O. Box: 84156-83111, Isfahan, Iran. Email Address: [email protected]. 1 Needless to say, in each case, efficiency and time-complexity of the proposed algorithms are global parameters with a decisive role in applicability. The subject of this article falls into the setup of clustering in an unsupervised and static graph- based data presentation. It is instructive to note that the graph-based approach essentially provides data presentation in a very general (not necessarily Euclidean) setting in terms of similarity kernels. In this respect, one of the main well-studied criteria is the "sparsest cut prob- lem" which apart from tremendous real-world applications in the context of spectral clustering (see e.g. [19, 21]), has played a crucial role in the development of many subjects in theoretical computer science (see e.g. [7, 22]). Our main objective in this article is to improve this approach, which is essentially based on solving a suitable subpartitioning problem on a corresponding minimum spanning tree, by pro- viding an algorithm that not only gives rise to a fast clustering procedure, but also provides good control on determining the number of clusters and outliers. The procedure is based on a dynamic programming which runs in the worst case in O(k2n3), where n is the data size and k is the number of clusters. Also, the algorithm runs in linear time in terms of the data size when the number of clusters k and the upper bound on the number of outliers are both constant (which is the case in the most prevalent applications). To the best of our knowledge, the partitioning problem solved by the proposed algorithm (Algorithm 3) is among the most challenging problems in this literature which is efficiently solvable, while we will also dwell on some important consequences in what follows. 1.1 A formal setup and the main result Partitioning problems are essentially as old as graph theory itself, with wide applications in science and technology. In particular, one may refer to the unnormalized partitioning problems that usually are considered as different versions of minimum cut problems as well as the normal- ized versions which are more plausible in real applications, however, are much harder to resolve. One of the main problems in the category of normalized cut criteria is the sparsest cut problem which is defined as follows. Given a graph G, the sparsest cut problem asks for a cut (a subset of vertices) which has the minimum edge expansion, i.e. φ(G) := min S(V (G),S6=∅ max(cid:26)∂S S S (cid:27) , , ∂S (1) where S := V (G) \ S and ∂S is the set of all edges with exactly one end in S. The sparsest cut problem is known to be an N P−hard problem on general graphs [18, 21]. Efforts to find an efficient algorithm for a good approximation of this problem have triggered off the development of many subfields of computer science and have had a significant influence on algorithm design and complexity theory. It is amazing to see that recent advances in computer science have given rise to a culmination of ideas not only from the classical graph theoretic point of view but also from the more geometric point of view discussed in the theory of Riemannian manifolds and stochastic processes [23]. Up to now, the best known approximation result for the sparsest cut problem is due to Arora, Rao, and Vazirani [3] which gives an O(√log n) approximation algorithm. It is also worth noting that the invariant defined in (1) has an intimate connection with the second eigenvalue of the associated Laplacian operator. In fact, relaxation of the minimization problem in (1) to the Euclidean norm for real functions (i.e. changing the edge expansion to the Euclidean 2-norm of the gradient of real functions which is the energy representable by the Laplacian operator) gives rise to an eigenvalue problem which is efficiently solvable, while estimating the approximation ratio of this relaxation has led to some fundamental contributions 2 (e.g. see [1,2]). These relations, known as Cheeger's inequalities, also exert considerable influence over constructing the expander graphs as well as the study of the mixing time of Markov chains (see e.g. [14, 15]). In general, although the motivating problems in these fields of study are usually different, the synergistic effect of methods and techniques have flourished into one of the most active and productive topics in mathematics and computer science. Recently, some generalizations of the sparsest cut problem have been studied in the literature. Here, we study a generalization which extends two-way partitioning into k−way connected subpartitioning and allows some vertices to lie outside the parts. To formulate the problem precisely, let us first fix our notation and terminology. We assume that the data is given as a simple and finite weighted graph G = (V, E, ω, c) in which ω : V → Q+ and c : E → Q+ are the vertex and edge weight functions, respectively. Note that in the literature close to applications the function c is sometimes referred to as the kernel or the similarity, while from a geometric point of view the graph can also be considered as a discrete metric-measure space, where the distance function is usually chosen to be proportional to some inverse function of c. In this setting, by an unweighted graph we mean a graph in which all the vertex and edge weights are equal to 1. Given a graph G = (V, E, ω, c) and a subset of vertices S ⊆ V , the edge exapnsion or the conductance of S, is defined as where, φG(S) := c(∂S) ω(S) , ω(S) := Xu∈S ω(u), c(∂S) := Xe∈E(S,S) c(e). From a geometric point of view, the conductance can be interpreted as a normalized norm of a gradient function or a normalized energy (e.g. see [5,6] for more on the geometric interpretations). The set Dk(V ) is defined to be the set of all k-subpartitions {A1, . . . , Ak} := {Ai}k 1 of V , in which Ai's are nonempty disjoint subsets of V . The residue of a subpartition {A1, . . . , Ak} is defined to be the set R := V − ∪k i=1Ai. The set of all k-partitions of V , which is denoted by Pk(V ), is the subclass of Dk(V ) containing all k-subpartitions {Ai}k i=1Ai = V (i.e. R = ∅). A subpartition (or a partition in particular) is said to be connected if the subgraph induced on each of its parts is a connected subgraph of G. A generalization of the sparsest cut problem can be formulated as follows. 1 for which ∪k Definition 1. Given a weighted graph G = (V, E, ω, c) and a positive integer k, 1 ≤ k ≤ V , the kth isoperimetric number is defined as, ιk(G) := min 1 ∈Dk(V ) {Ai}k max 1≤i≤k φG(Ai). Furthermore, considering the partitions, the kth minimum normalized cut number is defined as, ιk(G) := min 1 ∈Pk(V ) {Ai}k max 1≤i≤k φG(Ai). A vertex v ∈ V is called a k-outlier, if there exists a minimizing subpartition achieving ιk(G), while v lies in its residue. It is well-known that ι2 = ι2 (see [8]) and the common value is usually called the Cheeger constant or edge expansion in the literature. N In this regard, Louis et al. in [17] provide a polynomial time approximation algorithm which outputs a (1 − ǫ)k-partition of the vertex set such that each piece has expansion at most Oǫ(√log n log k) times ιk(G) (for every positive number ǫ). Also, in [16], higher-order Cheeger's 3 inequalities have been proved which relate the above parameters to the eigenvalues of the asso- ciated Laplacian Matrix (see also [8, 10]). Prior to formulating our problem, let us discuss some facts. First, one may note that as an imprecise rule of thumb, changing the cost function of a partitioning problem, from the normal- ized form to the unnormalized form, from partitions to subpartitions, or from the mean (i.e. 1-norm) to the max (i.e. ∞-norm) generally makes the problem more tractable in the sense that finding more efficient algorithms to solve the problem become more probable. One of our major observations in this article is the fact that the restriction of the search space to "connected" subpartitions reduces the complexity of the problem too. In particular, this distinction is much comprehensible when the graph is a tree where the restriction on subpartitions to be connected reduces the complexity of the problem from N P−hard to polynomial time. Also, note that this restriction is to the best of our advantage in the sense that a cluster is more expected to be represented by a connected subgraph than a disconnected one (based on intra-similarity of the objects within a cluster). Hence, as far as clustering is concerned, this can be considered as an acceptable assumption. As a matter of fact, in what follows, we show that such a change to the better will give rise to an efficient algorithm for clustering with a control on the number of parts and outliers. We denote the main problem, i.e. the multi-way sparsest cut problem with a control on the residue number, by the acronym "MSC problem" which is defined as follows. MSC Problem. INSTANCE: A weighted graph G = (V, E, ω, c), nonnegative integers κ ∈ Z+ and 1 ∈ Dκ(V ) such QUERY: V \ λ ∈ Z+ and a positive rational number ξ ∈ Q+. Does there exist a κ-subpartition of V such as {Ai}κ that max ∪κ i=1Ai ≤ λ? 1≤i≤κ{φG(Ai)} ≤ ξ and its residue number is at most λ, i.e. The MSC problem is known to be a hard problem even when the graph is of its simplest form, i.e. a tree. When the graph G is a tree, it is proved in [9] that MSC problem is N P−complete even when the tree is unweighted and λ is constant (e.g. λ = 0). Nonetheless, it is shown there that the problem is solvable in linear time for weighted trees when we drop the restriction on the residue number (i.e. λ = V ). An improvement of this result has effectively been applied to real clustering problems for large data-sets [11]. The main contribution of this article (Algorithm 3) is to show that although MSC problem is N P−complete for trees, it becomes tractable when the search space is restricted to connected subpartitions. In other words, the following problem abbreviated by CMSC can be solved in polynomial time for weighted trees. CMSC Problem. INSTANCE: A weighted graph G = (V, E, ω, c), nonnegative integers κ ∈ Z+ and 1 ∈ Dκ(V ) QUERY: 1≤i≤κ{φG(Ai)} ≤ ξ and its residue number is at most λ, i.e. λ ∈ Z+ and a positive rational number ξ ∈ Q+. Does there exist a connected κ-subpartition of V such as {Ai}κ such that max V \ ∪κ i=1Ai ≤ λ? This result along with the fact that the minimum spanning tree of a geometric metric-measure space inherits a large part of the geometry of the space, can lead to a good approximation for MSC problem for general graphs. This can justify the importance of the problem on weighted trees when applications are concerned. Let us consider some consequences of this result. Firstly, note that given a weighted tree T and integers κ and λ, finding the minimum num- ber ξ for which there exists a connected κ−subpartition with the residue number at most λ 4 and max1≤i≤κ{φG(Ai)} ≤ ξ (as well as finding the minimizing subpartition) can be done in polynomial time by applying our algorithm iteratively along with a simple binary search. Secondly, given a weighted tree T and numbers ξ, λ (the worst edge expansion of the clusters), we can obtain a number kmax(T, ξ), denoting the maximum number of parts for which the answer to CMSC problem is positive. This by itself is an important piece of information when one considers the large existing literature discussing how to determine the number of clusters for a clustering algorithm (e.g. see [20] for k-means). Thirdly, from another point of view, CMSC problem can be considered as a problem of outlier- robust clustering where a solution will provide information on the number of outliers. It is well-known that detection of outliers and anomalies in data-sets are among the most challenging problems in the field, not just because of the hardness of the problem itself, but since the concepts themselves are quite fuzzy and depend on many different parameters as scaling or distribution of the source (e.g. see [4,12] for the background). These facts, and in particular, lack of a universal sound and precise definition, is among the first obstacles when one is dealing with these kinds of problems. In [11] some evidence has been discussed that how the data remained in the exterior of the clusters in MSC problem can be justified to be actual outliers in some sense. Finally, our method can be extended to handle some more general semi-supervised settings where a number of training samples are given by the user which are forced or forbidden to lie in outliers (see Section 4). The organization of forthcoming sections is as follows. In Section 2, we give required definitions and notations as well as the lemmas which justify our algorithm. In Section 3, we present the main algorithm and explain how it can find the optimal subpartition. We also compute the time complexity of our algorithm. Finally, in Section 4, we discuss some extensions which handle more realistic models. 2 Preliminaries Let T be a rooted tree with root r. There is a natural partial order induced through the root on the vertices and edges of T defined as u ≤ v for two vertices u and v whenever there is a path P (r, v, u) in T starting from r and ending at u which contains v. Similarly, e ≤ e′ for two edges e and e′ whenever there is a path P (r, e′, e) in T starting from r and containing e and e′ such that e′ is closer than e to r on P . In this setting, note that for any u 6= r there exists a unique minimal vertex v, with v ≥ u and an edge eu := uv, where v and eu are called the parent vertex and the parent edge of u, respectively (and also u is called the child of v). Also, for a given edge e = uv with u ≤ v we may refer to e− = u and e+ = v, intermittently. For some technical reasons, we add one new vertex r′ to T and connect it to r and define the parent edge of r, er, as the edge rr′. Also, we set ω(r′) = c(er) = 0. If F is a subset of edges of T , then M (F ) is the set of maximal elements of F with respect to the natural partial order of T . Given a vertex u with the parent edge eu, the subtree Tu = Teu refers to the subtree induced on the set {v ∈ V (T ) : v ≤ u}. Therefore, Tr = Ter = T . Let T = (V, E, ω, c) be a weighted tree and ξ be a fixed positive number. For every integer 0 ≤ k ≤ V , define Ck(T ) to be the class of all k-subpartitions A = {Ai}k 1 such that for each 1 ≤ i ≤ k, Ai ⊆ V (T ) and the induced subgraph of T on Ai is connected (i.e. Ai is a subtree of T ). Also, given a subpartition A = {Ai}k 1 ∈ Ck(T ), its residue set is defined as R(A, T ) := V (T ) \ ∪k i=1Ai. We also define, φT (Ai) := c(∂Ai) ω(Ai) , φT (A) := max 1≤i≤k φT (Ai) and ιC k (T ) := min A∈Ck(T ) φT (A). In the following we describe the idea that our algorithm is based on and also prove the correctness 5 of the algorithm. First, note that since we are looking for subsets with small edge expansion, when we cut an edge e, the subset containing e+ sustains a loss in its edge expansion. The cause of this deficiency is that the numerator of the edge expansion is added by c(e) and the denominator is subtracted by ω(Te). With this intuition, for every edge e ∈ E, define εξ(e) := ξ ω(Te) + c(e). (2) Now, let κ and λ be two nonnegative integers and for every integers 1 ≤ k ≤ κ, 0 ≤ l ≤ λ and vertex u ∈ V (T ), define Cξ(u, k, l) to be the set of all k-subpartitions A = {Ai}k 1 in Ck(Tu) such that u ∈ A1 and R(A, Tu) ≤ l and for each 2 ≤ i ≤ k, we have φT (Ai) ≤ ξ. For each such subpartition A, let FA := ∂A1 \ {eu}. Note that any pair of edges in FA are incomparable and define, γξ(A) := Xe∈FA εξ(e). We will shortly see that minimizing the edge expansion φT (A1), in some sense, is equivalent to minimizing γξ(A) (see (6)). Thus, define, Γξ(u, k, l) := min A∈Cξ(u,k,l) γξ(A). (3) On the other hand, for every integers 0 ≤ k ≤ κ and 0 ≤ l ≤ λ and vertex u ∈ V (T ), define µξ(u, k, l) to be equal to 1 if there exists a connected k-subpartition A = {Ai}k 1 ∈ Ck(Tu) such that φT (A) ≤ ξ and R(A, Tu) ≤ l and it is equal to 0, otherwise. Note that, although Ai's are subsets of V (Tu), φT (Ai) is computed in the whole tree T . Also, note that for every vertex u ∈ V (T ) and integer l, we have µξ(u, 0, l) =(1 0 if V (Tu) ≤ l, o.w. In fact, our main goal is to compute the parameter µξ(r, κ, λ), since evidently the answer to CMSC problem is yes if and only if µξ(r, κ, λ) = 1. In the sequel, we are going to show that the parameters Γξ(u, k, l) and µξ(u, k, l) can be computed recursively in a breath-first scanning of vertices towards the root. First, in the following, we explain how one can compute µξ(u, k, l) recursively in terms of the values Γξ(u, k, l), 1 ≤ k ≤ κ, 0 ≤ l ≤ λ. For this, let ξ, κ, λ be fixed and given a vertex u, let (u1, . . . , ud) be an ordering of all of its children. Now, for every integers 0 ≤ k ≤ κ, 0 ≤ l ≤ λ, define U (1, k, l) := µξ(u1, k, l), if there exist 0 ≤ k′ ≤ k and 0 ≤ l′ ≤ l − 1 such that U (i− 1, k′, l′) = µξ(ui, k − k′, l− 1− l′) = 1, (4) (5) and for every 2 ≤ i ≤ d, define 1 U (i, k, l) :=  0 o.w. In the following lemma, we show how one can use the recursion in (5) to compute the function µξ. Lemma 2. Let u be a vertex in a rooted tree T , ξ ≥ 0 be a number and λ ≥ 0, κ ≥ 1 be two integers. Also, let u1, . . . , ud be the children of u in T . For every integers 0 ≤ k ≤ κ, 0 ≤ l ≤ λ, µξ(u, k, l) = 1 if and only if either Γξ(u, k, l) ≤ ξ ω(Tu) − c(eu), or U (d, k, l) = 1. 6 Proof . Suppose that µξ(u, k, l) = 1 and let A = {Ai}k 1 ∈ Ck(Tu) be a connected subpartition where R(A, Tu) ≤ l and φT (A) ≤ ξ. First, assume that u ∈ R(A, Tu). Thus, A itself can be partitioned into d connected subpartitions A1, . . . ,Ad such that Ai ∈ Cki(Tui), for some integers ki, where k1 + ··· + kd = k. Also, let li = R(Ai, Tui). Therefore, by definition µξ(ui, ki, li) = 1 and l1 + ··· + ld = R(A, Tu) \ {u} ≤ l − 1. Thus, again by definition U (d, k, l) = 1. Next, suppose that u 6∈ R(A, Tu) and so, without loss of generality, assume that u ∈ A1. Then, ω(Te)  φT (A1) ≤ ξ ⇔ c(∂A1) ≤ ξ ω(A1) ⇔ c(eu) + Xe∈FA (6) c(e) ≤ ξ ω(Tu) − Xe∈FA ⇔ γξ(A) ≤ ξ ω(Tu) − c(eu). Therefore, Γξ(u, k, l) ≤ ξ ω(Tu) − c(eu). This implies that if µξ(u, k, l) = 1, then either Γξ(u, k, l) ≤ ξ ω(Tu) − c(eu), or U (d, k, l) = 1. Now, suppose that U (d, k, l) = 1. Then, there exist integers l1, . . . , ld and k1, . . . , kd such that Pd i=1 li = l − 1, Pd i=1 ki = k and µξ(ui, ki, li) = 1, for all 1 ≤ i ≤ d. Thus, for each 1 ≤ i ≤ d, there exists Ai ∈ Cki(Tui) such that R(Ai, Tui) ≤ li and φT (Ai) ≤ ξ. Define A = ∪d i=1Ai. Thus, A ∈ Ck(Tu) and R(A, Tu) ≤ l. Hence, µξ(u, k, l) = 1. Finally, suppose that Γξ(u, k, l) ≤ ξ ω(Tu) − c(eu). Also, let A ∈ Cξ(u, k, l) be a minimizer with γξ(A) = Γξ(u, k, l). Then, by definition, for every 2 ≤ i ≤ k, φT (Ai) ≤ ξ and R(A, Tu) ≤ l and by (6), φT (A1) ≤ ξ. Hence, µξ(u, k, l) = 1. This completes the proof. As we see in Lemma 2, in order to obtain the value of µξ(u, k, l), we require to have the value of Γξ(u, k, l). In the next step, we show that given ξ, κ and λ, how one may compute Γξ(u, k, l) efficiently for all vertices u and integers 1 ≤ k ≤ κ, 0 ≤ l ≤ λ. For this, let ξ, κ, λ be fixed and given a vertex u, let (u1, . . . , ud) be an ordering of all of its children. Now, for every integers 1 ≤ k ≤ κ, 0 ≤ l ≤ λ and 1 ≤ i ≤ d, define (cid:4) Xξ(i, k, l) :=(min{εξ(uui), Γξ(ui, k, l)} Γξ(ui, k, l) if µξ(ui, k − 1, l) = 1, o.w. Also, define and for every 2 ≤ i ≤ d, define Yξ(1, k, l) := Xξ(1, k, l), Yξ(i, k, l) := min{Yξ(i − 1, k′, l′) + Xξ(i, k + 1 − k′, l − l′) : 1 ≤ k′ ≤ k, 0 ≤ l′ ≤ l}. The following lemma shows how to compute the function Γξ using recursion (9). (7) (8) (9) Lemma 3. Let T be a rooted tree, ξ ≥ 0 be a number and λ ≥ 0, κ ≥ 1 be two integers. Then, for every vertex u ∈ V (T ) with d children (u1, . . . , ud) and every integers 1 ≤ k ≤ κ and 0 ≤ l ≤ λ, we have (10) Γξ(u, k, l) = Yξ(d, k, l). Proof . We prove the lemma by induction on the number d. Let A = {Ai}k 1 ∈ Cξ(u, k, l) be a k-subpartition. First, suppose that d = 1. If uu1 ∈ FA, then γξ(A) = εξ(uu1) and A2, . . . , Ak ⊆ V (Tu1), so µξ(u1, k − 1, l) = 1. Also, if uu1 6∈ FA, then u1 ∈ A1 and γξ(A) ≥ Γξ(u1, k, l). Therefore, Γξ(u, k, l) = Xξ(1, k, l) = Yξ(1, k, l) as in (7) and (8). Now, suppose that d ≥ 2. Let T ′ := T \ Tud and T ′′ := T \ (∪d−1 i=1 Tui) and Γ(k, l), Γ′(k, l) and Γ′′(k, l) be the values of Γξ(u, k, l) for the trees T , T ′ and T ′′, respectively. Also, let l′ = R(A, T ) ∩ V (T ′), l′′ = l − l′ and let k′ (resp. k′′) be the number of sets Ai which intersect 7 V (T ′) (resp. V (T ′′)). Then, evidently we have k′ + k′′ = k + 1 (note that A1 intersects both V (T ′) and V (T ′′)) and γξ(A) ≥ Γ′(k′, l′) + Γ′′(k′′, l′′). Therefore, Γ(k, l) = min{Γ′(k′, l′) + Γ′′(k′′, l′′) : k′ + k′′ = k + 1, l′ + l′′ = l}. On the other hand, by the induction hypothesis, we have Γ′(k′, l′) = Yξ(d − 1, k′, l′) and Γ′′(k′′, l′′) = Xξ(d, k′′, l′′). Hence, by (9), we have Γ(k, l) = Yξ(d, k, l) and we are done. (cid:4) 3 The algorithm In this section, using Lemmas 2 and 3, we provide an algorithm to solve the CMSC problem for all weighted trees. The cores of the algorithm are two dynamic programmings. The final solution to the problem is given in Algorithm 3 which scans the vertices in a BFS order towards the root r and computes recursively the values of Γξ(u, k, l) and µξ(u, k, l), for 1 ≤ k ≤ κ and 0 ≤ l ≤ λ. The structure of Algorithm 3 which deploys Algorithms 1 and 2 as two subroutines, is as follows. First, for all leaves u (vertices with no children), it computes the values of Γξ(u, k, l) and µξ(u, k, l) (Lines 8-13 in Algorithm 3). Next, for a vertex u, with children (u1, . . . , ud), according to Lemma 3, it applies a dynamic programming (Algorithm 1) based on the recursion given in Equations (8) and (9), to obtain the value of Γξ(u, k, l), assuming the values of µξ(ui, k, l) and Γξ(ui, k, l) are given. Finally, according to Lemma 2, it applies another dynamic programming (Algorithm 2) based on the recursion given in (5) to obtain the value of µξ(u, k, l), assuming the values of Γξ(u, k, l) and µξ(ui, k, l) are given. The backtracking ends up outputting the value of µξ(r, κ, λ) which is equal to 1 if and only if there exists a connected κ-subpartition A with φT (A) ≤ ξ and R(A, T ) ≤ λ. This completes the solution. 3.1 Time complexity The time complexity of the provided algorithms can be computed as follows. In Algorithm 1, Lines 2-12 can be done in O(d(λ + 1)κ). Also, Lines 14-25 can be performed in O(d(λ + 1)2κ2). In Algorithm 2, Lines 2-9 run in O((λ + 1)κ) and Lines 11-26 run in O(d(λ + 1)2κ2). Hence, the runtime of Algorithm 3 is in O((λ + 1)2κ2n). Since in real applications, the values of κ and λ are mostly much smaller than n, we can assume that the algorithm runs in linear time with respect to the number of nodes. 3.2 Constructing the optimal subpartition Now, we show that during the execution of Algorithm 3, how one can construct a subpartition A ∈ Cκ(T ) with φT (A) ≤ ξ and R(A, T ) ≤ λ (if there exists). Let ξ, κ and λ be fixed and for every vertex u ∈ V (T ) and 1 ≤ k ≤ κ and 0 ≤ l ≤ λ, if µξ(u, k, l) = 1, then let Aµ = Aµ(u, k, l) be a k−subpartition in Ck(Tu) such that φT (Aµ) ≤ ξ and R(Aµ, Tu) ≤ l. Also, if µξ(u, k, l) = 0, let Aµ = Aµ(u, k, l) := ∅. Then, the subpartition Aµ(r, κ, λ) is what we are looking for. Also, let AΓ = AΓ(u, k, l) be a subpartition in Cξ(u, k, l) which minimizes (3). Now, let u be a vertex with children (u1, . . . , ud). First, according to Algorithm 2 and as- suming that we have all the subpartitions AΓ(u, k, l) and Aµ(ui, k, l), we explain how to ob- tain Aµ(u, k, l). For this, throughout the execution of Algorithm 2, in Line 5, if Γξ(u, k, l) ≤ ξω(Tu) − c(eu), then set Aµ(u, k, l) := AΓ(u, k, l), otherwise set Aµ(u, k, l) := ∅. Also, in Line 10, if µξ(u1, k, l) = 1, then set U (k, l) := Aµ(u1, k, l) and in Line 18, if U (i − 1, k′, l′) = µξ(ui, k − k′, l − 1 − l′) = 1, then set U (k, l) := U (k′, l′) ∪ Aµ(ui, k − k′, l − 1 − l′). Finally, in Line 27, if U (d, k, l) = 1, then set Aµ(u, k, l) := U (k, l). 8 Algorithm 1 Input: A weighted tree (T, ω, c), a rational number ξ and integers κ ≥ 1 and λ ≥ 0. A vertex u ∈ V (T ) with children (u1, . . . , ud). The numbers µξ(ui, k, l) and Γξ(ui, k, l), for all 1 ≤ i ≤ d, 1 ≤ k ≤ κ and 0 ≤ l ≤ λ. Output: The numbers Γξ(u, k, l) for all 1 ≤ k ≤ κ and 0 ≤ l ≤ λ. 1: Set εi := ξω(Tui) + c(uui), ∀ 1 ≤ i ≤ d; 2: for i = 1 : d do 3: for l = 0 : λ do 4: 5: 6: 7: 8: 9: for k = 1 : κ do if µξ(ui, k − 1, l) = 1 and εi ≤ Γξ(ui, k, l) then else X(i, k, l) := εi; X(i, k, l) := Γξ(ui, k, l); end if 10: end for end for 11: 12: end for 13: Set Y (1, k, l) := X(1, k, l), ∀ 1 ≤ k ≤ κ, 0 ≤ l ≤ λ; 14: for i = 2 : d do 15: for l = 0 : λ do 16: 17: 18: 19: 20: 21: 22: 23: for k = 1 : κ do Y (i, k, l) := +∞; for l′ = 0 : l do for k′ = 1 : k do Y (i, k, l) := min{Y (i, k, l), Y (i − 1, k′, l′) + X(i, k + 1 − k′, l − l′)}; end for end for end for end for 24: 25: end for 26: Set Γξ(u, k, l) := Y (d, k, l), ∀ 1 ≤ k ≤ κ, 0 ≤ l ≤ λ; 27: return Γξ(u, k, l), for all 1 ≤ k ≤ κ and 0 ≤ l ≤ λ; Next, according to Algorithm 1 and assuming that we have all the subpartitions Aµ(ui, k, l) and AΓ(ui, k, l), we explain how to obtain AΓ(u, k, l). First, throughout the execution of Algorithm 1, in Line 5, if µξ(ui, k− 1, l) = 1 and εi ≤ Γξ(ui, k, l), then set X (i, k, l) := Aµ(ui, k− 1, l)∪{{u}}, otherwise let X (i, k, l) be the subpartition obtained from AΓ(ui, k, l) by adding the vertex u to the set containing u1. Also, in Line 13, set Y(k, l) := X (1, k, l). Next, in Line 20, if Y (i − 1, k′, l′) + X(i, k + 1 − k′, l − l′) ≤ Y (i, k, l), then let Y(k, l) be obtained from the disjoint union of Y(k′, l′) and X (i, k + 1 − k′, l − l′) by merging two sets containing the vertex u. Finally, in Line 26, set AΓ(u, k, l) := Y(k, l). 4 Towards more extensions In this section, we show that our presented scheme can be generalized to solve the following more realizable problems efficiently: 1. Solving CMSC problem on trees with potentials. 9 Algorithm 2 Input: A weighted tree (T, ω, c), a rational number ξ and integers κ ≥ 1 and λ ≥ 0. A vertex u ∈ V (T ) with children (u1, . . . , ud). The numbers Γξ(u, k, l), for all 1 ≤ k ≤ κ and 0 ≤ l ≤ λ. The numbers µξ(ui, k, l) for all 1 ≤ i ≤ d, 1 ≤ k ≤ κ and 0 ≤ l ≤ λ. Output: The numbers µξ(u, k, l) for all 1 ≤ k ≤ κ and 0 ≤ l ≤ λ. 1: Let eu be the parent edge of u and u1, . . . , ud be the children of u. 2: for l = 0 : λ do 3: for k = 1 : κ do 4: 5: 6: 7: µξ(u, k, l) := 0; if Γξ(u, k, l) ≤ ξω(Tu) − c(eu) then end if µξ(u, k, l) := 1; end for 8: 9: end for 10: Define U (1, k, l) := µξ(u1, k, l), for every 0 ≤ k ≤ κ, 0 ≤ l ≤ λ; 11: for i = 2 : d do 12: for l = 0 : λ do 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: for k = 0 : κ do if µξ(u, k, l) = 0 then U (i, k, l) := 0; for l′ = 0 : l − 1 do for k′ = 0 : k do if U (i − 1, k′, l′) = µξ(ui, k − k′, l − 1 − l′) = 1 then U (i, k, l) := 1 and go to Line 22; end if end for end for end if end for end for 25: 26: end for 27: For every 0 ≤ k ≤ κ and 0 ≤ l ≤ λ, if U (d, k, l) = 1, then set µξ(u, k, l) := 1. 28: return µξ(u, k, l), for all 0 ≤ l ≤ λ; 2. Solving CMSC problem on forests. 3. Solving the following semi-supervised problem: Given a weighted graph G = (V, E, ω, c) (not necessarily a forest), two disjoint subsets S1, S2 ⊆ V , rational number ξ and integers κ, λ, such that the induced subgraph of G on V (G) \ S1 is a forest. Does there exist a connected subpartition A ∈ Dκ(V ) such that φG(A) ≤ ξ, R(A, G) ≤ λ, S1 ⊆ R(A, G) and S2 ∩ R(A, G) = ∅? In the following, we elaborate on the modifications that should be made to tackle the above settings. 1. In the setting of trees with potentials, each vertex v ∈ V (T ) is endowed with a potential weight, say p(v), which is a nonnegative number and the goal is to determine whether there exists a connected k-subpartition A = {Ai}k 1≤i≤k(cid:26)φT (Ai) = 1 ∈ Dk(V ) such that (cid:27) ≤ ξ c(∂Ai) + p(Ai) φT (A) = max ω(Ai) 10 Algorithm 3 Input: A weighted tree (T, ω, c), a rational number ξ and integers κ ≥ 1 and λ ≥ 0. Output: Decide if there exists A ∈ Ck(T ) where φT (A) ≤ ξ and R(A, T ) ≤ λ? 1: Root T with an arbitrary node r; 2: Order all nodes in BFS order with respect to r, as v1, ..., vn = r; 3: Set i := 1; 4: while i ≤ n do Let u := vi and eu be the parent edge of u and u1, . . . , ud be the children of u. Initialize µξ(u, k, l) := 0, ∀ 0 ≤ k ≤ κ, 0 ≤ l ≤ λ; Initialize Γξ(u, k, l) := +∞, ∀ 1 ≤ k ≤ κ, 0 ≤ l ≤ λ; if d = 0 then Set µξ(u, 1, l) := 1,∀ 0 ≤ l ≤ λ. Set µξ(u, 0, l) := 1,∀ 1 ≤ l ≤ λ. if c(eu) ≤ ξω(u) then end if Set Γξ(u, 1, l) := 0, ∀ 0 ≤ l ≤ λ; Using Algorithm 1, find the value of Γξ(u, k, l), for all 0 ≤ l ≤ λ and 1 ≤ k ≤ κ; Using Algorithm 2, find the value of µξ(u, k, l), for all 0 ≤ l ≤ λ and 0 ≤ k ≤ κ; else 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: end if i ← i + 1; 18: 19: end while 20: If µξ(u, κ, λ) = 1, then return Yes. Otherwise, return No. and R(A, T ) ≤ λ. We can extend our method to solve this problem using Algorithm 3. First, for each edge e ∈ E(T ), amend the definition of εξ(e) in (2) as follows εξ(e) := ξ ω(Te) + c(e) − p(Te). Also, define the functions µξ and Γξ analogously. Next, with a similar argument as in Lemma 2, one may prove that µξ(u, k, l) = 1 if and only if either Γξ(u, k, l) ≤ ξ ω(Tu) − c(eu)−p(Tu), or U (d, k, l) = 1. Moreover, Lemma 3 is still valid. So, we should just change Line 1 in Algorithm 1 and Line 5 in Algorithm 2, accordingly and then Algorithm 3 works for the new setting. 2. Suppose that the forest F consists of c disjoint trees T1, . . . , Tc rooted at r1, . . . , rc respec- tively. Also, let ξ, κ, λ be fixed. First, using Algorithm 3, compute the value of µξ(ri, k, l), for every integers 0 ≤ l ≤ λ, 0 ≤ k ≤ κ and 1 ≤ i ≤ c. Also, define Zξ(1, k, l) = µξ(r1, k, l). The following recursion helps us to solve the problem on F . For every 2 ≤ i ≤ c, define 1 if there exists 0 ≤ k′ ≤ k and 0 ≤ l′ ≤ l, s.t. Z(i − 1, k′, l′) = µξ(ri, k − k′, l − l′) = 1, 0 o.w. Z(i, k, l) :=  Then, the solution to CMSC problem is yes if and only if Zξ(c, κ, λ) = 1. Furhermore, One may easily extend this recursion to solve the corresponding problem on forests with potentials. 11 3. In this setting some vertices should be or should not be in the residue set. The problem can be solved in the following steps: - First, for each vertex v ∈ V (G), define a potential as follows p(v) := Xe∈E({v},S1) c(e). - Now, let F be a forest obtained from G by deleting all vertices in S1. Also, let λ′ := λ − S1. - If S2 is empty, then the solution can be obtained by performing the method given in 2 on the forest F with the potential weight p and the numbers ξ, κ, λ′. If S2 is non-empty, we have to make the following additional modifications to handle the problem. Suppose that T is a tree and S ⊆ V (T ) is a subset of vertices. Also, numbers ξ, κ, λ are given. We are looking for a connected subpartition A ∈ Dκ(V ) such that φT (A) ≤ ξ, R(A, T ) ≤ λ and S ∩ R(A, T ) = ∅. Note that Lemma 3 is still valid in this setting. However, in the computation of µξ(u, k, l), for each u ∈ V (T ), in Lemma 2, if u ∈ S, then u is not allowed to be in the residue set. So, the value of µξ(u, k, l) is equal to 1 if and only if Γξ(u, k, l) ≤ ξ ω(Tu) − c(eu). Thus, with a similar proof as in Lemma 2, we can prove that µξ(u, k, l) =  1 if u ∈ S and Γξ(u, k, l) ≤ ξ ω(Tu) − c(eu), 1 if u 6∈ S and either Γξ(u, k, l) ≤ ξω(Tu) − c(eu) or U (d, k, l) = 1, 0 o.w. Then, Algorithm 2 can be modified accordingly to compute the value of µξ(u, k, l). 5 Concluding remarks and future work In this paper, a multi-way sparsest cut problem has been investigated for weighted trees and it was shown that although the problem is N P−complete for trees, it becomes tractable when the search space is confined to connected subdomains. One of the strengths of the method is that it has a control on the number of outliers and can manage semi-supervised settings when some data points are forced or forbidden to be outlier. Besides the theoretical importance of the sparsest cut problem, when our method is applied to the minimum spanning tree, it can steer several applications in both unsupervised and semi-supervised clustering. One may also consider an analogous problem when we are seeking for a subpartition minimizing "the average" (instead of the maximum) of the edge expansions of the parts (e.g. as in [21]). This objective function is more sensitive and exquisite and are more likely to produce high-quality clustering results. Nevertheless, the problem unfortunately turns out to be N P−complete on trees even when the search space is restricted to connected subpartitions (or partitions) [9]. Finding a good approximation algorithm for this problem is an interesting and challenging task that can be the purpose of future work in this line of research. Acknowledgment. We would like to express our sincere thanks to Amir Daneshgar whose valuable comments were crucial in preparing and improving the present article. 12 References [1] N. Alon, Eigenvalues and expanders, Combinatorica 6 (1986), no. 2, 83–96, Theory of computing (Singer Island, Fla., 1984). MR 875835 [2] N. Alon and V. D. Milman, λ1, isoperimetric inequalities for graphs, and superconcentrators, J. Combin. Theory Ser. B 38 (1985), no. 1, 73–88. MR 782626 [3] Sanjeev Arora, Satish Rao, and Umesh Vazirani, Expander flows, geometric embeddings and graph partitioning, J. ACM 56 (2009), no. 2, Art. 5, 37. MR 2535878 [4] James C. Bezdek, Pattern recognition with fuzzy objective function algorithms, Plenum Press, New York-London, 1981, With a foreword by L. A. Zadeh, Advanced Applications in Pattern Recognition. MR 631231 [5] Peter Buser, Geometry and spectra of compact Riemann surfaces, Progress in Mathematics, vol. 106, Birkhauser Boston, Inc., Boston, MA, 1992. MR 1183224 [6] Isaac Chavel, Eigenvalues in Riemannian geometry, Pure and Applied Mathematics, vol. 115, Academic Press, Inc., Orlando, FL, 1984, Including a chapter by Burton Randol, With an appendix by Jozef Dodziuk. MR 768584 [7] Fan R. K. Chung, Spectral graph theory, CBMS Regional Conference Series in Mathematics, vol. 92, Published for the Conference Board of the Mathematical Sciences, Washington, DC; by the American Mathematical Society, Providence, RI, 1997. MR 1421568 [8] Amir Daneshgar, Hossein Hajiabolhassan, and Ramin Javadi, On the isoperimetric spectrum of graphs and its approximations, J. Combin. Theory Ser. B 100 (2010), no. 4, 390–412. MR 2644242 [9] Amir Daneshgar and Ramin Javadi, On the complexity of isoperimetric problems on trees, Discrete Applied Mathematics 160 (2012), no. 1, 116–131. [10] Amir Daneshgar, Ramin Javadi, and Laurent Miclo, On nodal domains and higher-order Cheeger inequalities of finite reversible Markov processes, Stochastic Process. Appl. 122 (2012), no. 4, 1748–1776. MR 2914771 [11] Amir Daneshgar, Ramin Javadi, and SB Shariat Razavi, Clustering and outlier detection using isoperimetric number of trees, Pattern Recognition 46 (2013), no. 12, 3371–3382. [12] Rajesh N Dav´e and Raghuram Krishnapuram, Robust clustering methods: a unified view, IEEE Transactions on fuzzy systems 5 (1997), no. 2, 270–293. [13] Guojun Gan, Chaoqun Ma, and Jianhong Wu, Data clustering, ASA-SIAM Series on Statis- tics and Applied Probability, vol. 20, Society for Industrial and Applied Mathematics (SIAM), Philadelphia, PA; American Statistical Association, Alexandria, VA, 2007, Theory, algorithms, and applications. MR 2331172 [14] Shlomo Hoory, Nathan Linial, and Avi Wigderson, Expander graphs and their applications, Bull. Amer. Math. Soc. (N.S.) 43 (2006), no. 4, 439–561. MR 2247919 [15] Mark Jerrum and Alistair Sinclair, The markov chain monte carlo method: an approach to approximate counting and integration, Approximation algorithms for NP-hard problems (1996), 482–520. 13 [16] James R Lee, Shayan Oveis Gharan, and Luca Trevisan, Multiway spectral partitioning and higher-order cheeger inequalities, Journal of the ACM (JACM) 61 (2014), no. 6, 37. [17] Anand Louis and Konstantin Makarychev, Approximation algorithm for sparsest k- partitioning, Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, ACM, New York, 2014, pp. 1244–1255. MR 3376452 [18] Bojan Mohar, Isoperimetric numbers of graphs, J. Combin. Theory Ser. B 47 (1989), no. 3, 274–291. MR 1026065 [19] Andrew Y Ng, Michael I Jordan, Yair Weiss, et al., On spectral clustering: Analysis and an algorithm, Advances in neural information processing systems 2 (2002), 849–856. [20] Dan Pelleg, Andrew W Moore, et al., X-means: Extending k-means with efficient estimation of the number of clusters., ICML, vol. 1, 2000, pp. 727–734. [21] Jianbo Shi and Jitendra Malik, Normalized cuts and image segmentation, IEEE Transac- tions on pattern analysis and machine intelligence 22 (2000), no. 8, 888–905. [22] Vijay V. Vazirani, Approximation algorithms, Springer-Verlag, Berlin, 2001. MR 1851303 [23] Shing Tung Yau, Isoperimetric constants and the first eigenvalue of a compact Riemannian manifold, Ann. Sci. ´Ecole Norm. Sup. (4) 8 (1975), no. 4, 487–507. MR 0397619 14
1904.09690
2
1904
2019-05-23T20:43:00
Dynamic Time Warping in Strongly Subquadratic Time: Algorithms for the Low-Distance Regime and Approximate Evaluation
[ "cs.DS" ]
Dynamic time warping distance (DTW) is a widely used distance measure between time series. The best known algorithms for computing DTW run in near quadratic time, and conditional lower bounds prohibit the existence of significantly faster algorithms. The lower bounds do not prevent a faster algorithm for the special case in which the DTW is small, however. For an arbitrary metric space $\Sigma$ with distances normalized so that the smallest non-zero distance is one, we present an algorithm which computes $\operatorname{dtw}(x, y)$ for two strings $x$ and $y$ over $\Sigma$ in time $O(n \cdot \operatorname{dtw}(x, y))$. We also present an approximation algorithm which computes $\operatorname{dtw}(x, y)$ within a factor of $O(n^\epsilon)$ in time $\tilde{O}(n^{2 - \epsilon})$ for $0 < \epsilon < 1$. The algorithm allows for the strings $x$ and $y$ to be taken over an arbitrary well-separated tree metric with logarithmic depth and at most exponential aspect ratio. Extending our techniques further, we also obtain the first approximation algorithm for edit distance to work with characters taken from an arbitrary metric space, providing an $n^\epsilon$-approximation in time $\tilde{O}(n^{2 - \epsilon})$, with high probability. Additionally, we present a simple reduction from computing edit distance to computing DTW. Applying our reduction to a conditional lower bound of Bringmann and K\"unnemann pertaining to edit distance over $\{0, 1\}$, we obtain a conditional lower bound for computing DTW over a three letter alphabet (with distances of zero and one). This improves on a previous result of Abboud, Backurs, and Williams. With a similar approach, we prove a reduction from computing edit distance to computing longest LCS length. This means that one can recover conditional lower bounds for LCS directly from those for edit distance, which was not previously thought to be the case.
cs.DS
cs
Dynamic Time Warping in Strongly Subquadratic Time: Algorithms for the Low-Distance Regime and Approximate Evaluation William Kuszmaul Massachusetts Institute of Technology, Cambridge, USA. [email protected]. May 27, 2019 Abstract Dynamic time warping distance (DTW) is a widely used distance measure between time se- ries, with applications in areas such as speech recognition and bioinformatics. The best known algorithms for computing DTW run in near quadratic time, and conditional lower bounds pro- hibit the existence of significantly faster algorithms. The lower bounds do not prevent a faster algorithm for the important special case in which the DTW is small, however. For an arbitrary metric space Σ with distances normalized so that the smallest non-zero distance is one, we present an algorithm which computes dtw(x, y) for two strings x and y over Σ in time O(n · dtw(x, y)). When dtw(x, y) is small, this represents a significant speedup over the standard quadratic-time algorithm. Using our low-distance regime algorithm as a building block, we also present an approxima- tion algorithm which computes dtw(x, y) within a factor of O(nǫ) in time O(n2−ǫ) for 0 < ǫ < 1. The algorithm allows for the strings x and y to be taken over an arbitrary well-separated tree metric with logarithmic depth and at most exponential aspect ratio. Notably, any polynomial- size metric space can be efficiently embedded into such a tree metric with logarithmic expected distortion. Extending our techniques further, we also obtain the first approximation algorithm for edit distance to work with characters taken from an arbitrary metric space, providing an nǫ-approximation in time O(n2−ǫ), with high probability. Finally, we turn our attention to the relationship between edit distance and dynamic time warping distance. We prove a reduction from computing edit distance over an arbitrary metric space to computing DTW over the same metric space, except with an added null character (whose distance to a letter l is defined to be the edit-distance insertion cost of l). Applying our reduction to a conditional lower bound of Bringmann and Kunnemann pertaining to edit distance over {0, 1}, we obtain a conditional lower bound for computing DTW over a three letter alphabet (with distances of zero and one). This improves on a previous result of Abboud, Backurs, and Williams, who gave a conditional lower bound for DTW over an alphabet of size five. With a similar approach, we also prove a reduction from computing edit distance (over generalized Hamming Space) to computing longest-common-subsequence length (LCS) over an alphabet with an added null character. Surprisingly, this means that one can recover conditional lower bounds for LCS directly from those for edit distance, which was not previously thought to be the case. 1 1 Introduction Dynamic Time Warping distance (DTW) is a widely used distance measure between time series. DTW is particularly flexible in dealing with temporal sequences that vary in speed. To measure the distance between two sequences, portions of each sequence are allowed to be warped (meaning that a character may be replaced with multiple consecutive copies of itself), and then the warped sequences are compared by summing the distances between corresponding pairs of characters. DTW's many applications include phone authentication [20], signature verification [35], speech recognition [34], bioinformatics [1], cardiac medicine [16], and song identification [45]. The textbook dynamic-programming algorithm for DTW runs in time O(n2), which can be prohibitively slow for large inputs. Moreover, conditional lower bounds [14, 3] prohibit the existence of a strongly subquadratic-time algorithm1, unless the Strong Exponential Time Hypothesis is false. The difficulty of computing DTW directly has motivated the development of fast heuristics [39, 29, 30, 28, 12, 38] which typically lack provable guarantees. On the theoretical side, researchers have considered DTW in the contexts of locality sensitive hashing [21] and nearest neighbor search [22], but very little additional progress has been made on the general problem in which one is given two strings x and y with characters from a metric space Σ, and one wishes to compute (or approximate) dtw(x, y). To see the spectrum of results one might aim for, it is helpful to consider edit distance, another string-similarity measure, defined to be the minimum number of insertions, deletions, and substitu- tions needed to get between two strings. Like DTW, edit distance can be computed in time O(n2) using dynamic programming [43, 37, 42], and conditional lower bounds suggest that no algorithm can do significantly better [7, 14]. This has led to researchers focusing on specialized versions of the problem, especially in two important directions: • Low-Distance Regime Algorithms: In the special case where the edit distance between two strings is small (less than √n), the algorithm of Landau, Myers and Schmidt [33] can be used to compute the exact distance in time O(n). In general, the algorithm runs in time O(n + ed(x, y)2). Significant effort has also been made to design variants of the algorithm which exhibit small constant overhead in practice [18]. • Approximation Algorithms: Andoni, Krauthgamer and Onak introduced an algorithm estimating edit distance within a factor of (log n)O(1/ε) in time O(n1+ε) [5], culminating a long line of research on approximation algorithms that run in close to linear time [6, 11, 9, 19]. Recently, Chakraborty et al. gave the first strongly subquadratic algorithm to achieve a constant approximation, running time O(n12/7) [17]. This paper presents the first theoretical results in these directions for DTW. A Low-Distance Regime Algorithm for DTW (Section 3) We present the first algorithm for computing DTW in the low-distance regime. Our algorithm computes dtw(x, y) in time O(n · dtw(x, y)) for strings x and y with characters taken from an arbitrary metric space in which the minimum non-zero distance is one. The key step in our algorithm is the design of a new dynamic- programming algorithm for DTW, which lends itself especially well to the low-distance setting. 1An algorithm is said to run in strongly subquadratic time if it runs in time O(n2−ǫ) for some constant ǫ > 0. Although strongly subquadratic time algorithms are prohibited by conditional lower bounds, runtime improvements by subpolynomial factors are not. Such improvements have been achieved [26]. 2 Our dynamic program relies on a recursive structure in which the two strings x and y are treated asymmetrically within each subproblem: One of the strings is considered as a sequence of letters, while the other string is considered as a sequence of runs (of equal letters). The subproblems build on one-another in a way so that at appropriate points in the recursion, we toggle the role that the two strings play. The asymmetric treatment of the strings limits the number of subproblems that can have return-values less than any given threshold K to O(nK), allowing for a fast algorithm in the low-distance setting. We remark that the requirement of having the smallest distance between distinct characters be 1 is necessary for the low-distance regime algorithm to be feasible, since otherwise distances can simply be scaled down to make every DTW instance be low-distance. Approximating DTW Over Well Separated Tree Metrics (Section 4) We design the first approximation algorithm for DTW to run in strongly subquadratic time. Our algorithm computes dtw(x, y) within an nǫ-approximation in time O(n2−ǫ). The algorithm allows for the strings x and y have characters taken from an arbitrary well-separated tree metric of logarithmic depth and at most exponential aspect ratio.2 These metric spaces are universal in the sense that any finite metric space M of polynomial size can be efficiently embedded into a well-separated tree metric with expected distortion O(log M) and logarithmic depth [23, 8]. An important consequence of our approximation algorithm is for the special case of DTW over the reals. Exploiting a folklore embedding from R to a well-separated tree metric metric, we are able to obtain with high probability an O(nǫ)-approximation for dtw(x, y) in time O(n2−ǫ), for any strings x and y of length at most n over a subset of the reals with a polynomial aspect ratio. In the special case of DTW over the reals, previous work has been done to find approximation algorithms under certain geometric assumptions about the inputs x and y [4, 44]. To the best of our knowledge, our approximation algorithm is the first to not rely on any such assumptions. It is interesting to note that our results on low-distance regime and approximation algorithms for DTW have bounds very similar to the earliest results for edit distance in the same directions. Indeed, the first algorithm to compute edit distance in the low-distance regime [24] exploited properties of a (now standard) dynamic-programming algorithm in order to compute ed(x, y) in time O(n · ed(x, y)). This implicitly resulted in the first approximation algorithm for edit distance, allowing one to compute an O(nǫ)-approximation in time O(n2−ǫ). Until the work of [6] and [5], which culminated in an algorithm with a polylogarithmic approximation ratio, the best known approximation ratio for edit distance remained polynomial for roughly twenty years [33, 9, 11]. The O(n2−ǫ)-time O(nǫ)-approximation tradeoff is also the current state-of-the-art for another related distance measurement known as Fr´echet distance [15], and is achieved using an algorithm that differs significantly from its edit-distance and DTW counterparts. Reduction from Edit Distance to DTW (Section 5) We show that the similarity between our results for DTW and the earliest such results for edit distance is not coincidental. In partic- ular, we prove a simple reduction from computing edit distance over an arbitrary metric space to computing DTW over the same metric space (with an added null character). Consequently, any algorithmic result for computing DTW in the low-distance regime or approximating DTW immedi- ately implies the analogous result for edit distance. The opposite direction is true for lower bounds. For example, the conditional lower bound of Bringmann and Kunnemann [14], which applies to edit 2The aspect ratio of a metric space is the ratio between the largest and smallest non-zero distances in the space. 3 distance over the alphabet {0, 1}, now immediately implies a conditional lower bound for DTW over an alphabet of size three (in which characters are compared with distances zero and one). This resolves a direction of work posed by Abboud, Backurs, and Williams [3], who gave a conditional lower bound for DTW over an alphabet of size five, and noted that if one could prove the same lower bound for an alphabet of size three, then the runtime complexity of DTW over generalized Hamming space would be settled (modulo the Strong Exponential Time Hypothesis). Indeed, it is known that over an alphabet of size two, DTW can be computed in strongly subquadratic time [3]. Using a similar approach we also prove a simple reduction from computing edit distance (over generalized Hamming space) to computing the longest-common-subsequence length (LCS) between two strings. Thus conditional lower bounds for computing edit distance directly imply conditional lower bounds for computing LCS (over an alphabet with one additional character). This was not previously though to be the case. Indeed, the first known conditional lower bounds for LCS came after those for edit distance [2, 7], and it was noted by Abboud et al. [2] that "A simple observation is that the computation of the LCS is equivalent to the computation of the Edit-Distance when only deletions and insertions are allowed, but no substitutions. Thus, intuitively, LCS seems like an easier version of Edit Distance, since a solution has fewer degrees of freedom, and the lower bound for Edit-Distance does not immediately imply any hardness for LCS." Our reduction violates this intuition by showing that edit distance without substitutions can be used to efficiently simulate edit distance without substitutions. In addition to presenting a reduction from edit distance to LCS, we show that no similar reduction can exist in the other direction. We remark that our reduction from edit distance to LCS was also previously briefly described in Chapter 6.1 of [40], a fact of which we only became aware after the completion of this manuscript. Approximating Edit Distance Over an Arbitrary Metric (Section 6) The aforementioned results for approximating edit distance [24, 9, 11, 33, 6, 5, 17, 32] consider only the case in which insertion, deletion, and substitution costs are all constant. To the best of our knowledge, no approximation algorithm is known for the more general case in which characters are taken from an arbitrary metric space and edit costs are assigned based on metric distances between characters. This variant of edit distance is sometimes referred to as general edit distance [36]. The study of general edit distance dates back to the first papers on edit distance [43, 41], and allowing for nonuniform costs is important in many applications, including in computational biology [27]. We present an approximation algorithm for edit distance over an an arbitrary metric. Our algorithm runs in time O(n2−ǫ) and computes an O(nǫ)-approximation for ed(x, y) with high prob- ability. Note that for the case where characters are taken from a well-separated tree metric with logarithmic depth and at most exponential aspect ratio, the result already follows from our approx- imation algorithm for DTW, and our reduction from edit distance to DTW. The approach taken in Section 6 is particularly interesting in that it places no restrictions on the underlying metric space. Both our approximation algorithm for DTW and our approximation algorithm for edit distance exhibit relatively weak runtime/approximation tradeoffs. To the best of our knowledge, however, they are the first such algorithms to run in strongly subquadratic time. 2 Preliminaries In this section, we present preliminary definitions and background on dynamic time warping dis- tance (DTW) and edit distance. 4 Dynamic Time Warping Distance For a metric space Σ, the dynamic time warping distance (DTW) between two strings x, y ∈ Σn is a natural measure of similarity between the strings. Before fully defining DTW, we first introduce the notion of an expansion of a string. Definition 2.1. The runs of a string x ∈ Σn are the maximal subsequences of consecutive letters with the same value. One can extend a run by replacing it with a longer run of the same letter. An expansion of the string x is any string which can be obtained from x by extending runs. As an example, consider x = aaaccbbd. Then the runs of x are aaa, cc, bb, and d. The string x = aaacccccbbdd is an expansion of x and extends the runs containing c and d. Using the terminology of expansions, we now define DTW. Definition 2.2. Consider strings x and y of length n over a metric (Σ, d). A correspondence (x, y) between x and y is a pair of equal-length expansions x of x and y of y. The cost of a correspondence is given by Pi d(xi, yi). dence between x and y. The dynamic time warping distance dtw(x, y) is defined to be the minimum cost of a correspon- When referring to a run r in one of x or y, and when talking about a correspondence (x, y), we will often use r to implicitly refer to the extended run corresponding with r in the correspondence. Whether we are referring to the original run or the extended version of the run should be clear from context. Note that any minimum-length optimal correspondence between strings x, y ∈ Σn will be of length at most 2n. This is because if a run r1 in x overlaps a run r2 in y in the correspondence, then we may assume without loss of generality that at most one of the two runs is extended by the correspondence. (Otherwise, we could un-extend each run by one and arrive at a shorter correspondence with no added cost.) Edit Distance Over an Arbitrary Metric The simple edit distance between two strings x and y is the minimum number of insertions, deletions, and substitutions needed to transform x into y. In this paper we will mostly focus on a more general variant of edit distance, in which characters are taken from an arbitrary metric: Definition 2.3. Let x and y be strings over an alphabet Σ, where (Σ ∪ {∅}, d) is a metric space. We say that the magnitude l of a letter l ∈ Σ is d(∅, l). We define the edit distance between x and y to be the minimum cost of a sequence of edits from x to y, where the insertion or deletion of a letter l costs d(∅, l), and the substitution of a letter l to a letter l′ costs d(l, l′). 3 Computing DTW in the Low-Distance Regime In this section, we present a low-distance regime algorithm for DTW (with characters from an arbitrary metric in which all non-zero distances are at least one). Given that dtw(x, y) is bounded above by a parameter K, our algorithm can compute dtw(x, y) in time O(nK). Moreover, if dtw(x, y) > K, then the algorithm will conclude as much. Consequently, by doubling our guess for K repeatedly, one can compute dtw(x, y) in time O(n · dtw(x, y)). Consider x and y of length n with characters taken from a metric space Σ in which all non-zero distances are at least one. In the textbook dynamic program for DTW [31], each pair of indices 5 i, j ∈ [n] represents a subproblem T (i, j) whose value is dtw(x[1 : i], y[1 : j]). Since T (i, j) can be determined using T (i − 1, j), T (i, j − 1), T (i − 1, j − 1), and knowledge of xi and yj, this leads to an O(n2) algorithm for DTW. A common heuristic in practice is to construct only a small band around the main diagonal of the dynamic programming grid; by computing only entries T (i, j) with i − j ≤ 2K, and treating other subproblems as having infinite return values, one can obtain a correct computation for DTW as long as there is an optimal correspondence which matches only letters which are within K of each other in position. This heuristic is known as the Sakoe-Chiba Band [39] and is employed, for example, in the commonly used library of Giorgino [25]. The Sakoe-Chiba Band heuristic can perform badly even when dtw(x, y) is very small, however. Consider x = abbb··· b and y = aaa··· ab. Although dtw(x, y) = 0, if we restrict ourselves to match- ing letters within K positions of each other for some small K, then the resulting correspondence will cost Ω(n). In order to obtain an algorithm which performs well in the low-distance regime, we introduce a new dynamic program for DTW. The new dynamic program treats x and y asymmetrically within each subproblem. Loosely speaking, for indices i and j, there are two subproblems SP(x, y, i, j) and SP(y, x, i, j). The first of these subproblems evaluates to the DTW between the first i runs of x and the first j letters of y, with the added condition that the final run of y[1 : j] is not extended. The second of the subproblems is analogously defined as the DTW between the first i runs of y and the first j letters of x with the added condition that the final run of x[1 : j] is not extended. The recursion connecting the new subproblems is somewhat more intricate than for the textbook dynamic program. By matching the i-th run with the j-th letter, however, we limit the number of subproblems which can evaluate to less than K. In particular, if the j-th letter of y is in y's t-th run, then any correspondence which matches the i-th run of x to the j-th letter of y must cost at least Ω(i − t). (This is formally shown in Appendix A.) Thus for a given j, there are only O(K) options for i such that SP(x, y, i, j) can possibly be at most K, and similarly for SP(y, x, i, j). Since we are interested in the case of dtw(x, y) ≤ K, we can restrict ourselves to the O(nK) subproblems which have the potential to evaluate to at most O(K). Notice that, in fact, our algorithm will work even when dtw(x, y) > K as long as there is an optimal correspondence between x and y which only matches letters from x from the rx-th run with letters from y from the ry-th run if rx − ry ≤ O(K). Formally we define our recursive problems in a manner slightly different from that described above. Let x and y be strings of length at most n and let K be a parameter which we assume is greater than dtw(x, y). Our subproblems will be the form SP(x, y, rx, ry, oy), which is defined as follows. Let x′ consist of the first rx runs of x and y′ consist of the first ry runs of y until the oy-th letter in the ry-th run. Then SP(x, y, rx, ry, oy) is the value of the optimal correspondence between x′ and y′ such that the ry-th run in y′ is not extended.3 If no such correspondence exists (which can only happen if ry ≤ 1 or rx = 0), then the value of the subproblem is ∞. Note that we allow rx, ry, oy to be zero, and if ry is zero, then oy must be zero as well. We also consider the symmetrically defined subproblems of the form SP(y, x, ry, rx, ox). We will focus on the subproblems of the first types, implicitly treating subproblems of the second type symmetrically. Example 3.1. Suppose characters are taken from generalized Hamming space, with distances of 0 and 1. The subproblem SP(ef abbccccd, f f aabcccddd, 5, 4, 2) takes the value of the optimal corre- spondence between ef abbcccc and f f aabcc such that the final cc run in the latter is not extended. The subproblem's value turns out to be 3, due to the correspondence: 3If oy = 0, then the ry-th run in y ′ is empty and thus trivially cannot be extended. 6 e f f f a a c a b b c a b b b b c c c c . The next lemma presents the key recursive relationship between subproblems. The lemma focuses on the case where rx, ry, oy ≥ 1. Lemma 3.2. Suppose that rx and ry are both between 1 and the number of runs in x and y respectively; and that oy is between 1 and the length of the ry-th run in y. Let lx be the length of the rx-th run in x and ly be the length of the ry-th run in y. Let d be the distance between the letter populating the rx-th run in x and the letter populating the ry-th run in y. Then SP(x, y, rx, ry, oy) is given by (min (SP(x, y, rx, ry, oy − 1) + d, SP(x, y, rx − 1, ry, oy − lx) + d · lx) min (SP(x, y, rx, ry, oy − 1) + d, SP(y, x, ry − 1, rx, lx − oy) + d · oy) if lx ≤ oy if lx > oy. Proof. Consider a minimum-cost correspondence A between the first rx runs of x and the portion of y up until the oy-th letter in the ry-th run, such that the ry-th run in y is not extended. rx-th run in A is not extended, then we consider two cases. If the rx-th run in A is extended, then the cost of A will be SP(x, y, rx, ry, oy − 1) + d. If the In the first case, lx ≤ oy. In this case, the entirety of the rx-th run of x is engulfed by the ry-th run of y in the correspondence A. Since the rx-th run is not extended, the cost of the overlap is lx · d. Thus the cost of A must be SP(x, y, rx − 1, ry, oy − lx) + d · lx. expression, regardless of whether the rx-th run in x is extended in A. Moreover, since A is minimum-cost, as long as lx ≤ oy, the cost of A is at most the above In the second case, lx > oy. In this case, the first oy letters in the ry-th run of y all overlap the rx-th run of x in A. Since the ry-th run is not extended, the cost of the overlap is d· oy. Thus, since the rx-th run in x is also not extended in A, the cost of A must be SP(y, x, ry − 1, rx, lx− oy) + d· oy . Moreover, since A is minimal, as long as lx > oy, the cost of A is at most the above expression, regardless of whether the rx-th run in x is extended. The above lemma handles cases where rx, ry, oy > 0. In the case where rx > 0, ry > 0, and oy = 0, SP(x, y, rx, ry, oy) is just the dynamic time warping distance between the first rx runs of x and the first ry − 1 runs of y, given by min (SP(x, y, rx, ry − 1, t1), SP(y, x, ry − 1, rx, t2)) , where t1 is the length of the (ry − 1)-th run in y and t2 is the length of the rx-th run in x. The remaining cases are edge-cases with SP(x, y, rx, ry, oy) ∈ {0,∞}. (See Appendix A.) One can show that any correspondence A in which a letter from the rx-th run of x is matched with a letter from the ry-th run of y must contain must contain at least rx−ry−1 instances of unequal letters being matched; we prove this in Appendix A. It follows that if dtw(x, y) ≤ K, then we can limit ourselves to subproblems in which rx − ry ≤ O(K). For each of the n options of (ry, oy), there are only O(K) options of rx that must be considered. This limits the total number of subproblems to O(nK). The resulting dynamic program yields the following theorem: 2 Theorem 3.3. Let x and y be strings of length n taken from a metric space Σ with minimum non-zero distance at least one, and let K be parameter such that dtw(x, y) ≤ K. Then there exists a dynamic program for computing dtw(x, y) in time O(nK). Moreover, if dtw(x, y) > K, then the dynamic program will return a value greater than K. By repeatedly doubling one's guess for K until the computed value of dtw(x, y) evaluates to less than K, one can therefore compute dtw(x, y) in time O(n · dtw(x, y)). 7 4 Approximating DTW Over Well-Separated Tree Metrics In this section, we present an O(n2−ǫ)-time O(nǫ)-approximation algorithm for DTW over a well- separated tree metric with logarithmic depth. We begin by presenting a brief background on well-separated tree metrics. Definition 4.1. Consider a tree T whose vertices form an alphabet Σ, and whose edges have positive weights. T is said to be a well-separated tree metric if every root-to-leaf path consists of edges ordered by nonincreasing weight. The distance between two nodes u, v ∈ Σ is defined as the maximum weight of any edge in the shortest path from u to v. Well-separated tree metrics are universal in the sense that any metric Σ can be efficiently em- bedded (in time O(Σ2)) into a well-separated tree metric T with expected distortion O(log Σ) [23]. Moreover, the tree metric may be made to have logarithmic depth using Theorem 8 of [8]. For strings x, y ∈ Σn, let dtwT (x, y) denote the dynamic time warping distance after embed- ding Σ into T . Then the tree-metric embedding guarantees that dtw(x, y) ≤ dtwT (x, y) and that E[dtwT (x, y)] ≤ O(log n) · dtw(x, y). (The latter fact is slightly nontrivial and is further explained in Appendix B.) It follows that any approximation algorithm for DTW over well-separated tree metrics will immediately yield an approximation algorithm over an arbitrary polynomial-size metric Σ, with two caveats: the new algorithm will have its multiplicative error increased by O(log n); and O(log n) instances of Σ embedded into a well-separated tree metric must be precomputed for use by the algorithm (requiring, in general, O(Σ2 log n) preprocessing time). In particular, given O(log n) tree embeddings of Σ, T1, . . . , TO(log n), with high probability mini (dtwTi(x, y)) will be within a logarithmic factor of dtw(x, y). The remainder of the section will be devoted to designing an approximation algorithm for DTW over a well-separated tree metric. We will prove the following theorem: Theorem 4.2. Consider 0 < ǫ < 1. Suppose that Σ is a well-separated tree metric of polynomial size and at most logarithmic depth. Moreover, suppose that the aspect ratio of Σ is at most expo- nential in n (i.e., the ratio between the largest distance and the smallest non-zero distance). Then in time O(n2−ǫ) we can obtain an O(nǫ)-approximation for dtw(x, y) for any x, y ∈ Σn. An important consequence of the theorem occurs for DTW over the reals. When Σ is an O(n)-point subset of the reals with a polynomial aspect ratio, there exists an O(n log n)-time embedding with O(log n) expected distortion from Σ to a well-separated tree metric of size O(n) with logarithmic depth. (See Appendix B). This gives the following corollary: Corollary 4.3. Consider 0 < ǫ < 1. Suppose that Σ = [0, nc] ∩ Z for some constant c. Then in time O(n2−ǫ) we can obtain an O(nǫ)-approximation for dtw(x, y) with high probability for any x, y ∈ Σn. In proving Theorem 4.2, our approximation algorithm will take advantage of what we refer to as the r-simplification of a string over a well-separated tree metric. Definition 4.4. Let T be a well-separated tree metric whose nodes form an alphabet Σ. For a string x ∈ Σn, and for any r ≥ 1, the r-simplification sr(x) is constructed by replacing each letter l ∈ x with its highest ancestor l′ in T that can be reached from l using only edges of weight at most r/4. 8 Our approximation algorithm will apply the low-distance regime algorithm from the previous section to sr(x) and sr(y) for various r in order to extract information about dtw(x, y). Notice that using our low-distance regime algorithm for DTW, we get the following useful lemma for free: Lemma 4.5. Consider 0 < ǫ < 1. Suppose that for all pairs l1, l2 of distinct letters in Σ, d(l1, l2) ≥ γ. Then for x, y ∈ Σn there is an O(n2−ǫ) time algorithm which either computes dtw(x, y) exactly, or concludes that dtw(x, y) > γn1−ǫ. The next lemma states three important properties of r-simplifications. We remark that the same lemma appears in our concurrent work on the communication complexity of DTW, in which we use the lemma in designing an efficient one-way communication protocol [13]. Lemma 4.6. Let T be a well-separated tree metric with distance function d and whose nodes form the alphabet Σ. Consider strings x and y in Σn. Then the following three properties of sr(x) and sr(y) hold: • For every letter l1 ∈ sr(x) and every letter l2 ∈ sr(y), if l1 6= l2, then d(l1, l2) > r/4. • For all α, if dtw(x, y) ≤ nr/α then dtw(sr(x), sr(y)) ≤ nr/α. • If dtw(x, y) > nr, then dtw(sr(x), sr(y)) > nr/2. The first and second parts of Lemma 4.6 are straightforward from the definitions of sr(x) and sr(y). The third part follows from the observation that a correspondence C between x and y can cost at most C· r 4 more than the corresponding correspondence between sr(x) and sr(y), where C denotes the length of the correspondence. Since there exists an optimal correspondence between sr(x) and sr(y) of length no more than 2n, it follows that dtw(x, y) ≤ dtw(sr(x), sr(y)) + nr/2, which implies the third part of the lemma. A full proof of Lemma 4.6 appears in Appendix B. Next we prove Theorem 4.2. Proof of Theorem 4.2. Without loss of generality, the minimum non-zero distance in Σ is 1 and the largest distance is some value m, which is at most exponential in n. We begin by defining the (r, nǫ)-DTW gap problem for r ≥ 1, in which for two strings x and y a return value of 0 indicates that dtw(x, y) < nr and a return value of 1 indicates that dtw(x, y) ≥ n1−ǫr. By Lemma 4.6, in order to solve the (r, nǫ)-DTW gap problem for x and y, it suffices to determine whether dtw(sr(x), sr(y)) ≤ n1−ǫr. Moreover, because the minimum distance between distinct letters in sr(x) and sr(y) is at least r/4, this can be done in time O(n2−ǫ log n) using Lemma 4.5.4 In order to obtain an nǫ-approximation for dtw(x, y), we begin by using Lemma 4.5 to either determine dtw(x, y) or to determine that dtw(x, y) ≥ n1−ǫ. For the rest of the proof, suppose we are in the latter case, meaning that we know dtw(x, y) ≥ n1−ǫ. We will now consider the (2i, nǫ/2)-DTW gap problem for i ∈ {0, 1, 2, . . . ,⌈log m⌉}. (Recall that m is the largest distance in Σ.) If the (20, nǫ/2)-DTW gap problem returned 0, then we would know that dtw(x, y) ≤ n, and thus we could return n1−ǫ as an nǫ-approximation for dtw(x, y). Therefore, we need only consider the case where the (20, nǫ/2)-DTW gap returns 1. Moreover we 4The logarithmic factor comes from the fact that evaluating distances between points may take logarithmic time in our well-separated tree metric. 9 may assume without computing it that (2⌈log m⌉, nǫ/2)-DTW gap returns 0 since trivially dtw(x, y) cannot exceed nm. Because (2i, nǫ/2)-DTW gap returns 1 for i = 0 and returns 0 for i = ⌈log m⌉, there must be some i such that (2i−1, nǫ/2)-DTW gap returns 1 and (2i, nǫ/2)-DTW gap returns 0. Moreover, we can find such an i by performing a binary search on i in the range R = {0, . . . ,⌈log m⌉}. We begin by computing (2i, nǫ/2)-DTW gap for i in the middle of the range R. If the result is a one, then we can recurse on the second half of the range; otherwise we recurse on the first half of the range. Continuing like this, we can find in time O(n2−ǫ log log m) = O(n2−ǫ) some value i for which (2i−1, nǫ/2)-DTW gap returns 1 and (2i, nǫ/2)-DTW gap returns 0. Given such an i, we know that dtw(x, y) ≥ 2i−1n nǫ/2 = 2in1−ǫ and that dtw(x, y) ≤ 2in. Thus we can return 2in1−ǫ as an nǫ approximation of dtw(x, y). 5 Reducing Edit Distance to DTW and LCS In this section we present a simple reduction from edit distance over an arbitrary metric to DTW over the same metric.At the end of the section, we prove as a corollary a conditional lower bound for DTW over three-letter Hamming space, prohibiting any algorithm from running in strongly subquadratic time. Surprisingly, the exact same reduction, although with a different analysis, can be used to reduce the computation of edit distance (over generalized Hamming space) to the computation of longest- common-subsequence length (LCS). Since computing LCS is equivalent to computing edit distance without substitutions, this reduction can be interpreted as proving that edit distance without substitutions can be used to efficiently simulate edit distance with substitutions, also known as simple edit distance. Recall that for a metric Σ∪{∅}, we define the edit distance between two strings x, y ∈ Σn such that the cost of a substitution from a letter l1 to l2 is d(l1, l2), and the cost of a deletion or insertion of a letter l is d(l,∅). Additionally, define the simple edit distance edS(x, y) to be the edit distance using only insertions and deletions. For a string x ∈ Σn, define the padded string p(x) of length 2n+1 to be the string ∅x1∅x2∅x3 ··· xn∅. In particular, for i ≤ 2n + 1, p(x)i = ∅ when i is odd, and p(x)i = xi/2 when i is even. The following theorem proves that dtw(p(x), p(y)) = ed(x, y). Theorem 5.1. Let Σ ∪ {∅} be a metric. Then for any x, y ∈ Σn, dtw(p(x), p(y)) = ed(x, y). Proof sketch. A key observation is that when constructing an optimal correspondence between p(x) and p(y), one may w.l.o.g. extend only runs consisting of ∅ characters. In particular, suppose that one extends a non-∅ character a in p(x) to match a non-∅ character b in p(y). Then the extended run of a's must not only overlap b, but also the ∅-character preceding b. The total cost of extending a to overlap b is therefore d(a,∅) + d(a, b), which by the triangle inequality is at least d(∅, b). Thus instead of extending the run containing a, one could have instead extend a run of ∅-characters to overlap b at the same cost. The fact that optimal correspondences arise by simply extending runs of ∅-characters can then be used to prove Theorem 5.1; in particular, given such a correspondence, one can obtain a sequence of edits from x to y by performing a substitution every time the correspondence matches two non-∅ characters and a insertion or deletion every time the correspondence matches a non-∅ character and a ∅-character. 10 Theorem 5.2 proves an analogous reduction from edit distance to LCS. Theorem 5.2. Let Σ be a generalized Hamming metric. Then for any x, y ∈ Σn, edS(p(x), p(y)) = 2 ed(x, y). Proof sketch. Each edit in x can be simulated in s(x) using exactly two insertions/deletions. In particular, the substitution of a character in x corresponds with the deletion and insertion of the same character in s(x); and the insertion/deletion of a character in x corresponds with the insertion/deletion of that character and an additional ∅-character in s(x). more subtle, and is differed to Appendix C. This establishes that edS(p(x), p(y)) ≤ 2 ed(x, y). The other direction of inequality is somewhat Whereas Theorem 5.2 embeds edit distance into simple edit distance with no distortion, Theo- rem 5.3 shows that no nontrivial embedding in the other direction exists. Theorem 5.3. Consider edit distance over generalized Hamming space. Any embedding from edit distance to simple edit distance must have distortion at least 2. The proofs of Theorems 5.1, 5.2, 5.3 are differed to Appendix C. An important consequence of Theorem 5.1 is a new conditional lower bound for computing DTW over a three-letter alphabet (in which character distances are zero or one). This concludes a direction of work initiated by Abboud, Backurs, and Williams [3], who proved the same result over five-letter alphabet. Corollary 5.4. Let Σ = {a, b, c} with distance function d(a, b) = d(a, c) = d(b, c) = 1. If we assume the Strong Exponential Time Hypothesis, then for all ǫ > 1, no algorithm can compute dtw(x, y) for x, y ∈ Σn in time less than O(n2−ǫ). Proof. See Appendix C. 6 Approximating Edit Distance Over an Arbitrary Metric In this section we present an approximation algorithm for edit distance over an arbitrary metric space. Our algorithm achieves approximation ratio at most nǫ (with high probability) and runtime O(n2−ǫ). Note that when the metric is a well-separated tree metric, such an algorithm can be obtained by combining the approximation algorithm for DTW from Section 4 with the reduction in Section 5. Indeed the algorithm in this section is structurally quite similar to the one in Section 4, but uses a probability argument exploiting properties of edit distance in order to hold over an arbitrary metric. Theorem 6.1. Let (Σ ∪ {∅}, d) be an arbitrary metric space such that l ≥ 1 for all l ∈ Σ. For all 0 < ǫ < 1, and for strings x, y ∈ Σn, there is an algorithm which computes an O(nǫ)-approximation for ed(x, y) (with high probability) in time O(n2−ǫ). Using the standard dynamic-programming algorithm for computing ed(x, y) [43, 37, 42], one can easily obtain the following observation, analogous to Lemma 4.5 in Section 4: Observation 6.2. Consider x, y ∈ Σn, and let R be the smallest magnitude of the letters in x and y. There is an O(n2−ǫ)-time algorithm which returns a value at least as large as ed(x, y); and which returns exactly ed(x, y) when ed(x, y) ≤ R · n1−ǫ. 11 In order to prove Theorem 6.1, we present a new definition of the r-simplification of a string. The difference between this definition and the one in the preceding section allows the new definition to be useful when studying edit distance rather than dynamic time warping. Definition 6.3. For a string x ∈ Σn and for r ≥ 1, we construct the r-simplification sr(x) by removing any letter l satisfying l ≤ r. In the proof of Theorem 6.1 we use randomization in the selection of r in order to ensure that sr(x) satisfies desirable properties in expectation. The key proposition follows: Proposition 6.4. Consider strings x and y in Σn. Consider 0 < ǫ < 1 and R ≥ 1. Select r to be a random real between R and 2R. Then the following three properties hold: • Every letter l in sr(x) or sr(y) satisfies l ≥ R. 15nǫ then E[ed(sr(x), sr(y))] ≤ nR • If ed(x, y) ≤ nR 3nǫ . • If ed(x, y) > 5nR, then ed(sr(x), sr(y)) > nR. The full proofs of Proposition 6.4 and of Theorem 6.1 appear in Appendix D. Structurally, both proofs are similar to the analogous results in Section 4. The key difference appears in the proof of the second part of Proposition 6.4, which uses the random selection of r in order to probabilistically upper-bound ed(sr(x), sr(y). This is presented below. Lemma 6.5. Consider strings x and y in Σn. Consider R ≥ 1 and select r to be a random real between R and 2R. Then E[ed(sr(x), sr(y))] ≤ 5 ed(x, y). Proof. Consider an optimal sequence S of edits from x to y. We will consider the cost of simulating this sequence of edits to transform sr(x) to sr(y). Insertions and deletions are easily simulated by either performing the same operation to sr(x) or performing no operation at all (if the operation involves a letter of magnitude less than or equal to r). Substitutions are slightly more complicated as they may originally be between letters l1 ∈ x and l2 ∈ y of different magnitudes. By symmetry, we may assume without loss of generality that l1 < l2. We will show that the expected cost of simulating the substitution of l1 to l2 in sr(x) is at most 5d(l1, l2). Because insertions and deletions can be simulated with no overhead, it follows that E[ed(sr(x), sr(y))] ≤ 5 ed(x, y). If l1 ≤ r < l2 then l1 does not appear in sr(x) but l2 remains in sr(y). Thus what was previously a substitution of l1 with l2 becomes an insertion of l2 at cost l2. On the other hand, if we do not have l1 ≤ r < l2, then either both l1 and l2 are removed from sr(x) and sr(y) respectively, in which the substitution operation no longer needs to be performed, or both l1 and l2 are still present, in which case the substitution operation can still be performed at cost d(l1, l2). Therefore, the expected cost of simulating the substitution of l1 to l2 in sr(x) is at most (1) Because r is selected at random from the range [R, 2R], the probability that l1 ≤ r < l2 is at most l2−l1 R . If we suppose that l2 ≤ 4R, then it follows by (1) that the expected cost of simulating the substitution of l1 to l2 in sr(x) is at most d(l1,l2) R . By the triangle inequality, this is at most d(l1,l2) Pr[l1 ≤ r < l2] · l2 + d(l1, l2). R · 4R + d(l1, l2) ≤ 5d(l1, l2). If, on the other hand, l2 > 4R, then in order for l1 ≤ r to be true, we must have l1 ≤ 2R, meaning by the triangle inequality that d(l1, l2) ≥ l2/2. Thus in this case l2 ≤ 2d(l1, l2), meaning by (1) that the expected cost of simulating the substitution of l1 to l2 in sr(x) is at most three times as expensive as the original substitution. 12 I would like to thank Moses Charikar for his mentoring and advice through- Acknowledgments out the project, Ofir Geri for his support and for many useful conversations, and Virginia Williams for suggesting the problem of reducing between edit distance and LCS. I would also like to thank Pawe l Gawrychowski for making me aware of [40]. This research is supported by an MIT Akamai Fellowship and a Fannie & John Hertz Foundation Fellowship. This research was also supported in part by NSF Grants 1314547 and 1533644. Parts of this research were performed during the Stanford CURIS research program. 13 References [1] John Aach and George M Church. Aligning gene expression time series with time warping algorithms. Bioinformatics, 17(6):495 -- 508, 2001. [2] Amir Abboud, Arturs Backurs, and Virginia Vassilevska Williams. Quadratic-time hardness of lcs and other sequence similarity measures. arXiv preprint arXiv:1501.07053, 2015. [3] Amir Abboud, Arturs Backurs, and Virginia Vassilevska Williams. Tight hardness results for In 56th Annual Symposium on Foundations of lcs and other sequence similarity measures. Computer Science (FOCS), pages 59 -- 78, 2015. [4] Pankaj K. Agarwal, Kyle Fox, Jiangwei Pan, and Rex Ying. Approximating dynamic time warping and edit distance for a pair of point sequences. In 32nd International Symposium on Computational Geometry (SoCG), pages 6:1 -- 6:16, 2016. [5] Alexandr Andoni, Robert Krauthgamer, and Krzysztof Onak. Polylogarithmic approximation In Proceedings of the 51st Annual for edit distance and the asymmetric query complexity. Symposium on Foundations of Computer Science (FOCS), pages 377 -- 386, 2010. [6] Alexandr Andoni and Krzysztof Onak. Approximating edit distance in near-linear time. SIAM J. Comput., 41(6):1635 -- 1648, 2012. [7] Arturs Backurs and Piotr Indyk. Edit distance cannot be computed in strongly subquadratic time (unless seth is false). In Proceedings of the 47th Annual Symposium on Theory of Com- puting (STOC), pages 51 -- 58, 2015. [8] Nikhil Bansal, Niv Buchbinder, Aleksander Madry, and Joseph Naor. A polylogarithmic- competitive algorithm for the k-server problem. In 52nd Annual Symposium on Foundations of Computer Science (FOCS), pages 267 -- 276, 2011. [9] Ziv Bar-Yossef, T.S. Jayram, Robert Krauthgamer, and Ravi Kumar. Approximating edit distance efficiently. In Proceedings of 45th Annual Symposium on Foundations of Computer Science (FOCS), pages 550 -- 559, 2004. [10] Yair Bartal. On approximating arbitrary metrices by tree metrics. In Proceedings of the 30th Annual Symposium on the Theory of Computing (STOC), pages 161 -- 168, 1998. [11] Tugkan Batu, Funda Ergun, and Suleyman Cenk Sahinalp. Oblivious string embeddings and edit distance approximations. In Proceedings of the 17th Annual Symposium on Discrete Al- gorithms (SODA), pages 792 -- 801, 2006. [12] Nurjahan Begum, Liudmila Ulanova, Jun Wang, and Eamonn J. Keogh. Accelerating dynamic time warping clustering with a novel admissible pruning strategy. In Proceedings of the 21th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 49 -- 58, 2015. [13] Vladimir Braverman, Moses Charikar, William Kuszmaul, David Woodruff, and Lin Yang. The one-way communication complexity of dynamic time warping distance. Manuscript submitted for publication, 2018. 14 [14] Karl Bringmann and Marvin Kunnemann. Quadratic conditional lower bounds for string problems and dynamic time warping. In 56th Annual Symposium on Foundations of Computer Science (FOCS), pages 79 -- 97, 2015. [15] Karl Bringmann and Wolfgang Mulzer. Approximability of the discrete fr´echet distance. Jour- nal of Computational Geometry, 7(2):46 -- 76, 2015. [16] EG Caiani, A Porta, G Baselli, M Turiel, S Muzzupappa, F Pieruzzi, C Crema, A Malliani, and S Cerutti. Warped-average template technique to track on a cycle-by-cycle basis the cardiac filling phases on left ventricular volume. In Computers in Cardiology 1998, pages 73 -- 76, 1998. [17] Diptarka Chakraborty, Debarati Das, Elazar Goldenberg, Michal Kouck`y, and Michael Saks. Approximating edit distance within constant factor in truly sub-quadratic time. In Proceedings of the 59th Annual Symposium on Foundations of Computer Science (FOCS), pages 979 -- 990, 2018. [18] Diptarka Chakraborty, Elazar Goldenberg, and Michal Kouck`y. Streaming algorithms for computing edit distance without exploiting suffix trees. arXiv preprint arXiv:1607.03718, 2016. [19] Moses Charikar, Ofir Geri, Michael P. Kim, and William Kuszmaul. On estimating edit distance: Alignment, dimension reduction, and embeddings. In 45th International Colloquium on Automata, Languages, and Programming (ICALP), pages 34:1 -- 34:14, 2018. [20] Alexander De Luca, Alina Hang, Frederik Brudy, Christian Lindner, and Heinrich Hussmann. Touch me once and i know it's you!: implicit authentication based on touch screen patterns. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, pages 987 -- 996, 2012. [21] Anne Driemel and Francesco Silvestri. Locality-sensitive hashing of curves. In 33rd Interna- tional Symposium on Computational Geometry (SoCG), pages 37:1 -- 37:16, 2017. [22] Ioannis Z. Emiris and Ioannis Psarros. Products of Euclidean metrics and applications to prox- imity questions among curves. In 34th International Symposium on Computational Geometry, SoCG 2018, June 11-14, 2018, Budapest, Hungary, pages 37:1 -- 37:13, 2018. [23] Jittat Fakcharoenphol, Satish Rao, and Kunal Talwar. A tight bound on approximating ar- bitrary metrics by tree metrics. Journal of Computer and System Sciences, 69(3):485 -- 497, 2004. [24] Zvi Galil and Kunsoo Park. An improved algorithm for approximate string matching. SIAM Journal on Computing, 19(6):989 -- 999, 1990. [25] Toni Giorgino et al. Computing and visualizing dynamic time warping alignments in R: the DTW package. Journal of statistical Software, 31(7):1 -- 24, 2009. [26] Omer Gold and Micha Sharir. Dynamic time warping and geometric edit distance: Break- In 44th International Colloquium on Automata, Languages, and ing the quadratic barrier. Programming, (ICALP), pages 25:1 -- 25:14, 2017. 15 [27] Tao Jiang, Guohui Lin, Bin Ma, and Kaizhong Zhang. A general edit distance between rna structures. Journal of computational biology, 9(2):371 -- 388, 2002. [28] Eamonn J. Keogh. Exact indexing of dynamic time warping. In 28th International Conference on Very Large Data Bases (VLDB), pages 406 -- 417, 2002. [29] Eamonn J. Keogh and Michael J. Pazzani. Scaling up dynamic time warping to massive dataset. In Principles of Data Mining and Knowledge Discovery, Third European Conference, (PKDD), pages 1 -- 11, 1999. [30] Eamonn J. Keogh and Michael J. Pazzani. Scaling up dynamic time warping for datamining applications. In Proceedings of the sixth ACM SIGKDD international conference on Knowledge discovery and data mining, pages 285 -- 289, 2000. [31] Jon Kleinberg and Eva Tardos. Algorithm design. Pearson, 2006. [32] William Kuszmaul. Efficiently approximating edit distance between pseudorandom strings. In Proceedings of the thirtieth annual ACM-SIAM Symposium on Discrete Algorithms. SIAM, 2019. [33] Gad M. Landau, Eugene W. Myers, and Jeanette P. Schmidt. Incremental string comparison. SIAM Journal on Computing, 27(2):557 -- 582, 1998. [34] Lindasalwa Muda, Mumtaj Begam, and Irraivan Elamvazuthi. Voice recognition algorithms using mel frequency cepstral coefficient (MFCC) and dynamic time warping (DTW) techniques. arXiv preprint arXiv:1003.4083, 2010. [35] Mario E Munich and Pietro Perona. Continuous dynamic time warping for translation-invariant curve alignment with applications to signature verification. In Proceedings of 7th International Conference on Computer Vision, volume 1, pages 108 -- 115, 1999. [36] Gonzalo Navarro. A guided tour to approximate string matching. ACM computing surveys (CSUR), 33(1):31 -- 88, 2001. [37] Saul B. Needleman and Christian D. Wunsch. A general method applicable to the search for similarities in the amino acid sequence of two proteins. Journal of molecular biology, 48(3):443 -- 453, 1970. [38] Fran¸cois Petitjean, Germain Forestier, Geoffrey I. Webb, Ann E. Nicholson, Yanping Chen, and Eamonn J. Keogh. Faster and more accurate classification of time series by exploiting a novel dynamic time warping averaging algorithm. Knowl. Inf. Syst., 47(1):1 -- 26, 2016. [39] Hiroaki Sakoe and Seibi Chiba. Dynamic programming algorithm optimization for spoken word recognition. IEEE transactions on acoustics, speech, and signal processing, 26(1):43 -- 49, 1978. [40] Alexander Tiskin. Semi-local string comparison: algorithmic techniques and applications. arXiv preprint arXiv:0707.3619v21, 2013. [41] Esko Ukkonen. Algorithms for approximate string matching. Information and control, 64(1- 3):100 -- 118, 1985. 16 [42] Taras K. Vintsyuk. Speech discrimination by dynamic programming. Cybernetics, 4(1):52 -- 57, 1968. [43] Robert A. Wagner and Michael J. Fischer. The string-to-string correction problem. J. ACM, 21(1):168 -- 173, 1974. [44] Rex Ying, Jiangwei Pan, Kyle Fox, and Pankaj K Agarwal. A simple efficient approximation algorithm for dynamic time warping. In Proceedings of the 24th ACM SIGSPATIAL Interna- tional Conference on Advances in Geographic Information Systems, page 21, 2016. [45] Yunyue Zhu and Dennis Shasha. Warping indexes with envelope transforms for query by humming. In Proceedings of the 2003 ACM SIGMOD international conference on Management of data, pages 181 -- 192, 2003. A Computing DTW in the Low-Distance Regime In this section, we present a low-distance regime algorithm for DTW (with characters from an arbitrary metric in which all non-zero distances are at least one). Given that dtw(x, y) is bounded above by a parameter K, our algorithm can compute dtw(x, y) in time O(nK). Moreover, if dtw(x, y) > K, then the algorithm will conclude as much. Consequently, by doubling our guess for K repeatedly, one can compute dtw(x, y) in time O(n · dtw(x, y)). Consider x and y of length n with characters taken from a metric space Σ in which all non-zero distances are at least one. In the textbook dynamic program for DTW [31], each pair of indices i, j ∈ [n] represents a subproblem T (i, j) whose value is dtw(x[1 : i], y[1 : j]). Since T (i, j) can be determined using T (i − 1, j), T (i, j − 1), T (i − 1, j − 1), and knowledge of xi and yj, this leads to an O(n2) algorithm for DTW. A common heuristic in practice is to construct only a small band around the main diagonal of the dynamic programming grid; by computing only entries T (i, j) with i − j ≤ 2K, and treating other subproblems as having infinite return values, one can obtain a correct computation for DTW as long as there is an optimal correspondence which matches only letters which are within K of each other in position. This heuristic is known as the Sakoe-Chiba Band [39] and is employed, for example, in the commonly used library of Giorgino [25]. The Sakoe-Chiba Band heuristic can perform badly even when dtw(x, y) is very small, however. Consider x = abbb··· b and y = aaa··· ab. Although dtw(x, y) = 0, if we restrict ourselves to match- ing letters within K positions of each other for some small K, then the resulting correspondence will cost Ω(n). In order to obtain an algorithm which performs well in the low-distance regime, we introduce a new dynamic program for DTW. The new dynamic program treats x and y asymmetrically within each subproblem. Loosely speaking, for indices i and j, there are two subproblems SP(x, y, i, j) and SP(y, x, i, j). The first of these subproblems evaluates to the DTW between the first i runs of x and the first j letters of y, with the added condition that the final run of y[1 : j] is not extended. The second of the subproblems is analogously defined as the DTW between the first i runs of y and the first j letters of x with the added condition that the final run of x[1 : j] is not extended. The recursion connecting the new subproblems is somewhat more intricate than for the textbook dynamic program. By matching the i-th run with the j-th letter, however, we limit the number of subproblems which can evaluate to less than K. In particular, if the j-th letter of y is in y's t-th run, then any correspondence which matches the i-th run of x to the j-th letter of y must cost 17 at least Ω(i − t) (Lemma A.3). Thus for a given j, there are only O(K) options for i such that SP(x, y, i, j) can possibly be at most K, and similarly for SP(y, x, i, j). Since we are interested in the case of dtw(x, y) ≤ K, we can restrict ourselves to the O(nK) subproblems which have the potential to evaluate to at most O(K). Notice that, in fact, our algorithm will work even when dtw(x, y) > K as long as there is an optimal correspondence between x and y which only matches letters from x from the rx-th run with letters from y from the ry-th run if rx − ry ≤ O(K). We will now formally present our algorithm. For the rest of the section let x and y be strings of length at most n and let K be a parameter which we assume is greater than dtw(x, y). We will present an O(nK) time algorithm for computing dtw(x, y). Our subproblems will be of the form SP(x, y, rx, ry, oy), which is defined as follows. Let x′ consist of the first rx runs of x and y′ consist of the first ry runs of y until the oy-th letter in the ry-th run. Then SP(x, y, rx, ry, oy) is the value of the optimal correspondence between x′ and y′ such that the ry-th run in y′ is not extended.5 If no such correspondence exists (which can only happen if ry ≤ 1 or rx = 0), then the value of the subproblem is ∞. Note that we allow rx, ry, oy to be zero, and if ry is zero, then oy must be zero as well. We will also consider the symmetrically defined subproblems of the form SP(y, x, ry, rx, ox), (These though for simplicity we will only prove recursions for subproblems of the first type. recursions will involve subproblems of the second type, however.) Example A.1. Suppose characters are taken from generalized Hamming space, with distances of zero and one. The subproblem SP(ef abbccccd, f f aabcccddd, 5, 4, 2) takes the value of the optimal correspondence between ef abbcccc and f f aabcc such that the final cc run in the latter is not extended. The subproblem's value turns out to be three, due to the following correspondence: e f f f a a a b b c c a b b b b c c c c . Before continuing, we show how to solve for dtw(x, y) in terms of the subproblems described above. Lemma A.2. Let x and y be strings. Then there is an optimal correspondence between x and y such that either the final run of x is not extended, or the final run of y is not extended. Consequently, if x has s runs with the final run of length j and y has t runs with the final run of length k, then dtw(x, y) = min (SP(x, y, s, t, k), SP(y, x, t, s, j)) . Proof. Consider an optimal correspondence between x and y. If both the final run of x and the final run of y are extended in the correspondence, then we can simply un-extend each by one in order to obtain a shorter correspondence which is at least as good. Thus any minimum-length optimal correspondence between x and y must leave either the final run of x unextended or the final run of y unextended. Because we know that dtw(x, y) ≤ K, there is a large class of subproblems we can ignore. This follows from the next lemma, which provides a lower bound for SP(x, y, rx, ry, oy). 5If oy = 0, then the ry-th run in y ′ is empty and thus trivially cannot be extended. 18 Lemma A.3. SP(x, y, rx, ry, oy) ≥ rx − ry − 1 2 . Proof. Consider two strings a and b, such that a has s non-empty runs and b has t non-empty runs, with s < t. We will show that dtw(a, b) ≥ t−s 2 . Since SP(x, y, rx, ry, oy) returns a correspondence between the first rx runs of x and a portion of y containing either ry or ry − 1 (if oy = 0) non-empty runs, it follows that SP(x, y, rx, ry, oy) ≥ rx−ry−1 Consider a correspondence A between a and b. Notice that b contains t − 1 pairs of adjacent letters where the first letter is from a different run than the second (i.e., the two letters are distinct). The correspondence A can match at most s− 1 of these pairs with pairs of distinct adjacent letters from a. Therefore, there are at least t − s pairs of distinct adjacent letters in b which are matched by A with a pair of equal letters in a. This means that there are at least t − s pairs of adjacent letters in b such that one of the two letters is mismatched by A. Since a mismatched letter can appear in at most two such pairs, there must be at least t−s 2 letters mismatched by A. , as desired. 2 Lemma A.3 restricts the number of subproblems that we are interested in to O(nK). In partic- ular, because we assume dtw(x, y) ≤ K, any dynamic program for computing dtw(x, y) in terms of subproblems of the form SP(x, y, rx, ry, oy) can ignore subproblems in which rx − ry > 2K + 1 (as long as the recursion makes each subproblem's value at least as large as any of the subproblems on which it relies). Now consider how many subproblems SP(x, y, rx, ry, oy) satisfy rx − ry > 2K + 1. The options for ry and oy together correspond with the O(n) positions in y. For each value of ry, there are O(K) values of rx such that rx − ry ≤ 2K + 1. Therefore, there are O(nK) subproblems of the form SP(x, y, rx, ry, oy) with rx − ry ≤ 2K + 1. Similarly, there are are O(nK) subproblems of the form SP(x, y, rx, ry, oy) with rx − ry ≤ 2K + 1. In order to complete our dynamic program, it remains to present a tree of recursions connecting the subproblems. We begin with a recursion for the case where rx, ry, oy ≥ 1. Lemma A.4. Suppose that rx and ry are both between 1 and the number of runs in x and y respectively; and that oy is between 1 and the length of the ry-th run in y. Let lx be the length of the rx-th run in x and ly be the length of the ry-th run in y. Let d be the distance between the letter populating the rx-th run in x and the letter populating the ry-th run in y. Then SP(x, y, rx, ry, oy) is given by (min (SP(x, y, rx, ry, oy − 1) + d, SP(x, y, rx − 1, ry, oy − lx) + d · lx) min (SP(x, y, rx, ry, oy − 1) + d, SP(y, x, ry − 1, rx, lx − oy) + d · oy) if lx ≤ oy if lx > oy. Proof. Consider a minimum-cost correspondence A between the first rx runs of x and the portion of y up until the oy-th letter in the ry-th run, such that the ry-th run in y is not extended. regardless of whether the rx-th run in A is extended, this is an upper bound for the cost of A). If the rx-th run in A is extended, then the cost of A must be SP(x, y, rx, ry, oy − 1) + d (and If the rx-th run in A is not extended, then we consider two cases. In the first case, lx ≤ oy. In this case, The entirety of the rx-th run of x is engulfed by the ry-th run of y in the correspondence A. Since the rx-th run is not extended, the cost of the overlap is lx · d. Thus the cost of A must be SP(x, y, rx − 1, ry, oy − lx) + d · lx. 19 Moreover, since A is minimal, as long as lx ≤ oy, the cost of A is at most the above expression, regardless of whether the rx-th run in x is extended in A. In the second case, lx > oy. In this case, the first oy letters in the ry-th run of y all overlap the rx-th run of x in A. Since the ry-th run is not extended, the cost of the overlap is d · oy. Thus, since the rx-th run in x is also not extended in A, the cost of A must be SP(y, x, ry − 1, rx, lx − oy) + d · oy. Moreover, since A is minimal, as long as lx > oy, the cost of A is at most the above expression, regardless of whether the rx-th run in x is extended in A. The cases where at least one of rx, ry, oy is 0 are easily handled by the following two lemmas. Lemma A.5. Suppose that rx > 0 is at most the number of runs in x, and ry ≥ 0 is at most the number of runs in y. Further suppose that oy = 0. If ry = 0, then SP(x, y, rx, ry, oy) = ∞. Otherwise, let py be the length of the (ry − 1)-th run in y (and zero if no such run exists). Then SP(x, y, rx, ry, oy) = min (SP(x, y, rx, ry − 1, py), SP(y, x, ry − 1, rx, lx)) . Proof. The case where ry = 0 is immediate from the fact that rx > 0 but ry = 0. Suppose that ry 6= 0. Then because oy = 0, SP(x, y, rx, ry, oy) is just the dynamic time warping distance between the first rx runs of x and the first ry − 1 runs of y. The recursion therefore follows from Lemma A.2. Lemma A.6. Suppose that rx = 0 and ry ≥ 0. If ry = 0 and oy = 0, then SP(x, y, rx, ry, oy) = 0. Otherwise, SP(x, y, rx, ry, oy) = ∞. Proof. This is immediate from the definition of SP(x, y, rx, ry, oy). The recursions presented in Lemmas A.4, A.5, A.6 cover every case where rx and ry are between 0 and the number of runs in x and y respectively, and where oy is between 0 and the length of the ry-th run (or zero if ry = 0). Moreover, any recursive call whose inputs satisfy the above conditions will only rely on recursive subcalls whose inputs still satisfy the above conditions. The recursions can be seen to be acyclic as follows. For a given subproblem either of the form SP(x, y, rx, ry, oy) or SP(y, x, ry, rx, ox), associate with it a tuple (rx, ry, t1, t2), where t1 is the length of the portion of x considered by the subproblem and t2 is the length of the portion of y considered by the subproblem. The recursions given allow a subproblem to rely on another subproblem only if the latter subproblem's tuple is dominated by the first subproblem's tuple. This induces a partial ordering on the subproblems, thereby forcing the recursion to be acyclic. Moreover, because we never recurse on a case where any of rx, ry, t1, t2 are negative, the recursion must terminate. Algorithm 1 is a recursive algorithm for computing SP(x, y, rx, ry, oy) using Lemmas A.4, A.5, A.6. The algorithm can be transformed into a dynamic program using memoization. Taking this approach, we can now prove the main result of the section: Theorem A.7. Let x and y be strings of length n taken from a metric space Σ with minimum non-zero distance at least one, and let K be parameter such that dtw(x, y) ≤ K. Then there exists a dynamic program for computing dtw(x, y) in time O(nK). Moreover, if dtw(x, y) > K, then the dynamic program will return a value greater than K. 20 Proof. By Lemma A.2, if x has s runs with the final run of length j and y has t runs with the final run of length k, then dtw(x, y) = min (SP(x, y, s, t, k), SP(y, x, t, s, j)) . By Lemma A.3, the only subproblems to have return value no greater than K are those for which rx − ry ≤ 2K + 1. Therefore, if we relax our recursion to return ∞ whenever rx − ry > 2K + 1, we will still obtain the correct value for dtw(x, y) when dtw(x, y) ≤ K, and we will obtain a value greater than K when dtw(x, y) > K. The resulting recursive algorithm is given by Algorithm 1, and is based on the recursions given in Lemmas A.4, A.5, A.6. To run the algorithm efficiently, we can use memoization in order to treat it as a dynamic program. Because we only recurse on cases where rx − ry ≤ 2K + 1, the total time in the spent is O(nK). In particular, for subproblems of the form SP(x, y, rx, ry, oy), there are O(n) options for ry and oy, for each of which there are O(K) options for rx; similarly, there are O(nK) options for subproblems of the form SP(y, x, ry, rx, ox). Corollary A.8. Let x and y be strings of length n. Then one can compute dtw(x, y) in time O(n · dtw(x, y)). Proof. For a parameter K, the dynamic program from the proof of Theorem A.7 correctly computes dtw(x, y) when dtw(x, y) ≤ K, and otherwise returns a value greater than K. By guessing K to be successive powers of two, one can find the first power of two K such that dtw(x, y) ≤ K in time O(n· 1 + n· 2 + n· 4 +··· + n· K) = O(n· K), allowing one to then compute dtw(x, y) in time O(n · K) = O(n · dtw(x, y)). 21 Algorithm 1 Subproblem SP(x, y, rx, ry, oy) with the relaxation SP(x, y, rx, ry, oy) = ∞ when rx − ry > 2K + 1. 1: procedure SP(x, y, rx, ry, oy) if rx − ry > 2K + 1 then 2: if rx > 0 and oy > 0 then return ∞. d ← distance between each letter in rx-th run in x and each letter in ry-th run in y. lx ← length of rx-th run in x. ly ← length of ry-th run in y. answer ← SP(x, y, rx, ry, oy − 1) + d. if lx ≤ oy then 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: option2 ← SP(x, y, rx − 1, ry, oy − lx) + d · lx. answer ← min (answer, option2) if lx > oy then option2 ← SP(y, x, ry − 1, rx, lx − oy) + d · oy. answer ← min (answer, option2) return answer. if rx > 0 and ry = 0 then if rx > 0 and ry > 0 and oy = 0 then return ∞. lx ← length of rx-th run in x. py ← length of (ry − 1)-th run in y. option1 ← SP(x, y, rx, ry − 1, py). option2 ← SP(y, x, ry − 1, rx, lx). return min(option1, option2). if rx = 0 and ry = 0 then return 0. return ∞. B Approximating DTW Over Well-Separated Tree Metrics In this section, we present an O(n2−ǫ)-time O(nǫ)-approximation algorithm for DTW over a well- separated tree metric with logarithmic depth. We begin by presenting a brief background on well-separated tree metrics. Definition B.1. Consider a tree T whose vertices form an alphabet Σ, and whose edges have positive weights. T is said to be a well-separated tree metric if every root-to-leaf path consists of edges ordered by nonincreasing weight. The distance between two nodes u, v ∈ Σ is defined as the maximum weight of any edge in the shortest path from u to v. Well-separated tree metrics are universal in the sense that any metric Σ can be efficiently embedded (in time O(Σ2)) into a well-separated tree metric T with expected distortion O(log Σ) [23].6 That is, if dΣ(u, v) denotes the distance between two elements of Σ, and dT (u, v) denotes the 6In particular, [23] shows how to embed Σ into what is known as a 2-hierarchically well-separated tree metric. 22 distance in T between the nodes corresponding with u and v, then and dΣ(u, v) ≤ dT (u, v), E[dT (u, v)] ≤ O(log n) · dΣ(u, v). (2) (3) Moreover, using the algorithm from Theorem 8 of [8] to modify the well-separated tree metric T , we may assume without loss of generality that T has maximum depth O(log Σ), allowing for fast evaluation of distances. For strings x, y ∈ Σn, let dtwT (x, y) denote the dynamic time warping distance after embedding Σ into T . Then by (2), every correspondence between the embedded strings must cost at least as much as the same correspondence between the original strings, meaning that dtw(x, y) ≤ dtwT (x, y). (4) Moreover, by (3), if we take the optimal correspondence between x and y, then the same corre- spondence between the embedded strings will have expected cost at most O(log n) times as large, meaning that E[dtwT (x, y)] ≤ dtw(x, y). (5) Combined, (4) and (5) tell us that any approximation algorithm for DTW over well-separated tree metrics will immediately yield an approximation algorithm over an arbitrary polynomial-size metric Σ, with two caveats: the new algorithm will have its multiplicative error increased by O(log n); and O(log n) instances of Σ embedded into a well-separated tree metric must be pre- computed for use by the algorithm (requiring, in general, O(Σ2 log n) preprocessing time). In particular, given O(log n) tree embeddings of Σ, T1, . . . , TO(log n), (4) and (5) tell us that with high probability mini (dtwTi(x, y)) will be within a logarithmic factor of dtw(x, y). The remainder of the section will be devoted to designing an approximation algorithm for DTW over a well-separated tree metric. We will prove the following theorem: Theorem B.2. Consider 0 < ǫ < 1. Suppose that Σ is a well-separated tree metric of polynomial size and at most logarithmic depth. Moreover, suppose that the aspect ratio of Σ is at most expo- nential in n (i.e., the ratio between the largest distance and the smallest non-zero distance). Then in time O(n2−ǫ) we can obtain an O(nǫ)-approximation for dtw(x, y) for any x, y ∈ Σn. An important consequence of the theorem occurs for DTW over the reals. Corollary B.3. Consider 0 < ǫ < 1. Suppose that Σ is an O(n)-point subset of the reals with polynomial aspect ratio. Then in time O(n2−ǫ) we can obtain an O(nǫ)-approximation for dtw(x, y) with high probability for any x, y ∈ Σn. Proof. Without loss of generality, Σ ⊂ [0, nc] for some constant c, and no two points in Σ have distance less than one from each other. The key observation is that there is an O(n log n)-time embedding with O(log n) expected distortion from Σ to a well-separated tree metric of size O(n) with logarithmic depth. Such an These metrics differ slightly from our definition of a well-separated tree metric in that the distance between two nodes is given by the sum of the edge weights in the shortest path, rather than the maximum. It turns out that in the case of 2-hierarchically well-separated tree metrics, these quantities will differ from one another by at most a factor of two, however. 23 embedding can be constructed by a random partitioning process, as follows7. If m1 and m2 are the smallest and largest elements of Σ, respectively, and r = m2 − m1 is the size of the range in which Σ lies, then first select a pivot p at random from the range [m1 + r/4, m2 − r/4]. Next recursively constructing a subtree L for the subset of Σ less than p, and then recursively constructing a subtree R for the subset of Σ greater than p. Finally, return the tree T in which p is the root, L is the left subtree, R is the right subtree, and the edges from p to its children have weight r. One can easily verify that T is a well-separated tree metric; that distances in T dominate distances in Σ; that the depth of T is O(log n); and that T can be recursively constructed in time O(n log n). It is slightly more subtle to show that for a, b ∈ Σ, the expected distance dT (a, b) between a and b in T is at most O(log n) · a − b. Note that dT (a, b) is the length r of the range for the recursive subproblem in which a and b are split from one-another. For each recursive subproblem containing a, the probability that a and b will be split by the pivot in that subproblem is at most O(a− b/r), where r is the range size of the subproblem. This means that the expected contribution to dT (a, b) by that subproblem is O(a − b/r) · r ≤ O(a − b). Since there are at most O(log n) recursive subproblems containing a, the expected value of dT (a, b) is at most O(log n)·a− b. This completes the analysis of the embedding. Combining the above embedding with Theorem B.2 (and taking the minimum output of the algorithm over O(log n) independent iterations in order to obtain a high probability result) yields the desired result. In proving Theorem B.2, our approximation algorithm will take advantage of what we refer to as the r-simplification of a string over a well-separated tree metric. Definition B.4. Let T be a well-separated tree metric whose nodes form an alphabet Σ. For a string x ∈ Σn, and for any r ≥ 1, the r-simplification sr(x) is constructed by replacing each letter l ∈ x with its highest ancestor l′ in T that can be reached from l using only edges of weight at most r/4. Our approximation algorithm will apply the low-distance regime algorithm from the previous section to sr(x) and sr(y) for various r in order to extract information about dtw(x, y). Notice that using our low-distance regime algorithm for DTW, we get the following useful lemma for free: Lemma B.5. Consider 0 < ǫ < 1. Suppose that for all pairs l1, l2 of distinct letters in Σ, d(l1, l2) ≥ γ. Then for x, y ∈ Σn there is an O(n2−ǫ) time algorithm which either computes dtw(x, y) exactly, or concludes that dtw(x, y) > γn1−ǫ. Proof. This follows immediately from Theorem A.7. The next lemma states three important properties of r-simplifications. We remark that the same lemma appears in our concurrent work on the communication complexity of DTW, in which we use the lemma in designing an efficient one-way communication protocol [13]. Lemma B.6. Let T be a well-separated tree metric with distance function d and whose nodes form the alphabet Σ. Consider strings x and y in Σn. Then the following three properties of sr(x) and sr(y) hold: • For every letter l1 ∈ sr(x) and every letter l2 ∈ sr(y), if l1 6= l2, then d(l1, l2) > r/4. 7This construction appears to be somewhat of a folklore result. It is a natural consequence of ideas from [10]. 24 • For all α, if dtw(x, y) ≤ nr/α then dtw(sr(x), sr(y)) ≤ nr/α. • If dtw(x, y) > nr, then dtw(sr(x), sr(y)) > nr/2. Proof. The first part of the lemma follows directly from the definitions of sr(x) and sr(y). Let C be the optimal correspondence between x and y, and let C ′ be the same correspondence 2 be between sr(x) and sr(y). Suppose C matches some letter l1 ∈ x to a letter l2 in y. Let l′ the corresponding letters in sr(x) and sr(y). Notice that if d(l1, l2) ≤ r/4, then 1 and l′ 1 = l′ l′ 2, (6) and that if d(l1, l2) > r/4, then d(l′ 1, l′ 2) = d(l1, l2). (7) By (6) and (7), the correspondence C ′ costs no more than C, meaning that dtw(sr(x), sr(y)) ≤ dtw(x, y). Therefore, if dtw(x, y) ≤ nr/α then dtw(sr(x), sr(y)) ≤ nr/α, completing the second part of the lemma. Now suppose that dtw(x, y) > nr. Consider an optimal correspondence D between sr(x) and sr(y), and assume without loss of generality that D is of length no more than 2n. Equations (6) and (7) tell us that the cost of D can be no more than 2n · r/4 smaller than the cost of the same correspondence between x and y. Since dtw(x, y) > nr, it follows that dtw(sr(x), sr(y)) > nr − 2n · r/4 = nr/2, completing the third part of the lemma. We can now prove Theorem B.2. Proof of Theorem B.2. Without loss of generality, the minimum non-zero distance in Σ is 1 and the largest distance is some value m, which is at most exponential in n. We begin by defining the (r, nǫ)-DTW gap problem for r ≥ 1, in which for two strings x and y a return value of 0 indicates that dtw(x, y) < nr and a return value of 1 indicates that dtw(x, y) ≥ n1−ǫr. By Lemma B.6, in order to solve the (r, nǫ)-DTW gap problem for x and y, it suffices to determine whether dtw(sr(x), sr(y)) ≤ n1−ǫr. Moreover, because the minimum distance between distinct letters in sr(x) and sr(y) is at least r/4, this can be done in time O(n2−ǫ log n) using Lemma B.5.8 We will now consider the (2i, nǫ/2)-DTW gap problem for i ∈ {0, 1, 2, . . . ,⌈log m⌉}. In order to obtain an nǫ-approximation for dtw(x, y), we begin by using Lemma B.5 to either determine dtw(x, y) or to determine that dtw(x, y) ≥ n1−ǫ. For the rest of the proof, suppose we are in the latter case, meaning that we know dtw(x, y) ≥ n1−ǫ. If the (20, nǫ/2)-DTW gap problem returned 0, then we would know that dtw(x, y) ≤ n, and thus we could return n1−ǫ as an nǫ-approximation for dtw(x, y). Therefore, we need only consider the case where the (20, nǫ/2)-DTW gap returns 1. Moreover we may assume without computing it that (2⌈log m⌉, nǫ/2)-DTW gap returns 0 since trivially dtw(x, y) cannot exceed nm. Because (2i, nǫ/2)- DTW gap returns 1 for i = 0 and returns 0 for i = ⌈log m⌉, there must be some i such that (2i−1, nǫ/2)-DTW gap returns 1 and (2i, nǫ/2)-DTW gap returns 0. Moreover, we can find such an i by performing a binary search on i in the range R = {0, . . . ,⌈log m⌉}. We begin by computing (2i, nǫ/2)-DTW gap for i in the middle of the range R. If the result is a one, then we can recurse 8The logarithmic factor comes from the fact that evaluating distances between points may take logarithmic time in our well-separated tree metric. 25 on the second half of the range; otherwise we recurse on the first half of the range. Continuing like this, we can find in time O(n2−ǫ log log m) = O(n2−ǫ) some value i for which (2i−1, nǫ/2)-DTW gap returns 1 and (2i, nǫ/2)-DTW gap returns 0. Given such an i, we know that dtw(x, y) ≥ nǫ/2 = 2in1−ǫ and that dtw(x, y) ≤ 2in. Thus we can return 2in1−ǫ as an nǫ approximation of dtw(x, y). 2i−1n C Reducing Edit Distance to DTW and LCS In this section we present a simple reduction from edit distance over an arbitrary metric to DTW over the same metric.At the end of the section, we prove as a corollary a conditional lower bound for DTW over three-letter Hamming space, prohibiting any algorithm from running in strongly subquadratic time. Surprisingly, the exact same reduction, although with a different analysis, can be used to reduce the computation of edit distance (over generalized Hamming space) to the computation of longest- common-subsequence length (LCS). Since computing LCS is equivalent to computing edit distance without substitutions, this reduction can be interpreted as proving that edit distance without substitutions can be used to efficiently simulate edit distance with substitutions, also known as simple edit distance. Recall that for a metric Σ∪{∅}, we define the edit distance between two strings x, y ∈ Σn such that the cost of a substitution from a letter l1 to l2 is d(l1, l2), and the cost of a deletion or insertion of a letter l is d(l,∅). Additionally, define the simple edit distance edS(x, y) to be the edit distance using only insertions and deletions. For a string x ∈ Σn, define the padded string p(x) of length 2n+1 to be the string ∅x1∅x2∅x3 ··· xn∅. In particular, for i ≤ 2n + 1, p(x)i = ∅ when i is odd, and p(x)i = xi/2 when i is even. The following theorem proves that dtw(p(x), p(y)) = ed(x, y). Theorem C.1. Let Σ ∪ {∅} be a metric. Then for any x, y ∈ Σn, dtw(p(x), p(y)) = ed(x, y). Proof. We begin by showing that there is an optimal correspondence C between p(x) and p(y) in which the only extended runs are those consisting of the letter ∅. Consider an arbitrary optimal correspondence D between p(x) and p(y), and assume without loss of generality that no two runs which are extended in the correspondence are matched by the correspondence to overlap. Suppose a run r consisting of a letter a 6= ∅ in x is extended in D. If the first letter in the run r is matched with the letter ∅ in y, then the correspondence D could be improved by replacing the first letter in r with an ∅ character, which can be achieved by un-extending the run r by one, and instead further extending the preceding run of ∅'s by one. Consequently, the first letter in the run r must match to some letter l1 6= ∅ in y, and similarly the final letter in the run r must match to some letter l2 6= ∅ in y, meaning the extended run must be at least three letters long. Now consider the first two letters l1,∅ to which the run r is matched by D. By the triangle inequality, d(l1, a) + d(a,∅) ≥ d(l1,∅) (recall that a is the letter which populates the run r). It follows that if we un-extend the run r by two letters, and instead further extend the run of ∅'s preceding r, then we arrive at a correspondence D′ no more expensive than D. Moreover, the sum of the lengths of runs of non-∅ elements in D′ has been reduced by two from the same sum for D. Repeating this process as many times as necessary, we can arrive at a correspondence C in which no runs containing non-∅ letters are extended, as desired. Because D was an optimal correspondence, and C costs no more than D, C must also be optimal. 26 Using the correspondence C, we can now prove that ed(x, y) ≤ dtw(p(x), p(y)). In particular, we can construct a sequence of edits between x and y at most as expensive as the correspondence C. To do this, we first delete from x any letter l in x which is matched by C to an ∅ character, and we do the same for y. Call the resulting strings x′ and y′. Notice that for each letter x′ i in x′, i in y′. Consequently, if we perform substitutions in C must match x′ order to transform each x′ i, then the full sequence of edits between x and y will have cost no more than the cost of C. i to the corresponding letter y′ i into y′ Finally, to show that dtw(p(x), p(y)) ≤ ed(x, y), we present a correspondence C between p(x) and p(y) of cost ed(x, y). Consider an optimal sequence of edits E from x to y. One can think of E as performing a series of insertions in x, a series of insertions in y, and then a series of substitutions to transform the resulting strings into one another. Now suppose that for each insertion into x, we instead insert an ∅ character, and similarly for each insertion into y. Notice that the resulting strings x′ and y′ will satisfy Pi d(x′ i) = cost(E). Next, insert an additional ∅ character in every other position in x′ and in every other position in y′ to obtain strings x′′ and y′′. These new strings still satisfy Pi d(x′′ i ) = cost(E), but have the additional property that they are expansions of p(x) and p(y). Hence dtw(p(x), p(y)) ≤ ed(x, y), completing the proof. i , y′′ i, y′ Theorem C.2 proves an analogous reduction from edit distance to LCS. As a convention, we use complex edits to refer to insertions, deletions, and substitutions, and simple edits to refer to edits consisting only of insertions and deletions. Theorem C.2. Let Σ be a generalized Hamming metric. Then for any x, y ∈ Σn, edS(p(x), p(y)) = 2 ed(x, y). Proof. Given a sequence of complex edits from x to y, those edits can be emulated at twice the cost using simple edits from p(x) to p(y). In particular, the insertion of a letter l becomes the insertion of the letters l,∅, the deletion of a letter l becomes the deletion of the letters l,∅, and the substitution of the letter l to the letter k becomes the deletion and insertion needed to transform l,∅ to k,∅. It follows that edS(p(x), p(y)) ≤ 2 ed(x, y). It remains to prove that 2 ed(x, y) ≤ edS(p(x), p(y)). For the sake of completeness, we will now prove it formally. Consider an optimal alignment A between p(x) and p(y) (allowing only simple edits). That is, A is a non-crossing bipartite graph between the letters of p(x) and p(y) with edges only between letters of the same value. The cost of A is the number of singleton nodes in A, which is equal to edS(p(x), p(y)). Without loss of generality, for each edge e1 in A connecting two non-null nodes u and v, there is another edge e2 connecting the 0-nodes directly following u and v. Indeed, if there is not, then since A is non-crossing, at most one of the two 0-nodes can be part of an edge in A. Deleting such an edge and replacing it with the desired edge does not change the cost of A. Call a letter xi in x totally unmatched by A if p(x)2i and p(x)2i+1 are both unmatched in A. Call a letter xi partially matched to yj by A if p(x)2i is unmatched in A but p(x)2i+1 is matched to some p(y)2j+1. Call a letter xi totally matched to yj by A if both p(x)2i and p(x)2i+1 are matched by A to some p(y)2j and p(y)2j+1 respectively. If we define the analogous terms for letters of y, then notice that every letter of x and y is either totally unmatched, partially matched to another partially matched letter, or totally matched to another totally matched letter. We now construct an alignment between x and y (allowing for complex edits). That is, we construct a non-crossing bipartite graph B from the letters of x to the letters of y, such that the number of unmatched nodes in B plus the number of edges between different-valued characters 27 in B is at most the number of unmatched nodes in A. For each letter xi or yi that is totally unmatched by A, leave it as a singleton node in B. For each letter xi which is partially matched to some yj by A, match xi to yj in B. For each letter xi which is totally matched to some letter yj, match xi to yj in B. The resulting B has cost equal to the number of totally unmatched letters in x and y, plus the number of partially matched letters in x (since they are paired with the partially matched letters in y through substitutions). This is half the cost of A, since each totally unmatched letter in x or y corresponds with two adjacent singleton nodes in A, and each partially matched pair of letters between x and y corresponds with two singleton nodes in A. It follows that 2 ed(x, y) ≤ edS(p(x), p(y)). Whereas Theorem C.2 embeds edit distance into simple edit distance with no distortion, the next theorem shows that no nontrivial embedding in the other direction exists. Formally, we say that an embedding from a metric space (M1, d1) to (M2, d2) is an injective map φ. The distortion of an embedding is defined as supx,y∈M1 d1(x, y)/d2(φ(x), φ(y)) inf x,y∈M1 d1(x, y)/d2(φ(x), φ(y)) , unless the numerator is unbounded or the denominator is zero, in which case the distortion is ∞. A trivial embedding from edit distance to simple edit distance would be the identity map, which achieves distortion 2. Theorem C.3 establishes that no other embedding can do better. Theorem C.3. Consider edit distance over generalized Hamming space. Any embedding from edit distance to simple edit distance must have distortion at least 2. Proof. For an alphabet Σ containing both 0 and 1, suppose for contradiction that there is an embedding φ : Σ∗ → Σ∗ such that c1 edS(x, y) ≤ ed(φ(x), φ(y)) ≤ c2 edS(x, y) for constants c1 ≤ c2 within a factor of less than two of each other. For all n, ed(φ(0n), φ(1n)) ≥ c1 · 2n. Since the edit distance between two strings is at most the maximum of their lengths, it follows without loss of generality that φ(0n) ≥ c1 · 2n (since the case where φ(1n) ≥ c1 · 2n is symmetric). Now define x to be the empty string, and y = 0n. By assumption, ed(φ(x), φ(y)) ≤ c2n, and thus φ(x) and φ(y) are within c2n of each other in length. Since φ(y) is length at least 2 · c1n, it follows that φ(x) must be length at least (2c1 − c2)n. Recall that c1 and c2 are within less than a factor of two of each other, meaning that (2c1 − c2) is a positive constant. Therefore, we have shown that for all n, φ(x) ≥ Ω(n), a contradiction. We conclude the section by obtaining a novel conditional lower bound for computing DTW over a three-letter alphabet (in which character distances are zero or one). This concludes a direction of work initiated by Abboud, Backurs, and Williams [3], who proved the same result over five-letter alphabet. Corollary C.4. Let Σ = {a, b, c} with distance function d(a, b) = d(a, c) = d(b, c) = 1. If we assume the Strong Exponential Time Hypothesis, then for all ǫ > 1, no algorithm can compute dtw(x, y) for x, y ∈ Σn in time less than O(n2−ǫ). 28 Proof. By Theorem 1.2 of [14], edit distance between binary strings cannot be computed in strongly subquadratic time, assuming the Strong Exponential Time Hypothesis. Applying Theorem C.1, we get the same result for DTW over Σ. D Approximating Edit Distance Over an Arbitrary Metric In this section we present an approximation algorithm for edit distance over an arbitrary metric space. Our algorithm achieves approximation ratio at most nǫ (with high probability) and runtime O(n2−ǫ). Note that when the metric is a well-separated tree metric, such an algorithm can be obtained by combining the approximation algorithm for DTW from Section 4 with the reduction in Section 5. Indeed the algorithm in this section is structurally quite similar to the one in Section 4, but uses a probability argument exploiting properties of edit distance in order to hold over an arbitrary metric. Theorem D.1. Let (Σ∪{∅}, d) be an arbitrary metric space such that l ≥ 1 for all l ∈ Σ. For all 0 < ǫ < 1, and for strings x, y ∈ Σn, there is an algorithm which computes an O(nǫ)-approximation for ed(x, y) (with high probability) in time O(n2−ǫ). Before continuing, we remind the reader of the standard dynamic-programming algorithm for computing ed(x, y) [43, 37, 42]. For i, j ∈ {0, . . . , n}, the subproblem A(i, j) is defined to be the edit distance ed(x1 ··· xi, y1 ··· yj). Notice that for i, j > 0, the return-value for A(i, j) is completely determined by A(i−1, j), A(i, j−1), and A(i − 1, j − 1), as well as knowledge of xi and yj. Using this, one can formulate a recursion which results in an O(n2)-time dynamic-program for computing ed(x, y). Now consider the same dynamic program, except with A(i, j) artificially set to ∞ whenever i − j > K, for some parameter K. This new dynamic program runs in time O(n · K) and returns the minimum cost of any sequence of edits that transforms x to y without ever matching any xi to some yj for which i − j > K. Importantly, this means that if there is an optimal sequence of edits involving no more than K insertions and deletions, then the new dynamic program will find the true value of ed(x, y); otherwise, the dynamic program may return an overestimate for ed(x, y). This implies in the following observation: Observation D.2. Consider x, y ∈ Σn, and let R be the smallest magnitude of the letters in x and y. There is an O(n2−ǫ)-time algorithm which returns a value at least as large as ed(x, y); and which returns exactly ed(x, y) when ed(x, y) ≤ R · n1−ǫ. In order to prove Theorem D.1, we present a new definition of the r-simplification of a string. The difference between this definition and the one in the preceding section allows the new definition to be useful when studying edit distance rather than dynamic time warping. Definition D.3. For a string x ∈ Σn and for r ≥ 1, we construct the r-simplification sr(x) by removing any letter l satisfying l ≤ r. The proof of Theorem D.1 has a similar structure to that of Theorem B.2, but interestingly avoids the use of well-separated tree metrics. A key insight in the proof of Theorem D.1 is to use randomization in the selection of r in order to ensure that sr(x) satisfies desirable properties in expectation. The key proposition follows: 29 Proposition D.4. Consider strings x and y in Σn. Consider 0 < ǫ < 1 and R ≥ 1. Select r to be a random real between R and 2R. Then the following three properties hold: • Every letter l in sr(x) or sr(y) satisies l ≥ R. 15nǫ then E[ed(sr(x), sr(y))] ≤ nR • If ed(x, y) ≤ nR 3nǫ . • If ed(x, y) > 5nR, then ed(sr(x), sr(y)) > nR. Before proving Proposition D.4, we first use it to prove Theorem D.1. Proof of Theorem D.1. We begin by defining the (R, nǫ)-edit-distance gap problem for r ≥ 1, in which for two strings x and y a return value of 0 indicates that ed(x, y) < 5nR and a return value of 1 indicates that ed(x, y) ≥ n1−ǫR/15. One can solve the (R, n1−ǫ)-edit-distance gap problem with high probability in time O(n2−ǫ) as follows. For a sufficiently large number of samples t = O(log n), select r1, . . . , rt each at random from [R, 2R]. Then apply Observation D.2 to each of the ri's in order to obtain an estimate ei for ed(sri(x), sri(y)) in time O(n2−ǫ). Because each ei is either correct or an overestimate, if any of the ei's are less than nR, then we can conclude that ed(sri(x), sri(y)) < nR, meaning by Proposition D.4 that ed(x, y) ≤ 5nR. On the other hand, if none of the ei's are less than nR, then our algorithm for the gap problem concludes that ed(x, y) ≥ n1−ǫR/15. In order to show that our algorithm for the gap problem is correct with high probability, it suffices to show that if ed(x, y) < n1−ǫR/15 then with high probability, at least one of the ei's will be less than nR. By Proposition D.4, if ed(x, y) < n1−ǫR/15, then E[ed(sri(x), sri(y))] ≤ nR 3nǫ . Applying Markov's inequality to each ed(sri(x), sri(y)), with high probability there is some i for which which by Observation D.2 means that ed(sri(x), sri(y)) < Rn1−ǫ, ei = ed(sri(x), sri(y)) < nR, as desired. Now that we have an algorithm for the (R, n1−ǫ)-edit-distance gap problem, the proof of The- orem D.1 follows just as did the proof of Theorem B.2 using the solution to the (r, nǫ)-DTW gap problem. Recall, however, that the proof of Theorem D.1 required the metric space to have at most exponential aspect ratio. This was so that a binary search could efficiently find some i for which (2i−1, nǫ/2)-DTW gap returns 1 and (2i, nǫ/2)-DTW gap returns 0. Such a requirement is not necessary here, because we can restrict ourselves to considering only the O(n) i's for which there is at least one letter l in x or y for which 2i−1 ≤ l ≤ 2i+1; indeed, for all other values of i, our algorithm for the (R, n1−ǫ)-edit-distance gap problem will be guaranteed to return the same value for R = 2i−1 as for R = 2i. By restricting ourselves to these values of i, the binary search to find some i for which (2i−1, nǫ/2)-DTW gap returns 1 and (2i, nǫ/2)-DTW gap returns 0 can be performed efficiently regardless of the aspect ratio of the metric space. part of the proposition follows immediately from the definition of sr(x) and sr(y). The rest of the section will be devoted to proving Proposition D.4. Because r ≥ R, The first The second part of the proposition comes from the following lemma. 30 Lemma D.5. Consider strings x and y in Σn. Consider R ≥ 1 and select r to be a random real between R and 2R. Then E[ed(sr(x), sr(y))] ≤ 5 ed(x, y). Proof. Consider an optimal sequence S of edits from x to y. We will consider the cost of simulating this sequence of edits to transform sr(x) to sr(y). Insertions and deletions are easily simulated by either performing the same operation to sr(x) or performing no operation at all (if the operation involves a letter of magnitude less than or equal to r). Substitutions are slightly more complicated as they may originally be between letters l1 ∈ x and l2 ∈ y of different magnitudes. By symmetry, we may assume without loss of generality that l1 < l2. We will show that the expected cost of simulating the substitution of l1 to l2 in sr(x) is at most 5d(l1, l2). Because insertions and deletions can be simulated with no overhead, it follows that E[ed(sr(x), sr(y))] ≤ 5 ed(x, y). If l1 ≤ r < l2 then l1 does not appear in sr(x) but l2 remains in sr(y). Thus what was previously a substitution of l1 with l2 becomes an insertion of l2 at cost l2. On the other hand, if we do not have l1 ≤ r < l2, then either both l1 and l2 are removed from sr(x) and sr(y) respectively, in which the substitution operation no longer needs to be performed, or both l1 and l2 are still present, in which case the substitution operation can still be performed at cost d(l1, l2). Therefore, the expected cost of simulating the substitution of l1 to l2 in sr(x) is at most Pr[l1 ≤ r < l2] · l2 + d(l1, l2). (8) Because r is selected at random from the range [R, 2R], the probability that l1 ≤ r < l2 is at most l2−l1 R . If we suppose that l2 ≤ 4R, then it follows by (8) that the expected cost of simulating the substitution of l1 to l2 in sr(x) is at most R . By the triangle inequality, this is at most d(l1,l2) d(l1, l2) R · 4R + d(l1, l2) ≤ 5d(l1, l2). If, on the other hand, l2 > 4R, then in order for l1 ≤ r to be true, we must have l1 ≤ 2R, meaning by the triangle inequality that d(l1, l2) ≥ l2/2. Thus in this case l2 ≤ 2d(l1, l2), meaning by (8) that the expected cost of simultating the substitution of l1 to l2 in sr(x) is at most three times as expensive as the original substitution. Finally the third part of Proposition D.4 is a consequence of the following lemma, which com- pletes the proof of Proposition D.4. Lemma D.6. Consider strings x and y in Σn. Consider R ≥ 1 and select r to be a random real between R and 2R. Then ed(x, y) < ed(sr(x), sr(y)) + 4Rn. Proof. Beginning with x, remove all letters of magnitude at most r; this costs at most 2nR. Then obtain sr(y) through ed(sr(x), sr(y)) edits. Finally, insert all letters of magnitude at most r in y; this costs at most 2nR. Combining these three steps, we get from x to y at cost ed(sr(x), sr(y)) + 4nR. 31
1709.06299
1
1709
2017-09-19T08:52:23
Tilt Assembly: Algorithms for Micro-Factories That Build Objects with Uniform External Forces
[ "cs.DS", "cs.CC", "cs.CG" ]
We present algorithmic results for the parallel assembly of many micro-scale objects in two and three dimensions from tiny particles, which has been proposed in the context of programmable matter and self-assembly for building high-yield micro-factories. The underlying model has particles moving under the influence of uniform external forces until they hit an obstacle; particles can bond when being forced together with another appropriate particle. Due to the physical and geometric constraints, not all shapes can be built in this manner; this gives rise to the Tilt Assembly Problem (TAP) of deciding constructibility. For simply-connected polyominoes $P$ in 2D consisting of $N$ unit-squares ("tiles"), we prove that TAP can be decided in $O(N\log N)$ time. For the optimization variant MaxTAP (in which the objective is to construct a subshape of maximum possible size), we show polyAPX-hardness: unless P=NP, MaxTAP cannot be approximated within a factor of $\Omega(N^{\frac{1}{3}})$; for tree-shaped structures, we give an $O(N^{\frac{1}{2}})$-approximation algorithm. For the efficiency of the assembly process itself, we show that any constructible shape allows pipelined assembly, which produces copies of $P$ in $O(1)$ amortized time, i.e., $N$ copies of $P$ in $O(N)$ time steps. These considerations can be extended to three-dimensional objects: For the class of polycubes $P$ we prove that it is NP-hard to decide whether it is possible to construct a path between two points of $P$; it is also NP-hard to decide constructibility of a polycube $P$. Moreover, it is expAPX-hard to maximize a path from a given start point.
cs.DS
cs
Tilt Assembly: Algorithms for Micro-Factories That Build Objects with Uniform External Forces Aaron T. Becker∗1, S´andor P. Fekete2, Phillip Keldenich2, Dominik Krupke2, Christian Rieck2, Christian Scheffer2, and Arne Schmidt2 1Department of Electrical and Computer Engineering, University of Houston, USA. 2Department of Computer Science, TU Braunschweig, Germany. {s.fekete, p.keldenich, d.krupke, c.rieck, c.scheffer, arne.schmidt}@tu-bs.de [email protected] Abstract We present algorithmic results for the parallel assembly of many micro-scale objects in two and three dimensions from tiny particles, which has been proposed in the context of programmable matter and self-assembly for building high-yield micro-factories. The underlying model has particles moving under the influence of uniform external forces until they hit an obstacle; particles can bond when being forced together with another appropriate particle. 1 3 ); for tree-shaped structures, we give an O(N Due to the physical and geometric constraints, not all shapes can be built in this manner; this gives rise to the Tilt Assembly Problem (TAP) of deciding constructibility. For simply-connected polyominoes P in 2D consisting of N unit-squares ("tiles"), we prove that TAP can be decided in O(N log N ) time. For the optimization variant MaxTAP (in which the objective is to construct a subshape of maximum possible size), we show polyAPX-hardness: unless P=NP, MaxTAP cannot be approximated within a factor of 1 Ω(N 2 )-approximation algorithm. For the efficiency of the assembly process itself, we show that any constructible shape allows pipelined assembly, which produces copies of P in O(1) amortized time, i.e., N copies of P in O(N ) time steps. These considerations can be extended to three-dimensional objects: For the class of polycubes P we prove that it is NP-hard to decide whether it is possible to construct a path between two points of P ; it is also NP-hard to decide constructibility of a polycube P . Moreover, it is expAPX-hard to maximize a path from a given start point. 1 Introduction In recent years, progress on flexible construction at micro- and nano-scale has given rise to a large set of challenges that deal with algorithmic aspects of programmable matter. Examples of cutting-edge application areas with a strong algorithmic flavor include self-assembling systems, in which chemical and biological sub- stances such as DNA are designed to form predetermined shapes or carry out massively parallel computations; and swarm robotics, in which complex tasks are achieved through the local interactions of robots with highly limited individual capabilities, including micro- and nano-robots. Moving individual particles to their appropriate attachment locations when assembling a shape is difficult because the small size of the particles limits the amount of onboard energy and computation. One successful approach to dealing with this challenge is to use molecular diffusion in combination with cleverly designed sets of possible connections: in DNA tile self-assembly, the particles are equipped with sophisticated bonds that ∗Work from this author was partially supported by National Science Foundation IIS-1553063 and IIS-1619278 1 ensure that only a predesigned shape is produced when mixing together a set of tiles, see [18]. The resulting study of algorithmic tile self-assembly has given rise to an extremely powerful framework and produced a wide range of impressive results. However, the required properties of the building material (which must be specifically designed and finely tuned for each particular shape) in combination with the construction process (which is left to chemical reactions, so it cannot be controlled or stopped until it has run its course) make DNA self-assembly unsuitable for some applications. An alternative method for controlling the eventual position of particles is to apply a uniform external force, causing all particles to move in a given direction until they hit an obstacle or another blocked particle. As two of us (Becker and Fekete, [1]) have shown in the past, combining this approach with custom-made obstacles (instead of custom-made particles) allows complex rearrangements of particles, even in grid-like environments with axis-parallel motion. The appeal of this approach is that it shifts the design complexity from the building material (the tiles) to the machinery (the environment). As recent practical work by Manzoor et al. [15] shows, it is possible to apply this to simple "sticky" particles that can be forced to bond, see Fig. 1: the overall assembly is achieved by adding particles one at a time, attaching them to the existing sub-assembly. Figure 1: A practical demonstration of Tilt Assembly based on alginate (i.e., a gel made by combining a powder derived from seaweed with water) particles [15]. (a) Alginate particles in initial positions. (b) After control moves of (cid:104)e, s, w, n, e, s(cid:105) (for east, south, west, north), the alginate microrobots move to the shown positions. (c) After (cid:104)w, n(cid:105) inputs, the system produces the first multi-microrobot polyomino. (d) The next three microrobot polyominoes are produced after applying multiple (cid:104)e, s, w, n(cid:105) cycles. (e) After the alginate microrobots have moved through the microfluidic factory layout, the final 4-particle polyomino is generated. Moreover, pipelining this process may result in efficient rates of production, see Fig. 2 [15]. One critical issue of this approach is the requirement of getting particles to their destination without being blocked by or bonding to other particles. As Fig. 3 shows, this is not always possible, so there are some shapes that cannot be constructed by Tilt Assembly. This gives rise to a variety of algorithmic questions: (1) Can we decide efficiently whether a given polyomino can be constructed by Tilt Assembly? (2) Can the resulting process be pipelined to yield low 2 ns we Figure 2: (Top left) Initial setup of a seven-tile polyomino assembly; the composed shape is shown enlarged on the lower left. The bipartite decomposition into blue and red particles is shown for greater clarity, but can also be used for better control of bonds. The sequence of control moves is (cid:104)e, s, w, n(cid:105), i.e., a clockwise order. (Bottom left) The situation after 18 control moves. (Right) The situation after 7 full cycles, i.e., after 28 control moves; shown are three parallel "factories". Figure 3: A polyomino (black) that cannot be constructed by Tilt Assembly: the last tile cannot be attached, as it gets blocked by previously attached tiles. amortized building time? (3) Can we compute a maximum-size subpolyomino that can be constructed? (4) What can be said about three-dimensional versions of the problem? 1.1 Our Contribution We present the results shown in Table 1. Dimension Decision 2D (simple) O(N log N ) (Sec. 3) 3D (general) NP-hard (Sec. 5) Approximation Maximization Constructible Path polyAPX -hard Ω(N 1/3), O(√N ) (Sec. 4) O(N log N )(Sec. 4) polyAPX -hard Ω(N 1/3), (Sec. 5) NP-hard - (Sec. 4) Table 1: Results for Tilt Assembly Problem (TAP) and its maximization variant (MaxTAP) 1.2 Related Work Assembling polyominoes with tiles has been considered intensively in the context of tile self-assembly. In 1998, Erik Winfree [18] introduced the abstract tile self-assembly model (aTAM), in which tiles have glue types on each of the four sides and two tiles can stick together if their glue type matches and the bonding strength is sufficient. Starting with a seed tile, tiles will continue to attach to the existing partial assembly 3 ns we until they form a desired polyomino; the process stops when no further attachments are possible. Apart from the aTAM, there are various other models like the two-handed tile self-assembly model (2HAM) [8] and the hierarchical tile self-assembly model [9], in which we have no single seed but pairs of subassemblies that can attach to each other. Furthermore, the staged self-assembly model [10, 11] allows greater efficiency by assembling polyominoes in multiple bins which are gradually combined with the content of other bins. All this differs from the model in Tilt Assembly, in which each tile has the same glue type on all four sides, and tiles are added to the assembly one at a time by attaching them from the outside along a straight line. This approach of externally movable tiles has actually been considered in practice at the microscale level using biological cells and an MRI, see [12], [13], [4]. Becker et al. [5] consider this for the assembly of a magnetic Gauss gun, which can be used for applying strong local forces by very weak triggers, allowing applications such as micro-surgery. Using an external force for moving the robots becomes inevitable at some scale because the energy capacity decreases faster than the energy demand. A consequence is that all non-fixed robots/particles perform the same movement, so all particles move in the same direction of the external force until they hit an obstacle or another particle. These obstacles allow shaping the particle swarm. Designing appropriate sets of obstacles and moves gives rise to a range of algorithmic problems. Deciding whether a given initial configuration of particles in a given environment can be transformed into a desired target configuration is NP-hard [1], even in a grid-like setting, whereas finding an optimal control sequence is shown to be PSPACE-complete by Becker et al. [2]. However, if it is allowed to design the obstacles in the first place, the problems become much more tractable [1]. Moreover, even complex computations become possible: If we allow additional particles of double size (i.e., two adjacent fields), full computational complexity is achieved, see Shad et al. [16]. Further related work includes gathering a particle swarm at a single position [14] and using swarms of very simple robots (such as Kilobots) for moving objects [6]. For the case in which human controllers have to move objects by such a swarm, Becker et al. [3] study different control options. The results are used by Shahrokhi and Becker [17] to investigate an automatic controller. Most recent and most closely related to our paper is the work by Manzoor et al. [15], who use global control to assembly polyominoes in a pipelined fashion: after constructing the first polyomino, each cycle of a small control sequence produces another polyomino. However, the algorithmic part is purely heuristic; providing a thorough understanding of algorithms and complexity is the content of our paper. 2 Preliminaries Polyomino: For a set P ⊂ Z2 of N grid points in the plane, the graph GP is the induced grid graph, in which two vertices p1, p2 ∈ P are connected if they are at unit distance. Any set P with con- nected grid graph GP gives rise to a polyomino by replacing each point p ∈ P by a unit square centered at p, which is called a tile; for simplicity, we also use P to denote the polyomino when the context is clear, and refer to GP as the dual graph of the polyomino; P is tree-shaped, if GP is a tree. A polyomino is called hole-free or simple if and only if the grid graph induced by Z2\P is connected. Blocking sets: For each point p ∈ Z2 we define blocking sets Np, Sp ⊆ P as the set of all points q ∈ P that are above or below p and px − qx ≤ 1. Analogously, we define the blocking sets Ep, Wp ⊆ P as the set of all points q ∈ P that are to the right or to the left of p and py − qy ≤ 1. Construction step: A construction step is defined by a direction (north, east, south, west, abbreviated by n, e, s, w) from which a tile is added and a latitude/longitude l describing a column or row. The tile arrives from (l,∞) for north, (∞, l) for east, (l,−∞) for south, and (−∞, l) for west into the corresponding direction until it reaches the first grid position that is adjacent to one occupied by an existing tile. If there is no such tile, the polyomino does not change. We note that a position p can be added to a polyomino P if and only if there is a point q ∈ P with p − q1 = 1 and one of the four 4 (a) Removing t destroys decomposability. The polyomino can be decomposed by starting with the three tiles above t. (b) Removing the red convex tile leaves the poly- omino non-decomposable; it can be decomposed by starting from the bottom or the sides. Figure 4: Two polyominoes and their convex tiles (white). (a) Removing non-convex tiles may destroy decomposability. (b) In case of non-simple polygons we may not be able to remove convex tiles. blocking sets, Np, Ep, Sp or Wp, is empty. Otherwise, if none of these sets are empty, this position is blocked. Constructibility: Beginning with a seed tile at some position p, a polyomino P is constructible if and only if there is a sequence σ = ((d1, l1), (d2, l2), . . . , (dN−1, lN−1)), such that the resulting polyomino P (cid:48), induced by successively adding tiles with σ, is equal to P . We allow the constructed polyomino P (cid:48) to be a translated copy of P . Reversing σ yields a decomposition sequence, i.e., a sequence of tiles getting removed from P . 3 Constructibility of Simple Polyominoes In this section we focus on hole-free (i.e., simple) polyominoes. We show that the problem of deciding whether a given polyomino can be constructed can be solved in polynomial time. This decision problem can be defined as follows. Definition 1 (Tilt Assembly Problem). Given a polyomino P , the Tilt Assembly Problem ( TAP) asks for a sequence of tiles constructing P , if P is constructible. 3.1 A Key Lemma A simple observation is that construction and (restricted) decomposition are the same problem. This allows us to give a more intuitive argument, as it is easier to argue that we do not lose connectivity when removing tiles than it is to prove that we do not block future tiles. Theorem 2. A polyomino P can be constructed if and only if it can be decomposed using a sequence of tile removal steps that preserve connectivity. A construction sequence is a reversed decomposition sequence. Proof. To prove this theorem, it suffices to consider a single step. Let P be a polyomino and t be a tile that is removed from P into some direction l, leaving a polyomino P (cid:48). Conversely, adding t to P (cid:48) from direction l yields P , as there cannot be any tile that blocks t from reaching the correct position, or we would not be able to remove t from P in direction l. For hole-free polyominoes we can efficiently find a construction/decomposition sequence if one exists. The key insight is that one can greedily remove convex tiles. A tile t is said to be convex if and only if there is a 2 × 2 square solely containing t; see Fig. 4. If a convex tile is not a cut tile, i.e., it is a tile whose removal does not disconnect the polyomino, its removal does not interfere with the decomposability of the remaining polyomino. This conclusion is based on the observation that a minimal cut (i.e., a minimal set of vertices whose removal leaves a disconnected polyomino) of cardinality two in a hole-free polyomino always consists of two (possibly diagonally) adjacent tiles. Furthermore, we can always find such a removable convex tile in any decomposable hole-free polyomino. This allows us to devise a simple greedy algorithm. 5 t We start by showing that if we find a non-blocked convex tile that is not a cut tile, we can simply remove it. It is important to focus on convex tiles, as the removal of non-convex tiles can harm the decomposability: see Fig. 4a for an illustration. In non-simple polyominoes, the removal of convex tiles can destroy decomposability, as demonstrated in Fig. 4b. Lemma 3. Consider a non-blocked non-cut convex tile t in a hole-free polyomino P . The polyomino P − t is decomposable if and only if P is decomposable. Proof. The first direction is trivial: if P − t is decomposable, P is decomposable as well, because we can remove the non-blocked tile t first and afterwards use the existing decomposition sequence for P − t. The other direction requires some case distinctions. Suppose for contradiction that P is decomposable but P − t is not, i.e., t is important for the later decomposition. Consider a valid decomposition sequence for P and the first tile t(cid:48) we cannot remove if we were to remove t in the beginning. W.l.o.g., let t(cid:48) be the first tile in this sequence (removing all previous tiles obviously does not destroy the decomposability). When we remove t first, we are missing a tile, hence t(cid:48) cannot be blocked but has to be a cut tile in the remaining polyomino P − t. The presence of t preserves connectivity, i.e., {t, t(cid:48)} is a minimal cut on P . Because P has no holes, then t and t(cid:48) must be diagonal neighbors, sharing the neighbors a and b. Furthermore, by definition neither of t and t(cid:48) is blocked in some direction. We make a case distinction on the relation of these two directions. The directions are orthogonal (Fig. 5a). Either a or b is a non-blocked convex tile, because t and t(cid:48) are both non-blocked; w.l.o.g., let this be a. It is easy to see that independent of removing t or t(cid:48) first, after removing a we can also remove the other one. The directions are parallel (Fig. 5b). This case is slightly more involved. By assumption, we have a decomposition sequence beginning with t(cid:48). We show that swapping t(cid:48) with our convex tile t in this sequence preserves feasibility. The original sequence has to remove either a or b before it removes t, as otherwise the connection between the two is lost when t(cid:48) is removed first. After either a or b is removed, t becomes a leaf and can no longer be important for connectivity. Thus, we only need to consider the sequence until either a or b is removed. The main observation is that a and b block the same tiles as t or t(cid:48), except for tile c as in Fig. 5b. However, when c is removed, it has to be a leaf, because a is still not removed and in the original decomposition sequence, t(cid:48) has already been removed. Therefore, a tile d (cid:54)= t(cid:48) would have to be removed before c. Hence, the decomposition sequence remains feasible, concluding the proof. Next we show that such a convex tile always exists if the polyomino is decomposable. Lemma 4. Let P be a decomposable polyomino. Then there exists a convex tile that is removable without destroying connectivity. Proof. We prove this by contradiction based on two possible cases. Assume P to be a decomposable polyomino in which no convex tile is removable. Because P is decompos- able, there exists some feasible decomposition sequence S. Let Pconvex denote the set of convex tiles of P and let t ∈ Pconvex be the first removed convex tile in the decomposition sequence S. By assumption, t cannot be removed yet, so it is either blocked or a cut tile. t is blocked. Consider the direction in which we would remove t. If it does not cut the polyomino, the last blocking tile has to be convex (and would have to be removed before t), see Fig. 6a. If it cuts the polyomino, the component cut off also must have a convex tile and the full component has to be removed before t, see Fig. 6b. This is again a contradiction to t being the first convex tile to be removed in S. t is a cut tile. P − t consists of exactly two connected polyominoes, P1 and P2. It is easy to see that P1 ∩ Pconvex (cid:54)= ∅ and P2 ∩ Pconvex (cid:54)= ∅, because every polyomino of size n ≥ 2 has at least two convex tiles of which at most one becomes non-convex by adding t. (A polyomino of size 1 is trivial.) Before being able to remove t, either P1 or P2 has to be completely removed, including their convex tiles. This is a contradiction to t being the first convex tile in S to be removed. 6 (a) If the unblocked directions of t and t(cid:48) are orthogo- nal, one of the two adjacent tiles (w.l.o.g. a) cannot have any further neighbors. There can also be no tiles in the upper left corner, because the polyomino cannot cross the two free directions of t and t(cid:48) (red marks). (b) If the unblocked directions of t and t(cid:48) are parallel, there is only the tile c for which something can change if we remove t before t(cid:48). Figure 5: The red marks indicate that no tile is at this position; the dashed outline represents the rest of the polyomino. (a) If the removal direction of t is not crossed, the last blocking tile has to be convex (and has to be removed before). (b) If the removal direction of t crosses P , then P gets split into components A and B. Component B has a convex tile t(cid:48) that needs to be removed before t. Figure 6: Polyominoes for which no convex tile should be removable, showing the contradiction to t being the first blocked convex tile in P getting removed. 3.2 An Efficient Algorithm An iterative combination of these two lemmas proves the correctness of greedily removing convex tiles. As we show in the next theorem, using a search tree technique allows an efficient implementation of this greedy algorithm. Theorem 5. A hole-free polyomino can be checked for decomposability/constructibility in time O(N log N ). Proof. Lemma 3 allows us to remove any convex tile, as long as it is not blocked and does not destroy connectivity. Applying the same lemma on the remaining polyomino iteratively creates a feasible decomposition sequence. Lemma 4 proves that this is always sufficient. If and only if we can at some point no longer find a matching convex tile (to which we refer as candidates), the polyomino cannot be decomposable. Let B be the time needed to check whether a tile t is blocked. A naıve way of doing this is to try out all tiles and check if t gets blocked, requiring time O(N ). With a preprocessing step, we can decrease B to O(log N ) by using O(N ) binary search trees for searching for blocking tiles and utilizing that removing a tile can change the state of at most O(1) tiles. For every vertical line x and horizontal line y going through P , we create a balanced search tree, i.e., for a total of O(N ) search trees. An x-search tree for a vertical line x contains tiles lying on x, sorted by their y-coordinate. Analogously define a y-search tree for a horizontal line y containing tiles lying on y sorted by their x-coordinate. We iterate over all tiles t = (x, y) and insert the 7 tt0batt0bcdattt0AB Figure 7: When removing the red tile, only the orange tiles can become unblocked or convex. tile in the corresponding x- and y-search tree with a total complexity of O(N log N ). Note that the memory complexity remains linear, because every tile is in exactly two search trees. To check if a tile at position (x(cid:48), y(cid:48)) is blocked from above, we can simply search in the (x(cid:48) − 1)-, x(cid:48)- and (x(cid:48) + 1)-search tree for a tile with y > y(cid:48). We analogously perform search queries for the other three directions, and thus have 12 queries of total cost O(log N ). We now iterate on all tiles and add all convex tiles that are not blocked and are not a cut tile to the set F (cost O(N log N )). Note that checking whether a tile is a cut tile can be done in constant time, because it suffices to look into the local neighborhood. While F is not empty, we remove a tile from F , from the polyomino, and from its two search trees in time O(log N ). Next, we check the up to 12 tiles that are blocked first from the removed tile for all four orientations, see Fig. 7. Only these tiles can become unblocked or a convex tile. Those that are convex tiles, not blocked and no cut tile are added to F . All tiles behind those cannot become unblocked as the first tiles would still be blocking them. The cost for this is again in O(log N ). This is continued until F is empty, which takes at most O(N ) loops each of cost O(log N ). If the polyomino has been decomposed, the polyomino is decomposable/constructible by the corresponding tile sequence. Otherwise, there cannot exist such a sequence. By prohibiting to remove a specific tile, one can force a specific start tile. 3.3 Pipelined Assembly Given that a construction is always possible based on adding convex corners to a partial construction, we can argue that the idea of Manzoor et al. [15] for pipelined assembly can be realized for every constructible polyomino: We can transform the construction sequence into a spiral-shaped maze environment, as illustrated in Fig. 8. This allows it to produce D copies of P in N + D cycles, implying that we only need 2N cycles for N copies. It suffices to use a clockwise order of four unit steps (west, north, east, south) in each cycle. The main idea is to create a spiral in which the assemblies move from the inside to the outside. The first tile is provided by an initial south movement. After each cycle, ending with a south movement, the next seed tile of the next copy of P is added. For every direction corresponding to the direction of the next tile added by the sequence, we place a tile depot on the outside of the spiral, with a straight-line path to the location of the corresponding attachment. Theorem 6. Given a construction sequence σ := ((d1, l1), . . . , (dN−1, lN−1)) that constructs a polyomino P , we can construct a maze environment for pipelined tilt assembly, such that constructing D copies of P needs O(N + D) unit steps. In particular, constructing one copy of P can be done in amortized time O(1). Proof. Consider the construction sequence σ, the movement sequence ζ consisting of N repetitions of the cycle (w, n, e, s), and an injective function m : σ → ζ, with m((w,·)) = e, m((n,·)) = s, m(e,·)) = w and m((s,·)) = n. We also require that m((di, li)) = ζj if for all i(cid:48) < i there is a j(cid:48) < j with m((di(cid:48), li(cid:48))) = ζj(cid:48) and j is smallest possible. This implies that in each cycle there is at least one tile in σ mapped to one direction in this cycle. 8 Figure 8: (Left) A polyomino P . Shown is the assembly order and the direction of attachment to the seed (tile 0). (Right) A maze environment for pipelined construction of the desired polyomino P . After the fourth cycle, each further cycle produces a new copy of P . Labyrinth construction: The main part of the labyrinth is a spiral as can be seen in Fig. 8. Consider a spiral that is making ζ many turns, and the innermost point q of this spiral. From q upwards, we make a lane through the spiral until we are outside the spiral. At this point we add a depot of tiles, such that after each south movement a new tile comes out of the depot (this can easily be done with bottleneck constructions as seen in Fig. 8 or in [15]). Then, we proceed for each turn in the spiral as follows: For the j-th turn, if m−1(ζj) is empty we do nothing. Else if m−1(ζj) is not empty we want to add the next tile. Let ti be this particular tile. Then, we construct a lane in direction −ζj, i.e., the direction from where the tile will come from, until we are outside the spiral. By shifting this line in an orthogonal direction we can enforce the tile to fly in at the correct position relating to li. There, we add a depot with tiles, such that the first tile comes out after j − 1 steps and with each further cycle a new tile comes out (this can be done by using loops in the depot, see Fig. 8 or [15]). Depots, which lie on the same side of the spiral, can be shifted arbitrarily, so they do not collide. These depots can be made arbitrarily big, and thus, we can make as many copies of P as we wish. Note that we can make the paths in the spiral big enough, such that after every turn the bounding box of the current polyomino fits through the spiral. Correctness: We will now show that we will obtain copies of P . Consider any j-th turn in the spiral, where the i-th tile ti is going to be added to the current polyomino. With the next step, ti and the polyomino move in direction ζj. While the polyomino does not touch the next wall in the spiral, the distance between ti and the polyomino will not decrease. However when the polyomino hits the wall the polyomino stops moving and ti continues moving towards the polyomino. Wall-hitting is the same situation as in our non-parallel model: To a fixed polyomino we can add tiles from n, e, s or w. Therefore, the tile connects to the correct place. Since this is true for any tile and any copy, we conclude that every polyomino we build is indeed a copy of P . Time: Since the spiral has at most 4N unit steps (or N cycles), the first polyomino will be constructed after 4N unit steps. By construction, we began the second copy one cycle after beginning the first copy, the third copy one cycle after the second, and so on. This means, after each cycle, when the first 9 01675432 Figure 9: Two different sequences. The red tile represents the bounding box of the current polyomino. (Left) A desired sequence. The latitude intersects the bounding box. (Right) A sequence where the latitude does not intersect the bounding box. polyomino is constructed, we obtain another copy of P . Therefore, for D copies we need N + D cycles (or O(N + D) unit steps). For D ∈ Ω(N ) this results in an amortized constant time construction for P . Note that this proof only considers construction sequences in the following form: If a tile ti increases the side length of the bounding box of the current polyomino, then the tile is added from a direction with a longitude/latitude, such that the longitude/latitude intersects the bounding box (see Fig. 9). In the case there is a tile, such that the longitude/latitude does not intersect the bounding box, then we can rotate the direction by π 2 towards the polyomino and we will have a desired construction sequence. 4 Optimization Variants in 2D For polyominoes that cannot be assembled, it is natural to look for a maximum-size subpolyomino that is constructible. This optimization variant is polyAPX-hard, i.e., we cannot hope for an approximation algorithm with an approximation factor within Ω(N 3 ), unless P = NP. 1 Definition 7 (Maximum Tilt Assembly Problem). Given a polyomino P , the Maximum Tilt Assembly Problem ( MaxTAP) asks for a sequence of tiles building a cardinality-maximal connected subpolyomino P (cid:48) ⊆ P . Theorem 8. MaxTAP is polyAPX-hard, even for tree-shaped polyominoes. Proof. We reduce Maximum Independent Set (MIS) to MaxTAP; see Fig. 10 for an illustration. Consider an instance G = (V, E) of MIS, which we transform into a polyomino PG. We construct PG as follows. Firstly, construct a horizontal line from which we go down to select which vertex in G will be chosen. The line must have length 10n − 9, where n = V . Every 10th tile will represent a vertex, starting with the first tile on the line. Let ti be such a tile representing vertex vi. For every vi we add a selector gadget below ti and for every {vi, vj} ∈ δ(vi) we add a reflected selector gadget below tj, as shown in Fig. 10, each consisting of 19 tiles. Note that all gadgets for selecting vertex vi are above the gadgets of vj if i < j and that there are at most n2 such gadgets. After all gadgets have been constructed, we have already placed at most 19n2 + 10n− 9 ≤ 29n2 tiles. We continue with a vertical line with a length of 30n2 tiles. Now let α∗ be an optimal solution to MIS. Then MaxTAP has a maximum polyomino of size at least 30n2α∗ and at most 30n2α∗ + 29n2: We take the complete vertical part of ti for every vi in the optimal solution of MIS. Choosing other lines block the assembly of further lines and thus, yields a smaller solution. Now suppose we had an N 1−ε-approximation for MaxTAP. Then we would have a solution of at least N 1−ε T ∗, where T ∗ is the optimal solution. We know that an optimal solution has T ∗ ≥ 30n2α∗ tiles and the polyomino has at most N ≤ 30n3 + 29n2 ≤ 59n3 tiles. Therefore, we have at least 591−εn3−3ε tiles and thus at least 3 + η for any η > 0, 591/3n1−3η α∗ which results in an n1−δ-approximation for MIS, contradicting the then the number of strips is inapproximability of MIS (unless P=NP) shown by Berman and Schnitger [7]. 591−εn3−3ε α∗ strips, because each strips is 30n2 tiles long. Consider some ε ≥ 2 30n2α∗ 1 1 1 As a consequence of the construction, we get Corollary 9. 10 0101 Figure 10: Reduction from MIS to MaxTAP. (Left) A graph G with four vertices. (Right) A polyomino constructed for the reduction with a feasible, maximum solution marked in grey. Corollary 9. Unless P = N P , MaxTAP cannot be approximated within a factor of Ω(N 1 3 ). On the positive side, we can give an O(√N )-approximation algorithm. Theorem 10. The longest constructible path in a tree-shaped polyomino P is a √N -approximation for MaxTAP, and we can find such a path in polynomial time. Proof. Consider an optimal solution P ∗ and a smallest enclosing box B containing P ∗. Then there must be two opposite sides of B having at least one tile of P ∗. Consider the path S between both tiles. Because the area AB of B is at least the number of tiles in P ∗, S ≥ √AB and a longest, constructible path in P has length at least S, we conclude that the longest constructible path is a √N -approximation. To find such a path, we can search for every path between two tiles, check whether we can build this path, and take the longest, constructible path. Checking constructibility for O(N 2) possible paths is rather expensive. However, we can efficiently approx- imate the longest constructible path in a tree-shaped polyomino with the help of sequentially constructible paths, i.e., the initial tile is a leaf in the final path. Theorem 11. We can find a constructible path in a tree-shaped polyomino in O(N 2 log N ) time that has a length of at least half the length of the longest constructible path. Proof. We only search for paths that can be built sequentially. Clearly, the longest such path is at least half as long as the longest path that can have its initial tile anywhere. We use the same search tree technique as before to look for blocking tiles. Select a tile of the polyomino as the initial tile. Do a depth-first search and for every tile in this search, check if it can be added to the path. If it cannot be added, skip all deeper tiles, as they also cannot be added. During every step in the depth-first search, we only need to change a single tile in the search trees, doing O(1) updates with O(log N ) cost. As we only consider O(N ) vertices in the depth-first search, this results in a cost of O(N log N ) for a fixed start tile. It is trivial to keep track of the longest such constructible path. Repeating this for every tile results in a running time of O(N 2 log N ). In tree-shaped polyominoes, finding a constructible path is easy. For simple polyominoes, additional arguments and data structures lead to a similar result. Theorem 12. In simple polyominoes, finding the longest of all shortest paths that are sequentially constructible takes O(N 2 log N ) time. 11 v1v2v4v3v1v2v3v4 Before we start with the proof of Theorem 12, we show in the next two lemmas that it is sufficient to consider shortest paths only, and that we can restrict ourselves to one specific shortest path between two tiles. Hence, we just need to test a maximum of O(n2) different paths. Lemma 13. In a sequentially constructible path, if there is a direct straight connection for a subpath, the subpath can be replaced by the straight connection. Figure 11: A subpath W (cid:48) and its shortcut L in green. To block L, A and B must exist. But then, either p0 or p1 (red tiles) will also be blocked. Therefore, also W (cid:48) cannot be built. Proof. Consider a sequentially constructible path W and a subpath W (cid:48) ⊂ W that has a straight line L connecting the startpoint and the endpoint of W (cid:48). W.l.o.g., L is a vertical line and we build from bottom to top. Assume that (W\W (cid:48)) ∪ L is not constructible. Then at least two structures (which can be single tiles) A and B must exist, preventing us from building L. Furthermore, these structures have to be connected via a path (AB or BA, see Fig. 11). We observe that none of these connections can exist or otherwise, we cannot build W (if AB exist, we cannot build the last tile p0 of L; if BA exist, we cannot build the first tile p1 of W (cid:48)). Therefore, we can replace W (cid:48) with L. By repeating the construction of Lemma 13 we get a shortest path from tile t1 to t2 in the following form: Let P1, . . . , Pk be reflex tiles on the path from t1 to t2. Furthermore, for every 1 ≤ i ≤ k − 1, the path from Pi to Pi+1 is monotone. This property holds for every shortest path, or else we can use shortcuts as in Lemma 13. Lemma 14. If a shortest path between two tiles is sequentially constructible, then every shortest path between these two tiles is sequentially constructible. Proof. Consider a constructible shortest path W , a maximal subpath W (cid:48) that is x-y-monotone, and a bounding box B around W (cid:48). Due to L1-metric, any x-y-monotone path within B is as long as W (cid:48). Suppose some path within B is not constructible. Then we can use the same blocking argument as in Lemma 13 to prove that W (cid:48) cannot be constructible as well, contradicting that W is constructible. Using Lemma 13 and Lemma 14, we are ready to prove Theorem 12. Proof of Theorem 12. Because it suffices to check one shortest path between two tiles, we can look at the BFS tree from each tile and then proceed like we did in Theorem 11. Thus, for each tile we perform a BFS in time O(N ) and a DFS with blocking look-ups in time O(N log N ), which results in a total time of O(N 2 log N ). 12 LABABBAp0p1W' 5 Three-Dimensional Shapes An interesting and natural generalization of TAP is to consider three-dimensional shapes, i.e., polycubes. The local considerations for simply connected two-dimensional shapes are no longer sufficient. In the following we show that deciding whether a polycube is constructible is NP-hard. Moreover, it is NP-hard to check whether there is a constructible path from a start cube s to an end cube t in a partial shape. As a stepping stone, we start with a restricted version of the three-dimensional problem. Theorem 15. It is NP-hard to decide if a polycube can be built by inserting tiles only from above, north, east, south, and west. Figure 12: Top-view on the polycube. There is a vertical part going south for the true and false assignment of each variable. We start building at the top layer (blue) and have to block either the true or the false part of each variable from above. The blocked parts have to be built with only inserting from east, west, and south. For each clause, the parts of the inverted literals are modified to allow at most two of them being built in this way. All other parts can simply be inserted from above in the end. Proof. We prove hardness by a reduction from 3SAT. A visualization for the formula (x1 ∨ x2 ∨ x3) ∧ (x2 ∨ x3 ∨ x4)∧ (x1 ∨ x3 ∨ x4) can be seen in Fig. 12. It consists of two layers of interest (and some further auxiliary ones for space and forcing the seed tile by using the one-way gadget shown in Fig. 14). In the beginning, one has to build a part of the top layer (highlighted in blue in the example, details in Fig. 13 (Right)). Forcing a specific start tile can be done by a simple construction. For each variable we have to choose to block the left (for assigning true) or the right (for assigning false) part of the lower layer. In the end, the remaining parts of the upper layer can trivially be filled from above. The blocked parts of the lower layer then have to be built with only inserting tiles from east, south, or west. In the end, the non-blocked parts can be filled in from above. For each clause we use a part (as shown in Fig. 13 (Left)) that allows only at most two of its three subparts to be built from the limited insertion directions. We attach these subparts to the three variable values not satisfying the clause, i.e., the negated literals. This forces us to leave at least one negated 13 x1x1x2x2x3x3x4x4x1_x2_x3x2_x3_x4x1_x3_x4nesw Figure 13: Top-view on the polycube. (Left) In the beginning we have to block the access from the top for either the true or false part of the variable. The variable is assigned the blocked value. (Right) Three gadgets for a clause. Only two of them can be built if the tiles are only able to come from the east, south, and west. literal of the clause unblocked, and thus at least one literal of the clause to be true. Overall, this allows us to build the blocked parts of the lower layers only if the blocking of the upper level corresponds to a satisfying assignment. If we can build the true and the false parts of a variable in the beginning, any truth assignment for the variable is possible. Figure 14: (Left) This polyomino can only be constructed by starting at "in" and ending at "out". (Right) By adding layers above (white) and below (black) this polyomino starting at the "out"-tile, we obtain a polycube that is only constructible by starting at "in" (from the other direction we must build the black and white layer first and must then build the grey layer with 2D directions). Triangles denote where we can switch to another layer. With this gadget we can enforce a seed tile. The construction can be extended to assemblies with arbitrary direction. Theorem 16. It is NP-hard to decide if a polycube can be built by inserting tiles from any direction. 14 x1truefalsetruefalsex2inoutinout Proof. We add an additional layer below the construction in Theorem 15 that has to be built first and blocks access from below. Forcing the bottom layer to be built first can again be done with the one-way gadget shown in Fig. 14. The difficulties of construction in 3D are highlighted by the fact that even identifying constructible connections between specific positions is NP-hard. Theorem 17. It is NP-hard to decide whether a path from one tile to another can be built in a general polycube. Figure 15: (Left) Circuit representation for the SAT formula (x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x4) ∧ (x2 ∨ x3 ∨ x4) ∧ (x1 ∨ x3 ∨ x4) ∧ (x1 ∨ x2 ∨ x4). (Right) Reduction from SAT formula. Boxes represent variable boxes. Proof. We prove NP-hardness by a reduction from SAT. For each variable we have two vertical lines, one for the true setting, one for the false setting. Each clause gets a horizontal line and is connected with a variable if it appears as literal in the clause, see Fig 15 (Left). We transform this representation into a tour problem where, starting at a point s, one first has to go through either the true or false line of each variable and then through all clause lines, see Fig. 15 (Right). The clause part is only passable if the path in at least one crossing part (squares) does not cross, forcing us to satisfy at least one literal of a clause. As one has to go through all clauses, t is only reachable if the selected branches for the variables equal a satisfying variable assignment for the formula. We now consider how to implement this as a polycube. The only difficult part is to allow a constructible clause path if there is a free crossing. In Fig. 16 (Left), we see a variable box that corresponds to the crossing of the variable path at the squares in Fig. 15 (Right). It blocks the core from further insertions. The clause path has to pass at least one of these variable boxes in order to reach the other side. See Fig. 15 (Right) for an example. Note that the corresponding clause parts can be built by inserting only from above and below, so there are no interferences. 6 Conclusion/Future Work We have provided a number of algorithmic results for Tilt Assembly. Various unsolved challenges remain. What is the complexity of deciding TAP for non-simple polyominoes? While Lemma 4 can be applied to all polyominoes, we cannot simply remove any convex tile. Can we find a constructible path in a polyomino from a given start and endpoint? This would help in finding a √N -approximation for non-simple polyominoes. How can we optimize the total makespan for constructing a shape? And what options exist for non-constructible shapes? 15 ANDx1x2x3x4x1x3x4x2st Figure 16: (Left) Empty variable box. (Right) A clause line (blue) dips into a variable box. If the variable box is built, then we cannot build the dip of the clause line. An interesting approach may be to consider staged assembly, as shown in Fig. 17, where a shape gets constructed by putting together subpolyominoes, instead of adding one tile at a time. This is similar to staged tile self-assembly [10, 11]. This may also provide a path to sublinear assembly times, as a hierarchical assembly allows massive parallelization. We conjecture that a makespan of O(√N ) for a polyomino with N tiles can be achieved. All this is left to future work. Figure 17: (Left) A polyomino that cannot be constructed in the basic TAP model. (Right) Construction in a staged assembly model by putting together subpolyominoes. References [1] A. T. Becker, E. D. Demaine, S. P. Fekete, G. Habibi, and J. McLurkin. Reconfiguring massive particle swarms with limited, global control. In Proceedings of the International Symposium on Algorithms and Experiments for Sensor Systems, Wireless Networks and Distributed Robotics (ALGOSENSORS), pages 51–66, 2013. [2] A. T. Becker, E. D. Demaine, S. P. Fekete, and J. McLurkin. Particle computation: Designing worlds to control robot swarms with only global signals. In Proceedings IEEE International Conference on Robotics and Automation (ICRA), pages 6751–6756, 2014. [3] A. T. Becker, C. Ertel, and J. McLurkin. Crowdsourcing swarm manipulation experiments: A massive online user study with large swarms of simple robots. In Proceedings IEEE International Conference on Robotics and Automation (ICRA), pages 2825–2830, 2014. [4] A. T. Becker, O. Felfoul, and P. E. Dupont. Simultaneously powering and controlling many actuators with a clinical MRI scanner. In Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 2017–2023, 2014. [5] A. T. Becker, O. Felfoul, and P. E. Dupont. Toward tissue penetration by MRI-powered millirobots using a self-assembled Gauss gun. In Proceedings IEEE International Conference on Robotics and Automation (ICRA), pages 1184–1189, 2015. 16 [6] A. T. Becker, G. Habibi, J. Werfel, M. Rubenstein, and J. McLurkin. Massive uniform manipulation: In Proceedings of the Controlling large populations of simple robots with a common input signal. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 520–527, 2013. [7] P. Berman and G. Schnitger. On the complexity of approximating the independent set problem. Information and Computation, 96(1):77–94, 1992. [8] S. Cannon, E. D. Demaine, M. L. Demaine, S. Eisenstat, M. J. Patitz, R. Schweller, S. M. Summers, and A. Winslow. Two hands are better than one (up to constant factors). In Proc. Int. Symp. on Theoretical Aspects of Computer Science(STACS), pages 172–184, 2013. [9] H.-L. Chen and D. Doty. Parallelism and time in hierarchical self-assembly. SIAM Journal on Computing, 46(2):661–709, 2017. [10] E. D. Demaine, M. L. Demaine, S. P. Fekete, M. Ishaque, E. Rafalin, R. T. Schweller, and D. L. Souvaine. Staged self-assembly: nanomanufacture of arbitrary shapes with O(1) glues. Natural Computing, 7(3):347–370, 2008. [11] E. D. Demaine, S. P. Fekete, C. Scheffer, and A. Schmidt. New geometric algorithms for fully connected staged self-assembly. Theoretical Computer Science, 671:4–18, 2017. [12] P. S. S. Kim, A. T. Becker, Y. Ou, A. A. Julius, and M. J. Kim. Imparting magnetic dipole heterogeneity to internalized iron oxide nanoparticles for microorganism swarm control. Journal of Nanoparticle Research, 17(3):1–15, 2015. [13] P. S. S. Kim, A. T. Becker, Y. Ou, M. J. Kim, et al. Swarm control of cell-based microrobots using a single global magnetic field. In Proceedings of the International Conference on Ubiquitous Robotics and Ambient Intelligence (URAI), pages 21–26, 2013. [14] A. V. Mahadev, D. Krupke, J.-M. Reinhardt, S. P. Fekete, and A. T. Becker. Collecting a swarm in a grid environment using shared, global inputs. In Proc. IEEE Int. Conf. Autom. Sci. and Eng. (CASE), pages 1231–1236, 2016. [15] S. Manzoor, S. Sheckman, J. Lonsford, H. Kim, M. J. Kim, and A. T. Becker. Parallel self-assembly of polyominoes under uniform control inputs. IEEE Robotics and Automation Letters, 2(4):2040–2047, 2017. [16] H. M. Shad, R. Morris-Wright, E. D. Demaine, S. P. Fekete, and A. T. Becker. Particle computation: Device fan-out and binary memory. In Proceedings IEEE International Conference on Robotics and Automation (ICRA), pages 5384–5389, 2015. [17] S. Shahrokhi and A. T. Becker. Stochastic swarm control with global inputs. In Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 421–427, 2015. [18] E. Winfree. Algorithmic self-assembly of DNA. PhD thesis, California Institute of Technology, 1998. 17
1909.12760
2
1909
2019-10-14T11:12:14
Beating Greedy for Stochastic Bipartite Matching
[ "cs.DS" ]
We consider the maximum bipartite matching problem in stochastic settings, namely the query-commit and price-of-information models. In the query-commit model, an edge e independently exists with probability $p_e$. We can query whether an edge exists or not, but if it does exist, then we have to take it into our solution. In the unweighted case, one can query edges in the order given by the classical online algorithm of Karp, Vazirani, and Vazirani to get a $(1-1/e)$-approximation. In contrast, the previously best known algorithm in the weighted case is the $(1/2)$-approximation achieved by the greedy algorithm that sorts the edges according to their weights and queries in that order. Improving upon the basic greedy, we give a $(1-1/e)$-approximation algorithm in the weighted query-commit model. We use a linear program (LP) to upper bound the optimum achieved by any strategy. The proposed LP admits several structural properties that play a crucial role in the design and analysis of our algorithm. We also extend these techniques to get a $(1-1/e)$-approximation algorithm for maximum bipartite matching in the price-of-information model introduced by Singla, who also used the basic greedy algorithm to give a $(1/2)$-approximation.
cs.DS
cs
Beating Greedy for Stochastic Bipartite Matching Buddhima Gamlath EPFL Sagar Kale EPFL Ola Svensson EPFL [email protected] [email protected] [email protected] Abstract We consider the maximum bipartite matching problem in stochastic settings, namely the query-commit and price-of-information models. In the query-commit model, an edge e independently exists with probability pe. We can query whether an edge exists or not, but if it does exist, then we have to take it into our solution. In the unweighted case, one can query edges in the order given by the classical online algorithm of Karp, Vazirani, and Vazirani [KVV90] to get a (1 − 1/e)-approximation. In contrast, the previously best known algorithm in the weighted case is the (1/2)-approximation achieved by the greedy algorithm that sorts the edges according to their weights and queries in that order. Improving upon the basic greedy, we give a (1 − 1/e)-approximation algorithm in the weighted query-commit model. We use a linear program (LP) to upper bound the optimum achieved by any strategy. The proposed LP admits several structural properties that play a crucial role in the design and analysis of our algorithm. We also extend these techniques to get a (1 − 1/e)-approximation algorithm for maximum bipartite matching in the price-of- information model introduced by Singla [Sin18], who also used the basic greedy algorithm to give a (1/2)-approximation. 1 Introduction Maximum matching is an important problem in theoretical computer science. We consider it in the query-commit and price-of-information models. These settings model the situation where the input is random, but we can know a specific part of the input by incurring some cost, which is explicit in the price-of-information setting, i.e., pay πe to know the weight of the edge e, and implicit in the query-commit, i.e., the algorithm queries existence of e, and if e exists, the algorithm has to take e into its solution. We formalize this now. In the query-commit model, an edge e independently exists with probability pe. We can query whether an edge exists or not, but if it does exist, then we have to take it into our solution (hence the name query-commit). So, specifically, for the matching problem, if M is our current matching, then we cannot query an edge e if it intersects with M . In the price-of-information model introduced by Singla [Sin18], edge weights are random variables and we can query for the weight We of an edge e by paying a (fixed) cost πe. We want to query a set Q of edges and output a matching M ⊆ Q such that W (M ) −Pe∈Q πe is maximized. In the query-commit model, for bipartite graphs, one can query edges in the order given by the classical algorithm of Karp, Vazirani, and Vazirani [KVV90] to get a (1−1/e) approximation. However, in the more general weighted query-commit setting where an edge e exists with weight we with probability pe and does not exist with probability 1 − pe, it is not clear how to use such a strategy. In fact, prior to our work, the best algorithm for the weighted setting was the basic greedy that sorts the edges by weight we and then queries in that order to get a 1 (1/2)-approximate matching. Similarly, in the price-of-information setting, Singla gave a (1/2)- approximation algorithm based on the greedy approach. In this work, we beat the greedy algorithm using new techniques and give clean algorithms that achieve an approximation ratio of 1 − 1/e (improving from 1/2) in the settings of weighted query-commit as well as price-of- information. A key component of our approach is to upper bound the optimum achieved by any strategy using a linear program (LP), and exploit several structural properties of this LP in the design of our algorithms. We now give a high level description of these techniques. Techniques We first solve the weighted query-commit version, and this part of the paper contains the essential ideas. We then expand on these ideas to solve the price-of-information version1. Let us first focus on the weighted query-commit setting. Here, the input is a bipartite graph G = (A, B, E), and for each e ∈ E, its existence probability pe and weight we. Our goal is to design a polynomial-time algorithm that gives a sequence of edges to query such that after the last query, we end up with a matching of large weight. First, to get a handle on the expected value of an optimum strategy (OPT), consider the linear program (LP) below. For a vertex u, let Eu be the set of edges incident to u. Maximize Xe∈E subject to Xe∈F xe · we, xe 6 Pr[an edge in F exists] , for all u ∈ A ∪ B and for all F ⊆ Eu , xe > 0 , for all e ∈ E . Hence, Pe∈F x′ Let x′ e be the probability that OPT solution contains e. Since OPT can have at most one edge incident to u, for any F ⊆ Eu, the events in {OPT contains e : e ∈ F } are disjoint. e is the probability that OPT contains an edge in F , which must be at most the probability that at least one edge in F exists. Therefore, (x′ e)e∈E has to satisfy the above LP. We can solve this LP in polynomial time using a subdmodular-function-minimization algorithm as a separation oracle for the ellipsoid algorithm. Let x∗ be the solution. For a u ∈ A, if we restrict x∗ to Eu to get, say, x∗ u as a convex combination of extreme points of the polytope u, we can write x∗ (x ∈ REu + : Xe∈F xe 6 Pr[an edge in F exists] ∀F ⊆ Eu) . (1) A key part of our approach is the nice structural properties of extreme points: the subsets corresponding to the tight constraints for an extreme point y of the above polytope form a chain over a subset of Eu, because the right hand side of the constraints is strictly submodular. For a y, if we query the edges in the order given by its chain then it can be proved that we commit to an edge e ∈ Eu with probability ye. Since x∗ u can be written as a convex combination of such extreme points, if we select an extreme point with probability equal to its coefficient in the convex combination and query the edges in the order given by its chain, we commit to an edge e ∈ Eu with probability x∗ e. See Figure 1. But if we do this independently for each vertex in A, then we end up with collisions on B, so we have to do contention resolution there. 1Actually, we implicitly use "multiple-weight query-commit" as an intermediate step, where an edge has nonnegative random weight, and an algorithm can ask queries of the form "is weight of e greater than c," and if it is, then the algorithm has to add e to its solution. Then we use a reduction by Singla to reduce from price-of-information. 2 A B u 4/9 2/9 b1 b2 b3 Let p{u,b2} = 1/2. Let p{u,b2} = 1/3. Figure 1: Here, we have Eu = {{u, b2}, {u, b3}}. We write x∗ u = (4/9, 2/9) as a con- vex combination of extreme points of the polytope described in Equation (1): x∗ u = (2/3)(1/2, 1/6)+(1/3)(1/3, 1/3). For (1/2, 1/6), the inequalities corresponding to sets {{u, b2}} and {{u, b2}, {u, b3}} are tight, and for (1/3, 1/3), the inequalities corresponding to sets {{u, b3}} and {{u, b2}, {u, b3}} are tight. Observe that these form a chain. We note that it is possible that an inequality corresponding to a nonnegativity constraint is tight. Now, say we query the edges in the order given by the chain. For (1/2, 1/6), we first query {u, b2} then {u, b3}, so we select {u, b2} with probability p{u,b2} = 1/2 and {u, b3} with probability (1 − p{u,b2})p{u,b3} = 1/6, which does indeed correspond to the extreme point (1/2, 1/6). Effectively, for each vertex in v ∈ B, its neighbor u arrives independently with probability x∗ uv and weight wuv, and it has to pick one neighbor so that its expected utility is close to uv · wuv. This setting is similar to the prophet secretary problem, and we extend the ideas of Ehsani et al. [EHKS18] to achieve this. Puv x∗ To generalize this from two-point distributions to multi-point distributions, we think of an edge e to have as many copies as the values its weight can take. But now instead of being independent, the existence of these copies is correlated. To handle this, we write a more general LP with constraints corresponding to sets that are from a lattice family. We can solve submodular-function-minimization over a lattice family in polynomial time [GLS81], which gives us a separation oracle for this LP. Also, the extreme points of the polytope defined by constraints for a left-hand-side vertex correspond to a chain with properties similar to the two-point-distribution case (see Lemma 12). Once we have a query-commit algorithm for multi-point distributions, we can basically get for each edge e with weight a price-of-information algorithm by a clean reduction [Sin18]: given by the random variable Xe and probing cost πe, let τe be the solution to the equation E[max{(Xe − τe), 0}] = πe, and let Ye = min(Xe, τe) be a new random variable. Now run the query-commit algorithm with Ye, and whenever the algorithm queries any copy of the edge e, we probe e, and we only pay πe the first time we probe that edge. Organization of the Paper Next, we review the related work. In Section 2, we see the weighted query-commit algorithm; we then extend it to the price-of-information setting in Section 3. Related Work As mentioned earlier, the algorithm of Karp et al. gives a (1 − 1/e) = 0.632 approximation in the unweighted query-commit model for bipartite graphs. Costello et al. [CTT12] give a 3 0.573-approximation for general graphs and show that no algorithm can give an approximation better than 0.898 compared to the optimal offline algorithm (that knows all the outcomes before selecting the matching). Motivated by applications in kidney exchange and online dating, Chen et al. [CIK+09] consider the matching problem in the query-commit model with further constraint that for each vertex v, the algorithm can query at most tv edges incident to it (tv is a part of the input) and give a (1/4)-approximation algorithm. Bansal et al. [BGL+12] improve it to (1/3) for bipartite graphs and to (1/3.46) for general graphs, and also give a (1/4)-approximation in the weighted query-commit (for general graphs); both of these ratios for the unweighted case are further improved by Adamczyk et al. [AGM15], who give a (1/3.709)-approximation for general graphs. Baveja et al. [BCN+17] improve this to 1/3.224. We mention that this setting is more general than the setting we consider, because tv = deg(v) for us, i.e., we do not put any restriction on the number of edges incident to a vertex that we can query. Molinaro and Ravi [MR11] give an optimal algorithm for a very special class of sparse graphs in the unweighted query-commit setting. Blum et al. [BDH+15] consider the maximum matching problem, where, in the input graph, an edge e exists with probability pe, the algorithm can query the existence of an edge and does not have to commit, but needs to minimize the number of queries subject to outputting a good approximation. This model is considered in several follow-up works [AKL16, AKL17, MY18, BR18]. Further Related Work in Other Stochastic Models Feldman et al. [FMMM09] consider an online variant of stochastic matching where the algorithm gets as input a bipartite graph G = (A, B, E), and a distribution D over B, and n elements are drawn i.i.d from B according to D (so there may be repetitions) that the algorithm accesses online. When a copy v ∼ D arrives online, we have to match it to an unmatched vertex u in A such that {u, v} ∈ E. Note that here the existence of an edge is not random in itself but that of a vertex is. Again, Karp et al.'s algorithm gives a (1 − 1/e)-approximation, and Feldman et al. give a 0.67-approximation. Significant amount of work has been done on this variant as well [MGS11, HMZ11, BGL+12, JL14, AGM15, BSSX16]. We would like to mention the works of Dean et al. [DGV04, DGV05], where they consider stochastic problems where cost of an input unit is only known as a probability distribution that is instantiated after the algorithm commits to including the item in the solution. Charikar et al. [CCP05] and Katriel et al. [KKMU07] consider two stage optimization problems, where the first stage is stochastic with a lower cost for decisions, and in the second stage, with an increase in the decision cost, the actual input is known. 2 A Weighted Query-Commit Algorithm In this section, we present a (1−1/e)-approximation algorithm for the maximum weight bipartite matching problem (MWBM) in the query-commit model. Let G = (A, B, E, w) be a weighted bipartite graph with A = B = n, where each edge e ∈ E has weight w(e) and exists independently with probability2 pe. Let Ie be the indicator variable for the event that edge e exists (i.e., Ie = 1 if and only if edge e exists). The actual 2Alternatively, one may think of the weight of an edge e as an independent random variable that takes value w(e) with probability pe and value zero with probability 1 − pe. We consider a more general distribution of edge weights in Section 3. 4 value of Ie can only be determined by querying edge e to check whether it exists or not. Given such a graph G, a query-commit algorithm for MWBM (adaptively) queries a sequence of edges Q = (eq1, . . . , eqm) and outputs a valid matching M ⊆ Q. Since a query-commit algorithm is committed to add any queried edge that exists to its output, M = {e ∈ Q : Ie = 1}. Let A be a query-commit algorithm for MWBM and let M (A) denote its output on input G. We define the expected utility of A, U(A) := E[Pe∈M (A) w(e)] to be the expected weight of its output matching, where the expectation is over the randomness of the existence of edges and any internal randomness of the algorithm. Let OPT = maxA U(A), where the maximum is taken over all query-commit algorithms3, be the optimal expected query-commit utility. We give a query-commit algorithm Approx-QC whose expected query-commit utility U(Approx-QC) is at least (1 − 1/e) OPT. As described in the introduction, our approach consists of two stages. First, we solve a linear program to bound the optimal expected query-commit utility OPT. For each edge e ∈ E we associate a variable xe, which we think of as the probability that an optimal algorithm adds edge e to its output. We set our LP constraints on xe variables to be those that must be satisfied by any algorithm that outputs a valid matching formed only of edges that exist. Then the optimal expected utility is upper bounded by the maximum of the weighted sum Pe∈E xe · w(e) subject to our LP constraints. a Then, we use the structural properties of our LP polytope to define a distribution over the permutations of edges and use this distribution to set the query order in our algorithm. For this, we first define distributions DQC over the permutations of neighboring edges for each vertex a ∈ A such that the following holds: If we draw a random permutation σa from DQC for each a ∈ A, query edges in the order of σa, and finally add to our output the first edge in σa that exists, then the expected utility is optimal. However, the output is not guaranteed to be a matching, because it might have more than one edge incident to a vertex in B (i.e., collisions). To deal with the issue of collisions in B, we view the problem as a collection of prophet secretary problem instances that has an instance for each vertex b ∈ B. In the prophet secretary problem, we have one item to sell (position to be filled) and a set of buyers (secretaries) arrive in a random order. Each buyer makes a take it or leave it offer to buy the item at some random price (or each secretary has some random skill level) whose distribution we know beforehand, and we are interested in maximizing the profit (or hiring the best secretary). a In their recent work, Ehsani et al. [EHKS18] gave a (1 − 1/e)-competitive algorithm for the prophet secretary problem. Inspired by this result, we design our algorithm so that for each b ∈ B, it recovers at least (1 − 1/e)-fraction of the expected weight of the edge incident to b in an optimal algorithm's output. To elaborate, we pick a uniformly random permutation of the vertices in A and treat them as buyers arriving at uniformly random times. Then, as seen from the perspective of a fixed vertex (i.e. an item) b ∈ B, buyers make a one-time offer with random values (corresponding to weights of edges incident to b), and our algorithm uses dynamic thresholds that depend on arrival times to make the decision of whether to sell the item at the offered price or not. One may view our algorithm as running the (1 − 1/e)-competitive prophet secretary algorithm in parallel for each of the vertices in B, but the way we set the dynamic thresholds is different. The rest of this section is organized as follows: In Section 2.1, we describe how to upper bound OPT using an LP. In Section 2.2, we analyze the structure of the LP polytope and show how to construct the distributions DQC for each a ∈ A. Finally in Section 2.3, we present our a 3We remark that our approximation guarantee in the query-commit model also works with respect to the stronger offline adversary that knows all outcomes before selecting the matching. We have presented it in this way as the guarantees in the price-of-information model are of this type. 5 proposed algorithm and adapt the ideas of Ehsani et al. [EHKS18] to analyze its approximation guarantee. 2.1 Upper-bounding the optimal expected utility For each vertex u ∈ A ∪ B, let δ(u) denote the set of edges incident to u. For a subset of edges F ⊆ E, let f (F ) be the probability that at least one edge in F exists, then f (F ) = 1 −Qe∈F (1 − pe), because each edge e exists independently with probability pe. Fix any query-commit algorithm A. For each edge e ∈ E, let xe be the probability that A outputs e. Consider a vertex u ∈ A ∪ B and a subset F ⊆ δ(u). Since A outputs a valid matching, the events that edge e being added to the output of A for each e ∈ F are disjoint, for an edge to be added to the output, it must exist in the first place, and thus it must be and hence the probability that A adds one of the edges in F to its output is Pe∈F xe. But, the case that Pe∈F xe 6 f (F ) (because f (F ) is the probability that at least one edge in F exists). Therefore, x = (xe)e∈E is a feasible solution to the following linear program, which we call LPQC. So, the expected utility U(A) of A is at most the value of LPQC, which implies Lemma 1 below. Maximize subject to Xe∈E Xe∈F xe · w(e), xe 6 f (F ) , for all u ∈ A ∪ B and for all F ⊆ δ(u) , xe > 0 , for all e ∈ E . Lemma 1. The optimal expected query-commit utility, OPT, is upper bounded by the value of LPQC. 2.2 Structure of the LP and its implications Although LPQC has exponentially many constraints, we can solve it in polynomial time. Lemma 2. The linear program LPQC is polynomial-time solvable. is a submodular function (notice that f is submodular because it is a coverage function while Proof. Observe that for a fixed vertex u ∈ A ∪ B, the constraints Pe∈F xe 6 f (F ) for all F ⊆ δ(u), can be re-written as 0 6 gu(F ) for all F ⊆ δ(u), where gu(F ) = f (F ) −Pe∈F xe Pe∈F xe is clearly modular). Thus we can minimize gu over all subsets of δ(u) for all u ∈ A ∪ B in polynomial time using O(n) submodular minimizations to find a violating constraint. If none of the minimizations gives a negative value and if xe > 0 for all e ∈ E, then the solution is feasible. Thus we can solve LPQC in polynomial-time using the ellipsoid method. For the rest of this section, we assume that 0 < pe < 1 for all e ∈ E. We can safely ignore those edges e ∈ E for which pe = 0, and for those with pe = 1, we can scale down the probabilities (at a small loss in the objective value) due to the following lemma. Lemma 3. Let pe = (1−γ)pe for all e ∈ E, and for a subset F ⊆ E, let f (F ) = 1−Qe∈F (1− pe) be the probability that at least one edge in F exists under the scaled down probabilities pe. If we replace f (F ) in LPQC by f (F ), the value of the resulting LP is at least (1 − γ) times the value of LPQC. 6 let Qi = 1 −Qi Proof. Fix a set F ⊆ E and label the edges in F from 1 through F . For i = 1, . . . , F , e=1(1 − pe). Then, for i > 1 we have that Qi = Qi−1 + pi(1 − Qi−1), and similarly, Qi = Qi−1 + pi(1 − Qi−1). By definition, we have f (F ) = QF and f (F ) = QF . We now prove that Qi > (1 − γ)Qi for i = 1, . . . , F by induction. e=1(1 − pe) and let Qi = 1 −Qi For the base case, we have Q1 = (1 − γ)Q1. Notice that, by the definition of pi's, we have Qi > Qi. Thus, for i > 1 we have that Qi = Qi−1 + pi(1 − Qi−1) > (1 − γ)Qi−1 + (1 − γ)pi(1 − Qi−1) > (1 − γ)Qi−1 + (1 − γ)pi(1 − Qi−1) = (1 − γ)(Qi−1 + pi(1 − Qi−1)) = (1 − γ)Qi. (by inductive hypothesis) (because Qi−1 > Qi−1) Thus if we scale down the polytope defined by the constraints of LPQC by a factor of (1 − γ), the resulting polytope is contained inside the polytope defined by f (F ) constraints. Moreover, all extreme points of both the polytopes have non-negative coordinates and the objective function has non-negative coefficients. Hence the claim of Lemma 3 follows. Remark. The expected utility of our proposed algorithm is (1 − 1/e) · OPT∗ > (1 − 1/e) · OPT, where OPT∗ is the optimal LP value of LPQC. Thus, in the cases where the assumption pe < 1 for all e ∈ E does not hold, we can scale the probabilities down by (1 − γ), and consequently the guarantee on expected utility will at least be (1 − γ)(1 − 1/e) · OPT due to Lemma 3. We can choose γ to be arbitrarily small. To implement the scaling down operation, we can simply replace each query made by an algorithm with a function that only queries with probability (1 − γ). The assumption that 0 < pe < 1 for all e ∈ E yields the following lemma on the function f . Lemma 4. Fix a vertex u ∈ A ∪ B, and suppose that 0 < pe < 1 for all e ∈ δ(u). Then the function f is strictly submodular and strictly increasing on subsets of δ(u). That is: 1. For all subsets A, B ⊆ δ(u) such that A \ B 6= ∅ and B \ A 6= ∅, f (A) + f (B) > f (A ∪ B) + f (A ∩ B). 2. For all A ( B ⊆ δ(u), f (A) < f (B). Proof. Let g(F ) = 1−f (F ) =Qe∈F (1−pe) (note that g(∅) = 1). Notice that for F1, F2 ⊆ F such that F1 ∩F2 = ∅ and F1 ∪F2 = F , it holds that g(F ) = g(F1)·g(F2). Let A, B ⊆ δ(u) be two sets such that A\B 6= ∅ and B\A 6= ∅. It is sufficient to show that g(A)+g(B) < g(A∪B)+g(A∩B). We have and g(A \ B) g(A) + g(B) = g(A ∩ B)  g(A ∪ B) + g(A ∩ B) = g(A ∩ B) g(A \ B) · g(B \ A) } {z {z a {z } a·b ,   } +1  . + g(B \ A) b 7 (2) (3) Since A \ B 6= ∅ and B \ A 6= ∅, and 0 < pe < 1 for all e ∈ E, we have g(A ∩ B) > 0 and both a, b < 1. Thus a + b < 1 + a · b, because (1 − a)(1 − b) > 0. This combined with Equations (2) and (3) yields Property 1. Now consider A ( δ(u) and any edge e ∈ δ(u) \ A. To prove Property 2, it is sufficient to show that f (A ∪ {e}) > f (A), or equivalently, g(A ∪ {e}) < g(A). This is straightforward since g(A ∪ {e})/g(A) = 1 − pe < 1, because pe > 0. Let x∗ = (x∗ e)e∈E be an optimal solution to LPQC. Fix a vertex a ∈ A. Then, xa = e)e∈δ(a), which is x∗ restricted only to those coordinates that correspond to edges in δ(a), (x∗ satisfy the following constraints: Xe∈F xe 6 f (F ) , xe > 0 , for all F ⊆ δ(a) , (4) for all e ∈ δ(a) . Notice that these constraints are only a subset of the constraints of LPQC. a Let P QC denote the polytope defined by the above constrains. The extreme points of P QC have a nice structure that becomes crucial when designing the probability distribution DQC over permutations of edges. Namely, for any extreme point, the sets for which Constraint (4) is tight form a chain. Moreover, each set in the chain has exactly one more element than its predecessor and this element is non-zero coordinate of the extreme point. Formally, we have Lemma 5 below. a a Lemma 5. Let y = (ye)e∈δ(a) be an extreme point of P QC and let Y = {e ∈ δ(a) : ye > 0} be the set of edges that correspond to the non-zero coordinates of y. Then there exist Y subsets S1, . . . , SY of δ(a) such that S1 ( S2 ( · · · ( SY with the following properties: a 1. Constraint (4) is tight for all S1, S2, . . . SY . That is Pe∈Si ye = f (Si) for all i = 1, . . . , Y . 2. For each i = 1, . . . , Y , the set Si \ Si−1 contains exactly one element ei, and yei is non-zero (i.e., ei ∈ Y ). Proof. It is clear that at least Y constraints in (4) are tight. If Y = 1, the claim of the lemma is obviously true. Suppose that Y > 1. Now let A, B ⊆ δ(a) be two different sets for which Constraint (4) is tight. Then we have f (A) + f (B) = Xe∈A ye + Xe∈B ye = Xe∈A∪B ye + Xe∈A∩B ye 6 f (A ∪ B) + f (A ∩ B), where the last inequality follows because y satisfies Constraint (4). Observe that, if A * B and B * A, then by Lemma 4, f (A) + f (B) > f (A ∪ B) + f (A ∩ B). Thus, it must be the case that either A ( B or B ( A, and consequently there exist Y sets S1, S2, . . . , SY such that S1 ( S2 ( · · · ( SY , for which Constraint (4) is tight. For each i = 1, 2, . . . , Y , we thus have that Pe∈Si\Si−1 ye = f (Si) − f (Si−1) > 0, where the inequality is due to the strictly increasing property of f . This implies that each Si \ Si−1 must contain at least one edge ei such that yei > 0, and since there are only Y non-zero coordinates in y, each Si \ Si−1 must contain exactly one such ei. Now, suppose that some Si \ Si−1 contains some e′ i}) < f (Si) yields a contradiction. Here, the first inequality is due to Constraint (4) whereas the last inequality is due the strictly increasing property of f . = 0. Then f (Si) =Pe∈Si ye =Pe∈Si\{e′ i} ye 6 f (Si \ {e′ i such that ye′ i 8 Now fix a vertex a ∈ A and consider the simple query algorithm given in Algorithm 1, which outputs at most one edge adjacent to vertex a. In Algorithm 1, DQC is a distribution over the permutations of edges in some subsets of δ(a) that, by Lemma 6, can be found in polynomial time. We have the following lemma considering Algorithm 1. a 1 Draw a permutation σ from DQC 2 foreach edge e in the order of σ do 3 Query edge e to check whether it exists. If edge e exists, output e and terminate. a 4 for some fixed vertex a ∈ A. Algorithm 1: Query algorithm for selecting an edge adjacent to a fixed vertex a ∈ A. Lemma 6. Let x∗ be an optimal solution to LPQC and let x∗ e)e∈δ(a) be its restriction to the coordinates that corresponds to edges in δ(a). Then there exists a distribution DQC over the permutations of subsets of δ(a) with the following property: When the permutation σ is drawn from DQC e, hence the ew(e). Moreover, a permutation in Algorithm 1, the probability that the algorithm outputs the edge e is x∗ expected weight of the edge output by Algorithm 1 is Pe∈Ea x∗ can be sampled in polynomial time. of edges from DQC a = (x∗ a a a a Proof. Let y = (ye)e∈δ(a) be an extreme point of P QC and let Y be set of non-zero coordinates of y. Let ∅ = S0 ( S1 ( · · · ( SY be the chain of sets (for which Constraint (4) is tight) guaranteed by Lemma 5 for the extreme point y. We can efficiently find the chain by first setting SY = Y , and iteratively recovering Si−1 from Si by trying all possible Si \ {e} for e ∈ Si to check whether Constraint (4) is tight. For each i = 1, . . . , Y , let ei be the unique element in Si \ Si−1 and let σy = (e1, . . . , eY ). Notice that Si = {e1, . . . , ei}, and hence yei = Pe∈Si ye −Pe∈Si−1 ye = f (Si) − f (Si−1). Thus if we select σy as the permutation in Algorithm 1 and query according to that order, the probability that it outputs the edge ei is exactly Pr[some edge in Si appears] − Pr[some edge in Si−1 appears] = f (Si) − f (Si−1) = yei. Note that the point x∗ a is contained in polytope P QC a . Thus, using the constructive version of Caratheodary's theorem, we can efficiently find a convex combination x∗ where ai > 0 for all i ∈ [k], y(i) is an extreme points of P QC k = poly(Ea). This is because we can optimize a linear function over P QC in polynomial time using submodular minimization as a separation oracle, and for such polytopes, the constructive version of Caratheodary's theorem holds (See Theorem 6.5.11 of [GLS88]). a = Pi∈[k] ai · y(i), for all i ∈ [k], Pi∈[k] ai = 1, and a a a Define the distribution DQC If follows that, if we sample according to this distribution in Algorithm 1, then for any fixed edge e. Consequently, such that it gives permutation σy(i) with probability ai. e, the probability that the algorithm outputs the edge e is Pi∈[k] ai · y(i) the expected weight of the output of Algorithm 1 is Pe∈Ea x∗ e · w(e). e = x∗ 2.3 Proposed algorithm and analysis Suppose that we run Algorithm 1 for all vertices a ∈ A and let M ′ be the set of all output edges. Then we have E  Xe∈M ′ w(e)  = Xa∈A Xe∈δ(a) x∗ e · w(e) = Xe∈E x∗ e · w(e) > OPT . 9 Furthermore, M ′ contains at most one adjacent edge per each vertex a ∈ A. However M ′ may contain more than one adjacent edge for some vertices b ∈ B, and hence it may not be valid matching. Now again suppose that we run Algorithm 1 as described above for all vertices a ∈ A in some arbitrary order. Consider some fixed vertex b ∈ B. By Lemma 6, from the perspective of b, an edge e ∈ δ(b) appears with probability x∗ e (when we say an edge e = (a, b) appears, it means that Algorithm 1, when run on vertex a, outputs the edge e). Viewing the vertices in A as buyers, we think of the appearance of an edge e = (a, b) as a buyer a making a take-it or leave-it offer of value we for item b. Thus if we use a uniformly random order of vertices in A, picking an edge adjacent to the fixed vertex b can be viewed as an instance of the prophet secretary problem. The (1 − 1/e)-competitive algorithm algorithm given by Ehsani et al. [EHKS18] for the prophet secretary problem first sets a base price for the item. If some buyer comes at time t ∈ [0, 1], and if the item is not already sold, then the algorithm sells the item to this buyer if the offered price is at least (1 − et−1) times the base price. Since the prophet secretary problem deals with a single item, the goal is to choose the buyer with highest offer, and hence they set base price of the item as the expected value of the maximum offer. However, rather than picking the maximum weighted edge adjacent to each b, we want to maximize the total weight of the matching constructed. Thus, we set the base price cb for each b, not as the the expectation of the offline secretary problem, but as the expected weight of the edge adjacent to b in some optimal offline maximum-weight bipartite matching. To be concrete, e as the probability that some fixed optimal algorithm for maximum weighted bipartite matching in query-commit model adds edge e to its output). we set cb =Pe∈δ(b) x∗ e · w(e) (recall that we can think of x∗ 1 Solve LPQC to get x∗ and find the permutation distributions DQC 2 For each vertex a ∈ A, select ta ∈ [0, 1] (arrival time) independently and uniformly at for all a ∈ A. a random. 3 For each vertex b ∈ B, set the base price cb =Pe∈Eb 4 Let M be an empty matching. 5 foreach vertex a ∈ A in the increasing order of ta do 6 Draw a permutation σ of edges from DQC a . foreach e = (a, b) in the order of σ do x∗ e · w(e). if w(e) > (1 − eta−1) · cb and b is not matched then Query edge e to check whether it exists. If it exists, add it to M and continue to next vertex in A. else Flip a coin that give Heads with probability pe. If Heads, continue to next vertex in A. 7 8 9 10 11 12 13 14 return the matching M . Algorithm 2: Outline of Approx-QC. We present the pseudo-code of our algorithm Approx-QC in Algorithm 2. We start by independently assigning each a ∈ A a uniformly random arrival time ta ∈ [0, 1], and then for each vertex a ∈ A in the order of the arrival time, we run a slightly modified version of the query algorithm given in Algorithm 1. For each b ∈ B, we pick an edge e = (a, b) if it appears and if 10 its weight exceeds the threshold (1 − eta−1) · cb. Since a query-commit algorithm is committed to adding any queried edge that exists, we query an edge e only if e ∩ B is not already assigned to some other vertex a ∈ A and its weight w(e) exceeds the threshold. But we still need to make sure that, for a fixed b, edges e ∈ δ(b) appears (in the sense that if we run Algorithm 1, it outputs the edge e) with probability x∗ e. Hence we have the else clause of the conditional in Algorithm 2 that simulates the behavior of Algorithm 1 in the cases we decide not to actually query an edge. We conclude this section with Theorem 7 which shows that our algorithm Approx-QC is (1 − 1/e)-approximate. The proof follows exactly the same lines (except for the definition of base price cb) as in Ehsani et al. [EHKS18] to show that the expected weight of the edge adjacent to a fixed vertex b ∈ B in the output of Approx-QC is at least (1 − 1/e) · cb. Then by the linearity of expectation, the expected utility of Approx-QC is at least (1 − 1/e) ·Pb∈B cb = (1 − 1/e) ·Pe∈E x∗ e · w(e) > OPT (recall that cb =Pe∈δ(b) x∗ Theorem 7. The expected utility U(Approx-QC) of the algorithm Approx-QC is at least (1 − 1/e) · OPT. e · w(e)). Remark. For the sake of completeness, we reproduce the analysis of Ehsani et al. [EHKS18] in Section 3 for our more general algorithm in the price of information model (see Theorem 15). 3 Extension to the Price of Information Model In this section, we present a (1 − 1/e)-approximation algorithm for the maximum weight bi- partite matching problem (MWBM) in the price of information (PoI) model introduced by Singla [Sin18]. Our strategy is essentially the same as that used in Section 2 for the query-com- mit model except for a few enhancements. Let G = (A ∪ B, E) be a bipartite graph where each edge e ∈ E independently takes some random weight Xe from a known probability distribution. The weight distributions can be different for different edges and are independent. To find the realization of Xe (i.e., the actual weight of the edge e), we have to query the edge e at a cost of πe. Consider an algorithm A that queries a subset Q of edges E and outputs a valid matching M ⊆ Q. We call such an algorithm a PoI algorithm for MWBM. We define the expected PoI utility of Algorithm A as U(A) := E Xe∈M Xe −Xe∈Q πe  , where the expectation is taken over the randomness of Xe's and any internal randomness of the algorithm. The goal is to design a polynomial-time PoI algorithm A for MWBM such that its expected PoI utility U(A) is maximized. Let OPT = max U(A) denote the optimal expected PoI utility, where the maximization is over all PoI algorithms. Let E = {e1, . . . , em}, and let X = (Xe1, . . . , Xem ). Let M be the collection of all valid bipartite matchings in G. The following lemma is due to Singla [Sin18]. Lemma 8. For each edge e ∈ E, let τe be the solution to the equation E[max{(Xe −τe), 0}] = πe and let Ye = min(Xe, τe). Then the optimal expected PoI utility OPT is upper bounded by EX [maxM ∈MPe∈M Ye]. To derive our algorithm, we go through the same two stages as in Section 2. We first construct a linear program (LP), this times defining the constraints using the probability dis- tributions of Ye's (that were defined in Lemma 8), and use its value together with Lemma 8 11 to upper bound OPT. For this, we discretize the distributions of Ye's, and in contrast to the query-commit setting, we now define variables xe,v for each edge-value pair (e, v); We think of xe,v as the joint probability that Ye = v and some fixed optimal PoI algorithm includes edge e in its output. The objective value of this LP upper bounds the quantity EX [maxM ∈MPe∈M Ye], which in turn is an upper bound of the optimal expected PoI utility as stated in Lemma 8. We describe the construction of our LP in Section 3.1. Next, in Section 3.2, we analyze the structure of our new LP as we did in the previous section and use it to define analogous prob- ability distributions over subsets of edge-value pairs. Finally, in Section 3.3 we put everything together to construct our (1 − 1/e)-approximate PoI algorithm for MWBM. 3.1 Upper-bounding the optimal expected utility. Assume that the distributions of Ye are discrete4. For each e ∈ E, let Ve denote the set of possible values of Ye. For each vertex u ∈ A ∪ B, let Eu = {(e, v) : e ∈ δ(u), v ∈ Ve} be the set of all edge-value pairs for all edges incident to u. Let Eall = ∪u∈AEu be the set of all edge-value pairs. For each edge e ∈ E and value v ∈ Ve, let pe,v be the probability that Ye = v, and for a set F ⊆ Eall, let f (F ) be the probability that Ye = v for at least one edge-value pair (e, v) ∈ F . Fix any PoI algorithm A for MWBM. For each edge-value pair (e, v) ∈ Eall, let Ae,v be the event that Ye = v and A includes edge e in its output, and let xe,v = Pr[Ae,v]. Now fix a vertex u ∈ A ∪ B and a set F ⊆ Eu. Then Pr[∪(e,v)∈F Ae,v] 6 Pr[Ye = v for some (e, v) ∈ F ] = f (F ). But since all events Ae,v for (e, v) ∈ Eu are mutually disjoint (as with the query-commit setting, the algorithm A outputs a valid matching and thus the output has at most one edge incident to vertex u), Pr[∪(e,v)∈F Ae,v] = P(e,v)∈F Pr[Ae,v] = P(e,v)∈F xe,v. Thus we have P(e,v)∈F xe,v 6 f (F ), and this must be true for all u ∈ A ∪ B and F ⊆ Eu. Now consider the following LP, which we call LPPoI. Maximize subject to xe,v · v, X(e,v)∈Eall X(e,v)∈F xe,v 6 f (F ) for all F ⊆ Eu for all u ∈ A ∪ B, xe,v > 0 for all (u, v) ∈ Eall. We have the following lemma concerning LPPoI. Lemma 9. The optimal expected PoI utility OPT is upper bounded by the value of LPPoI. A that queries Ye for all edges e ∈ E and outputs a maximum weighted bipartite matching M of G. Setting xe,v to be the joint probability that Ye = v and e ∈ M for each edge-value Proof. By Lemma 8, we have that OPT 6 EX[maxM ∈MPe∈M Ye]. Now consider an algorithm pair (e, v) ∈ Eall gives a feasible solution to LPPoI. Hence U(A) = EX[maxM ∈MPe∈M Ye] 6 P(e,v)∈Eall x∗ e,v)(e,v)∈Eall is an optimal solution of LPPoI. e,v · v, where x∗ = (x∗ 3.2 Structure of the LP and its implications. Now we analyze the structure of LPPoI. Our analysis closely follows that of Section 2.2. As usual, f is a coverage function and hence it is submodular. Thus, for each vertex u ∈ A ∪ B, we can use submodular minimization to check whether any constraint of the form P(e,v)∈F xe,v 6 f (F ) is violated for any subset F ⊆ Eu. This yields Lemma 10 below. 4We can e.g. achieve this by geometric grouping into polynomially many classes. 12 Lemma 10. The linear program LPPoI is solvable in polynomial-time. We proceed as follows. Consider the query strategy given in Algorithm 3 that queries edges incident to a fixed vertex a ∈ A in some random order. This is the PoI version of the Algorithm 1 given for the query-commit setting. Following (almost) the same procedure as in Section 2.2, we find distributions DPoI that makes Algorithm 3 pick an edge e that has value v with probability x∗ e,v, and then use those to construct a PoI algorithm for MWBM that gives (1 − 1/e) approximation guarantee. But the issue here is that Algorithm 3 considers the distributions of Ye's and does not pay query costs whereas our final approximate PoI algorithm needs to consider the distributions of Xe's and has to pay query costs. a 1 Let ze = Null for all e ∈ δ(a). 2 Draw a permutation σ from DPoI 3 foreach (e, v) in the order of σ do 4 a . If ze = Null, draw ze from a distribution identical to that of Ye. If ze = v, output e and terminate. 5 Algorithm 3: Query algorithm for selecting an edge incident to a fixed vertex a ∈ A. Now consider the way we defined τe (which we used to define Ye's), and observe that the values of Xe above the threshold τe, on expectation, covers the cost πe of querying it. Thus, if we can make sure that the first time we query an edge e (i.e., the time where we pay the price πe) in Algorithm 3 is for the value τe, then we can still use it to construct our final PoI matching algorithm (where we actually query Xe values, and when an edge e is queried for the first time for value τe, in expectation we actually get a net value of τe with probability x∗ e,τe after paying πe). Using a careful construction, we make sure that distributions DPoI only gives those permutations where for any edge e, the pair (e, τe) appears before any other pair (e, v). (as opposed to how ) for each a ∈ A. Fix a vertex a ∈ A, and consider the family Ea of subsets of For such a construction, we consider a slightly different polytope P PoI a a we defined P QC Ea defined as follows: a Ea := {F ⊆ Ea : (e, v) ∈ F ⇒ (e, v′) ∈ F for all v′ > v such that (e, v′) ∈ Ea}. I.e., Ea is a family of subsets of Ea that satisfy the following: If a set F of edge-value pairs is in Ea and an edge-value pair (e, v) is in F , then F also contains all edge-value pairs for the same edge e having values greater than v. It is easy to verify that if A, B ∈ Ea then both A ∪ B ∈ Ea and A ∩ B ∈ Ea, which makes Ea a lattice family. (I.e., the sets in Ea forms a lattice where intersection and union serve as meet and join operations respectively.) We define below the polytope P PoI a using a constraint for each set in the family Ea. X(e,v)∈F xe,v 6 f (F ) xe,v > 0 for all F ∈ Ea (5) for all (e, v) ∈ Ea. Analogous to our assumption 0 < pe < 1 for all e ∈ E for the query-commit setting, we now assume that each pe,v > 0 and for each edge e, Pv∈Ve pe,v < 1. (I.e., we can assume that with some small probability pe,⋆ the edge e does not exist or equivalently, we can also assume pe,0 > 0 and 0 /∈ Ve. We omit the details, but one can use the same argument of re-scaling the probabilities to justify this assumption.) Under these assumptions on pe,v's, we have the following lemma. The proof resembles that of Lemma 4 from Section 2.2, and we defer it to Appendix A. 13 Lemma 11. Fix a vertex a ∈ A. If pe,v > 0 for all (e, v) ∈ Ea and Pv∈Ve pe,v < 1 for all e ∈ δ(a), the function f is strictly submodular and strictly increasing on the lattice family Ea. Formally, 1. For any A, B ∈ Ea such that A\B 6= ∅ and B \A 6= ∅, f (A)+f (B) > f (A∩B)+f (A∪B), and 2. For any A ( B ⊆ Ea, f (B) > f (A). Similarly to the query-commit setting, we now analyze the structure of the extreme points . We have the following lemma, which is a slightly different version of Lemma 5 of polytope P PoI from Section 2.2. a Lemma 12. Let y = (ye,v)(e,v)∈Ea be an extreme point of P PoI and let Y = {e ∈ Ea : ye,v > 0} be the set of non-zero coordinates of y. Then there exist Y subsets S1, . . . , SY of Ea such that S1 ( S2 ( · · · ( SY with the following properties: a 1. Constraint (5) is tight for all S1, S2, . . . SY . That is P(e,v)∈Si ye,v = f (Si) for all i = 1, . . . , Y . 2. For each i = 1, . . . , Y , the set (Si \ Si−1) ∩ Y contains exactly one element (ei, vi). Moreover, for any other (e, w) ∈ Si \ Si−1, we have e = ei and w > vi. Proof. Property 1 and the fact that each (Si \ Si−1) ∩ Y contains exactly one pair (ei, vi) follows from the proof of Lemma 5. It remains to show that each Si \ Si−1 additionally contains only those edge-value pairs (ei, w) for which w > vi. Suppose to the contrary that there is some Si \ Si−1 that contains at least one other pair i ( Si and (e′, v′) that violates this property. Let S′ i is also in the family Ea. Thus we have that f (S′ S′ which is a contradiction because f is strictly increasing and S′ i ( Si. Here the first inequality holds because y is in P PoI i contains all coordinates in Si for which y is non-zero. The last equality is true because Si corresponds to a tight constraint for the extreme point y. ye,v = P(e,v)∈Si ye,v = f (Si), i = Si−1 ∪ {(ei, w) : w > vi}. Then Si−1 ( S′ and the first equality holds because S′ i) > P(e,v)∈S ′ a i As in the previous section, we are now ready to construct the distribution DPoI . We present this explicit construction in the proof of Lemma 13 stated below, which is the counterpart of Lemma 6. a Lemma 13. Let x∗ be an optimal solution of LPPoI. For each vertex a ∈ A, there exist a distribution DPoI over the permutations of (subsets of) edge-value pairs in Ea that satisfies the following properties: a 1. For each permutation σ drawn from DPoI a , if edge-value pair (e, v) appears in σ, then the edge-value pair (e, w) appears before (e, v) in σ for all w ∈ Ve such that w > v, 2. Pr[Algorithm 3 outputs e] =Pv∈Ve x∗ 3. Pv∈Ve:v>w Pr[Algorithm 3 outputs e with value v] · v > Pv∈Ve:v>w x∗ e,v for all e ∈ δ(a), and and w ∈ R+. e,v · v for all e ∈ δ(a) Moreover, a permutation of edge-value pairs from DPoI a can be sampled in polynomial time. 14 Proof. As with the case of Lemma 6, we first associate a permutation of edge-value pairs with each extreme point of P PoI . a For an extreme point y, let Y and S1, . . . , SY be as defined in Lemma 12. Consider the permutation σy of elements in SY that is defined as follows: Start with σy = [ ] and for each i = 1, . . . , Y , append to it the edge-value pairs in Si \ Si−1 in the decreasing order of value. Recall that for all i = 1, . . . , Y , all edge-value pairs in Si \ Si−1 corresponds to a single edge. Let (e, v) ∈ Si. Then, by the definition of the family Eu, (e, v′) ∈ Si for all v′ ∈ Ve such that v′ > v. Thus none of the sets Si+1 \ Si, Si+2 \ Si+1, . . . , SY \ SY −1 can contain an edge-value pair (e, v′) such that v′ > v. Also, since the elements in Si \ Si−1 are appended to σy in decreasing order of values, σy has the following property: If at any point the edge-value pair (e, v) appears in σy, then (e, w) appears in σy before (e, v) for all w ∈ Ve such that w > v. Let σy = (e1, v1), . . . , (eℓ, vℓ) be the permutation of edge value pairs associated with the extreme-point y. Let Ti := {(e1, v1), . . . , (ei, vi)} denote the set of first i edge-value pairs in σy. If we select permutation σy in Line 2 in Algorithm 3, the probability of it picking edge ei with value vi is exactly f (Ti) − f (Ti−1). Now define a new vector y′ with the same indices as y as ej,vj = f (Tj) − f (Tj−1), and all the other coordinates of y′ are follows: For each (ej, vj) ∈ σy, y′ 0. Notice that y′ and y satisfy the following: 1. Pv∈Ve y′ 2. Pv∈Ve:v>w y′ e,v =Pv∈Ve ye,v for all e ∈ δ(a), and e,v · v >Pv∈Ve:v>w ye,v · v for all e ∈ δ(a) and w ∈ R+. j ′=j y′ thus have that Pk To see this fix some set Si and let (ej, vj), (ej+1, vj+1), . . . , (ek, vk) be all the edge-value pairs in Si − Si−1. Then we know that ej = ej+1 = · · · = ek, vj > vj+1 > · · · > vk, and yek,vk 6= 0. We ek,vj = f (Tk) − f (Tj−1) = f (Si) − f (Si−1) = yek,vk (recall that (ek, vk) is the unique element in Si \ Si−1 for which yek,vk is non-zero). This holds for elements in Si \ Si−1 in all i = 1, . . . , Y , and yields the Property 1 above. To see Property 2, notice that within each Si \ Si−1, the weight of the non-zero coordinate yek,vk is re-distributed among yej,vj , . . . , yek,vk, and that vj ′ > vk for j′ = j, j + 1, . . . , k. Let σ be the random variable that denotes the permutation picked by Algorithm 3. Then we have that, for all e ∈ δ(u), Pr[Algorithm 3 picks eσ = σy] = Xv∈Ve y′ e,v = Xv∈Ve ye,v, and for all (e, w) ∈ Eu, Xe,v∈Ve:v>w Pr[Algorithm 3 picks e with value vσ = σy] · v = Xe,v∈Ve:v>w y′ e,v · v > Xe,v∈Ve:v>w ye,v · v. Now let x∗ a are only a subset of the constraints of LPPoI, x∗ a be the restriction of the optimal solution the coordinates in Ea. Since the constraints that define P PoI . If we can optimize a linear function of P PoI in polynomial time, then we can follow the same lines of the proof of Lemma 6 and use the constructive version of Caratheodary's theorem to find a convex combination x∗ an extreme point of P PoI only has constraints for sets of a lattice family, and as a result, we cannot use the usual submodular minimization as a separation oracle for LPPoI. But luckily, Grotschel et al. [GLS81] showed that we can minimize any submodular function over a lattice family in polynomial time. Thus we can efficiently find such a convex combination. a = Pi∈[k] ai · y(i), where k = poly(Ea]) and for each i ∈ [k], y(i) is . However, unlike in the query-commit case, the polytope P PoI a a lies in P PoI a a a 15 Once we have the convex combination, the rest is exactly the same as the query-commit returns the permutation σy(i) with probability ai for all i ∈ [k]. setting. The distribution DPoI One can easily verify that Properties 1-3 hold for this distribution. a 3.3 Proposed algorithm and analysis. We now present a (1 − 1/e)-approximate PoI algorithm Approx-PoI for MWBM. The algorithm closely resembles the algorithm Approx-QC we presented for the query-commit model, but has two key differences. First, we now have to pay a price for querying edges. But, as we prove later, this price is already taken care of by the way we defined Ye variables. The second difference is that for each edge e ∈ E, we now have multiple values to consider, but regardless, with respect to a fixed vertex (i.e. an item) b ∈ B, the vertices a ∈ A can still be viewed as buyers; The appearance of multiple edge-value pairs for the same edge can be interpreted as a distribution over values that the buyer a offers for the item b. The outline of our algorithm is given in Algorithm 4. Note that, we again have the else clause in the conditional to make sure that we do not change the probability distributions of the appearances of edge-value pairs even if we decide not to query some edges for certain values. 1 Solve LP ⋆ to get x∗ and find the permutation distributions DPoI 2 For each vertex a ∈ A, select ta ∈ [0, 1] (arrival time) independently and uniformly at for all a ∈ A. a random. 3 For each vertex b ∈ B, let cb =P(e,v)∈Eb 4 Let ze = Null for all e ∈ E. 5 Let M be an empty matching. 6 foreach vertex a ∈ A in the increasing order of ta do 7 Draw a permutation σ from DPoI foreach (e = (a, b), v) in the order of σ do x∗ e,v · v. a . 8 9 10 11 12 13 14 if v > (1 − eta−1) · cb and b is not matched then If ze = Null, pay πe and query edge e to find its actual value. Let ze be this value. If min(ze, τe) = v, add e to M and continue to next vertex in A. else If ze = Null, draw ze from a distribution identical to that of Xe. If min(ze, τe) = v, continue to next vertex in A. 15 return the matching M . Algorithm 4: Outline of Approx-PoI. The analysis of the expected PoI utility of Approx-PoI consists of two parts. First we use the same technique used by Singla [Sin18] to show that we can analyze the expected utility using Ye variables and no query costs instead of using Xe variables with query costs. Next we reproduce almost the same analyis by Ehsani et al. [EHKS18] to prove the approximation guarantee. Let Z be the value we get from Algorithm 4. Then Z =Pe∈E(cid:16)Ipick are the indicator variables for the events that edge e is picked in Line 11 and it πe(cid:17) , where e Xe − Iquery e and Iquery Ipick e is queried in Line 10 respectively. e Now suppose that we run an identical copy of Algorithm 4 in parallel but we do not pay for querying in Line 10, but instead of gaining Xe, we only get Ye = min(Xe, τe). We say that this latter execution in the "free-information" world whereas the original algorithm runs in the 16 "price-of-information" world or PoI world. Let Z ′ be the value we get in the free information world. We have the following lemma. Lemma 14. The expected utility E[Z] of Approx-PoI (which is the PoI world) is equal to the expected utility of its counterpart in the free information world. Proof. Consider a case where the algorithm picks an edge that is already queried before. In this case, both algorithms get the same value, so the expected increase to Z and Z ′ are the same. Now consider the case where both algorithms query for some edge e. Notice that if an edge e is queried at any point, it is queried for the edge-value pair (e, τe). This is because τe is the maximum possible value for an edge e, and as a result, (e, τe) appears before any other (e, v) for v < τe (if it appears at all) in the permutations chosen in Line 7 of Algorithm 4. In this case, the expected increase to Z ′ in the free information world is τe · Pr[Xe > τe]. The expected increase to Z in the PoI world is −πe +Z ∞ τe (t − τe) · pe(t) dt +Z ∞ t · pe(t)dt = −πe +Z ∞ {z = −πe + E[(Xe − τe)+] } τe τe 0 +τe · Pr[Xe > τe]. τe · pe(t) dt To conclude our analysis, we now present following theorem on the approximation guarantee. Theorem 15. The expected PoI utility U(Approx-PoI) of Approx-PoI is at least (1−1/e)·OPT. Proof. By Lemma 14, we have U(Approx-PoI) = E[Z] = E[Z ′]. Since the optimal value of LPPoI is an upper bound on the optimal value OPT (by Lemma 9), it is sufficient to show that E[Z ′] > (1 − 1/e) · X(e,v)∈Eall x∗ e,vv = (1 − 1/e) ·Xb∈B cb. u,v·v as defined on Line 3 in Algorithm 4.) Let Z ′ x∗ (Recall that cb =P(e,v)∈Eb so that Z ′ = Pb∈B Z ′ a,b Ya,b b] > (1 − 1/e) · cb. Then the theorem follows from the linearity of expectation. The following calculations now follow the analysis in [EHKS18] and are included for completeness. a,b into two parts: b. We show that for any b ∈ B, E[Z ′ b =Pa∈δ(b) Ipick We proceed by splitting Z ′ a,b = Ipick Z ′ a,b (Ya,b − (1 − eta−1) · cb) + Ipick a,b (1 − eta−1) · cb . Ma,b {z Define r(t) := Pr[no edge incident to b is picked before time t] and α(t) := 1−et−1. Notice that r(t) is decreasing, and since our ta's are from a continuous distribution, r(t) is a differentiable function. Thus we have } Na,b {z } E  Xa∈δ(b) Na,b  = −Z 1 0 r′(t) · (1 − 1/et−1) · cb dt = −cbZ 1 0 r′(t) · α(t) dt. 17 By applying integration by parts, E  Xa∈δ(b) Na,b  = −cb(cid:18)[r(t) · α(t)]1 = cb(cid:18)(1 − 1/e) +Z 1 r(t) · α′(t) dt(cid:19) 0 −Z 1 r(t) · α′(t) dt(cid:19) . 0 0 (6) Now we consider the expectation of Ma,b. Note that the inequality below is due to the third property of the distributions DPoI of edge-value pairs we used in the algorithm (see Lemma 13). a E[Ma,bta = t] > Pr[no edge incident to b is picked before tta = t] Xv∈Va,b v>α(t)·cb x∗ (a,b),v(v − α(t) · cb). If ta = t, this means that ta could not have arrived before t. Hence Pr[no edge incident to b is picked before t ta = t] > Pr[no edge incident to b is picked before t ], and thus we have E[Ma,bta = t] Xa∈δ(b) x∗ (a,b),v(v − α(t) · cb) x∗ (a,b),v(v − α(t) · cb) > Pr[no edge incident to b is picked before tta = t] Xa∈δ(b) Xv∈Va,b > Pr[no edge incident to b is picked before t] Xa∈δ(b) Xv∈Va,b > r(t) Xa∈δ(b) Xv∈Va,b = r(t) x∗ (a,b),v(v − α(t) · cb) v>α(t)·cb x∗ v>α(t)·cb cb − α(t) · cb Xa∈δ(b) Xv∈Va,b (a,b),v  > r(t)(1 − α(t)) · cb. Since ta is uniformly distributed over [0, 1] for each a ∈ A, it follows that r(t) (1 − α(t)) dt. (7) Now (6) + (7) yields E  Xa∈δ(b) 0 Z ′ 0 Xa∈δ(b) E[Ma,bta = t] dt > cbZ 1 Ma,b E  =Z 1  Xa∈δ(b) a,b  = E Na,b  + E  Xa∈δ(b)  Xa∈δ(b) r(t) · α′(t) dt(cid:19) + cbZ 1 > cb(cid:18)(1 − 1/e) +Z 1 = cb(1 − 1/e) + cbZ 1 r(t)(cid:0)1 − α(t) + α′(t)(cid:1) } Mij  = (1 − 1/e) · cb. {z 0 0 0 0 r(t) (1 − α(t)) dt dt 18 Acknowledgements We are grateful to Anupam Gupta and Amit Kumar for influential discussions at an early stage of this work. References [AGM15] Marek Adamczyk, Fabrizio Grandoni, and Joydeep Mukherjee. Improved approxi- mation algorithms for stochastic matching. In Algorithms - ESA 2015, pages 1 -- 12, 2015. [AKL16] [AKL17] Sepehr Assadi, Sanjeev Khanna, and Yang Li. The stochastic matching problem with (very) few queries. In Proceedings of the 2016 ACM Conference on Economics and Computation, EC '16, pages 43 -- 60, 2016. Sepehr Assadi, Sanjeev Khanna, and Yang Li. The stochastic matching problem: Beating half with a non-adaptive algorithm. In Proceedings of the 2017 ACM Conference on Economics and Computation, EC '17, pages 99 -- 116, 2017. [BCN+17] Alok Baveja, Amit Chavan, Andrei Nikiforov, Aravind Srinivasan, and Pan Xu. Improved bounds in stochastic matching and optimization. Algorithmica, Oct 2017. [BDH+15] Avrim Blum, John P. Dickerson, Nika Haghtalab, Ariel D. Procaccia, Tuomas Sandholm, and Ankit Sharma. Ignorance is almost bliss: Near-optimal stochastic matching with few queries. In Proceedings of the Sixteenth ACM Conference on Economics and Computation, EC '15, pages 325 -- 342, 2015. [BGL+12] Nikhil Bansal, Anupam Gupta, Jian Li, Juli´an Mestre, Viswanath Nagarajan, and Atri Rudra. When lp is the cure for your matching woes: Improved bounds for stochastic matchings. Algorithmica, 63(4):733 -- 762, Aug 2012. [BR18] Soheil Behnezhad and Nima Reyhani. Almost optimal stochastic weighted match- ing with few queries. In Proceedings of the 2018 ACM Conference on Economics and Computation, EC '18, pages 235 -- 249, 2018. [BSSX16] Brian Brubach, Karthik Abinav Sankararaman, Aravind Srinivasan, and Pan Xu. New Algorithms, Better Bounds, and a Novel Model for Online Stochastic Match- ing. In 24th Annual European Symposium on Algorithms (ESA 2016), volume 57, pages 24:1 -- 24:16, 2016. [CCP05] Moses Charikar, Chandra Chekuri, and Martin P´al. Sampling bounds for stochastic optimization. In Approximation, Randomization and Combinatorial Optimization. Algorithms and Techniques, pages 257 -- 269, 2005. [CIK+09] Ning Chen, Nicole Immorlica, Anna R. Karlin, Mohammad Mahdian, and Atri Rudra. Approximating matches made in heaven. In Proc. 36th International Col- loquium on Automata, Languages and Programming, pages 266 -- 278, 2009. [CTT12] Kevin P. Costello, Prasad Tetali, and Pushkar Tripathi. Stochastic matching with commitment. In Proc. 39th International Colloquium on Automata, Languages and Programming, pages 822 -- 833, 2012. 19 [DGV04] [DGV05] Brian C. Dean, Michel X. Goemans, and Jan Vondr´ak. Approximating the stochas- tic knapsack problem: the benefit of adaptivity. In Proc. 45th Annual IEEE Sym- posium on Foundations of Computer Science, pages 208 -- 217, 2004. Brian C. Dean, Michel X. Goemans, and Jan Vondr´ak. Adaptivity and approxima- tion for stochastic packing problems. In Proc. 16th Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '05, pages 395 -- 404, 2005. [EHKS18] Soheil Ehsani, MohammadTaghi Hajiaghayi, Thomas Kesselheim, and Sahil Singla. Prophet secretary for combinatorial auctions and matroids. In Proc. 29th Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '18, pages 700 -- 714, 2018. [FMMM09] Jon Feldman, Aranyak Mehta, Vahab Mirrokni, and S. Muthukrishnan. Online stochastic matching: Beating 1-1/e. In Proc. 50th Annual IEEE Symposium on Foundations of Computer Science, FOCS '09, pages 117 -- 126, Washington, DC, USA, 2009. IEEE Computer Society. [GLS81] [GLS88] [HMZ11] M. Grotschel, L. Lov´asz, and A. Schrijver. The ellipsoid method and its conse- quences in combinatorial optimization. Combinatorica, 1(2):169 -- 197, jun 1981. M Grotschel, L Lov´asz, and A Schrijver. Geometric Algorithms and Combinatorial Optimization. Springer-Verlag, 1988. Bernhard Haeupler, Vahab S. Mirrokni, and Morteza Zadimoghaddam. Online stochastic weighted matching: Improved approximation algorithms. In Internet and Network Economics, WINE '11, pages 170 -- 181, 2011. [JL14] Patrick Jaillet and Xin Lu. Online stochastic matching: New algorithms with better bounds. Mathematics of Operations Research, 39(3):624 -- 646, Aug 2014. [KKMU07] Irit Katriel, Claire Kenyon-Mathieu, and Eli Upfal. Commitment under uncer- In Automata, Languages and tainty: Two-stage stochastic matching problems. Programming, pages 171 -- 182. Springer Berlin Heidelberg, 2007. [KVV90] [MGS11] [MR11] [MY18] [Sin18] Richard M. Karp, Umesh V. Vazirani, and Vijay V. Vazirani. An optimal algorithm for on-line bipartite matching. In Proc. 22nd Annual ACM Symposium on the Theory of Computing, pages 352 -- 358, 1990. Vahideh H. Manshadi, Shayan Oveis Gharan, and Amin Saberi. Online stochastic matching: Online actions based on offline statistics. In Proceedings of the Twenty- second Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '11, pages 1285 -- 1294, 2011. Marco Molinaro and R. Ravi. The query-commit problem. CoRR, abs/1110.0990, 2011. Takanori Maehara and Yutaro Yamaguchi. Stochastic packing integer programs with few queries. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Sympo- sium on Discrete Algorithms, SODA '18, pages 293 -- 310, 2018. Sahil Singla. The Price of Information in Combinatorial Optimization. Proc. 29th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 2523 -- 2532, nov 2018. 20 A Proofs of Some Supplementary Results Lemma 16 (Lemma 11). Fix a vertex a ∈ A. If pe,v > 0 for all (e, v) ∈ Ea and Pv∈Ve pe,v < 1 for all e ∈ δ(a), the function f is strictly submodular and strictly increasing on the lattice family Ea. Formally, 1. For any A, B ∈ Ea such that A\B 6= ∅ and B \A 6= ∅, f (A)+f (B) > f (A∩B)+f (A∪B), and 2. For any A ( B ⊆ Ea, f (B) > f (A). Proof. It is easy to see that f (F ) = 1−Qe∈E(1−Pv∈Ve:(e,v)∈F pe,v). Consider two sets A, B ∈ Ea such that A \ B 6= ∅ and B \ A 6= ∅. Fore each e ∈ E, let ae = 1 −Pv∈Ve:(e,v)∈A pe,v and be = 1 −Pv∈Ve:(e,v)∈B pe,v. Thus we have that f (A) = 1 −Qe∈E ae, f (B) = 1 −Qe∈E be, f (A ∪ B) = 1 −Qe∈E min(ae, be), and f (A ∩ B) = 1 −Qe∈E max(ae, be). The last two equations follow from the definition of the family Ea. Now we have f (A) + f (B) − f (A ∪ B) − f (A ∩ B) = Ye∈E min(ae, be) + Ye∈E max(ae, be) − Ye∈E ae − Ye∈E be. (8) Thus to prove Property 1, it is sufficient to prove that the right hand side of (8) is strictly greater than zero, which is equivalent to showing that Qe∈E min(ae, be) +Qe∈E max(ae, be) > Qe∈E ae +Qe∈E be. Since A \ B 6= ∅, we have ae < be for at least one edge e1 ∈ E. To see this, let (e, v) ∈ A \ B. Then for such edge e, it follows from the definition of set family Ea that the set Ae = A∩{(e, w) : w ∈ Ve} contains all the elements in the set Be = B ∩ {(e, w) : w ∈ Ve}, and in addition, it also contains at least one more element, namely (e, v). Since pe,v > 0, ae < be. Similarly, we have ae > be for at least one edge e2 ∈ E (since we assumed that pe,v > 0 for all (e, v) ∈ Ea). Let E1 be the (nonempty) set of edges for which ae < be, and let E2 be the (nonempty) set of edges for which ae > be. Without loss of generality we assume that E1 ∪ E2 = E (if ae = be for some e, then we can divide (8) by ae since Pv∈Ve pe,v < 1, ae > 0). We then have ae Ye∈E1 be Ye∈E1 ae + Ye∈E2 ae + Ye∈E2 min(ae, be) + Ye∈E Ye∈E max(ae, be) = Ye∈E2 > Ye∈E2 = Ye∈E be Ye∈E1 ae Ye∈E1 ae + Ye∈E be be be as required. The inequality above follows from the rearrangement inequality as Qe∈E1 be > Qe∈E1 ae and Qe∈E2 ae >Qe∈E2 be. e ∈ E, ae > be. Hence f (B) − f (A) =Qe∈E ae −Qe∈E be > 0. As for Property 2, suppose that A ( B. Then for all e ∈ E, ae > be, and for at least one 21
1508.04874
2
1508
2015-11-05T07:04:31
A Faster Cutting Plane Method and its Implications for Combinatorial and Convex Optimization
[ "cs.DS", "cs.DM", "math.NA", "math.OC" ]
We improve upon the running time for finding a point in a convex set given a separation oracle. In particular, given a separation oracle for a convex set $K\subset \mathbb{R}^n$ contained in a box of radius $R$, we show how to either find a point in $K$ or prove that $K$ does not contain a ball of radius $\epsilon$ using an expected $O(n\log(nR/\epsilon))$ oracle evaluations and additional time $O(n^3\log^{O(1)}(nR/\epsilon))$. This matches the oracle complexity and improves upon the $O(n^{\omega+1}\log(nR/\epsilon))$ additional time of the previous fastest algorithm achieved over 25 years ago by Vaidya for the current matrix multiplication constant $\omega<2.373$ when $R/\epsilon=n^{O(1)}$. Using a mix of standard reductions and new techniques, our algorithm yields improved runtimes for solving classic problems in continuous and combinatorial optimization: Submodular Minimization: Our weakly and strongly polynomial time algorithms have runtimes of $O(n^2\log nM\cdot\text{EO}+n^3\log^{O(1)}nM)$ and $O(n^3\log^2 n\cdot\text{EO}+n^4\log^{O(1)}n)$, improving upon the previous best of $O((n^4\text{EO}+n^5)\log M)$ and $O(n^5\text{EO}+n^6)$. Matroid Intersection: Our runtimes are $O(nrT_{\text{rank}}\log n\log (nM) +n^3\log^{O(1)}(nM))$ and $O(n^2\log (nM) T_{\text{ind}}+n^3 \log^{O(1)} (nM))$, achieving the first quadratic bound on the query complexity for the independence and rank oracles. In the unweighted case, this is the first improvement since 1986 for independence oracle. Submodular Flow: Our runtime is $O(n^2\log nCU\cdot\text{EO}+n^3\log^{O(1)}nCU)$, improving upon the previous bests from 15 years ago roughly by a factor of $O(n^4)$. Semidefinite Programming: Our runtime is $\tilde{O}(n(n^2+m^{\omega}+S))$, improving upon the previous best of $\tilde{O}(n(n^{\omega}+m^{\omega}+S))$ for the regime where the number of nonzeros $S$ is small.
cs.DS
cs
A Faster Cutting Plane Method and its Implications for Combinatorial and Convex Optimization Yin Tat Lee Aaron Sidford Sam Chiu-wai Wong MIT MIT UC Berkeley [email protected] [email protected] [email protected] Abstract In this paper we improve upon the running time for finding a point in a convex set given a separation oracle. In particular, given a separation oracle for a convex set K ⊂ Rn that is contained in a box of radius R we show how to either compute a point in K or prove that K does not contain a ball of radius  using an expected O(n log(nR/)) evaluations of the oracle and additional time O(n3 logO(1)(nR/)). This matches the oracle complexity and improves upon the O(nω+1 log(nR/)) additional time of the previous fastest algorithm achieved over 25 years ago by Vaidya [103] for the current value of the matrix multiplication constant ω < 2.373 [110, 41] when R/ = O(poly(n)). Using a mix of standard reductions and new techniques we show how our algorithm can be used to improve the running time for solving classic problems in continuous and combinatorial optimization. In particular we provide the following running time improvements: • Submodular Function Minimization: let n be the size of the ground set, M be the maximum absolute value of function values, and EO be the time for function evaluation. Our weakly and strongly polynomial time algorithms have a running time of O(n2 log nM · EO + n3 logO(1) nM ) and O(n3 log2 n · EO + n4 logO(1) n), improving upon the previous best of O((n4 · EO + n5) log M ) and O(n5 · EO + n6) respectively. • Submodular Flow: let n and m be the number of vertices and edges, C be the maximum edge cost in absolute value, and U be the maximum edge capacity in absolute value. We obtain a faster weakly polynomial running time of O(n2 log nCU·EO+n3 logO(1) nCU ), improving upon the previous best of O(mn5 log nU · EO) and O(cid:0)n4h min{log C, log U}(cid:1) from 15 years ago by a factor of O(n4). We also achieve faster strongly polynomial time algorithms as a consequence of our result on submodular minimization. • Semidefinite Programming: let n be the number of constraints, m be the number of dimensions and S be the total number of non-zeros in the constraint matrix. We obtain a running time of O(n(n2 + mω + S)), improving upon the previous best of O(n(nω + mω + S)) for the regime S is small. 1 • Matroid Intersection: let n be the size of the ground set, r be the maximum size of independent sets, M be the maximum absolute value of element weight, and Trank and Tind be the time for each rank and independence oracle query. We obtain a running time of O(nrTrank log n log(nM )+n3 logO(1) nM ) and O(n2Tind log(nM )+ n3 logO(1) nM ), achieving the first quadratic bound on the query complexity for the in- dependence and rank oracles. In the unweighted case, this is the first improvement since 1986 for independence oracle. Contents Overview 1 Introduction 1.1 Paper Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Overview of Our Results 2.1 Cutting Plane Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Convex Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Submodular Function Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Preliminaries 3.1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Separation Oracles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I A Faster Cutting Plane Method 4 4 5 5 5 6 8 8 8 9 10 4 Introduction 10 4.1 Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.2 Challenges in Improving Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3 Our Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.4 Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5 Preliminaries 14 5.1 Leverage Scores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5.2 Hybrid Barrier Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 6 Our Cutting Plane Method 15 6.1 Centering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 6.2 Changing Constraints 6.3 Hybrid Center Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 6.4 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 6.5 Guarantees of the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 7 Technical Tools 38 7.1 Estimating Changes in Leverage Scores . . . . . . . . . . . . . . . . . . . . . . . . . 38 7.2 The Stochastic Chasing (cid:126)0 Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 II A User’s Guide to Cutting Plane Methods 45 8 Introduction 45 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 8.1 Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 8.2 Applications 8.3 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 9 Preliminaries 50 2 10 Convex Optimization 53 10.1 From Feasibility to Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 10.2 Duality and Semidefinite Programming . . . . . . . . . . . . . . . . . . . . . . . . . . 55 11 Intersection of Convex Sets 60 11.1 The Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 11.2 Matroid Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 11.3 Submodular Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 11.4 Affine Subspace of Convex Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 III Submodular Function Minimization 71 12 Introduction 71 12.1 Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 12.2 Our Results and Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 12.3 Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 13 Preliminaries 74 13.1 Submodular Function Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 13.2 Lov´asz Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 13.3 Polyhedral Aspects of SFM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 14 Improved Weakly Polynomial Algorithms for SFM 77 15 Improved Strongly Polynomial Algorithms for SFM 80 15.1 Improved Oracle Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 15.2 Technical Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 15.2.1 SFM over Ring Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 15.2.2 Identifying New Valid Arcs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 15.3 (cid:101)O(n4 · EO + n5) Time Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 15.4 (cid:101)O(n3 · EO + n4) Time Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 15.3.1 Consolidating A and f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 15.3.2 Deducing New Constraints xi = 0, xj = 1, xi = xj or xi ≤ xj . . . . . . . . . 89 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 15.3.3 Running Time 15.4.1 Partitioning Ground Set into Buckets . . . . . . . . . . . . . . . . . . . . . . 96 15.4.2 Separating Hyperplane: Project and Lift . . . . . . . . . . . . . . . . . . . . . 97 15.4.3 Deducing New Constraints xi = 0, xj = 1, xi = xj or xi ≤ xj . . . . . . . . . 99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 15.4.4 Running Time 16 Discussion and Comparison with Previous Algorithms 103 16.1 Open Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 3 Part Overview 1 Introduction The ellipsoid method and more generally, cutting plane methods,1 that is optimization algorithms which iteratively call a separation oracle, have long been central to theoretical computer science. In combinatorial optimization, since Khachiyan’s seminal result in 1980 [65] proving that the ellipsoid method solves linear programs in polynomial time, the ellipsoid method has been crucial to solving discrete problems in polynomial time [49]. In continuous optimization, cutting plane methods have long played a critical role in convex optimization, where they are fundamental to the theory of non-smooth optimization [45]. Despite the key role that cutting plane methods have played historically in both combinatorial and convex optimization, over the past two decades progress on improving both the theoretical running time of cutting plane methods as well as the complexity of using cutting plane methods for combinatorial optimization has stagnated.2 The theoretical running time of cutting plane methods for convex optimization has not been improved since the breakthrough result by Vaidya in 1989 [103, 105]. Moreover, for many of the key combinatorial applications of ellipsoid method, such as submodular minimization, matroid intersection and submodular flow, the running time improvements over the past two decades have been primarily combinatorial; that is they have been achieved by discrete algorithms that do not use numerical machinery such as cutting plane methods. In this paper we make progress on these classic optimization problems on two fronts. First we show how to improve on the running time of cutting plane methods for a broad range of parameters that arise frequently in both combinatorial applications and convex programming (Part I). Second, we provide several frameworks for applying the cutting plane method and illustrate the efficacy of these frameworks by obtaining faster running times for semidefinite programming, matroid intersec- tion, and submodular flow (Part II). Finally, we show how to couple our approach with the problem specific structure and obtain faster weakly and strongly polynomial running times for submodular function minimization, a problem of tremendous importance in combinatorial optimization (Part III). In both cases our algorithms are faster than previous best by a factor of roughly Ω(n2). We remark that many of our running time improvements come both from our faster cutting method and from new careful analysis of how to apply these cutting plane methods. In fact, simply using our reductions to cutting plane methods and a seminal result of Vaidya [103, 105] on cutting plane methods we provide running times for solving many of these problems that improves upon the previous best stated. As such, we organized our presentation to hopefully make it easy to apply cutting plane methods to optimization problems and obtain provable guarantees in the future. Our results demonstrate the power of cutting plane methods in theory and possibly pave the way for new cutting plane methods in practice. We show how cutting plane methods can continue to improve running times for classic optimization problems and we hope that these methods may find further use. As cutting plane methods such as analytic cutting plane method [43, 10, 44, 87, 111, 45] are frequently used in practice [48, 42], these techniques may have further implications. 1Throughout this paper our focus is on algorithms for polynomial time solvable convex optimization problems given access to a linear separation oracle. Our usage of the term cutting plane methods, should not be confused with work on integer programming, an NP-hard problem. 2There are exceptions to this trend. For example, [70] showed how to apply cutting plane methods to yield running time improvements for semidefinite programming, and recently [15] showed how to use cutting plane methods to obtain an optimal result for smooth optimization problems. 4 1.1 Paper Organization After providing an overview of our results (Section 2) and preliminary information and notation used throughout the paper (Section 3), we split the remainder of the paper into three parts: • In Part I we provide our new cutting plane method. • In Part II we provide several general frameworks for using this cutting plane method and illustrate these frameworks with applications in combinatorial and convex optimization. • In Part III we then consider the more specific problem of submodular function minimization and show how our methods can be used to improve the running time for both strongly and weakly polynomial time algorithms. We aim to make each part relatively self contained. While each part builds upon the previous and the problems considered in each part are increasingly specific, we present the key results in each section in a modular way so that they may be read in any order. The dependencies between the different parts of our paper are characterized by the following: • Part I presents our faster cutting plane method as Theorem 31. • Part II depends only on Theorem 31 of Part I and presents a general running time guarantee for convex optimization problems as Theorem 42. • The faster weakly polynomial time algorithm in Part III depends only on Theorem 42, Part II. • The faster strongly polynomial time algorithm in Part III depends only on Theorem 31, Part I. 2 Overview of Our Results Here we briefly summarize the contributions of our paper. For each of Part I, Part II, and Part III we describe the key technical contributions and present the running time improvements achieved. 2.1 Cutting Plane Methods The central problem we consider in Part I is as follows. We are promised that a set K is contained a box of radius R and a separation oracle that given a point (cid:126)x in time SO either outputs that (cid:126)x is in K or outputs a separating hyperplane. We wish to either find a point in K or prove that K does not contain an ball of radius . The running times for this problem are given in Table 1. Inscribed Ellipsoid [66, 88] Year Algorithm 1979 Ellipsoid Method [97, 112, 65] 1988 1989 Volumetric Center [103] 1995 Analytic Center [10] 2004 Random Walk [13] 2013 This paper Complexity O(n2SO log κ + n4 log κ) O(nSO log κ + (n log κ)4.5) O(nSO log κ + n1+ω log κ) O(nSO log2 κ + nω+1 log2 κ + (n log κ)2+ω/2) → O(nSO log κ + n7 log κ) O(nSO log κ + n3 logO(1) κ) Table 1: Algorithms for the Feasibility Problem. κ indicates nR/. The arrow, →, indicates that it solves a more general problem where only a membership oracle is given. 5 This is an improvement over the previous best running time of (cid:101)O(nSO log(nR/) + nω+1 log(nR/)) In Part I we show how to solve this problem in O(nSO log(nR/) + n3 logO(1)(nR/)) time. for the current best known bound of ω < 2.37 [41] assuming that R/ = O(poly(n)), a common assumption for many problems in combinatorial optimization and numerical analysis as we find in Part II and Part III. (See Table 1 for a summary of previous running times.) Our key idea for achieving this running time improvement is a new straightforward technique for providing low variance unbiased estimates for changes in leverage scores that we hope will be of independent interest (See Section 7.1). We show how to use this technique along with ideas from [10, 104, 76] to decrease the (cid:101)O(nω+1 log(D/)) overhead in the previous fastest algorithm [103]. 2.2 Convex Optimization In Part II we provide two techniques for applying our cutting plane method (and cutting plane methods in general) to optimization problems and provide several applications of these techniques. The first technique concerns reducing the number of dimensions through duality. For many problems, their dual is significantly simpler than itself (primal). We use semidefinite programming as a concrete example to show how to improve upon the running time for finding both primal and dual solution by using the cutting planes maintained by our cutting plane method. (See Table 2.) The second technique concerns how to minimize a linear function over the intersection of convex sets using optimization oracle. We analyze a simple potential function which allows us to bypass the typical reduction between separation and optimization to achieve faster running times. This reduction provides an improvement over the reductions used previously in [49]. Moroever, we show how this technique allows us to achieve improved running times for matroid intersection and minimum cost submodular flow. (See Tables 2, 3, 4, and 5 for running time summaries.) Authors Nesterov, Nemirovsky[89] Anstreicher [7] Krishnan, Mitchell [70] This paper Years 1992 2000 2003 2015 √ O( Running times m(nmω + nω−1m2)) O((mn)1/4(nmω + nω−1m2)) O(n(nω + mω + S)) (dual SDP) O(n(n2 + mω + S)) Table 2: Algorithms for solving a m × m SDP with n constraints and S non-zero entries Authors Edmonds [26] Aigner, Dowling [2] Tomizawa, Iri [102] Lawler [72] Edmonds [28] Cunningham [21] This paper Years 1968 1971 1974 1975 1979 1986 2015 Complexity not stated O(nr2Tind) not stated O(nr2Tind) not stated O(nr1.5Tind) O(n2 log nTind + n3 logO(1) n) O(nr log2 nTrank + n3 logO(1) n) Table 3: Algorithms for (unweighted) matroid intersection. n is the size of the ground set, r is the maximum rank of the two matroids, Tind is the time to check if a set is independent (membership oracle), and Trank is the time to compute the rank of a given set (rank oracle). 6 Authors Edmonds [26] Tomizawa, Iri [102] Lawler [72] Edmonds [28] Frank [33] Orlin, Ahuja [91] Brezovec, Cornu´ejols, Glover[14] Fujishige, Zhang [39] Shigeno, Iwata [96] This paper Years 1968 1974 1975 1979 1981 1983 1986 1995 1995 2015 Running times not stated not stated O(nr2Tind + nr3) O(n2r(Tcircuit + n)) not stated not stated O(nr(Tcircuit + r + log n)) O(n2r0.5 log rM · Tind) O((n + Tcircuit)nr0.5 log rM ) O(n2 log nMTind + n3 logO(1) nM ) O(nr log n log nMTrank + n3 logO(1) nM ) Table 4: Algorithms for weighted matroid intersection. In addition to the notation in Table 3 Tcircuit is the time needed to find a fundamental circuit and M is the bit complexity of the weights. Authors Fujishige [35] Grotschel, Lovasz, Schrijver[49] Zimmermann [113] Barahona, Cunningham [12] Cunningham, Frank [22] Fujishige [36] Frank, Tardos [34] Cui, Fujishige [108] Fujishige, Rock, Zimmermann[38] Chung, Tcha [18] Zimmermann [114] McCormick, Ervolina [82] Wallacher, Zimmermann [109] Iwata [52] Iwata, McCormick, Shigeno [57] Iwata, McCormick, Shigeno [58] Fleischer, Iwata, McCormick[32] Iwata, McCormick, Shigeno [59] Fleischer, Iwata [30] This paper Running times not stated weakly polynomial not stated not stated not stated → O(n6h log n) → O(n4h log C) Years 1978 1981 1982 1984 1985 1987 1987 1988 1989 1991 1992 1993 1994 1997 1998 1999 1999 1999 2000 2015 O(n2 log nCU · EO + n3 logO(1) nCU ) O(cid:0)n4h min(cid:8)log nC, n2 log n(cid:9)(cid:1) O(cid:0)n6h min(cid:8)log nU, n2 log n(cid:9)(cid:1) O(cid:0)n4h min(cid:8)log U, n2 log n(cid:9)(cid:1) O(cid:0)n4h min(cid:8)log C, n2 log n(cid:9)(cid:1) O(n7h∗ log nCU ) O(n8h log nCU ) O(mn5 log nU · EO) not stated not stated not stated strongly polynomial O(n7h log U ) Table 5: Algorithms for minimum cost submodular flow with n vertices, maximum cost C and maximum capacity U . The factor h is the time for an exchange capacity oracle, h∗ is the time for a “more complicated exchange capacity oracle,” and EO is the time for evaluation oracle of the submodular function. The arrow, →, indicates that it uses the current best submodular flow algorithm as subroutine which was non-existent at the time of the publication. 7 2.3 Submodular Function Minimization In Part III we consider the problem of submodular minimization, a fundamental problem in com- binatorial optimization with many diverse applications in theoretical computer science, operations research, machine learning and economics. We show that by considering the interplay between the guarantees of our cutting plane algorithm and the primal-dual structure of submodular minimiza- tion we can achieve improved running times in various settings. First, we show that a direct application of our method yields an improved weakly polynomial time algorithm for submodular minimization. Then, we present a simple geometric argument that submodular function can be solved with O(n3 log n · EO) oracle calls but with exponential running time. Finally, we show that by further studying the combinatorial structure of submodular minimization and a modification to our cutting plane algorithm we can obtained a fully improved strongly polynomial time algorithm for submodular minimization. We summarize the improvements in Table 6. Authors Years Grotschel, Lov´asz, Schrijver [49, 50] Cunningham [20] Schrijver [93] Iwata, Fleischer, Fujishige[56] Iwata, Fleischer [31] Iwata [54] Vygen [107] Orlin [90] Iwata, Orlin [60] 1981,1988 1985 2000 2000 2000 2003 2003 2007 2009 Our algorithms 2015 Running times (cid:101)O(n5 · EO + n7) [81] O(M n6 log nM · EO) O(n8 · EO + n9) O(n5 · EO log M ) O(n7 log n · EO) O(n7 · EO + n8) O((n4 · EO + n5) log M ) O((n6 · EO + n7) log n) O(n7 · EO + n8) O(n5 · EO + n6) O((n4 · EO + n5) log nM ) O((n5 · EO + n6) log n) O(n2 log nM · EO + n3 logO(1) nM ) O(n3 log2 n · EO + n4 logO(1) n) Remarks first weakly and strongly first combin. pseudopoly first combin. strongly first combin. strongly current best weakly current best strongly Table 6: Algorithms for submodular function minimization. 3 Preliminaries Here we introduce notation and concepts we use throughout the paper. 3.1 Notation Basics: Throughout this paper, we use vector notation, e.g (cid:126)x = (x1, . . . , xn), to denote a vector and bold, e.g. A, to denote a matrix. We use nnz((cid:126)x) or nnz(A) to denote the number of nonzero entries in a vector or a matrix respectively. Frequently, for (cid:126)x ∈ Rd we let X ∈ Rd×d denote diag((cid:126)x), the diagonal matrix such that Xii = xi. For a symmetric matrix, M, we let diag(M) denote the vector corresponding to the diagonal entries of M, and for a vector, (cid:126)x, we let (cid:107)(cid:126)x(cid:107)M √ (cid:126)xT M(cid:126)x. def= 8 Running Times: We typically use XO to denote the running time for invoking the oracle, where X depends on the type of oracle, e.g., SO typically denotes the running time of a separation oracle, EO denotes the running time of an evaluation oracle, etc. Furthermore, we use (cid:101)O(f ) def= O(f logO(1) f ). Standard Convex Sets: We let Bp(r) def= {(cid:126)x : (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)p ≤ r} denote a ball of radius r in the (cid:96)p Spectral Approximations: For symmetric matrices N, M ∈ Rn×n, we write N (cid:22) M to de- note that (cid:126)xT N(cid:126)x ≤ (cid:126)xT M(cid:126)x for all (cid:126)x ∈ Rn and we define N (cid:23) M, N ≺ M and N (cid:31) M analogously. norm. For brevity we refer to B2(r) as a a ball of radius r and B∞(r) as a box of radius r. Misc: We let ω < 2.373 [110] denote the matrix multiplication constant. 3.2 Separation Oracles Throughout this paper we frequently make assumptions about the existence of separation oracles for sets and functions. Here we formally define these objects as we use them throughout the paper. Our definitions are possibly non-standard and chosen to handle the different settings that occur in this paper. Definition 1 (Separation Oracle for a Set). Given a set K ⊂ Rn and δ ≥ 0, a δ-separation oracle for K is a function on Rn such that for any input (cid:126)x ∈ Rn, it either outputs “successful” or a half space of the form H = {(cid:126)z : (cid:126)cT (cid:126)z ≤ (cid:126)cT (cid:126)x + b} ⊇ K with b ≤ δ(cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 and (cid:126)c (cid:54)= (cid:126)0. We let SOδ(K) be the time complexity of this oracle. For brevity we refer to a 0-separation oracle for a set as just a separation oracle. We refer to the hyperplanes defining the halfspaces returned by a δ-separation oracle as oracle hyperplanes. Note that in Definition 1 we do not assume that K is convex. However, we remark that it is well known that there is a separation oracle for a set if and only if it is convex and that there is a δ separation oracle if and only if the set is close to convex in some sense. Definition 2 (Separation Oracle for a Function). For any convex function f , η ≥ 0 and δ ≥ 0, a (η, δ)-separation oracle on a convex set Γ for f is a function on Rn such that for any input (cid:126)x ∈ Γ, it either asserts f ((cid:126)x) ≤ min(cid:126)y∈Γ f ((cid:126)y) + η or outputs a half space H such that with b ≤ δ(cid:13)(cid:13)(cid:126)c(cid:13)(cid:13) and (cid:126)c (cid:54)= (cid:126)0. We let SOη,δ(f ) be the time complexity of this oracle. {(cid:126)z ∈ Γ : f ((cid:126)z) ≤ f ((cid:126)x)} ⊂ H def= {(cid:126)z : (cid:126)cT (cid:126)z ≤ (cid:126)cT (cid:126)x + b} (3.1) 9 Part I A Faster Cutting Plane Method 4 Introduction Throughout Part I we study the following feasibility problem: Definition 3 (Feasibility Problem). Given a separation oracle for a set K ⊆ Rn contained in a box of radius R either find a point (cid:126)x ∈ K or prove that K does not contain a ball of radius . This feasibility problem is one of the most fundamental and classic problems in optimization. Since the celebrated result of Yudin and Nemirovski [112] in 1976 and Khachiyan [65] in 1979 essentially proving that it can be solved in time O(poly(n) · SO · log(R/)), this problem has served as one of the key primitives for solving numerous problems in both combinatorial and convex optimization. Despite the prevalence of this feasibility problem, the best known running time for solving this problem has not been improved in over 25 years. In a seminal paper of Vaidya in 1989 [103], he showed how to solve the problem in (cid:101)O(n·SO·log(nR/)+nω+1 log(nR/)) time. Despite interesting generalizations and practical improvements [5, 92, 43, 10, 44, 87, 111, 45, 15], the best theoretical guarantees for solving this problem have not been improved since. In Part I we show how to improve upon Vaidya’s running time in certain regimes. We provide a cutting plane algorithm which achieves an expected running time of O(n · SO · log(nR/) + n3 logO(1)(nR/)), improving upon the previous best known running time for the current known value of ω < 2.373 [110, 41] when R/ = O(poly(n)). We achieve our results by the combination of multiple techniques. First we show how to use techniques from the work of Vaidya and Atkinson to modify Vaidya’s scheme so that it is able to tolerate random noise in the computation in each iteration. We then show how to use known numer- ical machinery [104, 99, 76] in combination with some new techniques (Section 7.1 and Section 7.2) to implement each of these relaxed iterations efficiently. We hope that both these numerical tech- niques as well as our scheme for approximating complicated methods, such as Vaidya’s, may find further applications. While our paper focuses on theoretical aspects of cutting plane methods, we achieve our results via the careful application of practical techniques such as dimension reduction and sampling. As such we hope that ideas in this paper may lead to improved practical3 algorithms for non-smooth optimization. 4.1 Previous Work Throughout this paper, we restrict our attention to algorithms for the feasibility problem that have a polynomial dependence on SO, n, and log(R/). Such “efficient” algorithms typically follow the following iterative framework. First, they compute some trivial region Ω that contains K. Then, they call the separation oracle at some point (cid:126)x ∈ Ω. If (cid:126)x ∈ K the algorithm terminates having If (cid:126)x /∈ K then the separation oracle must return a half-space successfully solved the problem. 3Although cutting plane methods are often criticized for their empirical performance, recently, Bubeck, Lee and Singh [15] provided a variant of the ellipsoid method that achieves the same convergence rate as Nesterov’s accelerated gradient descent. Moreover, they provided numerical evidence that this method can be superior to Nesterov’s accel- erated gradient descent, thereby suggesting that cutting plane methods can be as aggressive as first order methods if designed properly. 10 Year Algorithm 1979 Ellipsoid Method [97, 112, 65] 1988 1989 Volumetric Center [103] Inscribed Ellipsoid [66, 88] 1995 Analytic Center [10] O 2004 Random Walk [13] 2013 This paper Complexity O(n2SO log κ + n4 log κ) O(nSO log κ + (n log κ)4.5) O(nSO log κ + n1+ω log κ) (cid:18) nSO log2 κ + nω+1 log2 κ + (n log κ)2+ω/2 → O(nSO log κ + n7 log κ) O(nSO log κ + n3 logO(1) κ) (cid:19) Table 7: Algorithms for the Feasibility Problem. κ indicates nR/. The arrow, →, indicates that it solves a more general problem where only a membership oracle is given. containing K. The algorithm then uses this half-space to shrink the region Ω while maintaining the invariant that K ⊆ Ω. The algorithm then repeats this process until it finds a point (cid:126)x ∈ K or the region Ω becomes too small to contain a ball with radius . Previous works on efficient algorithms for the feasibility problem all follow this iterative frame- work. They vary in terms of what set Ω they maintain, how they compute the center to query the separation oracle, and how they update the set. In Table 7, we list the previous running times for solving the feasibility problem. As usual SO indicates the cost of the separation oracle. To simplify the running times we let κ def= nR/. The running times of some algorithms in the table depend on R/ instead of nR/. However, for many situations, we have log(R/) = Θ(log(nR/)) and hence we believe this is still a fair comparison. The first efficient algorithm for the feasibility problem is the ellipsoid method, due to Shor [97], Nemirovksii and Yudin [112], and Khachiyan [65]. The ellipsoid method maintains an ellipsoid as Ω and uses the center of the ellipsoid as the next query point. It takes Θ(n2 log κ) calls of oracle which is far from the lower bound Ω(n log κ) calls [86]. To alleviate the problem, the algorithm could maintain all the information from the oracle, i.e., the polytope created from the intersection of all half-spaces obtained. The center of gravity method [77] achieves the optimal oracle complexity using this polytope and the center of gravity of this polytope as the next point. However, computing center of gravity is computationally expensive and hence we do not list its running time in Table 7. The Inscribed Ellipsoid Method [66] also achieved an optimal oracle complexity using this polytope as Ω but instead using the center of the maximal inscribed ellipsoid in the polytope to query the separation oracle. We listed it as occurring in year 1988 in Table 7 because it was [88] that yielded the first polynomial time algorithm to actually compute this maximal inscribed ellipsoid for polytope. Vaidya [103] obtained a faster algorithm by maintaining an approximation of this polytope and using a different center, namely the volumetric center. Although the oracle complexity of this volumetric center method is very good, the algorithm is not extremely efficient as each iteration involves matrix inversion. Atkinson and Vaidya [10] showed how to avoid this computation in certain settings. However, they were unable to achieve the desired convergence rate from their method. Bertsimas and Vempala [13] also gives an algorithm that avoids these expensive linear algebra operations while maintaining the optimal convergence rate by using techniques in sampling convex sets. Even better, this result works for a much weaker oracle, the membership oracle. However, the additional cost of this algorithm is relatively high in theory. We remark that while there are considerable improvemenst on the sampling techniques [79, 63, 76], the additional cost is still quite high compared to standard linear algebra. 11 4.2 Challenges in Improving Previous Work Our algorithm builds upon the previous fastest algorithm of Vaidya [105]. Ignoring implementation details and analysis, Vaidya’s algorithm is quite simple. This algorithm simply maintains a polytope P (k) = {x ∈ Rn : A(cid:126)x − (cid:126)b ≥ (cid:126)0} as the current Ω and uses the volumetric center, the minimizer of the following volumetric barrier function log det(cid:0)AT S−2 (cid:126)x A(cid:1) arg min (cid:126)x 1 2 where S(cid:126)x def= diag(A(cid:126)x − (cid:126)b) (4.1) as the point at which to query the separation oracle. The polytope is then updated by adding shifts of the half-spaces returned by the separation oracle and dropping unimportant constraints. By choosing the appropriate shift, picking the right rule for dropping constraints, and using Newton’s method to compute the volumetric center he achieved a running time of O(n·SO·log κ+n1+ω log κ). While Vaidya’s algorithm’s dependence on SO is essentially optimal, the additional per-iteration costs of his algorithm could possibly be improved. The computational bottleneck in each iteration of Vaidya’s algorithm is computing the gradient of log det which in turn involves computing the leverage scores (cid:126)σ((cid:126)x) def= diag(S−1 x ), a commonly occurring quantity in nu- merical analysis and convex optimization [99, 19, 78, 76, 75]. As the best known algorithms for computing leverage scores exactly in this setting take time O(nω), directly improving the running time of Vaidya’s algorithm seems challenging. x A(cid:1)−1 AT S−1 x A(cid:0)AT S−2 However, since an intriguing result of Spielman and Srivastava in 2008 [99], it has been well known that using Johnson-Lindenstrauss transform these leverage scores can be computed up to a multiplicative (1 ± ) error by solving O(−2 log n) linear systems involving AT S−2 x A. While in general this still takes time O(−2nω), there are known techniques for efficiently maintaining the inverse of a matrix so that solving linear systems take amortized O(n2) time [104, 75, 76]. Consequently if it could be shown that computing approximate leverage scores sufficed, this would potentially decrease the amortized cost per iteration of Vaidya’s method. Unfortunately, Vaidya’s method does not seem to tolerate this type of multiplicative error. If leverage scores were computed this crudely then in using them to compute approximate gradients for (4.1), it seems that any point computed would be far from the true center. Moreover, without being fairly close to the true volumetric center, it is difficult to argue that such a cutting plane method would make sufficient progress. To overcome this issue, it is tempting to directly use recent work on improving the running time of linear program [75]. In this work, the authors faced a similar issue where a volumetric, i.e. log det, potential function had the right analytic and geometric properties, however was computational expensive to minimize. To overcome this issue the authors instead computed a weighted analytic center: wi log si((cid:126)x) where (cid:126)s((cid:126)x) def= A(cid:126)x − (cid:126)b . − (cid:88) i∈[m] arg min (cid:126)x For carefully chosen weights this center provides the same convergence guarantees as the volumetric potential function, while each step can be computed by solving few linear systems (rather than forming the matrix inverse). Unfortunately, it is unclear how to directly extend the work in [75] on solving an explicit linear program to the feasibility problem specified by a separation oracle. While it is possible to approximate the volumetric barrier by a weighted analytic center in many respects, proving that this approximation suffices for fast convergence remains open. In fact, the volumetric barrier 12 function as used in Vaidya’s algorithm is well approximated simply by the standard analytic center − (cid:88) i∈[m] arg min (cid:126)x log si((cid:126)x) where (cid:126)s((cid:126)x) def= A(cid:126)x − (cid:126)b . as all the unimportant constraints are dropped during the algorithm. However, despite decades of research, the best running times known for solving the feasibility problem using the analytic center are Vaidya and Atkinson algorithm from 1995 [10]. While the running time of this algorithm could possibly be improved using approximate leverage score computations and amortized efficient linear system solvers, unfortunately at best, without further insight this would yield an algorithm which requires a suboptimal O(n logO(1) κ) queries to the separation oracle. As pointed out in [10], the primary difficulty in using any sort of analytic center is quantifying the amount of progress made in each step. We still believe providing direct near-optimal analysis of weighted analytic center is a tantalizing open question warranting further investigation. However, rather than directly address the question of the performance of weighted analytic centers for the feasibility problem, we take a slightly different approach that side-steps this issue. We provide a partial answer that still sheds some light on the performance of the weighted analytic center while still providing our desired running time improvements. 4.3 Our Approach To overcome the shortcoming of the volumetric and analytic centers we instead consider a hybrid barrier function wi log si((cid:126)x) + log det(AT S−1 x A) where (cid:126)s((cid:126)x) def= A(cid:126)x − (cid:126)b . − (cid:88) i∈[m] arg min (cid:126)x this potential function is the same as the gradients of (cid:80) for careful chosen weights. Our key observation is that for correct choice of weights, we can compute the gradient of this potential function. In particular if we let (cid:126)w = (cid:126)τ − (cid:126)σ((cid:126)x) then the gradient of i∈[m] τi log si((cid:126)x), which we can compute efficiently. Moreover, since we are using log det, we can use analysis similar to Vaidya’s algorithm [103] to analyze the convergence rate of this algorithm. Unfortunately, this is a simple observation and does not immediately change the problem sub- stantially. It simply pushes the problem of computing gradients of log det to computing (cid:126)w. There- fore, for this scheme to work, we would need to ensure that the weights do not change too much and that when they change, they do not significantly hurt the progress of our algorithm. In other words, for this scheme to work, we would still need very precise estimates of leverage scores. However, we note that the leverage scores (cid:126)σ((cid:126)x) do not change too much between iterations. Moreover, we provide what we believe is an interesting technical result that an unbiased estimates to the changes in leverage scores can be computed using linear system solvers such that the total error of the estimate is bounded by the total change of the leverage scores (See Section 7.1). Using this result our scheme simply follows Vaidya’s basic scheme in [103], however instead of minimizing the hybrid barrier function directly we alternate between taking Newton steps we can compute, changing the weights so that we can still compute Newton steps, and computing accurate unbiased estimates of the changes in the leverage scores so that the weights do not change adversarially by too much. To make this scheme work, there are two additional details that need to be dealt with. First, we cannot let the weights vary too much as this might ultimately hurt the rate of progress of our algorithm. Therefore, in every iteration we compute a single leverage score to high precision to 13 control the value of wi and we show that by careful choice of the index we can ensure that no weight gets too large (See Section 7.2). Second, we need to show that changing weights does not affect our progress by much more than the progress we make with respect to log det. To do this, we need to show the slacks are bounded above and below. We enforce this by adding regularization terms and instead consider the potential function log det(cid:0)AT S−2 x A + λI(cid:1) + 1 2 (cid:13)(cid:13)x(cid:13)(cid:13)2 2 λ 2 p(cid:126)e((cid:126)x) = − (cid:88) i∈[m] wi log si((cid:126)x) + This allows us to ensure that the entries of (cid:126)s((cid:126)x) do not get too large or too small and therefore changing the weighting of the analytic center cannot affect the function value too much. Third, we need to make sure our potential function is convex. If we simply take (cid:126)w = (cid:126)τ − (cid:126)σ((cid:126)x) with (cid:126)τ as an estimator of (cid:126)σ((cid:126)x), (cid:126)w can be negative and the potential function could be non-convex. To circumvent this issue, we use (cid:126)w = ce + (cid:126)τ − (cid:126)σ((cid:126)x) and make sure(cid:13)(cid:13)(cid:126)τ − (cid:126)σ((cid:126)x)(cid:13)(cid:13)∞ < ce. Combining these insights, using efficient algorithms for solving a sequence of slowly changing linear systems [104, 75, 76], and providing careful analysis ultimately allows us to achieve a running time of O(nSO log κ+n3 logO(1) κ) for the feasibility problem. Furthermore, in the case that K does not contain a ball of radius , our algorithm provides a proof that the polytope does not contain a ball of radius . This proof ultimately allows us to achieve running time improvements for strongly polynomial submodular minimization in Part III. 4.4 Organization The rest of Part I is organized as follows. In Section 5 we provide some preliminary information and notation we use throughout Part I. In Section 6 we then provide and analyze our cutting plane method. In Section 7 we provide key technical tools which may be of independent interest. 5 Preliminaries Here we introduce some notation and concepts we use throughout Part I. 5.1 Leverage Scores Our algorithms in this section make extensive use of leverage scores, a common measure of the importance of rows of a matrix. We denote the leverage scores of a matrix A ∈ Rn×d by (cid:126)σ ∈ Rn and say the leverage score of row i ∈ [n] is σi >0, and D def= diag( (cid:126)d) we use the shorthand (cid:126)σA( (cid:126)d) to denote the leverage scores of the matrix D1/2A. We frequently use well known facts regarding leverage scores, such as σi ∈ [0, 1] and (cid:13)(cid:13)(cid:126)σ(cid:13)(cid:13)1 ≤ d. (See def= [A(cid:0)AT A(cid:1)−1 AT ]ii. For A ∈ Rn×d, (cid:126)d ∈ Rn [99, 80, 78, 19] for a more in-depth discussion of leverage scores, their properties, and their many applications.) In addition, we make use of the fact that given an efficient linear system solver of AT A we can efficiently compute multiplicative approximations to leverage scores (See Definition 4 and Lemma 5 below). Definition 4 (Linear System Solver). An algorithm S is a LO-time solver of a PD matrix M ∈ Rn×n if for all (cid:126)b ∈ Rn and  ∈ (0, 1/2], the algorithm outputs a vector S((cid:126)b, ) ∈ Rn in time O(LO·log(−1)) such that with high probability in n,(cid:13)(cid:13)S((cid:126)b, ) − M−1(cid:126)b(cid:13)(cid:13)2 and let  > 0. If we have a LO-time solver for AT A then in time (cid:101)O((nnz(A) + LO)−2 log(−1)) Lemma 5 (Computing Leverage Scores [99]). Let A ∈ Rn×d, let (cid:126)σ denote the leverage scores of A, we can compute (cid:126)τ ∈ Rn such that with high probability in d, (1− )σi ≤ τi ≤ (1 + )σi for all i ∈ [n]. M ≤ (cid:13)(cid:13)M−1(cid:126)b(cid:13)(cid:13)2 M. 14 5.2 Hybrid Barrier Function As explained in Section 4.3 our cutting plane method maintains a polytope P = {(cid:126)x ∈ Rn : A(cid:126)x ≥ (cid:126)b} for A ∈ Rm×n and (cid:126)b ∈ Rn that contains some target set K. We then maintain a minimizer of the following hybrid barrier function: (ce + ei) log si((cid:126)x) + 1 2 log det(cid:0)AT S−2 x A + λI(cid:1) + (cid:13)(cid:13)x(cid:13)(cid:13)2 2 λ 2 p(cid:126)e((cid:126)x) def= − (cid:88) i∈[m] where (cid:126)e ∈ Rm is a variable we maintain, ce ≥ 0 and λ ≥ 0 are constants we fix later, (cid:126)s((cid:126)x) def= A(cid:126)x−(cid:126)b, def= and Sx = diag((cid:126)s((cid:126)x)). When the meaning is clear from context we often use the shorthand Ax S−1 x A. Rather than maintaining (cid:126)e explicitly, we instead maintain a vector (cid:126)τ ∈ Rm that approximates the leverage score (cid:126)ψ((cid:126)x) def= diag (cid:17) AT x . (cid:16) Ax (cid:0)AT x Ax + λI(cid:1)−1 (cid:21) (cid:20) Ax√ Note that (cid:126)ψ((cid:126)x) is simply the leverage scores of certain rows of the matrix and therefore the usual properties of leverage scores hold, i.e. ψi((cid:126)x) ∈ (0, 1) and (cid:13)(cid:13)ψi((cid:126)x)(cid:13)(cid:13)1 ≤ n. We write (cid:126)ψ((cid:126)x) equivalently as (cid:126)ψAx or (cid:126)ψP when we want the matrix to be clear. Furthermore, def= diag( (cid:126)ψ((cid:126)x)) and µ((cid:126)x) def= mini ψi((cid:126)x). Finally, we typically pick (cid:126)e using the function we let Ψx (cid:126)eP ((cid:126)τ , (cid:126)x) def= (cid:126)τ − (cid:126)ψ((cid:126)x). Again, we use the subscripts of Ax and P interchangeably and often drop them when the meaning is clear from context. λI . We remark that the last term λ 2 2 ensures that our point is always within a certain region (Lemma 23) and hence the term (ce + ei) log si((cid:126)x)i never gets too large. However, this (cid:96)2 term changes the Hessian of the potential function and hence we need to put a λI term inside both the log det and the leverage score to reflect this. This is the reason why we use (cid:126)ψ instead of the standard leverage score. (cid:13)(cid:13)x(cid:13)(cid:13)2 6 Our Cutting Plane Method In this section we develop and prove the correctness of our cutting plane method. We use the notation introduced in Section 3 and Section 5 as well as the technical tools we introduce in Section 7. We break the presentation and proof of correctness of our cutting plane methods into multiple parts. First in Section 6.1 we describe how we maintain a center of the hybrid barrier function p(cid:126)e and analyze this procedure. Then, in Section 6.2 we carefully analyze the effect of changing constraints on the hybrid barrier function and in Section 6.3 we prove properties of an approximate center of hybrid barrier function, which we call a hybrid center. In Section 6.4 we then provide our cutting plane method and in Section 6.5 we prove that the cutting plane method solves the feasibility problem as desired. 6.1 Centering In this section we show how to compute approximate centers or minimizers of the hybrid barrier function for the current polytope P = {(cid:126)x : A(cid:126)x ≥ (cid:126)b}. We split this proof up into multiple parts. First we simply bound the gradient and Hessian of the hybrid barrier function, p(cid:126)e, as follows. 15 Lemma 6. For f ((cid:126)x) def= 1 2 log det(cid:0)AT S−2 x A + λI(cid:1), we have that ∇f ((cid:126)x) = −AT x (cid:126)ψ((cid:126)x) and AT x Ψ((cid:126)x)Ax (cid:22) ∇2f ((cid:126)x) (cid:22) 3AT x Ψ((cid:126)x)Ax . Proof. Our proof is similar to [4, Appendix] which proved the statement when λ = 0. This case does not change the derivation significantly, however for completeness we include the proof below. We take derivatives on (cid:126)s first and then apply chain rule. Let f ((cid:126)s) = 1 2 log det(cid:0)AT S−2A + λI(cid:1). We use the notation Df ((cid:126)x)[(cid:126)h] to denote the directional derivative of f along the direction (cid:126)h d at the point (cid:126)x. Using the standard formula for the derivative of log det, i.e. dt log det Bt = Tr((Bt)−1( dBt dt )), we have Applying chain rules, we have ∇f ((cid:126)x) = −AT Taking the derivative of (6.1) again and using the cyclic property of trace, we have x D2f ((cid:126)s)[(cid:126)h1, (cid:126)h2] = Tr −Tr Df ((cid:126)s)[(cid:126)h] = i i . 1 2 (cid:126)1T (6.1) hi si ψihi si Tr((AT S−2A + λI)−1(AT (−2)S−3HA)) AS−1(cid:126)1i = −(cid:88) i S−1A(cid:0)AT S−2A + λI(cid:1)−1 = −(cid:88) (cid:126)ψ. Now let P def= S−1A(cid:0)AT S−2A + λI(cid:1)−1 AT S−1. (cid:16)(cid:0)AT S−2A + λI(cid:1)−1(cid:0)AT (−2)S−3H2A(cid:1)(cid:0)AT S−2A + λI(cid:1)−1(cid:0)AT S−3H1A(cid:1)(cid:17) (cid:16)(cid:0)AT S−2A + λI(cid:1)−1(cid:0)AT (−3)S−4H2H1A(cid:1)(cid:17) (cid:1) (cid:88) (cid:88) (cid:1) − 2Tr(cid:0)PS−1H2PS−1H1 (cid:88) (cid:88) (cid:126)h1(i)(cid:126)h2(i) (cid:126)h1(i)(cid:126)h2(i) (cid:126)h2(j) (cid:126)h2(j) (cid:126)h2(i) (cid:126)h2(i) − 2 Pji Pij Pii s2 i sj si ij = 3Tr(cid:0)PS−2H2H1 = 3 i − 2 P 2 ij i ψi s2 i = 3 Consequently, D2f ((cid:126)x)[(cid:126)1i, (cid:126)1j] = [S−1(cid:0)3Ψ − 2P(2)(cid:1) S−1]ij where P(2) is the Schur product of P with Now note that(cid:88) AT S−2A(cid:0)AT S−2A + λI(cid:1)−1 AT S−1(cid:126)1j itself. P 2 sj si ij . ij = (cid:126)1jS−1A(cid:0)AT S−2A + λI(cid:1)−1 ≤ (cid:126)1jS−1A(cid:0)AT S−2A + λI(cid:1)−1 i AT S−1(cid:126)1j = Pjj = Ψjj . Hence, the Gershgorin circle theorem shows that the eigenvalues of Ψ − P(2) are lies in union of the interval [0, 2ψj] over all j. Hence, Ψ − P(2) (cid:23) 0. On the other hand, Schur product theorem shows that P(2) (cid:23) 0 as P (cid:23) 0. Hence, the result follows by chain rule. Lemma 6 immediately shows that under our choice of (cid:126)e = (cid:126)eP ((cid:126)x, (cid:126)τ ) we can compute the gra- dient of the hybrid barrier function, p(cid:126)e((cid:126)x) efficiently. Formally, Lemma 6 immediately implies the following: Lemma 7 (Gradient). For (cid:126)x ∈ P = {(cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b} and (cid:126)e ∈ Rm we have and therefore for all (cid:126)τ ∈ Rm, we have ∇p(cid:126)e((cid:126)x) = −AT x (ce(cid:126)1 + (cid:126)e + (cid:126)ψP ((cid:126)x)) + λ(cid:126)x (cid:16) (cid:17) ce(cid:126)1 + (cid:126)τ + λ(cid:126)x. ∇p(cid:126)e((cid:126)τ ,(cid:126)x)((cid:126)x) = −AT x 16 Remark 8. To be clear, the vector ∇p(cid:126)e((cid:126)τ ,(cid:126)x)((cid:126)x) is defined as the vector such that (cid:16) (cid:17) [∇p(cid:126)e((cid:126)τ ,(cid:126)x)((cid:126)x)]i = lim t→0 1 t p(cid:126)e((cid:126)τ ,(cid:126)x)((cid:126)x + t(cid:126)1i) − p(cid:126)e((cid:126)τ ,(cid:126)x)((cid:126)x) . In other words, we treat the parameter (cid:126)e((cid:126)τ , (cid:126)x) as fixed. This is the reason we denote it by subscript to emphasize that p(cid:126)e((cid:126)x) is a family of functions, p(cid:126)e((cid:126)τ ,(cid:126)x) is one particular function, and ∇p(cid:126)e((cid:126)τ ,(cid:126)x) means taking gradient on that particular function. Consequently, we can always compute ∇p(cid:126)e((cid:126)τ ,(cid:126)x)((cid:126)x) efficiently. Now, we measure centrality or how close we are to the hybrid center as follows. Definition 9 (Centrality). For (cid:126)x ∈ P = of (cid:126)x by (cid:111) (cid:110) δ(cid:126)e((cid:126)x) def=(cid:13)(cid:13)∇p(cid:126)e((cid:126)x)(cid:13)(cid:13)H((cid:126)x) (cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b −1 and (cid:126)e ∈ Rm, we define the centrality where H((cid:126)x) def= AT Hessian and consider Q((cid:126)x, (cid:126)w) def= AT x (ceI + Ψ((cid:126)x)) Ax + λI. Often, we use weights (cid:126)w ∈ Rm >0 to approximate this Next, we bound how much slacks can change in a region close to a nearly central point. (cid:110) x (ceI + W) Ax + λI. (cid:111) and (cid:126)y ∈ Rn such that (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) ≤ (cid:112)ce + µ((cid:126)x) Lemma 10. Let (cid:126)x ∈ P = for  < 1. Then (cid:126)y ∈ P and (1 − )Sx (cid:22) Sy (cid:22) (1 + )Sx . Proof. Direct calculation reveals the following: (cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b x ((cid:126)s(cid:126)y − (cid:126)sx)(cid:13)(cid:13)∞ ≤(cid:13)(cid:13)Ax((cid:126)y − (cid:126)x)(cid:13)(cid:13)2 ≤ (cid:13)(cid:13)S−1 1(cid:112)ce + µ((cid:126)x) 1(cid:112)ce + µ((cid:126)x) (cid:13)(cid:13)(cid:126)y − (cid:126)x(cid:13)(cid:13)H((cid:126)x) ≤  ≤ (cid:13)(cid:13)Ax((cid:126)y − (cid:126)x)(cid:13)(cid:13)ceI+Ψ((cid:126)x) . Consequently, (1 − )Sx (cid:22) Sy (cid:22) (1 + )Sx. Since y ∈ P if and only if Sy (cid:23) 0 the result follows. Combining the previous lemmas we obtain the following. Lemma 11. Let (cid:126)x ∈ P = {(cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b} and (cid:126)e, (cid:126)w ∈ Rm such that (cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ ≤ 1 3 Ψ((cid:126)x). If (cid:126)y ∈ Rn satisfies(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)Q((cid:126)x, (cid:126)w) ≤ 1 (cid:112)ce + µ((cid:126)x), then Ψ((cid:126)x) (cid:22) W (cid:22) 4 10 2 ce ≤ 1 and Q((cid:126)x, (cid:126)w) (cid:22) ∇2p(cid:126)e((cid:126)y) (cid:22) 8Q((cid:126)x, (cid:126)w) and 1 4 H((cid:126)x) (cid:22) H((cid:126)y) (cid:22) 2H((cid:126)x) . 1 2 Proof. Lemma 6 shows that y (ceI + E + Ψ((cid:126)y)) Ay + λI (cid:22) ∇2p(cid:126)e((cid:126)y) (cid:22) AT AT Since W (cid:23) Ψ, we have that Q((cid:126)x, (cid:126)w) (cid:23) H((cid:126)x) and therefore(cid:13)(cid:13)(cid:126)x−(cid:126)y(cid:13)(cid:13)H((cid:126)x) ≤ (cid:112)ce + µ((cid:126)x) with  = 0.1. y (ceI + E + 3Ψ((cid:126)y)) Ay + λI Consequently, by Lemma 10 we have (1 − )Sx (cid:22) Sy (cid:22) (1 + )Sx and therefore (6.2) . (1 − )2 (1 + )2 Ψ((cid:126)x) (cid:22) Ψ((cid:126)y) (cid:22) (1 + )2 (1 − )2 Ψ((cid:126)x) and 1 2 H((cid:126)x) (cid:22) (1 − )2 (1 + )4 H((cid:126)x) (cid:22) H((cid:126)y) (cid:22) (1 + )2 (1 − )4 H((cid:126)x) (cid:22) 2H((cid:126)x) 17 Furthermore, (6.2) shows that ∇2p(cid:126)e((cid:126)y) (cid:22) AT x (ceI + E + 3Ψ((cid:126)x)) Ax + λI (cid:22) (1 + )2 (cid:18) 3 y (ceI + E + 3Ψ((cid:126)y)) Ay + λI (1 − )4 AT (1 − )4 AT (1 + )2 (1 − )4 Q((cid:126)x, (cid:126)w) (cid:22) 8Q((cid:126)x, (cid:126)w) ceI + 3W (cid:19) 2 x (cid:22) (1 + )2 (cid:22) 3 Ax + λI and ∇2p(cid:126)e((cid:126)y) (cid:23) AT x (ceI + E + Ψ((cid:126)x)) Ax + λI (cid:18) 1 y (ceI + E + Ψ((cid:126)y)) Ay + λI (cid:23) (1 − )4 (1 + )2 AT (cid:23) (1 − )4 (1 + )2 AT (1 − )4 (cid:23) 1 (1 + )2 Q((cid:126)x, (cid:126)w) (cid:23) 1 2 (cid:19) ceI + W 3 4 4 2 x Q((cid:126)x, (cid:126)w). Ax + λI To analyze our centering scheme we use standard facts about gradient descent we prove in Lemma 12. Lemma 12 (Gradient Descent). Let f : Rn → R be twice differentiable and Q ∈ Rn×n be positive L Q−1∇f ((cid:126)x0). Furthermore, let (cid:126)xα = (cid:126)x0 + α((cid:126)x1 − (cid:126)x) and definite. Let (cid:126)x0 ∈ Rn and (cid:126)x1 suppose that µQ (cid:22) ∇2f ((cid:126)xα) (cid:22) LQ for all α ∈ [0, 1]. Then, def= (cid:126)x0 − 1 1. (cid:13)(cid:13)∇f ((cid:126)x1)(cid:13)(cid:13)Q−1 ≤(cid:0)1 − µ 2. f ((cid:126)x1) ≥ f ((cid:126)x0) − 1 L L (cid:1)(cid:13)(cid:13)∇f ((cid:126)x0)(cid:13)(cid:13)Q−1 (cid:13)(cid:13)∇f ((cid:126)x0)(cid:13)(cid:13)2 Q−1 Proof. Integrating we have that ∇f ((cid:126)x1) = ∇f ((cid:126)x0) + 1 0 Consequently, by applying Jensen’s inequality we have (cid:13)(cid:13)∇f ((cid:126)x1)(cid:13)(cid:13)Q−1 = Now we know that by assumption that ∇2f ((cid:126)xα) Q−1∇f ((cid:126)x0)dα Q − 1 L ∇2f ((cid:126)xα)((cid:126)x1 − (cid:126)x0)dα = 1 0 1 (cid:18) (cid:13)(cid:13)(cid:13)(cid:13) (cid:18) (cid:19) (cid:13)(cid:13)(cid:13)(cid:13)(cid:18) (cid:19) ≤(cid:13)(cid:13)Q−1/2∇f ((cid:126)x0)(cid:13)(cid:13)[Q−1/2(Q− 1 (cid:18) Q−1/2 (cid:22)(cid:16) Q − 1 L Q − 1 L ∇2f ((cid:126)xα) ∇2f ((cid:126)xα) ∇2f ((cid:126)xα) (cid:19) ≤ 0 1 0 Q − 1 L 18 (cid:19) (cid:13)(cid:13)(cid:13)(cid:13)Q−1 (cid:13)(cid:13)(cid:13)(cid:13)Q−1 (cid:17) I dα Q−1∇f ((cid:126)x0)dα Q−1∇f ((cid:126)x0) L∇2f ((cid:126)xα))Q−1/2]2 0 (cid:22) Q−1/2 1 − µ L and therefore combining these (1) holds. Using the convexity of f , we have and since(cid:13)(cid:13)(cid:126)x1 − (cid:126)x0 (cid:13)(cid:13)Q = 1 L f ((cid:126)x1) ≥ f ((cid:126)x0) + (cid:104)∇f ((cid:126)x0), (cid:126)x1 − (cid:126)x0(cid:105) ≥ f ((cid:126)x0) −(cid:13)(cid:13)∇f ((cid:126)x0)(cid:13)(cid:13)Q−1 (cid:13)(cid:13)∇f ((cid:126)x0)(cid:13)(cid:13)Q−1, (2) holds as well. (cid:13)(cid:13)(cid:126)x1 − (cid:126)x0 (cid:13)(cid:13)Q Next we bound the effect of changing (cid:126)e on the hybrid barrier function p(cid:126)e((cid:126)x). Lemma 13. For (cid:126)x ∈ P = {(cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b}, (cid:126)e, (cid:126)f ∈ Rm, and (cid:126)w ∈ Rm >0 such that W (cid:23) Ψx Proof. Direct calculation shows the following (cid:13)(cid:13)∇p (cid:126)f ((cid:126)x)(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 =(cid:13)(cid:13) − AT 1(cid:112)ce + µ((cid:126)x) (cid:13)(cid:13)∇p (cid:126)f ((cid:126)x)(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 ≤(cid:13)(cid:13)∇p(cid:126)e((cid:126)x)(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 + x (ce(cid:126)1 + (cid:126)f + (cid:126)ψP ((cid:126)x)) + λ(cid:126)x(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 x ( (cid:126)f − (cid:126)e)(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 x ( (cid:126)f − (cid:126)e)(cid:13)(cid:13)(AT (cid:13)(cid:13)AT 1(cid:112)ce + µ((cid:126)x) (cid:13)(cid:13) (cid:126)f − (cid:126)e(cid:13)(cid:13)2 1(cid:112)ce + µ((cid:126)x) ≤(cid:13)(cid:13)∇p(cid:126)e((cid:126)x)(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 +(cid:13)(cid:13)AT ≤(cid:13)(cid:13)∇p(cid:126)e((cid:126)x)(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 + ≤(cid:13)(cid:13)∇p(cid:126)e((cid:126)x)(cid:13)(cid:13)Q((cid:126)x, (cid:126)w)−1 + where in the second to third line we used Q((cid:126)x, (cid:126)w) (cid:23) H((cid:126)x) (cid:23) (ce + µ((cid:126)x))AT x Ax. We now have everything we need to analyze our centering algorithm. (cid:13)(cid:13) (cid:126)f − (cid:126)e(cid:13)(cid:13)2 (Formula for ∇p (cid:126)f ((cid:126)x)) (Triangle inequality) (Bound on Q((cid:126)x, (cid:126)w)) −1 x Ax) (Property of projection matrix) Algorithm 1: ((cid:126)x(r), (cid:126)τ (r)) = Centering((cid:126)x(0), (cid:126)τ (0), r, c∆) Input: Initial point (cid:126)x(0) ∈ P = {(cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b}, Estimator of leverage scores (cid:126)τ (0) ∈ Rn Input: Number of iterations r > 0, Accuracy of the estimator 0 ≤ c∆ ≤ 0.01ce. Given: (cid:13)(cid:13)(cid:126)e(0)(cid:13)(cid:13)∞ ≤ 1 Given: δ(cid:126)e(0)((cid:126)x(0)) =(cid:13)(cid:13)∇p(cid:126)e(0)((cid:126)x(0))(cid:13)(cid:13)H((cid:126)x(0))−1 ≤ 1 (cid:112)ce + µ((cid:126)x(0)). 3 where (cid:126)e(0) = (cid:126)e((cid:126)τ (0), (cid:126)x(0)). 3 ce ≤ 1 100 3 Ψ((cid:126)x(0)) (See Lemma 5) Compute (cid:126)w such that Ψ((cid:126)x(0)) (cid:22) W (cid:22) 4 Let Q def= Q((cid:126)x(0), (cid:126)w). for k = 1 to r do (cid:126)x(k) := (cid:126)x(k−1) − 1 Sample (cid:126)∆(k) ∈ Rn s.t. 8 Q−1∇p(cid:126)e(k−1)((cid:126)x(k−1)). E[(cid:126)∆(k)] = (cid:126)ψ((cid:126)x(k)) − (cid:126)ψ((cid:126)x(k−1)) and with high probability in n, (cid:13)(cid:13)(cid:126)∆(k) − ( (cid:126)ψ((cid:126)x(k)) − (cid:126)ψ((cid:126)x(k−1)))(cid:13)(cid:13)2 ≤ c∆ (cid:126)τ (k) := (cid:126)τ (k−1) + (cid:126)∆(k). (cid:126)e(k) := (cid:126)e((cid:126)τ (k), (cid:126)x(k)). end Output: ((cid:126)x(r), (cid:126)τ (r)) 19 (cid:126)x(k−1)((cid:126)s(cid:126)x(k) − (cid:126)s(cid:126)x(k−1))(cid:13)(cid:13)2 (See Section 7.1) (cid:13)(cid:13)S−1 . 1 64 4. 100 10 c∆. (cid:126)x(0)((cid:126)s((cid:126)x(r)) − (cid:126)s((cid:126)x(0))) 3 . Assume that r is a positive integer, 0 ≤ c∆ ≤ 0.01ce and δ(cid:126)e(0)((cid:126)x(0)) ≤ 1 3 ce ≤ 1 With high probability in n, the algorithm Centering((cid:126)x(0), (cid:126)τ (0), r, c∆) outputs ((cid:126)x(r), (cid:126)τ (r)) such that Lemma 14. Let (cid:126)x(0) ∈ P = {(cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b} and let (cid:126)τ (0) ∈ Rm such that (cid:13)(cid:13)(cid:126)e((cid:126)τ (0), (cid:126)x(0))(cid:13)(cid:13)∞ ≤ (cid:112)ce + µ((cid:126)x(0)). 1. δ(cid:126)e(r)((cid:126)x(r)) ≤ 2(cid:0)1 − 1 (cid:1)r δ(cid:126)e(0)((cid:126)x(0)). 2. E[p(cid:126)e(k)((cid:126)x(r))] ≥ p(cid:126)e(0)((cid:126)x(0)) − 8(cid:0)δ(cid:126)e(0)((cid:126)x(0))(cid:1)2 3. E(cid:126)e(r) = (cid:126)e(0) and(cid:13)(cid:13)(cid:126)e(r) − (cid:126)e(0)(cid:13)(cid:13)2 ≤ 1 (cid:13)(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:13)S−1 Proof. Let η = (cid:13)(cid:13)∇p(cid:126)e(0)((cid:126)x(0))(cid:13)(cid:13)Q−1. First, we use induction to prove that (cid:13)(cid:13)(cid:126)x(r) − (cid:126)x(0)(cid:13)(cid:13)Q ≤ 8η, (cid:13)(cid:13)∇p(cid:126)e(r)((cid:126)x(r))(cid:13)(cid:13)Q−1 ≤(cid:0)1 − 1 (cid:1)r η and(cid:13)(cid:13)(cid:126)e(r) − (cid:126)e(0)(cid:13)(cid:13)2 ≤ 1 they hold for r = t + 1. Now, since (cid:13)(cid:13)(cid:126)x(t) − (cid:126)x(0)(cid:13)(cid:13)Q ≤ 8η, (cid:126)x(t+1) = (cid:126)x(t) − 1 (cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 ≤(cid:0)1 − 1 (cid:1)t η ≤ η, we have (cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 ≤ 9η. We will improve this estimate later in the proof to finish the induction on (cid:13)(cid:13)(cid:126)x(t+1) − (cid:126)x(0)(cid:13)(cid:13)Q, but using this, η ≤ 0.01(cid:112)ce + µ((cid:126)x(0)), and (cid:13)(cid:13)(cid:126)e(t)(cid:13)(cid:13)∞ ≤ (cid:13)(cid:13)(cid:126)e(t) − (cid:126)e(0)(cid:13)(cid:13)∞ +(cid:13)(cid:13)(cid:126)e(0)(cid:13)(cid:13)∞ ≤ ce Clearly the claims hold for r = 0. We now suppose they hold for all r ≤ t and show that 8 Q−1∇p(cid:126)e(t)((cid:126)x(t)), and (cid:13)(cid:13)(cid:126)x(t+1) − (cid:126)x(0)(cid:13)(cid:13)Q ≤(cid:13)(cid:13)(cid:126)x(t) − (cid:126)x(0)(cid:13)(cid:13)Q + where (cid:126)e(r) = (cid:126)e((cid:126)τ (r), (cid:126)x(r)). 2 , we can invoke 10 c∆ for all r. ≤ 1 10 . 1 8 64 64 Lemma 11 and Lemma 12 and therefore (cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t+1))(cid:13)(cid:13)Q−1 ≤ (cid:18) 1 − 1 32 (cid:18) By Lemma 13 we have (cid:13)(cid:13)∇p(cid:126)e(t+1)((cid:126)x(t+1))(cid:13)(cid:13)Q−1 ≤ To bound(cid:13)(cid:13)(cid:126)e(t+1)−(cid:126)e(t)(cid:13)(cid:13)2, we note that Lemma 10 and the induction hypothesis(cid:13)(cid:13)(cid:126)x(t)−(cid:126)x(0)(cid:13)(cid:13)H((cid:126)x(0)) ≤ (cid:13)(cid:13)(cid:126)x(t) − (cid:126)x(0)(cid:13)(cid:13)Q ≤ 8η shows that (1 − 0.1)Sx(0) (cid:22) Sx(t) (cid:22) (1 + 0.1)Sx(0) and therefore (cid:13)(cid:13)(cid:126)e(t+1) − (cid:126)e(t)(cid:13)(cid:13)2. (cid:19)(cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 + 1 − 1 32 (6.3) (cid:13)(cid:13)S−1 x(t)((cid:126)sx(t) − (cid:126)sx(t+1))(cid:13)(cid:13)2 ≤ (cid:13)(cid:13)S−1 (cid:13)(cid:13)(cid:13)(cid:13) 1 8 1 1 − 0.1 1 − 0.1 1 = (cid:19)(cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 . 1(cid:112)ce + µ((cid:126)x(0)) (cid:16) (cid:126)x(t) − (cid:126)x(t+1)(cid:17)(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:13)(cid:13)AT S−2 (cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 x(0) A x(0)A Q−1∇p(cid:126)e(t)((cid:126)x(t)) 1 ≤ 8 (1 − 0.1)(cid:112)ce + µ((cid:126)x(0)) (cid:17) −(cid:16) (cid:16) = (cid:126)∆(t+1) −(cid:16) (cid:126)ψ((cid:126)x(t+1)) − (cid:126)ψ((cid:126)x(t)) (cid:126)τ (t+1) − (cid:126)ψ((cid:126)x(t+1)) (cid:17) (cid:17) (cid:126)τ (t) − (cid:126)ψ((cid:126)x(t)) 20 Now since (cid:126)e(t+1) − (cid:126)e(t) = (6.4) where in the last line we used mini∈[m] wi ≥ µ((cid:126)x(0)). Since c∆ < 0.01ce, by (6.3), we have (cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 η = 8η . Consequently, with high probability in n, (cid:13)(cid:13)∇p(cid:126)e(t+1)((cid:126)x(t+1))(cid:13)(cid:13)Q−1 ≤ . c∆ ≤ c∆ ≤ x(t)((cid:126)sx(t+1) − (cid:126)sx(t)) (cid:13)(cid:13)(cid:126)e(t+1) − (cid:126)e(t)(cid:13)(cid:13)2 = (cid:13)(cid:13)(cid:13)(cid:126)∆(t+1) −(cid:16) (cid:126)ψ((cid:126)x(t+1)) − (cid:126)ψ((cid:126)x(t)) (cid:17)(cid:13)(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:13)S−1 (cid:13)(cid:13)(cid:13)2 (cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 8 (1 − 0.1)(cid:112)ce + µ((cid:126)x(0)) (cid:19)(cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 + (cid:18) (cid:19)(cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1 (cid:18) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)Q−1 (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) t(cid:88) (cid:13)(cid:13)(cid:126)x(t+1) − (cid:126)x(0)(cid:13)(cid:13)Q ≤ (cid:18) (cid:13)(cid:13)(cid:126)e(t+1) − (cid:126)e(0)(cid:13)(cid:13)2 ≤ t(cid:88) 8 (1 − 0.1)(cid:112)ce + µ((cid:126)x(0)) (1 − 0.1)(cid:112)ce + µ((cid:126)x(0)) (1 − 0.1)(cid:112)ce + µ((cid:126)x(0)) (cid:18) ∞(cid:88) (cid:19)k(cid:13)(cid:13)∇p(cid:126)e(0)((cid:126)x(0))(cid:13)(cid:13)Q−1 8 (1 − 0.1) (ce + µ((cid:126)x(0))) 1 − 1 32 1 − 1 64 Q−1∇p(cid:126)e(k)((cid:126)x(k)) η ≤ 64 8 1 − 1 64 1 − 1 64 (cid:19)k ≤ 1 8 0.01ce 8c∆η 8c∆ ≤ ≤ 1 8 k=0 ≤ c∆ k=0 i=0 . Furthermore, this implies that Similarly, we have that δ(cid:126)e(0)((cid:126)x(0)) ≤ 1 10 where we used η =(cid:13)(cid:13)∇p(cid:126)e(0)((cid:126)x(0))(cid:13)(cid:13)Q−1 ≤(cid:13)(cid:13)∇p(cid:126)e(0)((cid:126)x(0))(cid:13)(cid:13)H−1 = δ(cid:126)e(0)((cid:126)x(0)) and this finishes the induc- tion on(cid:13)(cid:13)∇p(cid:126)e(t)((cid:126)x(t))(cid:13)(cid:13)Q−1,(cid:13)(cid:13)(cid:126)x(t) − (cid:126)x(0)(cid:13)(cid:13)Q and(cid:13)(cid:13)(cid:126)e(t) − (cid:126)e(0)(cid:13)(cid:13)2. 2(cid:13)(cid:13)∇p(cid:126)e(r)((cid:126)x(r))(cid:13)(cid:13)H((cid:126)x(0))−1 (cid:114) 8 (cid:18) δ(cid:126)e(r)((cid:126)x(r)) = (cid:13)(cid:13)∇p(cid:126)e(r)((cid:126)x(r))(cid:13)(cid:13)H((cid:126)x(r))−1 ≤ (cid:13)(cid:13)∇p(cid:126)e(r)((cid:126)x(r))(cid:13)(cid:13)Q−1 ≤ (cid:19)r(cid:13)(cid:13)∇p(cid:126)e(0)((cid:126)x(0))(cid:13)(cid:13)Q−1 Hence, for all r, Lemma 11 shows that √ ≤ c∆ 1 − 1 64 3 (cid:114) 8 (cid:18) (cid:19)r ≤ 2 3 1 − 1 64 δ(cid:126)e(0)((cid:126)x(0)). Using that E(cid:126)e(t+1) = (cid:126)e(t), we see that the expected change in function value is only due to the change while taking centering steps and therefore Lemma 12 shows that E[p(cid:126)e(r)((cid:126)x(r))] ≥ p(cid:126)e(0)((cid:126)x(0)) − 1 8 Finally, for (4), we note that (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) s((cid:126)x(r)) − s((cid:126)x(0)) s((cid:126)x(0)) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 = k=0 1 − 1 64 (cid:18) ∞(cid:88) (cid:13)(cid:13)(cid:13)(cid:126)x(r) − (cid:126)x(0)(cid:13)(cid:13)(cid:13)AT S−2 (cid:19)2k(cid:13)(cid:13)∇p(cid:126)e(0)((cid:126)x(0))(cid:13)(cid:13)2 1(cid:112)µ((cid:126)x(0)) + ce ≤ x(0) A (cid:16) (cid:13)(cid:13)(cid:13)(cid:126)x(r) − (cid:126)x(0)(cid:13)(cid:13)(cid:13)Q−1 ≤ 1 10 . Q−1 ≥ p(cid:126)e(0)((cid:126)x(0)) − 8 δ(cid:126)e(0)((cid:126)x(0)) . (cid:17)2 21 6.2 Changing Constraints Here we bound the effect that adding or a removing a constraint has on the hybrid barrier function. Much of the analysis in this section follows from the following lemma which follows easily from the Sherman Morrison Formula. Lemma 15 (Sherman Morrison Formula Implications). Let B ∈ Rn×n be an invertible symmetric matrix and let (cid:126)a ∈ Rn be arbitrary vector satisfying (cid:126)aT B−1(cid:126)a < 1. The following hold: 1. (cid:0)B ± (cid:126)a(cid:126)aT(cid:1)−1 = B−1 ∓ B−1(cid:126)a(cid:126)aT B−1 3. log det(cid:0)B ± (cid:126)a(cid:126)aT(cid:1) = ln det B + ln(cid:0)1 ± (cid:126)aT B−1(cid:126)a(cid:1) . 1±(cid:126)aT B−1(cid:126)a . 1±(cid:126)aT B−1(cid:126)a B−1. 1±(cid:126)aT B−1(cid:126)a (cid:22) (cid:126)aT B−1(cid:126)a 2. 0 (cid:22) B−1(cid:126)a(cid:126)aT B−1 Proof. (1) follows immediately from Sherman Morrison [95]. (2) follows since (cid:126)a(cid:126)aT is PSD, (cid:34) (cid:35) B−1(cid:126)a(cid:126)aT B−1 1 ± (cid:126)aT B−1(cid:126)a = B−1/2 B−1/2(cid:126)a(cid:126)aT B−1/2 1 ± (cid:126)aT B−1(cid:126)a B−1/2 , 2I for any vector (cid:126)y. (3) follows immediately from the Matrix Determinant Lemma. and (cid:126)y(cid:126)yT (cid:22)(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 Proof. We have by Cauchy Schwarz that We also make use of the following technical helper lemma. Lemma 16. For A ∈ Rn×m and all (cid:126)a ∈ Rn we have (cid:17)2 (cid:126)a (cid:126)a (cid:126)a (cid:126)a i (cid:16) 1 i∈[m] ψA[i] (cid:17)4 A(cid:0)AT A + λI(cid:1)−1 ≤(cid:16) (cid:88) (cid:126)aT(cid:0)AT A + λI(cid:1)−1 (cid:16)(cid:126)1T (cid:17)2 ≤ ψA[i] · (cid:126)aT(cid:0)AT A + λI(cid:1)−1 i A(cid:0)AT A + λI(cid:1)−1 (cid:16)(cid:126)1T (cid:17)4 i A(cid:0)AT A + λI(cid:1)−1 (cid:126)a ≤(cid:16) (cid:126)aT(cid:0)AT A + λI(cid:1)−1 (cid:17)2 (cid:16)(cid:126)1T = (cid:126)aT(cid:0)AT A + λI(cid:1)−1 i A(cid:0)AT A + λI(cid:1)−1 ≤ (cid:126)aT(cid:0)AT A + λI(cid:1)−1 (cid:17) (cid:88) (cid:88) ψA[i] i∈[m] (cid:126)a i∈[m] (cid:126)a, (cid:126)a (cid:17)2 (cid:126)a . (cid:16)(cid:126)1iA(cid:0)AT A + λI(cid:1)−1 AT A(cid:0)AT A + λI(cid:1)−1 (cid:126)a and consequently (cid:88) i∈[m] Since we have the desired result. We now bound the effect of adding a constraint. 22 (cid:110) (cid:111) Lemma 17. Let A ∈ Rm×n, (cid:126)b ∈ Rm, (cid:126)τ ∈ Rm, and (cid:126)x ∈ P def= . Let A ∈ R(m+1)×n be A with a row (cid:126)am+1 added, let b ∈ Rm+1 be the vector (cid:126)b with an entry bm+1 added, and let (cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b P def=(cid:8)(cid:126)y ∈ Rn : A(cid:126)y ≥ b(cid:9). Let sm+1 = (cid:126)aT x Ax+λI)−1(cid:126)am+1 . Now, let (cid:126)υ ∈ Rm+1 be defined so that υm+1 = ψa m+1(AT (cid:126)aT and for all i ∈ [m] m+1(cid:126)x − bm+1 > 0, ψa = (cid:20) (cid:0)AT x Ax + λI(cid:1)−1 (cid:126)am+1 (cid:21)2 1+ψa Ax sm+1 . i s2 m+1 υi = τi − 1 1 + ψa Then, the following hold • [Leverage Score Estimation] eP ((cid:126)υ, (cid:126)x)m+1 = 0 and eP ((cid:126)υ, (cid:126)x)i = eP ((cid:126)τ , (cid:126)x)i for all i ∈ [m]. • [Function Value Increase] p(cid:126)eP ((cid:126)υ,(cid:126)x)((cid:126)x) = p(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) − ce ln s((cid:126)x)m+1 + ln(1 + ψa). • [Centrality Increase] δ(cid:126)eP ((cid:126)υ,(cid:126)x)((cid:126)x) ≤ δ(cid:126)eP ((cid:126)υ,(cid:126)x)((cid:126)x) + (ce + ψa) (cid:113) ψa µ((cid:126)x) + ψa. Proof. By (1) in Lemma 15, we have that for all i ∈ [m] ψP ((cid:126)x)i = ψP ((cid:126)x)i − 1 1 + ψa Ax (cid:20) (cid:0)AT x Ax + λI(cid:1)−1 (cid:126)am+1 sm+1 (cid:21)2 i and that ψP ((cid:126)x)m+1 = ψa − ψ2 1 + ψa a = ψa 1 + ψa . Consequently [Leverage Score Estimation] holds. Furthermore, by (3) in Lemma 15 this then implies that [Function Value Change] holds. −1 (cid:22) H−1. i = (cid:126)υi for all i ∈ [m] then by triangle inequality we To bound the change in centrality note that by (2) in Lemma 15 we have that H Therefore if let (cid:126)υ(cid:48) ∈ Rm be defined so that (cid:126)υ(cid:48) have T T sm+1 (ce + υm+1) = δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + δ(cid:126)ep((cid:126)υ,(cid:126)x)((cid:126)x) =(cid:13)(cid:13)A x (ce(cid:126)1 + (cid:126)υ)(cid:13)(cid:13)H x (ce(cid:126)1 + (cid:126)υ)(cid:13)(cid:13)H−1 −1 ≤(cid:13)(cid:13)A (cid:13)(cid:13)(cid:13)(cid:13)(cid:126)am+1 (cid:13)(cid:13)(cid:13)(cid:13)H−1 ≤(cid:13)(cid:13)AT x (ce(cid:126)1 + (cid:126)τ )(cid:13)(cid:13)H−1 + x ((cid:126)υ(cid:48) − (cid:126)τ )(cid:13)(cid:13)H−1 +(cid:13)(cid:13)AT (cid:13)(cid:13)(cid:13)(cid:13)H−1 (cid:19)(cid:13)(cid:13)(cid:13)(cid:13)(cid:126)am+1 (cid:18) x ((cid:126)υ(cid:48) − (cid:126)τ )(cid:13)(cid:13)H−1 +(cid:13)(cid:13)AT (cid:0)AT x Ax + λI(cid:1)−1, we have that (cid:115) (cid:13)(cid:13)(cid:13)(cid:13)(cid:126)am+1 (cid:13)(cid:13)(cid:13)(cid:13)(AT (cid:13)(cid:13)(cid:13)(cid:13)(cid:126)am+1 (cid:13)(cid:13)(cid:13)(cid:13)H−1 (cid:1)−1 AT x Ψ1/2 is a projection matrix, we have Ψ−1 (cid:23) Ax 1(cid:112)µ((cid:126)x) (cid:0)AT (cid:0)AT ψa µ((cid:126)x) x ΨAx 1 + ψa x Ax+λI) = −1 sm+1 sm+1 sm+1 ce + ≤ ψa . (cid:1)−1 AT x (cid:23) x ΨAx Now, since H−1 (cid:22) 1 µ((cid:126)x) Since Ψ1/2Ax 23 AxH−1AT x . By Lemma 16, we have (cid:13)(cid:13)AT x (cid:0)(cid:126)τ(cid:48) − (cid:126)υ(cid:1)(cid:13)(cid:13)2 H−1 ≤(cid:13)(cid:13)(cid:126)τ(cid:48) − (cid:126)υ(cid:13)(cid:13)2 (cid:32) (cid:88) (cid:19)2(cid:32) (cid:18) 1 ψ((cid:126)x)i i∈[m] Ψ−1 = 1 ≤ (cid:19)2(cid:33)2 (cid:18) (cid:0)AT x Ax + λI(cid:1)−1 (cid:126)am+1 (cid:0)AT x Ax + λI(cid:1)−1 (cid:126)am+1 (cid:18) ψa (cid:33)2 (cid:126)1iAx sm+1 (cid:19)2 1 1 + ψa (cid:126)aT m+1 = 1 + ψa 1 + ψa s2 m+1 Combining, we have that δ(cid:126)eP ((cid:126)υ,(cid:126)x)((cid:126)x) ≤ δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + (cid:18) ce + (cid:19)(cid:115) ψa µ((cid:126)x) + ψa 1 + ψa 1 + ψa ψa (cid:115) ≤ δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + (ce + ψa) ψa µ((cid:126)x) + ψa. We now bound the effect of removing a constraint. Lemma 18 (Removing a Constraint). Let A ∈ Rm×n, (cid:126)b ∈ Rm, (cid:126)τ ∈ Rm, and (cid:126)x ∈ P def= {(cid:126)y ∈ Rn : A(cid:126)y ≥ (cid:126)b}. Let A ∈ R(m−1)×n be A with row m removed, let b ∈ Rm−1 denote the first m − 1 coordinates of (cid:126)b, and let P def= {(cid:126)y ∈ Rn : A(cid:126)y ≥ b}. Let ψd = ψP ((cid:126)x)m. Now, let (cid:126)υ ∈ Rm−1 be defined so that for all i ∈ [m − 1] (cid:16) (cid:0)AT x Ax + λI(cid:1)−1 10 and(cid:13)(cid:13)(cid:126)eP ((cid:126)τ , (cid:126)x)(cid:13)(cid:13)∞ ≤ ce ≤ 1 1 − ψd υi = τi + Ax 1 (cid:17)2 i AT x (cid:126)1m . 2 , we have the following: Assume ψd ≤ 1.1µ((cid:126)x) ≤ 1 • [Leverage Score Estimation] eP ((cid:126)υ, (cid:126)x)i = eP ((cid:126)τ , (cid:126)x)i for all i ∈ [m − 1]. • [Function Value Decrease] p(cid:126)ep((cid:126)υ,(cid:126)x)((cid:126)x) = p(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + [ce + eP ((cid:126)τ , (cid:126)x)m] ln s((cid:126)x)m + ln(1 − ψd) • [Centrality Increase] δ(cid:126)ep((cid:126)υ,(cid:126)x)((cid:126)x) ≤ δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + 3(ce + µ((cid:126)x)). 1√ 1−2µ((cid:126)x) Proof. By (1) in Lemma 15, we have that for all i ∈ [m − 1] ψP ((cid:126)x)i = ψP ((cid:126)x)i + 1 1 − ψd (cid:16)(cid:126)1T i Ax (cid:0)AT x Ax + λI(cid:1)−1 (cid:17)2 . AT x (cid:126)1m Consequently, [Leverage Score Estimation] holds. Furthermore, by (3) in Lemma 15, this then implies that [Function Value Change] holds. To bound the change in centrality we first note that by (1) and (2) in Lemma 15, we have that the approximate Hessian for P , denoted H((cid:126)x), is bounded by (cid:16) (cid:18) H((cid:126)x)−1 = (cid:22) (cid:19) H((cid:126)x) − AT 1 + α 1 − α (cid:17)−1 x (ceI + Ψx)1/2 (cid:126)1m(cid:126)1T m (ceI + Ψx)1/2 Ax (cid:19) (cid:18) 1 1 − α H((cid:126)x)−1 H((cid:126)x)−1 = 24 where α def= (cid:126)1T have m (ceI + Ψx)1/2 AxH((cid:126)x)−1AT Using this, we have α ≤ ce + µ((cid:126)x) H((cid:126)x)−1 (cid:22)(cid:0)AT (cid:18) ce + ψd δ(cid:126)ep((cid:126)υ,(cid:126)x)((cid:126)x) =(cid:13)(cid:13)A x (ce(cid:126)1 + (cid:126)υ)(cid:13)(cid:13)H−1 ≤(cid:13)(cid:13)AT T T (cid:13)(cid:13)A and therefore, by triangle inequality Now, (6.5) shows that (cid:126)1m x (cid:13)(cid:13)AT (cid:0)(cid:126)τ(cid:48) − (cid:126)υ(cid:1)(cid:13)(cid:13)2 (cid:13)(cid:13)AT x Furthermore, since Ψ−1 (cid:23) Ax 2 + 1 10 ≤ 1, we (6.5) (6.6) . T ψd . −1 ≤ AT x (cid:126)1m = (cid:126)1T mAx ce + µ((cid:126)x) (cid:13)(cid:13)A 1√ 1 − α x (ceI + Ψx)1/2 (cid:126)1m. Using ce + µ((cid:126)x) ≤ 1 x Ax + λI(cid:1)−1 (cid:19) x (ce + µ((cid:126)x))Ax + λI(cid:1)−1 (cid:22) (ce + µ((cid:126)x))−1(cid:0)AT (cid:18) ce + ψd (cid:19) x (ce(cid:126)1 + (cid:126)υ)(cid:13)(cid:13)H−1 (cid:126)1m(ce + τm)(cid:13)(cid:13)H−1 +(cid:13)(cid:13)AT x ((cid:126)τ(cid:48) − (cid:126)υ)(cid:13)(cid:13)H−1 . (cid:13)(cid:13)H−1 +(cid:13)(cid:13)AT (cid:115) (cid:0)AT x Ax + λI(cid:1)−1 x (ce(cid:126)1 + (cid:126)υ)(cid:13)(cid:13)H x (ce(cid:126)1 + (cid:126)τ )(cid:13)(cid:13)H−1 +(cid:13)(cid:13)AT = δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + (ce + τm)(cid:13)(cid:13)AT (cid:13)(cid:13)H−1 ≤ (cid:13)(cid:13)AT (cid:13)(cid:13)(AT 1(cid:112)ce + µ((cid:126)x) (cid:1)−1 AT (cid:0)AT H−1 ≤(cid:13)(cid:13)(cid:126)τ(cid:48) − (cid:126)υ(cid:13)(cid:13)2 (cid:18) 1 (cid:88) (cid:19)2(cid:16)(cid:126)1T (cid:18) 1 (cid:34) (cid:16)(cid:126)1T x Ax + λI(cid:1)−1 (cid:0)AT (cid:17)2 x Ax + λI(cid:1)−1 (cid:0)AT (cid:115) (cid:17)2(cid:19)2 (cid:18) ψd (cid:35) x , by Lemma 16 we have x (cid:23) AxH−1AT 1 − ψd 1 − ψd ce + µ((cid:126)x) −1 ≤ AT x (cid:126)1m AT x (cid:126)1m x ΨAx = ≤ i∈[m] ψ((cid:126)x)i x (cid:126)1m x x Ax+λI) (cid:126)1m x Ψ−1 1 mAx i Ax ψd = 1 − ψd (cid:19)2 x ((cid:126)τ(cid:48) − (cid:126)υ)(cid:13)(cid:13)H−1 Now let (cid:126)τ(cid:48) ∈ Rm−1 be defined so that τ(cid:48) i = τi for all i ∈ [m − 1]. We have by above that Combining, we have that δ(cid:126)ep((cid:126)υ,(cid:126)x)((cid:126)x) ≤ 1√ 1 − α δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + (ce + τm) 10 , (cid:13)(cid:13)(cid:126)eP ((cid:126)τ , (cid:126)x)(cid:13)(cid:13)∞ ≤ ce and (6.6), we have α ≤ 1.1ψd ≤ ce + µ((cid:126)x) + . ψd ψd 1 − ψd Using the assumption ψd ≤ 1.1µ((cid:126)x) ≤ 1 1.21µ((cid:126)x) and τm ≤ ψd + ce, and δ(cid:126)ep((cid:126)υ,(cid:126)x)((cid:126)x) ≤ ≤ (cid:104) 1(cid:112)1 − 1.3µ((cid:126)x) 1(cid:112)1 − 2µ((cid:126)x) δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + (ce + τm) 1(cid:113) 1 − 1.3 10 δ(cid:126)eP ((cid:126)τ ,(cid:126)x)((cid:126)x) + (cid:105) √ (cid:16)√ 1.1 + 1.2ψd √ 1.1 · 2ce + ( (cid:17) 1.1 + 1.2 · 1.1)µ((cid:126)x) 25 6.3 Hybrid Center Properties Here we prove properties of points near the hybrid center. First we bound the distance between points in the H((cid:126)x) norm in terms of the (cid:96)2 norm of the points. Lemma 19. For A ∈ Rm×n and (cid:126)b ∈ Rm suppose that (cid:126)x ∈ P = {(cid:126)y : A(cid:126)y ≥ (cid:126)b} and (cid:126)e ∈ Rm such that and i = + 2 . 2 ≤ i∈[m] ti ≤ ti i∈[m] ti i∈[m] ti i∈[m] ti i∈[m] AT x TAx = [(cid:126)sx]2 i (cid:19) (cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ ≤ 1 Proof. For notational simplicity let (cid:126)t def= ce(cid:126)1 + (cid:126)e + (cid:126)ψx, T def= diag((cid:126)t), and Q def= AT We have i∈[m] and (cid:88) and (cid:13)(cid:13)S−1 Now, clearly (cid:80) 1 − 2 2 ce < 1 [(cid:126)sx − (cid:126)sy]2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:88) x ((cid:126)sx − (cid:126)sy)(cid:13)(cid:13)∞ ≤ max 20 and δ(cid:126)e ≤ 0.1(cid:112)ce + µ((cid:126)x). Then for all (cid:126)y ∈ P we have (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) ≤ 12mce + 6n + 2λ(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 (cid:112)ce + µ((cid:126)x) (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 2 ≤ 4λ−1(mce + n) + 2(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 (cid:18) (cid:88) (cid:88) (cid:0)1 +(cid:13)(cid:13)S−1  max (cid:88) x ((cid:126)sy − (cid:126)sx)(cid:13)(cid:13)∞ (cid:114) (cid:12)(cid:12)(cid:12)(cid:126)1iS−1 (cid:12)(cid:12)(cid:12) ≤(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) (cid:2)S−1 i∈[m] ti[(cid:126)sy]i/[(cid:126)sx]i is positive and since (cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ ≤ 1 (cid:88) (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) (cid:112)ce + µ((cid:126)x) (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) (cid:112)ce + µ((cid:126)x) −1/2(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) 2 ce we know that 1 ≤ (ce + µ((cid:126)x)) x A ((cid:126)x − (cid:126)y) [(cid:126)sy]2 i [(cid:126)sx]2 i [(cid:126)sy]2 i [(cid:126)sx]2 i [(cid:126)sy]i [(cid:126)sx]i [(cid:126)sy]i [(cid:126)sx]i [(cid:126)sy]i [(cid:126)sx]i [(cid:126)sy]i [(cid:126)sx]i i∈[m] i∈[m] [(cid:126)sy]i [(cid:126)sx]i [(cid:126)sy]i [(cid:126)sx]i [(cid:126)sy]i [(cid:126)sx]i Now since ∇p(cid:126)e((cid:126)x) = −AT S−1 Therefore, by combining, (6.8), (6.9), and (6.10) we have Q ≤ (cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 − (cid:88) (cid:88) ≤ (cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + (cid:104)(cid:126)x − (cid:126)y,∇p(cid:126)e((cid:126)x)(cid:105) = − (cid:88) and therefore by Cauchy Schwarz and (cid:126)xT (cid:126)y ≤(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:88) =(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 − λ(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 2 +(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x)δ(cid:126)e((cid:126)x) ≤(cid:13)(cid:13)t(cid:13)(cid:13)1 + x T(cid:126)1 + λ(cid:126)x we have (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 [(cid:126)sx − (cid:126)sy]i [(cid:126)sy]i [(cid:126)sx]i i∈[m] i∈[m] i∈[m] 4 2, 2 + 1 2 + λ(cid:126)xT (cid:126)y + (cid:104)(cid:126)x − (cid:126)y,∇p(cid:126)e((cid:126)x)(cid:105) + λ(cid:126)xT ((cid:126)x − (cid:126)y) max i∈[m] ti + ti [(cid:126)sx]i i∈[m] . ti 1 2 ti ti λ 4 26 . (6.7) x (ceI + Ψx)Ax. (cid:1) (6.8) (6.9) (cid:3) ii (6.10) 2 Q (cid:22) AT x TAx. x AH((cid:126)x)−1AT S−1 x (6.11) (6.12) (6.13) 2 1 4 λ 2 1 2 1 2 i∈[m] 4 2 + λ 2 2 2 + 4 2 λ 2 λ 2 H((cid:126)x) + λ 2 Q + λ 2 2 + λ 2 and hence H((cid:126)x) = 2 ≤ λ 2 ti [(cid:126)sy]i [(cid:126)sx]i (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 i∈[m] ti[(cid:126)sy]i/[(cid:126)sx]i is positive, (6.12) shows that Now, using (6.11), (6.13) and the definition of H((cid:126)x), we have (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:88) (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) ≤ (cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:112)ce + µ((cid:126)x) (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)t(cid:13)(cid:13)1 + λ (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ≤ (cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) + δe((cid:126)x) (cid:112)ce + µ((cid:126)x) (cid:112)ce + µ((cid:126)x) Using the fact that δe((cid:126)x) ≤ 0.1(cid:112)ce + µ((cid:126)x), we have (cid:13)(cid:13)t(cid:13)(cid:13)1 + λ (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x). (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 H((cid:126)x) ≤(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:112)ce + µ((cid:126)x) Furthermore, since(cid:80) 2 − λ(cid:126)xT (cid:126)y ≤(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + (cid:104)(cid:126)x − (cid:126)y,∇p(cid:126)e((cid:126)x)(cid:105) ≤(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 +(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x)δe((cid:126)x) λ(cid:126)xT ((cid:126)x − (cid:126)y) = λ(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 2 +(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x)δe((cid:126)x) (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ≤(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + Putting (6.15) into (6.14) and using the fact that δe((cid:126)x) ≤ 0.1(cid:112)ce + µ((cid:126)x), we have (cid:33)(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x). (cid:32) (cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + λ (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 H((cid:126)x) ≤ 2(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 + (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:112)ce + µ((cid:126)x) Now, using(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 ≤ 2mce + n, we have (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 H((cid:126)x) ≤ 2α + (0.1 + α)(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:112)ce + µ((cid:126)x) Since(cid:112)ce + µ((cid:126)x) ≤ 1.05, we have α ≥ 0.9 and hence (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) ≤ 0.1 + α +(cid:112)(α + 0.1)2 + 2α We also have by (6.12) and the fact that δe((cid:126)x) ≤ 0.1(cid:112)ce + µ((cid:126)x), 2 =(cid:13)(cid:13)t(cid:13)(cid:13)1 + λ(cid:126)xT (cid:126)y + (cid:104)(cid:126)x − (cid:126)y,∇p(cid:126)e((cid:126)x)(cid:105) − (cid:88) λ(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 2 +(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x)δe((cid:126)x) ≤(cid:13)(cid:13)t(cid:13)(cid:13)1 + 2 + 0.1(cid:112)ce + µ((cid:126)x)(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ≤(cid:13)(cid:13)t(cid:13)(cid:13)1 + 2 = λ(cid:126)xT ((cid:126)x − (cid:126)y) + (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 2mce + n + λ 4 ti [(cid:126)sy]i [(cid:126)sx]i yielding (6.7). 2 + 2 + for α = 2 + 0.1 + λ 2 . ≤ 6α 1 4 1 4 λ 2 4 2 2 . 2 · 1 4 i∈[m] (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 2. (6.14) (6.15) 2 λ 2 λ 2 λ 2 λ 2 27 Hence, using(cid:13)(cid:13)(cid:126)t(cid:13)(cid:13)1 ≤ 2mce + n and(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) ≤ 6α, we have 2 ≤(cid:13)(cid:13)t(cid:13)(cid:13)1 + (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ≤ λ(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 λ 2 (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 λ 2 2 + 2(mce + n). (cid:18) 2 + 0.6 2mce + n + (cid:19) (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 2 λ 4 In the following lemma we show how we can write one hyperplane in terms of the others provided that we are nearly centered and show there is a constraint that the central point is close to. Lemma 20. Let A ∈ Rm×n and (cid:126)b ∈ Rm such that (cid:13)(cid:13)ai A(cid:126)y ≥ (cid:126)b} and (cid:126)e ∈ Rm such that(cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ ≤ 1 2 ce ≤ 1 (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:126)ai + (cid:19)(cid:18) ce + ej + ψj((cid:126)x) (cid:19) that i = arg minj∈[m] sj((cid:126)x) then (cid:18) s(x)i ce + ei + ψi((cid:126)x) (cid:88) s(x)j j(cid:54)=i (cid:126)aj 2 . Furthermore, let  = minj∈[m] sj((cid:126)x) and suppose (cid:13)(cid:13)2 = 1 for all i. Suppose that (cid:126)x ∈ P = {(cid:126)y : (cid:35) (cid:114) mce + n λ(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 + δe((cid:126)x) + λ . (cid:34) 2 (ce + µ((cid:126)x)) 2 ≤ (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 = λ(cid:126)x − (cid:88) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 (cid:19) ∇pe((cid:126)x) = −AT S−1 x (ce(cid:126)1 + (cid:126)e + (cid:126)ψx) + λ(cid:126)x (ce + ei + ψi) s((cid:126)x)i (cid:126)ai Proof. We know that (cid:88) (cid:18) s(x)i Consequently, by(cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ ≤ 1 (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:126)ai + (cid:13)(cid:13) = 1,(cid:80) Using(cid:13)(cid:13)(cid:126)ai s(x)j j(cid:54)=i Hence, we have H((cid:126)x) (cid:22)(cid:0) mce+n (cid:13)(cid:13)(cid:13)2 x (ce(cid:126)1 + (cid:126)e + (cid:126)ψx) i∈[m] 2 ce, and ψi((cid:126)x) ≥ µ((cid:126)x) = 2 (cid:126)aj ≤ si((cid:126)x) ce + ei + ψi((cid:126)x) (ce + ei + ψi((cid:126)x)) (cid:19)(cid:18) ce + ej + ψj((cid:126)x) (cid:13)(cid:13)(cid:13)AT S−1 (cid:2)λ(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 +(cid:13)(cid:13)∇pe((cid:126)x)(cid:13)(cid:13)2 (cid:13)(cid:13)2 (cid:13)(cid:13)ai (cid:113) mce+n 2 + λ(cid:1) I and(cid:13)(cid:13)∇pe((cid:126)x)(cid:13)(cid:13)2 ≤ δe((cid:126)x) i ψi ≤ n, and si((cid:126)x) ≥ , we have (cid:88) Tr(AT x (ceI + Ψx)Ax) = Tr(AxAT ≤ mce + n x (ceI + Ψx)) (ce + µ((cid:126)x)) 2 s2 i ((cid:126)x) (ce + ψi) 2 = . i (cid:3) . 2 + λ yielding the result. (6.16) 6.4 The Algorithm Here, we put all the results in the previous sections to get our ellipsoid algorithm. Below is a sketch of the pseudocode; we use ca, cd, ce, c∆ to denote parameters we decide later. In the algorithm, there are two main invariants we maintain. First, we maintain that the centrality δP,(cid:126)e((cid:126)x), which indicates how close (cid:126)x is to the minimum point of p(cid:126)e, is small. Second, we maintain that(cid:13)(cid:13)(cid:126)e((cid:126)τ , (cid:126)x)(cid:13)(cid:13)∞, which indicates how accurate the leverage score estimate (cid:126)τ is, is small. In the following lemma we show that we maintain both invariants throughout the algorithm. 28 Algorithm 2: Our Cutting Plane Method Input: A(0) ∈ Rm×n, (cid:126)b(0) ∈ Rm,  > 0, and radius R > 0. Input: A separation oracle for a non-empty set K ⊂ B∞(R). Check: Throughout the algorithm, if si((cid:126)x(k)) <  output P (k). Check: Throughout the algorithm, if (cid:126)x(k) ∈ K, output (cid:126)x(k). Set P (0) = B∞(R). Set (cid:126)x(0) := (cid:126)0 and compute τ (0) for k = 0 to ∞ do i = ψP (0)((cid:126)x(0))i for all i ∈ [m] exactly. (cid:12)(cid:12)(cid:12)w(k) Let m(k) be the number of constraints in P (k). Compute (cid:126)w(k) such that ΨP (k)((cid:126)x(k)) (cid:22) W(k) (cid:22) (1 + c∆)ΨP (k)((cid:126)x(k)). Let i(k) ∈ arg maxi∈[m(k)] Set τ if mini∈[m(k)] w(k) (k+ 1 3 ) i(k) = ψP (k)((cid:126)x(k))i(k) and τ i ≤ cd then for all j (cid:54)= i(k). i − τ (k) i (k+ 1 3 ) j = τ (k) j Remove constraint with minimum w(k) yielding polytope P (k+1). (cid:12)(cid:12)(cid:12). i else (k+ 2 3 ) Update (cid:126)τ according to Lemma 18 to get τ j Use separation oracle at (cid:126)x(k) to get a constraint {(cid:126)x : (cid:126)aT (cid:126)x ≥ (cid:126)aT (cid:126)x(k)} with(cid:13)(cid:13)(cid:126)a(cid:13)(cid:13)2 = 1. . (cid:113) (cid:126)aT (AT S−2 (cid:126)x(k)A + λI)−1(cid:126)a} yielding Add constraint {(cid:126)x : (cid:126)aT (cid:126)x ≥ (cid:126)aT (cid:126)x(k) − c polytope P (k+1). (k+ 2 3 ) Update (cid:126)τ according to Lemma 17 to get τ j −1/2 a . ((cid:126)x(k+1), (cid:126)τ (k+1)) = Centering((cid:126)x(k), (cid:126)τ (k+ 2 3 ), 200, c∆). end √ Lemma 21. Assume that ce ≤ cd ≤ 1 small enough universal constant C. During our cutting plane method, for all k, with high probability in n, we have 103 , cd ≤ ca, and c∆ ≤ Cce/ log(n) for some ca ≤ cd 106 , ca 1. (cid:13)(cid:13)(cid:126)e((cid:126)τ (k+ 1 3 ), (cid:126)x(k))(cid:13)(cid:13)∞ ≤ 1 2. δ P (k),(cid:126)e((cid:126)τ (k+ 2 3 ),(cid:126)x(k)) ((cid:126)x(k)) ≤ 1 1000 ce,(cid:13)(cid:13)(cid:126)e((cid:126)τ (k+1), (cid:126)x(k+1))(cid:13)(cid:13)∞ ≤ 1 3 ), (cid:126)x(k))(cid:13)(cid:13)∞ ≤ 1 1000 ce,(cid:13)(cid:13)(cid:126)e((cid:126)τ (k+ 2 (cid:113) ce + min(cid:0)µ((cid:126)x(k)), cd (cid:1). (cid:113) ce + min(cid:0)µ((cid:126)x(k+1)), cd (cid:1). 100 3. δP (k+1),(cid:126)e((cid:126)τ (k+1),(cid:126)x(k+1))((cid:126)x(k+1)) ≤ 1 400 400 ce. Proof. Some statements of the proof hold only with high probability in n; we omit mentioning this for simplicity. We prove by induction on k. Note that the claims are written in order consistent with the algorithm and proving the statement for k involves bounding centrality at the point (cid:126)x(k+1). Trivially 3 ) = (cid:126)τ (0) and note that the claims then hold for k = −1 as we we define, (cid:126)τ (−1) = (cid:126)τ (− 2 compute the initial leverage scores, (cid:126)τ (0), exactly and since the polytope is symmetric we have δ(cid:126)e((cid:126)τ (0),(cid:126)x(0))((cid:126)0) = 0. We now suppose they hold for all r < t and show that they hold for r = t. def=(cid:112)ce + min{µ((cid:126)x(t)), cd}. By the induction We first bound δ. For notational simplicity, let ηt 3 ) = (cid:126)τ (− 1 hypothesis we know that δP (t),(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t)) ≤ 1 400 ηt. Now, when we update τ (t) to τ (t+ 1 3 ), we set 29 (cid:126)ei(t) to 0. Consequently, Lemma 13 and the induction hypothesis(cid:13)(cid:13)(cid:126)e((cid:126)τ (t), (cid:126)x(t))(cid:13)(cid:13)∞ ≤ 1 400 ce show that δ P (t),(cid:126)e((cid:126)τ (t+ 1 3 ),(cid:126)x(t)) ((cid:126)x(t)) ≤ δP (t),(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t)) + ≤ ηt 200 ≤ 1 400 ce 400 ηt + √ 1(cid:112)ce + µ((cid:126)x(t)) ei(t)((cid:126)τ (t), (cid:126)x(t)) (6.17) Next, we estimate the δ changes when we remove or add a constraint. For the case of removal, we note that it happens only if µ((cid:126)x(t)) ≤ mini wi ≤ cd ≤ 1 106 . Also, the row we remove has leverage score at most 1.1µ((cid:126)x(t)) because we pick the row with minimum w. Hence, Lemma 18 and ce ≤ 1 106 show that δ P (t+1),(cid:126)e((cid:126)τ (t+ 2 3 ),(cid:126)x(t)) ((cid:126)x(t)) ≤ ≤ √ 1(cid:112)1 − 2µ((cid:126)x(t)) (cid:16) ηt 1 δ 1 − 2 · 10−6 200 (cid:17) P (t),(cid:126)e((cid:126)τ (t+ 1 3 ),(cid:126)x(t)) ((cid:126)x(t)) + 2.7(ce + µ((cid:126)x(t))) + 3(ce + µ((cid:126)x(t))) ≤ ηt 100 ce + cdηt ≤ √ 2 ((cid:126)x(t)) ≤ δ 3 ),(cid:126)x(t)) √ where we used the fact µ((cid:126)x(t)) ≤ cd and hence ce + µ((cid:126)x(t)) ≤ √ For the case of addition, we note that it happens only if 2µ((cid:126)x(t)) ≥ mini wi ≥ cd. Furthermore, in this case the hyperplane we add is chosen precisely so that ψa = ca. Furthermore, since ce ≤ cd ≤ ca (cid:115) by Lemma 17 we have that 1000 ηt. δ P (t+1),(cid:126)e((cid:126)τ (t+ 2 P (t),(cid:126)e((cid:126)τ (t+ 1 3 ),(cid:126)x(t)) + (ce + ψa) µ((cid:126)x(t)) Now, note that Lemmas 17 and 18 show that (cid:126)e does not change during the addition or removal ca ≤ cd 1000 , µ((cid:126)x(t)) ≥ cd/2, and cd ≤ 10−6 we know that 4ca ((cid:126)x(t)) ≤ 1 3 ),(cid:126)x(t)) P (t+1),(cid:126)e((cid:126)τ (t+ 2 3 ), (cid:126)x(t))(cid:13)(cid:13)∞ ≤(cid:13)(cid:13)(cid:126)e((cid:126)τ (t+ 1 = ψP (k)((cid:126)x(k))i(k)” only decreases (cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ and hence we have (cid:13)(cid:13)(cid:126)e((cid:126)τ (t+ 2 Furthermore, since ca and consequently in both cases we have δ of an constraint. Hence, we have (cid:13)(cid:13)(cid:126)e((cid:126)τ (t+ 2 (cid:13)(cid:13)(cid:126)e((cid:126)τ (t), (cid:126)x(t))(cid:13)(cid:13)∞ ≤ ce (cid:18) the step “(cid:126)τ (k+ 1 3 ) i(k) δP (t+1),(cid:126)e((cid:126)τ (t+1),(cid:126)x(t+1))((cid:126)x(t+1)) ≤ 2 400 . Thus, we have all the conditions needed for Lemma 14 and consequently 1 − 1 64 (cid:13)(cid:13)(cid:13) s((cid:126)x(t+1))−s((cid:126)x(t)) s((cid:126)x(t)) ((cid:126)x(t)) ≤ 1 1000 3 ),(cid:126)x(t)) δ P (t+1),(cid:126)e((cid:126)τ (t+ 2 10 and hence ψi((cid:126)x(t)) ≤ 2ψi((cid:126)x(t+1)) for all i. ηt . ≤ 1 (cid:19)200 (cid:13)(cid:13)(cid:13)2 Lemma 14 also shows that that Therefore, ηt ≤ 2ηt+1 and thus . ψa cd + 4ca + ψa ≤ ηt 200 (cid:114) ca (cid:112)ca/cd ≤ 1 3 ), (cid:126)x(t))(cid:13)(cid:13)∞. Furthermore, we know 3 ), (cid:126)x(t))(cid:13)(cid:13)∞ ≤ 100 ηt. 200 ηt δP (t+1),(cid:126)e((cid:126)τ (t+1),(cid:126)x(t+1))((cid:126)x(t+1)) ≤ completing the induction case for δ. Now, we bound(cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞. Lemma 17 and 18 show that (cid:126)e does not change during the addition or 400 removal of an constraint. Hence, (cid:126)e is affected by only the update step “τ the centering step. Using the induction hypothesis δ shows that E(cid:126)e((cid:126)τ (r+1), (cid:126)x(r+1)) = (cid:126)e((cid:126)τ (r+ 2 3 ), (cid:126)x(r)) and(cid:13)(cid:13)(cid:126)e((cid:126)τ (r+1), (cid:126)x(r+1)) − (cid:126)e((cid:126)τ (r+ 2 ((cid:126)x(r)) ≤ 1 P (r),(cid:126)e((cid:126)τ (r+ 2 3 ),(cid:126)x(r)) (k+ 1 2 ) i(k) = ψP (k)((cid:126)x(k))i(k)” and 100 ηr and Lemma 14 10 c∆ for 3 ), (cid:126)x(r))(cid:13)(cid:13)2 ≤ 1 (cid:113) ce + min(cid:0)cd, µ((cid:126)x(t+1))(cid:1) . 30 all r ≤ t. The goal for the update step is to decrease (cid:126)e by updating (cid:126)τ . In Section 7.2, we give a self-contained analysis of the effect of this step as a game. In each round, the vector (cid:126)e is corrupted by some mean 0 and bounded variance noise and the problem is how to update (cid:126)e such that(cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ is bounded. Theorem 34 shows that we can do this by setting the (cid:126)ei = 0 for the almost maximum coordinate in each iteration. This is exactly what the update step is doing. Hence, Theorem 34 shows that this strategy guarantees that after the update step, we have (cid:13)(cid:13)(cid:13)∞ = O (c∆ log (n)) for all r ≤ t. Now, by our choice of c∆, we have (cid:13)(cid:13)(cid:126)e((cid:126)τ (t+ 1 have (cid:13)(cid:13)(cid:126)e((cid:126)τ (t+ 2 induction case for(cid:13)(cid:13)(cid:126)e(cid:13)(cid:13)∞ and proves this lemma. (cid:13)(cid:13)(cid:13)(cid:126)e(τ (r+ 1 3 ), (cid:126)x(t))(cid:13)(cid:13)∞ ≤ 1 1000 ce. Now, we note that again Lemma 14 shows (cid:13)(cid:13)(cid:126)e((cid:126)τ (t+1), (cid:126)x(t+1)) − 1000 ce, and we have (cid:13)(cid:13)(cid:126)e((cid:126)τ (t+1), (cid:126)x(t+1))(cid:13)(cid:13)∞ ≤ ce 1000 ce. Lemma 17 and 18 show that (cid:126)e does not change during the addition or removal of an constraint. Hence, we 3 ), (cid:126)x(t))(cid:13)(cid:13)∞ ≤ 1 3 ), (cid:126)x(t))(cid:13)(cid:13)2 ≤ 1 400 . This finishes the 10 c∆ ≤ 1 3 ), (cid:126)x(r)) (cid:126)e((cid:126)τ (t+ 2 Next, we show the number of constraints is always linear to n. constraints. 2 for all i. Letting Using K (cid:54)= ∅ and K ⊂ B∞(R), here we show that the points are bounded. Lemma 22. Throughout our cutting plane method, there are at most 1 + 2n cd Proof. We only add a constraint if mini wi ≥ cd. Since 2ψi ≥ wi, we have ψi ≥ cd m denote the number of constraints after we add that row, we have n ≥(cid:80) Lemma 23. During our Cutting Plane Method, for all k, we have(cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13)2 ≤ 6(cid:112)n/λ + 2 2 ≤ 4λ−1(mce + n) + 2(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 Proof. By Lemma 21 and Lemma 19 we know that (cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13)2 (cid:126)y ∈ K ⊂ P (k). Since K ⊂ B∞(R), we have(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 2 for any (cid:126)y ∈ P (k). Since our method never cuts out any point in K and since K is nonempty, there is some 2 ≤ nR. Furthermore, by Lemma 22 we have that (cid:113) 1 mce ≤ ce + 2n ≤ 3n yielding the result. √ (cid:0)(cid:126)x(k)(cid:1) ≤ 12(cid:112)n/λ + 4 i ψi ≥ (m− 1)(cd/2). caλ for all i and k in the our cutting plane method. Lemma 24. si nR + nR. √ Proof. Let (cid:126)x(j) be the current point at the time that the constraint corresponding to si, denoted {(cid:126)x : (cid:126)aT i (cid:126)x(j) − si((cid:126)x(j))}, was added. Clearly i (cid:126)x ≥ aT si((cid:126)x(k)) = (cid:126)aT i (cid:126)x(k) − aT i (cid:126)x(j) + si((cid:126)x(j)) ≤(cid:13)(cid:13)(cid:126)ai (cid:13)(cid:13) ·(cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13) + (cid:12)(cid:12)(cid:12)(cid:126)aT (cid:12)(cid:12)(cid:12) i (cid:126)x(j) − si((cid:126)x(j)) . know that On the one hand, if the constraint for si comes from the initial symmetric polytope P (0) = B∞(R), we know (cid:12)(cid:12)(cid:126)aT (cid:126)x(j) − (cid:126)si((cid:126)x(j))(cid:12)(cid:12) ≤ R . On the other hand, if the constraint was added later then we (cid:113) and (cid:12)(cid:12)(cid:126)aT (cid:126)x(j) − si((cid:126)x(j))(cid:12)(cid:12) ≤ (cid:13)(cid:13)(cid:126)ai (cid:13)(cid:13)2 = 1 by design and (cid:13)(cid:13)(cid:126)x(j)(cid:13)(cid:13)2 and (cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13)2 are upper bounded by 6(cid:112)n/λ + 2 (cid:13)(cid:13) ·(cid:13)(cid:13)(cid:126)x(j)(cid:13)(cid:13) +(cid:12)(cid:12)si((cid:126)x(j))(cid:12)(cid:12). Since (cid:13)(cid:13)(cid:126)ai (cid:126)x(j)A + λI)−1(cid:126)a ≤ (caλ)−1/2 nR by Lemma 23, in either case the result follows. si((cid:126)x(j)) = c−1/2 (cid:126)aT (AT S−2 √ a Now, we have everything we need to prove that the potential function is increasing in expecta- tion. 31 Lemma 25. Under the assumptions of Lemma 21 if λ = 1 then for all k we have caR2 , ce = 6 ln(17nR/) , and 24cd ≤ ca ≤ 1 cd 3 Ep(cid:126)e((cid:126)τ (k+1),(cid:126)x(k+1))((cid:126)x(k+1)) ≥ p(cid:126)e((cid:126)τ (k),(cid:126)x(k))((cid:126)x(k)) − cd + ln(1 + β) where β = ca for the case of adding a constraint β = −cd for the case of removal. Proof. Note that there are three places which affect the function value, namely the update step for τ (k+ 1 3 ), the addition/removal of constraints, and the centering step. We bound the effect of each separately. First, for the update step, we have p (cid:126)e((cid:126)τ (k+ 1 3 ),(cid:126)x(k)) ((cid:126)x(k)) = −ei(k) log(si(k)((cid:126)x(k))) + p(cid:126)e((cid:126)τ (k),(cid:126)x(k))((cid:126)x(k)). Lemma 24, the termination condition and λ = 1  ≤ si(k)((cid:126)x(k)) ≤ 12(cid:112)n/λ + 4 √ nR + caR2 ensure that (cid:114) 1 caλ and Lemma 21 shows that ei(k) ≤ ce. Hence, we have √ ≤ 17 nR (6.18) p (cid:126)e((cid:126)τ (k+ 1 3 ),(cid:126)x(k)) ((cid:126)x(k)) ≥ p(cid:126)e((cid:126)τ (k),(cid:126)x(k))((cid:126)x(k)) − ce log(17nR/). For the addition step, Lemma 17 shows that p (cid:126)e((cid:126)τ (k+ 2 3 ),(cid:126)x(k)) ((cid:126)x(k)) = p ≥ p (cid:126)e((cid:126)τ (k+ 1 3 ),(cid:126)x(k)) (cid:126)e((cid:126)τ (k+ 1 3 ),(cid:126)x(k)) ((cid:126)x(k)) − ce ln s((cid:126)x)m+1 + ln(1 + ca) ((cid:126)x(k)) − ce log(17nR/) + ln(1 + ca) and for the removal step, Lemma 18 and ei ≤ ce shows that p (cid:126)e((cid:126)τ (k+ 2 3 ),(cid:126)x(k)) ((cid:126)x(k)) ≥ p ≥ p (cid:126)e((cid:126)τ (k+ 1 3 ),(cid:126)x(k)) (cid:126)e((cid:126)τ (k+ 1 3 ),(cid:126)x(k)) ((cid:126)x(k)) − [ce + eP ((cid:126)τ , (cid:126)x)m] ln s((cid:126)x)m + ln(1 − cd) ((cid:126)x(k)) − 2ce log(17nR/) + ln(1 − cd) After the addition or removal of a constraint, Lemma 21 shows that δ P (k),(cid:126)e((cid:126)τ (k+ 2 3 ),(cid:126)x(k)) ((cid:126)x(k)) ≤ 1 100 and therefore Lemma 14 and ce ≤ cd show that Ep(cid:126)e((cid:126)τ (k+1),(cid:126)x(k+1))((cid:126)x(k+1)) ≥ p (cid:126)e((cid:126)τ (k+ 2 3 ),(cid:126)x(k)) (cid:1) (cid:113) ce + min(cid:0)µ((cid:126)x(k)), cd  ((cid:126)x(k)) − 8 (cid:113) ce + min(cid:0)µ((cid:126)x(k)), cd 100 (cid:1) 2 ≥ p (cid:126)e((cid:126)τ (k+ 2 3 ),(cid:126)x(k)) ((cid:126)x(k)) − cd 625 . Combining them with ce = cd 6 ln(17nR/) , we have Ep(cid:126)e((cid:126)τ (k+1),(cid:126)x(k+1))((cid:126)x(k+1)) ≥ p(cid:126)e((cid:126)τ (k),(cid:126)x(k))((cid:126)x(k)) − 3ce log(17nR/) − cd 625 ≥ p(cid:126)e((cid:126)τ (k),(cid:126)x(k))((cid:126)x(k)) − cd + ln(1 + β) + ln(1 + β) where β = ca for the case of addition and β = −cd for the case of removal. 32 Theorem 26. For ca = 1 enough universal constant C, then we have 1010 , cd = 1 1012 , ce = cd 6 ln(17nR/) , c∆ = Cce log(n) and λ = 1 caR2 for some small Ep(cid:126)e((cid:126)τ (k+1),(cid:126)x(k+1))((cid:126)x(k+1)) ≥ p(cid:126)e((cid:126)τ (k),(cid:126)x(k))((cid:126)x(k)) − 1 1011 + 9β 1011 where β = 1 for the case of addition and β = 0 for the case of removal. Proof. It is easy to see that these parameters satisfy the requirements of Lemma 25. 6.5 Guarantees of the Algorithm In this section we put everything together to prove Theorem 31, the main result of this section, providing the guarantees of our cutting plane method. For the remainder of this section we assume that ca = 1 1010 , cd = 1 1012 , ce = cd 6 ln(17nR/) , c∆ = Cce log(n) and λ = 1 caR2 . Consequently, throughout the algorithm we have (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ≤ 6(cid:112)n/λ + 2 √ (cid:112) nR = 6 canR2 + 2 nR. (6.19) √ nR ≤ 3 √ Lemma 27. If si((cid:126)x(k)) <  for some i and k during our Cutting Plane Method then (cid:104)(cid:126)ai, (cid:126)y(cid:105) − max (cid:126)y∈P (k)∩B∞(R) Proof. Let (cid:126)y ∈ P (k) ∩ B∞(R) be arbitrary. Since (cid:126)y ∈ B∞(R) clearly(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 2 ≤ nR2. Furthermore, by Lemma 22 and the choice of parameters mce + n ≤ 3n. Consequently, by Lemma 19 and the fact that λ = 1 (cid:126)y∈P (k)∩B∞(R) min . caR2 and ca < 1 we have (cid:104)(cid:126)ai, (cid:126)y(cid:105) ≤ 8n cace (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)H((cid:126)x) ≤ 12mce + 6n + 2λ(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 (cid:112)ce + µ((cid:126)x) (cid:13)(cid:13)(cid:13)S−1 x(k)(s((cid:126)x(k)) − s((cid:126)y)) (cid:13)(cid:13)(cid:13)∞ ≤ 1√ ce 2 ≤ 4n √ ce ca ≤ 30n + 2 n ca (cid:112)ce + µ((cid:126)x) (cid:13)(cid:13)(cid:13)ceI+Ψ x(k)(s((cid:126)x(k)) − s((cid:126)y)) ≤ 4n cace . and therefore(cid:13)(cid:13)(cid:13)S−1 Consequently, we have (1 − 4n cace )si((cid:126)x(k)) ≤ si((cid:126)y) ≤ (1 + 4n cace )si((cid:126)x(k)) for all (cid:126)y ∈ P (k) ∩ B∞(R). Now let us show how to compute a proof (or certificate) that the feasible region has small width on the direction (cid:126)ai. Lemma 28. Suppose that during some iteration k for i = arg minj sj((cid:126)x(k)) we have si((cid:126)x(k)) ≤ . Let ((cid:126)x∗, (cid:126)τ∗) = Centering((cid:126)x(k), (cid:126)τ (k), 64 log(2R/), c∆) where (cid:126)τ (k) is the τ at that point in the algorithm and let (cid:88) tj(cid:126)aj where tj = (cid:18) s((cid:126)x∗)i (cid:19)(cid:18) ce + ej((cid:126)x∗, (cid:126)τ∗) + ψj((cid:126)x∗) √ caceR and tj ≥ 0 for all j. Furthermore, we have ce + ei((cid:126)x∗, (cid:126)τ∗) + ψi((cid:126)x∗) s((cid:126)x∗)j (cid:19) n . (cid:126)a∗ = j(cid:54)=i Then, we have that(cid:13)(cid:13)(cid:126)ai + (cid:126)a∗(cid:13)(cid:13)2 ≤ 8 O(n)(cid:88) T tjaj j(cid:54)=i (cid:126)x∗ − tjbj ≤ 3n ce s((cid:126)x∗)i . O(n)(cid:88) j(cid:54)=i 33 Proof. By Lemma 14 and Lemma 21 we know that (cid:126)e((cid:126)x∗, (cid:126)τ∗) ≤ 1 Since (cid:126)e((cid:126)x∗, (cid:126)τ∗) ≤ 1 have that with high probability in n 2 ce, we have tj ≥ 0 for all j. Furthermore, by Lemma 20 and (6.19), we then 2 ce and δ(cid:126)e((cid:126)x∗,(cid:126)τ∗) ≤  R (cid:112)ce + µ((cid:126)x∗). (cid:13)(cid:13)(cid:126)ai + (cid:126)a∗(cid:13)(cid:13)2 ≤ (cid:35) + λ (cid:34) λ(cid:13)(cid:13)(cid:126)x∗(cid:13)(cid:13)2 + δe((cid:126)x∗) (cid:114) 3n (cid:35) 2 + (cid:114) mce + n (cid:21) 2 n caR2 2 (cid:20) 1 (cid:34) (ce + µ((cid:126)x∗)) √ caR2 (3 nR) + √ √ 3 n caR 3n 4 ≤ 2 ce ≤ 2 ce + + (cid:13)(cid:13)(cid:126)ai + (cid:126)a∗(cid:13)(cid:13)2 ≤ 8  R √ n√ 2 caR √ n caceR . . Hence, we have O(n)(cid:88) j(cid:54)=i T O(n)(cid:88) j(cid:54)=i By Lemma 21 we know that (cid:126)e((cid:126)x∗, (cid:126)τ∗) ≤ 1 2 ce and hence tjaj (cid:126)x∗ − tjbj = tjs((cid:126)x∗)j = si((cid:126)x∗) O(n)(cid:88) j(cid:54)=i (cid:32) 3 O(n)(cid:88) j(cid:54)=i ≤ si((cid:126)x∗) 2 ce + ψj((cid:126)x∗) 2 ce + ψi((cid:126)x∗) 1 O(n)(cid:88) j(cid:54)=i (cid:19) (cid:18) ce + ej((cid:126)x∗, (cid:126)τ∗) + ψj((cid:126)x∗) (cid:33) (cid:18) 3mce + 2n ce + ei((cid:126)x∗, (cid:126)τ∗) + ψi((cid:126)x∗) O(n)(cid:88) ≤ si((cid:126)x∗) j(cid:54)=i ce (cid:19) ≤ 3n ce si((cid:126)x∗) Lemma 29. During our Cutting Plane Method, if p(cid:126)e((cid:126)x(k)) ≥ n log( n  for some i. ca )+ 6n ca , then we have si((cid:126)x(k)) ≤ (cid:16) (cid:16) (cid:17) (ce + ei) log si((cid:126)x(k))i + 1 2 log det AT S−2 x(k)A + λI i∈[m] Proof. Recall that p(cid:126)e((cid:126)x(k)) = − (cid:88) p(cid:126)e((cid:126)x(k)) ≤ − (cid:88) Using(cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13) ≤ 3 Next, we note that(cid:13)(cid:13)ei √ i∈[m] (cid:13)(cid:13)∞ ≤ ce ≤ nR (6.19) and λ = 1 caR2 , we have (ce + ei) log(s((cid:126)x(k))i) + (Lemma 24). Hence, we have p(cid:126)e((cid:126)x(k)) ≤ 1 2 log det 1 12 ln(17nR/) and si (cid:16) Since p(cid:126)e((cid:126)x(k)) ≥ n log( n have that n2 c2 a2 ≥ n2 ca ) + 6n ca , we have 1 2 log det 2 + λ and hence(cid:88) log λi (cid:0)AT S−2 x A + λI(cid:1) ≥ n log (cid:16) n AT S−2 (cid:16) + x(k)A + λI AT S−2 x(k)A + λI . 6n ca (cid:17) ≥ n log( n (cid:17) 2 + λ . i 34 (cid:17) (cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13)2 2. + λ 2 (cid:17) + 1 2 AT S−2 log det (cid:0)(cid:126)x(k)(cid:1) ≤ 12(cid:112)n/λ + 4 x(k)A + λI √ nR + 5n ca . (cid:113) 1 caλ ≤ 6 √ nR ca ). Using  < R, we Therefore, we have log λmax such that (cid:126)vAT S−2 x A(cid:126)v + λ(cid:126)vT (cid:126)v ≥ n 2 + λ(cid:1). Hence, we have some unit vector (cid:126)v (cid:0)AT S−2 x A + λI(cid:1) ≥ log(cid:0) n 2 + λ. Thus,(cid:88) (A(cid:126)v)2 i s((cid:126)x(k))2 i ≥ n 2 . i (A(cid:126)v)2 i s((cid:126)x(k))2 i Therefore there is some i such that (cid:104)(cid:126)ai, (cid:126)v(cid:105)2 ≥ s((cid:126)x(k))2 Lemma 30. With constant probability, the algorithm ends in 1024n log( nR i /2 and hence s((cid:126)x(k))i ≤ .  ) iterations. 4 ≥ 1 2 . Since (cid:126)ai and (cid:126)v are unit vectors, we have 1 ≥ Proof. Theorem 26 shows that for all k Ep(cid:126)e((cid:126)τ (k+1),(cid:126)x(k+1))((cid:126)x(k+1)) ≥ p(cid:126)e((cid:126)τ (k),(cid:126)x(k))((cid:126)x(k)) − 1 1011 + 9β 1011 (6.20) where β = 1 for the case of adding a constraint and β = 0 for the case of removing a constraint. Now, for all t consider the random variable Xt = p(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t)) − 4.5m(t) 1011 − 3.5t 1011 where m(t) is the number of constraints in iteration t of the algorithm. Then, since m(t+1) = m(t) − 1 + 2β, (6.20) shows that EXt+1 ≥ p(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t)) − 1 1011 + 9β 1011 − 4.5m(t+1) 1011 − 3.5(t + 1) − 3.5 1011 = Xt. 1011 9β 1011 − 4.5(−1 + 2β) 1011 = Xt − 1 1011 + Hence, it is a sub-martingale. Let τ be the iteration the algorithm throws out error or outputs P (k). Optional stopping theorem shows that EXmin(τ,t) ≥ EX0. (6.21) 0 A + λI(cid:1) + (cid:13)(cid:13)(cid:126)0(cid:13)(cid:13)2 2 λ 2 log det(cid:0)AT S−2 (cid:18) 1 (cid:19) 1 2 caR2 Using the diameter of P (0) is nR, we have √ i∈[m(0)] √ ≥ −cem(0) log( p(cid:126)0((cid:126)0) = − (cid:88) n + cem(0)(cid:17) ≥ −(cid:16) X0 ≥ −(cid:16) cd ce log si((cid:126)0) + n nR) + 2 √ log( log nR). Using ce = 6 ln(17nR/) , cd = 1 n + cem(0)(cid:17) 1012 and m(0) = 2n, we have √ log( nR) − 100n. √ ≥ −n log( nR) − 4.5m(0) 1011 4We have made no effort on improving this constant and we believe it can be improved to less than 300 using techniques in [5, 6]. 35 Therefore, (6.21) shows that for all t we have − n(log(nR) + 100) ≤ EXmin(τ,t) = pE(cid:2)Xmin(τ,t)τ < t(cid:3) + (1 − p)E(cid:2)Xmin(τ,t)τ ≥ t(cid:3) (6.22) where p def= P(τ < t). Note that E(cid:2)Xmin(τ,t)τ ≥ t(cid:3) ≤ E ≤ E (cid:104) (cid:104) p(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t))τ ≥ t p(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t))τ ≥ t (cid:105) − 4.5m(t) (cid:105) − 3.5t 1011 − 3.5t 1011 . 1011 . Furthermore, by Lemma 29 we know that when p(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t)) ≥ n log( n that is too small and the algorithm terminates. Hence, we have ca ) + 6n ca E(cid:2)Xmin(τ,t)τ ≥ t(cid:3) ≤ n log( n ca ) + 6n ca − 3.5t 1011 . , there is a slack The proof of Lemma 21 shows that the function value does not change by more than 1 in one iteration by changing (cid:126)x and can change by at most mce log( 3nR  ) by changing τ . Since by Lemma 22 we know that m ≤ 1 + 2n throughout the execution of the algorithm. Therefore, we have 6 ln(17nR/) , we have that p(cid:126)e((cid:126)x) ≤ n log( n ca ) + 7n ca and ce = cd ca E(cid:2)Xmin(τ,t)τ ≤ t(cid:3) ≤ Eτ <tp(cid:126)e((cid:126)τ (t),(cid:126)x(t))((cid:126)x(t)) ≤ n log( n ca ) + 7n ca . Therefore, (6.22) shows that −n(log(nR) + 100) ≤ n log + 7n ca − (1 − p) 3.5t 1011 . Hence, we have Thus, we have (1 − p) 3.5t 1011 ≤ n log ≤ n log = n log P(τ < t) = p ≥ 1 − 1 t 1011n log (cid:19) 7n ca 7n ca ca (cid:18) n (cid:18) n (cid:19) (cid:19) (cid:18) Rn2 (cid:19) (cid:18) Rn2 (cid:18) ca ca ca + + n(log(nR) + 100) + + 100n + 8 · 1010n. (cid:18) n2R (cid:19) (cid:19) . + 1022n  Now, we gather all the result as follows: Theorem 31 (Our Cutting Plane Method). Let K ⊆ Rn be a non-empty set contained in a box of radius R, i.e. K ⊆ B∞(R). For any  ∈ (0, R) in expected time O(nSOΩ(/ √ n)(K) log(nR/) + n3 logO(1)(nR/)) our cutting plane method either outputs (cid:126)x ∈ K or finds a polytope P = {(cid:126)x : A(cid:126)x ≥ (cid:126)b} ⊇ K such that 36 nR, √ (a) (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ≤ 3 (cid:13)(cid:13)(cid:13)(cid:126)a1 +(cid:80)O(n) (cid:16)(cid:80)O(n) (cid:17)T 1 (cid:126)x − (cid:126)b1 ≤ , i=2 tiai (c) (cid:126)aT (d) (b) i=2 ti(cid:126)ai (cid:13)(cid:13)(cid:13)2 = O(cid:0)  (cid:126)x −(cid:80)O(n) R n log(R/)(cid:1), √ i=2 tibi ≤ O(n log(R/)) . 1. P has O(n) many constraints (i.e. A ∈ RO(n)×n and (cid:126)b ∈ RO(n)). 2. Each constraint of P is either an initial constraint from B∞(R) or of the form (cid:104)(cid:126)a, (cid:126)x(cid:105) ≥ b − δ where (cid:104)(cid:126)a, (cid:126)x(cid:105) ≥ b is a normalized hyperplane (i.e. (cid:13)(cid:13)(cid:126)a(cid:13)(cid:13)2 = 1) returned by the separation oracle (cid:16) √ (cid:17) . n and δ = Ω 3. The polytope P has small width with respect to some direction (cid:126)a1 given by one of the con- straints, i.e. max (cid:126)y∈P∩B∞(R) (cid:104)(cid:126)a1, (cid:126)y(cid:105) − min (cid:126)y∈P∩B∞(R) (cid:104)(cid:126)a1, (cid:126)y(cid:105) ≤ O (n ln(R/)) 4. Furthermore, the algorithm produces a proof of the fact above involving convex combination of the constraints, namely, non-negatives t2, ..., tO(n) and (cid:126)x ∈ P such that Proof. Our algorithm either finds (cid:126)x ∈ K or we have si((cid:126)x(k)) < . When si((cid:126)x(k)) < , we apply Lemma 28 to construct the polytope P and the linear combination(cid:80)O(n) i=2 ti(cid:126)ai. Notice that each iteration of our algorithm needs to solve constant number of linear systems and implements the sampling step to find (cid:126)∆(k) ∈ Rn s.t. E[(cid:126)∆(k)] = (cid:126)ψ((cid:126)x(k))− (cid:126)ψ((cid:126)x(k−1)). Theorem 33 shows how to do the sampling in O(1) many linear systems. Hence, in total, each iterations needs to solve O(1) many linear systems plus nearly linear work. To output the proof for (4), we use Lemma 28. Note that the linear systems the whole algorithm need to solve is of the form (AT S−2 x A + λI)−1(cid:126)x = (cid:126)y. (cid:21) T DA for the matrix A = [A I] and diagonal x A + λI can be written as A where the matrix AT S−2 matrix (cid:20) S−2 Note that Lemma 14 shows that(cid:13)(cid:13)(cid:0)S(k)(cid:1)−1 ((cid:126)s(k+1) − (cid:126)s(k))(cid:13)(cid:13)2 ≤ 1 systems we solved in the algorithm. Hence, we have (cid:13)(cid:13)(cid:0)D(k)(cid:1)−1 0 λI D = 0 . √ n) suffices. (see Def 1). Consequently, the total work O(nSOΩ(/ 10 for the kth and (k + 1)th linear 10 . In [76], they showed how to solve such sequence of systems in O(n2) amortized cost. Moreover, since our algorithm always changes the constraints by δ amount where δ = Ω( √ n ) an inexact separation oracle SOΩ(/ n)(K) log(nR/) + n3 logO(1)(nR/)). Note that as the running time holds with only constant probability, we can restart the algorithm whenever the running time is too large. from B∞(R) or of the form (cid:126)aT (cid:126)x ≥ (cid:126)aT (cid:126)x(k) − δ where (cid:126)aT (AT S−2 (cid:126)x(k)A + λI)−1(cid:126)a ca To prove (2), we note that from the algorithm description, we know the constraints are either (cid:115) δ = √ . ((cid:126)d(k+1) − (cid:126)d(k))(cid:13)(cid:13)2 ≤ 1 37 From the proof of Lemma 29, we know that if λmax(AT S−2 Hence, we have λmin((AT S−2 n . Since (cid:126)a is a unit vector, we have 2 , then there is si < . (cid:115) x A + λI)−1) ≤ 2 (cid:126)aT (AT S−2 (cid:126)x(k)A + λI)−1(cid:126)a ca x A + λI) ≥ n (cid:115) ≥ 2 nca . 7 Technical Tools In this section we provide stand-alone technical tools we use in our cutting plane method in Sec- tion 6. In Section 7.1 we show how to efficiently compute accurate estimates of changes in leverage scores using access to a linear system solver. In Section 7.2 we study what we call the “Stochastic Chasing (cid:126)0 Game” and show how to maintain that a vector is small in (cid:96)∞ norm by making small coordinate updates while the vector changes randomly in (cid:96)2. 7.1 Estimating Changes in Leverage Scores In previous sections, we needed to compute leverage scores accurately and efficiently for use in our cutting plane method. Note that the leverage score definition we used was √ ψ( (cid:126)w)i = (cid:126)1T i σ( (cid:126)w)i = (cid:126)1T i √ AT W(cid:126)1i √ W(cid:126)1i. √ WA(cid:0)AT WA + λI(cid:1)−1 WA(cid:0)AT WA(cid:1)−1 (cid:20) W 0 (cid:21) AT D = 0 λI . for some λ > 0 which is different from the standard definition T However, note that the matrix AT WA + λI can be written as A and diagonal matrix DA for the matrix A = [A I] and therefore computing ψ is essentially strictly easier than computing typical leverage scores. Consequently, we use the standard definition σ to simplify notation. In [99], Spielman and Srivastava observed that leverage scores can be written as the norm of certain vectors σ( (cid:126)w)i = (cid:13)(cid:13)(cid:13)√ WA(cid:0)AT WA(cid:1)−1 √ AT W(cid:126)1i (cid:13)(cid:13)(cid:13)2 2 and therefore leverage scores can be approximated efficiently using dimension reduction. Unfortu- nately, the error incurred by this approximation is too large to use inside the cutting point method. In this section, we show how to efficiently approximate the change of leverage score more accurately. In particular, we show how to approximate σ( (cid:126)w) − σ((cid:126)v) for any given (cid:126)w, (cid:126)v with (cid:13)(cid:13) log( (cid:126)w) − log((cid:126)v)(cid:13)(cid:13)2 (cid:28) 1. Our algorithm breaks σ( (cid:126)w)i − σ((cid:126)v)i into the sum of the norm of small vectors and then uses the Johnson-Lindenstrauss dimension reduction to approximate the norm of each vector separately. Our algorithm makes use of the following version of Johnson-Lindenstrauss. Lemma 32 ([1]). Let 0 ≤  ≤ 1 O(−2 log(m)) let Q be a k × n random matrix with each entry sampled from {− 1√ 2 and let (cid:126)x1, ..., (cid:126)xm ∈ Rn be arbitrary m points. For k = } uni- formly and independently. Then, E(cid:107)Q(cid:126)xi(cid:107)2 =(cid:13)(cid:13)(cid:126)xi (cid:13)(cid:13)2 for all i ∈ [m] and with high probability in m , 1√ k k we have that for all i ∈ [m] (1 − )(cid:13)(cid:13)(cid:126)xi (cid:13)(cid:13)2 ≤ (cid:107)Q(cid:126)xi(cid:107)2 ≤ (1 + )(cid:13)(cid:13)(cid:126)xi (cid:13)(cid:13)2 . 38 Input: A ∈ Rm×n, (cid:126)v, (cid:126)w ∈ Rm Algorithm 3:(cid:98)h = LeverageChange(A, (cid:126)v, (cid:126)w, , α) Given: (cid:13)(cid:13)V−1((cid:126)v − (cid:126)w)(cid:13)(cid:13)2 ≤ 1 Let di =(cid:13)(cid:13)Qd Let t = O(cid:0)log(−1)(cid:1). WA(cid:0)AT WA(cid:1)−1 AT (cid:126)1i Sample Qd ∈ RO(−2 log(m))×n as in Lemma 32. (cid:13)(cid:13)2 √ 2 for all i ∈ [n]. >0,  ∈ (0, 0.5). 10 and AT VA and AT WA are invertible. Sample Qf ∈ RO(−2 log(mt))×n as in Lemma 32. Pick positive integer u randomly such that Pr[u = i] = ( 1 for j ∈ {1, 2,··· , t} ∪ {t + u} do 2 )i. if j is even then √ Let f (j) VA(cid:0)AT VA(cid:1)−1(cid:16) AT (V − W) A(cid:0)AT VA(cid:1)−1(cid:17) j ∆+A(AT VA)−1(AT (V − W) A(cid:0)AT VA(cid:1)−1) Let ∆+ def= (V − W)+, i.e. the matrix V − W with negative entries set to 0. Let ∆− def= (W − V)+, i.e. the matrix W − V with negative entries set to 0. j−1 Let α(j) 2 AT (cid:126)1i 2. Let β(j) 2. Let f (j) √ √ ∆−A(AT VA)−1(AT (V − W)A(AT VA)−1) (cid:13)(cid:13)2 (cid:13)(cid:13)2 (cid:13)(cid:13)2 j−1 2 AT (cid:126)1i 2 AT (cid:126)1i 2. . i − β(j) i else end i =(cid:13)(cid:13)Qf i =(cid:13)(cid:13)Qf i =(cid:13)(cid:13)Qf +(cid:80)t i = α(j) end Let fi = 2u f (t+u) Output: hi = (wi − vi) di + vi fi. for all i ∈ [m] f (j) i j=1 . i >0 be such that α def= (cid:13)(cid:13)V−1((cid:126)v − (cid:126)w)(cid:13)(cid:13)2 ≤ 1 Theorem 33. Let A ∈ Rm×n and (cid:126)v, (cid:126)w ∈ Rm AT VA and AT WA are invertible. For any  ∈ (0, 0.5), Algorithm 3 generates a random variable(cid:98)h such that Eh = σ( (cid:126)w)− σ((cid:126)v) and with high probability in m, we have (cid:107)(cid:98)h− (σ( (cid:126)w) − σ((cid:126)v))(cid:107)2 ≤ O (α). Furthermore, the expected running time is (cid:101)O((nnz(A) + LO)/2) where LO is the amount of time needed to apply(cid:0)AT VA(cid:1)−1 and(cid:0)AT WA(cid:1)−1 to a vector. this would take time (cid:101)O((t + u)2 log(mt)(nnz(A) + LO)). However, we can reuse the computation in computing high powers of j to only take time (cid:101)O((t + u) log(mt)(nnz(A) + LO)). Now since E[u] Proof. First we bound the running time. To compute di, f (j) , we simply perform matrix multiplications from the left and then consider the dot products with each of the rows of A. Naively 10 and both , α(j) , β(j) i i i is constant we see that the total running time is as desired. It only remains to prove the desired properties of h. First we note that we can re-write leverage score differences using σ( (cid:126)w)i − σ((cid:126)v)i = (wi − vi) Consequently, for all i ∈ [m], if we let + vi A (cid:104) A(cid:0)AT WA(cid:1)−1 (cid:104) AT(cid:105) i A(cid:0)AT WA(cid:1)−1 (cid:104)(cid:0)AT WA(cid:1)−1 −(cid:0)AT VA(cid:1)−1(cid:105) AT (cid:126)1i, ii di fi def= (cid:126)1T def= (cid:126)1T i A AT (cid:126)1i. (cid:16)(cid:0)AT WA(cid:1)−1 −(cid:0)AT VA(cid:1)−1(cid:17) AT(cid:105) then σ( (cid:126)w)i − σ((cid:126)v)i = (wi − vi)di + (vi)fi . 39 ii . (7.1) (cid:13)(cid:13)2 We show that di approximates d and fi approximate f well enough to satisfy the statements in the Theorem. 2. Consequently, Lemma 32 shows that E[ di] = di and that with high probability in m we have (1−)di ≤ di ≤ (1+)di for all i ∈ [m]. Therefore, with high probability in m, we have First we bound the quality of di. Note that di =(cid:13)(cid:13)√ (wi − vi)2(cid:16)(cid:98)di − di (cid:13)(cid:13) ( (cid:126)w − (cid:126)v)(cid:98)d − ( (cid:126)w − (cid:126)v) (cid:126)d(cid:13)(cid:13)2 (cid:18) σ( (cid:126)w)i (cid:88) = 2 (cid:88) WA(cid:0)AT WA(cid:1)−1 AT (cid:126)1i (cid:17)2 ≤ 2 (cid:88) (cid:19)2 ≤ 22 (cid:88) (cid:18) wi − vi (wi − vi)2d2 (cid:19)2 Next we show how to estimate f . Let X def=(cid:0)AT VA(cid:1)−1/2 AT (V − W) A(cid:0)AT VA(cid:1)−1/2. By the i∈[m] i∈[m] (wi − vi)2 i∈[m] i∈[m] 2 = (cid:126)wi vi . i 2 V ≺ V − W ≺ 1 2 V and therefore − 1 2 I ≺ X ≺ 1 2 I. Consequently we assumption on α we know − 1 have that and therefore fi = (cid:126)1T i A ∞(cid:88) j=1 f (j) i f (j) i = (cid:126)1T = (cid:126)1T For odd j, using our definition of ∆+ and ∆− we have that = f (j) i where f (j) i AT (cid:126)1i . Furthermore, using the definition of X we have that for even j . −1(cid:0)AT VA(cid:1)−1/2 Xj(cid:0)AT VA(cid:1)−1/2  AT (cid:126)1i Xj(cid:0)AT VA(cid:1)−1/2 (cid:0)AT WA(cid:1)−1 = (cid:0)AT VA(cid:1)−1/2 ∞(cid:88) (cid:0)AT VA(cid:1)−1/2 = (I − X) j=0  ∞(cid:88) j=0 (cid:0)AT VA(cid:1)−1/2 2 def= (cid:126)1T AT (cid:126)1i Xj(cid:0)AT VA(cid:1)−1/2 −(cid:0)AT VA(cid:1)−1 i A(cid:0)AT VA(cid:1)−1/2 (cid:13)(cid:13)(cid:13)2 AT (V − W) A(cid:0)AT VA(cid:1)−1(cid:17) j AT (V − W) A(cid:0)AT VA(cid:1)−1(cid:17) j Xj(cid:0)AT VA(cid:1)−1/2 (cid:17) j−1 2 (cid:0)AT VA(cid:1)−1 AT (V − W) A(cid:0)AT VA(cid:1)−1(cid:17) j−1 AT (V − W) A AT (cid:126)1i = = = j (cid:13)(cid:13)(cid:13)X 2(cid:0)AT VA(cid:1)−1/2 (cid:13)(cid:13)(cid:13)(cid:13)(cid:0)AT VA(cid:1)−1/2(cid:16) (cid:13)(cid:13)(cid:13)(cid:13)√ VA(cid:0)AT VA(cid:1)−1(cid:16) i A(cid:0)AT VA(cid:1)−1/2 (cid:16)(cid:0)AT VA(cid:1)−1 ×A(cid:0)AT VA(cid:1)−1(cid:16) i A (cid:13)(cid:13)(cid:13)(cid:13)2 2 2 AT (cid:126)1i (cid:13)(cid:13)(cid:13)(cid:13)2 2 2 AT (cid:126)1i AT (V − W) 2 AT (cid:126)1i = α(j) i − β(j) i 40 where (cid:13)(cid:13)(cid:13)(cid:13)√ (cid:13)(cid:13)(cid:13)(cid:13)√ α(j) i β(j) i def= def= ∆+A(cid:0)AT VA(cid:1)−1(cid:16) ∆−A(cid:0)AT VA(cid:1)−1(cid:16)  t(cid:88) E fi = E f (j) i + AT (W − V) A(cid:0)AT VA(cid:1)−1(cid:17) j−1 AT (W − V) A(cid:0)AT VA(cid:1)−1(cid:17) j−1 ∞(cid:88) ∞(cid:88)  = f (j) i = fi f (t+u) i 2u 2u j=1 u=1 j=1 (cid:13)(cid:13)(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:13)(cid:13)2 2 2 , . 2 AT (cid:126)1i 2 AT (cid:126)1i Consequently, by Lemma 32 and the construction, we see that To bound the variance of f , let X = (cid:0)AT VA(cid:1)−1/2 AT W − V A(cid:0)AT VA(cid:1)−1/2. Note that and therefore Eh = σ( (cid:126)w) − σ((cid:126)v) as desired. All that remains is to bound the variance of fi. 4 I (cid:22) −X (cid:22) X (cid:22) X (cid:22) 1 − 1 4 I and consequently for all j i A(cid:0)AT VA(cid:1)−1/2 Xj(cid:0)AT VA(cid:1)−1/2 i A(cid:0)AT VA(cid:1)−1/2 X(cid:0)AT VA(cid:1)−1/2 (cid:126)1T AT (cid:126)1i AT (cid:126)1i g(j) i def= (cid:126)1T ≤ 1 4j−1 1 vi4j−1 def= (cid:12)(cid:12)(cid:12) wi−vi vi (cid:12)(cid:12)(cid:12). Using √ (cid:126)1T i Pv∆Pv(cid:126)1i √ where Pv = that 0 (cid:22) Pv (cid:22) I, we have that for all j VA(cid:0)AT VA(cid:1)−1/2 AT (cid:17)2 (cid:16) m(cid:88) (4j−1)2 vig(j) i i=1 and thus (cid:13)(cid:13)V(cid:126)g(j)(cid:13)(cid:13)2 ≤ 4α (cid:12)(cid:12)(cid:12)α(j) (cid:12)(cid:12)(cid:12) ≤ g(j) (cid:12)(cid:12)(cid:12)β(j) (cid:12)(cid:12)(cid:12) ≤ g(j) (cid:13)(cid:13)V f (j) − V (cid:126)f (j)(cid:13)(cid:13)2 and i i i i 2 = V and ∆ is a diagonal matrix with ∆ii = i Pv∆Pv(cid:126)1i = ≤ Tr (Pv∆∆Pv) = Tr (∆PvPv∆) = Tr (Pv∆PvPv∆Pv) (cid:16)(cid:126)1T m(cid:88) ≤ Tr(cid:0)∆2(cid:1) = i=1 (cid:17)2 (cid:18) wi − vi m(cid:88) i=1 vi (cid:19)2 ≤ α2 (cid:16) β(j) i − β(j) i (cid:17)2 i i v2 i ≤ 2 (cid:17)2 (cid:16) f (j) (cid:88) i − f (j) (cid:16) (cid:17)2 (cid:88) i − α(j) (cid:18)(cid:16) (cid:16) (cid:17)2 α(j) ≤ 22(cid:88) (cid:17)2 ≤ 2α22 ≤ 22(cid:88) α(j) i (cid:16) vig(j) v2 i v2 i + 2 + i i i i β(j) i (4j−1)2 . (cid:88) (cid:17)2(cid:19) i v2 i i 41 4j . Furthermore, since ∆+ (cid:22) W − V and ∆− (cid:22) W − V we have that . Consequently, by Lemma 32 again, we have Putting this all together we have that t(cid:88) (cid:13)(cid:13)V f − V (cid:126)f(cid:13)(cid:13)2 ≤(cid:13)(cid:13)2uV f (t+u) + t(cid:88) ≤ 2u(cid:13)(cid:13)V f (t+u)(cid:13)(cid:13)2 + t(cid:88) (cid:16) (cid:17) ≤ 2u 4α √ 2α 4j−1 + j=1 j=1 4t+u + j=1 α 4t α + . = O V f (j) − ∞(cid:88) V (cid:126)f (j)(cid:13)(cid:13)2 (cid:13)(cid:13)V f (j) − V (cid:126)f (j)(cid:13)(cid:13)2 + ∞(cid:88) j=1 ∞(cid:88) (cid:13)(cid:13)V (cid:126)f (j)(cid:13)(cid:13)2 j=t+1 4α 4j j=t+1 Consequently, since t = O(log(−1)) we have the desired result. 7.2 The Stochastic Chasing (cid:126)0 Game To avoid computing leverage scores exactly, in Section 7.1 we showed how to estimate the difference of leverage scores and use these to update the leverage scores. However, if we only applied this technique the error of leverage scores would accumulate in the algorithm and we need to fix it. Naturally, one may wish to use dimension reduction to compute a multiplicative approximation to the leverage scores and update our computed value if the error is too large. However, this strategy would fail if there are too many rows with inaccurate leverage scores in the same iteration. In this case, we would change the central point too much that we are not able to recover. In this section, we present this update problem in a general form that we call Stochastic Chasing 0 game and provide an effective strategy for playing this game. The Stochastic chasing 0 game is as follows. There is a player, a stochastic adversary, and a point (cid:126)x ∈ Rm. The goal of the player is to keep the point close to (cid:126)0 ∈ Rm in (cid:96)∞ norm and the goal of the stochastic adversary is to move (cid:126)x away from (cid:126)0. The game proceeds for an infinite number of iterations where in each iteration the stochastic adversary moves the current point (cid:126)x(k) ∈ Rm to some new point (cid:126)x(k) + (cid:126)∆(k) ∈ Rm and the player needs to respond. The stochastic adversary cannot move the (cid:126)∆(k) arbitrarily, instead he is only allowed to choose a probability distribution D(k) and 2 ≤ c for some fixed c and all (cid:126)∆ ∈ D(k). The player does not know (cid:126)x(k) or the distribution D(k) or the move (cid:126)∆(k) of the stochastic adversary. All the player knows is some (cid:126)y(k) ∈ Rn that is close to (cid:126)x(k) in (cid:96)∞ norm. With this information, the player is allowed to choose one coordinate i and set x(k+1) to be zero and for other j, we have x(k+1) sample (cid:126)∆(k) from it. Furthermore, it is required that ED(k) (cid:126)∆ = (cid:126)0 and(cid:13)(cid:13)(cid:126)∆(cid:13)(cid:13)2 = x(k) . i j + ∆(k) j j The question we would like to address is, what strategy the player should choose to keep (cid:126)x(k) close to (cid:126)0 in (cid:96)∞ norm? We show that there is a trivial strategy that performs well: simply pick the 42 largest coordinate and set it to 0. Algorithm 4: Stochastic chasing (cid:126)0 game Constant: c > 0, R > 0. Let (cid:126)x(1) = (cid:126)0 ∈ Rm. for k = 1 to ∞ do Stochastic Adversary: Pick D(k) such that ED(k) (cid:126)∆ = (cid:126)0 and(cid:13)(cid:13)(cid:126)∆(cid:13)(cid:13)2 ≤ c all (cid:126)∆ ∈ D(k). Stochastic Adversary: Pick (cid:126)y(k) ∈ Rm such that(cid:13)(cid:13)(cid:126)y(k) − (cid:126)x(k)(cid:13)(cid:13)∞ ≤ R. Player: Pick a coordinate i(k) using only (cid:126)y(k). Sample (cid:126)∆(k) from D(k). Set x(k+1) i(k) = 0 and x(k+1) j + ∆(k) = x(k) j j for all j (cid:54)= i. end Theorem 34. Using the strategy i(k) = arg maxi (cid:12)(cid:12)(cid:12)y(k) (cid:12)(cid:12)(cid:12), with probability at least 1 − p, we have (cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13)∞ ≤ 2(c + R) log(cid:0)4mk2/p(cid:1) i eαxi +(cid:80) Proof. Consider the potential function Φ((cid:126)x) = (cid:80) for all k in the Stochastic Chasing (cid:126)0 Game. i e−αxi where α is to be determined. i Now for all x we know that ex ≤ 1 + x + x2 2 ex and therefore for all δ ≤ c, x and α, we have  e−αx(k) i ∆i  . e−αx(k) i ∆2 i eαx+αδ ≤ eαx + αδeαx + α2δ2eαx+αc . 1 2 i ∆i − (cid:88) i∈[m] eαx(k) (cid:13)(cid:13) (cid:126)∆ Consequently, E (cid:126)∆∈D(k)Φ((cid:126)x(k) + (cid:126)∆) ≤ Φ((cid:126)x(k)) + αE (cid:126)∆∈D(k) (cid:88) (cid:88) (cid:13)(cid:13)∞E (cid:126)∆∈D(k) (cid:16)(cid:80) Since ED(k) (cid:126)∆ = (cid:126)0 and(cid:13)(cid:13)(cid:126)∆(cid:13)(cid:13)2 ≤ c, we have E (cid:126)∆∈D(k) i ∆i −(cid:80) (cid:33)(cid:18) (cid:32)(cid:88) (cid:33) ≤ E (cid:126)∆∈D(k) (cid:18) (cid:17) (cid:32)(cid:88) (cid:88) e−αx(k) E (cid:126)∆∈D(k) i eαx(k) eαx(k) i ∆2 eαx(k) i ∆2 eαx(k) ≤ c2 i ∆2 i α2 2 i∈[m] (cid:16) max i + ∆2 i eα i + max + i i i i i maxi eαx(k) i , maxi e−αx(k) i , we then have Letting η(k) = max (cid:88) i∈[m] i + i∈[m] i e−αx(k) (cid:19) eαx(k) e−αx(k) i i max (cid:17) . i ∆i = 0 and i + max i e−αx(k) i (cid:19) (cid:12)(cid:12)(cid:12)y(k) E (cid:126)∆∈D(k)Φ((cid:126)x(k) + (cid:126)∆) ≤ Φ((cid:126)x(k)) + α2eαcc2η(k). (cid:12)(cid:12)(cid:12) and(cid:13)(cid:13)(cid:126)y(k) − (cid:126)x(k)(cid:13)(cid:13)∞ ≤ R, the player setting x(k+1) i(k) = 0 decreases Φ by Since i(k) = arg maxi at least e−α(R+c)η(k). Hence, we have i E (cid:126)∆∈D(k)Φ((cid:126)x(k+1)) ≤ Φ((cid:126)x(k)) + α2eαcc2η(k) − e−αRη(k). 43 Picking α = 1 have that 2(c+R) , we have e2α(c+R)(α(c + R))2 ≤ 1 and hence α2eαcc2 ≤ e−α(R+c). Therefore, we E (cid:126)∆∈D(k)Φ((cid:126)x(k+1)) ≤ EΦ((cid:126)x(k)) ≤ ... ≤ Φ((cid:126)x(1)) = 2m . Consequently, by Markov’s inequality we have that Pr[Φ((cid:126)x(k)) ≥ λk] ≤ 2m since clearly Φ((cid:126)x) ≥ eα(cid:107)(cid:126)x(cid:107)∞ we have that Pr[(cid:107)(cid:126)x(k)(cid:107)∞ ≥ log(λk)/α] ≤ 2m λk = 4mk2 p and taking a union bound over all k, we have that λk λk for any λk. Furthermore, for all k. Choosing for all k with probability at least (cid:13)(cid:13)(cid:126)x(k)(cid:13)(cid:13)∞ ≤ 2(c + R) log(cid:0)4mk2/p(cid:1) ∞(cid:88) ∞(cid:88) 1 − i=1 = 1 − 2m λk p 2k2 ≥ 1 − p . k=1 44 Part II A User’s Guide to Cutting Plane Methods 8 Introduction Cutting plane methods have long been employed to obtain polynomial time algorithms for solving optimization problems. However, for many problems cutting plane methods are often regarded as inefficient both in theory and in practice. Here, in Part II we provide several techniques for applying cutting plane methods efficiently. Moreover, we illustrate the efficacy and versatility of these techniques by applying them to achieve improved running times for solving multiple problems including semidefinite programming, matroid intersection, and submodular flow. We hope these results revive interest in ellipsoid and cutting plane methods. We believe these results demonstrate how cutting plan methods are often useful not just for showing that a problem is solvable in polynomial time, but in many yield substantial running time improvements. We stress that while some results in Part II are problem-specific, the techniques introduced here are quite general and are applicable to a wide range of problems. In the remainder of this introduction we survey the key techniques we use to apply our cutting plane method (Section 8.1) and the key results we obtain on improving the running time for solving various optimization problems (Section 8.2). We conclude in Section 8.3 by providing an overview of where to find additional technical result in Part II. 8.1 Techniques Although cutting plane methods are typically introduced as algorithms for finding a point in a convex set (as we did with the feasibility problem in Part I), this is often not the easiest way to apply the methods. Moreover, improperly applying results on the feasibility problem to solve convex optimization problems can lead to vastly sub-optimal running times. Our central goal, here, in Part II is to provide tools that allow cutting plane methods to be efficiently applied to solve complex optimization problems. Some of these tools are new and some are extensions of previously known techniques. Here we briefly survey the techniques we cover in Section 10 and Section 11. Technique 0: From Feasibility to Optimization In Section 10.1, we explain how to use our cutting plane method to solve convex optimization problems using an approximate subgradient oracle. Our result is based on a result of Nemirovski [85] in which he showed how to use a cutting plane method to solve convex optimization problems without smoothness assumptions on the function and with minimal assumptions on the size of the function’s domain. We generalize his proof to accommodate for an approximate separation oracle, an extension which is essential for our applications. We use this result as the starting point for two new techniques we discuss below. Technique 1: Dimension Reduction through Duality In Section 10.2, we discuss how cutting plane methods can be applied to obtain both primal and dual solutions to convex optimization problems. Moreover, we show how this can be achieved while only applying the cutting plane method in the space, primal or dual, which has a fewer number of variables. Thus we show how to use duality to improve the convergence of cutting plane methods while still solving the original problem. 45 To illustrate this idea consider the following very simple linear program (LP) n(cid:88) i=1 xi≥0,(cid:80) xi=1 min wixi where (cid:126)x ∈ Rn and (cid:126)w ∈ Rn. Although this LP has n variables, it should to be easy to solve purely on the grounds that it only has one equality constraint and thus dual linear program is simply max y≤wi∀i y , i.e. a LP with only one variable. Consequently, we can apply our cutting plane method to solve it efficiently. However, while this simple example demonstrates how we can use duality to decrease dimen- sions, it is not always obvious how to recover the optimal primal solution x variable given the optimal dual solution y. Indeed, for many problems their dual is significantly simpler than itself (primal), so some work is required to show that working in the space suffices to require a primal solution. One such recent example of this approach proving successful is a recent linear programming result [75]. In this result, the authors show how to take advantage of this observation and get a faster LP solver and maximum flow algorithm. It is interesting to study how far this technique can extend, that is, in what settings can one recover the solution to a more difficult dual problem from the solution to its easier primal problem? There is in fact another precedent for such an approach. Grotschel, Lov´asz and Schrijver[50] showed how to obtain the primal solution for linear program by using a cutting plane method to solve the linear program exactly. This is based on the observation that cutting plane methods are able to find the active constraints of the optimal solution and hence one can take dual of the linear program to get the dual solution. This idea was further extended in [69] which also observed that cutting plane methods are incrementally building up a LP relaxation of the optimization problem. Hence, one can find a dual solution by taking the dual of that relaxation. In Section 10.2, we provide a fairly general technique to recover a dual optimal solution from an approximately optimal primal solution. Unfortunately, the performance of this technique seems quite problem-dependent. We therefore only analyze this technique for semidefinite programming (SDP), a classic and popular convex optimization problem. As a result, we obtain a faster SDP solver in both the primal and dual formulations of the problem. Technique 2: Using Optimization Oracles Directly In the seminal works of Grotschel, Lov´asz, Schrijver and independently Karp and Papadimitriou [49, 64], they showed the equivalence between optimization oracles and separation oracles, and gave a general method to construct a separation oracle for a convex set given an optimization oracle for that set, that is an oracle for minimizing linear functionals over the set. This seminal result led to the first weakly polynomial time algorithm for many algorithms such as submodular function minimization. Since then, this idea has been used extensively in various settings [62, 16, 17, 23]. Unfortunately, while this equivalence of separation and optimization is a beautiful and powerful tool for polynomial time solvability of problems, in many case it may lead to inefficient algorithms. In order to use this reduction to get a separation oracle, the optimization oracle may need to be called multiple times – essentially the number of times needed to run a cutting plane method and hence may be detrimental to obtaining small asymptotic running times. Therefore, it is an interesting question of whether there is a way of using an optimization oracle more directly. 46 In Section 11 we provide a partial answer to this question for the case of a broad class of problems, that we call the intersection problem. For these problems we demonstrate how to achieve running time improvements by using optimization oracles directly. The problem we consider is as follows. We wish to solve the problem for some cost vector (cid:126)c ∈ Rn and convex set K. We assume that the convex set K can be decomposed as K = K1 ∩ K2 such that max(cid:126)x∈K1 (cid:104)(cid:126)c, (cid:126)x(cid:105) and max(cid:126)x∈K2 (cid:104)(cid:126)c, (cid:126)x(cid:105) can each be solved efficiently. Our goal is to obtain a running time for this problem comparable to that of minimizing K given only a separation oracle for it. We show that by considering a carefully regularized variant, we obtain a problem such that optimization oracles for K1 and K2 immediately yield a separation oracle for this regularized problem. By analyzing the regularizer and bounding the domains of the problem we are able to show that this allows us to efficiently compute highly accurate solutions to the intersection problem by applying our cutting plane method once. In other words, we do not need to use a complicated iterative scheme or directly invoke the equivalence between separation and optimization and thereby save O(poly(n)) factors in our running times. We note that this intersection problem can be viewed as a generalization of the matroid in- tersection problem and in Section 11.2, we show our reduction gives a faster algorithm in certain parameter regimes. As another example, in Section 11.3 we show our reduction gives a substantial polynomial improvement for the submodular flow problem. Furthermore, in Section 11.4 we show how our techniques allow us to minimize a linear function over the intersection of a convex set and an affine subspace in a number of iterations that depends only on the co-dimension of the affine space. 8.2 Applications Our main goal in Part II is to provide general techniques for efficiently using cutting plane methods for various problems. Hence, in Part II we use minimally problem-specific techniques to achieve the best possible running time. However, we also demonstrate the efficacy of our approach by showing how techniques improve upon the previous best known running times for solve several classic problems in combinatorial and continuous optimization. Here we provide a brief overview of these applications, previous work on these problems, and our results. In order to avoid deviating from our main discussion, our coverage of previous methods and techniques is brief. Given the large body of prior works on SDP, matroid intersection and submod- ular flow, it would be impossible to have an in-depth discussion on all of them. Therefore, this section focuses on running time comparisons and explanations of relevant preivous techniques. Semidefinite Programming In Section 10.2 we consider the classic semidefinite programming (SDP) problem: n(cid:88) i=1 C • X s.t. Ai • X = bi (primal) max X(cid:23)0 (cid:126)bT (cid:126)y s.t. min (cid:126)y yiAi (cid:23) C (dual) where X, C, Ai are m × m symmetric matrices, (cid:126)b, (cid:126)y ∈ Rn, and A • B def= Tr(AT B). For many problems, n (cid:28) m2 and hence the dual problem has fewer variables than the primal. There are many results and applications of SDP; see [106, 101, 83] for a survey on this topic. Since our focus is on polynomial time algorithms, we do not discuss pseudo-polynomial algorithms such as the spectral bundle method [51], multiplicative weight update methods [8, 9, 61, 3], etc. 47 Authors Nesterov, Nemirovsky[89] Anstreicher [7] Krishnan, Mitchell [70] This paper Years 1992 2000 2003 2015 √ Running times n(nmω + nω−1m2)) O( O((mn)1/4(nmω + nω−1m2)) O(m(nω + mω + S)) (dual SDP) O(m(n2 + mω + S)) Table 8: Previous algorithms for solving a n × n SDP with m constraints and S non-zeros entries Currently, there are two competing approaches for solving SDP problems, namely interior point methods (IPM) and cutting plane methods. Typically, IPMs require fewer iterations than the cut- ting plane methods, however each iteration of these methods is more complicated and possibly more computationally expensive. For SDP problems, interior point methods require the computations of i=1 yiAi) whereas cutting plane methods usually only the Hessian of the function − log det (C −(cid:80)n need to compute minimum eigenvectors of the slack matrix C −(cid:80)n i=1 yiAi. In [7], Anstreicher provided the current fastest IPM for solving the dual SDP problem using a method based on the volumetric barrier function. This method takes O((mn)1/4) iterations and each iteration is as cheap as usual IPMs. For general matrices C, X, Ai, each iteration takes O(nmω + nω−1m2) time where ω is the fast matrix multiplication exponent. If the constraint matrices Ai are rank one matrices, the iteration cost can be improved to O(mω + nm2 + n2m) [71]. If the matrices are sparse, then [40, 84] show how to use matrix completion inside the IPM. However, the running time depends on the extended sparsity patterns which can be much larger than the total number of non-zeros. O(mω + S) time, where S = (cid:80)n not too dense, i.e. (cid:80)n In [70], Krishnan and Mitchell observed that the separation oracle for dual SDP takes only i=1 nnz(Ai) be the total number of non-zeros in the constant matrix. Hence, the cutting plane method by [105] gives a faster algorithm for SDP for many regimes. For ω = 2.38, the cutting plane method is faster when Ai is not rank 1 and the problem is i=1 nnz(Ai) < n0.63m2.25. While there are previous methods for using cutting plane methods to obtain primal solutions[69] , to the best of our knowledge, there are no worst case running time analysis for these techniques. In Section 10.2, show how to alleviate this issue. We provide an improved algorithm for finding the dual solution and prove carefully how to obtain a comparable primal solution as well. See Figure 9.1 for a summary of the algorithms for SDP and their running times. Matroid Intersection In Section 11.2 we show how our optimization oracle technique can be used to improve upon the previous best known running times for matroid intersection. Matroid intersection is one of the most fundamental problems in combinatorial optimization. The first algorithm for matroid intersection is due to the seminal paper by Edmonds [26]. In Figures 9.2 and 9.3 we provide a summary of the previous algorithms for unweighted and weighted matroid intersection as well as the new running times we obtain in this paper. While there is no total ordering on the running times of these algorithms due to the different dependence on various parameters, we would like to point out that our algorithms outperform the previous ones in regimes where r is close to n and/or the oracle query costs are relatively expensive. In particular, in terms of oracle query complexity our algorithms are the first to achieve the quadratic bounds of O(n2) and O(nr) for independence and rank oracles. We hope our work will revive the interest in the problem of which progress has been mostly stagnated for the past 20-30 years. 48 Authors Edmonds [26] Aigner, Dowling [2] Tomizawa, Iri [102] Lawler [72] Edmonds [28] Cunningham [21] This paper Years 1968 1971 1974 1975 1979 1986 2015 Running times not stated O(nr2Tind) not stated O(nr2Tind) not stated O(nr1.5Tind) O(n2 log nTind + n3 logO(1) n) O(nr log2 nTrank + n3 logO(1) n) Table 9: Previous algorithms for (unweighted) matroid intersection. Here n is the size of the ground set, r = max{r1, r2} is the maximum rank of the two matroids, Tind is the time needed to check if a set is independent (independence oracle), and Trank is the time needed to compute the rank of a given set (rank oracle). Authors Edmonds [26] Tomizawa, Iri [102] Lawler [72] Edmonds [28] Frank [33] Orlin, Ahuja [91] Brezovec, Cornu´ejols, Glover[14] Fujishige, Zhang [39] Shigeno, Iwata [96] This paper Years 1968 1974 1975 1979 1981 1983 1986 1995 1995 2015 Running times not stated not stated O(nr2Tind + nr3) O(n2r(Tcircuit + n)) not stated not stated O(nr(Tcircuit + r + log n)) O(n2r0.5 log rM · Tind) O((n + Tcircuit)nr0.5 log rM ) O((n2 log nTind + n3 logO(1) n) log nM ) O((nr log2 nTrank + n3 logO(1) n) log nM ) Table 10: Previous algorithms for weighted matroid intersection. In additions to the notations used in the unweighted table, Tcircuit is the time needed to find a fundamental circuit and M is the bit complexity of the weights. 49 Minimum-Cost Submodular Flow In Section 11.3 we show how our optimization oracle technique can be used to improve upon the previous best known running times for (Minimum-cost) Submodular Flow. Submodular flow is a very general problem in combinatorial optimization which generalizes many problems such as minimum cost flow, the graph orientation, polymatroid intersection, directed cut covering [37]. In Figure 9.4 we provide an overview of the previous algorithms for submodular flow as well as the new running times we obtain in this paper. Many of the running times are in terms of a parameter h, which is the time required for com- puting an “exchange capacity”. To the best of our knowledge, the most efficient way of computing an exchange capacity is to solve an instance of submodular minimization which previously took time O(n4EO + n5) (and now takes O(n2EO + n3) time using our result in Part III). Readers may wish to substitute h = O(n2EO + n3) when reading the table. The previous fastest weakly polynomial algorithms for submodular flow are by [59, 30, 32], which take time O(n6EO + n7) and O(mn5 log nU · EO), assuming h = O(n2EO + n3). Our algorithm for submodular flow has a running time of O(n2EO + n3), which is significantly faster by roughly a factor of O(n4). For strongly polynomial algorithms, our results do not yield a speedup but we remark that our faster strongly polynomial algorithm for submodular minimization in Part III improves the previous algorithms by a factor of O(n2) as a corollary (because h requires solving an instance of submodular minimization). 8.3 Overview After providing covering some preliminaries on convex analysis in Section 9 we split the remain- der of Part II into Section 10 and Section 11. In Section 10 we cover our algorithm for convex optimization using an approximate subgradient oracle (Section 10.1) as well as our technique on using duality to decrease dimensions and improve the running time of semidefinite programming (Section 10.2). In Section 11 we provide our technique for using minimization oracles to minimize functions over the intersection of convex sets and provide several applications including matroid intersection (Section 11.2), submodular flow (Section 11.3), and minimizing a linear function over the intersection of an affine subspace and a convex set (Section 11.4). 9 Preliminaries In this section we review basic facts about convex functions that we use throughout Part II. We also introduce two oracles that we use throughout Part II, i.e. subgradient and optimization oracles, and provide some basic reductions between them. Note that we have slightly extended some definitions and facts to accommodate for the noisy separation oracles used in this paper. First we recall the definition of strong convexity Definition 35 (Strong Convexity ). A real valued function f on a convex set Ω is α-strongly convex if for any (cid:126)x, (cid:126)y ∈ Ω and t ∈ [0, 1], we have αt(1 − t)(cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 ≤ tf ((cid:126)x) + (1 − t)f ((cid:126)y). f (t(cid:126)x + (1 − t)(cid:126)y) + 1 2 Next we define an approximate subgradient. 50 Authors Fujishige [35] Grotschel, Lov´asz, Schrijver[49] Zimmermann [113] Barahona, Cunningham [12] Cunningham, Frank [22] Fujishige [36] Frank, Tardos [34] Cui, Fujishige [108] Fujishige, Rock, Zimmermann[38] Chung, Tcha [18] Zimmermann [114] McCormick, Ervolina [82] Wallacher, Zimmermann [109] Iwata [52] Iwata, McCormick, Shigeno [57] Iwata, McCormick, Shigeno [58] Fleischer, Iwata, McCormick[32] Iwata, McCormick, Shigeno [59] Fleischer, Iwata [30] This paper Running times not stated weakly polynomial strongly polynomial not stated not stated → O(n4h log C) not stated not stated → O(n6h log n) Years 1978 1981 1982 1984 1985 1987 1987 1988 1989 1991 1992 1993 1994 1997 1998 1999 1999 1999 2000 2015 O(n2 log nCU · EO + n3 logO(1) nCU ) O(cid:0)n4h min(cid:8)log nC, n2 log n(cid:9)(cid:1) O(cid:0)n6h min(cid:8)log nU, n2 log n(cid:9)(cid:1) O(cid:0)n4h min(cid:8)log U, n2 log n(cid:9)(cid:1) O(cid:0)n4h min(cid:8)log C, n2 log n(cid:9)(cid:1) O(n7h∗ log nCU ) O(n8h log nCU ) O(mn5 log nU · EO) not stated not stated O(n7h log U ) Figure 8.1: Previous algorithms for Submodular Flow with n vertices, maximum cost C and max- imum capacity U . The factor h is the time for an exchange capacity oracle, h∗ is the time for a “more complicated exchange capacity oracle” and EO is the time for evaluation oracle of the submodular function. The arrow,→, indicates that it used currently best maximum submodular flow algorithm as subroutine which was non-existent at the time of the publication. 51 Definition 36 (Subgradient). For any convex function f on a convex set Ω, the δ-subgradients of f at x are defined to be ∂δf ((cid:126)x) def= {(cid:126)g ∈ Ω : f ((cid:126)y) + δ ≥ f ((cid:126)x) + (cid:104)(cid:126)g, (cid:126)y − (cid:126)x(cid:105) for all (cid:126)y ∈ Ω}. Here we provide some basic facts regarding convexity and subgradients. These statements are natural extensions of well known facts regarding convex functions and their proof can be found in any standard textbook on convex optimization. Fact 37. For any convex set Ω and (cid:126)x be a point in the interior of Ω, we have the following: 1. If f is convex on Ω, then ∂0f ((cid:126)x) (cid:54)= ∅ and ∂sf ((cid:126)x) ⊆ ∂tf ((cid:126)x) for all 0 ≤ s ≤ t.Otherwise, we D . For any f ((cid:126)y) ≤ f ((cid:126)x), we have δ ≥ (cid:104)(cid:126)g, (cid:126)y − (cid:126)x(cid:105) and hence have(cid:13)(cid:13)(cid:126)g(cid:13)(cid:13)2 > 1 2 (cid:113) δ 2. If f is a differential convex function on Ω, then ∇f ((cid:126)x) ∈ ∂0f ((cid:126)x). 3. If f1 and f2 are convex function on Ω, (cid:126)g1 ∈ ∂δ1f1((cid:126)x) and (cid:126)g2 ∈ ∂δ2f1((cid:126)x), then α(cid:126)g1 + β(cid:126)g2 ∈ ∂αδ1+βδ2((cid:126)g1 + (cid:126)g2)((cid:126)x). √ have 1 (cid:113) δ D , then f ((cid:126)x) ≤ min(cid:107)(cid:126)y2(cid:107)2≤D f ((cid:126)y) + 2 2 several times in Part II to simplify our construction of separation oracles. δD and if(cid:13)(cid:13)(cid:126)g(cid:13)(cid:13)2 ≤ 1 2 Next we provide a reduction from subgradients to separation oracles. We will use this reduction 4. If f is α-strongly convex on Ω with minimizer x∗, then for any (cid:126)y with f ((cid:126)y) ≤ f ((cid:126)x∗) + , we 2 α(cid:13)(cid:13)(cid:126)x∗ − (cid:126)y(cid:13)(cid:13)2 ≤ . (cid:113) δ {(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ≤ D : f ((cid:126)y) ≤ f ((cid:126)x)} ⊂ {(cid:126)y : (cid:126)dT (cid:126)y ≤ (cid:126)dT (cid:126)x + 2 Lemma 38. Let f be a convex function. Suppose we have (cid:126)x and (cid:126)g ∈ ∂δf ((cid:126)x) with (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ≤ 1 ≤ D and δ ≤ 1. If(cid:13)(cid:13)(cid:126)g(cid:13)(cid:13)2 ≤ 1 δD)-separation oracle on the set {(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ≤ D}. with (cid:126)d = (cid:126)g/(cid:13)(cid:13)(cid:126)g(cid:13)(cid:13)2. Hence, this gives a (2 Proof. Let (cid:126)y such that(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ≤ D. By the definition of δ-subgradient, we have δD because(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13) ≤ D and(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ≤ D. Therefore, If(cid:13)(cid:13)(cid:126)g(cid:13)(cid:13) ≤ 1 Otherwise, we have(cid:13)(cid:13)(cid:126)g(cid:13)(cid:13)2 > 1 (cid:113) δ D , then, we have (cid:104)(cid:126)g, (cid:126)y − (cid:126)x(cid:105) ≤ √ D . For any f ((cid:126)y) ≤ f ((cid:126)x), we have δ ≥ (cid:104)(cid:126)g, (cid:126)y − (cid:126)x(cid:105) and hence f ((cid:126)y) + δ ≥ f ((cid:126)x) + (cid:104)(cid:126)g, (cid:126)y − (cid:126)x(cid:105) . (cid:13)(cid:13)(cid:126)y (cid:13)(cid:13)2 min ≤D (cid:113) δ 2 δD ≥ f ((cid:126)x). √ δD} √ √ δD, 2 √ f ((cid:126)y) + 2 D then 2 (cid:42) (cid:43) . (cid:126)g(cid:13)(cid:13)(cid:126)g(cid:13)(cid:13) , (cid:126)y − (cid:126)x √ 2 δD ≥ At several times in Part II we will wish to construct subgradient oracles or separation oracles given only the ability to approximately maximize a linear function over a convex set. In the remainder of this section we formally define such a optimization oracle and prove this equivalence. 52 Definition 39 (Optimization Oracle). Given a convex set K and δ > 0 a δ-optimization oracle for K is a function on Rn such that for any input (cid:126)c ∈ Rn, it outputs (cid:126)y such that (cid:104)(cid:126)c, (cid:126)x(cid:105) ≤ (cid:104)(cid:126)c, (cid:126)y(cid:105) + δ. max (cid:126)x∈K We denote by OOδ(K) the time complexity of this oracle. Lemma 40. Given a convex set K, any -optimization oracle for K is a -subgradient oracle for f ((cid:126)c) def= max(cid:126)x∈K (cid:104)(cid:126)c, (cid:126)x(cid:105) . Proof. Let (cid:126)xc be the output of -optimization oracle on the cost vector (cid:126)c. We have Hence, for all (cid:126)d, we have and therefore(cid:68) (cid:69) (cid:104)(cid:126)c, (cid:126)x(cid:105) ≤ (cid:104)(cid:126)c, (cid:126)xc(cid:105) + . max (cid:126)x∈K (cid:126)xc, (cid:126)d − (cid:126)c + f ((cid:126)c) ≤ f ((cid:126)d) + . Hence, (cid:126)xc ∈ ∂δf ((cid:126)c). Combining these lemmas shows that having an -optimization oracle for a convex set K con- D) separation oracle for maxx∈K (cid:104)(cid:126)c, (cid:126)x(cid:105). We use √ tained in a ball of radius D yields a O( these ideas to construction separation oracles throughout Part II. D, √ 10 Convex Optimization In this section we show how to apply our cutting plane method to efficiently solve problems in convex optimization. First, in Section 10.1 we show how to use our result to minimize a convex function given an approximate subgradient oracle. Then, in Section 10.2 we illustrate how this result can be used to obtain both primal and dual solutions for a standard convex optimization problems. In particular, we show how our result can be used to obtain improved running times for semidefinite programming across a range of parameters. 10.1 From Feasibility to Optimization In this section we consider the following standard optimization problem. We are given a convex function f : Rn → R ∪ {+∞} and we want to find a point (cid:126)x that approximately solves the minimization problem min (cid:126)x∈Rn f ((cid:126)x) given only a subgradient oracle for f . Here we show how to apply the cutting plane method from Part I turning the small width guarantee of the output of that algorithm into a tool to find an approximate minimizer of f . Our result is applicable to any convex optimization problem armed with a separation or subgradient oracle. This result will serve as the foundation for many of our applications in Part II. Our approach is an adaptation of Nemiroski’s method [85] which applies the cutting plane method to solve convex optimiziation problems, with only minimal assumption on the cutting plane method. The proof here is a generalization that accommodates for the noisy separation oracle used in this paper. In the remainder of this subsection we provide a key definition we will use in our algorithm (Defintion 41), provide our main result (Theorem 42), and conclude with a brief discussion of this result. 53 f ((cid:126)x) − min (cid:126)y∈Ω with an expected running time of f ((cid:126)y) ≤ η + α (cid:16) (cid:16) αMinWidth(Ω) (cid:17) O nSOη,δ(f ) log (cid:18) (cid:16) nκ (cid:17) α max (cid:126)y∈Ω f ((cid:126)y) − min (cid:126)y∈Ω + n3 logO(1)(cid:16) nκ α (cid:19) (cid:17)(cid:17) , Definition 41. For any compact set K, we define the minimum width by MinWidth(K) def= min(cid:107)(cid:126)a(cid:107)2=1 max(cid:126)x,(cid:126)y∈K (cid:104)(cid:126)a, (cid:126)x − (cid:126)y(cid:105) . Theorem 42. Let f be a convex function on Rn and Ω be a convex set that contains a minimizer of f . Suppose we have a (η, δ)-separation oracle for f and Ω is contained inside B∞(R). Using B∞(R) as the initial polytope for our Cutting Plane Method, for any 0 < α < 1, we can compute (cid:126)x ∈ Rn such that f ((cid:126)y) . (10.1) R n3/2 ln(κ) and κ = MinWidth(Ω) . Furthermore, we only need the oracle defined on where δ = Θ the set B∞(R). Proof. Let (cid:126)x∗ ∈ arg min(cid:126)x∈Ω f ((cid:126)x). Since B∞(R) ⊃ Ω contains a minimizer of f , by the definition of (η, δ)-separation oracles, our Cutting Plane Method (Theorem 31) either returns a point (cid:126)x that is almost optimal or returns a polytope P of small width. In the former case we have a point (cid:126)x such that f ((cid:126)x) ≤ min(cid:126)y f ((cid:126)y) + η. Hence, the error is clearly at most η + α (max(cid:126)z∈Ω f ((cid:126)z) − min(cid:126)x∈Ω f ((cid:126)x)) as desired. Consequently, we assume the latter case. Theorem 31 shows MinWidth(P ) < Cn ln(R/) for some universal constant C. Picking  = C(cid:48) αMinWidth(Ω) n ln(cid:0) nκ α (cid:1) (10.2) for small enough constant C(cid:48), we have MinWidth(P (i)) < αMinWidth(Ω). Let Ωα = (cid:126)x∗ +α(Ω−(cid:126)x∗), namely, Ωα = {(cid:126)x∗ + α((cid:126)z − (cid:126)x∗) : (cid:126)z ∈ Ω}. Then, we have MinWidth(Ωα) = αMinWidth(Ω) > MinWidth(P ). Therefore, Ωα is not a subset of P (i) and hence there is some point (cid:126)y ∈ Ωα\P . Since Ωα ⊆ Ω ⊆ B∞(R), we know that (cid:126)y does not violate any of the constraints of P (0) and therefore must violate one of the constraints added by querying the separation oracle. Therefore, for some j ≤ i, we have (cid:126)c(j−1), (cid:126)y √ n)-separation oracle (Definition 2), we have f ((cid:126)y) > f ((cid:126)x(j−1)). Since n . > By the definition of (η, cs/ (cid:126)y ∈ Ωα, we have (cid:126)y = (1 − α)(cid:126)x∗ + α(cid:126)z for some (cid:126)z ∈ Ω. Thus, the convexity of f implies that (cid:68) (cid:69) (cid:126)c(j−1), (cid:126)x(j−1)(cid:69) (cid:68) √ + cs/ f ((cid:126)y) ≤ (1 − α)f ((cid:126)x∗) + αf ((cid:126)z). Therefore, we have min 1≤k≤i f ((cid:126)x(k)) − min (cid:126)x∈Ω f ((cid:126)x) < f ((cid:126)y) − f ((cid:126)x∗) ≤ α (cid:18) (cid:19) f ((cid:126)x) . f ((cid:126)z) − min (cid:126)x∈Ω max (cid:126)z∈Ω Note that we need to call (η, δ)-separation oracle with δ = Ω(/ Hence, we can simply output the best (cid:126)x among all (cid:126)x(j) and in either case (cid:126)x satisfies (10.1). n) to ensure we do not cut out (cid:126)x∗. Theorem 31 shows that the algorithm takes O(nSOη,δ(f ) log(nR/) + n3 logO(1)(nR/)) expected time, as promised. Furthermore, the oracle needs only be defined on B∞(R) as our cutting plane method guarantees (cid:126)x(k) ∈ B∞(R) for all k (although if needed, an obvious separating hyperplane can be returned for a query point outside B∞(R) ). √ 54 Observe that this algorithm requires no information about Ω (other than that Ω ⊆ B∞(R)) and does not guarantee that the output is in Ω. Hence, even though Ω can be complicated to describe, the algorithm still gives a guarantee related to the gap max(cid:126)x∈Ω f ((cid:126)x) − min(cid:126)x∈Ω f ((cid:126)x). For specific applications, it is therefore advantageous to pick a Ω as large as possible while the bound on function value is as small as possible. (cid:16) Before indulging into specific applications, we remark on the dependence on κ. Using John’s ellipsoid, it can be shown that any convex set Ω can be transformed linearly such that (1) B∞(1) contains Ω and, (2) MinWidth(Ω) = Ω(n−3/2). In other words, κ can be effectively chosen as O(n3/2). Therefore if we are able to find such a linear transformation, the running time is simply O . Often this can be done easily using the structure of the particular problem and the running time does not depend on the size of domain at all. nSO(f ) log (n/α) + n3 logO(1) (n/α) (cid:17) 10.2 Duality and Semidefinite Programming (cid:69) (cid:68) (cid:126)d, (cid:126)y In this section we illustrate how our result in Section 10.1 can be used to obtain both primal and dual solutions for standard problems in convex optimization. In particular we show how to obtain improved running times for semidefinite programming. To explain our approach, consider the following minimax problem (cid:104)A(cid:126)x, (cid:126)y(cid:105) + (cid:104)(cid:126)c, (cid:126)x(cid:105) + min (cid:126)y∈Y max (cid:126)x∈X (10.3) where (cid:126)x ∈ Rm and (cid:126)y ∈ Rn. When m (cid:29) n, solving this problem by directly using Part I could lead to an inefficient algorithm with running time at least m3. In many situations, for any fixed (cid:126)y, the problem max(cid:126)x∈X (cid:104)A(cid:126)x, (cid:126)y(cid:105) is very easy and hence one can use it as a separation oracle and apply Part I and this would gives a running time almost independent of m. However, this would only give us the (cid:126)y variable and it is not clear how to recover (cid:126)x variable from it. In this section we show how to alleviate this issue and give semidefinite programming (SDP) as a concrete example of how to apply this general technique. We do not write down the general version as the running time of the technique seems to be problem specific and faster SDP is already an interesting application. For the remainder of this section we focus on the semidefinite programming (SDP) problem: and its dual max X(cid:23)0 C • X s.t. Ai • X = bi (cid:126)bT (cid:126)y s.t. min (cid:126)y yiAi (cid:23) C (10.4) (10.5) n(cid:88) i=1 n(cid:88) i=1 where X, C, Ai are m × m symmetric matrices and (cid:126)b, (cid:126)y ∈ Rn. Our approach is partially inspired by one of the key ideas of [51, 70]. These results write down the dual SDP in the form (cid:126)bT (cid:126)y − K min(λmin( yiAi − C), 0) (10.6) min y for some large number K and use non-smooth optimization techniques to solve the dual SDP problem. Here, we follow the same approach but instead write it as a max-min problem min(cid:126)y fK((cid:126)y) where (cid:43)(cid:33) (cid:32) yiAi . (10.7) (cid:42) X, C − n(cid:88) i=1 fK((cid:126)y) = max TrX≤K,X(cid:23)0 (cid:126)bT (cid:126)y + 55 Thus the SDP problem in fact assumes the form (10.3) and many ideas in this section can be generalized to the minimax problem (10.3). To get a dual solution, we notice that the cutting plane method maintains a subset of the primal feasible solution conv(Xi) such that (cid:42) X, C − n(cid:88) i=1 (cid:43) yiAi . (cid:42) X, C − n(cid:88) (cid:43) min (cid:126)y (cid:126)bT (cid:126)y + max TrX≤K,X(cid:23)0 yiAi i=1 ∼ min (cid:126)y (cid:126)bT (cid:126)y + max X∈conv(Xi) Applying minimax theorem, this shows that there exists an approximation solution X in conv(Xi) for the primal problem. Hence, we can restrict the primal SDP on the polytope conv(Xi), this reduces the primal SDP into a linear program which can be solved very efficiently. This idea of getting primal/dual solution from the cutting plane method is quite general and is the main purpose of this example. As a by-product, we have a faster SDP solver in both primal and dual! We remark that this idea has been used as a heuristic to obtain [69] for getting the primal SDP solution and our contribution here is mainly the asymptotic time analysis. We first show how to construct the separation oracle for SDP. For that we need to compute smallest eigenvector of a matrix. Below, for completeness we provide a folklore result showing we can do this using fast matrix multiplication. Lemma 43. Given a n × n symmetric matrix Y such that −RI (cid:22) Y (cid:22) RI, for any  > 0, with high probability in n in time O(nω+o(1) logO(1)(R/)) we can find a unit vector (cid:126)u such that (cid:126)uT Y(cid:126)u ≥ λmax(Y) − . Proof. Let B def= 1 Bk+1 = B2 k TrB2 k R Y + I. Note that B (cid:23) 0. Now, we consider the repeated squaring B0 = B and . Let 0 ≤ λ1 ≤ λ2 ≤ ··· ≤ λn be the eigenvalues of B and (cid:126)vi be the corresponding eigenvectors. Then, it is easy to see the the eigenvalues of Bk are Let (cid:126)q be a random unit vector and (cid:126)r def= Bk(cid:126)q. Now (cid:126)q =(cid:80) αi(cid:126)vi for some αi such that(cid:80) α2 λ2k i=1 λ2k i(cid:80)n . i i = 1. Letting we have (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) (cid:107)(cid:126)r − (cid:126)p(cid:107)2 = (cid:16) log(n3/2/δ) δ Letting k = log2 αiλ2k i (cid:126)vi (cid:80)n λi≤(1−δ)λn i=1 λ2k i λ2k i ≤ (1 − δ)2k n. n. Since 0 (cid:22) B (cid:22) 2I, we have (cid:80) i=1 λ2k i (cid:80) ≤ αiλ2k i (cid:126)vi (cid:126)p = i=1 λ2k i λi≤(1−δ)λn λi>(1−δ)λn (cid:80) (cid:17) (cid:80)n (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 (cid:126)pT B(cid:126)p −(cid:113) (cid:80)n √ , we have (cid:107)(cid:126)r − (cid:126)p(cid:107)2 ≤ δ/ (cid:126)rT B(cid:126)r ≥ (cid:112) √ ≥ (cid:112) (cid:126)rT B(cid:126)r ≥(cid:112)(1 − δ)λn √ ((cid:126)r − (cid:126)p)T B((cid:126)r − (cid:126)p) √ (cid:126)pT B(cid:126)p − 2δ/ n. (cid:13)(cid:13)(cid:126)p(cid:13)(cid:13)2 − 2δ/ √ n. Note that (cid:126)p involves only eigenvectors between (1 − δ)λn to λn. Hence, we have 56 B (cid:22) 2I and(cid:13)(cid:13)(cid:126)p(cid:13)(cid:13)2 ≥(cid:13)(cid:13)(cid:126)r(cid:13)(cid:13)2 − δ/ With constant probability, we have αn = Ω(1/ n we have that so long as δ is a small enough universal constant √ √ (cid:126)rT B(cid:126)r (cid:13)(cid:13)(cid:126)r(cid:13)(cid:13)2 √ n). Hence, we have (cid:13)(cid:13)(cid:126)p(cid:13)(cid:13)2 = Ω(1/ (cid:112)(1 − δ)λn (cid:13)(cid:13)(cid:126)p(cid:13)(cid:13)2 − 2δ/ (cid:13)(cid:13)(cid:126)p(cid:13)(cid:13)2 + δ/ (cid:112) (cid:112) λn − O(δ) √ R). ≥ = (1 − O(δ)) λn − O(δ = √ √ n n √ n). Using multiplications. Therefore, we have (cid:126)rT Y(cid:126)r(cid:13)(cid:13)(cid:126)r for any η > 0, using O(log(n/b)) bits, we can find C such that (cid:13)(cid:13)C − AB(cid:13)(cid:13)F ≤ 1 (cid:13)(cid:13)2 ≥ λmax(Y) − O(Rδ). Hence, we can find vector (cid:126)r by computing k matrix (cid:13)(cid:13)A(cid:13)(cid:13)(cid:13)(cid:13)B(cid:13)(cid:13) in [24] showed that fast matrix multiplication is stable under Frobenius norm, i.e., time O(nω+η) where ω is the matrix multiplicative constant. Hence, this algorithm takes only O(nω+o(1) logO(1)(δ−1)) time. The result follows from renormalizing the vector (cid:126)r, repeating the algorithm O(log n) times to boost the probability and taking δ = Ω(/R). b i=1 nnz(Ai). The following lemma shows how to compute a separation for fK defined in (10.7). in time O(S + mω+o(1) logO(1)(nKM L/)) where where S is the sparsity of the problem defined as (cid:13)(cid:13)F ≤ M and (cid:13)(cid:13)C(cid:13)(cid:13)F ≤ M . For any 0 <  < 1 and (cid:126)y with (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 = Lemma 44. Suppose that (cid:13)(cid:13)Ai O(L), with high probability in m, we can compute a (, )-separation of fK on {(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ≤ L} at (cid:126)y nnz(C) +(cid:80)n Proof. Note that −O(nM L)I (cid:22) C−(cid:80)n (cid:126)v with(cid:13)(cid:13)(cid:126)v(cid:13)(cid:13)2 = K in time O(mω+o(1) logO(1)(nKM L/δ)) such that i=1 yiAi (cid:22) O(nM L)I. Using Lemma 43, we can find a vector (cid:33) (cid:42) X, C − n(cid:88) (cid:16) In other words, we have a δ-optimization oracle for the function fK. Lemma 40 shows this yields a δ-subgradient oracle and Lemma 38 then shows this yields a -separation oracle on the set {(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ≤ L}. By picking δ = 2/L, we have the promised oracle. (cid:32) C − n(cid:88) TrX≤K,X(cid:23)0 δL), O( (cid:43) − δ. (cid:126)v ≥ (10.8) (cid:17) yiAi i=1 √ √ δL) max yiAi (cid:126)vT i=1 O( With the separation oracle in hand, we are ready to give the algorithm for SDP: Theorem 45. Given a primal-dual semidefinite programming problem in the form (10.4) and (10.5), suppose that for some M ≥ 1 we have 2. The primal feasible set lies inside the region TrX ≤ M . 1. (cid:13)(cid:13)b(cid:13)(cid:13)2 ≤ M ,(cid:13)(cid:13)C(cid:13)(cid:13)F ≤ M and(cid:13)(cid:13)Ai (cid:13)(cid:13)F ≤ M for all i. 3. The dual feasible set lies inside the region(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)∞ ≤ M . 1. X (cid:23) 0, TrX = O(M ),(cid:80) 2. (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)∞ = O(M ),(cid:80)n i=1 yiAi (cid:23) C − I and (cid:126)bT (cid:126)y ≤ OPT + . Let OPT be the optimum solution of (10.4) and (10.5). Then, with high probability, we can find X and (cid:126)y such that i bi − (cid:104)X, Ai(cid:105) ≤  for all i and C • X ≥ OPT − . 57 defined as nnz(C) +(cid:80)n in expected time O (cid:16)(cid:0)nS + n3 + nmω+o(1)(cid:1) logO(1)(cid:0) nM (cid:1)(cid:17) where S is the sparsity of the problem  i=1 nnz(Ai) and ω is the fast matrix multiplication constant. Proof. Let K ≥ M be some parameter to be determined. Since the primal feasible set is lies inside the region TrX ≤ M ≤ K, we have (cid:80)n i=1 yiAi(cid:23)C min (cid:126)bT (cid:126)y = max X(cid:23)0,TrX≤K,Ai•X=bi C • X C • X −(cid:88) (cid:32) (cid:126)bT (cid:126)y + (C −(cid:88) i yi (Ai • X − bi) (cid:33) yiAi) • X i = max X(cid:23)0,TrX≤K min (cid:126)y = min (cid:126)y max X(cid:23)0,TrX≤K = min (cid:126)y fK((cid:126)y). Lemma 44 shows that it takes SOδ,δ(fK) = O(S + mω+o(1) log(nKM L/δ)) time to compute a (δ, δ)-separation oracle of fK for any point (cid:126)y with (cid:107)(cid:126)y(cid:107)∞ = O(L) where L is some parameter with L ≥ M . Taking the radius R = L, Theorem 42 shows that it takes O (cid:1)(cid:17) (cid:16) (cid:1) + n3 logO(1)(cid:0) n nSOδ,δ(fK) log(cid:0) n  ≤ δ + 2α (nM L + 2nKM L) . α α (cid:13)(cid:13)(cid:126)y (cid:13)(cid:13)∞≤L fK((cid:126)y) ≤ δ + α fK((cid:126)y) − min  max (cid:13)(cid:13)∞≤L (cid:13)(cid:13)(cid:126)y expected time with δ = Θ(cid:0)αn−3/2L(cid:1) to find (cid:126)y such that (cid:13)(cid:13)∞≤L (cid:13)(cid:13)(cid:126)y (cid:126)bT (cid:126)y + K max(λmax(C − n(cid:88) i=1 yiAi), 0). Then, we have that(cid:80)n Let β = max(λmax(C −(cid:80)n 7nM KL , we have fK((cid:126)y) ≤ min(cid:126)y fK((cid:126)y) + . Therefore, fK((cid:126)y) − min Picking α = fK((cid:126)y) i=1  yiAi), 0) ≤ OPT + . i=1 yiAi (cid:23) C − βI and (cid:126)bT (cid:126)y ≥ (cid:80)n i=1 yiAi(cid:23)C−βI min (cid:126)bT (cid:126)y (C − βI) • X max = X(cid:23)0Ai•X=bi ≥ OPT − βM because TrX ≤ M . Hence, we have OPT − βM + βK ≤ (cid:126)bT (cid:126)y + K max(λmax(C − n(cid:88) yiAi), 0) ≤ OPT +  i=1 Putting K = M + 1, we have β ≤ . Thus, n(cid:88) i=1 yiAi (cid:23) C − I. This gives the result for the dual with the running time O (cid:16)(cid:0)nS + n3 + nmω+o(1)(cid:1) logO(1)(cid:0) nM L  (cid:1)(cid:17) . 58 Our Cutting Plane Method accesses the sub-problem (C −(cid:88) i max X(cid:23)0,TrX≤K yiAi) • X only through the separation oracle. Let (cid:126)z be the output of our Cutting Plane Method and {(cid:126)vi(cid:126)vT i }O(n) i=1 be the matrices used to construct the separation for the O(n) hyperplanes the algorithm maintains i=1 ziAi. Now, we consider a realization at the end. Let (cid:126)u be the maximum eigenvector of C −(cid:80)n (cid:42) X, C − n(cid:88) fK((cid:126)y) = (cid:126)bT (cid:126)y + yiAi . (cid:43) of fK max X∈conv(K(cid:126)u(cid:126)uT ,(cid:126)vi(cid:126)vT i ) i=1 Since applying our Cutting Plane Method to either fK or fK gives the same result, the correctness of the our Cutting Plane Method shows that fK((cid:126)z) ≤ min fK((cid:126)y) + . (cid:13)(cid:13)(cid:126)y (cid:13)(cid:13)∞≤L Note that the function fK is defined such that fK((cid:126)z) = fK((cid:126)z). Hence, we have fK((cid:126)y) ≤ fK((cid:126)z) ≤ fK((cid:126)z) ≤ min fK((cid:126)y) + . Also, note that fK((cid:126)x) ≤ fK((cid:126)x) for all (cid:126)x. Hence, we have min (cid:13)(cid:13)∞≤L (cid:13)(cid:13)(cid:126)y (cid:13)(cid:13)∞≤L (cid:13)(cid:13)(cid:126)y min fK((cid:126)y) −  ≤ min (cid:13)(cid:13)(cid:126)y g(X) def= min (cid:126)bT (cid:126)y + (cid:13)(cid:13)(cid:126)y (cid:13)(cid:13)∞≤L (cid:13)(cid:13)(cid:126)y f ((cid:126)y) ≤ min (cid:13)(cid:13)∞≤L (cid:13)(cid:13)∞≤L (cid:13)(cid:13)∞≤L (cid:13)(cid:13)(cid:126)y (cid:42) X, C − n(cid:88) (cid:13)(cid:13)∞≤L (cid:13)(cid:13)(cid:126)y i=1 yiAi fK((cid:126)y). (cid:43) . Now, we consider the primal version of f , namely Sion’s minimax theorem [98] shows that OPT ≥ max X∈conv(K(cid:126)u(cid:126)uT ,(cid:126)vi(cid:126)vT i ) g(X) = min f ((cid:126)y) ≥ OPT − . Therefore, to get the primal solution, we only need to find (cid:126)u by Lemma 43 and solve the maxi- mization problem on g. Note that g(X) = yi (bi − (cid:104)X, Ai(cid:105)) + (cid:104)X, C(cid:105) = −L n(cid:88) (cid:13)(cid:13)(cid:126)y min i i=1 bi − (cid:104)X, Ai(cid:105) + (cid:104)X, C(cid:105) . (cid:13)(cid:13)∞≤L (cid:88) 0 . Then, X =(cid:80)O(n) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) + (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)bi −(cid:88) (cid:88) j Ai(cid:126)vj αj(cid:126)vT j j (cid:88) j 59 For notation simplicity, we write K(cid:126)u(cid:126)uT = (cid:126)v0(cid:126)vT αj ≥ 0. Substituting this into the function g, we have j=0 αj(cid:126)vj(cid:126)vT j g((cid:126)α) = −L αj(cid:126)vT j C(cid:126)vj. for some(cid:80) αj = 1 and Hence, this can be easily written as a linear program with O(n) variables and O(n) constraints in time O(nS). Now, we can apply interior point method to find (cid:126)α such that g(X) −  ≥ OPT − 2. g((cid:126)α) ≥ max Let the corresponding approximate solution be (cid:101)X =(cid:80) αj(cid:126)vj(cid:126)vT X∈conv(K(cid:126)u(cid:126)uT ,(cid:126)vi(cid:126)vT i ) j . Then, we have (cid:68)(cid:101)X, Ai (cid:69) Now, we let bi = (cid:88) i (cid:68)(cid:101)X, C (cid:68)(cid:101)X, C (cid:69) − L (cid:69) ≤ . Then, we note that because(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)∞ ≤ M . Hence, we have (cid:12)(cid:12)(cid:12)bi −(cid:68)(cid:101)X, Ai Now, we put L = M + 2, we have (cid:88) OPT + (M − L) (cid:88) i bi − (cid:104)X, Ai(cid:105) ≥ OPT − 2. max X(cid:23)0Ai•X=bi C • X i min bT i (cid:126)y (cid:80)n = i=1 yiAi(cid:23)C ≤ OPT + M (cid:69)(cid:12)(cid:12)(cid:12) (cid:12)(cid:12)(cid:12)bi −(cid:68)(cid:101)X, Ai (cid:12)(cid:12)(cid:12)bi −(cid:68)(cid:101)X, Ai (cid:88) (cid:69)(cid:12)(cid:12)(cid:12) ≥(cid:68)(cid:101)X, C (cid:69) − L (cid:88) (cid:12)(cid:12)(cid:12)bi −(cid:68)(cid:101)X, Ai (cid:69)(cid:12)(cid:12)(cid:12) ≤ . i i (cid:69)(cid:12)(cid:12)(cid:12) ≥ OPT − 2. This gives the result for the primal. Note that it only takes O(n5/2 logO(1)(nM/)) to solve a linear program with O(n) variables and O(n) constraints because we have an explicit interior point deep inside the feasible set, i.e. αi = 1 m for some parameter m [76].5 Hence, the running time is dominated by the cost of cutting plane method which is O by putting L = M + 2. (cid:16)(cid:0)nS + n3 + nmω+o(1)(cid:1) logO(1)(cid:0) nM (cid:1)(cid:17) (cid:16)(cid:0)nS + n3 + nm2(cid:1) logO(1)(cid:0) nM We leave it as an open problem if it is possible to improve this result by reusing the computation (cid:1)(cid:17) .   in the separation oracle and achieve a running time of O 11 Intersection of Convex Sets In this section we introduce a general technique to optimize a linear function over the intersec- tion of two convex sets, whenever the linear optimization problem on each of them can be done efficiently. At the very high level, this is accomplished by applying cutting plane to a suitably regularized version of the problem. In Section 11.1 we present the technique and in the remaining sections we provide several applications including, matroid intersection (Section 11.2), submodular flow (Section 11.3), and minimizing over the intersection of an affine subspace and a convex set (Section 11.4). 5Without this, the running time of interior point method depends on the bit complexity of the linear programs. 60 11.1 The Technique Throughout this section we consider variants of the following general optimization problem (cid:104)(cid:126)c, (cid:126)x(cid:105) max (cid:126)x∈K1∩K2 where (cid:126)x, (cid:126)c ∈ Rn, K1 and K2 are convex subsets of Rn. We assume that (cid:107)(cid:126)x(cid:107)2 < M, (cid:107)(cid:126)c(cid:107)2 ≤ M (cid:107)(cid:126)x(cid:107)2 < M, max (cid:126)x∈K2 max (cid:126)x∈K1 for some constant M ≥ 1 and we assume that K1 ∩ K2 (cid:54)= ∅. (11.1) (11.2) (11.3) Instead of a separation oracle, we assume that K1 and K2 each have optimization oracles (see Section 9). 2 (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 To solve this problem we first introduce a relaxation for the problem (11.1) that we can optimize efficiently. Because we have only the optimization oracles for K1 and K2, we simply have variables (cid:126)x and (cid:126)y for each of them in the objective. Since the output should (approximately) be in the intersection of K1 and K2, a regularization term − λ 2 is added to force (cid:126)x ≈ (cid:126)y where λ is a large number to be determined later. Furthermore, we add terms to make the problem strong concave. Lemma 46. Assume (11.2) and (11.3). For λ ≥ 1, let (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 ((cid:126)xλ, (cid:126)yλ) is a good approximation of the solution of (11.1), i.e. (cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ Proof. Let (cid:126)x∗ be a maximizer of max(cid:126)x∈K1∩K2 (cid:104)(cid:126)c, (cid:126)x(cid:105). By assumption (11.2), (cid:13)(cid:13)(cid:126)x∗(cid:13)(cid:13)2 ≤ M , and There is an unique maximizer ((cid:126)xλ, (cid:126)yλ) for the problem max(cid:126)x∈K1,(cid:126)y∈K2 fλ((cid:126)x, (cid:126)y). The maximizer (cid:13)(cid:13)(cid:126)x − (cid:126)y(cid:13)(cid:13)2 (cid:104)(cid:126)c, (cid:126)x(cid:105) ≤ fλ((cid:126)xλ, (cid:126)yλ) + (cid:104)(cid:126)c, (cid:126)y(cid:105) − λ 2 (cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 2 ≤ 6M 2 fλ((cid:126)x, (cid:126)y) def= max (cid:126)x∈K1∩K2 (cid:104)(cid:126)c, (cid:126)x(cid:105) + 2 − 1 2 − 1 2λ (cid:13)(cid:13)2 M 2 λ (11.4) (11.5) and 1 2 . 2 1 2 2λ λ . therefore fλ((cid:126)x∗, (cid:126)x∗) = (cid:104)(cid:126)c, (cid:126)x∗(cid:105) − ≥ max (cid:126)x∈K1∩K2 (cid:104)(cid:126)c, (cid:126)x(cid:105) − M 2 λ . (11.6) This shows (11.5). Since fλ is strongly concave in (cid:126)x and (cid:126)y, there is a unique maximizer ((cid:126)xλ, (cid:126)yλ). Let OPTλ = fλ((cid:126)xλ, (cid:126)yλ). Then, we have (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)xλ OPTλ ≤ 1 2 ≤ 6M 2 λ . (11.7) (cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ (cid:13)(cid:13)2 2 (cid:13)(cid:13)2 − λ (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)yλ (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ 1 2 2 2. (cid:104)(cid:126)c, (cid:126)x(cid:105) − M 2 λ ≥ −2M 2. ≤ M 2 2 − λ 2 On the other hand, using λ ≥ 1, (11.6) shows that OPTλ ≥ fλ((cid:126)x∗, (cid:126)x∗) ≥ max (cid:126)x∈K1∩K2 M 2 2 + Hence, we have (cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ 2 ≤ 2(cid:0)M 2 − OPTλ (cid:13)(cid:13)2 (cid:1) λ 2 λ (cid:13)(cid:13)(cid:126)x∗(cid:13)(cid:13)2 (cid:13)(cid:13)2 + 61 Now we write max fλ((cid:126)x, (cid:126)y) as a max-min problem. The reason for doing this is that the dual approximate solution is much easier to obtain and there is a way to read off a primal approximate solution from a dual approximate solution. This is analogous to the idea in [73] which showed how to convert a cut solution to a flow solution by adding regularization terms into the problem. Lemma 47. Assume (11.2) and (11.3). Let λ ≥ 2. For any (cid:126)x ∈ K1 and (cid:126)y ∈ K2, the function fλ can be represented as where Ω = {((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) :(cid:13)(cid:13)(cid:126)θ1 (cid:42) fλ((cid:126)x, (cid:126)y) = min (cid:13)(cid:13)2 ≤ 2M, (cid:13)(cid:13)(cid:126)θ2 (cid:43) ((cid:126)θ1,(cid:126)θ2,(cid:126)θ3)∈Ω (cid:13)(cid:13)2 ≤ M, (cid:13)(cid:13)(cid:126)θ3 (cid:42) gλ((cid:126)x, (cid:126)y, (cid:126)θ1, (cid:126)θ2, (cid:126)θ3) = + λ(cid:126)θ1 + , (cid:126)x + gλ((cid:126)x, (cid:126)y, (cid:126)θ1, (cid:126)θ2, (cid:126)θ3) (cid:13)(cid:13)2 ≤ M} and (cid:43) (cid:13)(cid:13)(cid:126)θ1 , (cid:126)y + (cid:126)θ3 λ λ 2 (11.8) (cid:13)(cid:13)2 2 + (cid:13)(cid:13)(cid:126)θ2 (cid:13)(cid:13)2 2 + (cid:13)(cid:13)(cid:126)θ3 (cid:13)(cid:13)2 2. 1 2λ 1 2λ − λ(cid:126)θ1 + (cid:126)c 2 (cid:126)c 2 (cid:126)θ2 λ Let hλ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) = max(cid:126)x∈K1,(cid:126)y∈K2 gλ((cid:126)x, (cid:126)y, (cid:126)θ1, (cid:126)θ2, (cid:126)θ3). For any ((cid:126)θ(cid:48) 1, (cid:126)θ(cid:48) 2, (cid:126)θ(cid:48) 3) such that hλ((cid:126)θ(cid:48) 1, (cid:126)θ(cid:48) min((cid:126)θ1,(cid:126)θ2,(cid:126)θ3)∈Ω hλ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) + , we know (cid:126)z = 1 2 ((cid:126)θ(cid:48) 2 + (cid:126)θ(cid:48) 3) satisfies (11.9) 3) ≤ 2, (cid:126)θ(cid:48) (cid:104)(cid:126)c, (cid:126)x(cid:105) ≤ (cid:104)(cid:126)c, (cid:126)z(cid:105) + 20M 2 λ + 20λ3. max (cid:126)x∈K1∩K2 √ (cid:13)(cid:13)2 ≤ 4 max(cid:126)x∈K1,(cid:126)y∈K2 fλ((cid:126)x, (cid:126)y). (cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)z− (cid:126)yλ (cid:113) 6M 2 and(cid:13)(cid:13)(cid:126)z− (cid:126)xλ Proof. Note that for any(cid:13)(cid:13)(cid:126)ξ(cid:13)(cid:13)2 ≤ α, we have (cid:13)(cid:13)(cid:126)ξ(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)θ (cid:13)(cid:13)2 − 1 2 2λ + 2 = min ≤α (cid:68)(cid:126)θ, (cid:126)ξ (cid:69) (cid:13)(cid:13)(cid:126)θ(cid:13)(cid:13)2 2 + 1 2 λ where ((cid:126)xλ, (cid:126)yλ) is the unique maximizer for the problem Using this and (11.2), we have (11.8) for all (cid:126)x ∈ K1 and (cid:126)y ∈ K2 as desired. Since Ω is closed and bounded set and the function gλ is concave in ((cid:126)x, (cid:126)y) and convex in ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3), Sion’s minimax theorem [98] shows that max (cid:126)x∈K1,(cid:126)y∈K2 fλ((cid:126)x, (cid:126)y) = min ((cid:126)θ1,(cid:126)θ2,(cid:126)θ3)∈Ω hλ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) (11.10) Since fλ is strongly concave, there is an unique maximizer ((cid:126)xλ, (cid:126)yλ) of fλ. Since hλ is strongly convex, there is a unique minimizer ((cid:126)θ∗ 3). By the definition of fλ and hλ, we have 2, (cid:126)θ∗ 1, (cid:126)θ∗ 1, (cid:126)θ∗ 2, (cid:126)θ∗ hλ((cid:126)θ∗ 3) ≥ fλ((cid:126)xλ, (cid:126)yλ) 3) ≥ gλ((cid:126)xλ, (cid:126)yλ, (cid:126)θ∗ 2, (cid:126)θ∗ 1, (cid:126)θ∗ Using (11.10), the equality above holds and hence ((cid:126)θ∗ 2, (cid:126)θ∗ 1, (cid:126)θ∗ 3) is the minimizer of gλ((cid:126)xλ, (cid:126)yλ, (cid:126)θ1, (cid:126)θ2, (cid:126)θ3) over ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3). Since the domain Ω is large enough that ((cid:126)θ∗ 3) is an interior point in Ω, the 2 = (cid:126)xλ and (cid:126)θ∗ optimality condition of gλ shows that we have (cid:126)θ∗ 2 ≤ 2λ (Fact 37). 1 − (cid:126)θ∗ 1, (cid:126)θ∗ 2, (cid:126)θ∗ 3 = (cid:126)yλ. 2 − (cid:126)θ∗ (cid:13)(cid:13)2 2 +(cid:13)(cid:13)(cid:126)θ(cid:48) Since hλ is 1 3 − (cid:126)θ∗ (cid:13)(cid:13)2 3 1 2 . λ strongly convex, we have(cid:13)(cid:13)(cid:126)θ(cid:48) (cid:13)(cid:13)2 3 = (cid:126)yλ, we have(cid:13)(cid:13)(cid:126)θ(cid:48) 2 +(cid:13)(cid:13)(cid:126)θ(cid:48) 2 − (cid:126)xλ (cid:13)(cid:13)2 2 +(cid:13)(cid:13)(cid:126)θ(cid:48) (cid:13)(cid:13)2 Since (cid:126)θ∗ 2 = (cid:126)xλ and (cid:126)θ∗ 3 − (cid:126)yλ 2 ≤ 2λ. (11.11) 62 (cid:13)(cid:13)2 ≥ 2λ and (cid:13)(cid:13)(cid:126)yλ (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)θ(cid:48) 3 2 3 3 3 2λ √ 2 3 √ 2λ 2λ 2λ 2 2 3) = 2 − 1 2λ fλ((cid:126)θ(cid:48) 2, (cid:126)θ(cid:48) (cid:13)(cid:13)2 − √ (cid:13)(cid:13)2 2 − 1 (cid:126)c, (cid:126)θ(cid:48) 1 2 2 √ (cid:104)(cid:126)c, (cid:126)yλ(cid:105) − M 1 2 √ (cid:126)c, (cid:126)θ(cid:48) 1 + 2 ≥ 1 (cid:104)(cid:126)c, (cid:126)xλ(cid:105) + 2 − λ 2 − 1 2λ (cid:104)(cid:126)c, (cid:126)xλ(cid:105) + 1 2 −M − 1 λ Therefore, we have (cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ 2λ, (cid:13)(cid:13)(cid:126)xλ (cid:13)(cid:13)2 ≥ (cid:13)(cid:13)(cid:126)θ(cid:48) (cid:13)(cid:13)2 − 2 (cid:13)(cid:13)2 ≥ (cid:13)(cid:13)(cid:126)θ(cid:48) 2λ. Using these,(cid:13)(cid:13)(cid:126)xλ (cid:13)(cid:13)2 − √ (cid:13)(cid:13)2 ≤ M and(cid:13)(cid:13)(cid:126)yλ (cid:13)(cid:13)2 ≤ M , we have (cid:13)(cid:13)(cid:126)θ(cid:48) 2 − (cid:126)θ(cid:48) (cid:68) (cid:69) (cid:69) − λ (cid:68) (cid:13)(cid:13)(cid:126)θ(cid:48) (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)θ(cid:48) 2 − (cid:126)θ(cid:48) (cid:17)2 (cid:16)(cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ (cid:13)(cid:13)2 + 2 (cid:16)(cid:13)(cid:13)(cid:126)yλ (cid:17)2 − 1 (cid:16)(cid:13)(cid:13)(cid:126)xλ (cid:13)(cid:13)2 + (cid:13)(cid:13)2 + (cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ (cid:13)(cid:13)2 2λ(cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ (cid:13)(cid:13)2 − 4λ2 (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)xλ (cid:13)(cid:13)(cid:126)yλ (cid:13)(cid:13)2 (cid:13)(cid:13)2 < M , we have (cid:13)(cid:13)2 < M and(cid:13)(cid:13)(cid:126)yλ (Lemma 46),(cid:13)(cid:13)(cid:126)xλ (cid:13)(cid:13)2 − 4λ2 2λ(cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ (cid:13)(cid:13)(cid:126)xλ (cid:13)(cid:13)(cid:126)yλ (cid:13)(cid:13)2 (cid:13)(cid:13)2 (cid:114) 3) ≥ fλ((cid:126)xλ, (cid:126)yλ) √ (cid:104)(cid:126)c, (cid:126)yλ(cid:105) − λ √ 2 1 2 √ 2λ −  − 1 λ Using(cid:13)(cid:13)(cid:126)xλ − (cid:126)yλ (cid:13)(cid:13)2 ≤(cid:113) 6M 2 (cid:17)2 (cid:13)(cid:13)2 2 − 1 √ 2λ − 2λ 2λ −  − 1 λ √ 2λ − . ≥ fλ((cid:126)xλ, (cid:126)yλ) 12M − 4λ2 −M − 1 λ 2λ (cid:13)(cid:13)(cid:126)xλ fλ((cid:126)θ(cid:48) 2, (cid:126)θ(cid:48) 2λ − 2λ 2 − 1 2λ 2λ − . √ √ √ = λ √ 2λ 2λ √ −M −2M √ 2λ − 2λ − 2. 2  λ Since λ ≥ 2, we have fλ((cid:126)θ(cid:48) 2, (cid:126)θ(cid:48) 3) ≥ fλ((cid:126)xλ, (cid:126)yλ) − 20M λ √  − 10λ2. Let (cid:126)z = (cid:126)θ(cid:48) 2+(cid:126)θ(cid:48) 2 3 . Lemma 46 shows that (cid:13)(cid:13)(cid:126)yλ (cid:13)(cid:13)2 2 (cid:13)(cid:13)2 (cid:104)(cid:126)c, (cid:126)x(cid:105) ≤ max (cid:126)x∈K1∩K2 fλ((cid:126)x, (cid:126)y) + M 2 λ max (cid:126)x∈K1,(cid:126)y∈K2 ≤ fλ((cid:126)θ(cid:48) 2, (cid:126)θ(cid:48) ≤ (cid:104)(cid:126)c, (cid:126)z(cid:105) + M 2 3) + λ 20M 2 λ √  + 10λ2 + 20M λ √ because 20M λ λ + 10λ3. Furthermore, we have  ≤ 10 M 2 (cid:13)(cid:13)(cid:126)z − (cid:126)xλ (cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)z − (cid:126)yλ (cid:13)(cid:13)2 ≤ (cid:13)(cid:13)(cid:126)θ(cid:48) (cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)θ(cid:48) 2 − (cid:126)θ(cid:48) 3 3 − (cid:126)yλ + 20λ3 (cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)θ(cid:48) (cid:114) 6M 2 . λ 2 − (cid:126)xλ √ ≤ 4 2λ + 63 We now apply our cutting plane method to solve the optimization problem (11.1). First we show how to transform the optimization oracles for K1 and K2 to get a separation oracle for hλ, with the appropriate parameters. Lemma 48. Suppose we have a -optimization oracle for K1 and K2 for some 0 <  < 1. Then on λD))-separation oracle for hλ with time complexity √ √ λD), O( the set {(cid:13)(cid:13)(cid:126)θ(cid:13)(cid:13)2 ≤ D}, we have a (O( OO(K1) + OO(K2). Proof. Recall that the function hλ is defined by (cid:32)(cid:42) (cid:126)c 2 hλ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) = max (cid:126)x∈K1,(cid:126)y∈K2 (cid:42) (cid:43) (cid:42) + (cid:42) + λ(cid:126)θ1 + , (cid:126)x (cid:126)θ2 λ (cid:43) − λ(cid:126)θ1 + (cid:126)c 2 (cid:126)θ3 λ = max (cid:126)x∈K1 (cid:126)c 2 + λ(cid:126)θ1 + (cid:126)θ2 λ , (cid:126)x + max (cid:126)y∈K2 − λ(cid:126)θ1 + (cid:126)c 2 (cid:126)θ3 λ , (cid:126)y + (cid:43) , (cid:126)y (cid:43) (cid:33) λ 2 (cid:13)(cid:13)(cid:126)θ1 (cid:13)(cid:13)2 (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)θ1 2 + 2 + 1 2λ 1 2λ (cid:13)(cid:13)(cid:126)θ2 (cid:13)(cid:13)2 (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)θ2 2 + 2 + 1 2λ (cid:13)(cid:13)(cid:126)θ3 (cid:13)(cid:13)2 (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)θ3 2. 2 1 2λ + λ 2 Lemma 40 shows how to compute the subgradient of functions of the form f ((cid:126)c) = max(cid:126)x∈K (cid:104)(cid:126)c, (cid:126)x(cid:105) using the optimization oracle for K. The rest of the term are differentiable so its subgradient is just the gradient. Hence, by addition rule for subgradients (Fact 37), we have a O(λ)-subgradient oracle for fλ using a O()-optimization oracle for K1 and K2. The result then follows from Lemma 38. Theorem 49. Assume (11.2) and (11.3). Suppose that we have -optimization oracle for every  > 0. For 0 < δ < 1, we can find (cid:126)z ∈ Rn such that and(cid:13)(cid:13)(cid:126)z − (cid:126)x(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)z − (cid:126)y(cid:13)(cid:13)2 ≤ δ for some (cid:126)x ∈ K1 and (cid:126)y ∈ K2 in time (cid:126)x∈K1∩K2 max (cid:104)(cid:126)c, (cid:126)x(cid:105) ≤ δ + (cid:104)(cid:126)c, (cid:126)z(cid:105) O n (OOη(K1) + OOη(K2)) log + n3 logO(1) (cid:18) nM (cid:19) δ (cid:18) nM (cid:19)(cid:19) δ (cid:18) (cid:1)O(1)(cid:17) . (cid:16)(cid:0) δ nM where η = Ω Proof. Setting λ = 40M 2 δ2 1, (cid:126)θ(cid:48) approximate solution ((cid:126)θ(cid:48) then we obtain the point we want. To apply Theorem 42, we use 107M 6 in Lemma 47 we see that so long as we obtain any and  = δ7 2, (cid:126)θ(cid:48) 3) such that hλ((cid:126)θ(cid:48) 1, (cid:126)θ(cid:48) 2, (cid:126)θ(cid:48) h((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) = ((cid:126)θ1,(cid:126)θ2,(cid:126)θ3)∈Ω 3) ≤ min (cid:40) hλ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) +∞ hλ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) + , if ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) ∈ Ω else . Lemma 48 shows that for any γ > 0 we can obtain a (γ, γ)-separation oracle of hλ((cid:126)θ) by using sufficiently accurate optimization oracles. Since Ω is just a product of (cid:96)2 balls, we can produce a separating hyperplane easily when ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3) /∈ Ω. Hence, we can obtain a (γ, γ)-separation oracle 64 of h((cid:126)θ). For simplicity, we use (cid:126)θ to represent ((cid:126)θ1, (cid:126)θ2, (cid:126)θ3). Note that B∞(2M ) ⊇ Ω and therefore we can apply Theorem 42 with R = 2M to compute (cid:126)θ(cid:48) such h((cid:126)θ) ≤ γ + α h((cid:126)θ(cid:48)) − min (cid:126)θ∈Ω nSOγ,γ log(cid:0) nκ (cid:16) MinWidth(Ω) = O(1). Using λ ≥ 1 and M ≥ 1, we have (cid:1) + n3 logO(1)(cid:0) nκ max (cid:126)θ∈Ω 2M α α in time O and κ = h((cid:126)θ) (cid:19) (cid:19) h((cid:126)θ) − min (cid:126)θ∈Ω (cid:18) (cid:1)(cid:17) where γ = Ω(cid:0)αMinWidth(Ω)/nO(1)(cid:1) = Ω(cid:0)αM/nO(1)(cid:1) (cid:18) M 4 h((cid:126)θ) ≤ O(cid:0)λM 2(cid:1) ≤ O (cid:18) M 4 (cid:19) (cid:19) (cid:16)(cid:0) δ (cid:1)O(1)(cid:17) hλ((cid:126)θ) + γ + αO (cid:18) δ7 hλ((cid:126)θ) + O hλ((cid:126)θ) +  (cid:1)(cid:17) M 6 δ2 δ2 . Lemma 48 shows that . where γ = Ω nM (cid:16)(cid:0) δ (cid:1)O(1)(cid:17) (cid:17) (cid:16) δ9 M 10 Setting α = Θ h((cid:126)θ) − min (cid:126)θ∈Ω max (cid:126)θ∈Ω with some small enough constant, we have that we can find (cid:126)θ(cid:48) such that hλ((cid:126)θ(cid:48)) ≤ min (cid:126)θ∈P = min (cid:126)θ∈P = min (cid:126)θ∈P (cid:16) nSOγ,γ log(cid:0) nM δ in time O (cid:1) + n3 logO(1)(cid:0) nM δ the cost of (γ, γ)-separation oracle is just O(OOη(K1) + OOη(K2)) where η = Ω Remark 50. Note that the algorithm does not promise that we obtain a point close to K1 ∩ K2. It only promises to give a point that is close to both some point in K1 and some point in K2. It appears to the authors that a further assumption is needed to get a point close to K1 ∩ K2. For example, if K1 and K2 are two almost parallel lines, it would be difficult to get an algorithm that does not depend on the angle. However, as far as we know, most algorithms tackling this problem are pseudo-polynomial and have polynomial dependence on the angle. Our algorithm depends on the logarithmic of the angle which is useful for combinatorial problems. nM . This reduction is very useful for problems in many areas including linear programming, semi- definite programming and algorithmic game theory. In the remainder of this section we demonstrate its power by applying it to classical combinatorial problems. There is however one issue with applying our cutting plane algorithm to these problems. As with other convex optimization methods, only an approximately optimal solution is found. On the other hand, typically an exact solution is insisted in combinatorial optimization. To overcome this gap, we introduce the following lemma which (1) transforms the objective function so that there is only one optimal solution and (2) shows that an approximate solution is close to the optimal solution whenever it is unique. As we shall see in the next two subsections, this allows us to round an approximate solution to an optimal one. Lemma 51. Given a linear program minA(cid:126)x≥(cid:126)b (cid:126)cT (cid:126)x where (cid:126)x, (cid:126)c ∈ Zn, (cid:126)b ∈ Zm and A ∈ Zm×n. Suppose {A(cid:126)x ≥ (cid:126)b} is an integral polytope (i.e. all extreme points are integral) contained in the such that with constant probability, minA(cid:126)x≥(cid:126)b (cid:126)zT (cid:126)x has an unique minimizer (cid:126)x∗ and this minimizer is one of the minimizer(s) of minA(cid:126)x≥(cid:126)b (cid:126)cT (cid:126)x. Furthermore, if there is an interior point (cid:126)y such that set {(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)∞ ≤ M}. Then we can find a random cost vector (cid:126)z ∈ Zn with (cid:13)(cid:13)(cid:126)z(cid:13)(cid:13)∞ ≤ O(n2M 2(cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)∞) (cid:126)zT (cid:126)y < minA(cid:126)x≥(cid:126)b (cid:126)zT (cid:126)x + δ, then(cid:13)(cid:13)(cid:126)y − (cid:126)x∗(cid:13)(cid:13)∞ ≤ 2nM δ. 65 Proof. The first part of the lemma follows by randomly perturbing the cost vector (cid:126)c. We con- sider a new cost vector (cid:126)z = 100n2M 2(cid:126)c + (cid:126)r where each coordinate of (cid:126)r is sampled randomly from {0, 1,··· , 10nM}. [67, Lem 4] shows that the linear program minA(cid:126)x≥(cid:126)b (cid:126)zT (cid:126)x has a unique minimizer with constant probability. Furthermore, it is clear that the minimizer of minA(cid:126)x≥(cid:126)b (cid:126)zT (cid:126)x is a minimizer of minA(cid:126)x≥(cid:126)b (cid:126)cT (cid:126)x (as (cid:126)ri (cid:28) 100n2M 2(cid:126)ci). Now we show the second part of the lemma. Given an interior point (cid:126)y of the polytope {A(cid:126)x ≥ (cid:126)b}, we can write (cid:126)y as a convex combination of the vertices of {A(cid:126)x ≥ (cid:126)b}, i.e. (cid:126)y =(cid:80) ti(cid:126)vi. Note that (cid:126)zT (cid:126)y =(cid:80) ti(cid:126)zT (cid:126)vi. If all (cid:126)vi are not the minimizer, then (cid:126)zT (cid:126)vi ≥ OPT + 1 and hence (cid:126)zT (cid:126)y ≥ OPT + 1 the claim follows from(cid:13)(cid:13)(cid:126)y − (cid:126)v1 which is impossible. Hence, we can assume that (cid:126)v1 is the minimizer. Hence, (cid:126)zT (cid:126)vi = OPT if i = 1 and (cid:126)zT (cid:126)vi ≥ OPT + 1 otherwise. We then have (cid:126)zT (cid:126)y ≥ OPT + (1− t1) which gives 1− t1 < δ. Finally, (cid:13)(cid:13)∞ ≤ 2nM δ. (cid:13)(cid:13)∞ ≤(cid:80) (cid:13)(cid:13)(cid:126)vi − (cid:126)v1 i(cid:54)=1 ti 11.2 Matroid Intersection Let M1 = (E,I1) and M2 = (E,I2) be two matroids sharing the same ground set. In this section we consider the weighted matroid intersection problem where (cid:126)w ∈ RE and w(S) def=(cid:80) e∈S we. min S∈I1∩I2 (cid:126)w(S). For any matroid M = (E,I), it is well known that the polytope of all independent sets has the following description [28]: conv(I1) = {(cid:126)x ∈ RE s.t. 0 ≤ x(S) ≤ r(S) for all S ⊆ E} (11.12) where r is the rank function for M , i.e. r(S) is the size of the largest independent set that is a subset of S. Furthermore, the polytope of the matroid intersection satisfies conv(I1 ∩ I2) = conv(I1) ∩ conv(I2). It is well known that the optimization problem min S∈I1 w(S) and min S∈I2 w(S) can be solved efficiently by the greedy method. Given a matroid (polytope), the greedy method finds a maximum weight independent subset by maintaining a candidate independent subset S and iteratively attempts to add new element to S in descending weight. A element i is added to S if S ∪ {i} is still independent. A proof of this algorithm is well-known and can be found in any standard textbook on combinatorial optimization. Clearly, the greedy method can be implemented by O(n) calls to the independence oracle (also called membership oracle). For rank oracle, it requires O(r log n) calls by finding the next element to add via binary search. Therefore, we can apply Theorem 49 to get the following result (note that this algorithm is the fastest if r is close to n for the independence oracle). Theorem 52. Suppose that the weights (cid:126)w are integer with(cid:13)(cid:13)w(cid:13)(cid:13)∞ ≤ M . Then, we can find (cid:16) in time O nGO log (nM ) + n3 logO(1) (nM ) w(S) S ∈ arg min S∈I1∩I2 where GO is the cost of greedy method for I1 and I2. (cid:17) 66 Proof. Applying Lemma 51, we can find a new cost (cid:126)z such that min (cid:126)zT (cid:126)x (cid:126)x∈conv(I1)∩conv(I2) (cid:126)x ∈ conv(I1) and (cid:126)y ∈ conv(I2). Using (11.12), we have the coordinate wise minimum of (cid:126)x, (cid:126)y, i.e. has an unique solution. Note that for any (cid:126)x ∈ conv(I1), we have (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)∞ ≤ 1. Hence, applying theorem 49, we can find (cid:126)q such that (cid:126)qT (cid:126)z ≤ OPT +  and (cid:13)(cid:13)(cid:126)q − (cid:126)x(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)q − (cid:126)y(cid:13)(cid:13)2 ≤  for some min{(cid:126)x, (cid:126)y}, is in conv(I1) ∩ conv(I2). Since(cid:13)(cid:13)(cid:126)q − min{(cid:126)x, (cid:126)y}(cid:13)(cid:13)2 ≤(cid:13)(cid:13)(cid:126)q − (cid:126)x(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)q − (cid:126)y(cid:13)(cid:13)2 ≤ , we have (cid:13)(cid:13) min((cid:126)x, (cid:126)y)−(cid:126)s(cid:13)(cid:13)∞ ≤ 2n2M 2 where (cid:126)s is the optimal solution. Hence, we have(cid:13)(cid:13)(cid:126)q−(cid:126)s(cid:13)(cid:13)∞ ≤ 2n2M 2+. Hence, we have a feasible point min{(cid:126)x, (cid:126)y} which has value close to optimal and Lemma 51 shows that (min{(cid:126)x, (cid:126)y})T (cid:126)z ≤ OPT + nM . Picking  = 1 to the nearest integer. 2 and hence, we can get the optimal solution by rounding Since optimization over I1 and I2 involves applying greedy method on certain vectors, it takes in finding nGO log (nM ) + n3 logO(1) (nM ) 6n2M 2 , we have(cid:13)(cid:13)(cid:126)q − (cid:126)s(cid:13)(cid:13)∞ < 1 (cid:16) (cid:17) only O(GO) time. Theorem 49 shows it only takes O such (cid:126)q. This gives the following corollary. Corollary 53. We have O(n2Tind log(nM )+n3 logO(1) nM ) and O(nrTrank log n log(nM )+n3 logO(1) nM ) time algorithms for weighted matroid intersection. Here Tind is the time needed to check if a subset is independent, and Trank is the time needed to compute the rank of a given subset. Proof. By Theorem 52, it suffices to show that the optimization oracle for the matroid polytope can be implemented in O(nTind) and O(rTrank log n) time. This is simply attained by the well-known greedy algorithm which iterates through all the positively-weighted elements in decreasing order, and adds an element to our candidate independent set whenever possible. For the independence oracle, this involves one oracle call for each element. On the other hand, for the rank oracle, we can find the next element to add by binary search which takes time O(Trank log n). Since there are at most r elements to add, we have the desired running time. 11.3 Submodular Flow Let G = (V, E) be a directed graphwith E = m, let f be a submodular function on RV with V = n, f (∅) = 0 and f (V ) = 0, and let A be the incidence matrix of G. In this section we consider the submodular flow problem Minimize subject to (cid:104)c, ϕ(cid:105) l(e) ≤ ϕ(e) ≤ u(e) ∀e ∈ E x(v) = (Aϕ)(v) ∀v ∈ V x(v) ≤ f (S) ∀S ⊆ V (cid:88) (11.13) where c ∈ ZE, l ∈ ZE, u ∈ ZE where C =(cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)∞ and U = max(cid:0)(cid:13)(cid:13)u(cid:13)(cid:13)∞,(cid:13)(cid:13)l(cid:13)(cid:13)∞, maxS⊂V f (S)(cid:1). Here c is the cost on edges, ϕ is the flow on edges, l and u are lower and upper bounds on the amount of flow on the edges, and x(v) is the net flow out of vertex v. The submodular function f upper bounds the total net flow out of any subset S of vertices by f (S). v∈S 67 (cid:17) (cid:16) Theorem 54. Suppose that the cost vector (cid:126)c is integer weight with (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)∞ ≤ C and the capacity vector and the submodular function satisfy U = max(cid:0)(cid:13)(cid:13)u(cid:13)(cid:13)∞,(cid:13)(cid:13)l(cid:13)(cid:13)∞, maxS⊂V f (S)(cid:1). Then, we can where n2EO log(mCU ) + n3 logO(1)(mCU ) solve the submodular flow problem (11.13) in time O EO is the cost of function evaluation. Proof. First, we can assume l(e) ≤ u(e) for every edge e, otherwise, the problem is infeasible. Now, we apply a similar transformation in [49] to modify the graph. We create a new vertex v0. For every vertex v in V , we create a edge from v0 to v with capacity lower bounded by 0, upper bounded by 4nU , and with cost 2mCU . Edmonds and Giles showed that the submodular flow polytope is integral [29]. Hence, there is an integral optimal flow on this new graph. If the optimal flow passes through the newly created edge, then it has cost at least 2mCU − mCU because the cost of all other edges in total has at least −mCU . That means the optimal flow has the cost larger than mCU which is impossible. So the optimal flow does not use the newly created edges and vertex and hence the optimal flow in the new problem gives the optimal solution of the original problem. Next, we note that for any ϕ on the original graph such that l(e) ≤ ϕ(e) ≤ u(e), we can send suitable amount of flow from v0 to v to make ϕ feasible. Hence, this modification makes the feasibility problem trivial. Lemma 51 shows that we can assume the new problem has an unique solution and it only blows up C by a (mU )O(1) factors. Note that the optimal value is an integer and its absolute value at most mCU . By binary search, we can assume we know the optimal value OPT. Now, we reduce the problem to finding a feasible ϕ with {(cid:104)d, ϕ(cid:105) ≤ OPT + } with  determined later. Let P be the set of such ϕ. Note that P = K1, ∩ K2, where K1, = x ∈ RV such that (cid:40) Note that the extra condition (cid:80) y ∈ RV such that K2, = l(e) ≤ ϕ(e) ≤ u(e) ∀e ∈ E x(v) = (Aϕ)(v) ∀v ∈ V for some ϕ (cid:88) (cid:104)d, ϕ(cid:105) ≤ OPT +  (cid:88) v y(v) = (cid:80) v y(v) = f (V ) is valid because (cid:80) y(v) ≤ f (S) ∀S ⊆ V, v∈S v∈V y(v) = f (V ) .  , (cid:41) v(Aϕ)(v) = 0 and f (V ) = 0, and K1, has radius bounded by O((mCU )O(1)) and K2, has radius bounded by O(nU ). Furthermore, for any vector (cid:126)c ∈ RV , we note that (cid:104)c, x(cid:105) = max x∈K1, l≤ϕ≤u,(cid:104)d,ϕ(cid:105)≤OPT+,x=Aϕ max (cid:104)c, x(cid:105) (cid:104)c, Aϕ(cid:105) (cid:10)AT c, ϕ(cid:11) . = = max l≤ϕ≤u,(cid:104)d,ϕ(cid:105)≤OPT+ max l≤ϕ≤u,(cid:104)d,ϕ(cid:105)≤OPT+ To solve this problem, again we can do a binary search on (cid:104)d, ϕ(cid:105) and reduce the problem to (cid:10)AT c, ϕ(cid:11) max l≤ϕ≤u,(cid:104)d,ϕ(cid:105)=K for some value of K. Since AT c is fixed, this is a linear program with only the box constraints and an extra equality constraint. Hence, it can be solved in nearly linear time [76, Thm 17, ArXiv v1]. As the optimization oracle for K1, involves only computing AT c and solving this simple linear program, it takes only O(n2 logO(1)(mCU/)) time. On the other hand, since K2, is just a base 68 Applying Theorem 49, we can find q such that (cid:13)(cid:13)q − x(cid:13)(cid:13)2 +(cid:13)(cid:13)q − y(cid:13)(cid:13)2 ≤ δ for some x ∈ K1,, l(e) ≤ ϕ(e) ≤ u(e) and x(v) = (Aϕ)(v) for all v and (cid:104)d, ϕ(cid:105) ≤ OPT + . Since(cid:13)(cid:13)y − x(cid:13)(cid:13)2 ≤ 2δ, that polyhedron, the optimization oracle for K2, can be done by greedy method and only takes O(nEO) time. y ∈ K2, and δ to be chosen later. According to the definition of K1,, there is ϕ such that means y(v) − (Aϕ)(v) ≤ 2δ for all v. • Case 1) If y(v) ≥ (Aϕ)(v), then we can replace y(v) by (Aϕ)(v), note that y is still in K2, because of the submodular constraints. • Case 2) If y(v) ≤ (Aϕ)(v), then we can send a suitable amount of flow from v0 to v to make ϕ feasible y(v) ≤ (Aϕ)(v). for some constant c, then we can guarantee that(cid:13)(cid:13)y − x∗(cid:13)(cid:13)∞ ≤ 1 Now, we note that(cid:13)(cid:13)q − y(cid:13)(cid:13)2 ≤ δ and we note that we only modify y by a small amount, we in fact have(cid:13)(cid:13)q − x∗(cid:13)(cid:13)∞ < 1 Note that under this modification, we increased the objective value by (δn)(2mCU ) because the new edge cost 2mCU per unit of flow. Hence, we find a flow ϕ which is feasible in new graph with objective value  + (δn)(2mCU ) far from optimum value. By picking δ = 2mnCU , we have the value 2 far from OPT. Now, we use Lemma 51 to shows that when  is small enough, i.e, (mCU )c 4 where x∗ is the optimal demand. 2 . Hence, we can read off the solution x∗ by rounding q to the nearest integer. Note that we only need to solve the problem K1,∩ K2, to (mCU )Θ(1) accuracy and the optimization oracle for K1, and K2, takes time O(n2 logO(1)(mCU )) and O(nEO) respectively. Hence, Theorem 49 shows that it takes O √ [74], which takes O(m After getting x∗, one can find ϕ∗ by solving a min cost flow problem using interior point method n logO(1)(mCU )) time. n2EO log(mCU ) + n3 logO(1)(mCU ) time to find x∗ exactly. 1 1 (cid:16) 1 (cid:17) 11.4 Affine Subspace of Convex Set In this section, we give another example about using optimization oracle directly via regularization. We consider the following optimization problem max (cid:126)x∈K and A(cid:126)x=(cid:126)b (cid:104)(cid:126)c, (cid:126)x(cid:105) (11.14) where (cid:126)x, (cid:126)c ∈ Rn, K is a convex subset of Rn, A ∈ Rr×n and (cid:126)b ∈ Rm. We suppose that r (cid:28) n and thus, the goal of this subsection is to show how to obtain an algorithm takes only O(r) many iterations. To do this, we assume a slightly stronger optimization oracle for K: Definition 55. Given a convex set K and δ > 0. A δ-2nd-order-optimization oracle for K is a function on Rn such that for any input (cid:126)c ∈ Rn and λ > 0, it outputs (cid:126)y such that (cid:16)(cid:104)(cid:126)c, (cid:126)x(cid:105) − λ(cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2(cid:17) ≤ δ + (cid:104)(cid:126)c, (cid:126)y(cid:105) − λ(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2. max (cid:126)x∈K We denote by OO(2) δ,λ(K) the time complexity of this oracle. The strategy for solving this problem is very similar to the intersection problem and hence some details are omitted. 69 Theorem 56. Assume that max(cid:126)x∈K (cid:107)(cid:126)x(cid:107)2 < M ,(cid:13)(cid:13)(cid:126)b(cid:13)(cid:13)2 < M ,(cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 < M ,(cid:13)(cid:13)A(cid:13)(cid:13)2 < M and λmin(A) > 1/M . Assume that K ∩{A(cid:126)x = (cid:126)b} (cid:54)= ∅ and we have -2nd-order-optimization oracle for every  > 0. For 0 < δ < 1, we can find (cid:126)z ∈ K such that (cid:104)(cid:126)c, (cid:126)x(cid:105) ≤ δ + (cid:104)(cid:126)c, (cid:126)z(cid:105) max (cid:126)x∈K and A(cid:126)x=(cid:126)b and(cid:13)(cid:13)A(cid:126)z − (cid:126)b(cid:13)(cid:13)2 ≤ δ. This algorithm takes time (cid:18) nM (cid:19) where r is the number of rows in A, η =(cid:0) δ (cid:1)Θ(1) η,λ(K) log rOO(2) (cid:18) O δ nM Proof. The proof is based on the minimax problem (cid:104)(cid:126)c, (cid:126)x(cid:105) + def= min OPTλ (cid:13)(cid:13)(cid:126)η (cid:13)(cid:13)2 max (cid:126)x∈K ≤λ where λ =(cid:0) δ nM (cid:1)c + r3 logO(1) and λ =(cid:0) δ (cid:68) (cid:126)η, A(cid:126)x − (cid:126)b nM for some large constant c. We note that (cid:68) min (cid:104)(cid:126)c, (cid:126)x(cid:105) + (cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)η (cid:104)(cid:126)c, (cid:126)x(cid:105) − λ(cid:13)(cid:13)A(cid:126)x − (cid:126)b(cid:13)(cid:13)2 − 1 (cid:126)η, A(cid:126)x − (cid:126)b ≤λ λ OPTλ = max (cid:126)x∈K = max (cid:126)x∈K . δ (cid:19)(cid:19) (cid:18) nM (cid:1)Θ(1) (cid:69) − 1 (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:69) − 1 (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 λ λ 2 2 2. Since λmin(A) > 1/M and the set K is bounded by M , one can show that the saddle point ((cid:126)x∗, (cid:126)η∗) of the minimax problem gives a good enough solution (cid:126)x for the original problem for large enough constant c. For any (cid:126)η, we define (cid:126)x(cid:126)η = arg max (cid:126)x∈K (cid:104)(cid:126)c, (cid:126)x(cid:105) + (cid:68) (cid:18) nM (cid:126)η, A(cid:126)x − (cid:126)b (cid:69) − 1 (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 (cid:19)O(c)(cid:13)(cid:13)(cid:126)η − (cid:126)η∗(cid:13)(cid:13)2. λ 2. δ (cid:13)(cid:13)(cid:126)x(cid:126)η − (cid:126)x∗(cid:13)(cid:13)2 ≤ Since the problem is strongly concave in (cid:126)x, one can prove that (cid:68) (cid:69)− (cid:13)(cid:13)(cid:126)x(cid:13)(cid:13)2 1 λ Hence, we can first find an approximate minimizer of the function f ((cid:126)η) = max(cid:126)x∈K (cid:104)(cid:126)c, (cid:126)x(cid:105)+ (cid:126)η, A(cid:126)x − (cid:126)b 2 and use the oracle to find (cid:126)x(cid:126)η. To find an approximate minimizer of f , we note that the subgradient of f can be found using the optimization oracle similar to Theorem 49. Hence, the result follows from our cutting plane method and the fact that (cid:126)η ∈ Rr. Remark 57. In [74], they considered the special case K = {(cid:126)x : 0 ≤ xi ≤ 1} and showed that it can be solved in O( r) iterations using interior point methods. This gives the current fastest algorithm for the maximum flow problem on directed weighted graphs. Our result generalizes their result to any convex set K but with O(r) iterations. This suggests the following open problem: under what condition on K can one optimize linear functions over affine subspaces of K with r constraints in O( r) iterations? √ √ 70 Part III Submodular Function Minimization 12 Introduction Submodular functions and submodular function minimization (SFM) are fundamental to the field of combinatorial optimization. Examples of submodular functions include graph cut functions, set coverage function, and utility functions from economics. Since the seminal work by Edmonds in 1970 [27], submodular functions and the problem of minimizing such functions (i.e. submodular function minimization) have served as a popular modeling and optimization tool in various fields such as theoretical computer science, operations research, game theory, and most recently, machine learning. Given its prevalence, fast algorithms for SFM are of immense interest both in theory and in practice. Throughout Part III, we consider the standard formulation of SFM: we are given a submodular function f defined over the subsets of a n-element ground set. The values of f are integers, have absolute value at most M , and are evaluated by querying an oracle that takes time EO. Our goal is to produce an algorithm that solves this SFM problem, i.e. finds a minimizer of f , while minimizing both the number of oracle calls made and the total running time. We provide new O(n2 log nM · EO + n3 logO(1) nM ) and O(n3 log2 n · EO + n4 logO(1) n) time algorithms for SFM. These algorithms improve upon the previous fastest weakly and strongly polynomial time algorithms for SFM which had a a running time of O((n4 · EO + n5) log M ) [54] and O(n5 · EO + n6) [90] respectively. Consequently, we improve the running times in both regimes by roughly a factor of O(n2). Both of our algorithms bear resemblance to the classic approach of Grotschel, Lov´asz and Schrijver [49, 50] using the Lov´asz extension. In fact our weakly polynomial time algorithm directly uses the Lov´asz extension as well as the results of Part II to achieve these results. Our strongly polynomial time algorithm also uses the Lov´asz extension, along with more modern tools from the past 15 years. At a high level, our strongly polynomial algorithms apply our cutting plane method in con- junction with techniques originally developed by Iwata, Fleischer, and Fujishige (IFF) [56]. Our cutting plane method is performed for enough iterations to sandwich the feasible region in a narrow strip from which useful structural information about the minimizers can be deduced. Our ability to derive the new information hinges on a significant extension of IFF techniques. Over the past few decades, SFM has drawn considerable attention from various research com- munities, most recently in machine learning [11, 68]. Given this abundant interest in SFM, we hope that our ideas will be of value in various practical applications. Indeed, one of the critiques against existing theoretical algorithms is that their running time is too slow to be practical. Our contribu- tion, on the contrary, shows that this school of algorithms can actually be made fast theoretically and we hope it may potentially be competitive against heuristics which are more commonly used. 71 12.1 Previous Work Here we provide a brief survey of the history of algorithms for SFM. For a more comprehensive account of the rich history of SFM, we refer the readers to recent surveys [81, 55]. The first weakly and strongly polynomial time algorithms for SFM were based on the ellipsoid method [65] and were established in the foundational work of Grotschel, Lov´asz and Schrijver in 1980’s [49, 50]. Their work was complemented by a landmark paper by Cunningham in 1985 which provided a pseudopolynomial algorithm that followed a flow-style algorithmic framework [20]. His tools foreshadowed much of the development in SFM that would take place 15 years later. Indeed, modern algorithms synthesize his framework with inspirations from various max flow algorithms. The first such “flow style” strongly polynomial algorithms for SFM were discovered indepen- dently in the breakthrough papers by Schrijver [93] and Iwata, Fleischer, and Fujishige (IFF) [56]. Schrijver’s algorithm has a running of O(n8 · EO + n9) and borrows ideas from the push-relabel algorithms [46, 25] for the maximum flow problem. On the other hand, IFF’s algorithm runs in time O(n7 log n·EO) and O(n5·EO log M ), and applies a flow-scaling scheme with the aid of certain proximity-type lemmas as in the work of Tardos [100]. Their method has roots in flow algorithms such as [52, 47]. Subsequent work on SFM provided algorithms with considerably faster running time by extend- ing the ideas in these two “genesis” papers [93, 56] in various novel directions [107, 31, 54, 90, 60]. Currently, the fastest weakly and strongly polynomial time algorithms for SFM have a running time of O((n4 · EO + n5) log M ) [54] and O(n5 · EO + n6) [90] respectively. Despite this impressive track record, the running time has not been improved in the last eight years. We remark that all of the previous algorithms for SFM proceed by maintaining a convex com- bination of O(n) BFS’s of the base polyhedron, and incrementally improving it in a relatively local manner. As we shall discuss in Section 12.2, our algorithms do not explicitly maintain a convex combination. This may be one of the fundamental reasons why our algorithms achieve a faster running time. Finally, beyond the distinction between weakly and strongly polynomial time algorithms for SFM, there has been interest in another type of SFM algorithm, known as fully combinatorial algorithms in which only additions and subtractions are permitted. Previous such algorithms include [60, 54, 53]. We do not consider such algorithms in the remainder of the paper and leave it as an open question if it is possible to turn our algorithms into fully combinatorial ones. 12.2 Our Results and Techniques In Part III we show how to improve upon the previous best known running times for SFM by a factor of O(n2) in both the strongly and weakly polynomial regimes. In Table 11 summarizes the running time of the previous algorithms as well as the running times of the fastest algorithms presented in this paper. Both our weakly and strongly polynomial algorithms for SFM utilize a convex relaxation of the submodular function, called the Lov´asz extension. Our algorithms apply our cutting plane method from Part I using a separation oracle given by the subgradient of the Lov´asz extension. To the best of the author’s knowledge, Grotschel, Lov´asz and Schrijver were the first to formulate this convex optimization framework for SFM [49, 50]. For weakly polynomial algorithms, our contribution is two-fold. First, we show that cutting plane methods such as Vaidya’s [105] can be applied to SFM to yield faster algorithms. Second, as our cutting plane method, Theorem 42, improves upon previous cutting plane algorithms and consequently the running time for SFM as well. This gives a running time of O(n2 log nM · EO + 72 Authors Years Grotschel, Lov´asz, Schrijver [49, 50] Cunningham [20] Schrijver [93] Iwata, Fleischer, Fujishige[56] Iwata, Fleischer [31] Iwata [54] Vygen [107] Orlin [90] Iwata, Orlin [60] 1981,1988 1985 2000 2000 2000 2003 2003 2007 2009 Our algorithms 2015 Running times (cid:101)O(n5 · EO + n7)[81] Remarks first weakly and strongly first pseudopoly first combin. strongly first combin. strongly current best weakly current best strongly O(M n6 log nM · EO) O(n8 · EO + n9) O(n5 · EO log M ) O(n7 log n · EO) O(n7 · EO + n8) O((n4 · EO + n5) log M ) O((n6 · EO + n7) log n) O(n7 · EO + n8) O(n5 · EO + n6) O((n4 · EO + n5) log nM ) O((n5 · EO + n6) log n) O(n2 log nM · EO + n3 logO(1) nM ) O(n3 log2 n · EO + n4 logO(1) n) Table 11: Algorithms for submodular function minimization. Note that some of these algorithms were published in both conferences and journals, in which case the year we provided is the earlier one. n3 logO(1) nM ), an improvement over the previous best algorithm by Iwata [54] by a factor of almost O(n2). Our strongly polynomial algorithms, on the other hand, require substantially more innovation. We first begin with a very simple geometric argument that SFM can be solved in O(n3 log n · EO) oracle calls (but in exponential time). This proof only uses Grunbaum’s Theorem from convex geometry and is completely independent from the rest of the paper. It was the starting point of our method and suggests that a running time of (cid:101)O(n3 · EO + nO(1)) for submodular minimization is in principle achievable. To make this existence result algorithmic, we first run cutting plane, Theorem 31, for enough iterations such that we compute either a minimizer or a set P containing the minimizers that fits within in a narrow strip. This narrow strip consists of the intersection of two approximately parallel hyperplanes. If our narrow strip separates P from one of the faces xi = 0, xi = 1, we can effectively eliminate the element i from our consideration and reduce the dimension of our problem by 1. Otherwise a pair of elements p, q can be identified for which q is guaranteed to be in any minimizer containing p (but p may not be contained in a minimizer). Our first algorithm deduces only one such pair at a time. This technique immediately suffices to achieve a (cid:101)O(n4 · EO + n5) time algorithm for SFM (See Section 15.3). We then improve the running time to (cid:101)O(n3 · EO + n4) by showing how to deduce many such pairs simultaneously. Similar to past algorithms, this structural information is deduced from a point in the so-called base polyhedron (See Section 13). Readers well-versed in SFM literature may recognize that our strongly polynomial algorithms are reminiscent of the scaling-based approach first used by IFF [56] and later in [54, 60]. While both approaches share the same skeleton, there are differences as to how structural information about minimizers is deduced. A comparison of our algorithms and previous ones are presented in Section 16. Finally, there is one more crucial difference between these algorithms which we believe is re- sponsible for much of our speedup. One common feature shared by all the previous algorithms is 73 that they maintain a convex combination of O(n) BFS’s of the base polyhedron, and incrementally improve on it by introducing new BFS’s by making local changes to existing ones. Our algorithms, on the other hand, choose new BFS’s by the cutting plane method. Because of this, our algorithm considers the geometry of the existing BFS’s where each of them has influences over the choice of the next BFS. In some sense, our next BFS is chosen in a more “global” manner. 12.3 Organization The rest of Part III is organized as follows. We first begin with a gentle introduction to submodular functions in Section 13. In Section 14, we apply our cutting plane method to SFM to obtain a faster weakly polynomial algorithms. In Section 15 we then present our results for achieving better strongly polynomial algorithms, where a warm-up (cid:101)O(n4 · EO + n5) algorithm is given before the full-fledged (cid:101)O(n3 · EO + n4) algorithm. Finally, we end the part with a discussion and comparison between our algorithms and previous ones in Section 16. We note that there are a few results in Part III that can be read fairly independently of the In Theorem 67 we show how Vaidya’s algorithm can be applied to SFM to rest of the paper. obtain a faster weakly polynomial running time. Also in Theorem 71 we present a simple geometric argument that SFM can be solved with O(n3 log n · EO) oracle calls but with exponential time. These results can be read with only a working knowledge of the Lov´asz extension of submodular functions. 13 Preliminaries Here we introduce background on submodular function minimization (SFM) and notation that we use throughout Part III. Our exposition is kept to a minimal amount sufficient for our purposes. We refer interested readers to the extensive survey by McCormick [81] for further intuition. 13.1 Submodular Function Minimization Throughout the rest of the paper, let V = {1, ..., n} = [n] denote a ground set and let f : 2V −→ Z denote a submodular function defined on subsets of this ground set. We use V and [n] interchange- ably and let [0] def= ∅. We abuse notation by letting S + i def= S ∪ {i} and S − i def= S\{i} for an element i ∈ V and a set S ⊆ 2V . Formally, we call a function submodular if it obeys the following property of diminishing marginal differences: Definition 58 (Submodularity). A function f : 2V −→ Z is submodular if f (T + i) − f (T ) ≤ f (S + i) − f (S) for any S ⊆ T and i ∈ V \T . For convenience we assume without loss of generality that f (∅) = 0 by replacing f (S) by f (S) − f (∅) for all S. We also let M def= maxS∈2V f (S). The central goal of Part III is to design algorithms for SFM, i.e. computing the minimizer of f . We call such an algorithm strongly polynomial if its running time depends only polynomially on n and EO, the time needed to compute f (S) for a set S, and we call such an algorithm weakly polynomial if it also depends polylogarithmically on M . 13.2 Lov´asz Extension Our new algorithms for SFM all consider a convex relaxation of a submodular function, known as the Lov´asz extension, and then carefully apply our cutting plane methods to it. Here we formally introduce the Lov´asz extension and present basic facts that we use throughout Part III. 74 The Lov´asz extension of f : [0, 1]n −→ R of our submodular function f is defined for all (cid:126)x by f ((cid:126)x) def= Et∼[0,1][f ({i : xi ≥ t})], where t ∼ [0, 1] is drawn uniformly at random from [0, 1]. The Lov´asz extension allows us to reduce SFM to minimizing a convex function defined over the interior of the hypercube. Below we state that the Lov´asz extension is a convex relaxation of f and that it can be evaluated efficiently. Theorem 59. The Lov´asz extension f satisfies the following properties: 1. f is convex and min(cid:126)x∈[0,1]n f ((cid:126)x) = minS⊂[n] f (S); 2. f (S) = f (IS), where IS is the characteristic vector for S, i.e. IS(i) = (cid:40) 1 0 if i ∈ S if i /∈ S ; 3. If S is a minimizer of f , then IS is a minimizer of f ; 4. Suppose x1 ≥ ··· ≥ xn ≥ xn+1 def= 0, then n(cid:88) f ((cid:126)x) = n(cid:88) f ([i])(xi − xi+1) = (f ([i]) − f ([i − 1]))xi . i=1 i=1 Proof. See [50] or any standard textbook on combinatorial optimization, e.g. [94]. Next we show that we can efficiently compute a subgradient of the Lov´asz or alternatively, a separating hyperplane for the set of minimizers of our submdoular function f . First we remind the reader of the definition of a separation oracle, and then we prove the necessary properties of the hyperplane, Theorem 61. Definition 60 (separation oracle, Defintion 1 restated for Lov´asz extension). Given a point ¯x and a convex function f over a convex set P , (cid:126)aT (cid:126)x ≤ b is a separating hyperplane if (cid:126)aT ¯x ≥ b and any minimizer x∗ of f over P satisfies (cid:126)aT x∗ ≤ b. Theorem 61. Given a point ¯x ∈ [0, 1]n assume without loss of generality (by re-indexing the coordinates) that ¯x1 ≥ ··· ≥ ¯xn. Then the following inequality is a valid separating hyperplane for (cid:126)x and f : n(cid:88) i=1 (f ([i]) − f ([i − 1]))xi ≤ f (¯x) i.e., it satisfies the following: 1. (separating) ¯x lies on(cid:80)n 2. (valid) For any (cid:126)x, we have (cid:80)n f ([i − 1]))x∗ any minimizer. i=1(f ([i]) − f ([i − 1]))xi ≤ f (¯x). i=1(f ([i]) − f ([i − 1]))xi ≤ f ((cid:126)x). In particular, (cid:80)n i=1(f ([i]) − i ≤ f (¯x) for any minimizer (cid:126)x∗, i.e. the separating hyperplane does not cut out Moreover, such a hyperplane can be computed with n oracle calls to f and in time O(n · EO + n2). 75 Proof. Note that by Theorem 59 we have that (cid:80) i∈[n](f ([i]) − f ([i − 1]))xi = f (¯x) and thus the hyperplane satisfies the separating condition. Moreover, clearly computing it only takes time O(n· EO + n2) as we simply need to sort the coordinates and evaluate f at n points, i.e. each of the [i]. All that remains is to show that the hyperplane satisfies the valid condition. Let L(t) def= {i : xi ≥ t}. Recall that f ((cid:126)x) = Et∼[0,1][f (Lt)]. Thus f ((cid:126)x) can be written as a t αt = 1. However, by diminishing t αtf (L(t)), where αt ≥ 0 and(cid:80) convex combination f ((cid:126)x) =(cid:80) marginal differences we see that for all t (f ([i]) − f ([i − 1])) (IL(t))i = (f ([i]) − f ([i − 1])) (cid:88) ≤ (cid:88) i∈L(t) (cid:16) (cid:17) f ([i] ∩ L(t)) − f ([i − 1] ∩ L(t)) i∈L(t) = f (L(t)) − f (∅) = f (L(t)) (cid:88) i∈[n] and therefore since(cid:80) (cid:88) i∈[n] (f [i] − f ([i − 1])xi = αt t αtIL(t) = (cid:126)x we have (cid:88) n(cid:88) (f ([i]) − f ([i − 1])) (IL(t))i ≤(cid:88) t i=1 t αtf (L(t)) = f ((cid:126)x). 13.3 Polyhedral Aspects of SFM Here we provide a natural primal dual view of SFM that we use throughout the analysis. We provide a dual convex optimization program to minimizing the Lov´asz extension and provide several properties of these programs. We believe the material in this section helps crystallize some of the intuition behind our algorithm and we make heavy use of the notation presented in this section. However, we will not need to appeal to the strong duality of these programs in our proofs. Consider the following primal and dual programs, where we use the shorthands y(S) =(cid:80) i∈S yi and y− i = min{0, yi}. Here the primal constraints are often called the base polyhedron B(f ) def= {(cid:126)y ∈ Rn : y(S) ≤ f (S)∀S (cid:54)⊆ V, y(V ) = f (V )} and the dual program directly corresponds to minimizing the Lov´asz extension and thus f . Primal maxy−(V ) y(S) ≤ f (S)∀S (cid:54)⊆ V y(V ) = f (V ) Dual min f ((cid:126)x) 0 ≤ (cid:126)x ≤ 1 Theorem 62. (cid:126)h is a basic feasible solution (BFS) of the base polyhedron B(f ) if and only if hi = f ({v1, ..., vi}) − f ({v1, ..., vi−1}) for some permutation v1, ..., vn of the ground set V . We call v1, ..., vn the defining permutation of (cid:126)h. We call vi precedes vj for i < j. This theorem gives a nice characterization of the BFS’s of B(f ). It also gives the key observation underpinning our approach: the coefficients of each separating hyperplane in Theorem 61 precisely corresponds to a primal BFS (Theorem 62). Our analysis relies heavily on this connection. We re-state Theorem 61 in the language of BFS. 76 Lemma 63. We have (cid:126)hT (cid:126)x ≤ f ((cid:126)x) for any (cid:126)x ∈ [0, 1]n and BFS (cid:126)h. Proof. Any BFS is given by some permutation. Thus this is just Theorem 61 in disguise. We also note that since the objective function of the primal program is non-linear, we cannot say that the optimal solution to the primal program is a BFS. Instead we only know that it is a convex combination of the BFS’s that satisfy the following property. A proof can be found in any standard textbook on combinatorial optimization. exists a primal optimal solution (cid:126)y =(cid:80) k λ(k)(cid:126)h(k) with (cid:80) Theorem 64. The above primal and dual programs have no duality gap. Moreover, there always k λ(k) = 1 (a convex combination of BFS (cid:126)h(k)) s.t. any i with yi < 0 precedes any j with yj > 0 in the defining permutation for each BFS (cid:126)h(k). Our algorithms will maintain collections of BFS and use properties of (cid:126)h ∈ B(f ), i.e. convex combination of BFS. To simplify our analysis at several points we will want to assume that such a vector (cid:126)h ∈ B(f ) is non-degenerate, meaning it has both positive and negative entries. Below, we prove that such degenerate points in the base polytope immediately allow us to trivially solve the SFM problem. Lemma 65 (Degenerate Hyperplanes). If (cid:126)h ∈ B(f ) is non-negative then ∅ is a minimizer of f and if (cid:126)h is non-positive then V is a minimizer of f . Proof. While this follows immediately from Theorem 64, for completeness we prove this directly. Let S ∈ 2V be arbitrary. If (cid:126)h ∈ B(f ) is non-negative then by the we have On the other hand if (cid:126)h is non-positive then by definition we have f (S) ≥ (cid:126)h(S) = hi = h(V ) = f (V ) . f (S) ≥ (cid:126)h(S) = hi ≥ 0 = f (∅) . i∈S (cid:88) hi ≥(cid:88) i∈V (cid:88) i∈S Improved Weakly Polynomial Algorithms for SFM 14 In this section we show how our cutting plane method can be used to obtain a O(n2 log nM · EO + n3 logO(1) nM ) time algorithm for SFM. Our main result in this section is the following theorem, which shows how directly applying our results from earlier parts to minimize the Lov´asz extension yields the desired running time. Theorem 66. We have an O(n2 log nM · EO + n3 logO(1) nM ) time algorithm for submodular function minimization. Proof. We apply Theorem 42 to the Lov´asz extension f : [0, 1]n −→ R with the separation oracle given by Theorem 61. f fulfills the requirement on the domain as its domain Ω = [0, 1]n is symmetric about the point (1/2, . . . , 1/2) and has exactly 2n constraints. In the language of Theorem 42, our separation oracle is a (0, 0)-separation oracle with η = 0 and δ = 0. 77 We first show that δ = 0. Firstly, our separating hyperplane can be written as n(cid:88) n(cid:88) (f ([i]) − f ([i − 1]))xi ≤ f (¯x) = (f ([i]) − f ([i − 1]))¯xi, i=1 i=1 where the equality follows from Theorem 59. Secondly, for any (cid:126)x with f ((cid:126)x) ≤ f (¯x) we have by Theorem 61 that (f ([i]) − f ([i − 1]))xi ≤ f ((cid:126)x) ≤ f (¯x) n(cid:88) i=1 f ((cid:126)x) ≥ n(cid:88) which implies that (cid:126)x is not cut away by the hyperplane. Next we show that η = 0. Our separating hyperplane induces a valid halfspace whenever it is not nonzero, i.e. f ([i]) (cid:54)= f ([i − 1]) for some i. In the case that it is zero f ([i]) = f ([i − 1])∀i, by the same argument above, we have f (¯x) =(cid:80)n i=1(f ([i]) − f ([i − 1]))¯xi = 0 and (f ([i]) − f ([i − 1]))xi = 0 = f (¯x). In other words, ¯x is an exact minimizer, i.e. η = 0. Note that (cid:12)(cid:12)(cid:12) =(cid:12)(cid:12)Et∼[0,1][f ({i : xi ≥ t})](cid:12)(cid:12) ≤ M as M = maxS f (S). Now plugging in α = 1 (cid:12)(cid:12)(cid:12) f ((cid:126)x) i=1 4M in the guarantee of Theorem 31, we can find a point x∗ such that (cid:19) f ((cid:126)x) − min (cid:126)x∈[0,1]n f ((cid:126)x) (cid:18) max (cid:126)x∈[0,1]n (2M ) f (x∗) − min (cid:126)x∈[0,1]n f ((cid:126)x) ≤ 1 4M 1 4M ≤ < 1 We claim that mint∈[0,1] f ({i : x∗ i ≥ t}) is minimum. To see this, recall from 59 that f has an integer minimizer and hence min(cid:126)x∈[0,1]n f ((cid:126)x) = minS f (S). Moreover, f (x∗) is a convex combination of f ({i : x∗ i ≥ t}) which gives 1 > f (x∗) − min (cid:126)x∈[0,1]n f ((cid:126)x) = f (x∗) − min f (S) ≥ min t∈[0,1] f ({i : x∗ i ≥ t}) − min S f (S). S Since f is integer-valued, we must then have mint∈[0,1] f ({i : x∗ i ≥ t}) = minS f (S) as desired. Since our separation oracle can be computed by n oracle calls and runs in time O(n · EO + n2), by Theorem 42 the overall running time is then O(n2 log nM · EO + n3 logO(1) nM ) as claimed. Needless to say the proof above completely depends on Theorem 42. We remark that one can use the Vaidya’s cutting plane instead of ours to get a time complexity O(n2 log nM · EO + nω+1 logO(1) n · log M ). There is actually an alternate argument that gives a time complexity of O(n2 log M · EO + nO(1) · log M ). Thus it requires slightly fewer oracle calls at the expense of slower running time. A proof is offered in this section, which can be skipped without any risk of discontinuation. This proof relies the following cutting plane method. Theorem 67 ([13] ). Given any convex set K ⊂ [0, 1]n with a separation oracle of cost SO, in time O(kSO + knO(1)) one can find either find a point (cid:126)x ∈ K or find a polytope P such that K ⊂ P and the volume of K is at most(cid:0) 2 (cid:1)k. 3 78 The Theorem allows us to decrease the volume of the feasible region by a factor of(cid:0) 2 (cid:1)k after 3 k iterations. Similar to above, we apply cutting plane to minimize f over the hypercube [0, 1]n for O(n log M ) iterations, and outputs any integral point in the remaining feasible region P . Lemma 68. Let x∗ achieve the minimum function value f (x∗) among the points used to query the separation oracle. Then 1. x∗ ∈ P (k), the current feasible region. 2. Any (cid:126)x with f ((cid:126)x) ≤ f (x∗) belongs to P (k). 3. suppose x∗ ≥ ··· ≥ x∗ i1 in P (k). and let Sj = {i1, . . . , ij}. Then Sl ∈ arg minSj f (Sj) also belongs to Proof. For any separating hyperplane (cid:126)hT x ≤ f (¯x) given by ¯x, we have by Lemma 63 that (cid:126)hT x∗ ≤ f (x∗). Since f (x∗) is the minimum among all f (¯x), (cid:126)hT x∗ ≤ f (¯x) and hence x∗ is not removed by any new separating hyperplane. In other words, x∗ ∈ P (k) . The argument for (2) is analogous. For (3), recall that by the definition of Lov´asz extension f (x∗) is a convex combination of f (Sj) and thus the indicator variable ISl for Sl satisfies f (ISl) ≤ f (x∗). By Lemma 63 again, this implies (cid:126)hT ISl ≤ f (ISl) ≤ f (x∗) ≤ f (¯x) for any separating hyperplane (cid:126)hT x ≤ f (¯x). Theorem 69. Suppose that we run Cutting Plane in Theorem 67 for O(n log M ) iterations. Then Sl from the last lemma also minimizes f . Proof. We use the notations from the last lemma. After k = Kn log2/3 M iterations, the volume of the feasible region P (k) is at most 1/M Kn. By the last lemma, ISl ∈ P (k). Suppose for the sake of contradiction that S minimizes f but f (S) < f (Sl). Since f is integer- valued, f (S) + 1 ≤ f (Sl). Let r def= 1/6M . Consider the set B def= {(cid:126)x : 0 ≤ xi ≤ r ∀i /∈ S, 1 − r ≤ xi ≤ 1 ∀i ∈ S}. We claim that for (cid:126)x ∈ B, f ((cid:126)x) ≤ f (S) + 1. To show this, note that f ({i : xi ≥ t}) = f (S) for r < t ≤ 1 − r as xi ≤ r for i /∈ S and xi ≥ 1 − r for i ∈ S. Now using conditional probability and f (T ) ≤ M for any T , f ((cid:126)x) = Et∼[0,1][f ({i : xi ≥ t})] = (1 − 2r) E[f ({i : xi ≥ t})r < t ≤ 1 − r] + r (E[f ({i : xi ≥ t})0 ≤ t ≤ r] + E[f ({i : xi ≥ t})1 − r ≤ t ≤ 1]]) = (1 − r) f (S) + r (E[f ({i : xi ≥ t})0 ≤ t ≤ r + E[f ({i : xi ≥ t})1 − r ≤ t ≤ 1]]) ≤ (1 − 2r) f (S) + 2rM ≤ f (S) + 4rM ≤ f (S) + 1 But now B ⊆ P (k) as f ((cid:126)x) ≤ f (S) + 1 ≤ f (Sl) and by (2) of the last lemma. This would lead to a contradiction since vol(B) = for sufficiently large K. 1 (6M )n > 1 M Kn ≥ vol(P (k)) 79 Corollary 70. There is an O(n2 log M · EO + nO(1) log M ) time algorithm for submodular function minimization. Proof. This simply follows from the last lemma, Theorem 67, and the fact that our separation oracle runs in time O(n · EO + n2). Curiously, we obtained O(log M ) rather than O(log nM ) as in our algorithm. We leave it as an open problem whether one can slightly improve our running time to O(n2 log M · EO + n3 logO(1) n· log M ). The rest of this paper is devoted to obtaining better strongly polynomial running time. 15 Improved Strongly Polynomial Algorithms for SFM In this section we show how our cutting plane method can be used to obtain a (cid:101)O(n3 · EO + n4) time algorithm for SFM, which improves over the currently fastest O(n5 · EO + n6) time algorithm by Orlin. Improved Oracle Complexity 15.1 We first present a simple geometric argument that f can be minimized with just O(n3 log n · EO) oracle calls. While this is our desired query complexity (and it improves upon the previous best known bounds by a factor of O(n2) unfortunately the algorithm runs in exponential time. Nevertheless, it does provide some insight into how our more efficient algorithms should proceed and it alone, does suggests that information theoretically, O(n3 log n·EO) calls suffice to solve SFM. In the rest of the paper, we combine this insight with some of the existing SFM tools developed over the last decade to get improved polynomial time algorithms. Theorem 71. Submodular functions can be minimized with O(n3 log n · EO) oracle calls. Proof. We use the cutting plane method in Theorem 67 with the separation oracle given by Theo- rem 61. This method reduce the volume of the feasible region by a factor of ( 2 3 )k after k iterations if the optimal has not found yet. Now, we argue that after O(n log n) iterations of this procedure we have either found a minimizer of f or we have enough information to reduce the dimension of the problem by 1. To see this, first note that if the separation oracle ever returns a degenerate hyperplane, then by Lemma 65 then either ∅ or V is the minimizer, which we can determine in time O(EO + n). Otherwise, after 100n log n iterations, our feasible region P must have a volume of at most 1/n10n . In this case, we claim that the remaining integer points in P all lie on a hyperplane. This holds, as if this was not the case, then there is a simplex (cid:52), with integral vertices v0, v1, . . . , vn, contained in P . But then vol(P ) ≥ vol((cid:52)) = 1 n! det (v1 − v0 v2 − v0 . . . vn − v0) ≥ 1 n! where the last inequality holds since the determinant of an integral matrix is integral, yielding a contradiction. In other words after O(n log n) iterations, we have reduced the dimension of all viable solutions by at least 1. Thus, we can recurse by applying the cutting plane method to the lower dimensional feasible region, i.e. P is (replaced by) the convex combination of all the remaining integer points. There is a minor technical issue we need to address as our space is now lower dimensional and the starting region is not necessarily the hypercube anymore and the starting volume is not necessarily equal to 1. 80 √ We argue that the starting volume is bounded by nO(n). If this is indeed the case, then our previous argument still works as the volume goes down by a factor of 1/nO(n) in O(n log n) iterations. Let v ∈ P be an integer point. Now the dim(P )-dimensional ball of radius n centered at v must contain all the other integer points in P as any two points of {0, 1}n are at most n apart. Thus the volume of P is bounded by the volume of the ball which is nO(n). Now to get the volume down to 1/n10n, the number of iterations is still O(n log n). In summary, we have reduced our dimension by 1 using O(n log n) iterations which requires O(n2 log n · EO) oracle calls (as each separating hyperplane is computed with n · EO oracle calls). This can happen at most n times. The overall query complexity is then O(n3 log n · EO). Note that the minimizer (cid:126)x obtained may not be integral. This is not a problem as the definition of Lov´asz extension implies that if f ((cid:126)x) is minimal, then f ({i : xi ≥ t}) is minimal for any t ∈ [0, 1]. We remark that this algorithm does not have a polynomial runtime. Even though all the integral vertices of P lie on a hyperplane, the best way we know of that identifies it takes exponential time by checking for all the integer points {0, 1}n. √ Remark 72. Note that this algorithm works for minimizing any convex function over the hypercube that obtains its optimal value at a vertex of the hypercube. Formally, our proof of Theorem 71 holds whenever a function f : 2V −→ Rn admits a convex relaxation f with the following properties: 1. For every S ⊆ V , f (IS) = f (S). 2. Every f ((cid:126)x) can be written as a convex combination (cid:80) O(n), and S can be computed without any oracle call. S∈S αSf (S), where (cid:80) αS = 1, S = 3. A subgradient ∂ f ((cid:126)x) of f at any point (cid:126)x ∈ [0, 1]n can be computed with O(n · EO) oracle calls. In this case, the proof of Theorem 71, implies that f and f can be minimized with O(n3 log n· EO) oracle calls by using the separating hyperplane ∂ f (¯x)T ((cid:126)x − ¯x) ≤ 0. 15.2 Technical Tools To improve upon the running time of the algorithm in the previous section, we use more structure of our submodular function f . Rather than merely showing that we can decrease the dimension of our SFM problem by 1 we show how we can reduce the degrees of freedom of our problem in a more principled way. In Section 15.2.1 we formally define the abstraction we use for this and discuss how to change our separation oracle to accommodate this abstraction, and in Section 15.2.2 we show how we can deduce these constraints. These tools serve as the foundation for the faster strongly polynomial time SFM algorithms we present in Section 15.3 and Section 15.4. 15.2.1 SFM over Ring Family For the remainder of the paper we consider a more general problem than SFM in which we wish to compute a minimizer of our submodular function f over a ring family of the ground set V = [n]. A ring family F is a collection of subsets of V such that for any S1, S2 ∈ F, we have S1∪S2, S1∩S2 ∈ F. Thus SFM corresponds to the special case where F consists of every subset of V . This generalization has been considered before in the literature and was essential to the IFF algorithm. It is well known that any ring family F over V can be represented by a directed graph D = (V, A) where S ∈ F iff S contains all of the descendants of any i ∈ S. An equivalent definition is that for 81 any arc (i, j) ∈ A, i ∈ S implies j ∈ S. It is customary to assume that A is acyclic as any (directed) cycle of A can be contracted (see section 15.3.1). We denote by R(i) the set of descendants of i (including i itself) and Q(i) the set of ancestors of i (including i itself). Polyhedrally, an arc (i, j) ∈ A can be encoded as the constraint xi ≤ xj as shown by the next lemma. Lemma 73. Let F be a ring family over V and D = (V, A) be its directed acyclic graph represen- tation. Suppose f : V −→ R is submodular with Lov´asz extension f . Then the characteristic vector IS of any minimizer S = arg minS∈F f (S) over F is also the solution to min f ((cid:126)x) (15.1) xi ≤ xj ∀(i, j) ∈ A 0 ≤ (cid:126)x ≤ 1 Proof. Let x∗ be a minimizer, and L(t) = {i : x∗ It is easy to check that the indicator variable IL(t) satisfies (15.1) since x∗ does. Moreover, recall that f (x∗) = Et∼[0,1][f (Lt)]. Thus t αt f (IL(t)), where αt > 0 f (x∗) can be written as a convex combination f (x∗) =(cid:80) and(cid:80) t αt = 1. Thus all such f (IL(t)) are minimal, i.e. (15.1) has no “integrality gap”. i ≥ t}. t αtf (L(t)) =(cid:80) We also modify our separation oracle to accommodate for this generalization as follows. Before doing so we need a definition which relates our BFS to the ring family formalism. Definition 74. A permutation (v1, . . . , vn) of V is said to be consistent with an arc (i, j) if j precedes i in (v1, . . . , vn). Similarly, a BFS of the base polyhedron is consistent with (i, j) if j precedes i in its defining permutation. (v1, . . . , vn) (or a BFS) is consistent with A if it is consistent with every (i, j) ∈ A. Readers may find it helpful to keep in mind the following picture which depicts the relative positions between R(i), i, Q(i) in the defining permutation of (cid:126)h that is consistent with A: ······ R(i)\{i} ······ i ······ Q(i)\{i} ······ In Theorem 61, given ¯x ∈ [0, 1]n our separating hyperplane is constructed by sorting the entries of ¯x. This hyperplane is associated with some BFS (cid:126)h of the base polyhedron. As we shall see towards the end of the section, we would like (cid:126)h to be consistent with every arc (i, j) ∈ A. This task is easy initially as ¯x satisfies xi ≤ xj for (i, j) ∈ A for the starting polytope of (15.1). If xi < xj, nothing special has to be done as j must precede i in the ordering. On the other hand, whenever xi = xj, we can always break ties by ranking j ahead of i. However, a technical issue arises due to the fact that our cutting plane algorithm may drop constraints from the current feasible region P . In other words, ¯x may violate xi ≥ 0, xj ≤ 1 or xi ≤ xj if it is ever dropped. Fortunately this can be fixed by reintroducing the constraint. We summarize the modification needed in the pseudocode below and formally show that it fulfills our requirement. Lemma 75. Our modified separation oracle returns either some BFS (cid:126)h = 0 or a valid separating hyperplane, i.e. 1. ¯x either lies on the separating hyperplane or is cut away by it. 2. Any minimizer of (15.1) is not cut away by the separating hyperplane. 82 Algorithm 5: Modified Separation Oracle Input: ¯x ∈ Rn and the set of arcs A if ¯xi < 0 for some i then else if ¯xj > 1 for some j then else if ¯xi > ¯xj for some (i, j) ∈ A then Output: xi ≥ 0 Output: xj ≤ 1 Output: xi ≤ xj Let i1, . . . , in be a permutation of V such that ¯xi1 ≥ . . . ≥ ¯xinand for all (i, j) ∈ A, j precedes i in i1, . . . , in. Output: (cid:126)hT (cid:126)x ≤ f (¯x), where (cid:126)h is the BFS defined by the permutation i1, . . . , in. else Such a hyperplane can be computed with n oracle calls to f and in time O(n · EO + n2). Proof. If we get xi ≥ 0, xj ≤ 1 or xi ≤ xj (if loop or the first two else loops), then clearly ¯x is cut away by it and any minimizer must of course satisfy xi ≥ 0, xj ≤ 1 and xi ≤ xj as they are the constraints in (15.1). This proves (1) and (2) for the case of getting xi ≥ 0, xj ≤ 1 or xi ≤ xj. Thus it remains to consider the case (cid:126)hT (cid:126)x ≤ f (¯x) (last else loop). First of all, ¯x lies on it as f (¯x) = (cid:126)hT ¯x. This proves (1). For (2), we have from Lemma 63 that (cid:126)hT (cid:126)x ≤ f ((cid:126)x). If x∗ is a minimizer of (15.1), we must then have (cid:126)hT x∗ ≤ f (x∗) ≤ f (¯x) as ¯x is also feasible for (15.1). Finally we note that the running time is self-evident. We stress again that the main purpose of modifying our separation oracle is to ensure that any BFS (cid:126)h used to define a new separating hyperplane must be consistent with every (i, j) ∈ A. 15.2.2 Identifying New Valid Arcs strongly polynomial algorithm since there are only 2·(cid:0)n The reason for considering the ring family generalization of SFM is that our algorithms (and some previous algorithms too) work by adding new arcs to our digraph D. This operation yields a (i, j) is valid only if i ∈ Smin =⇒ j ∈ Smin for some minimizer Smin. Here we show how to identify such valid arcs by extracting information from certain nice elements of the base polyhedron. (cid:1) possible arcs to add. Of course, a new arc 2 This is guaranteed by the next four lemmas, which are stated in a way different from previous works e.g. our version is extended to the ring family setting. This is necessary as our algorithms require a more general formulation. We also give a new polyhedral proof, which is mildly simpler than the previous combinatorial proof. On the other hand, Lemma 80 is new and unique to our work. It is an important ingredient of our (cid:101)O(n3 · EO + n4) time algorithm. Recall that each BFS of the base polyhedron is defined by some permutation of the ground set elements. First, we prove the following two lemmas which show that should we ever encounter a non- degenerate point in the base polytope with a coordinate of very large value, then we can immediately conclude that that coordinate must be or must not be in solution to SFM over the ring family. Lemma 76. If (cid:126)y ∈ B(f ) is non-degenerate and satisfies yi > −(n− 1) minj yj, then i is not in any minimizer of f (over the ring family A). 83 Proof. We proceed by contradiction and suppose that S is a minimizer of f that contains i. Now since (cid:126)y is non-degenerate we know that minj yj ≤ 0 and by the definition of (cid:126)y we have the following contradiction 0 < yi + (n − 1) min j yj = (cid:126)y(S) ≤ f (S) ≤ f (∅) = 0 . yj ≤(cid:88) j∈S Lemma 77. If (cid:126)y ∈ B(f ) is non-degenerate and satisfies yi < −(n − 1) maxj yj, then i is in every minimizer of f (over the ring family A). Proof. We proceed by contradiction and suppose that S is a minimizer of f that does not contain i. Now since (cid:126)y is non-degenerate we know that maxj yj ≥ 0 and therefore yj ≤(cid:88) j∈S yj . yj + (V − S − 1) max j (cid:88) j∈[n] yj . (cid:88) j∈[n] (cid:88) j∈S (cid:88) j∈V −(S+i) yj = yi + yj + yj < −(n − 1) max j yj + (cid:88) j∈S However by the definition of (cid:126)y we have(cid:88) yj = (cid:126)y(S) ≤ f (S) ≤ f (V ) = j∈S Thus we have a contradiction and the result follows. Now we are ready to present conditions under which a new valid arc can be added. We begin with a simple observation. Let upper(i) def= f (R(i)) − f (R(i) − i) and lower(i) def= f (V \Q(i) + i) − f (V \Q(i)). As the names suggest, they bound the value of hi for any BFS used. Lemma 78. For any BFS (cid:126)h used to construct a separating hyperplane given by our modified separation oracle, we have lower(i) ≤ hi ≤ upper(i). Proof. Note that by Lemma 75, (cid:126)h is consistent with every (j1, j2) ∈ A and hence i must precede Q(i) and be preceded by R(i). Let S be the set of elements preceding i in the defining permutation of (cid:126)h. Then hi = f (S + i) − f (S) ≤ f (R(i)) − f (R(i) − i) because of diminishing return and R(i) − i ⊆ S. The lower bound follows from the same argument as Q(i) − i comes after i, and so Q(i) ⊆ V \S. In the following two lemmas, we show that if upper(i) is ever sufficiently positive or lower(i) is sufficiently negative, then we find a new arc. While these lemmas may appear somewhat technical but actually has an intuitive interpretation. Suppose an element p is in a minimizer Smin of f over the ring family D. Then R(p) must also be part of Smin. Now if f (R(p)) is very large relative to f (R(p) − p), there should be some element q ∈ Smin\R(p) compensating for the discrepancy. The lemma says that such an element q can in fact be found efficiently. Lemma 79 (new arc). Let (cid:126)y =(cid:80) k λ(k)(cid:126)y(k) be a non-degenerate convex combination of O(n) base polyhedron BFS’s (cid:126)y(k) which are consistent with every arc (i, j) ∈ A. If some element p satisfies upper(p) > n4 max yj, then we can find, using O(n·EO) oracle calls and O(n2) time, some q /∈ R(p) such that the arc (p, q) is valid, i.e. if p is in a minimizer, then so is q. 84 Proof. If max yj < 0 then we are immediately done by Lemma 65. We assume max yj ≥ 0 in the proof. For all k let (cid:126)y(cid:48)(k) be the BFS obtained by taking the defining permutation of (cid:126)y(k) and moving R(p) to the front while preserving the relative ordering of R(p) within each permutation). p = f (R(p)) − f (R(p) − p) = upper(p) we have Furthermore, let (cid:126)y(cid:48) def=(cid:80) k λ(k)(cid:126)y(cid:48)(k). Then since y(cid:48)(k) p = f (R(p)) − f (R(p) − p). Moreover, upper(p) = y(cid:48) j ≥ yj ∀j ∈ R(p) and y(cid:48) y(cid:48) j ≤ yj ∀j /∈ R(p) (15.2) by diminishing marginal return. Now, suppose p is in a minimizer Smin. Then R(p) ⊆ Smin by definition. We then define f(cid:48)(S) = f (S ∪ R(p)) for S ⊆ V \R(p). It can be checked readily that f(cid:48) is submodular and Smin\R(p) is a minimizer of f(cid:48) (over the corresponding ring family). Note that now (cid:126)y(cid:48) V \R(p) (the restriction of (cid:126)y(cid:48) to V \R(p)) is a convex combination of the BFS’s of the base polyhedron B(f(cid:48)) of f(cid:48). We shall show that (cid:126)y(cid:48) V \R(p) has the desired property in Lemma 77. Note that y(cid:48)(V \R(p) + p) ≤ y(V \R(p) + p) since y(cid:48)(V \R(p) + p) = y(cid:48)(V )− y(cid:48)(R(p)− p) = y(V )− y(cid:48)(R(p)− p) ≤ y(V )− y(R(p)− p) = y(V \R(p) + p). But now since (cid:126)y is non-degenerate maxj yj ≥ 0 and therefore y(cid:48)(V \R(p)) ≤ y(V \R(p) + p) − y(cid:48) p = y(V \R(p) + p) − (f (R(p)) − f (R(p) − p)) ≤ n max yj − (f (R(p)) − f (R(p) − p)) < (n − n4) max yj (15.3) Therefore by the Pigeonhole Principle some q /∈ R(p) must satisfy q < (cid:0)(n − n4) max yj y(cid:48) (cid:1) /(n − 1) = −(n3 + n2 + n) max yj ≤ −(n3 + n2 + n) max yj j /∈R(p) ≤ −(n3 + n2 + n) max y(cid:48) j by (15.2) j /∈R(p) By Lemma 77, this q must be in any minimizer of f(cid:48). In other words, whenever p is in a minimizer of f , then so is q. Note however that computing all (cid:126)y(cid:48) would take O(n2) oracle calls in the worst case as there are q < −(n − 1) max yj using just O(n) (cid:126)y(cid:48)(k)’s. We use the following trick to identify some q with y(cid:48) O(n) calls. The idea is that we actually only want to have sufficient decreases in y(cid:48)(V \R(p)) which can be accomplished by having a large corresponding decrease in some (cid:126)y(cid:48)(k). For each k, by the same argument above (see (15.3)) y(cid:48)(k)(V \R(p)) − y(k)(V \R(p)) ≤ y(k) The “weighted decrease” λ(k)(cid:16) (cid:88) (cid:17) p − (f (R(p)) − f (R(p) − p)) y(k) p − (f (R(p)) − f (R(p) − p)) y(k) p − (f (R(p)) − f (R(p) − p)) for (cid:126)y(cid:48)(k) sum up to (cid:17) = yp − (f (R(p)) − f (R(p) − p)) < (1 − n4) max yj Thus by the Pigeonhole Principle, some l will have (cid:17) p − (f (R(p)) − f (R(p) − p)) y(l) <(cid:0)(1 − n4) max yj (cid:1) /O(n) < −n2 max yj. λ(k)(cid:16) λ(l)(cid:16) (15.4) 85 For this (cid:126)y(l) we compute (cid:126)y(cid:48)(l). We show that (cid:126)y(cid:48)(cid:48) = λ(l)(cid:126)y(cid:48)(l) +(cid:80) as (cid:126)y(cid:48) above. (cid:88) k(cid:54)=l λ(k)(cid:126)y(k) has the same property y(cid:48)(cid:48)(V \R(p)) = λ(l)y(cid:48)(l)(V \R(p)) + = y(V \R(p)) + λ(l)(cid:16) ≤ y(V \R(p)) + λ(l)(cid:16) λ(k)y(k)(V \R(p)) (cid:17) k(cid:54)=l (cid:17) y(cid:48)(l)(V \R(p)) − y(l)(V \R(p)) p − (f (R(p)) − f (R(p) − p)) y(l) by (15.4) < (n − 1) max yj − n2 max yj < (n − n2) max yj Then some q ∈ V \R(p) must satisfy y(cid:48)(cid:48) q < n − n2 n − 1 max yj = −n max yj That is, the arc (p, q) is valid. This takes O(n) oracle calls as given (cid:126)y =(cid:80) Lemma 80. Let (cid:126)y =(cid:80) k λ(k)(cid:126)y(k) , computing (cid:126)y(cid:48)(cid:48) requires knowing only f (R(p)), f (R(p) − p), and (cid:126)y(cid:48)(l) which can be computed from (cid:126)y(l) with n oracle calls. The runtime is O(n2) which is needed for computing (cid:126)y(cid:48)(cid:48). k λ(k)(cid:126)y(k)be a non-degenerate convex combination of base polyhedron BFS (cid:126)y(k) which is consistent with every arc (i, j) ∈ A. If lower(p) < n4 min yj, then we can find, using O(n · EO) oracle calls and O(n2) time, some q /∈ Q(p) such that the arc (q, p) is valid, i.e. if p is not in a minimizer, then q is not either. Proof. It is possible to follow the same recipe in the proof of Lemma 79 but using Lemma 76 instead of Lemma 77. Here we offer a proof which directly invokes Lemma 77 on a different submodular function. Let g be defined by g(S) def= f (V \S) for any S, and Ag be the set of arcs obtained by reversing the directions of the arcs of A. Consider the problem of minimizing g over the ring family Ag. Using subscripts to avoid confusion with f and g, e.g. Rg(i) is the set of descendants of i w.r.t. Ag, it is not hard to verify the following: • g is submodular • Rg(i) = Qf (i) • g(Rg(p)) − g(Rg(p) − p) = − (f (V \Qf (p) + p) − f (V \Qf (p))) • −(cid:126)y(k) is a BFS of B(g) if and only if (cid:126)y(k) is a BFS of B(f ) • max(−yj) = − min yj By using the above correspondence and applying Lemma 79 to g and Ag, we can find, using O(n) oracle calls and O(n2) time, some q /∈ Rg(p) = Q(p) such that the arc (p, q) is valid for g and Ag. In other words, the reverse (q, p) will be valid for f and A. These lemmas lay the foundation of our algorithm. They suggests that if the positive entries of a point in the base polyhedron are small relative to some upper(p) = f (R(p)) − f (R(p) − p), a new arc (p, q) can be added to A. This can be seen as a robust version of Lemma 65. Finally, we end the section with a technical lemma that will be used crucially for both of our algorithms. The importance of it would become obvious when it is invoked in our analyses. 86 Lemma 81. Let (cid:126)h(cid:48)(cid:48) denote a convex combination of two vectors (cid:126)h and (cid:126)h(cid:48) in the base polyhedron, i.e. (cid:126)h(cid:48)(cid:48) = λ(cid:126)h + (1 − λ)(cid:126)h(cid:48) for some λ ∈ [0, 1]. Further suppose that for some α ≤ 1 √ 2 (cid:13)(cid:13)(cid:126)h(cid:48)(cid:48)(cid:13)(cid:13)2 ≤ α min (cid:110) λ(cid:13)(cid:13)(cid:126)h(cid:13)(cid:13)2, (1 − λ)(cid:13)(cid:13)(cid:126)h(cid:48)(cid:13)(cid:13)2 ·(cid:13)(cid:13)(cid:126)h(cid:48)(cid:48)(cid:13)(cid:13)∞ and n . Then for p = arg maxj(max{λhj, (1 − λ)h(cid:48) √ lower(p) ≤ − 1 2α n (cid:111) j}) we have ·(cid:13)(cid:13)(cid:126)h(cid:48)(cid:48)(cid:13)(cid:13)∞ . √ upper(p) ≥ 1 2α p. Then by assumptions we have n (cid:111) ≤ α √ nλhp . However, since α ≤ 1 √ 2 Consequently, λhp and (1 − λ)h(cid:48) Proof. Suppose without loss of generality that λhp ≥ (1 − λ)h(cid:48) (cid:13)(cid:13)(cid:126)h(cid:48)(cid:48)(cid:13)(cid:13)∞ ≤(cid:13)(cid:13)(cid:126)h(cid:48)(cid:48)(cid:13)(cid:13)2 ≤ α · min (cid:12)(cid:12)λhp + (1 − λ)h(cid:48) n we see that (cid:110) λ(cid:13)(cid:13)(cid:126)h(cid:13)(cid:13)2, (1 − λ)(cid:13)(cid:13)(cid:126)h(cid:48)(cid:13)(cid:13)2 (cid:12)(cid:12) ≤(cid:13)(cid:13)h(cid:48)(cid:48)(cid:13)(cid:13)∞ ≤ α p have opposite signs and(cid:12)(cid:12)(1 − λ)h(cid:48) (cid:9) ≤ − 1 (cid:9) ≤ min(cid:8)λhp, (1 − λ)h(cid:48) (cid:9) ≥ 1 (cid:9) ≥ max(cid:8)λhp, (1 − λ)h(cid:48) nλhp ≤ 1 2 √ 2 p p p p lower(p) ≤ min(cid:8)hp, h(cid:48) upper(p) ≥ max(cid:8)hp, h(cid:48) (cid:101)O(n4 · EO + n5) Time Algorithm p and λhp (cid:12)(cid:12) ≥ 1 2 p . (cid:12)(cid:12)λh(cid:48) p √ λhp ≤ − 1 n 2α (cid:12)(cid:12). We then have, (cid:13)(cid:13)h(cid:48)(cid:48)(cid:13)(cid:13)∞ (cid:13)(cid:13)h(cid:48)(cid:48)(cid:13)(cid:13)∞ . √ λhp ≥ 1 2α n 2 15.3 Here we present a (cid:101)O(n4 · EO + n5) time, i.e. strongly polynomial time algorithm, for SFM. We build upon the algorithm achieved in the section to achieve a faster running time in Section 15.4. Our new algorithm combines the existing tools for SFM developed over the last decade with our cutting plane method. While there are certain similarities with previous algorithms (especially [54, 60, 56]), our approach significantly departs from all the old approaches in one important aspect. All of the previous algorithms actively maintain a point in the base polyhedron and represent it as a convex combination of BFS’s. At each step, a new BFS may enter the convex combination and an old BFS may exit. Our algorithm, on the other hand, maintains only a collection of BFS’s (corresponding to our separating hyperplanes), rather than an explicit convex combination. A “good” convex combination is computed from the collection of BFS’s only after running Cutting Plane for enough iterations. We believe that this crucial difference is the fundamental reason which offers the speedup. This is achieved by the Cutting Plane method which considers the geometry of the collection of BFS’s. On the other hand, considering only a convex combination of BFS’s effectively narrows our sight to only one point in the base polyhedron. Overview 87 Now we are ready to describe our strongly polynomial time algorithm. Similar to the weakly poly- nomial algorithm, we first run our cutting plane for enough iterations on the initial feasible region {(cid:126)x ∈ [0, 1]n : xi ≤ xj ∀(i, j) ∈ A}, after which a pair of approximately parallel supporting hyper- planes F1, F2 of width 1/nΘ(1) can be found. Our strategy is to write F1 and F2 as a nonnegative combination of the facets of remaining feasible region P . This combination is made up of newly added separating hyperplanes as well as the inequalities xi ≥ 0, xj ≤ 1 and xi ≤ xj. We then argue that one of the following updates can be done: • Collapsing: xi = 0, xj = 1 or xi = xj • Adding a new arc (i, j): xi ≤ xj for some (i, j) /∈ A The former case is easy to handle by elimination or contraction. If xi = 0, we simply eliminate i from the ground set V ; and if xi = 1, we redefine f so that f (S) = f (S + i) for any S ⊆ V − i. xi = xj can be handled in a similar fashion. In the latter case, we simply add the arc (i, j) to A. We then repeat the same procedure on the new problem. Roughly speaking, our strongly polynomial time guarantee follows as eliminations and contrac- tions can happen at most n times and at most 2 ·(cid:0)n (cid:1) new arcs can be added. While the whole picture is simple, numerous technical details come into play in the execution. We advise readers to keep this overview in mind when reading the subsequent sections. 2 Algorithm Our algorithm is summarized below. Again, we remark that our algorithm simply uses Theorem 82 regarding our cutting plane and is agnostic as to how the cutting plane works, thus it could be replaced with other methods, albeit at the expense of slower runtime. 1. Run cutting plane on (15.1) (Theorem 82 with τ = Θ(1)) using our modified separation oracle (Section 15.2.1). 2. Identify a pair of “narrow” approximately parallel supporting hyperplanes or get some BFS (cid:126)h = 0 (in which case both ∅ and V are minimizers). 3. Deduce from the hyperplanes some new constraint of the forms xi = 0, xj = 1, xi = xj or xi ≤ xj (Section 15.3.2). 4. Consolidate A and f (Section 15.3.1). 5. Repeat by running our cutting plane method on (15.1) with updated A and f . (Note that Any previously found separating hyperplanes are discarded.) We call step (1) a phase of cutting plane. The minimizer can be constructed by unraveling the recursion. 15.3.1 Consolidating A and f Here we detail how the set of valid arcs A and submodular function f should be updated once we deduce new information xi = 0, xi = 1, xi = xj or xi ≤ xj. Recall that R(i) and Q(i) are the sets of descendants and ancestors of i respectively (including i itself). The changes below are somewhat self-evident, and are actually used in some of the previous algorithms so we only sketch how they are done without a detailed justification. Changes to the digraph representation D of our ring family include: 88 • xi = 0: remove Q(i) from the ground set and all the arcs incident to Q(i) • xi = 1: remove R(i) from the ground set and all the arcs incident to R(i) • xi = xj: contract i and j in D and remove any duplicate arcs • xi ≤ xj: insert the arc (i, j) to A • For the last two cases, we also contract the vertices on a directed cycle of A until there is no more. Remove any duplicate arcs. Here we can contract any cycle (i1, . . . , ik) because the inequalities xi1 ≤ xi2, . . . , xik−1 ≤ xik , xik ≤ xi1 imply xi1 = . . . = xik . Changes to f : • xi = 0: replace f by f(cid:48) : 2V \Q(i) −→ R, f(cid:48)(S) = f (S) for S ⊆ V \Q(i) • xi = 1: replace f by f(cid:48) : 2V \R(i) −→ R, f(cid:48)(S) = f (S ∪ R(i)) for S ⊆ V \R(i) • xi = xj: see below • xi ≤ xj: no changes to f needed if it does not create a cycle in A; otherwise see below • Contraction of C = {i1, . . . , ik}: replace f by f(cid:48) : 2V \C+l −→ R, f(cid:48)(S) = f (S) for S ⊆ V \C and f(cid:48)(S) = f ((S − l) ∪ C) for S (cid:51) l Strictly speaking, these changes are in fact not needed as they will automatically be taken care of by our cutting plane method. Nevertheless, performing them lends a more natural formulation of the algorithm and simplifies its description. 15.3.2 Deducing New Constraints xi = 0, xj = 1, xi = xj or xi ≤ xj Here we show how to deduce new constraints through the result of our cutting plane method. This is the most important ingredient of our algorithm. As mentioned before, similar arguments were used first by IFF [56] and later in [54, 60]. There are however two important differences for our method: • We maintain a collection of BFS’s rather a convex combination; a convex combination is computed and needed only after each phase of cutting plane. • As a result, our results are proved mostly geometrically whereas the previous ones were proved mostly combinatorially. Our ability to deduce such information hinges on the power of the cutting plane method in Part I. We re-state our main result Theorem 31 in the language of SFM. Note that Theorem 82 is formulated in a fairly general manner in order to accommodate for the next section. Readers may wish to think τ = Θ(1) for now. Theorem 82 (Theorem 31 restated for SFM). For any τ ≥ 100, applying our cutting plane method, Theorem 82, to (15.1) with our modified separation oracle (or its variant in Section 15.4) with high probability in n either 1. Finds a degenerate BFS (cid:126)h ≥ (cid:126)0 or (cid:126)h ≤ (cid:126)0. 89 2. Finds a polytope P consisting of O(n) constraints which are our separating hyperplanes or the constraints in (15.1). Moreover, P satisfies the following inequalities (cid:126)cT (cid:126)x ≤ M and (cid:126)c(cid:48)T (cid:126)x ≤ M(cid:48), both of which are nonnegative combinations of the constraints of P , where (cid:126)c + (cid:126)c(cid:48)2 ≤ min{(cid:126)c2,(cid:126)c(cid:48)2}/nΘ(τ ) and M + M(cid:48) ≤ min{(cid:126)c2,(cid:126)c(cid:48)2}/nΘ(τ ). Furthermore, the algorithm runs in expected time O(n2τ log n · EO + n3τ O(1) logO(1) n). Proof. In applying Theorem 82 we let K be the set of minimizers of f over the ring family and the box is the hypercube with R = 1. We run cutting plane with our modified separation oracle (Lemma 75). The initial polytope P (0) can be chosen to be, say, the hypercube. If some separating hyperplane is degenerate, then we have the desired result (and know that either ∅ or V is optimal). Otherwise let P be the current feasible region. Note that P (cid:54)= ∅, because our minimizers of f are all in P (0) and P (k) as they are never cut away by the separating hyperplanes. Let S be the collection of inequalities (15.1) as well as the separating hyperplanes (cid:126)hT (cid:126)x ≤ f (¯xh) = (cid:126)hT ¯xh used. By Theorem 31, all of our minimizers will be contained in P , consisting of i (cid:126)x ≥ bi is a scaling and shifting of some inequality O(n) constraints A(cid:126)x ≥ (cid:126)b. Each such constraint (cid:126)aT i (cid:126)x ≥ qi in S, i.e. (cid:126)ai = (cid:126)pi/(cid:126)pi2 and bi ≤ qi/(cid:126)pi2. (cid:126)pT has a narrow width by (cid:126)a1, some nonnegative combination (cid:80)O(n) By taking  = 1/nΘ(τ ) with sufficiently large constant in Θ, our theorem certifies that P i=2 ti(cid:126)ai and point (cid:126)xo ∈ P with (cid:126)xo∞ ≤ 3 √ √ nR = 3 n satisying the following: def= ti · (cid:126)p12/(cid:126)pi2 ≥ 0. ≤ (cid:126)p12/nΘ(τ ) i t(cid:48) i(cid:126)pi We convert these inequalities to (cid:126)p and q. Let t(cid:48) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 O(n)(cid:88) We claim that6 (cid:126)c = −(cid:126)p1, M = −q1, (cid:126)c(cid:48) = −(cid:80)O(n) 0 ≤ (cid:126)pT (cid:126)xo − 0 ≤ i=2 i=2 1 (cid:126)xo − q1 ≤ (cid:126)p12/nΘ(τ ) iqi ≤ (cid:126)p12/nΘ(τ ) t(cid:48) i(cid:126)pi, M(cid:48) = −(cid:80)O(n) i=2 t(cid:48) i=2 t(cid:48) iqi satisfy our require- ment. 6Minus signs is needed because we express our inequalities as e.g. (cid:126)hT (cid:126)x ≤ (cid:126)hT ¯xh whereas in Theorem 31, (cid:126)aT i (cid:126)x ≥ bi is used. We apologize for the inconvenience. 90 0 ≤ (cid:126)xo − tibi ≤ 1/nΘ(τ ) ti(cid:126)ai ≤ 1/nΘ(τ ) 1 (cid:126)xo − (cid:126)b1 ≤ 1/nΘ(τ ) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 O(n)(cid:88) i=2 i=2 tiai 0 ≤ (cid:126)aT (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:126)a1 + O(n)(cid:88) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:126)p1 + O(n)(cid:88) O(n)(cid:88) T O(n)(cid:88) T t(cid:48) i(cid:126)pi i=2 i=2 We first show that (cid:126)c + (cid:126)c(cid:48)2 ≤ min{(cid:126)c2,(cid:126)c(cid:48)2}/nΘ(τ ). We have (cid:126)c + (cid:126)c(cid:48)2 ≤ (cid:126)c2/nΘ(τ ) from the first inequality. If (cid:126)c2 ≤ (cid:126)c(cid:48)2 we are done. Otherwise, by triangle inequality (cid:126)c(cid:48)2 − (cid:126)c2 ≤ (cid:126)c + (cid:126)c(cid:48)2 ≤ (cid:126)c2/nΘ(τ ) =⇒ 2(cid:126)c2 ≥ (cid:126)c(cid:48)2 and hence (cid:126)c + (cid:126)c(cid:48)2 ≤ (cid:126)c2/nΘ(τ ) ≤ (cid:126)c(cid:48)2/2nΘ(τ ) = (cid:126)c(cid:48)2/nΘ(τ ). We also need to prove M + M(cid:48) ≤ min{(cid:126)c2,(cid:126)c(cid:48)2}/nΘ(τ ). Summing the second and third inequalities, Recall that we have (cid:126)xo∞ ≤ 3 √ n. Then −(cid:126)c2/nΘ(τ ) ≤ ((cid:126)c + (cid:126)c(cid:48))T (cid:126)xo − (M + M(cid:48)) ≤ 0 M + M(cid:48) ≤ ((cid:126)c + (cid:126)c(cid:48))T (cid:126)xo − (M + M(cid:48)) + ((cid:126)c + (cid:126)c(cid:48))T (cid:126)xo ≤ (cid:126)c2/nΘ(τ ) + 3 ≤ (cid:126)c2/nΘ(τ ) + 3 = (cid:126)c2/nΘ(τ ) √ √ n(cid:126)c + (cid:126)c(cid:48)2 n(cid:126)c2/nΘ(τ ) as desired. Our result then follows as we proved 2(cid:126)c(cid:48)2 ≥ (cid:126)c2. Finally, we have the desired runtime as our modified separation oracle runs in time O(n · EO + n2 logO(1) n). Informally, the theorem above simply states that after O(nτ log n) iterations of cutting plane, the remaining feasible region P can be sandwiched between two approximately parallel supporting hyperplanes of width 1/nO(τ ). A good intuition to keep in mind is that every O(n) iterations of cutting plane reduces the minimum width by a constant factor. Remark 83. As shown in the proof of Theorem 82, one of the two approximately parallel hyperplanes can actually be chosen to be a constraint of our feasible region P . However we do not exploit this property as it does not seem to help us and would break the notational symmetry in (cid:126)c and (cid:126)c(cid:48). Setup In each phase, we run cutting plane using Theorem 82 with τ = Θ(1). If some separating hyperplane used is degenerate, we have found the minimizer by Lemma 65. Now assume none of the separating hyperplanes is degenerate. By Theorem 82, P is sandwiched by a pair of approximately parallel supporting hyperplanes F, F (cid:48) which are of width 1/10n10 apart. The width here can actually be 1/nc for any constant c by taking a sufficiently large constant in Theta. Here, we show how to deduce from F and F (cid:48) some xi = 0,, xj = 1,xi = xj, or xi ≤ xj constraint on the minimizers of f over the ring family. Let (cid:88) (cid:88) (cid:126)cT (cid:126)x = cixi ≤ M and (cid:126)c(cid:48)T (cid:126)x = ixi ≤ M(cid:48) c(cid:48) be the inequality for F and F (cid:48) such that M + M(cid:48), (cid:126)c + (cid:126)c(cid:48)2 ≤ gap, where gap def= 1 10n10 min{(cid:126)c2,(cid:126)c(cid:48)2}. By the same theorem we can write (cid:126)cT (cid:126)x ≤ M as a nonnegative combination of the constraints for P . Recall that the constraints for P take on four different forms: (1) −xi ≤ 0; (2) xj ≤ 1; (3) −(xj − xi) ≤ 0; (4) (cid:126)hT (cid:126)x =(cid:80) hixi ≤ f (¯xh). Here the first three types are present initially whereas 91 the last type is the separating hyperplane added. As alleged previously, the coefficient vector (cid:126)h corresponds to a BFS of the base polyhedron for f . Our analysis crucially exploits this property. i cixi ≤ M is a nonnegative combination of our constraints with weights αi, βj, γij, λh ≥ 0. The number of (positive) αi, βj, γij, λh is at most O(n). Here we denote sep- arating hyperplanes by (cid:126)hT (cid:126)x ≤ f (¯xh). Let H be the set of BFS’s used to construct separating hyperplanes. Thus suppose (cid:126)cT (cid:126)x =(cid:80) (cid:88) (cid:126)cT (cid:126)x = −(cid:88) (cid:126)hT (cid:126)x λh and M = γij(xi − xj) + (cid:88) (cid:88) (cid:88) (cid:88) λh f (¯xh). βjxj + αixi + βj + i j (i,j)∈A (15.5) Similarly, we write the inequality for F (cid:48) as a nonnegative combination of the constraints for P j (cid:88) h∈H (cid:88) h∈H λ(cid:48) h f (¯xh). (15.6) λ(cid:48) (cid:126)hT (cid:126)x h and M(cid:48) = β(cid:48) j + h∈H (cid:88) h∈H α(cid:48) ixi + (cid:88) and the number of (positive) α(cid:48) (cid:126)c(cid:48)T (cid:126)x = −(cid:88) (cid:88) i, β(cid:48) j, γ(cid:48) ij, λ(cid:48) h is O(n): ij(xi − xj) + γ(cid:48) We also scale (cid:126)c, (cid:126)c(cid:48), α, α(cid:48), β, β(cid:48), γ, γ(cid:48), λ, λ(cid:48) so that(cid:88) β(cid:48) jxj + (i,j)∈A (λh + λ(cid:48) h) = 1 h∈H as this does not change any of our preceding inequalities regarding F and F (cid:48). Now that F, F (cid:48) have been written as combinations of our constraints, we have gathered the necessary ingredients to derive our new arc. We first give a geometric intuition why we would expect to be able to derive a new constraint. Consider the nonnegative combination making up F . We think of the coefficient βj as the contribution of xj ≤ 1 to F . Now if βj is very large, F is “very parallel” to xj ≤ 1 and consequently F (cid:48) would miss xj = 0 as the gap between F and F (cid:48) is small. P would then miss xj = 0 too as it is sandwiched between F and F (cid:48). Similarly, a large αi and a large γij would respectively imply that xi = 1 and (xi = 0, xj = 1) would be missed. The same argument works for F (cid:48) as well. But on the other hand, if the contributions from xi ≥ 0, xj ≤ 1, xi ≤ xj to both F and F (cid:48) are small, then the supporting hyperplanes (cid:126)cT (cid:126)x ≤ ... and (cid:126)c(cid:48)T (cid:126)x ≤ ... would be mostly made up of separating hyperplanes (cid:126)hT (cid:126)x ≤ f (¯xh). By summing up these separating hyperplanes (whose coefficients form BFS’s), we would then get a point in the base polyhedron which is very close to the origin 0. Moreover, by Lemma 81 and Lemma 79 we should then be able to deduce some interesting information about the minimizer of f over D. The rest of this section is devoted to realizing the vision sketched above. We stress that while the algebraic manipulations may be long, they are simply the execution of this elegant geometric picture. Now, consider the following weighted sum of (cid:126)hT (cid:126)x ≤ f (¯xh): (cid:32)(cid:88) h∈H (cid:88) h∈H (cid:33) (cid:88) h∈H (cid:126)hT + λh λ(cid:48) (cid:126)hT h (cid:126)x = (cid:126)hT (cid:126)x + λh (cid:88) h∈H (cid:126)hT (cid:126)x ≤ (cid:88) λ(cid:48) h h∈H (cid:88) h∈H λ(cid:48) h f (¯xh). λh f (¯xh) + 92 Observe that(cid:80) (cid:32)(cid:88) (cid:88) (cid:126)hT + λh h∈H λh λ(cid:48) (cid:126)hT h (cid:126)hT +(cid:80) (cid:33) (cid:126)x = h∈H λ(cid:48) (cid:126)cT (cid:126)x + and + h∈H h∈H (i,j)∈A (cid:88) (cid:16) M(cid:48) −(cid:88) βj −(cid:88) β(cid:48) Furthermore, we can bound (cid:126)cT (cid:126)x + (cid:126)c(cid:48)T (cid:126)x by (cid:126)cT (cid:126)x + (cid:126)c(cid:48)T (cid:126)x ≥ −(cid:126)c + (cid:126)c(cid:48)1 ≥ −√ β(cid:48) jxj + (cid:88) (cid:88) f (¯xh) + (i,j)∈A h∈H h∈H λ(cid:48) λh h j as (cid:126)x ≤ 1. Since M + M(cid:48) ≤ gap, we obtain (cid:88) (cid:88) ixi −(cid:88) α(cid:48) LHS def= αixi + + βj α(cid:48) βjxj + f (¯xh) = (cid:88) (cid:88) αixi −(cid:88) (cid:126)c(cid:48)T (cid:126)x + (cid:88) ixi −(cid:88) (cid:17) (cid:16) M −(cid:88) = (M + M(cid:48)) −(cid:88) (cid:88) βj −(cid:88) ngap−(cid:80) βj−(cid:80) β(cid:48) βjxj −(cid:88) ngap −(cid:88) (i,j)∈A β(cid:48) β(cid:48) jxj + √ j ≤ 2  γij(xj − xi)  (15.7) ij(xj − xi) γ(cid:48) (cid:17) β(cid:48) j ngap n(cid:126)c + (cid:126)c(cid:48)2 ≥ −√ (cid:88) ij(xj − xi) γ(cid:48) (i,j)∈A γij(xj − xi) + of BFS (cid:126)h. Furthermore, using (15.5) and (15.6) this can also be written as (cid:126)hT is in the base polyhedron since it is a convex combination h Geometrically, the next lemma states that if the contribution from, say xi ≥ 0, to F is too large, then F (cid:48) would be forced to miss xi = 1 because they are close to one another. Lemma 84. Suppose (cid:126)x satisfies (15.1) and LHS ≤ 2 0. j with αi, βj, γij, α(cid:48) j, γ(cid:48) i, β(cid:48) √ ij ≥ 1. If αi > 2 √ ngap or α(cid:48) √ ngap or β(cid:48) √ ngap or γ(cid:48) 3. If γij > 2 2. If βj > 2 i > 2 j > 2 √ ngap, then xi < 1. √ ngap, then xj > 0. √ ngap, then 0 ≤ xj − xi < 1. ij > 2 Proof. We only prove it for αi, βj, γij as the other case follows by symmetry. αixi ≤ 2 Using 0 ≤ x ≤ 1 and xi ≤ xj for (i, j) ∈ A, we have LHS ≥ αixi −(cid:80) βj −(cid:80) β(cid:48) j(cid:54)=k βj −(cid:80) β(cid:48) Similarly, LHS ≥ −βkxk −(cid:80) Finally, LHS ≥ γij(xj − xi)−(cid:80) βj −(cid:80) β(cid:48) √ j. Hence √ ngap. j which gives −βkxk ≤ 2 ngap − βk. Then xk > 0 √ ngap. Then xj − xi < 1 j which gives γij(xj − xi) ≤ 2 √ ngap and we get xi < 1 if αi > 2 √ ngap. if βk > 2 √ ngap. We have xi ≤ xj since (i, j) ∈ A. if γij > 2 So if either condition of Lemma 84 holds, we can set xi = 0 or xj = 1 or xi = xj since our problem (15.1) has an integral minimizer and any minimizer of f is never cut away by Lemma 75. Consequently, in this case we can reduce the dimension by at least 1. From now on we may assume that max{αi, α(cid:48) i, βj, β(cid:48) j, γij, γ(cid:48) ij} ≤ 2 √ ngap. (15.8) Geometrically, (15.8) says that if the supporting hyperplanes are both mostly made up of the separating hyperplanes, then their aggregate contributions to F and F (cid:48) should be small in absolute value. The next lemma identifies some p ∈ V for which f (R(p)) − f (R(p) − p) is “big”. This prepares for the final step of our approach which invokes Lemma 79. 93 h h∈H λh h∈H λ(cid:48) assuming (15.8). (cid:126)h and (cid:126)y(cid:48) def=(cid:80) Lemma 85. Let (cid:126)y def=(cid:80) Proof. Recall that(cid:13)(cid:13)(cid:126)c + (cid:126)c(cid:48)(cid:13)(cid:13)2 ≤ gap where gap = 1 (cid:126)c = (cid:126)y −(cid:88) By (15.8) we know that (cid:13)(cid:13)(cid:126)c − (cid:126)y(cid:13)(cid:13)2 ≤ 4n2gap ≤ 4 upper(p) ≥ n7(cid:13)(cid:13)(cid:126)y + (cid:126)y(cid:48)(cid:13)(cid:13)∞ and (cid:126)c(cid:48) = (cid:126)y(cid:48) −(cid:88) γij((cid:126)1i − (cid:126)1j) (cid:88) (cid:88) βj(cid:126)1j + αi(cid:126)1i + (i,j) j i (cid:88) 10n10 min{(cid:126)c2,(cid:126)c(cid:48)2}, (cid:126)1i + i α(cid:48) (cid:88) β(cid:48) (cid:126)1j + ij((cid:126)1i − (cid:126)1j) . γ(cid:48) i (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 and (cid:13)(cid:13)(cid:126)c(cid:48) − (cid:126)y(cid:48)(cid:13)(cid:13)2 ≤ 4n2gap ≤ 4 (i,j) j j 10n8 (cid:13)(cid:13)(cid:126)c(cid:48)(cid:13)(cid:13)2. (cid:126)h and let p ∈ arg maxl{max{yl,y(cid:48) l}} then and 10n8 Consequently, by the triangle inequality we have that (cid:13)(cid:13)(cid:126)y + (cid:126)y(cid:48)(cid:13)(cid:13)2 ≤(cid:13)(cid:13)(cid:126)c + (cid:126)c(cid:48)(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)c − (cid:126)y(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)c(cid:48) − (cid:126)y(cid:48)(cid:13)(cid:13)2 ≤ 9n2gap (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ⇒ (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 ≤ 2(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 ≤(cid:13)(cid:13)(cid:126)c − (cid:126)y(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2 ≤ 4 Similarly, we have that(cid:13)(cid:13)(cid:126)c(cid:48)(cid:13)(cid:13)2 ≤ 2(cid:13)(cid:13)(cid:126)y(cid:48)(cid:13)(cid:13)2. Consequently since gap ≤ 1 n8 min(cid:8)(cid:13)(cid:13)(cid:126)y(cid:13)(cid:13)2,(cid:13)(cid:13)(cid:126)y(cid:48)(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:126)y + (cid:126)y(cid:48)(cid:13)(cid:13)2 ≤ 2 (cid:9) 10n8 that 10n10 min{(cid:126)c2,(cid:126)c(cid:48)2}, we have and thus, invoking Lemma 81 yields the result. We summarize the results in the lemma below. Corollary 86. Let P be the feasible region after running cutting plane on (15.1). Then one of the following holds: 1. We found a degenerate BFS and hence either ∅ or V is a minimizer. 2. The integral points of P all lie on some hyperplane xi = 0, xj = 1 or xi = xj which we can find. 3. Let H be the collection of BFS’s (cid:126)h used to construct our separating hyperplanes for P . Then there is a convex combination (cid:126)y of H such that n4yi < maxp upper(p) for all i. if one of the conditions in Lemma 84 holds. Otherwise, y =(cid:80) Proof. As mentioned before, (1) happens if some separating hyperplane is degenerate. We have (2) (cid:126)h is a candidate h (cid:126)h +(cid:80) h∈H λ(cid:48) h∈H λh for Case 3 by Lemma 85. Let us revisit the conditions of Lemma 79 and explain that they are satisfied by Case 3 of the last lemma. • (cid:126)y is a convex combination of at most O(n) BFS’s. This holds in Case 3 since our current feasible region consists of only O(n) constraints thanks to the Cutting Plane method. • Those BFS’s must be consistent with every arc of A. This holds because Case 3 uses the BFS’s for constructing our separating hyperplane. Our modified separation oracle guarantees that they are consistent with A. Thus in Case 3 of the last corollary, Lemma 79 allows us to deduce a new constraint xp ≤ xq for some q /∈ R(p). 94 15.3.3 Running Time Here we bound the total running time of our algorithm and prove the following. Theorem 87. Our algorithm runs in time O(n4 log n · EO + n5 logO(1) n). Proof. To avoid being repetitive, we appeal to Corollary 86. Each phase of cutting plane takes time O(n2 log n · EO + n3 logO(1) n) (Theorem 82 with τ being a big constant. Given F and F (cid:48) represented as a nonnegative combination of facets, we can check for the conditions in Lemma 84 in O(n) time as there are only this many facets of P . This settles Case 2 of Corollary 86. Finally, Lemma 79 tells us that we can find a new arc in O(n · EO + n2) time for Case 3 of Corollary 86. Our conclusion follows from the fact that we can get xi = 0, xi = 1, xi = xj at most n times and xi ≤ xj at most O(n2) times. (cid:101)O(n3 · EO + n4) Time Algorithm 15.4 Here we show how to improve our running time for strongly polynomial SFM to (cid:101)O(n3·EO+n4). Our cost us (cid:101)O(n2 · EO + n3). Here we show how to reduce our amortized cost for identifying a valid arc down to (cid:101)O(n · EO + n2) and thereby achieve our result. algorithm can be viewed as an extension of the algorithm we presented in the previous Section 15.3. The main bottleneck of our previous algorithm was the time needed to identify a new arc, which The key observation we make to improve this running time is that our choice of p for adding an arc in the previous lemma can be relaxed. p actually need not be arg maxi upper(i); instead it is enough to have upper(p) > n4 max{αi, α(cid:48) ij}. For each such p a new constraint xp ≤ xq can be identified via Lemma 79. So if there are many p’s satisfying this we will be able to obtain many new constraints and hence new valid arcs (p, q). j, γij, γ(cid:48) i, βj, β(cid:48) On the other hand, the bound in Lemma 85 says that our point in the base polyhedron is small in absolute value. This is actually stronger than what we need in Lemma 79 which requires only its positive entries to be “small”. However as we saw in Lemma 80 we can generate a constraint of the form xq ≤ xp whenever lower(p) is sufficiently negative. Using this idea, we divide V into different buckets according to upper(p) and lower(p). This will allow us to get a speedup for two reasons. First, bucketing allows us to disregard unimportant elements of V during certain executions of our cutting plane method. If both upper(i) and lower(i) are small in absolute value, then i is essentially negligible because for a separating hyperplane (cid:126)hT (cid:126)x ≤ f (¯x), any hi ∈ [lower(i), upper(i)] small in absolute value would not really make a difference. We can then run our cutting plane algorithm only on those non-negligible i’s, thereby reducing our time complexity. Of course, whether hi is small is something relative. This suggests that partitioning the ground set by the relative size of upper(i) and lower(i) is a good idea. Second, bucketing allows us to ensure that we can always add an arc for many edges simulta- neously. Recall that we remarked that all we want is nO(1)yi ≤ upper(p) for some (cid:126)y in the base polyhedron. This would be sufficient to identify a new valid arc (p, q). Now if the marginal dif- ferences upper(p) and upper(p(cid:48)) are close in value, knowing nO(1)yi ≤ upper(p) would effectively give us the same for p(cid:48) for free. This suggests that elements with similar marginal differences should be grouped together. The remainder of this section simply formalizes these ideas. In Section 15.4.1 we discuss how we partition the ground set V . In Section 15.4.2, we present our cutting plane method on a subset of the coordinates. Then in Section 15.4.3 we show how we find new arcs. Finally, in Section 15.4.4 we put all of this together to achieve our desired running time. 95 15.4.1 Partitioning Ground Set into Buckets We partition the ground set V into different buckets according to the values of upper(i) and lower(i). This is reminiscent to Iwata-Orlin’s algorithm [60] which considers elements with big upper(i). However they did not need to do bucketing by size or to consider lower(i), whereas these seem necessary for our algorithm. Let N = maxi{max{upper(i),−lower(i)}} be the largest marginal difference in absolute value. By Lemma (78), N ≥ 0. We partition our ground set V as follows: B1 = {i : upper(i) ≥ N/n10 or lower(i) ≤ −N/n10} Bk = {i /∈ B1 ∪ . . . ∪ Bk−1 : N/n10k ≤ upper(i) < N/n10(k−1) or − N/n10(k−1) < lower(i) ≤ −N/n10k}, k ≥ 2 We call Bk buckets. Our buckets group elements by the values of upper(i) and lower(i) at 1/n10 “precision”. There are two cases. • Case 1: the number of buckets is at most log n7, in which case upper(i) > N/nO(log n) or lower(i) < −N/nO(log n) for all i. • Case 2: there is some k for which B1 ∪ . . . ∪ Bk ≥ Bk+1. This is because if there is no such k in Case 2, then by induction each bucket Bk+1 has at least 2kB1 ≥ 2k elements and hence k ≤ log n. Case 1 is easier to handle, and is in fact a special case of Case 2. We first informally sketch the treatment for Case 1 which should shed some light into how we deal with Case 2. We run Cutting Plane for O(n log2 n) iterations (i.e. τ = Θ(log n)). By Theorem 82, our feasible region P would be sandwiched by a pair of approximately parallel supporting hyperplanes of width at most 1/nΘ(log n). Now proceeding as in the last section, we would be able to find some (cid:126)y in the base polyhedron and some element p such that nΘ(log n)yi ≤ upper(p). This gives nΘ(log n)yi ≤ upper(p) nΘ(log n) ≤ N . nΘ(log n) Since upper(i) > N/nΘ(log n) or lower(i) < −N/nΘ(log n) for all i in Case 1, we can then conclude that some valid arc (i, q) or (q, i) can be added for every i. Thus we add n/2 arcs simultaneously in one phase of the algorithm at the expense of blowing up the runtime by O(log n). This saves a factor of n/ log n from our runtime in the last section, and the amortized cost for an arc would then be (cid:101)O(n · EO + n2). useful for acting as a soft boundary between B1 ∪ . . . ∪ Bk and(cid:83) to “ignore”(cid:83) On the other hand, in Case 2 we have a “trough” at Bk+1. Roughly speaking, this trough is l≥k+2 Bl. Recall that we are able l≥k+2 Bl because their hi is relatively small in absolute value. In particular, we know that for any p ∈ B1 ∪ . . . ∪ Bk and i ∈ Bl, where l ≥ k + 2, max{upper(p),−lower(p)} ≥ n10 max{upper(i),−lower(i)}. This is possible because Bk+1, which is sandwiched in between, acts like a shield preventing Bl to “mess with” B1 ∪ . . . ∪ Bk. This property comes at the expense of sacrificing Bk+1 which must confront Bl. Furthermore, we require that B1 ∪ . . . ∪ Bk ≥ Bk+1, and run Cutting Plane on B = (B1 ∪ . . . ∪ Bk) ∪ Bk+1. If Bk+1 (cid:29) B1 ∪ . . . ∪ Bk, our effort would mostly be wasted on Bk+1 which is sacrificed, and the amortized time complexity for B1 ∪ . . . ∪ Bk would then be large. Before discussing the algorithm for Case 2, we need some preparatory work. 7More precisely, Bk = ∅ for k > (cid:100)log n(cid:101). 96 15.4.2 Separating Hyperplane: Project and Lift Our speedup is achieved by running our cutting plane method on the projection of our feasible region onto B := (B1 ∪ ··· ∪ Bk) ∪ Bk+1. More precisely, we start by running our cutting plane on P B = {(cid:126)x ∈ RB : ∃(cid:126)x(cid:48) ∈ R ¯B s.t. ((cid:126)x, (cid:126)x(cid:48)) satisfies (15.1)}, which has a lower dimension. However, to do this, we need to specify a separation oracle for P B. Here we make one of the most natural choices. We begin by making an apparently immaterial change to our set of arcs A. Let us take the transitive closure of A by adding the arc (i, j) whenever there is a path from i to j. Clearly this would not change our ring family as a path from i to j implies j ∈ R(i). Roughly speaking, we do this to handle pathological cases such as (i, k), (k, j) ∈ A, (i, j) /∈ A and i, j ∈ B, k /∈ B. Without introducing the arc (i, j), we risk confusing a solution containing i but not j as feasible since we are restricting our attention to B and ignoring k /∈ B. Definition 88. Given a digraph D = (V, A), the transitive closure of A is the set of arcs (i, j) for which there is a directed path from i to j. We say that A is complete if it is equal to its transitive closure. Given ¯x ∈ [0, 1]B, we define the completion of ¯x with respect to A as follows. i ≤ xC j for every (i, j) ∈ A. Here xC Definition 89. Given ¯x ∈ [0, 1]B and a set of arcs A, xC ∈ [0, 1]n is a completion of ¯x if xC and xC Lemma 90. Given ¯x ∈ [0, 1]B and a complete set of arcs A, there is a completion of ¯x if ¯xi ≤ ¯xj for every (i, j) ∈ A ∩ (B × B). Moreover, it can be computed in O(n2) time. Proof. We set xC B denotes the restriction of xC to B. B = ¯x. For i /∈ B, we set B = ¯x (cid:40) xC i = 1 min(i,j)∈A,j∈B xC j if (cid:64)j ∈ B s.t. (i, j) ∈ A otherwise B(cid:126)xB ≤(cid:80) One may verify that xC satisfies our requirement as A is complete. Computing each xC O(n) time. Since V \B = ¯B ≤ n, computing the whole xC takes O(n2) time. i takes This notion of completion is needed since our original separation oracle requires a full dimen- sional input ¯x. Now that ¯x ∈ RB, we need a way of extending it to Rn while retaining the crucial property that (cid:126)h is consistent with every arc in A. Note that the runtime is still O(n · EO + n2 logO(1) n) as xC can be computed in O(n2) time by the last lemma. We reckon that the hyperplane (cid:126)hT “proxy” to the true separating hyperplane (cid:126)hT (cid:126)x ≤ f (xC) =(cid:80) i∈B hi ¯xi returned by the oracle is not a valid separat- ing hyperplane (i.e. it may cut out the minimizers). Nevertheless, we will show that it is a decent i and is good enough to serve our purpose of sandwiching the remaining feasible region in a small strip. To get a glimpse, note i∈B hi ¯xi all involve hi for i /∈ B, which is “negligible” compared that the terms missing (cid:126)hT to B1 ∪ ··· ∪ Bk. i /∈B hi. The i∈B hi ¯xi < i /∈B hi. Consequently, we lose the width (or volume) guarantee of our cutting plane algorithm. Although this seems problematic, it is actually still possible to show a guarantee i /∈B hi is relatively small. We leave it as a nontrivial exercise to (cid:80) i∈B hi ¯xi +(cid:80) sufficient for our purpose as (cid:80) problem is that such hyperplanes would not be separating for ¯x anymore as (cid:126)hT i∈B hi ¯xi +(cid:80) B ¯x =(cid:80) B(cid:126)xB ≤(cid:80) B(cid:126)xB ≤(cid:80) B(cid:126)xB ≤(cid:80) i∈B hi ¯xi valid, say, by (cid:126)hT One may try to make (cid:126)hT i∈V hixC interested readers. 97 Algorithm 6: Projected Separation Oracle Input: ¯x ∈ RB and a complete set of arcs A if ¯xi < 0 for some i ∈ B then else if ¯xj > 1 for some j ∈ B then else if ¯xi > ¯xj for some (i, j) ∈ A ∩ B2 then Output: xi ≥ 0 Output: xj ≤ 1 Output: xi ≤ xj Let xC ∈ Rn be a completion of ¯x Let i1, . . . , in be a permutation of V such that xC precedes i in i1, . . . , in. Output: (cid:126)hT permutation i1, . . . , in. else B(cid:126)xB =(cid:80) i∈B hixi ≤(cid:80) ≥ . . . ≥ xC in and for all (i, j) ∈ A, j i1 i∈B hi ¯xi, where (cid:126)h is the BFS defined by the In conclusion, it seems that one cannot have the best of both worlds: the hyperplane returned by the oracle cannot be simultaneously valid and separating. Algorithm We take k to be the first for which B1∪ . . .∪ Bk ≥ Bk+1, i.e. B1∪ . . .∪ Bl < Bl+1 for l ≤ k− 1. Thus k ≤ log n. Let b = B, and so B1 ∪···∪ Bk ≥ b/2. Case 1 is a special case by taking B = V . Our algorithm is summarized below. Here A is always complete as A is replaced its transitive closure whenever a new valid arc is added. 1. Run Cutting Plane on P B = {x ∈ RB : ∃x(cid:48) ∈ R ¯B s.t. (x, x(cid:48)) satisfies (15.1)} with the new projected separation oracle. 2. Identify a pair of “narrow” approximately parallel supporting hyperplanes. 3. Deduce from the hyperplanes certain new constraints of the forms xi = 0, xj = 1, xi = xj or xi ≤ xj by lifting separating hyperplanes back to Rn 4. Consolidate A and f . If some xi ≤ xj added, replace A by its transitive closure. 5. Repeat Step 1 with updated A and f . (Any previously found separating hyperplanes are discarded.) The minimizer can be constructed by unraveling the recursion. First of all, to be able to run Cutting Plane on P B we must come up with a polyhedral description of P B which consists of just the constraints involving B. This is shown in the next lemma. Lemma 91. Let P B = {(cid:126)x ∈ RB : ∃(cid:126)x(cid:48) ∈ R ¯B s.t. ((cid:126)x, (cid:126)x(cid:48)) satisfies (15.1)}. Then P B = {(cid:126)x ∈ RB : 0 ≤ (cid:126)x ≤ 1, xi ≤ xj∀(i, j) ∈ A ∩ (B × B)} Proof. It is clear that P B ⊆ {(cid:126)x ∈ RB : 0 ≤ (cid:126)x ≤ 1, xi ≤ xj∀(i, j) ∈ A ∩ (B × B)} as the constraints 0 ≤ x ≤ 1, xi ≤ xj∀(i, j) ∈ A ∩ (B × B) all appear in (15.1). Conversely, for any (cid:126)x ∈ RB satisfying 0 ≤ (cid:126)x ≤ 1, xi ≤ xj∀(i, j) ∈ A ∩ (B × B), we know there is some completion xC of (cid:126)x by Lemma 90 as A is complete. Now xC satisfies (15.1) by definition, and hence (cid:126)x ∈ P B. 98 The only place where we have really changed the algorithm is Step (3). 15.4.3 Deducing New Constraints xi = 0, xj = 1, xi = xj or xi ≤ xj Our method will deduce one of the following: • xi = 0, xj = 1 or xi = xj • for each p ∈ B1 ∪ ··· ∪ Bk, xp ≤ xq for some q /∈ R(p) or xp ≥ xq for some q /∈ Q(p) Our argument is very similar to the last section’s. Roughly speaking, it is the same argument but with “noise” introduced by i /∈ B. We use extensively the notations from the last section. Our main tool is again Theorem 82. Note that n should be replaced by b in the Theorem statement. We invoke it with τ = k logb n = O(log2 n) (using k ≤ log n) to get a width of 1/bΘ(τ ) = 1/nΘ(k). This takes time at most O(bn log2 n·EO+bn2 logO(1) n). Again, this is intuitively clear as we run it for O(kb log n) iterations, each of which takes time O(n · EO + n2 logO(1) n). After each phase of (roughly O(kb log n) iterations) of Cutting Plane, P B is sandwiched between a pair of approximately parallel supporting hyperplanes F and F (cid:48) which have width 1/n20k. Let F and F (cid:48) be (cid:126)cT (cid:126)xB = cixi ≤ M, (cid:126)c(cid:48)T (cid:126)xB = ixi ≤ M(cid:48), c(cid:48) such that M + M(cid:48), (cid:126)c + (cid:126)c(cid:48)2 ≤ gap, where gap = basically geared towards bringing the amortized cost for identifying a valid arc down to (cid:101)O(n · The rest of this section presents an execution of the ideas discussed above. All of our work is EO + n2). Again, we can write these two constraints as a nonnegative combination. Here ¯xC the completion of the point ¯xh used to construct (cid:126)hT restriction of ¯xC n20k min{(cid:126)c2,(cid:126)c(cid:48)2}. (cid:0)¯xC h is B is the (cid:1) 1 B h h h to B.) (cid:126)cT (cid:126)xB = −(cid:88) (cid:126)c(cid:48)T (cid:126)xB = −(cid:88) i∈B i∈B (cid:88) (cid:88) j∈B j∈B αixi+ βjxj+ (i,j)∈A∩B2 γij(xi−xj)+ B(cid:126)xB and M = α(cid:48) ixi+ β(cid:48) jxj+ ij(xi−xj)+ γ(cid:48) λ(cid:48) B(cid:126)xB and M(cid:48) = (cid:126)hT h (i,j)∈A∩B2 (cid:1) B. (Recall that (cid:0)¯xC (cid:88) (cid:88) (cid:0)¯xC (cid:1) (cid:88) (cid:88) j∈B B(cid:126)xB ≤ (cid:126)hT β(cid:48) j+ h∈H βj+ j∈B h∈H B h (cid:1) (cid:0)¯xC (cid:0)¯xC h B . (cid:1) B . λh (cid:126)hT B λ(cid:48) (cid:126)hT B h (cid:88) i∈B (cid:88) (cid:88) (cid:88) i∈B B(cid:126)xB ≤ (cid:126)hT (cid:88) (cid:88) (cid:126)hT λh h∈H h∈H As we have discussed, the problem is that the separating hyperplanes (cid:126)hT B are not actually valid. We can, however, recover their valid counterpart by lifting them back to (cid:126)hT (cid:126)x ≤ (cid:126)hT ¯xC h. The hope is that (cid:126)hT h are not too different so that the arguments will still go through. We show that this is indeed the case. (cid:0)¯xC (cid:1) B h B(cid:126)xB ≤ (cid:126)hT B and (cid:126)hT (cid:126)x ≤ (cid:126)hT ¯xC Again, we scale c, c(cid:48), α, α(cid:48), β, β(cid:48), γ, γ(cid:48), λ, λ(cid:48) so that (λh + λ(cid:48) (cid:88) h h) = 1. h∈H By adding all the constituent separating hyperplane inequalities, we get 99 h∈H λh (cid:88) (cid:88) (cid:88) h∈H (cid:126)hT ¯xC h αixi + Let LHS def= (cid:88) Here we know that(cid:88) (cid:88) (cid:88) (cid:88) h∈H (cid:126)hT ¯xC LHS+((cid:126)c+(cid:126)c(cid:48))T (cid:126)xB+ h∈H h∈H h + λ(cid:48) λh λh (cid:126)hT (cid:126)x + (cid:88) h∈H (cid:126)hT ¯xC h + λh λ(cid:48) h (cid:126)hT ¯xC h (cid:126)hT (cid:126)x + (cid:88) ixi −(cid:88) h∈H h λ(cid:48) (cid:126)hT (cid:126)x ≤ (cid:88) βjxj −(cid:88) h∈H α(cid:48) β(cid:48) jxj + γij(xj − xi) + ij(xj − xi). γ(cid:48) λ(cid:48) h (cid:126)hT (cid:126)x = LHS + ((cid:126)c + (cid:126)c(cid:48))T (cid:126)xB + (cid:126)hT ¯B(cid:126)x ¯B + (cid:126)hT ¯B(cid:126)x ¯B h (cid:88) (cid:88) (cid:88) h∈H λh ¯B + h∈H (cid:1) (cid:0)¯xC h (cid:88) h∈H λ(cid:48) (cid:88) (cid:88) ¯B −(cid:88) (cid:1) (cid:0)¯xC (cid:88) (cid:1) h∈H h j β(cid:48) βj −(cid:88) ¯B−(cid:88) (cid:1) (cid:0)¯xC βj −(cid:88) ngap. Since β(cid:48) h j βj−(cid:88) β(cid:48) j h = (M + M(cid:48)) + λh (cid:126)hT ¯B λ(cid:48) (cid:126)hT ¯B h (cid:88) λh (cid:126)hT ¯B(cid:126)x ¯B+ Combining all yields (cid:0)¯xC λ(cid:48) Here ((cid:126)c + (cid:126)c(cid:48))T (cid:126)xB can be bounded as before: ((cid:126)c + (cid:126)c(cid:48))T (cid:126)xB ≥ −√ n(cid:126)c + (cid:126)c(cid:48)2 ≥ −√ ¯B −(cid:88) (cid:88) (cid:88) ¯B(cid:126)x ¯B ≤ (M +M(cid:48))+ (cid:126)hT h √ ¯B(cid:126)x ¯B ≤ 2 (cid:126)hT h M + M(cid:48) ≤ gap, We then obtain (cid:0)¯xC (cid:0)¯xC (cid:88) (cid:88) (cid:126)hT ¯B(cid:126)x ¯B + LHS + ngap + (cid:126)hT ¯B h (cid:126)hT ¯B h ¯B + h∈H h∈H h∈H h∈H ¯B+ (cid:126)hT ¯B (cid:126)hT ¯B (cid:1) (cid:1) λ(cid:48) λ(cid:48) λ(cid:48) λh λh λh h h h (cid:88) h∈H h∈H h∈H h∈H We should expect the contribution from (cid:126)h ¯B to be small as hi for i /∈ B is small compared to B1 ∪ . . . ∪ Bk. We formalize our argument in the next two lemmas. upper(i) ≤ N/n10(k+1). By Lemma 78 hi ≤ upper(i). Therefore, (cid:126)hT ¯B h (cid:1) h (cid:1) (cid:0)¯xC ¯B +(cid:80) (cid:88) h∈H λ(cid:48) h h h∈H λh h∈H λ(cid:48) (cid:126)hT ¯B ¯B +(cid:80) (cid:0)¯xC (cid:32)(cid:88) (cid:88) h∈H h (cid:126)hT ¯B h∈H λh (cid:88) (cid:88) (cid:1) (cid:0)¯xC Lemma 92. We have(cid:80) Proof. We bound each component of(cid:80) (cid:1) (cid:0)¯xC i ≤ (cid:0)¯xC (cid:1) ¯B(cid:126)x ¯B +(cid:80) (cid:1) (cid:0)¯xC (cid:1) (cid:0)¯xC Lemma 93. We have(cid:80) Our result then follows since (cid:88) (cid:88) h∈H λh (cid:126)hT ¯B h ¯B + (cid:126)hT i h h∈H h∈H h∈H h∈H (cid:126)hT ¯B i + (cid:126)hT i (cid:126)hT λ(cid:48) λ(cid:48) λh λh h h h h ¯B = λh + (cid:32)(cid:88) i∈ ¯B h∈H (cid:0)¯xC (cid:1) ¯B ≤ N/n10(k+1)−1. h∈H λ(cid:48) (cid:33) (cid:126)hT ¯B h h ¯B. For i ∈ ¯B, we have N/n10(k+1) = N/n10(k+1). (cid:1) (cid:0)¯xC h i + (cid:88) h∈H λ(cid:48) (cid:126)hT i h λh (cid:126)hT i (cid:33) . (cid:1) (cid:0)¯xC h i h∈H λ(cid:48) ¯B(cid:126)x ¯B ≥ −N/n10(k+1)−1. (cid:126)hT h Proof. The proof is almost identical to the last lemma except that we use hi ≥ lower(i) instead of hi ≤ upper(i), and lower(i) ≥ −N/n10(k+1). The two lemmas above imply that ngap −(cid:88) βj −(cid:88) √ LHS ≤ 2 √ where gap(cid:48) = 2 ngap + 2N/n10(k+1)−1. 100 βj + 2N/n10(k+1)−1 = gap (cid:48) −(cid:88) βj −(cid:88) βj Lemma 94. Suppose x satisfies (15.1) and LHS ≤ gap(cid:48)−(cid:80) βj −(cid:80) β(cid:48) j with αi, βj, γij, α(cid:48) i, β(cid:48) j, γ(cid:48) ij ≥ 0. 1. If αi > gap(cid:48) or α(cid:48) 2. If βj > gap(cid:48) or β(cid:48) 3. If γij > gap(cid:48) or γ(cid:48) i > gap(cid:48), then xi < 1. j > gap(cid:48), then xj > 0. ij > gap(cid:48), then 0 ≤ xj − xi < 1. Proof. The proof is exactly the same as Lemma 84 with 2 From now on we may assume that √ ngap replaced by gap(cid:48). ij} ≤ gap (cid:48). i, βj, β(cid:48) j, γij, γ(cid:48) max{αi, α(cid:48) (cid:126)h and (cid:126)y(cid:48) def=(cid:80) Lemma 95. Let (cid:126)y def=(cid:80) N ≥ n10k+6(cid:13)(cid:13)(cid:126)yB + (cid:126)y(cid:48) Proof. Recall that(cid:13)(cid:13)(cid:126)c +(cid:126)c(cid:48)(cid:13)(cid:13)2 ≤ gap < gap(cid:48) where gap = 1 assuming (15.9). h∈H λ(cid:48) h∈H λh 2N/n10(k+1)−1. Now there are two cases. h ngap ≥ 2N/n10(k+1)−1. Then gap(cid:48) ≤ 4 √ Case 1: 2 (cid:13)(cid:13)∞ B (cid:126)h and let p ∈ arg maxl∈B{max{yl,y(cid:48) (15.9) l} then √ n20k min{(cid:126)c2,(cid:126)c(cid:48)2} and gap(cid:48) = 2 √ ngap and we follow the same proof of ngap + B (i,j) B (cid:48) (i,j) and that B n17k Lemma 85. We have i j i j β(cid:48) j (cid:126)1j + α(cid:48) (cid:126)1i + i αi(cid:126)1i + βj(cid:126)1j + (cid:88) (cid:88) and (cid:126)c(cid:48) = (cid:126)y(cid:48) γij((cid:126)1i −(cid:126)1j) ij((cid:126)1i −(cid:126)1j) . γ(cid:48) (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2. n17k Consequently, by the triangle inequality we have that (cid:13)(cid:13)(cid:126)yB + (cid:126)y(cid:48) (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 ≤(cid:13)(cid:13)(cid:126)c − (cid:126)yB (cid:88) (cid:13)(cid:13)2 ≤ 4n2gap(cid:48) ≤ 1 (cid:126)c = (cid:126)yB −(cid:88) (cid:88) B −(cid:88) (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 and (cid:13)(cid:13)(cid:126)c(cid:48) − (cid:126)y(cid:48) (cid:13)(cid:13)2 ≤ 4n2gap(cid:48) ≤ 1 By (15.9) we know that (cid:13)(cid:13)(cid:126)c − (cid:126)yB (cid:13)(cid:13)2 ≤ 9n2gap (cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)c(cid:48) − (cid:126)y(cid:48) (cid:13)(cid:13)2 ≤(cid:13)(cid:13)(cid:126)c + (cid:126)c(cid:48)(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)c − (cid:126)yB (cid:13)(cid:13)2 ≤ 1 (cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)yB (cid:13)(cid:13)2 ⇒ (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 ≤ 2(cid:13)(cid:13)(cid:126)yB (cid:13)(cid:13)(cid:126)c(cid:13)(cid:13)2 +(cid:13)(cid:13)(cid:126)yB (cid:13)(cid:13)2. Consequently since gap(cid:48) ≤ 1 Similarly, we have that(cid:13)(cid:13)(cid:126)c(cid:48)(cid:13)(cid:13)2 ≤ 2(cid:13)(cid:13)(cid:126)y(cid:48) n19k min{(cid:126)c2,(cid:126)c(cid:48)2}, we have n17k min(cid:8)(cid:13)(cid:13)(cid:126)yB (cid:13)(cid:13)2 ≤ 18 (cid:13)(cid:13)(cid:126)yB + (cid:126)y(cid:48) (cid:13)(cid:13)2 (cid:13)(cid:13)2,(cid:13)(cid:13)(cid:126)y(cid:48) (cid:9) (cid:13)(cid:13)∞, as desired. and thus, invoking Lemma 81 yields N ≥ upper(p) ≥ n16k(cid:13)(cid:13)(cid:126)yB + (cid:126)y(cid:48) (cid:126)1j −(cid:88) (cid:126)1i −(cid:88) (cid:88) βj(cid:126)1j −(cid:88) (cid:13)(cid:13)∞ ≤ 2N/n10(k+1)−1 + 2n1.5gap αi(cid:126)1i −(cid:88) (cid:88) (cid:13)(cid:13)(cid:126)yB + (cid:126)y(cid:48) ngap < 2N/n10(k+1)−1. Then for any i ∈ B, ci + c(cid:48) 2N/n10(k+1)−1. Since B = ((cid:126)c + (cid:126)c(cid:48)) + (cid:126)yB + (cid:126)y(cid:48) i ≤ (cid:126)c + (cid:126)c(cid:48)2 ≤ gap < √ Case 2: 2 γij((cid:126)1i − (cid:126)1j) + (cid:48) ≤ N/n10k+7. ij((cid:126)1i − (cid:126)1j) γ(cid:48) (cid:13)(cid:13)2 we have i j i j B B B B α(cid:48) i n17k β(cid:48) j (i,j) B (i,j) 101 Corollary 96. Let P be the feasible region after running Cutting Plane on (15.1) with the projected separation oracle. Then one of the following holds: 1. We found a BFS (cid:126)h with (cid:126)hB = 0. 2. The integral points of P all lie on some hyperplane xi = 0, xj = 1 or xi = xj. 3. Let H be the collection of BFS’s (cid:126)h used to construct our separating hyperplanes for P . Then there is a convex combination (cid:126)y of H such that for p ∈ B1∪···∪Bk, we have n4yi < upper(p) or lower(p) < −n4yi for all i. 94 holds. Otherwise, we claim y = (cid:80) h λhh +(cid:80) Proof. As mentioned before, (1) happens if some separating hyperplane satisfies (cid:126)hB = 0 when running cutting plane on the non-negligible coordinates. We have (2) if some condition in Lemma hh is a candidate for Case 3. y is a convex combination of BFS and by Lemma 95, for the big elements i ∈ B we have n4 max{upper(p),−lower(p)}. yi ≤ N/n10k+6 ≤ 1 h λ(cid:48) as desired. where the last inequality holds since for p ∈ B1 ∪ ··· ∪ Bk, max{upper(p),−lower(p)} ≥ N/n10k. On the other hand, for the small elements i /∈ B, yi ≤ N/n10(k+1) ≤ 1 n4 max{upper(p),−lower(p)} 80. Therefore we can add a total of B1 ∪ ··· ∪ Bk/2 ≥ b/4 arcs with roughly O(kb log n) = (cid:101)O(b) iterations of Cutting Plane, each of which takes (cid:101)O(n · EO + n2). That is, the amortized cost for each arc is (cid:101)O(n· EO + n2). We give a more formal time analysis in below but it should be somewhat The gap is then smaller enough to add an arc for each p ∈ B1 ∪ ··· ∪ Bk by Lemmas 79 and clear why we have the desired time complexity. Lemma 97. Suppose there is a convex combination (cid:126)y of H such that for p ∈ B1 ∪ ··· ∪ Bk, we have n4yi < upper(p) or lower(p) < −n4yi for all i. Then we can identify at least b/4 new valid arcs. Proof. We have H = O(n) since H is the set of BFS’s used for the constraints of P which has O(n) constraints. By Lemmas 79 and 80, for p ∈ B1 ∪ ··· ∪ Bk we can add a new valid arc (p, q) or (q, p). However note that a new arc (p1, p2) may added twice by both p1 and p2. Therefore the total number of new arcs is only at least B1 ∪ ··· ∪ Bk/2 ≥ b/4. 15.4.4 Running Time Not much changes to the previous runtime analysis are needed. To avoid repetition, various details already present in the corresponding part of the last section are omitted. Recall k ≤ log n, and of course, b ≤ n. For each (roughly) O(kb log n) iterations of Cutting Plane we either get xi = 0,xi = 1,xi = xj or b/4 xi ≤ xj’s. The former can happen at most n times while in the latter case, the amortized cost of each arc is O(k log n) iterations of Cutting Plane. In the worst case the overall number of iterations required is (cid:101)O(n2). Thus our algorithm has a runtime of (cid:101)O(n3 · EO + n4) since each iteration is (cid:101)O(n · EO + n2) as shown below. Theorem 98. Our algorithm runs in time O(n3 log2 n · EO + n4 logO(1) n). 102 Proof. We use Corollary 96. First we note that Case 1 can actually be integrated into Case 3 since max{upper(p),−lower(p)} ≥ N/n10k = n10N/n10(k+1) ≥ hi for i /∈ B. As we have argued in the beginning of the last section, Theorem 82 with τ = k logb n implies that the runtime for each phase is O(bn log2 n · EO + bn2 logO(1) n). In each phase we either get xi = 0, xi = 1, xi = xj (Case 2) or b/4 xi ≤ xj’s (Case 3), the latter of which follows from Corollary 96 and Lemma 97. Case 2 can only happen n times. Thus the total cost is at most O(n3 log2 n· EO + n4 logO(1) n). The overhead cost is also small. Similar to before, given F and F (cid:48) represented as a nonnegative combination of facets, we can check for the conditions in Lemma 94 in O(n) time as there are only this many facets of P . This settles Case 2. For case 3 the amortized cost for each arc is O(n log2 n· EO + n2 logO(1) n). Our desired runtime follows since there are only O(n2) arcs to add. Unlike Case 2 some extra care is needed to handle the overhead cost. The time needed to deduce a new arc (applying Lemmas 79 and 80 to (cid:126)y and p ∈ B1 ∪ ··· ∪ Bk) is still O(n · EO + n2). But as soon as we get a new arc, we must update A to be its transitive closure so that it is still complete. Given A complete and a new arc (p, q) /∈ A, we can simply add the arcs from the ancestors of p to q and from p to the descendants of q. There are at most O(n) arcs to add so this takes time O(n2) per arc, which is okay. 16 Discussion and Comparison with Previous Algorithms We compare and contrast our algorithms with the previous ones. We focus primarily on strongly polynomial time algorithms. Convex combination of BFS’s All of the previous algorithms maintain a convex combination of BFS’s and iteratively improve over it to get a better primal solution. In particular, the new BFS’s used are typically obtained by making local changes to existing ones. Our algorithms, on the other hand, considers the geometry of the existing BFS’s. The weighted “influences”8 then aggregately govern the choice of the next BFS. We believe that this is the main driving force for the speedup of our algorithms. Scaling schemes Many algorithms for combinatorial problems are explicitly or implicitly scaling a potential function or a parameter. In this paper, our algorithms in some sense aim to minimize the volume of the feasible region. Scaling schemes for different potential functions and parameters were also designed in previous works [56, 54, 60, 53]. All of these functions and parameters have an explict form. On the contrary, our potential function is somewhat unusual in the sense that it has no closed form. Deducing new constraints As mentioned in the main text, our algorithms share the same skeleton and tools for deducing new constraints with [56, 54, 60, 53]. Nevertheless, there are differences in the way these tools are employed. Our algorithms proceed by invoking them in a geometric manner, whereas previous algorithms were mostly combinatorial. Big elements and bucketing Our bucketing idea has roots in Iwata-Orlin’s algorithm [60] but is much more sophisticated. For instance, it is sufficient for their algorithm to consider only big elements, i.e. upper(i) ≥ N/nO(1). Our algorithm, on the other hand, must carefully group elements by the size of both upper(i) and 8In the terminology of Part I, these weighted influences are the leverage scores. 103 lower(i). The speedup appears impossible without these new ideas. We do however note that it is unfair to expect such a sophisticated scheme in Iwata-Orlin’s algorithm as it would not lead to a speedup. In other words, their method is fully sufficient for their purposes, and the simplicity in their case is a virtue rather than a shortcoming. 16.1 Open Problems One natural open problem is improving our weakly polynomial algorithm to O(n2 log M · EO + n3 logO(1) n · log M ) time. Our application of center of mass to SFM demonstrates that it should be possible. For strongly polynomial algorithms, the existential result of Theorem 71 shows that SFM can be solved with O(n3 log n · EO) oracle calls. Unfortunately, our algorithm incurs an overhead of log n as there can be as many as log n buckets each time. One may try to remove this log n overhead by designing a better bucketing scheme or arguing that more arcs can be added. The other log n overhead seem much trickier to remove. Our method currently makes crucial use of the tools developed by [56], where the log n factors in the runtime seem inevitable. We suspect that our algorithm may have an analogue similar to [93, 90], which do not carry any log n overhead in the running time. Perhaps an even more interesting open problem is whether our algorithm is optimal (up to polylogarithmic factors). There are grounds for optimism. So far the best way of certifying the optimality of a given solution S ⊆ V is to employ duality and express some optimal solution to the base polyhedron as a convex combination of n + 1 BFS’s. This already takes n2 oracle calls as each BFS requires n. Thus one would expect the optimal number of oracle calls needed for SFM to be at least n2. Our bound is not too far off from it, and anything strictly between n2 and n3 seems instinctively unnatural. Acknowledgments We thank Matt Weinberg for insightful comments about submodular minimization and minimizing the intersection of convex sets that were deeply influential to our work. We thank Yan Kit Chim, Stefanie Jegelka, Jonathan A. Kelner, Robert Kleinberg, Pak-Hin Lee, Christos Papadimitriou, and Chit Yu Ng for many helpful conversations. We thank Chien-Chung Huang for pointing out a typo in an earlier draft of this paper. This work was partially supported by NSF awards 0843915 and 1111109, NSF grants CCF0964033 and CCF1408635, Templeton Foundation grant 3966, NSF Graduate Research Fellowship (grant no. 1122374). Part of this work was done while the first two authors were visiting the Simons Institute for the Theory of Computing, UC Berkeley. Lastly, we would like to thank Vaidya for his beautiful work on his cutting plane method. References [1] Dimitris Achlioptas. Database-friendly random projections: Johnson-lindenstrauss with bi- nary coins. Journal of computer and System Sciences, 66(4):671–687, 2003. [2] Martin Aigner and Thomas A Dowling. Matching theory for combinatorial geometries. Trans- actions of the American Mathematical Society, 158(1):231–245, 1971. 104 [3] Zeyuan Allen-Zhu, Yin Tat Lee, and Lorenzo Orecchia. Using optimization to obtain arXiv preprint a width-independent, parallel, simpler, and faster positive sdp solver. arXiv:1507.02259, 2015. [4] Kurt M Anstreicher. Large step volumetric potential reduction algorithms for linear pro- gramming. Annals of Operations Research, 62(1):521–538, 1996. [5] Kurt M Anstreicher. On vaidya’s volumetric cutting plane method for convex programming. Mathematics of Operations Research, 22(1):63–89, 1997. [6] Kurt M Anstreicher. Towards a practical volumetric cutting plane method for convex pro- gramming. SIAM Journal on Optimization, 9(1):190–206, 1998. [7] Kurt M Anstreicher. The volumetric barrier for semidefinite programming. Mathematics of Operations Research, 25(3):365–380, 2000. [8] Sanjeev Arora, Elad Hazan, and Satyen Kale. Fast algorithms for approximate semidefinite programming using the multiplicative weights update method. In Foundations of Computer Science, 2005. FOCS 2005. 46th Annual IEEE Symposium on, pages 339–348. IEEE, 2005. [9] Sanjeev Arora and Satyen Kale. A combinatorial, primal-dual approach to semidefinite pro- grams. In Proceedings of the thirty-ninth annual ACM symposium on Theory of computing, pages 227–236. ACM, 2007. [10] David S Atkinson and Pravin M Vaidya. A cutting plane algorithm for convex programming that uses analytic centers. Mathematical Programming, 69(1-3):1–43, 1995. [11] Francis Bach. Learning with submodular functions: A convex optimization perspective. Foundations and Trends in Machine Learning, 2013. [12] Francisco Barahona and William H Cunningham. A submodular network simplex method. In Mathematical Programming at Oberwolfach II, pages 9–31. Springer, 1984. [13] Dimitris Bertsimas and Santosh Vempala. Solving convex programs by random walks. Journal of the ACM (JACM), 51(4):540–556, 2004. [14] Carl Brezovec, Gerard Cornu´ejols, and Fred Glover. Two algorithms for weighted matroid intersection. Mathematical Programming, 36(1):39–53, 1986. [15] S´ebastien Bubeck, Yin Tat Lee, and Mohit Singh. A geometric alternative to nesterov’s accelerated gradient descent. arXiv preprint arXiv:1506.08187, 2015. [16] Yang Cai, Constantinos Daskalakis, and S Matthew Weinberg. Optimal multi-dimensional mechanism design: Reducing revenue to welfare maximization. In Foundations of Computer Science (FOCS), 2012 IEEE 53rd Annual Symposium on, pages 130–139. IEEE, 2012. [17] Yang Cai, Constantinos Daskalakis, and S Matthew Weinberg. Reducing revenue to wel- fare maximization: Approximation algorithms and other generalizations. In Proceedings of the Twenty-Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 578–595. SIAM, 2013. [18] Nam-Kee Chung and Dong-Wan Tcha. A dual algorithm for submodular flow problems. Operations research letters, 10(8):489–495, 1991. 105 [19] Michael B. Cohen, Yin Tat Lee, Cameron Musco, Christopher Musco, Richard Peng, and Aaron Sidford. Uniform sampling for matrix approximation. CoRR, abs/1408.5099, 2014. [20] William H Cunningham. On submodular function minimization. Combinatorica, 5(3):185– 192, 1985. [21] William H Cunningham. Improved bounds for matroid partition and intersection algorithms. SIAM Journal on Computing, 15(4):948–957, 1986. [22] William H Cunningham and Andr´as Frank. A primal-dual algorithm for submodular flows. Mathematics of Operations Research, 10(2):251–262, 1985. [23] Constantinos Daskalakis and S Matthew Weinberg. Bayesian truthful mechanisms for job scheduling from bi-criterion approximation algorithms. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1934–1952. SIAM, 2015. [24] James Demmel, Ioana Dumitriu, Olga Holtz, and Robert Kleinberg. Fast matrix multiplica- tion is stable. Numerische Mathematik, 106(2):199–224, 2007. [25] EA Dinic. An algorithm for the solution of the max-flow problem with the polynomial estimation. Doklady Akademii Nauk SSSR, 194(4):1277–1280, 1970. [26] Jack Edmonds. Matroid partition. Mathematics of the Decision Sciences, 11:335–345, 1968. [27] Jack Edmonds. Submodular functions, matroids, and certain polyhedra. Edited by G. Goos, J. Hartmanis, and J. van Leeuwen, page 11, 1970. [28] Jack Edmonds. Matroid intersection. Annals of discrete Mathematics, 4:39–49, 1979. [29] Jack Edmonds and Rick Giles. A min-max relation for submodular functions on graphs. Stud- ies in Integer Programming (PL Hammer, EL Johnson and BH Korte, eds.), Ann. Discrete Math, 1:185–204, 1977. [30] Lisa Fleischer and Satoru Iwata. Improved algorithms for submodular function minimization and submodular flow. In Proceedings of the thirty-second annual ACM symposium on Theory of computing, pages 107–116. ACM, 2000. [31] Lisa Fleischer and Satoru Iwata. A push-relabel framework for submodular function minimiza- tion and applications to parametric optimization. Discrete Applied Mathematics, 131(2):311– 322, 2003. [32] Lisa Fleischer, Satoru Iwata, and S Thomas McCormick. A faster capacity scaling algorithm for minimum cost submodular flow. Mathematical Programming, 92(1):119–139, 2002. [33] Andr´as Frank. A weighted matroid intersection algorithm. Journal of Algorithms, 2(4):328– 336, 1981. [34] Andr´as Frank and ´Eva Tardos. An application of simultaneous diophantine approximation in combinatorial optimization. Combinatorica, 7(1):49–65, 1987. [35] S. Fujishige. Algorithms for solving the independent-flow problems. Journal of the Operations Research Society of Japan, 1978. 106 [36] Satoru Fujishige. An out-of-kilter method for submodular flows. Discrete applied mathematics, 17(1):3–16, 1987. [37] Satoru Fujishige and Satoru Iwata. Algorithms for submodular flows. IEICE TRANSAC- TIONS on Information and Systems, 83(3):322–329, 2000. [38] Satoru Fujishige, Hans Rock, and Uwe Zimmermann. A strongly polynomial algorithm for minimum cost submodular flow problems. Mathematics of Operations Research, 14(1):60–69, 1989. [39] Satoru Fujishige and Zhang Xiaodong. An efficient cost scaling algorithm for the independent assignment problem. Journal of the Operations Research Society of Japan, 38(1):124–136, 1995. [40] Mituhiro Fukuda, Masakazu Kojima, Kazuo Murota, and Kazuhide Nakata. Exploiting spar- sity in semidefinite programming via matrix completion i: General framework. SIAM Journal on Optimization, 11(3):647–674, 2001. [41] Fran¸cois Le Gall. Powers of tensors and fast matrix multiplication. arXiv preprint arXiv:1401.7714, 2014. [42] J-L Goffin, Jacek Gondzio, Robert Sarkissian, and J-P Vial. Solving nonlinear multicommod- ity flow problems by the analytic center cutting plane method. Mathematical Programming, 76(1):131–154, 1997. [43] Jean-Louis Goffin, Zhi-Quan Luo, and Yinyu Ye. Complexity analysis of an interior cutting plane method for convex feasibility problems. SIAM Journal on Optimization, 6(3):638–652, 1996. [44] Jean-Louis Goffin and Jean-Philippe Vial. Shallow, deep and very deep cuts in the analytic center cutting plane method. Mathematical Programming, 84(1):89–103, 1999. [45] Jean-Louis Goffin and Jean-Philippe Vial. Convex nondifferentiable optimization: A survey focused on the analytic center cutting plane method. Optimization Methods and Software, 17(5):805–867, 2002. [46] Andrew V Goldberg and Robert E Tarjan. A new approach to the maximum-flow problem. Journal of the ACM (JACM), 35(4):921–940, 1988. [47] Andrew V Goldberg and Robert E Tarjan. Finding minimum-cost circulations by successive approximation. Mathematics of Operations Research, 15(3):430–466, 1990. [48] Jacek Gondzio, O Du Merle, Robert Sarkissian, and J-P Vial. Accpmı¿oexa library for convex optimization based on an analytic center cutting plane method. European Journal of Operational Research, 94(1):206–211, 1996. [49] Martin Grotschel, L´aszl´o Lov´asz, and Alexander Schrijver. The ellipsoid method and its consequences in combinatorial optimization. Combinatorica, 1(2):169–197, 1981. [50] Martin Grotschel, L´aszl´o Lov´asz, and Alexander Schrijver. Geometric algorithms and com- binatorial optimization. Springer, 1988. [51] Christoph Helmberg and Franz Rendl. A spectral bundle method for semidefinite program- ming. SIAM Journal on Optimization, 10(3):673–696, 2000. 107 [52] Satoru Iwata. A capacity scaling algorithm for convex cost submodular flows. Mathematical programming, 76(2):299–308, 1997. [53] Satoru Iwata. A fully combinatorial algorithm for submodular function minimization. Journal of Combinatorial Theory, Series B, 84(2):203–212, 2002. [54] Satoru Iwata. A faster scaling algorithm for minimizing submodular functions. SIAM Journal on Computing, 32(4):833–840, 2003. [55] Satoru Iwata. Submodular function minimization. Mathematical Programming, 112(1):45–64, 2008. [56] Satoru Iwata, Lisa Fleischer, and Satoru Fujishige. A combinatorial strongly polynomial algorithm for minimizing submodular functions. Journal of the ACM (JACM), 48(4):761– 777, 2001. [57] Satoru Iwata, S Thomas McCormick, and Maiko Shigeno. A faster algorithm for minimum cost submodular flows. In SODA, pages 167–174, 1998. [58] Satoru Iwata, S Thomas McCormick, and Maiko Shigeno. A strongly polynomial cut canceling In Integer Programming and Combinatorial algorithm for the submodular flow problem. Optimization, pages 259–272. Springer, 1999. [59] Satoru Iwata, S Thomas McCormick, and Maiko Shigeno. A fast cost scaling algorithm for submodular flow. Information Processing Letters, 74(3):123–128, 2000. [60] Satoru Iwata and James B Orlin. A simple combinatorial algorithm for submodular function minimization. In Proceedings of the twentieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1230–1237. Society for Industrial and Applied Mathematics, 2009. [61] Rahul Jain and Penghui Yao. A parallel approximation algorithm for positive semidefinite programming. In Foundations of Computer Science (FOCS), 2011 IEEE 52nd Annual Sym- posium on, pages 463–471. IEEE, 2011. [62] Klaus Jansen. Approximate strong separation with application in fractional graph coloring and preemptive scheduling. Theoretical Computer Science, 302(1):239–256, 2003. [63] Ravindran Kannan and Hariharan Narayanan. Random walks on polytopes and an affine interior point method for linear programming. Mathematics of Operations Research, 37(1):1– 20, 2012. [64] Richard M Karp and Christos H Papadimitriou. On linear characterizations of combinatorial optimization problems. SIAM Journal on Computing, 11(4):620–632, 1982. [65] Leonid G Khachiyan. Polynomial algorithms in linear programming. USSR Computational Mathematics and Mathematical Physics, 20(1):53–72, 1980. [66] LG Khachiyan, SP Tarasov, and II Erlikh. The method of inscribed ellipsoids. In Soviet Math. Dokl, volume 37, pages 226–230, 1988. [67] Adam R Klivans and Daniel Spielman. Randomness efficient identity testing of multivari- In Proceedings of the thirty-third annual ACM symposium on Theory of ate polynomials. computing, pages 216–223. ACM, 2001. 108 [68] Andreas Krause. http://submodularity.org/. [69] Kartik Krishnan and John E Mitchell. A unifying framework for several cutting plane methods for semidefinite programming. Optimization methods and software, 21(1):57–74, 2006. [70] Kartik Krishnan and John E Mitchell. Properties of a cutting plane method for semidefinite programming. Pacific Journal of Optimization, 8(4):779–802, 2012. [71] Kartik Krishnan and Tam´as Terlaky. Interior point and semidefinite approaches in combina- torial optimization. In Graph theory and combinatorial optimization, pages 101–157. Springer, 2005. [72] Eugene L Lawler. Matroid intersection algorithms. Mathematical programming, 9(1):31–56, 1975. [73] Yin Tat Lee, Satish Rao, and Nikhil Srivastava. A new approach to computing maximum flows using electrical flows. In The 45th ACM Symposium on Theory of Computing (STOC), pages 755–764, 2013. [74] Yin Tat Lee and Aaron Sidford. Path finding ii: An\ o (m sqrt (n)) algorithm for the minimum cost flow problem. arXiv preprint arXiv:1312.6713, 2013. [75] Yin Tat Lee and Aaron Sidford. Path-finding methods for linear programming : Solving linear programs in o(sqrt(rank)) iterations and faster algorithms for maximum flow. In 55th Annual IEEE Symposium on Foundations of Computer Science, FOCS 2014, 18-21 October, 2014, Philadelphia, PA, USA, pages 424–433, 2014. [76] Yin Tat Lee and Aaron Sidford. Efficient inverse maintenance and faster algorithms for linear programming. arXiv preprint arXiv:1503.01752, 2015. [77] A. Yu Levin. On an algorithm for the minimization of convex functions. Soviet Math. Doklady, 1965. [78] Mu Li, Gary L Miller, and Richard Peng. Iterative row sampling. 2012. [79] L´aszl´o Lov´asz and Santosh Vempala. Simulated annealing in convex bodies and an o*(n4) volume algorithm. J. Comput. Syst. Sci., 72(2):392–417, 2006. [80] Michael W. Mahoney. Randomized algorithms for matrices and data. Foundations and Trends in Machine Learning, 3(2):123–224, 2011. [81] S McCormick. Submodular Function Minimization. 2013. [82] S Thomas and McCormick. Canceling most helpful total submodular cuts for submodular flow. In IPCO, pages 343–353, 1993. [83] Renato DC Monteiro. First-and second-order methods for semidefinite programming. Math- ematical Programming, 97(1-2):209–244, 2003. [84] Kazuhide Nakata, Katsuki Fujisawa, Mituhiro Fukuda, Masakazu Kojima, and Kazuo Murota. Exploiting sparsity in semidefinite programming via matrix completion ii: Imple- mentation and numerical results. Mathematical Programming, 95(2):303–327, 2003. [85] Arkadi Nemirovski. Efficient methods in convex programming. 1994. 109 [86] D. B. Nemirovsky, A. S., & Yudin. Problem complexity and method efficiency in optimization. 1983. [87] Yu Nesterov. Complexity estimates of some cutting plane methods based on the analytic barrier. Mathematical Programming, 69(1-3):149–176, 1995. [88] Yu Nesterov and Arkadi Nemirovskiy. Self-concordant functions and polynomial-time meth- ods in convex programming. USSR Academy of Sciences, Central Economic & Mathematic Institute, 1989. [89] Yu Nesterov and A Nemirovsky. Conic formulation of a convex programming problem and duality. Optimization Methods and Software, 1(2):95–115, 1992. [90] James B Orlin. A faster strongly polynomial time algorithm for submodular function mini- mization. Mathematical Programming, 118(2):237–251, 2009. [91] James B Orlin, John VandeVate, et al. On a” primal” matroid intersection algorithm. 1983. [92] Srinivasan Ramaswamy and John E Mitchell. A long step cutting plane algorithm that uses the volumetric barrier. Department of Mathematical Science, RPI, Troy, NY, 1995. [93] Alexander Schrijver. A combinatorial algorithm minimizing submodular functions in strongly polynomial time. Journal of Combinatorial Theory, Series B, 80(2):346–355, 2000. [94] Alexander Schrijver. Combinatorial optimization: polyhedra and efficiency, volume 24. Springer, 2003. [95] Jack Sherman and Winifred J Morrison. Adjustment of an inverse matrix corresponding to a change in one element of a given matrix. The Annals of Mathematical Statistics, pages 124–127, 1950. [96] Maiko Shigeno and Satoru Iwata. A dual approximation approach to weighted matroid intersection. Operations research letters, 18(3):153–156, 1995. [97] Naum Z Shor. Cut-off method with space extension in convex programming problems. Cy- bernetics and systems analysis, 13(1):94–96, 1977. [98] Maurice Sion. On general minimax theorems. Pacific J. Math, 8(1):171–176, 1958. [99] Daniel A Spielman and Nikhil Srivastava. Graph sparsification by effective resistances. SIAM Journal on Computing, 40(6):1913–1926, 2011. [100] ´Eva Tardos. A strongly polynomial minimum cost circulation algorithm. Combinatorica, 5(3):247–255, 1985. [101] Michael J Todd. Semidefinite optimization. Acta Numerica 2001, 10:515–560, 2001. [102] Nobuaki Tomizawa and Masao Iri. Algorithm for determining rank of a triple matrix product axb with application to problem of discerning existence of unique solution in a network. ELECTRONICS & COMMUNICATIONS IN JAPAN, 57(11):50–57, 1974. [103] Pravin M. Vaidya. A new algorithm for minimizing convex functions over convex sets (ex- tended abstract). In FOCS, pages 338–343, 1989. 110 [104] Pravin M Vaidya. Speeding-up linear programming using fast matrix multiplication. In Foundations of Computer Science, 1989., 30th Annual Symposium on, pages 332–337. IEEE, 1989. [105] Pravin M Vaidya. A new algorithm for minimizing convex functions over convex sets. Math- ematical Programming, 73(3):291–341, 1996. [106] Lieven Vandenberghe and Stephen Boyd. Semidefinite programming. SIAM review, 38(1):49– 95, 1996. [107] Jens Vygen. A note on schrijver’s submodular function minimization algorithm. Journal of Combinatorial Theory, Series B, 88(2):399–402, 2003. [108] S. Fujishige W. Cui. A primal algorithm for the submodular flow problem with minimum mean cycle selection. Journal of the Operations Research Society of Japan, 1988. [109] C Wallacher and Uwe T Zimmermann. A polynomial cycle canceling algorithm for submod- ular flows. Mathematical programming, 86(1):1–15, 1999. [110] Virginia Vassilevska Williams. Multiplying matrices faster than coppersmith-winograd. In Proceedings of the forty-fourth annual ACM symposium on Theory of computing, pages 887– 898. ACM, 2012. [111] Yinyu Ye. Complexity analysis of the analytic center cutting plane method that uses multiple cuts. Mathematical Programming, 78(1):85–104, 1996. [112] David B Yudin and Arkadii S Nemirovski. Evaluation of the information complexity of mathematical programming problems. Ekonomika i Matematicheskie Metody, 12:128–142, 1976. [113] U Zimmermann. Minimization on submodular flows. Discrete Applied Mathematics, 4(4):303– 323, 1982. [114] Uwe Zimmermann. Negative circuits for flows and submodular flows. Discrete applied math- ematics, 36(2):179–189, 1992. 111
1608.05100
11
1608
2017-11-01T10:57:39
In-Place Sparse Suffix Sorting
[ "cs.DS" ]
Suffix arrays encode the lexicographical order of all suffixes of a text and are often combined with the Longest Common Prefix array (LCP) to simulate navigational queries on the suffix tree in reduced space. In space-critical applications such as sparse and compressed text indexing, only information regarding the lexicographical order of a size-$b$ subset of all $n$ text suffixes is often needed. Such information can be stored space-efficiently (in $b$ words) in the sparse suffix array (SSA). The SSA and its relative sparse LCP array (SLCP) can be used as a space-efficient substitute of the sparse suffix tree. Very recently, Gawrychowski and Kociumaka [SODA 2017] showed that the sparse suffix tree (and therefore SSA and SLCP) can be built in asymptotically optimal $O(b)$ space with a Monte Carlo algorithm running in $O(n)$ time. The main reason for using the SSA and SLCP arrays in place of the sparse suffix tree is, however, their reduced space of $b$ words each. This leads naturally to the quest for in-place algorithms building these arrays. Franceschini and Muthukrishnan [ICALP 2007] showed that the full suffix array can be built in-place and in optimal running time. On the other hand, finding sub-quadratic in-place algorithms for building the SSA and SLCP for \emph{general} subsets of suffixes has been an elusive task for decades. In this paper, we give the first solution to this problem. We provide the first in-place algorithm building the full LCP array in $O(n\log n)$ expected time and the first Monte Carlo in-place algorithms building the SSA and SLCP in $O(n + b\log^2 n)$ expected time. We moreover describe the first in-place solution for the suffix selection problem: to compute the $i$-th smallest text suffix.
cs.DS
cs
In-Place Longest Common Extensions Nicola Prezza∗ Technical University of Denmark, DTU Compute [email protected] Abstract Longest Common Extension (LCE) queries are a fundamental sub-routine in several string- processing algorithms, including (but not limited to) suffix-sorting, string matching, compression, and identification of repeats and palindrome factors. A LCE query takes as input two positions i, j in a text T ∈ Σn and returns the length ' of the longest common prefix between T's i-th and j-th suffixes. In this paper, we present the following result: we can replace the (plain) text with a data structure of the exact same size-ndlog2 Σe bits-supporting text extraction in optimal time and LCE queries in logarithmic time-i.e. exponentially faster than what can be achieved using the plain text alone. Our structure can be built in O(n log n) expected time and linear space. We show that our result is a powerful tool that can be used to efficiently solve in-place a wide variety of string processing problems: we provide the first in-place algorithms to compute the LCP array in O(n log n) expected time (the previous fastest in-place algorithm runs in O(n2) time) and to suffix-sort-with high probability of success-any set of b text suffixes in O(n + b log2 n) expected time (the previous fastest in-place algorithm runs in O(nb) time). 1998 ACM Subject Classification E.1 DATA STRUCTURES Keywords and phrases Longest Common Extensions, in-place, LCP array, sparse suffix sorting Digital Object Identifier 10.4230/LIPIcs.CVIT.2016.23 Introduction 1 Let T be a length-n text over an integer alphabet Σ = {0, . . . , σ − 1}. In this paper, we consider the longest common extension (LCE) problem: to efficiently support (with some data structure) the computation of the length ' of the longest common prefix between any two T's suffixes. This problem finds important applications which include (but are not limited to): suffix-sorting, computing palindrome factors [1,6], identification of repeats [22,24], and string matching [2,25,29]. Clearly, constant-time random access to T is sufficient to support O(')-time LCE queries by direct comparison of the two suffixes and is also time-efficient in the average case as the longest common prefix between any two T's suffixes does not exceed expected length O(logσ n) on uniform texts. However, as the repetitiveness of T increases, ' can be as large as n so more time-efficient solutions are required. Constant-time LCE queries are possible at the expenses of space usage. One way to achieve this goal is to build a O(1)-time lowest common ancestor structure (see, e.g., [14]) on the suffix tree of the text (ST+LCA). A second solution consists in combining the longest common prefix array, a O(1)-time range minimum query structure (see, e.g. [8]), and the inverted suffix array (RMQ+LCP). Both solutions require O(n log n) bits of working space, so for very large texts are not feasible in practice. One way to space-efficiently solve this problem is to flank the text T with some (sublinear-space) ∗ Part of this work was done while the author was a PhD student at the University of Udine, Italy. Work supported by the Danish Research Council (DFF-4005-00267) 7 1 0 2 b e F 8 2 ] S D . s c [ 9 v 0 0 1 5 0 . 8 0 6 1 : v i X r a © Nicola Prezza; licensed under Creative Commons License CC-BY 42nd Conference on Very Important Topics (CVIT 2016). Editors: John Q. Open and Joan R. Acces; Article No. 23; pp. 23:1–23:16 Leibniz International Proceedings in Informatics Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 23:2 In-Place Longest Common Extensions data structure. In their recent works [4, 5], Bille et al. follow this approach and propose a number of solutions to this problem that trade query-time for space-usage. Their most practical solution is a Monte Carlo data structure requiring O(nw/τ) bits on top of the text, w and 0 < τ ≤ n being the memory word size and the block size, respectively, and answering LCE queries w.h.p. (with high probability) in O(τ) time. This structure can be built in O(n log(n/τ)) time. They also propose deterministic and Las Vegas structures with the same space-time bounds, but their preprocessing times-O(n2+) and O(n3/2)-make them not practical on big input texts. Deterministic data structures with similar time bounds but considerably improved construction times (of O(nτ)) have been recently described by Tanimura et al. in [32]. While using a negligible amount of space on top of the text (for big enough τ), these solutions are still not able to reach the information-theoretic minimum amount of space of n log σ bits while supporting fast queries at the same time. Our contributions In this work, we obtain the following result: in the RAM model with word size w, ndlog σe bits of space are sufficient to answer deterministic O(log2 ')-time LCE queries and optimal O(m log σ/w)-time extraction of any length-m text substring (all logarithms are in base 2). In the case the alphabet is composed by k-bits integers, this space is nk bits: exactly the information-theoretic minimum number of bits required to represent any T ∈ Σn. LCE query times can be improved to O(log ') by adding O(log n) memory words to the space usage (which is negligible in practice). Despite not being directly applicable to our case, a recent work [23] suggests that our query times could be close to optimal within this space (the optimal would be O(logσ n), but the result in [23] applies only to sub-linear structures built on top of the text). Our data structure is based on Karp-Rabin fingerprinting and can be built in O(n log n) expected time and O(n) words of space. In order to achieve this result, we introduce new techniques of general interest, including a statistical compression technique and several de-randomization procedures for Karp-Rabin fingerprinting. We point out that our result is a powerful tool that can be used to solve in-place a wide range of string-processing problems. To prove this statement, we present the first practical in-place Longest Common Prefix (LCP) array construction algorithm. Our algorithm runs in O(n log n) expected time and uses O(1) memory locations on top of T and the LCP array. The previous fastest in-place LCP array construction algorithm [26] runs in quadratic time. As intermediate result, we describe a Monte Carlo LCE data structure taking ndlog σe bits of space and admitting an in-place construction algorithm running in O(n) expected time: the construction algorithm replaces the text with the data structure while using O(1) words of extra working space. We apply this result to the suffix sorting problem and obtain an in-place Monte Carlo algorithm to suffix-sort any subset of b text suffixes with high probability in O(n + b log2 n) expected time. This is the first in-place solution (with non-trivial running times) for the sparse suffix sorting problem, and improves the space of the state of the art [3,9,12,16,20]. In Table 1 we give an overview of the main solutions for the LCE problem described in the literature, distinguishing between Monte Carlo (first three lines), and deterministic structures. 2 Preliminaries We assume our input to be a rewritable text of length n drawn from an integer alphabet Σ = {0, . . . , σ − 1} stored using dlog σe bits per character. w ≥ 1 is the memory word size (in bits). Since we will make use only of integer additions, multiplications, modulo, N. Prezza 23:3 build time O(n log(n/τ)) Notes τ ≤ n, w.h.p. O(n) exp. O(n) exp. O(n) O(n) O(n2+) O(n3/2) exp. O(nτ) O(n log n) exp. - O(n log n) exp. w.h.p. w.h.p. exact exact τ ≤ n, exact τ ≤ n, exact τ ≤ n log n, exact exact exact exact exact Reference [4] Theorem 3 Theorem 2 ST + LCA RM Q + LCP [4] [4] [32] Theorem 7 store only T Theorem 7 Space (bits) ndlog σe + O(nw/τ) ndlog σe + w log n ndlog σe O(n log n) O(n log n) ndlog σe + O(nw/τ) ndlog σe + O(nw/τ) ndlog σe + O(nw/τ) ndlog σe + O(w log n) ndlog σe ndlog σe Query time O(τ) O(log ') O(log2 ') O(1) O(1) O(τ) O(τ) O(τ log τ) O(log ') O(') O(log2 ') O(n log z) O(log n log∗ n) O(zw log n log∗ n) Table 1 Main solutions for the LCE problem described in the literature. The first three solutions return the correct result with high probability (w.h.p.), while the others are exact. We account also for the space to store the plain text if this is required to answer LCE queries. ' = LCE(i, j) is the output of the LCE query. In the first column, we omit any O(w)-bits (O(1) words) additional term. "exp." after the build time (third column) means that construction times are in the expected case. If not specified, times are worst-case. z is the number of phrases of the LZ77 parsing without self-references. log∗ n is the iterated logarithm function. [17,30] and bitwise operations (masks, shifts), we assume that we can simulate a memory word of size w0 = c · w for any constant c with only a constant slowdown in the execution of these operations (see Appendix A for a description of how this can be achieved). In our proofs we assume n ≥ 4 (note that, if n < 4, then LCE queries can be trivially implemented in constant time), log n ≤ w, and dlog σe ≤ w. For the above consideration, our results will be easily generalizable to the case log n ∈ O(w) and log σ ∈ O(w). We will describe our ideas starting from the binary alphabet σ = 2. On more general alphabets, note that we can build a binary text T 0 ∈ {0, 1}n·b, where b = dlog σe, by concatenating numbers T[0], T[1], . . . , T[n − 1] written in binary and reduce the problem to the binary case as T.LCE(i, j) = bT 0.LCE(i · b, j · b)/bc. This reduction will turn out to keep times alphabet-independent with our solution. To make notation more compact, with T[i, . . . , j] we denote both T's substring starting at position i and ending at position j, and the integer with binary representation T[i]T[i + 1] . . . , T[j] (each T[i] being a dlog σe- bits integer). If j < i, T[i, . . . , j] denotes the empty string  or the integer 0. The use (string/integer) will be clear from the context. While computing the space taken by our data structures we drop any additive O(w)-bits space term. For space constraints, we assume the reader to be familiar with Karp-Rabin fingerprinting [21]. φq : {0, 1}∗ → [0, q − 1] indicates the Karp-Rabin hash function with modulo q on strings from the binary alphabet {0, 1}. W.h.p. (with high probability) means with probability at least 1 − n−c for an arbitrarily large constant c. If not otherwise specified, logarithms are in base 2. 3 Monte Carlo LCE data structure Our general strategy to obtain a data structure supporting LCE queries follows the one described by Bille et al. [4,5]. Our improvements over this result concern the space of our CVIT 2016 23:4 In-Place Longest Common Extensions structure and its construction time. First, we describe an optimal-space data structure supporting efficient computation of the Karp-Rabin fingerprint of any text substring. Our original idea is to replace the text (not just augment it) with the fingerprints of a subset of its prefixes. The loss in space efficiency is avoided by repeatedly picking the Karp-Rabin module q very close, but above, a power of two until all residues are below that power of two (thus saving 1 bit per stored fingerprint). As a result, we are able to achieve ndlog σe bits of space usage for our structure. Then, to compute LCE(i, j) on T we perform the following two steps. (1) Exponential search: we compare φq(T[i, . . . , i+2k]) and φq(T[j, . . . , j+2k]) for k = 0, 1, . . . until the two compared strings differ. Letting ' = LCE(i, j), this phase terminates in O(log ') steps. (2) Binary search: we compare φq(T[i, . . . , i + m]) and φq(T[j, . . . , j + m]) for O(log ') values of m using binary search in the interval found in step (1) until we find the value ' such that φq(T[i, . . . , i+ '−1]) = φq(T[j, . . . , j + '−1]) and φq(T[i, . . . , i+ ']) 6= φq(T[j, . . . , j + ']). Follows a detailed description of our Monte Carlo data structure; in Section 4 we show how to de-randomize our solution so that it computes always the correct LCE. 3.1 Fingerprint Sampling We start considering the binary case σ = 2, and then extend the result to more general alphabets. We introduce two sources of randomness in our structure: the modulus q and the seed ¯s. First, we choose a random prime q uniformly in the interval [2, 2w − 1]. We define a block size τ = dlog qe. Without loss of generality, we assume that n is a multiple of τ (the general case can be reduced to this case by left-padding the text with τ − (n mod τ) bits). At this point, we choose uniformly a random number (the seed) ¯s in the interval [0, q − 1]. ¯s is a τ-bits integer (after a suitable left-padding of zeros); we left-pad our binary text T with ¯s written in binary. Clearly, LCE(i, j) queries on T can still be solved using the padded text ¯sT by simply adding τ to the arguments of LCE (i.e. solving LCE(i + τ, j + τ) on the padded text). To improve readability, in what follows we assume that T is prefixed by ¯s (and thus write just T and n instead of ¯sT and n + τ, respectively). Let B, P 0 ∈ [0, q − 1]n/τ be the integer arrays defined as B[i] = T[i · τ, . . . , (i + 1) · τ − 1], i = 0, . . . , n/τ − 1 and iX j=0 P 0[i] = 2(i−j)·τ · B[j] mod q = φq(T[0, . . . , (i + 1) · τ − 1]) First, note that B[i] − q ≤ (2τ − 1) − 2τ−1 < 2τ−1 ≤ q, so bB[i]/qc ∈ {0, 1} holds. We build a bitvector D[0, . . . , n/τ − 1] defined as D[i] = bB[i]/qc. To simplify notation, let P 0[−1] = 0. At this point, B's values can be retrieved as B[i] = (P 0[i] − 2τ · P 0[i − 1] mod q) + D[i] · q. Arrays P 0 and D take n + n/τ bits of space and replace the text in that they support the retrieval of any B[i]. First, we show how to compute efficiently φq(T[i, . . . , j]) for any 0 ≤ i ≤ j < n by using P 0 and D. We then show how to reduce the space usage to n bits while still being able to support constant-time text extraction and Karp-Rabin fingerprint computation. Let j = bi/τc. Then, φq(T[0, . . . , i]) = φq(T[0, . . . , j · τ − 1]) · 2i−j·τ+1 + φq(T[j · τ, . . . , i]) mod q = P 0[j − 1] · 2i−j·τ+1 + bB[j]/2τ−i+j·τ−1c mod q We now have to show how to compute the fingerprint φq(T[i, . . . , j]), j ≥ i of any text N. Prezza 23:5 substring. This can be easily achieved by means of the equality: φq(T[i, . . . , j]) = φq(T[0, . . . , j]) − φq(T[0, . . . , i − 1]) · 2j−i+1 mod q (1) Computing 2e mod q takes O(log e) time with the fast exponentiation algorithm, therefore the computation of φq(T[i, . . . , j]) takes O(log(j − i + 1)) time with our structure for all 0 ≤ i ≤ j < n. 3.2 Reducing space usage In order to remove the n/τ-bits overhead, we build an auxiliary array S = hi : bP 0[i]/2τ−1c = 1, i = 0, . . . , n/τ − 1i storing all i's such that the most significant bit of P 0[i] is equal to 1. At this point, we replace P 0 with an array P of n/τ integers of (τ − 1) bits each defined as i = 0, . . . , n/τ − 1, i.e. we remove the most significant bit from P[i] = P 0[i] mod 2τ−1, each P 0[i]. P takes n · (τ − 1)/τ bits of space. Clearly, by using P and S we can retrieve any P 0[i] in O(S) time with a simple linear scan on S. The main idea, at this point, is to choose the prime q in such a way that the expected size of S becomes constant. After achieving this goal, the overall space of P, D, and S will be of n bits (plus a constant number of memory words) and we will still be able to retrieve any B[i] and P 0[i] in constant time. We reverse our strategy. We first choose a block size τ ∈ Θ(w), pick a uniform prime q such that dlog qe = τ, and then choose a uniform seed ¯s in [0, q − 1]. In Sections 3.3 and 3.4 we show how to choose τ. The key point is that each P 0[i] is a uniform random variable taking values in the range [0, q − 1]. To prove this statement, note that P 0[i] can be written as P 0[i] ≡q ¯s · 2i·τ + ¯ti, where ¯ti = φq(T[τ, . . . , (i + 1) · τ − 1]). Let P(P 0[i] = x), x < q, be the probability that P 0[i] is equal to x. Then, for any x < q, P(P 0[i] = x) = P(¯s · 2i·τ + ¯ti ≡q x) = P(¯s ≡q (x − ¯ti) · 2−i·τ) = 1/q (2) The fact that q is prime guarantees the existence of the inverse of 2i·τ modulo q. Let x < q. Equation 2 implies, in particular, that P(P 0[i] < x) = x/q (3) Let ¯1i ∈ {0, 1} be the indicator random variable taking value 1 iff the most significant bit of P 0[i] is equal to 1. Equation 3 implies that ¯1i has a Bernoullian distribution with success probability p = (q − 2τ−1)/q. We want this probability to be at most 1/n in order to get an expected constant size for S. By solving (q − 2τ−1)/q ≤ 1/n and by adding the constraint dlog qe = τ, we obtain that the interval Z from which we have to uniformly pick q in order to satisfy both constraints is The issue to efficiently pick a uniform prime from an interval has been addressed in [18]. At this point, S's expected size can be computed as (4) (cid:20) Z = 2τ−1, 2τ−1 n − 1 (cid:18) n  = (cid:19)(cid:21) n/τ−1X i=0 n/τ−1X i=0 ¯1i E[S] = E E[¯1i] = (n/τ)·E[¯1i] = (n/τ)·(q−2τ−1)/q ≤ (n/τ)·(1/n) = 1/τ (5) where E[X] is the expected value of random variable X. Recall that the expected value of a Bernoullian random variable with success probability p is p. CVIT 2016 23:6 In-Place Longest Common Extensions Let b = dlog σe. On a general alphabet size such that b ≤ w, the text is processed as a binary sequence of nb bits, and the validity of the above results is preserved by substituting n with nb in Equation 4. In particular, Z's size becomes Z = 2τ−1/(nb − 1) ≥ 2τ−1/(nb) = 2τ−1−log n−log b. Since we assume w ≥ log n and w ≥ b ≥ log b, we get the lower bound Z ≥ 2τ−1−2w. Number of primes in Z Let π(x) denote the number of primes smaller than x. Let moreover A = 2τ−1 and H = 2τ−1−2w be the smallest element contained in Z and the lower bound for Z above computed, respectively. Our aim in this paragraph is to compute a lower bound for the number zp = π(A + H) − π(A) of primes contained in Z. This will be needed later in order to compute the collision probability of our hash function. Note that the Prime Number Theorem can be applied to solve this task only if H ≥ A · c, for some fixed c > 0, so we cannot use it in our case. Luckily for us, Heath-Brown [15] proved (see also [27]) that, if H grows at least as A7/12, then π(A + H) − π(A) ∼ H/ loge A (for A → ∞. e is the natural logarithm base). Solving H ≥ A7/12 we get the constraint τ ≥ (24/5)w + 1 (6) Later we will show how to choose τ (keeping (6) in mind). Heath-Brown's theorem gives us zp ≥ H/ loge A = 2τ−1−2w/ loge(2τ−1) ≥ 2τ−1−2w/(τ − 1) ≥ 2τ−1−2w/τ. 3.3 Deterministic space With the above strategy, our structure takes ndlog σe bits of space with high probability only. We can make the space deterministic by picking multiple random pairs q, ¯s as described above and re-building the structure until this requirement is satisfied. Our goal in this section is to compute the expected number R of pairs q, ¯s we have to randomly pick before obtaining a constant size for S (in our calculations below, we focus on S = 0). Note that E[S] = k>0 P(S = k), so P(S > 0) ≤ E[S] holds. From Equation 5, E[S] ≤ 1/τ, therefore P(S > 0) ≤ 1/τ. This yields P(S = 0) ≥ 1 − 1/τ. We choose P k>0 k · P(S = k) and P(S > 0) =P τ = cw ≥ c log n (7) for any constant c ≥ 1, so the above probability is at least 1 − 1/ log n. Later we will show how to choose c keeping in mind also Constraint (6). Finally, since we assume n ≥ 4 (and therefore log n ≥ 2), we obtain P(S = 0) ≥ 0.5. Given that we repeat the construction of our structure as long as S > 0 holds, the number R of times we repeat the construction is a geometric random variable with success probability p = P(S = 0) ≥ 0.5, and has therefore expected value 1/p ≤ 2. Note that, since τ ∈ Θ(w) and dlog σe ≤ w, arrays P and D have O(n) entries each. We obtain the following Lemma: (cid:73) Lemma 1. In O(n) expected time we can build arrays P, D, and S taking overall ndlog σe bits of space and supporting the computation of any B[i] and P 0[i] in constant time. 3.4 A Monte Carlo in-place LCE data structure On a binary alphabet, we can easily answer LCE(i, j) by comparing φq(T[i, . . . , i + k]) with φq(T[j, . . . , j + k]) for O(log n) values of k with binary search. We can furthermore improve query times by performing an exponential search before applying the binary search procedure. We compare φq(T[i, . . . , i + k]) with φq(T[j, . . . , j + k]) for k = 20, 21, 22, . . . until the two N. Prezza 23:7 fingerprints differ. Letting ' = LCE(i, j), this procedure terminates in O(log ') steps. We then apply the binary search procedure described above on the interval of size O(') obtained with the exponential search. Each exponential and binary search step take O(log ') time (from the fast exponentiation algorithm). On a more general alphabet, each character takes b = dlog σe ∈ O(w) bits, and our structure is therefore built over a binary text T 0 of length n · b. We can make query times alphabet-independent as follows. First of all, while computing T.LCE(i, j) we perform exponential and binary searches by comparing φq(T 0[i · b, . . . , (i + k) · b]) with φq(T 0[j · b, . . . , (j + k) · b]), i.e. we compare T 0 substrings starting and ending at character boundaries. This reduces the number of steps to be performed from O(log('· b)) to O(log '). At this point, note that each step requires the computation of 2t·b mod q with the fast exponentiation algorithm, t ∈ O(') being the length of the two compared substrings (O(log(' log σ)) time). Since b is a common factor in all exponents, we can pre-compute Y = 2b mod q and-at each step-compute Y t mod q instead of 2t·b mod q with the fast exponentiation algorithm. This reduces the number of steps of the exponentiation algorithm to O(log '). Finally, note that extracting text corresponds to reading array B (τ ∈ Θ(w) bits of the text per B element). divides their product z =Qn−1 3.4.1 Wrong LCE probability We start the analysis from the binary case σ = 2. Let C be the random variable denoting the number of pairs hX, Y i of T substrings with X = Y that generate a collision, i.e. X 6= Y and φq(X) = φq(Y ). Our goal is to compute an upper bound for the probability P(C > 0). Clearly, P(C > 0) is an upper bound to the probability of computing a wrong LCE with i denote T's substring of length k starting at position i. There is at our structure. Let X k i ≡q Y k j , i.e. iff q divides at least one collision (C > 0) iff X k Q j such that X k i − Y k least one of the numbers X k j . Since q is prime, this happens iff q X k j . Since each X k i − Y k j has at most n i,j:X k k=1 binary digits and there are no more than n2 such pairs for every k, we have that z < 2n4. It follows that there cannot be more than n4 distinct primes dividing z. j has at most nb Let b = dlog σe. On a more general alphabet with b ≤ w, each X k binary digits, and we obtain z < 2n4·b. It follows that there cannot be more than n4·b distinct primes dividing z. The probability of uniformly picking a prime q ∈ Z dividing z is therefore upper bounded by n4 · b/zp, where zp is a lower bound on the number of primes contained in Z, see Section 3.2. Recall that zp ≥ 2τ−1−2w/τ, so n4 · b/zp ≤ n4 · b · τ /2τ−1−2w = 24 log n+log b+log τ+1+2w−τ. We choose for at least one pair X k i 6= Y k i − Y k i − Y k i 6=Y k j j 6= Y k i τ = (9 + c)w (8) for an arbitrarily large constant c. Being w ∈ ω(1), we assume1 w ≥ log τ = log(9+ c)+log w. We obtain τ = (9+c)w ≥ (4+c) log n+log b+log τ+1+2w, therefore n4·b/zp ≤ 2−c log n = n−c. Note that this choice of τ satisfies constraints (6) and (7). This leads to: P(wrong LCE) ≤ P(C > 0) ≤ n−c For an arbitrarily large constant c. We obtain: 1 Note that this inequality always holds after simulating a memory word of size w0 = dw for a sufficiently large constant d CVIT 2016 23:8 In-Place Longest Common Extensions (cid:73) Theorem 2. In O(n) expected time we can build a data structure taking ndlog σe bits of space and supporting extraction of any length-m text substring and LCE queries w.h.p. in O (m log σ/w) and O(log2 ') worst-case time, respectively. 3.4.2 Speeding up LCE queries We consider a general alphabet size σ ≤ 2w. Let b = dlog σe and let T 0 ∈ {0, 1}n·b be the concatenation of T's characters written in binary. We can avoid the overhead introduced by the fast exponentiation algorithm by pre-computing and storing (in O(w log n) bits) values zi = 2b·2i mod q, i = 0, . . . ,blog nc and performing binary search by splitting interval lengths in correspondence of powers of 2 as follows. First, note that z0 = 2b mod q and zi+1 = (zi)2 mod q, so the values zi can be pre-computed in O(log n) time. Let the notation hi, j, e, ki, with 0 ≤ i, j, e, k < n and e < k, denote that we already verified (w.h.p.) that T[i, . . . , i + e − 1] = T[j, . . . , j + e − 1] and T[i, . . . , i + k − 1] 6= T[j, . . . , j + k − 1]. We use this notation to indicate the state of a binary search step, and start from state hi, j, 0, n − ji (we assume for simplicity that T[i, . . . , i + (n − j) − 1] 6= T[j, . . . , n − 1]; otherwise, LCE(i, j) = n − j). We use a modified version of Equation 1 by adding a parameter (exponential exp) to the Karp-Rabin hash function: q(T 0[(i + e) · b, . . . , (i + e + l0 − 1) · b], zblog(l/2)c) q(T 0[i, . . . , j], exp) = φq(T 0[0, . . . , j]) − φq(T 0[0, . . . , i − 1]) · exp mod q φ0 (9) q(T 0[i, . . . , j], 2(j−i+1)·b). At binary search step hi, j, e, ki we Note that φq(T 0[i, . . . , j]) = φ0 still have to compare the last l = k − e characters of T[i, . . . , i + k − 1] and T[j, . . . , j + k − 1]. We split each of these two substrings suffixes in a left part of length l0 = 2blog(l/2)c (i.e. the closest power of 2 smaller than or equal to l/2) and a right part of length l − l0. Note that value 2l0·b mod q = zlog l0 = zblog(l/2)c has been pre-computed, so we can compute and compare in constant time the two values φq(T 0[(i + e) · b, . . . , (i + e + l0 − 1) · b]) = φ0 and φq(T 0[(j + e) · b, . . . , (j + e + l0 − 1) · b]) = φ0 q(T 0[(j + e) · b, . . . , (j + e + l0 − 1) · b], zblog(l/2)c) If the two values differ, then we recurse on hi, j, e, e + l0i. If the two values are equal, then we recurse on hi, j, e + l0, ki. Note that we always compare (fingerprints of) strings whose lengths are powers of two. This will be crucial in the next section in order to efficiently de-randomize our structure. Since l/4 < l0 ≤ l/2, this binary search procedure terminates in O(log n) steps, each taking constant time. As done in the previous section, we can perform an exponential search before the binary search in order to reduce the size of the binary search interval from O(n) to O('). Note that with our sampling zi it is straightforward to implement each exponential search step in constant time. We obtain: (cid:73) Theorem 3. In O(n) expected time we can build a data structure taking ndlog σe + O(w log n) bits of space and supporting extraction of any length-m text substring and LCE queries w.h.p. in O (m log σ/w) and O(log ') worst-case time, respectively. Note that values zi need to be explicitly stored for the binary search as this step might need access to a zi with arbitrarily small i (and, while we can quickly compute zi from zi−1, the opposite is not true). Note moreover that, even if we assumed dlog σe ≤ w, it is easy to see that our results are valid also for the more general case log σ ∈ O(w): in the case alphabet characters are composed by O(1) words, we can break them in a constant number of w-bits sub-characters. This introduces only a constant slowdown in the computation of LCE queries on the original text. N. Prezza 23:9 3.5 In-place construction algorithm In this section we show that our data structure can be built in-place, i.e. we can replace the text with the data structure and use only O(1) memory words of extra space during construction. A direct consequence of this fact is (see Section 5) the existence of an in-place algorithm to efficiently suffix-sort (with high probability of success) any subset of text positions. We first consider the binary case σ = 2. First, we pick τ, q, ¯s as described in the previous sections. We consider the text as a sequence B[0, . . . , n/τ − 1] of integers in the range [0, 2τ − 1] (again, we assume for simplicity that τ divides n), and, for i = 0, . . . , n/τ − 1, we replace the most significant bit of B[i] with the bit D[i], and the remaining τ − 1 bits with the value P[i] (clearly, this allows to retrieve any P[i] and D[i] in constant time). If the most significant bit of P 0[i] is equal to 1, then we append i to the vector S (initialized as empty). Note that P 0[i], P[i], and D[i] can all be easily computed in constant time by using P 0[i − 1] and B[i] for i > 0, so we need to keep in memory only a constant number of memory words at each of the n/τ steps. Let c be any constant chosen in advance. If the size of S exceeds c at some point of the construction, then we reverse the procedure and restore T. It is easy to see that B[i] can be computed in constant time by using P[i], P[i − 1], D[i], and S (recall that B[i] has been replaced with P[i] and D[i] during construction), so we can restore the text in O(n/w) time using O(1) memory words of working space. After restoring the text, we empty array S. For the same considerations made in the previous section, we need to repeat the construc- tion at most O(1) times in the expected case. At each round, we spend O(n/w) time. On a general alphabet with dlog σe ∈ O(w), we build the structure on the binary representation of the text and the construction algorithm terminates therefore in expected optimal O( n log σ w ) time (assuming that the input text is already packed) while taking only O(1) words on top of the space of the text. 4 Deterministic LCE data structure The aim of this section is to show how to make the structure described in the previous section deterministic. We start by proving three theorems solving with different space/time tradeoffs the problem of checking whether φq generates collisions over a specific subset of text substrings. Detailed proofs of Theorems 4-6 can be found in Appendix B. (cid:73) Theorem 4. In O(n log n) expected time and O(n) words of space we can check whether φq is collision-free over all pairs of substrings of T having the same length k = 2e, for all 0 ≤ e ≤ log n Proof. (sketch) The idea is to iteratively check collisions between strings of length 2e, for e = 0, . . . , log n. At step e, we hash text positions i = 0, . . . , n−2e according to the fingerprint of T[i, . . . , i + 2e − 1] and exploit the results of step e − 1 to check string equality in constant (cid:74) time. See Appendix B for the full proof. The above space bounds can be improved by replacing hashing with any comparison-based in-place integer sorting algorithm: (cid:73) Theorem 5. In O(n log2 n) worst-case time and n words of space (on top of T) we can check whether φq is collision-free over all pairs of substrings of T having the same length k = 2e, for all 0 ≤ e ≤ log n CVIT 2016 23:10 In-Place Longest Common Extensions If we limit the word size to w ∈ Θ(log n), then we can use in-place radix sorting [11] to improve the above result: (cid:73) Theorem 6. If w ∈ Θ(log n), then in O(n log n) expected time and n words of space (on top of T) we can check whether φq is collision-free over all pairs of substrings of T having the same length k = 2e, for all 0 ≤ e ≤ log n We can now use these results to build a deterministic LCE data structure. We randomly pick pairs q, ¯s and keep re-building our LCE structure until: 1. Its total space usage is of ndlog σe bits plus a constant number of memory words, and 2. φq is collision-free over all pairs of substrings of T having the same length k = 2e, for all 1 ≤ e ≤ blog nc Checking property (1) can be done during construction. As described in Section 3.5, by reversing construction whenever S exceeds some constant chosen in advance, working space never exceeds ndlog σe bits plus a constant number of memory words. After successful construction, property (2) can be checked with the space/time tradeoffs of Theorems 4-6. We are left to show what is the expected number R of pairs q, ¯s we have to pick before both properties are satisfied. Number of construction rounds Recall (Section 3.4.1) that C is the random variable denoting the number of pairs hX, Y i of T substrings with X = Y that generate a collision, i.e. X 6= Y and φq(X) = φq(Y ), and that S is the set containing all positions i such that the most significant bit of P 0[i] is equal to 1. We are interested in computing a lower bound for the success probability P(C = 0 ∧ S = 0) = 1 − P(C > 0 ∨ S > 0) (10) From the inequality P(C > 0 ∨ S > 0) ≤ P(C > 0) + P(S > 0), we obtain that the quantity in Equation 10 is greater than or equal to 1 − P(C > 0) − P(S > 0) We choose τ = 10w. This satisfies Constraints (6), (7), and (8) and implies that-see Section 3.3-P(S > 0) = 1 − P(S = 0) ≤ 1 − 0.5 = 0.5. It follows that quantity in Equation 11 is greater than or equal to 0.5 − P(C > 0). Finally-see Section 3.4.1-the choice τ = 10w implies P(C > 0) ≤ n−1. This, plugged into the above inequalities, gives us P(C = 0 ∧ S = 0) ≥ 0.5 − n−1. Note that n−1 ≤ 0.25 holds for n ≥ 4, which is true by assumption. We obtain: P(C = 0 ∧ S = 0) ≥ 0.25. The number R of rounds of our construction algorithm is a geometric random variable with success probability p = P(C = 0 ∧ S = 0) ≥ 0.25, and has therefore expected value 1/p ≤ 4. (11) We use the technique described in Section 3.4.2 (subsection Speeding up LCE queries) in order to compute LCE queries with our structure, so that we only need φq to be collision-free between text substrings whose lengths are powers of two. If we do not sample values 2dlog σe·2i mod q, 0 ≤ i < log n, at each binary/exponential search step we have to compute one of them in O(log ') time using the fast exponentiation algorithm. Using the collision-checking procedure described in Theorem 4 we obtain: (cid:73) Theorem 7. In O(n log n) expected time and O(n) words of space we can build a determ- inistic data structure taking ndlog σe bits of space and supporting extraction of any length-m text substring and LCE queries in O (m log σ/w) and O(log2 ') worst-case time, respectively. LCE queries can be supported in O(log ') time by using O(log n) additional words of space. N. Prezza 23:11 Applications 5 In what follows we assume that the memory word's size is w = dlog ne bits, and that the suffix/LCP arrays are composed by n such words (or b ≤ n words in the case of the sparse suffix array). This restriction is required in order to being able to in-place radix sort [11] Θ(w)-bits fingerprints. As a consequence, our results hold for alphabet size σ ≤ nO(1) (recall that we need σ ≤ 2O(w) in order to manipulate alphabet characters in constant time). With slow LCE queries we denote queries running in O(log2 n) time and O(1) space on top of our LCE data structure. With fast LCE queries we denote those running in O(log n) time and requiring τ · log n = 10w log n = 10 log2 n bits of space on top of our LCE data structure (this space is needed to store values 2dlog σe·2i mod q, see Section 3.4.2). In our results below, we obtain the space to support fast LCE queries by compressing integer sequences as done in [10,11]. Given a sequence S[1, . . . , k] of log n-bits integers, with k ≥ 10 log2 n, we first sort it in increasing order (in-place and O(k) time using in-place radix sort [11]). Then, we store in one word the index of the first integer in the sorted sequence starting with bit '1', and compact S in k log n − k adjacent bits by removing the first bit from each integer. This saves k ≥ 10 log2 n bits of space. We store values 2dlog σe·2i mod q in this space, so that our structure supports fast LCE queries. When fast LCE queries are no more needed, S can be decompressed and restored in its original (sorted) form. Suffix sorting The lexicographic order of two text suffixes can be easily computed by comparing the two characters following their longest common prefix (i.e. one LCE query and one text access). By carefully combining our Monte Carlo data structure with in-place comparison sorting, in-place merging [31], and compression of integer sequences we obtain: (cid:73) Theorem 8. Any set S = {i1, . . . , ib} of b suffixes of a text T ∈ Σn, Σ ≤ nO(1), can be sorted correctly with high probability in O(n + b log2 n) expected time using O(1) words of space on top of T and S Proof. We first build our Monte Carlo structure using the in-place construction algorithm of Section 3.5 (O(n) expected time). If b < n/ log3 n, then we suffix-sort the b text positions plugging slow LCE queries in any in-place comparison sorting algorithm terminating within O(b log b) comparisons. This requires O(n + b log b log2 n) ∈ O(n) time. If b ≥ n/ log3 n, then we divide the array S of text positions in two sub-arrays S0 = S[1, . . . , n/ log3 n] and S00 = S[n/ log3 n + 1, . . . , b] and: 1. We compress S0 as described at the beginning of this section. This saves n/ log3 n > 10 log2 n bits of space (note that this inequality holds for n larger than some constant). We store values 2dlog σe·2i mod q in this space, so that our structure now supports fast LCE queries. 2. We suffix-sort in-place (comparison-based sorting) S00 using fast LCE queries. This step terminates in O(b log b log n) ⊆ O(b log2 n) time. 3. We decompress S0. Now our structure supports only slow LCE queries. 4. We suffix sort in-place (comparison-based sorting) S0 using slow LCE queries. This step terminates in O((n/ log3 n) · log(n/ log3 n) · log2 n) ∈ O(n) time 5. We merge S0 and S00 using slow LCE queries and in-place comparison-based merging [31]. This step terminates O(b log2 n) time. (cid:74) CVIT 2016 23:12 In-Place Longest Common Extensions To the best of our knowledge, Theorem 8 is the first in-place solution for the sparse suffix sorting problem improving over the time O(nb) achievable using radix sort. Our result improves the space of the state of the art [3, 9, 12, 16, 20]. Note that the above procedure could return a wrong result with small probability. If we wish to compute the full suffix array, however, we can de-randomize our structure with Theorem 5 before applying Theorem 8 to the sequence S = {1, . . . , n}. We obtain: (cid:73) Theorem 9. The suffix array SA of T ∈ Σn, Σ ≤ nO(1), can be computed in O(n log2 n) expected time using O(1) words of space on top of T and SA. Theorem 9 does not improve the state of the art [10]. However, it represents the only other known solution to the problem so we think it is worth mentioning. LCP array construction the Longest Common Prefix (LCP) array stores the LCEs of lexicographically consecutive suffixes, and is often used to speed up search algorithms based on the suffix array and to simulate the suffix tree. To date, the most space-efficient and practical LCP construction algorithms [7, 13, 19, 28] rely on succinct and compressed data structures, and use O(n) bits of auxiliary storage on top of the text and the LCP array. The previous fastest in-place LCP array construction algorithm [26] runs in quadratic time, and is therefore not practical on big texts. Here we present the first practical in-place LCP construction algorithm. The result, stated in the following theorem, follows from a careful combination of our deterministic LCE data structure, in-place suffix sorting [10], in-place radix sorting [11], and compression of increasing sequences of integers: (cid:73) Theorem 10. The Longest Common Prefix array (LCP) of T ∈ Σn, Σ ≤ nO(1), can be computed in O(n log n) expected time using O(1) words of space on top of the text and the LCP. Proof. Our procedure consists of the following steps: 1. We build and de-randomize our LCE structure using Theorem 6. We store in two words 2. We build the suffix array SA in-place and O(n log n) time using [10]. 3. We re-build our deterministic LCE structure using the values q and ¯s computed in step the modulo q and the seed ¯s computed during construction and re-store the text. (1). This step runs in-place and O(n) time. 4. We compress the integers in SA0 = SA[1, . . . , n/ log2 n] with the procedure described at the beginning of this section. This saves n/ log2 n > 10 log2 n bits of space (this inequality holds for n larger than some constant). We store values 2dlog σe·2i mod q in this space, so that our structure now supports fast LCE queries. Note that SA0 is no more suffix-sorted. 5. We convert SA00 = SA[n/ log2 n + 1, . . . , n] to LCP[n/ log2 n + 1, . . . , n] by computing LCE values of adjacent suffixes using fast LCE queries. This step runs in-place and O(n log n) time. 6. We decompress SA0. Now our LCE structure supports only slow LCE queries. 7. We suffix-sort in-place (comparison-based sorting) SA0 using slow LCE queries. This step runs in-place and O((n/ log2 n) log(n/ log2 n) log2 n) = O(n log n) time. 8. We convert SA0 to LCP[1, . . . , n/ log2 n] by computing LCE values of adjacent suffixes using slow LCE queries. This step runs in-place and O((n/ log2 n) log2 n) = O(n) time. (cid:74) 1 References Jean-Paul Allouche, Michael Baake, Julien Cassaigne, and David Damanik. Palindrome complexity. Theoretical Computer Science, 292(1):9–31, 2003. N. Prezza 23:13 2 Amihood Amir, Moshe Lewenstein, and Ely Porat. Faster algorithms for string matching with k mismatches. Journal of Algorithms, 50(2):257–275, 2004. Philip Bille, Johannes Fischer, Inge Li Gørtz, Tsvi Kopelowitz, Benjamin Sach, and Hjalte Wedel Vildhøj. Sparse text indexing in small space. ACM Transactions on Al- gorithms (TALG), 12(3):39, 2016. Philip Bille, Hjalte Wedel Vildhøj. Longest common extensions in sublinear space. posium on Combinatorial Pattern Matching, pages 65–76. Springer, 2015. Philip Bille, Inge Li Gørtz, Benjamin Sach, and Hjalte Wedel Vildhøj. Time–space trade- offs for longest common extensions. Journal of Discrete Algorithms, 25:42–50, 2014. Inge Li Gørtz, Mathias Baek Tejs Knudsen, Moshe Lewenstein, and In Annual Sym- 3 4 5 7 8 9 6 Dany Breslauer and Zvi Galil. Finding all periods and initial palindromes of a string in parallel. Algorithmica, 14(4):355–366, 1995. Johannes Fischer. Inducing the LCP-array. In Workshop on Algorithms and Data Struc- tures, pages 374–385. Springer, 2011. Johannes Fischer and Volker Heun. Theoretical and practical improvements on the RMQ- problem, with applications to LCA and LCE. In Annual Symposium on Combinatorial Pattern Matching, pages 36–48. Springer, 2006. Johannes Fischer, I Tomohiro, and Dominik Köppl. Deterministic sparse suffix sorting on rewritable texts. In Latin American Symposium on Theoretical Informatics, pages 483–496. Springer, 2016. 10 Gianni Franceschini and S Muthukrishnan. In-place suffix sorting. In International Col- loquium on Automata, Languages, and Programming, pages 533–545. Springer, 2007. 11 Gianni Franceschini, S. Muthukrishnan, and Mihai Patrascu. Radix sorting with no extra 12 13 space. In Proc. 15th ESA, pages 194–205, 2007. Paweł Gawrychowski and Tomasz Kociumaka. Sparse suffix tree construction in optimal time and space. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 425–439. SIAM, 2017. Simon Gog and Enno Ohlebusch. Fast and lightweight LCP-array construction algorithms. In Proceedings of the Meeting on Algorithm Engineering & Expermiments, pages 25–34. Society for Industrial and Applied Mathematics, 2011. 14 Dov Harel and Robert Endre Tarjan. Fast algorithms for finding nearest common ancestors. siam Journal on Computing, 13(2):338–355, 1984. 15 DR Heath-Brown. The differences between consecutive primes. Journal of the London Mathematical Society, 2(1):7–13, 1978. 16 Tomohiro I, Juha Kärkkäinen, and Dominik Kempa. Faster Sparse Suffix Sorting. In 31st International Symposium on Theoretical Aspects of Computer Science, pages 386–396. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 2014. Shunsuke Inenaga. A faster longest common extension algorithm on compressed strings and its applications. In Prague Stringology Conference, pages 1–4, 2015. 17 18 Marc Joye and Pascal Paillier. Fast generation of prime numbers on portable devices: An In International Workshop on Cryptographic Hardware and Embedded Systems, update. pages 160–173. Springer, 2006. Juha Kärkkäinen, Giovanni Manzini, and Simon J Puglisi. Permuted longest-common- prefix array. In Annual Symposium on Combinatorial Pattern Matching, pages 181–192. Springer, 2009. Juha Kärkkäinen, Peter Sanders, and Stefan Burkhardt. Linear work suffix array construc- tion. Journal of the ACM (JACM), 53(6):918–936, 2006. 19 20 21 Richard M Karp and Michael O Rabin. Efficient randomized pattern-matching algorithms. IBM Journal of Research and Development, 31(2):249–260, 1987. CVIT 2016 23:14 In-Place Longest Common Extensions 22 Roman Kolpakov, Mikhail Podolskiy, Mikhail Posypkin, and Nickolay Khrapov. Searching of gapped repeats and subrepetitions in a word. In Symposium on Combinatorial Pattern Matching, pages 212–221. Springer, 2014. 23 Dmitry Kosolobov. Tight lower bounds for the longest common extension problem. arXiv preprint arXiv:1611.02891, 2016. 24 Gad M Landau, Jeanette P Schmidt, and Dina Sokol. An algorithm for approximate tandem repeats. Journal of Computational Biology, 8(1):1–18, 2001. 25 Gad M Landau and Uzi Vishkin. Fast parallel and serial approximate string matching. Journal of algorithms, 10(2):157–169, 1989. Felipe A Louza and Guilherme P Telles. Computing the BWT and the LCP Array in Constant Space. In International Workshop on Combinatorial Algorithms, pages 312–320. Springer, 2015. 27 Helmut Maier et al. Primes in short intervals. The Michigan Mathematical Journal, 26 29 32(2):221–225, 1985. 28 Giovanni Manzini. Two space saving tricks for linear time LCP array computation. In Scandinavian Workshop on Algorithm Theory, pages 372–383. Springer, 2004. Eugene W Myers. An O(ND) difference algorithm and its variations. Algorithmica, 1(1- 4):251–266, 1986. 31 30 Takaaki Nishimoto, I Tomohiro, Shunsuke Inenaga, Hideo Bannai, and Masayuki Takeda. Fully Dynamic Data Structure for LCE Queries in Compressed Space. In 41st International Symposium on Mathematical Foundations of Computer Science, pages 72:1–72:15, 2015. Jeffrey S. Salowe and William L. Steiger. Simplified stable merging tasks. J. Algorithms, 8(4):557–571, 1987. 32 Yuka Tanimura, Tomohiro I, Hideo Bannai, Shunsuke Inenaga, Simon J. Puglisi, and Masay- uki Takeda. Deterministic sub-linear space LCE data structures with efficient construction. In Annual Symposium on Combinatorial Pattern Matching. Springer, 2016. Simulating larger word sizes A Since we make use only of integer additions, multiplications, modulo, and bitwise operations (masks, shifts), we can assume that we can simulate a memory word of size w0 = c · w for any constant c with only a constant slowdown in the execution of these operations. Subtractions, additions and multiplications between (c · w)-bits words take trivially constant time by breaking the operands in 2c digits of w/2 bits each and use schoolbook's algorithms (i.e. O(c)-time addition and O(c2)-time multiplication). The modulo operator a mod q (with q fixed) can be computed as a mod q = a−ba/qc· q. Computing ba/qc requires pre-computing (once) the floating point value q−1 up to some fixed precision (i.e. O(w) decimal binary digits since a and q have O(w) binary digits), performing a (constant time) multiplication a · q−1, and truncating the result to an integer. Bitwise operations on (c · w)-bits words can trivially be implemented with c bitwise operations between w-bits words. Appendix: proofs B B.0.1 Proof of Theorem 4 The idea is to check the property on strings of length 2e by using the already-checked property on strings of length 2e−1. First, we build a data structure supporting the computation of φq(T[i, . . . , j]) in constant time. To this end, we can use the structure described in the previous section, augmented with n words storing values 2dlog ne·i mod q, i = 0, . . . , n− 1 (to guarantee constant-time retrieval of powers of 2 modulo q). We start with e = 0 and repeat N. Prezza 23:15 blog nc+1 times the following procedure, each time incrementing e by one. We use a hash table H of size O(n) with associated hash function h : [0, q − 1] → [0,H− 1] mapping Karp-Rabin fingerprints of length-2e text substrings to numbers in [0,H−1]. H can be implemented, e.g. with linear probing in order to guarantee expected constant-time operations. Each entry of H is associated with a list of integers. We scan T left-to-right and, for each 0 ≤ i ≤ n−2e, append the value i at the end of the list H[h(φq(T[i, . . . , i + 2e − 1]))]. Then, for each 0 ≤ t < H, we check that all i1, i2 ∈ H[t] are such that T[i1, . . . , i1 + 2e − 1] = T[i2, . . . , i2 + 2e − 1]. This task can be performed in O(H[t]) time as follows. Let H[t] = hi0, . . . , id−1i. We only need to perform d − 1 comparisons T[ij, . . . , ij + 2e − 1] = T[ij+1, . . . , ij+1 + 2e − 1] for 0 ≤ j < d. If e = 0, then each comparison takes constant time and can be done by simply accessing the text. If e > 0, then T[ij, . . . , ij + 2e − 1] = T[ij+1, . . . , ij+1 + 2e − 1] holds if and only if both φq(T[ij, . . . , ij + 2e−1 − 1]) = φq(T[ij+1, . . . , ij+1 + 2e−1 − 1]) and φq(T[ij + 2e−1, . . . , ij + 2e − 1]) = φq(T[ij+1+2e−1, . . . , ij+1+2e−1]) hold (constant time by using our structure to compute any φq(T[i0, . . . , j0])). Note that we already verified that φq is collision-free over T's substrings of length 2e−1, so both checks are deterministic. All lists in H store overall n − 2e + 1 elements, therefore the procedure terminates in O(n) expected time. Since we have to repeat this for every non-negative integer e ≤ log n, the overall expected time is O(n log n). (cid:74) B.0.2 Proof of Theorem 5 First, we build in-place and O(n) time the in-place data structure supporting the computation of φq(T[i, . . . , j]) in O(log n) time described in Section 3.5. For e = 0, . . . ,blog nc we repeat the following procedure. We initialize an array (text positions) A[0, . . . , n − 2e] with A[i] = i. We use any O(n log n) in-place comparison-sorting algorithm to sort A according to length-2e fingerprints, i.e. using the ordering ≺ defined by A[i] ≺ A[j] iff φq(T[A[i], . . . , A[i] + 2e − 1]) < φq(T[A[j], . . . , A[j] + 2e − 1]). At this point, we scan A and, for every pair of adjacent A's elements A[i], A[i + 1], if φq(T[A[i], . . . , A[i] + 2e − 1]) = φq(T[A[i + 1], . . . , A[i + 1] + 2e − 1]), then we check deterministically that the two substrings T[A[i], . . . , A[i] + 2e − 1] and T[A[i + 1], . . . , A[i + 1] + 2e − 1] are indeed equal with the same strategy used in the proof of Theorem 4 (i.e. we compare the fingerprints of their two halves of length 2e−1, or we just access the text if e = 0). Finally, we free the memory allocated for A. Analysis. For every e ≤ log n we sort A (O(n log n) comparisons). Note that fingerprints have all the same length 2e, so we only need to sample value 2b·2e mod q, with b = dlog σe, in order to speed up fingerprint computation (see Section 3.4.2-Speeding up LCE queries). Each comparison in the sorting algorithm requires the computation of two fingerprints and takes therefore constant time. We moreover need value 2b·2e−1 mod q to perform the deterministic collision check. Since 2b·2e mod q can be computed in constant time from 2b·2e−1 mod q, we need to reserve only two memory words for this sampling of powers of 2 (cid:74) modulo q (updating these two values every time e is incremented). B.0.3 Proof of Theorem 6 We need to show that we can sort in-place (i.e. n log n bits of space) and O(n) time text positions i = 0, . . . , n − 2e using as comparison values φq(T[i, . . . , i + 2e − 1]). Then, we plug this sorting procedure in the proof of Theorem 5 to obtain the claimed bounds of the theorem. CVIT 2016 23:16 In-Place Longest Common Extensions Let w = c · log n, with c ∈ O(1). A Karp-Rabin fingerprint takes τ = 10w = 10c log n bits of space. Let xi = φq(T[i, . . . , i + 2e − 1])i be the concatenation of the fingerprint of T[i, . . . , i + 2e − 1] and of position i written in binary. xi takes (10c + 1) log n bits of space (note that Karp-Rabin Fingerprints can be computed in constant time using our Monte Carlo structure as the power 2e mod q is fixed). We store x0, . . . xn/(10c+1)−1 in an array A taking n log n bits of space. We sort x0, . . . xn/(10c+1)−1 in-place and O(n) time using in-place radix sort [11]. Then, we compact A by replacing each xi with the integer i. As a result, the first n/(10c + 1) entries of A now contain text positions 0, . . . , n/(10c + 1) − 1 sorted by their fingerprint. We apply recursively the above procedure to text positions n/(10c + 1), . . . , n− 1 using the free space left in A (i.e. n log n − n 10c+1 log n bits) to perform sorting. Note that we recurse on n − n 10c > 1. This gives us the recurrence T(n) = O(n) + T(n/d) for our overall procedure (with base case T(1) = O(1)), which results in overall T(n) = O(n) time (being d > 1). After terminating the above procedure, A contains O(log n) sub-arrays of text positions sorted by their fingerprints. Starting from the two rightmost such sub-arrays, we repeatedly apply in-place merge sort [31] until the whole A is sorted. Note that a single comparison of two text positions i and j requires computing φq(T[i, . . . , i+2e−1]) and φq(T[j, . . . , j+2e−1]) (constant time with our structure and using the sampled value 2e mod q). Boundaries of the sub-arrays can be computed on-the-fly (i.e. 0, n − n/d, n − n/d2, ...). Analogously to the above analysis, at the j-th step, j ≥ 1, we merge in linear time two sub-arrays of total size O(dj). The overall time spent inside this procedure is therefore O(Plogd n i=1 dj) = O(n). 10c+1 = n 10c 10c+1 text positions. Let d = 10c+1 B.0.4 Acknowledgments I wish to thank Tomasz Kociumaka for reviewing the first draft of the paper and spotting some imprecisions in the proofs, and anonymous reviewers for useful comments on a preliminary version of the paper.
1612.05474
1
1612
2016-12-16T14:12:07
A Generalized Approximation Framework for Fractional Network Flow and Packing Problems
[ "cs.DS" ]
We generalize the fractional packing framework of Garg and Koenemann to the case of linear fractional packing problems over polyhedral cones. More precisely, we provide approximation algorithms for problems of the form $\max\{c^T x : Ax \leq b, x \in C \}$, where the matrix $A$ contains no negative entries and $C$ is a cone that is generated by a finite set $S$ of non-negative vectors. While the cone is allowed to require an exponential-sized representation, we assume that we can access it via one of three types of oracles. For each of these oracles, we present positive results for the approximability of the packing problem. In contrast to other frameworks, the presented one allows the use of arbitrary linear objective functions and can be applied to a large class of packing problems without much effort. In particular, our framework instantly allows to derive fast and simple fully polynomial-time approximation algorithms (FPTASs) for a large set of network flow problems, such as budget-constrained versions of traditional network flows, multicommodity flows, or generalized flows. Some of these FPTASs represent the first ones of their kind, while others match existing results but offer a much simpler proof.
cs.DS
cs
A Generalized Approximation Framework for Fractional Network Flow and Packing Problems∗ Michael Holzhauser Sven O. Krumke University of Kaiserslautern, Department of Mathematics We generalize the fractional packing framework of Garg and Koenemann [17] to the case of linear fractional packing problems over polyhedral cones. More precisely, we pro- vide approximation algorithms for problems of the form max{cT x : Ax 6 b, x ∈ C}, where the matrix A contains no negative entries and C is a cone that is generated by a finite set S of non-negative vectors. While the cone is allowed to require an exponential-sized representation, we assume that we can access it via one of three types of oracles. For each of these oracles, we present positive results for the approximability of the packing problem. In contrast to other frameworks, the presented one allows the use of arbitrary linear objective functions and can be applied to a large class of packing problems with- out much effort. In particular, our framework instantly allows to derive fast and simple fully polynomial-time approximation algorithms (FPTASs) for a large set of network flow problems, such as budget-constrained versions of traditional network flows, multicom- modity flows, or generalized flows. Some of these FPTASs represent the first ones of their kind, while others match existing results but offer a much simpler proof. 1 Introduction In a fractional linear packing problem, one seeks to find a solution to the problem max{cT x : Ax 6 b, x > 0}, where the matrix A ∈ Nm×n contains no negative entries and, without loss of generality, >0 >0 and b ∈ Nm the vectors c ∈ Nn >0 have positive entries. Many problems can be formulated as packing problems, possibly the most intuitive being the fractional knapsack problem (cf. [27]). More than this, many network flow problems can be seen as fractional packing problems if one allows exponential sized representations. For example, the traditional maximum flow problem can be seen as the problem of packing flows on s-t-paths without violating the capacities of the edges. A large number of authors presented approximation frameworks for such fractional packing prob- lems, including Plotkin et al. [32], Grigoriadis and Khachiyan [18, 19], Young [38], and Bienstock ∗This work was partially supported by the German Federal Ministry of Education and Research within the project "SinOp- tiKom -- Cross-sectoral Optimization of Transformation Processes in Municipal Infrastructures in Rural Areas". 1 and Iyengar [3] (cf. [2, 17] for an overview of these results). One of the most powerful frame- works among these was developed by Garg and Koenemann [17], who have shown that a (1 − ε)- approximate solution to a general fractional packing problem of the above form can be computed efficiently provided we are able to "handle" the dual problem appropriately. More precisely, in the dual formulation min{bT y : AT y > c, y > 0}, we need to be able to determine a most violated dual constraint efficiently: For some given infeasible solution y to the dual, we need to find a dual con- straint1 (AT )l·y > cl that minimizes the value (AT )l·y among all dual constraints with a positive right-hand side value. This constraint reveals the largest degree of violation. Since the result may even hold if the number of variables in the primal formulation is of exponential size, the authors were able to provide efficient FPTASs for network flow problems such as multicommodity flow problems by using (exponential-sized) path-based formulations of the corresponding problems (cf. Garg and Koenemann [17]). Fleischer [14] later showed that it suffices to determine an approximately most vio- lated dual constraint, whose fraction (AT )l·y may be up to a factor 1 + ε away from the largest violation. cl cl In this paper, we generalize the result of Garg and Koenemann [17] to the case of packing problems over polyhedral cones. More precisely, we are interested in approximate solutions to problems of the form max cT x s.t. Ax 6 b, x ∈ C, (1a) (1b) (1c) >0 where the matrix A ∈ Nm×n contains no negative numbers and where the cone C is finitely gener- ated by a set S of non-negative vectors. While the vector b ∈ Nm >0 is still assumed to contain positive entries (without loss of generality), we allow the entries of the vector c ∈ Nn to have arbitrary signs. We will thereby combine a large set of well-known techniques such as the fractional packing frame- work of Garg and Koenemann [17], the extension of Fleischer [14], the parametric search technique of Megiddo [29], geometric-mean binary search due to Hassin [21], and transformation strategies for fractional objectives as described in Lawler [28]. The chosen formulation is motivated by the following observation: Network flow problems often allow a characterization by some kind of flow decomposition, i.e., each feasible flow is representable by the sum of flows on much simpler structures, which we call basic components in the following. Viewed from the other side, we can express each such feasible flow as a conic combination of flows on these basic components. Hence, if C describes the cone that is generated by flows on basic components, we can express structural properties of each flow by the containment in the cone. What usually remains are packing constraints that bound the total flow on each edge, the flow that leaves some node, or the overall costs of the flow. As it will be shown, most common network flow problems can be modeled in such a way. One major advantage of the presented framework is that we do not assume the cone C or the set S that generates it to be given explicitly. Instead, we only assume that we have some kind of oracle access 1We use the notation Bl· for a matrix B to denote the l-th row of the matrix. 2 to the cone, which allows us to derive polynomial-time algorithms for problems that require cones with an exponential number of extreme rays. In addition to this benefit, our framework provides the following advantages: ⊲ The framework allows to derive fast and simple combinatorial FPTASs for a large class of pack- In many cases, we are even able to derive first ing problems and network flow problems. strongly polynomial-time FPTASs. ⊲ As our problem is formulated as a packing problem, the addition of further budget-constraints does not influence the applicability of the procedure, whereas such constraints usually make the design of exact algorithms significantly harder. ⊲ The application of the framework only requires two "ingredients", namely the existence of some kind of flow decomposition theorem and a decent amount of control over the resulting basic components. ⊲ As the framework is based on the approximation scheme of Garg and Koenemann [17] in its core, it works without considering some kind of residual network in case of network flow prob- lems. As a consequence, the framework can be applied to problems that do not offer a concept of residual networks. One example is the maximum flow problem in generalized processing networks that will be discussed later. Moreover, it maintains properties of the underlying net- work such as cycle freeness or signs of costs. ⊲ In contrast to the framework of Garg and Koenemann [17], our formulation allows to stick to the natural edge-based formulations of the corresponding network flow problems and does not require an explicit reformulation of the problem as a packing problem. ⊲ Moreover, the presented framework is the first application of the procedure of Garg and Koen- emann [17] that natively supports the use of arbitrary linear objective functions, which allows the application to minimum cost flow problems. To the best of our knowledge, all prior ap- plications instead transformed the objective functions into budget-constraints and searched for the optimal budget, which requires the restriction to positive costs and which results in weakly polynomial running times (cf. [17, 14, 13]). The paper is structured as follows: In Section 2, we briefly introduce the concepts that are inherent to our framework such as the procedure of Garg and Koenemann [17] and Megiddo's parametric search technique [29, 30]. In Section 3, we reformulate the given problem (1) as a packing problem and iden- tify a subproblem that needs to be solved in each iteration of the algorithm. Moreover, we introduce three oracle types that will be investigated in the rest of the paper: a minimizing oracle returning a cost-minimal vector in the ground set, a sign oracle only returning a vector with the same sign as a cost minimal vector, and a separation oracle either returning a vector with negative costs or stating that there is no such vector. Based on these considerations, we describe the general procedure in Sec- tion 4 and show that we can approximate problem (1) efficiently if we are able to find a sufficiently good initial lower bound on the most violated dual constraint. In Section 5, we provide both weakly polynomial-time and strongly polynomial-time approaches to find such a lower bound. Finally, we apply our framework to a large class of network flow and packing problems in Section 6, including the maximum/minimum cost flow problem, generalized minimum cost flow problem, and the max- imum/minimum cost flow problem in processing networks as well as budget-constrained versions 3 of these. Moreover, we apply our framework to the maximum (weighted) spanning tree packing problem and the maximum (weighted) matroid base packing problem as examples of "pure" combi- natorial problems. In Table 1, we give an overview of the results that will be derived in Section 6. Problem Previous best FPTAS Our FPTAS Budget-Constrained Maximum Flow Problem Budget-Constrained Minimum Cost Flow Problem Budget-Constrained Minimum Cost Generalized Flow Problem Maximum Flows in Generalized Processing Networks Minimum Cost Flows in General- ized Processing Networks Maximum Concurrent Problem Flow Maximum Weighted Multicom- modity Flow Problem Maximum Spanning Tree Packing Problem -- [22] ε2 · nm2 · (log 1 ε2 · (nm2 + n3m))(cid:17) eO(cid:16) 1 eO(cid:16) 1 O(cid:16) 1 ε2 · m2 log m(cid:17) (positive costs) [13] [24] ε + log log M)(cid:17) -- [25] eO(cid:16) 1 ε2 · (m2 + kn)(cid:17) eO(cid:16) 1 ε2 · m2 · min{log C, k}(cid:17) O(cid:0)n3m log(n2/m)(cid:1) (exact algorithm) [15] [14] Maximum Weighted Spanning Tree Packing Problem -- Maximum Matroid Base Packing Problem O(cid:0)m7 · F(m)(cid:1) (exact algorithm) [33, p. 734] Maximum Weighted Matroid Base Packing Problem -- (simpler proof) (simpler proof) (arbitrary costs) ε2 · m log m · (m + n log n)(cid:17) O(cid:16) 1 ε2 · nm2(cid:17) eO(cid:16) 1 ε2 · n2m2(cid:17) eO(cid:16) 1 O(cid:16) 1 ε2 · m2 log m(cid:17) O(cid:16) 1 ε2 · m2 log m(cid:17) eO(cid:16) 1 ε2 · m2 · min{k, n}(cid:17) ε2 · m2(cid:17) eO(cid:16) 1 O(cid:16) 1 ε2 · m2 log m · α(m, n)(cid:17) O(cid:16) 1 ε2 · m2 log m · α(m, n)(cid:17) O(cid:16) 1 ε2 · m2 log m · (F(m) + log m)(cid:17) ε2 · m + log log M(cid:17)(cid:17) eO(cid:16)m · F(m) ·(cid:16) 1 Table 1: A summary of our results. Here, m and n denote the number of edges and nodes, respectively. The variable k denotes the number of commodities and C denotes the largest ratio of any two weights of commodities. M is the largest integer given in the input. The notationeO(·) ignores poly-logarithmic factors in m, so eO(f(n, m)) = O(f(n, m) · logq m) for some constant q. α(m, n) denotes the inverse Ackermann function. F(m) is the running time of a independence testing oracle for a given matroid with m elements in its ground set. 2 Preliminaries 2.1 Approximation Algorithms An algorithm A is called a (polynomial-time) approximation algorithm with performance guarantee α ∈ [1,∞) or simply an α -- approximation for a maximization problem Π with objective function c if, for each instance I of Π with optimum solution x∗, it computes a feasible solution x with objective value 4 c(x) > 1 α c(x∗) in polynomial time. An algorithm A that receives as input an instance I ∈ Π and a real number ε ∈ (0, 1) is called a polynomial-time approximation scheme (PTAS) if, on input (I, ε), it computes a feasible solution x with objective value c(x) > (1 − ε) · c(x∗) with a running-time that is polynomial in the encoding size I of I. If this running-time is additionally polynomial in 1 ε , the algorithm is called a fully polynomial-time approximation scheme (FPTAS). 2.2 Garg and Koenemann's Fractional Packing Framework >0 Consider a fractional packing problem of the form max{cT x : Ax 6 b, x > 0} with non-negative entries in the matrix A ∈ Nm×n . For example, we can model the maximum flow problem in such a way by interpreting the variables as flows on s-t-paths and requiring that the sum of flows on all paths that share some specific edge e is bounded by the edge's capacity. Hence, the vector b corresponds to the capacities of the edges and the vector c equals the all-one vector. Note that we need to stick to the path-based formulation of the problem since we are not allowed to introduce flow conservation constraints as they require negative coefficients. The dual formulation of the general primal problem is given as min{bT y : AT y > c, y > 0}. In the example, the dual problem is to find small edge-lengths such that each path has length at least one. Although both the primal and the dual formulation of the problem are of exponential size in general, the fractional packing framework of Garg and Koenemann [17] allows us to obtain approximate solutions for the primal problem by using these formulations only implicitly, which will be shown in the following. Suppose that we want to find an (1 − ε)-approximate solution for the primal problem with ε ∈ (0, 1) and let ε ′ := ε 2 . The procedure described in [17] starts with the feasible primal solution x = 0 and the infeasible dual solution given by yi := δ . bi > 0 for each i ∈ {1, . . . , m}, where δ := (1+ε ′) ((1+ε ′)m) 1 ε ′ (AT )j·y In each step of the algorithm, the most violated dual constraint is determined based on the current among dual solution y, i.e., we determine a row j in the dual formulation that minimizes all rows with negative right-hand side value. For example, although there are exponentially many constraints in the dual formulation of the maximum flow problem, we can find the most violated constraint in O(m + n log n) time by computing a shortest s-t-path with edge lengths given by the dual vector y. We then increase xj by the (in terms of the primal problem) maximum allowed value ν := mini∈{1,...,m}:Aij>0 (i.e., in the example, we send ν units of flow on the shortest path without considering flow that has been sent in previous iterations), which will most likely make the primal solution infeasible. At the same time, each variable yi will be multiplied by a factor of Aij!. Intuitively, for the maximum flow problem, the "congested" edges will get "longer" 1 + ε ′ · ν bi Aij cj bi over time and will, thus, be used less likely in future iterations, which somehow balances the flow among all paths. The algorithm stops as soon as the dual solution fulfills Pi∈{1,...,m} bi · yi > 1. As noted above, the primal solution will most likely be infeasible since, in each iteration, the primal variables are increased regardless of the previous values. However, Garg and Koenemann [17] show that we and that this solution obtain a feasible primal solution by scaling down the solution x by log1+ε ′ is within a factor (1 − 2ε ′) = (1 − ε) of the optimal solution. Moreover, they prove that the described 1+ε ′ δ 5 procedure terminates within 1 13] for further details on the procedure. ε ′ · m · (1 + log1+ε ′ m) = O(cid:0) 1 ε2 · m log m(cid:1) iterations. We refer to [17, 14, In a follow-up publication, Fleischer [14] showed that it suffices to determine an approximately most violated dual constraint in each iteration of the problem: The claimed time bound and approximation guarantee continue to hold even if we choose a dual constraint (AT )j·y > cj only fulfilling (AT )j·y 6 cj (1 + ε) · minl∈{1,...,n}:cl>0 (AT )l·y cl . We will make use of this observation in Section 4. 2.3 Megiddo's Parametric Search Technique In Section 6, we make use of Megiddo's parametric search technique (cf. [29]). Since we will go into the very heart of the method, we will briefly describe its idea in the following. We refer the reader to [29] and [30] for further details on the method. Assume that we want to solve an optimization problem Π for which we already know an (exact) algorithm A that solves the problem, but in which some of the input values are now linear parametric values that depend linearly on some real parameter λ. Moreover, suppose that an algorithm C is known (in the following called callback) that is able to decide if some candidate value for λ is smaller, larger, or equal to the value λ∗ that leads to an optimum solution to the underlying problem Π. The idea of the parametric search technique is to extend the input of A from constants to affine functions depending on λ and to simulate the execution of algorithm A step by step. Note that each variable remains its affine structure as long as the algorithm only performs additions, subtractions, multiplications with constants, and comparisons. We call such an algorithm strongly combinatorial in the following. Throughout the execution, an interval I is maintained that is known to contain the optimal value λ∗. As soon as the simulation reaches the comparisons of two linear parametric values, since both values depend linearly on λ, it either holds that one of the variables is always larger than or equal to the other one in I (in which case the result of the comparison is independent from λ) or that there is a unique intersection point λ ′. For this intersection point, we evaluate the callback C in order to determine if λ ′ < λ∗, λ ′ > λ∗, or λ ′ = λ∗ and, thus, resolve the comparison, update the interval I, and continue the execution. Hence, as soon as the simulation of A finishes, we have obtained an optimum solution to Π. The overall running-time is given by the running-time of A times the running-time of C and can be further improved using parallelization techniques described in [30]. We refer to [29, 30] for details on the parametric search technique. Further applications and extensions of parametric search techniques can moreover be found in [8, 34, 35]. 3 Packing over Cones In this section, we transform the problem (1) to a general (possibly exponential-sized) fractional pack- ing problem in a first step and then reduce this problem to a more simple subproblem by incorpo- rating the fractional packing framework of Garg and Koenemann [17]. Moreover, we introduce three types of oracles that enable us access to the cone C and that will be used throughout the rest of the paper. 6 Let S := {x(1), . . . , x(k)} denote a finite set of k non-negative n-dimensional vectors x(l) ∈ Rn x(l) 6= 0. The cone that is spanned by these vectors is given by >0 with C :=(cid:14)x ∈ Rn : x = k Xl=1 αl · x(l) with αl > 0 for all l ∈ {1, . . . , k}(cid:15) . (2) The main result of this paper is that we are able to compute (1 − ε)-approximate solutions for the problem to maximize a linear function over the cone C subject to a set of packing constraints under specific assumptions that will be investigated in the following. As we will see in Section 6, this extended framework is especially useful in the case of network flow problems for which some kind of flow decomposition theorem is known. Note that we do neither require the set S to be of polynomial size nor assume the set S or the cone C to be given explicitly. Instead, as it is common when dealing with implicitly given polyhedra, we only assume the cone to be well-described, which implies that it has an encoding length of at least n + 1 (cf. [20] for further details). Moreover, we make decisions over S and C via a given oracle A (to be specified later) that yields information about S based on a given cost vector d. We assume that the running-time TA of each oracle A fulfills TA ∈ Ω(n) since it would not be able to investigate each component of d or return a vector x ∈ C otherwise. In the following, let A ∈ Nm×n denote a constraint matrix with non-negative entries, b ∈ Nm >0 a positive right-hand side vector, and c ∈ Zn a cost vector with arbitrary signs. Without loss of generality, we assume that at least one entry in each row and each column of A is positive. Moreover, we define N to be the number of non-zero entries contained in the matrix A. >0 As described above, the problem we want to approximate is given as follows: max cT x s.t. Ax 6 b, x ∈ C. (1a) (1b) (1c) Using the definition of the cone C based on equation (2), we obtain the following equivalent formu- lation of the problem (1): k αl · x(l) max cT Xl=1 s.t. A k Xl=1 αl · x(l)! 6 b, αl > 0 for all l ∈ {1, . . . , k}. In particular, we replaced the original variables x by the weight vector α and, in doing so, incor- porated the constraints of the cone. As noted above, this formulation might be of exponential size. 7 However, in the following, we will never need to state it explicitly but will derive results based on its implicit structure. By rearranging the objective function and the packing constraints, we obtain the following equivalent formulation of the problem: max s.t. k Xl=1 Xl=1 k αl ·(cid:16)cT x(l)(cid:17) αl ·(cid:16)Ai·x(l)(cid:17) 6 bi for all i ∈ {1, . . . , m}, αl > 0 for all l ∈ {1, . . . , k}. (4a) (4b) (4c) Clearly, we can neglect vectors x(l) for which cT x(l) 6 0 since, without loss of generality, it holds that αl = 0 for each such l in an optimal solution. Hence, for the moment, we restrict2 our consid- erations on vectors x(l) with cT x(l) > 0 such that the primal problem (4) becomes in fact a fractional packing problem (again, possibly of exponential size). The dual formulation of this problem is given as follows: min s.t. m Xi=1 Xi=1 m yi · bi yi ·(cid:16)Ai·x(l)(cid:17) > cT x(l) for all l ∈ {1, . . . , k} with cT x(l) > 0, yi > 0 for all i ∈ {1, . . . , m}. (5a) (5b) (5c) As it was shown in Section 2.2, we can apply the fractional packing framework of [17] to the original problem (1) provided we are able to determine the most violated dual constraint in equation (5b) efficiently. Hence, given a dual solution y > 0, we need to be able to solve the following subproblem in polynomial time: cT x(l)>0 Pm i=1 yi ·Pn = min l∈{1,...,k} cT x(l) j=1 Aij · x (l) j cT x(l) i=1 yi ·(cid:0)Ai·x(l)(cid:1) ·Pm cT x(l) j=1 x (l) j i=1 yi · Aij . min l∈{1,...,k} cT x(l)>0 Pm cT x(l)>0 Pn With aj :=Pm = min l∈{1,...,k} aT x(l) cT x(l) . min l∈{1,...,k} cT x(l)>0 i=1 yi · Aij for j ∈ {1, . . . , n} and a = (a1, . . . , an)T , this subproblem reduces to (6) Note that the vector a depends on y and, thus, changes throughout the course of the procedure of Garg and Koenemann [17]. However, it always holds that aj > 0 for each j ∈ {1, . . . , n} since yi > 0 2We will see how we can "filter out" vectors x(l) with negative costs in the following sections. 8 for each i ∈ {1, . . . , m} throughout the procedure and since the matrix A has at least one positive and no negative entry in each row as assumed above. Since x(l) 6= 0 and x(l) ∈ Rn >0 for each l ∈ {1, . . . , k}, this also yields that aT x(l) > 0, so the minimum in equation (6) is always strictly positive. Observation 1: It always holds that aj > 0 for each j ∈ {1, . . . , n}. Moreover, aT x(l) > 0 for each x(l) ∈ S. ⊳ Clearly, if the vectors in S are given explicitly, we immediately obtain an FPTAS for the original prob- lem (1) using the arguments given in Section 2.2. In the following, we discuss the more elaborate case that we can access the set S and the cone C only via given oracles. Throughout this paper, we investi- gate three kinds of oracles with decreasing strength. The most powerful oracle to be considered can be defined as follows: Definition 2 (Minimizing Oracle): For a given vector d ∈ Rn, a minimizing oracle for the set S returns a vector x(l∗) ∈ S that minimizes dT x(l) among all vectors x(l) ∈ S. ⊳ Clearly, the notion of minimizing oracles requires very powerful algorithms. For example, if S is the set of unit-flows on simple cycles in a given graph G, a minimizing oracle would need to be able to determine a most negative simple cycle, which is NP-complete in general (see Section 6.2). In many cases, it suffices to consider a much weaker type of oracle given as follows: Definition 3 (Sign Oracle): For a given vector d ∈ Rn, a sign oracle for the set S returns a vector x(l) ∈ S with3 sgn dT x(l) = sgn dT x(l∗), where x(l∗) minimizes dT x(i) among all vectors in S. ⊳ Rather than determining a vector in S with minimum cost, a sign oracle only returns any vector whose cost have the same sign as a minimum-cost vector, which may be much easier to find. In the example above, we can easily find a cycle with the same costs as a most negative cycle by computing a minimum mean cycle in O(nm) time (cf. [26] and Section 6.2). An even simpler kind of oracle is given as follows: Definition 4 (Separation Oracle): For a given vector d ∈ Rn, a separation oracle for the set S either states that dT x(i) > 0 for all vec- tors x(i) ∈ S or returns a certificate x(l) ∈ S that fulfills dT x(l) < 0. ⊳ Clearly, the notion of separation oracles yields the least powerful yet most natural definition of an oracle. The name "separation oracle" is based on the fact that such an oracle can be seen as a tradi- tional separation oracle for the dual cone C∗ := {w ∈ Rn : wT x > 0 for all x ∈ C} of the cone C (cf. [20]). Note that each minimizing oracle also induces a sign oracle and that each sign oracle induces a separation oracle, so the considered oracles have in fact decreasing strength. In particular, each ap- proximation algorithm that is based on a sign oracle (separation oracle) is also valid for the case of a minimizing oracle (sign oracle). 3The sign function sgn : R 7→ {−1, 0, 1} returns −1, 0, or 1 depending on whether the argument is negative, zero, or positive, respectively. 9 For the special case of uniform costs cT x(l) for all vectors x(l) ∈ S, we get the first approximation result based on the procedure of Garg and Koenemann [17]: Theorem 5: Suppose that cT x(l) = c for all x(l) ∈ S and some constant c > 0. Given a minimizing oracle A for S running in TA time, a (1 − ε)-approximate solution for the problem (1) can be computed in O(cid:0) 1 ε2 · m log m · (N + TA)(cid:1) time. problem of finding a vector x(l) with minimum cost(cid:0) 1 Pm Proof: Since cT x(l) = c for each x(l) ∈ S, the subproblem given in equation (6) reduces to the x(l) among all vectors in S. Using the minimizing oracle, we can compute a minimizer for (6) in O(TA) time based on the cost vector d := 1 c · a. Note that this cost vector can be built in O(N) time as each entry aj of a is defined to be i=1 yi · Aij, where each yi stems from the framework of Garg and Koenemann [17]. Consequently, we need look at each of the N entries of A once in order to build d. Hence, we are able to determine a most violated dual constraint of (5) in O(N + TA) time, so the claim follows immediately from the arguments outlined in Section 2.2. c · a(cid:1)T Note that the vector d that is constructed in the above procedure is always positive in each component according to Observation 1. As a consequence, if for example we use the vector d to denote the length of edges in a graph, we can use Dijkstra's (1959) algorithm to compute a shortest path. This will be used in Section 6. In the following sections, we will focus on the more general cases in which the costs are no longer uniform and in which we may only have access to the cone via weaker types of oracles. 4 General Algorithm Throughout this section, we assume that there is a separation oracle A for S running in TA time. Hence, the presented results are valid for the case of minimizing oracles and sign oracles as well. In the subsequent section, we will see where the different strengths of the oracles come into play. The procedure of the upcoming algorithm is based on an idea introduced by Fleischer [14], which was originally developed for the maximum multicommodity flow problem: For λ∗ to denote the optimal value of the most violated dual constraint in equation (6), we let λ denote a positive lower bound for λ∗. We will show in Section 5 how we can find a good initial value for this lower bound efficiently. In each iteration of the procedure of Garg and Koenemann [17] as described in Section 2.2, we need to determine an approximately most violated dual constraint corresponding to some vector x(j) ∈ S fulfilling aT x(j) cT x(j) 6 (1 + ε) · λ∗ = (1 + ε) · min l∈{1,...,k} cT x(l)>0 aT x(l) cT x(l) . For λ ∈ R, let d(λ) := a − λc and D(λ) := min{d(λ)T x(l) : l ∈ {1, . . . , k} with cT x(l) > 0}. Similar to the minimum ratio cycle problem [28, 29, 30], we get the following characterization of the relation between the sign of D(λ) and the sign of λ∗ − λ: 10 Lemma 6: For some given value of λ ∈ R, it holds that sgn(D(λ)) = sgn(λ∗ − λ). Proof: Let L := {l ∈ {1, . . . , k} : cT x(l) > 0}. First, consider the case that D(λ) > 0. The claim follows by simple arguments: D(λ) > 0 ⇐⇒ d(λ)T x(l) > 0 ⇐⇒ (a − λc)T x(l) > 0 ⇐⇒ aT x(l) cT x(l) > λ ⇐⇒ λ∗ > λ. for all l ∈ L for all l ∈ L for all l ∈ L Conversely, if D(λ) < 0, we get the following equivalences by similar arguments: D(λ) < 0 ⇐⇒ d(λ)T x(l) < 0 ⇐⇒ (a − λc)T x(l) < 0 ⇐⇒ aT x(l) cT x(l) < λ ⇐⇒ λ∗ < λ. for some l ∈ L for some l ∈ L for some l ∈ L Finally, in the remaining case D(λ) = 0, it follows by continuity that λ∗ = λ, which shows the claim. Lemma 6 implies that λ∗ is the maximum value of λ such that D(λ) > 0, i.e., such that d(λ)T x(l) > 0 for each x(l) ∈ S with cT x(l) > 0. In each iteration of our general procedure, we call the given separation oracle A with the vector d((1 + ε)λ). We distinguish between the two possible outcomes of one such call: Case 1: The oracle returns some certificate x(l) ∈ S with d((1 + ε)λ)T x(l) < 0. In this case, we get that ⇐⇒ =⇒ =⇒ (a − (1 + ε) · λ · c)T x(l) < 0 aT x(l) < (1 + ε) · λ · cT x(l) aT x(l) cT x(l) < (1 + ε) · λ aT x(l) cT x(l) < (1 + ε) · λ∗. The third inequality follows from the fact that aT x(l) > 0 (cf. Observation 1) and that λ > 0 such that it also holds that cT x(l) > 0. The returned vector x(l) yields an approximately most 11 violated dual constraint. We use this dual constraint and continue the procedure of Garg and Koenemann [17]. Note that, during an iteration of the procedure, it holds that cT x(j) remains constant for each vector x(j) ∈ S (since it does not depend on the dual solution y) and that aT x(l) does not decrease (since both the entries in x(l) and the entries in A are non-negative). Hence, λ continues to be a lower bound for the (possibly increased) new value λ∗ of (6). Case 2: The oracle states that all vectors x(l) fulfill d((1 + ε)λ)T x(l) > 0. It now holds that (a − (1 + ε) · λ · c)T x(l) > 0 ∀x(l) ∈ S ⇐⇒ ⇐⇒ ⇐⇒ aT x(l) > (1 + ε) · λ · cT x(l) ∀x(l) ∈ S aT x(l) cT x(l) > (1 + ε) · λ ∀x(l) ∈ S with cT x(l) > 0 λ∗ > (1 + ε) · λ. In this case, we can update the lower bound λ to (1 + ε) · λ and continue. Hence, in each iteration of the algorithm, we either proceed in the procedure of Garg and Koenemann [17] or we increase the lower bound by a factor of 1 + ε. Again, we want to stress that λ continues to be a lower bound for λ∗ after an iteration of the above algorithm. The following theorem shows that this yields an efficient approximation algorithm for the problem (1) provided we are given a sufficiently good initial estimate for λ∗: Theorem 7: Given a separation oracle A for S running in TA time and given an initial lower bound λ for the ε m · λ, a (1 − ε)-approximate solution for problem (1) can be initial value of λ∗ fulfilling λ 6 λ∗ 6 m 1 determined in O(cid:0) 1 ε2 · m log m · (N + TA)(cid:1) time. Proof: The correctness of the procedure follows from the arguments outlined in Section 2.2, the pre- ceding discussion, and the fact that the initial value of λ is a valid lower bound for λ∗. In each step of the algorithm, we evaluate the given separation oracle and -- based on its result -- either perform one iteration of the procedure of Garg and Koenemann [17] and Fleischer [14] or update the lower bound λ. As noted in Section 2.2, the former case occurs up to O( 1 ε2 · m log m) times. In order to (k) determine the number of updates to λ, let (λ∗)(k), λ(k), y i denote the values of the corresponding variables after the k-th iteration of the overall algorithm and let τ denote the number of iterations > 1. Hence, after (τ−1) i until the algorithm stops. Note that the procedure stops as soon asPm for each i ∈ {1, . . . , m}. Since each variable y the (τ − 1)-th iteration, it holds that y i=1 bi · y (τ−1) i will be increased by a factor of at most 1 + ε in the final iteration, it holds that y := δ bi δ during the execution of the algorithm, so y (τ) i < (1 + ε) · 1 bi , every dual variable increases by a (τ) δ · y(0). However, this also i δ · (λ∗)(0). Since the lower bound λ remains to be a lower bound after every Since the initial value of each variable yi was set to y factor of at most 1+ε implies that (λ∗)(τ) 6 1+ε step of the algorithm as discussed above, it holds that 6 1+ε < 1 bi (k) i (0) i . λ(τ) 6 (λ∗)(τ) 6 1 + ε δ · (λ∗)(0) 6 1 + ε δ · m 1 ε m · λ(0), 12 ε m · λ(0). Since λ is in- where the third inequality follows from the requirement that (λ∗)(0) 6 m creased by a factor of 1 + ε in each update step, we get that the number of such steps is bounded by 1 log1+ε λ(τ) λ(0) 6 log1+ε(cid:18) 1 + ε δ · m 1 ε m(cid:19) = log1+ε 1 + ε δ + log1+ε m 1 ε m = log1+ε 1 + ε 1+ε ((1+ε)m) 1 ε + 1 ε · m log1+ε m = log1+ε((1 + ε)m) 1 ε + 1 ε · m log1+ε m = 1 ε · (1 + log1+ε m) + 1 ε · m log1+ε m ∈ O(cid:18) 1 ε · m log1+ε m(cid:19) = O(cid:18) 1 ε · m · log m log(1 + ε)(cid:19) = O(cid:18) 1 ε2 · m log m(cid:19) and, thus, matches the number of iterations of the procedure of Garg and Koenemann [17]. The claim then follows by the fact that, in each step of the algorithm, we need O(N) time to compute the entries of the vector d((1 + ε)λ) and TA time to evaluate the oracle. Note that the allowed deviation of the initial lower bound λ to λ∗ in Theorem 7 is chosen in a way such that the number of update steps to λ does not dominate the O( 1 ε2 · m log m) steps of the overall procedure. 5 Determining a lower bound The proof of Theorem 7 shows that the strongly polynomial number of oracle calls depends on the assumption that the initial value for the lower bound λ is not "too far away" from the real value λ∗ of the most violated dual constraint. In this section, we present a weakly polynomial-time and a strongly polynomial-time approach to find such a sufficiently good initial value. 5.1 Weakly Polynomial-Time Approach for Separation Oracles We start by providing a general approach that is valid for all three types of oracles. The running time will depend (logarithmically) on the largest number given in the input, denoted by M := max{(maxi bi), (maxj cj), (maxi,j Ai,j), n, m} ∈ N. Lemma 8: Suppose that we are given a separation oracle A running in TA time. An initial lower bound λ for λ∗ ε m · λ can be determined in weakly polynomial time O((TA + N) · (log log M − fulfilling λ 6 λ∗ 6 m (log 1 ε + log m + log log m))). 1 13 Proof: Let x(l) ∈ S denote a vector with aT x(l) Using that yi := bi δ for each i ∈ {1, . . . , m} at the beginning of the procedure, we get that cT x(l) = λ∗ that determines the minimum in equation (6). aT x(l) cT x(l) = Pn Pn j=1 aj · x j=1 cj · x (l) j (l) j = Pn i=1 yi · Aij(cid:1) · x j=1(cid:0)Pm Pn j=1 cj · x (l) j (l) j = Pn j=1Pm Pn · Aij · x δ bi i=1 j=1 cj · x (l) j (l) j . (7) Without loss of generality, we can assume the separation oracle A to always return a vector x(l) ∈ S with maxj∈{1,...,n} xj = 1 (whenever it returns a vector at all): For each x ∈ C, it also holds that β · x ∈ C for some positive constant β. Hence, if the oracle does not fulfill the required property, we can wrap it into a new oracle A ′ which divides the vector returned by A by maxj∈{1,...,n} xi > 0. Using this fact in equation (7), we get the following lower and upper bound on λ∗: λ∗ > δ M i=1 Aij(cid:1) · x (l) j j=1 M · x j=1(cid:0)Pm ·Pn Pn (l) j > δ M ·Pn j=1 1 · x n · M (l) j > δ n · M2 > δ M3 =: λ1 and λ∗ 6 δ 1 i=1 Aij(cid:1) · x(l) (l) j j=1 1 · x j j=1(cid:0)Pm ·Pn Pn j=1 m · M · x(l) j 6 δ ·Pn 1 6 δ · nm · M 6 δ · M3 =: λ2. According to Lemma 6, each feasible lower bound λ for λ∗ is characterized by the fact that D(λ) > 0, so an oracle call with the vector d(λ) results in the answer that there are no vectors in S with negative ε m · λ, we only need to consider values for λ of the costs. Since λ is required to fulfill λ 6 λ∗ 6 m ε m)k in [λ1, λ2] for integral values of k. Moreover, since the oracle returns a vector if and form λ1 · (m only if λ > λ∗, we can perform a binary search on these values in order to find the best possible lower bound for λ∗. In total, we get the following number of iterations: 1 1 O(cid:18)log log 1 ε m m δ δ · M3 M3 ! = O(cid:16)log log ε m! = O log ε m M(cid:17) ε · m log m! log M m 1 1 m 1 ε m λ2 λ1(cid:19) = O log log = O log = O(cid:18)log log M −(cid:18)log log M 1 log m 1 ε + log m + log log m(cid:19)(cid:19) . In combination with the overhead of N + TA to call the oracle (as in the proof of Theorem 7), we get the claimed time bound. Note that the time bound given in Lemma 8 is in fact only weakly polynomial for very large values of M: The binary search only has an effect on the overall running time if the encoding length log M of M fulfills log M ∈ ω( 1 ε · m log m), i.e., if M is exponential in 1 ε · m log m. Theorem 7 in combination with Lemma 8 yields the following theorem: 14 Theorem 9: Given a separation oracle A for S running in TA time, a (1 − ε)-approximate solution for problem (1) can be determined in weakly polynomial time O((TA + N) · ( 1 ε + log m + log log m))). ε2 · m log m + log log M − (log 1 In particular, if the oracle A runs in polynomial time, we immediately obtain an FPTAS for prob- lem (1) according to Theorem 9. 5.2 Strongly Polynomial-Time Approach for Sign Oracles In the previous subsection, we introduced a method to determine an initial lower bound for λ∗ that is valid for each of the investigated types of oracles. However, although the general procedure that was described in Section 4 performs a strongly polynomial number of steps, the overall procedure would not yield a strongly polynomial FPTAS, in general, even if the oracle runs in strongly polynomial time due to the weakly polynomial overhead of the binary search. In this section, we present an alternative method for minimizing and sign oracles running in strongly polynomial time. In the subsequent subsection, we generalize the result to separation oracles. According to Lemma 6, we can decide about the direction of the deviation between some candidate value λ and the desired value λ∗, if we are able to determine the sign of D(λ). Clearly, this task is strongly related to the definition a sign oracle for S. However, the value D(λ) is defined to be the minimum of d(λ)T x(l) among all vectors x(l) that additionally fulfill cT x(l) > 0 whereas the sign oracle is not required to consider only such vectors according to Definition 3. Nevertheless, as it will be shown in the following lemma, we can neglect this additional restriction when evaluating the sign oracle: Lemma 10: For any positive value of λ, it holds that sgn(D(λ)) = sgn(d(λ)T x(l)) where x(l) is a vector returned by a sign oracle for S. Proof: First consider the case that sgn(d(λ)T x(l)) = −1, i.e., that d(λ)T x(l) < 0. Using the definition of d(λ), we get that (a − λc)T x(l) = aT x(l) − λ · cT x(l) < 0. Since both aT x(l) > 0 according to Observation 1 and λ > 0, it must hold that cT x(l) > 0 as well. Thus, we can conclude that D(λ) 6 d(λ)T x(l) < 0. Now consider the case that sgn(d(λ)T x(l)) = 0. According to Definition 3, it holds that there are no vectors x(j) ∈ S with d(λ)T x(j) < 0, so D(λ) > 0. As in the previous case, we get that (a − λc)T x(l) = aT x(l) − λ · cT x(l) = 0 if and only if cT x(l) > 0 since both aT x(l) > 0 and λ > 0. Hence, we also get that D(λ) 6 d(λ)T x(l) = 0, so D(λ) = 0. Finally, if sgn(d(λ)T x(l)) = 1, there are no vectors x(i) ∈ S with d(λ)T x(i) 6 0. Thus, it also holds that D(λ) > 0, which shows the claim. Lemma 10 now allows us to determine a sufficiently good initial lower bound λ. In fact, as it will be shown in the following lemma, we are even able to determine an exact most violated dual constraint in each iteration of the procedure: 15 Lemma 11: Given a strongly combinatorial and strongly polynomial-time sign oracle A for S running in TA time, a most violated dual constraint can be determined in O(cid:0)N + T 2 A(cid:1) time. Proof: Lemma 6 and Lemma 10 imply that λ∗ is the unique value for λ for which the sign oracle returns a vector x(l) ∈ S with d(λ)T x(l) = 0. In particular, the returned vector x(l) is a minimizer for (6). Hence, since the values ai can be computed in O(N) time, we are done if we are able to determine such a vector x(l) in O(T 2 A) time. Let d(λ) be defined as above, where λ is now treated as a symbolic value that is known to be contained in an interval I. Initially, we set I to (0, +∞) since the optimal value λ∗ is known to be strictly positive (cf. equation (6)). Note that the costs (d(λ))i = ai − λ · ci fulfill the linear parametric value property. We simulate the execution of the sign oracle A at input d(λ) using Megiddo's (1979) parametric search technique as described in Section 2.3. The underlying idea is to "direct" the control flow during the execution of A in a way such that it eventually returns the desired vector minimizing (6). Whenever we need to resolve a comparison between two linear parametric values that intersect at some point λ ′ ∈ I, we call the sign oracle itself with the cost vector d := d(λ ′) in order to determine the sign of D(λ ′). If D(λ ′) = 0, we found a minimizer for equation (6) and are done. If D(λ ′) < 0 (D(λ ′) > 0), the candidate value λ ′ for λ∗ was too large (too small) according to Lemma 6 and Lemma 10 such that we can update the interval I to I ∩ (−∞, λ ′) (I ∩ (λ ′, +∞)), resolve the comparison, and continue the simulation of the oracle algorithm. After O(TA) steps, the simulation terminates and returns a vector x(l) ∈ S that fulfills d(λ∗)T x(l) = 0 for the desired value λ∗ ∈ I. Hence, this vector yields a most violated constraint in (5b). Since the described simulation runs in O(T 2 A) time, the claim follows. Note that we actually still obtain a polynomial running-time of the above algorithm even if we do not assume the sign oracle to run in strongly polynomial time but only to run in weakly polynomial time. However, the running-time of the resulting algorithm might exceed the stated time bound since the candidate values λ ′ that determine the input to the callback oracle are rational numbers whose representation might involve exponential-size numbers of the form HTA for some H with polynomial encoding length. Although the running-time of a weakly polynomial-time oracle algorithm depends only logarithmically on the size of these numbers, the running-time might still increase by a large (polynomial) factor. Lemma 11 can be incorporated into the procedure of Garg and Koenemann [17] to obtain an FPTAS for problem (1) running in O( 1 A)) time. However, it can also be used to find an initial lower bound λ for λ∗ (which, in fact, equals λ∗), which yields the following theorem in combination with Theorem 7: ε2 · m log m · (N + T 2 Theorem 12: Given a strongly combinatorial and strongly polynomial-time sign oracle A for S running in TA time, ε2 · m log m · (N + TA) + T 2 there is a strongly polynomial FPTAS for the problem (1) running in O(cid:0) 1 A(cid:1) time. 16 5.3 Strongly polynomial-time approach for Separation Oracles Although separation oracles are probably the most natural kind of oracle, they are also the weakest of the considered oracle types. The proof of Lemma 11 relies on the fact that we are able to decide if some candidate value λ is too small, too large, or equal to the desired value. In the case of a separation oracle, however, the case that dT x(i) > 0 for all vectors x(i) ∈ S does no longer include the information whether there is a vector x(l) ∈ S with dT x(l) = 0 (in which case we have found the desired vector in the parametric search as described above) or if dT x(i) > 0 for all x(i) ∈ S. For example, if we come across a comparison of the form a0 + λ · a1 6 b0 + λ · b1 during the simulation where a1 > b1, we are actually interested in the information whether or not the optimal value λ∗ fulfills λ∗ 6 λ ′ . However, if we use the separation oracle with the cost vector d(λ ′), we only obtain the information whether λ∗ < λ ′ (in case that the oracle returns a certificate) or if λ∗ > λ ′. Hence, in the latter case, the outcome of the comparison is not yet resolved since we need the additional information whether or not λ∗ = λ ′, so we cannot continue the simulation without any further ado. Nevertheless, as it will be shown in the following lemma, we can gather this additional information by a more sophisticated approach: := b0−a0 a1−b1 Lemma 13: Given a strongly combinatorial and strongly polynomial-time separation oracle A for S running in TA time, a most violated dual constraint can still be determined in O(cid:0)N + T 2 A(cid:1) time. Proof: The claim directly follows from Lemma 11 if we can show that we can extend the given separation oracle into a sign oracle for S. As in the proof of Lemma 11, we simulate the execution of the separation oracle using the parametric cost vector d(λ) := a − λc. Assume that the execution halts at a comparison that needs to be resolved, resulting in a candidate value λ ′ for the desired value λ∗. We invoke the separation oracle with the cost vector d := d(λ ′). Clearly, if the oracle returns a certificate x(l) with dT x(l) < 0, we can conclude that D(λ ′) < 0 such that the value λ ′ was too large according to Lemma 6 and the result of the comparison is determined. Conversely, if the oracle states that dT x(i) > 0 for all x(i) ∈ S, we can conclude that D(λ ′) > 0. However, we may not yet be able to resolve the comparison since its result may rely on the additional information whether D(λ ′) = 0 or D(λ ′) > 0 as shown above. Nevertheless, we can extract this information by one additional call to the oracle as it will be shown in the following. First suppose that λ ′ = λ∗. In this situation, it holds that d(λ ′)T x(i) > 0 for all x(i) ∈ S and there is at least one vector x(l) ∈ S that fulfills d(λ ′)T x(l) = 0. Since all the functions f(i)(λ) := d(λ)T x(i) = aT x(i) − λ · cT x(i) are linear functions of λ with negative slope (in case that cT x(i) > 0; otherwise, the function has no positive root at all), it holds that several functions f(l) evaluate to zero at λ ′ while every other function attains its root at a larger value for λ (cf. Figure 1a). Hence, for every larger value of λ, the separation oracle changes its outcome and returns a certificate. In particular, for a sufficiently small but positive value of δ, the separation oracle called with the cost vector d(λ ′ + δ) returns a vector x(l) ∈ S with d(λ ′ + δ)x(l) < 0 that additionally fulfills d(λ ′)T x(l) = 0 (so x(l) yields a most violated constraint in the overall procedure). Clearly, the value of δ must be small enough to guarantee that we do not reach the root of another function f(i) (i.e., smaller than the distance between the dashed and the dotted line in Figure 1a). 17 f(i) λ ′ = λ∗ f(i) λ ′ λ∗ f(4) f(1) f(3) f(2) f(4) f(1) f(3) f(2) λ λ (a) λ ′ = λ∗ (b) λ ′ < λ∗ Figure 1: Illustration of the two cases that may occur during the simulation of the separation oracle in case that the separation oracle did not return a certificate when evaluated for a candidate value λ ′. Now suppose that λ ′ < λ∗ (cf. Figure 1b). In this case, for a sufficiently small but positive value of δ, the separation oracle returns the same answer when called with the cost vector d(λ ′ + δ) as long as λ ′ + δ 6 λ∗ (i.e., as long as δ is smaller than the distance between the dotted and the dashed line in Figure 1b). Consequently, in order to separate this case from the former case, it suffices to specify a value for δ that is smaller than the distance between any two roots of the functions that occur both in the instance and during the simulation of A. We can then use a second call to the decision oracle in order to decide whether a candidate value λ ′ is smaller than or equal to the optimal value λ∗. First note that the root of each function f(i) is given by the rational number aT x(i) ficients cj are part of the instance I of the problem (1) and since the values aj = Pm cT x(i) . Since the coef- i=1 yi · Aij are generated within the framework of Garg and Koenemann [17], the encoding length of both values is polynomial in the problem size. Similarly, as noted in Section 3, we can assume that the encoding lengths of all vectors x(i) returned by the oracle are in Ω(n) and, since the oracle runs in polynomial time, polynomially bounded in the instance size. Consequently, there is some bound Mf with poly- nomial encoding length such that the root of each function f(i) can be represented by a fraction pi qi with pi, qi ∈ N and qi 6 Mf. Now consider the root − a0−b0 of some function g of the form g(λ) := (a0 − b0) + λ · (a1 − b1) a1−b1 that stems from a comparison of two linear parametric values of the forms a0 + λ · a1 and b0 + λ · b1. Assume that we are in the k-th step of the simulation. Since the oracle algorithm is strongly combina- torial, the values a0 + λ · a1 and b0 + λ · b1 result from one or more of the input values dj := aj − λ · cj (which are the only linear parametric values at the beginning of the simulation) as well as a sequence of up to k additions or subtractions with other linear parametric values and multiplications with con- stants. Hence, since k ∈ O(TA) and A runs in (strongly) polynomial time, there is a bound Mg with polynomial encoding length such that the root − a0−b0 of each such function g considered up to the a1−b1 k-th step of the simulation can be represented by a fraction of the form p q with p, q ∈ N and q 6 Mg. Now let µ1 = p1 q1 and µ2 = p2 q2 with µ1 6= µ2 denote the roots of two of the above functions of the 18 form f(i) or g. Since q1, q2 6 Mf · Mg, we get that µ1 − µ2 =(cid:12)(cid:12)(cid:12)(cid:12) p1 q1 − p2 q2(cid:12)(cid:12)(cid:12)(cid:12) =(cid:12)(cid:12)(cid:12)(cid:12) p1 · q2 − p2 · q1 q1 · q2 1 f · M2 g M2 =: µ (cid:12)(cid:12)(cid:12)(cid:12) > Hence, choosing δ := µ 2 , we are able to differentiate between the three cases D(λ) < 0, D(λ) = 0, and D(λ) > 0. Moreover, by returning any4 vector in S in the case of D(λ) > 0 and returning the certificate in every other case, the separation oracle is extended into a sign oracle and the correctness follows from the proof of Lemma 11. Note that the running time remains to be O(cid:0)N + T 2 a sign oracle in Lemma 11) since the encoding length of the number δ is polynomially bounded and since the oracle algorithm is assumed to run in strongly polynomial time. A(cid:1) (as in the case of Lemma 13 now yields one of the main results of this paper: Theorem 14: Given a strongly combinatorial and strongly polynomial-time sign oracle A for S running in TA time, ε2 · m log m · (N + TA) + T 2 there is a strongly polynomial FPTAS for the problem (1) running in O(cid:0) 1 A(cid:1) time. 6 Applications In this section, we present several applications of the introduced framework. We will be able to derive new strongly polynomial-time FPTASs for several well-known network flow and packing problems and complement or even improve upon well-known results. All graphs considered in this section are assumed to be connected, such that the number of nodes n fulfills n ∈ O(m). 6.1 Budget-Constrained Maximum Flows In the budget-constrained maximum flow problem, the aim is to determine a flow with maximum value in an s-t-network that is additionally restricted by a budget-constraint of the formPe∈E be · xe 6 B for non-negative integers be ∈ N for each e ∈ E a budget B ∈ N. The problem is known to be efficiently solvable by combinatorial algorithms, both in weakly polynomial-time [1, 4, 5, 6] and in strongly polynomial-time [23]. In the following, we present a strongly polynomial-time FPTAS for the problem, which is both much more simple and efficient than the exact strongly polynomial-time algorithm. In order to apply our framework, we need to show that each feasible solution is decomposable in some kind of basic component and that we are able to handle these components appropriately. With- out loss of generality, since each budget-constrained maximum flow x is also a traditional s-t-flow and since flows on cycles do not contribute to the flow value, it holds that x can be decomposed j=1 x(j). Hence, if x(l) denotes the flow into m ′ 6 m flows x(j) on s-t-paths Pj such that x = Pm ′ 4Actually, since we do not have direct access to the set S, we need to obtain such a vector via an oracle access. However, by calling the oracle once more with a very large value for λ or by returning some vector found before, we obtain a certificate in S, which we can return. 19 with unit flow value on some path Pl in the set of s-t-paths {P1, . . . , Pk}, it holds that each (budget- constrained) maximum flow x is contained in the cone C that is generated by the vectors in the set S := {x(l) : l ∈ {1, . . . , k}}. Consequently, we can formulate the budget-constrained maximum flow problem as follows: max Xe∈E s.t. Xe∈E ce · xe be · xe 6 B, xe 6 ue x ∈ C, for each e ∈ E, (8a) (8b) (8c) (8d) where ce = 1 if e ∈ δ−(t), and ce = 0, else. Note that the flow conservation constraints are now modeled by the containment in the cone C, such that a packing problem over a polyhedral cone remains, i.e., a problem of the form (1). In the above formulation, it holds that cT x(l) = c := 1 for each x(l) ∈ S since each s-t-path con- tributes equally to the value of the flow. Hence, we can apply Theorem 5 if we can show that there is a minimizing oracle for S, i.e., that we can determine a vector x(l) minimizing dT x(l) for a given cost vector d. This simply reduces to the determination of a shortest s-t-path with respect to the edge lengths d. Note that, since the vector a is always positive in each component according to Ob- servation 1 and since c = 1, we need to search for a shortest path with non-negative edge lengths in SP(m, n) ∈ O(m + n log n) time according to the proof of Theorem 5. Thus, we get that there is an FP- TAS for the budget-constrained maximum flow problem running in O(cid:0) 1 since the number N of non-zero entries in the constraint matrix in (8) is bounded by 2m ∈ O(SP(m, n)). Note that this running time is still obtained even if we add (a constant number of) different budget- constraints. ε2 · m log m · SP(m, n)(cid:1) time We want to stress that our framework allows to stick to the commonly used edge-based formulation of the problem, in which there is a linear number of variables defining the flow on single edges. In contrast, one is required to use the path-based formulation of the problem when using the orig- inal framework of Garg and Koenemann [17]: The flow conservation constraints, which define the "shape" of a feasible flow, cannot be directly used in a formulation as a packing problem. These constraints, however, are now modeled by the containment in the cone C. Moreover, note that the only ingredients that we used are that (1) each flow decomposes into flows on some type of basic components (s-t-paths) and (2) that we are able to handle these basic components efficiently, which allowed us to apply the framework. 6.2 Budget-Constrained Minimum Cost Flows In the budget-constrained minimum cost flow problem, the aim is to determine a minimum cost flow subject to a budget constraint of the form Pe∈E be · xe 6 B, similarly to the budget-constrained maximum flow problem that was studied above. The problem is known to be efficiently solvable 20 in weakly and strongly polynomial-time [22, 23]. In [22], a strongly polynomial-time FPTAS was presented for the budget-constrained minimum cost flow problem, which runs in O(cid:18) 1 ε2 · m log m · (nm log m log log m + n3 log n + nm log2 n log log n)(cid:19) time and which uses similar ideas as the ones presented above. In the following, we improve upon this result. When considering the (equivalent) circulation based version of the problem in which there are no demands and flow conservation holds at each node, it is easy to see that each optimal flow can be decomposed into flows on simple cycles. Hence, we can restrict our considerations to flows that are contained in the cone C that is spanned by flows on simple cycles with unit flow value. The result of Theorem 5 cannot be applied to this problem for two reasons: On the one hand, since we are dealing with arbitrary costs, it clearly does no longer hold that cT x(l) is constant among all flows on cycles with unit flow value. On the other hand, any minimizing oracle would be required to return a vector x(l) that minimizes dT x(l) for a given cost vector d, so it would be necessary to find a most negative cycle C∗ in the underlying graph. However, this problem is known to be NP-complete in general since finding a most negative simple cycle in a graph with edge costs de = −1 for each e ∈ E is equivalent to deciding if the graph contains a Hamiltonian cycle (cf. Garey and Johnson [16]). Nevertheless, we are able to determine a cycle C with the same sign as the most negative cycle C∗ efficiently by computing a minimum mean cycle in O(nm) time (cf. [26]). Hence, we can apply both Theorem 9 and Theorem 12 to the budget-constrained minimum cost flow problem in order to obtain a weakly polynomial-time FPTAS running in O(cid:18)nm ·(cid:18) 1 ε2 · m log m + log log M − log 1 ε − log m − log log m(cid:19)(cid:19) time and, since the minimum mean cycle algorithm of Karp [26] is both strongly polynomial and strongly combinatorial, a strongly polynomial-time FPTAS with a time bound of O(cid:18) 1 ε2 · m log m · nm + (nm)2(cid:19) = O(cid:18)nm ·(cid:18) 1 ε2 · m log m + nm(cid:19)(cid:19) . The latter running time can be improved by making use of the following observation: As it was shown in Lemma 11, the sign oracle is incorporated into Megiddo's parametric search in order to determine a minimizer of aT x(l) cT x(l) min l∈{1,...,k} cT x(l)>0 (6) for a positive cost vector a and a vector c. In the case of the budget-constrained minimum cost flow problem, this reduces to the determination of a minimum ratio cycle C. Megiddo [30] derived an algo- rithm that determines a minimum ratio cycle in a simple graph in O(n3 log n + nm log2 n log log n) time by making use of a parallel algorithm for the all-pairs shortest path problem in combination with Karp's minimum mean cycle algorithm [26] as a negative cycle detector in his parametric search. This running time was later improved by Cole [10] to O(n3 log n + nm log2 n). Hence, the strongly 21 polynomial FPTAS can be improved to run in O(cid:18) 1 ε2 · m log m · nm + n3 log n + nm log2 n(cid:19) = O(cid:18) 1 ε2 · nm2 log n(cid:19) time on simple graphs. In the case of multigraphs, one can use a technique introduced in [22] in order to transform the graph into an equivalent simple graph in O(nm log m log log m) time before applying Cole's minimum ratio cycle algorithm, yielding an FPTAS running in O(cid:18) 1 ε2 · m log m · nm + nm log m log log m + n3 log n + nm log2 n(cid:19) = O(cid:18) 1 ε2 · nm2 log m(cid:19) time. Hence, in both cases, the strongly polynomial-time FPTAS dominates the FPTASs introduced above. The claimed running time holds even if we add up to O(n) different budget constraints to the problem. 6.3 Budget-Constrained Minimum Cost Generalized Flows The generalized minimum cost flow problem is an extension of the minimum cost flow problem, in which each edge e ∈ E is denoted with an additional gain factor γe. The flow that enters some edge e is mul- tiplied by γe as soon as it leaves the edge (cf. [36]). In the budget-constrained minimum cost generalized flow problem, the flow is additionally restricted by a budget-constraint of the formPe∈E be · xe 6 B as above. The traditional minimum cost generalized flow problem (without an additional budget constraint) is known to be solvable by combinatorial algorithms in weakly polynomial-time [37]. Moreover, there is ever, this algorithm makes use of the inherent structure of traditional generalized flows and cannot be extended to the budget-constrained case without further ado. Earlier, Oldham [31] presented an FP- TAS for the related generalized minimum cost maximum flow problem with non-negative edge costs ε · n2m2(cid:1) time presented by Wayne [37]. How- a strongly polynomial-time FPTAS running ineO(cid:0)log 1 with a weakly polynomial running time of eO(cid:0) 1 problem running5 in eO(cid:0) 1 ε2 · nm2 · (log 1 ε2 · log 1 ε · n2m2 · log mCU(cid:1), which, as well, cannot ε + log log M)(cid:1) time was presented by Fleischer and Wayne be easily extended to the budget-constrained case. Another weakly polynomial-time FPTAS for this [13], which is also based on the procedure of Garg and Koenemann [17] and which can be extended to the budget-constrained version of the problem. Using our framework, we present two much sim- pler FPTASs that work for the generalized minimum cost flow with arbitrary edge costs and that complement the above ones by achieving better time complexities in specific cases. Again, we consider the circulation based version of the problem in which the excess is zero at each node v ∈ V. As it was shown in [37], every such generalized circulation x can be decomposed into at most m flows on unit-gain cycles and bicycles, i.e., flows on cycles C withQe∈C γe = 1 and flows on pairs of cycles (C1, C2) with Qe∈C1 γe > 1 that are connected by a path, respectively. Hence, every generalized circulation lies in the cone C that is generated by flows on γe < 1 and Qe∈C2 5M denotes the largest absolute value of each number given in the problem instance, assuming gain factor are given as ratios of integers. 22 such unit-gain cycles and bicycles: max Xe∈E s.t. Xe∈E ce · xe be · xe 6 B, xe 6 ue x ∈ C. for each e ∈ E, (9a) (9b) (9c) (9d) Note that this formulation does not differ from the models in the previous applications. Instead, the "structural complexity" of the problem that comes with the introduction of gain factors is modeled by the containment in the cone C. We are done if we are able to find a separation oracle for the set that generates this cone. Wayne [37] shows that there is a unit-gain cycle or bicycle with negative costs in a given network if and only if a specialized system with two variables per inequality (2VPI) is infeasible. Among others, Cohen and Megiddo [9] present a procedure that checks the feasibility of such a system and, in case that it is infeasible, provides a "certificate of infeasibility", which cor- responds to a negative cost unit-gain cycle/bicycle [37]. This procedure runs ineO(n) time on O(nm) processors. Hence, when used as a separation oracle, we are able to apply Theorem 9. This yields an FPTAS running in eO(cid:18)n2m ·(cid:18) 1 ε2 · m + log log M ′ − log 1 ε(cid:19)(cid:19) time, where M ′ is an upper bound on the absolute costs ce, fees be, and capacities ue of the edges e ∈ E -- independent of the numbers involved to represent the gain factors. Moreover, since the separation oracle is both strongly polynomial and strongly combinatorial [37], we can apply Theorem 12 in order to obtain a strongly polynomial-time FPTAS. Using parallelization techniques that are common when using Megiddo's parametric search [30], the time that is necessary to find an initial most violated dual constraint using Lemma 13 can be improved fromeO((nm)2) toeO(n · (nm + nm log(nm) + log(nm) · (n2m))) =eO(n3m). This yields an FPTAS with a strongly polynomial running time in eO(cid:18) 1 ε2 · m · n2m + n3m(cid:19) =eO(cid:18) 1 ε2 · n2m2(cid:19) . This algorithm embodies the first strongly polynomial-time FPTAS for the budget-constrained gener- alized minimum cost flow problem and improves upon the running time of the weakly polynomial- time FPTAS. Moreover, this FPTAS outperforms both the algorithm of Oldham [31] and, for large values of M or small values of ε, the algorithm of Fleischer and Wayne [13]. 6.4 Maximum Flows in Generalized Processing Networks Generalized processing networks extend traditional networks by a second kind of capacities, so called dynamic capacities, that depend on the flow itself. More precisely, the flow on each edge e = (v, w) ∈ E 23 is additionally constrained to be at most αe ·Pe ′∈δ+(v) xe ′ for some edge-dependent constant αe ∈ (0, 1], i.e., the flow on e may only make up a specific fraction αe of the total flow leaving the starting node v of e. This extension allows to model manufacturing and distillation processes, in particular (cf. [24]). Similar to s-t-paths, the "basic component" in the field of generalized processing networks is the notion of so-called basic flow distribution schemes. For each node v ∈ V with δ+(v) 6= ∅, such a basic flow distribution scheme β is a function that assigns a value in [0, αe] to each edge e ∈ δ+(v) such Intuitively, a basic flow distribution scheme describes how flow can be distributed to the outgoing edges at each node without violating any dynamic capacity constraint. that Pe∈δ+(v) βe = 1 and at most one edge e ∈ δ+(v) fulfills βe ∈ (0, αe). In [24], the authors show that each flow in a generalized processing network can be decomposed into at most 2m flows on basic flow distribution schemes. Hence, we can conclude that each maxi- mum flow in a generalized processing network is contained in the cone C that is generated by unit-flows on basic flow distribution schemes. Moreover, for the problem on acyclic graphs and for a given cost vector d, we can determine a basic flow distribution scheme β that allows a unit-flow x with minimum costs d(x) := Pe∈E de · xe in linear time O(m) (cf. [24]). By using Theorem 5, we get an FPTAS for the maximum flow problem in generalized processing networks with a strongly polyno- mial running-time of O( 1 ε2 · m2 log m). This result is in particular interesting since it is unknown whether an exact solution can be determined in strongly polynomial time since the problem is at least as hard to solve as any linear fractional packing problem (cf. [24] for further details). 6.5 Minimum Cost Flows in Generalized Processing Networks Similar to the previous problem, each minimum cost flow in a generalized processing network is contained in the cone that is generated by flows with unit flow value on basic flow distribution schemes. On acyclic graphs, we have the same minimizing oracle as described above. Since the costs ce are now arbitrary, we can no longer apply Theorem 5. Nevertheless, since each minimizing oracle induces a sign oracle, we are able to apply Theorem 12, which yields an FPTAS for the problem running in strongly polynomial-time O(cid:18) 1 ε2 · m log m · m + m2(cid:19) = O(cid:18) 1 ε2 · m2 log m(cid:19) . This matches the time complexity of the maximum flow variant of the problem described in Sec- tion 6.4. 6.6 Maximum Concurrent Flow Problem The maximum concurrent flow problem is a variant of the maximum multicommodity flow problem, in which a demand dj is given for each commodity j with source-sink-pair (sj, tj) ∈ V × V. The task is to determine the maximum value of λ such that a fraction λ of all demands is satisfied without violating any edge capacity. While several FPTASs emerged for this problem, the best time bound at 24 present is given byeO(cid:0) 1 of commodities. ε2 · (m2 + kn)(cid:1) due to Karakostas [25], where k ∈ O(n2) denotes the number The problem can be approximated efficiently with our framework by using the following novel ap- proach: In order to improve the objective function value by one unit, we need to send dj units of each commodity. Hence, each concurrent flow decomposes into basic components of the following type: A set of flows on k paths, containing a flow with value dj on an (sj, tj) path for each com- modity j. For a given (positive) cost vector, a basic component with minimum costs can be found by determining a shortest path between each commodity. Since Dijkstra's (1959) algorithm computes the shortest paths from one node to every other node, we only need to apply it min{k, n} times (once for each of the distinct sources of all commodities), which yields a minimizing oracle running in O(min{k, n} · (m + n log n)) time and an FPTAS running in eO(cid:0) 1 Theorem 5. This algorithm has a worse time complexity than the one of Karakostas [25]. Neverthe- less, the application of the presented framework is much simpler than the algorithm given in [25] (and even matches its time complexity in the case of sparse graphs with a large number of commodi- ties) and inherently allows the incorporation of additional budget-constraints. ε2 · m2 · min{k, n}(cid:1) time according to 6.7 Maximum Weighted Multicommodity flow Problem The maximum weighted multicommodity flow problem is a generalization of the maximum multicom- modity flow problem, in which a positive weight cj is denoted with each commodity and the aim is to maximize the weighted flow value. The problem is known to be solvable ineO(cid:0) 1 time as shown by Fleischer [14], where C denotes the largest ratio of any two weights of commodities. ε2 · m2 min{log C, k}(cid:1) Similar to the multicommodity flow problem, each feasible flow decomposes into flows with unit flow value on single (sj, tj) paths. Moreover, the determination of such a path with minimal costs reduces to min{k, n} shortest path computations with possibly negative costs, similar to the maxi- mum concurrent flow problem considered above. Using similar ideas as in the case of the budget- constrained minimum cost flow problem (Section 6.2), this would yield an FPTAS with a running time ineO(cid:0) 1 ε2 · min{n, k} · nm + min{n, k} · n3(cid:1). This running time can be improved as follows: As above, we can consider the cone C to be spanned by flows on (sj, tj) paths for each commodity, but where each flow between any (sj, tj)-pair now has flow value 1 . Each vector in the ground set S then has uniform costs. In order to apply Theorem 5, cj we need to be able to determine a cost-minimal vector with respect to a given positive cost vector d. One straight-forward way to obtain such a minimizing oracle is to compute a shortest path for each commodity j using the edge lengths de for each e ∈ E and to choose a shortest path among all cj commodities. This would result in aeO(cid:0) 1 ε2 · m2 · k(cid:1) time FPTAS, similar to the previous application. However, it suffices to compute only min{n, k} shortest paths per iteration, which can be seen as follows: For each node s out of the set of the min{k, n} distinct source nodes, we perform two steps: We first compute the shortest path distance to every other node using Dijkstra's (1959) algorithm. Afterwards, for each node that corresponds to the sink tj of a commodity j with source sj = s, we multiply the distance from sj to tj by 1 . By repeating this procedure for each source and keeping cj track of the overall shortest path, we obtain a minimizing oracle. This yields an FPTAS running in 25 eO(cid:0) 1 ε2 · m2 · min{n, k}(cid:1) time, which complements the result of Fleischer [14]. This example shows that more sophisticated definitions of the ground set S and the cone C may improve the running time of the procedure. Finally, using this approach, we can even further improve the algorithm to obtain a time bound of flow problem: For an initially tight lower bound L on the length of a shortest path for any com- eO(cid:0) 1 ε2 · m2(cid:1) using an idea that was applied by Fleischer [14] to the (unweighted) multicommodity modity (which can be computed ineO(min{n, k} · m) time as above at the beginning), we can stick to one commodity j in each iteration of the overall procedure and compute a single shortest path from the source sj to the sink tj. Once the length of this shortest path multiplied by 1 becomes as large cj as (1 + ε) · L, we go on to the next commodity and continue the procedure. After each commodity was considered, we update L to (1 + ε) · L and continue with the first commodity. Following the shortest path computations that lead to a change of the commodity. However, since Dijkstra's (1959) algorithm computes the distance to every other node, we only need to consider min{k, n} different nodes by grouping commodities with the same source as above, which reduces the running time to ε2 · k(cid:1) ε2 · (m2 + km)(cid:1) time as there areeO(cid:0) 1 lines of Fleischer [14], this yields an FPTAS running ineO(cid:0) 1 ε2 · m2(cid:1) (see [14] for details on the algorithm). Although Fleischer [14] both considered this tech- eO(cid:0) 1 nique and introduced the maximum weighted multicommodity flow problem, she refrained from applying this procedure to the problem. 6.8 Maximum Spanning Tree Packing Problem In the maximum spanning tree packing problem, one is given an undirected graph G = (V, E) with positive edge capacities ue. Let T denote the set of all spanning trees in G. The aim is to find a solution to the problem xT max XT ∈T s.t. XT ∈T:e∈T xT > 0 xT 6 ue ∀ e ∈ E, ∀T ∈ T, i.e., one seeks to pack as many spanning trees as possible (in the fractional sense) without violating any edge capacity. While the problem was investigated in a large number of publications, the fastest (exact) algorithm for the problem is due to Gabow and Manu [15] and runs in O(cid:16)n3m log n2 Let S denote the set of incidence vectors χT of spanning trees T ∈ T, where (χT )e = 1 if e ∈ T and (χT )e = 0 else. Since each spanning tree contains exactly n − 1 edges, the problem can be stated in m(cid:17) time. 26 an equivalent edge-based fashion as follows: max 1 n − 1 xe ·Xe∈E s.t. xe 6 ue x ∈ C. ∀ e ∈ E, Our framework also applies to a weighted version of the problem: Assume that each edge is labeled with an additional cost ce (with arbitrary sign) and assume that the weight c(T ) of each spanning ε2 · m2 log m · α(m, n)(cid:1) time. In order to apply Theorem 5 (which is eligible since each spanning tree contributes equally to the objective function value), we need a minimizing oracle for the set S. However, this simply reduces to the determination of a minimum spanning tree, which can be done in O(m · α(m, n)) time, where α(m, n) denotes the inverse Ackermann function (cf. [7]). This yields a strongly polynomial-time FPTAS for the problem running in O(cid:0) 1 tree T ∈ T is defined to be the sum of the weights of its edges, i.e., c(T ) := Pe∈E ce. The aim is then to maximize the objective function PT ∈T c(T ) · xT . As above, we can stick to an equivalent n−1 ·Pe∈E ce · xe. The minimum spanning tree edge-based formulation using the objective function 1 algorithm can then be used as a sign oracle, which allows us to apply Theorem 12 to the problem. This yields an FPTAS for the maximum weighted spanning tree packing problem running in strongly polynomial time O(cid:18) 1 ε2 · m2 log m · α(m, n) + m2 · α2(m, n)(cid:19) = O(cid:18) 1 ε2 · m2 log m · α(m, n)(cid:19) . To the best of our knowledge, this is the first combinatorial approximation algorithm for this problem. 6.9 Maximum Matroid Base Packing Problem Having a closer look at the results of Section 6.8, one might expect that they can be generalized to matroids: As spanning trees form the bases of graphic matroids, the presented ideas suggest that the framework can also be applied to packing problems over general matroids. In the maximum matroid base packing problem, a matroid M(S, I) with ground set S := {1, . . . , m} and independent sets in I is given as well as a positive capacity ui ∈ N>0 for each i ∈ S. For r to be the rank function of M, let B ⊂ I denote the set of bases such that I ∈ B if and only if r(I) = r(S). The aim of the problem is to pack as many bases of M as possible (in the fractional sense) without violating any capacity 27 constraints: xI max XI∈B s.t. XI∈B:i∈I xI > 0 xI 6 ui ∀ i ∈ S, ∀I ∈ B. As it is common when dealing with matroids, we assume that the matroid is described by an inde- pendence testing oracle, which checks if some set S ′ ⊆ S is independent in M (cf. [33]). Let F(m) denote the running time of this oracle. As it is shown in [33], the problem can be solved in O(m7 · F(m)) time using a result derived by Cunningham [11]. As it was the case in the maximum spanning tree packing problem in Section 6.8, the problem can be formulated in an equivalent element-based fashion as follows: max 1 r(S) xi ·Xi∈S s.t. xi 6 ui x ∈ C, ∀ i ∈ S, where the cone C is spanned by the incidence vectors of bases in B. In order to apply our framework, we need to be able to handle these bases efficiently. However, as we are dealing with matroids, we can find a cost-minimal basis I ∈ B of M with respect to a given cost vector d just by applying the Greedy algorithm (cf. [33]): Starting with I = ∅, we sort the elements by their costs and iteratively add each el- ement in the sorted sequence unless the independence test fails. This yields a minimizing oracle for B running in O(m · F(m) + m log m) time. Hence, we immediately get an FPTAS for the maximum ma- As it was the case in Section 6.8, we can also extend our results to a weighted version of the problem: troid base packing problem running in strongly polynomial time O(cid:0) 1 ε2 · m2 log m · (F(m) + log m)(cid:1) Assume we are additionally given costs ci ∈ Z and want to maximizePI∈B c(I) · xI, where c(I) := Pi∈I ci. Equivalently, we can also maximize r(S) ·Pi∈S ci · xi in the element-based formulation of the problem. Using the above minimizing oracle as a sign oracle, we can apply both Theorem 9 and, in case that the independence testing oracle is strongly polynomial and strongly combinatorial, Theorem 12 to the problem. This yields two FPTASs for the problem running in according to Theorem 5. 1 O(cid:18)(m · F(m) + m log m) ·(cid:18) 1 ε2 · m log m + log log M − log 1 ε − log m − log log m(cid:19)(cid:19) and O(cid:18) 1 ε2 · m2 log m · (F(m) + log m) + (m · F(m) + m log m)2(cid:19) 28 time, respectively. To the best of our knowledge, no other polynomial-time algorithm is known for this problem. 7 Conclusion We investigated an extension of the fractional packing framework by Garg and Koenemann [17] that generalizes their results to fractional packing problems over polyhedral cones. By combining a large diversity of known techniques, we derived a framework that can be easily adopted to a large class of network flow and packing problems. This framework may in particular be applicable even if the cone has an exponential-sized representation as it only relies on a strongly polynomial number of oracle calls in order to gather information about the cone. In many cases, its application allows the derivation of approximation algorithms that are either the first ones with a strongly polynomial running time or the first combinatorial ones at all. For a large variety of applications, we were even able to complement or improve existing results. The presented paper raises several questions for future research. On the one hand, we believe that our results can be applied to a much larger set of problems and can be used to obtain combinatorial FPTASs for complex problems without much effort. It may also be possible that the results continue to hold for even weaker kinds of oracles. On the other hand, as our framework is based on the one of Garg and Koenemann [17] in its core, all of the derived approximation algorithms have a running time in Ω( 1 ε . It may be possible to achieve a subquadratic dependency on 1 ε by relying on other approaches such as the one of Bienstock and Iyengar [3]. Nevertheless, it seems that this trade comes with a worse dependence on other parameters, a worse practical performance, or a worse generality of the presented results. ε2 · m log m · n) and, in particular, have a quadratic dependency on 1 References [1] R. K. Ahuja and J. B. Orlin. A capacity scaling algorithm for the constrained maximum flow problem. Networks, 25(2):89 -- 98, 1995. [2] D. Bienstock. Potential function methods for approximately solving linear programming problems: the- ory and practice, volume 53. Springer Science & Business Media, 2006. [3] D. Bienstock and G. Iyengar. Approximating fractional packings and coverings in o (1/epsilon) iterations. SIAM Journal on Computing, 35(4):825 -- 854, 2006. [4] C. C¸ alıs¸kan. A double scaling algorithm for the constrained maximum flow problem. Computers & Operations Research, 35(4):1138 -- 1150, 2008. [5] C. C¸ alıs¸kan. On a capacity scaling algorithm for the constrained maximum flow problem. Net- works, 53(3):229 -- 230, 2009. [6] C. C¸ alıs¸kan. A faster polynomial algorithm for the constrained maximum flow problem. Com- puters & Operations Research, 39(11):2634 -- 2641, 2012. 29 [7] B. Chazelle. A minimum spanning tree algorithm with inverse-ackermann type complexity. Journal of the ACM (JACM), 47(6):1028 -- 1047, 2000. [8] E. Cohen and N. Megiddo. Maximizing concave functions in fixed dimension. World Scientific, 1990. [9] E. Cohen and N. Megiddo. Improved algorithms for linear inequalities with two variables per inequality. SIAM Journal on Computing, 23(6):1313 -- 1347, 1994. [10] R. Cole. Slowing down sorting networks to obtain faster sorting algorithms. Journal of the ACM (JACM), 34(1):200 -- 208, 1987. [11] W.H. Cunningham. Testing membership in matroid polyhedra. Journal of Combinatorial Theory, Series B, 36(2):161 -- 188, 1984. [12] E. W. Dijkstra. A note on two problems in connexion with graphs. Numerische Mathematik, 1(1): 269 -- 271, 1959. [13] L. K. Fleischer and K. D. Wayne. Fast and simple approximation schemes for generalized flow. Mathematical Programming, 91(2):215 -- 238, 2002. [14] L.K. Fleischer. Approximating fractional multicommodity flow independent of the number of commodities. SIAM Journal on Discrete Mathematics, 13(4):505 -- 520, 2000. [15] H.N. Gabow and K.S. Manu. Packing algorithms for arborescences (and spanning trees) in capacitated graphs. Mathematical Programming, 82(1-2):83 -- 109, 1998. [16] M. R. Garey and D. S. Johnson. Computers and Intractability -- A Guide to the Theory of NP- Completeness. W. H. Freeman and Company, New York, 1979. [17] N. Garg and J. Koenemann. Faster and simpler algorithms for multicommodity flow and other fractional packing problems. SIAM Journal on Computing, 37(2):630 -- 652, 2007. [18] M.D. Grigoriadis and L.G. Khachiyan. Fast approximation schemes for convex programs with many blocks and coupling constraints. SIAM Journal on Optimization, 4(1):86 -- 107, 1994. [19] M.D. Grigoriadis and L.G. Khachiyan. Coordination complexity of parallel price-directive de- composition. Mathematics of Operations Research, 21(2):321 -- 340, 1996. [20] M. Gr otschel, L. Lov´asz, and A. Schrijver. Geometric Algorithms and Combinatorial Optimization, volume 2 of Algorithms and Combinatorics. Springer Berlin Heidelberg, 1993. [21] R. Hassin. Approximation schemes for the restricted shortest path problem. Mathematics of Operations research, 17(1):36 -- 42, 1992. [22] M. Holzhauser, S. O. Krumke, and C. Thielen. On the complexity and approximability of budget- constrained minimum cost flows. submitted to Information Processing Letters, 2015. [23] M. Holzhauser, S. O. Krumke, and C. Thielen. Budget-constrained minimum cost flows. Journal of Combinatorial Optimization, 31(4):1720 -- 1745, 2016. 30 [24] M. Holzhauser, S. O. Krumke, and C. Thielen. Maximum flows in generalized processing net- works. Journal of Combinatorial Optimization, pages 1 -- 31, 2016. [25] G. Karakostas. Faster approximation schemes for fractional multicommodity flow problems. ACM Transactions on Algorithms (TALG), 4(1):13, 2008. [26] R. M. Karp. A characterization of the minimum cycle mean in a digraph. Discrete mathematics, 23(3):309 -- 311, 1978. [27] H. Kellerer, U. Pferschy, and D. Pisinger. Knapsack Problems. Springer, 2004. [28] E. L. Lawler. Combinatorial optimization: networks and matroids. Courier Corporation, 2001. [29] N. Megiddo. Combinatorial optimization with rational objective functions. Mathematics of Op- erations Research, 4(4):414 -- 424, 1979. [30] N. Megiddo. Applying parallel computation algorithms in the design of serial algorithms. Jour- nal of the ACM (JACM), 30(4):852 -- 865, 1983. [31] J.D. Oldham. Combinatorial approximation algorithms for generalized flow problems. Journal of Algorithms, 38(1):135 -- 169, 2001. [32] S.A. Plotkin, D.B. Shmoys, and ´E. Tardos. Fast approximation algorithms for fractional packing and covering problems. Mathematics of Operations Research, 20(2):257 -- 301, 1995. [33] A. Schrijver. Combinatorial optimization: polyhedra and efficiency, volume 24. Springer Science & Business Media, 2002. [34] S. Toledo. Maximizing non-linear concave functions in fixed dimension. In Foundations of Com- puter Science, 1992. Proceedings., 33rd Annual Symposium on, pages 676 -- 685. IEEE, 1992. [35] S. Toledo. Approximate parametric searching. Information processing letters, 47(1):1 -- 4, 1993. [36] K. D. Wayne. Generalized Maximum Flow Algorithms. PhD thesis, Cornell University, 1999. [37] K. D. Wayne. A polynomial combinatorial algorithm for generalized minimum cost flow. Math- ematics of Operations Research, 27(3):445 -- 459, 2002. [38] N.E. Young. Randomized rounding without solving the linear program. In SODA, volume 95, pages 170 -- 178, 1995. 31
1606.04157
1
1606
2016-06-13T22:21:04
Single machine scheduling with job-dependent machine deterioration
[ "cs.DS" ]
We consider the single machine scheduling problem with job-dependent machine deterioration. In the problem, we are given a single machine with an initial non-negative maintenance level, and a set of jobs each with a non-preemptive processing time and a machine deterioration. Such a machine deterioration quantifies the decrement in the machine maintenance level after processing the job. To avoid machine breakdown, one should guarantee a non-negative maintenance level at any time point; and whenever necessary, a maintenance activity must be allocated for restoring the machine maintenance level. The goal of the problem is to schedule the jobs and the maintenance activities such that the total completion time of jobs is minimized. There are two variants of maintenance activities: in the partial maintenance case each activity can be allocated to increase the machine maintenance level to any level not exceeding the maximum; in the full maintenance case every activity must be allocated to increase the machine maintenance level to the maximum. In a recent work, the problem in the full maintenance case has been proven NP-hard; several special cases of the problem in the partial maintenance case were shown solvable in polynomial time, but the complexity of the general problem is left open. In this paper we first prove that the problem in the partial maintenance case is NP-hard, thus settling the open problem; we then design a $2$-approximation algorithm.
cs.DS
cs
Single machine scheduling with job-dependent machine deterioration∗ Wenchang Luo1,2, Yao Xu2, Weitian Tong3, and Guohui Lin2 Faculty of Science, Ningbo University. Ningbo, Zhejiang 315211, China. 1 2 Department of Computing Science, University of Alberta. Edmonton, Alberta T6G 2E8, Canada. {wenchang,xu2,guohui}@ualberta.ca 3 Department of Computer Sciences, Georgia Southern University. Statesboro, Georgia 30460, USA. [email protected] 6 1 0 2 n u J 3 1 ] S D . s c [ 1 v 7 5 1 4 0 . 6 0 6 1 : v i X r a Abstract We consider the single machine scheduling problem with job-dependent machine deterioration. In the problem, we are given a single machine with an initial non-negative maintenance level, and a set of jobs each with a non-preemptive processing time and a machine deterioration. Such a machine deterioration quantifies the decrement in the machine maintenance level after processing the job. To avoid machine breakdown, one should guarantee a non-negative maintenance level at any time point; and whenever necessary, a maintenance activity must be allocated for restoring the machine maintenance level. The goal of the problem is to schedule the jobs and the mainten- ance activities such that the total completion time of jobs is minimized. There are two variants of maintenance activities: in the partial maintenance case each activity can be allocated to increase the machine maintenance level to any level not exceeding the maximum; in the full maintenance case every activity must be allocated to increase the machine maintenance level to the maximum. In a recent work, the problem in the full maintenance case has been proven NP-hard; several special cases of the problem in the partial maintenance case were shown solvable in polynomial time, but the complexity of the general problem is left open. In this paper we first prove that the problem in the partial maintenance case is NP-hard, thus settling the open problem; we then design a 2-approximation algorithm. 1998 ACM Subject Classification Dummy classification -- please refer to http://www.acm.org/ about/class/ccs98-html Keywords and phrases Scheduling, machine deterioration, maintenance, NP-hard, approxima- tion algorithm 1 Introduction In many scheduling problems, processing a job on a machine causes the machine to deteriorate to some extent, and consequently maintenance activities need to be executed in order to restore the machine capacity. Scheduling problems with maintenance activities have been extensively investigated since the work of Lee and Liman [7]. A maintenance activity is normally described by two parameters, the starting time and If these two parameters are given beforehand, a maintenance activity is the duration. referred to as fixed; otherwise it is called flexible. Various scheduling models with fixed maintenance activities, on different machine environments and job characteristics, have been comprehensively surveyed by Schmidt [13], Lee [5], and Ma et al. [9]. ∗ This work was partially supported by AITF and NSERC Canada, and China Scholarship Council. © Wenchang Luo, Yao Xu, Weitian Tong, and Guohui Lin; licensed under Creative Commons License CC-BY Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 2 Single machine scheduling with job-dependent machine deterioration A number of researchers initiated the work with flexible maintenance activities. Qi et al. [12] considered a single machine scheduling problem to simultaneously schedule jobs and maintenance activities, with the objective to minimize the total completion time of jobs. They showed that the problem is NP-hard in the strong sense and proposed heuristics and a branch-and-bound exact algorithm. (Qi [11] later analyzed the worst-case performance ratio for one of the heuristics, the shortest processing time first or SPT.) Lee and Chen [6] studied the multiple parallel machines scheduling problem where each machine must be maintained exactly once, with the objective to minimize the total weighted completion time of jobs. They proved the NP-hardness for some special cases and proposed a branch-and-bound exact algorithm based on column generation; the NP-hardness for the general problem is implied. Kubzin and Strusevich [4] considered a two-machine open shop and a two-machine flow shop scheduling problems in which each machine has to be maintained exactly once and the duration of each maintenance depends on its starting time. The objective is to minimize the maximum completion time of all jobs and all maintenance activities. Among others, the authors showed that the open shop problem is polynomial time solvable for quite general functions defining the duration of maintenance in its starting time; they also proved that the flow shop problem is binary NP-hard and presented a fully polynomial time approximation scheme (FPTAS) [4]. Returning to a single machine scheduling problem, Chen [2] studied the periodic mainten- ance activities of a constant duration not exceeding the available period, with the objective to minimize the maximum completion time of jobs (that is, the makespan). The author presen- ted two mixed integer programs and heuristics and conducted computational experiments to examine their performance. Mosheiov and Sarig [10] considered the problem where the machine needs to be maintained prior to a given deadline, with the objective to minimize the total weighted completion time of jobs. They showed the binary NP-hardness and presented a pseudo-polynomial time dynamic programming algorithm and an efficient heuristic. Luo et al. [8] investigated a similar variant (to [10]) in which the jobs are weighted and the duration of the maintenance is a nondecreasing function of the starting time (which must be prior to a given deadline). Their objective is to minimize the total weighted completion time of jobs; the authors showed the weakly NP-hardness, and for the special case of concave duration function they proposed a (1 + 2/2 + )-approximation algorithm. Yang and Yang [16] considered a position-dependent aging effect described by a power function under maintenance activities and variable maintenance duration considerations simultaneously; they examined two models with the objective to minimize the makespan, and for each of them they presented a polynomial time algorithm. √ Scheduling on two identical parallel machines with periodic maintenance activities was examined by Sun and Li [14], where the authors presented approximation algorithms with constant performance ratios for minimizing the makespan or minimizing the total completion time of jobs. Xu et al. [15] considered the case where the length of time between two consecutive maintenances is bounded; they presented an approximation algorithm for the multiple parallel machines scheduling problem to minimize the completion time of the last maintenance, and for the single machine scheduling problem to minimize the makespan, respectively. 1.1 Problem definition Considering the machine deterioration in the real world, in a recent work by Bock et al. [1], a new scheduling model subject to job-dependent machine deterioration is introduced. In this model, the single machine must have a non-negative maintenance level (ML) at any time Luo et al. version/31st May 2021 3 point, specifying its current maintenance state. (A negative maintenance level indicates the machine breakdown, which is prohibited.) We are given a set of jobs J = {Ji, i = 1, 2, . . . , n}, where each job Ji = (pi, δi) is specified by its non-preemptive processing time pi and machine deterioration δi. The machine deterioration δi quantifies the decrement in the machine maintenance level after processing the job Ji. (That is, if before processing the job Ji the maintenance level is ML, then afterwards the maintenance level reduces to ML−δi -- suggesting that ML has to be at least δi in order for the machine to process the job Ji.) Clearly, to process all the jobs, maintenance activities (MAs) need to be allocated inside a schedule to restore the maintenance level, preventing machine breakdown. Given that the machine can have a maximum maintenance level of MLmax, and assuming a unit maintenance speed, an MA of a duration D would increase the maintenance level by min{D, MLmax − ML}, where ML is the maintenance level before the MA. With an initial machine maintenance level ML0, 0 ≤ ML0 ≤ MLmax, the goal of the problem is to schedule the jobs and necessary MAs such that all jobs can be processed without machine breakdown, and that the total completion time of jobs is minimized. There are two variants of the problem depending on whether or not one has the freedom to choose the duration of an MA: in the partial maintenance case, the duration of each MA can be anywhere in between 0 and (MLmax − ML), where ML is the maintenance level before the MA; in the full maintenance case, however, the duration of every MA must be exactly (MLmax − ML), consequently increasing the maintenance level to the maximum value MLmax. Let Ci denote the completion time of the job Ji, for i = 1, 2, . . . , n. In the three i Ci) i Ci), respectively, where p MA and f MA refer to the partial and the full field notation, the two problems discussed in this paper are denoted as (1p MAP and (1f MAP maintenance, respectively. 1.2 Prior work and our contribution i Ci) is NP-hard, even when pi = p for all i or when pi = δi for all i, both by a reduction from the Partition problem [3]; while all the jobs have the same deterioration, i.e. δi = δ for all i, the problem can be solved in O(n log n) time. For the partial maintenance case, Bock et al. [1] showed that the SPT rule gives an optimal i Ci) when pi < pj implies pi + δi ≤ pj + δj for each pair of i and j (which includes the special cases where pi = p for all i, or δi = δ for all i, or pi = δi for all i). i Ci) was left as an open problem. Also, to the best of our knowledge, no approximation algorithms have been designed for either problem. Bock et al. [1] proved that (1f MAP schedule for (1p MAP The complexity of the general problem (1p MAP (1p MAP Our main contribution in this paper is to settle the NP-hardness of the general problem i Ci). Such an NP-hardness might appear a bit surprising at the first glance since one has so much freedom in choosing the starting time and the duration of each MA. Our reduction is from the Partition problem too, using a kind of job swapping argument. This reduction is presented in Section 3, following some preliminary properties we observe for the problem in Section 2. In Section 4, we propose a 2-approximation algorithm i Ci). We conclude the paper in Section 5 with some discussion on the for (1p MAP O(n) time and (1f MACmax) is NP-hard but admits an O(cid:0)n2(MLmax)2 log (Pn Lastly, we would like to point out that when the objective is to minimize the makespan Cmax, i.e. the maximum completion time of jobs, (1p MACmax) can be trivially solved in (in-)approximability. time algorithm based on dynamic programming (and thus admits an FPTAS) [1]. i=1(pi + δi))(cid:1) 4 Single machine scheduling with job-dependent machine deterioration 2 Preliminaries Given a feasible schedule π to the problem (1p MAP i Ci), which specifies the start pro- cessing time for each job and the starting time and the duration of each MA, we abuse slightly π to also denote the permutation of the job indices (1, 2, . . . , n) in which the jobs are processed in order: π = (π1, π2, . . . , πn). The following lemma is proved in [1]. (cid:73) Lemma 1. [1] There is an optimal schedule π to (1p MAP maintenance duration before processing the job Jπi equals maxn0,Pi i Ci) such that the total o, for j=1 δπj − ML0 each i = 1, 2, . . . , n. Lemma 1 essentially states that each MA should be pushed later in the schedule as much as possible until absolutely necessary, and its duration should be minimized just for processing the succeeding job. In the sequel, we limit our discussion on the feasible schedules satisfying these two properties. We define the separation job in such a schedule π as the first job that requires an MA (of a positive duration). (cid:73) Lemma 2. Suppose Jπk is the separation job in an optimal schedule π to (1p MAP i Ci). Then, the jobs before the separation job Jπk are scheduled in the SPT order; the jobs after the separation job Jπk are scheduled in the shortest sum-of-processing-time- and-deterioration first (SSF) order; the jobs adjacent to the separation job Jπk satisfy pπk−1 + min{δπk−1 , δπk − δ} ≤ pπk + (δπk − δ) ≤ pπk+1 + max{0, δπk+1 − δ}, where δ = ML0 −Pk−1 i=1 δπi is the remaining maintenance level before the first MA. Proof. Starting with an optimal schedule satisfying the properties stated in Lemma 1, one may apply a simple job swapping procedure if the job order is violated either in the prefix or in the suffix of job order separated by the separation job Jπk. This procedure would decrease the value of the objective, contradicting to the optimality. That is, we have (see Figure 1 for an illustration) pπ1 ≤ pπ2 ≤ . . . ≤ pπk−1, and pπk+1 + δπk+1 ≤ pπk+2 + δπk+2 ≤ . . . ≤ pπn + δπn. (1) (2) 1st ? π1 π2 . . . πk−1 MA πk 6 separation MA πk+1 MA πk+2 . . . MA πn - Figure 1 An illustration of the optimal schedule π stated in Lemma 2, where the separation job is Jπk; the width of a framebox does not necessarily equal the processing time of a job or the duration of an MA. i=1 δπi denote the remaining maintenance level before the first MA. Because δ < δπk, an (the first) MA of duration δπk − δ needs to be performed for processing Let δ = ML0 −Pk−1 Luo et al. version/31st May 2021 5 the separation job Jπk. From the optimality of π, swapping the two jobs Jπk and Jπk+1 should not decrease the objective, that is, pπk + (δπk − δ) ≤ pπk+1, (cid:26) pπk + (δπk − δ) ≤ pπk+1 + (δπk+1 − δ), (cid:26) pπk−1 ≤ pπk , pπk−1 + δπk−1 ≤ pπk + (δπk − δ), otherwise. if δπk+1 > δ; otherwise. if δπk−1 ≥ δπk − δ; Similarly, swapping the two jobs Jπk−1 and Jπk should not decrease the objective, that is, These together give pπk−1 + min{δπk−1 , δπk − δ} ≤ pπk + (δπk − δ) ≤ pπk+1 + max{0, δπk+1 − δ}. This proves the lemma. (3) (cid:74) From Lemma 2, one sees that the separation job in an optimal schedule is unique, in the sense that it cannot always be "appended" to either the prefix SPT order or the suffix SSF order. This is reflected in our NP-completeness reduction in Section 3, where we force a certain scenario to happen. 3 NP-hardness of the problem (1p MAP i Ci) Partition: Our reduction is from the classic NP-complete problem Partition [3], formally defined as follows: Instance: A set X of n positive integers X = {x1, x2, . . . , xn}, withPn Query: Is there a subset X1 ⊂ X such thatP Pn i=1 xi = 2B. The corresponding instance I of the problem (1p MAP We abuse X to denote the instance of Partition with the set X = {x1, x2, . . . , xn} and i Ci) is constructed x∈X1 x =P x∈X−X1 x = B? i=1 xi = 2B. in polynomial time, as follows: Number of jobs: Job processing time: pn+1+i = pi =Pi 2n + 3; Machine deterioration: Initial maintenance level: ML0 =Pn Maximum maintenance level: MLmax =Pn (note that pn+1 = p0 =P0 Objective threshold: Q = Q0 + B, i=0 δi − 2B; i=0 δi; j=1 xj, for i = 0, 1, 2, . . . , n, p2n+2 = M − 2B; δn+1+i = δi = M − 2pi, for i = 0, 1, 2, . . . , n, δ2n+2 = 0; j=1 xj = 0 due to the empty range for j) where M is a big integer: M > (4n + 8)B, (4) and Q0 is the total completion time of jobs for an initial infeasible schedule π0 (see Figure 2): nX j=0  nX j=0 + nX j=0 Q0 = (n− j +1)pj +(n+2) pj + 2B + p2n+2 (j +1)(pn+1+j + δn+1+j). (5) 6 Single machine scheduling with job-dependent machine deterioration J0 J1 J2 . . . Jn 1st MA ? 2B J2n+2 6 separation δ2n+1 J2n+1 δ2n J2n . . . δn+1 Jn+1 ? - Figure 2 The initial infeasible schedule π0 for the instance I with the separation job J2n+2; π0 satisfies all properties stated in Lemma 2. All MAs are indicated by their respective durations (for the first MA, its duration is δ2n+2 − δ = 2B). breakdown is no longer tolerated. From ML0 =Pn later. The Query of the decision version of the problem (1p MAP The job order in this initial schedule π0 is (J0, J1, . . . , Jn, J2n+2, J2n+1, J2n, . . . , Jn+1), and the first MA precedes the job J2n+2, which is regarded as the separation job (see Figure 2). Before the separation job J2n+2, the machine maintenance level is allowed to go into negative, but has to be restored to zero just for processing J2n+2; afterwards, machine i=0 δi − 2B, we know that π0 is infeasible due to machine breakdown before the first MA; we will convert it to a feasible schedule i Ci) is whether or not there exists a feasible schedule π such that the total completion time of jobs is no more than Q = Q0 + B. Despite the infeasibility, the initial schedule π0 has all the properties stated in Lemma 2, with the separation job J2n+2 at the center position. The first (n + 1) jobs are in the SPT order and the last (n + 1) jobs are in the SSF order; since δ = −2B, pn = p2n+1 = 2B, δn = δ2n+1 = M − 4B, p2n+2 = M − 2B, δ2n+2 = 0, Eq. (3) is also satisfied due to the big M in Eq. (4): pn + min{δn, δ2n+2 − δ} < p2n+2 + (δ2n+2 − δ) = p2n+1 + max{0, δ2n+1 − δ}. In the rest of the section, we will show that there is a subset X1 ⊂ X of sum exactly B if and only if the initial schedule π0 can be converted into a feasible schedule π with the total completion time of jobs no more than Q = Q0 + B, through a repeated job swapping procedure. Notice that the two jobs Ji and Jn+1+i are identical, for i = 0, 1, . . . , n. In any schedule with the job J2n+2 at the center position, if exactly one of Ji and Jn+1+i is scheduled before J2n+2, then we always say Ji is scheduled before J2n+2 while Jn+1+i is scheduled after J2n+2. Also, when the two jobs Ji and Jn+1+i are both scheduled before J2n+2, then Jn+1+i precedes Ji; when the two jobs Ji and Jn+1+i are both scheduled after J2n+2, then Ji precedes Jn+1+i. 3.1 Proof of "only if" In this subsection, we show that if there is a subset X1 ⊂ X of sum exactly B, then the initial infeasible schedule π0 can be converted into a feasible schedule π with the total completion time no more than Q = Q0 + B. We also demonstrate the repeated job swapping procedure leading to this successful schedule π. Suppose the indices of the elements in the subset X1 are {i1, i2, . . . , im}, satisfying 1 ≤ i1 < i2 < . . . < im ≤ n. Starting with the initial schedule π0, we sequentially swap the job Ji'−1 with the job Jn+1+i', for ' = 1, 2, . . . , m. Let π' denote the schedule after the '-th job swapping. (cid:73) Lemma 3. For each 1 ≤ ' ≤ m, the schedule π' with the separation job J2n+2 satisfies the properties in Lemma 2; Luo et al. version/31st May 2021 7 the '-th job swapping decreases the total machine deterioration before the separation job J2n+2 by 2xi'; the '-th job swapping increases the total completion time by xi'. Proof. Recall that the two jobs Ji' and Jn+1+i' are identical. Before the '-th job swapping between Ji'−1 and Jn+1+i' (in the schedule π'−1), the jobs in between Ji'−1 and Jn+1+i' are (Ji'−1, Ji' , Ji'+1, . . . , Jn, J2n+2, J2n+1, J2n, . . . , Jn+1+i'+1, Jn+1+i'). After the swapping (in the schedule π') this sub-schedule becomes (Jn+1+i', Ji', Ji'+1, . . . , Jn, J2n+2, J2n+1, J2n, . . . , Jn+1+i'+1, Ji'−1). By a simple induction, all jobs before Jn+1+i' have their processing times less than pi', and thus the jobs before the separation job J2n+2 are in the SPT order; for a similar reason, the jobs after the separation job J2n+2 are in the SSF order. By the '-th job swapping, the change in the total machine deterioration before the separation job J2n+2 is δi' − δi'−1 = −2(pi' − pi'−1) = −2xi', that is, decreases by 2xi'. Therefore the duration of the first MA also decreases by 2xi'. Since Jn always directly precedes J2n+2 and pn < p2n+2, the first half of Eq. (3) holds; since p2n+2 + δ2n+2 is the smallest among all jobs, the second half of Eq. (3) holds. That is, the schedule π' satisfies all properties in Lemma 2. For ease of presentation, let Ci denote the completion time of the job Ji in the schedule i denote the completion time of the job Ji in the schedule π'−1. Comparing to π', and let C0 the schedule π'−1 (' ≥ 1), after the '-th job swapping between Ji'−1 and Jn+1+i', i'−1 = pi' − pi'−1 = xi'; the completion time of jobs preceding Jn+1+i' is unchanged; Cn+1+i' − C0 the completion time of each job in between Ji' and Jn (inclusive, n − i' + 1 of them) increases by xi'; the duration of the first MA decreases by 2xi'; the completion time of each job in between J2n+2 and Jn+1+i'+1 (inclusive, n − i' + 1 of them) decreases by xi'; Ci'−1 − C0 from the last item, the completion time of jobs succeeding Ji'−1 is unchanged. = −xi' + (δi'−1 + pi'−1) − (δi' + pi') = 0; n+1+i' In summary, there are (n − i' + 2) jobs of which the completion time increases by xi' and (n − i' + 1) jobs of which the completion time decreases by xi'. Therefore, the '-th job swapping between Ji'−1 and Jn+1+i' increases the total completion time by xi'. This finishes (cid:74) the proof. (cid:73) Theorem 4. If there is a subset X1 ⊂ X of sum exactly B, then there is a feasible schedule π to the instance I with the total completion time no more than Q = Q0 + B. Proof. Let the indices of the elements in the subset X1 be {i1, i2, . . . , im}, such that 1 ≤ i1 < i2 < . . . < im ≤ n. Starting with the initial schedule π0, we sequentially swap the job Ji'−1 with the job Jn+1+i', for ' = 1, 2, . . . , m. Let π' denote the schedule after the '-th job swapping, and let Q' denote the total completion time of jobs in π'. From Lemma 3 we know that the ending schedule πm satisfies all the properties in Lemma 2. Also, the total machine deterioration before the separation job J2n+2 in πm is δi − 2 xi' = δi − 2B = ML0, i=0 '=1 nX mX nX i=0 8 Single machine scheduling with job-dependent machine deterioration suggesting that πm is a feasible schedule. (The first MA has zero duration and thus becomes unnecessary.) Moreover, the total completion time of jobs in πm is Qm = Q0 +Pm '=1 xi' = Q0 + B. Therefore, the schedule πm obtained from the initial schedule π0 through the repeated job (cid:74) swapping procedure is a desired one. 3.2 Proof of "if" In this subsection, we show that if there is a feasible schedule π to the constructed instance I with the total completion time no more than Q = Q0 + B, then there is a subset X1 ⊂ X of sum exactly B. Assume without loss of generality that the schedule π satisfies the properties in Lemma 2. We start with some structure properties which the schedule π must have. (cid:73) Lemma 5. Excluding the job J2n+2, there are at least n and at most (n + 1) jobs scheduled before the first MA in the schedule π. Proof. Recall that in Eq. (4) we set M to be a large value such that M > (4n + 8)B. Using M > (4n + 6)B, it follows from M − 4B = δn < δn−1 < . . . < δ1 < δ0 = M that the initial machine maintenance level ML0 = δi − 2B > (n + 1)(M − 4B) − 2B = nM + M − (4n + 6)B > nM. nX i=0 We thus conclude that at least n jobs, excluding J2n+2 which has 0 deterioration, can be processed before the first MA. Nevertheless, if there were more than (n+1) jobs scheduled before the first MA, excluding J2n+2, then their total machine deterioration would be greater than (n + 2)(M − 4B). Using M > (4n + 8)B, we have (n + 2)(M − 4B) = (n + 1)M + M − (4n + 8)B > (n + 1)M > δi > ML0, nX i=0 (cid:74) contradicting the feasibility of the schedule π. (cid:73) Lemma 6. There are at most (n + 1) jobs scheduled after the job J2n+2 in the schedule π. Proof. We prove the lemma by contradiction. Firstly, noting that the job J2n+2 has a much larger processing time compared to any other job (M − 2B versus 2B), we conclude that the earliest possible position for J2n+2 in the schedule π is right before the first MA. We disallow a zero-duration MA and thus the job J2n+2 can never be the separation job in π due to δ2n+2 = 0. If J2n+2 is scheduled after the separation job, by Eq. (2) or the SSF rule, for every job Ji scheduled after J2n+2 we have p2n+2 ≤ pi + δi. If J2n+2 is scheduled right before the first MA, by Eq. (3), for the separation job Ji we have p2n+2 ≤ pi + (δi − δ); by Eqs. (2) and (3), for every other job Ji scheduled after J2n+2 we have p2n+2 ≤ pi + δi. Therefore, the completion time of a job scheduled ' positions after the job J2n+2 is at least (' + 1) × p2n+2. If there were (n + 2) jobs scheduled after J2n+2, then the total completion time of the last (n + 3) jobs would be at least n+2X '=0 (' + 1)p2n+2 = (n + 3)(n + 4) 2 p2n+2 = (n + 3)(n + 4) 2 (M − 2B). Luo et al. version/31st May 2021 9 However, using pj ≤ 2B for j 6= 2n + 2, one sees that Eq. (5) can be simplified as Q0 = (n − j + 1)pj + (n + 2) pj + 2B + (M − 2B) (j + 1)(M − pj)  + nX j=0 j=0 nX = (n + 2)(n + 3) ≤ (n + 2)(n + 3) = (n + 2)(n + 3) 2 2 2  nX nX nX j=0 j=0 M + 2 (n − j + 1)pj M + 4B (n − j + 1) j=0 M + 2(n + 1)(n + 2)B. Using M > (3n + 6)B, (n + 3)(n + 4) 2 (M − 2B) ≥ Q0 + (n + 3)M − (3n2 + 13n + 16)B > Q0 + (2n + 2)B, that is, we would have the total completion time of the last (n + 3) jobs in π strictly greater (cid:74) than Q = Q0 + B, contradicting to our assumption. Combining Lemmas 5 and 6, we have the following lemma regarding the position of J2n+2 in the schedule π. (cid:73) Lemma 7. In the schedule π, the position of the job J2n+2 has three possibilities: Case 1: There are (n+1) jobs before the first MA, πn+2 = 2n+2, and Jπn+3 is the separation Case 2: There are (n + 1) jobs before the first MA, Jπn+2 is the separation job, and πn+3 = job. 2n + 2. Case 3: There are n jobs before the first MA, Jπn+1 is the separation job, and πn+2 = 2n+2. Proof. Note that the processing time of the job J2n+2 is strictly greater than that of any other job, while the sum of its processing time and machine deterioration (p2n+2 + δ2n+2) achieves the minimum. Because J2n+2 cannot act as the separation job due to δ2n+2 = 0, by Lemma 2 it can only be either the last job scheduled before the first MA or the first job scheduled after the separation job (through a possible job swapping, if necessary). Using Lemmas 5 and 6, it is easy to distinguish the three possible cases stated in the lemma. (cid:74) Recall that the job order in the initial infeasible schedule π0 is (J0, J1, . . . , Jn, J2n+2, J2n+1, J2n, . . . , Jn+2, Jn+1), and the first MA is executed before processing the job J2n+2, which is regarded as the separation job (see Figure 2). In the sequel, we will again convert π0 into our target schedule π through a repeated job swapping procedure. During such a procedure, the job J2n+2 is kept at the center position, and a job swapping always involves a job before J2n+2 and a job after J2n+2. In Cases 1 and 3 of the schedule π, the job J2n+2 is at the center position (recall that there are in total 2n + 3 jobs), and therefore the target schedule is well set. In Case 2, J2n+2 is at position n + 3, not the center position; we first exchange J2n+2 and Jπn+2 to obtain a schedule π0, which becomes our target schedule. That is, we will first convert π0 into π0 through a repeated job swapping procedure, and at the end exchange J2n+2 back to the position n + 3 to obtain the final schedule π. In summary, our primary goal is to convert the schedule π0 through a repeated job swapping procedure, keeping the job J2n+2 at the center position and keeping the first MA right before the job J2n+2 (to be detailed next). At the end, to obtain the target schedule π, in Case 1, we swap the job J2n+2 and the first 10 Single machine scheduling with job-dependent machine deterioration MA (i.e., moving the first MA one position backward); in Case 2, we swap J2n+2 and the immediate succeeding MA and the following job (with the MA merged with the first MA); in Case 3, we swap the first MA and its immediate preceding job (i.e., moving the first MA one position forward). In the target schedule (π in Cases 1 and 3, or π0 in Case 2), let R = {r1, r2, . . . , rm} denote the subset of indices such that both Jrj and Jn+1+rj are among the first (n + 1) jobs, where 0 ≤ r1 < r2 < . . . < rm ≤ n, and L = {'1, '2, . . . , 'm} denote the subset of indices such that both J'j and Jn+1+'j are among the last (n+1) jobs, where 0 ≤ '1 < '2 < . . . < 'm ≤ n. Note that J2n+2 is at the center position in the target schedule, and thus it has to be R = L and we let m = R. Clearly, all these 'j's and rj's are distinct from each other. In the repeated job swapping procedure leading the initial infeasible schedule π0 to the target feasible schedule, the j-th job swapping is to swap the two jobs J'j and Jn+1+rj. The resultant schedule after the j-th job swapping is denoted as πj, for j = 1, 2, . . . , m. In Section 3.1, the job swapping is "regular" in the sense that 'j = rj − 1 for all j, but now 'j and rj do not necessarily relate to each other. We remark that immediately after the swapping, a job sorting is needed to restore the SPT order for the prefix and the SSF order for the suffix (see the last paragraph before Section 3.1 for possible re-indexing the jobs). The following Lemma 8 on the j-th job swapping, when 'j < rj, is an extension of Lemma 3. (cid:73) Lemma 8. For each 1 ≤ j ≤ m, if the schedule πj−1 satisfies the first two properties in Lemma 2 and 'j < rj, then the schedule πj satisfies the first two properties in Lemma 2; the j-th job swapping decreases the total machine deterioration before the center job J2n+2 by δ'j − δrj = 2Prj the j-th job swapping increases the total completion time by at leastPrj increment equalsPrj k='j+1 xk if and only if 'j > rj−1. k='j+1 xk; and the k='j+1 xk; k='j+1 xk. Proof. Note that 0 ≤ r1 < r2 < . . . < rm ≤ n, 0 ≤ '1 < '2 < . . . < 'm ≤ n, and all these 'j's and rj's are distinct from each other. Since 'j < rj, we assume without loss of generality that rj0−1 < 'j < rj0 for some j0 ≤ j, that is, the (j − j0) jobs Jn+1+rj0 , Jn+1+rj0+1 , . . . , Jn+1+rj−1 have been moved to be in between J'j and the center job J2n+2 in the schedule πj−1. The j-th job swapping between the two jobs J'j and Jn+1+rj clearly decreases the total machine deterioration before the center job J2n+2 by δ'j − δrj = 2Prj To estimate the total completion time, we decompose the j-th job swapping between the two jobs J'j and Jn+1+rj as a sequence of (rj − 'j) "regular" job swappings, between the two jobs Jk and Jn+1+k+1 for k = rj − 1, rj − 2, . . . , 'j + 1, 'j. We remark that the order of these regular job swappings is important, which guarantees that at the time of such a swapping, the job Jk is before the center job J2n+2 and the job Jn+1+k+1 is after the center job J2n+2 (see the last paragraph before Section 3.1 for possible re-indexing the jobs). For each such regular job swapping between the two jobs Jk and Jn+1+k+1, we can apply (almost, see below) Lemma 3 to conclude that it increases the total completion time by at least xk+1. From the proof of Lemma 3, the increment in the total completion time equals xk+1 if and only if there are exactly (n − k + 1) jobs in between Jn+1+k+1 and Jn (inclusive), that is, the (j − j0) jobs Jn+1+rj0 , Jn+1+rj0+1 , . . . , Jn+1+rj−1 should not be moved in between Jk and the center job J2n+2 in the schedule πj−1. Therefore, the j-th job swapping increases k='j+1 xk if (cid:74) k='j+1 xk; and the increment equalsPrj the total completion time by at leastPrj and only if 'j > rj−1 (i.e., j0 = j). This proves the lemma. Luo et al. version/31st May 2021 11 (cid:73) Lemma 9. For each 1 ≤ j ≤ m, if the schedule πj−1 satisfies the first two properties in Lemma 2 and 'j > rj, then the schedule πj satisfies the first two properties in Lemma 2; the j-th job swapping increases the total machine deterioration before the center job J2n+2 by δrj − δ'j = 2P'j the j-th job swapping increases the total completion time by at leastP'j k=rj+1 xk; k=rj+1 xk. Proof. We prove first an analog to Lemma 3 on a regular job swapping between the two jobs Ji'+1 and Jn+1+i', which can be viewed as an inverse operation of the regular job swapping between the two jobs Ji' and Jn+1+i'+1. For ease of presentation, let Ci denote the completion time of the job Ji in the schedule after the regular job swapping, and let C0 i denote the completion time of the job Ji in the schedule before the regular job swapping. Comparing to the schedule before the swapping, i'+1 = pi' − pi'+1 = −xi'+1; the completion time of jobs preceding Jn+1+i' is unchanged; Cn+1+i' − C0 the completion time of each job in between Ji'+2 and Jn (inclusive, n − i' − 1 of them) decreases by xi'+1; the duration of the first MA increases by 2xi'+1; the completion time of each job in between J2n+2 and Jn+1+i'+1 (inclusive, n − i' + 1 of them) increases by xi'+1; Ci'+1 − C0 consequently, the completion time of jobs succeeding Ji'+1 is unchanged. = xi'+1 + (δi'+1 + pi'+1) − (δi' + pi') = 0; n+1+i' The total completion time of jobs in the schedule after this regular job swapping increases by at least xi'+1. Note that the increment equals xi'+1 if and only if there are exactly (n− i' +1) jobs in between J2n+2 and Jn+1+i'+1 (inclusive), that is, the (j − 1) jobs J'1 , J'2, . . . , J'j−1 should not be moved in between the center job J2n+2 and Jn+1+i' in the schedule πj−1. Using the above analog of Lemma 3, the rest of the proof of the lemma is similar to the proof of Lemma 8 by decomposing the j-th job swapping between the two jobs J'j and Jn+1+rj as a sequence of ('j − rj) "regular" job swappings, between the two jobs Jk+1 and Jn+1+k for k = 'j − 1, 'j − 2, . . . , rj + 1, rj. (cid:74) (cid:73) Theorem 10. If there is a feasible schedule π to the instance I with the total completion time no more than Q = Q0 + B, then there is a subset X1 ⊂ X of sum exactly B. Proof. We start with a feasible schedule π, which has the first two properties stated in Lemma 2 and for which the total completion time is no more than Q = Q0 + B. Excluding the job J2n+2, using the first n + 1 jobs and the last n + 1 job in π, we determine the two subsets of indices R = {r1, r2, . . . , rm} and L = {'1, '2, . . . , 'm}, and define the corresponding m job swappings. We then repeatedly apply the job swapping to convert the initial infeasible schedule π0 into π. In Case 1, the total machine deterioration of the first (n + 1) jobs in π is rjX xk + 2 X 'jX 'j <rj k='j+1 'j >rj k=rj+1 xk = ML0 −δ, xk = B + 1 2 δ, (6) nX δi − 2 X implying thatX rjX i=0 xk − X 'jX 'j <rj k='j+1 'j >rj k=rj+1 12 Single machine scheduling with job-dependent machine deterioration 'jX 2 δ + 2 X j=1{x'j+1, x'j+2, . . . , xrj}, P k=rj+1 'j >rj xk. where δ ≥ 0 is the remaining machine maintenance level before the first MA. On the other hand, the total completion time of jobs in the schedule π is at least Q0 + X rjX xk + X 'jX 'j <rj k='j+1 'j >rj k=rj+1 xk = Q0 + B + 1 It follows that 1) δ = 0; 2) there is no pair of swapping jobs J'j and Jn+1+rj such that 'j > rj; and 3) '1 < r1 < '2 < r2 < . . . < 'm < rm (from the third item of Lemma 8). Therefore, from Eq. (6), for the subset X1 = ∪m x∈X1 x = B. That is, the instance X of the Partition problem is a yes-instance. In Case 2, after all the m job swappings, the first MA immediately precedes J2n+2 and has its duration −δ since δ2n+2 = 0, where δ ≥ 0 is the remaining machine maintenance level before the first MA. J2n+2 and its immediate succeeding MA and the following job need to be swapped to obtain the schedule π; the thus moved MA is merged to the first MA, resulting in a positive duration. The total machine deterioration of the first (n + 1) jobs in π (before the first MA) is nX δi − 2 X rjX xk + 2 X 'jX i=0 k=rj+1 implying that Eq. (6) still holds in this case. k='j+1 'j >rj 'j <rj xk = ML0 −δ, 2 δ+2 X 'jX 'j >rj k=rj+1 xk. On the other hand, the total completion time of jobs in the schedule π is at least Q0+X rjX xk+X 'jX 'j <rj k='j+1 'j >rj k=rj+1 xk+(δπn+2+pπn+2−p2n+2) ≥ Q0+B+1 j=1{x'j+1, x'j+2, . . . , xrj},P The similarly as in Case 1, it follows that 1) δ = 0; 2) there is no pair of swapping jobs J'j and Jn+1+rj such that 'j > rj; and 3) '1 < r1 < '2 < r2 < . . . < 'm < rm. Therefore, from Eq. (6), for the subset X1 = ∪m x∈X1 x = B. That is, the instance X of the Partition problem is a yes-instance. In Case 3, after all the m job swappings, the first MA immediately precedes J2n+2 and has its duration −δ since δ2n+2 = 0, where δ ≤ 0 is the remaining machine maintenance level before the first MA. Therefore, Jπn+1 and the first MA need to be swapped to obtain the schedule π. The total machine deterioration of the first (n + 1) jobs in π (before the first MA) is nX i=0 δi − 2 X rjX xk + 2 X 'jX 'j <rj k='j+1 'j >rj k=rj+1 xk = ML0 −δ, implying that Eq. (6) still holds in this case, except that here δ ≤ 0. On the other hand, the total completion time of jobs in the schedule π is at least Q0 + X rjX xk + X 'jX 'j <rj k='j+1 'j >rj k=rj+1 xk + (−δ) ≥ Q0 + B − 1 2 δ + 2 X 'jX j=1{x'j+1, x'j+2, . . . , xrj}, P 'j >rj k=rj+1 xk. The similarly as in Case 1, except that here δ ≤ 0, it follows that 1) δ = 0; 2) there is no pair of swapping jobs J'j and Jn+1+rj such that 'j > rj; and 3) '1 < r1 < '2 < r2 < . . . < 'm < rm. Therefore, from Eq. (6), for the subset X1 = ∪m x∈X1 x = B. (cid:74) That is, the instance X of the Partition problem is a yes-instance. The following theorem follows immediately from Theorems 4 and 10. (cid:73) Theorem 11. The general problem (1p MAP j Cj) is NP-hard. 13 Luo et al. version/31st May 2021 A 2-approximation algorithm for (1p MAP 4 Recall that in the problem (1p MAP j Cj) j Cj), we are given a set of jobs J = {Ji, i = 1, 2, . . . , n}, where each job Ji = (pi, δi) is specified by its non-preemptive processing time pi and machine deterioration δi. The machine deterioration δi quantifies the decrement in the machine maintenance level after processing the job Ji. The machine has an initial machine maintenance level ML0, 0 ≤ ML0 ≤ MLmax, where MLmax is the maximum maintenance level. The goal is to schedule the jobs and necessary MAs of any duration such that all jobs can be processed without machine breakdown, and that the total completion time of jobs is minimized. In this section, we present a 2-approximation algorithm, denoted as A1, for the problem. Furthermore, the algorithm A1 produces a feasible schedule π satisfying the first two properties stated in Lemma 2, suggesting that if the third property is violated then a local job swapping can further decrease the total completion time. In the algorithm A1, the first step is to sort the jobs in SSF order (and thus we assume without loss of generality that) p1 + δ1 ≤ p2 + δ2 ≤ . . . ≤ pn + δn. In the second Pk−1 step, the separation job is determined to be Jk, where k is the maximum index such that i=1 δi ≤ ML0. In the last step, the jobs preceding the separation job Jk are re-sorted in the SPT order, denoted by (Ji1 , Ji2, . . . , Jik−1), and the jobs succeeding the separation job are (Jk+1, Jk+2, . . . , Jn). That is, the solution schedule is π = (Ji1 , Ji2 , . . . , Jik−1; MA1, Jk; MA2, Jk+1, MA3, Jk+2, . . . , MAn−k+1, Jn), j=1 δj − ML0 and MAi = δk−1+i for i = 2, 3, . . . , n − k + 1. Let π∗ denote an optimal schedule satisfying all properties stated in Lemma 2, and its where MA1 =Pk separation job is Jπ∗ k∗ : π∗ = (Jπ∗ 1 , Jπ∗ 2 , . . . , Jπ∗ k∗−1; MA∗ 1, Jπ∗ k∗ ; MA∗ 2, Jπ∗ k∗+1 , MA∗ 3, Jπ∗ k∗+2, . . . , MA∗ n−k∗+1, Jπ∗ n ). Let Ci (C∗ schedule π (π∗, respectively); the makespans of π and π∗ are Cmax and C∗ i , respectively) denote the completion time of the job Jπi (Jπ∗ , respectively) in the max, respectively, i and (recall that ML0 <Pn nX Cmax = C∗ max = i=1 i=1 δi) (pi + δi) − ML0 . (7) j j ). j=i j=i (pπ∗ + δπ∗ (cid:73) Lemma 12. For every i ≥ k we have nX (pj + δj) ≥ nX Proof. Since p1 + δ1 ≤ p2 + δ2 ≤ . . . ≤ pn + δn, Pn problem (1p MAP j=i(pj + δj) is the maximum sum of processing times and machine deterioration, over all possible subsets of (n − i + 1) jobs. The (cid:74) lemma thus holds. (cid:73) Theorem 13. The algorithm A1 is an O(n log n)-time 2-approximation algorithm for the j Cj). Proof. We compare the two schedules π obtained by the algorithm A1 and π∗ an optimal schedule satisfying the properties stated in Lemma 2. Using Eq. (7) and Lemma 12, it is clear that Ci ≤ C∗ i for each i = n, n − 1, . . . , max{k, k∗}. 14 Single machine scheduling with job-dependent machine deterioration Suppose k < k∗, then for each i such that k ≤ i < k∗, we have (pj + δj) (pπ∗ j + δπ∗ j ) + δπ∗ j ) − ML0 ML0 − iX −  δπ∗ j j=1 = C∗ i . j=i+1 j=i+1 = (pπ∗ ≤ C∗ Ci = Cn − nX n − nX iX iX iX Ci ≤ nX nX pπ∗ j=1 pπ∗ j j=1 j=1 ≤ = j j i ≤ OPT. C∗ k−1X i=1 k−1X nX Ci + Ci ≤ 2 · OPT. Therefore, we have Ci ≤ C∗ i for each i = n, n − 1, . . . , k. It follows that i=k i=k On the other hand, by the SPT order, the algorithm A1 achieves the minimum total completion time of jobs of {J1, J2, . . . , Jk−1}. One clearly sees that in the optimal schedule π∗, the sub-total completion time of {J1, J2, . . . , Jk−1} is upper-bounded by OPT. Therefore, (8) Ci ≤ OPT. (9) Merging Eqs. (8) and (9), we conclude that the total completion time of schedule π is i=1 i=k This proves the performance ratio of 2 (which can also be shown tight on a trivial 2-job instance I = {J1 = (1, λ), J2 = (λ − 1, 1), ML0 = MLmax = λ}, with a sufficiently large λ). The running time of the algorithm A1 is dominated by two times of sorting, each taking (cid:74) O(n log n) time. Concluding remarks 5 We investigated the single machine scheduling with job-dependent machine deterioration, recently introduced by Bock et al. [1], with the objective to minimize the total completion time of jobs. In the partial maintenance case, we proved the NP-hardness for the general problem, thus addressing the open problem left in the previous work. From the approximation perspective, we designed a 2-approximation, for which the ratio 2 is tight on a trivial two-job instance. The 2-approximation algorithm is simple, but it is the first such work. Our major contribution is the non-trivial NP-hardness proof, which might appear surprising at the first glance since one has so much freedom in choosing the starting time and the duration of the Luo et al. version/31st May 2021 15 maintenance activities. It would be interesting to further study the (in-)approximability for the problem. It would also be interesting to study the problem in the full maintenance case, which was shown NP-hard, from the approximation algorithm perspective. Approximating the problem in the full maintenance case seems more challenging, where we need to deal with multiple bin-packing sub-problems, while the inter-relationship among them is much complex. Acknowledgments W.L. was supported by the China Scholarship Council (Grant No. 201408330402). Y.X. and G.L. were supported by NSERC. W.T. was supported in part by funds from the Office of the Vice President for Research & Economic Development and Georgia Southern University. 1 References S. Bock, D. Briskorn, and A. Horbach. Scheduling flexible maintenance activities subject to job-dependent machine deterioration. Journal of Scheduling, 15:565 -- 578, 2012. J.-S. Chen. Scheduling of non-resumable jobs and flexible maintenance activities on a single machine to minimize makespan. European Journal of Operation Research, 190:90 -- 102, 2008. 3 M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory of 2 NP-completeness. W. H. Freeman and Company, San Francisco, 1979. 4 M. A. Kubzin and V. A. Strusevich. Planning machine maintenance in two-machine shop scheduling. Operations Research, 54:789 -- 800, 2006. 5 C.-Y. Lee. Machine scheduling with availability constraints. In J. Y.-T. Leung, editor, Handbook of Scheduling: Algorithms, Models and Performance Analysis, pages 22: 1 -- 13. 2004. 6 C.-Y. Lee and Z.-L. Chen. Scheduling jobs and maintenance activities on parallel machines. Naval Research Logistics, 47:145 -- 165, 2000. 7 C.-Y. Lee and S. Liman. Single machine flow-time scheduling with scheduled maintenance. Acta Informatica, 29:375 -- 382, 1992. 8 W. Luo, L. Chen, and G. Zhang. Approximation algorithms for scheduling with a variable machine maintenance. In Proceedings of Algorithmic Aspects in Information and Manage- ment (AAIM 2010), LNCS 6124, pages 209 -- 219, 2010. 9 Y. Ma, C. Chu, and C. Zuo. A survey of scheduling with deterministic machine availability constraints. Computers & Industrial Engineering, 58:199 -- 211, 2010. 10 G. Mosheiov and A. Sarig. Scheduling a maintenance activity to minimize total weighted completion-time. Computers & Mathematics with Applications, 57:619 -- 623, 2009. 11 X. Qi. A note on worst-case performance of heuristics for maintenance scheduling problems. Discrete Applied Mathematics, 155:416 -- 422, 2007. 12 X. Qi, T. Chen, and F. Tu. Scheduling the maintenance on a single machine. Journal of the Operational Research Society, 50:1071 -- 1078, 1999. 13 G. Schmidt. Scheduling with limited machine availability. European Journal of Operational Research, 121:1 -- 15, 2000. 14 K. Sun and H. Li. Scheduling problems with multiple maintenance activities and non- preemptive jobs on two identical parallel machines. International Journal of Production Economics, 124:151 -- 158, 2010. 15 D. Xu, Y. Yin, and H. Li. Scheduling jobs under increasing linear machine maintenance time. Journal of Scheduling, 13:443 -- 449, 2010. S. Yang and D. Yang. Minimizing the makespan on single-machine scheduling with aging effect and variable maintenance activities. Omega, 38:528 -- 533, 2010. 16
1608.06666
2
1608
2016-09-30T19:44:30
Synergistic Sorting, MultiSelection and Deferred Data Structures on MultiSets
[ "cs.DS" ]
Karp et al. (1988) described Deferred Data Structures for Multisets as "lazy" data structures which partially sort data to support online rank and select queries, with the minimum amount of work in the worst case over instances of size $n$ and number of queries $q$ fixed (i.e., the query size). Barbay et al. (2016) refined this approach to take advantage of the gaps between the positions hit by the queries (i.e., the structure in the queries). We develop new techniques in order to further refine this approach and to take advantage all at once of the structure (i.e., the multiplicities of the elements), the local order (i.e., the number and sizes of runs) and the global order (i.e., the number and positions of existing pivots) in the input; and of the structure and order in the sequence of queries. Our main result is a synergistic deferred data structure which performs much better on large classes of instances, while performing always asymptotically as good as previous solutions. As intermediate results, we describe two new synergistic sorting algorithms, which take advantage of the structure and order (local and global) in the input, improving upon previous results which take advantage only of the structure (Munro and Spira 1979) or of the local order (Takaoka 1997) in the input; and one new multiselection algorithm which takes advantage of not only the order and structure in the input, but also of the structure in the queries. We described two compressed data structures to represent a multiset taking advantage of both the local order and structure, while supporting the operators rank and select on the multiset.
cs.DS
cs
Synergistic Sorting, MultiSelection and Deferred Data Structures on MultiSets J´er´emy Barbay1, Carlos Ochoa1, and Srinivasa Rao Satti2 1 Departamento de Ciencias de la Computaci´on, Universidad de Chile, Chile 2 Department of Computer Science and Engineering, Seoul National University, South Korea [email protected], [email protected] [email protected] Abstract. Karp et al. (1988) described Deferred Data Structures for Multisets as "lazy" data struc- tures which partially sort data to support online rank and select queries, with the minimum amount of work in the worst case over instances of size n and number of queries q fixed (i.e., the query size). Barbay et al. (2016) refined this approach to take advantage of the gaps between the positions hit by the queries (i.e., the structure in the queries). We develop new techniques in order to further refine this approach and to take advantage all at once of the structure (i.e., the multiplicities of the elements), the local order (i.e., the number and sizes of runs) and the global order (i.e., the number and positions of existing pivots) in the input; and of the structure and order in the sequence of queries. Our main result is a synergistic deferred data structure which performs much better on large classes of instances, while performing always asymptotically as good as previous solutions. As intermediate results, we de- scribe two new synergistic sorting algorithms, which take advantage of the structure and order (local and global) in the input, improving upon previous results which take advantage only of the structure (Munro and Spira 1979) or of the local order (Takaoka 1997) in the input; and one new multiselection algorithm which takes advantage of not only the order and structure in the input, but also of the structure in the queries. We described two compressed data structures to represent a multiset taking advantage of both the local order and structure, while supporting the operators rank and select on the multiset. Keywords: Deferred Data Structure, Divide and Conquer, Fine Grained Analysis, Quick Select, Quick Sort, Compressed Data Structure, Rank, Select. Introduction the entropy function H(m1, . . . , mσ) = (cid:80)σ and m1, . . . , mσ are the multiplicities of the σ distinct elements in M (such that(cid:80)σ 1 Consider a multiset M of size n (e.g., M = {1, 2, 3, 3, 4, 5, 6, 7, 8, 9} of size n = 10). The multiplicity of an element x of M is the number mx of occurrences of x in M (e.g., m3 = 2). We call the distribution of the multiplicities of the elements in M the input structure , and denote it by a set of pairs (x, mx) (e.g., {(1, 1), (2, 1), (3, 2), (4, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1)} in M). As early as 1976, Munro and Spira [25] described a variant of the algorithm MergeSort using counters, which optimally takes advantage of the input structure (i.e., the multiplicities of the distinct elements) when sorting a multiset M of n elements. Munro and Spira measure the "difficulty" of the instance in terms of the "input structure" by . The time complexity of the algorithm is within O(n(1 + H(m1, . . . , mσ))) ⊆ O(n(1+ log σ)) ⊆ O(n log n), where σ is the number of distinct elements in M i=1 mi = n), respectively. Any array A representing a multiset lists its element in some order, which we call the input order and denote by a tuple (e.g., A = (2, 3, 1, 3, 7, 8, 9, 4, 5, 6)). Maximal sorted subblocks in A are a local form of input order and are called runs [21] (e.g., {(2, 3), (1, 3, 7, 8, 9), (4, 5, 6)} in A). As early as 1973, Knuth [21] described a variant of the algorithm MergeSort using a prepossessing step taking linear time to detect runs in the array A , which he named Natural MergeSort. Mannila [22] refined the analysis of the Natural MergeSort algorithm to yield a time complexity for sorting an array A of size n in time within O(n(1+log ρ)) ⊆ O(n lg n), where ρ is the number of runs in the A. Takaoka [28] described a new sorting algorithm that optimally takes mi n log n mi i=1 are the sizes of the ρ runs in A (such that (cid:80)ρ 2advantage of the distribution of the sizes of the runs in the array A, which yields a time complexity within O(n(1 + H(r1, . . . , rρ))) ⊆ O(n(1+ log ρ)) ⊆ O(n log n), where ρ is the number of runs in A and r1, . . . , rρ i=1 ri = n), respectively. It is worth noting that in 1997, Takaoka [27] first described this algorithm in a technical report. Given an element x of a multiset M and an integer j ∈ [1..n] (e.g., M = {1, 2, 3, 3, 4, 5, 6, 7, 8, 9}, x = 3 and j = 4) , the rank rank(x) of x is the number of elements smaller than x in M, (e.g., rank(3) = 2) and selecting the j-th element in M corresponds to computing the value select(j) of the j-th smallest element (counted with multiplicity) in M (e.g., select(4) = 3). As early as 1961, Hoare [17] showed how to support rank and select queries in average linear time, a result later improved to worst case linear time by Blum et al. [6]. Twenty years later, Dobkin and Munro [10] described a MultiSelection algorithm that supports several select queries in parallel and whose running time is optimal in the worst case over all multisets of size n and all sets of q queries hitting positions in the multisets separated by gaps (differences between consecutive select queries in sorted order) of sizes g0, . . . , gq. Kaligosi et al. [19] later described a variant of this algorithm which number of comparisons performed is within a negligible additional term of the optimal. In the online context where the queries arrive one at a time, Karp et al. [20] further extended Dobkin and Munro's result [10]. Karp et al. called their solution a Deferred Data Structure and describe it as "lazy", as it partially sorts data, performing the minimum amount of work necessary in the worst case over all instances for a fixed n and q. Barbay et al. [2] refined this result by taking advantage of the gaps between the positions hit by the queries (i.e., the query structure). This suggests the following questions: 1. Is there a sorting algorithm for multisets which takes the best advantage of both its input order and its input structure in a synergistic way, so that it performs as good as previously known solutions on all instances, and much better on instances where it can take advantage of both at the same time? 2. Is there a multiselection algorithm and a deferred data structure for answering rank and select queries which takes the best advantage not only of both of those notions of easiness in the input, but additionally also of notions of easiness in the queries, such as the query structure and the query order ? We answer both questions affirmatively: In the context of Sorting, this improves upon both algorithms from Munro and Spira [25] and Takaoka [28]. In the context of MultiSelection and Deferred Data Structure for rank and select on Multisets, this improves upon Barbay et al.'s results [2] by adding 3 new measures of difficulty (input order, input structure and query order) to the single one previously considered (query structure). Even though the techniques used by our algorithms are known, the techniques used to refine the analysis of these algorithms to show that they improve the state of the art are complex. Additionally, we correct the analysis of the Sorted Set Union algorithm by Demaine et al. [9] (Section 2.3), and we define a simple yet new notion of "global" input order (Section 2.5), formed by the number of preexisting pivot positions in the input (e.g. (3, 2, 1, 6, 5, 4) has one pre-existing pivot position in the middle), not mentioned in previous surveys [11, 23] nor extensions [3]. We present our results incrementally, each building on the previous one, such that the most complete and complex result is in Section 4. In Section 2 we describe how to measure the interaction of the order (local and global) with the structure in the input, and two new synergistic Sorting algorithms based on distinct paradigms (i.e., merging vs splitting) which take advantage of both the input order and structure in order to sort the multiset in less time than traditional solutions based on one of those, at most. We refine the second of those results in Section 3 with the analysis of a MultiSelection algorithm which takes advantage of not only the order and structure in the input, but also of the query structure, in the offline setting. In Section 4 we analyze an online Deferred Data Structure taking advantage of the order and structure in the input on one hand, and of the order and structure in the queries on the other hand, in a synergistic way. As an additional result, we describe in Section 5 two compressed data structures to represent a multiset taking advantage of both the input order and structure, while supporting the operators rank and select on the multiset. We conclude with a discussion of our results in Section 6. 2 Sorting Algorithms 3 We review in Section 2.1 the algorithms MergeSort with Counters described by Munro and Spira [25] and Minimal MergeSort described by Takaoka [28], each takes advantage of distinct features in the input. In Section 2.2 we show that the algorithm MergeSort with Counters is incomparable with the algorithm Minimal MergeSort, in the sense that none performs always better than the other (by describing families of instances where MergeSort with Counters performs better than Minimal MergeSort on one hand, and families of instances where the second one performs better than the first one on the other hand), and some simple modifications and combinations of these algorithms, which still do not take full advantage of both the order (local and global) and structure in the input. In Sections 2.3 and 2.4, we describe two synergistic Sorting algorithms, which never perform worse than the algorithms presented in Section 2.1 and Section 2.2, and perform much better on some large classes of instances by taking advantage of both the order (local and global) and the structure in the input, in a synergistic way. 2.1 Previously Known Input-structure and Local Input-order Algorithms The algorithm MergeSort with Counters described by Munro and Spira [25] is an adaptation of the tradi- tional sorting algorithm MergeSort that optimally takes advantage of the structure in the input when sorting a multiset M of size n. The algorithm divides M into two equal size parts, sorts both parts recursively, and then merges the two sorted lists. When two elements of same value v are found, one is thrown away and a counter holding the number of occurrences of v is updated. Munro and Spira measure the "difficulty" of the . The time complexity of the algorithm is within O(n(1 + H(m1, . . . , mσ))) ⊆ O(n(1+ log σ)) ⊆ O(n log n), where σ is the number of distinct elements in M and m1, . . . , mσ are the multiplicities of the σ distinct elements instance in terms of the "input structure" by the entropy function H(m1, . . . , mσ) =(cid:80)σ in M (such that(cid:80)σ mi n log n mi i=1 i=1 mi = n), respectively. The algorithm Minimal MergeSort described by Takaoka [28] optimally takes advantage of the local order in the input, as measured by the decomposition into runs when sorting an array A of size n. The main idea is to detect the runs first and then merge them pairwise, using a MergeSort-like step. The runs are detected in linear time by a scanning process identifying the positions i in A such that A[i] > A[i + 1]. Merging the two shortest runs at each step further reduces the number of comparisons, making the running time of the merging process adaptive to the entropy of the sequence of the sizes of the runs. The merging process is then represented by a tree with the shape of a Huffman [18] tree, built from the distribution of the sizes of the i=1 ri = n), then the algorithm sorts A in time within O(n(1 + H(r1, . . . , rρ))) ⊆ O(n(1+ log ρ)) ⊆ O(n log n). runs. If the array A is formed by ρ runs and r1, . . . , rρ are the sizes of the ρ runs (such that(cid:80)ρ 2.2 Comparison Between Sorting Algorithms Example 1: (cid:104)1, 2, 1, 2, . . . , 1, 2(cid:105) On this family of instances, the algorithm Minimal MergeSort detects n 2 runs that merges two at a time. The time complexity of Minimal MergeSort is within Θ(n log n). On the other hand, the algorithm MergeSort with Counters recognizes the multiplicity of the elements with values 1 and 2. In every merging step, the resulting set is always {1, 2}. Therefore, the number of elements is reduced by half at each step, which yields a complexity linear in the size of the instance for sorting such instances. Example 2: (cid:104)1, 2, . . . , n(cid:105) On this family of instances, the algorithm Minimal MergeSort detects in time linear in the size n of the input that the sequence is already sorted, and in turn it finishes. On the other hand, the running time of the algorithm MergeSort with Counters is within Θ(n log n) because this algorithm would perform at least as many operations as MergeSort. 4 The algorithm Parallel Minimal Counter MergeSort runs both algorithms in parallel, when one of these algorithms manages to sort the sequence, the algorithm Parallel Minimal Counter MergeSort re- turns the sorted sequence and then finishes. The time complexity of this algorithm in any instance is twice the minimum of the complexities of Minimal MergeSort and MergeSort with Counters for this instance. The algorithm Parallel Minimal Counter MergeSort needs to duplicate the input in order to run both algorithms in parallel. Combining the ideas of identifying and merging runs from Takaoka [28] with the use of counters by Munro and Spira [25], we describe the Small vs Small Sort algorithm to sort a multiset. It identifies the runs using the same linear scanning as Minimal MergeSort and associates counters to the elements in the same way that MergeSort with Counters does. Once the runs are identified, this algorithm initializes a heap with them ordered by sizes. At each merging step the two shorter runs are selected for merging and both are removed from the heap. The pair is merged and the resulting run is inserted into the heap. The process is repeated until only one run is left and the sorted sequence is known. The Small vs Small Sort algorithm is adaptive to the sizes of the resulting runs in the merging process. The time complexity of Small vs Small Sort for all instances is within a constant factor of the time complexity of Parallel Minimal Counter MergeSort; but the next example shows that there are families of instances where Small vs Small Sort performs better than a constant factor of the time complexity of Parallel Minimal Counter MergeSort. Example 3: (cid:104)1, 2, . . . , σ, 1, 2, . . . , σ . . . , 1, 2, . . . , σ(cid:105) In this family of instances, there are ρ runs, each of size σ. The complexity of MergeSort with Counters for this instance is within Θ(ρσ log σ), while the complexity of Minimal MergeSort for this instance is within Θ(ρσ log ρ). On the other hand, the complexity Small vs Small Sort for this instance is better, within Θ(ρσ): at each level of the binary tree representing the merging order, the sum of the sizes of the runs is halved. Even though Small vs Small Sort is adaptive to the sizes of the resulting runs, it does not take ad- vantage of the fact that there may exist a pair of runs that can be merged very quickly, but it needs linear time in the sum of the sizes to merge one of them when paired with another run of the same size. We show this disadvantage in the Example 4 at the end of the next section. In the following sections we describe two sorting algorithms that take the best advantage of both the order (local and global) and structure in the input all at once when sorting a multiset. The first one is a straightforward application of previous results, while the second one prepares the ground for the MultiSe- lection algorithm (Section 3) and the Deferred Data Structures (Section 4), which take advantage of the order (local and global) and structure in the data and of the order and structure in the queries. 2.3 "Kind-of-new" Sorting Algorithm DLM Sort In 2000, Demaine et al. [9] described the algorithm DLM Union, an instance optimal algorithm that computes the union of ρ sorted sets. It inserts the smallest element of each set in a heap. At each step, it deletes from the heap all the elements whose values are equal to the minimum value of the heap. If more than one element is deleted, it knows the multiplicity of this value in the union of the sets. It then adds to the heap the elements following the elements of minimum value of each set that contained the minimum value. If there is only one minimum element, it extracts from the heap the second minimum and executes a doubling search [5] in the set where the minimum belongs for the value of the second minimum. Once it finds the insertion rank r of the second minimum (i.e., number of elements smaller than the second minimum in the set that contains the minimum), it also knows that the multiplicity of all elements whose positions are before r in the set that contain the minimum are 1 in the union of the ρ sets. The process is repeated until all elements are discarded. The time complexity of the DLM Union algorithm is measured in terms of the number and sizes of blocks of consecutive elements in the sets that are also consecutive in the sorted union (see Figure 1 for a graphical representation of such a decomposition on a particular instance of the Sorted Set Union problem). The 5 sizes of these blocks are referred to as gaps in the analysis of the algorithm. These blocks induce a partition π of the output into intervals such that any singleton corresponds to a value that has multiplicity greater than 1 in the input, and each other interval corresponds to a block as defined above. Each member i of π has a value mi associated with it: if the member i of π is a block, then mi is 1, otherwise, if the member i of π is a singleton corresponding to a value of multiplicity q, then mi is q. Let χ be the size of π. If the instance is formed by δ blocks of sizes g1, . . . , gδ such that these blocks induce a partition π whose members have values m1, . . . , mχ, we express the time complexity of DLM Union as within Θ((cid:80)δ i=1 log gi +(cid:80)χ i=1 log(cid:0) ρ (cid:1)). This time complexity is within a constant factor of the complexity of any other algorithm computing the union of these sorted sets (i.e., the algorithm is instance optimal). mi Fig. 1: An instance of the Sorted Set Union problem with ρ = 3 sorted sets. In each set, the entry A[i] is represented by a point of x- coordinate A[i]. The blocks that form the sets are noted. The blocks g4, g5 and g6 are of size 1 because they correspond to elements of equal value and they induce the 4-th member of the partition π with value m4 equals 3. The vertical bars separate the members of π. We adapt the DLM Union algorithm for sorting a multiset. The algorithm DLM Sort detects the runs first through a linear scan and then applies the algorithm DLM Union. After that, transforming the output of the union algorithm to yield the sorted multiset takes only linear time. The following corollary follows from our refined analysis above: Corollary 1. Given a multiset M of size n formed by ρ runs and δ blocks of sizes g1, . . . , gδ such that these blocks induce a partition π of size χ of the output whose members have values m1, . . . , mχ, the algorithm DLM (cid:1)) data comparisons. This number of comparisons is Sort performs within O(n +(cid:80)δ i=1 log gi +(cid:80)χ i=1 log(cid:0) ρ optimal in the worst case over multisets of size n formed by ρ runs and δ blocks of sizes g1, . . . , gδ such that these blocks induce a partition π of size χ of the output whose members have values m1, . . . , mχ. mi There are families of instances where the algorithm DLM Sort behaves significantly better than the algorithm Small vs Small Sort. Consider for instance the following example: (cid:69) Example 4: ρ n, . . . , 1, . . . , 1 ρ n (cid:68) ρ−1 ρ n + 1, . . . , n, ρ−2 ρ n + 1, . . . , ρ−1 (cid:17) (cid:16) In this family of instances, there are ρ runs of size n ρ each. The runs are pairwise disjoint and the elements of each run are consecutive in the sorted set. The time complexity of the algorithm Small vs Small Sort in this instances is within Θ(n log ρ), while the time complexity of the algorithm DLM Sort is within Θ n + ρ log ρ + ρ log n ρ = Θ(n + ρ log n) (which is better than Θ(n log ρ) for ρ ∈ o(n)). While the algorithm DLM Sort answers the Question 1 from Section 1, it does not yield a MultiSe- lection algorithm nor a Deferred Data Structure answering Question 2. In the following section we describe another sorting algorithm that also optimally takes advantage of the local order and structure in the input, but which is based on a distinct paradigm, more suitable to such extensions. 2.4 New Sorting Algorithm Quick Synergy Sort Given a multiset M, the algorithm Quick Synergy Sort identifies the runs in linear time through a scanning process. As indicated by its name, the algorithm is directly inspired by the QuickSort [16] algorithm. It computes a pivot µ, which is the median of the set formed by the middle elements of each run, and partitions each run by the value of µ. This partitioning process takes advantage of the fact that the elements in each run are already sorted. It then recurses on the elements smaller than µ and on the elements greater than µ. (See Algorithm 1 for a more formal description). g1g3g2g4g5g6g7g8ρ 6Definition 1 (Median of the middles). Given a multiset M formed by runs, the " median of the middles" is the median element of the set formed by the middle elements of each run. 1: Compute the ρ runs of respective sizes (ri)i∈[1..ρ] in M such that(cid:80)ρ Algorithm 1 Quick Synergy Sort Input: A multiset M of size n Output: A sorted sequence of M 2: Compute the median µ of the middles of the runs, note j ∈ [1..ρ] the run containing µ; 3: Perform doubling searches for the value µ in all runs except the j-th, starting at both ends of the runs in parallel; i=1 ri = n; 4: Find the maximum max(cid:96) (minimum minr) among the elements smaller (resp., greater) than µ in all runs except the j-th; 5: Perform doubling searches for the values max(cid:96) and minr in the j-th run, starting at the position of µ; 6: Recurse on the elements smaller than o equal to max(cid:96) and on the elements greater than or equal to minr. The number of data comparisons performed by the algorithm Quick Synergy Sort is asymptotically the same as the number of data comparisons performed by the algorithm DLM Sort described in the previous section. We divide the proof into two lemmas. We first bound the overall number of data comparisons performed by all the doubling searches of the algorithm Quick Synergy Sort. Lemma 1. Let g1, . . . , gk be the sizes of the k blocks that form the r-th run. The overall number of data comparisons performed by the doubling searches of the algorithm Quick Synergy Sort to find the values of the medians of the middles in the r-th run is within O((cid:80)k i=1 log gi). Proof. Every time the algorithm finds the insertion rank of one of the medians of the middles in the r-th run, it partitions the run by a position separating two blocks. The doubling search steps can be represented as a tree (see Figure 2 for a tree representation of a particular instance). Each node of the tree corresponds to a step. Each internal node has two children, which correspond to the two subproblems into which the step partitions the run. The cost of the step is less than four times the logarithm of the size of the child subproblem with smaller size, because of the two doubling searches in parallel. The leaves of the tree correspond to the blocks themselves. We prove that at each step, the total cost is bounded by eight times the sum of the logarithms of the sizes of the leaf subproblems. This is done by induction over the number of steps. If the number of steps is zero then there is no cost. For the inductive step, if the number of steps increases by one, then a new doubling search step is done and a leaf subproblem is partitioned into two new subproblems. At this step, a leaf of the tree is transformed into an internal node and two new leaves are created. Let a and b such that a ≤ b be the sizes of the new leaves created. The cost of this step is less than 4 log a. The cost of all the steps then increases by 4 lg a, and hence the sum of the logarithms of the sizes of the leaves increases by 8(lg a + lg b) − 8 lg(a + b). But if a ≥ 4 and b ≥ a, then 2 lg(a + b) ≤ lg a + 2 lg b. The result follows. (cid:117)(cid:116) Fig. 2: The tree that represents the doubling search steps for a run composed of four blocks of respective sizes 2, 4, 2, 8. The size of the subprob- lem is noted in each node. At each subproblem, the cost of the step is the logarithm of the size of the subproblem of the solid child. The step that computes the median µ of the middles of ρ runs and the step that finds the maximum max(cid:96) (minimum minr) among the elements smaller (resp., greater) than µ of ρ runs performs linear in ρ data 88162642 mi i=1 log(cid:0) ρ these steps is within O((cid:80)χ Consider the instance depicted in Figure 3 for an example illustrating where the term log(cid:0) ρ of value v is within O(log(cid:0) ρ 7 comparisons. As shown in the following lemma, the overall number of data comparisons performed during (see Section 2.3 for the definition of π) and ρ is the number of runs in M. from. In this instance, there is a value v that has multiplicity mv > 1 in M and the rest of the values have multiplicity 1. The elements with value v are present at the end of the last mv runs and the rest of the runs are formed by only one block. The elements of the i-th run are greater than the elements of the (i+1)-th run. During the computation of the medians of the middles, the number of data comparisons that involve elements (cid:1)), where m1, . . . , mχ are the values of the member of the partition π (cid:1) comes (cid:1)). The algorithm computes the median µ of the middles and partitions the (cid:1)), where runs by the value of µ. In the recursive call that involves elements of value v, the number of runs is reduced by half. This is repeated until one occurrence of µ belongs to one of the last mv runs. The number of data comparisons that involve elements of value v up to this step is within O(mv log ρ mv log ρ mv call will necessarily choose one element of value v as the median of the middles. corresponds to the number of steps where µ does not belong to the last mv runs. The next recursive Fig. 3: A multiset M formed by ρ runs. Each en- try M[i] is represented by a point of x-coordinate M[i]. There is an element of multiplicity mv present in the last mv runs and the rest of the runs are formed by only one block. ) = O(log(cid:0) ρ mv mv mv Lemma 2. Let M be a multiset formed by ρ runs and δ blocks such that these blocks induce a partition π of the output of size χ whose members have values m1, . . . , mχ. Consider the steps that compute the medians of the middles and the steps that find the elements max(cid:96) and minr in the algorithm Quick Synergy Sort, the overall number of data comparisons performed during these steps is within O((cid:80)χ i=1 log(cid:0) ρ (cid:1)). mi Proof. We prove this lemma by induction over the size of π and ρ. The number of data comparisons performed by one of these steps is linear in the number of runs in the sub-instance (i.e., ignoring all the empty sets of this sub-instance). Let T (π, ρ) be the overall number of data comparisons performed during the steps that compute the medians of the middles and during the steps that find the elements max(cid:96) and minr in the − ρ. Let µ be the first median of the middles computed by the algorithm. Let (cid:96) and r be the number of runs that are completely to the left and to the right of µ, respectively. Let b be the number of runs that are split in the doubling searches for the value µ in all runs. Let π(cid:96) and πr be the partitions induced by the blocks yielded to the left and to the right of µ, respectively. Then, T (π, ρ) = T (π(cid:96), (cid:96) + b) + T (πr, r + b) + ρ because of the two recursive calls and the − (cid:96) − b and T (δr, r + b) ≤ , algorithm Quick Synergy Sort. We prove that T (π, ρ) ≤(cid:80)χ step that computes µ. By Induction Hypothesis, T (π(cid:96), (cid:96) + b) ≤(cid:80)χ(cid:96) (cid:80)χr − r − b. Hence, we need to prove that (cid:96) + r ≤(cid:80)χ(cid:96) but this is a consequence of(cid:80)χ(cid:96) log(cid:0)1 + y (cid:17) i=1 mi ≥ r + b (the number of blocks is greater than or equal 2 runs are left to the left and to the right of µ); and (cid:117)(cid:116) to the number of runs); (cid:96) ≤ r + b, r ≤ (cid:96) + b (at least ρ i=1 mi ≥ (cid:96) + b,(cid:80)χr (cid:1)x ≥ y for y ≤ x. +(cid:80)χr i=1 mi log r+b mi i=1 mi log (cid:96)+b mi i=1 mi log ρ mi i=1 mi log 1 + (cid:96) r+b 1 + r (cid:96)+b (cid:16) x (cid:17) (cid:16) i=1 mi Consider the step that performs doubling searches for the values max(cid:96) and minr in the run that contains the median µ of the middles, this step results in the finding of the block g that contains µ in at most 4 log g data comparisons, where g is the size of g. Combining Lemma 1 and Lemma 2 yields an upper bound on the number of data comparisons performed by the algorithm Quick Synergy Sort: Theorem 1. Let M be a multiset of size n formed by ρ runs and δ blocks of sizes g1, . . . , gδ such that these blocks induce a partition π of the output of size χ whose members have values m1, . . . , mχ. The algorithm Quick Synergy Sort performs within O(n +(cid:80)δ (cid:1)) data comparisons on M. This i=1 log gi +(cid:80)χ i=1 log(cid:0) ρ number of comparisons is optimal in the worst case over multisets of size n formed by ρ runs and δ blocks of sizes g1, . . . , gδ such that these blocks induce a partition π of size χ of the output whose members have values m1, . . . , mχ. mi mvρ 8 We extend these results to take advantage of the global order of the multiset in a way that can be combined with the notion of runs (local order). 2.5 Taking Advantage of Global Order Given a multiset M, a pivot position is a position p in M such that all elements in previous position are smaller than or equal to all elements at p or in the following positions. Formally: Definition 2 (Pivot positions). Given a multiset M = (x1, . . . , xn) of size n, the pivot positions are the positions p such that xa ≤ xb for all a, b such that a ∈ [1..p − 1] and b ∈ [p..n]. Existing pivot positions in the input order of M divide the input into subsequences of consecutive elements such that the range of positions of the elements at each subsequence coincide with the range of positions of the same elements in the sorted sequence of M: the more there are of such positions, the more "global" order there is in the input. Detecting such positions takes only a linear number of comparisons. Lemma 3. Given a multiset M of size n with φ pivot positions p1, . . . , pφ, the φ pivot positions can be detected within a linear number of comparisons. Proof. The bubble-up step of the algorithm BubbleSort [21] sequentially compares the elements in positions i − 1 and i of M, for i from 2 to n. If M[i − 1] > M[i], then the elements interchange their values. As consequence of this step the elements with large values tend to move to the right. In an execution of a bubble-up step in M, the elements that do not interchange their values are those elements whose values are greater than or equal to all the elements on their left. The bubble-down step is similar to the bubble-up step, but it scans the sequence from right to left, interchanging the elements in positions i − 1 and i if M[i − 1] > M[i]. In an execution of a bubble-down step in M, the elements that do not interchange their values are those elements whose values are smaller than or equal to all the elements on their right. Hence, the positions of the elements that do not interchange their values during the executions of both bubble-up and bubble-down steps are the pivot positions in M. (cid:117)(cid:116) n0, . . . , nφ (such that(cid:80)φ When there are φ such positions, they simply divide the input of size n into φ + 1 sub-instances of sizes i=0 ni = n). Each sub-instance Ii for i ∈ [0..φ] then has its own number of runs ri and alphabet size σi, on which the synergistic solutions described in this work can be applied, from mere Sorting (Section 2) to supporting MultiSelection (Section 3) and the more sophisticated Deferred Data Structures (Section 4). Corollary 2. Let M be a multiset of size n with φ pivot positions. The φ pivot positions divide M into i=0 ni = n). Each sub-instance Ii of size ni is formed by ρi runs and δi blocks of sizes gi1, . . . , giδi such that these blocks induce a partition πi of the output of size χi whose members have values mi1, . . . , miχi for i ∈ [0..φ]. There exists an algorithm that performs within ) data comparisons for sorting M. This number of comparisons is optimal in the worst case over multisets of size n with φ pivot positions which divide the multiset into i=0 ni = n) and each sub-instance Ii of size ni is formed by ρi runs and δi blocks of sizes gi1, . . . , giδi such that these blocks induce a partition πi of the output of size χi whose members have values mi1, . . . , miχi for i ∈ [0..φ]. φ + 1 sub-instances of sizes n0, . . . , nφ (such that (cid:80)φ O(n +(cid:80)φ φ + 1 sub-instances of sizes n0, . . . , nφ (such that(cid:80)φ (cid:1)(cid:111) (cid:110)(cid:80)δi j=1 log gij +(cid:80)χi j=1 log(cid:0) ρ mij i=0 Next, we generalize the algorithm Quick Synergy Sort to an offline multiselection algorithm that par- tially sorts a multiset according to the set of select queries given as input. This serves as a pedagogical introduction to the online Deferred Data Structures for answering rank and select queries presented in Section 4. For simplicity, in Section 3 and Section 4 we first describe results ignoring existing pivot positions, and then present the complete result as corollary. 3 MultiSelection Algorithm Given a linearly ordered multiset M and a sequence of ranks r1, . . . , rq, a multiselection algorithm must answer the queries select(r1), . . . , select(rq) in M, hence partially sorting M. We describe a MultiS- election algorithm based on the sorting algorithm Quick Synergy Sort introduced in Section 2.4. This algorithm is an intermediate result leading to the two Deferred Data Structures described in Section 4. Given a multiset M and a set of q select queries, the algorithm Quick Synergy MultiSelection follows the same first steps as the algorithm Quick Synergy Sort. But once it has computed the ranks of all elements in the block that contains the pivot µ, it determines which select queries correspond to elements smaller than or equal to max(cid:96) and which ones correspond to elements greater than or equal to minr (see Algorithm 1 for the definitions of max(cid:96) and minr). It then recurses on both sides. See Algorithm 2 for a formal description of the algorithm Quick Synergy MultiSelection. 9 1: Compute the ρ runs of respective sizes (ri)i∈[1..ρ] in M such that(cid:80)ρ Algorithm 2 Quick Synergy MultiSelection Input: A multiset M and a set Q of q offline select queries Output: The q selected elements 2: Compute the median µ of the middles of the ρ runs, note j ∈ [1..ρ] the run containing µ; 3: Perform doubling searches for the value µ in all runs except the j-th, starting at both ends of the runs in parallel; i=1 ri = n; 4: Find the maximum max(cid:96) (minimum minr) among the elements smaller (resp., greater) than µ in all runs except the j-th; 5: Perform doubling searches for the values max(cid:96) and minr in the j-th run, starting at the position of µ; 6: Compute the set of queries Q(cid:96) that go to the left of max(cid:96) and the set of queries Qr that go to the right of minr; 7: Recurse on the elements smaller than or equal to max(cid:96) and on the elements greater than or equal to minr with the set of queries Q(cid:96) and Qr, respectively. We extend the notion of blocks to the context of partial sorting. The idea is to consider consecutive blocks, which have not been identified by the Quick Synergy MultiSelection algorithm, as a single block. We next introduce the definitions of pivot blocks and selection blocks. Definition 3 (Pivot Blocks). Given a multiset M formed by ρ runs and δ blocks. The " pivot blocks" are the blocks of M that contain the pivots and the elements of value equals to the pivots during the steps of the algorithm Quick Synergy MultiSelection. In each run, between the pivot blocks and the insertion ranks of the pivots, there are consecutive blocks that the algorithm Quick Synergy MultiSelection has not identified as separated blocks, because no doubling searches occurred inside them. Definition 4 (Selection Blocks). Given the i-th run, formed of various blocks, and q select queries, the algorithm Quick Synergy MultiSelection computes ξ pivots in the process of answering the q queries. During the doubling searches, the algorithm Quick Synergy MultiSelection finds the insertion ranks of the ξ pivots inside the i-th run. These positions determine a partition of size ξ + 1 of the i-th run where each element of the partition is formed by consecutive blocks or is empty. We call the elements of this partition " selection blocks". The set of all selection blocks include the set of all pivot blocks. Using these definitions, we generalize the results proven in Section 2.4 to the more general problem of MultiSelection. Theorem 2. Given a multiset M of size n formed by ρ runs and δ blocks; and q offline select queries over M corresponding to elements of ranks r1, . . . , rq. The algorithm Quick Synergy MultiSelection computes ξ pivots in the process of answering the q queries. Let s1, . . . , sβ be the sizes of the β selection 10blocks determined by these ξ pivots in all runs. Let m1, . . . , mλ be the numbers of pivot blocks among this selection blocks corresponding to the values of the λ pivots with multiplicity greater than 1, respectively. Let ρ0, . . . , ρξ be the sequence where ρi is the number of runs that have elements with values between the pivots i and i + 1 sorted by ranks, for i ∈ [1..ξ]. The algorithm Quick Synergy MultiSelection answers the q select queries performing within O i=1 log si + β log ρ −(cid:80)λ i=1 mi log mi −(cid:80)ξ n +(cid:80)β (cid:17) ⊆ i=0 ρi log ρi (cid:16) i=0 ∆i log ∆i) data comparisons, where ∆i = ri+1 − ri, r0 = 0 and rq+1 = n. O (n log n −(cid:80)q algorithm perform within O((cid:80)β Proof. The doubling searches that find the insertion ranks of the pivots during the overall execution of the i=1 log si) data comparisons . At each run, a constant factor of the sum of the logarithm of the sizes of the selection blocks bounds the number of data comparisons performed by these doubling searches (see the proof of Lemma 1 analyzing the algorithm Quick Synergy Sort for details). The pivots computed by the algorithm Quick Synergy MultiSelection for answering the queries are a subset of the pivots computed by the algorithm Quick Synergy Sort for sorting the whole multiset. Suppose that the selection blocks determined by every two consecutive pivots form a multiset Mj such that for every (cid:17) pair of selection blocks in Mj the elements of one are smaller than the elements of the other one. Consider the steps that compute the medians of the middles in the algorithm Quick Synergy Sort, the number of data comparisons performed by these steps would be within O details). The number of comparisons needed to sort the multisets Mj is within Θ((cid:80)ξ in this supposed instance (see the proof of Lemmas 2 analyzing the algorithm Quick Synergy Sort for i=0 ρi log ρi). The result (cid:117)(cid:116) i=1 log si + β log ρ −(cid:80)λ n +(cid:80)β i=1 mi log mi (cid:16) follows. φ + 1 sub-instances of sizes n0, . . . , nφ (such that (cid:80)φ The process of detecting the φ pre-existing pivot positions seen in Section 2.5 can be applied as the first step of the multiselection algorithm. The φ pivot positions divide the input of size n into φ + 1 sub-instances of sizes n0, . . . , nφ. For each sub-instance Ii for i ∈ [0..φ], the multiselection algorithm determines which select queries correspond to Ii and applies then the steps of the Algorithm 2 inside Ii in order to answer these queries. Corollary 3. Let M be a multiset of size n with φ pivot positions. The φ pivot positions divide M into i=0 ni = n). Let q be the number of offline select queries over M, such that qi queries correspond to the sub-instance Ii, for i ∈ [0..φ]. In each sub-instance Ii of size ni formed by ρi runs, the algorithm Quick Synergy MultiSelection selects ξi pivots when it answers the qi queries. These ξi pivots determine βi selection blocks of sizes si1, . . . , siβi inside Ii. Let mi1, . . . , miλi be the numbers of pivot blocks among this selection blocks corresponding to the val- ues of the λi pivots with multiplicity greater than 1, respectively. Let ρi0, . . . , ρiξi be the sequence where ρij is the number of runs that have elements with values between the pivots ij and i(j + 1) sorted by ranks, for j ∈ [1..ξi]. There is an algorithm that answers the q offline select queries performing within (cid:110)(cid:80)βi j=1 log sij + βi log ρi −(cid:80)λi j=1 mij log mij −(cid:80)ξi j=0 ρij log ρij ) data comparisons. O(n +(cid:80)φ i=0 (cid:111) In the result above, the queries are given all at the same time (i.e., offline). In the context where they arrive one at the time (i.e., online), we define two Deferred Data Structures for answering online rank and select queries, both inspired by the algorithm Quick Synergy MultiSelection. 4 Rank and Select Deferred Data Structures We describe two Deferred Data Structures that answer a set of rank and select queries arriving one at the time over a multiset M, progressively sorting M. Both data structures take advantage of the order (local and global) and structure in the input, and of the structure in the queries. The first data structure is in the RAM model of computation, at the cost of not taking advantage of the order in which the queries are given. The second data structure is in the comparison model (a more constrained model) but does take advantage of the query order. 4.1 Taking Advantage of Order and Structure in the Input, but only of Structure in the 11 Queries Given a multiset M of size n, the RAM Deferred Data Structure is composed of a bitvector A of size n, in which we mark the elements in M that have been computed as pivots by the algorithm when it answers the online queries; a dynamic predecessor and successor structure B over the bitvector A, which allows us to find the two successive pivots between which the query fits; and for each pivot p found, the data structure stores pointers to the insertion ranks of p in each run, to the beginning and end of the block g to which p belongs, and to the position of p inside g. The dynamic predecessor and successor structure B requires the RAM model of computation in order to answer predecessor and successor queries in time within o(log n) [4]. Theorem 3. Consider a multiset M of size n formed by ρ runs and δ blocks. The RAM Deferred Data Structure computes ξ pivots in the process of answering q online rank and select queries over M. Let s1, . . . , sβ be the sizes of the β selection blocks determined by these ξ pivots in all runs. Let m1, . . . , mλ be the numbers of pivot blocks among this selection blocks corresponding to the values of the λ pivots with multiplicity greater than 1, respectively. Let ρ0, . . . , ρξ be the sequence where ρi is the number of runs that have elements with values between the pivots i and i + 1 sorted by ranks, for i ∈ [1..ξ]. Let u and g1, . . . , gu be the number of rank queries and the sizes of the identified and searched blocks in the process of answering the u rank queries, respectively. The RAM Deferred Data Structure answers these q online rank and i=0 ρi log ρi + ξ log log n + select queries in time within O(n +(cid:80)β u log n log log n +(cid:80)u i=1 log si + β log ρ −(cid:80)λ i=1 mi log mi −(cid:80)ξ i=1 log gi). Proof. The algorithm answers a new select(i) query by accessing in A the query position i. If A[i] is 1, then the element e has been computed as pivot, and hence the algorithm answers the query in constant time by following the position of e inside the block at which e belongs. If A[i] is 0, then the algorithm finds the nearest pivots to its left and right using the predecessor and successor structure, B. If the position i is inside a block to which one of the two nearest pivots belong, then the algorithm answers the query and in turn finishes. If not, it then applies the same steps as the algorithm Quick Synergy MultiSelection in order to answer the query; it updates the bitvector A and the dynamic predecessor and successor structure B whenever a new pivot is computed; and for each pivot p computed, the structure stores the pointers to the insertion ranks of p in each run, to the beginning and end of the block g to which p belongs, and to the position of p inside g. The algorithm answers a new rank(x) query by finding the selection block sj in the j-th run such that x is between the smallest and the greatest value of sj for all j ∈ [1..ρ]. For that, the algorithm performs a sort of parallel binary searches for the value x at each run taking advantage of the pivots that have been computed by the algorithm. The algorithm accesses the position n 2 has been computed as pivot. Following the pointer to the block g to which e belongs, the algorithm decides if x is to the right, to the left or inside g by performing a constant number of data comparisons. In the last case, a binary search for the value x inside g yields the answer of the query. If A[ n 2 ] is 0, then the algorithm finds 2 using the predecessor and successor structure, B. the nearest pivots to the left and right of the position n Following the pointers to the blocks that contain these pivots the algorithm decides if x is inside one of these blocks, to the right of the rightmost block, to the left of the leftmost block, or between these two blocks. In the last case, the algorithm applies the same steps as the algorithm Quick Synergy MultiSelection in order to compute the median µ of the middles and partitions the selection blocks by µ. The algorithm then decides to which side x belongs. These steps identify several new pivots, and in consequence several new (cid:117)(cid:116) blocks in the structure. The RAM Deferred Data Structure includes the pivot positions (seen in Section 2.5) as a natural extension of the algorithm. The φ pivot positions are marked in the bitvector A. For each pivot position p, the structure stores pointers to the end of the runs detected on the left of p; to the beginning of the runs detected on the right of p; and to the position of p in the multiset. Corollary 4. Let M be a multiset of size n with φ pivot positions. The φ pivot positions divide M into φ+1 i=0 ni = n). Let q be the number of online rank and select sub-instances of sizes n0, . . . , nφ (such that (cid:80)φ 2 ] is 1, then the element e of rank n 2 in A. If A[ n 12queries over M, such that qi queries correspond to the sub-instance Ii, for i ∈ [0..φ]. In each sub-instance Ii of size ni formed by ρi runs, the RAM Deferred Data Structure selects ξi pivots in the process of answering the qi online rank and select queries over Ii. Let si1, si2, . . . , siβi be the sizes of the βi selection blocks determined by the ξi pivots in all runs of Ii. Let m1i, . . . , miλi be the numbers of pivot blocks among this selection blocks corresponding to the values of the λi pivots with multiplicity greater than 1, respectively. Let ρi0, . . . , ρiξi be the sequence where ρij is the number of runs that have elements with values between the pivots ij and i(j + 1) sorted by ranks, for j ∈ [1..ξi]. Let ui and gi1, . . . , giui be the number of rank queries and (cid:80)φ the sizes of the identified and searched blocks in the process of answering the ui rank queries over Ii, respec- tively. There exists an algorithm that answers these q online rank and select queries in time within O(n + j=0 ρij log ρij + ξi log log ni + u log ni log log ni +(cid:80)ui j=1 log gij (cid:110) βi log ρi −(cid:80)λi j=1 mij log mij −(cid:80)ξi (cid:111) ). i=0 The RAM Deferred Data Structure takes advantage of the structure in the queries and of the structure and order (local and global) in the input. Changing the order in the rank and select queries does not affect the time complexity of the RAM Deferred Data Structure. Once the structure identifies the nearest pivots to the left and right of the query positions, the steps of the algorithms are the same as in the offline case (Section 3). We next describe a deferred data structure taking advantage of the structure and order in the queries and of the structure and order (local and global) in the input data. 4.2 Taking Advantage of the Order and Structure in both the Input and the Queries To take advantage of the order in the queries, we introduce a data structure that finds the nearest pivots to the left and to the right of a position p ∈ [1..n], while taking advantage of the distance between the position of the last computed pivot and p. This distance is measured in the number of computed pivots between the two positions. For that we use a finger search tree [15] which is a search tree maintaining fingers (i.e., pointers) to elements in the search tree. Finger search trees support efficient updates and searches in the vicinity of the fingers. Brodal [7] described an implementation of finger search trees that searches for an element x, starting the search at the element given by the finger f in time within O(log d), where d is the distance between x and f in the set (i.e, the difference between rank(x) and rank(f ) in the set). This operation returns a finger to x if x is contained in the set, otherwise a finger to the largest element smaller than x in the set. This implementation supports the insertion of an element x immediately to the left or to the right of a finger in worst-case constant time. In the description of the RAM Deferred Data Structure from Theorem 3, we substitute the dynamic predecessor and successor structure B by a finger search tree Fselect, as described by Brodal [7]. Once a block g is identified, every element in g is a valid pivot for the rest of the elements in M. In order to capture this idea, we modify the structure Fselect so that it contains blocks (i.e., a sequence of consecutive values) instead of singleton pivots. Each element in Fselect points in M to the beginning and the end of the block g that it represents and in each run to the position where the elements of g partition the run. This modification allows the structure to answer select queries, taking advantage of the structure and order in the queries and of the structure and order of the input data. But in order to answer rank queries taking advantage of the features in the queries and the input data, the structure needs another finger search tree Frank. In Frank the structure stores for each block g identified, the value of one of the elements in g, and pointers in M to the beginning and the end of g and in each run to the position where the elements of g partition the run. We name this structure Full-Synergistic Deferred Data Structure. Theorem 4. Consider a multiset M of size n formed by ρ runs and δ blocks. The Full-Synergistic Deferred Data Structure identifies γ blocks in the process of answering q online rank and select queries over M. The q queries correspond to elements of ranks r1, . . . , rq. Let s1, . . . , sβ be the sizes of the β selection blocks determined by the γ blocks in all runs. Let m1, . . . , mλ be the numbers of pivot blocks among this selection blocks corresponding to the values of the λ pivots with multiplicity greater than 1, respectively. Let ρ0, . . . , ρξ be the sequence where ρi is the number of runs that have elements with values between the pivots i and i+1 sorted by ranks, for i ∈ [1..ξ]. Let d1, . . . , dq−1 be the sequence where dj is the number of identified blocks between the block that answers the j−1-th query and the one that answers the j-th query before starting the steps to answer the j-th query, for j ∈ [2..q]. Let u and g1, . . . , gu be the number of rank queries and the sizes of the identified and searched blocks in the process of answering the u rank queries, respectively. The Full-Synergistic Deferred Data Structure answers the q online rank and select queries i=1 log gi) ⊆ i=1 log si +β log ρ−(cid:80)λ i=1 mi log mi−(cid:80)ξ performing within O(n+(cid:80)β O (n log n −(cid:80)q i=0 ρi log ρi +(cid:80)q−1 i=1 log di +(cid:80)u 13 i=0 ∆i log ∆i + q log n) data comparisons, where ∆i = ri+1 − ri, r0 = 0 and rq+1 = n. Proof. The steps for answering a new select(i) query are the same as the above description except when the algorithm searches for the nearest pivots to the left and right of the query position i. In this case, the algorithm searches for the position i in Fselect. If i is contained in an element of Fselect, then the block g that contains the element in the position i has already been identified. If i is not contained in an element of Fselect, then the returned finger f points the nearest block b to the left of i. The block that follows f in Fselect is the nearest block to the right of i. Given f , the algorithm inserts in Fselect each block identified in the process of answering the query in constant time and stores the respective pointers to positions in M. In Frank the algorithm searches for the value of one of the elements in g or b. Once the algorithm obtains the finger returned by this search, the algorithm inserts in Frank the value of one of the elements of each block identified in constant time and stores the respective pointers to positions in M. The algorithm answers a new rank(x) query by finding the selection block sj in the j-th run such that x is between the smallest and the greatest value of sj for all j ∈ [1..ρ] , similar to the steps of the RAM Deferred Data Structure for answering the query . For that the algorithm searches for the value x in Frank. The number of data comparisons performed by this searching process is within O(log d), where d is the number of blocks in Frank between the last inserted or searched block and returned finger f . Given the finger f , there are three possibilities for the rank r of x: (i) r is between the ranks of the elements at the beginning and the end of the block pointed by f , (ii) r is between the ranks of the elements at the beginning and the end of the block pointed by the finger following f , or (iii) r is between the ranks of the elements in the selection blocks determined by f and the finger following f . In the cases (i) and (ii), a binary search inside the block yields the answer of the query. In case (iii), the algorithm applies the same steps as the algorithm Quick Synergy MultiSelection in order to compute the median µ of the middles and partitions the selection blocks by µ. The algorithm then decides to which side x belongs. These doubling searches identify two new blocks in the structure, the block that contains the greatest element smaller than or equal to x in M and the block that contains the smallest element greater than x in M. Once compute rank(x), the algorithm searches for this value in Fselect. It inserts then in Fselect the block that contains the greatest element smaller than or equal to x and the block that contains the smallest element greater (cid:117)(cid:116) than x. The process of detecting the φ pivot positions seen in Section 2.5 allows the Full-Synergistic De- ferred Data Structure to insert these pivots in Fselect and Frank. For each pivot position p in Fselect and Frank, the structure stores pointers to the end of the runs detected on the left of p; to the beginning of the runs detected on the right of p; and to the position of p in the multiset. Corollary 5. Let M be a multiset of size n with φ pivot positions. The φ pivot positions divide M into i=0 ni = n). Let q be the number of online rank and select queries over M, such that qi queries correspond to the sub-instance Ii, for i ∈ [0..φ]. In each sub-instance Ii of size ni formed by ρi runs, the Full-Synergistic Deferred Data Structure identi- fies γi blocks in the process of answering qi online rank and select queries over Ii. Let si1, si2, . . . , siβi be the sizes of the βi selection blocks determined by the γi blocks in all runs of Ii. Let m1i, . . . , miλi be the numbers of pivot blocks among this selection blocks corresponding to the values of the λi pivots with multiplicity greater than 1, respectively. Let ρi0, . . . , ρiξi be the sequence where ρij is the number of runs that have elements with values between the pivots ij and i(j + 1) sorted by ranks, for j ∈ [1..ξi]. Let di1, di2, . . . , diqi−1 be the sequence where dij is the number of identified blocks between the block that answers the ij − 1-th query and the one that answers the ij-th query before starting the steps for an- swering the ij-th query, for j ∈ [2..qi]. Let ui and gi1, . . . , giui be the number of rank queries and the sizes of the identified and searched blocks in the process of answering the ui rank queries over Ii, respec- tively. There exists an algorithm that answers the q online rank and select queries performing within φ + 1 sub-instances of size n0, . . . , nφ (such that (cid:80)φ O(n +(cid:80)φ 14 i=0 (cid:110)(cid:80)βi j=1 log sij + βi log ρi −(cid:80)λi j=1 mij log mij −(cid:80)ξi j=0 ρij log ρij +(cid:80)qi−1 j=1 log dij +(cid:80)ui j=1 log gij (cid:111) ) data comparisons. The Full-Synergistic Deferred Data Structure has two advantages over the RAM Deferred Data Structure: (i) it is in the pointer machine model of computation, which is less powerful than the RAM model; and (ii) it takes advantage of the structure and order in the queries and of the structure and order (local and global) in the input, when the RAM Deferred Data Structure does not take advantage of the order in the queries. Next, we present two compressed data structures, taking advantage of the block representation of a multiset M while supporting the operators rank and select on M. 5 Compressed Data Structures for Rank and Select We describe two compressed representations of a multiset M of size n formed by ρ runs and δ blocks while supporting the operators rank and select on it. The first compressed data structure represents M in δ log ρ+3n+o(δ log ρ+n) bits and supports each rank query in constant time and each select query in time within O(log log ρ). The second compressed data structure represents M in δ log δ + 2n + O(δ log log δ) + o(n) bits and supports each select query in constant time and each rank query in time within O Given a bitvector V, rank1(V, j) finds the number of occurrences of bit 1 in V[0..j], and select1(V, i) finds the position of the i-th occurrence of bit 1 in V. Given a sequence S from an alphabet of size ρ, rank(S, c, j) finds the number of occurrences of character c in S[0..j]; select(S, c, i) finds the position of the i-th occurrence of character c in S; and access(S, j) returns the character at position j in S. (cid:16) log δ (cid:17) log log δ . 5.1 Rank-aware Compressed Data Structure for Rank and Select The Rank-aware Compressed Data Structure supports rank in constant time and select in time within O(log log ρ) using δ log ρ + 3n + o(δ log ρ + n) bits. It contains three structures A, B and C representing bitvectors of size n supporting for V ∈ {A,B,C}, rank1(V, j) and select1(V, i) in constant time using n + o(n) bits each [8]. It contains a data structure S representing a sequence of length δ from an alphabet of size ρ supporting rank(S, c, j) in time within O(log log ρ), access(S, j) in time within O(log log ρ), and select(S, c, i) in constant time, using δ log ρ + o(δ log ρ) bits [14]. Given the blocks g1, . . . , gδ in sorted order, A contains the information of the lengths of these blocks in this order in a bitvector of length n with a 1 marking the position where each block starts. B contains the information of the lengths of the blocks similar to A but with the blocks maintaining the original order, such that all blocks belonging to the same run are consecutive. C contains the information of the length of the runs in a bitvector of length n with a 1 marking the position where each run starts. The structure S contains the run to which g belongs for each block g in sorted order. Theorem 5. Let M be a multiset formed by ρ runs and δ blocks. The Rank-aware Compressed Data Structure represents M in δ log ρ + 3n + o(δ log ρ + n) bits supporting each rank query in constant time and each select query in time within O(log log ρ). Proof. To answer a query rank(M, x), the following operations are executed: rank1(C, i) returns the run r that contains x in constant time, where i is the position of x in the original order of M; select1(C, r) returns the position q where r starts in the original order of M in constant time; rank1(B, i) − rank1(B, q − 1) returns the position p inside of r of the block g that contains x in constant time; select(S, r, p) returns the position j of g in sorted order in constant time; and select1(A, j) returns the rank of the first element in g in constant time. For answering a query select(M, i), the following operations are executed: rank1(A, i) returns the position j of the block g in sorted order that contains the selected element in constant time; access(S, j) returns the run r that contains the selected element in time within O(log log ρ); rank(S, r, j) returns the position p of g inside r in time within O(log log ρ); and select1(B, p + rank1(B, select1(C, r))) returns (cid:117)(cid:116) the position where g starts in the original order of M in constant time. 15 We describe next a compressed data structure that represents a multiset, taking advantage of the block representation of it, but unlike Rank-aware Compressed Data Structure, the structure supports select in constant time. 5.2 Select-aware Compressed Data Structure for Rank and Select (cid:16) log δ log log δ (cid:17) log log δ (cid:17) (cid:16) log δ The Select-aware Compressed Data Structure supports select in constant time and rank in time using δ log δ + 2n + O(δ log log δ) + o(n) bits. It contains the same two structures A and within O B described above and a structure representing a permutation π of the numbers [1..δ] supporting the direct operator π() in constant time and the inverse operator π−1() in time within O using δ log δ + O(δ log log δ) bits [24]. Given the blocks g1, . . . , gδ in sorted order, π(i) returns the position j of the block gi in the original order of M and π−1(j) = i if the position of the block gi is j in the original order of M. Theorem 6. Let M be a multiset formed by ρ runs and δ blocks. The Select-aware Compressed Data Structure represents M in δ log δ +2n+O(δ log log δ)+o(n) bits supporting each select query in constant time and each rank query in time within O Proof. To answer a query select(M, i), the following operations are executed: rank1(A, i) returns the position j of the block gj in sorted order that contains the selected element in constant time; π(j) returns the position p of gj in the original order of M in constant time; and select1(B, p) returns the position where gj starts in M in constant time. To answer a query rank(M, x), the following operations are executed: rank1(B, i) returns the position j of the block g that contains x in constant time, where i is the position of x in the original order of M; ; and select1(A, p) returns the π−1(j) returns the position p of g in sorted order in time within O (cid:117)(cid:116) rank of the first element of g in constant time. (cid:16) log δ (cid:16) log δ (cid:17) . (cid:17) log log δ log log δ This concludes the description of our synergistic results. In the next section we discuss how these results relate to various past results and future work. 6 Discussion In the context of deferred data structure, the concept of runs was introduced previously in [2, 19], but for a different purpose than the refined analysis of the complexity presented in this work: we clarify the difference and the research perspectives that it suggests in Section 6.1, and other perspectives for future research in Section 6.2. At a higher cognition level, we discuss the importance of categorizing techniques of multivariate analysis of algorithms in Section 6.3. 6.1 Comparison with previous work Kaligosi et al.'s multiselection algorithm [19] and Barbay et al's deferred data structure [2] use the very same concept of runs as the one described in this work. The difference is that whereas we describe algorithms which detect the existing runs in the input in order to take advantage of them, the algorithms described by those previous works do not take into consideration any pre-existing runs in the input (assuming that there are none) and rather build and maintain such runs as a strategy to minimize the number of comparisons performed while partially sorting the multiset. We leave the combination of both approaches as a topic for future work which could probably shave a constant factor off the number of comparisons performed by the Sorting and MultiSelection algorithms and by the Deferred Data Structures supporting rank and select on Multisets. Johnson and Frederickson [13] described an algorithm answering a single select i=1 log ri). Using their algorithm on pre-existing runs outperforms the Deferred Data Structures described in Section 4, when there is a single query in a set of sorted arrays of sizes r1, r2, . . . , rρ, in time within O((cid:80)ρ 16query. Yet it is not clear how to generalize their algorithm into a deferred data structure in order to support more than one query. The difference is somehow negligible as the cost of such a query is anyway dominated by the cost (n − 1 comparisons) of partitioning the input into runs. We leave the generalization of Johnson and Frederickson's algorithm into a deferred data structure which optimally supports more than one query as an open problem. We describe additional perspectives for future research in the next section. 6.2 Perspectives for future research One question to tackle is to see how frequent are "easy" instances in concrete applications, in terms of input order and structure, and in terms of query order and structure; and how much advantage can be taken of them. Barbay and Navarro [3] described how sorting algorithms in the comparison model directly imply en- codings for permutations, and in particular how sorting algorithms taking advantage of specificities of the input imply compressed encodings of such permutations. By using the similarity of the execution tree of the algorithm MergeSort with the well known Wavelet Tree data structure, they described a compressed data structure for permutations taking advantage of local order, i.e., using space proportional to H(r1, . . . , rρ) and supporting direct access (i.e. π()) and inverse access (i.e. π−1()) in worst time within O(1 + lg ρ) and average time within O(1 + H(r1, . . . , rρ)). We leave the definition of a compressed data structure for multisets taking additional advantage of its structure and global order as future work. Another perspective is to generalize the synergistic results to related problems in computational geometry: Karp et al. [20] defined the first deferred data structure not only to support rank and select queries on multisets, but also to support online queries in a deferred way on Convex Hull in two dimensions and online Maxima queries on sets of multi-dimensional vectors. One could refine the results from Karp et al. [20], expressed in function of the number of queries, to take into account the blocks between each queries (i.e., the structure in the queries) as Barbay et al. [2] did for multisets; but also for the relative position of the points (i.e., the structure in the data) as Afshani et al. [1] did for Convex Hulls and Maxima; the order in the points (i.e., the order in the data), as computing the convex hull in two dimension takes linear time if the points are sorted; and potentially the order in the queries. 6.3 Importance of the Parameterization of Structure and Order The computational complexity of most problems is studied in the worst case over instances of fixed size n, for n asymptotically tending to infinity. This approach was refined for NP-difficult problems under the term "parameterized complexity" [12], for polynomial problems under the term "Adaptive Algorithms" [11, 23], and more simply for data encodings under the term of "Data Compression" [3], for a wide range of problems and data types. Such a variety of results has motivated various tentative to classify them, in the context of NP-hard problems with a theory of Fixed Parameter Tractability [12], and in the context of sorting in the comparison model with a theory of reduction between parameters [26]. We introduced two other perspectives from which to classify algorithms and data structures. Through the study of the sorting of multisets according to the potential "easiness" in both the order and the values in the multiset, we aimed to introduce a way to classify refined techniques of complexity analysis between the ones considering the input order and the ones considering the structure in the input; and to show an example of the difficulty of combining both into a single hybrid algorithmic technique. Through the study of the online support of rank and select queries on multisets according to the potential "easiness" in both the order and the values in the queries themselves (in addition to the potential easiness in the data being queried), we aimed to introduce such categorizations. We predict that such analysis techniques will take on more importance in the future, along with the growth of the block between practical cases and the worst case over instances of fixed sizes. Furthermore, we conjecture that synergistic techniques taking advantage of more than one "easiness" aspect will be of practical importance if the block between theoretical analysis and practice is to ever be reduced. References 17 1. Afshani, P., Barbay, J., Chan, T.M.: Instance-optimal geometric algorithms. In: Proceedings of the Annual IEEE Symposium on Foundations of Computer Science (FOCS). pp. 129 -- 138. IEEE Computer Society (2009) 2. Barbay, J., Gupta, A., Satti, S.R., Sorenson, J.: Near-optimal online multiselection in internal and external memory. Journal of Discrete Algorithms (JDA) 36, 3 -- 17 (2016) 3. Barbay, J., Navarro, G.: On compressing permutations and adaptive sorting. Theoretical Computer Science (TCS) 513, 109 -- 123 (2013) 4. Beame, P., Fich, F.E.: Optimal bounds for the predecessor problem and related problems. Journal of Computer and System Sciences (JCSS) 65(1), 38 -- 72 (2002) 5. Bentley, J.L., Yao, A.C.C.: An almost optimal algorithm for unbounded searching. Information Processing Letters (IPL) 5(3), 82 -- 87 (1976) 6. Blum, M., Floyd, R.W., Pratt, V.R., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. Journal of Compu- tational System Science (JCSS) 7(4), 448 -- 461 (1973) 7. Brodal, G.S.: Finger search trees with constant insertion time. In: Proceedings of the ninth annual ACM-SIAM symposium on Discrete algorithms (SODA). pp. 540 -- 549. Society for Industrial and Applied Mathematics (1998) 8. Clark, D.R.: Compact Pat Trees. Ph.D. thesis, University of Waterloo (1996) 9. Demaine, E.D., L´opez-Ortiz, A., Munro, J.I.: Adaptive set intersections, unions, and differences. In: Proceedings of the 11th ACM-SIAM Symposium on Discrete Algorithms (SODA). pp. 743 -- 752 (2000) 10. Dobkin, D.P., Munro, J.I.: Optimal time minimal space selection algorithms. Journal of the ACM (JACM) 28(3), 454 -- 461 (1981) 11. Estivill-Castro, V., Wood, D.: A survey of adaptive sorting algorithms. ACM Computing Surveys (ACMCS) 24(4), 441 -- 476 (1992) 12. Flum, J., Grohe, M.: Parameterized Complexity Theory (Texts in Theoretical Computer Science. An EATCS Series). Springer-Verlag New York, Inc., Secaucus, NJ, USA (2006) 13. Frederickson, G.N., Johnson, D.B.: Generalized selection and ranking. In: Proceedings of the 12th Annual ACM Symposium on Theory of Computing (STOC), April 28-30, 1980, Los Angeles, California, USA. pp. 420 -- 428 (1980) 14. Golynski, A., Munro, J.I., Rao, S.S.: Rank/select operations on large alphabets: A tool for text indexing. In: Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithm (SODA). pp. 368 -- 373. SODA '06, Society for Industrial and Applied Mathematics, Philadelphia, PA, USA (2006) 15. Guibas, L.J., McCreight, E.M., Plass, M.F., Roberts, J.R.: A new representation for linear lists. In: Proceedings of the ninth annual ACM symposium on Theory of computing (STOC). pp. 49 -- 60. ACM Press, New York, NY, USA (1977) 16. Hoare, C.A.R.: Algorithm 64: Quicksort. Communication of the ACM (CACM) 4(7), 321 (1961) 17. Hoare, C.A.R.: Algorithm 65: Find. Communication of the ACM (CACM) 4(7), 321 -- 322 (1961) 18. Huffman, D.A.: A method for the construction of minimum-redundancy codes. Proceedings of the Institute of Radio Engineers (IRE) 40(9), 1098 -- 1101 (September 1952) 19. Kaligosi, K., Mehlhorn, K., Munro, J.I., Sanders, P.: Towards optimal multiple selection. In: Proceedings of the International Conference on Automata, Languages, and Programming (ICALP). pp. 103 -- 114 (2005) 20. Karp, R.M., Motwani, R., Raghavan, P.: Deferred data structuring. SIAM Journal on Computing (SICOMP) 17(5), 883 -- 902 (1988) 21. Knuth, D.E.: The Art of Computer Programming, Vol 3, chap. Sorting and Searching, Section 5.3. Addison-Wesley (1973) 22. Mannila, H.: Measures of presortedness and optimal sorting algorithms. IEEE Trans. Computers 34(4), 318 -- 325 (1985) 23. Moffat, A., Petersson, O.: An overview of adaptive sorting. Australian Computer Journal (ACJ) 24(2), 70 -- 77 (1992) 24. Munro, J.I., Raman, R., Raman, V., S., S.R.: Succinct representations of permutations and functions. Theoretical Computer Science (TCS) 438, 74 -- 88 (2012) 25. Munro, J.I., Spira, P.M.: Sorting and searching in multisets. SIAM Journal on Computing (SICOMP) 5(1), 1 -- 8 (1976) 26. Petersson, O., Moffat, A.: A framework for adaptive sorting. Discrete Applied Mathematics (DAM) 59, 153 -- 179 (1995) 27. Takaoka, T.: University http://ir.canterbury.ac.nz/handle/10092/9676, last accessed [2016-08-23 Tue] mergesort. Minimal Tech. rep., of Canterbury (1997), 1828. Takaoka, T.: Partial solution and entropy. In: Kr´alovic, R., Niwi´nski, D. (eds.) Mathematical Foundations of Computer Science (MFCS) 2009: 34th International Symposium, Novy Smokovec, High Tatras, Slovakia, August 24-28, 2009. Proceedings. pp. 700 -- 711. Springer Berlin Heidelberg, Berlin, Heidelberg (2009)
1704.08558
1
1704
2017-04-27T13:28:45
Practical and Effective Re-Pair Compression
[ "cs.DS" ]
Re-Pair is an efficient grammar compressor that operates by recursively replacing high-frequency character pairs with new grammar symbols. The most space-efficient linear-time algorithm computing Re-Pair uses $(1+\epsilon)n+\sqrt n$ words on top of the re-writable text (of length $n$ and stored in $n$ words), for any constant $\epsilon>0$; in practice however, this solution uses complex sub-procedures preventing it from being practical. In this paper, we present an implementation of the above-mentioned result making use of more practical solutions; our tool further improves the working space to $(1.5+\epsilon)n$ words (text included), for some small constant $\epsilon$. As a second contribution, we focus on compact representations of the output grammar. The lower bound for storing a grammar with $d$ rules is $\log(d!)+2d\approx d\log d+0.557 d$ bits, and the most efficient encoding algorithm in the literature uses at most $d\log d + 2d$ bits and runs in $\mathcal O(d^{1.5})$ time. We describe a linear-time heuristic maximizing the compressibility of the output Re-Pair grammar. On real datasets, our grammar encoding uses---on average---only $2.8\%$ more bits than the information-theoretic minimum. In half of the tested cases, our compressor improves the output size of 7-Zip with maximum compression rate turned on.
cs.DS
cs
Practical and Effective Re-Pair Compression Philip Bille1, Inge Li Gørtz1, and Nicola Prezza1 1 Technical University of Denmark, DTU Compute, [email protected], [email protected], [email protected] Abstract Re-Pair is an efficient grammar compressor that operates by recursively replacing high-frequency character pairs with new grammar symbols. The most space-efficient linear-time algorithm com- puting Re-Pair uses (1 + )n +√ n words on top of the re-writable text (of length n and stored in n words), for any constant  > 0; in practice however, this solution uses complex sub-procedures preventing it from being practical. In this paper, we present an implementation of the above- mentioned result making use of more practical solutions; our tool further improves the working space to (1.5 + )n words (text included), for some small constant . As a second contribution, we focus on compact representations of the output grammar. The lower bound for storing a grammar with d rules is log(d!) + 2d ≈ d log d + 0.557d bits, and the most efficient encoding algorithm in the literature uses at most d log d + 2d bits and runs in O(d1.5) time. We describe a linear-time heuristic maximizing the compressibility of the output Re-Pair grammar. On real datasets, our grammar encoding uses -- on average -- only 2.8% more bits than the information- theoretic minimum. In half of the tested cases, our compressor improves the output size of 7-Zip with maximum compression rate turned on. 1998 ACM Subject Classification E.4 Coding and Information Theory, E.1 Data Structures, F.2.2 Nonnumerical Algorithms and Problems Keywords and phrases Grammars; Re-Pair Compression Digital Object Identifier 10.4230/LIPIcs.CVIT.2017.YY Introduction 1 Grammar compression aims at reducing the size of an input string S ∈ Σn by replacing it with a (small) set of grammar productions G generating S (and only S) as output. Despite generating the smallest such grammar has been proved to be NP-hard [5], several approximation techniques have been developed during the last decades which produce very small grammars on inputs of practical interest. Among these techniques, Re-Pair [11] (short for Recursive Pairing) is a simple and fast off-line compression scheme that generates the grammar by recursively replacing high-frequency character pairs with new grammar symbols. Despite its simplicity, Re-Pair achieves high-order entropy compression [12] and -- especially on repetitive datasets -- is an excellent compressor in practice [8,10,17]. This feature makes it the favorite choice in applications where grammar compression is convenient over other strategies (e.g. compression and indexing of repetitive collections [6,7,10]). Re-Pair works as follows on a string S. As long as there is a pair of adjacent symbols occurring at least twice: Find the most frequent pair ab. Let X be a new symbol not appearing in S. Add the rule X → ab and replace all occurrences of ab in S with X. Letting Σ = {0, . . . , σ − 1}, this procedure generates a grammar of size d of the form Xi → YiZi, with Xi ∈ {σ, . . . , d − 1} and Yi, Zi ∈ {0, . . . , σ + d − 1} for i = 0, . . . , d − 1, 7 1 0 2 r p A 7 2 ] S D . s c [ 1 v 8 5 5 8 0 . 4 0 7 1 : v i X r a © Philip Bille, Inge L. Gørtz, and Nicola Prezza; licensed under Creative Commons License CC-BY 42nd Conference on Very Important Topics (CVIT 2016). Editors: John Q. Open and Joan R. Acces; Article No. YY; pp. YY:1 -- YY:12 Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany YY:2 Practical and Effective Re-Pair Compression together with a text T ∈ {0, . . . , σ + d − 1}∗ without repeated character pairs. The first algorithm implementing this strategy was described by Larsson and Moffat in their original Re-Pair paper [11]. This algorithm runs in optimal O(n) time but is very space-consuming, requiring 5n + 4σ2 + 4d + √ n words of working space on top of the text. This space does not scale well with the alphabet size, and is particularly high if the input string is not very if d ≈ n. A very fast and more space-efficient implementation of this compressible, i.e. algorithm exists [14], and it requires about 12n Bytes of main memory during execution. Very recently, this space was reduced -- without increasing running times -- to (1 + )n + √ n words (on top of the text stored in n words) for any constant 0 <  ≤ 1 [2]. This space saving, however, comes at the expenses of practicality: the algorithm in [2] makes use of complex sub-procedures -- such as in-place radix sorting -- and is therefore not suitable for a practical direct implementation. The first contribution of this paper is a practical and even more space-efficient variant of the strategy proposed in [2]. Our algorithm makes use of new techniques of independent interest (such as a very practical integer clustering procedure), runs in linear time, and uses -- including the space for storing the text -- only (1.5 + )n words of space during execution for some small constant  > 0 (therefore further improving upon [2]). Our implementation [15] reduces by half the working space of the state of the art [14]. A second concern that should be considered by a good grammar compressor is how to represent the output grammar using the information-theoretic minimum number of bits. This problem has recently been addressed in [16], where the authors show that the information- theoretic minimum number of bits needed to represent a grammar with d rules of the form X → ZY (the result therefore applies also to Re-Pair) is log(d!)+2d ≈ d log d+0.557d. In the same paper, the authors show an encoding -- based on monotone subsequences decomposition -- achieving d log d + 2d bits in the worst case. Their encoding can be computed in O(d1.5) time. In this paper, we show how to exploit a degree of freedom in the Re-Pair procedure specification in order to maximize the compressibility of the output grammar. Our improved Re-Pair algorithm runs in optimal O(n) time, and the output grammar can be encoded in optimal O(d) time with our technique. We bound the size of our encoding in terms of the number M ≤ d of distinct frequencies in the right-productions of the output grammar (i.e. frequencies of pairs at substitution time): our final grammar representation takes at most d(log d + log M + 1) + M log(d/M) + o(d log d) bits. As we show experimentally, M is orders of magnitude smaller than d on real datasets, making this strategy very effective in practice: on average, our encoding uses just 2.8% more bits than the information-theoretic minimum (with a very small variance and achieving compression in half of the cases). Our strategy turns out to be very effective when compared with the most efficient compressors used in practice: in half of the tested cases, our compressor improves the output size of 7-Zip with maximum compression rate turned on. Space-Efficient Re-Pair 2 In this section we give an overview of the algorithm [2] that obtained (1 + )n + √ space on top of the text and expected O(n/) time, for any constant 0 <  ≤ 1. One of the most space-consuming components of Larsson's and Moffat's solution [11] is the text S, which is represented as a doubly-linked list of characters to support fast pair replacement. The first idea to save space upon this text representation is to represent the text as a plain word-vector and write blank characters _ in text positions where we replace pairs: when performing replacement X → ab at text position i, the occurrence of ab n words of P. Bille, I.L. Gørtz, and N. Prezza YY:3 starting in S[i] is replaced by X_. Note that, after several replacements, there could be long (super-constant) runs of blanks in the text. To keep operations efficient, in [2] we show how to skip such runs in constant time by storing pointers at the beginning and end of each run. This trick gives us constant-time pair extraction from the text. The idea, at this point, is to insert pairs in a queue and extract them by decreasing frequency. Each time we extract the maximum-frequency pair AB, we replace all text occurrences of AB with a new grammar symbol X. In order to keep space usage under control, we use two main strategies: (i) we define a frequency cut-off equal to c·√ n, for some constant c (the exact value of c is used to keep space under control and is not relevant for this discussion, see [2] for full details), call high-frequency (resp. low-frequency) pairs those character pairs appearing more (resp. less) than c·√ n times in the text, and use two different queues for high- and low- frequency pairs. (ii) We keep a position table (array) TP that, for each pair in the queue, holds the positions of the occurrences of that pair in the text. This position array improves upon the space of the original solution [11], where pairs' occurrences are stored using linked lists. Let Fab denote the frequency of pair ab. The positions of all occurrences of pair ab are stored in a TP-interval TP[Pab . . . Pab + Lab − 1], and the queue element associated with ab stores values Pab, Lab, and Fab. Invariant Fab ≤ Lab ≤ 2Fab is valid at all times, and is at the core of an amortization policy guaranteeing efficient operations on the queues in small space (read below). The space-efficient Re-Pair algorithm works as follows on a string S. We start by using the high-frequency queue -- we call this high-frequency phase -- , and then switch to the low-frequency queue when all text pairs have frequency smaller than c · √ n -- we call this low-frequency phase. Algorithm As long as the queue Q is non-empty: Extract the most frequent pair AB from Q. Let X be a new symbol not appearing in S. Output rule X → AB. Replace all occurrences of AB in S with X using the position array TP. When replacing xABy with xXy, decrease the frequencies of xA and By in the queue. For all decreased pairs cd such that Fcd < Lcd/2: update TP[Pcd . . . Pcd + Lcd − 1] using the amortization procedure Synchronize described below Update TP[PAB . . . PAB + LAB − 1] using procedure Synchronize and remove AB from the queue. Synchronize(ab): When entering in this procedure, TP[Pab . . . Pab + Lab − 1] (possibly) contains pairs xy different from ab and/or blanks. The aim is to re-organize the sub-array in such a way that TP[Pab . . . Pab + Lab − 1] contains only occurrences of ab. Sort TP[Pab . . . Pab + Lab − 1] by character pairs (ignoring blanks). This procedure uses in-place radix sorting. Compute Fxy and Lxy for all the pairs xy contained in TP[Pab . . . Pab + Lab − 1] including ab, and insert them in the queue Q (only if their frequency is at least c · √ n if Q is the high-frequency queue) In [2] we show that the above amortization policy (i) preserves correctness, in the sense that we always correctly extract the maximum-frequency pair from the queue, and (ii) permits to implement queues operations efficiently. CVIT 2017 YY:4 Practical and Effective Re-Pair Compression Queue operations Both queues need to support the following operations (in addition to Synchronize): Q[ab]: return the triple hPab, Lab, Fabi associated with pair ab Q.remove(ab) : remove ab from Q Q.contains(ab): return true iff Q contains pair ab Q.decrease(ab): decrease Fab by one Q.insert(ab, Pab, Lab, Fab): insert ab and its associated information in Q Q.max(): return the pair AB with largest FAB The high-frequency queue contains pairs occurring at least c · √ n times, therefore its maximum capacity is O(√ n). The high-frequency phase ends when the queue is empty, i.e., when there are no more pairs occurring at least c · √ n times. In [2] we show how to implement all operations on this queue in constant (expected, amortized) time, except max and remove -- which are supported in O(√ n) time (i.e. with a simple linear scan of the queue) -- and Synchronize(ab) -- which is supported in O(Lab + N · √ n) time, where Lab is ab's interval length at the moment of entering in this procedure, and N is the number of new pairs xy inserted in the queue. Since we execute at most O(√ n) times max and remove (once per high-frequency pair), we spend overall O(n) time on the high-frequency queue. The capacity of the low-frequency queue is · n, for an arbitrary 0 <  ≤ 1. All operations on this queue run in constant (expected, amortized) time, except Synchronize(ab) -- which is supported in O(Lab) expected time, Lab being ab's interval length at the moment of entering in this procedure. We point out and fix a mistake we had in [2]. Here, we mistakenly claimed we could implement remove in constant time on the low-frequency queue. Unfortunately, this is not true. We fix this mistake in the next section using amortization (this works also for the original solution): instead of deleting the least occurring pair, we remove the least frequent half of the pairs, when the queue is filled up to its max capacity. This gives amortized constant time for remove. We fill the low-frequency queue at most O(1/) times and hence it follows that our overall algorithm runs in O(n/) expected time. Implementation 3 The main differences between our theoretical proposal and the implementation here described are: 1. The skippable text representation: our implementation of this component uses only 50% of the space of the theoretical version. 2. The way we cluster pairs in the T P array: we replace in-place radix sorting with a very efficient and practical in-place clustering algorithm. 3. The queues implementation: we replace linked lists with more cache-efficient plain vectors of pairs. Moreover, we use a frequency cut-off of n2/3 to distinguish between high- frequency and low-frequency pairs (in [2] the cut-off was O(√ n)). This cut-off allows us to achieve linear running time for our clustering procedures while using sublinear space for the universal tables. 4. We show how to produce a more regular Re-Pair grammar and how to efficiently compress it. On average, our encoding uses almost exactly the information-theoretic minimum number of bits. P. Bille, I.L. Gørtz, and N. Prezza YY:5 Since we deal only with the ASCII alphabet, in our implementation we assume that the alphabet size σ is constant and, in particular, that we can fit alphabet characters in half a memory word. 3.1 A more space-efficient skippable text We represent the input string S as an array of n half-word locations. Note that grammar symbols can be as large as n, so they do not necessarily fit in half a memory word (since we assume w = log2 n). However we observe that -- whenever we perform a pair replacement -- the new grammar symbol is always followed by a blank character (because, after a replacement X → AB, we replace AB with X_): we therefore have available a full word for storing the grammar symbol. We use a word-packed bitvector M[1, . . . , n] to mark non-blank positions with a bit set. If M[i, i + 1] = 11, then the i-th text symbol is stored in S[i] (in half a word). If M[i, i + 1] = 10, then the i-th text symbol is stored in S[i, i + 1] (in a full word). Finally, we skip in constant time runs of blank characters as follows. If the run's length is shorter than or equal to w, then we skip the run querying in parallel w bits of M (i.e. extracting the leftmost bit set of some packed size-w sub-array of M). Otherwise, we explicitly store the run's length in a word: we keep a word array W[1, . . . , n/w] and store the length of the run starting in position i inside W[bi/wc]. The total size of our skippable text is 0.5n + o(n) words. 3.2 Pair clustering and queues implementation Note that our algorithm does not actually need the pairs to be sorted in the TP array; the correctness of our procedures is preserved if we just cluster text positions by character pairs. In this section we show how we achieve this task with a very practical linear-time and in-place procedure. We start by defining a frequency cut-off f = n2/3. Pairs with frequency larger than f are processed in the high-frequency phase. Let dHF be the number of distinct high- frequency pairs. Clearly, dHF · f ≤ n, so in the high-frequency phase we process at most dHF ≤ n/f = n1/3 pairs. Let ΣHF = {0, . . . , σ + dHF − 1} be the alphabet composed by the original alphabet Σ plus grammar symbols created during the high-frequency phase. We have that ΣHF < σ + n1/3. This, together with the assumption σ ∈ O(1), implies that a table directly addressing all pairs of symbols in the high-frequency phase contains no more than ΣHF2 = (n1/3 + σ)2 = O(n2/3) entries. The idea, at this point, is to use such tables to cluster the pairs contained in TP sub-arrays in-place (modulo the tables) and in linear time during the high-frequency phase. Algorithm 1 reports our clustering procedure. When entering in Algorithm 1, we assume that two tables C1, C2 : ΣHF × ΣHF → [0, . . . , n) have been pre-allocated. C1 is filled with 0, while C2 with NULL values. The algorithm uses these tables to cluster pairs in the input vector A and, before exiting, resets the used entries to 0 (in C1) or NULL (in C2). This is the intuition behind our clustering procedure. After counting pairs (first two for loops in Algorithm 1), C1[ab] = C2[ab] store the first position containing ab in the final clustered array. Then, inside our main procedure (while loop in Algorithm 1) we use an index j to scan A-positions left to right. The following two invariants are maintained: (i) A[0, . . . , j −1] is clustered, and (ii) A[C1[ab], . . . , C2[ab]−1] contains only pairs equal to ab. At each cycle, either value A[j] is already in the correct position (i.e. it contains a pair ab such that C1[ab] ≤ j < C2[ab]) and we increment j, or it contains a pair ab but j is not inside interval [C1[ab], C2[ab]). In such case, we place A[j] in the correct position (i.e. C2[ab]) with a swap operation and increment C2[ab] (since now A[C1[ab], . . . , C2[ab]] CVIT 2017 YY:6 Practical and Effective Re-Pair Compression contains only pairs equal to ab). Note that (a) j cannot be incremented more than A times (while condition), and (b) C2[ab] cannot be incremented more than fab times, fab being the number of occurrences of ab in the text positions contained in A (this is implied by our invariant (ii)). This implies that, in Algorithm 1: (a) Line 14 is executed at most A times, and (b) Lines 16-17 are ab∈A fab = A times (for simplicity ab ∈ A indicates that pair ab occurs in one of the text positions contained in A). Clearly, we spend O(A) time inside the three for loops in Algorithm 1. It follows that the whole clustering procedure runs in O(A) time. executed at mostP Algorithm 1: cluster(A) input behavior : Cluster A's entries by character pairs : Array A of text positions ab ← T.pair_starting_at(A[i]); C1[ab] = C1[ab] + 1; ab ← T.pair_starting_at(A[i]); if C2[ab] = N U LL then j ← j + C1[ab]; C1[ab] ← C2[ab] ← (j − C1[ab]); ab ← T.pair_starting_at(A[j]); if C1[ab] ≤ j < C2[ab] then 1 for i = 0, . . . ,A − 1 do 2 3 4 j ← 0; 5 for i = 0, . . . ,A − 1 do 6 7 8 9 10 j ← 0; 11 while j < A do 12 13 14 15 16 17 18 for i = 0, . . . ,A − 1 do 19 20 21 j ← j + 1; else swap(A, j, C2[ab]); C2[ab] ← C2[ab] + 1; ab ← T.pair_starting_at(A[i]); C1[ab] ← 0; C2[ab] ← N U LL; High-frequency queue Our high-frequency queue QHF is implemented simply as a matrix (i.e. a direct-access table) H : ΣHF × ΣHF → N3 mapping high-frequency pairs to their coordinates in the TP array: H[ab] = hPab, Lab, Fabi (these variables have the same meaning as in our original theoretical proposal). Then, QHF [ab] requires just an access on H, QHF .remove(ab) requires setting H[ab] to hN U LL, N U LL, N U LLi, QHF .contains(ab) is implemented by checking whether H[ab] does not contain N U LL values, QHF .decrease(ab) requires decrementing the third component of H[ab], and inserting hab, Pab, Lab, Fabi in QHF requires just setting H[ab] = hPab, Lab, Fabi. To compute QHF .max(), we just scan every entry of H and return the pair ab with the highest Fab. This operation takes O(ΣHF2) = O(n2/3) time. P. Bille, I.L. Gørtz, and N. Prezza YY:7 Low-frequency queue Let ¯Σ = {0, . . . , σ + d − 1} be the final alphabet including original characters from Σ and grammar symbols. Let moreover  > 0 be an arbitrarily small positive constant. We allow at most  · n pairs to be in the low-frequency queue at the same time. Our low-frequency queue QLF is implemented as a quadruple hH, F, maxf , exti, where: H : ¯Σ × ¯Σ → N3 is a hash table mapping low-frequency pairs to their coordinates in the T P array: H[ab] = hPab, Lab, Fabi. In this case, H is implemented with linear probing and only guarantees expected constant-time operations. We allocate 2 · n slots for H (maximum load factor is 0.5). F : [2, . . . , n2/3] → (¯Σ × ¯Σ)∗ is a vector mapping frequencies of pairs in the queue to (a superset) of all pairs with that frequency: throughout the execution of our algorithm, all pairs with frequency f are stored in vector F[f]. However, F[f] may contain also pairs that are no more in the queue or that have a frequency smaller than f (this happens because we amortize operations on F, read below). maxf is the frequency of the most frequent pair in the text. Note that this value can only decrease during computation. ext is an index such that all pairs in F[maxf][1, . . . , ext] have already been extracted from the queue (and thus processed). At this point, QLF [ab] requires just an access on H, and QLF .contains(ab) is implemented by checking whether H contains pair ab. QLF .decrease(ab) is implemented with a "lazy" let f be ab's frequency. We append ab at the end of F[f − 1], we decrement strategy: the third component of H[ab], but we do not remove ab from F[f − 1] (this would require time proportional to F[f − 1]). However, we keep F counters storing the number of deleted pairs in each F[i], and rebuild F[i] whenever the number of deleted pairs is above F[i]/2. The rebuilding process requires removing from F[i] pairs that are no longer in H or whose frequency is no longer i (this can be checked accessing H). It is easy to see that -- thanks to this amortization strategy -- rebuilding F's elements adds no asymptotic cost to our procedures. To insert hab, Pab, Lab, Fabi in QLF , we set H[ab] = hPab, Lab, Fabi and append ab at the end of F[Fab]. To compute QLF .max(), we access F[maxf][ext] for increasing values of ext until we find a pair that is in H and has frequency maxf. If ext reaches the end of F[maxf], we decrement maxf by one, reset ext to 0, and proceed with the search (note: ext needs to be reset to 0 also after rebuilding F[maxf]). Note that, thanks to our amortization policy on F and to the fact that maxf can only decrease, the overall time spent inside QLF .max() cannot exceed O(n). We can deal with queue overflows (i.e. cases where we insert more than  · n pairs in QLF ) as follows. We keep a counter storing the number of pairs in the queue (updating it each time we either extract the maximum or insert a new pair). Whenever this counter reaches size  · n, we remove from QLF the 0.5 · n pairs with the lowest frequency. It is easy to see that this operation takes amortized constant time over all insert operations on the queue. Analysis All operations in the high-frequency queue take constant amortized time except max(), which takes O(n2/3) time. Note that we call max() at most dHF ≤ n1/3 times (i.e. the maximum number of high-frequency pairs), therefore the overall time spent inside this function is O(n). We perform a constant number of operations for each text occurrence of a high-frequency pair. Being the overall number of occurrences of high-frequency pairs O(n), it follows that we spend overall O(n) time on the high-frequency queue. In the low-frequency queue, all operations take constant amortized expected time. Note that we may need to re-fill the queue (up to) O(1/) times, being its capacity O(· n). Again, CVIT 2017 YY:8 Practical and Effective Re-Pair Compression the total number of occurrences of low-frequency pairs cannot exceed n and we perform a constant number of operations on each pair occurrence every time the queue is re-filled, therefore we spend overall O(n/) expected time on the low-frequency queue; this time dominates the overall time of our algorithm. Our high-frequency queue takes O(ΣHF2) = O(n2/3) words of space, while our low- frequency queue takes  · n words of space for an arbitrarily small constant . Taking into account all components, the overall space used in RAM by our practical implementation is (including the skippable text) (1.5 + )n words, for some small positive constant  (where we hide o(n) terms inside n). 3.3 Compressing the final grammar The problem of succinctly representing straight line programs (SLPs) has lately been addressed in [16]. In this work, the authors propose an encoding of at most d log d + 2d bits for a grammar consisting of d symbols. This bound is very close to the information-theoretic lower bound of log(d!) + 2d ≈ d log d + 0.557d bits (also proved in the same paper), and considerably improves the straightforward encoding of 2d log d bits obtained by explicitly storing the two grammar symbols of each production. One of the drawbacks of this solution is, however, its running time of O(d1.5), which can become prohibitively high if the input text is not very compressible (i.e. d ≈ n). In this paragraph, we show how to exploit a degree of freedom in the Re-Pair algorithm specification (namely, the processing order of same-frequency pairs in the queue) in order to produce a more compressible grammar. Our Re-Pair variant runs with the same space/time bounds of our original proposal described in the previous sections. The algorithm for compressing the output grammar runs in optimal O(d) time and, on average, compresses the grammar with only a negligible overhead on top of the optimal log(d!) + 2d bits (see experimental section). Our strategy is the following. First of all note that, when choosing the pair with the highest frequency maxf from our queues, this pair is not univoquely determined (as there can be more than one pair with frequency maxf). Our idea is to choose the extraction order of pairs with frequency maxf in such a way that the output sequence of grammar productions is more compressible. We extract max-frequency pairs in increasing order according to the ordering ≺max defined as ab ≺max cd ⇔ max(a, b) < max(c, d). In the high-frequency queue, the maximum is extracted scanning all pairs in the queue; it follows that the extraction order can be easily modified to that defined by ≺max without affecting running times. In the low-frequency queue, as soon as we decrease maxf, we sort the pairs in F[maxf] according to ≺max. In theory, this task can easily be achieved in linear time and in-place by using in-place radix sorting [9]. In our implementation, considering that the pairs in F[maxf] are stored contiguously in main memory (i.e. cache locality can be exploited), we use C++ std's sort. At this point, note that the sequence of pairs extracted (left-to-right) from F[maxf] is ordered according to ≺max provided that F[maxf] is not modified (i.e. no pairs are added to it) after the sorting procedure. Note that we either remove or append pairs in F[maxf]. Removing pairs does not invalidate the ordering. We append some pair at the end of F[maxf] only when we extract a pair ab from the queue and ab is always followed (resp. preceded) by the same character c. In this case, after replacement X → ab, a new pair Xc (resp, cX) with frequency maxf appears in the text and is therefore appended at the end of F[maxf]. However, note that X is (by definition) larger than all symbols appearing in the text; it follows that order ≺max is preserved when appending Xc (resp, cX) at the end of F[maxf]. Let M be the number of distinct frequencies in the right-productions of the output grammar (i.e. frequencies of pairs at substitution time). Note that M can be much smaller than d (one P. Bille, I.L. Gørtz, and N. Prezza YY:9 boost cere dblp einstein english fib41 sources tm29 plain 800.00 439.92 200.00 800.00 800.00 255.50 200.00 256.00 7-Zip 0.162 5.00 21.90 1.16 194.29 0.450272 29.78 0.91866 bzip2 51.87 110.96 22.71 45.50 226.60 0.014203 37.32 0.031403 NAV 0.243 22.04 42.58 3.16 337.14 0.000307 77.06 0.000601 rp 0.087 8.50 23.91 1.46 181.55 0.000044 42.61 0.000132 Table 1 Size of the uncompressed (column plain) and compressed files. Space is expressed in MB. In half of the cases (the most repetitive ones), rp improves the compression rate of 7-Zip. to three orders of magnitude on real-case examples, as shown in the experimental section). We encode the output grammar G = {σ → a1b1, (σ + 1) → a2b2, . . . , (σ + d − 1) → adbd} as follows. We delta-encode (using Elias delta-encoding) the (at most) M increasing sub- sequences of max(a1, b1), . . . , max(ad, bd) in d log M(1 + o(1)) bits; we encode the lengths of these sub-sequences in M log(d/M)(1 + o(1)) bits; we store with Elias delta-encoding the sequence a1 − b1, . . . ,ad − bd in d log d(1 + o(1)) bits (note that this is a very pessimistic upper bound); we store a length-d bitvector recording whether ai > bi, for i = 1, . . . , d. In total, our encoding uses at most d(log d + log M + 1) + M log(d/M) + o(d log d) bits. Experimental results 4 We compared running times, memory usage, and compression rates of our [15] (rp) and Navarro's [14] (NAV) implementations of Re-Pair against the compression tools 7-Zip [1] (with maximum compression rate turned on, i.e. using option -mx=9), and bzip2 [4]. We ran all tools on two artificial extremely repetitive datasets -- fib41 and tm29 -- , on three real repetitive datasets -- boost, cere, and einstein -- , and on three real not-so- repetitive datasets -- dblp, english, and sources. All datasets except boost come from the pizza&chili corpus [13]. Dataset boost consists of concatenated versions of the C++ boost library [3], a collection that turns out ot be very repetitive. We moreover compressed with our tool all pizza&chili real datasets -- truncated to 50MB when bigger -- and compared the compressed files' sizes with the information-theoretic minimum number of bits needed to represent them. Recall that Re-Pair outputs a grammar consisting of d productions plus a text T ∈ ¯Σt, where ¯Σ = {0, . . . , σ + d − 1}, such that every XY ∈ ¯Σ2 appears at most once in T. It follows, from [16], that the minimum number of bits to represent the compressed file is log(d!) + 2d + t log(σ + d) ≈ d(log d + 0.557) + t log(σ + d). Table 1 reports the compressed file's sizes. rp compresses better than NAV: this is expected, since NAV does not compress the output grammar (i.e. 32-bits integers are used to represent grammar rules and the final text). Our tool improves in almost all cases the output of bzip2; this is also expected, considering the small maximum window size of this tool (900 KB). 7-Zip compresses better than rp in half of the cases. This is mainly due to the large dictionary size of 7-Zip and to the fact that LZ77 is inherently more powerful than grammar compression. On very repetitive files (boost, fib41, and tm29) and on dataset english, however, rp's compression rate is much better than that of 7-Zip. Working space of all tools during compression and decompression are reported in Table 2. Columns NAV (C) and rp (C) show that our goal of improving the state of the art's working CVIT 2017 YY:10 Practical and Effective Re-Pair Compression boost cere dblp einstein english fib41 sources tm29 rp (D) 6 136 162 17 1239 5 289 5 Table 2 RAM usage of the tools executed on the files of Table 1 during compression (C) and 7-Zip (D) 68 70 69 70 69 69 69 69 bzip2 (D) 4 4 4 4 4 4 4 4 NAV (D) 1 20 13 3 168 1 32 1 7-Zip (C) 683 683 683 683 683 683 683 683 bzip2 (C) 8 8 7 8 7 8 8 8 NAV (C) 9602 5281 2405 9606 9606 3068 2407 3074 rp (C) 4450 2838 1136 4381 5755 1665 1572 1667 decompression (D). Space is expressed in MB. boost cere dblp einstein english fib41 sources tm29 7-Zip (C) 212.86 525.77 135.40 154.15 833.08 36.50 117.99 47.88 bzip2 (C) 104.76 44.00 26.35 124.92 87.81 97.94 21.63 166.41 NAV (C) 179.95 82.56 73.24 196.49 458.19 25.36 81.46 24.23 rp (C) 1040.54 3817.68 1134.84 2118.36 25850.62 71.97 3459.01 101.32 7-Zip (D) 1.20 0.94 1.43 1.53 10.36 0.34 1.88 0.56 bzip2 (D) 12.63 14.15 4.40 16.06 29.21 4.34 4.66 4.43 NAV (D) 12.28 7.83 3.01 13.60 15.56 2.50 3.54 2.54 rp (D) 8.07 8.28 3.61 9.22 25.32 1.47 5.44 1.58 Table 3 Compression (C) and decompression (D) times of the tools executed on the files of Table 1. Times are expressed in seconds. dataset cere coreutils dblp dna einstein.de einstein.en english influenza kernel proteins sources pitches world_leaders d 1712283 1265102 517857 571507 35042 36707 2137984 299721 778089 1853756 1232862 2480114 209283 M 1441 2684 1995 1551 2720 2695 2375 2288 2617 2106 2584 2514 1670 plain 50 50 50 50 50 50 50 50 50 50 50 50 45 lower bound 5.02 3.76 6.16 15.36 0.09 0.09 12.90 1.58 2.11 26.06 11.64 24.18 0.68 rp 4.60 3.78 6.24 13.89 0.11 0.12 11.68 1.65 2.18 24.33 11.37 22.73 0.77 rate (%) 91.69 100.53 101.30 90.42 128.73 128.67 90.58 104.00 103.39 93.36 97.66 94.00 112.39 Table 4 Number of grammar rules d, number M of distinct pair frequencies at substitution time, uncompressed file size (column plain), information-theoretic lower bound for storing the grammar and the final compressed text, size of our compressed file (column rp), and compression rate of our succinct representation with respect to the information-theoretic lower bound. Space is expressed in MB. On average, our representation's size is only 2.8% larger than the information-theoretic lower bound. P. Bille, I.L. Gørtz, and N. Prezza YY:11 space is achieved: our tool reduces by a factor of 2 NAV's memory requirements. Note that the tools 7-Zip and bzip2 compress the file in windows of fixed size and therefore use a constant (and much smaller) working space. As far as decompression is concerned, rp uses a very variable working space across the datasets, with very repetitive files being decompressed in much less space than less repetitive ones. In all cases, rp uses much less working space during decompression than compression; this space is about one order of magnitude larger than that of NAV. The efficiency of our compressor in terms of compression rate and working space is paid in terms of running times. As shown in Table 3 (first 5 columns), rp is one to two orders of magnitude slower than NAV, despite their theoretical running times being the same (linear). We suspect this is due to the large number of calls to our clustering procedure on the array TP and to our amortization policies (which require to re-build our structures from time to time in order to keep space usage under control). Needless to say, the highly-optimized compressors 7-Zip and bzip2 outperform rp in terms of running times (except on extremely high repetitive datasets). On the other hand, our decompressor turns out to be very fast: rp decompresses faster than bzip2 and in comparable times with respect to NAV and -- except on very repetitive datasets -- 7-Zip. On very repetitive datasets, rp's decompressor is one order of magnitude slower than 7-Zip. To conclude, Table 4 displays the compression rate of our tool on 13 real datasets from the pizza&chili corpus. The table shows that the number M of distinct pair frequencies at substitution time is one to three orders of magnitude smaller than the number d of rules; this justifies the grammar compression strategy introduced in Section 3.3. In column 5 we show the information-theoretic minimum number of MB needed to store the compressed file, which can be directly compared to the size of our output (column 6). In the last column we report the efficiency of our compressed representation with respect to the information-theoretic minimum. It is very interesting to observe that our representation gets always very close to the lower bound, improving it (i.e. achieving compression) in half of the cases. On average, we use just 2.8% more space than the lower bound. Interestingly, our grammar representation achieves better compression on less compressible files, rather than on those that result in a very small grammar. References 7-Zip: a file archiver with a high compression ratio. http://www.7-zip.org/. Accessed: 2016-04-06. Philip Bille, Inge Li Gørtz, and Nicola Prezza. Space-Efficient Re-Pair Compression. In Data Compression Conference (DCC), 2017. IEEE, 2017. boost: free peer-reviewed portable c++ source libraries. https://github.com/boostorg. Accessed: 2016-04-06. bzip2: a freely available, patent free, high-quality data compressor. http://www.bzip. org/. Accessed: 2016-04-06. 1 2 3 4 5 Moses Charikar, Eric Lehman, Ding Liu, Rina Panigrahy, Manoj Prabhakaran, Amit Sahai, IEEE Transactions on Information and Abhi Shelat. The smallest grammar problem. Theory, 51(7):2554 -- 2576, 2005. Francisco Claude, Antonio Farina, Miguel A Martínez-Prieto, and Gonzalo Navarro. Com- pressed q-gram indexing for highly repetitive biological sequences. In BioInformatics and BioEngineering (BIBE), 2010 IEEE International Conference on, pages 86 -- 91. IEEE, 2010. 6 CVIT 2017 YY:12 Practical and Effective Re-Pair Compression 7 8 Francisco Claude, Antonio Fariña, Miguel A Martínez-Prieto, and Gonzalo Navarro. In- dexes for highly repetitive document collections. In Proceedings of the 20th ACM interna- tional conference on Information and knowledge management, pages 463 -- 468. ACM, 2011. Francisco Claude and Gonzalo Navarro. Fast and compact web graph representations. ACM Trans. Web, 4(4):16:1 -- 16:31, 2010. 9 Gianni Franceschini, S. Muthukrishnan, and Mihai Patrascu. Radix sorting with no extra space. In Proc. 15th ESA, pages 194 -- 205, 2007. 10 Rodrigo González and Gonzalo Navarro. Compressed text indexes with fast locate. In Proc. 11 N Jesper Larsson and Alistair Moffat. Off-line dictionary-based compression. Proceedings 18th CPM, pages 216 -- 227, 2007. of the IEEE, 88(11):1722 -- 1732, 2000. 12 Gonzalo Navarro and Luís Russo. Re-pair achieves high-order entropy. In Proc. 18th DCC, page 537, 2008. Pizza&chili corpus: Compressed indexes and their testbeds. http://pizzachili.dcc. uchile.cl/. Accessed: 2016-04-06. 13 14 Re-Pair compression and decompression (2010). ~gnavarro/software/index.html. Accessed: 2016-04-06. https://www.dcc.uchile.cl/ 15 Re-Pair: A space-efficient compressor based on the re-pair grammar. https://github. com/nicolaprezza/Re-Pair. Accessed: 2016-04-06. 16 Yasuo Tabei, Yoshimasa Takabatake, and Hiroshi Sakamoto. A succinct grammar compres- sion. In Annual Symposium on Combinatorial Pattern Matching, pages 235 -- 246. Springer, 2013. 17 Raymond Wan. Browsing and Searching Compressed Documents. PhD thesis, Department of Computer Science and Software Engineering, University of Melbourne., 2003.
1009.4214
2
1009
2010-09-30T07:48:15
A Versatile Algorithm to Generate Various Combinatorial Structures
[ "cs.DS" ]
Algorithms to generate various combinatorial structures find tremendous importance in computer science. In this paper, we begin by reviewing an algorithm proposed by Rohl that generates all unique permutations of a list of elements which possibly contains repetitions, taking some or all of the elements at a time, in any imposed order. The algorithm uses an auxiliary array that maintains the number of occurrences of each unique element in the input list. We provide a proof of correctness of the algorithm. We then show how one can efficiently generate other combinatorial structures like combinations, subsets, n-Parenthesizations, derangements and integer partitions & compositions with minor changes to the same algorithm.
cs.DS
cs
A Versatile Algorithm to Generate Various Combinatorial Structures Pramod Ganapathi∗, Rama B† August 23, 2018 Abstract Algorithms to generate various combinatorial structures find tremen- dous importance in computer science. In this paper, we begin by reviewing an algorithm proposed by Rohl [24] that generates all unique permutations of a list of elements which possibly contains repetitions, taking some or all of the elements at a time, in any imposed order. The algorithm uses an auxiliary array that maintains the number of occurrences of each unique element in the input list. We provide a proof of correctness of the algo- rithm. We then show how one can efficiently generate other combinatorial structures like combinations, subsets, n-Parenthesizations, derangements and integer partitions & compositions with minor changes to the same algorithm. 1 Introduction Algorithms which generate combinatorial structures like permutations, combi- nations, etc. come under the broad category of combinatorial algorithms [16]. These algorithms find importance in areas like Cryptography, Molecular Bi- ology, Optimization, Graph Theory, etc. Combinatorial algorithms have had a long and distinguished history. Surveys by Akl [1], Sedgewick [27], Ord Smith [21, 22], Lehmer [18], and of course Knuth's thorough treatment [12, 13], successfully capture the most important developments over the years. The lit- erature is clearly too large for us to do complete justice. We shall instead focus on those which have directly impacted our work. The well known algorithms which solve the problem of generating all n! per- mutations of a list of n unique elements are Heap Permute [9], Ives [11] and Johnson-Trotter [29]. In addition, interesting variations to the problem are - algorithms which generate only unique permutations of a list of elements with possibly repeated elements, like [3, 5, 25], algorithms which generate permuta- tions in lexicographic order, like [20, 26, 28] and algorithms which genenerate ∗Associate Software Engineer, IBM, India; [email protected] †Graduate Student, Department of Computer Science and Automation, Indian Institute of Science, India; [email protected] 1 permutations taking r(< n) elements at a time. With regard to these variations, the most complete algorithm, in our opinion, is the one proposed by Rohl [24] which possesses the following salient features: 1. Generates all permutations of a list considering some or all elements at a time 2. Generates only unique permutations 3. Generates permutations in any imposed order It is of course possible to extend any permutation generating algorithm to ex- hibit all of the above features. However, when such naive algorithms are given inputs similar to aaaaaaaaaaaaaaaaaaab 1 , the number of wasteful computations can be unmanageably huge. Clearly, the need for specially tailored algorithms is justified. We provide a rigorous proof of correctness of Rohl's algorithm. We also show interesting adaptations of the algorithm to generate various other combinatorial structures efficiently. The paper is organised as follows: we begin by introducing terminologies and notations that will be used in the paper in Section 2, and presenting Rohl's algorithm in Section 3. Section 4 contains a detailed analysis of the algorithm, which also includes the proof of correctness of the algorithm (missing in Rohl's paper). We then present various efficient extensions of Rohl's algorithm in Section 5, to generate many more combinatorial structures. Rohl's algorithm involves two stages. The first stage builds up an auxiliary array that maintains the number of occurrences of each unique element in the input list. The second stage uses this auxiliary array to effect and generates the required combinatorial structure. We present a recursive representation of the algorithm. It would be quite easy to transform the recursive version to an iterative one [23]. 2 Preliminaries In this section, we introduce the key terms, concepts and notations that will be used in the paper. 2.1 Basic Definitions Set: A collection of elements without repetitions List: A collection of elements possibly with repetitions Permutation: A permutation of a list is an arrangement of the elements of the list in any order, taking some or all elements at a time E.g: Consider a list {a, b, c, d}; Various permutations are - {d, a, b, c}, {a, d, c}, {b, d, a}, {a, d}, {d, c}, {b, a} 1There are 20 unique permutations of length 20 2 r-Permutation Set: The r-permutation set of a list is defined as the set of all possible r-permutations of the list, where an r-permutation is defined as a permutation taking exactly r (1 ≤ r ≤ size(list)) elements at a time E.g: Consider a list {a, b, c}. We get: {a, b, c}, {ab, ac, ba, bc, ca, cb} and {abc, acb, bac, bca, cab, cba}2 as the 1-permutation set, 2-permutation set and 3- permutation set, respectively. The algorithm takes as input: • A list of n elements to permute, called input list: L = {l1, l2, . . . , ln} containing p(≤ n) unique elements • An integer r, 1 ≤ r ≤ n, which denotes the number of elements to be taken at a time during permuting • A set of p elements which are actually the p unique elements of L in a particular sequence, called Order Set (or just Order): O = {o1, o2, . . . , op} i = {pr 2 , . . . , P r It produces as output the r-permutation set of L, which is a set of m r- 1 , P r permutations: P r(L) = {P r is in turn is a list of r elements: P r i1, . . . , pr ir} ∀ (1 ≤ i ≤ m). The algorithm works such that P r(L) follows the order O (definition and explanation in Section 2.2). Quite obviously, pr ij ∈ L ∀ (1 ≤ i ≤ m), (1 ≤ j ≤ r). Note that we use the terms r-permutation (set) and permutation (set) interchangeably, if clear from the context. m} where each P r i 2.2 Order of Permutation Set Consider the 3-permutation set of the list {a, b, c} : {abc, acb, bac, bca, cab, cba}. We see that the permutations are in lexicographic order, i.e they follow the order {a, b, c}. At the same time, the 3-permutation set {bac, bca, abc, acb, cba, cab} follows the order {b, a, c}. We shall now introduce a formal definition of what we mean when we say P r(L) follows the order O. Discriminating Index: The discriminating index between two different r- permutations is the first (minimum) index in both permutations at which the elements differ from each other. Given two permutations P r b , we denote the discriminating index as a and P r D(P r a, P r b ) = min{x : pr ax 6= pr bx} ij ) denotes the index of the element pr Also, assume that IO(pr ij) = x ⇐⇒ ox = pr IO(pr ij. ij in O. Thus P r(L) is said to follow an order O if: • ∀ (1 ≤ i ≤ m), (1 ≤ j ≤ r) pr ij ∈ O 2Each permutation in an r-permutation set is actually a list of elements. For compactness, we represent the elements in concatenated form. 3 • For every pair of permutations in P r(L), the elements at the discriminat- ing index have the same positions relative to each other in O, as do the pair of permutations in P r(L) ∀ (1 ≤ a < b ≤ m) : ad) < IO(pr IO(pr bd) where d = D(P r a, P r b ). It has to be noted that similar definitions hold for both sets of combinations and derangements too. 2.3 Auxiliary Array Central to the algorithm is an auxiliary array denoted as CountArray. It is an array of integers built in such a way that CountArray[i] gives the number of occurrences of element oi in the input list L. CountArray is of size p as it is maintained parallel to O. As an example, consider L = {a, c, b, a, a, c}, O = {c, a, b}; here n = 6 and p = 3. We have o1 (= c) occurring twice, o2 (= a) occurring thrice and o3 (= b) occurring once. Thus we must have CountArray = {2, 3, 1}. Instead, if we had O = {a, b, c}, we would have CountArray = {3, 1, 2}. 3 The Algorithm In this section, we introduce the algorithm. The algorithm takes L, r and O as input and produces P r(L) as output, while ensuring that P r(L) follows O. The first stage involves building CountArray while the second stage involves recursive generation of P r(L) using CountArray. 3.1 Building CountArray The first stage involves building CountArray parallel to O in a way that CountArray[i] is an integer which represents the number of occurrences of oi in L. Procedure 1 is a pseudocode representation of how to build CountArray, given L and O. We assume the existence of the function IO which takes an element of L as a parameter and returns the position of the element in O. We can say IO(li) = x ⇔ ox = li. A naive implementation of IO would be to perform a linear search over O, and this would have a worst case runtime of O(p). However, if needed, we can achieve O(1) runtime using hash functions. We leave the implementation details to the reader. 3.2 Generating Permutations Procedure 1 builds CountArray. The second stage involves using the recursive routine APR to generate P r(L), following order O, as output. To this end, we use an output array R. Procedure 2 is a pseudocode representation of APR. It assumes non-local existence of the following: CountArray, O, r, p and R. Also, it has a lo- cal parameter - an integer index. Thus the function's header takes the form 4 Procedure 1 : Building CountArray 1: Input: L and O 2: Output: CountArray 3: CountArray[1 . . . p] ← 0 4: for i ← 1 to n do 5: 6: pos ← IO(li) CountArray[pos] ← CountArray[pos] + 1 APR(index). It is invoked by the function call APR(1). As APR recursively calls itself (1 ≤ index ≤ r), R[1, . . . , r] is populated using CountArray. Procedure 2 : APR(index) - Permutations 1: Local: index 2: Global: CountArray, O, r, p and R 3: if index > r then Print R[1, . . . , r] 4: return 5: 6: else 7: 8: for i ← 1 to p do if CountArray[i] ≥ 1 then 9: 10: 11: 12: R[index] ← oi CountArray[i] ← CountArray[i] − 1 APR(index + 1) CountArray[i] ← CountArray[i] + 1 4 Algorithm Analysis In this section, we begin by explaining how APR works and showing the recur- sion tree for a particular example. We then give a formal proof of its correctness. We conclude by establishing an upper bound on the runtime of APR. We know that the contents of CountArray are constantly changing. Given a particular index in R we assign to it an element oi ∈ O (1 ≤ i ≤ p) only if CountArray[i] ≥ 1, at that particular time. We call the assignment minimal if we choose the oi corresponding to the minimum i for which CountArray[i] ≥ 1. More formally, we can say that an assignment of oi to a particular index in R is minimal iff ∄ ox ∈ O; 1 ≤ x < i such that CountArray[x] ≥ 1. Also we say populates R[i . . . j] minimally to signify that minimal assignment is done at every index from i to j (inclusive). 5 4.1 Recursion Tree Let us analyse how APR functions by referring to Procedure 2. The function, at any recursion level, begins by searching for the first available element, i.e. the first index i at which CountArray[i] ≥ 1 (lines 7-8). Once found, the corresponding element (oi) is assigned at the current index in R (line 9). It then decrements CountArray[i] to reflect the fact that that particular element was assigned (line 10). After that, there is a recursive call and the control moves to the next recursion level and deeper thereafter performing the same set of functions (lines 7-10). Once the control returns to the current recursion level, it de-assigns the element that was assigned to the current index in R, by incrementing CountArray[i] (line 10). It then moves to the next available element in CountArray and performs the process of assigning and recursion all over again. CA = {2,2} R = {} APR(1) index=1 CA = {1,2} R = {1} APR(2) index=1 CA = {2,1} R = {2} APR(2) index=2 CA = {0,2} R = {1, 1} APR(3) index=3 CA = {0,1} R = {1, 1, 2} APR(4) index=4 R = {1, 1, 2} index=2 CA = {1,1} R = {1, 2} APR(3) index=2 CA = {1,1} R = {2, 1} APR(3) index=3 CA = {0,1} R = {1, 2, 1} APR(4) index=3 CA = {1,0} R = {1, 2, 2} APR(4) index=3 CA = {0,1} R = {2, 1, 1} APR(4) index=3 CA = {1,0} R = {2, 1, 2} APR(4) index=4 index =4 index=4 index=4 R = {1, 2, 1} R = {1, 2, 2} R = {2, 1, 1} R = {2, 1, 2} index=2 CA = {2,0} R = {2, 2} APR(3) index=3 CA = {1,0} R = {2, 2, 1} APR(4) index =4 R = {2, 2, 1} Figure 1: Recursion Tree of APR for L = {1, 1, 2, 2}; r = 3; O = {1, 2} We venture an example to better illustrate the process. Assume we have L = {1, 1, 2, 2}, r = 3 and O = {1, 2}. When L and O are fed to Proce- dure 1, we would obtain CountArray[1] = CountArray[2] = 2. Procedure 2 is then invoked. The recursion tree that would be obtained is shown in Figure 1 (CountArray is abbreviated to CA). The root of the tree represents the initial state, i.e. CountArray = {2, 2} and R = {}. Every descendant of the root represents a particular recursion depth, indicated by the value of index. At ev- 6 ery node, we indicate the values in CountArray and R just before going down to the next recursion level followed by the function call that initiates the next recursion level. Once we go four levels deep into the recursion, i.e. index = 4, the contents of R would be output because index > r (lines 3-4 of Procedure 2). The control then returns to the previous recursion level (line 5). We observe that P 3(L), i.e. the collection of all leaves of the recursion tree from left to right, follows the order {1, 2}. 4.2 Proof of Correctness In this section, we shall use Pi to denote a general r-permutation instead of i . Also, we shall use Pi[x], instead of pix, to denote the xth element of the ith P r permutation. Theorem 1. The algorithm generates only valid permutations of L. Proof. We assign an element oi to any particular index in R only if we have CountArray[i] ≥ 1. Also, we decrement or increment CountArray[i] whenever oi is assigned or de-assigned, respectively. This process ensures that APR only assigns elements that were actually present in L and no element is assigned more times than it occurs. Hence we can say that every permutation that is output is valid. Theorem 2. The algorithm generates only unique permutations of L following order O. Before we prove Theorem 2, we must understand how the algorithm gener- ates a permutation subsequent to an already generated one. Once a permutation is output, the program searches backwards from the end of R for an index where it can assign, from the available elements, an element that has a higher position in O than the previously assigned element. This means that, if ox were assigned at a particular index, the algorithm checks if it can assign any among ox+1 . . . op at the same index. At the first instance (referred to as Property 1) of such an in- dex, the algorithm assigns the first among (referred to as Property 2) ox+1 . . . op, whichever is available. Note that this index would be the discriminating index between the previously output permutation and the next permutation that is going to be output. Once this is done, the program populates the rest of R minimally (referred to as Property 3). Proof of Theorem 2. This process ensures that, between two consecutive per- mutations, we will have at least one index where the elements differ. Given that at this index, i.e. discriminating index, we assign one of ox+1 . . . op, we can be sure that the permutation generated subsequent to a particular permutation will occupy a higher position in P r(L) (when it follows order O). Lemma 3. Given three consecutive permutations Pi, Pj and Pk, we have: D(Pi, Pj) ≥ D(Pi, Pk). 7 Proof. This shall be proved by contradiction. Let us assume we have Pi, Pj, Pj such that dij < dik (1) where dij , djk, dik represent each of D(Pi, Pj), D(Pj, Pk), D(Pi, Pk), respec- tively. By the definition of discriminating index in Section 2.2, we have the following equations. and Pi[1 . . . (dij − 1)] = Pj[1 . . . (dij − 1)] IO(Pi[dij]) < IO(Pj[dij ]) Pi[1 . . . (dik − 1)] = Pk[1 . . . (dik − 1)] IO(Pi[dik]) < IO(Pk[dik]) (2) (3) (4) (5) From equations 1 and 4, we can say Pk[dij ] = Pi[dij ]. By using this in equa- tion 3, we get IO(Pk[dij ]) < IO(Pj[dij ]) Also, from equations 2 and 4 and equation 1, we get Pk[1 . . . (dij − 1)] = Pj[1 . . . (dij − 1)] (6) (7) Equations 6 and 7 imply that Pk comes before Pj, when order of consideration is O, which is a contradiction to the order of the permutations. This in turn implies that the initial assumption is wrong. Corollary 4. D(Pj, Pk) ≥ D(Pi, Pk). Proof. Equations 2 and 4 follow from the definition of discriminating index. From Lemma 3 we have dij ≥ dik, thus we get Pk[1 . . . (dik − 1)] = Pj[1 . . . (dik − 1)] (8) Thus the corollary follows. Lemma 5. Given two successive permutations that APR generates, say Pa and Pb, ∄ Px ∈ (P r(L)/{Pa, Pb}): such that Px occurs between Pa and Pb.3 Proof. This shall be proved by contradiction. Assume there exists such a Px. Let us take dab = D(Pa, Pb), dax = D(Pa, Px) and dxb = D(Px, Pb). By the analysis of how APR generates a permutation subsequent to an already generated one dax ≯ dab dxb ≯ dab [From Property 1] [From Property 3] (9) (10) 3A/{A1, A2} Denotes A excluding A1 and A2 8 Also we have dax ≮ dab from Lemma 3 and dxb ≮ dab from Corollary 4. Thus dax = dbx = dab(= λ say) is the only possibility. For Px to be between Pa and Pb: IO(Pa[λ]) < IO(Px[λ]) < IO(Pb[λ]). This is a direct contradiction to Property 2. Thus we can have no Px in between Pa and Pb. Theorem 6. The algorithm generates all r-permutations of L. Proof. We begin by proving that APR correctly generates the first permuta- tion. By Lemma 5, we have proved that the process of generating the next permutation given the current one is accurate in that the immediate next per- mutation, in accordance with the order O, is generated. We then prove that APR terminates once all permutations are generated. At the beginning of the algorithm, we perform a minimal assignment at the first index, i.e. index = 1. The program then moves down a recursion level and once again performs a minimal assignment. This process continues until the last recursion level. In the (r + 1)th recursion level, the program outputs the permutation. Clearly the first permutation that would be output by APR would be formed by populating R[1 . . . r] minimally. The program control returns from a level of recursion only after looping in [1, p] is complete, i.e. when there are no more available elements that can be allotted at that corresponding index in R. We know that the range [1, p] is finite because the size of L is finite. Also the maximum recursion depth of the program is finite because r is finite. This would ensure that every recursion level would eventually end which in turn ensures that the program will eventually terminate. 4.3 Running Times To establish an upper bound on the running time of APR, let us analyse the recursion tree shown in Figure 1. We see that the number of leaves are exactly P r(L). Each of the equal to the number of unique r-permutations of L, i.e. leaves are exactly (r + 1) levels below the root. The critical operations, i.e. looping and searching for available elements, are done on the first r levels.4 At each level, we loop in the range [1, p]. Thus we can say that the running time of APR is bounded by O (P r(L) × r × p) in the worst case. It is to be noted that the runtime of Procedure 1 has been ignored in com- parison to the runtime of Procedure 2. 5 Extensions In this section we show how the smallest of changes to Procedure 2 helps us generate many more combinatorial structures. Please note that the proof of correctness of each of the following algorithms follows trivially from the rigorous analysis in Section 4.2. 4In the (r + 1)th level, the permutations are output. 9 5.1 Derangements A derangement of a list is a permutation of the list in which none of the ele- ments appear in their original positions. Some previous work on derangement generating algorithms can be found in [15, 19]. With just two changes to Procedure 2, we are able to generate derangements - • Non-local existence of L, in addition to the other entities, is required • Before assigning an element at a particular index, we perform an additional check to ensure that the same element does not occur at the exact same index in L, i.e., if we were to assign oi to R[index], we would need to ensure that lindex 6= oi The procedure shall be referred to as APR2 (shown in Procedure 3). It is invoked by the call APR2(1). All we do is perform an additional check to ensure that the element being assigned at the current position does not appear in L at the same position (Line 8). CountArray is built exactly as was illustrated in Procedure 1. Extending the algorithm to generate partial derangements, like in [14], is easily done. Figure 2 shows the recursion tree when we generate derangements of L = {1, 2, 3}; r = 3 and O = {1, 2, 3}. It is to be noted that the program can output r-derangements, as well all derangements following an imposed order. Procedure 3 : APR2(index) - Derangements 1: Local: index 2: Global: CountArray, O, r, p and R 3: if index > r then Print R[1, . . . , r] 4: return 5: 6: else 7: 8: for i ← 1 to p do if CountArray[i] ≥ 1 and lindex 6= oi then 9: 10: 11: 12: R[index] ← oi CountArray[i] ← CountArray[i] − 1 APR2(index + 1) CountArray[i] ← CountArray[i] + 1 5.2 Combinations A combination of a list of elements is a selection of some or all of the elements. It is a selection where the sequence of elements in the selection is not important. Some combination generating algorithms that have been proposed are Chase [4], Ehrlich [7, 8] and Lam-Soicher [17]. 10 CA = {1,1,1} R = {} APR2(1) index=1 CA = {1,0,1} R = {2} APR2(2) index=2 index=2 CA = {0,0,1} CA = {1,0,0} R = {2, 1} APR2(3) R = {2, 3} APR2(3) ∅ index=3 CA = {0,0,0} R = {2, 3, 1} APR2(4) index=4 R = {2, 3, 1} index=1 CA = {1,1,0} R = {3} APR2(2) index=2 CA = {0,1,0} R = {3, 1} APR2(3) index=3 CA = {0,0,0} R = {3, 1, 2} APR2(4) index=4 R = {3, 1, 2} Figure 2: Recursion Tree of APR2: L = {1, 2, 3}; r = 3 and O = {1, 2, 3} CA = {1,1,1} R = {} APR3(1) index = 1 CA = {1,0,1} R = {b} APR3(2) index = 2 CA = {1,0,0} R = {b, c} APR3(3) index = 3 R = {b, c} index = 1 CA = {0,1,1} R = {a} APR3(2) index = 2 index = 2 CA = {0,0,1} CA = {0,1,0} R = {a, b} APR3(3) R = {a, c} APR3(3) index = 3 index = 3 R = {a, b} R = {a, c} index = 1 CA = {1,1,0} R = {c} APR3(2) ∅ Figure 3: Recursion Tree of APR3 for L = {a, b, c}; r = 2 11 We would require to make just one change to Procedure 2 to be able to produce all possible r-combinations5 of an input list. The new procedure shall be referred to as APR3 (shown in Procedure 4). All we do is - before assigning an element at a particular index in R, we make sure that the element occupies a position in O that is greater than the position of element at the previous index, in O. At the first index however, we may assign any element. The change is in Line 8 of Procedure 4. CountArray is built in exactly as was illustrated in Procedure 1. By changing, the condition i ≥ IO(R[index − 1]) to i > IO(R[index − 1]), we can get combinations which contain no repeated elements. The recursion tree obtained when we generate all combinations of L = {a, b, c} with r = 2 and O = {a, b, c} is shown in Figure 3. Procedure 4 : APR3(index) - Combinations 1: Local: index 2: Global: CountArray, O, r, p and R 3: if index > r then Print R[1, . . . , r] 4: return 5: 6: else 7: for i ← 1 to p do 8: 9: 10: 11: 12: if CountArray[i] ≥ 1 and (index = 1 or i ≥ IO(R[index − 1])) then R[index] ← oi CountArray[i] ← CountArray[i] − 1 APR3(index + 1) CountArray[i] ← CountArray[i] + 1 As is evident from Figure 3, there can be many wasteful branches with certain kinds of input to APR3. For example, if we were to have L = {a, b, . . . , y, z}, r = 26 and O = {a, b, . . . , y, z}, we would have a recursion tree similar to Figure 4, where branches ending with ∅ denote wasteful branches, i.e. recursion branches that do not produce any output. All unnecessary computations are because we loop from o1 . . . op at every index. However, based on two simple observations, we can completely eliminate all wasteful branches 1. Once ox is assigned at a particular index, subsequent indices can only contain one of ox+1 . . . op 2. In the case where we have already assigned elements to the first β indices of R, and R[β] = oy, we need not loop if we are sure that there are fewer than (r − β) elements left over, i.e., if Pp i=y CountArray[i] < (r − β), we can terminate looping in the current recursion level and return to the previous recursion level 5Definition analogous to definition of r-permutation. 12 26 times CA = { z } { 1, . . . , 1} R = {} APR3(1) index = 1 index = 1 CA = {0,1,. . . ,1} CA = {1,0,1,. . . ,1} . . . ∅ R = {a} APR3(2) R = {b} APR3(2) . . . . . . index = 26 index = 25 CA = {0,0,. . . ,0} R = {a, b, . . . , y, z} CA = {1,0,. . . ,0} R = {b, c, . . . , y, z} APR3(27) APR3(26) index = 27 ∅ R = {a, b, . . . , y, z} index = 1 CA = {1,. . . ,1,0} R = {z} APR3(2) ∅ Figure 4: Recursion Tree of APR3 for L = {a, b, c, . . . , z}; r = 26; O = {a, b, . . . , z} CA = {1,1,1,1} R = {} APR3Π(1) index=1 CA = {0,1,1,1} R = {a} APR3Π(2) index=2 CA = {0,0,1,1} R = {a, b} APR3Π(3) index=3 index=3 CA = {0,0,0,1} CA = {0,0,1,0} R = {a, b, c} APR3Π(4) R = {a, b, d} APR3Π(4) index=2 CA = {0,1,0,1} R = {a, c} APR3Π(3) index=3 CA = {0,1,0,0} R = {a, c, d} APR3Π(4) index=4 index=4 index =4 R = {a, c, d} R = {a, b, c} R = {a, b, d} index=1 CA = {1,0,1,1} R = {b} APR3Π(2) index=2 CA = {1,0,0,1} R = {b, c} APR3Π(3) index=3 CA = {1,0,0,0} R = {b, c, d} APR3Π(4) index=4 R = {b, c, d} Figure 5: Recursion Tree of APR3Π for L = {a, b, c, d}; r = 3; O = {a, b, c, d} 13 Procedure 5 : Building CumCA 1: CumCA[1] ← 0 2: for i ← 1 to p do 3: CumCA[i + 1] ← CumCA[i] + CountArray[i] Procedure 6 : APR3Π(index) - Combinations Efficiently 1: Local: index 2: Global: CumCA, CountArray, O, r, p and R 3: if index > r then Print R[1, . . . , r] 4: return 5: 6: else 7: 8: while (CumCA[p + 1] − CumCA[i + 1] + CountArray[i]) > (r − index) i ← IO(R[index − 1]) do 9: 10: 11: 12: 13: 14: if CountArray[i] ≥ 1 then R[index] ← oi CountArray[i] ← CountArray[i] − 1 APR3Π(index + 1) CountArray[i] ← CountArray[i] + 1 i ← i + 1 This means that in Line 7 of Procedure 4, the loop limits would need to be made tighter. For simplicity, we modify the definition of IO(element) to return 0 if element /∈ O. Also, we assign to R[0] an element that does not exist in O. This would mean that IO(R[0]) = 0. Now, Point 1 indicates that we can begin looping from IO(R[index − 1]) instead of 1. To incorporate Point 2, we build a Cumulative Array [2] on CountArray. It is called CumCA and is of size (p + 1). It is built such that (CumCA[y + 1] − CumCA[x]) = Py i=x CountArray[i]. A quick implementation is shown Procedure 5. It is to be noted that CumCA reflects CountArray values at the beginning. We know that CountArray values are constantly changing. Thus we can use CumCA only for indices where CountArray values are known to have not changed. Procedure 6 is a pseudocode representation of the modified version of APR3. This is denoted by APR3Π. The effectiveness of APR3Π is made apparent in Figure 5. Analogous to the argument in Section 4.3, the running time of APR3Π is in O((n − r + 1) × r × C r(L)) 5.3 Catalan Families In this section, we show how the algorithm can be modified to output all possible valid parenthesizations of (n + 1) factors. A valid parenthesization of (n + 1) 14 factors can be defined as a sequence of n opening brackets and n closing brackets with the condition that at no point in the sequence should the number of closing brackets be greater than the number of opening brackets. We shall refer to the set of all possible valid parenthesizations of (n+1) factors as n-Parenthesizations. Some previous work can be found in [6, 12]. Procedure 7 : Building CountArray 1: Input: n 2: Output: CountArray 3: CountArray[1] ← n 4: CountArray[2] ← n Procedure 8 : APR4(index) - n-Parenthesizations 1: Local: index 2: Global: CountArray, n, O and R 3: if index > 2n then Print R[1, . . . , 2n] 4: return 5: 6: else 7: 8: for i = 1 to 2 do if (i 6= 2 or CountArray[2] > CountArray[1]) and CountArray[i] ≥ 1 then 9: 10: 11: 12: R[index] ← oi CountArray[i] ← CountArray[i] − 1 APR4(index + 1) CountArray[i] ← CountArray[i] + 1 The input to the algorithm is n. We initialize CountArray such that CountArray[1] = CountArray[2] = n. This can be viewed as an input list of n opening brackets and n closing brackets (p = 2). We then generate all pos- sible permutations of this input list using CountArray and make sure that at no point in a permutation we assign more closing brackets than opening brackets. We set o1 = "(" and o2 = ")". Once again, we see that we generate a different combinatorial structure us- ing pretty much the same algorithm. The building of CountArray is shown in Procedure 7 and the recursive generation of parenthesizations is shown in Procedure 8. The recursive procedure is called APR4. 5.4 Subsets True to the formula 2n = Pn i(cid:1), we know that all subsets of a list can be generated using an algorithm that generates all r-combinations. This is i=0 (cid:0)n 15 Procedure 9 : APR5(index) - Subsets 1: Local: index 2: Global: CountArray, O, n, p and R 3: Print R[1, . . . , index] 4: if index > n then 5: 6: else 7: for i ← 1 to p do return 8: 9: 10: 11: 12: if CountArray[i] ≥ 1 and (index = 1 or i > IO(R[index − 1])) then R[index] ← oi CountArray[i] ← CountArray[i] − 1 APR5(index + 1) CountArray[i] ← CountArray[i] + 1 achieved by calling the r-combinations generating algorithm successively with: 0 ≤ r ≤ n. However, the structure of APR allows us to do it more efficiently. All subsets of a list of n elements can be obtained by calling APR5 (shown in Procedure 9). It is a modified version of APR3 (shown in Procedure 4) with r = n and the Print statement before the if block. CountArray is again built exactly as was shown in Procedure 1. 5.5 Integer Compositions and Partitions A composition of an integer n is a set of strictly positive integers which sum up to n [10]. For example, 3 has four compositions - (cid:8){1, 1, 1}, {1, 2}, {2, 1}, {3}(cid:9). Generally, a composition of n can contain any number from 1 to n. However, it is also interesting to study a variation of the problem wherein we are not allowed to use all numbers. Procedure 10 : APR6(index) - Integer Compositions 1: Local: index 2: Global: n, O, p and R Print R[1, . . . , (index − 1)] return 3: if n = 0 then 4: 5: 6: else 7: for i ← 1 to p do if n ≥ oi then 8: 9: 10: 11: 12: R[index] ← oi n ← n − oi APR6(index + 1) n ← n + oi 16 We now present an algorithm (APR6), based on the same algorithmic struc- ture used so far, that given an n and O = {o1, . . . , op}, generates all possible compositions of n using elements in O. It is shown in Procedure 10. An ex- ample recursion tree is shown in Figure 6. It is easy to modify Procedure 10 to generate all integer partitions, instead of integer compositions (analogous to how we generated combinations by using a permutations generating algorithm). It is possible that when given an O = {o1, . . . , op}, we have a limited number of some or all of the numbers. For example, we could have n = 15; O = {1, . . . , 15} with the condition that no number can be used more than twice. This can be handled by maintaining an auxilary array CountArray parallel to O. n=9 R = {} APR6(1) index = 1 n = 6 R = {3} APR6(2) index = 2 n = 3 R = {3, 3} APR6(3) index = 3 n = 0 R = {3, 3, 3} APR6(4) index = 4 R = {3, 3, 3} index = 2 n = 4 R = {3, 2} APR6(3) index = 3 n = 2 R = {3, 2, 2} APR6(4) index = 4 n = 0 R = {3, 2, 2, 2} APR6(5) index = 5 R = {3, 2, 2, 2} index = 1 n = 7 R = {2} APR6(2) index = 2 n = 5 R = {2, 2} APR6(3) index = 3 n = 2 R = {2, 2, 3} APR6(4) index = 4 n = 0 index = 2 n = 4 R = {2, 3} APR6(3) index = 3 n = 2 R = {2, 3, 2} APR6(4) index = 4 n = 0 index = 2 n = 5 R = {2, 2} APR6(3) index = 3 n = 3 R = {2, 2, 2} APR6(4) index = 4 n = 0 R = {2, 3, 2, 2} R = {2, 2, 3, 2} R = {2, 2, 2, 3} APR6(5) APR6(5) APR6(5) index = 5 index = 5 index = 5 R = {2, 3, 2, 2} R = {2, 2, 3, 2} R = {2, 2, 2, 3} Figure 6: Recursion Tree of APR6 for n = 9; O = {3, 2} 6 Conclusion Algorithms to generate combinatorial structures will always be needed, simply because of the fundamental nature of the problem. One could need different kinds of combinatorial structures for different kinds of input. Thus, having one common effective algorithm, as the one proposed in this paper, which solves 17 many problems, would be useful. One must note that a few other non-trivial adaptations - generating all palin- dromes of a string, generating all positive solutions to a diophantine equation with positive co-efficients, etc, are also possible. 7 Future Research The proposed algorithm conclusively solves quite a few fundamental problems in combinatorics. Further research directed towards achieving even more combina- torial structures while preserving the essence of the proposed algorithm should assume topmost priority. One could also perform some probabilistic analysis and derive tighter average case bounds on the runtime of the algorithms. Acknowledgement We would like to thank Prof. K V Vishwanatha from the CSE Dept. of R V College of Engineering, Bangalore for his comments. References [1] Selim G. Akl, A comparison of combination generation methods, ACM Trans. Math. Softw. 7 (1981), no. 1, 42 -- 45. [2] Jon Bentley, Programming pearls (2nd ed.), ACM Press/Addison-Wesley Publishing Co., New York, NY, USA, 2000. [3] P. Bratley, Algorithm 306: Permutations with repetitions, Commun. ACM 10 (1967), no. 7, 450 -- 451. [4] Phillip J. Chase, Algorithm 382: Combinations of m out of n objects [g6], Commun. ACM 13 (1970), no. 6, 368. [5] , Algorithm 383: Permutations of a set with repetitions [g6], Com- mun. ACM 13 (1970), no. 6, 368 -- 369. [6] J. Cigler, Some remarks on catalan families, Eur. J. Comb. 8 (1987), no. 3, 261 -- 267. [7] Gideon Ehrlich, Algorithm 466: Four combinatorial algorithm [g6], Com- mun. ACM 16 (1973), no. 11, 690 -- 691. [8] , Loopless algorithms for generating permutations, combinations, and other combinatorial configurations, J. ACM 20 (1973), no. 3, 500 -- 513. [9] B. R. Heap, Permutations by Interchanges, The Computer Journal 6 (1963), no. 3, 293 -- 298. 18 [10] Silvia Heubach and Toufik Mansour, Combinatorics of compositions and words, Chapman & Hall/CRC, 2009. [11] F. M. Ives, Permutation enumeration: Four new permutation algorithms, Commun. ACM 19 (1976), no. 2, 68 -- 72. [12] Donald E. Knuth, The art of computer programming, volume 4, fascicle 2: Generating all tuples and permutations (art of computer programming), Addison-Wesley Professional, 2005. [13] , The art of computer programming, volume 4, fascicle 3: Generat- ing all combinations and partitions, Addison-Wesley Professional, 2005. [14] Zbigniew Kokosinski, On parallel generation of partial derangements, de- rangements and permutations. [15] James F. Korsh and Paul S. LaFollette, Constant time generation of de- rangements, Inf. Process. Lett. 90 (2004), no. 4, 181 -- 186. [16] Donald L. Kreher and Douglas R. Stinson, Combinatorial algorithms: Gen- eration, enumeration, and search, SIGACT News 30 (1999), no. 1, 33 -- 35. [17] Clement W. H. Lam and Leonard H. Soicher, Three new combination algo- rithms with the minimal change property, Commun. ACM 25 (1982), no. 8, 555 -- 559. [18] D. H. Lehmer, Teaching combinatorial tricks to a computer, Proceedings of the Symposium on Applications of Mathematics to Combinatorial Analysis 10 (1960), 179 -- 193. [19] Kenji Mikawa and Ichiro Semba, Generating derangements by interchanging atmost four elements, Syst. Comput. Japan 35 (2004), no. 12, 25 -- 31. [20] R. J. Ord-Smith, Algorithms: Algorithm 323:generation of permutations in lexicographic order, Commun. ACM 11 (1968), no. 2, 117. [21] R. J. Ord-Smith, Generation of permutation sequences: Part 1, Comput. J. 13 (1970), no. 2, 152 -- 155. [22] , Generation of permutation sequences: Part 2, Comput. J. 14 (1971), no. 2, 136 -- 139. [23] J. S. Rohl, Converting a class of recursive procedures into non-recursive ones, Software: Practice and Experience 7 (1977), no. 2, 231 -- 238. [24] , Generating permutations by choosing, The Computer Journal 21 (1978), no. 4, 302 -- 305. [25] T. W. Sag, Algorithm 242: Permutations of a set with repetitions, Com- mun. ACM 7 (1964), no. 10, 585. 19 [26] G. F. Schrack and M. Shimrat, Algorithm 102: Permutation in lexicograph- ical order, Commun. ACM 5 (1962), no. 6, 346. [27] Robert Sedgewick, Permutation generation methods, ACM Comput. Surv. 9 (1977), no. 2, 137 -- 164. [28] Mok-Kong Shen, Algorithm 202: Generation of permutations in lexico- graphical order, Commun. ACM 6 (1963), no. 9, 517. [29] H. F. Trotter, Algorithm 115: Perm, Commun. ACM 5 (1962), no. 8, 434 -- 435. 20
1611.06529
1
1611
2016-11-20T15:32:27
A note on distance labeling in planar graphs
[ "cs.DS" ]
A distance labeling scheme is an assignments of labels, that is binary strings, to all nodes of a graph, so that the distance between any two nodes can be computed from their labels and the labels are as short as possible. A major open problem is to determine the complexity of distance labeling in unweighted and undirected planar graphs. It is known that, in such a graph on $n$ nodes, some labels must consist of $\Omega(n^{1/3})$ bits, but the best known labeling scheme uses labels of length $O(\sqrt{n}\log n)$ [Gavoille, Peleg, P\'erennes, and Raz, J. Algorithms, 2004]. We show that, in fact, labels of length $O(\sqrt{n})$ are enough.
cs.DS
cs
A note on distance labeling in planar graphs Paweł Gawrychowski1 and Przemysław Uznański2 1University of Haifa, Israel and University of Wrocław, Poland 2ETH Zürich, Switzerland Abstract A distance labeling scheme is an assignments of labels, that is binary strings, to all nodes of a graph, so that the distance between any two nodes can be computed from their labels and the labels are as short as possible. A major open problem is to determine the complexity of distance labeling in unweighted and undirected planar graphs. It is known that, in such a graph on n nodes, some labels must consist of Ω(n1/3) bits, but the best known labeling scheme uses labels of length O( n log n) [Gavoille, Peleg, √ Pérennes, and Raz, J. Algorithms, 2004]. We show that, in fact, labels of length O( n) are enough. √ Introduction 1 A distance labeling scheme is an assignments of labels, that is binary strings, to all nodes of a graph G, so that the distance δG(u, v) between any two nodes u, v can be computed from their labels. The main goal is to make the labels as short as possible, that is to minimize the maximum length of a label. The secondary goal is to optimize the query time, that is the time necessary to compute δG(u, v) given the labels of u and v. We consider distance labeling for unweighted undirected graphs on n nodes. This was first considered by Graham and Pollak [1], who obtained labels of length O(n). The decoding time was subsequently improved to O(log log n) by Gavoille et al. [2], then to O(log n) by Weimann and Peleg [3], and finally Alstrup et al. [4] obtained O(1) decoding time with labels of length log 3 2 n + o(n). It is known that, in the general case, some labels must consist of at least n 2 bits [5, 6], so achieving sublinear bounds is not possible. Better schemes for distance labeling are known for restricted classes of graphs. As a prime example, trees admit distance labeling scheme with labels of length 1 4 log2 n + o(log2 n) bits [7], and this is known to be tight up to lower order terms [8]. In fact, any sparse graph admits a sublinear distance labeling scheme [9] (see also [10] for a somewhat simpler construction). However, the best known upper bound is still rather √ n). An important subclass of sparse graphs are planar far away from the best known lower bound of Ω( √ graphs, for which Gavoille et al. [2] constructed labeling schemes of length O( n log n). They also proved that in any such scheme some label must consist of Ω(n1/3) bits. Their upper bound of O( n log n) bits is also valid for weighted undirected planar graphs if the weights are polynomially bounded. Very recently, √ n log n) in such a setting. However, Abboud and Dahlgaard [11] showed a matching lower bound of Ω( determining the complexity of distance labeling in unweighted planar graphs remains to be a major open problem in this area. We design a better distance labeling scheme for unweighted undirected planar graphs, where the labels √ consist of only O( n) bits. While this is only a logarithmic improvement, we believe lack of any progress in the last 12 years makes any asymptotic decrease desirable. Our improvement is based on a tailored version of the well-known planar separator lemma. We explain the idea in more detail after presenting the previous labeling scheme. ∗ 1 √ 2 Previous scheme We briefly recap the scheme of Gavoille et al. [2]. Their construction is based on the notion of separators, that is, sets of vertices which can be removed from the graph so that every remaining connected component consists of at most 2 3 n nodes. By the classical result of Lipton and Tarjan [12] any planar graph on n nodes √ has such a separator consisting of O( n) nodes. Now the whole construction proceeds as follows: find a separator S of the graph, and let G1, G2, . . . be the connected components of G \ S. The label of v ∈ Gi in G, denoted (cid:96)G(v), is composed of i, (cid:96)Gi(v) and the distances δG(v, u) for all u ∈ S written down in the same order for every v ∈ G. A label of v ∈ S consist of only the distances δG(v, u) for all u ∈ S. The space complexity of the whole scheme is dominated by the space required to store S distances, each √ consisting of log n bits, so O( n) on the size of a separator is asymptotically tight. However, the total length of the label of v ∈ G (in bits) depends not on the size of the separator, but on the number of bits necessary to encode the distances from v to the nodes of the separator. If the separator is a simple cycle (u1, u2, . . . , uS) then δ(v, ui)− δ(v, ui+1) ≤ 1, for every i = 1, 2, . . . ,S − 1, and consequently writing down δ(v, u1) explicitly and then storing all the differences δ(v, ui) − δ(v, ui+1) takes only O( n) bits in total. It is known that if the graph is triangulated, √ there always exists a simple cycle separator [13], so for such graphs labels of length O( n) are enough. We will show that, in fact, for any planar graph it is possible to select a separator so that the obtained sequence of differences is compressible. This will be done by triangulating the faces using carefully designed gadgets. √ n log n) bits in total. (All logarithms are in base 2.) The bound of O( √ Improved scheme 3 We introduce the notion of weighted separators. Consider a planar graph, where every node has a non- negative weight and all these weights sum up to 1. Then a set of nodes is a weighted separator if after removing these nodes the total weight of every remaining connected component is at most 2 3. We have the following well-known theorem (the result is in fact more general and allows assigning weights also to edges and faces, but this is not needed in our application): √ Theorem 3.1 (see [13]). For every 2-connected planar graph on n nodes having assigned nonnegative weights summing up to 1, there exists a simple cycle of length at most 2 2dn which is a weighted separator, where d is the maximum face size. Now we are ready to use this tool to show the main technical lemma of this section: Lemma 3.2. Any planar graph G has a separator S, such that √ log δG(ui, ui+1) = O( (cid:88) n) i for some ordering u1, u2 . . . , uS of all vertices of S. 2(cid:101). To complete the construction, we recursively build D(cid:100) s Before proving the lemma, we first describe a family of subdivided cycles. A subdivided cycle on s ≥ 3 nodes, denoted Ds, consists of a cycle Cs = (v1, . . . , vs) and possibly some auxiliary nodes. D3 and D4 is simply C3 and C4, respectively. For s > 4, we add (cid:100) s 2(cid:101), and connect every vi 2(cid:101)). with u(cid:100) i (An example of such a subdivided cycle on 10 nodes is shown in Figure 1.) We have the following property. Lemma 3.3. For any u, v ∈ Cs, δDs (u, v) ≥ log(1 + δCs(u, v)). Proof. We apply induction on s. It is easy to check that the lemma holds when s ≤ 4, so we assume s ≥ 5. Let us denote δDs(u, v) = d(cid:48) and δCs(u, v) = d. We proceed with another induction on d. It is easy to check that the lemma holds when d ≤ 2, so we assume d ≥ 3. Consider a shortest path connecting u and v in Ds. If it consists of only auxiliary nodes except for the endpoints u and v, then we consider the immediate 2(cid:101) auxiliary vertices u1, . . . , u(cid:100) s 2(cid:101) and identify its cycle with (u1, . . . , u(cid:100) s 2 Figure 1: A face of size 10 is transformed by replacing C10 with D10 containing 8 new auxiliary nodes. neighbors of u and v on the path, denoted u(cid:48) and v(cid:48), respectively. Since u(cid:48) and v(cid:48) must belong to the cycle of 2(cid:99), by the inductive assumption: D(cid:100) s 2(cid:101) and the distance between them in the corresponding C(cid:100) s 2(cid:101) is at least (cid:98) d d(cid:48) ≥ 2 + log(1 + (cid:98)d/2(cid:99)) = log(4 + 4(cid:98)d/2(cid:99)) ≥ log(1 + d). Otherwise, let u0 = u, u1, u2, . . . , us = v be all nodes of the cycle Cs appearing on the path, where s ≥ 2. We have that: (cid:88) i d(cid:48) = δDs (ui, ui+1) inequality, (cid:80) i log(1 + di) = log(cid:81) and by the inductive assumption: d(cid:48) = (cid:88) i 1 + di ≥ 1 + d, so also (cid:81) δDs(ui, ui+1) ≥(cid:88) i 1 + di ≥ 1 + d. Therefore, d(cid:48) ≥(cid:80) log(1 + δCs(ui, ui+1)). i i Let us denote di = δCs (ui, ui+1) ≥ 1 (as otherwise the path could have been shortened). By the triangle i 1 + di ≥ log(1 + d). Proof of Lemma 3.2. Let G(cid:48) be the graph constructed from G by replacing every face (including the external face) with a subdivided cycle of appropriate size. More precisely, let (v1, v2, . . . , vs) be a cyclic walk of a face of G. Note that nodes vi are not necessarily distinct. We create a subdivided cycle Ds and identify its cycle Cs with (v1, v2, . . . , vs). Clearly G(cid:48) is also planar and each of its faces is either a triangle or a square. Additionally, every subdivided cycle is 2-connected, so also the whole G(cid:48) is 2-connected. Since any subdivided cycle has at most as many auxiliary vertices as cycle vertices and lengths of all cyclic walks sum up to twice the number of edges, which is at most 3n − 6, G(cid:48) contains at most n(cid:48) = n + 2 · (3n − 6) < 7n vertices. We assign weights to vertices of G(cid:48) in such a way that that every vertex that also appears in G has weight 1 and every new vertex has weight 0. By Theorem 3.1 there exists a weighted simple cycle separator S(cid:48) in 28n. Then S = S(cid:48) ∩ G is a separator in G. Because S(cid:48) is a simple cycle separator, G(cid:48) of size at most 2 S = (u1, u2 . . . , uc), and ui and ui+1 are incident to the same face of G that has been replaced with a subdivided cycle Dsi such that S(cid:48) connects ui and ui+1 either directly or by visiting some auxiliary nodes of Dsi, for every i = 1, 2, . . . , c (we assume uc+1 = u1). Let vi and v(cid:48) i denote nodes of Dsi that have been √ identified with ui and ui+1, respectively. Then:(cid:88) (vi, v(cid:48) i) ≤ S = O( δDsi √ n). i 3 By Lemma 3.3, δDsi as required. (vi, v(cid:48) (vi, v(cid:48) i) ≥ log δCsi (cid:88) log δG(vi, vi+1) ≤(cid:88) i), so: i i log δCsi (vi, v(cid:48) i) ≤ O( √ n) Now we proceed to the main result of this section: √ √ n). Theorem 3.4. Any planar graph on n nodes admits a distance labeling scheme of size O( Proof. We proceed as in the previously known scheme of size O( n log n), except that in every step we apply our Lemma 3.2. In more detail, to construct the label of every v ∈ G we proceed as follows. First, we find a separator S = {u1, u2 . . . , uc} using Lemma 3.2. For every v ∈ G we encode its distances to all nodes of the separator. This is done by first writing down δG(v, u1) explicitly, and then δG(v, ui) − δG(v, ui−1) for i = 2, . . . , c. All these numbers are encoded in binary, so by δG(v, ui) − δG(v, ui−1) ≤ δG(ui−1, ui) and √ the properties of our separator this encoding takes O( n) bits in total. Second, for every node we store the name of its connected component of G \ S. Third, we recurse on every connected component of G \ S and append the obtained labels to the current labels. To calculate δG(v, v(cid:48)), we proceed recursively: we compute minu∈S(δG(v, u) + δG(v(cid:48), u)) and then, if v and v(cid:48) belong to the same connected component of G \ S, proceed recursively. The correctness is clear: either a shortest path between u and v is fully within one of the connected components, or it visits some u ∈ S, and in such case we can recover δG(v, u) + δG(v(cid:48), u) √ from the stored distances. The final size of every label is O( (cid:113) 2 √ 3 n + . . .) = O( n) bits. n + References [1] R. Graham, H. Pollak, On embedding graphs in squashed cubes, in: Graph Theory and Applications, Vol. 303 of Lecture Notes in Mathematics, Springer Berlin Heidelberg, 1972, pp. 99 -- 110. [2] C. Gavoille, D. Peleg, S. Pérennes, R. Raz, Distance labeling in graphs, J. Algorithms 53 (1) (2004) 85 -- 112. [3] O. Weimann, D. Peleg, A note on exact distance labeling, Inf. Process. Lett. 111 (14) (2011) 671 -- 673. [4] S. Alstrup, C. Gavoille, E. B. Halvorsen, H. Petersen, Simpler, faster and shorter labels for distances in graphs, in: 27th SODA, 2016, pp. 338 -- 350. [5] J. Moon, On minimal n-universal graphs, in: Proceedings of the Glasgow Mathematical Association, Vol. 7, Cambridge Univ Press, 1965, pp. 32 -- 33. [6] S. Kannan, M. Naor, S. Rudich, Implicit representation of graphs, SIAM J. Discrete Math. 5 (4) (1992) 596 -- 603. [7] O. Freedman, P. Gawrychowski, P. K. Nicholson, O. Weimann, Optimal distance labeling schemes for trees, CoRR abs/1608.00212. [8] S. Alstrup, I. L. Gørtz, E. B. Halvorsen, E. Porat, Distance labeling schemes for trees, in: 43rd ICALP, 2016, pp. 132:1 -- 132:16. [9] S. Alstrup, S. Dahlgaard, M. B. T. Knudsen, E. Porat, Sublinear distance labeling, in: 24th ESA, 2016, pp. 5:1 -- 5:15. [10] P. Gawrychowski, A. Kosowski, P. Uznański, Sublinear-space distance labeling using hubs, in: 30th DISC, 2016, pp. 230 -- 242. 4 [11] A. Abboud, S. Dahlgaard, Popular conjectures as a barrier for dynamic planar graph algorithms, CoRR abs/1605.03797. [12] R. J. Lipton, R. E. Tarjan, Applications of a planar separator theorem, SIAM J. Comput. 9 (3) (1980) 615 -- 627. [13] G. L. Miller, Finding small simple cycle separators for 2-connected planar graphs, J. Comput. Syst. Sci. 32 (3) (1986) 265 -- 279. 5
1802.09665
4
1802
2018-07-24T23:58:19
Polynomial Treedepth Bounds in Linear Colorings
[ "cs.DS" ]
Low-treedepth colorings are an important tool for algorithms that exploit structure in classes of bounded expansion; they guarantee subgraphs that use few colors have bounded treedepth. These colorings have an implicit tradeoff between the total number of colors used and the treedepth bound, and prior empirical work suggests that the former dominates the run time of existing algorithms in practice. We introduce $p$-linear colorings as an alternative to the commonly used $p$-centered colorings. They can be efficiently computed in bounded expansion classes and use at most as many colors as $p$-centered colorings. Although a set of $k<p$ colors from a $p$-centered coloring induces a subgraph of treedepth at most $k$, the same number of colors from a $p$-linear coloring may induce subgraphs of larger treedepth. We establish a polynomial upper bound on the treedepth in general graphs, and give tighter bounds in trees and interval graphs via constructive coloring algorithms. We also give a co-NP-completeness reduction for recognizing $p$-linear colorings and discuss ways to overcome this limitation in practice. This preprint extends results that appeared in [9]; for full proofs omitted from [9], see previous versions of this preprint.
cs.DS
cs
Polynomial Treedepth Bounds in Linear Colorings Jeremy Kun · Michael P. O'Brien · Marcin Pilipczuk · Blair D. Sullivan 8 1 0 2 l u J 4 2 ] S D . s c [ 4 v 5 6 6 9 0 . 2 0 8 1 : v i X r a July 26, 2018 Abstract Low-treedepth colorings are an important tool for algorithms that exploit structure in classes of bounded expansion; they guarantee subgraphs that use few colors have bounded treedepth. These colorings have an implicit tradeoff between the total number of colors used and the treedepth bound, and prior empirical work suggests that the former dominates the run time of exist- ing algorithms in practice. We introduce p-linear colorings as an alternative to the commonly used p-centered colorings. They can be efficiently computed in bounded expansion classes and use at most as many colors as p-centered colorings. Although a set of k < p colors from a p-centered coloring induces a subgraph of treedepth at most k, the same number of colors from a p-linear coloring may induce subgraphs of larger treedepth. We establish a polynomial upper bound on the treedepth in general graphs, and give tighter bounds in trees and interval graphs via constructive coloring algorithms. We also give a co-NP-completeness reduction for recognizing p-linear colorings and discuss ways to overcome this limitation in practice. This preprint extends results that appeared in [9]; for full proofs omitted from [9], see previous versions of this preprint. J. Kun Google, Mountain View, CA, USA E-mail: [email protected] M. P. O'Brien North Carolina State University, Raleigh, NC, USA E-mail: [email protected] M. Pilipczuk University of Warsaw, Warsaw, Poland E-mail: [email protected] B. D. Sullivan North Carolina State University, Raleigh, NC, USA E-mail: blair [email protected] 2 Jeremy Kun et al. Keywords Linear colorings · p-centered colorings · bounded expansion · treedepth 1 Introduction Algorithms for graph classes that exhibit bounded expansion structure [12, 13,14,11] offer a promising framework for efficiently solving many NP-hard problems on real-world networks. The structural restrictions of bounded ex- pansion, which allow for pockets of localized density in globally sparse graphs, are compatible with properties of many real-world networks such as cluster- ing and heavy-tailed degree distributions. Moreover, multiple random graph models designed to mimic these properties have been proven to asymptotically almost surely belong to classes of bounded expansion [3]. From a theoretical perspective, graphs belonging to classes of bounded expansion can be char- acterized by low-treedepth colorings of bounded size, i.e. using only a small number of colors. Roughly speaking, a low-treedepth coloring is one in which the subgraphs induced on each small set of colors have small treedepth, a structural property stronger than treewidth. This definition naturally implies an algorithmic pipeline [13,3,4] for classes of bounded expansion involving four stages: computing a low-treedepth coloring, using the coloring to decompose the graph into subgraphs of small treedepth, solving the problem efficiently on each such subgraph, and combining the subsolutions to construct a global solution. The complexities of algorithms using this paradigm often are of the (cid:1)2d log d · nc) where k is the coloring size and d is the treedepth of the subgraphs. form O((cid:0)k p A recent implementation [15] and experimental evaluation [16] of this pipeline has identified that the coloring size has a much larger effect on the run time than the treedepth in practice. Although graphs in classes of bounded ex- pansion are guaranteed to admit colorings of constant size with respect to the number of vertices, the only known polynomial-time algorithms for computing these colorings are approximations [11]. Consequently it is unclear to what extent our current coloring algorithms can be altered to reduce the coloring size. A more viable approach to improving the performance of the algorithmic pipeline without significant high-level changes would be to develop a new type of low-treedepth coloring that uses fewer colors but potentially has weaker guarantees about the treedepth of the subgraphs. The traditional low-treedepth colorings for classes of bounded expansion are known as p-centered colorings. This name stems from the property that on any subgraph H, a p-centered coloring either uses at least p colors or is a cen- tered coloring, which restricts the multiplicity of colors in induced subgraphs. In this paper we introduce an alternative that closely mirrors this paradigm but only extends the color multiplicity guarantees to path subgraphs. For this reason we refer to them as p-linear colorings and linear colorings. We iden- tify that p-linear colorings share three important properties with p-centered Polynomial Treedepth Bounds in Linear Colorings 3 colorings that allow them to be used in the bounded expansion algorithmic pipeline. 1. The minimum coloring size is constant in graphs of bounded expansion. 2. A coloring of bounded size can be computed in polynomial time. 3. Small sets of colors induce graphs of small treedepth. The third of these properties is of particular interest, since understanding the tradeoffs between coloring size and treedepth in switching between p- centered and p-linear colorings fundamentally depends on bounding the max- imum treedepth of a graph that admits a linear coloring with k colors. Equiv- alently, we frame this problem as determining the gap between the minimum number of colors needed for a linear versus a centered coloring in any given graph. Using a grid minors approach, we prove that the minimum size of a centered coloring is polynomially bounded in the minimum size of a centered coloring. Because the "heavy machinery" of this approach likely does not give a tight bound, we give stronger upper bounds on the gap in trees and inter- val graphs and a matching lower bound for binary trees. Surprisingly, we also prove that some p-linear colorings cannot be verified in polynomial time un- less P = co-NP and discuss the practical implications of these findings. Some results in this paper appeared previously in WG 2018 [9]. This version adds a polynomial treedepth upper bound for general graphs, as well as tighter lower and upper bounds for trees. 2 Definitions and Background In this section we detail the background and terminology necessary to under- stand p-linear colorings. 2.1 Graph Terminology We denote the vertices and edges of a graph G as V (G) and E(G), respectively, and assume all graphs are simple and undirected except where specifically noted otherwise. The open neighborhood of a vertex v, denoted N (v), is the set of vertices u such that uv ∈ E(G), while the closed neighborhood, N [v] is defined as N (v) ∪ {v}. Vertex a is an apex with respect to a subgraph H if V (H) ⊆ N (a). We say P is a v1v(cid:96)-path if V (P ) = {v1, . . . , v(cid:96)} for distinct v1, . . . , v(cid:96) and E(P ) = {vivi+1 : 1 ≤ i ≤ (cid:96) − 1}; we will notate this as P = v1, . . . , v(cid:96). Given disjoint paths P = v1, . . . , v(cid:96) and Q = u1, . . . , u(cid:96)(cid:48), the path P · Q = v1, . . . , v(cid:96), u1, . . . , u(cid:96)(cid:48) is the concatenation of P and Q if v(cid:96) and u1 are adjacent. A path is Hamiltonian with respect to subgraph H if V (P ) = V (H). In a rooted tree T , we let Tv be the subtree of T rooted at v and the leaf paths of Tv be the set of paths from a leaf of Tv to v. We label the levels of T from bottom to top starting from 1; that is, if D is the maximum distance 4 Jeremy Kun et al. from a leaf to the root then the root is the only vertex in level D + 1 and level i consists of all vertices whose parents are in level i + 1. Vertices u and v are unrelated in T if u is neither an ancestor nor a descendant of v. A coloring φ of a graph G is a mapping of the vertices of G to colors 1, . . . , k and has size φ = k. A coloring is proper if no pair of adjacent vertices have the same color. For any subgraph H and color c, if there is exactly one vertex v ∈ H such that φ(v) = c we say c appears uniquely in H and v is a center of H. A subgraph with no unique color is said to be non-centered. We use the notation X = Y1 (cid:93) ··· (cid:93) Y(cid:96) to denote that Y1, . . . , Y(cid:96) form a partition of X; that is, X = Y1 ∪ ··· ∪ Y(cid:96) and the sets Y1, . . . Y(cid:96) are pairwise disjoint. 2.2 p-Centered Colorings and Bounded Expansion Definition 1 A p-centered coloring φ of graph G is a coloring such that for every connected subgraph H, H has a center or φH uses at least p colors. Nesetril and Ossana de Mendez established that bounding the minimum size of a p-centered coloring is a necessary and sufficient condition for a graph class to have bounded expansion. Proposition 1 ([12]) A class of graphs C has bounded expansion iff there exists a function f such that for all G ∈ C and all p ≥ 1, G admits a p- centered coloring with f (p) colors. There are varying methods to compute p-centered colorings, such as transitive- fraternal augmentations [12,5] and generalized coloring numbers [20], we focus here on distance-truncated transitive-fraternal augmentations (DTFAs) [17], which iteratively augment the graph with additional edges to impose con- straints on proper colorings. This linear time algorithm guarantees that after (2 log p)p DTFA iterations, any proper coloring of the augmented graph is a p-centered coloring whose size is bounded in classes of bounded expansion. 2.3 Centered Colorings and Treedepth Note that if φ is a p-centered coloring of G and H is a subgraph of G whose vertices use at most p − 1 colors in φ, H must have a center. This relates p-centered colorings to a more restricted class of graphs defined by centered colorings. Definition 2 A centered coloring φ of graph G is a coloring such that every connected subgraph has a center. The minimum size of a centered coloring of G is denoted χcen(G). Note that a centered coloring is also proper, or else there would be a connected subgraph of size two with no center. Observe that if X is the set of all centers Polynomial Treedepth Bounds in Linear Colorings 5 of G, then G\X must either be empty or disconnected. This implies that if G (cid:29) χcen(G), then G breaks into many components after only a few vertex deletions. This property is captured by treedepth decompositions. Definition 3 A treedepth decomposition T of graph G is a rooted forest with the same vertex set as G such that uv ∈ E(G) implies u is an ancestor of v in T or vice versa. The depth of T is the length of the longest path from a leaf of T to the root of its component. The treedepth of G, td(G), is the minimum depth of a treedepth decomposition of G. Given a centered coloring of size k, we can generate a treedepth decompo- sition of depth at most k by choosing any center v to be the root and setting the children of v to be the roots of the treedepth decompositions of the compo- nents of G\{v}. Likewise, given a treedepth decomposition of depth k, we can generate a centered coloring using k colors by bijectively assigning the colors to levels of the tree and coloring vertices according to their level. We refer to the colorings and decompositions resulting from these procedures as canoni- cal ; together they imply that the treedepth and centered coloring numbers are equal for all graphs. 3 p-Linear and Linear Colorings We introduce p-linear colorings as an alternative to p-centered colorings. Definition 4 A p-linear coloring is a coloring ψ of a graph G such that for every path1 P , either P has a center or ψP uses at least p colors. It is proven in [17] that after performing 2p DTFA iterations, any proper coloring of the augmented graph is a p-linear coloring. This implies that p- linear colorings indeed have constant size in bounded expansion classes and can be constructed in polynomial time (like p-centered colorings). In the interest of maintaining consistency with prior terminology, we define linear colorings analogously to centered colorings. Definition 5 A linear coloring is a coloring ψ of a graph G such that every path has a center. The linear coloring number is the minimum number of colors needed for a linear coloring and is denoted χlin(G). Note that linear colorings must also be proper. A simple recursive argument shows that every path of length d requires at least log2(d + 1) colors in a linear coloring; thus a graph of linear coloring number k has no path of length 2k. Because every depth-first search tree is a treedepth decomposition, td(G) ≤ 2 χlin(G), proving that small numbers of colors in p-linear colorings induce graphs of bounded treedepth2. Our study of the divergence between linear and centered coloring numbers will naturally focus on linear colorings that are not also centered colorings. 1 This includes non-induced paths. 2 This tightens a bound in [17] from double to single exponential. 6 Jeremy Kun et al. We say ψ is a non-centered linear coloring (NCLC) of graph G if G contains a connected induced subgraph with no center. For NCLC ψ, we say a connected induced subgraph H is a witness to ψ if H is non-centered but every proper connected subgraph of H has a center. For the sake of completeness, we prove in Lemma 1 that many simple graph classes do not admit NCLCs. Lemma 1 If G is a cograph, has maximum degree 2, or has independence number 2, any linear coloring of G is also a centered coloring. Proof We analyze each graph class separately below. Maximum degree 2: Let G be a graph of maximum degree 2. Each connected induced subgraph of G is either a path or a cycle, both of which have a Hamiltonian path. Thus every connected subgraph has a center, making any linear coloring centered. Cographs: Let ψ be an NCLC of cograph G and H be a witness to ψ. If ψH only contains one color, H is an isolated vertex and the coloring is centered. Thus, we may assume ψH has at least two colors. Because H is a cograph, we can partition its vertices into nonempty sets X, Y such that xy is an edge in H for all x ∈ X and y ∈ Y . But since ψ is proper, every pair of vertices with the same color must lie in the same set X or Y . Since every color in ψH appears at least twice, there are vertices {v, v(cid:48)} ∈ X and {u, u(cid:48)} ∈ Y such that ψ(v) = ψ(v(cid:48)) and ψ(u) = ψ(u(cid:48)) but ψ(v) (cid:54)= ψ(u). But then v, u, v(cid:48)u(cid:48) form a path with no center and thus ψ is not a linear coloring. Independence number 2: Since independence number is hereditary, it is sufficient to show every connected graph of independence number 2 has a Hamiltonian path. We prove this by induction on the number of vertices, observing that an isolated vertex has a trivial Hamiltonian path. Let G be a graph of independence number 2 and v ∈ G a vertex such that G \ {v} is connected, e.g., v is a leaf in a minimum spanning tree of G. If G \ {v} has a Hamiltonian cycle, then G must have a Hamiltonian path. Otherwise, by the inductive hypothesis G \ {v} has a Hamiltonian path whose endpoints are some non-adjacent pair of vertices u, w. Either v is adjacent to one of u, w, in which case G has a Hamiltonian path, or {u, w, v} form an independent set of (cid:117)(cid:116) size 3. The classes described in Lemma 1 are maximal in the sense that there are graphs with independence number 3 (graph R3 described in Lemma 3) and binary trees (Lemma 4) that admit NCLCs. 4 Treedepth Lower Bounds To understand the tradeoff between the number of colors and treedepth of small color sets when using p-linear colorings in lieu of p-centered colorings, it is important to know the maximum treedepth of a graph of fixed linear coloring number k, tmax(k). In Lemmas 3 and 4, we prove lower bounds on tmax(k) through explicit constructions of graph families. In order to show that these Polynomial Treedepth Bounds in Linear Colorings 7 graphs have large treedepth, we first establish assumptions about the structure of treedepth decompositions that can be made without loss of generality. Lemma 2 Let G be a graph and S ⊂ V (G) such that G[S] is connected and with respect to some component C ∈ G\S, every vertex in S is an apex of C. Then for any treedepth decomposition T of G with depth k, we can construct a treedepth decomposition T (cid:48) such that: 1. depth(T (cid:48)) ≤ k 2. Each vertex in S is an ancestor of every vertex in C in T (cid:48) 3. For each pair of vertices {u, w} ⊆ V (C) or {u, w} ⊆ V (G \ C), u is an ancestor of w in T (cid:48) iff it is an ancestor of w in T . Proof Let φ be a canonical centered coloring of G with respect to T . Let T (cid:48) be a canonical treedepth decomposition with respect to φ; if there are multiple vertices of unique color, prioritize removing those outside C before members of C, and then small colors over large colors, i.e., remove color 2 before color 5. Since T (cid:48) is derived from a centered coloring with k colors, its depth is at most k, satisfying condition 1. Condition 2 is satisfied as long each member of S is removed in the construc- tion of T (cid:48) before any member of C. Note that since S contains apex vertices with respect to C and every vertex v ∈ V (C) satisfies N [v] ⊆ V (C) ∪ V (S), the removal of any vertex from C cannot disconnect a previously connected component if S has not been removed. Thus at any point in the algorithm before the removal of S if a vertex in C has a unique color in its remaining component H, there must be another vertex in H\C of unique color as well. Consequently, we will never be forced to remove any vertex of C before S. To prove condition 3 is satisfied, observe that u is an ancestor of w in T (cid:48) iff there is a connected subgraph H containing u and w and no vertex with color smaller than ψ(u). As stated previously, G\C is a connected subgraph, which means that there is a subgraph witnessing this ancestor-descendant relationship between u and w such that H∩C = ∅ if u /∈ C and H∩(G\C) = ∅ if u ∈ C. Thus the relationships in T are preserved in T (cid:48). (cid:117)(cid:116) Using Lemma 2, we now show that tmax(k) ≥ 2k. Lemma 3 There exists an infinite sequence of graphs R1, R2, . . . such that lim i→∞ χcen(Ri) χlin(Ri) = 2. Proof Define Ri recursively such that R0 is the empty graph and Ri is a complete graph on vertices v1, . . . , vi along with i copies of Rp for p = (cid:98) i−1 2 (cid:99), call them H1, . . . , Hi, such that vj is an apex with respect to Hj (Figure 1). We prove that χlin(Ri) = i and limi→∞ χcen(Ri) = 2i. With respect to the linear coloring number, note that χlin(Ri) ≥ i since the clique of size i requires i colors by Lemma 1. We prove the upper bound χlin(Ri) ≤ i by induction on i. The case of i = 1 is trivial; assume it is true for 1, . . . , i − 1. From the inductive hypothesis, we can assume each Hj only 8 Jeremy Kun et al. requires p colors for a linear coloring. Consider the coloring ψ of Ri such that ψ(vj) = j and ψHj is a linear coloring of Hj using colors {1+(j +1) mod i, 1+ (j + 2) mod i, . . . , 1 + (j + p) mod i}. If ψ is not a linear coloring, there is some path Q without a center. Since ψ(vj) /∈ ψHj , Q must contain vertices from at least two Hjs; each vj is a cut vertex, so Q cannot contain vertices from more than two Hjs. However, ψ−1(1) ⊆ {v1} ∪ V (H2) ∪ ··· ∪ V (Hp+1), but {2, . . . , p + 1} /∈ ψH1 , which means Q ∩ H1 = ∅. Based on the symmetry of ψ we can apply the same argument to the remaining colors, which means that no such non-centered path Q exists and ψ is indeed a linear coloring of size i. With respect to the centered coloring number, by Lemma 2 there is an minimum-depth treedepth decomposition in which vj is an ancestor of Hj. This implies there is a j such that no vertex in Hj shares a color in the canonical coloring with any of the vertices in the clique. Thus χcen(Ri) = i + χcen(Rp); (cid:117)(cid:116) in the limit this recursion approaches 2i. The graphs in Lemma 3 contain large cliques. We now show that this is not a necessary condition for the linear and centered coloring numbers to diverge. Lemma 4 Let B(cid:96) be the complete binary tree with (cid:96) levels. Then lim (cid:96)→∞ χcen(B(cid:96)) χlin(B(cid:96)) ≥ log2 3. Proof Fix an integer a ≥ 1 and let b be the smallest integer such that 2a < 3b. (1) Our proof proceeds by first constructing a coloring pattern Ψa of Ba and then using Ψa to create a linear coloring for an arbitrarily large complete binary tree. Some vertices of Ba will be left uncolored (we will call them local ), while some vertices will be colored with one of the b colors [b] (we will call these colors (cid:80)(cid:96) global ). Let C1, C2, . . . , C2b be the sequence of all subsets of [b] in order of nonincreasing size (in particular, C1 = [b] and C2b = ∅) and let (cid:96) be such that i=1 2Ci−1 = 2a−1. Note that such an index (cid:96) exists due to Equation (1): 2b(cid:88) i=1 2Ci−1 = 1 2 · 3b > 2a−1 and the fact that the sets Ci are ordered in the nonincreasing order of their sizes. Furthermore, we have (cid:96) < 2b. Let v1, v2, . . . , v2a−1 be an ordering of the leaves of Ba corresponding to an in-order traversal. Consider an index 1 ≤ i ≤ (cid:96). By construction, there exists a vertex vi ∈ Ba at level Ci that is the root of a subtree Tvi whose leaves i(cid:48)=1 2Ci(cid:48)−1. We color the vertices of Tvi level by level with (global) colors of Ci; that is, we order the colors of Ci arbitrarily and color level k of Tvi with the k-th color of Ci for every k ∈ [Ci]. are exactly vj for(cid:80)i−1 i(cid:48)=1 2Ci(cid:48)−1 < j ≤(cid:80)i Polynomial Treedepth Bounds in Linear Colorings 9 All remaining vertices of Ba (that is, those that lie in none of the subtrees Tvi for 1 ≤ i ≤ (cid:96)) remain local. The following claim summarizes the properties of the above coloring. Claim 1 For every path P in Ba that either -- has both endpoints in a leaf or the root of the tree Ba, or -- does not contain a local vertex, there exists a global color c ∈ [b] such c appears uniquely on P . Proof If a path P does not contain a local vertex, then it is contained in a single tree Tvi. For such a path, the unique vertex on P of maximum level is colored with a global color that appears uniquely on P . Similarly, if P is a leaf path in Ba, then any globally colored vertex of the tree Tvi containing the leaf endpoint of P satisfies the desired property. Otherwise, a path P that has both endpoints in leaves of Ba but contains a local vertex needs to start in a leaf of one subtree Tvi and end in a leaf of a different subtree Tv(cid:48) . Then, observe that any (global) color of Ci(cid:52)Ci(cid:48) appears exactly once on P . (cid:121) i Let p < 2a be the number of local vertices in the pattern Ψa. For an even integer d ≥ 2, consider a coloring ψ of Bad defined as follows. Fix a palette [db] of global colors and a palette [2p] of local colors. For every 1 ≤ i ≤ d, the i-th stripe consists of a levels (i − 1)a + 1, . . . , ia. In Bad, such a stripe consists of 2(d−i)a copies of Ba. Color every such copy using the pattern Ψa with global colors (i− 1)b + 1, . . . , ib as the b global colors of Ψa and color each local vertex with a different local color from the set {1, 2, . . . , p} if i is odd and from the set {p + 1, p + 2, . . . , 2p} if i is even. We claim that the above is a linear coloring of Bad with db+2p < db+2a+1 colors. Consider a path P in Bad and let i be the index of the highest stripe intersected by P . By the choice of i, P intersects exactly one of the copies of Ba in the i-th stripe. If P contains a leaf-to-leaf path in this copy, then Claim 1 asserts that P contains a center in this copy (recall that every stripe uses a different set of b global colors). Otherwise, P intersects at most one copy of Ba in every stripe. If P intersects at least three stripes, then P contains a root-to-leaf path in the single copy of Ba intersected by P at stripe (i − 1), and we are again done by Claim 1. Similarly, Claim 1 finishes the proof if P does not contain a local vertex at the i-th stripe. Finally, in the remaining case P intersects at most two stripes (the i-th one and possibly the (i − 1)-th one) and contains a local vertex in the i-th stripe. Since we used different set of local colors for odd and even stripes, any such local vertex in i-th stripe is a center of P . Consequently, we have exhibited a linear coloring of Bad with less than db + 2a+1 colors, where b is defined as in Equation (1). If we let d go to ∞, then the ratio (ad)/(db + 2a+1) approaches a/b. This ratio, in turn, approaches log2(3) as a → ∞ due to the choice of b at Equation (1). This finishes the proof (cid:117)(cid:116) of the lemma. 10 Jeremy Kun et al. Fig. 1: Linear colorings of graph R6 in Lemma 3 In Section 6 we show that the bound in Lemma 4 is tight for binary trees (Theorem 4). We conjecture that the construction in Lemma 3 is also tight for general graphs. Conjecture 1 For any graph G, χcen(G) ≤ 2χlin(G). While the exclusion of a path of length 2k indicates tmax(k) ≤ 2k, this nonethe- less leaves a large gap between the upper and lower bounds on tmax(k). To move towards a proof of Conjecture 1, we establish a polynomial upper bound on tmax(k) in general graphs in the next section (Theorem 1). Because this proof uses "heavy machinery", we consider two restricted graph classes -- namely, trees and interval graphs -- in Sections 6 and 7 and give tighter upper bounds on tmax(k) for graphs in these classes. 5 Treedepth Upper Bounds on General Graphs This section is devoted to proving a polynomial upper bound on tmax(k). Theorem 1 There exists a polynomial p such that every graph G satsifies χcen ≤ χ190 lin p(log χlin). Our starting point is the following theorem of Kawarabayashi and Ross- man [7]: Theorem 2 ([7]) There is an absolute constant C such that every graph G of treedepth at least Ck5 log2 k satisfies at least one of the following: 1. the treewidth of G is at least k; 2. G contains a complete binary tree of height k as a minor; 3. G contains a path on 2k vertices. Polynomial Treedepth Bounds in Linear Colorings 11 Assume that the treedepth of G is at least Ck5 log2 k. If G contains a path on 2k vertices (condition 3), then clearly χlin(G) ≥ k. If G contains a complete binary tree of height k as a minor (condition 2), then G also contains a subdivision of a complete binary tree of height k as a subgraph. Since χlin(H) ≤ χlin(G) for any subgraph H of G, Theorem 4 asserts that χlin(G) ≥ k/ log2(3). Thus, in the proof of Theorem 1, we are left with the case when G has large treewidth. Here, we use the celebrated grid minor theorem, with the best known bound due to Chuzhoy [2]. Theorem 3 ([2]) There is a polynomial p(cid:48) such that every graph G with treewidth at least k19p(cid:48)(log k) contains a k × k grid as a minor. We slightly relax the notion of a k × k grid minor to a k-pseudogrid, defined as follows. Definition 6 A graph G contains a k-pseudogrid if there exist two sequences of vertex-disjoint paths in G, P = (P1, P2, . . . , Pk) and Q = (Q1, Q2, . . . , Qk) such that -- for every i ∈ [k], the path Pi is a concatenation of paths Pi,0, P Q i,1, Pi,1, i,j for j ∈ [k] P Q i,2, Pi,2, . . ., P Q is a subpath of Qj (possibly consisting of a single vertex) and every path Pi,j, 0 ≤ j ≤ k does not contain any edge nor internal vertex on any path Qj (we explicitly allow Pi,0 and Pi,k to be paths of length 0); i,k, Pi,k in this order such that each path P Q -- a symmetric condition holds with the roles of P and Q swapped. i,j, Qi,j, and QP k). V (P) = (cid:83) In what follows, the paths Pi,j, P Q i,j are considered empty for pairs of indices (i, j) not defined above. Clearly, if G contains a k × k-grid as a minor, it contains a k-pseudogrid: just let the paths P follow the rows of the grid and the paths of Q follow the columns. To finish the proof of Theorem 1, it suffices to show the following technical result. √ Lemma 5 If G contains a k-pseudogrid, then χlin(G) = Ω( Proof Fix a linear coloring ψ of G. Let (P,Q) be a k-pseudogrid in G. Let P∈P V (P ) and similarly define V (Q). Let µ(P) be the number of distinct colors ψ uses on V (P) and similarly define µ(Q). To prove the lemma, it suffices to show for any k-pseudogrid (P,Q) in G, k ≤ 100· (µ(P) + µ(Q))2. We shall prove it by induction over k. The statement is trivial for k ≤ 100. For an inductive step, we proceed as follows. For a vertex v ∈ V (P) ∪ V (Q), the grid coordinate of v is (i, j) if v ∈ V (P Q i+1,j)). A vertex v is marginal if its grid coordinates (i, j) satisfy i ≤ 3, j ≤ 3, i ≥ k − 2, or j ≥ k − 2. A color c is infrequent on P if it appears on V (P), but there exists a family Pc ⊆ P of at size at most 50(µ(P) + µ(Q)) such that every vertex v ∈ V (P) with ψ(v) = c is either marginal or lies on one of the paths in Pc. The definition of a color infrequent on Q is analogous. i,j)∪ (V (Qi,j)\ V (QP i,j)∪ (V (Pi,j)\ V (P Q i,j+1))∪ V (QP 12 Jeremy Kun et al. For an inductive step, it suffices to show that there is always an infrequent color on P or an infrequent color on Q. Indeed, assume that c is infrequent on P (the arguments for Q are symmetrical) and let Pc ⊆ P be as in the above definition. Construct a k(cid:48)-pseudogrid (P(cid:48),Q(cid:48)) from (P,Q) as follows. Start with (P(cid:48),Q(cid:48)) = (P,Q). First, delete from P(cid:48) the first and last 3 paths, and similarly for Q(cid:48). Second, shorten every path Pi ∈ P(cid:48) by deleting the i,j for j ≤ 3 and j ≥ k − 2; similarly shorten every path edges of Pi,j and P Q Qj ∈ Q(cid:48). Finally, delete all (shortened) paths of Pc from P(cid:48), and delete a matching number of paths from Q(cid:48). In this manner, we obtain a k(cid:48)-pseudogrid (P(cid:48),Q(cid:48)) such that k − k(cid:48) ≤ 6 + 50(µ(P) + µ(Q)) and such that the color c no longer appears on V (P). Therefore, µ(P(cid:48)) + 1 ≤ µ(P) and µ(Q(cid:48)) ≤ µ(Q). The inductive step follows. In the remainder of the proof, assume that there is no infrequent color on P nor an infrequent color on Q. We shall reach a contradiction by exhibiting a simple noncentered path P ⊆ P ∪ Q. We perform the following selecting and marking scheme. Initially, no vertex is selected and no path is marked. For every color c that appears on V (P), perform the following operation twice. 1. Pick a vertex v ∈ V (P) such that ψ(v) = c, v is not marginal, and v does 2. Select v and mark all paths Pi(cid:48) for i(cid:48) − i ≤ 10 and all paths Qj(cid:48) for not lie on a marked path Pi. Let the grid coordinates of v be (i, j). j(cid:48) − j ≤ 10. Now swap the roles of P and Q and perform the above operation twice also for every color c that appears on V (Q). In total, we select 2(µ(P) + µ(Q)) vertices. For every selected vertex we mark 21 paths of P and 21 paths of Q. Since there is no infrequent color, there is always a vertex to choose at Step 1, as otherwise the so-far marked paths would witness infrequency of c. Thus, the above selecting and marking scheme is well-defined. Let v, v(cid:48) be two distinct selected vertices and let (i, j) and (i(cid:48), j(cid:48)) be their grid coordinates. By the above marking scheme, we have that 3 < i, i(cid:48), j, j(cid:48) < k − 2 and i − i(cid:48) + j − j(cid:48) ≥ 11. (2) Consider now the following simple path P . We start with P being the concatenation of even-numbered paths Pi without the prefixes and suffixes Pi,0 ∪ Pi,k in the natural order, connected by paths Qi,1 ∪ QP i+1,1 ∪ Qi+1,1 for i divisible by 4 and by Qi,k ∪ QP i+1,k ∪ Qi+1,k for i ≡ 2 (mod 4) (so that paths Pi with i ≡ 2 (mod 4) are traversed forwards and paths Pi with i divisible by 4 are traversed backwards). Then, for every selected v with grid coordinates (i, j), we pick an even i(cid:48) ∈ {i, i + 1} and modify locally P ∩ Pi(cid:48) to pass through i+1,j ∪ v. In the modification, we use only parts of paths P Q Pi+1,j ∪ P Q i+1,j+1. By Equation (2), two such modifications do not interfere with each other and no such modification interferes with the connections contained in paths Q1 and Qk. Consequently, the final path P is a simple path contained in P ∪ Q that i,j ∪ Pi,j ∪ P Q i,j+1 ∪ Qi,j+1 ∪ QP i+1,j, and QP i+1,j+1, QP i,j ∪ Qi,j ∪ QP i,j+1, P Q Polynomial Treedepth Bounds in Linear Colorings 13 visits all selected vertices. Such a path does not contain a center, which is the (cid:117)(cid:116) desired contradiction. 6 Treedepth Upper Bounds on Trees Schaffer proved that there is a linear time algorithm for finding a minimum- sized centered coloring of a tree T [19]. In this section we prove the follow- ing theorem by showing a correspondence between the centered coloring from Schaffer's algorithm and colors on paths in any linear coloring of T . Theorem 4 Let T be a tree of maximum degree ∆ ≥ 3, Then Schaffer's algorithm finds a centered coloring of T with size at most (log2 ∆) · χlin(T ). In particular, for trees of maximum degree 3 we have χcen(T ) ≤ log2(3)χlin(T ), matching the lower bound of Lemma 4. We do not have any matching lower bound for larger ∆. In fact, we conjecture that none exists, that is, the upper bound of Theorem 4 for ∆ ≥ 4 is not tight. Schaffer's algorithm finds a particular centered coloring whose colors are ordered in a way that reflects their roles as centers. For this reason, the coloring is called a vertex ranking and the colors are referred to as ranks; it guarantees that in each subgraph, the vertex of maximum rank is also a center. We will use this terminology in this section to clearly distinguish between the ranks in the vertex ranking and colors in the linear coloring. Note that the canonical centered coloring of a treedepth decomposition is a vertex ranking if the colors are ranked decreasing from the root downwards, which implies that every cen- tered coloring can be converted to a vertex ranking of the same size. Of central importance to Schaffer's algorithm are what we will refer to as rank lists. Definition 7 For a vertex ranking r of tree T , the rank list of T , denoted L(T ), can be defined recursively as L(T ) = L(T\Tv) ∪ {r(v)} where v is the vertex of maximum rank in T . Schaffer's algorithm arbitrarily roots T and builds the ranking from the leaves to the root of T , computing the rank of each vertex from the rank lists of each of its children. For brevity, we denote L(v) = L(Tv) for every v in T . Proposition 2 ([19]) Let r be a vertex ranking of T produced by Schaffer's algorithm and let v ∈ T be a vertex with children u1, . . . , u(cid:96). If x is the largest integer appearing on rank lists of at least two children of v (or 0 if all such rank lists are pairwise disjoint) then r(v) is the smallest integer satisfying r(v) > x and r(v) /∈(cid:83)(cid:96) i=1 L(ui). We root T at an arbitrary leaf of T and let r be a ranking output by Schaf- fers algorithm applied on (rooted) T . With a vertex v in T we associate the following potential. (cid:88) r∈L(v) ζ(v) = 2r. The following is immediate from Proposition 2: 14 Jeremy Kun et al. Lemma 6 For every v in T with children u1, u2, . . . , u(cid:96), it holds that (cid:96)(cid:88) ζ(v) ≤ 2 + ζ(ui). Furthermore, the equality holds if and only if all rank lists L(ui) are pairwise disjoint. i=1 Let ψ be a linear coloring of T with k := χlin(T ) colors. Our proof of Theorem 4 is based on tracking sets of colors of ψ on paths terminating at the current vertex as Schaffer's algorithm moves up the rooted tree. Given a path P ⊆ T and a linear coloring ψ of size k, we say a color set X ⊆ {1, . . . , k} is compatible with P if both the following conditions are true: 1. For every center v ∈ P , ψ(v) ∈ X. 2. For every color c ∈ X, there is a vertex u ∈ P such that ψ(u) = c. In other words, a compatible set must not contain colors not found on P , must contain each color appearing uniquely in P , and may or may not contain any colors appearing multiple times on P . For each v ∈ T , let S(v) be a set of sets defined recursively as follows. If v is a leaf, S(v) = {{ψ(v)}}. Otherwise, i=1 S(ui), and ξ : S(cid:48) → 2[k] be an let u1, . . . , u(cid:96) be the children of v, S(cid:48) =(cid:83)(cid:96) injective function such that (cid:40) ξ(X) = X \ {ψ(v)} X ∪ {ψ(v)} if ψ(v) ∈ X and X\{ψ(v)} ∈ S(cid:48) otherwise for all X ∈ S(cid:48). Then S(v) = {ξ(X) : X ∈ S(cid:48)} ∪ {{ψ(v)}}. We start with the following straightforward observation. Lemma 7 For every v ∈ T it holds that ∅ /∈ S(v). Consequently, for every nonleaf v ∈ T , ξ is a bijection between S(cid:48) and S(v) \ {{ψ(v)}}. We prove that the construction of S(v) preserves compatibility of sets. Lemma 8 For all vertices v ∈ T and each X ∈ S(v), there is a corresponding path P ⊆ Tv with v as an endpoint such that P is compatible with X. Proof It is clear that the lemma holds at the leaves of T , so we proceed by inductively showing the recursive step preserves the property. Observe that the path consisting of v only is compatible with {ψ(v)} ∈ S(v). For any X ∈ S(v)\{{ψ(v)}}, there is a child u of v such that X(cid:48) = ξ−1(X) is in S(u). By the inductive hypothesis, there must be a path P (cid:48) terminating at u such that X(cid:48) is compatible with P (cid:48). We claim that P = P (cid:48) ·{v} is compatible with X. Since X(cid:52)X(cid:48) ⊆ {ψ(v)} and each color c (cid:54)= ψ(v) appears the same number of times in P and P (cid:48), it is only necessary to prove the requirements for compatibility are satified with respect to ψ(v). Moreover, because ψ(v) appears at least once on P it suffices to show that if ψ(v) /∈ X, then ψ(v) appears multiple times on P . By the definition of ξ, ψ(v) /∈ X implies ψ(v) ∈ X(cid:48) and thus v is not a (cid:117)(cid:116) center of P . Polynomial Treedepth Bounds in Linear Colorings 15 X∈S(v)(∆ − 1)X. We observe the following Lemma 9 For any vertex v ∈ T with children u1, . . . , u(cid:96), ρ(v) ≥ (∆ − 1) + Define ρ(v) =(cid:80) (cid:80)(cid:96) i=1 ρ(ui). Proof First, note that (cid:96) ≤ ∆− 1. Also, the lemma is straightforward for a leaf v as then S(v) = {{ψ(v)}} and ρ(v) = ∆ − 1. Assume then (cid:96) ≥ 1. Recall that S(cid:48) =(cid:83)(cid:96) i=1 S(ui). Let S1 be the set of all color sets that appear in exactly one S(ui) and SM be those that occur in multiple S(ui)'s; we have S(cid:48) = S1 (cid:93) SM . Note that for each X ∈ SM , ψ(v) /∈ X or else concatenating the corresponding compatible paths with v creates a path with no center. Likewise, if there are distinct color sets Y and Y (cid:48) = Y \{ψ(v)} such that {Y, Y (cid:48)} ⊆ S1 ∪ SM , then Y, Y (cid:48) both belong to the same S(ui); in particular, both Y, Y (cid:48) belong to S1. By the definition of ξ, for each color set X ∈ S(v) \ {{ψ(v)}} either X ≥ ξ−1(X) or X = ξ−1(X) − 1. In the latter case, there is a corresponding color set X(cid:48) = X ∪ {ψ(v)} such that X(cid:48) ∈ S(v) and ξ−1(X(cid:48)) = X. Also, from the discussion in the previous paragraph we infer that this latter case can only happen when X, X(cid:48) ∈ S1. Hence, (∆ − 1)ξ(X(cid:48)) ≥ (cid:88) X(cid:48)∈S1 (cid:88) (cid:88) X(cid:48)∈S1 (∆ − 1)ξ(X(cid:48)) = (∆ − 1) (∆ − 1)X(cid:48). (∆ − 1)X(cid:48), and (cid:88) X(cid:48)∈SM X(cid:48)∈SM We infer that (cid:88) ρ(v) = (∆ − 1){ψ(v)} + (∆ − 1)X X(cid:48)∈S(cid:48) (cid:88) (cid:88) (cid:88) (cid:96)(cid:88) (cid:96)(cid:88) i=1 X(cid:48)∈S1 X(cid:48)∈S1 = (∆ − 1) + = (∆ − 1) + ≥ (∆ − 1) + ≥ (∆ − 1) + ≥ (∆ − 1) + (cid:88) X(cid:48)∈S(ui) ρ(ui). X∈S(v)\{{ψ(v)}} (∆ − 1)ξ(X(cid:48)) (cid:88) (∆ − 1)ξ(X(cid:48)) + X(cid:48)∈SM (∆ − 1)X(cid:48) + (∆ − 1) (cid:88) (∆ − 1)ξ(X(cid:48)) (∆ − 1)X(cid:48) X(cid:48)∈SM (∆ − 1)X(cid:48) i=1 (cid:117)(cid:116) We conclude with the proof of Theorem 4. 16 Jeremy Kun et al. Proof (Theorem 4) For every leaf v ∈ T , we have ρ(v) = ∆ − 1 ≥ 2 = ζ(v). Lemmas 6 and 9 show inductively that ρ(v) ≥ ζ(v) for every v ∈ T . If k(cid:48) is the size of the centered coloring output by Schaffer's algorithm, then for the root v0 of T we have 2k(cid:48) ≤ ζ(v0) ≤ ρ(v) ≤ (cid:88) X⊆[k] (∆ − 1)X = ∆k. Thus k(cid:48) ≤ (log2 ∆) · k. (cid:117)(cid:116) 7 Treedepth Upper Bounds on Interval Graphs Because linear colorings are equivalent to centered colorings when restricted to paths, we turn our attention to the linear coloring numbers of "pathlike" graphs. We investigate a particular class of "pathlike" graphs in this section and prove a quadratic relationship between their centered and linear coloring numbers. Definition 8 A graph G is an interval graph if there is an injective mapping f from V (G) to intervals on the real line such that uv ∈ E(G) iff f (u) and f (v) overlap. We refer to the mapping f as the interval representation of G. Since the overlap between intervals f (u) and f (v) is independent of the interval representations of the other vertices, every subgraph of an interval graph is also an interval graph. The interval representation of G implies a natural "left-to-right" layout that gives it the "pathlike" qualities, which are manifested in restrictions on the length of induced cycles (chordal ) and paths between vertex triples (AT- free). Definition 9 A graph is chordal if it has no induced cycles of length ≥ 4. Definition 10 Vertices u, v, w are an asteroidal triple (AT) if there exist uv-, vw-, and wu-paths Puv, Pvw, and Pwu, respectively, such that N [w] ∩ Puv = N [u] ∩ Pvw = N [v] ∩ Puv = ∅. A graph with no AT is called AT-free. Proposition 3 ([10]) A graph G is an interval graph iff G is chordal and AT-free. Intuitively, Definition 10 is a set of three vertices such that every pair is con- nected by a path that avoids the neighbors of the third. Roughly speaking, in the context of linear colorings, Proposition 3 indicates that if w is a center of a "long" uv-path P in G, any vertex w(cid:48) such that ψ(w) = ψ(w(cid:48)) must have a neighbor on P . We devote the rest of this section to proving Theorem 5. Theorem 5 There exists a polynomial time algorithm that takes as input an interval graph G and a linear coloring of G with size k and outputs a centered coloring of G with size at most k2. Polynomial Treedepth Bounds in Linear Colorings 17 Our algorithm makes extensive use of the following well-known property of maximal cliques in interval graphs. Proposition 4 ([10]) If G is an interval graph, its maximal cliques can be linearly ordered in polynomial time such that for each vertex v, the cliques containing v appear consecutively. In particular, we identify a prevailing path in G whose vertices "span" the maximal cliques and a prevailing subgraph that consists of the prevailing path as well as vertices in maximal cliques "between" consecutive vertices on the prevailing path. We will show that any linear coloring is a centered color- ing when restricted to the prevailing subgraph and that after removing the prevailing subgraph, the remaining components each use fewer colors. Let C1, . . . Cm be an ordering of the maximal cliques of G that satisfies Proposition 4. We say vertex v is introduced in Ci if v ∈ Ci but v /∈ Ci−1, and denote this as I(v) = i. Likewise, v is forgotten in Cj if v ∈ Cj but v /∈ Cj+1, and denote this as F (v) = j. The procedure for constructing a prevailing subgraph and prevailing path is described in Algorithm 1. This algorithm selects the vertex v from the current maximal clique that is forgotten "last" and adds v to the prevailing path and CF (v) to the prevailing subgraph. We prove in Lemma 10 that if P, Q are a prevailing path and subgraph, the vertices in Q\P can be inserted between vertices of P to form a Hamiltonian path of Q. Algorithm 1 Construction of a prevailing path and subgraph. Input: interval graph G Output: prevailing path P and prevailing subgraph Q 1: C1, . . . , Cm ← maximal cliques of G labeled in accordance with Proposition 4 2: P ← ∅ 3: VQ ← ∅ 4: i ← 1 5: j ← 1 6: while i < m do vj ← arg maxu∈Ci 7: P ← P · {vj} 8: i ← F (v) 9: VQ ← VQ ∪ V (Ci) 10: j ← j + 1 11: 12: end while 13: Q ← G[VQ] 14: return P, Q F (u) Lemma 10 Every prevailing subgraph has a Hamiltonian path. Proof Let P, Q be the prevailing path and subgraph constructed in Algo- rithm 1. We prove by constructing the Hamiltonian path of Q. Let Mj be the set of all u ∈ Q\P , for which j is the smallest integer for which u ∈ CF (vj ). In other words Mj contains the vertices in CF (vj ) that do not appear in CF (vj−1). 1≤j≤p Mj then by construction P ∪ M = Q. Moreover, for each If M = (cid:83) 18 Jeremy Kun et al. u ∈ Mj, Mj ∪{vj, vj+1} ⊆ N [u]. For each Mj, let µ1 ing of Mj such that F (µi ). Then j) ≤ F (µi+1 M1 1 , v2, µ1 j 2, . . . , µ j , µ2 j , . . . , µ Mj j be a order- v1, µ1 1, . . . , µ is a Hamiltonian path. M2 2 , . . . , vp, µ1 p, . . . µMp p (cid:117)(cid:116) Although the fact that the prevailing subgraph Q has a Hamiltonian path implies Q has a center with respect to ψ, we must ensure that the proper subgraphs of Q also have a center. In Lemma 11, we prove ψQ is centered by showing every proper connected subgraph of Q also has a Hamiltonian path. Lemma 11 If Q is a prevailing subgraph of an interval graph G and ψ a linear coloring of G, ψQ is a centered coloring. Proof It suffices to show that every proper, connected induced subgraph of Q has a Hamiltonian path, since the existence of a Hamiltonian path implies the subgraph has a center. Assume H ⊆ Q has a Hamiltonian path. Let w be a center and wp, ws be its predecessor and successor in the Hamiltonian path. It is clear that the subpath from the start of the Hamiltonian path to wp remains a path in H\{w}; this is also true for the subpath from ws to the end. Therefore if H\{w} is disconnected, there are two components and both have Hamiltonian paths. Otherwise suppose H\{w} is connected. Note that if P = {v1, . . . , vp} is the prevailing path generated by Algorithm 1, CF (vj ) ∩ CF (vj+2) = ∅ or else vj+2 would be forgotten later than vj+1 and would have been chosen to be vj+1 instead. Thus, there is some 1 ≤ (cid:96) ≤ q ≤ p such that H\{w} ⊆ CF (v(cid:96))∪CF (v(cid:96)+1)∪···∪CF (vq) and since H\{w} is connected, for each (cid:96) ≤ j < q the intersection of cliques CF (vj ) and CF (vj+1) is non-empty. Consequently, the ordering of the vertices in the Hamiltonian path of Q must also define a (cid:117)(cid:116) Hamiltonian path of H\{w}. Since any linear coloring ψ of the prevailing subgraph Q must also be a centered coloring, td(Q) ≤ ψ. To get a bound on the treedepth of G, we focus on the relationship between Q and G\Q. In particular, we show that the components of G\Q use fewer than ψ colors by proving that each such component has an apex in the prevailing path. Lemma 12 Let P, Q be a prevailing path and subgraph of an interval graph G. For each component X of G\Q, there is a vertex a ∈ P such that X ⊆ N (a). i=F (vj−1)+1 Ci]\Q, defining F (v0) = 0. By this definition and the fact that vj is a member of both CF (vj−1) and CF (vj ), vj is a neighbor of all vertices in X for each X ∈ Xj. j=1 CF (vj ), V (G) = V (Q) ∪ V (X1) ∪ ··· ∪ V (Xp) and j=1 Xj = ∅. Hence, if X ∈ Xj is not a component of G\Q, then there Proof For 1 ≤ j ≤ p, let Xj be the set of components of G[(cid:83)F (vj )−1 Thus it suffices to show that(cid:83)p Since V (Q) = (cid:83)p V (Q)∩(cid:83)p j=1 Xj are the components of G\Q. Polynomial Treedepth Bounds in Linear Colorings 19 must be some component X(cid:48) ∈ Xi for which i (cid:54)= j and there exists u ∈ X and u(cid:48) ∈ X(cid:48) and uu(cid:48) ∈ E(G). But CF (vj ) ∪ CF (vj+1) has no common vertices with X and separates it from any vertices in Xi. An analogous statement for X(cid:48) is 1≤j≤p Xj (cid:117)(cid:116) are the components of G\Q and the lemma is proven. true as well, so no such edges uu(cid:48) exist. Therefore we conclude that(cid:83) We can now establish a polynomial upper bound on the treedepth of in- terval graphs, proving Theorem 5. Proof (Theorem 5) Let A be the algorithm that constructs a treedepth de- composition T of G by finding a prevailing subgraph Q (Algorithm 1), using ψQ to create a treedepth decomposition of Q, and recursively constructing treedepth decompositions of G\Q. If depth(T ) ≤ k2 and A runs in polyno- mial time, then the canonical centered coloring of T is a centered coloring of G of size at most k2. We prove A satisfies these requirements by induction on k = ψ. At k = 1, the graph consists of isolated vertices and A trivially constructs a treedepth decomposition of G of depth 1 in polynomial time. Assume A has the desired properties for linear colorings of size at most k−1. Because the maximal cliques of an interval graph can be enumerated and ordered in polynomial time (Proposition 4), identifying Q via Algorithm 1 can be done in polynomial time. By Lemma 11, the canonical treedepth decom- position of Q has depth at most k. Since every component X of G\Q has an apex a in P (Lemma 12), we can assume a is an ancestor in T of each vertex in X (Lemma 2). Because ψ is proper, ψ(a) does not appear in ψX and since induced subgraphs of interval graphs are themselves interval graphs, A finds a treedepth decomposition of X whose depth is at most (k − 1)2. Thus T has depth k + (k − 1)2 ≤ k2. The recursion only lasts k ≤ n steps, so A runs in (cid:117)(cid:116) polynomial time. 8 Hardness of Recognizing Linear Colorings Based on the similarity in definition between linear and centered colorings, one might assume that computing them should be roughly equally difficult. Finding a centered coloring of a fixed size is NP-hard [1], but given a coloring of a graph, we can recognize whether it is centered in polynomial time by attempting to create the canonical treedepth decomposition; this procedure will identify a non-centered subgraph if the coloring is not centered. To the contrary, we will prove that Linear Coloring Recognition, the problem of recognizing whether a coloring is linear, is co-NP-complete. In order to prove the hardness of Linear Coloring Recognition, we first define a dual problem. The Non-centered Path problem takes a graph G and coloring ψ as input and decides whether G has a non-centered path P . We focus on proving the hardness of Non-centered Path because a certificate to that problem is easily definable: a path where every color appears at least twice. Theorem 6 Non-centered Path is NP-complete. 20 Jeremy Kun et al. P T 1 w1,1 P T 2 w2,1 w2,2 P T 3 w3,2 u(cid:48) 1 u(cid:48) 2 u(cid:48) 3 w(cid:48) 1 w(cid:48) 2 w(cid:48) 3 u0 u1 u2 u3 u(cid:48) 0 P F 1 w1,2 P F 2 w2,3 P F 3 w3,1 Fig. 2: The graph G and coloring ψ for Φ = (x1 ∨ x2 ∨¬x3)∧ (¬x1 ∨ x2 ∨ x3)∧ (¬x2). Proof A certificate to Non-centered Path can be verified in linear time by iterating over all vertices in the path and counting color occurrences. Thus, Non-centered Path is in NP. We prove NP-hardness by reducing from CNF-SAT. Given a CNF-SAT formula Φ with variables x1, . . . xn and clauses C1, . . . Cm, we construct a graph G and coloring ψ that will have a non-centered path if and only if Φ is satis- fiable. We assume that Φ satisfies the following properties: (1) Every variable appears at most once in each clause. (2) No clause contains both a variable and its negation. (3) Every variable appears as a positive literal and negative literal. We can assume (1) since the disjunction operation is idempotent. Every clause for which (2) does not hold is satisfied by any truth assignment of the variables and thus can be removed without changing the satisfiability of Φ. If variable xi appears only positively then assigning xi to be false does not cause any clauses to be satisfied. Therefore, it is sufficient to set xi to true and only consider the clauses of Φ that do not contain xi; since the analogous statement is true when xi does not appear positively, we can assume (3). The variables of Φ are represented by a set of vertices U = {u0, . . . , un}. For each xi, we connect ui−1 and ui with two paths P T i ; we will force the non-centered path to contain vertices from exactly one of P T i , which will correspond to whether xi was set to true or false. The path P T i contains one vertex for each Cj in which xi appears positively while P F i contains one vertex for each Cj in which the negation of xi appears. By assumption (2), we can uniquely label the vertex on P T i corresponding to clause Cj as wi,j and the order of the vertices on P T i can be chosen arbitrarily. To complete the construction of G, we add path P0 = u(cid:48) 1, u(cid:48) m such that w(cid:48) m is adjacent to u0 and all other vertices on P0 have no additional edges. Finally, we attach a pendant vertex u(cid:48) 0 to un. Since each vertex wi,j corresponds to a unique literal in Φ and U + P0 = 2n + m + 1, G has size linear in the size of Φ. To encode satisfaction of clauses, we color G with coloring ψ : V (G) → {0, . . . , n + m} such that ψ(ui) = ψ(u(cid:48) j) = ψ(wi,j) = n + j. In this way, we force any non-centered path to contain all colors and color i ∪ P F i and P F i) = i and ψ(w(cid:48) 2, . . . , u(cid:48) n, w(cid:48) 1, w(cid:48) 2, . . . , w(cid:48) i and P F i and P F Polynomial Treedepth Bounds in Linear Colorings 21 j + n appears twice if and only if Cj is satisfied. An example can be found in Figure 2. Given a satisfying assignment of Φ, let P ∗ xi is set to false. Then Q = P0 · u0 · P ∗ path since it contains all pairs ui, u(cid:48) We now prove that Φ is satisfiable iff G contains a path Q with no center. if 0, is a non-centered i contains a vertex with the same color as each vertex in(cid:83) if xi is set to true and P F n · un · u(cid:48) i 1≤i≤n P ∗ 1≤j≤m w(cid:48) j. i and (cid:83) 1 · u1 · ··· · P ∗ i be P T i 0, . . . , u(cid:48) To prove the reverse direction suppose G contains a non-centered path Q. Let U(cid:48) = {u(cid:48) n}. Since each vertex in U(cid:48) shares a color with exactly one other vertex and that vertex is a member of U , Q contains a vertex from U iff Q contains a vertex from U(cid:48). By our construction of P0 and assumptions about Φ, no component of G\(U ∪ U(cid:48)) contains two vertices of the same color. Thus, Q must contain vertices from U , U(cid:48), and G\(U ∪ U(cid:48)). For any 0 ≤ i (cid:54)= j ≤ n, i, which implies that (U ∪ U(cid:48)) ⊂ Q and Q is every uju(cid:48) 0 path. In order for Q to be connected, P0 ⊆ Q and in order for it to be a u(cid:48) i and P F a path, exactly one of P T i ) is a subpath of Q for each 1 ≤ i ≤ n. Since the colors in w(cid:48) i i contains at least one vertex of each color on [n+1, n+m], which corresponds to a selection m are unique, (cid:83) j path contains ui or u(cid:48) (denote it P ∗ 1≤i≤n P ∗ 1, . . . w(cid:48) 1u(cid:48) of truth assignments to the variables of Φ such that every clause is satisfied.(cid:117)(cid:116) Corollary 1 Linear Coloring Recognition is co-NP-complete. The co-NP-hardness of recognizing linear colorings is compounded by three stronger hardness implications. First, the coloring ψ given in Theorem 6 has size m+n+1, which means that unless the exponential time hypothesis [6] fails, there is no 2o(k) algorithm to recognize a linear coloring of size k. Second, the graph G constructed in the proof of Theorem 6 is outerplanar with pathwidth two, which implies that neither treewidth-style dynamic programming nor a Baker-style layering approach is likely to solve this problem efficiently. Finally, by subdividing each edge and coloring all subdivision vertices with a (single) new color, we obtain a bipartite graph with degeneracy two, proving hardness for each of those classes. Nonetheless, the fact that χcen(G) = O(log m + log n) while ψ = m + n + 1 leaves open the possibility that Linear Coloring Recognition becomes easier for colorings of minimum size. 9 Conclusion We have introduced p-linear and linear colorings as an alternative to p-centered and centered colorings for use in algorithms for classes of bounded expansion. The p-linear colorings are computable in polynomial time and require a con- stant number of colors in classes of bounded expansion, while inducing graphs of bounded treedepth for all small sets of colors, allowing direct substitution in existing algorithmic pipelines. A major direction for future work is to bring the upper bound on tmax(k) of poly(k) closer to the lower bound of 2k. In particular, it appears our current toolkit for analyzing linear colorings must 22 Jeremy Kun et al. be expanded in order to prove (or disprove) Conjecture 1. We also believe it is worth studying whether recognizing linear colorings can be done in polyno- mial time if we assume the coloring is of size χlin(G). Finally, using p-linear colorings in practice will require an efficient method for translating a linear coloring into a treedepth decomposition. Although there exist general-purpose algorithms to find treedepth decompositions efficiently in graphs of bounded linear coloring number (e.g. [18]), a more specialized algorithm that avoids "heavy machinery" is likely necessary to be practically useful. Acknowledgments The authors would like to thank Felix Reidl and Fernando S´anchez-Villaamil for bringing these colorings to our atten- tion and several anonymous reviewers for their helpful sug- gestion. This work was supported in part by the DARPA GRAPHS Program and the Gordon & Betty Moore Foun- dation's Data-Driven Discovery Initiative through Grants SPAWARN66001-14-1-4063 and GBMF4560 to Blair D. Sul- livan. The research of Marcin Pilipczuk is a part of a project that has received funding from the European Research Coun- cil (ERC) under the European Union's Horizon 2020 research and innovation programme, grant agreement No 714704. References 1. Bodlaender, H.L., et al.: Rankings of graphs. SIAM J. on Discrete Mathematics 11(1), 168 -- 181 (1998) 2. Chuzhoy, J.: Improved bounds for the excluded grid theorem. CoRR abs/1602.02629 (2016). URL http://arxiv.org/abs/1602.02629 3. Demaine, E.D., et al.: Structural sparsity of complex networks: Random graph models and linear algorithms. CoRR abs/1406.2587 (2015). URL http://arxiv.org/abs/ 1406.2587 4. Dvor´ak, Z., , Kr´al, D., Thomas, R.: Testing first-order properties for subclasses of sparse graphs. JACM 60(5), 36:1 -- 36:24 (2013). DOI 10.1145/2499483 5. Grohe, M., Kreutzer, S., Siebertz, S.: Deciding first-order properties of nowhere dense graphs. Journal of the ACM (JACM) 64(3), 17 (2017) 6. Impagliazzo, R., Paturi, R.: On the complexity of k-sat. Journal of Computer and System Sciences 62(2), 367 -- 375 (2001) 7. Kawarabayashi, K., Rossman, B.: A polynomial excluded-minor approximation of treedepth. In: A. Czumaj (ed.) Proceedings of the Twenty-Ninth Annual ACM- SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, Jan- uary 7-10, 2018, pp. 234 -- 246. SIAM (2018). DOI 10.1137/1.9781611975031.17. URL https://doi.org/10.1137/1.9781611975031.17 8. Kun, J., O'Brien, M.P., Sullivan, B.D.: Treedepth bounds in linear colorings. CoRR abs/1802.09665 (2018). URL http://arxiv.org/abs/1802.09665 9. Kun, J., O'Brien, M.P., Sullivan, B.D.: Treedepth bounds in linear colorings. In: 44th International Workshop on Graph-Theoretic Concepts in Computer Science. Springer (2018) Polynomial Treedepth Bounds in Linear Colorings 23 10. Lekkeikerker, C., Boland, J.: Representation of a finite graph by a set of intervals on the real line. Fundamenta Mathematicae 51(1), 45 -- 64 (1962). URL http://eudml.org/ doc/213681 11. de Mendez, P.O., et al.: Sparsity: graphs, structures, and algorithms, vol. 28. Springer (2012) 12. Nesetril , J., de Mendez, P.O.: Grad and classes with bounded expansion i. decomposi- tions. European Journal of Combinatorics 29(3), 760 -- 776 (2008) 13. Nesetril , J., de Mendez, P.O.: Grad and classes with bounded expansion ii. algorithmic aspects. European Journal of Combinatorics 29(3), 777 -- 791 (2008) 14. Nesetril , J., de Mendez, P.O.: Grad and classes with bounded expansion iii. restricted graph homomorphism dualities. European Journal of Combinatorics 29(4), 1012 -- 1024 (2008). Homomorphisms: Structure and Highlights 15. O'Brien, M.P., Hobbs, C.G., Jasnick, K., Reidl, F., Rodrigues, N.G., Sullivan, B.D.: CONCUSS, v2.0. http://dx.doi.org/10.5281/zenodo.30281 (2016) 16. O'Brien, M.P., Sullivan, B.D.: An experimental evaluation of a bounded expansion algo- rithmic pipeline. CoRR abs/1712.06690 (2017). URL http://arxiv.org/abs/1712. 06690 17. Reidl, F.: Structural sparseness and complex networks. Dr., Aachen, Techn. Hochsch., Aachen (2015). URL https://publications.rwth-aachen.de/record/565064. Aachen, Techn. Hochsch., Diss., 2015 18. Reidl, F., Rossmanith, P., S´anchez Villaamil, F., Sikdar, S.: A faster parameterized algorithm for treedepth. In: J. Esparza, P. Fraigniaud, T. Husfeldt, E. Koutsoupias (eds.) Automata, Languages, and Programming, pp. 931 -- 942. Springer Berlin Heidel- berg, Berlin, Heidelberg (2014) 19. Schaffer, A.A.: Optimal node ranking of trees in linear time. Information Processing Letters 33(2), 91 -- 96 (1989) 20. Zhu, X.: Colouring graphs with bounded generalized colouring number. Discrete Math- ematics 309(18), 5562 -- 5568 (2009)
1807.07143
2
1807
2018-11-18T20:57:35
Fast and Deterministic Approximations for $k$-Cut
[ "cs.DS" ]
In an undirected graph, a $k$-cut is a set of edges whose removal breaks the graph into at least $k$ connected components. The minimum weight $k$-cut can be computed in $O(n^{O(k)})$ time, but when $k$ is treated as part of the input, computing the minimum weight $k$-cut is NP-Hard [Holdschmidt and Hochbaum 1994]. For $\operatorname{poly}(m,n,k)$-time algorithms, the best possible approximation factor is essentially 2 under the small set expansion hypothesis [Manurangsi 2017]. Saran and Vazirani [1995] showed that a $(2 - 2/k)$-approximately minimum weight $k$-cut can be computed by $O(k)$ minimum cuts, which implies an $\tilde{O}(mk)$ randomized running time via the nearly linear time randomized min-cut algorithm of Karger [2000]. Nagamochi and Kamidoi [2007] showed that the minimum weight $k$-cut can be computed deterministically in $O(mn + n^2 \log n)$ time. These results prompt two basic questions. The first concerns the role of randomization. Is there a deterministic algorithm for 2-approximate $k$-cuts matching the randomized running time of $\tilde{O}(mk)$? The second question qualitatively compares minimum cut to 2-approximate minimum $k$-cut. Can 2-approximate $k$-cuts be computed as fast as the (exact) minimum cut - in $\tilde{O}(m)$ randomized time? We make progress on these questions with a deterministic approximation algorithm that computes $(2 + \epsilon)$-minimum $k$-cuts in $O(m \log^3(n) / \epsilon^2)$ time, via a $(1 + \epsilon)$-approximate for an LP relaxation of $k$-cut.
cs.DS
cs
Fast and Deterministic Approximations for k-Cut Kent Quanrud∗ November 20, 2018 Abstract In an undirected graph, a k-cut is a set of edges whose removal breaks the graph into at least k connected components. The minimum weight k-cut can be computed in nO(k) time, but when k is treated as part of the input, computing the minimum weight k- cut is NP-Hard [Goldschmidt and Hochbaum 1994]. For poly(m, n, k)-time algorithms, the best possible approximation factor is essentially 2 under the small set expansion hypothesis [Manurangsi 2017]. Saran and Vazirani [1995] showed that a (cid:18)2 − mum weight k-cut can be computed via O(k) minimum cuts, which implies a O(km) random- ized running time via the nearly linear time randomized min-cut algorithm of Karger [2000]. Nagamochi and Kamidoi [2007] showed that the minimum weight k-cut can be computed de- 2 k(cid:19)-approximately mini- terministically in O(cid:0)mn + n2 log n(cid:1) time. These results prompt two basic questions. The first concerns the role of randomization. Is there a deterministic algorithm for 2-approximate k-cuts matching the randomized running time of O(km)? The second question qualitatively compares minimum cut to 2-approximate minimum k-cut. Can 2-approximate k-cuts be computed as fast as the minimum cut -- in O(m) randomized time? We make progress on these questions with a deterministic approximation algorithm that computes (2 + ǫ)-minimum k-cuts in O(cid:0)m log3 n/ǫ2(cid:1) time, via a (1 + ǫ)-approximation for an LP relaxation of k-cut. 1 Introduction Let G = (V, E) be an undirected graph with m edges and n vertices, with positive edge capacities given by c : E → R>0. A cut is a set of edges C ⊆ E whose removal leaves G disconnected. For k ∈ N, a k-cut is a set of edges C ⊆ E whose removal leaves G disconnected into at least k components. The capacity of a cut C is the sum capacity c(C) = Xe∈C ce of edges in the cut. The minimum k-cut problem is to find a k-cut C of minimum capacity c(C). The special case k = 2, which is to find the minimum cut, is particularly well-studied. The minimum cut can be computed in polynomial time by fixing a source s and computing the minimum ∗Department of Computer Science, University of Illinois, Urbana-Champaign, Urbana, IL 61801. [email protected]. Work on this paper is partly supported by NSF grant CCF-1526799. 1 s-t cut (via s-t max-flow) for all choices of t. Nagamochi and Ibaraki [36, 37, 38] and Hao and Orlin [21] improved the running time to O(mn) which, at the time, was as fast as computing a single maximum flow. A randomized edge contraction algorithm by Karger and Stein [26] finds the courses on randomized algorithms. Karger [25] gave a randomized algorithm based on the Tutte -- Nash-Williams theorem [47, 41] that computes the minimum weight cut with high probability in minimum cut with high probability in O(cid:0)n2(cid:1) time; this algorithm is now a staple of graduate level O(m) time. The best deterministic running time for minimum cut is currently O(cid:0)mn + n2 log n(cid:1), by Stoer and Wagner [45]. Computing the minimum capacity cut deterministically in nearly linear time is a major open problem. Recently, Kawarabayashi and Thorup [28] made substantial progress on this problem with a deterministic nearly linear time algorithm for computing the minimum cardinality cut in an unweighted simple graph. This algorithm was simplified by Lo, Schmidt, and Thorup [33], and a faster algorithm was obtained by Henzinger, Rao, and Wang [23]. The general case k > 2 is more peculiar. Goldschmidt and Hochbaum [18] showed that for any fixed k, finding the minimum k-cut is polynomial time solvable, but when k is part of the input, the problem is NP-Hard. The aforementioned randomized contraction algorithm of Karger and Stein deterministic algorithm that also leverages the Tutte -- Nash-Williams theorem [47, 41] and runs in [26] computes a minimum k-cut with high probability in O(cid:16)n2(k−1)(cid:17) time. Thorup [46] gave a O(cid:16)mn2k−2(cid:17) time; this approach was recently refined to improve the running time to O(cid:16)mn2k−3(cid:17) concerned, Saran and Vazirani [43] showed that a (cid:18)2 − k(cid:19)-approximate k-cut can be obtained graph is unweighted [20]. As far as algorithms with running times that are polynomial in k are [10]. There are slightly faster algorithms for particularly small values of k [32] and when the 2 by O(k) minimum cut computations. By the aforementioned min-cut algorithms, this approach can be implemented in O(km) randomized time, O(kmn) time deterministically, and O(km) time deterministically in unweighted graphs. Alternatively, Saran and Vazirani [43] showed that the same approximation factor can be obtained by computing a Gomory-Hu tree and taking the k lightest cuts. The Gomory-Hu tree can be computed in n maximum flow computations, and the maximum flow can be computed deterministically in O(cid:16)m minnm1/2, n2/3o log U(cid:17) time for integer capacities between 1 and U [17]. This gives a O(cid:16)mn minnm1/2, n2/3o log U(cid:17) deterministic time (2 − 2/k)-approximation for minimum k-cut, which is faster than O(kmn) for sufficiently large k. (There are faster randomized algorithms for maximum flow [31, 34], but these still lead to slower randomized running times than O(km) for k-cut.) An LP based 2-approximation was derived by Naor and Rabani [40], and a combinatorial 2-approximation was given by Ravi and Sinha [42] (see also [1]), but the running times are worse than those implied by Saran and Vazirani [43]. Finally, a O(cid:0)mn + n2 log n(cid:1) deterministic running time was obtained by a combinatorial algorithm by Nagamochi and Kamidoi [39], which is the best known deterministic running time. The constant factor of 2 is believed to be essentially the best possible. Manurangsi [35] showed that under the small set expansion hypothesis, for any fixed ǫ > 0, one cannot compute a (2 − ǫ)-approximation for the minimum k-cut in poly(k, m, n) time unless P = N P . The state of affairs for computing 2-approximate minimum k-cuts in poly(k, m, n)-time paral- 2 lels the status of minimum cut. The fastest randomized algorithm is an order of magnitude faster than the fastest deterministic algorithm, while in the unweighted case the running times are essen- tially equal. A basic question is whether there exists a deterministic algorithm that computes a 2-approximation in O(km) time, matching the randomized running time. As Saran and Vazirani's algorithm reduces k-cut to k minimum cuts, the gap between the deterministic and randomized running times for k-cut is not only similar to, but a reflection of, the gap between the deterministic and randomized running times for minimum cut. An O(m) deterministic algorithm for minimum cut would close the gap for 2-approximate k-cut as well. A second question asks if computing a 2-approximate k-cut is qualitatively harder than com- puting the minimum cut. There is currently a large gap between the fastest algorithm for minimum cut and the fastest algorithm for 2-approximate minimum k-cut. Can one compute 2-approximate minimum k-cuts as fast as minimum cuts -- in O(m) randomized time? Removing the linear depen- dence on k would show that computing 2-approximate k-cuts is as easy as computing a minimum cut. 1.1 The main result We make progress on both of these questions with a deterministic and nearly linear time (2 + ǫ)- approximation scheme for minimum k-cuts. To state the result formally, we first introduce an LP relaxation for the minimum k-cut due to Naor and Rabani [40]. min Xe s.t. Xe∈T cexe over x : E → R xe ≥ k − 1 for all spanning trees T, (L) 0 ≤ xe ≤ 1 for all edges e. The feasible integral solutions of the LP (L) are precisely the k-cuts in G. The main contribution of this work is a nearly linear time approximation scheme for (L). approximation to (L). Theorem 1.1. In O(cid:0)m log3(n)/ǫ2(cid:1) deterministic time, one can compute an (1 ± ǫ)-multiplicative The integrality gap of (L) is known to be (2 − 2/n) [40, 9]. Upon inspection, the rounding algorithm can be implemented in O(m log n) time, giving the following nearly linear time (2 + ǫ)- approximation scheme for k-cut. Theorem 1.2. For sufficiently small ǫ > 0, there is a deterministic algorithm that computes a k-cut This algorithm should be compared with the aforementioned algorithms of Saran and Vazirani with total capacity at most (2 + ǫ) times the optimum value to (L) in O(cid:0)m log3(n)/ǫ2(cid:1) time. [43], which computes a (cid:18)2 − k(cid:19)-approximation to the minimum k-cut in O(km) randomized time (with high probability), and of Nagamochi and Kamidoi [39], which computes a 2-approximate 2 3 minimum cut in O(cid:0)mn + n2 log n(cid:1) deterministic time. At the cost of a (1 + ǫ)-multiplicative fac- tor, we obtain a deterministic algorithm with nearly linear running time for all values of k. The approximation factor converges to 2, and we cannot expect to beat 2 under the small set expansion hypothesis [35]. Thus, Theorem 1.2 gives a tight, deterministic, and nearly linear time approxima- tion scheme for k-cut. Theorem 1.2 leaves a little bit of room for improvement: the hope is for a deterministic algorithm that computes (2 − o(1))-approximate minimum k-cuts in O(m) time. Based on Theorem 1.2, we conjecture that such an algorithm exists. 1.2 Overview of the algorithm We give a brief sketch of the algorithm, for the sake of informing subsequent discussion on related work in Section 1.3. A more complete description of the algorithm begins in earnest in Section 2. The algorithm consists of a nearly linear time approximation scheme for the LP (L), and a nearly linear time rounding scheme. The approximation scheme for solving the LP extends techniques from recent work [5], applied to the dual of an indirect reformulation of (L). The rounding scheme is a simplification of the rounding scheme by Chekuri et al. [9] for the more general Steiner k-cut problem, which builds on the primal-dual framework of Goemans and Williamson [15]. The first step is to obtain a (1 + ǫ)-multiplicative approximation to the LP (L). Here a (1 + ǫ)-multiplicative approximation to the LP (L) is a feasible vector x of cost at most a (1 + ǫ)- multiplicative factor greater than the optimum value. The LP (L) can be solved exactly by the ellipsoid method, with the separation oracle supplied by a minimum spanning tree (abbr. MST) computation, but the running time is a larger polynomial than desired. From the perspective of fast approximations, the LP (L) is difficult to handle because it is an exponentially large mixed packing and covering problem, with exponentially many covering constraints alongside upper bounds on each edge. Fast approximation algorithms for mixed packing and covering problems (e.g. [50, 7]) give bicriteria approximations that meet either the covering constraints or the packing constraints but not both. Even without consideration of the objective function, it is not known how to find feasible points to general mixed packing and covering problems in time faster than via exact LP solvers. Alternatively, one may consider the dual of (L), as follows. Let T denote the family of spanning trees in G. yT −Xe∈E ze over y : T → R and z : E → R max (k − 1)XT s.t. XT ∋e yT ≤ ce + ze for all edges e, yT ≥ 0 for all spanning trees T ∈ T , ze ≥ 0 for all edges e. This program is not a positive linear program, and the edge potentials z ∈ RE ≥0 are difficult to handle by techniques such as [50, 5, 7]. It was not known, prior to this work, how to obtain any 4 approximation to (L) (better than its integrality gap) with running time faster than the ellipsoid algorithm. Critically, we consider the following larger LP instead of (L). Let F denote the family of all forests in G. min Xe s.t. Xe∈T cexe over x : E → R xe ≥ F + k − n for all forests F ∈ F, (C) xe ≥ 0 for all edges e ∈ E. (C) is also an LP relaxation for k-cut. In fact, (C) is equivalent to (L), as one can verify directly (see Lemma 2.1 below). (C) is obtained from (L) by adding all the knapsack covering constraints [2], which makes the packing constraints (xe ≤ 1 for each edge e) redundant. Although the LP (C) adds exponentially many constraints to the original LP (L), (C) has the advantage of being a pure covering problem. Its dual is a pure packing problem, as follows. maximize XF ∈F s.t. XF ∋e (F + k − n)yF over y : F → R yF ≤ ce for all edges e ∈ E, yF ≥ 0 for all forests F ∈ F. (P) The above LP packs forests into the capacitated graph G where the value of a forest F depends on the number of edges it contains, F. The objective value F + k − n of a forest F is a lower bound on the number of edges F contributes to any k-cut. Clearly, we need only consider forests with at least n − k + 1 edges. To approximate the desired LP (C), we apply the MWU framework to the above LP (P), which generates (1 ± ǫ)-multiplicative approximations to both (P) and its dual, (C). Implementing the MWU framework in nearly linear time is not immediate, despite precedent for similar problems. In the special case where k = 2, the above LP (P) fractionally packs spanning trees into G. A nearly linear time approximation scheme for k = 2 is given in previous work [5]. The general case with k > 2 is more difficult for two reasons. First, the family of forests that we pack is larger than the family of spanning trees. Second, (P) is a weighted packing problem, where the coefficients in the objective depends on the number of edges in the forest. When k = 2, we need only consider spanning trees with n − 1 edges, so all the coefficients are 1 and the packing problem is unweighted. The heterogeneous coefficients in the objective create technical complications in the MWU framework, as the Lagrangian relaxation generated by the framework is no longer solved by a MST. In Section 2, we give an overview of the MWU framework and discuss the algorithmic complications in greater depth. In Section 3 and Section 4, we show how to extend the techniques of [5] with some new observations to overcome these challenges and approximate the LP (P) in nearly the same time 5 as one can approximately pack spanning trees. Ultimately, we obtain the following deterministic algorithm for approximating the LP (P). Theorem 1.3. In O(cid:0)m log3(n)/ǫ2(cid:1) deterministic time, one can compute (1 ± ǫ)-multiplicative ap- proximations to (P), (C) and (L). The second step, after computing a fractional solution x to (L) with Theorem 1.3, is to round x to a discrete k-cut. The rounding step is essentially that of Chekuri et al. [9] for Steiner k-cuts. Their case is more general than ours; we simplify their rounding scheme, and pay greater attention to the running time. The rounding scheme is based on the elegant primal-dual MST algorithm of Goemans and Williamson [15]. Theorem 1.4. Given a feasible solution x to (C), one can compute a k-cut C with cost at most 2(1 − 1/n) times the cost of x in O(m log n) time. Applying Theorem 1.4 to the output of Theorem 1.3 gives Theorem 1.2. Computing the minimum k-cut via the LP (L) has additional benefits. First, computing a minimum k-cut with an approximation factor relative to the LP may be much stronger than the same approximation factor relative to the original problem, as LP's perform well in practice. Second, the solution to the LP gives a certificate of approximation ratio, as we can compare the rounded k-cut to the LP solution to infer an upper bound on the approximation ratio that may be smaller than 2. Lastly, we note that some data structures can be simplified at the cost of randomization by using a randomized MWU framework instead [7]. These modifications are discussed at the end of Section 4. 1.3 Further related results and discussion Fixed parameter tractability. The k-cut results reviewed above were focused on either exact polynomial-time algorithms for constant k or (2 − o(1))-approximations in poly(k, m, n) time, with a particular emphasis on the fastest algorithms in the poly(k, m, n) time regime. There is also a body of literature concerning fixed parameter tractable algorithms for k-cut. Downey, Estivill- Castro, Fellows, Prieto-Rodriguez, and Rosamond [12] showed that k-cut is W [1]-hard in k even for simple unweighted graphs; W [1]-hardness implies that it is unlikely to obtain a running time of the form f (k) poly(m, n) for any function f . On the other hand, Kawarabayashi and Thorup [27] showed that k-cut is fixed parameter tractable in the number of edges in the cut. More precisely, Kawarabayashi and Thorup [27] gave a deterministic algorithm that, for a given cardinality s ∈ N, n2(cid:17) time. time, either finds a k-cut with at most s edges or reports that no such cut exists in O(cid:16)ssO(s) The running time was improved to O(cid:16)2O(s2 log s)n4 log n(cid:17) deterministic time and O(cid:16)2O(s) log kn2(cid:17) randomized time by Chitnis, Cygan, Hajiaghayi, Pilipczuk, and Pilipczuk [11]. Besides exact parameterized algorithms for k-cut, there is interest in approximation ratios be- tween 1 and 2. Xiao, Cai, and Yao [48] showed that by adjusting the reduction of Saran and Vazirani 6 [43] to use (exact) minimum ℓ-cuts -- instead of minimum (2-)cuts, for any choice of ℓ ∈ {2, . . . , k − 1} -- one can obtain (cid:18)2 − k2(cid:19)(cid:19)-approximate minimum k-cuts in nO(ℓ) time. For sufficiently small ǫ > 0, by setting ℓ ≈ ǫk, this gives a nO(ǫk) time algorithm for (2 − ǫ)-approximate minimum cuts. + O(cid:18) ℓ2 ℓ k The hardness results of Downey et al. [12] and Manurangsi [35] do not rule out approximation algorithms with approximation ratio better than 2 and running times of the form f (k) poly(m, n) (for any function f ). Recently, Gupta, Lee, and Li [19] gave a FPT algorithm that, for a particular constant c ∈ (0, 1), computes a (2 − c)-approximate k-cut in 2O(k6) O(cid:0)n4(cid:1) time. This improves the running time of [48] for ǫ = c and k greater than some constant. Further improvements by Gupta et al. [20] achieved a deterministic 1.81 approximation in 2O(k2)nO(1) time, and a randomized (1 + ǫ)-approximation (for any ǫ > 0) in (k/ǫ)O(k)nk+O(1) time. Knapsack covering constraints. We were surprised to discover that adding the knapsack cov- ering constraints allowed for faster approximation algorithms. Knapsack covering constraints, pro- posed by Carr et al. [2] in the context of capacitated network design problems, generate a stronger LP whose solutions can be rounded to obtain better approximation factors [2, 29, 30, 3]. However, the larger LP can be much more complicated and is usually more difficult to solve. We recently obtained a faster approximation scheme for approximating covering integer programs via knapsack covering constraints, but the dependency on ǫ is much worse, and the algorithm has a "weakly nearly linear" running time that suffers from a logarithmic dependency on the multiplicative range of input coefficients [8]. Fast approximations via LP's. Linear programs have long been used to obtain more accurate approximations to NP-Hard problems. Recently, we have explored the use of fast LP solvers to obtain faster approximations, including situations where polynomial time algorithms are known. In recent work [6], we used a linear time approximation to an LP relaxation for Metric TSP (obtained in [4]) to effectively sparsify the input and accelerate Christofides' algorithm. While nearly linear time approximations for complicated LP's are surprising in and of itself, perhaps the application to obtain faster approximations for combinatorial problems is more compelling. We think this result is an important data point for this approach. 2 Reviewing the MWU framework and identifying bottlenecks In this section, let ǫ > 0 be fixed. It suffices to assume that ǫ ≥ 1/ poly(n), since below this point one can use the ellipsoid algorithm instead and still meet the desired running time. For ease of exposition, we seek only a (1 + O(ǫ))-multiplicative approximation; a (1 + ǫ)-multiplicative approximation with the same asymptotic running time follows by decreasing ǫ by a constant factor. 7 2.1 k-cuts as a (pure) covering problem As discussed above, the first (and most decisive) step towards a fast, fractional approximation to k-cut is identifying the right LP. The standard LP (L) is difficult because it is a mixed packing and covering problem, and fast approximation algorithms for mixed packing and covering problems lead to bicriteria approximations that we do not know how to round. On the other hand, extending (L) with all the knapsack cover constraints makes the packing constraints xe ≤ 1 redundant (as shown below), leaving the pure covering problem, (C). The LPs (L) and (C) have essentially equivalent solutions in the following sense. Lemma 2.1. Any feasible solution x ∈ RE solution x to (C), the truncation x′ ∈ Rn (L) and (C). ≥0 to (L) is a feasible solution to (C). For any feasible e = max{xe, 1} is a feasible solution to both ≥0 defined by x′ Proof. Let x be a feasible solution to (L). We claim that x is feasible in (C). Indeed, let F be a forest, and extend F to a tree T . Then Xe∈F xe =Xe∈T xe − Xe∈T \F as desired. xe ≥ k − 1 − T \ F = k − 1 − (n − 1 − F) = F + k − n, Conversely, let x ∈ RE ≥0 be a feasible solution to (C), and let x′ be the coordinatewise maximum of x and 1. Since x′ ≤ 1, and the covering constraints in (L) are a subset of the covering constraints in (C), if x′ is feasible in (C) then it is also feasible in (L). To show that x′ is feasible in (C), let F be a forest. Let F ′ = {e ∈ F : xe > 1} be the edges in F truncated by x′ and let F ′′ = F \ F ′ be the remaining edges. Since (1) x′ e = xe for all e ∈ F ′′, and (2) x covers F ′′ in (C), we have e = 1 for all e ∈ F ′ and x′ Xe∈F x′ e = Xe∈F ′ x′ e + Xe∈F ′′ x′ e as desired. (1) = (cid:12)(cid:12)F ′(cid:12)(cid:12) + Xe∈F ′′ xe (2) ≥ (cid:12)(cid:12)F ′(cid:12)(cid:12) +(cid:12)(cid:12)F ′′(cid:12)(cid:12) + k − n = F + k − n, (cid:4) While having many more constraints than (L), (C) is a pure covering problem, for which finding a feasible point (faster than an exact LP solver) is at least plausible. The dual of (C) is the LP (P), which packs forests in the graph and weights each forest by the number of edges minus (n − k). The coefficient of a forest in the objective of (P) can be interpreted as the number of edges that forest must contribute to any k-cut. 2.2 A brief sketch of width-independent MWU We apply a width-independent version of the MWU framework to the packing LP (P), developed by Garg and Könemann [14] for multicommodity flow problems and generalized by Young [49]. We restrict ourselves to a sketch of the framework and refer to previous work for further details. 8 The width-independent MWU framework is a monotonic and iterative algorithm that starts with an empty solution y = 0 to the LP (P) and increases y along forests that solve certain Lagrangian relaxations to (P). Each Lagrangian relaxation is designed to steer y away from packing forests that have edges that are already tightly packed. For each edge e, the framework maintains a weight we that (approximately) exponentiates the load of edge e w/r/t the current forest packing y, as follows: ln(cewe) ≈ log n ǫ PF ∋e yF ce . (1) The weight can be interpreted as follows. For an edge e, the value PF ∋e yF capacity used by the current packing y relative to the capacity of the edge e. We call PF ∋e yF the (relative) load on edge e and is ≤ 1 if y is a feasible packing. The weight we is exponential in the . Initially, the load on the edge, where the exponential is amplified by the leading coefficient is the amount of log n ce ce empty solution y = ∅ induces zero load on any edge and we have we = for each edge e. Each iteration, the framework solves the following Lagrangian relaxation of (P): ǫ 1 ce maximize XF ∈F (F + k − n)zF over z : F → R≥0 s.t. Xe∈E weXF ∋e zF ≤ Xe∈E wece. (R) Given a (1 + O(ǫ))-approximate solution z to the above, the framework adds δz to y for a carefully chosen value δ > 0 (discussed in greater detail below). The next iteration encounters a different relaxation, where the edge weights we are increased to account for the loads increased by adding δz. Note that the edge weights we are monotonically increasing over the course of the algorithm. At the end of the algorithm, standard analysis shows that the fractional forest packing y has objective value (1 − O(ǫ)) OPT, and that (1 − O(ǫ))y satisfies all of the packing constraints. The error can be made one-sided by scaling y up or down. Moreover, it can be shown that at some point in the algorithm, an easily computable rescaling of w is a (1 + O(ǫ))-relative approximation for the desired LP (C) (see for example [13, 14, 4]). Thus, although we may appear more interested in solving the dual LP (P), we are approximating the desired LP (C) as well. The choice of δ differentiates this "width-independent" MWU from other MWU-type algorithms in the literature. The step size δ is chosen small enough that no weight increases by more than an exp(ǫ)-multiplicative factor, and large enough that some weight increases by (about) an exp(ǫ)- multiplicative factor. The analysis of the MWU framework reveals that hw, ci ≤ nO(1/ǫ) at all times. In particular, each weight can increase by an exp(ǫ)-multiplicative factor at most O(cid:18)ln n ǫ2 (cid:19) times, so there are at most O(cid:18) n ln n ǫ2 (cid:19) iterations total. 9 2.3 Two bottlenecks The MWU framework alternates between (a) solving the relaxation (R) induced by edge weights we and (b) updating the weights we for each edge in response to the solution to the relaxation. As the framework requires O(cid:18) m log n ǫ2 (cid:19) iterations, both parts must be implemented in polylogarithmic amortized time to reach the desired running time. A sublinear per-iteration running time seems unlikely by the following simple observations. Consider first the complexity of simply expressing a solution. Any solution z to (R) is indexed by forests in G. A forest can have Ω(n) edges and requires Ω(n log n) bits to specify. Writing down the index of just one forest in each of O(cid:18) m log n ǫ2 (cid:19) iterations takes O(cid:18) mn log2 n difficulty of even writing down a solution to (P) is not just a feature of the MWU framework. In (cid:19) time. The ǫ2 general, there exists an optimal solution to (P) that is supported by at most m forests, as m is the rank of the implicit packing matrix. Writing down m forests also requires Ω(mn log n) bits. Thus, either on a per-iteration basis in the MWU framework or w/r/t to the entire LP, the complexity of the output suggests a quadratic lower bound on the running time. A second type of bottleneck arises from updating the weights. The weights we for each edge reflect the load induced by the packing y, per the formula (1). After computing a solution z to the relaxation (R), and updating y ← y + δz, we need to update the weights we to reflect the increased load from δz. In the worst case, δz packs into every edge, requiring us to update O(m) individual weights. At the very least, δz should pack into the edges of at least one forest, and thus effect Ω(n) edges. Updating n edge weights in each iteration requires O(cid:18) mn log n ǫ2 (cid:19) time. Even in hindsight, implementing either part -- solving the relaxation or updating the weights -- in isolation in sublinear time remains difficult. Our algorithm carefully plays both parts off each other, as co-routines, and amortizes against invariants revealed by the analysis of the MWU framework. The seemingly necessary dependence between parts is an important theme of this work and an ongoing theme from previous work [5, 4, 8]. 3 Greedily finding forests to pack in O(cid:0)log2 n(cid:1) amortized time The MWU framework reduces (P) to a sequence of problems of the form (R). An important aspect of the Lagrangian approach is that satisfying the single packing constraint in (R) is much simpler than simultaneously satisfying all of the packing constraints in (P). With only 1 packing constraint, it suffices to (approximately) identify the best bang-for-buck forest F and taking as much as can fit in the packing constraint. The "bang-for-buck" ratio of a forest F is the ratio where F is the number of edges in F . Given a forest F (approximately) maximizing the above ratio, we set z = γeF for γ as large as possible as fits in the single packing constraint. Note that, , F + k − n Pe∈F we 10 when k = 2, the optimal forest is the minimum weight spanning tree w/r/t w. We first consider the simpler problem of maximizing the above ratio over forests F with exactly F = ℓ edges, for some ℓ > n − k. Recall that the MST can be computed greedily by repeatedly adding the minimum weight edge that does not induce a cycle. Optimality of the greedy algorithm follows from the fact that spanning trees are the bases of a matroid called the graphic matroid. The forests of exactly ℓ edges are also the bases of a matroid; namely, the restriction of the graphic matroid to forests of at most ℓ edges. In particular, the same greedy procedure computes the minimum weight forest of ℓ edges. Repeating the greedy algorithm for each choice of ℓ, one can solve (R) in O(km log n) time for each of O(cid:18) m log n ǫ2 (cid:19) iterations. Stepping back, we want to compute the minimum weight forest with ℓ edges for a range of k − 1 values of ℓ, and we can run the greedy algorithm for each choice of ℓ. We observe that the greedy algorithm is oblivious to the parameter ℓ, except for deciding when to stop. We can run the greedy algorithm once to build the MST, and then simulate the greedy algorithm for any value of ℓ by taking the first ℓ edges added to the MST. Lemma 3.1. Let T be the minimum weight spanning tree w/r/t w. For any ℓ ∈ [n−1], the minimum weight forest w/r/t w with ℓ edges consists of the first ℓ minimum weight edges of T . Lemma 3.1 effectively reduces (R) to one MST computation, which takes O(m log n) time. Re- peated over O(cid:18) m log n ǫ2 (cid:19) iterations, this leads to a O(cid:18) m2 log2 n ǫ2 (cid:19) running time. As observed previously [46, 5], the minimum weight spanning tree does not have to be rebuilt from scratch from one iteration to another, but rather adjusted dynamically as the weights change. Lemma 3.2 (Holm, de Lichtenberg, and Thorup [24]). In O(cid:0)log2 n(cid:1) amortized time per increment to w, one can maintain the MST w/r/t w. The running time of Lemma 3.2 depends on the number of times the edge weights change, so we want to limit the number of weight updates exposed to Lemma 3.2. It is easy to see that solving (R) w/r/t a second set of weights w that is a (1 ± ǫ)-multiplicative factor coordinatewise approximation of w gives a solution that is a (1 ± ǫ)-multiplicative approximation to (R) w/r/t w. We maintain the MST w/r/t an approximation w of w, and only propagate changes from w to w when w is greater than w by at least a (1 + ǫ)-multiplicative factor. As mentioned in Section 2, a weight we increases weights w and amortizing against the total growth of weights in the system gives us the following. by a (1 + ǫ)-multiplicative factor at most O(cid:18)log n Lemma 3.3. In O(cid:18) m log3 n that, for all e ∈ E, we have we ∈ (1 ± ǫ)we. Moreover, the MST makes at most O(cid:18)m log n ǫ2 (cid:19) times. Applying Lemma 3.2 to the discretized (cid:19) total time, one can maintain the MST w/r/t a set of weights w such ǫ2 (cid:19) edge ǫ2 updates total. Given such an MST T as above, and ℓ ∈ {n − k + 1, . . . , n − 1} we need the ℓ minimum ( w- )weight edges to form an (approximately) minimum weight forest F of ℓ edges. However, the data 11 structure of Lemma 3.2 does not provide a list of edges in increasing order of weight. We maintain the edges in sorted order separately, where each time the dynamic MST replaces one edge with another, we make the same update in the sorted list. Clearly, such a list can be maintained in O(log n) time per update by dynamic trees. Our setting is simpler because the range of possible values of any weight we is known in advance as follows. For e ∈ E, define ǫ2 (cid:19)(cid:27)). : i ∈(cid:26)0, 1, . . . , O(cid:18) log n We =( (1 + ǫ)i ce Then we ∈ We for all e ∈ E at all times. Define L = {(e, α) : α ∈ We}. The set L represents the set of ǫ2 (cid:19). all possible assignments of weights to edges that may arise. As mentioned above, L = O(cid:18) m log n Let B be a balanced binary tree over L, where L is sorted by increasing order of the second coordinate we (and ties are broken arbitrarily). The tree B has height logL = O(log m) and can be built in O(L) = O(cid:18) m log n We mark the leaves based on the edges in T . Every time the MST T adds an edge e of weight we, we mark the corresponding leaf (e, we) as marked. When an edge e is deleted, we unmark the corresponding leaf. Lastly, when an edge e ∈ T has its weight increased from α to α′, we unmark the leaf (e, α) and mark the leaf (e, α′). Note that only edges in T have their weight changed. ǫ2 (cid:19) time1. For each subtree of T , we track aggregate information and maintain data structures over the set of all marked leaves in the subtree. For a node b in B, let Lb be the set of marked leaves in the subtree rooted at b. For each b ∈ B we maintain two quantities: (a) the number of leaves marked in the subtree rooted at b, Lb; and (b) the sum of edges weights of leaves marked in the subtree rooted at b, Wb = X(e,α)∈Lb α. Since the height of B is O(log n), both of these quantities can be Lemma 3.4. In O(cid:0)m log(n)/ǫ2(cid:1) time initially and O(log n) time per weight update, one can main- tain a data structure that, given ℓ ∈ [n − 1], returns in O(log n) time (a) the ℓ minimum weight edges of the MST (implicitly), and (b) the total weight of the first ℓ edges of the MST. maintained in O(log n) time per weight update. With Lemma 3.2 and Lemma 3.4, we can now compute, for any ℓ ∈ [n − 1], a (1 + ǫ)- approximation to the minimum weight forest of ℓ edges, along with the sum weight of the forest, both in logarithmic time. To find the best forest, then, we need only query the data structure for each of the k − 1 integer values from n − k + 1 to n − 1. That is, excluding the time to maintain the data structures, we can now solve the relaxation (R) in O(k log n) time per iteration. At this point, we still require O(km log n) time just to solve the Lagrangian relaxations (R) generated by the MWU framework. (There are other bottlenecks, such as updating the weights at each iteration, that we have not yet addressed.) To remove the factor of k in solving (R), we require one final observation. Lemma 3.5. The minimum ratio subforest of T can be found by binary search. 1or even less time if we build B lazily, but constructing B is not a bottleneck 12 Proof. Enumerate the MST edges e1, . . . , en−1 ∈ T in increasing order of weight. For ease of notation, we denote wi = wei for i ∈ [n − 1]. We define a function f : [k − 1] → R>0 by f (i) = i j=1 Pn−k+i . wj For each i, f (i) is the ratio achieved by the first n− k + i edges of the MST. Our goal is to maximize f (i) over i ∈ [k − 1]. For any i ∈ [k − 2], we have i + 1 j=1 i j=1 = j=1 wj j=1 j=1 wj j=1 f (i + 1) − f (i) = wj − Pn−k+i+1 Pn−k+i wj − iPn−k+i+1 (i + 1)Pn−k+i (cid:16)Pn−k+i+1 wj(cid:17)(cid:16)Pn−k+i wj(cid:17) Since the denominator   wj wj Xj=1 Xj=1  is positive, we have f (i + 1) ≤ f (i) ⇐⇒    Xj=1 wj for all i ∈ [k− 2], then f (1) < f (2) < ··· < f (k− 1), wj. If i wn−k+i+1 ≥ i wn−k+i+1 ≥ so f (i) is maximized by i = k − 1. Otherwise, let i0 ∈ [k − 2] be the first value of i such that f (i + 1) ≤ f (i). For i1 ≥ i0, as (1) wei is increasing in i, (2) f (i0 + 1) ≤ f (i0), we have wj − i wn−k+i+1 wj(cid:17)(cid:16)Pn−k+i wj(cid:17) = Pn−k+i (cid:16)Pn−k+i+1 Xj=1 n−k+i+1 n−k+i n−k+i j=1 j=1 n−k+i j=1 . n−k+i0 n−k+i1 wj − i0 wn−k+i1+1 + wj − (i1 − i0) wn−k+i1+1 n−k+i1 Xj=1 wj − i1wn−k+i1+1 = (1) ≤ n−k+i0 Xj=1 Xj=1 Xj=n−k+i0+1 ≤ 0. (2) wj − i0 wn−k+i0+1 That is, f (i1 + 1) ≤ f (i1) for all i1 ≥ i0. Thus f consists of one increasing subsequence followed by a decreasing subsequence, and its global maximum is the unique local maximum. (cid:4) By Lemma 3.5, the choice of ℓ can be found by calculating the ratio of O(log k) candidate forests. By Lemma 3.4, the ratio of a candidate forest can be computed in O(log n) time. Lemma 3.6. Given the data structure of Lemma 3.4, one can compute a (1 + O(ǫ))-multiplicative approximation to (R) in O(log n log k) time. The polylogarithmic running time in Lemma 3.6 is surprising when considering that solutions to (R) should require at least a linear number of bits, as discussed earlier in Section 2.3. In hindsight, a combination of additional structure provided by the MWU framework and the LP (P) allows us to apply data structures that effectively compress the forests and output each forest in polylogarithmic amortized time. Implicit compression of this sort also appears in previous work [5, 4, 8]. 13 4 Packing greedy forests in O(cid:0)log2 n(cid:1) amortized time In Section 3, we showed how to solve (R) in polylogarithmic time per iteration. In this section, we address the second main bottleneck: updating the weights w after increasing y to y + δz per the formula (1), where z is an approximate solution to the relaxation (R) and δ > 0 is the largest possible value such that no weight increases by more than a (1 + ǫ)-multiplicative factor. As discussed in Section 2.3, this may be hard to do in polylogarithmic time when many of the edges e ∈ E require updating. A sublinear time weight update must depend heavily on the structure of the solutions generated to (R). In our case, each solution z to a relaxation (R) is of the form γeF , where eF is the indicator vector of a forest F and γ > 0 is a scalar as large as possible subject to the packing constraint in (R). We need to update the weights to reflect the loads induced by δz = δγeF , where δ is chosen large as possible so that no weight increases by more than an exp(ǫ)-multiplicative factor. With this choice of δ, the weight update simplifies to the following formula. Let w denote the set of weights before the updates and w′ denote the set of weights after the updates. For a solution z = γeF , we have w′ e =  we exp(cid:18) ǫ minf ∈F cf ce if e /∈ F, (cid:19) if e ∈ F. (4) The weight update formula above can be interpreted as follows. Because our solution is supported along a single forest F , the only edges whose loads are effected are those in the forest F . As load is relative to the capacity of an edge e, the increase of the logarithm the weight we of an edge e ∈ F is cf has its inversely proportional to its capacity. By choice of δ, the minimum capacity edge arg min f ∈F weight increased by an exp(ǫ) multiplicative factor. The remaining edges with larger capacity each have the logarithm of their weight increased in proportion to the ratio of the bottleneck capacity to its own capacity. Simplifying the weight update formula does not address the basic problem of updating the weights of every edge in a forest F , without visiting every edge in F . Here we require substantially more structure as to how the edges in F are selected. We observe that although there may be Ω(n) edges in F , we can always decompose F into a logarithmic number of "canonical subforests", as follows. Lemma 4.1. One can maintain, in O(log n) time per update to the MST T , a collection of subforests CT such that: (i) CT = O(n log n). (ii) Each edge e ∈ T is contained in O(log n) forests. (iii) For each ℓ ∈ [n − 1], the forest F consists of the ℓ minimum weight edges in T decomposes 14 uniquely into the disjoint union of O(log n) forests in F. The decomposition can be computed in O(log n) time. In fact, the collection of subforests is already maintained implicitly in Lemma 3.4. Recall, from Section 3, the balanced binary tree B over the leaf set L, which consists of all possible discretized weight-to-edge assignments and is ordered in increasing order of weight. Leaves are marked accord- ing to the edges in the MST T , and each node is identified with the forest consisting of all marked leaves in the subtree rooted at the node. For each ℓ ∈ [n−1], the forest Fℓ induced by the ℓ minimum weight edges in T is the set of marked leaves over an interval of L. The interval decomposes into the disjoint union of leaves of O(log n) subtrees, which corresponds to decomposing Fℓ into the disjoint union of marked leaves of O(log n) subtrees of B. That is, the forests of marked leaves induced by subtrees of B gives the "canonical forests" CT that we seek. The following technique of decomposing weight updates is critical to previous work [5, 4, 8]; we briefly discuss the high-level ideas and refer to previous work for complete details. Decomposing the solution into a small number of known static sets is important because weight updates can be simulated over a fixed set efficiently. The data structure lazy-inc, defined in [5] and inspired by techniques by Young [50], simulates a weight update over a fixed set of weights in such a way that the time can be amortized against the logarithm of the increase in each of the weights. As discussed above, the total logarithmic increase in each of the weights is bounded from above. The data structure lazy-inc is dynamic, allowing insertion and deletion into the underlying set, in O(log n) time per insertion or deletion [4]. We define an instance of lazy-inc at each node in the balanced binary tree B. Whenever a leaf is marked as occupied, the corresponding edge is inserted into each of O(log n) instances of lazy-inc at the ancestors of the leaf; when a leaf is marked as unoccupied, it is removed from each of these instances as well. Each instance of lazy-inc can then simulate a weight update over the marked leaves at its nodes in O(1) constant time per instance, plus a total O(log n) amortized time. More precisely, the additional time is amortized against the sum of increases in the logarithms of the weights, which (as discussed earlier) is bounded above by O(cid:0)m log(n)/ǫ2(cid:1). We also track, for each canonical forest, the minimum capacity of any edge in the forest. The minimum capacity ultimately controls the rate at which all the other edges increase, per (2). Given a forest F induced by the ℓ minimum weight edges of T , we decompose F into the disjoint union of O(log n) canonical subforests of T . For each subforest we have precomputed the minimum capacity, and an instance of lazy-inc that simulates weight updates on all edges in the subforest. The minimum capacity over edges in F determines the rate of increase, and the increase is made to each instance of lazy-inc in O(1) time per instance plus O(log n) amortized time over all instances. Lemma 4.2. Given a forest F generated by Lemma 3.6, one can update the edge weights per (2) in O(cid:0)log2 n(cid:1) amortized time per iteration. Note that Lemma 4.2 holds only for the forests output by Lemma 3.6. We can not decom- pose other forests in G, or even other subforests of T , into the disjoint union O(log n) subforests. 15 Lemma 4.1 holds specifically for the forests induced by the ℓ minimum weight edges of T , for varying values of ℓ. This limitation highlights the importance of coupling the oracle and the weight update: the running time in Lemma 3.6 for solving (R) is amortized against the growth of the weights, and the weight updates in Lemma 4.2 leverage the specific structure by which solutions to (R) are generated. We note that the lazy-inc data structures can be replaced by random sampling in the random- ized MWU framework [7]. Here one still requires the decomposition into canonical subforests; an efficient threshold-based sampling is then conducted at each subforest. 5 Putting things together In this section, we summarize the main points of the algorithm and account for the running time claimed in Theorem 1.3. Proof of Theorem 1.3. By standard analysis (e.g., [5, Theorem 2.1]), the MWU framework returns a (1 − O(ǫ))-multiplicative approximation to the packing LP (P) as long as we can approximate the relaxation (R) to within a (1 − O(ǫ))-multiplicative factor. This slack allows us to maintain the weight we to within a (1 ± O(ǫ))-multiplicative factor of the "true weights" given (up to a leading constant) by (1). In particular, we only propagate a change to we when it has increased by a (1 + ǫ)-multiplicative factor. Each weight we is monotonically increasing and its growth is bounded by a mO( 1 ǫ )-multiplicative factor, so each weight we increases by a (1 + ǫ)-multiplicative factor running time is amortized against the number of weight updates, as the solution can be updated O(cid:18) log m ǫ2 (cid:19) times. By Lemma 3.6, each instance of (R) can be solved in O(cid:0)log2 n(cid:1) amortized time. Here the dynamically in O(cid:0)log2 n(cid:1) amortized time. By Lemma 4.2, the weight update w/r/t a solution generated by Lemma 3.6 can be implemented in O(cid:0)log2 n(cid:1) amortized time. Here again the running time is amortized against the growth of the edge weights. Since there are O(cid:18) m log n ǫ2 (cid:19) total edge updates, this gives a total running time of O(cid:18) m log3 n (cid:4) ǫ2 (cid:19). 6 Rounding fractional forest packings to k-cuts In this section, we show how to round a fractional solution x to (L) a k-cut of cost at most twice the cost of x. The rounding scheme is due to Chekuri et al. [9] for the more general problem of Steiner k- cuts. The rounding scheme extends the primal-dual framework of Goemans and Williamson [15, 16]. In hindsight, we realized the primal-dual framework is only required for the analysis, and that the algorithm itself is very simple. We first give a conceptual description of the algorithm, called greedy-cuts. The conceptual description suffices for the sake of analyzing the approximation guarantee. Later, we give imple- mentation details and demonstrate that it can be executed in O(m log n) time. 16 greedy-cuts(G = (V, E),c,x) (conceptual sketch) 1. let E′ =(cid:26)e ∈ E : xe ≥ 2n (cid:27), E ← E \ E′ n − 1 2. if E′ is a k-cut then return E′ 3. let F be a minimum weight spanning forest w/r/t x with ℓ components 4. return the union of E′ and the k − ℓ minimum weight greedy cuts of F Figure 1: A conceptual sketch of a deterministic rounding algorithm for k-cut. To describe the algorithm, we first introduce the following definitions. Definition 6.1. Let F be a minimum weight spanning forest in a weighted, undirected graph, and order the edges of F in increasing order of weight (breaking ties arbitrarily). A greedy component of F is a connected component induced by a prefix of F . A greedy cut is a cut induced by a greedy component of F . The rounding algorithm is conceptually very simple and a pseudocode sketch is given in Figure 1. We first take all the edges with xe > 1/2+o(1). If this is already a k-cut, then it is a 2-approximation because the corresponding indicator vector is ≤ (2 − o(1))x. Otherwise, we compute the minimum spanning forest F in the remaining graph, where the weight of an edge is given by x. Letting ℓ be number of components of F , we compute the k − ℓ minimum weight greedy cuts w/r/t F . We output the union of E′ and the k − ℓ greedy cuts. Chekuri, Guha, and Naor [9] implicitly showed that this algorithm has an approximation factor of 2(1 − 1/n). Their analysis is for the more general Steiner k-cut problem, where we are given a set of terminal vertices T , and want to find the minimum weight set of edges whose removal divides the graph into at least k components each containing a terminal vertex t ∈ T . The algorithm and analysis is based on the primal-dual framework of Goemans and Williamson [15, 16]. For the minimum weight Steiner tree problem, the primal-dual framework returns a Steiner tree and a feasible fractional cut packing in the dual LP. The cost of the Steiner cut packing is within a 2(1 − o(1))-multiplicative factor of the corresponding Steiner tree. Via LP duality, the Steiner tree and the cut packing mutually certify an approximation ratio of 2(1 − o(1)). The cut packing certificate has other nice properties, and Chekuri, Guha, and Naor [9] show that the k− 1 minimum cuts in the support of the fractional cut packing give a 2-approximate Steiner k-cut. For the (non-Steiner) k-cut problem, we want minimum cuts in the support of the fractional cut packing returned by the primal-dual framework applied to minimum spanning forests. To shorten the algorithm, we observe that (a) the primal-dual framework returns the minimum spanning forest, and (b) the cuts supported by the corresponding dual certificate are precisely the greedy cuts of the minimum spanning forest. Thus greedy-cuts essentially refactors the algorithm analyzed by 17 greedy-cuts(G = (V, E),c,x) 1. let E′ =(cid:26)e ∈ E : xe ≥ 2n (cid:27), E ← E \ E′ n − 1 2. if E′ is a k-cut then return E′ 3. let F be a minimum weight spanning forest w/r/t x with ℓ components /* Arrange the greedily induced components as subtrees of a dynamic forest */ 4. for each v ∈ V (a) make a singleton tree labeled by v 5. for each edge f = {u, v} ∈ F in increasing order of xf (a) let Tu and Tv be the rooted trees containing u and v, respectively. (b) make Tu and Tv children of a new vertex labeled by f /* Compute the weight of each cut induced by a greedy component. */ 6. let each node in the dynamic forest have value 0 7. for each edge e = {u, v} ∈ E (a) add xe to the value of every node on the u-to-root and v-to-root paths (b) let w be the least common ancestor u and v (c) subtract 2xe from the value of every node on the w to root paths 8. let v1, v2, . . . , vk−ℓ be the k − ℓ minimum value nodes in the dynamic forest. For i ∈ [k − ℓ], let Ci be the components induced by the leaves in the subtree rooted by vi. 9. return E′ ∪ ∂(C1) ∪ ··· ∪ ∂(Ck−ℓ) Figure 2: A detailed implementation of a deterministic rounding algorithm for k-cut. Chekuri et al. [9]. Lemma 6.2 (9). greedy-cuts returns a k-cut of weight at most 2(cid:18)1 − 1 n(cid:19)hc, xi. The connection to Chekuri et al. [9] is not explicitly clear because Chekuri et al. rounded a slightly more complicated LP. The complication arises from the difficulty of solving (L) directly for Steiner k-cut (which can be simplified by knapsack covering constraints, in hindsight). Morally, however, their proof extends to our setting here. For the sake of completeness, a proof of Lemma 6.2 is included in Appendix A. It remains to implement greedy-cuts in O(m log n) time. With the help of dynamic trees 18 [44], this can be done in a straightforward fashion. We briefly describe the full implementation; pseudocode is given in Figure 2. Recall from the conceptual sketch above that greedy-cuts requires up to k − 1 minimum greedy cuts of a minimum spanning forest w/r/t x. To compute the value of these cuts, greedy-cuts first simulates the greedy algorithm by processing the edges in the spanning forest in increasing order of x. The greedy algorithm repeatedly adds an edge that bridges two greedy components. We assemble a auxiliary forest of dynamic trees where each leaf is a vertex, and each subtree corresponds to a greedy component induced by the vertices at the leaves of the subtree. After building this dynamic forest, we compute the number of edges in each cut. We associate each node in the dynamic forest with the greedy component induced by its leaves, and given each node an initial value of 0. We process edges one at a time and add its weight to the value of every node corresponding to a greedy component cutting that edge. Now, an edge in the original graph is cut by a greedy component iff the corresponding subtree in the dynamic forest does not contain both its end points as leaves. We compute the least common ancestor of the endpoints in the dynamic forest in O(log n) time [22], and add the weight of edge to every node between the leaves and the common ancestor, excluding the common ancestor. Adding the weight to every node on a node-to-root path takes O(log n) time [44] in dynamic trees. After processing every edge, we simply read off the value of each greedy cut as the value of the corresponding node in the forest. Thus we have the following. Lemma 6.3. greedy-cuts can be implemented in O(m log n) time. Together, Lemma 6.2 and Lemma 6.3 imply Theorem 1.4. Acknowledgements The author thanks Chandra Chekuri for introducing him to the problem and providing helpful feedback, including pointers to the literature for rounding the LP. We thank Chao Xu for pointers to references. References [1] Francisco Barahona. On the k-cut problem. Oper. Res. Lett., 26(3):99 -- 105, 2000. [2] Robert D. Carr, Lisa Fleischer, Vitus J. Leung, and Cynthia A. Phillips. Strengthening in- tegrality gaps for capacitated network design and covering problems. In Proceedings of the Eleventh Annual ACM-SIAM Symposium on Discrete Algorithms, January 9-11, 2000, San Francisco, CA, USA., pages 106 -- 115. ACM/SIAM, 2000. [3] Deeparnab Chakrabarty, Chandra Chekuri, Sanjeev Khanna, and Nitish Korula. Approxima- bility of capacitated network design. Algorithmica, 72(2):493 -- 514, 2015. Preliminary version in IPCO 2011. 19 [4] Chandra Chekuri and Kent Quanrud. Approximating the Held-Karp bound for metric TSP in nearly-linear time. In 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, 2017, pages 789 -- 800. IEEE Computer Society, 2017. [5] Chandra Chekuri and Kent Quanrud. Near-linear time approximation schemes for some im- plicit fractional packing problems. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 801 -- 820. SIAM, 2017. [6] Chandra Chekuri and Kent Quanrud. Fast approximations for metric-TSP via linear program- ming. CoRR, abs/1802.01242, 2018. URL https://arxiv.org/abs/1802.01242. [7] Chandra Chekuri and Kent Quanrud. Randomized MWU for positive LPs. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, January 7-10, 2018, pages 358 -- 377. SIAM, 2018. [8] Chandra Chekuri and Kent Quanrud. On approximating (sparse) covering integer programs. CoRR, abs/1807.11538, 2018. URL http://arxiv.org/abs/1807.11538. To appear in SODA, 2019. [9] Chandra Chekuri, Sudipto Guha, and Joseph Naor. The Steiner k-cut problem. SIAM J. Discrete Math., 20(1):261 -- 271, 2006. Preliminary version in ICALP 2003. [10] Chandra Chekuri, Kent Quanrud, and Chao Xu. LP relaxation and tree packing for minimum k-cuts. CoRR, abs/1808.05765, 2018. URL http://arxiv.org/abs/1808.05765. To appear in SOSA, 2019. [11] Rajesh Chitnis, Marek Cygan, MohammadTaghi Hajiaghayi, Marcin Pilipczuk, and Michal Pilipczuk. Designing FPT algorithms for cut problems using randomized contractions. SIAM J. Comput., 45(4):1171 -- 1229, 2016. Preliminary version in FOCS 2012. [12] Rodney G. Downey, Vladimir Estivill-Castro, Michael R. Fellows, Elena Prieto-Rodriguez, and Frances A. Rosamond. Cutting up is hard to do: the parameterized complexity of k-cut and related problems. Electr. Notes Theor. Comput. Sci., 78:209 -- 222, 2003. [13] Naveen Garg and Jochen Könemann. Faster and simpler algorithms for multicommodity flow and other fractional packing problems. In 39th Annual Symposium on Foundations of Computer Science, FOCS '98, November 8-11, 1998, Palo Alto, California, USA, pages 300 -- 309. IEEE Computer Society, 1998. [14] Naveen Garg and Jochen Könemann. Faster and simpler algorithms for multicommodity flow and other fractional packing problems. SIAM J. Comput., 37(2):630 -- 652, 2007. Preliminary version in FOCS 1998. 20 [15] Michel X. Goemans and David P. Williamson. A general approximation technique for con- strained forest problems. SIAM J. Comput., 24(2):296 -- 317, 1995. Preliminary version in SODA 1992. [16] Michel X. Goemans and David P. Williamson. The primal-dual method for approximation algorithms and its applications to network design problems. In Dorit S. Hochbaum, editor, Approximation Algorithms for NP-Hard Problems, pages 144 -- 191. PWS Publishing Company, Boston, MA, July 1996. [17] Andrew V. Goldberg and Satish Rao. Beyond the flow decomposition barrier. J. ACM, 45(5): 783 -- 797, 1998. Preliminary version in FOCS 1997. [18] Olivier Goldschmidt and Dorit S. Hochbaum. A polynomial algorithm for the k-cut problem for fixed k. Math. Oper. Res., 19(1):24 -- 37, 1994. Preliminary version in FOCS 1988. [19] Anupam Gupta, Euiwoong Lee, and Jason Li. An FPT algorithm beating 2-approximation for k-cut. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, January 7-10, 2018, pages 2821 -- 2837. SIAM, 2018. [20] Anupam Gupta, Euiwoong Lee, and Jason Li. Faster exact and approximate algorithms for k-cut. In 59th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2018, Paris, France, October 7-9, 2018. IEEE Computer Society, 2018. [21] Jianxiu Hao and James B. Orlin. A faster algorithm for finding the minimum cut in a directed graph. J. Algorithms, 17(3):424 -- 446, 1994. Preliminary version in SODA 1992. [22] Dov Harel and Robert Endre Tarjan. Fast algorithms for finding nearest common ancestors. SIAM J. Comput., 13(2):338 -- 355, 1984. [23] Monika Henzinger, Satish Rao, and Di Wang. Local flow partitioning for faster edge connec- tivity. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Al- gorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 1919 -- 1938. SIAM, 2017. [24] Jacob Holm, Kristian de Lichtenberg, and Mikkel Thorup. Poly-logarithmic deterministic fully- dynamic algorithms for connectivity, minimum spanning tree, 2-edge, and biconnectivity. J. ACM, 48(4):723 -- 760, 2001. Preliminary version in STOC 1998. [25] David R. Karger. Minimum cuts in near-linear time. J. ACM, 47(1):46 -- 76, 2000. Preliminary version in STOC 1996. [26] David R. Karger and Clifford Stein. A new approach to the minimum cut problem. J. ACM, 43(4):601 -- 640, 1996. Preliminary version in STOC 1993. 21 [27] Ken-ichi Kawarabayashi and Mikkel Thorup. The minimum k-way cut of bounded size is fixed- parameter tractable. In IEEE 52nd Annual Symposium on Foundations of Computer Science, FOCS 2011, Palm Springs, CA, USA, October 22-25, 2011, pages 160 -- 169. IEEE Computer Society, 2011. [28] Ken-ichi Kawarabayashi and Mikkel Thorup. Deterministic global minimum cut of a simple graph in near-linear time. In Proceedings of the Forty-Seventh Annual ACM on Symposium on Theory of Computing, STOC 2015, Portland, OR, USA, June 14-17, 2015, pages 665 -- 674. ACM, 2015. [29] Stavros G. Kolliopoulos and Neal E. Young. Tight approximation results for general covering integer programs. In 42nd Annual Symposium on Foundations of Computer Science, FOCS 2001, 14-17 October 2001, Las Vegas, Nevada, USA, pages 522 -- 528. IEEE Computer Society, 2001. [30] Stavros G. Kolliopoulos and Neal E. Young. Approximation algorithms for covering/packing integer programs. J. Comput. Syst. Sci., 71(4):495 -- 505, 2005. Preliminary version in FOCS 2001. [31] Yin Tat Lee and Aaron Sidford. Path finding methods for linear programming: Solving linear programs in O(√rank) iterations and faster algorithms for maximum flow. Annual Symposium on Foundations of Computer Science, FOCS 2014, Philadelphia, PA, USA, October 18-21, 2014, pages 424 -- 433. IEEE Computer Society, 2014. In 55th IEEE [32] Matthew S. Levine. Fast randomized algorithms for computing minimum {3, 4, 5, 6}-way cuts. In Proceedings of the Eleventh Annual ACM-SIAM Symposium on Discrete Algorithms, January 9-11, 2000, San Francisco, CA, USA., pages 735 -- 742, 2000. [33] On-Hei Solomon Lo, Jens M. Schmidt, and Mikkel Thorup. Contraction-based sparsification in near-linear time. CoRR, abs/1810.03865, 2018. URL http://arxiv.org/abs/1810.03865. To appear in SOSA, 2019. [34] Aleksander Madry. Computing maximum flow with augmenting electrical flows. In IEEE 57th Annual Symposium on Foundations of Computer Science, FOCS 2016, 9-11 October 2016, Hyatt Regency, New Brunswick, New Jersey, USA, pages 593 -- 602. IEEE Computer Society, 2016. [35] Pasin Manurangsi. Inapproximability of maximum edge biclique, maximum balanced biclique and minimum k-cut from the small set expansion hypothesis. In 44th International Colloquium on Automata, Languages, and Programming, ICALP 2017, July 10-14, 2017, Warsaw, Poland, volume 80 of LIPIcs, pages 79:1 -- 79:14. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2017. 22 [36] Hiroshi Nagamochi and Toshihide Ibaraki. Computing edge-connectivity in multiple and ca- pacitated graphs. In Algorithms, International Symposium SIGAL '90, Tokyo, Japan, August 16-18, 1990, Proceedings, volume 450 of Lecture Notes in Computer Science, pages 12 -- 20. Springer, 1990. [37] Hiroshi Nagamochi and Toshihide Ibaraki. A linear-time algorithm for finding a sparse k- connected spanning subgraph of a k-connected graph. Algorithmica, 7(5&6):583 -- 596, 1992. [38] Hiroshi Nagamochi and Toshihide Ibaraki. Computing edge-connectivity in multigraphs and capacitated graphs. SIAM J. Discrete Math., 5(1):54 -- 66, 1992. [39] Hiroshi Nagamochi and Yoko Kamidoi. Minimum cost subpartitions in graphs. Inf. Process. Lett., 102(2-3):79 -- 84, 2007. [40] Joseph Naor and Yuval Rabani. Tree packing and approximating k-cuts. In Proceedings of the Twelfth Annual Symposium on Discrete Algorithms, January 7-9, 2001, Washington, DC, USA., pages 26 -- 27. ACM/SIAM, 2001. [41] C. St. J. A. Nash-Williams. Edge-disjoint spanning trees of finite graphs. J. London Math. Soc., 36:445 -- 450, 1961. [42] R. Ravi and Amitabh Sinha. Approximating k-cuts using network strengths as a Lagrangean relaxation. European Journal of Operational Research, 186(1):77 -- 90, 2008. Preliminary version in SODA 2002. [43] Huzur Saran and Vijay V. Vazirani. Finding k cuts within twice the optimal. SIAM J. Comput., 24(1):101 -- 108, 1995. Preliminary version in FOCS 1991. [44] Daniel Dominic Sleator and Robert Endre Tarjan. A data structure for dynamic trees. J. Comput. Syst. Sci., 26(3):362 -- 391, 1983. Preliminary version in STOC 1981. [45] Mechthild Stoer and Frank Wagner. A simple min-cut algorithm. J. ACM, 44(4):585 -- 591, 1997. Preliminary version in ESA 1994. [46] Mikkel Thorup. Minimum k-way cuts via deterministic greedy tree packing. In Proceedings of the 40th Annual ACM Symposium on Theory of Computing, Victoria, British Columbia, Canada, May 17-20, 2008, pages 159 -- 166. ACM, 2008. [47] W. T. Tutte. On the problem of decomposing a graph into n connected components. J. London Math. Soc., 36:221 -- 230, 1961. [48] Mingyu Xiao, Leizhen Cai, and Andrew Chi-Chih Yao. Tight approximation ratio of a general greedy splitting algorithm for the minimum k-way cut problem. Algorithmica, 59(4):510 -- 520, 2011. 23 [49] Neal E. Young. Sequential and parallel algorithms for mixed packing and covering. In 42nd Annual Symposium on Foundations of Computer Science, FOCS 2001, 14-17 October 2001, Las Vegas, Nevada, USA, pages 538 -- 546. IEEE Computer Society, 2001. [50] Neal E. Young. Nearly linear-time approximation schemes for mixed pack- ing/covering and facility-location linear programs. CoRR, abs/1407.3015, 2014. URL http://arxiv.org/abs/1407.3015. A Proofs for Section 6 Chekuri et al. [9] gave a rounding scheme for the more general problem of Steiner k-cut and the analysis extends to the rounding schemes presented here. We provide a brief sketch for the sake of completeness as there are some slight technical gaps. The proof is simpler and more direct in our setting because we have a direct fractional solution to (L), while Chekuri et al. [9] dealt with a solution to a slightly more complicated LP. We note that our analysis also extends to Steiner cuts. We take as a starting point the existence of a dual certificate from the primal-dual framework. Lemma A.1 (15, 16). Let F be a minimum spanning forest in a undirected graph G = (V, E) weighted by x ∈ RE ′ ≥0. Let C be the family of greedy cuts induced by F . Then there exists y ∈ RC satisfying the following properties. ≥0 yC ≤ xe. yC = xe. (a) For each edge e ∈ E, XC∈C:C∋e (b) For each edge e ∈ F , XC∈C:C∋e (c) 2(cid:18)1 − n(cid:19)hy, 1i ≥Xe∈F xe. 1 We note that the dual variables y can be computed in O(n) time (after computing the minimum spanning forest). Lemma A.2 (9). greedy-cuts returns a k-cut with total cost ≤ 2(cid:18)1 − 1 n(cid:19)hc, xi. n Proof sketch. Let y be as in Lemma A.1. We first make two observations about y. First, since xe ≤ greedy cuts C. Second, by (1) property (c) of Lemma A.1 and (2) the feasibility of x w/r/t the for all e ∈ E′, we have (by property (a) of Lemma A.1) that yC ≤ 2(n − 1) 2(n − 1) n for all k-cut LP (L), we have 2(cid:18)1 − 1 n(cid:19)hy, 1i (1) ≥ Xe∈T xe (2) ≥ k − 1. 24 Let C1, . . . , Ck−1 be the k − 1 minimum greedy cuts. Now, by (3) rewriting the sum of the k − 1 minimum greedy cuts as the solution of a minimization problem, (4) observing that 2(cid:18)1 − n(cid:19)y is a feasible solution to the minimization problem, (5) interchanging sums, and (6) property (a) of 1 Lemma A.1, we have c(Ci) k−1 Xi=1 (3) (4) = min(cid:8)(cid:10)y′, c(cid:11) : 0 ≤ y′ ≤ 1, support y′ ⊆ support y, and (cid:13)(cid:13)y′(cid:13)(cid:13)1 ≥ k − 1(cid:9) ≤ 2(cid:18)1 − n(cid:19)hy, ci =XC ≤ Xe∈E ′ yCXe∈C (5) = Xe∈E ′ ceXC∋e cexe, (6) yC 1 ce as desired. (cid:4) 25
1412.3852
3
1412
2015-11-25T18:01:18
Fully Dynamic All Pairs All Shortest Paths
[ "cs.DS" ]
We consider the all pairs all shortest paths (APASP) problem, which maintains all of the multiple shortest paths for every vertex pair in a directed graph G=(V,E) with a positive real weight on each edge. We present a fully dynamic algorithm for this problem in which an update supports either weight increases or weight decreases on a subset of edges incident to a vertex. Our algorithm runs in amortized O(\vstar^2 \cdot \log^3 n) time per update, where n = |V|, and \vstar bounds the number of edges that lie on shortest paths through any single vertex. Our APASP algorithm leads to the same amortized bound for the fully dynamic computation of betweenness centrality (BC), which is a parameter widely used in the analysis of large complex networks. Our method is a generalization and a variant of the fully dynamic algorithm of Demetrescu and Italiano [DI04] for unique shortest path, and it builds on very recent work on decremental APASP [NPR14]. Our algorithm matches the fully dynamic amortized bound in [DI04] for graphs with unique shortest paths, though our method, and especially its analysis, are different.
cs.DS
cs
Fully Dynamic All Pairs All Shortest Paths∗ Matteo Pontecorvi and Vijaya Ramachandran University of Texas at Austin, USA {cavia,vlr}@cs.utexas.edu Abstract We consider the all pairs all shortest paths (APASP) problem, which maintains all of the multiple shortest paths for every vertex pair in a directed graph G = (V, E) with a positive real weight on each edge. We present a fully dynamic algorithm for this problem in which an update supports either weight increases or weight decreases on a subset of edges incident to a vertex. Our algorithm runs in amortized O(ν ∗ 2 · log3 n) time per update, where n = V , and ν ∗ bounds the number of edges that lie on shortest paths through any single vertex. Our APASP algorithm leads to the same amortized bound for the fully dynamic computation of betweenness centrality (BC), which is a parameter widely used in the analysis of large complex networks. Our method is a generalization and a variant of the fully dynamic algorithm of Demetrescu and Italiano [7] for unique shortest paths, and it builds on very recent work on decremental APASP [19]. Our algorithm matches the fully dynamic amortized bound in [7] for graphs with unique shortest paths, though our method, and especially its analysis, are different. 1 Introduction Given a directed graph G = (V, E) with positive edge weights, we consider the problem of maintaining APASP (all pairs all shortest paths) [19], i.e., the set of all shortest paths between all pairs of vertices. This is a fundamental graph property, and it also enables the efficient computation of betweenness centrality (BC) for every vertex in the graph. BC is a widely used measure for the analysis of social networks. In this paper we present a fully dynamic algorithm for the APASP problem, where each update in G is either incremental or decremental. An incremental update either inserts a new vertex along with incident edges of finite weight, or decreases the weights of some existing edges incident on a vertex. A decremental update deletes an existing vertex, or increases the weights of some edges incident on a vertex.1 Recently, we gave (with Nasre) a simple incremental APASP algorithm [18], and a more involved decre- mental APASP algorithm [19]. Neither of these algorithms is correct for the fully dynamic case. The fully dynamic method that we present in this paper builds on [19], and is a variant of the fully dynamic method developed by Demetrescu and Italiano [7] for APSP (the 'DI' method) where only one shortest path is main- tained for each pair of vertices. The DI algorithm runs in O(n2 · log3 n) amortized time per update, where n = V . A method that is faster by a logarithmic factor was given by Thorup [27], but this algorithm is considerably more complicated, even for the unique shortest paths case. For instance, the experimental study in [8] considers the DI method and a few other methods, but omits the algorithm in [27], deeming it to be mainly of theoretical interest. The algorithms in both [7] and [27] use the unique shortest paths assumption crucially, and need considerable enhancements even to maintain a small number of multiple shortest paths ∗This work was supported in part by NSF grants CCF-0830737 and CCF-1320675. Authors' affiliation: Dept. of Computer Science, University of Texas, Austin, TX 78712. An extended abstract of the results in this paper is in Proc. ISAAC 2015. 1Incremental/decremental refer to the insertion/deletion of a vertex or edge; the corresponding weight changes that apply are weight decreases/increases, respectively. 1 correctly. In this paper we present a fully dynamic algorithm for APASP, which maintains all of the multiple shortest paths for every pair of vertices. Our algorithm is as simple as the DI method (though somewhat different) when specialized to unique shortest paths, and it matches the DI bound for graphs with a constant number of (or unique) shortest paths while being applicable to the more general APASP problem. Our APASP algorithm gives a fully dynamic algorithm for the betweenness centrality (BC) problem, described below. Betweenness Centrality (BC). Betweenness centrality is a widely-used measure in the analysis of large complex networks, and is defined as follows. For any pair x, y in V , let σxy denote the number of shortest paths from x to y in G, and let σxy(v) denote the number of shortest paths from x to y in G that pass through v. Then, BC(v) = Ps6=v,t6=v . This measure is often used as an index that determines the relative importance of v in the network. Some applications of BC include analyzing social interaction networks [13], identifying lethality in biological networks [20], and identifying key actors in terrorist networks [5, 15]. Heuristics for dynamic betweenness centrality with good experimental performance are given in [10, 16, 25], but none of these heuristics provably improve on the widely used static algorithm by Brandes [4], which runs in O(mn + n2 log n) time (where m = E) on any class of graphs. The only earlier results that provably improve on Brandes on some classes of graphs are the recent separate incremental and decremental algorithms in [18, 19]. Table 1 contains a summary of these results. σst(v) σst It is shown in [18, 19] that a decremental APASP algorithm can be used to give a decremental BC algorithm with the same bound. In a similar way, our fully dynamic APASP algorithm gives a fully dynamic BC algorithm with the same bound. We do not give further details for fully dynamic BC here. Paper Brandes [4] Brandes [4] Geisberger et al. [9] Riondato et al. [23] Green et al. [10] Kas et al. [12] NPR [18] NPRdec [19] Bergamini et al. [3] Lee et al. [16] Singh et al. [25] Kourtellis+ [14] Bergamini et al. [2] This paper Year 2001 2001 2007 2014 2012 2013 2014 2014 2015 2012 2013 2014 2015 2015 Weights Update Type DR/UN Result Time O(mn) O(mn + n2 log n) Heuristic depends on ǫ NO YES YES YES Semi Dynamic O(mn) Heuristic O(ν ∗ · n) O(ν ∗ 2 · log n) depends on ǫ NO YES YES YES YES Fully Dynamic Heuristic Heuristic O(mn) depends on ǫ O(ν ∗ 2 · log3 n) NO NO NO YES YES Static Alg. Static Alg. Static Alg. Static Alg. Edge Inc. Edge Inc. Vertex Inc. Vertex Dec. Batch (edges) Inc. Edge Update Vertex Update Edge Update Batch (edges) Vertex Update Both Both Both Both Both Both Both Both Both UN UN Both UN Both Exact Exact Approx. ǫ-Approx. Exact Exact Exact Exact ǫ-Approx. Exact Exact Exact ǫ-Approx. Exact Table 1: Related results (DR stands for Directed and UN for Undirected) Our Results. Let ν∗ be the maximum number of edges that lie on shortest paths through any given vertex in G. Our main result is the following theorem, where we assume for convenience ν∗ = Ω(n). Theorem 1. Let Σ be a sequence of Ω(n) fully dynamic APASP updates on an n-node graph G = (V, E). Then, APASP and all BC scores can be maintained in amortized time O(ν∗ 2 · log3 n) per update, where ν∗ bounds the number of distinct edges that lie on shortest paths through any given vertex in any of the updated graphs or their vertex induced subgraphs. Discussion of the Parameter ν∗. Let m∗ be the number of edges in G that lie on shortest paths. As noted in [11], it is well-known that m∗ = O(n log n) with high probability in a complete graph where edge weights are chosen from a large class of probability distributions. Since ν∗ ≤ m∗, our algorithms will have an amortized bound of O(n2 · polylog(n)) on such graphs. Also, ν∗ = O(n) in any graph with only a constant number of shortest paths between every pair of vertices. These graphs are called k-geodetic [22] (when at most k SPs exists between two nodes), and are well studied in graph theory [26, 1, 17]. In fact ν∗ = O(n) even in some graphs that have an exponential number of SPs between some pairs of vertices. In contrast, 2 m∗ can be Θ(n2) even in some graphs with unique SPs, for example the complete unweighted graph Kn. Another type of graph with ν∗ ≪ m∗ is one with large clusters of nodes (e.g., as described by the planted ℓ-partition model [6, 24]). Consider a graph H with k clusters of size n/k (for some constant k ≥ 1) with δ < w(e) ≤ 2δ, for some constant δ > 0, for each edge e in a cluster; between the clusters is a sparse interconnect. Then m∗ = Ω(n2) but ν∗ = O(n). In all such cases our algorithm will run in amortized O(n2 log3 n) time per update. Thus we have: Theorem 2. Let Σ be a sequence of Ω(n) updates on graphs with O(n) distinct edges on shortest paths through any single vertex in any vertex-induced subgraph. Then, APASP and all BC scores can be maintained in amortized time O(n2 · log3 n) per update. Corollary 3. If the number of shortest paths through any single vertex is bounded by a constant, then fully dynamic APASP and BC have amortized cost O(n2 · log3 n) per update if the update sequence has length Ω(n). Our algorithm uses eO(m · ν∗) space, extending the eO(mn) result in DI for APSP. Brandes uses only linear space, but all known dynamic algorithms require at least Ω(n2) space. In a companion paper [21], we present a fully dynamic APASP algorithm that gives a logarithmic factor improvement over the results in Theorems 1 and 2, and Corollary 3. This algorithm is considerably more complex than the algorithm we present in the current paper. Overview of the Paper. In Section 2 we review the DI fully dynamic algorithm as well as the decremental APASP algorithm in [19]. In contrast to the DI method, the decremental algorithm in [19] is not a correct fully dynamic APASP algorithm. In Section 3 we describe a basic fully dynamic APASP algorithm, which includes suitable enhancements to [19] to be correct for fully dynamic updates. However, this algorithm is not very efficient. In Section 4 we present fully-dynamic, our overall fully dynamic algorithm, which is similar to the DI fully dynamic algorithm but uses a different 'dummy update' sequence. In Section 5 we analyze our algorithm and establish the amortized time bound claimed in Theorem 1. The paper ends with a conclusion in Section 6. 2 Background Our fully dynamic APASP algorithm builds on the approach used in the elegant fully dynamic APSP algorithm of Demetresu and Italiano [7] for unique shortest paths (the 'DI' method). It also builds on the decremental APASP algorithm in [19] (the 'NPR' method). We now briefly review these two methods, and then we give an overview of our method for fully dynamic APASP. The rest of the paper presents our method and its amortized complexity. 2.1 The NPR Decremental APASP Algorithm [19] The decremental algorithm NPR for APASP builds on the key concept of a locally shortest path (LSP) in a graph, introduced in the DI method [7]. A path p in G is an LSP if the path p′ obtained by removing the first edge from p and the path p′′ obtained by removing the last edge from p are both SPs in G. For APASP, we need to maintain all shortest paths, and G can have an exponential (in n) number of SPs. Thus the DI method is not feasible for APASP since it maintains each SP (and LSP) separately. In order to succinctly maintain all SPs and LSPs in a manner suitable for efficient decremental updates, NPR developed the tuple system described below. 2.1.1 A System of Tuples [19] Since a graph could have an exponential number of shortest paths, NPR introduced the compact tuple system described below (we briefly review it, referring the reader to [19] for more details). Let d(x, y) denote the shortest path length from x to y. 3 A tuple, τ = (xa, by), represents a set of paths in G, all with the same weight, and all of which use If the paths in τ are LSPs, then τ is an LST In addition, if the same first edge (x, a) and the same last edge (b, y). (locally shortest tuple), and the weight of every path in τ is w(x, a) + d(a, b) + w(b, y). d(x, y) = w(x, a) + d(a, b) + w(b, y), then τ is a shortest path tuple (ST). A triple γ = (τ, wt, count), represents the tuple τ = (xa, by) that contains count number of paths from x to y, each with weight wt. We use triples to succinctly store all LSPs and SPs for each vertex pair in G. For x, y ∈ V , we define: P (x, y) = {((xa, by), wt, count): (xa, by) is an LST from x to y in G} P ∗(x, y) = {((xa, by), wt, count): (xa, by) is an ST from x to y in G}. Left Tuple and Right Tuple. A left tuple (or ℓ-tuple), τℓ = (xa, y), represents the set of LSPs from x to y, all of which use the same first edge (x, a). A right tuple (r-tuple) τr = (x, by) is defined analogously. For a shortest path r-tuple τr = (x, by), L(τr) is the set of vertices which can be used as pre-extensions to create LSTs in G, and for a shortest path ℓ-tuple τℓ = (xa, y), R(τℓ) is the set of vertices which can be used as post-extensions to create LSTs in G. Hence: L(x, by) = {x′ : (x′, x) ∈ E(G) and (x′x, by) is an LST in G} R(xa, y) = {y′ : (y, y′) ∈ E(G) and (xa, yy′) is an LST in G}. For x, y ∈ V , L∗(x, y) denotes the set of vertices which can be used as pre-extensions to create shortest path tuples in G; R∗(x, y) is defined symmetrically: L∗(x, y) = {x′ : (x′, x) ∈ E(G) and (x′x, y) is a ℓ-tuple representing SPs in G} R∗(x, y) = {y′ : (y, y′) ∈ E(G) and (x, yy′) is an r-tuple representing SPs in G}. Data Structures. The algorithm in [19] uses priority queues for P , P ∗, and balanced search trees for L∗, L, R∗ and R, as well as for a set Marked-Tuples that is specific only to one update. It also uses priority queues Hc and Hf for the cleanup and fixup procedures, respectively. Some key differences between this representation and the one in DI [7] are described in [19]. Lemma 4. [19] Let G = (V, E) be a directed graph with positive edge weights. The number of LSTs (or triples) that contain a vertex v in G is O(ν∗2), and the total number of LSTs (or triples) in G is bounded by O(m∗ · ν∗). The NPR algorithm maintains all STs and LSTs in the current graph, and for each tuple, it maintains the L, R, L∗ and R∗ sets. To execute a new update to a vertex v, NPR (similar to DI) first calls an algorithm cleanup on v which removes all STs and LSTs that contain v. This is followed by a call to algorithm fixup on v which computes all STs and LSTs in the updated graph that are not already present in the system. The overall algorithm update consists of cleanup followed by fixup. If the updates are all decremental then NPR maintains exactly all the SPs and LSPs in the graph in O(ν∗ 2 · log n) amortized time per update. Several challenges to adapting the techniques in the DI decremental method to the tuple system are addressed in [19]. The analysis of the amortized time bound is also more involved since with multiple shortest paths it is possible for the dynamic APASP algorithm to examine a tuple and merely change its count; in such a case, the DI proof method of charging the cost of the examination to the new path added to or removed from the system does not apply. 2.2 The DI Fully Dynamic APSP Algorithm [7] The DI method first gives a decremental APSP algorithm, and shows that this is also a correct, though inefficient, fully dynamic APSP algorithm. The inefficiency arises because under incremental updates the method may maintain some old SPs and their combinations that are not currently SPs or LSPs; such 4 paths are called historical shortest paths (HPs) and locally historical paths (LHPs). To obtain an efficient fully dynamic algorithm, the DI method introduces 'dummy updates' into the update sequence. A dummy update performs cleanup and fixup on a vertex that was updated in the past. Using a strategically chosen sequence of dummy updates, it is established in [7] that the resulting APSP algorithm runs in amortized time O(n2 · log3 n) per real update. The DI method continues to use the notation P ∗, L∗, etc., even though these are supersets of the defined sets in a fully dynamic setting. We will do the same in our fully dynamic algorithms. 2.3 Our Approach A natural approach to obtain a fully dynamic APASP algorithm would be to convert the NPR decremental APASP algorithm to an efficient fully dynamic APASP algorithm by using dummy updates, similar to DI. There are two steps in this process, and each has challenges (the second step is more challenging). Step 1: Converting NPR decremental algorithm to a correct (but inefficient) fully dynamic APASP algo- rithm. In Section 3 we describe algorithm fully-update, an updated version of the NPR decremental algorithm in [19], which is a correct fully dynamic APASP algorithm that maintains a superset of all STs and LSTs in the current graph. This algorithm, however, is not very efficient since it may add, remove, and examine a large number of tuples (this is similar to the DI decremental algorithm when used as a fully dynamic algorithm without any additional features). Step 2: Obtaining a good dummy sequence for efficient fully dynamic APASP. In Section 4 we present Algorithm fully-dynamic, which calls fully-update not only on the current update, but also on a se- quence of vertices updated at suitable previous time steps. This is similar to the dummy updates used in DI, however we use a different dummy update sequence. We now describe the DI dummy update sequence and its limitations for APASP. Then, we introduce our new method (whose full details are in Section 4). The DI method uses 'dummy updates', where a vertex updated at time t is also given a 'dummy' update at steps t + 2i, for each i > 0 (this update is performed along with the real update at step t + 2i). The effect of a dummy update on a vertex v is to remove any HP or LHP that contains v, thereby streamlining the collection of paths maintained. Further, with unique SPs, each HP in P ∗(x, y) for a given pair x, y will have a different weight. An O(log n) bound on the number of HPs in a P ∗(x, y) is established in DI as follows. Let the current time step be t, and consider an HP τ last updated at t′ < t. Let us denote the smallest i such that t′ + 2i > t as the dummy-index for τ . By observing that different HPs for x, y must have different dummy-indices, it follows that their number is O(log t), which is O(log n) since the data structure is reconstructed after O(n) updates. If we try to apply the DI dummy sequence to APASP, we are faced with the issue that a new ST for x, y (with the same weight) could be created at each update in a long sequence of successive updates. Then, an incremental update could transform all of these STs into HTs. If this happens, then several HTs for x, y, all with the same weight, could have the same dummy-index (in DI only one HP can be present for this entire collection due to unique SPs). Thus, the DI approach of obtaining an O(log n) bound for the number of HPs for each vertex pair does not work for HTs in our tuple system. Our method for Step 2 is to use a different dummy sequence, and a completely different analysis that obtains an O(log n) bound for the number of different 'PDGs' (a PDG is a type of derived graph defined in Section 4) that can contain the HTs. Our new dummy sequence is inspired by the 'level graph' method introduced in Thorup [27] to improve the amortized bound for fully dynamic APSP to O(n2 · log2 n), saving a log factor over DI. The Thorup method is complex because it maintains O(log n) levels of data structures for suitable 'level graphs'. Our algorithm fully-dynamic does not maintain these level graphs. Instead, fully-dynamic performs exactly like the fully dynamic algorithm in DI, except that it uses this alternate dummy update sequence, and it calls fully-update for APASP instead of the DI update algorithm for APSP. Our change in the update sequence requires a completely new proof of the amortized bound which we present in Section 4. We consider this to be a contribution of independent interest: If we replace fully- update by the DI update algorithm in fully-dynamic, we get a new fully dynamic APSP algorithm which 5 is as simple as DI, with a new analysis. 3 Algorithm fully-update We first extend the notions of historical and locally historical paths [7] to tuples and triples. Definition 5 (HT, THT, LHT, and TLHT). Let τ be a tuple in the tuple system at time t. Let t′ ≤ t denote the most recent step at which a vertex on a path in τ was updated. Then τ is a historical tuple (HT) at time t if τ was an ST-tuple at least once in the interval [t′, t]; τ is a true HT (THT) at time t if it is not an ST in the current graph. A tuple τ is a locally historical tuple (LHT) at time t if either it only contains a single vertex or every proper sub-path in it is an HT at time t; a tuple τ is a true LHT (TLHT) at time t if it is not an LST in the current graph. In fully-update, P ∗(x, y) and P (x, y) will contain HTs (including all STs) and LHTs (including all LSTs), respectively, from x to y. Given an update to a vertex in the current graph, the algorithm fully-update (Algorithm 2 in the appendix) performs a call to a 'cleanup' routine, followed by a call to a 'fixup' routine. This is similar to the update procedure in the decremental and fully dynamic algorithms for unique paths in DI [7] and in the decremental algorithm in [19]. It was observed in [7] that the decremental algorithm they presented for the unique SP case is a correct algorithm when incremental updates are interleaved with decremental ones. However here, in contrast to DI, the decremental APASP algorithm in [19] (the NPR algorithm) needs to be refined before it becomes correct for a fully dynamic sequence, and this is due to the presence of multiple shortest paths. Consider, for instance, a THT τ = (xa, by) with weight wt which is currently an LST. With the NPR algorithm [19], since τ is a THT it will be present in P ∗(x, y) (but not as an ST). Suppose a new set of paths represented by a new triple τ ′ = ((xa, by), wt, count′), with the same weight wt, is added to the count of this tuple τ . We cannot simply add count′ to τ in P ∗(x, y) because its extensions were performed using the old count, and if τ is restored as an ST in P ∗(x, y), these extensions will not have the correct count. (With unique SPs this situation can never occur.) Our solution here is to have τ in P (x, y) with the larger correct count (thus including count′), and to leave the corresponding τ in P ∗(x, y) with its original count. Should τ later be restored as an ST then the difference in counts between τ in P ∗(x, y) and the corresponding τ in P (x, y) will trigger left and right extensions of τ with the correct count even though τ is currently in P ∗(x, y). There are additional subtleties. During fully-cleanup starting from the current updated vertex v, we may reach a triple γ = (τ, wt, count) in P through say, a left extension, while the triple in P ∗ for τ with weight wt is γ′ = (τ, wt, count′), with count′ < count (the extreme case being that τ ′ = 0, in which case there is no γ′ in P ∗). This is an indication that the paths in γ − γ′ were formed after γ′ became a THT. We address this situation in fully-cleanup by noting that a THT contains obsolete information that can be completely removed without affecting the correctness of the algorithm. We apply the same approach to TLHTs, since these can also be removed without affecting correctness. Hence, when we encounter a THT or a TLHT during cleanup, we completely remove the triple from the tuple system. The pseudocode for fully-cleanup and fully-fixup are given at the end of this paper (after the references) in Algorithm 3 and Algorithm 4, with the changes from the pseudocode for the decremental algorithm highlighted. Recall that fully-update (Algorithm 2) is simply an execution of fully-cleanup followed by fully-fixup. The correctness of this algorithm is argued by noting that our method ensures that when an ST in P ∗ is processed during fully-fixup without further extensions, it has the correct weight and count and all of its extensions have been performed with that count; every ST and LST is generated starting with singleton edges, min-weight tuples from the P sets, and correct STs from the P ∗ sets, hence the counts of the tuples identified as STs and LSTs are maintained correctly. 3.1 Analysis and Properties of fully-update The pseudocode for algorithm fully-update and its proof are given in Appendix A. In this section we establish some basic properties of algorithm fully-update based on the high-level description we have 6 given above. Let C be the maximum number of tuples in the tuple system containing a path through a given vertex at any time, and let D be the maximum number of tuples that can be in the tuple system at any time. For the complexity analysis, we observe that any triple examined during the cleanup phase contains at least one path going through the updated node v. Thus the number of triples examined during the cleanup phase cannot exceed C in the worst case. The amortized time bound for fully-fixup is obtained similar to NPR [19]. This analysis observes that many existing tuples may simply have their count increased, but any such tuple contains a path through the updated vertex v, and hence their number is bounded by O(C). Thus, during a call to fully-fixup, the number of existing tuples examined is O(n2 + C), and any other tuple examined is newly created during the fully-fixup step or moved from P to P ∗. Further, fully-fixup does not remove any tuple. Hence, the total number of tuples accessed in all fully-fixup steps across a sequence of r updates is bounded by O(r · (n2 + C)) for the existing tuples examined, plus the total number of tuples T added to the tuple system by fully-fixup. This number T is no more than the number of tuples removed by all fully-cleanup steps, O(r ·C), plus D, the number of tuples that can remain in the tuple system at the end of the update sequence. Factoring in the O(log n) cost for accessing each tuple in the data structures, we obtain the following lemma (proof in Appendix B). Lemma 6. Consider a sequence of r calls to fully-update on a graph with n vertices. Let C be the maximum number of tuples in the tuple system that can contain a path through a given vertex, and let D be the maximum number of tuples that can be in the tuple system at any time. Then fully-update executes the r updates in O((r · (n2 + C) + D) · log n) time. In Section 4, we will use the algorithm fully-update within algorithm fully-dynamic, that performs a special sequence of 'dummy' updates, to obtain a fully dynamic APASP algorithm with an O(ν∗2 log3 n) amortized cost per update; we obtain this amortized bound by establishing suitable upper bounds on the parameters C and D in Lemma 6 when algorithm fully-dynamic is used. We conclude this section with some lemmas that will be used in the analysis of the amortized time bound of Algorithm 1. The proof of the following lemma is fairly straightforwared, but since it refers to the pseudocode in Appendix A, it is deferred to Appendix B. Lemma 7. At each step t, the tuple system for Algorithm fully-update maintains a subset of HTs and LHTs that includes all STs and LSTs for step t, and further, for every LHT triple ((xa, by), wt, count) in step t, there are HTs (a∗, by) and (xa, ∗b) with weights wt − w(x, a) and wt − w(b, y) respectively, in that step. Lemma 8. If fully-update is called on vertex v at step t, then at the end of step t: 1. There is no THT in the tuple system that contains a path through v. 2. For any TLHT (xa, by) in the tuple system that contains a path through v, the vertex v must be one of the endpoints x,y. Proof. Part 1 of the lemma follows from Definition 5. For part 2, by Lemma 7, any LHT in the tuple system is formed by combining two HTs that are in the tuple system. Now consider the TLHT (xa, by) that contains v. Since by definition of TLHT, (xa, by) is not an LST in the current graph, assume w.l.o.g. that (xa, b) is the subtuple that is not an ST when an end edge is deleted from (xa, by). But this is not possible since any tuple HT (xa, ∗b) that contains v must be an ST. The lemma follows. Lemma 9. Let G be a graph after a sequence of calls to fully-update, and suppose every HT in the tuple system is an ST in one of z different graphs H1, · · · , Hz, and every LHT is formed from these HTs. If n and m bound the number of vertices and edges, respectively, in any of these graphs, and if ν∗ bounds the maximum number of edges that lie on shortest paths through any given vertex in any of the these graphs, then: 7 1. The number of LHTs in G's tuple system is at most O(z · m · ν∗). 2. The number of LHTs that contain the newly updated vertex v in G is O(z · ν∗2). 3. Let u be any vertex in G, and suppose that the HTs that contain u lie in z′ ≤ z of the graphs H1, · · · , Hz. Then, the number of LHTs that contain the vertex u is O((z + z′2) · ν∗2). Proof. For part 1, we bound the number of LHTs (xa, by) (across all weights) that can exist in G. The edge (x, a) can be chosen in m ways, and once we fix (x, a), the r-tuple (a, by) must be an ST in one of the Hj. Since (b, y) must lie on a shortest path through a in the graph Hi that contains the r-tuple (a, by) of that weight, the number of different choices for (b, y) that will then uniquely determine the tuple (xa, by), together with its weight, is z · ν∗. Hence the number of LHTs in G 's tuple system is O(z · m · ν∗). For part 2, the number of LHTs that contain v as an internal vertex is simply the number of LSTs in the current graph by Lemma 8 (part 2), and using Lemma 4, this is O(ν∗2). We now bound the number of LHTs (va, by). There are n − 1 choices for the edge (v, a) and z · ν∗ choices for the r-tuple (a, by), hence the total number of such tuples is O(z · n · ν∗). The same bound holds for LHTs of the form (xa, bv). Since ν∗ = Ω(n), the result in part 2 follows. For part 3, we observe that each LHT that contains u as an internal vertex must be composed of two HTs, each of which is an ST in one of the z′ graphs that contain v. Thus, there are O(z′2 · ν∗2) such tuples. For an LHT, say τ = (ua, by), that contains u as an end vertex, the analysis remains the same as above in part 2: there are n − 1 choices for the edge (u, a) and z · ν∗ choices for the r-tuple (a, by), hence the total number of such tuples is O(z · n · ν∗). This gives the desired result. 4 The Overall Algorithm fully-dynamic Algorithm fully-update in Section 3 is a correct fully dynamic algorithm for APASP, but it is not a very efficient algorithm, since C and D in Lemma 6 could be very large. We now present our overall fully dynamic algorithm for APASP. As in [7, 27] we build up the tuple system for the initial n-node graph G = (V, E) with n inserts starting with the empty graph (and hence n incremental updates), and we then perform the first n updates in the given update sequence Σ. After these 2n updates, we reset all data structures and start afresh. Consider a graph G = (V, E) with weight function w in which an incremental or decremental update is applied to a vertex u. Let w′ be the weight function after the update, hence the only changes to the edge weights occur on edges incident to u. Algorithm 1 gives the overall fully dynamic algorithm for the t-th update to a vertex v with the new weight function w′. This algorithm applies fully-update to vertex v with the new weight function, thus it will be correct if we executed only the first step, but not necessarily efficient. To obtain an efficient algorithm we execute 'dummy updates' on a sequence N of the most recently updated vertices as specified in Steps 2-5. The length of this sequence of vertices is determined by the position k of the least significant bit set to 1 in the bit representation B = br−1 · · · b0 of t. We denote k by set-bit(t). Algorithm 1 fully-dynamic(G, v, w′, t) 1: fully-update(v, w′) 2: k ← set-bit(t) (i.e., if the bit representation of t is br−1 · · · b0, then bk is the least significant bit with value 1) 3: N ← set of vertices updated at steps t − 1, · · · , t − (2k − 1) 4: for each u ∈ N in decreasing order of update time do 5: fully-update(u, w′) (dummy updates) Properties of N . Consider the current update step t, with its bit representation B = br−1 · · · b0 and with set-bit(t) = k. We say that index i is a time-stamp for t if bi = 1 (so r − 1 ≥ i ≥ k), and for each such 8 time-stamp i, we let timet(i) be the earlier update step t′ whose bit representation has zeros in positions bi − 1, · · · , 0, and which matches B in positions br−1 · · · bi. In other words, timet(i) = t′, where t′ has bit representation br−1 · · · bi+1bi0 · · · 0. We do not define timet(i) if bi = 0. We define P rior-times(t) be the set of timet(i), where i is a time-stamp for t. Note that P rior-times(t) ≤ r = O(log n), since r ≤ log(2n). Let Gt be the graph after the t-th update is applied, t ≥ 1, with the initial graph being G0. Thus, the input graph to Algorithm 1 is Gt−1, and the updated graph is Gt. Lemma 10. For every vertex v in Gt, the step tv of the most recent update to v is in P rior-times(t). Proof. Let the bit representation of t be B = br−1 · · · b0, let set-bit(t) = i, and let j1 > j2 > · · · > js = i be the time-stamps for t. Let tu = timet(bju ), thus the bit representation of tu is the same as B, with all bits in positions less than ju set to zero; let t0 = 1. Then, we observe that during the execution of Algorithm 1 for the tu-th update, the vertex for update tu will be updated in Step 1, and the vertices updated in steps tu−1 + 1, · · · , tu − 1 will be updated in Steps 4-5 of Algorithm 1. Hence all vertices updated in [tu−1 + 1, tu] are more recently updated in step tu. Thus the most recent update step for every vertex in Gt is one of the O(log n) steps in P rior-times(t). 5 Analysis of Algorithm fully-dynamic The analysis in this section incorporates many elements from Thorup's algorithm [27]. However, these are present only in the analysis, and the only component of that rather complicated algorithm that we use is the form of the dummy update sequence in Step 3 of Algorithm 1. Our Algorithm 1 is about as simple as the DI algorithm when specialized to unique shortest paths since in that case it suffices to use the update algorithm in DI instead of the more elaborate fully-update we use here. 5.1 The Prior Deletion Graph (PDG) Let t′ < t be two update steps, and let W be the set of vertices that are updated in the interval of steps [t′ + 1, t]. We define the prior deletion graph (PDG) Γt′,t as the induced subgraph of Gt′ on the vertex set V (Gt′ ) − W . If t is the current update step, then we simply use Γt′ instead of Γt′,t. We say that a path p is present in both Gt′ and Gt if no call to fully-update is made on any vertex in p during the update steps in the interval [t′ + 1, t]. Lemma 11. Let tuple τ represent a collection of paths in Gt′ .Then, 1. If τ is an ST in Gt′ then τ continues to be an ST in every PDG Γt′,t with t ≥ t′ in which τ is present. 2. For any t ≥ t′, if τ is an ST in Gt then τ is an ST in every PDG Γt′,t′′ , t′′ ≥ t, in which τ is present. Proof. As observed in [19] (and in [7] for unique shortest paths), an ST in a graph remains an ST after a weight increase on any edge that is not on it. This establishes the first part. For the second part, we observe that Γt′,t can be viewed as being obtained from Gt by deleting the vertices updated in [t′ + 1, t]. Since τ is an ST in Gt, it continues to be an ST in the graph Γt′,t, which can be obtained from Gt through a sequence of decremental updates that do not change the weight of any edge on τ . Finally since τ is an ST in Γt′,t, it must be an ST in any Γt′,t′′ in which it appears, for t′′ > t. PDGs for Update t: We will associate with the current update step t, the set of PDGs Γt′, for t′ ∈ P rior-times(t). These PDGs are similar to the level graphs maintained in Thorup's algorithm [27], but we choose to give them a different name since we use them here only to analyze the performance of our algorithm. Lemma 12. Consider a sequence of fully dynamic updates performed using Algorithm 1. Let the current update step be t and consider the set of graphs Γt′ , for t′ ∈ P rior-times(t). Then, each HT in the tuple system for Gt is an ST in at least one of the Γt′ ∈ P rior-times(t). Further z = O(log n) in Lemma 9 for Gt. 9 Proof. Consider an HT τ = (xa, by) in Gt. Let the most recently updated vertex in τ be v, and let its update step be tv ≤ t. By definition of HT, τ is an ST in some t′ in [tv, t], and hence by part 2 of Lemma 11, using t = t′ = tv and t′′ = t, τ is an ST in Γtv . By Lemma 10, tv ∈ P rior-times(t). Finally, since P rior-times(t) ≤ log n for any t, z = O(log n) in Lemma 9. We will use the above lemma to obtain our amortized time bound in Lemma 13 in the next section. It is not clear that a similar result can be obtained with the DI dummy update sequence. 5.2 Amortized Cost of Algorithm fully-dynamic We will now bound the amortized cost of an update in a sequence Σ of n real updates on an initial n-node graph G = (V, E). As mentioned earlier, in our method this will translate to a sequence Σ′ of 2n real (as opposed to dummy) updates: there is an initial sequence of n updates, starting with the empty graph, which inserts each of the n vertices in G along with incident edges that have not yet been inserted. Following this is the sequence of n real updates in Σ. Each of these 2n updates in Σ′ will make a call to Algorithm 1. As before, let ν∗ be a bound on the number of edges that lie on shortest paths through any given vertex in any of Gt. The following lemma establishes our main Theorem 1. Lemma 13. Algorithm 1 executes a sequence Σ of n real updates on an n-node graph in O(ν∗ 2 · log3 n) amortized time per update. Proof. Let n′ = 2n, and as described above, let Σ′ be the sequence of n′ calls to Algorithm 1 used to execute the n updates in Σ. We first observe that Algorithm 1 performs O(n′ log n′) dummy updates when executing these n′ calls. This is because there are n′/2k real updates for update steps t with set-bit(t) = k, and each such update is accompanied by 2k − 1 dummy updates. So, across all real updates there are O(n′) dummy updates for each position of set-bit, adding up to O(n′ log n′) in total, across all set-bit positions. We now use Lemma 6 to bound the time needed to execute the d = n′ log n′ dummy updates and n′ real updates. We need to bound the parameters C and D in Lemma 6. We first consider D. For this we will use part 1 of Lemma 9. By Lemma 12, z = O(log n) for any t. Hence by Lemma 9 the maximum number of tuples that can remain at the end of the update sequence is D = O(m · ν∗ · log n). Now we bound the parameter C, for which we will obtain separate bounds, C1 for the real updates, and C2 for the dummy updates. For each real update we have z = z′ = O(log n) in part 3 of Lemma 9, hence the number of tuples that contain a path through the updated vertex is O(ν∗ 2 · log2 n), thus C1 = O(ν∗2 · log2 n). Now consider a dummy update on a vertex u in Step 5 of Algorithm 1, and let u be in some level i (note the i must be less than the current level k). At the time this call is made, all vertices that were updated after u was last updated in the graph (i.e., after time(i)) are now in the newest level k. Thus, any LHT that contains u lies in either Γtime(i) or in Gt = Γt. Hence z′ = 2 in part 3 of Lemma 9 for any vertex u undergoing a dummy update. Thus C2 = O(ν∗2 · log n). Hence the total time taken by Algorithm 1 for its d = n′ log n′ dummy updates and the n′ real updates is, by Lemma 6, O( (n′ · (n2 + C1) + (n′ log n′) · (n2 + C2) + D) · log n) = O(n′ · ν∗2 · log2 n + (n′ · log n′) · ν∗2 · log n + D log n) = O(n · ν∗2 · log3 n) (the n2 and D terms are dropped since ν∗ = Ω(n), hence m = O(n · ν∗)). It follows that the amortized cost of each of the n updates in Σ is O( 1 n ·n′ ·ν∗2·log3 n) = O(ν∗2 ·log3 n). 6 Conclusion We have presented an efficient fully dynamic algorithm for APASP. Our algorithm stores a superset of the STs and LSTs in the current graph in two priority queues P ∗(x, y) and P (x, y) for each vertex pair x, y. To generate all shortest paths from all other vertices to x, we construct the shortest path in-dag rooted at x in O(ν∗) time. Then, the shortest paths ending in x can be enumerated in a traversal of this dag, starting from x. This query time is output-optimal, and takes time proportional to the number of edges on these paths. Our algorithm, when specialized to fully dynamic APSP (i.e., for unique SPs), is a variant of the DI [7] method, and it uses a different 'dummy update sequence' from the one in [7], with different properties. Our 10 dummy update sequence is inspired by the updates performed on 'level graphs' in [27], though our algorithm is considerably simpler (but is also slower by a logarithmic factor). As noted in Section 5.1, our analysis is tailored to the dummy update sequence we use, and a different analysis would be needed if the DI update sequence is to be used. Recently we have developed a fully dynamic algorithm for APASP [21] that runs in amortized O(ν∗ 2 · log2 n) time, which is a log factor faster than the result presented here. This algorithm is considerably more involved and adapts the method in Thorup [27] to the APASP problem by maintaining the PDGs explicitly. An additional complexity in this fully dynamic APASP algorithm (beyond that present in [27]) is the need to maintain several different time-stamps for each tuple in the data structures, since the component paths in a tuple may have been updated at different time steps. It would be interesting to investigate if one could stay with our method here of only performing dummy updates and not maintaining the PDGs explicitly, but still obtain the improved bound in our companion paper [21] (and in Thorup [27] for unique shortest paths). This would give a reasonably simple fully dynamic APASP algorithm that is a logarithmic factor faster than the algorithm in this paper, and it would lead to a simpler fully dynamic APSP algorithm with O(n2 · log2 n) amortized time than Thorup's algorithm [27]. One appealing approach is to only form LSTs in the current graph during fully-fixup (instead of forming all LHTs in the for loop starting on line 24 of fully-fixup). It is not difficult to see that this would reduce the cost of fully-cleanup by a logarithmic factor. However, if an HT τ becomes an ST at a later step, we would then have no guarantee that all of its extensions have been generated. Hence, if this approach is to succeed, a modified algorithm is needed. Acknowledgement: The authors would like to thank the reviewers for their comments, which helped to improve the presentation of the write-up. References [1] Hans-Jrgen Bandelt and Henry Martyn Mulder. Interval-regular graphs of diameter two. Discrete Mathematics, 50(0):117 -- 134, 1984. [2] Elisabetta Bergamini and Henning Meyerhenke. Fully-dynamic approximation of betweenness centrality. arXiv:1504.07091 [cs.DS], 2015. [3] Elisabetta Bergamini, Henning Meyerhenke, and Christian L. Staudt. Approximating betweenness centrality in large evolving networks. In Proc. of ALENEX 2015, chapter 11, pages 133 -- 146. SIAM, 2015. [4] U. Brandes. A faster algorithm for betweenness centrality. Journal of Mathematical Sociology, 25(2):163 -- 177, 2001. [5] Thayne Coffman, Seth Greenblatt, and Sherry Marcus. Graph-based technologies for intelligence anal- ysis. Commun. ACM, 47(3):45 -- 47, 2004. [6] Anne Condon and Richard M. Karp. Algorithms for graph partitioning on the planted partition model. Random Struct. Algorithms, 18(2):116 -- 140, March 2001. [7] Camil Demetrescu and Giuseppe F. Italiano. A new approach to dynamic all pairs shortest paths. J. ACM, 51(6):968 -- 992, 2004. [8] Camil Demetrescu and Giuseppe F. Italiano. Experimental analysis of dynamic all pairs shortest path algorithms. ACM Trans. Algorithms (TALG), 2(64):578 -- 601, 2006. [9] Robert Geisberger, Peter Sanders, and Dominik Schultes. Better approximation of betweenness cen- trality. In Proc. of ALENEX 2008, chapter 8, pages 90 -- 100. SIAM, 2008. 11 [10] Oded Green, Robert McColl, and David A. Bader. A fast algorithm for streaming betweenness centrality. In Proc. of 4th PASSAT, pages 11 -- 20, 2012. [11] David R. Karger, Daphne Koller, and Steven J. Phillips. Finding the hidden path: Time bounds for all-pairs shortest paths. SIAM J. Comput., 22(6):1199 -- 1217, 1993. [12] Miray Kas, Matthew Wachs, Kathleen M. Carley, and L. Richard Carley. Incremental algorithm for updating betweenness centrality in dynamically growing networks. In Proc. of ASONAM, 2013. [13] Nicolas Kourtellis, Tharaka Alahakoon, Ramanuja Simha, Adriana Iamnitchi, and Rahul Tripathi. Identifying high betweenness centrality nodes in large social networks. SNAM, pages 1 -- 16, 2012. [14] Nicolas Kourtellis, Gianmarco De Francisci Morales, and Francesco Bonchi. Scalable online betweenness centrality in evolving graphs. IEEE Trans. Knowl. Data Eng., 27(9):2494 -- 2506, 2015. [15] Valdis Krebs. Mapping networks of terrorist cells. CONNECTIONS, 24(3):43 -- 52, 2002. [16] Min-Joong Lee, Jungmin Lee, Jaimie Yejean Park, Ryan Hyun Choi, and Chin-Wan Chung. Qube: a quick algorithm for updating betweenness centrality. In Proc. 21st WWW Conference, pages 351 -- 360, 2012. [17] Henry Martyn Mulder. Interval-regular graphs. Discrete Mathematics, 41(3):253 -- 269, 1982. [18] Meghana Nasre, Matteo Pontecorvi, and Vijaya Ramachandran. Betweenness centrality incremental and faster. In MFCS 2014, volume 8635 of LNCS, pages 577 -- 588. Springer, 2014. [19] Meghana Nasre, Matteo Pontecorvi, and Vijaya Ramachandran. Decremental all-pairs all shortest paths and betweenness centrality. In ISAAC 2014, volume 8889 of LNCS, pages 766 -- 778. Springer, 2014. [20] John W. Pinney, Gleen A. McConkey, and David R. Westhead. Decomposition of biological networks using betweenness centrality. In Proc. of 9th RECOMB, 2005. [21] Matteo Pontecorvi and Vijaya Ramachandran. A faster algorithm for fully dynamic betweenness cen- trality. http://arxiv.org/abs/1506.05783, 2015. [22] J. Sicilia R. M. Ramos and M. T. Ramos. A generalization of geodetic graphs: K-geodetic graphs. Inverstigacin Operativa, 1:85 -- 101, 1998. [23] Matteo Riondato and Evgenios M. Kornaropoulos. Fast approximation of betweenness centrality through sampling. In Proc. of the 7th ACM WSDM, pages 413 -- 422. ACM, 2014. [24] Satu Elisa Schaeffer. Survey: Graph clustering. Comput. Sci. Rev., 1(1):27 -- 64, August 2007. [25] Rishi Ranjan Singh, Keshav Goel, Sudarshan Iyengar, and Sukrit. A faster algorithm to update be- tweenness centrality after node alteration. In Proc. of 10th WAW, 2013. [26] N. Srinivasan, J. Opatrny, and V.S. Alagar. Bigeodetic graphs. Graphs and Combinatorics, 4(1):379 -- 392, 1988. [27] Mikkel Thorup. Fully-dynamic all-pairs shortest paths: Faster and allowing negative cycles. In SWAT, pages 384 -- 396, 2004. 12 A Pseudocode for Algorithm fully-update fully-update is given in the two-line Algorithm 2. It calls Algorithm 3 (fully-cleanup) and Algorithm 4 (fully-fixup), in sequence, on the updated vertex v. We present pseudocode for these two procedures here. They are similar to the corresponding pseudocode cleanup and fixup in [19], and we have marked the steps changed from [19] with a • at the end of the line. Also, a triple γ is now inserted in P with a key [wt, β], instead of just wt. Here β is a control bit that is set during the fixup phase and indicates if γ is present in P ∗ with the correct count (β = 1), or if γ has the correct count only in P (β = 0). In the latter case γ could be also present in P ∗ but with a wrong count. The only changes from [19] in Algorithm 3 are in steps 11, 18, 23 and 26 where we remove any THT or TLHT we encounter during cleanup while extending from the updated node v. More specifically, a triple (x′x, by) with weight wt′ is an LST iff wt′ − w(b, y) = d(x′, b) (as checked in step 11, Algorithm 3), and in this case we proceed as in the decremental-only algorithm; otherwise the triple is a TLHT and we remove it completely from the tuple system (Steps 18 -- 20, Algorithm 3). The same method applies to HTs (steps 23, 26, Algorithm 3). Steps 11 and 23 are performed using the shortest distances between any two nodes before the cleanup phase starts. The other steps in Algorithm 3 are described in [19]. Algorithm 4 introduces new features to achieve correctness and efficiency. We observe that we may revert an HT from, say, x to y, back to an ST during an update, and this happens only if the shortest path distance from x to y increases. This condition translates into the new check in Step 9 of Algorithm 4. Here we proceed as in [19] keeping in mind that an LHT extracted from P as an ST (Step 10, Algorithm 4) may or may not be in P ∗. If the LHT is not in P ∗ (Step 13, Algorithm 4) we add the triple to the tuple system as in [19]. If the LHT is already in P ∗ with a different count (Step 16, Algorithm 4), we replace the count of the triple in P ∗ with count′ from the triple in P and we add the triple to S (Step 17, Algorithm 4). Note that the extension sets L∗ and R∗ do not need to be updated in this case. In step 10, Algorithm 4 we check the bit β associated with the triple γ. Since P is a priority queue, we will process only the triples in P with min-key [wt, 0], so we avoid examining the triples that are already in P ∗ with a correct count. We set β to 1 for any triple added to or updated in P ∗ with the correct count (Steps 18 and 23, Algorithm 4). Also, for an LHT updated in P and not P ∗, we set β = 0 (Step 34, Algorithm 4). The other steps in Algorithm 4 are described in [19], as are the two parameters paths(γ, v), which gives the number of paths containing the node v that are represented by the triple γ, and update-num(γ), which is a timestamp that indicates the last update in which the triple γ is involved. A.1 Correctness In this section, we establish the correctness of Algorithm 3 and 4. We assume that all the local structures are correct before the update, and we will show the correctness of them after the update. fully-cleanup works with a heap Hc of triples. The algorithm maintains the loop invariant that any triple inserted into Hc has already been deleted from the tuple system: only its extensions remain to be processed and deleted. We prove the following lemma: Lemma 14. After Algorithm 3 (fully-cleanup) is executed, for any (x, y) ∈ V , the STs in P ∗(x, y) (LSTs in P (x, y)) represent all the SPs (LSPs) from x to y in G that do not pass through v. Moreover, every THT (TLHT) present in the tuple system represents a collection of HPs (LHPs) in G that contains only paths that do not pass through v. Finally, the sets L, L∗, R, R∗ are correctly maintained. Proof. To prove the lemma statement, we use a loop invariant on the while loop in Step 3 of Algorithm 3. We show that the while loop maintains the following invariants. Loop Invariant: At the start of each iteration of the while loop in Step 3 of Algorithm 3, assume that the first triple to be extracted from Hc and processed has min-key = [wt, x, y]. Then the following properties hold about the tuple system and Hc. 1. For any a, b ∈ V , if G contains cab LHPs of weight wt of the form (xa, by) passing through v, then Hc contains a triple γ = ((xa, by), wt, cab) with key [wt, x, y] already processed: the cab LHPs through v are cleaned from the system. 13 extract in S all the triples with min-key [wt, x, y] from Hc for every b such that (x×, by) ∈ S do let f count′ = Pi cti such that ((xai, by), wt, cti) ∈ S for every x′ ∈ L(x, by) such that (x′x, by) /∈ Marked-Tuples do wt′ ← wt + w(x′, x); γ ′ ← ((x′x, by), wt′, f count′); add γ ′ to Hc {The next step will check if γ ′ is an LST or a TLHT} if wt′ − w(b, y) = d(x′, b) • then remove γ ′ in P (x′, y) // decrements its count in P by f count′ {we decrement an LST} if a triple for (x′x, by) exists in P (x′, y) then insert (x′x, by) in Marked-Tuples delete x′ from L(x, by) and delete y from R(x′x, b) remove the tuple (x′x, by) with weight wt′ from P (x′, y) • {we completely remove a TLHT} if a triple for (x′x, by) does not exist in P (x′, y) then delete x′ from L(x, by) and delete y from R(x′x, b) if a triple γ ′′ for (x′x, by) exists in P ∗(x′, y) with weight wt′ and count paths then {The next step will check if γ ′ is an ST or a THT} if wt′ = d(x′, y) • then remove γ ′ in P ∗(x′, y) // decrements count by f count′ {we decrement an ST} remove γ ′′ from P ∗(x′, y) • {we completely remove a THT} if P ∗(x, y) = ∅ then delete x′ from L∗(x, y) if P ∗(x′, b) = ∅ then delete y from R∗(x′, b) perform symmetric steps 5 -- 28 for right extensions Algorithm 2 fully-update(v, w′) 1: fully-cleanup(v) 2: fully-fixup(v, w′) 2. Algorithm 3 fully-cleanup(v) 1: Hc ← ∅; Marked-Tuples ← ∅ 2: γ ← ((vv, vv), 0, 1); add γ to Hc 3: while Hc 6= ∅ do 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: else else else add a min-key triple from P (x, y) to Hf Algorithm 4 fully-fixup(v, w′) 1: Hf ← ∅; Marked-Tuples ← ∅ 2: for each edge incident on v do 3: 4: for each x, y ∈ V do 5: 6: while Hf 6= ∅ do 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: else else set β for γ ′ ∈ P (x′, y) to 1 • create a triple γ; set paths(γ, v) = 1; set update-num(γ); add γ to Hf and to P () extract in S ′ all triples with min-key [wt, x, y] from Hf ; S ← ∅ if S ′ is the first extracted set from Hf for x, y then if P ∗(x, y) increased min-weight after cleanup • then for each γ ′ ∈ P (x, y) with min-key [wt, 0] • do let γ ′ = ((xa′, b′y), wt, count′) {Next step check if γ ′ is completely missing from P ∗} if γ ′ is not in P ∗(x, y) then add γ ′ in P ∗(x, y) and S; add x to L∗(a′, y) and y to R∗(x, b′) {Next step check if γ ′ is in P ∗ with a different count} else if γ ′ is in P (x, y) and P ∗(x, y) with different counts • then replace the count of γ ′ in P ∗(x, y) with count′ and add γ ′ to S • for each γ ′ ∈ S ′ containing a path through v do let γ ′ = ((xa′, b′y), wt, count′) add γ ′ with paths(γ ′, v) in P ∗(x, y) and S; add x to L∗(a′, y) and y to R∗(x, b′) set β for γ ′ ∈ P (x′, y) to 1 • for every b such that (x×, by) ∈ S do let f count′ = Pi cti such that ((xai, by), wt, cti) ∈ S for every x′ in L∗(x, b) do if (x′x, by) /∈ Marked-Tuples then wt′ ← wt + w(x′, x); γ ′ ← ((x′x, by), wt′, f count′) set update-num(γ ′); paths(γ ′, v) ← Pγ=(x×,by) paths(γ, v); add γ ′ to Hf if a triple for ((x′x, by), wt′) exists in P (x′, y) then add γ ′ with paths(γ ′, v) in P (x′, y); add (x′x, by) to Marked-Tuples add γ ′ to P (x′, y); add x′ to L(x, by) and y to R(x′x, b) set β for γ ′ ∈ P (x′, y) to 0 • perform symmetric steps 24 -- 34 for right extensions 14 Let [ wt, x, y] be the last key extracted from Hc and processed before [wt, x, y]. For any key [wt1, x1, y1] ≤ [ wt, x, y], let G contain c > 0 number of LHPs of weight wt1 of the form (x1×, b1y1). Further, let cv (resp. c¯v) denote the number of such LHPs that pass through v (resp. do not pass through v). Here cv + c¯v = c. For every extension x′ ∈ L(x1, b1y1), let let wt′ = wt1 + w(x′, x1) be the weight of the extended triple (x′x1, b1y1). Then, (the following assertions are similar for y′ ∈ R(x1a1, y1)) (a) if c > cv there is a triple in P (x′, y1) of the form (x′x1, b1y1) and weight wt′ representing c − cv LHPs. If c = cv there is no such triple in P (x′, y1). (b) If a triple of the form (x′x1, b1y1) and weight wt′ is present as an HT in P ∗(x′, y1), then it represents the exact same number of LHPs c − cv of the corresponding triple in P (x′, y1). This is exactly the number of HPs of the form (x′x1, b1y1) and weight wt′ in G − {v}. (c) x′ ∈ L(x1, b1y1), y1 ∈ R(x′x1, b1) and (x′x1, b1y1) ∈ Marked-Tuples iff c¯v > 0. If the triple (x′x1, b1y1) is an HT, a similar statement holds for x′ ∈ L∗(x1, y1) iff P ∗(x1, y1) 6= ∅, and y1 ∈ R∗(x′, b1) iff P ∗(x′, b1) 6= ∅. (d) A triple corresponding to (x′x1, b1y1) with weight wt′ and counts cv is in Hc. A similar assertion holds for y′ ∈ R(x1a1, y1). (e) The tuple system does not contain any TLHT in P (x′, y1) and THT in P ∗(x′, y1) of the form (x′x1, b1y1) and weight wt′. 3. For any key [wt2, x2, y2] ≥ [wt, x, y], let G contain c > 0 LHPs of weight wt2 of the form (x2a2, b2y2). Further, let cv (resp. c¯v) denote the number of such LHPs that pass through v (resp. do not pass through v). Here cv + c¯v = c. Then the tuple (x2a2, b2y2) ∈ Marked-Tuples, iff c¯v > 0 and a triple for (x2a2, b2y2) is present in Hc Initialization: We start by showing that the invariants hold before the first loop iteration. The min-key triple in Hc has key [0, v, v]. Invariant assertion 1 holds since we inserted into Hc the trivial triple of weight 0 corresponding to the vertex v and that is the only triple of such key. Moreover, since we do not represent trivial paths containing the single vertex, no counts need to be decremented. Since we assume positive edge weights, there are no LHPs in G of weight less than zero. Thus all the points of invariant assertion 2 hold trivially. Invariant assertion 3 holds since Hc does not contain any triple of weight > 0 and we initialized Marked-Tuples to empty. Maintenance: Assume that the invariants are true before an iteration k of the loop. We prove that the invariant assertions remains true before the next iteration k + 1. Let the min-key triple at the beginning of the k-th iteration be [wtk, xk, yk]. By invariant assertion 1, we know that for any ai, bj, if there exists a triple γ of the form (xkai, bjyk) of weight wtk representing count paths going through v, then it is present in Hc. Now consider the set of triples with key [wtk, xk, yk] which we extract in the set S (Step 4, Algorithm 3). We consider left-extensions of triples in S; symmetric arguments apply for right-extensions. Consider for a particular b, the set Sb ⊆ S of triples of the form (xk×, byk) and let f count′ denote the sum of the counts of the paths represented by triples in Sb. Let x′ ∈ L(xk, byk) be a left extension; our goal is to generate the triple (x′xk, byk) with count f count′ and weight wt′ = wtk +w(x′, xk). However, we generate such triple only if it has not been generated by a right-extension of another set of paths. We observe that the paths of the form (x′xk, byk) can be generated by right extending to yk the set of triples of the form (x′xk, ×b). Without loss of generality assume that the triples of the form (x′xk, ×b) have a key which is greater than the key [wtk, xk, yk]. Thus, at the beginning of the k-th iteration, by invariant assertion 3, we know that (x′xk, byk) /∈ Marked-Tuples. Steps 9 -- 12, Algorithm 3 create a triple of the form (x′xk, byk) of weight wt′. The generated triple can be an LST or a TLHT in P . In the first case the condition at step 11, Algorithm 3 holds and we remove γ′ by decrementing f count′ many paths from the appropriate triple in P (x′, yk). Moreover, if the condition does not hold, we just encountered a TLHT: in this case we completely remove this TLHT from P in step 18, Algorithm 3. Moreover, if the generated triple is also contained in P ∗(x′, yk), we check if it is an ST or a THT using step 23, Algorithm 3. In the case of an ST we normally decrement f count′ paths from the appropriate triple in P ∗(x′, yk), otherwise we completely remove the THT from P ∗(x′, yk) in 15 step 26, Algorithm 3. This establishes invariant assertions 2a, 2b and 2e. In addition, if there are no LSPs in G of the form (x′xk, byk) which do not pass through v, we delete x′ from L(xk, byk) and delete yk from R(x′xk, b) (Step 16, Algorithm 3). On the other hand, if there exist LSPs in G of the form (x′xk, byk), then x′ (resp. yk) continues to exist in L(xk, byk) (resp. in R(x′xk, b)). Further, we add the tuple (x′xk, byk) to Marked-Tuples and observe that the corresponding triple is already present in Hc (Step 14, Algorithm 3). Similarly, if the generated triple (x′xk, byk) is an ST, then we check if P ∗(xk, yk) = ∅ and P ∗(x′, b) = ∅ in order to delete x′ from L∗(xk, yk) and yk from R∗(x′, b). By the loop invariant, invariant assertions 2c and 2d were true for every key < [wtk, xk, yk] and by the above steps we ensure that these invariant assertions hold for every key = [wtk, xk, yk]. Thus, invariant assertions 2c and 2d are true at the beginning of the (k + 1)-th iteration. Note that any triple that is generated by a left extension (or symmetrically right extension) is inserted into Hc as well as into Marked-Tuples. This establishes invariant assertion 3 at the beginning of the (k + 1)-th iteration. Finally, to see that invariant assertion 1 holds at the beginning of the (k + 1)-th iteration, let the min-key at the (k + 1)-th iteration be [wtk+1, xk+1, yk+1]. Observe that triples with weight wtk+1 starting with xk+1 and ending in yk+1 can be created either by left extending or right extending the triples of smaller weight. And since for each of iteration ≤ k, invariant assertion 2 holds for any extension, we conclude that invariant assertion 1 holds at the beginning of the (k + 1)-th iteration. This finishes our maintenance step. Termination: The condition to exit the loop is Hc = ∅. Because invariant assertion 1 maintains in Hc all the triples already processed, then Hc = ∅ implies that there are no other triples to extend in the graph G that contain the updated node v. Moreover, because of invariant assertion 1, every triple containing the node v inserted into Hc = ∅, has been correctly decremented from the tuple system. Also, since invariant assertion 2e holds, every THT and TLHT containing the node v has been completely deleted from the tuple system. Finally, for invariant assertion 2c, the sets L, L∗, R, R∗ are correctly maintained. This completes the proof. For fully-fixup , we first show that Algorithm 4 computes the correct distances for all the SPs in the updated graph G′ (Lemma 16). Moreover, we process all the new SPs in G′ (Lemma 18). Finally, we show that data structures and counts are correctly maintained after the algorithm (Lemma 20). Here we use the notion of a fresh LHT for a triple that represents at least one path that is in P but not in P ∗. We will consider fresh triples in Lemma 18 and Observation 19. Invariant 15. During the execution of Algorithm 4, for any pair (x, y), consider the first extraction from Hf of a set of triples from x to y, and let their weight be wt. Then wt is the shortest path distance from x to y in the updated graph G′. Lemma 16. Algorithm 4 maintains Invariant 15. Proof. Suppose for a contradiction that the invariant is violated at some extraction. Consider the earliest event in which the first set of triples S′ of weight wt, extracted for some pair (x, y), does not contain STs in G′. Let γ = ((xa, by), wt, count) be a triple in G′ that represents at least one shortest path from x to y in G′, with wt < wt. The triple cannot be in P (x, y) at the beginning of fixup otherwise it (or another triple with same weight wt) would have been inserted in Hf during step 5 of Algorithm 4. Moreover, γ cannot be in Hf otherwise it would have been extracted before any triple of weight wt in S′; hence γ must be a new LST generated by the algorithm. Since all the edges incident to v are added to Hf during step 3 of Algorithm 4, then γ must represent SPs of at least two edges. We define lef t(γ) as the set of LSTs of the form ((xa, cib), wt − w(b, y), countci) that represent all the LSPs in the left tuple ((xa, b), wt − w(b, y)); similarly we define right(γ) as the set of LSTs of the form ((adj , by), wt − w(x, a), countdj ) that represent all the LSPs in the right tuple ((a, by), wt − w(x, a)). Observe that since γ is an ST, all the LSTs in lef t(γ) and right(γ) are also STs. A triple in lef t(γ) and a triple in right(γ) cannot be present in P ∗ together at the beginning of fixup. In fact, if at least one triple from both sets is present in P ∗ at the beginning of fixup, then the last one inserted during the fixup triggered by the previous update, would have generated an LST of the form ((xa, by), wt) automatically inserted and 16 thus present in P at the beginning of fixup (a contradiction). Thus either there is no triple in lef t(γ) in P ∗, or there is no triple in right(γ) in P ∗. Assume w.l.o.g. that no triple in right(γ) is in P ∗. Since edge weights are positive, wt − w(x, a) < wt < wt, and because all the extractions before γ were correct, then the triples in right(γ) were correctly extracted from Hf and placed in P ∗ before the wrong extractions in S′. If at least one triple in lef t(γ) is in P ∗ then the fixup would generate the tuple ((xa, by), wt) and place it in P and Hf (Steps 24 -- 34, Algorithm 4). Otherwise, since wt − w(b, y) < wt < wt, the triples in lef t(γ) were discovered by the algorithm before the wrong extractions in S′. Moreover the algorithm would generate the tuple ((xa, by), wt) (as right extensions) and place it in P and Hf (because at least one triple in right(γ) is already in P ∗). Thus, in both cases, a tuple ((xa, by), wt) should have been extracted from Hf before any triple in S′. A contradiction. Invariant 17. The set S of triples constructed in Steps 9 -- 23 of Algorithm 4 represents all the new shortest paths from x to y. Lemma 18. Algorithm 4 maintains Invariant 17. Proof. Any new SP from x to y is of the following three types: 1. a single edge containing the vertex v (such a path is added to P (x, y) and Hf in Step 3) 2. a path generated via left/right extension of some shortest path previously extracted from Hf during the execution of Algorithm 4 (this generated path is added to P (x, y) and Hf in Step 29 and an analogous step in right-extend). 3. a path that was an LSP but not an SP before the update and is an SP after the update. In type (1) and (2) above any new SP from x to y which is added to Hf is also added to P ∗(x, y). However, amongst the several triples representing paths of the type (3) listed above, only one candidate triple will be present in Hf . Thus we conclude that, for a given x, y, when we extract from Hf a type (3) triple of weight wt, P (x, y) could contain a superset of triples with the same weight wt that are not present in Hf . We now consider the two cases the algorithm deals with. • P ∗(x, y) increased its min-weight, when the first set of triples for x, y is extracted from Hf . This is the only case where we could restore historical triples, or process fresh triples from scratch because they are not yet in P ∗ or they are present in P ∗ with a lower count than the corresponding triple in P (note that this condition is triggered only by decremental updates). To do that we process all the min-weight triples in P (x, y), but before we really add a triple in S for further extensions, we check if it is present in P ∗ with a lower count (Step 16, Algorithm 4), or it is not present in P ∗ (Step 13, Algorithm 4). By the above argument, we consider all the new STs from x to y present in P (x, y). Therefore it suffices to argue that all of them contains new shortest paths to be processed. Suppose for contradiction that some triple γ does not contains new shortest paths. Thus, γ was a ST before the update and already in P ∗ with at least one path not going through v. However, since cleanup only removes paths that contain v, the triple γ remained in P ∗(x, y) after the fully-cleanup phase. This contradicts the fact that P ∗(x, y) increased its min-weight. • P ∗(x, y) didn't change its min-weight when the first set of triples for x, y is extracted from Hf . Let the weight of triples in P ∗(x, y) be wt. This implies that the shortest path distance from x to y before and after the update is wt. Both in the case of incremental and decremental updates, all the new paths that we need to consider from x to y are going through the updated node v. By construction of the Algorithm 4, every triple containing the updated node v is always placed into Hf . Thus it suffices to consider only triples in Hf . Observation 19. During the execution of Algorithm 4, consider a THT τ that becomes shortest. If τ 's corresponding triple in P is not fresh, then it is simply restored (not processed); otherwise τ 's count is replaced with the updated count from P and it is extended anew. 17 Proof. When we restore an existing HT τ from P ∗, we always check if its corresponding triple in P contains more paths (Step 16, Algorithm 4) or the counts match. In the first case τ in P ∗ is carrying an obsolete num- ber of SPs and is therefore replaced with the correct count in P and extended anew (Step 17, Algorithm 4). Otherwise it is still representing the correct number of SPs to be restored and it is not processed. Lemma 20. After the execution of Algorithm 4 (fully-fixup), for any (x, y) ∈ V , the STs in P ∗(x, y) (LSTs in P (x, y)) represent all the SPs (LSPs) from x to y in the updated graph. Also, the sets L, L∗, R, R∗ are correctly maintained. Proof. We prove the lemma statement by showing the following loop invariant. Loop Invariant: At the start of each iteration of the while loop in Step 6 of Algorithm 4, assume that the first triple in Hf to be extracted and processed has min-key = [wt, x, y]. Then the following properties hold about the tuple system and Hf . 1. For any a, b ∈ V , if G′ contains cab SPs of form (xa, by) and weight wt, then Hf contains a triple of form (xa, by) and weight wt to be extracted and processed. Further, a triple γ = ((xa, by), wt, cab) is present in P (x, y). 2. Let [ wt, x, y] be the last key extracted from Hf and processed before [wt, x, y]. For any key [wt1, x1, y1] ≤ [ wt, x, y], let G′ contain c > 0 number of LHPs of weight wt1 of the form (x1a1, b1y1). Further, let cnew (resp. cold) denote the number of these LHPs that are new (resp. not new). Here cnew + cold = c. If cnew > 0 then, (a) there is an LHT in P (x1, y1) of the form (x1a1, b1y1) and weight wt1 that represents c LHPs. (b) If a triple of the form (x1a1, b1y1) and weight wt1 is present as an HT in P ∗, then it represents the exact same count of c HPs of its corresponding triple in P . This is exactly the number of HPs of the form (x1a1, b1y1) and weight wt1 in G′. (c) x1 ∈ L(a1, b1y1), y1 ∈ R(x1a1, b1), and if the triple of the form (x1a1, b1y1) and weight wt1 is also shortest then x1 ∈ L∗(a1, y1), y1 ∈ R∗(x1, b1). Further, (x1a1, b1y1) ∈ Marked-Tuples iff cold > 0. (d) If cnew > 0, for every x′ ∈ L(x1, b1y1), an LHT corresponding to (x′x1, b1y1) with weight wt′ = wt1 + w(x′, x1) ≥ wt and counts equal to the sum of new paths represented by its constituents, is in Hf and P . A similar assertion holds for y′ ∈ R(x1a1, y1). 3. For any key [wt2, x2, y2] ≥ [wt, x, y], let G′ contain c > 0 number of LHPs of weight wt2 of the form (x2a2, b2y2). Further, let cnew (resp. cold) denote the number of such LHPs that are new (resp. not new). Here cnew + cold = c. Then the tuple (x2a2, b2y2) ∈ Marked-Tuples, iff cold > 0 and cnew paths have been added to Hf by some earlier iteration of the while loop. Initialization and Maintenance for the 3 invariant assertions are similar to the proof of Lemma 14. Termination: The condition to exit the loop is Hf = ∅. Because invariant assertion 1 maintains in Hf the first triple to be extracted and processed, then Hf = ∅ implies that there are no triples, formed by a valid left or right extensions, that contain new SPs or LSPs, that need to be added or restored in the graph G. Moreover, because of invariant assertions 2a and 2b, every triple containing the node v, extracted and processed before Hf = ∅, has been added or restored with its correct count in the tuple system. Finally, for invariant assertion 2c, the sets L, L∗, R, R∗ are correctly maintained. This completes the proof of the loop invariant. By Lemma 18, all the new SPs in G′ are placed in Hf and processed by the algorithm and hence are in P ∗ after the execution of Algorithm 4. Moreover, for a pair (x, y), the check in Step 9 of Algorithm 4 would fail if the distance from x to y doesn't change after the update. Thus the old SPs from x to y will remain in P ∗(x, y). Hence, after Algorithm 4 is executed, every SP in G′ is in its corresponding P ∗. Since every LST of the form (xa, by) in G′ is formed by a left extension of a set of STs of the form (a∗, by) (Steps 24 -- 34, Algorithm 4), or a right extension of a set of the form (xa, ∗b) (analogous steps for right extensions), and all the STs are correctly maintained by the algorithm, then all the LSTs are correctly maintained at the end of the fixup algorithm. This completes the proof of the Lemma. 18 B Proofs of Lemmas 6 and 7 Lemma 6. Consider a sequence of r calls to fully-update on a graph with n vertices. Let C be the maximum number of tuples in the tuple system that can contain a path through a given vertex, and let D be the maximum number of tuples that can be in the tuple system at any time. Then fully-update executes the r updates in O((r · (n2 + C) + D) · log n) time. Proof. We bound the cost of fully-update by classifying each triple γ as one of the following disjoint types: • Type-0 (contains-v): γ represents at least one path containing vertex v. • Type-1 (new-LHT): γ was not an LHT before the update but is an LHT after the update, and no path in γ contains v. • Type-2 (new-HT-old-LHT): γ is an HT after the update, and γ was an LHT but not an HT before the update, and no path in γ contains v. • Type-3 (renew-ST): γ was a THT before the update and it is restored as a ST after the update, and no path in γ contains v. • Type-4 (new-LHT-old-LHT): γ was an LHT before the update and continues to be an LHT after the update, and no path in γ contains v. The number of Type-0 triples, processed in Steps 20 -- 23, Algorithm 4, is at most C. The number of Type-1 triples, processed in Steps 24 -- 34, Algorithm 4, is addressed by amortizing over the entire update sequence as described in the paragraph below. For Type-2 triples, processed in Steps 9 -- 18, Algorithm 4, we observe that after such a triple becomes an HT, it is not removed from P ∗ unless a real or dummy update is triggered on a vertex that lies in it. But in such an update this would be counted as a Type-0 triple. Further, each such Type-2 triple is examined only a constant number of times (in Steps 9 -- 18, Algorithm 4), because after they are inserted into P ∗ the bit β associated changes to 1 and they will not be processed again by fixup, unless the number of paths they represent is changed. Hence we charge each access to a Type-2 triple to the step in which it was created as a Type-1 triple. For Type-3 triples, also processed in Steps 9 -- 18, Algorithm 4, we distinguish two cases: if γ didn't change its count in P after it became a THT then its flag is β = 1 and it is present in P ∗ with the correct count. Thus the fixup algorithm will not process it. If γ changed its count in P while it was a THT then its flag is β = 0 and we can charge the processing of γ (if extracted from Hf ) to the sub-triple γ′ generated from the updated node that increased the count of γ; in other words there was an ST γ′, created in a previous update, whose extensions added to the count of γ. Observe that, triples in P ∗ that are not placed initially in Hf and have β = 1 in P (no additional path was added to that triple) are not examined in any step of fixup, so no additional Type-3 triples are examined. For Type-4, we note that for any x, y we add exactly one candidate min-key triple from P (x, y) to Hf (in Step 5, Algorithm 4), hence initially there are at most n2 such triples in Hf , any of which could be Type-4. Moreover, we never process an old LHT which is not a new HT so no additional Type-4 triples are examined during fixup. Thus the number of triples examined by a call to fixup is C plus X, where X is the number of new triples fixup adds to the tuple system. (This includes an O(1) credit placed on each new LHT for a possible later conversion to an HT.) Let r be the number of updates in the update sequence. Since triples are removed only in cleanup, at most O(r ·C) triples are removed by the cleanups. There can be at most D triples remaining at the end of the sequence, hence the total number of new triples added by all fixups in the update sequence is O(r · C + D). Since the time taken to access a triple is O(log n) due to the data structure operations, and we examine at least n2 triples at each round, the total time spent by fixup over r updates is O((r · (n2 + C) + D) · log n). Lemma 7. At each step t, the tuple system for Algorithm fully-update maintains a subset of HTs and LHTs that includes all STs and LSTs for step t, and further, for every LHT triple ((xa, by), wt, count) in step t, there are HTs (a∗, by) and (xa, ∗b) with weights wt − w(x, a) and wt − w(b, y) respectively, in that step. 19 Proof. For the first part see Appendix A.1 (Lemmas 14 and 20). For the second part, if a triple γ = ((xa, by), wt, count) is present in step t, then γ was generated during fully-fixup of some step t′ ≤ t. By the construction of our algorithm, at the end of step t′, the tuple system contains at least one HT of the form (a∗, by) and one of the form (xa, ∗b) with weights wt − w(x, a) and wt − w(b, y) respectively. W.l.o.g. suppose that the set S of all the HTs of the form (a∗, by) and weight wt − w(x, a) are removed during fully- cleanup at some step t′′ ≤ t, then since these HTs are the right constituents of γ, when S is left extended to x in fully-cleanup then exactly count paths will be removed from γ making the triple disappear from the tuple system. Thus at step t, at least one HT of the form (a∗, by) with weight wt − w(x, a) must be in P ∗. Similarly, there must be an HT of the form (xa, ∗b) with weight wt − w(b, y) in P ∗ at step t. 20
1703.03603
1
1703
2017-03-10T09:58:40
The Densest Subgraph Problem with a Convex/Concave Size Function
[ "cs.DS", "cs.DM", "cs.SI" ]
In the densest subgraph problem, given an edge-weighted undirected graph $G=(V,E,w)$, we are asked to find $S\subseteq V$ that maximizes the density, i.e., $w(S)/|S|$, where $w(S)$ is the sum of weights of the edges in the subgraph induced by $S$. This problem has often been employed in a wide variety of graph mining applications. However, the problem has a drawback; it may happen that the obtained subset is too large or too small in comparison with the size desired in the application at hand. In this study, we address the size issue of the densest subgraph problem by generalizing the density of $S\subseteq V$. Specifically, we introduce the $f$-density of $S\subseteq V$, which is defined as $w(S)/f(|S|)$, where $f:\mathbb{Z}_{\geq 0}\rightarrow \mathbb{R}_{\geq 0}$ is a monotonically non-decreasing function. In the $f$-densest subgraph problem ($f$-DS), we aim to find $S\subseteq V$ that maximizes the $f$-density $w(S)/f(|S|)$. Although $f$-DS does not explicitly specify the size of the output subset of vertices, we can handle the above size issue using a convex/concave size function $f$ appropriately. For $f$-DS with convex function $f$, we propose a nearly-linear-time algorithm with a provable approximation guarantee. On the other hand, for $f$-DS with concave function $f$, we propose an LP-based exact algorithm, a flow-based $O(|V|^3)$-time exact algorithm for unweighted graphs, and a nearly-linear-time approximation algorithm.
cs.DS
cs
The Densest Subgraph Problem with a Convex/Concave Size Function∗ Yasushi Kawase and Atsushi Miyauchi Tokyo Institute of Technology, Tokyo, Japan {kawase.y.ab, miyauchi.a.aa}@m.titech.ac.jp Abstract In the densest subgraph problem, given an edge-weighted undirected graph G = (V, E, w), we are asked to find S ⊆ V that maximizes the density, i.e., w(S)/S, where w(S) is the sum of weights of the edges in the subgraph induced by S. This problem has often been employed in a wide variety of graph mining applications. However, the problem has a drawback; it may happen that the obtained subset is too large or too small in comparison with the size desired in the application at hand. In this study, we address the size issue of the densest subgraph problem by generalizing the density of S ⊆ V . Specifically, we introduce the f-density of S ⊆ V , which is defined as w(S)/f (S), where f : Z≥0 → R≥0 is a monotonically non-decreasing function. In the f-densest subgraph problem (f-DS), we aim to find S ⊆ V that maximizes the f-density w(S)/f (S). Although f-DS does not explicitly specify the size of the output subset of vertices, we can handle the above size issue using a convex/concave size function f appropriately. For f-DS with convex function f, we propose a nearly-linear-time algorithm with a provable approximation guarantee. On the other hand, for f-DS with concave function f, we propose an LP-based exact algorithm, a flow-based O(V 3)-time exact algorithm for unweighted graphs, and a nearly-linear-time approximation algorithm. 1 Introduction Finding dense components in a graph is an active research topic in graph mining. Techniques for identifying dense subgraphs have been used in various applications. For example, in Web graph analysis, they are used for detecting communities (i.e., sets of web pages dealing with the same or similar topics) [9] and spam link farms [13]. As another example, in bioinformatics, they are used for finding molecular complexes in protein -- protein interaction networks [4] and identifying regulatory motifs in DNA [11]. Furthermore, they are also used for expert team formation [6, 20] and real-time story identification in micro-blogging streams [2]. To date, various optimization problems have been considered to find dense components in a graph. The densest subgraph problem is one of the most well-studied optimization problems. Let ∗A preliminary version of this paper appeared in the Proceedings of the 27th International Symposium on Algorithms and Computation (ISAAC 2016) [15]. 1 e∈E(S) w(e). G = (V, E, w) be an edge-weighted undirected graph consisting of n = V vertices, m = E edges, and a weight function w : E → Q>0, where Q>0 is the set of positive rational numbers. w(S) = (cid:80) For a subset of vertices S ⊆ V , let G[S] be the subgraph induced by S, i.e., G[S] = (S, E(S)), where E(S) = {{i, j} ∈ E i, j ∈ S}. The density of S ⊆ V is defined as w(S)/S, where In the (weighted) densest subgraph problem, given an (edge-weighted) undirected graph G = (V, E, w), we are asked to find S ⊆ V that maximizes the density w(S)/S. The densest subgraph problem has received significant attention recently because it can be solved exactly in polynomial time and approximately in nearly linear time. In fact, there exist a flow-based exact algorithm [14] and a linear-programming-based (LP-based) exact algorithm [7]. Charikar [7] demonstrated that the greedy algorithm designed by Asahiro et al. [3], which is called the greedy peeling, obtains a 2-approximate solution1 for any instance. This algorithm runs in O(m + n log n) time for weighted graphs and O(m + n) time for unweighted graphs. However, the densest subgraph problem has a drawback; it may happen that the obtained subset is too large or too small in comparison with the size desired in the application at hand. To overcome this issue, some variants of the problem have often been employed. The densest k-subgraph problem (DkS) is a straightforward size-restricted variant of the densest subgraph problem [10]. In this problem, given an additional input k being a positive integer, we are asked to find S ⊆ V of size k that maximizes the density w(S)/S. Note that in this problem, the objective function can be replaced by w(S) since S is fixed to k. Unfortunately, it is known that this size restriction makes the problem much harder to solve. In fact, Khot [16] proved that DkS has no PTAS under some reasonable computational complexity assumption. The current best approximation algorithm has an approximation ratio of O(n1/4+) for any  > 0 [5]. Furthermore, Andersen and Chellapilla [1] introduced two relaxed versions of DkS. The first problem, the densest at-least-k-subgraph problem (DalkS), asks for S ⊆ V that maximizes the density w(S)/S under the size constraint S ≥ k. For this problem, Andersen and Chellapilla [1] adopted the greedy peeling, and demonstrated that the algorithm yields a 3-approximate solution for any instance. Later, Khuller and Saha [17] investigated the problem more deeply. They proved that DalkS is NP-hard, and designed a flow-based algorithm and an LP-based algorithm. These algorithms have an approximation ratio of 2, which improves the above approximation ratio of 3. The second problem is called the densest at-most-k-subgraph problem (DamkS), which asks for S ⊆ V that maximizes the density w(S)/S under the size constraint S ≤ k. The NP-hardness is immediate since finding a maximum clique can be reduced to it. Khuller and Saha [17] proved that approximating DamkS is as hard as approximating DkS, within a constant factor. 1.1 Our Contribution In this study, we address the size issue of the densest subgraph problem by generalizing the density of S ⊆ V . Specifically, we introduce the f-density of S ⊆ V , which is defined as w(S)/f (S), where 1A feasible solution is said to be γ-approximate if its objective value times γ is greater than or equal to the optimal value. An algorithm is called a γ-approximation algorithm if it runs in polynomial time and returns a γ-approximate solution for any instance. For a γ-approximation algorithm, γ is referred to as an approximation ratio of the algorithm. 2 ≥0 → R ≥0 is a monotonically non-decreasing function with f (0) = 0.2 Note that Z f : Z ≥0 and R ≥0 are the sets of nonnegative integers and nonnegative real numbers, respectively. In the f-densest subgraph problem (f-DS), we aim to find S ⊆ V that maximizes the f-density w(S)/f (S). For simplicity, we assume that E (cid:54)= ∅. Hence, any optimal solution S∗ ⊆ V satisfies S∗ ≥ 2. Although f-DS does not explicitly specify the size of the output subset of vertices, we can handle the above size issue using a convex size function f or a concave size function f appropriately. In fact, we can show that any optimal solution to f-DS with convex (resp. concave) function f has a size smaller (resp. larger) than or equal to that of any densest subgraph (i.e., any optimal solution to the densest subgraph problem). For details, see Sections 2 and 3. Here we mention the relationship between our problem and DkS. Any optimal solution S∗ ⊆ V to f-DS is a maximum weight subset of size S∗, i.e., S∗ ∈ argmax{w(S) S ⊆ V, S = S∗}, which implies that S∗ is also optimal to DkS with k = S∗. Furthermore, the iterative use of a γ-approximation algorithm for DkS leads to a γ-approximation algorithm for f-DS. Using the above O(n1/4+)-approximation algorithm for DkS [5], we can obtain an O(n1/4+)-approximation algorithm for f-DS. In what follows, we summarize our results for both the cases where f is convex and where f is concave. ≥0 → R The case where f is convex. We first describe our results for the case where f is convex. A function f : Z ≥0 is said to be convex if f (x) − 2f (x + 1) + f (x + 2) ≥ 0 holds for any x ∈ Z ≥0. We first prove the NP-hardness of f-DS with a certain convex function f by constructing a reduction from DamkS. Thus, for f-DS with convex function f, one of the best possible ways is to design an algorithm with a provable approximation guarantee. (cid:110) f (2)/2 (cid:111) 2f (n)/n f (S∗)−f (S∗−1) f (2)/2 f (S∗)/S∗2 , To this end, we propose a min -approximation algorithm, where S∗ ⊆ V is an optimal solution to f-DS with convex function f. Our algorithm consists of the following two procedures, and outputs the better solution found by them. The first one is based on the brute-force search, which obtains an f (S∗)/S∗2 -approximate solution in O(m + n) time. The second one adopts the greedy peeling, which obtains a f (S∗)−f (S∗−1)-approximate solution in O(m + n log n) time. Thus, the total running time of our algorithm is O(m + n log n). Our analysis on the approximation ratio of the second procedure extends the analysis by Charikar [7] for the densest subgraph problem. 2f (n)/n At the end of our analysis, we observe the behavior of the approximation ratio of our algorithm for three concrete size functions. We consider size functions between linear and quadratic because, as we will see later, f-DS with any super-quadratic size function is a trivial problem; in fact, it only produces constant-size optimal solutions. The first example is f (x) = xα (α ∈ [1, 2]). We show that the approximation ratio of our algorithm is 2 · n(α−1)(2−α), where the worst-case performance of 2 · n1/4 is attained at α = 1.5. The second example is f (x) = λx + (1 − λ)x2 (λ ∈ [0, 1)). For this case, the approximation ratio of our algorithm is (2 − λ)/(1 − λ), which is a constant for a fixed λ. 2To handle various types of functions (e.g., f (x) = xα for α > 0), we set the codomain of the function f to be the set of nonnegative real numbers. We assume that we can compare p · f (i) and q · f (j) in constant time for any p, q ∈ Q and i, j ∈ Z ≥0. 3 Figure 1: An example graph and the corresponding points in P = {(S, w(S)) S ⊆ V }. The diamond-shaped points, i.e., (0, 0), (4, 6), (7, 10), and (8, 11), are dense frontier points. The third example is f (x) = x2/(λx + (1− λ)) (λ ∈ [0, 1]). Note that this size function is derived by density function λ w(S) S2 . The approximation ratio of our algorithm is 4/(1 + λ), which S is at most 4. + (1 − λ) w(S) ≥0 → R The case where f is concave. We next describe our results for the case where f is concave. A function f : Z ≥0 is said to be concave if f (x) − 2f (x + 1) + f (x + 2) ≤ 0 holds for any x ∈ Z ≥0. Unlike the above convex case, f-DS in this case can be solved exactly in polynomial time. In fact, we present an LP-based exact algorithm, which extends Charikar's exact algorithm for the densest subgraph problem [7] and Khuller and Saha's 2-approximation algorithm for DalkS [17]. It should be emphasized that our LP-based algorithm obtains not only an optimal solution to f-DS but also some attractive subsets of vertices. Let us see an example in Figure 1. The graph consists of 8 vertices and 11 unweighted edges (i.e., w(e) = 1 for every e ∈ E). For this graph, we plotted all the points contained in P = {(S, w(S)) S ⊆ V }. We refer to the extreme points of the upper convex hull of P as the dense frontier points. The (smallest) densest subgraph is a typical subset of vertices corresponding to a dense frontier point. Our LP-based algorithm obtains a corresponding subset of vertices for every dense frontier point. It should be noted that the algorithm SSM designed by Nagano, Kawahara, and Aihara [18] can also be used to obtain a corresponding subset of vertices for every dense frontier point. The difference between their algorithm and ours is that their algorithm is based on the computation of a minimum norm base, whereas ours solves linear programming problems. Moreover, in this concave case, we design a combinatorial exact algorithm for unweighted graphs. Our algorithm is based on the standard technique for fractional programming. By using the tech- nique, we can reduce f-DS to a sequence of submodular function minimizations. However, the direct application of a submodular function minimization algorithm leads to a computationally expensive algorithm that runs in O(n5(m + n) · log n) time. To reduce the computation time, we replace a submodular function minimization algorithm with a much faster flow-based algorithm that substan- tially extends a technique of Goldberg's flow-based algorithm for the densest subgraph problem [14]. 4 Sw(S)0123456780246810 (cid:16) n3 (cid:16) log n (cid:17)(cid:17)  -time (1 + )-approximation algorithm for weighted graphs. The total running time of our algorithm is O(n3). Modifying this algorithm, we also present an O log n · log Although our flow-based algorithm is much faster than the reduction-based algorithm, the run- ning time is still long for large-sized graphs. To design an algorithm with much higher scalability, we adopt the greedy peeling. As mentioned above, this algorithm runs in O(m + n log n) time for weighted graphs and O(m + n) time for unweighted graphs. We prove that the algorithm yields a 3-approximate solution for any instance. 1.2 Related Work (i.e., relatively small dense subgraphs), and they derived the function OQCα(S) = E(S) − α(cid:0)S2 Tsourakakis et al. [20] introduced a general optimization problem to find dense subgraphs, which is referred to as the optimal (g, h, α)-edge-surplus problem. In this problem, given an unweighted undirected graph G = (V, E), we are asked to find S ⊆ V that maximizes edge-surplusα(S) = g(E(S)) − αh(S), where g and h are strictly monotonically increasing functions, and α > 0 is a constant. The intuition behind this optimization problem is the same as that of f-DS. In fact, the first term g(E(S)) prefers S ⊆ V that has a large number of edges, whereas the second term −αh(S) penalizes S ⊆ V with a large size. Tsourakakis et al. [20] were motivated by finding near-cliques which is called the OQC function, by setting g(x) = x and h(x) = x(x − 1)/2. For OQC function maximization, they adopted the greedy peeling and a simple local search heuristic. Recently, Yanagisawa and Hara [21] introduced density function E(S)/Sα for α ∈ (1, 2], which they called the discounted average degree. For discounted average degree maximization, they designed an integer-programming-based exact algorithm, which is applicable only to graphs with a maximum of a few thousand edges. They also designed a local search heuristic, which is applicable to web-scale graphs but has no provable approximation guarantee. As mentioned above, our algorithm for f-DS with convex function f runs in O(m + n log n) time, and has an approximation ratio of 2 · n(α−1)(2−α) for f (x) = xα (α ∈ [1, 2]). (cid:1), 2 Convex Case In this section, we investigate f-DS with convex function f. A function f : Z ≥0 is said to be convex if f (x) − 2f (x + 1) + f (x + 2) ≥ 0 holds for any x ∈ Z ≥0. We remark that f (x)/x is monotonically non-decreasing for x since we assume that f (0) = 0. It should be emphasized that any optimal solution to f-DS with convex function f has a size smaller than or equal to that of any densest subgraph. To see this, let S∗ ⊆ V be any optimal solution to f-DS and S∗DS ⊆ V be any densest subgraph. Then we have ≥0 → R f (S∗) S∗ = w(S∗)/S∗ w(S∗)/f (S∗) ≤ w(S∗DS)/S∗DS w(S∗DS)/f (S∗DS) = f (S∗DS) S∗DS . (1) This implies that S∗ ≤ S∗DS holds because f (x)/x is monotonically non-decreasing. 5 2.1 Hardness We first prove that f-DS with convex function f contains DamkS as a special case. Theorem 1. For any integer k ∈ [2, n], S ⊆ V is optimal to DamkS if and only if S is optimal to f-DS with (convex) function f (x) = max , where e is an arbitrary edge. x, w(V ) (cid:110) (cid:111) w(e)/2 (x − k) + k Proof. Since the maximum of linear functions is convex, the function f is convex. We remark that x f (x) = if x ≤ k, w(e)/2 (x − k) + k otherwise. w(V ) For any S ⊆ V with S ≤ k, we have w(S)/f (S) = w(S)/S. On the other hand, for any S ⊆ V with S > k, we have w(S) f (S) = w(S) w(V ) w(e)/2 (S − k) + k < w(S) w(V ) w(e)/2 w(e) 2 , ≤ which implies that S is not optimal to f-DS. Thus, we have the theorem. 2.2 Our Algorithm f (2)/2 In this subsection, we provide an algorithm for f-DS with convex function f. Our algorithm consists of the following two procedures, and outputs the better solution found by them. Let S∗ ⊆ V be an optimal solution to the problem. The first one is based on the brute-force search, which obtains an f (S∗)/S∗2 -approximate solution in O(m + n) time. The second one adopts the greedy peeling [3], which obtains a f (S∗)−f (S∗−1)-approximate solution in O(m + n log n) time. Combining these results, both of which will be proved later, we have the following theorem. Theorem 2. Let S∗ ⊆ V be an optimal solution to f-DS with convex function f. For the problem, our algorithm runs in O(m + n log n) time, and has an approximation ratio of 2f (n)/n (cid:26) f (2)/2 f (S∗)/S∗2 , (cid:27) . 2f (n)/n f (S∗) − f (S∗ − 1) min 2.2.1 Brute-Force Search f (2)/2 As will be shown below, to obtain an f (S∗)/S∗2 -approximate solution, it suffices to find the heaviest edge (i.e., argmax{w(e) e ∈ E}), which can be done in O(m + n) time. Here we present a more general algorithm, which is useful for some case. Our algorithm examines all the subsets of vertices of size at most k, and then returns an optimal subset among them, where k is a constant that satisfies k ≥ 2. For reference, we describe the procedure in Algorithm 1. This algorithm can be implemented to run in O((m + n)nk) time because the number of subsets with at most k vertices (cid:1) = O(nk) and the value of w(S)/f (S) for each S ⊆ V can be computed in O(m + n) is(cid:80)k (cid:0)n i=0 i time. 6 Algorithm 1: Brute-force search 1 for i ← 2, . . . , k do 3 return S ∈ {S∗2 , . . . , S∗k} that maximizes w(S)/f (S); 2 Find S∗i ∈ argmax{w(S) S ⊆ V, S = i} by examining all the candidate subsets; 2 2 (cid:1) as the edge density of i vertices. The following lemma gives a fundamental property of the edge density. Lemma 1. The edge density is monotonically non-increasing for the number of vertices, i.e., We analyze the approximation ratio of the algorithm. Let S∗i ⊆ V denote a maximum weight subset of size i ≥ 2, i.e., S∗i ∈ argmax{w(S) S ⊆ V, S = i}. We refer to w(S∗i )/(cid:0)i (cid:1) w(S∗i )/(cid:0)i Proof. It suffices to show that w(S∗i )/(cid:0)i dS(v) =(cid:80) ≥ w(S∗j )/(cid:0)j (cid:80) For S ⊆ V and v ∈ S, let dS(v) denote the weighted degree of v in the induced subgraph G[S], i.e., (v) v ∈ S∗i+1}. Then we obtain u∈V : {u,v}∈E(S) w({u, v}). Take a vertex u ∈ argmin{dS∗i+1 (u) ≤ 1 (cid:1) (cid:1) ≥ (cid:0)i (cid:0)i i+1 ) · w(S∗i+1) (cid:1) holds for any 2 ≤ i ≤ j ≤ n. ≥ w(S∗i+1)/(cid:0)i+1 (cid:1) holds for any positive integer i ∈ [2, n−1]. i+1 · w(S∗i+1). Hence, we have w(S∗i+1) − dS∗i+1 (1 − 2 v∈S∗i+1 w(S∗i+1 \ {u}) (cid:0)i (cid:1) (cid:1) , (cid:0)i+1 w(S∗i+1) (v) = 2 w(S∗i ) dS∗i+1 dS∗i+1 (u) (cid:1) 2 ≥ i+1 = 2 2 = 2 2 (cid:0)i (cid:1) 2 2 2 as desired. Using the above lemma, we can provide the approximation ratio. Lemma 2. Let S∗ ⊆ V be an optimal solution to f-DS with convex function f. If S∗ ≤ k, then Algorithm 1 obtains an optimal solution. If S∗ ≥ k, then it holds that Proof. If S∗ ≤ k, then Algorithm 1 obtains an optimal solution because S∗ ∈ {S∗2 , . . . , S∗k}. S∗ ≥ k, then we have w(S∗) f (S∗) ≤ w(S∗k) f (k) 2 If w(S∗k) f (k) . w(S∗) 2 · f (k)/k2 f (S∗)/S∗2 · f (S∗) ≤ (cid:1) f (k)/(cid:0)k w(S∗k)/(cid:0)k (cid:1) f (S∗)/(cid:0)S∗2 w(S∗)/(cid:0)S∗2 (cid:1) = f (S∗)/S∗2 · w(S∗k) f (k) ≤ f (k)/k2 2 (cid:1) · 2 · f (k)/k2 f (S∗)/S∗2 · w(S∗) f (S∗) · 1 − 1/S∗ 1 − 1/k · = w(S∗k) f (k) , where the first inequality follows from Lemma 1, and the last inequality follows from k ≥ 2. From this lemma, we see that Algorithm 1 with k = 2 has an approximation ratio of f (2)/2 f (S∗)/S∗2 . 7 Algorithm 2: Greedy peeling 1 Sn ← V ; 2 for i ← n, . . . , 2 do Find vi ∈ argminv∈Si dSi(v) and Si−1 ← Si \ {vi}; 4 return S ∈ {S1, . . . , Sn} that maximizes w(S)/f (S); 3 v in the induced subgraph G[S], i.e., dS(v) =(cid:80) 2.2.2 Greedy Peeling Here we adopt the greedy peeling. For S ⊆ V and v ∈ S, let dS(v) denote the weighted degree of u∈V : {u,v}∈E(S) w({u, v}). Our algorithm iteratively removes the vertex with the smallest weighted degree in the currently remaining graph, and then returns S ⊆ V with maximum w(S)/f (S) over the iterations. For reference, we describe the procedure in Algorithm 2. This algorithm can be implemented to run in O(m + n log n) time for weighted graphs and O(m + n) time for unweighted graphs. The following lemma provides the approximation ratio. Lemma 3. Let S∗ ⊆ V be an optimal solution to f-DS with convex function f. Algorithm 2 returns S ⊆ V that satisfies w(S∗) f (S∗) ≤ 2f (n)/n f (S∗) − f (S∗ − 1) · w(S) f (S) . Proof. Choose an arbitrary vertex v ∈ S∗. By the optimality of S∗, we have w(S∗) f (S∗) ≥ w(S∗ \ {v}) f (S∗ − 1) . By using the fact that w(S∗ \ {v}) = w(S∗) − dS∗(v), the above inequality can be transformed to (2) dS∗(v) ≥ (f (S∗) − f (S∗ − 1)) · w(S∗) f (S∗) . Let l be the smallest index that satisfies Sl ⊇ S∗, where Sl is the subset of vertices of size l appeared in Algorithm 2. Note that vl (∈ argminv∈Sl dSl(v)) is contained in S∗. Then we have (cid:80) w(Sl) f (l) = ≥ dSl(u) u∈Sl 2f (l) ≥ f (S∗) − f (S∗ − 1) 2f (l)/l dS∗(vl) 2f (l)/l l · dSl(vl) 2f (l) ≥ w(S∗) f (S∗) ≥ · f (S∗) − f (S∗ − 1) 2f (n)/n · w(S∗) f (S∗) , where the first inequality follows from the greedy choice of vl, the second inequality follows from Sl ⊇ S∗, the third inequality follows from inequality (2), and the last inequality follows from the monotonicity of f (x)/x. Since Algorithm 2 considers Sl as a candidate subset of the output, we have the lemma. 8 2.3 Examples Here we observe the behavior of the approximation ratio of our algorithm for three concrete convex size functions. We consider size functions between linear and quadratic because f-DS with any super- quadratic size function is a trivial problem; in fact, it only produces constant-size optimal solutions. This follows from the inequality f (S∗)/S∗2 ≥ 1 (i.e., f (2)/2 ≥ f (S∗)/S∗2) by Lemma 2. f (2)/2 (i) f (x) = xα (α ∈ [1, 2]). The following corollary provides an approximation ratio of our algorithm. Corollary 1. For f-DS with f (x) = xα (α ∈ [1, 2]), our algorithm has an approximation ratio of 2 · n(α−1)(2−α). Proof. Let s = S∗. By Theorem 2, the approximation ratio is (cid:27) = min ≤ min 2α−1 · s2−α, 2 · s2−α, 2nα−1 sα−1 2nα−1 (cid:27) sα − (s − 1)α ≤ 2 · n(α−1)(2−α). (cid:26) f (2)/2 f (s)/s2 , min (cid:27) (cid:26) (cid:26) 2f (n)/n f (s) − f (s − 1) The first inequality follows from the fact that sα−(s−1)α = sα−(s−1)α−1(s−1) ≥ sα−sα−1(s−1) = sα−1. The last inequality follows from the fact that the first term and the second term of the minimum function are, respectively, monotonically non-decreasing and non-increasing for s, and they have the same value at s = nα−1. Note that an upper bound on 2 · n(α−1)(2−α) is 2 · n1/4, which is attained at α = 1.5. (ii) f (x) = λx + (1 − λ)x2 (λ ∈ [0, 1)). The following corollary provides an approximation ratio of Algorithm 1, which is a constant for a fixed λ. Corollary 2. For f-DS with f (x) = λx + (1 − λ)x2 (λ ∈ [0, 1)), Algorithm 1 with k = 2 has an approximation ratio of (2 − λ)/(1 − λ). Furthermore, for any  > 0, Algorithm 1 with k ≥ 2  · λ 1−λ has an approximation ratio of 2 + . Proof. Let s = S∗. By Lemma 2, the approximation ratio is 2 · f (k)/k2 f (s)/s2 = 2 · λ/k + (1 − λ) λ/s + (1 − λ) ≤ 2 · λ/k + (1 − λ) 1 − λ = 2 + 2λ (1 − λ)k .  · λ 1−λ, the approximation ratio is at most 2 + . Thus, by choosing k = 2, the approximation ratio is at most (2 − λ)/(1 − λ). For any  > 0, by choosing k ≥ 2 (iii) f (x) = x2/(λx + (1 − λ)) (λ ∈ [0, 1]). This size function is derived by density function S2 . The following corollary provides an approximation ratio of our algorithm, which λ w(S) S is at most 4. +(1−λ) w(S) 9 Corollary 3. For f-DS with f (x) = x2/(λx + (1 − λ)) (λ ∈ [0, 1)), our algorithm has an approxi- mation ratio of 4/(1 + λ). Proof. Let s = S∗. By Theorem 2, the approximation ratio is (cid:26) f (2)/2 f (s)/s2 , min (cid:27) 2f (n)/n f (s) − f (s − 1)  2n λn+(1−λ) (s−1)2 λ(s−1)+(1−λ) 1 + λ  2(λs + (1 − λ)) (cid:40) (cid:18) (cid:18) 2(λs + (1 − λ)) (1 + λ)n 1 + λ λ · λn + (1 − λ) 1 + λ , , = min ≤ min 2 ≤ ≤ 1 + λ 2 1 + λ (cid:41) (cid:19) s2 s 2n λs+(1−λ) − λn+(1−λ) λs+(1−λ) + (1 − λ) 4 (cid:19) λ · λ + (1 − λ) = , 1 + λ where the second inequality follows from the fact that the first term and the second term of the minimum function are, respectively, monotonically non-decreasing and non-increasing for s, and λn+(1−λ). they have the same value at s = (1+λ)n 3 Concave Case In this section, we investigate f-DS with concave function f. A function f : Z ≥0 is said to be concave if f (x) − 2f (x + 1) + f (x + 2) ≤ 0 holds for any x ∈ Z ≥0. We remark that f (x)/x is monotonically non-increasing for x since we assume that f (0) = 0. It should be emphasized that any optimal solution to f-DS with concave function f has a size larger than or equal to that of any densest subgraph. This follows from inequality (1) and the monotonicity of f (x)/x. ≥0 → R 3.1 Dense Frontier Points Here we define the dense frontier points and prove some basic properties. We denote by P the set {(S, w(S)) S ⊆ V }. A point in P is called a dense frontier point if it is a unique maximizer of y − λx over (x, y) ∈ P for some λ > 0. In other words, the extreme points of the upper convex hull of P are dense frontier points. The (smallest) densest subgraph is a typical subset of vertices corresponding to a dense frontier point. We prove that (i) for any dense frontier point, there exists some concave function f such that any optimal solution to f-DS with the function f corresponds to the dense frontier point, and conversely, (ii) for any strictly concave function f (i.e., f that satisfies f (x) − 2f (x + 1) + f (x + 2) < 0 for any x ∈ Z ≥0), any optimal solution to f-DS with the function f corresponds to a dense frontier point. We first prove (i). Note that each dense frontier point can be written as (i, w(S∗i )) for some i ∈ {0, 1, . . . , n}, where S∗i ⊆ V is a maximum weight subset of size i. Let (k, w(S∗k)) be a dense frontier point and assume that it is a unique maximizer of y − λx over (x, y) ∈ P for λ > 0. Consider the concave function f such that f (x) = λ(x − k) + w(S∗k) for x > 0 and f (0) = 0 (see 10 Figure 2: A relationship between a dense frontier point and concave funcitons. Figure 2). The concavity of f follows from w(S∗k) − λk ≥ w(S∗0 ) − λ · 0 = 0 = f (0). Then, any optimal solution S∗ ⊆ V to f-DS with the function f corresponds to the dense frontier point (i.e., (S∗, w(S∗)) = (k, w(S∗k)) holds) because w(S)/f (S) is greater than or equal to 1 if and only if w(S) − λS ≥ w(S∗k) − λk holds. We next prove (ii). Let f be any strictly concave function. Let S∗k ⊆ V be any optimal solution to f-DS with the function f, and take λ that satisfies (f (k) − f (k − 1)) · w(S∗k ) f (k) > λ > (f (k + 1) − f (k)) · w(S∗k ) f (k) (see Figure 2). Note that the strict concavity of f guarantees the existence of such λ. Since f is strictly concave, we have λ(S − k) + w(S∗k) ≥ w(S∗k) f (k) · f (S) ≥ w(S) f (S) · f (S) = w(S) for any S ⊆ V , and the inequalities hold as equalities only when (S, w(S)) = (k, w(S∗k)). Thus, (k, w(S∗k)) is a unique maximizer of y − λx over (x, y) ∈ P, and hence is a dense frontier point. 3.2 LP-Based Algorithm We provide an LP-based polynomial-time exact algorithm. We introduce a variable xe for each e ∈ E and a variable yv for each v ∈ V . For k = 1, . . . , n, we construct the following linear programming 11 xyOk−1kk+1w(S∗k)f(k)·f(k−1)w(S∗k)w(S∗k)f(k)·f(k+1)y=w(S∗k)f(k)·f(x)y=λ(x−k)+w(S∗k)w(S∗k)−λk Algorithm 3: LP-based algorithm 1 for k ← 1, . . . , n do 2 3 Solve LPk and obtain an optimal solution (xk, yk); Compute r∗k that maximizes w(Sk(r))/f (Sk(r)); 4 return S ∈ {S1(r∗1), . . . , Sn(r∗n)} that maximizes w(S)/f (S); problem: LPk : maximize (cid:88) subject to (cid:88) e∈E w(e) · xe yv = k, v∈V xe ≤ yu, xe ≤ yv xe, yv ∈ [0, 1] for all e = {u, v} ∈ E, for all e ∈ E, v ∈ V. For an optimal solution (xk, yk) to LPk and a real parameter r, we define a sequence of subsets v ≥ r}. For k = 1, . . . , n, our algorithm first solves LPk to obtain an optimal Sk(r) = {v ∈ V yk solution (xk, yk), and then computes r∗k that maximizes w(Sk(r))/f (Sk(r)). Note here that to find such r∗k, it suffices to check all the distinct sets Sk(r) by simply setting r = yk v for every v ∈ V . The algorithm returns S ∈ {S1(r∗1), . . . , Sn(r∗n)} that maximizes w(S)/f (S). For reference, we describe the procedure in Algorithm 3. Clearly, the algorithm runs in polynomial time. In what follows, we demonstrate that Algorithm 3 obtains an optimal solution to f-DS with concave function f. The following lemma provides a lower bound on the optimal value of LPk. Lemma 4. For any S ⊆ V , the optimal value of LPS Proof. For S ⊆ V , we construct a solution (x, y) of LPS is at least w(S). as follows: 1 if e ∈ E(S), 0 otherwise, xe = 1 if v ∈ S, 0 otherwise. and yv = Then we can easily check that (x, y) is feasible for LPS have the lemma. and its objective value is w(S). Thus, we We prove the following key lemma. Lemma 5. Let S∗ ⊆ V be an optimal solution to f-DS with concave function f, and let k∗ = S∗. Furthermore, let (x∗, y∗) be an optimal solution to LPk∗. Then, there exists a real number r such that Sk∗(r) is optimal to f-DS with concave function f. Proof. For each e = {u, v} ∈ E, we have x∗e = min{y∗u, y∗v} from the optimality of (x∗, y∗). Without 12 loss of generality, we relabel the indices of (x∗, y∗) so that y∗1 ≥ ··· ≥ y∗n. Then we have (cid:90) y∗1 0 w(Sk∗(r))dr = = =  (cid:88) (cid:90) y∗1 (cid:90) y∗1 (cid:88) (cid:88) e={u,v}∈E 0 0 e={u,v}∈E e={u,v}∈E w(e) · [y∗u ≥ r and y∗v ≥ r] (w(e) · [y∗u ≥ r and y∗v ≥ r]) dr (cid:88) e∈E  dr where [y∗u ≥ r and y∗v ≥ r] is the function of r that takes 1 if the condition in the square bracket is satisfied and 0 otherwise, and the last inequality follows from Lemma 4. Moreover, we have w(e) · min{y∗u, y∗v} = w(e) · x∗e ≥ w(S∗), (3) f (h) · (y∗h − y∗h+1) = n(cid:88) (f (h) − f (h − 1)) · y∗h h=1 (f (h) − f (h − 1)) = f (k∗) − f (0) = f (k∗), (4) (cid:90) y∗1 0 f (Sk∗(r))dr = n(cid:88) k∗(cid:88) f (h + 2) − f (h + 1) ≤ f (h + 1) − f (h)),(cid:80)n ≤ h=1 h=1 where y∗n+1 is defined to be 0 for convenience, and the inequality holds by the concavity of f (i.e., Let r∗ be a real number that maximizes w(Sk∗(r))/f (Sk∗(r)) in [0, y∗1]. Using inequalities (3) and (4), we have h=1 y∗h = k∗, and y∗h ≤ 1. (cid:82) y∗1 (cid:82) y∗1 (cid:82) y∗1 (cid:82) y∗1 (cid:16) w(Sk∗ (r)) (cid:17) (cid:82) y∗1 f (Sk∗ (r)) · f (Sk∗(r)) (cid:16) w(Sk∗ (r∗)) (cid:17) 0 f (Sk∗(r))dr (cid:82) y∗1 f (Sk∗ (r∗)) · f (Sk∗(r)) dr 0 w(Sk∗(r))dr 0 f (Sk∗(r))dr = = 0 0 w(Sk∗(r∗)) f (Sk∗(r∗)) . 0 f (Sk∗(r))dr dr w(S∗) f (k∗) ≤ ≤ This completes the proof. Algorithm 3 considers Sk∗(r∗) as a candidate subset of the output. Therefore, we have the desired result. Theorem 3. Algorithm 3 is a polynomial-time exact algorithm for f-DS with concave function f. By Lemma 5, for any concave function f, an optimal solution to f-DS with the function f is contained in {Sk(r) k = 1, . . . , n, r ∈ [0, 1]} whose cardinality is at most n2. As shown above, for any dense frontier point, there exists some concave function f such that any optimal solution to f-DS with the function f corresponds to the dense frontier point. Thus, we have the following result. Theorem 4. We can find a corresponding subset of vertices for every dense frontier point in poly- nomial time. 13 3.3 Flow-Based Algorithm We provide a combinatorial exact algorithm for unweighted graphs (i.e., w(e) = 1 for every e ∈ E). We first show that using the standard technique for fractional programming, we can reduce f-DS with concave function f to a sequence of submodular function minimizations. The critical fact is that maxS⊆V w(S)/f (S) is at least β if and only if minS⊆V (β · f (S) − w(S)) is at most 0. Note that for β ≥ 0, the function β · f (S) − w(S) is submodular because β · f (S) and −w(S) are submodular [12]. Thus, we can calculate minS⊆V (β · f (S) − w(S)) in O(n5(m + n)) time using Orlin's algorithm [19], which implies that we can determine maxS⊆V w(S)/f (S) ≥ β or not in O(n5(m + n)) time. Hence, we can obtain the value of maxS⊆V w(S)/f (S) by binary search. Note that the objective function of f-DS on unweighted graphs may have at most O(mn) distinct values since w(S) is a nonnegative integer at most m. Thus, the procedure yields an optimal solution in O(log(mn)) = O(log n) iterations. The total running time is O(n5(m + n) · log n). To reduce the computation time, we replace Orlin's algorithm with a much faster flow-based algorithm that substantially extends a technique of Goldberg's flow-based algorithm for the densest subgraph problem [14]. The key technique is to represent the value of minS⊆V (β · f (S) − w(S)) using the cost of minimum cut of a certain directed network constructed from G and β ≥ 0. For a given unweighted undirected graph G = (V, E, w) (i.e., w(e) = 1 for every e ∈ E) and a real number β ≥ 0, we construct a directed network (U, A, wβ) as follows. Note that for later convenience, we discuss the procedure on weighted graphs. The vertex set U is defined by U = V ∪ P ∪ {s, t}, where P = {p1, . . . , pn}. The edge set A is given by A = As ∪ At ∪ A1 ∪ A2, where As = {(s, v) v ∈ V }, At = {(p, t) p ∈ P}, A1 = {(u, v), (v, u) {u, v} ∈ E}, and A2 = {(v, p) v ∈ V, p ∈ P}. The edge weight wβ : A → R ≥0 is defined by d(v)/2 β · k · ak 1/2 (= w({u, v})/2) β · ak  2f (k) − f (k + 1) − f (k − 1) f (n) − f (n − 1) (e = (s, v) ∈ As), (e = (pk, t) ∈ At), (e = (u, v) ∈ A1), (e = (v, pk) ∈ A2), (k = 1, . . . , n − 1), (k = n). wβ(e) = ak = where d(v) is the (weighted) degree of vertex v, and Note that ak ≥ 0 holds since f is a monotonically non-decreasing concave function. For reference, Figure 3 depicts the network (U, A, wβ). The following lemma reveals the relationship between a minimum s -- t cut in (U, A, wβ) and the value of minS⊆V (β · f (S) − w(S)). Note that an s -- t cut in (U, A, wβ) is a partition (X, Y ) of U 14 Figure 3: The network (U, A, wβ) constructed from G and β ≥ 0. (i.e., X ∪ Y = U and X ∩ Y = ∅) such that s ∈ X and t ∈ Y , and the cost of (X, Y ) is defined to be(cid:80) (u,v)∈A: u∈X,v∈Y wβ(u, v). Lemma 6. Let (X, Y ) be any minimum s -- t cut in the network (U, A, wβ), and let S = X ∩ V . Then, the cost of (X, Y ) is equal to w(V ) + β · f (S) − w(S). Proof. We first show that for any positive integer s (≤ n), it holds that min{i, s} · ai = f (s). (5) n(cid:88) i=1 n−1(cid:88) n−1(cid:88) j=i j=i By the definition of ak, we get n(cid:88) j=i aj = (f (n) − f (n − 1)) + = (f (n) − f (n − 1)) − (2f (j) − f (j + 1) − f (j − 1)) ((f (j + 1) − f (j)) − (f (j) − f (j − 1))) = f (i) − f (i − 1). Thus, we have n(cid:88) i=1 min{i, s} · ai = s(cid:88) n(cid:88) aj = s(cid:88) i=1 j=i i=1 (f (i) − f (i − 1)) = f (s) − f (0) = f (s). We are now ready to prove the lemma. Note that pk ∈ X if S > k and pk ∈ Y if S < k. 15 st...u...v...p1...pk...pnVPβ·akβ·akd(u)2d(v)2β·1·a1β·k·ak12(=w({u,v})2)12(=w({u,v})2)β·n·an Algorithm 4: Flow-based algorithm for unweighted graphs 1 Let {β1, . . . , βr} = {p/f (q) p = 0, 1, . . . , m, q = 2, 3, . . . , n} such that β1 < ··· < βr; 2 imin ← 1 and imax ← r; 3 while True do i ← (cid:98)(imax + imin)/2(cid:99); 4 Compute a minimum s -- t cut (X, Y ) in (U, A, wβi); 5 if the cost of (X, Y ) is larger than w(V ) then imax ← i − 1; 6 else if the cost of (X, Y ) is less than w(V ) then imin ← i + 1; 7 else return X ∩ V ; 8 Therefore, the cost of the minimum cut (X, Y ) is (cid:88) (cid:88) (cid:88) v∈V \S = v∈V \S = d(v) 2 + d(v) 2 (cid:88) (cid:88) (cid:88) {u,v}∈E: u∈S, v∈V \S + {u,v}∈E: u∈S, v∈V \S {u,v}∈E {u,v}∈E(S) w({u, v}) 2 + β · n(cid:88) i=1 min{i,S} · ai w({u, v}) 2 + β · f (S) w({u, v}) − w({u, v}) + β · f (S) = w(V ) + β · f (S) − w(S), where the first equality follows from equality (5). From this lemma, we see that the cost of a minimum s -- t cut is w(V ) + minS⊆V (β · f (S) − w(S)). Therefore, for a given value β ≥ 0, we can determine whether there exists S ⊆ V that satisfies w(S)/f (S) ≥ β by checking the cost of a minimum s -- t cut is at most w(V ) or not. Our algorithm applies binary search for β within the possible objective values of f-DS (i.e., {p/f (q) p = 0, 1, . . . , m, q = 2, 3, . . . , n}). For reference, we describe the procedure in Algorithm 4. The minimum s -- t cut problem can be solved in O(N 3/ log N ) time for a network with N vertices [8]. log n · log(mn)) = O(n3) since U = 2n + 2. We Thus, the running time of our algorithm is O( n3 summarize the result in the following theorem. Theorem 5. Algorithm 4 is an O(n3)-time exact algorithm for f-DS with concave function f on unweighted graphs. For f-DS with concave function f on weighted graphs, the binary search used in Algorithm 4 is not applicable because there may be exponentially many possible objective values in the weighted setting. Alternatively, we present an algorithm that employs another binary search strategy (Algo- rithm 5). We have the following theorem. Theorem 6. Algorithm 5 is an O with concave function f. Proof. Let i∗ be the number of iterations executed by Algorithm 5, and let S = X (i∗) ∩ V . Then we have maxS⊆V w(S)/f (S) ≤ β(i∗) lb ≤ w( S)/f ( S). Combining -time (1+)-approximation algorithm for f-DS ub < (1 + ) · β(i∗) lb , and β(i∗) ub , β(i∗) log n · log  (cid:16) n3 (cid:16) log n (cid:17)(cid:17) 16 3 (cid:113) lb ← w(S∗2 )/f (2), β(0) ub ≥ (1 + ) · β(i) ub ← w(V )/f (2), and i ← 0; lb do Algorithm 5: Flow-based algorithm for weighted graphs 1 β(0) 2 while β(i) β(i) ← Compute a minimum s -- t cut (X (i), Y (i)) in (U, A, wβ(i)); if the cost of (X (i), Y (i)) is larger than w(V ) then β(i+1) else β(i+1) i ← i + 1; 6 7 8 Compute a minimum s -- t cut (X (i), Y (i)) in (U, A, w lb ← β(i) and β(i+1) ub ← β(i) ub; lb · β(i) β(i) ub; 4 5 lb ← β(i) lb and β(i+1) ub ← β(i); ) and return X (i) ∩ V ; β(i) lb these inequalities, we have maxS⊆V w(S)/f (S) < (1 + ) · w( S)/f ( S), which means that S is a (1 + )-approximate solution. In what follows, we analyze the time complexity of the algorithm. For each i ∈ {0, 1, . . . , i∗ − 1}, it holds that (cid:40) (cid:41) β(i+1) ub β(i+1) lb ≤ max β(i) ub β(i) , β(i) β(i) lb = max (cid:113)  β(i) ub(cid:113) β(i) lb · β(i) (cid:17)(cid:17) lb ≤ m1/2i for i = 1, . . . , i∗. Note that i∗ is lb ≤ 1 + . Thus, we see that i∗ is upper bounded by (cid:118)(cid:117)(cid:117)(cid:116) β(i) (cid:16) log n  = (cid:16) n3 β(i) lb · β(i) β(i) lb ub /β(i) ub β(i) lb ub ub . , log n · log log(1+) = 1 holds. log(1+)  = ub /β(0) Since β(0) the minimum index i that satisfies β(i) O (cid:16) log n (cid:17)(cid:17) lb = w(V )/w(S∗2 ) ≤ m, we have β(i) (cid:16) log n (cid:16) (cid:16) n3 ub /β(i) (cid:17)(cid:17) log(1+) . Therefore, the total running time of the algorithm is O , where the equality follows from the fact that lim→+0  log log n · log O 3.4 Greedy Peeling Finally, we provide an approximation algorithm with much higher scalability. Specifically, we prove that the greedy peeling (Algorithm 2) has an approximation ratio of 3 for f-DS with concave function f. As mentioned above, the algorithm runs in O(m+n log n) time for weighted graphs and O(m+n) time for unweighted graphs. We prove the approximation ratio. Recall that Sn, . . . , S1 are the subsets of vertices produced by the greedy peeling. We use the following fact, which implies that there exists a 3-approximate solution for DalkS in Sn, . . . , Sk. Fact 1 (Theorem 1 in Andersen and Chellapilla [1]). For any integer k (≤ n), it holds that max S⊆V : S≥k w(S) S ≤ 3 · max k≤i≤n w(Si) i . Theorem 7. The greedy peeling (Algorithm 2) has an approximation ratio of 3 for f-DS with concave function f. 17 Proof. Let S∗ ⊆ V be an optimal solution to f-DS with concave function f, and let s∗ = S∗. Let S ⊆ V be the output of the greedy peeling for the problem. Then we have w(S∗) f (s∗) = w(S∗)/s∗ f (s∗)/s∗ ≤ max S(cid:48)⊆V : S(cid:48)≥s∗ w(S(cid:48))/S(cid:48) f (s∗)/s∗ ≤ 3 · max s∗≤i≤n w(Si)/i f (s∗)/s∗ ≤ 3 · max s∗≤i≤n w(Si)/i f (i)/i ≤ 3 · w(S) f (S) , where the second inequality follows from Fact 1, and the third inequality follows from the mono- tonicity of f (x)/x. Acknowledgments The authors would like to thank Yoshio Okamoto for pointing out the reference [18]. The first author is supported by a Grant-in-Aid for Young Scientists (B) (No. 16K16005). The second author is supported by a Grant-in-Aid for JSPS Fellows (No. 26-11908). References [1] R. Andersen and K. Chellapilla. Finding dense subgraphs with size bounds. In WAW '09: Proceedings of the 6th Workshop on Algorithms and Models for the Web Graph, pages 25 -- 37, 2009. [2] A. Angel, N. Sarkas, N. Koudas, and D. Srivastava. Dense subgraph maintenance under stream- ing edge weight updates for real-time story identification. In VLDB '12: Proceedings of the 38th International Conference on Very Large Data Bases, pages 574 -- 585, 2012. [3] Y. Asahiro, K. Iwama, H. Tamaki, and T. Tokuyama. Greedily finding a dense subgraph. J. Algorithms, 34(2):203 -- 221, 2000. [4] G. D. Bader and C. W. V. Hogue. An automated method for finding molecular complexes in large protein interaction networks. BMC Bioinformatics, 4(1):1 -- 27, 2003. [5] A. Bhaskara, M. Charikar, E. Chlamtac, U. Feige, and A. Vijayaraghavan. Detecting high log-densities: An O(n1/4) approximation for densest k-subgraph. In STOC '10: Proceedings of the 42nd ACM Symposium on Theory of Computing, pages 201 -- 210, 2010. [6] F. Bonchi, F. Gullo, A. Kaltenbrunner, and Y. Volkovich. Core decomposition of uncertain In KDD '14: Proceedings of the 20th ACM SIGKDD International Conference on graphs. Knowledge Discovery and Data Mining, pages 1316 -- 1325, 2014. [7] M. Charikar. Greedy approximation algorithms for finding dense components in a graph. In APPROX '00: Proceedings of the 3rd International Workshop on Approximation Algorithms for Combinatorial Optimization, pages 84 -- 95, 2000. 18 [8] J. Cheriyan, T. Hagerup, and K. Mehlhorn. An o(n3)-time maximum-flow algorithm. SIAM J. Comput., 25(6):1144 -- 1170, 1996. [9] Y. Dourisboure, F. Geraci, and M. Pellegrini. Extraction and classification of dense communities in the web. In WWW '07: Proceedings of the 16th International Conference on World Wide Web, pages 461 -- 470, 2007. [10] U. Feige, D. Peleg, and G. Kortsarz. The dense k-subgraph problem. Algorithmica, 29(3):410 -- 421, 2001. [11] E. Fratkin, B. T. Naughton, D. L. Brutlag, and S. Batzoglou. MotifCut: regulatory motifs finding with maximum density subgraphs. Bioinformatics, 22(14):e150 -- e157, 2006. [12] S. Fujishige. Submodular Functions and Optimization, volume 58 of Annals of Discrete Mathe- matics. Elsevier, 2005. [13] D. Gibson, R. Kumar, and A. Tomkins. Discovering large dense subgraphs in massive graphs. In VLDB '05: Proceedings of the 31st International Conference on Very Large Data Bases, pages 721 -- 732, 2005. [14] A. V. Goldberg. Finding a maximum density subgraph. Technical report, University of Cali- fornia Berkeley, 1984. [15] Y. Kawase and A. Miyauchi. The densest subgraph problem with a convex/concave size func- In ISAAC '16: Proceedings of the 27th International Symposium on Algorithms and tion. Computation, pages 44:1 -- 44:12, 2016. [16] S. Khot. Ruling out PTAS for graph min-bisection, dense k-subgraph, and bipartite clique. SIAM J. Comput., 36(4):1025 -- 1071, 2006. [17] S. Khuller and B. Saha. On finding dense subgraphs. In ICALP '09: Proceedings of the 36th International Colloquium on Automata, Languages and Programming, pages 597 -- 608, 2009. [18] K. Nagano, Y. Kawahara, and K. Aihara. Size-constrained submodular minimization through minimum norm base. In ICML '11: Proceedings of the 28th International Conference on Ma- chine Learning, pages 977 -- 984, 2011. [19] J. B. Orlin. A faster strongly polynomial time algorithm for submodular function minimization. Math. Program., 118(2):237 -- 251, 2009. [20] C. E. Tsourakakis, F. Bonchi, A. Gionis, F. Gullo, and M. Tsiarli. Denser than the densest subgraph: Extracting optimal quasi-cliques with quality guarantees. In KDD '13: Proceedings of the 19th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 104 -- 112, 2013. [21] H. Yanagisawa and S. Hara. Axioms of density: How to define and detect the densest subgraph. Technical report, IBM Research - Tokyo, 2016. 19
1211.5414
1
1211
2012-11-23T06:11:54
Analysis of a randomized approximation scheme for matrix multiplication
[ "cs.DS", "cs.LG", "math.NA", "stat.ML" ]
This note gives a simple analysis of a randomized approximation scheme for matrix multiplication proposed by Sarlos (2006) based on a random rotation followed by uniform column sampling. The result follows from a matrix version of Bernstein's inequality and a tail inequality for quadratic forms in subgaussian random vectors.
cs.DS
cs
Analysis of a randomized approximation scheme for matrix multiplication Daniel Hsu1, Sham M. Kakade1, and Tong Zhang2 1Microsoft Research, New England 2Department of Statistics, Rutgers University August 27, 2018 Abstract This note gives a simple analysis of a randomized approximation scheme for matrix multipli- cation proposed by [Sar06] based on a random rotation followed by uniform column sampling. The result follows from a matrix version of Bernstein's inequality and a tail inequality for quadratic forms in subgaussian random vectors. 1 Introduction Let A := [a1a2··· am] ∈ RdA×m and B := [b1b2··· bm] ∈ RdB×m be fixed matrices, each with m columns. If m is very large, then the straightforward computation of the matrix product AB ⊤ (with Ω(dAdBm) operations) can be prohibitive. We can instead approximate the product using the following randomized scheme. Let Θ ∈ Rm×m be a random orthogonal matrix; the distribution of Θ will be specified later in Theorem 1, but a key property of Θ will be that the matrix products A := AΘ and B := BΘ can be computed with O((dA + dB)m log m) operations. Given the products A = [a1a2··· am] and B = [b1b2··· bm], we take a small uniform random sample of pairs of their columns (drawn with replacement) (ai1, bi1), (ai2 , bi2), . . . , (ain , bin), and then compute the sum of outer products [AB ⊤ := m n nXj=1 aij b⊤ ij . It is easy to check that [AB ⊤ is an unbiased estimator of AB ⊤. The sum can be computed from A and B with O(dAdBn) operations, so overall, the matrix [AB ⊤ can be computed with O(dAdBn + E-mail: [email protected], [email protected], [email protected] 1 (dA + dB)m log m) operations. (In fact, the log m can be replaced by log n [AL08].) Therefore, we would like n to be as small as possible so that, with high probability, k[AB ⊤ − AB ⊤k ≤ εkAkkBk for some error ε > 0, where k · k denotes the spectral norm. As shown in Theorem 1, it suffices to have n = Ω(cid:18)(k + log(m)) log(k) ε2 (cid:19), where k := max{tr(A⊤A)/kAk2, tr(B ⊤B)/kBk2} ≤ max{rank(A), rank(B)}. A flawed analysis of a different scheme based on non-uniform column sampling (without a random rotation Θ) was given in [HKZ12a]; that analysis gave an incorrect bound on kE[X 2]k for a certain random symmetric matrix X. A different analysis of this non-uniform sampling scheme can be found in [MZ11], but that analysis has some deficiencies as pointed out in [HKZ12a]. The scheme studied in the present work, which employs a certain random rotation followed by uniform column sampling, was proposed by [Sar06], and is based on the Fast Johnson-Lindenstrauss Transform of [AC09]. The analysis given in [Sar06] bounds the Frobenius norm error; in this work, we bound the spectral norm error. A similar but slightly looser analysis of spectral norm error was very recently provided in [ABTZ12]. 2 Analysis Let [m] := {1, 2, . . . , m}. Theorem 1. Pick any δ ∈ (0, 1/3), and let k := max{tr(AA⊤)/kAk2, tr(BB ⊤)/kBk2} (note that √m DH, where D = diag(ǫ), ǫ ∈ {±1}m is a vector k ≤ max{rank(A), rank(B)}. Assume Θ = 1 of independent Rademacher random variables, and H ∈ {±1}m×m is a Hadamard matrix. With probability at least 1 − δ, k[AB ⊤ − AB ⊤k ≤ kAkkBk s 4(k + 2pk ln(3m/δ) + 2 ln(3m/δ) + 1) ln(6k/δ) n 2(k + 2pk ln(3m/δ) + 2 ln(3m/δ) + 1) ln(6k/δ) 3n + !. The proof of Theorem 1 is a consequence of the following lemmas, combined with a union bound. Lemma 1 bounds the error in terms of a certain quantity µ which depends on the random orthogonal matrix Θ (and A and B). Lemma 2 gives a bound on µ that holds with high probability over the random choice of Θ. Lemma 1. Define Q = [q1q2··· qm] := kAk−1AΘ, R = [r1r2··· rm] := kBk−1BΘ, kA := tr(QQ⊤) = tr(AA⊤)/kAk2, kB := tr(RR⊤) = tr(BB ⊤)/kBk2, and Then µ := m max(cid:16)(cid:8)kqik2 : i ∈ [m](cid:9) ∪(cid:8)krik2 : i ∈ [m](cid:9)(cid:17). 3n (cid:19)(cid:21) ≤ 2pkAkB · Pr(cid:20)k[AB ⊤ − AB ⊤k > kAkkBk(cid:18)r 2(µ + 1)t (µ + 1)t + n t et − t − 1 . 2 and let X1, X2, . . . , Xn be independent copies of X. Define Then Proof. Observe that because Θ is orthogonal, ij − QR⊤(cid:13)(cid:13)(cid:13)(cid:13). i ∈ [m], m n RQ⊤ 1 n 1 n riq⊤ i qir⊤ i qij r⊤ distribution = Xj and 1 m , nXj=1 k[AB ⊤ − AB ⊤k = kAkkBk(cid:13)(cid:13)(cid:13)(cid:13) 0 (cid:21)(cid:21) = Pr(cid:20)X = m(cid:20) 0 M :=(cid:20) 0 (cid:13)(cid:13)(cid:13)(cid:13) (Xj − M )(cid:13)(cid:13)(cid:13)(cid:13) RQ⊤QR⊤(cid:21) , nXj=1 cM := kcM − Mk =(cid:13)(cid:13)(cid:13)(cid:13) nXj=1 E[X]2 = M 2 =(cid:20)QR⊤RQ⊤ m(cid:20)krik2qiq⊤ i(cid:21) = m(cid:20)Pm mXi=1 kqikkrik ≤ 2µpkAkB, mXi=1 kqik2krik2 ≤ 2µ i(cid:13)(cid:13)(cid:13), (cid:13)(cid:13)(cid:13) mXi=1 kqik2rir⊤ mXi=1 krik2qiq⊤ Pr(cid:20)kcM − Mk >r 2(µ + 1)t kqik2rir⊤ mXi=1 nXj=1 E[X 2] = (µ + 1)t 0 0 0 0 n + 3n m n kE[X 2]k ≤ m maxn(cid:13)(cid:13)(cid:13) i tr(E[X 2]) = 2m kE[(X − M )2]k = kE[X 2] − M 2k ≤ µ + 1. Therefore, by the matrix Bernstein inequality from [HKZ12a], QR⊤ 0 (cid:21) . ij − QR⊤(cid:13)(cid:13)(cid:13)(cid:13). qij r⊤ i=1 krik2qiq⊤ i 0 0 i=1 kqik2rir⊤ i(cid:21) , Pm i(cid:13)(cid:13)(cid:13)o ≤ µ maxnkQQ⊤k, kRR⊤ko = µ, (cid:21) ≤ 2pkAkB · et − t − 1 t . We now derive a high probability bound for the last term on the right-hand side. Define a random symmetric matrix X with Observe that E[X − M ] = 0 and kX − Mk ≤ kXk + kMk ≤ µ + 1. Moreover, The lemma follows. The following lemma is a special case of a result found in [HKZ11]. √m DH, where D = diag(ǫ), ǫ ∈ {±1}m is a vector of independent Lemma 2. Assume Θ = 1 Rademacher random variables, and H ∈ {±1}m×m is a Hadamard matrix. Let Z ∈ Rm×d be a matrix with kZk ≤ 1, and set kZ := tr(ZZ ⊤). Then Pr(cid:20)max{kZ ⊤Θeik2 : i ∈ [m]} > kZ + 2pkZ (ln(m) + t) + 2(ln(m) + t) m (cid:21) ≤ e−t where ei ∈ {0, 1}m is the i-th coordinate axis vector in Rm. 3 Proof. Observe that for each i ∈ [m], the random vector √mΘei has the same distribution as ǫ. Moreover, ǫ is a subgaussian random vector in the sense that E[exp(α⊤ǫ)] ≤ exp(kαk2/2) for any vector α ∈ Rm. Therefore, we may apply a tail bound for quadratic forms in subgaussian random vectors (e.g., [HKZ12b]) to obtain Pr(cid:20)k√mZ ⊤Θeik2 > tr(ZZ ⊤) + 2ptr((ZZ ⊤)2)τ + 2kZZ ⊤kτ(cid:21) ≤ e−τ for each i ∈ [m] and any τ > 0. The lemma follows by observing that kZZ ⊤k ≤ 1 and tr((ZZ ⊤)2) ≤ tr(ZZ ⊤)kZZ ⊤k ≤ kZ , and applying a union bound over all i ∈ [m]. We note that Lemma 2 holds for many other distributions of orthogonal matrices (with possibly worse constants). All that is required is that √mΘei be a subgaussian random vector for each i ∈ [m]. See [HKZ11] for more discussion. Proof of Theorem 1. We apply Lemma 2 with both Z = A/kAk and Z = B/kBk, and combine the implied probability bounds with a union bound to obtain Pr(cid:2)µ > k + 2pk log(3m/δ) + 2 ln(3m/δ)(cid:3) ≤ 2δ/3, where µ is defined in the statement of Lemma 1, and the probabiltiy is taken with respect to the random choice of Θ. Now we apply Lemma 1, together with the bound t/(et − t − 1) ≤ e−t/2 for t ≥ 2.6, and substitute t := 2 ln(6k/δ) to obtain Pr(cid:20)k[AB ⊤ − AB ⊤k > kAkkBk(cid:18)r 4(µ + 1) ln(6k/δ) n + 2(µ + 1) ln(6k/δ) 3n (cid:19)(cid:21) ≤ δ/3. Combining the two probability bounds with a union bound implies the claim. Acknowledgements We thank Joel Tropp for pointing out the error in the analysis from [HKZ12a]. References [ABTZ12] H. Avron, C. Boutsidis, S. Toledo, and A. Zouzias. Efficient dimensionality reduction for canonical correlation analysis, 2012. arXiv:1209.2185. [AC09] [AL08] N. Ailon and B. Chazelle. Approximate nearest neighbors and the fast Johnson- Lindenstrauss transform. SIAM J. Comput., 39(1):302 -- 322, 2009. N. Ailon and E. Liberty. Fast dimension reduction using Rademacher series on dual BCH codes. In Proceedings of the 19th Annual ACM-SIAM Symposium on Discrete Algorithms, 2008. [HKZ11] D. Hsu, S. M. Kakade, and T. Zhang. Analysis of random design linear regression, 2011. arXiv:1106.2363. [HKZ12a] D. Hsu, S. M. Kakade, and T. Zhang. Tail inequalities for sums of random matrices that depend on the intrinsic dimension. Electronic Communications in Probability, 17(14):1 -- 13, 2012. 4 [HKZ12b] D. Hsu, S. M. Kakade, and T. Zhang. A tail inequality for quadratic forms of subgaussian random vectors. Electronic Communications in Probability, 17(52):1 -- 6, 2012. [MZ11] [Sar06] A. Magen and A. Zouzias. Low rank matrix-valued Chernoff bounds and approximate matrix multiplication. In Proceedings of the 22nd ACM-SIAM Symposium on Discrete Algorithms, 2011. T. Sarl´os. Improved approximation algorithms for large matrices via random projec- tions. In Proceedings of the 47th Annual IEEE Symposium on Foundations of Computer Science, 2006. 5
1909.07515
2
1909
2019-10-28T20:38:59
Multiplicative Rank-1 Approximation using Length-Squared Sampling
[ "cs.DS" ]
We show that the span of $\Omega(\frac{1}{\varepsilon^4})$ rows of any matrix $A \subset \mathbb{R}^{n \times d}$ sampled according to the length-squared distribution contains a rank-$1$ matrix $\tilde{A}$ such that $||A - \tilde{A}||_F^2 \leq (1 + \varepsilon) \cdot ||A - \pi_1(A)||_F^2$, where $\pi_1(A)$ denotes the best rank-$1$ approximation of $A$ under the Frobenius norm. Length-squared sampling has previously been used in the context of rank-$k$ approximation. However, the approximation obtained was additive in nature. We obtain a multiplicative approximation albeit only for rank-$1$ approximation.
cs.DS
cs
Multiplicative Rank-1 Approximation using Length-Squared Sampling Ragesh Jaiswal⋆ and Amit Kumar Department of Computer Science and Engineering, Indian Institute of Technology Delhi.⋆⋆ ε4 ) rows of any matrix A ⊂ Rn×d sampled according to Abstract. We show that the span of Ω( 1 the length-squared distribution contains a rank-1 matrix A such that A − A2 F ≤ (1 + ε) · A − π1(A)2 F , where π1(A) denotes the best rank-1 approximation of A under the Frobenius norm. Length- squared sampling has previously been used in the context of rank-k approximation. However, the approximation obtained was additive in nature. We obtain a multiplicative approximation albeit only for rank-1 approximation. 1 Introduction Rank-k approximation is an important problem in data analysis. Given a dataset represented as a matrix A ⊂ Rn×d, where the rows of the matrix represent the data points, the goal is to find a rank-k matrix A such that A − A2 F . Here πk(A) denotes the best rank-k matrix under the Frobenius norm, that is, F is is not too large compared to A − πk(A)2 πk(A) = argmin X:rank(X)≤k A − X2 F . Note that this problem is not computationally hard and can be solved using Singular Value Decom- position (SVD). Here, we discuss a simpler sampling based algorithm. From a geometric perspective, the problem is to find a best-fit k-subspace to a given n points in d-dimensional Euclidean space where the measure of fit is the sum of squared distance of the points to the subspace. In this article we restrict our discussion to rank-1 approximation which corresponds to the geometric best-fit line problem. We will be using the matrix and the geometric interpretations interchangeably in this discussion. We will discuss a sampling technique for this problem. We start with the following question: "Is there a simple sampling procedure that samples a few rows of the given matrix such that the span of the sampled rows contain a good rank-1 approximation?" Let us try the simplest option of sampling from the uniform distribution. One quickly realises that it is easy to construct datasets where the span of even a fairly large sample of uniformly sampled rows does not contain a good rank-1 matrix. For example, consider a two-dimensional dataset where all points except one have coordinate (0, y) and the remaining point has coordinate (x, 0) and x ≫ y. This example suggests that one should take the norm of a point into consideration while sampling. This naturally leads to length-squared sampling. The idea is to sample rows such that the sampling probability of the ith row is proportional to the square of its norm. That is, the sampling probability pi of the row A(i) of a matrix A is given by: pi = kA(i)k2 A2 F ⋆ Part of the work was done while the author was on sabbatical from IIT Delhi and visiting UC San Diego. ⋆⋆ Email addresses: {rjaiswal, amitk}@cse.iitd.ac.in Length-squared sampling has been explored in the past work of Frieze et al. [FKV04] and further explored in various works [DRVW06, DV06]. The main result known from previous works in the context of rank-1 approximation is the following theorem of Frieze et al. [FKV04]. Theorem 1 ([FKV04]). Let 0 < ε < 1. Let S be a sample of s rows of an n × d matrix A, each chosen independently with length-squared distribution. If s = Ω( 1 ε ), then the span of S contains a matrix A of rank-1 such that: E[A − A2 F ] ≤ A − π1(A)2 F + ε · A2 F . Note that this only gives an additive approximation and the additive error of ε · A2 F can be very large since we do not have any control on A2 F . This raises the question about whether a multiplica- tive approximation could be possible. The subsequent works of Deshpande and Vempala [DV06] and Deshpande et al. [DRVW06] use adaptive length-squared sampling along with volume sampling to obtain a multiplicative approximation. In this work, we show that length-squared sampling is sufficient to obtain a multiplicative approximation albeit at the cost of using a slightly larger sample size. Our main result is formally stated as the following theorem. Theorem 2 (Main result). Let 0 < ε < 1. Let S be a sample of s rows of an n×d matrix A, each chosen independently with length-squared distribution. If s = Ω( 1 ε4 ), then the span of S contains a matrix A of rank-1 such that: E[A − A2 F ] ≤ (1 + ε) · A − π1(A)2 F . We prove our main result in the next section. Before we do this, let us discuss the application of our results in the streaming setting that is relevant for big data analysis where n and d are very large1. Note that length-squared sampling will naturally give a 2-pass streaming algorithm that uses O( n+d log nd) space. Here, in the first pass, we perform length-squared sampling using reservoir ε4 sampling2. In the second pass, we project all the points in the space spanned by the sampled rows and find the best fit line in this smaller dimensional space. It is important to note that a streaming algorithm with similar space bound that works using only one pass is known [CW09]. So, our note is more about the properties of length-squared sampling than streaming algorithms for rank-1 approximation. 1.1 Related work Low rank approximation of matrices has large number of applications in information retrieval and data mining (see e.g. [DKR02, PRTV00, AFKM01, DFK+04]). There has been lot of recent activity in obtaining low rank approximations in time depending on the number of non-zero entries in the input matrix [CW17, Sar06, DV06, Har14]. All of these methods rely on computing suitable random projections of the input matrix. Length-squared sampling is a natural sampling algorithm and has had applications in many problems involving matrix computations [DK01, DK03, FKV04, DFK+04]. As mentioned earlier, Frieze et al. [FKV04] showed that this can also be used for 1 In this setting, one is allowed to make a few passes over the dataset while using limited amount of workspace. That is, the amount of space the should not scale linearly with the dataset size. This makes sense for big data analysis where it may not be possible to hold the entire dataset in the memory for processing. 2 In order to maintain a single sample one does the following. The first row is stored with probability 1. On seeing kA(i)k2 j=1kA(j) k2 . A simple telescoping product the ith row (i > 1), the stored item is replaced wth A(i) with probability Pi shows that the rows get sampled with the desired probability. 2 obtaining low rank approximations, but one needs to incur an additive error term. This restriction was removed in subsequent works [DV06, Sar06, DMM06a, DMM06b, DMM06c, NDT09, MZ11, DMMS11] but using different techniques. Our main contribution is to show that length-squared sampling is sufficient to obtain a bounded multiplicative error for rank-1 approximation. 2 Rank-1 approximation We prove our main result in this section. Before delving into the proof, we give some intuition behind the analysis. By a suitable rotation, we can assume that π1(A), the closest rank-1 matrix to A in terms of Frobenius norm, is the first column of A. Let σ2 and r2 denote π1(A)2 F and A−π1(A)2 F respectively. If r is large compared to σ, then the additive guarantee given by Theorem 1 implies a multiplicative guarantee as well. So the non-trivial case is when r ≪ σ. Let ri and σi denote the contribution towards r and σ from the ith row respectively. So for most rows, ri ≪ σi -- we call such rows good rows. When we sample a good row, the normalized row will be close to the vector (1, 0, . . . , 0). The heart of the analysis relies on showing that the average of such normalized sampled rows will be close to (1, 0, . . . , 0). In other words, we need to bound the variance term corresponding to rows which are not good. Let A(i) denote the ith row of matrix A. Let v denote the unit vector such that kAvk2 is maximised. Note that v is the largest singular vector of matrix A. We assume without loss of generality that v = (1, 0, 0, ..., 0)3 . Let σ2 = kAvk2. So, we can write A(i) ≡ (σui, r(i)), where i . The following lemma states that under the assumption that r2 is significantly larger than σ2, the conclusion of our main theorem holds due to Theorem 1 (as stated in [FKV04]). Pi u2 Lemma 1. If r2 > ε3σ2, then there is a rank-1 matrix A in the span of Ω(cid:0) 1 i = 1 and r(i) is a vector of dimension (d − 1). Let ri ≡ kr(i)k and r2 ≡ Pikr(i)k2 = Pi r2 ε4(cid:1) independently sampled rows of A sampled with length-squared distribution such that E[A − A2 π1(A)2 F . F ] ≤ (1 + ε) · A − Proof. Note that since v maximises kAvk2, we have π1(A) = σu1,0,...,0 σu2,0,...,0! , which implies that F = σ2 + r2. Combining the above with Theorem 1 (where we use ε4 F = r2. Also, A2 ... A − π1(A)2 for ε), we get: 2 E[A − A2 F ] ≤ r2 + ε3 2 · (r2 + σ2) ≤ (1 + ε) · r2 = (1 + ε) · A − π1(A)2 F . This completes the proof of the lemma. For the remainder of the proof, we will assume that r2 ≤ ε3σ2. ⊓⊔ (1) Let s be a randomly sampled row of matrix A sampled with length-squared distribution and let s(1), s(2), ..., s(l) be l independent copies of s. We would like to define a deterministic procedure to construct a (random) rank-1 matrix X using s(1), ..., s(l), where each row of X lies in the span of s(1), ..., s(l), such that the expected value of A − X2 F is at most (1 + ε) · r2. Another (geometric) way of saying this is that there is a point t in the span of s(1), ..., s(l) such that the squared distance 3 For a matrix A and a unitary matrix Q of appropriate dimension, the lengths of the corresponding rows in A and AQ are the same. So we can choose a suitable Q such that v has the mentioned property 3 of rows of A from the line ℓ(t) is at most (1 + ε) times of that from the best-fit line ℓ(v). Here ℓ(.) denotes the line passing through the given point and origin o = (0, ..., 0). We will need a few more definitions to give the procedure that defines X from s(1), ..., s(l). We first divide the rows into "good" and "bad". A row A(i) is said to be good if i < εσ2u2 r2 i , (2) otherwise it is bad. We now give the procedure for mapping the randomly length-squared sampled s(1), ..., s(l) to an appropriate matrix X. Mapping(s(1), ..., s(l)) - For all i ∈ {1, ..., l}: - If (s(i) is a bad row) then t(i) ← (0, ..., 0) - Else t(i) ← s(i) σui t(i) i=1 l - t ← Pl - For all i ∈ {1, ..., n}: X(i) ← σuit - X ← X(1) X(n)! ... The intuition is that if s(i) is a good row, then t(i) will be close to v = (1, 0, . . . , 0). So X will be very close to π1(A). Note that the above defined procedure is only meant for the analysis and is never actually executed. Also it is easy to see that the n × d matrix X defined above is a rank-1 matrix. We will now bound E[A − X2 F ]. We start with a simple lemma that bounds the probability of sampling a bad row. F ], which is the same as Pi E[A(i) − X(i)2 Lemma 2. The probability that a sampled row s, sampled using length-squared distribution, is bad is at most 2r2 εσ2 . Proof. The probability of sampling a bad row A(i) is given by r2 that a sample row is bad is at most Pi is bad(r2 σ2 i +σ2u2 i ) ≤ Pi is bad(1+ 1 ε )r2 i σ2 i +σ2u2 σ2+r2 ≤ r2 i i +σ2u2 i σ2 ≤ 2r2 εσ2 . . So, the probability ⊓⊔ Let A(i) 1 denote the first coordinate of A(i). Define X(i) 1 − X(i) 1 )2]. 1 and t(i) 1 similarly. We first estimate Pi E[(A(i) Lemma 3. Pi E[(A(i) 1 − X(i) 1 )2] ≤ 5εr2. Proof. Fix an index i. Note that A(i) 1 is σui and X(i) 1 is σuit1. Therefore: (A(i) 1 − X(i) 1 )2 = σ2u2 i (1 − t1)2 ≤ σ2u2 i l2   l Xj=1 (1 − t(j) 2 . 1 )  The last inequality follows from the Jensen's inequality using (1 − x)2 as the convex function. We obtain a bound on the expectation of (A(i) 1 )2 from the above. 1 − X(i) E[(A(i) 1 − X(i) 1 )2] ≤ σ2u2 i l2 l Xj=1 ·  E(cid:20)(cid:16)1 − t(j) 1 (cid:17)2(cid:21)  + σ2u2 i l2 2 l Xj=1 ·  Eh(cid:16)1 − t(j) 1 (cid:17)i  (3) 4 The previous inequality follows from the independence of random variables t(1) shows that the probability of the Bernoulli random variable t(j) So, E[(1 − t(j) εσ2 (note that t(j) in (3) above, we get 1 . Lemma 2 1 being 0 for any j is at most 2r2 εσ2 . is either 0 or 1). Substituting this εσ2 and E[(1 − t(j) 1 )2] ≤ 2r2 1 )] ≤ 2r2 1 , ..., t(l) 1 E[(A(i) 1 − X(i) 1 )2] ≤ 2u2 i r2 εl + 4u2 i r4 ε2σ2 The lemma follows from the facts that Pi u2 i = 1, r2 ≤ ε3σ2 and l ≥ 2 ε4 . ⊓⊔ the first coordinate. If z denotes the vector obtained from t by removing the first coordinate, then Now we estimate the contribution towards Pi E[kA(i) − X(i)k2] from coordinates other than d=2(A(i) observe that PiPl Xi j − X(i) E[kr(i) − σuizk2] = r2 − 2σhXi j )2 =Pikr(i) − σuizk2. Now, observe that uir(i), E[z]i + σ2E[kzk2] (4) We will now estimate each of the terms above. First, note that if z(j) denotes the vector obtained j=1 z(j). Let G denote the index set of from t(j) by removing the first coordinate, then z = 1 good rows. Then observe that for any j, l Pl E[z(j)] = Xk∈G pk r(k) ukσ , (5) where pk is the probability of length-squared sampling the kth row of A. Since the vectors t(j) are chosen i.i.d, the expectation of z can also be written in terms of the above expression (i.e., RHS of (5)). Next, we show a useful inequality for good rows. Fact 1 If row A(i) if good, then ui − pi ui ≤ εui. Proof. Assume that ui > 0, otherwise we can replace ui by −ui in the following argument. Since row A(i) is good, we know that r2 i . Also note that length squared sampling means that pi = σ2u2 i ≤ εσ2u2 σ2+r2 . Using these we get: i +r2 i and pi ui ≤ σ2u2 i + r2 i σ2ui = ui + r2 i σ2ui ≤ (1 + ε) · ui, pi ui ≥ σ2ui r2 + σ2 (1) ≥ ui ε3 + 1 ≥ (1 − ε) · ui The lemma follows from the above two inequalities. ⊓⊔ The next lemma gives an upper bound on kσ · E[z] −Pi uir(i)k. Lemma 4. kσ · E[z] −Pi uir(i)k ≤ 2εr. Proof. Using the triangle inequality and an expression for E[z] using (5), we get that : kσ · E[z] −Xi uir(i)k ≤ kXi /∈G uir(i)k + kXi∈G(cid:18)ui − pi ui(cid:19) r(i)k 5 ui − ui pi ri εuiri + 1 2 r2 1 i! 2 Xi∈G 1 2 r2 i! Cauchy-Schwarz Fact 1 1 ≤ ≤ Xi /∈G uiri +Xi∈G ≤ Xi /∈G uiri +Xi∈G i! Xi /∈G 2 Xi /∈G i! ε · Xi∈G εσ2! r2 i u2 u2 1 2 (2) ≤ + εr 1 2 + εr r · Xi /∈G r ·(cid:18) r2 εσ2(cid:19) 2εr ≤ (1) ≤ This completes the proof of the lemma. We now show a useful fact regarding r(i). Fact 2 kPi uir(i)k ≤ r. Proof. The statement follows by triangle inequality and Cauchy-Schwarz: uir(i)k ≤Xi uiri ≤ Xi kXi 1 2 u2 i! 1 2 r2 i! · Xi = r. This completes the proof. The next lemma bounds the middle term of the RHS of (4). ⊓⊔ ⊓⊔ Proof. We have Lemma 5. 2σ · hPi uir(i), E[z]i ≥ 2kPi uir(i)k2 − 4ε · r2. σ · hXi uir(i),Xj (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) uir(i), E[z]i = hXi uir(i), σ · E[z]i = hXi ujr(j)i(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) uir(i), σ · E[z] −Xj The lemma follows from the above inequality. We now get the following inequalities: kXi hXi Cauchy-Schwarz ≤ ujr(j)i + hXi uir(i), σ · E[z] −Xj ujr(j)i uir(i)k · kσ · E[z] −Xj ujr(j)k Lemma 4, Fact 2 ≤ 2εr2 We now bound the last RHS term of (4). Since z = z(1)+z(2)+...+z(l) l , it is easy to see that where j is an arbitrary index between 1 and l. We can bound the two terms on the RHS below. σ2E[kzk2] ≤ σ2 l E[kz(j)k2] + σ2 ·(cid:16)kE[z(j)]k(cid:17)2 , ⊓⊔ (6) 6 Lemma 6. For any index j, σ2 l · E[kz(j)k2] ≤ εr2. Proof. Note that z(j) is equal to r(k) ukσ with probability pk. Therefore, We have σ2 l · E[kz(j)k2] = σ2 l ·Xk∈G pkr2 k u2 kσ2 Fact 1 ≤ (1 + ε)r2 l The lemma now follows from the fact that l ≥ 2 ε4 . ⊓⊔ Lemma 7. For any index j, σ2 · (kE[z(j)]k)2 ≤ 2kPk ukr(k)k2 + 4ε2r2. Proof. For any index k ∈ G, let δk denote pk uk k /∈ G, let δk denote −uk. Using (5), we can write: − uk. Fact 1 shows that δk≤ εuk. For any index pk r(k) uk k2 σ2 · (kE[z(j)]k)2 = kXk∈G = k Xk∈G = k Xk ≤ 2 kXk (since δk = pk uk − uk for k ∈ G) (since δk = −uk for k /∈ G) δkr(k)!k2 δkr(k)!k2 ukr(k) +Xk∈G ukr(k) +Xk ukr(k)k2 + 2 kXk δkr(k)k2. The second term above can be bounded as follows: kXk δkr(k)k2 ≤ Xk Fact 1 kr2 δ2 k u2 k + r2Xk /∈G u2 k ≤ ε2r2Xk∈G (2) ≤ ε2r2 + r4 εσ2 (1) ≤ 2ε2r2. This completes the proof of the lemma. ⊓⊔ Now, combining Lemma 5, Lemma 6, Lemma 7, we see that (4) can be simplified as: E[kr(i) − σuizk2] ≤ r2 + 9εr2. Xi Combining this with Lemma 3, we get that A− X2 F has an expected value at most (1+ 15ε)r2 for the case where (1) holds. Finally, combining this with Lemma 1, we obtain the main result in Theorem 24. 4 The extra factor of 15 can be handled by using ε/15 instead of ε in the sampling procedure. 7 3 Conclusion and Open Problems The following questions related to length-squared sampling are relevant for the current discussion. 1. Does a single length-squared sampled point approximate the best-fit line? How good is the approximation? 2. Does the result also hold for rank-k approximation for k > 1? That is, does a set of f (ε) length-squared sampled rows (for some function f of ε) contain a rank-k matrix A such that A − A2 F ≤ (1 + ε) · A − πk(A)2 F ? 3. Our results show that Ω( 1 tiplicative approximation. Can we show that sampling Ω( 1 additive approximation (see Theorem 1), Ω( 1 ε ) rows are sufficient. ε4 ) length-squared sampled rows are sufficient to obtain (1 + ε) mul- ε4 ) rows are necessary? Note that for 4. Does adaptive length-squared sampling5 give multiplicative rank-k approximation? Note that the previous work of Deshpande and Vempala [DV06] only showed additive approximation. Multiplicative approximation was shown to be achieved in subsequent work of Deshpande et al. [DRVW06] when length-squared sampling was combined with volume sampling. So the relevant question is whether length-squared sampling is sufficient for multiplicative approximation. The first two questions are simple to resolve. A simple analysis, which is also implicit in some of the previous works (e.g., [DRVW06]), gives us that a single length-squared sampled point gives a 2-factor approximation in expectation. A simple example gives a negative answer to the second question. Consider a 2-dimensional point set where all but one point have coordinates (x, 0) and the remaining point has coordinates (0, y), where x >> y. In this case, A − π2(A)2 F = 0 but any constant sized length-squared sampled set is unlikely to contain the point at (0, y). The last two questions remain open. References AFKM01. D. Achlioptas, A. Fiat, A. R. Karlin, and F. McSherry. Web search via hub synthesis. In Proceedings CW09. CW17. 42nd IEEE Symposium on Foundations of Computer Science, pages 500 -- 509, Oct 2001. Kenneth L. Clarkson and David P. Woodruff. Numerical linear algebra in the streaming model. In Proceedings of the Forty-first Annual ACM Symposium on Theory of Computing, STOC '09, pages 205 -- 214, New York, NY, USA, 2009. ACM. Kenneth L. Clarkson and David P. Woodruff. Low-rank approximation and regression in input sparsity time. J. ACM, 63(6):54:1 -- 54:45, January 2017. DFK+04. P. Drineas, A. Frieze, R. Kannan, S. Vempala, and V. Vinay. Clustering large graphs via the singular DK01. DK03. DKR02. value decomposition. Machine Learning, 56(1):9 -- 33, Jul 2004. In P. Drineas and R. Kannan. Fast monte-carlo algorithms for approximate matrix multiplication. Proceedings of the 42Nd IEEE Symposium on Foundations of Computer Science, FOCS '01, pages 452 -- , Washington, DC, USA, 2001. IEEE Computer Society. Petros Drineas and Ravi Kannan. Pass efficient algorithms for approximating large matrices. In Proceed- ings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '03, pages 223 -- 232, Philadelphia, PA, USA, 2003. Society for Industrial and Applied Mathematics. Petros Drineas, Iordanis Kerenidis, and Prabhakar Raghavan. Competitive recommendation systems. In Proceedings of the Thiry-fourth Annual ACM Symposium on Theory of Computing, STOC '02, pages 82 -- 90, New York, NY, USA, 2002. ACM. DMM06a. Petros Drineas, Michael W. Mahoney, and S. Muthukrishnan. Sampling algorithms for l2 regression and applications. In Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithm, SODA '06, pages 1127 -- 1136, Philadelphia, PA, USA, 2006. Society for Industrial and Applied Mathemat- ics. 5 Adaptive sampling means that we sample a sequence of sets S1, ..., Sk, where S1 contains length-squared sampled rows of the given matrix A, S2 contains length-squared sampled rows of the matrix A − πS1 (A), and so on. Here, πS(A) denotes the projection of the rows of matrix A onto the linear subspace spanned by elements of S. See [DV06] for a detailed discussion. 8 DMM06b. Petros Drineas, Michael W. Mahoney, and S. Muthukrishnan. Subspace sampling and relative-error matrix approximation: Column-based methods. In Josep D´ıaz, Klaus Jansen, Jos´e D. P. Rolim, and Uri Zwick, editors, Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques, pages 316 -- 326, Berlin, Heidelberg, 2006. Springer Berlin Heidelberg. DMM06c. Petros Drineas, Michael W. Mahoney, and S. Muthukrishnan. Subspace sampling and relative-error matrix approximation: Column-row-based methods. In Yossi Azar and Thomas Erlebach, editors, Algorithms -- ESA 2006, pages 304 -- 314, Berlin, Heidelberg, 2006. Springer Berlin Heidelberg. DMMS11. Petros Drineas, Michael W. Mahoney, S. Muthukrishnan, and Tam´as Sarl´os. Faster least squares approx- imation. Numerische Mathematik, 117(2):219 -- 249, Feb 2011. DRVW06. Amit Deshpande, Luis Rademacher, Santosh Vempala, and Grant Wang. Matrix approximation and DV06. FKV04. Har14. MZ11. NDT09. projective clustering via volume sampling. Theory of Computing, 2(12):225 -- 247, 2006. Amit Deshpande and Santosh Vempala. Adaptive sampling and fast low-rank matrix approximation. In Josep D´ıaz, Klaus Jansen, Jos´e D. P. Rolim, and Uri Zwick, editors, Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques, pages 292 -- 303, Berlin, Heidelberg, 2006. Springer Berlin Heidelberg. Alan Frieze, Ravi Kannan, and Santosh Vempala. Fast monte-carlo algorithms for finding low-rank approximations. J. ACM, 51(6):1025 -- 1041, November 2004. Sariel Har-Peled. Low rank matrix approximation in linear time. CoRR, abs/1410.8802, 2014. Avner Magen and Anastasios Zouzias. Low rank matrix-valued chernoff bounds and approximate matrix multiplication. In Proceedings of the Twenty-second Annual ACM-SIAM Symposium on Discrete Algo- rithms, SODA '11, pages 1422 -- 1436, Philadelphia, PA, USA, 2011. Society for Industrial and Applied Mathematics. Nam H. Nguyen, Thong T. Do, and Trac D. Tran. A fast and efficient algorithm for low-rank approximation of a matrix. In Proceedings of the Forty-first Annual ACM Symposium on Theory of Computing, STOC '09, pages 215 -- 224, New York, NY, USA, 2009. ACM. PRTV00. Christos H. Papadimitriou, Prabhakar Raghavan, Hisao Tamaki, and Santosh Vempala. Latent semantic Sar06. indexing: A probabilistic analysis. Journal of Computer and System Sciences, 61(2):217 -- 235, 2000. Tamas Sarlos. Improved approximation algorithms for large matrices via random projections. In Proceed- ings of the 47th Annual IEEE Symposium on Foundations of Computer Science, FOCS '06, pages 143 -- 152, Washington, DC, USA, 2006. IEEE Computer Society. 9
1805.06990
1
1805
2018-05-17T23:19:29
Fast Maximization of Non-Submodular, Monotonic Functions on the Integer Lattice
[ "cs.DS" ]
The optimization of submodular functions on the integer lattice has received much attention recently, but the objective functions of many applications are non-submodular. We provide two approximation algorithms for maximizing a non-submodular function on the integer lattice subject to a cardinality constraint; these are the first algorithms for this purpose that have polynomial query complexity. We propose a general framework for influence maximization on the integer lattice that generalizes prior works on this topic, and we demonstrate the efficiency of our algorithms in this context.
cs.DS
cs
Fast Maximization of Non-Submodular, Monotonic Functions on the Integer Lattice Alan Kuhnle, J. David Smith, Victoria G. Crawford, My T. Thai May 21, 2018 Abstract The optimization of submodular functions on the integer lattice has received much attention recently, but the objective functions of many applications are non- submodular. We provide two approximation algorithms for maximizing a non- submodular function on the integer lattice subject to a cardinality constraint; these are the first algorithms for this purpose that have polynomial query complexity. We propose a general framework for influence maximization on the integer lattice that generalizes prior works on this topic, and we demonstrate the efficiency of our algorithms in this context. Introduction 1 As a natural extension of finite sets S (equivalently, {0, 1}S), optimization of discrete functions on the integer lattice NS has received attention recently [Alon et al., 2012, Demaine et al., 2014, Soma and Yoshida, 2015]. As an example, consider the place- ment of sensors in a water network [Krause et al., 2008a]; in the set version, each sensor takes a value in {0, 1}, which corresponds to whether the sensor was placed. In the lat- tice version Soma and Yoshida [2015], each sensor has a power level in {0, . . . , b} ⊆ N, to which the sensitivity of the sensor is correlated. As a second example, consider the influence maximization problem [Kempe et al., 2003]; instead of the binary seeding of a user, the lattice version enables partial incentives or discounts to be used [Demaine et al., 2014]. Although many results from the optimization of submodular set functions have been generalized to the integer lattice [Soma and Yoshida, 2015, 2016, Ene and Nguyen, 2016], many objective functions arising from applications are not submodular [Bian et al., 2017b, Lin et al., 2017, Das and Kempe, 2011, Horel and Singer, 2016]. In this work, we consider maximization subject to a cardinality constraint (MCC), where the function f to be maximized may be non-submodular. Let k ∈ N (the budget), b ∈ (N ∪ {∞})S (the box), and let f : {x ∈ NS : x ≤ b} → R+ (the objective) be a non-negative and monotonic1 function with f (0) = 0. Then determine (MCC) f (w), max (cid:107)w(cid:107)1≤k 1for all v ≤ w (coordinate-wise), f (v) ≤ f (w) 1 where w = (ws)s∈S ∈ NS, (cid:107)w(cid:107)1 =(cid:80) s∈S ws. Since the integer lattice may be represented as a multiset of size kS, one may use results for Problem MCC with non-submodular set functions. In particular, the tight ra- α (1 − e−αγs ) of the standard greedy algorithm by Bian et al. [2017b], where α, γs tio 1 are discussed below, applies with the lattice adaptation of the standard greedy algorithm (StandardGreedy) given in Alg. 1. However, this approach requires Ω(Sk) queries of f, which is not polynomial in the input2 size O(S log k). Even for applications with set functions, Ω(Sk) queries may be prohibitive, and researchers [Leskovec et al., 2007, Mirzasoleiman et al., 2015, Badanidiyuru and Vondr´ak, 2014] have sought ways to speed up the StandardGreedy algorithm. Unfortunately, these approaches rely upon the submodularity of f, and there has been no analogous effort for non-submodular functions. To quantify the non-submodularity of a lattice function f, we generalize the fol- lowing quantities defined for set functions to the lattice: (1) the diminishing-return (DR) ratio γd of f [Lehmann et al., 2006], (2) the submodularity ratio γs of f [Das and Kempe, 2011], and (3) the generalized curvature α of f [Bian et al., 2017b]. Our main contributions are: • To speed up StandardGreedy (Alg. 1), we adapt the threshold greedy framework of Badanidiyuru and Vondr´ak [2014] to non-submodular functions; this yields an algorithm (ThresholdGreedy, Alg. 2) with approximation ratio (1− e−γdγs − η), (cid:0)ε2/k(cid:1)(cid:1), where Greedy algorithm is improved from Ω(nk) to O(cid:0)n log k logκ for any η > 0, the first approximation algorithm with polynomial query com- plexity for Problem MCC on the lattice. The query complexity of the Standard- κ, ε ∈ (0, 1) are parameters of ThresholdGreedy. • We introduce the novel approximation algorithm FastGreedy, which combines elements of StandardGreedy and ThresholdGreedy to improve the performance ratio to (1−e−β∗γs−η), where β∗ is at least γd and in many cases3 is determined by the algorithm. Furthermore, FastGreedy exploits the non-submodularity of the function to decrease its runtime in practice without sacrificing its perfor- mance guarantee, while maintaining the same worst-case query complexity as ThresholdGreedy up to a constant factor. • To demonstrate our algorithms, we introduce a general budget allocation prob- lem for viral marketing, which unifies submodular influence maximization (IM) under the independent cascade model [Kempe et al., 2003] with the non-submodular boosting problem [Lin et al., 2017] and in addition allows partial incentives. We prove a lower bound on the DR and submodularity ratios for this unified frame- work, and we experimentally validate our proposed algorithms in this setting. 2The input is considered to be the vector b of length n = S and the number k represented in log k bits (w.l.o.g. each component of b is at most k); the function is regarded as an oracle and hence does not contribute to input size. 3When the solution g returned by FastGreedy satisfies (cid:107)g(cid:107)1 = k. Otherwise, an upper bound on β∗ is returned. 2 Algorithm 1 StandardGreedy 1: Input: f ∈ Fb, k ∈ N, b ∈ NS 2: Output: g ∈ NS 3: g ← 0 4: for i = 1 to k do 5: 6: return g g ← g + arg maxs∈S:g+s≤b δs(g) 2 Related Work The study of optimization of submodular set functions is too extensive to give a com- prehensive overview. On the integer lattice, there have been many efforts to maximize submodular functions, e.g Soma and Yoshida [2017], Bian et al. [2017a], Gottschalk and Peis [2016]. To the best of our knowledge, we are the first to study the optimiza- tion of non-submodular functions on the integer lattice. In the following discussion, we primarily restrict our attention to the maximization of monotonic, submodular lattice functions subject to a cardinality constraint and the maximization of non-submodular set functions. Reduction of Ene and Nguyen [2016]. Ene and Nguyen [2016] have given a polynomial- time reduction from the lattice to a set that enables unified translation of submodu- lar optimization strategies to DR-submodular (i.e. DR ratio γd = 1, see Section 3) functions on the integer lattice. Since this translation is designed for DR-submodular functions, it does not give a polynomial-time algorithm for Problem MCC when f is non-submodular. Specifically, for the case of maximization subject to a cardinality constraint, Ene and Nguyen [2016] rely upon the threshold greedy algorithm for sub- modular set functions [Badanidiyuru and Vondr´ak, 2014], which does not work for non-submodular functions without modifications such as the ones in our paper. to O(cid:0) n ε log n ε Threshold Greedy and Lattice Optimization. To speed up the StandardGreedy for submodular set functions, Badanidiyuru and Vondr´ak [2014] introduced the threshold greedy framework, which speeds up the StandardGreedy algorithm for maximizing submodular set functions under cardinality constraint from O(nk) function evaluations (cid:1), and it maintains the approximation ratio (1−1/e−ε), for ε > 0. Soma and Yoshida [2016] adapted the threshold approach for efficiently maximizing DR- submodular functions on the integer lattice and provided (1 − 1/e − ε)-approximation algorithms. Other adaptations of the threshold approach of Badanidiyuru and Vondr´ak [2014] to the integer lattice include Ene and Nguyen [2016], Soma and Yoshida [2015]. To the best of our knowledge, in this work we make the first use of the threshold framework for non-submodular functions. Our ThresholdGreedy algorithm is an adaptation of the algorithm of Soma and Yoshida [2016] for DR-submodular maximization to non-submodular functions. The non-submodularity requires new analysis, in the following specific ways: (1) during the binary search phase, we cannot guarantee that we find the maximum number of 3 copies whose average gain exceeds the threshold τ; hence, we must settle for any number of copies whose average gain exceeds τ, while ensuring that the gain of adding one additional copy falls belows τ. (2) To prove the performance ratio, we require a combination of the DR ratio γd and the submodularity ratio γs. (3) The stopping condition (smallest threshold value) is different resulting from the non-submodularity; the proof this condition is sufficient requires another application of the DR ratio. Optimization of Non-Submodular Set Functions. For non-submodular set func- tions, the submodularity ratio γs was introduced by Das and Kempe [2011]; we gener- alize γs to lattice functions in Section 3, and we show the DR ratio γd ≤ γs. Bian et al. [2017b] introduced generalized curvature α of a set function, an analogous concept to the DR ratio as we discuss in Section 3. Bian et al. [2017b] extended the analy- sis of Conforti and Cornu´ejols [1984] to non-submodular set functions; together with the submodularity ratio γs, they proved StandardGreedy has tight approximation ratio α (1 − e−γsα) under cardinality constraint. 1 The DR ratio γd was introduced by Lehmann et al. [2006] for the valuation func- tions in the maximum allocation problem for a combinatorial auction; if each valuation function has DR ratio at least γd, the maximum allocation problem is a special case of maximizing a set function f with DR ratio γd over a matroid, for which Lehmann et al. [2006] employ the StandardGreedy algorithm (for matroids). Many other notions of non-submodular set functions have been introduced [Krause et al., 2008b, Horel and Singer, 2016, Borodin et al., 2014, Feige and Izsak, 2013]. For a comprehensive discussion of the relation of these and additional notions to the submodularity ratio γs, we refer the reader to Bian et al. [2017b]. 3 Non-Submodularity on the Lattice In this section, we define the lattice versions of DR ratio γd, submodularity ratio γs, and generalized curvature α, which are used in the approximation ratios proved in Section 4. Notations. For each s ∈ S, let s be the unit vector with 1 in the coordinate corre- sponding to s, and 0 elsewhere. We write δw(v) = f (v + w) − f (v) for v, w ∈ NS. Given a box in the integer lattice b ∈ NS, let the set of all non-negative, monotonic lattice functions with f (0) = 0, and domain {x ∈ NS : x ≤ b} be denoted Fb. It is often useful to think of a vector v ∈ NS as a multi-set containing vs copies of s ∈ S, where vs is the value of v's coordinate corresponding to s. We use the notation {v} to represent the multiset corresponding to the vector v. Finally, we define v ∨ w and v∧w for v, w ∈ NS to be the vector with the coordinate-wise maximum and minimum respectively. Rather than an algorithm taking an explicit description of the function f as input, we consider the function f as an oracle and measure the complexity of an algorithm in terms of the number of oracle calls or queries. We begin with the related concepts of DR ratio and generalized curvature. 4 Definition 1. Let f ∈ Fb. The diminishing-return (DR) ratio of f, γd(f ), is the maximum value in [0, 1] such that for any s ∈ S, and for all v ≤ w such that w+s ≤ b, γd(f )δs(w) ≤ δs(v). Definition 2. Let f ∈ Fb. The generalized curvature of f, α(f ), is the minimum value in [0, 1] such that for any s ∈ S, and for all v ≤ w such that w + s ≤ b, δs(w) ≥ (1 − α(f ))δs(v). The DR ratio extends the notion of DR-submodularity of Soma and Yoshida [2015], which is obtained as the special case γd = 1. Generalized curvature for set functions was introduced in Bian et al. [2017b]. Notice that α results in lower bounds on the marginal gain of s to a vector w, while γd results in upper bounds on the same quantity: (1 − α)δs(v) ≤ δs(w) ≤ 1 γd δs(v), whenever v ≤ w and the above expressions are defined. Next, we generalize the submodularity ratio of Das and Kempe [2011] to the integer lattice. Definition 3. Let f ∈ Fb. The submodularity ratio of f, γs(f ), is the maximum value in [0, 1] such that for all v, w, such that v ≤ w, γs(f )(f (w) − f (v)) ≤ (cid:88) δs(v). s∈{w−v} The next proposition, proved in Appendix C, shows the relationship between DR ratio and submodularity ratio. Proposition 1. For all f ∈ Fb, γd(f ) ≤ γs(f ). In the rest of this work, we will parameterize functions by the non-submodularity = {f ∈ Fb : ratios defined above and partition functions into the sets F γd,γs,α γd(f ) = γd, γs(f ) = γs, α(f ) = α}. Greedy versions. In the proofs of this paper, the full power of the parameters defined above is not required. It suffices to consider restricted versions, where the maximiza- tion is taken over only those vectors which appear in the ratio proofs. We define these greedy versions in Appendix B and include more discussion in Remark 1 of Section 4.1. b 4 Algorithms 4.1 The ThresholdGreedy Algorithm In this section, we present the algorithm ThresholdGreedy (Alg. 2) to approximate Problem MCC with ratio 1− e−γgγs − η with polynomial query complexity. Appendix D contains the proofs of all lemmas, claims, and omitted details from this section. 5 Description. ThresholdGreedy operates by considering decreasing thresholds for the marginal gain in its outer for loop; for each threshold τ, the algorithm adds on line 2 elements whose marginal gain exceeds τ as described below. The parameter κ ∈ (0, 1) determines the stepsize between successive thresholds; the algorithm continues until the budget k is met (line 2) or the threshold is below a minimum value dependent on the parameter ε ∈ (0, 1). Intuitively, the goal of the threshold approach [Badanidiyuru and Vondr´ak, 2014] for submodular set functions is as follows. At each threshold (i.e., iteration of the outer for loop), add all elements whose marginal gain exceeds τ to the solution g. On the lattice, adding all copies of s ∈ S whose average gain exceeds τ on line 2 would require the addition of the maximum multiple ls such that the average marginal gain exceeds τ: δls(g) ≥ lτ, (P1) as in the threshold algorithm of Soma and Yoshida [2016] for DR-submodular func- tions, in which the maximum l is identified by binary search. However, since f is not DR-submodular, it is not always the case that δs(g + ls) ≥ δs(g + (l + 1)s), for each l. For this reason, we cannot find the maximum such l by binary search. Furthermore, even if we found the maximum l for each s ∈ S, we could not guarantee that all el- ements of marginal gain at least τ were added due to the non-submodularity of f: an element whose gain is less than τ when considered in the inner for loop might have gain greater than τ after additional elements are added to the solution. ThresholdGreedy more conservatively ensures that the number l chosen for each s ∈ S satisfies both (P1) and δs(g + ls) < τ, (P2) but it is not necessarily the maximum such l. Pivot. Any l satisfying both (P1) and (P2) is termed a pivot4 with respect to g, s, τ. Perhaps surprisingly, a valid pivot can be found with binary search in O(log bmax) = O(log k) function queries, where bmax = maxs∈S bs; discussion of BinarySearch- Pivot and proof of this results is provided in Appendix D, Lemma 2. By finding a pivot for each s ∈ S, ThresholdGreedy does not attempt to add all elements exceeding the marginal gain of threshold τ; instead, ThresholdGreedy maintains the following property at each threshold. Property 1. Let gτ be the solution of ThresholdGreedy immediately after the iteration of the outer for loop corresponding to threshold τ. Then for each s ∈ S, there exists h ≤ gτ such that δs(h) < τ. Performance ratios. Next, we present the main result of this section, the perfor- mance guarantee involving the DR and submodularity ratios. Observe that the query complexity of ThresholdGreedy is polynomial in the input size O(n log k). 4For convenience, we also define the maximum value of l, lmax = min{bs − gs, k − (cid:107)g(cid:107)1} to be a pivot if lmax satisfies (P1) only, and set δs(g + lmaxs) = 0, so that all pivots satisfy both properties. 6 Algorithm 2 ThresholdGreedy 1: Input: f ∈ Fb, k ∈ N, κ, ε ∈ (0, 1). (cid:17) 2: Output: g ∈ NS 3: g ← 0, M ← maxs∈S f (s). 4: for 5: 6: 7: 8: 9: 10: return g (cid:16) τ = M ; τ ≥ κε2M for s ∈ S do l ←BinarySearchPivot(f, g, b, s, k, τ ) g ← g + ls if (cid:107)g(cid:107)1 = k then return g ; τ ← κτ do k b f (g) ≥ (cid:0)ε2/k(cid:1)(cid:1). If η > 0 is given, the assignment κ = (1 − η/2), ε = η/2 yields performance ratio Theorem 1. Let an instance of Problem MCC be given, with f ∈ F γd,γs,α . If g is the solution returned by ThresholdGreedy and Ω is an optimal solution to this instance, then (cid:0)1 − e−κγdγs − ε(cid:1) f (Ω). The query complexity of ThresholdGreedy is O(cid:0)n log k logκ at least 1 − e−γdγs − η. Proof. If γd < ε, the ratio holds trivially; so assume γd ≥ ε. The proof of the following claim requires an application of the DR ratio. Claim 1. Let g be produced by a modified version of ThresholdGreedy that continues until (cid:107)g(cid:107)1 = k. If we show f (g) ≥ (1 − e−κγdγs)f (Ω), the results follows. Thus, for the rest of the proof let g be as described in Claim 1. Let gt be the value of g after the tth execution of line 2 of ThresholdGreedy. Let lt be the tth pivot, such that gt = gt−1 + ltst. The next claim lower bounds the marginal gain in terms of the DR ratio and the previous threshold. Claim 2. For each s ∈ {Ω − gt−1 ∧ Ω}, ltγdκδs(gt−1) ≤ f (gt) − f (gt−1). Proof. Let τ be the threshold at which ltst is added to gt−1; let s ∈ {Ω − gt−1 ∧ Ω}. If τ is the first threshold, γdδs(gt−1) ≤ δs(0) ≤ τ < τ κ . If τ is not the first threshold, τ(cid:48) = τ /κ is the previous threshold value of the previous iteration of the outer for loop. By Property 1, there exists h ≤ gτ(cid:48) ≤ gt−1, such that δs(h) < τ(cid:48). By the definition of DR ratio, γdδs(gt−1) ≤ δs(h) < τ(cid:48) = τ /κ. In either case, by the fact that property (P1) of a pivot holds for lt, we have f (gt) − f (gt−1) ≥ ltτ ≥ ltγdκδs(gt−1). 7 Since Ω ≤ k, we have by Claim 2 ltγdκ f (gt) − f (gt−1) ≥ k = ltγdκ k ltγdγsκ k ltγdγsκ k ≥ ≥ s∈{Ω−(gt−1∧Ω)} s∈{Ω∨gt−1−gt−1} δs(gt−1) δs(gt−1) (cid:88) (cid:88) (cid:0)f (Ω ∨ gt−1) − f (gt−1)(cid:1) (cid:0)f (Ω) − f (gt−1)(cid:1) , (cid:16) (cid:17)(cid:17) where the equality follows from the lattice identity v∨w−v = w−v∧w for all v, w ∈ NS, the second inequality is by definition of the submodularity ratio, and the third in- 1 − ltγdγsκ equality is from monotonicity. From here, we obtain f (g) ≥ from which the hypothesis of Claim 1 follows. (cid:81)T 1 − (cid:16) t=1 k f (Ω), Query complexity. The for loop on line 2 (Alg. 2) iterates at most logκ ε2/k times; each iteration requires O(n log k) queries, by Lemma 2. For additional speedup, the inner for loop of FastGreedy may be parallelized, which divides the factor of n in the query complexity by the number of threads but worsens the performance ratio; in addition to γd, γs, the generalized curvature α is required in the proof. Corollary 1. If the inner for loop of ThresholdGreedy is parallelized, the performance ratio becomes 1 − e−(1−α)γdγs − η, for η > 0. Remark 1. A careful analysis of the usage of γd,γs in the proof of Theorem 1 shows that the full power of the definitions of these quantities is not required. Rather, it is sufficient to consider ThresholdGreedy versions of these parameters, as defined in Appendix B. In the same way, we also have FastGreedy version of γs based upon the proof of Theorem 2. The FastGreedy version of the DR ratio is an integral part of how the algorithm works and is calculated directly by the algorithm, as we discuss in the next section. 4.2 The FastGreedy Algorithm The proof of the performance ratio of ThresholdGreedy requires both the submodularty ratio γs and the DR ratio γd. In this section, we provide an algorithm (FastGreedy, Alg. 3) that achieves ratio 1 − e−β∗γs − η, with factor β∗ ≥ γd that it can determine during its execution. Appendix E provides proofs for all lemmas, claims, and omitted details. Description. FastGreedy employs a threshold framework analogous to Threshold- Greedy. Each iteration of the outer while loop of FastGreedy is analogous to an it- eration of the outer for loop in ThresholdGreedy, in which elements are added whose 8 marginal gain exceeds a threshold. FastGreedy employs BinarySearchPivot to find piv- ots for each s ∈ S for each threshold value τ. Finally, the parameter ε determines a minimum threshold value. As its threshold, FastGreedy uses τ = βκm, where m is the maximum marginal gain found on line 3, parameter κ is the intended stepsize between thresholds as in ThresholdGreedy, and β is an upper bound on the DR ratio γd, as described below. This choice of τ has the following advantages over the approach of ThresholdGreedy: (1) since the threshold is related to the maximum marginal gain m, the theoretical performance ratio is improved; (2) the use of β to lower the threshold ensures the same5 worst-case query complexity as ThresholdGreedy and leads to substantial reduction of the number of queries in practice, as we demonstrate in Section 6. FastGreedy DR ratio β∗. If FastGreedy is modified6 to continue until (cid:107)g(cid:107)1 = k, let the final, smallest value β∗ of β be termed the FastGreedy DR ratio on the instance. The FastGreedy DR ratio β∗ is at least the DR ratio γd of the function, up to the parameter δ: Lemma 1. Let parameters κ, δ, ε ∈ (0, 1) be given. Throughout the execution of FastGreedy on an instance of Problem MCC with f ∈ F γd,γs , β ≥ γdδ. Since ε can be arbitrarily small, β∗ Proof. Initally, β = 1; it decreases by a factor of δ ∈ (0, 1) at most once per iteration of the while loop. Suppose β ≤ γd for some iteration i of the while loop, and let g have the value assigned immediately after iteration i, m have the value assigned after line 3 of iteration i. Since a valid pivot was found for each s ∈ S during iteration i, by property (P2) there exists gs ≤ g, δs(gs) < βκm ≤ γdκm. Hence δs(g) ≤ κm, by the definition of DR ratio. In iteration i + 1, m(cid:48) has the value of m from iteration i, so the value of m computed during iteration i + 1 is at most κm(cid:48), and β does not decrease during iteration i + 1. ≥ γdδ. b Performance ratio. Next, we present the main result of this section. In contrast to ThresholdGreedy, the factor of γd in the performance ratio has been replaced with β∗; at the termination of the algorithm, the value of β∗ is an output of FastGreedy if the solution g satisfies (cid:107)g(cid:107)1 = k. In any case, by Lemma 1, the performance ratio is at worst the same as that of ThresholdGreedy. Theorem 2. Let an instance of Problem MCC be given, with f ∈ F γd,γs . Let g be the solution returned by FastGreedy with parameters κ, δ, ε ∈ (0, 1), and let Ω be an optimal solution to this instance; also, suppose γd ≥ ε. Let β∗ be the FastGreedy DR ratio on this instance. Then, The worst-case query complexity of FastGreedy is O(cid:0)(cid:0)logδ(γd) logκ(γd) + logκ ε2/k(cid:1) n log k(cid:1) . 1 − e−κβ∗γs − ε f (g) ≥ (cid:16) b (cid:17) f (Ω) 5Up to a constant factor, which depends on γd. 6This modification can be accomplished by setting ε to ensure the condition on line 3 is always true on this instance. 9 ← M/κ, β ← 1 if m > κm(cid:48) then Algorithm 3 FastGreedy 1: Input: f ∈ Fb, k ∈ N, κ, δ, ε ∈ (0, 1). 2: Output: g ∈ NS 3: g ← 0, M ← maxs∈S f (s), m ← M, m(cid:48) 4: while m ≥ M ε2/k do 5: m ← maxs∈S δs(g) 6: 7: 8: m(cid:48) 9: 10: 11: 12: 13: 14: 15: return g β ← βδ ← m τ ← βκm for s ∈ S do l ←BinarySearchPivot(f, g, b, s, k, τ ) g ← g + ls if (cid:107)g(cid:107)1 = k then return g 1, . . . , m(cid:48) K , . . . , m(cid:48) j(cid:96) If η > 0 is given, the assignment κ = (1 − η/2), ε = η/2 yields performance ratio at least 1 − e−β∗γs − η. Proof of query complexity. The performance ratio is proved in Appendix E. Let m(cid:48) be the sequence of m(cid:48) values in the order considered by the algorithm. By Lemma 1, m(cid:48) j > κm(cid:48) j−1 at most Γ = logδ γd times; label each such index j an uptick, and let j1, . . . , jl be the indices of each uptick in order of their appearance. Also, let ki be the first index after ji such that m(cid:48) Next, we will iteratively delete from the sequence of m(cid:48) values. Initially, let (cid:96) = l be the last uptick in the sequence; delete all terms m(cid:48) k(cid:96)−1 from the m(cid:48) se- quence. Set (cid:96) = (cid:96) − 1 and repeat this process until (cid:96) = 0. Claim 3. For each (cid:96) selected in the iterative deletion above, there are at most logκ γd values deleted from the sequence. ji−1, for each i ∈ {1, . . . , l}. ki ≤ κm(cid:48) By Claim 3 and the bound on the number of upticks, we have deleted at most logκ γd logδ γd thresholds m(cid:48) from the sequence; every term in the remaining sequence satisfies m(cid:48) j−1; hence, the remaining sequence contains at most logκ ε2/k terms, by its initial and terminal values. The query complexity follows from the number of queries per value of m(cid:48), which is O(n log k) by Lemma 2. j ≤ κm(cid:48) 5 Influence Maximization: A General Framework In this section, we provide a non-submodular framework for viral marketing on a social network that unifies the classical influence maximization [Kempe et al., 2003] with the boosting problem [Lin et al., 2017]. 10 Overview. The goal of influence maximization is to select seed users (i.e. initially activated users) to maximize the expected adoption in the social network, where the total number of seeds is restricted by a budget, such that the expected adoption in the social network is maximized. The boosting problem is, given a fixed seed set S, to incentivize (i.e. increase the susceptibility of a user to the influence of his friends) users within a budget such that the expected adoption with seed set S increases the most. Our framework combines the above two scenarios with a partial incentive: an in- centive (say, x% off the purchase price) increases the probability a user will purchase the product independently and increases the susceptibility of the user to the influence of his friends. Hence, our problem asks how to best allocate the budget between (par- tially) seeding users and boosting the influence of likely extant seeds. Both the classical influence maximization and the non-submodular boosting problem can be obtained as special cases, as shown in Appendix F. Our model is related to the formulation of Demaine et al. [2014]; however, they em- ploy a submodular threshold-based model, while our model is inherently non-submodular due to the boosting mechanism [Lin et al., 2017]. Also, GIM is related to the submod- ular budgeted allocation problem of Alon et al. [2012], in which the influence of an advertiser increases with the amount of budget allocated; the main difference with GIM is that we modify incoming edge weights with incentives instead of outgoing, which creates the boosting mechanism responsible for the non-submodularity. Model. Given a social network G = (V, E), and a product p, we define the following model of adoption. The allocation of budget to u is thought of as a discount towards purchasing the product; this discount increases the probability that this user will adopt or purchase the product. Furthermore, this discount increases the susceptibility of the user to influence from its (incoming) social connections. Formally, an incentive level xu is chosen for each user u. With independent prob- ability p(u, xu), user u initially activates or adopts the product; altogether, this creates a probabilistic initial set S of activated users. Next, through the classical Independent Cascade (IC) model7 of adoption, users influence their neighbors in the social network; wherein the weight p(v, u, xu) for edge (v, u) is determined by the incentive level xu of user u as well as the strength of the social connection from v to u. (cid:80) We write px(H, T ) to denote the probability of full graph realization H and seed set T when x gives the incentive levels for each user. We write R(H, T ) to denote the size of the reachable set from T in realization H. The expected activation in the network given a choice x of incentive levels is given by I(x) =(cid:80) where an explicit formula for px(H, T ) is given in Appendix F. Finally, let A(x) = I(x) − I(0). Definition 4 (Generalized Influence Maximization (GIM)). Let social network G = (V, E) be given, together with the mappings i (cid:55)→ p(u, i), i (cid:55)→ p(u, v, i), for all u ∈ V, (u, v) ∈ E, for each i ∈ {0, . . . , L}, where L is the number of incentive levels. Given budget k, determine incentive levels x, with (cid:107)x(cid:107)1 ≤ k, such that A(x) is maximized. T⊆V H⊆G px(H, T )R(H, T ), 7The IC model is defined in Appendix F. 11 Bound on non-submodularity. Next, we provide a lower bound on the greedy sub- modularity ratios (see Appendix B). We emphasize that the assumption that the prob- ability mappings as a function of incentive level be submodular does not imply the objective A(x) is DR-submodular. Theorem 3 is proved in Appendix F. Theorem 3. Let I be an instance of GIM, with budget k. Let ce = max(u,v)∈E,i∈L . Suppose for all (u, v) ∈ E, w ∈ V , the mappings cn = maxx∈V,i∈L i (cid:55)→ p(u, v, i), i (cid:55)→ p(w, i) are submodular set functions. Then, the greedy submodu- larity ratios defined in Appendix B and the FastGreedy DR ratio are lower bounded by c−k∆ c−k n , where ∆ is the maximum in-degree in G. e p(x,i+1) p(x,i) p(u,v,i+1) p(u,v,i) , 6 Experimental Evaluation In this section, we evaluate our proposed algorithms for the GIM problem defined in Section 5. We evaluate our algorithms as compared with StandardGreedy; by the naive reduction of the lattice to sets in exponential time, this algorithm is equivalent performing this reduction and running the standard greedy for sets, the performance of which for non-submodular set functions was analyzed by Bian et al. [2017b]. In Section 6.1, we describe our methodology; in Section 6.2, we compare the algo- rithms and non-submodularity parameters. In Appendix G.1, we explore the behavior of FastGreedy as the parameters δ, κ, and ε are varied. 6.1 Methodology Our implementation uses Monte Carlo sampling to estimate the objective value A(x), with 10 000 samples used. As a result, each function query is relatively expensive. We evaluate on two networks taken from the SNAP dataset Leskovec and Krevl [2014]: ca-GrQc ("GrQc"; 15k nodes, 14.5K edges) and facebook ("Facebook"; 4k nodes, 176K edges). Unless otherwise specified, we use 10 repetitions per datapoint and display the mean. The width of shaded intervals is one standard deviation. Stan- dard greedy is omitted from some figures where running time is prohibitive. Unless noted otherwise, we use default settings of ε = 0.05, δ = 0.9, κ = 0.95. We use a uniform box constraint and assign each user the same number of incentive levels; the maximum incentive level for a user corresponds to giving the product to the user for free and hence deterministically seeds the user; we adopt linear models for the map- pings i (cid:55)→ p(u, i), i (cid:55)→ p(u, v, i). We often plot versus K, which is defined as the maximum number of deterministic seeds; for example, if k = 200 with 10 incentive levels, then K = 20. 6.2 Results In this section, we demonstrate the following: (1) our algorithms exhibit virtually iden- tical quality of solution with StandardGreedy, (2) our algorithms query the function much fewer times, which leads to dramatic runtime improvement over StandardGreedy, 12 (a) GrQc (10 levels) (b) Facebook (100 lev- els) Figure 1: Activation A(g) for the solution returned by each algorithm. (a) GrQc (10 levels) (b) Facebook (100 lev- els) Figure 2: Total function queries on the GrQc and Facebook networks. (3) FastGreedy further reduces the number of queries of ThresholdGreedy while sac- rificing little in solution quality, and (4) the non-submodularity parameters on a small instance are computed, which provides evidence that our theoretical performance ratios are useful. Quality of Solution In Fig. 1(a), we plot A(g) for the solution returned by each algorithm on the GrQc network with 10 incentive levels; the difference in quality of solution returned by the three algorithms is negligible. In Fig. 1(b), we plot the same for the Facebook network with 100 incentive levels; on Facebook, we drop Standard- Greedy due to its prohibitive runtime. FastGreedy is observed to lose a small (up to 3%) factor, which we consider acceptable in light of its large runtime improvement, which we discuss next. Number of Queries Next, we present in Fig. 2 the number of function queries8 each algorithm requires on the GrQc and Facebook networks. StandardGreedy required up to 20M queries on Facebook, hence it is not shown in Fig. 2(b). Both of our algorithms provide a large improvement over StandardGreedy; in particular, notice that StandardGreedy increases linearly with k, while both of the others exhibit logarithmic increase in agreement with the theoretical query complexity of each. Furthermore, 8Our implementation is in terms of the marginal gain. The number of function queries shown is the number of times the marginal gain function was called. 13 20406080100K–Maximum#ofdeterministicseeds300400500600700SolutionValueFastStandardThreshold20304050K–Maximum#ofdeterministicseeds120140160180200SolutionValueFastThreshold20406080100K–Maximum#ofdeterministicseeds150200250FunctionQueries(Thousands)5010025005000FastThresholdStandard20304050K–Maximum#ofdeterministicseeds200250300FunctionQueries(Thousands)FastThreshold (a) GrQc (10 levels) (b) Facebook (100 lev- els) Figure 3: Runtime on the GrQc and Facebook networks with 100 levels. (a) GrQc (b) BA network Figure 4: (a): The value of FastGreedy DR ratio β∗ on the GrQc dataset. (b): Fast- Greedy submodularity ratio γs and FastGreedy DR Ratio β∗ on a small, random BA network. FastGreedy uses at least 14.5% fewer function queries than ThresholdGreedy and up to 43% fewer as k grows. In terms of CPU runtime, we show in Fig. 3 that FastGreedy significantly outper- forms ThresholdGreedy; hence, the runtime appears to be dominated by the number of function queries as expected. Non-Submodularity Parameters The value of the FastGreedy DR ratio β∗ on GrQc is shown in Fig. 4(a); notice that it is relatively stable as the budget increases from K = 20 to 100, although there is substantial drop from 10 incentive levels to 100; this may be explained as an increase in the non-submodularity resulting from inaccurate sampling of A, since it is more difficult to detect differences between the finer levels. Still, on all instances tested, β∗ > 0.6, which suggests the worst-case performance ratio of FastGreedy is not far from that of StandardGreedy. Finally, we examine the various non-submodularity parameters on a very small in- stance which admits their computation: a random Barabasi-Albert network with 10 nodes and 10 incentive levels. We compute the FastGreedy version of the submodular- ity ratio γs defined in Appendix B by direct enumeration and consider the FastGreedy DR ratio β∗. Results are shown in Fig. 4(b). The value of β∗ is close to 1 and remains constant with increasing budget k, while the FastGreedy submodularity ratio decreases slowly with k. With β∗ and the FastGreedy γs, we can compute the worst-case perfor- mance ratio of FastGreedy across these instances: 0.449692. 14 20406080100K–Maximum#ofdeterministicseeds102030RunningTime(Thousandsofsec.)FastStandardThreshold20304050K–Maximum#ofdeterministicseeds50100150RunningTime(Thousandsofsec.)FastThreshold20406080100K–Maximum#ofdeterministicseeds0.60.70.80.9β∗10levels100levels6810k0.000.250.500.751.00FastGreedyDRRatioβ∗FastGreedySMRatioγs 7 Conclusions In this work, we provide two approximation algorithms for maximizing non-submodular functions with respect to a cardinality constraint on the integer lattice with polynomial query complexity. Since set functions are a special case, our work provides faster al- gorithms for the same problem with set functions than the standard greedy algorithm, although the performance ratio degrades from at least 1 − e−γs to 1 − e−β∗γs, where β∗ is the FastGreedy DR Ratio. We propose a natural application of non-submodular influence maximization, for which we lower bound the relevant non-submodularity pa- rameters and validate our algorithms. 15 References Noga Alon, Iftah Gamzu, and Moshe Tennenholtz. Optimizing budget allocation among channels and influencers. Proceedings of the 21st International Conference on World Wide Web (WWW), pages 381–388, 2012. doi: 10.1145/2187836.2187888. URL http://dl.acm.org/citation.cfm?doid=2187836.2187888. Ashwinkumar Badanidiyuru and J Vondr´ak. Fast algorithms for maximizing submod- ular functions. Proceedings of the 25th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1497–1514, 2014. doi: 10.1137/1.9781611973402.110. An Bian, Kfir Y. Levy, Andreas Krause, and Algorithms. In Advances in Neural Continuous DR-submodular Maximization: Non-monotone ture ing Systems org/abs/1711.02515http://papers.nips.cc/paper/ 6652-non-monotone-continuous-dr-submodular-maximization-structure-and-algorithms. pdf. (NIPS), pages 486–496, 2017a. and Joachim M. Buhmann. Struc- Information Process- URL http://arxiv. Andrew An Bian, Joachim M. Buhmann, Andreas Krause, and Sebastian Tschiatschek. Guarantees for Greedy Maximization of Non-submodular Functions with Applica- tions. In Proceedings of the 34th International Conference on Machine Learning (ICML), 2017b. Allan Borodin, Dai Tri Man Le, and Yuli Ye. Weakly Submodular Functions. arXiv preprint arXiv:1401.6697, 2014. URL http://arxiv.org/abs/1401. 6697. Michele Conforti and G´erard Cornu´ejols. Submodular set functions, matroids and the greedy algorithm: Tight worst-case bounds and some generalizations of the Rado-Edmonds theorem. Discrete Applied Mathematics, 7(3):251–274, 1984. ISSN 0166218X. doi: 10.1016/0166-218X(84)90003-9. Abhimanyu Das and David Kempe. Submodular meets Spectral: Greedy Algorithms for Subset Selection, Sparse Approximation and Dictionary Selection. Proceedings of the 28th International Conference on Machine Learning (ICML), 2011. ISSN <null>. URL http://arxiv.org/abs/1102.3975. Erik D. Demaine, Mohammad T. Hajiaghayi, Hamid Mahini, David L. Malec, S. Raghavan, Anshul Sawant, and Morteza Zadimoghadam. How to Influence Peo- ple with Partial Incentives. Proceedings of the 23rd International Conference on World Wide Web (WWW), pages 937–948, 2014. doi: 10.1145/2566486.2568039. URL http://dl.acm.org/citation.cfm?id=2568039. Alina Ene and Huy L. Nguyen. A Reduction for Optimizing Lattice Submodular Func- tions with Diminishing Returns. arXiv preprint arXiv:1606.08362v1, 2016. Uriel Feige and Rani Izsak. Welfare Maximization and the Supermodular Degree. In Proceedings of the 4th conference on Innovations in Theoretical Computer Sci- ence (ITCS), pages 247–256, 2013. ISBN 9781450318594. doi: 10.1145/2422436. 16 2422466. URL http://dl.acm.org/citation.cfm?doid=2422436. 2422466. Corinna Gottschalk and Britta Peis. Submodular Function Maximization over Dis- arXiv preprint arXiv:1505:05423, 2016. URL tributive and Integer Lattices. http://arxiv.org/abs/1505.05423. Thibaut Horel and Yaron Singer. Maximization of Approximately Submodular Func- tions. In Advances in Neural Information Processing Systems (NIPS), 2016. David Kempe, Jon Kleinberg, and ´Eva Tardos. Maximizing the spread of influ- In Proceedings of the 9th ACM SIGKDD In- ence through a social network. ternational Conference on Knowledge Discovery and Data Mining (KDD), pages 137–146, 2003. ISBN 1581137370. doi: 10.1145/956755.956769. URL http: //portal.acm.org/citation.cfm?doid=956750.956769. Andreas Krause, Jure Leskovec, Carlos Guestrin, Jeanne M. VanBriesen, and Chris- tos Faloutsos. Efficient sensor placement optimization for securing large water Journal of Water Resources Planning and Management, distribution networks. 134(6):516–526, 2008a. ISSN 0733-9496/2008/6-516526. doi: 10.1061/(ASCE) 0733-9496(2008)134:6(516). URL http://ascelibrary.org/doi/abs/ 10.1061/(ASCE)0733-9496(2008)134:6(516). Andreas Krause, Ajit Singh, and Carlos Guestrin. Near-Optimal Sensor Placements in Gaussian Processes: Theory, Efficient Algorithms and Empirical Studies. In Journal of Machine Learning Research, volume 9, pages 235–284, 2008b. ISBN 1390681139. doi: 10.1145/1102351.1102385. Benny Lehmann, Daniel Lehmann, and Noam Nisan. Combinatorial auctions with decreasing marginal utilities. Games and Economic Behavior, 55(2):270–296, 2006. ISSN 08998256. doi: 10.1016/j.geb.2005.02.006. Jure Leskovec and Andrej Krevl. SNAP Datasets: Stanford large network dataset col- lection. http://snap.stanford.edu/data, June 2014. Jure Leskovec, Andreas Krause, Carlos Guestrin, Christos Faloutsos, Jeanne Van- Briesen, and Natalie Glance. Cost-effective Outbreak Detection in Networks. In Proceedings of the 13th ACM SIGKDD International Conference on Knowledge Dis- covery and Data Mining (KDD), pages 420–429, 2007. ISBN 978-1-59593-609-7. doi: 10.1145/1281192.1281239. URL http://eprints.pascal-network. org/archive/00005342/. Yishi Lin, Wei Chen, and John C.S. Lui. Boosting information spread: An algorith- mic approach. Proceedings of the International Conference on Data Engineering (ICDE), pages 883–894, 2017. ISSN 10844627. doi: 10.1109/ICDE.2017.137. Baharan Mirzasoleiman, Ashwinkumar Badanidiyuru, Amin Karbasi, Jan Vondrak, In Proceedings of the Twenty- and Andreas Krause. Lazier Than Lazy Greedy. Ninth AAAI Conference on Artificial Intelligence (AAAI), pages 1812–1818, 2015. ISBN 9781577357018. URL http://arxiv.org/abs/1409.7938. 17 Tasuku Soma and Yuichi Yoshida. A Generalization of Submodular Cover via the Diminishing Return Property on the Integer Lattice. Advances in Neural Information Processing Systems (NIPS), 2015. ISSN 10495258. Tasuku Soma and Yuichi Yoshida. Maximizing Monotone Submodular Functions over the Integer Lattice. In Quentin Louveaux and Martin Skutella, editors, Integer Pro- gramming and Combinatorial Optimization, pages 325–336, Cham, 2016. Springer International Publishing. ISBN 978-3-319-33461-5. URL http://arxiv.org/ abs/1503.01218. Tasuku Soma and Yuichi Yoshida. Non-monotone DR-Submodular Function Maxi- mization. In Proceedings of the Thirty-First AAAI Conference on Artificial Intelli- gence (AAAI), pages 898–904, 2017. 18 A Organization of the Appendix Appendix B defines the greedy versions of the non-submodularity parameters. Appendix C provides omitted proofs from Section 3. Appendix D defines the BinarySearchPivot procedure and omitted proofs from Sec- tion 4.1. Appendix E provides omitted proofs from Section 4.2. Appendix F defines the Independent Cascade model, proves that classical IM and boosting are subproblems of our IM model, and provides the proof of Theorem 3 from Section 5. Appendix G provides additional experimental results characterizing the parameters of FastGreedy. Appendix H presents details of our GIM implementation. B Greedy Versions of Non-Submodularity Parameters We define various greedy versions of the non-submodularity parameters in this section. In this work, these are referred to as FastGreedy submodularity ratio, etc., where the instance is clear from the context. ThresholdGreedy DR ratio. Definition 5 (ThresholdGreedy DR ratio). Let an instance I of Problem MCC be given, with budget constraint k. Let g1, . . . , gT be the sequence of values g takes during execution of ThresholdGreedy on I. The ThresholdGreedy version of the DR ratio on I γTG,I (f ) ∈ [0, 1], is the maximum value such that for any i ∈ {1, . . . , T}, for any s ∈ S, if gi,s is the value of the greedy vector immediately after s was consid- ered during the inner for loop of the threshold directly preceding the one in which gi was considered (gi,s = 0 if gi was considered during the first threshold), d γTG,I d δs(gi) ≤ δs(gi,s). Greedy versions of submodularity ratio. Definition 6. Let A ∈ {StandardGreedy, ThresholdGreedy}, and let an instance I of Problem MCC be given, with budget constraint k. Let g1, . . . , gT be the sequence of values g takes during execution of A on I. The A version of the submodularity ratio on I γA,I ∈ [0, 1], is the maximum value such that for any s ∈ S, for any i ∈ {1, . . . , T}, for any w such that gi ≤ w and (cid:107)w − gi(cid:107)1 ≤ k and w ≤ b, s (cid:2)f (w) − f (gi)(cid:3) ≤ γA,I s (cid:88) δs(gi). s∈{w−gi} The FastGreedy submodularity ratio differs from the above two only in that the sequence of vectors g1, . . . , gT are the value of the greedy vector g at the beginning of each iteration of the outer while loop, instead of all values of g during execution of the algorithm. 19 return lt Algorithm 4 BinarySearchPivot(f, g, b, s, k, τ ) 1: Input: f ∈ Fb, g ∈ NS, b ∈ NS, s ∈ S, k ∈ N, τ ∈ R+ 2: Output: l ∈ N 3: ls ← 1, lt ← min{bs − gs, k − (cid:107)g(cid:107)1}, 4: if δlts(g) ≥ ltτ then 5: 6: if δs(g) < τ then 7: 8: while lt (cid:54)= ls + 1 do 9: m = (cid:98)(lt + ls)/2(cid:99) if δms(g) ≥ mτ then 10: ls = m 11: else 12: 13: 14: return ls return 0 lt = m C Proofs for Section 3 Proof of Proposition 1. Suppose v ≤ w ∈ NS. Let {w − v} = {s1, ..., sl}. Then, l(cid:88) [f (v + s1 + ... + si) − f (v + s1 + ... + si−1)] l(cid:88) l(cid:88) γd(f (w) − f (v)) = γd δsi(v + s1 + ... + si−1) = γd i=1 i=1 δsi(v) ≤ i=1 Therefore, γd ≤ γs, since γs is the maximum number satisfying the above inequality. D BinarySearchPivot and Proofs for Section 4.1 (Thresh- oldGreedy) BinarySearchPivot. The routine BinarySearchPivot (Alg. 4) efficiently finds a pivot for each s ∈ S. BinarySearchPivot uses a modified binary-search procedure that main- tains ls < lt such that both δlss(g) ≥ lsτ, δlts(g) < ltτ. (1) (2) Initially, ls and lt do satisfy (1), (2), or else we have already found a valid pivot (lines 4, 4). The midpoint m of the interval [ls, lt] is tested to determine if ls or lt should be updated to maintain (1), (2); this process continues until lt = ls + 1. 20 Lemma 2. BinarySearchPivot finds a valid pivot l ∈ {0, . . . , lmax} in O(log lmax) queries of f, where lmax = min{bs − gs, k − (cid:107)g(cid:107)1}, bmax = maxs∈S bs. Proof of Lemma 2. The routine BinarySearchPivot maintains inequalities (1), (2), it is enough to show that given (1), (2), there exists a l ∈ {ls, ..., lt − 1} such that l is a pivot. Consider lj = lt − j, for j ∈ N; there must be a smallest j ≥ 1 such that lj satisfies property (P1) of being a pivot, since ls < lt satisfies property (P1). If property (P2) is unsatisfied, then δ(lj +1)ei(s) = δi(s + lj) + δlj ei (s) ≥ τ + ljτ = (lj + 1)τ, contradicting the choice of j since lj + 1 = lj−1. The query complexity follows from a constant number of queries per iteration of the while loop and the fact that each iteration reduces the distance from ls to lt by a factor of 2; initially, this distance was lmax. Omitted proofs from Section 4.1. Proof that Property 1 holds. Let gτ,s be the value of g immediately after s is consid- ered during the iteration corresponding to τ; then property (P2) of pivot was satisfied: δs(gτ,s) < τ. Proof of Claim 1. Suppose γd ≥ ε. Suppose (cid:107)g(cid:107)1 < k, and let g(cid:48) be the solution returned by a modified ThresholdGreedy that continues updating the threshold until (cid:107)g(cid:48) } \ {g} = {s1, . . . , s(cid:96)}, and let g(cid:48) i−1 + si, i = 1, . . . , (cid:96), with g(cid:48) (cid:96) = g(cid:48). Also, let gi−1 ≤ g be the vector guaranteed for si by Lemma 1 with the last threshold value τ of ThresholdGreedy. Then (cid:107)1 = k. Order {g(cid:48) 0 = g, so that g(cid:48) i = g(cid:48) δsi(g(cid:48) i−1) (cid:96)(cid:88) (cid:96)(cid:88) i=1 1 γd f (g(cid:48)) − f (g) = ≤ δsi (gi−1) i=1 ε2M k ≤ εM ≤ εf (Ω). (cid:96) ε ≤ f (g(cid:48)) ≥ Φf (Ω), Hence, for any Φ > ε, if then From proof of Theorem 1: f (g) ≥ (Φ − ε)f (Ω). 21 If γd < ε, the ratio holds trivially from the "If γd < ε, the ratio holds trivially". inequality 1 − e−x ≤ x, for real x > 0, since "from which the hypothesis of Claim 1 follows". Since (1−x) ≤ e−x and(cid:80) (cid:81)T k, we have(cid:81)T t=1 exp((−ltγdγsκ/k)) = exp(−γdγsκ). 1 − e−γdγsκ ≤ γdγsκ < ε. t=1(1 − ltγdγsκ/k) ≤ t lt = Let gt i = gt Proof of Corollary 1. As in proof of Theorem 1, suppose γd ≥ ε. Claim 1 still holds as before. Now, let gt be the value of g at the beginning of the tth iteration of the outer for loop with threshold value τt. Since the inner for loop is conducted in parallel, all marginal gains in iteration t are considered with respect to gt. Order the vectors added in this iteration l1s1, . . . , l(cid:96)s(cid:96); because each li is a pivot, we know δlisi(gt) ≥ liτt and δsi(gt + lisi) < τt. (cid:96) = gt+1. Now for each i and for each s ∈ i = gt−1 + l∗si, i = 0 if t = 1 is S, there exists a vector hs i ) < τt/κ (namely hs from when si was considered during the previous iteration t − 1, or hs the first iteration). Furthermore gt ≤ gt δlisi(gt i ) ≥ κ(1− α)liγdδs(gt i), for any s ∈ S. The preceding argument proves an analogue of Claim 2, and the argument from here is exactly analogous to the proof of Theorem 1. i) ≥ (1− α)δlisi(gt) ≥ (1− α)liτt ≥ κ(1− α)liδs(hs i and δlisi(gt) ≥ liτt. Hence i ≤ gt such that δs(hs i−1 + lisi, so gt 0 = gt and gt E Proofs for Section 4.2 Proof of Theorem 2. Since we have included γd ≥ ε as a hypothesis, we have the following claim, analogous to Claim 1. Claim 4. If g is produced by the modified version of FastGreedy that continues until (cid:107)g(cid:107)1 = k, and f (g) ≥ (1 − e−κβ∗γs)f (Ω), then the Theorem is proved. Proof. Suppose (cid:107)g(cid:107)1 < k, and let g(cid:48) be the solution returned by a FastGreedy* which continues updating the threshold until (cid:107)g(cid:48) (cid:107)1 = k. Order {g(cid:48) } \ {g} = {s1, . . . , s(cid:96)}, and let g(cid:48) i−1 + si, i = 1, . . . , (cid:96), with g(cid:48) (cid:96) = g(cid:48). Then 0 = g, so that g(cid:48) (cid:96)(cid:88) (cid:96)(cid:88) f (g(cid:48)) − f (g) = i = g(cid:48) δsi(g(cid:48) i−1) i=1 Hence, for any Φ > ε, if 1 γd ≤ δsi (g) i=1 ε2M k ≤ εM ≤ εf (Ω). (cid:96) ε ≤ f (g(cid:48)) ≥ Φf (Ω), 22 then f (g) ≥ (Φ − ε)f (Ω). 1, . . . , l(cid:96)s(cid:48) m−1 + lms(cid:48) Thus, for the rest of the proof, let g be produced by the modified version of Fast- Greedy as in the hypothesis of Claim 4. Let st ∈ S, gt be the direction maximiz- ing the marginal gain on line 3, the solution g immediately after the tth iteration of the while loop, respectively. By the choice of st, for each s ∈ {Ω}, we have δs(gt−1) ≤ δst (gt−1). Let l1s(cid:48) m. Let Lt =(cid:80)(cid:96) (cid:96) be the additions on line 3 to the solution g during iteration t, with each lm > 0 for m = 1, . . . , (cid:96). Let gt−1 0 = gt−1 and m = gt−1 gt−1 m=1 lm. Now, lm was chosen by BinarySearch- (gt−1 m−1) ≥ lmβκδst(gt−1) by property (P1) of pivot Pivot and hence satisfies δlms(cid:48) and the choice of threshold τ = βκm. So (cid:96)(cid:88) (cid:96)(cid:88) f (gt) − f (gt−1) = m ) − f (gt−1 f (gt−1 m−1) m=1 m lmβκδst(gt−1) ≥ = Ltβκδst(gt−1) m=1 (cid:88) (cid:0)f (Ω) − f (gt−1)(cid:1) , s∈{Ω−(gt−1∧Ω)} δs(gt−1) k Ltβ∗κ k Ltβ∗γsκ ≥ ≥ 1 − (cid:32) f (g) ≥ (cid:19)(cid:33) Ltβ∗γsκ where the first inequality is by definition of gt m, the first inequality is by the preceding paragraph, the second equality is by definition of Lt, the second inequality is by the selection of st and that fact (cid:107)Ω(cid:107)1 ≤ k, and the third inequality is by the definition of submodularity ratio and the lattice identity v ∨ w − v = w − v ∧ w. From here, (cid:18) T(cid:89) from which the hypothesis of Claim 4 follows: since (1 − x) ≤ e−x and(cid:80) (cid:81)T we have(cid:81)T t=1 exp((−Ltβ∗γsκ/k)) = exp(−β∗γsκ). t=1(1 − Ltβ∗γsκ/k) ≤ Proof of Claim 3. For any i, m(cid:48) i−1/γd: to see this, observe m(cid:48) i ≤ m(cid:48) i = maxs∈S δs(gi), m(cid:48) i−1 = maxs∈S δs(gi−1), for some gi−1 ≤ gi. For each s ∈ S, δs(gi−1) ≤ m(cid:48) i−1, so δs(gi) ≤ m(cid:48) i. Since j(cid:96) is the last uptick in the sequence before the deletion, we know for every i > j(cid:96), m(cid:48) i−1. Hence the deleted se- j(cid:96) by definition of m(cid:48) quence proceeds from m(cid:48) (cid:96)/γd down to m(cid:48) , k(cid:96) with each term decreasing by a factor of at least κ. i−1/γd, and hence so is m(cid:48) i ≤ κm(cid:48) k(cid:96)−1 ≥ κm(cid:48) j(cid:96)+1 ≤ m(cid:48) t Lt = k, 1 − f (Ω), t=1 k 23 F Influence Maximization: A General Framework "explicit formula for px(H, T )". px(H, T ) = P r(Hx)P r(Tx), with P r (Hx) = P r (Tx) = y∈V (cid:89) (cid:89) p(y, xy)I(y∈T )(1 − p(y, xy))I(y(cid:54)∈T ). (x,y)∈E p(x, y, xy)I((x,y)∈H)(1 − p(x, y, xy))I((x,y)(cid:54)∈H), The Independent Cascade (IC) Model. The IC model is defined as follows. Given a graph G = (V, E), with probabilities p(e) associated to each edge e ∈ E. Let H be a realization of G, where each edge e is included in H with probability p(e). Then, from an initial seed set T of activated users, a user is activated if it is reachable in H from T . Intuitively, the weight on edge (u, v) represents the probability that u activates v (i.e user u convinces v to adopt the product). For more information, we refer the reader to Kempe et al. [2003]. Proposition 2. There is a natural one-to-one correspondence between instances of the IM problem under IC model and a subclass of instances of GIM. Proof of Proposition 2. With exactly two levels, our GIM can encapsulate the classical IM problem with the IC model [Kempe et al., 2003]. Let weighted social network G = (V, E) and budget k be given, as an instance of the IM problem. This instance corresponds to one of GIM with the same network and budget, as follows. For each edge (u, v) ∈ E, let w(u, v) be its weight. Then we assign p(u, v, i) = w(u, v) for each i ∈ {0, 1}. Each incentive vector x is a binary vector, indicating which users are present in the seed set; i.e. p(u, 0) = 0 and p(u, 1) = 1, for all u ∈ V . This mapping is injective and hence invertible. Proposition 3. There is a natural one-to-one correspondence between instances of the boosting problem and a subclass of instances of GIM. Proof of Proposition 3. Let social network G = (V, E), seed set S, and k ∈ N be given as an instance of the boosting problem, where edge (u, v) ∈ E has weight p(u, v) if v is not boosted, and weight p(cid:48)(u, v) if v is boosted. The corresponding instance of GIM has two levels. Set p(y, 0) = p(y, 1) = 1 for all y ∈ S and set p(y, 0) = p(y, 1) = 0 for all y (cid:54)∈ S. For each edge (u, v) ∈ E, set p(u, v, 0) = p(u, v), p(u, v, 1) = p(cid:48)(u, v). Hence, spending budget to incentivize a node from level 0 to level 1 does not affect the initial seed set, which is always S. But this incentive does work in exactly the same way as the boosting of a node by changing its incoming edge probabilities; hence, the objective values are the same. This mapping is injective and hence invertible. Proof of Theorem 3. c−k Claim 5. Suppose γδs(w) ≤ δs(v), where γ = c−k∆ n , and v, w are any vectors satisfying v ≤ w, (cid:107)v(cid:107)1 ≤ k, and (cid:107)w − v(cid:107)1 ≤ k. Then the result of Theorem 3 follows. e Proof. Suppose the hypothesis of the claim holds. 24 , where γA,I Greedy submodularity ratios. We will show γ ≤ γA,I is the Fast- Greedy submodularity ratio on instance I. The proofs for the other greedy submodu- larity ratios are exactly analogous. Let {w − v} = {s1, ..., sl}. Then v +(cid:80)l Let g1, . . . , gT be the greedy vectors in the definition of FastGreedy submodularity ratio. Let i ∈ {1, . . . , T}, and let v = gi. Let w ≥ v ∈ NS such that (cid:107)w − v(cid:107)1 ≤ k. v +(cid:80)m j=1 sj = w. In addition, for every m ≤ l, j=1 sj = vm where vm ∈ NS, vm ≤ w. Then, s s γ(f (w) − f (v)) = γ f (v + s1 + ... + sj) − f (v + s1 + ... + sj−1) δsj (v + s1 + ... + sj−1) δsj (vj−1) j=1 l(cid:88) l(cid:88) l(cid:88) l(cid:88) j=1 j=1 j=1 = γ = γ ≤ δsj (v), by the hypothesis of the claim. Therefore γ ≤ γA,I number satisfying the above inequality for each w, gi as above. s , since the latter is the maximum FastGreedy DR ratio β∗. Initally, β = 1; it decreases by a factor of δ ∈ (0, 1) at most once per iteration of the while loop of FastGreedy. Suppose β ≤ γ for some iteration i of the while loop, and let g have the value assigned immediately after iter- ation i, m have the value assigned after line 3 of iteration i. Then Since a valid pivot was found for each s ∈ S during iteration i, by property (P2) there exists gs ≤ g, δs(gs) < βκm ≤ γκm. Hence δs(g) ≤ κm, since g, gs are vectors satisfying the conditions on γ in the hypothesis of the claim. In iteration i + 1, m(cid:48) has the value of m from iteration i, so the value of m computed during iteration i + 1 is at most κm(cid:48), and β does not decrease during iteration i. It follows that β∗ ≥ γδ. Let v ≤ w, (cid:107)v − w(cid:107)1 ≤ k. We will consider graph realizations H that have the Then, status of all edges determined; and seed sets T ⊆ V . pw+s(H, T ) = K1(H, T )pv+s(H, T ), and pw(H, T ) = K2(H, T )pv(H, T ), (3) (4) 25 where K1(H, T ) = K1(H)K1(T ), K2(H, T ) = K2(H)K2(T ) with (cid:18) p(x, y, wy) (cid:89) (cid:18) p(x, wx) (cid:89) (cid:19)I((x,y)∈H)(cid:18) 1 − p(x, y, wy) (cid:19)I(x(cid:54)∈T ) (cid:19)I(x∈T )(cid:18) 1 − p(x, wx) 1 − p(x, y, vy) p(x, y, vy) (x,y)∈E , x∈V p(x, vx) 1 − p(x, vx) K2(H) = K2(T ) = (cid:19)I((x,y)(cid:54)∈H) , and the definitions of K1(H), K1(T ) are analogous to the above with vectors v + s, w + s in place of v, w. Lemma 3. Let ∆ be the maximum in-degree in G. e ck K1(H, T ) ≤ K2(H, T ) ≤ ck∆ n Proof. (a) K1(T ) ≤ K2(T ): if s ∈ T , K1(T ) = K2(T ) · = K2(T ) · p(s, ws + 1) p(s, vs + 1) p(s, vs) p(s, ws) · z(cid:48) + α(cid:48) z z + α ≤ K2(T ), z(cid:48) · where α(cid:48) by monotonicity of the same mapping. Otherwise, if s (cid:54)∈ T , ≤ α by DR-submodularity of i (cid:55)→ p(s, i), and p(s, vs) = z ≤ z(cid:48) = p(s, ws) K1(T ) = K2(T ) · = K2(T ) · 1 − p(s, ws + 1) 1 − p(s, vs + 1) 1 − p(s, vs) 1 − p(s, ws) · − α(cid:48) z(cid:48) z z − α ≤ K2(T ), z(cid:48) · where as before α(cid:48) p(s, ws). ≤ α by DR-submodularity, but 1 − p(s, vs) = z ≥ z(cid:48) = 1 − (b) K1(H) ≤ K2(H): if (u, s) ∈ H, K1(H) = K2(H) · = K2(H) · p(u, s, ws + 1) p(u, s, vs + 1) p(u, s, vs) p(u, s, ws) · z(cid:48) + α(cid:48) z z + α ≤ K2(H), z(cid:48) · where α(cid:48) p(u, s, ws) by monotonicity of the same mapping. Otherwise, if (u, s) (cid:54)∈ H, ≤ α by DR-submodularity of i (cid:55)→ p(u, s, i), and p(u, s, vs) = z ≤ z(cid:48) = K1(H) = K2(H) · 1 − p(u, s, ws + 1) 1 − p(u, s, vs + 1) 1 − p(u, s, vs) 1 − p(u, s, ws) · z z(cid:48) · − α(cid:48) z(cid:48) z − α ≤ K2(H), = K2(H) · ≤ α by DR-submodularity, but 1 − p(u, s, vs) = z ≥ z(cid:48) = where as before α(cid:48) 1 − p(u, s, ws). 26 (c) K2(H, T ) ≤ ck∆ n: e ck K2(H, T ) = K2(H)K2(T ) = (cid:89) (x,y)∈E (cid:18) p(x, y, wy) p(x, y, vy) (cid:19)I((x,y)∈H)(cid:18) 1 − p(x, y, wy) (cid:18) p(x, wx) 1 − p(x, y, vy) (cid:89) (cid:19)I((x,y)(cid:54)∈H) (cid:19)I(x∈T )(cid:18) 1 − p(x, wx) x∈V p(x, vx) 1 − p(x, vx) (cid:19)I(x(cid:54)∈T ) Each of the fractions in the above product is of the form ξ(wy)/ξ(vy), where wy ≥ vy and hence can be written wy−vy(cid:89) i=1 ξ(wy) ξ(vy) = ξ(vy + i + 1) ξ(vy + i) ≤ (wy − vy) max j ξ(j + 1) ξ(j) . Hence, by the fact that (cid:107)w − v(cid:107)1 ≤ k and the definitions of ce, cn, and the maximum in-degree ∆ in G, we have K2(H, T ) ≤ ck∆ e ck n. Finally, by Lemma 3, we have A(w + s) − A(w) = (cid:88) (cid:88) (cid:88) H,T H,T H,T = ≤ (cid:0)pw+s(H, T ) − pw(H, T )(cid:1) R(H, T ) (cid:0)K1(H, T )pv+s(H, T ) − K2(H, T )pv(H, T )(cid:1) R(H, T ) K2(H, T )(cid:0)pv+s(H, T ) − pv(H, T )(cid:1) R(H, T ) ≤ ce k∆ck n (A(v + s) − A(v)) . Therefore, the hypothesis of Claim 5 is satisfied, and the result follows. G Additional Experimental Results G.1 Characterizing the Parameters of FastGreedy In this section, we evaluate the impact of varying the parameters of FastGreedy: ε, δ, and κ. We note that ε only impacts the running time and performance if it is used as a stopping condition. However, in our experiments this did not occur: the cardinality constraint was reached first. Therefore, in our experiments FastGreedy = FastGreedy* and we are free to set ε = 0 without changing any of our results. Figures 5 & 6 show the impact of δ & κ on performance and running time. Note that performance remains similar until κ or δ drops below 0.6. However, the running time plummets to nearly half of what it is at 0.95 in each case, resulting in a similar-quality solution in significantly less time. A natural follow-up question from this figures is: 27 (a) κ (b) δ Figure 5: Performance as δ and κ are varied. Note that ThresholdGreedy does not use δ. (a) κ (b) δ Figure 6: Running time as δ and κ are varied. Note that ThresholdGreedy does not use δ. (a) Solution Quality (b) Running Time Figure 7: Performance and running time of FastGreedy as κ and δ are simultaneously varied. 28 0.20.40.60.8κ200250300SolutionValueFastThreshold0.20.40.60.8δ200250300SolutionValueFastThreshold0.20.40.60.8κ1000200030004000RunningTime(s)FastThreshold0.20.40.60.8δ200030004000RunningTime(s)FastThreshold0.050.150.250.350.450.550.650.750.850.95δ0.950.850.750.650.550.450.350.250.150.05κ501001502002503000.050.150.250.350.450.550.650.750.850.95δ0.950.850.750.650.550.450.350.250.150.05κ6001200180024003000 what happens when both parameters are varied at once? Fig. 7 details the answer. In particular, we note that the steep drop in running time remains present, and there is a reasonable gain to be had by dropping both parameters at once – up to a point. We further notice some interesting patterns in these heat-maps. When κ is near 0, the selection of δ does not appear to matter. This is likely due to the role each parameter plays: κ plays a critical role in identifying a DR-violation, at which point δ is the rate by which β is reduced to compensate. When κ is small, it takes commensurately larger violations for δ to apply. These larger violations are not seen in our simulations, and thus δ has no impact when κ is very small. H Implementation Notes The facebook dataset originally is undirected; we replace each edge u ↔ v with two edges u → v and v → u. We calculated the FastGreedy ratio using the values κ = 0.95, β∗ = 0.9, γs = 0.69857, ε = 0. The values of κ and ε are taken from the parameters used to run the algorithm (ε can be 0 since the algorithm always returned g with (cid:107)g(cid:107)1 = k), and the values of β∗ and γs are the minimum over all instances where FastGreedy Submodularity Ratio was computed. H.1 Evaluating δs(g) As mentioned in Section 6, we evaluate the objective on a set of 10,000 Monte Carlo samples. However, for performance reasons we do not evaluate the marginal gain δs(g) directly by computing each of f (g + s) and f (g) and then subtracting. Instead, we compute the expected number of activations across the sample set were s to be added. We accomplish this as follows. First, we mantain a state associated with the vector g. This state contains a number of variables for logging purposes, in addition to two of note for our discussion here: samples and active. The former is the list of sampled graphs, each represented as a pair of vectors of floating point numbers corresponding to random thresholds assigned to each node and edge. The latter is a list of sets of nodes currently active in each sam- pled graph under solution vector g. These active sets are computed only when a new element (or elements) are added to the solution vector and are computed directly by (a) computing the set of externally activated nodes by checking if the random threshold is sufficient to activate the node; then (b) propagating across any active edges according to their thresholds. The code for this is contained in the active nodes function of src/bin/inf.rs in the code distribution. Given this representation, to estimate the marginal gain of (cid:96) copies of a node s on each sample Si as follows: 1. Check if the node is already active on Si. If so, return 0 for this sample. 2. Check if the node would be externally activated if added to the solution. If not, return 0. 29 3. Check if the node would be activated by neighboring nodes if added to the solu- tion. If not, return 0. 4. Compute the set of nodes that would be newly activated if s becomes active via breadth-first-search from s. Return this number c. Each would-be-activated check is accomplished by comparing the activation probabil- ity of the node or edge to the random threshold associated with it in the sample. Then the expected marginal gain is the average result across all samples Si. When an el- ement (with multiplicity) is chosen to be inserted into the solution, we add it to the solution vector, discard and recompute all samples, and then recompute the active set on each sample from scratch. This is in line with prior Monte-Carlo-based solutions for IM Kempe et al. [2003]. While in theory it is possible to consider the marginal gain of an arbitrary vec- tor v, in our implementation we restrict the values it can take to v = (cid:96)s, where s is the unit vector for node s. This simplifies each of the steps above. The imple- mentation of the above is contained in the functions delta and scaled delta in src/bin/inf.rs. 30
1704.06818
2
1704
2017-10-11T05:54:56
Adaptive Cuckoo Filters
[ "cs.DS" ]
We introduce the adaptive cuckoo filter (ACF), a data structure for approximate set membership that extends cuckoo filters by reacting to false positives, removing them for future queries. As an example application, in packet processing queries may correspond to flow identifiers, so a search for an element is likely to be followed by repeated searches for that element. Removing false positives can therefore significantly lower the false positive rate. The ACF, like the cuckoo filter, uses a cuckoo hash table to store fingerprints. We allow fingerprint entries to be changed in response to a false positive in a manner designed to minimize the effect on the performance of the filter. We show that the ACF is able to significantly reduce the false positive rate by presenting both a theoretical model for the false positive rate and simulations using both synthetic data sets and real packet traces.
cs.DS
cs
Adaptive Cuckoo Filters Michael Mitzenmacher1, Salvatore Pontarelli2, and Pedro Reviriego3 1 Harvard University, 33 Oxford Street, Cambridge, MA 02138, USA., [email protected] 2Consorzio Nazionale Interuniversitario per le Telecomunicazioni (CNIT), Via del Politecnico 1, 00133 Rome, Italy., [email protected] 3Universidad Antonio de Nebrija, C/ Pirineos, 55, E-28040 Madrid, Spain., [email protected] October 12, 2017 Abstract We introduce the adaptive cuckoo filter (ACF), a data structure for approximate set membership that extends cuckoo filters by reacting to false positives, removing them for future queries. As an example appli- cation, in packet processing queries may correspond to flow identifiers, so a search for an element is likely to be followed by repeated searches for that element. Removing false positives can therefore significantly lower the false positive rate. The ACF, like the cuckoo filter, uses a cuckoo hash table to store fingerprints. We allow fingerprint entries to be changed in response to a false positive in a manner designed to minimize the effect on the performance of the filter. We show that the ACF is able to sig- nificantly reduce the false positive rate by presenting both a theoretical model for the false positive rate and simulations using both synthetic data sets and real packet traces. 1 Introduction Modern networks need to classify packets at high speed. A common function in packet processing is to check if a packet belongs to a set S. As a simple example, if the source of the packet is on a restricted list, the packet should be subject to further analysis. In some applications, the cost of such a check can be beneficially reduced via an approximate membership check that may produce false positives but not false negatives; that is, it may with small probability say an element is in a set even when it is not. We first use the approximate 1 membership check, and if we are told the element is not in the set we can safely continue regular processing. On a positive response a more expensive full check may be done to find the false positives, removing them from further analysis. Packets with a source on the restricted list are always correctly identified. This approach speeds the common case by storing the approximate representation of the set S in a small fast memory, and the exact representation of S in a bigger but slower memory that is accessed infrequently. The well known example of a data structure for approximate set membership is the Bloom filter [1], which is widely used in networking applications. Many variants and enhancements for Bloom filters have been proposed [2]. There are other data structures that also provide approximate membership checks with improved performance, such as the recently proposed cuckoo filter [3] that stores fingerprints of the elements in a suitable cuckoo table [4], as we describe in more detail in Section 2. A key parameter for such data structures is the false positive probability, which gives the probability that an element not in the set yields a false positive. A slightly different quantity is the false positive rate, which gives the fraction of false positives for a given collection of queries (or, in some settings, for a given distribution of the input queries). If an element that gives a false positive is queried for many times, the false positive rate may be much higher than the false positive probability, even though in expectation over suitably randomly chosen hash functions the false positive rate should be close to the false positive probability. In many network applications, the queried elements are repeated. For ex- ample, let us consider an application in which we track the packets of a subset of the 5-tuple flows on a link. We may use an approximate membership check for each packet to tell us if the packet belongs to one of the flows that we are tracking, in which case it is subject to more expensive processing. In this appli- cation, receiving a packet with 5-tuple x makes it very likely that we will receive other packets with the same 5-tuple value in the near future. Now suppose that a packet with 5-tuple x returns a false positive on the approximate membership check. It is clear that we would like to adapt the approximate membership check structure so that x will not return a false positive for the following packets of the same flow. Ideally, the false positive responses could theoretically be reduced to one per flow, lowering the false positive rate. Such adaptation cannot be easily done for the existing approximate member- ship check structures. A variation of a Bloom filter, referred to as a retouched Bloom filter, removes false positives (by changing some bits in the filter to 0), but can create false negatives by doing so [5]. Other options include changing the number of hash functions according to the likelihood of an element being in a set [6],[7], but this approach requires additional offline information and computation that does not appear natural for many settings. In all of these cases, removing the false positives significantly changes the nature of the data structure. We introduce the adaptive cuckoo filter (ACF), an approximate membership check structure that is able to selectively remove false positives without intro- ducing false negatives. The scheme is based on cuckoo hashing [4] and uses 2 fingerprints, following standard cuckoo filters [3]. In contrast with the cuckoo filter, where movements in the cuckoo table can be based solely on the finger- prints, here we assume we have the original elements available, although they can be in a slower, larger memory. When inserting a new element, existing elements can be moved. Our enhancement is to allow different hash functions for the fingerprints, which allows us to remove and reinsert elements to remove false positives without affecting the functionality of the filter. The removal of false positives is almost as simple as a search operation, and does not substan- tially impact performance. Instead, the impact is felt by having a slightly more complex insertion procedure, and requiring slightly more space than a standard cuckoo filter to achieve the same false positive probability. Of course, since the ACF is adaptive, it generally achieves a better false positive rate than a stan- dard cuckoo filter with the same space, and our goal here is to improve the false positive rate (as opposed to the false positive probability). We provide a theoretical model that provides accurate estimates for ACF performance. We validate ACF performance through simulations using syn- thetic data and real packet traces. The results confirm that the ACF is able to reduce false positives, making it of interest for many networking applications. Before beginning, we emphasize that the ACF is not a general replacement for a Bloom filter or cuckoo filter, but an optimization that is particularly well- suited to the setting when a pre-filter is desired to avoid unnecessary accesses to memory for data that is not stored there. There are many applications where the original, complete data is required in any case, and the filter is used as a first stage screen to prevent the need to access slower memory to check the original data. For example, for both whitelists and blacklists, a pre-filter could make lookups much more efficient, but all proposed positives would be checked against the original data. Even if only an approximate set membership data structure without the original data is required, in some architectures the memory cost of a slower and larger memory to hold the original data may be relatively inexpensive. However, we note that our need for storing the original data might make the use of ACFs unsuitable for many applications. The rest of the paper is organized as follows. Section 2 briefly reviews the data structures on which the ACF is based, namely cuckoo hash tables and cuckoo filters. Section 3 introduces the ACF, describing its implementation and providing a model of its expected performance. The ACF is evaluated in Section 4 using both randomly generated packets and real packet traces to show its effectiveness. We conclude with a summary and some ideas for future work. 2 Preliminaries We provide a brief overview of cuckoo hashing [4] and cuckoo filters [3]. 3 2.1 Cuckoo hashing Cuckoo hash tables provide an efficient dictionary data structure [4]. A cuckoo hash table can be implemented as a collection of d subtables composed of b buckets each, with each bucket having c cells. The hash table uses d hash func- tions h1, h2, . . . , hd, where the domain is the universe of possible input elements and the range is [0, b). We assume that all functions are independent and uni- form; such assumptions are often reasonable in practice [8]. A given element x can be placed in bucket hi(x) in the ith subtable; each element is placed in only one bucket. The placement is done so that there are at most c elements in any bucket. This limitation can require moving elements among their choices of buckets when a new element is inserted. Values associated with elements can be stored with them if that is required by the application; alternatively, pointers to associated values kept in an external memory can also be stored. The structure supports the following operations: Lookup: Given an element x, the buckets given by the hi(x) are examined to see if x is in the table. Insertion: Given an element x, we first check that x is not already in the table via a lookup. If not, we sequentially examine the buckets hi(x). If there is empty space, x is inserted into the first available space. If no space is found, a value j is chosen independently and uniformly at random from [1, d], and x is stored in the jth subtable at bucket hj(x). This displaces an element y from that bucket, and then the insertion process is recursively executed for y. Deletion: Given an element x, x is searched for via a lookup; if it is found it is removed. Cuckoo hash tables are governed by a threshold effect; asymptotically, if the load, which is the number of elements divided by the number of cells, is below a certain threshold (which depends on c and d), then with high probability all elements can be placed. The above description of insertion is somewhat incomplete, as there is room for variation. For example, the displaced element y is often chosen uniformly at random from the bucket, and it is often not allowed to put y immediately back into the same bucket. The description also does not suggest what to do in case of a failure. Generally after some number of recursive placement attempts, a failure occurs, in which case elements can be re-hashed, or an additional structure referred to as a stash can be used to hold a small number of items that would not otherwise be placed [9]. An alternative implementation of cuckoo hashing uses a single table of buck- ets, so each hash function can return any of the buckets. The two alternatives provide the same asymptotic performance in terms of memory occupancy. As previously stated, the asymptotic load threshold depends on the values of c and d, the number of cells per bucket and the number of hash functions. In practice, even for reasonably sized systems one obtains performance close to the asymptotic load threshold. Two natural configurations include d = 2 and 4 c = 4, which gives a threshold over 98%, and d = 4 and c = 1 which gives a threshold of over 97%. These configurations give high memory utilization, while requiring a small memory bandwidth [10]. The decision for what configuration to use may depend on the size of the item being stored and the natural cell size for memory. Note that if subtables can be put on distinct memory devices, then lookup operations can possibly be completed in one memory access cycle by searching subtables in parallel [11]. 2.2 Cuckoo filters A cuckoo filter is an approximate membership check data structure based on cuckoo hash tables [3]. Instead of storing set elements, a cuckoo filter stores fingerprints of the elements, obtained using an additional hash function. In this way, it uses less space, while still being able to ensure a low false positive probability. In the suggested implementation, each element is hashed to d = 2 possible buckets, with up to c = 4 elements per bucket. To achieve small space, the cuckoo filter does not store the original ele- ments. A difficulty arises in moving the fingerprints when buckets are full, as is required by the underlying cuckoo hash table. The cuckoo filter uses the following method, referred to as partial-key cuckoo hashing. If the fingerprint of an element x is f (x), its two bucket locations will be given by h1(x) and h1(x) ⊕ h2(f (x)). Notice that, given a bucket location and a fingerprint, the other bucket location can be determined by computing h2(f (x)) and xoring the result with the current bucket number. The structure supports the following operations, where in what follows we assume an insertion is never performed for an element already in the structure: Lookup: Given an element x, compute its fingerprint f (x), and the bucket locations h1(x) and h1(x) ⊕ h2(f (x)). The fingerprints stored in these buckets are compared with f (x). If any fingerprints match f (x), then a positive result is returned, otherwise a negative result is returned. Insertion: Given an element x, compute the two bucket locations and the fingerprint f (x). If a cell is open in one of these buckets, place f (x) in the first available open cell. Otherwise, a fingerprint f (y) in one of the buckets is displaced, and then recursively placed, in the same manner as in a cuckoo hash table. Here we use that both buckets for y can be determined from f (y) and the bucket from which f (y) was displaced. Deletion: Given an element x, x is searched for via a lookup. If the finger- print f (x) is found in one of the buckets, one copy of the fingerprint is removed. The false positive probability of a cuckoo filter can be roughly estimated as follows. If a bits are used for the fingerprints and the load of the hash table is (cid:96), the false positive probability will be approximately 8(cid:96)/2a. This is because on average the search will compare against 8(cid:96) fingerprints (assuming 2 choices of 5 buckets with 4 cells per bucket), with each having a probability 2−a of yielding a false positive. 3 Adaptive Cuckoo Filter Construction Before beginning, we note that pseudocode for our algorithms appear in the Appendix. Our proposed ACF stores the elements of a set S in a cuckoo hash table. A replica of the cuckoo hash table that stores fingerprints instead of full elements is constructed, and acts as a cuckoo filter. The key difference from the cuckoo filter is that we do not use partial-key cuckoo hashing; the buckets an element can be placed in are determined by hash values of the element, and not solely on the fingerprint. To be clear, the filter uses the same hash functions as the main cuckoo hash table; the element and the fingerprint are always placed in corresponding locations. Using the filter, false positives occur when an element not in the set has the same fingerprint as an element stored in one of the positions accessed during the search. A false positive is detected by examining the cuckoo hash table when a positive result is found; if the element is not found in the corresponding location – specifically, in the same bucket and same position within that bucket as the corresponding fingerprint – a false positive has occurred, and moreover we know what element has caused the false positive. As we explain below, to remove the false positive, we need to change the fingerprint associated with that element, by using a different fingerprint function. We suggest two ways of accomplishing this easily below. Before describing the structure in more detail, we define the parameters that will be used. • The number of tables used in the Cuckoo hash: d. • The number of cells per bucket: c. • The total number of cells over all tables: m. • The number of buckets per table: b = m/(d · c). • The occupancy or load of the ACF: (cid:96). • The number of bits used for the fingerprints: a. To see the potential benefits of the ACF, let us consider its behavior over a window of time. Let us suppose that a fraction p1 of operations are lookups, p2 are insertions, and p3 are deletions. Let us further suppose that of the lookup operations, a fraction q1 are true positives, and the remaining fraction 1 − q1 have a false positive rate of q2. If we assume costs cI , cD, cP , and cF for the inserts, deletes, positive lookups, and negative lookups, we find the total cost is: p1((q1 + (1 − q1)q2)cP + (1 − q1)(1 − q2)cF ) + p2cI + p3cD. 6 In the types of implementations we target, we expect p1 to be large compared to p2 and p3, so that the cost of lookups dominate the costs of insertions and deletions. We also expect q1 to be small, and cF to be much less than cP , so a filter can successfully and at low cost prevent lookups to slow memory. In this case the dominant cost corresponds to the term p1(q1 + (1 − q1)q2)cP , and as q1 is small, the importance of minimizing the false positive rate q2 is apparent. We now present variants of the ACF and discuss their implementation. 3.1 ACF for buckets with one cell We present the design of the ACF when the number of tables is d = 4 and the number of cells per bucket is c = 1. This configuration achieves similar utilization as d = 2 and c = 4 and requires less memory bandwidth [10] at the cost of using more tables. The ACF consists of a filter and a cuckoo hash table, with both having the same number of tables and numbers of cell per bucket, so that there is a one-to-one correspondence of cells between the two structures. The ACF stores only a fingerprint of the element stored in the main table. To implement the ACF we use a small number of bits within each bucket in the ACF filter to represent a choice of hash function for the fingerprint, allowing multiple possible fingerprints for the same element. We use s hash selector bits, which we denote by α, to determine which hash function is used to compute the fingerprint stored in that bucket. We refer to the fingerprint hash functions as f0, f1, . . . , f2s−1. For example, by default we can set α = 0 and use f0(x). If we detect a false positive for an element in that bucket then we increment α to 1 and use f1(x) (For convenience we think of the s bits as representing values 0 to 2s − 1). In most cases this will eliminate the false positive. On a search, we first read the hash selector bits, and then we compute the fingerprint using the corresponding fingerprint function before comparing it with the stored value. The downside of this approach is we are now using a small number of additional bits per cell to represent the choice of hash function, increasing the overall space required. In more detail, to remove a false positive, we increment α (modulo 2s) and update the fingerprint on the filter accordingly (Sequential selection is slightly better than random selection as it avoids picking a value of α that recently produced another false positive). We verify that the adaptation removes the false positive by checking that the new fingerprint is different from the new fingerprint for the element that led to the false positive. For example, if x created a false positive with an element y stored on the ACF when α = 1, we can increment α and check that f2(x) (cid:54)= f2(y); if the fingerprints match we can increment α again. This refinement is not considered in the rest of the paper as the probability of removing the false positive is already close to one (1 − 1/2a) and we want to keep the adaptation procedure as simple as possible. The insertion and deletion procedures use the standard insertion or deletion methods for the cuckoo hash table, with the addition that any insertions, dele- tions, or movement of elements are also performed in the filter to maintain the one-to-one relationship between elements and fingerprints. 7 To perform a search for an element x, the filter is accessed and buckets h1(x), . . . , h4(x) are read. From each bucket the corresponding fingerprint and α value is read and the fingerprint value is compared against fα(x). If there is no match in any table, the search returns that the element is not found. If there is a match, the cuckoo hash table is accessed to see if x is indeed stored there. If there is a match but x is not found, a false positive is detected. The search in the filter of an ACF is similar to a search in a cuckoo filter and should have a similar false positive probability; however, we can reduce the false positive rate. We emphasize again that the false positive probability corresponds to the probability that a "fresh," previously unseen element not in the set yields a false positive. Instead, the false positive rate corresponds to the fraction of false positives over a given sequence of queries, which may repeatedly query the same element multiple times. To model the behavior of the ACF, we will define a Markov chain that describes the evolution of α in a single bucket of the filter, with changes to α triggered by the occurrence of false positives. We assume that we have ζ elements that are not in the hash table that are currently checked on a given bucket; this is the set of potential false positives on that bucket. We assume that requests from the ζ elements are generated independently and uniformly at random; while arguably this assumption is not suitable in many practical situations, it simplifies the analysis, and is a natural test case to determine the potential gains of this approach. (More skewed request distributions will generally lead to even better performance for adaptive schemes.) We further assume that the hash table is stable, that is no elements are inserted and deleted, in the course of this analysis of the false positive rate. Finally, we first perform the analysis from the point of view of a single bucket; we then use this to determine the overall expected false positive rate over all buckets. We analyze the false positive rate assuming that these are the only queries; true matches into the hash table are not counted in our analysis, as the frequency with which items in the table are queried as compared to items not in the table is application- dependent. Without loss of generality we may assume that an element x is in the hash table, and the fingerprint value f0(x) is located in the cell. (If there is no ele- ment in the cell, then there are no false positives on that cell.) The number of elements that provide a false positive on the first hash function is a binomial random variable Bin(ζ, 2−a), which we approximate by a Poisson random vari- able with mean ζ2−a for convenience. We refer to this value by the random variable Z1, and similarly use Zj to refer to the corresponding number of ele- ments that provide a false positive for the j-th hash function. It is a reasonable approximation to treat the Zj as independent for practical values of ζ and a, and we do so henceforth. We can now consider a Markov chain with states 0, 1, . . . , 2s − 1; the state i corresponds to α = i, so the cell's fingerprint is fi(x). The transitions of this Markov chain are from i to i + 1 modulo 2s with probability Zi/ζ; all other transitions are self-loops. Note that if any of the Zi are equal to zero, we obtain a finite number of false positives before finding a configuration with 8 no additional false positives for this set of ζ elements; if all Zi are greater than zero, then we obtain false positives that average to a constant rate over time. Using this chain, we can determine the false positive rate. Specifically, let us suppose that we run for n queries. Let µ = ζ2−a, so that e−µ is our approximation for the probability that there are no false positives for a given hash function. We first note that for any value k < 2s we have a probability Pstop(k) = (1 − e−µ)ke−µ to finish in a configuration with no additional false positives after the bucket is triggered by k false positives. For this case the false positive rate is simply k/n, if we suppose that n is sufficiently large to trigger the system up to the final state. For the case where all hash functions have at least one element that yields a false positive, so that all the Zi are greater than 0, the expected number of queries to complete a cycle from the first hash function and back again, given the Zi values, is given by the following expression: 2s−1(cid:88) j=0 ζ Zj . Over this many queries, we obtain 2s false positives, The overall asymptotic false positive rate F (ζ, n) for a bucket which stores an element and to which ζ > 0 elements not in the hash table map can therefore be expressed as: 2s−1(cid:88) i=1 F (ζ, n) = (1 − e−µ)ie−µ i n + (cid:88) (cid:32)2s−1(cid:89) (cid:33) e−µµZi Zi! 2s(cid:80)2s−1 i=0 . ζ Zi Z0,Z1,...,Z2s−1>0 i=0 Notice that this expression is a good approximation even for reasonably small values of n. Further, when n is large, the first term will be comparatively small compared to the second. The previous analysis considered a bucket in isolation. We now move to consider the false positive rate for an entire table that has bd buckets with an occupancy (cid:96). The number of elements ζ that map to each bucket is a binomial random variable, asymptotically well-approximated by a Poisson random vari- able. Let us assume that there are A elements not stored that are searched for in the table; then ζ can be approximated by a Poisson random variable with mean eb = A/b. Over a collection of N queries to the table, the total num- ber of queries j that map to a bucket with ζ items is itself a binomial random variable, asymptotically well-approximated by a Poisson random variable with mean N ζ/A. We conclude that the (asymptotic, approximate) average false positive rate F over all buckets is: (cid:88) ζ>0 ζ e−eb eb ζ! (cid:88) F = bd(cid:96) e−ζN/A(ζN/A)jF (ζ, j)(j/N ) . j≥0 j! 9 While we do not provide a full proof here, we note that standard concen- tration results can be used to show that in this model the false positive rate over all the buckets is close to the expected false positive rate calculated above. Such concentration means we should not see large variance in performance over instantiations of the ACF structure in this setting. Although we have looked at a model where each query is equally likely to come from each of the ζ flows, so each has approximately the same size ne, we could generalize this model to settings where the ζ flows correspond to a small number of types (or rates), and then consider similar calculations based on the number of false positives of each rate. Intuitively, the setting we have chosen where each flow is equally likely to be queried at each step is the worst case for us, as it leads to the fastest cycling through the 2s fingerprint hash functions in the case that each fingerprint has at least one false positive. This will be confirmed by the results presented in the evaluation section. 3.2 ACF for buckets with multiple cells We now examine the case where the number of tables is d = 2 and the number of cells per bucket is c = 4, the case that was studied originally in constructing cuckoo filters [3]. The ACF again consists of a filter and a cuckoo hash table with a one-to-one correspondence of cells between the two structures; the ACF holds the fingerprint of the element stored in the main table. To reduce the false positive rate, the hash functions used for the fingerprint are different for each of the cell locations, so that in our example there will be four possible fingerprints for an element, f1(x), f2(x), f3(x) and f4(x), each corresponding to a cell (1, 2, 3, and 4) in the bucket. The insertion and deletion procedures use the standard insertion or deletion methods for the cuckoo hash table, with the addition that any changes are matched in the filter to maintain the one-to-one relationship between elements and fingerprints. Note that if an element is moved via insertion to a different cell location, its fingerprint may correspondingly change; if an element x moves from cell 1 to cell 2 (either in the same bucket or a different bucket), its fingerprint changes from f1(x) to f2(x). The search is similar to the case described in the previous subsection. When there is a match in the filter but not the main table, a false positive is detected. We describe how this ACF responds when a false positive occurs. Suppose a search for an element x yields a false positive; the fingerprints match, but element y is stored at that location in the cuckoo hash table. For convenience let us assume that the false positive was caused by the fingerprint stored in the first cell of the first table, and that there is another element z in the second cell on the first table. Then, we can swap y and z in the ACF, keeping them in the same bucket, so that now instead of f1(y) and f2(z), the bucket will hold f1(z) and f2(y) in the first two cells. If subsequently we search again for x, in most cases f1(z) and f2(y) will be different from f1(x) and f2(x), and therefore the false positive for x will be removed. If we search for y or z, we still obtain a match. As a result of the change, however, we might create false positives 10 for other elements that have also been recently queried. More precisely, when a lookup provides a positive response but the cuckoo hash table does not have the corresponding element, there was a false positive and the filter adapts to remove it by randomly selecting one of the elements in the other c − 1 cells on the bucket and performing a swap. To model the ACF for buckets with multiple cells, we define a Markov chain that takes into account the evolution of a bucket as cells are swapped. As before we assume fingerprints of a bits, with ζ elements creating potential false posi- tives, and each request being independently and uniformly chosen from this set of elements. Without loss of generality we may assume that elements w, x, y, and z are in the bucket being analyzed, initially in positions 1, 2, 3, and 4 re- spectively. Let Zw,1 be the number of elements that yield a false positive with element w when it is in position 1, that is when the corresponding value is f1(w), and similarly for the other elements and positions. Here, since some buckets may not be full, we can think of some of these elements as possibly being "null" elements that do not match with any of the ζ potential false positives. For non-null elements, as before, Zw,1 is distributed as a binomial random variable Bin(ζ, 2−a), approximated by Poisson random variable with mean µ = ζ2−a, and we treat the random variables as independent. We use Z to refer to a 16-dimensional vector of values for Zw,1, Zw,2, etc. In this setting, we consider a Markov chain with states being the 24 ordered tuples corresponding to all possible orderings of w, x, y, and z. The transition probability from for example the ordering (w, x, y, z) to (x, w, y, z) is given by Zw,1 3ζ + Zx,2 3ζ ; that is, with probability Zw,1/ζ the query is for an element that gives a false positive against w, and then with probability 1/3 the elements x and w are swapped, and similarly for the second term in the expression. Any transition corresponds to either a swap of two elements or a self-loop. It is possible an absorbing state can be reached where there is no transition that leaves that state – that is, there are no false positives in the given state – if there is some permutation where the corresponding Z variables for transitions out of that state are all 0. However, there may be no such absorbing state, in which case the false positives average to a constant rate over time. (This is similar to what we have previously seen in the ACF with one cell per bucket.) While there is no simple way to write an expression for the false positive rate for a bucket based on Z, as there was in the setting of one cell per bucket, the calculations are straightforward. Given values for a vector of Z, we can determine the false positive rate by determining either the expected number of transitions to reach the stable state, or the expected overall rate of false positives, depending on the values. Thus, in theory, we can determine the overall expected false positive rate, similarly to the case of buckets with one cell. That is, we can calculate the probability of each vector Z, and determine either the probability distribution on the number of false positives before reaching an absorbing state (if one exists), or the expected 11 time between false positives (which can be derived from the equilibrium distri- bution if there is no absorbing state), and take the corresponding weighted sum. In practice we would sum over vectors Z of sufficient probability to obtain an approximation good to a suitable error tolerance; however, we find the number of relevant vectors Z is very large, making this computation impractical. Instead, we suggest a sampling-based approach to determine the false posi- tive rate. Vectors Z are sampled a large number of times with the appropriate probability, with the corresponding false positive rate for a bucket determined for each sampled Z, to obtain a reasonable approximation. This sampling pro- cess must take into account that some cells may be left unoccupied. Based on this, we can calculate an estimate for the expected false positive rate for a single bucket to which ζ elements map, and then find the overall false positive rate by taking appropriate weighted averages, again similarly to the case of one cell per bucket. 3.3 Implementation considerations Both variants of the ACF we have proposed are simple, and straightforward to implement. The search operation is similar to that of a cuckoo hash table, with the cuckoo filter acting as a prefilter. Indeed, if there is no false positive, the cuckoo filter will determine what bucket the element is in, so that only one bucket in the cuckoo hash table will need to be checked for the element. On a false positive, after checking the table the additional work to modify the table to adapt requires only a few operations. Both variants of the ACF require the computation of different hash functions to obtain the fingerprints. This adds some complexity to the implementation. However the overhead is expected to be small as hash functions can be computed in very few clock cycles (e.g. CLHASH is able to process 64 bytes in one clock cycle [12]) in modern processors exploiting the last x86 ISA extensions [13] or implemented in hardware with low cost. In both variants, it may be possible to compute multiple fingerprints of an element at once, since most hash functions return either 32 or 64 bits, and these bits can be split into multiple fingerprints. In a hardware or modern processor implementation, hash computations are commonly much faster than memory accesses. Therefore, the time required to perform a lookup in the filter is typically dominated by the memory accesses to the filter cells. The number of such memory accesses is the same for both the cuckoo filter and the ACF. Therefore, we can argue that they will achieve similar lookup speeds. We have assumed thus far that adaptation, or the procedure to remove a false positive, is done every time a false positive is found. This is straightforward, but might not be optimal in some settings, depending on the costs of changing the ACF cuckoo hash table and filter. We leave consideration of alternative schemes that do not try to modify the ACF on each false positive for future work. For our algorithms, we have not considered the additional possibility of moving items to another bucket when false positives are detected, although this is possible with cuckoo hashing. Our motivation is in part theoretical and in part practical. On 12 the practical side, such movements would potentially be expensive, similar to additional cuckoo hash table insertions. On the theoretical side, analyzing the false positive rate when items are moving in the table seems significantly more difficult. Again, considerations of such schemes would be interesting for future work. 4 Evaluation To evaluate the performance of our proposed ACF implementations, we have simulated both with queries that are generated according to different param- eters and also with real packet traces. In the first case, the goal is to gain understanding about how the performance of the ACF depends on the different parameters while in the second, the goal is to show that the ACF can provide reductions on the false positive rate for real applications. The results are also compared with those of the analytic estimates presented in Section 3. We note that we do not compare with possible alternatives such as the retouched Bloom filter or varying the number of hash functions because they are not directly comparable with the ACF; the retouched Bloom filter introduces false negatives, and varying the number of hash functions requires additional offline information. The original cuckoo filter is the best natural alternative with which to compare. 4.1 Simulations with generated queries The first set of simulations aims to determine the effect of the different param- eters on the performance of the ACF. The ACF is filled with randomly selected elements up to 95% occupancy; let S be the number of elements stored in the ACF. Then A elements that are not in the ACF are randomly generated.The queries are then generated by taking randomly elements from A with all ele- ments having the same probability and the false positive rate is measured. We consider the following configurations: • ACF with d = 4, c = 1 (first variant) and s = 1, 2, 3. • ACF with d = 2, c = 4 (second variant). • Cuckoo filter with d = 4, c = 1. We note that we only provide results for the cuckoo filter with d = 4, c = 1 and not for the cuckoo filter with d = 2, c = 4 in our comparisons as the former achieves a significantly better false positive rate than the latter. To provide an initial understanding of the ACF performance, we fix the same probability of being selected for a query for all elements, so that on average each has ne queries. For the first variant we set the number of buckets to 32768 for each table, so the overall number of cells is 131072. For the second variant there are two tables and each table has 16384 buckets. The overall number of cells 13 is 131072 also in this case. The number of bits for the fingerprint a is set to 8,12 and 16 so that the standard cuckoo filter with d = 4, c = 1 gets a false positive rate of approximately 1.5%, 0.1%, and 0.006% at 95% occupancy. The same number of bits per cell is used for the different ACF configurations. This means that for the first variant the number of fingerprint bits are 8 − s, 12 − s, and 16 − s. The ACFs are adapted on every false positive. The value of ne is set to 10, 100, and 1000 and the experiment is repeated for several ratios of elements not in the set (A) to elements in the set (S) that appear in the queries ranging from 1 to 100. The A/S ratios used in the experiment are {1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}. Figure 1: False positive rate versus A/S ratio for the different configurations when using 8 bits per cell. Figure 2: False positive rate versus A/S ratio for the different configurations when using 12 bits per cell. Figures 1, 2, and 3 present results for 8, 12 and 16 bits per cell respec- tively. The average over 10 trials is reported. We observe, as expected, that the false positive rates for the ACFs are better for lower A/S ratios, and that the performance of the ACF improves when the number of queries per element ne increases. We also see that the second variant of the ACF (d = 2, c = 4) pro- vides better performance than the first variant (d = 4, c = 1) in almost all cases. This result backs the intuition that the second variant would perform better as it does not require any bits to track the hash function currently selected in the cell. Focusing on a comparison with a standard cuckoo filter, the ACFs outper- form the cuckoo filter for all A/S ratios considered when the number of bits per cell is 12 or 16. (Here we count only the data in the filter part, and do not 14 Figure 3: False positive rate versus A/S ratio for the different configurations when using 16 bits per cell. count the additional memory for the original data.) When the number of bits per cell is 8, the ACF has a lower false positive rate only when the A/S ratio is small. In configurations where A/S is large and the number of bits per cell is small, there are a large number of false positives, causing many cells to fail to adapt sufficiently, as they simply rotate through multiple false positives. In contrast, the reductions in the false positive rate for ACFs can be of several or- ders of magnitude for small values of the A/S ratio and large values of ne. This confirms the potential of the ACF to reduce the false positive rate on network- ing applications. In fact, the configuration considered in which all elements are queried the same number of times is a worst case for the ACF; if some elements have more queries than others, the ACF is able to more effectively remove the false positives that occur on those elements. This holds in simulations, and is seen in the next subsection with real data. (Generally network traffic is highly skewed [14].) Finally, the theoretical estimates were computed using the Markov chains and equations discussed in the previous section for all the configurations.The estimates matched the simulation results and the error was in most cases well below 5%. We note that in cases with larger error, the deviations appear to be primarily due to the variance in the simulation results; low probability events can have a significant effect on the false positive rate. For example, in the first ACF variant when s = 1 (so there are two fingerprints available for an element in the cell), the probability of having a false positive on the two fingerprints when the A/S ratio is 5 and the number of bits per cell is 16 is below 10−6, but when that event occurs it can create up to ne false positives and thereby signif- icantly contribute to the false positive rate, particularly when ne is large. Our results demonstrate that the theoretical estimates can be used as an additional approach to guide choosing parameters for performance, along with simulations. 4.2 Simulations with packet traces We also utilized packet traces taken from the CAIDA datasets [15] to validate the ACF with real-world data. For each trace, a number of flows was selected to be in the set S and placed on the ACF. Then all the packets were queried and the false positive rate was logged. To simulate several values of the A/S 15 Figure 4: False positive rate versus A/S ratio for the three CAIDA traces when using 8 bits per cell. Figure 5: False positive rate versus A/S ratio for the three CAIDA traces when using 12 bits per cell. ratio, the size of the ACF was changed. The two variants of the ACF and the cuckoo filter were evaluated as in the previous subsection. The ACF was able to consistently reduce the false positive rate of the cuckoo filter. We selected the 5-tuple as the key to insert in the ACF, and the set of 5-tuples in each trace as the A ∪ S set. Then we select the same A/S ratios used in the previous experiment and set the size of the S set, and consequently the size of the ACF so that the it reaches the 95% load when it is filled. After, the ACF is loaded picking the first S 5-tuples in the trace. The remaining flows were considered as potential false positives for the ACF. We provide results for three distinct traces1, with each corresponding to 60 seconds of traffic. The first trace has approximately 18.5 million packets and 691,371 different flows, giving an average value of ne ≈ 26.7 packets per flow. The distribution of ne is highly skewed with the largest flow having 130,675 packets, the largest one thousand flows each having more than ten thousand packets and the largest ten thousand flows each having more than two thousand packets. The other two traces have 14.6 and 37.4 million packets and 632,543 and 2,313,092 flows respectively, and the number of packets per flow is also highly skewed. The false positive rates for the three traces are shown in Figures 4, 5 and 6 for 8, 12, and 16 bits per cell. The results are similar for the three traces. 1The traces used were taken from the CAIDA 2014 dataset and are equinix- equinix- equinix-chicago.dirB.20140619-132600, chicago.dirA.20140619-130900, sanjose.dirA.20140320-130400. and 16 Figure 6: False positive rate versus A/S ratio for the three CAIDA traces when using 16 bits per cell. The best ACF configurations are the first variant (d = 2, c = 1) with s = 1 and the second variant (d = 2, c = 4). Both provide similar false positive rates and clearly outperform the cuckoo filter for all the values of the bits per cell tested. An interesting observation is that the ACF reduces the false positive rate for all A/S ratios even when the number of bits per cell is only eight. This was not the case with simulated queries, and the empirical result can be explained by how the ACF benefits from the skewness of the traffic. For example, let us consider the first ACF first variant (d = 2, c = 1) with s = 1, and consider a case where there are two flows that create false positives on a bucket, one on each of the hash selector values. If one of the flows has 1000 packets and the other has only 10, in the worst case, the ACF gives only 20 false positives on the bucket, because after 10 packets the hash selector value that gave a false positive for the small flow will give no more false positives, and the ACF will stop on that hash selector. Also, when the number of bits per cell increases, the results for the cuckoo filter show high variability. This is again due to the traffic skewness because as the false positive probability gets smaller, only a few flows contribute to the false positive rate, and the rate therefore depends heavily on the number of packets of those flows. This variability does not appear on the ACF as false positives on flows with many packets are effectively removed by the ACF as explained before. 5 Conclusions and future work This paper has presented the adaptive cuckoo filter (ACF), a variant of the cuckoo filter that attempts to remove false positives after they occur so that the following queries to the same element do not cause further false positives, thereby reducing the false positive rate. The performance of the ACF has been studied theoretically and evaluated with simulations. The results confirm that when queries have a temporal correlation the ACF is able to significantly re- duce the false positive rate compared to the cuckoo filter, which itself offers improvements over the original Bloom filter. The main novelty of the ACF is its ability to adapt to false positives by iden- tifying the element that caused the false positive, removing it and re-inserting 17 it again in a different way so that the false positive is removed, but the element can still be found when searched for. This paper has studied two variants of the ACF, in both of which the elements remain in the same bucket when false positives are found; other more complex schemes could move elements to dif- ferent buckets as well, but we leave studying such variants to future work. We believe the simple variants we have proposed, because of their simplicity and strong performance, can find uses in many natural applications. Acknowledgments Michael Mitzenmacher is supported in part by NSF grants CCF-1563710, CCF- 1535795, CCF-1320231, and CNS-1228598. Salvatore Pontarelli is partially sup- ported by the Horizon 2020 project 5G-PICTURE (grant #762057). Pedro Re- viriego would like to acknowledge the support of the excellence network Elastic Networks TEC2015-71932-REDT funded by the Spanish Ministry of Economy and competitivity. References [1] B. Bloom, "Space/time tradeoffs in hash coding with allowable errors," Communications of the ACM, vol. 13, no. 7, pp. 422–426, 1970. [2] A. Broder and M. Mitzenmacher, "Network applications of Bloom filters: A survey," Internet Math., vol. 1, no. 4, pp. 485–509, 2003. [3] B. Fan, D. Andersen, M. Kaminsky and M. Mitzenmacher "Cuckoo Filter: Practically Better Than Bloom" in Proceedings of CoNext 2014. [4] R. Pagh and F. Rodler "Cuckoo hashing", Journal of Algorithms, 2004, pp. 122-144. [5] B. Donnet, B. Baynat, and T. Friedman, "Retouched bloom filters: allow- ing networked applications to trade off selected false positives against false negatives", In Proceedings of the ACM CoNEXT conference, 2006. [6] M. Zhong, P. Lu, K. Shen, and J. Seiferas, "Optimizing data popularity conscious bloom filters," in Proceedings of the twenty-seventh ACM sym- posium on Principles of distributed computing (PODC), 2008. [7] J. Bruck, J. Gao and A. Jiang, "Weighted Bloom filter," in Proceedings of the IEEE International Symposium on Information Theory 2006. [8] K. Chung, M. Mitzenmacher, and S. Vadhan, "Why Simple Hash Functions Work: Exploiting the Entropy in a Data Stream", Theory of Computing 9(2013), 897-945. 18 [9] A. Kirsch, M. Mitzenmacher, and U. Wieder. "More robust hashing: Cuckoo hashing with a stash", SIAM Journal on Computing 39(4):1543- 1561, 2009. [10] U. Erlingsson, M. Manasse, and F. Mcsherry, "A cool and practical alter- native to traditional hash tables", in Proc. of the Seventh Workshop on Distributed Data and Structures (WDAS), 2006. [11] S. Pontarelli, P. Reviriego and J.A. Maestro, "Parallel d-Pipeline: a Cuckoo Hashing Implementation for Increased Throughput", IEEE Transactions on Computers, vol. 65, no 1, January 2016, pp. 326-331. [12] D. Lemire and O. Kaser. "Faster 64-bit universal hashing using carry-less multiplications." Journal of Cryptographic Engineering (2015): 1-15. [13] Intel R(cid:13) 64 and IA-32 Architectures Software Developer's Manual Volume 2. [14] N. Sarrar, N., S. Uhlig, A. Feldmann, R. Sherwood, & X. Huang, (2012). Leveraging Zipf's law for traffic offloading. ACM SIGCOMM Computer Communication Review, 42(1), 16-22. [15] CAIDA realtime passive network monitors, available online: www.caida.org/data/realtime/passive. 19 Appendix: Algorithms We provide pseudocode for our algorithms. Algorithm 1 ACF for buckets with a single cell: Lookup for an element x Require: Element x to search for Ensure: Positive/negative 1: for i ← 1 to 4 do 2: 3: 4: 5: 6: Access bucket hi(x) Read α and fα(y) stored on the cell Compute fα(x) Compare fα(y) in the cell with fα(x) if Match then return positive end if 7: 8: 9: end for 10: return negative Algorithm 2 ACF for buckets with a single cell: Adaptation to remove a false positive Require: False positive on bucket hi(y) Ensure: update α and fα(y) 1: Access bucket hi(y) 2: Read α stored on the cell 3: Retrieve element y stored on bucket hi(y) from the main table 4: Increment α modulo 2s 5: Compute fα(y) 6: Store the new value of α and fα(y) on bucket hi(y) in the ACF 20 Algorithm 3 ACF for buckets with multiple cells: Lookup for an element x Require: Element x to search for Ensure: Positive/negative 1: Compute f1(x), f2(x), f3(x), f4(x) 2: for i ← 1 to 2 do 3: 4: Access bucket hi(x) for j ← 1 to 4 do Compare fingerprint stored in cell j with fj(x) if Match then 5: 6: 7: 8: 9: 10: end for 11: return negative end for return positive end if Algorithm 4 ACF for buckets with multiple cells: Adaptation to remove a false positive Require: False positive in cell j on bucket hi(y) Ensure: update bucket hi(y) 1: Select randomly a cell k different from j on bucket hi(y) 2: Retrieve elements y, z stored in cells j, k on bucket hi(y) from the main table 3: Compute fj(z) and fk(y) 4: Write fj(z) and fk(y) in cells j and k on bucket hi(y) of the ACF 5: Write z in cell j and y in cell k on bucket hi(y) in the main table 21
1508.02435
2
1508
2015-10-05T08:15:32
Two Particle-in-Grid Realisations on Spacetrees
[ "cs.DS" ]
The present paper studies two particle management strategies for dynamically adaptive Cartesian grids at hands of a particle-in-cell code. One holds the particles within the grid cells, the other within the grid vertices. The fundamental challenge for the algorithmic strategies results from the fact that particles may run through the grid without velocity constraints. To facilitate this, we rely on multiscale grid representations. They allow us to lift and drop particles between different spatial resolutions. We call this cell-based strategy particle in tree (PIT). Our second approach assigns particles to vertices describing a dual grid (PIDT) and augments the lifts and drops with multiscale linked cells. Our experiments validate the two schemes at hands of an electrostatic particle-in-cell code by retrieving the dispersion relation of Langmuir waves in a thermal plasma. They reveal that different particle and grid characteristics favour different realisations. The possibility that particles can tunnel through an arbitrary number of grid cells implies that most data is exchanged between neighbouring ranks, while very few data is transferred non-locally. This constraints the scalability as the code potentially has to realise global communication. We show that the merger of an analysed tree grammar with PIDT allows us to predict particle movements among several levels and to skip parts of this global communication a priori. It is capable to outperform several established implementations based upon trees and/or space-filling curves.
cs.DS
cs
Two Particle-in-Grid Realisations on Spacetrees T. Weinzierla,∗, B. Verleyeb,c, P. Henrid, D. Rooseb aSchool of Engineering and Computing Sciences, Durham University Stockton Road, Durham DH1 3LE, Great Britain bDepartment of Computer Science, KU Leuven Celestijnenlaan 200A, B-3001 Leuven, Belgium cVrije Universiteit Brussel Pleinlaan 2, 1050 Elsene, Belgium dLaboratoire de Physique et Chimie de l'Environnement et de l'Espace (LPC2E) CNRS, Universit´e d'Orl´eans 45071 Orl´eans Cedex 2, France Abstract The present paper studies two particle management strategies for dynamically adaptive Cartesian grids at hands of a particle-in-cell code. One holds the par- ticles within the grid cells, the other within the grid vertices. The fundamental challenge for the algorithmic strategies results from the fact that particles may run through the grid without velocity constraints. To facilitate this, we rely on multiscale grid representations. They allow us to lift and drop particles be- tween different spatial resolutions. We call this cell-based strategy particle in tree (PIT). Our second approach assigns particles to vertices describing a dual grid (PIDT) and augments the lifts and drops with multiscale linked cells. Our experiments validate the two schemes at hands of an electrostatic particle- in-cell code by retrieving the dispersion relation of Langmuir waves in a thermal plasma. They reveal that different particle and grid characteristics favour differ- ent realisations. The possibility that particles can tunnel through an arbitrary number of grid cells implies that most data is exchanged between neighbouring ranks, while very few data is transferred non-locally. This constraints the scala- bility as the code potentially has to realise global communication. We show that the merger of an analysed tree grammar with PIDT allows us to predict particle movements among several levels and to skip parts of this global communication a priori. It is capable to outperform several established implementations based upon trees and/or space-filling curves. Keywords: Particle-in-cell, spacetree, particle sorting, AMR, Lagrangian-Eulerian methods, communication-avoiding ∗Corresponding author Email addresses: [email protected] (T. Weinzierl), [email protected] (B. Verleye), [email protected] (P. Henri), [email protected] (D. Roose) URL: www.dur.ac.uk/tobias.weinzierl (T. Weinzierl) Preprint submitted to Elsevier November 8, 2018 1. Introduction Lagrangian-Eulerian descriptions of physical phenomena are used by a wide range of applications. They combine the short-range aptitude of particle-based with the long-range capabilities of grid-based approaches. Besides their pop- ularity driven by application needs, particle-grid methods are also popular in supercomputing. They are among the best scaling algorithms today (cf. for example [8, 20, 21]). This scaling mainly relies on two ingredients. On the one hand, particle-particle interactions often are computationally expensive in terms of floating point operations with moderate memory footprint. On the other hand, the particle-grid interaction requires a mapping of particles to the grid. This is a spatial sorting problem. It either is performed infrequently, is computationally cheap as the particles move at most one grid cell at a time, or the grid can be constructed efficiently starting from the particles [21]. The present paper is driven by a plain electrostatic PIC simulation [9, 27] of an unmagnetised plasma. Its computational profile differs from the previous characteristics as it solves a partial differential equation (PDE) on an adaptive Cartesian grid which has to be stored persistently in-between two time steps. At the same time, the particles do not interact with each other -- they induce very low computational workload -- but may move at very high speed through the grid. Our work focuses on well-suited data structures and algorithms required for such a code within a dynamic adaptive mesh (AMR) environment where the simultion is ran on a distributed memory machine. The setup raises an algorithmic challenge. While dynamic AMR for PDEs as well as algorithms based upon particle-particle interactions are exhaustively studied, our algorithm requires a fast mapping of particle effects onto the grid and the other way round per time step. This assignment of particles to the grid changes incrementally. Yet, some particles might tunnel several cells per time step: no particle is constrained to move at most into a neighbouring cell. In general, the time step size is chosen such that the majority of particles travel at most one cell per time step. This avoids the finite grid instability [2], i.e. numer- ical, non-physical, heating of the experiment. However, in our application as well as most non-relativistic plasma and gravitation applications, suprathermal particles do exist. Their velocity is not bounded. The present paper proposes the parallel, locally refined, dynamically adap- tive grid to result from a spacetree [29, 32] yielding a Cartesian tessellation. Particles are embedded into the finest tree level. The latter is the adaptive grid hosting the PDE. A multiscale grid traversal with particle-grid updates then can be realised via a simple recursive code mirroring a depth-first search [30]. Two particle realisation variants are studied: we either store the particles within the spacetree leaves (particle in tree; PIT) or within the dual tree (par- ticle in dual tree; PIDT) induced by the spacetree vertices. The latter is similar to a linked-list approach with links on each resolution level. This multiscale linked-list can be deduced on-the-fly, i.e. is not stored explicitly but encoded 2 within the tree's adjacency information. Both particle storage variants ren- der the evaluation of classical compact particle-grid operators straightforward as each particle is assigned to its spatially nearest grid entity anytime. Tun- neling is enabled as particles are allowed to move up and down in the whole spacetree. PIDT furthermore can move particles between neighbours. Besides neighbours and parent-child relations, no global adjacency data structure is re- quired. While PIDT induces a runtime overhead and induces a more complex code compared to PIT, the multiscale linked-list nature of PIDT reduces the particle movements up (lift) and down (drop) in the tree, and particles moving along the links can be exchanged asynchronously in-between grid traversals. If we combine PIDT with a simple analysed tree grammar [11] for the particle velocities, we can predict lifts and anticipate drops in whole grid regions. This helps to overcome a fundamental problem. Since tunneling is always possible, we need all-to-all communication in every time step: each rank has to check whether data is to be received from any other rank. This synchronisation in- troduces inverse weak scaling. The more particles the higher the number of tunnels. The more ranks the more tunnel checks. With a lift prediction, we can locally avoid the all-to-all that we map onto a reduction (reduction-avoiding PIDT; raPIDT). We weaken the rank synchronisation. Rank and process are used here as synonyms. For reasonably big parallel architectures, PIDT and its extension raPIDT thus outperform PIT. Though all three flavours of particle storage support tunneling, their performance is not significantly slower than a classic linked-list approach not allowing particles to tunnel. The multiscale nature of both PIT and PIDT as well as its variant raPIDT further makes the communication pattern, i.e. the sequence and choice of particles communicated via MPI, comprise spatial information. Ranks receiving particles that have to be sorted into a local grid anticipate this presorting and thus can outperform other classic approaches [4, 23, 25]. The remainder is organised as follows. We refer to related work before we introduce the algorithmic steps of electrostatic PIC motivating our algorithmic research (Section 3). In Section 4, we describe our spacetree grid paradigm. Two particle realisation variants storing particles either within the grid cells or within the vertices form the present work's focus (Section 5). Our experimental evaluation starts from a review of the particle movement characteristics before we study the runtime behaviour of the particle storage and sorting schemes as well as the scaling. Finally, we compare our results to three other approaches. This comparison (Section 7) highlights our contribution with respect to the particular application from Section 3 as well as the inevitable cost introduced by the tunneling particles. A summary and outlook in Section 8 close the discussion. The appendix comprises a real-world validation run of our code as well as additional experimental data. 2. Related and used work Requiring tunneling in combination with a persistent grid holding a PDE so- lution renders many established grid data structures inappropriate or unsuited. 3 We distinguish three classes of alternatives: on-the-fly (re-)construction, sort- ing and linked-list. Reconstructing the assignment for the prescribed grid from scratch per time step [21] is not an option, as the grid is given, holds data and is distributed. Local sorting followed by scattering is not an option (see e.g. [23, 25] and references therein) as the decomposition, i.e. the adaptive mesh, is not known on each individual rank. The two possible modifications are to rely on replicated grids per rank and then to map these grids onto the real PDE grid -- this approach is not followed-up here -- or to sort locally within the grid and then to scatter those particles that cannot be sorted locally. Such a two-stage approach enriches local meta data information with additional decom- position data (ranks have to know how to scatter the particles) held on each rank, but may run into network congestion (cf. results from [4]) even if we avoid all-to-all collectives [25] and rely on elegant decomposition paradigms such as space-filling curves (SFCs). Finally, standard linked-cell algorithms, cell-based Verlet lists or hypergraph-based approaches [7, 17] are not well-suited. They impose constraints on the velocities of particles, i.e. they can not handle parti- cles that may travel arbitrarily fast. Alternative approaches such as overlapping domain decompositions where the grid holding the particles is replicated on all ranks, schemes where particle and domain decomposition may differ, schemes where the associativity is re-emended only every k steps or approaches tailored to regular grids only are not considered here [5, 10, 17, 19]. For the present challenge, we require an algorithm that updates the grid- particle correlation incrementally. It has to be fast, i.e. anticipate the incremen- tal character, but nevertheless has to support particle escapees. Hereby, the particle distribution follows the grid decomposition: particles contained within a grid cell should reside on the compute node holding the respective grid cell in a non-overlapping domain decomposition sense. For this, we rely on a tree data structure where grid cells 'point' to particles. Our approaches materialise ideas of bucket sorts [25]. A tree's multiscale nature allows us to realise the sorting incrementally, locally and fast without constraints on the particle velocity or the dynamically adaptive grid structure. The omnipresent multiscale nature and the lack of grid constraints make it differ from the up down tree approach in [4]. Our PIDT variant holds particles within vertices and thus allows cells to push particles into their neighbouring cells directly. No multiscale data is involved. As such it materialises the linked-cells idea where each cells holds a list of its neighbours. As these links are available on all discretisation levels, our PIDT variant can be read as a multiscale linked-cell approach. Finally, our code holds all tree data non-overlappingly and does not require any rank to hold the subdomain dimensions of each and every other rank. This makes the present algorithms differ from classic codes that rely on SFCs to obtain a fine grid partition and then construct (overlapping) coarse grid regions bottom-up. All adjacency data of the domain decomposition is localised. Comparisions to several of these aforementioned approaches with tunneling highlight the present algorithms' strenghts and weaknesses. Notably, they high- light that our local decomposition and particle handling is, for many applica- tions, superior to classic SFC decompositions where the domain decomposition 4 is known globally as well as to approaches where particles are handed around cyclically or sorted from a coarse regular mesh into the fine AMR structure [4]. A comparison to a classic linked-cell code that does not support tunneling finally reveals the price we have to pay to enable tunneling. Throughout the present paper, we rely on our open source AMR software framework Peano [30, 31]. It allows us to rapidely implement and evaluate the present algorithmic ideas. raPIDT was fed back into this framework and now is available as black-box particle handling scheme. Yet, none of the present algorithms is tied to that particular framework. They work for any spactree- based code -- relying on classic quadtree or octree discretisation, e.g. -- and for any spatial dimension as long as two criteria are met. First, our algorithms need all resolution levels of the multiple AMR grids embedded into each other explicitly. The meshing software has to provide all the mesh resolution levels to the solver and the solver has to be able to embed data into each and every level. Providing solely the finest mesh, e.g., is not sufficient. Second, the algorithms have to switch from coarser to finer levels and the other way round throughout the mesh traversal. Notably, a depth-first, a breadth-first or any hybrid traversal on the tree that is implemented recursively work. 3. Use case: a particle-in-cell code Figure 1: An artificial test setup at time steps t ∈ {2, 130, 190} from left to right: Particles are homogeneously distributed among a small cube embedded into the unit cube at time t = 0. We apply reflecting boundary conditions. As the particles move according to a fixed random velocity (the brighter the higher their speed) and as the grid keeps the number of particles per cell bounded, the mapping of grid entities to particles is permanently to be updated. The particle-in-cell (PIC) method has originally been developed to solve kinetic equations in plasma physics and self-gravitating systems (the so-called Vlasov equation, or collisionless Boltzmann equation), but it has also shown to be efficient for computational fluid simulations ([5, 6, 9, 10, 13, 14, 16, 19, 27], e.g.). Macro particles in a Lagrangian frame -- they mimic the behaviour of a distribution function -- are tracked in continuous phase space. Simultaneously, moments of the distribution function such as charge density for plasma physics simulations are computed on an Eulerian frame (fixed cells) in Rd, d ∈ {2, 3}. 5 The PIC method reduces the N-body problem by filtering out binary interactions between particles through a so-called mean field approximation. In return, it couples the particles to a grid accommodating a grid-based solver of a partial differential equation. PIC typically reads as follows: on the grid, and obtained from the particle through ρ =(cid:80) 1. Given a set of particles at positions xi, the charge density ρ is defined i R(xi). The restriction R(xi) in our case has local support and the grid based upon squares/cubes is chosen such that R affects at most 2d vertices. It depends on the particle position. 2. We solve L(V ) = ρ (1) on the grid which yields a potential V . V 's semantics depend on the model. In our case it is the electric potential though all properties hold when we consider a gravitational potential with ρ being the mass density. L is, in our case, the Laplacian. Throughout the solution process, the grid is dynamically coarsened and refined to resolve V and the particle- cell interplay accurately. 3. A field E = −∇V is derived from the potential. This field then is interpo- lated from the grid to the particle positions ∀i : Ei = RT (xi)E. We apply the transpose of the interpolation per particle. 4. The particle velocities vi and positions xi are updated (some authors call this "push" [19]) with ∂tvi = φi(Ei, vi) and ∂txi = vi with a generic particle property equation φi(Ei, vi). Moving the particles is computationally cheap once the impact Ei on the parti- cles is known. The particle-to-grid and grid-to-particle mappings usually stem from the multiplication of particle shape functions translated to the particle positions xi with grid-aligned test functions that in turn are used to discretise the PDE. In our case, we restrict to Cartesian grids, i.e. to square or cube cells for the spatial discretisation, and we use d-linear shape functions for the PDE. More sophisticated schemes are possible. As L generally may comprise ∂tE, E or V from the previous time step have to be available on the grid. Equation (1) typically is solved by an iterative scheme. The present work neglects particularities of the PDE solver as well as dynamic load balancing and adaptivity criteria. However, we highlight that the impact of the particles on the PDE solution correlates to the particle density, i.e. the more particles in a given grid region, the rougher the PDE solution due to stimuli on the right-hand side. At the same time, a proper adaptivity criterion anticipates the Debye length: the maximum grid size depends locally on both the particle density and the mean velocity (bulk flow velocity) or mean square particle velocity (thermal velocity) [2]. Our particle-grid realisations have to support dynamically adaptive grids. We first focus exclusively on adaptive Cartesian grids and storage paradigms for the dynamically adaptive grid holding the particles in the cells/vertices. Dif- ferent to many other particle codes where the grid is merely a helper data struc- ture, our grid stays persistent between any two time steps. Second, we focus on 6 reassignment procedures once the particles are moved. Different to many other particle codes, it is crucial that the grid-particle relations are updated immedi- ately and that there is no restriction on vi with respect to the grid size. Third, we focus on the distributed memory parallelisation of the reassignment induced by a non-overlapping, given grid decomposition, and we study how particles have to be exchanged if they move along this decomposed geometric structure. This facilitates a fast evaluation of the grid-particle operator, as particles reside on the same node as their corresponding grid element. A discussion of a proper choice of a grid decomposition as well as dynamic load balancing are beyond scope. Finally, we reiterate that we neither can make assumptions on the grid structure nor on the particle velocities nor on the actual particle distribution. Particles can either traverse the grid elements smoothly or tunnel several grid elements a time. 4. A distributed spacetree data structure holding particles A multitude of ways exists to formalise and implement adaptive Cartesian grids. Tree-based approaches are popular (cf. overview in [1] or [15, 20, 21, 29, 32]). They facilitate dynamic adaptivity and low memory footprint storage schemes teaming up with good memory access characteristics -- in particular in combination with space-filling curves [1]. In the present paper, we follow a k-spacetree formalism [29, 32]: the com- putational domain is embedded into a square or cube, the root. This geometric primitive is split into k parts along each coordinate axis. We end up with kd squares or cubes, respectively. They tessellate the original primitive. This setup can be represented by a graph with kd + 1 nodes and a relation (cid:118)child of . Each node of this graph represents one cube or square, respectively, and is denoted If a (cid:118)child of b, a is contained within b and is derived from b by k as cell. cuts through b along each coordinate axis. We continue recursively while we decide for each cell whether to refine further or not. The resulting graph is a k- spacetree given by (cid:118)child of , a set of cells T and a distinguished root. For k = 2 the scheme mirrors the traditional octree/quadtree concept [1, 15, 20, 21]. Our present code relies on the software Peano [30, 31] and thus uses k = 3. However, all algorithmic ideas work for any k ≥ 2. Let Ω(cid:96) denote the grid of one spacetree level (cid:96). The union Ωh = (cid:83) The distance from the root cell to any other cell is the cell's level. All cells of one level represent geometric primitives of exactly the same size, are aligned and do not overlap. The k-spacetree consequently yields a cascade of ragged Cartesian grids. The union of all these grids is an adaptive Cartesian grid. (cid:96) Ω(cid:96) then yields an adaptive Cartesian grid. A cell of T is a leaf if it does not have a child. If a (cid:118)child of b, b is a parent of a. Due to the cascade-of-grids formalism, there may be multiple vertices in a spacetree at the same spatial location while they belong to different grids Ω(cid:96), i.e. different levels. Each vertex has up to 2d adjacent cells on the same level. If it has less than 2d adjacent cells, it is a hanging vertex. Anticipating the spacetree's partial order, a vertex has up to 2d parent vertices (Figure 2): A vertex vb is a parent to vertex va, if all cells 7 Figure 2: The spacetree introduces a parent relation on the spacetree cells (left; arrows point from child to parent). This spatial order in combination with the grid embedding induce a parent relation upon the vertices as well (middle and right). Vertices coinciding with coarser vertices on the same level have one parent, vertices within coarser cells have 2d parents, vertices located on coarse grid faces and edges have a parent cardinality in-between. that are adjacent to va have parent cells that are in turn adjacent to vb. While many tree-based codes deduce an adaptive grid from a spacetree formalism and then work basically on the spacetree's leaves, we preserve and maintain the whole tree as computational data structure though the particle-grid interaction is often computed only in leaves. 4.1. Dual spacetree grid (cid:96) of one level is defined as follows: Besides the cascade of Cartesian grids, the spacetree formalism also induces dual grids. A dual grid Ω(d) It is a grid consisting of geometric primitives of exactly the type as in Ω(cid:96). They are dilated such that each cell center of Ω(cid:96) coincides with one non-hanging vertex of the dual grid. T (d) then is the cascade of dual grids to T (Figure 3). For odd k -- we have k = 3 -- we observe dual grid consistency: A dual cell of one level either is contained completely within a dual cell of a coarser level or does not intersect with coarsers cells at all. The present algorithms did, in principle, not rely on this consistency, but their implementation's simplicity benefits from k = 3. 4.2. Storing particles within the spacetree The present paper studies two choices to store the particle-grid relations: either each cell holds the particles covered by it, or each vertex holds the parti- cles whose positions are closer to this vertex than to any other vertex. "Holds" denotes that the grid entity basically links to an array of particles. While we focus on the data handling and parallelisation, packed memory algorithms [5], e.g., can replace these arrays with more efficient realisation variants avoiding frequent reallocation. Furthermore, we do not discuss global data layout opti- misations to improve the placement of the arrays in memory [5, 10] but rather refer to [29, 32] where we introduce a multiscale ordering of the spacetree cells along the Peano space-filling curve. Such an ordering of the cells transfers to an ordering of arrays. We thus can assume reasonably efficient memory data access with respect to caches. Without loss of generality, these arrays are, for 8 Figure 3: From left to right: A spacetree is a directed graph (cid:118)child of visualised bottom-up here. It yields a cascade of ragged Cartesian grids Ω0, Ω1, Ω2. The merger of the three is an adaptive Cartesian grid Ωh. The dual k = 3-spacetree yields a cascade of three dual grids (with the original grid as dotted lines). the time being, empty on the coarse levels, whereas all particles reside within the finest grid resolution. In our second storage scheme, particles are assigned to the vertex whose dual cell covers their position. It is a Voronoy-based par- ticle assignment [24]. As we are working in a spacetree environment, the two approaches are named particle in tree (PIT) and particle in dual tree (PIDT). 4.3. Parallel grid decomposition Let P = {p0, p1, . . .} be the finite set of processes (ranks) on a parallel computer. col : T (cid:55)→ P is a colouring that assigns each spacetree cell a colour, i.e. a processor that is responsible for this cell. In practice, each processor holds only that part of a spacetree it is responsible for [29]. Let (cid:118)worker of induce a tree topology on P as follows: ∀a (cid:118)child of b : col(a) = pi ∧ col(b) = pj ⇒ pi = pj ∨ pi (cid:118)worker of pj. (2) As the graph in (2) shall be free of cycles, different subtrees of the global space- tree are handled by different processes, i.e. on different ranks. We decompose the spacetree. No refined cell is shared among multiple ranks, and col introduces a master-worker relations with a distinguished global master being responsible for the root. This scheme differs from local essential tree constructions where coarse grid cells are replicated among multiple nodes ([15] and their references to original work). We rely on a unique rank responsibility for coarse grid spacetree cells [30]. Our tree colouring induces a multiscale non-overlapping spacetree decompo- sition, i.e. each cell is assigned to a rank uniquely, while vertices at the partition boundaries are held and replicated on up to 2d ranks. The term non-overlapping refers to each individual level. Let each cell of T (d) be assigned to the ranks that hold cells that are adjacent to the center of the cell in T . The colouring then induces a multiscale 1-overlapping decomposition on T (d). 9 O0O1O2Oh For PIC, it is convenient to decompose particles along col as the particles do not interact. For PIDT, dual cells intersecting with the parallel boundary then are replicated while the particles are never replicated but always are assigned to one rank uniquely. 4.4. Event-based formalism of the tree traversal A tree traversal is an algorithm running through T . An effective tree traver- sal shall have three properties: 1. All data access is local within the grid/tree. 2. All data access anticipates the domain decomposition. 3. The data access scheme is efficient. In particular, any particle sorting shall be possible in one tree traversal even if the grid changes. For this, we process each cell of this set twice: an operation enterCell is per- formed prior to an operation leaveCell. We enforce ∀a (cid:118)child of b : ⇒ enterCell(b) (cid:118)bef ore enterCell(a) ∧ leaveCell(a) (cid:118)bef ore leaveCell(b) enterCell(c) (cid:118)bef ore leaveCell(c) and for a, b, c ∈ T (3) where (cid:118)bef ore is a partial temporal access order. Obviously, both depth-first and breadth-first k-spacetree traversal as well as hybrid variants preserve (3). ∀c : As the tree is a representation of the cascade of grids, a tree traversal de- scribes a strict element-wise multiscale processing of the whole grid cascade. For any element-wise realisation of a PDE solver or a particle-based algorithm it is then sufficient to specify which data are assigned to the k-spacetree's ver- tices and cells, and to specify how individual events [30] such as enterCell and leaveCell map onto algorithmic fragments often called compute kernels. Our discussion restricts to element-wise algorithms as those algorithms fit straight- forwardly to non-overlapping domain decompositions. Following the notion of element-wise processing, only records assigned to one cell and its adjacent vertices are available to an event. Following the notion of a spacetree, the parent data are passed to events as well. Besides the cell events, our implementations rely on two additional events: touchVertexFirstTime is called once per spacetree vertex per traversal per rank before the vertex is used by this rank the very first time, i.e. before enterCell is invoked on any adjacent cell of this vertex. touchVertexLastTime is called once per spacetree vertex on each rank after the vertex has been used the very last time, i.e. after leaveCell has been invoked on all adjacent cells. In a parallel tree traversal, the global master starts to traverse the tree. Its workers' tree traversals are successively started up as soon as (3) allows for. This is a broadcast along a tree topology. Whenever a tree traversal ascends again in the tree (processes leaveCell and touchVertexLastTime), it might have to wait for other colours to finish their share of the global tree due to (3). The startup of a remote colour is accompanied by the two events prepareSendToWorker and 10 mergeWithWorker invoked on the master or worker, respectively. The other way round, prepareSendToMaster and mergeWithMaster are called. Furthermore, events, i.e. plug-in points for the algorithm, do exist to merge vertices at the domain decomposition boundaries. Vertex exchanges are triggered after a local vertex has been used for the last time. mergeWithNeighbour events then are invoked on each rank per parallel domain boundary vertex prior to any usage of this vertex. As mergeWithNeighbour is called prior to the next usage but copies are sent after touchVertexLastTime, vertex data exchange along the rank boundaries overlaps two iterations. This exchange is asynchronous while the information exchange between masters and workers is synchronous. 5. Cell- and vertex-based particle movers For each of the two particle storage schemes, PIC requires the scheme to maintain the particle-to-grid mapping. Whenever a particle moves, our code has to analyse whether the particle remains within its cell or dual cell, respectively, or it has to update the mapping otherwise. While it might be straightforward to iterate first over all particles to move them before we sort them in an up- date sweep, we propose to merge particle movement and reassignment. This way, we avoid an extra sorting step. For both PIT and PIDT, we propose to move particles up and down within the spacetree to enable tunneling, but we enforce that all particles are sorted into the leaf tree level prior to any subse- quent operation on the particle in the next traversal. Our algorithmic sketches describe stationary grids. If spacetree nodes are added dynamically, both ap- proaches automatically move particles into the right grid entities as the sort algorithm makes all particles reside on the finest grid level. If spacetree nodes are removed, both approaches move the particles associated with removed grid entities up in the spacetree and continue. Support of dynamic adaptivity hence is straightforward and not discussed further. 5.1. Particle in tree (PIT) PIT maps each particle from the particle set M onto a leaf of the spacetree, i.e. XPIT : M (cid:55)→ T . Only the particle position x ∈ Rd determines this mapping. PIT's particle update then reads as Algorithm 1 and integrates into any tree traversal preserving (3) (Figure 4). Each global particle sorting is split among two traversals. Let traversal t2 follow t1. All lift operations with respect to particle updates in t1 are embed- ded into the traversal t1, whereas the drops and the particle position updates are embedded into t2. t2 already realises the lifts of the subsequent time step whereas t1 realises the drops of the previous one. Hence, one (amortised) traver- sal per resort is sufficient -- the first 1.5 traversals realise the first sort, the next 2.5 the second, . . . -- and the following statement holds: Theorem 5.1. Whenever enterCell is invoked on a leaf a and all its preamble operations terminate, all particles within the cell have a position x covered by a. 11 Figure 4: Left: Assigning particles to cells is trivial as long as particles due not leave 'their' cell to the particle update (empty particle). If particles leave a cell (filled particles), they have to be reassigned to a new cell. Middle: PIT lifts these particles to the next coarser levels and then drops them back. If particles tunnel (light gray), they have to be lifted several levels. Right: A tree decomposed into two colours is traversed by PIT. Lifts (red) and drops (blue) are embedded into this parallel traversal. Therefore, particles are exchanged in-between processors only along the parallelisation's master-worker topology. Proof. We restrict to a single particle m ∈ M, and we assume that the theorem holds prior to traversal t1 with XPIT(m) being a leaf. We first show that x ∈ XPIT(m) as soon as t1 terminates though the image can be a refined spacetree cell. x ∈ XPIT(m) denotes that the spacetree cell to which m is mapped to covers the position x. For this, we make a simple top down induction on the tree depth. If XPIT(m) is the root, x ∈ XPIT(m) is trivial as the root spans the whole computational domain. Otherwise we distinguish two cases for leaveCell invoked for a spacetree cell of level (cid:96) + 1: • x ∈ XPIT(m): the particle resided in XPIT(m) prior to a position update and doesn't leave the cell. PIT does not modify XPIT. • x (cid:54)∈ XPIT(m): the particle leaves the cell in which it was contained before. In leaveCell, we assign it to its parent, i.e. XPIT X (new) PIT (m) XPIT(m) (cid:118)child of (cid:55)→ = X (new) p PIT with while p. Due to (3), this happens after enterCell is invoked for m in t1 and does not harm our initial assumption. Due to (3), this transition is triggered before the leaveCell call for the parent on level (cid:96). The statement for level (cid:96) holds by induction. 12 end for if c refined then for all m ∈ M associated to c do identify c(cid:48) (cid:118)child of c containing m assign m to c(cid:48) end if invoke application-specific operations if c unrefined then for all m ∈ M associated to c do Algorithm 1 Particle-in-tree algorithm. 1: function enterCell(cell c ∈ T ) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: end function 16: function leaveCell(cell c ∈ T ) 17: 18: 19: 20: 21: 22: 23: end function end if invoke application-specific operations invoke application-specific operations for all m ∈ M associated to c do update position x(m) end if end for end for if position x of m not contained in c then assign m to c(cid:48) with c (cid:118)child of c(cid:48) (cid:46) preamble (cid:46) drop (cid:46) move (cid:46) epilogue (cid:46) lift For the subsequent traversal t2, we again use an induction over the tree height and distinct two cases. However, we argue bottom-up. For trees of height zero the algorithm's correctness is trivial. Let the root be refined. • XPIT(m) on level (cid:96) is a leaf: The theorem holds. • XPIT(m) on level (cid:96) is refined. The algorithm bucket sorts the particle into the child cell covering its new position, i.e. XPIT X (new) PIT (m) (cid:55)→ = X (new) c PIT while c (cid:118)child of XPIT(m). with c has level (cid:96) + 1. Due to (3), enterCell for the parent is invoked prior to enterCell for the spacetree node on level (cid:96) + 1. The statement for level (cid:96) + 1 holds by induction. A distributed memory parallel version of PIT adds two case distinctions. When- ever PIT lifts a particle from a local root, i.e. a spacetree node whose parent is assigned to a different colour, this particle is sent to the parent's rank by the event prepareSendToMaster. In return, mergeWithMaster receives and inserts it into the local data structure. Whenever the tree traversal encounters a cell of a different colour, prepareSendToWorker replaces the drop by a send to the worker rank. mergeWithWorker receives them and continues to drop them (Figure 4). All 13 Figure 5: Parallel PIDT: There are three different types of particle movements. Particles might remain in their dual cell (blue), might move to an adjacent dual cell (gray) or tunnel (red and dark red). Only for the latter, multilevel movement comes into play. Copies of particles leaving through vertices without further tunneling are sent away immediately throughout the traversal but are not received prior to the next iteration (asynchronous communication, dotted arrows from left to right). Only very few tunneling particles are communicated synchronously among the tree topology (dark red particle, red dotted diagonal arrow). parallel data flow is aligned with the tree topology on P, i.e. particles are only sent up and down within the spacetree. All data exchange is synchronous. 5.2. Particle in dual tree (PIDT) PIDT augments each particle by a boolean flag moved ∈ {(cid:62),⊥} ("has moved already" (cid:62) and "has not not moved yet" ⊥) and maps each particle onto a vertex of the spacetree, i.e. XPIDT : M (cid:55)→ T (d). The particle update then reads as as Algorithm 2 and integrates into any tree traversal preserving (3) (Figure 5). For efficiency reasons, the particle loops in enterCell and leaveCell can be merged for leaf cells. Theorem 5.2. Whenever touchVertexFirstTime is invoked on a vertex v and all its preamble operations have terminated, all particles within the dual cell of v have a position covered by this dual cell. Proof. The proof follows the proof of Theorem 5.1. Again, parallel PIDT is straightforward. Whenever the grid traversal has in- voked touchVertexLastTime on one parallel rank for a vertex, each particle of this vertex falls into one of four categories: • It is to be lifted but the vertex does not belong to the coarsest level on the local rank. These particles are neglected by the parallelisation as the 14 (cid:46) i.e. all surrounding cells are refined (cid:46) preamble if c refined then (cid:46) preamble moved(m) ← ⊥ end for if v refined then for all m ∈ M associated to v do end if invoke application-specific operations if moved(m) = ⊥ and x(m) contained in c then for all 2d adjacent vertices v do for all m ∈ M associated to v do identify child vertex v(cid:48) whose dual cell holds x(m) assign m to v(cid:48) Algorithm 2 Particle-in-dual-tree algorithm (continued in Algorithm 3). 1: function touchVertexFirstTime(v) 2: 3: 4: 5: 6: 7: 8: end function 9: function enterCell(cell c ∈ T ) 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: end function end if invoke application-specific operations if c unrefined then for all 2d adjacent vertices v do for all m ∈ M associated to v do end if invoke application-specific operations if moved(m) = ⊥ ∧ x(m) contained in c then update position x of m moved(m) ← (cid:62) (cid:46) drop (cid:46) move end if end for end for end if end for end for particle is lifted locally with touchVertexLastTime being called bottom-up throughout the traversal. • It is to be lifted and the vertex is adjacent to the coarsest cell held by a rank. Such a particle is sent to the rank's master node where it is received in the same iteration prior to the master's leaveCell. • It belongs to the vertex's dual cell and intersects the local domain. Such a particle already is assigned to the correct vertex and skipped. • It belongs to the vertex's dual cell but it is not covered by the local domain. In the latter case, the particle is removed from the local vertex and sent to the respective destination rank merging all received particles into the local vertices prior to touchVertexFirstTime in the next tree traversal. The data flow from workers to masters is aligned with the tree topology on P. This data flow comprises only particles that have to be lifted between the coarsest worker cell and its parent residing on the master. It is synchronised with the tree traversal. The drop mechanism also uses synchronous particle exchange 15 end if end for end for invoke application-specific operations for all 2d adjacent vertices v do for all m ∈ M associated to v do (cid:46) epilogue if moved(m) = (cid:62) ∧ x(m) contained in dual cell of other v(cid:48) adjacent to c then (cid:46) linked-list type reassignment (cid:46) (no tunneling) Algorithm 3 Particle-in-dual-tree algorithm continued from Algorithm 2. 1: function leaveCell(cell c ∈ T ) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: end function 12: function touchVertexLastTime(v) 13: 14: 15: 16: 17: 18: 19: 20: end function if moved(m) = (cid:62) ∧ x(m) not contained within dual cell of v then invoke application-specific operations for all m ∈ M associated to v do (cid:46) epilogue (cid:46) lift (cmp. Figure 2) (cid:46) tunneling assign m to v(cid:48) assign m to parent vertex end if end for whenever a rank descends into a cell not handled locally. The exchange through the vertices follows a Jacobi-style update: particles are sent away in one traversal and received prior to touchVertexFirstTime of the subsequent traversal. That is convenient, as the particle lift and drop are split among two tree traversals. The latter data exchange is asynchronous and can be realised in the background in parallel to the tree traversal. 5.3. Remarks While PIT and PIDT realise the same fundamental ideas, they differ in code complexity and the handling of not-tunneling particles. If particles do not tunnel but move from one cell to a neighbouring cell, PIT moves them up in the tree one level and down one level. PIDT exchanges them directly mirroring linked-list techniques. This pattern applies in a multiscale sense for PIDT. PIDT thus is a multiscale linked-list approach, where its "radius of operation" is twice the grid width. It is expected to have fewer lifts and drops compared to PIT. Contrary, PIDT's higher algorithmic complexity mirrors directly to a more complex code. While this might not influence the runtime, the redundant check of particles does: we need a flag moved to mark updated particles which might double the number of particle loads, i.e. memory accesses. Finally, we antedate experimental insight. Both algorithms suffer from a synchronisation of masters and workers. Workers cannot start their tree traver- sal prior to their master having entered the parent cell, as particles might drop from coarser resolution levels. Masters cannot continue their tree traversal be- fore the workers have finished, as particles might have to be lifted from finer resolution levels. Both synchronisation points introduce a latency and a band- width penalty and make perfectly balanced load a must. The bandwidth penalty scales with the number of particles to be exchanged. It is hence less significant 16 for PIDT than for PIT. Both master-worker and worker-master communication describe a global all-to-all communication that is realised as tree communica- tion. We state that the resulting global synchronisation were needless if no particles would be lifted or dropped. 5.4. Restriction-avoiding PIDT (raPIDT) To identify cases where we could skip the global communication, we intro- duce a marker vmax : T (cid:55)→ R+ 0 . On any leaf of the spacetree, vmax shall hold the maximum velocity component of all particles associated to the 2d adjacent vertices. vmax is a cell-based value though it results from vertex-associated data. It is the maximum norm of all velocity components of all particles contained within the 2d dual cells intersecting the current cell. This value is determined by leaveCell in each traversal. On a refined cell, we update the value with vmax(c) ← max{vmax(c(cid:48)) : c(cid:48) (cid:118)child of c}. (4) Here, vmax(c) is an analysed tree attribute [11] (re-)computable on-the-fly. Given any spacetree cell of width h = 3−level, the time step size ∆t and a correct vmax, we know that no particles will be removed from this cell or any of its children and successors due to lifts if all particles contained have a velocity smaller than h/∆t. We can check this due to vmax. We augment PIDT with the following mechanisms: • Each rank holds a boolean map for all its workers. • On enterCell for a cell deployed to a worker, we first update the local vmax due to all particles dropped into this cell. • The updated vmax ≤ h/∆h identifies a priori whether particles will be lifted again from the remote subtree. We store this information within the local boolean map. • We then continue with PIDT, i.e. start up the remote rank. • On leaveCell on the respective deployed cell, we have two opportunities: 1. If lifts are to be expected, we receive all particles from the worker, redetermine (4) and continue. 2. If no lifts are to be expected, we continue with the tree traversal without waiting for any worker data. The reduction is avoided. The receive branch is mirrored with the same rules on the worker to ensure that no worker sends data in the reduction-avoiding case at all. 17 6. Results Our case studies were executed on SuperMUC at the Leibniz Supercomput- ing Centre and the N8 Polaris system at Leeds. SuperMUC hosts Sandy Bridge E5-2680 processors clocked to 2.3 GHz, Polaris hosts Sandy Bridge E5-2670 pro- cessors at 2.6 GHz plus Turbo Boost. Both have two eight-core processors per node. SuperMUC runs Intel MPI 4.1, and every 8192 cores (512 two-processor nodes) are called an island and are connected via a fully non-blocking Infiniband network. Beyond that core count, SuperMUC relies on a 4:1 blocking network. Polaris runs Open MPI 1.6.1, and every 192 cores are fully non-blocking con- nected to one Mellanox QDR InfiniBand switch. Beyond that core count, Polaris realises 2:1 blocking. Our code relies on good, i.e. close to optimal, placement, i.e. it uses as few switches as possible. All performance data is specified as particle updates per second, all machine sizes are specified in cores. For the performance tests, we remove the PDE solver part as well as the interplay of particles and grid, and thus focus exclusively on the particle han- dling. The appendix presents a real-world run. We study worst-case setups where the particle handling's performance characteristics are not interwoven with other application phases. Yet, we artificially impose, where highlighted, a fixed number of 0, 128, 256, 1024 or 4096 floating point operations (flops) onto each particle move to quantify the impact of arithmetics on the runtime. All particles are initially placed randomly and homogeneously within the unit square (0, 1)d ⊂ Rd or a subdomain (0.1, 0.1)d ⊂ (0, 1)d. The total number of particles results from the particle density ρparticles within the initially popu- lated area. Each particle is assigned a random velocity 0 ≤ v ≤ 1 uniformly distributed (Figure 1). This way, we make the characteristic particle movement per step depend only on one quantity -- the time step size. A confusion with particle-grid mapping in the PIC blueprint of Section 3 is out of question as we neglect the PDE. We hence write ρ = ρparticles. Time step size ∆t and the maximum number of particles per cell (ppc) both determine the particle move- ment/tunneling and the grid structure. Whenever the given ppc is overrun in a particular spacetree cell, this cell is refined and the particles are hence sorted into the new spacetree nodes. This mirrors dynamic adaptivity assuming that the particle density correlates to the smoothness of E in (1). Whenever multiple children of one refined spacetree node can be coarsened without violating the ppc constraint, we remove these children and lift the particles into the formerly refined cell. All experimental code supports dynamic AMR. All experiments apply reflecting boundary conditions at the border of the unit square or cube, respectively, but do not change the particle velocities otherwise. All experimen- tal data result from a code with a static domain decomposition deriving P from the spacetree due to graph partitioning. The experiments are, if not stated oth- erwise, stopped after few time steps and thus do not suffer (significantly) from ill-balancing. All domain decomposition/initialisation overhead is removed from the measurements. With all these parameters at hand, we can study the impact of total particle count relative to the computational domain, we can study setups with extremely 18 inhomogeneous particle distribution vs. homogeneous particle distributions, we can analyse the impact of the ratio of particle speed to minimal grid size, and we can study the interplay of particle density, ppc and time step size. 6.1. Algorithmic properties Figure 6: Lifts per particle per time step (ppc=1000). Left column: particles are homo- geneously distributed among the unit square (d = 2). Right column: particles are initially homogeneously distributed in (0, 0.1)3 ⊂ R3, i.e. the grid is dynamically adaptive. Results from ten random initial setups (blurry) with averages as solid lines. No lifts are observed at all for ∆t ≤ 10−3. Prior to measuring the runtime, we focus on the lift behaviour for different setups and count the average number of lifts per particle during the first 50 time steps. Drop observations deduce from these. All measurements are almost independent of (sufficiently big) ρ -- here set to 107. If a particle is lifted n levels up in the spacetree, we count this as n independent lifts. When we fix ppc (ppc=1000 in Figure 6, e.g.), we observe that the number of lifts remains de facto invariant throughout the simulation for a globally homogeneous particle distribution. For an inhomogeneous initial distribution, lifts occur only sporad- ically (unless the time step size is very large), i.e. the average number of lifts is below one. For both realisation variants, the number of lifts scales with the time step size, i.e. the bigger the time step size the more lifts per particle, while PIT yields significantly more lifts than PIDT. If the time step sizes underrun a certain threshold, PIDT comes along completely without lifts while PIT has a very low lift count. 19 01020304050time step0.00.51.01.52.02.53.0#lifts/particlePIT, 2d, (0.0,1.0)2, ppc=1000∆t=10−2∆t=10−1∆t=10−001020304050time step0.00.51.01.52.0#lifts/particlePIT, 3d, (0.0,0.1)3, ppc=100001020304050time step0.00.10.20.30.40.50.60.70.80.9#lifts/particlePIDT, 2d, (0.0,1.0)2, ppc=100001020304050time step0.00.20.40.60.81.01.21.41.6#lifts/particlePIDT, 3d, (0.0,0.1)3, ppc=1000 If we fix in turn the time step size and make ppc a free parameter (see Appendix B), we observe that any ppc yields, on average, time-independent behaviour for homogeneous setups. The bigger ppc the fewer lifts, and the num- ber of lifts per particle is always bigger for PIT than for PIDT where the number of lifts is negligible for reasonably big ppc or coarse grids, respectively. Larger ppc make each leaf represent larger geometric domains and thus explain the ppc dependence. If the particle distribution is inhomogeneous, the correspond- ing grid at setup time is strongly adaptive if ppc is reasonably small. Initial time steps of PIDT then face almost no lifts; similar as in the homogeneous setup. However, the number of lifts increases as the grid becomes more regular (and coarser), and the particles distribute more homogeneously, until the lift count drops again to its regular characteristics. With increasing ppc the curve flattens out and shifts to the right. Due to the invariant velocity profile besides the reflecting boundary con- ditions, particles are expelled from the subarea by the large (electric) field. Therefore, the global grid determined by ppc becomes coarser and more regular (Figure 1). It smoothens out. As a consequence, subtrees of a certain depth hold more and more particles with velocities of the same magnitude. In return, the average particle density within each cell decreases. The further (fast) parti- cles move away from the initially dense area, the more often they hit adaptivity boundaries, i.e. hanging nodes. PIDT has to lift them there. For PIT, these additional lifts make almost no difference compared to the lifts required anyway. Particles hit adaptivity boundaries often if ppc is small. As the grid smoothens out, also the lift counts drop. Referring to real-world runs (Appendix A), such a behaviour mirrors a setup where initially all particles are held within the subarea where the solution to (1) depending on the particle density is non-smooth and yields large particle accelerations. The push out from this area then results from a mixed neutralising positively charged background and negatively charged particles. 6.2. Memory throughput Table 1: Stream particle throughput, i.e. particles per second, for different particle counts p using 1,2,4,12,16 cores or 16 cores plus hyperthreading (32) on SuperMUC. The upper section gives results for d = 2, the lower for d = 3. Best case throughputs per row are bold. p 104 105 106 107 108 104 105 106 107 108 1 3.03 · 107 6.66 · 107 7.03 · 107 7.14 · 107 7.17 · 107 2.48 · 107 5.11 · 107 4.93 · 107 5.40 · 107 5.41 · 107 2 2.98 · 107 1.03 · 108 1.16 · 108 1.25 · 108 1.26 · 108 3.22 · 107 8.43 · 107 9.15 · 107 9.30 · 107 9.33 · 107 4 4.14 · 106 1.35 · 108 1.58 · 108 1.63 · 108 1.68 · 108 3.25 · 107 1.14 · 108 1.18 · 108 1.24 · 108 1.25 · 108 8 2.46 · 107 1.06 · 108 1.56 · 108 2.44 · 108 2.28 · 108 2.39 · 107 1.23 · 108 1.73 · 108 1.82 · 108 1.65 · 108 12 1.46 · 107 8.96 · 107 2.25 · 108 2.63 · 108 2.65 · 108 2.42 · 107 7.67 · 107 1.81 · 108 1.77 · 108 1.84 · 108 16 2.21 · 107 1.02 · 108 2.41 · 108 2.42 · 108 2.84 · 108 2.27 · 107 2.44 · 107 1.94 · 108 1.63 · 108 1.92 · 108 32 1.94 · 107 6.15 · 107 5.51 · 107 7.99 · 107 2.59 · 108 1.44 · 107 2.43 · 107 4.56 · 107 9.24 · 107 1.65 · 108 To be able to put runtime measurements into context, we first run a bench- mark holding an array of particles that is iterated once per time step without 20 any grid. Each particle position is updated according to an explicit Euler inte- gration step, it is reflected at the domain boundaries, and the resulting position is written back to the corresponding array position. Besides the position update, no computation or assignment to grid entities is done and no data is reordered. The implementation is the same source code fragment we use in the spacetree algorithms. As we aim to compare it with our parallel implementation running multiple MPI ranks per node, we parallelise this embarrassingly parallel bench- mark with a plain parallel-for along the lines of the Stream benchmark [18]. This yields upper bounds, as our spacetree implementation relies on MPI only and thus has message passing overhead. We analyse the throughput behaviour at hands of SuperMUC (Table 1). Polaris exhibits qualitatively the same behaviour. On both systems, a single core cannot exploit the memory subsystem alone. The bigger the particle count the more cores can be used effectively and the higher the throughput. However, the throughput does not scale linearly with the core count due to bandwidth restrictions. 3.00 · 108 for d = 2 and 2.00 · 108 for d = 3 are upper bounds for the throughput of our particle codes in the absence of any solver, i.e. of any 'real' computation, on SuperMUC. On Polaris, these best case thresholds have to be doubled due to the higher clock rate and the Turbo Boost. Besides for small particle numbers, less than eight threads/ranks per node do not make the nodes run into bandwidth saturation. As a consequence, all parallel experiments deploy six MPI ranks per node from hereon. This heuristic choice valid for both SuperMUC and Polaris yields a reasonable core usage while memory subsystem effects are not dominant. It also anticipates that the presence of a grid to maintain increases the average per-particle memory footprint. 6.3. Single core results We next measure the particle throughput for homogeneous and inhomo- geneous start scenarios with different ∆t on a single core with 107 particles for 50 time steps, while we still neglect arithmetics per particle (Figure 7). PIT's throughput monotonously increases with increasing reasonable ppc. It decreases with increasing time step size. Any reduction of lifts due to a bigger ppc or smaller time step sizes pays off for a homogeneous start setup. For an inhomogeneous start setup, we observe a decreasing performance with bigger time step sizes as the grid then changes faster. This picture would change if we fixed the simulation time rather than the time step count. PIDT is typically outperformed by PIT due to the more complicated algorithm despite in situa- tions where particles move very fast in an adaptive setting. ppc ≈ 1000 here yields the best throughput. Polaris and SuperMUC results do coincide if scaled with the clock rate, i.e. the duplication of throughput rates on Polaris cannot be observed again. Hardware counter measurements with Likwid [26] reveal that cache misses for both approaches are negligible. They resemble exactly the results reported in [1, 29, 32] and references therein for other application areas. Our algo- rithms' AMR code base Peano [31] relies on a depth-first alike tree traversal [30] that picks up Holder continuity properties of the Peano space-filling curve 21 Figure 7: Single core throughput with homogeneous (left) or inhomogeneous/breaking dam (right) start conditions for PIT (top) and PIDT (bottom). d = 2 marked by solid lines and d = 3 by dashed lines. Figures compare impact of ppc choice on throughput for regular (homogeneous) and dynamically adaptive (breaking dam) grids. Results from SuperMUC. [32]. This implies advantageous spatial and temporal memory access charac- teristics. However, we expect a reimplementation with another code base to yield advantageous properties as well, as all PIC and PIDT ingredients follow a strict element-wise/local formulation and as the memory subsystem in above measurements is underutilised. A slight increase of cache misses thus does not neccessarily pollute runtime results significantly, if proper prefetching is applied, while the basic memory usage profile is advantageous since all operations are local -- either accessing neighbours or parents/children within the grid. There is a sweet spot from which it pays off to use PIDT rather than PIT. This payoff point depends on time step size and ppc. For sufficiently big time steps and reasonable small ppc, PIDT outperforms PIT. This is due to the reduction of lift operations, i.e. due to PIT having more particles tunneling. PIT is around a factor of three slower than the pure particle throughput on a single core if ∆t is very small. PIDT is around a factor of 3d slower due to the particle sorting overhead. The remainder of the experiments runs all settings for ∆t = 10−4 as this is an interesting regime where PIT has not yet overtaken PIDT for the majority of experiments. Putting runtime evaluations into relation to the number of lifts always allows us to predict properties of all particle handling algorithms. The remainder of the experiments also restricts to homogeneous settings, i.e. the particles initially are distributed homogeneously among the computational domain, as particle characteristics then remain invari- 22 101102103104105106107ppc104105106107108#particles/sPIT, (0.0,1.0)d∆t=1.0e-02, d=2∆t=1.0e-02, d=3101102103104105106107ppc104105106107108#particles/sPIT, (0.0,0.1)d101102103104105106107ppc104105106107108#particles/sPIDT, (0.0,1.0)d∆t=1.0e-06, d=2∆t=1.0e-06, d=3101102103104105106107ppc104105106107108#particles/sPIDT, (0.0,0.1)d∆t=1.0e-04, d=2∆t=1.0e-04, d=3 ant. Putting runtime evaluations into relation to the number of characteristic ppc allows us to predict properties of simulations where the computational do- main comprises different spatial regions with different particle distributions. 6.4. Parallel PIT Figure 8: Parallel throughput of PIT. Each plot studies three different total particle numbers (different markers) for one fixed ppc and dimension d. Each particle study is ran five times with 0, 128, 256, 1024 or 4096 flops per particle. The brighter the points the higher the number of flops. The saturated points with a solid line are measurements without any compute flops per particle, i.e. solely the particle move and resort into the grid. Different colours here pick up the colouring from Figure 9 and PIDT experiments. We start our parallel studies with PIT and artificially perform an additional 0, 128, 256, 1024 or 4096 floating point operations per particle to emulate the solving of a PDE and to be able to study the impact of this additional workload on the particle performance. Each experiment hence was performed five times. Four properties become apparent from measurements on SuperMUC (Figure 8): First, the more computation is done per particle the lower the throughput, but this difference almost vanishes for high core counts. Second, the throughputs for d = 2 and d = 3 approach each other for high core counts. Third, PIT's 2d scaling is close to linear up to a given threshold. For d = 3, the results are rougher, but a similar threshold is hit for higher core counts. If the core count exceeds this threshold, the throughput stagnates. Fourth, the more particles the 23 16642561024cores107108109#particles/sSuperMUC, 2d, ppc=100, with flops#particles=1.0e+07#particles=1.0e+08#particles=1.0e+0916642561024cores107108109#particles/sSuperMUC, 3d, ppc=1000, with flops16642561024cores107108109#particles/sSuperMUC, 2d, ppc=1000, with flops16642561024cores107108109#particles/sSuperMUC, 3d, ppc=10000, with flops lower the parallel efficiency. Eventually, PIT does not scale for 109 particles. We observe an inverse weak scaling with respect to particle numbers. The behaviour results purely from the particle handling, as the synchronisa- tion of the grid along subdomain boundaries is neglectable due to our realisation from [22]. Any master has to wait for all its workers before it may ascend, as the workers might lift particles. Any node triggers its send to its master after the traversal of its local domain has finished. This is a partial synchronisation of the ranks and a blocking data exchange realising a reduction. The latter is sensitive to latency and bandwidth restrictions. As master-worker data exchange prelude or follow the actual local particle handling, the computational work per particle does influence the runtime, as it cannot overlap with the communication. The fewer computation to be done, however, i.e. the more cores participate in the computation, the lower the impact of this work and the more severe communi- cation bounds. As the logical master-worker tree topology is broader for d = 3 than for d = 2, the synchronisation runtime pressure at the workers is higher for d = 3. As latency is critical for the global reduction and its counterpart when we start up the cores and drop particles, latency dominates the runtime if "too" many cores collaborate. The performance then stagnates. As bandwidth is critical for the master-worker data exchange, more particles slow down the reduction phase and its startup counterpart. PIT scales only in a very limited parameter regime. Figure 9: Results from Figure 8 without any additional flops rerun on Polaris. The marker size/colour identifies the ppc, while circles plot 107 particles and triangles 108 particles. Ver- tical lines mark whenever the ports of one switch layer theoretically are exceeded. In practice, more switches are used for lower (small) core counts already. Basically, its scaling is determined by the hardware characteristics plus the tight synchronisation. This effect becomes evident for the same experiments on Polaris (Figure 9). Polaris exhibits slightly better results for moderate core counts. However, the throughput drops whenever the core count requires the su- percomputer to employ another level of switches. Due to a good placement that anticipates broken or overbooked nodes, the resulting performance drops appear slightly prior to the theoretical switch capacity. Notably, the more restrictive network topology introduces an inverse weak scaling effect for a high core count 24 16642561024cores107108109#particles/sPolaris, 2d, no flops16642561024cores107108109#particles/sPolaris, 3d, no flopspcc=10000pcc=1000pcc=100 to particles ratio, where an increase of cores introduces a degeneration of the throughput due to increased communication/synchronisation pressure. 6.5. Parallel PIDT Figure 10: Parallel throughput of PIDT for SuperMUC (left) and Polaris (right). The darker the dots the fewer flops are added to each particle. Solid lines are worst case setups with no computation per particle besides position updates. The bigger the marker the bigger ppc ∈ {102, 103, 104} (blue,green,red). All marker types pick up conventions of the other plots. We next rerun all experiments for PIDT and compare the outcomes to the PIT results. Three differences become apparent (Figure 10): First, the impact of the operations per particle diminishes. Yet, lower arithmetic intensity still 25 16642561024cores107108109#particles/sSuperMUC, 2d, #particles=1.0e+0716642561024cores107108109#particles/sPolaris, 2d, #particles=1.0e+0716642561024cores107108109#particles/sSuperMUC, 2d, #particles=1.0e+0816642561024cores107108109#particles/sPolaris, 2d, #particles=1.0e+0816642561024cores107108109#particles/sSuperMUC, 3d, #particles=1.0e+08ppc=1.0e+04ppc=1.0e+03ppc=1.0e+0216642561024cores107108109#particles/sPolaris, 3d, #particles=1.0e+08 means higher throughput. Second, PIDT inherits its lower throughput com- pared to PIT for low core counts. It still is slower. Third however, PIDT scales better than PIT if the number of particles is reasonably big and ppc is small. There still is a stagnation threshold, but this threshold is higher than for PIT, i.e. PIDT overtakes its sibling algorithm for a decent core count. The improvement of PIDT compared to PIT stems from the fact that PIDT exchanges particles both via master-worker relations and along subdomain bound- aries. The exchange along these boundaries can be realised asynchronously. This allows PIDT to hide computations behind non-blocking MPI calls. Such a hiding is the more effective the more computational workload per particle. However, it also depends on the dimensionality as the domain boundary is a d − 1-dimensional submanifold. Still, PIDT restricts data along the spacetree each iteration and thus is vulnerable to latency effects. However, the actual number of lifts along the master-worker hierarchy is significantly smaller than for PIT and thus attenuates the impact of bandwidth constraints. Big ppc make the underlying spacetree more shallow and thus counteract to this effect while small ppc lead to deep spacetrees where boundary data exchange and parallel domain handling gain weight in the total runtime profile. 6.6. raPIDT Figure 11: Parallel throughput of PIDT (left) and raPIDT (right) on Polaris. 26 16642561024cores107108109#particles/sPolaris, 2d, ppc=100, with flops16642561024cores107108109#particles/sPolaris, 2d, ppc=100, with flops#particles=1.0e+07#particles=1.0e+08#particles=1.0e+0916642561024cores107108109#particles/sPolaris, 2d, ppc=1000, with flops16642561024cores107108109#particles/sPolaris, 2d, ppc=1000, with flops Figure 12: Scaling results for ppc=100 regarding different time step sizes for d = 2 (top) and d = 3 (bottom). PIT (left) is outperformed by raPIDT (right) while both approaches profit from decreasing time step sizes. Large core count measurements become dominated by network effects that eventually stop any scaling for both approaches on Polaris as opposed to Figure 13. raPIDT tackles the reduction challenge of our particle management, i.e. skips them if possible, and thus yields improved throughput rates for the previously studied setups (Figure 11) where the time step size is kept constant. It makes the PIDT idea to yield throughput rates comparable to PIT. Notably, it weakens the impact of the network topology. An interpretation of raPIDT on a bigger core scale requires us to empha- sise how the scenario properties normalise experiment parameters. Due to ppc, we control the particle density per spacetree cell, while the total particle count determines the spacetree depth, i.e. the cell sizes. Since we standardise the do- main to the unit square or cube, prescribe the time step size and have a uniform √ velocity distribution, the relative velocity of particles to cell sizes scales with the total particle count by roughly d #particles. An increase of the particle count induces an increase of the particles' velocity. While a study of weak scaling with respect to particles in Section 6.4 and 6.5 is reasonable to understand al- gorithmic properties, our subsequent performance studies focus on weak scaling where the overall computational domain is successively increased. To enable use to compare results with previous results, we stick with the unit length domain but decrease the time step size when we increase the particle count. 27 166425610244096cores106107108109#particles/sPolaris, PIT,2d1.0e+08, ∆t=1.0e-031.0e+08, ∆t=1.0e-04166425610244096cores106107108109#particles/sPolaris, raPIDT,2d1.0e+07, ∆t=1.0e-021.0e+07, ∆t=1.0e-031.0e+07, ∆t=1.0e-04166425610244096cores106107108109#particles/sPolaris, PIT,3d2.0e+07, ∆t=1.0e-032.0e+07, ∆t=1.0e-042.0e+07, ∆t=1.0e-05166425610244096cores106107108109#particles/sPolaris, raPIDT,3d4.0e+07, ∆t=1.0e-044.0e+07, ∆t=1.0e-054.0e+07, ∆t=1.0e-06 Figure 13: Experiments from Figure 12 for different particle counts rerun on SuperMUC. Once we apply this normalisation, we observe that raPIDT outperforms PIT (Figures 12 and 13) for reasonable big time step sizes. For small time step sizes (relative to the particle count, i.e. the grid structure), both perform with the same throughput. raPIDT is more robust than PIT on Polaris (Figures 12). The d = 3 throughput is lower than the two-dimensional counterpart for both setups, as the typical grid structure for fixed ppc differs. If we normalised with respect to the grid depth, d = 2 and d = 3 yield similar results. On SuperMUC, the 4:1 blocking topology for more than 8192 cores stops both variants to pass the 1010 particles per second threshold and makes the throughput stagnate or degenerate. raPIDT here does not perform significantly more robust than PIT. 7. Comparison with other algorithms We finally compare PIT, PIDT and raPIDT to alternative implementations. Ob- viously, only alternatives that support both tunneling and dynamically adaptive grids candidate. The most prominent class of spacetree AMR codes is the fam- ily of spacetree algorithms that rely on space-filling curves for the partitioning [1, 8, 15, 20, 21]. Textbook variants of SFC codes typically hold information about their subpartitioning on each rank -- they basically store where the SFC's preimage is cut into pieces. Each rank's tree construction starts from its lo- cally owned cells, i.e. the cells in-between the rank's start index and its end 28 3212851220489102cores1061071081091010#particles/sSuperMUC, PIT,2d1.0e+08, ∆t=1.0e-031.0e+08, ∆t=1.0e-043212851220489102cores1061071081091010#particles/sSuperMUC, raPIDT,2d1.0e+09, ∆t=1.0e-041.0e+09, ∆t=1.0e-051.0e+09, ∆t=1.0e-063212851220489102cores1061071081091010#particles/sSuperMUC, PIT,3d2.0e+09, ∆t=1.0e-042.0e+09, ∆t=1.0e-052.0e+09, ∆t=1.0e-063212851220489102cores1061071081091010#particles/sSuperMUC, raPIDT,3d4.0e+09, ∆t=1.0e-054.0e+09, ∆t=1.0e-064.0e+09, ∆t=1.0e-07 index along the SFC. From hereon, the rank constructs the local spacetree in a bottom-up manner: if a cell is held by a rank, also its parent is held by this rank which yields, on coarser levels, a partial replication. Detailed comparisons to the present Peano approach used in our PIT and raPIDT implementation can be found in [30]. If the cuts along the SFC are known, it is possible due to the SFC code [30] to compute per particle the preimage of their position, i.e. an index along the SFC. This immediately yields the information which rank holds a particle. One thus can send any particle directly to the right rank after the move. Though our implementation base relies on a space-filling curve as well [22, 29, 31, 32], it does neither exhibit curve information to the application nor does it hold information about the global partitioning on any rank. However, we can man- ually expose this information to the ranks and thus reconstruct a SFC-based implementation. This allows us to compare an SFC-based code directly to the present alternatives: Our implementation using SFC cuts runs through the grid and moves the particles as for PIT. Whenever a particle leaves the local domain, we move it into a buffer. For each rank, there's one buffer. Upon termination of the local traversal, all buffers are sent away. As there is no information available whether particles tunnel, each rank then has to wait for a notification from all other ranks. Though this is a global operation, our implementation follows [25] and realises it with point-to-point exchange. If one rank finishes prior to other ranks, the in-between time is then already used for data exchange. Throughout our experiments, any overhead to maintain the global decomposition data is neglected, i.e. we restrict purely to the particle sorting. However, we emphasise that a rank receiving particles does not hold any additional information about the particle position, i.e. where within the local domain it has to be inserted. We thus rely on the drop mechanism. Comparisons to a direct insert based upon SFCs again (the particle's cell is identified due to the preimage and inserted right into the correct cell) show that both variants yield comparable results. This is an important difference to PIT and PIDT as the latter schemes encode remote sorting information implicitly within their send order. A second competing idea is the sieve approach from [4]. Different to SFCs, it comes along without global domain decomposition knowledge. Each rank collects all particles that leave its domain. Again, we rely on local buffers. These sets of particles then are passed around between the ranks cyclically. Each rank extracts the particles falling into its domain. It sieves and then passes on the array. We distinguish two variants to sort particles into the local grid if we receive a set of particles from the neighbour node: in one variant (sieve & drop), we rely on PIT's drop mechanism. In a second variant, we use the local SFC information to sort the received particles directly into the correct cells. Besides the alternative variants, we also compare PIT, PIDT and raPIDT to a plain linked-cell algorithm. For the latter, we use a modified PIDT code. The velocity profile is chosen such that no particle may tunnel. As a consequence, we manually switch off all multiscale checks, and we, in particular, skip any master-worker or worker-master communication. Such a test is thus a valid 29 Figure 14: Comparison of different solvers for small core counts and characteristic setups with ppc=100, ∆t = 10−2 (top left), ppc=100, ∆t = 10−3 (top right), ppc=100, ∆t = 10−4 (bottom left). ppc=10, ∆t = 10−4 for d = 3 (bottom right) illustrates a regime where all algorithms yield comparable results because of a low particle density. All experiments are ran with 106 particles. setup to quantify the overhead introduced by the tunneling for the present software independent of the quality of implementation. No software ingredient is particular tuned and all codes rely on the same ingredients where possible. All setups rely on exactly the same domain decomposition, i.e. balancing differences are eliminated. We reiterate that PIDT is faster than PIT for big time step sizes of ∆t = 10−2 (Figure 14). However, each run with the linked-cell approach remains faster though the performance gap closes with increasing core counts. Neither our SFC-cut nor our sieve implementations can cope with these results. How- ever, they always scale better. For sufficiently big ∆t, they eventually close the performance gap. If we reduce the time step size, there is a sweet spot where PIT becomes faster than PIDT as well as the linked-cell approach (visible here only for d = 3). Still, the sieve algorithm yields significantly lower throughput. The SFC-based variants are slower, too. The differences between PIT and PIDT have been discussed already. Our experiments validate, for most setups, statements from [4] that observe that all variants supporting tunneling are slower than a pure linked-cell like code. However, both PIT and PIDT reduce this runtime difference significantly. This is insofar interesting, as PIT exhibits similarities to the up down tree algorithm from [4] which is reported to be even slower than sieve. Sieve suffers from a 30 16326496128192cores103104105106107108#particles/sPolaris, d=216326496128192cores103104105106107108#particles/sPolaris, d=216326496128192cores103104105106107108#particles/sPolaris, d=216326496128192cores103104105106107108#particles/sPolaris, d=3pitpidtrapidtsfc-cutssieve & sortsieve & droplinked cell global communication phase after each iteration where the length of the phase (number of data exchange steps) increases with more ranks participating. It thus cannot scale. PIT circumnavigates such a global data exchange phase. While the SFC-cut implementation scales and allows all the ranks to process their local grid asynchronously, it still runs into a synchronisation phase, as each rank has to wait per time step for every other rank for notification. This point-to-point synchronisation determines the performance, since we found no significant runtime difference when we studied whether a drop mechanism for local sorting or the direct application of SFC indices yields better results for SFCs. PIT and PIDT are able to spread all data transfer more evenly accross the executation time than their competitors. It is in particular interesting that PIT manages to outperform the linked-cell approach for very small time steps and d = 3 with small ppc, i.e. a deep spacetree. This results from the fact that particles within a cell are not sorted and few particles cross the cell faces per time step. Obviously this is an unfair competition: as no neighbourhood information is available in PIT (different to PIDT where we have half a cell overlap), no particle-particle interaction can be realised. PIT is designed for particle-mesh interaction only. Our SFC implementation was able to compete with PIT and PIDT only for small core counts and deep spacetree hierarchies. For bigger core counts, the SFC's behaviour resembles the sieve algorithm which results from the global communication phase found there, too. We emphasise that the whole runtime picture might change if the grid were regular, if the grid were not fixed prior to the particle sorting, i.e. if we could create the grid depending on the particles without persistent grid data, or if we translated our reduction-avoiding mechanism from raPIDT into the SFC world. The latter would yield a higher asynchronity level and remove a global SFC communication phase. 8. Conclusion and outlook We introduce three particle management variants facilitating solvers that have to resort particles into an existing dynamically adaptive Cartesian grid frequently and can run into tunneling. Particle in tree (PIT) holds the particles within the tree, i.e. the cells of a multiscale adaptive Cartesian grid, and lifts and drops the particles between the levels to move particles in-between cells. Particle in dual tree (PIDT) stores the particles within the vertices, i.e. switches to a dual grid, and thus fuses ideas of a tree-based particle management with a multiscale linked-list paradigm. Particles either can move up or down within the (dual) tree or directly into neighbouring cells. The latter works on any level of the multiscale grid. raPIDT finally augments PIDT by a simple velocity analysis. This analysis labels regions where no particle is moved in-between certain grid levels in the subsequent time steps. This allows us to eliminate reductions within the tree locally. Comparisons of the straightforward PIT with the dual grid strategy PIDT reveal that no scheme is superior to the other schemes by default. For small problem setups with slowly moving particles, PIT yields higher performance 31 than PIDT. For big problem setups or fast particles, there is a sweet spot where the higher code complexity of PIDT pays off. Particular interesting is the fact that raPIDT picks up advantages of linked cell strategies, i.e. asynchronity of the ranks and exchange of data in the background, while arbitrary tunneling still is enabled. This might make it a promising candidate for the upcoming massively parallel age. It is also not surprising that the particle throughput depends on differences in the hardware characteristics. High clock rates pay off for moderate particle counts. For high core counts, topology properties of the interconnection network outshine clocking considerations. Regarding latency effects, raPIDT is more robust than PIT and PIDT. For big core counts and high particle numbers, all variants however continue to suffer from latency and bandwidth constraints introduced by x:1 blocking. Our particle maintenance strategies are of relevance for multiple particle- in-cell (PIC) simulations as well as other particle-grid codes with different al- gorithmic properties. Examples for PIC are plasma processes with shocks or reconnection, global large-scale simulations with multifaceted particle velocity characteristics, or self-gravitating systems whose dynamics imply large parti- cle inhomogeneities. While such setups require substantial investment into the PDE solver, our particle treatment transfers directly. Another example is local particle time stepping where some particles march in time fast and thus might tunnel, while others then follow up with tiny time steps where the reduction skips come into play. It is part of our future work to use the present algorithms in such a context. Of particular interest to us is the fusion with applications that realise implicit schemes or particle-particle interactions. While the former weaken the grid size and, hence, time step constraints -- though we still can make the grid size adapt to fine-scale inhomogeneities of the PDE without algorithmic constraints resulting from the particle velocities -- both increase the arithmetic intensity and thus damp the impact of communication on the scaling. We fur- ther recognise that the dual grid approach allows us to realise any interaction with a cut-off radius smaller than half the grid width without any additional helper data structure such as linked-cell lists or modified linked lists [7, 17]. In this sense, our approach is related to dual tree traversals [3, 28] that also avoid to build up connectivity links. It seems to be important to stress two facts. On the one hand, our lift and drop mechanisms can also be used by particle-interaction kernels to push particles to the "right" resolution level, i.e. a level fitting to their cut-off radius. For complex applications, there is no need to drop particles always into the finest grid all the time. This enables particles suspended within the tree. It is subject of future work with respect to applications with particle-particle interaction to exploit such a multilevel storage. On the other hand, we appreciate how fast linked-list algorithms perform in many applications. In our formalism, they basically induce an overlapping domain topology on top of a given tree distribution. And we recognise that the fastest variants of these algorithms rely on incremental updates of these interaction lists. It is hence a straightforward idea to combine our grammar paradigm plus the particle management with an update of these lists where the grammar eliminates also list updates. 32 Acknowledgements The authors gratefully acknowledge the Gauss Centre for Supercomputing e.V. (www.gauss-centre.eu) for funding this project by providing computing time on the GCS Supercomputer SuperMUC at Leibniz Supercomputing Centre (LRZ, www.lrz.de), as well for the support of the LRZ. This work also made use of the facilities of N8 HPC provided and funded by the N8 consortium and EPSRC (Grant No. N8HPC DUR TW PEANO). The Centre is co-ordinated by the Universities of Leeds and Manchester. Special thanks are due to Bram Reps and Kristof Unterweger for their support on linear algebra and implemen- tation details. Kristof also contributed to make the numerical experiments run. Robert Glas and Stefan Wallner made a major contribution to the maturity and performance of the presented implementations as they used it for their as- trophysics code and thus pushed the development. Bart Verleye was funded by Intel and by the Institute for the Promotion of Innovation through Science and Technology in Flanders (IWT). All underlying software is open source and available at [31]. References [1] M. Bader. Space-Filling Curves - An Introduction with Applications in Scientific Computing, volume 9 of Texts in Computational Science and Engineering. Springer-Verlag, 2013. [2] C. K. Birdsall and A. B. Langdon. Plasma physics via computer simulation. Taylor and Francis, first edition, 2005. [3] W. Dehnen. A hierarchical o(n) force calculation algorithm. J. Computa- tional Physics, 179(1):27 -- 42, 2002. [4] A. Dubey, K. Antypas, and C. Daley. Parallel algorithms for moving La- grange data on block structured Eulerian meshes. Parallel Computing, 37:101 -- 113, 2011. [5] M. Durand, B. Raffin, and F. Faure. A Packed Memory Array to Keep Moving Particles Sorted. In J. Bender, A. Kuijper, D. W. Fellner, and E. Guerin, editors, Workshop on Virtual Reality Interaction and Physical Simulation. The Eurographics Association, 2012. [6] F. Fleissner and P. Eberhard. Parallel load-balanced simulation for short- range interaction particle methods with hierarchical particle grouping based on orthogonal recursive bisection. Int. J. Numer. Methods Eng., 74(4):531 -- 553, 2008. [7] P. Gonnet. A simple algorithm to accelerate the computation of non- bonded interactions in cell-based molecular dynamics simulations. J. Com- put. Chem., 28(2):570 -- 573, 2007. 33 [8] T. Hamada, T. Narumi, R. Yokota, K. Yasuoka, K. Nitadori, and M. Taiji. 42 tflops hierarchical n-body simulations on gpus with applications in both astrophysics and turbulence. In Proceedings of the Conference on High Performance Computing Networking, Storage and Analysis, SC '09, pages 62:1 -- 62:12, New York, NY, USA, 2009. ACM. [9] R. Hockney and J. Eastwood. Computer Simulation Using Particles. Aca- demic Press, 1988. [10] M. Ihmsen, N. Akinci, M. Becker, and M. Teschner. A parallel sph im- plementation on multi-core cpus. Comput. Graph. Forum, 30(1):99 -- 112, 2011. [11] D. E. Knuth. The genesis of attribute grammars. In P. Deransart and M. Jourdan, editors, WAGA: Proceedings of the international conference on Attribute grammars and their applications, pages 1 -- 12. Springer-Verlag, 1990. [12] N.A. Krall and A.W. Trivelpiece. Principles of Plasma Physics. McGraw- Hill, 1973. [13] G. Lapenta. Particle simulations of space weather. Journal of Computa- tional Physics, 231(3):795 -- 821, 2012. [14] G. Lapenta and J.U. Brackbill. Control of the number of particles in fluid and mhd particle in cell methods. Computer Physics Communications, 87(1 -- 2):139 -- 154, 1995. [15] I. Lashuk, A. Chandramowlishwaran, H. Langston, T.-A. Nguyen, R. Sam- path, A. Shringarpure, R. Vuduc, L. Ying, D. Zorin, and G. Biros. A massively parallel adaptive fast multipole method on heterogeneous archi- tectures. Commun. ACM, 55(5):101 -- 109, 2012. [16] S. Li and W. K. Liu. Meshfree and particle methods and their applications. Appl. Mech. Rev., 55:1 -- 34, 2002. [17] W. Mattson and B. M. Rice. Near-neighbor calculations using a modified cell-linked list method. Computer Physics Communications, 119(2-3):135 -- 148, 1999. [18] J. D. McCalpin. Memory bandwidth and machine balance in current high performance computers. IEEE Computer Society Technical Committee on Computer Architecture (TCCA) Newsletter, pages 19 -- 25, 1995. [19] S. J. Plimpton, D. B. Seidel, M. F. Pasik, R. S. Coats, and G. R. Montry. A load-balancing algorithm for a parallel electromagnetic particle-in-cell code. Computer Physics Communications, 152(3):227 -- 241, 2003. 34 [20] A. Rahimian, I. Lashuk, S. Veerapaneni, A. Chandramowlishwaran, D. Mal- hotra, L. Moon, R. Sampath, A. Shringarpure, J. Vetter, R. Vuduc, D. Zorin, and G. Biros. Petascale direct numerical simulation of blood flow on 200k cores and heterogeneous architectures. In Proceedings of the 2010 ACM/IEEE International Conference for High Performance Comput- ing, Networking, Storage and Analysis, SC '10, pages 1 -- 11, Washington, DC, USA, 2010. IEEE Computer Society. [21] R. S. Sampath, S. S. Adavani, H. Sundar, I. Lashuk, and G. Biros. Dendro: parallel algorithms for multigrid and amr methods on 2:1 balanced octrees. In Proceedings of the 2008 ACM/IEEE conference on Supercomputing, SC '08, pages 18:1 -- 18:12, Piscataway, NJ, USA, 2008. IEEE Press. [22] M. Schreiber, T. Weinzierl, and H.-J. Bungartz. Sfc-based communication metadata encoding for adaptive mesh. In M. Bader, editor, Proceedings of the International Conference on Parallel Computing (ParCo), volume 25 of Advances in Parallel Computing: Accelerating Computational Science and Engineering (CSE). IOS Press, October 2013. accepted. [23] H. Shamoto, K. Shirahata, A. Drozd, H. Sato, and S. Matsuoka. Large- scale distributed sorting for gpu-based heterogeneous supercomputers. In Big Data (Big Data), 2014 IEEE International Conference on, pages 510 -- 518, 2014. [24] V. Springel. E pur si muove: Galilean-invariant cosmological hydrodynam- ical simulations on a moving mesh. NMRAS, 401:791 -- 851, 2010. [25] H. Sundar, D. Malhotra, and G. Biros. Hyksort: A new variant of hyper- cube quicksort on distributed memory architectures. In Proceedings of the 27th International ACM Conference on International Conference on Su- percomputing, ICS '13, pages 293 -- 302, New York, NY, USA, 2013. ACM. [26] J. Treibig, G. Hager, and G. Wellein. LIKWID: A Lightweight Performance-Oriented Tool Suite for x86 Multicore Environments. In Pro- ceedings of the 2010 39th International Conference on Parallel Processing Workshops, ICPPW '10, pages 207 -- 216. IEEE Computer Society, 2010. [27] B. Verleye, P. Henri, R. Wuyts, G. Lapenta, and K. Meerbergen. Imple- mentation of a 2D electrostatic particle in cell algorithm in Unified Parallel C with dynamic load-balancing. Computers & Fluids, 80:10 -- 16, 2013. [28] M. S. Warren and J. K. Salmon. A portable parallel particle program. Computer Physics Communications, 87:266 -- 290, 1995. [29] T. Weinzierl. A Framework for Parallel PDE Solvers on Multiscale Adap- tive Cartesian Grids. Verlag Dr. Hut, Munchen, 2009. [30] T. Weinzierl. The Peano software -- parallel, automaton-based, dynamically adaptive grid traversals. Technical Report 2015arXiv150604496W, Durham University, 2015. 35 [31] T. Weinzierl et al. Peano -- a Framework for PDE Solvers on Spacetree Grids, 2012. www.peano-framework.org. [32] T. Weinzierl and M. Mehl. Peano -- A Traversal and Storage Scheme for Octree-Like Adaptive Cartesian Multiscale Grids. SIAM Journal on Sci- entific Computing, 33(5):2732 -- 2760, October 2011. Appendix A. Validation Figure A.15: Electric field spectrum in the wavevector-frequency plane (k1, ω), at k2 = 0. The colors range from white (low signal) to black (high signal). The red dashed line shows the theoretical Langmuir wave dispersion relation obtained from the Vlasov-Poisson theory. As validation of our PIC implementation -- which is independent of the choice of PIT or PIDT -- we study a thermal plasma at rest, and we confirm that our code retrieves the theoretical Langmuir wave dispersion relation obtained from the Vlasov-Poisson theory. For our test, we rely on a regular d = 2 grid with 243 × 243 grid cells. Time is normalized to the inverse plasma frequency ω−1 p , and space is normalized to the Debye length λd, i.e. a grid cell has size λd × λd. The (angular) plasma frequency is defined by (cid:115) ωp = ne2 0me with n being the electron density, me being the electron mass and e being the elementary charge. The Debye length λd, the typical length scale for the electric screening of a charge in a plasma, is defined by (cid:114) λd = 0kB T ne2 = vth/ωp with 0 being the vacuum permittivity, kB being the Boltzmann constant, and T being the electron temperature. All parameters follow [12]. Our observed 36 Langmuir waves, also called electron plasma waves, are high frequency oscilla- tions of the electron density over a fixed ion background. The frequency is high enough for the ions not to have time to respond because of their higher inertia. The charge separation generates an electric force acting as the restoring force. In the cold plasma approximation, i.e. when the thermal velocity of the plasma is much smaller than the phase velocity of the wave, the Langmuir waves oscillate at the plasma frequency. When taking into account the finite temperature of the electrons, a (small) frequency correction appears, leading to the following dispersion relation for a Maxwellian velocity distribution function ω2 = ω2 p + 3k2v2 th = ω2 p(1 + 3k2λ2 d) where kL is the wave vector, vth the electron thermal velocity. The electron plasma is initially loaded with 100 macro-particles per cell, a charge-to-mass ratio q/m = −1, and a random velocity characterized by a Gaussian distribution of mean velocity 0 and thermal velocity vth = 1. The electron charge density is initially uniform n = −1. We also set a neutralising fixed ion background -- this contribution adds as constant term to the right- hand side in (1) besides the simulated particles -- with a constant charge density ni = 1. Our simulation runs with a time step size ∆t = 0.01 and the potential is output every 150 time steps. Figure A.16: Electric field spectrum in the wavevector-wavevector plane (k1, k2), at ω = 1.14. The colors range from white (low signal) to black (high signal). The red dashed line shows the wavevectors in the d = 2 plane corresponding to Langmuir waves at frequency ω = 1.14, from the theoretical Langmuir wave dispersion relation obtained from the Vlasov-Poisson theory. The initial random velocity seeds a sea of Langmuir waves whose dispersion 37 relation can be checked from the analysis of the electric potential: the output electric potential V (x, y, t) is Fourier transformed both in time and space which yields V (k1, k2, ω) where k1 and k2 are the wave vectors associated to the space coordinates xi i ∈ {1, 2}. ω is the frequency. The Fourier transform of the electric field is shown for a cut at ky = 0 in the plane (kx, ω) in Figure A.15. The electric fluctuations are organized in Fourier space so to match the theoretical Langmuir wave dispersion relation obtained from the Vlasov-Poisson theory ω2 = ω2 p in the plane (ky, ω). The Fourier transform of the electric field is also shown in a two-dimensional cut at fixed frequency ω = 1.14, in the wavevectors plane (k1, k2), in Figure A.16. Again, the electric fluctuations are organized in Fourier space at the wave vectors corresponding to Langmuir waves (dashed line) at the prescribed frequency. (cid:0)1 + 3 (kλd)2(cid:1) (dashed line). The result is identical in a cut at kx = 0 Appendix B. Additional experimental data Table B.2: Experiments from Table 1 reran on Polaris. p 103 104 105 106 107 108 103 104 105 106 107 108 1 4.59 · 107 1.04 · 108 1.17 · 108 1.14 · 108 1.11 · 108 1.05 · 108 5.92 · 107 7.85 · 107 9.77 · 107 8.94 · 107 7.75 · 107 7.73 · 107 2 4.86 · 107 1.65 · 108 2.31 · 108 2.35 · 108 2.20 · 108 2.20 · 108 4.52 · 107 1.28 · 108 1.90 · 108 1.71 · 108 1.67 · 108 1.72 · 108 4 5.26 · 107 2.24 · 108 4.18 · 108 4.57 · 108 4.26 · 108 4.30 · 108 3.91 · 107 1.83 · 108 3.40 · 108 3.36 · 108 3.20 · 108 3.22 · 108 8 3.73 · 107 2.36 · 108 6.60 · 108 8.52 · 108 5.99 · 108 6.02 · 108 3.26 · 107 2.13 · 108 5.64 · 108 5.53 · 108 4.05 · 108 4.07 · 108 12 2.94 · 107 2.24 · 108 8.08 · 108 1.20 · 109 6.24 · 108 6.28 · 108 3.01 · 107 1.94 · 108 6.82 · 108 6.44 · 108 4.17 · 108 4.19 · 108 16 3.03 · 107 1.98 · 108 8.83 · 108 1.38 · 109 6.29 · 108 6.31 · 108 3.40 · 107 2.00 · 108 7.20 · 108 6.71 · 108 4.20 · 108 4.24 · 108 32 1.92 · 107 1.32 · 108 7.04 · 108 1.33 · 109 5.93 · 108 6.26 · 108 1.90 · 107 1.18 · 108 5.42 · 108 6.13 · 108 4.07 · 108 4.21 · 108 We ran the stream-like benchmark without particle sorting or any grid on both Polaris and SuperMUC. On Polaris, it yields almost twice the performance compared to SuperMUC (Table B.2). This is a direct result of the higher clock frequency on the smaller cluster. Finally, some additional plots illustrating the lift behaviour for a fixed time step size can be found in Figure B.17. They validate our statements on pros and cons of PIT or PIDT respectively. 38 Figure B.17: ∆t = 0.01 for PIT (top) and PIDT (bottom). We restrict to d = 2 and study homogeneous (left) and inhomogeneous (right) initial distributions, i.e. regular and dynamically adaptive grids. 39 01020304050time step0.00.20.40.60.81.01.21.41.61.8#lifts/particlePIT, 2d, (0.0,1.0)2, ∆t=0.0101020304050time step0.00.20.40.60.81.01.21.41.61.8#lifts/particlePIT, 2d, (0.0,0.1)2, ∆t=0.01ppc=10000ppc=1000ppc=100ppc=1001020304050time step0.000.050.100.150.200.250.30#lifts/particlePIDT, 2d, (0.0,1.0)2, ∆t=0.0101020304050time step0.000.050.100.150.200.250.300.350.40#lifts/particlePIDT, 2d, (0.0,0.1)2, ∆t=0.01
1508.03593
1
1508
2015-08-14T18:24:37
Online Assignment of Heterogeneous Tasks in Crowdsourcing Markets
[ "cs.DS", "cs.HC" ]
We investigate the problem of heterogeneous task assignment in crowdsourcing markets from the point of view of the requester, who has a collection of tasks. Workers arrive online one by one, and each declare a set of feasible tasks they can solve, and desired payment for each feasible task. The requester must decide on the fly which task (if any) to assign to the worker, while assigning workers only to feasible tasks. The goal is to maximize the number of assigned tasks with a fixed overall budget. We provide an online algorithm for this problem and prove an upper bound on the competitive ratio of this algorithm against an arbitrary (possibly worst-case) sequence of workers who want small payments relative to the requester's total budget. We further show an almost matching lower bound on the competitive ratio of any algorithm in this setting. Finally, we propose a different algorithm that achieves an improved competitive ratio in the random permutation model, where the order of arrival of the workers is chosen uniformly at random. Apart from these strong theoretical guarantees, we carry out experiments on simulated data which demonstrates the practical applicability of our algorithms.
cs.DS
cs
Online Assignment of Heterogeneous Tasks in Crowdsourcing Markets Department of Computer and Information Science, University of Pennsylvania Sepehr Assadi∗, Justin Hsu†, Shahin Jabbari {sassadi, justhsu, jabbari}@cis.upenn.edu August 18, 2015 Abstract We investigate the problem of heterogeneous task assignment in crowdsourcing markets from the point of view of the requester, who has a collection of tasks. Workers arrive online one by one, and each declare a set of feasible tasks they can solve, and desired payment for each feasible task. The requester must decide on the fly which task (if any) to assign to the worker, while assigning workers only to feasible tasks. The goal is to maximize the number of assigned tasks with a fixed overall budget. We provide an online algorithm for this problem and prove an upper bound on the competitive ratio of this algorithm against an arbitrary (possibly worst-case) sequence of workers who want small payments relative to the requester's total budget. We further show an almost matching lower bound on the competitive ratio of any algorithm in this setting. Finally, we propose a different algorithm that achieves an improved competitive ratio in the random permutation model, where the order of arrival of the workers is chosen uniformly at random. Apart from these strong theoretical guarantees, we carry out experiments on simulated data which demonstrates the practical applicability of our algorithms. 1 Introduction Crowdsourcing markets have seen a remarkable rise in recent years, as more and more markets use the internet to connect people with tasks to solve, to people willing to solve tasks in exchange for payment. While these tasks were originally simple tasks that could be accomplished while sitting at a computer -- say, labeling images or cleaning data -- recent systems handle complex tasks in the real world. Services like TaskRabbit let users hire workers to run errands, like picking up a package; ride-sharing applications like Lyft or Uber provide drivers on-demand to transport customers; other services offer meal or grocery delivery, house cleaning, and even on-demand massages1 to customers. Accordingly, an important challenge for task requesters in crowdsourcing (and more general) platforms is handling more and more heterogenous workers and tasks. A worker may not be able to solve all the tasks -- say, they may only be able to translate certain languages, or they may only be able to handle time-sensitive tasks on a deadline far into the future. Among the solvable tasks, a worker may want different payment for different tasks; a short task can require a small payment, while a more complex task may warrant a higher payment. At the same time, requesters must cope with a highly dynamic flow of workers. Since it is common for workers to work for several different platforms simultaneously, the pool of available workers is constantly changing. The requester may not have the luxury of seeing all the workers, and then selecting the right ∗Supported in part by NSF grants CCF-1116961 and IIS-1447470. †Supported in part by a grant from the Simons Foundation (#360368 to Justin Hsu) and NSF grant CNS-1065060. 1www.zeel.com 1 workers. Instead, requesters may need to select workers in an online fashion, where workers arrive one by one and must be hired (or not) as soon as they arrive. We take aim at both of these challenges in crowdsourcing by considering the following task assignment problem: if workers (i) have an arbitrary set of feasible tasks, (ii) demand heterogeneous payments by bidding for feasible tasks, and (iii) arrive online, how can a requester assign workers to tasks in order to maximize the number of completed tasks given a fixed overall budget? Singer and Mittal [8] were the first to study a simpler version of this problem. In their setting, each worker has a single bid for all the tasks; all the tasks are treated homogeneously, and workers are assumed to be able to solve all the tasks (if they receive a payment which is at least equal to their bids). We generalize their setting in two significant ways: First, we allow workers to specify only a subset of feasible tasks that they can handle. Second, we work in a setting with heterogeneous tasks: workers can have different preferences over tasks. As we will show, this heterogeneity significantly complicates the task assignment problem; algorithms for the heterogeneous case may look nothing like their counterparts in the homogeneous case. As a warm up, we start by providing two algorithms for the offline problem -- where the requester knows the sequence of workers and their bids up front: first, the optimal algorithm via min-cost flows, and second, a fixed-threshold constant factor approximation algorithm inspired by the algorithm of Singer and Mittal [8]. Then, we move to the online setting, where we draw on techniques from the online knapsack literature. As is typical for online algorithms, we measure the performance of our algorithm via the competitive ratio, i.e., the ratio of the number of tasks assigned by the best offline algorithm to the number of tasks assigned by the online algorithm on the same problem. When the bids are bounded in [1, R], the bids of the workers are small compared to the budget of the requester, and the order is worst-case, we give an algorithm that achieves an O(R ln(R)) competitive ratio when R ≤ B.2 The central idea is to use a moving threshold, and take all workers with bid below the threshold. As the budget is depleted, the threshold steadily decreases. Our algorithm is inspired by Zhou, Chakrabarty, and Lukose [13], who give algorithms for the online knapsack problem. We also show a lower bound: for any (possibly randomized) online algorithm, there exists an input that forces a competitive ratio of at least Ω(ln(R)). Then, we consider the random permutation setting where the bids are adversarial, but the order of workers is chosen uniformly at random. Here, we measure the performance of an online algorithm by comparing the number of tasks assigned averaged over all permutations to the number of tasks assigned by the offline optimal. 2 Model Let us begin by defining our modeling more formally. We will use j to index tasks and i to index workers throughout. We model the problem from the perspective of a requester who has a collection of m tasks. Each worker i picks a subset of tasks Ji ⊆ {1, . . . , m}, along with the numeric bid bij for each task j ∈ Ji. Workers arrive online: the sequence of the workers and their bids are initially unknown to the requester but once a worker arrives, her bids for all the tasks are revealed to the requester. We assume that each worker can be assigned to at most one task; we can relax this assumption by having multiple copies of each worker. We denote the total number of workers by n. As customary in the crowdsourcing setting we assume workers are abundant, hence n is large. We model the sequence of workers (their bids and their order of arrivals) in two different ways. First, we consider the case that we have no assumptions on the sequence of workers. This worst case scenario has been referred to as the adversarial setting in the literature. Second, we consider the random permutation model in which we still make no assumptions on the bids of the workers but we assume the order of their arrival is randomly permuted before being presented to the requester. We define these two settings in more detail in the following sections. The requester has a budget of B and has to decide on the fly which task to assign to the worker who arrives; of course, a worker can only be assigned to a task he is willing to do. If task j is assigned to worker i, 2In particular, when R (cid:28) B, which is arguably the case in most practical applications, our algorithm achieves an optimal competitive ratio of O(ln(R)). 2 then the requester pays worker i at least the price bij. The goal of the requester is to maximize the number of tasks he assigns to the workers while spending at most a budget of B and satisfying all the constraints of the workers (on the tasks they are willing to solve). Similar to the online algorithms literature, we compare the performance of our online algorithms to the performance of the best offline algorithm (denoted by OPT), which can see all the bids and the order of arrival of workers before allocating tasks to workers. As is standard, we measure the performance via the competitive ratio: the ratio of the number of tasks assigned in the offline optimal solution to the number of tasks assigned by the online algorithm (so competitive ratio is at least 1, and smaller competitive ratio is more desirable). 2.1 Related Work Pricing and task assignments have been previously studied in the context of mechanism design for crowd- sourcing markets. Singer and Mittal [8, 9] provide mechanisms for task assignment when tasks are homoge- neous and the workers are arriving from a random permutation model. Our work in the random permutation section generalizes their work to heterogeneous tasks. Ho and Vaughan [5] consider task assignment when the tasks are heterogeneous. However, they assume the existence of limited task types and the focus of their work is learning qualities of the workers from stochastic observations. Singla and Krause [11] design price mechanism for crowdsourcing markets using tools from online learning. Goel, Nikzad, and Singla [4] consider the heterogeneous task assignment in the offline setting and provide near optimal approximation algorithms. However, they focus on the mechanism design aspect of the problem -- how to pay workers so that they report their bids truthfully. This line of budget feasible mechanism design is inspired by the work of Singer [10] and has been followed up in Singer and Mittal [8, 9].3 Also these pricing mechanisms have close connections to the stochastic online adwords problem [3] and the online primal-dual literature (see Buchbinder, Jain, and Naor [1] and references within). Our work is inspired by variants of the online knapsack problem. In the adversarial setting with homo- geneous tasks, our problem is an instance of the online knapsack problem studied by Zhou, Chakrabarty, and Lukose [13] (see references within for more information). However, it is not clear how to formulate our problem as a knapsack problem when the tasks are heterogeneous. Variants of generalized online matching and the adwords problem are also related to our problem (e.g., see Mehta et al. [6] and Mehta [7] for an excellent survey). The adwords problem can be described as follows. There are some bidders and each bidder has a fixed budget. Queries arrive one at the time, bidders bid for the queries and the algorithm has to decide what bidder to assign to the query. If the algorithm assigns a bidder to a query, the bidder pays the amount that is equal to her bid. The goal is to maximize the revenue. While one might attempt to formalize our task assignment problem as an instance of the online adwords problem, it is not hard to see that our constraint on the total budget of the requester cannot be written as an adwords type budget constraint for the bidders. 3 Adversarial Setting When comparing an online algorithm with an offline algorithm, we first need to precisely specify the inputs on which we make the comparison. Let us first consider the worst case for the requester: adversarial inputs. In this setting, there is a fixed input and order, and we compare an online algorithm in this single input to an offline algorithm on the same input via the competitive ratio. We are interested in bounding this ratio in the worst case, i.e., the max over all inputs. Of course, if we really do not make any assumption on the input, we cannot hope to compete with an offline algorithm as the competitive ratio may be arbitrarily high (see, for instance, Zhou, Chakrabarty, and Lukose [13, Section 1.2]). 3While we ignore the mechanism design aspect of the problem in our formulation, as we describe at the end of the Random Permutation section, all our online algorithms (either with a slight modification or as they are) satisfy truthfulness and incentive compatibility. 3 Consequently, we restrict the adversary's power by making one main assumption on the relationship between worker bids and the budget: the ratio of the largest bid to the smallest bid should be small compared to the budget. More precisely, we can scale worker bids so that bij ∈ [1, R], and we write R = B. We will frequently consider  to be small -- this is appropriate for the crowdsourcing problems we have in mind, where (i) the scale of the budget is much larger than the scale of payments to workers and (ii) the tasks are not extremely difficult, so no worker charges an exorbitantly high price. We refer to this assumption as large market assumption because when the bids are small compared to the budget, the requester can hire a large number of workers before exhausting his budget. This is in line with the common assumption in crowdsourcing that n is large. Before diving into the technical details, let us consider which range of parameters and competitive ratios is interesting. Since the bids are restricted in [1, R], achieving a competitive ratio of R is trivial. So, we will be mainly interested in the following question: Can we design an algorithm that has a competitive ratio much smaller than R for any sequence of workers? The rest of this section is organized as follows. We first investigate the offline problem, describing how the problem can be solved optimally. Then we propose a simpler algorithm for the offline setting; the performance is a constant factor off from optimal, but the simpler algorithm will be useful in Section 4, when we will work in the random permutation setting. We then move to the online setting, giving an algorithm with competitive ratio of O(R ln(R)) for any sequence of workers. Finally, we give a lower bound showing that any algorithm has competitive ratio of at least Ω(ln(R)) in the worst case. 3.1 The Offline Problem Let us start by investigating the offline problem where the sequence of workers and their bids are known up front. We first show how the offline optimal assignment can be computed. Then we propose a simpler algorithm that approximates the offline optimal assignment by a factor of 4. We show later in the paper that how this second algorithm, while suboptimal, can be converted to an online algorithm. The offline problem is a well-known problem in the crowdsourcing literature [10] and can be solved by a reduction to the min-cost flow problem defined as follows. Consider a graph with costs and capacities on the edges and two nodes marked as source and target. Given this graph, for a demand value of flow, the goal of the min-cost flow problem is to route this amount of flow from the source to the target while minimizing the total flow cost over the edges, where the flow cost over an edge is equal to the amount of the flow passing the edge multiply by the cost of the edge. We now briefly describe an algorithm for solving the offline problem optimally which uses min-cost flow algorithms as a subroutine. Note that this algorithm is generally known in the literature and we provide it here for the sake of completeness. In our problem, we want to maximize the number of assigned tasks given a fixed budget. In order to do so, we first construct the following instance of the min-cost flow problem. We start with a bipartite graph with workers on one side and tasks on the other. We then draw an edge from a worker to a task if the worker is willing to solve that task and let the cost of this edge to be equal to the bid of the worker for the task. Additionally, we attach a source node pointing to all the workers and connect all the tasks to an added target node. Finally, we set the capacity of all edges to be 1. First notice that any feasible flow in this graph corresponds to an assignment of tasks and workers. Moreover, for any integer F , the minimum cost of a flow with value F corresponds to the minimum budget required for assigning F worker-task pairs.4 Consequently, we can search over all possible F ∈ [n], solve the min-cost flow problem on the described graph and demand flow of F , and return the maximum value of F where the minimum cost flow is at most the available budget. While the above approach achieves the optimal solution, we will see in the random permutation section that using a fixed threshold to decide which workers to hire can be very useful. Hence, we next provide a simpler algorithm with this feature; while this simpler algorithm does not guarantee an optimal solution anymore, we show in Theorem 1 that its solution is within a factor of at most 4 from OPT. 4Since the amount of flow routed from the source to the target and the capacity of the edges are integral, the min-cost flow problem has an integral solution. 4 The algorithm, which we refer to as Offline Approximation Algorithm (OA) (see Algorithm 2) is mainly using the subroutine Fixed Threshold Policy (FTP). In this subroutine, given a threshold value p, the algorithm goes over workers one by one and assigns a task to an unassigned worker if the bid of the worker for that task is not bigger than p. In case there are more than one unassigned task that the worker bids p or less for, the algorithm break ties arbitrarily. The FTP subroutine is described in Algorithm 1.5 Algorithm 1 FTP Input: Threshold price p, budget B, worker bids {bij}, set of available tasks J. While B > 0, on input worker i: Let Ci := {j ∈ J bij ≤ min(p, B)}. If Ci (cid:54)= ∅: Output: a(i) ∈ Ci. Let B := B − bi,a(i). Let J := J \ {a(i)}. Output: a(i) :=⊥. else: OA then searches over all possible values of p to find the proper threshold. Although the search space is continuous, it is sufficient for the algorithm to restrict its search to the bids of the workers. Hence, the running time of OA is polynomial in m and n. We show that the number of assignments of the OA is least a quarter of the OPT for any sequence of workers. Algorithm 2 OA Input: Worker bids {bij}, set of available tasks J, budget B. Let Q := 0. Foreach bij: Let q := FTP(bij, B,{bi,j}, J). If q > Q then: Update Q := q. Output Q (number of assignments) and p∗ := B/Q (the threshold price). Theorem 1. Let ALGOA(σ) and OPT(σ) denote the number of tasks assigned by the OA and the offline optimal algorithm for a sequence of workers σ, respectively. Then for any σ, OPT(σ) ≤ 4 · ALGOA(σ). Before proving Theorem 1, we state the following useful lemma. Lemma 1 (Singer and Mittal [9, Lemma 3.1]). Let a1, . . . ak be a sorted sequence of k positive numbers in an increasing order such that Σk i=1ai ≤ B. Then a(cid:98)k/2(cid:99) · k/2 ≤ B. The proof of Lemma 1 is the result of the following two simple observations: (i) the sum of the second half of the numbers is at most B and (ii) each of the numbers in the second half is at least as big as the median of the sequence. Proof of Theorem 1. Consider all the (worker, task) pairs in the offline optimal where a pair simply denotes that the task is assigned to the worker. Sort these pairs in an increasing order of the bids. Let p∗ denote the median of the bids. By Lemma 1, we can assign half of these (worker, task) pairs, pay all the workers price p∗ (clearly an upper bound on the bid of every considered worker) and be sure not to exceed the budget. However, there are two problems: (i) we do not know which (worker, task) pairs are in the optimal solution and hence, (ii) we do not know the value p∗. 5While we use FTP as an offline algorithm in this section, the sequential nature of the algorithm allows FTP to be used when workers arrive online (one by one). We exploit this feature of FTP in Section 4. 5 To deal with problem (i), suppose we somehow knew p∗. We can then assign a worker to any task where the worker has a bid of at most p∗ and continue until (a) we exhaust the budget or (b) there are no more workers or tasks left. In case (a), the algorithm made at least B/p∗ assignments and by Lemma 1, we know this number is at least OPT/2. For case (b), consider the bipartite graph between the tasks and the workers described earlier for the min-cost flow problem construction and remove all the edges with cost bigger than p∗. Since p∗ is the median of the bids in the optimal solution, we know that in this graph, there exists a matching M of size at least OPT/2 between the workers and the tasks. On the other hand, since we know OA terminated in this case because there are no tasks or workers left, we know that OA has arrived at a maximal matching. Finally, since the size of any maximal matching is at least half of the size of the maximum matching, we know the number of assignments of OA is at least a half of the number of assignments of M . So ALGOA(σ) ≥ OPT(σ)/4 if we knew p∗. To deal with problem (ii) (not knowing p∗), we run the FTP for all the values that p∗ can take and return the maximum number of assignments as our solution.6 A brief detour: the homogeneous case. As we discussed in the introduction, we make a strong dis- tinction between the setting with heterogeneous tasks and the setting with homogeneous tasks. To highlight this difference, we show that in the homogeneous case, the following simple algorithm computes the offline optimal: sort all the workers by their bids and (if possible) assigns a task to the sorted workers until the budget is exhausted or there are no more tasks or workers left. It is easy to verify that this greedy construction indeed computes the best offline assignments when the workers are homogeneous. However, this method will not result in the optimal offline assignment when the tasks are heterogeneous. For example consider the following toy problem with two workers and two tasks where each workers is willing to do both tasks. Let the bids of worker 1 and 2 to be (0.4, 0.5) and (0.45, 0.7) for the two tasks, respectively. With a budget of 1, the optimal offline assignment is to assign task 1 to worker 2 and task 2 to worker 1. However, the homogeneous greedy algorithm will assign task 1 to worker 1 and will not have enough budget left to assign a task to worker 2. 3.2 The Online Problem Let's now move to the online setting, where the workers arrive online and our algorithm must decide which (if any) task to assign to a worker before seeing the remaining workers. We propose an online algorithm and prove an upper bound on the competitive ratio of our algorithm which holds against any sequence of workers. Our upper bound crucially depends on the large market assumption where we assume that the bids of the workers are small compared to the budget. So throughout this section, we assume the bids are bounded in [1, R] where R ≤ B for some small value of . Our Online Heterogeneous Algorithm (OHA) is inspired by an algorithm from the online knapsack liter- ature proposed by Zhou, Chakrabarty, and Lukose [13], with an analysis modified for our setting. The idea is to use a potential function φ : [0, 1] → [1, R] based on the fraction of budget spent so far as an input. The φ function acts as a price threshold: the algorithm assigns a task to a worker only if the bid of the worker for any of the remaining unassigned tasks is below the value of the potential function -- intuitively, as the budget shrinks, the algorithm becomes pickier about which workers to hire. Once a worker is selected, the algorithm greedily assigns a task arbitrarily from the remaining set of tasks. See Algorithm 3 for a pseudo-code.7 Theorem 2. Let ALGOHA(σ) and OPT(σ) denote the number of tasks assigned by the OHA and the offline optimal algorithm for a sequence of workers σ, respectively. Then for any σ with bids in [1, R] such that R ≤ B, OPT(σ)/ALGOHA(σ) ≤ (R · e) (ln(R) + 3) . 6Note that this might result in OA using a threshold p which is different than p∗ but since OA picks a p that maximizes the number of assignments we know the number of assignments made by OA using p is at least as large as the number of assignments made by OA using p∗. 7In Algorithm 3, e is the base of natural logarithm. 6 Algorithm 3 OHA Input: Available tasks J, budget B. Online input: Worker bids {bij} ∈ [1, R]. Define φ(x) = min((R · e)1−x, R). Let x := 0, f := B. While B > 0, on input i: Let Ci := {j ∈ J bij ≤ min(f, φ(x))}. If Ci (cid:54)= ∅ then Output a(i) ∈ Ci. Let x := x + bi,a(i)/B. Let f := f − bi,a(i). Let J := J \ {a(i)}. Output: a(i) :=⊥. else: Proof. Fix a sequence of workers σ. Let S = {(i, j)} be the set of (worker, task) pairs assigned by the OHA where i and j index workers and tasks, respectively. Also let S∗ = {(i∗, j∗)} be the offline optimal. We want to bound OPT(σ)/ALGOHA(σ) = S∗/S. (worker, task) pairs which we denote by (i, j) ∈ S ∩ S∗. Let W =(cid:80) Let xi and X denote the fraction of the budget used by the OHA when worker i arrives and upon termination, respectively. We will analyze the (worker, task) pairs in three stages. First, consider the common (i,j)∈S∩S∗ bij denote the total bid of such workers. Since each worker i in the common part who is assigned to task j is picked by the OHA, it must be that bij ≤ φ(xi). Therefore, . (1) S ∩ S∗ ≥ (cid:88) bij φ(xi) (i,j)∈S∩S∗ Second, consider (i, j) ∈ S∗ \ S. This can happen either because (i) the worker i is assigned to a task different than j by OHA, or (ii) the worker i is not assigned to any task by OHA. We know the number of pairs that satisfy the condition (i) is at most S because all such workers are assigned to a task by both OHA and the offline optimal. For the pairs that satisfy condition (ii), either (a) bij ≤ φ(xi) or (b) bij > φ(xi). It is easy to see that in case (a), OHA assigned task j to some other worker i(cid:48) who arrived before i. Again we know this can happen at most S times. For case (b), since φ is non-increasing then bij > φ(xi) ≥ φ(X) for all such pairs (i, j). Since the offline optimal spent a budget of W for hiring workers in S∗ ∩ S, then it has a budget of at most B − W to hire workers in case (b). Since all the pairs in case (b) have bij > φ(xi) ≥ φ(X), the offline optimal can hire at most (B − W )/bij ≤ (B − W )/φ(X) workers. Adding up cases (i) and (ii), we can bound S∗ \ S ≤ 2S + (B − W ) φ(X) . Finally, consider (i, j) ∈ S \ S∗. Since bij ≤ φ(xi) for all such pairs, we know S \ S∗ ≥ (cid:88) bij φ(xi) . (i,j)∈S\S∗ (2) (3) Putting all the pieces together, Equations (1) to (3) yield OPT(σ) − 2 · ALGOHA(σ) ALGOHA(σ) S ∩ S∗ + S∗ \ S − 2S S ∩ S∗ + S \ S∗ ≤ = (cid:80) (cid:80) (i,j)∈S∩S∗ bij/φ(xi) + S∗ \ S − 2S (i,j)∈S∩S∗ bij/φ(xi) + S \ S∗ . (4) 7 To see why the inequality holds, first note that we know S ∩ S∗ ≥(cid:80) Now if OPT = S∗ < 3S then we are done. Otherwise, (i,j)∈S∩S∗ bij/φ(xi) by Equation (1). S∗ ≥ 3S =⇒ S ∩ S∗ + S∗ \ S ≥ S \ S∗ + S ∩ S∗ + 2S =⇒ S∗ \ S − 2S ≥ S \ S∗. Hence, the inequality holds because if a ≥ b and c ≥ d then (a + c)/(a + d) ≤ (b + c)/(b + d). We bound the right hand side of Equation (4) as follows. (cid:80) (cid:80) (i,j)∈S∩S∗ bij/φ(xi) + S∗ \ S − 2S (i,j)∈S∩S∗ bij/φ(xi) + S \ S∗ (cid:80) (i,j)∈S∩S∗ bij/φ(xi) + S \ S∗ (cid:80) (i,j)∈S∩S∗ bij/φ(xi) + 2S + (B − W )/φ(X) − 2S (cid:80) (cid:80) (i,j)∈S∩S∗ bij/φ(xi) + (B − W )/φ(X) (cid:80) (i,j)∈S∩S∗ bij/φ(xi) + S \ S∗ (cid:80) (i,j)∈S∩S∗ bij/φ(X) + (B − W )/φ(X) (i,j)∈S∩S∗ bij/φ(xi) + S \ S∗ (cid:80) W/φ(X) + (B − W )/φ(X) (i,j)∈S∩S∗ bij/φ(xi) + S \ S∗ (cid:80) (i,j)∈S∩S∗ bij/φ(xi) + S \ S∗ (cid:80) (i,j)∈S∩S∗ bij/φ(xi) +(cid:80) (cid:80) φ(X)(cid:80) (i,j)∈S\S∗ bij/φ(xi) (i,j)∈S bij/φ(xi) (i,j)∈S ∆(xi)/φ(xi) B/φ(X) B/φ(X) B/φ(X) 1 , ≤ = ≤ = = ≤ = = It is easy to show by algebraic manipulation that the first term in the 3rd line is equal to 0. Therefore, OPT(σ) − 2 · ALGOHA(σ) ALGOHA(σ) 1 (i,j)∈S ∆(xi)/φ(xi) ≤ (Re)(ln(R) + 1). where ∆(xi) := xi+1 − xi. The first inequality is due to Equation (2), the second is due to monotonicity of φ and the third inequality is due to Equation (3). Since (i, j) ∈ S, OHA assigns task j to worker i and increases the fraction of the budget consumed by bij/B, so bij/B = ∆(xi). We now estimate the sum with an integral. If ∆(xi) ≤ , Letting c = 1/(1 + ln(R)), we have φ(x) = R if x ≤ c. Similar to [13], we bound the integral as follows. (cid:90) X− 0 1 φ(xi) dx = = = = = (cid:90) X− ∆(xi) 1 φ(xi) ≥ 0 1 φ(xi) dx. (cid:90) X− 1 dx c 1 φ(xi) ((Re)X− − (Re)c) (cid:19) 1 + ln(R) · 1 1 + ln(R) (Re)X− (i,j)∈S (cid:88) (cid:90) c (cid:18) c 0 c R + 1 R · R 1 Re 1 φ(X) dx + · 1 Re − 1 Re 1 1 + ln(R) (Re)− · 1 + ln(R) . φ(X)(cid:80) ≤ 8 (Re)c + · 1 Re 1 ln(R) + 1 (Re)X− Thus, OPT(σ) ≤ ((Re)(ln(R) + 3) · ALGOHA(σ), as desired. 3.3 A Lower Bound on the Competitive Ratio To wrap up this section, we show that if the large market assumption is the only assumption on the sequence of workers, then no algorithm (even randomized) can achieve a constant competitive ratio. We prove the result for the special case that all the tasks are homogeneous. The proof is very similar to the lower bound for the competitive ratio in a variant of the online knapsack problem studied by Zhou, Chakrabarty, and Lukose [13]. In this variant, items arrive one by one online and we have a knapsack with some known capacity. Each item has a weight and a utility parameter and it is assumed that the utility to weight ratio for all the items are within a bounded range. Furthermore, it is assumed that the weight of each item is small compared to the capacity of the knapsack (similar to our large market assumption). The algorithm have to decide whether to pick an item or not upon arrival and the goal is to maximize the utility of the picked items while satisfying the knapsack capacity constraint. Since our setting when the tasks are homogeneous is a special case of the online knapsack variant, the lower bound for that problem might not necessarily provide us with a lower bound. However, we show that with a bit of care, we can achieve the same lower bound using a similar construction. The main idea of the lower bound is to construct hard sequences of worker arrivals. A hard sequence can be described as follows. The sequence starts with workers with maximum bid, R, and then the following workers progressively have smaller and smaller bids compared to the preceding workers. Then at some random point until the end of the sequence only workers with bid R appear in the sequence. Intuitively, these sequences are hard because no algorithm can foresee whether the bids will decrease (so it should wait for cheaper workers) or increase (so it should spend its budget on the current workers). Theorem 3. For any (possibly randomized) online algorithm, there exists a set of sequences of worker arrivals satisfying the large market assumption (all bids in [1, R] and R (cid:28) B) such that the competitive ratio of the algorithm on the sequence is at least Ω (ln(R)). Since the proof is modification of a proof by Zhou, Chakrabarty, and Lukose [13], we defer the details to Appendix A. Finally, it is worth mentioning that if we consider the limit where worker's bids are very small compared to the budget ( → 0), Theorem 2 shows that Algorithm 3 has an optimal competitive ratio approaching O(ln(R)), the best possible as proven by Theorem 3. 4 Random Permutation Setting Now that we have considered the worst-case scenario of inputs, let us consider more "well-distributed" inputs. We consider the random permutation model [3]. In the random permutation model there is no assumption about the bids of the workers (they can still be chosen by an adversary) but we measure the competitive ratio a bit differently: we take all possible permutations of these workers, and take the average competitive ratio over all permutations. Intuitively, this assumption makes the task assignment easier because the premium workers get distributed evenly in the sequence. As pointed out by Devanur and Hayes [3], the random permutation model can be considered as drawing bids from an unknown distribution without replacement. Hence, the random permutation model is very similar to the model that assumes the bids of the workers are drawn i .i .d . from an unknown distribution. Throughout this section, we assume that the number of available workers, n, is large and known to us. Also, we restrict our attention to inputs where the offline optimal algorithm assigns at least a constant fraction of workers, i.e., OPT(σ) = Ω(n) for all sequences σ. For the case that the workers are homogeneous, Singer and Mittal [9] provide an algorithm with com- petitive ratio of 360. In this section, we extend their result to the case the tasks are heterogeneous. We also improve on their competitive ratio, though the setting is a bit different: as they were concerned with mechanism design properties, it was important for Singer and Mittal [9] to carefully tune their payments to 9 (i) incentivize workers to bid honestly and (ii) compensate all workers, even workers at the very beginning. Our algorithm only satisfies the first property. We discuss more about this at the end of this section. If we knew the sequence of the workers and their bids, we could run OA to compute a threshold price p and number of assignments Q where we know Q is at least a quarter of the optimal number of assignments by The- orem 1. However, since we are in the random permutation model, we can estimate this threshold with high probability by observing a subset of workers. This idea is summarized as the Random Permutation Algorithm (RPA) in Algorithm 4. Algorithm 4 RPA Input: Parameter α ∈ (0, 1), set of available tasks J, budget B. Online input: Worker bids {bij}. Let C be the first half of workers; do not assign. Let p := OA(C, J, B/2). On rest of input, run FTP((1 + α)p, B/2). The algorithm observes the first half of workers, assign no tasks but computes a threshold p by running OA with a half of the budget on the sequence of workers on the first half. Given an input parameter α, the algorithm then uses the threshold (1+α)p and runs FTP on the second half of the workers with the remaining half of the budget.8 While using the threshold (1 + α)p instead of p might decrease the performance of our algorithm, we show that (1 + α)p is higher than p with high probability and use this observation to make the analysis of the competitive ratio of RPA easier. Theorem 4. Let α, δ ∈ (0, 1), and suppose the number of workers is at least (cid:18) 1 (cid:19) ) , n = Ω log( 1 δ α and OPT = Ω(n) for every input. For any sequence of workers σ, let ALGRPA(σ) and OPT(σ) denote the number of tasks assigned by the RPA and the offline optimal algorithm for a sequence of workers σ, respectively. Then, OPT(σ) ≤ 8(1 + α)2/(1 − α) · ALGRPA(σ), with probability at least 1 − δ for all σ. Proof. If we knew the sequence of the workers and their bids, we could run OA to compute a price p and number of assignments Q. We know Q ≥ OPT/4 by Theorem 1. Let us refer to these Q workers hired by OA as good workers. We first claim that if we use a price of (1 + α) · p instead of p, the number of assignments will decrease by a factor of (1 + α). This is because we can still assign a task to workers who OA assigned a task to with a threshold of p, but now we also have access to workers with bids in (p, (1 + α) · p] which may cause us to exhaust the budget faster. (1 − α)Q/2 of the good workers are in the second half of the sequence with high probability, and Second, we can estimate p from the first half of the workers. Call this estimate p. We claim that at least p ≤ (1 + α)p ≤ (1 + α)p/(1 − α). (5) This together with the first claim and the 4-approximation of OA will give us the competitive ratio claimed in the statement of the theorem. To complete the proof, we first show that there are enough good workers in the second half of the sequence. Since we are in the random permutation model, then with high probability, we know the number of good 8While we can use the whole budget on the second half of the workers (as we did in our experiments) because the algorithm assigns no tasks to the first half of the workers, this will only decrease the competitive ratio by a factor of half. 10 workers in the first half of the workers is in [Q(1 − α)/2, Q(1 + α)/2]. Chvatal [2] show that this probability is bounded by Q(cid:88) 1 − 2 i=Q(1+α)/2 n/2 (cid:0) i Q/2 (cid:1) (cid:1)(cid:0)n/2−i (cid:0) n (cid:1) n−Q = (cid:40) 1 − O(e−αQ2/n) 1 − O(e−α(n−Q)2Q/n2 if Q ≥ n 2 , if Q < n 2 ) = 1 − O(e−αn). To prove that Equation (5) holds, we consider two cases. 1. The number of good workers in the first half is [Q(1 − α)/2, Q/2). In this case p ≥ p because we can obviously use the budget to assign tasks to all the good workers. And if there is leftover budget, we might be able to assign tasks to workers with bid greater than p. So, p Q 2 (1 − α) ≤ B 2 = pQ 2 =⇒ p ≤ 1 (1 − α) p, since B = P Q by the last line in Algorithm 2. Combined with p ≥ p, the condition in Equation (5) holds in this case. 2. The number of good workers in the first half is [Q/2, Q(1 + α)/2]. In this case p ≤ p. Suppose by contradiction that p > p. This means the workers hired by the OA with bids of at most p is at least S = B/(2p). We know S ≥ Q/2 because all good workers have bids of most p. So, B 2p = pQ 2p ≥ Q 2 =⇒ p ≥ p, which is a contradiction. Thus, p Q 2 (1 + α) ≥ B 2 = pQ 2 =⇒ p ≥ 1 1 + α p. Combined with p ≤ p, the condition in Equation (5) also holds in this case, concluding the proof. A Note On Incentive Compatibility. A problem closely related to ours is to design incentive compatible mechanisms in a setting where the workers arrive online but their bids are private and unknown to the requester [9]. While our focus in this paper was mainly on designing competitive online algorithms, we point out that both of our online algorithms, OHA (Algorithm 3) and RPA (Algorithm 4), can lead to incentive compatible mechanisms in a straightforward way. We briefly describe this relation here and omit the formal proofs. For any worker i, let φi denote the largest price that satisfies the potential φ upon the arrival of worker i. Suppose in OHA, instead of checking the bids of each worker against the potential function φ, the requester simply offers φi to worker i (without knowing the worker's true bids). One can simply check that by allocating this budget to the i-th worker instead of her bid (which is never bigger than φi by definition) in OHA, the proof of Theorem 2 still holds and consequently the modified OHA still achieves the promised competitive ration. However, in this variant of OHA, the dominant strategy for a worker is to reveal her true bid since her utility (i.e, the payment she receives) is independent of her true bid (0 if bij > φi and φi otherwise). Similarly, we can argue this property for the RPA (with the modification that we pay the workers equal to the fixed threshold price not their true bid) also. Although we are dealing with heterogeneous tasks, the analysis of incentive compatibility is similar to Singer and Mittal [9] which only consider homogenous tasks. 11 Figure 1: Competitive Ratio of OHA and RPA against an adversarially chosen input. The line with circle shows the competitive ratio of OHA on the adversarial sequence. The lines with diamond and square show the competitive ratio of RPA and OHA on the randomly permuted sequence, respectively. A line for ln(R) as the theoretical bound on the competitive ratio of OHA is also provided. The plot is presented in log-scale. 5 Experiments In this section we describe some experiments to examine the performance of OHA (Algorithm 3) and RPA (Algorithm 4) on synthetic data.9 We conduct two sets of experiments. The first set focuses on the performance under homogeneous and adversarially chosen bids (similar to the hard distribution in Theorem 3). In the second set of experiments, we use a sequence of heterogeneous workers and bids produced from a family of distributions meant to model input in practical settings. Adversarial Homogenous Bids. The input in this setting is created similar to the hard distribution in Theorem 3 with groups of workers that are willing to solve any of the tasks with the same bid, but the bids may vary across different groups of workers. Since these instances are hard inputs from the adversarial setting (as shown in Theorem 3), they are a good benchmark for comparing the algorithms in adversarial setting. Formally, the input is created as follows. We vary R in the range from 2 to 220 (on all powers of two) and set B = 2R. The bids of the workers are R, R/2, . . . , R/2i, where in each experiment, i is chosen uniformly at random from {1, 2, . . . , log2 R}; for each group with bid R/2i, there will be B · 2i/R workers. We always pad the input with a set of workers with bid R to ensure that the total number of workers in each instance is the same (i.e., we set n = 8R). We set the number of tasks to be equal to the number of workers (so a worker will never run out of tasks to solve no matter what the previous workers have done). Finally, for each value of R, we create the input 10, 000 times and compute the average competitive ratio of OHA. Note that since in this distribution, there is essentially no suitable worker in the second half, RPA performs very poorly and hence we do not include it in this part of the experiment. We then ran the same experiment (for both OHA and RPA) on the same input but this time we permute the workers randomly; Figure 1 shows the result for this experiment. The experiment over the truly adversarial input shows that OHA outperforms the theoretical guarantee of O(R ln (R)), ( = 0.5 here) and grows roughly like ln R, suggesting that the true performance of OHA may be closer to our theoretical lower bound from Theorem 3. The experiment over the randomly permuted input shows that RPA is obtaining a constant competitive ratio even though the input does not satisfy all the properties required by Theorem 4 (e.g., OPT = Ω(n) 9We slightly modified the RPA in our experiments by using all the budget (instead of half) on the second half of the workers. Note that this modification can only improve the performance in our implementation compared to our theoretical guarantee for Algorithm 4. 12 Figure 2: Competitive Ratio of OHA and RPA against the uniform heterogeneous bids. assumption). Interestingly, even OHA performs very well over the input (only slightly worse than RPA), and also much better than the theoretical guarantee proved in Theorem 2. Finally note that although the sequence of workers were adversarially chosen to begin with, a random permutation of this sequence makes the problem significantly easier; to the point that even OHA which is designed to perform against worst case sequences will also achieve a constant competitive ratio. Uniform Heterogeneous Bids. We consider a similar distribution (with minor modification of parame- ters) as the one introduced by Goel, Nikzad, and Singla [4]. They use this setting to analyze the performance of their proposed algorithms for heterogeneous task assignment in the offline case. These inputs are aimed to capture more realistic scenarios compared to our experiments in the previous part. The distribution is as follows. We vary R in range from 2 to 50 and set B = 200. The workers are heterogeneous and are only willing to solve a subset of all available tasks. In particular, we create n = 200 workers and m = 200 tasks and create a random graph with probability of edge formation equal to 0.05 between any of the (worker, task) pairs. Additionally, over each realized edge, we choose the bid of the worker for the given task uniformly at random from {1, 2, . . . , R} (independently of the bids chosen over the other edges for this worker). For each choice of R, we repeat the experiment 80 times and report the average competitive ratio of the algorithms over the runs. Figure 2 illustrates the results of this experiment. As seen in Figure 2 both algorithms perform very well over these inputs, obtaining a competitive ratio that is nearly independent of R. Interestingly, OHA performs distinctly better than its theoretical guarantee, even outperforming RPA. We suspect that this is because OHA is more adaptive than RPA, since it uses a varying price threshold while RPA sticks to a fixed price (after discarding half the input). Hence RPA exhausts the budget sooner than necessary, while additionally losing the contribution of half of the workers. Acknowledgement We would like to thank Steven Zhiwei Wu for helpful discussion in the earlier stages of this work. We are also grateful to the anonymous reviewers for their insightful comments. References [1] Buchbinder, N.; Jain, K.; and Naor, J. 2007. Online primal-dual algorithms for maximizing ad-auctions revenue. In Proceedings of the 15th Annual European Symposium on Algorithms, 253 -- 264. [2] Chvatal, V. 1979. The tail of the hypergeometric distribution. Discrete Mathematics 25(3):285 -- 287. [3] Devanur, N., and Hayes, T. 2009. The adwords problem: online keyword matching with budgeted bidders under random permutations. In Proceedings of 10th ACM Conference on Electronic Commerce, 71 -- 78. 13 [4] Goel, G.; Nikzad, A.; and Singla, A. 2014. Mechanism design for crowdsourcing markets with heteroge- neous tasks. In Proceedings of the Second AAAI Conference on Human Computation and Crowdsourcing. [5] Ho, C.-J., and Vaughan, J. 2012. Online task assignment in crowdsourcing markets. In Proceedings of the 26th AAAI Conference on Artificial Intelligence. [6] Mehta, A.; Saberi, A.; Vazirani, U.; and Vazirani, V. 2005. Adwords and generalized on-line matching. In Proceedings of the 46th Annual IEEE Symposium on Foundations of Computer Science, 264 -- 273. [7] Mehta, A. 2013. Online matching and ad allocation. Foundations and Trends in Theoretical Computer Science 8(4):265 -- 368. [8] Singer, Y., and Mittal, M. 2011. Pricing tasks in online labor markets. In Proceedings of the 3rd Human Computation Workshop. [9] Singer, Y., and Mittal, M. 2013. Pricing mechanisms for crowdsourcing markets. In Proceedings of 22nd International World Wide Web Conference, 1157 -- 1166. [10] Singer, Y. 2010. Budget feasible mechanisms. In Proceedings of the 51th Annual IEEE Symposium on Foundations of Computer Science, 765 -- 774. [11] Singla, A., and Krause, A. 2013. Truthful incentives in crowdsourcing tasks using regret minimization mechanisms. In Proceedings of the 22nd International World Wide Web Conference, 1167 -- 1178. [12] Yao, A. 1977. Probabilistic computations: Toward a unified measure of complexity. In Proceedings of the 54th IEEE Annual Symposium on Foundations of Computer Science, 222 -- 227. [13] Zhou, Y.; Chakrabarty, D.; and Lukose, R. 2008. Budget constrained bidding in keyword auctions and online knapsack problems. In Proceedings of the 4th International Workshop on Internet and Network Economics, 566 -- 576. A Proof of Lower Bound on Competitive Ratio Theorem 3. For any (possibly randomized) online algorithm, there exists a set of sequences of worker arrivals satisfying the large market assumption (all bids in [1, R] and R (cid:28) B) such that the competitive ratio of the algorithm on the sequence is at least Ω (ln(R)). Proof. We modify the proof of Theorem 2.2 by Zhou, Chakrabarty, and Lukose [13] to fit our problem formulation. We use Yao's minimax principle; by constructing a distribution over a set of instances and showing that no deterministic algorithm can achieve a expected competitive ratio which is better than ln(R) + 1 on these instances, Yao's principle implies that no randomized algorithm can beat this competitive ratio in the worst-case [12]. To construct the distribution, fix η ∈ (0, 1), let k be the smallest integer such that (1 − η)k ≤ 1/R, and define k + 1 instances indexed by I0 to Ik as follows. I0 contains B/R identical workers all with bids equal to R. For all u > 0, Iu is Iu−1 followed by B/(R(1 − η)u) workers all with bids equal to R(1 − η)u. Since these instances have different length we pad all the instances with enough workers with bid R so that all the instances have the same length. We specify a distribution D by k + 1 values p0, . . . , pk where pu denotes the probability of occurrence of instance Iu. Let p0 = p1 = . . . = pk−1 := η (k + 1)η + 1 and pk := 1 + η (k + 1)η + 1 . 14 On this distribution of inputs, any deterministic algorithm is fully specified by the fraction of budget spent on hiring workers with bid R(1 − η)u; call each fraction fu. Since the optimal assignment for instance i is to only hire workers with bids R(1 − η)i, the inverse of the expected competitive ratio can be bounded as follows. k(cid:88) u=0 pu (cid:80)u v=0 fvB/(R(1 − η)v) B/(R(1 − η)u) k(cid:88) u(cid:88) = pu k(cid:88) k(cid:88) fv(1 − η)u−v = fv pu(1 − η)u−v, u=0 v=0 v=0 u=v where the last statement is by expanding the sums and reordering the terms. The second sum in the RHS of Equation (6) is bounded by pu(1 − η)u−v = 2η(1 − η)k−v + (1 − η) (k + 1)η + 1 ≤ 2η + (1 − η) (k + 1)η + 1 = 1 + η (k + 1)η + 1 , k(cid:88) u=v (6) (7) k(cid:88) k(cid:88) fv v=0 u=v since by definition(cid:80)k v=0 fv ≤ 1. k(cid:88) k(cid:88) where the first equality is derived exactly similar to Zhou, Chakrabarty, and Lukose [13]. Replacing Equa- tion (7) into the RHS of Equation (6), pu(1 − η)u−v ≤ 1 + η (k + 1)η + 1 v=0 fv ≤ 1 + η (k + 1)η + 1 k(cid:88) (cid:18) 1 (cid:19) ln(R) Now by definition of k, we know (1 − η)k ≤ 1/R, which implies k + 1 ≥ ln(R)/ ln(1/(1 − η)). So, fv pu(1 − η)u−v ≤ 1 + η (k + 1)η + 1 ≤ 1 + η η ln(R)/ ln(1/(1 − η)) + 1 = O v=0 u=v as η → 0, because limη→0 η/ ln(1/(1 − η)) = 1. Since we bound the inverse of the competitive ratio in the above analysis, then the competitive ratio is at least Ω(ln R). 15
1702.05626
1
1702
2017-02-18T15:47:39
Embeddings of Schatten Norms with Applications to Data Streams
[ "cs.DS" ]
Given an $n \times d$ matrix $A$, its Schatten-$p$ norm, $p \geq 1$, is defined as $\|A\|_p = \left (\sum_{i=1}^{\textrm{rank}(A)}\sigma_i(A)^p \right )^{1/p}$, where $\sigma_i(A)$ is the $i$-th largest singular value of $A$. These norms have been studied in functional analysis in the context of non-commutative $\ell_p$-spaces, and recently in data stream and linear sketching models of computation. Basic questions on the relations between these norms, such as their embeddability, are still open. Specifically, given a set of matrices $A^1, \ldots, A^{\operatorname{poly}(nd)} \in \mathbb{R}^{n \times d}$, suppose we want to construct a linear map $L$ such that $L(A^i) \in \mathbb{R}^{n' \times d'}$ for each $i$, where $n' \leq n$ and $d' \leq d$, and further, $\|A^i\|_p \leq \|L(A^i)\|_q \leq D_{p,q} \|A^i\|_p$ for a given approximation factor $D_{p,q}$ and real number $q \geq 1$. Then how large do $n'$ and $d'$ need to be as a function of $D_{p,q}$? We nearly resolve this question for every $p, q \geq 1$, for the case where $L(A^i)$ can be expressed as $R \cdot A^i \cdot S$, where $R$ and $S$ are arbitrary matrices that are allowed to depend on $A^1, \ldots, A^t$, that is, $L(A^i)$ can be implemented by left and right matrix multiplication. Namely, for every $p, q \geq 1$, we provide nearly matching upper and lower bounds on the size of $n'$ and $d'$ as a function of $D_{p,q}$. Importantly, our upper bounds are {\it oblivious}, meaning that $R$ and $S$ do not depend on the $A^i$, while our lower bounds hold even if $R$ and $S$ depend on the $A^i$. As an application of our upper bounds, we answer a recent open question of Blasiok et al. about space-approximation trade-offs for the Schatten $1$-norm, showing in a data stream it is possible to estimate the Schatten-$1$ norm up to a factor of $D \geq 1$ using $\tilde{O}(\min(n,d)^2/D^4)$ space.
cs.DS
cs
Embeddings of Schatten Norms with Applications to Data Streams Yi Li David P. Woodruff Division of Mathematics IBM Almaden Research Center School of Physical & Mathematical Sciences [email protected] Nanyang Technological University [email protected] September 5, 2018 Abstract i=1 σi(A)p(cid:17)1/p , Given an n×d matrix A, its Schatten-p norm, p ≥ 1, is defined as kAkp =(cid:16)Prank(A) where σi(A) is the i-th largest singular value of A. These norms have been studied in functional analysis in the context of non-commutative ℓp-spaces, and recently in data stream and linear sketching models of computation. Basic questions on the relations between these norms, such as their embeddability, are still open. Specifically, given a set of matrices A1, . . . , Apoly(nd) ∈ Rn×d, suppose we want to construct a linear map L such that L(Ai) ∈ Rn′ for each i, where n′ ≤ n and d′ ≤ d, and further, kAikp ≤ kL(Ai)kq ≤ Dp,qkAikp for a given approximation factor Dp,q and real number q ≥ 1. Then how large do n′ and d′ need to be as a function of Dp,q? We nearly resolve this question for every p, q ≥ 1, for the case where L(Ai) can be expressed as R · Ai · S, where R and S are arbitrary matrices that are allowed to depend on A1, . . . , At, that is, L(Ai) can be implemented by left and right matrix multiplication. Namely, for every p, q ≥ 1, we provide nearly matching upper and lower bounds on the size of n′ and d′ as a function of Dp,q. Importantly, our upper bounds are oblivious, meaning that R and S do not depend on the Ai, while our lower bounds hold even if R and S depend on the Ai. As an application of our upper bounds, we answer a recent open question of Blasiok et al. about space-approximation trade-offs for the Schatten 1-norm, showing in a data stream it is possible to estimate the Schatten-1 norm up to a factor of D ≥ 1 using O(min(n, d)2/D4) space. ×d′ 1 Introduction σi(A)p(cid:17)1/p Given an n× d matrix A, its Schatten-p norm, p ≥ 1, is defined to be kAkp =(cid:16)Prank(A) , where σi(A) is the i-th largest singular value of A, i.e., the square root of the i-th largest eigenvalue of AT A. The Schatten-1 norm is the nuclear norm or trace norm, the Schatten-2 norm is the Frobenius norm, and the Schatten ∞-norm, defined as the limit of the Schatten-p norm when p → ∞, is the operator norm. The Schatten 1-norm has applications in non-convex optimization [5], while Schatten-2 and Schatten-∞ norms are useful in geometry and linear algebra, see, e.g., [26]. Schatten-p norms for large p also provide approximations to the Schatten-∞ norm. The Schatten norms appear to be significantly harder to compute or approximate than the vector ℓp-norms in various models of computation, and understanding the complexity of estimating them has led to new algorithmic ideas and lower bound techniques. The main difficulty is that we do not directly have access to the spectrum of A, and naıvely it is costly in space and time to i=1 1 extract useful information about it. A line of work has focused on understanding the complexity of estimating such norms in the data stream model with 1-pass over the stream [17] as well as with multiple passes [4], the sketching model [2, 16, 18], statistical models [13], as well as the general RAM model [21, 23]. Dimensionality reduction in these norms also has applications in quantum computing [9, 25]. It has also been asked in places if the Schatten-1 norm admits non-trivial nearest neighbor search data structures [1]. In this paper we study the embeddability of the Schatten-p norm into the Schatten- Our Results. q norm for linear maps implementable by matrix multiplication. More concretely, we first ask for the following form of embeddability: given n and t (where t = Ω(log n)), what is the smallest value of Dp,q, which we call the distortion, such that there exists a distribution R on Rt×n satisfying, for any given n × d matrix A, Pr R∼RnkAkp ≤ kRAkq ≤ Dp,qkAkpo ≥ 1 − exp(−ct)? Here c > 0 is an absolute constant. We can assume, w.l.o.g., that n = d because we can first apply a so-called subspace embedding matrix (see, e.g., [26] for a survey) to the left or to the right of A to preserve each of its singular values up to a constant factor - we refer the reader to [16, Appendix C] for this standard argument. We shall show that Dp,q & Dp,q, where 1 ≤ p ≤ q ≤ 2; 1 ≤ p ≤ 2 ≤ q; 2 ≤ p ≤ q; 1 ≤ q ≤ 2 ≤ p; 2 ≤ q ≤ p; 1 ≤ q ≤ p ≤ 2, (1) 1 q − 1 p}, p , t 1 p− 1 q}, 2 , (t/ ln t) Dp,q = 1 1 1 1 n 2 /t 2− 1 q − 1 2 , p− 1 p− 1 n 2 , max{(n/t) 2− 1 n p , 2− 1 2− 1 n q , p− 1 max{(n/t) p /t 1 1 1 1   and the notation f & g means f ≥ g/C for some constant C > 0. The constant C in the & notation above depends on p and q only. This distortion is asymptotically tight, up to logarithmic factors, as we also construct a distribution R on t-by-n matrices for which for any n × d matrix A, Pr R∼RnkAkp ≤ kRAkq ≤ Dp,q(cid:16)log t(cid:17)kAkpo ≥ 1 − exp (−ct) , n where Dp,q differs from Dp,q by a constant or a factor of log t. Specifically, Dp,q .(max{(n/t) Dp,q, 1 p− 1 2 , t 1 q − 1 p}, 1 ≤ q ≤ p ≤ 2; otherwise, (2) where Dp,q is given in (1). Replacing t with t/(ln(n/t)), we arrive at a matching failure probability and distortion, while using a logarithmic factor more number of rows in R. Namely, we construct a distribution R on matrices with t ln(n/t) rows for which Pr R∼RnkAkp ≤ kRAkq ≤ Dp,qkAkpo ≥ 1 − exp (−ct) . 2 We can also sketch RA on the right by a subspace embedding matrix S with Θ(t) rows, which yields Pr R,SnkAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ Dp,qkAkpo ≥ 1 − exp (−ct) . We show that this two-sided sketch is asympotically optimal for two-sided sketches in its product of number of rows of R and number of columns of S, up to logarithmic factors. Formally, we next ask: what is the smallest value of Dp,q for which there exists a distribution G1 on Rr×n and a distribution G2 on Rn×s satisfying Pr R∼G1,S∼G2nkAkp ≤ kRASkq ≤ Dp,qkAkpo ≥ 1 − exp(−c min{r, s})? Again we can assume, w.l.o.g, that r = s, because otherwise we can compose R or S with a subspace embedding to preserve all singular values up to a constant factor1. Henceforth for the two-sided problem, we assume that G1 and G2 are distributions on Rt×n. We also prove a matching lower bound that Dp,q & Dp,q except in the case when 1 ≤ q ≤ p ≤ 2, where we instead obtain a matching lower bound up to logarithmic factors, namely, Dp,q & max{(n/t) In the important case when p = q = 1, our results show a space-approximation tradeoff for estimating the Schatten 1-norm (or trace norm) in a data stream, answering a question posed by Blasiok et al. [3]. This application crucially uses that R and S are oblivious to A, i.e., they can be sampled and succinctly stored without looking at A. Specifically, when each entry of A fits in a word of O(log n) bits, we can choose R and S to be Gaussian random matrices with entries truncated to O(log n) bits and with entries drawn from a family of random variables with bounded independence (see Appendix 6). For time-efficiency purposes, R and S can also be chosen to be Fast Johnson Lindenstrauss Transforms or sparse embedding matrices [7, 20, 22], though they will have larger dimension, especially to satisfy the exponential probability of failure in the problem statement (and even with constant failure probability, the dimension will be slightly larger; see [26] for a survey). 2 t, (t/ ln t) 2 / log p}. 1 q − 1 1 p− 1 3 Choosing R and S to be Gaussian matrices, our result provides a data stream algorithm us- ing (n2/D4) polylog(n) bits of memory, and achieving approximation factor D (taking t = n/D2). While kAk2, the Frobenius norm of A, provides a √n-approximation to kAk1 and can be approxi- mated up to a constant factor in a data stream using O(1) words of space, if we want an algorithm achieving a better approximation factor then all that was known was an algorithm requiring O(n2) words of space, namely, the trivial algorithm of storing A exactly and achieving D = 1. It was asked in [3] if there is a smooth trade-off between the case when D = 1 and D = √n; our (n2/D4) polylog(n) space algorithm provides the first such trade-off, and is optimal at the two ex- tremes. Our results are the first of their kind for large approximation factors D ≫ 1 for estimating the Schatten-p norms in a data stream. Finally, while in our upper bounds R and S are chosen obliviously to A, for our lower bounds we would like to rule out those R and S which are even allowed to depend on A. Clearly, if there is only a single matrix A, this question is ill-posed as one can just choose R and S to have a single row and column so that kRASkq = kAkp. Instead, we ask the question analogous to the Johnson- Lindenstrauss transform (see e.g., [14]): given A1, . . . , Apoly(n), can we construct an R with t rows 1That is, if r ≤ s, we can choose a subspace embedding matrix H of dimension n × Θ(r) such that kRASHkq = Θ(kRASkq) with probability ≥ 1 − exp(−s), and then pad R with zero rows so that R has the same number of rows as columns of S, increasing the number of rows of R by at most a constant factor. 3 and an S with t columns for which kAikp ≤ kRAiSkq ≤ Dp,qkAikp for all i? We show that our lower bound on the trade-off between Dp,q and t given by (1) continues to hold even in this setting. Our Techniques. We shall focus on the case p = q in this description of our technical overview. For our upper bounds, a natural idea is to take R to be a (normalized) Gaussian random matrix, and the analysis of the quantity kRAkp, when p ≥ 2, follows fairly directly from the so-called non-commutative Khintchine inequality as follows. Lemma 1 (Non-commutative Khintchine Inequality [19]). Suppose that C1, . . . , Cn are (determin- istic) matrices of the same dimension and g1, . . . , gn are independent N (0, 1) variables. It holds that E giCi(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)p g1,...,gn(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) Xi ≃ max (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) Xi  In order to estimate kRAkp, we can write RA =Xi,j CiC T 1 i ! 2(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)p ,(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) j A) =:Xi,j rij(eieT rijCij Xi C T i Ci! 1 2(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)p   , p ≥ 2. and it is straightforward to compute that Xi,j CijC T ij = tr(AAT )It = kAk2 F It, Xi,j C T ij Cij = t · AT A. It follows from the non-commutative Khintchine inequality that (recall that R is a normalized Gaussian matrix with N (0, 1/t) entries) EkRAkp ≃ maxnt 1 2− 1 pkAkF ,kAkpo , p ≥ 2. Using a concentration inequality for Lipschitz functions on Gaussian space, one can show that kRAkp is concentrated around EkRAkp, and using standard the standard relationship between kAkF and kAkp then completes the argument. When p < 2, the non-commutative Khintchine inequality gives a much less tractable charac- terization, so we need to analyze kRAkp in a different manner, which is potentially of independent interest. Our analysis also works for non-Gaussian matrices R whenever R satisfies certain proper- ties, which, for instance, are satisfied by a Fast Johnson-Lindenstrauss Transform. Upper bound. We give an overview of our upper bound now, focusing on the one-sided case, since the two-sided case follows by simply right-multiplying by a generic subspace embedding S. Here we focus on the case in which R is an r× n Gaussian matrix, where r = t· polylog(n). By rotational invariance of Gaussian matrices, and for the purposes of computing kARkp, we can assume that A is diagonal. Let A1 be the restriction of A to its top Θ(t log n) singular values. Since R is a Gaussian matrix with at least t log n rows, it is well-known that R is also a subspace embedding on A1 (see, e.g., [24, Corollary 5.35]), namely, σi(RA1) ≃ σi(A1) for all i, and thus kRA1kp ≃ kA1kp = Ω(kAkp) when kA1kp = Ω(kAkp). If it does not hold that kA1kp = Ω(kAkp), then the singular values of A are "heavy-tailed", and we show how to find a σi(A) with i < Θ(t log n) for which σ2 i (A) is relatively small compared to 4 i+1(A) +··· + σ2 n(A). More specifically, let A2 be the restriction of A to σi(A), . . . , σn(A). i (A) + σ2 σ2 Then we have that kA2kop . kA2kF /√t. Since for a Gaussian matrix R it holds that kRA2kop . kA2kop+kAkF /√r (see Proposition 3), we thus have that kRA2kop . kA2kF /√t. On the other hand, kRA2kF ≃ kA2kF . This implies there exist Ω(t) singular values of RA2 that are Ω(kA2kF /√t), which yields that kRA2kp & kA2kp = Ω(kAkp). Therefore we have established the lower bound that kRAkp ≥ max{kRA1kp,kRA2kp} in terms of kAkp. To upper bound kRAkp in terms of kAkp, note that kRAkp ≤ kRA1kp +kRA2kp by the triangle inequality, where A1, A2 are as above. Again it follows from the subspace embedding property of R that kRA1kp . kA1kp ≤ kAkp. Regarding kRA2kp, we relate its Schatten-p norm to its Frobenius norm and use the fact that kRA2kF ≃ kA2kF . This gives an upper bound of kRA2kp in terms of kA2kp, and using that kA2kp ≤ kAkp, it gives an upper bound in terms of kAkp. This is sufficient to obtain an overall upper bound on kRAkp. Lower bound. Now we give an overview of our lower bounds for some specific cases. First consider one-sided sketches. We choose our hard distribution as follows: we choose an n × (10t) Gaussian matrix G padded with 0s to become an n × n matrix. For a sketch matrix R containing t rows, by rotational invariance of Gaussian matrices, kRGkp is identically distributed to kΣRG′kp, where ΣR is the t×t diagonal matrix consisting of the singular values of R, and where G′ is a t×(10t) Gaussian matrix. It is a classical result that all singular values of G′ are Θ(√t) and thus kRGkp ≃ √tkRkp. This implies that since all non-zero singular values of G are Θ(√n). On the other hand, applying R to the n × n identity matrix gives that √nt 1 p . √tkRkp . Dp,p√nt 2− 1 1 2− 1 p , (3) 1 n p ≤ kRkp ≤ Dp,pn 1 p . (4) Combining (3) and (4) gives that Dp,p ≥ max{(n/t)1/2−1/p, (n/t)1/p−1/2}. For the two-sided sketch, we change the hard distribution to (i) n× n Gaussian random matrix F and (ii) the distribution of GH T , where G and H are n × Θ(t) Gaussian random matrices. The proof then relies on the analysis for (cid:13)(cid:13)RF ST(cid:13)(cid:13)p and (cid:13)(cid:13)RGH T ST(cid:13)(cid:13)p. When p ≥ 2, non-commutative Khintchine inequality gives immediately that (cid:13)(cid:13)RGH T ST(cid:13)(cid:13)p ≃ √t(cid:13)(cid:13)RF ST(cid:13)(cid:13)p ≃ √t max{kRkpkSkop,kRkopkSkp}, When p < 2, a different approach is followed. We divide the singular values of R and S into bands, where each band contains singular values within a factor of 2 from each other. We shall consider the first Θ(log t) bands only because the remaining singular values are 1/ poly(t) and negligible. Now, if all singular values of R′ and S′ are within a factor of 2 from each other, then (cid:13)(cid:13)R′F (S′)T(cid:13)(cid:13)p ≃ kR′kopkS′kopkFkp and (cid:13)(cid:13)R′GH T (S′)T(cid:13)(cid:13)p ≃ kR′kopkS′kop(cid:13)(cid:13)GH T(cid:13)(cid:13)p. It is not difficult to see that (6) p ≥ 2. (5) Since R′ and S′ consist of one of the Θ(log t) bands of R and S, respectively, it follows that A lower bound of Dp,p then follows from combining (6), (5) (or (7)) with (cid:13)(cid:13)RGH T ST(cid:13)(cid:13)p ≃ kFkp ≤(cid:13)(cid:13)RF ST(cid:13)(cid:13)p ≤ Dp,pkFkp, kGH Tkp ≃ √tkFkp √t/ polylog(t) ·(cid:13)(cid:13)RF ST(cid:13)(cid:13)p, and (cid:13)(cid:13)GH T(cid:13)(cid:13)p ≤(cid:13)(cid:13)RGH T ST(cid:13)(cid:13)p ≤ Dp,p(cid:13)(cid:13)GH T(cid:13)(cid:13)p. p < 2. 5 (7) To strengthen the lower bound for the sketches that even depend on the input matrix, we follow the approach in [14]. We first work with random hard instances, and then sample input matrices A1, . . . , Apoly(n) from the hard distribution, and apply a net argument on sketching matrices R and S to obtain a deterministic statement, which states that for any fixed R and S such that the distortion guarantee is satisfied with all samples A1, . . . , Apoly(n), the distortion lower bound remains to hold. 2 Preliminaries Notations. Throughout the paper, we use f . g to denote f ≤ Cg for some constant C, f & g to denote f ≥ Cg for some constant C and f ≃ g to denote C1g ≤ f ≤ C2g for some constants C1 and C2. Bands of Singular Values. Given a matrix A, we split the singular values of A, σ1(A) ≥ σ2(A) ≥ ··· , into bands such that the singular values in each band are within a factor of 2 from each other. Formally, define the i-th singular value band of A as Bi(A) =(cid:26)k : kAkop 2i (cid:27) , 2i+1 < σk(A) ≤ kAkop i ≥ 0, and let Ni(A) = Bi(A), the cardinality of the i-th band. Extreme Singular Values of Gaussian Matrices. We shall repeatedly use the following re- sults on Gaussian matrices. Proposition 2 ([24, Corollary 5.35]). Let G be an r × n (r < n) Gaussian random matrix of i.i.d. entries N (0, 1). With probability at least 1 − 2 exp(−u2/2), it holds that √n − √r − u ≤ smin(G) ≤ smax(G) ≤ √n + √r + u. Combining [15, Corollary 3.21] and the concentration bound in Gauss space [24, Proposition 5.34], we also have Proposition 3. Let A be a deterministic n× n matrix and G be an r× n (r < n) Gaussian random matrix of i.i.d. entries N (0, 1). Then with probability at least 1 − exp(−c√Kr), where c > 0 is an absolute constant. kGAkop ≤ K(kAkop√r + kAkF ) Nets on Matrices. The following fact is used in [14], which shows the lower bound for the target dimension of linear space embedding. Proposition 4 ([14, Lemma 2]). There exists a net R ⊂ St0 Rt×n of size exp(O(t0n ln(Dn/η)) such that for any R ∈ Rt×n (1 ≤ t ≤ t0) with column norms in [1, D], we can find R′ ∈ R such that kR − R′kop ≤ η. t=1 6 3 Lower bounds For One-sided Sketches Theorem 5. Let 1 ≤ p ≤ 2 and q ≥ 1. There exist a set T ⊂ Rn×n with T = O(n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrix R ∈ Rt×n with t ≤ cn and for all A ∈ T that (8) it must hold that kAkp ≤ kRAkq ≤ Dp,qkAkp Dp,q &(n p− 1 p− 1 2 , q − 1 2 , 2 /t n 1 1 1 q ≤ 2 q ≥ 2 Proof. First we consider the case 1 ≤ p ≤ q ≤ 2. We take T = {In, e1eT identity matrix and {ei} the canonical basis in Rn. We know from letting A = I in (8) that 1 , . . . , eneT n}, where In is the kRkq ≥ n1/p. On the other hand, hence kRkq ≤ t 1 q − 1 2kRkF . kRk2 F ≥ t 2 p n q −1 2 . Hence there exists i such that the i-th column of R, denoted by Ri, satisfies that Letting A = eieT i in (8), kRik2 2 ≥ n t 2 p−1 q −1 2 . Dp,q = Dp,qkeieT i kp ≥ kReieT i kq = kRik2 ≥ 2 1 p− 1 n q − 1 t 2 1 . 1 p− 1 2 . A similar argument works for 1 ≤ p < 2 < q. We take the same T as above. And now i yields n1/p ≤ kRkq ≤ kRkF so there exists i such that kRik2 ≥ n2/p−1. Letting A = eieT Dp,q ≥ n Theorem 6. Let p ≥ 2 and q ≥ 1. There exist a set T ⊂ Rn×n with T = O(n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrix R ∈ Rt×n with t ≤ cn and for all A ∈ T that (8) it must hold that kAkp ≤ kRAkq ≤ Dp,qkAkp Dp,q &(n 2− 1 p , 2− 1 2− 1 q , p /t n 1 1 1 q ≤ 2; q ≥ 2. 7 Proof. Let T = {In, e1eT 1 , . . . , eneT n}. In (8), take A = In, p . kRkq ≤ Dp,qn 1 Take A = eieT i , where Ri is the i-th column of R, and hence kRkF ≥ √n. The lower bound for Dp,q follows from the facts kRik2 =(cid:13)(cid:13)GeieT kRkF ≤(kRkq, 2− 1 t 1 q kRkq, i (cid:13)(cid:13)q ≥ 1, q < 2; q > 2. Theorem 7. Let p, q ≥ 1. There exist a set T ⊂ Rn×n with T = exp(O(t)) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrix R ∈ Rt×n with t ≤ cn and for all A ∈ T that (8) kAkp ≤ kRAkq ≤ Dp,qkAkp it must hold that Dp,q & t 1 p− 1 q . Proof. Let N be an ǫ-net on the unit sphere St−1 of size (1 + 2/ǫ)t. For each x ∈ Rt, define Ax =(cid:18)x 0 0 0(cid:19) then kRAxkp = kR′xk2 and kAxkp = kxk2 for all p, where R′ is the left t × t block of R. Letting A = Ax in (8), Let kxk2 ≤ kR′xk2 ≤ Dp,qkxk2, At =(cid:18)It 0 0(cid:19) , 0 ∀x ∈ N . and take T = {At} ∪ N . Since R satisfies (8) on N , a standard argument (see, e.g., [24, p233]) shows that kR′kop ≤ Dp,q/(1 − ǫ). Thus kR′kq . Dp,qt1/q. On the other hand, letting A = At in (8) gives that kR′kq ≥ t1/p. Hence Dp,q & t1/p−1/q. Theorem 8. Let p, q ≥ 1. There exist a set T ⊂ Rn×n with T = exp(O(t)) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrix R ∈ Rt×n with t ≤ cn and for all A ∈ T that (8) kAkp ≤ kRAkq ≤ Dp,qkAkp it must hold that Dp,q & (t/ ln t) 1 q − 1 p . Proof. Let t′ = t/ ln t. Assume that D = Dp,q ≤ t′, otherwise the result holds already. We can fur- ther assume that p > q. Let N be a (1/2D)-net on St′−1 of size exp(Θ(t′ ln D)) = exp(O(t′ ln t′)) = exp(O(t)). Proceed as in the proof of Theorem 7, and we arrive at kxk2 ≤ kR′xk2 ≤ Dp,qkxk2, ∀x ∈ N , 8 where R′ is the left t′ columns of R. The proof of Theorem 7 shows that kR′kop ≤ 2D. We claim that smin(R′) ≥ 1/2, or equivalently, kR′xk2 ≥ 1/2 for all x ∈ St′−1. For x ∈ St′−1, find y ∈ N such that kx − yk2 ≤ 1/(2D), and thus kR′xk2 ≥ kR′yk2 − kR′(x − y)k2 ≥ 1 −(cid:13)(cid:13)R′(cid:13)(cid:13)opkx − yk2 ≥ 1 − D · We then have that kRAtkq = kR′kq . D(t′)1/p and kRAt′kq = kR′kq & (t′)1/q, and it follows that D & (t′)1/q−1/p. Theorem 9. Let p > 2 and p > q. There exist a set T ⊂ Rn×n with T = poly(n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrix R ∈ Rt×n with t ≤ cn and for all A ∈ T that (8) kAkp ≤ kRAkq ≤ Dp,qkAkp 1 2D = 1 2 . it must hold that Dp,q & (n/t) 1 2− 1 p (9) Instead of proving this theorem, we prove the following rephrased version. Theorem 9' (rephrased). Let p > 2 and p > q. There exist an absolute constant D0 and a set T ⊂ Rn×n with T = O(n ln(Dn)) such that, if D ≥ D0 and it holds for some matrix R ∈ Rt×n and for all A ∈ T that 1 (10) kAkp ≤ kRAkq ≤ D 2− 1 pkAkp then it must hold that t & n/D. Proof. Let r = n/(ρ2D) and t0 = θr for some constants ρ > 1 and θ ∈ (0, 1) to be determined. We shall show that if t ≤ t0, it will not happen that R satisfies (10) for all A ∈ T . Let D be the distribution of Gaussian random matrices of dimension n × r with i.i.d. entries N (0, 1/r). Let R = U ΣV T be the singular value decomposition of R and A ∼ D. Then by rotational invariance of the Schatten norm and Gaussian random matrices, we know that kRAkq is identically distributed as kΣAkq = kBT Σ′kq, where Σ′ is the left t × t block of Σ and B is formed by the first t rows of A. It follows from Proposition 2 that with probability ≥ 1 − exp(−c1c2r), smax(B) ≤ 1 + 2c1r t r ≤ 1 + 2√θc1, and thus kBT Σ′kq ≤ smax(B)kΣ′kq ≤ (1 + 2√θc1)kΣ′kq = (1 + √θc1)kRkq ≤ (1 + 2√θc1)D 1 2− 1 p n 1 p , that is, with probability ≥ 1 − exp(−c1c2r), kRAkq ≤ (1 + 2√θc1)D 1 2− 1 p n 1 p . On the other hand, with probability ≥ 1 − exp(−c1c2r), all singular values of A are at least pn/r − 2c1 = ρ√D − 2c1 ≥ (1 − ǫ)ρ√D if we choose D0 ≥ 4c2 p√D = (1 − ǫ)ρ1− 2 kRAkq ≥ kAkp ≥ (1 − ǫ)sr 1 1/ǫ2. Then 1 p D 1 2− 1 p . p n 9 1 p (1 + ǫ)s√D = (1 + ǫ)ρ1− 2 p n This motivates the following definitions of constraints for R ∈ Rt×n and A ∈ Rn×n: Also, with probability ≥ 1 − exp(−c1c2r), all singular values of A are at most pn/r + 2c1 = ρ√D + 2c1 ≤ (1 + ǫ)ρ√D and thus kAkp ≤ r P1(R, A) : kRAkq ≤ (1 + 2√θc1)D1/2−1/pn1/p P2(R, A) : kRAkq ≥ (1 − ǫ)ρ1− 2 P3(A) : kAkp ≤ (1 + ǫ)ρ1− 2 p n1/pD1/2−1/p. p n1/pD1/2−1/p 2− 1 p . p D 1 1 Now, for m samples A1, . . . , Am drawn from D, it holds for any fixed R that Pr A1,...,Am {∃i s.t. P1(R, A) and P2(R, A) and P3(A) hold} ≥ 1 − e−c1c2mr. (11) t=1 Pr Now it follows from (11) that i kq ≤ D and kGeieT i kq = kRik2, we can restrict the matrix R to matrices with Rt×n of size exp(O(t0n ln(Dn/η)) such Since 1 ≤ kGeieT column norm in [1, D]. Thus we can find a net R ⊂ St0 that for any R with column norms in [1, D], we can find R′ ∈ R such that kR − R′kop ≤ η. A1,...,Am {∀R ∈ R,∃i, P1(R, A) and P2(R, A) and P3(R, A) hold} ≥ 1 − exp(cid:18)O(cid:18)t0n ln mn(cid:17) > 0, if we choose m = Θ(n ln(Dn)). Fix A1, . . . , Am such that for each R ∈ R there exists i such that P1(R′, Ai) and P2(R′, Ai) and P3(Ai) all hold. n , A1, . . . , Am}. We know that if R satisfies (8) for all A ∈ T , then there exists R′ such that kR′−RkF ≤ η, and there exists 1 ≤ i ≤ m such that P1(R′, Ai), P2(R′, Ai) and P3(Ai) all hold. It follows that η (cid:19)(cid:19) exp(cid:16)− Take T = {In, e1eT 1 , . . . , eneT c1c2 D Dn and kRAikq ≤ kR′Aikq + k(R − R′)Aikq ≤ kR′Aikq + kR − R′kopkAikp ≤(cid:16)1 + 2√θc1 + (1 + ǫ)ρ1− 2 p η(cid:17) D kRAikq ≥ kRAikq − k(R − R′)Aikq ≥ kR′Aikq − kR − R′kopkAikp p D ≥ ((1 − ǫ) − (1 + ǫ)η) ρ1− 2 1 2− 1 p n 1 p 1 2− 1 p n 1 p We meet a contradiction when θ, ǫ and η are all sufficiently small and ρ is sufficiently large, for instance, when η = Θ(ǫ), θ = Θ(ǫ2/c2 2) and ρ = Θ(1 + pǫ/(p − 2)). Using almost the exact argument with the identical set T as in the proof of Theorem 9 we can prove a similar bound for p < 2. The proof is omitted. Theorem 10 (p < 2). Let 1 ≤ p < 2 and p < q. There exist a set T ⊂ Rn×n with T = poly(n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrix R ∈ Rt×n with t ≤ cn and for all A ∈ T that (8) kAkp ≤ kRAkq ≤ Dp,qkAkp it must hold that Dp,q & (n/t) 1 p− 1 2 . 10 4 Lower Bounds for Two-sided Sketches Theorem 11. Let 1 ≤ p ≤ 2 and q ≥ 1. There exist a set T ⊂ Rn×n with T = O(n2 ln n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrices R, S ∈ Rt×n with t ≤ cn and for all A ∈ T that (12) it must hold that Proof. First we consider the case 1 ≤ p ≤ q ≤ 2. Without loss of generality we can assume that maximum column norm of R and S are the same. Let F be the distribution of n × n Gaussian matrices of i.i.d. entries N (0, 1) and F ∼ F. With probability ≥ 0.9, the following conditions hold: kAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ Dp,qkAkp Dp,q &(n p− 1 p− 1 2 , q − 1 2 , 2 /t n 1 1 1 q ≤ 2 q ≥ 2 P1(F ) : kFkp & n1/p√n, P2(F, R, S) : (cid:13)(cid:13)RF ST(cid:13)(cid:13)F . kRkFkSkF P3(g) : kgkp . √n, P4(g, R) : kRgk2 & kRkF . Let g ∼ N (0, In), then with probability ≥ 0.9 the following conditions further holds: Therefore for any fixed R and S, Pr F∼F g,h∼N (0,In) {P1(F ), P2(F, R, S), P3(g), P4(g, R), P3(h), P4(h, S) all hold} ≥ 0.7. Hence if we draw m samples F1, . . . , Fm from F and 2m samples g1, . . . , gm, h1, . . . , hm from N (0, In), it holds that Fi,gi,hi {∃i s.t. P1(Fi), P2(Fi, R, S), P3(gi), P4(gi, R), P3(hi), P4(hi, S) all hold} ≥ 1 − (0.3)m. Pr Next, we find a net M ⊂ Scn Rt×n of size exp(O(n2 ln(n/η)) such that for any M with column norms in [1,√n], we can find M′ ∈ G such that kM − M′kop ≤ η. Let m = Θ(n2 ln(n/η)), we can find F1, . . . , Fm and g1, . . . , gm, h1, . . . , hm such that for any R, S ∈ M, there exists i such that t=1 P1(Fi), P2(Fi, R, S), P3(gi), P4(gi, R), P3(hi), P4(hi, S) all hold. Let T = {eieT i=1. Now, given any R, S with maximum column norm √n, a standard net argument show that those properties above still hold (probably with slightly smaller or larger heading constants) for some i. Thus i,j=1 ∪{F1, . . . , Fm}∪{gihT i }m j }n kRkFkSkF & kRFiSTkF ≥ kRFiSTkq q − 1 1 2 t & kFikq q − 1 t 2 1 & 2 1 p + 1 n q − 1 t 2 1 (13) and kRkFkSkF . kRgik2kShik2 =(cid:13)(cid:13)RgihT i ST(cid:13)(cid:13)q ≤ D(cid:13)(cid:13)gihT i (cid:13)(cid:13)2 = Dkgik2khik2 ≤ Dn. 11 It follows immediately that D & 2 1 p− 1 n q − 1 t 1 2 . When the maximum norm of R and S is at least √n, say, kRik2 = kSjk2 ≥ √n, then D ≥ kReieT j Sk2 = kRik2kSjk2 ≥ n. This completes the proof for q ≤ 2. When q > 2, instead of (13) we have kRkFkSkF & kRFiSTkF ≥ kRFiSTkq & kFkq & n 1 p + 1 2 . 1 p− 1 2 . and thus D & n Theorem 12. Let p ≥ 2 and q ≥ 1. There exist a set T ⊂ Rn×n with T = O(n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrices R, S ∈ Rt×n with t ≤ cn and for all A ∈ T that (12) it must hold that kAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ Dp,qkAkp Dp,q &(n 2− 1 p , 2− 1 2− 1 q , p /t n q ≤ 2; q ≥ 2. 1 1 1 Proof. The proof is similar to that of Theorem 11, except that we need upper bounds for P1(F ) and P4(g, R) and lower bounds for P2(F, R, S) and P3(g). Details are omitted. Theorem 13. Let p, q ≥ 1. There exist a set T ⊂ Rn×n with T = exp(O(t)) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrices R, S ∈ Rt×n with t ≤ cn and for all A ∈ T that (12) it must hold that kAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ Dp,qkAkp Dp,q & t 1 p− 1 q . Proof. Let N be an ǫ-net on the unit sphere St−1 of size (1 + 2/ǫ)t. Let At =(cid:18)It 0 0(cid:19) , and take T = {At} ∪ N . For each pair (x, y) ∈ Rt, define 0(cid:19) 0 Ax,y =(cid:18)xyT 0 0 then kRAx,ySTkp = kR′xk2kS′yk2 and kAx,ykp = kxk2kyk2 for all p, where R′ and S′ are the leftmost t × t block of R and S respectively. Letting A = Ax,y in (12), kxk2kyk2 ≤ kR′xk2kS′yk2 ≤ Dp,qkxk2kyk2, ∀x, y ∈ N . A standard argument as in [24, p233] shows that kR′kopkS′kop ≤ Dp,q/(1 − ǫ). Thus kR′S′kq . Dp,qt1/q. On the other hand, letting A = At in (12) gives that kR′S′kq ≥ t1/p. Hence Dp,q & t1/p−1/q. 12 Theorem 14. Let p, q ≥ 1. There exist a set T ⊂ Rn×n with T = exp(O(t ln t)) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrices R, S ∈ Rt×n with t ≤ cn and for all A ∈ T that (12) it must hold that kAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ Dp,qkAkp 1 Dp,q & (t/ ln t) q − 1 p . Proof. Let t′ = t/ ln t and assume that D = Dp,q ≤ t, otherwise the result holds already. We can further assume that p > q. Let N be a (1/2D)-net on Rt of size exp(O(t ln D)) = exp(O(t′ ln t′)) = exp(Θ(t)). Proceed as in the proof of Theorem 13, and we arrive at kxk2kyk2 ≤ kR′xk2kS′xk2 ≤ Dp,qkxk2kyk2, ∀x, y ∈ N , where R′ and H′ are the left t′ columns of R and S, respectively.. The proof of Theorem 13 shows that kRkopkSkop ≤ 2D, whence an argument similar to that in Theorem 8 shows that smin(R′)smin(S′) ≥ 1/2. We then have that kRAt′STkq = kR′S′Tkq . D(t′)1/p and kRAt′STkq = kR′S′Tkq & (t′)1/q, and it follows that D & (t′)1/q−1/p. Theorem 15. Let p < 2. There exist a set T ⊂ Rn×n with T = poly(n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrices R, S ∈ Rt×n with t ≤ cn and for all A ∈ T that (12) it must hold that kAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ Dp,qkAkp 3 Dp,q & (n/t) 1 p− 1 2 / log 2 t. (14) (15) Instead of proving this theorem, we prove the following rephrased version. Theorem 15' (rephrased). Let p < 2, p > q and D ≥ D0 for some an absolute constant D0. There exists a set T ⊂ Rn×n with T = O(n ln(Dn)) such that it holds for some matrices R, S ∈ Rt×n and for all A ∈ T that 1 then it must hold that t & n/(D log3p/(2−p) t). kAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ D p− 1 2kAkp We need two auxiliary lemmata. Lemma 16. Let A and B be deterministic n × n matrices and G be a Gaussian random matrix of i.i.d. N (0, 1) entries. It holds with probability 1 − O(1) that kAGBkp . (log 5 2 n)(log log n)kAkopkBkopEp(A, B), where Ep(A, B) = max 0≤i,j≤3 log n 1 2i+j · min{Ni(A), Nj (B)} 1 p · max(cid:26)pNi(A),qNj(B)(cid:27) . (16) 13 Proof. By rotational invariance we may assume that A and B are diagonal. Write A = diag(a1, . . . , an) and B = diag(b1, . . . , bn), where ai, bi ≥ 0. By scaling we further assume that kAkop = 1 and kBkop = 1. For notational simplicity, let Ii = Bi(A), Jj = Bj(A) and si = Ii, tj = Ji. Let GI,J be the submatrix of G restricted to rows indiced by I and columns indiced by J. Then kAGBkp ≤Xi,j (cid:13)(cid:13)AIiGIiJj BJj(cid:13)(cid:13)p ≤Xi,j 2i+j(cid:13)(cid:13)GIiJj(cid:13)(cid:13)p. 1 (17) Now, for each i and j, it holds with probability ≥ 1− exp(−cK 2 max{si, tj}) ≥ 1− exp(−cK 2) that 1 2i+j kGIiJjkp ≃ 1 2i+j · K(√si +ptj) min{si, tj} 1 p We claim that summands on the rightmost side of (17) with max{i, j} ≥ 3 log n are negligible. Indeed, taking K = Θ(√log n), then Xmax{i,j}≥3 log n 1 2i+j kGIiJjkp ≤ 1 n3 · Θ(plog n) Xmax{i,j}≥3 log n (si + tj) ≤ 1 n2 · Θ(plog n) · 2n = o(1) with failure probability ≤ n2 exp(−cK 2) = O(1). Note that when i = 0 and j = 0, the corre- sponding summand is & K = Θ(√log n), hence the summands with max{i, j} ≥ 3 log n is indeed negligible. The claim result follows immediately, where we need to take a union bound over all i, j ≤ 3 log n, so we need which holds when K = Θ(log log n). (3 log n + 1)2 exp(−cK 2) = O(1), Lemma 17. Let A and B be deterministic n × N matrices and G, H be N × r Gaussian random matrix of i.i.d. N (0, 1) entries. Suppose that n ≤ cr for some absolute constant c ∈ (0, 1). It holds with probability 1 − O(1) that kAGH T BTkp & √rkAkopkBkopEp(A, B), where Ep(A, B) is as defined in (16). Proof. As in the proof of Lemma 16, we assume that kAkop = kBkop = 1 and define Ii, Jj, si, tj, GI,J in the same manner. Similarly to before, it holds with probability 1 − O(1) that Xmax{i,j}≥3 log n(cid:13)(cid:13)AIiGIiJj BJj(cid:13)(cid:13)p = o(1). Now we choose the (i, j) block with biggest Schatten-p norm among i, j ≤ 3 log n, that is, we choose i and j such that Then (cid:13)(cid:13)AIiGIiJj BJj(cid:13)(cid:13)p = max 1≤i′,j ′≤3 log n(cid:13)(cid:13)(cid:13) AIi′ GIi′ Jj′ BJj′(cid:13)(cid:13)(cid:13)p 1 . 1 p (cid:0)(√r − C√si)(√r − Cptj)(cid:1) (cid:13)(cid:13)GIiJj(cid:13)(cid:13)p ≥ min{si, tj} p & min{si, tj} 1 p r 14 1 2j+1 ·(cid:13)(cid:13)GIiJj(cid:13)(cid:13)p 1 p 1 2j r 1 2i · & min{si, tj} & min{si, tj} 1 p max{√si,ptj} 1 2i · 1 2j √r. with probability ≥ 1 − exp(−cr), and thus 1 2i+1 · (cid:13)(cid:13)AIiGIiHJj BJj(cid:13)(cid:13)p ≥ The claimed lower bound follows immediately, noting that the sum over max{i, j} ≥ 3 log n is negligible compared with the term corresponding to i = j = 0. Proof of Theorem 15'. Without loss of generality, we can assume that the maximum column norm of R and that of S are the same; otherwise we can rescale R and S. Let r = n/(ρ2D) and t0 = θr for some ρ = Θ(log3p/(2−p) t) and θ ∈ (0, 1) to be determined. We Let D be the distribution of Gaussian random matrices of dimension n × r with i.i.d. entries It follows from Lemma 17 that with probability ≥ Skq & √rEq(R, S). (18) shall show that if t ≤ t0, it will not happen that G satisfies (15) for all A ∈ T . N (0, 1) and let G, H ∼ D be independent. 1 − O(1), kΣRGH T ΣT On the other hand, it follows from (12) that with probability ≥ 1 − exp(−c1n), kΣRGH T ΣT Skq ≤ D 1 2− 1 pkGH Tkp . D 1 2− 1 p nr 1 p . (19) Now, let F be the distribution of n× n Gaussian matrix of i.i.d. entries N (0, 1) and let F be drawn from F. Then kRF Skq is identically distributed as ΣRF ′ΣS, where F ′ is a random t × t Gaussian matrix of i.i.d. entries N (0, 1). It follows from Lemma 16 that with probability ≥ 1 − O(1), 2 t)(log log t)Eq(R, S) ≤ (log3 t)Eq(R, S) On the other hand, it follows from (12) that with probability ≥ 1 − exp(−c2n), kΣRF ′ΣT Skq . (log 5 kRF STkq ≥ kFkp & n1/p√n. (20) (21) Define events P1(G, H, R, S) and P2(F, R, S) to be (18) and (20) respectively. Further define P3(G, H) : (cid:13)(cid:13)GH T(cid:13)(cid:13)p . nr1/p, P4(F ) : kFkp . n1/p√n. Pr Now, for 2m samples G1, . . . , Gm, H1, . . . , Hm independently drawn from D, and m samples Both P3(G, H) and P4(F ) hold with probability ≥ 1 − exp(−c3n) when G, H ∼ D and F ∼ F. F1, . . . , Fm independently drawn from F, it holds for any fixed S and T that Gi,Hi,Fi {∃i s.t. P1(Gi, Hi, R, S) and P2(Fi, R, S) and P3(Gi, Hi) and P4(Fi) all hold} ≥ 1−e−c4m. (22) j STkq = kRik2kSjk2 ≤ D, we can restrict the matrix R and S to matrices with column norm in [1,√D]. Thus we can find a net M ⊂St0 Rt×n of size exp(O(t0n ln(Dn/η)) such that for any M with column norms in [1,√D], we can find M′ ∈ G such that kM − M′kop ≤ η. Since 1 ≤ kReieT t=1 15 Now it follows from (22) that Pr Gi,Hi,Fi {∀R, S ∈ M,∃i, P1(Gi, Hi, R, S) and P2(Fi, R, S) and P3(Gi, Hi) and P4(Fi) all hold} η (cid:19)(cid:19) exp (−c4m) > 0, if we choose m = Θ(n ln(Dn)). Fix {Gi, Hi, Fi}i such that for each pair R′, S′ ∈ M there exists i such that P1(Gi, Hi, R′, S′) and P2(Fi, R′, S′) and P3(Gi, Hi) and P4(Fi) all hold. i }i ∪ {Fi}i. We know that if (R, S) satisfies (12) for all A ∈ T , then there exists R′ and S′ such that kR′−Rkop ≤ η and kS′−Skop ≤ η, and there exists 1 ≤ i ≤ m such that P1(Gi, Hi, R′, S′) and P2(Fi, R′, S′) and P3(Gi, Hi) and P4(Fi) all hold. One can then show that (18), (19), (20), (21) all hold with slightly larger or smaller constants for R and S. It follows that ≥ 1 − exp(cid:18)O(cid:18)t0n ln Dn Take T = {In} ∪ {eieT j } ∪ {GiH T 1 p√n n log3 t 1 p− 1 2√rnr 1 p , . D or, 1 log3 t .(cid:18) rD n (cid:19) 1 p− 1 2 = 1 p−1 2 , ρ which contradicts our choice of ρ (the hidden constant in . above depends only on D0, θ and η, and then we can choose the hidden constant in the Θ-notation for ρ). Using almost the exact argument with the identical set T as in the proof of Theorem 15 we can prove a similar bound for p > 2. We need a lower bound for Lemma 16 and an upper bound for Lemma 17, which are corollaries of non-commutative Khintchine inequality. Theorem 18. Let p > 2. There exist a set T ⊂ Rn×n with T = poly(n) and an absolute constant c ∈ (0, 1) such that, if it holds for some matrices R, S ∈ Rt×n with t ≤ cn and for all A ∈ T that (12) it must hold that kAkp ≤(cid:13)(cid:13)RAST(cid:13)(cid:13)q ≤ Dp,qkAkp 1 Dp,q & (n/t) 2− 1 p . The proof of the theorem is omitted but we shall show the two auxiliary corollaries of non- commutative Khintchine inequality. Corollary 19. Let A and B be deterministic n × n matrices and G be a Gaussian random matrix of i.i.d. N (0, 1) entries. It holds with probability 1 − O(1) that kAGBkp ≃ max{kAkpkBkF ,kAkFkBkp}, p ≥ 2. Proof. Note that the function X 7→ kAGBkp is a Lipschitz function with Lipschitz constant kAkopkBkop when p ≥ 2. Using concentration inequality for Lipschitz function on Gaussian space, it suffices to show that E G kAGBkp ≃ max{kAkpkBkF ,kAkFkBkp}. 16 By rotational invariance, assume that A and B are diagonal matrices, whose diagonal entries are (a1, . . . , an) and (b1, . . . , bn), respectively. Write AGB =Xi,j gijaibjeieT j =:Xi,j gijCi,j. To apply noncommutative Khintchine inequality, we shall calculate  Xi,j (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) Ci,jC T i,j  1 2(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)p and  Xi,j C T i,jCi,j  (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) . 1 2(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)p Xi,j Xi,j Ci,jC T i,j =Xi,j i,jCi,j =Xi,j C T a2 i b2 j eieT a2 i b2 j ejeT i = kBk2 j = kAk2 F A2 F B2, Note that and thus = kBkFkAkp and = kAkFkBkp. (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)  Xi,j C T i,jCi,j  1 2(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)p  Xi,j Ci,jC T i,j  (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) 1 2(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)p The result follows immediately from noncommutative Khintchine inequality. Corollary 20. Let A and B be deterministic n× N matrices and G, H be N × r Gaussian random matrix of i.i.d. N (0, 1) entries. Suppose that n ≤ cr for some absolute constant c ∈ (0, 1). It holds with probability 1 − exp(−r) that kAGH T BTkp ≃ √r max{kAkpkBkF ,kAkFkBkp}. 1 Proof. Note that the function X 7→ kAGH T BTkp is a Lipschitz function with Lipschitz constant 2kAkopkBkop when p ≥ 2. Using the concentration inequality for Lipschitz function on Gaussian space, it suffices to show that G,H kAGH T BTkp ≃ √r max{kAkpkBkF ,kAkF kBkp}. E It follows from the proof of the previous lemma that E G kAGH T BTkp ≃ √r max{kAkpkHBkF ,kAkFkHBkp}. The result is immediate, noting that EkHBkp ≃ √rkBkp because E smax(H), E smin(H) ≃ √r. 17 5 Upper bounds We show specific designs of G that achieve the distortion in Dp,q advertised in the introduction, up to logarithmic factors. Specifically, we show that (a) we can design G with r = 1 which attains the distortion Dp,q for 1 ≤ p ≤ 2 ≤ q and 1 ≤ q ≤ 2 ≤ p; (b) for some θ ∈ (0, 1) and t ≤ θn, we can design G with r = Θ(t log(n/t)) rows which attains the distortion Dp,q, in all other cases of p, q. 5.1 Cases other than 1 ≤ p ≤ 2 ≤ q and 1 ≤ q ≤ 2 ≤ p Let G ∈ Rr×n (r ≥ Ct) be a random matrix and c, c′, η > 0 be absolute constants which satisfy the following properties: (a) (subspace embedding) For a fixed t-dimensional subspace X ⊆ Rn it holds with probability ≥ 1 − exp(−c′t) that ∀x ∈ X. (b) For a fixed A ∈ Rn×n it holds with probability ≥ 1 − exp(−c′r) that (1 − η)kxk2 ≤ kGxk2 ≤ (1 + η)kxk2, kGAkop ≤ c(cid:18)kAkop + 1 √rkAkF(cid:19) (c) For a fixed A ∈ Rn×n it holds with probability ≥ 1 − exp(−c′r) that (1 − η)kAkF ≤ kGAkF ≤ (1 + η)kAkF . Consider the singular value decomposition A = U ΣV T , where U and V are orthogonal matrices, Σ = diag{σ1, . . . , σn} with σ1 ≥ σ2 ≥ ··· . For an index set I ⊆ [n], define AI = U ΣIV T , where ΣI is Σ restricted to the diagonal elements with indices inside I (the diagonal entries with indices outside I are replaced with 0). Theorem 21. Let p, q ≥ 1. There exist constants θ = θ(p, q) < 1 small enough and C = C(p, q) large enough such that for t ≤ θn and matrix G satisfying the aforementioned properties, it holds for any (fixed) A ∈ Rn×n with probabilty 1 − exp(−c′′t) that t p− 1 1 n 1 2 q − 1 2 log n t q − 1 p− 1 n t , 1 2 1 min( 1 log n t kAkp . kGAkq . kAkp, 2)kAkp . kGAkq . t 1 1 1 p− 1 q log n t t kAkp . kGAkq . max( n 1 p 2− 1 2− 1 q 1 p ≤ q < 2 q − 1 pkAkp, , 1) kAkp, q ≤ p < 2 q ≥ p ≥ 2 1 log n t kAkp . kGAkq . q kAkp, p ≥ q ≥ 2 1 t 2− 1 n 2− 1 t p 1 18 Note that for t = Ω(log n) and r = Ct for some large C, a Gaussian random matrix of i.i.d. entries N (0, 1/r), or a randomized Hadamard Transform matrix of t polylog(t) rows, satisfies the conditions on G [8]. We thus have an immediate corollary of Theorem 21 as follows. Corollary 22. Suppose that 1 ≤ p, q and c log n ≤ t ≤ θn for some absolute constants θ ∈ (0, 1) and c ≥ 1. There exists (random) G ∈ Rr×m with r & t such that with probability ≥ 1− exp(−c′′t), 1 t kAkp ≤ kGAkq . kAkp ≤ kGAkq . max(cid:26)(cid:16) n t(cid:17) kAkp ≤ kGAkq . max(cid:26)(cid:16) n t(cid:17) kAkp . kGAkq . 1 n n 1 2 p− 1 q − 1 p− 1 1 2 2 (cid:16)log 1 q − 1 , t 1 2− 1 p , t 1 p 2− 1 n 2− 1 t q (cid:16)log n t(cid:17)kAkp, p(cid:27)(cid:16)log q(cid:27)(cid:16)log t(cid:17)kAkp, 1 ≤ p < q < 2; t(cid:17)kAkp, t(cid:17)kAkp, p ≥ q ≥ 2. n n 1 p− 1 1 ≤ q ≤ p ≤ 2; q ≥ p ≥ 2; In particular when p = q, kAkp ≤ kGAkp .(cid:16) n t(cid:17) kAkp ≤ kGAkp .(cid:16) n t(cid:17) 1 p− 1 1 2− 1 2 (cid:16)log p (cid:16)log n n t(cid:17) , t(cid:17) , To prove Theorem 21, we need a few auxillary lemmata. p ≤ 2 p ≥ 2 Lemma 23. Let θ, t, C and G be as defined in Theorem 21 and b = Θ(log(n/t)). At least one of the following conditions will hold: and σ2 s ≤ 2 t σ2 i for some s ≤ bt. σp i ≥ 1 2 σp i . n Xi=1 bt Xi=1 Xi=s n (23) (24) To prove the preceding lemma we need a further auxiliary lemma. Consider the first b blocks of singular values of A each of size t, that is, I1 = {σ1, . . . , σt}, . . . , Ib = {σ(b−1)t+1, . . . , σbt}. Lemma 24. If (24) does not hold for any s ≤ bt, it must hold for all 2 ≤ j ≤ b that σjt ≤ 1 Proof. If this is not true for some j then 2 σ(j−1)t. jt Xi=(j−1)t+1 which contradicts (24) with s = (j − 1)t ≤ bt. σ2 i ≥ tσ2 jt > t 2 σ2 (j−1)t, Now we prove Lemma 23. 19 Proof of Lemma 23. Suppose that (23) does not hold and we need to show that (24) holds for some s ≤ bt. Otherwise, it follows from the Lemma 24 that n(cid:19)2 2b ≤(cid:18) t t2p 1 ≤ tθ2p−1σp n2p−1 σp 1, σp i < nσp σbt+1 ≤ bt+1 ≤ and thus (25) σ1 σ1 n Xi=bt+1 On the other hand, bt Xi=1 σp i ≥ tσp 1(cid:18) 1 2 + 1 4 + ··· + 1 2b(cid:19) =(cid:18)1 − 1 2b(cid:19) tσp 1 = (1 − θ2)tσp 1. (26) Using the assumption on θ, we see that the rightmost side of (26) is bigger than the rightmost side of (25), which contradicts the assumption that (23) does not hold. Lemma 25. Let p, q ≥ 1, and t, b and G be defined as in Lemma 23. Suppose that s satisfies (24) and let J = {s, s + 1, . . . , n}. Then 2 kAJkp, q kAJkp, Proof. Combining Property (b) of G with (24) yields that kGAJkq &  1 p 1 n 1 p 1 q 1 2 t t − − − 1 1 p ≤ 2 p > 2. kGAJkop ≤ On the other hand, c √t √2 +r 1 C!kAJkF =: K √tkAJkF kGAJkF ≥ 1 2kAJkF . This implies that at least αr singular values of GAJ are at least γ√tkAJkF , provided that 1 C(cid:0)(1 − α)γ2 + αK 2(cid:1) < 4 which is satisfied if we choose γ = Θ(1/√C), α = Θ(1/K 2/q). , Now, when p ≤ 2, When p > 2, we have and thus kGAJkq ≥ (αr) 1 q γ √tkAJkF ≥ (αC) 1 q γ · t n 1 2 q − 1 p− 1 1 2 kAJkp. kAJkp ≤ kAJk p 1− 2 op kAJk 2 p F ≤(cid:18) 2 t(cid:19) 1 2− 1 p kAJkF , kGAJkq ≥ (αr) 1 q γ √tkAJkF ≥ (αC) 1 q γ q · 2− 1 1 t 20 1 2− 1 1 p kAJkp & (cid:0) 2 t(cid:1) 1 p− 1 1 q kAJkp. t Lemma 26. Let p, q ≥ 1, and t, b and G be defined as in Lemma 23. Suppose that s satisfies (24) and let J = {s, s + 1, . . . , n}. Then Proof. When p ≤ 2, we have that p, q ≤ 2; p, q ≥ 2. q kAJkp, q kAJkp, 1 p 1 1 − − 1 t n 1 p 1 2 kGAJkq .  kAJk2 F ≤ kAJkp 1 2 t − pkAJk2−p op . Using (24), we obtain that kAJkp ≥ kAJk2/p kAJk2/p−1 op F ≥(cid:18) t 2(cid:19) When q ≤ 2, it follows from Property (c) of G that 1 p− 1 2 kAJkF . kGAJkq ≤ r 1 q − 1 2kGAJkF ≤ (1 + η)r 1 q − 1 2kAJkF . Thus when p, q ≤ 2, kGAJkq ≤ (1 + η)r When p, q > 2, 1 q − 1 t(cid:19) 2 (cid:18) 2 1 p− 1 2 kAJkp = (1 + η)(Cbqt) 1 q − 1 t(cid:19) 2 (cid:18) 2 1 p− 1 2 kAJkp . t 1 p− 1 1 q kAJkp. kGAJkq ≤ kGAJk q 1− 2 op kGAJk 2 q F ≤(cid:18) K √tkAkF(cid:19)1− 2 q ((1 + η)kAkF ) 2 q = ((1 + η)) 2 q t 1 2− 1 1 q kAkF . 1 p 2− 1 2− 1 1 q kAkp. n t Now we are ready to show Theorem 21. Proof of Theorem 21. It follows from the subspace embedding property of G to show that (1 − η)kAIikq ≤ kGAIikq ≤ (1 + η)kAIikq, 1 ≤ i ≤ b and thus 1 − η p− 1 t 1 q kAIikp ≤ kGAIikq ≤ (1 + η)kAIikp, pkAIikp, q − 1 1 p ≤ q; p ≥ q. (1 − η)kAIikp ≤ kGAIikq ≤ (1 + η)t When (23) holds, there exists i∗ (1 ≤ i∗ ≤ b) such that 1 1 p bkAkp 2 (cid:13)(cid:13)AIi∗(cid:13)(cid:13)p ≥ 21 and thus 1 p− 1 1 bt 1 q kAkp .(cid:13)(cid:13)GAIi∗(cid:13)(cid:13)q . kAkp, 1 q − 1 pkAkp, When (23) does not hold, let J be as defined in Lemma 25 and bkAkp .(cid:13)(cid:13)GAIi∗(cid:13)(cid:13)q . t p ≤ q p ≥ q 1 p kAkp ≤ kAJkp ≤ kAkp. 1 2 The claimed upper and lower bounds follow from combining the bounds above, together with Lemma 25, Lemma 26, and kGAkq ≥ maxnkGAI1kq, . . . ,kGAIbkq,kGAJkqo b kGAkq ≤ Xi=1(cid:13)(cid:13)GA[Ii](cid:13)(cid:13)q + kGAJkq. 5.2 Case 1 ≤ p ≤ 2 ≤ q and 1 ≤ q ≤ 2 ≤ p Theorem 27. Let 1 ≤ p ≤ 2 ≤ q or 1 ≤ q ≤ 2 ≤ p. Let g ∼ N (0, In). Then with arbitrarily large constant probability, 1 2− 1 n pkAkp .(cid:13)(cid:13)gT A(cid:13)(cid:13)q . kAkp, p− 1 2kAkp, kAkp .(cid:13)(cid:13)gT A(cid:13)(cid:13)q . n 1 1 ≤ p ≤ 2 ≤ q; 1 ≤ p ≤ 2 ≤ q. Proof. Note that gT A is a row vector, and it holds that (cid:13)(cid:13)gT A(cid:13)(cid:13)q =(cid:13)(cid:13)gT A(cid:13)(cid:13)F for all q. Since (cid:13)(cid:13)gT A(cid:13)(cid:13)F = Θ(kAkF ) with arbitrarily large constant probability, the theorem follows from the facts that 1 2− 1 n p ≤ kAkF ≤ kAkp, p < 2 kAkp ≤ kAkF ≤ n 1 2− 1 pkAkp, p > 2. 6 Application to Streaming Algorithms Here we show that we can implement our embedding as a streaming algorithm. The two things we need to show are that our sketching matrices can be maintained with limited randomness, and our sketch can be maintained in small space. We first prove our claim that we can truncate sketching matrices to Θ(log n) bits for each entry by verifying that properties (a), (b) and (c) of Section 5 will continue to hold after truncation. Let G be a matrix satisfying properties (a), (b) and (c), and let G′ be of the same dimension as G such that (G − G′)ij ≤ 1/ poly(n) for all i, j. We can choose the power of n in poly(n) big enough such that kG − G′kop ≤ 0.001. Then (cid:12)(cid:12)kG′xk2 − kGxk2(cid:12)(cid:12) ≤ k(G − G′)xk2 ≤ kG − G′kopkxk2 ≤ 0.001kxk2 22 and which shows that properties (a) and (c) hold for G′ with a slightly bigger η. Lastly, (cid:12)(cid:12)(cid:13)(cid:13)G′A(cid:13)(cid:13)F − kGAkF(cid:12)(cid:12) ≤(cid:13)(cid:13)(G − G′)A(cid:13)(cid:13)F ≤(cid:13)(cid:13)G − G′(cid:13)(cid:13)opkAkF ≤ 0.001kAkF , (cid:12)(cid:12)(cid:12)(cid:13)(cid:13)G′A(cid:13)(cid:13)op − kGAkop(cid:12)(cid:12)(cid:12) ≤(cid:13)(cid:13)(G − G′)A(cid:13)(cid:13)op ≤(cid:13)(cid:13)G − G′(cid:13)(cid:13)opkAkop ≤ 0.001kAkop, which shows that property (b) holds for G′ with a slightly bigger constant c. Next we show that the three properties (a), (b) and (c) also hold for Gaussian random matrices with reduced randomness. Let G be a random matrix with Θ(r)-wise independent entries each drawn from an N (0, 1/r) distribution, but truncated to additive 1/ poly(n) for a suficiently large poly(n) (recall that in our streaming application, r = n/D2 -- see Section 1 for discussion). It is known that without the truncation, G with Θ(r)-wise independent entries provides a subspace embedding for t-dimensional spaces (see, e.g., the second part of the proof of Theorem 8 of [12], which is stated for sign matrices but the same argument holds for Gaussians. For the latter, one can replace Theorem 2.2 of [6] with the more general Theorem 6 and Remark 1 of [10]), which is property (a). It is also known that G is a Johnson-Lindenstrauss transform [11, Remark 7], that is, Pr{(1 − η)kxk2 ≤ kGxk2 ≤ (1 + η)kxk2} ≥ 1 − exp(−c′r), whence Property (c) follows immediately by taking a union bound over the columns x of A (recall that r ≥ t ≥ log n). Since G provides a subspace embedding, property (b) follows from Theorem 1 in [8]. Finally, note that as argued above, given that properties (a), (b), and (c) hold for G before truncation, they also hold after truncation. It follows from the discussion above that we can store an O((n/D2) log n) bit seed to succinctly describe and generate matrices R and S, and for matrices A specified with O(log n) bits, we can store our sketch RAS in a stream using (n2/D4) polylog(n) bits of memory. Note that the space needed to store the random seed to generate R and S is negligible compared to the space to store the sketch RAS. References [1] Alexandr Andoni. Nearest neighbor the In http://www.mit.edu/~andoni/nns-barriers.pdf. workshop: Barriers in search in Computational high-dimensional Complexity II, spaces. 2010. [2] Alexandr Andoni, Robert Krauthgamer, and Ilya Razenshteyn. Sketching and embedding are In Proceedings of the Forty-Seventh Annual ACM on Symposium on equivalent for norms. Theory of Computing, pages 479 -- 488. ACM, 2015. [3] Jaroslaw Blasiok, Vladimir Braverman, Stephen R. Chestnut, Robert Krauthgamer, and Lin F. Yang. Streaming symmetric norms via measure concentration. arXiv:1511.01111, 2016. [4] Vladimir Braverman, Stephen R. Chestnut, Robert Krauthgamer, and Lin F. Yang. Sketches for matrix norms: Faster, smaller and more general. CoRR, abs/1609.05885, 2016. [5] Emmanuel Candes and Benjamin Recht. Exact matrix completion via convex optimization. Communications of the ACM, 55(6):111 -- 119, 2012. 23 [6] Kenneth L. Clarkson and David P. Woodruff. Numerical linear algebra in the streaming model. In Proceedings of the 41st Annual ACM Symposium on Theory of Computing, STOC 2009, Bethesda, MD, USA, May 31 - June 2, 2009, pages 205 -- 214, 2009. [7] Kenneth L Clarkson and David P Woodruff. Low rank approximation and regression in input sparsity time. In Proceedings of the forty-fifth annual ACM symposium on Theory of computing, pages 81 -- 90. ACM, 2013. [8] Michael B. Cohen, Jelani Nelson, and David P. Woodruff. Optimal approximate matrix product In 43rd International Colloquium on Automata, Languages, and in terms of stable rank. Programming, ICALP 2016, July 11-15, 2016, Rome, Italy, pages 11:1 -- 11:14, 2016. [9] Aram W Harrow, Ashley Montanaro, and Anthony J Short. Limitations on quantum dimen- sionality reduction. In International Colloquium on Automata, Languages, and Programming, pages 86 -- 97. Springer, 2011. [10] Daniel M. Kane, Raghu Meka, and Jelani Nelson. Almost optimal explicit johnson- lindenstrauss families. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques - 14th International Workshop, APPROX 2011, and 15th Inter- national Workshop, RANDOM 2011, Princeton, NJ, USA, August 17-19, 2011. Proceedings, pages 628 -- 639, 2011. [11] Daniel M Kane and Jelani Nelson. A derandomized sparse Johnson-Lindenstrauss transform. arXiv:1006.3585, 2010. [12] Ravi Kannan, Santosh Vempala, and David P Woodruff. Principal component analysis and higher correlations for distributed data. In COLT, 2014. [13] Weihao Kong and Gregory Valiant. Spectrum estimation from samples. CoRR, abs/1602.00061, 2016. [14] Kasper Green Larsen and Jelani Nelson. The Johnson-Lindenstrauss Lemma Is Optimal for Linear Dimensionality Reduction. In Ioannis Chatzigiannakis, Michael Mitzenmacher, Yuval Rabani, and Davide Sangiorgi, editors, 43rd International Colloquium on Automata, Lan- guages, and Programming (ICALP 2016), volume 55 of Leibniz International Proceedings in Informatics (LIPIcs), pages 82:1 -- 82:11, 2016. [15] Michel Ledoux and Michel Talagrand. Probability in Banach spaces. Springer-Verlag, Berlin, 1991. [16] Yi Li, Huy L. Nguyen, and David P. Woodruff. On sketching matrix norms and the top singular vector. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 1562 -- 1581, 2014. [17] Yi Li and David P. Woodruff. On approximating functions of the singular values in a stream. In Proceedings of the 48th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2016, Cambridge, MA, USA, June 18-21, 2016, pages 726 -- 739, 2016. 24 [18] Yi Li and David P. Woodruff. Tight bounds for sketching the operator norm, schatten norms, and subspace embeddings. In Approximation, Randomization, and Combinatorial Optimiza- tion. Algorithms and Techniques, APPROX/RANDOM 2016, September 7-9, 2016, Paris, France, pages 39:1 -- 39:11, 2016. [19] Fran¸coise Lust-Piquard. In´egalit´es de khintchine dans cp (1 < p < ∞). Comptes Rendus de l'Acadmie des Sciences - Series I - Mathematics, 303:289 -- 292, 1986. [20] Xiangrui Meng and Michael W. Mahoney. Low-distortion subspace embeddings in input- sparsity time and applications to robust linear regression. In Symposium on Theory of Com- puting Conference, STOC'13, Palo Alto, CA, USA, June 1-4, 2013, pages 91 -- 100, 2013. [21] Cameron Musco, Praneeth Netrapalli, Aaron Sidford, Shashanka Ubaru, and David P. Spectral sums beyond fast matrix multiplication: Algorithms and hardness. Woodruff. manuscript, 2016. [22] Jelani Nelson and Huy L. Nguyen. OSNAP: faster numerical linear algebra algorithms via sparser subspace embeddings. In 54th Annual IEEE Symposium on Foundations of Computer Science, FOCS 2013, 26-29 October, 2013, Berkeley, CA, USA, pages 117 -- 126, 2013. [23] Shashanka Ubaru, Jie Chen, and Yousef Saad. Fast estimation of tr(F (A)) via stochastic lanc- zos quadrature. 2016. URL: http://www-users.cs.umn.edu/~saad/PDF/ys-2016-04.pdf. [24] Roman Vershynin. Introduction to the non-asymptotic analysis of random matrices. In Yon- ina C. Eldar and Gitta Kutyniok, editors, Compressed Sensing: Theory and Practice, pages 210 -- 268. Cambridge University Press, 2012. [25] Andreas J. Winter. Quantum and classical message identification via quantum channels. Quan- tum Information & Computation, 5(7):605 -- 606, 2005. [26] David P. Woodruff. Sketching as a tool for numerical linear algebra. Foundations and Trends in Theoretical Computer Science, 10(1-2):1 -- 157, 2014. 25
1601.04248
1
1601
2015-11-27T12:37:22
Word Existence Algorithm
[ "cs.DS" ]
The current scenario in the field of computing is largely affected by the speed at which data can be accessed and recalled. In this paper, we present the word existence algorithm which is used to check if the word given as an input is part of a particular database or not. We have taken the English language as an example here. This algorithm tries to solve the problem of lookup by using a uniformly distributed hash function. We have also addressed the problem of clustering and collision. A further contribution is that we follow a direct hashed model where each hash value is linked to another table if the continuity for the function holds true. The core of the algorithm lies in the data model being used during preordering. Our focus lies on the formation of a continuity series and validating the words that exists in the database. This algorithm can be used in applications where we there is a requirement to search for just the existence of a word, example Artificial Intelligence responding to input ,look up for neural networks and dictionary lookups and more. We have observed that this algorithm provides a faster search time
cs.DS
cs
Word Existence Algorithm Vyom Chabbra Dept. of Computer Science & Engineering, Manipal Institute of Technology, Manipal – 576104, India. [email protected] gaming to fashion, app development has taken a huge leap. Every aspect of human life has been effected by mobile technology and hence there is a requirement for building much faster responsive applications. Many of these mobile applications, require a fast and simple search algorithm to perform their tasks. These applications are generally light weight in nature and require simple look-up algorithms that are not time-consuming to serve their purpose. We can observe that the biggest pain point for an application is the experience of waiting for a page to respond or load. There are various reasons for slow response of applications. Look-up or searching for an entity in the database is one of the reasons causing this delay. Other areas where look-up are required is in the development of artificial neural networks and the initial stages of an artificial intelligence that respond to input, and dictionary look-ups. It has been noticed that the major requirement for all the above applications is fast search time. The traditional hash function provide a considerable solution to this problem, but still has certain problems like collision and clustering. In this paper, we attempt to provide a simple, yet effective hash function to solve the problem of look-up for a word in any database or table data. II. METHODOLOGY The search defines a specific storage pattern to work properly. Once the data is stored in the proper format we can check if a particular word exists in the list or not. Adding of new values to this storage type is relatively simple. Data is stored in form of nested hash tables. For this explanation: we take around 50000 words in the English language to be stored (26 possible characters).The length of a word (n) specifies the no. of levels (l) we need to store it. Each level will have maximum 26^n hash tables in it where n is the length of word. Tejeswini Sundaram Dept. of Computer Science & Engineering, Manipal Institute of Technology, Manipal – 576104, India [email protected] Abstract— the current scenario in the field of computing is largely affected by the speed at which data can be accessed and recalled. In this paper, we present the word existence algorithm which is used to check if the word given as an input is part of a particular database or not. We have taken the English language as an example here. This algorithm tries to solve the problem of lookup by using a uniformly distributed hash function. We have also addressed the problem of clustering and collision. A further contribution is that we follow a direct hashed model where each hash value is linked to another table if the continuity for the function holds true. The core of the algorithm lies in the data model being used during preordering. Our focus lies on the formation of a continuity series and validating the words that exists in the database. This algorithm can be used in applications where we there is a requirement to search for just the existence of a word, example Artificial Intelligence responding to input ,look up for neural networks and dictionary lookups and more. We have observed that this algorithm provides a faster search time Keywords: Lookup algorithm, existence algorithm, hash function, clustering, collision I. INTRODUCTION Development in computer software and applications continues to be very dynamic. Each software problem requires different tools and algorithms to solve it effectively and achieve best results. As a result, we witness the announcement of new tools and algorithms in quick succession with multiple updates. Among these algorithms, there have been various solutions being provided for solving the look up or word search problem. It is interesting to note that, though there seems to be multiple choices for looking up an entity, there is not one solution which provides optimal results in terms of both time and space complexity. The algorithms are selected depending on the nearest problem we require to be solved. With the help of the currently available software tools, there are a multitude of desktop and mobile applications that are being developed on various platforms, be it android, IOS or windows phone application. Mobile application development has sprung over all industries and domains, from e-commerce to food, from health to education, from This sharing of spaces can done for any number of combinations and thus can reduce the total space needed for storage. The Word-Existence Algorithm discussed in the previous section is a based on a simple hash function. It inherits the features of a uniformly distributed hash function and is an example of minimal perfect hashing. The problems of clustering is eliminated by the multi-level hash table model that has been incorporated. No two characters are stored in the same bin of the hash table. A separate bin is allotted to all the 26 characters in the English alphabets. Hence, clustering and collision has been avoided. Another important feature of the Word Existence Algorithm is that it allocates a bin (memory) to the alphabet, only if it is necessary. This way, memory space has been saved and unnecessary allocations will be avoided. Here, we follow a direct hashed model where each hash value is linked to another table if the continuity for the function holds true. The data model used during pre- ordering is the highlight of the algorithm. We have observed that this multi-hash algorithm provides a faster search time than the conventional searching techniques with respect to the applications discussed earlier and the time complexity is found to be of the order O(1). IV. CONCLUSION This algorithm was developed keeping in mind the application of it in database retrieval and management, mobile apps, desktop apps and various other projects that require basic look-up tasks. The algorithm tries to solve the problem of waiting for a page to load or respond to an event that has occurred. Look-up in the database is one of the reasons causing the delay in loading, and by speeding up the look-up we have intended to speed up the loading process. Our experimental results show that, the algorithm is well suited for applications that require fast and simple look-up from an existing database. The highlights of the algorithm is that it is a minimally perfect hash function which has efficient memory management for simple databases. It is based on multi-level hashing and is very quick for the discussed applications. V. REFERENCES [1] Knuth, Donald (1973). The Art of Computer Programming, volume 3, Sorting and Searching. pp. 506–542. [2] N. Alon, M. Dietzfelbinger, P.B. Miltersen, E. Petrank, and G. Tardos. Linear hash functions. Journal of the ACM, 46(5):667–683, 1999. [3] N. Alon and M. Naor. Derandomization, witnesses for Boolean matrix multiplication and construction of perfect hash functions. Algorithmica, 16(4-5):434–449, 1996. [4] . K. Mehlhorn. Data Structures and Algorithms 1: Sorting and Searching. Springer Verlag, 1984. [5] http://en.wikipedia.org/wiki/Hash_function [6] Peter Kankowski. "Hash functions: An empirical comparison". Fig 1. Levels in Hash Table Each table has 26 inputs with two values stored in it, the first is for the continuation value and the second one is for the existence value. These inputs are then connected to a table of their own on the next level depending on the continuation value. For example take into consideration this case when for an input when the continuation value is zero. This invariably means that no word with such a prefix exists. Thus we can stop the search here. On the other hand, if c = 1 then we can keep searching and move to the next level in the Hash table. Once we reach the last character of the searched word, we then check for the existence value instead of the continuation value. If the existence value is 1(true) then the algorithm returns that the word is valid, otherwise it is invalid III. EXPERIMENTAL RESULTS The above algorithm is advantageous in the terms that it works very fast with minimal time complexity and exhibits space overwriting. For explanation purposes, consider two search words “bat” and “bath” to be searched in the hash table. The format of the levels of the hash table is as shown in Figure 2. Note that the letter ‘c’ depicts the continuation value and ‘e’ depicts the existence value as discussed in the earlier paragraph. Here we can observe that the two words ‘bat’ and ‘bath’ are stored in 4 levels. And 3 of the layers are shared by both.
1605.08107
2
1605
2017-06-24T05:13:36
Dominance Product and High-Dimensional Closest Pair under $L_\infty$
[ "cs.DS", "cs.CG" ]
Given a set $S$ of $n$ points in $\mathbb{R}^d$, the Closest Pair problem is to find a pair of distinct points in $S$ at minimum distance. When $d$ is constant, there are efficient algorithms that solve this problem, and fast approximate solutions for general $d$. However, obtaining an exact solution in very high dimensions seems to be much less understood. We consider the high-dimensional $L_\infty$ Closest Pair problem, where $d=n^r$ for some $r > 0$, and the underlying metric is $L_\infty$. We improve and simplify previous results for $L_\infty$ Closest Pair, showing that it can be solved by a deterministic strongly-polynomial algorithm that runs in $O(DP(n,d)\log n)$ time, and by a randomized algorithm that runs in $O(DP(n,d))$ expected time, where $DP(n,d)$ is the time bound for computing the {\em dominance product} for $n$ points in $\mathbb{R}^d$. That is a matrix $D$, such that $D[i,j] = \bigl| \{k \mid p_i[k] \leq p_j[k]\} \bigr|$; this is the number of coordinates at which $p_j$ dominates $p_i$. For integer coordinates from some interval $[-M, M]$, we obtain an algorithm that runs in $\tilde{O}\left(\min\{Mn^{\omega(1,r,1)},\, DP(n,d)\}\right)$ time, where $\omega(1,r,1)$ is the exponent of multiplying an $n \times n^r$ matrix by an $n^r \times n$ matrix. We also give slightly better bounds for $DP(n,d)$, by using more recent rectangular matrix multiplication bounds. Computing the dominance product itself is an important task, since it is applied in many algorithms as a major black-box ingredient, such as algorithms for APBP (all pairs bottleneck paths), and variants of APSP (all pairs shortest paths).
cs.DS
cs
Dominance Product and High-Dimensional Closest Pair under L∞∗ Omer Gold1 and Micha Sharir2 1 Blavatnik School of Computer Science, Tel Aviv University, 2 Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv 69978, Israel [email protected] Tel Aviv 69978, Israel [email protected] 7 1 0 2 n u J 4 2 ] S D . s c [ 2 v 7 0 1 8 0 . 5 0 6 1 : v i X r a Abstract Given a set S of n points in Rd, the Closest Pair problem is to find a pair of distinct points in S at minimum distance. When d is constant, there are efficient algorithms that solve this problem, and fast approximate solutions for general d. However, obtaining an exact solution in very high dimensions seems to be much less understood. We consider the high-dimensional L∞ Closest Pair problem, where d = nr for some r > 0, and the underlying metric is L∞. We improve and simplify previous results for L∞ Closest Pair, showing that it can be solved by a deterministic strongly-polynomial algorithm that runs in O(DP(n, d) log n) time, and by a randomized algorithm that runs in O(DP(n, d)) expected time, where DP(n, d) is the time bound for computing the dominance product for n points in Rd. That is a matrix D, such pi. For integer coordinates from some interval [−M, M], we obtain an algorithm that runs in matrix by an nr × n matrix. that D[i, j] = (cid:12)(cid:12){k pi[k] ≤ pj[k]}(cid:12)(cid:12); this is the number of coordinates at which pj dominates O(cid:0)min{M nω(1,r,1) , DP(n, d)}(cid:1) time1, where ω(1, r, 1) is the exponent of multiplying an n × nr We also give slightly better bounds for DP(n, d), by using more recent rectangular matrix multiplication bounds. Computing the dominance product itself is an important task, since it is applied in many algorithms as a major black-box ingredient, such as algorithms for APBP (all pairs bottleneck paths), and variants of APSP (all pairs shortest paths). 1998 ACM Subject Classification F.2.2 Nonnumerical Algorithms and Problems Keywords and phrases Closest Pair, Dominance Product, L∞ Proximity Digital Object Identifier 10.4230/LIPIcs...1 Introduction 1 Finding the closest pair among a set of n points in Rd was among the first studied algorithmic geometric problems, considered at the origins of computational geometry; see [20, 18]. The distance between pairs of points is often measured by the Lτ metric, for some 1 ≤ τ ≤ ∞, under which the distance between the points pi = (pi[1], . . . , pi[d]) and pj = (pj[1], . . . , pj[d]) ∗ Work on this paper has been supported by Grant 892/13 from the Israel Science Foundation, by Grant 2012/229 from the U.S.-Israeli Binational Science Foundation, by the Israeli Centers of Research Excellence (I-CORE) program (Center No. 4/11), and by the Hermann Minkowski -- MINERVA Center for Geometry at Tel Aviv University. 1 The O(·) notation hides poly-logarithmic factors. © Omer Gold and Micha Sharir; licensed under Creative Commons License CC-BY Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 1:2 Dominance Product and High-Dimensional Closest Pair under L∞ is distτ(pi, pj) = kpi − pjkτ =(cid:16)Pd (cid:12)(cid:12)pi[k] − pj[k](cid:12)(cid:12), for τ = ∞. The Closest Pair problem and its corresponding , for τ < ∞, and dist∞(pi, pj) = k=1 kpi− pjk∞ = maxk decision variant, under the Lτ-metric, are defined as follows. (cid:12)(cid:12)pi[k] − pj[k](cid:12)(cid:12)τ(cid:17)1/τ Closest Pair: Given a set S of n points in Rd, find a pair of distinct points pi, pj ∈ S such that distτ(pi, pj) = min'6=m{distτ(p', pm) p', pm ∈ S}. Closest Pair Decision: Given a set S of n points in Rd, and a parameter δ > 0, determine whether there is a pair of distinct points pi, pj ∈ S such that distτ(pi, pj) ≤ δ. Throughout the paper, the notation Lτ Closest Pair refers to the Closest Pair problem under some specific metric Lτ, for 1 ≤ τ ≤ ∞ (and we will mostly consider the case τ = ∞). In the algebraic computation tree model (see [3]), the Closest Pair problem has a complexity lower bound of Ω(n log n) (for any Lτ metric), even for the one-dimensional case d = 1, as implied from a lower bound for the Element-Uniqueness problem [3]. As for upper bounds, Bentley and Shamos [5, 4] were the first who gave a deterministic algorithm for finding the closest pair under the L2 metric that runs in O(n log n) time for any constant dimension d ≥ 1, which is optimal in the algebraic computation tree model, for any fixed d. Their algorithm uses the divide-and-conquer paradigm, and became since, a classical textbook example for this technique. In 1976 Rabin presented, in a seminal paper [19], a randomized algorithm that finds the closest pair in O(n) expected time, using the floor function (which is not included in the algebraic computation tree model). His algorithm uses random sampling to decompose the problem into smaller subproblems, and uses the floor function in solving them, for a total cost of O(n) expected time. Later, in 1979, Fortune and Hopcroft [9] gave a deterministic algorithm that uses the floor function, and runs in O(n log log n) time. The bounds above hold as long as the dimension d is constant, as they involve factors that are exponential in d. Thus, when d is large (e.g., d = n), the problem seems to be much less understood. Shamos and Bentley [5] conjectured in 1976 that, for d = n, and 2 log n) time; so far, their conjectured under the L2 metric, the problem can be solved in O(n bound is considerably far from the O(nω) state-of-the-art time bound for this case [13], where ω < 2.373 denotes the exponent for matrix multiplication (see below). If one settles on approximate solutions, many efficient algorithms were developed in the last two decades, mostly based on LSH (locality sensitive hashing) schemes, and dimensionality reduction via the Johnson-Lindenstrauss transform; see [2, 1] for examples of such algorithms. These algorithms are often used for finding approximate nearest neighbors, which itself is of major importance and in massive use in many practical fields of computer science. Nevertheless, finding an exact solution seems to be a much harder task. We consider the case where d depends on n, i.e., d = nr for some r > 0. Note that a naive brute-force algorithm runs in O(n d) time and works for any metric Lτ. For some Lτ metrics, a much faster solution is known; see [13]. Specifically, the L2 Closest Pair problem can be solved by one algebraic matrix multiplication, so for example when d = n, it can be solved in O(nω) time (as already mentioned above). If τ ≥ 2 is an even integer, then Lτ Closest Pair can be solved in O(τ nω) time. However, for other Lτ metrics, such as when τ is odd (or fractional), or the L∞ metric, the known solutions are significantly inferior. (cid:17) = O(n For the L1 and L∞ metrics, Indyk et al. [13] obtained the first (and best known until now) non-naive algorithms for the case d = n. For L1, they gave an algorithm that runs in 2.687 log D) O time, where D is the diameter of the given point-set. The bound for L∞ is weakly polynomial, 2.687) time, and for L∞, one that runs in O (cid:17) = O(n log D (cid:16) (cid:16) ω+3 2 ω+3 2 n n 2 O. Gold and M. Sharir 1:3 due to the dependence on D, and, for real data, only yields an approximation. Their paper is perhaps the most related to our work. Our new approach is based on two main observations. The first is showing a reduction from L∞ Closest Pair Decision to another well-studied problem, dominance product. The second is by showing we can solve the optimization problem deterministically by executing the decision procedure only O(log n) times. We also give improved runtime analysis for the dominance product problem, defined as follows. Dominance Product: given a set S of n points p1, . . . , pn in Rd, compute a matrix D such that for each i, j ∈ [n], D[i, j] = (cid:12)(cid:12)(cid:12){k pi[k] ≤ pj[k]}(cid:12)(cid:12)(cid:12). This matrix is called the dominance product or dominance matrix for S. For d = n, there is a non-trivial strongly subcubic algorithm by Matoušek [17] (see Section 4), and a slightly improved one by Yuster [23]. For d ≤ n, there are extensions of Matoušek's algorithm by Vassilevska-Williams, Williams, and Yuster [21]. All of them use fast matrix multiplications. Dominance product computations were liberally used to improve some fundamental algorithmic problems. For example, Vassilevska-Williams, Williams, and Yuster [21], give the first strongly subcubic algorithm for the all pairs bottleneck paths (APBP) problem, using dominance product computations. Duan and Pettie [8] later improved their algorithm, also by using dominance product computations, in fact, their time bound for (max, min)-product match the current time bound of computing the dominance product of n points in Rn. Yuster [23] showed that APSP can be solved in strongly subcubic time if the number of 0.338). In his algorithm, he distinct weights of edges emanating from any fixed vertex is O(n uses dominance product computation as a black box. 1.1 Preliminaries We review some notations that we will use throughout the paper. We denote by [N] = {1, . . . ,dNe}, the set of the first dNe natural numbers succeeding zero, for any N ∈ R+. For a point p ∈ Rd, we denote by p[k] the k-th coordinate of p, for k ∈ [d]. For a matrix A, we denote the transpose of A by AT . The O(·) notation hides poly-logarithmic factors. Most of the algorithms discussed in this paper heavily rely on fast matrix multiplication algorithms. Throughout the paper, ω < 2.373 denotes the exponent of multiplying two n × n matrices [22, 14], and ω(1, r, 1) refers to the exponent of multiplying an n × nr matrix by an nr × n matrix, for some r > 0; see [12, 15]. For more details on rectangular matrix multiplication exponents, we refer the reader to the seminal work of Huang and Pan [12], and to a more recent work of Le Gall [15, 16]. 1.2 Our Results Let DP(n, d) denote the runtime order for computing the dominance product (defined above) of n points in Rd. We obtain the following results for the L∞ Closest Pair problem in Rd, where d = nr, for some r > 0. (cid:73) Theorem 1. L∞ Closest Pair can be solved by a deterministic algorithm that runs in O(DP(n, d) log n) time. Theorem 1 improves the O(n aspects, first is that the polynomial factor n which we then improve further to n 2.687 log D) time bound of Indyk et al. [13] (see above) in two 2.684, 2.6598 in Theorem 4; this holds also for Theorem 2, stated 2.687 goes slightly down to DP(n, n) = n  2+o(1) 0.697 d 0.909 d 0.921 d 0.931 d n n n n 1.896 + n 1.75 1.739 1.73 DP(n, d) ≤ if d ≤ n if n if n if n 0.687 0.87 0.963 1.056 2 ≤ n ω−1 0.687 ≤ d ≤ n 0.87 ≤ d ≤ n 0.963 ≤ d ≤ n 2.6598, which improves Yuster's O(n 1:4 Dominance Product and High-Dimensional Closest Pair under L∞ below. The second aspect is that the log D factor is replaced by a log n factor, which makes our algorithm strongly-polynomial, independent of the diameter of the given point-set. For the proof of Theorem 1, we first show a reduction from L∞ Closest Pair Decision to dominance product computation, then we show that the optimization problem can be cleverly solved deterministically by executing the decision procedure only O(log n) times. (cid:73) Theorem 2. L∞ Closest Pair can be solved by a randomized algorithm that runs in O(DP(n, d)) expected time. (cid:73) Theorem 3. For points with integer coordinates from [−M, M], L∞ Closest Pair can be solved by a deterministic algorithm that runs in O(cid:0)min{M nω(1,r,1) , DP(n, d)}(cid:1) time. From Theorem 3 we obtain that for n points in Rn with small integer coordinates we can solve the optimization problem in O(nω) time, which is a significant improvement compared to the general case from Theorems 1 and 2. Additionally, in Theorem 4 we give improved bounds for DP(n, d). (cid:73) Theorem 4. given a set S of n points p1, . . . , pn in Rd, their dominance product can be computed in O(DP(n, d)) time, where 2.684) time In particular, we obtain that DP(n, n) = n bound. As mentioned above, these bounds will slightly improve the time bounds for algorithms that use dominance product computation as a bottleneck step (see some examples above). In the rest of the paper we will often refer to the function DP(n, d) above. L∞ Closest Pair 2 Recall that, given a set S of n points p1, . . . , pn in Rd, the L∞ Closest Pair problem is to find a pair of points (pi, pj), such that i 6= j and kpi − pjk∞ = min'6=m∈[n] kp' − pmk∞. The corresponding decision version of this problem is to determine whether there is a pair of distinct points (pi, pj) such that kpi − pjk∞ ≤ δ, for a given δ > 0. d) time, and choose the smallest one. However, as we see next, a significant improvement can be achieved, for any d = nr, for any r > 0. Naively, we can compute all the distances between every pair of points in O(n 2 Specifically, we first obtain the following theorem. (cid:73) Theorem 5. Given a parameter δ > 0, and a set S of n points p1, . . . , pn in Rd, the set of all pairs (pi, pj) with kpi − pjk∞ ≤ δ, can be computed in O(DP(n, d)) time. Proof. First, we note the following trivial but useful observation. (cid:73) Observation 6. For a pair of points pi, pj ∈ Rd, kpi − pjk∞ ≤ δ ⇐⇒ pi[k] ≤ pj[k] + δ and pj[k] ≤ pi[k] + δ, for every coordinate k ∈ [d]. Indeed, a pair of points (pi, pj) satisfies kpi − pjk∞ = maxk∈[d] pi[k] − pj[k] ≤ δ ⇐⇒ for every coordinate k ∈ [d], pi[k] − pj[k] ≤ δ. The last inequalities hold iff pi[k] − pj[k] ≤ δ and pj[k] − pi[k] ≤ δ, or, equivalently, iff pi[k] ≤ pj[k] + δ and pj[k] ≤ pi[k] + δ, for each O. Gold and M. Sharir 1:5 k ∈ [d]. Although the rephrasing in the observation is trivial, it is crucial for our next step. It can be regarded as a (simple) variant of what is usually referred to as "Fredman's trick" (see [11]). For every i ∈ [n] we create a new point pn+i = pi + (δ, δ, . . . , δ). Thus in total, we now have 2n points. Concretely, for every i ∈ [n], we have the points =(cid:0) pn+i =(cid:0) pi[1] + δ, pi[2] + δ, pi[1], pi pi[2], pi[d] . . . , . . . , pi[d] + δ (cid:1), (cid:1). We compute the dominance matrix Dδ for these 2n points, using the algorithm from Section 4.1. By Observation 6, a pair of points (pi, pj) satisfies kpi − pjk∞ ≤ δ ⇐⇒ (Dδ[i, n + j] = d) ∧ (Dδ[j, n + i] = d) , so we can find all these pairs in O(n by the time bound of computing the dominance matrix Dδ, that is, O(DP(n, d)). 2) additional time. Clearly, the runtime is determined (cid:74) The proof of Theorem 5 shows that solving the L∞ Closest Pair Decision is not harder than computing the dominance matrix for n points in Rd. In particular, by the decision tree complexity bound for computing dominance matrices, as discussed in Section 4, the following result is straightforward. (cid:73) Corollary 7. Given a parameter δ > 0, and a set S of n points p1, . . . , pn in Rd, determining all pairs i 6= j such that kpi − pjk∞ ≤ δ can be done using O(dn log n) pairwise comparisons (of real numbers). By Corollary 7, we obtain that the 2-linear decision tree complexity for the L∞ Closest Pair Decision problem is O(dn log n). This bound matches a special case of an old conjectured algorithmic complexity bound by Shamos and Bentley (see Section 1, and [5]). 2.1 Solving the Optimization Problem The algorithm from Theorem 5 solves the L∞ Closest Pair Decision problem. It actually gives a stronger result, as it finds all pairs of points (pi, pj) such that kpi − pjk∞ ≤ δ. We use this algorithm in order to solve the optimization problem L∞ Closest Pair. As a "quick and dirty" solution, one can solve the optimization problem by using the algorithm from Theorem 5 to guide a binary search over the diameter W of the input point set, which is at most twice the largest absolute value of the coordinates of the input points. If the coordinates are integers then we need to invoke the algorithm from Theorem 5 O(log W) times. If the coordinates are reals, we invoke it O(B) times for B bits of precision. However, the dependence on W makes this method weakly polynomial, and, for real data, only yields an approximation. As we show next, this naive approach can be replaced by strongly-polynomial algorithms, A deterministic one that runs in O(DP(n, d) log n) time, and a randomized one that runs in O(DP(n, d)) expected time. Deterministic strongly-polynomial algorithm. (cid:73) Theorem 8. Given a set S of n points p1, . . . , pn in Rd, the L∞ Closest Pair problem can be solved for S in O(DP(n, d) log n) time. Proof. Since the distance between the closest pair of points, say pi, pj, is δ0 = kpi − pjk∞ = max k∈[d] (cid:12)(cid:12)pi[k] − pj[k](cid:12)(cid:12), 1:6 Dominance Product and High-Dimensional Closest Pair under L∞ 2 d) values p'[k]− pm[k], ', m ∈ [n], k ∈ [d]. Our goal is to somehow search it is one of the O(n through these values, using the decision procedure (i.e., the algorithm from Theorem 5). However, enumerating all these values takes Ω(n d) time, which is too expensive, and pointless anyway, since by having them, the closest pair can be found immediately. Instead, we proceed in the following more efficient manner. For each k ∈ [d], we sort the points of S in increasing order of their k-th coordinate. This (cid:17) denote the sequence of the points of S takes O(nd log n) time in total. Let(cid:16) (k) 1 , . . . , p (k) n p 2 sorted in increasing order of their k-th coordinate. For each k, let M so that for i, j ∈ [n], we have (k) j (k)[i, j] = p [k] − p (k) i [k]. M (k) be an n × n matrix, (k), where its elements are We are in fact interested only in the upper triangular portion of M positive, but for simplicity of presentation, we ignore this issue. (We view the row indices from bottom to top, i.e., the first row is the bottommost one, and the column indices from left to right.) (k), for any 1 ≤ t ≤ n Observe that each row of M We use this method to conduct a simultaneous binary search over all d matrices M (k) is sorted in decreasing order and each column is sorted in increasing order. Under these conditions, the selection algorithm of Frederickson and 2, in O(n) time.2 (Note Johnson [10] can find the t-largest element of M (k), this will be too expensive. The that we do not need to explicitly construct the matrices M (k) is accessible bound of Frederickson-Johnson's algorithm holds as long as each entry of M in O(1) time, like in our case.) (k) to find δ0. At each step of the search we maintain two counters Lk ≤ Hk, for each k. Initially 2. The invariant that we maintain is that, at each step, δ0 lies in between Lk = 1 and Hk = n the Lk-th and the Hk-th largest elements of M Each binary search step is performed as follows. We compute rk = b(Lk + Hk)/2c, for each k, and apply the Frederickson-Johnson algorithm to retrieve the rk-th largest element (k), which we denote as δk, in total time O(nd). We give δk the weight Hk − Lk + 1, of M and compute the weighted median δmed of {δ1, . . . , δd}. We run the L∞ Closest Pair Decision procedure of Theorem 5 on δmed. Suppose that it determines that δ0 ≤ δmed. Then for each k for which δk ≥ δmed we know that δ0 ≤ δk, so we set Hk := rk and leave Lk unchanged. Symmetric actions are taken if δ0 > δmed. In either case, we remove roughly one quarter k∈[d] (Hk − Lk + 1) decreases by roughly a factor of 3/4. Hence, after O(log n) steps, the sum becomes O(d), and a straightforward binary search through the remaining values finds δ0. The overall running time is of the candidate differences; that is, the sumP (k), for each k. O(nd log n + DP(n, d)(log n + log d)). Since in our setting d is polynomial in n, and nd (cid:28) DP(n, d), we obtain that the overall (cid:74) runtime is O(DP(n, d) log n). This completes the proof of Theorem 1. Randomized algorithm. Using randomization, we can improve the time bound of the preceding deterministic algorithm to equal the time bound of computing the dominance product O(DP(n, d)) in expectation. This can be done by using a randomized optimization technique by Chan [6]. Among the problems for which this technique can be applied, Chan specifically addresses the Closest Pair problem. 2 Simpler algorithms can select the t-largest element in such cases in O(n log n) time, which is also sufficient for our approach. O. Gold and M. Sharir 1:7 (cid:73) Theorem 9 (Chan [6]). Let U be a collection of objects. If the Closest Pair Decision problem can be solved in O(T(n)) time, for an arbitrary distance function d : U × U → R, then the Closest Pair problem can be solved in O(T(n)) expected time, assuming that T(n)/n is monotone increasing. We refer the reader to [6], for the proof of Theorem 9. By Theorem 5, L∞ Closest Pair Decision can be solved in O(DP(n, d)) time. Clearly, DP(n, d)/n is monotone increasing in n. Hence, by Theorem 9, we obtain a randomized algorithm for L∞ Closest Pair that runs in O(DP(n, d)) expected time, as stated in Theorem 2. L∞ Closest Pair with Integer Coordinates 3 A considerable part of the algorithm from the previous section is the reduction to computing a suitable dominance matrix. The algorithms for computing dominance matrices given in Section 4 do not make any assumptions on the coordinates of the points, and support real numbers. When the coordinates are bounded integers, we can improve the algorithms. In particular, for n points in Rn with small integer coordinates we can solve the optimization 2.6598) time problem in O(nω) time, which is a significant improvement compared to the O(n bound of our previous algorithm for this case3. Our improvement is based on techniques for computing (min, +)-matrix multiplication over integer-valued matrices. (cid:73) Theorem 10. Let S be a set of n points p1, . . . , pn in Rd such that d = nr for some r > 0, and for all i ∈ [n], k ∈ [d], pi[k] is an integer in [−M, M]. Then the L∞ closest pair can be computed in (cid:16)minn , DP(n, d)o(cid:17) time. M nω(1,r,1) O We first define (max, +)-product and (min, +)-product over matrices. (cid:73) Definition 11 (Distance products of matrices). Let A be an n × m matrix and B be an m × n matrix. The (max, +)-product of A and B, denoted by A ? B, is the n × n matrix C whose elements are given by {aik + bkj}, for i, j ∈ [n]. cij = max 1≤k≤m Similarly, the (min, +)-product of A and B denoted by A ∗ B is the n × n matrix C0 whose elements are given by c0 ij = min 1≤k≤m {aik + bkj}, for i, j ∈ [n]. We refer to either of the (min, +)-product or the (max, +)-product as a distance product. 2 The distance product of an n × m matrix by an m × n matrix can be computed naively in O(n m) time. When m = n, the problem is equivalent to APSP (all pairs shortest paths) problem in a directed graph with real edge weights, and the fastest algorithm known is a recent one by Chan and Williams [7] that runs in O long-standing open problem whether a truly subcubic algorithm for this problem exists. However, when the entries of the matrices are integers, we can convert distance products of matrices into standard algebraic products. We use a technique by Zwick [24]. √Ω(log n)(cid:17) time. It is a prominent (cid:16) n 3 /2 3 For integer coordinates that are bounded by a constant, the L∞-diameter of the points is also a constant (bounded by twice the largest coordinate), hence, one can use the decision procedure to (naively) guide a binary search over the diameter in constant time. 1:8 Dominance Product and High-Dimensional Closest Pair under L∞ (cid:73) Lemma 12 (Zwick [24]). Given an n× m matrix A = {aij} and an m× n matrix B = {bij} such that m = nr for some r > 0, and all the elements of both matrices are integers from [−M, M], their (min, +)-product C = A ∗ B can be computed in O(M nω(1,r,1)) time. With minor appropriate modifications, the (max, +)-product of matrices A and B can be computed within the same time as in Lemma 12. We now give an algorithm for computing all-pairs L∞ distances, by using the fast algorithm for computing (max, +)-product over bounded integers. (cid:73) Lemma 13. Let S be a set of n points p1, . . . , pn in Rd such that d = nr for some r > 0, and for all i ∈ [n], pi[k] is an integer from the interval [−M, M], for all k ∈ [d]. Then the L∞ distances between all pairs of points (pi, pj) from S can be computed in O(M nω(1,r,1)) time. Proof. We create the n × d matrix A = {aik} and the d × n matrix B = (−A)T = {bki}, where for i ∈ [n], k ∈ [d] for i ∈ [n], k ∈ [d]. aik = pi[k], bki = −pi[k], Now we compute the (max, +)-product C = A?B. The matrix L of all-pairs L∞-distances is then easily seen to be L[i, j] = max(cid:8)C[i, j], C[j, i](cid:9) = kpi − pjk∞ , for every pair i, j ∈ [n]. Clearly, the runtime is determined by computing the (max, +)-product C = A ? B. This (cid:74) is done as explained earlier, and achieves the required running time. Consequently, by taking the minimum from the algorithm above, and the (say, determ- inistic) algorithm from Section 2, we obtain that for points in Rd with integer coordinates from [−M, M], where d = nr for some r > 0, we can find the L∞ closest pair in (cid:16)minn O , DP(n, d)o(cid:17) time, M nω(1,r,1) as stated in Theorem 3. 4 Dominance Products We recall the dominance product problem: given n points p1, . . . , pn in Rd, we want to compute a matrix D such that for each i, j ∈ [n], (cid:12)(cid:12)(cid:12){k pi[k] ≤ pj[k]}(cid:12)(cid:12)(cid:12). D[i, j] = 2) time. Note that, in It is easy to see that the matrix D can be computed naively in O(dn terms of decision tree complexity, it is straightforward to show that O(dn log n) pairwise comparisons suffice for computing the dominance product of n points in Rd. However, the actual best known time bound to solve this problem is significantly larger than its decision tree complexity bound. The first who gave a truly subcubic algorithm to compute the dominance product of n points in Rn is Matoušek [17]. We first outline his algorithm, and then present our extension and improved runtime analysis. O. Gold and M. Sharir 1:9 3+ω 2 ) = O(n 2.687) time. (cid:73) Theorem 14 (Matoušek [17]). Given a set S of n points in Rn, the dominance matrix for S can be computed in O(n Proof. For each j ∈ [n], sort the n points by their j-th coordinate. This takes a total of 2 log n) time. Define the j-th rank of point pi, denoted as rj(pi), to be the position of pi O(n in the sorted list for coordinate j. Let s ∈ [log n, n] be a parameter to be determined later. Define n/s pairs (assuming for simplicity that n/s is an integer) of n × n Boolean matrices (A1, B1), . . . , (An/s, Bn/s) as follows: Ak[i, j] = if rj(pi) ∈ [ks, ks + s) otherwise, Bk[i, j] = if rj(pi) ≥ ks + s otherwise, (1 0 (1 0 k . Then Ck[i, j] equals the number of coordinates t such that k=1 Ck, we have that C[i, j] is the number of coordinates t such Thus, by letting C =Pn/s for i, j ∈ [n]. Put Ck = Ak · BT rt(pi) ∈ [ks, ks + s), and rt(pj) ≥ ks + s. that pi[t] ≤ pj[t] and brt(pi)/sc < brt(pj)/sc. Next, we compute a matrix E such that E[i, j] is the number of coordinates t such that pi[t] ≤ pj[t] and brt(pi)/sc = brt(pj)/sc. Then D := C + E is the desired dominance matrix. To compute E, we use the n sorted lists we computed earlier. For each pair (i, j) ∈ [n]×[n], we retrieve q := rj(pi). By reading off the adjacent points that precede pi in the j-th sorted list in reverse order (i.e., the points at positions q − 1, q − 2, etc.), and stopping as soon as we reach a point pk such that brj(pk)/sc < brj(pi)/sc, we obtain the list pi1 , . . . , pil of l ≤ s points such that pix[j] ≤ pi[j] and brj(pi)/sc = brj(pix)/sc. For each x = 1, . . . , l, we add a 1 to E[ix, i]. Assuming constant time lookups and constant time probes into a matrix (as is s) time. The runtime standard in the real RAM model), this entire process takes only O(n s · nω). Choosing s = n ω−1 2 , the time bound of the above procedure is therefore O(n (cid:74) becomes O(n 2.684) time, by using Yuster [23] has slightly improved this algorithm to run in O(n 2 s + n 3+ω 2 ). 2 rectangular matrix multiplication. 4.1 Generalized and Improved Bounds We extend Yuster's idea to obtain bounds for dimension d = nr, for the entire range r > 0, and, at the same time, give an improved time analysis, using the recent bounds for rectangular matrix multiplications of Le Gall [15, 16] coupled with an interpolation technique. This analysis is not trivial, as Le Gall's bounds for ω(1, r, 1) are obtained by a nonlinear optimization problem, and are only provided for a few selected values of r (see Table 1 in [16] and [15]). Combining Le Gall's exponents with an interpolation technique, similar to the one used by Huang and Pan [12], we obtain improved bounds for all values d = nr, for any r > 0. Note that the matrices Ak and Bk, defined above, are now n × d matrices. Thus, the sum C defined earlier, can be viewed as a product of block matrices C =(cid:2)A1 A2 (cid:3) · ··· An/s  .  BT1 BT2 ... BT n/s Thus, to compute C we need to multiply an n × (dn/s) matrix by a (dn/s) × n matrix. Computing E in this case can be done exactly as in Matoušek's algorithm, in O(nds) time. 1:10 Dominance Product and High-Dimensional Closest Pair under L∞ r r0 = 1.0 r1 = 1.1 r2 = 1.2 r3 = 1.3 r4 = 1.4 ω ω0 = 2.372864 ω1 = 2.456151 ω2 = 2.539392 ω3 = 2.624703 ω4 = 2.711707 ζ ζ0 = 0.6865 ζ1 = 0.7781 ζ2 = 0.8697 ζ3 = 0.9624 ζ4 = 1.0559 Table 1 The relevant entries from Le Gall's table. The dominance product can be computed in O(nωi) time, for dimension di = nζi. Consider first the case where d is small; concretely, d ≤ n ω−1 2 . In this case we compute C using the following result by Huang and Pan. (cid:73) Lemma 15 (Huang and Pan [12]). Let α = sup(cid:8)0 ≤ r ≤ 1 w(1, r, 1) = 2 + o(1)(cid:9). Then (cid:16) for all nα ≤ m ≤ n, one can multiply an n × m matrix with an m × n matrix in time O ω−2 1−α n 2−ωα 1−α (cid:17) m . Huang and Pan [12] showed that α > 0.294. Recently, Le Gall [15, 16] improved the bound on α to α > 0.302. By plugging this into Lemma 15, we obtain that multiplying an n × m matrix with an m × n matrix, where nα ≤ m ≤ n, can be done in time O(m From the above, computing C and E can be done in O(cid:0)(dn/s)0.535 1.839 + dns(cid:1) time. n 0.303, the runtime is asymptotically minimized, and we obtain the 0.302 ≤ dn/s ≤ n, /d 1.896). This time bound holds only when nα < n 1.839). 0.896 0.535 n By choosing s = n time bound O(d which yields the time bound 0.697 n 0.697 O(d 1.896 + n n 2+o(1)), for d ≤ n (ω−1)/2 ≤ n 0.687 . We now handle the case d > n (ω−1)/2. Note that in this case, dn/s > n (for s as above), thus, we cannot use the bound from Lemma 15. Le Gall [15, 16] gives a table (Table 1 in [16] and [15]) of values r (he refers to them as k), including values of r > 1 (which is what we need), with various respective exponents ω(1, r, 1). We will confine ourselves to the given bounds for the values r1 = 1.1, r2 = 1.2, r3 = 1.3, and r4 = 1.4. We denote their corresponding exponents ω(1, ri, 1) by ω1 ≤ 2.456151, ω2 ≤ 2.539392, ω3 ≤ 2.624703, and ω4 ≤ 2.711707 respectively. The exponent for r0 = 1 is ω0 = ω ≤ 2.372864 (see [22, 14]). The algorithm consists of two parts. For a parameter s, that we will fix shortly, the cost of computing C = A · BT is O (nωr), where ωr is a shorthand notation for ω(1, r, 1), and where nr = dn/s, and the cost of computing E is O(nds) = O(cid:0)s 2 constants of proportionality, and equating the two expressions, we choose nr(cid:1). Dropping the s = n (ωr−r)/2 , that is, d = snr−1 = n (ωr+r)/2−1 = nζr , for ζr = (ωr + r)/2 − 1. Put ζi = ζri, for the values r0, . . . , r4 mentioned earlier; see Table 1. Now if we are lucky and d = nζi, for i = 0, 1, 2, 3, 4, then the overall cost of the algorithm is O(nωi). For in-between values of d, we need to interpolate, using the following bound, which is derived in the earlier studies (see, e.g., Huang and Pan [12]), and which asserts that, for a ≤ r ≤ b, we have ωr ≤ (b − r)ωa + (r − a)ωb b − a . (1) O. Gold and M. Sharir 1:11 ζmin 0.687 0.87 0.963 ζmax 0.87 0.963 1.056 u 0.909 0.921 0.931 v 1.75 1.739 1.73 Table 2 The time bound for computing dominance product for n points in dimension nζmin ≤ d ≤ nζmax is O (dunv). That is, given d = nζ, where ζi ≤ ζ ≤ ζi+1, for some i ∈ {0, 1, 2, 3}, the cost of the algorithm will be O (nωr), where r satisfies ζ = ζr = ωr + r 2 − 1. Substituting the bound for ωr from (1), with a = ri and b = ri+1, we have (ri+1 − r)ωi + (r − ri)ωi+1 ri+1 − ri + r = 2(ζ + 1). Eliminating r, we get r = 2(ζ + 1)(ri+1 − ri) − ri+1wi + riwi+1 wi+1 + ri+1 − wi − ri , and the cost of the algorithm will be O (nωr), where ri+1 − ri ωr ≤ (ri+1 − r)ωi + (r − ri)ωi+1 O (nωr) = O(cid:0)nuζ+v(cid:1) = O (dunv) . . Note that r is a linear function of ζ, and so is ωr. Writing ωr = uζ + v, the cost is (2) (3) The values of u and v for each of our intervals are given in Table 2. (The first row covers the two intervals 1.0 ≤ r ≤ 1.1 and 1.1 ≤ r ≤ 1.2, as the bounds happen to coincide there.) See also (??) in Section 1.2. We have provided explicit expressions for DP(n, d) only for d ≤ nζ4 = n 1.056, which includes the range d ≤ n, which is the range one expects in practice. Nevertheless, the recipe that we provide can also be applied to larger values of d, using larger entries from Le Gall's table [15, 16]. Dropping constant factors, we denote the time bound for computing the dominance product of n points in Rd by DP(n, d); see Theorem 4 in Section 1.2. by plugging the corresponding values of 0.302 < r < 1 from Le Gall's Table 1 2.6598), which improves Yuster's in [16]. We also note that, for d = n, the time bound is O(n O(n 2.684) time bound mentioned above. References 1 Nir Ailon and Bernard Chazelle. The fast Johnson-Lindenstrauss transform and approxim- ate nearest neighbors. SIAM J. Comput., 39(1):302 -- 322, 2009. 2 Alexandr Andoni and Piotr Indyk. Near-optimal hashing algorithms for approximate nearest neighbor in high dimensions. Commun. ACM, 51(1):117 -- 122, 2008. 3 Michael Ben-Or. Lower bounds for algebraic computation trees. In Proc. of the 15th Annu. ACM Sympos. on Theory of Computing (STOC), pages 80 -- 86, 1983. 1:12 Dominance Product and High-Dimensional Closest Pair under L∞ 4 5 Jon Louis Bentley. Multidimensional divide-and-conquer. Commun. ACM, 23(4):214 -- 229, 1980. Jon Louis Bentley and Michael Ian Shamos. Divide-and-conquer in multidimensional space. In Proc. of the 8th Annu. ACM Sympos. on Theory of Computing (STOC), pages 220 -- 230, 1976. 6 T. M. Chan. Geometric applications of a randomized optimization technique. Discrete & Computational Geometry, 22(4):547 -- 567, 1999. 7 Timothy M. Chan and Ryan Williams. Deterministic APSP, orthogonal vectors, and more: Quickly derandomizing Razborov-Smolensky. In Proc. of the 27th Annu. ACM-SIAM Sym- pos. on Discrete Algorithms (SODA), pages 1246 -- 1255, 2016. 8 Ran Duan and Seth Pettie. Fast algorithms for (max, min)-matrix multiplication and bottleneck shortest paths. In Proc. of the 20th Annu. ACM-SIAM Sympos. on Discrete Algorithms (SODA), pages 384 -- 391, 2009. Steve Fortune and John Hopcroft. A note on Rabin's nearest-neighbor algorithm. Inform. Process. Lett., 8(1):20 -- 23, 1979. 9 10 Greg N. Frederickson and Donald B. Johnson. The complexity of selection and ranking in x + y and matrices with sorted columns. Journal of Computer and System Sciences, 24(2):197 -- 208, 1982. 11 M. L. Fredman. How good is the information theory bound in sorting? Theoret. Comput. Sci, 1(4):355 -- 361, 1976. 12 Xiaohan Huang and Victor Y. Pan. Fast rectangular matrix multiplication and applications. 13 14 15 16 17 18 J. Complexity, 14(2):257 -- 299, 1998. Piotr Indyk, Moshe Lewenstein, Ohad Lipsky, and Ely Porat. Closest pair problems in very high dimensions. In Proc. 31st International Colloquium on Automata, Languages and Programming (ICALP), pages 782 -- 792, 2004. François Le Gall. Powers of tensors and fast matrix multiplication. In Proc. 39th Interna- tional Sympos. on Symbolic and Algebraic Computation (ISSAC), pages 296 -- 303, 2014. François Le Gall. Faster algorithms for rectangular matrix multiplication. In Proc. 53rd Annu. IEEE Sympos. on Foundations of Computer Science (FOCS), pages 514 -- 523, 2012. François Le Gall. Faster algorithms for rectangular matrix multiplication. CoRR, abs/1204.1111, 2012. Jiří Matoušek. Computing dominances in En. Inform. Process. Lett., 38(5):277 -- 278, 1991. Franco P. Preparata and Michael I. Shamos. Computational Geometry: An Introduction. Springer-Verlag New York, NY, 1985. 19 Michael Rabin. Probabilistic algorithms. In Algorithms and Complexity, Recent Results and New Directions, Academic Press, pages 21 -- 39, 1976. 20 Michael Ian Shamos. Geometric complexity. In Proc. of 7th Annu. ACM Sympos. on Theory of Computing (STOC), pages 224 -- 233, 1975. 21 Virginia Vassilevska, Ryan Williams, and Raphael Yuster. All pairs bottleneck paths and max-min matrix products in truly subcubic time. Theory of Computing, 5(1):173 -- 189, 2009. 22 Virginia Vassilevska Williams. Multiplying matrices faster than Coppersmith-Winograd. In Proc. 44th Sympos. on Theory of Computing (STOC), pages 887 -- 898, 2012. 23 Raphael Yuster. Efficient algorithms on sets of permutations, dominance, and real-weighted APSP. In Proc. 20th Annu. ACM-SIAM Sympos. on Discrete Algorithms (SODA), pages 950 -- 957, 2009. 24 Uri Zwick. All pairs shortest paths using bridging sets and rectangular matrix multiplica- tion. J. ACM, 49(3):289 -- 317, 2002.
1608.03611
1
1608
2016-08-11T20:36:45
Constrained Submodular Maximization: Beyond 1/e
[ "cs.DS" ]
In this work, we present a new algorithm for maximizing a non-monotone submodular function subject to a general constraint. Our algorithm finds an approximate fractional solution for maximizing the multilinear extension of the function over a down-closed polytope. The approximation guarantee is 0.372 and it is the first improvement over the 1/e approximation achieved by the unified Continuous Greedy algorithm [Feldman et al., FOCS 2011].
cs.DS
cs
Constrained Submodular Maximization: Beyond 1/e Alina Ene∗ Huy L. Nguyên† August 15, 2016 Abstract In this work, we present a new algorithm for maximizing a non-monotone submodular func- tion subject to a general constraint. Our algorithm finds an approximate fractional solution for maximizing the multilinear extension of the function over a down-closed polytope. The approx- imation guarantee is 0.372 and it is the first improvement over the 1/e approximation achieved by the unified Continuous Greedy algorithm [Feldman et al., FOCS 2011]. 6 1 0 2 g u A 1 1 ] S D . s c [ 1 v 1 1 6 3 0 . 8 0 6 1 : v i X r a ∗Department of Computer Science, Boston University, [email protected]. This work was done in part while the author was with the Computer Science department at the University of Warwick and a visitor at the Toyota Technological Institute at Chicago. †College of Computer and Information Science, Northeastern University, [email protected]. This work was done in part while the author was with the Toyota Technological Institute at Chicago. 1 1 Introduction A set function f : 2V → R is submodular if for every A, B ⊆ V , we have f(A) + f(B) ≥ f(A ∪ B) + f(A∩B). Submodular functions naturally arise in a variety of contexts, both in theory and practice. From a theoretical perspective, submodular functions provide a common abstraction of cut functions of graphs and digraphs, Shannon entropy, weighted coverage functions, and log-determinants. From a practical perspective, submodular functions are used in a wide range of application domains from machine learning to economics. In machine learning, it is used for document summarization [15], sensor placement [12], exemplar clustering [9], potential functions for image segmentation [10], etc. In an economics context, it can be used to model market expansion [6], influence in social networks [11], etc. The core mathematical problem underpinning many of these applications is the meta problem of maximizing a submodular objective function subject to some constraints, i.e., maxS∈S f(S) where S is a down-closed family of sets1. A common approach to this problem is a two-step framework based on the multilinear extension F of f, a continuous function that extends f to the domain [0, 1]V . The program first (1) maximizes F (x) subject to x ∈ C where C is a convex relaxation of S, and then (2) rounds x to an integral solution in S. This paradigm has been very successful and it has led to the current best approximation algorithms for a wide variety of constraints including cardinality constraints, knapsack constraints, matroid constraints, etc. The contention resolution scheme framework of Chekuri et al. [5] gives a generic way to perform step 2 of the program. Thus, many recent works [7, 4] focus on improving step 1, as it immediately leads to improved algorithms when combined with the known rounding schemes. Feldman et al. [7] give a beautiful generalization of the continuous greedy algorithm [18], achieving an 1/e approximation for step 1 for any down-closed and solvable polytope2 C. While it is known that the continuous greedy algorithm is optimal when we restrict to monotone functions3, it is not known if the 1/e approximation of the extension by [7] is optimal. Recently, the work of Buchbinder et al. [1] shows that, for the special case of a cardinality constraint, it is possible to beat 1/e. However, this result still leaves open the possibility that an 1/e approximation is best possible for a harder constraint. This possibility is consistent with our current knowledge: the best known hardness for a cardinality constraint is 0.491 while the best known hardness for a matroid constraint is 0.478 [8], suggesting that the matroid constraint may be strictly harder to approximate. In this paper, we rule out this possibility and show that it is possible to go beyond the 1/e barrier in the same generic setting as considered by [7]. Theorem 1. Let f be a non-negative, non-monotone, submodular function f . Let F be the multi- linear extension of f . Let C be a down-closed and solvable polytope. There is an efficient algorithm that constructs a solution x ∈ C such that F (x) ≥ 0.372 · F (OPT), where OPT is an optimal integral solution to the problem maxx∈C∩{0,1}V F (x). In order to keep the analysis as simple as possible, we have not tried to optimize the constant in the theorem above. We believe a better constant can be obtained using the techniques in this paper, and we hope that our work will lead to improved approximation guarantees for the problem. 1A family of sets S is down-closed if for all A ⊂ B, if B ∈ S then A ∈ S. 2A polytope C is solvable if there is an oracle for optimizing linear functions over C, i.e., for solving maxc∈Chv, ci for any vector v. 3A function f : 2V → R is monotone if f (A) ≤ f (B) for all A ⊆ B. 1 Using known rounding techniques, we obtain improved approximation guarantees for several classes of constraints. In particular, we obtain a 0.372 − o(1) approximation for submodular maximization subject to a matroid constraint and a 0.372 − ǫ approximation for a constant number of knapsack constraints, which improve over the 1/e − o(1) and 1/e − ǫ approximations [7]. 1.1 Our techniques Our starting point is the unified continuous greedy algorithm [7] achieving the approximation factor 1/e. The algorithm grows a solution x over the time interval [0, 1], improving F (x) in each time step by an amount proportional to (1−kxk∞)F (OPT). As x increases over time, the gain starts out large and decreases to 0 at the end of the process. The change in x in each time step is proportional4 to v = argmaxc∈C h∇F (x) ◦ (1 − x), ci. Notice that we can improve the gain ((1 − kxk∞)F (OPT)) by slowing down the growth of kxk∞. Thus in our algorithm, we add a new constraint kck∞ ≤ α and have v = argmaxc∈C,kck∞≤αh∇F (x) ◦ (1 − x), ci. How does this change affect the performance of the algorithm and in particular, the quantity h∇F (x)◦(1−x), vi? Intuitively, if there is a second solution other than OPT with value close to OPT, we can pick v to be a mixture of OPT and this solution and have a new solution comparable to OPT but with lower ℓ∞ norm. Thus, if this is the case, we do not lose very much in h∇F (x) ◦ (1 − x), vi while simultaneously increasing the gain (1 − kxk∞)F (OPT). On the other hand, if there is no such solution, the crucial insight is that v must be well correlated with OPT. Thus we can identify a good fraction of OPT by searching for argmaxx≤v F (x). (Here we crucially use the fact that C is a down-closed polytope.) This problem turns out to be not very different from the unconstrained setting and we can use a variant of the double greedy algorithm of Buchbinder et al. [2] to find a good solution. The above description is an intuitive but simplified overview of the algorithm. Nevertheless, each routine mentioned above corresponds to a part of the algorithm described in Section 4. The main technical difficulty is in formalizing the statement "v must be well correlated with OPT" and the subsequent identification of (a large part of) OPT. We describe how to overcome these difficulties in Section 5.2. Comparison with the work of [1] for a cardinality constraint. The idea of adding a new constraint kck∞ ≤ α is inspired by a recent algorithm by [1] for the cardinality constraint. In their setting, the goal is to maximize F (x) subject to a constraint kxk1 ≤ k. In the ith step, their algorithm picks 2(k − i) elements with maximum marginal gain and randomly adds one of them to the current solution. This can be viewed as an analog of adding a constraint kck∞ ≤ k/(2k − 2i) when the time is in the range [(i − 1)/k, i/k]. This more sophisticated use of varying thresholds depending on the time is allowed in our framework but in the simple solution presented here, we just use a fixed threshold throughout. When the marginal gain (h∇F (x) ◦ (1 − x), vi in our case) is small, they also use a variant of the double greedy algorithm to finish the solution. From the 2(k − i) elements that are picked in the last iteration, their algorithm picks k − i elements using a sophisticated variant of double Greedy, and add them to the i elements it picked in the previous iterations. Unfortunately this step crucially uses the structure of the solution when the constraint is a cardinality constraint. From the point of view of a continuous Greedy algorithm, this is analogous to doubling a fractional solution and then selecting half of the coordinates. It is not clear what the analog should be in 4We use x ◦ y to denote the vector whose i-th coordinate is xi · yi. 2 the general case. Instead, we compute a different solution p = argmaxc∈Ch∇F (x) ◦ (1 − x), ci (dropping the dampening constraint) and use standard double greedy to find z = argmaxc≤p F (c). While v and p could potentially be very different, we manage to connect h∇F (x) ◦ (1 − x), vi and h∇F (x) ◦ (1 − x), pi, which is enough to prove the existence of z ≤ p with large F (z). In summary, in this work, we introduce several novel insights that lead to a much more general algorithm and analysis. We believe that our algorithm and analysis are conceptually much simpler and cleaner, and we hope that our techniques will lead to further improvements for the problem. 1.2 Related work Submodular maximization problems are well-studied and it is hard to do justice to all previous liter- ature on this subject. Starting with the seminal work Nemhauser et al. [16], the classical approaches to these problems are largely combinatorial and based on greedy and local search algorithms. Over the years, with increasing sophistication, this direction has led to many tight results such as the algorithm of [17] for a knapsack constraint, and the current best results for constraints such as mul- tiple matroid constraints [14]. In the last few years, another approach emerged [3] that follows the popular paradigm in approximation algorithms of optimizing a continuous relaxation and rounding the resulting fractional solution. A key difficulty that separates the submodular setting from the classical setting is that even finding a fractional solution may be quite challenging, and in particular it is NP-hard to solve the continuous relaxation for maximizing submodular functions that is based on the multilinear extension. Thus, a line of work has been developed to approximately optimize this relaxation [3, 13, 8, 7] culminating in the work [7], which we extend here. 2 Preliminaries Here we consider the problem of maximizing a submodular function f subject to a downward closed convex constraint x ∈ C. We use the following notation. Let n = V . We write x ≤ y if xi ≤ yi for all coordinates i ∈ [n]. Let x ◦ y denote the vector whose i-th coordinate is xi · yi. Let x ∨ y (resp. x ∧ y) be the vector whose i-th coordinate is max{xi, yi} (resp. min{xi, yi}). Let 1S ∈ {0, 1}V denote the indicator vector of S ⊆ V , i.e., the vector that has a 1 in entry i if and only if i ∈ S. Let F : [0, 1]n → R+ denote the multilinear extension of f: F (x) = E[f(R(x))] = XS⊆V f(S)Yi∈S xi Yi∈V \S (1 − xi), where R(x) is a random subset of V where each i ∈ V is included independently at random with probability xi. We use ∇F to denote the gradient of F and we use ∂F to denote the i-th coordinate ∂xi of the gradient of F . The multilinear extension has the following well-known properties, see for instance [18]. Claim 2. ∂F ∂xi (x) = F (x ∨ 1{i}) − F (x ∧ 1V \{i}). Proof: Note that F (x) = xi · F (x ∨ 1{i}) + (1 − xi) · F (x ∧ 1V \{i}). 3 Algorithm 1: Algorithm for a box constraint 1 u(0) = u, v(0) = v 2 for i ∈ [n] do ai ← (vi − ui)(cid:16)F(cid:16)u(i−1) ∨ 1{i}(cid:17) − F(cid:16)u(i−1) ∧ 1V \{i}(cid:17)(cid:17) bi ← (vi − ui)(cid:16)F(cid:16)v(i−1) ∧ 1V \{i}(cid:17) − F(cid:16)v(i−1) ∨ 1{i}(cid:17)(cid:17) i = max(bi, 0) i = max(ai, 0), b′ a′ if a′ i 6= 0 then i + b′ u(i) ← u(i−1) + a′ i+b′ a′ v(i) ← v(i−1) − b′ i+b′ a′ i i · (vi − ui) · 1{i} · (vi − ui) · 1{i} i i 3 4 5 6 7 8 9 10 11 else // Can update u(i) and v(i) i i // We set u(i) i = v(i−1) i = v(i) u(i) ← u(i−1) + (vi − ui) · 1{i} v(i) ← v(i−1) i to any common value 12 return u(n) Figure 1: Double Greedy algorithm for a box constraint {x : u ≤ x ≤ v}. Thus if we take the partial derivative with respect to xi, we obtain the claim. (cid:3) Claim 3. If x ≤ y then ∇F (x) ≥ ∇F (y). Proof: Fix a coordinate i. Since x ≤ y, submodularity implies that F (x ∨ 1{i}) − F (x ∧ 1V \{i}) ≥ F (y ∨ 1{i}) − F (y ∧ 1V \{i}). By Claim 2, the left-hand side of the inequality above is ∂F ∂xi (x) and the right-hand side is ∂F ∂xi (y). (cid:3) Claim 4. F is concave along any line of direction d ≥ 0. That is, for any vector x, the function φ : R → R such that φ(t) = F (x + t · d) for every t ∈ R for which x + t · d ∈ [0, 1]V is concave. Proof sketch: By submodularity, we can verify that φ′′(t) ≤ 0 and thus φ is concave. (cid:3) 3 Double Greedy algorithm for a box constraint In this section, we describe an algorithm for maximizing the multilinear extension subject to a box constraint: given u and v, find maxu≤x≤v F (x). The algorithm is similar to the Double Greedy algorithm of [2] and it is given in Figure 1. The proof of the following lemma is similar to the analysis of the Double Greedy algorithm and it can be found in Appendix A. 4 Algorithm 2: Algorithm for a general constraint 1 Initialize x∗ = 0 2 for θ ∈ [0, 1] do // Dampened Continuous Greedy stage Initialize x(0) = 0 for t ∈ [0, θ] do v(t) = argmaxc∈C,kck∞≤αh∇F (x(t)) ◦ (1 − x(t)), ci Update x(t) according to dx(t) dt = v(t) ◦ (1 − x(t)) // Standard Continuous Greedy stage Initialize y(θ) = x(θ) for t ∈ (θ, 1] do v(t) = argmaxc∈Ch∇F (y(t)) ◦ (1 − y(t)), ci Update y(t) according to dy(t) dt = v(t) ◦ (1 − y(t)) // Double Greedy stage p = argmaxc∈C h∇F (x(θ)) ◦ (1 − x(θ)), ci Find z approximating argmaxc≤p F (c) using the Double Greedy algorithm (Algorithm 1) // Update the best solution if F (y(1)) > F (x∗) then x∗ = y(1) if F (z) > F (x∗) then x∗ = z 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Return x∗ Figure 2: Continuous algorithm for a general constraint Lemma 5. Algorithm 1 finds a solution x to the problem maxu≤x≤v F (x) such that F (x) ≥ 1 2 · F (OPT) + 1 4 · F (u) + 1 4 · F (v), where OPT is an optimal solution to the problem maxu≤x≤v F (x). Alternatively, we can reduce the problem with a box constraint to the unconstrained problem by defining a suitable submodular function g(S) = F (u+(v−u)◦1S). We can show that this reduction is correct using the same argument given in the appendix. 5 4 The algorithm In this section, we describe our main algorithm for the problem maxx∈C F (x). We first give a continuous version of our algorithm; in order to efficiently implement the algorithm, we discretize it using a standard approach, and we give the details in Appendix B. The algorithm picks the best out of two solutions. The first solution is constructed by running the Continuous Greedy algorithm with an additional dampening constraint5 as long as the marginal gain remains high despite the dampening constraint, and then finishing the solution via the standard Continuous Greedy algorithm for the remaining time. The second solution is constructed by running Double Greedy exactly when the marginal gain becomes low because of the dampening constraint, which must happen early if the first solution is not good. Since we do not know precisely when the marginal gain becomes low, the algorithm tries all possible values via the outer for loop on line 2. 5 The analysis In this section, we analyze the algorithm and show that it achieves an approximation greater than 0.372. We remark that the analysis in Subsection 5.1 is fairly standard, and the crux of the analysis is in Subsection 5.2. In the following, we fix an iteration θ of the outer loop and we analyze the solutions constructed in that iteration. In the remainder of this section, all of the vectors x(·), y(·), etc. refer to the vectors during iteration θ. 5.1 Analysis of the solution y(1) In this section, we analyze the solution y(1) constructed in any given iteration θ ∈ [0, 1]. Theorem 6. Let θ ∈ [0, 1] and let y(1) be the solution constructed by Algorithm 2 in iteration θ of the outer loop. We have F (y(1)) ≥ 1 e(cid:16)eθF (x(θ)) + (1 − θ)e(1−α)θF (OPT)(cid:17) . We devote the rest of this section to the proof of Theorem 6. In the remainder of this section, all of the vectors x(·), y(·), etc. refer to the vectors during iteration θ. We start by upper bounding the ℓ∞ norm of x(t) and y(t). Lemma 7. Consider the following process. Let time run from t = t0 ≥ 0 to t = t1 ≤ 1. Let u(t) be a vector updated according to du(t) dt = v(t) ◦ (1 − u(t)), where v(t) is a vector such that kv(t)k∞ ≤ δ. Then ku(t)k∞ ≤ 1 + (ku(t0)k∞ − 1)e−δ(t−t0 ) for each t ∈ [t0, t1]. 5The dampening constraint imposes an ℓ∞ constraint in line 5 of Algorithm 2. 6 Proof: The i-th coordinate u(t) i of u(t) is updated according to du(t) i dt = v(t) i (1 − u(t) i ) ≤ δ(1 − u(t) i ). By solving the differential inequality above, we obtain u(t) Using the initial condition 1 + C · e−δt0 = u(t0) 1 + (u(t0) i − 1)e−δ(t−t0 ). i , we obtain C = (u(t0) i ≤ 1 + C · e−δt, where C is a constant. i ≤ (cid:3) i − 1)eδt0 and thus u(t) Corollary 8. For every t ∈ [0, θ], kx(t)k∞ ≤ 1 − e−αt. Proof: The vector x(t) starts at 0 and it is updated according to the update rule in line 6, where v(t) is a vector of ℓ∞ norm at most α. Thus it follows from Lemma 7 that kx(t)k∞ ≤ 1 − e−αt. (cid:3) Corollary 9. For every t ∈ [θ, 1], ky(t)k∞ ≤ 1 − e(1−α)θ−t. Proof: The vector y(t) starts at y(θ) = x(θ) and it is updated according to the update rule in line 11, where v(t) is a vector of ℓ∞ norm at most 1. Thus it follows from Lemma 7 and the upper bound on kx(θ)k∞ given by Corollary 8 that ky(t)k∞ ≤ 1 + (kx(θ)k∞ − 1)e−(t−θ) ≤ 1 − e(1−α)θ−t. We will also need the following lemma that was shown in [7]. Lemma 10 ([7, Lemma III.5]). Let x ∈ [0, 1]n and let S ⊆ V . We have F (x ∨ 1S) ≥ (1 − kxk∞)f(S). Proof of Theorem 6: Using the chain rule, for every t ∈ [θ, 1], we have dF (y(t)) dt dy(t) dt + =*∇F (y(t)), =D∇F (y(t)), v(t) ◦ (1 − y(t))E =D∇F (y(t)) ◦ (1 − y(t)), v(t)E ≥D∇F (y(t)) ◦ (1 − y(t)), OPTE ≥ F (y(t) ∨ OPT) − F (y(t)) ≥ e(1−α)θ−t · F (OPT) − F (y(t)). By solving the differential inequality, we obtain (By Corollary 9 and Lemma 10) and thus F (y(t)) ≥ F (y(1)) ≥ 1 et(cid:16)eθF (y(θ)) + (t − θ)e(1−α)θF (OPT)(cid:17) , e(cid:16)eθF (y(θ)) + (1 − θ)e(1−α)θF (OPT)(cid:17) . 1 The theorem now follows, since y(θ) = x(θ). 7 (cid:3) (cid:3) 5.2 Analysis of the solution z In this section, we analyze the solution z constructed using the Double Greedy algorithm, and this is the crux of our argument. Theorem 11. Let θ ∈ [0, 1] and let z be the solution constructed by Algorithm 2 in iteration θ of the outer loop. If α ≥ 1/2, we have F (z) ≥ 1 2(1 − α) (e−αθF (OPT) − F (x(θ)) − h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i). We first give some intuition for the approach. Consider the solution x constructed by the dampened Continuous Greedy algorithm. The rate of growth of F (x) is given by the inner product h∇F (x) ◦ (1 − x), vi and thus the crux of the analysis is to understand how this inner product evolves over time. The inner product h∇F (x) ◦ (1 − x), vi is always at least h∇F (x) ◦ (1 − x), αOPTi and intuitively we should gain proportional to the difference between the two. If this difference is very small, the key insight is that once we drop the dampening constraint and compute the vector that maximizes h∇F (x)◦(1−x), ci over all feasible vectors c, we obtain a vector p that is well-correlated with OPT in the sense that p∧OPT is a good solution. We formalize this intuition in the remainder of this section. In the remainder of this section, we analyze the solution By submodularity, we have bz := (1 − x(θ)) ◦ (p ∧ OPT). F (bz) − F (0) ≥ F (bz + x(θ)) − F (x(θ)), and thus it suffices to analyze F (bz + x(θ)). Note that x(θ) ≤bz + x(θ) ≤ x(θ) + (1 − x(θ)) ◦ OPT = x(θ) ∨ OPT. Thus Claim 4 and Claim 3 give F (x(θ) ∨ OPT) − F (bz + x(θ)) ≤ h∇F (bz + x(θ)), (1 − x(θ)) ◦ ((1 − p) ∧ OPT)i (By Claim 4) (By Claim 3) ≤ h∇F (x(θ)), (1 − x(θ)) ◦ ((1 − p) ∧ OPT)i = h∇F (x(θ)) ◦ (1 − x(θ)), (1 − p) ∧ OPTi In the first inequality, we have used the fact that (x(θ) ∨ OPT) − (bz + x(θ)) = (x(θ) + (1 − x(θ)) ◦ OPT) − (bz + x(θ)) = (1 − x(θ)) ◦ ((1 − p) ∧ OPT). In order to upper bound h∇F (x(θ)) ◦ (1 − x(θ)), (1 − p) ∧ OPTi, we consider the following vector. bv := (1 − α)((1 − p) ∧ OPT) + αp. The intuition behind the choice of bv is to connect the fact that the inner product h∇F (x(τ )) ◦ (1 − x(τ )), vi is not much more than h∇F (x(τ )) ◦ (1 − x(τ )), αOPTi to the insight that h∇F (x(τ )) ◦ (1 − x(τ )), (1 − p) ∧ OPTi is small. Since α ≥ 1/2, we have 1 − α ≤ α. Therefore, for each i ∈ [n], we have bvi =((1 − α)(1 − pi) + αpi ≤ α αpi ≤ α 8 if i ∈ OPT otherwise Therefore kbvk∞ ≤ α. Additionally, bv ∈ C, since it is a convex combination of two vectors in C (recall that C is downward closed and convex). It follows from the definition of v(θ) on line 5 that h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i ≥ h∇F (x(θ)) ◦ (1 − x(θ)),bvi = (1 − α)h∇F (x(θ)) ◦ (1 − x(θ)), (1 − p) ∧ OPT)i + αh∇F (x(θ)) ◦ (1 − x(θ)), pi ≥ (1 − α)h∇F (x(θ)) ◦ (1 − x(θ)), (1 − p) ∧ OPT)i + αh∇F (x(θ)) ◦ (1 − x(θ)), OPTi ≥ (1 − α)h∇F (x(θ)) ◦ (1 − x(θ)), (1 − p) ∧ OPT)i + α(F (x(θ) ∨ OPT) − F (x(θ))) By rearranging the inequality above, we obtain h∇F (x(θ)) ◦ (1 − x(θ)), (1 − p) ∧ OPT)i ≤ 1 1 − α h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i − α 1 − α (F (x(θ) ∨ OPT) − F (x(θ))). By combining all of the inequalities, we obtain F (bz) ≥ F (bz + x(θ)) − F (x(θ)) ≥ F (x(θ) ∨ OPT) − F (x(θ)) − h∇F (x(θ)) ◦ (1 − x(θ)), (1 − p) ∧ OPT)i ≥ ≥ 1 1 − α 1 1 − α (F (x(θ) ∨ OPT) − F (x(θ)) − h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i) (e−αθF (OPT) − F (x(θ)) − h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i) In the last inequality, we have used Corollary 8 and Lemma 10 to lower bound F (x(θ) ∨ OPT) by e−αθF (OPT). Sincebz is a candidate solution for the Double Greedy step on line 14, it follows from Lemma 5 that F (z) ≥ 1 2 F (bz), and the theorem follows. 5.3 Combining the two solutions As we have shown above, in every iteration θ of the algorithm, we obtain two solutions y(1) and z satisfying: F (y(1)) ≥ F (z) ≥ 2(1 − α) 1 e(cid:16)(1 − θ)e(1−α)θF (OPT) + eθF (x(θ))(cid:17) 1 (e−αθF (OPT) − F (x(θ)) − h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i) In the following, we show that there is an iteration θ for which max{F (y(1)), F (z)} > C · F (OPT), where C is a constant that we will set later. We will proceed by contradiction and assume that max{F (y(1)), F (z)} ≤ C · F (OPT) for all θ. Note that the coefficient of F (x(θ)) is positive in the first inequality above and it is negative in the second inequality, and there is a trade-off between the two solutions. We can get a handle on this 9 trade-off as follows. To simplify matters, we take a convex combination of the two inequalities and eliminate F (x(θ)). Thus we get that, for all θ ∈ [0, 1], 1 2(1−α) + eθ−1 (2 − θ)e(1−α)θ−1 2(1 − α) 1 F (OPT) − eθ−1 2(1 − α) h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i! ≤ C · F (OPT). Thus, for all θ ∈ [0, 1], Now note that 0 h∇F (x(t)) ◦ (1 − x(t)), v(t)i)dt h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i ≥(cid:16)(2 − θ)e−αθ − (e1−θ + 2(1 − α))C(cid:17)F (OPT). F (x(θ)) =Z θ ≥Z θ 0 (cid:16)(2 − t)e−αt − (e1−t + 2(1 − α))C(cid:17)F (OPT)dt − (−e1−t + 2(1 − α)t)C!(cid:12)(cid:12)(cid:12) = e−αt(α(t − 2) + 1) = e−αθ(α(θ − 2) + 1) + 2α − 1 − (−e1−θ + 2(1 − α)θ + e)C! F (OPT) F (OPT) α2 θ t=0 α2 Therefore F (y(1)) ≥ (1 − θ)e(1−α)θ−1 + e(1−α)θ−1(α(θ − 2) + 1) + eθ−1(2α − 1) α2 − (−1 + 2(1 − α)θeθ−1 + eθ)C!F (OPT) In order to obtain a contradiction, we need that the coefficient of F (OPT) in the inequality above is at least C for some θ ∈ [0, 1] and some α ∈ [1/2, 1]. Equivalently, (1 − θ)e(1−α)θ−1 + e(1−α)θ−1(α(θ − 2) + 1) + eθ−1(2α − 1) α2 − (2(1 − α)θeθ−1 + eθ)C! ≥ 0. By rearranging, we have C ≤ 2(1 − α)θeθ−1 + eθ (1 − θ)e(1−α)θ−1 + 1 e(1−α)θ−1(α(θ − 2) + 1) + eθ−1(2α − 1) α2 ! . Thus, in order to obtain the best approximation C, we need to maximize the right hand side of the inequality above over θ ∈ [0, 1] and α ∈ [1/2, 1]. Setting α = 1/2 and θ = 0.18 gives C > 0.372. References [1] Niv Buchbinder, Moran Feldman, Joseph Naor, and Roy Schwartz. Submodular maximization with cardinality constraints. In Proc. 25th SODA, pages 1433–1452, 2014. 10 [2] Niv Buchbinder, Moran Feldman, Joseph (Seffi) Naor, and Roy Schwartz. A tight linear time (1/2)-approximation for unconstrained submodular maximization. In Proc. 53nd FOCS, 2012. [3] Gruia Calinescu, Chandra Chekuri, Martin Pál, and Jan Vondrák. Maximizing a submodular set function subject to a matroid constraint. SIAM J. Comput., 40(6):1740–1766, 2011. [4] Chandra Chekuri, T. S. Jayram, and Jan Vondrák. On multiplicative weight updates for concave and submodular function maximization. In Proc. 6th ITCS, pages 201–210, 2015. [5] Chandra Chekuri, Jan Vondrák, and Rico Zenklusen. Submodular function maximization via the multilinear relaxation and contention resolution schemes. SIAM J. Comput., 43(6):1831– 1879, 2014. [6] Shaddin Dughmi, Tim Roughgarden, and Mukund Sundararajan. Revenue submodularity. Theory of Computing, 8(1):95–119, 2012. [7] Moran Feldman, Joseph Naor, and Roy Schwartz. A unified continuous greedy algorithm for submodular maximization. In Proc. 52nd FOCS, pages 570–579, 2011. [8] Shayan Oveis Gharan and Jan Vondrák. Submodular maximization by simulated annealing. In Proc. 22nd SODA, pages 1098–1117. SIAM, 2011. [9] Ryan Gomes and Andreas Krause. Budgeted nonparametric learning from data streams. In Proc. 27th ICML, pages 391–398, 2010. [10] Stefanie Jegelka and Jeff A. Bilmes. Submodularity beyond submodular energies: Coupling edges in graph cuts. In The 24th IEEE Conference on Computer Vision and Pattern Recogni- tion, CVPR 2011, Colorado Springs, CO, USA, 20-25 June 2011, pages 1897–1904, 2011. [11] David Kempe, Jon M. Kleinberg, and Éva Tardos. Maximizing the spread of influence through a social network. In Proc. 9th KDD, pages 137–146, 2003. [12] Andreas Krause, Ajit Paul Singh, and Carlos Guestrin. Near-optimal sensor placements in gaussian processes: Theory, efficient algorithms and empirical studies. Journal of Machine Learning Research, 9:235–284, 2008. [13] Jon Lee, Vahab S Mirrokni, Viswanath Nagarajan, and Maxim Sviridenko. Non-monotone In Proc. 41st STOC, submodular maximization under matroid and knapsack constraints. pages 323–332. ACM, 2009. [14] Jon Lee, Maxim Sviridenko, and Jan Vondrák. Submodular maximization over multiple ma- troids via generalized exchange properties. Mathematics of Operations Research, 35(4):795–806, 2010. [15] Hui Lin and Jeff A. Bilmes. Multi-document summarization via budgeted maximization of submodular functions. In Human Language Technologies: Conference of the North American Chapter of the Association of Computational Linguistics, Proceedings, June 2-4, 2010, Los Angeles, California, USA, pages 912–920, 2010. [16] G L Nemhauser and L A Wolsey. Best algorithms for approximating the maximum of a submodular set function. Mathematics of Operations Research, 3(3):177–188, 1978. 11 [17] Maxim Sviridenko. A note on maximizing a submodular set function subject to a knapsack constraint. Operations Research Letters, 32(1):41–43, 2004. [18] Jan Vondrák. Optimal approximation for the submodular welfare problem in the value oracle model. In Proc. 40th STOC, pages 67–74. ACM, 2008. 12 A Analysis of Algorithm 1 In this section, we analyze Algorithm 1 given in Section 3. We start by showing that the problem maxu≤x≤v F (x) has an optimal solution OPT with the following property. Lemma 12. There is an optimal solution OPT to the problem maxu≤x≤v F (x) such that for all i, either OPTi = ui or OPTi = vi. Proof: Let OPT = argmaxu≤x≤v F (x) be an arbitrary optimal solution. Note that we can write each OPTi as a convex combination of ui and vi: OPTi = γiui + (1 − γi)vi, where γi = (OPTi − ui)/(vi − ui) if ui 6= vi and γi = 1 otherwise. Let oi be a random variable that is equal to ui with probability γi and is equal to vi with probability 1 − γi. Let o be the vector whose coordinates are oi's. By the definition of the multilinear extension, we have F (OPT) = Eo[F (o)]. Thus, there exists a realization o = o such that F (o) ≥ F (OPT). Thus there is an optimal solution such that for all i, its ith coordinate is either ui or vi. (cid:3) We will also use the following observation that follows from the definition of the multilinear exten- sion. Claim 13. Let x ∈ [0, 1]n and δ ∈ [−xi, 1 − xi]. We have F (x + δ · 1{i}) − F (x) = δ · (F (x ∨ 1{i}) − F (x ∧ 1V \{i})). Proof: Note that, for each y ∈ [0, 1]n and each j ∈ [n], F (y) = yj · F (y ∨ 1{j}) + (1 − yj) · F (y ∧ 1V \{j}). Therefore F (x + δ · 1{i}) = (xi + δ) · F (x ∨ 1{i}) + (1 − xi − δ) · F (x ∧ 1V \{i}), F (x) = xi · F (x ∨ 1{i}) + (1 − xi) · F (x ∧ 1V \{i}), and the claim follows. (cid:3) Proof of Lemma 5: Let OPT = argmaxu≤x≤v F (x). By Lemma 12, we may assume that for each i, either OPTi = ui or OPTi = vi. Let OPT(i) = (OPT∨u(i))∧v(i). Note that u(i) ≤ OPT(i) ≤ v(i) and therefore ∇F (u(i)) ≥ ∇F (OPT(i)) ≥ ∇F (v(i)) by Fact 3. We will show that F (OPT(i−1)) − F (OPT(i)) ≤ 1 2(cid:16)F (u(i)) − F (u(i−1)) + F (v(i)) − F (v(i−1))(cid:17) . (1) Note that (1) immediately implies the lemma. We prove (1) in the following. Suppose that a′ i 6= 0. By Claim 13, i + b′ F (u(i)) − F (u(i−1)) = and F (v(i)) − F (v(i−1)) = b′ i i + b′ a′ i a′ i i + b′ a′ i (vi − ui)(cid:16)F (u(i−1) ∨ 1{i}) − F (u(i−1) ∧ 1V \{i})(cid:17) = (vi − ui)(cid:16)−F (v(i−1) ∨ 1{i}) + F (v(i−1) ∧ 1V \{i})(cid:17) = i)2 (a′ i + b′ a′ i . i)2 (b′ i + b′ a′ i . 13 Now recall that we have either OPTi = ui or OPTi = vi. If OPTi = ui, we have F (OPT(i−1)) − F (OPT(i)) = (vi − ui)(cid:16)−F (OPT(i−1) ∨ 1{i}) + F (OPT(i−1) ∧ 1(V \{i}))(cid:17) (vi − ui) (vi − ui) ∂F ∂xi ∂F ∂xi (OPT(i−1)) (v(i−1)) a′ i i + b′ a′ i a′ i i + b′ a′ i a′ i i + b′ a′ i a′ ibi i + b′ a′ i ib′ a′ i i + b′ a′ i = − ≤ − = ≤ On the first two lines, we have used Claim 13 and Fact 2. On the third line, we have used the fact that ∇F (OPT(i−1)) ≥ ∇F (v(i−1)). On the fourth and fifth lines, we have used the definition of bi and b′ i. If OPTi = vi, we use an analogous argument. F (OPT(i−1)) − F (OPT(i)) = = ≤ ≤ (vi − ui)(F (OPT(i−1) ∨ 1{i}) − F (OPT(i−1) ∧ 1V \{i})) (vi − ui) (vi − ui) ∂F ∂xi ∂F ∂xi (OPT(i−1)) (u(i−1)) b′ i i + b′ a′ i b′ i i + b′ a′ i b′ i i + b′ a′ i ib′ a′ i i + b′ a′ i ib′ i ≤ (a′ i)2, the inequality (1) follows. i + b′ i)2 + (b′ Since 2a′ Finally, suppose that a′ i = 0. Notice that ai ≥ −bi by submodularity so this case can only happen if ai = bi = 0. In this case, we can set the ith coordinate of u and v to an arbitrary common value and by the same argument as above, we have F (u(i)) = F (u(i−1)), F (v(i)) = F (v(i−1)), and F (OPT(i)) = F (OPT(i−1)). Therefore (1) is trivially satisfied. (cid:3) B Discretized algorithm In Figure 3, we give a discretized version of Algorithm 2. In the remainder of this section, we show how to modify the analysis from Section 5. We discretize the time interval [0, 1] into segments of size δ = n−4. Analysis of the solution y(1). We modify the analysis from Subsection 5.1 as follows. (Note that the rest of the analysis remains unchanged.) Consider an iteration θ of the outer for loop of Algorithm 3. In the remainder of this section, all of the vectors x(·), y(·), etc. refer to the vectors during iteration θ. All of the time steps are implicitly assumed to be the discrete time steps {0, δ, 2δ, 3δ, . . . , 1}. 14 Algorithm 3: Discretized algorithm for a general constraint 1 Initialize x∗ = 0 2 δ = n−4 3 for θ ∈ {0, δ, 2δ, 3δ, . . . , 1} do // Dampened Continuous Greedy stage Initialize x(0) = 0 t = 0 while t < θ do v(t) = argmaxc∈C,kck∞≤αh∇F (x(t)) ◦ (1 − x(t)), ci x(t+δ) = x(t) + δv(t) ◦ (1 − x(t)) t = t + δ // Standard Continuous Greedy stage Initialize y(θ) = x(θ) while t < 1 do v(t) = argmaxc∈Ch∇F (y(t)) ◦ (1 − y(t)), ci y(t+δ) = y(t) + δv(t) ◦ (1 − y(t)) t = t + δ // Double Greedy stage p = argmaxc∈C h∇F (x(θ)) ◦ (1 − x(θ)), ci Find z approximating argmaxc≤p F (c) using the Double Greedy algorithm (Algorithm 1) // Update the best solution if F (y(1)) > F (x∗) then x∗ = y(1) if F (z) > F (x∗) then x∗ = z 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Return x∗ Figure 3: Discretized algorithm for a general constraint First we prove bounds on kx(t)k∞ and ky(t)k∞ with a similar argument to Lemma 7. Consider a fixed i ∈ [n]. Since v(t) i ) for all t < θ. Thus, i ≤ α for all t < θ, we have 1 − x(t+δ) ≥ (1 − δα)(1 − x(t) i Similarly, for all t ∈ [θ, 1] and t a multiple of δ, 1 − x(t) i ≥ (1 − δα)t/δ . 1 − y(t) i ≥ (1 − δα)θ/δ(1 − δ)(t−θ)/δ. Next we prove a lower bound on F (y(1)) with a similar argument to Theorem 6. 15 Lemma 14. Consider u, v satisfying ui − vi ≤ δ. Then F (v) − F (u) ≤ δn2M, where M = maxi∈[n] f({i}). Proof: First consider the case u, v agree on all but coordinate i0. Let R(x) be the random set where each element i is independently included with probability xi. This process can be thought of as picking a random ri ∈ [0, 1] and including i if ri ≤ xi. One can generate (coupled) R(u) and R(v) by sharing the same ri's. Notice that R(u) and R(v) agree on all coordinates other than i0 and they disagree on coordinate i0 with probability at most δ. Thus we have E[f(R(u)) − f(R(v))] ≤ δE[f(R(u)) R(u) 6= R(v)] ≤ δ max S⊆V f(S) ≤ δnM. Next, let ui be the vector whose first i coordinates agree with u and the last n − i coordinates agree with v. We have F (v) − F (u) = (F (ui) − F (ui+1)) ≤ δn2M, n−1Xi=0 where the inequality comes from the above special case. Corollary 15. Consider u and v satisfying u ≤ v and vi ≤ ui + δ. Then ∂F ∂xi (u) − ∂F ∂xi (v) ≤ 2δn2M. Proof: By Claim 2, ∂F ∂xi (u) − ∂F ∂xi (v) = F (u ∨ 1{i}) − F (v ∨ 1{i}) − F (u ∧ 1V \{i}) + F (v ∧ 1V \{i}) ≤ 2δn2M. For any given t ∈ [θ, 1 − δ], we have (cid:3) (cid:3) F (y(t+δ)) − F (y(t)) h∇F ((1 − z)y(t) + zy(t+δ)), y(t+δ) − y(t)idz 0 h∇F ((1 − z)y(t) + zy(t+δ)) − ∇F (y(t)), y(t+δ) − y(t)idz k∇F ((1 − z)y(t) + zy(t+δ)) − ∇F (y(t))k∞ky(t+δ) − y(t)k1dz =Z 1 = h∇F (y(t)), y(t+δ) − y(t)i +Z 1 ≥ h∇F (y(t)), y(t+δ) − y(t)i −Z 1 0 0 ≥ h∇F (y(t)), y(t+δ) − y(t)i − δ2n3M = h∇F (y(t)), δv(t) ◦ (1 − y(t))i − δ2n3M = h∇F (y(t)) ◦ (1 − y(t)), δv(t)i − δ2n3M ≥ h∇F (y(t)) ◦ (1 − y(t)), δOPTi − δ2n3M ≥ δ(F (y(t) ∨ OPT) − F (y(t))) − δ2n3M 16 ≥ δ(1 − δα)θ/δ(1 − δ)(t−θ)/δ · F (OPT) − δ · F (y(t)) − δ2n3M (By Lemma 10) Therefore we have the following recurrence for F (y(t)): F (y(t+δ)) ≥ (1 − δ)F (y(t)) + δ(1 − δα)θ/δ(1 − δ)(t−θ)/δ · F (OPT) − δ2n3M. By expanding the recurrence, we obtain F (y(t)) ≥ (1 − δ)(t−θ)/δ(cid:16)(t − θ)(1 − δα)θ/δ · F (OPT) + F (x(θ))(cid:17) − tδn3M. By substituting t = 1 and δ = n−4 and by using the inequalities e−x/(1−x) ≤ 1 − x ≤ e−x for all 0 < x < 1, we obtain F (y(1)) ≥ e−1+θ(cid:16)(1 − θ)e−αθF (OPT) + F (x(θ))(cid:17) − O(n−1)F (OPT) e(cid:16)(1 − θ)e(1−α)θF (OPT) + eθF (x(θ))(cid:17) − O(n−1)F (OPT). = 1 Combining the two solutions y(1) and z. We extend the argument in Subsection 5.3 as follows. As we have shown above, in every iteration θ that is a multiple of δ, we obtain two solutions y(1) and z satisfying: F (y(1)) ≥ F (z) ≥ 1 e(cid:16)(1 − θ)e(1−α)θF (OPT) + eθF (x(θ))(cid:17) − O(n−1)F (OPT) (e−αθF (OPT) − F (x(θ)) − h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i) 1 2(1 − α) As before, we show that there is an iteration θ for which max{F (y(1)), F (z)} > C · F (OPT), where C is a constant that we will set later. We will proceed by contradiction and assume that max{F (y(1)), F (z)} ≤ C · F (OPT) for all θ. We take a convex combination of the two inequalities and eliminate F (x(θ)). Thus we get that, for all θ, 1 2(1−α) + eθ−1 (2 − θ)e(1−α)θ−1 2(1 − α) 1 F (OPT) − eθ−1 2(1 − α) h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i)! ≤ C ′·F (OPT), where C ′ = C + O(n−1). Thus, for all θ ∈ [0, 1], h∇F (x(θ)) ◦ (1 − x(θ)), v(θ)i) ≥(cid:16)(2 − θ)e−αθ − (e1−θ + 2(1 − α))C ′(cid:17)F (OPT). For any given t ∈ [0, θ), we have F (x(t+δ)) − F (x(t)) 0 =Z 1 = h∇F (x(t)), x(t+δ) − x(t)i +Z 1 0 h∇F ((1 − z)x(t) + zx(t+δ)), x(t+δ) − x(t)idz h∇F ((1 − z)x(t) + zx(t+δ)) − ∇F (x(t)), x(t+δ) − x(t)idz 17 k∇F ((1 − z)x(t) + zx(t+δ)) − ∇F (x(t))k∞kx(t+δ) − x(t)k1dz ≥ h∇F (x(t)), x(t+δ) − x(t)i −Z 1 0 ≥ h∇F (x(t)), x(t+δ) − x(t)i − δ2n3M = h∇F (x(t)), δv(t) ◦ (1 − x(t))i − δ2n3M = δh∇F (x(t)) ◦ (1 − x(t)), δv(t)i − δ2n3M ≥ δ(cid:16)(2 − t)e−αt − (e1−t + 2(1 − α))C ′(cid:17)F (OPT) − δ2n3M By expanding the recurrence, we obtain F (x(t+δ)) ≥ t/δXi=0(cid:16)δ(cid:16)(2 − t + iδ)e−α(t−iδ) − (e1−t+iδ + 2(1 − α))C ′(cid:17)F (OPT) − δ2n3M(cid:17) (2) By computation, we have δ(2 − t + iδ)e−α(t−iδ) = δe−αt (2 − t − δ) t/δXi=0 eαδ − 1 + δ tαeαt − eαt + 1 ≥ e−αt (2 − t)(eαt − 1) α + = (t − 2)αe−αt + 2α − 1 + e−αt α2 α2 − O(δ) (eαδ − 1)2 ! − O(δ) eαδ(t/δ+1) − 1 (t/δ + 1)eαδ(t/δ+2) − (t/δ + 2)eαδ(t/δ+1) + 1 ! We also have t/δXi=0 δ(e1−t+iδ + 2(1 − α))C ′ = δe1−t et+δ − 1 eδ − 1 + 2(1 − α)(t + δ)! C ′ ≤(cid:16)e − e1−t + 2(1 − α)(t + δ)(cid:17) C ′ + O(δ) Substituting into Equation 2, we have F (x(t+δ)) ≥ (t − 2)αe−αt + 2α − 1 + e−αt α2 − (e − e1−t + 2(1 − α)t)C ′ − O(δn3)! F (OPT) Notice that the RHS is exactly the same as in the continuous argument except for an additive error O(δn3)F (OPT). By carrying this error through, we can finish the proof exactly the same as before. 18
1903.08014
1
1903
2019-03-19T14:21:43
Independent Range Sampling, Revisited Again
[ "cs.DS", "cs.CG" ]
We revisit the range sampling problem: the input is a set of points where each point is associated with a real-valued weight. The goal is to store them in a structure such that given a query range and an integer $k$, we can extract $k$ independent random samples from the points inside the query range, where the probability of sampling a point is proportional to its weight. This line of work was initiated in 2014 by Hu, Qiao, and Tao and it was later followed up by Afshani and Wei. The first line of work mostly studied unweighted but dynamic version of the problem in one dimension whereas the second result considered the static weighted problem in one dimension as well as the unweighted problem in 3D for halfspace queries. We offer three main results and some interesting insights that were missed by the previous work: We show that it is possible to build efficient data structures for range sampling queries if we allow the query time to hold in expectation (the first result), or obtain efficient worst-case query bounds by allowing the sampling probability to be approximately proportional to the weight (the second result). The third result is a conditional lower bound that shows essentially one of the previous two concessions is needed. For instance, for the 3D range sampling queries, the first two results give efficient data structures with near-linear space and polylogarithmic query time whereas the lower bound shows with near-linear space the worst-case query time must be close to $n^{2/3}$, ignoring polylogarithmic factors. Up to our knowledge, this is the first such major gap between the expected and worst-case query time of a range searching problem.
cs.DS
cs
Independent Range Sampling, Revisited Again Peyman Afshani Aarhus University [email protected] Jeff M. Phillips University of Utah [email protected] Abstract We revisit the range sampling problem: the input is a set of points where each point is associated with a real-valued weight. The goal is to store them in a structure such that given a query range and an integer k, we can extract k independent random samples from the points inside the query range, where the probability of sampling a point is proportional to its weight. This line of work was initiated in 2014 by Hu, Qiao, and Tao and it was later followed up by Afshani and Wei. The first line of work mostly studied unweighted but dynamic version of the problem in one dimension whereas the second result considered the static weighted problem in one dimension as well as the unweighted problem in 3D for halfspace queries. We offer three main results and some interesting insights that were missed by the previous work: We show that it is possible to build efficient data structures for range sampling queries if we allow the query time to hold in expectation (the first result), or obtain efficient worst-case query bounds by allowing the sampling probability to be approximately proportional to the weight (the second result). The third result is a conditional lower bound that shows essentially one of the previous two concessions is needed. For instance, for the 3D range sampling queries, the first two results give efficient data structures with near-linear space and polylogarithmic query time whereas the lower bound shows with near-linear space the worst-case query time must be close to n2/3, ignoring polylogarithmic factors. Up to our knowledge, this is the first such major gap between the expected and worst-case query time of a range searching problem. 2012 ACM Subject Classification Theory of computation → Randomness, geometry and discrete structures; Theory of computation → Computational geometry Keywords and phrases Range Searching, Data Structures, Sampling Digital Object Identifier 10.4230/LIPIcs... Funding Peyman Afshani: supported by DFF (Det Frie Forskningsräd) of Danish Council for Indepndent Reserach under grant ID DFF−7014−00404. Jeff M. Phillips: supported by NSF CCF-1350888, CNS-1514520, CNS-1564287, IIS-1816149, and in particular ACI-1443046. Part of the work was completed while visiting the Simons Institute for Theory of Computing. 1 Introduction In range searching, the goal is store a set P of points in a data structure such that given a query range, we can answer certain questions about the subset of points inside the query range. The difficulty of the range searching problem, thus depends primarily on the shape of the query as well as types of questions that the data structure is able to answer. These range searching questions have been studied extensively and we refer the reader to the survey by Agarwal and Erickson [3] for a deeper review of range searching problems. Let us for a moment fix a particular query shape. For example, assume we are given a set P ⊂ R2 to preprocess and at the query time we will be given a query halfplane h. The simplest type of question is an emptiness query where we simply want to report to the © Peyman Afshani and Jeff M. Phillips; licensed under Creative Commons License CC-BY Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany XX:2 Independent Range Sampling, Revisited Again user whether h ∩ P is empty or not. Within the classical literature of range searching, the most general (and thus the most difficult) variant of range searching is semigroup range searching where each point in P is assigned a weight from a semigroup and at the query time the goal is to return the sum of the weights of the points of h ∩ P. The restriction of the weights to be from a semigroup is to disallow subtraction. As a result, semigroup range searching data structures can answer a diverse set of questions. Other classical variants of range searching lie between the emptiness and the semigroup variant. In our example, the emptiness queries can be trivially solved with O(n) space and O(log n) query time whereas √ the semigroup variant can only be solved with O( n) query time using O(n) space. Finally, the third important variant, range reporting, where the goal is to output all the points in P ∩ h, is often close to the emptiness variant in terms of difficulty. E.g., halfplane queries can be answered in O(log n + k) time where k is the size of the output, using O(n) space. Sampling queries. Let P be a large set of points that we would like to preprocess for range searching queries. Consider a query range h. Classical range searching solutions can answer simple questions such as the list of points inside h, or the number of them. However, we immediately hit a barrier if we are interested in more complex questions, e.g., what if we want to know how a "typical" point in h looks like? Or if we are curious about the distribution of the data in h. In general, doing more complex data analysis requires that we extract the list of all the points inside h but this could be an expensive operation. For questions of this type, as well as many other similar questions, it is very useful to be able to extract a (relatively) small random sample from the subset of points inside h. In fact, range sampling queries were considered more than two decades ago within the context of database systems [9, 4, 7, 13, 12]. Indeed the entire field of sample complexity, which provides the basis for statistics and machine learning, argues how any statistical quantity can be understood from an iid sample of the data. Range sampling allows this literature to quickly be specified to data in a query range. However, many of these classical solutions fail to hold in the worst-case as they use R-trees or Quadtrees whose performance depends on the distribution of the coordinates of the input points (which could be pretty bad). Some don't even guarantee that the samples extracted in the future will be independent of the samples extracted in the past. For example, sometimes asking the same query twice would return the same samples. The previous results. Given a set of n weights, one can sample one weight with proportional probability using the well-known "alias method" by A. J. Walker [16]. This method uses linear space and can sample a weight in worst-case constant time. The rigorous study of independent range sampling was initiated by Hu et al. [10]. They emphasized the requirement that any random sample extracted from the data structure should be independent of all the other samples. They studied the one-dimensional version and for an unweighted point set and presented a linear-sized data structure that could extract k random samples in O(log n + k) time and it could be updated in O(log n) time as well. A few years later, Afshani and Wei [2] revisited the problem and solved the one-dimensional version of the problem for weighted points: they presented a linear-size data structure that could answer queries in O(Pred(n) + k) time where Pred(n) referred to the running time of a predecessor query (often O(log n) but sometimes it could be faster, e.g., if the input is indexed by an array then the predecessor query can be answered trivially in O(1) time). They also studied the 3D halfspace queries but for unweighted points. Their main result was an optimal data structure of linear-size that could answer queries in O(log n + k) time. Afshani & Phillips XX:3 Our results. We provide general results for the independent range sampling problem on weighted input (wIRS), and design specific results for 3D halfspace queries. We show a strong link between the wIRS and the range max problem. Namely, we show that the range max problem is at least as hard as wIRS, and also we provide a general formulation to solve the wIRS problem using range max. For halfspace queries in 3D, our framework gives a structure that uses O(n log n) space and has O(log2 n + k) query time. We improve the space complexity to O(n) when the ratio of the weights is nO(1). This solution uses rejection sampling, so it only provides an expected query time bound. To compensate, we provide another solution that has worst-case query time, but allows the points to be sampled within a (1 ± ε) factor of their desired probability, and may ignore points that would be sampled with probability less than γ/n for γ < ε < 1. This structure requires O(n log n) space, and has a worst-case query time of O(log(n/γ)(log n + 1/ε3) + k). Finally, we show a conditional lower bound when we enforce worst-case query time and exact sampling probabilities, in what we call the separated algebraic decision tree (SAD) model. This model allows any decision tree structure that compares random bits to algebraic functions of a set of input weights. In this model, we show wIRS is as hard as the range sum problem, which is conjectured to be hard. In particular, if the best known solution to the range sum problem for halfspaces in 3D is optimal, then the wIRS problem would require Ω(n2/3−o(1)) query time if it uses near-linear space. This provides the first such separation between expected O(log2 n + k) and worst-case Ω(n2/3−o(1)) query time for a range searching problem that we are aware of. A Randomized Data Structure 2 In this section, we show that if we allow for the query bound to hold in expectation, then the range sampling problem can be solved under some general circumstances. Intuitively, we show that we need two ingredients: one, a data structure for range maximum queries, and two, a data structure that can sample from a weighted set of points under the assumptions that the weights are within a constant factor of each other. Furthermore, with an easy observation, we can also show that the range sampling problem is at least as hard as range maximum problem. We consider the input as a general set system (X, R). We assume the input is a set X of n data elements (e.g., points) and we consider queries to be elements of a set of ranges R where each R ∈ R is a subset of X. The set R is often given implicitly, and for example, if X is a set of points in R3, R could be the set of all h ∩ X where h is a halfspace in 3D. Note that our model of computation is the real RAM model. (cid:73) Definition 1 (The Range Maximum Problem). Let X be a data set, s.t., each element x ∈ X is assigned a real-value weight w(x). The goal is to store X in a structure, s.t., given a range R ∈ R, we can find the element in R with the maximum weight. Given a weighted set X, for any subset Y ⊂ X, we denote by w(Y ) the sumP x∈Y w(x). First we observe that range sampling is at least as hard as the range maximum problem. (cid:73) Lemma 2. Assume we can solve range sampling queries on input (X, R) and for any weight assignment w: X → R using S(X) space and Q(X) query time where the query only returns one sample. Then, given the set X and a weight function w0 : X → R, we can store X in a data structure of size S(X) such that given a query R, we can find the data element in R with the maximum weight in Q(X) time, with high probability. Proof. Let x1,··· , xn be the list of input elements in X sorted by their weight function w0. We then assign the element xi a new weight w(xi) = nci, for a large enough constant c, and XX:4 Independent Range Sampling, Revisited Again store them in the data structure for the range sampling problem. This takes S(X) space. Given a query R for the range maximum problem, we sample one element xi from the range R. We have w(xi) = nci and the total weight of all the other points in R can be at most n · nc(i−1), i.e., we find the element with the maximum weight with high probability. (cid:74) Next, we show that weighted range sampling can be obtained from a combination of a range maximum data structure and a particular form of weighted range sampling data structure for almost uniform weights. (cid:73) Lemma 3. Let (X, R) be an input to the range sampling problem. Assume, we have a structure for the range maximum queries that uses O(Sm(X)) space and with query time of O(Qm(X)). Furthermore, assume for any subset X0 ⊂ X we can build a structure Ds(X0) that uses O(Ss(X0)) space and given a query R ∈ R, it does the following: it can return w(Y ) for a subset Y ⊂ X0 with the property that R ∩ X0 ⊂ Y , and Y = O(R ∩ X0) and furthermore, the structure can extract k random samples from Y in O(Qs(X) + k) time. Then, we can answer range sampling queries using O(Sm(X) + Ss(X)) space and with expected query time of O(Qm(X) + Qs(X) log X + k). Proof. Let n = X. We store X in a data structure for the range maximum queries. We partition X into subsets Xi ⊂ X in the following way. We place the element x1 with the largest weight in X1 and then we add to X1 any element whose weight is at least w(x1)/2 and then recurse on the remaining elements. Observe that for all x, x0 ∈ Xi we have w(x)/w(x0) ∈ (1/2, 2]. Thus, the weight function w is almost uniform on each Xi. We store Xi in a data structure Ds(Xi). union of all subsets Xi0 with i0 ≥ i, that is, W(Xi) =P Next, we build a subset sum information over the total weight W(Xi) of the (disjoint) j≥i w(Xj). Consider a query R ∈ R. Step 1: Use the Range Maximum Structure. the query range R ∈ R. Let x be the answer to the range-max query, assume x ∈ Xi. Issue a single range-max query on X for Step 2: top-level alias structure. Having found i, we identify the smallest index i0 ≥ i such that the maximum weight w(x0) for x0 ∈ Xi0 and the minimum weight w(x) for x ∈ Xi satisfy w(x)/w(x0) > n2. As the weights in the sets Xi decreases geometrically, we have i0 − i = O(log n). Then, for each Xj with j ∈ [i, i0), we use the data structure Ds(Xj) to identify the set Yj such that Yj contains the set R ∩ Xj. This returns the values w(Yj), and the total running time of this step is O(Qs(n) log n). We build a top-level alias structure on i0 − i + 1 values: all the i0 − i values w(Yj), j=i w(Yj). This can be done i ≤ j < i0, as well as the value W(Xi0). Let T = W(Xi0) +Pi0−1 in O(log n) time as i0 − i = O(log n). Step 3: Extracting samples. To generate k random samples from R, we first sample a value using the top-level alias structure. This can result in two different cases: It returns the value W(Xi0). Let Xi0+ = ∪j≥i0Xj. In this case, we sample an Case 1. element from the set R ∩ Xi0+, by building an alias structure on Xi+ in O(n) time. The probability of sampling an element xj ∈ Xi0+ is set exactly to w(xj) W (Xi0 ). Note that these probabilities of xj ∈ Xi0+ ∩ R do not add up to one which means the sampling might fail and we might not return any element. If this happens, we go back to the top-level alias structure and try again. Notice that R contains at least one element xi from Xi, and that for any Afshani & Phillips XX:5 x ∈ Xj, j ≥ i0 have w(x) ≤ w(xi)/n2 which implies W(Xi0) ≤ w(xi)/n. Thus, this case can happen with probability at most 1/n, meaning, even if we spend O(n) time to answer the query, the expected query time is O(1). It returns a value w(Yj), for i ≤ j < i0. We place Yj into a list for now. At some Case 2. later point (to be described) we will extract a sample z from Yi. If z happens to be inside R, then we return z, otherwise, the sampling fails and we go back to the top-level structure. We iterate until k queries have been pooled. Then, we issue them in O(log n) batches to data structure Ds(Xj), i ≤ j < i0. Ignoring the failure events in case (2), processing a batch of k queries will take O(Qs(n) log n + k) time. Notice that each iteration of the above procedure will succeed with a constant probability: case (1) is very unlikely (happens with probability less than 1/n) and for case (2) observe that we have w(Yi) = O(w(R ∩ Xi)) and thus each query will succeed with constant probability. As a result, in expectation we only issue a constant number of batches of size k to extract k random samples. It remains to show that we sample each element with the correct probability. The probability of reaching case (1) is equal to W (Xi0 ) . Thus, the probability of sampling an element xj ∈ Xi0+ is equal to W (Xi0 ) . The same holds in case (2) and the probability of sampling an element xj ∈ Xj, i ≤ j < i0 is w(xj) . Thus, conditioned on the event that the sampling succeeds, each element is sampled with the correct probability. (cid:74) · w(xj) W (Xi0 ) = w(xj) T T T T 3D Halfspace Sampling 3 3.1 Preliminaries In this section, we consider random sampling queries for 3D halfspaces. But we first need to review some preliminaries. (cid:73) Lemma 4. Let P be a set of n points in R3. Let P = P1 ∪ ··· ∪ Pt be a partition of P into t subsets. We can store P in a data structure of size O(n log t) such that given a query halfspace h, we can find the smallest index i such that Pi ∩ h 6= ∅ in O(log n log t) time. Proof. We consider the dual problem where Hi is the set of hyperplanes dual to Pi and the goal is to store them in a data structure such that given a query point q, we can find the smallest index i such that there exists a halfspace of Hi that passes below q. Let H' = H1 ∪ ··· ∪ Ht/2 and Hr = Ht/2+1 ∪ ··· Ht. We compute the lower envelope of H', and store its projection in a point location data structure and then recurse on H' and Hr. The depth of the recursion is O(log t) and each level of the recursion consumes O(n) space and thus the total storage is O(n log t). Given a query q, we have two cases: if a halfspace of H' passes below q, then the answer is obviously in H' so we recurse there; otherwise, no halfspace of H' passes below q and thus, we can recurse on Hr. This decision can be easily made using the point location data (cid:74) structure. The total query time is O(log t log n). The following folklore result is a special case of the above lemma. (cid:73) Corollary 5. Let P be a set of n points in R3 where each point p ∈ P is assigned a real-valued weight w(p). We can store P in a data structure of size O(n log n) such that given a query halfspace h, we can find the point with maximum weight in O(log2 n) time. We also need the following preliminaries. Given a set H of n hyperplanes in R3, the level of a point p is the number hyperplanes that pass below p. The (≤ k)-level of H (resp. XX:6 Independent Range Sampling, Revisited Again k-level of H) is the closure of the subset of R3 containing points with level at most k (resp. exactly k). An approximate k-level of H is a surface composed of triangles (possibly infinite triangles) that lies above k-level of H but below (ck)-level of H for a fixed constant c. For a point q ∈ R3, we define the conflict list of q with respect to H as the subset of hyperplanes in H that pass below q and we denote this with ∆(H, q). Similarly, for a triangle τ with vertices v1, v2, and v3, we define ∆(H, τ) = ∆(H, v1)∪ ∆(H, v2)∪ ∆(H, v3). One of the main tools that we will use is the existence of small approximate levels. This follows from the existence of shallow cuttings together with some geometric observations. (cid:73) Lemma 6. For any set H of n hyperplanes in R3, and any parameter 1 ≤ k ≤ n/2, there exists an approximate k-level which is a convex surface consisting of O(n/k) triangles. Furthermore, we can construct a hierarchy of approximate ki-levels Li, for ki = 2i and i = 0,··· , log n, together with the list ∆(H, τ) for every triangle τ ∈ Li in O(n log n) time and O(n) space. Given a query point q, we can find an index i in O(log n) time such that there exists a triangle τ ∈ Li that lies above q such that ∆(H, q) = O(∆(H, τ)). Proof. Shallow cuttings were first introduced by Matoušek [15] and later Chan [5] observed that we can work with the triangulation of the convex hull of Matoušek's construction. As a result, shallow cuttings could be represented as convex surfaces formed by triangles. Ramos [14] offered a randomized O(n log n) time construction algorithm that could build a hierarchy of shallow cuttings in O(n log n) time possibly together with the conflict lists (i.e., ∆(H, τ) for any triangle). This was recently made deterministic [6]. Regarding the query part, it is known that we can store H in a data structure of size O(n) such that given a query point q, we can find a constant factor approximation k such that ∆(H, q) ≤ k = O(∆(H, q)) in O(log n) worst-case time [1]. We can then set i = log(k) + O(1) and note that his method also finds τ. (cid:74) We will also use the following results. (cid:73) Theorem 7 (The Partition Theorem). [11] Given a set P of n points in 3D and an integer 0 < r ≤ n/2, there exists a partition of P into r subsets P1,··· , Pr, each of size Θ(n/r), where each Pi is enclosed by a tetrahedron Ti, s.t., any hyperplane crosses O(r2/3) tetrahedra. (cid:73) Lemma 8. Let T be tree of size n where each leaf v stores a real-valued non-negative weight w(v). We can build a data structure s.t., given an internal node u ∈ T at the query time, we can independently sample a leaf with probability proportional to its weight in the subtree of u. The data structure uses O(n) space and it can answer queries in O(1) worst-case time. Proof. Let A be an array of the leafs obtained using the DFS ordering of the leafs. Observe that for any internal node u, the leafs in the subtree of u correspond to a contiguous interval of A. Thus, the problem reduces to one-dimensional range sampling queries. Afshani and Wei [2] showed that these queries can be solved in O(1) time plus the time it takes to answer predecessor queries. In our problem, since there are only n different possible queries (one for each internal node), we can simply store a pointer from each internal node u to the location (cid:74) of its predecessor in array A. Afshani and Wei [2] consider unweighted sampling for 3D halfspace queries. We next use the following technical result of theirs. (cid:73) Lemma 9. Let H be a set of n hyperplanes in 3D. Let f(n) = (log n)c log log n where c is a large enough constant. We can build a tree Tglobal with n leafs where each hyperplane is Afshani & Phillips XX:7 stored in one leaf such that the following holds: Given a point q ∈ R3 with level k where k ≥ f(n), we can find k0 = O(k/ log2 n) internal nodes u1,··· , uk0 in Tglobal such that ∆(H, q) = Tglobal(u1) ∪ ··· ∪ Tglobal(uk0) where Tglobal(ui) is the set of hyperplanes stored in the subtree of ui. Unfortunately, the above lemma is not stated explicitly by Afshani and Wei, however, Tglobal is the "Global Structure" that is described in [2] under the same notation. 3.2 A Solution with Expected Query Time We now observe that we can use Lemma 3 to give a data structure for weighted halfspace range sampling queries in 3D. We first note that using Corollary 5 and by building a hierarchy of shallow cuttings, i.e., building approximate ki-levels for ki = 2i, i = 0,··· , log n, we can get a data structure with O(n log n) space that can answer queries in O(log2 n + k) query time. Furthermore, as Lemma 2 shows, our problem is at least as hard as the halfspace range maximum problem which currently has no better solution than O(n log n) space and O(log2 n) expected query time. Thus, it seems we cannot do better unless we can do better for range maximum queries, a problem that seems very difficult. Wi =P However, the reduction given by Lemma 2 is not completely satisfying since we need to create a set of weights that are exponentially distributed. As a result, it does not capture a more "natural" setting where the ratio between the largest and the smallest weight is bounded by a parameter U that is polynomial in n. Our improved solution is the following which shows when U = nO(1) we can in fact reduce the space to linear. (cid:73) Theorem 10. Let P be a set of n weighted points in R3, where the smallest weight is 1 and the largest weight is U. We can store P in a data structure of size O(n min{log n, log logn U}) such that given a query halfspace and an integer k, we can extract k independent random samples from the points inside h in O(log2 n + k) time. Proof summary. Let X be the set of hyperplanes dual to P. We partition X into sets X1, . . . , Xt where the weights of the elements in Xi are larger than those of Xi+1 and for two hyperplanes h, h0 ∈ Xi we have w(h)/w(h0) ∈ [1/n2, n2]. Clearly, we have t ≤ min{n, logn U}. Given a query point q, we can find the smallest index i such that a hyperplane of Hi passes below q, in O(log t log n) = O(log2 n) time using Lemma 4. Also, by building a prefix sum, j≥i w(Xj), we can essentially focus on sampling from Xi, similar to Lemma 3. With a slight abuse of the notation, let us rename Xi as X. Let m = X. We build a hierarchy of approximate levels by Lemma 6. We use Lemma 9. Consider a triangle τ ∈ Li with vertices v1, v2, and v3 where the level of each vertex is at most O(ki). By the lemma, if ki ≥ f(m), then we can find a representation of ∆(X, v1), ∆(X, v2), and ∆(X, v3), each using O(ki/ log2 m) internal nodes. Since ∆(X, τ) = ∆(X, v1) ∪ ∆(X, v2) ∪ ∆(X, v3), we can also represent ∆(X, τ) using O(ki/ log2 m) internal nodes of Tglobal. At τ we store an alias data structure on the weights of the subtrees of Tglobal that represent ∆(X, τ). This requires O(ki/ log2 m) space. Observe that at the query time, we can proportionally sample one of these subtrees and then using Lemma 8 we can sample an element from the subtree. Thus, we can extract one random sample from ∆(X, τ) in O(1) worst-case time using only O(∆(X, τ)/ log2 m) space. The total size of the lists ∆(X, τ) for all τ ∈ Li and all i is O(m log m), meaning, this in total will consume O(m) space. By Lemma 6, we can identify an index i s.t., q lies below a triangle τ ∈ Li with ∆(H, τ) = O(∆(H, q)). It is clear that we can now sample from ∆(H, τ) using tree Tglobal. XX:8 Independent Range Sampling, Revisited Again This satisfies all the conditions in Lemma 3 as we can sample from ∆(H, τ) in O(1) time, after an initial O(log n) search time. If ki < f(m), we can repeat a classical idea that was also used by Afshani and Wei and that is build an approximate f(m)-level L and for each triangle τ ∈ L, we can repeat the above solution just one more time. We will be able to handle the indices i such that ki ≥ f(c(f m)) = o(log m) = o(log n). However, if ∆(H, q) = o(log n), then we can simply find all the hyperplanes passing below q in O(log n) time and build an alias data structure (cid:74) on them. 3.3 Worst-Case Time with Approximate Weights All of the previous data structures sample items exactly proportional to their weight, but rely on rejection sampling. Hence, their query time is expected, and not worst case. With small probability these structures may repeatedly sample items which are not in h, and then need to reset and try again with no bound on the worst-case time. To achieve worst-case query time, we need some modifications. We allow for items to be sampled "almost" proportional to their weights, i.e., we introduce a notion of approximation. As we shall see in the next chapter, without some kind of approximation, our task is very likely impossible. value k and we would like to extract k random samples from X ∩ h. Let w(h) =P Problem definition. We consider an input set X of n points where xi has weight wi and we would like to store X in a data structure. At the query time, we are given a halfspace h and a xi∈X∩h wi, and set two parameters 0 < γ < ε < 1. Ideally, we would like to sample each xi with probability wi/w(h). Instead we sample xi with probability ρi, if wi/w(h) ≥ γ/n then (1 − ε) wi w(h) ≤ ρi ≤ (1 + ε) wi w(h) , (1) and if wi/w(h) < γ/n then we must have ρi ≤ (1 + ε) wi w(h). That is, we sample all items within a (1 ± ε) factor of their desired probability, except for items with very small weight, which could be ignored and not sampled. The smaller items are such that the sum of their desired probabilities is at most γ. Overview of modifications. We start in the same framework as Section 3.2 and Lemma 3, i.e., we partition X into subsets X' by weight. Then, we need to make the following modifications: (1) We can now ignore small enough weights; (2) We can no longer use rejection sampling to probe into each set X', rather we need to collect a bounded number (a function f(ε)) of candidates from all X' which is guaranteed to contain some point in the query h. (3) We can also no longer use rejection sampling within each X' to get candidates, instead we build a stratified sample via the partition theorem. Change (1) is trivial to implement. Remember that given query h, we first identify indices i and i0 such that Xi contains the largest weight in h and the weights in Xi0 are a factor n2 smaller. We now require weights in Xi0 to be a factor n/γ smaller, and let i0 = i + t where t = O(log(n/γ)). We can now ignore all the remaining sets: the sets Xj with j ≥ i + t will have weights so small that even if there are Ω(n) points within, the sum of their weights will be at most γ times the largest weight. Since γ < ε, this implicitly increases all of the other weights in each X' (for ' ∈ [i, i + t)) by at most a factor (1 + ε). We next describe how we can build a data structure on each X' to generate f(1/ε) candidate points. Once we have these t · f(1/ε) points, we can build two alias structures on them (they will come with weights proportional to the probability they should be selected), Afshani & Phillips XX:9 and select points until we find one in h. As a first pass, to generate k samples, we can repeat this k times, or bring kf(1/ε) samples from each X'. We will return to this subproblem to improve the dependence on k and ε by short-circuiting a low-probability event and reloading these points dynamically. 3.3.1 Generating Candidate Points Here we will focus on sampling our set of candidates. We will do this for every set X', i ≤ ' < i0. However, to simplify the presentation, we will assume that the input is a set X of n points such that the weights of the points in X are within factor 2 of each other. We will sample f(1/ε) candidate points from X (representing a subset X') s.t., the set of candidates intersects with the query halfspace h. Each candidate will be sampled with a probability that is almost uniform, i.e., it fits within our framework captured by Eq. 1. Let H be the set of hyperplanes dual to points in X. We maintain a hierarchical shallow- cutting of approximate levels (Lemma 6) on H. By Lemma 6, we get the following in the primal setting (on X), given a query halfspace h: We can build O(X) subsets of X where the subsets have in total O(X log X) points. Given a query halfspace h, in O(log n) time, we can find a subset X0 so that X ∩ h ⊂ X0 and X0 = O(X ∩ h). We now augment this structure with the following information on each such subset X0, without increasing the space complexity. We maintain an r-partition (Z1, ∆1), (Z2, ∆2), . . . (Zr0, ∆r0) on X0. (That is, so r0 = Θ(r), each subset Zj ⊂ ∆j and has size bound X0/r ≤ Zj ≤ 2X0/r, and the boundary of any halfspace h intersects at most O(r2/3) cells ∆j.) For each Zj we maintain an alias structure so in O(1) time we can generate a random sj from the points w(x). In O(r) time we can generate a weighted set S = {s1, s2, . . . , sr0}; this will be the candidate set. to approximately sample each x ∈ X0 ∩ h with probability w(x)/w(h). (cid:73) Lemma 11. Let r = Ω(1/ε3) and consider a candidate set S, and sample one point proportional to their weights. For a point x ∈ X0 ∩ h, the probability ρx that it is selected satisfies within. It is given a weight Wj =P The sum of all weights of points within h is w(h) =P x∈X∩h w(x), and so we would like x∈Zj (1 − ε) w(x) w(h) ≤ ρx ≤ (1 + ε) w(x) w(h) . w(h). Indeed it is the representative of Sj with probability w(x) be between these two cases. Let Win =P Proof. Of the r0 cells in S, classify them in sets as inside if ∆j ∈ h, as outside if ∆j ∩ h = ∅, and as straddling otherwise. We can ignore the outside sets. There are O(r) inside sets, and O(r2/3) straddling sets. For point x ∈ Sj from an inside set, it ideally should be selected with probability · Wj w(h) = w(x) w(x) and is give weight Wj proportional to Wj in the alias structure. We now examine two cases, that all representative points in the straddling sets are in h, and that none are; the probability x is selected will be between the probability of these two cases, and the desired probability it is selected will also Sj is straddling Wj. The Win ]. probability x is selected if it is the representative of Sj is then in the range [ Wj Win+Wstr , Wj The ratio of these probabilities is Wj Θ(r) = 1 + O(r1/3). Setting r = Ω(1/ε3) ensures that these probabilities are within a (1 + ε)-factor of each other, and on all points from an inside set, are chosen with approximately the correct probability. and . As with For a point x in a straddling set Sj, it should be selected with probability w(x) Sj is inside Wj and Wstr =P is selected with probability between Lx = w(x) Wj Win+Wstr and Ux = w(x) Wj Win · Win+Wstr Wj = 1 + O(r2/3) = Win+Wstr Win Wj Wj Wj Wj Win+Wj XX:10 Independent Range Sampling, Revisited Again points from an inside set, these are within a (1 + ε)-factor of each other if r = Ω(1/ε3). And w(h) ≤ Ux, and the desired probability of indeed since Win ≤ w(h) ≤ Win + Wstr then Lx ≤ w(x) (cid:74) sampling straddling point x is in that range. 3.3.2 Constructing the k Samples To select k random samples, the simplest way is to run this procedure k times sequentially, generating O(k/ε3) candidate points; this is on top of O(log n) to identify the proper subset X0 from the shallow cutting, applied to all t = O(log(n/γ)) weight partitions X'. We can do better by first generating O(1/ε3) candidate points per X', enough for a single random point in h. Now we place these candidates in two separate alias structures along with the candidate points from the other t structures. There are O(t/ε3) candidate points placed in an inside alias structure, and O(t/ε2) points placed in a straddling alias structure. Now to generate one point, we flip a coin proportional to the total weights in the two structures. If we go to the inside structure, we always draw a point in h, we are done. If we go to the straddling structure, we may or may not select a point in h. If we do, we are done; if not we flip another coin to decide to go to one of the two structures, and repeat. It is easy to see this samples points with the correct probability, but it does not yet have a worst case time. We could use a dynamic aliasing structure [8] on the straddling set, so we sample those without replacement, and update the coin weight. However, this adds a O(log( 1 ε log(n/γ))) factor to each of O(t/ε2) steps which might be needed. A better solution is to only allow the coin to direct the sampler to the straddling sets at most once; if it goes there and fails, then it automatically redirects to the alias structure on the inside sets which must succeed. This distorts the sampling probabilities, but not by too much since in the rejection sampling scheme, the probability of going to the straddling set even once is O(ε). (cid:73) Lemma 12. For any candidate point s let ρs be the probability it should be sampled, and ρ0 the probability it is sampled with the one-shot deterministic scheme. Then ρs ≤ ρ0 s ≤ (1+ ε)ρs s ≤ ρs if s is from a straddling set. if s is an inside point and (1 − ε)ρs ≤ ρ0 Proof. The probability that the coin directs to the inside set is πin = Win 1+Wstr/Win = 1+Ω(ε) = 1 − O(ε). Let wstr be the probability of selecting a point inside h, given that the coin has directed to the straddling set; we only need that Wstr ∈ [0, 1]. For a candidate point in the inside set s, the probability it is selected in the rejection Win (πin + Win (1 − O(ε)), and in the deterministic scheme is ρ0 sampling scheme is ρs = w(s) (1 − πin)(1 − wstr)) which is in the range [ρs, w(s) s = w(s) Win ], and these have a ratio 1 + O(ε). Similarly, for a candidate point in the straddling set s, the probability it is selected in Win+Wstr = 1 1 s the rejection sampling scheme is (1 − πin)(1 + O(ε)) ρs = w(s) Wstr (1 − πin)(1 + Wstr(1 − πin)(1 + . . .)) = w(s) Wstr Wstr (1−πin). Thus ρ0 s = w(s) s is in the range [ρs(1−O(ε)), ρs]. and in the deterministic scheme is ρ0 Adjusting the constant coefficients in ε elsewhere in the algorithm completes the proof. (cid:74) Now to generate the next independent point (which we need k of), we do not need to re-query with h or rebuild the alias structures. In particular, each candidate point can have a pointer back to the alias structure within its partition cell, so it can replace its representative candidate point. Moreover, since the points have weight proportional to their cell in the partition Wj, these weights do not change on a replacement. And more importantly, the points we never inspected to see if they belong to h do not need to be replaced. This Afshani & Phillips XX:11 deterministic process only inspects at most 2 points, and these can be replaced in O(1) time. Hence extending to k samples, only increases the total runtime by an additive term O(k). Final bound. We now have the ingredients for our final bound. In general the argument follows that of Lemma 3 except for a few changes. First, we allow items with probability total less than γn to be ignored. This replaces a log n factor in query time to be replaced with t = log(n/γ) term. Second, we require O(t log n) time to identify the relevant subset X0 in each of t shallow-cutting structures. Then we select O(1/ε3) candidate points from each of t weight partitions, in O(t/ε3) time. Then pulling k independent samples, and refilling the candidates takes O(k) time. This results in the following final bound: (cid:73) Theorem 13. Let X be a set of n weighted points in R3, where the smallest weight is 1 and the largest weight is U. Choose 0 < γ < ε ≤ 1/2. We can store X in a data structure of size O(n min{log n, log logn U}) such that for any integer k, we can extract k independent random samples from the points (ε, γ)-approximately proportional to their weights in worst case time O(log(n/γ)(log n + 1/ε3) + k) In particular, if ε, γ = Ω(1), then the worst case time is O(log2 n + k) matching the expected time algorithm to sample by the exact weights. 4 Lower Bound for Worst-Case Time with Exact Weights In this section, we focus on proving a (conditional) lower bound for a data structure that can extract one random sample in Q(n) worst-case time using S(n) space. Our main result is that under a reasonably restricted model, the data structure must essentially solve an equivalent range searching problem in the "group model". As a result, we get a conditional lower bound as this latter problem is conjectured to be difficult. As an example, our conditional lower bound suggests that halfspace range sampling queries would require that S(n)Q3(n) = Ω(n3), i.e., with near-linear space we can only expect to get close to O(n2/3) query time. This is in contrast to the case when we allow expected query time or approximate weights. As already shown, we can solve the same problem with O(n log n) space and O(log2 n) query time which reveals a large polynomial gap between the expected and the worst-case variants of the problem. To our knowledge, this is the first time such a large gap appears in the range searching literature between the worst-case and expected query times. The Model of Computation. We assume the input is a list X of n elements, x1,··· , xn, where each element xi is associated with a real-valued weight w(xi). We use the decision tree model of computation. We assume the data structure has three components: a preprocessing algorithm that builds the data structure, a data structure which is a set of S(n) stored real values, and finally a query algorithm that given a query q it returns an element sampled with the correct probability in Q(n) worst-case time. We allow no approximation: the query algorithm should return an element x with exactly w(x)/w(X) probability. The main bottleneck. The challenge in obtaining our lower bound was understanding where the main computational bottleneck lied and formulating a plan of attack to exploit it. This turned out to be in the query algorithm. As a result, we place no restrictions on the storage, or the preprocessing part of the algorithm, an idea that initially sounds very counter intuitive. After giving the algorithm the input X together with the weight assignment w: X → R, the algorithm stores some S(n) values in its storage. Afterwards, we XX:12 Independent Range Sampling, Revisited Again move to the query phase and this is where we would like to put reasonable limits. We give the query algorithm the query q. We allow the query algorithm access to a set of t real random numbers, R = {r1,··· , rt}, generated uniformly in [0, 1]. We restrict the query algorithm to be a "binary decision tree" T but in a specialized format: each node v of T involves a comparison between some random number rv ∈ R and a rational function fv = gv/Gv where gv and Gv are n-variate polynomials of the input weights w1,··· , wn. To be more precise, we assume the query algorithm can compute polynomials gv and Gv (either using polynomials stored at the ancestors of v or using the values stored by the data structure). The query algorithm at node v computes the ratio gv and Gv and compares it to the random value rv ∈ {r1,··· , rt}. If v is an internal node, then v will have two children u1 and u2 and the algorithm will proceed to u1 if fv(w(x1),··· , w(xn)) < rv and to u2 if otherwise. If v is a leaf node, then v will return (a fixed) element xv ∈ X. Note that there is no restriction on the rational function fv; it could be of an arbitrary size or complexity. We call this the separated Algebraic decision tree (SAD) model since at each node, we have "separated" the random numbers from the rational function that involves the weights of the input elements; a more general model would be to allow a rational function of the weights wi and the random numbers rj. If we insist the polynomials gv and Gv be linear (i.e., degree one), then we call the model separated linear decision tree model (SLD). (cid:73) Theorem 14. Consider an algorithm for range sampling in the SAD model where the input is a list of n of elements, x1,··· , xn together with a weight assignment w(xi) ∈ R, for each xi. Assume that the query algorithm has a worst-case bound, i.e., the maximum depth of its decision tree T is bounded by a function d(n). Then, for every query q, there exists a node v ∈ T such that Gv is divisible by the polynomialP p∈q w(p). Proof. Consider the query decision tree T. By our assumptions, T is a finite tree that involves some N(n) nodes and it has the maximum depth of d(n). Each node v involves a comparison between some random number ri and a rational function fv(w(x1),··· , w(xt)). To reduce clutter, we will simply write the rational function as fv. Let P be the set of all the rational functions stored at the nodes of T. Note that each unique rational function appears only once in P. Consider the set ∆P = {f1 − f2f1, f2 ∈ P} which is the set of pairwise differences. As each unique rational function appears only once in P, it follows that none of the rational functions in ∆P is identical to zero. This in particular implies that we can find real values w1,··· , wn such that none of the rational functions in ∆P are zero on w1,··· , wn. Thus, as these functions are continuous at the points (w1,··· , wn), it follows that we can find a real value ε > 0 such that for every weight assignment w(xi) ∈ [wi, wi + ε], the rational functions in ∆P have the same (none zero) sign. In the rest of the proof, we only focus on the weight assignment functions w with the property that w(xi) ∈ [wi, wi + ε]. Let U be the unit cube in Rt. U denotes the total probability space that corresponds to the random variables r1,··· , rt. Every point in U corresponds to a possible value for the random variables r1,··· , rt. Now consider one rational function fv stored at a node v of T, and assume v involves a comparison between ri and fv and let u1 and u2 be the left and the right child of v. By our assumption, we follow the path to u1 if fv ≤ ri but to u2 if otherwise. Observe that this is equivalent to partitioning U into two regions by a hyperplane perpendicular to the i-th axis at point fv. As a result, for every node v ∈ T, we can assign a rectangular subset of U that denotes its region and it includes all the points (r1,··· , rt) of U such that we would reach node v if our random variables were sampled to be (r1,··· , rt). The next observation is that we can assume the region of each node is defined by fixed rational functions. Consider the list of rational functions encountered on the path from v to the root of T. Assume among this list, the rational functions f1,··· , fm are involved in Afshani & Phillips XX:13 comparisons with ri. Clearly, the lower boundary of the region of v along the i-th dimension is min{f1,··· , fm} whereas its upper boundary is max{f1,··· , fm}. Now, observe that since we have assumed that each fi − fj has a fixed sign, it follows that these evaluate to a fixed rational function. Thus, let fi,v (resp. Fi,v) be the rational function that describes the lower (resp. upper) boundary of the region of v along the i-th dimension. Let fi,v = ai,v/bi,v and Fi,v = Ai,v/Bi,v where ai,v, bi,v, Ai,v, Bi,v are some polynomials of w(x1),··· , w(xn) stored in tree T (e.g., bi,v is equal to some Gu for some ancestor u of v and the same holds for Bi,v). The Lebesgue measure of the region of v, Vol(v), is thus defined by the rational function tY Ai,vbi,v − ai,vBi,v . i=1 Bi,vbi,v tY tY Vol(v) = (Fi,v − fi,v) = i=1 i=1 ( Ai,v Bi,v − ai,v bi,v ) = Vol(v) is the probability of reaching v. Consider a query q that contains k elements. W.l.o.g, let x1,··· , xk be these k elements. Let v1,··· , v' be the set of all the leaf nodes that return x1. For x1 to have been sampled with correct probability we must have the following identity 'X i=1 Vol(vi) = w(x1) w(x1) + ··· + w(xk) . Observe that since the polynomial w(x1) + ··· + w(xk) is irreducible, it follows that at least (cid:74) one of the polynomials bi or Bi for some i has this polynomial as a factor. of the points in the query range -- since the total weight P Conditional Lower Bound. Intuitively, our above theorem suggests that if we can perform range sampling in finite worst-case time, then we should also be able to find the total weight p∈q w(p) is encoded in some rational function. This latter problem is conjectured to be difficult but obtaining provable good lower bounds remains elusive. This suggests that short of a breakthrough, we can only hope for a conditional lower bound. This is reinforced by this observation that an efficient data structure for range sum queries leads to an efficient data structure for range sampling. (cid:66) Observation 1. Assume for any set of X of n elements each associated with a real-valued weight, we can build a data structure that uses S(n) space such that given a query range q, it can output the total weight of the elements in q in Q(n) time. Then, we can extract k random samples from q by a data structure that uses O(S(n) log n) space and has the query time of O(kQ(n) log n). Proof. Partition X into two equal-sized sets X1 and X2 and build the data structure for range sum on each. Then recurse on X1 and X2. The total space complexity is O(S(n) log n). Given a query q, it suffices to show how to extract one sample. Using the range sum query q x∈q∩X2 w(x). Thus, we can recurse into X1 with probability w1/(w1 + w2) and into X2 with w2/(w1 + w2). (cid:74) In O(log n) recursion steps we find a random sample with query time O(Q(n) log n). on X1 and X2, we can know the exact value of w1 =P x∈q∩X1 w(x) and w2 =P This implies that in the SLD model, the range sampling problem in the worst-case is equivalent to the range sum problem, ignoring polylog factors. This has consequences for query ranges like halfspaces where the latter problem is conjectured to be hard. (cid:66) Conjecture 1. For every integer n, there exists a set P of Θ(n) points in Rd with the following property: If for any function w: P → R given as input, we can build a data structure p∈P∩h w(p) in of size S(n) such that for any query halfspace h, it can return the valueP Q(n) time, then, we must have S(n)Qd(n) = Ω(nd−o(1)). XX:14 Independent Range Sampling, Revisited Again (cid:73) Corollary 15. Assume Conjecture 1 holds for d = 3. Then, there exists an input set of n points in R3 such that for any data structure that uses S(n) space and solves the range sampling problem where the query algorithm is a decision tree T with worst-case query time Q(n), we must have S(n)Q3(n) = Ω(n3−o(1)). Thus if space S(n) is near-linear, query time Q(n) = Ω(n2/3−o(1)). References Peyman Afshani, Chris Hamilton, and Norbert Zeh. A general approach for cache-oblivious range reporting and approximate range counting. Computational Geometry: Theory and Applications, 43:700 -- 712, 2010. preliminary version at SoCG'09. Peyman Afshani and Zhewei Wei. Independent range sampling, revisited. In Proceedings of European Symposium on Algorithms (ESA), pages 3:1 -- 3:14, 2017. Pankaj K. Agarwal and Jeff Erickson. Geometric range searching and its relatives. Advances in Discrete and Computational Geometry, pages 1 -- 56, 1999. Sameer Agarwal, Barzan Mozafari, Aurojit Panda, Henry Milner, Samuel Madden, and Ion Stoica. Blinkdb: queries with bounded errors and bounded response times on very large data. In Proceedings of the 8th ACM European Conference on Computer Systems, pages 29 -- 42. ACM, 2013. 5 Timothy M. Chan. Random sampling, halfspace range reporting, and construction of (<= k)-levels in three dimensions. SIAM Journal of Computing, 30(2):561 -- 575, 2000. Timothy M Chan and Konstantinos Tsakalidas. Optimal deterministic algorithms for 2-d and 3-d shallow cuttings. In Symposium on Computational Geometry (SoCG), 2015. Surajit Chaudhuri, Rajeev Motwani, and Vivek Narasayya. Random sampling for histogram construction: How much is enough? In ACM SIGMOD Record, pages 436 -- 447. ACM, 1998. 8 T Hagerup, K Mehlhorn, and JI Munro. Optimal algorithms for generating discrete random variables with changing distributions. Lecture Notes in Computer Science, 700:253 -- 264, 1993. Joseph M. Hellerstein, Peter J. Haas, and Helen J. Wang. Online aggregation. ACM SIGMOD Record, 26(2):171 -- 182, 1997. 9 10 Xiaocheng Hu, Miao Qiao, and Yufei Tao. Independent range sampling. In Proceedings of 1 2 3 4 6 7 11 12 13 14 15 ACM Symposium on Principles of Database Systems (PODS), pages 246 -- 255. ACM, 2014. Jiří Matoušek. Efficient partition trees. Discrete & Computational Geometry, 8(3):315 -- 334, 1992. Frank Olken. Random sampling from databases. PhD thesis, University of California at Berkeley, 1993. Frank Olken and Doron Rotem. Random sampling from databases: a survey. Statistics and Computing, 5(1):25 -- 42, 1995. Edgar A. Ramos. On range reporting, ray shooting and k-level construction. In Symposium on Computational Geometry (SoCG), pages 390 -- 399, 1999. Jiří Matoušek. Reporting points in halfspaces. Computational Geometry, Theory and Applica- tions, 2(3):169 -- 186, 1992. 16 Alastair J. Walker. New fast method for generating discrete random numbers with arbitrary frequency distributions. Electronics Letters, 10(8):127 -- 128, 1974.
1207.0892
1
1207
2012-07-04T03:58:39
Incubators vs Zombies: Fault-Tolerant, Short, Thin and Lanky Spanners for Doubling Metrics
[ "cs.DS" ]
Recently Elkin and Solomon gave a construction of spanners for doubling metrics that has constant maximum degree, hop-diameter O(log n) and lightness O(log n) (i.e., weight O(log n)w(MST). This resolves a long standing conjecture proposed by Arya et al. in a seminal STOC 1995 paper. However, Elkin and Solomon's spanner construction is extremely complicated; we offer a simple alternative construction that is very intuitive and is based on the standard technique of net tree with cross edges. Indeed, our approach can be readily applied to our previous construction of k-fault tolerant spanners (ICALP 2012) to achieve k-fault tolerance, maximum degree O(k^2), hop-diameter O(log n) and lightness O(k^3 log n).
cs.DS
cs
Incubators vs Zombies: Fault-Tolerant, Short, Thin and Lanky Spanners for Doubling Metrics T-H. Hubert Chan Mingfei Li Li Ning ∗† Abstract Recently Elkin and Solomon gave a construction of spanners for doubling metrics that has constant maximum degree, hop-diameter O(log n) and lightness O(log n) (i.e., weight O(log n)·w(MST)). This resolves a long standing conjecture proposed by Arya et al. in a seminal STOC 1995 paper. However, Elkin and Solomon's spanner construction is extremely complicated; we offer a simple alternative construction that is very intuitive and is based on the standard technique of net tree with cross edges. Indeed, our approach can be readily applied to our previous construction of k-fault tolerant spanners (ICALP 2012) to achieve k-fault tolerance, maximum degree O(k2), hop-diameter O(log n) and lightness O(k3 log n). 2 1 0 2 l u J 4 ] S D . s c [ 1 v 2 9 8 0 . 7 0 2 1 : v i X r a ∗Department of Computer Science, The University of Hong Kong †{hubert, mfli, lning}@ cs.hku.hk 1 Introduction A finite metric space (X, d) with n = X can be represented by a complete graph G = (X, E), where the edge weight w(e) on an edge e = {x, y} is d(x, y). A t-spanner of X, is a weighted subgraph H = (X, E(cid:48)) of G that preserves all pairwise distance within a factor of t, i.e., dH (x, y) ≤ t · d(x, y) for all x, y ∈ X, where dH (x, y) denotes the shortest-path distance between x and y in H, and the factor t is called the stretch of H. A path between x and y in H with length at most t· d(x, y) is called a t-spanner path. Spanners have been studied extensively since the mid-eighties (see [2, 7, 1, 14, 12, 3, 5, 10] and the references therein; also refer to [13] for an excellent survey), and find applications in approximation algorithms, network topology design, distance oracles, distributed systems. Spanners are important structures, as they enable approximation of a metric space in a much more economical form. Depending on the application, there are parameters of the spanner other than stretch that can be optimized. The total weight of the edges should be at most some factor (known as lightness) times the weight of a minimum spanning tree (MST) of the metric space. It might also be desirable for the spanner to have small maximum degree (hence also having small number of edges), or small hop-diameter, i.e., every pair of points x and y should be connected by a t-spanner path with a small number of edges. Observe that for some metric spaces such as the uniform metric on n points, the only possible spanner with stretch 1.5 is the complete graph. Doubling metrics are special classes of metrics, but still have interesting properties. The doubling dimension of a metric space (X, d), denoted by dim(X) (or dim when the context is clear), is the smallest value ρ such that every ball in X can be covered by 2ρ balls of half the radius [11]. A metric space is called doubling, if its doubling dimension is bounded by some constant. Doubling dimension is a generalization of Euclidean dimension to arbitrary metric spaces, as the space RT equipped with (cid:96)p-norm has doubling dimension Θ(T ) [11]. Spanners for doubling metrics have been studied in [12, 3, 5, 10, 14]. Sometimes we want our spanner to be robust against node failures, meaning that even when some of the nodes in the spanner fail, the remaining part is still a t-spanner. Formally, given 1 ≤ k ≤ n − 2, a spanner H of X is called a k-vertex-fault-tolerant t-spanner ((k, t)-VFTS or simply k-VFTS if the stretch t is clear from context), if for any subset S ⊆ X with S ≤ k, H \ S is a t-spanner for X \ S. Our Contributions. Our main theorem subsumes the results of two recent works on spanners for doubling metrics: (1) our previous paper [4] on fault-tolerant spanners with constant maximum degree or small hop-diameter, (2) Elkin and Solomon's spanner construction [9] with constant maximum degree, O(log n) hop-diameter and O(log n) lightness. Theorem 1.1 (VFTS with O(1) Max Degree, O(log n) Hop-Diameter, O(log n) Lightness) Let (X, d) be a metric space with n points, and let 0 <  < 1 be a constant. Given 1 ≤ k ≤ n − 2, there exists a (k, 1 + )-VFTS with maximum degree −O(dim) · k2, hop-diameter O(log n), and lightness −O(dim) · k3 · log n. Research Background. We review the most relevant related work; the readers can refer to [4, 9] for more references. In a seminal STOC 1995 paper, Arya et al. [1] gave several constructions for Euclidean spanners that trade between the number of edges, maximum degree, hop-diameter and lightness. In particular, they showed that for any n points in low-dimensional Euclidean space, there exists a (1 + )- spanner with O(n) edges, constant maximum degree, hop-diameter O(log n) and lightness O(log2 n). Since then, it has been a long standing open problem whether there exists a Euclidean (1 + )-spanner 1 with lightness O(log n) and all other properties above; this is the best possible lightness because of a lower bound Ω(log n) result by Dinitz et al. [8]. Seventeen years later, Elkin and Solomon [9] recently answered this open problem in the affirmative, and showed a stronger result: their construction actually works for doubling metrics. Perhaps it might not come as a surprise that their construction is highly complicated. The construction starts with an Euler tour on an MST and partitions the tour into hierarchical blocks, with very sophisticated nomenclature systems to describe various kinds of counters and representatives for the blocks, in order to reassign parent-child relationship between the blocks for achieving a spanner with all the desirable properties. While we were trying to study the intricate rules of their construction1, we began to look for a simpler construction. We discovered that the standard net tree with cross edges framework (used in [3]) can be augmented with a few modifications to give a spanner construction with the same desirable properties. Since our fault-tolerant spanners [4] are also based on net trees, our techniques can be used for con- structing fault-tolerant spanners with similar maximum degree, hop-diameter and lightness guarantees as well. We believe that it is an important contribution to have a simple and intuitive construction, which can be readily understood and used by researchers in the community. For instance, it is not immediately clear how Elkin and Solomon's construction can be used to construct fault-tolerant spanners. As a way of paying tribute to their work [9], we borrow their terminology incubator and zombie (some of our zombies can also disappear !), although their meanings are totally different in this paper. Our Techniques. In order to illustrate our techniques, we now give the main ideas for constructing a spanner when all nodes are functioning. The formal treatment for fault-tolerance is given in the main body of the paper. We use the standard net tree with cross edges framework given in [3]: given a metric space (X, d), construct a hierarchical sequence {Ni} of nets with geometrically decreasing distance scales, and build a tree structure, where the root has only 1 point with distance scale around the maximum inter-point distance ∆, and each leaf corresponds to each point in X at distance scale around the minimum inter-point distance (assumed to be more than 1). At each level, cross edges are added between net points that are close to each other relative to their level distance scale. A basic spanner [3] consisting of the tree edges and the cross edges can be shown to have low stretch. The basic idea is that for any two points u and v, we can start at the corresponding leaf nodes and climb to an appropriate level depending on d(x, y) to net points u(cid:48) and v(cid:48) that are close to u and v respectively such that the cross edge {u(cid:48), v(cid:48)} is guaranteed to exist. We analyze each of the properties: maximum degree, hop-diameter and lightness, and describe how issues arise and can be resolved. Lightness. For doubling metrics, lightness comes almost for free (see details in Section 4). Since the sum of all edges with length at most ∆ n2 is at most ∆, which is at most the weight of an MST, the significant distance scales are those between ∆ n2 and ∆, and there are O(log n) of them. The standard analysis in [3] uses doubling dimension to argue that at each level, each net point only has constant number of neighbors at that level. Hence, one can conclude that the weight of edges from each significant distance scale is a constant times that of an MST, thereby giving O(log n) lightness. Maximum Degree. Using doubling dimension, it is shown in [3] that edges can be directed such that the out-degree of every node is constant. For each node v, the edges from its incoming neighbors are replaced by a constant degree single-sink spanner rooted at v. This idea is used in [3] and made explicit in [4]. By the low stretch property of the single-sink spanner, the weight will increase by only a constant factor. Although no non-trivial bounds on the hop-diameter of the single-sink spanners are 1Even to this date, we do not claim that we fully understand the construction in [9]. 2 given in [3, 4], an easy modification is described in Section 5 to achieve O(log n) hop-diameter. Since the out-degree of every node is constant, it can only participate in only a constant number of single-sink spanners. Therefore, after this single-sink transformation for every node, the maximum degree of the resulting spanner is constant. Hop-Diameter. If the metric space has large maximum distance ∆ with respect to the minimum inter- point distance, the number of levels in the net tree can be large. In particular, in the above mentioned spanner path between u and v, it can take many hops to go from u to u(cid:48) in the appropriate level. However, this can be easily fixed by adding shortcutting edges to subtrees at distance scales less than ∆ n2 via the 1-spanner construction for tree metrics by Solomon and Elkin [14] with O(log n) hop-diameter and O(log n) lightness; moreover, this 1-spanner construction only increases the maximum degree of the input tree by a constant. Since the edges from insignificant distance scales have total weight at most that of an MST, this will still give O(log n) lightness. There are only O(log n) significant distance scales and the tree edges from insignificant distance scales can be climbed using O(log n) hops. Hence, it might seem that we have O(log n) hop-diameter. However, observe that each tree edge might participate in a single-sink spanner and might be replaced by a path with Ω(log n) hops. Therefore, we can only bound the hop-diameter by O(log2 n). If we could stop tree edges from participating in single-sink spanners, then the hop-diameter would be O(log n). However, the issue is that a net tree is likely to have large degree, because of the hierarchical property of the nets. In particular, the root node is a net point at every level, and hence could have many tree edges connecting to it. Our key idea is simple: we keep the net tree structure, but replace each node with another representative (that is close by) such that the degree due to tree edges induced on the representatives is constant. To describe our ideas clearly, we use the terminology incubator for a node in the net tree and zombie for a representative. Incubators Working with Zombies. If a point x in X is a net point in several levels, we explicitly have a separate node known as an incubator for each level x is in. The net tree structure before becomes a tree on the incubators, and a former cross edge at some level becomes an incubator edge at the same level. If an internal incubator has only one child, we merge the two incubators together and the merged incubator inherits the corresponding edges; this merging is repeated until every internal incubator has at least two children. Observe that each incubator only has a constant number of tree edges incident to it. Each incubator has a representative known as a zombie, each of which is identified with a point in X. The graph structure on incubators naturally induces a spanner on X: if there is an edge between two incubators, then there is an induced edge between the corresponding zombies. The remaining issue is how we assign zombies to incubators; the following procedure turns out to be sufficient. "The zombies are climbing..." Each leaf incubator initially has two zombies, both having the same identity as the leaf. One zombie stays at the leaf and the other zombie climbs up the tree. The order of zombie climbing is arbitrary. If a zombie finds an empty incubator, it stays there, and otherwise continues to climb up; if the root incubator is reached and is already occupied, the zombie simply disappears. Sketch Analysis. After merging, each internal incubator has at least two children. Hence, there will be enough zombies such that each incubator will be occupied by a zombie that originates from one of its descendant leaves. We are essentially replacing each net point corresponding to an incubator with a point represented by the zombie that is close by with respect to the relevant distance scale. It can be shown that the stretch is still preserved. Moreover, observe that every point in X can only be the 3 identity of at most two zombies. Since the incubator tree has constant degree, it follows that the degree of a point due to induced tree edges is constant. Hence, we can let only the edges not induced by tree edges to participate in the single-sink spanner construction. This resolves the aforementioned issue of the net tree having high degree, and so O(log n) hop-diameter can be achieved. We apply the incubator-zombie technique to the fault-tolerant spanner construction in [4]. The rules for inducing edges on X are slightly more involved and are given in Section 3. Future Direction. Observe that for our k-fault tolerant spanner construction, the dependence on k for maximum degree is O(k2) and for lightness is O(k3), where the lower bounds are Ω(k) (trivial) and Ω(k2) (a simple example is given in [6]) respectively; it is interesting to see whether the dependence on k can be improved. Indeed, for low-dimensional Euclidean metrics, Czumaj and Zhou [6] constructed k-fault tolerant spanners with maximum degree O(k) and O(k2) lightness, but no guarantee on hop-diameter. For doubling metrics, another interesting open question is to construct spanners with constant lightness even when no nodes fail and with no restriction on degree or hop-diameter. 2 Preliminaries For any positive integer m, we denote [m] := {1, 2, . . . , m}. Throughout this paper, let (X, d) be a doubling metric with n points, 1 ≤ k ≤ n − 2 be an integer representing the number of failed nodes allowed, and let 0 <  < 1 2 be a constant and consider 1 +  stretch. Without loss of generality, we also assume that the minimum inter-point distance of X is greater than 1. We denote ∆ := maxx,y∈X d(x, y) as the diameter of X. Suppose r > 0. The ball of radius r centered at x is B(x, r) := {y ∈ X : d(x, y) ≤ r}. We say that a cluster C ⊆ X has radius at most r, if there exists x ∈ C such that C ⊆ B(x, r). Let r2 > r1 > 0. The ring of inner radius r1 and outer radius r2 centered at x is R(x, r1, r2) := B(x, r2) \ B(x, r1). A set Y ⊆ X is an r-cover of X if for any point x ∈ X there is a point y ∈ Y such that d(x, y) ≤ r. A set Y is an r-packing if for any pair of distinct points y, y(cid:48) ∈ Y , it holds that d(y, y(cid:48)) > r. We say that a set Y ⊆ X is an r-net for X if Y is both an r-cover of X and an r-packing. Note that if X is finite, an r-net can be constructed by a greedy algorithm. By recursively applying the definition of doubling dimension, we can get the following key proposition [11]. Proposition 2.1 (Nets Have Small Size [11]) Let R ≥ 2r > 0 and let Y ⊆ X be an r-packing contained in a ball of radius R. Then, Y ≤ ( R r )2dim. The minimum spanning tree of a finite metric space (X, d) is denoted by MST(X) (or simply MST if (X, d) is clear). Also, we use w(MST) to denote the weight of MST. Given a spanner H on (X, d), the lightness of H is defined by the ratio of the total weight of edges in H to the weight of MST. Fact 2.1 (Lower Bounds for MST) We have the following two lower bounds for w(MST). 1. The weight of MST is bounded from below by its diameter ∆. 2. Let S ⊆ X be an r-packing, with r ≤ ∆. Then, w(MST) ≥ 1 2 r · S. The fault-tolerant spanner construction in [4], which is the basis for our construction in this paper, relies on fault-tolerant hierarchical nets. We review their construction and some key properties of them. Fault-Tolerant Hierarchical Nets. We color each point in X with one of the colors in [k + 1], and let Xc be the set of points with color c. For each color c ∈ [k + 1], we build a sequence of hierarchical nets of (cid:96) := (cid:100)log2 ∆(cid:101) levels, Xc = N c i the set of all (cid:96) . We denote by Ni := ∪c∈[k+1]N c 0 ⊇ N c 1 ⊇ ··· ⊇ N c 4 level-i net points. Let ri := 2i be the distance scale of level i. Fault-tolerant hierarchical nets should satisfy the following properties: 1. Packing. For each 0 ≤ i ≤ (cid:96) and c ∈ [k + 1], N c 2. Covering. For any 1 ≤ i ≤ (cid:96), if x ∈ X is not a net point in Ni, then for each color c ∈ [k + 1], is an ri-packing; i there exists a net point yc ∈ N c i such that d(yc, x) ≤ ri. Initially, each N c Construction. The hierarchical nets can be constructed in a top-down approach. consists of a distinct point in X. Note that k ≤ n − 2 and hence the initialization is well defined. Also, (cid:96) the single point in N c (cid:96) is colored with c and points not included in any cluster N c (cid:96) stay uncolored. Suppose all nets on level i + 1 have been built and we construct the level-i nets as follows. For c from 1 to k + 1, let Uc be the set of uncolored points when we start to build N c i , i.e., after finishing the construction of N 1 i+1, and extend N c i+1 to get N c i by greedily i ∩ Uc adding points in Uc to N c with color c. := N c i is an ri-net for Uc; we color the points in N c . We initialize N c i i such that the resulting N c i , . . . , N c−1 i , N 2 i Note that the packing property and the covering property follow directly from the net construction. 3 Incubators Working with Zombies: Reducing Degree of Net Trees As mentioned in the introduction, the net-tree-with-cross-edges approach in [3] has the issue that the degree of a net tree can be high. The reason is that a high level net point (in particular the root) can participate in many levels in the net tree, causing high degree. The use of single-sink spanner can reduce the maximum degree, but at the cost of replacing a tree edge with a path consisting of Ω(log n) hops. In this section, we modify the net tree construction such that each point participates in a small number of levels. We borrow some terminology from [9] and define our own incubators and zombies to describe our construction, which is based on the fault-tolerant hierarchical nets defined in Section 2. Incubators. For each level i, and each x ∈ Ni, there is a corresponding incubator y = (x, i), where x is the identity of the incubator and i is its level. The color of an incubator is the same as its identity. Observe that the original metric induces a distance function on the incubators in a natural way: if y1 = (x1, i1) and y2 = (x2, i2), then d(y1, y2) = d(x1, x2). We also define distances between points in the original metric space and incubators: if y1 = (x1, i1) and x2 ∈ X, then d(y1, x2) = d(x1, x2). Incubator Graph. We define a graph H on incubators. An edge is local if it connects two incubators of the same color, and is foreign otherwise. Edges are added between incubators according to the following rules. i+1 is a closest point in N c 1. Tree edges. For each level 0 ≤ i < l, color c ∈ [k + 1], and x ∈ N c i , consider the incubator y = (x, i). Suppose xc ∈ N c i+1, then i+1, then d(x, xc) ≤ ri+1.) Then, we add a local tree edge between the incubators x = xc; if x /∈ N c y and yc = (xc, i + 1), and we call yc the local parent of y and y is a local child of yc. All the incubators of color c form an incubator tree Tc. Suppose x ∈ N c i+1 is a closest point in i+1 to x. (Note that d(x, xc(cid:48)) ≤ ri+1.) Then, we add a foreign tree edge between the incubators N c(cid:48) y = (x, i) and yc(cid:48) = (xc(cid:48), i + 1). Then, yc(cid:48) is a foreign parent of y and y is a foreign child of yc(cid:48). 2. Cross edges. For each level 0 ≤ i ≤ l, and all u (cid:54)= v ∈ Ni such that d(u, v) ≤ γ · ri, where i+1 to x. (Observe that if x ∈ N c i+1. Then, for each color c(cid:48) (cid:54)= c, suppose xc(cid:48) ∈ N c(cid:48) i \ N c γ := 34 + 272  as in [3, 4], we add a cross edge between the incubators (u, i) and (v, i). 3. Skeleton edges. The idea in [3, 4] to obtain a low-stretch path between two points is to use a similar net tree structure: for both points, start at their corresponding leaves and climb up the 5 tree to a certain level, at which level the net points are connected by a cross edge. However, if the number of levels is large, in particular when the diameter of the metric space is super-polynomial, then the number of hops in the path can be large. To resolve this issue, we use techniques in [14] to shortcut each incubator tree Tc by adding more local edges; the details are given in Section 4. Skeleton edges are the local tree edges together with the local shortcutting edges that we add later; in this section, we only have local tree edges as skeleton edges. Lonely vs Super Incubators. An incubator is lonely if it has exactly one local child incubator (which has the same identity as the parent), otherwise it is normal. Observe that the leaf incubators have no children and are normal. Whenever there is a lonely incubator, we merge it with its only local child to form a super incubator, which inherits the edges from the two merged incubators. This process continues if the resulting super incubator is still lonely; hence, we combine a chain of lonely incubators (with a normal incubator at the bottom of the chain) to form a super incubator. A super incubator is described by y = (x, I), where I is the set of levels from which incubators are merged to form y. Observe that after incubator merging, there are only normal and super incubators, and every non-leaf incubator has at least two local child incubators. For the rest of this section, the incubator graph H is the union of tree edges and cross edges after incu- bator merging; we later augment this graph by adding local shortcutting edges in Section 4. Moreover, we use incubator trees to refer to the trees after incubator merging. Also, when we refer to an incubator (x, i), if it has been merged into a super incubator, we are actually referring to the corresponding super incubator. Note that the incubator graph H induces a spanner on X naturally: an edge between incubators y1 = (x1, i1) and y2 = (x2, i2) induces an edge between x1 and x2. The spanner recovered by the above incubator description is essentially the one constructed in [4]. As mentioned earlier, we would like to reduce the degree due to local tree edges, and we use the concept zombies to assign representatives to incubators. Zombies. A zombie is identified by a point x in the metric space, which is the identity of the zombie. The color of a zombie is the same as its identity. When the context is clear, we do not distinguish between a zombie and its identity. Each incubator is occupied by exactly one zombie with the same color in the following procedure. "The zombies are climbing..." Initially, each leaf incubator y = (x, 0) at level 0 contains a zombie with the same identity x; the incubator clones an extra copy of the zombie, which climbs up the incubator tree Tc of its color in the following way. The order in which zombies climb is arbitrary. If a zombie enters an incubator which contains no zombie, then the zombie occupies the incubator; we say that a zombie is at level i if it occupies an incubator at level i. In particular, if a zombie occupies a super incubator y = (x, I), we say the zombie is at all levels with indices in I. Otherwise, the current incubator already contains another zombie (this applies to the case when a cloned zombie finds another zombie already contained in the leaf incubator); in this case, the zombie climbs to the local parent of the current incubator in the incubator tree Tc. If the current incubator is the root and is already occupied, the zombie simply disappears. Observe that in each incubator tree, each internal incubator has at least two children, and hence there are enough zombies such that every incubator will be occupied by one zombie with the same color. Moreover, each incubator y contains a zombie which has the same identity as one of the local descendant leaf incubators of y. Spanner Induced by Incubator Graph with Zombies. The incubator graph H with zombies 6 induces a spanner H for the original space X as follows. Suppose there is an edge between incubators y1 = (x1, i1) and y2 = (x2, i2), which contain zombies z1 and z2 respectively. If the edge {y1, y2} is a skeleton edge (i.e. a local tree edge in this section), then an edge between the zombies z1 and z2 is induced; otherwise (i.e. a foreign or a cross edge in this section), an edge between the identities x1 and x2 of the incubators is induced. A path on X induced by a path in the incubator tree Tc is called a c-path. Naming Convention. (Please read!) We use the following naming convention to describe induced edges on X. Suppose type is a certain class for describing incubator edges, such as "tree", "cross", "local" or "foreign". We say an edge on X is a type edge if it is induced by a type edge between incubators. For example, an edge on X is a cross edge if it is induced by a cross edge between incubators. Observe that an edge on X can be induced by multiple incubator edges. We say an edge on X is a pure type edge if it is induced by type incubator edges only, and it is a non-type edge if it is not induced by any type incubator edge. For example, if an edge on X is induced by a cross edge on incubators, but not by any tree edge, then it is both a pure cross edge and a non-tree edge. The properties of the induced graph H are summarized in the following lemma, which is the main result of the section. We first prove Property 2 and 3. Lemma 3.1 The induced graph H is a (k, 1 + )-VFTS for X with the following properties. 1. For any set S ⊆ X with S ≤ k, and any x, y ∈ X \ S, there exists a (1 + )-spanner path in H \ S between x and y which is the concatenation of at most two foreign tree edges, at most one pure cross edge, and at most two c-paths for some color c (though not necessarily in this order). 2. The maximum degree of H due to local tree edges is bounded by 2O(dim). 3. The non-skeleton edges in H can be directed such that the out-degree of any point in H due to non-skeleton edges is bounded by −O(dim) · k. We first show that the maximum degree due to local tree edges is a constant. Lemma 3.2 (Small Degree due to Local Tree Edges) For all x ∈ X, the degree of x in H due to local tree edges is 2O(dim). Proof: We first show that each incubator has at most 4dim local children. Let y be any internal incubator of Tc. Let i be y's level (if y is a super incubator, let i be the lowest level in which y participates). Note that the identities of y's children in Tc form an ri−1-net, and they are all within a distance of ri from y. By Proposition 2.1, y has at most 22dim local children. Note that for any x ∈ X, there are two zombies identified by x, each of which occupies at most one incubator. Hence, the degree of x due to local tree edges is bounded by 2(22dim + 1) = 2O(dim). Now we show how to direct the non-skeleton edges in the induced graph H; observe that a non-skeleton edge is induced by either a foreign tree edge or a cross edge. If more than one rule applies, we can pick the direction indicated by any one of the rules. • Foreign Tree Edges. For a foreign tree edge between a child y1 = (x1, i1) and a parent y2 = (x2, i2), we direct from x1 to x2. • Cross Edges. Suppose {x1, x2} is a cross edge in H. Let i∗(x) be the highest level i such that x ∈ Ni. The cross edge {x1, x2} is directed from x1 to x2 if i∗(x1) < i∗(x2). If i∗(x1) = i∗(x2), the cross edge {x1, x2} is directed arbitrarily. Lemma 3.3 (Small Out-Degree due to Non-Skeleton Edges) If the non-skeleton edges in H are directed as above, then the out-degree due to them is bounded by −O(dim) · k. 7 Proof: Fix a point x in X. we show that its out-degree due to foreign tree edges is at most k, and its out-degree due to cross edges is at most −O(dim) · k. Observe the out-going foreign tree edges from x are due to the foreign parents of the incubator (x, i∗(x)). Each incubator can have at most k foreign parents; hence the out-degree of x due to them is at most k. Now we bound the out-degree of a point x due to cross edges. Recall that a cross edge between incubators induces an edge between the identities of the incubators. Fix some color c, and suppose z has color c and {x, z} is a cross edge in H directed from x to z; let i = i∗(x) ≤ i∗(z). i and a cross edge that induces {x, z} must be at level at most i; hence, d(x, z) ≤ γ·ri. Observe that z ∈ N c Since N c  )O(dim). Since there are at most k + 1 colors, the number of cross edges coming out of x is bounded by (k + 1) · (34 + 272 i is an ri-packing, by Proposition 2.1 the number of such possible z's is γO(dim) = (34+ 272  )O(dim) = −O(dim) · k. Then, we show that H is a k-fault-tolerant (1 + )-spanner for X. Lemma 3.4 (Small distance between incubators and occupying zombies) Suppose the incuba- tor y = (x, i) is occupied by a zombie with identity z. Then, the distance d(x, z) is at most 2ri. In particular, this implies that if y(cid:48) is a child of y, then the distance between their occupying zombies is at most 4ri. Proof: We only need to prove the first statement about d(x, z). The second statement follows immediately because d(y, y(cid:48)) ≤ ri. Observe that both y and z have the same color, say color c. We let x0 = z and y0 = (z, 0) be the leaf incubator identified by z. For 0 < j ≤ i, let yj = (xj, j) be the ancestor of y0 in Tc. (Note that yj and yj(cid:48) may refer to the same super incubator for j (cid:54)= j(cid:48).) By the way that zombies climb, yi = y. Also, by the construction of incubator trees, d(xj, xj−1) ≤ rj, for all 0 < j ≤ i. Hence, d(x, z) =(cid:80)i j=1 d(xj−1, xj) ≤(cid:80)i j=1 rj ≤ 2ri. Figure 3.1: A c-path Figure 3.2: A c-path following a foreign edge, where y+ stands for yi∗+1 and x+ stands for xi∗+1. Lemma 3.5 (Every Level Every Color is Reachable) For any 0 ≤ i ≤ (cid:96) and x ∈ X \ Ni, and for all c ∈ [k + 1], there is a path Pc in H between x and the identity of a level-i incubator y, with length at most 17ri. In addition, if x is of color c, then Pc is a c-path; otherwise, Pc is the concatenation of a foreign tree edge {x, x(cid:48)} and a c-path, for some x(cid:48) with color c. Proof: Suppose x has color c. Let P + c be the path in H induced by the path in Tc between the leaf incubator y0 = (x, 0) and y0's ancestor at level i. For 0 ≤ j ≤ i, denote by yj the ancestor of y0 in 8 zixxiyi = (xi, i)y0' = (xi, 0)y0 = (x, 0)zix+xiyi = (xi, i)y0' = (xi, 0)y0 = (x+, 0)xy+ = (x+, 0)foreign edge c ) =(cid:80)i j=1 d(zj−1, zj) ≤(cid:80)i j=1 4rj ≤ 8ri. c and P − 0 has the same identity as yi. By similar analysis, length(P − c ) ≤ 8ri. c ) + length(P − c , which is a c-path in H from x to the identity c ) ≤ 16ri. See Figure 3.1 for illustration. c be the path in H induced by the path in Tc between the incubator yi and its leaf descendant c, which connects xi∗+1 and the identity of yi. Furthermore, P (cid:48) Tc at level j, and let zj be the zombie occupying yj. Note that z0 = x. By Lemma 3.4, for j ≥ 1, d(zj−1, zj) ≤ 4rj. Hence, we have length(P + Let P − y(cid:48) 0, such that y(cid:48) Define the path Pc as the concatenation of P + of yi. We have length(Pc) ≤ length(P + Now suppose x has a color c(cid:48) (cid:54)= c. Let i∗ be the highest level such that x ∈ Ni∗. Since x /∈ Ni, we know that i∗ < i. Let y = (x, i∗) be an incubator. By the construction of incubator trees, there is a foreign parent yi∗+1 = (xi∗+1, i∗ + 1) of y in Tc. Then, we know that H contains an edge x,{xi∗+1} induced by the foreign edge between incubators y and yi∗+1. For i ≥ i∗ + 1, let yi be yi∗+1's ancestor in Tc at level i. Since xi∗+1 has color c, there is a c-path in H, denoted by P (cid:48) c has length at most 16ri. Let Pc be the concatenation of x,{xi∗+1} and P (cid:48) c. Since d(xi∗+1, x) ≤ ri∗+1 ≤ ri, we know that length(Pc) ≤ 17ri, See Figure 3.2 for illustration. Lemma 3.6 (Fault-Tolerant Stretch) Let S ⊆ X be a set of at most k failed nodes. Then, H \ S is a (1 + )-spanner for X \ S. In addition, the (1 + )-spanner path in H \ S between any x and y contains at most one pure cross edge, and at most two foreign tree edges. Proof: Fix x (cid:54)= y ∈ X \ S. Let i be such that ri < d(x, y) ≤ ri+1, and let q := (cid:100)log 68  (cid:101). If i ≤ q − 1, then d(x, y) ≤ ri+1 ≤ 2q ≤ 136  ≤ γ · r0. Hence, there is an edge between x and y induced by a cross edge at level 0. Suppose i > q − 1. Let j := i − q ≥ 0. We first show that there is path P1 in H \ S with length at most 17rj between x and the identity x(cid:48) of an incubator at level j. Since there are at most k failed points, i.e., S ≤ k, there must be a color c such that no failed points has color c. If x is a net point at level j, then there is an incubator ¯x = (x, j) at level j. We simply let x(cid:48) := x and P1 := {x}, and the desired properties hold trivially. Otherwise, by Lemma 3.5, x is connected to the identity x(cid:48) of an incubator at level j by a path P1 = {x, x1} ⊕ P (cid:48) 1 in H with length at most 17rj, where x1 is a point of color c and P (cid:48) 1 is a c-path in H between x1 and x(cid:48). Note thta all points on P (cid:48) 1 have color c and thus none of them fails. Hence, it follows that P1 ∈ H \ S. By similar arguments, we can show that there is path P2 in H \ S with length at most 17rj between y and y(cid:48) which is the identity of an incubator at level j. Note that d(x, x(cid:48)) ≤ length(P1) ≤ 17rj and d(y, y(cid:48)) ≤ length(P2) ≤ 17rj. It follows that d(x(cid:48), y(cid:48)) ≤ d(x(cid:48), x) + d(x, y) + d(y, y(cid:48)) ≤ ri+1 + 34rj = (2q+1 + 34)rj < (34 + 272  )rj = γ · rj. Hence, there is an edge between x(cid:48) and y(cid:48) induced by a cross edge between the incubators containing them at level j. Next we show that we can obtain a (1+)-spanner path by first going from x to x(cid:48) by P1, then going along the edge {x(cid:48), y(cid:48)}, and finally going from y(cid:48) to y by P2: dH\S(x, y) ≤ length(P1) + d(x(cid:48), y(cid:48)) + length(P2) ≤ 2q · ri ≤ (1 + )d(x, y). Note that 17rj + d(x(cid:48), x) + d(x, y) + d(y, y(cid:48)) + 17rj = d(x, y) + 68rj = d(x, y) + 68 the (1 + )-spanner path contains at most two edges induced by foreign edges, and the only possible pure cross edge that it can contain is {x(cid:48), y(cid:48)}. 9 4 Achieving Small Hop-Diameter and Lightness Consider the spanner H described in the previous section. Given a set S of at most k failed nodes, Lemma 3.1 states that for any points x, y ∈ X \ S, there exists a (1 + )-spanner path in H \ S between x and y which is the concatenation of at most two foreign edges, at most one pure cross edge, and at most two c-paths for some c. Denote this path as PH\S(x, y). Notice that a c-path is induced by some path in the incubator tree Tc. In this section, we add edges to shortcut the incubator trees, such that each of the above c-paths can be replaced with a subpath with at most O(log n) hops. In [14], a construction for 1-spanners for tree metrics with short hop-diameter is introduced. . Fact 4.1 (Spanner Shortcut [14]) Let T be a tree (whose edges have non-negative weights) with n nodes and maximum degree D. For the tree metric induced by the shortest-path distances in T , there exists a 1-spanner J with O(n) edges, maximum degree at most D + 4, hop-diameter O(log n) and lightness O(log n). Furthermore, J has the following properties. 1. Spanner J includes all edges in the tree, i.e., T ⊆ J. 2. The construction of J only depends on the structure of T , and is independent of the edge weights. 3. Any path in T can be replaced by a subpath consisting of at most O(log n) edges in J. We also have the following lemma. Lemma 4.1 (Tree edges and cross edges are light) Let Ei be the set of tree edges between level i incubators and level i + 1 incubators, and Ci be the set of cross edges between level i incubators. By convention, let E(cid:96) := ∅. Let (cid:98)r = k2∆ 2. the total weight of the edges induced by(cid:83)σ n2γ , and define σ := (cid:98)log2(cid:98)r(cid:99). Then, 1. for any σ < i ≤ (cid:96), the total weight of the edges induced by Ei ∪ Ci is −O(dim) · k2 · w(MST); i=0(Ei ∪ Ci) is O(k2 · w(MST)). First, we analyze the total weight of edges induced by Ei, for any σ < i ≤ (cid:96). Since N c Proof: is ri-packing for any c ∈ [k + 1] from Fact 2.1, it holds that w(MST) ≥ 1 i . Consequently, w(MST) ≥ 1 2k · ri ·Ni. Notice that the total weight of edges induced by Ei is at most 2(k + 1)· ri ·Ni, which is O(k2 · w(MST)). Consider the edges in Ei with 0 ≤ i ≤ σ. For each subtree rooted at level-σ incubator in Tc, the total weight of edges induced by it is bounded by 2 · ri · N c i (cid:96)(cid:88) (cid:18) 1 (cid:19)i ≤ 2k2 · ∆ n · rσ . 2 i=0 n · γ Since there are at most n such subtrees, we know that the total weight of edges induced by(cid:83)σ O(k2 · w(MST)). Then we analyze the cross edges. Consider an incubator y at level i. The number of cross edges incident to y in Ci at most is (k + 1) · γ2dim, each of which has weight at most γ · ri. Hence, the total weight of edges induced by Ci is γ2dim+1 · (k + 1) · ri · Ni which is −O(dim) · k2 · w(MST). In particular, for i = σ − j with 0 ≤ j ≤ σ, there are at most n2 cross edges at level i, each of which i=0 Ei is has weight at most γ ·(cid:0) 1 2 (cid:1)j ·(cid:98)r. Hence, the total weight of edges induced by(cid:83)σ (cid:19)j ≤ 2k2 · ∆ = O(k2 · w(MST)). σ(cid:88) n2 · γ ·(cid:98)r · (cid:18) 1 2 j=0 i=0 Ci is at most 10 Shortcutting Sub-Trees at Level below σ. In Lemma 4.1, we have l − σ = O(log n), and the total weight of induced edges below level σ is O(k2 · w(MST)). We shortcut each subtree rooted at each level σ incubator, with a spanner given by Fact 4.1. Notice that this procedure adds edges to shortcut the paths consisting of local trees edges. Hence, for any S ⊆ X of size at most k, and points x, y ∈ X, the c-path in PH\S(x, y) can be substituted by its subpath with at most O(log n) hops. Furthermore, the lightness of our spanner over X is increased by a factor of at most O(log n). we have the following lemma, which is the main result of this section. Skeleton edges. The edges between incubators added by Fact 4.1, together with the local tree edges are called skeleton edges. Recall our naming system implies that an edge between points in X is a skeleton edge, if it is induced by a skeleton edge between incubators. Define a new spanner (cid:98)H to be the union of H and the skeleton edges. Combing Fact 4.1 and Lemma 4.1, Lemma 4.2 The spanner (cid:98)H is a (k, 1 + )-VFTS for X with the following properties. 1. For any set S ⊆ X with S ≤ k, and any x, y ∈ X \ S, there exists a (1 + )-spanner path in (cid:98)H \ S 2. The maximum degree of (cid:98)H due to skeleton edges is bounded by 2O(dim). between x and y which is the concatenation of at most two foreign tree edges, at most one pure cross edge, and at most two paths with O(log n) skeleton edges. 5 Achieving Small Degree via Single-Sink Spanners Up to this point, the spanner we have constructed has (1 + )-stretch, hop-diameter O(log n) and lightness −O(dim) · k2 · log n, but may suffer from a large maximum degree. In the next two sections, we reduce the maximum degree in the spanner to a constant, with the sacrifice of increasing a factor of k in the lightness. Our technique of reducing degrees in fault-tolerant spanners is based on single-sink spanners. Given a root point v ∈ X, a spanner H for X is a k-vertex-fault-tolerant v-single-sink t-spanner ((k, t, v)- VFTssS), if for any subset S ⊆ X \ {v} with S ≤ k, and any point x ∈ X \ S, it holds that dH\S(v, x) ≤ t· d(v, x), where t is called the root-stretch of H. In [4], a construction of a (k, 1 + Θ(), v)- VFTssS with maximum degree O(k) for doubling metrics is given, but there is no guarantee on hop- diameter. We review the main ideas of the previous fault-tolerant single-sink spanner construction [4] and show how it can be modified to achieve both O(log n) hop-diameter and small weight, as stated in Theorem 5.1. Theorem 5.1 (Fault-Tolerant Single-Sink Spanner) Given 0 <  ≤ 1 exists a (k, 1+10, v)-VFTssS Hv with maximum degree ( 1 x∈X d(x, v). to sink v) and weight at most (1 + )(k + 1)(cid:80) 6 and a sink v ∈ X, there  )O(dim)k, hop-diameter O(log n) (with respect The first idea (also used in [3]) is that instead of connecting every point in X directly to the sink v, a point far away from v can be connected to v with a path in which distances of points from the sink decrease geometrically rapidly. Lemma 5.1 (Path with Rapidly Geometrically Decreasing Distances) Suppose 0 <  ≤ 1 3 , and P is a path v = p0, p1, . . . , pl = x such that for all i ≥ 1, d(v, pi) ≤ d(v, pi+1). Then, the path distance dP (v, x) ≤ (1 + 3)d(v, x). Proof: The result follows from a simple induction proof on l. For l = 1, the result is trivial. Assume that dP (v, pl) ≤ (1 + 3)d(v, pl). By the hypothesis of the lemma, we have d(v, pl) ≤ d(v, pl+1) and so by the triangle inequality, d(pl+1, pl) ≤ d(pl+1, v) + d(v, pl) ≤ (1 + )d(v, pl+1). 11 Therefore, dP (v, pl+1) ≤ dP (v, pl)+d(pl, pl+1) ≤ (1+3)·d(v, pl+1)+(1+)d(v, pl+1) ≤ (1+3)d(v, pl+1), where the last inequality holds because  ≤ 1 3 . Since we consider points whose distances from the sink decrease geometrically rapidly, ring partition is considered in [4]. Ring Partition. Let (cid:96) = (cid:100)log 1 i with i ∈ [(cid:96)]. For convenience, let r0 = 1 (recall that we assume inter-point distances are larger than 1). Consider the rings, denoted by R1, . . . , R(cid:96), where Ri := R(v, ri−1, ri). For convenience, let R0 := {v}. We say a point is in ring i if it is in Ri. The rings are pairwise disjoint and their union covers X. We say that a point x is at least 2 rings below another point y, if for some i ≤ j − 2, x ∈ Ri and y ∈ Rj; in this case, observe that d(v, x) ≤  · d(v, y). In view of Lemma 5.1, we would like to connect a point to the sink through a path such that the next point is at least 2 rings below the previous point. ∆(cid:101) and ri = 1  However, the degree of the resulting spanner could be large if there is some ring that contains a lot of points. Hence, in [4], an appropriate net is constructed for each ring and each ring is decomposed into clusters, each of which is covered by the closest net point. In particular, for each i ∈ [(cid:96)], we build an )2dim = −4dim points. We denote ri−1-net Ni for Ri. By Proposition 2.1, Ni contains at most ( ri ri−1 this upper bound by Γ := (cid:100)−4dim(cid:101) and then we have Ni ≤ Γ. Let N := ∪i>0Ni be the set of net points. Then, for each net point y ∈ Ni, we construct a net cluster Cy, such that a point x ∈ X is in Cy iff x is in Ri, and among all points in Ni, y is the closest one to x (breaking ties arbitrarily). Achieving Fault-Tolerance via Multiple Portals for Each Cluster. If all nodes do not fail, then we can first build a single-sink spanner for the net points in all rings, and then for each cluster, we can build a subgraph such that each point is connected to the net point with a short path. However, the net point might fail, and so for each y ∈ N , we arbitrarily choose k + 1 portals Qy ⊆ Cy (if Cy < k + 1, we let Qy = Cy); we can think of in addition to the net point y, we choose k extra points (if there are enough points) in the cluster as portals such that when k nodes fail, there will be at least one functioning portal to connect that cluster with the outside world. Let Qi := ∪y∈NiQy be the portals in Ri, and let Q := ∪y∈N Qy be the set of all portals. Note that Qi ≤ (k + 1) · Ni ≤ Γ · (k + 1). The following approach is used in [4] to build a single-sink spanner for X by combining single-sink spanner for the portals and subgraphs connecting points in each cluster to their portals. Lemma 5.2 (Single-Sink Spanner for Portals and Connecting Points to Portals) Let 0 <  ≤ 1 6 . Suppose HQ is a (k, 1 + 3, v)-VFTssS for Q with maximum degree δ1 and hop-diameter D1. More- over, for each y ∈ N such that the cluster Cy has radius r, suppose Hy is a subgraph on Cy with maximum degree δ2 such that for any subset S of vertices of size k, for any x ∈ Cy \ S, there exists a portal q ∈ Qy \ S such that there is a path from x to y with length 4r and D2 hops. Then, the subgraph Hv := HQ ∪ (∪y∈N Hy) is a (k, 1 + 10, v)-VFTssS for X with maximum degree δ1 + δ2 and hop-diameter D1 + D2. Proof: Suppose S is a set of k failed nodes and x /∈ S. We can assume that x (cid:54)= v; otherwise the conclusion holds trivially. Suppose x ∈ Ri (where i ≥ 1), and let y ∈ Ni be the net point covering x, i.e., x ∈ Cy. Hence, the radius of Cy is r = ri−1 ≤ d(v, x). From assumption, there exists a path P2 in Hy \ S from x to some functioning portal q ∈ Qy with D2 hops and length 4r ≤ 4 · d(v, x). Note that d(v, q) ≤ d(x, v) + d(x, q) ≤ (1 + 2)d(v, x). By assumption, since HQ is a fault-tolerant spanner for Q, there exists a path P1 in HQ \ S from q to v with D1 hops and length (1 + 3)d(q, v) ≤ (1 + 6)d(v, x), where the last inequality holds because  ≤ 1 6 . 12 Hence, it follows that P2 and P1 forms a path from x to v that has length at most (1 + 10)d(x, v). The maximum degree of a point in H is trivially at most δ1 + δ2, since the clusters Cy's contain disjoint points. 5.1 Fault-Tolerant Single-Sink Spanner for Portals We review the fault-tolerant single-sink spanner construction [4] for portals and describe how we can achieve O(log n) diameter. Recall that because of Lemma 5.1, when we traverse on a path from some point x to v, we would like the next point to be at least 2 rings below that of the previous point. At the same time, we would like to achieve fault-tolerance. Hence, we arrange the portals in groups of size k + 1 sorted in non-decreasing distance from v. Grouping Portals. We sort points in Q = {q1, q2, . . . , qm} in non-decreasing distance from v, i.e., d(v, q1) ≤ d(v, q2) ≤ ··· ≤ d(v, qm), where m := Q. For convenience, let q0 := v. Then, we divide the points in Q into groups of size k + 1. Specifically, let Aj := {ql ∈ Q(j − 1)· (k + 1) + 1 ≤ l ≤ j · (k + 1)} for j ≥ 1. For convenience, let A0 := {v}, and for i < 0, Ai := A0. Observe that any consecutive two rings can contain at most 2Γ(k + 1) portals. Hence for any 1 ≤ i ≤ j − 2Γ − 1, any point in Ai must be at least two rings below any point in Aj. Hence, for each j ≥ 1, we can connect group Aj with Aj−2Γ−1, where connecting two groups Ai and Aj means adding edges between every point in Ai and every point in Aj. Observe that for i < j, when k nodes fail, there is at least one node in Ai available for the nodes in Aj to reach v. Note that the degree of v is at most (2Γ + 1)(k + 1), and every other node has degree at most 2(k + 1). This is the construction given in [4] and according to Lemma 5.1, the stretch to v is at most 1 + 3. However, the hop-diameter could be large, because for every i ≥ 1, every group Ai is connected to at most one group Aj with j > i. We modify our construction in the following way: for every j ≥ 1, we connect Aj to A(cid:100) j−2Γ−1 (cid:101). As before, when we connect two groups, we add edges to form a complete bipartite graph between them. Suppose HQ is the resulting subgraph on the portals Q. Lemma 5.3 (Fault-Tolerant Single-Sink Spanner for Portals) For 0 <  ≤ 1 is a (k, 1 + 3, v)-VFTssS for Q with maximum degree O(Γk) and hop-diameter O(log n). 2 3 , the subgraph HQ Proof: The property of k-fault-tolerance follows from the previous construction. The stretch analysis is the same as before because for each j ≥ 1, group Aj is connected to Ai, where i ≤ j − 2Γ − 1. Moreover, the degree of v is still O(Γk). If we view A0 is the root, and view Ai as Aj's parent if Aj is connected to Ai with i < j, then we can see that every group apart from the root has at most two children. Hence, the degree of a node other than v is at most 3(k + 1). Moreover, observe that for j ≥ 1, for all but at most one internal group Aj, the group Aj is connected to two child groups. Hence, it follows that it takes O(log n) hops to reach the root A0 from any group. 5.2 Connecting Points in Each Cluster to Portals For a net point y ∈ N , we describe how to build a subgraph Hy on the cluster Cy to connect points in Cy to the portals Qy such that the conditions stated in Lemma 5.2 are satisfied. Connecting Points in Clusters to Portals. Recall that the cluster Cy has radius r centered at y. As in [4], we define a procedure Add(Cy, Qy, r) which adds edges to connect points in Cy with portals 13 in Qy, where Cy is a cluster with radius r centered at some point. The idea in [4] is that we partition the points in Cy \ Qy into sub-clusters with radius r 2 and recurse on the sub-clusters. For each sub-cluster Cz, we choose k + 1 points Qz (if there are enough points) in Cz as portals; we connect every point in Qy with every point in Qz, and recursively call Add(Cz, Qz, r 2 ). The base case of the recursion is when a cluster has no more points other than its portals, i.e., Cz = Qz. However, it is possible that the points are distributed such that at every level of recursion, there is only one sub-cluster in the next level; this means the number of levels of recursion can be linear in the size of the original cluster. Notice that the number of hops for a portal at the last level to reach a portal at the first level is equal to the number of levels of recursion. A simple modification is to first divide the points in Cy \ Qy evenly into two sets U1 and U2, i.e., U1 − U2 ≤ 1; then we can work on U1 and U2 as described above. The formal procedure is described below. Result: Adds edges to connect points in Cy with portals in Qy // Now suppose Qy (cid:40) Cy 1 If Cy = Qy, return; 2 Partition the points in Cy \ Qy evenly into two sets U1 and U2 such that U1 − U2 ≤ 1; 3 foreach i ∈ {1, 2} do Build an r foreach z ∈ Ni do 2 -net Ni for Ui; 4 5 6 7 8 9 Build a sub-cluster Cz := {x ∈ Ui : z is the closest point in Ni to x}; Arbitrary select k + 1 portals Qz in Cz (select all points in Cz if Cz < k + 1); Add an edge between every point in Qy and every point in Qz; Recursively call Add(Cz, Qz, r 2 ); end 10 11 end Procedure 1: Add(Cy, Qy, r) Let Hy be the resulting subgraph returned by Add(Cy, Qy, r). We have the following lemma. Lemma 5.4 The graph Hy has maximum degree 2O(dim) · k. Suppose S ⊆ X be a set of at most k points. For any x ∈ Cy \ S and any q ∈ Qy \ S, there exists a path P2 in Hy \ S between q and x with length(P2) ≤ 4r and O(log n) hops. Proof: For each i ∈ {1, 2}, Ni is a r 2 -net for Ui, and is contained in the ball centered at y of radius r. By Proposition 2.1, Ni ≤ 22dim. Hence, each point in Qy is connected to portals in at most 22dim+1 sub-clusters. Since each sub-cluster has at most k + 1 portals, it follows that each point in Qy is connected to at most 22dim+1(k + 1) portals in sub-clusters. In addition, points in Qy may also be connected to k + 1 portals in Cy's super-cluster. Hence, each point in Qy is connected to at most (22dim+1 + 1)(k + 1) = 2O(dim) · k points in Hy. The k-fault-tolerance properties follows because if Cz is a sub-cluster of Cy, then even when k nodes fail, there always exists a functioning portal in Qy connecting to the functioning portals in Qz. Observe that the distance between a portal in the first level and one at the next level is at most 2r, and this decreases geometrically with factor 1 2 . Hence, a path P2 from a a portal in the first level to a portal in the last level has length at most 4r. Moreover, because we divide the remaining points evenly at each level of recursion, the total number of levels of recursion is O(log n), and so the path P2 has O(log n) hops. 14 5.3 Weight Analysis Lemma 5.5 The spanner Hv := HQ ∪ (∪y∈N Hy) constructed above has weight at most (1 + )(k + 1)(cid:80) x∈X d(x, v). Proof: For each edge in Hv, we charge the edge to one of its endpoints. Then, we show that for each x ∈ X, the sum of the weights of the edges charged to x is at most (1 + )(k + 1)d(x, v). For an edge in HQ, we charge it to the portal in the higher ring. For an edge in some Hy, it connects a portal u in some cluster C to a portal v in one of its sub-clusters; we charge this edge to v. Observe that for all x (cid:54)= v, at most k + 1 edges are charged to x and they are either all of the first type or all of the second type. Consider a node x for which all edges charged to it are in HQ. It follows that for each such edge {x, y}, the point y must be at least 2 rings below x. Hence, d(y, v) ≤ d(x, v), and so d(x, y) ≤ d(x, v)+d(v, y) ≤ (1 + )d(x, v). Consider a node x for which all edges charged to it are in Hy for some y ∈ N . Suppose x is in ring i. Then, it follows that x in some cluster Cy with radius r ≤ d(x, v). Hence, every edge charged to x has weight at most 2r ≤ 2d(x, v) ≤ (1 + )d(x, v). Since for every x (cid:54)= v, at most k + 1 edges are charged to it, it follows the sum of weights of edges charged to x is at most (1 + )(k + 1)d(x, v), as required. 6 (k, 1+)-VFTS with Bounded Degree, Hop-Diameter and Lightness H∗ consisting of all edges in E, as the final spanner for X. 3 )-VFTS H0. Let (cid:98)E be the skeleton In this section, we show how to combine our previous construction up to Section 4 and fault-tolerant single-sink spanners in Thoerem 5.1 to get a fault-tolerant (1 + )-spanner with simultaneously bounded degree, short hop-diameter and small lightness. We first use the construction up to Section 4 to build a (k, 1 +  edges, and E be the non-skeleton edges in H0. Then we direct the edges in E using the techniques in Section 3 so that the out-degree of each point x ∈ X due to E is −O(dim) · k. We denote an edge {x, y} by (x, y) if it is directed from x to y. For each x ∈ X, let Nin(x) := {y ∈ X : (y, x) ∈ E}, and we build edges in E directed into x with Hx. In other words, we let E := (cid:98)E ∪ (∪x∈X E(Hx)) and take the graph 3 , x)-VFTssS Hx for Nin(x) ∪ {x}. To get the final spanner, we replace the star consisting of a (k, 1 +  2 , H∗ is a (k, 1 + )-VFTS. In addition, its maximum degree is −O(dim)· k2, Theorem 6.1 For 0 <  < 1 its hop-diameter is O(log n), and its lightness is O(k3 log n). Proof: We first show the 1 +  stretch. Let S ⊆ X be a set with at most k points. Since H0 is a 3 )-spanner path P0 ⊆ H0 \ S between x and y. (k, 1 +  Also, by Lemma 4.2, there exists a path P0 ∈ H0 \ S that contains at most one pure cross edge and at most two foreign tree edges. In other words, P0 contains at most O(log n) edges, and at most 3 edges in E. Consider an edge {u, v} ∈ P0∩ E, and suppose it is directed as (u, v). Since Hv is a (k, 1 +  3 , v)-VFTssS 3 )-spanner path Puv in Hv \ S between x and y. Let P be and u, v are both functioning, there is a (1 +  the path obtained by replacing each {u, v} ∈ P0 ∩ E with Puv. Then, we know that P is contained in H \ S and is a spanner path between x and y with stretch at most (1 +  3 )-VFTS, for any x, y ∈ X \ S, there is a (1 +  3 )2 ≤ 1 + . 15 Next we bound the hop-diameter. Note that the (1+  3 )-spanner path P0 between x and y in H0 contains at most O(log n) edges. To obtain P , at most 3 edges in P0 ∩ E are replaced by a (1 +  3 )-spanner path in a single-sink spanner. Recall that the single-sink spanners constructed in Section 5 has hop-diameter O(log n). Hence, the replacement only increases the number of edges by O(log n), and thus P contains at most O(log n) edges. It follows that the hop-diameter of H∗ is at most O(log n). Now we bound the degree of an arbitrary point x ∈ X. We already know that the degree of X due to edges in (cid:98)E is 2O(dim), and we only need to give an upper bound for x's degree due to edges in the single-sink spanners. The edges in the single-sink spanners incident to x are contained in Hx and Hy's such that there is an edge (x, y) ∈ E. Note that the number of Hy's involving x is bounded by the out-degree of x due to E, which is −O(dim) · k. Also recall that the degree of x in Hx is −O(dim) · k and the degree of x in each Hy is 2O(dim) · k. It follows that the degree of x due to single-sink spanners is −O(dim) · k2. Hence, the degree of x in H∗ is −O(dim) · k2. Finally, we analyze the lightness. By Lemma 4.2, H0 has lightness O(k2 log n). Note that the star y∈Nin(x) d(x, y). By Lemma 5.5, the single-sink spanner y∈Nin(x) d(x, y). Hence, the replacement of the stars with single-sink spanners increases the weight by a factor of O(k). Also observe that the stars replaced are disjoint. It follows that the lightness of H∗ is at most O(k3 log n). spanning Nin(x) centered at x has weight (cid:80) Hx has weight at most O(k) ·(cid:80) References [1] S. Arya, G. Das, D. M. Mount, J. S. Salowe, and M. H. M. Smid. Euclidean spanners: short, thin, and lanky. In STOC, pages 489 -- 498, 1995. [2] P. B. Callahan and S. R. Kosaraju. Faster algorithms for some geometric graph problems in higher dimensions. In SODA, pages 291 -- 300, 1993. [3] H. T.-H. Chan, A. Gupta, B. M. Maggs, and S. Zhou. On hierarchical routing in doubling metrics. In SODA, pages 762 -- 771, 2005. [4] H. T.-H. Chan, M. Li, and L. Ning. Sparse fault-tolerant spanners for doubling metrics with bounded hop-diameter or degree. In ICALP, 2012. [5] T.-H. H. Chan and A. Gupta. Small hop-diameter sparse spanners for doubling metrics. Discrete & Computational Geometry, 41(1):28 -- 44, 2009. [6] A. Czumaj and H. Zhao. Fault-tolerant geometric spanners. Discrete & Computational Geometry, 32(2):207 -- 230, 2004. [7] G. Das and G. Narasimhan. A fast algorithm for constructing sparse euclidean spanners. In Symposium on Compu- tational Geometry, pages 132 -- 139, 1994. [8] Y. Dinitz, M. Elkin, and S. Solomon. Shallow-low-light trees, and tight lower bounds for euclidean spanners. In FOCS, pages 519 -- 528, 2008. [9] M. Elkin and S. Solomon. Optimal euclidean spanners: really short, thin and lanky. Technical Report CS-12-04, Department of Computer Science, Ben-Gurion University of the Negev, P.O. Box 653, Beer-Sheva 84105, ISRAEL, April 2012. [10] L.-A. Gottlieb and L. Roditty. An optimal dynamic spanner for doubling metric spaces. In ESA, pages 478 -- 489, 2008. [11] A. Gupta, R. Krauthgamer, and J. R. Lee. Bounded geometries, fractals, and low-distortion embeddings. In FOCS, pages 534 -- 543, 2003. [12] S. Har-Peled and M. Mendel. Fast construction of nets in low dimensional metrics, and their applications. In Symposium on Computational Geometry, pages 150 -- 158, 2005. [13] G. Narasimhan and M. H. M. Smid. Geometric spanner networks. Cambridge University Press, 2007. [14] S. Solomon and M. Elkin. Balancing degree, diameter and weight in euclidean spanners. In ESA (1), pages 48 -- 59, 2010. 16
1606.08022
5
1606
2017-04-21T18:01:47
Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems: Natural LP is not too bad
[ "cs.DS" ]
In this paper, we give first constant factor approximation for capacitated knapsack median problem (CKM) for hard uniform capacities, violating the budget only by an additive factor of $f_{max}$ where $f_{max}$ is the maximum cost of a facility opened by the optimal and violating capacities by $(2+\epsilon)$ factor. Natural LP for the problem is known to have an unbounded integrality gap when any one of the two constraints is allowed to be violated by a factor less than $2$. Thus, we present a result which is very close to the best achievable from the natural LP. To the best of our knowledge, the problem has not been studied earlier. For capacitated facility location problem with uniform capacities, a constant factor approximation algorithm is presented violating the capacities a little ($1 + \epsilon$). Though constant factor results are known for the problem without violating the capacities, the result is interesting as it is obtained by rounding the solution to the natural LP, which is known to have an unbounded integrality gap without violating the capacities. Thus, we achieve the best possible from the natural LP for the problem. The result shows that natural LP is not too bad. Finally, we raise some issues with the proofs of the results presented in~\cite{capkmByrkaFRS2013} for capacitated $k$-facility location problem (C$k$FLP).~\cite{capkmByrkaFRS2013} presents $O(1/\epsilon^2)$ approximation violating the capacities by a factor of $(2 + \epsilon)$ using dependent rounding. We first fix these issues using our techniques. Also, it can be argued that (deterministic) pipage rounding cannot be used to open the facilities instead of dependent rounding. Our techniques for CKM provide a constant factor approximation for CkFLP violating the capacities by $(2 + \epsilon)$.
cs.DS
cs
Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems: Natural LP is not too bad ∗ Sapna Grover1, Neelima Gupta2, and Aditya Pancholi3 1 Shivaji College, University of Delhi, India. [email protected] 2 University of Delhi, India. [email protected] 3 University of Delhi, India. [email protected] 7 1 0 2 r p A 1 2 ] S D . s c [ 5 v 2 2 0 8 0 . 6 0 6 1 : v i X r a Abstract In this paper, we give first constant factor approximation for capacitated knapsack median problem (CKM) for hard uniform capacities, violating the budget only by an additive factor of fmax where fmax is the maximum cost of a facility opened by the optimal and violating capacities by (2+) factor. Natural LP for the problem is known to have an unbounded integrality gap when any one of the two constraints is allowed to be violated by a factor less than 2. Thus, we present a result which is very close to the best achievable from the natural LP. To the best of our knowledge, the problem has not been studied earlier. For capacitated facility location problem with uniform capacities, a constant factor approximation algorithm is presented violating the capacities a little (1+). Though constant factor results are known for the problem without violating the capacities, the result is interesting as it is obtained by rounding the solution to the natural LP, which is known to have an unbounded integ- rality gap without violating the capacities. Thus, we achieve the best possible from the natural LP for the problem. The result shows that natural LP is not too bad. Finally, we raise some issues with the proofs of the results presented in [4] for capacitated k-facility location problem (CkFLP). [4] presents O(1/2) approximation violating the capacities by a factor of (2+) using dependent rounding. We first fix these issues using our techniques. Also, it can be argued that (deterministic) pipage rounding cannot be used to open the facilities instead of dependent rounding. Our techniques for CKM provide a constant factor approximation for CkFLP violating the capacities by (2+). 1998 ACM Subject Classification F.2 Analysis of Algorithms and Problem Complexity. Keywords and phrases Capacitated Knapsack Median, Capacitated k -Facility Location Digital Object Identifier 10.4230/LIPIcs... 1 Introduction Facility location problem (FLP) is one of the widely studied problems in computer science and operational research. The problem is well known to be NP-hard. In this paper, we study the capacitated variants of some facility location problems for hard uniform capacities. In particular, we study the capacitated knapsack median problem (CKM) and capacitated facility location probelm (CFLP). Knapsack median problem is a generalization of the well known k-median problem. The natural LP for knapsack median is known to have an unbounded integrality gap [6] even for the ∗ This work was partially supported by University of Delhi Research Grant. © Sapna Grover, Neelima Gupta and Aditya Pancholi; licensed under Creative Commons License CC-BY Leibniz International Proceedings in Informatics Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany XX:2 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems uncapacitated variant of the problem. Krishnaswamy et al. [9] showed that the integrality gap holds even on adding the covering inequalities to strengthen the LP, and gave a 16 factor approximation that violates the budget constraint by an additive factor of fmax, the maximum opening cost of a facility in optimal. Kumar [10] gave first constant factor approximation without violating the budget constraint. Kumar strengthened the natural LP by obtaining a bound on the maximum distance a client can travel. Charikar and Li [7] reduced the large constant obtained by Kumar to 34 which was further improved to 32 by Swamy in [11]. Byrka et al. [5] extended the work of Swamy to obtain a factor of 17.46. To the best of our knowledge, the capacitated variant of the problem has not been studied earlier. Natural LP for capacitated k-median is known to have an unbounded integrality gap when any one of the two constraints is allowed to be violated by a factor less than 2 [1]. The hardness result holds for CKM as well. We give first constant factor approximation for the problem violating the capacities by (2+) and budget only by an additive fmax where fmax is the maximum cost of a facility in the optimal. Thus, we present a result which is very close to the best achievable from the natural LP. In particular, we give the following result: (cid:73) Theorem 1. There is a polynomial time algorithm that approximates hard uniform capacitated knapsack median problem within a constant factor (O(1/2)) of optimal violating the capacities by a factor of (2+) and budget only by an additive factor of fmax where fmax is the maximum cost of a facility in the optimal for a fixed >0. Next, we present a constant factor approximation for capacitated facility location problem (CFLP) with uniform capacities violating the capacities a little, by (1+). Standard LP is known to have an unbounded integrality gap for the problem. However, the example [8] breaks when the capacities are allowed to be violated a little. In particular, for a fixed >0 if we allow the capacities to be violated by a factor of (1+), then the gap is bounded by O(1/). Though constant factor results are known for the problem without violating the capacities [2, 3], our result is interesting as it is obtained by rounding the solution to the natural LP. [2] is based on local search techniques whereas [3] rounds the solution to a very sophisticated LP. Our result shows that natural LP is not too bad. In particular, we give the following result: (cid:73) Theorem 2. There is a polynomial time algorithm that approximates hard uniform capacitated facility location problem within a constant factor (O(1/)) of optimal violating the capacities by a factor of at most (1+) for a fixed 0<<1/2. Finally, we raise some issues with the proofs of the results presented in [4] for capacitated k-facility location problem (CkFLP). Byrka et al. in [4] presents O(1/2) approximation violating the capacities by a factor of (2+) using dependent rounding. We fix the issues using our techniques. Also, it can be argued that (deterministic) pipage rounding cannot be used to open the facilities instead of dependent rounding. Our techniques for CKM provides similar result for CkFLP in a straight forward manner violating the cardinality by plus 1. We will show that the cardinality violation can be avoided. Thus we present the first deterministic constant factor approximation for the problem violating the capacities by (2+). Aardal et al. [1] gave a constant factor approximation when the facility costs are uniform using 2k−1 facilities. High Level Idea: We borrow some tools and techniques from [4]. Facilities and demands are partitioned into clusters, a binary tree structure is defined on the centers of clusters and meta-clusters(MCs) are formed as in [4]. A cluster is classified as sparse or dense depending on whether the demand served by it is small or large. A new LP is used to open facilities in sparse and dense clusters. Using the properties of extreme point solutions, a solution is obtained with at most two fractionally opened facilities. Both the fractional facilities are opened integrally at a loss of plus fmax in budget. Connection costs are bounded separately for sparse and dense clusters. (This helps us resolve the issues in [4].) Min-cost flow is then used to obtain integral assignments. S. Grover et. al. XX:3 Our algorithm for knapsack median works in three stages. Stage I comprises of clustering and meta-clustering and is largely same as that presented in [4]. In stage II, we transform our solution into what we call as pseudo-integral solution. A solution is said to be pseudo-integral if at most two facilities are opened fractionally. It is then transformed into an integrally open solution in stage III. Organization of the paper: We first present our algorithm for knapsack median in section 2 reviewing some of the the techniques used in [4] for CkF LP in sub-section 2.1 and highlighting the modifications we make at the end of the sub-section. Sub-sections 2.2 and 2.3 present stage II and stage III respectively of the algorithm. Section 3 presents the algorithm for CF LP. We fix the issues raised with respect to [4] using our techniques and also discuss how the techniques can be used to provide a deterministic solution for the problem in section 4. Capacitated Knapsack Median Problem 2 In knapsack median problem , we are given a set of clients C, a set of facilities F and a real valued distance function c(i, j) on F∪C in metric space. Each client j has some demand associated with it, each facility i has an opening cost fi, and we have a budget B. The goal is to open a set of facilities and assign demands to them so as to minimize the total connection cost subject to the constraint that the total facility cost of the opened facilities is at most B. When B=k and fi=1, problem reduces to the k-median problem. In capacitated knapsack median, each facility i also has an associated capacity ui which limits the maximum amount of demand it can serve. We deal with the case when ui=u ∀i and demands are unit and, denote it by unifCKM. The Integer Program (IP) for instance (C, F, c, f, u, B) of unifCKM is given as follows: i∈Fc(i, j)xij ∀ j∈C ∀ i∈F ∀ i∈F, j∈C subject to j∈CP Minimize CostKM(x,y)=P P P i∈Fxij =1 j∈Cxij ≤u yi P xij ≤yi i∈Ffiyi≤B yi, xij ∈{0,1} ∀ i∈F, j∈C (1) (2) (3) (4) LP-Relaxation of the problem is obtained by allowing the variables yi and xij to be fractional. Call it LP1. Let LPopt denote the cost of optimal solution. For an LP solution σ=<x,y >, j∈C and i∈T yi denote the total extent up to which facilities are a subset T of facilities, let size(y, T)=P opened in T, Aσ(j, T)=P i∈T xij denote the total assignment of j on facilities in T. To begin with, we guess the facility with maximum opening cost, fmax, in the optimal solution and remove all the facilities with facility cost >fmax before applying the algorithm. The algorithm runs for all possible choices of fmax and the solution with minimum cost is selected. This can be done in polynomial time because there are only F choices for fmax. As we build upon the techniques of [4] (for CkFLP), we present a brief overview of them in section 2.1. We also raise some issues in the claims and proofs presented in [4]. 2.1 Overview of the techniques used in [4] for CkFLP In CkFLP, instead of budget B, we have a bound k on the maximum number of facilities that can be opened. The goal is to open facilities within the bound and assign clients to them so as to minimize the total facility opening cost and connection cost subject to capacity constraint. connection cost of a client j in σ∗ i.e. Cj =P To begin with, sets of facilities and demands are partitioned into clusters at a loss of constant factor in cost. Let σ∗ =< x∗, y∗ > denote the optimal LP solution. Let Cj denote the average ijc(i, j). Let l≥2 be a fixed parameter and i∈F x∗ XX:4 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems ball(j) be the set of facilities within a distance of l Cj of j i.e. ball(j) = {i ∈ F : c(i, j) ≤ l Cj}. Then, size(y∗, ball(j))≥1− 1 l . Let Rj =l Cj denote the radius of ball(j). Consider the clients in non-decreasing order of their radii. Let S =C, C0=φ and j be a client with smallest radius Rj in S, breaking ties arbitrarily. Add j to C0 and delete it from S. ∀j0∈S with c(j, j0)≤2l Cj0, remove j0 from S and let ctr(j0)=j. For each j∈C0, define cluster Nj as the set of facilities to which j is nearest amongst all the clients in C0; that is Nj ={i∈F ∀j0∈C0: j6=j0⇒c(i, j)<c(i, j0)} assuming that the distances are distinct. j is called the center of the cluster. Thus, C0 is the set of cluster centers. Note that ball(j)⊆Nj and the sets Nj partition F. Any two cluster centers j and j0 satisfy the separation property : c(j, j0)>2l max{ Cj, Cj0}. Let li denote the total demand of clients in li. Move the demand dj to center j of the cluster. The cost of moving the demand is bounded by 2(l+1)LPopt (Lemma (2.6) of [4]). (cid:73) Lemma 3. [4] Let j ∈ C0 and i ∈ Nj then, (i) For j0 ∈ C0, c(j, j0) ≤ 2c(i, j0), (ii) For j0 ∈ C \ C0, c(j, j0) ≤ 2c(i, j0) + 2l Cj0, (iii) For j0 ∈ C, c(i, j) ≤ c(i, j0) + 2l Cj0 and (iv) C serviced by facility i i.e. li=P P j0∈CP j∈C0c(j, j0)Aσ∗(j0,Nj)≤2(l+1)LPopt. ij0 and, dj =P j0∈Cx∗ i∈Nj Let CS be the set of cluster centers for which the total opening is less than 1 and CD be the set of remaining centers in C0. The clusters centered at j∈CS are called sparse and those centered at j∈CD dense. Define NCD =∪j∈CDNj and NCS =∪j∈CSNj. A tree structure is defined on the cluster centers as follows: for j∈C0, let η(j) be the nearest other cluster center in C0, of j. A tree consists of client centers as nodes and (j, η(j)) as directed edges. In case, there is a 2 length cycle at the root, one of the cycle edges is removed arbitrarily. Note that the in-degree of a node may be unbounded in this structure. These trees are converted into binary trees using the standard procedure after sorting the children of node j∈C0 from left to right in non-decreasing order of distance from j. Let T 0 denote the new tree obtained and σ(j) be the parent of j in T 0. Its easy to show that c(j, σ(j))≤2c(j, η(j)) and the edge costs decrease as we go up the tree. Also, the in-degree of root is at most 1. Next, clusters are grouped in what we call as meta-clusters(MCs) so that facilities in each MC can be opened independently of the facilities in other MCs and all except at most u units of demand of a MC can be satisfied within the MC with capacities scaled up by a factor of 2+3/(l−1). MCs are formed by processing the nodes of a tree T in a top-down greedy manner starting from the root. To form a new MC, let r be a topmost node in T not yet grouped. Include r in the new MC, denote it by Gr. Let j be a node not yet grouped, include j in Gr such that j has the cheapest edge connecting it to some node in Gr i.e. j =argminw{c(w, v)∈T :v∈Gr and w is not yet grouped}. MCs are formed of size l (if possible) and these nodes are removed from further consideration in the formation of MCs. There may be some MCs with fewer nodes than l, towards the leaves of the tree. With a slight abuse of notation, we will use Gr to denote the collection of centers of the clusters in it as well as the set of clusters them- selves. Let H(Gr) denote the subgraph of T with nodes in Gr. The subgraph H(Gr) is converted into a chain of clusters loosing a factor of O(l) on distances. Let the new structure be denoted by H(Gr). An almost integral solution (having at most one fractional facility) is obtained within each cluster by truncating the openings from y∗ ij0/u and, greedily transferring the openings and assignments to facilities in non-decreasing order of fi+uc(i, j). Authors claim that certain properties (definition 5 in the paper) are satisfied by this solution. However, this is not true. In particular properties (iii) and (iv) are not satisfied1. i to zi =P j0∈Cx∗ 1 In a personal communication, authors provided modified versions of the properties viz. (iii0) For any j∈C0, the total opening in Nj of y∗ (size(y∗, Nj)) is at least 1−1/l and (iv0) Let j6=r be a node in a tree T 0 such that the cluster Sj has only one facility i with positive opening say y0 j. Now, it is not clear what is y0 i . If property (i) of Definition 5 is correct (authors make no mention of that in their personal communication), then almost integral solution z0 is obtained from z. y0 is not same as z0 as communicated in the personal communication. i)djc(j, σ(j))≤16bc i. It is not clear whether the almost integral solution is obtained from z or from y∗ i. Then, (1−y0 S. Grover et. al. XX:5 A tree structure is defined on the MCs as follows: a tree consists of MCs as nodes and there is an edge from a MC Gr to another MC Gs, if there is a directed edge from root r of Gr to some node s0∈Gs. Gs is then called the parent MC of Gr and the edge (r, s0) is called the connecting edge of the child MC Gr. If Gr is a root MC, add an edge to itself with cost c(r, σ(r)). This edge is then called the connecting edge of Gr. Note that the cost of any edge in Gs is less than the cost of the connecting edge of Gr which is further less than the cost of any edge in Gr. Next, it is shown that if fractional facilities (at most one in each cluster) are paired up in a top down manner, dependent rounding is applied on them preserving the sum of openings y0 i (or the truncated openings? is not clear from the paper; dependent rounding will not work with truncated openings), then the demand dj of j ∈CS can be assigned to facilities in clusters whose center is within O(l2)c(j, σ(j)) distance from j, within factor (2+) violation of capacities. However, it is not clear how the cost of transporting the demand dj from j to σ(j) and (2+)u units of demand from the center to the facilities opened in the cluster are bounded. We will show that this can be done using our techniques in section 2.2. Next, we present our rounding algorithm for CKM. Stage I of our algorithm comprises of clustering and meta-clustering and is same as that presented in this section except that we redefine sparse and dense clusters based on the amount of demand they serve rather than the total openings i.e. for j∈C0, we say that Nj is sparse if dj <u and dense otherwise. We continue to use CS and CD to denote the set of cluster centers of sparse and dense clusters respectively. We also redefine η(j) as: for each cluster center j ∈CS, let η(j) be the nearest other cluster center in C0, of j and for j∈CD, η(j)=j. Trees on cluster centers and those of MCs are then formed in the same way. Note that with this definition of η(j) there is at most one dense cluster in any MC, and if present, it is always the root cluster of a root MC. Also, we work with H(Gr) instead of H(Gr). 2.2 Stage II: Obtaining a pseudo-integral solution Sparse clusters have the nice property that they need to take care of small demand (less than u each) and dense clusters have the nice property that the total opening within each cluster is at least 1. These properties are exploited to obtain the claimed bounds. We define a new LP which provides us with a solution having at most two fractionally opened facilities. Before proceeding any further, we present the following results borrowing the notations from the previous section, to motivate us to define our LP. (cid:73) Lemma 4. Let j0∈C\C0 and j∈C0 such that c(j, j0)≤Rj , then Rj ≤2Rj0. Proof. Suppose, if possible, Rj > 2Rj0. Let ctr(j0) = k. Then, c(j0, k)≤ 2Rj0. And, c(k, j)≤ c(k, j0)+c(j0, j) ≤2Rj0+Rj <2Rj =2l Cj, which is a contradiction to separation property. (cid:74) (cid:74) (cid:74) (cid:1). j∈C0dj i∈Fc(i, j)x∗ ij =3LPopt. j0∈C:c(j,j0)≤Rj Second term in the sum on RHS < 1 ≤ 1 (cid:73) Lemma 5. P P ij ≤3P j∈CP j∈C0(cid:0)P j0∈CAσ∗(j0,Nj)(cid:1) Cj Proof. P ij =P P i∈Fc(i, j)x∗ j∈C0dj j∈C0(cid:0)P =P Aσ∗(j0,Nj) Cj+P i∈Fc(i, j)x∗ P j∈C0P P j0∈CP P ≤P j0∈CP P ij0(2c(i, j0)+2l Cj0) x∗ i∈Nj ij0(c(i, j0)+2 Cj0). Thus the claim follows. x∗ ij+c(j, η(j))(1−P (cid:73) Lemma 6. P dj(P i∈Nj (cid:0)P Proof. The second term of LHS =P c(i, j)x∗ (cid:0)P (cid:1) ≤P (cid:0)P P ≤P dj j∈CS i∈Nj0 c(j, j0)x∗ (cid:1) ij))≤6LPopt. x∗ i∈Nj c(j, η(j))x∗ j∈C0:c(j,j0)>Rj j∈C0:c(j,j0)>Rj Aσ∗(j0,Nj)c(j, j0) Aσ∗(j0,Nj) Cj j∈CS dj j0∈C0:j06=j j∈CS dj j0∈C0:j06=j j∈CS i∈Nj j0∈C:c(j,j0)>Rj j0∈C:c(j,j0)>Rj (cid:1) i/∈Nj ij ij P i∈Nj02c(i, j)x∗ ij l l XX:6 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems Hence, we have the following: X (cid:0)X dj ij+c(j, σ(j))(1−X ij)(cid:1)≤12LPopt x∗ c(i, j)x∗ (5) i∈Nj i∈Nj j∈CS Next, we define our new LP so as to open sufficient number of facilities in each MC such that the opened facilities are well spread out amongst the clusters (at most 1 (sparse) cluster has no facility opened in it) and demand of a dense cluster is satisfied within the cluster itself. One way to do this is to open bdj/uc facilities in a dense cluster centered at j and qr−1 facilities in sparse clusters of a MC with qr sparse clusters in it. The demand of the sparse cluster j in which no facility is opened, is assigned to facilities opened in clusters above it. If σ(j) is a dense cluster centered at j then dj must be assigned in Nj. This works well in all the scenarios except when dj is nearly (but less than) 2u. In this case it leads to capacity violation of 3 factor. The main observation here is that in this case, we may be able to open one more facility in the cluster centered at j or j. To be able to do so, we separate these two clusters from the remaining set of clusters in the meta-cluster so that the openings in the cluster of j are not utilised more than once. r and G2 For a MC Gr, let pr and qr denote the number of dense and sparse clusters in Gr and let tr =pr+qr. Let jd be the center of the dense cluster (if any) in Gr and js be the center of the first r essentially sparse cluster (if any) included in Gr. Gr is considered in two parts: G1 consists of jd and possibly js which must be in CS. G2 r consists of the remaining clusters in Gr which r be the must be all sparse. Let γr denote the number of facilities that will be opened in G1 r−1 will be the number of facilities that will be opened in G2 number of cluster centers in G2 r. r. Choose l such that 1/l <. For j∈CD, let r and G2 r ={jd} and G2 r =max{0,qr−1}. r will be decided soon. There are two possibilities Next, we explain how to partition Gr into G1 res(j)=dj/u−bdj/uc. We begin by setting G1 r or with G2 Whether js will be handled with G1 with respect to res(jd): r∪{js}, q0 1. res(jd)<: set γr =bdjd/uc, G2 2.  ≤ res(jd) < 1: For qr ≥ 1, we must have res(jd)+ size(y∗, Njs) ≥ 1. Set G1 r =q0 γr =bdjd/uc+1 and, set γr =bdjd/uc+1 if qr =0. r. G1 r and q0 r =Gr∩CS\{js}, q0 r, then q0 These two cases will be referred to, throughout the paper (in particular, in Lemmas (10) and (11)). Let τ(j)={i∈Nj : c(i, j)≤ c(j, σ(j))} for j ∈CS and, =Nj for j ∈CD. We next define our LP (LP2) so as to open at least γr facilities in ∪j∈G1 τ(j). r−1}. Note that G2 r has only sparse clusters in it. Let S1 Also, let F0=F and B0=B. r−1} facilities in ∪j∈G2 r =max{0, q0 r =G2 τ(j) and max{0, q0 r =γr and S2 r =G1 r, s2 r, s1 r ∪{js}, r+1=qr. r = G1 r =G2 r r dj(X c(i, j)wi+c(j, σ(j))(1−X wi))+uX Min. Cost(w)=X X wic(i, j) i∈Nj j∈CD i∈τ(j) X j∈CS wi≤1 i∈τ(j) wi≥bdj/uc i∈Nj ∀ j∈CS ∀ j∈CD wi≥s1 r ∀ G1 r :s1 r6=0 wi≥s2 r ∀ G2 r :s2 r6=0 fiwi≤B0 0≤wi≤1 ∀i∈F0 subject to X X X j∈S1 r i∈τ(j) X X X i∈τ(j) i∈F0 j∈S2 r i∈τ(j) (6) (7) (8) (9) (10) (11) S. Grover et. al. XX:7 r−1} facilities are opened in G1 Constraint (6) ensures that the opened facilities are well spread out amongst the clusters as no more than 1 facility is opened in a sparse cluster. Constraint (7) makes certain that at least bdj/uc facilities are opened in a dense cluster j. Constraint (8) and (9) ensure that at least γr and max{0, q0 r respectively. Constraint (10) guarantees that r and G2 opened facilities are within the available budget. (cid:73) Lemma 7. A feasible solution w0 to LP2 can be obtained such that Cost(w0)≤(2l+13)LPopt. Proof. Consider a MC Gr. For i∈ τ(j), j ∈CD, set w0 ij ≤ y∗ i = 0 for i ∈ Nj \ τ(j). We will next show that the solution is feas- for i ∈ τ(j) and w0 i≤P i=P ible: i∈τ(j)w0 P i∈Nj i∈τ(j)w0 i∈Nj x∗ i∈τ(j)w0 For G1 ij =∆(say). j∈G1 r∩CS r∩CS =∅. Hence, ∆=djd/u≥bdjd/uc(=γr). For res(jd)<, we have G1 For res(jd) ≥ , if qr ≥ 1, ∆ ≥ djd/u + (1 − 1/l) = bdjd/uc + 1(= γr). Else (i.e. qr = 0), ∆=djd/u≥bdjd/uc(=γr). Let j∈CS,P Let j∈CD,P r6=∅,P w0 i∈τ(j)x∗ li/u≥bdj/uc. i∈τ(j):j∈G1 i=P i=P i . If j ∈CS, set w0 li/u+P i = li/u≤ y∗ i∈τ(j):j∈G1 ij ≤1. i = x∗ r∩CD i r P i∈τ(j)x∗ ij ≥P i ≤P (1−1/l)= j∈G2 r∩CS P j0∈Cc(i, j)x∗ ij0 ij0 by Lemma (3). Summing over all j∈CD, we get u c(i, j)w0 i∈τ(j) i∈Nj r≥2, we haveP i=P P i∈τ(j)w0 j∈G2 i for all i∈F. r r with q0 i∈Nj j∈G2 r∩CS i≤y∗ r−1 as q0 j0∈C ic(i, j)≤(2l+1)LPopt w0 (cid:0)c(i, j0)+2l Cj0(cid:1)x∗ For G2 r(1−1/l)≥q0 r≤l. q0 Constraint (10) follows as w0 P X i)) =P i))=P dj(P dj(P dj(X Next, we bound the cost of objective function. For j∈CD, X ≤P uX Now consider the part of objective function for CS. P P dj(P i +P ij+c(j, σ(j))(1−P P dj(P <P ij + c(j, σ(j))(1−P i∈Nj i∈Nj\τ(j)w0 =P ij+c(j, σ(j))(1−P j∈CS c(j, σ(j)))x∗ i+c(j, σ(j))(1−X X j∈CS j∈CS i∈τ(j) c(i, j)x∗ c(i, j)x∗ ij) as c(i, j)>c(j, σ(j)) ∀i∈Nj\τ(j) i∈τ(j) c(i, j)w0 i∈τ(j)c(i, j)x∗ i))≤12LPopt. w0 i∈Nj c(i, j)w0 i∈τ(j) j∈CD j∈CS i∈Nj w0 j∈CS i∈Nj i∈Nj i∈Nj\τ(j) c(i, j)w0 j∈CS dj(P i + c(j, σ(j))(1 −P ij)) +P (12) i+c(j, σ(j))(1− i − i∈Nj\τ(j)(c(i, j)− i∈Nj i∈τ(j)x∗ ij)) j∈CS dj(P i∈τ(j) w0 c(i, j)w0 i∈τ(j) x∗ x∗ ij)). Thus, by equation (5), we have (13) Adding equation (12) and (13), we get Cost(w0)≤(2l+13)LPopt. (cid:74) We now present an iterative algorithm that solves LP2 and outputs a set A of integrally opened facilities. Iterative Algorithm: Obtaining a pseudo-integral solution 1. Initialize A=∅, F =F0, B=B0. 2. While F 6=∅ do: A i.e. set F = F\F1, A=A∪ F1 and B= B−P a. Compute an extreme point solution w to LP3. b. Let F0={i∈ F : wi=0}. Remove all facilities in F0 from F i.e. set F = F\ F0. c. Let F1 = {i ∈ F : wi = 1}. Remove all facilities in F1 from F and add them to d. While ∃j∈Gr such that constraint (6) or (7) is tight: r−bdj/uc. If s1 r =0, the constraint is removed. r∩CD, S1 i. If j∈G1 r\{j}, s1 i∈ F1fi wi. r =S1 r =s1 XX:8 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems ii. If j∈G1 iii. If j∈G2 r∩CS, set S1 r, set S2 r =S2 r =S1 r\{j}, s2 r\{j}, s1 r =s2 r−1. If s1 r =s1 r−1. If s2 r =0, the constraint is removed. r =0, the constraint is removed. e. If there does not exist any wi that is 0 or 1 then break. 3. Return A. (cid:73) Lemma 8. The solution w given by Iterative Algorithm satisfies the following: (i) w has at most two fractional facilities, (ii)P i∈Ffi wi≤B and, (iii) Cost(w)≤Cost(w0)≤(2l+13)LPopt. Proof. Consider the iteration when the algorithm reaches step (2e). Let the linearly independent tight constraints corresponding to (6) and (7) be denoted as X and the ones corresponding to (8) and (9) be denoted as Y. Let A be a set of variables corresponding to some constraint in X and B be a set of variables corresponding to some constraint in Y such that A ∩B6=φ. Then, due to laminar nature of constraints, A⊆B. Imagine deleting A from B and, subtracting 1 if the constraint comes from (6) and bdj/uc if the constraint comes from (7) appropriately from s1 r). Repeat the process with another such constraint in X until there is no more constraint in X whose variable set r)≥1 (for otherwise the constraints would has a non-empty intersection with B. At this point, s1 not be linearly independent) and the number of variables in B is at least 2. Number of variables in any set corresponding to a tight constraint in X is also at least 2. Thus the total number of variables is at least 2X+2Y and the number of tight constraints is at most X+Y+1. Thus, we get X+Y≤1 and hence there at most two (fractional) variables. Claim (2) follows as in step (2a), we compute a feasible solution of LP2, reduce B0 accordingly for subsequent iterations and maintain feasibility in every iteration. Note that no facility is opened in Nj\τ(j):j∈CS for if i∈Nj\τ(j):j∈CS is opened, then it can be shut down and the demand dj wi, can be shipped to σ(j), decreasing the cost as c(j, σ(j)) < c(i, j). Then, claim (3) follows as we compute extreme point solution in step (2a) in every iteration and the cost never increases (cid:74) in subsequent iterations. r(/s2 r(/s2 2.3 Obtaining an integrally open solution Next, we obtain an integrally open solution w from w by opening the two fractional facilities (if any) violating the budget by an additional cost of fmax. This is captured in the following lemma. (cid:73) Lemma 9. Given an optimal pseudo-integral solution w for LP2, an integrally open solution w can be obtained such that 1. X i∈F fi wi≤B+fmax. 2. Cost(w)≤Cost(w)≤(2l+13)LPopt. Proof. If there is no fractionally opened facility, then set wi = wi∀i∈F. Else, let {i1,i2} denote the fractionally opened facilities in solution w. Note that we must have wi1 + wi2 = 1. Set wi= wi∀i∈F\{i1,i2} and set wi1 =1, wi2 =1, A=A∪{i1∪i2}. fi1 wi1 +fi2 wi2 = fi1 wi1 +fi1(1− wi1)+fi2 wi2 +fi2(1− wi2)≤ fi1 wi1 +fi2 wi2 +fmax(1− wi1 + 1− wi2)= fi1 wi1 +fi2 wi2 +fmax(2−(wi1 + wi2))= fi1 wi1 +fi2 wi2 +fmax, where the last equality follows because wi1 + wi2 =1. Thus, the budget loss is no more than fmax and hence claim (1) (cid:74) holds. Clearly, there is no loss in connection cost. In the next two lemmas, we prove that these many facilities are sufficient to serve the demands coming onto Gr. Let M be the set of all meta clusters and M1 be the set of meta clusters, each consisting of exactly one dense and one sparse cluster. MCs in M1 need special treatment and will be considered separately. S. Grover et. al. XX:9 Lemma (10) discusses the capacity and cost bounds with respect to the assignments done within a MC Gr. Lemma (11) deals with the remaining demand that we fail to assign within a MC. Such demand is assigned in the parent MC. Lemma (11) discusses the cost bound for such assignments and the impact of the demand coming onto Gr from the children MC's along with the demand within Gr on capacity. (cid:73) Lemma 10. Consider a meta-cluster Gr. Suppose the capacities are scaled up by a factor of 2+ for l≥1/. Then, (i) Each dense cluster is self-sufficient i.e. its demand can be completely assigned within the cluster itself. (ii) There are at most two clusters, one in G1 r, with no facility opened in them and they are sparse clusters. (iii) Demands are assigned only to facilities above them in the meta-cluster except for the root cluster of a root meta-cluster. (iv) At most u units of demand in Gr remain un-assigned and it must be in the root cluster of Gr. (v) For Gr∈M\M1, let βr =bdjd/uc+max{0,qr−1}, where jd is the demand of the dense root cluster (if any) in Gr. Then, at least βr facilities are opened in Gr. (vi) For Gr∈M1, let βr =bdjd/uc for case 1 and =bdjd/uc+1 for case 2. Then, at least βr facilities are opened in Gr. (vii) Total distance traveled by demand dj of j(6=r)∈Gr to reach the centers of the clusters in which they are served is bounded by 2djc(j, σ(j)). Proof. At least one facility (bdjd/uc≥1) is opened in Njd. Demand u·res(jd) is assigned to these facilities. Thus dense clusters are self sufficient. βr =bdjd/uc if qr =0. Now onwards, we assume that qr≥1. r and one in G2 LP2 opens max{0,q0 r−1} facilities in G2 r where q0 r is empty or σ(j)∈G1 r is the number of clusters in G2 r. Constraint (6) ensures that at most one facility is opened in each cluster. Thus, there is at most one cluster in r ={jd,js}, it is possible r with no facility opened in it and it is a sparse cluster. In case 2 when G1 G2 that all the γr facilities are opened in τ(jd) and no facility is opened in τ(js). Thus, there are at most two clusters with no facility opened in them and they are sparse clusters. Let j∈ G2 r such that no facility is opened in τ(j). If σ(j)∈ G2 r, then LP2 must have opened a facility in τ(σ(j)). Demand of j is assigned to this facility at a loss of maximum 2 factor in capacity. If σ(j) /∈G2 r then r. Consider the first case: j must be the root of Gr. Note that Gr either G1 cannot be a root MC in this case for otherwise σ(j) would be in G2 r. Demand dj of j is then served in the parent meta-cluster; at most u units of demand of Gr remain unassigned within Gr and goes up to the parent MC. It is guaranteed that the demand will be served in the parent meta-cluster within the capacity bounds as shown in the next lemma. Next consider the case that σ(j)∈G1 r, then σ(j) is either jd or js. We will next show that demand of j will be absorbed in τ(jd)∪τ(js) in the claimed bounds along with claims (v) and (vi) of the lemma. 1. res(jd) < , we have G1 r = qr, and βr =bdjd/uc+qr−1. LP2 must have opened at least bdjd/uc≥1 facilities in τ(jd) (let i∗ be one of them) and at least r. In this case, j =js and σ(j)=jd. Demands u·res(jd) and dj are assigned qr−1 facilities in G2 to i∗ at a loss of (2+) factor in capacity. r = qr−1 and γr =bdjd/uc+1. r ={jd, js}, G2 βr = bdjd/uc+ qr −1 if qr 6= 1 and = bdjd/uc+1 if qr = 1. LP2 must have opened at least bdjd/uc+1≥2 facilities in τ(jd)∪τ(js) (let i1 and i2 be two of them) and (for qr≥2) at least qr−2 facilities in G2 r. In this case, σ(j)= js. In the worst case, no facility is opened in τ(js). Demands u·res(jd), djs and dj are assigned to i1 and i2 at a loss of factor 2 in capacity. Clearly, c(j, jd)≤2c(j, σ(j)). (cid:74) (cid:73) Lemma 11. Consider a meta-cluster Gr. The demand of Gr and the demand coming on Gr from the children meta-clusters can be assigned to the facilities opened in Gr such that: (i) Capacities l−1) for l≥1/ and, (ii) Total distance traveled by demand are violated at most by a factor of (2+ 4 dj of j∈C0 to reach the centers of the clusters in which they are served is bounded by ldjc(j, σ(j)). 2. ≤ res(jd) < 1, we have G1 r ={jd}, γr =bdjd/uc, G2 r = Gr∩CS, q0 r = Gr∩CS \{js}, q0 XX:10 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems βru βru Proof. After assigning the demands of the clusters within Gr as explained in the previous lemma, demand coming from all the children meta-clusters are distributed proportionately to facilities within Gr utilizing the remaining capacities. Next, we will show that this can be done within the claimed capacity bound. Let Gr be a non leaf meta-cluster with a dense cluster jd∈CD at the root, if any. Note that Gr /∈M1 for l >2. The total demand onto the facilities opened in Gr is at most u(bdjd/uc+1+qr)+u(tr+1)≤ (βr+2)u+(tr+1)u whereas the total available capacity is at least βru. Thus, the capacity violation =2+4/βr≤2+4/(l−1) (as bdjd/uc≥pr we have ≤ (βr+2)u+(βr+2)u is bounded by (βr+2)u+(tr+1)u βr≥qr−1+pr =tr−1=l−1 for a non-leaf MC). Leaf meta-clusters may have length less than l but they don't have any demand coming onto them from the children meta-cluster thus capacity violation is bounded as explained in the previous lemma. First of all, consider a leaf meta-cluster with only one cluster in it i.e. tr =1. If no facility is opened in this cluster then it must be sparse and its demand is served by the parent meta-cluster (note that it cannot be a root MC as a root MC with sparse root must have at least 2 clusters in it). If a facility is opened in it then it is self sufficient. Next consider a leaf meta-cluster with exactly two clusters in it. In that case, we must have βr≥1. Now, either Gr∈M1 or both the clusters are sparse. In the latter case, clearly capacity violation is no more than 2. So let Gr∈M1. If bdj/uc≥2, then clearly the capacity violation is no more than 2. So let bdj/uc=1. Now we'll have to consider the two cases: In case 1, one facility is opened and total demand is at most (2+)u. In case 2, two facilities are opened and total demand is at most 3u. Next consider a leaf meta-cluster with more than two clusters in it. Clearly, it is not in M1 and βr≥2. The capacity violation is at most (βr+2)u βru =1+2/βr≤2. Let j belongs to the MC Gr. Then, either the demand of j is served by a facility in τ(σ(j)) within Gr or j is the root of Gr and its demand is served by facilities in clusters of the parent MC, say Gs. Since the edges in Gs are no costlier than the connecting edge (j,σ(j)) of Gr and there are at most l−1 edges in Gs, the total distance traveled by demand dj of j to reach the centers (cid:74) of the clusters in which they are served is bounded by ldjc(j, σ(j)). Choosing l≥1/ such that 4/(l−1)< gives us l≥4/+1. Next, we bound the cost of assigning the demands collected at the centers to the facilities opened in their respective clusters. Let j∈C0. Let λ(j) be the set of centers j00 such that facilities in τ(j00) serve the demand of j. Note that if some facility is opened in τ(j), then λ(j) is {j} itself and if no facility is opened in τ(j), then λ(j)={j00:∃i∈τ(j00) such that demand of j is served by i}. Further, let gi be the total demand served by any facility i. The cost of assigning a part of the demand dj by a facility opened in τ(j00), j00 ∈ λ(j)∩CS is bounded differently from the part assigned to facilities in τ(j00), j00∈λ(j)∩CD. Let j00 ∈CS∩λ(j), i∈ τ(j00). Then, c(j00, i)≤ c(j00, σ(j00))≤ c(j, σ(j)). Last inequality follows as: either j00 is above j in the same MC (say Gr) (by Lemma (10)) or j00 is in the parent MC (say Gs) (by Lemma (11)) of Gr. In the first case, the edge (j00, σ(j00)) is either in Gr or is the connecting edge of Gr. The inequality follows as edge costs are non-increasing as we go up the tree. In the latter case, edge (j00, σ(j00)) is either in Gs or it is the connecting edge of Gs: in either case, c(j00, σ(j00))≤c(j, σ(j)) as the connecting edge of Gs is no costlier than the edges in Gs which are no costlier than the connecting edge (c(j, σ(j))) of Gr. Summing over all j,j00∈CS and applying the result of Lemma (9), we see that this cost is bounded by (2l+1)LPopt. Next, let j00∈CD∩λ(j). Let i∈τ(j00). Since gi≤(2+)u, the cost of transporting (2+)u units of demand from j00 to i is (2+)uwic(i, j00). Summing it over all i∈τ(j00), j00∈CD∩λ(j), j∈C0 and applying the result of Lemma (9), we get that the total cost for CD is bounded by (2+)(2l+1)LPopt. Hence we arrive at the following lemma: (cid:73) Lemma 12. An integrally open solution ¯σ =< ¯x,¯y > to knapsack-median problem instance (C, F, c, f, u, B) can be obtained with a capacity violation at most 2+ such that CostKM(¯x,¯y)= S. Grover et. al. XX:11 O(1/2)LPopt for a fixed >0. Proof. Set ¯yi= wi ∀i∈F. Let j∈C0. Borrowing notations λ(j) and gi ∀i∈F from above. Also, let ψ(j) be the set of facilities in λ(j) that serve the demand of j and θ(j,j00) be the extent to which dj is served by the facilities in Nj00, j00∈λ(j). Let j0∈C be such that Aσ∗(j0,Nj)>0. For j00∈λ(j), i∈Nj00, (cid:74) i0∈Nj00 gi0)θ(j,j00)Aσ∗(j0,Nj). For detailed proof, see Appendix 6.1. set ¯xij0 =(gi/P Capacitated Facility Location Problem 3 In Capacitated Facility Location Problem, we are given a set of clients C, a set of facilities F and a real valued distance function c(i, j) on F∪C in metric space, each facility i has facility opening cost fi and capacity ui while each client has unit demand. The goal is to open a set of facilities and assign clients to them so as to minimize the total facility opening cost and connection cost. We deal with the case when ui = u ∀i and denote it by unif-FLP. In this section, we present a constant factor approximation for the problem The natural LP-relaxation for instance (C, F, c, f, u) of unif-FLP is given as follows. LP3: Minimize CostF LP(x,y)=P i∈Ffiyi+P i∈FP j∈Cc(i, j)xij subject to X X xij =1 ∀j∈C i∈F xij ≤u yi ∀i∈F j∈C xij ≤yi ∀i∈F, j∈C xij ≥0, yi≥0 (14) (15) (16) Let CostF LP(x,y)=Costf(σ, T)+Costs(σ, T) denote the total opening cost and the connection cost paid by all clients for getting service from a given subset of facilities T under solution σ=<x,y >. Let σ∗=<x∗, y∗ > denote the optimal solution of LP3. Clusters are formed the same way as in knapsack median with l=2. Sparse clusters are easy to handle in this case as there is no budget on the cost of opened facilities. For a sparse cluster centered at j, we open the cheapest facility i∗ in ball(j), close all other facilities in the cluster and shift their demands to i∗. Let σ=<x,y > be the solution so obtained. (cid:73) Lemma 13. The solution σ=<x,y > satisfies the following: 1. it is integrally open in NCS and feasible. 2. Cost(σ, NCS)≤O(1)LPopt. Proof. For each j∈CS, claim (1) follows as i∗ is fully open and dj <u. Next, we prove claim (2). Let j∈CS, i∈Nj and j0∈C be such that x∗ ij0 >0. Then, by Lemma (3), c(j, j0)≤2c(i, j0)+2Rj0. Also, since i∗∈ball(j), we have c(i∗, j)≤Rj. Thus, c(i∗, j0)≤c(j, j0)+c(i∗, j)≤c(j, j0)+Rj. If Rj <c(j, j0) then c(i∗, j0)<2c(j, j0)≤4c(i, j0)+4Rj0 else c(i∗, j0)≤2Rj ≤4Rj0 ≤4c(i, j0)+4Rj0 where the second inequality in the else part follows by Lemma (4). Hence, c(i∗, j0)xi∗j0 = ij0 =P x∗ i∈Nj i∈Nj ij0c(i∗, j0)≤P x∗ x∗ ij0(4c(i, j0)+4Rj0). Thus, i∈Nj c(i∗, j0)P Costs(j0, σ, NCS)≤4Costs(j0, σ∗, NCS)+8 Cj0Aσ∗(j0, NCS) -(1) Also, Costf(σ, NCS)≤2Costf(σ∗, NCS) -(2) Equation (2) follows as i∗ is cheapest and size(y∗, ball(j))≥1/2. Adding equation (1) over all j0∈C, we get Costs(σ, NCS)≤4Costs(σ∗, NCS)+8P j0∈C Cj0Aσ∗(j0, NCS) -(3) XX:12 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems Adding equation (2) and (3) we get claim (2). P We next define some more notations which will be useful. Let CI-Costf(z, NCD)=P fizi denote the total facility opening cost paid by all i∈NCD under a solution z. Further, let li be the as- P signment of the demand of j to facility i in Nj with zi opening i.e. li=uzi, then, CI-Costs(z, NCD)= c(i, j)li , denote the total service cost paid by all j∈CD for getting served by facilities in NCD under solution z. Then, CostCI(z, NCD)= CI-Costf(z, NCD)+ CI-Costs(z, NCD). For dense clusters, we obtain what we call an almost integral solution, within each cluster. A solution is said to be almost integral if at most one facility is opened fractionally. We first define the notion of cluster instances. Let j ∈ CD. Define the following linear program for cluster instance: S(j,Nj, dj, bj), with bj = bf y∗ i fi is the budget j = X j, where bf j + bc i∈NCD j∈CD i∈Nj (cid:74) ij0(c(i, j0) + 2l Cj0) is the budget on connection x∗ i∈Nj (fi+uc(i, j))zi (17) (18) X i∈Nj on facility opening cost and bc j = X LP4: Minimize CostF LPj(z)=P subject to uX cost. j0∈C i∈Nj zi=dj i∈Nj 0≤zi≤1 i∈Nj j +bc 1. P 2. X Proof. Let i ∈ Nj. Set zi =P ible solution to the cluster instance. uP (cid:1)=P uP P c(i, j)(cid:0)P fizi≤P j0∈Cx∗ ij0 u fiy∗ i . Also, i∈Nj i∈Nj i∈Nj i∈Nj j where z denotes a solution to the cluster instance. (cid:73) Lemma 14. Let j∈CD, for cluster instance S(j,Nj,dj,bj), a feasible solution z can be obtained such that i∈Nj (fi+uc(i, j))zi≤bf i i.e. size(z, Nj)≤size(y∗, Nj) and, y∗ zi≤P i∈Nj ij0/u = liu ≤ y∗ j0∈C x∗ P j0∈Cc(i, j)x∗ i∈Nj zi =P ij0 ≤P li = dj. Also, uP P i . We will show that z so defined is a feas- c(i, j)zi = i∈Nj x∗ ij0 =bc j and c(i, j0)+2l Cj0 (cid:16) (cid:17) i∈Nj j0∈C i∈Nj P size(z, Nj)≤size(y∗, Nj) follows as zi≤y∗ (cid:74) i . (cid:73) Lemma 15. For a feasible solution z to a cluster instance centered at j∈CD, we can construct an almost integral solution z0 with size(z0, Nj)=size(z, Nj) without increasing the cost. Proof. Arrange the fractionally opened facilities in z in non-decreasing order of fi+uc(i, j) and greedily transfer the total opening size(z, Nj) to them. Let z0 denote the new openings. Let i ≤ i = z0 l0 i∈Nj l0 i∈Nj (fi + c(i, j)u) zi≤bf j +bc j. zi = dj. Clearly,P iu. Note thatP (cid:74) (cid:73) Lemma 16. Let dj ≥ u and 0 <  < 1/2 be fixed. Given an almost integral solution z0 and assignment l0 as obtained in Lemma (15), an integrally open solution z and assignment l (possibly fractional) can be obtained such that i∈Nj 1. li≤(1+)ziu ∀i∈Nj, andP i = uP i =uP (fi + c(i, j)u) z0 li=P l0 i=dj i∈Nj i∈Nj i∈Nj i∈Nj z0 S. Grover et. al. XX:13 i ∀j∈ CD (20) 2. CostCI(z, Nj)≤(1/) CostCI(z0, Nj)≤(1/)(bf Proof. We will construct solution z and assignment l such that they satisfy the following equations along with the claims (1) and (2): fiz0 X i ∀j∈ CD, j) j +bc (19) X fizi≤ 1 c(i, j)li≤(1+)X i∈Nj  i∈Nj c(i, j)l0 X i∈Nj i1 < u while l0 i∈Nj Adding (19) and (20) we get claim (2). We now proceed to prove claims (1), (19) and (20). If there is no fractionally open facility, we do nothing, i.e. set z=z0. Else, there is exactly one fractional facility, say i1, and at least one integral facility, say i2, as size(z0, Nj)≥1. There are two possibilities w.r.t i1, 1. z0 2. z0 i1 < i1 ≥ In first case, close i1 and shift its demand to i2 at a loss of factor (1+) in its capacity. Note that l0 i2 <(1+)u=(1+)uzi2. Also, li2 ≤(1+)l0 i2. There is no loss in facility cost in this case. In second case, simply open i1, at a loss of 1/ in facility cost. Set zi1 =1. Then, fi1zi1 ≤(1/)fi1z0 P i1. (cid:74) (cid:73) Lemma 17. Let 0<<1/2 be fixed. An integrally open solution ¯σ=<¯x,¯y > to (C, F, c, f, u) 1. P can be obtained such that, i2. Then, c(i2, j)li2 ≤(1+) c(i2, j)l0 There is no loss in connection cost in this case. i2 =u. Thus, set zi1 =0, li1 =0 and li2 = l0 j∈C¯xij ≤(1+)¯yiu ∀i∈F, 2. CostF LP(¯x,¯y)≤O(1/)LPopt. Proof. Set ¯yi =yi ∀i∈NCS, ¯yi =zi ∀ i ∈NCD and ¯xij0 =xij0 ∀i∈NCS , j0∈C and for j∈CD, j0∈ C, i∈Nj, let ¯xij0 = li (cid:74) Aσ∗(j0, Nj). For detailed proof, see Appendix 6.2. l0 i=dj holds clearly. li=P i1 +l0 P i∈Nj i∈Nj 0∈Nj i i0j0 = li x∗ dj dj 4 Capacitated k- Facility Location Problem In this section, we combine the techniques developed in the previous sections to fix the issues raised in section 2.1. We first obtain an almost integral solution in each sparse cluster, centered at j, by opening the cheapest facility i∗ in ball(j) to an extent of min{size(y∗, Nj), 1}, closing all other facilities in the cluster and shifting their demands to i∗. There is no loss in facility cost and the connection is bounded in the same manner as in Lemma (13). Let σ=<x,y > be the solution so obtained. Then it can be shown that (1−yi)djc(j, σ(j))≤8bc j (see appendix 6.3). For j∈CD, an i ≤5LPopt is obtained in a similar manner almost integral solution z0 withP (fi + c(i, j)u) z0 as in Section 3 without increasing the cardinality. Now the cost of transporting the demands from the centers to the facilities can be bounded in the similar manner as described for CKM in section 2: Let j∈C0, i∈τ(j), j00∈CS∩λ(j), i00∈τ(j00), c(j00, i00) ≤ c(j00, σ(j00)) ≤ c(j, σ(j)). Hence, (1 − yi)djc(j00, i00) ≤ (1 − yi)djc(j, σ(j)) ≤ 8bc j. Thus, summing over all j,j00 ∈ CS we see that this cost is bounded by O(1)LPopt. Next, let j00∈CD∩λ(j),i00∈Nj00. Since gi00 ≤(2+)u and the cost of transporting u units of demand from j00 to i00 is bounded, summing over all i00∈Nj00 and j00∈CD∩λ(j) and j∈C0, we get that the total cost for CD is bounded by 5(2+)LPopt. Finally, using the above techniques (deterministic) pipage rounding cannot be used to open the facilities instead of dependent rounding as only (1−yi)djc(j, σ(j)) is bounded and we need to bound i∈Nj XX:14 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems djc(j, σ(j)). An LP similar to LP2 provides us this bound in an appropriate manner. That is to say that our techniques for CKM provides similar results for CkF LP with (2+) factor violation in capacity, violating the cardinality by plus 1. The violation of cardinality can be avoided by opening the facility with larger opening integrally while converting a pseudo integral solution into an integrally open solution. Thus we present the first deterministic constant factor approximation for the problem violating the capacities by (2+) factor. 5 Conclusion In this work, we presented first constant factor approximation algorithm for uniform hard capacitated knapsack median problem violating the budget by an additional cost of fmax in the facility opening cost and a loss of factor 2+ in capacity. We also gave a constant factor (O(1/)) approximation for uniform capacitated facility location at a loss of (1+) in capacity. The result shows that the natural LP is not too bad. We raised some issues with the proofs presented in [4] for capacitated k facility location problem and then showed that they can be resolved using our techniques. We also give the first deterministic constant factor algorithm for the problem violating capacities by a factor of 2+. It would be interesting to see if we can either drop  from the capacity violation or avoid fmax loss in the budget using the same LP. Another direction to extend the work would be to consider non-uniform capacities. Conflicting requirement of facility costs and capacities makes the problem challenging. References 1 Karen Aardal, Pieter L. van den Berg, Dion Gijswijt, and Shanfei Li. Approximation algorithms for hard capacitated k-facility location problems. EJOR,, 242(2):358–368, 2015. doi:10.1016/j.ejor.2014.10.011. 2 Ankit Aggarwal, Anand Louis, Manisha Bansal, Naveen Garg, Neelima Gupta, Shubham Gupta, and Surabhi Jain. A 3-approximation algorithm for the facility location problem with uniform capacities. Journal of Mathematical Programming, 141(1-2):527–547, 2013. 3 Hyung-Chan An, Mohit Singh, and Ola Svensson. Lp-based algorithms for capacitated facility location. In FOCS, 2014,, pages 256–265. Jaroslaw Byrka, Krzysztof Fleszar, Bartosz Rybicki, and Joachim Spoerhase. Bi-factor approx- imation algorithms for hard capacitated k-median problems. In SODA 2015,, pages 722–736. Jaroslaw Byrka, Thomas Pensyl, Bartosz Rybicki, Joachim Spoerhase, Aravind Srinivasan, and Khoa Trinh. An improved approximation algorithm for knapsack median using sparsification. In ESA 2015, pages 275–287. 4 5 8 6 Moses Charikar and Sudipto Guha. Improved combinatorial algorithms for facility location problems. SIAM Journal on Computing, 34(4):803–824, 2005. 7 Moses Charikar and Shi Li. A dependent lp-rounding approach for the k-median problem. In ICALP 2012,, pages 194–205. Sapna Grover, Neelima Gupta, and Aditya Pancholi. Constant factor approximation algorithms for uniform hard capacitated facility location problems: Natural LP is not too bad. CoRR, abs/1606.08022, 2016. 9 Ravishankar Krishnaswamy, Amit Kumar, Viswanath Nagarajan, Yogish Sabharwal, and Barna Saha. The matroid median problem. In SODA, 2011, pages 1117–1130. 10 Amit Kumar. Constant factor approximation algorithm for the knapsack median problem. In SODA, 2012, pages 824–832. 11 Chaitanya Swamy. Improved approximation algorithms for matroid and knapsack median problems and applications. In APPROX/RANDOM, 2014, pages 403–418, 2014. S. Grover et. al. XX:15 Appendix 6 6.1 Detailed proof of Lemma (12) Choosing l ≥ 2/ such that 4/(l−1) <  gives us l ≥ 4/+1. Let j ∈C0. Let λ(j) be the set of centers j00 such that facilities in τ(j00) serve the demand of j. Note that if some facility is opened in τ(j), then λ(j) is {j} itself and if no facility is opened in τ(j),then λ(j) = {j00 : ∃i ∈ τ(j00) such that demand of j is served by i}. Further, let gi be the total demand served by any facility i. Then, set ¯yi = wi ∀i∈F. Let j0 ∈C be such that Aσ∗(j0,Nj) > 0. For j00 ∈ λ(j), i∈Nj00, set i0∈Nj00 gi0)θ(j,j00)Aσ∗(j0,Nj). The cost of assigning a part of the demand dj by a facility opened in λ(j)∩CS is bounded differently from the part assigned to facilities in λ(j)∩CD. From Lemma (3), the cost of consolidating the demands at the centers of the clusters is bounded c(j, j0)Aσ∗(j0,Nj)≤2(l+1)LPopt -(2) j∈C0 j0∈C Let J2 be the set of sparse clusters in which no facility is opened and J1 be the remaining ones i.e. J1=CS\J2. Then, λ(j)={j} ∀j∈J1. Let j∈J1 and i∗(j) be the facility opened in τ(j). ¯xij0c(i, j00)=X ¯xij0c(i, j00)=X X j∈J1 ¯xi∗(j)j0c(i∗(j), j) X ¯xi∗(j)j0c(i∗(j), j)=X j∈J1 j0∈C djc(i∗(j), j) j∈J1 θ(j,j00)dj. Using Lemma (11), the cost of moving the demand dj to the centers in λ(j) is bounded as follows: θ(j,j00)djc(j, j00)≤ldjc(j, σ(j)) j00∈λ(j) Summing over j∈J2 and applying Lemma (9), we get θ(j,j00)Aσ∗(j0,Nj)  giX Aσ∗(j0,Nj)= gi0 j0∈C i0∈Nj00 θ(j,j00)dj gi0 θ(j,j00)dj =gi - (1) X j∈C0 = gi0 i0∈Nj00 j0∈C j0∈C i0∈Nj00 j∈C0 j0∈C ¯xij0 = Summing over j∈C0, ¯xij0 =(gi/P  giX ¯xij0 =X X  giX θ(j,j00)X   giX X X θ(j,j00)dj = X as X as follows:X X X X X X =X X For j∈ J2, we have dj = X X j∈J1 Summing over j0∈C, we get X X dj wic(i, j)-(3) j00∈CS∩λ(j) j00∈CS∩λ(j) j∈J1 i∈Nj i∈Nj00 j0∈C i0∈Nj00 i0∈Nj00 gi0 gi0 i∈Nj00 j∈J1 j∈C0 j00∈λ(j) XX:16 Constant factor Approximation Algorithms for Uniform Hard Capacitated Facility Location Problems X X X djc(j, σ(j))(1−X θ(j,j00)djc(j, j00)≤l wi)≤l(2l+13)LPopt -(4) j∈J2 i∈Nj j00∈λ(j) j∈J2 Next, we bound the cost of assigning the demands collected at the centers in λ(j)s to the facilities opened in their respective clusters. The cost of assigning a part of the demand dj in a facility opened in λ(j)∩CS is bounded differently from the part assigned to facilities in λ(j)∩CD. Let j00∈CS∩λ(j), i∈τ(j00). Then, c(j00, i)≤c(j00, σ(j00))≤c(j, σ(j)). Last inequality follows as: either j00 is above j in the same MC (by Lemma (10)) or j00 is in the parent MC (say Gs) of the MC (say Gr) to which j belongs. In the first case, the inequality follows as edge costs are non-increasing as we go up the tree. In the latter case, edges (j00, σ(j00)) is either in Gs or it is the connecting edge of Gs: in either case, c(j00, σ(j00))≤c(j, σ(j)) as the edges in Gs are no costlier than the edges in Gr. wi)c(j, σ(j))-(5) j∈J2 Next, let j00∈CD∩λ(j),i∈Nj00. Multiplying both sides of (1) by c(i, j00), we get i∈Nj X ¯xij0c(i, j00) ≤(2+4/(l−1))u X j0∈C j0∈C j∈J2 Summing over all i∈Nj00 and j00∈CD∩λ(j), and then applying equation (3) wic(i, j00) -(6) X ¯xij0c(i, j00)=gic(i, j00)≤(2+4/(l−1))uwic(i, j00) by Lemma (11). j∈J2 j0∈C i∈Nj00 j00∈CD∩λ(j) The above equation bounds the cost of leaving the total demand accumulated at j00 (from J2) and including the demand of j00 itself. Also, recall that for j∈CD, λ(j)={j}. j00∈CD i∈Nj00 Adding (3), (5) and (6) and applying Lemma (9), we get X X X X ¯xij0c(i, j00)≤(2+4/(l−1))(2l+13)LPopt -(7) i∈Nj00 j00∈λ(j) j∈C0 Adding (2), (4) and (7), we get that the total connection cost is bounded by l(2l+13)LPopt+ j0∈C (2+4/(l−1))(2l+13)LPopt+2(l+1)LPopt=O(l2)LPopt=O(1/2)LPopt. ¯xij0c(i, j00) i0∈Nj00  giX  giX  giX i0∈Nj00 gi0 gi0 gi0 θ(j,j00)Aσ∗(j0,Nj)c(i, j00) θ(j,j00)djc(i, j00) θ(j,j00)djc(j, σ(j)) i0∈Nj00 X =X j∈J2 X X X X X X j0∈C j00∈CS∩λ(j) i∈Nj00 j∈J2 j00∈CS∩λ(j) i∈Nj00 j0∈C =X j∈J2 X X j00∈CS∩λ(j) i∈Nj00 j∈J2 j∈J2 i∈Nj00 j00∈CS∩λ(j) X X djc(j, σ(j)) ≤X ≤X =X dj(1−X ¯xij0c(i, j00)≤X X X X X X X j∈C0 S. Grover et. al. XX:17 dj i∈Nj j0∈C dj dj 0∈Nj i i∈Nj j0∈C¯xij0 ≤(1+)¯yiu ∀i∈NCD, Aσ∗(j0, Nj). Clearly, ¯xij0 ≤ li i0j0 = li x∗ Aσ∗(j0, Nj)=Aσ∗(j0, Nj). Then, the following holds: li dj 6.2 Detailed proof of Lemma (17) P Set ¯yi=yi ∀i∈NCS, ¯yi=zi ∀ i ∈NCD and ¯xij0 =xij0 ∀i∈NCS , j0∈C and for j∈CD, j0∈C, i∈Nj, ¯xij0 =P P ≤ 1 = zi = ¯yi, and A¯σ(j0, Nj) = let ¯xij0 = li a. P Claim (a) follows from Lemma (16) as follows: Let j ∈ CD,i ∈ Nj,j0 ∈ C. Then, X b. Cost(¯σ, NCD)≤O(1/)LPopt X X From Lemma (3), we have X From Lemma (3), we also have X CostCI(z, NCD)≤(1/)X ≤(1/) X c(i, j0)+4 Cj0 Summing claim (2) of Lemma (16) over all j∈CD, we get (cid:17) ij0 ≤5LPopt. x∗ (cid:16) i +X X X (cid:16) X X j)=(1/) X i∈NCD i +5LPopt=O(1/)LPopt -(2). Aσ∗(j0, Nj)=li≤(1+)u zi=(1+)u ¯yi. c(j, j0)Aσ∗(j0,Nj)≤6LPopt -(1). c(i, j0)+4 Cj0 (bf j +bc ¯xij0 = fiy∗ fiy∗ li dj x∗ ij0 j∈CD j∈CD j0∈C j∈C0 i∈Nj j0∈C i∈Nj j0∈C j∈CD j0∈C (cid:17) i∈NCD Adding equation (1) and (2), we get claim (b), which along with claim (2) of Lemma (13) implies the desired bound. 6.3 Proof of property (iv0) i.e. (1−y0 The following equation is proved as a part of the proof in the paper [4]. Though there is a flaw in this proof but it is rectifiable using our Lemma (4). i)djc(j, σ(j))≤8bc j of [4] Let i0∈Nj and j0∈C. (1−y0 i)c(j, η(j))≤4(c(i0, j0)+2l Cj0) Multiplying the above equation by x∗ i0j0 to both the sides, we get i)c(j, η(j))≤4x∗ i0j0(c(i0, j0)+2l Cj0) X i0j0(1−y0 x∗ Summing the above equation over all j0∈C and i0∈Nj on both the sides, we get X X i)c(j, η(j))X x∗ i0j0(c(i0, j0)+2l Cj0)=4bc i0∈Nj (1−y0 i0∈Nj j0∈C j0∈C j i0j0(1−y0 x∗ i)c(j, η(j))≤4X X j0∈C i)c(j, η(j))dj ≤4bc i)djc(j, σ(j))≤8bc i0j0 ≤4bc x∗ i0∈Nj j j j (1−y0 which implies, (1−y0 (21) (22) (23) (24) (25) (26)
1506.06163
2
1506
2015-09-18T08:58:04
Big Step Greedy Algorithm for Maximum Coverage Problem
[ "cs.DS" ]
This paper proposes a greedy heuristic named as Big step greedy heuristic and investigates the application of Big step greedy heuristic for maximum k-coverage problem. Greedy algorithms construct the solution in multiple steps, the classical greedy algorithm for maximum k-coverage problem, in each step selects one set that contains the greatest number of uncovered elements. The Big step greedy heuristic, in each step selects p (1 <= p <= k) sets such that the union of selected p sets contains the greatest number of uncovered elements by evaluating all possible p-combinations of given sets. When p=k Big step greedy algorithm behaves like exact algorithm that computes optimal solution by evaluating all possible k-combinations of given sets. When p=1 it behaves like the classical greedy algorithm.
cs.DS
cs
Traceback (most recent call last): File "/opt/python_2.7.2/bin/pdf2txt.py", line 115, in <module> if __name__ == '__main__': sys.exit(main(sys.argv)) File "/opt/python_2.7.2/bin/pdf2txt.py", line 109, in main interpreter.process_page(page) File "/opt/python_2.7.2/lib/python2.7/site-packages/pdfminer/pdfinterp.py", line 832, in process_page self.render_contents(page.resources, page.contents, ctm=ctm) File "/opt/python_2.7.2/lib/python2.7/site-packages/pdfminer/pdfinterp.py", line 843, in render_contents self.init_resources(resources) File "/opt/python_2.7.2/lib/python2.7/site-packages/pdfminer/pdfinterp.py", line 347, in init_resources self.fontmap[fontid] = self.rsrcmgr.get_font(objid, spec) File "/opt/python_2.7.2/lib/python2.7/site-packages/pdfminer/pdfinterp.py", line 186, in get_font font = PDFCIDFont(self, spec) File "/opt/python_2.7.2/lib/python2.7/site-packages/pdfminer/pdffont.py", line 663, in __init__ self.unicode_map = ttf.create_unicode_map() File "/opt/python_2.7.2/lib/python2.7/site-packages/pdfminer/pdffont.py", line 434, in create_unicode_map assert 0 AssertionError
1509.04549
3
1509
2017-05-11T06:58:46
Linear Probing with 5-Independent Hashing
[ "cs.DS" ]
These lecture notes show that linear probing takes expected constant time if the hash function is 5-independent. This result was first proved by Pagh et al. [STOC'07,SICOMP'09]. The simple proof here is essentially taken from [Patrascu and Thorup ICALP'10]. We will also consider a smaller space version of linear probing that may have false positives like Bloom filters. These lecture notes illustrate the use of higher moments in data structures, and could be used in a course on randomized algorithms.
cs.DS
cs
Lecture Notes on Linear Probing with 5-Independent Hashing Mikkel Thorup May 12, 2017 Abstract These lecture notes show that linear probing takes expected constant time if the hash function is 5-independent. This result was first proved by Pagh et al. [STOC'07,SICOMP'09]. The simple proof here is essentially taken from [Patra¸scu and Thorup ICALP'10]. We will also consider a smaller space version of linear probing that may have false positives like Bloom filters. These lecture notes illustrate the use of higher moments in data structures, and could be used in a course on randomized algorithms. 1 k-independence The concept of k-independence was introduced by Wegman and Carter [21] in FOCS'79 and has been the cornerstone of our understanding of hash functions ever since. A hash function is a random function h : [u] → [t] mapping keys to hash values. Here [s] = {0, . . . , s − 1}. We can also think of a h as a random variable distributed over [t][u]. We say that h is k-independent if for any distinct keys x0, . . . , xk−1 ∈ [u] and (possibly non-distinct) hash values y0, . . . , yk−1 ∈ [t], we have Pr[h(x0) = y0 ∧ ··· ∧ h(xk−1) = yk−1] = 1/tk. Equivalently, we can define k-independence via two separate conditions; namely, (a) for any distinct keys x0, . . . , xk−1 ∈ [u], the hash values h(x0), . . . , h(xk−1) are independent random variables, that is, for any (possibly non-distinct) hash values y0, . . . , yk−1 ∈ [t] and i ∈ [k], Pr[h(xi) = yi] = Prhh(xi) = yi Vj∈[k]\{i} h(xj) = yji, and (b) for any x ∈ [u], h(x) is uniformly distributed in [t]. As the concept of independence is fundamental to probabilistic analysis, k-independent hash func- tions are both natural and powerful in algorithm analysis. They allow us to replace the heuristic assumption of truly random hash functions that are uniformly distributed in [t][u], hence needing u lg t random bits (lg = log2), with real implementable hash functions that are still "independent enough" to yield provable performance guarantees similar to those proved with true randomness. We are then left with the natural goal of understanding the independence required by algorithms. Once we have proved that k-independence suffices for a hashing-based randomized algorithm, we are free to use any k-independent hash function. The canonical construction of a k-independent 1 hash function is based on polynomials of degree k − 1. Let p ≥ u be prime. Picking random a0, . . . , ak−1 ∈ [p] = {0, . . . , p − 1}, the hash function is defined by: h(x) =(cid:0)ak−1xk−1 + ··· + a1x + a0(cid:1) mod p (1) If we want to limit the range of hash values to [t], we use h′(x) = h(x) mod t. This preserves requirement (a) of independence among k hash values. Requirement (b) of uniformity is close to satisfied if p ≫ t. More precisely, for any key x ∈ [p] and hash value y ∈ [t], we get 1/t − 1/p < Pr[h′(x) = y] < 1/t + 1/p. Sometimes 2-independence suffices. For example, 2-independence implies so-called universality [5]; namely that the probability of two keys x and y colliding with h(x) = h(y) is 1/t; or close to 1/t if the uniformity of (b) is only approximate. Universality implies expected constant time performance of hash tables implemented with chaining. Universality also suffices for the 2-level hashing of Fredman et al. [7], yielding static hash tables with constant query time. At the other end of the spectrum, when dealing with problems involving n objects, O(lg n)- independence suffices in a vast majority of applications. One reason for this is the Chernoff bounds of [18] for k-independent events, whose probability bounds differ from the full-independence Cher- noff bound by 2−Ω(k). Another reason is that random graphs with O(lg n)-independent edges [2] share many of the properties of truly random graphs. The independence measure has long been central to the study of randomized algorithms. It applies not only to hash functions, but also to pseudo-random number generators viewed as as- signing hash values to 0, 1, 2, . . .. For example, [10] considers variants of QuickSort, [1] consider the maximal bucket size for hashing with chaining, and [9, 6] consider Cuckoo hashing. In several cases [1, 6, 10], it is proved that linear transformations x 7→ (cid:0)(ax + b) mod p(cid:1) do not suffice for good performance, hence that 2-independence is not in itself sufficient. Our focus in these notes is linear probing described below. 2 Linear probing Linear probing is a classic implementation of hash tables. It uses a hash function h to map a dynamic set S of keys into an array T of size t > S. The entries of T are keys, but we can also see if an entry is "empty". This could be coded, either via an extra bit, or via a distinguished nil-key. We start with an empty set S and all empty locations. When inserting x, if the desired location h(x) ∈ [t] is already occupied, the algorithm scans h(x) + 1, h(x) + 2, . . . , t − 1, 0, 1, . . . until an empty location is found, and places x there. Below, for simplicity, we ignore the wrap-around from t − 1 to 0, so a key x is always placed in a location i ≥ h(x). To search a key x, the query algorithm starts at h(x) and scans either until it finds x, or runs into an empty position, which certifies that x is not in the hash table. When the query search is unsuccessful, that is, when x is not stored, the query algorithm scans exactly the same locations as an insert of x. A general bound on the query time is hence also a bound on the insertion time. Deletions are slightly more complicated. The invariant we want to preserve is that if a key x is stored at some location i ∈ [t], then all locations from h(x) to i are filled; for otherwise the above search would not get to x. Suppose now that x is deleted from location i. We then scan locations j = i + 1, i + 2, . . . for a key y with h(y) ≤ i. If such a y is found at location j, we move y to location i, but then, recursively, we have to try refilling j, looking for a later key z with h(z) ≤ j. The deletion process terminates when we reach an empty location d, for then the invariant says 2 that there cannot be a key y at a location j > d with h(y) ≤ d. The recursive refillings always visit successive locations, so the total time spent on deleting x is proportional to the number of locations from that of x and to the first empty location. Summing up, we have Theorem 1 With linear probing, the time it takes to search, insert, or delete a key x is at most proportional to the number of locations from h(x) to the first empty location. With n the nunber of keys and t the size of the table, we call n/t the load of our table. We generally assume that the load is bounded from 1, e.g., that the number of keys is n ≤ 2 3 t. With a good distribution of keys, we would then hope that the number of locations from h(x) to an empty location is O(1). This classic data structure is one of the most popular implementations of hash tables, due to its unmatched simplicity and efficiency. The practical use of linear probing dates back at least to 1954 to an assembly program by Samuel, Amdahl, Boehme (c.f. [12]). On modern architectures, access to memory is done in cache lines (of much more than a word), so inspecting a few consecutive values is typically only slightly worse that a single memory access. Even if the scan straddles a cache line, the behavior will still be better than a second random memory access on architectures with prefetching. Empirical evaluations [3, 8, 14] confirm the practical advantage of linear probing over other known schemes, e.g., chaining, but caution [8, 20] that it behaves quite unreliably with weak hash functions. Taken together, these findings form a strong motivation for theoretical analysis. Linear probing was shown to take expected constant time for any operation in 1963 by Knuth [11], in a report which is now regarded as the birth of algorithm analysis. This analy- sis, however, assumed a truly random hash function. A central open question of Wegman and Carter [21] was how linear probing behaves with k-independence. Siegel and Schmidt [17, 19] showed that O(lg n)-independence suffices for any operation to take expected constant time. Pagh et al. [13] showed that just 5-independence suffices for expected constant operation time. They also showed that linear transformations do not suffice, hence that 2-independence is not in itself sufficient. Patra¸scu and Thorup [16] proved that 4-independence is not in itself sufficient for expected constant operation time. They display a concrete combination of keys and a 4-independent random hash function where searching certain keys takes super constant expected time. This shows that the 5-independence result of Pagh et al. [13] is best possible. In fact [16] provided a complete understanding of linear probing with low independence as summarized in Table 1. Considering loads close to 1, that is load (1 − ε), Patra¸scu and Thorup [15] proved that the expected operation time is O(1/ε2) with 5-independent hashing, matching the bound of Knuth [11] assuming true randomness. The analysis from [15] also works for something called simple tabulation hashing that is we shall return to in Section 3.2. 3 Linear probing with 5-independence Below we present the simplified version of the proof from [15] of the result from [13] that 5- independent hashing suffices for expected constant time with linear probing. For simplicity, we assume that the load is at most 2 3 . Thus we study a set S of n keys stored in a linear probing table of size t ≥ 3 A crucial concept is a run R which is a maximal interval of filled positions. We have an empty position before R, which means that all keys x ∈ S landing in R must also hash into R in the sense 2 n. We assume that t is a power of two. 3 Independence Query time Construction time Θ(n lg n) Θ(n lg n) ≥ 5 Θ(lg n) Θ(lg n) Θ(1) Θ(n) Θ(n) 2 Θ(√n) 3 4 Table 1: Expected time bounds for linear probing with a poor k-independent hash function. The bounds are worst-case expected, e.g., a lower bound for the query means that there is a concrete combination of stored set, query key, and k-independent hash function with this expected search time while the upper-bound means that this is the worst expected time for any such combination. Construction time refers to the worst-case expected total time for inserting n keys starting from an empty table. that h(x) ∈ R. Also, we must have exactly r = R keys hashing to R since the position after R is empty. By Theorem 1 the time it takes for any operation on a key q is at most proportional to the number of locations from h(x) to the first empty location. We upper bound this number by r + 1 where r is the length of the run containing h(q). Here r = 0 if the location h(q) is empty. We note that the query key q might itself be in R, and hence be part of the run, e.g., in the case of deletions. We want to give an expected upper bound on r. In order to limit the number of different events leading to a long run, we focus on dyadic intervals: a (dyadic) ℓ-interval is an interval of length 2ℓ of the form [i2ℓ, (i + 1)2ℓ) where i ∈ [t/2ℓ]. Assuming that the hashing maps S uniformly into [t], we expect n2ℓ/t ≤ 2 3 2ℓ keys to hash into a given ℓ-interval I. We say that I is "near-full" if at least 4 2ℓ keys from S \ {q} hash into I. We claim that a long run implies that some dyadic interval of similar size is near-full. More precisely, Lemma 2 Consider a run R of length r ≥ 2ℓ+2. Then one of the first four ℓ-intervals intersecting R must be near-full. 3 Proof Let I0, . . . , I3 be the first four ℓ-intervals intersecting R. Then I0 may only have its last end-point in R while I1, . . . , I3 are contained in R since r ≥ 4 · 2ℓ. In particular, this means that L =(cid:16)Si∈[4] Ii(cid:17) ∩ R has length at least 3 · 2ℓ + 1. But L is a prefix of R, so all keys landing in L must hash into L. Since L is full, we must have at least 3 · 2ℓ + 1 keys hashing into L. Even if this includes the query key q, then we conclude that one of our four intervals Ii must have 3 · 2ℓ/4 ≥ 3 4 2ℓ keys from S \ {q} hashing into it, implying that Ii is near-full. Getting back to our original question, we are considering the run R containing the hash of the query q. Lemma 3 If the run containing the hash of the query key q is of length r ∈ [2ℓ+2, 2ℓ+3), then one of the following 12 consecutive ℓ-intervals is near-full: the ℓ-interval containing h(q), the 8 nearest ℓ-intervals to its left, and the 3 nearest ℓ-intervals to its right. Proof Let R be the run containing h(q). To apply Lemma 2, we want to show that the first four ℓ-intervals intersecting R has to be among the 12 mentioned in Lemma 3. Since the run R containing h(q) has length less than 8· 2ℓ, the first ℓ-interval intersecting R can be at most 8 before the one containing h(q). The 3 following intervals are then trivially contained among the 12. 4 For our analysis, in the random choice of the hash function h, we first fix the hash value h(q) of the query key q. Conditioned on this value of h(q), for each ℓ, let Pℓ be an upper-bound on the the probability that any given ℓ-interval is near-full. Then the probability that the run containing h(q) has length r ∈ [2ℓ+2, 2ℓ+3) is bounded by 12Pℓ. Of course, this only gives us a bound for r ≥ 4. We thus conclude that the expected length of the run containing the hash of the query key q is bounded by Thus, conditioned on the hash of the query key, for each ℓ we are interested in a bound Pℓ on the probability that any given ℓ-interval is near-full. Then the probability that the run containing h(q) has length r ∈ [2ℓ+2, 2ℓ+3) is bounded by 12Pℓ. Of course, this only gives us a bound for r ≥ 4. We thus conclude that the expected length of the run containing the hash of the query key q is bounded by 3 + log2 t Xℓ=0 2ℓ+3 · 12Pℓ = O 1 + log2 t Xℓ=0 2ℓPℓ  . Combined with Theorem 1, we have now proved Theorem 4 Consider storing a set S of keys in a linear probing table of size t where t is a power of two. Conditioned on the hash of a key q, let Pℓ bound the probability that 3 4 2ℓ keys from S \ {q} hash to any given ℓ-interval. Then the expected time to search, insert, or delete q is bounded by O 1 + log2 t Xℓ=0 2ℓPℓ  . We note that Theorem 4 does not mention the size of S. However, as mentioned earlier, with a uniform distribution, the expected number of elements hashing to an ℓ-interval is ≤ 2ℓS/t, so for 4 2ℓ. Assuming S ≤ 2 Pℓ to be small, we want this expectation to be significantly smaller than 3 3 t, the expected number is 2 To get constant expected cost for linear probing, we are going to assume that the hash function used is 5-independent. This means that no matter the hash value h(q) of q, conditioned on h(q), the keys from S \ {q} are hashed 4-independently. This means that if Xx is the indicator variable for a key x ∈ S \ {q} hashing to a given interval I, then the variables Xx, x ∈ S \ {q} are 4-wise independent. 3 2ℓ. 3.1 Fourth moment bound The probabilistic tool we shall use here to analyze 4-wise independent variables is a 4th moment bound. For i ∈ [n], let Xi ∈ [2] = {0, 1}, pi = Pr[Xi = 1] = E[Xi], X = Pi∈[n] Xi, and µ = E[X] = Pi∈[n] pi. Also σ2 i . As long as the Xi are pairwise independent, the variance of the sum is the sum of the variances, so we define i = Var[Xi] = E[(Xi − pi)2] = pi(1 − pi)2 + (1 − pi)p2 i = pi − p2 σ2 = Var[X] = Xi∈[n] Var[Xi] = Xi∈[n] σ2 i ≤ µ. By Chebyshev's inequality, we have Pr[X − µ ≥ d√µ] ≤ Pr[X − µ ≥ dσ] ≤ 1/d2. (2) 5 We are going to prove a stronger bound if the variables are 4-wise independent and µ ≥ 1 (and which is only stronger if d ≥ 2). Theorem 5 If the variables X0, . . . , Xn−1 ∈ {0, 1} are 4-wise independent, X = Pi∈[n] Xi, and µ = E[X] ≥ 1, then Pr[X − µ ≥ d√µ] ≤ 4/d4. Our goal is to get a good bound on the fourth moment. Xi − pi(cid:1)4] = Xi,j,k,l∈[n] Proof Note that (X − µ) =Pi∈[n](Xi − pi). By linearity of expectation, the fourth moment is: are completely independent. Suppose one of them, say, Xi, appears only once. By definition, E(cid:2)(Xi − pi)(Xj − pj)(Xk − pk)(Xl − pl)(cid:3). E[(X − µ)4] = E[(cid:0)Xi Consider a term E(cid:2)(Xi − pi)(Xj − pj)(Xk − pk)(Xl − pl)(cid:3). The at most 4 distinct variables E(cid:2)(Xi − pi)(cid:3) = 0, and since it is independent of the other factors, we get E(cid:2)(Xi − pi)(Xj − pj)(Xk − pk)(Xl − pl)(cid:3) = 0. We can therefore ignore all terms where any variable appears once. We may to the other two, yielding (cid:0)4 therefore assume that each variables appears either twice or 4 times. In terms with variables appearing twice, we have two indices a < b where a is assigned to two of i, j, k, l, while b is assigned 2(cid:1) combinations based on a < b. Thus we get E(cid:2)(Xi − pi)(Xj − pj)(Xk − pk)(Xl − pl)(cid:3) E[(X − µ)4] = Xi,j,k,l∈[n] =Xi E(cid:2)(Xi − pi)4(cid:3) +(cid:18)4 2(cid:19)Xa<b(cid:0)E(cid:2)(Xa − pa)2(cid:3)E(cid:2)(Xb − pb)2(cid:3)(cid:1) . Considering any multiplicity m = 2, 3, 4, 5, . . ., we have E[(Xi − pi)m] ≤ E[(Xi − pi)2] = σ2 i . (3) To see this, note that Xi, pi ∈ [0, 1]. Hence Xi − pi ≤ 1, so (Xi − pi)m−2 ≤ 1, and therefore (Xi − pi)m ≤ (Xi − pi)2. Continuing our calculation, we get 2(cid:19)Xa<b(cid:0)E(cid:2)(Xa − pa)2(cid:3)E(cid:2)(Xb − pb)2(cid:3)(cid:1) E(cid:2)(Xi − pi)4(cid:3) +(cid:18)4 E[(X − µ)4] =Xi i +(cid:18)4 ≤Xi ≤ σ2 + 3 Xi 2(cid:19)Xa<b i!2 σ2 aσ2 b σ2 σ2 = σ2 + 3σ4. Since σ2 ≤ µ and µ ≥ 1, we get which is our desired bound on the fourth moment. E[(X − µ)4] ≤ µ + 3µ2 ≤ 4µ2. 6 (4) (5) by Markov's inequality, Pr[X − µ ≥ d√µ] = Pr[(X − µ)4 ≥ (d√µ)4] ≤ E[(X − µ)4]/(d√µ)4 ≤ 4/d4. This completes the proof of Theorem 5. We are now ready to prove the 5-independence suffices for linear probing. Theorem 6 Suppose we use a 5-independent hash function h to store a set S of n keys in a linear probing table of size t ≥ 3 2 n where t is a power of two. Then it takes expected constant time to search, insert, or delete a key. 2ℓ =⇒ X − µ ≥ Since h is 5-independent, the Xx are 4-independent, so by Theorem 5, we get Proof First we fix the hash of the query key q. To apply Theorem 4, we need to find a bound Pℓ on the probability that 3 4 2ℓ keys from S \ {q} hash to any given ℓ-interval I. For each key x ∈ S \{q}, let Xx be the indicator variable for h(x) ∈ I. Then X =Px∈S\{q} Xx is the number of keys hashing to I, and the expectation of X is µ = E[X] = n2ℓ/t ≤ 2 3 2ℓ. Our concern is the event that 10p2ℓµ. 2ℓ(cid:21) ≤ 40000/22ℓ = O(1/22ℓ).  = O 2ℓPℓ 1 + Thus we can use Pℓ = O(1/22ℓ) in Theorem 4, and then we get that the expected operation cost is O 1 +  = O(1). Pr(cid:20)X ≥ 3 4 2ℓ/22ℓ 1 2ℓ > 1 12 log2 t Xℓ=0 X ≥ 3 4 log2 t Xℓ=0 Problem 1 Above we assumed that the range of our hash function is [t] where t is a power of two. As suggested in the introduction, we use a hash function based on a degree 4 polynomial over a prime field Zp where p ≫ 1, that is, we pick 5 independent random coefficients a0, . . . , a4 ∈ [p], and define the hash function h′ : [p] → [t] by h′(x) =(cid:16)(cid:0)a4x4 + ··· + a1x + a0(cid:1) mod p(cid:17) mod t. Then for any distinct x0, . . . , x4, the hash values h′(x0), . . . , h′(x4) are independent. Moreover, we have almost uniformity in the sense that for any x ∈ [p] and y ∈ [t], we have 1/t− 1/p < Pr[h′(x) = y] < 1/t + 1/p. Prove that Theorem 6 still holds with constant operation time if p ≥ 24t. Problem 2 Assuming full randomness, use Chernoff bounds to prove that the longest run in the hash table has length O(log n) with probability at least 1 − 1/n10. is near-full. You can then pick ℓ = C ln n for some large enough constant C. Hint. You can use Lemma 2 to prove that if there is run of length r ≥ 2ℓ+2, then some ℓ-interval Problem 3 Using Chebyshev's inequality, show that with 3-independent hashing, the expected op- eration time is O(log n). 7 3.2 Fourth moment and simple tabulation hashing In the preceding analysis we use the 5-independence of the hash function as follows. First we fix the hash of the query key. Conditioned on this fixing, we still have 4-independence in the hashes of the stored keys, and we use this 4-independence to prove the 4th moment bound (5) on the number stored keys hashing to any given interval. This was all we needed about the hash function to conclude that linear probing takes expected constant time per operation. Patra¸scu and Thorup [15] have proved that something called simple tabulation hashing, that is only 3-independent, within a constant factor provides the same 4th moment bound (5) on the number of stored keys hashing to any given interval conditioned on a fixed hash of the query key. Linear probing therefore also works in expected constant time with simple tabulation. This is important because simple tabulation is 10 times faster than 5-independence implemented with a polynomial as in (1). Simple tabulation hashing was invented by Zobrist [22] in 1970 for chess computers. The basic idea is to view a key x as consisting of c characters for some constant c, e.g., a 32-bit key could be viewed as consisting of c = 4 characters of 8 bits. We initialize c tables T1, . . . , Tc mapping characters to random hash values that are bit-strings of a certain length. A key x = (x1, ..., xc) is then hashed to T1[x1] ⊕ ··· ⊕ Tc[xc] where ⊕ denotes bit-wise xor. 4 The k-th moment The 4th moment bound used above generalizes to any even moment. First we need Theorem 7 Let X0, . . . , Xn−1 ∈ {0, 1} be k-wise independent variables for some (possibly odd) k ≥ 2. Let pi = Pr[Xi = 1] and σ2 i . Moreover, let X =Pi∈[n] Xi, µ = E[X] = Pi∈[n] pi, and σ2 = Var[X] =Pi∈[n] σ2 i = Var[Xi] = pi − p2 i . Then E[(X − µ)k] ≤ O(σ2 + σk) = O(µ + µk/2). Proof The proof is a simple generalization of the proof of Theorem 5 up to (4). We have (X − µ)k = Xi0,...,ik−1∈[n](cid:0)(Xi0 − pi0)(Xi1 − pi1)··· (Xik−1 − pik−1)(cid:1) By linearity of expectation, E[(X − µ)k] = Xi0,...,ik−1∈[n] E(cid:2)(cid:0)(Xi0 − pi0)(Xi1 − pi1)··· (Xik−1 − pik−1)(cid:1)(cid:3) We now consider a specific term Let j0 < j1 < ··· < jc−1 be the distinct indices among i0, i1, . . . , in−1, and let mh be the multiplicity of jh. Then (cid:0)(Xi0 − pi0)(Xi1 − pi1)··· (Xik−1 − pik−1)(cid:1) (cid:0)(Xi0 − pi0)(Xi1 − pi1)··· (Xik−1 − pik−1)(cid:1) =(cid:0)(Xj0 − pj0)m0 (Xj1 − pj1)m1 ··· (Xjc−1 − pjc−1)mc−1(cid:1) . 8 The product involves at most k different variables so they are all independent, and therefore E(cid:2)(cid:0)(Xj0 − pj0)m0(Xj1 − pj1)m1 ··· (Xjc−1 − pjc−1)mc−1(cid:1)(cid:3) = E [(Xj0 − pj0)m0 ] E [(Xj1 − pj1)m1] ··· E(cid:2)(Xjc−1 − pjc−1)mc−1(cid:3) Now, for any i ∈ [n], E[Xi − pi] = 0, so if any multiplicity is 1, the expected value is zero. We therefore only need to count terms where all multiplicities mh are at least 2. The sum of multiplicities is Ph∈[c] mh = k, so we conclude that there are c ≤ k/2 distinct indices j0, . . . , jc−1. Now by (3), E [(Xj0 − pj0)m0 ] E [(Xj1 − pj1)m1] ··· E(cid:2)(Xjc−1 − pjc−1)mc−1(cid:3) ≤ σ2 j0σ2 j1 ··· σ2 jc−1. We now want to bound the number tuples (i0, i1, . . . , ik−1) that have the same c distinct indices j0 < j1 < ··· < jc−1. A crude upper bound is that we have c choices for each ih, hence ck tuples. We therefore conclude that ⌊k/2⌋ ≤ ≤ ⌊k/2⌋ σ2 j0σ2 jc−1  E[(X − µ)k] = Xi0,...,ik−1∈[n] E(cid:2)(cid:0)(Xi0 − pi0)(Xi1 − pi1)··· (Xik−1 − pik−1)(cid:1)(cid:3)  Xc=1 X0≤j0<j1<···<jc−1<n ck  c! Xj0,j1,...,jc−1∈[n] Xc=1  c c!  j  Xj∈[n] Xc=1    Xc=1 (cid:18) ck σ2c(cid:19) = O(cid:16)σ2 + σk(cid:17) = O(cid:16)µ + µk/2(cid:17) . j1 ··· σ2 jc−1  j1 ··· σ2 σ2 j0σ2 ⌊k/2⌋ ≤ = ck ck c! ⌊k/2⌋ σ2 Above we used that c, k = O(1) hence that, e.g., ck = O(1). This completes the proof of Theorem 7. For even moments, we now get a corresponding error probability bound Corollary 8 Let X0, . . . .Xn−1 ∈ {0, 1} be k-wise independent variables for some even constant k ≥ 2. Let pi = Pr[Xi = 1] and σ2 i . Moreover, let X =Pi∈[n] Xi, µ = E[X] = Pi∈[n] pi, and σ2 = Var[X] =Pi∈[n] σ2 i = Var[Xi] = pi − p2 i . If µ = Ω(1), then Pr[X − µ ≥ d√µ] = O(1/dk). 9 Proof By Theorem 7 and Markov's inequality, we get Pr[X − µ ≥ d√µ] = Pr[(X − µ)k ≥ dkµk/2] dkµk/2 ≤ = E[(X − µ)k] O(cid:0)µ + µ⌊k/2⌋(cid:1) dkµk/2 = O(1/dk). Problem 4 In the proofs of this section, where and why do we need that (a) k is a constant and (b) that k is even. 5 Bloom filters via linear probing We will now show how we can reduce the space of a linear probing table if we are willing to allow for a small chance of false positives, that is, the table attemps to answer if a query q is in the current stored set S. If it answers "no", then q 6∈ S. If q ∈ S, then it always answers "yes". However, even if q 6∈ S, then with some probability ≤ P , the table may answer "yes". Bloom [4] was the first to suggest creating such a filter using less space than one giving exact answers. Our implementation here, using linear probing, is completely different. The author suggested this use of linear probing to various people in the late 90ties, but it was never written down. To create a filter, we use a universal hash function s : [u] → [2b]. We call s(x) the signature of x. The point is that s(x) should be much smaller than x, that is, b ≪ log2 u. The linear probing array T is now only an array of t signatures. We still use the hash function h : [u] → [t] to start the search for a key in the array. Thus, to check if a key q is positive in the filter, we look for s(q) among the signatures in T from location h(q) and onwards until the first empty locatition. If s(q) is found, we report "yes"; otherwise "no". If we want to include q to the filter, we only do something if s(q) was not found. Then we place s(q) it in the first empty location. Our filter does not support deletion of keys (c.f. Problem 6). Theorem 9 Assume that the hash function h and the signature function s are independent, that h is 5-independent, and that s is universal. Then the probability of a false positive on a given key q 6∈ S is O(1/2b). Proof The keys from S have been inserted in some given order. Let us assume that h is fixed. Suppose we inserted the keys exactly, that is, not just their signatures, and let X(q) be the set of keys encountered when searching for q, that is, X(q) is the set of keys from h(q) and till the first empty location. Note that X(q) depends only on h, not on s. In Problem 5 you will argue that if q is a false positive, then s(q) = s(x) for some x ∈ X(q). For every key x ∈ [u] \ {q}, by universality of s, we have Pr[s(x) = s(q)] ≤ 1/2b. Since q 6∈ S ⊇ X(q), by union, Pr[∃x ∈ X(q) : s(x) = s(q)] ≤ X(q)/2b. It follows that the probability 10 that q is a false positive is bounded by Pr[X(q) = Y ] · Y /2b = E[X(q)]/2b. XY ⊆S By Theorem 6, E[X(q)] = O(1) when h is 5-independent. Problem 5 To complete the proof of Theorem 9, consider a sequence x1, . . . , xn of distinct keys in- serted in an exact linear probing table (as defined in Section 2). Also, let xi1, ..., xim be a subequence of these keys, that is, 1 ≤ i1 < i2 < ··· < im ≤ n. The task is to prove any fixed h : [u] → [t] and any fixed j ∈ [t], that when only the subsequence is inserted, then the sequence of keys encountered from location j and till the first empty location is a subsequence of those encountered when the full sequence is inserted. Hint. Using induction on n, show that the above statement is preserved when a new key xn+1 is added. Here xn+1 may or may not be part of the subsequence. The relation to the proof of Theorem 9 is that when we insert keys in a filter, we skip keys whose signatures are found as false postives. This means that only a subsequence of the keys have their signatures inserted. When searching for a key q starting from from location j = h(q), we have thus proved that we only consider (signatures of ) a subset of the set X(q) of keys that we would have considered if all keys where inserted. In particular, this means that if we from j encounter a key x with s(x) = s(q), then x ∈ X(q) as required for the proof of Theorem 9. Problem 6 Discuss why we canot support deletions. Problem 7 What would happen if we instead used h(s(x)) as the hash function to place or find x? What would be the probability of a false positive? Sometimes it is faster to generate the hash values and signatures together so that the pairs (h(x), s(x)) are 5-independent while the hash values and signatures are not necessarily independent of each other. An example is if we generate a larger hash value, using high-order bits for h(x) and low-order bits for s(x). In this situation we get a somewhat weaker bound than that in Theorem 9. Theorem 10 Assuming that x 7→ (h(x), s(x)) is 5-independent, the probability of a false positive on a given key q 6∈ S is O(1/22b/3). Proof Considering the exact insertion of all keys, we consider two cases. Either (a) there is a run of length at least 2b/3 around h(q), or (b) there is no such run. For case (a), we use Lemma 3 together with the bound Pℓ = O(1/22ℓ) from the proof of Theorem 4. We get that the probability of getting a run of length at least 2b/3 is bounded by ∞ Xℓ=b/3−2 12Pℓ = O(1/22b/3). We now consider case (b). By the statement proved in Problem 5, we know that any signature s(x) considered is from a key x from the set X(q) of keys that we would have considered from j = h(q) if all keys were inserted exactly. With no run of length at least 2b/3, all keys in X(q) must hash 11 to (h(q) − 2b/3, h(q) + 2b/3]. Thus, if we get a false positive in case (b), it is because there is a key x ∈ S with s(x) = s(q) and h(x) ∈ (h(q) − 2b/3, h(q) + 2b/3]. Since (h(x), s(x)) and (h(q), s(q)) are independent, the probability that this happens for x is bounded by 21+b/3/(t2b) = O(1/(n22b/3)), yeilding O(1/22b/3) when we sum over all n keys in S. By union, the probability of a false positive in case (a) or (b) is bounded by O(1/22b/3), as desired. We note that with the simple tabulation mentioned in Section 3.2, we can put hash-signature pairs as concatenated bit strings in the character tables T1, . . . , Tc. Then (h(x), s(x)) = T1[x1]⊕···⊕ Tc[xc]. The nice thing here is that with simple tabulation hashing, the output bits are all completely independent, which means that Theorem 9 applies even though we generate the hash-signature pairs together. References [1] Noga Alon, Martin Dietzfelbinger, Peter Bro Miltersen, Erez Petrank, and G´abor Tardos. Linear hash functions. J. ACM, 46(5):667–683, 1999. [2] Noga Alon and Asaf Nussboim. k-wise independent random graphs. In Proc. 49th IEEE Symposium on Foundations of Computer Science (FOCS), pages 813–822, 2008. [3] John R. Black, Charles U. Martel, and Hongbin Qi. Graph and hashing algorithms for modern architectures: Design and performance. In Proc. 2nd International Workshop on Algorithm Engineering (WAE), pages 37–48, 1998. [4] Burton H. Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422–426, 1970. [5] Larry Carter and Mark N. Wegman. Universal classes of hash functions. Journal of Computer and System Sciences, 18(2):143–154, 1979. Announced at STOC'77. [6] Martin Dietzfelbinger and Ulf Schellbach. On risks of using cuckoo hashing with simple uni- versal hash classes. In Proc. 20th ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 795–804, 2009. [7] Michael L. Fredman, J´anos Koml´os, and Endre Szemer´edi. Storing a sparse table with 0(1) worst case access time. Journal of the ACM, 31(3):538–544, 1984. Announced at FOCS'82. [8] Gregory L. Heileman and Wenbin Luo. How caching affects hashing. In Proc. 7th Workshop on Algorithm Engineering and Experiments (ALENEX), pages 141–154, 2005. [9] Daniel M. Kane Jeffery S. Cohen. Bounds on the independence required for cuckoo hashing, 2009. Manuscript. [10] Howard J. Karloff and Prabhakar Raghavan. Randomized algorithms and pseudorandom num- bers. Journal of the ACM, 40(3):454–476, 1993. [11] Donald E. Knuth. Notes on open addressing. Unpublished memorandum. See http://citeseer.ist.psu.edu/knuth63notes.html, 1963. 12 [12] Donald E. Knuth. The Art of Computer Programming, Volume III: Sorting and Searching. Addison-Wesley, 1973. [13] Anna Pagh, Rasmus Pagh, and Milan Ruzi´c. Linear probing with constant independence. SIAM Journal on Computing, 39(3):1107–1120, 2009. Announced at STOC'07. [14] Rasmus Pagh and Flemming Friche Rodler. Cuckoo hashing. Journal of Algorithms, 51(2):122– 144, 2004. Announced at ESA'01. [15] Mihai Patra¸scu and Mikkel Thorup. The power of simple tabulation-based hashing. Journal of the ACM, 59(3):Article 14, 2012. Announced at STOC'11. [16] Mihai Patra¸scu and Mikkel Thorup. On the k -independence required by linear probing and minw ise independence. ACM Transactions on Algorithms, 12(1):Article 8, 2016. Announced at ICALP'10. [17] Jeanette P. Schmidt and Alan Siegel. The analysis of closed hashing under limited randomness. In Proc. 22nd ACM Symposium on Theory of Computing (STOC), pages 224–234, 1990. [18] Jeanette P. Schmidt, Alan Siegel, and Aravind Srinivasan. Chernoff-Hoeffding bounds for applications with limited independence. SIAM Journal on Discrete Mathematics, 8(2):223– 250, 1995. Announced at SODA'93. [19] Alan Siegel and Jeanette P. Schmidt. Closed hashing is computable and optimally random- izable with universal hash functions. Technical Report TR1995-687, Courant Institute, New York University, 1995. [20] Mikkel Thorup and Yin Zhang. Tabulation-based 5-independent hashing with applications to linear probing and second moment estimation. SIAM Journal on Computing, 41(2):293–331, 2012. Announced at SODA'04 and ALENEX'10. [21] Mark N. Wegman and Larry Carter. New classes and applications of hash functions. Journal of Computer and System Sciences, 22(3):265–279, 1981. Announced at FOCS'79. [22] Albert Lindsey Zobrist. A new hashing method with application for game playing. Technical Report 88, Computer Sciences Department, University of Wisconsin, Madison, Wisconsin, 1970. 13
1611.04156
1
1611
2016-11-13T16:51:51
Planning system for deliveries in Medell\'in
[ "cs.DS" ]
Here we present the implementation of an application capable of planning the shortest delivery route in the city of Medell\'in, Colombia. We discuss the different approaches to this problem which is similar to the famous Traveling Salesman Problem (TSP), but differs in the fact that, in our problem, we can visit each place (or vertex) more than once. Solving this problem is important since it would help people, especially stores with delivering services, to save time and money spent in fuel, because they can plan any route in an efficient way.
cs.DS
cs
Planning system for deliveries in Medellín Catalina Patiño-Forero Mateo Agudelo-Toro Universidad EAFIT Medellín, Colombia [email protected] Universidad EAFIT Medellín, Colombia [email protected] Mauricio Toro Universidad EAFIT Medellín, Colombia [email protected] ABSTRACT Here we present the implementation of an application capable of planning the shortest delivery route in the city of Medellín, Colombia. We discuss the different approaches to this problem which is similar to the famous Traveling Salesman Problem (TSP), but differs in the fact that, in our problem, we can visit each place (or vertex) more than once. Solving this problem is important since it would help people, especially stores with delivering services, to save time and money spent in fuel, because they can plan any route in an efficient way. To solve this we need to construct a subgraph with the delivering points, based on the city's map, and it will be a complete one i.e. all of its vertices are connected. Then we will give the user different options that will determine which algorithm will be used to solve the problem. Between these options there is only one that will surely give the shortest route and works only with twenty or less points. The other options are quite fast but may or may not give the shortest route. Depending on the chosen algorithm, the results in time, memory and total distance will vary. For example, we have an algorithm that does not create a subgraph to give an answer, so it takes less memory and time, but will not give the total distance. Others can give a better answer quite fast, even though they require to compute a subgraph, but still the tour produced may not be the shortest one. At last, there is an algorithm that can give the shortest route every time, but needs to look through all possible answers so it takes much more time. For the problem of planning delivery routes in Medellín our proposed solution to find the shortest route can be of huge help for small companies if their couriers do not visit more than 20 points per trip. Author Keywords Planning, deliveries, routing, graph, complexity, shortest path. ACM Classification Keywords Theory of computation → Design and analysis of algorithms → Approximation algorithms analysis → Routing and network design problems 1. INTRODUCTION Efficiently planning the deliveries is something really useful for any company in the field. Here we talk about creating an efficient program that gives an optimal delivering route for a courier, in order to minimize the time spent traveling; the courier can pass over one place more than once. Without this last condition we would have a TSP which, though it is a "simple" problem formulated over 200 years ago [9], does not have any optimal solution for big graphs (thousands of vertexes). Since it is simpler (and possible) to treat our problem as TSP, we are going to do so. We will see the different approaches to this problem and also discuss the selection of the best available choice for our specific case. 2. PROBLEM As we just stated, we are trying to create an efficient program that gives an optimal (shortest total distance) delivering route for a courier, which minimizes the time spent traveling; this route can repeat places which were already visited. In our case, we will implement it for the city of Medellín in Colombia, but it does not mean the algorithm cannot be used for other cities. This efficient route planning request is quite difficult to compute if we want to get an optimal answer. This is due the incredible amount of possibilities we will have, since the idea is to use the algorithm for real cities, for example Medellín, which has a population that surpasses the 2 million people [11]. So it is to be expected that the algorithm will take an incredible amount of time to give an appropriate answer, time that may exceed what we can spend on it. We can take the TSP as an example, which requires a time proportional to (n-1)!/2 to execute (where n is the number of places or nodes) [10], which means that for 20 destinations it would require a about 12 years to compute using an average computer. We will treat our problem as TSP but using a faster algorithm that requires less than 3 seconds to compute the path for 20 points, but that would require 14 years for 45 points on the same computer. 3. RELATED WORK 3.1 Minimum Spanning Tree (MST) Given a weighted graph, the MST is the cheapest subset of edges that keeps the graph in one connected component [1]. Those are very useful because they give approximate solutions to the traveling salesman problem very efficiently. One efficient way to compute the MST of a graph is the Kruskal's algorithm. It is a greedy algorithm that starts by placing each vertex on its own connected component. It then iterates over the edges having them sorted in non-descending order, merging the two vertices connected by the current edge if, and only if, they are currently on different components. The complexity of this algorithm is O(m*log(m)) where m is the number of edges. 3.2 Hamiltonian Path and Cycle A Hamiltonian Path is a path between two vertices of a graph that visits each vertex exactly once [5]. A Hamiltonian Cycle is a closed loop through a graph that visits each node exactly once [6]. A closed loop is a cycle in a graph in which the first vertex is the same as the last [7]. A graph possessing a Hamiltonian Path is said to be a Hamiltonian Graph [8]. There is a backtracking approach to find whether an undirected graph is Hamiltonian. We start by creating an empty array and adding vertex 0 to it. We will try to add the other vertices starting from 1, but before that, we check whether it is adjacent to the previously added vertex and if it is not already added. If we find such vertex, we add it as part of the solution. If we do not find a vertex then we return false [1]. Anyway, the complexity of this algorithm is O(n!) where n is the number of vertices, just like the naïve approach. 3.3 Eulerian Path and Cycle An Eulerian Path is a path in a graph that visits each edge exactly once [3], and an Eulerian Cycle is an Eulerian Path which starts and ends in the same vertex [2]. It is similar to the Hamiltonian path because in both we want to visit some part of the graph only once. The difference is that in this case we want to walk through each edge instead of visiting each vertex. This difference changes everything: while the Hamiltonian path is an NP-Complete problem for a general graph, finding whether a given graph is Eulerian (has an Eulerian Cycle) can be done in O(n + m), where n is the number of vertices in the graph and m the number of edges. To find whether a undirected graph is Eulerian it must have all its non-zero degree vertices connected (which can be done using a DFS traversal) and the number of vertices with odd degree must be 1 (if it is 2 then the graph has a Eulerian Path instead) [4]. 3.4 Chinese Postman Problem (CPP) In this problem, given a weighted graph, the postman wants to find the shortest path that visits every edge at least once returning to the starting point. This problem can be solved in an optimal way by adding the appropriate edges to the graph to make it Eulerian, because that is basically what the problem is: finding an (especial) Eulerian Cycle in the graph. Specifically, we find the shortest path between each pair of odd-degree vertices in the graph. Adding a path between two odd-degree vertices in G turns both of them to even-degree, moving G closer to becoming an Eulerian graph. Finding the best set of shortest paths to add to G reduces to identifying a minimum-weight perfect matching in a special graph G'. For undirected graphs, the vertices of G' correspond the odd-degree vertices of G, with the weight of edge (i, j) defined to be the length of the shortest path from i to j in G. For directed graphs, the vertices of G' correspond to the degree- imbalanced vertices from G, with the bonus that all edges in G' go from out-degree deficient vertices to in-degree deficient ones. Thus, bipartite matching algorithms suffice when G is directed [1]. Once the graph is Eulerian, the actual cycle can be extracted using the algorithm described above. 4. DATA STRUCTURES To implement our algorithm, we need two graphs: one to store the city itself and other to store the points we need to visit. For the graph of the city, we use adjacency list representation. To achieve this we created four classes: vertex, edge, point and pair. The first two, vertex and edge, are used directly on the representation of the graph: we use HashMaps with vertex objects as keys and edge objects as values. Point class represents the latitude and longitude of the vertex in the world, and is used to access vertices given its latitude and longitude. Pair objects are used during the execution of A* and Dijkstra's algorithm, which require a priority queue of vertices (first value of the pair) sorted by some value acquired during the execution of the algorithm (second value of the pair). The other is a complete graph that contains only the vertices we want to visit. It is stored as an adjacency matrix, using a primitive double's 2D array with dynamically assigned integer codes to vertices (used as indices), and where the edges are completed using either Dijkstra's or A* algorithms on the city's graph (depending on the amount of points). Since it is a complete graph, using an adjacency matrix is better than an adjacency list, because both need the same memory space, but the adjacency matrix is faster when looking up for the distance between any two vertices and that is a main requirement of our algorithms. There are other auxiliary data structures used during the execution of different parts of the program. The Natural Approximation algorithm uses a HashMap with vertices as keys and integers as values to remember the original positions of the vertices to visit. To read the vertices the user wants to visit, we use a HashMap with points as keys and vertices as values, because the URL only contains information about the point and not the vertex itself. When reading the edges, we use a HashMap with the code of the vertices (long data type) as keys and vertices as values to access the vertices in the graph since the edge's specifications contain only the codes of the vertices it connects and its cost (distance). In the case where the user gives a point that it is not in our map, we compute a close enough one and use a HashMap with vertex objects as keys and point objects as values to store the original points of the approximated vertices we found. This is done with the aim of returning to the user the same points he or she entered. Finally, we use ArrayLists of vertex objects to store both the points entered by the user and the generated tours. The reason to use HashMaps is that we do not require our mapping to be stored in order, which allows us to use the most efficient map available in Java. 5. ALGORITHM First, the program creates the city's graph by reading its specifications which are given in two text files, one for the vertices and other for the edges. Then it reads the URL containing the points from the user, the program finds the nearest vertex to the ones corresponding to the given coordinates, which can be the exact same point. After this, the program will compute the complete subgraph containing only the points of interest. In order to create the subgraph the program will choose between two different algorithms, depending on the number of nodes given by the user: A* algorithm is used if this number is less or equal to five, otherwise it uses Dijkstra's algorithm. For the heuristic of the A* algorithm, it uses the Manhattan distance. Then it will execute one of the following three algorithms, according to user's choice: 1. Natural approximation: the algorithm is a simple sort over the vertices using its 2D coordinates, using a custom comparator to determine whether a point is to the left or to the right of another. This algorithm has two versions: the first (or the fastest) version just performs the sort described above and completes the tour adding the initial vertex, while the second version does the same as the first one, but also computes the subgraph and the reverse tour, compares both total lengths and returns the best tour. Notice that the fastest version does not generate the subgraph. The method for comparing the points is based on [11]. 2. Nearest neighbor: This algorithm starts with the first vertex and greedily chooses the nearest neighbor and moves to it. It keeps doing the same thing until all the vertices are visited. Finally, it adds the starting vertex to the end in order to complete the tour. This algorithm will not always give an optimal solution, but it's execution time is much faster than the brute force and can produces better tours than natural approximation. 3. Brute force: we try every possible path starting with the initial vertex, ending at i and passing through all the other vertices different to i. To this path we add the distance from i to the initial vertex to complete the tour. We now present the complexity analysis for the algorithms where n is the number of points to visit, E the number of edges (335719) and V the number of vertices (179403) in the city's graph. Table 1. Complexity table 6. IMPLEMENTATION When starting the program the first thing the user will see is an "Initializing" signal, shown to make the user wait until the program builds the city's graph. After this, the program will show the time required to build the city's graph and ask for the Google Maps URL containing the points to be visited (Figure 1). If the user inputs an invalid URL, the program will tell so and then ask again for a new one (Figure 1). It will repeat this process until the user gives a valid input. If the user wants to end the program from here, he or she may input an 'x' (lower or upper case) as URL and the program will finish. Figure 1. Starting the program and invalid URL After this, the program shows a warning telling the user that the route given by our program may differ with Google's because the points we used to build the city's graph are different. Then offers a menu with 6 or 7 different options (Figure 2), depending on how many points were given, to compute a tour which covers all the given points and comes back to the first one (the user should not add the first point at the end of the path). Figure 2. Program's menu The first five options are to choose the way the user wants the program to calculate the route, after choosing, the program will show the time needed to generate the route and will take the user to a Google Maps page where he or she can see this route. Since the options number two, three, four and five need to internally create a subgraph, the first time any of these options is chosen, the program will show the time spent creating it. 1. 2. 3. 4. 5. 6. 7. "Natural approximation fast mode" will present a route that tends to be circular and, compared with the other options, it is the fastest, but it will not give any distance and may not show the shortest route. "Natural approximation normal mode" will also present a route that tends to be circular, but this time shows the total distance and may even show a route that is shorter than the one obtained using last mode, although it may still not be the shortest possible route. "Nearest Neighbor" will give a route formed by finding the closest point from the current one, and then move to it. This process will repeat until reaching the last point (corresponding to the first one). It may not give the shortest possible route and its execution time is similar to the second option. This option shows total distance too. "The best of both" will choose the best route between the ones generated by last two options and show the total distance; this will take a little more time. We encourage its usage when there are more than 20 points in the URL and the user wants the shortest route. "Exact" will always show the shortest route with its respective distance. It is potentially much slower than the other options, reason why is not present in the menu when the URL has more than twenty points, since that would take a lot of time. If the user wants, he can expand the maximum of points he or she can input to 'unlimited'. For this, when the program asks for an URL (either when starting the program or changing the current one) "extreme-mode" must be written and press the enter key, then a warning will appear and the program will ask for the URL to continue as usual. "Change URL" lets the user change the current URL, if the new URL is not valid it will indicate so and ask for a new one; if the given input is an 'x' the program will end. "Exit" will end the program. Something important to consider is that, when the URL contains at least two points that are not connected between them, the program cannot calculate a distance, so it will tell the user so MemoryTimeBuild subgraphO(n2)O(n(E+VlogV))Brute ForceO(n2n)O(n22n)Nearest NeighborO(n)O(n2)Natural approximation (Normal mode)O(n)O(nlogn)Natural approximation (Fast mode)O(n)O(nlogn)AlgorithmWost case complexity and use the first option ("Natural approximation fast mode") to compute a possible route. 7. RESULTS WITH THE MAP OF MEDELLÍN 7.1 Execution Time The following table shows the time in seconds that each algorithm takes to process a route for a different number of vertices. The time required to build the subgraph for that same amount of points is also shown. Considering current limits imposed by Google Maps in terms of the available amounts of destinations for a single route (ten vertices), it is easy to notice that our algorithm will run in feasible time even when looking for an optimal solution after building the subgraph, and in under two seconds if it has not been build. 7.2 Memory space The following table shows the memory in megabytes that each algorithm takes to process a route for a different number of vertices. Is important to notice that the memory used by the subgraph can only be included in the algorithms that need it. Table 2. Execution time (seconds) on a Core i7 2410u processor. Remember that the Natural Approximation (Fast mode) does not require the subgraph to be computed by the time it is called. For the rest of the algorithms, the program only needs to compute the subgraph once, because after building it, it will be saved and reused until a new subgraph is required (new URL). As expected, the brute force algorithm is the slower one. For the others, it is hard to compare their running times with such a little amount of vertices. Table 3. Memory used (in MB) Is easy to notice that for all algorithms, except brute force, the memory is almost constant. This is due, the amount of vertices is not enough to show any difference. In the other hand, one can see the incredible difference in memory used by the brute force algorithm. This was expected since the memory use increase exponentially (O(n2n)). In graphic 3 we plot the obtained results. Graphic 1. Brute force's execution time on a Core i7 2410U processor. Graphic 3. Memory for Brute force 7.3 Total distance The following graphic shows the total distance (in meters) of the routes found as shortest by the different algorithms for random sets of points. Graphic 2. Subgraph construction time on a Core i7 2410U processor. 5101520Build subgraph0,41821,51462,14482,7558Brute Force00,00140,04282,1206Best of Both000,00010,0002Nearest Neighbor0000Natural approximation (Normal mode)0000Natural approximation (Fast mode)0000VerticesAlgorithm510152024Build subgraph275873111136Brute Force0121004771Nearest Neighbor34344Natural approximation (Normal mode)33343Natural approximation (Fast mode)24444VerticesAlgorithm Graphic 4. Total distance http://mathworld.wolfram.com/EulerianCycle.html. [Accessed 27 August 2016]. [3] E. W. Weisstein, "Eulerian Path," Wolfram MathWord, Available: [Online]. http://mathworld.wolfram.com/EulerianPath.html. [Accessed 28 August 2016]. [4] GeeksForGeeks, "Eulerian path and circuit for undirected [Online]. Available: http://www.geeksforgeeks.org/eulerian-path- and-circuit/. [Accessed 28 August 2016]. graph," GeeksForGeeks, [5] E. W. Weisstein, "Hamiltonian Path," Wolfram Available: MathWorld, http://mathworld.wolfram.com/HamiltonianPath.html. [Accessed 28 August 2016]. [Online]. [6] E. W. Weisstein, "Hamiltonian Cycle," Wolfram MathWorld, Available: http://mathworld.wolfram.com/HamiltonianCycle.html. [Accessed 28 August 2016]. [Online]. [7] E. W. Weisstein, "Graph Cycle," Wolfram MathWorld, Available: [Online]. http://mathworld.wolfram.com/GraphCycle.html. [Accessed 28 August 2016]. [8] GeeksForGeeks, "Backtracking Set 6 (Hamiltonian [Online]. Available: Cycle)," GeeksForGeeks, http://www.geeksforgeeks.org/backtracking-set-7- hamiltonian-cycle/. [Accessed 28 August 2016]. [9] University of Waterloo, "History of University of Waterloo, Enero 2007. Available: http://www.math.uwaterloo.ca/tsp/history/index.html. [Accessed 28 August 2016]. the TSP," [Online]. [10] A. Levitin, Introduction to The Design and Analysis of Algorithms, 3rd Edition, New Jersey: Pearson, 2012, p. 116. [11] C. e. dos, "Github," 18 Abril 2016. [Online]. Available: https://github.com/mvpossum/eldiego/blob/master/geo metria/orden.radial.cpp. [Accessed 4 September 2016]. Graphic 4 shows how volatile Nearest Neighbor and Natural Approximation algorithms are: in one case they got the optimal answer whereas in other cases both obtained longer routes than the optimal solution with a difference higher than 10 kilometers. The code can be found at https://subversion.assembla.com/svn/planningdeliverysystemme dellin/ 8. CONCLUSIONS The problem to calculate a delivery route given some points in a map is not new and has been researched for years. As prove to that, we can find the famous Traveling Salesman Problem or TSP, in which the delivery route may not have repeated points, except for the first one, that is the last one at the same time. This problem was defined in the 1800s and even today, there are not any algorithms that can give the best route efficiently: we still have to choose between efficiency and precision. For the problem of planning delivery routes in Medellín, that can be modeled as the TSP problem, our proposed solution can be of huge help for small companies when their couriers go out for a route because it's unlikely that, on a single trip, they will visit more than 20 points. If the delivery route can consider repeated points it will be harder to solve, so is better to simply solve TSP. The biggest problem is to find an efficient way to give an answer: algorithms that can give optimal answers require a lot of time and memory, to the point that they cannot be used for big graphs, and algorithms that can give an answer without consuming too much resources, may not be able to give the shortest route. Even if we apply all possible optimizations to the code, it is still not enough to efficiently compute an optimal solution. Thanks to this work, we were able to understand the limitations a computer has and the need of implementing efficient algorithms with the appropriate data structures, otherwise a program could take too much time to execute, time that the user is not able or willing to spend waiting, since it can get to a point where it needs years to compute an answer. And this gets worse considering that right now we are living in a world were a lot of data is stored, and only accessing it may take a lot of the computer's resources. 9. FUTURE WORK Currently, there are two big limitations we would like to fix in the future: 1. Our graph does not fit Google Map's very well, which makes the distances and the routes to be shown in a very different way in many cases. 2. The only way to add more than 10 points on a route is by working with the URL and the points' latitude and longitude. 10. REFERENCES [1] S. Skiena, The Algorithm Design Manual, New York: Springer, 2008. [2] E. W. Weisstein, MathWorld, "Eulerian Cycle," Wolfram [Online]. Available:
1907.00524
1
1907
2019-07-01T03:07:49
Approximate $\mathbb{F}_2$-Sketching of Valuation Functions
[ "cs.DS" ]
We study the problem of constructing a linear sketch of minimum dimension that allows approximation of a given real-valued function $f \colon \mathbb{F}_2^n \rightarrow \mathbb R$ with small expected squared error. We develop a general theory of linear sketching for such functions through which we analyze their dimension for most commonly studied types of valuation functions: additive, budget-additive, coverage, $\alpha$-Lipschitz submodular and matroid rank functions. This gives a characterization of how many bits of information have to be stored about the input $x$ so that one can compute $f$ under additive updates to its coordinates. Our results are tight in most cases and we also give extensions to the distributional version of the problem where the input $x \in \mathbb{F}_2^n$ is generated uniformly at random. Using known connections with dynamic streaming algorithms, both upper and lower bounds on dimension obtained in our work extend to the space complexity of algorithms evaluating $f(x)$ under long sequences of additive updates to the input $x$ presented as a stream. Similar results hold for simultaneous communication in a distributed setting.
cs.DS
cs
Approximate F2-Sketching of Valuation Functions Grigory Yaroslavtsev∗ Samson Zhou† July 2, 2019 Abstract We study the problem of constructing a linear sketch of minimum dimension that allows approximation of a given real-valued function f : Fn 2 → R with small expected squared error. We develop a general theory of linear sketching for such functions through which we analyze their dimension for most commonly studied types of valuation functions: additive, budget-additive, coverage, α-Lipschitz submodular and matroid rank functions. This gives a characterization of how many bits of information have to be stored about the input x so that one can compute f under additive updates to its coordinates. Our results are tight in most cases and we also give extensions to the distributional version of the problem where the input x ∈ Fn 2 is generated uniformly at random. Using known connections with dynamic streaming algorithms, both upper and lower bounds on dimension obtained in our work extend to the space complexity of algorithms evaluating f (x) under long sequences of additive updates to the input x presented as a stream. Similar results hold for simultaneous communication in a distributed setting. 1 Introduction Linear sketching is a fundamental tool in efficient algorithm design that has enabled many of the recent breakthroughs in fast graph algorithms and computational linear algebra. It has a wide range of applications, including randomized numerical linear algebra (see survey [Woo14]), graph sparsification (see survey [McG14]), frequency estimation [AMS99], dimensionality reduction [JL84], various forms of sampling, signal processing, and communication complexity. In fact, linear sketching has been shown to be the optimal algorithmic technique [LNW14, AHLW16] for dynamic data streams, where elements can be both inserted and deleted. Linear sketching is also a frequently used tool in distributed computing -- summaries communicated between the processors in massively parallel computational models are often linear sketches. In this paper we introduce a study of approximate linear sketching over F2 (approximate F2- sketching). This is a previously unstudied but natural generalization of the work of [KMSY18], which studies exact F2-sketching. For a set S ⊆ [n] let χS : Fn 2 → F2 be a parity function defined as χS(x) =Pi∈S xi. Given a function f : Fn 2 → R, we are looking for a distribution over k subsets S1, . . . , Sk ⊆ [n] such that for any input x, it should be possible to compute f (x) with expected squared error at most ǫ from the parities χS1(x), χS2 (x), . . . , χSk (x) computed over these sets. While looking only at linear functions over F2 as candidate sketches for evaluating f might seem ∗Indiana University, Bloomington, IN., USA & The Alan Turing Institute, London, UK. [email protected] †Indiana University, Bloomington, IN., USA. [email protected] 1 restrictive, this view turns out to be optimal in a number of settings. In the light of recent results of [KMSY18, HLY18], the complexity of F2-sketching also characterizes the space complexity of streaming algorithms in the XOR-update model as well as communication complexity of one-way multiplayer broadcasting protocols for XOR-functions. In matrix form, F2-sketching corresponds to multiplication over F2 of the row vector x ∈ Fn a random n × k matrix whose i-th column is the characteristic vector of χSi: 2 by (cid:0) x1 x2 . . . xn(cid:1)  ... ... χS1 χS2 ... ... ... ... . . . χSk ... ...  = (cid:0) χS1(x) χS2(x) . . . χSk (x)(cid:1) The goal is to minimize k, ensuring that the sketch alone is sufficient for computing f with expected squared error at most ǫ for any fixed input x. For a fixed distribution D of x, the definition of error is modified to include an expectation over D in the error guarantee. We give formal definitions below. Definition 1.1 (Exact F2-sketching, [KMSY18]). The exact randomized F2-sketch complexity with error δ of a function f : Fn δ (f )) is the smallest integer k such that there exists a distribution χS1, χS2, . . . , χSk over k linear functions over Fn 2 and a post-processing function g : Fk 2 → R (denoted as Rlin 2 → R that satisfies: ∀x ∈ Fn 2 : Pr S1,...,Sk [g(χS1 (x), χS2(x), . . . , χSk (x)) = f (x)] ≥ 1 − δ. The number of parities k in the definition above is referred to as the dimension of the F2-sketch. Definition 1.2 (Approximate F2-sketching). The ǫ-approximate randomized F2-sketch complexity of a function f : Fn ǫ (f )) is the smallest integer k such that there exists a distribution χS1, χS2, . . . , χSk over k linear functions over Fn 2 and a post-processing function g : Fk 2 → R (denoted as ¯Rlin 2 → R that satisfies: ∀x ∈ Fn 2 : E S1,...,Sk(cid:2)(g(χS1 (x), χS2 (x), . . . , χSk (x)) − f (x))2(cid:3) ≤ ǫ If g is an unbiased estimator of f , then this corresponds to an upper bound on the variance of the estimator. For example, functions with small spectral norm (e.g. coverage functions, Corollary A.4) admit such approximate F2-sketches. Moreover, observe that Definition 1.2 is not quite comparable with an epsilon-delta guarantee, which only promises that g(χS1 (x), χS2(x), . . . , χSk (x))−f (x) ≤ ǫ with probability 1 − δ, but guarantees nothing for δ fraction of the inputs. In addition to this worst-case guarantee, we also consider the same problem for x from a certain distribution. In this case, a weaker guarantee is required, i.e. the bound on expected squared error should hold only over some fixed known distribution D. An important case is D = U (Fn 2 ), the uniform distribution over all inputs. Definition 1.3 (Approximate distributional F2-sketching). For a function f : Fn 2 → R, we define its ǫ-approximate randomized distributional F2-sketch complexity with respect to a distribution D over Fn (f )) as the smallest integer k such that there exists a distribution χS1, χS2, . . . , χSk over k linear functions over F2 and a post-processing function g : Fk 2 → F2 that satisfies: 2 (denoted as ¯Dlin,D ǫ E x∼D E S1,...,Sk(cid:2)(g(χS1 (x), χS2 (x), . . . , χSk (x)) − f (x))2(cid:3) ≤ ǫ. 2 1.1 Applications to Streaming and Distributed Computing One of the key applications of our results is to the dynamic streaming model. In this model, the input x is generated via a sequence of additive updates to its coordinates, starting with x = 0n. If x ∈ Rn, then updates are of the form (i, ∆i) (turnstile model), where i ∈ [n], and ∆i ∈ R, which adds ∆i to the i-th coordinate of x. For x ∈ Fn 2 , only the coordinate i is specified and the corresponding bit is flipped, which is known as the XOR-update model [Tha16]1. Dynamic streaming algorithms aim to minimize space complexity of computing a given function f for an input generated through a sequence of such updates while also ensuring fast update and function evaluation times. Note that linear sketching over the reals and F2-sketching can be used directly in the respective streaming update models. Most interestingly, these techniques turn out to achieve almost optimal space complexity. It is known that linear sketching over the reals gives (almost) optimal space complexity for processing dynamic data streams in the turnstile model for any function f [LNW14, AHLW16]. However, the results of [LNW14, AHLW16] require adversarial streams of length triply In the XOR-update model, space optimality of F2-sketching has been shown exponential in n. recently in [HLY18]. This optimality result holds even for adversarial streams of much shorter length Ω(n2). Hence, lower bounds on F2-sketch complexity obtained in our work extend to space complexity of dynamic streaming algorithms for streams of quadratic length. A major open question in this area is the conjecture of [KMSY18] that the same holds even for streams of length only 2n. We thus complement our lower bounds on dimension of F2-sketches with one-way two-player communication complexity lower bounds for the corresponding XOR functions f +(x, y) = f (x + y). Such lower bounds translate to dynamic streaming lower bounds for streams of length 2n. Furthermore, whenever our communication lower bounds hold for the uniform distri- bution, the corresponding streaming lower bound applies to streaming algorithms under uniformly random input updates. Finally, our upper bounds can be used for distributed algorithms computing f (x1 + ··· + xM ) over a collection of distributed inputs x1, . . . , xM ∈ Fn 2 as F2-sketches can be used for distributed inputs. On the other hand, our communication lower bounds also apply to the simultaneous message passing (SMP) communication model, since it is strictly harder than one-way communication. 1.2 Valuation Functions and Sketching Submodular valuation functions, originally introduced in the context of algorithmic game theory and optimization, have received a lot of interest recently in the context of learning theory [BH11, BCIW12, CKKL12, GHRU13, RY13, FKV13, FK14, FV15, FV16]2, approximation [GHIM09, 1By slightly changing the function to f ′(x1, . . . , xn, y1, . . . , yn) = f (x1 + y1, x2 + y2, . . . , xn + yn), it is easy to see that there are functions for which knowledge of the sign of the update (i.e. whether it is +1 or -1) is not a stronger model than the XOR-update model. For some further motivation of the XOR-update model, consider dynamic graph streaming algorithms, i.e the setting when x represents the adjacency matrix of a graph and updates correspond to adding and removing the edges. Almost all known dynamic graph streaming algorithms (except spectral graph sparsification of [KLM+17]) are based on the ℓ0-sampling primitive [FIS08]. As shown recently, ℓ0-sampling can be implemented optimally using F2-sketches [KNP+17] and hence almost all known dynamic graph streaming algorithms can handle XOR-updates, i.e. knowing whether an edge was inserted or deleted does not help. 2We remark that in this literature the term "sketching" is used to refer to the space complexity of representing the function f itself under the assumption that it is unknown but belongs to a certain class. This question is orthogonal to our work as we assume f is known and fixed while the input x is changing. 3 BDF+12] and property testing [CH12, SV14, BB17]. As we show in this work, valuation func- tions also represent an interesting study case for linear sketching and streaming algorithms. While a variety of papers exists on streaming algorithms for optimizing various submodular objectives, e.g. [SG09, DIMV14, BMKK14, CGQ15, CW16, ER16, HIMV16, AKL16, BEM17], to the best of our knowledge no prior work considers the problem of evaluating such functions under a changing input. A systematic study of F2-sketching has been initiated for Boolean functions in [KMSY18]. This paper can be seen as a next step, as we introduce approximation into the study of F2-sketching. One of the consequences of our work is that the Fourier ℓ1-sampling technique, originally introduced by Bruck and Smolensky [BS92] (see also [Gro97, MO09]), turns out to be optimal in its dependence on both spectral norm and the error parameter. For Boolean functions, a corresponding result is not known as Boolean functions with small spectral norm and necessary properties are hard to construct. Another technical consequence of our work is that the study of learning and sketching algorithms turn out to be related on a technical level despite pursuing different objectives (in learning the specific function is unknown, while in sketching it is). In particular, our hardness result for Lipschitz submodular functions uses a construction of a large family of matroids from [BH11] (even though in a very different parameter regime), who designed such a family to fool learning algorithms. 1.3 Our Results A function f : 2[n] → R is α-Lipschitz if for any S ⊆ [n] and i ∈ [n], it holds that f (S∪{i})−f (S) ≤ α for some constant α > 0. A function f : 2[n] → R is submodular if: f (A ∪ {i}) − f (A) ≥ f (B ∪ {i}) − f (B) ∀A ⊆ B ⊆ [n] and i /∈ B. We consider the following classes of valuation functions of the form f : Fn 2 → R (all of them submodular) sometimes treating them as f : 2[n] → R and vice versa. These classes mostly cover all of existing literature on submodular functions3. See Table 1 for a summary of the results. • Additive (linear). f (x) =Pn Our results: For additive functions, it is easy to show that dimension of F2-sketches is O(min(kwk2 1/ǫ, n)) (Corollary A.3) and give a matching communication lower bound (Theo- rem A.7) for all ǫ ≥ kwk2 2. • Budget-additive. f (x) = min(b,Pn is the "hockey stick" function hsα(x) = min(α, 2α Our results: For budget-additive functions, it is easy to show that dimension of F2-sketches is O(min(kwk2 1/ǫ, n)) (Corollary A.6). We give a matching communication bound for the "hockey stick" function for constant ǫ (Theorem D.1) which holds even under the uniform distribution of the input. i=1 wixi) where b, wi ∈ R. An example of such functions i=1 wixi, where wi ∈ R. i=1 xi). n Pn 3We do not discuss some other subclasses of subadditive functions because they are either superclasses of classes for which we already have an Ω(n) lower bound (e.g. submodular, subadditive, etc.) or because such a lower bound follows trivially (e.g. for OXS/XOS since for XS-functions a lower bound of Ω(n) is easy to show, see Appendix C). 4 Class Error Distribution Complexity Result Additive/Budget additive i=1 wixi) min(b,Pn min(c√n, 2c√nPn Coverage i=1 xi) Matroid Rank 2 Graphic Matroids Rank r Matroid Rank r Matroid Rank r Matroid Rank c n -Lipschitz Submodular ǫ any constant uniform ǫ exact exact exact any any any any exact 1/√n constant uniform uniform any 1 Θ(cid:16)kwk2 ǫ (cid:17) ǫ(cid:1) O(cid:0) 1 Ω(n) Θ(1) O(r2 log r) Theorem A.7, D.1 Corollary A.3, A.6 Theorem D.1 Corollary A.4 Theorem 3.1 Theorem 3.5 Ω(r) Corollary 3.24 O((r log r + c)r+1) Corollary E.6 Θ(1) Θ(n) Corollary E.8 Theorem 3.17 Table 1: Linear sketching complexity of classes of valuation functions • Coverage. A function f is a coverage function on some universe U of size m if there exists a collection A1, . . . , An of subsets of U and a vector of non-negative weights (w1, . . . , wm) such that: f (S) = Xi∈∪j∈S Aj wi. Our results: We show a simple upper bound of O(1/ǫ) (Corollary A.4) for such functions. • Matroid rank. A pair M = ([n],I) is called a matroid if I ⊆ 2[n] is a non-empty set family such that the following two properties are satisfied: -- If I ∈ I and J ⊆ I, then J ∈ I -- If I, J ∈ I and J < I, then there exists an i ∈ I \ J such that J ∪ {i} ∈ I. The sets in I are called independent. A maximal independent set is called a base of M . All bases have the same size, which is called the rank of the matroid and is denoted as rk(M ). The rank function of the matroid is the function rankM : 2[n] → N+ defined as: rankM (S) := max{I : I ⊆ S, I ∈ I}. It follows from the definition that rankM is always a submodular 1-Lipschitz function. Our results: In order to have consistent notation with the rest of the manuscript we always assume that matroid rank functions are scaled so that their values are in [0, 1]. Some of our results are exact, i.e. the corresponding matroid rank function is computed exactly (and in this case rescaling does not matter) while others allow approximation of the function value. In the latter case, the approximation guarantees are multiplicative with respect to the rescaled function. Our main theorem regarding sketching of matroid rank functions is as follows: 5 Theorem 1.4 (Sketching matroid rank functions). For (scaled) matroid rank functions: -- There exists an exact F2-sketch of size O(1) for matroids of rank 2 (Theorem 3.1) and graphic matroids (Theorem 3.5). -- There exists c = Ω(1) and a matroid of rank r such that a c-approximation of its matroid rank function has randomized linear sketch complexity Ω(r). Furthermore, this lower bound also holds for the corresponding one-way communication problem (Theorem 3.23, Corollary 3.24). This can be contrasted with the results under the uniform distribution for which matroids of rank r have an exact F2-sketch of size O(cid:16)(cid:0)r log r + log 1 ǫ(cid:1)r+1(cid:17), where ǫ is the probability of failure (Corollary E.6, follows from the junta approximation of [BOSY13]). Furthermore, ma- troids of high rank Ω(n) can be trivially approximately sketched under product distributions, due to their concentration around their expectation (see Appendix E for details). • Lipschitz submodular. A function f : 2[n] → R is α-Lipschitz submodular if it is both submodular and α-Lipschitz. Our results: We show an Ω(n) communication lower bound (and hence a lower bound on F2-sketch complexity) for constant error for monotone non-negative O(1/n)-Lipschitz sub- modular functions (Theorem 3.17). We note that this hardness result crucially uses a non- product distribution over the input variables since Lipschitz submodular functions are tightly concentrated around their expectation under product distributions (see e.g. [Von10, BH11]) and hence can be approximated using their expectation without any sketching at all. 1.4 Overview and Techniques 1.4.1 Basic Tools: XOR Functions, Spectral Norm, Approximate Fourier Dimension In Section 2, we introduce the basics of approximate F2-sketching. Most definitions and results in this section can be seen as appropriate generalizations regarding Boolean functions (such as in [KMSY18]) to the case of real-valued functions where we replace Hamming distance with expected squared distance. We then define the randomized one-way communication complexity of the two- player XOR-function f +(x, y) = f (x + y) corresponding to f . This communication problem plays an important role in our arguments as it gives a lower bound on the sketching complexity of f . We then introduce the notion of approximate Fourier dimension developed in [KMSY18]. The key structural results of [KMSY18], which characterize both the sketching complexity of f and the one- way communication complexity of f + under the uniform distribution using the approximate Fourier dimension, can be extended to the real-valued case as shown in Proposition 2.6 and Theorem 2.7. This characterization is our main tool for showing lower bounds under the uniform distribution of x. Another useful basic tool is a bound on the linear sketching complexity based on the spectral In particular, as we show in Appendix A.1.1, norm of f which we develop in Appendix A.1. analogously to the Boolean case, we can leverage properties of the Fourier coefficients of a function f to show that the ǫ-approximate randomized sketching complexity of f is at most O(k fk2 1/ǫ). Thus, we can determine the dimension of F2-sketches for classes of functions whose spectral norms are well- bounded as well as functions which can be computed as Lipschitz compositions of a small number of 6 functions with bounded spectral norm (Proposition A.5). Examples of such classes include additive (linear), budget-additive and coverage functions. Finally, we argue that the dependence on the parameters in the spectral norm bound cannot be substantially improved in the real-valued case by presenting a subclass of linear functions which require sketches of size Ω(k fk2 1/ǫ) (Theorem A.7). This is in contrast with the case of Boolean functions studied in [KMSY18] for which such tightness result is not known. 1.4.2 Matroid Rank Functions, LTF, LTF◦OR In Section 3, we present our results on sketching matroid rank and Lipschitz submodular functions. In Section 3.1 we show that matroid rank functions of matroids of rank 2 and graphic matroids have constant randomized sketching complexity. This is done by first observing that rank functions of such matroids can be expressed as a threshold function over a number of disjunctions. There- fore, it remains to determine the sketching complexity of the threshold function on a collection of disjunctions. Unfortunately, known upper bounds for the sketching complexity of even the simpler class of linear threshold functions have a dependence on n and hence one cannot get a constant upper bound directly. as f (x) = sgn (Pn Hence we show how to remove this dependence in Section 3.1.1, also resolving an open question of Montanaro and Osborne [MO09]. Recall that a linear threshold function (LTF) can be represented i=1 wixi − θ) for some weights wi and threshold θ, where we slightly alter the traditional definition of the sign function sgn to output 0 if the input is negative and 1 otherwise. An important parameter of an LTF is its margin m, which corresponds to the difference between the threshold and the value of the linear combination closest to it. We first observe that the terms with insignificant coefficients, i.e. weights that are small in absolute value, do not contribute to the final output and thus, we can ignore them. Similarly, the remaining weights can be rounded, without altering the output of the function, to a collection of weights whose size is bounded, independent of θ 2m of these "significant" indices i of x. Thus, n. Furthermore, f (x) = 0 only if xi = 1 for at most we hash the significant indices to a large, but independent of n, number of buckets. As a result, either there are a small number of significant indices i with x1 = 1 and there are no collisions, or there is a large number of significant indices i with xi = 1. Since we can differentiate between these two cases, the sketch can output whether f (x) = 0 or f (x) = 1 with constant probability. With a more careful choice of hash functions this idea can be extended to linear thresholds of disjunctions. We show in Section 3.1.2 that a threshold function over a number of disjunctions (LTF◦OR) also has linear sketch complexity independent of n. In Section 3.2.1, we show that there exists an Ω(n)-Lipschitz submodular function f that requires a randomized linear sketch of size Ω(n). We construct such a function probabilistically by using a large family of matroid rank functions constructed by [BH11] with an appropriately chosen set of parameters. We show any fixed deterministic sketch fails on a matroid chosen uniformly at random from this parametric family with very high probability. In fact, even if we take a union bound over all possible sketches of bounded dimension, the failure of probability is still negligibly close to 1. By Yao's principle, the randomized linear sketch complexity follows. We then extend this result to a communication lower bound for f + in Section 3.2.2. In the one-way communication complexity setting, we show that there exists an Ω(n)-Lipschitz submodular function f whose f + requires communication Ω(n). 7 1.4.3 Uniform Distribution In Section D, we show lower bounds for a budget additive "hockey stick" function under the uniform distribution. The lower bounds follow from a characterization of communication complexity using approximate Fourier dimension, and to complete the analysis, we lower bound the Fourier spectrum of the hockey stick function in Appendix D.1. Although our approach for matroids of rank 2 does not seem to immediately generalize to matroids of higher rank under arbitrary distributions, we show in Section E that under the uniform distribution, we can use ǫ-approximations of disjunctive normal forms (DNFs) by juntas to obtain a randomized linear sketch whose size is independent of n. Furthermore, rank functions of matroids of very high rank admit trivial approximate sketches under the uniform distribution as follows from standard concentration results [Von10] (see Appendix E). 2 Basics of Approximate F2-Sketching 2.1 Communication Complexity of XOR functions In order to analyze the optimal dimension of F2-sketches, we need to introduce a closely related communication complexity problem. For f : Fn 2 → R as f +(x, y) = f (x + y) where x, y ∈ Fn 2 . Consider a communication game between two players Alice and Bob holding inputs x and y respectively. Given access to a shared source of random bits Alice has to send a single message to Bob so that he can compute f +(x, y). This is known as the one-way communication complexity problem for XOR-functions (see [SZ08, ZS10, MO09, LZ10, LLZ11, SW12, LZ13, TWXZ13, Lov14, HHL16, KMSY18] for related communication complexity results). 2 → R define the XOR-function f + : Fn 2 × Fn Definition 2.1 (Randomized one-way communication complexity of XOR function). For a func- tion f : Fn 2 → R, the randomized one-way communication complexity with error δ (denoted as R→δ (f +)) of its XOR-function is defined as the smallest size4 (in bits) of the (randomized using public randomness) message M (x) from Alice to Bob, which allows Bob to evaluate f +(x, y) for any x, y ∈ Fn 2 with error probability at most δ. It is easy to see that R→δ (f +) ≤ Rlin δ (f ) as using shared randomness Alice can just send k bits χS1(x), χS2 (x), . . . , χSk (x) to Bob, who can for each i ∈ [k] compute χSi(x + y) = χSi(x) + χSi(y), which is an F2-sketch of f on x + y and hence suffices for computing f +(x, y) with probability 1− δ. Replacing the guarantee of exactness of the output in the above definition with an upper bound on expected squared error, we obtain the following definition. Definition 2.2 (Randomized one-way communication complexity of approximating an XOR func- tion). For a function f : Fn 2 → R, the randomized one-way communication complexity (denoted as ¯R→ǫ (f +)) of approximating its XOR-function with error ǫ is defined as the smallest size(in bits) of the (randomized using public randomness) message M (x) from Alice to Bob, which allows Bob to evaluate f +(x, y) for any x, y ∈ Fn 2 with expected squared error at most ǫ. Distributional communication complexity is defined analogously for the corresponding XOR function and is denoted as Dǫ. 4Formally the minimum here is taken over all possible protocols where for each protocol the size of the message 2 . See [KN97] for a formal M (x) refers to the largest size (in bits) of such message taken over all inputs x ∈ Fn definition. 8 Finally, in the simultaneous model of computation [BK97, BGKL03], also called simultaneous message passing (SMP) model, there exist two players and a coordinator, who are all aware of a function f . The two players maintain x and y respectively, and must send messages of minimal size to the coordinator so that the coordinator can compute f (x ⊕ y). Definition 2.3 (Simultaneous communication complexity of XOR function). For a function f : Fn 2 → R, the simultaneous one-way communication complexity with error δ (denoted as Rsim (f +)) of its XOR-function is defined as the smallest sum of the sizes (in bits) of the (randomized using public randomness) messages M (x) and M (y) from Alice and Bob, respectively, to a coordinator, which allows the coordinator to evaluate f +(x, y) for any x, y ∈ Fn 2 with error probability at most δ. δ Observe that a protocol for randomized one-way communication complexity of XOR function translates to a protocol for the simultaneous model of computation. 2.2 Distributional Approximate F2-Sketch Complexity Fourier analysis plays an important role in the analysis of distributional F2-sketch complexity over the uniform distribution. In our discussion below, we make use of some standard facts from Fourier analysis of functions over Fn 2 . For definitions and basics of Fourier analysis of functions of such functions we refer the reader to the standard text [O'D14] and Appendix A.1. In particular, Fourier concentration on a low-dimensional subspace implies existence of a small sketch which satisfies this guarantee: Definition 2.4 (Fourier concentration). A function f : Fn subspace Ad of dimension d if for this subspace it satisfies: f (S)2 ≥ γ. 2 → R is γ-concentrated on a linear XS∈Ad We also use the following definition of approximate Fourier dimension from [KMSY18], adapted for the case of real-valued functions. Definition 2.5 (Approximate Fourier dimension). Let Ak be the set of all linear subspaces of Fn 2 of dimension k. For f : Fn 2] the ǫ-approximate Fourier dimension dimǫ(f ) is defined as: 2 → R and ǫ ∈ (0,kfk2 Proposition 2.6. For any f : Fn dimǫ(f ) = min k (∃A ∈ Ak : Xα∈A f 2(α) ≥ ǫ) . 2 → R, it holds that: ¯Dlin,U ǫ (f ) ≤ dimkfk2 2−ǫ(f ). Proof. Indeed, let Ad be a d-dimensional subspace such thatPS∈Ad the function g(x) =PS∈Ad 2 − ǫ and consider f (S)χS (x). Note that in order to compute all values χS(x) for S ∈ Ad it suffices to evaluate d parities corresponding to sets S1, . . . , Sd forming a basis in Ad. Values of all other parities can be computed as linear combinations. Let ∆(x) = f (x) − g(x). Then the desired guarantee follows from the following calculation: f 2(S) ≥ kfk2 E [∆(x)2] = x∼U ({0,1}n) E S∼U ({0,1}n) [ ∆(S)2] = XS∈{0,1}n ( f (S) − g(S))2 = XS /∈Ad f (S)2 ≤ ǫ, where the first equality holds from Parseval's identity. 9 Furthermore, approximate Fourier dimension can be used as a lower bound on the one-way communication complexity of the corresponding XOR-function. We defer the proof of the fol- lowing result to Appendix B.1 as it is follows closely an analogous result for Boolean functions from [KMSY18]. Theorem 2.7. For any f : Fn 2 → R, δ ∈ [0, 1/2] and ξ = kfk2 2 − ǫ(1 + 2δ) it holds that: ¯D→,U ǫ (f +) ≥ δ 2 · dimξ(f ). 3 Sketching Matroid Rank Functions In this section we analyze sketching complexity of matroid rank functions. We start by consider- ing the most fundamental possible matroids (of rank 2) in Section 3.1 and showing that exactly sketching the matroid rank function requires O(1) complexity. Similarly, we show that exactly sketching the rank of graphic matroids only uses O(1) complexity. On the other hand, we show a lower bound in Section 3.2.1 that even approximating the rank r of general matroids up to certain constant factors requires Ω(r) complexity. To sketch matroids of rank 2, we leverage a result by Acketa [Ack78] which characterizes the collection of independent sets of such matroids. This allows us to represent matroid rank functions for matroids of rank 2 as a linear threshold of disjunctions. Thus, we first show the randomized linear sketch complexity of (θ, m)-linear threshold functions, resolving an open question by Montanaro and Osborne [MO09]. 3.1 Matroids of Rank 2 and Graphic Matroids In this section, we show that there exists a constant-size sketch that can be used to compute exact values of matroid rank functions for matroids of rank 2. Theorem 3.1. For every matroid M of rank 2 it holds that Rlin 1 3 (rankM ) = O(1). It is well-known that matroids of rank 2 admit the following characterization (see e.g. [Ack78]). Fact 3.2. The collection of size 2 independent sets of a rank 2 matroid can be represented as the edges in a complete graph that has edges of some number of disjoint cliques removed. We define the following function as a threshold on the Hamming weight of a binary vector x HAM≤d(x) =(0, 1, if Pn otherwise. i=1 xi ≤ d + 1 2 We use a series of technical lemmas in the following section to prove the following result, which says that linear threshold functions can be succinctly summarized: Theorem 3.3. The function HAM≤d(cid:0)Wi∈S1 O(d2 log d). xi,Wi∈S2 xi, . . .(cid:1) has a randomized linear sketch of size The following fact that upper bounds the sketch complexity for functions with small support: 10 Fact 3.4 (Folklore, see e.g. [MO09, KMSY18]). For any function f : {0, 1}n → {0, 1} with minz∈{0,1} Prx∈{0,1}n(f (x) = z) ≤ ǫ it holds that Rlin δ (f ) ≤ log 2n+1ǫ . δ Using Fact 3.2, Theorem 3.3, and Fact 3.4, we prove Theorem 3.1 by writing the matroid rank function for M as a linear threshold function of disjunctions. Proof of Theorem 3.1: We first claim F2-sketching complexity of the rank function of any rank 2 matroid M is essentially the same as the complexity of the corresponding Boolean function that takes value 1 if rankM (x) = 2 and takes value 0 otherwise. Indeed, let the function above be denoted as fM . Without loss of generality, we can assume that all singletons are independent sets in M as otherwise the rank function of M does not depend on the corresponding input. Hence rankM (x) = 0 if and only if x = 0n. Thus Rlin δ (fM ) + O(log 1/δ) as by Fact 3.4 we can use O(log 1/δ)-bit sketch to check whether x = 0n first and then evaluate rankM using fM . Recall from Fact 3.2 that matroids of rank 2 can be represented as edges in a complete graph with edges corresponding to some disjoint union of cliques removed. δ (rankM ) = Rlin Let S1, . . . , St be the collection of vertex sets of disjoint cliques defining a rank 2 matroid M in i=1 Si = n by adding singletons. Then: Fact 3.2. Without loss of generality, we can assume that ∪t xj, _j∈S2 fM (x) = HAM≥2_j∈S1 where HAM≥2(z1, . . . , zt) = 1 if and only ifPt xj, . . . , _j∈St xj , i=1 zi ≥ 2 is the threshold Hamming weight function. By Theorem 3.3, the sketch complexity of fM (x) is O(1), since the Hamming weight threshold is d = 2. Since the independent bases of a graphic matroid M (G) are the spanning forests of G, the matroid rank function of a graphic matroid of rank r can be expressed as ✷ fM (x) = HAM≥r_j∈S1 xj, _j∈S2 xj, . . . , _j∈St xj , where each Si is a separate spanning forest. Therefore, Theorem 3.3 yields a O(r2 log r) space linear sketch for graphic matroids of rank r. Theorem 3.5. For every graphic matroid M of rank r, it holds that Rlin 1 3 (rankM ) = O(r2 log r). We use the remainder of the Section 3.1 to prove Theorem 3.3, while resolving an open question by Montanaro and Osborne [MO09]. 3.1.1 Linear Threshold Functions We first define linear threshold functions (LTFs) and (θ, m)-LTFs. Definition 3.6. A function f : {0, 1}n → {0, 1} is a linear threshold function (LTF) if there exist constants θ, w1, w2, . . . , wn such that f (x) = sgn (−θ +Pn i=1 wixi), where sgn (y) = 0 for y < 0 and sgn (y) = 1 for y ≥ 0 is the Heaviside step function. 11 m log θ m(cid:1) communication. Although (θ, m)-LTFs have previously been shown to have randomized linear sketch complexity Question 3.8 ([MO09]). Let g(x, y) = f (x ⊕ y), where f is a (θ, m)-LTF. Does there exist a Definition 3.7. A monotone linear threshold function f : {0, 1}n → {0, 1} is a (θ, m)-LTF if m ≤ minx∈{0,1}n −θ +Pn i=1 wixi, where θ is referred to as the threshold and m as the margin of the LTF. m log n(cid:1) [LZ13], Montanaro and Osborne asked whether any (θ, m)-LTF can be represented in O(cid:0) θ the simultaneous model with O(cid:0) θ m(cid:1)? protocol for g in the simultaneous model with communication complexity O(cid:0) θ show the stronger result that (θ, m)-LTFs admit a randomized linear sketch of size O(cid:0) θ Lemma 3.9. Let f (x) = sgn (−θ +Pn wi ≥ 2m and w′i = 0 otherwise. Then f (x) = sgn (−θ +Pn m(cid:1). i=1 wixi) be a (θ, m)-LTF. For 1 ≤ i ≤ n, let w′i = wi if Note that the difference between log n and log θ m is crucial for obtaining constant randomized linear sketch complexity for functions for matroid rank 2. We answer Question 3.8 in the affirmitive and We first show that we can completely ignore all variables whose weights are significantly smaller than 2m in evaluating a (θ, m)-LTF. Proof. We show the stronger result that for any j such that wj < 2m, then f (x) = f (x⊕ ej), where ej is the elementary unit vector with one in the j th position, and zeros elsewhere. This implies the lemma since it shows that any variable whose weight is less than 2m does not affect the output of the function or the margin of the function and thus might as well have weight zero. i=1 w′ixi). m log θ m log θ Suppose, by way of contradiction, that f (x) 6= f (x⊕ ej) and without loss of generality, f (x) = 0 i=1 wixi < 0. i=1 wixi < i=1 wixi < m, i=1 wixi < −m. Therefore, f (x ⊕ ej) = 0, so xj does not affect with xj = 0. Since f is a linear threshold function and f (x) = 0, then −θ +Pn Moreover, f is a (θ, m)-LTF, so −θ +Pn i=1 wixi < −m. Because wj < 2m, −θ + wj +Pn −θ+2m+Pn i=1 wixi < m. But because m is the margin of the function, if −θ+wj +Pn then it must hold that −θ + wj +Pn the output of the function or the margin of the function. As noted, Lemma 3.9 implies that we can ignore not only variables with zero weights, but all variables whose weights are less than 2m. We now bound the support of the set {x f (x) = 0}, where f is a (θ, m)-LTF, and apply Fact 3.4. m log n(cid:1). θ 2m variables in S can have value 1. Equivalently, at most Lemma 3.10. For any (θ, m)-LTF, there exists a randomized linear sketch of size O(cid:0) θ Proof. Let f (x) = sgn (−θ +Pn i=1 wixi) be a (θ, m)-LTF. By Lemma 3.9, the output of f remains the same even if we only consider the variables S with weight at least 2m. On the other hand, θ if f (x) = 0, then at most 2m indices i can have xi = 1 if f (x) = 0. Thus, the number of x ∈ {0, 1}n with f (x) = 0 is at most i(cid:1) ≤ (n + 1)⌈θ/2m⌉. Applying Fact 3.4, there exists a randomized linear sketch for f , P0≤i≤θ/2m(cid:0)n m log n(cid:1). of size O(cid:0) θ can be rounded to a set that contains O(cid:0) θ can then use hashing to reduce the number of variables down to poly(cid:0) θ m(cid:1) elements. Second, we show in Theorem 3.14 that we m(cid:1) before applying Lemma m rather than log n, we use the following two observations. First, we show in Lemma 3.11 that the weights of a (θ, m)-LTF In order to fully prove Question 3.8 and obtain a dependence on log θ 3.10. 12 m log θ i=1 wixi) be a (θ, m)-LTF. Then there exists a set W with i=1 w′ixi), where each m(cid:1), and a margin m′ = Θ(m) such that f (x) = sgn (−θ +Pn Lemma 3.11. Let f (x) = sgn (−θ +Pn W = O(cid:0) θ w′i ∈ W and f is a (θ, m′)-LTF. Proof. Observe that for any wi ≥ 2θ, if xi = 1, then f (x) = 1. Thus, if f (x) = 1, it suffices to consider 2m ≤ wi ≤ 2θ. m(cid:1)(cid:7), where ǫ is some fixed constant that we set Let W = {2m(1 + ǫ)i}t at a later time. For each i, let w′i be the largest element in W that does not exceed wi. Thus, w′i ≤ wi < (1 + ǫ)w′i. Observe that since w′i ≤ wi and f is a (θ, m)-LTF, then f (x) = 0 implies −m > −θ +Pn i=1 w′ixi) = 0 = f (x) and a margin of m remains. On the other hand, if f (x) = 1, thenPn (1 + ǫ)w′i, thenPn θ − ǫθ + m − ǫm ≥ θ + m − 2ǫθ. Setting ǫ = θ a margin of m′ = 4 i=1 wixi, so that sgn (−θ +Pn 1+ǫ > (1 − ǫ)(θ + m). Observe that θ ≥ m and hence,Pn i=1 wixi > θ + m as f is a (θ, m)-LTF. Since w′i ≤ wi < i=1 w′ixi > 10m shows that sgn (−θ +Pn i=1 w′ixi) = 1 = f (x) and i=0 for t = (cid:6)log1+ǫ(cid:0) θ i=1 wixi ≥ −θ +Pn i=1 w′ixi > θ+m 5 m remains. The following result is also useful for our construction of a sketch for a (θ, m)-LTF. Lemma 3.12. [HSZZ06] There is a randomized linear sketch with size O(1) for the function HAMn,d2d(x) =(1, 0, if x0 ≤ d if x0 ≥ 2d m log θ θ On the other hand, if less than θ θ 2m indices i of x satisfy xi = 1. m(cid:1). m(cid:7) for ǫ = θ i=1 wixi) be a (θ, m)-LTF. By Lemma 3.11, we can assume that 10m . θ 2m indices i of x. From Lemma 3.12, on instances {xx ∈ {0, 1}n and x0 ≤ d or x0 ≥ 2d}. Fact 3.13. If h : [n] → [M ] is a random hash function and S ⊆ [n], then the probability that there exist x, y ∈ S with h(x) = h(y) is at most S2 M . Theorem 3.14. Any (θ, m)-LTF admits a randomized linear sketch of size O(cid:0) θ Proof. Let f (x) = sgn (−θ +Pn 5 m and t = (cid:6)log1+ǫ i=0 so that the new margin m′ = 4 wi ∈ W = {2m(1 + ǫ)i}t Recall from Lemma 3.10, f (x) = 0 only if xi = 1 for at most we can detect the instances where at least and corresponding weights via hashing. Let h : [n] → [M ], where M = 5(cid:0) θ m(cid:1)2 of indices of x, of size at most θ elements of S is at most 1 Sw,j = {ih(i) = j ∧ wi = w}. Therefore with probability at least 4 under elements of S and Sw,j ≤ 1 for all w ∈ W and j ∈ [M ]. Let yw,j =Pi∈Sw,j nXi=1 2m indices i of x satisfy xi = 1, we can identify these indices , and S be a set m . Then by Fact 3.13, the probability of a collision in h under 5 . We partition [n] into sets Sw,j where w ∈ W and j ∈ [M ] so that 5 , there are no collisions in h xi = X(j,w)∈[M ]×W wixi = X(j,w)∈[M ]×W Thus, f (x) is equivalent to the function g(y) = sgn(cid:16)−θ +Pw,j w · yw,j(cid:17). Since W = O(cid:0) θ 5 m is the margin for g(y), then g(y) depends on O(cid:16)(cid:0) θ M = 5(cid:0) θ m(cid:1)3 m(cid:1)2 m(cid:1). yw,j. By Lemma 3.10, there exists a randomized sketch for g(y) of size O(cid:0) θ xi and note that if there are no collisions in h under elements of S, then m(cid:1), m(cid:17) variables w Xi∈Sw,j and m′ = 4 w · yw,j. log θ m log θ m log θ 13 We can also show that Theorem 3.14 is tight by recalling the function if Pn i=1 xi ≤ d + 1 HAM≤d(x) =(0, 2(cid:1)-LTF, it can be represented by a randomized linear sketch of size otherwise. 1, 2 2 , 1 O(d log d). On the other hand, Dasgupta, Kumar and Sivakumar [DKS12] notes that the one-way complexity of small set disjointness for two vectors x and y of weight d, which reduces to the function HAM≤d(x⊕ y), is Ω(d log d). Thus, HAM≤d(x⊕ y) also requires a sketch of size Ω(d log d). Since this function is a(cid:0)d + 1 3.1.2 Linear Threshold of Disjunctions In this section, we describe a randomized linear sketch for functions that can be represented as 2-depth circuits where the top gate is a monotone linear threshold function with threshold θ and xi, q is a linear margin m, and the bottom gates are OR functions. Formally, if gS(x) = _i∈S threshold function, and wS ≥ 0, then f (x) = q(. . . , gS(x), . . .) = sgn(cid:0)−θ +PS∈2[n] wS · gS(x)(cid:1). Lemma 3.15. Let f (x) = sgn (−θ +Pn Let h : [n] → [M ] be a random hash function where M = 50θ2 i=1 wixi) be a (θ, m)-LTF where wi ∈ W for some set W . m2 and 2m so that the probability there are collisions under h in S is at most If f (x) = 1, then either S < θ If f (x) = 0, then S ≤ θ by Fact 3.13. Thus if f (x) = 0, then fh(x) = 0 with probability at least 1 − 1 200 . under h in S is at most 1 S ≥ θ h(i) = j. Therefore, we set fh(x) = 1 whenever at least θ m , with probability at least 1 − 1 m , then the probability there are collisions 50 . If m values j such that there exists xi = 1 and 50 by Fact 3.13, so then fh(x) = 1 with probability at least 1 − 1 m . If S < θ 50 , there exist θ m or S ≥ θ m buckets of h are non-empty. 1 200 In all cases, fh(x) = f (x) with probability at least 1 − 1 50 . Theorem 3.16. Let gS(x) =Wi∈S xi with wS ≥ 0, q be a (θ, m)-LTF, and wS · gS(x) . f (x) = q(. . . , gS(x), . . .) = sgn−θ + XS∈2[n] 14 Then for all x, Pr [fh(x) 6= f (x)] ≤ 1 50 . Proof. As by Lemma 3.11, we can assume without loss of generality that wi ≥ 2m and w ≥ 2m. Let S = {ixi = 1} so that if there are no collisions under h in S, then fh(x) = sgn−θ + X(j,w)∈[M ]×W w _i:h(i)=j wi=w  . xi X(j,w)∈[M ]×W w _i:h(i)=j wi=w xi =Xi wixi. log2 θ log θ log2 θ q. Θ( θ Proof. We first apply Lemma 3.9 and Lemma 3.11 to q so that weights wi can be rounded to Then there is a randomized linear sketch for f of size O(cid:16)(cid:0) θ m(cid:1)4 elements of a set W with W = O(cid:0) θ m ) disjunctions are nonzero. Hence to hash O(cid:16)(cid:0) θ m(cid:1)2 hash function with M = O(cid:16)(cid:0) θ m(cid:1)4 linear sketch has size O(cid:16)(cid:0) θ m(cid:17). m(cid:1)4 Recall that HAM≤d(x) is a (cid:0)d + 1 m(cid:17), where m is the margin of m(cid:1). For each wi ∈ W , it again suffices to detect whether m(cid:17) disjunctions, it suffices to use a m(cid:17) buckets. By Lemma 3.15, our resulting randomized 2(cid:1)-LTF. Furthermore, the set of Proof of Theorem 3.3: weights W for HAM≤d(x) consists of a single element {1}, since the coefficient of each disjunction is one. Since M = O(d2 log d), we can construct a randomized linear sketch with size O(d2 log d) by Lemma 3.15. ✷ 2 , 1 m log θ log2 θ We note that our approach can be easily generalized to the case where the disjunction include the negations of some variables as well. 3.2 Communication Complexity of Lipschitz Submodular Functions We discuss the communication complexity of Lipschitz submodular functions in this section. We first show in Section 3.2.1 that there exists an Ω(n)-Lipschitz submodular function f that requires a randomized linear sketch of size Ω(n). We then show in Section 3.2.2 that in the one-way communication complexity model for XOR functions, there exists an Ω(n)-Lipschitz submodular function f that has communication complexity Ω(n). 3.2.1 Approximate F2-Sketching of Lipschitz Submodular Functions Theorem 3.17. There exist constants c1, c2, ǫ ≥ 0 and a monotone non-negative ( c1 submodular function f (a scaling of a matroid rank function) such that: n )-Lipschitz ¯Rlin ǫ (f ) ≥ c2n. Proof. Our proof uses a construction of a large family of matroid rank functions given in [BH11], Theorem 8. The construction uses the following notion of lossless bipartite expanders: Definition 3.18 (Lossless bipartite expander). Let G = (U ∪ V, E) be a bipartite graph. For J ⊆ U let Γ(J) = {v∃u ∈ U : {u, v} ∈ E}. Graph G is a (D, L, ǫ)-lossless expander if: Γ({u}) = D ∀u ∈ U Γ(J) ≥ (1 − ǫ)DJ ∀J ⊆ U,J ≤ L. Here we need different parameters than in [BH11] so we restate their theorem as follows: Theorem 3.19 ([BH11]). Let (U ∪ V, E) be a (D, L, ǫ)-lossless expander with U = k and V = n and let b = 8 log k. If D ≥ b, L = 4D/b − 2 and ǫ = b 4D then there exists a family of sets A ⊆ 2[n] and a family of matroids {MB : B ⊆ A} with the following properties: • A = k and for every A ∈ A it holds that A = D. 15 • For every B ⊆ A and every A ∈ A, we have: rankMB (A) =(b D if A ∈ B if A ∈ A \ B We use the following construction of lossless expanders from [Vad12], see also [BH11]. Theorem 3.20 ([Vad12]). Let k ≥ 2 and ǫ ≥ 0. For any L ≤ k, let D ≥ 2 log k/ǫ and n ≥ 6DL/ǫ. Then a (D, L, ǫ)-lossless expander exists. In the above theorem we can set parameters as follows: D = n 3 · 27 , L = 23, ǫ = 2−3, k = 2n/3·211 , b = n 3 · 28 . Note that under this choice of parameters we have 6DL/ǫ = n and 2 log k lossless expander with parameters set above exists. ǫ = D and hence a (D, L, ǫ)- Now consider the family of matroids M given by Theorem 3.19 using the expander construction above. The rest of the proof uses the probabilistic method. We will show non-constructively that there exists a matroid in this family whose rank function does not admit a sketch of dimension d = o(n). Let D = U (A) be the uniform distribution over A. By Yao's principle it suffices to show that there exists a matroid rank function for which any deterministic sketch fails with a constant probability over this distribution. In the proof below we first show that any fixed deterministic sketch succeeds on a randomly chosen matroid from M with only a very tiny probability, probability 22−Ω(n) Indeed, fix any deterministic sketch S of dimension d = n/211. Let {b1, . . . , b2d} be the set of all possible binary vectors of length d corresponding to the possible values of the sketch, so that each bi ∈ {0, 1}d. Let Sbi = {A ∈ A : S(A) = bi}. Let t = 1 proposition follows by a simple calculation. , and then take a union bound over all 2dn sketches of dimension at most d. and G = {bi ∈ {0, 1}dSbi ≥ t}. The following 4 2n/211 Proposition 3.21. If t = 1 4 2n/211 Proof. We have: 1 k Xbi∈G Sbi ≥ 1 − then 1 kPbi∈G Sbi ≥ 3 4 . 1 k Xbi : Sbi< k 4·2d Sbi ≥ 1 − 1 k · k 4 · 2d · 2d ≥ 3 4 . Let S1 bi = {A ∈ Sbi : rankMB(A) = b} and S2 bi following lemma. = {A ∈ Sbi : rankMB(A) = D}. We require the 4 2n/211 Lemma 3.22. Let t = 1 deterministic sketches S of dimension d and all bi ∈ G: 1 4Sbi. min(S1 bi,S2 bi) ≥ and d = n/211. There exists a matroid MB ∈ M such that for all 16 Proof. The proof uses the probabilistic method to show the existence of B with desired properties. Consider drawing a random matroid from the family M, i.e. pick B to be a uniformly random subset of A and consider MB. Fix any deterministic sketch S and any bi ∈ G. Since Sbi ≥ t, by the Chernoff bound, it holds that: Setting δ = 1/4, we have that the above probability is at most e−Ct for some constant C > 0. Applying the argument above to both S1 bi , we have that: and S2 bi 2 Pr bi(cid:12)(cid:12) >(cid:18) 1 B⊆A(cid:20)(cid:12)(cid:12)S1 B⊆A(cid:20)min((cid:12)(cid:12)S1 Let E denote the event that min((cid:12)(cid:12)S1 bi(cid:12)(cid:12) ,(cid:12)(cid:12)S2 Pr + δ(cid:19) Sbi(cid:21) ≤ e−cδ2Sbi ≤ e−cδ2t. 1 4Sbi(cid:21) ≤ 2e−Ct. bi(cid:12)(cid:12) ,(cid:12)(cid:12)S2 bi(cid:12)(cid:12)) < bi(cid:12)(cid:12)) ≥ 1 4Sbi. Note that the total number of deterministic sketches of dimension d is at most 2dn, since each sketch is specified by a collection of d linear functions over Fn 2 . Also note that for each sketch G ≤ 2d. Taking a union bound over all sketches and all sets G by the choice of t and d event E holds for all S and bi ∈ G with probability at least: = 1 − o(1). Thus, there exists some set B for which the statement of the lemma holds. 1 − 2(n+1)d+1e−Ct ≥ 1 − 2(n+1)d+12− C 4 2n/211 Fix the set B constructed in Lemma 3.22 and consider the function rankMB. Consider distribu- tion D over the inputs. The probability that any deterministic sketch over this distribution makes error at least D − b is at least: bi,S2 bi,S2 bi) min(S1 bi) ≥ 1 k Xbi∈{0,1}n 1 k Xbi∈G k Xbi∈G 1 min(S1 1 4Sbi 1 6 . ≥ ≥ 3 4 × 1 4 ≥ (by Lemma 3.22) (by Proposition 3.21) Finally, the construction of [BH11] ensures that the function rankMB takes integer values be- tween 0 and D. Using this and the fact that matroid rank functions are 1-Lipschitz, we can normalize it by dividing all values by D and ensure that the resulting function is O(1/n)-Lipschitz and takes values in [0, 1], while the sketch makes error at least (D − b)/D = 1 2 . 3.2.2 One-Way Communication of Lipschitz Submodular Functions In this section, we strengthen the lower bound shown above, extending it to the corresponding one-way communication problem. We use the same notation as in the previous section. Theorem 3.23. There exists a constant c1 > 0 and a c1 R→1/3 = Ω(n). n -Lipschitz submodular function such that 17 Proof. Let α = 1 3·211 and A = k = 2αn. Suppose Alice holds x ∈ A ⊆ {0, 1}n and Bob holds y ∈ {0, 1}n. Recall that in the one-way communication model for XOR functions, Alice must pass a message of minimal length to Bob, who must then compute f (x ⊕ y) with some probability, say 2 3 . Here, we let specifically let f be a scaling of a matroid rank function, which is some monotone n(cid:1)-Lipschitz submodular function. By Yao's principle, it suffices to show that non-negative (cid:0) c1 every deterministic one-way communication protocol using at most α greater than 1 deterministic one-way communication protocol, using at most α we furthermore suppose that Bob's input is fixed. 4 n bits fails with probability 3 over A. Suppose by way of contradiction, that Alice and Bob succeed through a 4 n bits. For the purpose of analysis, We now claim that if Alice passes a message to Bob using at most α 4 n bits, then there are at least 2αn − 4 · 2αn/4 points in A that are represented by the same message as at least five other points. Note that Alice can partition the input space A into at most 2αn/4 parts, each part with its own distinct representative message. The number of points not in parts containing at least five other points is at most 4 · 2αn/4. The remaining points, at least 2αn − 4 · 2αn/4 in quantity, are represented by the same message as at least five other points. Let S be the set of points in A represented by a given message from Alice. Hence, Alice assigns the same message to each of these points and passes the state of the protocol to Bob. Because Bob cannot distinguish between these points and must perform a deterministic protocol, then Bob must output the same result for each of these points. Recall that we consider Bob's input y ∈ {0, 1}n as fixed. Consider the family of functions F = {f : f (x ⊕ y) = b or f (x ⊕ y) = D for all x ∈ A}. 5 fraction Thus, if S contains at least five points, there exists f ∈ F such that Bob errs on at least 2 of the points in S by setting f (x ⊕ y) = b to at leastjS−1 2 k of the points x ∈ S and similarly for f (x⊕y) = D. Moreover, since Alice partitions the points in A, then there exists an f ∈ F such that Bob errs on at least 2 5 fraction on all points that are represented by the same message as at least five other points. Hence, the total number of inputs that Bob errs is at least 2 3 ·2αn for sufficiently large values of n. This contradicts the assumption that the communication protocol, using at most α 5(cid:0)2αn − 6 · 2αn/4(cid:1) > 1 4 n bits, succeeds with probability 2 3 . By restricting the n-dimensional elements to r coordinates and observing that the construction outputs matroids of rank b or D that are separated by a constant gap, we obtain the following result using the same proof: Corollary 3.24. There exists c = Ω(1) such that a c-approximation of matroid rank functions has randomized one-way communication complexity R→1/3 = Ω(r) where r is the rank of the underlying matroid. Acknowledgments We would like to thank Swagato Sanyal for multiple discussions leading to this paper, including the proof of Theorem 2.7 and Nikolai Karpov for his contributions to Section 3.1. We would also like to thank Amit Chakrabarti, Qin Zhang and anonymous reviewers for their comments. 18 References [Ack78] Dragan M Acketa. On the enumeration of matroids of rank-2. Zbornik radova Prirod- nomatematickog fakulteta -- Univerzitet u Novom Sadu, 8:83 -- 90, 1978. [AHLW16] Yuqing Ai, Wei Hu, Yi Li, and David P. Woodruff. New characterizations in turnstile In 31st Conference on Computational Complexity, CCC, streams with applications. pages 20:1 -- 20:22, 2016. [AKL16] Sepehr Assadi, Sanjeev Khanna, and Yang Li. Tight bounds for single-pass streaming complexity of the set cover problem. In Proceedings of the 48th Annual ACM SIGACT Symposium on Theory of Computing, STOC, pages 698 -- 711, 2016. [AMS99] Noga Alon, Yossi Matias, and Mario Szegedy. The space complexity of approximating the frequency moments. J. Comput. Syst. Sci., 58(1):137 -- 147, 1999. [BB17] Eric Blais and Abhinav Bommireddi. Testing submodularity and other properties of valuation functions. In 8th Innovations in Theoretical Computer Science Conference, ITCS, pages 33:1 -- 33:17, 2017. [BCIW12] Maria-Florina Balcan, Florin Constantin, Satoru Iwata, and Lei Wang. Learning val- uation functions. In COLT 2012 - The 25th Annual Conference on Learning Theory, June 25-27, 2012, Edinburgh, Scotland, pages 4.1 -- 4.24, 2012. [BDF+12] Ashwinkumar Badanidiyuru, Shahar Dobzinski, Hu Fu, Robert Kleinberg, Noam Nisan, and Tim Roughgarden. Sketching valuation functions. In Proceedings of the Twenty- Third Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 1025 -- 1035, 2012. [Bel92] Mihir Bellare. A technique for upper bounding the spectral norm with applications to learning. In Proceedings of the Fifth Annual ACM Conference on Computational Learning Theory, COLT 1992, pages 62 -- 70, 1992. [BEM17] MohammadHossein Bateni, Hossein Esfandiari, and Vahab S. Mirrokni. Almost op- timal streaming algorithms for coverage problems. In Proceedings of the 29th ACM Symposium on Parallelism in Algorithms and Architectures, SPAA, pages 13 -- 23, 2017. [BGKL03] L´aszl´o Babai, Anna G´al, Peter G. Kimmel, and Satyanarayana V. Lokam. Communi- cation complexity of simultaneous messages. SIAM J. Comput., 33(1):137 -- 166, 2003. [BH11] Maria-Florina Balcan and Nicholas J. A. Harvey. Learning submodular functions. In Proceedings of the 43rd ACM Symposium on Theory of Computing, STOC, pages 793 -- 802, 2011. [BJKK04] Ziv Bar-Yossef, T. S. Jayram, Robert Krauthgamer, and Ravi Kumar. The sketching complexity of pattern matching. In Approximation, Randomization, and Combina- torial Optimization, Algorithms and Techniques, 7th International Workshop on Ap- proximation Algorithms for Combinatorial Optimization Problems, APPROX, and 8th International Workshop on Randomization and Computation, RANDOM, Proceedings, pages 261 -- 272, 2004. 19 [BK97] L´aszl´o Babai and Peter G. Kimmel. Randomized simultaneous messages: Solution of a problem of yao in communication complexity. In Proceedings of the Twelfth Annual IEEE Conference on Computational Complexity, pages 239 -- 246, 1997. [BMKK14] Ashwinkumar Badanidiyuru, Baharan Mirzasoleiman, Amin Karbasi, and Andreas Krause. Streaming submodular maximization: massive data summarization on the fly. In The 20th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD, pages 671 -- 680, 2014. [BOSY13] Eric Blais, Krzysztof Onak, Rocco Servedio, and Grigory Yaroslavtsev. Concise repre- sentations of discrete submodular functions, 2013. [BS92] Jehoshua Bruck and Roman Smolensky. Polynomial threshold functions, ac0 func- tions, and spectral norms. SIAM J. Comput., 21(1):33 -- 42, 1992. [CGQ15] [CH12] Chandra Chekuri, Shalmoli Gupta, and Kent Quanrud. Streaming algorithms for sub- modular function maximization. In Automata, Languages, and Programming - 42nd International Colloquium, ICALP, Proceedings, Part I, pages 318 -- 330, 2015. Deeparnab Chakrabarty and Zhiyi Huang. Testing coverage functions. In Automata, Languages, and Programming - 39th International Colloquium, ICALP, Proceedings, Part I, pages 170 -- 181, 2012. [CKKL12] Mahdi Cheraghchi, Adam R. Klivans, Pravesh Kothari, and Homin K. Lee. Submodular In Proceedings of the Twenty-Third Annual ACM-SIAM functions are noise stable. Symposium on Discrete Algorithms, SODA, pages 1586 -- 1592, 2012. [CR12] [CW16] Amit Chakrabarti and Oded Regev. An optimal lower bound on the communication complexity of gap-hamming-distance. SIAM J. Comput., 41(5):1299 -- 1317, 2012. Amit Chakrabarti and Anthony Wirth. Incidence geometries and the pass complexity of semi-streaming set cover. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2016, pages 1365 -- 1373, 2016. [DIMV14] Erik D. Demaine, Piotr Indyk, Sepideh Mahabadi, and Ali Vakilian. On streaming and communication complexity of the set cover problem. In Distributed Computing - 28th International Symposium, DISC. Proceedings, pages 484 -- 498, 2014. [DKS12] [ER16] [FIS08] Anirban Dasgupta, Ravi Kumar, and D. Sivakumar. Sparse and lopsided set disjoint- ness via information theory. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques - 15th International Workshop, APPROX, and 16th International Workshop, RANDOM. Proceedings, pages 517 -- 528, 2012. Yuval Emek and Adi Ros´en. Semi-streaming set cover. ACM Trans. Algorithms, 13(1):6:1 -- 6:22, 2016. Gereon Frahling, Piotr Indyk, and Christian Sohler. Sampling in dynamic data streams and applications. Int. J. Comput. Geometry Appl., 18(1/2):3 -- 28, 2008. 20 [FK14] [FKV13] [FV15] Vitaly Feldman and Pravesh Kothari. Learning coverage functions and private release of marginals. In Proceedings of The 27th Conference on Learning Theory, COLT, pages 679 -- 702, 2014. Vitaly Feldman, Pravesh Kothari, and Jan Vondr´ak. Representation, approximation and learning of submodular functions using low-rank decision trees. In COLT 2013 - The 26th Annual Conference on Learning Theory, pages 711 -- 740, 2013. Vitaly Feldman and Jan Vondr´ak. Tight bounds on low-degree spectral concentration of submodular and XOS functions. In IEEE 56th Annual Symposium on Foundations of Computer Science, FOCS, pages 923 -- 942, 2015. [FV16] Vitaly Feldman and Jan Vondr´ak. Optimal bounds on approximation of submodular and XOS functions by juntas. SIAM J. Comput., 45(3):1129 -- 1170, 2016. [GHIM09] Michel X. Goemans, Nicholas J. A. Harvey, Satoru Iwata, and Vahab S. Mirrokni. In Proceedings of the Twentieth Approximating submodular functions everywhere. Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 535 -- 544, 2009. [GHRU13] Anupam Gupta, Moritz Hardt, Aaron Roth, and Jonathan Ullman. Privately releasing conjunctions and the statistical query barrier. SIAM J. Comput., 42(4):1494 -- 1520, 2013. [Gro97] Vince Grolmusz. On the power of circuits with gates of low l1 norms. Theor. Comput. Sci., 188(1-2):117 -- 128, 1997. [HHL16] Hamed Hatami, Kaave Hosseini, and Shachar Lovett. Structure of protocols for XOR functions. In IEEE 57th Annual Symposium on Foundations of Computer Science, FOCS, pages 282 -- 288, 2016. [HIMV16] Sariel Har-Peled, Piotr Indyk, Sepideh Mahabadi, and Ali Vakilian. Towards tight bounds for the streaming set cover problem. In Proceedings of the 35th ACM SIGMOD- SIGACT-SIGAI Symposium on Principles of Database Systems, PODS, pages 371 -- 383, 2016. [HLY18] Kaave Hosseini, Shachar Lovett, and Grigory Yaroslavtsev. Optimality of linear sketch- ing under modular updates. Electronic Colloquium on Computational Complexity (ECCC), 25:169, 2018. [HSZZ06] Wei Huang, Yaoyun Shi, Shengyu Zhang, and Yufan Zhu. The communication com- plexity of the hamming distance problem. Inf. Process. Lett., 99(4):149 -- 153, 2006. [IW03] [Jay10] Piotr Indyk and David P. Woodruff. Tight lower bounds for the distinct elements prob- lem. In 44th Symposium on Foundations of Computer Science (FOCS), Proceedings, pages 283 -- 288, 2003. Information complexity: a tutorial. T. S. Jayram. In Proceedings of the Twenty- Ninth ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Sys- tems, PODS, pages 159 -- 168, 2010. 21 [JKS08] T. S. Jayram, Ravi Kumar, and D. Sivakumar. The one-way communication complexity of hamming distance. Theory of Computing, 4(1):129 -- 135, 2008. [JL84] William B. Johnson and Joram Lindenstrauss. Extensions of lipschitz mappings into a hilbert space. In Conference in modern analysis and probability, pages 189 -- 206, 1984. [KLM+17] Michael Kapralov, Yin Tat Lee, Cameron Musco, Christopher Musco, and Aaron Sidford. Single pass spectral sparsification in dynamic streams. SIAM J. Comput., 46(1):456 -- 477, 2017. [KMSY18] Sampath Kannan, Elchanan Mossel, Swagato Sanyal, and Grigory Yaroslavtsev. Linear sketching over f 2. In 33rd Computational Complexity Conference, CCC, pages 8:1 -- 8:37, 2018. [KN97] Eyal Kushilevitz and Noam Nisan. Communication complexity. Cambridge University Press, 1997. [KNP+17] Michael Kapralov, Jelani Nelson, Jakub Pachocki, Zhengyu Wang, David P. Woodruff, and Mobin Yahyazadeh. Optimal lower bounds for universal relation, and for samplers and finding duplicates in streams. In 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS, pages 475 -- 486, 2017. [KNR99] Ilan Kremer, Noam Nisan, and Dana Ron. On randomized one-round communication complexity. Computational Complexity, 8(1):21 -- 49, 1999. [LLN06] [LLZ11] Benny Lehmann, Daniel J. Lehmann, and Noam Nisan. Combinatorial auctions with decreasing marginal utilities. Games and Economic Behavior, 55(2):270 -- 296, 2006. Ming Lam Leung, Yang Li, and Shengyu Zhang. Tight bounds on the randomized communication complexity of symmetric XOR functions in one-way and SMP models. CoRR, abs/1101.4555, 2011. [LNW14] Yi Li, Huy L. Nguyen, and David P. Woodruff. Turnstile streaming algorithms might as well be linear sketches. In Symposium on Theory of Computing, STOC, pages 174 -- 183, 2014. [Lov14] [LZ10] [LZ13] Shachar Lovett. Recent advances on the log-rank conjecture in communication com- plexity. Bulletin of the EATCS, 112, 2014. Troy Lee and Shengyu Zhang. Composition theorems in communication complexity. In Automata, Languages and Programming, 37th International Colloquium, ICALP, Proceedings, Part I, pages 475 -- 489, 2010. Yang Liu and Shengyu Zhang. Quantum and randomized communication complexity of XOR functions in the SMP model. Electronic Colloquium on Computational Complexity (ECCC), 20:10, 2013. [LZ18] Shachar Lovett and Jiapeng Zhang. DNF sparsification beyond sunflowers. Electronic Colloquium on Computational Complexity (ECCC), 25:190, 2018. 22 [McG14] Andrew McGregor. Graph stream algorithms: a survey. SIGMOD Record, 43(1):9 -- 20, 2014. [MNSW98] Peter Bro Miltersen, Noam Nisan, Shmuel Safra, and Avi Wigderson. On data struc- tures and asymmetric communication complexity. J. Comput. Syst. Sci., 57(1):37 -- 49, 1998. [MO09] Ashley Montanaro and Tobias Osborne. On the communication complexity of XOR functions. CoRR, abs/0909.3392, 2009. [O'D14] Ryan O'Donnell. Analysis of Boolean Functions. Cambridge University Press, 2014. [RY13] [SG09] [SV14] [SW12] [SZ08] [Tha16] Sofya Raskhodnikova and Grigory Yaroslavtsev. Learning pseudo-boolean k -dnf and submodular functions. In Proceedings of the Twenty-Fourth Annual ACM-SIAM Sym- posium on Discrete Algorithms, SODA, pages 1356 -- 1368, 2013. Barna Saha and Lise Getoor. On maximum coverage in the streaming model & appli- cation to multi-topic blog-watch. In Proceedings of the SIAM International Conference on Data Mining, SDM, pages 697 -- 708, 2009. C. Seshadhri and Jan Vondr´ak. Is submodularity testable? Algorithmica, 69(1):1 -- 25, 2014. Xiaoming Sun and Chengu Wang. Randomized communication complexity for linear algebra problems over finite fields. In 29th International Symposium on Theoretical Aspects of Computer Science, STACS, pages 477 -- 488, 2012. Yaoyun Shi and Zhiqiang Zhang. Communication complexities of symmetric xor func- tions. Quantum Inf. Comput, pages 0808 -- 1762, 2008. Justin Thaler. Semi-streaming algorithms for annotated graph streams. In 43rd Inter- national Colloquium on Automata, Languages, and Programming, ICALP 2016, July 11-15, 2016, Rome, Italy, pages 59:1 -- 59:14, 2016. [TWXZ13] Hing Yin Tsang, Chung Hoi Wong, Ning Xie, and Shengyu Zhang. Fourier sparsity, In 54th Annual IEEE Symposium on spectral norm, and the log-rank conjecture. Foundations of Computer Science, FOCS, pages 658 -- 667, 2013. [Vad12] [Von10] Salil P. Vadhan. Pseudorandomness. Foundations and Trends in Theoretical Computer Science, 7(1-3):1 -- 336, 2012. Jan Vondr´ak. A note on concentration of submodular functions. CoRR, abs/1005.2791, 2010. [Woo14] David P. Woodruff. Sketching as a tool for numerical linear algebra. Foundations and Trends in Theoretical Computer Science, 10(1-2):1 -- 157, 2014. [ZS10] Zhiqiang Zhang and Yaoyun Shi. On the parity complexity measures of boolean func- tions. Theor. Comput. Sci., 411(26-28):2612 -- 2618, 2010. 23 A Background A.1 Fourier Analysis 2 2 2 [f (x)g(x)] = 1 (f (x) − g(x))2. 2nPx∈Fn 2 to R. For any fixed n ≥ 1, the space of these functions forms an f (x)g(x). The ℓ2 We consider functions5 from Fn inner product space with the inner product hf, gi = Ex∈Fn norm of f : Fn f, g : Fn 2 → R is kfk2 =phf, fi =pEx[f (x)2] and the ℓ2 distance between two functions 2 → R is the ℓ2 norm of the function f − g. In other words, kf − gk2 =phf − g, f − gi = q 1 2nPx∈Fn 2 we denote the inner product as x · y = Pn For x, y ∈ Fn 2 , the character 2 → {+1,−1} is the function defined by χα(x) = (−1)α·x. Characters form an orthonormal χα : Fn basis as hχα, χβi = δαβ where δ is the Kronecker symbol. The Fourier coefficient of f : Fn 2 → R corresponding to α is f (α) = Ex[f (x)χα(x)]. The Fourier transform of f is the function f : Fn 2 → R that returns the value of each Fourier coefficient of f . The Fourier ℓ1 norm, or the spectral norm of f , is defined as k fk1 :=Pα∈Fn i=1 xiyi. For α ∈ Fn 2 f (α). Fact A.1 (Parseval's identity). For any f : Fn Moreover, if f : Fn 2 → {+1,−1} then kfk2 = k fk2 = 1. 2 → R it holds that kfk2 = k fk2 =qPα∈Fn 2 f (α)2. A.1.1 Fourier ℓ1-Sampling The following Fourier ℓ1-sampling primitive is based on the work of Bruck and Smolensky [Bel92] (see also [Gro97, MO09]). Here we need to analyze its properties for approximating real-valued functions instead of computing Boolean functions as in [Gro97, MO09]. Proposition A.2 (Fourier ℓ1-sampling). For any f : Fn Proof. Sample S ∈ {0, 1}n from the following distribution: Pr[S = S] = f (S) k fk1 2 → R it holds that ¯Rlin ǫ (f ) = O(k fk2 . Let Z = sgn( f (S))χS(x)k fk1. 1/ǫ). Then: E[Z] = E S [sgn( f (S))χS(x)k fk1] = XS∈{0,1}n sgn( f (S)) f (S) k fk1 = XS∈{0,1}n f (S)χS(x) χS(x)k fk1 5 In all Fourier-analytic arguments Boolean functions are treated as functions of the form f : Fn where 0 is mapped to 1 and 1 is mapped to −1. Otherwise we use these two notations interchangeably. 2 → {+1, −1} =f (x). 24 Variance of Z is: V ar[Z] = E S(cid:20)(cid:16)sgn( f (S))χS(x)k fk1 − f (x)(cid:17)2(cid:21) [sgn( f (S))χS(x)] 1 + f (x)2 − 2k fk1f (x) E =k fk2 =k fk2 1 − f (x)2 ≤k fk2 1. S Thus averaging Z over k fk2 1 ǫ repetitions reduces variance to at most ǫ as desired. It follows from Proposition A.2 that additive and coverage functions admit small approximate F2-sketches. Corollary A.3. Let ℓw(x) : {0, 1}n → R be an additive function ℓw(x) =Pn 1/ǫ, n)). Proof. Note that kℓwk1 = O(kwk1) and hence the bound follows. 2 → [0, 1] is a coverage function then ¯Rlin Corollary A.4. If f : Fn Proof. It is known (see Lemma 3.1 in [FK14]) that for such coverage functions k fk1 ≤ 2 and hence the desired bound follows from Proposition A.2. ¯Rlin ǫ (ℓw) = O(min(kwk2 ǫ (f ) = O(1/ǫ). i=1 wixi. Then 2 , 1 However, direct Fourier ℓ1-sampling can fail even in some fairly basic situations, e.g. even (x) = for budget-additive functions. Consider, for example, the "hockey stick" function: hs 1 2 min(cid:0) 1 i=1 xi(cid:1). Fourier spectrum of this function is well-understood (see. e.g. [FV15]) and nPn in particular k fk1 = 2Ω(n). Nevertheless small sketches for budget-additive functions can be con- structed using the following composition theorem. A function f : Rn → R is α-Lipschitz if f (x) − f (y) ≤ αkx − yk2 for any x, y ∈ Rn and some constant α > 06. Proposition A.5 (Composition theorem). If h : Rt → R is an α-Lipschitz function then for any functions f1, . . . , ft where fi : Fn 2 → R it holds that: ¯Rlin ǫ (h(f1, . . . , ft)) ≤ ¯Rlin ǫ/α2t(fi). tXi=1 Proof. Let f′1, . . . , f′t be the sketches of f1, . . . , ft respectively. Applying h to their values we have: E[(h(f′1, . . . , f′t) − h(f1, . . . , ft))2] ≤ E[α2kf′ − fk2 2] = α2 tXi=1 E[(f′i(x) − fi(x))2] ≤ ǫ. From Corollary A.3 and Proposition A.5 the following bound on approximate F2-sketch com- plexity of budget-additive functions follows immediately. 6Note that this definition is slightly different from the corresponding definition for functions over the Boolean hypercube 25 Proof. In the composition theorem above, we set h = min(b, z) and hence h is a 1-Lipschitz function i=1 wixi as f1 and the proof follows. Corollary A.6. For any budget additive function f (x) = min(b,Pn ¯Rlin ǫ (f ) = O(min(kwk2 of z. Hence we can set α = 1 and t = 1 by treatingPn Let ℓw(x) : {0, 1}n → R be an additive function ℓw(x) = Pn A.1.2 Optimality of Fourier ℓ1-Sampling 1/ǫ, n)). i=1 wixi parametrized by w ∈ Rn with non-negative weights w1, w2 . . . , wn. The corresponding XOR-function ℓ+ w(x, y) gives weighted Hamming distance between vectors x and y. The following result can be seen as a generalization of the unweighted Gap Hamming lower bound due to Jayram, Kumar and Sivakumar [JKS08] (see also [IW03, CR12]). Theorem A.7. For any additive function ℓw of the form ℓw(x) =Pn that for any ǫ ≥ kwk2 2: i=1 wixi where wi ≥ 0 it holds ¯R→ǫ (ℓ+ ǫ (cid:19) . w ) = Ω(cid:18)kwk2 1 Proof. We use reduction from the standard communication problem INDEX. In this problem Alice is given a ∈ {0, 1}n and Bob is given t ∈ [n]. Alice needs to send one message to Bob so that he can compute at. It is well-known that this requires linear communication: Theorem A.8 ([KNR99]). R→1/3(INDEX) = Ω(n). Let n be odd and k be a parameter to be chosen later. Consider an instance of indexing where Alice has an input a ∈ {−1, 1}k and Bob has an index t ∈ [k]. Draw n random vectors r1, . . . , rn where each ri is uniform over {−1, 1}k. Construct vectors x, y ∈ {−1, 1}n as follows: xi = sign(ha, rii), yi = sign(ri,t), 2 + c√k w(x, y) < 1 Note that if at = 1 then Pr[xi = yi] ≥ 1 where we define sign(z) = −1 if z ≤ 0 and sign(z) = 1 if z > 0. for some absolute constant c > 0. Now consider the function ℓ+ i=1 wi(xi + yi). We will show 2kwk1 + 2√ǫ if at = 1 that for a suitable choice of k with a large constant probability ℓ+ 2kwk1 − 2√ǫ = if at = −1. By Markov's inequality, a communication protocol for and ℓ+ ℓ+ w with expected squared error ǫ has squared error at most 4ǫ (and hence absolute error at most 2√ǫ) with probability at least 3/4. Hence, such a protocol can distinguish these two cases with probability 3/4 − ξ where ξ is the error probability introduced by the reduction. If ξ < 1/12 then it can solve indexing on strings of length k with probability at least 2/3 and so a lower bound of Ω(k) follows. , otherwise Pr[xi = yi] ≤ 1 w(x, y) = Pn w(x, y) > 1 2 − c√k Indeed, consider the case at = −1, as the case at = 1 is symmetric. Let Zi be a random variable defined as Zi = wiI[xi = yi]. We have E[Zi] ≤ wi(cid:16) 1 i=1 Zi, then: i=1 wixi) it holds that: E[Z] ≤ nXi=1 wi(cid:18) 1 2 − 2 − c√k(cid:17). Let Z =Pn √k(cid:19) . √k(cid:19) = kwk1(cid:18) 1 2 − c c 26 Let Xi = Z≤i − E[Z≤i] where Z≤i =Pi j=1 Zj. We have E[Xi+1X1, . . . , Xi] = E[Z≤i+1 − E[Z≤i+1]X1, . . . , Xi] = E[Zi+1 − E[Zi+1] + XiX1, . . . , Xi] = E[Zi+1 − E[Zi+1]] + Xi = Xi, and hence Xi is a martingale. Furthermore, for every i it holds that: Xi − Xi−1 = Z≤i − E[Z≤i] − Z≤i−1 + E[Z≤i−1] = Zi − E[Zi] < wi. We can now use the following form of Azuma's inequality: Theorem A.9 (Azuma's inequality). If Xi for i = 0, 1, . . . is a martingale such that X0 = 0 and Xi − Xi−1 < ci almost surely then for every integer m and positive real θ it holds that: Pr[Xm ≥ θ] ≤ e− θ2 2 Pm i=1 c2 i . Applying Azuma's inequality we have: Pr[Xn ≥ θ] ≤ e− θ2 2kwk2 and hence: 2 . Recall that E[Z≤n] ≤ kwk1(cid:16) 1 2 − c√k(cid:17) Pr(cid:20)Z ≥ kwk1(cid:18) 1 2 − c √k(cid:19) + θ(cid:21) ≤ e−θ2/2kwk2 2. Setting θ = ckwk1 2√k we have PrhZ ≥ kwk1 2 (1 − c/√k)i ≤ e− c2kwk2 1 8kkwk2 2 . If k = c2kwk2 36kwk2 1 2 then: Pr(cid:20)Z ≥ kwk1 2 − 3kwk2(cid:21) ≤ e−4. Using similar analysis for the case at = 1 we conclude that with probability at least 1 − 2e−4 > 2 + 3kwk2i ≤ e−4 and hence error probability ξ 1 − 1/12 in this case it holds that PrhZ ≤ kwk1 introduced by the reduction is at most 1/12. Thus using this reduction we obtain a protocol for solving indexing on strings of length k with probability at least 2/3 and the lower bound of Ω(k) = Ω(kwk2 A.2 2) = Ω(kwk2 Information Theory 1/ǫ) follows where we used the fact that ǫ ≥ kwk2 2. 1/kwk2 Let X be a random variable supported on a finite set {x1, . . . , xs}. Let E be any event in the same probability space. Let P[·] denote the probability of any event. The conditional entropy H(X E) of X conditioned on E is defined as follows. Definition A.10 (Conditional entropy). H(X E) := sXi=1 P[X = xi E] log2 1 P[X = xi E] An important special case is when E is the entire sample space. In that case the above conditional entropy is referred to as the Shannon entropy H(X) of X. 27 Definition A.11 (Entropy). H(X) := P[X = xi] log2 1 P[X = xi] Let Y be another random variable in the same probability space as X, taking values from a finite set {y1, . . . , yt}. Then the conditional entropy of X conditioned on Y , H(X Y ), is defined as follows. Definition A.12. H(X Y ) = P[Y = yi] · H(X Y = yi) sXi=1 tXi=1 We next define the binary entropy function Hb(·). Definition A.13 (Binary entropy). For p ∈ (0, 1), the binary entropy of p, Hb(p), is defined to be the Shannon entropy of a random variable taking two distinct values with probabilities p and 1 − p. Hb(p) := p log2 1 p + (1 − p) log 1 1 − p . The following properties of entropy and conditional entropy will be useful. Fact A.14. (1) Let X be a random variable supported on a finite set A, and let Y be another random variable in the same probability space. Then 0 ≤ H(X Y ) ≤ H(X) ≤ log2 A. (2) (Sub-additivity of conditional entropy). Let X1, . . . , Xn be n jointly distributed random vari- ables in some probability space, and let Y be another random variable in the same probability space, all taking values in finite domains. Then, H(X1, . . . , Xn Y ) ≤ nXi=1 H(Xi Y ). (3) Let X1, . . . , Xn are independent random variables taking values in finite domains. Then, H(X1, . . . , Xn) = H(Xi). nXi=1 (4) (Taylor expansion of binary entropy in the neighborhood of 1 2 ). (1 − 2p)2n n(2n − 1) Hb(p) = 1 − 2 loge 2 1 ∞Xn=1 Definition A.15 (Mutual information). Let X and Y be two random variables in the same proba- bility space, taking values from finite sets. The mutual information between X and Y , I(X; Y ), is defined as follows. It can be shown that I(X; Y ) is symmetric in X and Y , i.e. I(X; Y ) = I(Y ; X) = H(Y )−H(Y X). I(X; Y ) := H(X) − H(X Y ). The following observation follows immediately from the first inequality of Fact A.14 (1). Fact A.16. For any two random variables X and Y , I(X; Y ) ≤ H(X). 28 B Missing Proofs B.1 Proof of Theorem 2.7 Proof of Theorem 2.7: Proof. The proof is largely based on a similar proof in [KMSY18] except that here we work with real-valued functions with unbounded norm. In the next two lemmas, we look into the structure of a one-way communication protocol for f +, and analyze its performance when the inputs are uniformly distributed. We give a lower bound on the number of bits of information that any correct randomized one-way protocol reveals about Alice's input7, in terms of the linear sketching complexity of f for uniform distribution. The next lemma bounds the probability of error of a one-way protocol from below in terms of the Fourier coefficients of f , and the conditional distributions of different parities of Alice's input conditioned on Alice's random message. Lemma B.1. Let ǫ ∈ [0, 1 f +(x, y)]2 ≤ ǫ. Let M denote the distribution of the random message sent by Alice to Bob in Π. For any fixed message m sent by Alice, let Dm denote the distribution of Alice's input x conditioned on the event that M = m. Then, 2 ). Let Π be a deterministic one-way protocol for f + such that Ex,y∼U (Fn 2 )[Π(x, y)− ǫ ≥ Xα∈Fn 2 bf (α)2 · 1 − E [χα(x)](cid:19)2! . m∼M(cid:18) E m := Ex∼Dm(Π(x, y) − f +(x, y))2. Thus, x∼Dm Proof. For any fixed input y of Bob, define ǫ(y) ǫ ≥ E m∼M E y∼U (Fn 2 ) [ǫ(y) m ]. (1) Note that the output of the protocol is determined by Alice's message and y. Hence for a fixed message and Bob's input, if the restricted function has high variance, the protocol is forced to commit error with high probability. Formally, let a(y) m be the output of the protocol when Alice's message is m and Bob's input is y. Also, define µ(y) m := Ex∼Dm[f +(x, y)]. Then, 7We thus prove an information complexity lower bound. See, for example, [Jay10] for an introduction to informa- (2) m ))2i m − µ(y) m )2)i + 2(a(y) m − µ(y) m − µ(y) m ) E x∼Dmh(µ(y) m − f +(x, y))i ǫ(y) m = E = E = E m − f +(x, y))2i m − f +(x, y)) + (a(y) m − f +(x, y))2 + (a(y) m − f +(x, y))2i x∼Dmh(a(y) x∼Dmh((µ(y) x∼Dmh((µ(y) x∼Dmh(µ(y) = Varx∼Dm(cid:2)f +(x, y)(cid:3) . ≥ E tion complexity. 29 Now, = E x∼Dm = E x∼Dm Varx∼Dm[f +(x, y)] = E x∼Dm 2 x∼Dm x∼Dm [f +(x, y)](cid:19)2 [f +(x, y)2] −(cid:18) E [χα(x)] 2 bf (α)χα(y) E [χα(x)](cid:19)2 2 bf (α)2(cid:18) E 2 :α16=α2 bf (α1)bf (α2)χα1+α2 (y) E x∼Dm x∼Dm [f +(x, y)2] −Xα∈Fn [f +(x, y)2] −Xα∈Fn X (α1,α2)∈Fn 2 ×Fn + Taking expectation over y we have: E y∼U (Fn 2 )(cid:2)Varx∼Dm[f +(x, y)](cid:3) = E y∼U (Fn 2 ) E x∼Dm [f +(x, y)2] − Xα∈Fn [f +(x, y)2] − Xα∈Fn 2 bf (α)2(cid:18) E 2 bf (α)2(cid:18) E 2 bf (α)2(cid:18) E [χα(x)](cid:19)2 x∼Dm , x∼Dm x∼Dm = E x∼Dm E y∼U (Fn 2 ) = kfk2 2 − Xα∈Fn [χα1 (x)] E x∼Dm [χα2 (x)] . [χα(x)](cid:19)2 [χα(x)](cid:19)2 where in the last step we used the fact that for any fixed x we have Ey∼U (Fn Ez∼U (Fn 2. Taking expectation over messages it follows using (1), (2) that, 2 )[f 2(z)] = kfk2 2 )[f +(x, y)2] = 2 − Xα∈Fn 2 bf (α)2 · E ǫ ≥ kfk2 2 bf (α)2 · 1 − E = Xα∈Fn m∼M(cid:18) E m∼M(cid:18) E x∼Dm x∼Dm [χα(x)](cid:19)2 [χα(x)](cid:19)2! . (3) The second equality above follows from Parseval's identity. The lemma follows. Fn Let Π be a deterministic protocol such that Ex,y∼U (Fn 2 )[(Π(x, y) − f +(x, y))2] ≤ ǫ, with optimal cost cΠ := D→,U (f +). To prove our theorem, we use the protocol Π to come up with a subspace of 2 . Next, in Lemma B.2 (a) we prove, using Lemma B.1, that f is ξ-concentrated on that subspace where ξ = kfk2 2 − ǫ(1 + 2δ). In Lemma B.2 (b) we upper bound the dimension of that subspace in terms of cΠ. ǫ Let Aδ := {α ∈ Fn 2 : Em∼M (Ex∼Dm χα(x))2 ≥ δ} ⊆ Fn 2 . Lemma B.2. Let δ ∈ [0, 1/2] and ξ = kfk2 2 − ǫ(1 + 2δ), thenPα /∈span(Aδ ) bf (α)2 ≤ kfk2 2 − ξ. 30 Proof. We show that f is ξ-concentrated on span(Aδ). By Lemma B.1 we have that m∼M(cid:18) E x∼Dm χα(x)(cid:19)2! + Xα /∈span(Aδ )bf (α)2 · 1 − E m∼M(cid:18) E x∼Dm χα(x)(cid:19)2! ǫ ≥ Xα∈span(Aδ )bf (α)2 · 1 − E > (1 − δ) · Xα /∈span(Aδ )bf (α)2. ThusPα /∈span(Aδ ) bf (α)2 < ǫ 1−δ ≤ ǫ · (1 + 2δ) = kfk2 2 − ξ (since δ ≤ 1/2). Now we are ready to complete the proof of Theorem 2.7. Let ℓ = dim(span(Aδ)). Then it suffices to show that ℓ ≤ 2cΠ δ . Note that χα(x) is a unbiased random variable taking values in {1,−1}. For each α in the set Aδ in Proposition B.2, the value of Em∼M (Ex∼Dm χα(x))2 is bounded away from 0. This suggests that for a typical message m drawn from M , the distribution of χα(x) conditioned on the event M = m is significantly biased. Fact B.3 enables us to conclude that Alice's message reveals Ω(1) bit of information about χα(x). However, since the total information content of Alice's message is at most cΠ, there can be at most O(cΠ) independent vectors in Aδ. Now we formalize this intuition. In the derivation below we use several standard facts about properties of entropy and mutual information which can be found in Appendix A.2. We will need the following fact about entropy of a binary random variable. The proof can be found in Appendix A of [KMSY18]. Fact B.3. For any random variable X supported on {1,−1}, H(X) ≤ 1 − 1 2 (EX)2. Let T = {α1, . . . , αℓ} be a basis of span(Aδ). Then, cΠ ≥ H(M ) ≥ I(M ; χα1 = H(χα1 = ℓ − H(χα1 (x), . . . , χαℓ (x)) (x), . . . , χαℓ (x)) − H(χα1 (x) M ) (x), . . . , χαℓ (x), . . . , χαℓ (x) M ) ℓXi=1 ℓXi=1 ≥ ℓ − H(χαi (x) M ) ≥ ℓ − (1 − ≥ ℓ − ℓ(cid:18)1 − δ · 1 2(cid:0)E[χαi 2(cid:19) 1 (x)M ])2(cid:1) (by Fact B.3) ℓδ 2 = Thus ℓ ≤ 2cΠ δ . . ✷ 31 C Subadditive Functions Definition C.1. A function f : 2[n] → R+ is subadditive if f (A ∪ B) ≤ f (A) + f (B) for all A, B ⊆ [n]. The class of XS functions introduced in [LLN06] are subadditive functions that correspond to unit demand functions f (S) = maxi∈S wi. Similarly, a subadditive function f is XOS if f can be expressed as the maximum of a number of linear combinations of valuations, where each weight in the linear combination is positive, f (S) = max1≤i≤k w⊤i χ(S), where wi,j ≥ 0 for all i ∈ [n]. By flipping the roles of the MAX and SUM operators, we obtain a strict subclass of XOS valuations, called OXS functions. It is known that OXS functions is a strict subset of submodular functions, which is a strict subset of XOS functions, which is a strict subset of subadditive functions [LLN06]. For more details on subadditive functions, see [BCIW12]. C.1 Lower Bound for XS Functions Theorem C.2. If f is an XS function corresponding to a collection of distinct weights then R→1/3(f +) = Ω(n). Proof. Let w1 > w2 > ··· > wn. We use a reduction from a standard communication problem called Augmented Indexing, denoted AI(x, i). In this problem Alice's input is x ∈ Fn 2 and Bob's input is i ∈ [n] and the bits x1, . . . , xi−1. Theorem C.3 ([MNSW98, BJKK04]). R→1/3(AI) = Ω(n). In order to solve AI(x, i) using a protocol for f + set x′ = x and y′ = (x1, . . . , xi−1, 0, . . . , 0). If AI(x, i) = 1 then f +(x′ + y′) = wi, otherwise f +(x′ + y′) ≤ wi+1. Hence an Ω(n) lower bound follows. D Communication Under the Uniform Distribution In this section, we switch to lower bounds for the uniform distribution and show the following result for the "hockey stick" function: Theorem D.1. For any odd n, constant c > 0 and α = c√n there exists a constant ǫ > 0 such that for the"hockey stick" function hsα(x) = min(α, 2α i=1 xi) it holds that: n Pn ¯D→,U ǫ (hs+ α ) = Ω(n) The proof relies on the characterization of communication complexity using approximate Fourier dimension (Theorem 2.7). We also require a structural result, whose proof we defer to Section D.1, about the Fourier spectrum of the hockey stick function. Lemma D.2. Let n be odd and let hsα(x) = min(α, 2α i=1 xi) then: where [n] denotes the set {1, . . . , n}. n Pn 2 −dhsα(∅)2 −dhsα([n])2 = Θ(cid:18) α2 n(cid:19) , kdhsαk2 32 We are now ready to prove Theorem D.1. Proof of Theorem D.1: By Lemma D.2 it follows thatPS6=∅,S6=[n]dhsα(S)2 = Ω(cid:16) α2 as α = c√n. Since hsα is a symmetric function and hence its Fourier coefficients for all sets of the same size are the same, one can show that it is not khsαk2 2 − ǫ-concentrated on o(n)-dimensional subspaces. Formally, this is proved in Theorem 4.6 in [KMSY18] which shows that there exists ǫ > 0 such that dimkfk2 2−ǫ(f ) = Ω(n) for any symmetric function which satisfies the condition PS6=∅,S6=[n] f (S)2 = Ω(1). n(cid:17) = Ω(1), ✷ D.1 Fourier Spectrum of the "Hockey Stick" Function In this section, we bound the fourier spectrum of the "hockey stick" function. Proof of Lemma D.2: We have: 2 2α n 2 . Hence: 4α2 n2 khsαk2 We also have: ⌊n/2⌋Xi=0 2 = 2−n Xx∈{0,1}n dhsα(∅)2 =2−n Xx∈{0,1}n i(cid:19) hsα(x)2 = 2−nα22n−1 + i2(cid:18)n hsα(x) i(cid:19) = 2−2nα2n−1 + i(cid:18)n ⌊n/2⌋Xi=0 n222n 2 −dhsα(∅)2 = 4α2 1 i(cid:18)n i(cid:19) − i2(cid:18)n i(cid:19) − ⌊n/2⌋Xi=0 ⌊n/2⌋Xi=0 ⌊n/2⌋Xi=0 kdhsαk2 i(cid:1) = i For i ≥ 1 we have i(cid:0)n i−1(cid:1). Hence: (i−1)!(n−i)! = n(cid:0)n−1 i!(n−i)! = n (n−1)! i(cid:18)n i(cid:19) = n ⌊n/2⌋−1Xi=0 (cid:18)n − 1 i (cid:19) = n(2n−2 −(cid:18) n − 1 (n − 1)/2(cid:19)/2) ≈ n2n−2(1 − ⌊n/2⌋Xi=0 where the approximation omits lower order terms. Similarly we have i2(cid:0)n i(cid:1) = ni(cid:0)n−1 i−1(cid:1). Hence: n(i − 1)(cid:0)n−1 16 n22n n2n+1 1 + 1 1 n! i(cid:19) 2 i(cid:18)n √2 √πn ). i−1(cid:1) = n(cid:0)n−1 i−1(cid:1) + 33 ⌊n/2⌋Xi=0 ⌊n/2⌋−1Xi=0 i2(cid:18)n i(cid:19) = n ⌊n/2⌋−1Xi=0 (cid:18)n − 1 i (cid:19) + n i(cid:18)n − 1 i (cid:19) = n(cid:18)2n−1 −(cid:18) n − 1 (n − 1)/2(cid:19)/2(cid:19) + n(n − 1) ⌊n/2⌋−2Xi=0 (cid:18)n − 2 i (cid:19) = n(cid:18)2n−1 −(cid:18) n − 1 (n − 1)/2(cid:19)/2(cid:19) + n(n − 1)(cid:18)2n−3 −(cid:18) n − 2 ⌊n − 2⌋(cid:19)(cid:19) √πn ! √πn ! + n(n − 1) 2n−3 − ≈ n 2n−1 − √22n−2 √22n−2 √2n3/22n−2 = n22n−3 − + 3n2n−3 + o(2nn), √π where the approximation again omits lower order terms. Thus we have: 2 −dhsα(∅)2 = Θ(cid:18) α2 n(cid:19) kdhsαk2 To complete the proof, we will show that dhsα([n])2 = 0. It is well-known (see e.g. [FV15]) that for all S ⊆ [n] such that S ≥ 2 and i ∈ S, it holds that dhsα(S) = α [M aj(S\{i}) majority is an odd function, its Fourier coefficients on sets of even size are 0. . Using the fact that ✷ n E Sketches Under Uniform Distribution Recall that a function f : {0, 1}n → {0, 1} is ǫ-approximated by a function g : {0, 1}n → {0, 1} if Prx∈{0,1}n[f (x) 6= g(x)] ≤ ǫ. -junta. Theorem E.1. [LZ18] Every DNF with width w can be ǫ-approximated by a(cid:0) 1 ǫ(cid:1)O(w) m , w(cid:1) for some 1−ǫ (f ) ≤ u(cid:0) 1 Theorem E.2. Let f be a (θ, m)-LTF of width w DNFs then Dlin,U function u. 2 -approximation of f , denoted fh, that is a threshold function of q = O(cid:16)(cid:0) θ ǫ(cid:17) m(cid:1)3 ǫ(cid:1)O(w) f on at most ǫ fraction of the inputs. The resulting sketch complexity is(cid:0)log 1 O(cid:16)(cid:0) θ m(cid:1)3 Proof. Observe that by Lemma 3.15 and standard probability amplification techniques, there exists an ǫ m log 2 width w disjunctions. Thus, it suffices to take a ǫ 2q -approximation for each of the q width w disjunctions, using Theorem E.1. By a simple union bound, the resulting linear sketch differs from for each of the m(cid:17) disjunctions. Corollary E.3. If f can be represented as a (monotone) linear threshold function of (θi, mi)-linear threshold functions, then Dlin,U m = maxi log2 θ log2 θ ǫ , θ ǫ , θ θi mi . 1−ǫ (f ) ≤ u(cid:0) 1 m(cid:1), where θ 34 Note that any matroid of rank r can be expressed as a linear threshold function of DNFs, where each clause contains the r independent basis elements. Therefore, matroid rank functions can be sketched succinctly under the uniform distribution: Theorem E.4. Given 0 < ǫ < 1 to be the probability of failure, matroids of rank r have a random- ized linear sketch of size g(cid:0)r, 1 ǫ(cid:1) under the uniform distribution, where g is some function. In fact, the function f (·) can be improved using the following observation about using juntas to approximate monotone submodular functions. Theorem E.5 ([BOSY13], Theorem 6). Let f : {0, 1}n → {a1, . . . , ar} be a monotone submodular function. For any ǫ ∈(cid:0)0, 1 Corollary E.6. Matroids of rank r under the uniform distribution have a sketch of size O(cid:16)(cid:0)r log r + log 1 2(cid:1), f is ǫ-close to a (z + 1)r+1-junta, where z = O(cid:0)r log r + log 1 ǫ(cid:1). where ǫ is the probability of failure. ǫ(cid:1)r+1(cid:17), Finally, we note the concentration of matroid rank functions on uniform distributions (see also [Von10]): Theorem E.7 ([Von10],[GHRU13] Lemma 2.1). Let f : 2U → R be a 1-Lipschitz submodular function. Then for any product distribution D over 2U , [f (x) − E[f (S)] ≥ t] ≤ 2 exp(cid:18)− 2 (E[f (S)] + 5t/6)(cid:19) . Pr S∼D t2 Corollary E.8. For matroids of rank Ω(n) and ǫ > 1√n , the expectation of the matroid rank function rankM suffices for a ǫ-approximation to the matroid rank. Proof. Recall that the matroid rank function rankM is always a submodular 1-Lipschitz function. Thus, matroids of rank Ω(n) are highly concentrated around their expectation and so to get an ǫ-approximation to the matroid rank, it suffices to simply output the expectation of f , provided ǫ > 1√n . 35
1902.05638
1
1902
2019-02-14T22:51:48
Finding Nearest Neighbors in graphs locally
[ "cs.DS", "cs.SI" ]
Many distributed learning techniques have been motivated by the increasing size of datasets and their inability to fit into main memory on a single machine. We propose an algorithm that finds the nearest neighbor in a graph locally without the need of visiting the whole graph. Our algorithm is distributed which further encourage scalability. We prove the convergence of the algorithm
cs.DS
cs
Finding Nearest Neighbors in graphs locally Abhinav Mishra College of Computing Georgia Institute of Technology [email protected] 9 1 0 2 b e F 4 1 ] S D . s c [ 1 v 8 3 6 5 0 . 2 0 9 1 : v i X r a Abstract Many distributed learning techniques have been motivated by the increasing size of datasets and their inability to fit into main memory on a single machine. We propose an algorithm that finds the nearest neighbor in a graph locally without the need of visiting the whole graph. Our algorithm is distributed which further encourage scalability. We prove the convergence of the algorithm. 1 Introduction Graph based learning methods have applications in spectral algorithms [3], dimensionality reduc- tion[9], image-segmentation[2], semi-supervised learning [8], manifold learning [10], link predic- tion [4], databases[5] etc. Some of the desirable properties of any graph based algorithms include scalability where we can run the algorithm on networks such as Facebook involving billions of nodes, ability to handle dynamic environment (addition/removal of nodes or edges), online com- putation (avoiding pre-computation such as matrix inversion), ability to run in a distributed setting where a node communicates with its neighbors. Finding nearest neighbors in a graph is one of the fundamental problem and is applied to many applications mentioned above. Nearest neighbors are the nodes that are close to a given node based on a certain proximity measure. We expect a proximity measure to be able to capture the structure of the graph, i.e., if two nodes have multiple paths between them and fewer hops between them, then the nodes are said to be in a close proximity. We discuss the properties of proximity measures in detail in section 2. Traditionally, random walk based methods are used in identifying the nearest neighbors because its ability to look beyond one hop and capture the network structure. Random walk methods can be further divided into two types: probability of hitting a node also usually known as Personalized-pagerank (PPR) and expected number of steps to reach a node (hitting time or commute time) [6]. While it is exciting that a method such as random walk captures the relationship between two nodes in a good way, i.e., it favors the multiple short-paths between two nodes. However, random suffers from a critical problem. For finding nearest-neighbors, we require algorithm to capture the local structure instead of the whole graph. For example, consider two dense components connected by few edges. We expect a node and its neighbors to lie in the same component. Therefore, adding more edges or making other changes in another component should not have any significant effect on a good proximity measure. However, a personalized pagerank will be reduced by roughly one- fourth if we induce extra E/3 on a node from another component or add similar edges. To be more precise, in an undirected graph, the steady state distribution of a node is proportional to its degree in the graph. Such graphs are common, e.g., consider dense giant components connected with few edges. Any random walk based proximity measure is likely to be effected by the presence of high degree nodes. Similar results were drawn for hitting and commute times[1]. A good local proximity measure relies on the fact that a node should not be effected by any node that is far away. There is a line of work that focus on making random walk local of work such as truncated time. 1 Figure 1: Left subgraph of the starting node has a fewer edges and therefore has more active nodes as the charge is equally divided between edges. Right subgraph is dense and has fewer active nodes. Second issue with random walk based approaches is the computational load. Computing commute time typically involves finding a pseudo-inverse on laplacian which is O(n3)). Spielman made it finding in nearly linear time. However, if the graphs are changing, then even such approach is computationally expensive. At the same time, finding an algorithm in a distributed setting is of interest because it does not require any pre-computation and is naturally scalable. These issue gives rise to few fundamental questions. 1) can we derive a measure that is truly local, i.e., complexity is independent of number of nodes in the graph, measure to obey the properties such as favoring short-multiple paths between the nodes and captures the local-structure of the graph. The networks such as facebook are dynamic, where node or edges can be added or deleted. This give rise to a second important question Property 2: can we avoid any kind of pre-computation on the graph such as matrix inversion, or. Therefore, if there are any changes. on the fly computation. Recently there is a large amount of research on scalability and storage due to the increasing size of datasets and inability to fit into main memory on a single machine. So, this leads to the final question of devising an algorithm that is truly distributed in nature. We assume the simplest setting where a node in graph is allowed to interact with its neighbors. We propose an iterative algorithm that runs on a graph under distributed setting where a node contact its neighbors. Initially, the querying node has a finite charge and it starts spreading the charge to its neighbors and neighbors repeat the process and so on. Each node retain a certain amount of charge and therefore, we can expect fewer nodes to have charge and charge cannot reach the nodes that are far away. Our algorithm is a non-linear process but has s resemblance with Markov Chains, It terminates after few steps, instead of converging asymptotically. We prove the termination and present an upper-bound on the number of steps. Our algorithm runs on small part of the graph which is controlled by the user. Hence, the complexity of the algorithm is independent of the number of nodes. This makes the algorithm desirable for large graphs, where we can avoid the requirement to visit all the nodes. Algorithms such as Personalized Pagerank, commute time based measures. other global are global and do require the whole graph. It may need the whole Adjacency representation at once for the purpose of inversion, or may require all the nodes by . However, our algorithm explores a smaller part of the graph to find the k-Nearest Neighbors. 2 Pursuit for Proximity measure The nodes within a close proximity are expected to be a good candidate for Nearest Neighbors. There are number of factors that effect proximity. Simplest measure is the number of hops between two nodes. If the shortest path between two nodes is large, then it is expected that they are not close neighbors. However, this shortest path does not factor the multiplicity of paths. For example, if there are multiple paths between two nodes, it indicates that the two nodes might be well connected. As shown in Figure 1, node S (Source) is connected to node T (sink) through multiple paths compared to node 2 which has only one path from node S. Notice that both paths from S to T and S to node 2 are of length 2 each. However, since node T has more paths from S, it will have closer proximity compared to Node 2. So far the the two proximity measures (namely shortest path and number of paths) we have seen are symmetric, i.e., we obtain the same score from both source and destination. 2 ST3111211 Now we introduce the third measure that brings asymmetricity. It is not difficult to see that Nearest Neighbors (NN) in general is not a symmetric measure. It is not necessary for a node say A to be a NN of node B, given that node B is in a NN of A. A node with a high degree is less likely to have one of its neighbors as NN compared to a node with a low degree. However, a good measure of proximity should handle all three cases together. In isolation, For example in fig, We can draw parallel of our methods with Markov Chains in all three scenarios mentioned above. Commute time or hitting time essentially captures all the three characteristics. These two measures are also related to the electrical resistances between two nodes in a graph, where we treat edge weights as resistances. However, there are few problems with this measure. First is the computation. One generally require the whole graph for computing the commute time or hitting time. Therefore, the computational complexity depends on the number of nodes or edges. Secondly, even if the graph is stored with a succent representation for calculating the such measure. It suffers from the dynamic nature , where a nodes or edges are added or deleted and therefore, creates an extra overhead of creating a sub-structure. In Markov Chains, it can be seen as If node is removed then the resulting matrix will be sub-stochastic. We later show that by setting appropriate parameters, our algorithms becomes a Markov Chain. As discussed earlier, the technique we propose here is a non-linear iterative method, and by reducing the non-linearity, we reduce it to a Markov Chain. However, such transition from non-linearity to linearity has a lot of implications. Firstly, due to non-linearity, we only explore a small part of graph and secondly, the algorithm terminates after finite number of steps, while the markov chains converge asymptotically. i∈V x0 1, . . . , x0 n) is a non-negative function over the set of nodes: x0 node at any iteration. We also put a constraint that(cid:80) 3 Algorithm Consider G(V, E) as a connected undirected graph, V = n, di is the degree of node i and dmax = i ≥ 0. max{di : i ∈ V }, and (cid:126)x0 = (x0 k as the charge of node i at iteration k. We assume that the charge is non-negative for any We call xi i = 1. We further assume that there is only one node in the beginning with a unit charge. Our goal is to find k-nearest neighbor with respect to this node. We assume that the whole network of nodes is distributed, i.e., there is not any central node and computation at each node are independent and synchronous. For a node to communicate with a node 3-hops away, it has to do it through the neighbors. -advantages- We technique is an iterative method, where at each iteration nodes distribute the charge among themselves. The sum of the charge remains the same in each iteration. Also, there is a charge conservation at each node. We start with a single node with a unit charge, then the node spreads the charge to its neighbors and the neighbors so the same in the next iteration and so on. Therefore, with more iterations, the a subgraph induced by the charged nodes start spreading. Nodes that receive charge retain a certain amount all the time. Therefore the amount of charge that can be spread decreases with the increase in charged nodes. The amount of charge every charged node retains is between [(1 − α) · , ). Therefore, there are limited number of nodes that can spread the charge due to the conservation of charge at each iteration. By choosing the suitable  and α, we can control the size of subgraph formed by the charged nodes. We set formed by the charged nodes, we call as k-NN set. We now formally give the details of the algorithm. For a node i at iteration t, we define a variable zt i such that (cid:26) 1 0 zt i = if xt if xt i >  i ≤  A node i with zt i = 1 is known as an active node in iteration t and are the only nodes that are allowed to transfer the charge. Other nodes can only receive the charge from active nodes. Therefore, nodes with a charge more than  can transfer the charge. For a node i at iteration t, the amount of charge it carry in iteration t is represented by xt . Let dj be the degree of node j. The charge xt+1 i, and in t + 1 iteration by xt+1 is computed as follows: i i 3 = (cid:0)(1 − α)xt xt+1 i izt i + xt i(1 − zt i )(cid:1) + α (cid:88) j:{i,j}∈E xt jzt j dj (1) Second part of the equation α(cid:80) The first part of the equation ((1 − α)xt izt retains. If zt by the conservation of charge at the node , it cannot send charge to its neighbors. If zt node retains (1 − α) fraction of the charge as given by (1 − α)xt izt to its neighbors. i )) indicates the amount of charge node xt+1 i = 0, then the node retains all the charge it had in the previous iteration, and therefore i = 1, then the i, and it sends rest of the charge i(1 − zt i + xt i xt j zt dj j j:{i,j}∈E indicates the amount a node receives from its neigh- bors. Since only the node, with zt∗ = 1 are allowed to transfer the charge, therefore we have an indicator variable zt∗ indicating if the node is eligible to send the charge. Since the nodes with zt∗ = 1 retain the (1 − α) fraction of the charge, they distribute the other α fraction to its neighbors. In our process, they distribute it equally to their dj neighbors. Here dj indicates the degree of node j. It is not difficult to verify the charge conservation with the above formulation. The above formulation is a non-linear system of equation that terminates after finite steps using fixed-point iterations (proved in ). A necessary condition for termination is This non-linearity makes it difficult to analyze. We present a upper-bound on the number of steps required for termination. We discuss the running time in Section ??. We prove the termination of our algorithm in Section 5 and also give an upper-bound on the number of iterations required for a guaranteed termination. The algorithm exhibits a locality property that the charge is disseminated to the nodes that are closer in proximity. We discuss this locality in detail with applications in Section ??. 4 Discussion 1 The main intuition behind finding the NN is that if a node has a charge and it distribute it, then it will reach its NN first because of the multiple short paths between them. Next challenge is to formulate an algorithm that is scalable, terminates/converges, scalable and distributed. It is easy to see that the maximum number of k-NN nodes is (1−α)·, otherwise the net charge will be more than 1. We give various properties and their proof in Appendix. i ≤ ,∀i, since if there is not a single The necessary condition for termination in iteration t is xt active node, then there is no exchange of charge, so the process terminates. Once a nodes become active, the minimum charge it will retain is (1 − α) · . Here, α is a user controllable parameter and plays an important role in termination and setting an upper-bound on the number of steps required for termination. Let the set of nodes that were once active be called as NN set. More formally, NN= {i ∈ V : {xt i ≥ ,∀t ≥ 0}}. 4.1 Properties of NN subgraph 1 (1−α)·, otherwise the net charge will be more than 1 which The maximum number of k-NN nodes is is not possible. Moreover, the subgraph induced by the k-NN nodes is well-connected. It follows from the fact that a node can only receive charge from an active node and once a node becomes active, it belongs to k-NN set. The subgraph induced by the k-NN nodes is well-connected. It follows from the fact that a node can only receive charge from an active node and once a node becomes active, it belongs to k-NN set. 5 Complexity and termination Proof of termination. We start with an important observation that there is always a charge that either moves out of core or moves towards the periphery (while staying in the core). We quantify the charge later in the section. For now, say β is the minimum charge that continues to move out of core say in at most t iterations, then we conclude that after t/β iterations, the algorithm will terminate. Likewise if β is the minimum charge that moves a step closer to the periphery every t iterations, 4 then it will take t/β iteration to move a unit charge a step closer to the periphery. If the diameter of core is d, then it will take d · t/β iterations for the charge to move out of core. The maximum amount of charge a periphery can hold is 1 − (1 − α) ·  (for a star graph). Therefore, it will take (1 − (1 − α) · )d · t/β iterations at most. In case of star graph, it is a single iteration. But the above approach is more systematic and is applicable to any graph. Note that the bound given above is really loose, as the nodes in core will retain at least (1 − α) charge. But it does prove that as long as there is a fixed amount of charge coming out of core every few iterations, the process will terminate. Secondly, it is a progress if a charge moves towards the periphery while still residing inside the core, as it will eventually move out of core. We now quantify the values such β mentioned above. There could be at most 1/(1−α)) core nodes i xi > 1, which is not possible. The minimum charge a node can give out is at least α· . Therefore, it will take (property vi). Therefore, the diameter of the core is at most 1/(1 − α), otherwise the(cid:80) α·(1−α)·2 steps to pass at most the unit amount of charge. dmax dmax its neighbors. Therefore, the exact number of communication exchange is(cid:80) This bound is still loose. We further improve it by introducing the concept of excess charge. Excess charge is defined as the maximum amount of charge a core can give out to periphery. For example, if there are M nodes in core, than 1− (1− α)· · M ≤ 1− (1− α)·  is the amount of excess charge, as each core node will retain at least (1 − α) ·  charge. Plugging the excess charge into the earlier bound, we obtain an improved bound of (1 − (1 − α) · ) · dmax α·(1−α)2 . α· Complexity and Upper bound on the number of steps In any iteration, a node communicates with i∈V di = 2E. If the algorithm terminates in k steps , the complexity becomes O(kE). However, it is usually the case that algorithm runs on a small part of graph. The minimum charge a peripheral node can have is α· α· number of nodes with a non dmax zero charge. Hence the complexity now becomes O(k · d2 other than the nodes with zero charge. So there are at most dmax · M ≤ (1 − (1 − α) · ) · dmax max α· ). 6 Weighted Graphs and Markov Chains It is straightforward to extend the formulation to the directed-weighted graphs if the graph is strongly connected. For weighted-undirected graph, assume that there exist a directed edge in both direction. Since the algorithm works on a small part of graph, assume that (1 − α) << n. Assumption of strong connectivity is necessary, although not in every case. Suppose that we start with a node that does not have any outgoing edges, then the node cannot transfer the charge. We do not require the condition of aperiodicity, as . This is another difference with markov chains. Let wjk denote the edge weight of an edge going from node j to node k. = (cid:0)(1 − α)xt xt+1 i izt i + xt i )(cid:1) + α i(1 − zt (cid:88) j:{j→i}∈E j(cid:80) jzt xt k wjk (2) process if we set  to zero and enforce that(cid:80) In this section, we show that our method is similar to markov chain and in fact, it becomes a markov i = 1, so that it becomes a probability distribu- tion. To see this, z∗ ∗ becomes 1 for all nodes, and the equation becomes i∈V x0 xt+1 i = 1 2 xt i + 1 2 xt j dj (3) (cid:88) j:{i,j}∈E The above equation represents lazy random walk, where a node retains half of the charge each time and distributes the other half. In random walk terms, random walk stay at the same node with probability 0.5 and moves to one of its neighbor with probability 1/2d. Lazy random walk are typically used to fix up the periodicity problem. For example, in a bipartite graph, a walk will be either on the one side or another, and thus fail to converge. Self loop also helps in convergence rates as it bounds the eigenvalue of the transition matrix. We can observe the similar phenomenon with 5 our formulation, the self absorbing parameter α and  give an upper-bound on the number of steps required for termination. qualitative treatment with random walk 7 Terminating iterative method It remains an open question to show the convergence rate of the earlier technique. We now present an slightly modified version of the earlier algorithm. Most the properties remain the same. In this technique, a node looses (1 − α) fraction of access charge at each iteration. In other words, it has charge α(xi − ) to distribute to its neighbors. If the charge is less than  then the node retains most of its charge. So the modified method becomes i(1 − zt j(1 − zt xt j) (cid:88) i + xt izt (4) xt+1 i = (cid:0)xt = (cid:0)xt i )(cid:1) + α i )(cid:1) + α j:{j→i}∈E dj (cid:88) j(1 − zt xt j) To see the convergence rate, we can write the formulation as xt+1 i izt i + xt i(1 − zt Let (a1, ...at) be the excess charge in the graph. We define excess charge as at =(cid:80) i−)(1−zt i ). Notice that 1 ≥ ai ≥ aj,∀i ≤ j. In every iteration, excess charge is reduced by fraction α. Therefore after t iterations, excess charge at is at most αt after t iteration. Since excess charge is what is transferred between core nodes and peripheral nodes, for convergence we need it be at < δ. Therefore, we need logδ/ log α iterations. j:{j→i}∈E i(xt dj (cid:88) Now we look at the vector (cid:126)xt+1 =(cid:80) xt i +  2 xt+1 i = 1 2d + j − ) = (xt 1 2d j:{i,j}∈E,j∈C j:{i,j}∈E,j∈C (xt j + xt i) (6) j∈C(xt+1 j )2, and obtain an upper-bound. (cid:88) 2 (5) (7) (8) (cid:88) (cid:88) j∈C (cid:126)xt+1 = ≤(cid:88) i 1 d  1 2d (cid:88) i (cid:88) (cid:88) (xt+1 )2 = j (xt j + xt i) j:{i,j}∈E,j∈C (xt j + xt i) 2 = 1 d j:{i,j}∈E,j∈C 4 i,j∈E,i,j∈C 4 (xt j + xt i) 2 Since all the core nodes have at least  charge, at − at+1, the amount peripheral nodes receive in iteration t + 1. 8 Related work Different measure for proximity have been studied in detail in [4]. It was observed that classical measure such as katz outperform more appealing methods such as commute time especially in the presence of a high-degree node[7]. Sarkar also observed the global nature of the walk and proposed methods based on the fixed length walk and called it truncated hitting time. Here the paths of length less than T are considered. The total running time was O(nE), here n is the number of nodes, E is the number of nodes. One first problem is the time complexity and other one is the algorithm does not work on a dynamic graph. To overcome this, authors later refined their hitting time computation mechanism by sampling. Note that the computation is now approximately correct with a hight probability instead of deterministic in the earlier work. This way they reduced the complexity to to O(cid:112)(n) for a pair which is very reasonable. Knowing T apriori is a challenge. However, one can argue that since T is a constant, one can perform a linear search on the multiple values of T . But there is a major problem with such approach, graph 6 such as Facebook where average distance is 4.2 or classical milligram experiment[4] . Choosing T = 3 and T = 4 will capture entirely different graph. This seem to indicate that perhaps a fixed length walk is not the most suitable method. APPENDIX 1 i0 A. Properties of the Algorithm For a subset of nodes H ⊂ V , we use Γ1(H) to denote the 1-vertex neighborhood of H: Γ1(H) = {j ∈ V \ H : {i(cid:48) ∈ H : {i(cid:48), j} ∈ E} (cid:54)= ∅}. Let i0 ∈ V be a node such that x0 = 1 (consequently i = 0, ∀i(cid:54)= i0) and let n ≥ x0 (i)  · (1 − α) < x∗ i ≤ 1, ∀i ∈ H. If a node has a charge more than , it will retain at least  · (1 − α) of the charge (by Eq. 1). All the other nodes with charge more than  · (1 − α), but less than 1, will continue to hold all of the charge and will not distribute it to their neighbors. (1−α)·. Then following properties are true: i, ∀i ∈ V and ∀t ≥ t0. See Section 5 (ii) The subgraph of G induced by H is connected. A node can only receive a charge from a core node. Therefore there has to be a path of core nodes between a node receiving a charge and i0 (starting node). Also, a node that becomes a core node continues to be a core node, proving the connectivity. (iii) xt+1 (iv) 0 ≤ xt i <  · (1 − α), ∀i ∈ Γ1(H). Here, Γ1(H)indicates the set of nodes that are neighbor of core including the core nodes itself. H ∪ Γ1(H) shows the peripheral nodes. Such peripheral nodes can receive the charge from core since they are the neighbors of core, but their charge has to be less than  · (1 − α), otherwise they become core. i = 0, ∀i ∈ V \ (H ∪ Γ1(H)) and ∀t ≥ 0. All the nodes that neighbors of peripheral (v) xt nodes, but not a part of core will have zero charge, as the peripheral node can have at most · (1− α) charge and are not allowed to distribute it to their neighbors. (vi) H ≤ 1/ · (1 − α). The minimum charge a core node can have is  · (1 − α) and charge of a starting node 1, there by the conservation of charge, there could be at most 1/( · (1 − α)) core nodes. (vii) V ≤ 1/, then algorithm does not terminate. If the size of the graph is less than 1/, then there is at least one node with charge more than  and will continue to give charge to its neighbors, therefore the process cannot terminate. i = xt References [1] U. von Luxburg, A. Radl, and M. Hein. Hitting and commute times in large random neighborhood graphs. Journal of Machine Learning Research, 15:1751 1798, 2014. [2] J. Shi and J. Malik. Normalized cuts and image segmentation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 22(8):888905, 2000. [3] F. Chung. Spectral Graph Theory. American Mathematical Society, 1997. [4] D. Liben-Nowell and J. Kleinberg. The link prediction problem for social networks. In CIKM, 2003. [5] Balmin, A., Hristidis, V., and Papakonstantinou, Y. (2004). ObjectRank: Authority-based keyword search in databases. VLDB, 2004. [6] Aldous, D., and Fill, J. A. (2001). Reversible markov chains. [7] Sarkar, P., and Moore, A. (2007). A tractable approach to finding closest truncated-commute-time neighbors in large graphs. Proc. UAI. [8] Zhu, X., Ghahramani, Z. and Lafferty, J. (2003) Semi-Supervised Learning Using Gaussian Fields and Harmonic Functions. ICML 20: 912919. [9]J. B. Tenenbaum, V. de Silva, and J. C. Langford. A global geometric framework for nonlinear dimension- ality reduction. Science, 290:23192323, 2000. [10]M. Belkin and P. Niyogi. Laplacian eigenmaps for dimensionality reduction and data representation. Neural Computation, 15(6):13731396, 2003. 7
1112.6256
2
1112
2012-01-31T13:17:01
(1+epsilon)-Distance Oracle for Planar Labeled Graph
[ "cs.DS" ]
Given a vertex-labeled graph, each vertex $v$ is attached with a label from a set of labels. The vertex-label query desires the length of the shortest path from the given vertex to the set of vertices with the given label. We show how to construct an oracle if the given graph is planar, such that $O(\frac{1}{\epsilon}n\log n)$ storing space is needed, and any vertex-label query could be answered in $O(\frac{1}{\epsilon}\log n\log \rho)$ time with stretch $1+\epsilon$. $\rho$ is the radius of the given graph, which is half of the diameter. For the case that $\rho = O(\log n)$, we construct an oracle that achieves $O(\log n)$ query time, without changing the order of storing space.
cs.DS
cs
(1 + ǫ)-Distance Oracle on Planar, Labeled Graph Mingfei Li, Christoffer Ma, and Li Ning Department of Computer Science, The University of Hong Kong No Institute Given Abstract. Given a vertex-labeled graph, each vertex v is attached with a label from a set of labels. The vertex-label query desires the length of the shortest path from the given vertex to the set of vertices with the given label. We show how to construct an oracle if the given graph is planar, such that O( 1 ǫ n log n) storing space is needed, and any vertex- label query could be answered in O( 1 ǫ log n log ρ) time with stretch 1 + ǫ. ρ is the radius of the given graph, which is half of the diameter. For the case that ρ = O(log n), we construct an oracle that achieves O(log n) query time, without changing the order of storing space. 1 Introduction We consider those undirected graphs, in which each vertex is attached with a label from a set of labels, denoted by L. Fixed such a graph G = (V, E) and the label set L, the distance between two nodes v, u ∈ V , denoted by δ(v, u) is the length of the shortest path connecting v and u in G, and the distance between a vertex u ∈ V and a label λ ∈ L, denoted by δ(u, λ), is the distance between u and node v that is closest to u among all nodes with label λ, i.e. δ(u, λ) = min{δ(u, v)v is attached with label λ}. In the applications involving graphs, the query of vertex-label distance is often asked and used as a basic sub- procedure to achieve more complicated task. For example, a navigation software need to answer how far is the closest store for a specified service from the current position. Since these kind of questions raise very frequently, the answer should be returned with as less time as possible. Trivially, people could precalculate and store the answer for all possible queries. However, this may take too much space, which is of order O(V × L). The aim of distance oracle is to precalculate and store information using less than O(V × L) space, such that any distance query could be answered more efficiently than process the calculation based only on the graph structure. The approximate distance oracle answers the query with some stretch. In details, a distance oracle with stretch 1 + ǫ returns d(u, λ) as the approximation to δ(u, λ), such that δ(u, λ) ≤ d(u, λ) ≤ (1 + ǫ)δ(u, λ). wide applications to derive the particular distance oracle for planar graphs. Since in many practical cases, the given graph is drawn on a plane, it has 1.1 Related Work 2 1 0 2 n a J 1 3 ] S D . s c [ 2 v 6 5 2 6 . 2 1 1 1 : v i X r a 1 1 k − 2k Vertex-Label Distance Oracle. The problem of construct approximate distance oracles for vertex-labeled graphs was formalized and studied by Hermelin et al. in [4]. Let n denote the number of nodes and m denote the number of edges. They adapted the approximate scheme introduced by Thorup and Zwick in [10] to show the construction of vertex-label distance oracles with expected size O(kn1+ 1 k ), stretch 4k − 5 and query time O(k). The preprocessing time is k ). Let l = L. They also constructed vertex-label distance oracles with O(kmn k ), stretch 2k − 1 and query time O(k). The preprocessing expected size O(knl time is O(kmn 1 ). For a vertex in the graph, the associated label may change. A simple way to support label changes is to construct a new distance oracle. In [4], they constructed vertex-label distance oracles with expected size O(kn1+ 1 k ), stretch 2 · 3k−1 + 1 and query time O(k), which can support label changes in k log n) time. In [1], Chechik showed that Thorup and Zwick's scheme could O(kn k n log log n) time, with also be modified to support label changes in O(n the expected size O(n1+ 1 k ), stretch 4k− 5 and query time O(k). The preprocess- ing time is O(kmn The vertex-label distance oracle has also been studied for some specified class of graphs. Tao et al. have shown how to construct vertex-label distance oracles for XML trees, in [8]. For the case that each node is assigned with exactly one label, their construction results in exact vetex-label distance oracles with size O(n), and query time O(log n). The preprocessing time is O(n log n). k log1− k ). 1 1 1 1 1 Vertex-Vertex Distance Oracle. In [10], Thorup and Zwick have introduced a well-known scheme to construct vertex-vertex distance oracle with expected size O(kn1+ 1 k ), stretch 2k − 1, and query time O(k). The preprocessing time is k ). Wulff-Nilsen in [11] has improved the preprocessing time to O(√km+ O(kmn kn1+ c k ) except for very sparse graphs and small k. For planar graphs, Klein in [5] has shown how to construct vertex-vertex distance oracles with size O( 1 ǫ n log n), stretch 1 + ǫ and query time O(1). √k ) for some universal constant c, which is better than O(kmn 1 Shortest Path. The construction of distance oracles often harness the shortest path algorithms in preprocessing stage. Although it is better to know as well as possible the methods that aim at calculating the shortest path, we only selected the most related ones and list them here. For the others, we will introduce them while they are used in our algorithm. A shortest path tree with vertex v is a tree rooted at v and consisting of all nodes and a subset of edges from the given graph, such that for any u in the given graph, the path from v to u in the tree is the shortest path from v to u in the original graph. Given a single vertex, to calculate the shortest path tree rooted at it is called single source shortest path problem. In undirected graphs, the single source shortest path tree could be calculated in time of order O(m) where m is the number of the edges in the given graph. The algorithm is introduced by Throup in [9]. In directed graphs, the single source shortest path tree could be calculated in time of order O(m + n log n) where n is the number of the nodes in the given graph. This is done by the well known Dijkstra algorithm using Fibonacci heap [2]. 1.2 Simple Solution in Doubling Metrics Spaces. If the metric implied by the given graph is doubling, the following procedure provides a simple solution to return δ(u, λ) with (1 + ǫ)-stretch. Preprocessing. Let ǫ′ = ǫ 3 . For ǫ < 1, (1 + ǫ′)2 < 1 + ǫ. For each label λ ∈ L, construct the oracle to support (1 + ǫ′)-nearest neighbor search. In additional, construct the oracle to support (1 + ǫ′) vertex-vertex distance query. Query. Given u ∈ V and λ ∈ L, find the (1 + ǫ′)-NN of u among the nodes with label λ, and then query for their (1 + ǫ′) distance. Space and Query Time. The oracle supporting approximate nearest neighbor search for λ could be constructed using O(nλ) space , where ni is the number of nodes with label λ. Since any node is allowed to attached with only one label, then the space used in all is O(n). This kind of oracle could answer the query in O(log nλ) = O(log n) time . The oracle supporting approximate vertex-vertex query distance could be constructed using O(n) space and answer the query in O(1) time . 1.3 Our Contribution As shown in the subsection of related work, we are not aware of any vertex-label distance oracle on planar graphs. In this paper, we mainly show the following two results. Theorem 1. Given an undirected planar graph G = (V, E) and a label set L, each vertex v ∈ V is attached with one label in L. For any 0 < ǫ < 1, there exists an oracle that could answer any vertex-label query with stretch 1 + ǫ, in O( 1 ǫ log n log ρ) time. The oracle needs O( 1 ǫ n log n) space. Theorem 2. Given an undirected planar graph G = (V, E) and a label set L, each vertex v ∈ V is attached with one label in L. If the radius of G is of order O(log n), then for any 0 < ǫ < 1, there exists an oracle that could answer any vertex-label query with stretch 1 + ǫ, in O( 1 ǫ log n) time. The oracle needs O( 1 ǫ n log n) space. 2 Preliminary Lipton Tarjan Separator. [6] Let T be a spanning tree of a planar embedded triangulated graph G with weights on nodes. Then there is an edge e 6∈ T , s.t. the strict interior and strict exterior of the simple cycle in T ∪{e} each contains weight no more than 2 3 of the total weight. Recursive Graph Decomposition [5]. The recursive graph decomposition (RGD) of a given graph G is a rooted tree, such that each vertex p in G maintains -- a set N (p) of nodes in G, in particular the root of RGD maintains (as a label) N (p) = V (G), and -- p is a leaf of RGD iff. N (p) contains only one node of G, in this case let S(p) = N (p); -- if p is not a leaf of RGD, it maintains (as a label) an α-balanced separator S(p) of G, balanced with respect to the weight assignment in which each node in N (p) is assigned weight 1 and other nodes are assigned weight 0. A non-leaf vertex v of the tree has two children p1 and p2, such that -- N (p1) = v ∈ N (p) ∩ ext( S(p)), and -- N (p2) = v ∈ N (p) ∩ int( S(p)), where S denotes the cycle corresponding to a separator S. For a leaf node p of RGD, N (p) contains only one node of G. In practice, N (p) may contain a small number of nodes, such that the distances in the subgraph induced by N (p) for every pair of nodes in N (p) are pre-calculated and stored in a table support O(1) time look-up. Range Minimum Query. The range minimum query problem is to preprocess an array of length n in O(n) time such that all subsequent queries asking for the position of a minimal element between two specified indices can be answered quickly. This can be done in constant time using no more than 2n + o(n) bits [3]. 2.1 Notation Projection. Given a set of nodes S, and a node v, we define the projection of v on S as the node in S that is closest to v. Radius A graph has radius ρ iff. it has a shortest path tree with at most r levels. 3 (1 + ǫ)-Stretch, O( 1 ǫ log n log ρ) Query Time Oracle 3.1 Preprocessing Find the node node r ∈ G whose shortest path tree has ρ levels, compute the shortest-path tree T in G rooted at r and based on T . Calculate the RGD. Then store, 1. a table records, for each node v ∈ G, the leaf node p ∈RGD, s.t. v ∈ N (p); 2. a table records, for each node p ∈RGD, the depth of p in RGD; 3. a representation of RGD support quick (O(1) time) computation of lowest common ancestor (lca); 4. a table Tv for each node v ∈ G records, for each p ∈RGD such that v ∈ N (p), two sub-tables for the paths P ′, P ′′ in the separator S(p), respectively. In details, Tv[p][P ′] (similar for Tv[p][P ′′]) consists of a sequence of O( 1 ǫ ) pairs (d−q, h−q), . . . , (d0, h0), . . . , (dw, hw), where di is the distance from v to a node zi on P ′ and hi is the distance from zi to r (root of the shortest path tree T ), such that the sequence has the distance property: for any node w on P ′. there is a node zi such that the distance from v to zi plus the distance from zi to w is at most (1 + ǫ) times the distance from v to w. Refer to the nodes zi as portals, and to the corresponding di as portal distances. In [5], it is proved that O( 1 ǫ ) portals is enough to promise the distance property. To be self-contained, we include in the appendix a simple version of the proof (See Appendix A). Parts 1 to 3 need O(n) space. Part 4 needs O( n store the portals for each label λ. In details, we store ǫ log n) space. In addition, we 5. a table Tλ for each label λ ∈ L, in which there is an entry for each piece p ∈RGD, s.t. N (p) ∩ V (λ) 6= ∅. In each entry, it stores two sequence for the paths P ′ and P ′′ forming S(p), respectively. In details, the sequence for P ′ stores all the portals on P ′ for nodes in N (v)∩ V (λ), in the increasing order according to their distances from the root r. 6. a hash table for each label λ indicates whether there is an entry for a given separator in Tλ and return the index in Tλ if yes (both operation could be done in constant time). Part 5 needs O(n log n) space in total. Part 6 needs O(n log n) space in total, since Tλ contains one separator S(p) iff. there exists at least one node with label λ in N (p). 3.2 Query Given a node u ∈ G and a label λ ∈ L, do as Algorithm 1. Input: u, λ Initialization: d(u, λ) ← ∞ for Each p ∈RGD s.t. u ∈ N (p) and Tλ has an entry for p do for Each path P of S(p) do for Each path portal zu of u on P do C + ← {λ's portals on P that is farther or equal than zu from r} {z+, v+} ← the portal of some λ labeled node v that achieves min{δ(v, zv) + h(zv)} over C +, and v C − ← {λ's portals on P that is closer or equal than zu from r} {z−, v−} ← the portal of some λ labeled node v that achieves min{δ(v, zv) − h(zv)} over C −, and v d′ ← {δ(u, zu) + δ(zu, z+) + δ(v, z+), δ(u, zu) + δ(zu, z−) + δ(v, z−)} d(u, λ) ← min{d′, d(u, λ)} end end end Output: d(u, λ) Algorithm 1: Lemma 1. Given u, λ, let v be the λ labeled node satisfying δ(u, v) = δ(u, λ). There exist a portal zu of u and a portal zv of v on the same path P , such that δ(u, zu) + δ(zu, zv) + δ(zv, v) ≤ (1 + ǫ)δ(u, λ). Proof. Let pu, pv be the lowest pieces in RGD containing u, v, respectively, i.e. u ∈ N (pu) and v ∈ N (pv). Let puv be the lca of pu and pv in RGD. Then u ∈ N (puv), v ∈ N (puv), and the shortest path from u to v crosses with S(puv). Denote the crossing point as c. There exists a u's portal zu, such that δ(u, zu) + δ(zu, c) ≤ (1 + ǫ)δ(u, c), and a v's portal zv, such that δ(v, zv) + δ(zv, c) ≤ (1 + ǫ)δ(v, c). Hence δ(u, zu) + δ(zu, zv) + δ(zv, v) ≤ (1 + ǫ)δ(u, λ). This lemma implies that the output of Algorithm 1 achieves the (1+ǫ)-approximation to δ(u, λ), since -- if zv is farther than zu from r, then h(zv) + δ(zv, v) ≥ h(z+) + δ(z+, v+)), and hence δ(u, zu) + δ(zu, z+) + δ(v+, z+) ≤ δ(u, zu) + δ(zu, zv) + δ(v, zv) ≤ (1 + ǫ)δ(u, λ); -- if zv is closer than zu from r, then −h(zv) + δ(zv, v) ≥ −h(z−) + δ(z−, v−)), and hence δ(u, zu) + δ(zu, z−) + δ(v−, z−) ≤ δ(u, zu) + δ(zu, zv) + δ(v, zv) ≤ (1 + ǫ)δ(u, λ). To show the query time O( 1 ǫ log n log ρ), we only need to show that v+ (v−) and z+ (z−) could be found in O(log ρ) time. Actually, this could be done by identifying the range of C + (C −) of the portals of λ on the specified path, using O(log ρ) time, and locating v+ (v−) by range minimum query, using O(1) time. Theorem 1. Given an undirected planar graph G = (V, E) and a label set L, each vertex v ∈ V is attached with one label in L. For any 0 < ǫ < 1, there exists an oracle that could answer any vertex-label query with stretch 1 + ǫ, in O( 1 ǫ log n log ρ) time. The oracle needs O( 1 ǫ n log n) space. 3.3 3-Stretch, O(log n log ρ)-Query Time Oracle Consider the case that ǫ = 2. The oracle supports the 3-stretch, O(log n lg ρ)- query time, using space O(n log n). The space, query time product (suggested by Christian Sommer [7]) is O(n log2 n log ρ), which is better than O(n 2 ) × O(1) for general graphs. Note that in this case, each node u has only one portal on a specified path of a separator, which is the projection, denoted by zu, i.e. the node on the path closest to u. The reason is for any node z on the path, we have δ(z, zu) ≤ δ(u, zu) + δ(u, z) ≤ 2δ(u, zu), and hence δ(u, z) ≤ δ(u, zu) + δ(zu, z) ≤ 3δ(u, zu). 3 4 O(1) Time to Identify C + (C −) when ρ = O(log n) In the case that ρ = O(log n), the time to identify C + (C −) is O(log log n). We show that this could be improved to O(1). At first, note that when we store the portals for a label λ, it is possible that a node servers as the portals for different nodes. It is obvious that we can only store the one with the minimum portal-node distance. Thus fixed a label λ, on a path of a separator, each node serves as at most one portal of λ. Using a word of ρ = O(log n) bits, denoted by ω, it can be identified whether a node on the path is a portal, i.e. the i-th bit is 1 iff. the i-th node on the path is a portal for λ. If the portals on a path for λ are stored in the increasing order of their positions on the path, its index could be retrieved by counting how many 1 there are before the i-th position of ω. Since any operation on a single word is assumed to cost O(1) time, we achieve the O(1) time method to identify C +, with -- O(n log n) space to record the position on the path forming separator, for each portal; and -- O(n log n) space to store ω's for all labels. Theorem 2. Given an undirected planar graph G = (V, E) and a label set L, each vertex v ∈ V is attached with one label in L. If the radius of G is of order O(log n), then for any 0 < ǫ < 1, there exists an oracle that could answer any vertex-label query with stretch 1 + ǫ, in O( 1 ǫ log n) time. The oracle needs O( 1 ǫ n log n) space. 5 Label Changes We consider the cost to update the oracle, if a node v changes its label from λ1 to λ2. The portals of v are not affected. However, the portals of λ1 and λ2 should be change. To remove the portals of v from the portals of λ1, it requires to change the hash table indicating of whether a separator is related to λ1 for at most once, and change the portal sequences of λ1 for at most O(log n) separators. To add the portals of v to the portals of λ2, it requires to change the hash table indicating of whether a separator is related to λ2 for at most once, and change the portal sequences of λ2 for at most O(log n) separators. 6 Application Nearest Neighbor Search for Multiple Sets. Given a set V (λ) of nodes, it is trivial to construct a linear size (O(n)) oracle to support the query the nearest neighbor in V (λ) for a query node u, i.e. the closest node to u in V (λ). However, if there are several such sets {V (λi)}λi ∈L, this trivial method needs O(L · n) space, which may be as big as O(n2) even each node is associated with only one label. Using the oracle introduced in this document, we may construct an oracle using O( 1 ǫ n log n) space to support the query of (1 + ǫ)-NNS between a node and a label in O( 1 ǫ log n log ρ) time. Let's consider the case that each node in the graph could be associated with more than one labels. In this case, K = Pλi∈L V (λi) could be bigger than n, the oracle introduced here needs O( 1 ǫV (λi) log n). log n ) Note that O(Ln) = Pλi∈L O(n) and O( 1 Hence the method introduced here is more efficient on space if 1 for all λi ∈ L. ǫV (λi) = o( n ǫ K log n) space. ǫ K log n) = Pλi ∈L O( 1 References 1. Shiri Chechik. Improved distance oracles for vertex-labeled graphs. CoRR, abs/1109.3114, 2011. 2. Thomas H. Cormen, Clifford Stein, Ronald L. Rivest, and Charles E. Leiserson. Introduction to Algorithms. McGraw-Hill Higher Education, 2nd edition, 2001. 3. Johannes Fischer and Volker Heun. A new succinct representation of rmq- information and improvements in the enhanced suffix array. In PROC. ESCAPE. LNCS, pages 459 -- 470. Springer, 2007. 4. Danny Hermelin, Avivit Levy, Oren Weimann, and Raphael Yuster. Distance ora- cles for vertex-labeled graphs. In Proceedings of the 38th international conference on Automata, languages and programming - Volume Part II, ICALP'11, pages 490 -- 501, Berlin, Heidelberg, 2011. Springer-Verlag. 5. Philip Klein. Preprocessing an undirected planar network to enable fast approxi- mate distance queries. In Proceedings of the thirteenth annual ACM-SIAM sympo- sium on Discrete algorithms, SODA '02, pages 820 -- 827, Philadelphia, PA, USA, 2002. Society for Industrial and Applied Mathematics. 6. Richard J. Lipton and Robert Endre Tarjan. A separator theorem for planar graphs. SIAM Journal on Applied Mathematics, 36(2):pp. 177 -- 189, 1979. 7. Christian Sommer. More compact oracles for approximate distances in planar graphs. In arXiv, 2012. 8. Yufei Tao, Stavros Papadopoulos, Cheng Sheng, and Kostas Stefanidis. Nearest keyword search in xml documents. In Proceedings of the 2011 international confer- ence on Management of data, SIGMOD '11, pages 589 -- 600, New York, NY, USA, 2011. ACM. 9. M. Thorup. Undirected single source shortest paths in linear time. In Proceedings of the 38th Annual Symposium on Foundations of Computer Science, pages 12 -- , Washington, DC, USA, 1997. IEEE Computer Society. 10. Mikkel Thorup and Uri Zwick. Approximate distance oracles. In Proceedings of the thirty-third annual ACM symposium on Theory of computing, STOC '01, pages 183 -- 192, New York, NY, USA, 2001. ACM. 11. Christian Wulff-Nilsen. Approximate distance oracles with improved preprocessing time. SODA '12, 2012. Appendix A: Finding Portals to Promise Distance Property Lemma 2. For each node v and each path P ′, there exists a set {zi} of size less than 4(ǫ − ǫ2)−1 for which the distance condition is satisfied. Proof. Let z0 be the node on P ′ that is closest to the node v and then we choose the remaining portals zi in two phases. -- Phase 1. In this phase, we choose a set of nodes zi that are closer than z0 to the root r, using Algorithm 2. Define a node in z on P ′ to be a candidate with respect to (w.r.t.) i iff. 1. z is closer tot eh root than zi+1, and 2. δ(v, z) < (1 + ǫ)−1(δ(v, zi+1 + δ(r, zi+1) + δ(r, z)). Initialization: while ∃ candidates w.r.t i do i ← −1 zi ← candidate z that is farthest from r i ← i − 1 end Algorithm 2: Note the invariant for Phase 1: for i < 0 and any node h lying strictly between zi and zi+1 on P ′, we have δ(v, zi+1)+δ(zi+1, h) ≤ (1+ǫ)δ(v, h). In particular, if there is no candidate w.r.t. k, then for any node h lying strictly between the root r and zi+1 on P ′, we have δ(v, zi+1) + δ(zi+1, h) ≤ (1 + ǫ)δ(v, h). -- Phase 2. In this phase, we choose a set of nodes zi that are farther than z0 to the root r, using Algorithm 3. Define a node in z on P ′ to be a candidate with respect to (w.r.t.) i iff. 1. z is farther to the root than zi+1, and 2. δ(v, z) < (1 + ǫ)−1(δ(v, zi−1 + δ(r, z) + δ(r, zi−1)). Initialization: while ∃ candidates w.r.t i do i ← 1 zi ← candidate z that is closest from r i ← i + 1 end Algorithm 3: Note the invariant for Phase 2: for i > 0 and any node h lying strictly between zi and zi−1 on P ′, we have δ(v, zi−1) + δ(zi−1, h) ≤ (1 + ǫ)δ(v, h). In particular, if there is no candidate w.r.t. k, then for any node h lying beyond zi−1 on P ′, we have δ(v, zi−1) + δ(zi−1, h) ≤ (1 + ǫ)δ(v, h). Clearly, the {zi} chosen satisfies the distance condition. It remains to show that the number of zi chosen is O( 1 ǫ ). We show the analysis for i > 0 and it applies to the case of i < 0 in the similar way. Since δ(v, zi) < (1 + ǫ)−1(δ(v, zi−1) + δ(r, zi) − δ(r, zi−1)) ≤ (1 + ǫ)−1δ(v, zi−1) + δ(r, zi) − δ(r, zi−1) ≤ δ(v, zi−1) − (ǫ − ǫ2)δ(v, zi−1) + δ(r, zi) − δ(r, zi−1) ≤ δ(v, zi−1) − (ǫ − ǫ2)δ(v, z0) + δ(r, zi) − δ(r, zi−1), then δ(v, zi) − δ(zi, r) < δ(v, zi−1) − δ(r, zi−1) − (ǫ − ǫ2)δ(v, z0) < δ(v, z0) − δ(r, z0) − i(ǫ − ǫ2)δ(v, z0) Noting δ(v, zi) − δ(zi, r) ≥ −δ(v, z0) − δ(r, z0), it follows that i < 2(ǫ − ǫ2)−1. This implies the lemma.
1902.08809
2
1902
2019-04-16T15:52:03
Faster and simpler algorithms for finding large patterns in permutations
[ "cs.DS", "math.CO" ]
Permutation patterns and pattern avoidance have been intensively studied in combinatorics and computer science, going back at least to the seminal work of Knuth on stack-sorting (1968). Perhaps the most natural algorithmic question in this area is deciding whether a given permutation of length $n$ contains a given pattern of length $k$. In this work we give two new algorithms for this well-studied problem, one whose running time is $n^{0.44k+o(k)}$, and one whose running time is the better of $O(1.6181^n)$ and $n^{k/2+o(k)}$. These results improve the earlier best bounds of Ahal and Rabinovich (2000), and Bruner and Lackner (2012), and are the fastest algorithms for the problem when $k = \Omega(\log n)$. When $k = o(\log n)$, the parameterized algorithm of Guillemot and Marx (2013) dominates. Our second algorithm uses polynomial space and is significantly simpler than all previous approaches with comparable running times, including an $n^{k/2+o(k)}$ algorithm proposed by Guillemot and Marx. Our approach can be summarized as follows: "for every matching of the even-valued entries of the pattern, try to match all odd-valued entries left-to-right". For the special case of patterns that are Jordan-permutations, we show an improved, subexponential running time.
cs.DS
cs
Faster and simpler algorithms for finding large patterns in permutations László Kozma Institut für Informatik, Freie Universität Berlin [email protected] Abstract Permutation patterns and pattern avoidance have been intensively studied in combinatorics and computer science, going back at least to the seminal work of Knuth on stack-sorting (1968). Perhaps the most natural algorithmic question in this area is deciding whether a given permutation of length n contains a given pattern of length k. In this work we give two new algorithms for this well-studied problem, one whose running time is n0.44k+o(k), and one whose running time is the better of O(1.6181n) and nk/2+o(k). These results improve the earlier best bounds of Ahal and Rabinovich (2000), and Bruner and Lackner (2012), and are the fastest algorithms for the problem when k = Ω(log n). When k = o(log n), the parameterized algorithm of Guillemot and Marx (2013) dominates. Our second algorithm uses polynomial space and is significantly simpler than all previous approaches with comparable running times, including an nk/2+o(k) algorithm proposed by Guillemot and Marx. Our approach can be summarized as follows: "for every matching of the even-valued entries of the pattern, try to match all odd-valued entries left-to-right". For the special case of patterns that are Jordan-permutations, we show an improved, subexponential running time. 2012 ACM Subject Classification Theory of computation → Data structures design and analysis; Theory of computation → Pattern matching Keywords and phrases permutations, pattern matching, exponential time Introduction 1 Let [n] = {1, . . . , n}. Given two permutations t : [n] → [n], and π : [k] → [k], we say that t contains π, if there are indices 1 ≤ i1 < ··· < ik ≤ n such that t(ij) < t(i') if and only if π(j) < π('), for all 1 ≤ j, ' ≤ k. In other words, t contains π, if the sequence (t(1), . . . , t(n)) has a (possibly non-contiguous) subsequence with the same ordering as (π(1), . . . , π(k)), otherwise t avoids π. For example, t = (1, 5, 4, 6, 3, 7, 8, 2) contains (2, 3, 1), because its subsequence (5, 6, 3) has the same ordering as (2, 3, 1); on the other hand, t avoids (3, 1, 2). Knuth showed in 1968 [32, § 2.2.1], that permutations sortable by a single stack are exactly those that avoid (2, 3, 1). Sorting by restricted devices has remained an active research topic [45, 41, 43, 9, 2, 4], but permutation pattern avoidance has taken on a life of its own (especially after the influential work of Simion and Schmidt [44]), becoming an important subfield of combinatorics. For more background on permutation patterns and pattern avoidance we refer to the extensive survey [46] and relevant textbooks [10, 14, 30]. Perhaps the most important enumerative result related to permutation patterns is the Stanley-Wilf conjecture, raised in the late 1980s and proved in 2004 by Marcus and Tardos [35]. It states that the number of length-n permutations which avoid a fixed pattern π is bounded by c(π)n, where c(π) is a quantity independent of n. (Marcus and Tardos proved the result in the context of 0/1 matrices, answering a question of Füredi and Hajnal [23], which was shown by Klazar [31] to imply the Stanley-Wilf conjecture.) A fundamental algorithmic problem in this context is Permutation Pattern Matching (PPM): Given a length-n permutation t ("text") and a length-k permutation π ("pattern"), decide whether t contains π. 9 1 0 2 r p A 6 1 ] S D . s c [ 2 v 9 0 8 8 0 . 2 0 9 1 : v i X r a 2 Faster and simpler algorithms for finding large patterns in permutations Solving PPM is a bottleneck in experimental work on permutation patterns [3]. The problem and its variants also arise in practical applications, e.g. in computational biology [30, § 2.4] and time-series analysis [28, 7, 40]. Unfortunately, in general, PPM is NP-complete, as shown by Bose, Buss, and Lubiw [11] in 1998. (This is in contrast to e.g. string matching problems that are solvable in polynomial time.) An obvious algorithm for PPM is to enumerate all (cid:0)n (cid:1) length-k subsequences of t, k and check whether any of them has the same ordering as π. The first result to break this "triviality barrier" was the n2k/3+o(k)-time algorithm of Albert, Aldred, Atkinson, and Holton [3]. Around the same time, Ahal and Rabinovich [1] obtained the running time n0.47k+o(k). The two algorithms are based on a similar dynamic programming approach, but they differ in essential details. Informally, in both algorithms, the entries of the pattern π are matched one-by-one to entries of the text t, observing the order-restrictions imposed by the current partial matching. The key observation is that only a subset of the matched entries need to be remembered, namely those that form a certain "boundary" of the partial matching. The maximum size of this boundary depends on the matching strategy used, and the best attainable value is a graph-theoretic parameter of a certain graph constructed from the pattern (the parameter is essentially the pathwidth of the incidence graph of π). We review this framework in § 3.2. In the algorithm of Albert et al. the pattern-entries are matched in the simplest, left-to- right order. In the algorithm of Ahal and Rabinovich, the pattern-entries are matched in a uniform random order, interspersed with greedy steps that reduce the boundary. (For the purely random strategy, they show a weaker n0.54k+o(k) bound, and they describe further heuristics, without analysis.) Our first result is a new algorithm for PPM (Algorithm M), improving the bounds of [3, 1]. (cid:73) Theorem 1. Algorithm M solves Permutation Pattern Matching in time n0.44k+o(k). The algorithm uses dynamic programming, but selects the pattern-entries to be matched using an optimized, global strategy, differing significantly from the previous approaches. In addition to being the first (admittedly small) improvement in a long time on the complexity of PPM for large patterns, our approach is deterministic, and has the advantage of a more transparent analysis. (The analysis of the random walk in [1] is based on advanced probabilistic arguments, and appears in the journal paper only as a proof sketch.) In 2013, Guillemot and Marx [24] obtained the breakthrough result of a PPM algorithm with running time 2O(k2 log k) · n. This result established the fixed-parameter tractability of the problem in terms of the pattern length. Their algorithm builds upon the Marcus-Tardos proof of the Stanley-Wilf conjecture and introduces a novel decomposition of permutations. For the (arguably most natural) case of constant-size patterns, the Guillemot-Marx algorithm has linear running time. (Due to the large constants involved, it is however, not clear how efficient it is in practice.) Subsequently, Fox [21] refined the Marcus-Tardos result, thereby improving the Guillemot-Marx bound, removing the log k factor from the exponent. Whether the dependence on k can be further improved remains an intriguing open question. In light of the Guillemot-Marx result, for constant-length patterns, the PPM problem is well-understood. However, for patterns of length e.g. k ≈ log2 n or larger, the complexity of the problem is open, and in this regime, Theorem 1 is an improvement over previous results. Guillemot and Marx also describe an alternative, polynomial-space algorithm, with running time nk/2+o(k), i.e. slightly above the Ahal-Rabinovich bound [24, § 7]. Although simpler than their main result, this method is still rather complex -- it works by decomposing the text into 2d√ ne monotone subsequences (such a decomposition exists by the Erdős-Szekeres theorem), L. Kozma 3 and solving as a subroutine, a certain constraint-satisfaction problem whose tractability is implied by a nontrivial structural property. Our second result (Algorithm S) matches these time and space bounds by an exceedingly simple approach. Expressed in terms of n only, none of the mentioned running times improve, in the worst case, upon the trivial 2n. (Consider the case of a pattern of length k = Ω(n/ log n).) The first non-trivial bound in this parameter range was obtained by Bruner and Lackner [13]; their algorithm runs in time O(1.79n). The algorithm of Bruner and Lackner works by decomposing both the text and the pattern into alternating runs (consecutive sequences of increasing or decreasing elements). They then use this decomposition to restrict the space of admissible matchings. The exponent in the running time is, in fact, the number of runs of T, which can be as large as n. The approach is compelling and intuitive, the details, however, are intricate (the description of the algorithm and its analysis in [13] take over 24 pages). Our second result also improves this running time, with an algorithm that can be described and analysed in a few paragraphs. (cid:73) Theorem 2. Algorithm S solves Permutation Pattern Matching using polynomial space, in time nk/2+o(k) or O(1.6181n). At the heart of Algorithm S is the following observation: if all even-valued entries of the pattern π are matched to entries of the text t, then verifying whether the remaining (odd) entries of π can be correctly matched takes only a linear-time, left-to-right sweep through both π and t. Beyond the general case, the PPM problem has been extensively studied when either t or π come from some restricted family of permutations. Examples include separable permutations [11, 27, 47, 3], i.e. avoiding (2, 4, 1, 3) and (3, 1, 4, 2), k-increasing or k-decreasing patterns [17], k-monotone text [24, 15], patterns of length 3 or 4 [3], patterns avoiding (3, 2, 1) [25], text or pattern avoiding (2, 1, 3) and (2, 3, 1) [37], linear permutations [1], permutations with few runs [13]. In a similar vein, we consider the case of Jordan-permutations, a natural family of geometrically-defined permutations with applications in intersection problems of computa- tional geometry [42]. Jordan-permutations were studied by Hoffmann, Mehlhorn, Rosenstiehl, and Tarjan [26], who showed that they can be sorted with a linear number of comparisons, using level-linked trees. A Jordan permutation is generated by the intersection-pattern of two simple curves in the plane. Label the intersection points between the curves in increasing order along the first curve, and read out the labels along the second curve; the obtained sequence is a Jordan-permutation (Figure 1). We show that if the pattern is a Jordan-permutation, then PPM can be solved in sub-exponential time. √ (cid:73) Theorem 3. If π is a Jordan permutation, then PPM can be solved in time nO( k). The improvement comes from the observation that the incidence graph of Jordan- permutations is (by construction) planar, allowing the use of planar separators in generating a good matching order in the dynamic programming framework of Algorithm M. This observation suggests a more general question. Which permutations have incidence graphs with sublinear-size separators? We observe that many of the special families of patterns considered in the literature can be understood in terms of avoiding certain fixed patterns (that is, the pattern π avoids some smaller pattern σ). The following conjecture thus appears natural, as it would unify and generalize a number of results in the literature. 4 Faster and simpler algorithms for finding large patterns in permutations (cid:66) Conjecture 4. (with text t and pattern π) can be solved in time 2o(n). If the pattern π avoids an arbitrary pattern σ of length O(1), then PPM Conjecture 4 appears plausible, especially in light of the extremal results of Fox [21] related to the Stanley-Wilf conjecture. Characterizing the base c(π) of the Stanley-Wilf bound remains a deep open question. Fox has recently shown that, contrary to prior conjectures, c(π) is exponential in π for most patterns π. In some special cases it is known that c(π) is subexponential, and Fox conjectures [21, Conj. 1] that this is the case whenever the pattern π is itself pattern-avoiding; Conjecture 4 can be seen as an algorithmic counterpart of this question. A possible route towards proving Conjecture 4 is to show that avoidance of a length-d pattern in π (and the resulting f(d)-wide decomposition given by Guillemot and Marx) implies the avoidance of some g(d)-size minor in the incidence graph Gπ. We only remark here, that one cannot hope for a forbidden grid minor, as there are O(n)-permutations that avoid an O(1)-length pattern, yet contain a n grid in their incidence graph (§ 3.4). n × √ √ Further related work. Only classical patterns are considered in this paper; variants in the literature include vincular, bivincular, consecutive, and mesh patterns; we refer to [12] for a survey of related computational questions. Newman et al. [38] study pattern matching in a property-testing framework (aiming to distinguish pattern-avoiding sequences from those that contain many copies of the pattern). In this setting, the focus is on the query complexity of different approaches, and sampling techniques are often used; see also [6, 22]. A different line of work investigates whether standard algorithmic problems on permuta- tions (e.g. sorting, selection) become easier if the input can be assumed to be pattern- avoiding [5, 16]. Structure of the paper. In § 2 we introduce the concepts necessary to state and prove our results. In § 3 we describe and analyse our two algorithms; in § 3.1 the simpler Algorithm S, and in § 3.3 the improved Algorithm M, thereby proving Theorems 1 and 2. We describe the dynamic programming framework used by Algorithm M in § 3.2. In § 3.4 we discuss the special cases (Theorem 3 and Conjecture 4), and in § 4 we conclude with further questions. Preliminaries 2 A length-n permutation σ is a bijective function σ : [n] → [n], alternatively viewed as the sequence (σ(1), . . . , σ(n)). Given a length-n permutation σ, we denote as Sσ = {(i, σ(i)) 1 ≤ i ≤ n} the set of points corresponding to permutation σ. For a point p ∈ Sσ we denote its first entry as p.x, and its second entry as p.y, referring to these values as the index, respectively, the value of p. Observe that for every i ∈ [n], we have {p ∈ Sσ p.x = i} = {p ∈ Sσ p.y = i} = 1. We define four neighbors of a point (x, y) ∈ Sσ as follows. N R((x, y)) = (x + 1, σ(x + 1)), N L((x, y)) = (x − 1, σ(x − 1)), N U((x, y)) = (σ−1(y + 1), y + 1), N D((x, y)) = (σ−1(y − 1), y − 1). The superscripts R, L, U, D are meant to evoke the directions right, left, up, down, when plotting Sσ in the plane. Some neighbors of a point may coincide. When some L. Kozma 5 index is out of bounds, we let the offending neighbor be a "virtual point" as follows: N R(n, i) = N U(i, n) = (∞,∞), and N L(1, i) = N D(i, 1) = (0, 0), for all i ∈ [n]. The virtual points are not contained in Sσ, we only define them to simplify some of the statements. The incidence graph of a permutation σ is Gσ = (Sσ, Eσ), where Eσ = {(p, N α(p)) α ∈ {R, L, U, D}, and p, N α(p) ∈ Sσ} . In words, each point is connected to its (at most) four neighbors: its successor and predecessor by index, and its successor and predecessor by value. It is easy to see that Gσ is a union of two Hamiltonian paths on the same set of vertices, and that this is, in fact, an exact characterization of permutation incidence-graphs. (See Figure 1 for an illustration.) Figure 1 (left) Permutation π = (6, 5, 3, 1, 4, 7, 2) and its incidence graph Gπ. Solid lines indicate neighbors by index, dashed lines indicate neighbors by value (lines may overlap). Indices plotted on x-coordinate, values plotted on y-coordinate. (right) Jordan-permutation (4, 1, 2, 3, 8, 5, 6, 7) Throughout the paper we consider a text permutation t : [n] → [n], and a pattern permutation π : [k] → [k], where n ≥ k. We give an alternative definition of the Permutation Pattern Matching (PPM) problem in terms of embedding Sπ into St. Consider a function f : Sπ → St. We say that f is a valid embedding of Sπ into St if for all p ∈ Sπ the following hold: f(N L(p)).x < f(p).x < f(N R(p)).x, and f(N D(p)).y < f(p).y < f(N U(p)).y, (1) (2) whenever the corresponding neighbor N α(p) is also in Sπ, i.e. not a virtual point. In words, valid embeddings preserve the relative positions of neighbors in the incidence graph. (cid:73) Lemma 5. Permutation t contains permutation π if and only if there exists a valid embedding f : Sπ → St. For sets A ⊆ B ⊆ Sπ and functions g : A → St and f : B → St we say that g is the restriction of f to A, denoted g = fA, if g(i) = f(i) for all i ∈ A. In this case, we also say that f is the extension of g to B. Restrictions of valid embeddings will be called partial embeddings. We observe that if f : B → St is a partial embedding, then it satisfies conditions (1) and (2) with respect to all edges in the induced graph Gπ[B], i.e. the corresponding inequality holds whenever p, N α(p) ∈ B. Algorithms for pattern matching 3 We start in § 3.1 with the simpler Algorithm S, proving Theorem 2. In § 3.2 we describe the dynamic programming framework used in Algorithm M (Algorithm S does not require this). In § 3.3 we describe and analyse Algorithm M, proving Theorem 1. 6 Faster and simpler algorithms for finding large patterns in permutations 3.1 The even-odd method Let (QE, QO) be the partition of Sπ into points with even and odd indices. Formally, QE = {(2k, π(2k)) 1 ≤ k ≤ bk/2c}, and QO = {(2k − 1, π(2k − 1)) 1 ≤ k ≤ dk/2e}. Suppose t contains π. Then, by Lemma 5, there exists a valid embedding f : Sπ → St. We start by guessing a partial embedding g0 : QE → Sπ. (For example, g0 = fQE is such a partial embedding.) We then extend g0 step-by-step, adding points to its domain, until it becomes a valid embedding Sπ → St. Let p1, . . . , pdk/2e be the elements of QO in increasing order of value, i.e. 1 ≤ p1.y < ··· < pdk/2e.y ≤ n, and let P0 = ∅ and Pi = Pi−1 ∪ {pi}, for 1 ≤ i ≤ dk/2e. For all i, we maintain the invariant that gi is a restriction of some valid embedding to QE ∪ Pi. By our choice of g0, this is true initially for i = 0. In the i-th step (for i = 0, . . . ,dk/2e − 1), we extend gi to gi+1 by mapping the next point pi+1 onto a suitable point in St. For gi+1 to be a restriction of a valid embedding, it must satisfy conditions (1) and (2) on the relative position of neighbors. Observe that all, except possibly one, of the neighbors of pi+1 are already embedded by gi. This is because N L(pi+1) and N R(pi+1) have even index, are thus in QE, unless they are virtual points and thus implicitly embedded. The point N D(pi+1) is either an even-index point, and thus in QE, or the virtual point (0, 0) and thus implicitly embedded, or an odd-index point, in which case, by our ordering, it must be pi, and thus, contained in Pi. The only neighbor of pi+1 possibly not embedded is N U(pi+1). If we map pi+1 to a point q ∈ St, we have to observe the constraints gi(N L(pi+1)).x < q.x < gi(N R(pi+1)).x, and gi(N D(pi+1)).y < q.y. If N U(pi+1) is also in the domain of gi, then we have the additional constraint q.y < gi(N U(pi+1)).y. These constraints determine an (open) axis-parallel box, possibly extending upwards infinitely (in case only three of the four neighbors of pi+1 are embedded so far). Assuming gi is a restriction of a valid embedding f, the point f(pi+1) must satisfy all constraints, it is thus contained in this box. We extend gi to obtain gi+1 by mapping pi+1 to a point q ∈ St in the constraint-box, and if there are multiple such points, we pick the one that is lowest, i.e. the one with smallest value q.y. The crucial observation is that if gi is a partial embedding, then gi+1 is also a partial embedding, and the correctness of the procedure follows by induction. Indeed, some valid embedding f0 : Sπ → St must be the extension of gi+1. If q = f(pi+1), then f0 is f itself. Otherwise, let f0 be identical with f, except for mapping pi+1 → q (instead of mapping pi+1 → f(pi+1)). The only conditions of a valid embedding that may become violated are those involving pi+1. The conditions f0(N L(pi+1)).x < f0(pi+1).x < f0(N R(pi+1)).x and f0(N D(pi+1)).y < f0(pi+1).y hold by our choice of q. The condition f0(pi+1).y < f0(N U(pi+1)).y holds a fortiori since we picked the lowest point in a box that also contained f(pi+1), in other words, f0(pi+1).y = q.y ≤ f(pi+1).y < f(N U(pi+1)).y = f0(N U(pi+1)).y. Thus, gi+1 is a partial embedding, which concludes the argument. See Figure 2 for illustration. Assuming that our initial guess g0 was correct, we succeed in constructing a valid embedding that certifies the fact that t contains π. We remark that guessing g0 should be understood as trying all possible embeddings of QE. If our choice of g0 is incorrect, i.e. not a partial embedding, then we reach a situation where we cannot extend gi, and we abandon the choice of g0. If extending g0 to a valid embedding fails for all initial choices, we conclude that t does not contain π. The resulting Algorithm S is described in Figure 3. The space requirement is linear in the input size; apart from minor bookkeeping, only a single embedding must be stored at all times. L. Kozma 7 Figure 2 (left) Pattern π = (6, 3, 8, 5, 4, 2, 1, 7) and its incidence graph Gπ. Solid lines indicate neighbors by index, dashed lines indicate neighbors by value (lines may overlap). (right) Text permutation t, points shown as circles. Partial embedding of π shown with filled circles. Vertical bars mark even-index points e1, e2, e3, e4. Double circles mark the first two odd-index points p1, p2. Shaded box indicates constraints for embedding p2, determined by N U(p2) = N L(p2) = e2, N D(p2) = e1, and N R(p2) = e3. Observe that p2 is mapped to lowest point (by value) that satisfies constraints. Revealed edges of Gπ are shown. Algorithm S: for all g0 : QE → St do if g0 not valid, next g0 for i ← 0 to dk/2e − 1 do let q ∈ St with minimum q.y such that: gi(N L(pi+1)).x < q.x < gi(N R(pi+1)).x gi(N D(pi+1)).y < q.y gi(N U(pi+1)).y > q.y (in case N U(pi+1) ∈ QE) if no such q, next g0 extend gi to gi+1 by mapping pi+1 → q return gdk/2e return "t avoids π" Figure 3 Finding a valid embedding of Sπ into St, or reporting that t avoids π, with precomputed QE (even-index points of Sπ) and (p1, . . . , pdk/2e) (odd-index points of Sπ sorted by value). To analyse the running time, observe first, that g0 must map points in QE to points in St, preserving their left-to-right order (by index), and their bottom-to-top order (by value). The first condition can be enforced directly, by considering only subsequences of t. This leads (cid:1) choices for g0 in the outer loop. The second condition can be verified in a linear to(cid:0) nbk/2c time traversal of Gπ (this is the second line of Algorithm S). All remaining steps can be performed using straightforward data structuring: we need to traverse to neighbors in the incidence graph, to go from x to gi(x) and back, and to answer rectangle-minimum queries; all can be achieved in constant time, with a polynomial time preprocessing. We can in fact do away with rectangle queries, since candidate points of t are considered in increasing order of value -- the inner loop thus consists of a single sweep through π and t, which can be implemented in O(n) time. By a standard bound on the binomial coefficient, the claimed running time of nk/2+o(k) follows. We refine the analysis, observing that in the outer loop only those embeddings g0 (i.e. subsequences of t) need to be considered, that leave a gap of at least one point between each 8 Faster and simpler algorithms for finding large patterns in permutations with this property is(cid:0)n−k/2 (cid:1); first embed all even-index entries with a minimum required gap (cid:1), where β = α successive entry (to allow for embedding the odd-index points). The number of subsequences of one between them, then distribute the remaining total gap of n − k among the k/2 slots. To bound this quantity, denote α = k 1−α. A standard upper bound for this quantity (see e.g. [18, § 11]) is 2m·H(β), where H is the binary entropy function H(x) = − log2 (xx · (1 − x)1−x). 2n and m = n − αn, to obtain(cid:0) m Our upper bound is thus 2n·(1−α)·H(α/(1−α)). After simplification, we obtain the expres- k/2 mβ sion [B(α)]n, where B(α) = (1 − α)1−α αα · (1 − 2α)(1−2α) . 2 In the range of interest 0 < α < 0.5, we find B(α) to be maximized for α = 1 2 − 1 5, √ attaining a value smaller than 1.6181. We obtain thus the upper bound O(1.6181n) for the running time. The efficient enumeration of initial embeddings with the required property can be done with standard techniques, see e.g. [39]. Note that the algorithm can equivalently be implemented in the variant where both t and π are transposed, i.e. by embedding even values first, followed by odd values sorted by index, as described in § 1. Finally, we remark that instead of trying all embeddings g0, it may be more practical to build such an embedding incrementally, using backtracking. This allows the process to "fail early" if a certain embedding can not be extended to any partial embedding of QE. The order in which points of QE are considered in the backtracking process can affect the performance significantly, see [33, 34] for consideration of similar issues. Alternatively, a modification of the dynamic programming approach of § 3.2 and § 3.3 may also be used to enumerate all valid initial g0. 3.2 Dynamic programming approach We review the dynamic programming framework that Algorithm M (§ 3.3) shares with the previous algorithms of Albert et al. [3] and Ahal and Rabinovich [1]. We refer to these works for a more detailed exposition. The idea is to fix an embedding order τ in which the elements of Sπ are processed. Let τ : [k] → [k] be a permutation, and let ∅ = P0 ⊂ P1 ⊂ ··· ⊂ Pk = Sπ, where Pi = Pi−1∪{pi}, and pi = (τ(i), π(τ(i))). For i = 1, . . . , k, we find embeddings gi : Pi → St that extend the previously found embeddings gi−1, by mapping pi to a suitable target q ∈ St. The difference from Algorithm S is that we consider all possible targets (that satisfy the neighbor-constraints with respect to already mapped neighbors), and we store all (so far) valid embeddings gi in a table. More precisely, we store all embeddings of Pi that do not violate any neighborhood- constraint in Gπ[Pi]. In the i-th step, for all stored gi embeddings, we find all pos- sible extensions, mapping pi to q such that gi(N L(pi)).x < q.x < gi(N R(pi)).x, and gi(N D(pi)).y < q.y < gi(N U(pi)).y, whenever the respective neighbor of q is in the do- main of gi, i.e. already embedded by gi. The key to improving this basic approach is the observation that for each embedding gi it is sufficient to store those points that have neighbors in Gπ that are not yet embedded. (Points whose neighbors are all embedded cannot influence future choices.) We thus define, for a set P ⊆ Sπ the boundary set bd(P) = {q q ∈ P, N α(q) ∈ Sπ \ P, for some α ∈ {R, L, U, D}}. L. Kozma 9 (cid:0) Instead of storing the embeddings gi : Pi → St, we only store their restrictions gibd(Pi). (As different embeddings may have the same restriction, careful data structuring is required to prune out duplicates; see [1].) The total space- and time-requirement of the resulting algorithm is dominated by the number of essentially different embeddings gi (i.e. those with different restrictions to the boundary). At a given step i, the number of possible boundary-embeddings is at most nbd(Pi) by the embedding order τ. Let us therefore define bdτ(π) = maxi bd(Pi). (cid:1). Observe that this quantity depends on the sets Pi, which are in turn determined The quantity minτ bdτ(π) is known in the literature as the vertex-separation number, computed here for the graph Gπ. For an arbitrary graph, this quantity equals the pathwidth of the graph [29, 19]. An upper bound α· k on the pathwidth of Gπ thus implies an algorithm with running time at most nα·k+o(k) (by a standard upper bound on the binomial coefficient), and the problem reduces to finding an embedding order τ with small bdτ(π). Albert et al. show that if τ is the identity permutation, then bdτ(π) ≤ 2k/3 + 1. Ahal and Rabinovich show that the 2k/3 + 1 bound cannot be improved for any fixed τ (i.e. τ independent of π), and describe a randomized construction of τ with bdτ(π) ≤ 0.47k + o(k). They further show that there are permutations π for which bdτ(π) > 0.036k, with arbitrary τ. (This follows from a result of Bollobás on random 4-regular graphs [8].) We remark that Algorithm S (§ 3.1) can also be seen as an embedding order τ, with bdτ(π) ≤ k/2 + o(k), it can thus be easily adapted to the dynamic programming framework with similar running time, although at the cost of exponential space. (The key to the efficiency of Algorithm S is that we need not store more than one embedding.) 3.3 Improved dynamic programming As in § 3.1, let QE and QO denote the even-index, resp. odd-index points of Sπ. Let s = blog2 kc, and let Ij = [(j−1)·k/(2s)+1, j·k/(2s)], for j = 1, . . . , 2s. In words, partition [k] into equal-length contiguous intervals I1, . . . , I2s. Assume for simplicity that 2s divides k; we can ensure this by appropriate padding of π (after fixing s). Let Pj = {p ∈ Sπ p.y ∈ Ij}, i.e. the points of Sπ whose value falls in the j-th interval. We describe the embedding order τ in three stages, and show that bdτ(π) ≤ 0.4375k+o(k), which, by the discussion in § 3.2 yields the running time claimed in Theorem 1. First we summarize the process. In the first stage we embed s of the 2s sets P1, . . . , P2s, chosen such as to minimize the size of the boundary at the end of the stage. Let QI denote the set of points embedded in this stage. In the second stage we embed either QE \ QI or QO \ QI, depending on which is more advantegous, as explained later. In the third stage we embed all remaining points of Sπ in their increasing order of value. See Figure 4 for an illustration. We now provide more detail and analysis. s First stage. Let {i1, . . . , is} ⊂ [2s] be the collection of s indices for which QI = Pi1∪···∪Pis (cid:0)2s (cid:1) choices, each in linear time. The cost of this step is absorbed in our overall bound on has the smallest boundary. Finding these indices in a naïve way amounts to verifying all We claim that bd(QI) is at most k( 1 the running time. We then embed QI (i.e. the first k/2 entries of τ are the indices of points in QI). 8) + o(k). To see this, consider the expected boundary size of QI if {i1, . . . , is} were a subset of size s of [2s] chosen uniformly at random. A point p ∈ QI is not on the boundary, if all neighbors of p are in QI. Observe that N U(p) and N D(p) are in QI, unless p.y is at the margin of one of the chosen intervals Iij. Thus, at 2 − 1 10 Faster and simpler algorithms for finding large patterns in permutations in QI whose neighbors are all in QI is at least ( k The expected size of bd(QI) is thus at least k 2 − 2s)( 1 2 − k 4 − O( 1 s)) = ( k 8 − O( k s )). 8 + o(k). For the optimal choice of QI 2 −2s points have these two neighbors covered, for all choices of QI. We now look at the least k probability that the other two neighbors, N L(p) and N R(p) are in QI. The least favorable case is when the two are in separate intervals, different from the interval of p. Fixing all only the interval of p is fixed. Thus, the probability that N L(p), N R(p) ∈ QI, conditioned s), and therefore the expected number of points (cid:1) choices for completing the selection, out of(cid:0)2s−1 (cid:1)/(cid:0)2s−1 three intervals leaves(cid:0)2s−3 on p ∈ QI is at least(cid:0)2s−3 (cid:1) choices when (cid:1) = 1 4 − O( 1 s−3 s−1 s−1 s−3 (instead of random), the boundary size clearly cannot exceed this quantity. It remains to decide the actual order in which the points of QI are embedded, such as to keep the boundary size below its intended target throughout the process. This can be achieved by first embedding those points that have all their neighbors in QI, with each such point followed by its four neighbors. In this way, for every (at most) five points added, we increase the boundary by one less than the number of points added. This continues until the 8 − o(k) is realized. No intermediate boundary size can therefore exceed entire saving of k 5 · k 2} + o(k) ≤ 0.4k + o(k). max{ k 2 − k 8 , 4 Second stage. Let eE, eO denote the number of points in QE ∩ bd(QI), resp. QO ∩ bd(QI), i.e. the even- and odd-index points on the boundary of QI (call such points exposed). Let hE, hO denote the number of points in (QI ∩ QE) \ bd(QI), resp. (QI ∩ QO) \ bd(QI), i.e. the even- and odd-index points of QI not on the boundary (call such points hidden). Observe that eE + eO + hE + hO = k/2, since the sets in question partition QI. Moreover, hO + hE ≥ k 8 − o(k), by our earlier upper bound for bd(QI). k 2 + ( k If hO ≥ hE, then, in the second stage, we embed all points in QO \ QI, i.e. all odd-index points not yet embedded. Otherwise, we embed all points in QE \ QI, i.e. all even-index points not yet embedded. Suppose that we are in the first case. At the end of the stage we will have embedded a total number of k 2 − eO − hO) = 2 + eE + hE points. (The first term counts the points embedded in the first stage, the second term counts the odd-index points not embedded in the first stage. Observe that after this stage, all points in QI ∩ QE are hidden, except for (at most) 2s points with values at the margins of intervals Iij. This is because all non-margin points p ∈ QI ∩ QE have their neighbors N U(p), N D(p) already embedded in the first stage, since they fall in the same interval, and neighbors N L(p), N R(p) embedded in the second stage, since these are odd-index points. As there are at least eE − 2s newly hidden points in the second stage, the increase in boundary size is at most (eE + hE) − (eE − 2s) ≤ hE + 2s. By the assumption that hO ≥ hE, we have hE ≤ k 16 + o(k), the boundary size at the end of the stage is thus at most bd(QI) + k 16 + o(k) ≤ k 2 − k 16 + o(k) = 0.4375k + o(k). We observe that this step is the bottleneck of the entire argument. Again, we have to show that during the second stage, the boundary size never grows above this bound. To achieve this, we embed first, for each even-index point that is to be hidden in this stage, its two neighbors. As an effect, the entire saving is realized in the beginning of the stage, while the boundary size may grow by at most hE + 2s ≤ k 16 + o(k), i.e. it stays below the final bound. We can embed the remaining odd-index points in the natural, left-to-right order. In the case when hE > hO, the procedure and its analysis are symmetric, i.e. we embed all points in QE \ QI. L. Kozma 11 Figure 4 The three stages of embedding the points in Sπ. All points within shaded areas are embedded. In the first stage a point is shown whose neighbors are also embedded. Third stage. Finally, we embed all remaining points in increasing order of value. (Assuming that hO ≥ hE was the case in the second stage, this means embedding all points in QE \ QI.) We claim that the boundary does not increase during the process (except possibly by one). To see this, consider the embedding of a point p ∈ QE \ QI. Observe that N D(p) is already embedded; if it was not embedded in the first two stages, then it must be an even-index point, preceeding p by value, so it must have been embedded in the third stage. Neighbors N L(p) and N R(p) have odd index, they were thus embedded in the first two stages. Neighbor N U(p) either has odd index (is therefore already embedded), or has even index, in which case it will be the next point to be embedded, thereby hiding p. This concludes the analysis. 3.4 Special patterns We show that if the pattern π is a Jordan-permutation, then PPM can be solved in subexpo- nential time (Theorem 3). The proof is simple: the incidence graph of Jordan permutations is by definition planar. To see this, recall that a Jordan permutation is defined by the intersection pattern of two curves. We view the curves as the planar embedding of Gπ. The portions of the curves between intersection points correspond to edges (we trim the loose ends of both curves), and the curves connect the points in the order of their index, resp. value. We observe that this is in fact, an exact characterization: Gπ is planar if and only if π is a Jordan permutation.1 The pathwidth of a k-vertex planar graph is well-known to be O( n) [19]. A corresponding embedding order τ of π can be built recursively, concatenating the sequences obtained on the different sides of the separator and the sequence obtained from the separator itself. Theorem 3 follows. √ It would be interesting to obtain other classes of permutations whose incidence graphs are minor-free. Guillemot and Marx [24] show that a permutation π that avoids a pattern of length ' has a certain decomposition of width f('). To show Conjecture 4, one may relate this width with the size of a forbidden minor in Gπ. We point out that such a connection cannot be too strong: we exhibit a k-permutation that avoids a fixed pattern, but whose √ incidence graph contains a large grid, with resulting pathwidth Θ( Let a and b be parameters such that a is even, and ab = k. Let Li be the sequence of even integers in [1 + (i− 1)· a, i· a] in decreasing order, and let Ri be the sequence of odd integers in [1 + i · a, (i + 1) · a] in increasing order, for 1 ≤ i ≤ b. Observe that Li = Ri = a/2 for all i, and that all sequences are disjoint. Let π = π(a, b) denote the unique permutation of k). 1 For the "only if" direction, we need to allow touching points between the two curves. Consider any noncrossing embedding of Gπ, and construct the two curves as the Hamiltonian paths of Gπ that connect the vertices by increasing index, resp. value. Whenever the two curves overlap over an edge of Gπ, we bend the corresponding part of one of the curves, such as to create two intersection points at the two endpoints of the edge (one of the two intersection points may need to be a touching point). 12 Faster and simpler algorithms for finding large patterns in permutations length k that has the same ordering as the concatenation of T1, . . . , Tb, where Ti is obtained from interleaving Li and Ri. (See Figure 5.) We observe that π avoids the pattern σ = (4, 3, 1, 2). To see this, suppose for contradiction that π contains σ. Denote the embeddings of points of Sσ, by increasing index, as p1, p2, p3, p4. Point p2 must be in one of the Li sets, for otherwise it could have no point p1 above and to the left. Then, both p3 and p4 must be in the same Li, as only this subset contains points below and to the right of p2. However, no set Li contains two points in the same relative position as p3, p4 (i.e. one above and to the right of the other), a contradiction. Finally, we claim that Gπ contains a grid of size Θ(a) × Θ(b), as illustrated in Figure 5. Figure 5 (left) Permutation π(8, 4), with subsequences generated by Li and Ri. (right, above) Incidence graph of π(8, 4), with points corresponding to Li, Ri re-arranged in columns, to highlight grid structure. Solid line indicates neighborhood by index, dashed line indicates neighborhood by value. (right, below) Pattern (4, 3, 1, 2) avoided by π(8, 4). Concluding remarks 4 It is conceivable that the approaches presented here can be combined with previous techniques, to obtain further improvements in running time. In particular, our bounds depend on k and n only, but one could also consider finer structural parameters. A good understanding of which patterns are easiest to find is still lacking. Conjecture 4 points at a possible step in this direction. Obtaining tighter bounds for the pathwidth of permutation incidence graphs (and more generally, for the pathwidth of 4-regular graphs) is an interesting structural question in itself. For n-vertex cubic graphs, the pathwidth is known to be between 0.082n and 0.167n [20]. Related expansion-properties are also well-studied, for example, the bisection-width of 4- regular graphs is at most 0.4n + o(n) [36]. (Bisection-width is a lower bound for pathwidth.) Finally, as several different approaches for the PPM problem are now known in the literature, a thorough experimental comparison of them would be informative. Acknowledgements. An earlier version of the paper contained a mistaken analysis of Algorithm S. I thank Günter Rote for pointing out the error. This work was prompted by the Dagstuhl Seminar 18451 "Genomics, Pattern Avoidance, and Statistical Mechanics". I would like to thank the organizers for the invitation and the participants for interesting discussions. L. Kozma 13 Appendix A A.1 Proof of Lemma 5 Proof. Suppose t contains π, and let (t(i1), . . . , t(ik)) be the subsequence witnessing this. Let pj denote the point (j, π(j)), and set f(pj) = (ij, t(ij)) for all j ∈ [k]. Observe that f(N L(pj)).x = ij−1, and f(N R(pj)).x = ij+1, the first condition thus holds since ij−1 < ij < ij+1. Let π(j0) = N D(pj).y, and π(j00) = N U(pj).y. By definition, π(j0) < π(j) < π(j00). The second condition now becomes t(ij0) < t(ij) < t(ij00), which holds since t contains π. In the other direction, let f : Sπ → St be a valid embedding. Define ij = f(pj).x, for all j ∈ [k]. Since f(N L(pj)).x < f(pj).x < f(N R(pj)).x for all j, we have i1 ≤ ··· ≤ ik. Let j0, j00 ∈ [k], such that j0 < j00. Then π(ij0) < π(ij00) is equivalent with t(ij0) = f(pj).y < f(N U(. . . (N U(pj)) . . . )).y = t(ij00) where the N U(·) operator, and the second property of a valid embedding are applied j00 − j0 times. (cid:74) 14 Faster and simpler algorithms for finding large patterns in permutations 9 Miklós Bóna. A survey of stack-sorting disciplines. the electronic journal of combinatorics, combinatorics, 9(3):241 -- 244, 1988. 9(2):1, 2003. 1 References Shlomo Ahal and Yuri Rabinovich. On complexity of the subpattern problem. SIAM J. Discrete Math., 22(2):629 -- 649, 2008. 2 Michael Albert and Mireille Bousquet-Mélou. Permutations sortable by two stacks in parallel and quarter plane walks. Eur. J. Comb., 43:131 -- 164, 2015. 3 Michael H. Albert, Robert E. L. Aldred, Mike D. Atkinson, and Derek A. Holton. Algorithms for pattern involvement in permutations. In Proceedings of the 12th International Symposium on Algorithms and Computation, ISAAC '01, pages 355 -- 366, London, UK, UK, 2001. Springer- Verlag. 4 Michael H. Albert, Cheyne Homberger, Jay Pantone, Nathaniel Shar, and Vincent Vatter. Generating permutations with restricted containers. J. Comb. Theory, Ser. A, 157:205 -- 232, 2018. 5 David Arthur. Fast sorting and pattern-avoiding permutations. In Proceedings of the Fourth Workshop on Analytic Algorithmics and Combinatorics, ANALCO 2007, New Orleans, Louisi- ana, USA, January 06, 2007, pages 169 -- 174, 2007. 6 Omri Ben-Eliezer and Clément L. Canonne. Improved bounds for testing forbidden order patterns. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, January 7-10, 2018, pages 2093 -- 2112, 2018. 7 Donald J. Berndt and James Clifford. Using dynamic time warping to find patterns in time series. In Proceedings of the 3rd International Conference on Knowledge Discovery and Data Mining, AAAIWS'94, pages 359 -- 370. AAAI Press, 1994. 8 Béla Bollobás. The isoperimetric number of random regular graphs. European Journal of 10 Miklós Bóna. Combinatorics of Permutations. CRC Press, Inc., Boca Raton, FL, USA, 2004. Prosenjit Bose, Jonathan F. Buss, and Anna Lubiw. Pattern matching for permutations. Inf. 11 Process. Lett., 65(5):277 -- 283, 1998. 12 Marie-Louise Bruner and Martin Lackner. The computational landscape of permutation patterns. CoRR, abs/1301.0340, 2013. 13 Marie-Louise Bruner and Martin Lackner. A fast algorithm for permutation pattern matching based on alternating runs. Algorithmica, 75(1):84 -- 117, 2016. 14 M. B¢na. A Walk Through Combinatorics: An Introduction to Enumeration and Graph Theory. World Scientific, 2011. Laurent Bulteau, Romeo Rizzi, and Stéphane Vialette. Pattern matching for k-track per- mutations. In Costas Iliopoulos, Hon Wai Leong, and Wing-Kin Sung, editors, Combinatorial Algorithms, pages 102 -- 114, Cham, 2018. Springer International Publishing. Parinya Chalermsook, Mayank Goswami, László Kozma, Kurt Mehlhorn, and Thatchaphol Saranurak. Pattern-avoiding access in binary search trees. In IEEE 56th Annual Symposium on Foundations of Computer Science, FOCS 2015, Berkeley, CA, USA, 17-20 October, 2015, pages 410 -- 423, 2015. 15 16 17 Maw-Shang Chang and Fu-Hsing Wang. Efficient algorithms for the maximum weight clique and maximum weight independent set problems on permutation graphs. Information Processing Letters, 43(6):293 -- 295, 1992. 18 Thomas M. Cover and Joy A. Thomas. Elements of Information Theory (Wiley Series in Telecommunications and Signal Processing). Wiley-Interscience, New York, NY, USA, 2006. 19 Rodney G. Downey and Michael R. Fellows. Parameterized Complexity. Monographs in Computer Science. Springer, 1999. Fedor V. Fomin and Kjartan Høie. Pathwidth of cubic graphs and exact algorithms. Information Processing Letters, 97(5):191 -- 196, 2006. Jacob Fox. Stanley-wilf limits are typically exponential. CoRR, abs/1310.8378, 2013. 20 21 L. Kozma 15 22 23 24 25 Jacob Fox and Fan Wei. Fast property testing and metrics for permutations. Combinatorics, Probability and Computing, pages 1 -- 41, 2018. Zoltán Füredi and Péter Hajnal. Davenport-schinzel theory of matrices. Discrete Mathematics, 103(3):233 -- 251, 1992. Sylvain Guillemot and Dániel Marx. Finding small patterns in permutations in linear time. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 82 -- 101, 2014. Sylvain Guillemot and Stéphane Vialette. Pattern matching for 321-avoiding permutations. In Yingfei Dong, Ding-Zhu Du, and Oscar Ibarra, editors, Algorithms and Computation, pages 1064 -- 1073, Berlin, Heidelberg, 2009. Springer Berlin Heidelberg. 27 26 Kurt Hoffmann, Kurt Mehlhorn, Pierre Rosenstiehl, and Robert E Tarjan. Sorting jordan sequences in linear time using level-linked search trees. Information and Control, 68(1-3):170 -- 184, 1986. Louis Ibarra. Finding pattern matchings for permutations. Information Processing Letters, 61(6):293 -- 295, 1997. Eamonn J. Keogh, Stefano Lonardi, and Bill Yuan-chi Chiu. Finding surprising patterns in a time series database in linear time and space. In Proceedings of the Eighth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, July 23-26, 2002, Edmonton, Alberta, Canada, pages 550 -- 556, 2002. 29 Nancy G. Kinnersley. The vertex separation number of a graph equals its path-width. Inf. 28 Process. Lett., 42(6):345 -- 350, 1992. Sergey Kitaev. Patterns in Permutations and Words. Monographs in Theoretical Computer Science. An EATCS Series. Springer, 2011. 30 31 Martin Klazar. The füredi-hajnal conjecture implies the stanley-wilf conjecture. In Formal power series and algebraic combinatorics, pages 250 -- 255. Springer, 2000. 32 Donald E. Knuth. The Art of Computer Programming, Volume I: Fundamental Algorithms. 33 Donald E Knuth. Estimating the efficiency of backtrack programs. Mathematics of computation, Addison-Wesley, 1968. 29(129):122 -- 136, 1975. 34 Donald E Knuth. Dancing links. arXiv preprint cs/0011047, 2000. 35 Adam Marcus and Gábor Tardos. Excluded permutation matrices and the stanley-wilf conjecture. J. Comb. Theory, Ser. A, 107(1):153 -- 160, 2004. Burkhard Monien and Robert Preis. Upper bounds on the bisection width of 3- and 4-regular graphs. Journal of Discrete Algorithms, 4(3):475 -- 498, 2006. Special issue in honour of Giorgio Ausiello. 36 38 37 Both Neou, Romeo Rizzi, and Stéphane Vialette. Permutation Pattern matching in (213, 231)-avoiding permutations. Discrete Mathematics & Theoretical Computer Science, Vol. 18 no. 2, Permutation Patterns 2015, March 2017. Ilan Newman, Yuri Rabinovich, Deepak Rajendraprasad, and Christian Sohler. Testing for forbidden order patterns in an array. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 1582 -- 1597, 2017. 39 Albert Nijenhuis and Herbert S. Wilf. Combinatorial algorithms. Academic Press, Inc. [Harcourt Brace Jovanovich, Publishers], New York-London, second edition, 1978. Pranav Patel, Eamonn Keogh, Jessica Lin, and Stefano Lonardi. Mining motifs in massive time series databases. In In Proceedings of IEEE International Conference on Data Mining (ICDM'02, pages 370 -- 377, 2002. 41 Vaughan R. Pratt. Computing permutations with double-ended queues, parallel stacks and parallel queues. In Proceedings of the Fifth Annual ACM Symposium on Theory of Computing, STOC '73, pages 268 -- 277, New York, NY, USA, 1973. ACM. Pierre Rosenstiehl. Planar permutations defined by two intersecting Jordan curves. In Graph Theory and Combinatorics, pages 259 -- 271. London, Academic Press, 1984. 42 40 16 Faster and simpler algorithms for finding large patterns in permutations 43 Pierre Rosenstiehl and Robert E Tarjan. Gauss codes, planar hamiltonian graphs, and stack-sortable permutations. Journal of Algorithms, 5(3):375 -- 390, 1984. 44 Rodica Simion and Frank W. Schmidt. Restricted permutations. European Journal of Combinatorics, 6(4):383 -- 406, 1985. 45 Robert Tarjan. Sorting using networks of queues and stacks. J. ACM, 19(2):341 -- 346, April 1972. 46 Vincent Vatter. Permutation classes. In Miklós Bóna, editor, Handbook of Enumerative Combinatorics, chapter 12. Chapman and Hall/CRC, New York, 2015. Preprint at https: //arxiv.org/abs/1409.5159. 47 V. Yugandhar and Sanjeev Saxena. Parallel algorithms for separable permutations. Discrete Applied Mathematics, 146(3):343 -- 364, 2005.
1112.5741
1
1112
2011-12-24T17:23:14
Partially Symmetric Functions are Efficiently Isomorphism-Testable
[ "cs.DS", "cs.CC", "math.CO" ]
Given a function f: {0,1}^n \to {0,1}, the f-isomorphism testing problem requires a randomized algorithm to distinguish functions that are identical to f up to relabeling of the input variables from functions that are far from being so. An important open question in property testing is to determine for which functions f we can test f-isomorphism with a constant number of queries. Despite much recent attention to this question, essentially only two classes of functions were known to be efficiently isomorphism testable: symmetric functions and juntas. We unify and extend these results by showing that all partially symmetric functions---functions invariant to the reordering of all but a constant number of their variables---are efficiently isomorphism-testable. This class of functions, first introduced by Shannon, includes symmetric functions, juntas, and many other functions as well. We conjecture that these functions are essentially the only functions efficiently isomorphism-testable. To prove our main result, we also show that partial symmetry is efficiently testable. In turn, to prove this result we had to revisit the junta testing problem. We provide a new proof of correctness of the nearly-optimal junta tester. Our new proof replaces the Fourier machinery of the original proof with a purely combinatorial argument that exploits the connection between sets of variables with low influence and intersecting families. Another important ingredient in our proofs is a new notion of symmetric influence. We use this measure of influence to prove that partial symmetry is efficiently testable and also to construct an efficient sample extractor for partially symmetric functions. We then combine the sample extractor with the testing-by-implicit-learning approach to complete the proof that partially symmetric functions are efficiently isomorphism-testable.
cs.DS
cs
Partially Symmetric Functions are Efficiently Isomorphism-Testable Eric Blais∗ Amit Weinstein† Yuichi Yoshida‡ November 18, 2018 Abstract Given a function f : {0, 1}n → {0, 1}, the f -isomorphism testing problem requires a ran- domized algorithm to distinguish functions that are identical to f up to relabeling of the input variables from functions that are far from being so. An important open question in property testing is to determine for which functions f we can test f -isomorphism with a constant num- ber of queries. Despite much recent attention to this question, essentially only two classes of functions were known to be efficiently isomorphism testable: symmetric functions and juntas. We unify and extend these results by showing that all partially symmetric functions -- functions invariant to the reordering of all but a constant number of their variables -- are ef- ficiently isomorphism-testable. This class of functions, first introduced by Shannon, includes symmetric functions, juntas, and many other functions as well. We conjecture that these func- tions are essentially the only functions efficiently isomorphism-testable. To prove our main result, we also show that partial symmetry is efficiently testable. In turn, to prove this result we had to revisit the junta testing problem. We provide a new proof of correctness of the nearly-optimal junta tester. Our new proof replaces the Fourier machinery of the original proof with a purely combinatorial argument that exploits the connection between sets of variables with low influence and intersecting families. Another important ingredient in our proofs is a new notion of symmetric influence. We use this measure of influence to prove that partial symmetry is efficiently testable and also to construct an efficient sample extractor for partially symmetric functions. We then combine the sample extractor with the testing-by-implicit-learning approach to complete the proof that partially symmetric functions are efficiently isomorphism-testable. 1 1 0 2 c e D 4 2 ] S D . s c [ 1 v 1 4 7 5 . 2 1 1 1 : v i X r a ∗School of Computer Science, Carnegie Mellon University, Pittsburgh, PA, USA. Email: [email protected] †Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv, Israel. Email: [email protected]. Research supported in part by an ERC Advanced grant. ‡School of Informatics, Kyoto University and Preferred Infrastructure, Inc., Kyoto, Japan. Email: [email protected] 1 Introduction Property testing considers the following general problem: given a property P, identify the minimum number of queries required to determine with high probability whether an input has the property P or whether it is far from P. This question was first formalized by Rubinfeld and Sudan [27]. Definition 1 ([27]). Let P be a set of Boolean functions. An ǫ-tester for P is a randomized algorithm which queries an unknown function f : {0, 1}n → {0, 1} on a small number of inputs and (i) Accepts with probability at least 2/3 when f ∈ P; (ii) Rejects with probability at least 2/3 when f is ǫ-far from P, where f is ǫ-far from P if dist(f, g) := {x ∈ {0, 1}n f (x) 6= g(x)} ≥ ǫ2n holds for every g ∈ P. Goldreich, Goldwasser, and Ron [22] extended the scope of this definition to graphs and other combinatorial objects. Since then, the field of property testing has been very active. For an overview of recent developments, we refer the reader to the surveys [25, 26] and the book [21]. A notable achievement in the field of property testing is the complete characterization of graph properties that are testable with a constant number of queries [5]. An ambitious open problem is obtaining a similar characterization for properties of Boolean functions. Recently there has been a lot of progress on the restriction of this question to properties that are closed under linear or affine transformations [6, 23]. More generally, one might hope to settle this open problem for all properties of Boolean functions that are closed under relabeling of the input variables. An important sub-problem of this open question is function isomorphism testing. Given a Boolean function f , the f -isomorphism testing problem is to determine whether a function g is isomorphic to f -- that is, whether it is the same up to relabeling of the input variables -- or far from being so. A natural goal, and the focus of this paper, is to characterize the set of functions for which isomorphism testing can be done with a constant number of queries. Previous work. The function isomorphism testing problem was first raised by Fischer et al. [17]. They observed that fully symmetric functions are trivially isomorphism testable with a constant number of queries. They also showed that every k-junta, that is every function which depends on at most k of the input variables, is isomorphism testable with poly(k) queries. This bound was recently improved by Chakraborty et al. [12], who showed that O(k log k) suffice. In particular, these results imply that juntas on a constant number of variables are isomorphism testable with a constant number of queries. The first lower bound for isomorphism testing was also provided by Fischer et al. [17]. They showed that for small enough values of k, testing isomorphism to a k-linear function (i.e., a function that returns the parity of k variables) requires Ω(log k) queries.1 Following a series of recent works [20, 8, 9], the exact query complexity for testing isomorphism to k-linear functions has been determined to be Θ(min(k, n − k)). More general lower bounds for isomorphism testing were obtained by O'Donnell and the first author [10]. In particular, they showed that testing isomorphism to any k-junta that is far from being a (k−1)-junta requires Ω(log log k) queries. This lower bound gives a large family of functions for which testing isomorphism requires a super-constant number of queries. Alon et al. have shown that in fact the query complexity of testing isomorphism is Θ(n) for almost every function [4] (see also [3, 12]). 1More precisely, they showed that non-adaptive testers require Ω(√k) queries. Here and in the rest of this section, tilde notation is used to hide logarithmic factors. 1 Partially symmetric functions. As seen above, the only functions which we know are isomor- phism testable with a constant number of queries are fully symmetric functions and juntas. Our motivation for the current work was to see if we can unify and generalize the results to encompass a larger class of functions. While symmetric functions and juntas may seem unrelated, there is in fact a strong connection. Symmetric functions, of course, are invariant under any relabeling of the input variables. Juntas satisfy a similar but slightly weaker invariance property. For every k-junta, there is a set of at least n− k variables such that the function is invariant to any relabeling of these variables. Functions that satisfy this condition are called partially symmetric. Definition 2 (Partially symmetric functions). For a subset J ⊆ [n] := {1, . . . , n}, a function f : {0, 1}n → {0, 1} is J-symmetric if permuting the labels of the variables of J does not change the function. Moreover, f is called t-symmetric if there exists J ⊆ [n] of size at least t such that f is J-symmetric. Shannon first introduced partially symmetric functions as part of his investigation on the circuit complexity of Boolean functions [28]. He showed that while most functions require an exponential number of gates to compute, every partially symmetric function can be implemented much more efficiently. Research on the role of partial symmetry in the complexity of implementing functions in circuits, binary decision diagrams, and other models has remained active ever since [13, 24]. Our results suggest that studying partially symmetric functions may also yield greater understanding of property testing on Boolean functions. Our results. The set of partially symmetric functions includes both juntas and symmetric func- tions, but the set also contains many other functions as well. A natural question is whether this entire class of functions is isomorphism testable with a constant number of queries. Our first main result gives an affirmative answer to this question. Theorem 1. For every (n − k)-symmetric function f : {0, 1}n → {0, 1} there exists an ǫ-tester for f -isomorphism that performs O(k log k/ǫ2) queries. A simple modification of an argument in Alon et al. [4] can be used to show that the bound in the above theorem is tight up to logarithmic factors. Indeed by this argument, testing isomorphism to almost every (n − k)-symmetric function requires Ω(k) queries. We believe that the theorem might also be best possible in a different way. That is, we conjecture that the set of partially symmetric functions is essentially the set of functions for which testing isomorphism can be done with a constant number of queries. We discuss this conjecture with some supporting evidence in Section 6. The proof of our first main theorem follows the general outline of the proof that isomorphism testing to juntas can be done in a constant number of queries. The observation which allows us to make this connection is the fact that partially symmetric functions can be viewed as junta-like functions. More precisely, an (n − k)-symmetric function is a function that has k special variables where for each assignment for these variables, the restricted function is fully symmetric on the remaining n − k variables. The proof for testing isomorphism of juntas has two main components. The first is an efficient junta testing algorithm. This enables us to reject functions that are far from being juntas. The second is a query efficient sampler of the "core" of the input function given that the function is close to a junta. The sampler can then be used in order to verify if the two juntas are indeed isomorphic. We generalize both of these components for partially symmetric functions. Our second main result, and the first component of the isomorphism tester, is an efficient algorithm for testing partial symmetry. 2 Theorem 2. The property of being (n − k)-symmetric for k < n/10 is testable with O( k queries. ǫ log k ǫ ) The natural approach for proving this theorem is to try generalize the result on junta testing in [7]. That result heavily relied on the notion of influence of variables. The influence of a set S of variables in a function f is the probability that f (x) 6= f (y) when x is chosen uniformly at random and y is obtained from x by re-randomizing the values of xi for each i ∈ S. The notion of influence characterizes juntas: when f is a k-junta, there is a set of size n − k whose influence is 0, whereas when f is ǫ-far from being a k-junta, every set of size n − k has influence at least ǫ. We introduce a different notion of influence which we call symmetric influence. The symmetric influence of a set S of variables in f is the probability that f (x) 6= f (y) when x is chosen uniformly at random and y is obtained from x by permuting the values of {xi}i∈S. This notion characterizes partially symmetric functions and satisfies several other useful properties. We provide the details in Section 3. The proof of junta testing also relies on nice properties of the Fourier representation of the notion of influence. While symmetric influence has a clean Fourier representation, unfortunately it does not have the properties needed to carry over the proof in [7] to the setting of partially symmetric functions. Instead, we must come up with a new proof technique. Our proof of Theorem 2 uses a new connection to intersecting families. A family F of subsets of [n] is t-intersecting if for every pair of sets S, T ∈ F, their intersection size is at least S ∩ T ≥ t. This notion was introduced by Erdos, Ko, and Rado and a sequence of works led to the complete characterization of the maximum size of t-intersecting families that contain sets of fixed size [16, 18, 30, 2]. Dinur, Safra, and Friedgut recently extended those results to give bounds on the biased measure of intersecting families [15, 19]. Using results in intersecting families, we obtain a new and improved proof for the main lemma at the heart of the junta testing result [7]. We describe the new proof and the connection to intersecting families in Section 2. Most importantly, the same technique can also be extended to complete the proof of Theorem 2. We present this proof in Section 4. The second and final component of the isomorphism test for partially symmetric functions is an efficient way to sample the core of such functions. An (n − k)-symmetric function f , which is symmetric over a set J ⊆ [n] of size J = n − k, has a concise representation as a function fcore : {0, 1}k × {0, 1, . . . , n − k} → {0, 1} which we call the core of f . The core is the restriction of f to the variables in J (in the natural order), with the additional Hamming weight of the variables in J. To determine if two partially symmetric functions are isomorphic, it suffices to determine whether their cores are isomorphic. We do so with the help of an efficient sample extractor. Definition 3. A (1 query) δ-sampler for the (n − k)-symmetric function f : {0, 1}n → {0, 1} is a randomized algorithm that queries f on a single input and returns a triplet (x, w, z) ∈ {0, 1}k × {0, 1, . . . , n − k} × {0, 1} where • The distribution of (x, w) is δ-close, in total variation distance, to x being uniform over {0, 1}k and w being binomial over {0, 1, . . . , n − k} independently, and • z = fcore(x, w) with probability at least 1 − δ. Our third main result is that for any (n − k)-symmetric function f , there is a query-efficient algorithm for constructing a δ-sampler for f . Theorem 3. Let f : {0, 1}n → {0, 1} be (n − k)-symmetric with k < n/10. There is an algorithm that queries f on O( k ηδ ) inputs and with probability at least 1 − η outputs a δ-sampler for f . ηδ log k 3 This theorem is a generalization of a recent result of Chakraborty et al. [11], who gave a similar construction for sampling the core of juntas. Their result has many applications related to testing by implicit learning [14]. Our result may be of independent interest for similar such applications. We elaborate on this topic and present the proof of Theorem 3 in Section 5. 2 Intersecting families and testing juntas We begin by revisiting the problem of junta testing. In this section, we give a new proof of the correctness of the k-junta tester first introduced in [7]. At a high level, the junta tester is quite simple: it partitions the set of indices into a large enough number of parts, then tries to identify all the parts that contain a relevant variable. If at most k such parts are found, the test accepts; otherwise it rejects. The algorithm is described in Junta-Test. (See [7] for more details.) Algorithm 1 Junta-Test(f, k, ǫ) 1: Create a random partition I of the set [n] into r = Θ(k2) parts, and initialize J = ∅. 2: for each i = 1 to Θ(k/ǫ) do 3: Sample x, y ∈ {0, 1}n uniformly at random. if f (x) 6= f (xJ yJ ) then 4: 5: 6: 7: 8: Accept. Use binary search to find a set I ∈ I that contains a relevant variable. Set J := J ∪ I. if J is the union of > k parts then reject. It is clear that the Junta-Test always accepts k-juntas. The non-trivial part of the analysis involves showing that functions that are far from k-juntas are rejected by the tester with sufficiently high probability. To do so, we must argue that the inequality in Step 4 is satisfied with non- negligible probability whenever f is far from k-juntas and J is the union of at most k parts. This is accomplished by considering the influence of variables in a function. The influence of the set J ⊆ [n] of variables in the function f : {0, 1}n → {0, 1} is Inff (J) = Pr x,y [f (x) 6= f (xJ yJ )] , where xJ yJ is the vector z ∈ {0, 1}n obtained by setting zi = yi for every i ∈ J and zi = xi for every i ∈ [n] \ J. By definition, the probability that the inequality in Step 4 is satisfied is exactly Inff (J). To complete the analysis of correctness of the algorithm, we want to show that when f is ǫ-far from k-juntas with high probability over the choice of the random partition I, if J is the union of at most k parts in I, then Inf(J ) ≥ ǫ 4 . We do so by exploiting only a couple basic facts about the notion of influence. Lemma 1 (Fischer et al. [17]). For every f : {0, 1}n → {0, 1} and every J, K ⊆ [n], Inff (J) ≤ Inf f (J ∪ K) ≤ Inff (J) + Inf f (K) . Furthermore, if f is ǫ-far from k-juntas and J ≤ k, then Inff (J) ≥ ǫ. We also use the fact that the family of sets J ⊆ [n] whose complements have small influence form an intersecting family. For a fixed t ≥ 1, a family F of subsets of [n] is called t-intersecting if any two sets J and K in F have intersection size J ∩ K ≥ t. Much of the work in this area focused on bounding the size of t-intersecting families that contain only sets of a fixed size. Dinur and Safra [15] 4 considered general families and asked what the maximum p-biased measure of such families can be. For 0 < p < 1, this measure is defined as µp(F) := PrJ [J ∈ F] where the probability over J is obtained by including each coordinate i ∈ [n] in J independently with probability p. They showed that 2-intersecting families have small p-biased measure [15] and Friedgut showed how the same result also extends to t-intersecting families for t > 2 [19]. Theorem 4 (Dinur and Safra [15]; Friedgut [19]). Let F be a t-intersecting family of subsets of [n] for some t ≥ 1. For any p < 1 t+1 , the p-biased measure of F is bounded by µp(F) ≤ pt. We are now ready to complete the analysis of Junta-Test. Lemma 2. Let f : {0, 1}n → {0, 1} be a function ǫ-far from k-juntas and I be a random partition of [n] into r = c · k2 parts, for some large enough constant c. Then with probability at least 5/6, Inff (J) ≥ ǫ/4 for any union J of k parts from I. Proof. For 0 ≤ t ≤ 1 2 , let Ft = {J ⊆ [n] : Inff (J) < tǫ} be the family of all sets whose complements have influence at most tǫ. For any two sets J, K ∈ F1/2, the sub-additivity of influence implies that Inf f (J ∩ K) = Inff (J ∪ K) ≤ Inff (J) + Inff (K) < 2 · 1 2 ǫ = ǫ . But f is ǫ-far from k-juntas, so every set S ⊆ [n] of size S ≤ k satisfies Inff (S) ≥ ǫ. Therefore, J ∩ K > k and, since this argument applies to every pair of sets in the family, F1/2 is a (k + 1)- intersecting family. Let us now consider two separate cases: when F1/2 contains a set of size less than 2k; and when it does not. In the first case, let J ∈ F1/2 be one of the sets of size J < 2k. With high probability, the set J is completely separated by the partition I. When this event occurs, then for every other set K ∈ F1/2, J ∩ K ≥ k + 1, which means that K is not covered by any union of k parts in I. Therefore, with high probability f is ǫ 4 -far) from k-part juntas with respect to I, as we wanted to show. Consider now the case where F1/2 contains only sets of size at least 2k. Then we claim that F1/4 is a 2k-intersecting family: otherwise, we could find sets J, K ∈ F1/4 such that J ∩ K < 2k and Inff (J ∩ K) ≤ Inff (J) + Inff (K) < ǫ Let J ⊆ [n] be the union of k parts in I. Since I is a random partition, J is a random subset obtained by including each element of [n] in J independently with probability p = k 2k+1 . By Theorem 4, 2 , contradicting our assumption. 2 -far (and thus also ǫ r < 1 [Inf f (J ) < ǫ 4 ] = Pr[J ∈ F1/4] = µk/r(F1/4) ≤ (k/r)2k . Pr I Applying the union bound over the possible choices of J, we get that f is ǫ with respect to I with probability at most 4 -close to a k-part junta (cid:18)r k(cid:19)(cid:18) k r(cid:19)2k k(cid:17)k(cid:18) k r(cid:19)2k ≤(cid:16) er ≤(cid:18) ek r (cid:19)k = O(k−k) . 3 Symmetric influence The main focus of this paper is partially symmetric functions, that is, functions invariant under any reordering of the variables of some set J ⊆ [n]. Let SJ denote the set of permutations of [n] which only move elements from the set J. A function f : {0, 1}n → {0, 1} is J-symmetric if f (x) = f (πx) for every input x and a permutation π ∈ SJ , where πx is the vector whose π(i)-th coordinate is xi. For better analyzing partially symmetric functions, we introduce a new measure named symmet- ric influence. The symmetric influence of a set measures how invariant the function is to reordering of the elements in that set. 5 Definition 4 (Symmetric influence). The symmetric influence of a set J ⊆ [n] of variables in a Boolean function f : {0, 1}n → {0, 1} is defined as Pr SymInff (J) = x∈{0,1}n,π∈SJ [f (x) 6= f (πx)] . It is not hard to see that in fact a function f is t-symmetric iff there exists a set J of size t such that SymInff (J) = 0. A much stronger connection, however, exists between these properties as we will shortly describe. Before showing some nice properties of symmetric influence, we mention that it also has a simple representation using Fourier coefficients of the function. Although we do not use the representation in this paper, we feel it might be of independent interest. See Appendix A.1 for details. Lemma 3. Given a function f : {0, 1}n → {0, 1} and a subset J ⊆ [n], let fJ be the J-symmetric function closest to f . Then, the symmetric influence of J satisfies dist(f, fJ ) ≤ SymInff (J) ≤ 2 · dist(f, fJ ) . Proof. For every weight 0 ≤ w ≤ n and z ∈ {0, 1}J, define the layer Lw := {x ∈ {0, 1}n x = w ∧ xJ = z} to be the vectors of Hamming weight w which identify with z over the set J (where J←z =(cid:0) Jw−z(cid:1) if z ≤ w ≤ J +z or 0 otherwise). Let pw Lw 2 ] be the fraction of the vectors in Lw J←z With these notations, we can restate the definition of the symmetric influence of J as follows. one has to modify in order to make the restriction of f over Lw z ∈ [0, 1 constant. J←z J←z SymInff (J) = Xz Xw 2nXz Xw = 1 Pr [x ∈ Lw x∈{0,1}n Lw J←z · 2pw J←z] · z (1 − pw z ) . Pr x∈{0,1}n,π∈SJ [f (x) 6= f (πx) x ∈ Lw J←z] This holds as in each such layer, the probability that x and πx would result in two different outcomes is the probability that x would be chosen out of the smaller part and πx from the complement, or vise versa. The function fJ can be obtained by modifying f at pw , J←z as each layer can be addressed separately and we want to modify as few inputs as possible. By this observation, we have the following equality. z fraction of the inputs in each layer Lw dist(f, fJ ) = Lw J←z · pw z . z ∈ [ 1 z (1 − pw z ) ≤ 2pw 2 , 1], we have that pw But since 1 − pw SymInff (J) ≤ 2 · dist(f, fJ ) as required. Corollary 1. Let f : {0, 1}n → {0, 1} be a function that is ǫ-far from being t-symmetric. Then for every set J ⊆ [n] of size J ≥ t, SymInff (J) ≥ ǫ holds. Proof. Fix J ⊆ [n] of size J ≥ t and let g be a J-symmetric function closest to f . Since g is symmetric on any subset of J, it is in particular t-symmetric and therefore dist(f, g) ≥ ǫ as f is ǫ-far from being t-symmetric. Thus, by Lemma 3, SymInff (J) ≥ dist(f, g) ≥ ǫ holds. z and therefore dist(f, fJ ) ≤ 1 2nXz Xw z ≤ 2pw 6 Corollary 1 demonstrates the strong connection between symmetric influence and the distance from being partially symmetric, similar to the second part of Lemma 1 for influence and juntas. The additional properties of influence used in Section 2 are monotonicity and sub-additivity (Lemma 1). The following lemmas show that the same properties (approximately) hold for symmetric influence. See Appendices A.2 and A.3 for the proofs of both lemmas. Lemma 4 (Monotonicity). For any function f : {0, 1}n → {0, 1} and any sets J ⊆ K ⊆ [n], SymInff (J) ≤ SymInff (K) . Lemma 5 (Weak sub-additivity). There is a universal constant c such that, for any constant 0 < γ < 1, a function f : {0, 1}n → {0, 1}, and sets J, K ⊆ [n] of size at least (1 − γ)n, SymInff (J ∪ K) ≤ SymInff (J) + SymInff (K) + c√γ . 4 Testing partial symmetry Let us now return to the problem of testing partial symmetry. The goal of this section is to introduce an efficient tester for this property by combining the ideas from Sections 2 and 3. We begin by introducing the testing algorithm Partially-Symmetric-Test. This algorithm is conceptually very similar to the junta tester in Section 2. Again, the main idea is to partition the variables into O(k2) parts and identify the parts that contain "asymmetric" variables. More precisely, given a function f : {0, 1}n → {0, 1}, let us write core(f ) ⊆ [n] to be the maximum set J of variables such that f is J-symmetric. We call the variables in core(f ) symmetric and the variables in [n] \ core(f ) are called asymmetric. The function is (n − k)-symmetric iff it contains at most k asymmetric variables. The algorithm exploits this characterization by trying to identify k + 1 parts that contain asymmetric variables. Algorithm 2 Partially-Symmetric-Test(f, k, ǫ) 1: Create a random partition I of [n] into r = Θ(k2/ǫ2) parts, and initialize J := ∅. 2: Pick a random workspace W ∈ I, and if W < n 3: for each i = 1 to Θ(k/ǫ) do Let I := Find-Asymmetric-Set(f,I, J, W ). 4: if I 6= ∅ then 2r then fail. Set J := J ∪ I. if J is the union of > k parts then reject. 5: 6: 7: 8: Accept. There are two main differences in the analysis of Partially-Symmetric-Test and of Junta- Test in Section 2. The first is that we can no longer use a simple binary search algorithm to identify the parts that contain asymmetric variables, as we need to maintain the Hamming weight of our queries. To overcome this challenge, we introduce the Find-Asymmetric-Set function, which satisfies the following properties. Lemma 6. Let f be a function, I be a partition of [n] into r parts, W ∈ I,W ≥ n 2r be a workspace, and J be a union of parts from I \ {W}. Then, there exists an algorithm Find-Asymmetric- Set(f,I, J, W ) which performs O(log r) queries such that • With probability SymInff (J), the algorithm returns a set I ∈ I \{W} disjoint to J; otherwise it returns ∅. 7 • If W has no asymmetric variable and I ∈ I is returned, then I has an asymmetric variable. Due to space constraints, we provide a rough sketch of the algorithm and defer the details and analysis to Appendix B.1. Find-Asymmetric-Set generates a random pair of x ∈ {0, 1}n and π ∈ SJ and checks whether f (x) 6= f (πx). When this occurs, which happens with probability at least ǫ when SymInff (J ) ≥ ǫ, we know there exists some asymmetric variable in J. In order to identify a part I ∈ I, disjoint to J and the workspace W , which contains an asymmetric variable we iteratively change x to πx. In each step, we only permute bits in one part I ∈ I and the workspace W . Since f (x) 6= f (πx), we can find using binary search a set I, disjoint to J, such that permuting bits in I ∪ W changes the value of f . By our assumption, W has no asymmetric variables and therefore I must contain such a variable. The second and more important challenge in the analysis of Partially-Symmetric-Test is the use of symmetric influence (rather than influence). Similar to Lemma 2 for influence, we prove that if a function is far from being (n − k)-symmetric, then it is also far from being symmetric on any union of all but k parts of a random partition (assuming it has enough parts). The formal statement is given in Lemma 7, where its proof follows a very similar technique to that of Lemma 2. Lemma 7. Let f : {0, 1}n → {0, 1} be a function ǫ-far from (n− k)-symmetric and I be a random partition of [n] into r = c · k2/ǫ2 parts, for some large enough constant c. Then with probability at least 8/9, SymInff (J ) ≥ ǫ 9 holds for any union J of k parts. The main difference between this proof and the one of Lemma 2 arises from the weak sub- additivity of symmetric influence. In light of this difference, our definition of families of sets whose complement has small symmetric influence includes only sets which are not too big. We use the observation that adding sets which contain elements of a family does not change its existing intersection. In addition, due to the additive factor of the sub-additivity we prove a slightly weaker result where the symmetric influence is at least ǫ/9 and not ǫ/4. The complete proof of Lemma 7 is deferred to Appendix B.2. We can now complete the proof that partial symmetry is efficiently testable. Proof of Theorem 2. Note that W ≥ n bound. By Lemma 6, Find-Asymmetric-Set performs O(log k of r, and therefore the query complexity of Partially-Symmetric-Test is O( k 2r indeed holds with probability at least 8/9 from Chernoff ǫ ) queries according to our choice ǫ log k ǫ ). Suppose f is an (n − k)-symmetric function. The probability that W contains an asymmetric variable is at most k/r ≤ 2/9. Conditioned this did not occur, every set returned by Find- Asymmetric-Set contains an asymmetric variable. Since there are at most k such variables, J would be the union of at most k sets and we would accept. Suppose f is a function ǫ-far from being (n − k)-symmetric. From Lemma 7, with probability at least 8/9, SymInff (J) ≥ ǫ/9 holds while J consists of at most k parts. Conditioned on that, by executing Find-Asymmetric-Set O(k/ǫ) times we obtain more than k parts with probability at least 8/9, according to Lemma 6. Thus, we reject with probability at least 2/3. 5 Isomorphism testing of partially symmetric functions In this section we prove that isomorphism testing of partially symmetric functions can be done with a constant number of queries. The algorithm we describe consists of two main components, and follow a similar approach to the one used in [12] when they showed juntas are isomorphism testable. The first, which we already described in Section 4, is an efficient tester for the property 8 of being partially symmetric. Once we know the input function is indeed close to being partially symmetric, we can verify it is isomorphic (or at least very close) to the correct one. The second component of the algorithm is therefore an efficient sampler from the core of a function which is (close to) partially symmetric. Comparing the cores of two partially symmetric functions suffices to identify if two such functions are isomorphic or far from it. Ideally, when sampling the core of a partially symmetric function f , we would like to sample it according to the marginal distribution of sampling f at a uniform input x ∈ {0, 1}n. We denote this marginal distribution over {0, 1}k × {0, 1, . . . , n − k} by D∗k,n, which is in fact uniform over {0, 1}k and binomial over {0, 1, . . . , n − k}, independently. In our scenario, sampling the core of a function according to this distribution is not possible since we do not know the exact location of all the k asymmetric variables. Instead, we use the knowledge discovered by the partial symmetry tester, i.e., sets with asymmetric variables. Given these sets, we are able to define a sampling distribution over {0, 1}n such that we know the input of the core for each query, and whose marginal distribution over the core is close enough to D∗k,n. Definition 5. Let I be some partition of [n] into an odd number of parts and let W ∈ I be the workspace. Define the distribution DW I over {0, 1}n to be as follows. Pick a random Hamming weight w according to the binomial distribution over {0, . . . , n} and output, if exists, a random x ∈ {0, 1}n of Hamming weight x = w such that for every I ∈ I \ {W}, either xI ≡ 0 or xI ≡ 1. When no such x exists, return the all zeros vector. The sampling distribution which we just defined, together with the random choice of the par- tition and workspace, satisfies the following two important properties. The first, being close to uniform over the inputs of the function. The second, having a marginal distribution over the core of a partially symmetric function close to D∗k,n. These properties are formally written here as Proposition 1, whose proof is rather technical and appears in Appendix C.1. Proposition 1. Let J = {j1, . . . , jk} ⊆ [n] be a set of size k, and r = Ω(k2) be odd. If x ∼ DW I for a random partition I of [n] into r parts and a random workspace W ∈ I, then • x is o(1/n)-close to being uniform over {0, 1}n, and • (xJ ,xJ) is c/k-close to being distributed according to D∗k,n, for our choice of 0 < c < 1. We are now ready to describe the algorithm for isomorphism testing of (n − k)-symmetric functions. Given an (n − k)-symmetric function f , the algorithm tests whether the input function g is isomorphic to f or ǫ-far from being so. Algorithm 3 Partially-Symmetric-Isomorphism-Test(f, k, g, ǫ) 1: Perform Partially-Symmetric-Test(g, k, ǫ/1000) and reject if failed. 2: Let I and W ∈ I be the partition and workspace used by the algorithm. 3: Let J be the union of the k parts identified by the algorithm. 4: for each i = 1 to Θ(k log k/ǫ2) do 5: Query g(x) at a random x ∼ DW I 6: Accept iff (1− ǫ/2)-fraction of the queries are consistent with some isomorphism fπ of f , which maps the asymmetric variables of f into all k parts of J. We provide here a sketch of the analysis of the algorithm. See Appendix C.2 for the formal analysis and complete proof of Theorem 1. The first case to analyze is when g is rejected by Partially-Symmetric-Test, which implies that with good probability it is not (n−k)-symmetric and in particular not isomorphic to f . Assume now that Partially-Symmetric-Test did not 9 reject and therefore g is likely to be ǫ/1000-close to being (n − k)-partially symmetric. Let I, W and J be the partition, workspace and union of k parts identified by the algorithm. The main idea of the proof is showing that with good probability, there exists a function h that (a) is ǫ/250-close to g, and (b) is (n − k)-symmetric with asymmetric variables contained in J and separated by I. We prove the existence of this function h using the properties of symmetric influence presented in Section 4. Assuming such h exists, we use Proposition 1 in order to show that our queries to g, according to the sampling distribution, are in fact ǫ/10-close to querying h's core. We now consider the following two cases. If g is isomorphic to f , then for some isomorphism fπ of f , which maps the asymmetric variables of f into the parts of J, it holds that dist(fπ, h) ≤ dist(fπ, g) + dist(g, h) ≤ ǫ/500 + ǫ/250. Notice that we cannot assume that g = fπ as it is possible that one of the asymmetric variables of g are not in J (but the distance must be small). If g was ǫ-far from being isomorphic to f , then for every isomorphism fπ of f , dist(fπ, h) ≥ dist(fπ, g) − dist(g, h) ≥ ǫ − ǫ/250 . Given that there are only k! isomorphisms of f we need to consider, performing Θ(k log k/ǫ2) queries suffices for returning the correct answer in both cases, with good probability. As we outlined above, we in fact build an efficient sampler for the core of (n − k)-symmetric functions (or functions close to being so). Given the parts identified by Partially-Symmetric- Test, assuming it did not reject, we can sample the function's core by querying it at a single location, where the distribution over the core's inputs is close to D∗k,n. The algorithm and proof of Theorem 3 are deferred to Appendix C.3. 6 Discussion We showed that every partially symmetric function is isomorphism testable with a constant number of queries. It's easy to see that functions that are "close" to partially symmetric can also be isomorphism-tested with a constant number of queries. We believe that our result not only unifies the previous classes of functions efficiently isomorphism-testable, but that it includes essentially all of these functions. Conjecture 1. Let f : {0, 1}n → {0, 1} be ǫ-far from (n − k)-symmetric. Then testing f - isomorphism requires at least Ω(log log k) queries. In fact, we believe that more is true -- perhaps even Ω(k) queries are required. But the weaker bound (or, indeed, any function that grows with k) is sufficient to complete the qualitative charac- terization of functions that are isomorphism-testable with a constant number of queries. The known hardness results on isomorphism testing are all consistent with Conjecture 1. In particular, by the result in [4], we know that testing f -isomorphism requires at least Ω(k) queries for almost all functions f that are ǫ-far from (n − k)-symmetric. A simple extension of the proof in [10] shows that for every (n − k)-symmetric function f that is ǫ-far from (n − k + 1)-symmetric, testing f -isomorphism requires Ω(log log k) queries (assuming k/n is bounded away from 1). Lastly, let us consider another natural definition of partial symmetry that encompasses both symmetric functions and juntas. The function f : {0, 1}n → {0, 1} is k-part symmetric if there is a partition I = {I1, . . . , Ik} of [n] such that f is invariant under any permutation π of [n] where π(Ii) = Ii for every i = 1, . . . , k. One may be tempted to guess that k-part symmetric functions are efficiently isomorphism-testable. That is not the case, even when k = 2. To see this, consider the function f (x) = x1 ⊕ x2 ⊕ ··· ⊕ xn/2. This function is 2-part symmetric, but testing isomorphism to f requires Ω(n) queries [8]. 10 Acknowledgments We thank Noga Alon, Per Austrin, Irit Dinur, Ehud Friedgut, and Ryan O'Donnell for useful discussions and valuable feedback. References [1] Jos´e A. Adell and Pedro Jodr´a. Exact Kolmogorov and total variation distances between some familiar discrete distributions. Journal of Inequalities and Applications, 2006. [2] Rudolf Ahlswede and Levon H. Khachatrian. The complete intersection theorem for systems of finite sets. European Journal of Combinatorics, 18:125 -- 136, 1997. [3] Noga Alon and Eric Blais. Testing boolean function isomorphism. Proc. 14th International Workshop on Randomization and Approximation Techniques in Computer Science, pages 394 -- 405, 2010. [4] Noga Alon, Eric Blais, Sourav Chakraborty, David Garc´ıa-Soriano, and Arie Matsliah. Nearly tight bounds for testing function isomorphism, 2011. manuscript. [5] Noga Alon, Eldar Fischer, Ilan Newman, and Asaf Shapira. A combinatorial characterization It's all about regularity. SIAM Journal on Computing, of the testable graph properties: 39:143 -- 167, 2009. [6] Arnab Bhattacharyya, Elena Grigorescu, and Asaf Shapira. A unified framework for testing linear-invariant properties. In Proc. 51st Annual IEEE Symposium on Foundations of Com- puter Science (FOCS), pages 478 -- 487, 2010. [7] Eric Blais. Testing juntas nearly optimally. In Proc. 41st Annual ACM Symposium on Theory of Computing (STOC), pages 151 -- 158, 2009. [8] Eric Blais, Joshua Brody, and Kevin Matulef. Property testing lower bounds via communica- tion complexity. In Proc. 26th Annual IEEE Conference on Computational Complexity (CCC), pages 210 -- 220, 2011. [9] Eric Blais and Daniel Kane. Testing linear functions, 2011. manuscript. [10] Eric Blais and Ryan O'Donnell. Lower bounds for testing function isomorphism. In Proc. 25th Conference on Computational Complexity (CCC), pages 235 -- 246, 2010. [11] Sourav Chakraborty, David Garc´ıa-Soriano, and Arie Matsliah. Efficient sample extractors for juntas with applications. Automata, Languages and Programming, pages 545 -- 556, 2011. [12] Sourav Chakraborty, David Garc´ıa-Soriano, and Arie Matsliah. Nearly tight bounds for testing function isomorphism. In Proc. 22nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1683 -- 1702, 2011. [13] S.R. Das and C.L. Sheng. On detecting total or partial symmetry of switching functions. IEEE Trans. on Computers, C-20(3):352 -- 355, 1971. [14] I. Diakonikolas, H.K. Lee, K. Matulef, K. Onak, R. Rubinfeld, R.A. Servedio, and A. Wan. Testing for concise representations. In Proc. 48th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 549 -- 558, 2007. 11 [15] Irit Dinur and Shmuel Safra. On the hardness of approximating minimum vertex cover. Annals of Mathematics, 162(1):439 -- 485, 2005. [16] Paul Erdos, Chao Ko, and Richard Rado. Intersection theorems for systems of finite sets. The Quarterly Journal of Mathematics, 12(1):313 -- 320, 1961. [17] Eldar Fischer, Guy Kindler, Dana Ron, Shmuel Safra, and Alex Samorodnitsky. Testing juntas. Journal of Computer and System Sciences, 68(4):753 -- 787, 2004. [18] Peter Frankl. The Erdos-Ko-Rado theorem is true for n = ckt. In Combinatorics (Proc. Fifth Hungarian Colloquium, Keszthely), volume 1, pages 365 -- 375, 1976. [19] Ehud Friedgut. On the measure of intersecting families, uniqueness and stability. Combina- torica, 28(5):503 -- 528, 2008. [20] Oded Goldreich. On testing computability by small width OBDDs. Proc. 14th International Workshop on Randomization and Approximation Techniques in Computer Science, pages 574 -- 587, 2010. [21] Oded Goldreich, editor. Property Testing: Current Research and Surveys, volume 6390 of LNCS. Springer, 2010. [22] Oded Goldreich, Shafi Goldwasser, and Dana Ron. Property testing and its connection to learning and approximation. Journal of the ACM, 45(4):653 -- 750, 1998. [23] Tali Kaufman and Madhu Sudan. Algebraic property testing: the role of invariance. In Proc. 40th Annual ACM Symposium on Theory of Computing (STOC), pages 403 -- 412, 2008. [24] Christoph Meinel and Thorsten Theobald. Algorithms and Data Structures in VLSI Design. Springer, 1998. [25] Dana Ron. Algorithmic and analysis techniques in property testing. Foundations and Trends in Theoretical Computer Science, 5:73 -- 205, 2010. [26] Ronitt Rubinfeld and Asaf Shapira. Sublinear time algorithms. Electronic Colloquium on Computational Complexity (ECCC), 18, 2011. TR11-013. [27] Ronitt Rubinfeld and Madhu Sudan. Robust characterizations of polynomials with applications to program testing. SIAM Journal on Computing, 25(2):252 -- 271, 1996. [28] Claude E. Shannon. The synthesis of two-terminal switching circuits. Bell System Technical Journal, 28(1):59 -- 98, 1949. [29] Spario Y. T. Soon. Binomial approximation for dependent indicators. Statistica Sinica, 6:703 -- 714, 1996. [30] Richard M. Wilson. The exact bound in the Erdos-Ko-Rado theorem. Combinatorica, 4(2 -- 3):247 -- 257, 1984. 12 A Properties of symmetric influence A.1 Fourier representation of symmetric influence For convenience, we consider functions whose ranges are {−1, 1} instead of {0, 1}. Then, the symmetric influence of a function can be expressed as follows. Proposition 2. Given a Boolean function f : {0, 1}n → {−1, 1} and a set J ⊆ [n], the symmetric influence of J with respect to f can also be computed as SymInff (J) = 1 2 XS⊆[n] Var π∈SJ [bf (πS)] where bf (S) is the Fourier coefficient of f for the set S ⊆ [n], and πS = {π(i) i ∈ S}. The proposition indicates that the symmetric influence of any set J can be computed as a function of the variance of the Fourier coefficients of the function in the different layers. Each layer here refer to all the Fourier coefficients of sets which share the intersection with [n] \ J and the intersection size with J, resulting in (J + 1)2n−J different layers. The key to proving this proposition is the following basic result on linear functions. Recall that for a set S ⊆ [n], the function χS : {0, 1}n → {−1, 1} is defined by χS(x) = (−1)Pi∈S xi. Lemma 8. Fix J, S, T ⊆ [n]. Then [χS(x) · χT (πx)] =((cid:0) J S∩J(cid:1)−1 0 E x∈{0,1}n,π∈SJ if ∃π ∈ SJ , πS = T otherwise. Proof. For any vector x ∈ {0, 1}n, any set S ⊆ [n], and any permutation π ∈ Sn, we have the identity χS(πx) = χπ−1S(x). So E x∈{0,1}n,π∈SJ [χS(x) · χT (πx)] = E x,π [χS(x)χπ−1T (x)] = E π(cid:20)E x [χS(x)χπ−1T (x)](cid:21) . But Ex[χS(x)χπ−1T (x)] = 1[S = π−1T ], so we also have E x∈{0,1}n,π∈SJ [χS(x) · χT (πx)] = Pr π∈SJ [S = π−1T ] = Pr π∈SJ [πS = T ] . The identity πS = T holds iff the permutation π satisfies π(i) ∈ T for every i ∈ S. Since we only permute elements from J, the sets S and T must agree on the elements of [n] \ J. If this is not the case, or if the intersection of the sets with J is not of the same size, no such permutation exists. Otherwise, this event occurs if the elements of S ∩ J are mapped to the exact locations of T ∩ J. This holds for one out of the(cid:0) J S∩J(cid:1) possible sets of locations, each with equal probability. Proof of Proposition 2. By appealing to the fact that f is {−1, 1}-valued, we have that Pr x,π [f (x) 6= f (πx)] = 1 4 E x,π [f (x)2 + f (πx)2 − 2f (x)f (πx)]. Applying linearity of expectation and Parseval's identity, we obtain E x,π [f (x)2 + f (πx)2 − 2f (x)f (πx)] = 2 XS⊆[n] f (S)2 − 2 XS,T⊆[n] f (S) f (T ) E x,π [χS(x)χT (πx)] . 13 Fix any S ⊆ [n]. By Lemma 8, XT⊆[n] f (T ) E x,π Given this equality, f (πS) [χS(x)χT (πx)] = Xπ∈SJ π∈SJ S∩J(cid:1) = E (cid:0) J [χS(x)χT (πx)] =XS f (S) E π∈SJ [ f (πS)] . [ f (πS)] . XS,T⊆[n] f (S) f (T ) E x,π By applying some elementary manipulation, we now get Pr x,π [f (x) 6= f (πx)] = = f (S)(cid:18) f (S) − E [ f (πS)2] − E (E π π π [ f (πS)](cid:19) = [ f (πS)]2) = 1 2XS 2XS 1 1 2XS [ f (πS)] . Var π A.2 Monotonicity of symmetric influence Lemma 4 (Restated). For any function f : {0, 1}n → {0, 1} and any sets J ⊆ K ⊆ [n], SymInff (J) ≤ SymInff (K) . Proof. Fix a function f and two sets J, K ⊆ [n] so that J ⊆ K. We have seen before that the symmetric influence can be computed in layers, where each layer is determined by the Hamming weight and the elements outside the set we are considering. Using the fact that Var(X) = Pr[X = 0]·Pr[X = 1], the symmetric influence is twice the expected variance over all the layers (considering also the size of the layers). Using the same notation as before, SymInff (J) = 1 2nXz Xw yhVar x = 2 · E x Lw J←z · 2 Var [f (x) x ∈ Ly [f (x) x ∈ Lw ]i . J←yJ J←z] A key observation is that since K ⊆ J, the layers determined when considering J are a refine- ment of the layers determined when considering K. Together with the fact that Var(X) = Pr[X = 0]·Pr[X = 1] is a concave function in the range [0, 1], we can apply Jensen's inequality on each layer before and after the refinement to get the desired inequality. More precisely, for every z ∈ {0, 1}K and 0 ≤ w ≤ n, Var x [f (x) x ∈ Lw K←z] ≥ E [f (x) x ∈ Lw J←yJ ] y ∈ Lw yhVar x K←zi . Averaging this over all layers, we get the desired result. 14 A.3 Weak sub-additivity of symmetric influence In this section we prove that symmetric influence satisfies weak sub-additivity. It might be tempting to think that strong sub-additivity holds, as in the standard notion of influence, however this is not the case. For example, consider the function f (x) = f1(xJ ) ⊕ f2(xK ) for some partition [n] = J ∪ K and two randomly chosen symmetric functions f1, f2. Since f is far from symmetric, SymInff ([n]) = SymInff (J ∪ K) > 0 while SymInff (J) = SymInff (K) = 0. The additive factor of c√γ in Lemma 5 is derived from the distance between the two distributions πJ∪Kx and πJ πKx, for a random x ∈ {0, 1}n and random permutations from SJ∪K,SJ ,SK . When the sets J and K are large, the distance between these distributions is relatively small which therefore result in this weak sub-additivity property. The analysis of the lemma is done using hypergeometric distributions, and the distance between them. Let Hn,m,k be the hypergeometric distribution obtained when we pick k balls out of n, m of which are red, and count the number of red balls we obtained. Let dTV(·,·) denote the statistical distance between two distributions. The following two lemmas would be useful for our proof. Lemma 9. Let J, K ⊆ [n] be two sets and π, πJ , πK be permutations chosen uniformly at ran- dom from SJ∪K,SJ ,SK, respectively. For a fixed x ∈ {0, 1}n, we define Dπx and DπJ πK x as the distribution of πx and πJ πK x, respectively. Then, dTV(Dπx, DπJ πK x) = dTV(HJ∪K,xJ ∪K,K\J,HK,xK,K\J) holds. Lemma 10. Let n, m, n′, m′, k be non-negative integers with k, n′ ≤ γn for some γ ≤ 1 that m − n 2 ≤ t√n′ hold for some t ≤ 1 2 ≤ t√n and m′ − n′ 100√γ . Then, 2 . Suppose dTV(Hn,m,k,Hn−n′,m−m′,k) ≤ c10(1 + t)γ . holds for some universal constant c10. We first show how these lemmas imply the proof of Lemma 5, and will afterwards prove them. Lemma 5 (Restated). There is a universal constant c such that, for any constant 0 < γ < 1, a function f : {0, 1}n → {0, 1} and sets J, K ⊆ [n] of size at least (1 − γ)n, SymInff (J ∪ K) ≤ SymInff (J) + SymInff (K) + c√γ . Proof. Let π, πJ and πK be as in Lemma 9 and fix x ∈ {0, 1}n to be some input. Pr π [f (x) 6= f (πx)] ≤ Pr ≤ Pr πK πJ ,πK [f (x) 6= f (πJ πK x)] + dTV(Dπx,DπJ πK x) [f (x) 6= f (πKx)] + Pr πJ ,πK [f (πKx) 6= f (πJ πKx)] + dTV(Dπx,DπJ πK x) By summing over all possible inputs x we have SymInff (J ∪ K) = Pr x,π [f (x) 6= f (πx)] = 1 2nXx ≤ SymInff (J) + SymInff (K) + 15 Pr π [f (x) 6= f (πx)] 1 2nXx dTV(Dπx,DπJ πK x) . By applying Lemma 9 over each input x, it suffices to show that 1 2nXx dTV(Dπx,DπJ πK x) = 1 2nXx dTV(HJ∪K,xJ ∪K,K\J,HK,xK,K\J) ≤ c√γ . (1) Ideally, we would like to apply Lemma 10 on every input x and get the desired result, however this is not possible as some inputs does not satisfy the requirements of the lemma. Therefore, we perform a slightly more careful analysis. Let us choose c ≥ 2 and assume γ ≤ 1 4 (as otherwise the claim trivially holds). Fix γ′ = γ/(1 − γ) ≤ 1 100√γ′ . We first note that regardless of x, the required conditions on the size of the sets hold. To be exact, J \ K ≤ γ′J ∪ K and K \ J ≤ γ′J ∪ K since J ∪ K ≥ (1 − γ)n and J \ K ≤ K ≤ γn (and similarly K \ J ≤ γn). We say an input x is good if it satisfies the other conditions of Lemma 10. That is, both 2 and t = 1 bad. From the Chernoff bound and the union bound, the probability that x is bad is at most (cid:12)(cid:12)(cid:12) ≤ tpJ ∪ K and (cid:12)(cid:12)(cid:12)xJ\K − J\K2 (cid:12)(cid:12)(cid:12)xJ∪K − J∪K2 5000γ′(cid:17) ≤ c′γ for some constant c′ (notice that γ′ ≤ 2γ). 4 exp(−2t2) ≤ 4 exp(cid:16)− 1 2n Xx:bad c10(1 + t)γ ≤ c′γ + c10(1 + t)γ ≤ c√γ By applying Lemma 10 over the good inputs we get (cid:12)(cid:12)(cid:12) ≤ tpJ \ K hold. Otherwise we call such x 1 (1) ≤ 1 + 1 2n Xx:good for some constant c, as required. Proof of Lemma 9. Since both distributions Dπx and DπJ πK x only modify coordinates in J ∪ K, we can ignore all other coordinates. Moreover, it is in fact suffices to look only at the number of ones in the coordinates of K \ J and J ∪ K, which completely determines the distributions. Let Dz denote the uniform distribution over all elements y ∈ {0, 1}n such that y = x, yJ∪K = xJ∪K and yK\J = z (which also fixes the number of ones in yJ ). Notice that this is well defined only for values of z such that max{0,xJ∪K − J} ≤ z ≤ min{xJ∪K,K \ J}. Given this notation, Dπx can be looked at as choosing z ∼ HJ∪K,xJ ∪K,K\J and returning y ∼ Dz. This is because we apply a random permutation over all elements of J ∪ K, and therefore the number of ones inside K \ J is indeed distributed like z. Moreover, the order inside both sets K \ J and J is uniform. The distribution DπJ πK x can be looked at as choosing z ∼ HK,xK,K\J and returning y ∼ Dz. The number of ones in K \ J is determined already after applying πK. It is distributed like z as we care about the choice of K \ J out of the K elements, and xK of them are ones (and their order is uniform). Later, we apply a random permutation πJ over all other relevant coordinates, so the order of elements in J is also uniform. Since the distributions Dz are disjoint for different values of z, this implies that the distance between the two distributions Dπx and DπJ πK x depends only on the number of ones chosen to be inside K \ J. Therefore we have dTV(Dπx, DπJ πK x) = dTV(HJ∪K,xJ ∪K,K\J,HK,xK,K\J) as required. Proof of Lemma 10. Our proof uses the connection between hypergeometric distribution and the binomial distribution, which we denote by Bn,p (for n experiments, each with success probability p). By the triangle inequality we know that dTV(Hn,m,k,Hn−n′,m−m′,k) ≤ dTV(Hn,m,k,Bk,p) + dTV(Bk,p,Bk,p′) + dTV(Bk,p′,Hn−n′,m−m′,k) (2) 16 In order to bound the distances we just introduced, we use the n and p′ = m−m′ n−n′ . where p = m following two lemmas. Lemma 11 (Example 1 in [29]). dTV(Hn,m,k,Bk,p) ≤ k Lemma 12 ([1]). Let 0 < p < 1 and 0 < δ < 1 − p. Then, n holds for p = m n . dTV(Bn,p,Bn,p+δ) ≤ √e 2 τn,p(δ) (1 − τn,p(δ))2 2p(1−p) < 1. provided τn,p(δ) = δq n+2 Before using the above lemmas, we analyze some of the parameters. First, when k = 0 the lemma trivially holds and we therefore assume k ≥ 1. Notice that this implies that nγ ≥ k ≥ 1. The 100√nγ ≤ 1 probability p is known to be relatively close to half. To be exact, p − 1 p(1−p) < 6. Assume p ≤ p′ and let δ = p′ − p (the other case can be treated in the and therefore same manner). We first bound δ as follows. 2 ≤ t√n/n ≤ 100 1 1 δ = = mn′ − nm′ n(n − n′) ≤ t(n√n′ + √nn′) n(n − n′) 1 n(n − n′)(cid:18)(cid:16) n 2 2t√γn3/2 (1 − γ)n2 ≤ 4tr γ n ≤ + t√n(cid:17) n′ − n(cid:18)n′ 2 − t√n′(cid:19)(cid:19) (from γ ≤ 1 2 ) . Then, τk,p(δ) in Lemma 12 can be bounded by τk,p(δ) ≤ 4tr γ ns k + 2 2p(1 − p) ≤ 4tr 3γ(k + 2) ≤ 12tpγk/n ≤ 12tγ n (from 1 ≤ k ≤ γn) . (from 1 p(1−p) < 6) 2 . By Lemmas 11 and 12, we have Note that, from the assumption, we have τk,p(δ) ≤ 1 τk,p(δ) √e 2 k n + (2) ≤ k (1 − τk,p(δ))2 + n − n′ (from τk,p(δ) ≤ 1 2 ) ≤ 3γ + 2√e · 12tγ ≤ c10(1 + t)γ for some universal constant c10. B Testing partial symmetry B.1 Analysis of Find-Asymmetric-Set In this section we prove there exists an algorithm Find-Asymmetric-Set, which satisfies Lemma 6. Suppose that we have two inputs x, y ∈ {0, 1}n with xJ = yJ ,x = y such that f (x) 6= f (y). In order to Given such inputs, we know there exists some asymmetric variable outside of J. efficiently find a set from a partition I which contains such a variable, we will use binary search over the sets. First, we construct a refinement J of I. Every set of I \ {W} is partitioned further into parts so that each part has size at most ⌈W/4⌉. Let t = J \ {W} be the number of parts 17 in J excluding the workspace. Notice that the number of parts is at most t ≤ r + 4n/W = O(r). Then, we construct a series of inputs x0 = x, x1, . . . , xt = y by each step permuting only elements from some set I ∈ J \ {W} and the workspace W (that is, applying a permutation from SI∪W ). In each such step, we guarantee that xi I = yI for one more set I ∈ J \{W}, and therefore after (at most) t steps we would reach y (notice that we can choose the last step such that xt W = yW as the Hamming weight of all the inputs in the sequence is identical). Using this construction, we can now describe the algorithm Find-Asymmetric-Set as follows. Algorithm 4 Find-Asymmetric-Set(f,I, J, W ) Generate x ∈ {0, 1}n and π ∈ SJ uniformly at random. if f (x) 6= f (πx) then Define x0, . . . , xt. Perform binary search on x = x0, . . . , xt = y, and find i such that f (xi−1) 6= f (xi). return the only part I ∈ I \ {W} such that xi−1 6= xi I . I return ∅. Proof of Lemma 6. Since we perform binary search over the sequence x0, . . . , xt, the query com- plexity of the algorithm is indeed O(log t) = O(log r). Also, it is easy to verify that we only output an empty set or a part in I \ {W} disjoint to J (as xJ = yJ ). Two random inputs x and y := πx, for π ∈ SJ , satisfy f (x) 6= f (y) with probability SymInff (J). Thus, it suffices to show that we can always define a sequence of x0, . . . , xt, given that W ≥ n 2r . In order to see this is always feasible, we consider the sequence after already defining x0, . . . , xi, showing we can define xi+1. Let J + = {I ∈ J xi I < yI} denote the sets which require increasing or decreasing the Hamming weight of xW respectively, when applying a permutation from SI∪W to ensure xi+1 I = yI, as they do not impact the Hamming weight of xi W) ≥ ⌈W/2⌉ and the size of every set I ∈ J \ {W} is at most ⌈W/4⌉, there must exists a set we can use to define xi+1. On the other hand, if J + = 0 for example, then we can define xi+1 using any set from J − as xi It remains to show that when W contains no asymmetric variables and we output a part I ∈ I \ {W}, I contains an asymmetric variable. Suppose that the output I is the part which was modified between xi−1 and xi. Then, since f (xi−1) 6= f (xi),xi−1 = xi, and xi−1 and xi differ only on I ∪ W , an asymmetric variable exists in I ∪ W and we know it is not in W . W − yW = −PI∈J \{W} xi I = yI. Notice that we ignore sets I for which xi W . If J + > 0 and J − > 0, then since max(xi I − yI (recall that x = xi = y). I > yI} and J − = {I ∈ J xi W,W−xi B.2 Proof of Lemma 7 We first note that when the number of parts r is bigger then n, we simply partition into the n single-element sets and the lemma trivially holds. For 0 ≤ t ≤ 1, let Ft = {J ⊆ [n] : SymInff (J ) < tǫ, J ≤ 5kn/r} be the family of all sets which are not too big and whose complement has symmetric influence of at most tǫ. (Notice that with high probability, the union of any k sets in the partition would have size smaller than 5kn/r, and therefore we assume this is the case from this point on.) Our first observation is that for small enough values of t, Ft is a (k + 1)-intersecting family. Indeed, for any sets J, K ∈ F1/3, SymInff (J ∩ K) = SymInff (J ∪ K) ≤ SymInff (J ) + SymInff (K) + cp5k/r < 2ǫ/3 + ǫ/9 < ǫ . 18 Since f is ǫ-far from (n − k)-symmetric, every set S ⊆ [n] of size S ≤ k satisfies SymInff (S) ≥ ǫ. So J ∩ K > k. We consider two cases separately: when F1/3 contains a set of size less than 2k; and when it does not. The first case is identical to the proof of Lemma 2 and hence we do not elaborate on it. In the second case, which also resembles the proof of Lemma 2, we claim that F1/9 is a 2k- intersecting family. If this was not the case, we could find sets J, K ∈ F1/9 such that J ∩ K < 2k and SymInff (J ∩ K) ≤ SymInff (J ) + SymInff (K) + ǫ/9 < ǫ/3, contradicting our assumption. Let J ⊆ [n] be the union of k parts in I. Since I is a random partition, J is a random subset obtained by including each element of [n] in J independently with probability p = k/r < 1 2k+1 . To bound the probability that J contains some element from F1/9, we define F′1/9 to be all the sets that contain a member from F1/9. Since F′1/9 is also a 2k-intersecting family, by Theorem 4, for 9 ] = Pr[J ∈ F1/9] ≤ µk/r(F′1/9) ≤ (k/r)2k. every such J of size at most 5kn/r, Pr[SymInff (J ) < ǫ Applying the union bound over all possible choices for k parts, f will not satisfy the condition of k(cid:1)(cid:0) k the lemma with probability at most(cid:0)r r(cid:1)2k = O(k−k), which completes the proof of the lemma. C Isomorphism testing and sampling partially symmetric func- tions C.1 Properties of the sampling distribution We start this section with the following observation. When the number of parts r reaches n (or alternatively when k = Ω(√n)), we consider the partition of [n] into the n single-element sets. Notice that when this is the partition, then in fact DW I is identical to D∗k,n, making the following proposition trivial. Therefore, in the proof we assume that r < n and k = O(√n). Proof of Proposition 1. We start with the first part of the proposition, showing x is almost uniform. Consider the following procedure to generate a random I, W and x. We draw a random Hamming weight w ∼ Bn,1/2 and define x′ to be the input consisting of w ones followed by n − w zeros. We choose a random partition I′ of [n] into r consecutive parts I1, . . . , Ir (i.e., I1 = {1, 2, . . . ,I1} and Ir = {n − Ir + 1, . . . , n}) according to the typical distribution of sizes in a random partition. Let the workspace W ′ be the only part which contains the coordinate w (or I1 if w = 0). We now apply a random permutation over x′, I′ and W ′ to get x, I and W . It is clear the above procedure outputs a uniform x as we applied a random permutation over x′, which had a binomial Hamming weight. The choice of I was also done at random, considering the applied permutation over I′. The only difference is then in the choice of the workspace W , which can only be reflected in its size. However, when r = o(√n) we will choose the middle part as the workspace with probability 1 − o(1), regardless of its size. In the remaining cases, since there are n/r = Ω(√n) parts, the possible parts to be chosen as workspace are a small fraction among all parts, and therefore W would be o(1)-close to being a random part. Proving the second property of the proposition, we also consider two cases. When r = o(√n), with probability 1 − o(1), the workspace would have size ω(√n) and also w = n/2 + O(√n). In such a case, the r − 1 parts (excluding the workspace) would be half zeros and half ones, and the marginal distribution over the number of ones in J would be Hr−1,(r−1)/2,k (assuming the elements of J are separated by I, which happens with probability 1 − o(1)). By Lemma 11, the distance between this distribution and Bk,1/2 is bounded by k/r < c/k for our choice of 0 < c < 1. Since 19 there is no restriction on the ordering of the sets, this is also the distance from uniform over {0, 1}k as required. In the remaining case where r = Ω(√n), we can use the same arguments and also apply Lemma 12 with the distributions Bk,1/2 and Bk,1/2+δ for δ = O(1/√n), implying the distance be- tween these two distributions is at most o(1). Combining this with the distance to Hr−1,(r−1)(1/2+δ),k we get again a total distance of k/r + o(1) < c/k for our choice of 0 < c < 1. C.2 Analysis of Partially-Symmetric-Isomorphism-Test The analysis of the algorithm is based on the fact that functions which passes the Partially- Symmetric-Test satisfy some conditions, and in particularly are closed to being partially sym- metric. We therefore start with the following lemma. Lemma 13. Let g be a function ǫ-close to being (n − k)-symmetric which passed the Partially- Symmetric-Test(g, k, ǫ). In addition, let I, W and J be the partition, workspace and identified parts used by the algorithm. With probability at least 9/10, there exists a function h which satisfies the following properties. • h is 4ǫ-close to g, and • h is (n − k)-symmetric whose asymmetric variables are contained in J and separated by I. Proof. Let g∗ be the (n − k)-symmetric function closest to g (which can be f itself, up-to some isomorphism) and R be the set of (at most) k asymmetric variables of g∗. By Lemma 3 and our assumption over g, SymInfg(R) ≤ 2 · dist(g, g∗) ≤ 2ǫ . Notice however that R is not necessarily contained in J and therefore g∗ is not a good enough candidate for h. Let U = R ∩ J be the intersection of the asymmetric variables of g∗ and the In order to show that g is also close to being U -symmetric, sets identified by the algorithm. we bound SymInfg(U ) using Lemma 5 with the sets R and J . Notice that since R ≤ k and J ≤ 2kn/r ≤ ǫ2n/c′ for our choice of c′, we can bound the error term (in the notation of Lemma 5) by c√γ ≤ cpǫ2/c′ ≤ ǫ. We therefore have SymInfg(U ) ≤ SymInfg(R) + SymInfg(J ) + ǫ ≤ 2ǫ + ǫ + ǫ = 4ǫ where we know SymInfg(J) ≤ ǫ with probability at least 19/20 as the algorithm did not reject. By applying Lemma 3 again, we know there exists a U -symmetric function h, whose distance to g is bounded by dist(g, h) ≤ 4ǫ. Moreover, with probability at least 19/20, all its asymmetric variables are completely separated by the partition I (and they were all identified as part of J). Given Lemma 13, we are now ready to analyze Partially-Symmetric-Isomorphism-Test. Proof of Theorem 1. Before analyzing the algorithm we just described, we consider the case where k > n/10. Since Theorem 2 does not hold for such k's, we apply the basic algorithm of O(n log n/ǫ) random queries, which is applicable testing isomorphism of any given function (since there are n! possible isomorphisms, the random queries will rule out all of them with good probability, assuming we should reject). Since k = Ω(n), the complexity of this algorithm fits the statement of our theorem. We start by analyzing the query complexity of the algorithm. The step of Partially-Symmetric- Test performs O( k ǫ ) queries, and therefore the majority of the queries are performed at the sampling stage, resulting in O(k log k/ǫ2) queries as required. In order to prove the correctness of the algorithm, we consider the following cases. ǫ log k 20 • g is ǫ-far from being isomorphic to f and ǫ/1000-far from being (n − k)-symmetric. • g is ǫ-far from being isomorphic to f but ǫ/1000-close to being (n − k)-symmetric. • g is isomorphic to f . In the first case, with probability at least 9/10, Partially-Symmetric-Test will reject and so will we, as required. We assume from this point on that Partially-Symmetric-Test did not reject, as it will only reject g which is isomorphic to f with probability at most 1/10, and that we are not in the first case. Notice that these cases match the conditions of Lemma 13, and therefore from this point onward we assume there exists an h satisfying the lemma's properties (remembering we applied the algorithm with ǫ/1000). In order to bound the distance between h and g in our samples, we use Proposition 1, indicating Pr I,W∈I,x∼DW I [g(x) 6= h(x)] = dist(g, h) + o(1/n) . By Markov's inequality, with probability at least 9/10, the partition I and the workspace W satisfy Pr x∼DW I [g(x) 6= h(x)] ≤ 10 · dist(g, h) + o(1/n) ≤ 10 · 4ǫ/1000 + o(1/n) < ǫ/20 . By Proposition 1, if we were to sample h according to DW I , it should be ǫ/20-close to sampling its core (assuming the partition size is large enough). Combined with the distance between g and h in our samples, we expect our samples to be ǫ/20 + ǫ/20 = ǫ/10 close to sampling h's core. The last part of the proof is showing that there would be an almost consistent isomorphism of f only when g is isomorphic to f . Notice however that we care only for isomorphisms which map the asymmetric variables of f to the k sets of J. Therefore, the number of different isomorphisms we need to consider is k!. Assume we are in the second case and g is ǫ-far from being isomorphic to f . Let fπ be some isomorphism of f . By our assumptions and Lemma 13, dist(fπ, h) ≥ dist(fπ, g) − dist(g, h) ≥ ǫ − ǫ/250 . Each sample we perform would be inconsistent with fπ with probability at least ǫ− ǫ/250− ǫ/10 > 8ǫ/9. By the Chernoff bounds and the union bound, if we would perform q = O(k log k/ǫ2) queries, we would rule out all k! possible isomorphisms with probability at least 9/10 and reject the function as required. On the other hand, if g is isomorphic to f , then we know there exists with probability at least 9/10 some isomorphism fπ which maps the asymmetric variables of f into the sets of J, such that dist(fπ, h) ≤ dist(fπ, g) + dist(g, h) ≤ ǫ/500 + ǫ/250 . For this isomorphism, with high probability much more than (1− ǫ/2)-fraction of the queries would be consistent and we would therefore accept g as we should. C.3 Efficient sampler for partially symmetric functions We first provide the algorithm for efficiently generating a δ-sampler for partially symmetric func- tions. The algorithm perform its preprocessing by calling Partially-Symmetric-Test. Given the output of the algorithm, we query the function once for each call to the sampler, according to DW I , and return the result. 21 Algorithm 5 Partially-Symmetric-Sampler(f, k, δ, η) 1: Perform Partially-Symmetric-Test(f, k, ηδ). 2: Let I and W ∈ I be the partition and workspace used by the algorithm. 3: Let J be the union of k parts in I \ {W} that were identified by the algorithm. 4: Return the following sampler: Choose a random y ∼ DW 5: I Let x ∈ {0, 1}k be the value assigned to the parts in J Yield the triplet (x,y − x, f (y)) 6: 7: Proof of Theorem 3. The algorithm for generating the sampler is described by Partially-Symmetric- Sampler, which performs O( k proved is that indeed with good probability, the algorithm returns a valid sampler. ηδ ) preprocessing queries to the function. What remains to be ηδ log k Let h be the function defined in the analysis of Theorem 1, which satisfies the conditions of Lemma 13. Recall that its asymmetric variables were separated by I and appear in J. Following this analysis and that of Partially-Symmetric-Test, one can see that with probability at least 1 − η we would not reject f when calling Partially-Symmetric-Test. Moreover, the samples would be δ/2-close to sampling the core of h, which is by itself δ/2-close to f . Therefore, overall our samples would be δ-close to sampling the core of f . The last part in completing the proof of the theorem is showing that we sample the core with distribution δ-close to D∗k,n. By Proposition 1, the total variation distance between sampling the core according to D∗k,n and sampling it according to DW I is at most c/k for our choice of 0 < c < 1, which we can choose it to be at most δ. Notice that if the function f is not (n − k)-symmetric but still very close (say (k/ηδ)2-close), applying the same algorithm will provide a good sampler for an (n− k)-symmetric function f′ close to f . The main reason is that most likely, we will not query any location of the function where it does not agree with f′. 22
1401.0163
1
1401
2013-12-31T15:56:30
Fast Algorithm for Partial Covers in Words
[ "cs.DS" ]
A factor $u$ of a word $w$ is a cover of $w$ if every position in $w$ lies within some occurrence of $u$ in $w$. A word $w$ covered by $u$ thus generalizes the idea of a repetition, that is, a word composed of exact concatenations of $u$. In this article we introduce a new notion of $\alpha$-partial cover, which can be viewed as a relaxed variant of cover, that is, a factor covering at least $\alpha$ positions in $w$. We develop a data structure of $O(n)$ size (where $n=|w|$) that can be constructed in $O(n\log n)$ time which we apply to compute all shortest $\alpha$-partial covers for a given $\alpha$. We also employ it for an $O(n\log n)$-time algorithm computing a shortest $\alpha$-partial cover for each $\alpha=1,2,\ldots,n$.
cs.DS
cs
Fast Algorithm for Partial Covers in Words∗ Tomasz Kociumaka†1, Jakub Radoszewski‡1, Wojciech Rytter§1,2, Solon P. Pissis¶3, and Tomasz Wale´nk1 1Faculty of Mathematics, Informatics and Mechanics, University of Warsaw, Poland, [kociumaka, jrad, rytter, walen]@mimuw.edu.pl 2Faculty of Mathematics and Computer Science, Copernicus University, Toru´n, Poland 3Department of Informatics, King's College London, UK, [email protected] Abstract A factor u of a word w is a cover of w if every position in w lies within some occurrence of u in w. A word w covered by u thus generalizes the idea of a repetition, that is, a word composed of exact concatenations of u. In this article we introduce a new notion of α-partial cover, which can be viewed as a relaxed variant of cover, that is, a factor covering at least α positions in w. We develop a data structure of O(n) size (where n = w) that can be constructed in O(n log n) time which we apply to compute all shortest α-partial covers for a given α. We also employ it for an O(n log n)-time algorithm computing a shortest α-partial cover for each α = 1, 2, . . . , n. 1 Introduction The notion of periodicity in words and its many variants have been well-studied in numerous fields like combinatorics on words, pattern matching, data compression, automata theory, formal language theory, and molecular biology (see [9]). However the classic notion of periodicity is too restrictive to provide a description of a word such as abaababaaba, which is covered by copies of aba, yet not exactly periodic. To fill this gap, the idea of quasiperiodicity was introduced [1]. In a periodic word, the occurrences of the period do not overlap. In contrast, the occurrences of a quasiperiod in a quasiperiodic word may overlap. Quasiperiodicity thus enables the detection of repetitive structures that would be ignored by the classic characterization of periods. The most well-known formalization of quasiperiodicity is the cover of word. A factor u of a word w is said to be a cover of w if u 6= w, and every position in w lies within some occurrence of u in w. Equivalently, we say that u covers w. Note that a cover of w must also be a border -- both prefix and suffix -- of w. Thus, in the above example, aba is the shortest cover of abaababaaba. A linear-time algorithm for computing the shortest cover of a word was proposed by Apostolico et al. [2], and a linear-time algorithm for computing all the covers of a word was proposed by Moore & Smyth [23]. Breslauer [4] gave an online linear-time algorithm computing the minimal cover array of a word -- a data structure specifying the shortest cover of every prefix of the word. Li & Smyth [22] provided a linear-time ∗A preliminary version of this work appeared in the Proceedings of the Twenty-Fourth Annual Symposium on Combinatorial Pattern Matching, pp. 177 -- 188, 2013. †Supported by Polish budget funds for science in 2013-2017 as a research project under the 'Diamond Grant' program. ‡The author receives financial support of Foundation for Polish Science. §Supported by grant no. N206 566740 of the National Science Centre. ¶Supported by the NSF -- funded iPlant Collaborative (NSF grant #DBI-0735191). kSupported by Iuventus Plus grant (IP2011 058671) of the Polish Ministry of Science and Higher Education. 1 algorithm for computing the maximal cover array of a word, and showed that, analogous to the border array [8], it actually determines the structure of all the covers of every prefix of the word. A known extension of the notion of cover is the notion of seed. A seed is not necessarily aligned with the ends of the word being covered, but is allowed to overflow on either side. More formally, a word u is a seed of w if u is a factor of w and w is a factor of some word y covered by u. Seeds were first introduced by Iliopoulos, Moore, and Park [18]. A linear algorithm for computing the shortest seed of a word was given by Kociumaka et al. [19]. Still it remains unlikely that an arbitrary word, even over the binary alphabet, has a cover (or even a seed). For example, abaaababaabaaaababaa is a word that not only has no cover, but whose every prefix also has no cover. In this article we provide a natural form of quasiperiodicity. We introduce the notion of partial covers, that is, factors covering at least a given number of positions in w. Recently, Flouri et al. [14] suggested a related notion of enhanced covers which are additionally required to be borders of the word. Partial covers can be viewed as a relaxed variant of covers alternative to approximate covers [24]. The approximate covers require each position to lie within an approximate occurrence of the cover. This allows for small irregularities within each fragment of a word. On the other hand partial covers require exact occurrences but drop the condition that all positions need to be covered. This allows some fragments to be completely irregular as long as the total length of such fragments is small. The significant advantage of partial covers is that they enjoy more combinatorial properties, and consequently the algorithms solving the most natural problems are much more efficient than those concerning approximate covers, where the time complexity rarely drops below quadratic and some problems are even NP-hard. Let Covered (u, w) denote the number of positions in w covered by occurrences of the word u in w; we call this value the cover index of u within w. For example, Covered (aba, aababab) = 5. We primarily focus on the following two problems, but the tools we develop can be used to answer a number of questions concerning partial covers, some of which are discussed in the Conclusions. PartialCovers problem Input: a word w of length n and a positive integer α ≤ n. Output: all shortest factors u such that Covered (u, w) ≥ α. Each factor given in the output is represented by the first and the last starting position of its occurrence in w. Example 1. Let w = bcccacccaccaccb and α = 11. Then the only shortest α-partial covers are ccac and cacc. AllPartialCovers problem Input: a word w of length n. Output: for all α = 1, . . . , n, a shortest factor u such that Covered (u, w) ≥ α. Our contribution. The following summarizes our main result. Theorem 1. The PartialCovers and AllPartialCovers problems can be solved in O(n log n) time and O(n) space. We extensively use suffix trees, for an exposition see [8, 12]. A suffix tree of a word is a compact trie of its suffixes, the nodes of the trie which become nodes of the suffix tree are called explicit nodes, while the other nodes are called implicit. Each edge of the suffix tree can be viewed as an upward maximal path of implicit nodes starting with an explicit node. Moreover, each node belongs to a unique path of that kind. Then, each node of the trie can be represented in the suffix tree by the edge it belongs to and an index within the corresponding path. Each factor of the word corresponds to an explicit or implicit node of the suffix tree. A representation of this node is called the locus of the factor. Our algorithm finds the loci of the shortest partial covers, it is then straightforward to locate an occurrence for each of them. 2 A Sketch of the Algorithm The algorithm first augments the suffix tree of w, that is, a linear number of implicit extra nodes become explicit. Then, each node of the augmented tree is annotated with two integer values. They allow for determining the size of the covered area for each implicit node by a simple formula, since limited to a single edge of the augmented suffix tree, these values form an arithmetic progression. This yields a solution to the PartialCovers. For an efficient solution to the AllPartialCovers problem, we additionally find the upper envelope of a number of line segments constructed from the arithmetic progressions. In Section 2 we formally introduce the augmented and annotated suffix tree Structure of the Paper that we call Cover Suffix Tree. We show its basic properties and present its application for PartialCovers and AllPartialCovers problems. Section 4 is dedicated to the construction of the Cover Suffix Tree. Before that, Section 3 presents an auxiliary data structure being an extension of the classical Union/Find data structure; its implementation is given later, in Section 5. Additional applications of the Cover Suffix Tree are given in Sections 6 and 7. The former presents how the data structure can be used to compute all primitively rooted squares in a word and a linear-sized representation of all the seeds in a word. The latter contains a short discussion of variants of the PartialCovers problem that can be solved in a similar way. 2 Augmented and Annotated Suffix Trees Let w be a word of length n over a totally ordered alphabet Σ. The suffix tree T of w can be constructed in O(n log Σ) time [13, 25]. For an explicit or implicit node v of T , we denote by v the word obtained by spelling the characters on a path from the root to v. We also denote v = v. As in most applications of the suffix tree, the leaves of T play an auxiliary role and do not correspond to factors (actually they are suffixes of w#, where # /∈ Σ). They are labeled with the starting positions of the suffixes of w. We introduce the Cover Suffix Tree of w, denoted by CST (w), as an augmented -- new nodes are added -- suffix tree in which the nodes are annotated with information relevant to covers. CST (w) is similar to the data structure named Minimal Augmented Suffix Tree (see [3, 5]). For a set X of integers and x ∈ X, we define and we assume next X (x) = ∞ if x = max X. By Occ(v, w) we denote the set of starting positions of occurrences of v in w. For any i ∈ Occ(v, w), we define: next X (x) = min{y ∈ X, y > x}, δ(i, v) = next Occ(v,w)(i) − i. Note that δ(i, v) = ∞ if i is the last occurrence of v. Additionally, we define: see, for example, Fig. 1. cv (v) = Covered (v, w), ∆(v) = (cid:12)(cid:12) {i ∈ Occ(v, w) : δ(i, v) ≥ v}(cid:12)(cid:12); b c c c a c c c a c c a c c b 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Figure 1: Let w = bcccacccaccaccb and let v be the node corresponding to cacc. We have Occ(v, w) = {4, 8, 11}, cv (v) = 11, ∆(v) = 2. A word u is called primitive if u = yk for a word y and an integer k implies that y = u, and non-primitive otherwise. A square u2 is called primitively rooted if u is primitive. Observation 1. Let v be a node in the suffix trie of w. Then vv is a primitively rooted square in w if and only if there exists i ∈ Occ(v, w) such that δ(i, v) = v. 3 Proof. Recall that, by the synchronization property of primitive words (see [8]), v is primitive if and only if it occurs exactly twice in vv. (⇒) If vv occurs in w at position i then δ(i, v) = v. (⇐) If δ(i, v) = v then obviously vv occurs in w at position i. Additionally, if v was not primitive then δ(i, v) < v would hold. In CST (w), we introduce additional explicit nodes called extra nodes, which correspond to halves of primitively rooted square factors of w. Moreover we annotate all explicit nodes (including extra nodes) with the values cv , ∆; see, for example, Fig. 2. The number of extra nodes is bounded by the number of distinct squares, which is linear [15], so CST (w) takes O(n) space. Lemma 1. Let v1, v2, . . . , vk be the consecutive implicit nodes on the edge from an explicit node v of CST (w) to its explicit parent. Then for 1 ≤ i ≤ k we have in particular (cv (vi))k i=1 forms an arithmetic progression. cv (vi) = cv (v) − i∆(v), Proof. Note that Occ(vi, w) = Occ(v, w), since otherwise vi would be an explicit node of CST (w). Also note that if any two occurrences of v in w overlap, then the corresponding occurrences of vi overlap. Otherwise, by Observation 1, the path from v to vi (excluding v) would contain an extra node. Hence, when we go up from v (before reaching its parent) the size of the covered area decreases at each step by ∆(v). b c 2, 2 a c 9, 3 c c a c c c c a c c c a c c a c c b b c c 11, 2 a b 5, 1 8, 1 15, 1 12, 1 9, 1 6, 1 10, 10 c b 2, 1 a 9, 3 c 11, 2 c 12, 1 a c c b b c a c c a c c b 10, 4 a c c a c b 3, 1 c a c c b 13, 1 8, 2 c c a c c b 10, 1 c a c c a c c b 10, 1 14, 1 9, 3 a c c b b 4, 1 7, 1 c a c c a c c b 11, 1 Figure 2: CST (w) for w = bcccacccaccaccb. It contains four extra nodes that are denoted by squares in the figure. Each node is annotated with cv (v), ∆(v). Leaves are omitted for clarity. Example 2. Consider the word w from Fig. 2. The word cccacc corresponds to an explicit node of CST (w); we denote it by v. We have cv (v) = 10 and ∆(v) = 1 since the two occurrences of the factor cccacc in w overlap. The word cccac corresponds to an implicit node v′ and cv (v′) = 10 − 1 = 9. Now the word ccca corresponds to an extra node v′′ of CST (w). Its occurrences are adjacent in w and cv (v′′) = 8, ∆(v′′) = 2. The word ccc corresponds to an implicit node v′′′ and cv (v′′′) = 8 − 2 = 6. 4 As a consequence of Lemma 1 we obtain the following result. Recall that the locus of a factor v of w, given by its start and end position in w, can be found in O(log log v) time [21]. Lemma 2. Assume we are given CST (w). Then we can compute: (1) for any α, the loci of the shortest α-partial covers in linear time; (2) given the locus of a factor u in the suffix tree CST (w), the cover index Covered (u, w) in O(1) time. Proof. Part (2) is a direct consequence of Lemma 1. As for part (1), for each edge of CST (w), leading from v to its parent v′, we need to find minimum v ≥ j > v′ for which cv (v) − ∆(v) · (v − j) ≥ α. Such a linear inequality can be solved in constant time. Due to this fact the efficiency of the PartialCovers problem relies on the complexity of CST (w) construction. In turn, the following lemma, also a consequence of Lemma 1, can be used to solve AllPar- tialCovers problem provided that CST (w) is given. As a tool a solution to the geometric problem of upper envelope [17] is applied. Lemma 3. Assume we are given CST (w). Then we can compute the locus of a shortest α-partial cover for each α = 1, 2, . . . , n in O(n log n) time and O(n) space. Proof. Consider an edge of CST (w) from v to its parent v′ containing k implicit nodes. For each such edge, we form a line segment on the plane connecting points (v, cv (v)) and (v−k, cv (v)−k ·∆(v)) (if there are no implicit nodes on the edge, the line segment is a single point). Denote all such line segments obtained from CST (w) as s1, . . . , sm, we have m = O(n). We consider the upper envelope E of the set of these segments. Formally, if each si connecting points (xi, yi) and (x′ i, is interpreted as a linear function on a domain [xi, x′ i], E is defined as a function E : [1, n] → [1, n] such that: i, y′ i), xi ≤ x′ E(x) = max{si(x) : i ∈ {1, . . . , m}, x ∈ [xi, x′ i]}. Here we are actually interested in an integer envelope E ′, that is, E limited to integer arguments, see Fig. 3. By Lemma 1, for any j ∈ {1, . . . , n}, E ′(j) equals the maximum of Covered (u, w) over all factors u of w such that u = j. A piecewise linear representation of E can be computed in O(m log m) time and O(m) space [17], therefore the function E ′ for all its arguments can be computed in the same time complexity. Let us introduce a prefix maxima sequence for E ′: µi = max{E ′(j) : j ∈ {1, . . . , i}}, with µ0 = 0. Note that µi is non-decreasing. If µi > µi−1 then the shortest α-partial cover for all α ∈ (µi−1, µi] has length i. An example of such a partial cover can be recovered if we explicitly store the initial line segments used in the pieces of the representation of E. Thus the solution of the AllPartialCovers problem can be obtained from the sequence µi in O(m) = O(n) time. In the following two sections we provide an O(n log n) time construction of CST (w). Together with Lemmas 2 and 3, it yields Theorem 1. 3 Extension of Disjoint-Set Data Structure In this section we extend the classic disjoint-set data structure to compute the change lists of the sets being merged, as defined below. First, let us extend the next notation. For a partition P = {P1, . . . , Pk} of U = {1, . . . , n}, we define Now for two partitions P, P ′ let us define the change list (see also Fig. 4) by next P (x) = next Pi(x) where x ∈ Pi. ChangeList (P, P ′) = {(x, next P ′ (x)) : next P (x) 6= next P ′(x)}. We say that (P, id) is a partition of U labeled by L if P is a partition of U and id : P → L is a one-to-one (injective) mapping. A label ℓ ∈ L is called active if id(P ) = ℓ for some P ∈ P and free otherwise. 5 covered positions 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 word length Figure 3: Line segments constructed as in Lemma 3 for the CST (w) from Fig. 2. The marked points joined with a dashed polyline show the values of the integer upper envelope function E ′. We infer from the graph that the lengths of the shortest α-partial covers of w are as follows: 1 for α ≤ 10, 4 for α = 11, 5 for α = 12, and α for α ≥ 13. v v2 v1 v3 4 9 8 7 5 2 6 3 1 1 2 3 4 5 6 7 8 9 Figure 4: Let P be the partition of {1, . . . , 9} whose classes consist of leaves in the subtrees rooted at children of v, P = {{1, 3, 4}, {2, 5, 6, 7}, {8, 9}}, and let P ′ = {{1, . . . , 9}}. Then ChangeList (P, P ′) = {(1, 2), (2, 3), (4, 5), (7, 8)} (depicted by dotted arrows). Lemma 4. Let n ≤ k be positive integers such that k is of magnitude Θ(n). There exists a data structure of size O(n), which maintains a partition (P, id) of {1, . . . , n} labeled by L = {1, . . . , k} and supports the following operations: • Find (x) for x ∈ {1, . . . , n} gives the label of P ∈ P containing x. • Union(I, ℓ) for a set I of active labels and a free label ℓ replaces all P ∈ P with labels in I by their set-theoretic union with the label ℓ. The change list of the corresponding modification of P is returned. Initially P is a partition into singletons with id({x}) = x. Any valid sequence of Union operations is performed in O(n log n) time. A single Find operation takes O(1) time. Note that these are actually standard disjoint-set data structure operations except for the fact that we require Union to return the change list. The technical proof of Lemma 4 is postponed until Section 5. 6 4 O(n log n)-time Construction of CST (w) The suffix tree of w augmented with extra nodes is called the skeleton of CST (w), which we denote by sCST (w). It could be constructed using the fact that all square factors of a word can be computed in linear time [16, 10, 11]. However, we do not need such a complicated machinery here. We will compute sCST (w) on the fly, simultaneously annotating the nodes with cv , ∆. We introduce auxiliary notions related to covered area of nodes: cv h(v) = X i∈Occ(v,w) δ(i,v)<h δ(i, v), ∆h(v) = {i ∈ Occ(v, w) : δ(i, v) ≥ h}. Observation 2. cv (v) = cv v(v) + ∆v(v) · v, ∆(v) = ∆v(v). In the course of the algorithm some nodes will have their values c, ∆ already computed; we call them processed nodes. Whenever v will be processed, so will its descendants. The algorithm processes inner nodes v of sCST (w) in the order of non-increasing height h = v. The height is not defined for leaves, so we start with h = n + 1. Extra nodes are created on the fly using Observation 1 (this takes place in the auxiliary Lift routine). We maintain the partition P of {1, . . . , n} given by sets of leaves of subtrees rooted at peak nodes. Initially the peak nodes are the leaves of sCST (w). Each time we process v all its children are peak nodes. Consequently, after processing v they are no longer peak nodes and v becomes a new peak node. The sets in the partition are labeled with identifiers of the corresponding peak nodes. Recall that leaves are labeled with the starting positions of the corresponding suffixes. We allow any labeling of the remaining nodes as long as each node of sCST (w) has a distinct label of magnitude O(n). For this set of labels we store the data structure of Lemma 4 to compute the change list of the changing partition. h v1 v2 root v v3 i v5 v4 Figure 5: One stage of the algorithm, where the peak nodes are v1, . . . , v5 while the currently processed node is v. If i ∈ List [d] and v3 = Find (i), then d = δ(i, v3) = Dist[i]. The current partition is P = {Leaves(v1), Leaves(v2), Leaves(v3), Leaves(v4), Leaves(v5)}. After v is processed, the partition changes to P = {Leaves(v1), Leaves(v2), Leaves(v), Leaves(v5)}. The Union operation merges Leaves(v4), Leaves(v3) and returns the corresponding change list. We maintain the following technical invariant (see Fig. 5). Invariant(h): (A) For each peak node z we store: (B) For each i ∈ {1, . . . , n} we store Dist [i] = δ(i, Find (i)). cv ′[z] = cv h(z), ∆′[z] = ∆h(z). 7 (C) For each d < h we store List [d] = {i : Dist [i] = d}. We use two auxiliary routines. The Lift operation updates cv ′ and ∆′ values when h decrements. It also creates all extra nodes of depth h. The LocalCorrect operation is used for updating cv ′ and ∆′ values for children of the node v. The Dist and List arrays are stored to enable efficient implementation of these two routines. Algorithm ComputeCST(w) T := suffix tree of w; P := partition of {1, . . . , n} into singletons; foreach v : a leaf of T do cv ′[v] := 0, ∆′[v] := 1; for h := n + 1 downto 0 do Lift(h); {Now part (A) of Invariant(h) is satisfied} foreach v : an inner node of T , v = h do cv ′[v] := Pu∈children (v) cv ′[u]; ∆′[v] := Pu∈children(v) ∆′[u]; ChangeList (v) := Union(children(v), v) foreach (p, q) ∈ ChangeList (v) do LocalCorrect (p, q, v); cv [v] := cv ′[v] + ∆′[v] · v; ∆[v] := ∆′[v]; return T together with values of cv , ∆; Description of the Lift (h) Operation The procedure Lift plays an important preparatory role in pro- cessing the current node. According to part (A) of our invariant, for all peak nodes z we know the values: cv ′[z] = cv h+1(z), ∆′[z] = ∆h+1(z). Now we have to change h+1 to h and guarantee validity of the invariant: cv ′[z] = cv h(z), ∆′[z] = ∆h(z). This is exactly how the following operation updates cv ′ and ∆′. It also creates all extra nodes of depth h that were not explicit nodes of the suffix tree. By Observation 1, if i ∈ List [h] then at position i in w there is an occurrence of a primitively rooted square of half length h. Consequently, an extra node corresponding to this occurrence is created in the Lift operation. Function Lift(h) foreach i in List [h] do v := Find (i); ∆′[v] := ∆′[v] + 1; cv ′[v] := cv ′[v] − h; if parent (v) < h then Create a node of depth h on the edge from parent (v) to v Description of the LocalCorrect (p, q, v) Operation Here we assume that v occurs at positions p < q and that these are consecutive occurrences. Moreover, we assume that these occurrences are followed by distinct characters, i.e. (p, q) ∈ ChangeList (v). The LocalCorrect procedure updates Dist [p] to make part (B) of the invariant hold for p again. The data structure List is updated accordingly so that (C) remains satisfied. 8 Function LocalCorrect (p, q, v) d := q − p; d′ := Dist [p]; if d′ < v then cv ′[v] := cv ′[v] − d′ else ∆′[v] := ∆′[v] − 1; if d < v then cv ′[v] := cv ′[v] + d else ∆′[v] := ∆′[v] + 1; Dist[p] := d; remove(i, List[d′]); insert (i, List [d]); Complexity of the Algorithm In the course of the algorithm we compute ChangeList (v) for each v ∈ T . Due to Lemma 4 we have: ChangeList (v) = O(n log n). X v∈T Consequently we perform O(n log n) operations LocalCorrect . In each of them at most one element is added to a list List [d] for some d. Hence the total number of insertions to these lists is also O(n log n). The cost of each operation Lift is proportional to the total size of the list List [h] processed in this operation. For each h the list List [h] is processed once and the total number of insertions into lists is O(n log n), therefore the total cost of all operations Lift is also O(n log n). This proves the following fact which, together with Lemmas 2 and 3, implies our main result (Theorem 1). Lemma 5. Algorithm ComputeCST constructs CST (w) in O(n log n) time and O(n) space, where n = w. 5 Implementation Details In this section we give a proof of Lemma 4. We use an approach similar to Brodal and Pedersen [6] (who use the results of [7]) originally devised for computation of maximal quasiperiodicities. Theorem 3 of [6] states that a subset X of a linearly ordered universe can be stored in a height-balanced tree of linear size supporting the following operations: X.MultiInsert (Y ): insert all elements of Y to X, X.MultiPred (Y ): return all (y, x) for y ∈ Y and x = max{z ∈ X, z < y}, X.MultiSucc(Y ): return all (y, x) for y ∈ Y and x = min{z ∈ X, z > y}, in O (cid:16)Y max(cid:16)1, log X Y (cid:17)(cid:17) time. In the data structure we store each P ∈ P as a height-balanced tree. Additionally, we store several auxiliary arrays, whose semantics follows. For each x ∈ {1, . . . , n} we maintain a value next[x] = next P (x) and a pointer tree[x] to the tree representing P such that x ∈ P . For each P ∈ P (technically for each tree representing P ∈ P) we store id[P ] and for each ℓ ∈ L we store id−1[ℓ], a pointer to the corresponding tree (null for free labels). Answering Find is trivial as it suffices to follow the tree pointer and return the id value. The Union operation is performed according to the pseudocode given below (for brevity we write Pi instead of id−1[i]). Claim 2. The Union operation correctly computes the change list and updates the data structure. Proof. In the Union operation for sets Pi, i ∈ I, we find the largest set Pi0 and MultiInsert all the elements of the remaining sets to Pi0 . If (a, b) is in the change list, then a and b come from different sets Pi, in particular at least one of them does not come from Pi0 . Depending on which one it is, the pair (a, b) is found by MultiPred or MultiSucc operation. While computing C, the table next is not updated yet (i.e. corresponds to the state before Union operation) while S is already updated. Consequently the pairs inserted to C indeed belong to the change list. Once C is proved to be the change list, it is clear that next is updated correctly. For the other components of the data structure, correctness of updates is evident. 9 Function Union(I, ℓ) i0 := argmax{Pi : i ∈ I}; S := Pi0 ; foreach i ∈ I \ {i0} do foreach x ∈ Pi do tree[x] := S; S.MultiInsert (Pi); C := ∅; foreach i ∈ I \ {i0} do foreach (b, a) ∈ S.MultiPred (Pi) do if next [a] 6= b then C := C ∪ {(a, b)}; foreach (a, b) ∈ S.MultiSucc(Pi) do if next [a] 6= b then C := C ∪ {(a, b)}; id−1[i] := null; id−1[i0] := null; id[S] := ℓ; id−1[ℓ] := S; foreach (x, y) ∈ C do next [x] := y return C; Claim 3. Any sequence of Union operations takes O(n log n) time in total. Proof. Let us introduce a potential function Φ(P) = PP ∈P P log P . We shall prove that the running time of a single Union operation is proportional to the increase in potential. Clearly 0 ≤ Φ(P) = X P ∈P P log P ≤ X P ∈P P log n = n log n, so this suffices to obtain the desired O(n log n) bound. Let us consider a Union operation that merges partition classes of sizes p1 ≥ p2 ≥ . . . ≥ pk to a single i=1 pi. The most time-consuming steps of the algorithm are the operations on height- pi(cid:17)(cid:17) time. These operations are not performed 2 p (i.e. log p ≥ 1). This lets us bound the time class of size p = Pk balanced trees, which, for single i, run in O (cid:16)max(cid:16)pi, pi log p for the largest set and for the remaining ones we have pi < 1 complexity of the Union operation as follows: pi k X i=2 max(cid:16)pi, pi log p pi(cid:17) = k X i=2 pi log p pi ≤ k X i=1 pi log p pi = k X i=1 pi(log p − log pi) = p log p − k X i=1 pi log pi, which is equal to the increase in potential. 6 By-Products of Cover Suffix Tree In this section we present two additional applications of the Cover Suffix Tree. We show that, given CST (w) (or CST of a word that can be obtained from w in a simple manner), one can compute in linear time all distinct primitively rooted squares in w and a linear representation of all the seeds of w, in particular, the shortest seeds of w. This shows that constructing this data structure is at least as hard as computing all primitively rooted squares and seeds. While there are linear-time algorithms for these problems [16, 20, 10] and [19], they are all complex and rely on the combinatorial properties specific to the repetitive structures they seek for. Theorem 4. Assume that the Cover Suffix Tree of a word of length n can be computed in T (n) time. Then all distinct primitively rooted squares in a word w of length n can be computed in T (2n) time. 10 Proof. Let 0 /∈ Σ be a special symbol. Let ϕ : Σ∗ → (Σ ∪ {0})∗ be a morphism such that ϕ(c) = 0c for any c ∈ Σ. We consider the word w′ = ϕ(w)0, that is, the word w with 0-characters inserted at all its inter-positions, e.g. if w = aabab then w′ = 0a0a0b0a0b0. Let us consider the set of explicit non-branching nodes of CST (w′) and select among them the nodes corresponding to even-length factors of w′ starting with the symbol 0. It suffices to note that there is a one-to-one correspondence between these nodes and the halves of primitively rooted squares in w. a a a b a a b a a b a a a b a a b a Figure 6: Seed of string aaabaabaabaaabaaba. Recall that a word u is a seed of w if u is a factor of w and w is a factor of some word y covered by u, see Fig. 6. The following lemma states that the set of all seeds of w has a representation of O(n) size, where n = w. This representation enables, e.g., simple computation of all shortest seeds of the word. By a range on a edge of a suffix tree we mean a number of consecutive nodes on this edge (obviously at most one of these nodes is explicit). Let wR denote the reverse of the word w. Lemma 6 ([18, 19]). The set of all seeds of w can be split into two disjoint classes. The seeds from one class form a single (possibly empty) range on each edge of the suffix tree of w, while the seeds from the other class form a range on each edge of the suffix tree of wR. We will show that given CST (w) and CST (wR) we can compute the representation of all seeds from Lemma 6 in O(n) time. Let us recall auxiliary notions of quasiseed and quasigap, see [19]. By first(u) and last (u) let us denote min Occ(u) and max Occ(u), respectively. We say that u is a complete cover in w if u is a cover of the word w[first (u), last (u) + u − 1]. The word u is called a quasiseed of w if u is a complete cover in w, first(u) < u and n + 1 − last (u) < 2u. Alternatively, w can be decomposed into w = xyz, where x, z < u and u is a cover of y. All quasiseeds of w lying on the same edge of the suffix tree with lower explicit endpoint v form a range with the lower explicit end of the range located at v. The length of the upper end of the range is denoted as quasigap(v). If the range is empty, we set quasigap(v) = ∞. Thus a representation of all quasiseeds of a given word can be provided using only the quasigaps of explicit nodes in the suffix tree. It is known that computation of quasiseeds is the hardest part of an algorithm computing seeds: Lemma 7 ([18, 19]). Assume quasigaps of all explicit nodes of suffix trees of w and wR are known. Then a representation of all seeds of w from Lemma 6 can be found in O(n) time. It turns out that the auxiliary data in CST (w) and CST (wR) enable constant-time computation of quasigaps of explicit nodes. By Lemma 7 this yields an O(n) time algorithm for computing a representation of all the seeds of w. This is stated formally in the following theorem. Theorem 5. Assume that the Cover Suffix Tree of a word of length n can be computed in T (n) time. Given a word w of length n, one can compute a representation of all seeds of w from Lemma 6 in T (n) time. In particular, all the shortest seeds of w can be computed within the same time complexity. Proof. We show how to compute quasigaps for all explicit nodes of CST (w). The computation for CST (wR) is symmetric. Note that CST (w) may contain more explicit nodes that the suffix tree of the word. In this case, the results from any maximal sequence of edges connected by non-branching explicit nodes in CST (w) need to be merged into a single range on the corresponding edge of the suffix tree. 11 By the definition of cv (v), an explicit node v of CST (w) is a complete cover in w if the following condition holds: cv (v) = last (v) − first(v) + v. Thus for checking whether an explicit node v of CST (w) is a quasiseed of w it suffices to check whether this condition and the following equalities hold: first(v) < v, n + 1 − last (v) < 2v. If v is not a quasiseed of w, we have quasigap(v) = ∞, otherwise we can assume that quasigap(v) ≤ v. Example 3. Consider the word w from Fig. 2, n = 15. The word cacc corresponds to an explicit node of CST (w); we denote it by v. We have cv (v) = 11, first(v) = 4, last (v) = 11, and last (v) − first(v) + v = 11. Therefore cacc is a quasiseed of w, see also Fig. 1. By Lemma 1, the condition for any node on the edge ending at v to be a complete cover in w is very simple: ∆(v) = 1. Assume this condition is satisfied and consider any implicit node v′ on this edge. Then v′ is a quasiseed if both inequalities: first(v) < k and n + 1 − last (v) < 2k are satisfied. Thus in this case quasigap(v) = max(first (v) + 1, ⌈(n − last (v) + 2)/2⌉, parent (v) + 1). Example 4. Consider the word w from Fig. 2. The word cccacc corresponds to an explicit node of CST (w); we denote it by v. We have cv (v) = 10, first(v) = 2, last (v) = 6, and last (v) − first (v) + v = 10. Therefore cccacc is a quasiseed of w. Since ∆(v) = 1, quasigap(v) could be smaller than 6. However, ⌈(n − last (v) + 2)/2⌉ = 6 and the above formula yields quasigap(v) = 6. This concludes a complete set of rules for computing quasigap(v) for explicit nodes of CST (w). 7 Conclusions We have presented an algorithm which constructs a data structure, called the Cover Suffix Tree, in O(n log n) time and O(n) space. The Cover Suffix Tree has been developed in order to solve the PartialCovers and AllPartialCovers problem in O(n) and O(n log n) time, respectively, but it also gives a well-structured description of the cover indices of all factors. Consequently, various questions related to partial covers can be answered efficiently. For example, with the Cover Suffix Tree one can solve in linear time a problem inverse to PartialCovers: find a factor of length between l and r that maximizes the number of positions covered. Also a similar problem to AllPartialCovers problem, to compute for all lengths l = 1, . . . , n the maximum number of positions covered by a factor of length l, can be solved in O(n log n) time. This solution was actually given implicitly in the proof of Lemma 3. An interesting open problem is to reduce the construction time to O(n). This could be difficult, though, since by the results of Section 6 this would yield alternative linear-time algorithms finding primitively rooted squares and computing seeds. The only known linear-time algorithms for these problems (see [16, 10, 11] and [19]) are rather complex. 12 References [1] A. Apostolico and A. Ehrenfeucht. Efficient detection of quasiperiodicities in strings. Theor. Comput. Sci., 119(2):247 -- 265, 1993. [2] A. Apostolico, M. Farach, and C. S. Iliopoulos. Optimal superprimitivity testing for strings. Inf. Process. Lett., 39(1):17 -- 20, 1991. [3] A. Apostolico and F. P. Preparata. Data structures and algorithms for the string statistics problem. Algorithmica, 15(5):481 -- 494, 1996. [4] D. Breslauer. An on-line string superprimitivity test. Inf. Process. Lett., 44(6):345 -- 347, 1992. [5] G. S. Brodal, R. B. Lyngsø, A. Ostlin, and C. N. S. Pedersen. Solving the string statistics problem in time O(n log n). In P. Widmayer, F. T. Ruiz, R. M. Bueno, M. Hennessy, S. Eidenbenz, and R. Conejo, editors, ICALP, volume 2380 of Lecture Notes in Computer Science, pages 728 -- 739. Springer, 2002. [6] G. S. Brodal and C. N. S. Pedersen. Finding maximal quasiperiodicities in strings. In R. Giancarlo and D. Sankoff, editors, CPM, volume 1848 of Lecture Notes in Computer Science, pages 397 -- 411. Springer, 2000. [7] M. R. Brown and R. E. Tarjan. A fast merging algorithm. J. ACM, 26(2):211 -- 226, 1979. [8] M. Crochemore, C. Hancart, and T. Lecroq. Algorithms on Strings. Cambridge University Press, 2007. [9] M. Crochemore, L. Ilie, and W. Rytter. Repetitions in strings: Algorithms and combinatorics. Theor. Comput. Sci., 410(50):5227 -- 5235, 2009. [10] M. Crochemore, C. Iliopoulos, M. Kubica, J. Radoszewski, W. Rytter, and T. Wale´n. Extract- ing powers and periods in a word from its runs structure. Theoretical Computer Science, doi: 10.1016/j.tcs.2013.11.018, 2013. [11] M. Crochemore, C. S. Iliopoulos, M. Kubica, J. Radoszewski, W. Rytter, and T. Wale´n. Extracting powers and periods in a string from its runs structure. In E. Ch´avez and S. Lonardi, editors, SPIRE, volume 6393 of Lecture Notes in Computer Science, pages 258 -- 269. Springer, 2010. [12] M. Crochemore and W. Rytter. Jewels of Stringology. World Scientific, 2003. [13] M. Farach. Optimal suffix tree construction with large alphabets. In FOCS, pages 137 -- 143, 1997. [14] T. Flouri, C. S. Iliopoulos, T. Kociumaka, S. P. Pissis, S. J. Puglisi, W. Smyth, and W. Tyczy´nski. Enhanced string covering. Theoretical Computer Science, 506(0):102 -- 114, 2013. [15] A. S. Fraenkel and J. Simpson. How many squares can a string contain? J. Comb. Theory, Ser. A, 82(1):112 -- 120, 1998. [16] D. Gusfield and J. Stoye. Linear time algorithms for finding and representing all the tandem repeats in a string. J. Comput. Syst. Sci., 69(4):525 -- 546, 2004. [17] J. Hershberger. Finding the upper envelope of n line segments in O(n log n) time. Inf. Process. Lett., 33(4):169 -- 174, 1989. [18] C. S. Iliopoulos, D. W. G. Moore, and K. Park. Covering a string. Algorithmica, 16(3):288 -- 297, 1996. [19] T. Kociumaka, M. Kubica, J. Radoszewski, W. Rytter, and T. Wale´n. A linear time algorithm for seeds computation. In Y. Rabani, editor, SODA, pages 1095 -- 1112. SIAM, 2012. [20] R. M. Kolpakov and G. Kucherov. Finding maximal repetitions in a word in linear time. In FOCS, pages 596 -- 604. IEEE Computer Society, 1999. 13 [21] G. Kucherov, Y. Nekrich, and T. A. Starikovskaya. Cross-document pattern matching. In J. Karkkainen and J. Stoye, editors, CPM, volume 7354 of Lecture Notes in Computer Science, pages 196 -- 207. Springer, 2012. [22] Y. Li and W. F. Smyth. Computing the cover array in linear time. Algorithmica, 32(1):95 -- 106, 2002. [23] D. Moore and W. F. Smyth. An optimal algorithm to compute all the covers of a string. Inf. Process. Lett., 50(5):239 -- 246, 1994. [24] J. S. Sim, K. Park, S. Kim, and J. Lee. Finding approximate covers of strings. Journal of Korea Information Science Society, 29(1):16 -- 21, 2002. [25] E. Ukkonen. On-line construction of suffix trees. Algorithmica, 14(3):249 -- 260, 1995. 14
1508.03600
1
1508
2015-08-14T18:38:05
Metric embedding with outliers
[ "cs.DS" ]
We initiate the study of metric embeddings with \emph{outliers}. Given some metric space $(X,\rho)$ we wish to find a small set of outlier points $K \subset X$ and either an isometric or a low-distortion embedding of $(X\setminus K,\rho)$ into some target metric space. This is a natural problem that captures scenarios where a small fraction of points in the input corresponds to noise. For the case of isometric embeddings we derive polynomial-time approximation algorithms for minimizing the number of outliers when the target space is an ultrametric, a tree metric, or constant-dimensional Euclidean space. The approximation factors are 3, 4 and 2, respectively. For the case of embedding into an ultrametric or tree metric, we further improve the running time to $O(n^2)$ for an $n$-point input metric space, which is optimal. We complement these upper bounds by showing that outlier embedding into ultrametrics, trees, and $d$-dimensional Euclidean space for any $d\geq 2$ are all NP-hard, as well as NP-hard to approximate within a factor better than 2 assuming the Unique Game Conjecture. For the case of non-isometries we consider embeddings with small $\ell_{\infty}$ distortion. We present polynomial-time \emph{bi-criteria} approximation algorithms. Specifically, given some $\epsilon > 0$, let $k_\epsilon$ denote the minimum number of outliers required to obtain an embedding with distortion $\epsilon$. For the case of embedding into ultrametrics we obtain a polynomial-time algorithm which computes a set of at most $3k_{\epsilon}$ outliers and an embedding of the remaining points into an ultrametric with distortion $O(\epsilon \log n)$. For embedding a metric of unit diameter into constant-dimensional Euclidean space we present a polynomial-time algorithm which computes a set of at most $2k_{\epsilon}$ outliers and an embedding of the remaining points with distortion $O(\sqrt{\epsilon})$.
cs.DS
cs
Metric embeddings with outliers Yusu Wang† Anastasios Sidiropoulos∗ Abstract We initiate the study of metric embeddings with outliers. Given some metric space (X, ρ) we wish to find a small set of outlier points K ⊂ X and either an isometric or a low-distortion embedding of (X \ K, ρ) into some target metric space. This is a natural problem that captures scenarios where a small fraction of points in the input corresponds to noise. For the case of isometric embeddings we derive polynomial-time approximation algorithms for minimizing the number of outliers when the target space is an ultrametric, a tree metric, or some constant-dimensional Euclidean space. The approximation factors are 3, 4 and 2, respectively. For the case of embedding into an ultrametric or tree metric, we further improve the running time to O(n2) for an n-point input metric space, which is optimal. We complement these upper bounds by showing that outlier embedding into ultrametrics, trees, and d-dimensional Euclidean space for any d ≥ 2 are all NP-hard, as well as NP-hard to approximate within a factor better than 2 assuming the Unique Game Conjecture. For the case of non-isometries we consider embeddings with small (cid:96)∞ distortion. We present polynomial-time bi-criteria approximation algorithms. Specifically, given some ε > 0, let kε denote the minimum number of outliers required to obtain an embedding with distortion ε. For the case of embedding into ultrametrics we obtain a polynomial-time algorithm which computes a set of at most 3kε outliers and an embedding of the remaining points into an ultrametric with distortion O(ε log n). Finally, for embedding a metric of unit diameter into constant-dimensional Euclidean space we present a polynomial-time algorithm which computes a set of at most 2kε outliers and an embedding of the remaining points with distortion O(√ε). 5 1 0 2 g u A 4 1 ] S D . s c [ 1 v 0 0 6 3 0 . 8 0 5 1 : v i X r a ∗Dept. of Computer Science and Engineering and Dept. of Mathematics, The Ohio State University. Columbus, OH, USA. Supported by NSF grants CCF 1423230 and CAREER 1453472. †Dept. of Computer Science and Engineering, The Ohio State University. Columbus, OH, USA. The work is partially supported by NSF under grant CCF-1319406. 1 Introduction Metric embeddings provide a framework for addressing in a unified manner a variety of data-analytic tasks. Let X = (X, ρ), Y = (Y, ρ(cid:48)) be metric spaces. At the high level, a metric embedding is a mapping f : X → Y that either is isometric or preserves the pairwise distances up to some small error called the distortion 1. The corresponding computational problem is to decide whether an isometry f exists or, more generally, to find a mapping f with minimum distortion. The space Y might either be given or it might be constrained to be a member of a collection of spaces, such as trees, ultrametrics, and so on. The problems that can be geometrically abstracted using this language include phylogenetic reconstruction (e.g. via embeddings into trees [1, 2, 11] or ultrametrics [20, 4]), visualization (e.g. via embeddings into constant-dimensional Euclidean space [8, 21, 10, 32, 19, 9, 17, 22]), and many more (for a more detailed exposition we refer the reader to [26, 25]). Despite extensive research on the above metric embedding paradigm, essentially nothing is known when the input space X can contain outliers. This scenario is of interest for example in applications where outliers can arise from measurement errors. Another example is when real-world data does not perfectly fit a model due to mathematical simplifications of physical processes. We propose a generalization of the above high-level metric embedding problem which seeks to address such scenarios: Given X and Y we wish to find some small K ⊆ X and either an isometric or low-distortion mapping f : X \ K → Y . We refer to the points in K as outliers. We remark that it is easy to construct examples of spaces X , Y where any embedding f : X → Y has arbitrarily large distortion (for any “reasonable” notion of distortion), yet there exists x ∈ X and an isometry f : X \ {x} → Y . Thus new ideas are needed to tackle the more general metric embedding problem in the presence of outliers. 1.1 Our contribution Approximation algorithms. We focus on embeddings into ultrametrics, trees, and constant- dimensional Euclidean space. We first consider the problem of computing a minimum size set of outliers such that the remaining point-set admits an isometry into some target space. We refer to this task as the minimum outlier embedding problem. Outlier embeddings into ultrametrics. It is well-known that a metric space is an ultrametric if and only if any 3-point subset is an ultrametric. We may therefore obtain a 3-approximation as follows: For all (x, y, z) ∈ X 3, if the triple (x, y, z) is not an ultrametric then remove x, y, and z from X. It is rather easy to see that this gives a 3-approximation for the minimum outlier embedding problem into ultrametrics (as for every triple of points that we remove, at least one of them must be an outlier in any optimal solution), with running time O(n3). By exploiting further structural properties of ultrametrics, we obtain a 3-approximation with running time O(n2). We remark that this running time is optimal since the input has size Θ(n2) and it is straightforward to show that any 3-approximation has to read all the input (e.g. even to determine whether X is an ultrametric, which corresponds to the case where the minimum number of outliers is zero). Outlier embeddings into trees. Similarly to the case of ultrametrics, it is known that a space is a tree metric if and only if any 4-point subset is a tree metric. This similarly leads to a 4- approximation algorithm in O(n4) time. We further improve the running time to O(n2), which is 1Various definitions of distortion have been extensively considered, including multiplicative, additive, average, and (cid:96)p distortion, as well as expected distortion when the map f is random [6]. 1 also optimal. However, obtaining this improvement is significantly more complicated than the case of ultrametrics. Outlier embeddings into Rd. It is known that for any d ≥ 1 any metric space admits an isometric embedding into d-dimensional Euclidean space if and only if any subset of size d + 3 does [33]. This immediately implies a (d + 3)-approximation algorithm for outlier embedding into d-dimensional Euclidean space with running time O(nd+3), for any d ≥ 1. Using additional rigidity properties of Euclidean space we obain a 2-approximation with the same running time. Hardness of approximation. We show that, assuming the Unique Games Conjecture [28], the problems of computing a minimum outlier embedding into ultrametrics, trees, and d-dimensional Euclidean space for any d ≥ 2, are all NP-hard to approximate within a factor of 2 − ν, for any ν > 0. These inapproximability results are obtained by combining reductions from Vertex Cover to minimum outlier embedding and the known hardness result for the former problem [29]. Note that for the case of embedding into d-dimensional Euclidean space for any d ≥ 2 this inapproximability result matches our upper bound. Bi-criteria approximation algorithms. We also consider non-isometric embeddings. All our results concern (cid:96)∞ distortion. For some outlier set K ⊆ X, the (cid:96)∞ distortion of some map f : X \ K → Y is defined to be (cid:12)(cid:12)ρ(x, y) − ρ(cid:48)(f (x), f (y))(cid:12)(cid:12) . sup x,y∈X\K In this context there are two different objectives that we wish to minimize: the number of outliers and the distortion. For a compact metric space Z = (Z, ρZ), denote by ∆(Z) = supz,z(cid:48)∈Z ρZ(z, z(cid:48)) the diameter of Z. Definition 1.1 ((ε, k)-Outlier embedding). We say that X admits a (ε, k)-outlier embedding into Y if there exists K ⊂ X with K ≤ k and some f : X \ K → Y with (cid:96)∞ distortion at most ε∆(X ). We refer to K as the outlier set that witnesses a (ε, k)-outlier embedding of X. Note that the multiplication of the distortion by ∆(X) is to make the parameter ε scale-free. Since an isometry can be trivially achieved by removing all but one points; thus the above notion is well-defined for all ε > 0. We now state our main results concerning bi-criteria approximation: Bi-criteria outlier embeddings into ultrametrics: We obtain a polynomial-time algorithm which given an n-point metric space X and some ε > 0 such that X admits a (ε, k)-outlier embedding into an ultrametric, outputs a O(ε log n, 3k)-outlier embedding into an ultrametric. Bi-criteria outlier embeddings into Rd: We present an algorithm which given an n-point metric space X and some ε > 0 such that X admits a (ε, k)-outlier embedding in Rd, outputs a (O(√ε), 2k)- outlier embedding of X into Rd. The algorithm runs in time O(nd+3). Bi-criteria outlier embeddings into trees: Finally we mention that one can easily derive a bi- criteria approximation for outlier embedding into trees by the work of Gromov on δ-hyperbolicity [23] (see also [14]). Formally, there exists a polynomial-time algorithm which given a metric space X and some ε > 0 such that X admits a (ε, k)-outlier embedding into a tree, outputs a (O(ε log n), 4k)- outlier embedding into a tree. Let us briefly outline the proof of this result: δ-hyperbolicity is a four-point condition such that any δ-hyperbolic space admits an embedding into a tree with (cid:96)∞ distortion O(δ log n), and such an embedding can be computed in polynomial time. Any metric that admits an embedding into a tree with (cid:96)∞ distortion ε is O(ε)-hyperbolic. Thus by removing all 2 4-tuples of points that violate the O(ε)-hyperbolicity condition and applying the embedding from [23] we immediately obtain an (O(ε log n), 4k)-outlier embedding into a tree. We omit the details. 1.2 Previous work Over the recent years there has been a lot work on approximation algorithms for minimum distortion embeddings into several host spaces and under various notions of distortion. Perhaps the most well-studied case is that of multiplicative distortion. For this case, approximation algorithms and inapproximability results have been obtained for embedding into the line [34, 10, 8, 22], constant- dimensional Euclidean space [9, 17, 19, 32, 10], trees [11, 15], ultrametrics [4], and other graph- induced metrics [15]. We also mention that similar questions have been considered for the case of bijective embeddings [35, 24, 27, 19, 30]. Analogous questions have also been investigated for average [18], additive [5], (cid:96)p [2], and (cid:96)∞ distortion [20, 1]. Similar in spirit with the outlier embeddings introduced in this work is the notion of embeddings with slack [12, 13, 31]. In this scenario we are given a parameter ε > 0 and we wish to find an embedding that preserves (1 − ε)-fraction of all pairwise distances up to a certain distortion. We remark however that these mappings cannot in general be used to obtain outlier embeddings. This is because typically in an embedding with slack the pairwise distances that are distorted arbitrarily involve a large fraction of all points. 1.3 Discussion Our work naturally leads to several directions for further research. Let us briefly discuss the most prominent ones. An obvious direction is closing the gap between the approximation factors and the inapprox- imability results for embedding into ultrametrics and trees. Similarly, it is important to understand whether the running time of the 2-approximation for embedding into Euclidean space can be im- proved. More generally, an important direction is understanding the approximability of outlier embeddings into other host spaces, such as planar graphs and other graph-induced metrics. In the context of bi-criteria outlier embeddings, another direction is to investigate different notions of distortion. The case of (cid:96)∞ distortion studied here is a natural starting point since it is very sensitive to outliers. It seems promising to try to adapt existing approximation algorithms for (cid:96)p, multiplicative, and average distortion to the outlier case. Finally, it is important to understand whether improved guarantees or matching hardness results for bi-criteria approximations are possible. 2 Definitions A metric space is a pair X = (X, ρ) where X is a set and ρ : X × X → R≥0 such that (i) for any x, y ∈ X, ρ(x, y) = ρ(y, x) ≥ 0, (ii) ρ(x, y) = 0 if and only if x = y, and (iii) for any x, y, z ∈ X, ρ(x, z) ≤ ρ(x, y) + ρ(y, z). Given two metric spaces X = (X, ρX ) and Y = (Y, ρY ), an embedding of X into Y is simply a map ϕ : X → Y , and ϕ is an isometric embedding if for any x, x(cid:48) ∈ X, ρX (x, x(cid:48)) = ρY (ϕ(x), ϕ(x(cid:48))). In this paper our input is an n-point metric (X, ρ), meaning that X is a discrete set of cardinality n. Given an n-point metric space X = (X, ρ) and a value α ≥ 0, we denote by X + α the metric space (X, ρ(cid:48)) where for any x (cid:54)= y ∈ X we have ρ(cid:48)(x, y) = ρ(x, y) + α. 3 Definition 2.1 (Ultrametric space). A metric space (X, ρ) is an ultrametric (tree) space if and only if the following three-point condition holds for any x, y, z ∈ X: ρ(x, y) ≤ max{ρ(x, z), ρ(z, y)}. (1) Definition 2.2 (Tree metric). A metric space (X, ρ) is a tree metric if and only if the following four-point condition holds for any x, y, z, w ∈ X: ρ(x, y) + ρ(z, w) ≤ max{ρ(x, z) + ρ(y, w), ρ(x, w) + ρ(y, z)}. (2) An equivalent formulation of the four-point condition is that for all x, y, z, w ∈ X, the largest two quantities of the following three terms are equal: ρ(x, y) + ρ(z, w), ρ(x, z) + ρ(y, w), ρ(x, w) + ρ(y, z). (3) In particular, an n-point tree metric (X, ρ) can be realized by a weighted tree T such that there is a map ϕ : X → V (T ) into the set of nodes V (T ) of T , and that for any x, y ∈ X, the shortest path distance dT (ϕ(x), ϕ(y)) in T equals ρ(x, y). In other words, ϕ is an isometric embedding of (X, ρ) into the graphic tree metric (T, dT ). An ultrametric (X, ρ) is in fact a special case of tree metric, where there is an isometric embedding ϕ : X → V (T ) to a rooted tree (T, dT ) such that ϕ(X) are leaves of T and all leaves are at equal distance from the root of T . 3 Approximation algorithms for outlier embeddings In this section we present approximation algorithms for the minimum outlier embedding problem for three types of target metric spaces: ultrametrics, tree metrics, and Euclidean metric spaces. We show in Appendix B that finding optimal solutions for each of these problems is NP-hard (and roughly speaking hard to approximate within a factor of 2 as well). In the cases of ultrametric and tree metrics, it is easy to approximate the minimum outlier embedding within constant factor in O(n3) and O(n4) time, respectively. The key challenge (especially for embedding into tree metric) is to improve the time complexity of the approximation algorithm to O(n2), which is optimal. 3.1 Approximating outlier embeddings into ultrametrics Theorem 3.1. Given an n-point metric space (X, ρ), there exists a 3-approximation algorithm for minimum outlier embedding into ultrametrics, with running time O(n2). Proof. We can obtain a polynomial-time 3-approximation algorithm as follows: For each triple of points (x, y, z) ∈ X 3, considered in some arbitrary order, check whether it satisfies (1). If not, then remove x, y, and z from X and continue with the remaining triples. Let K be the set of removed points. For every triple of points removed, at least one must be in any optimal solution; therefore the resulting solution K is a 3-approximation. The running time of this method is O(n3). We next show how to improve the running time to O(n2). Let X = {x1, . . . , xn}. We inductively compute a sequence X0, . . . , Xn ⊆ X, where X0 is set to be X0 = ∅. Given Xi−1 for some i ∈ {1, . . . , n}, assuming the invariance that Xi−1 is an ultrametric, we compute Xi as follows. We check whether (Xi−1 ∪{xi}, ρ) is an ultrametric. If it is, then we set Xi = Xi−1 ∪ {xi}. Otherwise, there must exist (x, y, z) ∈ (Xi−1 ∪ {xi})3 that violates (1). Since 4 i be a nearest neighbor of xi in Xi−1, that is x∗ (Xi−1, ρ) is an ultrametric, it follows that every such triple must contain xi. Therefore it suffices to show how to quickly find y, z ∈ Xi−1 such that (xi, y, z) violates (1), if they exist. To this end, let x∗ i = argminx∈Xi−1{ρ(xi, x)}, where we brake ties arbitrarily. Instead of checking xi against all possible y, z from Xi−1, we claim that (1) holds for all (xi, y, z) with y, z ∈ Xi−1 if and only if for all w ∈ Xi−1 we have (4) (i) ρ(xi, x∗ i ) ≤ max{ρ(xi, w), ρ(x∗ i , w)} and (ii) ρ(xi, w) = ρ(x∗ i , w). i , y) and ρ(xi, z) = ρ(x∗ Indeed, assume that (i) and (ii) above hold for all w ∈ Xi−1, yet there exist some y, z ∈ Xi−1 such that (xi, y, z) violates (1), say w.l.o.g., ρ(xi, y) > max{ρ(xi, z), ρ(y, z)}. Then by (ii) above, we have ρ(xi, y) = ρ(x∗ i , z), ρ(y, z)}. Hence (x∗ i , y, z) also violates (1), contradicting the fact that (Xi−1, ρ) is an ultrametric. Hence no such y, z can exist, and (10) is sufficient to check whether Xi−1 ∪ {xi} induces an ultrametric or not. Finally, we can clearly check in time O(n) whether both conditions in (10) hold for all w ∈ Xi−1. If either (i) or (ii) in (10) fails then (xi, x∗ i , z), implying that ρ(x∗ i , w) violates (1), which concludes the proof. i , y) > max{ρ(x∗ 3.2 Approximating outlier embeddings into trees We now present a 4-approximation algorithm for embedding a given n-point metric space into a tree metric with a minimum number of outliers. Using the four-point condition (2) in Definition 2.2, it is fairly simple to obtain a 4-approximation algorithm for the problem with running time O(n4) as follows: Check all 4-tuples of points x, y, z, w ∈ X. If the 4-tuple violates the four-point condition, then remove x, y, z, w from X. It is immediate that for any such 4-tuple, at least one of its points much be an outlier in any optimal solution. It follows that the result is a 4-approximation. We next show how to implement this approach in time O(n2). The main technical difficult is in finding a set of violating 4-tuples quickly. The high-level description of the algorithm is rather simple, and is as follows. Let (X, ρ) be the input metric space where X = {x1, . . . , xn}. Set X1 = {x1}. For any i = 2, . . . , n, we inductively define Xi ⊆ X. At the beginning of the i-th iteration, we maintain the invariance that (Xi−1, ρ) is a tree metric. If (Xi−1 ∪ {xi}, ρ) is a tree metric, then we set Xi = Xi−1 ∪ {xi}. Otherwise there must exist yi, zi, wi ∈ Xi−1 such that the 4-tuple (xi, yi, zi, wi) violates the four-point condition; we set Xi = Xi−1 \ {yi, zi, wi}. To implement this idea in O(n2) time, it suffices to show that for any i = 2, . . . , n, given Xi−1, we can compute Xi in time O(n). The algorithm will inductively compute a collection of edge- weighted trees T1, . . . , Tn, with T1 simply being the graph with V (T1) = {x1}, and maintain the following invariants for each i ∈ [1, n]: (I-1) Xi ⊆ V (Ti) and all leaves of Ti are in Xi. (Xi, ρ) embeds isometrically into (Ti, dTi); that is, (I-2) At the i-th iteration either Xi = Xi−1 ∪ {xi} or Xi = Xi−1 \ {y, z, w} where the 4-tuple ⊆ X, let T be a tree with V (T ) ∩ X = X(cid:48). Given Definition 3.2 (Leaf augmentation). Given X(cid:48) a ∈ X \ X(cid:48) and u, v ∈ X(cid:48), the a-leaf augmentation of T at {u, v} is the tree T (cid:48) obtained as follows. Let P be the path in T between u and v (which may contain a single vertex if u = v). Set r = (ρ(a, u) + ρ(a, v) − ρ(u, v))/2. Let s be a vertex in P with dP (s, u) = ρ(a, u) − r; if no such vertex exists then we introduce a new such vertex s by subdividing the appropriate edge in P the shortest-path metric of Ti agrees with ρ on Xi: for any x, y ∈ Xi, dTi(x, y) = ρ(x, y). {xi, y, z, w} violates the four-point condition under metric ρ. 5 and update the edge lengths accordingly. In the resulting tree T (cid:48) we add the vertex a and the edge {a, s} if they do no already exist, and we set the length of {a, s} to be r. We call s the stem of a (w.r.t. the leaf augmentation). When u = v we say that T (cid:48) is the a-leaf augmentation of T at u, in which case T (cid:48) is obtained from T simply by adding a as a leaf attached to u, and u is the stem of a. In what follows, we set x∗ i to be the nearest neighbor of xi in Xi−1, that is x∗ i = argmin x∈Xi−1 ρ(x, xi), where we break ties arbitrarily. Intuitively, if we can build a new tree T (cid:48) from Ti−1 so that (Xi−1 ∪ {xi}, ρ) can be isometrically embedded in T (cid:48), then T (cid:48) is a xi-leaf augmentation of Ti−1 at some pair {x∗ i , u}. Our approach will first compute an auxiliary structure, called xi-orientation on Ti−1, to help us identify a potential leaf augmentation. We next check for the validity of this leaf augmentation. The key is to produce this candidate leaf augmentation such that if it is not valid, then we will be able to find a 4-tuple violating the four-point condition from it quickly. Definition 3.3 ((a, u, v)-orientation). Let X(cid:48) ⊆ X and let T be a tree with V (T ) ∩ X = X(cid:48). Let a ∈ X \ X(cid:48) and u, v ∈ X(cid:48). The (a, u, v)-orientation of T is a partially oriented tree (cid:126)T obtained as follows: Let T (cid:48) be the a-leaf augmentation of T at {u, v}, and let a(cid:48) be the stem of a. We orient every edge in Puv ∩ E(T (cid:48)) towards a(cid:48), where Puv is the unique path in T between u and v. All other edges in E(T ) \ Puv remain unoriented. If E(T ) (cid:54)= E(T (cid:48)) then there exists a unique edge in e ∈ Puv \ E(T (cid:48)) (which is subdivided in T (cid:48)); this edge e remains undirected in (cid:126)T . We call this edge the sink edge w.r.t. {u, v}. If there is no sink edge, then there is a unique vertex in Puv with no outgoing edges in Puv, which we call the sink vertex w.r.t. {u, v}. Note that the sink is the simplex of smallest dimension that contains the stem of a w.r.to the leaf augmentation at {u, v}. See the right figure for an example: where s is stem of a in the leaf augmentation at {u, v}. The thick path Puv is oriented, other than the sink edge (the one that contains the stem s). Definition 3.4 (xi-orientation). An xi-orientation of Ti−1 is any partial ori- entation (cid:126)Ti−1 of Ti−1 obtained via the following procedure: Consider any or- dering of Xi−1, say {v1, v2, . . . , v(cid:96)} = Xi−1. Start with (cid:126)Ti−1 = Ti−1, i.e. all edges in (cid:126)Ti−1 are initialized as undirected and we will iteratively modify their orientation. Process vertices v1, . . . , v(cid:96) in this order. For each vj, denote by Pj the path in Ti−1 between vj and x∗ i or an edge which is already visited. For each unoriented edge we visit, we set its orientation to be the one in the (xi, vj, x∗ i )-orientation of Ti−1. An edge that is visited in the above process is called masked. Since the above procedure is performed for all leaves of Ti−1, an xi-orientation will mask all edges. However, a masked edge may not be oriented, in which case this edge must be the sink edge i . Traverse Pj starting from vj until we reach either x∗ i} for some vj ∈ Xi−1. w.r.t. {vj, x∗ Definition 3.5 (Sinks). Given an xi-orientation (cid:126)T of tree T , a sink is either an un-oriented edge, or a vertex v ∈ V (T ) such that all incident edges have an orientation toward v. The former is also called a sink edge w.r.t. (cid:126)T and the latter a sink vertex w.r.t. (cid:126)T . It can be shown that each sink edge/vertex must be a sink edge/vertex w.r.t. {vj, x∗ vj ∈ Xi−1, and we call vj a generating vertex for this sink. i} for some 6 uvsa An xi-orientation may have multiple sinks. We further augment the xi- orientation to record a generating vertex vj for every sink (there may be multiple choices of vj for a single sink, and we can take an arbitrary one). We also re- i} may not ultimately be a sink for the global xi-orientation: see the right figure for an example, where s is a sink vertex w.r.t. mark that a sink w.r.t. some {vj, x∗ {vj, x∗ i}, but not a sink vertex for the global xi-orientation. The proofs of the following two results can be found in Appendix A. Lemma 3.6. An xi-orientation of Ti−1 (together with a generating vertex for each sink) can be computed in O(i) time. Lemma 3.7. Any xi-orientation (cid:126)Ti−1 of Ti−1 has at least one sink. (a) (b) (c) Figure 1: (a) An illustration for Case 1 in Lemma 3.8. Solid edges are from Ti−1 and the dotted edge connecting xi to its stem s is in L. (b) Case 2 when y = s. (c) If ρ(xi, w) > dL(xi, w), then we can find z the processing of which during the construction of (cid:126)Ti−1 assigns the orientation of edge (y, y(cid:48)). Lemma 3.8. For any i ∈ {2, . . . , n}, given Ti−1, we can compute Ti and Xi satisfying invariants (I-1) and (I-2) in O(i) time. Proof. It suffices to show that in O(i) time we can either find a 4-tuple of points in Xi−1 ∪ {xi}, that violates the four-point condition, or we can compute a tree having a shortest-path metric that agrees with ρ on Xi−1 ∪ {xi}. By Lemma 3.6, we can compute an x-orientation (cid:126)Ti−1 of Ti−1 in O(i) time. Consider any sink of (cid:126)Ti−1 (whose existence is guaranteed by Lemma 3.7), and let u be its associated generating vertex; u must be in Xi−1. Let L be the xi-leaf augmentation of Ti−1 at {x∗ i , u}, and let dL denote the shortest path metric on the tree L. ∈ Xi−1, dL(w, w(cid:48)) = dTi−1(w, w(cid:48)) = Since L is the xi-leaf augmentation of T , we have for all w, w(cid:48) ρ(w, w(cid:48)) (the last quality is because (Xi−1, ρ) embeds isometrically into Ti−1). Thus dL may only disagree with ρ on pairs of points xi, v, for some v ∈ Xi−1. We check in O(i) time if, for all v ∈ Xi−1, we have dL(xi, v) = ρ(xi, v) via a traveral of L starting from the stem of xi in L. If the above holds, then obviously (Xi−1 ∪ {xi}, ρ) embeds isometrically into L. We then set Xi = Xi−1 ∪ {xi} and output Ti = L. Otherwise, let w ∈ Xi−1 be such that dL(xi, w) (cid:54)= ρ(xi, w). We now show that we can find a 4-tuple including xi that violates the four-point condition in constant time. i and let y ∈ V (L) be the lowest common ancester of u and w. Note that y must be a vertex from V (Ti−1) too. Let Pvv(cid:48) denote the unique path in L between any two v and v(cid:48). The vertex y must be in the path Pux∗ Let s be the stem of xi in L. Consider L as rooted at x∗ . i 7 x∗ivjsvkx∗iusywxix∗ius=ywxix∗ius=ywxizy0 Case 1: y (cid:54)= s. In this case, y is either in the interior of path Psu or of path Psx∗ . Assume w.o.l.g. that y is in the interior of Psu; the handling of the other case is completely sym- metric. See Figure 1 (a) for an illustration. Since dL is a tree metric, we know that the i , u, w} should satisfy the four-point condition under the metric dL. Using the alternative formulation of four-point condition in Definition 2.2, we have that the largest two quantities of the following three terms should be equal: 4-tuple {xi, x∗ i dL(xi, x∗ i ) + dL(u, w), dL(xi, u) + dL(x∗ i , w), dL(xi, w) + dL(x∗ i , u). For this specific configuration of y, we further have: i ) + dL(u, w) < dL(xi, u) + dL(x∗ dL(xi, x∗ i , w) = dL(xi, w) + dL(x∗ i , u). (5) (6) On the other hand, by construction, we know that dL agrees with ρ on Xi−1. Furthermore, since L is the xi-leaf augmentation of Ti−1 at {u, x∗ i}, we have that dL(xi, u) = ρ(xi, u) and dL(xi, x∗ i ). Hence (6) can be rewritten as i ) + ρ(u, w) < ρ(xi, u) + ρ(x∗ i , w) = dL(xi, w) + ρ(x∗ i ) = ρ(xi, x∗ ρ(xi, x∗ i , u). (7) If ρ(xi, w) (cid:54)= dL(xi, w), then the largest two quantities of ρ(xi, x∗ i ) + ρ(u, w), ρ(xi, u) + ρ(x∗ i , w), ρ(xi, w) + ρ(x∗ i , u) can no longer be equal as ρ(xi, x∗ {xi, x∗ i , u, w} violates the four-point condition under the metric ρ (by using (3)). Case 2: y = s, in which case s must be a sink vertex: see Figure 1 (b) for an illustration. For this i ) + ρ(u, w) < ρ(xi, u) + ρ(x∗ i , w). Hence the 4-tuple configuration of y, it is necessary that ρ(xi, x∗ i ) + ρ(u, w) = ρ(xi, u) + ρ(x∗ Hence if ρ(xi, w) > dL(xi, w), then the 4-tuple {xi, x∗ i ) + ρ(u, w) = ρ(xi, u) + ρ(x∗ under the metric ρ because ρ(xi, x∗ i , w) = dL(xi, w) + ρ(x∗ i , u). (8) i , u, w} violates the four-point condition i , w) < ρ(xi, w) + ρ(x∗ i , u). What remains is to find an violating 4-tuple for the case when ρ(xi, w) < dL(xi, w). i , w))/2. In the augmented tree L, dL(xi, y) = (ρ(xi, x∗ i} necessarily lies in Pwy in Ti−1. Let rw = (ρ(xi, x∗ Now imagine performing the xi-leaf augmentation of Ti−1 at {w, x∗ i}. We first argue that the stem s(cid:48) of xi w.r.t. {w, x∗ i ) + ρ(xi, w) − ρ(x∗ i , u))/2. Combing (8) and ρ(xi, w) < dL(xi, w) we have that rw < dL(xi, y). On the other hand, following Definition 3.2, the position of s(cid:48) is such that dTi−1(x∗ i , xi) − rw, while the position of y = s was that dTi−1(x∗ i , xi) − dL(xi, y). It then follows that s(cid:48) must lie in the i , s) = ρ(x∗ interior of path Pwy. Since the stem of xi w.r.t. {w, x∗ i} is in Pwy, it means that before we process w in the construction of the xi-orientation (cid:126)Ti−1, there must exist some other leaf z ∈ V (Ti−1) such that the process of z assigns the orientation of the edge (y, y(cid:48)) ⊂ Pwy to be towards y; See Figure 1 (c). This is because if no such z exists, then while processing w, we would have i ) + ρ(xi, u)− ρ(x∗ i , s(cid:48)) = ρ(x∗ 8 oriented the edge (y, y(cid:48)) towards stem s(cid:48), thus towards y(cid:48), as the stem s(cid:48) is in Pwy(cid:48). The point z can be identified in constant time if during the construction of (cid:126)Ti−1, we also remember, for each edge, the vertex the processing of which leads to orienting this edge. Such information can be easily computed in O(i) time during the construction of (cid:126)Ti−1. Now consider z. If dL(xi, z) = ρ(xi, z), then one can show that y = s is necessarily the stem for xi w.r.t. {xi, z} as well (by simply computing the position of the stem using Definition 3.2). In this case, considering the 4-tuple {xi, x∗ i , z, w}, we are back to Case 1 (but for this new 4-tuple), which in turn means that this 4-tuple violates the four-point condition. Hence we are done. i If dL(xi, z) (cid:54)= ρ(xi, z), then since we orient the edge (y, y(cid:48)) towards y during the process of leaf z, the stem of xi of the leaf augmentation at {xi, z} is in the path Pyx∗ . By an argument similar to the proof that s(cid:48) is in the interior of Pwy above, we can show that ρ(xi, z) > dL(xi, z). Now consider the 4-tuple {xi, x∗ i , z, u}: this leads us to an analogous case when ρ(xi, w) > dL(xi, w) for the 4-tuple {xi, x∗ i , u, w}. Hence by a similar argument as at the beginning of Case 2, we can show that {xi, x∗ i , z, u} violates the four-point condition under metric ρ. i , u, w}, {xi, x∗ in either case, we can identify a 4-tuple U , which could be {xi, x∗ i , z, u} as shown above, that violates the four-point condi- tion under metric ρ. We simply remove these four points, adjust the resulting tree to obtain Ti and set Xi = Xi−1 \ U . The overall algorithm takes O(i) time as claimed. This proves the lemma. Theorem 3.9. There exists a 4-approximation algorithm for minimum outlier embedding into trees, with running time O(n2). i , z, w}, or {xi, x∗ Putting everything together, Proof. By Lemma 3.8 and induction on i = 1, . . . , n, it follows immediately that we can compute Tn in time O(n2). By invariant (I-1), the output (Xn, ρ) is a tree metric as it can be isometrically embedded into Tn. Furthermore, by invariant (I-2), each 4-tuple of points we removed forms a violation of the four-point condition, and thus must contain at least one point from any optimal outlier set. As such, the total number of points we removed can be at most four times the size of the optimal solution. Hence our algorithm is a 4-approximation as claimed. 3.3 Approximating outlier embeddings into Rd In this section, we present a 2-approximation algorithm for the minimum outlier embedding problem into the Euclidean space Rd in polynomial time, which matches our hardness result in Appendix B. Given two points p, q ∈ Rd, let dE(p, q) = (cid:107)p − q(cid:107)2 denote the Euclidean distance between p and q. Definition 3.10 (d-embedding). Given a discrete metric space X = (X, ρ), an d-embedding of X is simply an isometric embedding ϕ : X → Rd of X into (Rd, dE); that is, for any x, y ∈ X, ρ(x, y) = dE(ϕ(x), ϕ(y)). We say that X is strongly d-embeddable if it has a d-embedding, but cannot be isometrically embedded in Rd−1. In this case, d is called the embedding dimension of X . The following is a classic result in distance geometry of Euclidean spaces, see e.g [7, 37]. Theorem 3.11. The metric space X = (X, ρ) is strongly d-embeddable in Rd if and only if there exist d + 1 points, say Xd = {x0, . . . , xd}, such that: (i) (Xd, ρ) is strongly d-embeddable; and (ii) for any x, x(cid:48) ∈ X \ Xd, (Xd ∪ {x, x(cid:48) }, ρ) is d-embeddable. 9 Furthermore, given an m-point metric space (X, ρ), it is known that one can decide whether (X, ρ) is embeddable in some Euclidean space by checking whether a certain m× m matrix derived from the distance matrix ρ is positive semi-definite, and the rank of this matrix gives the embedding dimension of X ; see e.g. [36]. Following Theorem 3.11, one can easily come up with a (d + 3)-approximation algorithm for minimum outlier embedding into Rd, by simply checking whether each (d + 3)-tuple of points is d- embeddable, and if not, removing all these d+3 points. Our main result below is an 2-approximation algorithm within the same running time. In particular, Algorithm 1 satisfies the requirements of Theorem 3.12, and the proof is in Appendix A. Theorem 3.12. Given an n-point metric space (X, ρ), for any d ≥ 1, there exists 2-approximation algorithm for minimum outlier embedding into Rd, with running time O(nd+3). Algorithm 1 2-approximation outlier embedding in Rd. Input: An n-point metric space (X, ρ) Output: A set of outliers (cid:98)K If yes, insert x to Z; otherwise, insert x to the outlier set K. ≤ d. Initialize the set of candidate outlier sets C to be empty. Initialize sets Z and K to be the empty set. (Step-0) For each d + 1 number of distinct points Yd = {y0, . . . , yd} ⊂ X, perform the following: (Step-1) Check whether (Yd, ρ) is d-embeddable in Rd: If not, return to (Step-0). Otherwise, compute its embedding dimension d(cid:48); note, d(cid:48) (Step-2) For each remaining point x ∈ X \ Yd, check whether (Yd ∪ {s}, ρ) is d(cid:48)-embeddable: (Step-3) Construct a graph G = (Z, E), where (z, z(cid:48)) ∈ E if (Yd ∪ {z, z(cid:48) }, ρ) is not d(cid:48)- ⊂ Z of the vertex cover of G. Set K = K ∪ Z(cid:48), embeddable. Compute a 2-approximation Z(cid:48) (Step-4) Let (cid:98)K be the set from C with smallest cardinality. We return (cid:98)K as the outlier set. and we add the set K to the collection of candiate outlier sets C. Hardness results. In Appendix B, we show that the minimum outlier embedding problems into ultrametrics, trees and Euclidean space are all NP-hard, by reducing the Vertex Cover problem to them in each case. In fact, assuming the unique game conjecture, it is NP-hard to approximate each of them within 2 − ν, for any positive ν. For the case of minimum outlier embedding into Euclidean space, we note that our 2-approximation algorithm above matches the hardness result. 4 Bi-criteria approximation algorithms 4.1 Bi-criteria approximation for embedding into ultrametrics Let T = (X, E) be a tree with non-negative edge weights. The ultrametric induced by T is the ultrametric U = (X, δ) where for every x, y ∈ X we have that δ(x, y) is equal to the maximum weight of the edges in the unique x-y path in T (it is easy to verify that the metric constructed as such is indeed an ultrametric [20]). Given an metric space X = (X, ρ), we can view it as a weighted graph and talk about its minimum spanning tree (MST). The following result is from [20]. 10 ∗ ∗ Lemma 4.1 (Farach, Kannan and Warnow [20]). Let X = (X, ρ) be a metric space and let U an ultrametric minimizing (cid:107)X − U exists α ≥ 0, such that U (cid:107)∞. Let (cid:98)U be ultrametric induced by a MST of X . Then there ∗ = (cid:98)U + β/2. This further implies that (cid:107)U In particular, let β = (cid:107)(cid:98)U − X(cid:107)∞. Then U (cid:107)(cid:98)U − X(cid:107)∞/2 = β/2. ∗ = (cid:98)U + α. − X(cid:107)∞ = ∗ be 3 (cid:0)X (cid:1). For any such triple, if ρ(x, y) > max{ρ(x, z), ρ(z, y)} + 2ε, (cid:1) be such that ρ(x, y) > max{ρ(x, z), ρ(z, y)} + 2ε. It follows by Lemma 4.1 that Theorem 4.2. There exists a polynomial-time algorithm which given an n-point metric space X = (X, ρ), ε ≥ 0, and k ≥ 0, such that X admits a (ε, k)-outlier embedding into an ultrametric, outputs a (O(ε log(n)), 3k)-outlier embedding into an ultrametric. Proof. For simplicity, assume that the diameter ∆(X ) = 1. The algorithm is as follows. We first enumerate all triples {x, y, z} ∈ then we remove x, y, and z from X. Let X(cid:48) be the resulting point set. We output the ultrametric (cid:48) induced by an MST of the metric space (X(cid:48), ρ). This completes the description of the algorithm. U It suffices to prove that the output is indeed an (O(ε log(n)), 3k)-outlier embedding. Let K∗ (cid:0)X ⊆ ≤ k, be such that (X \ K∗, ρ) admits a (ε, 0)-outlier embedding into an ultrametric. X, with K∗ Let {x, y, z} ∈ ({x, y, z}, ρ) does not admit a (ε, 0)-outlier embedding into an ultrametric. Thus, K∗ ∩{x, y, z} (cid:54)= ∅. It follows that X \ X(cid:48) ≤ 3k. In other words, the algorithm removes at most 3k points. (cid:48) and (X(cid:48), ρ). Let T be the MST of (X(cid:48), ρ) It remains to bound the distortion between U (cid:48) = (X(cid:48), δ) induced by T . We will prove by such that the algorithm outputs the ultrametric U induction on i ≥ 0, that for all x, y ∈ X(cid:48), if the x-y path in T contains at most 2i edges, then ρ(x, y) ≤ δ(x, y) + 2i · ε. For the base case i = 0 we have that {x, y} ∈ E(T ). Since T is the minimum spanning tree of (X(cid:48), ρ), it follows that δ(x, y) = ρ(x, y), proving the base case. For the inductive step, let x, y ∈ X(cid:48) such that the x-y contains at most 2i edges, for some i ≥ 1. Let w ∈ X(cid:48) be such that w is in the x-y path in T , and moreover the x-w and w-z paths in T have at most 2i−1 edges each. Since {x, y, w} ∈ X(cid:48), it follows that the triple {x, y, w} was not removed by the algorithm, and thus ≤ 3 · K∗ 3 By the inductive hypothesis we have ρ(x, y) ≤ max{ρ(x, w), ρ(w, y)} + 2ε. (9) ρ(x, w) ≤ δ(x, w) + 2(i − 1) · ε, and ρ(w, y) ≤ δ(w, y) + 2(i − 1) · ε. By (9) and (10) we get (10) ρ(x, y) ≤ max{δ(x, w), δ(w, y)} + 2(i − 1) · ε + 2ε ≤ δ(x, y) + 2i · ε. (cid:48) is an (2ε log n, 0)-embedding of (X(cid:48), ρ). This, together with the bound on X \ X(cid:48) Hence U concludes the proof. 4.2 Bi-criteria approximation for embedding into Rd Theorem 4.3. Given an n-point metric space X = (X, ρ), if X admits a (ε, k∗)-outlier embedding in Rd, then we have an algorithm that outputs an (O(√ε), 2k∗)-outlier embedding of X in Rd in O(nd+3) time. Here the big-O notation hides constants depending on the dimension d. We only state the main result here, and the details can be found in Appendix C. In particular, the high level structure of our algorithm parallels that of Algorithm 1, which intuitively is an algorithm for the special case when ε = 0. However, the technical details here are much more involved so as to tackle several issues caused by the near-isometric embedding. 11 References [1] Richa Agarwala, Vineet Bafna, Martin Farach, Mike Paterson, and Mikkel Thorup. On the approximability of numerical taxonomy (fitting distances by tree metrics). SIAM Journal on Computing, 28(3):1073–1085, 1998. [2] Nir Ailon and Moses Charikar. Fitting tree metrics: Hierarchical clustering and phylogeny. In Foundations of Computer Science, 2005. FOCS 2005. 46th Annual IEEE Symposium on, pages 73–82. IEEE, 2005. [3] P. Alestalo, D. A. Trotsenko, and J. Vaisala. Isometric approximation. Israel Journal of Mathematics, 125(1):61–82, 2001. [4] Noga Alon, Mihai Badoiu, Erik D Demaine, Martin Farach-Colton, MohammadTaghi Haji- aghayi, and Anastasios Sidiropoulos. Ordinal embeddings of minimum relaxation: general properties, trees, and ultrametrics. ACM Transactions on Algorithms (TALG), 4(4):46, 2008. [5] Mihai Badoiu. Approximation algorithm for embedding metrics into a two-dimensional space. In Proceedings of the fourteenth annual ACM-SIAM symposium on Discrete algorithms, pages 434–443. Society for Industrial and Applied Mathematics, 2003. [6] Yair Bartal. Probabilistic approximation of metric spaces and its algorithmic applications. In Foundations of Computer Science, 1996. Proceedings., 37th Annual Symposium on, pages 184–193. IEEE, 1996. [7] Leonard M. Blumenthal. Theory and applications of distance geometry. Chelsea Publishing Company, 2 edition. [8] Mihai Badoiu, Julia Chuzhoy, Piotr Indyk, and Anastasios Sidiropoulos. Low-distortion em- beddings of general metrics into the line. In Proceedings of the thirty-seventh annual ACM symposium on Theory of computing, pages 225–233. ACM, 2005. [9] Mihai Badoiu, Julia Chuzhoy, Piotr Indyk, and Anastasios Sidiropoulos. Embedding ultra- metrics into low-dimensional spaces. In Proceedings of the 22nd ACM Symposium on Compu- tational Geometry, Sedona, Arizona, USA, June 5-7, 2006, pages 187–196, 2006. [10] Mihai Badoiu, Kedar Dhamdhere, Anupam Gupta, Yuri Rabinovich, Harald Racke, R Ravi, and Anastasios Sidiropoulos. Approximation algorithms for low-distortion embeddings into low-dimensional spaces. In Proceedings of the sixteenth annual ACM-SIAM symposium on Discrete algorithms, pages 119–128. Society for Industrial and Applied Mathematics, 2005. [11] Mihai Badoiu, Piotr Indyk, and Anastasios Sidiropoulos. Approximation algorithms for embed- ding general metrics into trees. In Proceedings of the eighteenth annual ACM-SIAM symposium on Discrete algorithms, pages 512–521. Society for Industrial and Applied Mathematics, 2007. [12] T-H Hubert Chan, Kedar Dhamdhere, Anupam Gupta, Jon Kleinberg, and Aleksandrs SIAM Journal on Computing, Slivkins. Metric embeddings with relaxed guarantees. 38(6):2303–2329, 2009. 12 [13] T-H Hubert Chan, Michael Dinitz, and Anupam Gupta. Spanners with slack. In Algorithms– ESA 2006, pages 196–207. Springer, 2006. [14] Victor Chepoi, Feodor Dragan, Bertrand Estellon, Michel Habib, and Yann Vax`es. Diameters, centers, and approximating trees of delta-hyperbolicgeodesic spaces and graphs. In Proceedings of the twenty-fourth annual symposium on Computational geometry, pages 59–68. ACM, 2008. [15] Victor Chepoi, Feodor F Dragan, Ilan Newman, Yuri Rabinovich, and Yann Vaxes. Constant approximation algorithms for embedding graph metrics into trees and outerplanar graphs. Discrete & Computational Geometry, 47(1):187–214, 2012. [16] Thomas H. Corman, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. 3 edition. [17] Mark de Berg, Krzysztof Onak, and Anastasios Sidiropoulos. Fat polygonal partitions with applications to visualization and embeddings. JoCG, 4(1):212–239, 2013. [18] Kedar Dhamdhere, Anupam Gupta, and R Ravi. Approximation algorithms for minimizing average distortion. Theory of Computing Systems, 39(1):93–111, 2006. [19] Jeff Edmonds, Anastasios Sidiropoulos, and Anastasios Zouzias. Inapproximability for planar embedding problems. In Proceedings of the Twenty-First Annual ACM-SIAM Symposium on Discrete Algorithms, pages 222–235. Society for Industrial and Applied Mathematics, 2010. [20] Martin Farach, Sampath Kannan, and Tandy Warnow. A robust model for finding optimal evolutionary trees. Algorithmica, 13(1-2):155–179, 1995. [21] Michael Fellows, Fedor Fomin, Daniel Lokshtanov, Elena Losievskaja, Frances A Rosamond, and Saket Saurabh. Parameterized low-distortion embeddings-graph metrics into lines and trees. arXiv preprint arXiv:0804.3028, 2008. [22] Michael R Fellows, Fedor V Fomin, Daniel Lokshtanov, Elena Losievskaja, Frances A Rosa- mond, and Saket Saurabh. Distortion is fixed parameter tractable. In Automata, Languages and Programming, pages 463–474. Springer, 2009. [23] Mikhael Gromov. Hyperbolic groups. Springer, 1987. [24] Alexander Hall and Christos Papadimitriou. Approximating the distortion. In Approximation, Randomization and Combinatorial Optimization. Algorithms and Techniques, pages 111–122. Springer, 2005. [25] Piotr Indyk. Algorithmic applications of low-distortion geometric embeddings. In focs, page 10. IEEE, 2001. [26] Piotr Indyk and Jiri Matousek. Low-distortion embeddings of finite metric spaces. Handbook of Discrete and Computational Geometry, page 177, 2004. [27] Claire Kenyon, Yuval Rabani, and Alistair Sinclair. Low distortion maps between point sets. SIAM Journal on Computing, 39(4):1617–1636, 2009. 13 [28] Subhash Khot. On the power of unique 2-prover 1-round games. In Proceedings of the thiry- fourth annual ACM symposium on Theory of computing, pages 767–775. ACM, 2002. [29] Subhash Khot and Oded Regev. Vertex cover might be hard to approximate to within 2 − . Journal of Computer and System Sciences, 74(3):335 – 349, 2008. Conference version appeared in Computational Complexity 2003. [30] Subhash Khot and Rishi Saket. Hardness of embedding metric spaces of equal size. In Approx- imation, randomization, and combinatorial optimization. Algorithms and techniques, pages 218–227. Springer, 2007. [31] Christiane Lammersen, Anastasios Sidiropoulos, and Christian Sohler. Streaming embeddings with slack. In Algorithms and Data Structures, 11th International Symposium, WADS 2009, Banff, Canada, August 21-23, 2009. Proceedings, pages 483–494, 2009. [32] Jir´ı Matousek and Anastasios Sidiropoulos. Inapproximability for metric embeddings into {}. Transactions of the American Mathematical Society, 362(12):6341–6365, 2010. [33] Karl Menger. New foundation of euclidean geometry. American Journal of Mathematics, pages 721–745, 1931. [34] Amir Nayyeri and Benjamin Raichel. Reality distortion: Exact and approximate algorithms for embedding into the line. In Foundations of Computer Science, 2015. FOCS 2015, to appear. IEEE, 2015. [35] Christos Papadimitriou and Shmuel Safra. The complexity of low-distortion embeddings be- tween point sets. In SODA, volume 5, pages 112–118, 2005. [36] Michal Parnas and Dana Ron. Testing metric properties. Information and Computation, 187:155–195, 2003. An earlier conference version appeard in STOC 2001. [37] Manfred J. Sippl and Harold A. Scheraga. Cayley-Menger coordinates. Proc. Natl. Acad. Sci. USA, 83:2283–2287, 1986. 14 A Missing details from Section 3 Proof of Lemma 3.6. Start with an arbitrary ordering of Xi−1, and follow the procedure laid-out in Definition 3.4. Specifically, for each vj, we can compute the distance rj = (ρ(vj, xi) + ρ(x∗ i , vj)− ρ(xi, x∗ i ))/2 in constant time. Hence we know the distance lj = ρ(vj, xi) − rj from vj to the stem of xi w.r.t. {vj, x∗ i}. Now, starting from vj, we follow the unique path towards the root x∗ i , till we meet an masked edge or we meet the root x∗ i . (In other words, we do not traverse the entire i .) For any edge we traverse, first we orient it towards x∗ path Pj from vj to x∗ i till we meet an edge (w, w(cid:48)) such that ρ(w, vj) < lj and ρ(w(cid:48), vj) > lj, or a vertex w such that ρ(w, vj) = lj. In this case, we set this edge or vertex to be a sink (as it would contain the stem of xi at {vj, x∗ i}) and associate vj as its generating vertex. After the sink, we orient each edge to be towards the sink, till we meet an masked edge. The entire procedure to process all vj’s takes O(V (Ti−1)) time – since all leaves of Ti−1 are from Xi−1, we have that O(V (Ti−1)) = O(Xi−1) = O(i). i} may ultimately not be a sink vertex for the final xi-orientation; recall the figure above this lemma. So we may associate generating vertex information for some non-sink vertices. Note that in this procedure, some sink vertex w.r.t. certain {vj, x∗ i )-orientation along the path Pv1x∗ Otherwise, consider the sink vertex w1 w.r.t. {v1, x∗ Proof of Lemma 3.7. Consider the ordering of leaf vertices of Ti−1, denoted by {v1, . . . , v(cid:96)}, that gives rise to the xi-orientation (cid:126)Ti−1. Following the procedure laid out in the proof of Lemma 3.6, after processing v1, we obtained the (xi, v1, x∗ (from v1 to x∗ i in Ti−1). Hence at this point, there must be a sink w.r.t. {v1, x∗ i}. If this is a sink edge, since this edge is masked, it remain unoriented throughout the entire procedure; that is, this edge will still be a sink edge for the final xi-orientation (cid:126)Ti−1. Hence (cid:126)T has at least one sink, and we are done. i}: Since w1 is not a sink vertex for (cid:126)Ti−1, there must exist an outgoing edge (w1, u) oriented towards u. In other words, the orientation is away from the root x∗ i . Follow any outgoing edge from u and continue in this manner: we have to either meet a sink edge / vertex (at which point we cannot find another outgoing edge to continue), or we reach a leaf vj of Ti−1. All edges we visited during this process are oriented away from the root x∗ i , this means such a path cannot lead us to a leaf vj, and thus we have to stop at a sink of (cid:126)Ti−1. Putting everything together, (cid:126)Ti−1 has at least one sink. i . Since when we start with each vj, we always first orient edges towards the root x∗ i main text 2-approximates the minimum outlier d-embedding of (X, ρ). Specifically, let K∗ be an . ∈ Zd, will form an edge in the graph G constructed in Step-3, and subsequently, the vertex cover will contain at least one point from such a pair. Statement (a) then follows from Theorem 3.11. Proof of Theorem 3.12. We claim that the output outlier set (cid:98)K of Algorithm 1 stated in the ≤ (cid:98)K ≤ 2K∗ optimal outlier set. We will show: (a) (X \ (cid:98)K, ρ) is d-embeddable; and (b) K∗ To prove (a), let(cid:98)Yd be the d+1 points in (Step-0) that gives rise to (cid:98)K, and (cid:98)d(≤ d) the embedding dimension of ((cid:98)Yd, ρ). Set Zd = X \ (K ∪(cid:98)Yd). (Step-3) ensures that for any two points z, z(cid:48) }, ρ) must be (cid:98)d-embeddable. This is because any pair z, z(cid:48) that violates this condition ((cid:98)Yd ∪ {z, z(cid:48) We now prove statement (b). The left inequality is evident. Let Z∗ = X \ K∗. Since (Z∗, ρ) ≤ d ⊆ Yd In the subsequent (Step-2), any point inserted into K violates is d-embeddable, by Theorem 3.11, there exists d∗ + 1 points, say Y ∗ = {y0, . . . , yd∗} with d∗ being the embedding dimension of Z∗, such that (Y ∗, ρ) is strongly d∗-embeddable. Now consider the time when the algorithm enumerates some Yd such that Yd ⊆ Z∗ and Y ∗ in (Step-0); Yd = Y ∗ if d∗ = d. 15 condition (ii) of Theorem 3.11 and thus must belong to the optimal outlier set K∗ as well. In (Step-3), again by Theorem 3.11 (ii), for any edge (z, z(cid:48)) ∈ E, at least one of its endpoint is necessarily in K∗. Hence a smallest set of outliers consistent with Yd would consist of the points removed in (Step-2) and the vertex cover of the graph G constructed in (Step-3). Since the algorithm Hence the output outlier set (cid:98)K is a 2-approximation for the minimum outlier embedding of computes a 2-approximation of the vertex cover, it follows that the set K at the end of (Step-3) contains at most 2K∗ (X, ρ) to Rd as claimed. points. Since (cid:98)K ≤ K, we then have that (cid:98)K ≤ 2K∗ . Finally, we analyze the time complexity of our algorithm. Steps 1 – 3 will be executed O(nd+1) number of times. For each Yd, (Step-1) takes time polynomial in d due to the discussion below Theorem 3.11. (Step-2) performs O(n) number of embedding test, each for O(d) points. Hence it takes O(ndO(1)) total time. In (Step-3), it takes O(n2dO(1)) time to construct the graph G = (Z, E). A 2-approximation of the vertex cover can easily be computed in O(V + E) time [16]. Putting everything together, the running time is O(nd+3dO(1)) = O(nd+3), where the big-O notation hides terms polynomial in d. B Hardness results In this section, we show that the minimum outlier embedding problems into ultrametrics, trees, and Euclidean space are all NP-hard, by reducing the vertex cover problem to them in each case. In fact, it is NP-hard to approximate each of them within 2 − ε, for any ε > 0, unless the unique game conjecture is true. For the case of minimum outlier embedding into Euclidean space, we note that our 2-approximation algorithm from the previous section almost matches the hardness result here. All the hardness results are obtained via reduction from vertex cover. The high-level approach is very similar, although the specific reduction is different in each case. Below we present the result for tree metric first. Theorem B.1. The problem of minimum outlier embedding into a tree metric is NP-hard. Fur- thermore, assuming the Unique Games Conjecture, it is NP-hard to approximate within a factor of 2 − ε, for any ε > 0. Proof. We use a reduction from Vertex Cover. This problem is known to be NP-hard. Furthermore, assuming the Unique Games Conjecture, it is also hard to approximate within a multiplicative factor of 2 − ε for any ε > 0 [29]. Let G = (V, E) be an instance to Vertex Cover. The goal is to find the smallest subset of vertices of V covering all edges in E. We construct a discrete metric space (X, dX ) as follows: Let ν be an arbitrarily small positive number. • For any vi ∈ V , add two nodes xi, yi ∈ X. Set X = {xi, yi}i∈[1,n] ∪ {o}. • Set dX (xi, yi) = 1, dX (o, xi) = 2, and dX (o, yi) = 1 for each i ∈ [1, n]. Set dX (yi, yj) = 2 and dX (xi, yj) = 3 for i (cid:54)= j. (vi, vj) /∈ E. • Set dX (xi, xj) = 4 − ν if (vi, vj) ∈ E is an edge in E; otherwise, set dX (xi, xj) = 4 if It is easy to verify that the above description indeed specifies a metric space. Intuitively, (X, dX ) is close to the tree metric induced by a star-shaped tree: o is the root, tree edges are (o, xi) and 16 Indeed, let K∗ (xi, yi), for i ∈ [1, n], and each edge has weight 1. Specifically, we claim that the optimal solution to minimum outlier embedding of (X, dX ) into a tree-metric has the same size as the optimal vertex cover for G = (V, E). . ≤ C∗ ⊂ X be the smallest set of outliers that one needs to remove so that the metric space restricted to X \ K∗ is a tree metric. Let C∗ ⊂ V denote the optimal vertex cover for G = (V, E). It is easy to see that K∗ , as removing the nodes xi corresponding to vertices in C∗ will result in a tree metric induced by the star rooted at o described above. We next show ≤ K∗ that C∗ Given K∗, construct a subset V ⊂ V as V = {vi ∈ V xi ∈ K∗ or yi ∈ K∗ }. By construction, V ≤ K∗ . We now show that V forms a vertex cover for G = (V, E), which in turn implies C∗ ≤ K∗ Indeed, suppose there exists an edge (vi, vj) ∈ E such that vi /∈ V and vj /∈ V . . This means that xi, yi, xj, yj ∈ X \ K∗. However, it is easy to check that these four points violate the four-point condition as in (2), as dX (xi, yj) + dX (xj, yi) = 6, which is strictly larger than dX (xi, xj) + dX (yj, yi) = 6 − ν, as well as larger than dX (xi, yi) + dX (yj, xj) = 4. Contradiction. Hence either vi or vj must be included in V . Hence C∗ , we have C∗ . The claimed hardness results, both for computing and for approximating the tree-metric outlier-embedding problem thus follow from the hardness of Vertex Cover. ≤ V ≤ K∗ = K∗ Combining K∗ and C∗ ≤ K∗ ≤ C∗ . Theorem B.2. The problem of minimum outlier embedding into an ultrametric is NP-hard. Fur- thermore, assuming the Unique Games Conjecture, it is NP-hard to approximate within a factor of 2 − ε, for all ε > 0. Proof. As for the case of embedding into trees, we give a reduction from Vertex Cover. Specifically, let G = (V, E) be an instance of Vertex Cover. We construct a discrete metric space (U, dU ) as follows: Let ν be a sufficiently small positive number. dU (ui, uj) = 1 − ν if (vi, vj) ∈ E; otherwise, set dU (ui, uj) = 1. • For each vi ∈ V , i ∈ [1, n], add a pair of nodes ui, wi ∈ U . Hence U = {ui, wi}i∈[1,n]. • Set dU (ui, wi) = 2ν, and dU (ui, wj) = 1, dU (wi, wj) = 1 for any i (cid:54)= j. For i (cid:54)= j, set It is easy to verify that the above description indeed specifies a metric. Let K∗ denote the optimal set of outliers so that dU restricted to U \K∗ gives rise to an ultrametric. Let C∗ denote the optimal vertex cover. Similar to the proof of Theorem B.1, we will show that C∗ . First, it is easy to see that by removing those vertices ui such that vi ∈ C∗, the resulting metric is an ultrametric. Hence K∗ . We claim that V forms a vertex cover for G = (V, E). Specifically, assume this is not the case and there exists an edge (vi, vj) ∈ E such that vi /∈ V and vj /∈ V . Then ui, wi, uj ∈ U \ K∗. However, these three points violate the three-point condition for ultrametrics as in (1), as dU (wi, uj) = 1, which is strictly larger than max{dU (wi, ui) = 2ν, dU (uj, ui) = 1 − ν}, which is a contradiction. Hence V is a vertex cover and thus C∗ To this end, construct V = {vi ∈ V ui ∈ K∗ or wi ∈ K∗ . It remains to show that C∗ }; obviously, V ≤ K∗ and the theorem then follows. . Overall, C∗ ≤ V ≤ K∗ = K∗ = K∗ ≤ C∗ ≤ K∗ . We next present a hardness result for outlier embedding into constant-dimensional Euclidean space. 17 Theorem B.3. For any d ≥ 2, the problem of minimum outlier embedding into d-dimensional Euclidean space is NP-hard. Furthermore, assuming the Unique Games Conjecture, it is NP-hard to approximate within a factor of 2 − ε, for any ε > 0. Proof. We first present the construction for d = 2, and then discuss how to extend it to the case d > 2. As before, we give a reduction from Vertex Cover. Specifically, given a graph G = (V, E), we construct a discrete metric space (X, dX ) as follows: Let ν be a sufficiently small positive real number. Set X = {x1, . . . , xn, y1, . . . , yn, z1, . . . , zn}. • We define: 1. for any i ∈ [1, n], xi = (i,−1), yi = (i, 1),and zi = (i, 0). • We assign distances dX as follows: Consider K∗. We construct the set V = {vi xi ∈ K∗ or yi ∈ K∗ or zi ∈ K∗ 1. dX (xi, zi) = 1, dX (yi, zi) = 1 and dX (xi, yi) = 2, for any i ∈ [1, n]. 2. For any i, j ∈ [1, n], for a, b ∈ {x, y}, dX (ai, bj) = (cid:107)ai − bj(cid:107). 3. For any i, j ∈ [1, n], dX (zi, xj) = (cid:107)zi − xj(cid:107), dX (zi, yj) = (cid:107)zi − yj(cid:107). 4. For i (cid:54)= j, if (vi, vj) ∈ E, then dX (zi, zj) = j − i − ν; otherwise, set dX (zi, zj) = j − i. In other words, other than zi and zj potentially deviates from the distance given by their coor- dinates, the distance between all other pairs of points are consistent with their coordinates. It is easy to verify that (X, dX ) as described above satisfies triangle inequality and is a valid metric. Let K∗ denote the optimal set of outliers so that dX restricted to X \ K∗ can be embedded in R2 isometrically. Let C∗ denote the optimal vertex cover for graph G = (V, E). We now show K∗ = C∗ Specifically, first note that given C∗, we can construct the set K containing all yi such that vi ∈ C∗. It is easy to see that the coordinates for the remaining points X \ K are consistent with their pairwise distances. Hence K∗ }. We now argue that V is a vertex cover for the graph G = (V, E). Assume that this is not true, and that there exists an edge (vi, vj) ∈ E such that vi /∈ V and vj /∈ V . This means that the 6 points in {xi, yi, zi, xj, yj, zj} must all belong to X \ K∗. However, we argue that their pairwise distances are not consistent. In particular, consider the 3 points xi, yi, xj. They are isometrically embeddable into R2 (but not into R1). Hence once their coordinates are fixed, there is only a unique position In other words, we can possible for any other point p given its distance to these three points. uniquely embed zi, as well as zj into R2 w.r.t. the current coordinates of {xi, yi, xj} (which form consistent with dX . Hence the points {xi, yi, xj, zi, zj} are not isometrically embeddable into R2, which contradicts our assumption that all of them are in X \ K∗. It then follows that V has to be a vertex cover, and C∗ construction of (X, dX ) we map each vi ∈ V to a sequence of d + 1 points x(0) contained in the subspace Rd−1 × {i}, where the first d points form a canonical (d − 1)-simplex, while the last point x(d) identical so we omit the details. a valid isometry consistent with dX ). However, the Euclidean distance between zi and zj is not We next discuss how the above construction can be generalized to the case d > 2. is the centroid of this simplex. The rest of the argument remains essentially ≤ K = C∗ . We next show that C∗ ≤ K∗ . . This completed the proof for d = 2. ≤ V ≤ K∗ , . . . , x(d) i i In the in X . i 18 C Bi-criteria approximation for embedding into Rd As before, let dE denote the Euclidean distance in Rd. Given a point x ∈ Rd and a set A ⊂ Rd, the distance from x to A is defined as d(x, A) = inf y∈A dE(x, y). Definition C.1 (Near-isometric d-embedding). Given a metric space X = (X, ρX ), we say that a map ϕ : X → Rd is a δ-near-isometric embedding of X into Rd if for any x, x(cid:48) ∈ X, we have that ρ(x, x(cid:48)) − dE(ϕ(x), ϕ(x(cid:48))) ≤ δ. In this case, we also say that X admits a δ-near-isometric d-embedding, and (ϕ(X ), dE) is a δ-approximation of X . We note that the parameter δ-above is not normalized w.r.t. the diameter of the set; this is for the convenience of the latter argument in this section. Before we describe our algorithm, we need some more definitions (following the notations of [3]). Definition C.2 (Normalized sequence). Given an ordered sequence of points U = {u0, u1, . . . , ud} ⊂ Rd, we say that U is normalized if u0 = o = (0, . . . , 0), and if ui ∈ Ri Given U ⊆ A ⊂ Rd, if f : A → Rd is a map such that f (U ) is normalized, then we say that the + for all 1 ≤ i ≤ d. map f is normalized at U . Definition C.3 (Maximal sequence). Let k ≤ d. Given an ordered sequence of points U = {u0, . . . , uk} from a set A ⊂ Rd, we say that U is maximal in A if: (i) dE(u0, u1) = ∆(A), and (ii) for any 2 ≤ i ≤ k, the distance d(ui, aff{u0, . . . , ui−1}) is maximal in A. Here, affB is the affine subspace of Rd spanned by points in set B ⊆ Rd. Description of the algorithm. Assume that the input n-point metric space X = (X, ρ) admits a (ε, k∗)-outlier embedding into Rd. We now present an algorithm, described in Algorithm 2, to find an approximation of such an embedding. The high level structure of this algorithm parallels that of Algorithm 1, which intuitively is an algorithm for the special case when ε = 0. However, the technical details here are more involved so as to tackle several issues caused by the near-isometric embedding. In this algorithm, Cd is a positive constant depending only on the dimension d. For the time being, for the sake of simplicity of presenting the main ideas, let us assume that we can implement (Step-1,2) (i.e, the computation of Pd and px)) in polynomial time. We will address how to modify Algorithm 2 to achieve this later in this section. Our main result is the following: in Rd, then Algorithm 2 returns an outlier set (cid:98)K that witnesses an (O(√ε),(cid:98)K)-outlier embedding Theorem C.4. Given an n-point metric space X = (X, ρ), if X admits a (ε, k∗)-outlier embedding of X in Rd with (cid:98)K ≤ 2k∗. Here O(√ε) hides constants depending on the dimension d. Proof of Theorem C.4. Let (cid:98)Z = X \ (cid:98)K. By (Step-2) and (Step-3), for any two points z, z(cid:48) ∈ (cid:98)Z, Hence ((cid:98)Z, ρ) indeed has an O(√ε∆(X))-near-isometric embedding in Rd. we computed pz and pz(cid:48) ∈ Rd in (Step-2) such that ρ(z, z(cid:48)) − dE(pz, pz(cid:48)) ≤ Cd√ε∆(X) + ε∆(X). It remains to show that (cid:98)K ≤ 2k∗. Let K∗ be an optimal set of outliers such that K∗ = k∗ and (X \ K∗, ρ) admits a ε∆(X)-near-isometric d-embedding, say ϕ : X \ K∗ → Rd. Set Z∗ = X \ K∗. For simplicity, we assume that there does not exist d(cid:48) < d such that (X \ K∗, ρ) admits a ε∆(X)- near-isometric d(cid:48)-embedding; the case where such d(cid:48) < d exists can be handled similarly. Let Y ∗ = {y0, . . . , yd} be the ordered sequence such that ϕ(Y ∗) is maximal in ϕ(Z∗). We assume w.l.o.g. that ϕ(Z∗) is also normalized in Rd; if not, there exists an isometry T : Rd → Rd so that T (ϕ(Y ∗)) is normalized, and we can simply take ϕ as T ◦ ϕ. 19 Algorithm 2 Bi-criteria approximation for embedding into Rd. Input: An n-point metric space (X, ρ), a parameter 0 ≤ ε < 1, dimension d Output: A set of outliers (cid:98)K ⊂ X If such a Pd does not exist, return to (Step-0). ≤ d for which such a Pd exists. Initialize the set of candidate outlier sets C to be empty. Initialize sets W and K to be the empty set. (Step-0) For each subset of d + 1 distinct points Yd = {y0, . . . , yd} ⊂ X, perform the following: (Step-1) Compute an normalized sequence Pd = {p0, p1, . . . , pd} ⊂ Rd such that (Pd, dE) is an (ε∆(X))-approximation of (Yd, ρ). Otherwise, compute the smallest dimension d(cid:48) (Step-2) For each remaining point x ∈ X \ Yd, compute px ∈ Rd(cid:48) satisfying that ρ(x, yi) − dE(px, pi) ≤ Cd√ε∆(X) + ε∆(X) for any i ∈ [0, d]. If such a px can be found, insert the (Step-3) Construct the graph G = (W, E) where, for any two w = (z, p), w(cid:48) = (z(cid:48), p(cid:48)) ∈ W , (w, w(cid:48)) ∈ E if and only if ρ(z, z(cid:48)) − dE(p, p(cid:48)) > Cd√ε∆(X) + ε∆(X). Compute a 2- approximation W (cid:48) }, and add (Step-4) Let (cid:98)K be the set from C with smallest cardinality. We return (cid:98)K as the outlier set. the set K to the collection of candiate outlier sets C. ⊂ W of the vertex cover of G. Set K = K ∪ {z (z, p) ∈ W (cid:48) pair (x, px) into the set W ; otherwise, insert x to the outlier set K. Consider the time when our algorithm enumerates Yd = Y ∗ in (Step-0). In the subsequent (Step- 1), the algorithm will be able to find an normalized sequence Pd as claimed, since ϕ(Yd) satisfies the requirements. Following our earlier assumption on Z∗, d(cid:48) = d for Pd. In (Step-2), for a point x ∈ X \ Z∗, we claim that there exists px ∈ Rd such that (Pd ∪{px}, dE) is an 2ε∆X -approximation of (Yd ∪ {x}, ρ). To prove this, we need to use the following result proved in [3]. Proposition C.5 (Section 2.6, [3]). For any fixed d > 1, let A = {o, u1, . . . , u d, x} ⊂ R d be such that the d-sequence U = (o, u1, . . . , u d) is normalized and maximal in A. Let f : A → R d be a map such that (f (A), dE) is an δ∆(A)-approximation of (A, dE), and f is normalized at U . Then there √δ∆(A). exists a constant c d depending only on the dimension d such that dE(x, f (x)) ≤ c d Consider the image Q∗ = ϕ(Z∗) of an optimal embedding ϕ : Z∗ = X \ K∗ → Rd. Denote by Qd = {q0 = ϕ(y0), q1 = ϕ(y1), . . . , qd = ϕ(yd)} and g : Qd → Pd ⊂ Rd the map that sends qi to pi, for each i ∈ [0, d]. We also use h : Y ∗ → Pd to denote the ε∆(X)-near-isometric embedding For any x ∈ Z∗, by the same argument as for the existence of Pd, we can show that there must exist a ε∆(X)-near-isometric embedding hx : Yd ∪ {x} → Rd of (Yd ∪ {x}, ρ) such that the ordered sequence {hx(y0), . . . , hx(yd)} is normalized. Furthermore, Proposition C.5 implies the following: Claim C.6. For any x ∈ Z∗ and any hx as described above, dE(ϕ(x), hx(x)) ≤ 2cd√ε∆(X). Proof. For simplicity of presentation, set yd+1 = x, and consider the set A = {q0, . . . , qd, qd+1 = ϕ(x)} ⊂ Q∗, and the map gx : A → Rd defined as gx(qi) = hx(yi) for any i ∈ [0, d + 1]. Since both ϕ and hx are ε∆(X)-near-isometric maps, we have by triangle inequality that: for any i, j ∈ [0, d + 1], dE(qi, qj) − dE(hx(yi), hx(yj) ≤ dE(qi, qj) − ρ(yi, yj) + ρ(yi, yj) − dE(hx(yi), hx(yj)) ≤ 2ε∆(X). computed in (Step-1). 20 (cid:112)2ε∆(X)∆(A) ≤ 2cd√ε∆(X). In other words, this means that the map gx is a 2ε∆(X)-nearisometry for (A, dE). Setting δ = 2ε∆(X)/∆(A), it then follows from Proposition C.5 that dE(qd+1 = ϕ(x), hx(x)) ≤ cd√δ∆(A) = cd The last inequality follows that since ϕ is ε∆(X)-nearisometry, we have that ∆(A) ≤ ∆(Q∗) ≤ (1 + ε)∆(Z∗) ≤ 2∆(X) for ε ≤ 1. On the other hand, note that the above statement is generic for any x ∈ Z∗ and any ε∆(X)- near-isometric map hx such that the ordered sequence {hx(y0), . . . , hx(yd)} is normalized. Hence we can choose x = yi for any i ∈ [0, d] and choose hx = h computed in (Step-1) h : Yd → Pd that gives rise to Pd. It then follows from Claim C.6 that: for any i ∈ [0, d], dE(ϕ(yi), pi = h(yi)) ≤ 2cd√ε∆(X). (11) Finally for any x ∈ X \ Yd inspected in (Step-2), set px = hx(x) for any ε∆(X)-near-isometry hx : Y ∗ ∪ {x} → Rd (which must exist as we argued earlier). Combining Claim C.6, Eqn (11), the triangle inequality and the fact that ϕ is an ε∆(X)-nearisometry, we thus have: Setting Cd = 4cd, we obtain the following. ρ(yi, x) − dE(pi, px) ≤ ρ(yi, x) − dE(ϕ(yi), ϕ(x)) + dE(ϕ(yi), ϕ(x)) − dE(pi, px) (12) By a similar argument as in Eqn (12), we can also obtain: ≤ ε∆(X) + dE(ϕ(yi), pi) + dE(ϕ(x), px) ≤ ε∆(X) + 4cd√ε∆(X). Corollary C.7. For any x ∈ Z∗, there exists px satisfying the requirements in (Step-2). Corollary C.8. For any z, z(cid:48) (Step-2). Then ρ(z, z(cid:48)) − dE(pz, pz(cid:48)) ≤ Cd√ε∆(X) + ε∆(X). Lemma C.9. K ≤ 2K∗ Proof. First, as argued earlier above Corollary C.7, for any x ∈ Z∗, (Step-2) will be able to compute the required px ∈ Rd. Let K1 denote the set O at the end of (Step-2). It then follows that K1 ⊂ K∗. Furthermore, by Corollary C.8, for any edge ((z, p), (z(cid:48), p(cid:48))) ∈ E in the graph constructed in Step-3, at least one of z and z(cid:48) is necessarily in K∗. Hence K∗ \ K1 is at least the size of the vertex cover of G. Since we compute a 2-approximation of the vertex cover, it follows that the set K at the end of Step-3 satisfies that K ≤ 2K∗ ∈ Z∗, let pz and pz(cid:48) be their corresponding points in Rd computed in . This proves the claim as K ≤ K. . This completes the proof of Theorem C.4. Computational issues. The computation of Pd and px in (Step-1) and (Step-2) require solving a system of O(d) quadratic equations and inequalities, and the solution would require infinite pre- cision. This can be addressed using real algebraic geometry theory for semi-algebraic sets which can output the solutions in arbitrary precision in time exponential in O(d). We can also use the fol- lowing “griding” strategy: After (Step-1), we discretize the d-dimensional cube [−3∆(X), 3∆(X)]d where the grid length is τ = ε 2d2 ∆(X). In (Step-1) and (Step-2), we look for solutions for Pd and px where coordinates fall on grid points. This requires us to relax the distance distortion bound by another factor of ε∆(X). However it will not change the final statement in Theorem C.4. The time to compute each near-isometry embedding is ( d ε )O(d). Overall, following a similar analysis as for Algorithm 1, we conclude with Theorem 4.3. 21
1807.03739
1
1807
2018-07-05T05:56:13
Constructing Concrete Hard Instances of the Maximum Independent Set Problem
[ "cs.DS", "cond-mat.dis-nn", "cond-mat.stat-mech", "cs.CC" ]
We provide a deterministic construction of hard instances for the maximum independent set problem (MIS). The constructed hard instances form an infinite graph sequence with increasing size, which possesses similar characteristics to sparse random graphs and in which MIS cannot be solved efficiently. We analytically and numerically show that all algorithms employing cycle-chain refutation, which is a general refutation method we introduce for capturing the ability of many known algorithms, cannot upper bound the size of the maximum independent set tightly.
cs.DS
cs
Constructing Concrete Hard Instances of the Maximum Independent Set Problem Department of Physics, Keio university, Hiyoshi 3-14-1, Kohoku-ku, Yokohama, Japan Naoto Shiraishi Department of Basic Science, University of Tokyo, Komaba 3-8-1, Meguro-ku, Tokyo, Japan∗ Jun Takahashi (Dated: July 11, 2018) We provide a deterministic construction of hard instances for the maximum independent set problem (MIS). The constructed hard instances form an infinite graph sequence with increasing size, which possesses similar characteristics to sparse random graphs and in which MIS cannot be solved efficiently. We analytically and numerically show that all algorithms employing cycle-chain refutation, which is a general refutation method we introduce for capturing the ability of many known algorithms, cannot upper bound the size of the maximum independent set tightly. 8 1 0 2 l u J 5 ] S D . s c [ 1 v 9 3 7 3 0 . 7 0 8 1 : v i X r a PACS numbers: Introduction.- Hardness of optimization problems has been an important topic not only in computer sci- ence but also in physics, cryptography theory, and en- gineering. Traditional computational complexity the- ory in computer science mainly concerns the worst-case hardness, where many significant results including NP- completeness and hardness of approximation have been developed [1]. Recently, the cooperation of computer sci- ence and statistical physics has shed light on the prob- lems of the average-case hardness, in which we consider the hardness of random instances of the problem. From the side of statistical mechanics, similarity between some optimization problems and some physical models were first pointed out [2–4], and then the easy-to-hard transi- tion threshold where random instances become typically easy/hard has been evaluated [5–14] with some mathe- matical supports [15–19]. In addition, similarity to the spin glass transition phenomena including replica sym- metry breaking and the complex structure of the state space has also been studied intensively [20–29]. In spite of these successes, one of the most impor- tant questions, why a hard problem is hard, has not yet been fully addressed. Compared to past studies with the physical approaches, the computational complexity approach has not been successful on understanding the average case hardness [30]. Contrary to the situation for worst case hardness where numerous hard problems could be reduced to each other forming a huge class of NP- complete, reductions regarding average case hard prob- lems is found only in very few cases [31–35]. One stum- bling block to clarifying the origin of hardness is that we do not have concrete examples of hard instances. While there have been attempts to obtain hard instances mainly for a benchmark of some new algorithms [36–42], these constructions are probabilistic, not deterministic, and the hardness of instances is usually confirmed only empiri- cally. In a probabilistic construction, we know that most of the instances are hard, but we cannot specify a con- crete instance as a hard instance. Therefore, construct- ing a concrete hard instance which reflects properties of typical hard instances will be of great importance for a further understanding of the origin of hardness in hard problems. In this Letter, we construct the first example of con- crete hard instances of an optimization problem called the maximum independent set problem (MIS). We pro- vide a construction of an infinite sequence of graphs with increasing size, which is deterministic, not probabilis- tic. An algorithm exactly solving an optimization prob- lem carries out two tasks; searching and refuting, and we focus on the hardness of the latter refutation pro- cess. The average hardness of refutation for another op- timization problem was previously conjectured by Feige, with which some optimization problems are shown to be hard for approximation in the sense of worst-case hard- ness [43, 44]. By fixing the employed algorithm to a spe- cific type, e.g., Sum-of-Squares method and semidefinite- programing method, the possibility and impossibility of average hardness of refutation was proven for some con- straint satisfaction problems [45–48]. Following this line, we fix the method of refutation to a specific type which covers many of known algorithms for MIS, and show that refutation is impossible for the constructed instances. We first derive a lower bound on possible refutation for the constructed instances, and then show numerically and analytically that the true optimal value for these in- stances is strictly less than that. Maximum independent set problem.- We first explain the maximum independent set problem (MIS). For a given graph G, an independent set is a set of vertices which are not neighboring with each other on the graph (i.e., for any edge at least one of two end point vertices is not included in the set). The task of MIS is to find (one of) the largest independent set(s). For example, given the graph in the left of Fig. 1, the set of gray vertices in the right figure is one of the largest independent sets. The size of the largest independent set is called the in- dependent number, which we denote by N∗. We define 2 FIG. 1: Left: An example of a graph. In MIS, we seek the largest set of vertices which are not neighboring with each other. Right: One of the maximum independent sets drawn in gray (three vertices) of this graph. independent ratio as N∗/N , where N denotes the number of all vertices in the given graph. It is known that MIS is an NP-complete problem [49]. Numerical simulations imply that MIS for Erdos- Renyi random graphs with the average degree larger than Napier's constant 2.718··· is hard to compute efficiently on average [10, 50, 51]. In other words, even the best known algorithms fail to solve MIS of a random graph with high probability, if computation time is bounded by a polynomial of the graph size N . However, perhaps sur- prisingly, we had no concrete instance of a graph which is indeed hard to solve MIS, although most random graphs are hard. One difficulty for finding hard instances is that one could always construct an algorithm which solves a particular instance in short time by simply hard-wiring this instance [52], if the number of those hard instances is finite. Thus, the aim of this Letter is to provide ex- plicit and deterministic construction of an infinite graph sequence, which contains provably hard instances with arbitrarily large size. An exact algorithm for MIS should handle the follow- ing two tasks. (i) Searching: to find an independent set with size N∗. (ii) Refuting: to ensure that the size of all other independent sets are less than or equal to N∗. When we consider the large size limit, we can generalize our result to allow o(N ) errors, that is, the algorithms is regarded as succeeded if it finds an independent set with size N∗−o(N ) and it refutes an independent set with size N∗ + o(N ). We focus on the hardness of the latter task, refutation, and construct a graph sequence such that all plausible algorithms explained below fail to refute. Cycle-chain refutation.- It should be noted that we should not aim for a hardness proof regarding any type of refutation, since that will imply P(cid:54)=NP, which is be- lieved to be true but proof is currently out of reach. On the other hand, proving hardness for only one particular algorithm may raise questions on the generality of the result. Thus, to discuss the hardness of computation in as general a way as possible, we specify the method of refutation, so that any algorithm that employs the same FIG. 2: (Color online) Examples of the cycle-chain refuta- tion. (a) All the vertices in the graph given in Fig. 1 is covered once by a 5-cycle and a 3-cycle, which means N∗ ≤ 3. (b) All the vertices are covered twice by four 3-cycle and a single chain, which means N∗ ≤ 5/2. Because N∗ is integer, this is equivalent to N∗ ≤ 2. strategy will follow our result. We here introduce the idea of cycle-chain refutation, which captures the refutation ability of various algorithms for MIS. In the following, we shall first explain the procedure of the cycle-chain refutation, and then argue that it captures the ability of many known algorithms. In the cycle-chain refuta- tion, vertices of the graph are covered by cycles (closed loop path), chains (pair of neighboring vertices), and sin- gle vertices such that any vertex is covered by them the same number of times. Examples are drawn in Fig. 2. In Fig. 2.(a), all vertices are covered by cycles just once, while in Fig. 2.(b), all vertices are covered exactly twice. A cycle with length 2k + 1 or 2k can have at most k vertices which belong to a given independent set, and in a chain or a single vertex, there could be at most one. The cycle-chain refutation draws an upper bound of the independent number by combining a coverage of vertices and the above fact. From Fig. 2.(a), any independent set has at most two vertices on the 5-cycle and one ver- tex on the 3-cycle, which means that the independent number is bounded above by three. From Fig. 2.(b), any independent set has at most four vertices on the four 3-cycle and one vertex on the chain. All vertices are cov- ered twice, which means that the independent number is bounded above by 5/2. Since the independent number is always an integer, we find that the independent num- ber of Fig. 2.(b) is bounded above by two. We denote by Ncc the best upper bound of the independent number obtained by the cycle-chain refutation. Note that there indeed exist independent sets with size three for Fig. 2.(a) and with size two for Fig. 2.(b), and thus the cycle-chain refutation works tightly for these examples. It should be noted that this cycle-chain refutation is not an algorithm, since we do not specify the way how this refutation is obtained. While the presence of a cycle- chain refutation does not necessarily imply the existence of an efficient algorithm to find it, the absence of cycle- chain refutation will imply that all algorithms relying on it cannot conduct an efficient refutation. (a)(b) Linear programming relaxation and kernelization are two common algorithms used for MIS [53, 54]. Impor- tantly, they could both be naturally regarded as a refu- tation process which upper bounds the independent num- ber of a given instance. The refutation of both algorithms relies on a property of MIS called half-integrality, which is only caused by odd-length cycles. Since our cycle-chain refutation directly deals with the information of the odd- length cycles, its refutation ability is at least as powerful as linear programming relaxation and kernelization. In the following, we will consider graphs with all vertices having degree 2 or 3. In this case, linear programming relaxation only yields a trivial upper bound of N/2 for the independent number, and thus the cycle-chain refu- tation always provides a tighter upper bound. Further- more, different algorithms such as the belief propagation and the leaf removal algorithm, which have been analyzed from the perspective of statistical mechanics before, are known to fail in exactly the same region as the linear programming relaxation fails [50, 55]. This means that the cycle-chain refutation is at least as powerful as the refutation ability of various algorithms for MIS. Construction of the graph sequence.- We now con- struct a graph sequence of hard instances. The graph has p vertices labeled as {0, 1, . . . , p − 1} with a prime p. Each vertex x is connected to x ± 1 and −x−1 (mod p), where we let 0−1 = 0 and thus the vertex 0 has a self loop [56]. We call this graph as inverse graph. The inverse graph with p = 11 is depicted in Fig. 3. This graph turns out to be a well-known example of an ex- pander graph [57]. Expander graphs are graph sequences with large expansion ratios [58] and thus random walks on them mix rapidly. We shall show the following two relations for the se- quence of the inverse graphs: lim p→∞ lim p→∞ Ncc N N∗ N = < 1 2 1 2 , . (1) (2) The first part (1) shows that the cycle-chain refutation only reproduces a trivial upper bound 1/2 in the large size limit. On the other hand, the second part (2) shows that the independent ratio is strictly less than 1/2. Com- bining these two relations, we conclude that any algo- rithm based on the cycle-chain refutation cannot solve MIS efficiently (i.e., we need a brute-force type search for refutation, which could take exponentially long time in general). Part 1: Lower bound on refutation.- We first show that for any ε > 0 there exists p(cid:48) such that Ncc/N > 1/2 − ε holds for any p > p(cid:48). Consider a coverage of a given cycle-chain refutation. Let no k be the number of odd-length cycles with length 2k +1, ne be the number of chains (where we decompose all even-length cycles into chains), nv be the number of single vertices. We then 3 FIG. 3: An example of the inverse graph with p = 11. The vertex x is connected to x + 1, x − 1 and −x−1 mod p. have Ncc = k kno , (3) k(2k + 1)no (cid:22) (cid:80) (cid:23) (cid:80) k + ne + nv k + 2ne + nv · N where (cid:98)·(cid:99) is the floor function. The denominator(cid:80) and the numerator(cid:80) k(2k+ 1)no k + 2ne + nv represents the cumulative total number of vertices covered by cycles, chains, and single vertices, k +ne +nv represents the upper bound of the cumulative total number of vertices in an independent set counted by the cycle-chain refutation. If all the vertices are covered m times, the denominator is equal to mN . This relation confirms the fact that only small odd-length cycles (i.e., small odd k) are responsible for good refutations with tighter bounds. k kno A crucial property of the inverse graph is that the num- ber of small odd-length cycles in this graph is rigorously bounded. To explain this, we introduce a symbol se- quence to describe a directed path. A single directed jump from x to x + 1, x − 1, −x−1 is denoted by +, −, R, respectively, and a directed path from a given initial vertex is written as a sequence of symbols {+,−, R}. For example, a directed path 2 → 3 → 7 → 6 → 5 → 4 → 8 in Fig. 3 is expressed as the sequence [+R − − − R] with the initial vertex 2. A cycle can be regarded as a directed path with the same initial and final state x. By choosing a proper initial state x and a proper direction, any cycle can be described in the form of [+··· R] without loss of generality. We refer to such a sequence as cycle sequence. As an example, let us consider a 5-cycle described by [++R−R] (see Fig. 4). By construction, the initial state of this cycle x is the solution of − 1 − 1 x+2 − 1 ≡ x mod p. (4) Because the left hand side is (x + 2)/(x + 3), this equa- tion is quadratic and has at most two solutions. This 012345678910 4 (Color online) Exactly computed independent ratio FIG. 5: for the inverse graph from p = 11 to p = 311. Two dotted lines show the average value of the data, either using all of it or only the latter half. Both of the error bars do not exceed 0.48, and becomes smaller for the latter half, which strongly suggests a convergence to a value strictly less than 0.5. In the second line, because at most a(k(cid:48)) vertices are covered by odd-length cycles with length less than 2k(cid:48), Ncc is bounded below by the case that a(k(cid:48)) vertices are covered by short odd-length cycles with length less than 2k(cid:48) and other vertices are covered by cycles with length 2k(cid:48) + 1. Because ε is arbitrary, this relation is equivalent to the desired relation (1). Part 2: Upper bound on independent ratio.- We next show two arguments, one analytical and the other nu- merical, that the true independent ratio is strictly less than half. First, we exactly compute the independent ratio of the inverse graph up to p = 311, using a refined brute force search algorithm [51]. We remark that the computation time by this algorithm increases exponen- tially with the size p. The obtained results are shown in Fig. 5, where the independent ratio is plotted against the system size N = p. The plot suggests that although the independent ratio fluctuates, it converges to a value around 0.46, which is strictly less than half. We provide another analytic argument supporting our claim. Let A be the N × N normalized adjacency matrix of a d-regular graph, where Aij = 1/d if there is an edge between the vertices i and j in the graph and Aij = 0 otherwise. We set Aii = 0. We denote the eigenvalues of A with decreasing order by λ1 ≥ λ2 ≥ ··· ≥ λN . If the graph is d-regular, it is known that λ1 = 1, λN ≥ −1 and the equality holds if and only if the graph is bipartite [61]. In addition, the independent ratio of a d-regular graph is bounded above by the smallest eigenvalue, which is called Hoffman's bound [61]: N∗ N ≤ −λN 1 − λN . (8) (7) Thus, obtaining a good lower bound of λN , we have a good bound of the independent ratio. It is noteworthy FIG. 4: Schematic diagram of a possible pass of [+ + R − R] with the initial vertex x. means that the inverse graph contains at most two 5- cycles expressed as [+ + R − R]. For any cycle sequence, the corresponding equation has at most two solutions, and hence the cycle described by this cycle sequence ap- pears at most twice in a given inverse graph. The exact number of cycles described by a particular cycle sequence in a given inverse graph could be obtained by calculat- ing the quadratic residue [59]. (For example, Eq. (4) is transformed into a quadratic equation y2 ≡ 3 mod p with y = x + 2, which has two solutions for p ≡ 1, 11 mod 12 and no solution for p ≡ 5, 7 mod 12. See also Supplemental Material [60]) Because the pairs +−, −+ and RR do not appear in cycle sequences, the number of cycle sequences with length 2k + 1 is bounded above by 22k−1. This directly implies that 2k + 1 cycles appear in the inverse graph for any p at most 2 · 22k−1 = 22k times. Hence, in any cycle-chain refutation, the number of vertices cov- ered by odd-length cycles with length less than 2k(cid:48) is bounded above by a constant independent of p: a(k(cid:48)) := k=1 (2k + 1)22k. In other words, short odd-length cy- cles cover only a small fraction of vertices for large p. (cid:80)k(cid:48)−1 Then, by defining b(k(cid:48)) :=(cid:80)k(cid:48)−1 (cid:19) k=1 k22k and setting as − 1 (cid:18) 1 , k(cid:48) ≥ 1 2 ε N = p ≥ p(cid:48) :=a(k(cid:48)) + a(k(cid:48)) − 2b(k(cid:48)) + 2 ε (5) (6) (cid:80) k kno for a given ε > 0, we have a lower bound of Ncc: Ncc ≥ (cid:80) k + ne + nv k + 2ne + nv · N − 1 ≥ b(k(cid:48)) + k(cid:48) · N−a(k(cid:48)) a(k(cid:48)) + (2k(cid:48) + 1) N−a(k(cid:48)) 2k(cid:48)+1 · N − 1 ≥ N k(2k + 1)no (cid:18) 1 2k(cid:48)+1 (cid:19) . − ε 2 (cid:692)(cid:692)x(cid:693)RR 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0 50 100 150 200 250 300N*/ NNExact value0.5Over-all averageLatter-half average that the second largest eigenvalue in the absolute sense λ := max(λ2,−λN ) characterizes the speed of mixing through random walks on the graph. The larger the gap 1 − λ is, the quicker the probability distribution equilibrates. For example, a review paper on the ex- pander graph [57] shows that the inverse graph satisfies λ < 1− 10−4 for large N . This relation suggests that the independent ratio for sufficiently large N is strictly less than half: N∗ N ≤ 0.499975 < 0.5. (9) While a tighter bound of λN should give us a better bound on the independent ratio, this already suffices for our argument. Discussion.- We explicitly constructed hard instances (an infinite sequence of graphs) of the maximum inde- pendent set problem (MIS). For this graph, the cycle- chain refutation, which is a plausible method of refuta- tion, only provides the upper bound of the independent ratio as 1/2, while the true independent ratio is strictly less than 1/2. This difference implies that the hardness stems from not local but global structures of the graph. To our best knowledge, this is the first explicit deter- ministic construction of a hard instance in optimization problems. It is noteworthy that the inverse graph shares various properties with K-regular random graphs with K ≥ 3, which are known to be typically hard for MIS [25]. For instance, it is known that regular random graphs are ex- pander graphs [57] and have few short cycles [62] with high probability. The expected independent ratio of 3-regular random graphs is almost surely larger than 6 ln(2/3)−2 (cid:39) 0.4328 [63, 64] and smaller than 0.458 [65], which is close to the numerical result of the inverse graph, which is also almost 3-regular. These facts lead us to an- ticipate that the introduced inverse graph shares the typi- cal properties of random graphs, which are hard instances of MIS. Recent studies on computational hardness from the viewpoint of statistical mechanics have paid much at- tention to the connection between the energy landscape of the solution space and the hardness of problems [21– 23, 26–28], which also resulted in inspiring efficient algo- rithms [66–68]. A concrete example of a hard instance will help our investigation of the deep structure of compu- tational hardness and serve as a benchmark for analytical evaluation of algorithms, and would further provide in- sights on average-case hardness and various phenomena arising from it. Acknowledgement.- We thank Koji Hukushima, Yoshiyuki Kabashima, Tomoyuki Obuchi, and Satoshi Takabe for fruitful discussions. NS was supported by Grant-in-Aid for JSPS Fellows JP17J00393. 5 ∗ Current Institute affiliation: of Physics, Chinese Academy of Sciences, No.8, 3rd South Street, Zhong- guancun, Beijing, China; [email protected] [1] S. Arora and B. Barak, Computational Complexity: A Modern Approach. Cambridge University Press (2009). [2] M. M´ezard et G. Parisi, Replicas and optimization. J. Physique Lett. 46, 771-778 (1985). [3] M. M´ezard et G. Parisi, A replica analysis of the trav- elling salesman problem, J. Phys. France 47, 1285-1296 (1986). [4] Y. Fu and P. W. Anderson, Application of statistical me- chanics to NP-complete problems in combinatorial opti- misation, J. Phys. A: Math. Gen. 19 1605 (1986). [5] P. C. Cheeseman, B. Kanefsky, and W. M. Taylor, Where the really hard problems are. IJCAI 91, 331 (1991). [6] D. Mitchell, B. Selman, and H. Levesque, Hard and easy distributions of SAT problems. AAAI 92, 459 (1992). [7] S. Kirkpatrick and B. Selman, Critical Behavior in the Satisfiability of Random Boolean Expressions. Science 264, 1297 (1994). [8] R. Monasson and R. Zecchina, Statistical mechanics of the random K-satisfiability model. Phys. Rev. E 56, 1357 (1997). [9] R. Monasson, R. Zecchina, S. Kirkpatrick, B. Selman, and L. Troyansky, Determining computational complexity from characteristic phase transitions. Nature 400, 133 (1999). [10] M. Weigt and A. K. Hartmann, Number of Guards Needed by a Museum: A Phase Transition in Vertex Covering of Random Graphs. Phys. Rev. Lett. 84, 6118 (2000). [11] F. Ricci-Tersenghi, M. Weigt, and R. Zecchina, Simplest random K-satisfiability problem. Phys. Rev. E 63, 026702 (2001). [12] M. M´ezard, G. Parisi, and R. Zecchina, Analytic and Algorithmic Solution of Random Satisfiability Problems. Science 297, 812 (2002). [13] M. M´ezard and R. Zecchina, Random K-satisfiability problem: From an analytic solution to an efficient al- gorithm. Phys. Rev. E 66, 056126 (2002). [14] A. K. Hartmann and M. Weigt, Phase Transitions in Combinatorial Optimization Problems: Basics, Algo- rithms and Statistical Mechanics. Wiley-VCH (2005). [15] E. Friedgut, Sharp thresholds of graph properties, and the k-sat problem. J. Amer. Math. Soc. 12, 1017 (1999). [16] D. Achlioptas and Y. Peres, The threshold for random k-SAT is 2k log 2 − O(k). J. Amer. Math. Soc. 17, 947 (2004). [17] D. Achlioptas, A. Naor, and Y. Peres, Rigorous location of phase transitions in hard optimization problems. Na- ture 435, 759 (2005). [18] M. Bayati, D. Gamarnik, and P. Tetali, Combinatorial approach to the interpolation method and scaling limits in sparse random graphs. Proceedings of the forty-second ACM symposium 105 (2010). [19] J. Ding, A. Sly, and N. Sun, Proof of the satisfiability conjecture for large k. Proceedings of the forty-seventh annual ACM symposium on Theory of computing. 59 (2015). [20] H. Zhou, Long-Range Frustration in a Spin-Glass Model of the Vertex-Cover Problem. Phys. Rev. Lett. 94, 217203 (2005). [21] F. Krz¸aka(cid:32)la, A. Montanari, F. Ricci-Tersenghi, G. Semer- jian and L. Zdeborov´a, Gibbs states and the set of solu- tions of random constraint satisfaction problems. Proc. Nat. Acad. Sci. 104, 10318 (2007). [22] L. Zdeborov´a and F. Krz¸aka(cid:32)la, Phase transitions in the coloring of random graphs, Phys. Rev. E 76, 031131 (2007). [23] D. Achlioptas and A. Coja-Oghlan, Algorithmic barri- ers from phase transitions. Found. Comp. Sci. 2008, 793 (2008). [24] K. Li, H. Ma, and H. Zhou, From one solution of a 3- satisfiability formula to a solution cluster: Frozen vari- ables and entropy. Phys. Rev. E 79, 031102 (2009). [25] P. Zhang, Y. Zeng, and H. Zhou, Stability analysis on the finite-temperature replica-symmetric and first-step replica-symmetry-broken cavity solutions of the random vertex cover problem Phys. Rev. E 80, 021122 (2009). [26] L. Zdeborov´a, Statistical Physics of Hard Optimization Problems. Acta Physica Slovaca 59, 169 (2009). [27] L. Zdeborov´a and F. Krz¸aka(cid:32)la, Generalization of the cav- ity method for adiabatic evolution of Gibbs states. Phys. Rev. B 81, 224205 (2010). [28] A. Braunstein, L. DallAsta, G. Semerjian, and L. Zde- borov´a, The large deviations of the whitening process in random constraint satisfaction problems. J. Stat. Mech. P053401 (2016). [29] M. M´ezard and A. Montanari, Information, Physics, and Computation. Oxford University Press (2009). [30] A. Bogdanov and L. Trevisan, Average-Case Complexity. Found. Tre. Theor. Comp. Sci. 2, 1 (2006). [31] R. J. Lipton, New Directions In Testing. Distributed Computing and Cryptography, 2, 191 (1989). [32] M. Ajtai, Generating hard instances of lattice problems. Proceeding of STOC '96 Proceedings of the twenty-eighth annual ACM symposium on Theory of computing, 99 (1996). [33] O. Regev, On lattices, learning with errors, random lin- ear codes, and cryptography. J. ACM 56, 34 (2009). [34] A. Daniely, N. Linial, and S. Shalev-Shwartz, From av- erage case complexity to improper learning complexity. Proceedings of the forty-sixth annual ACM symposium on Theory of computing, 441 (2014). [35] T. Wang, Q. Berthet, and Y. Plan, Average-case Hard- ness of RIP Certification. arXiv:1605.09646 (2016). [36] W. Barthel, A. K. Hartmann, M. Leone, F. Ricci- Tersenghi, M. Weigt, and R. Zecchina, Hiding Solutions in Random Satisfiability Problems: A Statistical Mechan- ics Approach. Phys. Rev. Lett. 88, 188701 (2002). [37] K. Xu, F. Boussemart, F. Hemery, and C. Lecoutre, Random constraint satisfaction: Easy generation of hard (satisfiable) instances. Artificial intelligence, 171, 514 (2007). [38] H. Jia, C. Moore, and D. Strain, Generating Hard Satis- fiable Formulas by Hiding Solutions Deceptively. J. Artif. Intel. Res. 28, 107 (2007). [39] I. Hen, J. Job, T. Albash, T. F. Rønnow, M. Troyer, and D. A. Lidar, Probing for quantum speedup in spin-glass problems with planted solutions. Phys. Rev. A 92, 042325 (2015). [40] H. G. Katzgraber, F. Hamze, Z. Zhu, A. J. Ochoa, and H. Munoz-Bauza, Seeking Quantum Speedup Through Spin Glasses: The Good, the Bad, and the Ugly. Phys. Rev. X 5, 031026 (2015). 6 [41] J. Marshall, V. Martin-Mayor, and I. Hen, Practical en- gineering of hard spin-glass instances. Phys. Rev. A 94, 012320 (2016). [42] S. Takabe, K. Hukushima, and A. K. Hartmann, Large-deviation Properties of Linear-programming Com- putational Hardness of the Vertex Cover Problem. arXiv:1802.02350 (2018). [43] U. Feige, Relations between average case complexity and approximation complexity. Proceeding of STOC '02 Pro- ceedings of the thiry-fourth annual ACM symposium on Theory of computing, 534 (2002). [44] M. Alekhnovich, More on Average Case vs Approxi- mation Complexity. Computational Complexity 20, 755 (2011). [45] B. Barak and A. Moitra, Tensor prediction, Rademacher complexity and random 3-XOR. CoRR, abs/1501.06521 (2015). [46] S. R. Allen, R. O'Donnell, and D. Witmer, How to Re- fute a Random CSP. Foundations of Computer Science (FOCS), IEEE 56th Annual Symposium, 689 (2015). [47] P. K. Kothari, R. Mori, R. O'Donnell, and D. Wit- mer, Sum of squares lower bounds for refuting any CSP. arXiv:1701.04521 (2017). [48] Y. Deshpande, A. Montanari, R. O'Donnell, T. Schramm, and S. Sen, The threshold for SDP-refutation of random regular NAE-3SAT. arXiv:1804.05230 (2018). [49] Whether MIS should be classified as NP-complete or NP- hard depends on the precise formulation of the problem (i.e. decision/optimization etc.). Here, we will not get into this subtlety and simply assume that MIS in the form we present in this paper captures the intrinsic hardness of NP. [50] S. Takabe and K. Hukushima, Typical Behavior of the Linear Programming Method for Combinatorial Opti- mization Problems: A Statistical-Mechanical Perspective. J. Phys. Soc. Jpn. 83, 043801 (2014). [51] J. Takahashi, S. Takabe, and K. Hukushima, An Ex- act Algorithm Exhibiting RS-RSB/Easy-Hard Correspon- dence for the Maximum Independent Set Problem. J. Phys. Soc. Jpn. 86, 073001 (2017). [52] We can always construct an algorithm solving MIS of a given fixed instance G(cid:48) with independent number N∗ efficiently as follows: Consider an algorithm which first checks whether an input graph G is the given graph G(cid:48) or not. If the graph is the given graph, then it returns the number N∗. If not, then it computes the independent number of the graph. This algorithm trivially solves MIS of the given particular graph efficiently. [53] G. L. Nemhauser and L. E. Trotter Jr., Vertex packings: Structural properties and algorithms. Math. Program. 8, 232 (1975). [54] M. Cygan, F. V. Fomin, L. Kowalik, D. Lokshtanov, D. Marx, M. Pilipczuk, M. Pilipczuk, S. Saurabh, Parame- terized Algorithms. Springer (2015). [55] S. Takabe and K. Hukushima, Typical performance of approximation algorithms for NP-hard problems. J. Stat. Mech. 113401 (2016). [56] If −x−1 ≡ x ± 1 mod p, we connect these two vertices with two edges. [57] S. Hoory, N. Linial, and A. Wigderson, Expander graphs and their applications. Bull. Amer. Math. Soc. 43, 439 (2006). [58] For a given set of vertices S, we consider the ratio of the number of edges connecting in and out of S to the 7 number of vertices S. The expansion ratio of a graph G is the maximum of the above ratio with respect to a set S with S ≤ G /2. [59] W. A. Coppel, Number Theory: An Introduction to Math- ematics. Springer (2006). [60] See Supplemental Material, which shows a table of pres- ence/absence of short cycles and some basic results on quadratic residues. [61] A.E. Brouwer and W.H. Haemers, Spectra of Graphs. Springer, New York (2012). [62] N. C.Wormald, The asymptotic distribution of short cy- cles in random regular graphs. J. Comb. Theory 31, 168 (1981). [63] A. Frieze and S. Suen, On the independence number of random cubic graphs. Random Structures and Algo- rithms 5, 649 (1994). [64] N. C. Wormald, Differential Equations for Random Pro- cesses and Random Graphs. Ann. Appl. Prob. 5, 1217 (1995). [65] L. Dall'Asta, P. Pin, and A. Ramezanpour, Statistical mechanics of maximal independent sets. Phys. Rev. E 80, 061136 (2005). [66] A. Montanari, F. Ricci-Tersenghi, and G. Semerjian, Solving Constraint Satisfaction Problems through Belief Propagation-guided decimation. arXiv:0709.1667, Pro- ceedings of the 45th Allerton Conference, 352 (2007). [67] R. Marino, G. Parisi and F. Ricci-Tersenghi, The back- tracking survey propagation algorithm for solving random K-SAT problems. Nat. Comm. 7, 12996 (2016). [68] C. Baldassi, C. Borgs, J. T. Chayes, A. Ingrosso, C. Lu- cibello, L. Saglietti, and R. Zecchina, Unreasonable ef- fectiveness of learning neural networks: From accessible states and robust ensembles to basic algorithmic schemes. Proc. Nat. Acad. Sci. 113, E7655 (2016). Supplemental Materials for "Constructing Concrete Hard Instances of the Maximum Independent Set Problem" 8 Naoto Shiraishi and Jun Takahashi Table of presence or absence of short cycles with odd length Length Sequence Quadratic equation two solutions no solution others x = −1 is a unique solution for any p x = −2 is a unique solution for any p no solution for any p no solution for any p no solution for any p no solution for any p x = −1 is a unique solution for any p no solution for any p no solution for any p p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1 mod 4 p ≡ 1, 7 mod 8 p ≡ 3 mod 4 p ≡ 3, 5 mod 8 p ≡ 1 mod 4 p ≡ 3 mod 4 p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1 mod 4 p ≡ 3 mod 4 p ≡ 1, 7 mod 8 p ≡ 1 mod 4 p ≡ 3, 5 mod 8 p ≡ 3 mod 4 p ≡ 1, 7 mod 8 p ≡ 3, 5 mod 8 p ≡ 3 mod 4 p ≡ 1 mod 4 p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 p ≡ 1 mod 4 p ≡ 3 mod 4 3 5 7 9 y2 ≡ −1 mod p y2 ≡ 15 mod p y2 ≡ 3 mod p y2 ≡ 3 mod p y2 ≡ 3 mod p y2 ≡ −1 mod p y2 ≡ 2 mod p [+ + R] [+ + + + R] [+ + R − R] [+ + R + R] [+ + + + + + R] [+ + + + R + R] [+ + + + R − R] [+ + +R + +R] [+ + +R − −R] [+ + R + R − R] [+ + R − R + R] y2 ≡ 3 mod p [+ + R + R + R] [+ + R − R − R] y2 ≡ 3 mod p [+ + + + + + + + R] y2 ≡ 15 mod p [+ + + + + + R + R] y2 ≡ 3 mod p [+ + + + + + R − R] y2 ≡ 15 mod p [+ + + + +R + +R] y2 ≡ 35 mod p [+ + + + +R − −R] y2 ≡ 15 mod p [+ + + + R + + + R] y2 ≡ 3 mod p [+ + + + R − − − R] y2 ≡ 6 mod p [+ + + + R + R + R] [+ + + + R − R − R] [+ + + + R + R − R] y2 ≡ 15 mod p [+ + + + R − R + R] y2 ≡ 15 mod p [+ + +R + +R + R] y2 ≡ −1 mod p [+ + +R + +R − R] y2 ≡ 6 mod p [+ + +R − −R + R] y2 ≡ 15 mod p [+ + +R − −R − R] y2 ≡ 2 mod p [+ + +R + R + +R] y2 ≡ −1 mod p [+ + +R + R − −R] y2 ≡ 15 mod p [+ + +R − R + +R] y2 ≡ 6 mod p [+ + +R − R − −R] y2 ≡ 2 mod p [+ + R + +R + +R] [+ + R + +R − −R] y2 ≡ 6 mod p [+ + R + R + R + R] [+ + R + R − R + R] [+ + R + R + R − R] y2 ≡ −1 mod p [+ + R + R − R − R] y2 ≡ 3 mod p [+ + R − R + R + R] y2 ≡ −1 mod p [+ + R − R + R − R] y2 ≡ 6 mod p [+ + R − R − R + R] y2 ≡ 3 mod p [+ + R − R − R − R] p ≡ 1, 11 mod 12 p ≡ 5, 7 mod 12 x = −1 is a unique solution for any p The table in the previous page shows which type of cycle appears in particular inverse graphs. The table is read as follows. For example, the number of the 7-cycle described by the cycle sequence [+ + + + + + R] is equal to the number of solutions of the equation y2 ≡ 2 mod p, which is two If p ≡ 1, 7 mod 8 and is none if p ≡ 3, 5 mod 8. In contrast, the 7-cycle described by the cycle sequence [+ + + + R + R] always exists uniquely, and the initial vertex of this sequence is always x = −2. Here, the equation corresponding to this sequence as Eq. (4) is not a quadratic equation but a simple first-degree polynomial equation. In some cases, this equation has no solution for any p, which occurs, for example, for the 7-cycle described by the cycle sequence [+ + R + R − R]. In this table, we leave some columns for quadric residues of composite numbers blank, because the conditions for the solutions to have two/no solutions are relatively complicated. The explicit conditions for those cases could be obtained in the following way. 9 We here briefly explain a mathematical background behind this calculation. We first introduce the Legendre's symbol for a prime p and an integer a which are relatively prime: (cid:40) (cid:18) a (cid:19) p := 1 −1 : y2 ≡ a (mod p) has two solutions : y2 ≡ a (mod p) has no solution. The Legendre's symbol satisfies the following relation(cid:18) ab (cid:19) p (cid:18) a (cid:19)(cid:18) b (cid:19) p p , = (A.1) (A.2) (A.3) (A.4) (A.5) which could be used to calculate the conditions of composite quadratic residues having two/no solutions. This relation says that y2 ≡ ab mod p has two solutions if and only if (i) both y2 ≡ a mod p and y2 ≡ b mod p have two solutions, or (ii) both y2 ≡ a mod p and y2 ≡ b mod p have no solution. For example, y2 ≡ 15 mod p has two solutions if and only if (i) both p ≡ 1, 11 mod 12 and p ≡ 1, 4 mod 5 hold, or (ii) both p ≡ 5, 7 mod 12 and p ≡ 2, 3 mod 5 hold. To calculate the quadratic residue of primes, we employ the quadratic reciprocity and the following two supplementary laws q p (cid:18) p (cid:19)(cid:18) q (cid:19) (cid:19) (cid:18)−1 (cid:18) 2 (cid:19) p p = (−1) p−1 2 q−1 2 , = (−1) = (−1) p−1 2 , p2−1 8 . We list the conditions for quadratic residues of small primes and the special case -1 below. Quadratic equation two solutions p ≡ 1 mod 4 y2 ≡ −1 mod p p ≡ 1, 7 mod 8 y2 ≡ 2 mod p p ≡ 1, 11 mod 12 y2 ≡ 3 mod p y2 ≡ 5 mod p p ≡ 1, 4 mod 5 p ≡ 1, 3, 9, 19, 25, 27 mod 28 p ≡ 5, 11, 13, 15, 17, 23 mod 28 y2 ≡ 7 mod p no solution p ≡ 3 mod 4 p ≡ 3, 5 mod 8 p ≡ 5, 7 mod 12 p ≡ 2, 3 mod 5
1806.06617
2
1806
2018-08-09T14:33:05
A Flow Formulation for Horizontal Coordinate Assignment with Prescribed Width
[ "cs.DS" ]
We consider the coordinate assignment phase of the well known Sugiyama framework for drawing directed graphs in a hierarchical style. The extensive literature in this area has given comparatively little attention to a prescribed width of the drawing. We present a minimum cost flow formulation that supports prescribed width and optionally other criteria like lower and upper bounds on the distance of neighbouring nodes in a layer or enforced vertical edges segments. In our experiments we demonstrate that our approach can compete with state-of-the-art algorithms.
cs.DS
cs
A Flow Formulation for Horizontal Coordinate Assignment with Prescribed Width Michael Junger1, Petra Mutzel2[0000−0001−7621−971X], and Christiane Spisla2() 1 University of Cologne, Cologne, Germany [email protected] 2 TU Dortmund University, Dortmund, Germany {petra.mutzel,christiane.spisla}@cs.tu-dortmund.de Abstract. We consider the coordinate assignment phase of the well known Sugiyama framework for drawing directed graphs in a hierarchi- cal style. The extensive literature in this area has given comparatively little attention to a prescribed width of the drawing. We present a mini- mum cost flow formulation that supports prescribed width and optionally other criteria like lower and upper bounds on the distance of neighboring nodes in a layer or enforced vertical edge segments. In our experiments we demonstrate that our approach can compete with state-of-the-art al- gorithms. Keywords: Hierarchical Drawings · Coordinate Assignment · Minimum Cost Flow · Prescribed Drawing Width 1 Introduction The Sugiyama framework [12] is a popular approach for drawing directed graphs. It layouts the graph in a hierarchical manner and works in five phases: Cycle removal, layer assignment, crossing minimization, coordinate assignment and edge routing. If the graph is not already acyclic, some edges are reversed to prepare the graph for the next phase. Then each node is assigned to a layer so that all edges point from top to bottom. After that the orderings of the nodes within each layer are determined. In the coordinate assignment phase that we consider here, the exact positions of the nodes are fixed. Finally the edges are layouted, e.g., as straight lines. A good overview over the different phases of the framework can be found in [9]. After the nodes are assigned to layers and the orderings of the nodes within their layers are fixed, the task of the coordinate assignment phase is to compute x-coordinates for all nodes. There are several, sometimes contradicting, objec- tives in this phase, e.g., short edges, minimum distance between neighboring nodes, straight edges, balanced positions of the nodes between their neighbors in adjacent layers, and few bend points of edges that cross multiple layers. The criterion "short edges" can be handled by exact algorithms as well as fast heuris- tics that give pleasant results, possibly also considering other aesthetic criteria. 2 Junger et al. k ··· k ··· Fig. 1. In the left picture the horizontal edge length is k − 3 and the width is 1, in the right picture the horizontal edge length is 0 and the width is k − 2, where k is the number of layers. When it comes to the width of the drawing one usually tries to restrict the maximum number of nodes in one layer, see e.g. [5]. Long edges, i.e. edges that span more than two layers, are often split into paths with one dummy node on each intermediate layer. Healy and Nikolov [8] present a branch-and- cut approach to compute a layering that takes the influence of the number of dummy nodes on the width into account. Jabrayilov et al. [10] do the same in a mixed integer program that treats the first two phases of the Sugiyama framework simultaneously. But still, the maximum number of nodes in one layer does not necessarily define the actual width of the final drawing, as illustrated in Fig. 1. The main objective of most methods for the coordinate assignment phase is "short edges", which often leads to small drawings, but the width of the final layout is not directly addressed. There may be further requirements for the final drawing, such as an aspect ratio in order to make optimal use of the drawing area, or a maximum distance between two nodes on the same layer if they are semantically related. A common request is that inner segments of long edges are drawn as vertical straight lines in order to improve readability. Related work. Sugiyama et al. [12] present a quadratic programming formulation that has a combination of two asthetic criteria as objective function, short edges (closeness to adjacent nodes) and a balanced layout (positioning nodes close to the barycenter of their upper and lower neighbors). Gansner et al. [7] give a simpler formulation in which they replace quadratic terms of the form (xv−xu)2 by xv−xu and leave out the balance terms. The coordinate assignment problem can be interpreted as an instance of the layer assignment problem, and they suggest to apply the network simplex algorithm to an auxiliary graph to obtain a drawing with minimum horizontal edge length. Given an initial layout, some heuristics sweep through the layers and try to shift the nodes to better positions depending on the fixed x-coordinates of their neighbors in adjacent layers, see e.g. [6,11,12]. Two fast heuristics that compute coordinates from scratch are presented by Buchheim et al. [3] and by Brandes and Kopf [2]. Both algorithms draw inner segments of long edges straight and aim for a balanced layout with short edges. Horizontal Coordinate Assignment with Prescribed Width 3 Our Contribution. We formulate the coordinate assignment problem as a min- imum cost flow problem that can be solved efficiently. Within this formulation we can fix the maximum width of the final drawing as well as a maximum and minimum horizontal distance between nodes in the same layer and we can en- force straightness to some edges. We compute x-coordinates such that the total horizontal edge length is minimized subject to these further constraints. 2 Notation and Preliminaries Let G = (V, E) be a directed graph with V = n nodes and E = m edges. For a directed edge e = (u, v) we denote the start node of e with start(e) = u and the target node of e with target(e) = v. A path P from u to v of length k is a set of edges {ei = (vi, vi+1) i = 1, . . . , k where u = v1 and v = vk+1}. We also ∗→ v. If vk+1 = v1 it is called a cycle. A graph is called a directed acyclic write u graph (DAG) if it has no cycles. A layering L of a graph assigns every v ∈ V a layer Li, such that i < j holds for every edge e = (u, v) with L(u) = Li and L(v) = Lj. The layering is called proper if L(v) = L(u) + 1 for every edge (u, v), i.e., the layers of every pair of adjacent nodes are consecutive. An edge that violates the latter property is called a long edge. Every graph with a layering can be transformed into a graph with a proper layering by subdividing every long edge into a chain of edges. We denote with L the number of layers and with Li the number of nodes in layer Li. An ordering ord defines a partial ordering on the nodes of G. For every layer Li it assigns each node in Li a number 1 ≤ j ≤ Li and we write u < v if ord(u) < ord(v). We denote with vi Given a graph G with a layering L and an ordering ord the horizontal co- ordinate assignment problem (HCAP) asks for x-coordinates for every node, so that x(u) < x(v) if u < v. We will restrict ourselves to integer coordinates. The horizontal length of an edge e = (u, v) is defined as length(e) = x(v)− x(u) and e∈E length(e). The width of the assignment is maxv∈V x(v)− minv∈V x(v). Unless otherwise stated, we mean the horizontal length whenever we talk about the length of an edge. the total horizontal edge length is length(E) =(cid:80) j the j-th node in layer Li. HCAPminEL is the variant of HCAP in which we also want to mimimize the total horizontal edge length. We assume familiarity with minimum cost flows. Ahuja et al. [1] give a good overview. Let N = (VN , EN ) be a directed graph with a super source s and a su- per sink t, so for all other nodes the amount of incoming flow equals the amount of outgoing flow. We have lower and upper bounds on the edges and a cost function cost : EN → R. Let f be a feasible flow. For a subset of nodes V (cid:48) ⊆ VN \ {s, t} e=(u,v) f (e) the flow through V (cid:48). For s we define f (s) to be the total amount of flow leav- e∈E(cid:48) f (e) e∈E(cid:48) cost(e) the cost of E(cid:48) and with we denote with f (V (cid:48)) = (cid:80) ing s. For a subset of edges E(cid:48) ⊂ EN we denote with f (E(cid:48)) = (cid:80) the flow over E(cid:48) and with cost(E(cid:48)) = (cid:80) costf = (cid:80) e=(v,w) f (e) = (cid:80) v∈V (cid:48)(cid:80) v∈V (cid:48)(cid:80) f (e) · cost(e) the total cost of f . e∈EN 4 Junger et al. 3 Network Flow Formulation In this section we describe the construction of a network for the horizontal coordinate assignment problem. Given a minimum cost flow in this network we show how to obtain x-coordinates for all nodes such that the total horizontal edge length is minimized. By a simple modification we can compute x-coordinates that give us minimum total horizontal edge length with respect to a given maximum width of the drawing. The basic idea is that flow represents horizontal distance and we send flow from top to bottom through the layers. j+1 (wi 3.1 Network Construction Let G = (V, E) be a DAG with a proper layering L and an ordering and let N = (VN , EN ) be the minimum cost flow network. For now let us assume that neighboring nodes on a layer should have an equal minimum distance of one and that we have no further requirements concerning the edges. For every layer Li with i ∈ {1, . . . ,L} we add nodes wi 1, . . . , ziLi to N . Imagine the node wi 1, . . . , wiLi and zi 0, zi j placed above the layer Li and between 0 is placed at the left end and wiLi at the right end of the layer). vi j and vi The nodes zi j are placed in the same way below layer Li. Although we do not have a drawing of G at this moment we can still use terms like "above" and "below" because the layering gives us a vertical ordering of the nodes of G and we can talk about "left" and "right" because of the given ordering of the nodes in each layer. Since we are placing the nodes wi j and zi j "between" the nodes vi j and vi j+1 we want to extend the "<" relation to give a partial ordering on V ∪ VN in the following way: wi 2 < ··· < viLi < wiLi and 2 < ··· < viLi < ziLi. We connect wi zi j with an edge ai 0 < vi that has a lower bound of one and an upper bound of ∞ and a cost of zero. The j flow over these edges will define the distance between vi j+1. We denote the set of these edges with A. Figure 2(a) shows an example. For every layer Li with i ∈ {1, . . . ,L} and every j ∈ {0, . . . ,Li− 1} we add j+1, zi j) edges to N . The lower bound of these edges is zero and the upper bound is ∞. The −→ cost of these network edges equals the number of graph edges they "cross over". bwi j equals the number of incoming graph That means, the cost of j and ←− edges of node vi bz i j and the cost of j and j equals the number of outgoing graph edges of vi j, see Fig. 2(a). Positive flow over one of these edges will cause the crossed-over graph edges to have positive horizontal length. We call the set of these edges B. j and vi j+1) and j = (wi j = (wi j = (zi j, zi 1 < zi 1 < vi 0 < vi 1 < wi 1 < vi j = (zi j+1, wi j), j, wi j+1), −→ bz i −→ bz i ←− bwi ←− bwi −→ bwi 0, wi j to zi ←− bz i j and every wi+1 Now we connect the nodes of neighboring layers. We could add edges between every zi , but we want to keep the number of edges between layers as small as possible. We add edges only in special situations and will show later that this suffices for correctness. For every layer Li with i ∈ {1, . . . ,L − 1} we ) and ciLiLi+1 = (ziLi, wi+1Li+1) to the network with add edges ci 00 = (zi 0, wi+1 k 0 Horizontal Coordinate Assignment with Prescribed Width 5 cost( j)= cost( ←− bwi −→ bwi j wi j−1 ai j−1 zi j−1 vj −→ bz i j ←− bz i cost( j)= cost( −→ bwi j)= 1 ←− bwi j wi j ai j zi j ←− bz i −→ j bz i j)= 2 • • • vi j vi j+1 • • • e1 e3 zi j ci jk wi+1 k e2 e4 • • • vi+1 k vi+1 k+1 • • • (a) (b) Fig. 2. Illustration of edges of the sets (a) A, B and (b) C. Nodes of G are white circles, nodes of N are green rectangles. Edges of G are gray, edges of N are green. k k , target(e4) = vi+1 jk = (zi j(cid:48), where vi j, wi+1 j(cid:48) is the next node to the right of vi a lower bound of zero, an upper bound of ∞ and a cost of zero. Additionally ) if there exist e1, e2, e3, e4 ∈ E with start(e1) = vi we add edges ci j, start(e2) = vi j with an outgoing edge and target(e3) = vi+1 is the next node to the right k with an incoming edge and the following conditions holds: start(e3) ≤ of vi+1 start(e1) < start(e2) ≤ start(e4) and target(e1) ≤ target(e3) < target(e4) ≤ target(e2). We call this situation a hug between zi . These edges get a lower bound of zero, an upper bound of ∞, and the cost equals the number q) ∈ E p ≤ j ∧ q ≥ of graph edges they cross over: cost(ci k(cid:48) or p ≥ j(cid:48) ∧ q ≤ k}. Like the edges of B, flow on edges of this kind will cause horizontal length and we denote the set of all ci jk by C. Figure 2(b) illustrates a hug situation. jk) = {e = (vi j and wi+1 , where vi+1 p, vi k(cid:48) k(cid:48) k j , j ∈ {1, . . . ,L1} and t with every z Finally we add a super source s and a super sink t to the network. We connect L k , k ∈ {1, . . . ,LL}. These s with every w1 edges get a lower bound of zero, an upper bound of ∞ and a cost of zero. Figure 3 shows a complete example network. If it is clear from the context which layer or which node is meant, we omit the node subscripts and superscripts. 3.2 Obtaining Coordinates and Correctness Let f be a feasible flow in the network described above. We observe that f (ai f (wi edge of zi j) = j and the only incoming j is the only outgoing edge of wi j. We define the x-coordinate of a node vi j) since ai j) = f (zi j as j−1(cid:88) j−1(cid:88) j−1(cid:88) x(vi j) := f (ai l) = f (wi l ) = f (zi l ). (1) l=0 l=0 l=0 Together with y(vi j) = i we get an induced drawing with a feasible coordinate assignment, because for every vj, vk within the same layer x(vj) < x(vk) if and only if vj < vk (since the amount of flow over edges a ∈ A is always positive). 6 Junger et al. Fig. 3. An example network with underlying graph. Edges of the set A are red (solid), edges of the set B are blue (dashed) and edges of the set C are purple (dashdotted). The numbers along the edges denote the flow, unlabeled edges carry no flow. Now we want to explain the correspondence between the cost of a flow f and the total horizontal edge length of the resulting drawing. The intuition is, that if flow is sent from the right of start(e) to the left of target(e) for some edge e, then target(e) is "pushed" to the right because of the additional flow on the left. This results in a horizontal expansion of e. We define for an edge e = (u, v) ∈ E −→ E (e) := {bw ∈ B start(bw) < v ∧ target(bw) > v} ∪ {bz ∈ B start(bz) < u ∧ target(bz) > u} ∪ {c ∈ C start(c) < u ∧ target(c) > v} as the set of network edges that start to the left of e and end to the right of e, thus cross over e from left to right. Analogously the set of network edges that cross over a graph edge from right to left is ←− E (e) := {bw ∈ B start(bw) > v ∧ target(bw) < v} ∪ {bz ∈ B start(bz) > u ∧ target(bz) < u} ∪ {c ∈ C start(c) > u ∧ target(c) < v}. E (e)} + {e ∈ E g ∈ ←− E (e)} ∀g ∈ B ∪ C. We make the following observations: Property 1 cost(g) = {e ∈ E g ∈ −→ (cid:80)Li (cid:80)Li j=0 f (zi j=0 f (wk j=0 f (wi j=0 f (wi j) =(cid:80)Li j) =(cid:80)Lk (cid:16)(cid:80)Li−1 Property 3 The width of the induced drawing is max1≤i≤L f (wi j) j=1 (cid:17) ≤ f (s). Property 2 Because of the flow conservation rule we have j) for all i ∈ {1, . . . ,L} and j ) = f (s) for all i, k ∈ {1, . . . ,L}. Horizontal Coordinate Assignment with Prescribed Width 7 (cid:80) Property 4 Let e = (vi j, vi+1 k wi+1 l <vi+1 k f (wi+1 l l <vi zi j ) be an edge. Then f (zi ←− E (e)) − f ( l ) + f ( −→ E (e)). ) =(cid:80) The last property is illustrated in Fig. 4. The total flow that reaches all wi+1 that are to left of target(e) comes from the zi j that are to the left of start(e) and from nodes that are to the right of target(e) or start(e). Flow from the latter nodes has to pass over e from right to left. Flow from a node zi j that is to the left of start(e) and does not enter one of the wi+1 left of target(e) has to pass over e from left to right. Lemma 1. For a feasible flow f and the induced drawing costf ≥ length(E) holds. j j Proof. Let e = (vi x(vi+1 ) and together with (1) we have j, vi+1 k k ) be an edge of G. The length of e is length(e) = x(vi j)− Therefore we have for the total edge length length(E) = l ) l ) − k−1(cid:88) f (wi+1 (cid:12)(cid:12)(cid:12) l ) − (cid:88) (cid:12)(cid:12)(cid:12) l=0 f (zi ←− E (e)) wi+1 (cid:12)(cid:12)(cid:12) ) f (wi+1 l zi l <start(e) −→ E (e)) − f ( l <target(e) (by Property 4). length(e) = f (zi = = l=0 (cid:12)(cid:12)(cid:12)j−1(cid:88) (cid:12)(cid:12)(cid:12) (cid:88) (cid:12)(cid:12)(cid:12)f ( (cid:12)(cid:12)(cid:12)f ( (cid:88) (cid:16)(cid:12)(cid:12)(cid:12)f ( ≤(cid:88) (cid:16) (cid:88) (cid:88) (cid:88) g∈EN e∈E e∈E e∈E f ( = = = g∈EN = costf . (cid:12)(cid:12)(cid:12)(cid:17) (cid:12)(cid:12)(cid:12)f ( (cid:12)(cid:12)(cid:12) + ←− E (e)) ←− E (e) (cid:12)(cid:12)(cid:12) −→ E (e)) − f ( −→ (cid:17) E (e)) −→ E (e)) + f ( f (g) · {e ∈ E g ∈ −→ f (g) · cost(g) ←− E (e) E (e)} ∪ {e ∈ E g ∈ ←− E (e)} (by Property 1) (cid:117)(cid:116) 8 Junger et al. • • • vj {z0, z1, ..., zj−1} {w0, w1, ..., wk−1} • • • vk −→ E (e)) f ( ←− E (e)) f ( Fig. 4. Illustration of Property 4. The rectangles represent all network nodes to the left of vj and vk, respectively. The thick arrows represent the flow of several edges. ∗→ ··· ∗→ w ∗→ w1 ji+1) ≥ k and x(vi Lemma 2. Let Γ be a drawing of G. There exists a flow f that induces Γ and whose cost is equal to the total edge length of Γ . Proof. If necessary, we set x(v) := x(v) − minv∈V x(v) so that the smallest x- coordinate is zero. That gives us an equivalent drawing. We construct the flow f as follows: Let ω be the width of Γ . We send ω units of flow from s to t, so that ∗→ t, where the k-th unit takes the path Pk = s 1) ≥ k and is chosen so that x(vi wi ji wi = wiLi, if x(viLi < k). That means we send the k-th unit through the k-th ji ∗→ "column" of Γ . This is always possible, because of the subpaths wi ji 0 → wi+1 zi . So for every v there are x(v) units of flow that pass by to the left of v, thus giving us correct coordinates for all nodes. ) ≥ k}∪{e ∈ E j) < k and x(vi+1 ) < k}, i.e. all edges that cross over the k-th column x(vi between Li and Li+1. We show that there exists a path Pk that produces the same cost as the number of graph edges that cross over the k-th column in total, that k = k. Then we have(cid:80)ω is cost(Pk) =(cid:80)L−1 k=1 cost(Pk) =(cid:80)ω We define Ei j) ≥ k and x(vi+1 (cid:80)L−1 ∗→ w2 ) < k (wi ji j2 k := {e = (vi ) ∈ E x(vi = wi 0, if x(vi ∗→ wi+1 ji+1 → zi ji j, vi+1 l k=1 i=1 L jL l Ei i=1 l Ei j1 ji 0 length(E) and we have proven the lemma. It suffices to focus on the subpath P i to w = wi+1 ji+1 k from z = zi ji j and wj for wi+1 between two consecutive layers. Notice that network edges (s, w1), (wi, zi) and (zL, t) do not contribute to the cost of the flow. For better readability we denote the nodes of Li with uj and the nodes of Li+1 with vj and we omit the superscripts. . We construct P (cid:48) = P i If not stated otherwise we use zj for zi so that cost(P (cid:48)) = E(cid:48) = Ei k. Case 1: There exists no edge e with start(e) < z and target(e) < w. That means every edge e with start(e) < z has target(e) > w, and if target(e) < w ∗→ z0 → w0 → w1 ∗→ w. For then start(e) > z. Then we set P (cid:48) = z → zji−1 ←− every uj < z with p outgoing edges P (cid:48) uses exactly one bz with cost p. All these −→ edges are in E(cid:48). For every vj < w with q incoming edges we use exactly one bw with cost q. Again these edges are in E(cid:48). So cost(P (cid:48)) = E(cid:48), since there are no other edges in E(cid:48). k j Horizontal Coordinate Assignment with Prescribed Width 9 Case 2: There exists no edge e with start(e) > z and target(e) > w. Arguing like in Case 1, we set P (cid:48) = z of P (cid:48) equals E(cid:48). ∗→ zLi → wLi+1 ∗→ w. As before the cost Case 3: There exists an edge el with start(el) < z and target(el) < w and another edge er with start(er) > z and target(er) > w. Let el be the edge with the biggest x(start(e)) of all edges e with start(e) < z and target(e) < w, and let er be the edge with the smallest x(start(e)) of all edges e with start(e) > z and target(e) > w. Case 3.1: There is at least one node u(cid:48) with outgoing edges and start(el) < u(cid:48) < z. Let ug = start(el) and vg(cid:48) = target(el). We know vg(cid:48) < w. Let vh(cid:48) be the first node to the right of vg(cid:48) with an edge er(cid:48) = (uh, vh(cid:48)) and uh > ug. Such a node does exist, since we have er. Notice that vh(cid:48) might be to the right of w. Then we have a hug: Set e1 = el, set e2 to one outgoing edge of ug+1 (or the next node to the right of ug, which has an outgoing edge), e4 = er(cid:48) and set e3 to one incoming edge of vh(cid:48)−1 (or the next one to the left of vh(cid:48)), see Fig. 5. Notice that e1 may coincide with e3 and e2 with e4. We have start(e3) ≤ start(e1), because we chose e1 = el with the biggest x(start(e)) and vh(cid:48) is the first node to the right of vg(cid:48) with an adjacent node to the right of ug. So every node between vg(cid:48) = target(e1) and vh(cid:48), including vh(cid:48)−1 = target(e3), can only have adjacent nodes to the left of ug = start(e1). It is clear that start(e1) < start(e2) and start(e2) ≤ start(e4), since start(e4) = uh > ug. By choice of e1, e3 and e4 target(e1) ≤ target(e3) < target(e4) holds. We know that target(e2) > w because there is at least one node between start(e1) and z whose outgoing edges have to end to the right of w because of the choice of e1. If target(e4) > target(e2) then e2 would have been chosen for er(cid:48) and therefore for e4. So target(e4) ≤ target(e2) also holds. So there exists cg(h(cid:48)−1) ∈ EN and we set P (cid:48) = z ∗→ zg → wh(cid:48)−1 Now for the cost. A subset of E(cid:48) are the edges e with zg < start(e) < z and ∗→ w. target(e) > w, which are covered by the ←− bz of P (cid:48). Now we have two options. First, if wh−1 > w then all edges e with start(e) < zg and target(e) > wh(cid:48)−1 are covered by cg(h(cid:48)−1) and the remaining edges e with ←− bw of P (cid:48). Edges e start(e) < zg and w < target(e) < wh(cid:48)−1 are covered by the with start(e) > z > ug and target(e) < w < wh(cid:48) are also covered by cg(h(cid:48)−1). There cannot be any edge e with z < start(e) and w < target(e) < wh(cid:48)−1 or zg < start(e) < z and target(e) < w, which would be crossed over by two differ- ent edges of P (cid:48), due to the choice of edges e1 to e4. Second, if wh−1 < w then cg(h(cid:48)−1) covers all edges e with start(e) < zg and target(e) > w > wh(cid:48)−1 and all edges e with start(e) > z > zg and target(e) < wh(cid:48)−1 < w. Edges e with start(e) > z and wh(cid:48)−1 < target(e) < w are covered by −→ bw. Again there are no edges that are crossed over twice by P (cid:48) due to the the choice of e1 to e4. And there are no edges in E(cid:48) that are not covered by some edge of P (cid:48). 10 Junger et al. ug e1 vg(cid:48) e2 z e3 w uh e4 vh(cid:48) Fig. 5. Case 3.1. Only relevant network nodes and edges are depicted. Edges that participate in the hug are black. Case 3.2: start(el) is the next node to the left of z with outgoing edges, but there is at least one node u(cid:48) with outgoing edges and start(er) > u(cid:48) > z. This case is analogous to Case 3.1. Case 3.3: start(el) is the next node to the left of z with outgoing edges and start(er) is the next node to the right of z with outgoing edges. Let el = (ug, vg(cid:48)) and vh(cid:48) be the first node right of vg(cid:48) with an adjacent node uh > ug. Again we have a hug. Set e1 = el, e2 = er, e3 to an incoming edge of vh(cid:48)−1 (or a lower node, if necessary) and e4 = (uh, vh(cid:48)). e3 and e4 are indeed a hug and we have cji(h(cid:48)−1). We set P (cid:48) = z → wh(cid:48)−1 As before cost(P (cid:48)) = E(cid:48). With the same arguments as in Case 3.1 we convince ourselves that e1, e2, ∗→ w. (cid:117)(cid:116) Theorem 1. A minimum cost flow in the network described above solves HCAPminEL. Proof. Lemma 1 and Lemma 2. (cid:117)(cid:116) j ) with (s(cid:48), w1 For controlling the maximum width of the drawing we make use of Property 3, which states that the width of the drawing is at most the flow leaving s. We can add an additional node s(cid:48) and an edge (s, s(cid:48)) to N and replace all edges of the form (s, w1 j ). Now we can limit the maximum width of the drawing by setting the upper bound of (s, s(cid:48)) to an appropriate value. Further constraints can be modelled by manipulating the network. By ad- justing the lower and upper bounds of edges a ∈ A we can realize minimum removing every g ∈ ←− and maximum distances between two neighboring nodes on the same layer. By E (e) from the network, we can enforce the edge e to E (e)∪−→ be drawn vertically. 4 Experimental Results In our experiment we want to demonstrate that we are able to restrict the width of the drawing without paying too much in terms of total (horizontal) edge length and time. Horizontal Coordinate Assignment with Prescribed Width 11 Fig. 6. Width and total edge length produced by MCF, Gansner, LP, BJL and BK relative to minimum width, resp. edge length. Fig. 7. Running time for MCF, Gansner, LP, BJL and BK. We implemented the algorithm from Sect. 3, which we will call MCF within the Open Graph Drawing Framework [4] (OGDF) and used the OGDF net- work simplex software to solve the minimum cost flow problem. We also imple- mented the approach of Gansner et al. [7] (Gansner) that also uses the network simplex algorithm. Additionally we use three other OGDF methods: an ILP that also takes balancing the nodes between their neighbors into account (LP), the algorithm of Buchheim, Junger and Leipert [3] (BJL) and the algorithm of Brandes and Kopf [2] (BK). All algorithms draw inner segments of long edges as vertical lines, since this is generally desirable for good readability. MCF is configured to compute a layout with mimimum edge length with respect to min- imum possible width and Gansner computes coordinates that minimize the total edge length regardless of width. We used a subset of the AT&T graphs from www.graphdrawing.org/data.html consisting of 1277 graphs with 10 to 100 nodes as our test set. The test was run on an Intel Xeon E5-2640v3 2.6GHz CPU with 128 GB RAM. Figures 6, 7, and 8 show the results. The whiskers in Fig. 6 and 7 cover 95% of the data and outliers are omitted for better readability. Figure 8 shows absolute values for MCF and Figure 9 displays three example drawings. In Figure 6 the resulting total edge length and width of the drawings are depicted relative to the minima that are computed by Gansner and MCF, respec- tively. We see that MCF still achieves good results in terms of total edge length, 100 120 140 160 180MCFGansnerLPBJLBKpercent to minimumwidthedge length 0.01 0.02 0.03 0.04 0.05MCFGansnerLPBJLBKrunning time in sec.time 12 Junger et al. (a) (b) Fig. 8. Absolute values of (a) width and (b) total edge length for MCF. (a) (b) (c) Fig. 9. Example drawings of a graph with 29 nodes and 33 edges. (a) MCF: width: 9, edge length: 58. (b) Gansner: width: 13, edge length: 54. (c) BK: width: 16.5, edge length: 63.5. even though it has the restriction of meeting the minimum width. The total edge length of drawings computed with MCF is on average 2.2% over the minimum, while drawings produced with Gansner have on average a width that is 8.9% over the minimum. In an extreme example with minimum width 1, Gansner results in width 15. Figure 7 shows the running time in seconds. MCF (4.9 milliseconds on av- erage) is a bit slower than Gansner (3.9 milliseconds on average). The fastest algorithm on average is BJL with 2.5 milliseconds. 5 Conclusion We presented a minimum cost flow formulation for the coordinate assignment problem that minimizes the total edge length with respect to several optional criteria like the maximum width or lower and upper bounds on the distance of neighboring nodes in a layer. In our experiments we showed that our approach can compete with state-of-the-art algorithms. 20 40 60 80 100 120 140 160 10 20 30 40 50 60 70 80 90 100widthnodes 1000 2000 3000 4000 5000 6000 7000 8000 10 20 30 40 50 60 70 80 90 100total edge lengthnodes Horizontal Coordinate Assignment with Prescribed Width 13 References 1. Ahuja, R.K., Magnanti, T.L., Orlin, J.B.: Network flows - theory, algorithms and applications. Prentice Hall (1993) 2. Brandes, U., Kopf, B.: Fast and simple horizontal coordinate assignment. In: Mutzel, P., Junger, M., Leipert, S. (eds.) Graph Drawing, 9th International Sym- posium, GD 2001 Vienna, Austria, September 23-26, 2001, Revised Papers. Lec- ture Notes in Computer Science, vol. 2265, pp. 31 -- 44. Springer (2001), https: //doi.org/10.1007/3-540-45848-4$_$3 3. Buchheim, C., Junger, M., Leipert, S.: A fast layout algorithm for k -level graphs. In: Marks, J. (ed.) Graph Drawing, 8th International Symposium, GD 2000, Colonial Williamsburg, VA, USA, September 20-23, 2000, Proceedings. Lecture Notes in Computer Science, vol. 1984, pp. 229 -- 240. Springer (2000), https: //doi.org/10.1007/3-540-44541-2$_$22 4. Chimani, M., Gutwenger, C., Junger, M., Klau, G.W., Klein, K., Mutzel, P.: The open graph drawing framework (OGDF). In: Tamassia, R. (ed.) Handbook on Graph Drawing and Visualization., pp. 543 -- 569. Chapman and Hall/CRC (2013) 5. Coffman, E.G., Graham, R.L.: Optimal scheduling for two-processor systems. Acta Informatica 1(3), 200 -- 213 (1972). https://doi.org/10.1007/BF00288685 6. Eades, P., Lin, X., Tamassia, R.: An algorithm for drawing a hierarchical graph. Int. J. Comput. Geometry Appl. 6(2), 145 -- 156 (1996), https://doi.org/10.1142/ S0218195996000101 7. Gansner, E.R., Koutsofios, E., North, S.C., Vo, K.P.: A technique for (1993). drawing directed graphs. Software Engineering 19(3), https://doi.org/10.1109/32.221135 214 -- 230 8. Healy, P., Nikolov, N.S.: A branch-and-cut approach to the directed acyclic graph layering problem. In: Kobourov, S.G., Goodrich, M.T. (eds.) Graph Drawing, 10th International Symposium, GD 2002, Irvine, CA, USA, August 26-28, 2002, Revised Papers. Lecture Notes in Computer Science, vol. 2528, pp. 98 -- 109. Springer (2002), https://doi.org/10.1007/3-540-36151-0$_$10 9. Healy, P., Nikolov, N.S.: Hierarchical drawing algorithms. In: Tamassia, R. (ed.) Handbook on Graph Drawing and Visualization., pp. 409 -- 453. Chapman and Hall/CRC (2013) 10. Jabrayilov, A., Mallach, S., Mutzel, P., Ruegg, U., von Hanxleden, R.: Compact layered drawings of general directed graphs. In: Hu, Y., Nollenburg, M. (eds.) Graph Drawing and Network Visualization - 24th International Symposium, GD 2016, Athens, Greece, September 19-21, 2016, Revised Selected Papers. Lecture Notes in Computer Science, vol. 9801, pp. 209 -- 221. Springer (2016), https:// doi.org/10.1007/978-3-319-50106-2$_$17 11. Sander, G.: A fast heuristic for hierarchical manhattan layout. In: Brandenburg, F. (ed.) Graph Drawing, Symposium on Graph Drawing, GD '95, Passau, Germany, September 20-22, 1995, Proceedings. Lecture Notes in Computer Science, vol. 1027, pp. 447 -- 458. Springer (1995), https://doi.org/10.1007/BFb0021828 12. Sugiyama, K., Tagawa, S., Toda, M.: Methods for visual understanding of hier- archical system structures. IEEE Transactions on Systems, Man and Cybernetics 11(2), 109 -- 125 (Feb 1981). https://doi.org/10.1109/TSMC.1981.4308636
1501.05828
1
1501
2015-01-23T15:23:25
An $O(n^{\epsilon})$ Space and Polynomial Time Algorithm for Reachability in Directed Layered Planar Graphs
[ "cs.DS", "cs.CC" ]
Given a graph $G$ and two vertices $s$ and $t$ in it, {\em graph reachability} is the problem of checking whether there exists a path from $s$ to $t$ in $G$. We show that reachability in directed layered planar graphs can be decided in polynomial time and $O(n^\epsilon)$ space, for any $\epsilon > 0$. The previous best known space bound for this problem with polynomial time was approximately $O(\sqrt{n})$ space \cite{INPVW13}. Deciding graph reachability in {\SC} is an important open question in complexity theory and in this paper we make progress towards resolving this question.
cs.DS
cs
An O(nǫ) Space and Polynomial Time Algorithm for Reachability in Directed Layered Planar Graphs Diptarka Chakraborty∗and Raghunath Tewari † Department of Computer Science and Engineering, Indian Institute of Technology Kanpur, Kanpur, India October 29, 2018 Abstract Given a graph G and two vertices s and t in it, graph reachability is the problem of checking whether there exists a path from s to t in G. We show that reachability in directed layered planar graphs can be decided in polynomial time and O(nǫ) space, for any ǫ > 0. The previous best known space bound for this problem with polynomial time was approximately O(√n) space [INP+13]. Deciding graph reachability in SC is an important open question in complexity theory and in this paper we make progress towards resolving this question. 1 Introduction Given a graph and two vertices s and t in it, the problem of determining whether there is a path from s to t in the graph is known as the graph reachability problem. Graph reachability problem is an important question in complexity theory. Particularly in the domain of space bounded computa- tions, the reachability problem in various classes of graphs characterize the complexity of different complexity classes. The reachability problem in directed and undirected graphs, is complete for the classes non-deterministic log-space (NL) and deterministic log-space ( L) respectively [LP82, Rei08]. The latter follows due to a famous result by Reingold who showed that undirected reachability is in L [Rei08]. Various other restrictions of reachability has been studied in the context of understand- ing the complexity of other space bounded classes (see [RTV06, CRV11, Lan97]). Wigderson gave a fairly comprehensive survey that discusses the complexity of reachability in various computational models [Wig92]. The time complexity of directed reachability is fairly well understood. Standard graph traversal algorithms such as DFS and BFS solve this problem in linear time. We also have a O(log2 n) space algorithm due to Savitch [Sav70], however it requires O(nlog n) time. The question, whether there exists a single algorithm that decides reachability in polynomial time and polylogarithmic space ∗[email protected][email protected] 1 is unresolved. In his survey, Wigderson asked whether it is possible to design a polynomial time algorithm that uses only O(nǫ) space, for some constant ǫ < 1 [Wig92]. This question is also still open. In 1992, Barnes, Buss, Ruzzo and Schieber made some progress on this problem and gave an algorithm for directed reachability that requires polynomial time and O(n/2√log n) space [BBRS92]. Planar graphs are a natural topological restriction of general graphs consisting of graphs that can be embedded on the surface of a plane such that no two edges cross. Grid graphs are a subclass of planar graphs, where the vertices are placed at the lattice points of a two dimensional grid and edges occur between a vertex and its immediate adjacent horizontal or vertical neighbor. Asano and Doerr provided a polynomial time algorithm to compute the shortest path (hence can decide reachability) in grid graphs which uses O(n1/2+ǫ) space, for any small constant ǫ > 0 [AD11]. Imai et al extended this to give a similar bound for reachability in planar graphs [INP+13]. Their approach was to use a space efficient method to design a separator for the planar graph and use divide and conquer strategy. Note that although it is known that reachability in grid graphs reduces to planar reachability in logspace, however since this class (polynomial time and O(n1/2+ǫ) space) is not closed under logspace reductions, planar reachability does not follow from grid graph reachability. Subsequently the result of Imai et al was extended to the class of high-genus and H-minor-free graphs [CPT+14]. Recently Asano et al gave a O(√n) space and polynomial time algorithm for reachability in planar graphs, thus improving upon the previous space bound [AKNW14]. More details on known results can be found in a recent survey article [Vin14]. In another line of work, Kannan et al gave a O(nǫ) space and polynomial time algorithm for solving reachability problem in unique path graphs [KKR08]. Unique path graphs are a generaliza- tion of strongly unambiguous graphs and reachability problem in strongly unambiguous graphs is known to be in SC (polynomial time and polylogarithmic space) [BJLR91, Coo79]. Reachability in strongly unambiguous graphs can also be decided by a O(log2 n/ log log n) space algorithm, how- ever this algorithm requires super polynomial time [AL98]. SC also contains the class randomized logspace or RL [Nis95]. We refer the readers to a recent survey by Allender [All07] to further under- stand the results on the complexity of reachability problem in UL and on certain special subclasses of directed graphs. Our Contribution We show that reachability in directed layered planar graphs can be decided in polynomial time and O(nǫ) space for any constant ǫ > 0. A layered planar graph is a planar graph where the vertex set is partitioned into layers (say L0 to Lm) and every edge occurs between layers Li and Li+1 only. Our result significantly improves upon the previous space bound due to [INP+13] and [AKNW14] for layered planar graphs. Theorem 1. For every ǫ > 0, there is a polynomial time and O(nǫ) space algorithm that decides reachability in directed layered planar graphs. Reachability in layered grid graphs is in UL which is a subclass of NL [ABC+09]. Subsequently this result was extended to the class of all planar graphs [BTV09]. Allender et al also gave some hardness results the reachability problem in certain subclasses of layered grid graphs. Specifically they showed that, 1LGGR is hard for NC1 and 11LGGR is hard for TC0 [ABC+09]. Both these problems are however known to be contained in L though. Firstly we argue that its enough to consider layered grid graphs (a subclass of general grid graphs). We divide a given layered grid graph into a courser grid structure along k horizontal and 2 k vertical lines (see Figure 1). We then design a modified DFS strategy that makes queries to the smaller graphs defined by these gridlines (we assume a solution in the smaller graphs by recursion) and visits every reachable vertex from a given start vertex. The modified DFS stores the highest visited vertex in each vertical line and the left most visited vertex in each horizontal line. We use this information to avoid visiting a vertex multiple number of times in our algorithm. We choose the number of horizontal and vertical lines to divide the graph appropriately to ensure that the algorithm runs in the required time and space bound. The rest of the paper is organized as follows. In Section 2, we give some basic definitions and notations that we use in this paper. We also state certain earlier results that we use in this paper. In Section 3, we give a proof of Theorem 1. 2 Preliminaries We will use the standard notations of graphs without defining them explicitly and follow the standard model of computation to discuss the complexity measures of the stated algorithms. In particular, we consider the computational model in which an input appears on a read-only tape and the output is produced on a write-only tape and we only consider an internal read-write tape in the measure of space complexity. Throughout this paper, by log we mean logarithm to the base 2. We denote the set {1, 2,··· , n} by [n]. Given a graph G, let V (G) and E(G) denote the set of vertices and the set of edges of G respectively. Definition 1 (Layered Planar Graph). A planar graph G = (V, E) is referred as layered planar if it is possible to represent V as a union of disjoint partitions, V = V1∪ V2 ∪···∪ Vk, for some k > 0, and there is a planar embedding of edges between the vertices of any two consecutive partitions Vi and Vi+1 and there is no edge between two vertices of non-consecutive partitions. Now let us define the notion of layered grid graph and also note that grid graphs are by definition planar. Definition 2 (Layered Grid Graph). A directed graph G is said to be a n × n grid graph if it can be drawn on a square grid of size n × n and two vertices are neighbors if their L1-distance is one. In a grid graph a edge can have four possible directions, i.e., north, south, east and west, but if we are allowed to have only two directions north and east, then we call it a layered grid graph. We also use the following result of Allender et al to simplify our proof [ABC+09]. Proposition 2 ([ABC+09]). Reachability problem in directed layered planar graphs is log-space reducible to the reachability problem in layered grid graphs. 2.1 Class nSC and its properties TISP(t(n), s(n)) denotes the class of languages decided by a deterministic Turing machine that runs in O(t(n)) time and O(s(n)) space. Then, SC = TISP(nO(1), (log n)O(1)). Expanding the class SC, we define the complexity class nSC (short for near-SC) in the following definition. Definition 3 (Complexity Class near-SC or nSC). For a fixed ǫ > 0, we define nSCǫ := TISP(nO(1), nǫ). The complexity class nSC is defined as nSC := \ǫ>0 nSCǫ. 3 We next show that nSC is closed under log-space reductions. This is an important property of the class nSC and will be used to prove Theorem 1. Although the proof is quite standard, but for the sake of completeness we provide it here. Theorem 3. If A ≤l B and B ∈ nSC, then A ∈ nSC. Proof. Let us consider that a log-space computable function f be the reduction from A to B. It is clear that for any x ∈ A such that x = n, f (x) ≤ nc, for some constant c > 0. We can think that after applying the reduction, f (x) appears in a separate write-once output tape and then we can solve f (x), which is an instance of the language B and now the input length is at most nc. Now take any ǫ > 0 and consider ǫ′ = ǫ c > 0. B ∈ nSC implies that B ∈ nSCǫ′ and as a consequence, A ∈ nSCǫ. This completes the proof. 3 Reachability in Layered Planar Graphs In this section we prove Theorem 1. We show that the reachability problem in layered grid graphs, (denoted as LGGR) is in nSC (Theorem 4). Then by applying Proposition 2 and Theorem 3 we have the proof of Theorem 1. Theorem 4. LGGR ∈ nSC. To establish Theorem 4 we define an auxiliary graph in Section 3.1 and give the required algorithm in Section 3.2. 3.1 The Auxiliary Graph H Let G be a n × n layered grid graph. We denote the vertices in G as (i, j), where 0 ≤ i, j ≤ n. Let k be a parameter that determines the number of pieces in which we divide G. We will fix the value of k later to optimize the time and space bounds. Assume without loss of generality that k divides n. Given G we construct an auxiliary graph H as described below. Divide G into k2 many blocks of dimension n/k × n/k. More formally, the vertex set of H is V (H) := {(i, j) either i or j is a non-negative multiple of n/k.} k ≤ i ≤ (i′ + 1) n k and j′ n Note that V (H) ⊆ V (G). We consider k2 many blocks G1, G2,··· , Gk2 , where a vertex (i, j) ∈ V (Gl) if and only if i′ n k , for some integer i′ ≥ 0 and j′ ≥ 0 and the vertices for which any of the four inequalities is strict will be referred as boundary vertices. Moreover, we have l = i′ · k + j′ + 1. E(Gl) is the set of edges in G induced by the vertex set V (Gl). For every i ∈ [k +1], let Lh(i) and Lv(i) denote the set of vertices, Lh(i) = {(i′, j′)j′ = (i−1) n k } and Lv(i) = {(i′, j′)i′ = (i − 1) n k}. When it is clear from the context, we will also use Lh(i) and Lv(i) to refer to the corresponding gridline in H. Observe that H has k + 1 vertical gridlines and k + 1 horizontal gridlines. k ≤ j ≤ (j′ + 1) n For every pair of vertices u, v ∈ V (Gl) ∩ V (H), for some l, add the edge (u, v) to E(H) if and only if there is a path from u to v in Gl, unless u, v ∈ Lv(i) or u, v ∈ Lh(i), for some i. Also for every pair of vertices u, v ∈ V (Gl), for some l, such that u = (i1, j1) and v = (i2, j2), where j1 = j′ n k and j2 = (j′ + 1) n k , for some i′, we add edge between u and v in the set E(H) if and only if there is a path from u to v in Gl and we call such vertices as corner vertices. k , for some j′ or i1 = i′ n k and i2 = (i′ + 1) n 4 t G7 G8 G9 Lh(3) Lh(2) s G4 Lv(2, 2) G5 G6 Lh(2, 2) G1 G2 G3 Lv(2) Lv(3) Figure 1: An example of layered grid graph and its decomposition into blocks Before proceeding further, let us introduce a few more notations that will be used later. For j ∈ [k], let Lh(i, j) denote the set of vertices in Lh(i) in between Lv(j) and Lv(j + 1). Similarly we also define Lv(i, j) (see Figure 1). For two vertices x, y ∈ Lv(i), we say x ≺ y if x is below y in Lv(i). For two vertices x, y ∈ Lh(i), we say x ≺ y if x is right of y in Lh(i). Lemma 5. Let u and v be two boundary vertices in G such that they belong to two different vertical or horizontal gridlines or u ∈ Gi and v ∈ Gj, for i 6= j. There is a path from u to v in G if and only if there is path from u to v in the auxiliary graph H. Proof. As every edge (a, b) in H corresponds to a path from a to b in G, so if-part is trivial to see. Now for the only-if-part, consider a path P from u to v in G. P can be decomposed as P1P2 ··· Pr, such that Pi is a path from xi ∈ V (Gl) to xi+1 ∈ V (Gl), where it re-enters V (Gl) for the next time, for some l, and is of following two types: 1. xi and xi+1 belong to different horizontal or vertical gridlines; or 2. xi and xi+1 are two corner vertices. Now by the construction H, for every i, there must be an edge (xi, xi+1) in H for both the above cases and hence there is a path from u to v in H as well. Now we consider the case when u and v belong to the same vertical or horizontal gridlines. Claim 6. Let u and v be two vertices contained in either Lv(i) or Lh(i) for some i. Then deciding reachability between u and v in G can be done in logspace. 5 Proof. Let us consider that u, v ∈ Lv(i), for some i. As the graph G under consideration is a layered grid graph, if there is a path between u and v, then it must pass through all the vertices in Lv(i) that lies in between u and v. Hence just by exploring the path starting from u through Lv(i), we can check the reachability and it is easy to see that this can be done in logspace, because the only thing we need to remember is the current vertex in the path. Same argument will also work when u, v ∈ Lh(i), for some i and this completes the proof. Now we argue on the upper bound of the length of any path in the auxiliary graph H. Lemma 7. For any two vertices u, v ∈ V (H), any path between them is of length at most 2k + 1. Proof. Consider any two vertices u, v ∈ V (H) and a path u = x1x2 ··· xr = v, from u to v, denoted as P . Now let us consider a bipartite (undirected) graph K, where V (K) = A ∪ B such that A = {xii ∈ [r]} and B = {Lv(i), Lh(j)i, j ∈ [k + 1]}. We add an edge (a, b) in E(K) if and only if a ∈ b, where b = Lv(i) or b = Lh(i), for some i. Now observe that by the construction of H, each xj belongs to different Lv(i) or Lh(i) unless xj is some corner vertex and in that case xj ∈ Lv(i), Lh(i′), for some i and i′. Moreover, if xj ∈ Lv(i) (or Lv(i)), but is not a corner vertex, then xj+1 cannot be a corner vertex on Lv(i) (or Lh(i)). As a consequence for every subset SA ⊆ A, its neighbor set N (SA) := {b ∈ B∃a ∈ SA such that (a, b) ∈ E(K)} ⊆ B satisfies the condition that N (SA) ≥ SA. Now we apply the Hall's Theorem [LP86], which states that a bipartite (undirected) graph G = (A ∪ B, E) has a matching if and only if for every S ⊆ A, N (S) ≥ S. Hence there is a matching between A and B and as B ≤ 2(k + 1), so is A. This shows that the path P is of length at most 2k + 1. 3.2 Description of the Algorithm We next give a modified version of DFS that starting at a given vertex, visits the set of vertices reachable from that vertex in the graph H. At every vertex, the traversal visits the set of outgoing edges from that vertex in an anticlockwise order. In our algorithm we maintain two arrays of size k + 1 each, say Av and Ah, one for vertical and the other for horizontal gridlines respectively. For every i ∈ [k + 1], Av(i) is the topmost visited vertex in Lv(i) and analogously Ah(i) is the leftmost visited vertex in Lh(i). This choice is guided by the choice of traversal of our algorithm. More precisely, we cycle through the outgoing edges of a vertex in an anticlockwise order. We perform a standard DFS-like procedure, using the tape space to simulate a stack, say S. S keeps track of the path taken to the current vertex from the starting vertex. By Lemma 7, the maximum length of a path in H is at most 2k + 1. Whenever we visit a vertex in a vertical gridline (say Lv(i)), we check whether the vertex is lower than the i-th entry of Av. If so, we return to the parent vertex and continue with its next child. Otherwise, we update the i-th entry of Av to be the current vertex and proceed forward. Similarly when visit a horizontal gridline (say Lh(i)), we check whether the current vertex is to the left of the i-th entry of Ah. If so, we return to the parent vertex and continue with its next child. Otherwise, we update the i-th entry of Ah to be the current vertex and proceed. The reason for doing this is to avoid revisiting the subtree rooted at the node of an already visited vertex. The algorithm is formally defined in Algorithm 1. Lemma 8. Let Gl be some block and let x and y be two vertices on the boundary of Gl such that there is a path from x to y in G. Let x′ and y′ be two other boundary vertices in Gl such that (i) 6 : The auxiliary graph H, two vertices u, v ∈ V (H) Input Output : YES if there is a path from u to v; otherwise NO 1 Initialize two arrays Av and Ah and a stack S; 2 Initialize three variables curr, prev and next to NULL; 3 Push u onto S; 4 while S is not empty do 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 curr ← top element of S; next ← neighbor of curr next to prev in counter-clockwise order; while next 6= NULL do /* cycles through neighbors of curr if next = v then return YES; end if next ∈ Lv(i) for some i and Av[i] ≺ next then Av[i] ← next; break; end if next ∈ Lh(i) for some i and Ah[i] ≺ next then Ah[i] ← next; break; end prev ← next; next ← neighbor of curr next to prev in counter-clockwise order; /* NULL if no more neighbors are present end if next = NULL then remove curr from S; prev ← curr; else add next to S; prev ← NULL; end 29 end 30 return NO; Algorithm 1: AlgoLGGR: Algorithm for Reachability in the Auxiliary Graph H 7 */ */ there is a path from x′ to y′ in G and (ii) x′ lies on one segment of the boundary of Gl between vertices x and y and y′ lies on the other segment of the boundary. Then there is a path in G from x to y′ and from x′ to y. Hence, if (x, y) and (x′, y′) are present in E(H) then so are (x, y′) and (x′, y). Proof. Since G is a layered grid graph hence the paths x to y and x′ to y′ must lie inside Gl. Also because of planarity, the paths must intersect at some vertex in Gl. Now using this point of intersection, we can easily show the existence of paths from x to y′ and from x′ to y. Lemma 9 will prove the correctness of Algorithm 1. Lemma 9. Let u and v be two vertices in H. Then starting at u Algorithm 1 visits v if and only if v is reachable from u. Proof. It is easy to see that every vertex visited by the algorithm is reachable from u since the algorithm proceeds along the edges of H. By induction on the shortest path length to a vertex, we will show that if a vertex is reachable from u then the algorithm visits that vertex. Let Bd(u) be the set of vertices reachable from u that are at a distance d from u. Assume that the algorithm visits every vertex in Bd−1(u). Let x be a vertex in Bd(u). Without loss of generality assume that x is in Lv(i, j) for some i and j. A similar argument can be given if x belongs to a horizontal gridline. Further, let x lie on the right boundary of a block Gl. Let Wx = {w ∈ Bd−1(u)(w, x) ∈ E(H)}. Note that by the definition of H, all vertices in Wx lie on the bottom boundary or on the left boundary of Gl. Suppose the algorithm does not visit x. Since x is reachable from u via a path of length d, therefore Wx is non empty. Let w be the first vertex added to Wx by the algorithm. Then w is either in Lh(j), or in Lv(i − 1). Without loss of generality assume w is in Lh(j). Let z be the value in Av(i) at this stage of the algorithm (that is when w is the current vertex). Since x is not visited hence x ≺ z. Also this implies that z was visited by the algorithm at an earlier stage of the algorithm. Let w′ be the ancestor of z in the DFS tree such that w′ is in Lh(j). There must exist such a vertex because z is above the j-th horizontal gridline, that is Lh(j). Suppose if w′ lies to the left of w then by the description of the algorithm, w is visited before w′. Hence x is visited before z. On the other hand, suppose if w′ lies to the right of w. Clearly w′ cannot lie to the right of vertical gridline Lv(i) since z is reachable from w′ and z is in Lv(i). Let w′′ be the vertex in Lh(j + 1) such that w′′ lies in the tree path between w′ and z (See Figure 2). Observe that all four vertices lie on the boundary of Gl. Now by applying Lemma 8 to the four vertices w, x, w′ and w′′ we conclude that there exists a path from w′ to x as well. Since x ≺ z, x must have been visited before z from the vertex w′. In both cases, we see that z cannot be Av(i) when w is the current vertex. Since z was an arbitrary vertex such that x ≺ z, the lemma follows. We next show Lemma 10 which will help us to achieve a polynomial bound on the running time of Algorithm 1. Lemma 10. Every vertex in the graph H is added to the set S at most once in Algorithm 1. 8 w′′ z x Gl Lh(j + 1) w w′ Lv(i − 1) Figure 2: Crossing between two paths Lv(i) Lh(j) Proof. Observe that a vertex u in Lv(i) is added to S only if Av(i) ≺ u, and once u is added, Av(i) is set to u. Also during subsequent stages of the algorithm, if Av(i) is set to v, then u ≺ v. Hence u ≺ Av(i). Therefore, u cannot be added to S again. We give a similar argument if u is in Lh(i). Suppose if u is in Lv(i) for some i and Lh(j) for some j, then we add u only once to S. This check is done in Line 16 of Algorithm 1. However we update both Av(i) and Ah(j). Algorithm 1 does not explicitly compute and store the graph H. Whenever it is queried with a pair of vertices to check if it forms an edge, it recursively runs a reachability query in the corresponding block and produces an answer. The base case is when a query is made to a grid of size k × k. For the base case, we run a standard DFS procedure on the k × k size graph. In every iteration of the outer while loop (Lines 4 -- 29) of Algorithm 1, either an element is added or an element is removed from S. Hence by Lemma 10 the loop iterates at most 4nk times. The inner while loop (Lines 7 -- 21), cycles through all the neighbors of a vertex and hence iterates for at most 2n/k times. Each iteration of the inner while loop makes a constant number of calls to check the presence of an edge in a n/k × n/k sized grid. Let T (n) and S(n) be the time and space required to decide reachability in a layered grid graph of size n × n respectively. Then, T (n) =(8n2(T (n/k) + O(1)) O(k2) if n > k otherwise. Hence, Since we do not store any query made to the smaller grids, therefore the space required to check the presence of an edge in H can be reused. Av and Ah are arrays of size k + 1 each. By Lemma 7, the number of elements in S at any stage of the algorithm is bounded by 2k + 1. Therefore, T (n) = O(cid:16)n3 log n log k(cid:17) . Hence, S(n) =(S(n/k) + O(k log n) O(k2) if n > k otherwise. S(n) = O(cid:18) k log k log2 n + k2(cid:19) . 9 Now given any constant ǫ > 0, if we set k = nǫ/2, then we get T (n) = O(n6/ǫ) and S(n) = O(nǫ). This proves Theorem 4. Acknowledgement We thank N. V. Vinodchandran for his helpful suggestions and comments. The first author would like to acknowledge the support of Research I Foundation. References [ABC+09] Eric Allender, David A. Mix Barrington, Tanmoy Chakraborty, Samir Datta, and Sambuddha Roy. Planar and grid graph reachability problems. Theory of Computing Systems, 45(4):675 -- 723, 2009. [AD11] Tetsuo Asano and Benjamin Doerr. Memory-constrained algorithms for shortest path problem. In CCCG, 2011. [AKNW14] Tetsuo Asano, David Kirkpatrick, Kotaro Nakagawa, and Osamu Watanabe. O(sqrt(n))-space and polynomial-time algorithm for the planar directed graph reacha- bility problem. Technical Report TR14-071, I, 2014. [AL98] [All07] Eric Allender and Klaus-Jorn Lange. Ruspace(log n) $\subseteq$ DSPACE (log2 n / log log n). Theory Comput. Syst., 31(5):539 -- 550, 1998. E. Allender. Reachability problems: An update. Computation and Logic in the Real World, pages 25 -- 27, 2007. [BBRS92] Greg Barnes, Jonathan F. Buss, Walter L. Ruzzo, and Baruch Schieber. A sublinear space, polynomial time algorithm for directed s-t connectivity. In Structure in Com- plexity Theory Conference, 1992., Proceedings of the Seventh Annual, pages 27 -- 33, 1992. [BJLR91] Gerhard Buntrock, Birgit Jenner, Klaus-Jrn Lange, and Peter Rossmanith. Unambi- guity and fewness for logarithmic space. In L. Budach, editor, Fundamentals of Com- putation Theory, volume 529 of Lecture Notes in Computer Science, pages 168 -- 179. Springer Berlin Heidelberg, 1991. [BTV09] [Coo79] Chris Bourke, Raghunath Tewari, and N. V. Vinodchandran. Directed planar reachabil- ity is in unambiguous log-space. ACM Transactions on Computation Theory, 1(1):1 -- 17, 2009. S.A. Cook. Deterministic CFL's are accepted simultaneously in polynomial time and log squared space. In Proceedings of the eleventh annual ACM Symposium on Theory of Computing, pages 338 -- 345. ACM, 1979. [CPT+14] Diptarka Chakraborty, Aduri Pavan, Raghunath Tewari, N. Variyam Vinodchandran, and Lin Yang. New time-space upperbounds for directed reachability in high-genus and $h$-minor-free graphs. Electronic Colloquium on Computational Complexity (ECCC), 21:35, 2014. 10 [CRV11] Kai-Min Chung, Omer Reingold, and Salil Vadhan. S-t connectivity on digraphs with a known stationary distribution. ACM Trans. Algorithms, 7(3):30:1 -- 30:21, July 2011. [INP+13] T. Imai, K. Nakagawa, A. Pavan, N.V. Vinodchandran, and O. Watanabe. An O(n1/2+ǫ)-Space and Polynomial-Time Algorithm for Directed Planar Reachability. In Computational Complexity (CCC), 2013 IEEE Conference on, pages 277 -- 286, 2013. [KKR08] Sampath Kannan, Sanjeev Khanna, and Sudeepa Roy. STCON in Directed Unique- Path Graphs. In Ramesh Hariharan, Madhavan Mukund, and V Vinay, editors, IARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science, volume 2 of Leibniz International Proceedings in Informatics (LIPIcs), pages 256 -- 267, Dagstuhl, Germany, 2008. Schloss Dagstuhl -- Leibniz-Zentrum fuer Informatik. [Lan97] Klaus-Jorn Lange. An unambiguous class possessing a complete set. In STACS '97: Proceedings of the 14th Annual Symposium on Theoretical Aspects of Computer Sci- ence, pages 339 -- 350, 1997. [LP82] Harry R. Lewis and Christos H. Papadimitriou. Symmetric space-bounded computa- tion. Theor. Comput. Sci., 19:161 -- 187, 1982. [LP86] L. Lovasz and M.D. Plummer. Matching theory. 1986. [Nis95] [Rei08] [RTV06] [Sav70] [Vin14] [Wig92] Noam Nisan. RL ⊆ SC. In In Proceedings of the Twenty Fourth Annual ACM Sympo- sium on Theory of Computing, pages 619 -- 623, 1995. Omer Reingold. Undirected connectivity in log-space. Journal of the ACM, 55(4), 2008. Omer Reingold, Luca Trevisan, and Salil Vadhan. Pseudorandom walks on regular digraphs and the RL vs. L problem. In STOC '06: Proceedings of the thirty-eighth annual ACM Symposium on Theory of Computing, pages 457 -- 466, New York, NY, USA, 2006. ACM. Walter J. Savitch. Relationships between nondeterministic and deterministic tape com- plexities. J. Comput. Syst. Sci., 4:177 -- 192, 1970. N. V. Vinodchandran. Space complexity of the directed reachability problem over surface-embedded graphs. Technical Report TR14-008, I, 2014. Avi Wigderson. The complexity of graph connectivity. Mathematical Foundations of Computer Science 1992, pages 112 -- 132, 1992. 11
1201.6488
2
1201
2012-04-03T13:17:20
Advanced Coarsening Schemes for Graph Partitioning
[ "cs.DS", "cs.DC" ]
The graph partitioning problem is widely used and studied in many practical and theoretical applications. The multilevel strategies represent today one of the most effective and efficient generic frameworks for solving this problem on large-scale graphs. Most of the attention in designing the multilevel partitioning frameworks has been on the refinement phase. In this work we focus on the coarsening phase, which is responsible for creating structurally similar to the original but smaller graphs. We compare different matching- and AMG-based coarsening schemes, experiment with the algebraic distance between nodes, and demonstrate computational results on several classes of graphs that emphasize the running time and quality advantages of different coarsenings.
cs.DS
cs
Advanced Coarsening Schemes for Graph Partitioning(cid:63) Ilya Safro1 , Peter Sanders2 , and Christian Schulz2 1 Mathematics and Computer Science Division, Argonne National Laboratory [email protected] 2 Karlsruhe Institute of Technology, Institute for Theoretical Informatics, Algorithmics II [email protected], [email protected] Abstract. The graph partitioning problem is widely used and studied in many practical and theoretical applications. The multilevel strategies represent today one of the most effective and efficient generic frameworks for solving this problem on large-scale graphs. Most of the attention in designing the multilevel partitioning frameworks has been on the refinement phase. In this work we focus on the coarsening phase, which is responsible for creating structurally similar to the original but smaller graphs. We compare different matching- and AMG-based coarsening schemes, experiment with the algebraic distance between nodes, and demonstrate computational results on several classes of graphs that emphasize the running time and quality advantages of different coarsenings. 1 Introduction Graph partitioning is a class of problems used in many fields of computer science and engineering. Applica- tions include VLSI design, load balancing for parallel computations, network analysis, and optimal scheduling. The goal is to partition the vertices of a graph into a certain number of disjoint sets of approximately the same size, so that a cut metric is minimized. This problem is NP-complete even for several restricted classes of graphs, and there is no constant factor approximation algorithm for general graphs [5]. In this paper we focus on a version of the problem that constrains the maximum block size to (1 + ) times the average block size and tries to minimize the total cut size, namely, the number of edges that run between blocks. Because of the practical importance, many heuristics of different nature (spectral [19], combinatorial [10], evolutionist [4,24], etc.) have been developed to provide an approximate result in a reasonable (and, one hopes, linear) computational time. We refer the reader to [11,26,33] for more material. However, only the introduction of the general-purpose multilevel methods during the 1990s has provided a breakthrough in efficiency and quality. The basic idea can be traced back to multigrid solvers for solving elliptic partial differential equations [31] but more recent practical methods are based on mostly graph-theoretic aspects of, in particular, edge contraction and local search. Well-known software packages based on this approach include Jostle [33], Metis [26], DiBaP [17], and Scotch [18]. A multilevel algorithm consists of two main phases: coarsening – where the problem instance is grad- ually mapped to smaller ones to reduce the original complexity (i.e., the graph underlying the problem is compressed), and uncoarsening – where the solution for the original instance is constructed by using the information inherited from the solutions created at the next coarser levels. So far, most of the attention in designing the multilevel partitioning frameworks has been on the uncoarsening phase. In this work we focus on the coarsening phase, which is responsible for creating graphs that are smaller than but structurally similar to the given graph. We compare different coarsening schemes, introduce new elements to them, and demonstrate computational results. For this purpose different coarsening schemes are integrated into the graph partitioning framework KaFFPa [25]. The paper is organized as follows. We begin in Section 2 by introducing notation and the multilevel ap- proach. In Section 3 we describe different coarsening schemes, including a novel algebraic, multigrid-inspired balanced coarsening scheme and matching-based coarsening schemes, as well as new measures for connectiv- ity. We present a large experimental evaluation in Section 4 on graphs arising in real-world applications and on graphs that are specifically designed to be hard for multilevel algorithms. (cid:63) Partially supported by DFG SA 933/10-1 and CSCAPES institute, a DOE pro ject. 2 Preliminaries n = V , and m = E . We extend c and ω to sets; in other words, c(V (cid:48) ) := (cid:80) Consider an undirected graph G = (V , E , c, ω) with edge weights3 ω : E → R>0 , node weights c : V → R≥0 , (cid:80) v∈V (cid:48) c(v) and ω(E (cid:48) ) := e∈E (cid:48) ω(e). Here, Γ (v) := {u : {v , u} ∈ E } denotes the neighbors of v . We are looking for blocks of nodes V1 ,. . . ,Vk that partition V , namely, V1 ∪ · · · ∪ Vk = V and Vi ∩ Vj = ∅ for i (cid:54)= j . The balancing constraint demands that ∀i ∈ {1..k} : c(Vi ) ≤ Lmax := (1 + )c(V )/k + maxv∈V c(v) for some parameter . The last term allowed. The ob jective is to minimize the total cut (cid:80) in this equation arises because each node is atomic and therefore a deviation of the heaviest node has to be i<j ω(Eij ) where Eij := {{u, v} ∈ E : u ∈ Vi , v ∈ Vj }. A vertex v ∈ Vi that has a neighbor w ∈ Vj , i (cid:54)= j , is a boundary vertex. We denote by nnzr(A, i) and nnzc(A, i) the number of nonzero entries in the ith row or column of a matrix A, respectively. A matching M ⊆ E is a set of edges that do not share any common nodes; that is, the graph (V , M ) has maximum degree one. Contracting an edge {u, v} means replacing the nodes u and v by a new node x connected to the former neighbors of u and v . We set c(x) = c(u) + c(v) so the weight of a node at each level is the number of nodes it is representing in the original graph. If replacing edges of the form {u, w},{v , w} would generate two parallel edges {x, w}, we insert a single edge with ω({x, w}) = ω({u, w}) + ω({v , w}). Uncontracting an edge e undoes its contraction. 2.1 Multilevel Graph Partitioning In the multilevel framework we construct a hierarchy of decreasing-size graphs, G0 , G1 , . . . , Gk , by coarsening, starting from the given graph G0 such that each next-coarser graph Gi reflects basic properties of the previous graph Gi−1 . At the coarsest level Gk is partitioned by a hybrid of external solvers, and starting from the (k − 1)th level the solution is pro jected gradually (level by level) to the finest level. Each pro jection is followed by the refinement, which moves nodes between the blocks in order to reduce the size of the cut. This entire process is called a V-cycle (see Figure 1). KaFFPa [25] extended the concept of iterated multilevel algorithms which was introduced for graph partitioning by Walshaw et al. [32]. The main idea is to iterate the multilevel-scheme using dif- ferent random seeds for coarsening and uncoarsening. This ensures non-decreased partition quality since the refinement algorithms of KaFFPa guarantee no worsening. In this pa- per, for the purpose of comparison we consider also F-cycles [25] (see Figure 1) as a potentially stronger and slower ver- sion of the multilevel framework for the graph partitioning problem. The detailed description of F-cycles for the multi- level graph partitioning framework can be found in [25]. Fig. 1. V- and F-cycles schemes. 3 Coarsening Schemes One of the most important concerns of multilevel schemes is a measure of the connection strength between vertices. For matching-based coarsening schemes, experiments indicate that more sophisticated edge rating functions are superior to edge weight as a criterion for the matching algorithm [12]. To be more precise first the edges get rated using a rating function that indicates how much sense it makes to contract an edge. Then a matching algorithm tries to maximize the sum of the ratings of the edges to be contracted. The default configurations of KaFFPa employ the ratings expansion∗2 ({u, v}) := ω({u, v})2/c(u)c(v), and where Out(v) := (cid:80) innerOuter({u, v}) := ω({u, v})/(Out(v) + Out(u) − 2ω(u, v)), x∈Γ (v) ω({v , x}), since they yielded the best results in [12]. 3 Subscripts will be used for a short notation; i.e., ωij corresponds to the weight of {i, j } ∈ E . 2 GGk0V−cycleF−cycle Algebraic distance for graph partitioning. The notion of algebraic distance introduced in [21,6] is based on the principle of obtaining low-residual error components used in the Bootstrap AMG [3]. When a priori knowledge of the nature of this error is not available, slightly relaxed random vectors are used to approximate it. This principle was used for linear ordering problems to distinguish between local and global edges [21]. The main difference between the k-partitioning problem and other (not necessarily combinatorial) problems for which the algebraic distance has been tested so far is the balancing constraints. For many instances, it is important to keep the coarsening balanced; otherwise, even though the structural information will be captured by a sophisticated coarsening procedure, most of the actual computational work that constructs the approximate solution will be done by the refinement iterations. Bounding the number of refinement iterations may dramatically decrease its quality. Thus, a volume-normalized algebraic distance is introduced D is the diagonal matrix with entries Dii = (cid:80) to take into account the balancing of vertices. Given the Laplacian of a graph L = D − W , where W is a weighted adjacency matrix of a graph and L = D − W based on volume-normalized edge weights ωij = ωij /(cid:112)c(i)c(j ). We define an iteration matrix j ωij , we define its volume-normalized version denoted by H for Jacobi over-relaxation (also known as a lazy random-walk matrix) as H = (1 − α)I + α D−1 W , where 0 ≤ α ≤ 1. The algebraic distance coupling ρij is defined as ρij = (cid:0) R(cid:88) 2 (cid:1) 1 2 , r=1 where χ(k,r) = H k χ(0,r) is a relaxed randomly initialized test vector (i.e., χ(0,r) is a random vector sampled over [-1/2, 1/2]), R is the number of test vectors, and k is the number of iterations. In our experimental settings we set α = 0.5, R = 5, and k = 20. − χ(k,r) j χ(k,r) i 3.1 Coarsening To the best of our knowledge, the existing multilevel algorithms for combinatorial optimization problems (such as k-partitioning, linear ordering, clustering, and segmentation) can be divided into two classes: contraction-based schemes [25,8,14] (including contractions of small subsets of nodes [2]) and algebraic multi- grid (AMG)-inspired schemes [21,13,27,20]. AMG-inspired coarsening. One of the most traditional approaches for derivation of the coarse systems in AMG is the Galerkin operator [31], which pro jects the fine system of equations to the coarser scale. In the context of graphs this pro jection is defined as Lc = P Lf P T , (1) where Lf and Lc are the Laplacians of fine and coarse graphs Gf = (Vf , Ef ) and Gc = (Vc , Ec ), respectively. The (i, J )th entry of pro jection matrix P represents the strength of the connection between fine node i and coarse node J . The entries of P, called interpolation weights, describe both the coarse-to-fine and fine-to- coarse relations between nodes. The coarsening begins by selecting a dominating set of (seed or coarse) nodes C ⊂ Vf such that all other (fine) nodes in F = Vf \ C are strongly coupled to C . This selection can be done by traversing all nodes and leaving node i in F (initially F = Vf , and C = ∅) that satisfy (cid:88) 1/ρij ≥ Θ · (cid:88) j∈Vf j∈C 1/ρij , (2) 3 where Θ is a parameter of coupling strength. As in AMG-based approaches for linear ordering problems [22] we observed that the order in which Vf is traversed does play an important role in reducing the dependence on random seeds (for details on future volume ordering see [21]). The Galerkin operator construction differs from other AMG-based approaches for combinatorial optimiza- tion problems. Balancing constraints of the partitioning problem require a limited number of fine-to-coarse attractions between i ∈ C (ith column in P ) and its neighbors from F (nonzero entries in the ith column in P ). In particular, this is important for graphs where the number of high-degree nodes in C is smaller than the number of parts in the desired partition. Another well-known problem of AMG that can affect the performance of the solver is the complexity of coarse levels. Consideration of the algebraic distance makes it possible to minimize the order of interpolation (the number of fractions a node from F can be divided to) to 1 or 2 only [21]. Algorithm 1 summarizes the construction of P . input : G, i ∈ Vf , P if i ∈ C then PiI (j ) ← 1; else l ← list of at most κ algebraically strongest connections of i to C ; {e1 , e2 } ← algebraically strongest pair of edges (according to ρe1 + ρe2 ) in l such that the corresponding C -neighbors are not over-loaded if i is divided between them; if {e1 , e2 } (cid:54)= ∅ then l ← {e1 , e2 } else e1 ← algebraically strongest connection of i to C such that the corresponding C -neighbor is not over-loaded if i is aggregated with it; l ← {e1 }; if l is empty then move i to C PiI (j ) ← 1/(ρij · (cid:80) else i ← C -neighbors of i that adjacent to edges in l; N c 1/ρik ) for j ∈ N c i ; k∈N c update future volumes of j ∈ N c i i ; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Algorithm 1: Interpolation weights for P Algorithm 1 can be viewed as simplified version of bootstrap AMG [3] with the additional restriction weight wpq = (cid:80) k (cid:54)=l PkpwklPlq . The volume of the pth coarse aggregate is (cid:80) on future volume of aggregates and adaptive interpolation order. PiI (j ) thus represents the likelihood of i belonging to the I (j )th aggregate. The edge connecting two coarse aggregates p and q is assigned with the j c(j )Pjp . We emphasize the property of adaptivity of C (line 15 in Algorithm 1), which is updated if the balancing of aggregates is not satisfied. We mention the difference between our AMG scheme and the weighted aggregation (WAG) scheme in [7]. The common principle that works in both schemes is based on the division of F -nodes between their C -neighbors. However, two critical components are missing in [7]: (1) the algebraic distance that forms both the set of seeds and the interpolation operator; and (2) the weight-balancing algorithmic component when aggregates are created, namely, operator P in [7] is created as in classical AMG schemes. One important disadvantage of [7] is a relatively high density of coarse levels, which is eliminated with introduction of the algebraic distance. This was achieved by reducing the order of interpolation to 1 or 2. The balancing factor played an important role in reducing the running time of the algorithm. Recently introduced max- flow/min-cut refinement leads to noticeably better results than FM/KL heuristics (explained in Section 3.3). In contrast to simple FM/KL swaps, however, its complexity becomes higher if the aggregates are unbalanced with respect to the maximum size of one part. Applying this refinement with unbalanced WAG 4 can significantly increase the total running time of the solver or lead to weak solutions if the refinement is terminated before it finds a good local minimum. Overall, the performance of our AMG scheme differs significantly from what we observed with WAG. Matching based coarsening. Another coarsening framework, which is more popular because of its sim- plicity and faster performance, is the matching based scheme. In this scheme a coarse graph is constructed by using contractions derived from a preprocessed edge matching. This scheme represents a special case of P Lf P T in which nnzr(P , r) = 1 for all rows r in P , and 1 ≤ nnzc(P , c) ≤ 2 for all columns c in P . Global Paths Algorithm. The Global Paths Algorithm (GPA), was proposed in [16] as a synthesis of Greedy and Path Growing algorithms [9]. Similar to the Greedy approach, GPA scans the edges in order of decreasing weight (or rating); but rather than immediately building a matching, it first constructs a collection of paths and even length cycles. To be more precise, these paths initially contain no edges. While scanning the edges, the set is then extended by successively adding applicable edges. An edge is called applicable if it connects two endpoints of different paths or the two endpoints of an odd length path. Afterwards, optimal solutions are computed for each of these paths and cycles using dynamic programming. KaFFPaStrong [25] employs innerOuter on the first level of the hierarchy since expansion∗2 evaluates to one on unweighted graphs. Afterwards it uses expansion∗2 . RandomGPA Algorithm. This algorithm is used by the classic KaFFPaEco configuration. It is a synthesis of the most simple random matching algorithm and the GPA algorithm. To be more precise this matching algorithm is dependent of the number of blocks the graph has to be partitioned in. It matches the first max{2, 7 − log k} levels using the random matching algorithm and switches to the GPA algorithm afterwards. The random matching algorithm traverses the nodes in a random order and if the current node is not already matched it chooses a random unmatched neighbor for the matching. KaFFPaEco employs expansion∗2 as a rating function as soon as it uses GPA. 3.2 The Coarsest Level Contraction is stopped when the graph is small enough to be partitioned by some other expensive algorithm. We use the same initial partitioning scheme as in KaFFPa [25], namely, the libraries Scotch and Metis for initial partitioning. For AMG, some modifications have to be made since Scotch and Metis cannot deal with fractional numbers and Metis expects ωij ≥ 1. To overcome this implementational problem, we perform the following two steps. First, we divide each edge weight of the coarsest graph by the smallest edge weight that occurred on that level. This step assures edge weights larger than or equal to one without skewing the graph partitioning problem for the library used. Second, we get rid of the fractional edge weights using randomized rounding. Let e ∈ E be an edge with fractional edge weight. We then obtain an integer edge weight ω(e) by flipping a coin with probabilities P (head) = ω(e) − (cid:98)ω(e)(cid:99), P (tail) = 1 − P (head). In the case of heads we set the edge weight ω(e) to (cid:100)ω(e)(cid:101); otherwise we set it to (cid:98)ω(e)(cid:99). This way we can assure that the value of the cut in the graph G = (Vk , Ek , ω) produced by the external initial partitioning algorithm is close to the real cut value in G. 3.3 Uncoarsening Recall that uncoarsening undoes contraction. For AMG-based coarsening this means that fine nodes have to be assigned to blocks of the partition of the finer graph in the hierarchy. We assign a fine node v to the block that minimizes cutB · pB (v), where cutB is the cut after v would be assigned to block B and pB (v) is a penalty function to avoid blocks that are heavily overloaded. To be more precise, after some experiments we fixed the penalty function to pB (v) = 2max(0,100 c(B)+c(v) ) , where Lmax is the upper bound for the block Lmax weight. Note that slight imbalances (e.g. overloaded blocks), can usually be fixed by the refinement algorithms implemented within KaFFPa. For matching-based coarsening the uncoarsening is straightforward: a vertex is assigned to the block of the corresponding coarse vertex. 5 Karlsruhe Fast Flow Partitioner (KaFFPa). Since we integrated different coarsening schemes into the multi- level graph partitioner KaFFPa [25], we now briefly outline the techniques KaFFPa uses during uncoarsening. After a matching is uncontracted, local search-based refinement algorithms move nodes between block bound- aries in order to reduce the cut while maintaining the balancing constraint. Local improvement algorithms are usually variants of the FM algorithm [10]. The variant KaFFPa uses is organized in rounds. In each round, a priority queue P is used that is initialized with all vertices that are incident to more than one block, in a random order. The priority is based on the gain g(i) = maxP gP (i) where gP (i) is the decrease in edge cut when moving i to block P . Local search then repeatedly looks for the highest gain node v and moves it to the corresponding block that maximizes the gain. However, in each round a node is moved at most once. After a node is moved, its unmoved neighbors become eligible, i.e. its unmoved neighbors are inserted into the priority queue. When a stopping criterion is reached, all movements to the best-found cut that occurred within the balance constraint are undone. This process is repeated several times until no improvement is found. Max-Flow Min-Cut Local Improvement. During the uncoarsening phase KaFFPa additionally uses more advanced refinement algorithms. The first method is based on max-flow min-cut computations between pairs of blocks, in other words, a method to improve a given bipartition. Roughly speaking, this improvement method is applied between all pairs of blocks that share a nonempty boundary. The algorithm basically constructs a flow problem by growing an area around the given boundary vertices of a pair of blocks such that each s-t cut in this area yields a feasible bipartition of the original graph/pair of blocks within the balance constraint. One can then apply a max-flow min-cut algorithm to obtain a min-cut in this area and therefore a nondecreased cut between the original pair of blocks. This can be improved in multiple ways, for example, by iteratively applying the method, searching in larger areas for feasible cuts, and applying most balanced minimum cut heuristics. For more details we refer the reader to [25]. Multi-try FM. The second method for improving a given partition is called multi-try FM. This local im- provement method moves nodes between blocks in order to decrease the cut. Previous k-way methods were initialized with al l boundary nodes, i.e., all boundary nodes were eligible for movement at the beginning. Roughly speaking, the multi-try FM algorithm is a k-way improvement method that is initialized with a single boundary node, thus achieving a more localized search. This is repeated several rounds. For more details about the multi-try FM algorithm we refer the reader to [25]. 4 Experimental Evaluation Configurations of KaFFPa. The AMG coarsening was implemented separately based on the coarsening for linear ordering solvers from [21] and was integrated into KaFFPa [25]. The computational experiments have been performed with six configurations of KaFFPa, which are presented in Table 1. All configurations use the described FM algorithm and flows for the refinement. The strong configurations further employ flows using larger areas, multi-try FM and F-cycles. A detailed description of the refinement configurations can be found in [25]. Throughout this section, because of the respective similar running times, we concentrate on two groups of comparison: for fast versions (AMG-ECO, ECO, ECO-ALG) and for strong versions (AMG, STRONG, F-CYCLE). To be precise, usually the running time of F-CYCLE is bigger than that of STRONG and AMG. However, the running time gap between fast and strong versions is even more significant on average. Since the main goal of this paper is to introduce the AMG coarsening with different uncoarsening configurations, most of the comparisons will be of type AMG vs respective non-AMG ratios. A comprehensive comparison of the F-CYCLE and the STRONG configuration can be found in [25]. All experiments are performed with fixed imbalance factor 3%. We also checked other small values, namely, 0%, 1%, and 5%; however, no significant difference in the comparison of the respective methods was observed. 6 ECO Represents the classical KaFFPaEco configuration, a good trade-off of partition quality and runtime. ECO-ALG Same refinement as in ECO, coarsening uses the GPA algorithm at each level and the edge rating function employs algebraic distances; i.e., it uses the rating function ex alg(e) := expansion∗2 (e)/ρe . F-CYCLE Represents the classical KaFFPaStrong configuration using strong refinement schemes and the F-cycle scheme, with the purpose of achieving high partition quality; this configuration achieved the best known partitions for many instances from Benchmark I in 2010 [25]. STRONG Uses the same refinement and matching schemes as in the F-CYCLE configuration; however, here only one single V-cycle is performed. AMG-ECO AMG coarsening based on algebraic distances with interpolation order at most 2, refinement as in ECO. AMG Same coarsening as in AMG-ECO, same refinement as in STRONG. Table 1. Description of the six configurations used for the computational experiments. Benchmark I: Walshaw’s Partitioning Archive. Chris Walshaw’s benchmark archive [28] is a collection of real-world instances for the partitioning problem. The rules used there imply that the running time is not an issue, but one wants to achieve minimal cut values for k ∈ {2, 4, 8, 16, 32, 64} and balance parameters  ∈ {0, 0.01, 0.03, 0.05}. It is the most used graph partitioning benchmark in the literature. Most of the graphs of the benchmark come from finite-element applications; however, there are also some graphs from VLSI design and a road network. Over the years many different heuristics have been tested and adjusted on this benchmark, so that many heuristics are able to obtain good results on these graphs. In Figures 2 we present the results of the comparison of the algorithms on these graphs for different numbers of blocks k . The horizontal axes represent ordered graphs from the benchmark (however, the ordering itself will be different for each curve). The vertical axes are for ratios that represent the comparison of averages of final results for a pair of methods. Each figure contains four curves. Each curve correspond to a comparison of the following pairs of methods: ECO vs. AMG-ECO, ECO-ALG vs. AMG-ECO, STRONG vs. AMG, and F-CYCLE vs. AMG. Each point on the curves corresponds to the ratio between the average over 10 runs of one method and the average over 10 runs of another method. Each run depends on different random seeds and, thus, can produce different results. For example, the last point at the black solid curve in Figure 2a has value 2.03, which means that average(ECO final cut given seed s1 , · · · , ECO final cut given seed s10 ) average(AMG-ECO final cut given seed s1 , · · · , AMG-ECO final cut given seed s10 ) in experimental series for k = 2. A comparison of the running time for uncoarsening phases is presented in Figure 3. Each point on the curves in Figure 3 corresponds to a ratio of uncoarsening running times of two methods. We observed that uncoarsening performance of fast versions (ECO, ECO-ALG, AMG-ECO) are more or less similar to each other. The uncoarsening of a STRONG V-cycle is somewhat slower than AMG because of the density of coarse levels. The averages are summarized in Table 2. Full results are summarized in [23]. = 2.03 k ECO/ECO-ALG ECO-ALG/ECO-AMG STRONG/AMG F-CYCLE/AMG 1.012 1.013 1.034 1.026 2 1.004 1.009 1.021 1.053 4 0.995 0.998 1.023 1.019 8 16 1.015 1.012 1.001 0.999 1.002 1.003 1.017 1.008 32 64 1.004 1.009 1.000 0.997 Table 2. Computational comparison for Benchmark I. Each number corresponds to the ratio of averages of final cuts for pair of methods in the column title and k given in the row. Benchmark II: Scale-free networks. In scale-free networks the distribution of vertex degrees asymptotically follows the power-law distribution. Examples of such networks include WWW links, social communities, and biological networks. These types of networks often contain irregular parts and long-range links (in contrast to Benchmark I) that can confuse both contraction and AMG coarsening schemes. Since Walshaw’s benchmark 7 (a) k = 2 (b) k = 4 (c) k = 8 (d) k = 16 (e) k = 32 (f ) k = 64 Fig. 2. Comparison of coarsening schemes on Walshaw’s benchmark graphs. Figures (a)-(f ) contain results of compari- son for k = 2, 4, 8, 16, 32, and 64, respectively. Each figure contains four curves that correspond to ECO/AMG-ECO, ECO-ALG/AMG-ECO, STRONG/AMG, and F-CYCLE/AMG ratios, respectively. Each point on a curve corre- sponds to the ratio related to one graph. 8 0102030graphs ordered by ratios11.21.41.61.82ratiosECO/AMG-ECOECO-ALG/AMG-ECOSTRONG/AMGF-CYCLE/AMG0102030graphs ordered by ratios11.21.41.61.82ratiosECO/AMG-ECOECO-ALG/AMG-ECOSTRONG/AMGF-CYCLE/AMG0102030graphs ordered by ratios0.9511.051.11.151.21.251.31.35ratiosECO/AMG-ECOECO-ALG/AMG-ECOSTRONG/AMGF-CYCLE/AMG0102030graphs ordered by ratios0.9511.051.11.151.21.25ratiosECO/AMG-ECOECO-ALG/AMG-ECOSTRONG/AMGF-CYCLE/AMG0102030graphs ordered by ratios11.051.11.15ratiosECO/AMG-ECOECO-ALG/AMG-ECOSTRONG/AMGF-CYCLE/AMG0102030graphs ordered by ratios0.9511.051.11.15ratiosECO/AMG-ECOECO-ALG/AMG-ECOSTRONG/AMGF-CYCLE/AMG Fig. 3. Comparison of uncoarsening running time on Walshaw’s benchmark graphs for k = 32. The figure contains four curves that correspond to ECO/AMG-ECO, ECO-ALG/AMG-ECO, STRONG/AMG, and F-CYCLE/AMG ratios, respectively. Each point on curves correspond to the ratio related to one graph. . doesn’t contain graphs derived from such networks, we evaluate our algorithms on 15 graphs collected from [1,15]. Full information about these graphs, along with the computational results, is available at [23]. The results of the comparison on scale-free graphs are presented in Figure 4. Because of the large running time of the strong configurations on these graphs, we compare only the fast versions of AMG and matching- based coarsening. Each figure corresponds to a different number of blocks k . The horizontal axes represent graphs from the benchmark. The vertical axes are for ratios that represent comparison of averages of final results for a pair of methods. Each graph corresponds to one quadruple of bars. First, second, third and fourth bars represent averages of ratios ECO/AMG-ECO, ECO-ALG/AMG-ECO after finest refinement, ECO/AMG-ECO, ECO-ALG/AMG-ECO before finest refinement, respectively. As in the previous case the averages are calculated over 10 runs. ECO-ALG ECO-ALG ECO ECO ECO ECO-ALG AMG-ECO AMG-ECO ECO-ALG ECO-ALG quality full time uncoarsening time quality uncoarsening time 3.62 1.16 1.62 0.77 1.38 1.24 1.32 1.85 1.11 2.14 1.94 1.07 1.45 1.29 1.15 1.69 1.06 1.33 1.27 1.09 1.60 1.00 1.23 1.18 1.06 1.06 1.13 1.13 1.01 2.99 k 2 4 8 16 32 64 Table 3. Computational comparison for scale-free graphs. Benchmark III: Potential ly Hard Graphs for Fast k-partitioning Algorithms. Today multilevel strategies represent one of the most effective and efficient generic frameworks for solving the graph partitioning problem on large-scale graphs. The reason is obvious: given a successful global optimization technique X for this problem, one can consider applying it locally by introducing a chain of subproblems along with fixed boundary conditions. Given this and if the coarsening preserves the structural properties of the graph well enough , the multilevel heuristic can behave better and work faster than a direct global application of the optimization technique X . Examples of such combinations include FM/KL, spectral and min-cut/max-flow techniques with multilevel frameworks. When can the multilevel framework produce low quality results? We present a simple strategy for checking the quality of multilevel schemes. To construct a potentially hard instance for gradual multilevel pro jections, we consider a mixture of graphs that are weakly connected with each other. These graphs have to possess different structural properties (such as finite-element faces, 9 0102030graphs ordered by ratios012345678ratiosECO/AMG-ECOECO-ALG/AMG-ECOSTRONG/AMGF-CYCLE/AMG (a) k = 2 (b) k = 4 (c) k = 8 (d) k = 16 (e) k = 32 (f ) k = 64 Fig. 4. Comparison of coarsening schemes on scale-free graphs. Figures (a)-(f ) contain results of comparison for k = 2, 4, 8, 16, 32, and 64, respectively. Each quadruple of bars correspond to one graph. First, second, third and fourth bars represent averages of ratios ECO/AMG-ECO, ECO-ALG/AMG-ECO after refinement, ECO/AMG-ECO, and ECO-ALG/AMG-ECO before refinement, respectively. Three exceptionally high ratios on both Figures are between 2.1 and 3. 10 1234567891011121314150.511.522.53Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.511.52Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.6Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.61.82Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.6Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.6Graphs ordered by ratio ECO−ALG/AMG−ECORatios ECO ECO-ALG quality k 2 4 8 1.42 1.15 1.12 ECO ECO-ALG full time 0.51 0.88 1.08 1.18 1.23 1.08 F-CYCLE STRONG STRONG ECO-ALG ECO-ALG AMG-ECO AMG AMG AMG AMG-ECO quality uncoarsening quality uncoarsening quality time time 2.11 0.55 1.69 0.64 0.98 1.37 1.15 1.13 1.05 1.11 1.12 1.04 Table 4. Computational comparison for potentially hard graphs. power-law degree distribution, and density) to ensure nonuniform coarsening and mutual aggregation of well-separated graph regions. Such mixtures of structures may have a twofold effect. First, they can force the algorithm to contract incorrect edges; and second, they can attract a ”too strong” refinement to reach a local optimum, which can contradict better local optimums at finer levels. The last situation has been observed in different variations also in multilevel linear ordering algorithms [22]. In other words, the uneven aggregation with respect to the scales (not to be confused with uneven sizes of clusters) can lead refinement algorithms to wrong local attraction basins. Examples of graphs that contain such mixtures of structures include multi-mode networks [30] and logistics multi-stage system networks [29]. In general, such graphs can be difficult not only to the multilevel algorithms. We created a benchmark (available at [1]) with potentially hard mixtures. Each graph in this benchmark represents a star-like structure of different graphs S0 , . . . , St . Graphs S1 , . . . , St are weakly connected to the center S0 by random edges. Since all the constituent graphs are sparse, a faster aggregation of them has been achieved by adding more than one random edge to each boundary node. The total number of edges between each Si and S0 was less than 3% out of the total number of edges in Si . We considered the mixtures of the following structures: social networks, finite-element graphs, VLSI chips, peer-to-peer networks, and matrices from optimization solvers. The comparison on this benchmark is demonstrated in Figure 5. Each graph corresponds to one quadruple of bars. The first, second, third and the fourth bar represent averages over 10 ratios of ECO/AMG-ECO, ECO-ALG/AMG-ECO, STRONG/AMG, and F-cycle/AMG, respectively. In almost all experiments we observed that introduction of algebraic distance as a measure of connectivity plays a crucial role in both fast versions AMG-ECO and ECO-ALG since it helps to separate the subgraphs and postpone their aggregation into one mixture. We also observe that both fast and slow AMG coarsenings almost always lead to better results. Note that in contrast to Benchmarks I and II, the uncoarsening of ECO-ALG is significantly faster than that of AMG-ECO. Role of the algebraic distance. In this work the importance of the algebraic distance as a measure of con- nectivity strength for graph partitioning algorithms has been justified in almost all experimental settings. In particular, the most significant gap was observed between ECO and ECO-ALG (see all benchmarks), versions which confirms preliminary experiments in [6], where the algebraic distance has been used at the finest level only. The price for improvement in the quality is the additional running time for Jacobi over- relaxation, which can be implemented by using the most suitable (parallel) matrix-vector multiplication method. However, in cases of strong configurations and/or large irregular instances, the difference in the running time becomes less influential as it is not comparable to the amount of work in the refinement phase. For example, for the largest graph in Benchmark I (auto, V = 448695, E = 3314611) the ECO coarsening is approximately 10 times faster than that in the ECO-ALG; but for both configurations when k = 64, it takes less than 3% of the total time. Note that for irregular instances from Benchmark II, already starting k = 4 the total running time for ECO becomes bigger than in ECO-ALG (see Table 3). More examples of trade-off between changes in the ob jectives and those in the running times on Benchmark III are presented in Figure 6. Does AMG coarsening help? The positive answer to this question is given mostly by Benchmarks II and III, which contain relatively complex instances (Tables 3 and 4). On Benchmark III we have demonstrated that the AMG configuration is superior to F-CYCLE, which runs significantly longer. This result is in contrast to Benchmark I, in which we did not observe any particular class of graphs that corresponded to stable significant difference in favor of one of the methods in pairs ECO-ALG vs AMG-ECO and STRONG vs 11 (a) k = 2 (b) k = 2, before last refinement (c) k = 4 (d) k = 4, before last refinement (e) k = 8 (f ) k = 8, before last refinement Fig. 5. Comparison of coarsening schemes on hard examples. Figures (a,c,e) contain results of comparison before applying finest level refinement. Figure (b,d,f ) contain results of comparison of final results. Each quadruple of bars correspond to one graph. First, second, third and fourth bars represent averages of ratios ECO/AMG-ECO, ECO- ALG/AMG-ECO, STRONG/AMG, and F-cycle/AMG, respectively. Four exceptionally high ratios on both Figures are between 3.5 and 5.7. 12 1234567891011121314150.811.21.41.61.82Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.6Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.61.822.2Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.61.82Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.61.8Graphs ordered by ratio ECO−ALG/AMG−ECORatios1234567891011121314150.811.21.41.6Graphs ordered by ratio ECO−ALG/AMG−ECORatios Fig. 6. Benchmark III: Trade-off between changes in the ob jectives (horizontal axis) and those in the running times (vertical axis) on Benchmark III. Data points for k = 2, 4, and 8 are represented by circles, squares, and triangles, respectively. Average ratios are calculated each over 10 runs similarly to previous figures. The left and right figures describe the comparison for ECO vs. ECO-ALG and ECO-ALG vs. STRONG configurations, respectively. AMG. However, we note that in both Benchmarks I and II several graphs exhibited that AMG versions yield to the respective matching for large k . The problem is eliminated when we stabilize ρ by using more relaxations according to Theorem 4.2 in [21]. We cannot present here the exact comparison of coarsening running times because their underlying implementations are very different. Theoretically, however, if in both matching and AMG configurations the algebraic distance is used and when the order of interpolation in AMG is limited by 2 (and usually it is 1, meaning that the coarse graphs are not dense like in [7]), the exact complexity of AMG coarsening is not supposed to be bigger than that of matching. 5 Conclusions We introduced a new coarsening scheme for multilevel graph partitioning based on the AMG coarsening. One of its most important components, namely, the algebraic distance connectivity measure, has been in- corporated into the matching coarsening schemes. Both coarsening schemes have been compared under fast and strong configurations of refinement. In addition to known benchmarks, we introduced new potentially hard graphs for large-scale graph partitioning solvers (available at [1]). As the main conclusion of this work, we emphasize the success of the proposed AMG coarsening and the algebraic distance connectivity mea- sure between nodes demonstrated on highly irregular instances. One has to take into account the trade-off between increased running time when using algebraic distance and improved quality of the partitions. The increasing running time becomes less tangible with growth of graph size compared with the complexity of the refinement phase. Many opportunities remain to improve the coarsening schemes for graph partitioning. We demonstrated the crucial importance of the connectivity strength metrics (especially for fast versions of the algorithm) which raises the question how one can use these metrics at the uncoarsening phase. Preliminary experiments show that this has the potential to improve fast versions even more. Another issue that requires more insight is related to the balancing of AMG aggregates. We observed a number of examples for which the unbalanced coarsening produces noticeably better results. 13 0.91.21.51.82.12.42.733.33.6ratios ECO/ECO-ALG00.511.52ratios time(ECO)/time(ECO-ALG)0.80.911.11.21.31.41.5ratios ECO-ALG/STRONG00.250.50.751ratios time(ECO-ALG)/time(STRONG) References In 19th 1. David A. Bader, Henning Meyerhenke, Peter Sanders, and Dorothea Wagner. 10th DIMACS Implementation Challenge - Graph Partitioning and Graph Clustering. http://www.cc.gatech.edu/dimacs10/. 2. Gereon Bartel, Carsten Gutwenger, Karsten Klein, and Petra Mutzel. An experimental evaluation of multilevel layout methods. In Ulrik Brandes and Sabine Cornelsen, editors, Graph Drawing, volume 6502 of Lecture Notes in Computer Science, pages 80–91. Springer, 2010. 3. A. Brandt. Multiscale scientific computation: Review 2001. In T. Barth, R. Haimes, and T. Chan, editors, Multiscale and Multiresolution methods (Proceeding of the Yosemite Educational Symposium, October 2000). Springer-Verlag, 2001. 4. T. N. Bui and B. R. Moon. Genetic algorithm and graph partitioning. IEEE Trans. Comput., 45(7):841–855, 1996. 5. Thang Nguyen Bui and Curt Jones. Finding good approximate vertex and edge partitions is NP-hard. Inf. Process. Lett., 42(3):153–159, 1992. 6. Jie Chen and Ilya Safro. Algebraic distance on graphs. SIAM Journal on Scientific Computing, 33(6):3468–3490, 2011. 7. C´edric Chevalier and Ilya Safro. Comparison of coarsening schemes for multilevel graph partitioning. In Thomas Stutzle, editor, LION, volume 5851 of Lecture Notes in Computer Science, pages 191–205. Springer, 2009. 8. Inderjit Dhillon. A fast kernel-based multilevel algorithm for graph clustering. In In Proceedings of the 11th ACM SIGKDD International Conference on Know ledge Discovery and Data Mining, pages 629–634, 2005. 9. D. Drake and S. Hougardy. A simple approximation algorithm for the weighted matching problem. Information Processing Letters, 85:211–213, 2003. 10. C. M. Fiduccia and R. M. Mattheyses. A Linear-Time Heuristic for Improving Network Partitions. Conference on Design Automation, pages 175–181, 1982. 11. P.O. Fjallstrom. Algorithms for graph partitioning: A survey. Linkoping Electronic Articles in Computer and Information Science, 3(10), 1998. 12. M. Holtgrewe, P. Sanders, and C. Schulz. Engineering a Scalable High Quality Graph Partitioner. 24th IEEE International Paral lal and Distributed Processing Symposium, 2010. 13. Y. F. Hu and J. A. Scott. A multilevel algorithm for wavefront reduction. SIAM J. Sci. Comput., 23:1352–1375, April 2001. 14. George Karypis and Vipin Kumar. Analysis of multilevel graph partitioning. In SC, 1995. 15. J. Lescovec. Stanford Network Analysis Package (SNAP). http://snap.stanford.edu/index.html. 16. J. Maue and P. Sanders. Engineering algorithms for approximate weighted matching. In 6th Workshop on Exp. Algorithms (WEA), volume 4525 of LNCS, pages 242–255. Springer, 2007. 17. H. Meyerhenke, B. Monien, and T. Sauerwald. A new diffusion-based multilevel algorithm for computing graph partitions of very high quality. In IEEE International Symposium on Paral lel and Distributed Processing, 2008. IPDPS 2008., pages 1–13, 2008. 18. F. Pellegrini. Scotch home page. http://www.labri.fr/pelegrin/scotch. 19. A. Pothen, H. D. Simon, and K.-P. Liou. Partitioning sparse matrices with eigenvectors of graphs. SIAM J. Matrix Anal. Appl., 11(3):430–452, 1990. 20. D. Ron, S. Wishko-Stern, and A. Brandt. An algebraic multigrid based algorithm for bisectioning general graphs. Technical Report MCS05-01, Department of Computer Science and Applied Mathematics, The Weizmann Institute of Science, 2005. 21. Dorit Ron, Ilya Safro, and Achi Brandt. Relaxation-based coarsening and multiscale graph organization. Multi- scale Modeling & Simulation, 9(1):407–423, 2011. 22. I. Safro, D. Ron, and A. Brandt. Multilevel algorithms for linear ordering problems. Journal of Experimental Algorithmics, 13:1.4–1.20, 2008. 23. I. Safro, P. Sanders, and C. Schulz. Benchmark with Potentially Hard Graphs for Partitioning Problem. http: //www.mcs.anl.gov/~safro/hardpart.html. 24. P. Sanders and C. Schulz. Distributed Evolutionary Graph Partitioning. 12th Workshop on Algorithm Engineering and Experimentation, 2011. 25. P. Sanders and C. Schulz. Engineering Multilevel Graph Partitioning Algorithms. 19th European Symposium on Algorithms, 2011. 26. K. Schloegel, G. Karypis, and V. Kumar. Graph partitioning for high performance scientific simulations. J. Dongarra and et al., editors, CRPC Par. Comp. Handbook. Morgan Kaufmann, 2000. 27. E. Sharon, A. Brandt, and R. Basri. Fast multiscale image segmentation. In Proceedings IEEE Conference on Computer Vision and Pattern Recognition, pages 70–77, 2000. In 14 28. A.J. Soper, C. Walshaw, and M. Cross. A combined evolutionary search and multilevel optimisation approach to graph-partitioning. Journal of Global Optimization, 29(2):225–241, 2004. 29. L.E. Stock. Strategic Logistics Management. Cram101 Textbook Outlines. Lightning Source Inc, 2006. 30. Lei Tang, Huan Liu, Jianping Zhang, and Zohreh Nazeri. Community evolution in dynamic multi-mode networks. In KDD, pages 677–685, 2008. 31. Ulrich Trottenberg and Anton Schuller. Multigrid. Academic Press, Inc., Orlando, FL, USA, 2001. 32. C. Walshaw. Multilevel refinement for combinatorial optimisation problems. Annals of Operations Research, 131(1):325–372, 2004. 33. C. Walshaw and M. Cross. JOSTLE: Parallel Multilevel Graph-Partitioning Software – An Overview. In F. Magoules, editor, Mesh Partitioning Techniques and Domain Decomposition Techniques, pages 27–58. Civil- Comp Ltd., 2007. (Invited chapter). The submitted manuscript has been created in part by UChicago Argonne, LLC, Operator of Argonne National Laboratory (“Argonne”). Ar- gonne, a U.S. Department of Energy Office of Sci- ence laboratory, is operated under Contract No. DE-AC02-06CH11357. The U.S. Government re- tains for itself, and others acting on its behalf, a paid-up nonexclusive, irrevocable worldwide li- cense in said article to reproduce, prepare deriva- tive works, distribute copies to the public, and per- form publicly and display publicly, by or on behalf of the Government. 15
1101.4446
1
1101
2011-01-24T05:35:05
High-Confidence Predictions under Adversarial Uncertainty
[ "cs.DS" ]
We study the setting in which the bits of an unknown infinite binary sequence x are revealed sequentially to an observer. We show that very limited assumptions about x allow one to make successful predictions about unseen bits of x. First, we study the problem of successfully predicting a single 0 from among the bits of x. In our model we have only one chance to make a prediction, but may do so at a time of our choosing. We describe and motivate this as the problem of a frog who wants to cross a road safely. Letting N_t denote the number of 1s among the first t bits of x, we say that x is "eps-weakly sparse" if lim inf (N_t/t) <= eps. Our main result is a randomized algorithm that, given any eps-weakly sparse sequence x, predicts a 0 of x with success probability as close as desired to 1 - \eps. Thus we can perform this task with essentially the same success probability as under the much stronger assumption that each bit of x takes the value 1 independently with probability eps. We apply this result to show how to successfully predict a bit (0 or 1) under a broad class of possible assumptions on the sequence x. The assumptions are stated in terms of the behavior of a finite automaton M reading the bits of x. We also propose and solve a variant of the well-studied "ignorant forecasting" problem. For every eps > 0, we give a randomized forecasting algorithm S_eps that, given sequential access to a binary sequence x, makes a prediction of the form: "A p fraction of the next N bits will be 1s." (The algorithm gets to choose p, N, and the time of the prediction.) For any fixed sequence x, the forecast fraction p is accurate to within +-eps with probability 1 - eps.
cs.DS
cs
High-Confidence Predictions under Adversarial Uncertainty Andrew Drucker∗ Abstract We study the setting in which the bits of an unknown infinite binary sequence x are revealed se- quentially to an observer. We show that very limited assumptions about x allow one to make successful predictions about unseen bits of x. First, we study the problem of successfully predicting a single 0 from among the bits of x. In our model we have only one chance to make a prediction, but may do so at a time of our choosing. We describe and motivate this as the problem of a frog who wants to cross a road safely. Letting Nt denote the number of 1s among the first t bits of x, we say that x is "ε-weakly sparse" if lim inf(Nt/t) ≤ ε. Our main result is a randomized algorithm that, given any ε-weakly sparse sequence x, predicts a 0 of x with success probability as close as desired to 1 − ε. Thus we can perform this task with essentially the same success probability as under the much stronger assumption that each bit of x takes the value 1 independently with probability ε. We apply this result to show how to successfully predict a bit (0 or 1) under a broad class of possible assumptions on the sequence x. The assumptions are stated in terms of the behavior of a finite automaton M reading the bits of x. We also propose and solve a variant of the well-studied "ignorant forecasting" problem. For every ε > 0, we give a randomized forecasting algorithm Sε that, given sequential access to a binary sequence x, makes a prediction of the form: "A p fraction of the next N bits will be 1s." (The algorithm gets to choose p, N , and the time of the prediction.) For any fixed sequence x, the forecast fraction p is accurate to within ±ε with probability 1 − ε. 1 Introduction 1.1 The frog crossing problem A frog wants to cross the road at some fixed location, to get to a nice pond. But she is concerned about cars. It takes her a minute to cross the road, and if a car passes during that time, she will be squashed. However, this is no ordinary frog. She is extremely patient, and happy to wait any finite number of steps to cross the road. What's more, she can observe and remember how many cars have passed, as well as when they passed. She can follow any algorithm to determine when to cross the road based on what she has seen so far, although her senses aren't keen enough to detect a car before it arrives. Think of a "car-stream" as defined by an infinite sequence of 0s and 1s describing the minutes when a car passes (we model time as discrete, and assume that at most one car passes each minute). We ask, under what assumptions on the car-stream can our frog cross the road safely? Obviously, if there is constant, bumper- to-bumper traffic -- the car-stream described by the sequence (1, 1, 1, . . .) -- then she cannot succeed, so we must make some assumption. ∗MIT, EECS Dept., Cambridge, MA, USA. Email: [email protected]. Supported by a DARPA YFA grant. 1 One natural approach to this kind of situation is to assume traffic is generated according to some prob- abilistic model. For example, we might assume that during each minute, a car arrives with probability .1, and that these events are independent. More complicated assumptions (involving dependence between the car arrival-times, for example) can also be considered. However, the frog may not have a detailed idea of how the cars are generated. It may be that the frog merely knows or conjectures some constraint obeyed by the car-stream. We then ask whether there exists a strategy which gets the frog safely across the road (at least, with sufficiently high probability), for any car-stream obeying the constraint. This model will be our focus in the present paper. For example, suppose the cars appear to arrive more-or-less independently with probability .1 at each minute. The frog may be unsure that the independence assumption is fully justified, so she may make the weaker assumption that the limiting car-density is at most .1. Note that this condition holds with probability 1 if the cars really are generated by independent .1-biased trials, so this constraint can be considered a natural relaxation of the original probabilistic model. The frog may then ask whether there exists a strategy that gets her across the road safely with probability nearly .9 under this relaxed assumption. (Happily, the answer is Yes; this will follow from our main result.) 1.2 Relation to previous work Our work studies prediction under adversarial uncertainty. In such problems, an observer tries to make predictions about successive states of nature, without assuming that these states are governed by some known probability distribution. Instead, nature is regarded as an adversary who makes choices in an attempt to thwart the observer's prediction strategy. The focus is on understanding what kinds of predictions can be made under very limited assumptions about the behavior of nature. Adversarial prediction is a broad topic, but two strands of research are particularly related to our work. The first strand is the study of gales and their relatives. Gales are a class of betting systems generalizing martingales; their study is fundamental for the theory of effective dimension in theoretical computer science (see [Hem05] for a survey). The basic idea is as follows. An infinite sequence x is chosen from some known subset A of the space {0, 1}ω of infinite binary sequences. A gambler is invited to gamble on predicting the bits of x as they are sequentially revealed; the gambler has a finite initial fortune and cannot go into debt. The basic question is, for which subsets A can the gambler be guaranteed long-term success in gambling, for any choice of x ∈ A? This question can be studied under different meanings of "success" for the gambler, and under more- or less-favorable classes of bets offered by the casino. Intuitively, the difficulty of gambling successfully on an unknown x ∈ A is a measure of the "largeness" of the set A. In fact, this perspective was shown to yield new characterizations of two important measures of fractal dimensionality. Lutz [Lut03a] gave a characterization of the Hausdorff dimension of subsets of {0, 1}ω in terms of gales, while Athreya, Hitchcock, Lutz, and Mayordomo [AHLM07] showed a gale characterization of the packing dimension. These works also investigated gales with a requirement that the gambler follows a computationally bounded betting strategy; using such gales, the authors explored new notions of "effective dimension" for complexity classes in computational complexity theory.1 The second strand of related work is the so-called forecasting problem in decision theory (see [Daw82] for an early, influential discussion). In this problem, an infinite binary sequence x ∈ {0, 1}ω is once again 1Computationally bounded betting and prediction schemes have also been used to study individual sequences x, rather than sets of sequences. This approach has been followed using various resource bounds and measures of predictive success; see, e.g., [MF98, Lut03b]. 2 revealed sequentially; we typically think of the t-th bit as indicating whether it rained on the t-th day at some location of interest. Each day a weather forecaster is asked to give, not an absolute prediction of whether it will rain tomorrow, but instead some estimate of the probability of rain tomorrow. In order to keep his job as the local weather reporter, the forecaster is expected to make forecasts which have the property of being calibrated: roughly speaking, this means that if we consider all the days for which the forecaster predicted some probability p of rain, about a p fraction turn out rainy (see [FV98] for more precise definitions). In the adversarial setting, a forecaster must make such forecasts without knowledge of the probability distribution governing nature. In the well-studied "ignorant forecaster" model, the forecaster is allowed no assumptions whatsoever about the sequence x. Nevertheless, it is a remarkable fact, shown by Foster and Vohra [FV98], that there exists a randomized ignorant forecasting scheme whose forecasts are calibrated in the limit. This result was extended by Sandroni [San03]. The calibration criterion is just one of many conceivable "tests" with which we might judge a forecaster's knowledge on the basis of his forecasts and the observed outcomes. Foster and Vohra's result showed that the calibration test can be passed even by an ignorant forecaster; but conceivably some other test of knowledge could be more meaningful. A reasonable class of tests to consider are those that can be passed with some high probability 1 − ε by a forecaster who knows the actual distribution D governing nature, for any possible setting of D. However, Sandroni showed that any such test can also be passed with probability 1 − ε by an ignorant forecaster! Fortnow and Vohra [FV09] give evidence that the ignorant strategies provided by Sandroni's result cannot in general be computed in polynomial time, even if the test is polynomial-time computable.2 In both of the strands of research described above, researchers have typically looked for prediction schemes that have some desirable long-term, aggregate property. In the gale setting, the focus is on betting strategies that may lose money on certain bets, but that succeed in the limit; in the forecasting problem, an ignorant forecaster wants his forecasts to appear competent overall, but is not required to give definite predictions of whether or not it will rain on any given day. By contrast, in our frog problem, the frog wants to cross the road just once, and her life depends on the outcome. Our focus is on making a single prediction, with success probability as close to 1 as possible. In a later section of the paper we will also study a variant of the ignorant forecasting scenario. Follow- ing [FV98, San03], we will make no assumption about the observation sequence x. Our goal will be to make a single forecast at a time of our choosing, of the following form: "A p fraction of the next N observations will take the value 1." We will seek to maximize the accuracy of our prediction, as well as the likelihood of falling within the desired accuracy. This forecasting variant is conceptually linked to our frog problem by its focus on making a single prediction with high confidence. 1.3 Our results on the frog crossing problem We now return to our patient frog. To appreciate the kinds of frog-strategies that are possible, we first consider a simple but instructive example. Suppose the frog knows that at most one car will ever drive by. In this case, the frog might choose to wait until she sees a car pass; however, this strategy makes her wait forever if no car ever arrives, and we consider this a failure. Similarly, suppose the frog follows a deterministic strategy which, for some t ≥ 1, makes her cross on the t-th minute if she has not yet seen a car. Then the frog is squashed on the car-stream 2The tests considered in [San03, FV09] are required to halt with an answer in finite time. See [FV09] for references to work in which this restriction is relaxed. 3 consisting of a single car passing at the t-th minute. Thus, any deterministic strategy fails against some car-stream obeying our constraint. What is left for the frog? We recommend following a randomized strategy. Fixing some δ > 0, consider the following strategy: the frog chooses a value t⋆ ∈ {1, 2, . . . , ⌈1/δ⌉} uniformly at random, and crosses at time t⋆. Let's analyze this algorithm. Fix any car-stream consisting of at most one car, say arriving at time t ≥ 1 (where t := ∞ if no car arrives). Then the strategy above fails only if t⋆ = t, which occurs with probability at most ⌈1/δ⌉−1 ≤ δ. Note that this error probability is over the randomness in the algorithm, not the car-stream; we regard the car-stream as chosen by an adversary who knows the frog's strategy, but not the outcomes of the frog's random decisions. We are interested in strategies which succeed with high probability against any choice by the adversary (obeying the assumed constraint). An easy modification of the above algorithm lets the frog succeed with probability 1 − δ against a car- stream promised to contain at most M cars, for any fixed M < ∞. However, it may come as a surprise that we can succeed given a much weaker assumption. The reader is invited to try the following puzzle: Puzzle 1. For any δ > 0, give a frog-strategy that succeeds with probability 1 − δ, under the assumption that the number of cars is finite. The assumption can be weakened further. Fixing a car-stream, let Nt denote the number of cars appear- ing in the first t minutes. Say that the car-stream is sparse if Nt = o(t), that is, if lim t→∞ Nt/t = 0. Puzzle 2. Give a frog-strategy that succeeds with probability 1−δ, under the assumption that the car-stream is sparse. Note that in Puzzle 2, the frog is promised that the fraction Nt/t approaches 0 as t → ∞, but she has no idea how quickly it will do so. Say the car-stream is weakly sparse if Nt /∈ Ω(t), that is, if s→∞(cid:18)inf lim t≥s Nt/t(cid:19) = 0. Puzzle 3. Give a frog-strategy that succeeds with probability 1−δ, under the assumption that the car-stream is weakly sparse. In this paper we provide a solution to Puzzle 3. This immediately implies a solution for Puzzles 1 and 2, but these first two puzzles also have simpler solutions, which we encourage the reader to find. The basic idea of our solution to Puzzle 3 is easy to state: roughly speaking, seeing fewer cars increases the frog's "courage" and makes her more likely to decide to cross. Correctly implementing and analyzing this idea turns out to be a delicate task, however. We actually prove a quantitative strengthening of Puzzle 3. For any ε > 0, say that a car-stream is ε-weakly sparse if s→∞(cid:18)inf lim t≥s Nt/t(cid:19) ≤ ε. Our main result is that, under the assumption that the car-stream is ε-weakly sparse, the frog can cross successfully with probability as close as desired to 1 − ε. We state our result formally in Section 2 after setting up the necessary definitions. 4 Our result bears some resemblance to known results in dimension theory. Let Aε−ws ⊆ {0, 1}ω denote the set of ε-weakly sparse infinite binary sequences. Eggleston [Egg49, Bil65] showed that for ε ≤ 1/2, the Hausdorff dimension of Aε−ws is equal to the binary entropy H(ε). More recently, Lutz [Lut03a] gave an alternative proof using his gale characterization of Hausdorff dimension (Lutz also calculated the "effective dimension" of Aε−ws according to several definitions). Lutz upper-bounds the Hausdorff dimension of Aε−ws by giving a gale betting strategy that "succeeds" (in the appropriate sense) against all x ∈ Aε−ws. This betting strategy, which is simple and elegant, does not appear to be applicable to our puzzles. Indeed, a major difference between our work and the study of gales is that gale betting strategies are deterministic (at least under standard definitions [Lut03a, AHLM07]), whereas randomization plays a crucial role in our frog-strategies. 1.4 Further results In Section 4, we prove an extension of the result of Puzzle 3, in a a modified setting in which we are allowed to predict either a 0 or a 1. We give a condition on the binary sequence x that is significantly more general than weak sparsity, and that still allows a bit to be predicted with high confidence. The condition is stated in terms of a finite automaton M that reads x: we assume that x causes M to enter a designated set of "bad" states B only infrequently. A certain "strong accessibility" assumption on the states B is needed for our result. In Section 5, we study a problem closely related to the "ignorant forecasting" problem discussed earlier, where (as in the frog problem) a single prediction is to be made. In the "density prediction game," an arbitrary infinite binary sequence is chosen by Nature, and its bits are revealed to us sequentially. Our goal is to make a single forecast of the form "A p fraction of the next N bits will be 1s." We are allowed to choose p, N, and the time at which we make our forecast. Fixing a binary sequence x, we say that a forecast described by (p, N ), and made after viewing xt, is ε-successful on x if the fraction of 1s among xt+1, . . . , xt+N is in the range (p − ε, p + ε). For δ, ε > 0, we say that a (randomized) forecasting strategy S is (δ, ε)-successful if for every x ∈ {0, 1}ω, Pr[S is ε-successful on x] ≥ 1 − δ. In Section 5, we show the following, perhaps surprising, result: Theorem 1. For any δ, ε > 0, there exists a (δ, ε)-successful forecasting strategy. 2 Preliminaries and the Main Theorem First we develop a formal basis to state and prove our main result. N = {1, 2, . . .} denotes the positive whole numbers. For N ∈ N, [N ] denotes the set {1, 2, . . . , N }. {0, 1}ω denotes the set of all infinite bit-sequences b = (b1, b2, . . .). We will freely refer to any such sequence as a "car-stream," where bi = 1 means "a car appears during the i-th minute." A frog-strategy (or simply strategy) is a collection S = {πS,b : b ∈ {0, 1}ω}, 5 where each πS,b is a probability distribution over N ∪ {∞}. We require that for all b = (b1, b2, . . .), b′ = (b′ 2, . . .), and all i ∈ N, 1, b′ (b1, . . . , bi−1) = (b′ 1, . . . , b′ i−1) ⇒ πS,b(i) = πS,b′(i). (1) That is, πS,b(i) depends only on b1, . . . , bi−1. Let us interpret the above definition. A frog-strategy defines, for each car-stream b and each i ∈ N, a probability πS,b(i) that, when facing the car-stream b, the frog will attempt to cross at step i. There is also some probability πS,b(∞) that the frog will wait forever without crossing. Whether it lives or dies, the frog only attempts to cross at most once, so these probabilities sum to 1. Eq. (1) requires that the frog's decision for the i-th minute depends only upon what it has seen of the car-stream during the first (i − 1) minutes. The frog-strategies we analyze in this paper will be defined in such a way that Eq. (1) obviously holds. Given a frog-strategy S, define the success probability Suc(S, b) := Xi∈N:bi=0 πS,b(i) as the probability that, facing b, the frog crosses successfully during some minute when there is no car. Similarly, define the death probability DP(S, b) := Xi∈N:bi=1 πS,b(i) = 1 − Suc(S, b) − πS,b(∞) as the probability that the strategy S leads to the frog being squashed by a car on car-stream b. For a subset A ⊆ {0, 1}ω, define Let Nt = Nt(b) := b1 + . . . + bt. A car-stream b is called ε-weakly sparse if Suc(S, A) := inf b∈A Suc(S, b). s→∞(cid:18)inf lim t≥s Nt/t(cid:19) ≤ ε. We can now formally state our main result: Theorem 2. Fix ε ∈ (0, 1) and let Aε−ws := {b : b is ε−weakly sparse}. Then for all γ > 0, there exists a strategy Sε,γ such that Suc(Sε,γ, Aε−ws) > 1 − ε − γ. Furthermore, Sε,γ has the following "safety" property: for any car-stream b ∈ {0, 1}ω, the death probability DP(S, b) is at most ε + γ. Note that b is weakly sparse (as defined in Section 1.3) exactly if it is ε-weakly sparse for all ε > 0. Thus if Aws := {b : b is weakly sparse}, then by Theorem 2, we can succeed on Aws with probability as close to 1 as we desire. This solves Puzzle 3. It is not hard to see that Theorem 2 is optimal for frog-strategies against Aε−ws. For consider a randomly generated car-stream bbb where the events [bbbi = 1] occur independently, with E[bbbi] = min{1, ε + 2−i}. Then [limt→∞ Nt(bbb)/t = ε] occurs with probability 1. On the other hand, any frog-strategy S has success probability less than 1 − ε against bbb. Thus, for any S we can find a particular car-stream b for which limt→∞ Nt(b)/t = ε and which causes S to succeed with probability less than 1 − ε. 6 3 Proof of the the Main Theorem In this section we prove Theorem 2. First we observe that, if we can construct a strategy S such that Suc(S, Aε−ws) > 1 − ε − γ, then the "safety" property claimed for S in the theorem statement will follow immediately. For suppose to the contrary that some car-stream b ∈ {0, 1}ω satisfies DP(S, b) > ε + γ. Then there exists m ∈ N such thatPi≤m:bi=1 πS,b(i) > ε + γ. If we define b′ ∈ {0, 1}ω by b′ i := (cid:26) bi 0 if i ≤ m, if i > m, then b′ ∈ Aε−ws and DP(S, b′) > ε + γ, contradicting our assumption on S. To construct the strategy S, we use a family of frog-strategies for attempting to cross the road within a finite, bounded interval of time. The following lemma is our key tool, and is interesting in its own right. Lemma 1. For any δ ∈ (0, 1) and integer K > 1, there exists a strategy T = TK,δ such that for all b ∈ {0, 1}ω: (i) The crossing time of T is always in [K] ∪ {∞}. That is, for K < i < ∞, we have πT ,b(i) = 0; (ii) If (b1 + . . . + bK−1)/(K − 1) ≤ δ′ < δ, then πT ,b(∞) ≤ 1 − Ω((δ − δ′)2/δ); (iii) The death probability satisfies DP(T , b) ≤ δ 1 − δ Suc(T , b) + O(cid:18) δ (1 − δ)K(cid:19) . We defer the proof of Lemma 1, and use it to prove Theorem 2. Proof of Theorem 2. Fix settings of ε, γ > 0; we may assume ε + γ < 1, or there is nothing to prove. Let ε1 := ε + γ/3, ε2 := ε + 2γ/3. We also use a large integer K > 1, to be specified later. Divide N into a sequence of intervals I1 = {1, 2, . . . , K}, I2 = {K + 1, . . . , 5K}, and so on, where Ir has length r2K. Let S = Sε,γ be the frog-strategy which does the following: first, follow the strategy TK,ε2 (as given by Lemma 1) during the time interval I1. If no crossing is attempted during these steps, then run the strategy T4K,ε2 on the interval I2, after shifting the indices of I2 appropriately (so that T4K,ε2 considers its input sequence to begin on bK+1). Similarly, for each r > 0, if we reach the interval Ir without an attempted crossing, we execute the strategy Tr2K,ε2 on the interval Ir, after shifting indices appropriately. We will show that if K is sufficiently large, we have Suc(S, Aε−ws) > 1 − ε − γ as required. Fix any b = (b1, b2, . . .) ∈ Aε−ws. Let αr := (cid:0)Pi∈Ir Claim 1. For infinitely many r, αr ≤ ε1. bi(cid:1) /Ir be the fraction of 1-entries in b during interval Ir. Proof. Suppose to the contrary that αr > ε1 when r ≥ R. Consider an interval {1, 2, . . . , M } large enough to properly contain I1, I2, . . . , IR. Let t ≥ R be such that It ⊆ [M ] but that It+1 * [M ]. Let α⋆ be the fraction of 1-entries in [M ] ∩ It+1; we set α⋆ := 0 if [M ] ∩ It+1 = ∅. With NM = (b1 + . . . + bM ), we have the expression NM M = Xr≤t Ir M · αr + [M ] ∩ It+1 M · α⋆ 7 giving the car-density (fraction of 1s) of b in [M ] as a weighted average of the car-densities in I1, . . . , It and in [M ] ∩ It+1. Note that [M ] ∩ It+1 It+1 M ≤ M ≤ (t + 1)2K Pr≤t r2K = O(1/t) → 0, as M → ∞. Now αr > ε1 when r ≥ R, so for sufficiently large M we have NM /M ≥ (ε1 + ε)/2 > ε. But this contradicts the fact that b ∈ Aε−ws, proving the Claim. Fix r > 0. If Ir = {j, . . . , k} and αr = (bj + . . . + bk)/(k − j + 1) ≤ ε1, then we also have (bj + . . . + bk−1)/(k − j) < ε + γ/2 if r is large enough. For any such r, condition (ii) of Lemma 1 tells us that if our frog-strategy reaches the interval Ir, it will attempt to cross during Ir with probability Ω((γ/6)2/ε2). There are infinitely many such r, by Claim 1. Thus, the frog-strategy eventually attempts to cross with probability 1. It follows that DP(S, b) = 1 − Suc(S, b). For r > 0, let Pr = Pr(b) be defined as the probability that S reaches Ir without attempting to cross earlier. Let b[Ir] denote the sequence b, shifted to begin at the first bit of Ir. Then we can reexpress the death probability of S on b, and bound this quantity, as follows: DP(S, b) = Xr≥1 ≤ Xr≥1 Pr · DP(Tr2K,ε2, b[Ir]) Pr ·(cid:18) ε2 1 − ε2 Suc(Tr2K,ε2, b[Ir]) + O(cid:18) ε2 (1 − ε2)r2K(cid:19)(cid:19) (by condition (iii) of Lemma 1) = ε2 1 − ε2  Xr≥1 Pr · Suc(Tr2K,ε2, b[Ir]) (using the fact thatXr>0 r−2 < ∞) = ε2 1 − ε2 Suc(S, b) + O(cid:18) ε2 (1 − ε2)K(cid:19) .  + O(cid:18) ε2 (1 − ε2)K(cid:19) Thus, DP(S, b) = 1 − Suc(S, b) ≤ ε2 1−ε2 Suc(S, b) ≥ 1 − ε2 − O(cid:18) ε2 (1−ε2)K(cid:17), which implies Suc(S, b) + O(cid:16) (1 − ε2)K(cid:19) = 1 − (ε + 2γ/3) − O(cid:18) ε2 ε2 (1 − ε2)K(cid:19) . By setting K ≫ ε2γ−1(1 − ε2)−1 sufficiently large, we can conclude Suc(S, b) > 1 − ε − γ, where the slack in the inequality is independent of the choice of b ∈ Aε−ws. This proves Theorem 2. Proof of Lemma 1. By an easy approximation argument, it suffices to prove the result for the case when δ is rational. So assume for some integers 0 < p < d, and let δ = p/d, q := d − p. 8 The frog-strategy T is as follows. First, pick a value t⋆ ∈ [K] uniformly at random. Do not attempt to cross on steps 1, 2, . . . , t⋆ − 1. During this time, maintain an ordered stack of "chips," initially empty. For 1 ≤ i < t⋆, after viewing bi, if bi = 0 then add p chips to the top of the stack; if bi = 1 then remove q chips from the top of the stack -- or, if the stack contains fewer than q chips, remove all the chips. After this modification to the stack, we say that the bit bi has been "processed". For 0 ≤ i ≤ K − 1, let Hi denote the number of chips on the stack after processing b1, . . . , bi (so, H0 = 0). After processing bt⋆−1, sample from a 0/1-valued random variable X, with expectation E[X] := Ht⋆−1 dK . (Note that this expectation is at most p(K−1) t⋆ if X = 1, otherwise make no crossing attempt at any step. dK < 1, so the definition makes sense.) Attempt to cross at step Note that the variable Ht can be regarded as a measure of the frog's "courage" after processing b1, . . . , bt, as in our sketch-description in Section 1.3. We now verify that T has the desired properties. Condition (i) in Lemma 1 is clearly satisfied. Before verifying conditions (ii) and (iii), we first sketch why they hold. For (ii), the idea is that if much less than a δ fraction of b1, . . . , bK−1 are 1s, then the stack of chips will be of significant height after processing these bits. Since the stack doesn't grow too quickly, we conclude that the average stack height during these steps is significant, which implies that the frog attempts to cross with noticeable probability. For (iii), the idea is that for any chip c, if c stays on the stack for a significant amount of time, then the fraction of 1s appearing during the interval in which c was on the stack must be not much more than δ. Thus c's contribution to the death probability is not much more than δ/(1 − δ) times c's contribution to the success probability. On the other hand, chips c which don't stay on the stack very long make only a small contribution to the death probability. Now we formally verify condition (ii). Fix some sequence b. First note that the placement and removal of chips, and the height sequence H0, . . . , HK−1, can be defined in terms of b alone, without reference to the algorithm's random choices. Throughout our analysis we consider the stack to continue to evolve as a function of the bits b1, . . . , bK−1, regardless of the algorithm's choices. Suppose b1 + . . . + bK−1 ≤ δ′(K − 1), where δ′ < δ; we ask, how large can πT ,b(∞) be? From the definition of T , we compute πT ,b(∞) = 1 − 1 K Xt∈[K] Ht−1 dK = 1 − 1 dK 2 X0≤t<K Ht. (2) Now, for a chip c, let mc ∈ N denote the number of indices i < K for which c was on the stack immediately after processing bi. (We consider each chip to be "unique;" that is, it is added to the stack at most once.) We can reexpress the sum appearing in Eq. (2) as X0≤t<K Ht = Xc mc. We will lower-bound this sum by considering the contribution made by chips that are never removed from the stack -- that is, chips which remain after processing bK−1. We call such chips "persistent." First, we argue that there are many persistent chips. By our assumption, at least p · (1 − δ′)(K − 1) chips are added 9 to the stack in total, while at most q · δ′(K − 1) chips are ever removed. Thus the number of persistent chips is at least p(1 − δ′)(K − 1) − qδ′(K − 1) = p(1 − δ + (δ − δ′))(K − 1) − q(δ + (δ′ − δ))(K − 1) = [p(1 − δ) − qδ + (p + q) (δ − δ′)](K − 1) = (δ − δ′)d(K − 1), } {z }=d =0 {z where we used p/q = δ/(1 − δ). Let J := (δ − δ′)d(K − 1). Pick any J persistent chips, and number them c(1), . . . , c(J) so that j′ < j ≤ J implies c(j′) appears above c(j) on the stack after processing bK−1. This means c(j′) was added to the stack no earlier than c(j), so that mc(j ′) ≤ mc(j). At most p chips are added for every processed bit of b, and if c(j) was added while processing the (K − i)-th bit, then mc(j) = i. Thus, by our indexing we conclude mc(j) ≥ ⌈j/p⌉ ≥ j/p. Summing over j, we obtain Xpersistent c mc ≥ J Xj=1 j/p = > = J(J + 1) 2p (δ − δ′)2d2(K − 1)2 2p (δ − δ′)2d(K − 1)2 2δ . Finally, returning to Eq. (2), we compute πT ,b(∞) = 1 − 1 dK 2 Xc mc < 1 − 1 dK 2 · (δ − δ′)2d(K − 1)2 2δ < 1 − (δ − δ′)2 8δ , since K > 1. This establishes condition (ii). Now we verify condition (iii). Fix any car-stream b. From our definitions, we have the expressions Suc(S, b) = 1 K Xt∈[K]:bt=0 Ht−1 dK , DP(S, b) = 1 K Xt∈[K]:bt=1 Ht−1 dK , and so DP(S, b) − (p/q) Suc(S, b) = (3) We regard the quantity Ht−1 as being composed of a contribution of 1 from each of the chips on the stack after processing bt−1. We rewrite the right-hand side of Eq. (3) as a sum of the total contributions from each chip. For a chip c, and for z ∈ {0, 1}, let 1 dK 2   Xt∈[K]:bt=1 Ht−1 − Xt∈[K]:bt=0 (p/q)Ht−1  . nc,z := {t ∈ [K] : bt = z, and c is on the stack immediately after processing bt−1} . 10 We then have DP(S, b) − (p/q) Suc(S, b) = 1 dK 2 Xc (nc,1 − (p/q)nc,0). (4) Fix attention to some chip c, which was placed on the stack while processing the ic-th bit, for some ic ∈ [K − 1]. First assume that c was later removed from the stack, and let jc ∈ [K − 1] be the index of the bit whose processing caused c to be removed (thus, bjc = 1). Then the stack was not empty after processing bits ic, . . . , jc − 1, since in particular, the stack contained c. Thus each 1 appearing in (bic+1, . . . bjc−1) caused exactly q chips to be removed from the stack. The removal caused by [bjc = 1] removes some number rc ≤ q of chips. Also, each 0 appearing in the same range causes p chips to be added. Now nc,0, nc,1 count the number of 0s and 1s respectively among (bic+1, . . . , bjc). Thus we have Hjc − Hic = pnc,0 − q(nc,1 − 1) − rc ≤ pnc,0 − q(nc,1 − 1), or rearranging, (5) The chip c is added to the stack with p − 1 other bits while processing bit ic. Later, c is removed from the stack when processing bit jc, along with at most q − 1 other chips. Thus we have nc,1 − (p/q)nc,0 ≤ (Hic − Hjc)/q + 1. and combining this with Eq. (5) gives Hic − Hjc ≤ p + q − 1, nc,1 − (p/q)nc,0 ≤ (p + q − 1)/q + 1 < p/q + 2. (6) Next suppose c was added after processing bit ic ∈ [K − 1], but never removed from the stack. Then the stack was nonempty after processing bit ic and remained nonempty from then on, so each 1 in bic+1, . . . , bK−1 caused exactly q chips to be removed. By reasoning similar to the previous case, we get nc,1 − (p/q)nc,0 = (Hic − HK−1)/q. Now, c was added along with p − 1 other chips after processing bic, and c remains on the stack after processing bK−1. It follows that Hic − HK−1 ≤ p − 1, so nc,1 − (p/q)nc,0 ≤ (p − 1)/q. (7) Plugging Eqs. (6) and (7) into Eq. (4), we bound DP(S, b) − (p/q) Suc(S, b) < 1 dK 2 Xc (p/q + 2) < p2/q + 2p dK (since at most p(K − 1) chips are ever used) · q 1 1 = K (cid:18)p K (cid:18) δ = O(cid:18) = p d + 2p d (cid:19) · δ + 2δ(cid:19) 1 − δ δ (1 − δ)K(cid:19) . Since (p/q) = δ/(1 − δ), this establishes condition (iii), and completes the proof of Lemma 1. 11 4 More on Bit-Prediction After thinking hard about car-streams and getting across the road safely, our frog had developed a taste for prediction. In this section we present an extension of Puzzle 3 that is able to predict single bits from significantly more general classes of binary sequences. 4.1 Bit-prediction algorithms Our result concerns the setting in which an observer is asked to correctly predict a single bit of their choice from a sequence x. Unlike the frog crossing problem, in which the frog needed to correctly predict a 0, in this problem the algorithm is allowed to predict either a 0 or a 1. Thus we need to modify our definition of frog-strategies (in the obvious way), as follows. A bit-prediction strategy is a collection S = {πS,b : b ∈ {0, 1}ω}, where each πS,b is now a probability distribution over (N × {0, 1}) ∪ {∞}. We require that for all b = (b1, b2, . . .), b′ = (b′ 2, . . .), and all i ∈ N, z ∈ {0, 1}, 1, b′ (b1, . . . , bi−1) = (b′ 1, . . . , b′ i−1) ⇒ πS,b((i, z)) = πS,b′((i, z)). That is, πS,b((i, z)) depends only on b1, . . . , bi−1. As in the frog-crossing setting, our bit-prediction strate- gies will be defined so that this constraint clearly holds. Define the success probability Sucbit-pred(S, b) := Xi∈N πS,b((i, bi)) as the probability that S correctly predicts a bit of b. For a subset A ⊆ {0, 1}ω, define Sucbit-pred(S, A) := inf b∈A Sucbit-pred(S, b). 4.2 Finite automata To state our result, we need the familiar notion of a finite automaton over a binary alphabet. Formally, this is a 3-tuple M = (Q, s, ∆), where: • Q is a finite set of states; • s ∈ Q is the designated starting state; • ∆ : Q × {0, 1} → Q is the transition function. For q ∈ Q, B ⊆ Q, say that B is accessible from q if there exists a sequence y1, . . . , ym of bits and a sequence q0 = q, q1, . . . , qm of states, such that 1. ∆(qi, yi+1) = qi+1 for i = 0, 1, . . . , m − 1; 2. qm ∈ B. 12 Say that B is strongly accessible if, for any state q that is accessible from the starting state s, B is accessible from q. Finite automata operate on infinite sequences x ∈ {0, 1}ω as follows: we let q0(x) := s, and inductively for t ≥ 1 we define qt(x) := ∆(qt−1(x), xt). We say that qt(x) is the state of M after t steps on the sequence x. For a state q ∈ Q we define Vq(x), the visits to q on x, as Similarly, for B ⊆ Q, define VB(x) as VB(x) := {t ≥ 0 : qt(x) ∈ B}. Vq(x) := {t ≥ 0 : qt(x) = q}. 4.3 Statement of the result Say we are presented with the bits of some unknown x ∈ {0, 1}ω sequentially. We assume that x is "nice" in the following sense: for some known finite automaton M, there is a set B ⊆ Q of "bad" states of M, which we assume M visits only infrequently when M is run on x. We show that, if B is strongly accessible, we can successfully predict a bit of x with high probability. First recall the definition of weak sparsity from Section 1.3. We say that a subset S ⊆ {0, 1, 2, . . .} is weakly sparse if its characteristic sequence is weakly sparse. We prove: Theorem 3. Let M = (Q, s, ∆) be a finite automaton, and let B ⊆ Q be a strongly accessible set of states. Define AB,ws := {x ∈ {0, 1}ω : VB(x) is weakly sparse}. Then for all ε > 0, there exists a bit-prediction strategy S = Sε such that Sucbit-pred(S, AB,ws) > 1 − ε. We make a few remarks before proving Theorem 3. First, simple examples show that the conclusion of Theorem 3 can hold even in some cases where B is not strongly accessible. Finding necessary and sufficient conditions on B could be an interesting question for future study. Second, it is natural to ask whether a more "quantitative" version of Theorem 3 can be given. Let AB,ε−ws be the set of sequences x for which the characteristic sequence of VB(x) is ε-weakly sparse (as defined in Section 2). If B is strongly accessible then, by a slight modification of our proof of Theorem 3, one can derive a bit-prediction strategy S such that Sucbit-pred(S, AB,ε−ws) > 1 − O(cid:16)ℓε1/ℓ(cid:17) , where ℓ = Q is the number of states of the automaton M. Something like this weak form of dependence on ε is essentially necessary, as can be seen from the following example. Let M be an automaton with states Q = {1, 2, . . . , ℓ}, and define ∆(i, 1) := min{i + 1, ℓ}, ∆(i, 0) := 1. Let B := {ℓ}, and consider running M on a sequence bbb of independent unbiased bits. Then with probability 1, VB(bbb) is 2−ℓ+1-weakly sparse. On the other hand, no algorithm can predict a bit of bbb with success probability greater than 1/2. 13 4.4 Proof of Theorem 3 Let Aws ⊆ {0, 1}ω denote the set of weakly sparse sequences. Given a sequence x = (x1, x2, . . .), define ¬x := (¬x1, ¬x2, . . .). Say that x is co-weakly sparse, and write x ∈ Aco−ws, if ¬x ∈ Aws. To prove Theorem 3, we need two lemmas. The following lemma follows easily from Theorem 2: Lemma 2. Given δ > 0, there exists a bit-prediction strategy P = Pδ such that Sucbit-pred(P, Aws ∪ Aco−ws) > 1 − δ. P also has the "safety" property that for any x ∈ {0, 1}ω, the probability that P outputs an incorrect bit-prediction on x is at most δ. Proof. First, note that a frog-strategy (as defined in Section 2) can be regarded as a bit-prediction strategy that only ever predicts a 0. Let ε = γ := δ/4. The bit-prediction strategy P, given access to some sequence b, simulates the frog-strategy Sε,γ from Theorem 2 on b, and simultaneously simulates an independent copy of Sε,γ on ¬b. If Sε,γ(b) ever outputs a prediction (i.e., that the next bit of b will be 0), P immediately outputs the same prediction. On the other hand, if Sε,γ(¬b) ever outputs a prediction (that the next bit of ¬b will be 0), then P predicts that the next bit of b will be 1. If both simulations output predictions simultaneously, P makes an arbitrary prediction for the next bit. To analyze P, say we are given input sequence b ∈ Aws ∪ Aco−ws. First suppose b ∈ Aws. Then Sε,γ(b) outputs a correct prediction with probability > 1 − ε − γ. Also, by the safety property of Sε,γ shown in Theorem 2, the probability that Sε,γ(¬b) outputs an incorrect prediction about ¬b is at most ε + γ. Thus the probability that P outputs a correct prediction on b is greater than 1 − 2ε − 2γ = 1 − δ. The case where b ∈ Aco−ws is analyzed similarly. Finally, the safety property of P follows from the safety property of Sε,γ. For the next lemma, we need some further definitions. Fix a finite automaton M = (Q, s, ∆). For x ∈ {0, 1}ω, let Qinf(x) := {q ∈ Q : Vq(x) = ∞}. Of course, Qinf(x) is nonempty since Q is finite. If q ∈ Qinf(x), define a sequence x(q) ∈ {0, 1}ω as follows. If Vq(x) = {t(1), t(2), . . . , } where 0 ≤ t(1) < t(2) < . . ., we define x(q) i := xt(i)+1. In words: if M is run on x, the i-th bit of x(q) records the bit of x seen immediately after the i-th visit to state q. If q /∈ Qinf(x), we define x(q) ∈ {0, 1}∗ similarly; in this case, x(q) is undefined if M visits state q fewer than i times while running on x. i The following lemma gives us a useful property obeyed by sequences x from the set AB,ws (defined in the statement of Theorem 3). Lemma 3. Given M = (Q, s, ∆), suppose B ⊆ Q is strongly accessible. If x ∈ AB,ws, then there exists a state q ∈ Qinf(x) such that x(q) ∈ Aws ∪ Aco−ws. 14 Proof. We prove the contrapositive. Assume that all q ∈ Qinf(x) satisfy x(q) /∈ Aws ∪ Aco−ws; we will show that x /∈ AB,ws. Say that a state q ∈ Q is frequent (on x) if there exist α, β > 0 such that for all T ∈ N, Let F denote the set of frequent states. Clearly F ⊆ Qinf(x). We will show: Vq(x) ∩ {0, 1, . . . , T − 1} ≥ αT − β. 1. F = Qinf(x); 2. F contains a state from B. Item 2 will immediately imply that x /∈ AB,ws, as desired. For each q ∈ Qinf(x), our assumption x(q) /∈ Aws ∪ Aco−ws implies that there is a δq ∈ (0, 1/2) and a Kq > 0 such that for k ≥ Kq, δq < 1 k (cid:16)x(q) 1 + . . . + x(q) k (cid:17) < 1 − δq. (8) Let δ := min δq. Choose a value T ⋆ > 0 such that each q ∈ Qinf(x) appears at least Kq times among (q0(x), q1(x), . . . , qT ⋆−1(x)). Choose a second value R > 0, such that any q /∈ Qinf(x) occurs fewer than R times in the infinite sequence (q0(x), q1(x), . . .). Let ℓ = Q. Fix any t ∈ N satisfying t ≥ max(cid:26) ℓR δ2(ℓ−1) , T ⋆(cid:27) . By simple counting, some q⋆ ∈ Q occurs at least t/ℓ times in (q0(x), q1(x), . . . , qt−1(x)). We have t/ℓ > R, so this q⋆ must lie in Qinf(x). Eq. (8) then implies that the states ∆(q⋆, 0), ∆(q⋆, 1) each ap- pear at least δt/ℓ − 1 > δ2t/ℓ times among (q0(x), q1(x), . . . , qt−1(x)). Now δ2t/ℓ > R, so we have ∆(q⋆, 0), ∆(q⋆, 1) ∈ Qinf(x). Iterating this argument (ℓ − 1) times, we conclude that every state q reachable from q⋆ by a se- quence of (ℓ − 1) or fewer transitions lies in Qinf(x), and appears at least δ2(ℓ−1)t/ℓ = Ω(t) times among (q0(x), q1(x), . . . , qt−1(x)). But every q ∈ Qinf(x) is reachable from q⋆ by at most (ℓ − 1) transitions. Thus F = Qinf(x), proving Item 1 above. The argument above shows that if q ∈ Qinf(x), then ∆(q, 0), ∆(q, 1) ∈ Qinf(x) as well. Recall that B is strongly accessible; it follows that Qinf(x) ∩ B is nonempty, proving Item 2 above. This proves Lemma 3. We can now complete the proof of Theorem 3. Let Q = {p1, . . . , pℓ}, where ℓ = Q. We may assume ℓ > 1, for otherwise AB,ws = ∅ and there is nothing to show. Given ε > 0, let δ := ε/(2ℓ). We define the algorithm S = Sε as follows. S runs in parallel ℓ different simulations of the algorithm Pδ from Lemma 2. P[j] is run, not on the input sequence x itself, but on the subsequence x(pj). To determine which simulation receives each successive bit of x, the algorithm S simply simulates P[1], . . . , P[ℓ] 15 M on the bits of x seen so far. (Note that, if pj /∈ Qinf(x), then the simulation P[j] may "stall" indefinitely without receiving any further input bits.) Suppose that the simulation P[j] outputs a prediction z ∈ {0, 1} after seeing the i-th bit of x(pj), and that we subsequently reach a time t such that qt(x) = pj is the (i + 1)-st visit to state pj. The algorithm S then predicts that xt+1 = x(pj) We now analyze S. Fix any x ∈ AB−ws. By the safety property of Lemma 2, each P[j] outputs an incorrect prediction with probability at most δ, so the overall probability of an incorrect prediction is at most ℓδ = ε/2. Also, since x ∈ AB,ws, Lemma 3 tells us that there exists a pj ∈ Qinf(x) such that x(pj) ∈ Aws ∪ Aco−ws. Thus, if P[j] is run individually on x(pj), P[j] outputs a correct prediction with probability greater than 1 − δ. We conclude that i+1 = z. Sucbit-pred (S, x) > (1 − δ) − ε/2 > 1 − ε, using ℓ > 1. This proves Theorem 3. 5 The Density Prediction Game In this section we prove Theorem 1 from Section 1.4. The proof uses a technique from the analysis of mar- tingales that seems to be folklore; my understanding of this technique benefited greatly from conversations with Russell Impagliazzo. For any fixed δ, ε, our prediction strategy will work entirely within a finite interval (x1, . . . , xT ) of the sequence x. We note that, to derive a (δ, ε)-successful strategy over this interval, it suffices to show that for every distribution D over {0, 1}T , there exists a strategy SD that is (δ, ε)-successful when played against D. This follows from the minimax theorem of game theory, or from the result of Sandroni [San03] mentioned in Section 1.2. However, this observation would lead to a nonconstructive proof of Theorem 1, and in any case does not seem to make the proof any simpler. Thus we will not follow this approach. Let δ, ε > 0 be given; we give a forecasting strategy S = Sδ,ε for the density prediction game, and prove that S is (δ, ε)-successful. Set n := ⌈4/(δε2)⌉. Our strategy will always make a prediction about an interval xa, . . . , xb where a ≤ b ≤ 2n. The strategy S is defined as follows: 1. Choose R ∈ {1, . . . , n} uniformly. Choose S uniformly from {1, . . . , 2n−R}. 2. Ignore the first t = (S − 1) · 2R bits of x. Observe bits xt+1, . . . , xt+2R−1, and let p be the fraction of 1s in this interval. Immediately after seeing xt+2R−1, predict: "Out of the next 2R−1 bits, a p fraction will be 1s." We now analyze S. To do so, it is helpful to describe S in a slightly different fashion. Let us re-index the first 2n bits of our sequence x, considering each such bit to be indexed by a string z ∈ {0, 1}n. We use lexicographic order, so that the sequence is indexed x0n, x0n−11, x0n−210, and so on. Let T be a directed binary tree of height n, whose vertices at depth i (0 ≤ i ≤ n) are indexed by binary strings of length i; in particular, the root vertex is labeled by the empty string. If i < n and y ∈ {0, 1}i, the vertex vy has left and right children vy0, vy1 respectively. Each leaf vertex is indexed by an n-bit string z, and any such vertex vz is labeled with the bit xz. For y ∈ {0, 1}∗, let Ty denote the subtree of T rooted at vy. A direct translation of the strategy S into our current perspective gives the following equivalent description of S: 16 1'. Choose R ∈ {1, . . . , n} uniformly. Starting at the root of T , take a directed, unbiased random walk of length n − R, reaching a vertex vY where Y ∈ {0, 1}n−R. 2'. Observe the bits of x that label leaf vertices in TY 0, and let p be the fraction of 1s seen among these bits. Immediately after seeing the last of these bits, predict: "Out of the next 2R−1 bits of x (i.e., those labeling leaf vertices in TY 1), a p fraction will be 1s." To analyze S in this form, fix any binary sequence x. We consider the random walk performed in S to be extended to an unbiased random walk of length n. The walk terminates at some leaf vertex vZ, where Z = (z1, . . . , zn) is uniform over {0, 1}n. For 0 ≤ i ≤ n and y ∈ {0, 1}i, define ρ(y) := 2i−n Xw∈{0,1}n−i xyw as the fraction of 1s among the labels of leaf vertices of Ty. For 0 ≤ t ≤ n, define the random variable X(t) := ρ(z1, . . . , zt), defined in terms of Z, where X(0) = ρ(∅). The sequence X(0), . . . , X(n) is a martingale; we follow a folklore technique by analyzing the squared differences between terms in the sequence. First, we have X(t) ∈ [0, 1], so that (X(n) − X(0))2 ≤ 1. On the other hand, E[(X(n) − X(0))2] = E   X0≤t<n  = E  X0≤t<n (X(t + 1) − X(t)) 2    + E (X(t + 1) − X(t))2 2 X0≤s<t<n (X(s + 1) − X(s))(X(t + 1) − X(t))  . (9) Now, for 0 ≤ s < t < n and for any outcome of the bits z1, . . . , zt (which determine X(s), X(s + 1), and X(t)), we have E[(X(t + 1) − X(t))z1, . . . , zt] = Ezt+1∈{0,1}[(ρ(z1, . . . , zt+1)] − ρ(z1, . . . , zt) [ρ(z1, . . . , zt, 0) + ρ(z1, . . . , zt, 1)] − ρ(z1, . . . , zt) = 1 2 = 0. Thus the second right-hand term in Eq. (9) is 0, and E[(X(n) − X(0))2] = X0≤t<n E(cid:2)(X(t + 1) − X(t))2(cid:3) . (10) Next we relate this to the accuracy of our guess p. Let p∗ be the fraction of 1s in TY 1, i.e., the quantity S attempts to predict; note that p∗ and p are both random variables. From the definitions, we have p = ρ(Y 0), p∗ = ρ(Y 1), X(n − R) = 1 2 (p + p∗) . 17 Also, Thus we have the identity X(n − R + 1) = (cid:26) p p∗ if zn−R+1 = 0, if zn−R+1 = 1. (X(n − R + 1) − X(n − R))2 = (p − p∗)2 . 1 4 Now, n − R is is uniform over {0, 1, . . . , n − 1}, and independent of Z. It follows from Eq. (10) that E[(X(n − R + 1) − X(n − R))2] = 1 n E[(X(n) − X(0))2] ≤ 1/n. Combining, we have On the other hand, E[(p − p∗)2] ≤ 4/n. E[(p − p∗)2] ≥ Pr[p − p∗ ≥ ε] · ε2. (11) (12) Combining Eqs. (11) and (12), we obtain Pr[p − p∗ ≥ ε] ≤ 4/(nε2) ≤ δ, by our setting n = ⌈4/(δε2)⌉. This proves Theorem 1. 6 Questions for Future Work 1. Fix some p ∈ [1/2, 1]; is there a satisfying characterization of the sets A ⊆ {0, 1}ω for which some bit-prediction strategy (as defined in Section 4.1) succeeds with probability ≥ p against all x ∈ A? Perhaps there is a characterization in terms of some appropriate notion of dimension, analogous to the gale characterizations of Hausdorff dimension [Lut03a] and packing dimension [AHLM07]. 2. Could the study of computationally bounded bit-prediction strategies be of value to the study of com- plexity classes, by analogy to the study of computationally bounded gales in [Lut03a, AHLM07] and in related work? 3. Find necessary and sufficient conditions on the set B of "infrequently visited" states, for the conclu- sion of Theorem 3 (in Section 4.3) to hold. 4. Our (δ, ε)-successful forecasting strategy in Section 5 always makes a forecast about an interval of bits within x1, . . . , xm, where m = 2O(δ−1ε−2). It would be interesting to know whether some al- ternative strategy could make forecasts within a much smaller interval -- for instance, with m = poly(δ−1, ε−1). It would also be interesting to look at a setting in which the forecaster is allowed to make predictions about sets other than intervals. 7 Acknowledgements I thank John Hitchcock for pointing me to the ignorant-forecasting literature, and Russell Impagliazzo for helpful discussions. I also thank the many people who tried the puzzles in this paper. 18 References [AHLM07] K. Athreya, J. Hitchcock, J. Lutz, and E. Mayordomo. Effective strong dimension in algorith- mic information and computational complexity. SIAM Journal on Computing, 37(3):671 -- 705, 2007. [Bil65] P. Billingsley. Ergodic Theory and Information. John Wiley and Sons, 1965. [Daw82] [Egg49] A. Dawid. The well-calibrated Bayesian. Journal of the American Statistical Association, 77(379):pp. 605 -- 610, 1982. H. Eggleston. The fractional dimension of a set defined by decimal properties. Quarterly Journal of Mathematics, Oxford Series 20:31 -- 36, 1949. [FV98] D. Foster and R. Vohra. Asymptotic calibration. Biometrika, 85(2):pp. 379 -- 390, 1998. [FV09] [Hem05] [Lut03a] [Lut03b] [MF98] [San03] L. Fortnow and R. Vohra. The complexity of forecast testing. Econometrica, 77:pp. 93 -- 105, 2009. L. Hemaspaandra. SIGACT news complexity theory column 48. SIGACT News, 36(3):24 -- 38, 2005. Guest Column: The Fractal Geometry of Complexity Classes, by J. Hitchcock, J. Lutz, and E. Mayordomo. J. Lutz. Dimension in complexity classes. SIAM Journal on Computing, 32(5):1236 -- 1259, 2003. J. Lutz. The dimensions of individual strings and sequences. Information and Computation, 187:49 -- 79, 2003. N. Merhav and M. Feder. Universal prediction. 44:2124 -- 2147, 1998. IEEE Transactions on Information Theory, A. Sandroni. The reproducible properties of correct forecasts. International Journal of Game Theory, 32(1):151 -- 159, 2003. 19
1810.04620
2
1810
2019-02-20T15:34:23
Parameterized Complexity of Independent Set in H-Free Graphs
[ "cs.DS", "cs.CC" ]
In this paper, we investigate the complexity of Maximum Independent Set (MIS) in the class of $H$-free graphs, that is, graphs excluding a fixed graph as an induced subgraph. Given that the problem remains $NP$-hard for most graphs $H$, we study its fixed-parameter tractability and make progress towards a dichotomy between $FPT$ and $W[1]$-hard cases. We first show that MIS remains $W[1]$-hard in graphs forbidding simultaneously $K_{1, 4}$, any finite set of cycles of length at least $4$, and any finite set of trees with at least two branching vertices. In particular, this answers an open question of Dabrowski et al. concerning $C_4$-free graphs. Then we extend the polynomial algorithm of Alekseev when $H$ is a disjoint union of edges to an $FPT$ algorithm when $H$ is a disjoint union of cliques. We also provide a framework for solving several other cases, which is a generalization of the concept of \emph{iterative expansion} accompanied by the extraction of a particular structure using Ramsey's theorem. Iterative expansion is a maximization version of the so-called \emph{iterative compression}. We believe that our framework can be of independent interest for solving other similar graph problems. Finally, we present positive and negative results on the existence of polynomial (Turing) kernels for several graphs $H$.
cs.DS
cs
Parameterized Complexity of Independent Set in H-Free Graphs Édouard Bonnet Univ Lyon, CNRS, ENS de Lyon, Université Claude Bernard Lyon 1, LIP UMR5668, France Nicolas Bousquet CNRS, G-SCOP laboratory, Grenoble-INP, France Pierre Charbit Université Paris Diderot, IRIF, France Stéphan Thomassé Univ Lyon, CNRS, ENS de Lyon, Université Claude Bernard Lyon 1, LIP UMR5668, France Institut Universitaire de France Rémi Watrigant Univ Lyon, CNRS, ENS de Lyon, Université Claude Bernard Lyon 1, LIP UMR5668, France Abstract In this paper, we investigate the complexity of Maximum Independent Set (MIS) in the class of H-free graphs, that is, graphs excluding a fixed graph as an induced subgraph. Given that the problem remains N P-hard for most graphs H, we study its fixed-parameter tractability and make progress towards a dichotomy between F P T and W[1]-hard cases. We first show that MIS remains W[1]-hard in graphs forbidding simultaneously K1,4, any finite set of cycles of length at least 4, and any finite set of trees with at least two branching vertices. In particular, this answers an open question of Dabrowski et al. concerning C4-free graphs. Then we extend the polynomial algorithm of Alekseev when H is a disjoint union of edges to an F P T algorithm when H is a disjoint union of cliques. We also provide a framework for solving several other cases, which is a generalization of the concept of iterative expansion accompanied by the extraction of a particular structure using Ramsey's theorem. Iterative expansion is a maximization version of the so-called iterative compression. We believe that our framework can be of independent interest for solving other similar graph problems. Finally, we present positive and negative results on the existence of polynomial (Turing) kernels for several graphs H. 2012 ACM Subject Classification Theory of computation → Fixed parameter tractability Keywords and phrases Parameterized Algorithms, Independent Set, H-Free Graphs Digital Object Identifier 10.4230/LIPIcs... Funding É. B. is supported by the LABEX MILYON (ANR-10- LABX-0070) of Université de Lyon, within the program "Investissements d'Avenir" (ANR-11-IDEX-0007) operated by the French National Research Agency (ANR). N. B. and P. C. are supported by the ANR Project DISTANCIA (ANR-17-CE40-0015) operated by the French National Research Agency (ANR). Introduction 1 Given a simple graph G, a set of vertices S ⊆ V (G) is an independent set if the vertices of this set are all pairwise non-adjacent. Finding an independent set with maximum cardinality is a fundamental problem in algorithmic graph theory, and is known as the MIS problem (MIS, for short) [14]. In general graphs, it is not only N P-hard, but also not approximable © É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant; licensed under Creative Commons License CC-BY Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 9 1 0 2 b e F 0 2 ] S D . s c [ 2 v 0 2 6 4 0 . 0 1 8 1 : v i X r a XX:2 Parameterized Complexity of Independent Set in H-Free Graphs within O(n1−) for any  > 0 unless P = N P [23], and W[1]-hard [12] (unless otherwise stated, n always denotes the number of vertices of the input graph). Thus, it seems natural to study the complexity of MIS in restricted graph classes. One natural way to obtain such a restricted graph class is to forbid some given pattern to appear in the input. For a fixed graph H, we say that a graph is H-free if it does not contain H as an induced subgraph. Unfortunately, it turns out that for most graphs H, MIS in H-free graphs remains N P-hard, as shown by a very simple reduction first observed by Alekseev: (cid:73) Theorem 1 ([1]). Let H be a connected graph which is neither a path nor a subdivision of the claw. Then MIS is NP-hard in H-free graphs. On the positive side, the case of Pt-free graphs has attracted a lot of attention during the last decade. While it is still open whether there exists t ∈ N for which MIS is N P-hard in Pt-free graphs, quite involved polynomial-time algorithms were discovered for P5-free graphs [19], and very recently for P6-free graphs [15]. In addition, we can also mention the √ recent following result: MIS admits a subexponential algorithm running in time 2O( tn log n) in Pt-free graphs for every t ∈ N [3]. The second open question concerns the subdivision of the claw. Let Si,j,j be a tree with exactly three vertices of degree one, being at distance i, j and k from the unique vertex of degree three. The complexity of MIS is still open in S1,2,2-free graphs and S1,1,3-free graphs. In this direction, the only positive results concern some subcases: it is polynomial-time solvable in (S1,2,2, S1,1,3, dart)-free graphs [17], (S1,1,3, banner)-free graphs and (S1,1,3, bull)-free graphs [18], where dart, banner and bull are particular graphs on five vertices. Given the large number of graphs H for which the problem remains N P-hard, it seems natural to investigate the existence of parameterized algorithms1, that is, determining the existence of an independent set of size k in a graph with n vertices in time O(f(k)nc) for some computable function f and constant c. A very simple case concerns Kr-free graphs, that is, graphs excluding a clique of size r. In that case, Ramsey's theorem implies that r−1 ), where n = V (G). In the every such graph G admits an independent set of size Ω(n F P T vocabulary, it implies that MIS in Kr-free graphs has a kernel with Okr−1) vertices. To the best of our knowledge, the first step towards an extension of this observation within the F P T framework is the work of Dabrowski et al. [10] (see also Dabrowski's PhD manuscript [9]) who showed, among others, that for any positive integer r, Max Weighted Independent Set is FPT in H-free graphs when H is a clique of size r minus an edge. In the same paper, they settle the parameterized complexity of MIS on almost all the remaining cases of H-free graphs when H has at most four vertices. The conclusion is that the problem is F P T on those classes, except for H = C4 which is left open. We answer this question by showing that MIS remains W[1]-hard in a subclass of C4-free graphs. On the negative side, it was proved that MIS remains W[1]-hard in K1,4-free graphs [16] 1 Finally, we can also mention the case where H is the bull graph, which is a triangle with a pending vertex attached to two different vertices. For that case, a polynomial Turing kernel was obtained [22] then improved [13]. 1 For the sake of simplicity, "MIS" will denote the optimisation, decision and parameterized version of the problem (in the latter case, the parameter is the size of the solution), the correct use being clear from the context. É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:3 1.1 Our results In Section 2, we present three reductions proving W[1]-hardness of MIS in graph excluding several graphs as induced subgraphs, such as K1,4, any fixed cycle of length at least four, and any fixed tree with two branching vertices. We propose a definition of a graph decomposition whose aim is to capture all graphs which can be excluded using our reductions. In Section 3, we extend the polynomial algorithm of Alekseev when H is a disjoint union of edges to an F P T algorithm when H is a disjoint union of cliques. In Section 4, we present a general framework extending the technique of iterative expansion, which itself is the maximization version of the well-known iterative compression technique. We apply this framework to provide F P T algorithms when H is a clique minus a complete bipartite graph, a clique minus a triangle, and when H is the so-called gem graph. Finally, in Section 5, we focus on the existence of polynomial (Turing) kernels. We first strenghten some results of the previous section by providing polynomial (Turing) kernels in the case where H is a clique minus a claw. Then, we prove that for many H, MIS on H-free graphs does not admit a polynomial kernel, unless N P ⊆ coN P/poly. Our results allows to obtain the complete dichotomy polynomial/polynomial kernel (PK)/no PK but polynomial Turing kernel/W[1]-hard for all possible graphs on four vertices, while only five graphs on five vertices remain open for the F P T/W[1]-hard dichotomy. 1.2 Notation For classical notation related to graph theory or fixed-parameter tractable algorithms, we refer the reader to the monographs [11] and [12], respectively. For an integer r ≥ 2 and a graph H with vertex set V (H) = {v1, . . . , vnH} with nH ≤ r, we denote by Kr \ H the graph with vertex set {1, . . . , r} and edge set {ab : 1 ≤ a, b ≤ r such that vavb /∈ E(H)}. For X ⊆ V (G), we write G \ X to denote G[V (G) \ X]. For two graphs G and H, we denote by G] H the disjoint union operation, that is, the graph with vertex set V (G)∪ V (H) and edge set E(G) ∪ E(H). We denote by G + H the join operation of G and H, that is, the graph with vertex set V (G) ∪ V (H) and edge set E(G) ∪ E(H) ∪ {uv : u ∈ V (G), v ∈ V (H)}. For two integers r, k, we denote by Ram(r, k) the Ramsey number of r and k, i.e. the minimum order of a graph to contain either a clique of size r or an independent set of size k. We write for short Ram(k) = Ram(k, k). Finally, for ', k > 0, we denote by Ram'(k) the minimum order of a complete graph whose edges are colored with ' colors to contain a monochromatic clique of size k. 2 W[1]-hardness 2.1 Main reduction We have the following: (cid:73) Theorem 2. For any p1 ≥ 4 and p2 ≥ 1, MIS remains W[1]-hard in graphs excluding simultaneously the following graphs as induced subgraphs: K1,4 C4, . . . , Cp1 any tree T with two branching vertices2 at distance at most p2. 2 A branching vertex in a tree is a vertex of degree at least 3. XX:4 Parameterized Complexity of Independent Set in H-Free Graphs Figure 1 Gadget T Gi,j representing a tile and its adjacencies with T Gi,j−1 and T Gi,j+1, for p = 1. Each circle is a clique on n vertices (dashed cliques are the cycle cliques). Black, blue and red arrows represent respectively type Th, Tr and Tc edges (bold arrows are between two gadgets). Figures 2a and 2b represent some adjacencies in more details. Proof. Let p = max{p1, p2}. We reduce from Grid Tiling, where the input is composed of k2 sets Si,j ⊆ [m] × [m] (0 ≤ i, j ≤ k − 1), called tiles, each composed of n elements. The i,j ∈ Si,j for each 0 ≤ i, j ≤ k − 1, such that objective of Grid Tiling is to find an element s∗ s∗ i,j agrees in the first coordinate with s∗ i+1,j, for every 0 ≤ i, j ≤ k − 1 (incrementations of i and j are done modulo k). In such case, we say that {s∗ i,j, 0 ≤ i, j ≤ k − 1} is a feasible solution of the instance. It is known that Grid Tiling is W[1]-hard parameterized by k [8]. i,j+1, and agrees in the second coordinate with s∗ i,j is row-compatible with s∗ Before describing formally the reduction, let us give some definitions and ideas. Given s = (a, b) and s0 = (a0, b0), we say that s is row-compatible (resp. column-compatible) with s0 if a ≥ a0 (resp. b ≥ b0)3. Observe that a solution {s∗ i,j, 0 ≤ i, j ≤ k − 1} is feasible if and only if s∗ i+1,j for every 0 ≤ i, j ≤ k − 1 (incrementations of i and j are done modulo k). Informally, the main idea of the reduction is that, when representing a tile by a clique, the row-compatibility (resp. column-compatibility) relation (as well at its complement) forms a C4-free graph when considering two consecutive tiles, and a claw-free graph when considering three consecutive tiles. The main difficulty is to forbid the desired graphs to appear in the "branchings" of tiles. We now describe the reduction. i,j+1 and column-compatible with s∗ 2.1.1 Tile gadget. n }, we construct a tile gadget T Gi,j, depicted in Figure 1. For every tile Si,j = {si,j Notice that this gadget shares some ideas with the W[1]-hardness of the problem in K1,4-free 1 , . . . , si,j 3 Notice that the row-compatibility (resp. column-compatibility) relation is not symmetrical. Ti,jRi,jLi,jBi,jGadgetTGi,jLi,j+1Ri,j−1 É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:5 (a) Adjacencies between cycle cliques (repres- ented by dashed circles in Figure 1). (b) Two consecutive tiles and the representation of their adjacencies (representing type Tr adjacencies). Figure 2 Some example of adjacencies within the first reduction. graphs by Hermelin et al. [16]. To define this gadget, we first describe an oriented graph with three types of arcs (type Th, Tr and Tc, which respectively stands for half graph, row and column, this meaning will become clearer later), and then explain how to represent the vertices and arcs of this graph to get the concrete gadget. Consider first a directed cycle on 4p + 4 vertices c1, . . . , c4p+4 with arcs of type Th. Then consider four oriented paths on p + 1 vertices: P1, P2, P3 and P4. P1 and P3 are composed of arcs of type Tc, while P2 and P4 are composed of arcs of type Tr. Put an arc of type Tc between: the last vertex of P1 and c1, c2p+3 and the first vertex of P3, and an arc of type Tr between: cp+2 and the first vertex of P2, the last vertex of P4 and c3p+4. Now, replace every vertex of this oriented graph by a clique on n vertices, and fix an arbitrary ordering on the vertices of each clique. For each arc of type Th between c and c0, add a half graph4 between the corresponding cliques: connect the ath vertex of the clique representing c with the bth vertex of the clique representing c0 iff a > b. For every arc of type Tr from a vertex c to a vertex c0, connect the ath vertex of the clique representing c with the bth vertex of the clique representing c0 iff si,j b . Similarly, for every arc of type Tc from a vertex c to a vertex c0, connect the ath vertex of the clique representing C with the bth vertex of the clique representing c0 iff si,j a is not column-compatible with si,j b . The cliques corresponding to vertices of this gadget are called the main cliques of T Gi,j, and the cliques corresponding to the central cycle on 4p + 4 vertices are called the cycle cliques. The main cliques which are not cycle cliques are called path cliques. The cycle cliques a is not row-compatible with si,j 4 Notice that our definition of half graph slighly differs from the usual one, in the sense that we do not put edges relying two vertices of the same index. Hence, our construction can actually be seen as the complement of a half graph (which is consistent with the fact that usually, both parts of a half graph are independent sets, while they are cliques in our gadgets). bbbbbbbbbbsi,j1si,j2si,j3si,j5si,j4si,j+15si,j+11si,j+14si,j+13si,j+12si,j1si,j2si,j3si,j4si,j5si,j+11si,j+12si,j+13si,j+14si,j+1512345123451234512345 XX:6 Parameterized Complexity of Independent Set in H-Free Graphs 1 , . . . , ti,j n }, Ri,j = {ri,j adjacent to one path clique are called branching cliques. Finally, the clique corresponding to the vertex of degree one in the path attached to c1 (resp. cp+2, c2p+3, c3p+4) is called the top (resp. right, bottom, left) clique of T Gi,j, denoted by Ti,j (resp. Ri,j, Bi,j, Li,j). Let Ti,j = {ti,j n }. 1 , . . . , 'i,j For the sake of readability, we might omit the superscripts i, j when it is clear from the context. (cid:73) Lemma 3. Let K be an independent set of size 8(p + 1) in T Gi,j. Then: (a) K intersects all the cycle cliques on the same index x; (b) if K ∩ Ti,j = {txt}, K ∩ Ri,j = {rxr}, K ∩ Bi,j = {bxb}, and K ∩ Li,j = {'x'}. Then: n }, and Li,j = {'i,j n }, Bi,j = {bi,j 1 , . . . , ri,j 1 , . . . , bi,j si,j x' si,j xt is row-compatible with si,j is column-compatible with si,j x which is row-compatible with si,j , and x which is column-compatible with si,j xr xb . Proof. Observe that the vertices of T Gi,j can be partitionned into 8(p + 1) cliques (the main cliques), hence an independent set of size 8(p + 1) intersects each main clique on exactly one vertex. Let C1, C2 and C3 be three consecutive cycle cliques, and suppose K intersects C1 (resp. C2, C3) on the xth1 (resp. xth2 , xth3 ) index. By definition of the gadget, it implies x1 ≤ x2 ≤ x3. By applying the same argument from C3 along the cycle, we obtain x3 ≤ x1, which proves (a). The proof of (b) directly comes from the definition of the adjacencies between cliques of type Tr and Tc, and from the fact that K intersects all cycle cliques on (cid:74) the same index. 2.1.2 Attaching gadgets together. For i, j ∈ {0, . . . , k − 1}, we connect the right clique of T Gi,j with the left clique of T Gi,j+1 ∈ Li,j+1 iff si,j in a "type Tr spirit": for every x, y ∈ [n], connect ri,j . Similarly, we connect the bottom clique of T Gi,j with is not row-compatible with si,j+1 x ∈ Bi,j with the top clique of T Gi+1,j in a "type Tc spirit": for every x, y ∈ [n], connect bi,j (all incrementations of i and j ti+1,j are done modulo k). This terminates the construction of the graph G. x is not column-compatible with si+1,j x ∈ Ri,j with 'i,j+1 ∈ Ti+1,j iff si,j x y y y y 2.1.3 Equivalence of solutions. We now prove that the input instance of Grid Tiling is positive if and only if G has an independent set of size k0 = 8(p+1)k2. First observe that G has k2 tile gadgets, each composed of 8(p + 1) main cliques, hence any independent set of size k0 intersects each main clique on exactly one vertex. By Lemma 3, for all i, j ∈ {0, . . . , k − 1}, K intersects the cycle cliques x } and K ∩ Li,j+1 = {'i,j+1 of T Gi,j on the same index xi,j. Moreover, if K ∩ Ri,j = {ri,j }, x } . Similarly, if K ∩ Bi,j = {bi,j then, by construction of G, si,j x0 and K ∩ Ti+1,j = {ti+1,j }, then, by construction of G, si,j x is column-compatible with si+1,j . x0 By Lemma 3, it implies that si,j xi,j+1 and column-compatible with xi,j : 0 ≤ i, j ≤ k − 1} is a si+1,j xi+1,j feasible solution. Using similar ideas, one can prove that a feasible solution of the grid tiling instance implies an independent set of size k0 in G. (incrementations of i and j are done modulo k), thus {xi,j x is row-compatible with si,j+1 is row-compatible with si,j+1 xi,j x0 x0 2.1.4 Structure of the obtained graph. Let us now prove that G does not contain the graphs mentionned in the statement as an induced subgraph: É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:7 (i) K1,4: we first prove that for every 0 ≤ i, j ≤ k − 1, the graph induced by the cycle cliques of T Gi,j is claw-free. For the sake of contradiction, suppose that there exist three consecutive cycle cliques A, B and C containing a claw. W.l.o.g. we may assume that bx ∈ B is the center of the claw, and aα ∈ A, bβ ∈ B and cγ ∈ C are the three endpoints. By construction of the gadgets (there is a half graph between A and B and between B and C), we must have α < x < γ. Now, observe that if x < β then aα must be adjacent to bβ, and if β < x, then bβ must be adjacent to cγ, but both case are impossible since {aα, bβ, cγ} is supposed to be an independent set. Similarly, we can prove that the graph induced by each path of size 2(p + 1) linking two consecutive gadgets is claw-free. Hence, the only way for K1,4 to appear in G would be that the center appears in the cycle clique attached to a path, for instance in the clique represented by the vertex c1 in the cycle. However, it can easily be seen that in this case, a claw must lie either in the graph induced by the cycle cliques of the gadget, or in the path linking T Gi,j with T Gi−1,j, which is impossible. (ii) C4, . . . , Cp1. The main argument is that the graph induced by any two main cliques does not contain any of these cycles. Then, we show that such a cycle cannot lie entirely in the cycle cliques of a single gadget T Gi,j. Indeed, if this cycle uses at most one vertex per main clique, then it must be of length at least 4p + 4. If it intersects a clique C on two vertices, then either it also intersect all the cycle cliques of the gadget, in which case it is of length 4p + 5, or it intersects an adjacent clique of C on two vertices, in which case these two cliques induce a C4, which is impossible. Similarly, such a cycle cannot lie entirely in a path between the main cliques of two gadgets. Finally, the main cliques of two gadgets are at distance 2(p + 1), hence such a cycle cannot intersect the main cliques of two gadgets. (iii) any tree T with two branching vertices at distance at most p2. Using the same argument as for the K1,4 case, observe that the claws contained in G can only appear in the cycle cliques where the paths are attached. However, observe that these cliques are at distance 2(p + 1) > p2, thus, such a tree T cannot appear in G. (cid:74) As a direct consequence of Theorem 2, we get the following by setting p1 = p2 = V (H)+1: (cid:73) Corollary 4. If H is not chordal, or contains as an induced subgraph a K1,4 or a tree with two branching vertices, then MIS in H-free graphs is W[1]-hard. 2.2 Capturing Hard Graphs We introduce two variants of the hardness construction of Theorem 2, which we refer to as the first construction. The second construction is obtained by replacing each interaction between two main cliques by an anti-matching, except the one interaction in the middle of the path cliques which remains a half-graph (see Figure 3, middle). In an anti-matching, the same elements in the two adjacent cliques define the only non-edges. The correctness of this new reduction is simpler since the propagation of a choice is now straightforward. Observe however that the graph C4 appears in this new construction. For the third construction, we start from the second construction and just add an anti-matching between two neighbors of each branching clique among the cycle cliques (see Figure 3, right). This anti-matching only constrains more the instance but does not destroy the intended solutions; hence the correctness. XX:8 Parameterized Complexity of Independent Set in H-Free Graphs Figure 3 A symbolic representation of the hardness constructions. To the left, only half-graphs (blue) are used between the cliques, as in the proof of Theorem 2. In the middle and to the right, the half-graphs (blue) are only used once in the middle of each path of cliques, and the rest of the interactions between the cliques are anti-matchings (red). The third construction (right) is a slight variation of the second (middle) where for each branching clique, we link by an anti-matching its two neighbors among the cycle cliques. To describe those connected graphs H which escape the disjunction of Theorem 2 (for which there is still a hope that MIS is FPT), we define a decomposition into cliques, similar yet different from clique graphs or tree decompositions of chordal graphs (a.k.a k-trees). (cid:73) Definition 5. Let T be a graph on ' vertices t1, . . . , t'. We say that T is a clique decomposition of H if there is a partition of V (H) into (C1, C2, . . . , C') such that: for each i ∈ ['], H[Ci] is a clique, and for each pair i 6= j ∈ ['], if H[Ci ∪ Cj] is connected, then titj ∈ E(T). Observe that, in the above definition, we do not require T to be a tree. Two cliques Ci and Cj are said adjacent if H[Ci ∪ Cj] is connected. We also write a clique decomposition on T (of H) to denote the choice of an actual partition (C1, C2, . . . , C'). Let T1 be the class of trees with at most one branching vertex. Equivalently, T1 consists of the paths and the subdivisions of the claw. (cid:73) Proposition 6. For a fixed connected graph H, if no tree in T1 is a clique decomposition of H, then MIS in H-free graphs is W[1]-hard. Proof. This is immediate from the proof of Theorem 2 since H cannot appear in the first (cid:74) construction. At this point, we can focus on connected graphs H admitting a tree T ∈ T1 as a clique decomposition. The reciprocal of Proposition 6 cannot be true since a simple edge is a clique decomposition of C4. The next definition further restricts the interaction between two adjacent cliques. (cid:73) Definition 7. Let T be a graph on ' vertices t1, . . . , t'. We say that T is a strong clique decomposition of H if there is a partition of V (H) into (C1, C2, . . . , C') such that: for each i ∈ ['], H[Ci] is a clique, and for each pair i 6= j ∈ ['], H[Ci ∪ Cj] is a clique iff titj ∈ E(T). An equivalent way to phrase this definition is that H can be obtained from T by adding false twins. Adding a false twin v0 to a graph consists in duplicating one of its vertex v (i.e., v and v0 have the same neighbors) and then adding an edge between v and v0. É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:9 We define almost strong clique decompositions which informally are strong clique decom- positions where at most one edge can be missing in the interaction between two adjacent cliques. (cid:73) Definition 8. Let T be a graph on ' vertices t1, . . . , t'. We say that T is an almost strong clique decomposition of H if there is a partition of V (H) into (C1, C2, . . . , C') such that: for each i ∈ ['], H[Ci] is a clique, and for each pair i 6= j ∈ ['], [H[Ci ∪ Cj] is a clique or H[Ci ∪ Cj] is a clique of size at least 3 minus an edge] iff titj ∈ E(T). Finally, a nearly strong clique decomposition is slightly weaker than an almost strong clique decomposition: at most one interaction between two adjacent cliques can induce a C4-free graph. Let P be the set of all the paths. Notice that T1 \ P is the set of all the subdivisions of the claw. (cid:73) Theorem 9. Let H be a fixed connected graph. If no P ∈ P is a nearly strong clique decomposition of H and no T ∈ T1 \ P is an almost strong clique decomposition of H, then MIS in H-free graphs is W[1]-hard. Proof. The idea is to mainly use the second construction and the fact that MIS in C4-free graphs is W[1]-hard (due to the first construction). For every fixed graph H which cannot be an induced subgraph in the second construction, MIS is W[1]-hard. To appear in this construction, the graph H should have either a clique decomposition on a subdivision of the claw, such that the interaction between two adjacent cliques is the complement of a (non necessarily perfect) matching, or a clique decomposition on a path, such that the interaction between two adjacent cliques is the complement of a matching, except for at most one interaction which can be a C4-free graph. We now just observe that in both cases if, among the interactions between adjacent cliques, one complement of matching has at least two non-edges, then H contains an induced C4. Hence the two items can be equivalently replaced by the existence of an almost strong clique decomposition on a subdivision of the claw, and a nearly strong clique decomposition on a (cid:74) path, respectively. Theorem 9 narrows down the connected open cases to graphs H which have a nearly strong clique decomposition on a path or an almost strong clique decomposition on a subdivision of the claw. In the strong clique decomposition, the interaction between two adjacent cliques is very simple: their union is a clique. Therefore, it might be tempting to conjecture that if H admits T ∈ T1 as a strong clique decomposition, then MIS in H-free graphs is FPT. Indeed, those graphs H appear everywhere in both the first and the second W[1]-hardness constructions. Nevertheless, we will see that this conjecture is false: even if H has a strong clique decomposition T ∈ T1, it can be that MIS is W[1]-hard. The simplest tree of T1 \ P is the claw. We denote by Ti,j,k the graph obtained by adding a universal vertex to the disjoint union of three cliques Ki ] Kj ] Kk. The claw is a strong clique decomposition of Ti,j,k (for every natural numbers i, j, k). (cid:73) Theorem 10. MIS in T1,2,2-free graphs is W[1]-hard. XX:10 Parameterized Complexity of Independent Set in H-Free Graphs Figure 4 The two ways the cricket appears in the third construction. The red edges between two adjacent cliques symbolize an anti-matching, whereas the blue edge symbolizes a C4-free graph. In the left hand-side, one neighbor of the universal vertex with degree 2 could alternatively be in the same clique as the universal vertex. Proof. We show that T1,2,2 does not appear in the third construction (Figure 3, right). We claim that, in this construction, the graph T1,1,2, sometimes called cricket, can only appear in the two ways depicted on Figure 4 (up to symmetry). Claim: The triangle of the cricket cannot appear within the same main clique. Proof. Otherwise the two leaves (i.e., vertices of degree 1) of the cricket are in two distinct adjacent cliques. But at least one of those adjacent cliques is linked to the main clique of the triangle by an anti-matching. This is a contradiction to the corresponding leaf having two (cid:74) non-neighbors in the main clique of the triangle. We first study how the cricket can appear in a path of cliques. Let C be the main clique containing the universal vertex of the cricket. This vertex is adjacent to three disjoint cliques K1 ] K1 ] K2. Due to the previous claim, the only way to distribute them is to put K1 in the previous main clique, K1 in the same main clique C, and K2 in the next main clique. This is only possible if the interaction between C and the next main clique is a half-graph. In particular, this implies that the interaction between the previous main clique and C is an anti-matching. This situation corresponds to the left of Figure 4. This also implies that the cricket cannot appear in a path of cliques without a half-graph interaction (anti-matchings only). We now turn our attention to the vicinity of a triangle of main cliques, which is proper to the third construction. By our previous remarks, we know that the universal vertex of the cricket has to be either alone in a main clique (by symmetry, it does not matter which one) of the triangle, or with exactly one of its neighbors of degree 2. Now, the only way to place K1 ] K1 ] K2 is to put the two K1 in the two other main cliques of the triangle, and the K2 (or the single vertex rest of it) in the remaining adjacent main clique. Indeed, if the K2 is in a main clique of the triangle, the K1 in the third main clique of the triangle would have two non-edges towards to K2. This is not possible with an anti-matching interaction. Therefore, the only option corresponds to the right of Figure 4. To obtain a T1,2,2, one needs to find a false twin to one of the leaves of the cricket. This is not possible since, in both cases, the two leaves are in two adjacent cliques with an anti- matching interaction. Therefore, adding the false twin would create a second non-neighbor (cid:74) to the remaining leaf. The graph T1,1,1 is the claw itself for which MIS is solvable in polynomial time. The parameterized complexity for the graph T1,1,2 (the cricket) remains open. As a matter É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:11 of fact, this question is unresolved for T1,1,s-free graphs, for any integer s (cid:62) 2. Solving those cases would bring us a bit closer to a full dichotomy FPT vs W[1]-hard. Although, Theorem 10 suggests that this dichotomy will be rather subtle. In addition, this result infirms the plausible conjecture: if MIS is FPT in H-free graphs, then it is FPT in H0-free graphs where H0 can be obtained from H by adding false twins. The toughest challenge towards the dichotomy is understanding MIS in the absence of paths of cliques5. In Theorem 19, we make a very first step in that direction: we show that for every graph H with a strong clique decomposition on P3, the problem is FPT. In the previous paragraphs, we dealt mostly with connected graphs H. In Theorem 11, we show that if H is a disjoint union of cliques, then MIS in H-free graphs is FPT. In the language of clique decompositions, this can be phrased as H has a clique decomposition on an independent set. Positive results I: disjoint union of cliques r be the disjoint union of q copies of Kr. The proof of the following 3 For r, q ≥ 1, let K q theorem is inspired by the case r = 2 by Alekseev [2]. (cid:73) Theorem 11. Maximum Independent Set is FPT in K q Proof. We will prove by induction on q that a K q r -free graph has an independent set of size k or has at most Ram(r, k)qknqr independent sets. This will give the desired FPT-algorithm, as the proof shows how to construct this collection of independent sets. Note that the case q = 1 is trivial by Ramsey's theorem. r -free graphs. Let G be a K q r -free graph and let < be any fixed total ordering of V (G). For any vertex x, define x+ = {y, x < y} and x− = V (G) \ x+. r Let C be a fixed clique of size r in G and let c be the smallest vertex of C with respect to <. Let V1 be the set of vertices of c+ which have no neighbor in C. Note that V1 induces a K q−1 -free graph, so by induction either it contains an independent set of size k, and so does G, or it has at most Ram(r, k)(q−1)kn(q−1)r independent sets. In the latter case, let S1 be the set of all independent sets of G[V1]. Now in a second phase we define an initially empty set SC and do the following. For each independent set S1 in S1, we denote by V2 the set of vertices in c− that have no neighbor in S1. For every choice of a vertex x amongst the largest Ram(r, k) vertices of V2 in the order, we add x to S1 and modify V2 in order to keep only vertices that are smaller than x (with respect to <) and non adjacent to x. We repeat this operation k times (or less if V2 becomes empty) and, at the end, we either find an independent set of size k or add S1 to SC. By doing so we construct a family of at most Ram(r, k)k independent sets for each S1, so in total we get indeed at most Ram(r, k)kqn(q−1)r independent sets for each clique C. Finally we define S as the union over all r-cliques C of the sets SC, so that S has size at most the desired number. We claim that if G does not contain an independent set of size k, then S contains all independent sets of G. It suffices to prove that for every independent set S, there exists a clique C for which S ∈ SC. Let S be an independent set, and define C to be a clique of size r such that its smallest vertex c (with respect to <) satisfies the conditions: no vertex of C is adjacent to a vertex of S ∩ c+, and 5 Actually, even the classical complexity of MIS in the absence of long induced paths is not well understood XX:12 Parameterized Complexity of Independent Set in H-Free Graphs c is the smallest vertex such that a clique C satisfying the first item exists. Note that several cliques C might satisfy these conditions. In that case, pick one such clique arbitrarily. These two conditions ensures that S ∩ c+ is an independent set in the set V1 defined in the construction above. Thus it will be picked in the second phase as some S1 in S1 and for this choice, each time V2 is considered, the fact that C is chosen to minimize its smallest element c guarantees that there must be a vertex of S in the Ram(r, k) last vertices in V2, otherwise we could find within those vertices an r-clique contradicting the choice of C. So we are insured that we will add S to the collection SC, which concludes our proof. (cid:74) Positive results II 4 4.1 Key ingredient: Iterative expansion and Ramsey extraction In this section, we present the main idea of our algorithms. It is a generalization of iterative expansion, which itself is the maximization version of the well-known iterative compression technique. Iterative compression is a useful tool for designing parameterized algorithms for subset problems (i.e. problems where a solution is a subset of some set of elements: vertices of a graph, variables of a logic formula...etc.) [8, 21]. Although it has been mainly used for minimization problems, iterative compression has been successfully applied for maximization problems as well, under the name iterative expansion [6]. Roughly speaking, when the problem consists in finding a solution of size at least k, the iterative expansion technique consists in solving the problem where a solution S of size k − 1 is given in the input, in the hope that this solution will imply some structure in the instance. In the following, we consider an extension of this approach where, instead of a single smaller solution, one is given a set of f(k) smaller solutions S1, . . . , Sf(k). As we will see later, we can further add more constraints on the sets S1, . . . , Sf(k). Notice that all the results presented in this sub-section (Lemmas 13 and 16 in particular) hold for any hereditary graph class (including the class of all graphs). The use of properties inherited from particular graphs (namely, H-free graphs in our case) will only appear in Sections 4.2 and 4.3. (cid:73) Definition 12. For a function f : N → N, the f-Iterative Expansion MIS takes as input a graph G, an integer k, and a set of f(k) independent sets S1, . . . , Sf(k), each of size k − 1. The objective is to find an independent set of size k in G, or to decide that such an independent set does not exist. (cid:73) Lemma 13. Let G be a hereditary graph class. MIS is F P T in G iff f-Iterative Expansion MIS is F P T in G for some computable function f : N → N. Proof. Clearly if MIS is F P T, then f-Iterative Expansion MIS is F P T for any com- putable function f. Conversely, let f be a function for which f-Iterative Expansion MIS is F P T, and let G be a graph with V (G) = n. We show by induction on k that there is an algorithm that either finds an independent set of size k, or answers that such a set does not exist, in F P T time parameterized by k. The initialization can obviously be computed in constant time. Assume we have an algorithm for k − 1. Successively for i from 1 to f(k), we construct an independent set Si of size k − 1 in G \ (S1, . . . , Sj−1). If, for some i, we are unable to find such an independent set, then it implies that any independent set of size k in G must intersect S1 ∪ ··· ∪ Si. We thus branch on every vertex v of this union, and, by induction, find an independent set of size k − 1 in the graph induced by V (G) \ N[v]. If no step i triggered the previous branching, we end up with f(k) vertex-disjoint independent sets S1, . . . , Sf(k), each of size k − 1. We now É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:13 invoke the algorithm for f-Iterative Expansion MIS to conclude. Let us analyze the running time of this algorithm: each step either branch on at most f(k)(k − 1) subcases with parameter k − 1, or concludes in time Af(n, k), the running time of the algorithm for f-Iterative Expansion MIS. Hence the total running time is O∗(f(k)k(k − 1)kAf(n, k)), where the O∗(.) suppresses polynomial factors. (cid:74) We will actually prove a stronger version of this result, by adding more constraints on the input sets S1, . . . , Sf(k), and show that solving the expansion version on this particular kind of input is enough to obtain the result for MIS. (cid:73) Definition 14. Given a graph G and a set of k − 1 vertex-disjoint cliques of G, C = {C1, . . . , Ck−1}, each of size q, we say that C is a set of Ramsey-extracted cliques of size q if the conditions below hold. Let Cr = {cr j : j ∈ {1, . . . , q}} for every r ∈ {1, . . . , k − 1}. j : r ∈ {1, . . . , k − 1}} is an independent set of G of size k − 1. For every j ∈ [q], the set {cr For any r 6= r0 ∈ {1, . . . , k − 1}, one of the four following case can happen: (i) for every j, j0 ∈ [q], cr (ii) for every j, j0 ∈ [q], cr (iii) for every j, j0 ∈ [q], cr (iv) for every j, j0 ∈ [q], cr j0 /∈ E(G) j cr0 j0 ∈ E(G) iff j 6= j0 j cr0 j0 ∈ E(G) iff j < j0 j cr0 j0 ∈ E(G) iff j > j0 j cr0 In the case (i) (resp. (ii)), we say that the relation between Cr and Cr0 is empty (resp. full6). In case (iii) or (iv), we say the relation is semi-full. Observe, in particular, that a set C of k − 1 Ramsey-extracted cliques of size q can be partitionned into q independent sets of size k − 1. As we will see later, these cliques will allow us to obtain more structure with the remaining vertices if the graph is H-free. Roughly speaking, if q is large, we will be able to extract from C another set C0 of k − 1 Ramsey-extracted cliques of size q0 < q, such that every clique is a module7 with respect to the solution x∗ k we are looking for. Then, by guessing the structure of the adjacencies between C0 and the solution, we will be able to identify from the remaining vertices k sets i w.r.t. C0, and plays the role of X1, . . . , Xk, where each Xi has the same neighborhood as x∗ "candidates" for this vertex. For a function f : N → N, we define the following problem: (cid:73) Definition 15. The f-Ramsey-extracted Iterative Expansion MIS problem takes as input an integer k and a graph G whose vertices are partitionned into non-empty sets X1 ∪ ··· ∪ Xk ∪ C1 ∪ ··· ∪ Ck−1, where: 1, . . . , x∗ {C1, . . . , Ck−1} is a set of k − 1 Ramsey-extracted cliques of size f(k) any independent set of size k in G is contained in X1 ∪ ··· ∪ Xk ∀i ∈ {1, . . . , k}, ∀v, w ∈ Xi and ∀j ∈ {1, . . . , k − 1}, N(v) ∩ Cj = N(w) ∩ Cj = ∅ or N(v) ∩ Cj = N(w) ∩ Cj = Cj k}, the following bipartite graph B is connected: V (B) = B1 ∪ B2, B1 = {b1 1, . . . , b1 B2 = {b2 k−1} and b1 r ∈ E(B) iff Xj and Cr are adjacent. j b2 1, . . . , b2 The objective is to find an independent set S in G of size at least k, or to decide that G does not contain an independent set S such that S ∩ Xi 6= ∅ for all i ∈ {1, . . . , k}. 6 Remark that in this case, the graph induced by Cr ∪ Cr0 is the complement of a perfect matching. 7 A set of vertices M is a module if every vertex v /∈ M is adjacent to either all vertices of M, or none. XX:14 Parameterized Complexity of Independent Set in H-Free Graphs X X7 X6 X5 X4 X3 X2 X1 B C S3 C6 C5 C4 C3 C2 C1 Figure 5 The structure of the f-Ramsey-extracted Iterative Expansion MIS inputs. (cid:73) Lemma 16. Let G be a hereditary graph class. If there exists a computable function f : N → N such that f-Ramsey-extracted Iterative Expansion MIS is F P T in G, then g-Iterative Expansion MIS is F P T in G, where g(x) = Ram'(f(x)2x(x−1)) ∀x ∈ N, with 'x = 2(x−1)2. Proof. Let f : N → N be such a function, and let G, k and S = {S1, . . . , Sg(k)} be an input of g-Iterative Expansion MIS. Recall that the objective is to find an independent set of size k in G, or to decide that such an independent set does not exist. If G contains an independent set of size k, then either there is one intersecting some set of S, or every independent set of size k avoids the sets in S. In order to capture the first case, we branch on every vertex v of the sets in S, and make a recursive call with parameter G \ N[v], k − 1. In the remainder of the algorithm, we thus assume that any independent set of size k in G avoids every set of S. j the rth vertex of Sj. Notice that given an ordered pair of sets of k − 1 vertices (A, B), there are 'k = 2(k−1)2 possible sets of edges between these two sets. Let us denote by c1, . . . , c2(k−1)2 the possible sets of edges, called types. We define an auxiliary edge-colored graph H whose vertices are in one-to-one correspondence with S1, . . . , Sg(k), and, for i < j, there is an edge between Si and Sj of color γ iff the type of (Si, Sj) is γ. By Ramsey's theorem, since H has Ram'k(f(k)2k(k−1)) vertices, it must admit a monochromatic clique of size at least h(k) = f(k)2k(k−1). W.l.o.g., the vertex set of this clique corresponds to S1, . . . , Sh(k). For p ∈ {1, . . . , k − 1}, let Cp = {sp h(k)}. Observe that the Ramsey extraction ensures that each Cp is either a clique or an independent set. If Cp is an independent set for some r, then we can immediately conclude, since h(k) ≥ k. Hence, we suppose that Cp is a clique for every p ∈ {1, . . . , k − 1}. We now prove that C1, . . . , Ck−1 are Ramsey-extracted cliques of size h(k). First, by construction, for every j ∈ {1, . . . , h(k)}, the set {sp j : p = 1, . . . , k − 1} is We choose an arbitrary ordering of the vertices of each Sj. Let us denote by sr j , . . . , sp É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:15 Suppose that G has an independent set X∗ = {x∗ j : j ∈ J}. For the sake of readability, we keep the notation Cp to denote {sp an independent set. Then, let c be the type of the clique obtained previously, represented by the adjacencies between two sets (A, B), each of size k − 1. For every p ∈ {1, . . . , k − 1}, let ap (resp. bp) be the ath vertex of A (resp. B). Let p, q ∈ {1, . . . , t}, p 6= q. If any of apbq and aqbp are edges in type c, then there is no edge between Cp and Cq, and their relation is thus empty. If both edges apbq and aqbp exist in c, then the relation between Cp and Cq is full. Finally if exactly one edge among apbq and aqbp exists in c, then the relation between Cp and Cq is semi-full. This concludes the fact that C = {C1, . . . , Ck−1} are Ramsey-extracted cliques of size h(k). k}. Recall that we assumed previously that X∗ is contained in V (G) \ (C1 ∪ ··· ∪ Ck−1). The next step of the algorithm consists in branching on every subset of f(k) indices J ⊆ {1, . . . , h(k)}, and restrict every set Cp to {sp j : j ∈ J} (the non-selected vertices are put back in the set of remaining vertices of the graph, i.e. we do not delete them). Since h(k) = f(k)2k(k−1), there must exist a branching where the chosen indices are such that for every i ∈ {1, . . . , k} and every p ∈ {1, . . . , k − 1}, x∗ i is either adjacent to all vertices of Cp or none of them. In the remainder, we may thus assume that such a branching has been made, with respect to the considered solution X∗ = {x∗ k}. 1, . . . , x∗ Now, for every v ∈ V (G) \ (C1, . . . , Ck−1), if there exists p ∈ {1, . . . , k − 1} such that N(v) ∩ Cp 6= ∅ and N(v) ∩ Cp 6= Cp , then we can remove this vertex, as we know that it cannot correspond to any x∗ i . Thus, we know that all the remaining vertices v are such that for every p ∈ {1, . . . , k − 1}, v is either adjacent to all vertices of Cp, or none of them. In the following, we perform a color coding-based step on the remaining vertices. Inform- ally, this color coding will allow us to identify, for every vertex x∗ i of the optimal solution, a set Xi of candidates, with the property that all vertices in Xi have the same neighborhood with respect to sets C1, . . . , Ck−1. We thus color uniformly at random the remaining vertices V (G) \ (C1, . . . , Ck−1) using k colors. The probability that the elements of X∗ are colored with pairwise distinct colors is at least e−k. We are thus reduced to the case of finding a colorful8 independent set of size k. For every i ∈ {1, . . . , k}, let Xi be the vertices of V (G) \ (C1, . . . , Ck−1) colored with color i. We now partition every set Xi into at most 2k−1 subsets X1 i have the same neighborhood with respect to the sets C1, . . . , Ck−1 (recall that every vertex of V (G) \ (C1, . . . , Ck−1) is adjacent to all vertices of Cp or none, for each p ∈ {1, . . . , k − 1}). We branch on every tuple (j1, . . . , jk) ∈ {1, . . . , 2k−1}. Clearly the number of branchings is bounded by a function of k only and, moreover, one branching (j1, . . . , jk) is such that for every i ∈ {1, . . . , k}. i has the same neighborhood in C1 ∪ ··· ∪ Ck−1 as vertices of X ji x∗ We assume in the following that such a branching has been made. For every i ∈ {1, . . . , k}, i for every j 6= ji. For the sake of readability, we rename we can thus remove vertices of X j i as Xi. Let B be the bipartite graph with vertex bipartition (B1, B2), B1 = {b1 k}, 1, . . . , b1 X ji B2 = {b2 i has the same neighborhood as Xi with respect to C1, . . . , Ck−1, this bipartite graph actually corresponds to the one described in Definition 15 representing the adjacencies between Xi's and Cp's. We now prove that it is connected. Suppose it is not. Then, since B1 = k and B2 = k − 1, there must be a component with as many vertices from B1 as vertices from B2. However, in this case, using the fixed solution X∗ on one side and an independent set of size k − 1 in C1 ∪ ··· ∪ Ck−1 on the other side, it implies that there is an independent set of size k intersecting ∪k−1 , such that for every j ∈ {1, . . . , 2k−1}, all vertices of X j i , . . . , X2k−1 i 1, . . . , b2 k−1}, and b1 p ∈ E(B) iff x∗ i b2 i is adjacent to Cp. Since every x∗ p=1Cp, a contradiction. 8 A set of vertices is called colorful if it is colored with pairwise distinct colors. 1, . . . , x∗ i XX:16 Parameterized Complexity of Independent Set in H-Free Graphs Hence, all conditions of Definition 15 are now fulfilled. It now remains to find an independent set of size k disjoint from the sets C, and having a non-empty intersection with Xi, for every i ∈ {1, . . . , k}. We thus run an algorithm solving f-Ramsey-extracted (cid:74) Iterative Expansion MIS on this input, which concludes the algorithm. The proof of the following result is immediate, by using successively Lemmas 13 and 16. (cid:73) Theorem 17. Let G be a hereditary graph class. If f-Ramsey-extracted Iterative Expansion MIS is F P T in G for some computable function f, then MIS is F P T in G. We now apply this framework to two families of graphs H. 1, . . . , x∗ 4.2 Clique minus a smaller clique (cid:73) Theorem 18. For any r ≥ 2 and s < r, MIS in (Kr \ Ks)-free graphs is F P T if s ≤ 3, and W[1]-hard otherwise. Proof. The case s = 2 was already known [10]. The result for s ≥ 4 comes from Theorem 2. We now deal with the case s = 3. We solve the problem in (Kr+3 \ K3)-free graphs, for every r ≥ 2 (the problem is polynomial for r = 1, since it it corresponds exactly to the case of claw-free graphs). Let G, k be an input of the problem. We present an F P T algorithm for f-Ramsey-extracted Iterative Expansion MIS with f(x) = r for every x ∈ N. The result for MIS can then be obtained using Theorem 17. We thus assume that V (G) = X1∪···∪ Xk ∪ C1∪···∪ Ck−1 where all cliques Cp have size r. Consider the bipartite graph B representing the adjacencies between {X1, . . . , Xk} and {C1, . . . , Ck−1}, as in Definition 15 (for the sake of readability, we will make no distinction between the vertices of B and the sets {X1, . . . , Xk} and {C1, . . . , Ck−1}). We may first assume that Xi ≥ Ram(r, k) for every i ∈ {1, . . . , k}, since otherwise we can branch on every vertex v of Xi and make a recursive call with input G \ N[v], k − 1. Suppose that G contains an independent set S∗ = {x∗ k}, with xi ∈ Xi for all i ∈ {1, . . . , k}. The first step is to consider the structure of B, using the fact that G is (Kr \ K3)-free. We have the following: Claim: B is a path. Proof of claim: We first prove that for every i ∈ {1, . . . , k}, the degree of Xi in B is at most 2. Indeed, assume by contradiction that it is adjacent to Ca, Cb and Cc. Since Xi ≥ Ram(r, k), by Ramsey's theorem, it either contains an independent set of size k, in which case we are done, or a clique K of size r. However, observe in this case that K together with sa1, sb1 and sc1 (which are pairwise non-adjacent) induces a graph isomorphic to Kr+3 \ K3. Then, we show that for every i ∈ {1, . . . , k − 1}, the degree of Ci in B is at most 2. Assume by contradiction that Ci is adjacent to Xa, Xb and Xc. If the instance is positive, then there must be an independent set of size three with non-empty intersection with each of Xa, Xb and Xc. If such an independent set does not exist (which can be checked in cubic time), we can immediately answer NO. Now observe that Ci (which is of size r) together with this independent set induces a graph isomorphic to Kr+3 \ K3. To summarize, B is a connected bipartite graph of maximum degree 2 with k vertices in one part, k − 1 vertices in the other part. It must be a path. / W.l.o.g., we may assume that for every i ∈ {2, . . . , k − 1}, Xi is adjacent to Ci−1 and Ci, and that X1 (resp. Xk) is adjacent to C1 (resp. Ck−1). We now concentrate on the adjacencies between sets Xi's. We say that an edge xy ∈ E(G) is a long edge if x ∈ Xi, y ∈ Xj with j − i ≥ 2 and 2 ≤ i, j ≤ k − 1, i 6= j. É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:17 , sj 1 Claim: ∀x ∈ X2 ∪ ··· ∪ Xk−1, x is incident to at most (k − 2)(Ram(r, 3) − 1) long edges. Proof of claim: To do so, for i, j ∈ {2, . . . , k − 1} such that j − i ≥ 2, i 6= j, we prove that ∀x ∈ Xi, N(x) ∩ Xj ≤ Ram(r, 3) − 1. Assume by contradiction that x ∈ Xi has at least Ram(r, 3) neighbors Y ⊆ Xj. By Ramsey's theorem, either Y contains an independent set of size 3 or a clique of size r. In the first case, Cj together with these three vertices induces a graph isomorphic to Kr+3 \ K3. Hence we may assume that Y contains a clique Y 0 of size r. But in this case, Y 0 together with x, sj−1 1 induce a graph isomorphic to Kr+3 \ K3 as well. / Recall that the objective is to find an independent set of size k with non-empty intersection with Xi, for every i ∈ {1, . . . , k}. We assume k ≥ 5, otherwise the problem is polynomial. The algorithm starts by branching on every pair of non-adjacent vertices (x1, xk) ∈ X1 × Xk, and removing the union of their neihborhoods in X2 ∪···∪ Xk−1. For the sake of readability, we still denote by X2, . . . , Xk−1 these reduced sets. If such a pair does not exist or the removal of their neighborhood empties some Xi, then we immediately answer NO (for this branch). Informally speaking, we just guessed the solution within X1 and Xk (the reason for this is that we cannot bound the number of long edges incident to vertices of these sets). We now concentrate on the graph G0, which is the graph induced by X2 ∪ ··· ∪ Xk−1. Clearly, it remains to decide whether G0 admits an independent set of size k − 2 with non-empty intersection with Xi, for every i ∈ {2, . . . , k − 1}. The previous claim showed that the structure of G0 is quite particular: roughly speaking, the adjacencies between consecutive Xi's is arbitrary, but the number of long edges is bounded for every vertex. The key observation is that if there were no long edge at all, then a simple dynamic programming algorithm would allow us to conclude. Nevertheless, using the previous claim, we can actually upper bound the number of long edges incident to a vertex of the solution by a function of k only (recall that r is a constant). We can then get rid of these problematic long edges using the so-called technique of random separation [5]. Let S = {x2, . . . , xk−1} be a solution of our problem (with xi ∈ Xi for every i ∈ {2, . . . , k − 1}). Let us define D = {y : xy is a long edge and x ∈ S}. By the previous claim, we have D ≤ (Ram(r, 3) − 1)(k − 2)2. The idea of random separation is to delete each vertex of the graph with probability 1 2. At the end, we say that a removal is successful if both of the two following conditions hold: (i) no vertex of S has been removed, and (ii) all vertices of D have been removed (other vertices but S may have also been removed). Observe that the probability that a removal is successful is at least 2−k2Ram(r,3). In such a case, we can remove all remaining long edges: indeed, for a remaining long edge xy, we know that there exists a solution avoiding both x and y, hence we can safely delete x and y. As previously, we still denote by X2, . . . , Xk−1 the reduced sets, for the sake of readability. We thus end up with a graph composed of sets X2, . . . , Xk−1, with edges between Xi and Xj only if [j − i = 1. In that case, observe that there is a solution if and only if the following dynamic programming returns true on input P(3, x2) for some x2 ∈ X2:  true W P(i, xi−1) = f alse xi∈Xi\N(xi−1) P(i + 1, xi) if i = k if Xi ⊆ N(xi−1) otherwise. Clearly this dynamic programming runs in O(mnk) time, where m and n are the number of edges and vertices of the remaining graph, respectively. Moreover, it can easily be turned into an algorithm returning a solution of size k − 2 if it exists. Finally, similarly to classical random separation algorithms, it is sufficient to repeat this process O(2k2Ram(r)) times in order to obtain an F P T one-sided error Monte Carlo algorithm XX:18 Parameterized Complexity of Independent Set in H-Free Graphs with constant success probability. Moreover, such an algorithm can be derandomized up to an additional 2kkO(log k) factor in the running time [8]. (cid:74) independent sets S1, . . . , S3r, each of size k − 1. Let X =Sk 4.3 Clique minus a complete bipartite graph For every three positive integers r, s1, s2 with s1 + s2 < r, we consider the graph Kr \ Ks1,s2. Another way to see Kr \ Ks1,s2 is as a P3 of cliques of size s1, r − s1 − s2, and s2. More formally, every graph Kr \ Ks1,s2 can be obtained from a P3 by adding s1 − 1 false twins of the first vertex, r − s1 − s2 − 1, for the second, and s2 − 1, for the third. (cid:73) Theorem 19. For any r ≥ 2 and s1 ≤ s2 with s1 + s2 < r, MIS in Kr \ Ks1,s2-free graphs is FPT. Proof. It is more convenient to prove the result for K3r \ Kr,r-free graphs, for any positive integer r. It implies the theorem by choosing this new r to be larger than s1, s2, and r − s1 − s2. We will show that for f(x) := 3r for every x ∈ N, f-Ramsey-extracted Iterative Expansion MIS in K3r \ Kr,r-free graphs is FPT. By Theorem 17, this implies that MIS is FPT in this class. Let C1, . . . , Ck−1 (whose union is denoted by C) be the Ramsey-extracted cliques of size 3r, which can be partitionned, as in Definition 15, into 3r i=1 Xi be the set in which we are looking for an independent set of size k. We recall that between any Xi and any Cj there are either all the edges or none. Hence, the whole interaction between X and C can be described by the bipartite graph B described in Definition 15. Firstly, we can assume that each Xi is of size at least Ram(r, k), otherwise we can branch on Ram(r, k) choices to find one vertex in an optimum solution. By Ramsey's theorem, we can assume that each Xi contains a clique of size r (if it contains an independent set of size k, we are done). Our general strategy is to leverage the fact that the input graph is (K3r \ Kr,r)-free to describe the structure of X . Hopefully, this structure will be sufficient to solve our problem in FPT time. We define an auxiliary graph Y with k − 1 vertices. The vertices y1, . . . , yk−1 of Y represent the Ramsey-extracted cliques of C and two vertices yi and yj are adjacent iff the relation between Ci and Cj is not empty (equivalently the relation is full or semi-full). It might seem peculiar that we concentrate the structure of C, when we will eventually discard it from the graph. It is an indirect move: the simple structure of C will imply that the interaction between X and C is simple, which in turn, will severely restrict the subgraph induced by X . More concretely, in the rest of the proof, we will (1) show that Y is a clique, (2) deduce that B is a complete bipartite graph, (3) conclude that X cannot contain an induced K2 r = Kr ] Kr and run the algorithm of Theorem 11. Suppose that there is yi1yi2 yi3 an induced P3 in Y , and consider Ci1, Ci2, Ci3 the corresponding Ramsey-extracted cliques. For s < t ∈ [3r], let C s→t s(cid:54)j(cid:54)t Sj. In other words, C s→t contains the elements of Ci having indices between s and t. Since Ci = 3r, each Ci can be partitionned into three sets, of r elements each: C1→r , C r+1→2r and C2r+1→3r . Recall that the relation between Ci1 and Ci2 (resp. Ci2 and Ci3) is either full or semi-full, while the relation between Ci1 and Ci3 is empty. This implies that at least one of the four following sets induces a graph isomorphic to K3r \ Kr,r: := Ci ∩S i i i i i i2 i1 ∪ C r+1→2r C1→r i1 ∪ C r+1→2r C1→r C2r+1→3r C2r+1→3r ∪ C r+1→2r ∪ C r+1→2r ∪ C1→r ∪ C2r+1→3r ∪ C1→r ∪ C2r+1→3r i2 i3 i1 i3 i3 i1 i2 i2 i3 É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:19 Figure 6 The gem. i ∈ B2 and b2 Recall that the bipartite graph B is connected. Thus there is b1 Hence, Y is a disjoint union of cliques. Let us assume that Y is the union of at least two (maximal) cliques. h ∈ B1 (corresponding to j ∈ B2 (corresponding to Ci and Cj, respectively), such that Xh) adjacent to b2 yi and yj lie in two different connected components of Y (in particular, the relation between Ci and Cj is empty). Recall that Xh contains a clique of size at least r. This clique induces, together with any r vertices in Ci and any r vertices in Cj, a graph isomorphic to K3r \ Kr,r; a contradiction. Hence, Y is a clique. Now, we can show that B is a complete bipartite graph. Each Xh has to be adjacent to at least one Ci (otherwise this trivially contradicts the connectedness of B). If Xh is not linked to Cj for some j ∈ {1, . . . , k − 1}, then a clique of size r in Xh (which always exists) induces, together with C1→r , a graph isomorphic to K3r \ Kr,r. Since B is a complete bipartite graph, every vertex of C1 dominates all vertices of X In particular, X is in the intersection of the neighborhood of the vertices of some clique of size r. This implies that the subgraph induced by X is (Kr ] Kr)-free. Hence, we can run the (cid:74) FPT algorithm of Theorem 11 on this graph. or with C2r+1→3r ∪ C2r+1→3r ∪ C1→r j i j i 4.4 The gem Let the gem be the graph obtained by adding a universal vertex to a path on four vertices (see Figure 6). Using our framework once again, we are able to obtain the following result: (cid:73) Theorem 20. There is a randomized F P T algorithm for MIS in gem-free graphs. Proof. Let f(x) := 1 for every x ∈ N. We prove that f-Ramsey-extracted Iterative Expansion MIS admits a randomized F P T in gem-free graphs. By the definition of f, we have Cp = {cp} for every p ∈ {1, . . . , k − 1}. Recall that the objective is to find a rainbow independent set in G, or to decide that a α(G) < k. Since the bipartite graph B representing the adjacencies between {X1, . . . , Xk} and {c1, . . . , ck−1} is connected, it implies that for every i ∈ {1, . . . , k}, there exists p ∈ {1, . . . , k − 1} such that cp dominates all vertices of Xi. Since G is gem-free, it implies that G[Xi] is P4-free for every i ∈ {1, . . . , k}. Since P4-free graphs (a.k.a cographs) are perfect, the size of a maximum independent set equals the size of a clique cover. If G[Xi] contains an independent set of size k (which can be tested in polynomial time), then we are done. Otherwise, we can, still in polynomial time, partition the vertices of Xi into at most k − 1 sets X1 i ] induces a clique for every j ∈ {1, . . . , qi}. We now perform a branching for every tuple (j1, . . . , jk), where ji ∈ {1, . . . , qi} for every i ∈ {1, . . . , k}, which, informally, allows us to guess the clique i which contains the element of the rainbow independent set we are looking for. For the X ji sake of readability, we allow ourselves this slight abuse of notation: we rename X ji into simply Xi. Thus, for every i ∈ {1, . . . , k}, G[Xi] is a clique. i , where G[X j i , . . . , X qi i XX:20 Parameterized Complexity of Independent Set in H-Free Graphs Figure 7 Schema of the adjacencies between Xi and Xi when they do not contain a balanced diamond (q = 6). An edge represent a complete relation between the corresponding subsets. Now, let i, j ∈ {1, . . . , k}, i 6= j. Let us analyse the adjacencies between Xi and Xj. We say that {a, b, c, d} ⊆ Xi ∪ Xj is a balanced diamond if a, b ∈ Xi (a 6= b), c, d ∈ Xj (c 6= d) and all vertices {a, b, c, d} are pairwise adjacent but {b, d}. We have the following claim: Claim: If the graph induced by Xi ∪ Xj has a balanced diamond, then Xi and Xj are twins in B. Proof of claim: Suppose they are not. W.l.o.g. we assume that Xi is adjacent to {cp} while Xj is not, for some p ∈ {1, . . . , k − 1}. Then the vertices of the balanced diamond together with cp induce a gem. / The remainder of the proof consists of "cleaning" the adjacencies (Xi, Xj) having no balanced diamond. In that case, observe that Xi and Xj can respectively be partitioned into i , X1 j are potentially empty) such that X0 i ∪ X r i and X r0 X r whenever r 6= r0 or r = 0 or r0 = 0 (see Figure 7). In each branch of the next branching rule, the sets {X1, . . . , Xk} will be modified into {X0 i , . . . , X q j induces a clique for every r ∈ {1, . . . , q}, and there is no edge between X r j (where X0 j , . . . , X q i and X0 i and X0 k}. 1, . . . , X0 j , X1 j Branching rule: Let i, j ∈ {1, . . . , k}, i 6= j such that Xi ∪ Xj has no balanced diamond. Then perform the following branching: Branch 1: X0 Branch 2: X0 Branch 3: pick a set T ⊆ {1, . . . , q} uniformly at random, then: z = Xz for z ∈ [k] \ {i} z = Xz for z ∈ [k] \ {j} i and X0 j and X0 i = X0 j = X0 i =S j =S X0 X0 z = Xz for z ∈ [k] \ {i, j} X0 r∈T X r i r /∈T X r j Consider the graph G(X1, . . . , Xk) having one vertex per set Xi, and an edge between Xi and Xj if these two sets are adjacent. We now prove the following: Claim: The graph G(X0 Proof of claim: In all three branches, observe that there is no edge between X0 k) has one edge less than G(X1, . . . , Xk) 1, . . . , X0 i and X0 j. / Claim: If G has independent set of size k, then no graph obtained after the branching contains an independent set of size k. Proof of claim: Observe that in all branches, Sk z ⊆ Sk z=1 X0 z=1 Xz, that is, each graph / obtained in each branch is an induced subgraph of G. Claim: If G has a rainbow independent set, then with probability at least 1 branch leads to a graph having a rainbow independent set. 2, at least one X0iX1iX2iX3iX4iX5iX6iX6jX5jX4jX3jX2iX1jX0j É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:21 Proof of claim: Suppose that G contains a rainbow independent set S∗. If S∗ intersects X0 i , then S∗ also exists in the graph of the first branch. If S∗ intersects X0 j , then S∗ also exists in the graph of the second branch. The last case is where S∗ intersects X r1 j , for some r1, r2 ∈ {1, . . . q}. In that case, there is a probability of 1 2 that r1 ∈ T and r2 /∈ T, which concludes the proof of the claim i and X r2 Claim 4.4 implies that each connected component of the graph induced by Sk / We may now assume that the previous branching rule cannot apply. For the sake of readability, we keep the notation X1, . . . , Xk in order to denote our instance, even after an eventual application of the previous branching rule. For every Xi, Xj with i 6= j, there is either (i) no edge between Xi and Xi, or (ii) a balanced diamond induced by Xi ∪ Xj. Hence, i=1 Xi is a module with respect to the clique {c1, . . . , ck−1}. In particular, each connected component is dominated by some cp, with p ∈ {1, . . . , k − 1}, and is thus P4-free (otherwise, a P4 together with this vertex cp induce a gem), which means that we can decide in polynomial time whether G contains an independent set of size k, by deciding the problem in every connected component separately. By Claim 4.4, the previous branching rule can be applied at most(cid:0)k (cid:1) times. Hence, by Claim 4.4, if G contains a rainbow independent set, then our algorithm will find such a set 1 with probability at least 2k2 . Finally, by Claim 4.4, if G does not contain any independent set of size k, then our algorithm will answer "No". This proves that our algorithm is a one-sided 1 error Monte Carlo algorithm with success probability at least 2k2 , which can be turned into a randomized F P T algorithm for f-Ramsey-extracted Iterative Expansion MIS. (cid:74) 2 5 Polynomial (Turing) kernels In this section we investigate some special cases of Section 4.3, in particular when H is a clique of size r minus a claw with s branches, for s < r. Although Theorem 19 proves that MIS is FPT for every possible values of r and s, we show that when s ≥ r − 2, the problem admits a polynomial Turing kernel, while for s ≤ 2, it admits a polynomial kernel. Notice that the latter result is somehow tight, as Corollary 28 shows that MIS cannot admit a polynomial kernel in (Kr \ K1,s)-free graphs whenever s ≥ 3. 5.1 Positive results The main ingredient of the two following results is a constructive version of the Erdös-Hajnal theorem for the concerned graph classes: (cid:73) Lemma 21 (Constructive Erdös-Hajnal for Kr \ K1,s). For every r ≥ 2 and s < r, there exists a polynomial-time algorithm which takes as input a connected (Kr \ K1,s)-free graph 1 G, and construct either a clique or an independent set of size n r−1 , where n is the number of vertices of G. Proof. First consider the case s = r − 1, i.e. the forbidden graph is Kr−1 plus an isolated r−2 vertex. r−1 , then, since G[N] is Kr−1-free, by Ramsey's theorem, it must contains an independent set of size N 1 1 r−1 , which can be found in polynomial time. We may now assume that the r−1 − 1. We construct a clique v1, . . . , vq in G by picking an maximum non-degree9 of G is n If G contains a vertex v with non-neighborhood N of size at least n r−2 = n r−2 9 The non-degree of a vertex is the size of its non-neighborhood. XX:22 Parameterized Complexity of Independent Set in H-Free Graphs r−2 n r−2 r−1 n arbitrary vertex v1, removing its non-neighborhood, then picking another vertex v2, removing its non-neighborhood, and repeating this process until the graph becomes empty. Using 1 the above argument on the maximum non-degree, this process can be applied r−1 times, corresponding to the size of the constructed clique. = n n r−2 r−1 n = n r−2 = n Now, we make an induction on r − 1− s (the base case is above). If G contains a vertex v r−1 , then, since G[N] is (Kr−1 \ Ks)-free, by induction with neighborhood N of size at least n it admits either a clique or an independent set of size N 1 1 r−1 , which can be found r−1 − 1. We r−2 in polynomial time. We may now assume that the maximum degree of G is n construct an independent set v1, . . . , vq in G by picking an arbitrary vertex v1, removing its neighborhood, and repeating this process until the graph becomes empty. Using the 1 r−1 times, above argument on the maximum degree, this process can be applied (cid:74) corresponding to the size of the constructed independent set. (cid:73) Theorem 22. ∀r ≥ 2, MIS in (Kr \ K1,r−2)-free graphs has a polynomial Turing kernel. Proof. The problem is polynomial for r = 2 and r = 3, hence we suppose r ≥ 4. Suppose we have an algorithm A which, given a graph J and an integer i such that V (J) = O(ir−1), decides whether J has an independent set of size i in constant time. Having a polynomial algorithm for MIS assuming the existence of A implies a polynomial Turing kernel for the problem [8]. To do so, we will present an algorithm B which, given a connected graph G and an integer k, outputs a polynomial (in V (G)) number of instances of size O(kr−1), such that one of them is positive iff the former one is. With this algorithm in hand, we obtain the polynomial Turing kernel as follows: let G and k be an instance of MIS. Let V1, . . . , V' be the connected components of G. For every j ∈ {1, . . . , '}, we determine the size of a maximum independent set kj of G[Vj] by first invoking, for successive values i = 1, . . . , k, the algorithm B on input (G[Vj], i), and then A on each reduced instance. At the end of the We now describe the algorithm B. Let (G, k) be an input, with n = V (G). By Lemma 21, 1 we start by constructing a clique C of size at least n r−1 in polynomial time. We assume that C > r2, since otherwise the instance is already reduced. Let B = N(C). First observe that for every u ∈ B, NC(u) ≥ C − (r − 3). Indeed, if NC(u) ≤ C − (r − 2), then the graph induced by r − 2 non-neighbors of u in C together with u and a neighbor of u in C (which exists since C > r2) is isomorphic to Kr \ K1,r−2. Secondly, we claim that V (G) = C ∪ B: for the sake of contradiction, take v ∈ N(B)\ C, and let u ∈ B be such that uv ∈ E(G). By the previous argument, u has at least C−r+3 ≥ r−2 neighbors in C which, in addition to u and v, induce a graph isomorphic to Kr \ K1,r−2. The algorithm outputs, for every u ∈ B, the graph induced by B \ N[u], and, for every u ∈ B and every v ∈ C such that uv /∈ E(G), the graph induced by B \ (N[u] ∪ N[v]). The correctness of the algorithm follows from the fact that if G has an independent set S of size k > 1, then either: algorithm, we answer Y ES iffP' j=1 ki ≥ k. S ∩ C = ∅, in which case S lies entirely in B \ N[u] for any u ∈ S, or S ∩ C = {v} for some v ∈ C, in which case S \ {v} lies entirely in B \ (N[u] ∪ N[v]) for any u ∈ S ∩ B. We now argue that each of these instances has O(kr−3) vertices. To do so, observe that for any u ∈ B, B \ N[u] does not contain Kr−2 as an induced subgraph: indeed, since C > r2, then any set of r−2 vertices of B must have a common neighbor in C. Taking a clique of size r − 2 in B together with its common neighbor in C and u would induce a graph isomorphic to Kr \ K1,r−2. Since each of these instances is Kr−2-free, applying Ramsey's theorem to É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:23 each of them allows us to either construct an independent set of size k − 1 in one of them (and thus output an independent set of size k in G), or to prove that each of them has at most O(kr−3) vertices. At the end, this algorithm outputs O(n2) instances, each having (cid:74) O(kr−3) vertices. Since a (Kr \ K1,r−1)-free graph is (Kr−1 \ K1,r−2)-free, we have the following: (cid:73) Corollary 23. ∀r ≥ 2, MIS in (Kr \ K1,r−1)-free graphs has a polynomial Turing Kernel. In other words, (Kr \ K1,r−1) is a clique of size r−1 plus an isolated vertex. Observe that the previous corollary can actually be proved in a very simple way: informally, we can "guess" a vertex v of the solution, and return its non-neighborhood together with parameter k − 1. Since this non-neighborhood is Kr−1-free, it can be reduced to a O(kr−2)-sized instance. This is perhaps the most simple example of a problem admitting a polynomial Turing kernel but no polynomial kernel10 (as we will prove later in Theorem 27). By considering the complement of graphs, it implies the even simpler following observation: Maximum Clique has a O(k2) Turing kernel on claw-free graphs, but no polynomial kernel10. (cid:73) Theorem 24. ∀r ≥ 3, MIS in (Kr \ K1,2)-free graphs has a kernel with O(kr−1) vertices. Proof. For r = 3, the problem is polynomial, so we assume r ≥ 4. The algorithm consists in 1 constructing, by Lemma 21, a clique C of size at least n r−1 in polynomial time. We present a reduction rule in the case C > (k − 1)(r − 4) + 1. If this rule cannot apply, then it means that the number of vertices of the reduced instance is O(kr−1). First observe that for every u ∈ N(C), then either NC(u) = C − 1, or NC(u) ≤ r − 4. Indeed, suppose that r − 3 ≤ NC(u) ≤ C − 2. Then u together with r − 3 of its neighbors in C and 2 of its non-neighbors in C induce a graph isomorphic to Kr \ K1,2, a contradiction. Let B = {u ∈ N(C) : NC(u) = C − 1} and D = {u ∈ N(C) : NC(u) ≤ r − 4}. We claim that C ∪ B is a complete C-multipartite graph. To do so, we prove that for u, v ∈ B, NC(u) = NC(v) implies uv /∈ E(G), and NC(u) 6= NC(v) implies uv ∈ E(G). Suppose that NC(u) = NC(v) = {x}. If uv ∈ E(G), then u, v, x together with r − 3 vertices of C different from x induce a graph isomorphic to Kr \ K1,2, which is impossible. Suppose now that NC(u) = xu 6= xv = NC(v). If uv /∈ E(G), then u, v, xu together with r−3 vertices of C different from xu and xv induce a graph isomorphic to Kr \ K1,2, which is impossible. Thus, we now write C ∪ B = S1 ∪ ··· ∪ SC, where, for every i, j ∈ {1, . . . ,C}, i 6= j, Si induces an independent set, and Si ∪ Sj induces a complete bipartite graph. We assume S1 ≥ S2 ≥ ··· ≥ SC. Recall that C > (k − 1)(r − 4) + 1. Using the same arguments as previously, we can show that every vertex of D is adjacent to at most r − 4 different parts among C ∪ B. More formally: for every u ∈ D, we have {Si : N(u) ∩ Si 6= ∅} ≤ r − 4. Let q = (k − 1)(r − 4) + 1. The reduction consists in removing Sq+1 ∪ ··· ∪ SC. Clearly it runs in polynomial time. Let G0 denote the reduced instance. Obviously, if G0 has an independent set of size k, then G does, since G0 is an induced subgraph of G. It remains to show that the converse is also true. Let X be an independent set of G of size k. If X ∩(cid:16)∪C an independent set of size k in G0, thus we suppose X ∩(cid:16)∪C since C ∪ B is a multipartite graph, there is a unique i ∈ {1, . . . ,C} such that X ∩ Si 6= ∅, and i ≥ q + 1. Since every vertex of D is adjacent to at most r − 4 parts of C ∪ B, and (cid:17) = ∅, then X is also (cid:17) = Xr 6= ∅. In particular, i=q+1Si i=q+1Si 10 Unless N P ⊆ coN P/poly. XX:24 Parameterized Complexity of Independent Set in H-Free Graphs since q = (k − 1)(r − 4) + 1, there must exist j ∈ {1, . . . , q} such that N(X ∩ D) ∩ Sj = ∅. Moreover, Sj ≥ Si. Hence, (X \ Si) ∪ Sj is an independent set of size at least k in G0. (cid:74) Observe that a (Kr \ K2)-free graph is (Kr+1 \ K1,2)-free, hence we have the following, which answers a question of [10]. (cid:73) Corollary 25. ∀r ≥ 1, MIS in (Kr \ K2)-free graphs has a kernel with O(kr−1) vertices. 5.2 Kernel lower bounds (cid:73) Definition 26. Given the graphs H, H1, . . . , Hp, we say that (H1, . . . , Hp) is a multipartite decomposition of H if H is isomorphic to H1 +···+ Hp. We say that (H1, . . . , Hp) is maximal if, for every multipartite decomposition (H0 q) of H, we have p > q. 1, . . . , H0 It can easily be seen that for every graph H, a maximal multipartite decomposition of H is unique. We have the following: (cid:73) Theorem 27. Let H be any fixed graph, and let H = H1 + ··· + Hp be the maximal multipartite decomposition of H. If, for some i ∈ [p], MIS is NP-hard in Hi-free graphs, then MIS does not admit a polynomial kernel in H-free graphs unless NP ⊆ coNP/poly. Proof. We construct an OR-cross-composition from MIS in Hi-free graphs. For more details about cross-compositions, see [4]. Let G1, . . . , Gt be a sequence of Hi-free graphs, and let G0 = G1 + ··· + Gt. Then we have the following: α(G0) = maxi=1...t α(Gi), since, by construction of G0, any independent set cannot intersect the vertex set of two distinct graphs Gi and Gj. G0 is H-free. Indeed, suppose that X ⊆ V (G0) induces a graph isomorphic to H, and let Xj = X ∩ V (Gj) for every j ∈ [p]. Then observe that the graphs induced by the non-empty sets Xj form a multipartite decomposition of H, and thus there must exist j ∈ [p] such that Gj[Xj] contains Hi as an induced subgraph, a contradiction. These two arguments imply a cross-composition from MIS in Hi-free graphs to MIS in (cid:74) H-free graphs. The next results shows that the polynomial kernel obtained in the previous section for (Kr \ K1,s)-free graphs, s ≤ 2, is somehow tight. (cid:73) Corollary 28. For r ≥ 4, and every 3 ≤ s ≤ r − 1, MIS in (Kr \ K1,s)-free graphs does not admit a polynomial kernel unless NP ⊆ coNP/poly. Proof. In that case, observe that the maximal multipartite decomposition of Kr \ K1,s is z r−1−s times K1 + ··· + K1 Ks + } { where Ks denotes the clique of size s plus an isolated vertex. Moreover, MIS is NP-hard in Ks-free graphs for s ≥ 3. (cid:74) We conjecture that Theorem 27 actually captures all possible negative cases concerning the kernelization of the problem. Informally speaking, our intuition is the natural idea that the join operation between graphs seems the only way to obtain α(G) = O(maxi=1,...,t α(Gi)), which is the main ingredient of OR-compositions. (cid:73) Conjecture 29. Let H be any fixed graph, and H = H1+···+Hp be its maximal multipartite decomposition. Then, assuming that N P 6⊆ coN P/poly, MIS admits a polynomial kernel in H-free graphs if and only if it is polynomial in Hi-free graph, for every i ∈ [p]. É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:25 Conclusion and open problems 6 We started to unravel the FPT/W[1]-hard dichotomy for MIS in H-free graphs, for a fixed graph H. At the cost of one reduction, we showed that it is W[1]-hard as soon as H is not chordal, even if we simultaneously forbid induced K1,4 and trees with at least two branching vertices. Tuning this construction, it is also possible to show that if a connected H is not roughly a "path of cliques" or a "subdivided claw of cliques", then MIS is W[1]-hard. More formally, with the definitions of Section 2.2, the remaining connected open cases are when H has an almost strong clique decomposition on a subdivided claw or a nearly strong clique decomposition on a path. In this language, we showed that for every connected graph H with a strong clique decomposition on a P3, there is an FPT algorithm. However, we also proved that for a very simple graph H with a strong clique decomposition on the claw, MIS is W[1]-hard. This suggests that the FPT/W[1]-hard dichotomy will be somewhat subtle. For instance, easy cases for the parameterized complexity do not coincide with easy cases for the classical complexity where each vertex can be blown into a clique. For graphs H with a clique decomposition on a path, the first unsolved cases are H having: an almost strong clique decomposition on P3; a nearly strong clique decomposition on P3; a strong clique decomposition on P4. For graphs H with a clique decomposition on the claw, an interesting open question is the case of cricket-free graphs (T1,1,2-free with our notation defined before Theorem 10), and, more generally, in T1,1,s-free graphs. For disconnected graphs H, we obtained an FPT algorithm when H is a cluster (i.e., a disjoint union of cliques). We conjecture that, more generally, the disjoint union of two easy cases is an easy case; formally, if MIS is FPT in G-free graphs and in H-free graphs, then it is FPT in G ] H-free graphs. A natural question regarding our two F P T algorithms of Section 4 concerns the existence of polynomial kernels. In particular, we even do not know whether the problem admits a kernel for very simple cases, such as when H = K5 \ K3 or H = K5 \ K2,2. A more anecdotal conclusion is the fact that the parameterized complexity of the problem on H-free graphs is now complete for every graph H on four vertices, including concerning the polynomial kernel question (see Figure 8). References 1 V. Alekseev. The effect of local constraints on the complexity of determination of the graph independence number. Combinatorial-Algebraic Methods in Applied Mathematics, pages 3 -- 13, 1982. in Russian. 2 V. E. Alekseev. On the number of maximal independent sets in graphs from hereditary classes. Combinatorial-Algebraic Methods in Discrete Optimization, pages 5 -- 8, 1991. (In Russian). 3 G. Bacsó, D. Lokshtanov, D. Marx, M. Pilipczuk, Z. Tuza, and E. Jan van Leeuwen. Subexponential-time algorithms for maximum independent set in $p_t$-free and broom- free graphs. CoRR, abs/1804.04077, 2018. 4 H. L. Bodlaender, B. M. P. Jansen, and S. Kratsch. Kernelization lower bounds by cross- composition. SIAM J. Discrete Math., 28(1):277 -- 305, 2014. L. Cai, S. M. Chan, and S. O. Chan. Random separation: A new method for solving fixed-cardinality optimization problems. In Proceedings of the 2nd International Workshop on Parameterized and Exact Computation (IWPEC), pages 239 -- 250, 2006. 5 XX:26 Parameterized Complexity of Independent Set in H-Free Graphs Graph P PK PTK FPT Obvious Obvious Obvious [2] [20] [7] Thm. 1 Ramsey Thm. 1 Cor. 25 Thm. 1 Thm. 24 Cor. 28 Cor. 23 Thm. 2 Figure 8 Status of the problem for graphs H on four vertices. P , P K, P T K respectively stand for Polynomial, N P -hard but admits a polynomial kernel, and no polynomial kernel unless N P ⊆ coN P/poly but admits a polynomial Turing kernel. É. Bonnet, N. Bousquet, P. Charbit, S. Thomassé, R. Watrigant XX:27 6 J. Chen, Y. L., S. Lu, S. S., and F. Zhang. improved algorithm for 3d-matching. ACM Trans. Algorithms, 8(1):6:1 -- 6:22, 2012. Iterative expansion and color coding: An 7 D. G. Corneil, Y. Perl, and L. K. Stewart. A linear recognition algorithm for cographs. SIAM J. Comput., 14(4):926 -- 934, 1985. 8 M. Cygan, F. V. Fomin, L. Kowalik, D. Lokshtanov, D. Marx, M. Pilipczuk, M. Pilipczuk, and S. Saurabh. Parameterized Algorithms. Springer, 2015. 9 K. Dabrowski. Structural Solutions to Maximum Independent Set and Related Problems. PhD thesis, University of Warwick, 2012. 10 K. Dabrowski, V. V. Lozin, H. Müller, and D. Rautenbach. Parameterized complexity of the weighted independent set problem beyond graphs of bounded clique number. J. Discrete Algorithms, 14:207 -- 213, 2012. 11 R. Diestel. Graph Theory, 4th Edition, volume 173 of Graduate texts in mathematics. 12 R. G. Downey and M. R. Fellows. Fundamentals of Parameterized Complexity. Texts in Springer, 2012. Computer Science. Springer, 2013. 13 H. Perret du Cray and I. Sau. Improved FPT algorithms for weighted independent set in bull-free graphs. Discrete Mathematics, 341(2):451 -- 462, 2018. 14 M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, 1979. 15 A. Grzesik, T. Klimosova, M. Pilipczuk, and M. Pilipczuk. Polynomial-time algorithm for maximum weight independent set on P6-free graphs. CoRR, abs/1707.05491, 2017. 16 D. Hermelin, M. Mnich, and E. J. van Leeuwen. Parameterized complexity of induced graph matching on claw-free graphs. Algorithmica, 70(3):513 -- 560, 2014. 17 T. Karthick. Independent sets in some classes of Si,j,k-free graphs. J. Comb. Optim., 34(2):612 -- 630, August 2017. 18 T. Karthick and F. Maffray. Maximum weight independent sets in classes related to claw- free graphs. Discrete Applied Mathematics, 216:233 -- 239, 2017. 19 D. Lokshtanov, M. Vatshelle, and Y. Villanger. Independent set in P5-free graphs in polynomial time. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, pages 570 -- 581, 2014. 20 G. J. Minty. On maximal independent sets of vertices in claw-free graphs. Journal of Combinatorial Theory, Series B, 28(3):284 -- 304, 1980. 21 B. Reed, K. Smith, and A. Vetta. Finding odd cycle transversals. Operations Research Letters, 32(4):299 -- 301, 2004. S. Thomassé, N. Trotignon, and K. Vuskovic. A polynomial turing-kernel for weighted independent set in bull-free graphs. Algorithmica, 77(3):619 -- 641, 2017. 23 D. Zuckerman. Linear degree extractors and the inapproximability of max clique and 22 chromatic number. Theory of Computing, 3(1):103 -- 128, 2007.
1901.03744
3
1901
2019-10-16T22:24:31
Exponentially Faster Massively Parallel Maximal Matching
[ "cs.DS", "cs.DC" ]
The study of approximate matching in the Massively Parallel Computations (MPC) model has recently seen a burst of breakthroughs. Despite this progress, however, we still have a far more limited understanding of maximal matching which is one of the central problems of parallel and distributed computing. All known MPC algorithms for maximal matching either take polylogarithmic time which is considered inefficient, or require a strictly super-linear space of $n^{1+\Omega(1)}$ per machine. In this work, we close this gap by providing a novel analysis of an extremely simple algorithm a variant of which was conjectured to work by Czumaj et al. [STOC'18]. The algorithm edge-samples the graph, randomly partitions the vertices, and finds a random greedy maximal matching within each partition. We show that this algorithm drastically reduces the vertex degrees. This, among some other results, leads to an $O(\log \log \Delta)$ round algorithm for maximal matching with $O(n)$ space (or even mildly sublinear in $n$ using standard techniques). As an immediate corollary, we get a $2$ approximate minimum vertex cover in essentially the same rounds and space. This is the best possible approximation factor under standard assumptions, culminating a long line of research. It also leads to an improved $O(\log\log \Delta)$ round algorithm for $1 + \varepsilon$ approximate matching. All these results can also be implemented in the congested clique model within the same number of rounds.
cs.DS
cs
Exponentially Faster Massively Parallel Maximal Matching∗ Soheil Behnezhad† [email protected] MohammadTaghi Hajiaghayi† David G. Harris† [email protected] [email protected] Abstract The study of approximate matching in the Massively Parallel Computations (MPC) model has recently seen a burst of breakthroughs. Despite this progress, however, we still have a far more limited understanding of maximal matching which is one of the central problems of parallel and distributed computing. All known MPC algorithms for maximal matching either take polylogarithmic time which is considered inefficient, or require a strictly super-linear space of n1+Ω(1) per machine. In this work, we close this gap by providing a novel analysis of an extremely simple algo- rithm a variant of which was conjectured to work by Czumaj et al. [STOC'18]. The algorithm edge-samples the graph, randomly partitions the vertices, and finds a random greedy maximal matching within each partition. We show that this algorithm drastically reduces the vertex degrees. This, among some other results, leads to an O(log log ∆) round algorithm for maximal matching with O(n) space (or even mildly sublinear in n using standard techniques). As an immediate corollary, we get a 2 approximate minimum vertex cover in essentially the same rounds and space. This is the best possible approximation factor under standard assumptions, culminating a long line of research. It also leads to an improved O(log log ∆) round algorithm for 1 + ε approximate matching. All these results can also be implemented in the congested clique model within the same number of rounds. 9 1 0 2 t c O 6 1 ] S D . s c [ 3 v 4 4 7 3 0 . 1 0 9 1 : v i X r a ∗ A preliminary version of this paper is to appear in the proceedings of The 60th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2019). † Department of Computer Science, University of Maryland, College Park, MD 20742. 1 1 Introduction The success of modern parallel frameworks such as MapReduce [17], Hadoop [35], or Spark [37] has resulted in an active area of research over the past few years for understanding the true computa- tional power of such systems. The Massively Parallel Computations (MPC) model, which provides a clean abstraction of these frameworks, has become the standard theoretical model for this purpose (see Section 2.2 for the model). In this work, we consider the maximal matching problem in the MPC model. It is one of the most fundamental graph problems in parallel and distributed computing with far reaching practical and theoretical implications. The study of maximal matching can be traced back to PRAM algorithms of 1980s [30, 23, 3] and has been studied in various computational models since then. In the MPC model, maximal matching is particularly important; an algorithm for it directly gives rise to algorithms for 1 + ε approximate maximum matching, 2 + ε approximate maximum weighted matching, and 2 approximate minimum vertex cover with essentially the same number of rounds and space. Each of these problems has been studied on its own [16, 5, 20, 6, 7, 13, 33, 2]. using nΩ(1) space. This bound was recently improved by Ghaffari and Uitto [21] to (cid:101)O( Known bounds. For many graph problems, including maximal matching, O(log n) round MPC algorithms can be achieved in a straightforward way by simulating PRAM algorithms [30, 23, 3] log ∆) rounds with the same memory. The main goal, however, is to obtain significantly faster (i.e., subpolylogarithmic round) algorithms by further utilizing MPC's additional powers. √ Currently, the only known such algorithm for maximal matching is that of Lattanzi et al. [27] which requires O(1/δ) rounds using a space of O(n1+δ). Their algorithm's round complexity, however, blows up back to Θ(log n) as soon as memory becomes O(n). In comparison, due to a breakthrough of Czumaj et al. [16], we have algorithms for 1 + ε approximate matching that take O(log log n) rounds using a space of O(n) [16, 20, 6]. Unfortunately, this progress on approximate matching offers no help for maximal matching or related problems. In fact, these algorithms also require up to Ω(log n) rounds to maintain maximality. In this paper, we give MPC algorithms for maximal matching that are expo- Our contribution. nentially faster than the state-of-the-art (we describe our precise results in Section 1.1). We achieve this by providing a novel analysis of an extremely simple and natural algorithm. The algorithm edge-samples the graph, randomly partitions the vertices into disjoint subsets, and finds a greedy maximal matching within the induced subgraph of each partition. This parti- tioning is useful since each induced subgraph can be sent to a different machine. We show that if we commit the edges of each of these greedy matchings to the final output, the vertex degrees in the residual graph are drastically dropped. Czumaj et al. [16] had conjectured that a variant of this algorithm might work and left its analysis as one of their main open problems:1 "Finally, we suspect that there is a simpler algorithm for the problem [...] by simply greedily matching high-degree vertices on induced subgraphs [...] in every phase. Unfor- tunately, we do not know how to analyze this kind of approach." [16] We summarize our results and their implications in Section 1.1 and give a high-level overview of the analysis in Section 1.2. 1A more detailed variant of the algorithm was also described in the following TCS+ talk by Artur Czumaj (starts from 1:03:23): https://youtu.be/eq0jwAnJu9c?t=3803. 2 1.1 Main Results Theorem 1 (main result). Given an n-vertex graph G with m edges and max degree ∆, there exists a randomized MPC algorithm for computing a maximal matching that (1) takes O(log log ∆) rounds using O(n) space per machine, (2) or takes O(log 1 δ ) rounds using O(n1+δ) space per machine, for any parameter δ ∈ (0, 1). The algorithm succeeds w.e.h.p.a and requires an optimal total space of O(m). aWe say an event occurs with exponentially high probability (w.e.h.p.) if it occurs with probability 1− e−nΩ(1) . Theorem 1 part (1) provides the first subpolylogarithmic round MPC algorithm for maximal matching that does not require a super-linear space in n. In fact, it improves exponentially over the prior algorithms in this regime, which all take polylogarithmic rounds [30, 27, 21]. Furthermore, Theorem 1 part (2) exponentially improves over the δ-dependency of Lattanzi et al.'s algorithm [27] which requires O(1/δ) rounds using O(n1+δ) space. Theorem 2. Given an n-vertex graph G with m edges and max degree ∆, there exists an MPC algorithm for computing a maximal matching that takes O(log log ∆ + log log log n) rounds and uses n/2Ω( log n) space per machine. The algorithm succeeds w.e.h.p. and uses a total space of O(m + n1+γ) for any constant γ > 0. √ Theorem 2 further improves the space per machine to mildly sublinear with the same round complexity (ignoring the lower terms). We comment that the n/2Ω( log n) space usage here goes below the n/ poly log n space that has commonly been considered for problems such as approximate matching [16, 20, 6] and graph connectivity [8]. √ Other implications. Our algorithm also has a few other implications when used as a black-box. Corollary 1.1. By a well-known reduction, the set of matched vertices in a maximal matching is a 2-approximation of minimum vertex cover. As such, all algorithms of Theorems 1 and 2 can be applied to the 2-approximate minimum vertex cover problem as well. The problem of whether an approximate vertex cover can be found faster in MPC with O(n) space was first asked by Czumaj et al. [16]. Subsequent works showed that indeed O(log log n) algorithms are achievable and the approximation factor has been improved from O(log n) to O(1) to 2 + ε [5, 20, 6]. Corollary 1.1 reaches a culminating point: If we restrict the machines to run a polynomial-time algorithm, which is a standard assumption (see [24, 4]), no algorithm can achieve a better approximation under the Unique Games Conjecture [25]. Corollary 1.2. By known reductions [14, 28], Theorem 1 directly implies an O(log log ∆) round algorithm for maximal matching in the congested clique model. It also leads to O(log log ∆) round congested clique algorithms for 2-approximate vertex cover, 1 + ε approximate maximum matching, and 2 + ε approximate maximum weighted matching by known reductions. The problem of maximal matching in the congested clique model was first asked by Ghaffari [19]. Prior to our work, the fastest known algorithm for this problem remained the classic O(log n) round algorithm of Luby [30].2 Corollary 1.2 exponentially improves over this bound. in the congested clique model leading to an (cid:101)O( √ log ∆) round algorithm. 2We comment that although it is unclaimed, a recent algorithm of Ghaffari and Uitto [21] can also be simulated 3 Corollary 1.3. For any constant ε ∈ (0, 1), Theorem 1 can be used to give algorithms for 1 + ε approximate matching and 2 + ε approximate maximum weighted matching in asymptotically the same number of rounds and space. The reduction from maximal matching (and in fact, any O(1) approximate matching) to 1 + ε approximate matching is due to an algorithm by McGregor [31] (see [6]) and the reduction to 2 + ε approximate weighted matching is due to an algorithm by Lotker et al. [29] (see [16]). We also note that if the space is O(n polylog n), then our algorithm can be used in a framework of Gamlath et al. [18] to get an O(log log ∆) round algorithm for 1 +  approximate maximum weighted matching. Corollary 1.3 also strengthens the round-complexity of the results in [16, 20, 6] from O(log log n) to O(log log ∆) using O(n) space. To our knowledge, the algorithms of [16, 20, 6] do require Ω(log log n) rounds even when ∆ = poly log n since they switch to an O(log ∆) round algorithm at this threshold. Corollary 1.3, however, implies an O(log log log n) round algorithm on such graphs. 1.2 High Level Technical Overview As discussed above, if the space per machine is n1+Ω(1), we already know how to find a maximal matching efficiently [27]. The main problem, roughly speaking, is that once the space becomes O(n), the computational power of a single machine alone does not seem to be sufficient to have a significant effect on the whole graph. More concretely, the known algorithms that work based on ideas such as edge-sampling the graph into a single machine and finding a matching there [27, 13, 2], all require Ω(log n) rounds of repeating this procedure if the space is O(n). Vertex partitioning [24, 10, 16, 6, 20], which in the context of matching was first used by [16], helps in utilizing several machines. The general idea is to randomly partition the vertices and find a matching in the induced subgraph of each partition individually in a different machine. It turns out that the choice of the internal matching algorithm over these induced subgraphs, has a significant effect on the global progress made over the whole graph. This is, in fact, the fundamental way that the algorithms within this framework differ [16, 6, 20]. We show that greedy maximal matching, which is perhaps the simplest matching algorithm one can think of, has several desirable structural properties that make it a perfect candidate for this purpose. This procedure iterates over the edges for some given ordering π, and at the time of processing each edge, adds it to the matching iff none of its incident edges are part of the matching so far. In other words, it is the lexicographically-first MIS of the line graph of G. We give a brief overview of our algorithm first, then describe the key ideas behind its analysis. The algorithm. Our main algorithm, which is formalized as Algorithm 1, uses three randomiza- tion steps, all of which are necessary for the analysis: • An ordering π over the edges is chosen uniformly at random. • Each edge of the graph is sampled independently with some probability p. • For some k, the vertex set V is partitioned into disjoint subsets V1, . . . , Vk where the partition of each vertex is chosen independently at random. After these steps, for any i ∈ [k], we put the edge-sampled induced subgraph of Vi into machine i and compute a greedy maximal matching Mi according to ordering π. We note that the choice of k and p in Algorithm 1 ensure that the induced subgraphs fit the memory of a machine. The analysis outline. Observe that M =(cid:83) i∈[k] Mi is a valid matching since the partitions are vertex disjoint. The key to our results, and the technically interesting part of our paper, is to show that if we commit the edges of M to the final maximal matching, then the degree of almost all 4 a random variable of the three randomizations involved in the algorithm, and that (cid:80) vertices drops to ∆1−Ω(1) in the residual graph. The main challenge here is to bound the vertex degrees across the partitions. To do this, for any vertex v and any partition i ∈ [k], we let Zv,i denote the number of neighbors of v in partition i that remain unmatched in greedy matching Mi. Note that Zv,i is i∈[k] Zv,i is precisely equal to the remaining degree of vertex v. We show the abovementioned degree reduction guarantee through a concentration bound on random variable Zv,i. Let us first outline how a concentration bound on Zv,i can be useful. Suppose, wishfully thinking, that Zv,i = (1 ± o(1))E[Zv,i] for every i ∈ [k] with high probability. By symmetry of the partitions, we have E[Zv,i] = E[Zv,1] for every i ∈ [k]. This means that all random variables Zv,1, . . . , Zv,k take on the same values ignoring the lower terms. Now, if E[Zv,1] is small enough that k · E[Zv,1] < ∆1−Ω(1), we get the desired bound on residual degree of v. Otherwise, due to the huge number of unmatched neighbors in its own partition, we show that v must have been matched and, thus, cannot survive to the residual graph! Unfortunately, Zv,i is a rather complicated function and it is not straightforward to prove such sharp concentration bounds on it. Recall that Chernoff-Hoeffding bounds work only on sum of independent random variables. Furthermore, concentration bounds obtained by Azuma's or other "dimension dependent" inequalities seem useless for our purposes: because the partition of every vertex in the graph may potentially affect Zv,i, these would give bounds on the order of n). As E[Zv,i] should be on the order of ∆, this is useless when ∆ is small. Zv,i = E[Zv,i] ± (cid:101)O( √ Instead of an exponential concentration bound, we aim for a weaker concentration bound by proving an upper bound on the variance of Zv,i. To achieve this upper bound, we use a method known as the Efron-Stein inequality (see Proposition 2.1) which plays a central role in our analysis. On one hand, this weaker concentration bound is still strong enough for our purpose of degree reduction. On the other hand, since we are only bounding the variance, the required conditions are much more relaxed and can be shown to be satisfied by the algorithm. On a conceptual level, one contribution of our paper is to provide a natural example for how the Efron-Stein inequality, which is often not among the standard tools used in theoretical computer science, can be extremely useful in the analysis of randomized algorithms. How greedy maximal matching helps. Our proof of the concentration bound relies on a number of unique properties of the random greedy maximal matching algorithm: 1. If we run greedy maximal matching on an edge-sampled subgraph of a graph, the maximum degree in the residual graph drops significantly (see Lemma A.1). 2. The set of matched vertices in the greedy maximal matching changes by a constant number of elements if a single vertex or edge is removed (see Lemma A.2). 3. If an ordering π is chosen randomly and an edge e of the graph is also chosen randomly, then determining whether e belongs to the greedy maximal matching according to π requires "looking" only at O(d) edges of the graph in expectation, where d is the average degree of the line graph (see Proposition A.3). We summarize these properties in Appendix A. Property 3 was originally developed in the context of sublinear time algorithms for approximating maximum matching size. To our knowledge, it was first formalized by Nguyen and Onak [32], with the precise bound of Proposition A.3 proved by Yoshida et al. [36]. We find the application of this methodology in proving concentration bounds extraordinary and possibly of independent interest. 5 2 Preliminaries 2.1 Notation Throughout the paper for any positive integer k, we use [k] to denote the set {1, . . . , k}. For any graph G = (V, E) and any V (cid:48) ⊆ V , we let G[V (cid:48)] denote the induced subgraph; that is, G[V (cid:48)] contains edge e in E if and only if both of its endpoints are in V (cid:48). For a vertex v, we define the neighborhood N (v) to be the set of vertices u with {u, v} ∈ E. An edge subset M ⊆ E is a matching if no two edges in M share an endpoint. A matching M of a graph G is a maximal matching if it is not possible to add any other edge of G to M and it is a maximum matching if every matching in G has size at most M. When it is clear from the context, we abuse notation to use M for the vertex set of matching M . In particular, we use G[V \ M ] to denote the graph obtained by removing every vertex of M from G. Furthermore, for any vertex v ∈ V and matching M , we define the residual degree degres M (v) to be zero if v ∈ M , and otherwise degres M (v) := degG[V \M ](v). Finally, we define the match-status of vertex v according to some matching M to be the indicator for the event that v ∈ M . 2.2 The MPC Model The Massively Parallel Computations (MPC) model was first introduced by Karloff et al. [24] and further refined by [22, 11, 12, 4]. An input of size N is initially distributed among M machines, each with a local space of size S. Computation proceeds in synchronous rounds in which each machine can perform an arbitrary local computation on its data and can send messages to other machines. The messages are delivered at the start of the next round. Furthermore, the total messages sent or received by each machine in each round should not exceed its memory. We desire algorithms that use a sublinear space per machine (i.e., S = N 1−Ω(1)) and only enough total space to store the input (i.e., S · M = O(N )). For graph problems, the edges of an input graph G(V, E) with n := V and m := E are initially distributed arbitrarily among the machines, meaning that N = Θ(m) words (or Θ(m log n) bits). Moreover, we mainly consider the regime of MPC with space per machine of S = Θ(n) words. 2.3 Concentration inequalities We will use two main concentration inequalities: the Efron-Stein inequality and the bounded dif- ferences inequality. These both concern functions f (x1, . . . , xn) which have Lipschitz properties, namely, changing each coordinate xi has a relatively small change to the value of f . Proposition 2.1 (Efron-Stein inequality [34]). Fix an arbitrary function f : {0, 1}n → R and let 1, . . . , X(cid:48) X1, . . . , Xn and X(cid:48) n be 2n i.i.d. Bernoulli random variables. For (cid:126)X := (X1, . . . , Xn) and (cid:126)X (i) := (X1, . . . , Xi−1, X(cid:48) i, Xi+1, . . . , Xn), we have · E(cid:104) n(cid:88) (cid:0)f ( (cid:126)X) − f ( (cid:126)X (i))(cid:1)2(cid:105) . Var(f ( (cid:126)X)) ≤ 1 2 i=1 We consider the following form the of the bounded differences inequality (which is a special case of McDiarmid's inequality): Proposition 2.2 (Bounded differences inequality). Let f be a λ-Lipschitz function on k variables, and let (cid:126)X = (X1, . . . , Xk) be a vector of k independent (not necessarily identically distributed) random variables. Then, Pr(cid:2)f ( (cid:126)X) ≥ E[f ( (cid:126)X)] + t(cid:3) ≤ exp . (cid:16)−2t2 (cid:17) kλ2 6 A slight reformulation of this, which is more useful for us to use directly, is the following: Proposition 2.3. Let f be a λ-Lipschitz function on k variables, and let (cid:126)X = (X1, . . . , Xk) be a vector of k independent (not necessarily identically distributed) random variables. Then w.e.h.p., f ( (cid:126)X) ≤ E[f ( (cid:126)X)] + λn0.01 √ k. 2.4 Sequential Greedy Maximal Matching As described in Section 1.2, a maximal matching can be found by a sequential greedy algorithm: Definition 2.4 (Greedy maximal matching). Given a graph G = (V, E) and an ordering π over the edges in E, the greedy maximal matching algorithm processes the edges in the order of π and adds an edge e to the matching if none of its incident edges have joined the matching so far. We denote the resulting maximal matching by GreedyMM(G, π). This greedy maximal matching has a number of nice properties that play a critical role in the analysis of our algorithm. We summarize these properties in Appendix A. We view the permutation π as a function mapping E to [m]; we say that e has higher priority than e(cid:48) if π(e) < π(e(cid:48)). In analyzing the greedy matching algorithm, it is often convenient to use the following local method of generating the permutation: each edge e is associated with a real ρe ∈ [0, 1]; we then form π by sorting in order of ρ. Slightly abusing notation, we write GreedyMM(G, ρ) in this case as shorthand for GreedyMM(G, π) where π is the permutation associated to ρ. 3 Roadmap As discussed in Section 1.2, the key to proving Theorem 1 and Theorem 2 is an algorithm to reduce the graph degree by a polynomial factor. The precise statement of this lemma is as follows: Lemma 3.1 (degree reduction). There is an O(1) round MPC algorithm to produce a matching M , with the following behavior w.e.h.p.: it uses n/∆Ω(1) space per machine and O(m) space in total, and the residual graph G[V \ M ] has maximum degree ∆1−Ω(1). Our main result, and the technical core of our analysis in proving Lemma 3.1 lies in showing that the following Algorithm 1 significantly reduces the degree of nearly all vertices in G. Algorithm 1. Input: A graph G = (V, E) with maximum degree ∆. Output: A matching M in G. (1) Permutation: Choose a permutation π uniformly at random over the edges in E. (2) Edge-sampling: Let GL(V, L) be an edge-sampled subgraph of G where each edge in E is sampled independently with probability p := ∆−0.85. (3) Vertex partitioning: Partition the vertices of V into k := ∆0.1 groups V1, . . . , Vk such that the partition of every vertex in V is chosen independently and uniformly at random. (4) Each machine i ∈ [k] receives the graph GL[Vi] and finds the greedy maximal matching (5) Return matching M :=(cid:83)k Mi := GreedyMM(GL[Vi], π). i=1 Mi. Specifically, we will show the following: 7 Lemma 3.2. Algorithm 1 has the following desirable behavior: 1. W.e.h.p., it uses n/∆Ω(1) space per machine. 2. W.e.h.p., it uses O(n) + m/∆Ω(1) space in total (aside from storing the original input graph.) 3. The expected number of vertices v ∈ V such that degres M (v) > ∆0.99 is at most O(n/∆0.03). We will prove Lemma 3.2 in Section 4 and we will prove Lemma 3.1 in Section 5. Before this, let us show how the degree reduction algorithm of Lemma 3.1 can be used to prove Theorem 1. Proof of Theorem 1. The algorithm consists of r iterations that each commits a number of edges to the final maximal matching using the algorithm of Lemma 3.1. In each iteration, the maximum degree in the remaining graph is reduced from ∆ to ∆1−α given that ∆ > c for some constant c and α. This ensures that by the end of iteration r, maximum degree is at most max{c, ∆(1−α)r}. To get the first result, take r = Θ(log log ∆); at the end of this process, the residual graph has degree O(1). At this point, we put the entire residual graph onto a single machine, and compute its maximal matching. To get the second result, take r = Θ(log(1/δ)); at the end of this process, the residual graph has degree nδ. At this point, we again put the entire residual graph onto a single machine, and compute its maximal matching. 4 Matching Almost All High-Degree Vertices: Proof of Lemma 3.2 We now turn to proving Lemma 3.2. We first need some notation for the analysis of Algorithm 1. For simplicity, we write Gi for the graph G[Vi]. Note that Gi is different from GL in that GL i i includes only a subset of the edges in Gi; those that were sampled in Line 2 of Algorithm 1. We let Li be the set of edges {u, v} ∈ L with u, v ∈ Vi; that is, Li is the edge-set of GL i . We further define χ to be the partition function of the vertices; that is, each vertex select a value χ(v) u.a.r from [k], and then we set Vi = χ−1(i). We also note that throughout the proof, we assume m ≥ n0.9. This assumption comes w.l.o.g. since otherwise one can put all the edges into one machine with even sublinear memory of O(n0.9) and find a maximal matching there. We begin by analyzing the residual degree of a vertex within its own partition, which are some simple consequences of the method used to generate L. Claim 4.1. The following bounds on the edge set L hold w.e.h.p.: 1. Every i ∈ [k] has Vi = Θ(n/∆0.1). 2. The graph GL contains O(m/∆0.85) edges. 3. Each graph GL i contains O(n/∆0.05) edges. Proof. The first property follows from a straightforward Chernoff bound, noting that E[Vi] = n/k = n/∆0.1 ≥ poly(n). For the second property, observe that the expected number of edges in GL is m · p = m/∆0.85. As we have discussed above, we can assume that m ≥ n0.9 and we also know that ∆ ≤ n; therefore, m/∆0.85 ≥ n0.05 and by Chernoff's bound the number of such edges is O(m/∆0.85) w.e.h.p. For the third property, we consider two cases where ∆ ≥ n0.01 and ∆ < n0.01 separately. Case 1: ∆ ≥ n0.01. For each vertex v ∈ Vi, its incident edge e = {u, v} will belong to GL if e is sampled in L and vertex u also belongs to Vi. Both of these events occur at the same time with probability p · k−1 = ∆−0.95. This means that the expected number of neighbors of v in GL i will i 8 be ∆ · ∆−0.95 = ∆0.05. Since we assumed ∆ ≥ n0.01, a simple Chernoff bound can show that this random variable is concentrated around O(∆0.05) w.e.h.p. Combined with the first property, the number of edges in each GL i will be O(n/∆0.1) · O(∆0.05) = O(n/∆0.05) w.e.h.p. Let U denote the number of edges in GL Case 2: ∆ < n0.01. i . For the arguments discussed above, we still have E[U ] ≤ O(n/∆0.05). Furthermore, U can be regarded as a function of the vertex partition χ and the edge set L. There are O(n∆) such random variables, and each of these can change U by at most ∆. Therefore, by Proposition 2.3, w.e.h.p., we have U ≤ E[U ] + ∆ · n0.01 ·(cid:112)O(n∆); as ∆ ≤ n0.01 this in turn implies that U ≤ O(n/∆0.05) w.e.h.p. These allow us to prove the first two parts of Lemma 3.2: Proof of Lemma 3.2 part 1 and 2. For the space bounds, Claim 4.1 shows that for each GL i , we require O(n/∆0.05) space for its edges and O(n/∆0.1) for its vertices. Since ∆ is larger than any constant, this is smaller than n/∆Ω(1). To show the bounds on total space usage note that the is clearly at most L, since each edge lives on at most one total edge count of all the graphs GL i machine, and this is at most m/ poly(∆). Furthermore, storing partition of each vertex requires only O(n) total space. As we have discussed before, for any vertex v ∈ V and any i ∈ [k], we define the random variable Zv,i :=(cid:12)(cid:12)Vi ∩ NG[V \M ](v)(cid:12)(cid:12), to be the degree of vertex v in the ith partition of the residual graph G[V \ M ]. Note here that v does not necessarily belong to Vi. With this definition, if a vertex v is not matched in M , we have degres M (v) = Zv,1 + ··· + Zv,k. We further define the related random variable Z(cid:48) v as: (cid:40) Z(cid:48) v := Zv,χ(v) 0 if v /∈ M if v ∈ M , which is equivalent to the residual degree of v in its own partition. Claim 4.2. For any vertex v, we have Pr(Z(cid:48) v > ∆0.86) ≤ exp(− poly(∆)). Proof. We will show that this bound holds, even after conditioning on the random variables χ and π. Suppose now that v ∈ Vi and so we need to bound the probability that Zv,i > ∆0.86. Note, here, that Z(cid:48) (v). Also, Mi is formed by performing independent edge sampling on G[Vi] and then taking the greedy maximal matching. Thus by Lemma A.1, the probability that Z(cid:48) v > ln(1/β) is at most β. Setting β = e−∆0.01, we have Z(cid:48) v > ∆0.86 with probability at most exp(− poly(∆)). v = degres Mi p 4.1 Analysis of the Inter-partition Degrees The key to analyzing Algorithm 1 is to show that for most vertices v, the values of Zv,i take on similar values across all possible indices i. We had sketched how this leads to the desired bound on vertex degrees in Section 1.2; let us provide some more technical details here. Recall from Section 1.2 that our concentration inequalities should not have an additive factor depending on n or they become too weak to be useful as ∆ gets smaller. To overcome this, we show that with careful analysis, the Efron-Stein inequality (Proposition 2.1) yields our desired 9 concentration bound; in particular, it gives concentration on the order Zv,i = E[Zv,i] ± ∆1−Ω(1). However, we emphasize that this concentration bound is not with exponentially high probability, or even with high probability: it only holds with a relatively small probability 1− 1/ poly(∆). This is the reason that we can only show that the number of high-degree vertices reduces by a 1/ poly(∆) factor, and not that Algorithm 1 reduces the maximum degree outright. Due to symmetry, we may consider showing a concentration bound for Zv,1. Let us furthermore assume that L and π have been fixed. Therefore, Zv,1 becomes only a function of the vertex partitioning χ, or more precisely, a function of the set of vertices that belong to partition V1. Let us define the vector (cid:126)x, by setting xv = 1 if χ(v) = 1, and xv = 0 otherwise. We may write Zv,1((cid:126)x) to emphasize that Zv,1 is merely a function of (cid:126)x. Observe that (cid:126)x is a vector of n i.i.d. Bernoulli-1/k random variables. To use the Efron-Stein inequality for bounding the variance, we have to upper bound the right-hand-side of inequality Var(Zv,1) ≤ 1 2 (cid:0)Zv,1((cid:126)x) − Zv,1((cid:126)x(w))(cid:1)2(cid:105) (cid:104)(cid:88) E(cid:126)x w∈V , (1) where (cid:126)x(w) is obtained by replacing the value of xw in (cid:126)x with x(cid:48) w which is drawn independently from the same distribution. In other words, the w summand of (1) corresponds to the effect of repartitioning vertex w on the value of Zv,1. Thus, we need to show that for most of the vertices in V , whether they belong to V1 or not does not affect Zv,1. To show this, consider a game where we determine Zv,1((cid:126)x) by querying entries of (cid:126)x. The queries can be conducted adaptively, i.e., each query can depend on the answers to previous queries. If we show an upper bound βv on the number of queries required to determine Zv,1((cid:126)x), then no matter what the other n − βv entries of (cid:126)x are, Zv,1((cid:126)x) remains unchanged and so clearly Zv,1((cid:126)x) − Zv,1((cid:126)x(w)) = 0 for all such unqueried vertices w. (The subscript v in βv is used to emphasize that the upper bound can be different for different choices of v.) Therefore, one way to show that most vertices of V do not affect Zv,1 is to design an efficient query process. We also note a particularly useful property of the Efron-Stein inequality in (1) is that even an upper bound on the expected number (taken over choice of (cid:126)x) of queries suffices. In addition to showing that most vertices do not affect Zv,1, we also need to show that the query process yields an appropriate Lipschitz property on Zv,1 as well. That is, even if the query process can guarantee Zv,1((cid:126)x)− Zv,1((cid:126)x(w)) = 0 for most vertices w, we still have to bound the value of (Zv,1((cid:126)x) − Zv,1((cid:126)x(w)))2 on those vertices w where Zv,1((cid:126)x) (cid:54)= Zv,1((cid:126)x(w)). This also follows from the nice structure of the greedy maximal matching algorithm. Claim 4.3 (Lipschitz property). For any vertex partitioning (cid:126)x, let (cid:126)x(w) be obtained by changing the w index of (cid:126)x. Then (Zv,1((cid:126)x) − Zv,1((cid:126)x(w)))2 ≤ 4. Proof. Suppose that xw = 0 which means x(w) 1 denote the vertex partitions due to (cid:126)x and (cid:126)x(w) respectively, i.e., V1 = {u xu = 1} and V (cid:48) u = 1}. Observe that V1 and V (cid:48) 1 differ in only one vertex w which belongs to V (cid:48) 1 but not V1. Define M1 := GreedyMM(G[V1], π) and M(cid:48) 1], π). By Lemma A.2 part 1, there are at most two vertices in V whose match-status differs between M1 and M(cid:48) 1. Even if these two vertices happen to be neighbors of v, we still have Zv,1((cid:126)x) − Zv,1((cid:126)x(w)) ≤ 2 and thus get the desired bound. The case with xw = 1 and x(w) w = 0 follows from a similar argument. w = 1. Let V1 and V (cid:48) 1 := GreedyMM(G[V (cid:48) 1 = {u x(w) The Lipschitz property can be plugged directly into (1) to show Var(Zv,1) ≤ O(n∆−0.1). In what follows, however, we describe a query process which significantly reduces this upper bound to poly(∆) for nearly all the vertices, i.e., removes the dependence on n. 10 The query process. We start with a query process to determine whether a given edge belongs to matching M1((cid:126)x) -- where here we write M1((cid:126)x) to emphasize that the parameters π, L should be regarded as fixed and so matching M1 is only a function of the vertex partitioning (cid:126)x. This process is very similar to a generic edge oracle for the greedy matching (which we briefly discuss in Appendix A), except that instead of querying the edges, it queries the entries of the vector (cid:126)x. Suppose that we have to determine whether a given edge e ∈ L belongs to the matching M1((cid:126)x). Instead of revealing the whole vector (cid:126)x, first note that if one of the end-points of e does not belong 1 and thus we can answer no immediately. to V1, then e cannot be in the induced subgraph GL Suppose that e appears in GL 1 . Since the greedy maximal matching algorithm processes the edges in the order of π, it suffices to recursively determine whether any of the incident edges to e belongs to M1((cid:126)x) in the order of their priorities. At any point that we find such incident edge to e, we immediately return no as e certainly cannot join M1((cid:126)x). Otherwise e has to join M1((cid:126)x), thus we return yes. We summarize the resulting query process as EOπ(e, (cid:126)x): EOπ(e, (cid:126)x): A query-process to determine whether e ∈ M1((cid:126)x). Let e = {u, v}. Query xu and xv; if xu = 0 or xv = 0, then return no. Let e1, . . . , ed be the incident edges to e in GL sorted as π(e1) < π(e2) < ··· < π(ed). for i = 1, . . . , d do if π(ei) < π(e) then if EOπ(ej, (cid:126)x) = yes then return no return yes We also define a degree oracle DOπ(v, (cid:126)x) to determine the value of Zv,1((cid:126)x). This checks whether each w ∈ NG(v) appears in V1 and is matched, which in turn requires checking whether every edge incident to w appears in matching of GL[V1]: DOπ(v, (cid:126)x): A query process to determine the value of Zv,1((cid:126)x). c ← 0 for all vertices u ∈ NG(v) do Query xu. if xu = 1 then Execute EOπ((u, w), (cid:126)x) for all vertices w ∈ NGL(u). if EOπ((u, w), (cid:126)x) = no for all such vertices w then c ← c + 1 return c (cid:46) u is unmatched in M1 Analysis of the query complexity. We now analyze the query complexity of the oracle DOπ, i.e., the number of indices in (cid:126)x that it queries. For any vertex v, we let B(v) denote the number of vertices that are queried when running DOπ(v). This is precisely the quantity that we need to bound for arguing that Var(Zv,1) is small according to (1). Formally: Claim 4.4. Fix any (cid:126)x, π, L and and let (cid:126)x(w) be a vector obtained by resampling the index xw. Then (cid:88) w∈V (Zv,1((cid:126)x) − Zv,1((cid:126)x(w)))2 ≤ 4B(v). Proof. By definition, the value of Zv,1((cid:126)x) can be uniquely determined by only revealing indices of (cid:126)x which are quered by DOπ(v, (cid:126)x). Therefore, changing other indices w of (cid:126)x cannot affect Zv,1 and 11 so Zv,1((cid:126)x) − Zv,1((cid:126)x(w)) = 0. There are B(v) indices queries by v. For any such index w, Claim 4.3 shows that (Zv,1((cid:126)x) − Zv,1((cid:126)x(w)))2 ≤ 4. To bound B(v), let us first define A(e) for an edge e ∈ L1 to be the number of edges in L1, on which the edge oracle is called (recursively) in the course of running EOπ(e, (cid:126)x). Note that when running EO, only edges that are in L1 can generate new recursive calls; other edges are checked, but immediately discarded. A(e)] ≤ O(n) where the expectation is taken over χ, L, and π. Claim 4.5. We have E[(cid:80) e∈L1 Proof. Let us first suppose that the random variables L and χ are fixed. Thus also GL i is determined. The only randomness remaining is the permutation π. As we are only interested in edges of L1, the edges outside L1 have no effect on the behavior of EOπ. Thus, A(e) is essentially the query complexity of GreedyMM(G1, π) under a random permutation. By Proposition A.3, we have: Eπ A(e) L, χ (cid:105) ≤ O(L1 + R1), (cid:105) ≤ O(E[L1 + R1]). A(e) (cid:104)(cid:88) E(cid:104)(cid:88) e∈L1 e∈L1 where R1 is the set of intersecting edge pairs in G1. Integrating now over the random variables L and χ, we get: Each edge e ∈ E goes into L1 with probability p/k2 = ∆−1.05, and so E[L1] = m∆−1.05. Like- wise, G contains at most m∆/2 pairs of intersecting edges and each of these survives to R1 with probability p2/k3 = ∆−2. Therefore, E[R1] ≤ m∆−1. Since m ≤ n∆, we therefore get E[(cid:80) A(e)] ≤ O(n). e∈L1 Claim 4.6. Suppose that we condition on the event that when running DOπ(v, (cid:126)x), we make a total of t calls to EOπ(e, (cid:126)x) with e ∈ L1. Then the expected number of total entries of (cid:126)x queried during DOπ(v, (cid:126)x) is at most O(∆1.15 + t∆0.15). Proof. Let us condition on the random variables χ, L1 and π. This determines the full listing of all edges in L1 that are queried during the execution of DOπ(v), because only such edges can generate new recursive calls to EOπ. Thus, if we show that this bound holds conditioned on χ, L1, π it will also show that it holds conditioned on the value t. The only remaining randomness at this point is the set L \ L1. Let J denote the set of edges in L1 queried during DOπ(v, (cid:126)x), with J = t. Then DOπ(v, (cid:126)x) will query xu for all u ∈ NG(v), and it will query w for all w ∈ NGL(u) for all such u ∈ NG(v). Finally, whenever it encounters edge e ∈ J, it will call EOπ(f, (cid:126)x) for some edges f ∈ L \ L1 which touch e; each of these will query two vertices, but the query process will not proceed further when they are discovered to lie outside L1. The number of vertices u ∈ NG(v) queried is clearly at most ∆. Now let us fix some u ∈ NG(v) and count the number of vertices w ∈ NGL(u) queried. This is precisely degL(u), and for any fixed u, the expected number of such vertices w is at most ∆p = ∆0.15. Thus, the total expected number of queried vertices in the first two categories is at most ∆1.15. Finally, let us consider some edge e = (a, b) ∈ J. The number of corresponding queried edges of L \ L1 is at most degL\L1(a) + degL\L1(b). Clearly again, for any fixed e we have E[degL\L1(a)] ≤ ∆p = ∆0.15 and similarly for b. Thus, the expected number of queried entries of (cid:126)x corresponding to edge e is at most 4∆0.15. Putting all these together, the expected number of queried entries of (cid:126)x is O(∆1.15 + t∆0.15). 12 Lemma 4.7. We have E[(cid:80) v∈V B(v)] ≤ O(n∆1.15) where the expectation is taken over χ, L, π. Proof. For any vertex v ∈ V , let us first define B(cid:48)(v) to the number of edges in L1 that are queried in the course of running DOπ(v). This can be bounded by: Summing over v ∈ V , we get: (cid:88) B(cid:48)(v) ≤(cid:88) v v (cid:88) u∈NG(v)∩V1 w:(u,w)∈L1 Taking expectations and applying Claim 4.5, we therefore have (cid:88) u∈NG(v)∩V1 B(cid:48)(v) ≤ (cid:88) (cid:88) E(cid:104)(cid:88) (cid:105) ≤ O A(u, w) ≤ (cid:88) (cid:105) ≤ 2∆E(cid:104)(cid:88) ∆0.15E(cid:104)(cid:88) B(cid:48)(v) v e∈L1 (u,w)∈L1 w:(u,w)∈L1 A(u, w). (cid:16) (cid:88) (cid:105) ≤ O(∆n). v∈NG(u) A(u, w) A(e) (cid:88) v∈NG(w) (cid:17) ≤ 2∆ 1 (cid:88) e∈L1 1 + A(e). By Claim 4.6, we have E[B(v) B(cid:48)(v) = t] ≤ O(∆1.15 + t∆0.15) for any vertex v. This further implies that E[B(v)] ≤ O(∆1.15 + E[B(cid:48)(v)]∆0.15); thus B(cid:48)(v) (cid:17) ≤ O(∆1.15n), E(cid:104)(cid:88) + ∆1.15n (cid:16) B(v) (cid:105) as desired. v v We now say that a vertex v is bad if E(cid:126)x[B(v) π, L] > ∆1.4 (i.e., Ω(∆0.25) times larger than the average value given by Lemma 4.7) and good otherwise. Let us define B to be the set of bad vertices. Note that, because B is based on a conditional expectation, it is determined solely by the random variables π, L. Claim 4.8. The expected size of B satisfies Eπ,L[B] ≤ O(n/∆0.25). Eχ[B(v) π, L] ≥ B · ∆1.4 with probability one since for each bad vertex v ∈ B, by definition the expected value of B(v) is at least ∆1.4. Taking expectations over π and L, we therefore get Proof. Observe that we have(cid:80) v∈V E(cid:126)x[B(v)] π, L] Eπ,L[B] ≤ ∆−1.4 · Eπ,L By Lemma 4.7, we have (cid:80) Proof. By Claim 4.4, for any vertex partitioning (cid:126)x, we have(cid:80) E[B] ≤ O(n∆−0.25). Claim 4.9. For any π, L, any good vertex v has Var(Zv,1 π, L) ≤ O(∆1.4). v∈V v∈V v∈V w∈V (Zv,1((cid:126)x)− Zv,1((cid:126)x(w)))2 ≤ 4B(v), where (cid:126)x(w) is obtained by changing the w entry of (cid:126)x. If we fix π, L and take expectations over (cid:126)x, this gives E[B(v)] ≤ O(∆1.15n). Putting these two bounds together gives (cid:21) = ∆−1.4(cid:88) E[B(v)]. (cid:20)(cid:88) (cid:104)(cid:88) w∈V E(cid:126)x (Zv,1((cid:126)x) − Zv,1((cid:126)x(w)))2 π, L (cid:105) ≤ 4E(cid:126)x[B(v) π, L]. (cid:105) (cid:0)Zv,1((cid:126)x) − Zv,1((cid:126)x(w))(cid:1)2 π, L . On the other hand, by (1), any vertex v has Var(Zv,1 π, L) ≤ 1 2 E(cid:126)x Combining the two inequalities gives Var(Zv,1 π, L) ≤ 2E[B(v) π, L]. Since v is good with respect to π, L, it satisfies E(cid:126)x[B(v) π, L] ≤ O(∆1.4) by definition. Thus Var(Zv,1 π, L) ≤ O(∆1.4). (cid:104)(cid:88) w∈V 13 We are now ready to prove the main part of Lemma 3.2. E[(cid:80) Proof of Lemma 3.2, part (3). For each vertex v ∈ V , define the random variable yv to be the indicator function that degres M (v) > ∆0.99 after running Algorithm 1. We need to show that v∈V yv] ≤ O(n/∆0.03). Depending on π and L, let us partition the vertices in V into two subsets B and G of respectively bad and good vertices as defined before. Furthermore, fix τ = 2∆0.86 and partition the set G of good vertices into two subsets H and L where for any vertex v ∈ H, E(cid:126)x[Zv,1 π, L] ≥ τ and for any v ∈ L, E(cid:126)x[Zv,1 π, L] < τ . We have:(cid:88) E[(cid:80) v∈V (cid:88) v∈B (cid:88) v∈L (cid:88) v∈H yv. yv = yv + yv + By Claim 4.8, we know directly that E[B] ≤ O(n/∆0.25). Since yv ≤ 1 for any vertex v, we have v∈B yv] ≤ E[B] ≤ O(n/∆0.25). Now, for any fixed v ∈ V , we compute the probability of the event that v ∈ L and yv = 1 (respectively, v ∈ H and yv = 1); we show that each such event has probability O(∆−0.03). Good vertices of type L. Recall that degres number of partitions. Taking expectations we get M (v) ≤ Zv,1 + . . . + Zv,k where k = ∆0.1 denotes the E[degres M (v) π, L] ≤ E[Zv,1 + . . . + Zv,k π, L] = kE[Zv,1 π, L] M (v) π, L] ≤ kτ = ∆0.1 · 2∆0.86 = 2∆0.96. By Markov's inequality, Pr[degres where the latter equality for symmetry of the partitions. If v ∈ L, then E[Zv,1 π, L] < τ , thus, M (v) > ∆0.99 E[degres π, L] < O(∆−0.03). Therefore, Pr[yv = 1 ∧ v ∈ L π, L] ≤ O(∆−0.03). Integrating over π, L also Pr[yv = 1 ∧ v ∈ L] ≤ O(∆−0.03) as desired. Good vertices of type H. We show that good vertices of type H are highly likely to be matched in their own partition and thus not too many of them will remain in the graph. For such a vertex v, one of the following two events must occur: either Z(cid:48) v < ∆0.86. The first of these events has probability exp(− poly(∆)) (cid:28) ∆−0.03 by Claim 4.2. We next need to bound the probability of having v ∈ H and also having Z(cid:48) v, we have at least one index j ∈ [k] with Zv,j < ∆0.86. We bound the occurrence probability of this event. Since v ∈ H, by definition it is a good vertex and thus Claim 4.9 shows that Var(Zv,i π, L) ≤ O(∆1.4). Also, E[Zv,i π, L] ≥ 2∆0.86. Therefore, by Chebyshev's inequality, for any fixed i ∈ [k], v ≤ ∆0.86. If this occurs, by definition of Z(cid:48) v ≥ ∆0.86 or Z(cid:48) Pr(cid:2)Zv,i < ∆0.86 π, L(cid:3) ≤ Pr (cid:104)(cid:12)(cid:12)Zv,i − E[Zv,i π, L](cid:12)(cid:12) ≥ 2∆0.86 − ∆0.86(cid:105) (cid:18) Var(Zv,i π, L) (cid:18) ∆1.4 (cid:19) (cid:19) ≤ O (∆0.86)2 ∆1.72 ≤ O(∆−0.32). ≤ O By a union bound over the k = ∆0.1 choices of j, we have Pr(cid:2)v ∈ H and there exists some j ∈ [k] with Zv,j ≤ ∆0.86 π, L(cid:3) ≤ O(∆−0.22). This means that overall, the probability that yv = 1 and v ∈ H is O(∆−0.22) (cid:28) O(∆−0.03). 14 5 Putting Everything Together We now prove Lemma 3.1, showing that Algorithm 1 can be used to reduce the overall graph degree. There are two parts to doing this. First, we need to amplify the success probability of Lemma 3.2, which only showed a degree reduction in expectation, into one holding w.e.h.p. Next, we need to remove the remaining high-degree vertices. Claim 5.1. There is an algorithm to generate a matching M which w.e.h.p. uses n/∆Ω(1) space per machine and O(m) total space, such that there are at most n/∆0.02 vertices v with degres M (v) > ∆0.99. Proof. We may assume that the original graph has as least n/∆0.02 vertices with deg(v) > ∆0.99, as otherwise there is nothing to do. This implies that m ≥ n∆0.97. of vertices v ∈ V with degres need to show concentration for Y . There are two cases depending on the size of ∆. Now consider running Algorithm 1 to generate a matching M . Let us define Y to be the number M (v) > ∆0.99. Lemma 1 has shown that E[Y ] ≤ O(n/∆0.03), and so we In this case, Markov's inequality applied to Y shows that Pr[Y > n∆−0.02] ≤ Case 1: ∆ > n0.1. O(∆−0.01) ≤ 1/2. Now consider running t = na parallel iterations of Algorithm 1 for some constant a > 0, generating matchings M1, . . . , Mt. Since they are independent, there is a probability of at least 1 − 2−t that at least one matching Mi has the property that its residual set of high- degree vertices satisfies Y > n∆−0.02. Thus, w.e.h.p., this algorithm satisfies the condition on the high-degree vertices. Each application of Algorithm 1 separately uses O(n) + m/ poly(∆) space. Therefore, the t iterations in total use O(n1+a) + nam/ poly(∆) space. Since ∆ > n0.1 and m ≥ ∆n0.97 > n1.07, this is O(m) for a a sufficiently small constant. Case 2: ∆ < n0.1. We can regard Y as being determined by O(n∆) random variables, namely, the values ρ, χ, L. By Lemma A.2, modifying each entry of ρ, χ, or L can only change the match-status of at most O(1) vertices. Each of these, in turn, has only ∆ neighbors, which are the only vertices whose degree in G[V \ M ] is changed. Thus, changing each of the underlying random variables can only change Y by O(∆). By Proposition 2.3, therefore, w.e.h.p. we have Y ≤ E[Y ] + O(∆)n0.01 n∆ ≤ O(n∆−0.03) + O(n0.51∆1.5). √ As ∆ ≤ n0.1 and ∆ is larger than any needed constants, this is at most n∆−0.02. Therefore, already a single application of Algorithm 1 suceeds w.e.h.p. Having slightly reduced the number of high-degree vertices, we next use the following Algo- rithm 2, which significantly decreases the number of high-degree vertices. Algorithm 2. (1) Let Y be the set of vertices in G[V \ M ] with degree greater than τ = ∆0.999. (2) Sample each edge with at least one end-point in Y with probability q := ∆−0.99 and let L be the set of sampled edges. (3) Put GL = (V, L) in machine 1, choose an arbitrary permutation π over its edges and return matching M(cid:48) := GreedyMM(GL, π). Claim 5.2. Given a graph G, suppose we apply Claim 5.1; let M be the resulting matching and G(cid:48) = G[V \ M ]. Suppose we next run Algorithm 2 on G(cid:48) and let M(cid:48) denote the resulting matching. Let Y(cid:48) denote the set of vertices v with degres M∪M(cid:48)(v) > τ . Then, w.e.h.p., Y(cid:48) ≤ n/∆1.01. 15 Proof. Let Y be the set of vertices with degres M (v) > τ and Y = Y. By Claim 5.1, w.e.h.p. Y ≤ n/∆0.02. For the remainder of this proof, we assume that M (and hence Y ) is fixed and it satisfies this bound. We first analyze E[Y (cid:48)] where we define Y (cid:48) = Y(cid:48). Consider some vertex v ∈ Y. By Lemma A.1, ). Setting β = e−∆0.001, we get M∪M(cid:48)(v) ≤ O(∆0.991) with probability 1 − exp(−∆Ω(1)). Since this holds for any vertex with probability at least 1− β the vertex v has degres that degres v ∈ Y, we have shown that M∪M(cid:48) ≤ O( log 1/β q E[Y (cid:48)] ≤ Y · exp(−∆Ω(1)) ≤ ne−∆Ω(1) . We next need to show concentration for Y (cid:48). For this, note that if ∆ > n0.01, then the above bound on E[Y (cid:48)] already implies (by Markov's inequality) that Y (cid:48) < 1 w.e.h.p. If ∆ < n0.01, then we use the bounded differences inequality. Here, Y (cid:48) can be regarded as a function of n∆ random variables (the membership of each edge in L). By Lemma A.2, each such edge can affect the match-status of O(1) vertices. Each such vertex w, in turn, can only change the membership in Y(cid:48) of its neighbors. Hence, each random variable changes Y (cid:48) by at most O(∆). By Proposition 2.3, we therefore have w.h.p. Y (cid:48) ≤ E[Y (cid:48)] + O(∆ × n∆ × n0.01) ≤ n exp(−∆Ω(1)) + O(∆1.5n0.51). By our assumption that ∆ ≤ n0.01, this is easily seen to be smaller than n/∆1.01. √ Proof of Lemma 3.1. When we apply Claim 5.1 and then apply Claim 5.2, this w.e.h.p. gives matchings M, M(cid:48) respectively such that G[V \ (M ∪ M(cid:48))] has at most n/∆1.01 vertices of degree larger than ∆0.999. Claim 5.1 already obeys the stated space bounds. For Algorithm 2, observe that Y ≤ n/∆0.02, and so there are at most n∆0.98 edges incident to Y. This means E[L] ≤ n/∆0.01 and a simple Chernoff bound thus shows that L ≤ n/∆Ω(1) w.e.h.p. Finally, we place all vertices with degree at least ∆0.999 and their incident edges onto a single machine; this clearly takes O(n/∆0.01) space. Since ∆ is larger than any needed constant, this is at most n/∆Ω(1). We thus expand M ∪ M(cid:48) to a maximal matching M(cid:48)(cid:48) of G[V \ (M ∪ M(cid:48))]. At the end of this process, all remaining vertices of G must have degree less than ∆0.999. 5.1 The Algorithm with Mildly Sublinear Space √ log n) with We now turn to proving Theorem 2, where we reduce the space per machine to n/2Ω( round complexity at O(log log ∆ + log log log n). The follows by combining the fact that our algo- rithms require n/∆Ω(1) space with a known technique for simulating LOCAL algorithm on low-degree graphs in an exponentially faster time. Proof of Theorem 2. The degree reduction algorithm of Lemma 3.1 uses a space per machine of √ n/∆Ω(1) to get the degree down from ∆ to ∆1−Ω(1). Therefore, if ∆ ≥ 2Ω( log n), the degree log n) space. This means that within O(log log ∆) rounds, reduction automatically requires n/2Ω( √ we can get the maximum degree down to ∆(cid:48) ≤ 2(γ/2) log n w.e.h.p., where γ ∈ (0, 1) is any small constant. (If ∆ ≤ 2(γ/2) log n originally, then we simply have ∆(cid:48) = ∆.) √ √ At this point, we switch to a different algorithm: we simulate the known t = O(log ∆ + poly(log log n)) round LOCAL algorithms for maximal matching [9]. This requires O(log t) = O(log log ∆ + log log log n) rounds; this is possible for the all-to-all communication of the machines (compared to LOCAL) and the fact that the maximum degree is small (so that the neighborhood is not too large that it does not fit the memory). For more details, see for example the blind 16 (cid:16) log ∆(cid:48) + poly log log n O log∆(cid:48) n + log log ∆(cid:48) + log log log n . (cid:17) coordination lemma of [15] which shows one can simulate t rounds of all state-congested LOCAL algorithms (such as that of [9]) in O( and O(n1+γ/2) total space. (This excludes the space needed to store the original graph.) √ In our case, since we apply this algorithm to a graph of maximum degree ∆(cid:48) = 2(γ/2) t = O(log ∆(cid:48) + poly(log log n)), and we get a runtime of log∆ n + log t) rounds of MPC with n1−Ω(1) space per machine log n and t √ log n), the first term is O(1); since ∆(cid:48) ≤ ∆, the second term is at most log log ∆. Since ∆(cid:48) ≤ 2O( Note that the LOCAL maximal matching algorithm we are simulating here only succeeds with high probability, i.e. with probability 1 − 1/ poly(n). In order to amplify it to exponential success probability, we can run nγ/2 separate independent executions; w.e.h.p., at least one will succeed. This multiplies the total space by nγ/2, bringing the total space (aside from the storage of G) up to n1+γ. A Useful Properties of Sequential Greedy Maximal Matching In this section we prove the properties of the sequential greedy maximal matching that we used throughout the paper. The first property concerns the behavior of greedy matching when it is run on an edge-sampled subgraph of a graph. This property is very similar to some results in [1, 20, 26] on greedy algorithms for correlation clustering and maximal independent set. Lemma A.1. Fix a graph G = (V, E), let π be a permutation over E, and let p ∈ (0, 1] be an arbitrary parameter. We define Gp = (V, Ep) to be the random subgraph of G formed wherein each edge in E appears in Ep independently with probability p and define M := GreedyMM(Gp, π). For any vertex v and any parameter β ∈ (0, 1/2), with probability at least 1 − β, degres M (v) ≤ ln(1/β) . p Proof. Consider the following equivalent method of generating M . We iterate over the edges in E in the order of π. Upon visiting an edge e, if one of its incident edges belongs to M , we call it irrelevant and discard it. Otherwise, we draw a Bernoulli-p random variable Xe; if Xe = 1, we call e lucky and add it to M otherwise we call e unlucky. M (v) = 0. Otherwise, all of its remaining edges in G[V \M ] should have been unlucky. That is, every time we encounter an edge e in this process, it must have been M (v) > τ = ln(1/β) irrelevant or we must have chosen Xe = 0. Furthermore, in order to have degres , there must remain at least τ edges which are not irrelevant. During this process, the probability that all such edges are marked unlucky is at most (1 − p)τ ≤ exp(−τ p) = β. If v is matched in M , then degres p The second useful property of the greedy matching is that modifying a single vertex or edge of G does not change the set of matched vertices too much. Note that that the set of edges selected for M can change significantly. Lemma A.2. Fix some graph G(V, E) and let ρ : E → [0, 1] be an associated list of priorities: 1. If graph G(cid:48) is derived by removing a vertex of G, then there are at most 2 vertices whose match-status differs in GreedyMM(G, ρ) and GreedyMM(G(cid:48), ρ). 2. If graph G(cid:48) is derived by removing an edge of G, then there are at most 2 vertices whose match-status differs in GreedyMM(G, ρ) and GreedyMM(G(cid:48), ρ). 17 3. If ρ(cid:48) is derived by changing a single entry of ρ, then there are at most 2 vertices whose match-status differs in GreedyMM(G, ρ) and GreedyMM(G, ρ(cid:48)). Proof. We start with the proof of the first part. Suppose that G(cid:48) is obtained by removing some vertex v from G. Let M := GreedyMM(G, ρ) and M(cid:48) := GreedyMM(G(cid:48), ρ). Furthermore, let D := M ⊕ M(cid:48) denote the symmetric difference of M and M(cid:48), i.e. the set (M \ M(cid:48)) ∪ (M(cid:48) \ M ). Note that the match-status of a vertex v differs in M and M(cid:48) if and only if its degree in D is one. Therefore, it suffices to show that there are at most two such vertices in D. We first claim that D has at most one connected component (apart from singleton vertices). For sake of contradiction, suppose that D has multiple such connected components; fix one component C that does not contain v. Let e be the edge in C with the highest priority. The fact that no higher priority edge that is connected to e is part of M or M(cid:48) (otherwise e would not be the highest priority edge in C) shows that e has to belong to both M and M(cid:48). By definition of D, this means that e /∈ D which is a contradiction. Next, observe that since D is composed of the edges of two matchings, its maximum degree is at most 2 and thus its unique component is either a path or a cycle. The latter has no vertex of degree one and the former has two; proving part 1 of Lemma A.2. The proof of the other two parts of Lemma A.2 follows from a similar argument. If an edge e is removed from G or its entry in ρ is changed, then for the same argument, the symmetric difference M ⊕M(cid:48) of the two greedy matchings M and M(cid:48) that are obtained would contain only one connected component which has to contain e. Since this component is a cycle or a path, the match-statuses of at most two vertices are different in the two matchings. The third property is the most subtle: it can be summarized as stating that the presence of any given edge e appearing in M can be determined from a relatively small number of other edges. To make this more precise, let us consider the following query-based method which we refer to as the "edge oracle" EOπ(e) for determining whether an edge e appears in GreedyMM(G, π): EOπ(e): A query-process to determine whether e ∈ GreedyMM(G, π). Let e1, . . . , ed be the incident edges to e in G sorted such that π(e1) < π(e2) < ··· < π(ed). for i = 1, . . . , d do if π(ei) < π(e) then if EOπ(ej) = yes then return no return yes It is clear that e ∈ GreedyMM(G, π) if and only if EOπ(e) = yes. For any edge e ∈ E, let us define A(e) to be the number of (recursive) calls to EOπ that are generated by running EOπ(e). Translating a result of Yoshida et al. [36] for maximal independent set into our context, gives: Proposition A.3 ([36]). Let G be a graph with m edges and r pairs of intersecting edges. If π is drawn u.a.r. from permutations on m elements, then Eπ[(cid:80) e∈E A(e)] ≤ O(m + r). Proof. Let H be the line graph of G. Then H has m vertices and r edges, and hence has average degree 2r/m. Also, Eπ[A(e)] is the expected query complexity of the maximal independent set of H under a random sequential greedy independent set. The result of Yoshida et al. [36, Theorem 2.1] implies the following bound on the average value of A(e) in terms of the average degree of H: (cid:104)(cid:88) e∈L Eπ 1 m (cid:105) ≤ 1 + A(e) 2r m . We obtain the stated result by multiplying through by m. 18 References [1] Kook Jin Ahn, Graham Cormode, Sudipto Guha, Andrew McGregor, and Anthony Wirth. Correlation clustering in data streams. In Proceedings of the 32nd International Conference on Machine Learning, ICML, pages 2237 -- 2246, 2015. [2] Kook Jin Ahn and Sudipto Guha. Access to data and number of iterations: Dual primal algorithms for maximum matching under resource constraints. In Proceedings of the 27th ACM Symposium on Parallelism in Algorithms and Architectures (SPAA), pages 202 -- 211, 2015. [3] Noga Alon, L´aszl´o Babai, and Alon Itai. A fast and simple randomized parallel algorithm for the maximal independent set problem. J. Algorithms, 7(4):567 -- 583, 1986. [4] Alexandr Andoni, Aleksandar Nikolov, Krzysztof Onak, and Grigory Yaroslavtsev. Parallel algorithms for geometric graph problems. In Proceedings of the 46th annual ACM Symposiim on Theory of Computing (STOC), pages 574 -- 583, 2014. [5] Sepehr Assadi. Simple round compression for parallel vertex cover. CoRR, abs/1709.04599, 2017. [6] Sepehr Assadi, MohammadHossein Bateni, Aaron Bernstein, Vahab Mirrokni, and Cliff Stein. Coresets meet edcs: algorithms for matching and vertex cover on massive graphs. In Pro- ceedings of the 30th annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1616 -- 1635, 2019. [7] Sepehr Assadi and Sanjeev Khanna. Randomized composable coresets for matching and ver- In Proceedings of the 29th ACM Symposium on Parallelism in Algorithms and tex cover. Architectures (SPAA), pages 3 -- 12, 2017. [8] Sepehr Assadi, Xiaorui Sun, and Omri Weinstein. Massively parallel algorithms for finding well-connected components in sparse graphs. CoRR, abs/1805.02974, 2018. [9] Leonid Barenboim, Michael Elkin, Seth Pettie, and Johannes Schneider. The Locality of In Proceedings of the 53rd Annual IEEE Symposium on Distributed Symmetry Breaking. Foundations of Computer Science (FOCS), pages 321 -- 330, 2012. [10] MohammadHossein Bateni, Soheil Behnezhad, Mahsa Derakhshan, MohammadTaghi Haji- aghayi, Raimondas Kiveris, Silvio Lattanzi, and Vahab S. Mirrokni. Affinity clustering: Hier- archical clustering at scale. In Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems (NIPS), pages 6867 -- 6877, 2017. [11] Paul Beame, Paraschos Koutris, and Dan Suciu. Communication steps for parallel query pro- cessing. In Proceedings of the 32nd ACM SIGMOD-SIGACT-SIGART Symposium on Princi- ples of Database Systems (PODS), pages 273 -- 284, 2013. [12] Paul Beame, Paraschos Koutris, and Dan Suciu. Communication steps for parallel query processing. J. ACM, 64(6):40:1 -- 40:58, 2017. [13] Soheil Behnezhad, Mahsa Derakhshan, Hossein Esfandiari, Elif Tan, and Hadi Yami. Brief an- nouncement: Graph matching in massive datasets. In Proceedings of the 29th ACM Symposium on Parallelism in Algorithms and Architectures (SPAA), pages 133 -- 136, 2017. 19 [14] Soheil Behnezhad, Mahsa Derakhshan, and MohammadTaghi Hajiaghayi. Brief announcement: Semi-mapreduce meets congested clique. CoRR, abs/1802.10297, 2018. [15] Soheil Behnezhad, Mahsa Derakhshan, MohammadTaghi Hajiaghayi, and Richard M. Karp. Massively parallel symmetry breaking on sparse graphs: MIS and maximal matching. CoRR, abs/1807.06701, 2018. [16] Artur Czumaj, Jakub Lacki, Aleksander Madry, Slobodan Mitrovic, Krzysztof Onak, and Piotr Sankowski. Round compression for parallel matching algorithms. In Proceedings of the 50th annual ACM SIGACT Symposium on Theory of Computing (STOC), pages 471 -- 484, 2018. [17] Jeffrey Dean and Sanjay Ghemawat. MapReduce: simplified data processing on large clusters. Commun. ACM, 51(1):107 -- 113, 2008. [18] Buddhima Gamlath, Sagar Kale, Slobodan Mitrovi´c, and Ola Svensson. Weighted matchings via unweighted augmentations. arXiv preprint arXiv:1811.02760, 2018. [19] Mohsen Ghaffari. Distributed MIS via all-to-all communication. In Proceedings of the ACM Symposium on Principles of Distributed Computing, PODC 2017, Washington, DC, USA, July 25-27, 2017, pages 141 -- 149, 2017. [20] Mohsen Ghaffari, Themis Gouleakis, Christian Konrad, Slobodan Mitrovic, and Ronitt Ru- binfeld. Improved massively parallel computation algorithms for MIS, matching, and vertex cover. In Proceedings of the 2018 ACM Symposium on Principles of Distributed (PODC), pages 129 -- 138, 2018. [21] Mohsen Ghaffari and Jara Uitto. Sparsifying distributed algorithms with ramifications in massively parallel computation and centralized local computation. Proceedings of the 30th annual ACM-SIAM Symposium on Discrete Algorithms (SODA), to appear., 2019. [22] Michael T. Goodrich, Nodari Sitchinava, and Qin Zhang. Sorting, searching, and simulation in the MapReduce framework. In Proceedings of the 22nd International Symposium on Algorithms and Computation (ISAAC), pages 374 -- 383, 2011. [23] Amos Israeli and Alon Itai. A fast and simple randomized parallel algorithm for maximal matching. Inf. Process. Lett., 22(2):77 -- 80, 1986. [24] Howard J. Karloff, Siddharth Suri, and Sergei Vassilvitskii. A model of computation for MapReduce. In Proceedings of the 21st annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 938 -- 948, 2010. [25] Subhash Khot and Oded Regev. Vertex cover might be hard to approximate to within 2- ε. Journal of Computer and System Sciences, 74(3):335 -- 349, 2008. [26] Christian Konrad. Mis in the congested clique model in O(log log ∆) rounds. CoRR, abs/1802.07647, 2018. [27] Silvio Lattanzi, Benjamin Moseley, Siddharth Suri, and Sergei Vassilvitskii. Filtering: a In Proceedings of the 23rd ACM Sym- method for solving graph problems in MapReduce. posium on Parallelism in Algorithms and Architectures (SPAA), pages 85 -- 94, 2011. [28] Christoph Lenzen. Optimal deterministic routing and sorting on the congested clique. In ACM Symposium on Principles of Distributed Computing, PODC, pages 42 -- 50, 2013. 20 [29] Zvi Lotker, Boaz Patt-Shamir, and Adi Ros´en. Distributed approximate matching. SIAM J. Comput., 39(2):445 -- 460, 2009. [30] Michael Luby. A simple parallel algorithm for the maximal independent set problem. In Proceedings of the 17th annual ACM Symposium on Theory of Computing (STOC), pages 1 -- 10, 1985. [31] Andrew McGregor. Finding graph matchings in data streams. In 8th International Workshop on Approximation Algorithms for Combinatorial Optimization Problems (APPROX) and 9th International Workshop on Randomization and Computation (RANDOM), pages 170 -- 181, 2005. [32] Huy N. Nguyen and Krzysztof Onak. Constant-time approximation algorithms via local im- provements. In Proceedings of the 49th annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 327 -- 336, 2008. [33] Krzysztof Onak. Round compression for parallel graph algorithms in strongly sublinear space. CoRR, abs/1807.08745, 2018. [34] J Michael Steele et al. An Efron-Stein inequality for nonsymmetric statistics. The Annals of Statistics, 14(2):753 -- 758, 1986. [35] Tom White. Hadoop - The Definitive Guide: Storage and Analysis at Internet Scale (2. ed.). O'Reilly, 2011. [36] Yuichi Yoshida, Masaki Yamamoto, and Hiro Ito. An improved constant-time approximation algorithm for maximum matchings. In Proceedings of the 41st annual ACM Symposium on Theory of Computing (STOC), pages 225 -- 234, 2009. [37] Matei Zaharia, Mosharaf Chowdhury, Michael J. Franklin, Scott Shenker, and Ion Stoica. Spark: Cluster Computing with Working Sets. In 2nd USENIX Workshop on Hot Topics in Cloud Computing (HotCloud), 2010. 21
1703.07244
2
1703
2017-11-08T02:12:09
A Hybrid Feasibility Constraints-Guided Search to the Two-Dimensional Bin Packing Problem with Due Dates
[ "cs.DS" ]
The two-dimensional non-oriented bin packing problem with due dates packs a set of rectangular items, which may be rotated by 90 degrees, into identical rectangular bins. The bins have equal processing times. An item's lateness is the difference between its due date and the completion time of its bin. The problem packs all items without overlap as to minimize maximum lateness Lmax. The paper proposes a tight lower bound that enhances an existing bound on Lmax for 24.07% of the benchmark instances and matches it in 30.87% cases. In addition, it models the problem using mixed integer programming (MIP), and solves small-sized instances exactly using CPLEX. It approximately solves larger-sized instances using a two-stage heuristic. The first stage constructs an initial solution via a first-fit heuristic that applies an iterative constraint programming (CP)-based neighborhood search. The second stage, which is iterative too, approximately solves a series of assignment low-level MIPs that are guided by feasibility constraints. It then enhances the solution via a high-level random local search. The approximate approach improves existing upper bounds by 27.45% on average, and obtains the optimum for 33.93% of the instances. Overall, the exact and approximate approaches identify the optimum for 39.07% cases. The proposed approach is applicable to complex problems. It applies CP and MIP sequentially, while exploring their advantages, and hybridizes heuristic search with MIP. It embeds a new lookahead strategy that guards against infeasible search directions and constrains the search to improving directions only; thus, differs from traditional lookahead beam searches.
cs.DS
cs
A Hybrid Feasibility Constraints-Guided Search to the Two-Dimensional Bin Packing Problem with Due Dates Sergey Polyakovskiya, Rym M'Hallahb,∗ aOptimisation and Logistics Group, School of Computer Science, University of Adelaide, bDepartment of Statistics and Operations Research, College of Science, Kuwait University, P.O. Box 5969, Safat 13060, Kuwait. Australia. Abstract The two-dimensional non-oriented bin packing problem with due dates packs a set of rectangular items, which may be rotated by 90 degrees, into identical rectangular bins. The bins have equal processing times. An item's lateness is the difference between its due date and the completion time of its bin. The problem packs all items without overlap as to minimize maximum lateness Lmax. The paper proposes a tight lower bound that enhances an existing bound on Lmax by 31.30% for 24.07% of the benchmark instances and matches it in 30.87% cases. Moreover, it models the problem via mixed integer programming (MIP), and solves small-sized instances exactly using CPLEX. It approximately solves larger-sized instances using a two-stage heuristic. The first stage con- structs an initial solution via a first-fit heuristic that applies an iterative con- straint programming (CP)-based neighborhood search. The second stage, which is iterative too, approximately solves a series of assignment low-level MIPs that are guided by feasibility constraints. It then enhances the solution via a high- level random local search. The approximate approach improves existing upper bounds by 27.45% on average, and obtains the optimum for 33.93% of the in- stances. Overall, the exact and approximate approaches find the optimum in 39.07% cases. The proposed approach is applicable to complex problems. It applies CP and MIP sequentially, while exploring their advantages, and hybridizes heuris- tic search with MIP. It embeds a new lookahead strategy that guards against infeasible search directions and constrains the search to improving directions only; thus, differs from traditional lookahead beam searches. Keywords: heuristic, lookahead search. cutting, two-dimensional bin packing, batch scheduling, packing ∗Corresponding author. Tel: +965-669-14150. Fax: +965-248-37332. Email addresses: [email protected] (Sergey Polyakovskiy), [email protected] (Rym M'Hallah) Preprint submitted to Elselvier November 9, 2017 1. Introduction Bin packing (BP) is a classical strongly NP-hard combinatorial optimization problem (Jansen & Pradel, 2016; Johnson et al., 1974). It consists in packing a set of items into as few bins as possible. Because of its prevalence in industry, BP has engendered many variants. Some variants impose additional constraints on the packing of the items or on the types of bins such as the oriented, or- thogonal, guillotine, and variable-sized BP. More recent variants combine BP with further complicating combinatorial aspects. For example, BP appears in combination with routing problems: minimizing transportation costs subject to loading constraints (Iori & Martello, 2013). It also emerges in lock scheduling (Verstichel et al., 2015) where lockages are scheduled, chambers are assigned to ships, and ships are positioned into chambers. Following this trend, this paper addresses the non-oriented two-dimensio- nal BP problem where items have due dates. This problem, denoted hereafter 2BPP with DD, searches for a feasible packing of a given set of n rectangular items into a set of at most b ≤ n identical rectangular bins, and schedules their packing as to minimize the maximum lateness Lmax of the items. Each item is characterized by its width, height, and due date. Its lateness is the difference between its completion time and its due date, where its completion time is that of its assigned bin. All bins' processing times are equal regardless of their assigned items. This problem is common in make-to-order low-volume production systems such as the high-fashion apparel industry and food delivery. In these contexts, packing efficiency might be increased by mixing up several orders; however, the increased efficiency can not be at the cost of customer service. That is, a company should choose, from the pool of items emanating from all orders, the ones that need to be packed (or cut) simultaneously with the objective of maximizing material utilization (or packing efficiency) while meeting due dates. Similar problems were considered in the literature. Reinertsen & Vossen (2010) investigate the one-dimensional cutting stock problem within steel man- ufacturing where orders have due dates that must be met. Arbib & Marinelli (2017) study a one-dimensional bin packing problem with the objective of min- imizing a weighted sum of maximum lateness and maximum completion time. Li (1996) tackles a two-dimensional cutting stock problem where meeting the orders' due dates is more important than minimizing the wasted material. Ar- bib & Marinelli (2014) survey the state of the art on packing with due dates. Polyakovskiy & M'Hallah (2011) address the on-line cutting of small rectangular items out of large rectangular stock material using parallel machines in a just- in-time environment. The cutting pattern minimizes both material waste and the sum of earliness-tardiness of the items. Polyakovskiy et al. (2017) consider another variant of BP. Items that are cut from the same bin form a batch, whose processing time depends on its assigned items. The items of a batch share the completion time of their bin. The problem searches for the cutting plan that minimizes the weighted sum of the earliness and tardiness of the items. Bennell et al. (2013) deal with a bi-criteria version of 2BPP with DD. They 2 minimize simultaneously the number of used bins and the maximum lateness of the items. They propose a lower bound LB1 to Lmax and approximately solve their bi-criteria problem using a single-crossover genetic algorithm, a multi- crossover genetic algorithm (MXGA), a unified tabu search, and a randomized descent. They generate a benchmark set for which they report the best average value for each of their two objective functions. They conclude that MXGA yields consistently the best upper bound LMXGA on Lmax. max This paper focuses on minimizing Lmax only (in lieu of both the number of used bins and Lmax as the bi-criteria case does). It is in no way a shortcoming for four reasons. First, the number of bins is naturally bounded. Second, for a given feasible bound on the number of used bins b, searching for the minimal Lmax is a standard practice to tackle multi-objective problems. Thus, it can be applied iteratively to build the Pareto optimal frontier of the bi-criteria problem. Third, the objectives of minimizing lateness and maximizing packing efficiency do not necessarily conflict (Bennell et al., 2013). Finally, it can be used by decision makers as a decision support tool that quantifies the tradeoff between service quality loss and reduction of both ecological cost and waste material. As for all difficult combinatorial optimization problems, finding an exact solution, in a reasonable time, for large-sized instances of 2BPP with DD is challenging. Indeed, BP variants are generally tackled using approximate ap- proaches that are based on meta-heuristics (Lodi et al., 2002, 2014; Sim & Hart, 2013), including genetic algorithms, and hyper-heuristics (Burke et al., 2006; L´opez-Camacho et al., 2014; Sim et al., 2015). Unlike the aforementioned techniques, the proposed two-stage approximate approach for 2BPP with DD ex- plores the complementary strengths of constraint programming (CP) and mixed integer programming (MIP). In its first stage, it applies CP. In its second stage, it hybridizes heuristic search with MIP, where MIP is in turn guided by feasi- bility constraints. In addition, it applies an innovative lookahead strategy that (i) forbids searching in directions that will eventually lead to infeasible solutions and (ii) directs the search towards improving solutions only. Consequently, the proposed assignment based packing approach with its new lookahead strategy is a viable alternative to the constructive heuristics traditionally applied to BP, where bins are filled sequentially in a very greedy manner (Lodi et al., 2002). Section 2 gives a mathematical formulation of the 2BPP with DD. Section 3 provides essential background information on feasibility constraints and on a CP-based approach for the two-dimensional orthogonal packing problem. Sec- tion 4 presents the existing lower bounds LB1 and LB2 and the new one LB3. Section 5 proposes the two-stage solution approach with Section 5.1 detailing the first-fit heuristic (i.e., stage one), Section 5.2 describing the assignment based heuristic, and Section 5.3 summarizing the second stage. Section 6 discusses the results of the computational investigation performed on benchmark instances. Finally, Section 7 summarizes the paper and gives some concluding remarks. 3 2. Mathematical Formulation Let B = {1, . . . , b} be a set of b identical rectangular bins. Bin k ∈ B has a width W , a height H, and a processing time P . Items assigned to the same bin have a common completion time. Let N = {1, . . . , n} be a set of n rectangular items, where n ≥ b. Item i ∈ N has a width wi ≤ W , a height hi ≤ H, and a due date di. When wi ≤ H and hi ≤ W , item i ∈ N may be rotated by 90o for packing purposes. Every item i ∈ N must be packed without overlap and must be completely contained within its assigned bin. When assigned to bin k, item i ∈ N has a completion time Ci = kP and lateness Li = Ci − di. The 2BPP with DD consists in finding a feasible packing of the n items into the available {Ci − di}. bins with the objective of minimizing Lmax, defined by Lmax = max i∈N Let N∗ denote the set N appended by the rotated duplicates. The duplicate of item i, i ∈ N , is item n + i of width hi, height wi and due date di. The problem is then modeled as an MIP with six types of variables. • x and y denote the position of an item within its assigned bin, where xi ≥ 0 and yi ≥ 0, i ∈ N∗, are the bottom left coordinates of item i. packed into bin k, i ∈ N∗, k ∈ B, and 0 otherwise. • f signals the assignment of an item to a bin, where fik = 1 if item i is • l and u are binary. They refer to the relative position of two items. lij = 1 (resp. uij = 1), i ∈ N∗, j ∈ N∗, i (cid:54)= j, j (cid:54)= i + n, and i (cid:54)= j + n, is used to make i to the left of (resp. below) j when i and j are in the same bin. • The sixth is the objective value, which is Lmax. When the rotated duplicate of item i cannot fit into a bin, i.e. its wi ≤ H and hi ≤ W, i ∈ N , its corresponding decision variables are not defined; thus, they are omitted from the model; so are any corresponding constraints. The MIP model (EXACT), which uses the disjunctive constraint technique of Chen et al. (1995) and Onodera et al. (1991), follows. min Lmax s.t. lij + lji + uij + uji − fik − fjk ≥ −1 xi + wi ≤ xj + W (1 − lij ) yi + hi ≤ yj + H (1 − uij ) xi ≤ W − wi yi ≤ H − hi (fik + fn+ik) = 1 (kP − di) fik ≤ Lmax (cid:88) (cid:88) k∈B (1) (i, j) ∈ N∗2, i < j, j (cid:54)= n + i, k ∈ B (2) (i, j) ∈ N∗2, i (cid:54)= j, j (cid:54)= i + n, i (cid:54)= j + n (3) (i, j) ∈ N∗2, i (cid:54)= j, j (cid:54)= i + n, i (cid:54)= j + n (4) i ∈ N∗ (5) i ∈ N∗ (6) i ∈ N (7) i ∈ N∗ (8) k∈B lij ∈ {0, 1} , bij ∈ {0, 1} fik ∈ {0, 1} xi ∈ R≥0, yi ∈ R≥0 Lmax ∈ R (i, j) ∈ N∗2, i (cid:54)= j, j (cid:54)= i + n, i (cid:54)= j + n (9) i ∈ N∗, k ∈ B (10) i ∈ N∗ (11) (12) Equation (1) defines the objective value. It minimizes the maximum lateness. Equation (2) determines the relative position of any pair of items that are as- signed to a same bin: one of them is either left of and/or below the other. 4 Equation (3) ensures that items i and j do not overlap horizontally if in the same bin while Equation (4) guarantees that they do not overlap vertically. Equations (5) and (6) guarantee that i is entirely contained within a bin. Equa- tion (7) ensures either i or its rotated copy i + n is packed into exactly one bin. Equation (8) sets Lmax larger than or equal to the lateness Li of i, where Li is the difference between the completion time of the bin to which i is assigned and the due date of i. Finally, Equations (9)-(12) declare the variables' types. The model has a quadratic number of variables in n. Because b is bounded by n, the model has a cubic number of constraints in n. The solution space has a large number of alternative solutions with many symmetric packing set ups. Subsequently, EXACT is hard to solve. Small-sized instances with as few as 20 items require significant computational effort. 3. Background The two-dimensional orthogonal packing problem (2OPP) determines whether a set of rectangular items can be packed into a rectangular bin. This decision problem is used, in this paper, when generating the lower bound LB3 (cf. Sec- tion 4.2) and as part of the new first-fit heuristic (FF) (cf. Section 5.1) when searching for a feasible packing. LB3 is the optimal solution of a mixed integer program that substitutes the containment and overlap constraints of EXACT by feasibility constraints. These constraints explore the notion of dual feasible functions (DFF) to strengthen the resulting relaxation of EXACT. Section 3.1 presents DFFs and explains their application to the non-oriented version of 2OPP. 2OPP arises also as a part of the constructive heuristic FF, which consti- tutes the first stage of the proposed solution approach APPROX . Specifically, every time it considers a subset of items, FF solves a non-oriented 2OPP to determine the feasibility of packing those items into a bin. As it calls the 2OPP decision problem several times, FF needs an effective way of tackling it. For this purpose, it models the problem as a CP, and augments it with two addi- tional constraints issued from two related non-preemptive cumulative scheduling problems. Section 3.2 presents this CP model. 3.1. Feasibility Constraints Alves et al. (2016) explore standard DFFs for different combinatorial opti- mization problems, including cutting and packing problems. Fekete & Schepers (2004) apply DFFs to find a lower bound L2d to the minimal number of bins needed to pack orthogonally a given set of two-dimensional oriented items. This section explains how to use DFFs to generate feasibility constraints. A function u : [0, 1] → [0, 1] is dual feasible if (cid:88) s∈S s ≤ 1 ⇒(cid:88) s∈S u (s) ≤ 1 holds for any set S of non-negative real numbers. Let u1 and u2 be two valid DFFs. For the problem at hand, the DFFs transform the scaled sizes (w(cid:48) i) of i, h(cid:48) 5 item i ∈ I into differently scaled ones (u1(w(cid:48) and h(cid:48) areas of the transformed items must be less than or equal to 1, i = wi/W i = hi/H. For a feasible packing into a single bin to exist, the sum of the i)) ∈ (0, 1] where w(cid:48) i), u2(h(cid:48) u1 (w(cid:48) i) u2 (h(cid:48) i) ≤ 1. (13) (cid:88) i∈I ci (resp. αr ci) ∈ Rm×n≥0 Let Ao = (αo This section explains how DFFs are combined in various ways to generate m inequalities/constraints in the form of Equation (13) for the non-oriented 2OPP. ci) ∈ Rm×n≥0 and Ar = (αr denote two real-valued ci), i ∈ N, c = 1, . . . , m, is a technological matrices. Element αo scaled area computed using w(cid:48) i and h(cid:48) i (resp. w"i = hi/W and h"i = wi/H) as arguments for DFFs u1 and u2, respectively. Fekete & Schepers (2004) designed DFFs, namely u(1), U (), and φ(),  = p, q. The functions and approach they use to obtained L2d is used herein to derive the combinations of functions (u1, u2). The DFFs' input parameters (p, q) ∈ (0, 0.5]2 , as further specified in Section 6. Furthermore, let to ∈ {0, 1}n (resp. tr ∈ {0, 1}n) be a binary decision vector i = 1) if item i, i ∈ N , is packed into the bin without (cid:88) i ≤ 1, the inequality such that to rotation (resp. with rotation) and 0 otherwise. When to i = 1 (resp. tr i + tr c = 1, . . . , m, (14) (αo cito i + αr citr i ) ≤ 1, i∈N derived from Equation (13), is a valid feasibility constraint. Equation (14) assumes that the rotated duplicate of an item i, i ∈ N, can fit into the bin. As mentioned in Section 2, when this assumption does not hold, tr i = 0 and is omitted from Equation (14). (cid:88) c, c = 1, . . . , m, is redundant if either i∈N c(cid:48), c(cid:48) = 1, . . . , m, c (cid:54)= c(cid:48), such that both αo ci ≤ αo Some of the m constraints of Equation (14) may be redundant. A constraint ci) ≤ 1 or there exists ci ≤ αr c(cid:48)i for all i ∈ N . c(cid:48)i and αr max (αo ci, αr 3.2. Solving the 2OPP with Constraint Programming 2n} and Ah =(cid:8)ah This section develops a CP model for the non-oriented 2OPP. The CP model, which is an extension of the model of Clautiaux et al. (2008) for orthogonal packing, is strengthened by constraints issued of two non-preemptive cumulative scheduling problems. In this model, a bin corresponds to two distinct resources rw and rh of capacity W and H, respectively, while the items to two sets of activities Aw = {aw i are the width and height of item i, i ∈ N∗. The first (resp. second) scheduling problem treats the widths (heights) of the items as processing times of activities Aw (resp. Ah) and considers the heights (widths) of the items as the amount of resource rh (rw) required to complete these activities. The activities in Aw and i+n, • = w, h, cannot both be Ah have compatibility restrictions; i.e., a• scheduled. (cid:9) where aw i and a• 1 , . . . , ah 2n 1 , . . . , aw i and ah The first (resp. second) scheduling problem investigates whether its set of activities Aw (resp. Ah) can be performed within their respective time windows, 6 rw). without preemption and without exceeding the availability H (resp. W ) of In fact, Aw and Ah are to be performed required resource rh (resp. concurrently but using two different resources. Activity aw i has a processing time wi and a time window [0, W − wi). To be processed, it uses an amount hi of resource rh. Similarly, activity ah i has a processing time hi and a time window [0, H − hi). Its processing requires an amount wi of resource rw. Let i denote the respective starting times of activities aw sw i and sh i . Then, sw i and sh i are the coordinates (xi, yi) of item i in the bin. The CP model that solves 2OPP is then given as: i and ah (cid:16) PresenceOf(aw (cid:16) (cid:17)(cid:17)(cid:54)= (cid:16) PresenceOf(cid:0)aw i ) (cid:54)= PresenceOf(cid:0)aw (cid:1) i )∧PresenceOf (cid:17) (cid:54)= PresenceOf (cid:16) (cid:17) PresenceOf(aw (cid:17)∧PresenceOf(cid:0)aw (cid:16) (cid:16) (cid:1)∧PresenceOf ah i (cid:17)∨(cid:16) (cid:1)∨(cid:16) (cid:1)∨(cid:0)sw i )∧PresenceOf ah ah i j j + hj ≤ sh j + wj ≤ sw sh (cid:16) (cid:1)∧PresenceOf (cid:17) ⇒ (cid:17) i + hi ≤ sh sh (cid:0)sw n+i ah n+i PresenceOf (cid:16) ah i n+i i j j (cid:17)(cid:17) ah n+i i (i, j) ∈ N∗2, i < j, j (cid:54)= n + i i ∈ N (15) i ∈ N (16) i ∈ N (17) (18) (19) (20) PresenceOf(aw i + wi ≤ sw (cid:16)(cid:104) j 1 , . . . , sw Cumulative([sw sh 1 , . . . , sh 2n Cumulative (cid:105) 2n] , [w1, . . . , w2n] , H) , [h1, . . . , h2n] , W (cid:17) i , ah i , ah n+i, ah n+i, ah i ) and (aw i ) and (aw n+i when ah Meta-constraint (15) guarantees that one of the pairs (aw n+i) is scheduled, where (aw n+i) correspond to item i and its rotated duplicate n + i. It uses the PresenceOf(a) constraint that signals the presence of optional activity a, a ∈ Aw ∪ Ah. It returns true when the optional activity a is present, and false otherwise. Constraint (16) forbids scheduling activity aw n+i when aw is scheduled and vice versa. Similarly, constraint (17) prohibits i scheduling activity ah i is scheduled. Despite the presence of constraint (15), constraints (16) and (17) are needed to eliminate some infeasible cases. For instance, constraint (15) discards neither the case where activities aw i , and aw n+i are scheduled while ah n+i is not nor the case where activities aw i , and ah n+i are scheduled while aw n+i is not. On the other hand, constraints (16) and (17) remove these cases. Constraint (18) ensures the no-overlap of any pair (i, j) ∈ N∗2, i < j, j (cid:54)= n + i, of packed items. Its left hand side holds when activities aw j are scheduled and implies the right hand side, which is a disjunctive constraint that avoids the horizontal and vertical overlap of i and j by setting i to the left of j or i above j or j to the left of i or j above i, where the 'or' is inclusive. Finally, cumulative constraint (19) (resp. (20)) makes the activities of Aw (resp. Ah) complete within their respective time windows without exceeding the resource's capacity H (resp. W ). Even though redundant, constraints (19)-(20) do strengthen the search. The CP model returns a feasible solution if and only if every item of N is assigned to the bin regardless of its rotation status. i , ah i , ah j , and ah i , ah i , aw For this model, the search tree is constructed as recommended by Clau- 2n are instantiated after variables tiaux et al. (2008); 2n. The CP-model is solved via the IBM ILOG CP Optimizer 12.6.2 1 , . . . , sw sw (Laborie, 2009); set to the restart mode, which applies a failure-directed search i.e., variables sh 1 , . . . , sh 7 when its large neighborhood search fails to identify an improving solution (Vil´ım et al., 2015). That is, instead of searching for a solution, it focuses on eliminat- ing assignments that are most likely to fail. (cf. Laborie & Rogerie (2008) and Vil´ım (2009) for basics of optional interval variables (i.e. optional activities) and cumulative constraints.) When allocated a threshold run time tPACK lim , the CP Optimizer acts as a heuristic, denoted hereafter as PACK. Preliminary experiments showed that PACK fathoms a large portion of infeasible solutions, especially when they are beyond "the edge of feasibility". 4. Lower Bounds This section presents three lower bounds for 2BPP with DD: two existing and a new one. These three bounds are compared in Section 6.2. Herein, LB designates the linear-time lower bound algorithm of Dell'Amico et al. (2002) for the non-oriented two-dimensional bin packing problem while LB(S) is a lower bound on the number of bins needed to pack the items of set S. 4.1. Existing Lower Bounds The procedure to calculate LB1 proceeds as follows. First, it sorts N in a non-decreasing order of the due dates, and sets [j] to the item with the jth of the lateness of the subset of items S[j] = {[1], . . . , [j]}. Some items must have (cid:1), j = 1, . . . , n, to deduce a lower bound earliest due date. It then uses LB(cid:0)S[j] (cid:1); thus, have a lateness of at least P ·LB(cid:0)S[j] (cid:1)−dj. a completion time P· LB(cid:0)S[j] {P · LB(cid:0)S[j] (cid:1) − dj} is a valid lower bound on Lmax. Therefore, LB1= max j=1,...,n Clautiaux et al. (2007) use DFFs to compute lower bounds for the non- oriented bin packing problem when the bin is a square. They show that their bounds dominate LB both theoretically and computationally for square bins. However, for rectangular bins, the quality of this bound remains an open issue. LB2, the second lower bound on Lmax, is the result of the linear relaxation of EXACT where all the binary variables are substituted by variables in [0, 1] . 4.2. A New Lower Bound To the opposite of LB2, which drops the integrality constraints, the new lower bound LB3 is the optimal value of RELAX , which is a mixed integer programming relaxation of EXACT. RELAX exchanges the disjunctive con- straints, given by Equations (2)-(6), with the feasibility constraints (αo cifik + αr cifn+ik) ≤ 1, k ∈ B, c = 1, . . . , m, (21) (cid:88) i∈N which are defined in the form of Equation (14). The disjunctive constraints define the geometrical relationships between pairs of packed items and between a packed item and its assigned bin. They consider both the height and width of the items and bins and ensure the non-overlap of pairs of items and the 8 containment of an item in the bin in both directions. The feasibility constraint, on the other hand, assimilates the item and the bin into dimensionless entities. Its inclusion in RELAX tightens the relaxation and improves the quality of the lower bound. Excluding it omits the layout aspect of the problem; thus, can not produce reasonably good bounds. LB3 is a valid bound if and only if RELAX is solved to optimality. 5. Approximate Approaches APPROX is a two-stage approximate approach for 2BPP with DD. The first stage constructs an initial solution and obtains related upper bounds using a new first-fit heuristic (FF). The second stage is iterative. It improves the current solution via an assignment-based heuristic HEUR and its relaxed version HEUR(cid:48), and updates the bounds if possible. The second stage diversifies its search when it stagnates. Sections 5.1 - 5.3 detail FF, HEUR, and APPROX . 5.1. First-Fit Heuristic FF solves, via CP, a series of 2OPPs, where each 2OPP determines the feasibility of packing a given set of items into a single bin. It constructs a solution as detailed in Algorithm 1. It sorts the items of N in a non-descending order of their due dates, sets k = 0, and applies a sequential packing that iterates as follows until N = ∅. First, it determines the current bin k to be filled, and initializes its set Nk of packed items to the empty set. It removes the first item from N and inserts it into Nk. Two scenarios are possible. When LB (Nk) ≤ 1, it considers the next item of N. (The use of LB (Nk) ensures that FF starts with a dense packing; thus, limits the number of sequential calls to PACK.) Otherwise, it undertakes a backward step followed by an iterative sequential packing step. It calls PACK from Section 3.2 to determine whether it is possible to pack the items of Nk. When infeasibility is detected (potentially because PACK runs out of time), the backward step removes the last added item from Nk (because it may have caused the infeasibility) and inserts i back into N. Then it calls PACK again. When a feasible solution is obtained, FF proceeds with the iterative sequential packing step. The constructive step considers the items of N sequentially. For every i ∈ N, it checks whether a feasible packing is possible. Specifically, it calls PACK when LB (Nk ∪ {i}) ≤ 1. When PACK determines that it is possible to pack the items of Nk ∪ {i} into the current bin, the constructive step removes i from N and inserts it into Nk. Having tested all unpacked items of N, FF proceeds to the next bin by incrementing k to (k + 1) if N (cid:54)= ∅. Hence, FF obtains an initial solution, characterized by its number of bins b and its corresponding maximum lateness UB. Subsequently, APPROX feeds this information to its second stage. 5.2. An Assignment-Based Heuristic The second stage of APPROX applies iteratively an assignment-based heuris- tic HEUR, which determines the feasibility of packing a set of oriented two- dimensional items into a set of multiple identical two-dimensional bins. Finding 9 move the first item of N to Nk; Algorithm 1 First-fit heuristic algorithm FF(N ) 1: sort N in a non-descending order of items' due dates; 2: set k = 0; 3: while (N (cid:54)= ∅) do set k = k + 1; 4: open a new bin k setting Nk = ∅; 5: while (LB (Nk) ≤ 1) do 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: end for 16: 17: end while 18: return solution as (N1, . . . , Nk); end while while (PACK(Nk) ⇐⇒ inf easible) do end while for each item i ∈ N do move the last item of Nk back to its position in N ; if ((LB (Nk ∪ {i}) ≤ 1) and PACK(Nk ∪ {i}) ⇐⇒ f easible)) then move item i from N to Nk; end if a feasible packing is hard not only because of the large number of alternative positions of an item within a bin but also because of the multitude of solutions having equal Lmax. Herein, HEUR implements four strategies that enhance its performance. First, it reduces the search space to a subset of feasible posi- tions, which correspond to the free regions within a bin. As it applies its greedy search to position items, it creates some free regions and fills others; thus, the search space is dynamic. Second, HEUR packs simultaneously as many items as possible into the various free regions. Thus, it reduces the number of itera- tions needed to obtain a solution; consequently, it decreases its runtime. Third, HEUR implements a new kind of lookahead strategy that directs the search to- wards a feasible packing. This guiding mechanism imposes feasibility constraints that prohibit the current two-dimensional assignment problem ASSIGN from generating partial solutions that will lead to infeasible ones in future iterations. This innovative mechanism makes current decisions account for their impact on future ones. Fourth and last, HEUR uses upper bounds UB on Lmax and b(UB) on the number of bins. These bounds further reduce the search space: a candidate solution is a feasible packing whose Lmax < UB and which uses at most b(UB) bins. Initially, UB is the Lmax of the solution of FF. HEUR, sketched in Algorithm 2, uses the following sets as input: the set N of not yet packed items, the set N of packed items, and the set E of available rectangular regions. These three sets are updated dynamically at each iteration. Initially, N is the set of the n items, N = ∅, and E = B, where B = b = b(UB). Thus, the set Ek of free regions contained in bin k, k ∈ B, is initially the kth bin: Ek = {(W, H)}, with Ek ⊆ E and ∪k∈BEk = E. Let (e, e(cid:48)) ∈ E2 denote two free regions characterised by their respective dimensions (We, He) and (We(cid:48), He(cid:48)) and by their bottom leftmost coordinate positions (xe, ye) and (xe(cid:48), ye(cid:48)) in their respective bins. When in a same bin, e 10 and e(cid:48) may overlap, as in Figure 1. To guard against assigning two items to the overlap area of e and e(cid:48), HEUR includes, into the assignment model, geometrical and disjunctive conditions that only apply if e and e(cid:48) are in the same bin and overlap. HEUR signals such overlap via four parameters. • θi • θii • θiii • θiv ee(cid:48) = 1 if (xe < xe(cid:48)) ∧ (ye > ye(cid:48)) as in Figure 1.a and 0 otherwise. ee(cid:48) = 1 if (xe < xe(cid:48)) ∧ (ye < ye(cid:48)) as in Figure 1.b and 0 otherwise. ee(cid:48) = 1 if (xe = xe(cid:48)) ∧ (ye > ye(cid:48)) as in Figure 1.c and 0 otherwise. ee(cid:48) = 1 if (xe < xe(cid:48)) ∧ (ye = ye(cid:48)) as in Figure 1.d and 0 otherwise. Similarly, it signals the already packed items via parameters • ρo • ρr ik = 1 if i ∈ N is packed in k ∈ B without rotation and 0 otherwise; and ik = 1 if i ∈ N is packed in k ∈ B with rotation and 0 otherwise. When item i is not yet packed (i.e., i ∈ N ), ρo ik + ρr ik = 0. (cid:88) k∈B Figure 1: Patterns where two regions e and e(cid:48) overlap Let EU i = ∪k∈B {Ek : kP − di < UB} denote the set of regions where i ∈ N {e : (hi ≤ We) ∧ (wi ≤ He)} are the sets of regions where i can can be scheduled and Li < UB. EU and Er be positioned without and with rotation respectively. i = ∪e∈EU i ⊇ Eo i ∪Er i = ∪e∈EU i , where Eo i {e : (wi ≤ We) ∧ (hi ≤ He)} i In each iteration, HEUR solves ASSIGN , which attaches a subset of un- packed items to regions of E using the following variables. • ϕo ie = 1 if item i ∈ N, is assigned without rotation to e ∈ Eo otherwise. i and 0 11 e´e(xe´ , ye´ )(xe , ye )e´e(xe´ , ye´ )(xe , ye )e´e(xe´ , ye´ )We´ We´ We´ We´ He´ He´ He´ He´ (xe , ye )We We We We He He He He e´e(xe´ , ye´ )(xe , ye )a)b)c)d) • ϕr • f o • f r i and 0 otherwise. ie = 1 if i is assigned with rotation to e ∈ Er ik = 1 if i can be packed without rotation in a future iteration in bin k such that Li = P k − di < UB, and 0 otherwise. ik = 1 if i can be packed with rotation in a future iteration in bin k such that Li = P k − di < UB, and 0 otherwise. f o ik allocate free space for items to be packed in future iterations without increasing UB. • we ∈ [0, We] and he ∈ [0, He], the width and height of the used area of ik and f r e ∈ E when an item is positioned in (xe, ye). • lee(cid:48) and uee(cid:48) are binary. They refer to the relative position of two areas e and e(cid:48). lee(cid:48) = 1 (resp. uee(cid:48) = 1) is used to make e to the left of (resp. below) e(cid:48) when e and e(cid:48) are part of the same bin. ASSIGN maximizes the total profit generated by the packed items subject to non-overlap and containment constraints. The profit of i, i ∈ N, is si ≥ 0. When si = wihi, ASSIGN maximizes the utilization of the bins; i.e., the density of the packed items. Formally, ASSIGN is modeled as an MIP: 12 max s.t.  (cid:88)  + (cid:88) ϕr ie e∈Er i WeHe i + si i i i i ϕo ϕo ie i∈N ϕr ie + ϕo ie + ie + e∈Er e∈Eo e∈Eo WeHe i∈N : e∈Eo i∈N : e∈Er  (cid:88) (cid:88) (cid:88) (cid:88) (cid:88) (cid:88)  (cid:88) (cid:88) (cid:88) (cid:88) (cid:88) i∈N : e∈Eo αr cif r i (cid:54)=∅ wiϕo ie ≤ 1 ϕr (cid:88) (cid:88) ik ≤ 1 −(cid:88) (cid:88) (cid:88) i∈N : e∈Er αo ciϕo i∈N : Ek∩Er i∈N : e∈Eo e∈Ek hiϕr ie + ie + i∈N i i i hiϕo ie + i∈N : e∈Er i (αo wiϕr ie ≤ he i i i∈N : e∈Er i∈N : e∈Eo xe + we ≤ xe(cid:48) + We (1 − lee(cid:48) ) ye(cid:48) + he(cid:48) ≤ ye + He(cid:48) (1 − ue(cid:48)e) ye + he ≤ ye(cid:48) + He (1 − uee(cid:48) ) ie ≤ we f o ik + i (cid:54)=∅ k∈B: Ek∩Er f r ik = 1 i (cid:54)=∅ k∈B: Ek∩Eo (cid:88) i∈N : Ek∩Eo ciρr ik) αr ciϕr ie ciρo ik + αr ik+ αo cif o i (cid:54)=∅ he(cid:48) + (ye(cid:48) + He(cid:48) − ye) ϕo ie + ϕr ie we + (xe + We − xe(cid:48) ) ϕo ie(cid:48) + ϕr ie(cid:48)  (cid:88)  (cid:88) i∈N : e∈Eo i∈N : e(cid:48)∈Eo i i  ≤ He(cid:48)  ≤ We (cid:88) i∈N : e∈Er i (cid:88) i∈N : e(cid:48)∈Er i lee(cid:48) + ue(cid:48)e ≥ 1 lee(cid:48) + uee(cid:48) ≥ 1 ie ∈ {0, 1} , ϕr ϕo ik ∈ {0, 1} f o ik ∈ {0, 1} f r lee(cid:48) ∈ {0, 1} , uee(cid:48) ∈ {0, 1} ie ∈ {0, 1} 0 ≤ we ≤ We, 0 ≤ he ≤ He (22) e ∈ E (23) i ∈ N (24) k ∈ B, c = 1, . . . , m (25) e ∈ E (26) e ∈ E (27) (e, e(cid:48))∈ E2 : θi ee(cid:48) +θii (e, e(cid:48)) ∈ E2 : θi (e, e(cid:48)) ∈ E2 : θii ee(cid:48) = 1 (28) ee(cid:48) = 1 (29) ee(cid:48) = 1 (30) (e, e(cid:48)) ∈ E2 : θiii ee(cid:48) = 1 (31) (e, e(cid:48)) ∈ E2 : θiv ee(cid:48) = 1 (32) (e, e(cid:48)) ∈ E2 : θi (e, e(cid:48)) ∈ E2 : θii ee(cid:48) = 1 (33) ee(cid:48) = 1 (34) i ∈ N, e ∈ E (35) i (cid:54)=∅ (36) i (cid:54)=∅ (37) (cid:17) (e, e(cid:48)) ∈ E2 : θii ee(cid:48) = 1 (cid:17) ∨(cid:16) (38) e ∈ E (39) i∈ N, k∈ B : Ek∩Eo i∈ N, k∈ B : Ek∩Er (cid:16) θi ee(cid:48) = 1 Equation (22) defines the objective function value as the weighted sum of the profits of packed items where the weight of an item i is inversely proportional to the area of region e used for its positioning. Equation (23) prohibits packing more than one item into any region e ∈ E. Equations (24) and (25) are part of the lookahead strategy. They employ ik, ∗ = o, r, i ∈ N, k ∈ B, to reserve a free space for unpacked items. Equation f∗ 13 ci and αr (24) assigns i, i ∈ N , either to one of the available regions during the current iteration or to one of the bins during a later iteration. Equation (25) imposes the set of feasibility constraints. Here, c, c = 1, . . . , m determines a vector ci) computed for all the items on N ∪ N and of transformed areas (αo their rotated copies and represented via matrices Ao and Ar (cf. Section 3.1). For every c, c = 1, . . . , m, and k ∈ B, Equation (25) requires that the sum of the transformed areas of (i) the items that have been previously packed (ρ∗ ik = 1, ∗ = o, r), (ii) those being packed at the current iteration (ϕ∗ ie = 1, ∗ = o, r), ik = 1, ∗ = o, r) in selected and (iii) those to be packed in future iterations (f∗ bin k be bounded by 1. Even though it discards many partial solutions that lead to an infeasible packing, Equation (25) doesn't guarantee that a not-yet-packed i will get a feasible position during later iterations. Equations (26) and (27) determine we and he of the used area of e by im- ee(cid:48). ee(cid:48) to θiv posing that wi and hi do not exceed we and he if i is assigned to e. Equations (28)-(34) guarantee the non-overlap of a pair of items packed in two overlapping regions (e, e(cid:48)). They substitute the full set of the disjunctive constraints that are traditionally used to ensure the non-overlap of packed items in a bin. This substitution reduces the number of constraints by eliminating redundant ones. That is, instead of considering all possible pairs of regions, ASSIGN focuses on those that can potentially create an overlap of packed items. It detects these regions via parameters θi Equations (28)-(30) focus on the case where e is to the left of e(cid:48) but e and e(cid:48) overlap. For those regions, Equation (28) makes the x−coordinate of the rightmost point of the used area of e less than or equal to its counterpart for the leftmost point of e(cid:48). Equations (29) and (30) constrain the vertical positions of the used areas of e and e(cid:48). Equation (29) deals with the case when e(cid:48) is below ee(cid:48) = 1 as in Figure 1.a. It restricts the y−coordinate of the topmost e and θi point of the used area of e(cid:48) to be less than or equal to its counterpart of the bottommost point of e. Similarly, when e(cid:48) is below e and θii ee(cid:48) = 1, Equation (30) constrains the topmost y−coordinate of the used area of region e to be less than or equal to the lowest y−coordinate of region e(cid:48); thus avoiding the potential overlap of items assigned to the two regions depicted in Figure 1.b. Equations (31) and (32) deal with two special cases: the left sides of e and e(cid:48) are aligned vertically, and the bottom sides of e and e(cid:48) are aligned horizontally. When e and e(cid:48) are aligned vertically and an item is packed in e, Equation (31) constrains the topmost y−coordinate of the used area of region e(cid:48) to be less than or equal to the lowest y−coordinate of region e as in Figure 1.c. Similarly, when both e and e(cid:48) are aligned horizontally and an item is positioned into e(cid:48), Equation (32) restricts the rightmost x−coordinate of the used area of region e to be less than or equal to the leftmost x−coordinate of e(cid:48) as in Figure 1.d. Equations (33) and (34) ensure that the used areas of any pair of overlapping regions (e, e(cid:48)) are such that the used area of e(cid:48) is below e, the used area of e is below e(cid:48) or the used area of e is to the left of e(cid:48). Finally, Equations (35)-(39) declare the types of the decision variables. When ASSIGN returns a feasible solution, HEUR moves the packed items ik = 1, ∗ = o, r, i ∈ N , k ∈ B, of the from N to N , and sets the parameters ρ∗ 14 move e from E to N ; end if end if else end if end for if (N = ∅) then end for if (∃ i ∈ N : Eo i ∪ Er i = ∅) then return infeasible solution; for each item i ∈ N do i) and (x(cid:48)(cid:48) i , y(cid:48)(cid:48) i ) for every item i ∈ N ; ie = 1)) then ie for k : e ∈ Ek; return feasible solution; i, y(cid:48) if ((cid:64) i∈ N : (wi≤ We)∧(hi≤ He)∧(kP −di < UB)) then if (∃ e ∈ E : (ϕo ik = ϕo ie = 1) ∨ (ϕr set ρo ie and ρr ik = ϕr move item i from N to N ; if (ASSIGN(cid:0)N, N , E(cid:1) ⇐⇒ f easible) then end if calculate coordinates (x(cid:48) update E exploring regions on top and to the right of every item i ∈ N ; for each region e∈ Ek, k∈ B do Algorithm 2 Assignment-Based Heuristic HEUR(UB) 1: initialize N = ∅ and E = B, B = b = b(UB); 2: while (true) do 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: end if 25: 26: end while items packed in the current iteration. Next, it calculates the coordinates (x(cid:48) i, y(cid:48) i) i ) of both the upper left and the bottom right corners of item i ∈ N , i , y(cid:48)(cid:48) and (x(cid:48)(cid:48) i, y(cid:48) where (x(cid:48) i ) = (xi + wiρo i) = (xi, yi + hiρo ik, yi). Finally, HEUR updates E using the following two-step approach. The first step defines the region et = (Wet, Het) on top of item i (cf. Figure 2.a). To identify the height Het, it searches along the ray x = xi and y ≥ y(cid:48) i for the first bottom side of another item j if such an item exists or the upper side of the bin. It sets Het = yt − y(cid:48) i, where y = yt is the line intersecting this side, with yt = yj if j exists, and yt = H otherwise. To determine the width Wet, it expands its search along the line y = y(cid:48) i; i.e., to both the left and right sides of x = xi. It shifts the left edge of et until it meets the first right edge of an item a or the left border of the bin. It determines the line x = x(cid:96) intersecting this side where x(cid:96) = x(cid:48)(cid:48) a if a exists, and x(cid:96) = 0 otherwise. Similarly, it moves the right edge of et until it meets either the first left edge of an item b or the right border of the bin. It finds the line x = xr intersecting this side where xr = xb if b exists, and xr = W otherwise. Subsequently, Wet = xr − xl. The second step defines the region er = (Wer , Her ) to the right of i (cf. Figure 2.b). It identifies the width Wer by searching along the ray y = yi, x ≥ x(cid:48)(cid:48) i for the first left side of another item j if j exists or the right side of the bin. It ik + wiρr ik) and (x(cid:48)(cid:48) i , y(cid:48)(cid:48) return infeasible solution; ik + hiρr 15 Figure 2: New regions created by the partial packing of a bin finds the line x = xr intersecting this side where xr = xj if j exists and xr = W otherwise. It deduces Wer = xr − x(cid:48)(cid:48) i . It determine the height Her by expanding its search along the line x = x(cid:48)(cid:48) i ; i.e., above and below y = yi. It moves the top edge of er until it meets either the first bottom edge of an item a or the top border of the bin. It sets the line intersecting this side to y = yt where yt = y(cid:48)(cid:48) a if a exists, and yt = H otherwise. Similarly, it shifts the bottom edge of er until it meets the first top edge of an item b or the lower border of the bin. It finds the line y = yb intersecting this side where yb = y(cid:48) b if b exists, and yb = 0 otherwise. Subsequently, Her = yt − yb. Having defined et and er, HEUR examines their "utility". It discards e if e cannot hold at least one of the unpacked items of N or e can hold an unpacked item but yields a lateness that is larger than or equal to UB. HEUR inserts a discarded region e into N treating e as a dummy item packed in bin k. This insertion strengthens Equation (25). Finally, HEUR inserts all non-discarded regions into E, and checks whether the stopping criterion is satisfied. In fact, HEUR stops when all the items are packed or there is an unpacked item that does not fit into any region of E. When the stopping criterion is not met, HEUR runs another iteration with the updated N and N . 5.3. Solution Process as a Whole APPROX , detailed in Algorithm 3, consists of two stages. The first stage applies FF to obtain an initial feasible solution to 2BPP with DD along with an upper bound UB on Lmax and an upper bound b(UB) on the number of bins in an optimal solution. The second stage strives to improve these two bounds and the current solution using both the assignment-based heuristic HEUR and its 16 (xi , yi )(xa , ya )(xi , yi )(xa , ya )(xj , yj )(xj , yj )e tWe tHe t123ijaWHa)(xi , yi )(xa , ya )(xb , yb )(xi , yi )(xb , yb )(xa , ya )(xj , yj )(xj , yj )e rWe rHe r123ijabWHb) Algorithm 3 The framework of APPROX 1: Stage 1: Initialization 2: run FF to obtain an initial solution; 3: compute UB and b = b(UB) = max i∈N {(cid:98)(UB +di)/P(cid:99)} based on the solution of Line 2; end if until count ≤ aHEUR if count > aHEUR lim lim then break; else if (call HEUR(cid:48) (UB) ⇐⇒ f easible) then compute UB and b = b(UB) based on the solution of Line 9; break; modify si = γwihi, i ∈ N, in Equation (22) of ASSIGN ; set count = count + 1; 4: Stage 2: Iterative Step 5: repeat set si = wihi, i ∈ N ; 6: set count = 0; 7: repeat 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: end if 19: 20: until true 21: repeat lines 5-20 replacing HEUR(cid:48) with HEUR; relaxed version HEUR(cid:48). Specifically, it solves the non-oriented 2OPP with b = {(cid:98)(UB + di) /P(cid:99)} bins so that the maximal lateness of any feasible b(UB) = max i∈N solution is less than UB. It solves the problem in two steps, each consisting of two loops: An outer loop whose objective is to identify a solution with a tighter UB rapidly and an inner loop whose objective is to refine the search. lines 5-20 of Algorithm 3) resets the profits si = wihi, i ∈ N , and the iteration counter count to 1. Then the inner loop runs HEUR(cid:48) (cf. lines 8-16), which is a reduced version of HEUR where ik, i ∈ N, k ∈ B, are omitted Equation (25) and the decision variables f o from the model ASSIGN . HEUR(cid:48) is generally weaker than HEUR in terms of the tightness of the upper bound of lateness but is faster in terms of run time. When it obtains a feasible solution, HEUR(cid:48) feeds APPROX with a solution whose Lmax < UB; that is, it tightens UB. This feasible solution may also reduce b = b(UB). Subsequently, APPROX exits the inner loop and runs one more iteration calling HEUR(cid:48) again but this time with new values of UB and b. On the other hand, when HEUR(cid:48) fails to find a feasible solution, the inner loop diversifies the search by using a different set of random profits. It changes the profits to si = γwihi, i ∈ N, where γ is a random real from the continuous Uniform[1,3], and increments count by 1. If count is less than or equal to a maximal number of iterations aHEUR lim , the inner loop starts a new iteration by solving HEUR(cid:48) with its modified profits in the objective function (i.e., in Equation (22) of ASSIGN ). In the first step, the outer loop (cf. ik and f r When count reaches the limit aHEUR lim , APPROX proceeds with the second step, which performs exactly the same actions as the first step does except that 17 it applies HEUR instead of HEUR(cid:48). The use of HEUR should improve the search. Therefore, the first step pre-solves the problem quickly while the second looks for an enhanced solution. Modifying the weight coefficients of Equation (22) of ASSIGN is a random local search (RLS). The choice of this particular diversification strategy along with this specific range of γ was based on preliminary computational investi- gations. Tests have shown that RLS yields, on average, better results than evolutionary strategies and techniques such as the method of sequential value correction (G. Belov, 2008). The superiority of RLS is due to the items' random order, which is further accentuated by the unequal weights. Classical approaches on the other hand do not tackle the highly symmetric nature of bin packing so- lutions. They mainly construct solutions based on the sequential packing of items in ascending order of their areas/widths/heights (Lodi et al., 2002). 6. Computational Experiments The objective of the computational investigation is fourfold. First, it com- pares the proposed lower bound LB3 to both LB1 and LB2. Second, it assesses the quality of the solution values of FF, APPROX and EXACT. Third, it com- pares the performance of FF and APPROX to that of MXGA. Last, it evaluates the performance of FF and APPROX on large-sized instances. All comparisons apply the appropriate statistical tests. All inferences are made at a 5% signifi- cance level, and all confidence interval estimates have a 95% confidence level. APPROX is implemented in C#, which evokes IBM ILOG Optimization Studio 12.6.2 to handle MIP and CP models. It is run on a PC with a 4 Gb RAM and a 3.06 GHz Dual Core processor. The time limit tPACK lim for PACK is set to 2 seconds. This setting, inferred from preliminary computational investigations, gives the best tradeoff between density of packing and runtime. Indeed, a longer tPACK lim does not necessarily lead to better packing solutions while it unduely increases the runtime of FF. Similarly, a shorter tPACK lim often hinders FF from reaching a feasible packing; thus causes poor quality solutions. The maximal number of iterations for count is aHEUR lim = 100, which also represents the best trade-off between quality and performance of APPROX according to our earlier tests. Furthermore, p ∈ {0.15, 0.3, 0.45}, q ∈ {0.15, 0.3, 0.45}, and up to m = 27 feasibility constraints are generated for the model ASSIGN of Section 5.2. A larger number of constraints does not generally improve the solution quality but increases the runtime of ASSIGN . Despite their large variety, the feasibility constraints of ASSIGN do not always tighten the lower bound on the free space available for packing. Therefore, their larger number does not necessarily tighten the model. Section 6.1 presents the benchmark set. Section 6.2 measures the tightness of LB3. Section 6.3 assesses the performance of FF, APPROX and EXACT in terms of their optimality gaps and number of times they reach the optimum. Section 6.4 compares the results of FF, APPROX and MXGA. Finally, Section 6.5 studies the sensitivity of FF, APPROX and EXACT to problem size. 18 6.1. Computational Set Up Bennell et al. (2013) generated the benchmark set (including the due dates) that we test. For each instance, they calculated LB1, and applied their multi- crossover genetic algorithm MXGA to obtain upper bounds. (MXGA was coded in ANSI-C using Microsoft Visual C++ 6.0 and run on a Pentium 4, 2.0 GHz, 2.0 GB RAM computer with a 120-second time limit per replication, and ten replications per instance.) They, then, computed the average percent deviations of their upper bounds from LB1. In their paper, they reported these average deviations aggregated over problem size. We use their aggregated average de- viations in the comparisons of Section 6.4. However, we recomputed their LB1 for every instance to perform the comparisons of Sections 6.2 and 6.4. Their benchmark set uses square bins (W = H) whose processing times P = 100. It consists of 10 categories as detailed in Table 1. Column 3 gives the width W of a bin. Column 4 specifies how items are generated. Each category is characterised by the dimensions of the items, with categories 1-6 having homogeneous items that are randomly generated from a specific discrete uniform whereas categories 7-10 contain heterogeneous items belonging to four types in various proportions. The four types correspond to items whose (wi, hi) are randomly selected from discrete uniforms on the respective ranges: • type 1: (cid:0)(cid:2) 2 • type 2: (cid:0)(cid:2)1, 1 • type 3: (cid:0)(cid:2) 1 • type 4: (cid:0)(cid:2)1, 1 3 W, W(cid:3) ,(cid:2)1, 1 2 W(cid:3)(cid:1); 3 W, W(cid:3)(cid:1); 2 W(cid:3) ,(cid:2) 2 2 W, W(cid:3)(cid:1); and 2 W, W(cid:3) ,(cid:2) 1 2 W(cid:3)(cid:1). 2 W(cid:3) ,(cid:2)1, 1 The categories can be divided, according to the relative size of the items, into two sets L and S. Set L, which contains instances with relatively large items, consists of categories 1, 3, 5, 7, 8, and 9. Set S, which contains instances with small items, consists of categories 2, 4, 6, and 10. Table 1: Generation of the widths and heights of items Category 1 2 3 4 5 6 7 8 9 10 Set L S L S L S L L L S Bin size (W ) 10 30 40 100 100 300 100 100 100 100 Item size (wi, hi) uniformly random in [1, 10] uniformly random in [1, 10] uniformly random in [1, 35] uniformly random in [1, 35] uniformly random in [1, 100] uniformly random in [1, 100] type 1 with probability 70%; type 2, 3, 4 with probability 10% each type 2 with probability 70%; type 1, 3, 4 with probability 10% each type 3 with probability 70%; type 1, 2, 4 with probability 10% each type 4 with probability 70%; type 1, 2, 3 with probability 10% each For each category, there are five problem sizes: n = 20, 40, 60, 80, and 100, and ten instances per category and problem size. For each problem, there are three classes A, B, and C of due dates, generated from the discrete Uni- form[101, βP · LB] where β = 0.6, 0.8, and 1.0; thus, a total of 1500 instances. 19 6.2. Quality of the Lower Bounds This section compares the performance of LB1, LB2, and LB3, where LB1 is computed via the algorithm of Section 4.1, LB2 is the value of the incumbent returned by CPLEX and LB3 is the optimal value of RELAX when CPLEX identifies the optimum within 1 hour of runtime. Table 2 summarizes the statis- tics of the lower bounds per class, category, and problem size. It displays • γ•, the percent deviation of LB•, • = 1, 2, 3, from the tightest lower bound LB∗ where LB∗ = max{LB1, LB2, LB3, EXACT}, and γ• = 100(LB∗ − LB•)/LB∗, with EXACT included in the computation of LB∗ only when EXACT is proven optimal; • η•, the number of times LB• = LB∗, • = 1, 2, 3; and • #, the number of times LB3 is not a valid bound; i.e., the number of times the linear programming solver CPLEX fails to prove the optimality of its incumbent within the 1 hour time limit. Table 3 reports statistics of the runtime of LB3 along with the tallied # per class, category and problem size. The statistics of the runtime are the average RT , median Q2, minimum RT and maximum RT ; all in seconds. The median (i.e., the 50th percentile) separates the ordered data into two parts with equal numbers of observations. It is a more appropriate measure of central tendency in the presence of outliers or when the distribution of the data is skewed. The Category rows of Tables 2 and 3 display the same statistics as the tables but per category per class. Their last rows report these statistics per class. Finally, their last eight columns give the statistics over all classes. A missing value indicates that all ten instances are unsolved by LB3; i.e., # = 10. The analysis of Tables 2 and 3 suggests the following. LB1 is the best lower bound in 1083 instances out of 1500 instances. Over all instances, its average deviation from LB∗ is 5.7%. Its runtime is very reduced. LB2 never outperforms LB3 nor LB1. It matches LB∗ for only 111 instances; i.e., in 7.40% of the cases. These instances have n = 20 and 40, and belong to categories 2, 4, and 6. The average percent deviation of LB2 from LB∗ is 72.5%. LB3 is a valid bound for 1244 instances. Its average runtime is 74.91 seconds. Its much smaller median (2.65 seconds) signals the existence of some outlier cases that increased the mean. This is expected since CPLEX is allocated up to one hour to prove the optimality of its incumbent. For those 1244 instances, LB3 enhances LB1 for 361 out of 1500 instances; i.e., in 24.07% cases. Its average enhancement over these 361 instances is 31.30%. In addition, it matches LB1 for another 463 instances; i.e., in 30.87% cases. Subsequently, it is the best lower bound (among LB3, LB2, LB1) in 824 cases. Figure 3 displays the box plots of the percent deviations γ• of LB•, • = 1, 2, 3, from LB∗ as a function of the class, size, category and set of the instances. A box plot reflects the central tendency, spread, and skewness of the observed values. Its box corresponds to the 25th, 50th and 75th percentiles whereas its fences extend to the lowest and largest value of the data. Its stars signal outliers or unusual observations. Figure 3 infers that LB3 is mostly superior for 20 set L; that is, for all sizes of categories 1, 3, 5, 9 and for small-sized instances (n = 20 and 40) of categories 7 and 8. Overall, the average percent deviations of LB3 from LB1 and from LB∗ are 3.58% and 14.1%. Furthermore, LB3 strictly dominates LB2 in 1074 cases. The three quartiles of the percent improvement, over all instances, are: 146.4, 218.9 and 417.1; implying a larger enhancement for the cases with strict dominance
1711.08494
3
1711
2018-06-21T16:15:21
Deterministic parallel algorithms for bilinear objective functions
[ "cs.DS" ]
Many randomized algorithms can be derandomized efficiently using either the method of conditional expectations or probability spaces with low independence. A series of papers, beginning with work by Luby (1988), showed that in many cases these techniques can be combined to give deterministic parallel (NC) algorithms for a variety of combinatorial optimization problems, with low time- and processor-complexity. We extend and generalize a technique of Luby for efficiently handling bilinear objective functions. One noteworthy application is an NC algorithm for maximal independent set. On a graph $G$ with $m$ edges and $n$ vertices, this takes $\tilde O(\log^2 n)$ time and $(m + n) n^{o(1)}$ processors, nearly matching the best randomized parallel algorithms. Other applications include reduced processor counts for algorithms of Berger (1997) for maximum acyclic subgraph and Gale-Berlekamp switching games. This bilinear factorization also gives better algorithms for problems involving discrepancy. An important application of this is to automata-fooling probability spaces, which are the basis of a notable derandomization technique of Sivakumar (2002). Our method leads to large reduction in processor complexity for a number of derandomization algorithms based on automata-fooling, including set discrepancy and the Johnson-Lindenstrauss Lemma.
cs.DS
cs
DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVE FUNCTIONS DAVID G. HARRIS1 Abstract. Many randomized algorithms can be derandomized efficiently using either the method of conditional expectations or probability spaces with low independence. A series of papers, begin- ning with work by Luby (1988), showed that in many cases these techniques can be combined to give deterministic parallel (NC) algorithms for a variety of combinatorial optimization problems, with low time- and processor-complexity. We extend and generalize a technique of Luby for efficiently handling bilinear objective functions. One noteworthy application is an NC algorithm for maximal independent set. On a graph G with m edges and n vertices, this takes O(log2 n) time and (m + n)no(1) processors, nearly matching the best randomized parallel algorithms. Other applications include reduced processor counts for algorithms of Berger (1997) for maximum acyclic subgraph and Gale-Berlekamp switching games. This bilinear factorization also gives better algorithms for problems involving discrepancy. An important application of this is to automata-fooling probability spaces, which are the basis of a notable derandomization technique of Sivakumar (2002). Our method leads to large reduction in processor complexity for a number of derandomization algorithms based on automata-fooling, including set discrepancy and the Johnson-Lindenstrauss Lemma. 1. Introduction Let us consider the following scenario, which frequently appears in applications of the prob- abilistic method of combinatorics. We have some objective function S(x) we wish to maximize over x ∈ {0, 1}n. Furthermore, we know that, if the random variable X is drawn from a w- wise-independent probability space over {0, 1}n, then E[S(X)] ≥ T . Then there certainly exists x ∈ {0, 1}n satisfying S(x) ≥ T . A key challenge for deterministic algorithms is to find such x efficiently and in parallel. As w-wise-probability spaces have size roughly nw, we could exhaustively enumerate over such a space using O(nw) processors. Alternatively, Luby [15] noted that a binary search can be used; this takes advantage of the fact that w-wise-independent probability spaces come from binary linear codes. Variants of this method are used by [6, 12] for NC derandomizations of a number of algorithms, including set discrepancy, rainbow hypergraph coloring and the Lov´asz Local Lemma. The main cost during this binary search is the evaluation of S(X), given that X is confined to some lower-dimensional subspace of {0, 1}n. This leads to high processor complexities, as typically one needs a single processor for each summand of S. When the objective function has a certain nice "bilinear" form, then Luby [15] noted that binary search can be applied without ever representing S explicitly. A simple example would be S(x) = X (γ1,e1)∈U1 (γ2,e2)∈U2 γ1γ2(−1)x•(e1⊕e2) where U1, U2 are subsets of R × 2[n], and where ⊕ represents XOR and • is the mod-2 inner product. Instead of evaluating this function by unrolling it into U1U2 separate summands, one 1Department of Computer Science, University of Maryland, College Park, MD 20742. Research supported in part by NSF Awards CNS-1010789 and CCF-1422569. Email: [email protected]. 1 2 DAVID G. HARRIS can compute the necessary conditional expectations directly in this bilinear form, leading to a significant reduction in processor count. This type of bilinear objective function is surprisingly common and the technique of [15] is quite powerful, but it seems to have fallen by the wayside in more recent derandomization research. With a few exceptions (e.g. [5, 2]), these techniques have not been applied as widely as they could be. 1.1. Overview of our approach and improvements. Our goal in this paper is to extend this technique to cover a greater range of algorithmic applications than considered by [15], including general classes of problems involving discrepancy and finite-state automata. In Section 2, we develop a general framework to handle different types of objective functions. In particular, we overcome a major technical limitation of [15] by handling non-binary random variables and non-linear objective functions in an efficient and clean way. In Section 3, we apply our framework to maximal independent set (MIS) of a graph G = (V, E). The key innovation here is our ability to handle non-binary random variables. This allows us to simulate Luby's randomized MIS algorithm [16], which uses a relatively complex probability distribution. We obtain an essentially optimal derandomization of Luby's MIS algorithm [16], with time complexity approximately O(log2 V ) and processor complexity approximately O(E + V ). In Section 4, we derandomize the Gale-Berlekamp Switching Game and the maximum acyclic subgraph problem, which are two problems from a class of algorithms based on Berger's fourth- moment method [4]. In Section 5, we consider discrepancy minimization. In this setting, there are m linear functionals in n variables, and we wish to ensure that all linear functionals are simultaneously close to their means. When the variables are independent, then very strong tail inequalities, such as Chernoff's bound, apply; when the variables are selected with w-wise-independence, then weaker bounds such as Chebyshev's inequality apply instead. We show that w-wise independence can be simulated using (mn)o(1)mn⌈w/2⌉ processors and O(log n) time; by contrast, previous work such as [17] would use roughly mnw processors. Discrepancy minimization plays a ubiquitous role in algorithm design. In Section 6, we consider one particularly powerful application to fooling finite-state automata developed by Nisan [20, 21]. Sivakumar [22] used this to derandomize algorithms based on low-memory statistical tests. The original processor complexities for these algorithms, while polynomial, were extremely high. In [18], Mahajan et al. optimized these for certain types of automata based on counters. We optimize these further, reducing the processor count significantly and covering more general classes of automata. In Section 7, we apply these results to two fundamental problems for which randomized algo- rithms can give very good results: set discrepancy, and the Johnson-Lindenstrauss Lemma. Here, the approach of [22] gives simple and clean derandomizations, albeit with very high processor counts. We obtain much lower processor counts for these problems. For example, for set discrepancy with m linear functionals on n variables, we require O(log2 n) time and m4+o(1)n3+o(1) processors. 1.2. Model of computation. This paper focuses on the deterministic PRAM model, in which there is a common memory, poly(n) processors and polylog(n) time on an input of length n. We focus on the most stringent variant, the EREW PRAM, in which no simultaneous access (either reading or writing) is allowed to a single memory cell. Other models, for instance the CRCW PRAM model, allow joint access; we can simulate a step of CRCW with a log n overhead in time and processor complexity. We say an algorithm has complexity (C1, C2) if it uses O(C1) time and O(C2) processors on a deterministic EREW PRAM. Our goal in this paper is to optimize algorithm complexity, and we often wish to focus on the first-order terms; for this reason, we say an algorithm has quasi-complexity (C1, C2) if it has complexity (C1polyloglog(n), C2no(1)); that is, we ignore polyloglog terms in the time and sub-polynomial terms in processor count. We note that many simple operations (such as adding integers) runs in polyloglog(n) time, depending on more precise details of the PRAM model DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 3 (for example, the size of the memory cells); thus, giving complexity bounds which are finer than quasi-complexity may be very difficult. 1.3. Notation. We let [t] throughout denote the set [t] = {1, . . . , t}. For a probability space Ω, we say that x ∼ Ω if x is a random variable drawn from Ω; we define the size of Ω as the cardinality of its support. For a finite set X, we write x ∼ X if x is drawn from the uniform distribution on X. For a boolean predicate P, we use the Iverson notation [P] for the indicator function which is 1 if P is true, and 0 otherwise. 2. Bilinearizable conditional expectations In this section, we develop NC algorithms for various types of objective functions. We begin with a particularly simple type of linear objective function (analyzed by [15] using different terminology). We define an ensemble E to be a pair of functions E 1,E 2 : 2[n] → R. We typically assume that these are highly sparse, and are represented by an explicit listing of their (few) non-zero entries. We define hEi to be the support of E, and we define E to be the total size needed to store E, i.e. E = Pe∈hEi e. For any e ⊆ [n] and vector x ∈ {0, 1}n, we define x • e = Pi∈e xi. For an ensemble E, we define the objective function SE : {0, 1}n → R by SE (x) = X e1,e2⊆[n] E 1(e1)E 2(e2)(−1)x•(e1⊕e2) where ⊕ is the coordinate-wise XOR (or symmetric difference) of the sets. We also define T (E) := X e⊆[n] E 1(e)E 2(e) It is straightforward to verify that E[SE (X)] = T (E) for X ∼ {0, 1}n. This is our "benchmark" result, and we will try to constructively find some x ∈ {0, 1}n with SE (x) ≥ T (E). Instead of directly searching the solution space (for example, searching a w-wise-independent probability space), we take advantage of the fact that low-independence spaces can be represented as binary codes. We use a somewhat nonstandard terminology in our discussion of such codes. A binary code is defined by associating an L-long binary vector A(i) ∈ {0, 1}L to each i ∈ [n]; we refer to L as the length of the code. For any e ⊆ [n] we define A(e) ∈ {0, 1}L as the coordinate-wise XOR given by A(e) := Li∈e A(i). Definition 2.1. Given an ensemble E and a code A over {0, 1}n, we say that A fools E if A(e1) 6= A(e2) for all distinct e1, e2 in hEi j=1 SEj (x) ≥ Pm Lemma 2.2. Let E1, . . . ,Em be ensembles on n variables and let A be a code of length L = Θ(log n) which fools E1, . . . ,Em. Then in quasi-complexity (log nPj Ej,Pj Ej) we can find x ∈ {0, 1}n satisfying Pm Proof. Consider the function G : {0, 1}L → R by E 1 j (e1)E 2 j (e2)(−1)y•A(e1⊕e2) j=1 T (Ej). G(y) = X m j=1 X e1,e2⊆[n] We will construct a vector y ∈ {0, 1}L with G(y) ≥ Pj T (Ej). We will then take our solution vector x defined by xi = A(i) • y; this will satisfy X SEj (x) = X E 1 j (e1)E 2 j j X e1⊆[n] e2⊆[n] j (e2)(−1)x•(e1⊕e2) = X X e1⊆[n] e2⊆[n] j=1 SEj (x) = G(y) ≥ Pm j E 1 j (e1)E 2 j (e2)(−1)y•A(e1⊕e2) = G(y) and so the vector x ∈ {0, 1}n has Pm j=1 T (Ej) as required. 4 DAVID G. HARRIS To construct y, we will proceed through L/t stages for parameter t = log n log log n , For each such stage ℓ = 0, . . . , L/t, we will determine a vector yℓ ∈ {0, 1}ℓt such that (1) EY ∼{0,1}L [G(Y ) (Y1, . . . , Yℓt) = yℓ] ≥ X T (Ej) j To begin, we set y0 to be the empty vector. To verify that this works, observe that E[G(Y )] = = = m X j=1 m X j=1 m X j=1 E 1 j (e1)E 2 j (e2)E[(−1)y•A(e1⊕e2)] = m X j=1 X e1,e2⊆[n] A(e1)=A(e2) E 1 j (e1)E 2 j (e2) E 1 j (e1)E 2 j (e2) since A fools Ej X e1,e2⊆[n] X e1,e2⊆[n] e1=e2 E 1 j (e)E 2 j (e) = X e⊆[n] m X j=1 T (Ej) In each stage ℓ = 0, . . . , L/t, we search over all 2t = no(1) possible extensions of yℓ to yℓ+1. We compute the conditional expected value of G(Y ), and select the choice of yℓ to maximize E[G(Y )]. This ensures that the conditional expected value increases at each stage, and so (1) holds. At the end setting y = yL/t achieves G(y) ≥ Pj T (Ej). In order to carry out this process, we must compute E[G(Y ) (Y1, . . . , Yℓt) = q] for a given vector q ∈ {0, 1}ℓt; this is the main computational cost of the algorithm. To do so, note that each summand (−1)y⊕A(e1⊕e2) has mean zero if there is a coordinate i ∈ {ℓt + 1, . . . , L} such that A(e1 ⊕ e2)(i) = 1, and otherwise (−1)y⊕A(e1⊕e2) is completely determined from the value q. Let us define π : {0, 1}L → {0, 1}L−q to be the projection onto the final L − q coordinates; thus we can write E[G(y) (Y1, . . . , Yℓt) = q] = X j X e1,e2⊆[n] π(A(e1))=π(A(e2)) E 1 j (e1)E 2 j (e2)(−1)q•(A(e1)⊕A(e2)) By sorting hEji, this quantity can be computed using quasi-complexity (log(nPj Ej),Pj Ej). Since there are L/t stages, and at each stage we must search for 2t possible values for the value yℓ+1, the overall processor count is 2t × Pj Ej and the overall runtime is L/t × log(nPj Ej). With our choice of parameter t = log n log log n and L = Θ(log n), this gives an overall quasi-complexity of (log(nPj Ej),Pj Ej). (cid:3) This is essentially optimal complexity, as it would require that much time and space to simply store the ensembles E1, . . . ,Em. 2.1. Bilinearizable objective functions. We now consider more general scenarios, in which the variables are not single bits but take values in the larger space Bb = {0, 1}b, and where the objective functions are complex functions of these variables. As a starting point, we are interested in objective functions of the form (2) S(x) = m1 m2 X k1=1 X k2=1 f1,k1(x)f2,k2(x) where each sub-function fℓ,k depends on w coordinates of x (such a function is referred to as a w-junta.) DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 5 We view the space Bb as consisting of b separate "bit-levels". There is an obvious identification between Bb and the integer set {0, 1, 2, . . . , 2b − 1}; so, we can identify the bit-levels from least- significant (rightmost) bits to most-significant (leftmost) bits. For any v ∈ Bb, we define hi : ji to the subvector consisting of bits i, . . . , j of v. Thus vh1 : ji represents the most-significant j bits of the integer v and vhb − j + 1 : bi are the least-significant j bits of the integer v. We also write x#y to mean the concatenation of the two bit-strings x, y. For a vector x ∈ Bn b , we define xhi : ji to be the vector (x1hi : ji, . . . , xnhi : ji). Likewise, for vectors x ∈ Bn s , y ∈ Bn t we define x#y = (x1#y1, . . . , xn#yn). The basic strategy of our conditional expectations algorithm is to fix the bit-levels of the vector x sequentially. For each bit-level in turn, we use a Fourier transform to transform (2) to a bilinear objective function. The key requirement for this is a certain type of factorization of the objective function S(x). Definition 2.3. We say that an objective function S : Bn b → R has bilinear expectations with width w on window t, if for every b′ ≤ b there is an (explicitly given) family of functions F such that for all f 0 ∈ Bn b′, f 1 ∈ Bn t we have EX∼Bn b hS(X) Xh1 : b′ + ti = f 0#f 1i = m mj,1 mj,2 X j=1 X k1=1 X k2=1 Fj,1,k1(f 0, f 1)Fj,2,k2(f 0, f 1) and each function Fj,ℓ,k depends on only w coordinates of f 1. (It may depend arbitrarily on f 0). j=1(mj1 + mj2). We define the weight of this factorization as W = Pm Frequently, when we use write a function F in this form, we omit the dependence on f 0, which we view as fixed and arbitrary. The critical part of this definition is how F depends on f 1. Specifically, for fixed f 0, the function F must be a w-junta. Theorem 2.4. Suppose that an objective function S : Bn b → R has a bilinear-expectations fac- torization of weight W , window t = O( log n log log n ) and width w = O(1), and b = O(log n), and this factorization can be determined explicitly with complexity (C1, C2). Then there is an algorithm to find x ∈ Bn Proof. We gradually fix the bit-levels of X in chunks of t, starting with the most-significant bit- levels, for b/t separate iterations. Specifically, at each step ℓ = 1, . . . , b/t, we find a vector yℓ ∈ Bn such that [S(X)] using quasi-complexity (C1 + log(W n), C2 + W + n). b with S(x) ≥ EX∼Bn b ℓt EX∼Bn b [S(X) Xh1 : ℓti = yℓ] ≥ EX∼Bn b [S(X)] This holds vacuously for y0 being the empty vector. To go from step ℓ to ℓ + 1, we use the bilinear expectations with b′ = ℓt to write G(z) = E[S(X) Xh1 : (ℓ + 1)ti = yℓ#z] = m mj,1 mj,2 X j=1 X k1=1 X k2=1 Fj,1,k1(yℓ, z)Fj,2,k2(yℓ, z) t . Having fixed yℓ, let us define Yj,p,k to be the set of coordinates of z affecting for any z ∈ Bn the function Fj,p,k. Since each coordinate of z corresponds to t different bit-levels, we let Y ′j,p,k = Yj,p,k × [t] denote the set of entries in the bit-vector z which affect function Fj,p,k. algorithm) to each function F with the fixed value f 0 = yℓ, to write it as: We can apply a Discrete Fourier transform (computed via the Fast Walsh-Hadamard Transform Fj,p,k(yℓ, z) = X e⊆Y ′ j,p,k γj,p,k(e)(−1)z•e 6 DAVID G. HARRIS for real parameters γj,p,k. Thus, G(z) = m mj,1 mj,2 X j=1 X k1=1 X k2=1 γj,1,k1(e1)γj,2,k2(e2)(−1)z•(e1⊕e2) X e1⊆Y ′ e2⊆Y ′ j,1,k1 j,2,k2 For each j = 1, . . . , m construct the ensemble Ej defined by γj,p,k(e) E p j (e) = X k:e⊆Y ′ j,p,k Thus, the conditional expectation G(z) is precisely Pj SEj (X). We will apply Lemma 2.2 to these ensembles. To do so, we must construct a code A fooling them. All the sets e ∈ hEji can be viewed as subsets of [n] × [t] (corresponding to the n variables and t bit-levels). With this interpretation, the subsets of Y ′j,p,k can be written as ({i1} × t1) ∪ ··· ∪ ({iw} × tw), where Yj,p,k = {i1, . . . , iw}. We form the code A via a well-known construction based on van der Monde matrices. By rescaling we may assume wlg that n = 2r. For α a primitive element of the finite field GF (2r), we define A by A(i, j) = (αj, αj+i, αj+2i, . . . , αj+2wi) Such a code has length L = O(w log n). Since the rows of a van der Monde matrix are linearly independent over the base field, the vector A(({i1} × t1) ∪ ··· ∪ ({iw} × tw)) takes distinct values for every choice of i1, . . . , iw, t1, . . . , tw. So A fools all the ensembles. All the computational steps up to this point have quasi-complexity (C1 + log(W n), C2 + W + n). This code A has length L = O(log n), and so Lemma 2.2 runs in time O(log n) and using no(1) Pj(mj,12wt + mj,22wt) = no(1)W processors. It generates a fixed value z with G(z) = E[S(X) Xh1 : (ℓ + 1)ti = yℓ#z] ≥ E[S(X) Xh1 : ℓti = yℓ] and we set yℓ+1 = yℓ#z. At the end, we set x = y⌈b/t⌉ such that S(x) ≥ E[S(X)]. (cid:3) One important application of Theorem 2.4 comes from the setting of independent Bernoulli variables. Definition 2.5. For any vector of probabilities q ∈ [0, 1]n, we write X ∼ q to mean that Xi is distributed as Bernoulli-qi, and all entries of X are independent. Theorem 2.6. Suppose that there are w-juntas Fj,ℓ,k, such that for any vector of probabilities q ∈ [0, 1]n we have m mj,1 mj,2 EX∼q[S(X)] = X j=1 X k1=1 X k2=1 Fj,1,k1(q)Fj,2,k2(q) and computing all of the functions F has complexity (C1, C2). Let W = Pm Then, for any vector p ∈ [0, 1]n, whose entries are rational number with denominator 2b for b = O(log n), there is an algorithm to find x ∈ {0, 1}n with S(x) ≥ EX∼p[S(X)], with quasi- complexity (C1 + log(W n), C2 + W + n). Proof. Define new variables Y ∈ Bn coordinate of g(y) is [pi2b ≤ 1]. If Y ∼ Bn b , then g(Y ) ∼ p. So EX∼p[S(X)] = EY ∼Bn it suffices to give a bilinear expectations factorization for S(g(y)) as a function of y. b → {0, 1}n, in which the ith S(g(Y )), and b , and define a function g : Bn j=1(mj1 + mj2). b Suppose we have fixed the most-significant b′ bit-levels of Y to some value y0, and the next t bit-levels of Y are set to some varying value y1, and the low-order b − b′ − t bit-levels vary freely. DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 7 Then g(Y ) ∼ q, where the entries qi are (easily computed) functions of y0 the dependence on y1, we have: i , y1 i , pi. Focusing only on E[S(g(Y )) Y h1 : b′ + ti = y0#y1] = EX∼q(y1)[S(X)] = m mj,1 mj,2 X j=1 X k1=1 X k2=1 Fj,1,k1(q(y1))Fj,2,k2(q(y1)) Each function F depends on w coordinates of q(y1), and each coordinate of q(y1) depends on only one coordinate of y1. So each function F depends on at most w bits. This factorization satisfies Theorem 2.4. Hence with quasi-complexity (log W n, W + n) we find y such that S(g(y)) ≥ T ; the solution vector is x = g(y). (cid:3) 3. Maximal independent set Let G = (V, E) be a graph with V = n and E = m. Finding a maximal independent set (MIS) of G is a fundamental algorithmic building block. The best randomized parallel algorithms are due to Luby in [16], which uses O(m + n) processors and O(log2 n) time for the EREW PRAM (or O(log n) time for the CRCW PRAM). The deterministic algorithms have complexity slightly higher than their randomized counterparts. The algorithm of [11] appears to have the lowest processor complexity but requires O(log2.5 n) time on an EREW PRAM, or O(log1.5 n) time on a CRCW PRAM. Other algorithms such as [16] run in O(log2 n) time but require super-linear processor counts. We will obtain a new algorithm with good processor and time complexity, by showing how an MIS computation can be reduced to maximizing a bilinearizable objective function. Our algorithm is based on Luby's randomized algorithm [16]. At its heart is a procedure FIND-IS to generate an independent set, which we summarize here. Algorithm 1 FIND-IS(G) 1: Mark each vertex independently with probability pv = c dv d(v) denotes the degree of v in the current graph G. for a small constant c, and where 2: If any edge (u, v) has both endpoints marked, unmark the endpoint with lower degree. (If both endpoints have the same degree, unmark the one with lower index). 3: Return the set I of vertices which remain marked. We can find a full MIS by repeatedly calling FIND-IS and forming the residual graph. For a graph G and an independent set I in G, we define H(I) to be the number of edges within distance two of I; these are deleted in the residual graph. Given any input graph G with m edges, FIND-IS(G) produces a random independent set I such that E[H(I)] ≥ Ω(m). We will turn this into an NC algorithm by derandomizing the FIND-IS procedure. Specifically, in quasi-complexity (log n, m + n), we will find an independent set I with H(I) ≥ Ω(m). To simplify the notation, let us suppose that the vertices have been sorted by degree (breaking ties arbitrarily), so that d(u) ≤ d(v) for vertices u < v. We let X(v) be the indicator variable that vertex v is marked in line (1). (It may become unmarked at line (2)). As shown by [16], if the vector X is drawn according to an appropriate 2-wise-independent distribution, then E[H(I)] ≥ Ω(m). We will explicitly construct a pessimistic estimator of E[H(I)] in this case, and we will then show this estimator has a good bilinear factorization. The main idea is to use inclusion-exclusion to estimate the probability that a neighbor of a vertex v is selected for the independent set I. We will be careful to ensure that our pessimistic estimator has a simple symmetric form, which is not the case for the estimator used in [16]. As is usual in inclusion-exclusion arguments, if the expected number of successes becomes too large, then the success probabilities must be attenuated. Accordingly, for each vertex v we define 8 DAVID G. HARRIS G(v) = Pw∈N (v) 1/d(w) and we define the attenuation factor by av = min(1, 1/G(v)) We now define the random variable S(v, X), which is a pessimistic estimator for the event that v is adjacent to some vertex w selected for the independent set: S(v, X) = av X w∈N (v) X(w) − a2 v X w,w′∈N (v) w<w′ X(w)X(w′) − av X w∈N (v) (w,u)∈E w<u X(w)X(u) and an overall objective function S(X) = Pv d(v)S(v, X). Proposition 3.1. For any marking vector X, the independent set IX returned by FIND-IS satisfies H(IX ) ≥ S(X)/2. Proof. We omit the subscript X for simplicity. If a neighbor of v is placed into I, then all of the edges incident to v will be counted in H(I). Each edge can only be counted twice, according to its two endpoints, so H(I) ≥ 1/2 × X v d(v)h _ w∈N (v) w ∈ Ii Next, we apply an attenuated inclusion-exclusion (as av ≤ 1): v X w<w′∈N (v) v X w<w′∈N (v) w ∈ Ii ≥ av X w∈N (v) ≥ av X w∈N (v) h _ w∈N (v) [w ∈ I] − a2 [w ∈ I] − a2 [w ∈ I][w′ ∈ I] XwXw′ A vertex w is placed into I iff it is marked and there is no neighbor u of w such that u > w and u is also marked. So [w ∈ I] ≥ Xw − X XwXu (w,u)∈E,w<u and so [Ww∈N (v) w ∈ I] ≥ S(v, X) and the proposition follows. Proposition 3.2. If X ∼ p for the vector pv = c small constant. d(v) , then E[S(X)] ≥ Ω(m) for c a sufficiently (cid:3) Proof. We omit this proof, since it is very similar to an argument of [16]. Theorem 3.3. There is an algorithm to determine a marking vector X such that S(X) ≥ Ω(m), using quasi-complexity (log n, m + n). Proof. We will apply Theorem 2.6 to objective function S to get S(X) ≥ EX∼p[S(X)]. For any probability vector q ∈ [0, 1]n we may compute: qw − X a2 EX∼q[S(X)] = X qwqu(cid:17) (cid:3) v X w,w′∈N (v) w<w′ qwqw′ − av X w∈N (v) qw − X a2 v/2 X w,w′∈N (v) qwqw′ + a2 (w,u)∈E,w<u v/2 X w∈N (v) qwqu(cid:17) w − av X q2 w∈N (v) (w,u)∈E w<u d(v)(cid:16)av X w∈N (v) d(v)(cid:16)av X w∈N (v) v = X v = X v γvqv + X v γ′vq2 v + X (u,v)∈E γuvquqv − X v d(v)a2 v/2 X w,w′∈N (v) qwqw′ DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 9 where the values of γ are given by γv = Pw∈N (v) d(v)av, γ′v = −Pw∈N (v) d(v)a2 v/2 for v ∈ V γuv = −Pw∈N (u) d(v)av for u < v, (u, v) ∈ E Let us compute the weight W of this bilinear-expectations factorization. First, we have terms for each vertex and for each edge; they contribute O(m + n). Next, for each vertex v, we have a bilinear form where the two relevant sets w, w′ vary over the neighbors of v; this contributes 2d(v). Overall W = O(m + n + Pv d(v)) = O(m). So Theorem 2.4 allows us to determine X with S(X) ≥ Ω(m) with quasi-complexity (log n, m + n). Theorem 3.4. There is an algorithm to compute the MIS of graph G using quasi-complexity (log2(mn), m + n). (cid:3) Proof. First, using a simple pre-processing step with complexity (log mn, m + n), we may remove any duplicate edges. Thus we assume m ≤ n2. Next repeatedly apply Theorem 3.3 to find a marking vector X with S(X) ≥ Ω(m). The resulting independent set I satisfies H(I) ≥ Ω(m). After O(log m) iterations of this procedure, the residual graph has no more edges, and we have found an MIS. (cid:3) Luby's randomized MIS algorithm has complexity (log2(mn), m + n) on an EREW PRAM, so this is a nearly optimal derandomization. 4. The fourth-moment method Berger [4] introduced the fourth-moment method as a general tool for showing lower bounds on E[X] for certain types of random variables, based on comparing the relative sizes of E[X 2] and E[X 4]. This can lead to NC algorithms for selecting large X which are amenable to bilinear factorization. 4.1. Gale-Berlekamp Switching Game. We begin with a very straightforward application, the Gale-Berlekamp Switching Game. In this case, we are given an n × n matrix a, whose entries are ±1. We would like to find vectors x, y ∈ {−1, +1}n, such that Pi,j ai,jxiyj ≥ Ω(n3/2). Brown [7] and Spencer [23] gave deterministic sequential polynomial-time algorithms to construct such x, y, using the method of conditional expectations, which Berger [4] transformed into an NC algorithm with complexity (log n, n4). We will reduce the processor count by a factor of n. Theorem 4.1. There is an algorithm with quasi-complexity (log n, n3) to find x, y ∈ {−1, +1}n satisfying Pi,j ai,jxiyj ≥ n3/2/√3. Proof. Following [4], we define Ri(y) = Pj aijyj and then set xi = (−1)[Ri(y)<0]. Thus X i,j ai,jxiyj = X i xiRi(y) = X i Ri(y) so we have reduced this problem to maximizing Pi Ri(y). any integer Z and any real q > 0, we have Z ≥ 3√3 We now make us of the the following fact, which is the heart of the fourth-moment method: for 2√q (Z 2 − Z 4/q). Thus, let us define the objective function (3) S(y) = X i 3√3 2√q (Ri(y)2 − Ri(y)4/q) for q = 3(1 + 3n). It suffices to construct S(y) ≥ Ω(n3/2). 10 DAVID G. HARRIS When y is drawn uniformly from {−1, +1}n, then our choice of q ensures: E[S(y)] = X i 3√3 2√q (E[Ri(y)2] − E[Ri(y)4]/q) = n2(3n + 1)−1/2 ≥ Ω(n3/2) To show that the function S(y) is bilinearizable, we factor it a : S(y) = X i 3√3 2√q(cid:16)X j1,j2 ai,j1ai,j2yj1yj2(1 − q−1 X j3,j4 ai,j3ai,j4yj3yj4)(cid:17) This has the form required by Definition 2.3. In particular, for each value i = 1, . . . , n we get functions F 1 where k1 enumerates over pairs j1, j2 and k2 enumerates over pairs j3, j4. In this k1 case, b = t = 1 and the overall weight is W = O(n3). So Theorem 2.4 runs in quasi-complexity (log n, n3). (cid:3) , F 2 k2 4.2. Maximum acyclic subgraph. In our next example, we will have to work much harder to transform our objective function into the desired bilinear form. Given a directed graph G = (V, A), we consider the maximum acyclic subgraph problem, which is to find a maximum-sized subset of arcs A′ ⊆ A, such that G′ = (V, A′) is acyclic. In [4], Berger gives a procedure for finding a relatively large (though not largest) acyclic set A′, satisfying (4) A′ ≥ A/2 + Ω(cid:16)X v∈V pd(v) + dout(v) − din(v)(cid:17) Here is a sketch of the algorithm. First, assign every vertex a random rank ρ(v) in the range {1, . . . , σ}, for some σ = nO(1). Then, for each vertex v, put into A′ either the set of out-edges from v to higher-ranking w, or the set of in-edges to v from higher-ranking w, whichever is larger. The resulting edge set A′ is acyclic. As shown in [4] and [8], this yields (5) A′ ≥ A/2 − X (u,v)∈A [ρ(u) = ρ(v)] + X v,S⊆N (V ),S≤4 cv,S[ρ(v) < min w∈S ρ(w)] The RHS of (5) can be viewed as an objective function S(ρ) in terms of the ranks ρ. It is a sum over all vertices v and all sets S of its neighbors (either in-neighbors or out-neighbors) of cardinality at most 4. Furthermore, if ρ is drawn from a 5-wise independent probability distribution, then the RHS has good expectation: E[S(ρ)] ≥ A/2 + Ω(cid:16)X v∈V pd(v) + dout(v) − din(v)(cid:17) By using conditional expectations on this quantity, [4] achieves an NC algorithm with complexity (log3 n, n∆4). This was improved by [8] to a complexity of (log n, n∆4). The processor cost in both cases comes from evaluating all n∆4 summands of the RHS of (5), for any putative ρ. Theorem 4.2. There is an algorithm with quasi-complexity (log mn, n∆2) to find an arc set A′ ⊆ A satisfying (4). Proof. We will show how to get a bilinear factorization for S(ρ). The term P(u,v)∈A[ρ(u) = ρ(v)] is easy to write in this form, as it has only O(n∆) summands altogether and they can listed individually. The challenge is dealing with Pv,S⊆N (V ),S≤4 cv,S[ρ(v) < minw∈S ρ(w)]. Say we have fixed a vertex v; to simplify the discussion, suppose Nin(v) ∩ Nout(v) = ∅. In [4], the sum over S is decomposed into a constant number of cases, depending on how many in-neighbors and how many out-neighbors of v are selected; the coefficient cv,S depends on the DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 11 number of in-neighbors and out-neighbors in S, not their precise identities. Thus, we can write for instance (6) S(ρ) = X v c1 X w1<w2∈Nin(v) w3<w4∈Nout(v) [ρv < ρw1][ρv < ρw2][ρv < ρw3][ρv < ρw4] + . . . (Here, the summand we are displaying is representative of the remaining, elided summands.) We wish to show that this S(ρ) has bilinear expectations with window t = log n log log n . So, suppose that ρh1 : b′ + ti is fixed to some value ρ0#ρ1, and all other entries of ρ are independent Bernoulli- 1/2. The comparison ρ(v) < ρ(w) is only undetermined for ρ0(v) = ρ0(w), and so we have S(ρ) = X v c1 (7) +c2 X w1<w2∈Nin(v) w3<w4∈Nout(v) ρ0(w1)=ρ0(w2)=ρ0(w3)=ρ0(w4) X X w1∈Nin(v) w3<w4∈Nout(v) ρ0(w1)=ρ0(w3)=ρ0(w4) w2∈Nin(v) ρ0(w1)>ρ0(v) [ρ1 v < ρ1 w1][ρ1 v < ρ1 w2][ρ1 v < ρ1 w3][ρ1 v < ρ1 w4] [ρ1 v < ρ1 w2][ρ1 v < ρ1 w3][ρ1 v < ρ1 w4] + . . . (This multiplies the number of cases for the summation by a constant factor. All of the summands have a similar form, so we will write only one, representative summand, henceforth.) Next, sum over all 2t possible values for ρ1(v) to obtain: (8) S(ρ) = X v 2t−1 X z=0 c1[ρ1 v = z] X [z < ρ1 w1][z < ρ1 w2][z < ρ1 w3][z < ρ1 w4] + . . . w1<w2∈Nin(v) w3<w4∈Nout(v) ρ0(w1)=ρ0(w2)=ρ0(w3)=ρ0(w4) Noting that w1, w2, w3, w4 are distinct, we compute the conditional expectation of (8): E[S(ρ)] = X v 2t−1 X z=0 c1P (ρ1 v = z) X w1<w2∈Nin(v) w3<w4∈Nout(v) ρ0(w1)=ρ0(w2)=ρ0(w3)=ρ0(w4) P (z < ρ1 w1)P (z < ρ1 w2)P (z < ρ1 w3)P (z < ρ1 w4)+. . . Finally, remove the condition that w1 < w2, w3 < w4 via inclusion-exclusion: E[S(ρ)] = X v 2t−1 X z=0 c1 4 P (ρ1 v = z) X w1,w2∈Nin(v) w3,w4∈Nout(v) ρ0(w1)=ρ0(w2)=ρ0(w3)=ρ0(w4) −X v 2t−1 X z=0 c1 4 P (ρ1 v = z) X w12∈Nin(v) w3,w4∈Nout(v) ρ0(w12)=ρ0(w3)=ρ0(w4) P (z < ρ1 w1)P (z < ρ1 w2)P (z < ρ1 w3)P (z < ρ1 w4) P (z < ρ1 w12)2P (z < ρ1 w3)P (z < ρ1 w4) + . . . The number of types of different summands has now multiplied to a painfully large constant. However, they are all essentially equivalent to each other: they all have the form P (ρ1 v = z) X w1,w2 w3,w4 P (z < ρ1 w1)P (z < ρ1 w2)P (z < ρ1 w3)P (z < ρ1 w4) where v ranges over the vertices of G, z ranges over 0, . . . , 2t−1, and the vertices w1, w2, w3, w4 come from subsets of neighbors of v. In particular, this has the bilinear form required by Theorem 2.4. 12 DAVID G. HARRIS The weight of this bilinear factorization is given by W = O(c× n× 2t × ∆2), where c is the number of different cases in the summation (a constant), n reflects that v varies, 2t reflects that z varies, and ∆2 reflects the number of possible choices for w1, w2 or w3, w4. We apply Theorem 2.4 to the objective function S and variables ρ using quasi-complexity (log(mn), W ) = (log mn, n∆2). (cid:3) 5. Discrepancy Consider a system of n variables x1, . . . , xn ∈ Bb and m linear functionals of the form lj(x) = X lj,i(xi) i and let µj be the expectation of E[lj(X)] for X ∼ Bn is to find a value x ∈ Bn means µ1, . . . , µm. (The precise definition of closeness may depend on the application.) b . The problem of discrepancy minimization b such that all the values l1(x), . . . , lm(x) are simultaneously close to their If components of X are chosen independently, then indeed lj(X) will be concentrated tightly around µj, with exponentially small probabilities of deviation. When X is drawn from a w-wise- independent probability space, then weaker bounds are available. One particularly important type of tail bound, due to Bellare-Rompel [3], is derived by noting that lj(X) − µj > aj ⇔ (lj(X) − µj)r > ar j and furthermore, by Markov's inequality P ((lj(X) − µj)r > ar j ) ≤ E[(lj(X) − µj)r]/ar j For example, when r = 2, this is precisely Chebyshev's inequality. For larger values of w, one can obtain a concentration which is similar to the Chernoff bound; the main difference is that instead of an exponential dependence on the deviation, one has only a dependence of order ≈ a1/w. A common proof technique to satisfy multiple discrepancy constraints, is to apply a concentration inequality to upper-bound the probability of violating each constraint separately and then a union bound to sum these probabilities over all constraints. If the total probability of violating the constraints is less than one, then with positive probability, they can simultaneously be satisfied. Crucially, such concentration inequalities use symmetric polynomials applied to the lj(X) variables. Definition 5.1 (Symmetric-moment bounds). Suppose that symmetric polynomials Q1(~z) . . . , Qm(~z) in n variables of degree at most d satisfy the condition E[Qj(lj1(X(1)), . . . , ljn(X(n))] < 1 X j Then we say that the condition Pj Qj(lj1(x(1)), . . . , ljn(x(n))) < 1 defines a degree-d symmetric- moment bound for the linear function l. For example, the Bellare-Rompel type tail bounds would use Qj(z1, . . . , zn) = (Pi zi−µj )d . In order to find a vector x satisfying the discrepancy condition, it thus suffices to find x ∈ Bn (9) Qj(lj1(x(1)), . . . , ljn(x(n))) < 1 ad j b with S(x) = X j and further we know that E[S(X)] < 1 when X is chosen from the appropriate distribution. In other words, we have reduced the problem of satisfying discrepancy constraints to satisfying an appropriate symmetric-moment bound. Berger & Rompel [6] and Motwani et al. [17] discussed the use of conditional expectations to simulate the concentration bounds corresponding to w-wise-independence in this context. The processor complexity of their procedure is roughly O(mnw). We next show how to reduce the processor complexity to roughly O(mn⌈w/2⌉). DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 13 Theorem 5.2. Suppose we have symmetric-moment bounds of degree d = O(1), and where b = O(log n). Furthermore suppose that we have a "partial-expectations oracle (PEO)," namely that with complexity (C1, C2) we can compute for all j, i and s ≤ d, and any vector z ∈ {0, 1}b′ for b′ ≤ b, the quantities EX∼Bb[lj,i(X)s Xh1 : b′i = z] Then there is an algorithm with quasi-complexity (C1 + log(mn), C2 + mn⌈d/2⌉) to find a vector b satisfying the discrepancy constraints. x ∈ Bn Proof. Since the summands Qj are symmetric polynomials, then for every monomial in the sum S(x), all corresponding monomial with permuted indices must appear as well. So the sum S(x) from (9) can be written in the form (10) S(x) = m X j=1 X v γj,v X i1,...,id distinct lj,i1(xi1)sv,1 . . . lj,id(xid)sv,d Here, v ranges over the types of monomials, with associated exponents sv,1, . . . , sv,d which are non-negative integers with sv,1 + ··· + sv,d ≤ d. For constant d, we have v = O(1). Let us flatten the indexing in the sum (10); instead of double indexing by j and v, we index by a new variable k. Since v has O(1) possible values, the index k can take on at most m′ = O(m) values, and so may write our objective function more compactly as (11) S(x) = m′ X k=1 γk X i1,...,id distinct lk,i1(xi1)sk,1 . . . lk,id(xid)sk,d We will use Theorem 2.4 to find x ∈ Bn b with S(x) < 1. This requires a bilinear-expectations factorization of S. So suppose we have fixed Xh1, . . . , b′+ti, and we wish to compute the expectation of S(X) when the least-significant bits of X vary. We have (12) E[S(X)] = m′ X k=1 γj X i1,...,id distinct E[lk,i1(Xi1 )sk,1] . . . E[lk,id(Xid)sk,d] (we are omitting, for notational simplicity, the conditioning of the most-significant bits of X.) We may remove the restriction that i1, . . . , id are distinct via a series of inclusion-exclusion expansions. For example, we subtract off the contribution coming from i1 = i2, the contribution from i1 = i3 etc., and then add in the contribution from i1 = i2 = i3 etc. This transformation blows up the number of summands, again by a factor which is constant for d = O(1). This gives us an objective function in the form (13) E[S(X)] = m′′ X k=1 γ′′k X i1,...,id E[lk,i1(Xi1 )sj,1]rj,1 . . . E[lk,id(Xid)sk,d]rk,d (where the weights γ′′ and number of summands m′′ have changed again, and m′′ = O(m)). Each term in (13) involves two different exponents, one inside the expectation and one outside. The PEO allows us to compute each term E[X s i ]r. We then can put (13) into the form of Theorem 2.4 by splitting each summand into two groups, one in which i1, . . . , i⌊d/2⌋ vary and the other in which i⌊d/2⌋+1, . . . , id vary. Thus, this factorization has weight W = O(mn⌈d/2⌉). (cid:3) 14 DAVID G. HARRIS 6. Fooling automata On their own, conditional expectations or low-independence probability spaces do not lead to de- randomizations of many algorithms. For example, we have seen in Section 5 that low-independence probability spaces achieve much weaker discrepancy bounds than fully-independent spaces. Sivaku- mar [22] described an alternate derandomization method based on log-space statistical tests. To summarize, consider a collection of statistical tests which have good behavior on random inputs (e.g. these statistical tests are the discrepancy of each linear functional), and which can be com- puted in O(log n) memory. Then there is an NC algorithm to build a relatively small probability distribution which has similar behavior with respect to the these statistical tests. This probability distribution can then be searched exhaustively. The Sivakumar derandomization method is based on an algorithm of Nisan [20, 21] for construct- ing probability spaces which fool a given list of finite-state automata. Mahajan et al. [18] further optimized this for a special class of automata based on counters. Our presentation follows [18] with a number of technical modifications. Basic definitions. We consider m finite-state automata, which are driven by T random vari- ables r1, . . . , rT which we refer to as the driving bits; we will suppose that these random variables r1, . . . , rT are fair coin flips, and that T is a power of two. (This setup does not lose much gener- ality). Each automaton has a state space A, of size A = η; this includes a designated start state denoted state 0. The automata also have a "clock" counter, which simply advances by one every time-step, and is not included in the state space S. We define the transition function F as follows: suppose automaton #i, currently in step s and time t, receives bit r = rt; then it transitions to state F (i, r, s, t) and time t + 1. We assume throughout that the transition function F can be computed, say using O(1) time and processors. In order to simplify the logarithmic notations, we define n = max(T, η, m, 1/ǫ). Handling multiple automata (m > 1) is important for our applications, and it is crucial here that all automata under consideration process the driving bits in the same fixed order. We abuse notation, so that F can refer also to multi-step transitions. For any ℓ ≤ T and bitstream r of length ℓ, we define F ℓ(i, r, s, t) to be the result of transiting on automata from times t to t + ℓ. Thus, we can write the entire trajectory of the automata as F T (0, r, 0, 0). Our goal is to find a distribution D on the driving bits r1, . . . , rT to "fool" these automata. That is, the behavior of the automata when presented with r ∼ D should be close to the behavior when r ∼ {0, 1}T . For the purposes of our algorithm, we will measure error as Errt,t+h(D, D) = max i∈[m] s∈S X s′∈S Pr∼D(F h(i, r, s, t) = s′) − Pr∼ D(F h(i, r, s, t) = s′)(cid:12)(cid:12)(cid:12) (cid:12)(cid:12)(cid:12) Stepping tables. In our algorithms, we will manipulate distributions over driving bits r over intermediate time intervals t to t + h. It is useful to maintain a data structure we refer to as the stepping table St,h(r); this lists F h(i, r, s, t) for every value s ∈ A. Given St,h(r1) and St+h,h(r2), we can form St,2h(r1#r2) with quasi-complexity (log n, mη). Whenever we construct a distribution D over driving bits from time t to t + h, we will also maintain the value of St,h(r) for every r ∈ D, which we write more compactly as St,h(D). At several points in the algorithm, we will discuss, for example, how to transform one distribution D into another D′; we also assume that St,h(D) is given as input and St′,h′(D′) will be produced as output. 6.1. The REDUCE algorithm. The REDUCE subroutine is the technical core of the automata- fooling procedure. It takes two distributions D1, D2, which go from times t to t + h and t + h to t + 2h respectively, and returns a single distribution D which is close to the product distribution D1 × D2. The latter distribution would have support D1D2, which is too large; the REDUCE subroutine compresses it into a new distribution D with much smaller support. DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 15 Theorem 6.1. Let D1, D2 be distributions of size nO(1). Then there is an algorithm REDUCE(D1, D2, ǫ) to construct a distribution D of size O(mη2ǫ−2) satisfying Errt,2h(D, D1 × D2) ≤ ǫ. It has quasi- complexity (log n, m(mη4ǫ−2 + (D1 + D2)(ηh + η2))). Proof. Let E = 2mη2ǫ−2. We will form D by selecting E pairs (x, y) ∈ D1 × D2; then D is the uniform distribution on the strings {x1#y1, . . . , xE#yE}. We define variables zj = (xj, yj), where j = 1, . . . , E; this designates that the jth string in D is given by concatenating the xth j string in D1 with the yth string in D2. Each zj variable is thus a bitstring of length b = log2 D1 + log2 D2 = j O(log n). At the end of this process, the stepping tables St,h(D1) and St+h,h(D2) can be used to form St,2h(D) with quasi-complexity (log n, mEη). Let us fix an automaton i, a start time t, and a transition length h. For any pair of states (s, s′), we define Gs,s′(r) = [F 2h(i, r, s, t) = s′] and p(s, s′) = Pr1∼D1,r2∼D2(Gs,s′(r1#r2)). For a given choice of the distribution D, we also define q(s, s′, D) = Pr∼D(Gs,s′(r)). In order to ensure that D has the desired error, we claim that it suffices to show that every pair s, s′ has (14) For then, summing over s′, q(s, s′, D) − p(s, s′) ≤ ǫpp(s, s′)/√η (cid:12)(cid:12)(cid:12) Pr∼D(F h(i, r, s, t) = s′) − Pr∼D1×D2(F h(i, r, s, t) = s′)(cid:12)(cid:12)(cid:12) X Errt,2h(D, D1 × D2) = max i∈[m] s′∈S s∈S qPr∼D1×D2(F h(i, r, s, t) = s′) ≤ ǫ/√η X ≤ ǫ/√η X p1/η ≤ ǫ s′∈S s′∈S Now, suppose that we set the variables zj equal to independent unbiased random variables Zj. Then q(s, s′, D) is (up to scaling) simply the number of indices j satisfying Gs,s′(Zj). Let Es,s′ denote the bad event that q(s, s′, D) − p(s, s′) > ǫpp(s, s′)/√η. We wish to avoid the event Es,s′, for every pair of states s, s′ as well as every automaton i. The random variable q(s, s′, D) has mean p(s, s′) and variance p(s, s′)(1 − p(s, s′))/E. So by Chebyshev's inequality P (Es,s′) ≤ p(s, s′)η(1 − p(s, s′)) Eǫ2p(s, s′) η Eǫ2 ≤ By taking a union bound over s, s′, i, we see that there is a positive probability that no E is true as long as ηm × ηE−1ǫ−2 < 1, which holds by hypothesis. Thus, using degree-2 symmetric-moment bounds (Chebyshev's inequality), we have shown that D has the desired properties with positive probability. Each s, s′, i gives rise to a linear functional (14), so we have a total of η2m functionals. The variable set here is the list of bit-strings in D, comprising E total variables of length b. Thus Theorem 5.2 can be used to constructively match Chebyshev's inequality with quasi-complexity (C1 + log n, C2 + η2mE) where (C1, C2) is the cost of the appropriate PEO. The PEO. To complete this algorithm, we will build an appropriate PEO for Theorem 5.2 with quasi-complexity (log n, mη2 + (D1 + D2)mηh). Here, for any i, s, s′ and z = (x, y), the corresponding coefficient in the linear function li,s,s′(z) is the indicator [F 2h(i, x#y, s, t) = s′]. As these coefficients are always zero or one, we only need to compute expectations of the form E[li,s,s′(Zj) Zjh1 : b′i = uj]. Each variable Zj here consists of two coordinates X, Y ; here X denotes the choice of the transition in D1 and Y denotes the choice of the transition in D2. Thus, either the most-significant bit-levels of X are fixed, while its least-significant bits and all of Y are free to vary; or X is fixed and the most-significant bit-levels of Y are fixed while its least-significant bits vary. We discuss the PEO in the case of varying X; the case of varying Y is similar and omitted. 16 DAVID G. HARRIS Using St+h,h(D2), we construct an η × η transition probability matrix M from time t + h to t + 2h, recording the probability of each state transition for r2 ∼ D2. This step can be implemented with quasi-complexity (log n,D2mηh + mη2). Next, loop over r1 ∈ D1 and use the stepping table St,h(D1) to map each state s ∈ A to the intermediate state s′′ = F h(i, r1, s, t). We then use M to determine the probability that s′′ transitions to any state s′ at time t + 2h. We sum these counts over the fixed most-significant bit-levels of X. Overall this step has quasi-complexity (log n,D1(mηh + mη2)). (cid:3) 6.2. The FOOL algorithm. We build the automata-fooling distribution recursively through a subroutine FOOL(t, h, ǫ), which generates a distribution Dt,h fooling the automata to error ǫ for the transitions from time t to t + h. Algorithm 2 FOOL(t, h, ǫ) 1: If h = 1, then return the uniform distribution. 2: Otherwise, in parallel recursively execute D1 = FOOL(t, h/2, ǫ/2(1 − 1/h)), 3: Compute D = REDUCE( D1, D2, ǫ h ) 4: Return D D2 = FOOL(t + h/2, h/2, ǫ/2(1 − 1/h)) To analyze this process, we simply need to show that the accumulation of errors is controlled. We quote a useful error-accumulation lemma from [18]: Lemma 6.2 ([18]). Let D1, D′1 be distributions from times t to t+h, and let D2, D′2 be distributions from times t + h to t + h + h′. Then Errt,h+h′(D1 × D2, D′1 × D′2) ≤ Errt,h(D1, D′1) + Errt+h,h′(D2, D′2) Proposition 6.3. Let D = FOOL(t, h, ǫ) and let U be the uniform distribution over {0, 1}h. Then Err( D, U ) ≤ ǫ. Proof. We prove this by induction on h. When h = 1, this is vacuously true as D is itself the uniform distribution. For h > 1, by inductive hypothesis, D1, D2 both have error ǫ/2(1− 2/h) with respect to their uniform distributions, and D has error ǫ Errt,h( D, U ) ≤ Errt,h( D, D1 × D2) + Errt,h( D1 × D2, U ) ≤ Errt,h( D, D1 × D2) + Errt,h( D1, U ) + Errt+h,h( D2, U ) ≤ + ǫ/2(1 − 1/h) + ǫ/2(1 − 1/h) = ǫ. ǫ h h with respect to D1, D2. So: triangle inequality by Lemma 6.2 (cid:3) Theorem 6.4. The FOOL algorithm has quasi-complexity (log T log n, m2η4T 3ǫ−2). The resulting distribution D has support D = O(mη2ǫ−2). Proof. The FOOL algorithm goes through log2 T levels of recursion. At each level h of the recursion there are T /h parallel invocations of the REDUCE subroutine with error parameter ǫh = Θ(ǫh/T ), which are applied to distributions going from t to t + h. By Theorem 6.1, each distribution on interval t, t + h has size Et,h ≤ O(mη2ǫ−2 h ) = O(mη2ǫ−2T 2h−2). The final distribution has support E1,T = O(η2mǫ−2). Thus, each invocation of the REDUCE subroutine at level t, h takes two distributions of size Et,h/2 and Et+h/2,h respectively and returns a new distribution of size Et,h. It runs in time O(log n), and uses mno(1)(Et,hη2 + (Et,h/2 + Et+h/2,h/2)ηh) = O(η3m2T 2ǫ−2h−2(η + h)) processors. DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES The total processor complexity is determined by taking the maximum over all h: T /h × O(η3m2T 2ǫ−2h−2(η + h)) ≤ O(η4m2T 3ǫ−2) Processors ≤ max h 17 (cid:3) 6.3. Equivalent transitions. In [18], Mahajan et al. introduced an additional powerful opti- mization to reduce the processor complexity. For many types of automata, there are equivalent transitions over a given time period [t, t + h], as we define next. Definition 6.5. For a fixed automaton i, starting time t and transition length h, we say that (s1, s2) ∼ (s′1, s′2) if for all r ∈ {0, 1}h we have F h(i, r, s1, t) = s2 ⇔ F h(i, r, s′1, t) = s′2 Recall that Theorem 6.1 is proved by taking a union-bound over all automata i and states s, s′. The key optimization is that it is only necessary to take this union bound over the equivalence classes under ∼; this can greatly reduce the support of the distribution. The algorithms in [18] concerned only the limited class of automata based on counter accumula- tors. Our algorithm will need to deal concretely with more general types of transitions. Concretely, we assume that for any t, h we list and process canonical representatives for these equivalence classes, which we will denote Ci,t,h. Definition 6.6 (Canonical transition set). For an automaton i, start time t, and a transition period h, we define a set Ci,t,h ⊆ A × A to be a canonical transition set if for every pair (s1, s2) ∈ A × A, there is some pair (s′1, s′2) ∈ Ci,t,h (not necessarily unique) with (s1, s2) ∼ (s′1, s′2). There will also be some computational tasks we need to perform on Ci,t,h. First, we define the canonical stepping table for r to be the table Si,t,h(r) = {(s1, s2) ∈ Ci,t,h F h(i, r, s1, t) = s2} We first show two simple results on the behavior of transitions with respect to ∼. Also, instead of keeping track of Si,t,h during our algorithm, we keep track of only the smaller set Si,t,h. As in the previous algorithm, we suppose throughout that whenever we form a distribution D, we also compute Si,t,h(r) for every r ∈ D (abbreviated Si,t,h(D)). Proposition 6.7. For any strings r, r′ with Si,t,h(r) = Si,t,h(r′), and any state s1 ∈ A, we must have F h(i, r, s1, t) = F h(i, r′, s1, t). Proof. Suppose that F h(i, r, s1, t) = s2, F h(i, r′, s1, t) = s′2 for s2 6= s′2. Then (s1, s2) ∼ (v1, v2) ∈ Ci,t,h, and (s1, s′2) ∼ (v′1, v′2) ∈ Ci,t,h. So any string w has F h(i, w, s1, t) = s2 iff F h(i, r, v1, t) = v2 and F h(i, w, s1, t) = s′2 iff F h(i, r, v′1, t) = v′2 by definition of ∼. So (v1, v2) ∈ Si,t,h(r) − Si,t,h(r′) and (v′1, v′2) ∈ Si,t,h(r′) − Si,t,h(r), a contradiction. Proposition 6.8. For any state s ∈ A, there are at most Ci,t,h states s′ of the form s′ = F h(i, r, s, t). Proof. Let s′1, s′2 be any two such states. Then (s, s′1) 6∼ (s, s′2). Hence all such states (s, s′) correspond to distinct equivalence classes under ∼. But the total number of such equivalence classes is at most Ci,t,h. (cid:3) (cid:3) We assume henceforth that we have fixed a set Ci,t,h for each i, t, h. We define a parameter Mh, which is roughly speaking an upper bound on the computational complexity of working with Ci,t,h. Definition 6.9 (Efficient canonical transition set). Let Mh be an increasing real-valued function of the parameter h. We say that a canonical transition set Ci,t,h is efficient with cost parameter Mh if Ci,t,h ≤ Mh and the following computational tasks can be accomplished in quasi-complexity (log n, Mh): 18 DAVID G. HARRIS (C1) We can enumerate Ci,t,h. (C2) Given any states s1, s2 ∈ A, we can find a pair (s′1, s′2) ∈ Ci,t,h with (s′1, s′2) ∼ (s1, s2). (C3) Given Si,t,h(r) and s ∈ A, then we can determine F h(i, r, s, t) (by Proposition 6.7, it is uniquely determined.) satisfies the definitions and gives an efficient canonical transition set with Mh = η2. If we define Ci,t,h = A × A, (i.e. the set of all transitions), then one can easily check that this As an example, consider a counter automaton, which is defined by maintaining a counter C where on input of bit xi, the counter value is changed by C ← C + f (i, xi) for some function f . This allows a much smaller canonical transition set in this setting. Proposition 6.10. For a counter automaton on state space A = [η], the set Ci,t,h = (cid:8)(0, z) z ∈ [η](cid:9) ∪ (cid:8)(z, 0) z ∈ [η](cid:9) defines an efficient canonical transition set with Mh = O(η). Proof. Property (C1) is clear. For Property (C2), note that if s2 ≥ s1 then (s1, s2) ∼ (0, s2 − s1), and if s2 ≤ s1 then (s1, s2) ∼ (s1 − s2, 0); so we can accomplish task (C2) with quasi-complexity (1, 1). For Property (C3), note that for any r, the table Si,t,h(r) consists of either a single entry (0, x), so that given any state s we can determine F h(i, r, s, t) = s + x, or a single entry (x, 0) so that given state s we have F h(i, r, s, t) = s − x; this again has quasi-complexity (1, 1). (cid:3) As the example of counter automata shows, Definition 6.9 has a lot of slack in the complexity requirements; for many types of automata, these tasks can be accomplished with significantly fewer processors than is required by this definition. The key result is that we can modify the REDUCE subroutine to take advantage of canonical transitions: 2hǫ−2 + mM 2 Theorem 6.11. Let D1, D2 be distributions on the subintervals [t, t + h] and [t + h, t + 2h] respec- tively, each of size nO(1). Then there is an algorithm REDUCE(D1, D2, ǫ) to construct a distribution D of size O(ǫ−2mMh) for the interval [t, t+2h] with Errt,2h(D, D1×D2) ≤ ǫ. It has quasi-complexity (log n, m2M 3 Proof. Let us define M = M2h and E = 2ǫ−2mM . We follow the proof of Theorem 6.1, with a few key modifications. First, instead of taking a Chebyshev bound for each transition i, s, s′, we only need to take a separate bound for each equivalency class. This accounts for the formula for E. Similarly, when we apply Theorem 5.2, the processor cost is C2 + EmM where C2 is the processor complexity of the PEO. 2h(D1 + D2)). Let us discuss how to implement the PEO as used by Theorem 6.1. To simplify the discussion, let us fix an automaton i and discuss only the case when the low bits of X vary. For any state s2 ∈ A, let us define the set Q(s2) ⊆ A to be the set of all states s3 of the form s3 = F h(i, r, s2, t + h), for r2 ∈ D2. By Proposition 6.8, we have Q(s2) ≤ Ci,t,h ≤ M ; for any fixed s2, Property (C3) allows us to generate the set Q(s2) with quasi-complexity (log n,D2M ). Our first step is to build a table S′i,t,h that associates to each (s1, s2) ∈ Ci,t,h and each state s3 ∈ Q(s2) a corresponding (s′1, s′3) ∈ Ci,t,h with (s′1, s′3) ∼ (s1, s3) and a corresponding (s′′2, s′′3) with (s′′2, s′′3) ∼ (s2, s3). To generate this table, we loop over (s1, s2) ∈ Ci,t,h and form the set Q(s2). For each s3 ∈ Q(s2), we use Property (C2) to determine (s1, s3) ∼ (s′1, s′3) ∈ Ci,t,h and also determine (s2, s3) ∼ (s′′2, s′′3) ∈ Ci,t+h,h. Over all values (s1, s2), building S′ has quasi-complexity (log n, m(D2M 2 + M 3)). Having built this table, our PEO is implemented as follows: (1) Using quasi-complexity (log n,D2M ), enumerate over (s2, s3) ∈ Ci+t+h,h, r2 ∈ D2 to com- pute the table P1 defined by P 1((s2, s3)) = {r2 ∈ D2 : F h(i, r2, s2, t + h) = s3} DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 19 (2) Loop over each (s1, s2) ∈ Ci,t,h and each s3 ∈ Q(s2). Using S′i,t,h, find some (s′′2, s′′3) ∼ (s2, s3) with (s′′2, s′′3) ∈ Ci,t+h,h. Sum over (s1, s2) to accumulate the table P 2 defined by P 2((s1, s2), s3) = X (s′′ (s′′ 2 ,s′′ 2 ,s′′ 3 )∼(s2,s3) 3 )∈Ci,t+h,h P 1((s′′2, s′′3)) By Proposition 6.8, the total number of such s1, s2, s3 is at most M 2 and hence this step has complexity (log n, M 2). (3) Loop over r1 ∈ D1 and pairs (s1, s2) ∈ Si,t,h(r1) and s3 ∈ Q(s2), and use the table S′i,t,h to find (s′1, s′3) ∈ Ci,t,h with (s′1, s′3) ∼ (s1, s3). Sum these counts over s3, (s1, s2) to obtain the table P 3 defined by P 3(r1, (s′1, s′3)) = X s3 X (s1,s2)∈ Si,t,h(r1) (s′ 3)∼(s1,s3) 1,s′ P 2((s1, s2), s3) By Proposition 6.8, there are at most M 2 tuples s1, s2, s3 for each r1 ∈ D1. The total quasi-complexity for this step is (log n,D1M 2). (4) Finally, sum the table P 3 over the varying bottom bits of X. After applying Theorem 5.2, we have generated the distribution D. To finish, we need to compute Si,t,2h(D). Consider some r ∈ D of the form r = r1#r2 for r1 ∈ D1, r2 ∈ D2. For each (s1, s2) ∈ Si,t,h(r1) we use Property (C3) to determine s3 = F h(i, r2, s2, t+h). We then use S′i,t,h to determine (s′1, s′3) ∈ Ci,t,h with (s′1, s′3) ∼ (s1, s3). Finally, store the pair (s′1, s′3) into Si,t,h. Overall, this step has quasi-complexity (log n, EM 2). (cid:3) This leads to the following bounds for FOOL: Theorem 6.12. Suppose we have efficient canonical transition sets with a cost parameter Mh. Then the FOOL algorithm has quasi-complexity (log T log n, ǫ−2T 3m2 maxh(Mh/h)3). The resulting probability distribution D has support D = O(mMT ǫ−2). Proof. (This is similar to Theorem 6.4, so we only provide a sketch). At each level h of the recursion, we invoke T /h parallel instances of REDUCE with error ǫh = Θ(ǫh/T ). Each invocation of REDUCE gives a distribution on the interval t, h of size Et,h = O(ǫ−2 h mMh) = O(mMhǫ−2T 2/h2). So the final distribution has support E1,T = O(mMT ǫ−2). 2h(mMhǫ−2T 2/h2)). The processor complexity can be simplified as m2M 3 By Theorem 6.11, each invocation of REDUCE at stage t, h has quasi-complexity (log n, m2M 3 2hǫ−2 2hǫ−2T 2/h2. As there mM 2 are T /h parallel applications of REDUCE at level h, the overall processor count at level h is at most ǫ−2T 3m2h−3M 3 h . (cid:3) h + 7. Applications of fooling automata 7.1. Set discrepancy. To illustrate how to use automata-fooling as a building-block for NC al- gorithms, consider the problem of set discrepancy. A simple example, we show how to to match Chernoff bound discrepancy for linear functionals with integer-valued coefficients and variables. Proposition 7.1. Given m linear functionals in n variables with coefficients {−1, 0, 1}, there is an algorithm to find X1, . . . , Xn ∈ {−1, 1}n such that using quasi-complexity (log2 mn, m4n3). lj(X) ≤ O(pn log m) for all j = 1, . . . , m 20 DAVID G. HARRIS Proof. For each j, we represent the "statistical test" lj(X) ≤ O(√n log m) by an automaton which receives the input values X1, . . . , Xn in order and maintains a running counter Pt k=1 ljkXk. When Xi are independent then with high probability each of the automata terminates in a state with counter bounded by O(√n log m). These automata run for T = n timesteps. Now consider a distribution D which fools these automata to error ǫ = 1/(2m); i.e. its transition probabilities are close to what one would obtain from the independent distribution. Then with positive probability, these automata run on D will have discrepancy O(√n log m). In particular, we can spend Dmn processors to test all possible elements of the distribution and produce a desired vector ~X. Let us first give a simple estimate using Theorem 6.4, and then show how to optimize this by more careful counting of states and equivalence classes of states. First, as the state space has size η = O(n) (to count the running sum), Theorem 6.4 gives a distribution to fool the automata in quasi-complexity (log2 n, η4m2T 3ǫ−2) = (log2 n, m4n7). The resulting distribution has support m3n2, thus the final testing step requires just m4n3 processors, which is negligible. Indeed, this final testing step is almost always negligible for automata-fooling. To improve this, note that in a window of size h, the only thing that matters is the total change in the value of the running sum. The starting state does not matter, and the running sum can only change by up to h; thus we can take a set of equivalent transitions of cost Mh = h. So by Theorem 6.12 the total processor complexity is at most (mn)o(1)ǫ−2T 3m2ǫ−2 maxh(Mh/h)3 ≤ m4+o(1)n3+o(1). (cid:3) By contrast, [18] required roughly m10n7 processors for this task. 7.2. The Gale-Berlekamp Game. The method of fooling automata can give better constants for the Gale-Berlekamp Game compared to the Fourth-Moment Method, at the cost of greater time and processor complexity. Theorem 7.2. There is an algorithm with quasi-complexity (log2 n, n5) to find x, y ∈ {−1, +1}n satisfying Pi,j ai,jxiyj ≥ (p2/π − o(1))n3/2. Proof. As in Theorem 4.1, we set Ri(y) = Pj aijyj and xi = (−1)[Ri(y)<0], so that we wish to maximize Pi Ri(y). As shown in [7, 23], for y ∼ {0, 1}n we have E[Ri(y)] ≥ p2n/π. Each term Ri(y) can be computed from the bits y by an automaton which counts the running sum. This automaton can be implemented using Mh = O(h). Thus, we can build a distribution D which fools these n automata to error ǫ = o(1); for y ∼ D we have E[Ri(y)] ≥ p2n/π − o(1). By Theorem 6.12, the distribution D can be generated using quasi-complexity (log2 n, ǫ−2T 3m2); the processor count can be simplified as n5+o(1). (cid:3) 7.3. Johnson-Lindenstrauss Lemma. In another application of [22], consider the well-known dimension-reduction procedure based on the Johnson-Lindenstrauss Lemma [13]. (We present it in a slightly modified form, based on approximating norms instead of distances.) We are given a collection of n unit vectors U ⊆ Rd, and we wish to find a linear projection φ : Rd → Rk for k = O(δ−2 log n) such that every u ∈ U satisfies (15) where here · denotes the euclidean ℓ2 norm. The original construction was randomized. In [10], a sequential derandomization was given using the method of conditional expectations. There has since been significant research in developing sequential deterministic algorithms for a variety of settings, see e.g. [9, 14]. (1 − δ) ≤ φ(u) ≤ (1 + δ) Achlioptas [1] gives a simple randomized algorithm where φ is a random k × d matrix L, whose entries are +1 or −1 with equal probability. As shown in [1], this satisfies the condition (15) DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 21 with high probability. Interpreting this as a type of finite automaton, Sivakumar [22] gives an NC derandomization. We make a number of modifications to optimize Sivakumar's algorithm. The randomized construction of Achlioptas can be easily transformed into a log-space statistical test. Here, the driving bits are the entries of the matrix L. For each u ∈ U , we need to compute φ(u). To do so, for each i = 1, . . . , k we compute the sum si = Pj Lijuj. We also compute the running sum of sums r = Pi s2 i . If the final value r satisfies r ≤ δ2 we output SUCCESS. As shown in [1], the expected number of values u which fail this test is at most 1/2, for appropriately chosen k. Theorem 7.3. There is an algorithm to find φ satisfying condition (15) for every u ∈ U , where k = O(δ−2 log n), using quasi-complexity (log2 n, n4d5δ−12 + n4δ−16). Proof. We begin with a few simple observations. By rescaling δ, it suffices to achieve relative error O(δ). Also, we may assume d, δ are polynomially bounded in n. For, if d ≥ n, then we can perform a change of basis so that v1, . . . , vn are unit vectors, and the remaining n − d coordinates are zero. If δ ≤ n−1/2, then we can simply take k = n and φ is the identity map. For any u, the automaton we have described computes separate summations s1, . . . , sk; these all have the same distribution, and depend on independent random bits. If we apply the automaton- fooling theorem directly, we are creating separate distributions to fool each of these summations; but this is redundant, as a single distribution will fool any of them. We can instead create a single distribution to fool the automaton computing s1, and replicate it k times. Thus, for each u we define the automaton R1(u), which receives d driving values y1, . . . , yd ∈ {−1, 1}d, to compute the running sum s = Pj yjuj. We begin by applying Theorem 6.12 to fool these n automata. Next, let D1 be a distribution fooling R1. We want to create a distribution which fools the sum s1 + ··· + sk to error ǫ = 1/n. We do so recursively. First, we create an automaton R2 which takes two independent draws from D1 and computes s1 + s2. We can fool R2, giving us a distribution D2 which fools the sum s1 + s2. It also automatically fools the sums s3 + s4, s5 + s6, . . . as these have the same distribution. Proceeding in this way, we recursively set Di+1 = REDUCE(Di, Di, ǫ2i/k) to fool automaton R2i. After log2 k steps, the distribution Dfinal = Dlog2 k fools the overall sum s1 + ··· + sk to error ǫ. This recursive application of REDUCE to larger and larger transitions, is very similar to the recursion used to define FOOL itself. The one key difference here is that at each level of this recursion, we only perform a single application of REDUCE Fooling automaton R1: We want to fool R1 to error n−1k−1. In order to achieve a finite-state automaton, we the running sum s as well as the vector u to integer multiples of a parameter x. We first note that this sum s can be maintained within a narrow window. For, while it is possible that that sum s achieves (either at the end or in an internal state) a value as large as Pj vj, this is unlikely. By Bennet's inequality coupled with the fact that Pj v2 j = 1, it holds with high probability (over random inputs) that s ≤ O( log n log log n ). So, we maintain s within this window; it it leaves this window, then we can force automaton R1 to go into a FAIL state. The quantized sum s we compute could differ from the true s by a factor of dx. This can causes an error of at most sdx ≤ no(1)dx in the term s2, which could cause an error of no(1)kdx in the final sum r (which is the sum of k copies of s). As we are only trying to ensure that r ≤ O(δ2), it suffices to take x = δ2/(dk) Let us count the number of inequivalent transitions in an interval [t, t + h] for the running sum computation. The starting state is irrelevant, and within this window the sum s changes by at j=t vj ≤ √h. This corresponds to √h/x distinct states after quantization, and so most Pt+h Mh ≤ dk√hδ−2 22 DAVID G. HARRIS We now apply Theorem 6.12 to construct a distribution D fooling these n automata to error ǫ = n−1k−1. The number of driving bits is T = d so this requires quasi-complexity (log2 n, d5n4δ−12). Fooling R2i , for i ≥ 1: We do this recursively through i = 1, . . . , log2 k stages; at each step, we consider a single REDUCE step on the simple automaton R2i which takes two draws from Di−1, uses these to compute respectively the sums s1 + ··· + s2i−1 and s2i−1+1 + ··· + s2i, and adds these quantities together. The running sum r can be quantized here to multiples of k−1δ2, to ensure a final truncation error of size at most O(δ2). As we have restricted the automaton R1 to maintain the running sum within an no(1) window, this implies that automaton R2i−1 only needs to keep track of 2iδ−2kno(1) states. Thus by Theorem 6.11, the distribution Di can be taken to have support Di = no(1)2in2δ−8(ǫ−1k/2i)2 Similarly, when combining these two automata, the number of relevant state transitions is at most 2ikδ−2no(1). (The sum r can change by no(1)2i in this time horizon). Thus by Theorem 6.11, the work for a single REDUCE step at iteration i is O(log n) time and processors. no(1)2in2δ−8(ǫ−2k/2i)2 × 2ikδ−2no(1) = n4+o(1)δ−16 (cid:3) This version of the Johnson-Lindenstrauss Lemma can be used to solve the (more standardly stated) version based on fooling distances: Proposition 7.4. Given a set U ⊆ Rd of vectors with b bits of precision and size U = n, there is an algorithm to find a linear mapping φ : Rd → Rk for k = O(δ−2 log n) such that (1 − δ)u − u′ ≤ φ(u) − φ(u′) ≤ (1 + δ)u − u′ using quasi-complexity (log2 n + log b, n8d5δ−12 + n8δ−16 + n2b). Proof. First, form the set of unit vectors U′ = { u−u′ (log nb, n2b). Next apply Theorem 7.3 to the set U′ which has cardinality U′ ≤ n2. u−u′ u, u′ ∈ U}. This requires quasi-complexity (cid:3) Thanks to Aravind Srinivasan, for extensive comments and discussion. Thanks to anonymous journal referees for careful review and a number of helpful helpful suggestions. 8. Acknowledgments References [1] Achlioptas, D.: Database friendly random projections. Proceedings of the 20th ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems (PODS), pp. 274-281 (2001). [2] Awerbuch, B., Berger, B., Cowen, L, Peleg, D. Low-diameter graph decomposition is in NC. Random Structures & Algorithms 5-3, pp. 441-452 (1994) [3] Bellare, M., Rompel, J.: Randomness-efficient oblivious sampling. Proceedings of the 35th annual Foundations of Computer Science (FOCS), pp. 276-287 (1994) [4] Berger, B.: The fourth moment method. SIAM Journal of Computing 26, pp. 1188-1207 (1997) [5] Berger, B., Rompel, J., Shor, P.: Efficient NC algorithms for set cover with applications to learning and geometry. Journal of Computer and System Sciences 49, pp. 454-477 (1994) [6] Berger, B., Rompel, J.: Simulating (logc n)-wise independence in NC. Journal of the ACM 38-4, pp. 1026-1046. (1991) [7] Brown, T., Spencer, J.: Minimization of ±1 matrices under line shifts. Colloq. Math. (Poland) 23, pp. 165-171 (1971) [8] Chari, S., Rohatgi, P, Srinivasan, A.: Improved algorithms via approximations of probability distributions. Journal of Computer and System Sciences 61-1, pp. 81-107 (2000) [9] Dadush, D., Guzm´an, C., Olver, N.: Fast, deterministic and sparse dimensionality reduction. Proceedings of the 29th annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 1330-1344. (2018) DETERMINISTIC PARALLEL ALGORITHMS FOR BILINEAR OBJECTIVES 23 [10] Engebretsen, L., Indyk, P., O'Donnell, R.: Derandomized dimensionality reduction with applications. Proceed- ings of the 13th annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 705-712 (2002) [11] Han, Y.: A fast derandomization scheme and its applications. SIAM Journal on Computing 25-1, pp. 52-82 (1996) [12] Harris, D.: Deterministic parallel algorithms for fooling polylogarithmic juntas and the Lov´asz Local Lemma. Proceedings of the 28th annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 1188-1203 (2017) [13] Johnson, W. B., Lindenstrauss, J.: Extensions of Lipschitz mappings into a Hilbert space. Conference in Modern Analysis and Probability, pp. 189-206 (1984) [14] Kane, D., Nelson, J.: A derandomized sparse Johnson-Lindenstrauss transform. arXiv preprint arXiv:1006.3585. (2010) [15] Luby, M.: Removing randomness in parallel computation without a processor penalty. Journal of Computer and System Sciences 47-2, pp. 250-286 (1993) [16] Luby, M.: A simple parallel algorithm for the maximal independent set problem. SIAM Journal on Computing 15-4, pp. 1036-1053 (1996) [17] Rajeev, M., Naor, J., Naor, M.: The probabilistic method yields deterministic parallel algorithms. Journal of Computer and System Sciences 49-3, pp. 478-516 (1994) [18] Mahajan, S., Ramos, E., Subrahmanyan, K.: Solving some discrepancy problems in NC. Foundations of Software Technology and Theoretical Computer Science, pp. 22-36 (1997) [19] Naor, J., Naor, M.: Small-bias probability spaces: efficient construction and applications. SIAM Journal of Computing 22-4, pp. 835-856 (1993) [20] Nisan, N. Pseudorandom generator for space-bounded computation. Combinatorica 12-4, pp. 449-461 (1992) [21] Nisan, N. RL ⊆ SC. Computational Complexity 4-1, pp. 1-11 (1994) [22] Sivakumar, D.: Algorithmic derandomization via complexity theory. Proceedings of the 34th annual ACM Sym- posium on Theory of Computing (STOC), pp. 619-626 (2002) [23] Spencer, J.: Ten lectures on the probabilistic method. SIAM (1987)
1908.02741
4
1908
2019-10-10T17:58:10
Parallel Finger Search Structures
[ "cs.DS", "cs.DC" ]
In this paper we present two versions of a parallel finger structure FS on p processors that supports searches, insertions and deletions, and has a finger at each end. This is to our knowledge the first implementation of a parallel search structure that is work-optimal with respect to the finger bound and yet has very good parallelism (within a factor of O( (log p)^2 ) of optimal). We utilize an extended implicit batching framework that transparently facilitates the use of FS by any parallel program P that is modelled by a dynamically generated DAG D where each node is either a unit-time instruction or a call to FS. The total work done by either version of FS is bounded by the finger bound F[L] (for some linearization L of D ), i.e. each operation on an item with finger distance r takes O( log r + 1 ) amortized work; it is cheaper for items closer to a finger. Running P using the simpler version takes O( ( T[1] + F[L] ) / p + T[inf] + d * ( (log p)^2 + log n ) ) time on a greedy scheduler, where T[1],T[inf] are the size and span of D respectively, and n is the maximum number of items in FS, and d is the maximum number of calls to FS along any path in D. Using the faster version, this is reduced to O( ( T[1] + F[L] ) / p + T[inf] + d * (log p)^2 + s[L] ) time, where s[L] is the weighted span of D where each call to FS is weighted by its cost according to F[L]. We also sketch how to extend FS to support a fixed number of movable fingers. The data structures in our paper fit into the dynamic multithreading paradigm, and their performance bounds are directly composable with other data structures given in the same paradigm. Also, the results can be translated to practical implementations using work-stealing schedulers.
cs.DS
cs
Parallel Finger Search Structures Seth Gilbert Wei Quan Lim National University of Singapore National University of Singapore (cid:17) p +T∞ +d·(logp)2 +sL Introduction Keywords Parallel data structures, multithreading, dictionaries, comparison-based search, distribution-sensitive algorithms Abstract In this paper 1 we present two versions of a parallel finger structure FS on p processors that supports searches, insertions and deletions, and has a finger at each end. This is to our knowledge the first implementation of a parallel search structure that is work-optimal with respect to the finger bound and yet has very good parallelism (within a factor of O(cid:0)(logp)2(cid:1) of optimal). p +T∞ +d·(cid:0)(logp)2 +logn(cid:1)(cid:17) (cid:16) T1+FL (cid:16) T1+FL We utilize an extended implicit batching framework that transparently facilitates the use of FS by any parallel program P that is modelled by a dynamically generated DAG D where each node is either a unit-time instruction or a call to FS. The total work done by either version of FS is bounded by the finger bound FL (for some linearization L of D), i.e. each operation on an item with distance r from a finger takes O(logr +1) amortized work. Running P using the simpler version takes time on a greedy scheduler, where T1,T∞ are the size and span of D respectively, and n O is the maximum number of items in FS, and d is the maximum number of calls to FS along any path in D. Using the faster version, this is reduced to O time, where sL is the weighted span of D where each call to FS is weighted by its cost according to FL. We also sketch how to extend FS to support a fixed number of movable fingers. The data structures in our paper fit into the dynamic multithreading paradigm, and their performance bounds are directly composable with other data structures given in the same paradigm. Also, the results can be translated to practical implementations using work-stealing schedulers. Acknowledgements We would like to express our gratitude to our families and friends for their wholehearted support, to the kind reviewers who provided helpful feedback, and to all others who have given us valuable comments and advice. This research was supported in part by Singapore MOE AcRF Tier 1 grant T1 251RES1719. 1 There has been much research on designing parallel programs and parallel data structures. The dynamic multithreading paradigm (see [14] chap. 27) is one common parallel programming model, in which algorithmic parallelism is expressed through parallel programming primitives such as fork/join (also spawn/sync), parallel loops and synchronized methods, but the program cannot stipulate any mapping from subcomputations to processors. This is the case with many parallel languages and libraries, such as Cilk dialects [20, 25], Intel TBB [34], Microsoft Task Parallel Library [37] and subsets of OpenMP [31]. Recently, Agrawal et al. [3] introduced the exciting modular design approach of implicit batching, in which the programmer writes a multithreaded parallel program that uses a black box data structure, treating calls to the data structure as basic operations, and also provides a data structure that supports batched operations. Given these, the runtime system automatically combines these two components together, buffering data structure operations generated by the program, and executing them in batches on the data structure. This idea was extended in [4] to data structures that do not process only one batch at a time (to improve parallelism). In this extended implicit batching framework, the runtime system not only holds the data structure operations in a parallel buffer, to form the next input batch, but also notifies the data structure on receiving the first operation in each batch. Independently, the data structure can at any point flush the parallel buffer to get the next batch. This framework nicely supports pipelined batched data structures, since the data structure can decide when it is ready to get the next input batch from the parallel buffer, which may be even before it has finished processing the previous batch. Furthermore, this framework makes it easy for us to build composable parallel algorithms and data structures with composable performance bounds. This is demonstrated by both the parallel working-set map in [4] and the parallel finger structure in this paper. 1 This is the full version of a paper published in the 33rd International Symposium on Distributed Computing (DISC 2019). It is posted here for your personal or classroom use. Not for redistribution. c(cid:13) 2019 Copyright is held by the owner/author(s). 1 Finger Structures The map (or dictionary) data structure, which supports inserts, deletes and searches/updates, collectively referred to as accesses, comes in many different kinds. A common implementation of a map is a balanced binary search tree such as an AVL tree or a red-black tree, which (in the comparison model) takes O(logn) worst-case cost per access for a tree with n items. There are also maps such as splay trees [36] that have amortized rather than worst-case performance bounds. A finger structure is a special kind of map that comes with a fixed finger at each end and a (fixed) number of movable fingers, each of which has a key (possibly −∞ or ∞ or between adjacent items in the map) that determines its position in the map, such that accessing items nearer the fingers is cheaper. For instance, the finger tree [27] was designed to have the finger property in the worst case; it takes O(logr +1) steps per operation with finger distance r (Definition 1), so its total cost satisfies the finger bound (Definition 2). Definition 1 (Finger Distance). Define the finger distance of accessing an item x on a finger structure M to be the number of items from x to the nearest finger in M (including x), and the finger distance of moving a finger to be the distance moved. Definition 2 (Finger Bound). Given any sequence L of N operations on a finger structure M, let FL denote the finger bound i=1(logri +1) where ri is the finger distance of the i-th operation in L when L is performed on M. for L, defined by FL =N Main Results We present in this paper, to the best of our knowledge, the first parallel finger structure. In particular, we design two parallel maps that are work-optimal with respect to the Finger Bound FL (i.e. it takes O(FL) work) for some linearization L of the operations (that is consistent with the results), while having very good parallelism. (We assume that each key comparison takes O(1) steps.) These parallel finger structures can be used by any parallel program P, whose actual execution is captured by a program DAG D, where each node is an instruction that finishes in O(1) time or a call to the finger structure M, called an M-call, that blocks until the result is returned, and each edge represents a dependency due to the parallel programming primitives. The first design, called FS1, is a simpler data structure that processes operations one batch at a time. Theorem 3 (FS1 Performance). If P uses FS1 (as M), then its running time on p processes using any greedy scheduler (i.e. at each step, as many tasks are executed as are available, up to p) is (cid:16) T1 +FL p O +T∞ +d·(cid:0)(logp)2 +logn(cid:1)(cid:17) for some linearization L of M-calls in D, where T1 is the number of nodes in D, and T∞ is the number of nodes on the longest path in D, and d is the maximum number of M-calls on any path in D, and n is the maximum size of M. 2 Notice that if M is an ideal concurrent finger structure (i.e. one that takes O(FL) work), then running P using M on p processors according to the linearization L takes Ω(Topt) worst-case time where Topt = T1+FL p +T∞. Thus FS1 gives an essentially optimal time bound except for the 'span term' d·(cid:0)(logp)2 +logn(cid:1), which adds O(cid:0)(logp)2 +logn(cid:1) time per FS1-call along some path in D. The second design, called FS2, uses a complex internal pipeline to reduce the 'span term'. Theorem 4 (FS2 Performance). If P uses FS2, then its running time on p processes using any greedy scheduler is (cid:16) T1 +FL p O (cid:17) +T∞ +d·(logp)2 +sL for some linearization L of M-calls in D, where d is the maximum number of FS2-calls on any path in D, and sL is the weighted span of D where each FS2-call is weighted by its cost according to FL, except that each finger-move operation is weighted by logn. Specifically, each access FS2-call that is an access with finger distance r according to L is given the weight logr +1, and each FS2-call that is a finger-move is given the weight logn, and sL is the maximum weight of any path in D. Thus, ignoring finger-move operations, FS2 gives an essentially optimal time bound up to an extra O(cid:0)(logp)2(cid:1) time per FS2-call along some path in D. We shall first focus on basic finger structures with just one fixed finger at each end, since we can implement the general finger structure with f movable fingers by essentially concatenating (f +1) basic finger structures, as we shall explain later in Section 6. We will also discuss later in Section 7 how to adapt our results for work-stealing schedulers that can actually be provided by a real runtime system. 2 To cater to instructions that may not finish in O(1) time (e.g. due to memory contention), it suffices to define T1 and T∞ to be the (weighted) work and span (Definition 5) respectively of the program DAG where each M-call is assumed to take O(1) time. 2 Si[k] has height O(cid:0)2k(cid:1), and that the r least items are in the first logO(logr) segments and the r greatest items are in the last Challenges & Key Ideas The sequential finger structure in [22] (essentially a B-tree with carefully staggered rebalancing) takes O(logr +1) worst-case time per access with finger distance r, but seems impossible to parallelize efficiently. It turns out that relaxing this bound to O(logr +1) amortized time admits a simple sequential finger structure FS0 (Section 3) that can be parallelized. In FS0, the items are stored in order in a list of segments S0[0],S0[1],··· ,S0[l] , S1[l],··· ,S1[1],S1[0], where each segment Si[k] is a balanced binary search tree with size at most 3· c(k) but at least c(k) unless k = l, where c(k) = 22k+1 . This ensures that logO(logr) segments. Thus for each operation with finger distance r, it takes O(logr +1) time to search through the segments from both ends simultaneously to find the correct segment and perform the operation in it. After that, we rebalance the segments to preserve the size invariant, in such a way that each imbalanced segment Si[k] will have new size 2·c(k). This double-exponential segment sizes and the reset-to-middle rebalancing is critical in ensuring that all the rebalancing takes O(1) amortized time per operation, even if each rebalancing cascade may take up to Θ(logn) time. The challenge is to parallelize FS0 while preserving the total work. Naturally, we want to process operations in batches, and use a batch-parallel search structure in place of each binary search tree. This may seem superficially similar to the parallel working-set map in [4], but the techniques in the earlier paper cannot be applied in the same way, for three main reasons. Firstly, searches and deletions for items not in the map must still be cheap if they have small finger distance, so we have to eliminate these operation in a separate preliminary phase by an unsorted search of the smaller segments, before sorting and executing the other operations. Secondly, insertions and deletions must be cheap if they have small finger distance (e.g. deleting an item from the first segment must have O(1) cost), so we cannot enforce a tight segment size invariant, otherwise rebalancing would be too costly. This is unlike the parallel working-set map, where we not only have a budget of O(logn) for each insertion or deletion or failed search, but also must shift accessed items sufficiently near to the front to achieve the desired span bound. The rebalancing in the parallel finger structures in this paper is hence completely different from that in the parallel working-set map. Thirdly, for the faster version FS2 where the larger segments are pipelined, in order to keep all segments sufficiently balanced, the pipelined segments must never be too underfull, so we must carefully restrict when a batch is allowed to be processed at a segment. Due to this, we cannot even guarantee that a batch of operations will proceed at a consistent pace through the pipeline, but we can use an accounting argument to bound the 'excess delay' by the number of FS2-calls divided by p. Other Related Work There are many approaches for designing efficient parallel data structures, so as to make maximal use of parallelism in a multi-processor system, whether with empirical or theoretical efficiency. For example, Ellen et al. [17] show how to design a non-blocking concurrent binary search tree, with later work analyzing the amortized complexity [16] and generalizing this technique [13]. Another notable concurrent search tree is the CBTree [2, 1], which is based on the splay tree. But despite experimental success, the theoretical access cost for these tree structures may increase with the number of concurrent operations due to contention near the root, and some of them do not even maintain balance (i.e., the height may get large). Another method is software combining [19, 23, 32], where each process inserts a request into a shared queue and at any time one process is sequentially executing the outstanding requests. This generalizes to parallel combining [6], where outstanding requests are executed in batches on a suitable batch-parallel data structure (similar to implicit batching). These methods were shown to yield empirically efficient concurrent implementations of various common abstract data structures including stacks, queues and priority queues. In the PRAM model, Paul et al. [33] devised a parallel 2-3 tree where p synchronous processors can perform a sorted batch of p operations on a parallel 2-3 tree of size n in O(logn +logp) time. Blelloch et al. [10] show how to increase parallelism of tree operations via pipelining. Other similar data structures include parallel treaps [11] and a variety of work-optimal parallel ordered sets [8] supporting unions and intersections with optimal work, but these do not have optimal span. As it turns out, we can in fact have parallel ordered sets with optimal work and span [5, 28]. Nevertheless, the programmer cannot use this kind of parallel data structure as a black box with atomic operations in a high-level parallel program, but must instead carefully coordinate access to it. This difficulty can be eliminated by designing a suitable batch-parallel data structure and using implicit batching [3] or extended implicit batching as presented in [4] and more fully in this paper. Batch-parallel implementations have been designed for various data structures including weight-balanced B-trees [18], priority queues [6], working-set maps [4] and euler-tour trees [38]. 3 2 Parallel Computation Model In this section, we describe parallel programming primitives in our model, how a parallel program generates an execution DAG, and how we measure the cost of an execution DAG. 2.1 Parallel Primitives The parallel finger structures FS1 and FS2 in this paper are described and explained as multithreaded data structures that can be used as composable building blocks in a larger parallel program. In this paper we shall focus on the abstract algorithms behind FS1 and FS2, relying merely on the following parallel programming primitives (rather than model-specific implementation details, but see Appendix Section A.6 for those): 1. Threads: A thread can at any point terminate itself (i.e. finish running). Or it can fork a new thread, obtaining a pointer to that thread, or join to another thread (i.e. wait until that thread terminates). Or it can suspend itself (i.e. temporarily stop running), after which a thread with a pointer to it can resume it (i.e. make it continue running from where it left off). Each of these takes O(1) time. 2. Non-blocking locks: Attempts to acquire a non-blocking lock are serialized but do not block. Acquiring the lock succeeds if the lock is not currently held but fails otherwise, and releasing always succeeds. If k threads concurrently access the lock, then each access finishes within O(k) time. 3. Dedicated lock: A dedicated lock is a blocking lock initialized with a constant number of keys, where concurrent threads must use different keys to acquire it, but releasing does not require a key. Each attempt to acquire the lock takes O(1) time, and the thread will acquire the lock after at most O(1) subsequent acquisitions of that lock. 4. Reactivation calls: A procedure P with no input/output can be encapsulated by a reactivation wrapper, in which it can be run only via reactivations. If there are always at most O(1) concurrent reactivations of P, then whenever a thread reactivates P, if P is not currently running then it will start running (in another thread forked in O(1) time), otherwise it will run within O(1) time after its current run finishes. We also make use of basic batch operations, namely filtering, sorted partitioning, joining and merging (see Appendix Section A.2), which have easy implementations using arrays in the binary forking model in [9]. So FS1 and FS2 (using a work-stealing scheduler) can be implemented in the Arbitrary CRCW PRAM model with fetch-and-add, achieving the claimed performance bounds. Actually, FS1 and FS2 were also designed to function correctly with the same performance bounds in a much stricter computation model called the QRMW parallel pointer machine model (see Appendix Section A.1 for details). 2.2 Execution DAG The program DAG D captures the high-level execution of P, but the actual complete execution of P (including interaction between data structure calls) is captured by the execution DAG E (which may be schedule-dependent), in which each node is a basic instruction and the directed edges represent the computation dependencies (such as constrained by forking/joining of threads and acquiring/releasing of blocking locks). At any point during the execution of P, a node in the program/execution DAG is said to be ready if its parent nodes have been executed. At any point in the execution, an active thread is simply a ready node in E, while a terminated/suspended thread is an executed node in E that has no child nodes. The execution DAG E consists of program nodes (specifically P-nodes) and ds (data-structure) nodes, which are dynamically generated as follows. At the start E has a single program node, corresponding to the start of the program P. Each node could be a normal instruction (i.e. basic arithmetic/memory operation) or a parallel primitive (see Section 2.1). Each program node could also be a data structure call. When a (ready) node is executed, it may generate child nodes or terminate. A normal instruction generates one child node and no extra edges. A join generates a child node with an extra edge to it from the terminate node of the joined thread. A resume generates an extra child node (the resumed thread) with an edge to it from the suspend node of the originally suspended thread. Accesses to locks and reactivation calls would each expand to a subDAG comprised of normal instructions and possibly fork/suspend/resume. The program nodes correspond to nodes in the program DAG D, and except for data structure calls they generate only program nodes. A call to a data structure M is called an M-call. If M is an ordinary (non-batched) data structure, then an M-call generates an M-node (and every M-node is a ds node), which thereafter generates only M-nodes except for calls to other data structures (external to M) or returning the result of some operation (generating a program node with an edge to it from the original M-call). 4 However, if M is an (implicitly) batched data structure, then all M-calls are automatically passed to the parallel buffer for M (see Appendix Section A.4). So an M-call generates a buffer node corresponding to passing the call to the parallel buffer, as if the parallel buffer for M is itself another data structure and not part of M. Buffer nodes generate only buffer nodes until it notifies M of the buffered M-calls or passes the input batch to M, which generates an M-node. In short, M-nodes exclude all nodes generated as part of the buffer subcomputations (i.e. buffering the M-calls, and notifying M, and flushing the buffer). 2.3 Data Structure Costs We shall now define work and span of any (terminating) subcomputation of a multithreaded program, i.e. any subset of the nodes in its execution DAG. This allows us to capture the intrinsic costs incurred by a data structure, separate from the costs of a parallel program using it. Definition 5 (Subcomputation Work/Span/Cost). Take any execution of a parallel program P (on p processors), and take any subset C of nodes in its execution DAG E. The work taken by C is the total weight w of C where each node is weighted by the time taken to execute it. The span taken by C is the maximum weight s of nodes in C on any (directed) path in E. The cost of C is w Definition 6 (Data Structure Work/Span/Cost). Take any parallel program P using a data structure M. The work/span/cost of M (as used by P) is the work/span/cost of the M-nodes in the execution DAG for P. Note that the cost of the entire execution DAG is in fact an upper bound on the actual time taken to run it on a greedy scheduler, which on each step assigns as many unassigned ready nodes (i.e. nodes that have been generated but have not been assigned) as possible to available processors (i.e. processors that are not executing any nodes) to be executed. Moreover, the subcomputation cost is subadditive across subcomputations. Thus our results are composable with other algorithms and data structures in this model, since we actually show the following for some linearization L (where FL,d,n,sL are as defined in Section 1 Main Results, and N is the total number of calls to the parallel finger structure). Theorem 7 (FS Work/Span Bounds). p +s. " (Theorem 12 and Theorem 14) FS1 takes O(FL) work and O(cid:0) N " (Theorem 16 and Theorem 21) FS2 takes O(FL) work and O(cid:0) N (cid:16) T1+w∗ p +T∞ +s∗ +d∗·logp Note that the bounds for the work/span of FS1 and FS2 are independent of the scheduler. In addition, using any greedy scheduler, the parallel buffer for either finger structure has cost O (Appendix Theorem 24). Therefore our main results (Theorem 3 and Theorem 4) follow from these composable bounds (Theorem 7). In general, if a program uses a fixed number of implicitly batched data structures, then running it using a greedy scheduler takes time, where w∗ is the total work of all the data structures, and s∗ is the total span of all the data O structures, and d∗ is the maximum number of data structure calls on any path in the program DAG. 3 Amortized Sequential Finger Structure In this section we explain a sequential finger structure FS0 with a fixed finger at each end, which (unlike finger structures based on balanced binary trees) is amenable to parallelization and pipelining due to its doubly-exponential segmented structure (which was partially inspired by Iacono's working-set structure [24]). (cid:17) p +d·(cid:0)(logp)2 +logn(cid:1)(cid:1) span. p +d·(logp)2 +sL(cid:1) span. (cid:16) T1+FL p +d·logp (cid:17) Front < S0[0] < S0[1] < S0[2] < ··· < Back > S1[0] > S1[1] > S1[2] > ··· > S0[l] ∧ S1[l] Figure 1: FS0 Outline; each box Si[k] represents a 2-3 tree of size Θ(22k) for k < l FS0 keeps the items in order in two halves, the front half stored in a chain of segments S0[0..l], and the back half stored in reverse order in a chain of segments S1[0..l]. Let c(k) = 22k+1 for each k ∈ Z. Each segment Si[k] has a target size t(k) = 2·c(k), and a target capacity defined to be [t(k),t(k)] if k < l but [0,t(k)] if k = l. Each segment stores its items in order in a 2-3 tree. We say that a segment Si[k] is balanced iff its size is within c(k) of its target capacity, and overfull iff it has more than c(k) items above target capacity, and underfull iff it has more than c(k) items below target capacity. At any time we associate every item x to a unique segment that it fits in; x fits in S0[k] if k is the minimum such that x ≤ max(S0[k]), and that x fits in S1[k] if k is the minimum such that x ≥ min(S1[k]), and that x fits in S0[l] if max(S0[l]) < x < min(S1[l]). We shall maintain the invariant that every segment is balanced after each operation is finished. 5 O(k +log(t(k) +c(k))) ⊆ O(cid:0)2k(cid:1) steps, and 2k = log2 c(k−1) ≤ log2 r +1 where r is the finger distance of the operation. For each operation on an item x, we find the segment Si[k] that x fits in, by checking the range of items in S0[a] and S1[a] for each a from 0 to l and stopping once k is found, and then perform the desired operation on the 2-3 tree in Si[k]. This takes After that, if Si[k] becomes imbalanced, we rebalance it by shifting (appropriate) items to or from Si[k +1] (after creating empty segment Si[k +1] if it does not exist) to make Si[k] have target size or as close as possible (via a suitable split then join of the 2-3 trees), and then Si[k +1] is removed if it is the last segment and is now empty. After the rebalancing, Si[k] will not only be balanced but also have size within its target capacity. But now Si[k +1] may become imbalanced, so the rebalancing may cascade. Finally, if one chain Si[0..l(cid:48)] is longer than the other chain Sj[0..l], it must be that l(cid:48) = l +1, so we rebalance the chains as follows: If Sj[l] is below target size, shift items from Si[l(cid:48)] to Sj[l] to fill it up to target size. If Sj[l] is (still) below target size, remove the now empty Si[l(cid:48)], otherwise add a new empty segment Sj[l +1]. Rebalancing may cascade throughout the whole chain and take Θ(logn) steps. But we shall show below that the rebalancing costs can be amortized away completely, and hence each operation with finger distance r takes O(logr +1) amortized steps, giving us the finger bound for FS0. We will later use the same technique in analyzing FS1 and FS2 as well. Lemma 8 (FS0 Rebalancing Cost). All the rebalancing takes O(1) amortized steps per operation. Proof. We shall maintain the invariant that each segment Si[k] with q items beyond (i.e. above or below) its target capacity has at least q· 2−k stored credits. Each operation is given 1 credit, and we use it to pay for any needed extra stored credits at the segment where we perform the operation. Whenever a segment Si[k] is rebalanced, it must have had q items beyond its target capacity for some q > c(k), and so had at least q· 2−k stored credits. Also, the rebalancing itself takes stored credits. Thus the stored credits at Si[k] can be used to pay for both the rebalancing and any extra stored credits needed by Si[k +1]. Whenever the chains are rebalanced, it can be paid for by the last segment rebalancing (which created or removed a (cid:5) segment), and no extra stored credits are needed. Therefore the total rebalancing cost amounts to O(1) per operation. O(log(t(k) +q) +log(t(k +1) +c(k +1) +q)) ⊆ O(logq) ⊆ O(cid:0)q·2−k(cid:1) steps, after which Si[k +1] needs at most q·2−(k+1) extra each search with the result, where n is the map size. O(logb +logn) span, tagging each operation with the result, where n is the map size. 4 Simpler Parallel Finger Structure We now present our simpler parallel finger structure FS1. The idea is to use the amortized sequential finger structure FS0 (Section 3) and execute operations in batches. We group each pair of segments S0[k] and S1[k] into one section S[k], and we say that an item x fits in the sections S[j..k] iff x fits in some segment in S[j..k]. The items in each segment are stored in a batch-parallel map (Appendix Section A.3), which supports: " Unsorted batch search: Search for an unsorted batch of b items within O(b·logn) work and O(logb·logn) span, tagging " Sorted batch access: Perform an item-sorted batch of b operations on distinct items within O(b·logn) work and " Split: Split a map of size n around a given pivot rank (into lower+upper parts) within O(logn) work/span. " Join: Join maps of total size n separated by a pivot (i.e. lower+upper parts) within O(logn) work/span. For each section S[k], we can perform a batch of b operations on it within O(b·logc(k)) work and O(logb +logc(k)) span if we have the batch sorted. Excluding sorting, the total work would satisfy the finger bound for the same reason as in FS0. However, we cannot afford to sort the input batch right at the start, because if the batch had b searches of distinct items all with finger distance O(1), then it would take Ω(b·logb) work and exceed our finger bound budget of O(b). We can solve this by splitting the sections into two slabs, where the first slab comprises the first loglog(2b) sections, and passing the batch through a preliminary phase in which we merely perform an unsorted search of the relevant items in the first slab, and eliminate operations on items that fit in the first slab but are neither found nor to be inserted. This preliminary phase takes O(logc(k)) work per operation and O(logb·logc(k)) span at each section S[k]. We then sort the uneliminated operations and execute them on the appropriate slab. For this, ordinary sorting still takes too much work as there can be many operations on the same item, but it turns out that the finger bound budget is enough to pay for entropy-sorting segments and chains is a little tricky, but if done correctly it takes O(1) amortized work per operation. Therefore we achieve (Appendix Definition 31), which takes O(cid:0)log b work-optimality while being able to process each batch within O(cid:0)(logb)2 +logn(cid:1) span. The details are below. q +1(cid:1) work for each item that occurs q times in the batch. Rebalancing the 6 4.1 Description of FS1 Parallel buffer size-b input batch −−−−−−−−−−−−−−−→ S[0] → ··· → S[m−1] (cid:124)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:123)(cid:122)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:125) First slab Sort−−−−−−→ (cid:31) S[m] → ··· → S[l] (cid:124)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:123)(cid:122)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:32)(cid:125) Final slab where m = (cid:100)loglog(2b)(cid:101) Figure 2: FS1 Outline; each batch is sorted only after being filtered through the smaller sections FS1-calls are put into the parallel buffer (Section 2) for FS1. Whenever the previous batch is done, FS1 flushes the parallel buffer to obtain the next batch B. Let b be the size of B, and we can assume b > 1. Based on b, the sections in FS1 are conceptually divided into two slabs, the first slab comprising sections S[0..m−1] and the final slab comprising sections S[m..l], where m = (cid:100)loglog(2b)(cid:101) +1 (where log is the binary logarithm). The items in each segment are stored in a batch-parallel map (Appendix Section A.3). FS1 processes the input batch B in four phases: 1. Preliminary phase: For each first slab section S[k] in order (i.e. k from 0 to m−1) do as follows: pointers into B), and tag the operations in the original batch B with the results. (a) Perform an unsorted search in each segment in S[k] for all the items relevant to the remaining batch B(cid:48) (of direct (b) Remove all operations on items that fit in S[k] from the remaining batch B(cid:48). (c) Skip the rest of the first slab if B(cid:48) becomes empty. 2. Separation phase: Partition B based on the tags into three parts and handle each part separately as follows: (a) Ineffectual operations (on items that fit in the first slab but are neither found nor to be inserted): Return the results. (b) Effectual operations (on items found in or to be inserted into the first slab): Entropy-sort (Appendix Definition 31) them in order of access type (search, update, insertion, deletion) with deletions last, followed by item, combining operations of the same access type on the same item into one group-operation that is treated as a single operation whose effect is the last operation in that group. Each group-operation is stored in a leaf-based binary tree with height O(logb) (but not necessarily balanced), and the combining is done during the entropy-sorting itself. (c) Residual operations (on items that do not fit in the first slab): Sort them while combining operations in the same manner as for effectual operations. 3 3. Execution phase: Execute the effectual operations as a batch on the first slab, and then execute the residual operations as a batch on the final slab, namely for each slab doing the following at each section S[k] in order (small to big): (a) Let G1..4 be the partition of the batch of operations into the 4 access types (deletions last), each Ga sorted by item. (b) For each segment Si[k] in S[k], and for each a from 1 to 4, cut out the operations that fit in Si[k] from Ga, and perform those operations (as a sorted batch) on Si[k], and then return their results. (c) Skip the rest of the slab if the batch becomes empty. 4. Rebalancing phase: Rebalance all the segments and chains by doing the following: (a) Segment rebalancing: For each chain Si, for each segment Si[k] in Si in order (small to big): i. If k > 0 and Si[k−1] is overfull, shift items from Si[k−1] to Si[k] to make Si[k−1] have target size. ii. If k > 0 and Si[k−1] is underfull and Si[k] either has at least c(k) be the first underfull segment in Si, and fill Si[k(cid:48) k(cid:48), shift items from Si[j +1] to Si[j] to make Si[k(cid:48) remove Si[j +1] if it is emptied. 2 items or is the last segment in Si, let Si[k(cid:48)] ..k−1] using Si[k] as follows: for each j from k−1 down to a=k(cid:48) t(a) or as close as possible, and then ..j] have total sizej iii. If Si[k] is (still) overfull and is the last segment in Si, create a new (empty) segment Si[k +1]. iv. Skip the rest of the current slab if Si[k] is (now) balanced and the execution phase had skipped S[k]. (b) Chain rebalancing: After that, if one chain Si is longer than the other chain Sj, repeat the following until the chains are the same length: i. Let the current chains be Si[0..k] and Sj[0..k(cid:48)]. Create new (empty) segments Sj[k(cid:48) +1..k], and shift all items from Si[k] to Sj[k], and then fill the underfull segments in Sj[k(cid:48) ii. If Sj[k] is (now) empty again, remove S[k]. ..k−1] using Sj[k] (as in step 4aii). 3 This does not require entropy-sorting, but combining merge-sort essentially achieves the entropy bound anyway. 7 ..k] are all underfull. 2 ≥k−1 ..k−1] would be filled using Si[k], which had at least c(k) 4.2 Analysis of FS1 First we establish that the rebalancing phase works, by proving the following two lemmas. Lemma 9 (FS1 Segment Rebalancing Invariant). During the segment rebalancing (step 4a), just after the iteration for segment Si[k], for any imbalanced segment Si[k(cid:48)] in Si[0..k], either k(cid:48) = k or Si[k(cid:48) Proof. The invariant clearly holds for Si[0]. Consider each iteration for segment Si[k] during the segment rebalancing where k > 0. If Si[k−1] was overfull, then by the invariant it was the only imbalanced segment in Si[0..k−1], and would be rebalanced in step 4ai, preserving the invariant. If Si[k−1] was underfull and Si[k] had at least c(k) 2 items or was the last segment in Si, then in step 4aii Si[k(cid:48) a=k(cid:48) t(a) items unless it was the last segment in Si, and hence after that every segment in Si[k(cid:48) ..k−1] (that is not removed) would be balanced, preserving the invariant. If step 4ai and step 4aii do not apply, then Si[k−1] is balanced or Si[k] is underfull, so the invariant is preserved. Finally, if Si[k] is balanced at the end of that iteration, and had been skipped by the execution phase, then by the invariant all segments in (cid:5) Si[0..k] are balanced, and all segments skipped by the rebalancing phase are also balanced, so the invariant is preserved. Lemma 10 (FS1 Chain Rebalancing Iterations). The chain rebalancing (step 4b) takes at most two iterations, after which both chains S0 and S1 will have equal length and all their segments will be balanced. Proof. By Lemma 9, all segments in each chain will be balanced after the segment rebalancing (step 4a). After that, if one chain Si[0..k] is longer than the other chain Sj[0..k(cid:48)], the first chain rebalancing iteration transfers all items in Si[k] to the other chain (step 4bi), leaving Si[k] empty. If Sj[k] remains non-empty, then both chains have length k and we are done. Otherwise, S[k] would be removed, and then the second chain rebalancing iteration transfers all items in Si[k−1] to the other chain, which is at ..k−2] would be filled to target size, and hence both chains would (cid:5) have length (k−1). Next we bound the work done by FS1. Definition 11 (Inward Order). Take any sequence A of map operations and let I be the set of items accessed by operations in A. Define the inward distance of an operation in A on an item x to be min(size(I≤x),size(I≥x)). We say that A is in inward order iff its operations are in order of (non-strict) increasing inward distance. Naturally, we say that A is in outward order iff its reverse is in inward order. Theorem 12 (FS1 Work). FS1 takes O(FL) work for some linearization L of FS1-calls in D. Proof. Let L∗ be a linearization of FS1-calls in D such that: " Operations on FS1 in earlier input batches are before those in later input batches. " The operations within each batch are ordered as follows: least c(k−1) ≥k−2 a=0 t(a) items, so every segment in Sj[k(cid:48) 1. Ineffectual operations are before effectual/residual operations. 2. Effectual/residual operations are in order of access type (deletions last). 3. Effectual insertions are in inward order, and effectual deletions are in outward order. 4. Operations in each group-operation are consecutive and in the same order as in that group. i=1 log b 8 a=0 c(a) +1 ≥ 1 a=0 c(a)−b ≥ 1 a=0 2a(cid:1) = O(cid:0)2k(cid:1) ⊆ O(logr +1) finger distance r according to L(cid:48) on an item x that was found to fit in section S[k] takes O(cid:0)k work, because r ≥k−1 in S[0..k−1]), and r ≥k−1 where H is the entropy of G (i.e. H =b j=1 Hj +b 3 (cid:16) 1 b Let L(cid:48) be the same as L∗ except that in point 3 effectual deletions are ordered so that those on items in earlier sections are later (instead of outward order). Now consider each input batch B of b operations on FS1. In the preliminary and execution phases, each section S[a] takes O(2a) work per operation. Thus each operation in B with 2c(k−1) if S[k] is in the first slab (since earlier effectual operations in B did not delete items 2c(m−1)). Therefore these phases take O(FL(cid:48)) work in total. Let G be the effectual operations in B as a subsequence of L∗. Entropy-sorting G takes O(H +b) work (Appendix Theorem 32), qi where qi is the number of occurrences of the i-th operation in G). Partition G into 3 parts: searches/updates G1 and insertions G2 and deletions G3. And let Hj be the entropy of Gj. Then H = ≤ b·log work. Let Cj be the cost of Gj according to FL∗. Since each operation in Gj has inward distance (with respect to Gj) at most its finger distance according to L∗, we have Hj ∈ O(Cj) (Appendix Theorem 28), and hence entropy-sorting takes O(FL∗) work in total. where bi is the number of operations in the same part of G as the i-th operation in G, andb i=1 log b bi = b·log3 by Jensen's inequality. Thus entropy-sorting G takes O b i=1 bi 2c(k−1) if S[k] is in the final slab (since b ≤ 1 (cid:16)3 (cid:17) j=1 Hj +b (cid:17) b i=1 log b bi Sorting the residual operations in the batch B (that do not fit in the first slab) takes O(logb) ⊆ O(logr) work per operation with finger distance r according to L∗, since r ≥ c(m−1) ≥ 2b. Therefore the separation phase takes O(FL∗) work in total. Finally, the rebalancing phase takes O(1) amortized work per (cid:5) operation, as we shall prove in the next lemma. Thus FS1 takes O(max(FL∗,FL(cid:48))) total work. Lemma 13 (FS1 Rebalancing Work). The rebalancing phase of FS1 takes O(1) amortized work per operation. Proof. We shall maintain the credit invariant that each segment Si[k] with q items beyond its target capacity has at least q·2−k stored credits. The execution phase clearly increases the total stored credits needed by at most 1 per operation, which we can pay for. We now show that the invariant can be preserved after the segment rebalancing and the chain rebalancing. During the segment rebalancing (step 4a), each shift is performed between some neighbouring segments Si[k] and Si[k +1], where Si[k] has t(k) +q items and Si[k +1] has t(k +1) +q(cid:48) items just before the shift, and q > c(k). The shift clearly takes O(log(t(k) +q) +log(t(k +1) +q(cid:48))) work. If q(cid:48) < 2· t(k +1) then this is obviously just O(logt(k) +logq) work. But if q(cid:48) a=0 t(a) ≤ t(k +1) items will be shifted from Si[k +1] to Si[k] in step 4aii, and hence Si[k +1] will still have at least q(cid:48) items. In that case, the second term O(log(t(k +1) +q(cid:48)))) in the work bound for this shift can be bounded by the first term of the work bound for the subsequent shift from Si[k +1] to Si[k +2], since log(t(k +1) +q(cid:48)) ∈ O(logq(cid:48)). Therefore in any case we can treat this shift as 2·t(k +1), then Si[k +1] will also be rebalanced in step 4ai of the next segment balancing iteration, since at mostk taking only O(logt(k) +logq) ⊆ O(logq) ⊆ O(cid:0)q·2−k(cid:1) work. > " Fill: step 4aii fills some underfull segments Si[k(cid:48) ..k]. After the fill, every segment in Si[k(cid:48) (cid:16)k j=k(cid:48) ui(j)(cid:17) ·2−(k+1) ≤ 1 2 ..k]. The other half of the ui(j)·2−j credits stored at Si[j] suffices to pay for ..k]. The chain rebalancing (step 4b) is performed only when segment rebalancing creates or removes a segment and makes one chain longer than the other. Consider the biggest segment Si[k] that was created or removed. If Si[k] was created, it must be was removed, it must be due to filling some segments Si[k(cid:48) ..k−1] using Si[k] in step 4aii, but Si[k−1] must have had at least c(k−1) items before the execution phase, and at least half of them were either deleted or shifted to Si[k−2], and hence either Now consider the two kinds of segment rebalancing: " Overflow: step 4ai shifts items from overfull Si[k] to Si[k +1]. Suppose that Si[k] has t(k) +u items just before the shift. After the shift, Si[k] has target size and needs no stored credits, and Si[k +1] would need at most u·2−(k+1) extra stored credits. Thus the u·2−k credits stored at Si[k] can pay for both the shift and the needed extra stored credits. ..k] using Si[k +1]. Suppose that Si[j] has t(j)−ui(j) items just before the fill, for each j ∈ [k(cid:48) ..k] has size within target capacity and needs no stored credits, and Si[k +1] needs at most half the credits stored at each segment in Si[k(cid:48) the shift from Si[j +1] to Si[j], for each j ∈ [k(cid:48) j=k(cid:48)(cid:0)ui(j)·2−j(cid:1) extra stored credits, which can be paid for by using k due to overflowing Si[k−1] to Si[k] in step 4ai, and hence the shift from Si[k−1] to Si[k] already took Θ(cid:0)2k(cid:1) work. If Si[k] the deletions can pay Θ(cid:0)2k(cid:1) credits, or the shift to Si[k−2] already took Θ(cid:0)2k(cid:1) work. Therefore in any case we can afford to ignore up to Θ(cid:0)2k(cid:1) work done by chain rebalancing. using Si(cid:48)[k]. The fill takes O(cid:0)2k(cid:1) work for the shift from Si(cid:48)[k] to Si(cid:48)[k−1], and takes O(cid:0)2j(cid:1) work for each shift from Si(cid:48)[j] to Si(cid:48)[j−1] for each j ∈ [k(cid:48) +1..k−1], since Si(cid:48)[j] has at mostj transfer takes O(cid:0)2k(cid:1) work in total, and hence we can ignore all the work done by the chain rebalancing. Theorem 14 (FS1 Span). FS1 takes O(cid:0) N p +d·(cid:0)(logp)2 +logn(cid:1)(cid:1) span, where N is the number of operations on FS1, and n is The preliminary phase takes O(cid:0)logb·2k(cid:1) span in each first slab segment S[k], adding up to O(cid:0)(logb)2(cid:1) span. The separation phase also takes O(cid:0)(logb)2(cid:1) span, by PESort Costs (Theorem 32). The execution phase takes O(cid:0)logb +2k(cid:1) span in each Now observe that the chain rebalancing performs at most two transfers (step 4bi) of items from the last segment of the longer chain Si[0..k] to the shorter chain Si(cid:48)[0..k(cid:48)], by the FS1 Chain Rebalancing Iterations (Lemma 10). Each transfer takes O(k) work to create the new segments and O(1) work to shift Si[k] over to Si(cid:48)[k], and then fills underfull segments in Si(cid:48)[k(cid:48) ..k−1] a=0 t(a) ≤ t(j +1) items just before the shift. Therefore each (cid:5) the maximum size of FS1, and d is the maximum number of FS1-calls on any path in the program DAG D. Proof. Let s(b) denote the maximum span of processing an input batch of size b (that has been flushed from the parallel buffer). Take any input batch B of size b. We shall bound the span taken by B in each phase. And now we turn to bounding the span of FS1. segment S[k], adding up to O(logb·loglogb +logn) span. Returning the results for each group-operation takes O(logb) span. 9 segments with total size q takes O(logq) span, and filling Si[k(cid:48) ..k−1] using Si[k] in step 4aii takes O(cid:0)log(cid:0)b +k (cid:16) The rebalancing phase also takes O(cid:0)logb +2k(cid:1) span for each segment S[k] processed in step 4a, because each shift between a=k(cid:48) t(a)(cid:1)(cid:1) ⊆ a=k(cid:48) t(a)(cid:17) ⊆ O(cid:0)2j(cid:1) span for each subsequent shift O(cid:0)logb +2k(cid:1) span for the first shift from Si[k] to Si[k−1] and then O logj p +(logp)2 +logn(cid:1), since (logb)2 ∈ O(cid:0) b (cid:1) if b ≥ p2. Therefore s(b) ∈ O(cid:0)(logb)2 +logn(cid:1) ⊆ O(cid:0) b O(cid:0) N p +d·(cid:0)(logp)2 +logn(cid:1)(cid:1). Each batch B of size b waits in the buffer for the preceding batch of size b(cid:48) to be processed, taking O(s(b(cid:48))) span, and then B itself is processed, taking O(s(b)) span, taking O(s(b) +s(b(cid:48))) span in total. Since over all batches each of b,b(cid:48) will sum up to at most the total number N of FS1-calls, and there are at most d FS1-calls on any path in the program DAG D, the span of FS1 is (cid:5) from Si[j +1] to Si[j]. Similarly, the chain rebalancing in step 4b takes O(logb +logn) span, because it performs at most two iterations by FS1 Chain Rebalancing Iterations (Lemma 10), each of which takes O(logb +logn) span to fill the underfull segments of the shorter chain using its last segment. p 5 Faster Parallel Finger Structure Although FS1 has optimal work and a small span, it is possible to reduce the span even further, intuitively by pipelining the batches in some fashion so that an expensive access in a batch does not hold up the next batch. As with FS1, we need to split the sections into two slabs, but this time we fix the first slab at m sections where m ∈ log Θ(logp) so that we can pipeline just the final slab. We need to allow big enough batches so that operations that are delayed because earlier batches are full can count their delay against the total work divided by p. But to keep the span of the sorting phase down to O(cid:0)(logp)2(cid:1), we need to restrict the batch size. It turns out that restricting to batches of size at most p2 works. O(cid:0)(logp)2(cid:1) span. The execution phase and rebalancing phases are still carried out as before on the first slab, taking O(cid:0)(logp)2(cid:1) We cannot pipeline the first slab (particularly the rebalancing), but the preliminary phase and separation phase would only take span, but execution and rebalancing on the final slab are pipelined, by having each final slab section S[k] process the batch passed to it and rebalance the preceding segments S0[k−1] and S1[k−1] if necessary. To guarantee that this local rebalancing is possible, we do not allow S[k] to proceed if it is imbalanced or if there are more than c(k) pending operations in the buffer to S[k +1]. In such a situation, S[k] must stop and reactivate S[k +1], which would clear its buffer and rebalance S[k] before restarting S[k]. It may be that S[k +1] also cannot proceed for the same reason and is stopped in the same manner, and so S[k] may be delayed by such a stop for a long time. But by a suitable accounting argument we can bound the total delay due to all such stops by the total work divided by p. Similarly, we do not allow the first slab to run (on a new batch) if S[m−1] is imbalanced or there are more than c(m−1) pending operations in the buffer to S[m]. Finally, we use an odd-even locking scheme to ensure that the segments in the final slab do not interfere with each other yet can proceed at a consistent pace. The details are below. 5.1 Description of FS2 FS2: Parallel buffer First slab: → S[0] → S[1] → ··· → S[m−1] → where m =(cid:6)loglog(cid:0)5p2(cid:1)(cid:7) size-p2 cut batch −−−−−−−−−−−−−−→ First slab −−−−−−−−−→ Feed buffer input batch Sort−−−−−−→ (cid:31) Final slab Final slab: S[m−1] Lock 1(cid:37) (cid:45)1 −−−−−−→ Buffer Lock 2(cid:37) (cid:45)2 −−−−−−→ Buffer S[m] S[m +1] Lock 1(cid:37) (cid:45)1 −−−−−−→ Buffer S[m +2] Lock 2(cid:37) (cid:45)2 −−−−−−→ Buffer ··· S[l] Figure 3: FS2 Sketch; the final slab is pipelined, facilitated by locks between adjacent sections We shall now give the details (see Figure 3). We will need the bunch structure (Appendix Definition 23) for aggregating batches, which is an unsorted set supporting both addition of a batch of new elements within O(1) work/span and conversion to a batch within O(b) work and O(logb) span if it has size b. FS2 has the same sections as in FS1, with the first slab comprising the first m =(cid:6)loglog(cid:0)5p2(cid:1)(cid:7) sections, and the final slab comprising the other sections. FS2 uses a feed buffer, which is a queue of bunches of operations each of size exactly p2 except the last (which can be empty). Whenever FS2 is notified of input (by the parallel buffer), it reactivates the first slab. 10 Each section S[k] in the final slab has a buffer before it (for pending operations from S[k−1]), which for each access type uses an optimal batch-parallel map (Appendix Section A.3) to store bunches of group-operations of that type, where operations on the same item are in the same bunch. When a batch of group-operations on an item is inserted into the buffer, it is simply added to the correct bunch. Whenever we count operations in the buffer, we shall count them individually even if they are on the same item. The first slab and each final slab section also has a deferred flag, which indicates whether its run is deferred until the next section has run. Between every pair of consecutive sections starting from after S[m−1] is a neighbour-lock, which is a dedicated lock (see Section 2.1) with 1 key for each arrow to it in Figure 3. Whenever the first slab is reactivated, it runs as follows: 1. If the parallel buffer and feed buffer are both empty, terminate. 2. Acquire the neighbour-lock between S[m−1] and S[m]. (Skip steps 2 to 4 and steps 8 to 10 if S[m] does not exist.) 3. If S[m−1] has any imbalanced segment or S[m] has more than c(m−1) operations in its buffer, set the first slab's deferred flag and release the neighbour-lock, and then reactivate S[m] and terminate. 4. Release the neighbour-lock. 5. Let q be the size of the last bunch F in the feed buffer. Flush the parallel buffer (if it is non-empty) and cut the input batch of size b into small batches of size p2 except possibly the first and last, where the first has size min(cid:0)b,p2−q(cid:1). Add that first small batch to F, and append the rest as bunches to the feed buffer. 6. Remove the first bunch from the feed buffer and convert it into a batch B, which we call a cut batch. 7. Process B using the same four phases as in FS1 (Section 4.1), but restricted to the first slab (i.e. execute only the effectual operations on the first slab, and do segment rebalancing only on the first slab, and do chain rebalancing only if S[m] had not existed before this processing). Furthermore, do not update S[m−1]'s segments' sizes until after this processing (so that S[m] in step 4 will not find any of S[m−1]'s segments imbalanced until the first slab rebalancing phase has finished). 8. Acquire the neighbour-lock between S[m−1] and S[m]. 9. Insert the residual group-operations (on items that do not fit in the first slab) into the buffer of S[m], and then reactivate S[m]. 10. Release the neighbour-lock. 11. Reactivate itself. Whenever a final slab section S[k] is reactivated, it runs as follows: 1. Acquire the neighbour-locks (between S[k] and its neighbours) in the order given by the arrow number in Figure 3. 2. If S[k] has any imbalanced segment or S[k +1] (exists and) has more than c(k) operations in its buffer, set S[k]'s deferred flag and release the neighbour-locks, and then reactivate S[k +1] and terminate. 3. For each access type, flush and process the (sorted) batch G of bunches of group-operations of that type in its buffer as follows: (a) Convert each bunch in G to a batch of group-operations. (b) For each segment Si[k] in S[k], cut out the group-operations on items that fit in Si[k] from G, and perform them (as a sorted batch) on Si[k], and then fork to return the results of the operations (according to the order within each group-operation). (c) If G is non-empty (i.e. has leftover group-operations), insert G into the buffer of S[k +1] and then reactivate S[k +1]. 4. Rebalance locally as follows (essentially like in FS1): (a) For each segment Si[k] in S[k]: Si[k] if it is emptied. i. If Si[k−1] is overfull, shift items from Si[k−1] to Si[k] to make Si[k−1] have target size. ii. If Si[k−1] is underfull, shift items from Si[k] to Si[k−1] to make Si[k−1] have target size, and then remove iii. If Si[k] is (still) overfull and is the last segment in Si, create a new segment Si[k +1] and reactivate it. i. Create a new segment Sj[k] and shift all items from Si[k] to Sj[k]. ii. If Sj[k−1] is (now) underfull, shift items from Sj[k] to Sj[k−1] to make Sj[k−1] have target size. iii. If Sj[k] is (now) empty again, remove S[k]. (b) If S[k] is (still) the last section, but chain Si is longer than chain Sj: 5. If k = m, and the first slab is deferred, clear its deferred flag then reactivate it. 6. If k > m, and S[k−1] is deferred, clear its defered flag then reactivate it. 7. Release the neighbour-locks. 11 5.2 Analysis of FS2 For each computation, we shall define its delay to intuitively capture the minimum time it needs, including all potential waiting on locks. Each blocked acquire of a dedicated lock corresponds to an acquire-stall node α in the execution DAG whose child node ρ is created by the release just before the successful acquisition of the lock. Let ∆(α) be the ancestor nodes of ρ that have not yet executed at the point when α is executed. Then the delay of a computation Γ is recursively defined as the weighted span of Γ, where each acquire-stall node α in Γ is weighted by the delay of ∆(α) (to capture the total waiting at α), and every other node is weighted by its cost. 4 Whenever the first slab or a final slab section runs, we say that it defers if it terminates with its deferred flag set (i.e. at step 2), otherwise we say that it proceeds (i.e. to step 3) and eventually finishes (i.e. reaches the last step) with its deferred flag cleared. We now establish some invariants, which guarantee that FS2 is always sufficiently balanced. Lemma 15 (FS2 Balance Invariants). FS2 satisfies the following invariants: 1. When the first slab is not running, every segment in Si[0..m−2] is balanced and Si[m−1] has at most 2·t(m−1) items. 2. When a final slab section S[k] rebalances a segment in S[k−1] (in step 4a), it will make that segment have size t(k−1). 3. Just after the last section finishes without creating new sections, the segments in S[k] are balanced and both chains have 4. Each final slab section S[k] always has at most 2·c(k−1) operations in its buffer. 5. Each final slab segment Si[k] always has at most 2·t(k) items, and at least c(k−1) items unless S[k] is the last section. Proof. Invariant 1 holds as follows: The first slab proceeds only if S[m−1]'s segments are balanced, and from that point until after the rebalancing phase, its segments are modified only by itself (since S[m] will not modify S[m−1]), and thereafter all its sections except S[m−1] remain unmodified until it processes the next cut batch. Thus the same proof as for FS1 Segment Rebalancing Invariant (Lemma 9) shows that just before the segment rebalancing (step 4a) iteration for Si[m−1], for any imbalanced first slab segment Si[k], either k = m−2 or Si[k..m−2] are underfull. But note that the cut batch had at most p2 ≤ c(m−1) items unless it was the last segment in its chain. Thus Si[0..m−2] will be made balanced (by step 4ai or step 4aii in the iteration for Si[m−1], or by step 4b). Similarly, operations, and so after the execution phase, Si[m−1] had at least c(m−1) 2 the same length. 2 S[m−1] will have at most t(m−1) +m−1 a=0 c(a) +p2 ≤ 2·t(m−1) items in each segment, sincem−2 Invariant 2 holds as follows. Each final slab section S[k] proceeds only if its segments each has at least c(k) items unless it is the last segment in its chain, and its buffer had at most 2·c(k−1) operations by Invariant 4. Since c(k)−2·c(k−1) ≥ t(k−1), rebalancing a segment in S[k−1] (step 4a) will make it have size t(k−1). Invariant 3 holds as follows. The last section S[l] proceeds only if its segments each has at most t(k) +c(k) items, and its buffer had at most 2·c(k−1) ≤ c(k) operations by Invariant 4. Thus if any of its segments Si[l] becomes overfull and it creates a new section S[l +1], it will subsequently be deferred until S[l +1] runs. And during that run of S[l +1], it will proceed and shift at most 2·c(k) items from Si[l] to Si[l +1], after which Si[l +1] will not be overfull, and so S[l +1] will not create another new section S[l +2]. Therefore we can assume that the chains' lengths never differ by more than one segment, and so the chain rebalancing (step 4b) will make the chains the same length while ensuring the segments in S[k−1] and S[k] are balanced. Invariant 4 holds for S[m], because the first slab proceeds only if S[m]'s buffer has at most c(m− 1) operations, and only processes a cut batch of size at most p2, hence after that S[m]'s buffer will have at most p2 +c(m−1) < 2·c(m−1) operations. Invariant 4 holds for S[k] for each k > m, because S[k−1] proceeds only if S[k]'s buffer has at most c(k−1) operations, and only processes a buffered batch of size at most 2·c(k−2) by Invariant 4 for S[k−1], hence after that S[k]'s buffer will have at most c(k−1) +2·c(k−2) ≤ 2·c(k−1) operations. Invariant 5 holds as follows. Each final slab segment Si[k] is modified only when either S[k] or S[k +1] runs, and the latter never makes Si[k] imbalanced. Consider each S[k] run. It proceeds only if Si[k] has at most t(k) +c(k) items and at least c(k) items unless S[k] is the last section, and its buffer had at most 2·c(k−1) operations by Invariant 4, and Si[k−1] had at most 2·t(k−1) items by Invariant 5 for S[k−1]. So at most 2·c(k−1) items were inserted into Si[k], and at most t(k−1) items were shifted from Si[k−1] to Si[k]. Also, at most 2·c(k−1) items were deleted from Si[k], and at most t(k−1) items were shifted from Si[k] to Si[k−1]. Thus after that run, Si[k] has at most t(k) +c(k) +4·c(k−1) ≤ 2·t(k) items and at least c(k)−2·c(k−1)−t(k−1) ≥ (cid:5) c(k−1) items unless S[k] was the last section, since c(k) = c(k−1)2 ≥ c(m−1)·c(k−1) ≥ 5·c(k−1). With these invariants, we are ready to bound the work done by FS2. a=0 c(a) ≤ c(m−1) 2 . 4 The delay of Γ depends on the actual execution, due to the definition of ∆(α) for each acquire-stall node α in Γ. But it captures the minimum time needed to run Γ in the following sense: For any computation Γ, on any step that executes all ready nodes in the remaining computation Γ(cid:48) (i.e. the unexecuted nodes in Γ), the delay of Γ(cid:48) is reduced. (So if a greedy scheduler is used, the number of steps in which some processor is idle is bounded by the delay.) 12 Theorem 16 (FS2 Work). FS2 takes O(FL) work for some linearization L of FS2-calls in D. Proof. We shall use a similar proof outline as for FS1 Work (Theorem 12). Let L∗ be a linearization of FS2-calls in D such that: " Operations on FS2 that finish during the first slab run or some final slab section run are ordered by when that run finished. " Operations on FS2 that finish during the same first slab run are ordered as follows: 1. Ineffectual operations are before effectual operations. 2. Effectual operations are in order of access type (deletions last). 3. Effectual insertions are in inward order, and effectual deletions are in outward order (Definition 11). " Operations on FS2 in each group-operation are in the same order as in that group. As before, let L(cid:48) be the same as L∗ except that in point 3 effectual deletions are ordered so that those on items in earlier sections are later (instead of outward order). Consider each cut batch B of operations processed by the first slab. By FS2 Balance Invariants (Lemma 15), just before that processing, every segment in Si[0..m−2] is balanced, and Si[m−1] has at most 2·t(m−1) items. Thus in both the preliminary As with FS1, the separation phase takes O(FL∗) work in total (see Theorem 12's proof). Now consider each batch B of operations processed by a final slab section S[k]. By FS2 Balance Invariants (Lemma 15), B has at most 2·c(k−1) operations, and each segment in S[k] always has at most 4·c(k) items. So inserting the operations in B into phase and the execution phase, each section S[k] takes O(cid:0)2k(cid:1) work per operation. And this amounts to O(logr +1) work per operation in B with finger distance r according to L(cid:48), because the operation reaches S[k] only if r ≥min(k−1,m−2) the buffer took O(cid:0)2k(cid:1) work per operation. Converting each bunch in B to a group-operation takes O(1) work per operation. Cutting out and performing and returning the results of the group-operations that fit takes O(cid:0)2k(cid:1) work per group-operation. And the local rebalancing takes O(cid:0)2k(cid:1) work. Therefore each S[k] run that proceeds to process its buffered operations takes O(cid:0)2k(cid:1) work per operation. This again amounts to O(logr +1) work per operation X in B with finger distance r according to L∗ Invariants (Lemma 15). Thus r ≥ c(k−2) and hence X costs O(cid:0)2k(cid:1) ⊆ O(logr) work. as follows: " If X finishes in S[m]: At that point the first slab has at least c(m−1)−p2 ≥ 4p2 items in each chain, because S[m−1] was " If X finishes in S[k] for some k > m: At that point S[k−1] has at least c(k−2) items in each segment by FS2 Balance (cid:5) balanced just before processing the last cut batch. Thus r ≥ 4p2 and hence X costs O(2m) ⊆ O(logr) work. c(k) +1. a=0 Finally, all the rebalancing takes O(1) amortized work per operation, which we shall leave to the next lemma. Lemma 17 (FS2 Rebalancing Work). All the rebalancing steps of FS2 take O(1) amortized work per operation. Proof. We shall maintain the credit invariant that each segment Si[k] with q items beyond its target capacity has at least q·2−k stored credits. Also, each unfinished operation carries 1 credit with it. As with FS1 (see Lemma 13's proof), the invariant can be preserved after rebalancing in the first slab. By the same reasoning, the invariant can also be preserved after segment invariant can be preserved after chain rebalancing in the final slab (step 4b), because it takes O(cid:0)2k(cid:1) work, which can be ignored rebalancing in the final slab (step 4a), because any shift between segments Si[k−1] and Si[k] where k ≥ m is performed only since the last segment rebalancing shift already took O(cid:0)2k(cid:1) work. when Si[k−1] is imbalanced, and after that Si[k−1] has size t(k−1) by FS2 Balance Invariants (Lemma 15). Similarly, the (cid:5) them in the feed buffer) within O(cid:0) b amounts to O(cid:0) b To tackle the span of FS2, we need some lemmas concerning the span of cutting the input batch and the delay in each slab. Lemma 18 (FS2 Input Cutting Span). The first slab cuts an input batch of size b (i.e. cutting it into small batches and storing p +logp(cid:1) span. p +logp(cid:1) span because logb ∈ O(cid:0) b Proof. Cutting the input batch into small batches takes O(logb) span. Adding them to the feed buffer takes O(1 + b p2) span. This (cid:5) (cid:1) if b > p2. p 13 Proof. Consider any final slab section S[k] that has acquired the second neighbour-lock. Checking whether it has an imbalanced segment and checking S[k +1]'s buffer size takes only O(1) delay. By FS2 Balance Invariants (Lemma 15), S[k] has at most 2·c(k−1) operations in its buffer, and S[k] always has at most 2·t(k) items in each segment, and S[k−1] has at most 2·t(k−1) Lemma 19 (FS2 Final Slab Delay). Each section S[k] in the final slab runs within O(cid:0)2k(cid:1) delay (whether it defers or finishes). items in each segment. Thus converting each bunch in the buffer takes O(cid:0)2k(cid:1) span, and performing the operations that fit in S[k] takes O(cid:0)2k(cid:1) span, and rebalancing the segments in S[k−1] takes O(cid:0)2k(cid:1) span. Now consider any final slab section S[k] that has acquired the first neighbour-lock. It waits O(cid:0)2k(cid:1) delay for the current holder (if any) of the second neighbour-lock to release it, and then itself takes O(cid:0)2k(cid:1) more delay to complete its run. Finally consider any final slab section S[k] that starts running. If k = m, it waits O(cid:0)2k(cid:1) delay for the first slab to release the shared neighbour-lock, since the first slab takes only O(2m) span on each access to S[m−1]. If k > m, it waits O(cid:0)2k(cid:1) delay for the current holder of the first neighbour-lock to release it, and then itself takes O(cid:0)2k(cid:1) more delay to complete its run. (cid:5) each cut batch within O(cid:0)(logp)2(cid:1) delay. Lemma 20 (FS2 First Slab Delay). The first slab takes O(logp) delay for each acquiring of the neighbour-lock, and it processes (whose size is at most p2) from the first bunch from the feed buffer takes O(logp) delay. The four phases take O(cid:0)(logp)2(cid:1) Proof. Each acquiring of the neighbour-lock takes O(2m) = O(logp) delay by FS2 Final Slab Delay (Lemma 19). Checking whether S[m−1] has an imbalanced segment and checking S[m]'s buffer size takes only O(1) delay. Obtaining the cut batch delay in total, as in FS1 (see Theorem 14). Inserting the residual group-operations into the buffer of S[m] takes O(logp +2m) = (cid:5) O(logp) delay, since S[m]'s buffer had at most 2·c(m−1) items by FS2 Balance Invariants (Lemma 15). p +d·(logp)2 +sL(cid:1) span for some linearization L of D. (d is the maximum number of Theorem 21 (FS2 Span). FS2 takes O(cid:0) N With these lemmas, we can finally bound the span of FS2. FS2-calls on any path in D, and sL is the weighted span of D with FS2-calls weighted according to FL.) Proof. Take any path C through the program DAG D. Let L be the linearization in the proof of FS2 Work (Theorem 16). Consider any FS2-call X along C with finger distance r according to L. We shall trace the journey of X from the parallel buffer in an input batch to a cut batch and then through the slabs, and bound the delay taken by X relative to FS2, meaning that in the computation of the delay we only count FS2-nodes. Along the way, we shall partition that delay into the normal delay and the deferment delay, where the latter comprises all waiting at the first slab or a section that defers from the point it sets the deferred flag until it is reactivated and clears the deferred flag (and proceeds). Normal delay At the start, X waits in the parallel buffer for the first slab to finish running on the previous input batch of size b(cid:48), taking O delay by FS2 Input Cutting Span (Lemma 18) and FS2 First Slab Delay (Lemma 20). Next X waits for the p +(logp)2(cid:17) (cid:16) b(cid:48) first slab to process some i cut batches of size p2 in the feed buffer, each taking O(cid:0)(logp)2(cid:1) ⊆ O(p) normal delay. Then X is flushed from the parallel buffer in some input batch of size b, which is cut within O(cid:0) b p +(logp)2(cid:1) normal delay, and next waits If X finishes in the final slab, it waits a further O(cid:0)2k(cid:1) normal delay at each final slab section S[k] that it passes through by FS2 segment by FS2 Balance Invariants (Lemma 15). Thus r ≥ c(k−2) and hence X takes O(cid:0)k a=m 2a(cid:1) = O(cid:0)2k(cid:1) ⊆ O(logr) normal O(logg) ⊆ O(cid:0) g for another j cut batches of size p2 that come before X in the feed buffer, each taking O(p) normal delay. (Note that we are ignoring all waiting while the first slab is deferred.) Final Slab Delay (Lemma 19). And when X finishes in a section S[k], at that point S[k−1] has at least c(k−2) items in each delay in the final slab. Finally when X is returned, it is in some group-operation with g operations, so returning the results takes p +logp(cid:1) span. (cid:16) b(cid:48) Therefore in total X takes O p + b p + g p +i·p +j·p +(logp)2 +logr normal delay. (cid:17) 14 p (cid:16)j+1 a=k 2a(cid:17) FS2-calls, and the total deferment delay of all FS2-calls along C is O(cid:0) N ,g,i·p2,j·p2 above will sum up to at most the total number N of (cid:1). Therefore the span of FS2 is O(cid:0) N p +d·(logp)2 +sL(cid:1). p deferment delay is at most O(cid:0) 1 proceed within O(cid:0)2k(cid:1) subsequent delay. (cid:1) per operation on FS2. The invariant is that for k ≥ m−1, each segment Si[k] with q items = O(cid:0)2j(cid:1) delay (by Lemma 15 again), and p·2j ≤(cid:112)c(m) ·2j ∈ O(cid:0)c(j)·2−j(cid:1) since 22j ∈ O(cid:0)(cid:112)c(j)(cid:1). If S[j] had an Deferment delay To bound the deferment delay, we shall use a similar credit invariant as in FS2 Rebalancing Work (Lemma 17), but instead of paying for rebalancing work we shall use the credits to pay for p times the deferment delay. This would imply that the beyond its target capacity has at least q·2−k stored credits, and that each operation in S[k +1]'s buffer carries 2−k credits with it. Consider each deferment of a section S[k] for k ≥ m−1 (where deferment of the first slab is treated as deferment of S[m−1]). At that point either one of its segment is imbalanced or S[k +1]'s buffer has more than c(k) items, and S[k] reactivates S[k +1], which may either defer or proceed. In any case, from that point until S[k + 1] proceeds, S[k] will never proceed (even if reactivated), because its segments and S[k +1]'s buffer remain untouched. But once S[k +1] proceeds, it will empty its buffer and make S[k]'s segments balanced by FS2 Balance Invariants (Lemma 15), and then reactivate S[k] on finishing, so S[k] will Thus if X is waiting at S[k] due to consecutive sections S[k..j] being deferred, and S[j +1] proceeding, the deferment at S[k] lasts O imbalanced segment, it would have at least c(j)·2−j stored credits, and we can use half of it to pay for any needed extra stored credits at S[j +1] due to the shift. If S[j +1]'s buffer had more than c(j) items, then they carry c(j)·2−j credits, and we can use half to pay for any needed extra stored credits at S[j +1] and for any credits carried by operations that go on to S[j +2]. In both cases, we can use the other half of those credits to pay for p times the deferment delay that X takes at S[k]. Total delay There are at most d FS2-calls along C, and over all X, each of b,b(cid:48) (cid:5) 6 General Parallel Finger Structures To support an arbitrary but fixed number f of movable fingers (besides the fingers at the ends), while retaining both work- optimality with respect to the finger bound and good parallelism, we essentially use a basic parallel finger structure for each sector between adjacent fingers. It is easier to do this with FS1, because we are processing the operations in batches. The finger-move operations are all done first in a finger phase before the rest of the batch, and of course we combine finger-move operations on the same finger. Consider any finger that is between two sectors R0 and R1. This finger is sandwiched between the nearest chain Si of R0 and the nearest chain S1−i of R1. To move this finger into chain Si of R0 past an item in segment Si[k], we move all the items I between the old and new finger position from R0 to R1, roughly as follows: 1. Cut out the items in I from sector R0's segments Si[0..k] and join them (from small to big) into a single batch B. 2. Join the items in sector R1's segments S1−i[0..k] (from small to big) and shift them into S1−i[k +1] (by a single join). 3. Use B to fill sector R1's sections S1−i[0..k] to target size except perhaps S1−i[k]. 4. Rebalance R0 and R1 as in FS1's rebalancing phase (Section 4.1). This essentially contributes O(cid:0)2k(cid:1) work and O(logn) span, because we can preserve the same credit invariant to bound the O(cid:0) b p +logp(cid:1), and each sector takes O(logn) span. Thus we will obtain the desired work/span bounds (Theorem 7). rebalancing work and span. It is similar but messier for moving a finger so far that it goes over the nearer chain of R0 and into its further chain. After that, we can simply partition the map operations around the fingers and perform each part on the correct sector in parallel. This partitioning takes O(b) work and O(logb) span for each batch of b operations (see Appendix Section A.2), and O(logb) ⊆ It is much harder for FS2, and considerably complicated, so we shall not attempt to explain it here. 15 7 Work-Stealing Schedulers The bounds on the work and span of FS1 and FS2 in Section 4 and Section 5 hold regardless of the scheduler. The performance bounds for FS1 and FS2 in Section 1 require a greedy scheduler, in order to bound the parallel buffer cost. In practice, we do not have such schedulers. But we can design a suitable work-stealing scheduler in the QRMW pointer machine model that yields the desired time bounds (Theorem 3 and Theorem 4) on average, as we shall explain below. We make the modest assumption that each processor (in the QRMW pointer machine) can generate a uniformly random integer in [1..p] and convert it to a pointer given by a constant lookup-table within O(1) steps. For instance, this can be done if each processor has local RAM of size p (i.e. sole access to its own local memory with p cells and O(1) random access). The blocking work-stealing scheduler in [12] is for an atomic message passing model, in which multiple concurrent accesses to each deque are arbitrarily queued and serviced one at a time. This can be supported by guarding each deque with a CLH lock [29], and the analysis carries over. The non-blocking work-stealing scheduler in [7] assumes O(1) memory contention cost, which is contrary to the QRMW contention model. Nevertheless, the combinatorial techniques in that paper can be adapted to prove the desired performance bounds for our implementation (Definition 22). Definition 22 (Non-Blocking Work-Stealing Scheduler). The non-blocking work-stealing scheduler can be implemented in the QRMW pointer machine model as follows: " Each processor i ∈ [1..p] has: " A global deque Qi of DAG nodes, shared between owner and stealer using Dekker's algorithm. " A global non-blocking lock Li (see Appendix Definition 36). " A local array Ri[1..p] where Ri[j] stores a pointer to Qj and a pointer to Lj. // Used implicitly wherever needed. " Each processor i does the following repeatedly: Access Qi as owner, removing the node v at the bottom if it is non-empty. If v exists (i.e. Qi was non-empty): Otherwise: Execute v. Access Qi as owner, inserting all the child nodes generated by v at the bottom. Create Int k uniformly randomly chosen from [1..p]. If TryLock(Lk): Access Qk as stealer, removing the node w at the top if it is non-empty. Unlock(Lk). If w exists (i.e. Qk was non-empty): Execute w. Access Qi as owner, inserting all the child nodes generated by w at the bottom. 8 Conclusions This paper presents two parallel finger structures that are work-optimal with respect to the finger bound, and the faster version has a lower span by using careful pipelining. Pipelining techniques to reduce the span of data structure operations have been explored before [10, 4]. As indicated by our results, the extended implicit batching framework combines nicely with pipelining and is a promising approach in the design of parallel data structures. Nevertheless, despite the common framework, the parallel finger structures in this paper and the parallel working-set map in [4] rely on different ad-hoc techniques and analysis, and it raises the obvious interesting question of whether there is a way to obtain a batch-parallel splay tree in the same framework, that satisfies both the working-set property and the finger property. 16 Appendix Here we spell out the model details, building blocks and supporting theorems used in our paper. A.1 QRMW Pointer Machine Model QRMW stands for queued read-modify-write, as described in [15]. In this contention model, asynchronous processors perform memory accesses via read-modify-write (RMW) operations (including read, write, test-and-set, fetch-and-add, compare-and- swap), which are supported by almost all modern architectures. Also, to capture contention costs, multiple memory requests to the same memory cell are FIFO-queued and serviced one at a time, and the processor making each memory request is blocked until the request has been serviced. In the parallel pointer machine, each processor has a fixed number of local registers and memory accesses are done only via pointers, which can be locally stored or tested for equality (but no pointer arithmetic). The QRMW pointer machine model, introduced in [4], extends the parallel pointer machine model in [21] to RMW operations. In this model, each memory node has a fixed number of memory cells, and each memory cell can hold a single field, which is either an integer or a pointer. Each processor also has a fixed number of local registers, each of which can hold a single field. The basic operations that a processor can perform include arithmetic operations on integers in its registers, equality-test between pointers in its registers, creating a new memory node and obtaining a pointer to it, and RMW operations. An RMW operation can be performed on any memory cell via a pointer to the memory node that it belongs to. All operations except for RMW operations take one step each. RMW operations on each memory cell are FIFO-queued to be serviced, and the first RMW operation in the queue (if any) is serviced at each time step. The processor making each memory request is blocked until the request has been serviced. A.2 Parallel Batch Operations We rely on the following basic operations on batches: " Split a given batch of n items into left and right parts around a given position, within O(logn) work/span. " Partition a given batch of n items into lower and upper parts around a given pivot, within O(n) work and O(logn) span. " Partition a sorted batch of n items around a sorted batch of k pivots, within O(k·logn) work and O(logn +logk) span. " Join a batch of batches with n total items, within O(n) work and O(logn) span. " Merge two sorted batches with n total items, optionally combining duplicates, within O(n) work and O(logn) span if the combining procedure takes O(1) work/span. These can be implemented in the QRMW pointer machine model [28] with each batch stored as a BBT (leaf-based height- balanced binary tree with an item at each leaf). They can also be implemented (more easily) in the binary forking model in [9] with each batch stored in an array. For instance, joining a batch of arrays can be done by using the standard prefix-sum technique to compute the total size of the first k arrays, and hence we can copy each array in parallel into the final output array, and merging two sorted arrays can be done by the algorithm given in [26] (section 2.4) and [35]. A related data structure that we also rely on is the bunch data structure, which is defined as follows. Definition 23 (Bunch Structure). A bunch is an unsorted set supporting addition of any batch of new elements within O(1) work/span and conversion to a batch within O(b) work and O(logb) span if it has size b. A bunch can be implemented using a complete binary tree with batches at the leaves, with a linked list threaded through each level to support adding a new batch as a leaf in O(1) work/span. To convert a bunch to a batch, we treat the bunch as a batch of batches and parallel join all the batches. A.3 Batch-Parallel Map In this paper we rely on a parallel map that supports the following operations: " Unsorted batch search: Search for an unsorted input batch of b items (not necessarily distinct), tagging each search item " Sorted batch access: Perform an item-sorted input batch of b operations on distinct items, tagging each operation with the with the result, all within O(b·logn) work and O(logb·logn) span, where n is the map size. result, all within O(b·logn) work and O(logb +logn) span, where n is the map size before the batch access. most r in M, and M2 contains the items with ranks more than r in M, within O(logk) work/span. " Split: Split a map M of size k around a given pivot rank r into two maps M1,M2, where M1 contains the items with ranks at " Join: Join maps M1,M2 of total size k where every item in M1 is less than every item in M2, within O(logk) work/span. This can be achieved in the QRMW pointer machine model [28], and also (more easily) in the binary forking model [9]. 17 A.4 Parallel Buffer To facilitate extended implicit batching, we can use any parallel buffer implementation that takes O(p + b) work and O(logp +logb) span per batch of size b (on p processors), any operation that arrives is (regardless of the scheduler) within O(1) span included in the batch that is being flushed or in the next batch, and there are always at most 1 2p +q ready buffer nodes (active threads of the buffer) where q is the number of operations that are currently buffered or being flushed. This would entail the following parallel buffer overhead [4] (and we reproduce the proof here). Theorem 24 (Parallel Buffer Cost). Take any program P using an implicitly batched data structure M that is run using any greedy scheduler. Then the cost (Definition 6) of the parallel buffer for M is O , where T1 is the work of all the P-nodes, and w is the work taken by M, and d is the maximum number of M-calls on any path in the program DAG D. Proof. Let t1 and t∞ be the total work and span (Definition 6) respectively of the parallel buffer for M. Let N be the total number of operations on M. Consider each batch B of b operations on M. Let tB be span taken by the buffer on B. If b ≤ p2, then tB ∈ O(logp). If b > p2, then tB ∈ O(logb) ⊆ O(cid:0) b p +logp(cid:1) and hence t∞ ∈ O(cid:0) N (cid:1). Thus tB ∈ O(cid:0) b p +d·logp(cid:1). (cid:16) T1+w p +d·logp (cid:17) p (cid:17) p ∈ O( T1+w p +d·logp since N ≤ T1. (cid:16) T1+w 2p +(b +b(cid:48)) < 2 p +t∞), and hence the buffer's cost is t1 3p ready buffer nodes in E, so at least one of the following holds at each over all intervals there are O(t∞) such steps, taking O(p·t∞) work. p +t∞ ∈ O Now consider the actual execution of the execution DAG E of the program P using M. At each time step, the buffer is processing at most two consecutive batches, so we shall analyze the buffer work done during the time interval for each pair of consecutive batches B and B(cid:48), where B has b operations and B(cid:48) has b(cid:48) operations. If b +b(cid:48) ≥ 1 6p, then the buffer work done on B and B(cid:48) is O(b +b(cid:48)). If b +b(cid:48) 6p, then there are at most 1 < 1 time step in this interval: 6p ready P-nodes in E are being executed. These steps take at most O(T1) work over all intervals. " At least 1 6p ready M-nodes in E are being executed. These steps take at most O(w) work over all intervals. " At least 1 " At most p ready nodes in E are being executed. All ready buffer nodes in E are being executed (by greedy scheduling), so (cid:5) Therefore t1 The parallel buffer for each data structure M can be implemented using a static BBT (leaf-based balanced binary tree), with a sub-buffer at each leaf node, one for each processor, and a flag at each internal node. Each sub-buffer stores its operations as the leaves of a complete binary tree with a linked list threaded through each level. Whenever a thread τ makes a call to M, the processor running τ suspends it and inserts the call together with a callback (i.e. a structure with a pointer to τ and a field for the result) into the sub-buffer for that processor. Then the processor walks up the BBT from leaf to root, test-and-setting each flag along the way, terminating if it was already set. On reaching the root, the processor notifies M (by reactivating it), which can decide when to flush the buffer. M can also query whether the parallel buffer is non-empty, defined as whether the flag at the root is set. M can eventually return the result of the call via the callback (i.e. by updating the result field and then resuming τ ). Whenever the buffer is flushed (by M), all sub-buffers are swapped out by a parallel recursion on the BBT, replaced by new sub-buffers in a newly constructed static BBT. We then wait for all pending insertions into the old sub-buffers to be completed, before joining their contents into a single batch to be returned (to M). To do so, each processor i has a flag yi initialized to true, and a thread field ϕi initialized to null. Whenever it inserts an M-call X, it sets yi := false, then inserts X into the (current) sub-buffer, then resumes ϕi if TestAndSet(yi) = true. To wait for pending insertions into the old sub-buffer for processor i, we store a pointer to the current thread in ϕi and then suspend it if TestAndSet(yi) = false. Inserting into each sub-buffer can be done in O(1) time. Test-and-setting each flag in the BBT also takes O(1) time, because at most three processors ever access it. Each static BBT takes O(p) work and O(logp) span to initialize. Each data structure call takes O(p) work and O(logp) span for a processor to reach the root, because the flags ensure that only O(1) work is done per node in traversing the BBT. Joining the contents of the sub-buffers takes O(p +b) work and O(logp +logb) span if the resulting joined batch is of size b. It is also easy to ensure that flushing uses at most 1 2p +b threads where b is the size of the flushed batch. Thus this parallel buffer implementation has the desired properties that support extended implicit batching. It is worth noting that the parallel buffer can be implemented in the dynamic multithreading paradigm, like all other data structures and algorithms in this paper, but it requires the ability for a thread to have O(1)-time access to the sub-buffer for the processor running it, so that it can insert each data structure-call into the sub-buffer in O(1) work/span. This can be done if each processor has a local array of size p (i.e. it is accessible only by that processor but supports O(1) random access) for each implicitly batched data structure, and each thread can retrieve the id of the processor running it. But in the QRMW pointer machine model this is not necessary if the program uses a fixed set of implicitly batched data structures, since each processor can be initialized with a (constant) pointer to a structure that always points to the current sub-buffer for that processor. 18 A.5 Sorting Theorems The items in the search problem can come from any arbitrary set S that is linearly ordered by a given comparison function, and we shall assume that S has at least two items. As is standard, let Sn be the set of all length-n sequences from S. Search structures can often be adapted to implement sorting algorithms 5, in which case any lower bound on complexity of sorting typically implies a lower bound on the costs of the search structure. For the proofs of FS1 Work and FS2 Work we need a crucial lemma that the entropy bound is a lower bound for (comparison-based) sorting, as precisely stated below. Lemma 25 (Sorting Entropy Bound). For any sequence I in Sn with item frequencies q1..u (i.e.u algorithm requires Ω(H) comparisons on average over all (distinct) rearrangements of I, where H =u i=1 qi = n), any sorting (cid:1) is the (cid:0)qi·log n entropy of I. [30] From this we immediately get a relation (Theorem 28) between the entropy bound and the maximum finger bound (i.e. the maximum finger bound over all permutations), because we can use a finger-tree to perform sorting. Definition 26 (Finger-Tree Sort). Let FSort be the sequential algorithm that sorts an input sequence I as follows: i=1 qi Create an empty finger-tree F (with one finger at each end) that stores linked lists of items. For each item x in I, if F already has a linked list of copies of x, then append x to that linked list, otherwise insert a linked list containing just x into F. At the end iterate through F to produce the desired sorted sequence. Definition 27 (In-order Item Frequencies). A sequence I in Sn is said to have in-order item frequencies q1..u if the i-th (cid:1). finger bound for I, defined as MFI =u smallest item in I occurs qi times in I. Theorem 28 (Maximum Finger Bound). Take any sequence I in Sn with in-order item frequencies q1..u. Then the maximum Proof. By the Sorting Entropy Bound (Lemma 25) let J be a rearrangement of I such that FSort(J) takes Ω(H) comparisons. Finally we give a parallel sorting algorithm PESort that achieves the entropy bound for work but yet takes only O(cid:0)(logn)2(cid:1) (cid:5) Clearly FSort(J) also takes O(MFJ) = O(MFI) comparisons, and hence MFq ∈ Ω(H). i=1 qi·(logmin(i,u +1−i) +1), satisfies MFI ∈ Ω(H) where H =u (cid:0)qi·log n i=1 qi span on a list of n items, which we need in our parallel finger structure. For comparison, we also give the simpler parallel merge-sort PMSort. The input and output lists are each stored in a batch (leaf-based balanced binary tree), and these algorithms work in the QRMW pointer machine model. We shall use the following notation for every binary tree T: T.root is its root, and for each node v of T, v.left and v.right are its child nodes, and v.height is the height of the subtree at v, and v.size is the number of leaves of the subtree at v. Definition 29 (Parallel Merge-Sort). Let PMSort be the procedure that does the following on an input batch I of items: If I.size ≤ 1, return I. Otherwise, compute in parallel A = PMSort(I.left) and B = PMSort(I.right), and then parallel merge (Section A.2) A and B into an item-sorted batch C, and then return C. Theorem 30 (PMSort Costs). PMSort sorts every sequence I in Sn within O(n·logn) work and O(cid:0)(logn)2(cid:1) span. (cid:5) Proof. The claim follows directly from the work/span bounds for parallel merging (Section A.2) and I.height ∈ O(logn). Definition 31 (Parallel Entropy-Sort). Define a bundle of an item x to be a BT (binary tree) in which every leaf has a tagged copy of x. Let PESort be the parallel merge-sort variant that does the following on an input batch I of items: If I.size ≤ 1, return I. Otherwise, compute in parallel A = PESort(I.left) and B = PESort(I.right), and then parallel merge (Section A.2) A and B into an item-sorted batch C of bundles, combining bundles of the same item into one by simply making them the child subtrees of a new bundle, and then return C. (cid:0)qi·ln n Then PESort(I) returns an item-sorted batch of bundles, with one bundle (of all the tagged copies) for each distinct item in I, and clearly each bundle has height at most I.height. Theorem 32 (PESort Costs). PESort sorts every sequence I in Sn with item frequencies q1..u within O(H + n) work and O(cid:0)(logn)2(cid:1) span, where H =u item x takes O(1) times the number of nodes of T that contain a bundle of x, and there are O(cid:0)k·log n the frequency of x in I, by Lemma 33 below. Therefore PESort(I) takes O(cid:0)u Proof. Consider the merge-tree T, in which each node is the result of parallel merging its child nodes. Note that T.height = I.height ∈ O(logn), and that each item in I occurs in at most one bundle in each node of T. Clearly the work done is O(1) times the total length of all the parallel merged batches (Section A.2). Thus the work done can be divided per item; work done on k +k(cid:1) such nodes where k is +qi(cid:1)(cid:1) ⊆ O(H +n) work. The span qi bound on PESort(I) is immediate from the span bound on parallel merging (Section A.2). (cid:0)qi·log n (cid:1). (cid:5) i=1 i=1 qi 5 A sorting algorithm is a procedure that given any input sequence will output a sequence of pointers to the input items in sorted order. 19 internal node marked iff it is on a path from the root to a marked leaf, the number of marked nodes of T is O(cid:0)k·log n k +k(cid:1). Lemma 33 (BBT Subtree Size Bound). Given any BBT T with n leaves of which k are marked with k > 0, and with each Proof. We shall iteratively change the set of marked leaves of T, and accordingly update the internal nodes so that each of them is marked iff it is on a path from the root to a marked leaf. At each step, if there is a marked node u with a marked child v and an unmarked child w such that v has two marked children, then unmark the rightmost marked leaf x in the subtree at v and mark the deepest leaf y in the subtree at w. This will not decrease the number of marked nodes, because unmarking x results in unmarking at most v.right.height internal nodes, and marking y results in marking at least w.height internal nodes, and v.right.height ≤ w.height since T is a BBT. Note that each step decreases the sum of the lengths of all the paths from the root to the marked nodes with two marked children, so this iterative procedure terminates after finitely many steps. After that, for every node v with only one marked child, there is only one marked leaf in the subtree at v. Let A be the set of marked nodes with two marked children, and B be the set of marked nodes not in A but with a parent in A. Then there are exactly (k−1) nodes in A, and exactly k nodes in B, and the subtrees at nodes in B are disjoint, sov∈B v.size ≤ n. Since every marked node is either in A or on the downward path of marked nodes from some node in B, the number of marked nodes is at most (k−1) +v∈B(v.height +1) ∈ O(k +v∈B logv.size) ⊆ O(cid:0)k +k·log n (cid:5) Remark. See [28] (Subtree Size Bound) for a generalization of Lemma 33 with a different proof, but if we want a bound with explicit constants then the above proof yields a tighter bound for a BBT. PESort is all we need for the parallel finger search structures FS1 and FS2, but we can in fact obtain a full parallel entropy-sorting algorithm, namely one that outputs a single item-sorted batch of all the (tagged copies of) items in the input sequence I from Sn and satisfies the entropy bound for work. Specifically, we can convert each bundle in PESort(I) to a batch (Definition 34), and then parallel join (Section A.2) all those batches to obtain the desired output. Definition 34 (Bundle Balancing). A bundle B of size b and height h is balanced as follows: (cid:1) by Jensen's inequality. k Recursively construct a linked list through all the leaves of B, and mark the leaves of B with (1-based) rank of the form (i·h +1), and then extract those marked leaves as a batch P (by parallel filtering as described in [28]). Then at each leaf v in P, construct and store at v a batch of the items in B with ranks i·h +1 to (i +1)·h, obtained by traversing the linked list forward. Now P is essentially a batch of size-h batches (except perhaps the last smaller batch), which we then recursively join to obtain the batch of all items in G (alternatively, but less efficiently, simply parallel join P). Theorem 35 (Bundle Balancing Costs). Balancing a bundle B of size b and height h takes O(b) work and O(h) span. Proof. Note that B has less internal nodes than leaves, and so constructing the linked list takes O(b) work and O(h) span. Extracting the batch P of items of B with ranks at intervals of h takes O(b +P.size·h) = O(b) work and O(h) span. Constructing the batches of items in-between those in P takes O(b) work and O(P.height +h) ⊆ O(h) span, and recursively joining them takes (cid:5) O(1) work and span per node of P (except O(h) span for the first joining involving the last batch). A.6 Locking Mechanisms Here we give pseudo-code implementations of the various locking mechanisms used as primitives in this paper (Section 2.1), which have the claimed properties under the QRMW memory contention model. The non-blocking lock is trivially implemented using test-and-set as shown in TryLock/Unlock below. Definition 36 (Non-Blocking Lock). TryLock( Bool x ): Return ¬TestAndSet(x). Unlock( Bool x ): Set x := false. Next is the reactivation wrapper for a procedure P, which can be implemented using fetch-and-add and guarantees the following according to some linearization [28]: 1. Whenever P is reactivated, there will be a complete run of P that starts after that reactivation. 2. If P is run only via reactivations, then no runs of P overlap, and there are at most as many runs of P as reactivations of P. 3. If P is reactivated by only k threads at any time, then each reactivation call C finishes within O(k) span, and some run of P starts within O(k) span after the start of C or the end of the last run of P that overlaps C. 20 Definition 37 (Reactivation Wrapper). (P is the procedure to be guarded by the wrapper.) Private Procedure P. Private Int count := 0. Public Reactivate(): If FetchAndAdd(count,1) = 0: Fork the following: Do: Set count := 1. P(). While FetchAndAdd(count,−1) > 1. The dedicated lock with keys [1..k], where threads must use distinct keys to acquire it, can be implemented using fetch-and-add as shown below and guarantees the following according to some linearization [4]: 1. Mutual exclusion: Only one thread can hold the lock at any point in time; a thread becomes the lock holder when it successfully acquires the lock, and must release the lock before the next successful acquisition. 2. Fairness and bounded latency: When any thread attempts to acquire the dedicated lock, it will become a pending holder within O(k) span, and each pending holder will successfully acquire the lock after at most 1 subsequent successful acquisition per key (if every lock holder eventually releases the lock). And whenever the lock is released, if there is at least one pending holder then within O(k) span the lock would be successfully acquired again. Definition 38 (Dedicated Lock). (k is the number of keys.) Private Int count := 0. Private Int last := 0. Private Array q[1..k] initialized with null. Public Acquire( Int i ): If FetchAndAdd(count,1) = 0: Set last := i. Return. Otherwise: Write pointer to current thread into q[i]. Suspend current thread. Public Release(): If FetchAndAdd(count,−1) > 1: Create Int j := last. Create Pointer t := null. While t = null: Set j := j%k +1. If q[j] (cid:44) null, then swap t,q[j]. Set last := j. Resume t. It is worth mentioning that we can easily replace the array q[1..k] in the above implementation by a cyclic linked list, and use the linked list nodes instead of integers as the keys. 21 References [1] Yehuda Afek, Haim Kaplan, Boris Korenfeld, Adam Morrison, and Robert E Tarjan. The cb tree: a practical concurrent self-adjusting search tree. Distributed computing, 27(6):393 -- 417, 2014. [2] Yehuda Afek, Haim Kaplan, Boris Korenfeld, Adam Morrison, and Robert Endre Tarjan. Cbtree: A practical concurrent self-adjusting search tree. In DISC, volume 7611 of Lecture Notes in Computer Science, pages 1 -- 15. Springer, 2012. [3] Kunal Agrawal, Jeremy T Fineman, Kefu Lu, Brendan Sheridan, Jim Sukha, and Robert Utterback. Provably good scheduling for parallel programs that use data structures through implicit batching. In Proceedings of the 26th ACM symposium on Parallelism in algorithms and architectures, pages 84 -- 95. ACM, 2014. [4] Kunal Agrawal, Seth Gilbert, and Wei Quan Lim. Parallel working-set search structures. In Proceedings of the 30th ACM symposium on Parallelism in algorithms and architectures, pages 321 -- 332. ACM, 2018. [5] Yaroslav Akhremtsev and Peter Sanders. Fast parallel operations on search trees. In 2016 IEEE 23rd International Conference on High Performance Computing (HiPC), pages 291 -- 300. IEEE, 2016. [6] Vitaly Aksenov, Petr Kuznetsov, and Anatoly Shalyto. Parallel Combining: Benefits of Explicit Synchronization. In Jiannong Cao, Faith Ellen, Luis Rodrigues, and Bernardo Ferreira, editors, 22nd International Conference on Principles of Distributed Systems (OPODIS 2018), volume 125 of Leibniz International Proceedings in Informatics (LIPIcs), pages 11:1 -- 11:16, Dagstuhl, Germany, 2018. Schloss Dagstuhl -- Leibniz-Zentrum fuer Informatik. [7] Nimar S Arora, Robert D Blumofe, and C Greg Plaxton. Thread scheduling for multiprogrammed multiprocessors. Theory of computing systems, 34(2):115 -- 144, 2001. [8] Guy E Blelloch, Daniel Ferizovic, and Yihan Sun. Just join for parallel ordered sets. In Proceedings of the 28th ACM Symposium on Parallelism in Algorithms and Architectures, pages 253 -- 264. ACM, 2016. [9] Guy E Blelloch, Jeremy T Fineman, Yan Gu, and Yihan Sun. Optimal parallel algorithms in the binary-forking model. arXiv preprint arXiv:1903.04650, 2019. [10] Guy E. Blelloch and Margaret Reid-Miller. Pipelining with futures. In Proceedings of the ninth annual ACM symposium on Parallel algorithms and architectures, SPAA '97, pages 249 -- 259, New York, NY, USA, 1997. ACM. [11] Guy E. Blelloch and Margaret Reid-Miller. Fast set operations using treaps. In Proceedings of the tenth annual ACM symposium on Parallel algorithms and architectures, pages 16 -- 26, 1998. [12] Robert D Blumofe and Charles E Leiserson. Scheduling multithreaded computations by work stealing. Journal of the ACM (JACM), 46(5):720 -- 748, 1999. [13] Trevor Brown, Faith Ellen, and Eric Ruppert. A general technique for non-blocking trees. In ACM SIGPLAN Notices, volume 49, pages 329 -- 342. ACM, 2014. [14] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. The MIT Press, third edition, 2009. [15] Cynthia Dwork, Maurice Herlihy, and Orli Waarts. Contention in shared memory algorithms. Journal of the ACM (JACM), 44(6):779 -- 805, 1997. [16] Faith Ellen, Panagiota Fatourou, Joanna Helga, and Eric Ruppert. The amortized complexity of non-blocking binary search trees. In Proceedings of the 2014 ACM symposium on Principles of distributed computing, pages 332 -- 340. ACM, 2014. [17] Faith Ellen, Panagiota Fatourou, Eric Ruppert, and Franck van Breugel. Non-blocking binary search trees. In Proceedings of the 29th ACM SIGACT-SIGOPS Symposium on Principles of Distributed Computing, PODC '10, pages 131 -- 140, New York, NY, USA, 2010. ACM. [18] Stephan Erb, Moritz Kobitzsch, and Peter Sanders. Parallel bi-objective shortest paths using weight-balanced b-trees with bulk updates. In International Symposium on Experimental Algorithms, pages 111 -- 122. Springer, 2014. [19] Panagiota Fatourou and Nikolaos D. Kallimanis. Revisiting the combining synchronization technique. In PPoPP, pages 257 -- 266, 2012. [20] Matteo Frigo, Charles E. Leiserson, and Keith H. Randall. The implementation of the Cilk-5 multithreaded language. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 212 -- 223, 1998. [21] Michael T Goodrich and S Rao Kosaraju. Sorting on a parallel pointer machine with applications to set expression evaluation. Journal of the ACM (JACM), 43(2):331 -- 361, 1996. [22] Leo J Guibas, Edward M McCreight, Michael F Plass, and Janet R Roberts. A new representation for linear lists. In Proceedings of the ninth annual ACM symposium on Theory of computing, pages 49 -- 60. ACM, 1977. 22 [23] Danny Hendler, Itai Incze, Nir Shavit, and Moran Tzafrir. Flat combining and the synchronization-parallelism tradeoff. In Proceedings of the ACM Symposium on Parallelism in Algorithms and Architectures (SPAA), pages 355 -- 364, 2010. [24] John Iacono. Alternatives to splay trees with O(log n) worst-case access times. In Proceedings of the twelfth annual ACM-SIAM symposium on Discrete algorithms, pages 516 -- 522. Society for Industrial and Applied Mathematics, 2001. Intel Cilk Plus Language Extension Specification, Version 1.1, 2013. Document 324396- 002US. Available from http://cilkplus.org/sites/default/files/open_specifications/Intel_Cilk_ plus_lang_spec_2.htm. [25] Intel Corporation. [26] Joseph JáJá. An introduction to parallel algorithms, volume 17. Addison-Wesley Reading, 1992. [27] S Rao Kosaraju. Localized search in sorted lists. In Proceedings of the thirteenth annual ACM symposium on Theory of computing, pages 62 -- 69. ACM, 1981. [28] Wei Quan Lim. Optimal multithreaded batch-parallel 2-3 trees. arXiv:1905.05254, 2019. [29] Peter Magnusson, Anders Landin, and Erik Hagersten. Queue locks on cache coherent multiprocessors. In Parallel Processing Symposium, 1994. Proceedings., Eighth International, pages 165 -- 171. IEEE, 1994. [30] Ian Munro and Philip M Spira. Sorting and searching in multisets. SIAM journal on Computing, 5(1):1 -- 8, 1976. [31] OpenMP Architecture Review Board. OpenMP application program interface, version 4.0. Available from http: //www.openmp.org/mp-documents/OpenMP4.0.0.pdf, July 2013. [32] Y. Oyama, K. Taura, and A. Yonezawa. Executing parallel programs with synchronization bottlenecks efficiently. In Proceedings of the International Workshop on Parallel and Distributed Computing for Symbolic and Irregular Applications (PDSIA), pages 182 -- 204, 1999. [33] Wolfgang Paul, Uzi Vishkin, and Hubert Wagener. Parallel dictionaries on 2 -- 3 trees. Automata, Languages and Programming, pages 597 -- 609, 1983. [34] James Reinders. Intel Threading Building Blocks: Outfitting C++ for Multi-Core Processor Parallelism. O'Reilly, 2007. [35] Nodari Sitchinava. Ics 643: Advanced parallel algorithms lecture 10. http://www2.hawaii.edu/~nodari/teaching/ f16/notes/notes10.pdf, 2016. [36] Daniel Dominic Sleator and Robert Endre Tarjan. Self-adjusting binary search trees. Journal of the ACM (JACM), 32(3):652 -- 686, 1985. [37] The Task Parallel Library. http://msdn.microsoft.com/en-us/magazine/cc163340.aspx, October 2007. [38] Thomas Tseng, Laxman Dhulipala, and Guy Blelloch. Batch-parallel euler tour trees. In 2019 Proceedings of the Twenty-First Workshop on Algorithm Engineering and Experiments (ALENEX), pages 92 -- 106. SIAM, 2019. 23
1205.6960
2
1205
2012-11-23T10:09:42
Minimizing Movement: Fixed-Parameter Tractability
[ "cs.DS" ]
We study an extensive class of movement minimization problems which arise from many practical scenarios but so far have little theoretical study. In general, these problems involve planning the coordinated motion of a collection of agents (representing robots, people, map labels, network messages, etc.) to achieve a global property in the network while minimizing the maximum or average movement (expended energy). The only previous theoretical results about this class of problems are about approximation, and mainly negative: many movement problems of interest have polynomial inapproximability. Given that the number of mobile agents is typically much smaller than the complexity of the environment, we turn to fixed-parameter tractability. We characterize the boundary between tractable and intractable movement problems in a very general set up: it turns out the complexity of the problem fundamentally depends on the treewidth of the minimal configurations. Thus the complexity of a particular problem can be determined by answering a purely combinatorial question. Using our general tools, we determine the complexity of several concrete problems and fortunately show that many movement problems of interest can be solved efficiently.
cs.DS
cs
Minimizing Movement: Fixed-Parameter Tractability∗ MohammadTaghi Hajiaghayi§‡¶ Erik D. Demaine†‡ D´aniel Marx(cid:107)∗∗ 2 1 0 2 v o N 3 2 ] S D . s c [ 2 v 0 6 9 6 . 5 0 2 1 : v i X r a Abstract We study an extensive class of movement minimization problems which arise from many practical scenarios but so far have little theoretical study. In general, these problems involve planning the coordi- nated motion of a collection of agents (representing robots, people, map labels, network messages, etc.) to achieve a global property in the network while minimizing the maximum or average movement (expended energy). The only previous theoretical results about this class of problems are about approximation, and mainly negative: many movement problems of interest have polynomial inapproximability. Given that the number of mobile agents is typically much smaller than the complexity of the environment, we turn to fixed-parameter tractability. We characterize the boundary between tractable and intractable movement problems in a very general setup: it turns out the complexity of the problem fundamentally depends on the treewidth of the minimal configurations. Thus the complexity of a particular problem can be determined by answering a purely combinatorial question. Using our general tools, we determine the complexity of several concrete problems and fortunately show that many movement problems of interest can be solved efficiently. 1 Introduction In many applications, we have a relatively small number of mobile agents (e.g., a team of autonomous robots or people) moving cooperatively in a vast terrain or complex building to achieve some task. The number of cooperative agents is often small because of their expense: only small groups of people (e.g., emergency response or special police units) can effectively cooperate, and autonomous mobile robots are currently quite expensive (in contrast to, e.g., immobile sensors). Nonetheless, an accurate model of the immense/intricate environment they traverse, and their ability to communicate or otherwise interact (say, by limited-range wireless radios or walkie-talkies), is complicated and results in a large problem input. Thus, to compute the most energy-efficient motion in such a scenario, we allow the running time to be relatively large (exponential) in the number of agents, but it must be small (polynomial or even linear) in the complexity of the environment. This setup motivates the study of fixed-parameter tractability (FPT) [13, 16, 27, 21] for minimizing movement, with running time f (k) · nO(1) for some function f , parameterized by the number k of mobile agents. A movement minimization problem is defined by a class of target configurations that we wish the mobile agents to form and a movement objective function. For example, we may wish to move the agents to edu -- Research. 1. form a connected communication network (given a model of connectivity); ∗A preliminary version of this paper appeared in Proceedings of the 17th Annual European Symposium on Algorithms, 2009. †MIT Computer Science and Artificial Intelligence Laboratory, 32 Vassar St., Cambridge, MA 02139, USA, edemaine@mit. ‡Research supported in part by NSF grant CCF-1161626 and DARPA/AFOSR grant FA9550-12-1-0423. §A. V. Williams Building, University of Maryland, College Park, MD 20742, USA, [email protected]; and AT&T Labs ¶Research supported in part by NSF CAREER award 1053605, NSF grant CCF-1161626, ONR YIP award N000141110662, (cid:107)Computer and Automation Research Institute, Hungarian Academy of Sciences (MTA SZTAKI), Budapest, Hungary, ∗∗Research supported by the European Research Council (ERC) grant "PARAMTIGHT: Parameterized complexity and the DARPA/AFOSR grant FA9550-12-1-0423, and a University of Maryland Research and Scholarship Award (RASA). [email protected] search for tight complexity results," reference 280152. 1 2. form a fault-tolerant (say, k-connected) communication network; 3. disperse throughout the environment (forming an independent set in a graph representing proximity, which also has applications to map labeling [12, 22, 32, 23, 11]). 4. collect into a small number of collocated groups (e.g., to form teams or arrange for a small number of deliveries); 5. form a perfect matching of communication pairs (e.g., to exchange information in each step of a network multicast); 6. arrange into a desired topological formation such as a grid (a common goal in providing reliable communication infrastructure); 7. service a collection of clients (e.g., sensors, who may themselves be mobile); 8. separate "main" agents (say, representing population) from "obnoxious" agents (say, representing power plants); or 9. augment an existing immobile network to achieve a desired property such as connectivity (viewing the agents as starting at infinity, and thus minimizing the number of moved/used resources as in [4, 6, 7]). This list is just a partial collection of interesting agent formations; there are many other desiderata of practical interest, including combinations of different constraints. See Section 3.1 for more formal examples of problems and how our theory applies to them. In the general formulation of the movement problem, we are given an arbitrary metric defining feasible motion, a graph defining "connectivity" (possibly according to the infinite Euclidean plane), and a desired property of the connectivity among the agents defined by a class G of graphs. We view the agents as "pebbles" located at vertices of the connectivity graph (and we use the two terms interchangeably). Our goal is to move the agents so that they induce a subgraph of the connectivity graph that possesses the desired property, that is, belongs to the class G. There are three natural measures of agent motion that we might want to minimize: the total amount of motion, the maximum motion of any agent, and the number of moved agents. To obtain further generality and to model a wider range of problems, we augment this model with additional features: the agents have types, desired solutions can require certain types of agents, multiple agents can be located at the same vertex, and the cost of the movement can be different (even nonmetric) for the different agents. To what level of generality can we solve these movement problems? Several versions have been studied from an approximation algorithms perspective [11, 18], in addition to various specific problems considered less formally in practical scenarios [4, 6, 7, 20, 26, 29, 31, 12, 22, 32, 23]. Unfortunately, most forms of the movement problem are NP-complete, and furthermore are often hard to approximate even within polynomial factors [11]. Nonetheless, the problems are of significant practical interest, and the motion must be kept small in order to minimize energy consumption. Fortunately, as motivated above, the number of mobile agents is often small. Thus we have a natural context for considering fixed-parameter algorithms, i.e., algorithms with running time f (k) · nO(1), where parameter k is the number of mobile agents. In this paper, we develop general efficient fixed-parameter algorithms for a broad family of movement problems. Furthermore, we show our results are tight by characterizing, in a very general setting, the line between fixed-parameter tractability and intractability. It turns out that the notion of treewidth plays an important role in defining this boundary line. Specifically we show that, for problems closed under edge addition (i.e., adding an edge to the connectivity graph cannot destroy a solution), the complexity of the problem depends solely on whether the edge-deletion minimal graphs of the property have bounded treewidth. If they all have bounded treewidth, we show how to solve a very general formulation of the problem with an efficient fixed-parameter algorithm. If they have unbounded treewidth, we show that even very simple questions are W[1]-hard, meaning there is no efficient fixed-parameter algorithm under the standard parameterized complexity assumption FPT (cid:54)= W[1]. (This assumption is the parameterized analog of P (cid:54)= NP: it is stronger than P (cid:54)= NP, but weaker than the Exponential Time Hypothesis.) Our framework for movement problems is very general, and sometimes this full generality is unnecessary. Thus, we begin in Section 2 with a simplified version of our framework, and describe several of its applications to specific movement problems in Section 2.1. Then, Section 3 presents the general version of our framework, 2 which allows multiple types of overlapping agents, and Section 3.1 presents many further applications of this framework to specific movement problems. Finally, Section 4 presents further improvements for specific problems and for specific graph classes such as planar graphs. The formal definition of all the concepts appear in Section 5. The results are proved in Sections 6 -- 8. 2 Simplified Results We start by presenting simplified versions of our main results, which handle only a simpler formulation of the movement problem, but are already capable of determining the complexity of several natural problems. The full model is presented in Sections 3 -- 4 and the formal definitions can be found in Section 5. A (simplified) movement problem is specified by a graph property: an (infinite) set G of desired configu- rations. Given a graph G with k agents on the vertices, the task in the movement problem is to move the agents to k distinct vertices such that the graph induced by the k agents is in G. The goal is to minimize the "cost" of the movements, such as the total number of steps the agents move, the maximum movement of an agent, or the number of agents that move at all. In fact, we define the cost of a solution to be the sum of costs of each agent's movement, where we are given a (polynomially computable) movement cost function for each agent specifying a nonnegative integer cost of moving that agent to each vertex in the graph. This definition obviously includes counting the total number of steps agents move as a special case, as well as modeling nonmetric terrains, agents of different speeds, immobile agents, regions impassable by certain agents, etc. This definition of movement cost also includes the other objectives mentioned above as special cases. To minimize the number of moved agents, we can specify a movement cost function for each agent of 0 to remain stationary and 1 to make any move. To minimize the maximum motion of an agent, we can binary search on the maximum movement cost τ , and modify the movement cost function to jump to ∞ whenever exceeding this threshold τ . Our algorithmic result for these (simplified) movement problems considers graph properties that are closed under edge addition (which holds in particular for properties that model some notion of connectivity): Theorem 2.1. If G is a decidable graph property that is closed under edge addition, and the edge-deletion minimal graphs in G have bounded treewidth, then the movement problem can be solved in time f (k) · nO(1). if the edge-deletion minimal graphs in G have We prove a matching hardness result for Theorem 2.1: unbounded treewidth, then it is hard to answer even some very simple questions. Theorem 2.2. If G is any graph property that is closed under edge addition and has unbounded treewidth, then the movement problem is W[1]-hard parameterized by k, already in the special case where each agent is allowed to move at most one step in the graph. Theorems 2.1 and 2.2 show that the algorithmic/complexity question of whether a given movement problem is FPT can be reduced to the purely combinatorial question of whether a certain set of graphs has bounded treewidth. Thus treewidth plays an essential role in the complexity of the problem, which is not apparent at first sight. As we shall see in the examples below, this connection with treewidth allows us to understand how subtle differences in the definition of the problem (e.g., connectivity vs. 2-connectivity or edge-disjoint paths vs. vertex-disjoint paths) change the complexity of the problem. Theorems 2.1 and 2.2 considered properties closed under edge addition. We prove another general result, which considers hereditary properties, i.e., properties closed under taking induced subgraphs: Theorem 2.3. Let G be a decidable hereditary property. If G does not contain all cliques or does not contain all independent sets, then the movement problem is W[1]-hard parameterized by k, already in the special case where each agent is allowed to move at most one step in the graph. 2.1 Applications of Simplified Results Theorems 2.1 -- 2.3 immediately characterize the complexity of several natural problems: 3 Example: CONNECTIVITY Move the pebbles (agents) so that they are connected and on distinct vertices. The parameter is the number k of pebbles. Now G contains all connected graphs. Clearly, G is closed under edge addition and the edge-deletion minimal graphs are trees. Trees have treewidth 1, hence by Theorem 2.1, this movement problem is fixed-parameter tractable for any movement cost function. (cid:3) Example: 2-CONNECTIVITY Move the pebbles so that they induce a 2-connected graph and the pebbles are on distinct vertices. The parameter is the number k of pebbles. Now G contains all 2-connected graphs and clearly G is closed under edge addition. The edge-deletion minimal graphs have unbounded treewidth: subdividing every edge of a clique gives an edge-deletion-minimal 2-connected graph. Thus by Theorem 2.2, it is W[1]-hard to decide whether there is a solution where each pebble moves at most one (cid:3) step. k(cid:99) × (cid:98)√ Example: GRID Move the k pebbles so that they are on distinct vertices and they form a (cid:98)√ k(cid:99) square grid. The parameter is the number k of pebbles. Let G contain all graphs containing a spanning square grid subgraph. Clearly, G is closed under edge addition and the edge-deletion minimal graphs are grids, which have arbitrarily large treewidth. Thus Theorem 2.2 implies that it is W[1]-hard, to decide (cid:3) whether there is a solution where each pebble moves at most one step. Example: MATCHING Move the pebbles so that the pebbles are on distinct vertices and there is a perfect matching in the graph induced by the pebbles. The parameter is the number of pebbles. Let G contain all graphs that have a perfect matching. The edge-deletion minimal graphs are perfect matchings, (i.e., k/2 independent edges on k vertices), so they have treewidth 1. By Theorem 2.1, the movement problem (cid:3) is FPT. Example: DISPERSION Move the pebbles to distinct vertices and such that no two pebbles are ad- jacent. The parameter is the number k of pebbles. Here G contains all independent sets. Because G is hereditary and the maximum clique size is 1, Theorem 2.3 implies that the movement problem is W[1]-hard, (cid:3) even in the case when each pebble is allowed to move at most one step. 3 Main Results In this section, we present the full generality of the problem we consider and results we obtain (note that the formal definitions are collected in Section 5). In particular, this generalization removes several limitations of the simplified version presented above, informally summarized as follows: 1. In many cases agents have different types (e.g., some of the agents are servers, some are clients, etc.). and the solution should take these types into account. 2. If, for example, the task is to provide connectivity between two specific vertices s and t, then the model should be capable of specifying these two distinguished vertices in the input. 3. Agents should be able to share vertices, i.e., we should not require that the agents move to distinct vertices. In fact, we may require that more than one agent is moved to a single vertex, e.g., if the task is to move a server to each client. 4. The graph induced by the agents might not suffice to certify that the solution is correct (e.g., if the requirement is that the agents are at distance-2 from each other). We might want to include (a bounded number of) unoccupied vertices into the solution in order to produce a witness showing that the agents have the correct configuration. 4 5. In some scenarios, agents are divided into "clients" that need to be satisfied somehow and "facilities" that are helpful for satisfying the clients but otherwise do not introduce any additional constraints to the problem. In many cases, we are able to extend the fixed-parameter tractability results such that the parameter is the number of client agents only, and thus the number of facility agents can be arbitrarily large. We introduce a similar generalization with an unbounded number of "obnoxious" agents which can interfere with clients, but otherwise do not introduce any requirements on their own. Formally, the general model we consider divides the agents into three types -- client, facility, and obnoxious agents -- and the parameter is just the number of clients, which can be much smaller than the total number of agents. The clients can require collocated or nearby facility agents, among a potentially large set of facility agents, which themselves are mobile. Intuitively, facilities provide some service needed by clients. Clients can also require at most a certain number (e.g., zero) of collocated obnoxious agents (again among a potentially large, mobile set), which can represent dangerous or undesirable resources. In other words, adding facility agents or removing obnoxious agents does not make a correct solution invalid. More generally, there can be many different subtypes of client, facility, and obnoxious agents, and we may require a particular pattern of these types. A (general) movement problem specifies a multicolored graph property: an (infinite) set G of desired configurations, each specifying a desired subgraph and how that subgraph should be populated by different types of agents (a multicolored graph). Each agent type (color) is specified as client, facility, or obnoxious, but there can be more than three types; in this way, we can specify different types of client agents that need to interact in a particular way, or need particular types of nearby facility agents. The goal of the movement problem is to move the agents into a configuration containing at most (cid:96) vertices that contain all k client agents and induce a "good" target pattern. A good target pattern is a multicolored graph that is either in the set G or it "dominates" some multicolored graph G ∈ G in the sense that it contains more facility agents and fewer obnoxious agents of each color at each vertex. To emphasize that the goal is to create a pattern containing all the client agents (which may contain only a subset of facility and obnoxious agents), we will sometimes call the client agents "main agents" and use the two terms interchangeably. for every fixed numbers k and (cid:96), there are only finitely many graphs in G with at most (cid:96) vertices and at most k client agents (as we do not bound the number of obnoxious and facility agents here, this is a nontrivial restriction). In other words, there should be only finitely many minimal ways to satisfy a bounded number of clients in a bounded subgraph. For example, the property requiring that the number of facility agents at each vertex is not less than the number of obnoxious agents at that vertex is not a regular property. Note that this restriction does not say that there is only a finite number of good configurations, it only says that there is a finite number of minimal good configurations: as mentioned in the previous paragraph, we allow configurations having any number of extra facility agents. A mild technical condition that we require is that the multicolored graph property G is regular : For a regular multicolored graph property, the corresponding movement problem is as follows: given an initial configuration (a multicolored graph), to minimize the total cost of all movement subject to reaching one of the desired target configurations in G with at most (cid:96) vertices, where both (cid:96) and the number k of client agents are parameters. As before, we are given a movement cost function for each agent, an arbitrary (polynomially computable) function specifying the nonnegative integer cost of moving that agent to each vertex in the graph. Our main algorithmic result considers properties that are closed under edge addition (for example, prop- erties that model some notion of connectivity). Besides requiring that the graph property is regular, another mild technical assumption is that two obnoxious agents of the same type behave similarly, i.e., the cost of moving them from vertex v1 to v2 has the same cost. Theorem 3.1. If G is a regular multicolored graph property that is closed under edge addition, and if the edge-deletion minimal graphs in G have bounded treewidth, then the movement problem can be solved in f (k, (cid:96)) · nO(1) time, assuming that the movement cost function is the same on any two agents of the same obnoxious type that are initially located on the same vertex. Our main algorithm (Section 6) uses several tools from fixed-parameter tractability, color coding, and graph structure theory, in particular treewidth. This combination of techniques seems interesting in its own right. 5 We prove in Section 7 a matching hardness result for Theorem 3.1: if the edge-deletion minimal graphs in G have unbounded treewidth, then it is hard to answer even some very simple questions. Thus treewidth plays an essential role in the complexity of the problem, which is not apparent at first sight. Theorem 3.2. If G is any (possibly regular) multicolored graph property that is closed under edge addition, and for every w ≥ 1, there is an edge-deletion minimal graph Gw ∈ G with treewidth at least w and at least one client agent on each vertex (but no other type of agent), then the movement problem is W[1]-hard with the combined parameter (k, (cid:96)), already in the special case where each agent is allowed to move at most one step. If a movement problem can be modeled with colored pebbles and the target patterns are closed under edge addition, then the complexity of the problem can be determined by solving the (sometimes nontriv- ial) combinatorial question of whether the minimal configurations have bounded treewidth. The minimal configurations are those pebbled graphs that are acceptable solutions, but removing any edge makes them unacceptable. As before, we also obtain a general hardness result for multicolored graph properties that are not closed under edge addition, but rather are hereditary, i.e., closed under taking induced subgraphs: Theorem 3.3. Let G be a hereditary property where each vertex has exactly one client agent and there are no other type of pebbles. If G does not contain all cliques or does not contain all independent sets, then the movement problem is W[1]-hard with the combined parameter (k, (cid:96)), already in the special case where each agent is allowed to move at most one step in the graph. The proof of Theorem 3.3 (in Section 8.6) uses a hardness result by Khot and Raman [24] on the parameterized complexity of finding induced subgraphs with hereditary properties. 3.1 Applications of Main Results Theorems 3.1 and 3.2 characterize the complexity of several additional natural problems beyond Section 2.1: Example: CONNECTIVITY (collocation allowed) The connectivity problem discussed in Sec- tion 2.1 required that all the pebbles are moved to distinct vertices. For example, moving all the pebbles to the same vertex is not a correct solution. It could be however that some applications are more faithfully expressed if we allow pebbles to share vertices. It is easy to express this variant using Theorem 3.1. Let G contain all connected graphs with at least one pebble on each vertex. Setting (cid:96) = k, it follows from (cid:3) Theorem 3.1 that this variant of the problem is FPT parameterized by k. Example: s-t CONNECTIVITY (few pebbles) Move the pebbles to form a path of pebbled vertices between fixed vertices s and t. The parameter is the number k of pebbles. Now there are two main colors of pebbles, call them red and blue, and G consists of all graphs containing exactly two red pebbles and a path between them using only vertices with blue pebbles. We reduce s-t CONNECTIVITY to this movement problem by putting red pebbles at s and t, and giving them an infinite movement cost to any other vertices. Clearly, G is closed under edge addition and the edge-deletion minimal graphs are paths. (cid:3) Paths have treewidth 1, so by Theorem 3.1, this problem is fixed-parameter tractable. In the next example, we show that a much more general version of s-t CONNECTIVITY is FPT: instead of parameterizing by the number k of pebbles, we can parameterize by the maximum length L of the path. Thus we can have arbitrarily many pebbles that might form the path, and allow the runtime to be exponential in the length of the path. Example: s-t CONNECTIVITY (bounded length) Move the pebbles to form a path of pebbled vertices of length at most L between fixed vertices s and t. The parameter is the length L. Now we define one main color of pebbles, red, and one facility color of pebbles, blue, and we define G as in the previous example. Again by Theorem 3.1, this problem is fixed-parameter tractable in the combined parameter (k, (cid:96)); (cid:3) in the example, we have k = 2 and (cid:96) = L + 1. 6 Example: STEINER CONNECTIVITY Connect the red pebbles (representing terminals) by moving the blue pebbles to form a Steiner tree. The parameter is the number of red pebbles plus the number of blue pebbles in the solution Steiner tree. This is simply a generalization of s-t CONNECTIVITY to more than two red pebbles. Again by Theorem 3.1 the problem is fixed-parameter tractable with this parameterization (the edge-deletion minimal graphs are trees), even when the number of blue pebbles is very large in the (cid:3) input. Example: s-t d-CONNECTIVITY (fixed d) Move the pebbles so that there are d vertex-disjoint paths using pebbled vertices between two fixed vertices s and t. The parameter is the total length L of the d paths in the solution. Now we use one main color, red, and one facility color, blue, and Gd consists of all graphs containing two vertices with a red pebble on each, and having d internally vertex-disjoint paths between these two vertices, with blue pebbles on each internal vertex. In the input instance, there are red pebbles on s and t, and the cost of moving them is infinite. Clearly, Gd is closed under edge addition and the edge- deletion minimal graphs are series-parallel (as they consist of d internally vertex disjoint paths connecting two vertices), which have treewidth 2. Hence, by Theorem 3.1, this movement problem is fixed-parameter tractable with respect to L, for every fixed d. Again the number of blue pebbles can be arbitrarily large. (cid:3) The previous example shows that s-t d-CONNECTIVITY is FPT for every fixed value of d, i.e., for every fixed d, there is an f (L)· nO(1) time algorithm. However, this statement does not make it clear if the degree of n depends on d or not. To show that the degree of n is independent of d and the problem can be solved in time f (L, d)· nO(1), we need to encode the number d in the input of the movement problem. We use dummy green pebbles for this purpose. Example: s-t d-CONNECTIVITY (unbounded version) Move the pebbles so that there are d vertex-disjoint paths using pebbled vertices between two fixed vertices s and t, where d is a number given in the input. The parameter is the total length L of the solution paths. First, if d is larger than the bound on the total length of the paths, then there is no solution. Otherwise, we can assume d is a fixed parameter. Now we use two main colors, red and green, and one facility color, blue. A graph G is in G if the blue pebbles form d internally vertex-disjoint paths between two vertices containing red pebbles, where d is the number of green pebbles in G. Thus we use green pebbles to "label" a graph G in G according to what level of connectivity it attains. Again G is closed under edge addition and the edge-deletion minimal graphs are series-parallel, which have treewidth 2, so by Theorem 3.1, the movement problem is fixed-parameter tractable with respect to k := 2 and (cid:96) := L. In the initial configuration, we put red pebbles on s and t with infinite movement cost, and we place d green pebbles arbitrarily in the graph. The target configuration we obtain will have exactly d green pebbles, and thus d vertex-disjoint paths, because these are main pebbles. (cid:3) We can also consider the edge-disjoint version of s-t connectivity. We need the following combinatorial lemma to characterize the minimal graphs: Lemma 3.4. Let G be a connected graph and assume that there are d edge-disjoint paths between vertices s and t in G, but for any edge e ∈ E(G), there are at most d − 1 edge-disjoint paths between s and t in G \ e. Then the treewidth of G is at most 2d + 1. Proof. Note that the size of the minimum s − t cut is exactly d. We use the folklore observation that there is a noncrossing family of minimum s − t cuts covering every minimum s − t cut. (We say that two s − t cuts C1, C2 ⊆ E(G) cross if there is a vertex v1 reachable from s in G \ C1 but not in G \ C2, and there is a vertex v2 reachable from s in G \ C2 but not in G \ C1.) The formal statement that we use is that there is a sequence {s} ⊆ X1 ⊆ X2 ⊆ ··· ⊆ Xr ⊆ V (G) \ {t} such that (1) for every 1 ≤ i ≤ t, exactly d edges go between Xi and V (G) \ Xi, and (2) if edge e appears in a minimum s − t cut, then there is an 1 ≤ i ≤ r such that e connects Xi and V (G) \ Xi. In our case, every edge appears in a minimum s − t cut, thus the edges leaving the Xi's cover every edge. Let Yi be the endpoints of the edges connecting Xi and V (G) \ Xi. Let T be a tree that is a path with nodes v1, . . . , vr and let us define Bi := Yi ∪ {s, t}; clearly Bi ≤ 2d + 2. We claim that (T, Bi) is a tree decomposition of width 2d + 1. From our discussion above, it is clear that every edge appears in one of the 7 bags. To see the connectedness property, suppose that v ∈ Bi and v (cid:54)∈ Bj for some j > i. We need to show that v (cid:54)∈ Bj(cid:48) for any j(cid:48) > j. As v ∈ Bj, vertex v is the endpoint of an edge leaving Xi. Thus either v ∈ Xi or v is adjacent to a vertex of Xi. In both cases, we have v ∈ Xj: in the first case, this follows from Xi ⊆ Xj; in the second case, v (cid:54)∈ Xj would mean that the edge connecting v with Xi does not leave Xj, which is only possible if this edge is contained in Xj. Thus v ∈ Xj and v has no neighbor outside Xj(cid:48), hence Xj ⊆ Xj(cid:48) implies that v is in Xj(cid:48) as well and has no neighbor outside Xj(cid:48), that is, v (cid:54)∈ Xj(cid:48). Example: s-t d-EDGE-CONNECTIVITY (fixed d) Move the pebbles so that there are d edge- disjoint paths of pebbled vertices between s and t. The parameter is the total length L of the paths. Now we use one main color, red, and one facility color, blue, and Gd contains all graphs containing two vertices with a red pebble on each and having d edge-disjoint paths between these two vertices, with blue pebbles on each path vertex. By Lemma 3.4, the edge-deletion minimal graphs have treewidth O(d). Hence, by (cid:3) Theorem 3.1, the movement problem is fixed-parameter tractable with respect to L. The previous example shows that s-t d-EDGE-CONNECTIVITY is FPT parameterized by L for every fixed value of d. As in the vertex-disjoint, we can ask if the problem is FPT if d is part of the input and the parameters are L and d. Somewhat surprisingly, unlike the vertex-disjoint case, the problem becomes hard: Example: s-t d-EDGE-CONNECTIVITY (unbounded version) Move the pebbles so that there are d edge-disjoint paths of pebbled vertices between s and t, where d is a number given in the input. We use three main colors: red, green, and blue. A graph G is in G if the blue pebbles form d edge-disjoint paths between two vertices containing red pebbles, where d is the number of green pebbles in G. We show that G contains edge-deletion minimal graphs of arbitrary large treewidth, so by Theorem 3.2, it is W[1]-hard to decide whether there is a solution where each of the k pebbles move at most one step each. Assume d is even and let G be a graph consisting of vertices s, t, and d vertex-disjoint s − t paths of length d + 2 such that vertices vi,0, . . . , vi,d+1 are the internal vertices of the ith path. Now for every odd i and odd 1 ≤ j < d, let us identify vertices vi,j and vi+1,j, and for every even i < d and even 1 < j ≤ d, let us identify vi,j and vi+1,j (see Figure 1). There are d edge-disjoint s-t paths in this graph, but there are at most d − 1 such paths after the deletion of every edge. (It is easy to see that every edge is in an s-t cut of exactly d edges.) Thus G is an edge-deletion minimal member of G. Furthermore, the graph contains a d/2 × d/2 grid, so the (cid:3) treewidth is Ω(d). Example: FACILITY LOCATION (collocation version) Move client and facility agents so that each client agent is collocated with at least one facility agent and the client agents are at distinct locations. The parameter is the number of client agents. We use one main color, red, for the clients, and one facility color, blue, for the facilities, and G contains all graphs in which every vertex contains exactly one red and one blue pebble. The edge-deletion minimal graphs in G have no edges, so have treewidth 0. By Theorem 3.1, the movement problem is fixed-parameter tractable parameterized by the number of main pebbles, i.e., the number of client agents. The number of facilities can be unbounded, which is useful, e.g., to organize a small (cid:3) team within a large infrastructure of wired network hubs or mobile satellites. Example: FACILITY LOCATION (distance-d version) Move client and facility agents so that each client agent is within distance at most d from at least one facility pebble and the client agents are at distinct locations. Now we use two main colors, red and green, and one facility color, blue. Let G contain all graphs that contain some number d of green pebbles and each red pebble is at distance at most d from some blue pebble. Given a graph with k main (red) pebbles and some number of facility (blue) pebbles, we add d dummy green pebbles and ask whether there is a solution on (cid:96) := k(d + 1) + d vertices. If we move the pebbles so that each red pebble is at distance d from some blue pebble, then there are k(d + 1) + d vertices that contain all d of the green pebbles and induce a graph that belongs to G (such a set can be obtained by taking all the red and green pebbles and selecting, for each red pebble, a path of at most d additional vertices that connect it to a blue pebble). We claim that the edge-deletion minimal graphs in G are forests, and hence have treewidth 1. Consider an edge-deletion minimal graph G ∈ G, and for each vertex v without a blue pebble, select an edge uv that goes to a neighbor u that is closer to some blue pebble than v. If 8 v1,0 v1,1 = v2,1 v1,2 v1,3 = v2,3 v1,4 v1,5 = v2,5 v1,6 s t v10,0 v10,1 = v9,1 v10,2 v10,3 = v9,3 v10,4 v10,5 = v9,5 v10,6 Figure 1: The graph G for d = 5 in the discussion of s-t d-EDGE-CONNECTIVITY (unbounded version). an edge is not selected in this process, then it can be removed (it does not change the distance to the blue pebbles), so by the minimality of G, every edge is selected. Each connected component contains at least one blue pebble. This means that, in each connected component, the number of selected edges is strictly smaller than the number of vertices, i.e., each component is a tree. Thus, by Theorem 3.1, the movement problem (cid:3) is FPT. On the other hand, FACILITY LOCATION becomes W[2]-hard if the parameter is the number of facil- ities, while the number of clients can be unbounded (Theorem 3.5 below). This result cannot be obtained using the general result of Theorem 3.2 because in this statement the parameter is the number of facility pebbles. However, it is not difficult to give a problem-specific hardness proof for this variant. Theorem 3.5. For every fixed d ≥ 0, FACILITY LOCATION (distance d version) is W[2]-hard parame- terized by the number of facilities, even if each pebble is allowed to move at most one step in the graph. Proof. To show that the problem is W[2]-hard, we show a reduction from MINIMUM DOMINATING SET (recall that a set S ⊆ V (G) is a dominating set of G if every vertex of G is either in S or adjacent to a vertex in S). Given a graph G and an integer k, we construct an instance of FACILITY LOCATION with k facility pebbles which can be solved by moving each pebble at most one step if and only if G has a dominating set of size k. Let v1, . . . , vn be the vertices of G. We construct a graph F as follows. We start with vertices s, b1, . . . , bn, c1, . . . , cn, where s is connected to every bi. If vi and vj are neighbors in G, then bi and cj are connected with a path having d internal vertices. We place k facility pebbles on s and one main pebble on each ci. If G has a dominating set vi1 , . . . , vik , then we move the k facility pebbles to bi1, . . . , bik , and if vertex vj of G is dominated by its neighbor vi(cid:96), then we move the main pebble at cj one step closer to bi(cid:96) . It is clear that each main pebble will be at distance exactly d from some facility pebble. The other direction is also easy to see: if the facility pebbles move to vertices bi1, . . . , bik , then vertices vi1 , . . . , vik form a dominating set in G. We remark that the fixed-parameter tractability of facility location problems has been investigated in [15]. The model studied there is somewhat different from the one studied here, but [15, Theorem 6] gives 9 a very similar simple reduction from (essentially) DOMINATING SET to facility location parameterized by the number of facilities. Example: SEPARATION Move client agents (say, representing population) and/or obnoxious agents (say, representing power plants) so that each client agent is collocated with at most o obnoxious pebbles. The parameter is the number of client agents. Here G contains all graphs with the desired bounds, so the edge-deletion minimal graphs have no edges, which have treewidth 0. By Theorem 3.1, the movement problem is fixed-parameter tractable. As in previous examples, we can make o an input to the problem. (cid:3) 4 Further Results In addition to our general classification and specific examples, we present many additional fixed-parameter results. These results capture situations where the general classification cannot be applied directly, or the general results apply but problem-specific approaches enable more efficient algorithms. Specifically, we consider situations where the graphs are more specific (e.g., almost planar), the property is not closed under edge addition, or the number of client agents is not bounded. Our aim is to demonstrate that there are many problem variants that can be explored and that there is a vast array of algorithmic techniques that become relevant when studying movement problems. In particular, results from algorithmic graph minor theory (Section 8.1), Courcelle's Theorem (Section 8.2), bidimensionality (Section 8.2), the fast set convolution algorithm of Bjorklund et al. (Section 8.3), and Canny's Roadmap Algorithm (Section 8.4) all find uses in this framework. 4.1 Planar Graphs and H-Minor-Free Graphs Our general characterization makes no assumptions on the connectivity structure: it is an arbitrary graph. However, significantly stronger results can be achieved if we have some restriction on the connectivity graph. For example, many road networks, fiber networks, and building floorplans can be accurately represented by planar graphs. We show that, for planar graphs, the fixed-parameter algorithms of Theorem 3.1 work even if we remove the requirement that G is closed under edge addition. That is, we can express for example that the pebbles induce an independent set. In many cases, approximation and fixed-parameter tractability results for planar graphs generalize to arbitrary surfaces, to graphs of bounded local treewidth, and to H-minor-free graph classes. These general- izations are made possible by the algorithmic consequences of the Graph Minor Theorem [10]; see Section 8.1. To obtain maximum generality, we state the result on planar graphs generalized to arbitrary H-minor-free classes: Theorem 4.1. If G is a regular multicolored graph property, then for every fixed graph H, the movement problem can be solved on H-minor-free graphs in f (k, (cid:96)) · nO(1) time, assuming that the movement cost function is the same on any two agents of the same obnoxious type that are initially located on the same vertex. We stress that in Theorem 4.1, unlike in Theorem 3.1, the property G is not required to be closed under edge addition. One possible application scenario where these generalizations of planar graphs play a role is the following. The terrain is a multi-level building, where the connectivity graph is planar on each level, and there are at most d connections between two adjacent levels (for some fixed d ≥ 4). It is easy to see that the graph is Kd+1-free: a Kd+1 minor would be contained on one level. Thus, for every fixed value of d, Theorem 4.1 applies for such connectivity graphs. We also consider two specific problems in the context of planar graphs. 4.2 Bidimensionality In Section 8.2, we show that bidimensionality theory can be exploited to obtain algorithms for movement problems on planar graphs. In particular, we show that the version of DISPERSION (see Section 2.1) where each pebble can move at most one step admits a subexponential parameterized algorithm. The proof uses 10 a combination of bidimensionality theory, parameter-treewidth bounds, grid-minor theorems, Courcelle's Theorem, and monadic second-order logic. 4.3 Planar STEINER CONNECTIVITY In the STEINER CONNECTIVITY problem (see Section 3.1), the goal is to connect one type of agents ("terminals") using another type of agents ("connectors"). Our general characterization shows that this problem is fixed-parameter tractable if the numbers of both types of agents are bounded, while it becomes W[1]-hard if only the number of connector agents is bounded and the number of terminal pebbles is un- bounded. On the other hand, we show that this version of the problem is fixed-parameter tractable for planar graphs, using problem-specific techniques; see Section 8.3. 4.4 Geometric Graphs In some of the applications, the environment can be naturally modeled by the infinite geometric graph defined by Euclidean space, where vertices correspond to points and edges connect two vertices that are within a fixed distance of each other, say 1. In this case, we develop efficient algorithms in a very general setting in Section 8.4, even though the graph is infinite: Theorem 4.2. If G is any regular graph property, then given rational starting coordinates for k total agents (including facility and obnoxious agents) in Euclidean d-space, we can find a solution to the movement problem up to additive error ε > 0 using f (k, d) · nO(1)(lg D + lg(1/ε)) time, where D is the maximum distance between any two starting coordinates. The main tool for proving this theorem is Canny's Roadmap Algorithm for motion planning in Euclidean space [5], which lets us manipulate bounded-size semi-algebraic sets; see Section 8.4. 4.5 Improving CONNECTIVITY with Fast Subset Convolution Finally, we optimize one particularly practical problem, CONNECTIVITY: moving the agents so that they form a connected subgraph. Our general characterization implies that this problem is fixed-parameter tractable. Using the recent algorithm of Bjorklund et al. [3] for fast subset convolution in the min-sum semiring, in Section 8.5 we design a more efficient algorithm for this problem: the exponential factor of the running time is only O(2k). In summary, our results form a systematic study of the movement problem, using powerful tools to classify the complexity of the different variants. Our algorithms are general, so may not be optimal for any specific version of the problem, but they nonetheless characterize which problems are tractable, and lead the way for future investigation into more efficient algorithms for practical special cases. 5 Model and Definitions In this section, we make precise the model described in Section 1 and introduce some additional notation. Definition 5.1. We fix three finite sets of colors: Cm (main colors), Cf (facility colors), Co (obnoxious colors). Pebbles with main colors will represent the client agents: the target pattern has to contain all such pebbles. Pebbles with facility colors are "good": having more than the prescribed number of such pebbles is still an acceptable solution. Conversely, pebbles with obnoxious colors are "bad": removing such a pebble from a target pattern does not make a solution invalid. Definition 5.2. A multicolored graph is a graph with a multiset of colored pebbles assigned to each vertex (a vertex can be assigned multiple pebbles with the same color). We extend the notions of vertex removal, edge removal, edge addition, and induced subgraphs to multi- colored graphs the obvious way, i.e., the set pebbles at the vertices (remaining in the graph) is unchanged. 11 Definition 5.3. • We denote by nG(c, v) the number of pebbles with color c at vertex v in G. • A multicolored graph property is a (possibly infinite) recursively enumerable set G of multicolored graphs. • A graph property G is regular if for every fixed k, (cid:96) there is only a finite number of graphs in G with at most (cid:96) vertices and at most k main pebbles and there is an algorithm that, given k and (cid:96), enumerates these graphs. (Note that the number of facility and obnoxious pebbles is not bounded here.) • A graph property G is hereditary if, for every G ∈ G, every induced multicolored subgraph of G is also in G. • A graph property G is closed under edge addition if whenever G is in G and G(cid:48) is the multicolored graph obtained from G by connecting two nonadjacent vertices, then G(cid:48) is also in G. • A graph G ∈ G is edge-deletion minimal if there is no multicolored graph G(cid:48) ∈ G that can obtained from G by edge deletions. Definition 5.4. Let G1 and G2 be two multicolored graphs whose underlying graphs are isomorphic. G2 dominates G1 if there is an isomorphism φ : V (G1) → V (G2) such that, for every v ∈ V (G1), 1. for every c ∈ Cm, vertices v and φ(v) have the same number of pebbles with color c; 2. for every c ∈ Cf , vertex φ(v) has at least as many pebbles with color c as v; and 3. for every c ∈ Co, vertex φ(v) has at most as many pebbles with color c as vertex v. Definition 5.5. For every set G of multicolored graphs, the movement problem has the following inputs: 1. a multicolored graph G(V, E), P is the set of pebbles, k is the number of main pebbles; 2. a movement cost function cp : V → Z + for each pebble p ∈ P ; 3. integer (cid:96), the maximum solution size; and 4. integer C, the maximum cost. The task is to find a movement plan m : P → V such that 1. the total cost(cid:80) p∈P cp(m(p)) of the moves is at most C; and 2. after the movements, there is a set S of at most (cid:96) vertices such that S contains all the main pebbles and the multicolored graph G[S] dominates some graph in G. By using different movement cost functions, we can express various goals: 1. if cp(v) is the distance of p from v, then we have to minimize the sum of movements, 2. if cp(v) = 0 if v is at distance at most d from p and ∞ otherwise, then we have to find a solution where p moves at most d steps, 3. if cp(v) = 0 if v is the initial location of p and cp(v) = 1 for every other vertex, then we have to minimize the number of pebbles that move. Of course, we can express combinations of these goals or the distance can be measured on different graphs for the different pebbles, etc. The formulation is very flexible. 12 6 Main Algorithm In this section, we present our main algorithm, i.e., the proof of Theorem 3.1. The algorithm is based on enumerating minimal configurations, nontrivially using the color-coding technique to narrow the possibilities. Then it finds the best possible location in the graph to realize each minimal configuration. By assumption, the minimal configurations have bounded treewidth and, as the following classical result shows, finding such subgraphs is FPT (see also [28]): Theorem 6.1 ([1]). Let F be an undirected graph on k vertices with treewidth t. Let G be an undirected graph with n vertices. A subgraph of G isomorphic to F , if one exists, can be found in time 2O(k) · nO(t). of φ to be c(φ) :=(cid:80) However, we need a weighted version of this result in order to express the movement costs. A subgraph embedding of F in G is a mapping φ : V (F ) → V (G) such that if u, v ∈ V (F ) are adjacent in F , then φ(u) and φ(v) are adjacent in G. Let c : V (F ) × V (G) → Z+ be a cost function that determines the cost of mapping a vertex of F to a vertex of G. If φ is a subgraph embedding of F into G, then we define the cost v∈V (F ) c(v, φ(v)). Note that c(v1, u) is not necessarily equal to c(v2, u), thus the cost of mapping two different vertices v1 and v2 of F to a particular vertex u of G can have different costs. By extending the techniques of Theorem 6.1, we can find a subgraph embedding of minimum cost. Theorem 6.2. Let F be an undirected graph on k vertices with treewidth t. Let G be an undirected graph with n vertices and let c : V (F ) × V (G) → Z+ be a cost function of mapping a vertex of F to a vertex of G. If F is a subgraph of G, then it is possible to find in time 2O(k)· nO(t) a subgraph embedding φ that minimizes c(φ). describes how the pebbles are moved. The objective is to minimize the total cost (cid:80) to express this cost cmin(φ) as a linear function of the mapping, i.e, as cmin(φ) =(cid:80) Similarly to Theorem 6.1, the proof of Theorem 6.2 is based on dynamic programming on the tree decomposition of F . However, here we have to maintain minimum-cost solutions instead of feasibility. This modification of the proof is quite straightforward, but as the proof in [1] is rather sketchy, we give a full proof in the Appendix for completeness. Proof (of Theorem 3.1). In the solution, the set S ⊆ V (G) has to induce a graph F that dominates some graph F (cid:48) ∈ G. The graph F (cid:48) has a subgraph F0 that is an edge-deletion minimal graph of G. Let Gk,(cid:96) be the set of edge-deletion minimal graphs in G with at most (cid:96) vertices and exactly k main pebbles. Since G is regular, Gk,(cid:96) is finite and we can enumerate the graphs in Gk,(cid:96) in time depending only on k and (cid:96). Let us denote by Dk,(cid:96) the maximum number of pebbles in a graph of Gk,(cid:96). For each F0 ∈ Gk,(cid:96), we test whether there is a solution with this particular F0. For a given F0, we proceed as follows. Let v1, . . . , v(cid:96)0 be the vertices of F0 (note that (cid:96)0 ≤ (cid:96)). A solution consists of two parts: a subgraph embedding of F0 into G and a way of moving the pebbles. Formally, a solution is a pair (φ, m) where φ : V (F0) → V (G) is a subgraph embedding of F0 in G and m : P → V (G) p∈P cp(m(p)) of the movements. For a given embedding φ, there might be several possible movement plans m such that (φ, m) is a solution, i.e., the vertices in φ(V (F0)) have the appropriate pebbles after the movements of m. Thus for each embedding φ, there is a minimal cost cmin(φ) of a movement plan that forms a solution together with φ. Therefore, we have to find an embedding φ such that cmin(φ) is minimal. The main idea of the proof is to try v∈V (F ) c(v, φ(v)) for some appropriate function c. If we can do that, then Theorem 6.2 can be invoked to find the embedding φ with the smallest cmin(φ). However, it seems unlikely that the cost of the best way of moving the pebbles can be expressed as a simple linear function of the embedding. If the embedding φ is fixed, finding the best movement plan involves making non-independent decisions about which pebble goes where, hence cmin(φ) seems to be a very nonlinear function. What we do instead is to make some guesses about the internal structure of the solution, and construct a linear cost function that is correct for solutions with such structure. Let L be a random labeling that assigns labels from {1, . . . , (cid:96)} to the main and facility pebbles, and labels from {0, 1, . . . , (cid:96)} to the vertices of G. We say that a solution (φ, m) is L-good if (R1) for 1 ≤ i ≤ (cid:96)0, vertex φ(vi) has label i; (R2) if m(p) = φ(vi) for a main pebble p, then p has label i; 13 (R3) there are at least nF0 (vi, c) facility pebbles p having label i such that m(p) = φ(vi); and (R4) for every 1 ≤ i ≤ (cid:96)0, if p is an obnoxious pebble initially located at φ(vi), then either m(p) = φ(vj) for some 1 ≤ j ≤ (cid:96)0, or m(p) is a vertex with label 0. We show that restricting our attention to L-good solutions is not a serious restriction, as we can bound from below the probability that a fixed solution is L-good with respect to a random labeling: Lemma 6.3. Let (φ, m) be an optimum solution that moves the minimum number of pebbles. Solution (φ, m) is L-good with respect to a random labeling L with positive probability depending only on k, (cid:96), and C0. Proof. Requirement (R1) holds with probability ((cid:96) + 1)−(cid:96)0 . There are at most Dk,(cid:96) facility pebbles in F0, thus there are no reason to move more than Dk,(cid:96) facility pebbles. Requirements (R2) and (R3) prescribe specific labels on at most Dk,(cid:96) pebbles. Finally, observe that if p1, p2 are two pebbles with color c ∈ Co initially located at φ(vi) and m(p1), m(p2) (cid:54)∈ φ(V (F0)), then it can be assumed that m(p1) = m(p2) (here we use that the movement cost functions of p1 and p2 are assumed to be the same, hence if both pebbles are moved outside φ(V (F0)), then we can move them to the same vertex). Thus it can be assumed that there are at most (cid:96)0Co vertices outside φ(V (F0)) where obnoxious pebbles are moved to, i.e., (R4) requires label 0 on at most (cid:96)0Co vertices. Since the requirements are independent, a random labeling satisfies all of them with positive probability. Let us fix a subgraph embedding φ : V (F0) → V (G) and let us intuitively discuss what is the cost of moving the pebbles in an L-good solution (φ, m). The cost comes from three parts: moving the main, the facility, and the obnoxious pebbles. • Main pebbles. As φ is L-good, every main pebble with label i should go to φ(vi). This means that φ determines the cost of moving the main pebbles. • Facility pebbles. For every color c, we have to ensure that at least nF0(vi, c) facility pebbles with color c and label i are moved to φ(vi) (including the possibility that some of them were already there and stay there). It is clear that we can always do this the cheapest possible way, i.e., by selecting those nF0 (vi, c) pebbles with color c and label i whose cost of moving to φ(vi) is minimum possible. In particular, no conflict arises between moving vertices to φ(vi) and to φ(vj), as they involve only vertices with label i and j, respectively. • Obnoxious pebbles. We have to ensure that at most nF0(vi, c) obnoxious pebbles of color c remains at φ(vi) after the movement. The rest should be moved somewhere else, preferably not to any other φ(vj). If the cheapest way of moving an obnoxious pebble away from φ(vi) is outside φ(V (F0)), then we should definitely move the pebbles there. However, it could be possible that the cheapest place is inside φ(V (F0)) and therefore in an optimum solution we cannot avoid moving an obnoxious pebble from φ(vi) to some φ(vj). To account for these movements, we guess the exact way the obnoxious pebbles move inside φ(V (F0)). For every 1 ≤ i, j ≤ (cid:96)0 and c ∈ Co, denote by ec,i,j the number of pebbles with color c that is moved from φ(vi) to φ(vj) (in particular, ec,i,i is the number of pebbles 2Co numbers will be called the scheme of with color c that stay at φ(vi)). The tuple E of these (cid:96)0 2Co the solution. Observe that ec,i,j ≤ Dk,(cid:96), thus there are D(cid:96)0 possible schemes, which is a constant depending only on k, (cid:96), and the property G. We say that a scheme is correct if for every c ∈ Co and i=1 ec,i,j ≤ nF0 (c, vj), i.e., the scheme does not move more obnoxious pebbles to a vertex vj than it is allowed there. It is clear that the scheme of a solution is always correct. The embedding φ and the scheme of the solution determines the way the obnoxious pebbles are moved: ec,i,j tells us how many pebbles of color c have to be moved from φ(vi) to φ(vj) and the remaining pebbles should be moved to the closest vertex with label 0. Furthermore, if an obnoxious pebble is outside φ(V (F0)) initially, then there is no reason to move it. 1 ≤ j ≤ (cid:96)0, the sum(cid:80)(cid:96)0 k,(cid:96) As mentioned earlier, we cannot make cmin(φ) a linear function. However, we can make it a linear function for L-good embeddings with respect to a particular labeling L and scheme E, in the following sense: Claim 6.4. Let L be a labeling and E be a correct scheme. It is possible to define an embedding function c(vi, u) with the following properties: 14 (P1) If (φ, m) is an L-good solution with the scheme E, then c(φ) is at most the cost of (φ, m). (P2) If F0 has an embedding φ(cid:48) into G, then there is a (not necessarily L-good) solution (φ(cid:48), m) with cost at most c(φ(cid:48)). Proof. The embedding cost c(vi, u) of mapping vi ∈ V (F0) to u ∈ V (G) is defined to be the sum of 3 terms: 1. The total cost c1(vi, u) of moving all the main pebbles with label i to u. 2. The total cost c2(vi, u) of moving, for every color c ∈ Cf , nF0(vi, c) facility pebbles with label i to u. If there are more than nF0(vi, c) such facility pebbles, then we move those whose movement cost to u is minimal. If there are less than nF0 (vi, c) such facility pebbles, then we make the cost infinite. 3. The total cost c3(vi, u) of moving away the obnoxious pebbles from u, according to the scheme. For a color c ∈ Co, let t(c, u, j) be the minimum cost of moving a pebble with color c from u to a vertex with label j. The total cost of removing the required number of obnoxious pebbles from u is nG(u, c) − nF0(vi, c) − (cid:96)0(cid:88)  t(c, u, 0)  . ec,i,j  (cid:96)0(cid:88) (cid:88) c∈Co c3(vi, u) = ec,i,j · t(c, u, j) + j=1 j=1 Additionally, if u is a vertex with label different from i, then we make the cost c(vi, u) infinite. It is straightforward to see that (P1) holds: the three components of c(φ) are covered by the cost of moving the pebbles. The cost of moving a main or facility pebble contributes to the embedding cost of the vertex where it arrives, while the cost of moving an obnoxious vertex contributes to the embedding cost of the vertex where it was initially. To see that (P2) holds, let φ(cid:48) be an embedding of F0 into G with cost c(φ(cid:48)). We construct a solution with cost at most c(φ(cid:48)) where φ(cid:48)(V (F0)) induces a multicolored graph that has a subgraph dominating F0. First we move every main pebble with label i to vertex φ(cid:48)(vi). The cost of this is covered by the first component of the cost function. Next for every c ∈ Cf and 1 ≤ i ≤ (cid:96)0, we move nF0 (vi, c) pebbles with color c and label i to φ(cid:48)(vi). Note that there are at least nF0(vi, c) such pebbles: otherwise the cost would be infinite by our definition. If there are more than nF0 (vi, c) such pebbles, then we move those pebbles whose cost of moving (cid:80)(cid:96)0 to vi is minimal. The total cost of this is covered by the second component of c(φ(cid:48)). Finally, we move the obnoxious pebbles according to the scheme. For each c ∈ Co and 1 ≤ i ≤ (cid:96)0, we j=1 ec,i,j · t(c, φ(cid:48)(vi), j) when moving the pebbles initially located at φ(cid:48)(vi). After that, for each c ∈ C0, we have to move from φ(cid:48)(vi) some of the remaining pebbles with color c to ensure that only nF0(vi, c) such pebbles with color c remain at φ(cid:48)(vi). We move these pebbles to the closest vertex having label 0, thus the total j=1 ec,i,j)t(c, φ(cid:48)(vi), 0)). Clearly, the third component of the cost covers the cost of these moves. As vertex φ(cid:48)(vi) is a vertex with label i (otherwise j=1 ec,j,i pebbles with color c that goes to φ(cid:48)(vi), which is at move ec,i,j of the pebbles at φ(cid:48)(vi) to a vertex with label j. This incurs a total cost of(cid:80) cost of these movements is (cid:80) c(vi, u) would be infinite), there are at most(cid:80)(cid:96)0 (nG(φ(cid:48)(vi), c) − nF0 (vi, c) −(cid:80)(cid:96)0 c∈Co c∈Co most nF0(vi, v) since the scheme is correct. Note that the solution (φ(cid:48), m) is not necessarily L-good and does not necessarily respect the scheme E. However, we eventually do not care about internal properties of the solution other than the cost. Observe that the only reason why (φ(cid:48), m) is not L-good is that obnoxious pebbles can be moved to a vertex of label i different from φ(vi), but this just means that fewer obnoxious pebbles are moved to φ(vi) than expected. In summary, the algorithm performs the following steps: 1. Try every F0 ∈ Gk,(cid:96) and try every correct scheme E. 2. Take a random labeling L of the pebbles and the vertices. 3. Based on F0, the scheme E, and the labeling, construct the embedding cost function c(vi, u) defined by Claim 6.4. 4. Using Theorem 6.2, find the minimum cost subgraph embedding φ with this cost function. 15 5. Construct the solution (φ, m) defined by (P2) of Claim 6.4. We claim that the above algorithm finds an optimum solution with positive probability depending only on k, (cid:96), G, thus by repeating the algorithm f (k, (cid:96),G) times, the error probability can be made arbitrarily small. (The algorithm can be derandomized by using k-perfect families of hash functions instead of the random labeling [1], [16, Section 13.3]; we omit the details.) Let (φ, m) be an optimum solution with cost OPT and let F0 ∈ Gk,(cid:96) be the edge-deletion minimal graph of G corresponding to the solution. At some point, the algorithm considers this particular F0 and the scheme E of this solution. In Step 2, with constant probability, this particular solution (φ, m) is L-good (as discussed above). Thus, by (P1) of Claim 6.4, the embedding cost of φ is at most OPT. This means that in Step 5, we find an embedding with cost at most OPT, and in Step 6, by (P2) of Claim 6.4, we find a solution with cost at most OPT. The number of possibilities tried in Step 1 is a constant depending only on k and (cid:96). The application of Theorem 6.2 in Step 5 takes time f ((cid:96))nO(w), where w is the maximum treewidth of an edge-deletion minimal graph in G, which is a constant depending only on G (and not on k and (cid:96)). Every other step is polynomial. Thus the running time is f (k, (cid:96)) · nO(1) for a fixed G. 7 Main Hardness Proof In this section, we prove the main hardness result, Theorem 3.2. The proof uses a result on the structural complexity of constraint satisfaction problems. An instance of a constraint satisfaction problem is a triple (V, D, C), where 1. V is a set of variables, 2. D is a domain of values, 3. C is a set of constraints, {c1, c2, . . . , cq}. Each constraint ci ∈ C is a pair (cid:104)si, Ri(cid:105), where (a) si is a tuple of variables of length mi, called the constraint scope, and (b) Ri is an mi-ary relation over D, called the constraint relation. For each constraint (cid:104)si, Ri(cid:105) the tuples of Ri indicate the allowed combinations of simultaneous values for the variables in si. The length mi of the tuple si is called the arity of the constraint. A solution to a constraint satisfaction problem instance is a function f from the set of variables V to the domain of values D such that for each constraint (cid:104)si, Ri(cid:105) with si = (cid:104)vi1 , vi2, . . . , vmi(cid:105), the tuple (cid:104)f (vi1), f (vi2 ), . . . , f (vmi)(cid:105) is a member of Ri. We say that an instance is binary if each constraint relation is binary, i.e., mi = 2 for each constraint. The primal graph of a binary constraint satisfaction instance is a graph where the vertices are the variables and the edges are the constraints. Given a class G of graphs, we denote by BINARY-CSP(G) the restriction of binary CSP to instances whose primal graph is in G. It is well-known that if G has bounded treewidth, then BINARY-CSP(G) is polynomial-time solvable [17]. The converse is also true: Theorem 7.1 (Grohe [19]). If G is a recursively enumerable class of graphs with unbounded treewidth, then BINARY-CSP(G) parameterized by the number of variables is W[1]-hard. We prove Theorem 3.2 using Theorem 7.1. Proof (of Theorem 3.2). Let G0 contain the underlying graphs (i.e., disregarding pebbles) of all the multi- colored graphs Gw (w ≥ 1) defined in the statement of the theorem. It is easy to see that G0 is recursively enumerable. By assumption, G0 has unbounded treewidth, hence BINARY-CSP(G0) is W[1]-hard by Theo- rem 7.1. We present a reduction from BINARY-CSP(G0) to the movement problem. Consider an instance of BINARY-CSP(G0) with primal graph F0 ∈ G0. Let x1, . . . , x(cid:96) be the variables of F0 and let {1, 2, . . . , m} be the domain D. By the definition of G0, there is an edge-deletion minimal multicolored graph F ∈ G whose underlying graph is F0; let u1, . . . , u(cid:96) be the vertices of F . (Since G is recursively enumerable, such an F can be found in time depending only on the size of F0.) Let p1, . . . , pk be the pebbles in F (by assumption, all these pebbles are main pebbles); assume that pebble pi is on vertex uti. We construct a graph G as follows. Graph G has D(cid:96) + k vertices: vi,j for 1 ≤ i ≤ (cid:96) and 1 ≤ j ≤ m 16 and vi2,di2 and qi for 1 ≤ i ≤ k. If pebble pi is on vertex uti in the graph F , then vertex qi of G is connected to every vertex vti,j with 1 ≤ j ≤ m. For each binary constraint (cid:104)(xi1, xi2), R(cid:105), we add edges as follows: for every pair (di1 , di2) ∈ R, we connect the vertices vi1,di1 . To complete the description of the instance, we put the pebble pi on qi for every i, 1 ≤ i ≤ k. We claim that the CSP instance has a solution if and only if there is a solution for the movement problem on at most (cid:96) vertices such that each pebble moves at most one step. Assume that f : V → D is a solution for the CSP instance. For every 1 ≤ i ≤ k, we move pebble pi from qi to vti,f (xti ). We show that the pebbles induce a multicolored graph isomorphic to F . First, observe that all the pebbles are on the (cid:96) vertices v1,f (x1), . . . , v(cid:96),f (x(cid:96)) and vi,f (xi) has the same number and types of pebbles as ui in F . If ui1 and ui2 are connected in F , then there is a binary constraint (cid:104)(xi1 , xi2), R(cid:105) in the CSP instance. As f is a solution, we have (f (xi1 ), f (xi2)) ∈ R and hence there is an edge connecting vi1,f (xi1 ) and vi2,f (xi2 ). On the other hand, if ui1 and ui2 are not adjacent in the primal graph, then there is no edge connecting any vi1,j1 with any vi2,j2. Conversely, we show that if there is a solution for the movement problem, then there is a solution f for the CSP instance. Each pebble can move only one step, thus pebble pi either stays at qi or goes to vti,j for some 1 ≤ j ≤ m. Therefore, at least (cid:96) vertices contain pebbles after the moves. We assumed that the solution is on at most (cid:96) vertices, hence for every 1 ≤ i ≤ (cid:96), there is at most one 1 ≤ j ≤ m such that there is a pebble on vi,j. Define f (xi) to be this value j, or define f (xi) arbitrarily if there is no such j (i.e., all the pebbles adjacent to vi,1, . . . , vi,D remained at their initial location). Observe that if two pebbles in G are collocated after the moves, then they are collocated in F as well. Therefore, the pebbles occupy at least V (F ) = (cid:96) vertices. However, we know that in the solution the pebbles occupy exactly (cid:96) vertices, which is only possible if whenever two pebbles are collocated in F , then they are collocated in the solution. If pebbles pi1 and pi2 are not neighbors in F , then they cannot be neighbors after the moves, since in that case there is no edge connecting any vti1 ,j1 with any vti2 ,j2 . Thus the graph induced by the pebbles is a subgraph of F . However, as F is an edge-deletion minimal graph of G, this is only possible if the pebbles induce the graph F itself. This means that for every edge vi1vi2 of F , vertices vi1,f (xi1 ) and vi2,f (xi2 ) have to be neighbors. By the way the graph was defined, this is only possible if (f (xi1 ), f (xi2)) ∈ R, that is, f satisfies the constraint. 8 Further Techniques In this section, we prove the various results described in Section 4, as well as the hardness result for hereditary problems described in Sections 2 and 3. 8.1 Planar Graphs and H-Minor-Free Graphs To prove Theorem 4.1, we need a version of Theorem 6.2 that finds a minimum cost induced subgraph embedding, i.e., a mapping φ : V (F ) → V (G) such that φ(v1)φ(v2) is an edge of G if and only if v1v2 is an edge of F . First, the minimum cost induced subgraph embedding can be found in linear time if G has bounded treewidth: Theorem 8.1. Let F be an undirected graph on k vertices, let G be an undirected graph with treewidth w, and let c : V (F ) × V (G) → Z+ be a cost function of mapping a vertex of F to a vertex of G. It is possible to find in time f (k, w) · n an induced subgraph embedding φ of F into G that minimizes c(φ) (if such an embedding exists). The proof of Theorem 8.1 uses the standard algorithmic techniques of bounded treewidth graphs (see e.g., [14] for a similar result). We omit the details. To generalize Theorem 8.1 to the case when G is planar, or more generally, H-minor-free, we need the following result: Theorem 8.2. [10] For a fixed graph H, there is a constant cH such that, for any integer k ≥ 1 and for every H-minor-free graph G, the vertices of G can be partitioned into k + 1 sets such that any k of the sets induce a graph of treewidth at most cH k. Furthermore, such a partition can be found in polynomial time. Theorem 8.3. Let F be an undirected graph on k vertices, let G be an undirected graph, and let c : V (F ) × V (G) → Z+ be a cost function of mapping a vertex of F to a vertex of G. For every fixed graph H, 17 if G is H-minor-free, then it is possible to find in time f (k) · nO(1) an induced subgraph embedding φ of F into G that minimizes c(φ) (if such an embedding exists). Proof. Let k := V (F ) and let V1, . . . , Vk+1 be the partition of V (G) obtained by Theorem 8.2. If φ is minimum cost embedding, then by the pigeon hole principle, there is a 1 ≤ i ≤ k + 1 such that φ does not map vertices to Vi. This means that the minimum cost embedding of F into G \ Vi has the same cost as φ. For every 1 ≤ i ≤ k + 1, we find the minimum cost embedding φi from F to G \ Vi; clearly, the φi with minimum cost gives an optimum solution. Because the treewidth of G \ Vi is at most cH k, by Theorem 8.1, embedding φi can be found in time f (k, cH k)n. This means that for a fixed H, the whole algorithm needs f(cid:48)(k)nO(1) time for some function f(cid:48). With these tools in hand, the proof of Theorem 4.1 is the same as the proof of Theorem 3.1, but with the following differences: 1. Gk,(cid:96) contains every graph with k main pebbles and at most (cid:96) vertices, not only the edge-deletion minimal ones. 2. For a given F0 ∈ Gk,(cid:96), we find a minimum cost induced subgraph embedding using Theorem 8.3, instead of a minimum cost subgraph embedding using Theorem 6.2. 8.2 Bidimensionality Theorem 4.1 shows that the DISPERSION problem defined in Section 2.1 is FPT for planar graphs, param- eterized by the number k of pebbles. Note that Theorem 4.1 holds for arbitrary movement cost functions. In the special case where each pebble is allowed to move only one step in the planar graph, called SINGLE- MOVE DISPERSION, we show how to obtain a simpler and more efficient algorithm using bidmensionality theory. k(cid:101) × 4(cid:100)√ We argue as follows. If a vertex does not have a pebble in its closed neighborhood, then it is irrelevant to the problem and can be deleted without changing the answer. Next we establish a parameter-treewidth bound, as in bidimensionality theory [9]: if the treewidth is sufficiently large, then the parameter must be larger than s, so we can simply answer "no". To prove this relation we use the grid-minor theorem of [30]: there is a universal constant c such that if a planar graph has treewidth at least c· s, then it has a s× s grid as a minor. Now suppose that the treewidth of the graph is at least 4c(cid:100)√ k(cid:101), which implies that the graph has a 4(cid:100)√ k(cid:101) grid minor. If we consider just the edge contractions that lead to this minor, ignoring the edge deletions, we obtain a partially triangulated grid as in bidimensionality theory [9]. Let S be the set of grid vertices interior to the grid (excluding the boundary) and having row and column numbers divisible by 3. In this way, we find a set of at least k + 1 vertices such that any two vertices are at distance more than 2 from each other. There is a pebble in the closed neighborhood of each vertex v ∈ S (otherwise v would be irrelevant). But the closed neighborhoods are disjoint, implying that that there are at least k + 1 pebbles, a contradiction. k(cid:101). In this case, we can solve the problem with a simple application of Courcelle's Theorem [8]. Sentences in the Extended Monadic Second Order Logic of Graphs (EMSO) contain quantifiers, logical connectives (¬, ∨, and ∧), vertex variables, edge variables, vertex set variables, edge set variables, and the following binary relations: ∈, =, inc(e, v) (edge variable e is incident to vertex variable v), and adj(u, v) (vertex variables u, v are neighbors). Furthermore, the language can contain arbitrary unary predicates on the vertices and edges. If a graph property can be expressed in EMSO then, for every fixed w, the problem can be solved in linear time on graphs with treewidth at most w [8]. It is easy to verify that the following formula expresses that the SINGLE-MOVE DISPERSION with k pebbles has a solution. The predicate P (v) expresses that there is a pebble at vertex v in the initial graph. Thus we can assume that the treewidth of the graph is at most 4c(cid:100)√ (cid:94) ∧ (cid:94) 1≤i≤k 1≤i<j≤k 18 ∃x1, . . . , xk, y1, . . . , yk : (P (xi) ∧ (adj(xi, yi) ∨ xi = yi)) (xi (cid:54)= xj ∧ yi (cid:54)= yj ∧ ¬adj(yi, yj)) Interestingly, one can give a single EMSO formula for SINGLE-MOVE DISPERSION that does not depend on the number k of pebbles (we can describe by a set E of edges the moves in the solution; we omit the details). Either way, we get that for every fixed k, the problem can be solved in linear time on graphs with treewidth at most 4c(cid:100)√ Theorem 8.4. SINGLE-MOVE DISPERSION can be solved in f (k) · nO(1) time. k(cid:101), completing the algorithm. Courcelle's Theorem gives an easy way of showing that a certain problem is FPT, but it cannot be used to optimize the exact running time, i.e., the function f (k). We believe we can obtain a better running time via a direct dynamic programming algorithm for SINGLE-MOVE DISPERSION on bounded-treewidth graphs. We do not give an explicit description of this, as the techniques are standard and the details are somewhat tedious. The main observation that if the tree decomposition has width w, then the dynamic programming has to consider 2O(w) states describing which vertices of the bag have pebbles on it in the solution and whether any pebble initially located in the bag was moved to a bag lower in the decomposition. This would take more work than applying Courcelle's Theorem, but results in an algorithm where the function f (k) in the running time is only 2O( It remains an interesting question for further work to determine whether other variants of the problem (such having an unbounded number of pebbles but parameterizing by the total movement) admit subexponential-time FPT algorithms based on bidimensionality. k), which is subexponential in k. √ 8.3 Planar STEINER CONNECTIVITY We have seen in Section 3.1 that STEINER CONNECTIVITY (connect the red pebbles using the blue pebbles) is FPT parameterized by the total number of pebbles (red and blue). On the other hand, if the parameter is only the number of blue pebbles, then the problem is W[2]-hard: Theorem 8.5. STEINER CONNECTIVITY is W[2]-hard parameterized by the number of blue pebbles, even in the special case when each blue pebble is allowed to move at most one step in the graph (and the red pebbles are stationary). Proof. The proof is similar to the proof Theorem 3.5. We present a reduction from MINIMUM DOMI- NATING SET: given a graph G with n vertices and an integer k, we construct an instance of STEINER CONNECTIVITY with n red pebbles and k blue pebbles such that there is solution by moving each blue pebble at most one step if and only if G has a dominating set of size k. Let v1, . . . , vn be the vertices of G. We construct a graph F as follows. We start with vertices s, a1, . . . , an, b1, . . . , bn where s is connected to every ai, and the ai's form a clique of size n. Furthermore, if vi and vj are neighbors in G, then ai and bj are adjacent in F . We place k blue pebbles on s and one red pebble on each bi. If G has a dominating set vi1, . . . , vik , then we move the k blue pebbles to ai1, . . . , aik . Note that the k blue pebbles induce a clique in F . Furthermore, if vertex vj of G is dominated by its neighbor vi(cid:96) , then the red pebble on vertex bj is adjacent to the blue pebble on vertex ai(cid:96). Thus the red pebbles are adjacent to the clique induced by the blue pebbles, hence the graph induced by all the pebbles is connected. The other direction is also easy to see: if the facility pebbles move to vertices ai1, . . . , aik such that the red and blue pebbles together induce a connected graph, then vertices vi1 , . . . , vik form a dominating set in G. In planar graphs, however, STEINER CONNECTIVITY is FPT parameterized by the number of con- nector (blue) pebbles. We only sketch the proof, which is a quite simple bounded search tree algorithm, using a combinatorial observation on the structure of planar graphs. Theorem 8.6. STEINER CONNECTIVITY, parameterized by the number of connector pebbles, is FPT on planar graphs. Proof. First, contracting each connected component of red pebbles to a single vertex does not change the problem, hence we can assume that the red pebbles are independent. It follows that the blue pebbles dominate the red pebbles in the solution, i.e., each red pebble has a blue neighbor. Let k be the number of blue pebbles. If there is no vertex having more than 2k2 red neighbors, then the k blue pebbles can dominate at most 2k3 red pebbles, i.e., it can be assumed that there is only a bounded number of red pebbles and the algorithm in Section 3.1 can be applied. Suppose that some vertex v has more than 2k2 red neighbors. 19 Then either a blue pebble is moved to v in a solution, or the red vertices are dominated some other way, implying that there is a vertex u having more than 2k2/k = 2k red neighbors common with v. By planarity, every vertex other than u and v can be adjacent to at most two of these red pebbles, hence they cannot be dominated if neither u and v is used. Thus we can branch into 2k directions: one of the k blue pebbles has to be moved to one of u and v. Formally, moving a blue pebble p to, say, u means changing the initial location of p to u and making it stationary by making the cost of moving p to any other vertex infinite. Since pebble p cannot move and u has a red neighbor, changing the color of p to red does not modify the problem. Thus in each branching step, we decrease the number blue pebbles, which means that the search tree has height at most k and has at most 2k leaves. 8.4 Geometric Graphs Proof (of Theorem 4.2): There are at most 2k2 possible graphs on k vertices. Suppose we are given a list of all possible allowed subgraphs. We guess which graph in this subset will be obtained by the pebbles (there are at most 2k2 choices). We guess the mapping of which pebbles will be mapped to which vertices of the intended graph (there are at most kk choices). It remains to optimize the maximum or total movement to realize this solution. We use Canny's Roadmap Algorithm for general Euclidean motion planning [5]. Given m semi-algebraic constraints, each of degree δ, over r real variables, this (randomized) algorithm computes a connectivity- preserving representation of the space of all solutions in mO(r)δO(r2) expected time. (Alternatively, the deter- ministic version of the algorithm runs in mO(r)δO(r4); and a new deterministic algorithm runs in mO(r)δO(r1.5) [2].) In particular, the algorithm decides whether the space is nonempty. We use the Roadmap Algorithm as follows. For each vertex i, we make d real variables representing the point pi to which that agent moves. For each edge (i, j) present in the graph, we add the semi-algebraic constraint (cid:107)pi − pj(cid:107)2 ≤ 1 (or < 1). For each edge (i, j) absent from the graph, we add the semi-algebraic constraint (cid:107)pi − pj(cid:107)2 > 1 (or ≥ 1). We also add the algebraic constraints pi = oi + vi, where oi is the known (constant) original position and vi is a vector of d additional variables representing the motion of agent i, i = (cid:107)vi(cid:107)2, where mi is another real variable to measure the motion. and we add the algebraic constraint m2 To decide whether the total motion can be at most x, we can add a constraint m1 + m2 + ··· + mn ≤ x and test with the Roadmap Algorithm whether the space is nonempty. To decide whether the maximum motion can be at most x, we can add n constraints mi ≤ x and test with the Roadmap Algorithm whether the space is nonempty. In total, we have O(kd) real variables and O(k2 + kd) semi-algebraic constraints, so the Roadmap Algorithm takes (k2 + kd)kd2O((kd)2) = 2O((kd)2) expected time. Finally we binary search on the objective. Clearly the optimal solution we seek has cost at least 0. We also claim that it has cost at most 2k2 +kD: move all agents to a common point, which costs at most kD; and then move the agents to a modified instance of the target graph where every connected component (which has diameter at most k) has distance at most 2 to another connected component, and thus the overall diameter is at most 2k, for a cost of at most 2k2. Thus a binary search, terminating when we have an interval of length at most ε (and thus have an additive ε approximation), requires O(lg[(2k2 + kD)/ε]) = O(lg k + lg D + lg(1/ε)) calls to the Roadmap Algorithm. The overall expected running time is 2k2 kk·2O((kd)2)·(lg k+lg D+lg(1/ε)) = 2O((kd)2)(lg D+lg(1/ε)). 8.5 Improving CONNECTIVITY with Fast Subset Convolution Here we consider the version of CONNECTIVITY where the pebbles have to be moved such that they induce a connected graph, and it is allowed that more than one pebbles are on the same vertex. We have seen in Section 3.1 that the general results of Theorem 3.1 imply that this problem is FPT. Here we give a more efficient algorithm for this specific problem: the exponential factor of the running time is only O(2k). The main tool we use is the recent algorithm of Bjorklund et al. [3] for fast subset convolution in the min-sum semiring: Theorem 8.7 (Bjorklund et al. [3]). Let P be a set of size k and let f, g : 2N → {−M, . . . , M} be two functions. The 2k values of the function h(S) := min T⊆S (f (T ) + g(S \ T )) 20 can be evaluated in time O(2kM ). v,i(S) is the minimum of fu,i(S), taken over all neighbors u of v). (The notation O suppresses polylogarithmic factors.) For each vertex v and subset S ⊆ P of pebbles, let fv(S) (resp., f(cid:48) v(S)) be the minimum cost of moving the pebbles in S to induce a connected subgraph including v (resp., including a neighbor of v). Let fv,i(S) be fv(S) if S ≤ i and infinity otherwise and define f(cid:48) v,i(S) similarly. Observe that fv,1(S) is trivial to determine and if fv,i(S) is known for every v, then f(cid:48) v,i(S) is easy to determine as well (as f(cid:48) Our strategy is to compute, iteratively for i = 1, 2, ..., k, the value of fv,i(S) (and hence the value of f(cid:48) v,i(S)) for every v and S. To determine fv,i(S), first we have to consider the trivial case when all the pebbles are moved to v; the cost of this is easy calculate. Otherwise, if F is the connected subgraph induced by the pebbles in S (after the movement), then F \ v has at least one connected component, say C, and this component C contains a nonempty proper subset T ⊂ S of the pebbles. In this case, the cost of the v,i−1(T ) + fv,i−1(S \ T ) (the equality follows from movement can be expressed as f(cid:48) T < S ≤ i, S \ T < S ≤ i). Thus we have to determine minT⊆S(f(cid:48) v,i−1(T ) + fv,i−1(S \ T )), and the algorithm of Theorem 8.7 can be used for this purpose (as the functions f(cid:48) v,i−1 and fv,i−1 were already determined). If the values of the movement cost function are polynomially bounded, then the resulting algorithm has running time O(2knO(1)). Theorem 8.8. The movement problem CONNECTIVITY with k pebbles can be solved in time 2k · nO(1) if the values of the movement cost function are polynomially bounded. v,i(T ) + fv,i(T \ S) = f(cid:48) 8.6 Hereditary Properties To prove Theorem 3.3 we use the following hardness result on the parameterized complexity of finding induced subgraphs with hereditary properties. Given a graph property H, in the problem INDUCED-H, we are given a graph G and an integer k, and the task is to find k vertices of G that induce a subgraph in H. Theorem 8.9 (Khot and Raman [24]). Let H be a decidable hereditary graph property. If H includes all empty and all complete graphs, then INDUCED-H is FPT, and W[1]-hard otherwise. Proof (of Theorem 3.3). Let G be a hereditary property where each vertex has exactly one client agent and there are no other type of pebbles. Let G0 contain the underlying graphs of the multi-colored graphs in G; clearly G0 is hereditary. Let G(cid:48) 0 contain all the graphs in G0 and those graphs G that can be made a member of G0 by connecting an arbitrary vertex of G with every other vertex. For example, if G0 is the set of all cliques, then G(cid:48) 0 contains those graphs where there is only at most one vertex which is not connected to every other vertex. On the other hand, if G0 is the set of all independent sets, then G(cid:48) 0 = G0. It is easy to see that G(cid:48) 0 is the same as the largest clique appearing in G0, and the 0 is hereditary, the largest clique appearing in G(cid:48) size of the largest independent set in G(cid:48) 0 is at most one larger than the size of the largest independent set in G0. Therefore, INDUCED-G(cid:48) 0 to the movement problem. Given a graph G, we construct a graph G(cid:48) by adding a new vertex v that is adjacent to every other vertex. For every possible combinations of k colors, we put k pebbles with these colors on v and check whether the movement problem has a solution where each pebble moves at most one step. We claim that the movement problem has such a solution for at least one combination of colors if and only if G has an induced subgraph H ∈ G(cid:48) Assume first that the movement problem has a solution. We consider two cases. If all the pebbles move, then they induce a multicolored graph that belongs to G. The underlying graph of this multicolored graph in G is in G0 ⊆ G(cid:48) 0. If not all pebbles move, then exactly one pebble p stays at v (as G has no member with more than one pebble at a vertex). The k pebbles induce a graph H ∈ G0 and by construction p is adjacent to every other pebble, i.e., H has a universal vertex. Thus if we move pebble p to an arbitrary vertex u not occupied by the other pebbles, then the k pebbles induce a graph in G(cid:48) 0 (as this graph can be made a member of G0 by making u an universal vertex). To prove the hardness of the movement problem, we reduce an instance (G, k) of INDUCED-G(cid:48) 0 by definition, that is, G has an induced subgraph that belongs to G(cid:48) 0 is W[1]-hard. We reduce this problem to the movement problem. 0 on k vertices. The other direction is also easy to see. If G has a subgraph H ∈ G0 ⊆ G(cid:48) 0, then by moving appropriately colored pebbles to these vertices we can obtain a solution where the k pebbles induce a multicolored graph whose underlying graph is H. Assume now that G has a subgraph H ∈ G(cid:48) 0 \ G0, i.e., connecting vertex 21 u ∈ H with every other vertex gives a graph H(cid:48) ∈ G0. In this case we can obtain a solution by moving k − 1 appropriately colored pebbles to the k − 1 vertices corresponding to H \ u and leaving one pebble at v. 9 Conclusions We have introduced a very general formulation of movement minimization problems and investigated their fixed-parameter tractability, parameterized by the number of pebbles (of certain type). We obtained general meta-theorems, both on the algorithmic and complexity side, which give us convenient tools to classify concrete problems. The interesting feature of this results is that they reduce an algorithmic/complexity question (is the problem FPT?) to a purely combinatorial question (is treewidth bounded?). By looking more closely at certain variants, we observed that a wide range of algorithmic ideas are relevant for this class of problems. Nevertheless, there are many natural problem variants for which our results do not give satisfying answers. We list a few concrete questions to stimulate further research: • Given a set of pebbles in a graph G, move the pebbles such that they induce a connected graph and the total movement is at most k steps. Is this problem FPT in general graphs/planar graphs, parameterized by k? • For which problems can we use bidimensionality theory to obtain subexponential FPT algorithms (i.e., running time of the form 2o(k)nO(1))? • Prove that natural movement problems are NP-hard in the geometric setting. For example, in the DISPERSION problem (move the agents such that the distance between any two of them is at least 1), is it NP-hard to minimize the sum or the maximum of the movements? Finally, let us mention that the general hardness proof of Theorem 3.2 is limited in the sense that it proves hardness only for a very specific question: finding a solution where every pebble moves at most one step. While intuitively every reasonable question should be at least as hard as this one-step question, this hardness result does not formally rule out the possibility that some other natural question is FPT. For example, it can happen that the one-step question is W[1]-hard, but minimizing the total movement is FPT. It would be interesting to adapt the hardness result to other reasonable questions. References [1] N. Alon, R. Yuster, and U. Zwick. Color-coding. J. ACM, 42(4):844 -- 856, 1995. [2] S. Basu, M.-F. Roy, M. S. E. Din, and ´E. Schost. A baby step-giant step roadmap algorithm for general algebraic sets. 2012. http://arxiv.org/abs/1201.6439. [3] A. Bjorklund, T. Husfeldt, P. Kaski, and M. Koivisto. Fourier meets Mobius: fast subset convolution. In STOC, pages 67 -- 74, New York, NY, USA, 2007. ACM. [4] J. L. Bredin, E. D. Demaine, M. Hajiaghayi, and D. Rus. Deploying sensor networks with guaranteed capacity and fault tolerance. In MOBIHOC, pages 309 -- 319, Urbana-Champaign, Illinois, May 25 -- 28 2005. [5] J. F. Canny. The Complexity of Robot Motion Planning. MIT Press, 1987. [6] P. Corke, S. Hrabar, R. Peterson, D. Rus, S. Saripalli, and G. Sukhatme. Autonomous deployment of a sensor network using an unmanned aerial vehicle. In ICRA, New Orleans, USA, 2004. [7] P. Corke, S. Hrabar, R. Peterson, D. Rus, S. Saripalli, and G. Sukhatme. Deployment and connectivity repair of a sensor net with a flying robot. In ISER, Singapore, 2004. [8] B. Courcelle. Graph rewriting: an algebraic and logic approach. In Handbook of Theoretical Computer Science, Vol. B, pages 193 -- 242. Elsevier, Amsterdam, 1990. 22 [9] E. D. Demaine and M. Hajiaghayi. The bidimensionality theory and its algorithmic applications. The Computer Journal, 51(3):292 -- 302, 2008. [10] E. D. Demaine, M. Hajiaghayi, and K. Kawarabayashi. Algorithmic graph minor theory: Decomposition, approximation, and coloring. In FOCS 2005, pages 637 -- 646, 2005. [11] E. D. Demaine, M. T. Hajiaghayi, H. Mahini, A. S. Sayedi-Roshkhar, S. O. Gharan, and M. Zadi- moghaddam. Minimizing movement. ACM Transactions on Algorithms, 5(3), 2009. [12] S. Doddi, M. V. Marathe, A. Mirzaian, B. M. E. Moret, and B. Zhu. Map labeling and its generalizations. In SODA, pages 148 -- 157, New Orleans, LA, 1997. [13] R. G. Downey and M. R. Fellows. Parameterized Complexity. Monographs in Computer Science. Springer, New York, 1999. [14] D. Eppstein. Subgraph isomorphism in planar graphs and related problems. J. Graph Algorithms Appl., 3(3), 1999. [15] M. R. Fellows and H. Fernau. Facility location problems: A parameterized view. Discrete Applied Mathematics, 159(11):1118 -- 1130, 2011. [16] J. Flum and M. Grohe. Parameterized Complexity Theory. Springer-Verlag, Berlin, 2006. [17] E. C. Freuder. Complexity of k-tree structured constraint satisfaction problems. In AAAI, pages 4 -- 9, 1990. [18] Z. Friggstad and M. R. Salavatipour. Minimizing movement in mobile facility location problems. In 49th Annual IEEE Symposium on Foundations of Computer Science (FOCS'08), pages 357 -- 366, 2008. [19] M. Grohe. The complexity of homomorphism and constraint satisfaction problems seen from the other side. J. ACM, 54(1):1, 2007. [20] T.-R. Hsiang, E. M. Arkin, M. A. Bender, S. P. Fekete, and J. S. B. Mitchell. Algorithms for rapidly dispersing robot swarms in unknown environments. In Algorithmic Foundations of Robotics V, volume 7 of Springer Tracts in Advanced Robotics, pages 77 -- 94. Springer-Verlag, 2003. [21] F. Huffner, R. Niedermeier, and S. Wernicke. Techniques for practical fixed-parameter algorithms. The Computer Journal, 51(1):7 -- 25, 2008. [22] M. Jiang, S. Bereg, Z. Qin, and B. Zhu. New bounds on map labeling with circular labels. In ISAAC, volume 3341 of Lecture Notes in Computer Science, pages 606 -- 617, Hong Kong, China, December 2004. [23] M. Jiang, J. Qian, Z. Qin, B. Zhu, and R. Cimikowski. A simple factor-3 approximation for labeling points with circles. Information Processing Letters, 87(2):101 -- 105, 2003. [24] S. Khot and V. Raman. Parameterized complexity of finding subgraphs with hereditary properties. Theoret. Comput. Sci., 289(2):997 -- 1008, 2002. [25] T. Kloks. Treewidth, volume 842 of Lecture Notes in Computer Science. Springer-Verlag, Berlin, 1994. [26] S. M. LaValle. Planning Algorithms. Cambridge University Press, 2006. http://msl.cs.uiuc.edu/ planning/. [27] R. Niedermeier. Invitation to fixed-parameter algorithms, volume 31 of Oxford Lecture Series in Math- ematics and its Applications. Oxford University Press, Oxford, 2006. [28] J. Plehn and B. Voigt. Finding minimally weighted subgraphs. In Graph-theoretic concepts in computer science (Berlin, 1990), volume 484 of Lecture Notes in Comput. Sci., pages 18 -- 29. Springer, Berlin, 1991. [29] J. H. Reif and H. Wang. Social potential fields: a distributed behavioral control for autonomous robots. In Proceedings of the Workshop on Algorithmic Foundations of Robotics, pages 331 -- 345, 1995. 23 [30] N. Robertson, P. D. Seymour, and R. Thomas. Quickly excluding a planar graph. J. Combin. Theory Ser. B, 62(2):323 -- 348, 1994. [31] A. C. Schultz, L. E. Parker, and F. E. Schneider, editors. Multi-Robot Systems: From Swarms to Intelligent Automata. Springer, 2003. Proceedings from the 2003 International Workshop on Multi- Robot Systems. [32] T. Strijk and A. Wolff. Labeling points with circles. International Journal of Computational Geometry & Applications, 11(2):181 -- 195, 2001. A Proof of Theorem 6.2 Let v1, . . . , vk be the vertices of F , and assign labels {1, . . . , k} to the vertices of G uniformly and indepen- dently at random. We say that a mapping φ from a subset S ⊆ V (F ) to V (G) is colorful if the vertices in φ(S) have distinct labels. Below we present an algorithm for finding the minimum cost colorful subgraph embedding with respect to a given labeling. This cost might be larger than the cost of the minimum cost embedding. However, an arbitrary embedding is colorful in a random labeling with probability at least k!/kk = 2−O(k), hence if we try 2O(k) random labelings, then with constant probability at least one optimum embedding becomes colorful in one of the labelings. This means that the probability of not finding the optimum can be reduced to an arbitrarily small constant by trying 2O(k) random labelings. The algorithm can be derandomized by using a k-perfect family of hash functions instead of the random labelings [1], [16, Section 13.3]. Let the rooted tree T with the bags (Bu ⊆ V (G) : u ∈ V (T )) be a width t tree decomposition of F . We assume this decomposition is nice [25]: every node u ∈ V (T ) is either a leaf node (u has no children), join node (u has two children u(cid:48), u(cid:48)(cid:48) and Bu(cid:48) = Bu(cid:48)(cid:48)), forget node (u has a single child u(cid:48) and Bu ⊆ Bu(cid:48), Bu = Bu(cid:48) − 1), or introduce node (u has a single child u(cid:48) and Bu ⊇ Bu(cid:48), Bu = Bu(cid:48) + 1). For every u ∈ V (T ), we denote by Vu the union of the bags Bu(cid:48) for every descendant u(cid:48) of u (including u itself). Let us fix a labeling (cid:96) : {1, . . . , k} → V (G) of the vertices. For every u ∈ V (T ), L ⊆ {1, . . . , k}, and mapping ψ : Bu → V (G), we define c(u, L, ψ) to be the cost of the minimum cost subgraph embedding φ : Vu → V (G) of G[Vu] in G satisfying 1. φ is colorful, 2. φ(v) = ψ(v) for every v ∈ Bu, and 3. φ(Vu) uses only the labels in L. If there is no mapping φ satisfying the requirements, then c(u, L, ψ) is defined to be ∞. It follows from these definitions that if r is the root of T , then the minimum cost of a colorful embedding of F into G is given by minψ c(r,{1, . . . , k}, ψ), where the minimum is taken over all mappings ψ : Br → V (G). We determine the values c(u, L, ψ) in a bottom up traversal of the tree T , i.e., we assume that these values are already determined for every child of u. Depending the type of node u ∈ V (F ) we do the following. • Node u is a leaf node. In this case Vu = Bu. Thus we can simply try all subgraph embeddings φ : Bu → V (G) of G[Bu] in G and define c(u, L, ψ) to be the minimum cost of a mapping φ that satisfies all three constraints above. • Node u is an introduce node with child u(cid:48). Let Bu \ Bu(cid:48) = {v}. To compute the value c(u, L, ψ) for a given L and ψ, we first check if (cid:96)(ψ(v)) ∈ L; if not, then clearly c(u, L, ψ) = ∞. Next we check if for every neighbor w ∈ Bu of v, ψ(w) is a neighbor of u. If this does not hold for some w, then again we have c(u, L, ψ) = ∞. Otherwise, let ψ(cid:48) be ψ restricted to Bu(cid:48). Now it is easy to see that c(u, L, ψ) = c(u(cid:48), L \ {(cid:96)(ψ(v))}, ψ(cid:48)) + c(v, ψ(v)): any mapping φ(cid:48) realizing the minimum c(u(cid:48), L \ {(cid:96)(ψ(v))}, ψ(cid:48)) can be extended to a suitable mapping φ by defining φ(v) = ψ(v). • Node u is a forget node with child u(cid:48). Let Bu(cid:48) \ Bu(cid:48) = {v}. It is easy to see that c(u, L, ψ) is the minimum of c(u(cid:48), L, ψ(cid:48)), taken over every ψ(cid:48) : Bu(cid:48) → V (G) satisfying ψ(cid:48)(w) = ψ(w) for every w ∈ Bu. Thus c(u, L, ψ) can be obtained as the minimum of n already determined values. 24 • Node u is a join node with children u(cid:48) and u(cid:48)(cid:48). Let L0 be the labels of the vertices ψ(Bu) and let Cu :=(cid:80) v∈Bu c(v, ψ(v)). We show that c(u, L, ψ) = min L(cid:48) ,L(cid:48)(cid:48)⊆L L(cid:48)∩L(cid:48)(cid:48)=L0 (cid:0)c(u(cid:48), L(cid:48), ψ) + c(u(cid:48)(cid:48), L(cid:48)(cid:48), ψ) − Cu (cid:1), (1) that w(cid:48), w(cid:48)(cid:48) ∈ Bu and w(cid:48) = w(cid:48)(cid:48) follows. The cost of φ is(cid:80) which means that c(u, L, ψ) can be determined in time 2O(k) using values already determined. Suppose that for some L(cid:48), L(cid:48)(cid:48) ⊆ L with L(cid:48) ∩ L(cid:48)(cid:48) = L0, mappings φ(cid:48) : Vu(cid:48) → V (G) and φ(cid:48)(cid:48) : Vu(cid:48)(cid:48) → V (G) are minimum cost subgraph embeddings that define the values c(u, L(cid:48), ψ(cid:48)) and c(u, L(cid:48)(cid:48), ψ(cid:48)(cid:48)), respectively. Since ψ(cid:48) and ψ(cid:48)(cid:48) are the same as ψ on Bu, they can be joined to obtain a subgraph embedding φ : Vu → V (G). Note that ψ is injective: if φ(cid:48)(w(cid:48)) = φ(cid:48)(cid:48)(w(cid:48)(cid:48)), then (cid:96)(φ(cid:48)(w)) ∈ L(cid:48) ∩ L(cid:48)(cid:48) = L0, which implies v∈Vu(cid:48)(cid:48) c(v, φ(cid:48)(cid:48)(v)) − Cu, where the last term accounts for the double counting of the vertices in Bu. Thus c(u, L, ψ) cannot be larger than the right hand side in (1). Conversely, if φ is an embedding of Vu that defines c(u, L, ψ), then let L(cid:48) := (cid:96)(ψ(Vu(cid:48))) and L(cid:48)(cid:48) := (cid:96)(ψ(Vu(cid:48)(cid:48))). Since Vu(cid:48) ∩ Vu(cid:48)(cid:48) = Bu, L(cid:48) ∩ L(cid:48)(cid:48) = φ(Bu) = ψ(Bu) = L0. Restricting φ to Vu(cid:48) and Vu(cid:48)(cid:48) gives two embeddings φ(cid:48) and φ(cid:48)(cid:48), respectively. By considering these two particular embeddings φ(cid:48), φ(cid:48)(cid:48), it is easy to see that the right hand side of (1) is at most c(u, L, ψ), proving the equality. v∈Vu(cid:48) c(v, φ(cid:48)(v)) +(cid:80) As discussed above, a value c(u, L, ψ) can be determined in time 2O(k) · nO(t) if the values corresponding to the children of u are already determined. As there are 2O(k) · nO(t) values c(u, L, ψ) and the running time of every other part of the algorithm (such as finding the tree decomposition) is dominated by 2O(k) · nO(t), the total running time is 2O(k) · nO(t). 25
cs/0608124
5
0608
2011-01-18T15:38:52
The Tree Inclusion Problem: In Linear Space and Faster
[ "cs.DS" ]
Given two rooted, ordered, and labeled trees $P$ and $T$ the tree inclusion problem is to determine if $P$ can be obtained from $T$ by deleting nodes in $T$. This problem has recently been recognized as an important query primitive in XML databases. Kilpel\"ainen and Mannila [\emph{SIAM J. Comput. 1995}] presented the first polynomial time algorithm using quadratic time and space. Since then several improved results have been obtained for special cases when $P$ and $T$ have a small number of leaves or small depth. However, in the worst case these algorithms still use quadratic time and space. Let $n_S$, $l_S$, and $d_S$ denote the number of nodes, the number of leaves, and the %maximum depth of a tree $S \in \{P, T\}$. In this paper we show that the tree inclusion problem can be solved in space $O(n_T)$ and time: O(\min(l_Pn_T, l_Pl_T\log \log n_T + n_T, \frac{n_Pn_T}{\log n_T} + n_{T}\log n_{T})). This improves or matches the best known time complexities while using only linear space instead of quadratic. This is particularly important in practical applications, such as XML databases, where the space is likely to be a bottleneck.
cs.DS
cs
The Tree Inclusion Problem: In Linear Space and Faster∗ Philip Bille† Inge Li Gørtz‡ Abstract Given two rooted, ordered, and labeled trees P and T the tree inclusion problem is to determine if P can be obtained from T by deleting nodes in T . This problem has recently been recognized as an important query primitive in XML databases. Kilpelainen and Mannila [SIAM J. Comput. 1995 ] presented the first polynomial time algorithm using quadratic time and space. Since then several improved results have been obtained for special cases when P and T have a small number of leaves or small depth. However, in the worst case these algorithms still use quadratic time and space. Let nS, lS, and dS denote the number of nodes, the number of leaves, and the depth of a tree S ∈ {P, T }. In this paper we show that the tree inclusion problem can be solved in space O(nT ) and time: O  min   lP nT lP lT log log nT + nT nP nT log nT + nT log nT     This improves or matches the best known time complexities while using only linear space instead of quadratic. This is particularly important in practical applications, such as XML databases, where the space is likely to be a bottleneck. 1 Introduction Let T be a rooted tree. We say that T is labeled if each node is assigned a character from an alphabet Σ and we say that T is ordered if a left-to-right order among siblings in T is given. All trees in this paper are rooted, ordered, and labeled. A tree P is included in T , denoted P ⊑ T , if P can be obtained from T by deleting nodes of T . Deleting a node v in T means making the children of v children of the parent of v and then removing v. The children are inserted in the place of v in the left-to-right order among the siblings of v. The tree inclusion problem is to determine if P can be included in T and if so report all subtrees of T that include P . Recently, the problem has been recognized as an important query primitive for XML data and has received considerable attention, see e.g., [33, 34, 37, 39 -- 41]. The key idea is that an XML document can be viewed as a tree and queries on the document correspond to a tree inclusion problem. As an example consider Figure 1. Suppose that we want to maintain a catalog of books for a bookstore. A fragment of the tree, denoted D, corresponding to the catalog is shown in (b). In addition to supporting full-text queries, such as find all documents containing the word "John", we can also utilize the tree structure of the catalog to ask more specific queries, such as "find all books written by John with a chapter that has something to do with XML". We can model this query by constructing the tree, denoted Q, shown in (a) and solve the is Q ⊑ D? The answer is yes and a possible way to include Q in D is indicated tree inclusion problem: ∗An extended abstract of this paper appeared in Proceedings of the 32nd International Colloquium on Automata, Languages and Programming, Lecture Notes in Computer Science, vol. 3580, pp. 66-77, Springer-Verlag, 2005. †Technical University of Denmark, Department of Informatics and Mathematical Modelling. This work is part of the DSSCV project supported by the IST Programme of the European Union (IST-2001-35443). ‡Corresponding author: Technical University of Denmark, Department of Informatics and Mathematical Modelling, Build- ing 322, Office 124, DK-2800 Kongens Lyngby, Denmark. Phone: (+45) 45 25 36 73. Fax: (+45) 45 88 26 73. Email: [email protected]. 1 author john Q book (a) book D catalog book chapter author chapter chapter XML name john title section title databases XML queries (b) catalog book author john chapter author chapter chapter XML name john title section title databases XML queries (c) Figure 1: (a) The tree Q corresponding to the query. (b) A fragment of the tree D. Can the tree Q be included in the tree D? It can and an embedding is given in (c). by the dashed lines in (c). If we delete all the nodes in D not touched by dashed lines the trees Q and D become isomorphic. Such a mapping of the nodes from Q to D given by the dashed lines is called an embedding (formally defined in Section 3). We note that the ordering of the XML document, and hence the left-to-right order of siblings, is important in many cases. For instance, in the above example, the relative order of contents of the chapters is most likely important. Also, in biological databases, order is of critical importance. Consequently, standard XML query languages, such as XPath [13] and XQuery [10], require the output of queries to be ordered. The tree inclusion problem was initially introduced by Knuth [27, exercise 2.3.2-22] who gave a sufficient condition for testing inclusion. Motivated by applications in structured databases [24, 29] Kilpelainen and Mannila [25] presented the first polynomial time algorithm using O(nP nT ) time and space, where nP and nT is the number of nodes in P and T , respectively. During the last decade several improvements of the original algorithm of [25] have been suggested [1, 11, 23, 32]. The previously best known bound is due to Chen [11] who presented an algorithm using O(lP nT ) time and O(lP · min{dT , lT}) space. Here, lS and dS denote the number of leaves and the depth of a tree S, respectively. This algorithm is based on an algorithm of Kilpelainen [23]. Note that the time and space is still Θ(nP nT ) for worst-case input trees. In this paper we present three algorithms which combined improve all of the previously known time and space bounds. To avoid trivial cases we always assume that 1 ≤ nP ≤ nT . We show the following theorem: Theorem 1 For trees P and T the tree inclusion problem can be solved in O(nT ) space with the following 2 running time:     lP nT lP lT log log nT + nT nP nT log nT + nT log nT min O  Hence, when P has few leaves we obtain a fast algorithm and even faster if both P and T have few leaves. When both trees have many leaves and nP = Ω(log2 nT ), we instead improve the previous quadratic time bound by a logarithmic factor. Most importantly, the space used is linear. In the context of XML databases this will likely make it possible to query larger trees and speed up the query time since more of the compu- tation can be kept in main memory. The extended abstract of this paper [9] contained an error. The algorithms in the paper [9] did not use linear space. The problem was due to a recursive traversal of P which stored too many sets of nodes leading to a worst-case space complexity of Ω(dP lT ). In this paper we fix this problem by recursively visiting the nodes such that the child with the largest number of descendant leaves is visited first, and by showing that the size of the resulting stored node sets exponentially decrease. With these ideas we show that all of our algorithms use O(nT ) space. Additionally, our improved analysis of the sizes of the stored node sets also leads to an improvement in the running time of the algorithm in the second case above. In the previous paper the running time was O(nplT log log nT + nT ). 1.1 Techniques Most of the previous algorithms, including the best one [11], are essentially based on a simple dynamic programming approach from the original algorithm of [25]. The main idea behind this algorithm is the following: Let v be a node in P with children v1, . . . , vi and let w be a node in T . Consider the subtrees rooted at v and w, denoted by P (v) and T (w). To decide if P (v) can be included in T (w) we try to find a sequence w1, . . . , wi of left-to-right ordered descendants of w such that P (vk) ⊑ T (wk) for all k, 1 ≤ k ≤ i. The sequence is computed greedily from left-to-right in T (w) effectively finding the leftmost inclusion of P (v) in T (w). Applying this approach in a bottom-up fashion we can determine, if P (v) ⊑ T (w), for all pairs of nodes v in P and w in T . In this paper we take a different approach. The main idea is to construct a data structure on T supporting a small number of procedures, called the set procedures, on subsets of nodes of T . We show that any such data structure implies an algorithm for the tree inclusion problem. We consider various implementations of this data structure which all use linear space. The first simple implementation gives an algorithm with O(lP nT ) running time. As it turns out, the running time depends on a well-studied problem known as the tree color problem. We show a direct connection between a data structure for the tree color problem and the tree inclusion problem. Plugging in a data structure of Dietz [16] we obtain an algorithm with O(lP lT log log nT + nT ) running time. Based on the simple algorithms above we show how to improve the worst-case running time of the set procedures by a logarithmic factor. The general idea used to achieve this is to divide T into small trees called clusters of logarithmic size which overlap with other clusters in at most 2 nodes. Each cluster is represented by a constant number of nodes in a macro tree. The nodes in the macro tree are then connected according to the overlap of the cluster they represent. We show how to efficiently preprocess the clusters and the macro tree such that the set procedures use constant time for each cluster. Hence, the worst-case quadratic running time is improved by a logarithmic factor. Our algorithms recursively traverse P top-down. For each node v ∈ V (P ) we compute a set of nodes representing all of the subtrees in T that include P (v). To avoid storing too many of these node sets the traversal of P visits the child with the largest number of descendant leaves first. For the first two algorithms this immediately implies a space complexity of O(lT log lP ), however, by carefully analyzing the sizes of stored node sets we are able to show that they decrease exponentially leading to the linear space bound. In the last algorithm the node sets are compactly encoded in O(nT / log nT ) space and therefore our recursive traversal alone implies a space bound of O(nT / log nT · log lP ) = O(nT ). 3 Throughout the paper we assume a unit-cost RAM model of computation with word size Θ(log nT ) and a standard instruction set including bitwise boolean operations, shifts, addition, and multiplication. All space complexities refer to the number of words used by the algorithm. 1.2 Related Work For some applications considering unordered trees is more natural. However, in [25, 30] this problem was proved to be NP-complete. The tree inclusion problem is closely related to the tree pattern matching problem [14, 17, 22, 28]. The goal is here to find an injective mapping f from the nodes of P to the nodes of T such that for every node v in P the ith child of v is mapped to the ith child of f (v). The tree pattern matching problem can be solved in (nP + nT ) logO(1)(nP + nT ) time. Another similar problem is the subtree isomorphism problem [12, 35], which is to determine if T has a subgraph isomorphic to P . The subtree isomorphism problem can be solved efficiently for ordered and unordered trees. The best algorithms for this problem use O( n1.5 + nT ) time for ordered trees [12,35]. Both use O(nP nT ) space. The tree inclusion problem can be considered a special case of the tree edit distance problem [15,26,36,42]. Here one wants to find the minimum sequence of insert, delete, and relabel operations needed to transform P into T . Currently the best algorithm for this problem uses O(nT n2 )) time [15]. For more details and references see the survey [8]. + nT ) time for unordered trees and O( nP nT log nP P nT log nP P (1 + log nT nP 1.3 Outline In Section 2 we give notation and definitions used throughout the paper. In Section 3 a common framework for our tree inclusion algorithms is given. Section 4 presents two simple algorithms and then, based on these results, we show how to get a faster algorithm in Section 5. 2 Notation and Definitions In this section we define the notation and definitions we will use throughout the paper. For a graph G we denote the set of nodes and edges by V (G) and E(G), respectively. Let T be a rooted tree. The root of T is denoted by root(T ). The size of T , denoted by nT , is V (T ). The depth of a node v ∈ V (T ), depth(v), is the number of edges on the path from v to root(T ) and the depth of T , denoted dT , is the maximum depth of any node in T . The parent of v is denoted parent(v) and the set of children of v is denoted child(v). We define parent(root(T )) = ⊥, where ⊥ 6∈ V (T ) is a special null node. A node with no children is a leaf and otherwise an internal node. The set of leaves of T is denoted L(T ) and we define lT = L(T ). We say that T is labeled if each node v is a assigned a character, denoted label(v), from an alphabet Σ and we say that T is ordered if a left-to-right order among siblings in T is given. Note that we do not require that the size of the alphabet is bounded by a constant. All trees in this paper are rooted, ordered, and labeled. Ancestors and Descendants Let T (v) denote the subtree of T rooted at a node v ∈ V (T ). If w ∈ V (T (v)) then v is an ancestor of w, denoted v (cid:22) w, and if w ∈ V (T (v))\{v} then v is a proper ancestor of w, denoted v ≺ w. If v is a (proper) ancestor of w then w is a (proper) descendant of v. A node z is a common ancestor of v and w if it is an ancestor of both v and w. The nearest common ancestor of v and w, nca(v, w), is the common ancestor of v and w of greatest depth. The first ancestor of w labeled α, denoted fl(w, α), is the node v such that v (cid:22) w, label(v) = α, and no node on the path between v and w is labeled α. If no such node exists then fl(w, α) = ⊥. Traversals and Orderings Let T be a tree with root v and let v1, . . . , vk be the children of v from left- to-right. The preorder traversal of T is obtained by visiting v and then recursively visiting T (vi), 1 ≤ i ≤ k, in order. Similarly, the postorder traversal is obtained by first visiting T (vi), 1 ≤ i ≤ k, in order and then v. The preorder number and postorder number of a node w ∈ T (v), denoted by pre(w) and post(w), are the 4 v1 v2 v5 v6 v7 v1 v2 v3 v4 (a) v5 v4 v3 v6 (b) v9 v8 v7 =S1 =S2 =S3 =S4 In (a) we have {(v1, v2, v3, v6, v7), (v1, v2, v5, v6, v7), (v1, v4, v5, v6, v7), (v3, v4, v5, v6, v7)} = Figure 2: Φ(S1, S2, S1, S3, S4) and thus mop(S1, S2, S1, S3, S4) = {(v3, v7)}. In (b) we have Φ(S1, S2, S1, S3, S4) = {(v1, v2, v3, v5, v7), (v1, v2, v6, v8, v9), (v1, v2, v3, v8, v9), (v1, v2, v3, v5, v9), (v1, v4, v6, v8, v9), (v3, v4, v6, v8, v9)} and thus mop(S1, S2, S1, S3, S4) = {(v1, v7), (v3, v9)}. 1 ⊳ x′ k E xk or x1 E x′ 1 ⊳ x′ 1, . . . , x′ k) ∈ Φ(X1, . . . , Xk), where either x1 ⊳ x′ number of nodes preceding w in the preorder and postorder traversal of T , respectively. The nodes to the left of w in T is the set of nodes u ∈ V (T ) such that pre(u) < pre(w) and post(u) < post(w). If u is to the left of w, denoted by u ⊳ w, then w is to the right of u. If u ⊳ w or u (cid:22) w or w ≺ u we write u E w. The null node ⊥ is not in the ordering, i.e., ⊥ ⋪ v for all nodes v. Minimum Ordered Pairs A set of nodes X ⊆ V (T ) is deep if no node in X is a proper ancestor of another node in X. For k deep sets of nodes X1, . . . , Xk let Φ(X1, . . . , Xk) ⊆ (X1 × ··· × Xk), be the set of tuples such that (x1, . . . , xk) ∈ Φ(X1, . . . , Xk) iff x1 ⊳ ··· ⊳ xk. If (x1, . . . , xk) ∈ Φ(X1, . . . , Xk) and there is no (x′ k ⊳ xk then the pair (x1, xk) is a minimum ordered pair. Intuitively, (x1, xk) is a closest pair of nodes from X1 and Xk in the left-to-right order for which we can find x2, . . . , xk−1 such that x1 ⊳··· ⊳ xk. The set of minimum ordered pairs for X1, . . . , Xk is denoted by mop(X1, . . . , Xk). Figure 2 illustrates these concepts on a small example. For any set of pairs Y , let Y 1 and Y 2 denote the projection of Y to the first and second coordinate, that is, if (y1, y2) ∈ Y then y1 ∈ Y 1 and y2 ∈ Y 2. We say that Y is deep if Y 1 and Y 2 are deep. The following lemma shows that given deep sets X1, . . . , Xk we can compute mop(X1, . . . , Xk) iteratively by first computing mop(X1, X2) and then mop(mop(X1, X2)2, X3) and so on. Lemma 1 For any deep sets of nodes X1, . . . , Xk, k > 2, we have, (x1, xk) ∈ mop(X1, . . . , Xk) iff there exists a node xk−1 such that (x1, xk−1) ∈ mop(X1, . . . , Xk−1) and (xk−1, xk) ∈ mop(mop(X1, . . . , Xk−1)2, Xk). Proof. We start by showing that if (x1, xk) ∈ mop(X1, . . . , Xk) then there exists a node xk−1 such that (x1, xk−1) ∈ mop(X1, . . . , Xk−1) and (xk−1, xk) ∈ mop(mop(X1, . . . , Xk−1)2, Xk). First note that (z1, . . . , zk) ∈ Φ(X1, . . . , Xk) implies (z1, . . . , zk−1) ∈ Φ(X1, . . . , Xk−1). Since (x1, xk) ∈ mop(X1, . . . , Xk) there must be a minimum node xk−1 such that the tuple (x1, . . . , xk−1) is in Φ(X1, . . . , Xk−1). We have (x1, xk−1) ∈ mop(X1, . . . , Xk−1). We need to show that (xk−1, xk) ∈ mop(mop(X1, . . . , Xk−1)2, Xk). Since (x1, xk) ∈ mop(X1, . . . , Xk) there exists no node z ∈ Xk such that xk−1 ⊳ z ⊳ xk. If such a z existed we would have (x1, . . . , xk−1, z) ∈ Φ(X1, . . . , Xk), contradicting that (x1, xk) ∈ mop(X1, . . . , Xk). Assume there exists a node z ∈ mop(X1, . . . , Xk−1)2 such that xk−1 ⊳ z ⊳ xk. Since (x1, xk−1) ∈ mop(X1, . . . , Xk−1) this implies that there is a node z′ ⊲ x1 such that (z′, z) ∈ mop(X1, . . . , Xk−1). But this implies that the tuple (z′, . . . , z, xk) is in Φ(X1, . . . , Xk) contradicting that (x1, xk) ∈ mop(X1, . . . , Xk). We will now show that if there exists a node xk−1 such that (x1, xk−1) ∈ mop(X1, . . . , Xk−1) and (xk−1, xk) ∈ mop(mop(X1, . . . , Xk−1)2, Xk) then the pair (x1, xk) ∈ mop(X1, . . . , Xk). Clearly, there exists a tuple (x1, . . . , xk−1, xk) ∈ Φ(X1, . . . , Xk). Assume that there exists a tuple (z1, . . . , zk) ∈ Φ(X1, . . . , Xk) such that x1 ⊳ z1 ⊳ zk E xk. Among the tuples satisfying these constraints let (y1, . . . , yk−1, yk) be the one It follows that (y1, yk−1) ∈ mop(X1, . . . , Xk−1). with maximum y1, minimum yk−1, and maximum yk. 5 Since (x1, xk−1) ∈ mop(X1, . . . , Xk−1) we must have xk−1 ⊳ yk−1. But this contradicts (xk−1, xk) ∈ mop(mop(X1, . . . , Xk−1)2, Xk), since node yk−1 ∈ mop(X1, . . . , Xk−1)2. Assume that there exists a tuple (z1, . . . , zk) ∈ Φ(X1, . . . , Xk) such that x1 E z1 ⊳ zk ⊳ xk. Since (x1, xk−1) ∈ mop(X1, . . . , Xk−1) we have xk−1 E zk−1 and thus xk−1 ⊳ zk ⊳ xk contradicting (xk−1, xk) ∈ mop(mop(X1, . . . , Xk−1)2, Xk). The following lemma is the reverse of the previous lemma and shows that given deep sets X1, . . . , Xk we also can compute mop(X1, . . . , Xk) iteratively from right to left. The proof is similar to the proof of Lemma 1. Lemma 2 For any deep sets of nodes X1, . . . , Xk, k > 2, we have, (x1, xk) ∈ mop(X1, . . . , Xk) iff there exists a node x2 such that (x2, xk) ∈ mop(X2, . . . , Xk) and (x1, x2) ∈ mop(X1, mop(X2, . . . , Xk)1). (cid:3) Heavy Leaf Path Decomposition We construct a heavy leaf path decomposition of P as follows. We classify each node as heavy or light. The root is light. For each internal node v we pick a child vj of v with maximum lP (vj ) and classify it as heavy. The remaining children of v are light. An edge to a light node is a light edge, and an edge to a heavy node is a heavy edge. The heavy child of a node v is denoted heavy(v). Let ldepth(v) denote the number of light edges on the path from v to root(P ). Note that a heavy leaf path decomposition is the same as the classical heavy path decomposition [21] except that the heavy child is defined as the child with largest number of the descendant leaves and not the child with the largest number of descendants. This distinction is essential for achieving the linear space bound of our algorithms. Note that heavy path decompositions have previously been used in algorithms for the related tree edit distance problem [26]. Lemma 3 For any tree P and node v ∈ V (P ), lP (v) ≤ lP 2ldepth(v) . Proof. By induction on ldepth(v). For ldepth(v) = 0 it is trivially true. Let ldepth(v) = ℓ. Assume wlog. that v is light. Let w be the unique light ancestor of v with ldepth(w) = ℓ − 1. By the induction hypothesis lP (w) ≤ lP /2ℓ−1. Now v has a sibling heavy(parent(v)) and thus at most half of the leaves in P (parent(v)) can be in the subtree rooted at v. Therefore, lP (v) ≤ lP (w)/2 ≤ lP /2ℓ. (cid:3) Corollary 1 For any tree P and node v ∈ V (P ), ldepth(v) ≤ log lP . Notation When we want to specify which tree we mean in the above relations we add a subscript. For instance, v ≺T w indicates that v is an ancestor of w in T . 3 Computing Deep Embeddings In this section we present a general framework for answering tree inclusion queries. As in [25] we solve the equivalent tree embedding problem. Let P and T be rooted labeled trees. An embedding of P in T is an injective function f : V (P ) → V (T ) such that for all nodes v, u ∈ V (P ), (i) label(v) = label(f (v)). (label preservation condition) (ii) v ≺ u iff f (v) ≺ f (u). (ancestor condition) (iii) v ⊳ u iff f (v) ⊳ f (u). (order condition) An example of an embedding is given in Figure 1(c). Lemma 4 (Kilpelainen and Mannila [25]) For any trees P and T , P ⊑ T iff there exists an embedding of P in T . 6 We say that the embedding f is deep if there is no embedding g such that f (root(P )) ≺ g(root(P )). The deep occurrences of P in T , denoted emb(P, T ) is the set of nodes, emb(P, T ) = {f (root(P )) f is a deep embedding of P in T}. By definition the set of ancestors of nodes in emb(P, T ) is exactly the set of nodes {u P ⊑ T (u)}. Hence, to solve the tree inclusion problem it is sufficient to compute emb(P, T ) and then, using additional O(nT ) time, report all ancestors of this set. We note that Kilpelainen and Mannila [25] used the similar concept of left embeddings in their algorithms. A left embedding of P in T is an embedding such that the root of P is mapped to the node in T with the smallest postorder number, i.e., the deepest node among the nodes furthest to the left. Our definition of emb(P, T ) only requires that the root is mapped to a deepest node. In the following we show how to compute deep embeddings. The key idea is to build a data structure for T allowing a fast implementation of the following procedures. For all X ⊆ V (T ), Y ⊆ V (T ) × V (T ), and α ∈ Σ define: Parent(X): Nca(Y ): Deep(X): Return the set {parent(x) x ∈ X}. Return the set {nca(y1, y2) (y1, y2) ∈ Y }. Return the set {x ∈ X there is no z ∈ X such that x ≺ z}. MopRight(Y, X): Return the set of pairs R such that for any pair (y1, y2) ∈ Y , (y1, x) ∈ R iff (y2, x) ∈ mop(Y 2, X). MopLeft(X, Y ): Return the set of pairs R such that for any pair (y1, y2) ∈ Y , (x, y2) ∈ R iff (x, y1) ∈ Fl(X, α): mop(X, Y 1). Return the set Deep({fl(x, α) x ∈ X}). Collectively we call these procedures the set procedures. The procedures Parent and Nca are self-explanatory. Deep(X) returns the set of all nodes in X that have no descendants in X. Hence, the returned set is always deep. MopRight and MopLeft are used to iteratively compute minimum ordered pairs. Fl(X, α) returns the deep set of first ancestors with label α of all nodes in X. If we want to specify that a procedure applies to a certain tree T we add the subscript T . With the set procedures we can compute deep embeddings. The following procedure Emb(v), v ∈ V (P ), recursively computes the set of deep occurrences of P (v) in T . Figure 3 illustrates how Emb works on a small example. 7 Procedure Emb(v) 1 Let v1, . . . , vk be the sequence of children of v ordered from left to right. There are three cases: 2 case 1. k = 0 // v is a leaf 3 Compute R := Fl(L(T ), label(v)). 4 case 2. k = 1 5 6 Recursively compute R1 := Emb(v1). Compute R := Fl(Deep(Parent(R1)), label(v)). 7 case 3. k > 1 Let vj be the heavy child of v. Recursively compute Rj := Emb(vj) and set Uj := {(r, r) r ∈ Rj}. for i := j + 1 to k do Recursively compute Ri := Emb(vi) and set Ui := MopRight(Ui−1, Ri). end Set Uj := Uk. for i := j − 1 downto 1 do end Compute R := Fl(Deep(Nca(U1)), label(v)). Recursively compute Ri := Emb(vi) and set Ui := MopLeft(Ri, Ui+1). 8 9 10 11 12 13 14 15 16 17 18 19 if R = ∅ then 21 else 20 stop and report that there is no deep embedding of P (v) in T . Return R. 22 23 To prove the correctness of the Emb procedure we need the following two propositions. The first propo- sition characterizes for node v ∈ V (P ) the set emb(v, T ) using mop, nca, and fl. The second proposition shows that the set U1 computed in case 3 of the Emb procedure is the set mop(Emb(v1), . . . , Emb(vk)). Proposition 1 Let v be a node in P and let v1, . . . , vk be the sequence of children of v ordered from left to right, where k ≥ 2. For any node w ∈ emb(P (v), T ), there exists a pair of nodes (w1, wk) ∈ mop(emb(P (v1), T ), . . . , emb(P (vk), T )) such that w = fl(nca(w1, wk), label(v)). Proof. Since w is the root of an occurrence of P (v) in T there must exist a set of disjoint occurrences of P (v1), . . . , P (vk) in T (w) with roots w1 ⊳ . . . ⊳ wk, such that w is an ancestor of w1, . . . , wk. Since the wi's are ordered w must be an ancestor of nca(w1, wk). Since w is the root of a deep occurrence of P (v) in T it follows that w = fl(nca(w1, wk), label(v)). It remains to show that we can assume (w1, wk) ∈ mop(emb(P (v1), T ), . . . , emb(P (vk), T )). It follows from the previous discussion that (w1, . . . , wk) ∈ Φ(emb(P (v1), T ), . . . , emb(P (vk), T )). Assume for the sake of contradiction that (w1, wk) is not a minimum ordered pair. Then there exists a set of disjoint occurrences of P (v1), . . . , P (vk) in T (w) with roots u1 ⊳ . . . ⊳ uk, such that either w1 ⊳ u1 ⊳ uk E wk or w1 E u1 ⊳ uk ⊳ wk, and (u1, uk) ∈ mop(emb(P (v1), T ), . . . , emb(P (vk), T )). Therefore u = fl(nca(u1, uk), label(v)) is an embed- ding of P (v) in T . Now either w ≺ u contradicting the assumption that w is a deep embedding or w = u in which case (u1, uk) satisfies the properties of the lemma (see also Figure 4(a)). (cid:3) Proposition 2 For j + 1 ≤ l ≤ k, For 1 ≤ l ≤ j − 1, Ul = mop(Emb(vj ), . . . , Emb(vl)), Ul = mop(Emb(vl), . . . , Emb(vk)). 8 (1) (2) P 1 a 4 a 2 3 b a (a) a b a a b a b a (c) a b a a b a b a (e) b a b a b a b a b a T a b a a b a b a (b) a b a a b a b a (d) a b a a b a b a (f) Figure 3: Computing the deep occurrences of P into T depicted in (a) and (b) respectively. The nodes in P are numbered 1 -- 4 for easy reference. (c) Case 1 of Emb: The crossed nodes are the nodes in the set Emb(3). Since 3 and 4 are leaves and label(3) = label(4) we have Emb(3) = Emb(4). (d) Case 2 of Emb: The black nodes are the nodes in the set Emb(2). Note that the middle child of the root of T is not in the set since it is not a deep occurrence. (e) and (f) illustrates the computation of Emb(1) and case 3 of Emb: (e) The two minimal ordered pairs of the sets from (d) and (c). In the procedure R1 is the set from (d) and R2 is the set from (c). The set U1 = {(v, v) v ∈ R1} and the set U2 = MopRight(U1, R2) which corresponds to the pairs shown in (e). The black nodes in the pairs are the nodes from R1 and the crossed nodes are the nodes from R2. Since k = 2 we set U1 = U2. (f) The nearest common ancestors of both pairs shown in (e) is the root node of T which is the only (deep) occurrence of P . 9 w u w2 u1 u2 u3 w3 w1 w1 w w3 w2 w4 (a) (b) Figure 4: (a) For all i, wi and ui are roots of occurrences of P (vi) in T , and w and u is the nearest common ancestor of (w1, w3) and (u1, u3), respectively. Since w1 ⊳ u1 and u3 ⊳ w3 we cannot have u ≺ w. (b) For all i, wi is an embedding of P (vi) in T , (w1, w4) is a minimum ordered pair, and w is the nearest common ancestor of all the wi's. The number of leaves in T (w) is at least P4 i=1 lT (wi) ≥P4 i=1 lP (vi). Proof. We first show Equation (1) by induction on l. For l = j+1 it follows from the definition of MopRight that Ul is the set of minimum ordered pairs of Emb(vj) and Emb(vj+1), i.e., Ul = mop(Emb(vj), Emb(vl)). Hence, assume that l > j + 1. By the induction hypothesis we have Ul = MopRight(Ul−1, Emb(vl)) = MopRight(mop(Emb(vj), . . . , Emb(vl−1)), Rl) . By definition of MopRight, Ul is the set of pairs such that for any pair (rj , rl−1) ∈ mop(Emb(vj ), . . . , Emb(vl−1)), (rj , rl) ∈ Ul iff (rl−1, rl) ∈ mop(mop(Emb(vj ), . . . , Emb(vl−1))2, Rl). By Lemma 1 it follows that (rj , rl) ∈ Ul iff (rj , rl) ∈ mop(Emb(vj ), . . . , Emb(vl)). We can now similarly show Equation (2) by induction on j′ = j − l. By Equation (1) we have Uj = mop(Emb(vj), . . . , Emb(vk)) when we begin computing Uj−1. For j′ = 1 (l = j − 1) it follows from the definition of MopLeft that Uj−1 = mop(Emb(vj−1), Emb(vj)). Hence, assume that j′ > 1. Using Lemma 2 the Equation follows similarly to the proof of Equation (1). (cid:3) By Proposition 2, U1 = mop(Emb(v1), . . . , Emb(vk)). We can now show the correctness of procedure Emb. Lemma 5 For trees P and T and node v ∈ V (P ), Emb(v) computes the set of deep occurrences of P (v) in T . Proof. By induction on the size of the subtree P (v). If v is a leaf, emb(v, T ) is the deep set of nodes in T with label label(v). It immediately follows that emb(v, T ) = Fl(L(T ), label(v)) and thus case 1 follows. Consider cases 2 and 3 of the algorithm. Suppose that v is an internal node with k ≥ 1 children v1, . . . , vk. We show that emb(P (v), T ) = Emb(v). For k = 1 we have that w ∈ Emb(v) implies that label(w) = label(v) and there is a node w1 ∈ Emb(v1) such that fl(parent(w1), label(v)) = w, that is, no node on the path between w1 and w is labeled label(v). By induction Emb(v1) = emb(P (v1), T ) and therefore w is the root of an embedding of P (v) in T . Since Emb(v) is the deep set of all such nodes it follows that w ∈ emb(P (v), T ). Conversely, if w ∈ emb(P (v), T ) then label(w) = label(v), there is a node w1 ∈ emb(P (v1), T ) such that w ≺ w1, and no node on the path between w and w1 is labeled label(v), that is, fl(w1, label(v)) = w. Hence, w ∈ Emb(v). Next consider the case k > 1. By Proposition 2 and the induction hypothesis U1 = mop(emb(P (v1), T ), . . . , emb(P (vk), T )) . We first show that w ∈ emb(P (v), T ) implies that w ∈ Emb(v). By Proposition 1 there exists a pair of nodes (w1, wk) ∈ mop(emb(P (v1), T ), . . . , emb(P (vk), T )) such that w = fl(nca(w1, wk), label(v)). We have 10 (w1, wk) ∈ U1 and it follows directly from the implementation that w ∈ Emb(v). To see that we do not loose w by taking Deep of Nca(U1) assume that w′ = nca(w1, wk) is removed from the set in this step. This means there is a node u in Nca(U1) which is a descendant of w′ and which is still in the set. Since w is the root of a deep occurrence we must have w = fl(w′, label(v)) = fl(u, label(v)). Let w ∈ Emb(v). Then w is the first ancestor with label label(v) of a nearest common ancestor of a pair in U1. That is, label(w) = label(v) and there exists nodes (w1, wk) ∈ mop(emb(P (v1), T ), . . . , emb(P (vk), T )) such that w = fl(nca(w1, wk), label(v)). Clearly, w is the root of an embedding of P (v) in T . Assume for contradiction that w is not a deep embedding, that is, w ≺ u for some node u ∈ emb(P (v), T ). We have just shown that this implies u ∈ Emb(v). Since Emb(v) is a deep set this contradicts w ∈ Emb(v). The set L(T ) is deep and in all three cases of Emb(V ) the returned set is also deep. By induction it follows that the input to Parent, Fl, Nca, and MopRight is always deep. We will use this fact to our advantage in the following algorithms. (cid:3) 4 A Simple Tree Inclusion Algorithm In this section we a present a simple implementation of the set procedures which leads to an efficient tree inclusion algorithm. Subsequently, we modify one of the procedures to obtain a family of tree inclusion algorithms where the complexities depend on the solution to a well-studied problem known as the tree color problem. 4.1 Preprocessing To compute deep embeddings we require a data structure for T which allows us, for any v, w ∈ V (T ), to compute ncaT (v, w) and determine if v ≺ w or v ⊳ w. In linear time we can compute pre(v) and post(v) for all nodes v ∈ V (T ), and with these it is straightforward to test the two conditions. Furthermore, Lemma 6 (Harel and Tarjan [21]) For any tree T there is a data structure using O(nT ) space and pre- processing time which supports nearest common ancestor queries in O(1) time. Hence, our data structure uses linear preprocessing time and space (see also [2, 7] for more recent nearest common ancestor data structures). 4.2 Implementation of the Set Procedures To answer tree inclusion queries we give an efficient implementation of the set procedures. The idea is to represent sets of nodes and sets of pairs of nodes in a left-to-right order using linked lists. For this purpose we introduce some helpful notation. Let X = [x1, . . . , xk] be a linked list of nodes. The length of X, denoted X, is the number of elements in X and the list with no elements is written []. The ith node of X, denoted X[i], is xi. Given any node y the list obtained by appending y to X, is the list X ◦ y = [x1, . . . , xk, y]. If for all i, 1 ≤ i ≤ X − 1, X[i] ⊳ X[i + 1] then X is ordered and if X[i] E X[i + 1] then X is semiordered. Recall that X[i] E X[i + 1] means that we can have X[i] ⊳ X[i + 1] or either of the nodes can be an ancestor of the other (X[i] ⊳ X[i + 1] or X[i] (cid:22) X[i + 1] or X[i] (cid:23) X[i + 1]). A list Y = [(x1, zk), . . . , (xk, zk)] is a node pair list. By analogy, we define length, append, etc. for Y . For a pair Y [i] = (xi, zi) define Y [i]1 = xi and Y [i]2 = zi. If the lists [Y [1]1, . . . , Y [k]1] and [Y [1]2, . . . , Y [k]2] are both ordered or semiordered then Y is ordered or semiordered, respectively. The set procedures are implemented using node lists. All lists used in the procedures are either ordered or semiordered. As noted in Section 3 we may assume that the inputs to all of the procedures, except Deep, represent deep sets, that is, the corresponding node list or node pair list is ordered. We assume that the input list given to Deep is semiordered and the output, of course, is ordered. Hence, the output of all the other set procedures must be semiordered. In the following let X be a node list, Y a node pair list, and α a character in Σ. The detailed implementation of the set procedures is given below. We show the correctness in Section 4.3 and discuss the complexity in Section 4.4. 11 Y [i′]2 Y [i]2 x (a) X[j] Y [i′]2 x = X[j] Y [i]2 (b) Figure 5: Case 1 and 2 from the implementation of MopRight. (a) We have x⊳X[j] and therefore Y [i]2 ⋪ x. So (y, x) is inserted in R. (b) We have Y [i′]2 ⊳ Y [i]2 ⊳ x = X[j]. Procedure Parent(X) 1 Return the list [parent(X[1]), . . . , parent(X[X])]. Procedure Nca(Y ) 1 Return the list [nca(Y [1]), . . . , nca(Y [Y ])]. Procedure Deep(X) 1 Initially, set x := X[1] and R := []. 2 for i := 2 to X do Compare x and X[i]. There are three cases: case 1. x ⊳ X[i] 3 4 Set R := R ◦ x and x := X[i]. case 2. x ≺ X[i] Set x := X[i]. case 3. X[i] (cid:22) x Do nothing. 5 6 7 8 9 10 11 end 12 Return R ◦ x. The implementation of procedure Deep takes advantage of the fact that the input list is semiordered. In case 1 the node X[i] is to the right of our "potential output node" x. Since any node that is a descendant of x must also be to the left of X[i] it cannot appear later in the list X than X[i]. We can thus safely add x to R at this point. In case 2 the node x is an ancestor of X[i] and thus x cannot be in Deep(X). In case 3 the node X[i] is an ancestor of x and can therefore not be in Deep(X). In procedure MopRight we have a "potential pair" (y, x) where y = Y [i′]1 for some i′ and Y [i′]2 ⊳ x. In case 1 we have x ⊳ X[j] and also Y [i′]2 ⊳ Y [i]2 since the input lists are ordered and i′ < i (see Figure 5(a)). Therefore, (y, x) is inserted into R. In case 2 we have x = X[j], i.e., Y [i]2 ⊳x, and as before Y [i′]2 ⊳Y [i]2 (see Figure 5(b)). Therefore (y, x) cannot be in MopRight(Y, X), and we set (Y [i]1, x) to be the new potential pair. We can implement MopLeft(X, Y ) similarly to MopRight replacing smallest by largest, ⊳ by ⊲, and traversing the lists backwards: 12 Procedure MopRight(Y ,X) 1 Initially, set R := []. 2 Find the smallest j such that Y [1]2 ⊳ X[j] and set y := Y [1]1, x := X[j]. If no such j exists stop and return R. 5 3 for i := 2 to Y do until Y [i]2 ⊳ X[j] or j > X do set j := j + 1. if j > X then else 8 4 6 7 stop and return R := R ◦ (y, x). Compare X[j] and x. There are two cases: case 1. x ⊳ X[j] case 2. If x = X[j] set R := R ◦ (y, x), y := Y [i]1, and x := X[j]. set y := Y [i]1. 9 10 11 12 13 14 15 3 4 5 6 7 8 9 10 11 12 16 end 17 Return R := R ◦ (y, x). Procedure Fl(X,α) 1 Initially, set L := X, Z := L. 2 while Z 6= [] do for i := 1 to Z do case 1. label(Z[i]) = α Delete Z[i] from Z (but keep it in L). Replace Z[i] with parent(Z[i]) in both Z and L. case 2. label(Z[i]) 6= α and parent(Z[i]) 6= ⊥ case 3. label(Z[i]) 6= α and parent(Z[i]) = ⊥ Delete Z[i] from both Z and L. end Set (Z, L) := Deep∗(Z, L). 13 end 14 Return L. The procedure Fl computes the set Deep({fl(x, α)x ∈ X}) bottom up. The list Z contains ancestors of the elements of X for which we have not yet found an ancestor with label α. In each step it considers each node z in the list Z. If it has the right label then x ∈ Fl(X, α) and we remove it from Z but keep it in L. Otherwise we replace it with its parent (unless it is the root). Thus L contains both the elements in Z and the part of Fl(X, α) found until now. To keep the running time down we wish to maintain the invariant that L is deep at the beginning of each iteration of the outer loop. To do this procedure Fl calls an auxiliary procedure Deep∗(Z, L) which takes two ordered lists Z and L, where Z ⊆ L, and returns two ordered lists representing the set Deep(L)∩ Z and Deep(L), i.e., Deep∗(Z, L) = ([z ∈ Z∄x ∈ L : z ≺ x], Deep(L)). If we use the procedure Deep to calculate Deep∗ it takes time O(Z + L) = O(L). Instead we will show how to calculate it in time O(Z) using a linked list representation for Z and L. We will need this in the proof of Lemma 12, which shows that the total running time of all calls to Fl from Emb takes time O(nT ). Below we describe in more detail how to implement Fl together with the auxiliary procedures. 13 Procedure MopLeft(X,Y ) 1 Initially, set R := []. 2 Find the largest j such that Y [Y ]1 ⊲ X[j] and set y := Y [Y ]2 and x := X[j]. If no such j exists 3 for i := Y − 1 to 1 do stop and return R. until Y [i]1 ⊲ X[j] or j < 1 do 4 5 6 7 8 9 10 11 12 13 14 15 16 if j < 1 then set j := j − 1. stop and return R := (x, y) ◦ R. compare X[j] and x. There are two cases: case 1. x ⊲ X[j] else set R := (x, y) ◦ R, y := Y [i]2, and x := X[j]. case 2. x = X[j] set y := Y [i]2. end 17 end 18 Return R := (x, y) ◦ R. We use a doubly linked list to represent L and extra pointers in this list to represent Z. Each element in the list has pointers SuccL and PredL pointing to its predecessor and successor in L. Similarly, each element in Z has pointers SuccZ and PredZ pointing to its predecessor and successor in Z (right after the initialization these are equal to SuccL and PredL). In the for loop we use the SuccZ pointers to find the next element in Z. To delete Z[i] from Z in case 1 we set SuccZ (PredZ (Z[i])) = SuccZ(Z[i]) and PredZ (SuccZ(Z[i])) = PredZ(Z[i]). The L pointers stay the same. In case 2 we simply replace Z[i] with its parent in the linked list. The Succ and Pred pointers stay the same. To delete Z[i] from both Z and L in case 3 we set Succj(Predj(Z[i])) = Succj(Z[i]) and Predj(Succj(Z[i])) = Predj(Z[i]) for j ∈ {Z, L}. Finally, to compute Deep∗(Z, L) walk through Z following the SuccZ pointers. At each node z compare PredL(z) and SuccL(z) with z. If one of them is a descendant of z remove z from the doubly linked list Z and L as in case 3. Note that instead of calling Deep∗(Z, L) this comparison can also be done directly in step 2, which is the only place where we insert nodes that might be an ancestor of another node in L. We will show in the next section that it is enough to compare z to its neighbors in the list L. 4.3 Correctness of the Set Procedures Clearly, Parent and Nca are correct. The following lemmas show that Deep, Fl, and MopRight are also correctly implemented. For notational convenience we write x ∈ X, for a list X, if x = X[i] for some i, 1 ≤ i ≤ X. Lemma 7 Procedure Deep(X) is correct. Proof. Let x be the variable in the procedure. We will first prove the following invariant on x: Invariant At the beginning of each iteration of the for loop in line 2 we have x 6≺ X[j] for any 1 ≤ j ≤ i− 1. We prove the invariant by induction on i. The invariant obviously holds for the base case i = 2. For the induction step let i ≥ 3. Let iteration k denote the iteration of the for loop when i = k. By the induction hypothesis we have x 6≺ X[j] for any 1 ≤ j ≤ i − 2 at the beginning of iteration i − 1. 14 Let x′ denote the value of the variable x at the beginning of iteration i− 1. Consider the value of variable x at the beginning of the iteration i. There are two cases: 1. If x = x′ then by the induction hypothesis x = x′ 6≺ X[j] for any 1 ≤ j ≤ i − 2. Since x was not changed in iteration i − 1 we have X[i − 1] (cid:22) x (case 3 of the procedure) and thus x 6≺ X[j] for any 1 ≤ j ≤ i − 1. 2. If x 6= x′ then x was set in either case 1 (x′ ⊳ x) or case 2 (x′ ≺ x) in iteration i − 1. Therefore, x = X[i− 1] and by the induction hypothesis x′ 6≺ X[j] for any 1 ≤ j ≤ i − 2. There are two subcases: (a) If x′ ≺ x it follows immediately from the induction hypothesis that x 6≺ X[j] for any 1 ≤ j ≤ i− 1, since all descendants of x also are descendants of x′. (b) If x′ ⊳ x we note that x is the first node to the left of x′ occuring after x′ in X (otherwise x would have been reset in case 1 of the procedure in an earlier iteration, contradicting that x′ is the value of variable x at the beginning of iteration i − 1). Since X is semiordered no node X[j] with smaller index in X than x′ can be to the right of x′. Thus no node X[j], 1 ≤ j < i − 2, can be to the right of x′. Since all descendants of x must be to the right of x′ we have x 6≺ X[j] for any 1 ≤ j ≤ i − 1. We are now ready to prove that y ∈ Deep(X) iff there exists no z ∈ X such that y ≺ z. We first argue that if y ∈ Deep(X) then ∄z ∈ X such that y ≺ z. Let y be an element in Deep(X). Only elements that have been assigned to x during the procedure are in the output. Consider the iteration where x = y is appended to R. This only happens in case 1 of the procedure and thus y = x ⊳ X[i]. Since X is semiordered this implies that x ⊳ X[j] for i ≤ j ≤ X, and therefore y = x 6≺ X[j] for i ≤ j ≤ X. By the above invariant it follows that y = x 6≺ X[j] for 1 ≤ j ≤ i − 1. Thus if y ∈ Deep(X) then ∄z ∈ X such that y ≺ z. Let y ∈ X be an element such that X ∩ V (T (y)) = {y}. Let j be the smallest index such that X[j] = y. When comparing y and x during the iteration where i = j we are in case 1 or 2, since j is the smallest index such that X[j] = y (implying x 6= y) and X ∩ V (T (y)) = {y} (implying y 6≺ x). In either case x is set to y. Since there are no descendants of y in X, the variable x remains equal to y until added to R. If y occurs several times in X we will have x = y each time we meet a copy of y (except the first) and it follows from the implementation that y will occur exactly once in R. (cid:3) To show that the implementation of MopRight is correct we will use the following proposition. At the end of each iteration of the for loop then, unless Y [i]2 6⊳X[X], we have y = Y [i]1, x = X[j] and Proposition 3 Before the first iteration of the for loop in line 3 of MopRight we have y = Y [1]1, x = X[j] and either X[j − 1] ⊳ Y [1]2 ⊳ X[j] (if j > 1) or Y [1]2 ⊳ X[j] if (j = 1). either X[j − 1] ⊳ Y [i]2 ⊳ X[j] (if j > 1) or Y [i]2 ⊳ X[j] if (j = 1). Proof. The first statement (y = Y [1]1, x = X[j] and either X[j − 1] ⊳ Y [1]2 ⊳ X[j] (if j > 1) or Y [1]2 ⊳ X[j] if (j = 1)) follows immediately from the implementation of the procedure line 2 and the fact that the input lists are ordered. We prove the second statement by induction on i. Base case i = 2. By the first statement we have y = Y [1]1, x = X[j] and either X[j − 1] ⊳ Y [1]2 ⊳ X[j] (if j > 1) or Y [1]2 ⊳ X[j] if (j = 1) before this iteration. Let j′ be the value of j before this iteration. It follows immediately from the implementation that y = Y [2]1 since y is set to this in both case 1 and 2. If Y [2]2 ⊳ X[j′] then j = j′. Since Y is ordered it follows that X[j − 1] ⊳ Y [1]2 ⊳ Y [2]2 ⊳ X[j] (if j > 1) or Y [2]2 ⊳ X[j] if (j = 1). If Y [2]2 6⊳X[j′] then j is increased until Y [2]2 ⊳ X[j] implying X[j − 1] ⊳ Y [2]2 ⊳ X[j] unless j > X, since X is ordered. Induction step i > 2. It follows immediately from the implementation that y = Y [i]1 since y is set to this in both case 1 and 2. By the induction hypothesis we have y = Y [i]1, x = X[j] and Y [i]2 ⊳ X[j] right before this iteration. Let j′ be the value of j before this iteration. If Y [i]2 ⊳ X[j′] then j = j′. Since Y is ordered it follows that X[j − 1] ⊳ Y [i− 1]2 ⊳ Y [i]2 ⊳ X[j] (if j > 1) or Y [i]2 ⊳ X[j] if (j = 1). If Y [i]2 6⊳X[j′] then j is increased until Y [i]2 ⊳ X[j] implying X[j − 1] ⊳ Y [i]2 ⊳ X[j] unless j > X. (cid:3) 15 Lemma 8 Procedure MopRight(Y, X) is correct. Proof. We want to show that for any 1 ≤ i′ ≤ Y , 1 ≤ j′ ≤ X: (Y [i′]1, X[j′]) ∈ R ⇔ (Y [i′]2, X[j′]) ∈ mop(Y 2, X) . Since Y 2 and X are ordered lists we have (Y [i′]2, X[j′]) ∈ mop(Y 2, X) if and only if (1) arg minj Y [i′]2 ⊳ X[j] = j′ (2) arg maxi Y [i]2 ⊳ X[j′] = i′ We will first show that (1) and (2) implies (Y [i′]2, X[j′]) ∈ R. We start by showing that when i is about to be incremented to i′ + 1 then y = Y [i′]1 and x = X[j′]. There are two cases to consider. • i′ = 1. After line 2 is executed, y is set to Y [1]1, j is set to j′ and x is set to X[j′]. • i′ > 1. Consider the step in the iteration when i = i′. At the beginning of this iteration, y = Y [i′ − 1] and j is the minimal index such that Y [i′ − 1] ⊳ X[j]. By (1) this implies that j ≤ j′, and that after line 4 and 5 are executed, j is set to j′. At the end of the iteration y = Y [i′] (y is assigned to Y [i′] in both cases) and x = X[j′]. If j = j′ then x set to X[j′] in case 1, otherwise we had j = j′ (case 2) and then x was set to X[j′] already). We have established that when i is about to be incremented to i′ + 1 then y = Y [i′]1 and x = X[j′]. To show that (Y [i′]2, X[j′]) ∈ R we consider the following two cases. • i′ < Y . Consider the (i′ +1)th iteration. By condition (2) X[j′] EY [i′ +1]2 and therefore j is increased in line 5. So now j > j′. If j > X then (y, x) = (Y [i′]2, X[j′]) is added to R in line 7. Otherwise, since X is ordered, x = X[j′] ⊳ X[j]. We are therefore in case 1 and (y, x) = (Y [i′]2, X[j′]) is added to R. • i′ = Y . Then (y, x) = (Y [i′]2, X[j′]) is added to R in line 15. We will now show that (Y [i′]1, X[j′]) ∈ R implies (1) and (2). Since (Y [i′]1, X[j′]) ∈ R we had (y, x) = (Y [i′]1, X[j′]) at some point during the execution. The pair (y, x) can be added to R only in the for loop before changing the values of y and x or at the execution of the last line of the procedure. Therefore (y, x) = (Y [i′]1, X[j′]) at the beginning of some execution of the for loop, or after the last iteration (i = Y ). It follows by Proposition 3 that X[j − 1] ⊳ Y [i]2 ⊳ X[j] if j > 1 or Y [i]2 ⊳ X[j] if j = 1. It remains to show that X[j′] ⊳ Y [i′ + 1]2 for i′ < Y . It follows from the implementation that (y, x) only is added to R inside the for loop if j is increased. Thus j was increased in the next iteration (i = i′ + 1) implying X[j′] ⊳ Y [i′ + 1]2. (cid:3) Lemma 9 Procedure MopLeft(X, Y ) is correct. Proof. Similar to the proof of Lemma 8. To show that Fl is correct we need the following proposition. (cid:3) Proposition 4 Let X be an ordered list and let x be an ancestor of X[i] for some i ∈ {1, . . . , k}. If x is an ancestor of some node in X other than X[i] then x is an ancestor of X[i − 1] or X[i + 1]. 16 Proof. Recall that u⊳v iff pre(u) < pre(v) and post(u) < post(v). Since x ≺ X[i] we have pre(x) < pre(X[i]) and post(X[i]) < post(x). Assume there exists a descendant X[j] of x such that j 6∈ {i − 1, i, i + 1}. If j < i − 1 we have pre(x) ≤ pre(X[j]) < pre(X[i − 1]), where the first inequality follows from x ≺ X[j] and the second from X being ordered. And post(X[i − 1]) < post(X[i]) ≤ post(x), where the first inequality follows from X being ordered and the second from x ≺ X[i]. Thus x ≺ X[i − 1]. Similarly, for j > i + 1, we have pre(x) ≤ pre(X[i]) < pre(X[i + 1]) and post(X[i + 1]) < post(X[j]) ≤ post(x) implying that x ≺ X[i + 1]. Proposition 4 shows that the doubly linked list implementation of Deep∗ is correct. Since all changes to the list are either deletions or insertions of a parent in the place of its child, the list L (and thus also Z) is ordered at the beginning of each iteration of the outer loop. (cid:3) Lemma 10 Procedure Fl(X, α) is correct. Proof. Let F = {fl(x, α) x ∈ X}. We first show that Fl(X, α) ⊆ F . Consider a node x ∈ Fl(X, α). Since x is in L after the final iteration, x was deleted from Z during some iteration. Thus label(x) = α. For any y ∈ X we follow the path from y to the root and stop the first time we meet a node with label α or even earlier since we keep the list deep. Thus x ∈ F . The set Fl(X, α) is a deep set, and therefore Deep(F ) ⊆ Fl(X, α) ⊆ F ⇒ Deep(F ) = Fl(X, α). Hence, it remains to show that Deep(F ) ⊆ Fl(X, α). Let x be a node in Deep(F ), let z ∈ X be a node such that x = fl(z, α), and let z = x1, x2, . . . , xk = x be the nodes on the path from z to x. We will argue that after each iteration of the algorithm we have xi ∈ L for some i. Since label(xi) 6= α for i < k this is the same as xi ∈ Z for i < k. Before the first iteration we have x1 ∈ X = Z. As long as i < k we replace xi with xi+1 in case 2 of the for loop, since label(xi) 6= α. When i = k we remove xk from Z but keep it in L. It remains to show that we do not delete xi in the computation of Deep∗(Z, L) in any iteration. If xi is removed then there is a node y ∈ L that is a descendant of xi and thus also a descendant of x. We argued above that L\ Z ⊆ F and thus y ∈ Z since x ∈ Deep(F ). But since x ∈ Deep(F ) no node on the path from y to x can have label α and therefore xi will eventually be reinserted in Z. (cid:3) 4.4 Complexity of the Set Procedures For the running time of the node list implementation observe that, given the data structure described in Section 4.1, all set procedures, except Fl, perform a single pass over the input using constant time at each step. Hence we have, Lemma 11 For any tree T there is a data structure using O(nT ) space and preprocessing which supports each of the procedures Parent, Deep, MopRight, MopLeft, and Nca in linear time (in the size of their input). The running time of a single call to Fl might take time O(nT ). Instead we will divide the calls to Fl into groups and analyze the total time used on such a group of calls. The intuition behind the division is that for a path in P the calls made to Fl by Emb are done bottom up on disjoint lists of nodes in T . Lemma 12 For disjoint ordered node lists X1, . . . , Xk and labels α1, . . . , αk, such that any node in Xi+1 is an ancestor of some node in FlT (Xi, αi), 1 ≤ i < k, all of FlT (X1, α1), . . . , FlT (Xk, αk) can be computed in O(nT ) time. 17 Let Z and L be as in the implementation of the procedure. Since Deep∗ takes time O(Z) and Proof. each of the steps in the for loop takes constant time, we only need to show that the total length of the lists Z -- summed over all the calls -- is O(nT ) to analyze the total time usage. We will show that any node in T can be in Z at the beginning of the while loop at most twice during all calls to Fl. The size of Z cannot increase in the iterations of the for loop (line 3 -- 10), and thus the size of Z when Deep∗ is called (line 11) is at most the size of Z at the beginning of this iteration of the while loop. Consider a single call to Fl. Except for the first iteration, a node can be in Z only if one of its children were in Z in the last iteration. Note that Z is ordered at the beginning of each for loop. Thus if a node is in Z at the beginning of the while loop none of its children are in Z and thus in one call to Fl a node can be in Z only once. Look at a node z the first time it appears in Z at the beginning of an execution of the while loop. Assume that this is in the call Fl(Xi, αi). • If z ∈ Xi then z cannot be in Z in any later calls, since no node in Xj where j > i can be a descendant of a node in Xi. • If label(z) 6= αi then z is removed from Z in case 2 or case 3 of the procedure and cannot be in Z in any of the later calls. To see this consider the time when z is removed from Z (case 2 or case 3). Since the set L is deep at the beginning of the while loop and Z ⊆ L, no descendant of z will appear in Z later in this call to Fl, and no node in the output from Fl(Xi, αi) can be a descendant of z. Since any node in Xj, j > i, is an ancestor of some node in Fl(Xi, αi) neither z or any descendant of z can be in any Xj, j > i. Thus z cannot appear in Z in any later calls to Fl. • Now if label(z) = αi then we might have z ∈ Xi+1. In that case, z will appear in Z in the first iteration of the procedure call Fl(Xi+1, αi), but not in any later calls since the lists are disjoint, and since no node in Xj where j > i + 1 can be a descendant of a node in Xi+1. If label(z) = αi and z 6∈ Xi+1 then clearly z cannot appear in Z in any later call. Thus a node in T is in Z at the beginning of an execution of the while loop at most twice during all the calls. (cid:3) 4.5 Complexity of the Tree Inclusion Algorithm Using the node list implementation of the set procedures we get: Lemma 13 For trees P and T the tree inclusion problem can be solved in O(lP nT ) time. Proof. By Lemma 11 we can preprocess T in O(nT ) time and space. Let g(n) denote the time used by Fl on a list of length n. Consider the time used by Emb(root(P )). We bound the contribution for each node v ∈ V (P ). If v is a leaf we are in case 1 of Emb. The cost of computing Fl(L(T ), label(v)) is O(g(lT )), and by Lemma 12 (with k = 1) we get O(g(lT )) = O(nT ). Hence, the total cost of all leaves is O(lP nT ). If v has a single child w we are in case 2 of Emb, and by Lemma 11 the cost is O(g(Emb(w))). If v has more than one child the cost of MopRight, Nca, and Deep is bounded by Pw∈child(v) O(Emb(w)). Furthermore, since the length of the output of MopRight (and thus Nca) is at most z = minw∈child(v) Emb(w) the cost of Fl is O(g(z)). Hence, the total cost for internal nodes is, Xv∈V (P )\L(P ) O(cid:18)g( min w∈child(v)Emb(w)) + Xw∈child(v) Emb(w)(cid:19) = Xv∈V (P ) O(g(Emb(v))) . (3) Next we bound (3). For any w ∈ child(v) we have that Emb(w) and Emb(v) are disjoint ordered lists. Furthermore we have that any node in Emb(v) must be an ancestor of some node in Fl(Emb(w), label(v)). 18 Hence, by Lemma 12, for any leaf to root path δ = v1, . . . , vk in P , we have thatPu∈δ g(Emb(u)) = O(nT ). Let ∆ denote the set of all root to leaf paths in P . It follows that, Xv∈V (T ) g(Emb(v)) ≤ Xp∈∆Xu∈p g(Emb(u)) = O(lP nT ) . Since this time is the same as the time spent at the leaves the time bound follows. To analyze the space used by the algorithm we first bound the size of Emb(v) for each node v ∈ V (P ). We then use this to bound the total the size of embeddings stored in the recursion stack in the computation of Emb(root(P )), i.e., the total size of embeddings stored by recursive calls during the computation. (cid:3) Lemma 14 For any tree P we have ∀v ∈ V (P ): EmbT (v) ≤ lT lP (v) . Proof. By Lemma 5 Emb(v) is the set of deep occurrences of P (v) in T . By the definition of deep the occurrences are disjoint and no node in one occurrence can be an ancestor of a node in another occurrence. Each occurrence has at least lP (v) descendant leaves and each of these leaves is an ancestor of at least one distinct leaf in T (see also Figure 4(b)). Thus the number of occurrences is bounded by lT /lP (v). (cid:3) Lemma 15 The total size of saved embeddings on the recursion stack at any time during the computation of Emb(root(P )) is at most O(lT ). Proof. Let node v be the node for which we are currently computing Emb. Let p be the path from the root to v and let w0, . . . , wℓ be the light nodes on this path. Let ℓ = ldepth(v). There is one embedding on the stack for each light node on the path (see Figure 6): For the heavy nodes on the path there can be no saved embeddings in the recursion as the algorithm always recurses on the heavy child first. For each light node wi on the path p except the root w0 the stack will contain either Emb(heavy(parent(wi))), or Uj = MopRight(Uj−1, Rj), where vj is wi's left sibling, or Uj = MopLeft(Uj−1, Rj), where vj is wi's right sibling. The computation of Uj is a series of MopRight (or MopLeft) computations that started with the pair of node lists (Emb(heavy(parent(wi))), Emb(heavy(parent(wi)))) as the first argument to MopRight (or MopLeft). As the output of MopRight (or MopLeft) can be no larger than the input to the procedure we have Uj = O(Emb(heavy(parent(wi)))) and thus the total space used at any time during the recursion is ldepth(v) By Lemma 14 we have O(cid:0) Xi=1 Emb(heavy(parent(wi)))(cid:1) . Emb(heavy(parent(wi))) ≤ lT lP (heavy(parent(wi))) , and thus ldepth(v) ldepth(v) Xi=1 Emb(heavy(parent(wi))) ≤ lT 1 lP (heavy(parent(wi))) . Xi=1 By the definition of heavy the node heavy(parent(wi)) has more leaves in its subtree than wi, i.e., Obviously, heavy(parent(wi)) has no more leaves in its subtree than its parent, i.e., lP (wi) ≤ lP (heavy(parent(wi))) . lP (heavy(parent(wi))) ≤ lP (parent(wi)) . 19 (4) (5) (6) w0 heavy(parent(w1)) w1 heavy(parent(w2)) w2 w3 heavy(parent(w3)) heavy(parent(w4)) v = w4 Figure 6: Path from root to v. The heavy nodes are black and the light nodes are white. The heavy edges are the thick edges and the light edges are thin. Since wi is light it has at most half the number of leaves in its subtree as its parent, that is Combining this with the fact that wi is an ancestor of wi+1 and heavy(parent(wi+1)) we get, lP (wi) ≤ lP (parent(wi))/2 . (7) lP (heavy(parent(wj )) ≤ lP (parent(wj )) by (6) ≤ lP (wj−1) ≤ lP (parent(wj−1))/2 ≤ lP (wj−2)/2 ≤ lP (heavy(parent(wj−2)))/2, by (5) by (7) since wj−1 is an ancestor of wj since wj−2 is an ancestor of parent(wj−1) for any 2 < j ≤ ldepth(v). Let li = lP (heavy(parent(wi))) for all i. To bound the sum in (4) we will use that li ≤ li−2/2, li < li−1, and lldepth(v) ≥ 1. We have ldepth(v) Xi=1 1 li ≤ 2 ldepth(v) Xi=2,i odd 1 li ≤ 2 · 2 = 4, since the li's in the last sum are decreasing with a factor of 2. Combining this with Equation (4) we get ldepth(v) Xi=1 Emb(heavy(parent(wi))) ≤ lT ldepth(v) Xi=1 1 lP (heavy(parent(wi))) ≤ 4lT . (cid:3) Theorem 2 For trees P and T the tree inclusion problem can be solved in O(lP nT ) time and O(nT ) space. Proof. The time bound follows from Lemma 13. Next consider the space used by Emb(root(P )). The preprocessing of Section 4.1 uses only O(nT ) space. By Lemma 15 the space used for the saved embeddings is O(lT ) = O(nT ). (cid:3) 20 4.6 An Alternative Algorithm In this section we present an alternative algorithm. Since the time complexity of the algorithm in the previous section is dominated by the time used by Fl, we present an implementation of this procedure which leads to a different complexity. Define a firstlabel data structure as a data structure supporting queries of the form fl(v, α), v ∈ V (T ), α ∈ Σ. Maintaining such a data structure is known as the tree color problem. This is a well-studied problem, see e.g. [5, 16, 18, 31]. With such a data structure available we can compute Fl as follows, Fl(X, α): Return the list Deep([fl(X[1], α), . . . , fl(X[X], α)]). Theorem 3 Let P and T be trees. Given a firstlabel data structure using s(nT ) space, p(nT ) preprocessing time, and q(nT ) time for queries, the tree inclusion problem can be solved in O(p(nT ) + lP lT · q(nT )) time and O(s(nT ) + nT ) space. Proof. Constructing the firstlabel data structures uses O(s(nT )) space and O(p(nT )) time. The total cost of the leaves is bounded by O(lplT · q(nT )), since the cost of a single leaf is O(lT · q(nT )). As in the proof of Theorem 2 we have that the total time used by the internal nodes is bounded by Pv∈V (P ) g(Emb(v)), where g(n) is the time used by Fl on a list of length n, that is, g(n) ≤ n·q(nT ). By Lemma 11 and Lemma 15 for any leaf to root path δ = v1, . . . , vk in P , we have that Pu∈δ Emb(u) ≤ O(lT ). Let ∆ denote the set of all root to leaf paths in P . It follows that, Xv∈V (P ) g(Emb(v)) ≤ Xp∈∆Xu∈p g(Emb(u)) ≤ Xp∈∆ O(lT · q(nT )) ≤ O(lP lT · q(nT )). Since this time is the same as the time spent at the leaves the time bound follows. (cid:3) Several firstlabel data structures are available, for instance, if we want to maintain linear space we have, Lemma 16 (Dietz [16]) For any tree T there is a data structure using O(nT ) space, O(nT ) expected pre- processing time which supports firstlabel queries in O(log log nT ) time. The expectation in the preprocessing time is due to perfect hashing. Since our data structure does not need to support efficient updates we can remove the expectation by using the deterministic dictionary of Hagerup et al. [20]. This gives a worst-case preprocessing time of O(nT log nT ). However, using a simple two-level approach this can be reduced to O(nT ) (see e.g. [38]). Plugging in this data structure we obtain, Corollary 2 For trees P and T the tree inclusion problem can be solved in O(lP lT log log nT + nT ) time and O(nT ) space. 5 A Faster Tree Inclusion Algorithm In this section we present a new tree inclusion algorithm which has a worst-case subquadratic running time. As discussed in the introduction, the general idea is to divide T into clusters of logarithmic size which we can efficiently preprocess and then use this to speed up the computation with a logarithmic factor. 5.1 Clustering In this section we describe how to divide T into clusters and how the macro tree is created. For simplicity in the presentation we assume that T is a binary tree. If this is not the case it is straightforward to construct a binary tree B, where nB ≤ 2nT , and a mapping g : V (T ) → V (B) such that for any pair of nodes v, w ∈ V (T ), label(v) = label(g(v)), v ≺ w iff g(v) ≺ g(w), and v ⊳ w iff g(v) ⊳ g(w). The nodes in the set U = V (B)\{g(v) v ∈ V (T )} are assigned a special label β 6∈ Σ. It follows that for any tree P , P ⊑ T iff P ⊑ B. 21 Let C be a connected subgraph of T . A node in V (C) adjacent to a node in V (T )\V (C) is a boundary node. The boundary nodes of C are denoted by δC. We have root(T ) ∈ δC if root(T ) ∈ V (C). A cluster of C is a connected subgraph of C with at most two boundary nodes. A set of clusters CS is a cluster partition of T iff V (T ) = ∪C∈CSV (C), E(T ) = ∪C∈CSE(C), and for any C1, C2 ∈ CS, E(C1) ∩ E(C2) = ∅, E(C1) ≥ 1. If δC = 1 we call C a leaf cluster and otherwise an internal cluster. We use the following recursive procedure ClusterT (v, s), adopted from [6], which creates a cluster partition CS of the tree T (v) with the property that CS = O(s) and V (C) ≤ ⌈nT /s⌉ for each C ∈ CS. A similar cluster partitioning achieving the same result follows from [3, 4, 19]. ClusterT (v, s): For each child u of v there are two cases: 1. V (T (u)) + 1 ≤ ⌈nT /s⌉. Let the nodes {v}∪ V (T (u)) be a leaf cluster with boundary node v. 2. V (T (u)) ≥ ⌈nT /s⌉. Pick a node w ∈ V (T (u)) of maximum depth such that V (T (u)) + 2−V (T (w)) ≤ ⌈nT /s⌉. Let the nodes V (T (u))\V (T (w))∪{v, w} be an internal cluster with boundary nodes v and w. Recursively, compute ClusterT (w, s). Lemma 17 Given a tree T with nT > 1 nodes, and a parameter s, where ⌈nT /s⌉ ≥ 2, we can build a cluster partition CS in O(nT ) time, such that CS = O(s) and V (C) ≤ ⌈nT /s⌉ for any C ∈ CS. Proof. The procedure ClusterT (root(T ), s) clearly creates a cluster partition of T and it is straightforward to implement in O(nT ) time. Consider the size of the clusters created. There are two cases for u. In case 1, V (T (u)) + 1 ≤ ⌈nT /s⌉ and hence the cluster C = {v} ∪ V (T (u)) has size V (C) ≤ ⌈nT /s⌉. In case 2, V (T (u)) + 2 − V (T (w)) ≤ ⌈nT /s⌉ and hence the cluster C = V (T (u))\V (T (w)) ∪ {v, w} has size V (C) ≤ ⌈nT /s⌉. Next consider the size of the cluster partition. Let c = ⌈nT /s⌉. We say that a cluster C is bad if V (C) ≤ c/2 and good otherwise. We will show that at least a constant fraction of the clusters in the cluster partition are good. It is easy to verify that the cluster partition created by procedure Cluster has the following properties: (i) Let C be a bad internal cluster with boundary nodes v and w (v ≺ w). Then w has two children with at least c/2 descendants each. (ii) Let C be a bad leaf cluster with boundary node v. Then the boundary node v is contained in a good cluster. By (ii) the number of bad leaf clusters is at most twice the number of good internal clusters and by (i) each bad internal cluster has two child clusters. Therefore, the number of bad internal clusters is bounded by the number of leaf clusters. Let bi and gi denote the number of bad and good internal clusters, respectively, and let bl and gl denote the number of bad and good leaf clusters, respectively. We have and therefore the number of bad clusters is bounded by bi ≤ bl + gl ≤ 2gi + gl, bl + bi ≤ 2gi + gl + 2gi = 4gi + gl . Thus the number of bad clusters is at most 4 times the number of good clusters, and therefore at most a constant fraction of the total number of clusters. Since a good cluster is of size more than c/2, there can be at most 2s good clusters and thus CS = O(s). (cid:3) Let C ∈ CS be an internal cluster with v, w ∈ δC. The spine path of C is the path between v, w excluding v and w. A node on the spine path is a spine node. A node to the left and right of v or of any node on 22 v w (a) v (c) v s(v, w) l(v, w) r(v, w) w (b) v l(v) (d) Figure 7: The clustering and the macro tree. (a) An internal cluster. The black nodes are the boundary nodes and the internal ellipses correspond to the boundary nodes, the right and left nodes, and spine path. (b) The macro tree corresponding to the cluster in (a). (c) A leaf cluster. The internal ellipses are the boundary node and the leaf nodes. (d) The macro tree corresponding to the cluster in (c). the spine path is a left node and right node, respectively. If C is a leaf cluster with v ∈ δC then any proper descendant of v is a leaf node. Let CS be a cluster partition of T as described in Lemma 17. We define an ordered macro tree M . Our definition of M may be viewed as an "ordered" version of the macro tree defined in [6]. The node set V (M ) consists of the boundary nodes in CS. Additionally, for each internal cluster C ∈ CS with v, w ∈ δC, v ≺ w, we have the nodes s(v, w), l(v, w) and r(v, w) and edges (v, s(v, w)), (s(v, w), l(v, w)), (s(v, w), w), and (s(v, w), r(v, w)). That is, the nodes l(v, w), r(v, w) and w are all children of s(v, w). The nodes are ordered so that l(v, w) ⊳ w ⊳ r(v, w). For each leaf cluster C, v ∈ δC, we have the node l(v) and edge (v, l(v)). Since root(T ) is a boundary node, M is rooted at root(T ). Figure 7 illustrates these definitions. With each node v ∈ V (T ) we associate a unique macro node denoted c(v). Let u ∈ V (C), where C ∈ CS. c(u) =   u l(v) s(v, w) l(v, w) r(v, w) if u is boundary node, if u is a leaf node and v ∈ δC, if u is a spine node, v, w ∈ δC, and v ≺ w, if u is a left node, v, w ∈ δC, and v ≺ w, if u is a right node, v, w ∈ δC, and v ≺ w. Conversely, for any macro node i ∈ V (M ) define the micro forest, denoted C(i), as the induced subgraph of T of the set of nodes {v v ∈ V (T ), i = c(v)}. We also assign a set of labels to i given by label(i) = {label(v) v ∈ V (C(i))}. If i is a spine node or a boundary node the unique node in V (C(i)) of greatest depth is denoted by first(i). Finally, for any set of nodes {i1, . . . , ik} ⊆ V (M ) we define C(i1, . . . , ik) as the induced subgraph of the set of nodes V (C(i1)) ∪ ··· ∪ V (C(ik)). The following propositions state useful properties of ancestors, nearest common ancestor, and the left- to-right ordering in the micro forests and in T . The propositions follow directly from the definition of the clustering. See also Figure 8. 23 v′ v w′ (a) w v w v′ w′ (b) v′ v w (c) w v′ v w′ (e) v′ w v w′ (f) v′ v w w′ (d) v v′ w′ w (g) Figure 8: Examples from the propositions. In all cases v′ and w′ are top and bottom boundary nodes of the cluster, respectively. (a) Proposition 5(ii). Here c(v) = s(v′, w′) and c(w) = l(v′, w′) (solid ellipses). The dashed ellipse corresponds to C(c(w), s(v′, w′), v′). (b) Proposition 6(i) and 7(ii). Here c(v) = c(w) = l(v′, w′) (solid ellipse). The dashed ellipse corresponds to C(c(w), s(v′, w′), v′). (c) Proposition 6(ii) and 7(i). Here c(v) = c(w) = l(v′) (solid ellipse). The dashed ellipse corresponds to C(c(v), v′). (d) Proposition 6(iii). Here c(v) = l(v′, w′) and c(w) = s(v′, w′) (solid ellipses). The dashed ellipse corresponds to C(c(v), c(w), v′). (e) Proposition 6(iv). Here c(v) = s(v′, w′) and c(w) = r(v′, w′) (solid ellipses). The dashed ellipse corresponds to C(c(v), c(w), v′). (f) Proposition 7(iv). Here c(v) = l(v′, w′) and c(w) = r(v′, w′) (solid ellipses). The dashed ellipse corresponds to C(c(v), c(w), s(v′, w′), v′). (g) Proposition 7(v). Here c(v) = l(v′, w′) (solid ellipse) and w′ (cid:22)M c(w). The dashed ellipse corresponds to C(c(v), s(v′, w′), v′, w′)). Proposition 5 (Ancestor relations) For any pair of nodes v, w ∈ V (T ), the following hold (i) If c(v) = c(w) then v ≺T w iff v ≺C(c(v)) w. (ii) If c(v) 6= c(w), and for some boundary nodes v′, w′ we have c(v) = s(v′, w′), and c(w) ∈ {l(v′, w′), r(v′, w′)}, then v ≺T w iff v ≺C(c(w),s(v′,w′),v′) w. (iii) In all other cases, v ≺T w iff c(v) ≺M c(w). Case (i) says that if v and w belong to the same macro node then v is an ancestor of w iff v is an ancestor of w in the micro forest for that macro node. Case (ii) says that if v is a spine node and w is a left or right node in the same cluster then v is an ancestor of w iff v is an ancestor of w in the micro tree induced by that cluster (Figure 8(a)). Case (iii) says that in all other cases v is an ancestor of w iff the macro node v belongs to is an ancestor of the macro node w belongs to in the macro tree. Proposition 6 (Left-of relations) For any pair of nodes v, w ∈ V (T ), the following hold 24 (i) If c(v) = c(w) ∈ {r(v′, w′), l(v′, w′)} for some boundary nodes v′, w′, then v⊳w iff v⊳C(c(v),v′,s(v′,w′))w. (ii) If c(v) = c(w) = l(v′) for some boundary node v′, then v ⊳ w iff v ⊳C(c(v),v′) w. (iii) If c(v) = l(v′, w′) and c(w) = s(v′, w′) for some boundary nodes v′, w′, then v ⊳ w iff v ⊳C(c(v),c(w),v′) w. (iv) If c(v) = s(v′, w′) and c(w) = r(v′, w′) for some boundary nodes v′, w′, then v ⊳w iff v ⊳C(c(v),c(w),v′) w. (v) In all other cases, v ⊳ w iff c(v) ⊳M c(w). Case (i) says that if v and w are both either left or right nodes in the same cluster then v is to the left of w iff v is to the left of w in the micro tree induced by their macro node together with the spine and top boundary node of the cluster (Figure 8(b)). Case (ii) says that if v and w are both leaf nodes in the same cluster then v is to the left of w iff v is to the left of w in the micro tree induced by that leaf cluster (Figure 8(c)). Case (iii) says that if v is a left node and w is a spine node in the same cluster then v is to the left of w iff v is to the left of w in the micro tree induced by their two macro nodes and the top boundary node of the cluster (Figure 8(d)). Case (iv) says that if v is a spine node and w is a right node in the same cluster then v is to the left of w iff v is to the left of w in the micro tree induced by their two macro nodes and the top boundary node of the cluster (Figure 8(e)). In all other cases v is to the left of w if the macro node v belongs to is to the left of the macro node of w in the macro tree (Case (v)). Proposition 7 (Nca relations) For any pair of nodes v, w ∈ V (T ), the following hold (i) If c(v) = c(w) = l(v′) for some boundary node v′, then ncaT (v, w) = ncaC(c(v),v′)(v, w). (ii) If c(v) = c(w) ∈ {l(v′, w′), r(v′, w′)} for some boundary nodes v′, w′, then ncaT (v, w) = ncaC(c(v),s(v′,w′),v′)(v, w). (iii) If c(v) = c(w) = s(v′, w′) for some boundary nodes v′, w′, then ncaT (v, w) = ncaC(c(v))(v, w). (iv) If c(v) 6= c(w) and c(v), c(w) ∈ {l(v′, w′), r(v′, w′), s(v′, w′)} for some boundary nodes v′, w′, then ncaT (v, w) = ncaC(c(v),c(w),s(v′,w′),v′)(v, w). (v) If c(v) 6= c(w), c(v) ∈ {l(v′, w′), r(v′, w′), s(v′, w′)}, and w′ (cid:22)M c(w) for some boundary nodes v′, w′, then ncaT (v, w) = ncaC(c(v),s(v′,w′),v′,w′)(v, w′). (vi) In all other cases, ncaT (v, w) = ncaM (c(v), c(w)). Case (i) says that if v and w are leaf nodes in the same cluster then the nearest common ancestor of v and w is the nearest common ancestor of v and w in the micro tree induced by that leaf cluster (Figure 8(c)). Case (ii) says that if v and w are both either left nodes or right nodes then the nearest common ancestor of v and w is the nearest common ancestor in the micro tree induced by their macro node together with the spine and top boundary node of the cluster (Figure 8(b)). Case (iii) says that if v and w are both spine nodes in the same cluster then the nearest common ancestor of v and w is the nearest common ancestor of v and w in the micro tree induced by their macro node. Case (iv) says that if v and w are in different macro nodes but are right, left, or spine nodes in the same cluster then the nearest common ancestor of v and w is the nearest common ancestor of v and w in the micro tree induced by that cluster (we can omit the bottom boundary node) (Figure 8(f)). Case (v) says that if v is a left, right, or spine node, and the bottom boundary node w′ of v's cluster is an ancestor in the macro tree of the macro node containing w, then the nearest common ancestor of v and w is the nearest common ancestor of v and w′ in the micro tree induced by the macro node of v, the spine node, and the top and bottom boundary nodes of v's cluster (Figure 8(g)). In all other cases the nearest common ancestor of v and w is the nearest common ancestor of their macro nodes in the macro tree (Case (vi)). 25 5.2 Preprocessing In this section we describe how to preprocess T . First build a cluster partition CS of the tree T with clusters of size s, to be fixed later, and the corresponding macro tree M in O(nT ) time. The macro tree is preprocessed as in Section 4.1. However, since nodes in M contain a set of labels, we now store a dictionary for label(v) for each node v ∈ V (M ). Using the deterministic dictionary of Hagerup et al. [20] all these dictionaries can be constructed in O(nT log nT ) time and O(nT ) space. Furthermore, we extend the definition of fl such that flM (v, α) is the nearest ancestor w of v such that α ∈ label(w). i ∈ N, and α ∈ Σ define the following procedures. size(X): Next we show how to preprocess the micro forests. For any cluster C ∈ CS, deep sets X, Y, Z ⊆ V (C), Return the number of nodes in X. left(i, X): Return the leftmost i nodes in X. right(i, X): Return the rightmost i nodes in X. leftof(X, Y ): Return all nodes of X to the left of the leftmost node in Y . rightof(X, Y ): Return all nodes of X to the right of the rightmost node in Y . match(X, Y, Z), where X = {m1 ⊳··· ⊳ mk}, Y = {v1 ⊳··· ⊳ vk}, and Z ⊆ Y . Return R := {mj vj ∈ Z}. mop(X, Y ) Return the pair (R1, R2), where R1 = mop(X, Y )1 and R2 = mop(X, Y )2. If we want to specify that a procedure applies to a certain cluster C we add the subscript C. In addition to these procedures we also define the set procedures on clusters, that is, parent, nca, deep, and fl, as in Section 3. Collectively, we will call these the cluster procedures. We represent the input and output sets in the procedures as bit strings indexed by preorder numbers. Specifically, a subset X in a cluster C is given by a bit string b1 . . . bs, such that bi = 1 iff the ith node in a preorder traversal of C is in X. If C contains fewer than s nodes we set the remaining bits to 0. The procedure size(X) is the number of ones in the bit string. The procedure left(i, X) corresponds to setting all bits in X larger than the ith set bit to zero. Similarly, right(i, X) corresponds to setting all bits smaller than the ith largest set bit to zero. Similarly, the procedures leftof(X, Y ), rightof(X, Y ), mop(X, Y ), and match(X, Y, Z) only depend on the preorder of the nodes and thus only on the bit string and not any other information about the cluster. Next we show how to implement the cluster procedures efficiently. We precompute the value of all procedures, except fl, for all possible inputs and clusters. By definition, these procedures do not depend on any specific labeling of the nodes in the cluster. Hence, it suffices to precompute the value for all rooted, ordered trees with at most s nodes. The total number of these is less than 22s (consider e.g. an encoding using balanced parenthesis). Furthermore, the number of possible input sets is at most 2s. Since at most 3 sets are given as input to a cluster procedure, it follows that we can tabulate all solutions using less 2 log n) = O(√n) bits. than 23s · 22s = 25s bits of memory. Hence, choosing s ≤ 1/10 log n we use O(2 Using standard bit wise operations each solution is easily implemented in O(s) time giving a total time of O(√n log n). 1 Since the procedure fl depends on the alphabet, which may be of size nT , we cannot efficiently apply the same trick as above. Instead define for any cluster C ∈ CS, X ⊆ V (C), and α ∈ Σ: ancestor(X): Return the set {x x is an ancestor of a node in X}. eqC (α): Return the set {x x ∈ V (C), label(x) = α}. Clearly, ancestor can be implemented as above. For eqC note that the total number of distinct labels in C is at most s. Hence, eqC can be stored in a dictionary with at most s entries each of which is a bit string of length s. Thus, (using again the result of [20]) the total time to build all such dictionaries is O(nT log nT ). 26 By the definition of fl we have that, flC (X, α) = deepC (ancestorC (X) ∩ eqC (α)). Since intersection can be implemented using a binary and -operation, flC (X, α) can be computed in constant time. Later, we will also need to compute union of sets represented as bit strings and we note that this can be done using a binary or -operation. To implement the set procedures in the following section we often need to "restrict" the cluster procedures to work on a subtree of a cluster. Specifically, for any set of macro nodes {i1, . . . , ik} in the same cluster C (hence, k ≤ 5), we will replace the subscript C with C(i1, . . . , ik). For instance, parentC(s(v,w),l(v,w))(X) = {parent(x) x ∈ X ∩ V (C(s(v, w), l(v, w))} ∩ V (C(s(v, w), l(v, w)). To implement all restricted versions of the cluster procedures, we compute for each cluster C ∈ CS a bit string representing the set of nodes in each micro forest. Clearly, this can be done in O(nT ) time. Since there are at most 5 micro forests in each cluster it follows that we can compute any restricted version using an additional constant number of and-operations. Note that the total preprocessing time and space is dominated by the construction of deterministic dictionaries which use O(nT log nT ) time and O(nT ) space. 5.3 Implementation of the Set Procedures Using the preprocessing from the previous section we show how to implement the set procedures in sublinear time. First we define a compact representation of node sets. Let T be a tree with macro tree M . For simplicity, we identify nodes in M with a number almost equal to their preorder number, which we denote their macro tree number : All nodes nodes except spine and left nodes are identified with their preorder number. Spine nodes are identified with their preorder number + 1 if they have a left node as a child and with their preorder number otherwise, and left nodes are identified with their preorder number - 1. Hence, we swap the order of left and spine nodes in the macro tree numbering. We will explain the reason for using macro tree numbers below. Note that the macro tree numbers are the same as the preorder numbers would be if we had let l(v, w) and r(v, w) be children of v instead of children of s(v, w) in the definition of the macro tree. Let S ⊆ V (T ) be any subset of nodes of T . A micro-macro node array (abbreviated node array) X representing S is an array of size nM . The ith entry, denoted X[i], represents the subset of nodes in C(i), that is, X[i] = V (C(i)) ∩ S. The set X[i] is encoded using the same bit representation as in Section 5.2. By our choice of parameter in the clustering the space used for this representation is O(nT / log nT ). We can now explain the reason for using macro tree numbers to identify the nodes instead of preorder numbers. Consider a node array representing a deep set. If a left node and the corresponding spine node are both non-empty, then all nodes in the left node are to the left of the node in the spine node. Formally, Proposition 8 Consider a node array X representing a deep set X . For any pair of nodes v, w ∈ X , such that v ∈ X[i] and w ∈ X[j], i 6= j, we have v ⊳ w ⇔ i < j . Proof. By Proposition 6(v) the claim is true for i ⊳ j. The remaining cases are i = l(v′, w′) and j = s(v′, w′) (Proposition 6 (iii)) and i = s(v′, w′) and j = r(v′, w′) (Proposition 6(iv)). In both cases i < j and it follows immediately that v ⊳ w ⇒ i < j. For the other direction, it follows from the structure of the macro tree that in both cases either v ⊳ w or w ≺ v. But X is deep and thus v ⊳ w. Thus, by using macro tree numbers we encounter the nodes in X according to their preorder number in the original tree T . This simplifies the implementation of all the procedures except Deep, since they all get deep sets as input. (cid:3) We now present the detailed implementation of the set procedures on node arrays. As in Section 4 we assume that the input to all of the procedures, except Deep, represent a deep set. Let X be a node array. 27 Implementation of Parent Procedure Parent takes a node array X representing a deep set as input. Procedure Parent(X) 1 Initialize an empty node array R of size nM (R[i] := ∅ for i = 1, . . . nM ) and set i := 1. 2 while i ≤ nM do 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 while X[i] = ∅ do i := i + 1. There are three cases depending on the type of i: case 1. i ∈ {l(v, w), r(v, w)} Compute N := parentC(i,s(v,w),v)(X[i]) . foreach j ∈ {i, s(v, w), v} do end R[j] := R[j] ∪ (N ∩ V (C(j))). case 2. i = l(v) Compute N := parentC(i,v)(X[i]) . foreach j ∈ {i, v} do end R[j] := R[j] ∪ (N ∩ V (C(j))). case 3. i 6∈ {l(v, w), r(v, w), l(v)} Compute N := parentC(i)(X[i]) . if N 6= ∅ then else if j := parentM (i) 6= ⊥ then end set R[i] := R[i] ∪ N . set R[j] := R[j] ∪ {first(j)}. Set i := i + 1. 25 end 26 Return R. Procedure Parent has three cases. Case 1 handles the fact that left or right nodes may have a node on a spine or the top boundary node as parent. Since no left or right nodes can have their parent outside their cluster there is no need to compute parents in the macro tree. Case 2 handles the fact that a leaf node may have the boundary node as parent. Since no leaf node can have its parent outside its cluster there is no need to compute parents in the macro tree. Case 3 handles boundary and spine nodes. In this case there is either a parent within the micro forest or we can use the macro tree to compute the parent of the root of the micro tree. Since the input to Parent is deep we only need to do one of the two things. If the computation of parent in the micro tree returns a nonempty set, this set is added to the output (line 18). Otherwise (the returned set is empty), we compute parent of i in the macro tree (line 19). If the computation of parent in the macro tree returns a node j, this will either be a spine node or a boundary node. To take care of the case where j is a spine node, we add the lowest node (first(j)) in j to the output (line 20). If j is a boundary node this is just j itself. Implementation of Nca We now give the implementation of procedure Nca. The input to procedure Nca is two node arrays X and Y representing two subsets X ,Y ⊆ V (T ), X = Y = k. The output is a node array R representing the set Deep({nca(Xi,Yi) 1 ≤ i ≤ k}), where Xi and Yi is the ith element of X and Y, w.r.t. their preorder number in the tree, respectively. We also assume that we have Xi ⊳ Yi for all i (since Nca is always called on a set of minimum ordered pairs). Note, that Xl and Yl can belong to different clusters/nodes in the macro tree, i.e., we might have Xl ∈ X[i] and Yl ∈ Y [j] where i 6= j. 28 Procedure Nca(X,Y ) 1 Initialize an empty node array R of size nM , set i := 1 and j := 1. 2 while i ≤ nM and j ≤ nM do while X[i] = ∅ do i := i + 1. while Y [j] = ∅ do j := j + 1. Set n := min(size(X[i]), size(Y [j])), Xi := left(n, X[i]), and Yj := left(n, Y [j]). Compare i and j. There are two cases: case 1. i = j. Set S :=(C(i, v), C(i, s(v, w), v), if i = l(v), if i ∈ {l(v, w), r(v, w)}. Compute N := ncaS(Xi, Yj). foreach macro node h = c(s) where s ∈ V (S) do end set R[h] := R[h] ∪ (N ∩ V (C(h))). case 2. i 6= j. Compute h := ncaM (i, j). There are two subcases: case (a) h is a boundary node Set R[h] := 1. case (b) h is a spine node s(v, w) There are three subcases: case i. i ∈ {l(v, w), s(v, w)} and j ∈ {s(v, w), r(v, w)} Compute N := ncaC(i,j,s(v,w),v)(Xi, Yj). Compute N := ncaC(i,s(v,w),v,w)(right(1, Xi), w). case ii. i = l(v, w) and w (cid:22) j case iii. j = r(v, w) and w (cid:22) i Compute N := ncaC(j,s(v,w),w,v)(w, left(1, Yj)). Set R[h] := R[h] ∪ (N ∩ V (C(h))) and R[v] := R[v] ∪ (N ∩ V (C(v))). 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Set X[i] := X[i] \ Xi and Y [j] := Y [j] \ Yj. 31 end 32 Return Deep(R). In the main loop of procedure Nca (line 2 -- 27) we first find the next non-empty entries in the node arrays X[i] and Y [j] (line 3 and 4). We then compare the sizes of X[i] and Y [j] and construct two sets of equal sizes Xi and Yj consisting of the min(size(X[i]), size(Y [j])) leftmost nodes from X[i] and Y [j] (line 5). In Section 5.4 we prove the following invariant on Xi and Yj The procedure has two main cases. left(1, Xi) = Xl and left(1, Yj) = Yl for some l . • If i = j (Case 1) then i is either a leaf, left, or right node due to the invariant and the assumption on the input that Xl ⊳ Yl (for a formal proof see Section 5.4). If i is a leaf node the nearest common ancestors of all pairs in Xi and Yj are in the leaf node or the boundary node. If i is a left or right node the nearest common ancestors of all the pairs are in i, on the spine, or in the top boundary node. In line 9 we compute nca in the appropriate cluster depending on the type of i. • If i 6= j (Case 2) we first compute the nearest common ancestor h of i and j in the macro tree (line 29 14). Due to the structure of the macro tree h is either a spine node or a boundary node (left, right, and leaf nodes have no descendants). If h is a boundary node all pairs in Xi and Yj have the same nearest common ancestor, namely h (Case 2(a)). If h is a spine node there are three cases depending on the types of i and j. -- In Case 2(b)i we have i = l(v, w) and j ∈ {s(v, w), r(v, w)} (see Figure 8(d) and (f)), or i = s(v, w) and j = r(v, w) (see Figure 8(e)). In this case we compute nca in the cluster containing i, j, s(v, w), v. -- In case 2(b)ii i is a left node l(v, w) and j is a (not necessarily proper) descendant of w (see Figure 8(g)). In this case we compute nca on the rightmost node in Xi and w in the cluster containing i, v, w, s(v, w). We can restrict the computation to right(1, Xi) because we always run Deep on the output from Nca before using it in any other computation and all nearest common ancestors of the pairs in Xi and Yj will be on the spine, and the deepest one will be the nearest common ancestor of the rightmost nodes in Xi and Yj (see Section 5.4 for a formal proof). -- Case 2(b)iii is similar to Case 2(b)ii. In the end of the iteration we have computed the nearest common ancestors of all the pairs in Xi and Yj and the nodes from these pairs are removed from X[i] and Y [j]. Implementation of Deep The implementation of Deep resembles the previous implementation, but takes advantage of the fact that the input list is in macro tree order. Procedure Deep(X) 1 Initialize an empty node array R of size nM . 2 Find the smallest j such that X[j] 6= ∅. If no such j exists stop. Set i := j + 1. 3 while i ≤ nM do while X[i] = ∅ do i := i + 1. Compare j and i. There are three cases: case 1. j ⊳ i. 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Set S :=  Set R[j] := deepS(X[j]). C(j, v), C(j, s(v, w), v), C(j), if j = l(v), if j ∈ {l(v, w), r(v, w)}, otherwise. case 2. j ≺ i. if j = s(v, w) and i = r(v, w) then compute N := deepC(r(v,w),s(v,w),v)(X[i] ∪ X[j]). Set R[j] := X[j] ∩ N . end case 3. i ≺ j (can happen if i = s(v, w) and j = l(v, w)). Compute N := deepC(l(v,w),s(v,w),v)(X[i] ∪ X[j]). Set R[j] := X[j] ∩ N , X[i] := X[i] ∩ N . Set j := i and i := i + 1. 18 end 19 Set R[j] := deepS(X[j]), where S is set as in Case 1. 20 Return R. The procedure Deep has three cases. In case 1 node i is to the right of our "potential output node" j. Since any node l that is a descendant of j must be to the left of i (l < i) it cannot appear later in the list 30 X than i. We can thus safely add deepS(X[j]) to R at this point. To ensure that the cluster we compute Deep on is a tree we include the top boundary node if j is a leaf node and the top and spine node if j is a left or right node. We add the result to R and set i to be our new potential output node. In case 2 node j is an ancestor of i and therefore no node from C(j) can be in the output list unless j is a spine node and i is the corresponding right node. If this is the case we compute Deep of X[j] and X[i] in the cluster containing i and j and add the result for j to the output and set i to be our new potential output node. In case 3 node i is an ancestor of j. This can only happen if j is a left node and i the corresponding spine node. We compute Deep of X[j] and X[i] in the cluster containing i and j and add the result for j to the output. We restrict X[i] to the nodes both in X[i] and the result N of the Deep computation, and let i be our potential output node. The results for X[i] cannot be added directly to the input since there might be nodes later in the input that are descendants of i. Since a left node has no children we can safely add the result for j to the output. After iterating through the whole node array X we add the last potential node j to the output after computing Deep of it as in Case 1. Implementation of MopRight We now give the implementation of procedure MopRight. Procedure MopRight takes a pair of node arrays (X, Y ) and another node array Z as input. The pair (X, Y ) represents a set of minimum ordered pairs, where the first coordinates are in X and the second coordinates are in Y . To simplify the implementation of procedure MopRight it calls two auxiliary procedures MopSim and Match defined below. Procedure MopSim computes mop of Y and Z, and procedure Match computes the first coordinates from X corresponding to the first coordinates from the minimum ordered pairs of Y and Z computed by MopSim. Procedure MopRight((X,Y ),Z) 1 Compute M := MopSim(Y, Z). 2 Compute R := Match(X, Y, M1). 3 Return (R, M2). Procedure MopSim takes two node arrays as input and computes mop of these. 31 Procedure MopSim(X,Y ) 1 Initialize two empty node arrays R and S of size nM . 2 Set i := 1, j := 1, (r1, r2) := (0,∅), (s1, s2) := (0,∅). 3 repeat 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 while X[i] = ∅ do set i := i + 1. There are four cases: case I. i = l(v, w) for some v, w. case II. i = s(v, w) for some v, w. Until Y [j] 6= ∅ and either i ⊳ j, i = j, or j = s(v, w) do set j := j + 1. Until Y [j] 6= ∅ and either i ⊳ j or j = r(v, w) do set j := j + 1. Until Y [j] 6= ∅ and either i ⊳ j or i = j do set j := j + 1. Until Y [j] 6= ∅ and i ⊳ j do set j := j + 1. case III. i ∈ {r(v, w), l(v)} for some v, w. case IV. i is a boundary node. Compare i and j. There are two cases: case 1. i ⊳ j. if s1 < j then set R[r1] := R[r1] ∪ r2, S[s1] := S[s1] ∪ s2, and (s1, s2) := (j, leftC(j)(1, Y [j])). end Set (r1, r2) := (i, rightC(i)(1, X[i])) and i = i + 1. otherwise // case 2. Compute (r, s) := mopC(i,j,v)(X[i], Y [j]), where v is the top boundary node in the cluster i and j belong to. if r 6= ∅ then set R[r1] := R[r1] ∪ r2, S[s1] := S[s1] ∪ s2. if s1 < j or if s1 = j and leftofC(i,j)(X[i], s2) = ∅ then end Set (r1, r2) := (i, r) and (s1, s2) := (j, s). end There are two subcases: case (a) i = j, or i = l(v, w) and j = s(v, w). Set X[i] := rightC(i)(1, rightofC(i)(X[i], r)) and j := j + 1. case (b) i = s(v, w) and j = r(v, w). if r = ∅ then set j := j + 1 else set i := j. endsw 37 until i > nM or j > nM ; 38 Set R[r1] := R[r1] ∪ r2 and S[s1] := S[s1] ∪ s2. 39 Return (R, S). Procedure MopSim is somewhat similar to the previous implementation of the procedure MopRight from Section 4.2. As in the previous implementation we have a "potential pair" ((r1, r2), (s1, s2)), where r1 and s1 are macro nodes, r2 ⊆ X[r1], s2 ⊆ Y [s1], where r2 = {r1 ⊳··· ⊳ rk} and s2 = {s1 ⊳··· ⊳ sk} such that rl ⊳ sl for l = 1, . . . k. Furthermore, for any l there exists no node y ∈ Y [j], for j < s1, such that rl ⊳ y ⊳ sl and no node x ∈ X[i], for i < r1, such that rl ⊳ x ⊳ sl. We have the following invariant at the beginning of each iteration: We first find the next non-empty macro node i. We then have 4 cases depending on which kind of node ∄x ∈ X[i], such that x E x′, for any x′ ∈ r2. (8) 32 i is. • In Case I i is a left node. Due to Proposition 6 we can have mop in i (case (i), see Fig. 8(b)), in the spine (case (iii), see Fig. 8(d)), or in a node to the right of i (case(v)). • In Case II i is a spine node. Due to Proposition 6 we can have mop in the right node (case (iv) , see Fig. 8(e)) or in a node to the right of i (case(v)). • In Case III i is a right node or a leaf node. Due to Proposition 6 we can have mop in i (case (i) and (ii), see Fig. 8(b)-(c)) or in a node to the right of i (case(v)). • In the last case (Case IV) i must be a boundary node and mop must be in a node to the right of i. We then compare i and j. The case where i ⊳ j is similar to the previous implementation of the procedure. We compare j with our potential pair (line 16). If s1 < j then s1 ⊳ j since the input is deep, and we can insert r2 and s2 into our output node arrays R and S, respectively. We also set s1 to j and s2 to the leftmost node in Y [j] (if s1 = j we already have (s1, s2) = (j, leftC(j)(1, Y [j]))). Then -- both if s1 ⊳ j or s1 = j -- we set r1 to i and r2 to the rightmost node in X[i] (line 19). That we only need the rightmost node in X[i] and the leftmost node in Y [j] follows from the definition of mop and the structure of the macro tree. Case 2 (i ⋪ j) is more complicated. In this case we first compute mop in the cluster i and j belong to (line 21). If this results in any minimum ordered pairs (r 6= ∅) we must update our potential pair (line 22 -- 27). Otherwise we leave the potential pair as it is and only update i and j. If r 6= ∅ we compare s1 and j (line 23). As in Case 1 of the procedure we add our potential pair to the output and update the potential pair with r and s if s1 < j, since this implies s1 ⊳ j. If s1 = j and no nodes in X[i] are to the left of the leftmost node in s2 we also add the potential pair to the output and update it. We show in the next section that in this case s2 = 1. Therefore we can safely add the potential pair to the output. In all other cases the pair (r, s) 6= (∅,∅) shows a contradiction to our potential pair and we update the potential pair without adding anything to the output. Finally, in Case 2, we update X[i], i, and j (line 28 -- 32). There are two cases depending on i and j. In Case (a) either i = j or i is a left node and j is the corresponding spine node. In both cases we can have nodes in X[i] that are not to the left of any node in Y [j]. These nodes could be in a minimum ordered pair with nodes from another macro node. We show in the next section that this can only be true for the rightmost node in X[i]. X[i] is updated accordingly. After this update all nodes in Y [j] are to the left of all nodes in X[i] in the next iteration and therefore j is incremented. In Case (b) i is a spine node and j is the corresponding right node. Since the input lists are deep, there is only one node in X[i]. If r = ∅ then no node in Y [j] is to the right of the single node in X[i]. Since the input arrays are deep, no node later in the array X can be to the left of any node in Y [j] and we therefore increment j. If r 6= ∅ then (r1, r2) = (i, X[i]) and we update i. Instead of incrementing i by one we set i := j, this is correct since all macro nodes with macro node number between i and j are descendants of i, and thus contains no nodes from X, since X is deep. When reaching the end of one of the arrays we add our potential pair to the output and return (line 35 -- 36). As in Section 4.2 we can implement MopLeft similarly to MopRight. Recall that proceudre MopRight calls Match to find the first coordinates from X corresponding to the first coordinates from the minimum ordered pairs computed by MopSim. Procedure Match takes three node arrays X, Y , and Y ′ representing deep sets X , Y, and Y ′, where X = Y, and Y ′ ⊆ Y. The output is a node array representing the set {Xj Yj ∈ Y ′}. 33 Procedure Match(X,Y ,Y ′) 1 Initialize an empty node array R of size nM . 2 Set XL := ∅, YL := ∅, Y ′ 3 repeat L := ∅, x := 0, y := 0, i := 1 and j := 1. while X[i] = ∅ do set i := i + 1. while Y [j] = ∅ do set j := j + 1. Set x := size(X[i]) and y := size(Y [j]). Compare Y [j] and Y ′[j]. There are two cases: case 1. Y [j] = Y ′[j] Compare x and y. There are three subcases: case (a) x = y. Set R[i] := R[i] ∪ X[i], i := i + 1, and j := j + 1. case (b) x < y. Set R[i] := R[i] ∪ X[i], Y [j] := right(y − x, Y [j]), Y ′[j] := Y [j], and i := i + 1. case (c) x > y. Set XL := left(y, X[i]), R[i] := R[i] ∪ XL, X[i] := X[i] \ XL, and j := j + 1. case 2. Y [j] 6= Y ′[j] Compare x and y. There are three subcases: case (a) x = y. Set R[i] := R[i] ∪ match(X[i], Y [j], Y ′[j]), i := i + 1, and j := j + 1. case (b) x < y. Set YL := left(x, Y [j]), Y ′ Y [j] := Y [j] \ YL, Y ′[j] := Y ′[j] \ Y ′ L := Y ′[j] ∩ YL, R[i] := R[i] ∪ match(X[i], YL, Y ′ L), L, and i := i + 1. case (c) x > y. Set XL := left(y, X[i]), R[i] := R[i] ∪ match(XL, Y [j], Y ′[j]), X[i] := X[i] \ XL, and j := j + 1. 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 until i > nM or j > nM ; 34 Return R. Procedure Match proceeds as follows. First we find the first non-empty entries in the two node arrays X[i] and Y [j] (line 4 -- 5). We then compare Y [j] and Y ′[j] (line 7). If they are equal we keep all nodes in X with the same rank as the nodes in Y [j] (case 1). We do this by splitting into three cases. If there are the same number of nodes X[i] and Y [j] we add all nodes in X[i] to the output and increment i and j (case 1(a)). If there are more nodes in Y [j] than in X[i] we add all nodes in X[i] to the output and update Y [j] and Y ′[j] to contain only the y − x leftmost nodes in Y [j] (case 1(b)). We then increment i and iterate. If there are more nodes in X[i] than in Y [j] we add the first y nodes in X[i] to the output, increment j, and update X[i] to contain only the nodes we did not add to the output (case 1(c)). If Y [j] 6= Y ′[j] we call the cluster procedure match (case 2). Again we split into three cases depending on the number of nodes in X[i] and Y [j]. If they have the same number of nodes we can just call match on X[i], Y [j], and Y ′[j] and increment i and j (case 2(a)). If size(Y [j]) > size(X[i]) we call match with X[i] the leftmost size(X[i]) nodes of Y [j] and with the part of Y ′[j] that are a subset of these leftmost size(X[i]) nodes of Y [j] (case 2(b)). We then update Y [j] and Y ′[j] to contain only the nodes we did not use in the call to match and increment i. If size(Y [j]) < size(X[i]) we call match with the leftmost size(Y [j]) nodes 34 of X[i], Y [j], and Y ′[j] (case 2(c)). We then update X[i] to contain only the nodes we did not use in the call to match and increment j. Implementation of Fl Procedure Fl takes as input a node array X representing a deep set and a label α. Procedure Fl(X, α) 1 q Initialize an empty node array R of size nM and two node lists L and S. 2 repeat 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 foreach j ∈ {i, s(v, w), v} do set R[j] = R[j] ∪ (N ∩ V (C(j))). case 2. i = l(v) foreach j ∈ {i, v} do set R[j] := R[j] ∪ (N ∩ V (C(j))). while X[i] = ∅ do set i := i + 1. There are three cases depending on the type of i: case 1. i ∈ {l(v, w), r(v, w)} Compute N := flC(i,s(v,w),v)(X[i], α). if N 6= ∅ then else set L := L ◦ parentM (v). Compute N := flC(i,v)(X[i], α). if N 6= ∅ then else set L := L ◦ parentM (v). case 3. i 6∈ {l(v, w), r(v, w), l(v)} Compute N := flC(i)(X[i], α). if N 6= ∅ then else set L := L ◦ parentM (i). set R[i] := R[i] ∪ N . 21 until i > nM ; 22 Compute the list S := flM (L, α). 23 foreach node i ∈ S do set R[i] := R[i] ∪ flC(i)(first(i), α)). 24 Return Deep(R). The Fl procedure is similar to Parent. The cases 1, 2 and 3 compute Fl on a micro forest. If the result is within the micro tree we add it to R and otherwise we store in a node list L the node in the macro tree which contains the parent of the root of the micro forest. Since we always call Deep on the output from Fl(X, α) there is no need to compute Fl in the macro tree if N is nonempty. We then compute Fl in the macro tree on the list L, store the results in a list S, and use this to compute the final result. Consider the cases of procedure Fl. In case 1 i is a left or right node. Due to Proposition 5 case (i) and (ii) fl of a node in i can be in i or on the spine or in the top boundary node. If this is not the case it can be found by a computation of Fl of the parent of the top boundary node of i's cluster in the macro tree (Proposition 5 case (iii)). In case 2 i is a leaf node. Then fl of a node in i must either be in i, in the top boundary node, or can be found by a computation of Fl of the parent of the top boundary node of i's cluster in the macro tree. If i is a spine node or a boundary node (case 3), then fl of a node in i is either in i or can be found by a computation of Fl of the parent of i in the macro tree. 5.4 Correctness of the Set Procedures The following lemmas show that the set procedures are correctly implemented. Lemma 18 Procedure Parent is correctly implemented. Proof. We will prove that in iteration i the procedure correctly computes the parents of all nodes in the macro node i. There are four cases depending on the type of i. 35 • Consider the case i ∈ {l(v, w), r(v, w)}, i.e., i is a left or right node. For all nodes x in C(i), parent(x) is either in C(i), on the spine s(v, w), or is the top boundary node v. The parents of all input nodes in C(i) is thus in N computed in Case 1 in the procedure. The last line in Case 1 ("For each j ∈ {i, s(v, w), v}, . . .") adds the set of parents to the appropriate macro node in the output array. • If i is a leaf node l(v) then for any node x ∈ C(i), parent(x) is either in C(i) or is the boundary node v. The parents of all input nodes in C(i) is thus in N computed in Case 2 in the procedure. The last line in Case 2 ("For each j ∈ {i, v}, . . .") adds the set of parents to the appropriate macro node in the output array. • If i is a spine node s(v, w) then the input contains at most one node in C(i), since the input to the procedure is deep. For any x ∈ C(i), parent(x) is either a node on the spine or the top boundary node v. This is handled by Case 3 in the procedure. Let x be the node in X[i]. If parent(x) = v, then N = ∅, and we compute j, which is the parent v of i in the macro tree, and add j to the output array (since j = v is a boundary node first(j) = v). If parent(x) is another node y on the spine, then N = {y} 6= ∅ and y is added to the output array. • If i is a boundary node v, then parent(v) is either another boundary node v′, the bottom node on a spine, or ⊥ if v is the root. This is handled by Case 3 in the procedure. In all three cases N = ∅ and we compute the parent j of i in the macro tree. If i is the root, then j = ⊥ and we do nothing. Otherwise, we add first(j) to the output. If parent(v) is a boundary node then first(j) = j. If j is a spine node then first(j) is the bottom node on j. In each iteration of the procedure we might add nodes to the output, but we never delete anything written to the output in earlier iterations. Procedure Parent thus correctly computes the parents of all nodes in X. (cid:3) Before proving the correctness of procedure Nca we will prove the following invariant on the variables Xi and Yj in the procedure. Lemma 19 In procedure Nca we have the following invariant of Xi and Yj: left(1, Xi) = Xl and left(1, Yj) = Yl for some l . Proof. The proof is by induction on the number of iterations of the outer loop. After the while loop on X in the first iteration (line 3), i is the smallest integer such that X[i] 6= ∅. Due to the macro tree order of the array X, X[i] contains the first nodes from X w.r.t. the preorder of the original tree (Proposition 8). Similarly, Y [j] contains the leftmost node in Y. The invariant now follows immediately from the assignment of Xi and Yj. For the induction step consider iteration m and let i′ and j′ be the values of i and j after the while loops in the previous iteration, i.e, after line 4. By the induction hypothesis left(1, Xi′) = Xl and left(1, Yj ′ ) = Yl for some l. Let n′ = min(size(X[i′]), size(Y [j′])). Then Xi′ contains Xl, . . . ,Xl+n′ and Yj ′ contains Yl, . . . ,Yl+n′ . We will show that left(1, Xi) = Xl+n′+1. In the end of the previous iteration we removed Xi′ from X[i′] (line 26). There are two cases depending on wether X[i′] is empty or not at the beginning of iteration m. • If X[i′] 6= ∅ then it clearly contains Xl+n′+1 as its leftmost node. Since a spine node can only contain one node from X , i′ cannot be a spine node. Thus i = i′, when we get to line 5 in the current iteration It follows that left(1, Xi) = Xl+n′+1. • X[i′] = ∅. It follows from the macro tree order of X that X[i] contains Xl+n′+1 as its leftmost node. It follows by a similar argument that left(1, Yj) = Yl+n′+1. (cid:3) 36 Lemma 20 Let X and Y be two node arrays representing the deep sets X and Y, X = Y = k, and let Xi and Yi denote the ith element of X and Y, w.r.t. their preorder number in the tree, respectively. For all i = 1, . . . , k, assume Xi ⊳ Yi. Procedure Nca(X, Y ) correctly computes Deep({nca(Xi,Yi)1 ≤ i ≤ k}). Proof. We are now ready to show that the procedure correctly takes care of all possible cases from Proposition 7. The proof is split into two parts. First we will argue that some of the cases from the proposition cannot occur during an iteration of the outer loop of Nca. Afterwards we prove that the procedure takes care of all the cases that can occur. Case (iii) cannot happen since if i = j is a spine node then Xl is either a descendant or an ancestor of Yl contradicting the assumption on the input that Xl ⊳ Yl. Case (vi) can only happen if i 6= j: If i = j and we are in case (vi) then i = j is a boundary node, and this would imply that C(i) only consists of one node, i.e., Xl = X[i] = Y [j] = Yl contradicting the assumption on the input that Xl ⊳ Yl. Due to this assumption on the input we also have that in case (iv) of the proposition i is either a left node or a spine node and j is a spine node or a right node. For case (v) either i is a left node and j is a descendant of the bottom boundary node of i's cluster or j is a right node and i is a descendant of the bottom boundary node of j's cluster. All the other cases from case (v) would contradict the assumption that Xl ⊳ Yl. The procedure first constructs two sets Xi and Yj containing the elements Xl, . . . ,Xl+n and Yl, . . . ,Yl+n for some l, respectively, where n = min(size(X[i]), size(Y [j])). The procedure Nca has two main cases depending on whether i = j or not. Case 1 (i = j) takes care of cases (i) -- (ii) from Proposition 7. Case 2 (i 6= j) takes care of the remaining cases from Proposition 7 (iv) -- (vi) that can occur. First consider Case 1: We compute nearest common ancestors N of the n nodes in Xi and Yj in a cluster S depending on what kind of node i is. We need to show that Case 1 handles Case (i) and (ii) from the Proposition correctly. • Case (i). i = j is a leaf node. By the Proposition the nearest common ancestors of the pairs in (Xl,Yl), . . . , (Xl+n,Yl+n) from Xi and Yj is either in c(i) or in the boundary node, i.e., in C(i, v). • Case (ii). i = j is a left or right node. By the Proposition the nearest common ancestors of the pairs in {(Xl,Yl), . . . , (Xl+n,Yl+n)} from Xi and Yj is either in c(i), on the spine, or in the top boundary node, i.e., in C(i, s(v, w), v). Thus S is correctly set in both cases. After the computation of N in line 9 the output is then added to the entries in the output array R for each of the macro nodes belonging to nodes in V (S) (line 10 -- 12). Case 1 thus handles Case (i)-(ii) (and only these two cases) from Proposition 7. Next consider Case 2 (i 6= j). We first compute the nearest common ancestor h of i and j in the macro tree. The macro node h is either a boundary node or a spine node due to the structure of the macro tree (see also Proposition 7). We will show that Case 2 takes care of the remaining cases. • Case (iv). From the above discussion it follows that we have one of the three following cases. i = l(v, w) and j = s(v, w), i = l(v, w) and j = r(v, w), or i = s(v, w) and j = r(v, w). All three cases are handled in Case 2(b)i of the procedure. It follows from the proposition that nca is computed in the correct cluster. • Case (v). It follows from the discussion above that either i = l(v, w) and w (cid:22) j, or j = r(v, w) and w (cid:22) i. These two cases are handled by Case 2(b)ii and 2(b)iii of the procedure. It follows from the Proposition that nca is computed in the correct cluster. We need to argue that we can restrict the computation of nca to the pair (right(1, Xi), w) instead of computing nca for all nodes in {Xl, . . . ,Xl+n}. Consider the case where i = l(v, w) and w (cid:22) j (Case 2(b)ii of the procedure). Since w (cid:22) Yr for all r = l, . . . l + n, and Xl ⊳ Xl+1 ⊳ . . . ⊳ Xl+n, then nca(Xr,Yr) (cid:22) nca(Xl+n,Yl+n) for all r = l, . . . l + n. Thus we do not need to compute nca(Xr,Yr) for r 6= n + l, since the output of the procedure is Deep({nca(Xi,Yi)1 ≤ i ≤ k}). A similar argument shows that we can restrict the computation to (w, left(1, Yj)) in Case 2(b)iii. 37 • Case (vi). It follows from the discussion above and the proposition that i 6= j and i and j are in different clusters, and we are not in any of the cases from (iv) and (v). Thus h must be a boundary node and all the pairs {(Xl,Yl), . . . , (Xl+n,Yl+n)} have the same nearest common ancestor, namely h. This is handled by Case 2(a). We have now argued that the procedure correctly takes care of all possible cases from Proposition 7. It remains to show that all pairs from {nca(Xi,Yi)1 ≤ i ≤ k} are considered during the computation. It follows from the invariant that we only consider pairs from the input. In the last lines we remove the nodes from the input that we have computed the ncas of in this iteration. It follows from the proof of the invariant that no entry in the input arrays is left nonempty. Thus all pairs are taken care of. (cid:3) To prove that procedure Deep is correctly implemented we will use the following fact about preorder and postorder numbers in the macro tree. Proposition 9 Let i and j be nodes in the macro tree identified by their macro tree number such that i < j. For all x ∈ C(i), y ∈ C(j) we have 1. pre(x) < pre(y) unless i = l(v, w) and j = s(v, w). 2. post(y) > post(x) unless i = s(v, w) and j = r(v, w). Proposition 10 Let x1, . . . , xn be nodes from the macro tree associated with their macro tree number such that x1 < x2 < ··· < xn. If xi ⊳ xj for some i and j then xi ⊳ xk for all xk > xj. Proof. From xi ⊳ xj we have pre(xi) < pre(xj) and post(xi) < post(xj). Since xk > xj we have pre(xj) < pre(xk) unless xk = s(v, w) and xj = l(v, w). In that case, pre(xk) + 1 = pre(xj ) > pre(xi). Since xi ⊳ xj we have xi 6= xj and thus pre(xk) > pre(xi). post(xi) < post(xj ). This implies xi ≺ xk and xj ≺ xk contradicting xi ⊳ xj. We will first prove the following invariants on i and j in procedure Deep. It remains to show that post(xi) < post(xk). Assume for the sake of contradiction that post(xk) < (cid:3) Lemma 21 In line 5 of procedure Deep we have the following invariant on i and j: For all l such that j < l < i we have X[l] = ∅. Proof. Let i′ be the value of i in line 5 of the previous iteration of the outer loop (line 3 -- 18). Then i is the smallest index greater than i′ such that the corresponding entry in X is nonempty. This is true since i was set to i′ + 1 in the end of the previous iteration (line 17), and in line 4 of this iteration i was incremented until we found a nonempty entry. Since j = i′ (this was also set in line 17 of the previous iteration), i is the first nonempty entry greater than j and the claim follows. (cid:3) Lemma 22 At the beginning of each iteration of the main loop of procedure Deep (line 3) we have the following invariant on j: For all nodes x ∈ X[j] and y ∈ X[l], where 1 ≤ l < j, we have x 6≺ y. Proof. Recall that x ≺ y ⇔ pre(x) < pre(y) and post(y) < post(x). By Proposition 9 the only case where we can have pre(x) < pre(y) is if l = l(v, w) and j = s(v, w) for some v, w. Assume this is the case. If X[l] = ∅ the claim follows trivially. Otherwise, let i′ and j′ be the values of i and j in the previous iteration, respectively (since l < j and X[l] 6= ∅ there must be such an iteration). We have j = l + 1, i′ = j = s(v, w) and j′ = l = l(v, w). Thus in the previous iteration the procedure entered case 3, where X[i′] was set to X[i′] ∩ deepC(l(v,w),s(v,w),v)(X[i′] ∪ X[j′]), and thus X[j] contains no nodes that are ancestors of nodes in X[j′] = X[l]. (cid:3) 38 Lemma 23 Procedure Deep is correctly implemented. Proof. We will prove that x ∈ Deep(X) iff x ∈ X and there exists no y ∈ X such that x ≺ y. Assume x ∈ Deep(X). Consider the iteration when x is assigned to the output. There are three cases depending on which case we are in when x is added to the input. If j ⊳ i (Case 1 of the procedure) then x ∈ DeepS(X[j]) and it follows from the invariant on j (Lemma 22) that x has no descendants in any nodes y ∈ X[l], l < j. For j < l < i the claim follows directly from Lemma 21. It remains to show that x has no descendants in X[l] for l ≥ i. By Proposition 10 we have j ⊳ l for all l > i and the claim follows from Proposition 5. If j ≺ i (Case 2 of the procedure) then j is a spine node s(v, w) and i is the corresponding right node r(v, w), and we compute N := DeepC(r(v,w),s(v,w),v)(X[i] ∪ X[j]). Since x ∈ Deep(X) we have x ∈ R[j] = X[j] ∩ N . It follows from the invariant (Lemma 22) and the computation of N that x has no descendants in X[l] for any l ≤ j. For l > j it follows from the structure of the macro tree that for any l > i we have j ⊳ l. For j < l < i the claim follows directly from Lemma 21. The claim follows from Proposition 5. For j < l < i the claim follows directly from Lemma 21. If i ≺ j (Case 3 of the procedure) then i is a spine node s(v, w) and j is the corresponding left node l(v, w), and we compute N := DeepC(l(v,w),s(v,w),v)(X[i]∪X[j]). Since x ∈ Deep(X) we have x ∈ R[j] = X[j]∩N . It follows from the computation of N that x has no descendants in X[i]∪X[j]. Since l(v, w) has no descendants in the macro tree it follows from Proposition 5 that x has no descendants in X[l] for any l 6= j. If x is assigned to the output in line 19 then it follows from the invariant on j (Lemma 22) and the computation of DeepS(X[j]) that x has no descendants in X. For the other direction let x ∈ X be a node such that X ∩ V (T (x)) = {x}. Let l be the index such that x ∈ X[l]. All nonempty entries in X are i in line 5 at some iteration. Consider the iteration when i = l. Unless i = l(v, w) and j = s(v, w) (Case 3 of the procedure) X[i] is not changed in this iteration. If we are in Case 3, then N is computed and X[i] is set to X[i] ∩ N . Since x has no descendants in X we have x ∈ N and thus x ∈ X[i] after the assignment. At the end of this iteration j is set to i. Consider the next iteration when j = l. If j ⊳ i or i > nM then x ∈ DeepS(X[j]) = R[j]. If j ≺ i we have j = s(v, w) and i = r(v, w) since x has no descendants in X. For the same reason we have x ∈ N and thus x ∈ X[j]∩ N = R[j]. If i ≺ j we have i = s(v, w) and j = l(v, w). Again x ∈ N and thus x ∈ X[j] ∩ N = R[j]. We now consider procedures MopSim and Match. (cid:3) Lemma 24 Let ((r1, r2), (s1, s2)) be as defined in procedure MopSim. Then r1 and s1 are macro nodes, r2 ⊆ X[r1], s2 ⊆ Y [s1], where r2 = {r1 ⊳ ··· ⊳ rk} and s2 = {s1 ⊳ ··· ⊳ sk}. For any l = 1, . . . , k we have 1. rl ⊳ sl, 2. for all j ≤ s1 there exists no node y ∈ Y [j] such that rl ⊳ y ⊳ sl, 3. for all i ≤ r1 there exists no node x ∈ X[i] such that rl ⊳ x ⊳ sl. It follows immediately from the code that r1 and s1 are macro nodes and that r2 ⊆ X[r1], s2 ⊆ Y [s1], Proof. where r2 = {r1 ⊳ ··· ⊳ rk1} and s2 = {s1 ⊳ ··· ⊳ sk2}. Due to the macro tree order of the tree and the fact that X represents a deep set, no node in X[i] can be to the right of any node in X[r1] for i < r1. To prove condition 3 it is thus enough to prove it for i = r1. We proceed by induction on the number k of iterations of the outer loop (line 3 -- 34). We consider the time right after the kth iteration of the loop, i.e., right before the (k + 1)th iteration. The base case (k = 0) is trivially satisfied. For the induction step let i∗ and j∗ be the values of i and j at line 14 in iteration k. Let r′ i and s′ i for i = 1, 2 be the values of ri and si, respectively, after the (k − 1)th round. There are 3 cases: 1. r′ 2. r′ 2 = s2: the claim follows directly from the induction hypothesis. 2 = r2 and s′ 2 6= r2 and s′ 2 = s2: condition 2 from the lemma follows directly from the induction hypothesis. Since s2 and thus also s1 were not changed, r2 was set in case 1 of the procedure and j∗ = s1. Therefore, i∗ ⊳ j∗, r1 = i∗, and r2 = 1. Let r2 = {r1} and s2 = {s1}. We have r1 = i∗ ⊳ j∗ = s1 and thus r1 ⊳ s1 39 3. r′ 2 6= s2: We first prove condition 1 and 3. satisfying condition 1 from the lemma. To prove condition 3 is satisfied we only have to consider the case i = r1. Since r2 was set in case 1 of the procedure, r1 is the rightmost node in X[r1] and it follows immediately that there exists no node x ∈ X[r1] such that r1 ⊳ x ⊳ s1. 2 6= r2 and s′ If the potential pair was set in case 1 (line 15 -- 19) of the procedure then r1 = i∗ ⊳ j∗ = s1 and r2 = 1 implying r1 ⊳ s1 (condition 1). The node r1 is the rightmost node in X[r1] (line 19) and it follows that there exists no node x ∈ X[r1] such that r1 ⊳ x ⊳ s1 proving condition 3. If the potential pair was set in case 2 then both condition 1 and 3 follows from the correctness of the implementation of mop and the computation (r, s) = mopC(i,j,v)(X[i∗], Y [j∗]) = mopC(i,j,v)(X[i∗], Y [s1]) in line 21. Let y ∈ Y [j], for j ≤ s1, be a node such that y 6∈ s2. To prove condition 2 is satisfied we will show that rl is not to the left of y. There are two cases • j = s1. Since s′ 2 6= s2 there are two cases depending on which case of the procedure the potential pair was set in. If the potential pair was set in case 2 of the procedure the claim follows from the correctness of the implementation of mop and the computation (r, s) = mopC(i,j,v)(X[i∗], Y [j∗]) = mopC(i,j,v)(X[i∗], Y [s1]) in line 21. If the potential pair was set in case 1, then r1 = i∗ ⊳ j∗ = s1. Since s2 6= s′ the kth iteration and is therefore the leftmost node in Y [s1] (line 17). The claim follows. 2, s2 was changed in • j < s1. We will use that we just proved the claim for j = s1. Assume for the sake of contradiction that there exists a y ∈ Y [j] such that rl ⊳ y. Since Y is representing a deep set and due to the macro tree order of Y this implies rl ⊳ y ⊳ y′ for all y′ ∈ Y [s1] contradicting that the claim is true for j = s1. (cid:3) Lemma 25 We have the following invariant at the beginning of each iteration of the main loop (line 3) of MopSim: ∄x ∈ X[i], such that x E x′, for any x′ ∈ r2. Proof. By induction on the number of iterations of the outer loop. In the base case r2 = ∅ and the condition is trivially satisfied. Note that X is representing a deep set and thus either x ⊳ x′ or x′ ⊳ x for all x ∈ X[i]. For the induction step let i′, j′, and r′ 2 be the values of i, j, and r2 respectively in the iteration before this. By the induction hypothesis x′ ⊳x for all x ∈ X[i′] and x′ ∈ r′ 2. Due to the macro tree order of X and the fact that X represents a deep set, all nodes in X[i′] are to the left of all nodes in X[i]. Thus, if r2 = r′ 2 it follows from the induction hypotheses that x′ ⊳ x for all x ∈ X[i] and x′ ∈ r′ 2 6= r2 there are two cases: If i′ ⊳ j′ then r2 = rightC(i′)(1, X[i′]) and i > i′ and thus the condition is satisfied. Otherwise r2 was set in case 2 of the procedure. Since r2 6= r′ 2 we have r2 = r ⊆ X[i′] and r 6= ∅. There are two subcases: If i = j or i = l(v, w) and j = s(v, w) (Case 2(a) of the procedure) then X[i] either contains a single node, which is the rightmost of the nodes in X[i′] that are to the right of all nodes in r2 or if there are no such nodes X[i] = ∅. In both cases the condition is satisfied. If i = s(v, w) and j = r(v, w) then i > i′ and the condition is satisfied. (cid:3) 2 = r2. For r′ Lemma 26 Procedure MopSim is correctly implemented. Let X and Y be the sets represented by X and Y , respectively. Let R = MopSim(X, Y )1 and Proof. S = MopSim(X, Y )2. For simplicity we will slightly abuse the notation and write (x, y) ∈ MopSim(X, Y ) iff there exists an i such that x ∈ R[i] and y ∈ S[i]. We want to show that (x, y) ∈ MopSim(X, Y ) ⇔ (x, y) ∈ mop(X ,Y) . 40 Assume (x, y) ∈ MopSim(X, Y ). Consider the round where x and y were added to R and S, respectively. We have x = rl ∈ r2 and y = sl ∈ s2. We want to show that there is no node x′ ∈ X[i] for any i such that x ⊳ x′ ⊳ y and no node y′ ∈ Y [j] for any j such that x ⊳ y′ ⊳ y. By Lemma 24 this is true for i ≤ r1 and j ≤ s1. By the macro tree order of Y we have that y ⊳ y′ for any y′ ∈ Y [j] when j > s1. Let i′ be the value of i in the round where x and y is added to the output. We will show that no node in X[i′] is to the left of any node in s2. Due to the macro tree order of X this implies that no node in X[i] is to the left of any node in s2 for any i ≥ i′. If i′ = r1 then it follows directly from Lemma 24. If i′ > r1 it follows from the implementation of the procedure that i′ is the first non-empty entry in X greater than r1. Thus the claim follows for any j. We now return to show that no node in X[i′] is to the left of any node in s2. There are two cases depending on whether j = s1 or j > s1. If j > s1 then j was changed either in one of the four cases I -- IV, or in the previous iteration in case 2. If j was equal to s1 at the beginning of this iteration then j was incremented in one of the four cases I -- IV. Thus none of the cases applied to s1. By Proposition 6 no node in X[i′] can be to the left of a node in X[s1]. Since s2 ⊆ X[s1] the claim follows. If j = s1 it follows from case 2 that left(X[i′], s2) = ∅ (otherwise the potential pairs would not have been added to the output in this iteration) and the claim follows immediately. Now assume (x, y) ∈ mop(X ,Y). We will deal with each of the cases from Proposition 6 separately. 1. Case (i): c(x) = c(y) = r(v, w). 2. Case (i): c(x) = c(y) = l(v, w). 3. Case (ii): c(x) = c(y) = l(v). 4. Case (iii): c(x) = l(v, w) and c(y) = s(v, w). 5. Case (iv): c(x) = s(v, w) and c(y) = r(v, w). 6. Case (v): c(x) = l(v, w) and c(y) = r(v, w). 7. Case (v): c(x) ⊳ c(y) and c(x) and c(y) belong to different clusters. Note that if c(x) ⊳ c(y) then x is the rightmost node in X[c(x)] and y is the leftmost node in Y [c(y)]. We first show that in all cases we will have x = rl ∈ r2 and y = sl ∈ s2 for some l at some iteration. Consider the first iteration where either x ∈ X[i] or y ∈ Y [j]. Let i′ and j′ be the values of i and j, respectively, in this iteration. There are three cases: (a) x ∈ X[i′] and y ∈ Y [j′]. For case 1 -- 5 the procedure goes into case 2. From the correctness of mop we get x ∈ r and y ∈ s. Thus r 6= ∅ and we set (r1, r2) = (i′, r) and (s1, s2) = (j′, s) and the claim follows. For case 6 -- 7 the procedure goes into case 1. Since this iteration is the first where y ∈ Y [j] we have j′ > s1 and we set (r1, r2) = (i′, rightC(i′)(1, X[i′])) and (s1, s2) = (j′, leftC(j ′)(1, Y [j′])). Since x is the rightmost node in X[i′] and y is the leftmost node in Y [c(j′)] the claim follows. (b) x ∈ X[i′] and y 6∈ Y [j′]. Since (x, y) ∈ mop(X ,Y) this implies j′ < c(y) and there exists no node y′ ∈ Y [j′] such that x ⊳ y′. Assume that there existed such a y′. Then x ⊳ y′ ⊳ y due to the macro tree order of Y contradicting (x, y) ∈ mop(X ,Y). Thus i′ 6⊳ j′. From case I -- IV of the procedure it follows that either i′ = j′, i′ = l(v, w) and j′ = s(v, w), or i′ = s(v, w) and j′ = r(v, w). From this and j′ < c(y) it follows that we are in case 4 or 7 from above. The procedure enters case 2 in this iteration. If we are in case 4 then i′ = l(v, w) = j′ and c(y) = s(v, w). If r = ∅ then i = i′, X[i′] is unchanged, and j = j′ + 1 = s(v, w) = c(y) at the end of this iteration. If r 6= ∅ then x must be to the right of all nodes in x′ ∈ r. Assume that there is a x′ ∈ r such that x ⊳ x′. Since x′ ∈ r there exists a node y′ ∈ s such that x′ ⊳ y′ ⊳ y. That y′ ⊳ y follows from y′ ∈ l(v, w) and y ∈ s(v, w) and the assumption that Y is deep. Thus x ⊳ x′ ⊳ y′ ⊳ y contradicting that (x, y) ∈ mop(X ,Y). Therefore, i = i′, x ∈ X[i′] and j = j′ + 1 = s(v, w) = c(y) at the end of this iteration. From case I of the procedure and the analysis of case (a) it follows that x = rl ∈ r2 and y = sl ∈ s2 for some l. 41 Now assume we are in case 7. By the same argument as before i = i′, x ∈ X[i], and j > j′ at the end of this iteration. Unless i′ = l(v, w) = j′ this implies that i ⊳ j at line 14 ("Compare i and j") in the next iteration. If i′ = l(v, w) = j′ then either i ⊳ j after the first loop in the next iteration (line 7), and the claim follows as before, or i = l(v, w) and j = s(v, w). In the last case we get into case (b) again, but it follows from the analysis that in the iteration after the next we will have i ⊳ j = c(y). The claim follows from the analysis of case (a). (c) x 6∈ X[i′] and y ∈ Y [j′]. It follows by inspection of the cases that unless we are in case 1 we have i′ ⊳ j′. If we are in case 1 (j′ = c(x) = r(v, w) = c(y)) we have either i′ ⊳ j′ or i′ = s(v, w). First we consider the cases 2 -- 7. Since i′ ⊳ j′ the procedure enters case 1 in this iteration. Thus i is incremented and j stays the same. This happens until i = c(x). Now consider case 1. If i′ ⊳ j′ the procedure enters case 1 in this iteration. Thus i is incremented and j stays the same. In the next iteration either the same happens or i′ = s(v, w). If i′ = s(v, w) the procedure enters case 2. Since i′ is a spine node and X is deep, X[i] contains only one node x′. By the structure of the macro tree and the assumption that X is deep x′ ⊳ x. Since x ⊳ y ∈ Y [j′] this implies r 6= ∅. It follows from case 2(b) of the procedure that i is incremented while j stays the same. At line 14 ("Compare i and j") in the next iteration we will have j = i = r(v, w) since all entries in X between j′ and r(v, w) are empty due to the assumption that X is deep. The claim follows from the analysis in case (a). It remains to show that once x = rl ∈ r2 and y = sl ∈ s2 they will stay this way until added to the output. Consider the iteration where x and y are assigned to r2 and s2. At the end of this iteration either i or j or both are incremented. Assume j is incremented while the potential pairs are still unchanged. Since j is incremented we have s1 < j until s1 is changed. It follows from case 1 and 2 of the procedure that in this case (r1, r2) is only changed if at the same time (s1, s2) are changed and right before that (r1, r2) and (s1, s2) are added to the output. Consider first case 1 -- 3. If i is incremented then j is incremented in one the cases I -- V in the next iteration since i′ = j′. By the above argument x and y are added to the output. For case 4 j is incremented (case 2(a) of the procedure) and the claim follows as before. For case 5 -- 7 first note that r2 and s2 contain only one node each, i.e., x = r2 and y = s2. For case 5 i is incremented (case 2(b) of the procedure). Since X is deep we have i ≥ r(v, w) = j′ at line 14 ("Compare i and j") in the next iteration. If i > r(v, w) then j > j′ and the claim follows. If i = r(v, w) the procedure enters case 2. If r = ∅ then j is incremented and the claim follows. If r 6= ∅ then s1 = j and (x, y) ∈ mop(X ,Y) implies leftC(i,j)(X[i], s2) = leftofC(i,j)(X[i], y) = ∅. Thus (r1, r2) and (s1, s2) are added to the output. If we are in case 6 and 7, i is incremented. Consider case 6. Since (x, y) ∈ mop(X ,Y) all entries in X between l(v, w) and r(v, w) are empty. Thus at line 14 ("Compare i and j") in the next iteration i ≥ r(v, w). The proof is equivalent to the one for case 5. Consider case 7. If j is a boundary node then all entries in X between c(x) and j are empty. Thus j is incremented in the second loop of the next iteration. For all other cases for j the proof is similar to the proof of case 5. (cid:3) Lemma 27 In procedure Match we have the following invariant of X[i] and Y [j] in line 6: left(1, X[i]) = Xl and left(1, Y [j]) = Yl for some l . Proof. Induction on the number of iterations of the outer loop. Base case: In the first iteration X[i] and Y [j] are the first nonempty entries in X and Y and thus left(1, X[i]) = X1 and left(1, Y [j]) = Y1. For the induction step let i′ and j′ be the values of i and j in the previous iteration. By the induction hypothesis left(1, X[i′]) = Xl′ and left(1, Y [j′]) = Yl′ . If x = X[i′] = Y [j′] both i and j were incremented and left(1, X[i]) = Xl′+x and left(1, Y [j]) = Yl′+x. If x = X[i′] < Y [j′] then i was incremented implying left(1, X[i]) = Xl′+x. In that case j = j′ and Y [j] = left(x, Y [j′]) implying left(1, Y [j]) = Yl′+x. Sim- ilarly, if X[i′] > Y [j′] = y we have left(1, X[i]) = Xl′+y. In that case j = j′ and left(1, Y [j]) = Yl′+y. (cid:3) Lemma 28 Procedure Match is correctly implemented. 42 Proof. We need to show that for all 1 ≤ k ≤ X: Xk ∈ Match(X, Y, Y ′) ⇔ Xk ∈ {XjYj ∈ Y}. Consider the iteration where Xk ∈ X[i] and Yk ∈ Y [j]. By Lemma 27 such an iteration exists. If Y [j] = Y [j′] then Yk ∈ Y ′ implying Xk ∈ {XjYj ∈ Y}. It follows from the implementation of case 1(a) and 1(b) that if x ≤ y all nodes in X[i] are added to the output and thus Xk ∈ Match(X, Y, Y ′). If x > y then Xk ∈ left(y, X[i]) since Yk ∈ Y [j] and thus Xk ∈ Match(X, Y, Y ′). If Y [j] 6= Y ′[j] the procedure calls match with some subset of X[i], Y [j], and Y ′[j] depending on the size of x and y. By Lemma 27 and the correctness of match it follows that Xk ∈ Match(X, Y, Y ′) ⇔ Xk ∈ {XjYj ∈ Y}. (cid:3) Lemma 29 Procedure MopRight is correctly implemented. Proof. Follows from the correctness of MopSim (Lemma 26) and Match (Lemma 28). (cid:3) Finally, we consider correctness of the Fl procedure. Lemma 30 Procedure Fl is correctly implemented. Proof. Let X denote the set represented by X and let F = {fl(x, α)x ∈ X}. To show Fl(X, α) ⊆ F we will first show that for any node x added to R during the computation x ∈ F . Consider a node x ∈ R[i] for some i. Either x was added directly to R after a computation of N in one of the three cases of the procedure or it was added after the computation of S. In the first case x ∈ F follows from the correctness of FlC . If x was added after the computation of S it follows from the correctness of FlM that x ∈ C(i) for some i ∈ S. Due to the correctness of FlC we have x ∈ F . To show Deep(F ) ⊆ Fl(X, α) we use Proposition 5. Let x be a node in Deep(F ) and let x′ be a node in X such that fl(x′, α) = x. We have x′ ∈ X[i] for some i. If i is a left or right node then according to Proposition 5 x can be in i (case (i)), on the spine (case (ii)), in the top boundary node (case (ii)), or in an ancestor of i in the macro tree (case (iii)). If x is in the same cluster as x′ then it follows from the correctness of FlC that x ∈ N . Thus x is added to R and due to the correctness of Deep we have x ∈ Fl(X, α). If c(x) is in a different cluster than c(x′) then c(x) is an ancestor of c(x′) in the macro tree due to Proposition 5. Since x ∈ Deep(F ) we have N = ∅ and thus parent(v) ≺M c(x′) is added to L. It follows from the correctness of FlM that c(x) ∈ S. Due to the structure of the macro tree c(x) is either a boundary node or a spine node and thus x = flC(c(x))(first(c(x)), α) = FlC(c(x))(first(c(x)), α). The last equality follows from the correctness of FlC. That x ∈ Fl(X, α) now follows from the above analysis showing that only nodes from F are added to R and the correctness of Deep. If i is a leaf node then x can be in i (case (i)), in the top boundary node (case (iii)), or in an ancestor of i in the macro tree (case (iii)). The correctness follows by an analysis similar to the one for the previous case. If i is a spine node or a boundary node, then x is either in i (case (i)) or in an ancestor of i in the macro tree (case (iii)). The correctness follows by an analysis similar to the one for the first case. (cid:3) 5.5 Complexity of the Tree Inclusion Algorithm To analyze the complexity of the node array implementation we first bound the running time of the above implementation of the set procedures. All procedures scan the input from left-to-right while gradually producing the output. In addition to this procedure Fl needs a call to a node list implementation of Fl on the macro tree. Given the data structure described in Section 5.2 it is easy to check that each step in the scan can be performed in O(1) time giving a total of O(nT / log nT ) time. Since the number of nodes in the macro tree is O(nT / log nT ), the call to the node list implementation of Fl is easily done within the same time. Hence, we have the following lemma. Lemma 31 For any tree T there is a data structure using O(nT ) space and O(nT log nT ) preprocessing time which supports all of the set procedures in O(nT / log nT ) time. 43 Next consider computing the deep occurrences of P in T using the procedure Emb of Section 3 and Lemma 31. The following lemma bounds the space usage. Lemma 32 The total size of the saved embeddings at any time during the computation of Emb(root(P )) is O(nT ). Proof. Let v be the node for which we are currently computing Emb. Let p be the path from the root to v and let w0, . . . , wl be the light nodes on this path. We have l = ldepth(v). As in the proof of Lemma 15 it suffices to bound Emb(heavy(parent(wi))) for all i. Assume that lP ≤ lT (otherwise we can check this in linear time and conclude that P cannot be included in T ). Each of the node arrays use O(nT / log nT ) space and therefore by Corollary 1 we have that Pl i=1 Emb(heavy(parent(wi))) = O(n/ log nT · log lP ) = O(nT ). For the time complexity note that during the computation of Emb(root(P )) each node v ∈ V (P ) con- tributes a constant number of calls to the set procedures. Hence, the total time used by the algorithm is O(nP nT / log nT + nT log nT ). Thus we have shown the following. (cid:3) Theorem 4 For trees P and T the tree inclusion problem can be solved in O(nP nT / log nT + nT log nT ) time and O(nT ) space. Combining the results in Theorems 2, 4 and Corollary 2 we have the main result of Theorem 1. 6 Conclusion We have presented three algorithms for the tree inclusion problem, which match or improve the best known time complexities while using only linear space. We believe that some of the new ideas are likely to be of both practical and theoretical value in future work. From a practical perspective, space is a common bottleneck for processing large data sets and hence reducing the space can significantly improve performance in practice. From a theoretical perspective, we have introduced several non-trivial algorithms to manipulate sets of nodes in trees that may have applications to other problems. For instance, the Nca procedure from Section 5 computes multiple nearest common ancestor queries in time sublinear in the size of input sets. Acknowledgments We would like to thank the anonymous reviewers of earlier drafts of this paper for many valuable comments that greatly improved the quality of the paper. We would also especially like to thank the reviewer who discovered the error in the space complexity of the original draft. References [1] L. Alonso and R. Schott. On the tree inclusion problem. Acta Inf., 37(9):653 -- 670, 2001. [2] S. Alstrup, C. Gavoille, H. Kaplan, and T. Rauhe. Nearest common ancestors: A survey and a new algorithm for a distributed environment. Theory of Comput. Syst., 37:441 -- 456, 2004. [3] S. Alstrup, J. Holm, K. de Lichtenberg, and M. Thorup. Minimizing diameters of dynamic trees. In Proceedings of the 24th International Colloquium on Automata, Languages and Programming, pages 270 -- 280, 1997. [4] S. Alstrup, J. Holm, and M. Thorup. Maintaining center and median in dynamic trees. In Proceedings of the 7th Scandinavian Workshop on Algorithm Theory, pages 46 -- 56, 2000. [5] S. Alstrup, T. Husfeldt, and T. Rauhe. Marked ancestor problems. In Proceedings of the 39th Symposium on Foundations of Computer Science, pages 534 -- 543, 1998. 44 [6] S. Alstrup and T. Rauhe. Improved labeling schemes for ancestor queries. In Proceedings of the 13th Symposium on Discrete Algorithms, pages 947 -- 953, 2002. [7] M. A. Bender and M. Farach-Colton. The LCA problem revisited. American Symposium on Theoretical Informatics, pages 88 -- 94, 2000. In Proceedings of the 4th Latin [8] P. Bille. A survey on tree edit distance and related problems. Theoret. Comput. Sci., 337(1-3):217 -- 239, 2005. [9] P. Bille and I. L. Gørtz. The tree inclusion problem: In optimal space and faster. In Proceedings of the 32nd International Colloquium on Automata, Languages and Programming, volume 3580 of Lecture Notes in Computer Science, pages 66 -- 77. Springer-Verlag, 2005. [10] S. Boag, D. Chamberlin, M. Fernandez, D. Florescu, J. Robie, J. Sim´eon, and M. Stefanescu. XML query language (XQuery), available as http://www.w3.org/TR/xquery, 2001. [11] W. Chen. More efficient algorithm for ordered tree inclusion. J. Algorithms, 26:370 -- 385, 1998. [12] M. J. Chung. O(n2.5) algorithm for the subgraph homeomorphism problem on trees. J. Algorithms, 8(1):106 -- 112, 1987. [13] J. Clark and S. DeRose. XML path language (XPath), available as http://www.w3.org/TR/xpath, 1999. [14] R. Cole, R. Hariharan, and P. Indyk. Tree pattern matching and subset matching in deterministic O(nlog3n)-time. In Proceedings of the 10th Symposium on Discrete Algorithms, pages 245 -- 254, 1999. [15] E. D. Demaine, S. Mozes, B. Rossman, and O. Weimann. An optimal decomposition algorithm for tree edit distance. In Proccedings of the 34th International Colloquium on Automata, Languages and Programming, volume 4596 of Lecture Notes in Computer Science, pages 146 -- 157. Springer, 2007. [16] P. F. Dietz. Fully persistent arrays. In Proceedings of the Workshop on Algorithms and Data Structures, pages 67 -- 74, 1989. [17] M. Dubiner, Z. Galil, and E. Magen. Faster tree pattern matching. In Proceedings of the 31st Symposium on the Foundations of Computer Science, pages 145 -- 150, 1990. [18] P. Ferragina and S. Muthukrishnan. Efficient dynamic method-lookup for object oriented languages. In Proceedings of the 4th European Symposium on Algorithms, pages 107 -- 120, 1996. [19] G. N. Frederickson. Ambivalent data structures for dynamic 2-edge-connectivity and k smallest spanning trees. SIAM J. Comput., 26(2):484 -- 538, 1997. [20] T. Hagerup, P. B. Miltersen, and R. Pagh. Deterministic dictionaries. J. Algorithms, 41(1):69 -- 85, 2001. [21] D. Harel and R. E. Tarjan. Fast algorithms for finding nearest common ancestors. SIAM J. Comput., 13(2):338 -- 355, 1984. [22] C. M. Hoffmann and M. J. O'Donnell. Pattern matching in trees. J. ACM, 29(1):68 -- 95, 1982. [23] P. Kilpelainen. Tree Matching Problems with Applications to Structured Text Databases. PhD thesis, University of Helsinki, Department of Computer Science, November 1992. [24] P. Kilpelainen and H. Mannila. Retrieval from hierarchical texts by partial patterns. In Proceedings of the 16th Conference on Research and Development in Information Retrieval, pages 214 -- 222, 1993. [25] P. Kilpelainen and H. Mannila. Ordered and unordered tree inclusion. SIAM J. Comput., 24:340 -- 356, 1995. 45 [26] P. Klein. Computing the edit-distance between unrooted ordered trees. In Proceedings of the 6th European Symposium on Algorithms, pages 91 -- 102, 1998. [27] D. E. Knuth. The Art of Computer Programming, Volume 1. Addison-Wesley, 1969. [28] S. R. Kosaraju. Efficient tree pattern matching. In Proceedings of the 30th Symposium on the Founda- tions of Computer Science, pages 178 -- 183, 1989. [29] H. Mannila and K. J. Raiha. On query languages for the p-string data model. Information Modelling and Knowledge Bases, pages 469 -- 482, 1990. [30] J. Matousek and R. Thomas. On the complexity of finding iso- and other morphisms for partial k-trees. Discrete Math., 108:343 -- 364, 1992. [31] S. Muthukrishnan and M. Muller. Time and space efficient method-lookup for object-oriented programs. In Proceedings of the 7th Symposium on Discrete algorithms, pages 42 -- 51, 1996. [32] T. Richter. A new algorithm for the ordered tree inclusion problem. In Proceedings of the 8th Symposium on Combinatorial Pattern Matching, pages 150 -- 166, 1997. [33] T. Schlieder and H. Meuss. Querying and ranking XML documents. J. Am. Soc. Inf. Sci. Technol., 53(6):489 -- 503, 2002. [34] T. Schlieder and F. Naumann. Approximate tree embedding for querying XML data. In Proceedings of the Workshop On XML and Information Retrieval, 2000. [35] R. Shamir and D. Tsur. Faster subtree isomorphism. J. of Algorithms, 33:267 -- 280, 1999. [36] K.-C. Tai. The tree-to-tree correction problem. J. ACM, 26:422 -- 433, 1979. [37] A. Termier, M. Rousset, and M. Sebag. Treefinder: a first step towards XML data mining. In Proceedings of the 2nd International Conference on Data Mining, page 450, 2002. [38] M. Thorup. Space efficient dynamic stabbing with fast queries. In Proceedings of the 33rd Symposium on Theory of Computing, pages 649 -- 658, 2003. [39] H. Yang, L. Lee, and W. Hsu. Finding hot query patterns over an XQuery stream. The VLDB Journal, 13(4):318 -- 332, 2004. [40] L. H. Yang, M. L. Lee, and W. Hsu. Efficient mining of XML query patterns for caching. In Proceedings of the 29th Conference on Very Large Data Bases, pages 69 -- 80, 2003. [41] P. Zezula, G. Amato, F. Debole, and F. Rabitti. Tree signatures for XML querying and navigation. In Proceedings of the 1st International XML Database Symposium, pages 149 -- 163, 2003. [42] K. Zhang and D. Shasha. Simple fast algorithms for the editing distance between trees and related problems. SIAM J. Comput., 18:1245 -- 1262, 1989. 46
1604.00870
2
1604
2018-01-11T18:50:35
Mixing Time for Some Adjacent Transposition Markov Chains
[ "cs.DS" ]
We prove rapid mixing for certain Markov chains on the set $S_n$ of permutations on $1,2,\dots,n$ in which adjacent transpositions are made with probabilities that depend on the items being transposed. Typically, when in state $\sigma$, a position $i<n$ is chosen uniformly at random, and $\sigma(i)$ and $\sigma(i{+}1)$ are swapped with probability depending on $\sigma(i)$ and $\sigma(i{+}1)$. The stationary distributions of such chains appear in various fields of theoretical computer science, and rapid mixing established in the uniform case. Recently, there has been progress in cases with biased stationary distributions, but there are wide classes of such chains whose mixing time is unknown. One case of particular interest is what we call the "gladiator chain," in which each number $g$ is assigned a "strength" $s_g$ and when $g$ and $g'$ are adjacent and chosen for possible swapping, $g$ comes out on top with probability $s_g/(s_g + s_{g'})$. We obtain a polynomial-time upper bound on mixing time when the gladiators fall into only three strength classes. A preliminary version of this paper appeared as "Mixing of Permutations by Biased Transposition" in STACS 2017.
cs.DS
cs
Mixing Time for Some Adjacent Transposition Markov Chains Shahrzad Haddadan, Peter Winkler Abstract We prove rapid mixing for certain Markov chains on the set Sn of permutations on 1, 2, . . . , n in which adjacent transpositions are made with probabilities that depend on the items being transposed. Typically, when in state σ, a position i < n is chosen uniformly at random, and σ(i) and σ(i+1) are swapped with probability depending on σ(i) and σ(i+1). The stationary distributions of such chains appear in various fields of theoretical computer science [24, 20, 4], and rapid mixing established in the uniform case [24]. Recently, there has been progress in cases with biased stationary dis- tributions [3, 2], but there are wide classes of such chains whose mixing time is unknown. One case of particular interest is what we call the "glad- iator chain," in which each number g is assigned a "strength" sg and when g and g(cid:48) are adjacent and chosen for possible swapping, g comes out on top with probability sg/(sg + sg(cid:48) ). We obtain a polynomial-time upper bound on mixing time when the gladiators fall into only three strength classes. A preliminary version of this paper appeared as "Mixing of Permuta- tions by Biased Transposition" in STACS 2017 [9]. Introduction 1 For n ∈ N, let Sn be the set of all permutations of the numbers 1, 2, . . . , n. One can think of a permutation as the order in which a search engine arranges its results [4], the order in which a self organizing list arranges its items [20, 10], or the order the playing cards appear after shuffling [24, 1]; each of these suggests different probability distributions on Sn. Taking samples from such distributions is a useful task which can be tackled using a Markov chain, in particular when dynamic programming approaches fail to have a polynomial runtime.1 1We note here that for the particular case of our study, i.e., gladiators with constant number of strengths, the dynamic programming approach is efficient. However, the mixing problem is still interesting for at least two reasons: (1) As discussed in the introduction, a self-organizing list is basically a Markov chain with high mixing time. Thus, analyzing the gladiator chain is closely related to studying this data structure's performance. (2) Dynamic programming algorithms would require exponential time when we have polynomial number of teams. Thus, employing Markov chains could provide an efficient sampling tool in such cases. 1 A natural Markov chain on Sn picks a number 1 ≤ i ≤ n−1 uniformly at random and from state σ, puts σ(i+1) ahead of σ(i) with probability pσ(i),σ(i+1). We call such chains adjacent transposition Markov chains. In this paper, we consider the total variation mixing time, which is defined as the number of steps required before the total variation distance between the distribution of the current state and stationarity is less than  (where  is some fixed convergence factor). For Markov chain M we denote this time by t(M), or if  = 1/4, simply by t(M). Jim Fill [7] conjectured that if an adjacent transposition Markov chain is monotone, then it is rapidly mixing. Monotonicity in this context means that for all i, j satisfying 1 ≤ i < j ≤ n, pi,j ≥ 1/2, pi,j−1 ≤ pi,j, and pi+1,j ≤ pi,j [7]. Furthermore, his conjecture asserts "the simple chain" whose stationary distribution is uniform has the highest spectral gap among all monotone adjacent transposition chains.2 Here we provide a brief history of the results on the adjacent transposition Markov chains. All of these chains are monotone and rapidly mixing. Wilson and Benjamini's papers [24, 3] led to Fill's conjecture [7]; Bhakta et al. [2] verified the conjecture in two cases. The current paper, as well as a recent result by Miracle et al. [16], study the so-called "gladiator chain" under certain conditions, and verify Fill's conjecture in limited cases. We will define the gladiator chain and present a few of its applications later in this introduction. 1. The simple chain. In the case where pi,j = 1/2 for all i and j, the chain will have a simple description: Given a permutation σ, pick two adjacent elements uniformly at random, and flip a fair coin to decide whether to swap them. We call this chain, whose stationary distribution is uniform, the simple chain. Getting precise mixing results for this chain turned out not to be simple; many papers targeted this problem [6, 5], and finally Wilson [24] showed the mixing time for this chain is Θ(n3 log n) (that is, he obtained lower and upper bounds within a constant factor). 2. The constant-bias chain. After Wilson's paper, Benjamini et al. [3] studied the case where pi,j = p > 1/2 for all i < j, and pj,i = 1−p. The station- ary distribution of this chain is the one assigning a probability proportional to pinv(σ), to each σ ∈ Sn where inv(σ) is the number of inversions in σ. This dis- tribution appears in statistics and machine learning since it is the distribution generated by the "Mallows model" [4, 13]. Benjamini et al. [3], showed that the constant biased Markov chain is closely related to another Markov chain known as the asymmetric simple exclusion process, and both chains mix in Θ(n2) steps. We will talk more about exclusion processes later on in this introduction. 3. "Choose your weapon" and "league hierarchy" chains. The In the choose following two special cases were studied by Bhakta et al. your weapon chain pi,j is only dependent on i, and the league hierarchy chain is [2]. 2 The spectral gap is another measure of mixing. Here, we are interested in total variation mixing time which, in this case, is within a polynomial factor of the spectral gap. 2 given by a binary tree T with n leaves. Each interior node v of T is labeled with some probability 1/2 ≤ qv ≤ 1, and the leaves are labeled by numbers 1 . . . n. The probability of putting j ahead of i for j > i is equal to pi,j = qj∧i where j ∧ i is the node that is the lowest common ancestor of i and j in T . Bhakta et al. showed that the choose your weapon chain mixes in O(n8 log n) steps and the league hierarchy chain in O(n4 log n) steps. Here we are interested in gladiator chains, which constitute a subclass of the monotone adjacent transposition chains. Gladiator chains have connections to self organizing lists, and were introduced by Jim Fill. Fill was interested in probabilistic analysis of algorithms for self-organizing lists (SOLs). Self-organizing lists are data structures that facilitate linear search- ing in a list of records; the objective of a self-organizing list is to sort the records in non-decreasing order of their access frequencies [20]. Since these frequen- cies are not known in advance, an SOL algorithm aims to move a particular record ahead in the list when access on that record is requested. There are two widely used SOL algorithms: the move ahead one algorithm (MA1) and the move to front algorithm (MTF). In MA1, if the current state of the list is (x1, x2, . . . , xi−1, xi, xi+1, . . . , xn) and the ith record is requested for access, it will go ahead in the list only one position and the list will be modified to (x1, x2, . . . , xi, xi−1, xi+1, . . . , xn). In MTF it will go to the front and the list will be modified to (xi, x1, x2, . . . , xi−1, xi+1, . . . , xn). It appears that MA1 should perform better than MTF when the list is almost sorted and worse when the low frequency records are standing in front; although this has been con- firmed by simulations, it has not been analytically confirmed [10]. Considering the adjacent transposition Markov chain corresponding to MA1, Fill shows [7] that there are cases in which the chain is not rapidly mixing. Hence, he poses the question of sampling from the stationary distribution of MA1, and he intro- duces the gladiator chain which has the same stationary distribution as MA1 and seems to be rapidly mixing for arbitrary choice of parameters. In the gladiator chain, each element i can be thought of as a gladiator with strength s(i). Every permutation of numbers 1, 2, . . . n can be thought of as a ranking of gladiators. In each step of Markov chains we choose 1 ≤ k < n uniformly at random, i.e., we choose adjacent gladiators σ(k) = i and σ(k +1) = j. These gladiators will fight over their position in ranking. With probability pj,i = s(i)/(s(i) + s(j)), gladiator i will be the winner of the game and will be placed ahead of j in σ if he isn't already. With probability 1−p, j is put ahead of i. If Fill's conjecture holds, gladiator chains must mix rapidly. Exclusion processes. A related Markov chain which has received a lot of attention is the exclusion process ([18, 17]). In this chain we have a graph G = (cid:104)V, E(cid:105) and m < V particles on the vertices of G. The sample space is the set containing all the different placements of the m particles on vertices of G. At each step of the Markov chain we pick a vertex v uniformly at random with probability 1/V and one of its adjacent vertices w with probability 1/d(v). If there is a particle in one of the vertices and not the other one, we swap the 3 position of the particle with a constant probability p. We are interested in the linear exclusion process when the graph is a finite path with n vertices. As mentioned before, the linear exclusion process was studied by Benjamini et al. [3] and is known to be mixing in time Θ(n2).3 Later, Greenberg et al. [8] presented a simpler proof. Our Contribution. We study the gladiator chain when the gladiators fall into a constant number of teams, gladiators in each team having the same strength (Definition 2.1). We then extend the definition of linear exclusion process (studied by Benjamini et al.) by allowing particles of different types to swap their positions on a line. We call this new chain a linear particle system (Definition 2.2). We will show that mixing results for linear particle systems can produce mixing results for gladiator chains (Theorem 2.2). In particular, we study the linear particle system in which there are three particle types, and in Theorem 2.3 we extend Benjamini et al.'s result by showing the three particle system mixes rapidly. Having Theorem 2.3 we conclude that the following adjacent transposition chains mix rapidly, and hence confirming Fill's conjecture in these cases: The gladiator chain when gladiators fall into three teams of same-strength gladiators; and the league hierarchy chain for ternary trees (extending Bhakta et al.'s work [2]). Remark. We believe linear particle systems, like exclusion processes, are interesting Markov chains that may appear as components of other Markov chains, and thus would facilitate studying mixing times of other chains. For instance, in Section 4 of this paper, by using Theorem 2.3 we extend a result about binary trees to ternary trees. As another example, we remind the reader of the correspondence between the exclusion process and the Markov chains on the lattice paths in an n × m rectangular lattice (Figure 4). Similarly, there is a correspondence between the linear particle systems having k particles and the lattice paths in k−dimensional lattices (Figure 4). Some Markov chains defined on lattice paths in a k−dimensional rectangle have already been studied by Greenberg et al. [8]. We remark here that following our result in STACS 2017 [9], Miracle et al. [16] studied the mixing time of linear particle system when the number of particles is a constant k, and showed the mixing time is upper bounded by n2k+4. With different techniques from ours, they prove the mixing time of gladiator chains with a constant number of teams is upper bounded by n2k+6 log k. The mixing time for linear particle systems and gladiator chains with teams, remains an open problem in the cases in which the number of particle types or teams is more than a constant. Definitions and results are presented in Section 2, along with the correspon- dence between the gladiator chains and the linear particle systems. Section 3 contains the proof that the linear three-type system mixes rapidly under certain 3Benjamini et al. use this result to prove that the constant biased adjacent transposition chain is rapidly mixing. 4 Figure 1: The correspondence between lattice paths and linear particle sys- tems: The picture on the left illustrates two paths in a two dimensional lattice; the red one corresponds to 001110100100001 and the black one corresponds to 10110100010000. The picture on the right illustrates two paths in a three di- mensional lattice; the red one corresponds to 0012122002 and the black one corresponds to 1012222000. conditions. In Section 4, we discuss the league hierarchy chain and our result for ternary trees. 2 Definitions and Results Definition 2.1. Gladiator chain (Playing in teams). Consider the Markov chain on state space Sn that has the following properties: The set [n] (i.e. glad- iators) can be partitioned into subsets: T1, T2, . . . , Tk (k teams). We have the following strength function: s : [n] → R, s(g) = sj iff g ∈ Tj. At each step of Markov chain, we choose i ∈ [n−1] uniformly at random. Given that we are at state σ, and σ(i) = g, σ(i+1) = g(cid:48), we put g ahead of g(cid:48) with probability s(g)+s(g(cid:48)) . We denote a gladiator chain having n gladiators playing in k teams by Gk(n).4 s(g) This is a reversible Markov chain and the stationary distribution π is π(σ) = n(cid:89)i=1 s(i)σ −1(i)/Z. (Z is a normalizing factor.) (1) Note that by writing σ(i) = g we mean gladiator g is located at position i in σ. By writing σ−1(g) we are referring to the position of gladiator g in the permutation σ. We use this notation throughout the text and for permutations presenting both gladiators and particles. cles and of each type i, we have ni indistinguishable copies. Let n =(cid:80)k Definition 2.2. Linear particle systems. Assume we have k types of parti- i=1 ni. Let Ωn1,n1,...nk be the state space containing all the different linear arrange- ments of these n particles. If the current state of the Markov chain is σ, choose 4Although the notation Gk(n1, n2, . . . , nk) would be more precise (ni being cardinality of Ti), we avoid using it for simplicity and also because our analysis is not dependent on n1, n2, . . . , nk. 5 i ∈ [1, n − 1] uniformly at random. Let σ(i) be of type t and σ(i + 1) be of type t(cid:48). If t = t(cid:48) do nothing. Otherwise, put σ(i) ahead of σ(i + 1) w.p. pt,t(cid:48) and put σ(i + 1) ahead of σ(i) w.p. 1− pt,t(cid:48). We denote the linear particle system having n particles of k different types by Xk(n). This chain is also a reversible Markov chain. In the special case where pt,t(cid:48) = s(t) s(t)+s(t(cid:48)) the stationary distribution π is π(σ) = n(cid:89)i=1 s(i)σ −1(i)/Z (cid:48) . (cid:48) (Z is a normalizing factor.) (2) Proposition 2.1. By regarding gladiators of equal strength as indistinguishable particles, we associate to any gladiator system a linear particle system. Note that the state space of the gladiator system has cardinality n! for n different gladiators but the linear particle system has only n!/(n1!n2! . . . nk!) states, since particles of the same type are indistinguishable. Thus, Z(cid:48) (cid:28) Z. The following theorem, whose proof will be presented later, shows the connection between the mixing times of the two chains. Theorem 2.2. Let t(Xk) and t(Gk) be respectively the mixing times for a linear particle system and its corresponding gladiator chain. Then, t(Gk) ≤ O(n8) t(Xk). Our main result, which extends the results of Benjamini et al. [3] on exclusion processes, is the following: Theorem 2.3. Let X3(n) be a linear particle system of Definition 2.2, having particles of type A, B and C. Assume that we have strength functions assigned to each particle type, namely sA < sB < sC, and thus swapping probabilities pB,A = sA/(sA + sB), pB,C = sC/(sC + sB) and pA,C = sC/(sA + sC). If sA/sB, sB/sC < 1/2, then the mixing time of X3(n) satisfies t(X3(n)) ≤ O(n10). Remark 2.4. The condition sA/sB, sB/sC ≤ 1/2 comes from the following simple bound on q-binomials that we later prove in Lemma 3.4: If q < 1/2 then, (cid:0)m r(cid:1)q < 2r < ( 1 q )r. Better bounds on q-binomials would allow the result to be improved. We will prove Theorem 2.3 in Section 3. Having Theorem 2.3, we deduce the following case of Fill's conjecture: Corollary 2.5. The mixing time of G3(n) satisfies t(G3(n)) ≤ O(n18), provided sA/sB < 1/2 and sB/sC < 1/2, where C is the strongest playing team among the three, and the gladiators in team B are stronger than the gladiators in team A. Proof. From Theorems 2.3 and 2.2. 6 We present the following corollary of Theorem 2.3 here and discuss it in full detail later in Section 4. Corollary 2.6. (League hierarchies for ternary trees) Let T be a ternary tree with n leaves. The children of each interior node v are labeled with labels A(v), B(v), and C(v), and each internal node has three strength values sA(v), sB(v), and sC(v). The leaves are labeled by numbers 1, 2, . . . , n. The probability of putting j ahead of i for j > i is equal to pi,j = sX(v)/(sX(v) + sY (v)) where v is the node that is the lowest common ancestor of i and j in T , and X(v) is the child of v which is an ancestor of j, and Y (v) is the child of v which is an ancestor of i. If for each v ∈ T , sA(v), sB(v), and sC(v) satisfy the conditions in Theorem 2.3, then the mixing time of the league hierarchy chain is bounded by n14 log n. We finish this section by proving Theorem 2.2. 2.1 Gladiators and Particles (Proof of Theorem 2.2) Consider the gladiator chain Gk(n) for arbitrary n being the number of gladiators and k the number of teams. Assume that we have ni gladiators on team i; hence, i=1 ni = n. At each step of the chain, one of two things is happening: (cid:80)k 1. Whisking: gladiators of the same team are fighting. 2. Sifting: gladiators of different teams are fighting. If we were restricted to whisking steps the chain would be equivalent to a product of several simple chains analyzed by Wilson [24]. If we were restricted to sifting steps the chain would be the linear particle system chain introduced in Definition 2.2. In order to study the mixing time of the gladiator chain we analyze sifting and whisking steps separately, and then we employ the following decomposition theorem: Theorem 2.7. Decomposition Theorem [14]. Let M be a Markov chain on state space Ω partitioned into Ω1, Ω2, . . . , Ωk. For each i, let Mi be the restriction of M to Ωi that rejects moves going outside of Ω. Let πi(A) = π(A ∩ Ωi)/π(Ωi) for A ⊆ Ωi. We define the Markov chain ¯M on state space {1, . . . k} as follows: P r ¯M(i, j) =(cid:80)x∈Ωi,y∈Ωj πi(x)P rM(x, y), where P rM and P r ¯M are transition probabilities of M and ¯M respectively. Then t(M) ≤ 2t( ¯M) max i {t(Mi)}. To apply the decomposition theorem, we partition Sn to Sσ1,σ2,...,σk for all choices of σ1 ∈ Sn1, σ2 ∈ Sn2 , . . . , σk ∈ Snk , each Sσ1,σ2,...,σk being the set of all permutations in Sn in which all the gladiators corresponding to particle i preserve the ordering associated to them by σi. The restriction of Gk(n) to Sσ1,σ2,...,σk is equivalent to Xk(n). We define ¯G to be the Markov chain on (cid:81)k i=1 Sni with the following transition probabilities: 7 P r ¯G(Sσ1,σ2,...,σi,...,σk , Sσ1,σ2,...,σ(cid:48) i,...,σk ) = (cid:88)x∈Sσ1,σ2,...,σi,...,σk , y∈Sσ1 ,σ2 ,...,σ(cid:48) ,...,σk i π(x)P rG(x, y) π(Sσ1,σ2,...,σi,...,σk ) , where σi and σ(cid:48) i are only different in swapping j and j + 1st elements and P rG(x, y) = 1/2(n− 1) iff j and j+1st copies of particle i are adjacent in x and swapped in y. Moreover, we observe that: 1 π(Sσ1,σ2,...,σi,...,σk ) (cid:88)x∈Sσ1 ,σ2 ,...,σi,...,σk , y∈Sσ1,σ2,...,σ(cid:48) ,...,σk i π(x) ≥ 1/(n − 1). We can verify the above equation by the following reasoning: consider an arbi- trary permutation z ∈ Sσ1,σ2,...,σi,...,σk in which jth and j+1st copies of particle i are not adjacent. We can map z to two other permutations z1 and z2 where in z1 we take the the jth copy of particle i down to make it adjacent to the j+1st copy, and in z2 we take the the j+1st copy of particle i up to make it adjacent to the jth copy. We will have π(z)/π(z1) = π(z2)/π(z), and hence one of π(z1) or π(z2) will be larger than π(z). This mapping is in worst case n−1 to 1, hence the above equation holds. Having the above observations, we realize ¯G is the product of k adjacent transposition Markov chains, and in each of these Markov chains we swap two adjacent elements with probability at least 1/2(n − 1)2. Let these chains be ¯G1, ¯G2, . . . , ¯Gk. By comparing the conductance (for more information about conductance, see [12]) of this chain to the simple chain analyzed by Wilson [24], for each i we will have t( ¯Gi) ≤ n8 i . We use the following Theorem of [2]: Theorem 2.8. If ¯G is a product of k independent Markov chains { ¯Gi}k it updates each ¯Gi with probability pi, then i=1 and t( ¯G) ≤ max i=1,...,n 2 pi 2k ( ¯Gi). t  Plugging in pi = ni/n, we have t( ¯G) ≤ max(2n/ni)n8 and employing the Decomposition Theorem, i ≤ 2n8. Summing up t(Gk(n)) ≤ 4n8t(Xk(n)). 3 Three-Particle Systems (Proof of the Main Theorem) In this section we prove Theorem 2.3 which states that t(X3(n)) ≤ O(n10) if sA/sB, sB/sC ≤ 1/2. 8 Assume that we have a copies of particle A, b copies of particle B, and c copies of particle C. We denote the set containing all the different arrangements of these particles by Ωa,b,c. We introduce another Markov chain Xt(n) on the same sample space Ωa,b,c. Using the comparison method (see [19]) we will show that the mixing times of X3(n) and Xt(n) are related. polynomial time, and hence we deduce Theorem 2.3. Then we will use the path congestion technique to show Xt(n) mixes in mixing time of X3(n) Comparison ←−−−−−−− technique mixing time of Xt(n) Notation. We denote the substring σ(i)σ(i + 1) . . . σ(j) by σ[i, j], and by Bt we refer to a string which is t copies of particle B. Definition 3.1. Let Xt(n) be a Markov chain on state space Ωa,b,c and n = a + b + c. If the current state is σ, we choose natural numbers 1 ≤ i < j ≤ n uniformly at random and swap them following these rules (Figure 2): 1. If σ(i) = A and in σ(j) = C or vice versa and σ[i+1, j−1] = Bj−i−1. Then, put σ(i) and σ(j) in increasing order of their strength w.p. (sC/sA)(j−i)/(1+ (sC/sA)(j−i)). With probability 1/(1 + (sC/sA)(j−i)), put them in de- creasing order. We call this move a Jump and we denote it by J j i (A, C) if σ(i) = A and σ(j) = C; and J j i (C, A) for vice versa. 2. If σ[i, j−1] = Bj−i and σ(j) = A or if σ[i + 1, j] = Bj−i and σ(i) = A. Then, put σ(i) and σ(j) in increasing order of their strength w.p. (sB/sA)j−i/(1 + (sB/sA)j−i). With probability 1/(1 + (sB/sA)j−i), put them in decreasing order. We call this move a Hop, and we denote it by Hj i (A, B) if σ(i) = A and σ(j) = B; and Hj i (B, A) for vice versa. Similar rules and notation apply when swapping B and C. 3. Else, do nothing. Figure 2: Jumps and Hops are the transitions in the Markov chain Xt. It can be easily checked that Xt is reversible and its stationary distribution is the π in Equation 2. Lemma 3.1. t(X3(n)) ≤ 2n4 t(Xt(n)). 9 Jump:CABBBB.$.....BBACHop:BABBBB.$.....BBABBCBBBB.$.....BBCB Proof. We use the comparison technique5 in the proof of Lemma 3.1 (see [5, 19]). To any edge (σ, τ ) in Xt, we assign a path from σ to τ in X3. Let ei(p, p(cid:48)) be a move in X3 which swaps particles p and p(cid:48) located at positions i and i + 1 in an arrangement. To e = (σ, τ ) making J j i (A, C) in Xt, we correspond the following path in X3: ei(A, B), ei+1(A, B), . . . ej−2(A, B), ej−1(A, C), ej−2(B, C), . . . ei(B, C). We denote this path by γστ , and the set contaning all such paths by ΓJ . Sim- ilarly, to e = (σ, τ ) making Hj i (A, B) in Xt, we correspond the following path in X3: ei(A, B), ei+1(A, B), . . . ej−2(A, B), ej−1(A, B). We denote this path by γσ,τ , and the set contaning all such paths by ΓH. Let Γ = {γσ,τ}σ,τ∈Ωa,b,c = ΓJ ∪ ΓH. We now bound the congestion placed by Γ on edges of X3. Consider an arbitrary e = (α, β) making swap ei(A, B) and assume α[i − t − 1, i + d + 1] = pBtABdp(cid:48) where p and p(cid:48) are particles different from B. For any σ and τ in Ωa,b,c if e ∈ γσ,τ then, there must be i− t ≤ j ≤ i− 1 and i + 1 ≤ k ≤ i + d such (A, p(cid:48)). Thus, the congestion that γστ corresponds to Hk placed on e only by paths in ΓH is: j (A, B) or to J i+d+1 j (cid:80){σ,τe∈γστ∈ΓH} γσ,τC(σ, τ ) C(e) = i−1(cid:88)j=i−t i+d(cid:88)k=i+1 ≤ 2(d+t)(cid:80)t ≤ 2t(d+t)(cid:80)d j(cid:48)=1(cid:80)d k(cid:48)=1 γσ,τ(sB/sA)i−j(1 + sB/sA) (1 + (sB/sA)k+1−j) (sB /sA)j(cid:48) (sB /sA) (1+(sB /sA)j(cid:48)+k(cid:48) ) k(cid:48)=1 sB /sA (sB /sA)k(cid:48) ≤ n2. We can similarly show that the congestion placed on e by ΓJ is less than n2, where n is the length of the arrangements or total number of particles. For each e ∈ E(M), let Ae be the congestion Γ places on e. We will have Ae ≤ 2n2. We also know πmin ≥ qn(n+1), where q = max{sA/sB, sB/sC} (we consider q to be a constant). Hence, employing the Comparison Theorem we have t(X3(n)) ≤ max e∈E(M)Aeπmint(Xt(n)) ≤ (2n4)t(Xt(n)). Having the above connection it suffices to bound the mixing time of Xt(n). In the rest of this section our goal is to bound t(Xt). We use the path congestion In particular, for any two arbitrary states theorem, which is stated below. σ, τ ∈ Ωa,b,c, we introduce a path γσ,τ . Then we show that none of the edges of the Markov chain Xt(n) is congested heavily by these paths. Formally, we employ Theorem 3.2 and in Theorem 3.5 we show that t (Xt(n)) ≤ O(n4). 5 The comparison method was introduced by Diaconis and Saloff-Coste [5]; Randall and Tetali extended it and employed it for analysis of Glauber dynamics [19]. For more information about this method we encourage the reader to refer to [12]. 10 Theorem 3.2. (Canonical Paths Theorem [11]) Let M be a Markov chain with stationary distribution π and E the set of the edges in its underlying graph. For any two states σ and τ in the state space Ω we define a path γσ,τ . The congestion factor for any edge e ∈ E is denoted by Φe and is defined by Φe = 1 π(x)π(y). We can bound the mixing time of M using the congestion factor: t(M) ≤ 8Φ2(log π Φ = maxe∈E φe, πmin = minx∈Ω π(x) and  is the convergence parameter. C(e)(cid:80) x,y e∈γx,y −1 min + log ), where The Paths. For each σ, τ ∈ Ωa,b,c, we introduce the following path in Xt from σ to τ : We partition σ and τ to b + 1 blocks; the end points of these blocks are locations of Bs in τ . For instance if in τ , the first B is located at position i and the second B is located at position j then, the first block in both σ and τ is [1, i], and the second is [i + 1, j]. Starting from the first block, we change each block in two steps, first we use Jump moves and change the relative position of A and Cs in σ to become in the order in which they appear in τ . Then, we bring the B in that block to its location in τ . Formally, we repeat the following loop: Notation. By saying k = Bj(σ), we mean the jth copy of particle B is located at position k in σ. Starting from σ, we repeat the following steps until τ is reached. Initially, let i, j = 1. 1. Let k = Bj(τ ). We define the jth block of σ and τ to be the substring starting from i and ending in k. Note that in τ , each blocks starts right after a B and ends with a B. In the jth iteration, the goal is to change σ[i, k] until σ[1, k] = τ [1, k], i.e. the first j blocks equal in σ and τ . 2. Using Jumps, and starting from the lowest index i, we bring particles C or A down until A and C particles in the block [i, k] have the same order in σ and τ . 3. We use Hops and bring the jth B in σ to Bj(τ ). In this process, we may need to bring several copies of particle B out of the jth block in σ. In that case, we choose a random ordering of Bs and move them with respect to that order (details explained in the proof of Claim 3.3). 4. Set i = Bj(τ ) + 1. 5. Increment j. Claim 3.3. Let {γσ,τ}σ,τ∈Ωa,b,c be the set of paths defined as above. Then, for any arbitrary edge e in the Markov chain Xt the congestion Φe, defined in Theorem 3.2 satisfies Φe ≤ n. We present a roadmap to the proof of the above claim before providing details. 11 1st iteration: 2nd iteration: C σ : A B C A C B C A Jump −→ Step 1 C A B C A C B A C Jump −→ Step 1 C A B C A A B C C Jump −→ Step 1 C A B C A A B C C Hop −→ Step 2 C A B C A B A C C Hop −→ Step 2 3rd iteration: C A C B B A A C C Hop −→ Step 2 C A B C B A A C C τ : Jump −→ Step 1 A C C B B A A C C Figure 3: We use the path congestion technique to bound t(Xt). In each iteration we fix a block in σ until τ is reached. In order to verify the claim, we analyze the congestion of Jump and Hop edges separately. In both of the analyses, we consider an edge e = (α, β), and to any σ, τ such that e ∈ γσ,τ we assign a Fe(σ, τ ) ∈ Ωa,b,c. The reverse image of F could be a subset of Ωa,b,c × Ωa,b,c. However, using q−binomials6 we show that(cid:80)σ,τ are mapped to the same ζ π(σ)π(τ ) is bounded by a polynomial function of n multiplied by π(ζ), and then we conclude the claim. A key factor of our analysis is the use of q-binomials. Note the following observations: Assume that we have no copies of particle A, b copies of B, and c copies of particle C. Let M ∈ Ω0,b,c be the arrangement with maximum stationary probability, i.e. M = BbC c. Note that for each σ ∈ Ω0,b,c, π(σ)/π(M ) = (sB/sC)t, where t is the number of transpositions needed to get from M to σ. For a constant t, the number of σs requiring t transpositions is equal to the number of integer partitions of t fitting in an b × c rectangle (see Figure 4). Thus: (cid:88)σ∈Ω0,b,c π(σ) π(M ) =(cid:18)b + c b (cid:19)q ; q = sB/sC. We will use the following lemma in our proof: 9 = 4+4+1 9 = 4+3+2 9 = 3+3+3 τ1 : C B C C C B B τ2 : C C B C B C B τ3 : C C C B B B C Figure 4: Correspondence of partition functions with q-binomials: There are three integer partitions of 9 that fit into a 3×4 rectangle, and there are three arrangements of gladiators in Ω0,3,4 with q(τ1) = q(τ2) = q(τ3) = q9. In other wors, the coefficient of q9 in(cid:0)7 Lemma 3.4. If q < 1/2 then,(cid:0)m 3(cid:1)q equals 3. r(cid:1)q <(cid:81)r Algebraic Combinatorics," Chapter 6 (see [23]). 6More information about q-binomials can be found in Richard Stanley's course "Topics in i=1 1/(1 − q) < 2r < ( 1 q )r. 12 Proof. (cid:18)m r(cid:19)q = (1 − qm)(1 − qm−1) . . . (1 − qm−r+1) (1 − q)(1 − q2) . . . (1 − qr) = r(cid:89)i=1 1/(1 − q) < 2r < ( 1 q (1 − qm−i+1)/(1 − qi). )r. (cid:18)m r(cid:19)q < r(cid:89)i=1 Proof of Claim 3.3. Consider an edge e = (α, β) corresponding to J k+g (C, A). Assume that k = Cl(α), k + d = Am(α) (remember the notation k = pm(σ) meaning the mth copy of particle p is located at position k in σ), i.e., this edge is swapping the lth C with the mth A in α. k (cid:54)= b or z + z(cid:48) It follows from the way we set the paths that, for some j, Am(α) ≤ j < Am+1(α), Am(σ) = j, and for some i, Am−1(β) < i ≤ Am(β), Am(τ ) = i. The preceding blocks of α have been changed in accordance with τ , and the succeeding blocks of α have not been changed yet, hence they resemble σ blocks. Therefore we have α[1, i−1] = τ [1, i−1] and α[j+1, n] = σ[j+1, n] (see Figure 5). We define the function Fe : Ωa,b,c × Ωa,b,c → Ωa,b,c as follows: For any σ, τ satisfying e ∈ γσ,τ , let ξσ,τ := σ[1, i − 1]τ [i, n] (the symbol denotes con- catenation). Since the arrangements of particles is changing, we may have ξσ,τ /∈ Ωa,b,c. For instance we may have τ [i, n] ∈ Ωx,y,z and σ[1, i − 1] ∈ Ωx(cid:48),y(cid:48),z(cid:48) but x + x (cid:54)= a or y + y(cid:48) (cid:54)= c. However, we know a − (x + x(cid:48)) + (b − (y + y(cid:48))) + (c − (z + z(cid:48))) = 0, which means there is a way to substitute the particles in σ[1, i− 1] to change ξ to ζ so that ζ ∈ Ωa,b,c. We call this stage the substitution stage, in which we identify the particle or particles with extra copies in σ[1, i− 1], and we substitute the lowest copies of them with inadequate particles and produce ζ ∈ Ωa,b,c. Then, we define Fe(σ, τ ) := ζ. For instance, if a − (x + x(cid:48)) + (b − (y + y(cid:48))) = −(c − (z + z(cid:48))), then substitute the lowest c − (z + z(cid:48)) copies of A and B with Cs, and produce Fe(σ, τ ) = ζ. The substitution stage will cause a substitution cost, we denote the substitution cost by co(ζ), and define it as: co(ζ) = π(ζ)/π(ξ), where ξ = σ[1, i − 1]τ [i, n]. Note that if we make t substitutions, the substitution cost is at most (sC/sA)t. To make the analysis simpler we only analyze the worst case in which we assume we have substituted t Cs with As in σ[1, i − 1]. This assumption also means that in σ[i, j] we have t more As and t fewer Cs than in α[i, j]. Consider σ, τ such that e ∈ γσ,τ . Let Fe(σ, τ ) = ζ. We have, =(cid:18) π(τ ) π(α)(cid:19)(cid:18) π(σ) π(ζ) π(α) wi(σ[i, j])(cid:19) co(ζ), where the later term is the substitution cost, and wi(σ[i, j]) :=(cid:81)j π(α)(cid:19)(cid:18) wi(α[i, j]) Having g = Am(α) − Cl(α) we will get: k=i s(k)i+σ −1(k). 13 Figure 5: We define Fe(σ, τ ) = ζ. To produce ζ we first concatenate σ[1, i − 1] and τ [i, n], then substitute some particles. Let St be the set of all σs with t substitutions. We have: π(σ) π(α) (cid:88)τ ; α[1,i−1]=τ [1,i−1] π(τ ) π(α) π(α) (cid:19)(cid:18) wi(σ[i, j]) wi(α[i, j])(cid:19) π(α). (3) Φe = (1 + (sA/sC)g) (cid:88)σ; Φe ≤ (cid:88)ζ needs t substititions 1 co(ζ)(cid:88)τ (cid:88)σ∈St(cid:18) π(Fe(σ, τ )) π(α) α[j+1,n]=σ[j+1,n] wi(Mt)Qi Let Mt(α) be the arrangement that we get from replacing the lowest t copies wi(σ[i,j]) wi(α[i,j]) = ¯B(Mt(α)) := of particle C with copies of particle A in α[i, j]. We have: (cid:80)σ∈St (cid:80)σ:fix the positions of all Bs −1(k), and Qi , where wi(σ[i, j]) := (cid:81)j π(σ)/π(Mt(α)). k=i s(k)i+σ in Mt(α) and rearrange the rest of particles ¯B (Mt(α)) wi(α[i,j]) Figure 6: We obtain Mt(α) from α and then take the sum over all ζs (Equation 3). Note that wi(Mt)Q ¯B(Mt) ≤ qt(t+1)−2twi(α[i, j]), q being max{sA/sB, sB/sC}. This inequality holds because Q ¯B(Mt) ≤(cid:0)y t(cid:1)sA/sC ≤ q−2t and w(Mt)/w(α[i, j]) ≤ qt(t+1)(See Figure 6). 14 ↵⌧⇠1⌧[i,n]=⇠[i,n]=⇣[i,n][1,i1]=⇠[1,i1]co(⇣)-⇣-AACAACAAAHHYHHjACAACAiij[j,n]=↵[j,n]?6⌧[1,i]=↵[1,i]?6A⇣⌘◆✓✏...↵xxuu⌧P⇠⇡⇣◆⌘✓⇢◆⇣✓⌘Mtum............P⌧⇠⇡⇣◆⌘✓⇢◆⇣✓⌘⇣u⇣⌘◆✓✏ Moreover, (cid:80) ζ needs t substititions (cid:48) 1 co(ζ) ≤ (cid:0)t+b t (cid:1)q2 ≤ q−2t, where b(cid:48) is the number of Bs in σ[0, i − 1] and q = max{sA/sB, sB/sC}. Putting all of the above inequalities together, we will have that each edge of Jump is only congested by: Φe ≤ (1 + qg)(cid:88)t (qt(t+1)−4t) ≤ n. So far, we showed that any Jump edge is only congested by a factor of a polynomial function of n. Consider an edge corresponding to a Hop, namely e. We denote this edge by e = (α, β). Assume we are swapping A and B. Consider a state σ traversing e to get to τ , and assume we traversed e while fixing block [i, j]. Since we are making a Hop, As and Cs in the block are fixed according to τ , and we are bringing the kth B to its position in τ . Before we proceed to the proof there is a subtlety about using a Hop that needs to be explained. If Ak has to go down to reach its position in τ or if there is only one copy of it in the block there is no complication. Let's assume we have t copies of particle B in σ[i, j]. All of the t copies of B should move up and stand out of block σ[i, j] to reach their position in τ . In order to accomplish this, we choose a subset S of {1k, . . . 1t+k} uniformly at random and we move the elements of S in decreasing order of their index out of the block. Assume, when going from σ to τ we used e = (α, β) and in α[i, j] we have t copies of particle B: Bk, . . . , Bk+t and swapping Bk+l, Bk+l+1, . . . , Bk+d with the next A. We have, τ [1, i] = α[1, i], σ[j + t, n] = α[j + t, n], and for any i, if Bk+i(α) < Bl+k(α) then, Bk+i(α) = Bk+i(σ). The following information about S can be determined by examining α and β: Bk+d+1, . . . Bk+t /∈ S while S may contain any of Bk, . . . Bk+l. Therefore, among the random paths connecting σ to τ , there are 2l subsets traversing through e and hence the congestion they place on e is π(τ )π(σ)/2t−l. To bound Φe for each e we introduce correspondence Fe : Ωa,b,c × Ωa,b,c → Ωa,b,c satisfying: ∀ζ ∈ Fe(Ωa,b,c); (cid:80) σ,τ ; F−1 e (ζ)=(σ,τ ) π(α) π(σ)π(τ ) ≤ 2t−lπ(ζ); (4) where c is the number of Cs in α[i, j] and Fe(σ, τ ) (cid:54)= NULL if and only if, e = (α, β) ∈ γσ,τ . Let σ and τ be two ends of a path traversing through e. We define Fe := σ[1, i − 1]τ [i, n]; to verify Equation 4, take ζ = Fe(σ, τ ). We have π(σ)π(τ ) π(α) = π(σ) π(α) π(τ ) π(α) π(α). Thus, π(α) = π(ζ[1,i−1]) π(α[1,i−1]) π(σ) π(α) (cid:48)) = π(σ π(σ) π(ζ) π(ζ[j,n]) π(α[j,n]) = π(σ[1,i−1]) π(α[1,i−1]) π(τ [i,j−1]) π(α[i,j−1]) π(τ [j,n]) π(α[j,n]) π(ζ[i,j−1]) π(α[i,j−1]) π(τ ) π(α) , 15 where σ(cid:48) is the following arrangement: σ(cid:48) := α[1, i − 1]σ[i, j − 1]α[j, n]. We have π(σ(cid:48))/π(α) = π(σ[i, j])/π(α[i, j]). Hence, π(σ)π(τ ) π(α) = (cid:88)σ,τ F (σ,τ )=ζ π(σ(cid:48)) π(σ) π(ζ). (cid:88)σ,τ ;F (σ,τ )=ζ (cid:1)q π(σ) ≤(cid:0)j−i+t−l (cid:48)) Since we have t − l Bs with undecided position between j−i other elements we have(cid:80) π(σ , where q = max{sA/sB, sB/sC}. Thus, we have (cid:48)) (cid:80) π(σ π(σ) ≤ 2t−l. Hence, the congestion placed on e is: t−l Φe=(α,β) = (1 + qg) (cid:88)σ,τ e∈γσ,τ π(σ)π(τ ) π(α)2t−l ≤ 1. Summing up, we showed that for any edge e, Φe ≤ max{n, 1}. Having the above claim, we now use the path congestion Theorem (Theorem 3.2) to bound t(Xt(n)): Theorem 3.5. If sA/sB, sB/sC ≤ 1/2, then t(Xt(n)) ≤ O(n4). Proof. Since πmin ≥ qn(n+1), q being maximum of sA/sB and sB/sC, we can apply Theorem 3.2 and we will have, t(Xt) ≤ 8n2(n2 + ln(−1)) =⇒ t(Xt) ≤ 8n4. Finally, from Lemma 3.1 and Theorem 3.5 we conclude Theorem 2.3. 4 League Hierarchies for Trenary Trees. As mentioned earlier in Section 1, the league hierarchies are a class of monotone adjacent transposition Markov chains and were introduced by Bhakta et al. (SODA 2014) [2] for binary trees. Here we extend their definition to trenary trees. Definition 4.1. (League hierarchies for ternary trees). Consider a ternary tree whose leaves are labeled by 1, 2, . . . n, and inside each interior node v there are three numbers SR,v > SC,v > SL,v satisfying : SR,v > 1/2. We define SC,v the Markov chain L3 on Sn as follows. In state σ ∈ Sn, 1 ≤ i ≤ n is chosen uniformly at random and σi and σi+1 are swapped with probability pσ(i),σ(i+1). The pi,js are defined in accordance with the tree structure. For each i ≤ j, the probability if swapping pi,j is equal to g; SX,v/(SX,v + SY,v), v being the lowest common ancestor of the leaves labeled i and j, and X, Y being one of R, L, C depending respectively on whether they are in the right, left or central subtree rooted at v. , SC,v SL,v 16 4213 RLLR 524316 RLCLLR 21 RL 43 RL 231 CRL 4 56 LR 1 2 3 4 1 2 3 5 6 SR=9, SC =4, SL=2 SR=8.2, SC =3, SL=1 4 SR=100, SC =4, SL=1 1 2 3 5 6 Figure 7: The league hierarchies for binary trees and the ternary trees. When the tree is a binary tree, Bhakta et al. (SODA 2014) [2], analyzed the mixing time of the league hierarchies using the comparison theorem and by comparing it to the following Markov chain: Consider a tree whose leaves are labeled by 1, 2, . . . n, and inside each interior node v there are three numbers SR,v > SC,v > SL,v satisfying SR,v > 1/2. SC,v The Markov chain Mtree works as follows: in state σ ∈ Sn, i and j with 1 ≤ i < j ≤ n are chosen uniformly at random. Let v = i ∧ j be the lowest common ancestor of i and j, and Tv the subtree rooted at v. We swap σ(i) and σ(j) iff σ(i + 1), σ(i + 2), . . . , σ(j − 1) /∈ Tv, with the probabilities given in Definition 4.1 Bhakta et al. proved that if the tree is a binary tree then Mtree is rapidly mixing. In the following lemma we extend their result: , SC,v SL,v Lemma 4.1. For the ternary tree labeled as in Definition 4.1, t(Mtree) ≤ O(n10 log n). Proof. The Markov chain of our discourse is a product of n − 1 smaller three particle systems (See Figure 7). Thus, by Theorem 2.8 and 2.3 we conclude the result. Bhakta et al. [2] had shown that the two Markov chains L3 and Mtree have the same stationary distribution. To conclude Corollary 2.6, it remains to show that their mixing time is related. As in Section 3, we use the comparison technique. Lemma 4.2. t(L3) ≤ n4t(Mtree). Proof. We label the interior nodes of the tree as done in Figure 7, then each edge in Mtree will be corresponding to the exchange of two particles of the same type in the root between which there is no particle of the same type. Consider 17 an arbitrary edge e = (σ, τ ) ∈ Mtree, we correspond the path Γe lying on L3 whose construction will be explained in the next paragraph. As an example, assume we are swapping 5 and 6 in 587231964 in a full balanced binary tree with 9 leaves and thus labeled by CRRLLLRCC. We define the path between any arbitrary σ and τ in L3 in which the particles at positions i and j are swapped as follows: Do the following until σ(i) and σ(j) meet (we call this stage one): 1. If σ(i + 1) = σ(j − 1), swap σ(i) and σ(i + 1), then swap σ(j − 1) and σ(j). Then, repeat. In the example starting from σ = 587231964; CRRLLLRCC, the first edges in the path will be 587231964 → 857231964 → 857231694. 2. If σ(i + 1) (cid:54)= σ(j − 1), then swap σ(i) and σ(i + 1) if σ(i) > σ(i + 1). Otherwise, swap σ(j) and σ(j − 1) if σ(j) > σ(j − 1). In case none of the above holds, we can conclude that both σ(i) and σ(j) are labeled by C and between them we have a sequence of L and Rs. In this case, using adjacent transpositions, take σ(k) to the position of i + 1 if σ(i + 1) is labeled with R, and k is the smallest index greater than i + 1 so that σ(k) is labeled by L. Then, repeat. Otherwise, find a k with the largest index smaller than j − 1 that is labeled by R and take it to the position at j − 1. Then, repeat. In our example we continue by the following edges: 857231694; RCRLLLCRC → 852731694 → 852371694 → 852317694. Then, we restart: 852317694; RCLLLCRC → 852317694 → 825316794 → 823561794. Repeat the above steps until σ(i) and σ(j) meet, then swap them, and enter stage two. In our example, we swap 5 and 6: 823651794 → 823651794; RLLCCLRRC. Let µ be the permutation in which σ(i) and σ(j) meet. Note that by the transpositions of stage one, on our way from σ we only visit arrangements µ, we only visit permutations ω satisfying π(σ) > π(ω). After reaching this state, in stage two, we take σ(i) to j and σ(j) to i; and also, in the case where the two particles were Cs, potentially take back other particles to their original positions. Note that by σ(i) can reach j by exactly performing the transpositions σ(j) made in stage one, and vice versa. Thus, for any ω visited on this stage we always will have: π(σ)(cid:16)max{ sR sC , sC sL }(cid:17) ≥ π(ω). In our example, in the second stage we take 6 and 5 to the final positions and also 7 to its original position: 823651794 → 826315794; RLCLLCRRC → 826317594 → 826317954 → 862317954 → 862371954 → 86271954. The congestion placed on each edge in Mtree by the paths of γ will be bounded by: 18 Ae = (cid:80){σ,τe∈γστ∈ΓH} γσ,τC(σ, τ ) C(e) ≤ n(cid:88)i=1 n(cid:88)j=1 q ≤ qn3. ;where q = max{ sR sC , sC sL }is a constant. Using the comparison theorem, we complete the proof. t(L3) ≤ max e∈E(M)Aeπmint(Mtree) ≤ n4t(Mtree). Acknowledgements. We would like to thank Dana Randall for a very helpful conversation about the gladiator problem and Fill's conjecture, and Sergi Elizalde for his help and knowledge concerning generating functions. References [1] D. Bayer and P. Diaconis. Trailing the Dovetail Shuffle to its Lair. The Annals of Applied Probability, Vol. 2, no. 2, Pages 294 -- 313, 1992. [2] P. Bhakta, S. Miracle, D. Randall and A. Streib, Mixing times of Markov chains for self-organized lists and biased permutations. 25th Symposium on Discrete Algorithms (SODA), 2014. [3] I. Benjamini, N. Berger, C. Hoffman, and E. Mossel. Mixing times of the biased card shuffling and the asymmetric exclusion process. Transactions of the American Mathematical Society, Vol. 357, Pages 3013 -- 3029, 2005. [4] F. Chierichetti, A. Dasgupta, R. Kumar, S. Lattanzi. On Reconstructing a Hidden Permutation. In Proceedings of RANDOM, 2014. [5] P. Diaconis and L. Saloff-Coste, Comparison techniques for random walks on finite groups. The Annals of Applied Probability, Vol. 21, Pages 2131 -- 2156, 1993. [6] P. Diaconis and M. Shahshahani, Generating a random permutation with random transpositions. Probability Theory and Related Fields, Vol. 57, Pages 159 -- 179, 1981. [7] J. Fill. An interesting spectral gap problem. Unpublished manuscript, 2003. [8] S. Greenberg, A. Pascoe, and D. Randall. Sampling Biased Lattice Con- figurations Using Exponential Metrics. 20th Symposium on Discrete Algo- rithms (SODA), 2009. 19 [9] S. Haddadan and P. Winkler. Mixing of Permutations by Biased Trans- position. 34th Symposium on Theoretical Aspects of Computer Science (STACS), 2017. [10] J. H. Hester and D. S. Hirschberg. Self-organizing linear search. ACM Com- puting Surveys, Vol. 19, Pages 295 -- 311, 1985. [11] M. Jerrum and A. Sinclair, Approximating the permanent. SIAM Journal on Computing, Vol. 18, Pages. 1149 -- 1178, 1989. [12] D. A. Levin, Y. Peres , and E. L. Wilmer. Markov Chains and Mixing Times. American Mathematical Society, 2009. http://pages.uoregon.edu/dlevin/MARKOV/markovmixing.pdf [13] C. L. Mallows. Non-null ranking models. I. Biometrika, Vol. 44(1-2), Pages 114 -- 130, 1957. [14] R. Martin and D. Randall. Disjoint decomposition of Markov chains and sampling circuits in Cayley graphs. Combinatorics, Probability and Com- puting, Vol. 15, Pages 411 -- 448, 2006. [15] M. Mihail and P. Winkler, On the number of Eulerian orientations of a graph. Algorithmica, Vol. 16, Pages 402 -- 414, 1995. [16] S. Miracle, A. P. Streib. Rapid Mixing of k-Class Biased Permutations arXiv:1708.05078. [17] B. Morris. The mixing time for simple exclusion. Annals of Probability, Vol. 16, no. 2, Pages 615 -- 635, 2006. [18] R. I. Oliveira. Mixing of the symmetric exclusion processes in terms of the corresponding single-particle random walk. Annals of Probability, Vol. 41, no. 2, Pages 871 -- 913, 2013. [19] D. Randall and P. Tetali, Analyzing glauber dynamics by comparison of Markov chains. Journal of Mathematical Physics, Vol. 41, Pages 1598 -- 1615, 2000. [20] R. Rivest. On self-organizing sequential search heuristics. Communications of the ACM, Vol. 19, no. 2, Pages 63 -- 67, 1976. [21] A. Sinclair, Improved bounds for mixing rates of Markov chains and multi- commodity flow. Combinatorics, Probability and Computing, Vol. 1, Pages 351 -- 370, 1992. [22] A. Sinclair and M. Jerrum, Approximate Counting, Uniform Generation, and Rapidly Mixing Markov Chains. Information and Computation, Vol. 82, Pages 93 -- 133, 1989. 20 [23] R. P. Stanley, Topics in Algebraic Combinatorics. Course notes for Math- ematics, 2012. Citeseer. http://www-math.mit.edu/∼rstan/algcomb/algcomb.pdf. [24] D. Wilson, Mixing times of lozenge tiling and card shuffling Markov chains. The Annals of Applied Probability, Vol. 1, Pages 274 -- 325, 2004. 21
1204.1616
2
1204
2012-08-17T19:05:56
Algorithmic Applications of Baur-Strassen's Theorem: Shortest Cycles, Diameter and Matchings
[ "cs.DS" ]
Consider a directed or an undirected graph with integral edge weights from the set [-W, W], that does not contain negative weight cycles. In this paper, we introduce a general framework for solving problems on such graphs using matrix multiplication. The framework is based on the usage of Baur-Strassen's theorem and of Strojohann's determinant algorithm. It allows us to give new and simple solutions to the following problems: * Finding Shortest Cycles -- We give a simple \tilde{O}(Wn^{\omega}) time algorithm for finding shortest cycles in undirected and directed graphs. For directed graphs (and undirected graphs with non-negative weights) this matches the time bounds obtained in 2011 by Roditty and Vassilevska-Williams. On the other hand, no algorithm working in \tilde{O}(Wn^{\omega}) time was previously known for undirected graphs with negative weights. Furthermore our algorithm for a given directed or undirected graph detects whether it contains a negative weight cycle within the same running time. * Computing Diameter and Radius -- We give a simple \tilde{O}(Wn^{\omega}) time algorithm for computing a diameter and radius of an undirected or directed graphs. To the best of our knowledge no algorithm with this running time was known for undirected graphs with negative weights. * Finding Minimum Weight Perfect Matchings -- We present an \tilde{O}(Wn^{\omega}) time algorithm for finding minimum weight perfect matchings in undirected graphs. This resolves an open problem posted by Sankowski in 2006, who presented such an algorithm but only in the case of bipartite graphs. In order to solve minimum weight perfect matching problem we develop a novel combinatorial interpretation of the dual solution which sheds new light on this problem. Such a combinatorial interpretation was not know previously, and is of independent interest.
cs.DS
cs
Algorithmic Applications of Baur-Strassen's Theorem: Shortest Cycles, Diameter and Matchings Marek Cygan ∗ Harold N. Gabow † Piotr Sankowski‡ 2 1 0 2 g u A 7 1 ] S D . s c [ 2 v 6 1 6 1 . 4 0 2 1 : v i X r a Abstract Consider a directed or an undirected graph with integral edge weights from the set [−W, W ], that does not contain negative weight cycles. In this paper, we introduce a general framework for solving problems on such graphs using matrix multiplication. The framework is based on the usage of Baur-Strassen's theorem and of Strojohann's determinant algorithm. It allows us to give new and simple solutions to the following problems: Finding Shortest Cycles -- We give a simple O(W nω) time algorithm for finding shortest cy- cles in undirected and directed graphs. For directed graphs (and undirected graphs with non- negative weights) this matches the time bounds obtained in 2011 by Roditty and Vassilevska- Williams. On the other hand, no algorithm working in O(W nω) time was previously known for undirected graphs with negative weights. Furthermore our algorithm for a given directed or undirected graph detects whether it contains a negative weight cycle within the same running time. Computing Diameter and Radius -- We give a simple O(W nω) time algorithm for comput- ing a diameter and radius of an undirected or directed graphs. To the best of our knowledge no algorithm with this running time was known for undirected graphs with negative weights. Finding Minimum Weight Perfect Matchings -- We present an O(W nω) time algorithm for finding minimum weight perfect matchings in undirected graphs. This resolves an open problem posted by Sankowski in 2006, who presented such an algorithm but only in the case of bipartite graphs. We believe that the presented framework can find applications for solving larger spectra of re- lated problems. As an illustrative example we apply it to the problem of computing a set of vertices that lie on cycles of length at most t, for some t. We give a simple O(W nω) time algo- rithm for this problem that improves over the O(W nωt) time algorithm given by Yuster in 2011. In order to solve minimum weight perfect matching problem we develop a novel combinatorial interpretation of the dual solution which sheds new light on this problem. Such a combinatorial interpretation was not know previously, and is of independent interest. ∗Institute of Informatics, University of Warsaw [email protected]. †Department of Computer Science, University of Colorado at Boulder [email protected]. ‡Institute of Informatics, University of Warsaw and Department of Computer and System Science, Sapienza University of Rome [email protected]. 1 Introduction The application of matrix multiplication to graph problems has been actively studied in recent years. The special case of unweighted graphs is well understood. For example, O(nω) time al- gorithms for finding shortest cycles [16] have been known for 35 years1. But similar results for weighted graphs were obtained only last year, by Roditty and Vassilevska-Williams [25]. Their algorithm works in O(W nω) time, where W is the largest magnitude of an edge weight. Two sim- ilar problems on weighted graphs where there has been considerable effort, but the full answer has not been achieved, are diameter and perfect weighted matching. This paper introduces a general framework that gives simple2 solutions to all three of these problems and others. In the following unless otherwise stated, we work with graphs that contain edges with possibly negative weights but no negative cycles. We obtain the following results. Finding Shortest Cycles We give a simple O(W nω) time algorithms for finding shortest cycles in undirected and directed graphs. In the case of directed graphs the algorithm reduces the problem to one determinant computation for a polynomial matrix. On the other hand, the undirected case requires handling short 2-edge cycles in a proper way. The idea used here is an extension of the algorithm by Sankowski contained in [27], that allowed to test whether a graph contains negative weight cycle. For directed graphs (and undirected graphs with non-negative weights), our bounds match the ones obtained in 2011 by Roditty and Vassilevska-Williams [25], whereas for undirected graphs with negative weights no O(W nω) time algorithm was previously know for this problem. For all related results see Table 1 and Table 2. For undirected graphs with negative weights the problem reduces to n computations of minimum weight perfect matchings [6]. Furthermore our algorithm for a given directed or undirected graph detects whether it contains a negative weight cycle within the same running time. Computing Diameter and Radius We present a simple O(W nω) time algorithm for comput- ing a diameter and radius of undirected and directed graphs. This algorithm combines determinant computations with binary search. Since computing all pairs shortest paths suffices to find both diameter and radius O(W nω) time algorithm follows from [31] in case of undirected graphs with non-negative weights. Moreover by generalizing the ideas of [31] used for non-negative weights by applying random sampling one can obtain the same running time for directed graphs without neg- ative weight cycles. However, to the best of our knowledge, all previous solutions to this problem in undirected graphs with negative weights reduced the problem to n computations of minimum weight perfect matchings. For other related results see Table 3 and Table 2. Finding Minimum Weight Perfect Matchings We present an O(W nω) time algorithm for finding minimum weight perfect matchings in undirected graphs. This resolves an open problem posted by Sankowski in 2006 [28], who presented such an algorithm but only in the case of bipartite graphs. Some advance on this problem has been recently given by Huang and Kavitha [15], who have shown an O(W nω) time algorithm for the maximum weight matching problem. However, the 1The O notation ignores factors of log n and log W . O(nω) is the time needed for a straight-line program to multiply two n × n matrices; ω is called matrix multiplication exponent. 2An objective sense in which our algorithms are simple is their use of algebra: The power of our algebraic algorithms comes from black-box routines, and the algorithms themselves use only elementary algebraic ideas. 1 weighted perfect matching problem is more involved and no reduction similar to the one presented in [15] is known to work. Previously, similar reduction was given in [18] for maximum weight bipartite matching. Nevertheless, to solve minimum weight perfect matching problem even in bi- partite graphs one is bound to use more structured techniques. Actually, we need to develop such a technique for general graphs. We give a novel combinatorial interpretation of the dual problem. Such an interpretation for general matching problem was not know previously and is of significant independent interest. For the summary of different algorithms see Table 2. un- nonnegative Complexity O(nm + n2 log n) directed O(nω) weighted O(W 0.681n2.575) directed O(nm + n2 log log n) directed O(n3 log3 log n/ log2 n) directed O(W nω) nonnegative undirected O(W nω) directed and Author Johnson (1977) [17] Itai and Rodeh (1977) [16] Zwick (2000) [37] Pettie (2004) [24] Chan (2007) [4] Roditty and Vassilevska- Williams (2011) [25] this paper Table 1: The complexity results for the shortest cycle problem. undi- Complexity O(nm + n2 log n) directed O(n min(m log n, n2)) rected O(W nω) nonnegative undi- rected O(W 0.681n2.575) directed O(n3 log3 log n/ log2 n) directed O(W nω) directed O(W nω) Author Johnson (1977) [17] Gabow (1983) [8] and Zwick Shoshan (1999) [31] Zwick (2000) [37] Chan (2007) [4] folklore+[31]+[37] this paper Table 3: The complexity results for the diameter and radius problem. Note that the first five results solve the more general All Pairs Shortest Paths problem. 1.1 The Framework Complexity O(n2m) O(n3) O(nm log n) O(n(m log log log m n Author Edmonds (1965) [5] Lawler (1973) [20] and Gabow (1974) [7] Galil, Micali Gabow (1982) [13] and n+n log n)) Gabow, Galil and Spencer (1984) [11] 3 4 m log W ) O(n O(n(m + n log n)) O((cid:112)nα(m, n) log n m log(nW )) Gabow and Tarjan Gabow (1985) [9] Gabow (1990) [10] O(W nω) (1991) [12] this paper Table 2: The complexity results for the minimum weight perfect matching problem. Note that first, third, fourth and fifth results solve the more general All Pairs Shortest Paths problem. Complexity O(nm) O(tW nω) undirected O(t4−ωW nω) directed O(W nω) Author Suurballe and Tarjan (1984) [33] Yuster (2011) [34] Yuster (2011) [34] this paper Table 4: The complexity results for the problem of finding vertices that lie on cycles of length at most t. Our framework is based on two seminal results. First of all we use Storjohann's algorithm [32] that computes the determinant of a degree d polynomial matrix in O(dnω) time. All the above graph problems can be encoded as a determinant problem on a polynomial matrix. However the determi- nant is just one number and does not provide enough information to decode the whole solution. Here we use the Baur-Strassen Theorem [2], which shows how to compute all partial derivatives of a func- tion in the same asymptotic time as computing the function itself. For a simple constructive proof please check [22]. This theorem allows us to magnify the output of the algorithm from 1 number to n2 numbers. The algorithms obtained in this way are very simple and work in three phases: compute the determinant of an appropriately defined matrix; apply Baur-Strassen to the result; decode the output. Even for minimum weight matching our algorithm is simple, and computes the dual solution in just a few lines of pseudocode. Based on these examples, we believe this framework will find appli- cation to a wider spectrum of problems. The full version of the paper will contain a more extensive 2 review of possible applications. Here we give one more illustration: a simple O(W nω) time algorithm that finds every vertex that lies on a cycle of length ≤ t, for a given arbitrary t (for a directed or undi- rected weighted graph, with negative edges allowed but no negative cycles). This improves the algo- rithms proposed by Yuster in 2011 [34] (see Table 4; those algorithms do not allow negative edges). The paper is organized as follows. In the next two sections we introduce needed tools and give the main definitions. In Section 4 we introduce our framework and give algorithms for the shortest cycle problem in directed graphs. This motivates the introduction of the framework in Section 5. Section 6 contains the algorithm for minimum weight perfect matching problem. The next section presents the application of our framework for computing the diameter of a graph. Section 8 intro- duces the ideas needed to compute shortest cycles in undirected graphs with positive weights. In Section 9 we join the ideas from all previous section to solve the shortest cycle problem and the diameter problem in undirected graphs with negative weights. Finally, in Section 10 we apply our framework to find the set of vertices that lie on a cycle of lenght at most t. 2 Preliminaries Our approach is based on three main ingredients. Linear Algebra Algorithms Storjohann [32] has made an important addition to the set of prob- lems solvable in O(nω) arithmetic operations: the determinant and the rational system solution for polynomial matrices. Theorem 1 (Storjohann '03). Let K be an arbitrary field, A ∈ K[y]n×n a polynomial matrix of degree d, and b ∈ K[y]n×1 a polynomial vector of the same degree. Then • rational system solution A−1b (Algorithm 5 [32]), • determinant det(A) (Algorithm 12 [32]), can be computed in O(dnω) operations in K, with high probability. For the next section, note that both algorithms of Storjohann can be written as straight-line programs. The randomization does not pose a problem as it is just used at the very beginning to generate a polynomial of degree d that does not divide det(A). After this the algorithms are deterministic. Our applications will work over a finite field (see Section 2) so there is no risk of manipulating huge integers. Finally usage of the FFT to perform multiplication of degree nd polynomials does not pose a problem. Baur-Strassen Theorem Another astonishing result is the Baur-Strassen Theorem from 1983 [2, 22]. It was used to show that matrix multiplication is no harder than determinant computation when considering algorithms that can be written as straight-line programs. Such a statement is unexpected when you realize that matrix multiplication returns n2 numbers and determinant com- putation just one. However it is possible to increase the number of outputs by modifying the algorithm appropriately. Let T (f1, . . . , fk) denote the time needed to compute functions f1, . . . , fk, all at the same given point. Theorem 2 (Baur-Strassen '83). For straight-line programs computing f (x1, . . . , xn), T (f, ∂f ∂x1 , . . . , ∂f ∂xn ) ≤ 5T (f ). 3 Thus we can compute all partial derivatives of a function f in the same asymptotic time as is used to compute f . [22] shows a RAM routine to compute all n partials can be constructed in time O(T (f )) as well. Schwartz-Zippel Lemma Our approach is to encode a graph problem in a symbolic matrix whose determinant is (symbolically) non-zero if and only if the problem has a solution. The Schwartz-Zippel Lemma [36, 30] provides the non-zero test: Corollary 3. For any prime p, if a (non-zero) multivariate polynomial of degree d over Zp is evaluated at a random point, the probability of false zero is ≤ d/p. We will choose primes p of size Θ(nc) for some constant c. In a RAM machine with word size Θ(log n), arithmetic modulo p can be realized in constant time. Moreover we would like to note that multivariate determinant expressions have been used several times in previous work, including Kirchhoff's Matrix-Tree Theorem, results of Tutte and Edmonds on perfect matchings, and recent result of Bjorklund [3] for undirected Hamiltonicity. 3 Definitions: Graphs with Integral Weights A weighted n-vertex graph G is a tuple G = (V, E, w, W ), where the vertex set is given by V = {1, . . . , n}, E ⊆ V × V denotes the edge set, and the function w : E → [−W, W ] ascribes weights to the edges. In this paper we consider both undirected and directed graphs. Hence, E might denote either a set of unordered pairs for undirected graphs or a set of ordered pairs for directed graphs. We define a weight of the edge set F ⊆ E to be e(F ) =(cid:80) e∈F w(e). Consider a path p = v1, v2, . . . , vk of length k. The weight of this path is simply equal to the weight of the edge set of p and denoted by by w(p). The distance from v to u in G, denoted by dist G(v, u), is equal to the minimum weight of the paths starting at v and ending in w. A path from v to u with minimum weight is called a shortest path. If for a path p we have v1 = vk then the path is called a cycle. In the shortest cycle problem we are given a weighted graph G and we need to compute the shortest (i.e., minimum weight) cycle in G. In this problem we assume that the graph contains no negative weight cycles. There is a subtle difference between the directed and undirected versions of the problem. The standard approach to reduce the undirected problem to directed problem by bidirecting the edges does not work. The resulting graph can contain cycles that pass though the same edge twice in both directions. Such cycles do not exist in the undirected graph. Moreover, when the undirected graph contains negative edges the resulting directed graph contains negative weight cycles, even if the undirected graph did not. In the diameter problem we are given a weighted graph G (directed or undirected) and are asked to find the a pair of vertices v, u ∈ V that maximizes dist G(v, u). Note that here the reduction of undirected problem to directed one by bidirecting the edges works on the in the case when the edges are positive. weight w(M ) =(cid:80) A matching M in G is a set of edges such that each vertex is incident at most one edge from M . In a perfect matching each vertex is incident to exactly one matched edge. A minimum weight perfect matching is a perfect matching M in a weighted undirected graph that minimizes the total e∈M w(e). Many other notions of "optimum weighted matching" reduce to min- imum weight perfect matching: A maximum weight perfect matching is equivalent to a minimum 4 weight perfect matching for weights w(cid:48)(e) := −w(e). A minimum weight cardinality k matching (i.e., exactly k edges are to be matched) is a minimum weight perfect matching on the graph with n − 2k articial vertices, each joined to every original vertex by a zero-weight edge. A maximum weight matching (i.e., we want to maximize the total weight of the matched edges) is a maximum weight perfect matching on the graph that has one artificial vertex if n is odd, plus new zero-weight edges that make the graph complete. There is a reduction going in the other direction: we set edge weights to w(cid:48)(e) := nW + w(e). However we are interested in time bounds that are linear in W , so this reduction is not of interest. 4 Shortest Cycles in Directed Graphs Let K be an arbitrary field. A symbolic polynomial p[y] is a multivariate polynomial over a set of variables y ∪ X over K. We denote the set of symbolic polynomials by K[y] = K[y ∪ X]. We write as well K to denote the set of multivariate polynomials K[X]. A symbolic matrix polynomial A[y] ∈ K[y]n×n is an n × n matrix whose entries are symbolic polynomials from K[y]. We shall use a straight-line program that evaluates det( A[y]) ( A[y] ∈ K[y]n×n) using Storjo- hann's algorithm. Here the goal is to evaluate the determinant to a polynomial in one variable y. This program is easily constructed: Start with the original straight-line program that evaluates det(A) (A ∈ K[y]n×n) using Storjohann's algorithm. Prepend assignment statements of the form aijk ← aijk, where aijk is the variable in the original program for the coefficient of yk in the en- try Aij, and the corresponding coefficient in A[y] is aijk ∈ K. In our applications each of these new assignment statements uses O(1) time, so the extra time can be ignored. Also note that all arithmetic in our straight-line programs is done in K = Zp for a chosen prime p. We say that σ : X → K is an evaluation function. We define define p[y]σ to be a one variable Let us define a symbolic adjacency matrix of the weighted directed graph −→G = (V, E, w, W ) to polynomial in y with all variables x ∈ X substituted by σ(x). be the symbolic matrix polynomial A(−→G ) such that (cid:26) xi,jyw((i,j)) A(−→G )i,j = if (i, j) ∈ E, 0 otherwise, y(q) for d = deg If q is the 0 polynomial, deg where xi,j are unique variables corresponding to the edges of −→G . Hence, X is the set of all variables xi,j. For a multi-variable polynomial q, let us denote by: ∗ • deg y(q) -- the degree of the smallest degree term of y in q, y(q) -- the coefficient of yd in q, • termd ∗ • term∗ y(q) -- termd y(q). ∗ y(q) := ∞. In the following we assume that K := Zp, i.e., we work We say that a nonempty set of disjoint cycles C in −→G is a cycle packing if every vertex of −→G belongs to at most one cycle in C. Observe that a minimum weight cycle packing is either a shortest cycle or a collection of shortest cycles all of weight 0. Lemma 4. Let −→G be a directed weighted graph. The minimum weight of a cycle packing in −→G ∗ y(det( A(−→G ) + I) − 1). This weight is also the weight of a shortest cycle if G has no equals deg over a finite field of order p for some prime number p. 5 negative cycle. Finally for any G and any p ≥ 2, all non-zero terms in det( A(−→G ) + I) are non-zero over a finite field Zp. Proof. By definition (cid:16) det A(−→G ) + I (cid:17) = (cid:88) p∈Γn n(cid:89) (cid:16) k=1 σ(p) (cid:17) , k,pk A(−→G ) + I (1) where Γn is the set of n-element permutations, and σ(p) is the sign of the permutation p. A permu- tation p defines a set of directed edges Cp = {(i, pi) : 1 ≤ i ≤ n}. This edge set corresponds to a set of cycles given by the cycles of p. The edge set Cp includes self-loops for all i such that i = pi. Note that p corresponds to a non-zero term in the determinant if and only if Cp contains only edges from E or self-loops. Hence, after throwing away self-loops p can be identified with a cycle packing in G, or ∅. Let us now compute the degree of y in the term of the determinant given by p. This term is obtained by multiplying the elements of the matrix A(−→G ) + I corresponding to the edges of Cp. The degree of the term equals the sum of the degrees in its individual elements. These degrees encode the weights of the edges or are zero for self-loops. So the degree of the term is the total weight of the cycles in Cp, where self-loops have weight zero. The term corresponding to a set of self-loops is equal to 1. Hence, det( A(−→G ) + I) − 1 contains only terms that correspond to nonempty sets of cycles. So we have proved the first assertion, i.e., the smallest degree of y is the smallest weight of a packings of cycles. For the third assertion note that each monomial in (1) has coefficient ±1 as each of them contains different variables. Hence each non-zero term is also non-zero over Zp for any p ≥ 2. Finally for the second assertion assume −→G has no negative cycle. Let C be the shortest cycle in −→G . It corresponds to a cycle packing of weight w(C). (The packing has a self-loop for every v (cid:54)∈ C.) In fact this is the minimum weight cycle packing. In proof take any cycle packing. If it contains more than one non-loop cycle discard all but one of them to get a packing of no greater weight (since every cycle is nonnegative). By definition this weight is ≥ w(C). Computing the Weight of the Shortest Cycle Next we apply the ideas of the previous sec- tion to compute the weight of a shortest cycle. Since A(−→G ) may have entries with negative powers of y, we cannot use Storjohann's result to compute its determinant. However we can multiply it by yW to make exponents nonnegative and use this identity: deg ∗ y(det( A(−→G ) + I) − 1) = deg ∗ y(det(( A(−→G ) + I)yW ) − ynW ) − nW. Combining this idea with the Schwartz-Zippel lemma we obtain the following algorithm. Algorithm 1 Computes the weight of the shortest cycle in a directed graph −→G . 1: Generate a random substitution σ : X → Zp for a prime p of order Θ(n2). 2: Compute δ = det(( A(−→G )σ + I)yW ) − ynW using Storjohann's theorem. 3: Return deg ∗ y(δ) − nW . This algorithm implies. 6 Theorem 5. Let −→G = (V, E, w, W ) be a weighted directed graph without negative weight cycles. The weight of the shortest cycle in −→G can be computed in O(W nω) time, with high probability. Note the algorithm also detects the existence of a negative cycle -- it corresponds to δ < 0. Finding a Shortest Cycle The above algorithms does not seem to give the cycle by itself. There is, however, a straightforward way of doing it using the Baur-Strassen theorem. We say that edge e is allowed if and only if it belongs to some shortest cycle C in −→G . term∗ Lemma 6. The edge (u, v) ∈ E is allowed if and only if: Moreover, for p ≥ 2, it is non-zero over a finite field Zp. Proof. The above follows directly by the proof of Lemma 4. The partial derivative is non-zero if and only if the variable xu,v exists in some smallest degree term, and so the corresponding edge (u, v) has to lie on some shortest cycle. y(det( A(−→G )+I)−1) is non-zero. ∂xu,v ∂ Rewrite the expression of the lemma to eliminate negative powers of y: ∂ ∂xu,v ∗ y(det( A(−→G ) + I) − 1) = term ∂ ∂xu,v term ∗ y(det(( A(−→G ) + I)yW ) − ynW ). This implies the following algorithm and theorem. Algorithm 2 Computes a shortest cycle in a directed graph −→G . 1: Let ∂xf be the routine given by the Baur-Strassen Theorem to compute the matrix of partial ∗ y(δ) computed det(( A(−→G ) + I)yW ) − ynW(cid:105) , where d is the degree deg termd y (cid:104) ∂ derivatives ∂xu,v in Algorithm 1. 2: Generate a random substitution σ : X → Zp for a prime p of order Θ(n2). 3: Compute the matrix δ = ∂xfσ. 4: Take any edge (u, v) such that δu,v (cid:54)= 0. 5: Compute the shortest path pv,u from v to u in −→G using [27, 35]. 6: Return the cycle formed by (u, v) and pv,u. (cid:104) det(( A(−→G ) + I)yW ) − ynW(cid:105) Note that in Step 1 we are applying the Baur-Strassen Theorem to the straight-line program . The latter is constructed using Storjohann's Theorem and for termd y the modification described at the start of this section. The shortest path computation using algorithms from [27, 35] takes O(W nω) time and succeeds with high probability, so we obtain: Theorem 7. Let −→G = (V, E, w, W ) be a weighted directed graph without negative weight cycles. The shortest cycle in −→G can be found in O(W nω) time, with high probability. 7 5 Performing Symbolic Computations This section gives a formal description of the algebraic operations used in our algorithms. Let A[y] be an n× n symbolic matrix and let σ : X → Zp be an arbitrary evaluation function. Moreover for a prime p let f : Zp[y]n×n → Zp be a symbolic matrix function. Theorem 8. If the result of f has degree bounded by some polynomial df (n) and f ( A[y]σ) is com- putable in tf (n) time, then there exists an algorithm that in O(tf (n)) time checks whether f ( A[y]) is symbolically non-zero over Zp with error probability ≤ df (n)/p. Proof. The algorithm works as follows: 1. uniformly at random choose a substitution function σ : X → Zp, 2. compute f ( A[y]σ) in tf (n) time, 3. check whether or not this value is zero and return the result. For the time bound note that tf (n) is obviously ≥ X. For the error bound if the degree of f ( A[y]) is d, Corollary 3 shows the probability of a false zero is ≤ d/p ≤ df (n)/p. Theorem 9. If the result of f has degree bounded by some polynomial df (n) and f ( A[y]σ) is computable by a straight-line program in tf (n) ≥ df (n) time, then there exists an algorithm that in ∂x f ( A[y]) is symbolically non-zero over Zp. O(tf (n)) time checks for each x ∈ X whether or not ∂ All X returned results are correct with total error probability ≤ df (n)X/p. Proof. Assume that the Baur-Strassen theorem gives a routine to compute ∂xf := ∂ all x ∈ X in O(tf (n)) time. The algorithm works as follows: 1. uniformly at random choose a substitution function σ : X → Zp, 2. apply the Baur-Strassen routine to compute ∂xfσ for all x ∈ X in O(tf (n)) time, 3. for each x ∈ X check whether or not ∂xfσ is zero and return the result. ∂x f ( A[y]) for Obviously ∂xf has degree ≤ df (n). So Corollary 3 shows that for each x ∈ X the probability of a false zero for ∂xf is ≤ df (n)/p. Hence the union bound shows the probability of any false zero in X results is ≤ df (n)X/p. The true goal is to check if a functional value is symbolically non-zero with high probability. This is easy to do with some weak assumptions on f . Specifically assume that any value f (α) in the range of f is a polynomial whose constant coefficients all have absolute value at most C, for some constant C. Also assume tf (n) ≥ n + df (n). Now consider the setting of Theorem 8. f (α) is a non-zero polynomial iff it is a non-zero poly- nomial over Zp for any prime p > C. In Theorem 8 take p as a prime of size Θ(n · df (n)). We get error probability O(1/n). The time to find p is easily accounted for by the assumption on tf (n). So for f as above, the theorem shows that in O(tf (n)) time we can check if f ( A[y]) is symbolically non-zero with high probability. Next consider the setting of Theorem 9. Any value of ∂xf is a non-zero polynomial iff it is a non-zero polynomial over Zp for any prime p > Cdf (n). In Theorem 9 take p as a prime of size Θ(nX·df (n)). We get error probability O(1/n). The time is similar. So for f as above the theorem ∂x f ( A[y]) is symbolically non-zero with high probability. shows that in O(tf (n)) time we can check if ∂ 8 6 Minimum Weight Perfect Matching This section presents an algorithm that, given an undirected graph with integral edge weights in [0, W ], finds a minimum weight perfect matching in O(W nω) time, assuming such matchings exist. The algorithm works in three phases: 1. The first phase uses algebra to reduce the problem to connected graphs, where each edge be- longs to some minimum weight perfect matching (Algorithm 3). Moreover for each vertex v, we are given the value w(M (v)) -- the minimum weight of a matching with exactly 2 unmatched vertices, one of which is v (Algorithm 4). This phase uses O(W nω) time and succeeds with high probability. 2. The second phase defines a new weight w(cid:48)(uv) := w(uv) + w(M (u)) + w(M (v)) for each edge uv. It performs a simple graph search algorithm on these new edges to obtain a laminar family of blossoms, which is the support of some optimum dual solution (Algorithm 5). Each blossom induces a factor critical graph. This phase is deterministic and uses O(n2) time. 3. The last phase uses a maximum cardinality matching algorithm (for unweighted graphs), guided by the structure of the blossoms, to obtain a minimum weight perfect matching (Lemma 20). This phase uses O(nω) time and succeeds with high probability. To elaborate on the second phase (which in our opinion is the most interesting), let A be the set of distinct values of the weight function w(cid:48). Section 6.2 proves A = O(n). For α ∈ A we define a 'threshold graph' Gα = (V, E(cid:48)), which is an unweighted undirected graph with E(cid:48) = {uv ∈ E : w(cid:48)(uv) ≤ α}. The nontrivial connected components of all the graphs Gα constitute the blossoms of an optimum dual solution! (A connected component is nontrivial if it has more than 1 and less than n vertices.) Our proof of this result hinges on showing there exists a special dual solution (called balanced critical dual solution) in which it is easy to find the blossoms (Lemma 28). Figure 1 depicts a sample graph and illustrates the steps for obtaining the laminar family of blossoms. Figure 1: The matching algorithm: The far left shows an example graph. Edges without a label weigh 0. The minimum weight of a perfect matching is 3. w(M (v)) is 2 for v ∈ {b2, c1, x, y, z} and 1 otherwise. The middle figure shows the allowed edges (edge c1z was removed) and new edge weights w(cid:48)(uv) = w(uv) + w(M (u)) + w(M (v)); edges with w(cid:48)(e) = 2 are drawn zigzag, w(cid:48)(e) = 3 are dashed, and w(cid:48)(e) = 4 are straight. The far right shows the laminar family induced by the blossoms found using the threshold graphs of Algorithm 5. 9 xa0a1a21yb0b1b21zc0c1c2122119xa0a1a2yb0b1b2zc0c1c2a0a1a2b0b1b2c0c1c2xyz In the rest of this section we show how to obtain the set of allowed edges, i.e., edges belonging to at least one minimum weight perfect matching and values w(M (u)) (Section 6.1). Next, in Sec- tion 6.2 we present the standard LP formulation of the problem. We recall and extend properties of a dual solution, in order to prove the correctness of our simple method of obtaining blossoms of an optimum dual solution. Finally, in Section 6.3, we gather all the theorems and formally prove correctness and bound the running time of our algorithm. We would like to note, that the simplicity of our algorithm for contracting the set of blossoms from the values w(M (u)) is due to the fact that the hardness is hidden in the proof of the purely combinatorial existential lemmas from Section 6.2 and in the algorithm for finding unweighted maximum matching problem. 6.1 Algebraic Tools Let us define a symbolic adjacency matrix of the weighted undirected graph G = (V, E, w, W ) to be the n × n matrix A(G) such that  xi,jyw(ij) −xj,iyw(ij) A(G)i,j = if ij ∈ E and i < j, if ij ∈ E and i > j, 0 otherwise, where xi,j are unique variables corresponding to the edges ij ∈ E of G. Karp, Upfal and Wigder- son [19] proved that the smallest degree of y in det( A(G)) is twice the weight of a minimum weight perfect matching in G. By using this line of reasoning together with results of Storjohann and Baur-Strassen, we show how to obtain the set of edges which appear in at least one minimum weight perfect matching. Lemma 10. An edge ij ∈ E belongs to some minimum weight perfect matching iff det( A(G)) = sgn(p) A(G)k,pk , (2) where Γn is the set of n-element permutations. A permutation p defines a multiset of edges Cp = {{i, pi} : 1 ≤ i ≤ n and i (cid:54)= pi}. This edge multiset corresponds to a cycle cover given by the cycles of p. Reversing an odd cycle in a permutation does not change its sign, but it changes the sign of the monomial corresponding to this permutation in the determinant. Consequently, the polynomial det( A(G)) contains only monomials corresponding to even-cycle covers of G. (An even-cycle cover has no odd cycles.) Since each even-cycle cover is easily decomposable into two perfect matchings, and doubling a matching gives an even-cycle cover, we infer that an edge ij ∈ E belongs to some minimum weight perfect matching in G iff it appears in some minimum degree monomial in det( A(G)). The lemma follows. Note that an even-cycle cover corresponding to a matching -- i.e., every cycle has length 2 -- corresponds to a unique permutation in (2). Thus the lemma is true in any field Zp. The combination of Lemma 10 with Theorem 9 proves the following corollary. 10 Proof. By the definition of a determinant we have: ∂ ∂xi,j term det( A(G)) (cid:54)= 0 . ∗ y (cid:104) (cid:88) p∈Γn (cid:105) n(cid:89) k=1 Corollary 11. For a weighted undirected graph G = (V, E, w, W ) one can compute the set of edges which belong to at least one minimum weight perfect matching in O(W nω) running time, with high probability. Algorithm 3 Computes the set of allowed edges in the graph G. 1: Generate a random substitution σ : X → Zp for a prime p of order Θ(n2). 2: Compute d = deg 3: Let ∂xf be the routine given by the Baur-Strassen theorem to compute the matrix of partial using Storjohann's theorem. ∗ y (cid:104) (cid:105) (cid:104) det( A(G)σ) det( A(G)) (cid:105) . derivatives ∂ ∂xi,j termd y 4: Generate a random substitution σ : X → Zp for a prime p of order Θ(n4). 5: Compute the matrix δ = ∂xfσ. 6: Mark each edge ij, where i < j, as allowed if δi,j (cid:54)= 0. Definition 12 (M(uv), M(u)). For a pair of vertices u, v ∈ V let M (uv) be a minimum weight perfect matching in G \ {u, v}, i.e., G with vertices u and v removed. Similarly, for a vertex u let M (u) be a minimum weight almost-perfect matching in the graph G \ {u}. Note that M (u) always exists, since we assume the given graph G has a perfect matching. In contrast M (uv) needn't exist. In that case M (uv) is ∞. Lemma 13. Let G = (V, E, w, W ) be a weighted undirected graph. Then deg w(M ) + w(M (ij)). Proof. We have adj( A(G))i,j = (−1)i+j det( A(G)j,i). Equivalently, if we take Z to be the matrix obtained from A(G) by zeroing entries of the j'th row and the i'th column and setting the entry (j, i) to 1, then adj( A(G))i,j = det( Z), and so ∗ y(adj( A(G))i,j) = adj( A(G))i,j = sgn(p) zk,pk . (3) (cid:88) p∈Γn n(cid:89) k=1 The permutation p can be viewed as a set of directed cycles C covering G, where there is a cycle c that contains the edge (j, i). (By definition (j, i) is an edge of C, even when (j, i) /∈ E(G). (j, j) is an example. The other edges of C are in E(G).) We claim that the terms in this adjoint correspond to even-length-cycle covers that contain a cycle c through (j, i). In other words cycle covers that contain an odd cycle make no net contribu- tion to (3). In proof let d be an odd cycle in C. First suppose d (cid:54)= c. Reversing its direction changes the sign of its contribution to (3), from antisymmetry of A(G). So such covers do not contribute to the adjoint. Second suppose d = c. G has an even number of vertices. Thus C has an even number of edges, and c cannot be the unique odd cycle. Now take any C contributing to (3). C decomposes into two matchings by taking alternate edges from each (even) cycle. One matching, say N , is a perfect matching of G; the other is a perfect matching of G \ {i, j}, say N (ij), plus edge (j, i). We conclude that the adjoint of (3) is 0 if N or N (ij) does not exist. This proves the case of the lemma when M or M (ij) does not exist. Now assume both M and M (ij) exist. The degree of any term in (3) equals the sum of the edge weights in C (note that the weight of the edge (j, i) is considered as 0, since zj,i = 1). Take 11 any term that has the smallest degree in (3). Its degree is deg ∗ y(adj( A(G))i,j) = w(N ) + w(N (ij)) ≥ w(M ) + w(M (ij)). We will complete the proof by showing deg ∗ y(adj( A(G))i,j) ≤ w(M ) + w(M (ij)). (Obviously the two displayed inequalities show equality holds, so they imply the lemma.) The multiset M ∪ M (ij)∪ (j, i) gives an even-length-cycle cover CM of G which contains the edge (j, i). Wlog the cycle through (j, i) is the only cycle in CM (since we can make M and M (ij) identical on any other even cycle). We claim the monomial corresponding to CM occurs exactly once in (3). This claim shows the monomial does not get cancelled, thus proving the desired inequality. To prove the claim, a variable xgh appearing in any term comes from the cycle cover edge (g, h) or (h, g). This implies that two terms with the same variables are cycle covers that differ only in the orientation of some cycles. A cycle of CM either has length two or contains (j, i). The former does not change when it is reversed, and the latter cannot be reversed. So no other cycle cover corresponds to the monomial of CM . Note that since the monomial for CM occurs exactly once, the lemma holds for any field Zp. If M or M (ij) does not exist, the expression of the lemma equals ∞. The lemma and the following extension also hold in any field Zp. Corollary 14. The vector of values w(M ) + w(M (i)), i ∈ V equals deg vector of n indeterminates b = (b1, b2, . . . , bn). adj( A(G))b for b a (cid:16) ∗ y (cid:17) (cid:16) ∗ y (cid:17) is(cid:80) Proof. Lemma 13 shows w(M )+w(M (i)) = minj deg corresponding to the 0 polynomial cause no problem.) The ith component of the vector adj( A(G))b j adj( A(G))i,jbj, and because of the indeterminates bj no terms cancel when the sum is formed. . (Note that entries adj( A(G))i,j adj( A(G))i,j (cid:16) ∗ y (cid:17) Thus deg adj( A(G))b = w(M ) + w(M (i)). This leads to the following algorithm to compute w(M (u)) for all u ∈ V (G). Let B = {b1, . . . , bn}. Algorithm 4 Computes the values w(M (i)) for all vertices i in the graph G. 1: Generate a random substitution σ : X ∪ B → Zp for a prime p of order Θ(n3). 2: Compute w(M ) = deg ∗ y(det( A(G)σ))/2 and v = det( A(G)σ)( A−1(G)b)σ using Storjohann's theorem, where b = (b1, . . . , bn). 3: For each i ∈ V set w(M (i)) = deg To see this algorithm is correct Statement 2 computes v = (cid:0) adj( A(G))b(cid:1) σ. So Corollary 14 shows the algorithm is correct if there are no false zeroes. A rational expression (like those in ( A−1(G)b)σ) is zero if and only if its numerator is zero and its denominator is nonzero. So we can apply the Schwartz-Zippel Lemma to show the final products have no false zeroes (in their lowest order term). So each deg ∗ y(vi) is computed correctly with high probability. ∗ y(vi) − w(M ). 12 Regarding efficiency consider the n multiplications of degree nW polynomials done to form v in Statement 2. We only use the lowest degree term of each product (Statement 3). That term comes from the lowest degree term in det( A(G)σ and the lowest degree term in the numerator and the ∗ denominator of ( A−1(G)b)σ. So we can find the smallest degree of y that corresponds to deg y(vi) using O(1) additions and subtractions, without multiplying polynomials. We conclude: Corollary 15. Algorithm 4 computes the values w(M (u)), for all u ∈ V (G), in O(W nω) time, with high probability. 6.2 Properties of the Dual We move on to the linear programming formulation of the minimum weight perfect matching prob- lem given by Edmonds [5]. An odd set has odd cardinality; Ω denotes the collection of odd subsets of V of cardinality ≥ 3. (cid:88) e∈E min w(e)xe x(δ(v)) = 1, for all v ∈ V x(δ(U )) ≥ 1, for all U ∈ Ω (4) uv ∈ E having {u, v} ∩ U = 1. We write δ(u) for δ({u}) and x(F ) for(cid:80) xe ≥ 0, for e ∈ E The dual problem has variables πv for each vertex v and πU for each odd set U : The variables xe indicate when an edge is included in the solution. Here, δ(U ) denotes all edges e∈F xe. (cid:88) v∈V (cid:88) U∈Ω πv + (cid:88) U∈Ω, uv∈δ(U ) max πu + πv + πU πU ≤ w(uv) for all uv ∈ E πU ≥ 0 for all U ∈ Ω (5) We say that an edge e = uv is tight with respect to a dual π if equality holds in (5). A laminar family is a set system where each pair of sets is either disjoint or one set contains the other. More- over, a graph is factor critical if after removing each vertex the graph has a perfect matching. We use existence of the following dual: Lemma 16 (Edmonds '65 [5]). There exists an optimal dual solution π : V ∪ Ω → R, such that: 1. the set system {U ∈ Ω : πU > 0} forms a laminar family, 2. for each U ∈ Ω with πU > 0, the graph G[U ] with each set of {S ∈ Ω : S ⊂ U, πS > 0} contracted is factor critical. Definition 17 (critical dual, blossom). An optimum dual solution satisfying the conditions from Lemma 16 is a critical dual solution. A set U ∈ Ω such that πU > 0 is a blossom w.r.t. π. Blossoms of critical dual solutions have the following useful property (note the lemma below is weight-oblivious and the only input given to the algorithm is an undirected unweighted graph, the family of blossoms, and v). 13 Lemma 18. Consider any critical dual solution and let U ∈ Ω be an arbitrary blossom. For any vertex v ∈ U there exists a perfect matching M (U, v) in G[U \ {v}], such that for each blossom U0 ⊆ U , M (U, v) ∩ δ(U0) is 0 if v ∈ U0 and 1 if v (cid:54)∈ U0. Furthermore, given the family of all blossoms and v, one can find such a matching in O(Uω) running time, with high probability. Proof. Let B be the set of blossoms of π properly contained in U (B might be empty); moreover let Bmax be the set of inclusionwise maximal sets in B. Let G(cid:48) be the graph G[U ]/Bmax and let v(cid:48) be a vertex of G(cid:48) corresponding to v. (Here we use the contraction operator -- if S is a family of disjoint vertex sets, G/S denotes the graph G with each set of S contracted to a single vertex.) \ v(cid:48). It exists since G(cid:48) is factor critical. For each blossom U0 ∈ Bmax, recursively find a perfect matching M0 in the graph G[U0 \ x], where x is the single vertex of the intersection of U0 and V (M (U, v)) ∪ {v}. Add the edges of M0 to M (U, v). By construction the final matching M (U, v) satisfies conditions from the lemma. For the time bound note that the laminarity of B implies the total number of vertices in all graphs constructed by the above procedure is O(n). The algorithms of [23, 26, 14] find a perfect matching on an arbitrary graph of n vertices in time O(nω), with high probability. Hence our recursive procedure runs in total time O(Uω). Initially let M (U, v) ⊆ E be a perfect matching in G(cid:48) Complementary slackness gives the following observation. Observation 19. For any optimum dual solution: (a) a set U ∈ Ω with πU > 0 has exactly one edge of δ(U ) in any minimum weight perfect matching; (b) an edge belonging to any minimum weight perfect matching is tight. Lemma 20. Given a weighted undirected graph G = (V, E, w, W ) where each edge is allowed, and the set of blossoms B of some critical dual solution, one can find a minimum weight perfect matching in O(nω) time, with high probability. Proof. Let Bmax ⊆ B be the set of inclusionwise maximal blossoms. Let graph G(cid:48) = G/Bmax. G(cid:48) has a perfect matching M0 (since Observation 19(a) shows any minimum weight perfect matching in G contains a subset of edges forming a perfect matching in G(cid:48)). We extend M0 to a perfect matching in G by considering the blossoms of U ∈ Bmax one by one. Let vU be the unique vertex of U that is matched by M0. Add the matching M (U, vU ) of Lemma 18 to M0. The final set M0 is a perfect matching for G. The time for this procedure is O(nω). This follows exactly as in Lemma 18, since the total number of vertices in all graphs considered is O(n). Finally, we prove that M is a minimum weight perfect matching in G by showing that for each blossom U ∈ B the set M contains exactly one edge of δ(U ). Consider a maximal blossom U ∈ Bmax. When finding a perfect matching in G(cid:48) we have added exactly a single edge of δ(U ) to the set M . Moreover each edge of M (U(cid:48), vU(cid:48)), for any maximal blossom U(cid:48) ∈ Bmax, is contained in U(cid:48), and therefore the set M contains exactly one edge of δ(U ). Now let us consider a blos- som U ∈ B \ Bmax, and let U(cid:48) ∈ Bmax be a maximal blossom containing U . If in the first phase (finding a perfect matching in G(cid:48)) we added no edge from δ(U ) to the set M , then by Lemma 18 in the set M (U(cid:48), vU(cid:48)) there is exactly one edge of δ(U ), whereas for each other maximal blossom U(cid:48)(cid:48) (cid:54)= U(cid:48), in the set M (U(cid:48)(cid:48), vU(cid:48)(cid:48)) there is no edge of δ(U ). If, however, in the first phase we added an edge from δ(U ) to the set M , then by the choice of v(cid:48) edge of δ(U ) ∩ M , no other edge of δ(U ) is added to the set M . U , which is the endpoint of the ∈ Bmax, U(cid:48)(cid:48) 14 Since all the edges are allowed, by Observation 19(b) the sum of values of edges of M is equal to the cost of the critical dual solution, which proves that M is a minimum weight perfect matching in the graph G. Note that our algorithm does not need exact values of the dual nor even weights of edges, since its input is only graph G and set B. A critical dual solution gives rise to a weighted tree in a natural way: Definition 21 (dual tree). Let π : Ω ∪ V → R be a critical dual solution, with B the set of its blossoms. The dual tree T (π) is a rooted tree on nodes {V } ∪ B ∪ V , where V is the root, vertices of V are leaves, blossoms of B are internal nodes and the parent-child relation in T (π) is naturally defined inclusionwise. The weight of the edge from a node t ∈ B ∪ V to its parent is πt. The height of the tree H(T (π)) is the weight of a longest path from the root to some leaf. In this definition note that the last edge of a path defining H(T (π)) may have negative length. For a tree T with weighted edges and two nodes u, v, dist T (u, v) denotes the weight of the path between u and v. The following simple lemma provides a basic tool. Lemma 22. If π is a critical dual solution for a weighted graph G = (V, E, w, W ), any allowed edge uv satisfies w(uv) = dist T (π)(u, v). Proof. Since uv is tight (Observation 19(b)), w(uv) = πu + πv +(cid:80) U∈Ω, uv∈δ(U ) πU . The right-hand side gives dist T (π)(u, v) for two reasons: The edges of T (π) incident to leaves are weighted with the singleton values of π. A blossom B of π contains exactly one endpoint of the edge uv if and only if the path between u and v in T (π) contains the edge between B and its parent. The next steps of our development (Lemmas 25 -- 27) can be derived using an appropriate ver- sion of Edmonds' weighted matching algorithm (e.g., [29]). Here we will use a structural approach, based on the following properties of allowed edges given by Lov´asz and Plummer. Lemma 23 ([21], Lemma 5.2.1 and Theorem 5.2.2). Let G = (V, E) be an undirected connected graph where each edge belongs to some perfect matching. Define a binary relation R ⊆ V × V by (u, v) ∈ R if and only if G \ {u, v} has no perfect matching. Then • R is an equivalence relation; • each equivalence class of R is an independent set; • for each equivalence class S of R, the graph G \ S has exactly S connected components, each of which is factor critical. We will use a special type of critical dual solution that we call "balanced". Definition 24 (balanced critical dual). Let π : Ω ∪ V → R be a critical dual solution, and let G(cid:48) be the graph G with each blossom of π contracted. π is a balanced critical dual solution if there are two distinct vertices u, v ∈ V such that dist T (π)(u, V ) = dist T (π)(v, V ) = H(T (π)) and further, G(cid:48) } has a perfect matching for u(cid:48), v(cid:48) the (distinct) vertices of G(cid:48) corresponding to u, v, respectively. \ {u(cid:48), v(cid:48) Before proving that balanced critical dual solutions exist, we give a lemma showing why they are useful. In particular they show how the M (v) values relate to T (π). Let M (G) be a minimum weight perfect matching in G. 15 (cid:80) (cid:80) x,z /∈U πU . The right-hand side equals w(M (G))−πx−πz− (cid:80){x,z}∩U(cid:54)=∅ πU , by strong duality. Since Lemma 25. Let G = (V, E, w, W ) be an undirected connected graph with every edge in some mini- mum weight perfect matching. Let π be a balanced critical dual solution for G. For any vertex z ∈ V , a minimum weight almost perfect matching in G \ z weighs w(M (G)) − H(T (π)) − dist T (π)(z, V ). Proof. Any almost perfect matching in G \ z weighs at least w(M (G)) − H(T (π)) − dist T (π)(z, V ). In proof let M1 be an arbitrary perfect matching in G \ {x, z} for any x ∈ V . For any blossom U w∈V −x,z πw + of π such that x, z (cid:54)∈ U , M1 ∩ δ(U ) ≥ 1. Together with (5) this gives w(M1) ≥ every πU is nonnegative this quantity is at least w(M (G))−dist T (π)(z, V )−dist T (π)(x, V ). The defi- nition of H(T (π)) shows the last quantity is at least w(M (G))−dist T (π)(z, V )−H(T (π)) as desired. We complete the proof by constructing an almost perfect matching in G\z of weight w(M (G))− H(T (π)) − dist T (π)(z, V ). Take G(cid:48), u, v, u(cid:48), v(cid:48) as in Definition 24. Moreover let z(cid:48) be the vertex of G(cid:48) corresponding to z. G(cid:48) is connected, with every edge in a perfect matching, so it satisfies the (cid:54)Rv(cid:48). So z(cid:48) is not equivalent to at least of u hypothesis of Lemma 23. Definition 24 shows that u(cid:48) and v. W.l.o.g. assume that u(cid:48) \ {u(cid:48), z(cid:48) } has a perfect matching M0. Next, consider each inclusionwise maximal blossom U of π one by one. Let x ∈ U be the unique vertex of U in the set V (M0) ∪ {u, z}. Add to M0 the edges of the matching M (U, x) guaranteed by Lemma 18. Clearly M0 is a perfect matching in G \ {u, z}. For each blossom U of π, M0 ∩ δ(U ) is 1 if u, z (cid:54)∈ U , and 0 if u or z belongs to U . Blossoms of the latter type are those in the path (cid:54)= z(cid:48). We get from u to V or z to V in T (π). These two paths have disjoint edge sets, since u(cid:48) w(M0) = w(M (G)) − dist T (π)(u, V ) − dist T (π)(z, V ), since every edge of M0 is allowed, i.e., tight. Since dist T (π)(u, V ) = H(T (π)) this is the desired weight. (cid:54)Rz(cid:48). Thus G(cid:48) We prove that balanced critical duals exist in two steps. The first step shows a simpler property for critical duals actually makes them balanced. The second step shows duals with this property exist. Lemma 26. Let G = (V, E, w, W ) be an undirected connected graph with every edge in some minimum weight perfect matching. A critical dual π0 is balanced if it has minimum height (i.e., H(T (π0)) is no larger than the height of any other critical dual). Proof. Assume for the purpose of contradiction that π0 is not a balanced critical dual. For any vertex v ∈ V let hv denote its height in π0, hv = dist T (π0)(v, V ). Let u be the vertex of G with the greatest height hu. Let G(cid:48) be the graph G with inclusionwise maximal blossoms of π0 contracted. Let R be the equivalence relation of Lemma 23 for G(cid:48), and S1, . . . , Sk its equivalence classes. Let u belong to vertex u(cid:48) of G(cid:48) and let u(cid:48) We will define a dual function π1. An element of S1 is either a maximal blossom of π0 or a vertex of V not in any blossom; let si, 1 ≤ i ≤ S1, be the ith of these blossoms and vertices. Lemma 23 shows G(cid:48) \ S1 has S1 connected components; let Bi, 1 ≤ i ≤ S1, be the set of vertices of G contracted onto the i-th connected component of G(cid:48) \S1. Define π1 : Ω∪V → R to be identical to π0 except ∈ S1. (cid:40) π1(x) = π0(x) −  x = si, 1 ≤ i ≤ S1 π0(x) +  x = Bi, 1 ≤ i ≤ S1. (Note that if Bi consists of more than one vertex in G(cid:48) then we are creating a new blossom.) Let  be any positive real no larger than the smallest value of π0(si) for a blossom si. This ensures π1 is nonnegative on blossoms. 16 Figure 2: Graph G(cid:48) and the modification of the duals. Let us verify that π1 is a critical dual. First, observe that each edge of G remains tight in π1: Nothing changes for an edge that has both ends in the same set of S1 or some Bi. The remaining possibility is an edge between S1 and some Bi (no edge joins 2 Bi sets or 2 sets of S1, the latter by independence of S1). For such edges we have added and subtracted  in the left-hand side of 5, so it remains tight. Next observe that the blossoms of π1 form a laminar family. Lemma 23 shows the sets Bi induce factor critical graphs. Finally π1 is an optimum dual, since its objective as π0. Thus π1 is a critical dual. Taking  small enough makes π1 a critical dual with smaller height than π0, the desired contra- diction. To see this take any vertex v ∈ V , and let v(cid:48) be the vertex of G(cid:48) that v is contracted onto. ∈ S1, the height of v decreases as long as  is positive. Suppose v(cid:48) /∈ S1. Lemma 23 shows If v(cid:48) π0 would be balanced if hv = hu. Thus hv < hu. Choose  small enough so that every such v has dist T (π1)(v) = dist T (π0)(v) +  ≤ hu − . Thus π1 has smaller height than π0. Lemma 27. Let G = (V, E, w, W ) be an undirected connected graph with every edge in some min- imum weight perfect matching. There is a critical dual π0 that has the smallest height H(T (π0)). Proof. Lemma 16 shows a critical dual π exists. There are a finite number of laminar families on V , i.e., a finite number of trees T (π). So it suffices to show that there is a smallest height among all critical duals π with the same tree T = T (π). We begin by showing that for every blossom U , there is a unique value for πx, where x is any vertex of U or any blossom properly contained in U . We argue inductively, so assume this holds for every blossom properly contained in U . For any edge uv we break the left-hand side of (5) into the contributions from u and from v, by defining (cid:88) πu,v = πu + πU U∈Ω, u={u,v}∩U and symmetrically for πv,u. So the left-hand side of (5) is πu,v + πv,u. Take any edge uv joining two vertices u, v ∈ U . uv is on an odd cycle C contained in U . (U is fac- tor critical, so let Mu (Mv) be a perfect matching on U−u (U−v) respectively. The symmetric differ- ence Mu⊕ Mv contains an even-length path from u to v.) Each edge of C is tight. So for every edge xy in C, the values of πx,y and πy,x are uniquely determined. If πx,y does not have any contributions from blossoms properly contained in U then πx = πx,y has been uniquely determined. If πx,y has 17 −−−−−−−−−−−−++S1++ a contribution πW from a blossom W that is a maximal blossom properly contained in U then πW has been uniquely determined. This follows since the other π values contributing to πx,y have been determined by induction. (Note that πW has also been uniquely determined from the other edge of C ∩ δ(W ).) If neither of these conditions apply to πx,y then all its π-values have been determined by induction. Since any vertex u ∈ U is on an edge uv in U , this completes the inductive argument. Next consider any edge uv not contained in a blossom of T . The previous argument shows exactly one term in the quantity πu,v is still undetermined. If uv is in an odd cycle C the previous argument shows that term is uniquely determined. Contract all such odd cycles as well as all blos- soms of T . We get a bipartite graph G(cid:48). It contains at least one edge. Let S be a spanning tree of G(cid:48). Choose a value p0 for the unknown term p at the root of S, that comes from a valid critical dual for T . Suppose we increase p. If this increases H(T ), every value of p larger than p0 gives larger height. Suppose this decreases H(T ). All the other unknown π-values are uniquely determined from tightness of the edges of S. Also every edge of G(cid:48) not in S remains tight by bipartiteness. There is a maximum value p such that every value p > p either makes the π-values invalid (because some πU , U ∈ Ω becomes negative) or increases the height (since p contributes to the height of the root vertex). Similarly there is a minimum value p for p. We conclude there is a unique smallest height for a critical dual for T -- it occurs when p is equal to either p or p. As already mentioned, the last two lemmas show any undirected connected graph G = (V, E, w, W ) with all edges allowed has a balanced critical dual. We can now reach our final goal. Lemma 28. Let G = (V, E, w, W ) be a weighted undirected connected graph where every edge is allowed. Given all values w(M (v)) for v ∈ V , the blossoms of a balanced critical dual solution can be found in O(n2) time. Proof. Let π be a balanced critical dual solution. By Lemma 25 for each leaf node v ∈ V of T (π), w(M (v)) = w(M (G))− H(T (π))− dist T (π)(z, V ). Define new edge weights w(cid:48) : E → Z as w(cid:48)(uv) = w(M (u)) + w(M (v)) + w(uv). Consider any uv ∈ E. Since uv is tight, w(uv) = dist T (π)(u, v). Define a quantity c that is independent of uv, c = 2(w(M (G)) − H(T (π))). Then (cid:48) w (uv) = w(uv) + w(M (u)) + w(M (v)) = dist T (π)(u, v) + 2w(M (G)) − 2H(T (π)) − dist T (π)(u, V ) − dist T (π)(v, V ) = 2(w(M (G)) − H(T (π))) − 2dist T (π)(lca(u, v), V ) = c − 2dist T (π)(lca(u, v), V ) . (6) Let B = lca(u, v). So B is the inclusionwise minimal blossom of π containing both u and v, or if no such blossom exists, B is the root V of the tree T (π). For any edge uv let Buv ⊆ V be the the set of vertices reachable from u or v by a path of edges e satisfying w(cid:48)(e) ≤ w(cid:48)(uv). Claim. For any edge uv, Buv = B. Proof of Claim. Let F ⊆ E be the set of edges of a spanning tree of G[B] (G[B] is connected since either B = V or G[B] is factor critical). Since any edge ab ∈ F is contained in B, the node lca(a, b) descends from lca(u, v) in T (π). Thus the path from lca(a, b) to lca(u, v) in T has nonnegative weight. This implies w(cid:48)(ab) ≤ w(cid:48)(uv) by (6). Thus B ⊆ Buv. For the opposite inclusion, consider any edge ab with a ∈ B and w(cid:48)(ab) ≤ w(cid:48)(uv). Since every blossom has a strictly positive π-value, (6) implies b ∈ B. Now an easy induction shows any path from u or v, with every edge e having w(cid:48)(e) ≤ w(cid:48)(uv), has every vertex in B. Thus Buv ⊆ B. ♦ 18 Any blossom B of π has an edge uv with B the minimal blossom containing u and v (by lam- inarity and connectedness of B). So the claim of the lemma amounts to constructing all the sets Buv. This is done in O(n2) time by Algorithm 5 below. Algorithm 5 Given all the values w(M (u)), finds the blossoms of a balanced critical dual in the graph G where all edges are allowed. 1: For each edge uv set w(cid:48)(uv) = w(uv) + w(M (u)) + w(M (v)). 2: Let A be the set of all different values w(cid:48)(uv). Let B = ∅. 3: for each α ∈ A, in increasing order, do Let C be the set of connected components of the graph (V,{uv : uv ∈ E, w(cid:48)(uv) ≤ α}). Add the nontrivial components of C to B. 4: 5: 6: end for 7: return B. 6.3 The Final Algorithm Theorem 29. Let G = (V, E, w, W ) be a weighted undirected graph containing a perfect matching. A minimum weight perfect matching in G can be computed O(W nω) time, with high probability. Proof. First, using Corollary 11, we can remove all the edges of G which are not allowed. Clearly, we can consider each connected component of G separately, hence w.l.o.g. we assume that G is connected. Next, compute all the values w(M (u)) for each u ∈ V using Corollary 15. Having all the values w(M (u)) by Lemma 28 we can find the set of blossoms B of a balanced critical dual solution and consequently by Lemma 20 we can find a minimum weight perfect matching in G. The full version of this paper shows how the matching algorithm can be made Las Vegas. In some applications the second smallest perfect matching is of interest (e.g., Section 9). Its weight is easily found, as follows. As discussed in the proof of Lemma 13, the terms in the de- terminant of det( A(G)) correspond to even-cycle covers in the graph G. Each such cycle can be decomposed into two perfect matchings. As we already observed the smallest degree term in y in det( A(G)) corresponds to taking twice the minimum weight perfect matching in G. The next smallest term gives the following. Corollary 30. Let G = (V, E, w, W ) be a weighted undirected graph. The degree in y of a second smallest monomial of det( A(G)) is equal to the weight of a minimum weight perfect matching M∗ plus the weight of a second smallest perfect matching M(cid:48). In particular, the weight of a second smallest perfect matching can be found in O(W nω) time, with high probability. Proof. Letting τ (M∗) denote the term corresponding to M∗ in det( A(G)), (cid:104) w(M(cid:48)) = term∗ y (cid:105) det( A(G)) − τ (M∗) . 7 Diameter and Radius In this section we consider the problem of computing the diameter and radius of a directed graph without negative weight cycles. By bidirecting the edges this result can be applied to undirected graphs with nonnegative edge weights. 19 We start with definitions of the quantities of interest, plus equivalent definitions that we use to compute these quantities. To motivate the latter note that it seems difficult to compute a given set of distances S directly. Instead we show how to check if, for an arbitrary value c, all the distances in S are ≤ c. For a graph G and a vertex i, eccentricity(i) = max{dist G(i, j) : j ∈ V } radius(G) diameter(G) = min{c : (∀j)(c ≥ dist(i, j))}, = min{eccentricty(i) : i ∈ V } = min{c : (∃i)(∀j)(c ≥ dist(i, j))}, = max{eccentricty(i) : i ∈ V } = min{c : (∀i, j)(c ≥ dist(i, j))}. We use the following theorem proven in [27]3: Lemma 31. Let −→G be a directed weighted graph without negative weight cycles. The weight of the . Moreover, all shortest path in G from i to j is given by dist G(i, j) = deg A(−→G ) + I adj (cid:18) ∗ y (cid:16) (cid:19) (cid:17) i,j non-zero terms in det are non-zero over any finite field Zp. i,j (cid:20) (cid:16) In order to be able to use the above lemma we first need to apply the following observation. Corollary 32. Let c be arbitrary number from [−nW, . . . , nW ]. There exists d ≤ c such that termd (cid:54)= 0. This y (cid:54)= 0 if and only if termc A(−→G ) + I A(−→G ) + I i,j · adj adj y (cid:20) (cid:16) (cid:17) i=0 yi(cid:17)(cid:21) (cid:16)(cid:80)2nW (cid:17) A(−→G ) (cid:16) (cid:17) (cid:21) continues to hold in any finite field. Proof. Multiplication of a polynomial by(cid:80)2nW i,j i=0 yi means that we add all lower degree terms to a term of a given degree. Hence, if some degree term d was non-zero then all higher degree terms become non-zero (assuming no terms get cancelled). Since 0 ≤ c−d ≤ 2nW a degree d term creates a corresponding degree c term in the product. Finally observe that no term drops out because of cancellations4: In the matrix A(−→G ) + I, every nonzero entry has the form xyw(x), where x is the indeterminate (cid:54)= y (or 1 in diagonal entries) and w is a function. So every term in det( A(−→G ) + I) has the exponent of y functionally dependent on the remaining variables. This holds for an entry of the adjoint too. Thus a term ((cid:81) x)yc created in the multiplication of the corollary comes from exactly one term ((cid:81) x)yd in the adjoint (i.e., d =(cid:80) w(x)). So there are no cancellations, in ordinary arithmetic or in Zp. To find the diameter, we use this Corollary to perform a binary search for the lowest c such that for all i, j ∈ V , (cid:34) (cid:16) termc y adj A(−→G ) + I (cid:17) i,j · (cid:32)2nW(cid:88) (cid:20) i=0 (cid:33)(cid:35) (cid:16) yi (cid:54)= 0. Clearly this c is the diameter. Similarly a binary search for the lowest c where the displayed condition holds for some i with every j gives the radius. The main problem left is how to check whether termd y (cid:54)= 0. We will show how to obtain adj as a partial derivative of det. We define Z to be a fully symbolic matrix of size n × n as Zi,j = zi,j, where zi,j are unique variables for all i, j ∈ [1, . . . , n]. We define σz to be an evaluation that assigns 0 to all zi,j. Now we are ready to prove the following lemma. i,j · adj (cid:17) i=0 yi(cid:17)(cid:21) (cid:16)(cid:80)2nW A(−→G ) + I A( 3In [27] the graph was defined to contain self-loops whereas here we add self-loops in the equation by taking −→ G ) + I. 4We shall apply this principle to other matrices. 20 Lemma 33. (cid:34) termd y adj (cid:16) A(−→G ) + I (cid:17) (cid:32)2nW(cid:88) i,j i=0 (cid:33)(cid:35) yi = ∂ ∂zj,i (cid:34) termd y det (cid:16) A(−→G ) + I + Z (cid:17)(cid:32)2nW(cid:88) i=0 (cid:33)(cid:35)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)σz . yi Proof. Observe that for the fully symbolic n × n matrix Z and any n × n matrix A not involving any variable zi,j, det( A + Z)σz = adj( A)i,j. ∂ ∂zj,i (cid:17)(cid:32)2nW(cid:88) (cid:12)(cid:12)(cid:12)σz (cid:17) i=0 i,j (cid:33)(cid:35)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)σz (cid:32)2nW(cid:88) yi yi i=0 (cid:34) = termd y (cid:33)(cid:35) ∂ ∂zj,i (cid:34) (cid:16) (cid:16) (cid:17)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)σz (cid:32)2nW(cid:88) (cid:32)2nW(cid:88) (cid:33)(cid:35) i=0 yi (7) (cid:33)(cid:35) yi . (cid:17) i,j i=0 Thus ∂ ∂zj,i termd y (cid:34) (cid:34) det (cid:16) (cid:16) A(−→G ) + I + Z det A(−→G ) + I + Z = termd y adj A(−→G ) + I + Z = termd y adj A(−→G ) + I Joining the above results together with Theorem 9 and Corollary 32 we get the following algo- rithm. ( A(−→G ) + I + Z)yW(cid:17)(cid:105) Algorithm 6 Checks whether diameter of the directed graph −→G is ≤ c. i=0 yi(cid:17) (cid:104)(cid:16)(cid:80)2nW termc+nW derivatives (cid:16) det ∂ y . ∂zi,j 1: Let ∂zf be the routine given by the Baur-Strassen theorem to compute the matrix of partial σ : X ∪ Z → Zp by setting σZ = σz. 2: Generate a random substitution σ : X → Zp for a prime p of order Θ(n4). Extend it to 3: Compute the matrix δ = ∂zfσ. 4: Return true if δi,j is non-zero for all i, j ∈ V . Note that the polynomial multiplication in Step 1 need only compute the coefficient of yc+nW and so only uses time O(nW ). Using binary search with the above algorithm, and using a similar algorithm for radius, we obtain: Theorem 34. Let −→G = (V, E, w, W ) be a weighted directed graph without negative weight cycles. The diameter and radius of G can be computed in O(W nω) time, with high probability. 8 Shortest Cycles in Undirected Graphs Let G = (V, E, w, W ) a weighted undirected graph. In this section we consider only the problem of computing shortest cycles when all edges have non-negative weights. The more general case is solved in the next section, and uses the ideas introduced here. Let us define a symbolic adjacency matrix of the weighted undirected graph G to be the be the symbolic matrix polynomial A(G) equal to A(−→G ), where −→G is the bidirection of G. 21 (cid:104) (cid:105) (cid:104) (cid:105) det( A(G) + I) − 1 ∂ ∂ ∂xv,u xu,v termd y ∂xu,v − xv,u Lemma 35. Let G be an undirected weighted graph with no negative edges, and d ∈ [0, nW ]. Some uv ∈ E has (cid:54)= 0 iff some cycle packing of weight d contains a component that is an oriented cycle through uv in G. Moreover, for p ≥ 2, all non-zero terms in the above expression are non-zero over the finite field Zp. Proof. As argued in the proof of Lemma 4 det( A(−→G )+I)−1 contains only terms that correspond to cycle packings. Moreover, the degree of each non-zero term is equal to the total weight of the cycles in the packing. However, because A(G) was constructed using bidirected graph there might be terms containing both antiparallel edges, that correspond to bidirected edges in the undirected graph. Next we show that a cycle packing C in G contributes to the expression of the lemma iff it con- tains exactly one of the variables xu,v and xv,u, and hence contains a simple cycle passing through uv. Moreover we show that in such a case the contribution of C is a product of variables corre- sponding to C and hence the contribution of C is not cancelled out by a different cycle packing. If C does not contain xu,v or xv,u, clearly it has zero contribution. This leaves two possibilities: (cid:104) (cid:105) ∂ ∂ xu,v ∂xu,v − xv,u Case 1. C contains a cycle u, v, u Since 0, C's term makes no contribution. Case 2. C contains a simple cycle C containing uv The corresponding term contains exactly one of xu,v and xv,u say xu,v. We have xu,v = xu,v. Hence, the derivative for this term is nonzero and is equal to the sign of permutation multiplied by the product of the variables of the oriented edges of C. xu,vxv,u = xu,vxv,u − xv,uxu,v = ∂xu,v − xv,u (cid:104) (cid:105) xu,v ∂xv,u ∂xv,u ∂ ∂ Similarly as in undirected graphs we say that edge e is allowed if and only if it belongs to some simple shortest cycle C in G. The above proof actually gives us a way to find allowed edges as well. Corollary 36. Let d be smallest number in [1, nW ] such that there exists an edge uv ∈ E such (cid:54)= 0. Then an edge uv ∈ E is allowed if and that ∂xu,v − xv,u termd y xu,v ∂xv,u ∂ ∂ (cid:104) (cid:105) only if when xu,v ∂ ∂xu,v − xv,u ∂ ∂xv,u det( A(G) + I) − 1 (cid:54)= 0. (cid:105) (cid:104) (cid:105) (cid:105) det( A(G) + I) − 1 termd y (cid:104) (cid:104) Computing the Weight of the Shortest Cycle Using Lemma 35 we will devise an algorithm that will be able to check whether there exists a simple cycle in G of length shorter or equal to c. In order to do it we need the observation similar to Corollary 32. Corollary 37. Let c be arbitrary number from [1, nW ]. There exists d ≤ c such that (cid:20) (cid:104) if and only if xu,v ∂ ∂xu,v − xv,u ∂ ∂xv,u (cid:105) xu,v ∂ ∂xu,v − xv,u ∂ ∂xv,u termc y (cid:21) (cid:104) (cid:105) det( A(G) + I) − 1 (det( A(G) + I) − 1) · ((cid:80)nW termd y (cid:104) (cid:54)= 0 (cid:105) i=0 yi) (cid:54)= 0. Using the above observation we can construct the following algorithm. 22 Algorithm 7 Checks whether the shortest cycle in undirected graph G has weight ≤ c. 1: Let ∂xf be the routine given by the Baur-Strassen theorem to compute the matrix of partial derivatives ∂ ∂xu,v termc y i=0 yi) 2: Generate a random substitution σ : X → Zp for a prime p of order Θ(n4). 3: Compute the matrix δ = ∂xfσ. 4: Compute the matrix δ(cid:48) with δ(cid:48) 5: Return true if δ(cid:48) has a non-zero entry. u,v = [xu,vδu,v − xv,uδv,u] (cid:104) ((cid:80)nW (cid:16) (cid:17)(cid:105) det( A(G) + I) − 1 (cid:12)(cid:12)σ. . The correctness of the above algorithm is implied by both Theorem 8 and Theorem 9. Using binary search with it we obtain. Theorem 38. Let G = (V, E, w, W ) be a weighted undirected graph without negative weight edges. The weight of the shortest simple cycle in G can be computed in O(W nω) time, with high probability. Finding the Shortest Cycle After showing how to compute the shortest cycle length it re- mains to show how to find the cycle itself. We essentially can use the same approach as we used for directed graphs in Section 4. Algorithm 8 Computes the shortest cycle in undirected graph G. 1: Let c∗ be the weight of the shortest cycle computed using Theorem 38. 2: Let δ(cid:48) be the matrix computed by Algorithm 7 for c = c∗. 3: Take any edge uv such that δuv (cid:54)= 0. 4: Compute the shortest path pv,u from v to u in G \ {uv} using Dijkstra. 5: Return the cycle formed by uv and pv,u. Theorem 39. Let G = (V, E, w, W ) be a weighted undirected graph without negative weight edges. The shortest simple cycle in G can be found in O(W nω) time, with high probability. 9 Undirected Graphs with Negative Weights This section gives algorithms for shortest cycle and diameter in undirected graphs with possibly negative edges but no negative weight cycles. To accomplish this we need to combine the ideas from Sections 7 and 8 with our results for weighted matching. We will recast the results for the diameter and shortest cycles into the language of matchings. Hence (unlike Section 8) throughout this section the symbolic adjacency matrix A(G) of an undirected graph G is defined as in Section 6.1. Diameter Let G = (V, E, w, W ) be an undirected graph with negative weights allowed, and let E− be the set of edges with negative weights. We will define a graph G that models paths in G by almost perfect matchings. We believe the construction is essentially due to Edmonds [6]. Define the split graph G = ( V , E, w, W ) where V = {v1, v2 : v ∈ V } ∪ {e1, e2 : e ∈ E − }, E = {v1v2 : v ∈ V } ∪ {u1v2, u2v1, u1v1, u2v2 : uv ∈ E \ E } ∪ {u1e1, u2e1, e1e2, v1e2, v2e2 : e = uv ∈ E − − , u < v}, 23  w(uv) w(e) if uv ∈ E \ E−, if ui = e1 and vj (cid:54)= e2 and e ∈ E−, 0 otherwise. w(uivj) = Figure 3: An undirected graph G and its graph G. In G zigzag edges weigh −1, dashed edges weigh 1 and the remaining edges weigh 0. Vertices corresponding to negative edges of G are white squares. The far right shows a matching M (a2c1) of weight −2, which corresponds to a shortest path between a and c. Note how a length-two path in G, say a, b, c with w(ab) ≥ 0 > w(bc) and e = bc, corresponds to a matching in G such as a1b1, b2e1, e2c1, having the same total weight. Fig.3 gives a complete example. An important property is that we can assume n = V ≤ 4n. This follows since we can assume E− < n, as otherwise the set of negative edges contains a cycle. We will consider minimum weight perfect matchings in G. To use our algebraic tools we should eliminate negative weights by setting w(cid:48)(e) := w(e) + W . Obviously this increases the weight of all perfect matchings by nW/2 and so doesn't change the minimum perfect matching. But to keep things simple in the following we keep G as defined above, with w possibly negative. The following observation is essentially given in [1] in Chapter 12.7 (for a larger version of our graph). Lemma 40. Let u, v ∈ V , let M be the minimum weight perfect matching, and let M (u2v1) be the minimum weight almost perfect matching in G that does not match v1 nor u2. If G does not contain negative weight cycles then w(M ) = 0 and the shortest path weight from u to v in G is equal to w(M (u2v1)). Note also that it is easy to detect a negative cycle in G -- it corresponds to a perfect matching in G with negative weight. ∗ y(adj( A( G))u2,v1) = w(M ) + w(M (u2v1)). Thus dist G(u, v) = By Lemma 13 we know that deg ∗ y(adj( A( G))u2,v1), i.e., just as in Lemma 31, adj( A( G)) encodes the distances in G. Now we deg proceed exactly as in Algorithm 6. 24 −1101−1abcda1a2b1b2d1d2ab1ab2cd2cd1c1c2a1a2b1b2d1d2ab1ab2cd2cd1c1c2 Algorithm 9 Checks whether diameter of the undirected graph G with negative weights is ≤ c. 1: Let ∂zf be the routine given by the Baur-Strassen theorem to compute the matrix of partial (cid:104)(cid:16)(cid:80)2nW i=0 yi(cid:17) (cid:16) ( A( G) + Z)yW(cid:17)(cid:105) det , u, v ∈ V . derivatives ∂ ∂zu2,v1 termc+nW y σ : X ∪ Z → Zp by setting σZ = σz. 2: Generate a random substitution σ : X → Zp for a prime p of order Θ(n4). Extend it to 3: Compute the matrix δ = ∂zfσ. 4: Return true if δu2,v1 is non-zero for all u, v ∈ V . Note that A( G) + Z is not skew-symmetric but we still get the adjoint by (7). Similarly to check if the radius is ≤ c, Step 4 returns true if some row of δ consists entirely of nonzeroes. Again using binary search we obtain. Theorem 41. Let G = (V, E, w, W ) be a weighted undirected graph without negative weight cycles. The diameter and radius of G can be computed in O(W nω) time, with high probability. (cid:104) y (cid:105)(cid:16) (cid:17) Shortest Cycles Recalling Corollary 30, it might appear that a second smallest perfect matching in G corresponds to a shortest cycle in G. But this is not true, because of cycles of length two (e.g., u1v1, v2u2 or u2v1, v2u1). These can be handled as in Section 8, by antisymmetric derivatives xu,v . For the next lemma note that in the absence of negative cycles, any cycle contains an edge of nonnegative weight. ∂xu,v − xv,u ∂xv,u ∂ ∂ Lemma 42. Let G be an undirected weighted graph with no negative cycle. For any edge uv ∈ E \ E−, a shortest cycle through uv weighs term∗ . This (cid:105)(cid:16) continues to hold in any field Zp, p ≥ 2. Proof. Let δ = (cid:21) ables x, y and any integers i, j, (cid:20) . Observe that in general for any vari- ∂xu1,v2 − xu2,v1 ∂xu1,v2 − xu2,v1 det( A( G)) det( A( G)) xu1,v2 xu1,v2 ∂xu2,v1 ∂xu2,v1 (cid:17) (cid:104) ∂ ∂ ∂ ∂ x ∂ ∂x − y ∂ ∂y xiyj = (i − j)xiyj. (8) Let C be a shortest cycle through uv. It gives an even-cycle cover M∗ Hence the terms in δ are a subset of those in det( A( G)), i.e., the effect of the differentiation operator is just to change the multiplicity of some terms, perhaps zeroing them or causing other cancellations. ∪ N in G with weight w(C), where M∗ is the minimum perfect matching of G, M∗ = {v1v2, e1e2 : v ∈ V, e ∈ E− }, and N is the perfect matching of G containing u1v2 but not u2v1, plus representatives of the other edges of C, plus edges x1x2 for vertices or negative edges x /∈ C. Let τ be the monomial corresponding to this cover (e.g., τ has the term yw(C)). (8) (applied to x1 u2,v1) shows τ is a term contributing to δ. In fact τ is the only such term in δ involving its monomial. This again follows from (8) and the preliminary observation (it is easy to see τ is the unique edge cover for its monomial, i.e., none of its cycles can be reversed). We conclude term∗ u1,v2x0 We complete the proof by showing term∗ y(δ) ≥ w(C). First observe that a perfect matching M on G that contains u1v2 but not u2v1 weighs at least w(C). To prove this imagine contracting each edge x1x2 of G; call the resulting vertex x. Every vertex now has degree 2 in M . We will compute the weight of M by examining its edges in the contracted graph. An edge x1x2 ∈ M becomes a y(δ) ≤ w(C). 25 loop at x of weight 0. An edge xy ∈ E \ E− with x1y1, x2y2 ∈ M or x1y2, x2y1 ∈ M becomes 2 copies of xy, both with nonnegative weight. The other edges of M form cycles in the contracted graph. Each cycle is a cycle in G and so has nonnegative weight. One of the cycles contains edge uv, so it weighs at least w(C). Hence w(M ) ≥ w(C). Consider an even-cycle cover C that contributes to δ. (8) shows i (cid:54)= j, i.e., u1v2 and u2v1 occur with different multiplicities in C. The possibilities for {i, j} are {0, 1}, {0, 2}, and {1, 2}. C decom- poses into 2 perfect matchings. In all three cases one of the matchings of C contains exactly 1 of the edges u1v2, u2v1. That matching weighs at least w(C). The other matching has nonnegative weight, so C weighs at least w(C). In other words term∗ y(δ) ≥ w(C). Using this lemma with the scheme of Algorithm 7 gives the following. compute the matrix of partial derivatives Algorithm 10 Checks whether a shortest cycle in undirected graph G with negative weights has weight ≤ c. 1: For (i, j) = (1, 2), (2, 1), let ∂xf i,j be the routine given by the Baur-Strassen theorem to (cid:16) 2: Generate a random substitution σ : X → Zp for a prime p of order Θ(n4). 3: For (i, j) = (1, 2), (2, 1) compute the matrix δi,j = ∂xf i,jσ. 4: Compute the matrix δ(cid:48) with δ(cid:48) u,v − xu2,v1δ2,1 5: Return true if δ(cid:48) has a non-zero entry. (cid:104) ((cid:80)nW (cid:105)(cid:12)(cid:12)(cid:12)σ det( A( G)yW ) termc+nW y xu1,v2δ1,2 (cid:17)(cid:105) . ∂ ∂xui,vj (cid:104) u,v = i=0 yi) u,v . Again a binary search gives Theorem 43. Let G = (V, E, w, W ) be a weighted undirected graph without negative weight cycles. The weight of a shortest cycle can be computed in O(W nω) time, with high probability. Algorithm 10 with c equal to the shortest cycle weight gives an edge uv with δ(cid:48) u,v (cid:54)= 0, i.e., uv is on a shortest cycle. So a minimum weight perfect matching on G− u1, v2 corresponds to a shortest cycle. Hence we can state Theorem 44. Let G = (V, E, w, W ) be a weighted undirected graph without negative weight cycles. A shortest cycle in G can be found in O(W nω) time, with high probability. The same holds for a shortest st-path, for any given vertices s, t. 10 Vertices Lying on Short Cycles For undirected graphs we only need to change the output of our algorithms: For Algorithm 7 (when there are no negative edges) or Algorithm 10 (in the general case) we find the set of vertices lying For directed graphs we apply the(cid:80)2nW on cycles of length ≤ c by changing the last step so that it returns {v ∈ V : ∃vu∈E δ(cid:48) i=0 yi multiplication technique to Algorithm 2: vu (cid:54)= 0}. 26 (cid:104) ((cid:80)2nW i=0 yi) (cid:16) det(( A(−→G ) + I)yW ) − ynW(cid:17)(cid:105) . Algorithm 11 Computes the set of vertices lying on cycles of length ≤ c in directed graphs. 1: Let ∂xf be the routine given by the Baur-Strassen theorem to compute the matrix of partial derivatives ∂ ∂xu,v termc+nW y 2: Generate a random substitution σ : X → Zp for a prime p of order Θ(n4). 3: Compute the matrix δ = ∂xfσ. 4: Return {v ∈ V : ∃(v,u)∈E δ(v,u) (cid:54)= 0}. Thus we obtain: Theorem 45. Let G be a weighted directed or undirected graph with integral weights in [−W, W ] and no negative cycle. For any c the set of vertices lying on cycles of length ≤ c can be computed in O(W nω) time, with high probability. References [1] R. K. Ahuja, T. L. Magnanti, and J. B. Orlin. Network Flows: Theory, Algorithms, and Applications. Prentice Hall, Englewood Cliffs, NJ, 1993. [2] W. Baur and V. Strassen. The complexity of partial derivatives. Theoretical Computer Science, 22(3):317 -- 330, 1983. [3] A. Bjorklund. Determinant sums for undirected hamiltonicity. In Prof. of FOCS'10, pages 173 -- 182, 2010. [4] T. M. Chan. More algorithms for all-pairs shortest paths in weighted graphs. In Proc. of STOC'07, pages 590 -- 598, 2007. [5] J. Edmonds. Maximum matching and a polyhedron with 0,1-vertices. Journal of Research National Bureau of Standards-B.,, 69B:125 -- 130, 1965. [6] J. Edmonds. An introduction to matching. Mimeographed notes, Engineering Summer Conference, U. Michigan, Ann Arbor, MI, 1967. [7] H. N. Gabow. An efficient implementation of edmonds' algorithm for maximum matching on graphs. Journal of the ACM, 23(2):221 -- 234, 1976. [8] H. N. Gabow. An efficient reduction technique for degree-constrained subgraph and bidirected network flow problems. In Proc. of STOC'83, pages 448 -- 456, 1983. [9] H. N. Gabow. A scaling algorithm for weighted matching on general graphs. In Proc. of FOCS'85, pages 90 -- 100, 1985. [10] H. N. Gabow. Data structures for weighted matching and nearest common ancestors with linking. In Proc. of SODA'90, pages 434 -- 443, 1990. [11] H. N. Gabow, Z. Galil, and T. Spencer. Efficient implementation of graph algorithms using contraction. Journal of the ACM, 36(3):540 -- 572, 1989. 27 [12] H. N. Gabow and R. E. Tarjan. Faster scaling algorithms for general graph matching problems. Journal of the ACM, 38(4):815 -- 853, 1991. [13] Z. Galil, S. Micali, and H. N. Gabow. An O(EV logV ) algorithm for finding a maximal weighted matching in general graphs. SIAM Journal on Computing, 15(1):120 -- 130, 1986. [14] N. J. A. Harvey. Algebraic structures and algorithms for matching and matroid problems. In Proc. of FOCS'06, pages 531 -- 542, 2006. [15] C.-C. Huang and T. Kavitha. Efficient algorithms for maximum weight matchings in general graphs with small edge weights. In Proc. of SODA'12, pages 1400 -- 1412, 2012. [16] A. Itai and M. Rodeh. Finding a minimum circuit in a graph. In Proc. of STOC'77, pages 1 -- 10, 1977. [17] D. B. Johnson. Efficient algorithms for shortest paths in sparse networks. Journal of the ACM, 24(1):1 -- 13, Jan. 1977. [18] M.-Y. Kao, T.-W. Lam, W.-K. Sung, and H.-F. Ting. A decomposition theorem for maximum weight bipartite matchings with applications to evolutionary trees. In Proc. of ESA'99, pages 438 -- 449, 1999. [19] R. M. Karp, E. Upfal, and A. Wigderson. Constructing a perfect matching is in random NC. Combinatorica, 6(1):35 -- 48, 1986. [20] E. L. Lawler. Combinatorial Optimization: Networks and Matroids. Holt, Rinehart, and Winston, New York, New York, 1976. [21] L. Lov´asz and M. D. Plummer. Matching Theory. Akad´emiai Kiad´o, 1986. [22] J. Morgenstern. How to compute fast a function and all its derivatives: a variation on the theorem of Baur-strassen. SIGACT News, 16(4):60 -- 62, Apr. 1985. [23] M. Mucha and P. Sankowski. Maximum matchings via Gaussian elimination. In Proc. of FOCS'04, pages 248 -- 255, 2004. [24] S. Pettie. A new approach to all-pairs shortest paths on real-weighted graphs. Theoretical Computer Science, 312(1):47 -- 74, 2004. [25] L. Roditty and V. V. Williams. Minimum weight cycles and triangles: Equivalences and algorithms. In Proc. of FOCS'11, pages 180 -- 189, 2011. [26] P. Sankowski. Processor efficient parallel matching. In Proc. of SPAA'05, pages 165 -- 170, 2005. [27] P. Sankowski. Shortest paths in matrix multiplication time. In Proc. of ESA'05, pages 770 -- 778, 2005. [28] P. Sankowski. Maximum weight bipartite matching in matrix multiplication time. Theoretical Computer Science, 410(44):4480 -- 4488, 2009. [29] A. Schrijver. Combinatorial Optimization - Polyhedra and Efficiency. Springer-Verlag, 2003. 28 [30] J. T. Schwartz. Fast probabilistic algorithms for verification of polynomial identities. Journal of the ACM, 27:701 -- 717, 1980. [31] A. Shoshan and U. Zwick. All pairs shortest paths in undirected graphs with integer weights. In Proc. of FOCS'99, pages 605 -- 614, 1999. [32] A. Storjohann. High-order lifting and integrality certification. Journal of Symbolic Computation, 36(3-4):613 -- 648, 2003. [33] J. W. Suurballe and R. E. Tarjan. A quick method for finding shortest pairs of disjoint paths. Networks, 14(2):325 -- 336, 1984. [34] R. Yuster. A shortest cycle for each vertex of a graph. Information Processing Letters, 111(21-22):1057 -- 1061, Nov. 2011. [35] R. Yuster and U. Zwick. Answering distance queries in directed graphs using fast matrix multiplication. In Proc. of FOCS'05, pages 389 -- 396, 2005. [36] R. Zippel. Probabilistic algorithms for sparse polynomials. In Proc. of EUROSAM'79, pages 216 -- 226, 1979. [37] U. Zwick. All pairs shortest paths using bridging sets and rectangular matrix multiplication. Journal of the ACM, 49(3):289 -- 317, 2002. 29
1805.03574
2
1805
2019-01-08T07:56:43
Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time
[ "cs.DS" ]
Given a threshold $L$ and a set $\mathcal{R} = \{R_1, \ldots, R_m\}$ of $m$ haplotype sequences, each having length $n$, the minimum segmentation problem for founder reconstruction is to partition the sequences into disjoint segments $\mathcal{R}[i_1{+}1,i_2], \mathcal{R}[i_2{+}1, i_3], \ldots, \mathcal{R}[i_{r-1}{+}1, i_r]$, where $0 = i_1 < \cdots < i_r = n$ and $\mathcal{R}[i_{j-1}{+}1, i_j]$ is the set $\{R_1[i_{j-1}{+}1, i_j], \ldots, R_m[i_{j-1}{+}1, i_j]\}$, such that the length of each segment, $i_j - i_{j-1}$, is at least $L$ and $K = \max_j\{ |\mathcal{R}[i_{j-1}{+}1, i_j]| \}$ is minimized. The distinct substrings in the segments $\mathcal{R}[i_{j-1}{+}1, i_j]$ represent founder blocks that can be concatenated to form $K$ founder sequences representing the original $\mathcal{R}$ such that crossovers happen only at segment boundaries. We give an optimal $O(mn)$ time algorithm to solve the problem, improving over earlier $O(mn^2)$. This improvement enables to exploit the algorithm on a pan-genomic setting of haplotypes being complete human chromosomes, with a goal of finding a representative set of references that can be indexed for read alignment and variant calling.
cs.DS
cs
Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time Tuukka Norri Department of Computer Science, University of Helsinki, Helsinki, Finland [email protected] https://orcid.org/0000-0002-8276-0585 Bastien Cazaux Department of Computer Science, University of Helsinki, Helsinki, Finland [email protected] https://orcid.org/0000-0002-1761-4354 Dmitry Kosolobov Department of Computer Science, University of Helsinki, Helsinki, Finland [email protected] https://orcid.org/0000-0002-2909-2952 Veli Mäkinen Department of Computer Science, University of Helsinki, Helsinki, Finland [email protected] https://orcid.org/0000-0003-4454-1493 Abstract Given a threshold L and a set R = {R1, . . . , Rm} of m haplotype sequences, each having length n, the minimum segmentation problem for founder reconstruction is to partition the sequences into disjoint segments R[i1+1, i2],R[i2+1, i3], . . . ,R[ir−1+1, ir], where 0 = i1 < ··· < ir = n and R[ij−1+1, ij] is the set {R1[ij−1+1, ij], . . . , Rm[ij−1+1, ij]}, such that the length of each segment, ij − ij−1, is at least L and K = maxj{R[ij−1+1, ij]} is minimized. The distinct substrings in the segments R[ij−1+1, ij] represent founder blocks that can be concatenated to form K founder sequences representing the original R such that crossovers happen only at segment boundaries. We give an optimal O(mn) time algorithm to solve the problem, improving over earlier O(mn2). This improvement enables to exploit the algorithm on a pan-genomic setting of haplotypes being complete human chromosomes, with a goal of finding a representative set of references that can be indexed for read alignment and variant calling. 2012 ACM Subject Classification Theory of computation → Design and analysis of algorithms, Applied computing → Life and medical sciences → Bioinformatics Keywords and phrases Pan-genome indexing, founder reconstruction, positional Burrows -- Wheeler transform, range minimum query Related Version This is a preprint of a paper in WABI 2018 [13, https://doi.org/10.4230/ LIPIcs.WABI.2018.15]. Introduction 1 A key problem in pan-genomics is to develop a sufficiently small, efficiently queriable, but still descriptive representation of the variation common to the subject under study [1]. For example, when studying human population, one would like to take all publicly available variation datasets (e.g. [17, 4, 18]) into account. Many approaches encode the variation as a graph [15, 8, 16, 2, 9, 21] and then one can encode the different haplotypes as paths in this 9 1 0 2 n a J 8 ] S D . s c [ 2 v 4 7 5 3 0 . 5 0 8 1 : v i X r a 23:2 Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time graph. An alternative was proposed in [20], based on a compressed indexing scheme for a multiple alignment of all the haplotypes [10, 12, 22, 5, 7]. In either approach, scalability is hampered by the encoding of all the haplotypes. We suggest to look for a smaller set of representative haplotype sequences to make the above pan-genomic representations scalable. Finding such set of representative haplotype sequences that retain the original contiguities as well as possible, is known as the founder sequence reconstruction problem [19]. In this problem, one seeks a set of k founders such that the original m haplotypes can be mapped with minimum amount of crossovers to the founders. Here a crossover means a position where one needs to jump from one founder to another to continue matching the content of the haplotype in question. Unfortunately, this problem in NP-hard even to approximate within a constant factor [14]. For founder reconstruction to be scalable to the pan-genomic setting, one would need an algorithm to be nearly linear to the input size. There is only one relaxation of founder reconstruction that is polynomial time solvable. Namely, when limiting all the crossovers to happen at the same locations, one obtains a minimum segmentation problem specific to founder reconstruction [19]. A dynamic programming algorithm given in [19] has complexity O(n2m), where m is the number of haplotypes and n is the length of each of them. In this paper, we improve the running time of solving the minimum segmentation problem of founder reconstruction to the optimal O(mn) (linear in the input size). The main technique behind the improvement is the use of positional Burrows -- Wheeler transform (pBWT) [3], or more specificly its extension to larger alphabets [11]. While the original dynamic programming solution uses O(nm) time to look for the best preceding segment boundary for each column of the input, we observe that at most m values in pBWT determine segment boundaries where the number of distinct founder substrings change. Minimums on the already computed dynamic programming values between each such interesting consecutive segment boundaries give the requested result. However, it turns that we can maintain the minimums directly in pBWT internal structures (with some modifications) and have to store only the last L computed dynamic programming values, thus spending only O(m + L) additional space, where L is the input threshold on the length of each segment. The segmentation is then reconstructed by standard backtracking approach in O(n) time using an array of length n. 2 Notation and Problem Statement For a string s = c1c2 ··· cn, denote by s its length n. We write s[i] for the letter ci of s and s[i, j] for the substring cici+1 ··· cj. An analogous notation is used for arrays. For any numbers i and j, the set of integers {x ∈ Z: i ≤ x ≤ j} (possibly empty) is denoted by [i, j]. The input for our problem is the set R = {R1, . . . , Rm} of strings of length n, called recombinants. A set F = {F1, . . . , Fd} of strings of length n is called a founder set of R if for each string Ri ∈ R, there exists a sequence Pi of length n such that, for all j ∈ [1, n], we have Pi[j] ∈ [1, d] and Ri[j] = FPi[j][j]. The sequence Pi is called a parse of Ri in terms of F and the set of parses {P1, . . . , Pm} is called a parse of R in terms of F. An integer j such that Pi[j − 1] 6= Pi[j] is called a crossover point of the parse Pi; for technical reasons, the integers 1 and n + 1 are called crossover points too. We consider the problem of finding a "good" founder set F and a "good" corresponding parse of R according to a reasonable measure of goodness. Ukkonen [19] pointed out that such measures may contradict each other: for instance, a minimum founder set obviously T. Norri, B. Cazaux, D. Kosolobov, V. Mäkinen 23:3 has size d = maxj∈[1,n] {R1[j], . . . , Rm[j]}, but parses corresponding to such set may have unnaturally many crossover points; conversely, R is a founder set of itself and the only crossover points of its trivial parse are 1 and n + 1, but the size m of this founder set is in most cases unacceptably large. Following Ukkonen's approach, we consider compromise parameterized solutions. The minimum founder set problem [19] is, given a bound L and a set of recombinants R, to find a smallest founder set F of R such that there exists a parse of R in terms of F in which the distance between any two crossover points is at least L. It is convenient to reformulate the problem in terms of segmentations of R. A segment of R = {R1, . . . , Rm} is a set R[j, k] = {Ri[j, k]: Ri ∈ R}. A segmentation of R is a collection S of disjoint segments that covers the whole R, i.e., for any distinct R[j, k] and R[j0, k0] from S, [j, k] and [j0, k0] do not intersect and, for each x ∈ [1, n], there is R[j, k] from S such that x ∈ [j, k]. The minimum segmentation problem is, given a bound L and a set of recombinants R, to find a segmentation S of R such that max{R[j, k]: R[j, k] ∈ S} is minimized and the length of each segment from S is at least L; in other words, the problem is to compute max{R[j, k]: R[j, k] ∈ S}, min S∈SL (1) where SL is the set of all segmentations in which all segments have length at least L. The minimum founder set problem and the minimum segmentation problem are, in a sense, equivalent: any segmentation S with segments of length at least L induces in an obvious way a founder set of size max{R[j, k]: R[j, k] ∈ S} and a parse in which all crossover points are located at segment boundaries (and, hence, at distance at least L from each other); conversely, if F is a founder set of R and {j1, . . . , jp} is the sorted set of all crossover points in a parse of R such that jq − jq−1 ≥ L for q ∈ [2, p], then S = {R[jq−1, jq−1]: q ∈ [2, p]} is a segmentation of R with segments of length at least L and max{R[j, k]: R[j, k] ∈ S} ≤ F. Our main result is an algorithm that solves the minimum segmentation problem in the optimal O(mn) time. The solution normally does not uniquely define a founder set of R: for in- stance, if the built segmentation of R = {baaaa, baaab, babab} is S = {R[1, 1],R[2, 3],R[4, 5]}, then the possible founder sets induced by S are F1 = {baaab, babaa} and F2 = {baaaa, babab}. In other words, to construct a founder set, one concatenates fragments of recombinants corresponding to the found segments in a certain order. One can use heuristics aiming to minimize the number of crossover points in founder set constructed in such a way [19]. Our techniques extend to implementing such heuristics fast, but we leave the details for later and focus here on the segmentation problem. Hereafter, we assume that the input alphabet Σ is the set [0..Σ−1] of size O(m), which is a natural assumption considering that the typical alphabet size is 4 in our problem. It is sometimes convenient to view the set R = {R1, . . . , Rm} as a matrix with m rows and n columns. We say that an algorithm processing the recombinants R is streaming if it reads the input from left to right "columnwise", for each k from 1 to n, and outputs an answer for each set of recombinants {R1[1, k], . . . , Rm[1, k]} immediately after reading the "column" {R1[k], . . . , Rm[k]}. The main result of the paper is the following theorem. (cid:73) Theorem 1. Given a bound L and recombinants R = {R1, . . . , Rm}, each having length n, there is an algorithm that computes (1) in a streaming fashion in the optimal O(mn) time and O(m + L) space; using an additional array of length n, one can also find in O(n) time a segmentation on which (1) is attained, thus solving the minimum segmentation problem. 23:4 Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time 3 Minimum Segmentation Problem Given a bound L and a set of recombinants R = {R1, . . . , Rm} each of which has length n, Ukkonen [19] proposed a dynamic programming algorithm that solves the minimum segment- ation problem in O(mn2) time based on the following recurrence relation: max{M(j),R[j + 1, k]} if k < L, if L ≤ k < 2L, if k ≥ 2L. (2)  +∞ R[1, k] min 0≤j≤k−L M(k) = It is obvious that M(n) is equal to the solution (1); the segmentation itself can be recon- structed by "backtracking" in a standard way (see [19]). We build on the same approach. For a given k ∈ [1, n], denote by jk,1, . . . , jk,rk the sequence of all positions j ∈ [1, k − L] in which the value of R[j, k] changes, i.e., 1 ≤ jk,1 < ··· < jk,rk ≤ k − L and R[jk,h, k] 6= R[jk,h+1, k] for h ∈ [1, rk]. We complement this sequence with jk,0 = 0 and jk,rk+1 = k−L+ 1, so that jk,0, . . . , jk,rk+1 can be interpreted as a splitting of the range [0, k−L] into segments in which the value R[j + 1, k] stays the same: namely, for h ∈ [0, rk], one has R[j + 1, k] = R[jk,h+1, k] provided jk,h ≤ j < jk,h+1. Hence, max{M(j),R[j + 1, k]} = max{R[jk,h+1, k], M(j)} and, therefore, (2) can be rewritten as follows: jk,h≤j<jk,h+1 min min jk,h≤j<jk,h+1  +∞ R[1, k] min 0≤h≤rk M(k) = max{R[jk,h+1, k], if k < L, if L ≤ k < 2L, if k ≥ 2L. (3) min jk,h≤j<jk,h+1 M(j)} Our crucial observation is that, for k ∈ [1, n] and j ∈ [1, k], one has R[j + 1, k] ≤ R[j, k] ≤ m. Therefore, m ≥ R[jk,1, k] > ··· > R[jk,rk+1, k] ≥ 1 and rk < m. Hence, M(k) can be computed in O(m) time using (3), provided one has the following components: (i) the numbers R[jk,h+1, k], for h ∈ [0, rk]; (ii) the values min{M(j): jk,h ≤ j < jk,h+1}, for h ∈ [0, rk]. In the remaining part of the section, we describe a streaming algorithm that reads the strings {R1, . . . , Rm} "columnwise" from left to right and computes the components (i) and (ii) immediately after reading each "column" {R1[k], . . . , Rm[k]}, for k ∈ [1, n], and all in O(mn) total time and O(m + L) space. To reconstruct a segmentation corresponding to the found solution M(n), we build along with the values M(k) an array of size n whose kth element, for each k ∈ [1, n], stores 0 if M(k) = R[1, k], and stores a number j ∈ [1, k−L] such that M(k) = max{M(j),R[j+1, k]} otherwise; then, the segmentation can be reconstructed from the array in an obvious way in O(n) time. In order to maintain the array, our algorithm computes, for each k ∈ [1, n], along with the values min{M(j): jk,h ≤ j < jk,h+1}, for h ∈ [0, rk], positions j on which these minima are attained (see below). Further details are straightforward and, thence, omitted. 3.1 Positional Burrows -- Wheeler Transform Let us fix k ∈ [1, n]. Throughout this subsection, the string Ri[k]Ri[k − 1]··· Ri[1], which i,k, for i ∈ [1, m]. Given a set of recombinants is the reversal of Ri[1, k], is denoted by R0 R = {R1, . . . , Rm} each of which has length n, a positional Burrows -- Wheeler transform (pBWT), as defined by Durbin [3], is a pair of integer arrays ak[1, m] and dk[1, m] such that: 1. ak[1, m] is a permutation of [1, m] such that R0 ak[m],k lexicographically; ak[1],k ≤ ··· ≤ R0 T. Norri, B. Cazaux, D. Kosolobov, V. Mäkinen 23:5 2. dk[i], for i ∈ [1, m], is an integer such that Rak[i][dk[i]..k] is the longest common suffix of Rak[i][1, k] and Rak[i−1][1, k], and dk[i] = k + 1 if either this suffix is empty or i = 1. (cid:73) Example 2. Consider the following example, where m = 6, k = 7, and Σ = {a, c, t}. It is easy to see that the pBWT implicitly encodes the trie depicted in the right part of Figure 1, and such interpretation drives the intuition behind this structure. R1 = tttccat R2 = accatta R3 = actacct R4 = actccat R5 = cttacct R6 = atcacat i ak[i] dk[i] i R[i, k] 1 2 8 1 6 2 6 8 2 6 3 4 5 3 4 4 1 3 4 4 5 3 7 5 3 6 5 3 6 3 7 2 ak[1] = 2 ak[2] = 6 ak[3] = 4 ak[4] = 1 ak[5] = 3 ak[6] = 5 a c a t a c t t a c c t c a t c a t a c a t c t t a c c Figure 1 The pBWT for a set of recombinants R = {R1, . . . , R6} and some additional information. Durbin [3] showed that ak and dk can be computed from ak−1 and dk−1 in O(m) time on the binary alphabet. Mäkinen and Norri [11] further generalized the construction for integer alphabets of size O(m), as in our case. For the sake of completeness, we describe in this subsection the solution from [11] (see Figure 2a), which serves then as a basis for our main algorithm. We also present a modification of this solution (see Figure 2b), which, albeit seems to be slightly inferior in theory (we could prove only O(m log Σ) time upper bound), showed better performance in practice and thus, as we believe, is interesting by itself. zero initialize C[0,Σ] and P [0,Σ − 1] for i ← 1 to m do C[Ri[k] + 1] ← C[Ri[k] + 1] + 1; for i ← 1 to Σ− 1 do C[i] ← C[i] + C[i− 1]; for i ← 1 to m do b ← Rak−1[i][k]; C[b] ← C[b] + 1; ak[C[b]] ← ak−1[i]; if P [b] = 0 then dk[C[b]] ← k + 1; else dk[C[b]] ← max{dk−1[']: P [b]<'≤i}; P [b] ← i; zero initialize C[0,Σ] and P [0,Σ − 1] for i ← 1 to m do C[Ri[k] + 1] ← C[Ri[k] + 1] + 1; for i ← 1 to Σ − 1 do C[i] ← C[i] + C[i − 1]; for i ← 1 to m do b ← Rak−1[i][k]; C[b] ← C[b] + 1; ak[C[b]] ← ak−1[i]; ak−1[i] ← i + 1; if P [b] = 0 then dk[C[b]] ← k + 1; else dk[C[b]] ← maxd(P [b] + 1, i); P [b] ← i; . erase ak−1[i] function maxd(j, i) if j 6= i then dk−1[j]← max{dk−1[j], maxd(ak−1[j], i)}; ak−1[j] ← i + 1; (a) The basic pBWT algorithm computing ak and dk from ak−1 and dk−1. (b) The algorithm with simple RMQ; ak−1 and dk−1 are used as auxiliary arrays (and corrupted). Figure 2 The computation of ak and dk from ak−1 and dk−1 in the pBWT. return dk−1[j]; Given ak−1 and dk−1, we are to show that the algorithm from Figure 2a correctly j,k iff either Ri[k] < Rj[k], j,k−1 lexicographically, it is easy to see that the array ak can ak−1[i],k−1)}m i=1. computes ak and dk. Since, for any i, j ∈ [1, m], we have R0 or Ri[k] = Rj[k] and R0 be deduced from ak−1 by radix sorting the sequence of pairs {(Rak−1[i][k], R0 i,k−1 ≤ R0 i,k ≤ R0 23:6 Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time Further, since, by definition of ak−1, the second components of the pairs are already in a sorted order, it remains to sort the first components by the counting sort. Accordingly, in Figure 2a, the first loop counts occurrences of letters in the sequence {Ri[k]}m i=1 using an auxiliary array C[0,Σ]; as is standard in the counting sort, the second loop modifies the array C so that, for each letter b ∈ [0,Σ−1], C[b] + 1 is the first index of the "bucket" that will contain all ak−1[i] such that Rak−1[i][k] = b; finally, the third loop fills the buckets incrementing the indices C[b] ← C[b] + 1, for b = Rak−1[i][k], and performing the assignments ak[C[b]] ← ak−1[i], for i = 1, . . . , m. Thus, the array ak is computed correctly. All is done in O(m + Σ) time, which is O(m) since the input alphabet is [0,Σ−1] and Σ = O(m). The last three lines of the algorithm are responsible for computing dk. Denote the length of the longest common prefix of any strings s1 and s2 by LCP(s1, s2). The computation of dk relies on the following well-known fact: given a sequence of strings s1, . . . , sr such that s1 ≤ ··· ≤ sr lexicographically, one has LCP(s1, sr) = min{LCP(si−1, si): 1 < i ≤ r}. Suppose that the last loop of the algorithm, which iterates through all i from 1 to m, assigns ak[i0] ← ak−1[i], for a given i ∈ [1, m] and some i0 = C[b]. Let j be the maximum integer such that j < i and Rak−1[j][k] = Rak−1[i][k] (if any). The definition of ak implies that ak[i0−1] = ak−1[j] if such j ak−1['],k−1): j<'≤i} exists. Hence, LCP(R0 if such number j does exist, and LCP(R0 ak[i0],k) = 0 otherwise. Therefore, since dk[i0] equals k+1−LCP(R0 ak[i0−1],k), we have either dk[i0] = max{dk−1[']: j < ' ≤ i} or dk[i0] = k + 1 according to whether the required j exists. To find j, we simply maintain an auxiliary array P[0..Σ−1] such that on the ith loop iteration, for any letter b ∈ [0,Σ−1], P[b] stores the position of the last seen b in the sequence Rak−1[1][k], Rak−1[2][k], . . . , Rak−1[i−1][k], or P[b] = 0 if b occurs for the first time. Thus, dk is indeed computed correctly. In order to calculate the maximums max{dk−1[']: P[b] ≤ ' ≤ i} in O(1) time, we build a range maximum query (RMQ) data structure on the array dk−1[1, m] in O(m) time (e.g., see [6]). Thus, the running time of the algorithm from Figure 2a is, evidently, O(m). (cid:73) Lemma 3. The arrays ak and dk can be computed from ak−1 and dk−1 in O(m) time. ak[i0],k) = 1 + min{LCP(R0 ak−1['−1],k−1, R0 ak[i0−1],k, R0 ak[i0],k, R0 ak[i0−1],k, R0 In practice the bottleneck of the algorithm is the RMQ data structure, which, although answers queries in O(1) time, has a sensible constant under the big-O in the construction time. We could naively compute the maximums by scanning the ranges dk−1[P[b]+1, i] from left to right but such algorithm works in quadratic time since same ranges of dk−1 might be processed many times in the worst case. Our key idea is to store the work done by a simple scanning algorithm to reused it in future queries. We store this information right in the arrays ak−1 and dk−1 rewriting them; in particular, since ak−1 is accessed sequentially from left to right in the last loop, the range ak−1[1, i] is free to use after the ith iteration. More precisely, after the ith iteration of the last loop, the subarrays ak−1[1, i] and dk−1[1, i] are modified so that the following invariant holds: for any j ∈ [1, i], j < ak−1[j] ≤ i + 1 and dk−1[j] = max{d0 k−1 denotes the original array dk−1 before modifications; note that the invariant holds if one simply puts ak−1[j] = j + 1 without altering dk−1[j]. Then, to compute max{d0 k−1[']: j ≤ ' ≤ i}, we do not have to scan all elements but can "jump" through the chain j, ak−1[j], ak−1[ak−1[j]], . . . , i and use maximums precomputed in dk−1[j], dk−1[ak−1[j]], dk−1[ak−1[ak−1[j]]], . . . , dk−1[i]; after this, we redirect the "jump pointers" in ak−1 to i + 1 and update the maximums in dk−1 accordingly. This idea is implemented in Figure 2b. Notice the new line ak−1[i] ← i + 1 in the main loop (it is commented), which erases ak−1[i] and makes it a part of the "jump table". The correctness of the algorithm is clear. But it is not immediate even that the algorithm works in O(m log m) time. We prove the upper bound O(m log Σ) on the running time, which is a quite strong guarantee considering that in our problem the alphabet often is very small. k−1[']: j ≤ ' < ak−1[j]}, where d0 T. Norri, B. Cazaux, D. Kosolobov, V. Mäkinen 23:7 (cid:73) Lemma 4. The algorithm from Figure 2b computes the arrays ak and dk from ak−1 and dk−1 in O(m log Σ) time. Proof. Fix i ∈ [1, m]. The ith iteration of the last loop in the algorithm computes the maximum in a range d0 k−1 is the original array dk−1 before modifications and i0 = P[b] + 1 for some b and P. Let 'i = i − i0. Denote ' = 1 i=1 'i, the "average query length". We are to prove that the running time of the algorithm is O(m log '), which i=1 'i ≤ σm. implies the result since m' =Pm i=1 'i and, obviously,Pm k−1[i0, i], where d0 We say that a position j is touched if the function maxd is called with its first argument equal to j. Clearly, it suffices to prove that the total number of touches is O(m log '). While processing the query maxd(i−'i, i), we may have touched many positions. Denote the sequence of all such position, for the given i, by i1, . . . , ir; in other words, at the time of the query maxd(i−'i, i), we have i1 = i − 'i, ij = ak−1[ij−1] for j ∈ [2, r], and ir = i. Obviously, i1 < ··· < ir. We say that, for j ∈ [1, r−1], the touch of ij in the query maxd(i−'i, i) is scaling if there exists an integer r such that i − ij > 2r and i − ij+1 ≤ 2r (see Figure 3). We count separately the total number of scaling and non-scaling touches in all i. Pm m i1 i2 i3 i4 i5 i6 i7 i8 'i i−2r i−2r−1 i−2r−2. . . i9 i10 Figure 3 RMQ query on a range [i − 'i, i]; scaling touches are red. P =Pm j=1 For position j, denote by p(j) the number of non-scaling touches of j. We are to prove that j=1 p(j) ≤ 2m log '. Let qh(j) denote the value of ak−1[j] − j in the hth non-scaling touch of j, for h ∈ [1, p(j)]. Suppose that this hth touch happens during the processing of a query maxd(i−'i, i). By the definition, j+qh(j) follows j in the sequence of touched positions. Since the touch of j is non-scaling, we have i−j > j+qh(j) > 2r, where r is the largest integer such that i − j > 2r, and hence, qh(j) < 2r. Since maxd(i − 'i, i) assigns ak−1[j] ← i + 1, we have ak−1[j]− j > i− j > 2r after the query. In other words, we had ak−1[j]− j = qh(j) < 2r before the query and have ak−1[j]− j > 2r after. This immediately implies that qh(j) ≥ 2h−1, for h ∈ [1, p(j)], and, therefore, every position can be touched in the non-scaling way at most O(log m) times, implying P = O(m log m). But we can deduce a stronger bound. Since the sum of all values j − ak−1[j] for all positions j touched in a query maxd(i − 'i, i) is equal i=1 'i = m'. On the other hand, we have j=1 2p(j) − m. The well-known property of the j=1 2p(j) is minimized whenever all p(j) are j=1 2P/m. Hence, once P > 2m log ', we obtain j=1 2P/m − m > m'2 − m, which is larger than m' for ' ≥ 2 (the case j=1 It remains to consider scaling touches. The definition implies that each query maxd(i−'i, i) i=1 log 'i. Since i=1 log 'i is maximized whenever all 'i are equal and (cid:74) h=1 qh(j) ≤ Pm to 'i, it is obvious that Pm Pp(j) Pm h=1 2h−1 =Pm Pp(j) h=1 qh(j) ≥Pm Pp(j) convexity of the exponent is that the sum Pm equal and maximal, i.e., Pm j=1 2p(j) ≥ Pm Pm Pp(j) h=1 qh(j) ≥Pm Pp(j) ' < 2 is trivial), contradictingPm h=1 qh(j) ≤ m'. Thus, P =Pm performs at most log 'i scaling touches. Thus, it suffices to upperboundPm the function log is concave, the sumPm i=1 log 'i ≤Pm maximal, i.e.,Pm Pm j=1 'j) = m log ', hence the result follows. i=1 log( 1 3.2 Modification of the pBWT We are to modify the basic pBWT construction algorithm in order to compute the sequence jk,1, . . . , jk,rk of all positions j ∈ [1, k − L] in which R[j, k] 6= R[j + 1, k], and to calculate j=1 p(j) ≤ 2m log '. j=1 j=1 j=1 m 23:8 Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time the numbers R[jk,h+1, k] and min{M(j): jk,h ≤ j < jk,h+1}, for h ∈ [0, rk] (assuming jk,0 = 0 and jk,rk+1 = k − L + 1); see the beginning of the section. As it follows from (3), these numbers are sufficient to calculate M(k), as defined in (2) and (3), in O(m) time. The following lemma reveals relations between the sequence jk,1, . . . , jk,rk and the array dk. (cid:73) Lemma 5. Consider recombinants R = {R1, . . . , Rm}, each having length n. For k ∈ [1, n] and j ∈ [1, k − 1], one has R[j, k] 6= R[j + 1, k] iff j = dk[i] − 1 for some i ∈ [1, m]. Proof. Suppose that R[j, k] 6= R[j + 1, k]. It is easy to see that R[j, k] > R[j + 1, k], which implies that there are two indices h and h0 such that Rh[j + 1, k] = Rh0[j + 1, k] and Rh[j] 6= Rh0[j]. Denote by a−1 k [h] the number x such that ak[x] = h. Without loss of k [h0]. Then, there exists i ∈ [a−1 k [h] < a−1 generality, assume that a−1 k [h0]] such that Rak[i−1][j + 1, k] = Rak[i][j + 1, k] and Rak[i−1][j] 6= Rak[i][j]. Hence, dk[i] = j + 1. Suppose now that j ∈ [1, k − 1] and j = dk[i] − 1, for some i ∈ [1, m]. Since j < k and dk[1] = k + 1, we have i > 1. Then, by definition of dk, Rak[i−1][j + 1, k] = Rak[i][j + 1, k] and Rak[i−1][j] 6= Rak[i][j], i.e., Rak[i][j + 1, k] can be "extended" to the left in two different ways, thus producing two distinct strings in the set R[j, k]. Therefore, R[j, k] > R[j + 1, k]. (cid:74) Denote by r the number of distinct integers in the array dk. Clearly, r may vary from 1 to m. For integer ', define M0(') = M(') if 1 ≤ ' ≤ k − L, and M0(') = +∞ otherwise. Our modified algorithm does not store dk but stores the following four arrays (but we still often refer to dk for the sake of analysis): k [h] + 1, a−1 sk[1, r] contains all distinct elements from dk[1, m] in the increasing sorted order; ek[1, m]: for j ∈ [1, r], ek[j] is equal to the unique index such that sk[ek[j]] = dk[j]; tk[1, r]: for j ∈ [1, r], tk[j] is equal to the number of times sk[j] occurs in dk[1, m]; uk[1, r]: for j ∈ [1, r], uk[j] = min{M0('): sk[j−1]−1 ≤ ' < sk[j]−1}, assuming sk[0] = 1. (cid:73) Example 6. In Example 2, where m = 6, k = 7, and Σ = {a, c, t}, we have r = 4, sk = [3, 5, 7, 8], tk = [2, 1, 1, 2], ek = [4, 4, 2, 1, 3, 1]. Further, suppose that L = 3, so that k − L = 4. Then, uk[1] = M(1), uk[2] = min{M(2), M(3)}, uk[3] = min{M(4), M0(5)} = M(4) since M0(5) = +∞, and uk[4] = M0(6) = +∞. By the definition of dk, we have dk[1] = k + 1 and, hence, the last element of sk, sk[sk], must be equal to k + 1. Assume that sk[0] = 1. Then, the array sk defines a splitting of the range [0, k − 1] into the disjoint segments [sk[j − 1] − 1, sk[j] − 2], for j ∈ [1,sk]. Note that only the first segment might be empty and only if sk[1] = 1. Recall that 0 = jk,0 < jk,1 < ··· jk,rk < jk,rk+1 = k − L + 1. It follows from Lemma 5 that the first rk non-empty segments [sk[j − 1] − 1, sk[j] − 2] correspond to the segments [jk,h−1, jk,h − 1], for h ∈ [1, rk], and the (rk + 1)st non-empty segment [sk[j − 1] − 1, sk[j] − 2] covers the point k− L, so that [jk,rk , jk,rk+1 −1] is a prefix of this segment. It is clear that uk[j] 6= +∞ only if the segment [sk[j − 1]− 1, sk[j]− 2] intersects the range [1, k − L] and, thus, corresponds to a segment [jk,h−1, jk,h−1], for h ∈ [1, rk +1], in the above sense. Therefore, since M0(') = +∞ for ' < 1 and ' > k − L and, thus, such values M0(') do not affect, in a sense, the minima stored in uk, one can rewrite (3) as follows:  M(k) = +∞ R[1, k] min 1≤j≤uk max{R[sk[j] − 1, k], uk[j]} if k < L, if L ≤ k < 2L, if k ≥ 2L. (4) It remains to compute the numbers R[sk[j] − 1, k], for j ∈ [1,sk]. T. Norri, B. Cazaux, D. Kosolobov, V. Mäkinen 23:9 (cid:73) Lemma 7. Consider a set of recombinants R = {R1, . . . , Rm}, each of which has length n. For k ∈ [1, n] and j ∈ [1,sk], one has R[sk[j] − 1, k] = tk[j] + tk[j + 1] + ··· + tk[tk]. Proof. Denote ' = k−sk[j]+1, so that R[sk[j]−1, k] = R[k−', k]. Suppose that ' = 0. Note that Rak[1][k] ≤ ··· ≤ Rak[m][k]. Since dk[i] = k + 1 iff either i = 1 or Rak[i−1][k] 6= Rak[i][k], it is easy to see that R[k, k], the number of distinct letters Ri[k], is equal to the number of time k + 1 = sk[sk] occurs in dk, i.e., tk[tk]. Suppose that ' > 0. It suffices to show that R[k − ', k] − R[k − ' + 1, k] = tk[j]. For i ∈ [1, m], denote by R0 i the string Ri[k]Ri[k − 1]··· Ri[k − ']. Fix w ∈ R[k − ' + 1, k]. Since ak[1] ≤ ··· ≤ R0 ak[m] lexicographically, there are numbers h and h0 such that Rak[i][k − ' + R0 1, k] = w iff i ∈ [h, h0]. Further, we have Rak[h][k − '] ≤ Rak[h+1][k − '] ≤ ··· ≤ Rak[h0][k − ']. Thus, by definition of dk, for i ∈ [h + 1, h0], we have Rak[i−1][k − '] 6= Rak[i][k − '] iff dk[i] = k − ' + 1 = sk[j]. Note that dk[h] > sk[j]. Therefore, the number of strings Ri[k − ', k] from R[k − ', k] having suffix w is equal to one plus the number of integers sk[j] in the range dk[h, h0], which implies R[k − ', k] − R[k − ' + 1, k] = tk[j]. (cid:74) In particular, it follows from Lemmas 5 and 7 that R[1, k] = tk[1] + ··· + tk[tk]. Thus, by (4), one can simply calculate M(k) in O(m) time using the arrays tk and uk. The arrays ek, sk, tk, uk along with ak are computed from ek−1, sk−1, tk−1, uk−1, ak−1 by Algorithm 1. Let us analyze this algorithm. Algorithm 1 The algorithm computing ek, sk, tk, uk, ak. 1: copy sk−1 into sk and add the element k + 1 to the end of sk, thus incrementing sk; 2: copy uk−1 into uk and add the element M0(k − 1) to the end of uk, thus incrementing uk; 3: zero initialize C[0,Σ], P [0,Σ − 1], and tk[1,sk]; 4: for i ← 1 to m do C[Ri[k] + 1] ← C[Ri[k] + 1] + 1; 5: for i ← 1 to Σ − 1 do C[i] ← C[i] + C[i − 1]; 6: for i ← 1 to m do b ← Rak−1[i][k]; 7: C[b] ← C[b] + 1; 8: ak[C[b]] ← ak−1[i]; 9: if P [b] = 0 then ek[C[b]] ← sk; 10: else ek[C[b]] ← max{ek−1[']: P [b] < ' ≤ i} 11: P [b] ← i; 12: 13: for i ← 1 to m do tk[ek[i]] ← tk[ek[i]] + 1; 14: j ← 1; 15: add a new "dummy" element +∞ to the end of uk and uk−1; 16: for i ← 1 to sk do uk[j] ← min{uk[j], uk−1[i]}; 17: if tk[i] 6= 0 then 18: tmp[i] ← j; 19: sk[j] ← sk[i], tk[j] ← tk[i], uk[j + 1] ← uk−1[i + 1]; 20: if sk[j]−1 > k−L and (j = 1 or sk[j−1]−1 ≤ k−L) then uk[j] ← min{uk[j], M(k−L)}; 21: j ← j + 1; 22: 23: shrink sk, tk, and uk to j − 1 elements, so that sk = tk = uk = j − 1; 24: for i ← 1 to m do ek[i] ← tmp[ek[i]]; By definition, dk−1[i] = sk−1[ek−1[i]] for i ∈ [1, m]. The first line of the algorithm initializes sk so that dk−1[i] = sk[ek−1[i]], for i ∈ [1, m], and sk[sk] = k + 1. Since after this initialization sk, obviously, is in the sorted order, one has, for i, j ∈ [1, m], ek−1[i] ≤ ek−1[j] iff dk−1[i] ≤ dk−1[j] and, therefore, for ' ∈ [i, j], one has dk−1['] = max{dk−1['0]: i ≤ '0 ≤ j} 23:10 Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time iff ek−1['] = max{ek−1['0]: i ≤ '0 ≤ j}. Based on this observation, we fill ek in lines 3 -- 12 so that dk[i] = sk[ek[i]], for i ∈ [1, m], using exactly the same algorithm as in Figure 2a, where dk is computed, but instead of the assignment dk[C[b]] ← k + 1, we have ek[C[b]] ← sk since sk[sk] = k + 1. Here we also compute ak in the same way as in Figure 2a. The loop in line 13 fills tk so that, for i ∈ [1,sk], tk[i] is the number of occurrences of the integer i in ek (tk was zero initialized in line 3). Since, for i ∈ [1, m], we have dk[i] = sk[ek[i]] at this point, tk[i] is also the number of occurrences of the integer sk[i] in dk[1, m]. By definition, sk must contain only elements from dk, but this is not necessarily the case in line 14. In order to fix sk and tk, we simply have to remove all elements sk[i] for which tk[i] = 0, moving all remaining elements of sk and non-zero elements of tk to the left accordingly. Suppose that, for some h and i, we have ek[h] = i and the number sk[i] is moved to sk[j], for some j < i, as we fix sk. Then, ek[h] must become j. We utilize an additional temporary array tmp[1,sk] to fix ek. The loop in lines 16 -- 22 fixes sk and tk in an obvious way; once sk[i] is moved to sk[j] during this process, we assign tmp[i] = j. Then, sk, tk, uk (uk is discussed below) are resized in line 23, and the loop in line 24 fixes ek using tmp. Recall that [sk[j − 1] − 1, sk[j] − 2], for j ∈ [1,sk], is a system of disjoint segments covering [0, k−1] (assuming sk[0] = 1). It is now easy to see that this system is obtained from the system [sk−1[j −1]−1, sk−1[j]−2], with j ∈ [1,sk−1] (assuming sk−1[0] = 1), by adding the new segment [k − 1, k − 1] and joining some segments together. The second line of the algorithm copies uk−1 into uk and adds M0(k−1) to the end of uk, so that, for j ∈ [1,uk−1], uk[j] is equal to the minimum of M0(') for all ' from the segment [sk−1[j − 1]− 1, sk−1[j]− 2] and uk[uk−1+1] = M0(k − 1) is the minimum in the segment [k − 1, k − 1]. (This is not completely correct since M0 has changed as k was increased; namely, M0(k − L) was equal to +∞ but now is equal to M(k − L).) As we join segments removing some elements from sk in the loop 16 -- 22, the array uk must be fixed accordingly: if [sk[j−1]−1, sk[j]−2] is obtained by joining [sk−1[h−1]−1, sk−1[h]−2], for j0 ≤ h ≤ j00, then uk[j] = min{uk−1[h]: j0 ≤ h ≤ j00}. We perform such fixes in line 17, accumulating the latter minimum. We start accumulating a new minimum in line 20, assigning uk[j + 1] ← uk−1[i + 1]. If at this point the ready minimum accumulated in uk[j] corresponds to a segment containing the position k − L, we have to fix uk taking into account the new value M0(k − L) = M(k − L); we do this in line 21. To avoid accessing out of range elements in uk and uk−1 in line 20, we add a "dummy" element in, respectively, uk and uk−1 in line 15. Besides all the arrays of length m, the algorithm also requires access to M(k − L) and, possibly, to M(k − 1). During the computation of M(k) for k ∈ [1, n], we maintain the last L calculated numbers M(k − 1), M(k − 2), . . . , M(k − L) in a circular array, so that the overall required space is O(m + L); when k is incremented, the array is modified in O(1) time in an obvious way. Thus, we have proved the following result, implying Theorem 1. (cid:73) Lemma 8. The arrays ak, ek, sk, tk, uk can be computed from ak−1, ek−1, sk−1, tk−1, uk−1 and from the numbers M(k − L) and M(k − 1) in O(m) time. If, as in our case, one does not need sk, tk, uk for all k, the arrays sk, tk, uk can be modified in-place, i.e., sk, tk, uk can be considered as aliases for sk−1, tk−1, uk−1, and yet the algorithm remains correct. Thus, we really need only 7 arrays in total: ak, ak−1, ek, ek−1, s, t, u, where s, t, u serve as sk, tk, uk and the array tmp can be organized in place of ak−1 or ek−1. It is easy to maintain along with each value uk[j] a corresponding position ' such that uk[j] = M0('); these positions can be used then to restore the found segmentation of R using backtracking (see the beginning of the section). To compute ek, instead of using an RMQ data structure, one can adapt in an obvious way the algorithm from Figure 2b rewriting the arrays ak−1 and ek−1 during the computation, which is faster in practice but T. Norri, B. Cazaux, D. Kosolobov, V. Mäkinen 23:11 theoretically takes O(m log σ) time by Lemma 4. We do not discuss further details as they are straightforward. References 1 Computational Pan-Genomics Consortium et al. Computational pan-genomics: status, promises and challenges. Briefings in Bioinformatics, page bbw089, 2016. 2 Alexander Dilthey, Charles Cox, Zamin Iqbal, Matthew R Nelson, and Gil McVean. Im- proved genome inference in the mhc using a population reference graph. Nature Genetics, 47:682 -- 688, 2015. 3 Richard Durbin. Efficient haplotype matching and storage using the positional burrows- wheeler transform (PBWT). Bioinformatics, 30(9):1266 -- 1272, 2014. Exome Aggregation Consortium. Analysis of protein-coding genetic variation in 60,706 humans. Nature, 536(7616):285 -- 291, August 2016. 5 Héctor Ferrada, Travis Gagie, Tommi Hirvola, and Simon J. Puglisi. Hybrid indexes for repetitive datasets. Philosophical Transactions of the Royal Society A, 372, 2014. Johannes Fischer and Volker Heun. Theoretical and practical improvements on the RMQ- problem, with applications to LCA and LCE. In CPM 2006, volume 4009 of LNCS, pages 36 -- 48. Springer, 2006. doi:10.1007/11780441_5. 7 Travis Gagie and Simon J. Puglisi. Searching and indexing genomic databases via kernel- ization. Frontiers in Bioengineering and Biotechnology, 3(12), 2015. L. Huang, V. Popic, and S. Batzoglou. Short read alignment with populations of genomes. Bioinformatics, 29(13):361 -- 370, 2013. Sorina Maciuca, Carlos del Ojo Elias, Gil McVean, and Zamin Iqbal. A natural encoding of genetic variation in a burrows-wheeler transform to enable mapping and genome inference. In Algorithms in Bioinformatics - 16th International Workshop, WABI 2016, Aarhus, Den- mark, August 22-24, 2016. Proceedings, volume 9838 of Lecture Notes in Computer Science, pages 222 -- 233. Springer, 2016. 4 6 8 9 10 V. Mäkinen, G. Navarro, J. Sirén, and N. Välimäki. Storage and retrieval of highly repet- itive sequence collections. Journal of Computational Biology, 17(3):281 -- 308, 2010. 11 Veli Mäkinen and Tuukka Norri. Applying the positional Burrows -- Wheeler transform to all-pairs hamming distance. Submitted manuscript, 2018. 12 G. Navarro. Indexing highly repetitive collections. In Proc. 23rd International Workshop on Combinatorial Algorithms (IWOCA), LNCS 7643, pages 274 -- 279, 2012. 13 Tuukka Norri and Bastien Cazaux and Dmitry Kosolobov and Veli Mäkinen. Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time. In Algorithms in Bioinformatics, 18th International Workshop, WABI 2018, Helsinki, Finland, August 20 -- 22, 2018, LIPIcs, volume 113, pages 15:1 -- 15:15, 2018. doi:10.4230/LIPIcs.WABI.2018. 15. Pasi Rastas and Esko Ukkonen. Haplotype inference via hierarchical genotype parsing. In Algorithms in Bioinformatics, 7th International Workshop, WABI 2007, Philadelphia, PA, USA, September 8-9, 2007, Proceedings, pages 85 -- 97, 2007. 14 15 Korbinian Schneeberger, Jörg Hagmann, Stephan Ossowski, Norman Warthmann, Sandra Gesing, Oliver Kohlbacher, and Detlef Weigel. Simultaneous alignment of short reads against multiple genomes. Genome Biology, 10:R98, 2009. J. Sirén, N. Välimäki, and V. Mäkinen. Indexing graphs for path queries with applications in genome research. IEEE/ACM Transactions on Computational Biology and Bioinformatics, 11(2):375 -- 388, 2014. 16 17 The 1000 Genomes Project Consortium. A global reference for human genetic variation. Nature, 526(7571):68 -- 74, September 2015. 23:12 Minimum Segmentation for Pan-genomic Founder Reconstruction in Linear Time 18 The UK10K Consortium. The UK10K project identifies rare variants in health and disease. 19 Nature, 526(7571):82 -- 90, September 2015. Esko Ukkonen. Finding founder sequences from a set of recombinants. In Algorithms in Bioinformatics, Second International Workshop, WABI 2002, Rome, Italy, September 17-21, 2002, Proceedings, pages 277 -- 286, 2002. 20 Daniel Valenzuela, Tuukka Norri, Välimäki Niko, Esa Pitkänen, and Veli Mäkinen. Towards In Selected articles from the pan-genome read alignment to improve variation calling. Sixteenth Asia Pacific Bioinformatics Conference (APBC 2018), 2018. In press, preliminary version in https://doi.org/10.1101/021444. 21 VGTeam. vg. https://github.com/vgteam/vg, 2018. 22 Sebastian Wandelt, Johannes Starlinger, Marc Bux, and Ulf Leser. Rcsi: Scalable similarity search in thousand(s) of genomes. PVLDB, 6(13):1534 -- 1545, 2013.
1108.1751
1
1108
2011-08-08T17:07:06
Efficient Sum-Based Hierarchical Smoothing Under \ell_1-Norm
[ "cs.DS" ]
We introduce a new regression problem which we call the Sum-Based Hierarchical Smoothing problem. Given a directed acyclic graph and a non-negative value, called target value, for each vertex in the graph, we wish to find non-negative values for the vertices satisfying a certain constraint while minimizing the distance of these assigned values and the target values in the lp-norm. The constraint is that the value assigned to each vertex should be no less than the sum of the values assigned to its children. We motivate this problem with applications in information retrieval and web mining. While our problem can be solved in polynomial time using linear programming, given the input size in these applications such a solution might be too slow. We mainly study the \ell_1-norm case restricting the underlying graphs to rooted trees. For this case we provide an efficient algorithm, running in O(n^2) time. While the algorithm is purely combinatorial, its proof of correctness is an elegant use of linear programming duality. We believe that our approach may be applicable to similar problems, where comparable hierarchical constraints are involved, e.g. considering the average of the values assigned to the children of each vertex. While similar in flavor to other smoothing problems like Isotonic Regression (see for example [Angelov et al. SODA'06]), our problem is arguably richer and theoretically more challenging.
cs.DS
cs
Efficient Sum-Based Hierarchical Smoothing Under ℓ1-Norm Siavosh Benabbas∗ Hyun Chul Lee† Joel Oren∗‡ [email protected] [email protected] [email protected] Yuli Ye∗‡ [email protected] June 7, 2018 Abstract We introduce a new regression problem which we call the Sum-Based Hierarchical Smoothing problem. Given a directed acyclic graph and a non-negative value, called target value, for each vertex in the graph, we wish to find non-negative values for the vertices satisfying a certain constraint while minimizing the distance of these assigned values and the target values in the ℓp-norm. The constraint is that the value assigned to each vertex should be no less than the sum of the values assigned to its children. We motivate this problem with applications in information retrieval and web mining. While our problem can be solved in polynomial time using linear programming, given the input size in these applications such a solution is too slow. We mainly study the ℓ1-norm case restricting the underlying graphs to rooted trees. For this case we provide an efficient algorithm, running in O(n2) time. While the algorithm is purely combinatorial, its proof of correctness is an elegant use of linear programming duality. We also present a number of other positive and negatives results for different norms and certain other special cases. We believe that our approach may be applicable to similar problems, where comparable hierarchical constraints are involved, e.g. considering the average of the values assigned to the children of each vertex. While similar in flavour to other smoothing problems like Isotonic Regression (see for example [Angelov et al. SODA'06]), our problem is arguably richer and theoretically more challenging. 1 1 0 2 g u A 8 ] S D . s c [ 1 v 1 5 7 1 . 8 0 1 1 : v i X r a ∗Department of Computer Science, University of Toronto †Thoora Inc., Toronto, ON, Canada ‡This research was supported by the MITACS Accelerate program, Thoora Inc., and The University of Toronto, Department of Computer Science. 1 Introduction In several recent studies (e.g. The prevalence of popular web services like Amazon, Google, Netflix, and StumbleUpon has given rise to many interesting large-scale problems related to classification, recommendation, ranking, and collaborative filtering. [KFB09, PG08, CKP07]), researchers have incorporated the underlying class hierarchies of the data-sets into the setting of recommenda- tion systems. Moreover, Koren et al. [DKK11] recently demonstrated an application of hierarchical classifications of topics, i.e. taxonomies, in Collaborative Filtering settings, in particular, music rec- ommendation. In these application scenarios, the taxonomies are abstracted as trees. Associated with the vertices are scalar target values, typically inferred through the use of various machine learning or information retrieval methods. For instance, given a hierarchy of topics and a search query, the target values could be the relevance measures of the topics to the search query. When a taxonomy is used, one would usually like to enforce particular constraints on the value assigned to the vertices to properly represent the hierarchical relationship among them. Typically, the relevant machine learning approaches are ill-equipped to handle these requirements. Often, these constraints state that the value of each vertex should be at least some function of the value of its direct children in the taxonomy (e.g. [PG08, CKP07]). Going back to the previous example of topics and search query, imagine that the taxonomy contains the topics sports, baseball, football, and basketball with the first topic being the parent of the other three and that the search query is "ESPN". One would like to find the relevance of this query to every topic in the taxonomy. A reasonable requirement of these relevance values would be that the relevance of "ESPN" to sports would be no less than the sum of its relevance to baseball, football, and basketball. One way to solve this problem would be to directly impose such a constraint on the learning algorithm that infers the relevance values using regularization; i.e. adding an additional term in the objective function of that algorithm penalizing any violation of the constraint. However, this approach has two problems. First, it "softens" our requirements; i.e. it allows for possible violations, to some limited extend. Moreover, it can dramatically deteriorate the running time of the process of learning or restrict our choice of the learning algorithm. Instead, we take the following, widely used, two-step approach. Given a search query s, we first infer each of the relevance scores of each of the topics, disregarding the hierarchy constraints. Then, we smoothen the inferred relevance scores by modifying them so as to uphold the above sum constraint. We would want the change of the relevance scores in the second step to be as small as possible. As the relevance scores are scalar values, we can represent both the original and final relevance scores as two vectors with non-negative values, and measure their difference in a suitable norm (e.g. the ℓ1, ℓ2 or the ℓ∞ norms). The subject of this paper is how to perform the second step. We formulate this problem which we call the Sum-Based Hierarchical Smoothing problem (SBHSP) as follows. Given a rooted tree (or in general a directed acyclic graph) G = (V, E) and a vector of original vertex values (called target values) a = (av1, av2 , . . . , avn ) the objective is to find a vector of new vertex values (called assigned values) x = (xv1, xv2 , . . . , xvn) with the following properties. (i) for any node w with incoming edges (u1, w), . . . , (uk, w) we have xu1 +···+xuk ≤ xw. (ii) a − xp is minimized. Different values of p result in different variants of the problem. We mainly study the problem for p = 1 and p = ∞ but the case of p = 2 is also interesting. It is not hard to see that for p = 1 the problem can be solved in polynomial time using linear programming (see inequalties (3a)-(3d)) and for p > 1 it can be solved by using a suitable separation oracle and the Ellipsoid method. However given the typical size of taxonomies these solutions are too slow. 1 We note that this problem seems to be more complex than other previously considered similar problems as the assigned value of each vertex affects the possible values for any vertex it shares a parent with. In particular, to the best of our knowledge techniques used for similar problems are ineffective for it. Contributions: Our main contribution is a purely combinatorial algorithm when the input is a rooted tree and p = 1 (i.e. the ℓ1 norm) that runs in time O(n2). We note that the ℓ1 norm was previously used as a good measure of difference in similar regression problems (e.g. see [AHKW06]). As many hierarchical structures in practice are trees, our algorithm can be used in many practical applications. Our second contribution is a linear time algorithm for the case p = ∞ which works for any directed acyclic graph. We also show an efficient FPTAS for optimizing the ℓ1 norm for another class of DAGs (directed bilayer graphs.) Finally, we show that if one adds the extra condition that the assigned values should be integral the problem is hard to approximate (to within a polylogarithmic factor) for any ℓp norm for 1 ≤ p < ∞. Interestingly, given that our algorithm for the ℓ1 norm on trees always outputs an integral solution this last result suggests that new ideas are needed to extend it to general DAGs. Our algorithm for the ℓ1 case has a rather simple structure. We assign values to the vertices of the tree in a bottom-up manner. For each vertex we first assign a valid (but possibly suboptimal) value and then use paths going down from that vertex to "push the excess" down the tree and improve the objective value. While the algorithm is purely combinatorial, its proof of correctness is an elegent use of linear programming duality. In particular, we use the complementary slackness condition to show that if the algorithm can no longer push the excess of a node down the tree the values assigned to its subtree most be optimal. Organization: We present the relevant previous work in Section 2. In Section 3, we present a precise definition of the problem and some preliminaries. We present our first algorithm which is for the case of trees and ℓ1 norm in Section 4 and prove its correctness. In Section 5 we show how this algorithm can be optimized to run in the promissed O(n2) time. We conclude and propose several open problems in Section 6. We extend the algorithm to the case of weighted ℓ1 norm in Appendix A. We present our algorithm for the case of ℓ∞ in Appendix B. We leave our hardness of approximation result to Appendix C and our results for the case of bilayer graphs to Appendix D. 2 Previous Work The main motivation of the current paper is the application of taxonomies in regression. A recent example, studied by Koren et al. [DKK11], is the application of topic hierarchies in the context of collaborative filtering. They provide a method of linking the data-set to a four level taxonomy, which helps them circumvent difficulties related to the size of the data-set. Regression and smoothing problems have been studied extensively in recent years. Perhaps the most relevant problem to our setting is the Isotonic regression problem and its variants. There one wishes to find a closest fit to a given vector subject to a set of monotonicity constraints. More precisely, let a = ha1, . . . , ani be n target values, and let E be a set of m pairwise order constraints on these variables. The Isotonic regression problem is to find values x = hx1, . . . , xni such that xi ≥ xj whenever (i, j) ∈ E for which the distance between x and a is minimized. To put things in a language similar to ours, in isotonic regression the assigned value of each vertex should be bigger than the maximum of the assigned value of its children as opposed to the sum of those values in our problem. Common choices of distance functions include the weighted ℓ1, ℓ2 and ℓ∞ norms. The Isotonic 2 regression problem for such weighted norms have been studied extensively. For some of the results for the ℓ1 and ℓ2 norms see [Sto08, AHKW06, BC90]. Stout also maintains a web site containing some of the fastest known Isotonic regression algorithms for different settings at [Sto]. The Isotonic regression problem belongs to a more general class of problems known as order restricted statistical inference. Order restricted statistical inference was first studied by Barlow et al [BBBB72]. The Isotonic regression problem became popular since it has many applications in testing [LB01, MAC01], modelling [MJDP+00, Ulm86], data smoothing [FT84, PG08] and other areas [RWD88] related to statistical and computational data analysis. It has been shown to be an important post-processing smoothing tool to impose desired hard constraints on the values that a learning algorithm has produced. Variations of Isotonic regression have been used for other appli- cations like template learning [CKP07], ranking [DCZ+10, MSCZ10], and classification [KFB09]. 3 Preliminaries We now formally define the problem as follows. Given a tree (or DAG) T = (V, E) rooted at node r ∈ V , and a vector a ∈ Rn ≥0 of the target values of the vertices. We wish to find the closest vector x ∈ Rn ≥0, in the ℓp-norm, so that for each node v, with children u1, . . . , uk, xv ≥ xu1 +xu2 +···+xuk . While most of the paper addresses the case of p = 1, we also discuss the case of p = ∞ in Appendix B. Note that our hardness results apply to all 1 ≤ p < ∞. For a vertex u ∈ T , we denote the set of nodes with edges to u the children of u or C(u), similarly the parent of u is A(u) (in the case where the underlying graph is a general DAG, A(u) will be a set of nodes). Throughout the paper, we will make extensive use of various paths in the given tree. For this purpose, we let Pu→v denote the (unique) path from vertex u to vertex v in T . We denote the sub-tree rooted in vertex v by Tv. For a given sub-tree Tv, we define aTv as the vector of target values corresponding to the nodes in Tv; we similarly define xTv . 4 The Algorithmic Approach for ℓ1 As an initial attempt, consider the following trivial feasible solution. For each leaf ℓ ∈ T , set xℓ = aℓ. Then, for each internal node v set xv = max(av,Pu∈C(v) xu), by traversing the tree in post-order. However, it is not hard to see that this approach would be arbitrarily sub-optimal (see Figure 1.) Indeed, in some cases it is preferable to lower the existing x values of a given node's children, instead of raising the node's x value, as this might help the objective value on the nodes ancestors as well. In order to optimize the objective function, our algorithm will proceed as follows. By traversing the tree T in post-order, it performs the following sequence of steps for every vertex v. xv is initially set to the maximum of av and the sum of the x values of its children, which is clearly a feasible assignment for Tv. It then improves the assignments for Tv by sequentially decreasing the values of some vertices that are located on some path P from v to some other node in Tv. The adjustments are made so that the overall improvement in the objective function equals the improvement in av − xv. We will refer to such paths as push-paths, and the improvements made on them as push operations. The algorithm is presented below as Algorithm 1. The procedure P ush− P ath(x, P, ǫ) checks what is the improvement on the objective function value if we reduce the x value of all vertices in the path P by ǫ. This path will always start at the current vertex v. For now we do not discuss how to find the push path or the exact value that we push down that path. This abstraction was made deliberately, so as to to separate the correctness of the algorithm from its performance. In fact, we later show that the individual paths need not be enumerated separately. 3 Algorithm 1: Push-Improve Input: Undirected tree T = (V, E), with a vector of vertex weights a ∈ Rn Output: A feasible vector of weights x ∈ Rn + for V + 1 Let v1, v2, . . . , vn−1, vn be the vertices in T sorted in post-order. 2 for v ← 1 to n do 3 4 xv = max{Pu∈C(vi) xu, av} ImproveSubtree(v) 5 end 6 ImproveSubtree(Vertex u) 7 while ∃ path P from u down to a vertex v, and ǫ > 0 such that v is either a leaf or xv > Pw∈C(v) xw and Push-Path (x, P ,ǫ)=ǫ do Push-Path(x, p, ǫ) 8 9 end 10 Push-Path(Assignment x, Path P , Non-negative real-value ǫ) 11 begin 12 Let v1, . . . , vk be the sequence of nodes on the P from top to bottom. 13 14 15 16 17 18 19 20 21 22 old = P1≤i≤k xvi − avi xv1 = xv1 − ǫ for i = 2 to k do t = Pu∈C(vi−1) xu − xvi−1 if t > 0 then xvi = xvi − t end end new = P1≤i≤k xvi − avi return old − new 23 end The following theorem states that the output of Algorithm 1 is optimal. Theorem 4.1. When Algorithm 1 terminates, the obtained vector x is a feasible and optimal assignment for the given tree T . Our proof of Theorem 4.1 will proceed as follows. We begin by characterizing the necessary push-path improvement at each step of the while-loop. We then inductively argue that before and after each push operation, the value of the objective function for each sub-tree rooted in a child of the current node remains optimal. We conclude by using an LP duality argument in order to show that once no more push operations exist for the current vertex in the for-loop, Tv is assigned optimal x values. The following lemma refers to the series of improvements performed on node v, and can be viewed as the set of invariants of the outer for-loop. Lemma 1. Let v be the current node, P = (v = u0, . . . , uk) be a push-path such that for 1 ≤ i ≤ k, ui ∈ C(ui−1). Then the following invariants hold throughout the execution of the inner while-loop: 4 1. If, for ǫ > 0, P ush − P ath(x, P, ǫ) > 0, then P ush − P ath(x, P, ǫ) ≤ ǫ. Furthermore, if for path P and ǫ > 0, P ush − P ath(x, P, ǫ) = δ > 0, then there exists ǫ′ > 0 such that P ush − P ath(x, P, ǫ′) = ǫ′. 2. If for path P and ǫ > 0 P ush − P ath(x, P, ǫ) = ǫ, then for each u ∈ C(v), Tu is optimally set before and after running P ush − P ath(x, P, ǫ). Proof. First, notice that the above invariants clearly hold if the current node v is a leaf, as their initial x values are set to their a values, and will only be modified as a result of performing P ush − P ath on their ancestors. Assume that the invariants hold for all nodes preceding v in the post-order, and suppose for contradiction that there exists some path P = (v = u0, . . . , um) and ǫ > 0 such that P ush − P ath(x, P, ǫ) > ǫ. The first part of the first invariant clearly holds since the sub-trees rooted in the children of v are assumed optimal. Hence, any ǫ-improvement on v cannot entail an additional improvement on the rest of the push-path. We now consider the second invariant, while briefly deferring the proof of the second part of the first invariant. First, notice that for each ℓ ∈ C(v)−{u1}, the assignments to Tℓ do not change. Let P be a modification-path, and ǫ > 0 such that P ush− P ath(x, P, ǫ) = ǫ. On the other hand, notice that xv is reduced by exactly ǫ. This implies that kxTu1 − aTu1k remains unchanged, thereby remaining optimal. We now turn to the remaining part of the first invariant. Consider a modification-path P and δ > 0. By the first part of the invariant, P ush − P ath(x, P, δ) ≤ δ. If P ush − P ath(x, P, δ) = δ, then the claim holds trivially. Hence, assume P ush − P ath(x, P, δ) < δ. We restrict ourselves to dealing with δ values in the range (0, xv −av]. The following observation stems from the fact that during the push operation, x values along P only decrease. Observation 1. For path P and ǫ > 0, if P ush − P ath(x, P, ǫ) > 0 {j ∈ P : xj > aj} > {j ∈ P : xj ≤ aj} (1) In fact, using the induction hypothesis, we can make Observation 1 even stronger: Claim 1. For path P and ǫ > 0, if P ush − P ath(x, P, ǫ) > 0 {j ∈ P : xj > aj} − {j ∈ P : xj ≤ aj} = 1 (2) Claim 1 can be justified by noticing that otherwise, the sub-tree rooted in one of v's children would be amenable to path-improvements, contradicting optimality. The invariant follows, as we could simply set ǫ to be the minimum (positive) amount that maintains the number of nodes along P with x values that are larger than their a values. Lemma 1 implies that each push operation improves the value of the objective function for the current sub-tree, while maintaining the optimality of the sub-trees rooted in the children of v. However, in order to show that the local optimum obtained by the algorithm is the globally optimal feasible solution, we need to argue that as long as the current assignment is not optimal, there exists a feasible path-improvement with a corresponding ǫ > 0 value. The following theorem, which constitutes the main technical part of this paper, formalizes this notion. Theorem 4.2. Upon termination of the inner while-loop, the sub-tree rooted in vertex v is assigned optimal x values. 5 Proof. First, notice that the algorithm clearly maintains the feasibility of the solution throughout its execution. The following observation follows from the definition of the algorithm. Observation 2. During the execution of the algorithm, xv ≥ av. Furthermore, if xv = av, the solution is trivially optimal. The proof of Theorem 4.2 will proceed as follows. We give the LP for the optimization problem, and its corresponding dual LP. We then construct a feasible solution for the dual LP that satisfies the complementary slackness conditions with respect to the solution of the algorithm. In order to construct a valid dual solution, we inductively bootstrap the dual solutions constructed for the nodes rooted sub-trees. From LP duality, we then conclude that the two solutions are optimal for the primal and dual problems. Recall that we inductively assume that the sub-trees rooted in the children of v are optimally adjusted. It is not hard to write a linear program which formulates our problem. This program and its dual can be seen below. The variables di are introduced to avoid using absolute values in the objective function. min Xi∈Tv di subject to di + xi ≥ ai di − xi ≥ −ai xi − Xj∈C(i) xj ≥ 0 max Xi∈Tv ai(λi − λ′ i) subject to λi + λ′ (λi − λ′ i = 1 i) + αi − αp(i) ≤ 0 ∀i ∈ Tv (4a) ∀i ∈ Tv\{v} (4b) (3a) (3b) (3c) (λv − λ′ v) + αv ≤ 0 λi, λ′ i, αi ≥ 0 (4c) ∀i ∈ Tv (4d) i, one can simplify the xi ≥ 0 ∀i ∈ Tv (3d) Note the special case for vertex v (inequality 4c). By denoting βi = λi − λ′ dual LP: max Xi∈Tv aiβi subject to − 1 ≤ βi ≤ 1 βi + αi − αA(i) ≤ 0 βv + αv ≤ 0 αi ≥ 0 ∀i ∈ Tv ∀i ∈ Tv − v ∀i ∈ Tv (5a) (5b) (5c) (5d) We now summarize the necessary complementary slackness conditions required by the dual: i = 1 (βi = −1) i = 0 (βi = 1) xi > ai ⇒ λi = 0, λ′ xi < ai ⇒ λi = 1, λ′ xi > Xj∈C(i) xi > 0 ⇒ λi − λ′ xj ⇒ αi = 0 i + αi − αp(i) = 0 (C1) (C2) (C3) (C4) Since throughout the execution of the while loop xv ≥ av and the case where xv = av is trivial, we will assume from now on that xv > av. This implies the last necessary condition: xv > av ⇒ αv = 1 6 (C5) We begin by suggesting an initial assignment which might not be feasible, and in addition, might violate one of the complementary slackness properties. The following lemma is a direct consequence of the construction of the dual LP and the com- plementary slackness constraints. It refers to a family of assignments to the dual LP that satisfy a subset of the complementary slackness conditions. Lemma 2. Let x, d be a feasible solution for the primal such that the sub-trees rooted in v are optimally assigned and v admits no Push-Path improvements. Let α, β be an assignment for the dual variables such that the following holds: (cid:26)αi = αp(i) − βi, if xi > 0 αi ≤ αp(i) − βi, otherwise βi =   −1, 1, a value in [−1, 1], if xi > ai if xi < ai if xi = ai (6) Then α, β satisfy all the properties of a feasible dual solution, and (α, β) along with (x, d) satisfy complementary slackness except that αi might be negative for some nodes, and condition C3 could be falsified. Next, we observe that if our modified dual LP admits an optimal feasible solution, then our range of possible values for α, β can be narrowed due the total unimodularity of the simplified constraint matrix of the dual LP: Observation 3. If the dual LP has an optimal and feasible solution, then it has an integral, feasible and optimal solution, as well. In particular, for every i ∈ Tv, βi ∈ {−1, 0, 1}). Observation 3 can be verified by induction on the constraint matrix of the dual LP, in order to show that every square sub-matrix of it has a determinant of ±1. in the case whenever xi = ai. The following lemma complements Lemma 2 by suggesting a concrete assignment for each βi Lemma 3. Consider an assignment as described in Lemma 2. If we set βi = 1 whenever xi = ai, then: ∀j ∈ Tv, xj > Xk:child of j xk ⇒ αj ≤ 0 Proof. We prove the claim by way of contradiction. Suppose that the claim is false, and let j be the highest node for which the claim does not hold. That is, xj > Pk∈C(j) xk and αj > 0. Consider Pj→v, the path from j to v. As we are trying to prove an upper bound for αj, we will assume that for every node k on the path from v to j αk = αp(k) − βk, as lower values will only strengthen our claim. This implies αj = − Xk∈Pj→v βk. Since βi = 1 for all nodes i such that xi ≤ ai, and βi = −1 otherwise, αj > 0 implies: {k ∈ Pj→v : xi > ai} > {k ∈ Pj→v : xi ≤ ai} (7) (8) This implies that we can reduce all x values of nodes Pj→v by an amount of at most xj −Pk∈C(j) xk so as to get a feasible solution with a better objective function value. However, this is exactly a push operation, thereby contradicting the assumption of no further path-paths. 7 The following corollary is the contra-positive statement of Lemma 3 Corollary 1. If there exists a node j ∈ Tv such that αj > 0 and xj − Pk∈C(j) xk > 0, then there exists an ancestor i of j such that βi ∈ {0,−1} and xi = ai. We now prove the main theorem by way of induction. We inductively assume that the sub-trees rooted in v have both an optimal setting for the primal LP, and there exists an integral and feasible solution for the dual LP that satisfy the complementary slackness conditions. Without loss of generality, we assume that no child i of v has xi = 0, since otherwise, we could use its assignments without any modifications, as xi does not harden the feasibility constraints of v. Consider the assumed set of assignments for the sub-trees rooted in v. By the assumption, they have corresponding assignments to the dual LPs. Observe that since the conditions listed in Lemma 2 are a subset of the complementary slackness conditions, Lemma 2 applies to them automatically. We will start from a tentative solution to the dual by initially set the (α, β) according to the assumed assignments, and set αv = 1, βv = −1. We let s1 denote the above assignment. Notice that for each child i of v, the dual LP that corresponds to the current assignment had αi + βi = 0, as i was the root (this is a strict equality as by our assumption xi > 0). However, in the current LP, the corresponding dual inequality becomes βi + αi − αv = 0, As αv = 1, this equality is therefore violated. In order to rectify this, we first raise all the α value (except v's) by 1, and denote the resulting solution by s2. Note that by the feasibility of the original assignments to the sub-trees and by the definition of s2 all the nodes in Tv have non-negative α values. Also observe that s2 now has all the properties listed in Lemma 2. Thus, by Lemma 2, we can conclude that s2 is a feasible solution to the dual LP, and s2 along with (x, d) satisfy complementary slackness except that complementary slackness condition C3 might be violated. Our next step would be to adjust s2 so as to fix any violation condition of condition C3. Let W be the set of all infeasible nodes: W = {j ∈ Tv : xj > Xk∈C(j) xk and αi > 0} (9) By Corollary 1, for each j ∈ W there exists an ancestor i such that (1) xi = ai and (2) βi ∈ {−1, 0}. We let (10) X = {i ∈ Tv : xi = ai, βi ∈ {−1, 0}} Moreover, we let Y = {i ∈ X : there is no ancestor of i in X} (11) Thus, for each node j ∈ W there exists an ancestor i ∈ Y . taking solution s2 with the following modifications: We now define the final solution to the dual LP. Define assignment s3 to the dual LP for Tv by 1. ∀k ∈ Ti, such that i ∈ Y , subtract αk by 1. 8 2. ∀i ∈ Y add 1 to βj. Increasing the βj values by 1 makes sure that complementary slackness condition C4 is satisfied after applying the first step. Applying the first modification step guarantees that complementary slackness condition C3 is again satisfied, as all nodes in W undergo the first modification. Observe that by definition, all the sub-trees rooted in nodes in Y are pair-wise disjoint. Hence, each α value can be decremented at most once. Also observe that in addition to nodes in W , other nodes may have their α values decremented. However, as by the definition of W , these nodes do not need to maintain condition C3, and thus this step will not violate their constraints. In addition, their α values are guaranteed to remain non-negative as they were previously incremented by 1. In conclusion, all of the complementary slackness conditions for the dual LP now hold for (x, d) and s3. Therefore, (x, d) is an optimal solution for Tv. 5 The Algorithm Given the general technique presented in Algorithm 1, we conclude our results by giving an O(n2) algorithm that follows the spirit of improving by pushing the surplus from a given vertex downward, along a path. Recall that the algorithm Push-Improve performs the push operations one path at a time. Instead, we can leverage the fact that some paths can share the same prefix. Specifically, instead of the inner while-loop, executed for each node v in the tree, we introduce a depth-first- search algorithm in which for each node j ∈ Tv, the algorithm remembers the maximal amount, pushable through Pv→j. We make use of two measures, defined for each node u ∈ Tv. Let δu = {j ∈ Pv→u : xj > aj}−{j ∈ Pv→u : xj ≤ aj}. In other words, for any push operation along Pv→u, δu is the difference between the number of nodes that will improve the objective function value, and the number of nodes that will worsen the objective function value, if we push a small enough value through Pv→u. Additionally, we define the positive bottleneck along Pv→u as ǫu = minj∈Pv→u{xj − aj : xj > aj}. This is the maximum ǫ we can push on the path Pv→u while gaining exactly δuǫ in the objective function. In order to maintain feasibility, we restrict ǫu to be no more than xk, for any node k on Pv→u. This value will have a similar function as the ǫ value given in Algorithm 1. That is, for the current node v, and a successor u, ǫu will serve as the amount of excess we push through Pv→u. Our algorithm will maintain feasability by restricting the decrease in xu by the sum of the decreases made on its direct children of u (unless xu was strictly bigger than the sum of the x's of its children before the decrease.) The final algorithm for optimizing the assignment to Tv, can be seen as Algorithm 4 in Ap- pendix E. It differs from Algorithm 1 in the way the sub-tree Tv is modified for each node v. The following theorem states that Algorithm 4 is optimal. Theorem 5.1. When Algorithm 4 leaves node v ∈ V , there is no push-path going from the root r, ends at a leaf, and passes through v. Proof. First, we note the following observation, which suggests that the potential for improvement on any path from the root to a node v cannot increase. Observation 4. Let u be a node in T . Let δ∗ u = {i ∈ Pr→u : xv > av} − {i ∈ Pr→u : xv ≤ av}. δ∗ u does not increase throughout the execution of the algorithm. 9 The observation follows immediately from the fact that the only modifications to the x values of the nodes are decreases. We proceed to prove the lemma by induction on the height h of the node v. For h = 0 (leaves), the claim is trivial. Assume the claim holds for h = k, and let v be a node of height k + 1. The claim follows immediately from Observation 4: no sub-tree rooted in a child of v can be improved as a result of a push-path through it. Additionally, the path from r to v never becomes amenable to improvements through push operations, once the algorithm leaves v. This concludes the proof. Running Time The algorithm essentially performs a depth-first-search for every node v on the tree. Therefore, the running time of the algorithm is O(n2). 6 Conclusions and Future Work We have demonstrated the technical difficulties that our problem entails, as well as an efficient method for handling a broad class of instances of the problem. Due to their high efficiency, our methods can be run on relatively large instances in practice. We also believe that our algorithm might be applicable to settings beyond recommendation systems. An immediate open question is to extend our algorithm to the case of general DAGs. It seems that one needs some new ideas to give a combinatorial algorithm for this general case. In fact even a (fast) approximation algorithm for this case seems to be beyond the reach of our techniques. Another interesting direction would be to consider other measures such as the ℓ2-norm. Due to the fundamental difference between the ℓ1 and ℓ2 norms, we suspect that this different distance measure will require a completely different approach. In addition to considering alternative objective functions, we can also consider other constraints. For instance, we can consider comparing the value assigned to each node to the average value of its children. Another type of constraint would be to require equality between the value of a node, and the sum of the values of its children. References [AHKW06] Stanislav Angelov, Boulos Harb, Sampath Kannan, and Li-San Wang. Weighted iso- tonic regression under the ℓ1 norm. In SODA, pages 783 -- 791, 2006. [BBBB72] R. E. Barlow, D. J. Bartholomew, J. M. Bremmer, and H. D. Brunk. Statistical Inference Under Order Restrictions. Wiley, 1972. [BC90] M. J. Best and N. Chakravarti. Active set algorithms for isotonic regression: a unifying framework. Math. Program., 47:425 -- 439, August 1990. [CKP07] Deepayan Chakrabarti, Ravi Kumar, and Kunal Punera. Page-level template detection via isotonic smoothing. In WWW, pages 61 -- 70, 2007. [DCZ+10] Anlei Dong, Yi Chang, Zhaohui Zheng, Gilad Mishne, Jing Bai, Ruiqiang Zhang, Karolina Buchner, Ciya Liao, and Fernando Diaz. Towards recency ranking in web search. In WSDM, pages 11 -- 20, 2010. [DKK11] Gideon Dror, Noam Koenigstein, and Yehuda Koren. Yahoo! music recommendations: Modeling music ratings with temporal dynamics and item taxonomy. In Recommender Systems, Chicago, IL, USA, 2011. ACM. 10 [Fei98] [Fle04] [FT84] [KFB09] Uriel Feige. A threshold of ln n for approximating set cover. J. ACM, 45:634 -- 652, July 1998. Lisa Fleischer. A fast approximation scheme for fractional covering problems with variable upper bounds. In Proceedings of the fifteenth annual ACM-SIAM symposium on Discrete algorithms, SODA '04, pages 1001 -- 1010, Philadelphia, PA, USA, 2004. Society for Industrial and Applied Mathematics. J. Friedman and R. Tibshirani. The monotone smoothing of scatterplots. Technomet- rics, 1984. R´emon Kamp, Ad Feelders, and Nicola Barile. Isotonic classification trees. In Pro- ceedings of the 8th International Symposium on Intelligent Data Analysis: Advances in Intelligent Data Analysis VIII, IDA '09, pages 405 -- 416, Berlin, Heidelberg, 2009. Springer-Verlag. [LB01] Klervi Leuraud and Jacques Benichou. A comparison of several methods to test for the existence of a monotonic dose-response relationship in clinical and epidemiological studies. Statistics in Medicine, 20(22):3335 -- 3351, 2001. [MAC01] Jessica Y. Mancuso, Hongshik Ahn, and James J. Chen. Order-restricted dose-related trend tests. Statistics in Medicine, 20(15):2305 -- 2318, 2001. [MJDP+00] Tony Morton-Jones, Peter Diggle, Louise Parker, Heather O. Dickinson, and Keith Binks. Additive isotonic regression models in epidemiology. Statistics in Medicine, 19(6):849 -- 859, 2000. [MSCZ10] Taesup Moon, Alex J. Smola, Yi Chang, and Zhaohui Zheng. Intervalrank: isotonic regression with listwise and pairwise constraints. In WSDM, pages 151 -- 160, 2010. [PG08] Kunal Punera and Joydeep Ghosh. Enhanced hierarchical classification via isotonic smoothing. In WWW, pages 151 -- 160, 2008. [RWD88] T. ROBERTSON, F. T. Wright, and R. L. Dykstra. Order Restricted Statistical In- ference. Wiley, 1988. [Sto] [Sto08] Quentin http://www.eecs.umich.edu/qstout/IsoRegAlg.html. Retrieved: Aug. 6th, 2011. Regression Isotonic F. Stout. Algorithms. Quentin F. Stout. Unimodal regression via prefix isotonic regression. Computational Statistics & Data Analysis, 53(2):289 -- 297, 2008. [Ulm86] K. Ulm. Nonparametric analysis of dose-response relations in epidemiology. Mathe- matical Modelling, 7(5-8):777 -- 783, 1986. A The Weighted ℓ1-Norm Case We now discuss the case where the nodes on the given tree can have varying levels of importance with respect to the objective function. Specifically, as done in related studies, we consider the case in which for each node i ∈ V , there is an associated weight wi. For ease of presentation, we assume that all weights are integral, i.e. w ∈ Nn ≥. The objective function will be g(x) = Pi∈V wi ·ai − xi. 11 Hence, we can simply reinterpret the variable δi defined for Algorithm 4 as the weighted bal- ance between the nodes which will benefit, and the nodes that will "suffer" as a result of a Push-Path operation. More precisely, when considering the path Pv→i, we will compute δi = wj. Therefore, a feasible push-improvement across a path Pv→u Pj∈Pv→i:xj>aj wj −Pj∈Pv→i:xj≤aj would lead to an improvement if and only if δu > 0. The above discussion leads to the following simple modification to procedure SetParams, given in Algorithm 2. Note that the weighted case reduces to the unweighted case by setting the weights Algorithm 2: The modified Set-Params procedure for the weighted case Input: Vertex v 1 Set-Params(Vertex i, Non-negative integer δ, Non-negative real-value ǫ) 2 begin 3 if xi > ai then 4 5 6 7 8 δi ← δ + wi, ǫi ← min{ǫ, xi − ai} end else δi ← δ − wi, ǫi ← min{xi, ǫ} end 9 end to 1. Clearly, the algorithm has the same O(n2) running time of the original algorithm. The following theorem argues about the optimality of the modified algorithm: Theorem A.1. The algorithm resulting from the modification given in Algorithm 2 obtains the optimal weighted-ℓ1 objective function value. Proof. In order to argue about the correctness of the modified algorithm, we compare the objective function obtained by the algorithm to the one obtained by the original algorithm, on an equivalent unweighted tree. The construction We construct the tree T = ( V , E) by replacing each node i with a chain i1, . . . , iwi, such that for any 1 ≤ j < wi, (ij, ij+1) ∈ E. Additionally, we set for children k ∈ C(i) (kwk , i1) ∈ E, and for i's parent ℓ (iwi, ℓ1) ∈ E. It is easy to see that T is a tree. Notice that T might be arbitrarily large (according to the weights). However, it is used only for the sake of proof of correctness, and never actually constructed by the algorithm. The following proof sketch highlights the equivalence of the uniform weight case to the weighted case. Claim 2. Let x and x be optimal assignments for T and T , respectively. Then g(x) = f (x). The following immediate observation, which follows from the construction of T , implies the above claim. Observation 5. Let x be an optimal assignment for T . Then for any chain (i1, . . . , iwi) that corresponds to vertex i in T : The following claim complements claim 2: xi1 = xi2 = . . . = xiwi 12 Claim 3. Let x and x be the feasible assignments returned by Algorithm 4 and the modified algo- rithm for weighted trees, respectively. Then g(x) = f (x) B The ℓ∞-norm We now turn our attention to the case of the ℓ∞-norm; i.e. minimizing the maximal difference maxu∈V ai − xi. In contrast to the case of the ℓ1-norm, this optimization problem can be solved in a straightforward manner by using dynamic programming, even when the underlying graph is a directed acyclic graph. For a given value t ≥ 0, the algorithm will go over all nodes and tries to produce an assignment of objective value at most t. We can show that if the algorithm fails then there is no valid assignment of objective value at most t. To find the optimal objective value then one only needs to run a binary search on the variable t. Algorithm 3: The dynamic programming algorithm for the ℓ∞-norm case Input: DAG G=(V,E), vertices 1, . . . , n sorted in topological order, vertex weight vector a. 1 for i ← 1 to n do 2 xmin i ← max{0,Pj∈C(i) xmin j , ai − t} 3 end 4 return xmin As mentioned above, we perform a binary search on t in the range [0,Pi ai]. Clearly, for an instance of the problem with optimal solution value τ , the running time of Algorithm 3 would be O(n · logτ ). We now briefly outline the proof of correctness of the algorithm. Theorem B.1. For any given t ≥ 0, x = xmin is a valid solution. Furthermore, if x − a∞ > t, then there does not exist a valid solution x′ such that a − x′∞ ≤ t. Proof. The validity of x follows from definition. To prove the second part we show the following simple lemma. Lemma 4. If x′ is a valid solution and a − x′∞ ≤ t, then for all i, x′ Proof. The proof follows with a simple induction on i. Note that because a−x′∞ ≤ t, x′ Furthermore, x′ is a valid solution so x′ i ≥ ai−t. i ≥ xmin i i ≥ 0 and j ≥ Xj∈C(i) x′ x′ i ≥ Xj∈C(i) xmin j = xmin i , where we have used the induction hypothesis for the second inequality. It then follows that, x′ i ≥ max{0, Xj∈C(i) xmin j , ai − t} = xmin i . 13 Now assume that there is a valid solution x′ with objective value at most t. It follows that for all i, that is, xmin − a∞ ≤ t. C Hardness of Approximation in General Graphs i ≤ ai + t, ai − t ≤ xmin i ≤ x′ As mentioned before when the objective value is the ℓ1 norm of the difference between the x and a vectors the (most general case of the) problem can be solved exactly in polynomial time by solving a linear program. In fact, it is not hard to see that using a similar approach one can solve this general case of the problem for any ℓp norm with 1 ≤ p ≤ ∞. The only difference is that one has a linear program with infinitely many facets which has an efficient separation oracle and can be solved with the Ellipsoid method. For an instance where all the input values are integral, one might ask whether the task of finding an optimal integral solution is tractable or not. This is especially interesting for the ℓ1 case, since in the case of trees, an integral solution can be found efficiently by our algorithm of Section 4, if the initial a values are integrals. Unfortunately, as soon as one considers the DAG case (even the special case of layered dags) this problem becomes intractable for essentially all ℓp norms. The following theorem summarizes our hardness results. Theorem C.1. Unless N P ⊆ T IM E(nO(log log n)) it is NP-hard to approximate the Integral Iso- tonic Regression problem for the case of directed acyclic graphs better than Θ((log n)1/p) for the ℓp norm. Proof. We prove the theorem by a reduction from the Set Cover problem. In the Set Cover problem one is given sets S1, S2, . . . , Sm such that S1 ∪ S2 ∪ ... ∪ Sm = {1, 2, . . . , n} and the objective is to select a minimum number of Si's such that their union is still {1, 2, . . . , n}. It is a well known result of Feige [Fei98] that unless N P ⊆ T IM E(nO(log log n)) it is NP-hard to approximate Set Cover better than a factor of (1 − o(1)) log n. Our reduction uses vertex weights so as to simplify the construction. However, one can easily adapt the construction to the uniform case by adding multiple copies of nodes so as to simulate large weights. Given an instance of the Set Cover problem We construct the following instance of the SBHSP problem: • The vertex set of the output digraph will be V = {v1, . . . , vm, u1, . . . un}. • The edge set of the output digraph will be E = {(vi, uj) : j ∈ Si}. • The a values on the vertices will be as follows. For all vi we have a(vi) = 1, while for all uj we have a(uj) = {i : j ∈ Si} − 1. • The w values (weights) of the vertices will be as follows. For all vi we have w(vi) = 1, while for all uj we have w(uj) = m. On the one hand it is easy to see that for any set cover of the original instance (of size α) one can construct a solution to the SBHSP instance (of cost p√α) by assigning x(vi) = 0 if Si is selected and 1 otherwise, and x(uj) = a(uj) for all uj. On the other hand it is not hard to see that the optimal solution to the SBHSP will have x(vi) ∈ {0, 1} for all i and x(uj) = a(uj) for all j. Furthermore, for any such solution (of cost 14 α) the set of Si for which x(vi) = 0 can be easily seen to be a valid set cover of size αp. Hence, a hardness of approximation of (1 − o(1)) log n for the Set Cover problem implies a hardness of approximation of Θ( p√log n) for SBHSP when the objective value is defined using the ℓp norm for any 1 ≤ p < ∞. Remark 1. The hard-instances of Set-Cover generated by Feige [Fei98] have less Sets than elements. As a result it is not hard to see that the hardness achieved by the proof of the above theorem is in fact ((1 − o(1)) ln n)1/p for the weighted case and (cid:16) (1−o(1)) ln n 2 (cid:17)1/p for the non-weighted case. D FPTAS for optimizing under the ℓ1 norm for Bilayered graphs Consider a DAG G = (V, E) which is bilayered, i.e. the vertex set can be partitioned as V = U ∪ W and each edge is from the U side to the W side (E ⊆ U × W .) In this section we show a fast Fully Polynomial Approximation Scheme for SBHSP with the ℓ1 norm for such DAGs. The run time will be close to linear in the size of the DAG. The algorithm is a simple reduction to a well known class of problems which admit such FPTASes. These problems are restricted class of the Mixed Positive Packing and Covering Problem, see [Fle04]. We start by the following simple observation. Lemma 5. When optimizing the ℓ1 norm and when the input DAG is bilayered there is always an optimal solution with the following two properties, (i) ∀w ∈ W : xw = aw, (ii) ∀u ∈ U : xu ≤ au. If xw < aw Proof. Consider any optimal solution x, and a vertex w ∈ W for which xw 6= aw. changing the assigned value of this vertex to aw produces another valid solution with a better objective function value. Now consider the case in which xw > aw. If xw > Pu∈C(w) xu then again we can improve the objective function by decreasing xw slightly, and if xw = Pu∈C(w) xu we can simultaneously decrease xw and the assigned value of some of its children. This last step would help the objective value due to the improvement on w, and possibly hurt it by the exact same amount due to the decrease on its children, while maintaining a valid the solution. Doing this step on every node on the W side results in a solution that satisfies the first condition. For the second condition observe that if xu > au we can simply decrease it to au without changing the validity of the solution while decreasing the objective function. In other words any optimal solution must satisfy the second condition. Given the above lemma one can write the following linear program whose solution is the exact value of the optimal solution. The left hand side is the original program based on the LP (3a)-(3d) while the right hand side is the result of a simplification. di min Xv∈V subject to du ≥ 0 xu ≥ 0 du + xu = au ∀u ∈ U ∀u ∈ U ∀u ∈ U xu ≤ aw ∀w ∈ W Xu∈C(w) di min Xv∈V subject to du ≥ 0 du ≤ au du ≥ ( Xu∈C(w) Xu∈C(w) ∀u ∈ U ∀u ∈ U au) − aw ∀w ∈ W (13a) (13b) (13c) Once written in this form the above formulation is a, so called, Mixed Positive Packing and Covering 15 Program. In fact it is among a certain class of such programs for which Fleischer [Fle04] provides a fast FPTAS. In particular, we have the following theorem. Theorem D.1. When the input is a bilayered graph and the objective value is in terms of the ℓ1 norm, there is an algorithm that given ǫ > 0 runs in time O(V E log(V )/ǫ2) and returns a valid solution with objective value no more than (1 + ǫ) times that of the optimum. Proof. The proof is a simple application of Theorem 2.1 from [Fle04] to the above Linear Program. A simple corollary of that theorem is that the algorithm finishes in O(V E log(V )/ǫ2) steps1 and in each step one has to find the most unsatisfied constraint among (13a)-(13c) given a current solution d. Each such step can be done by evaluating all the constraints in total time E. E Omitted figures and algorithms /.-, ()*+8 /.-, ()*+8 ^>>>>>>>> @ /.-, ()*+5 /.-, ()*+5 Figure 1: A counter-example for the naive algorithm. Node annotations denote the a values. The naive algorithm will obtain an objective function value of 4, whereas the optimum value is 2. 1the constant C in Theorem 2.1 of [Fle04] is 1 in our case. 16 O O @ ^ Algorithm 4: The improved ImproveSubtree procedure Input: Vertex v 1 begin /* If xv = av T (v) is optimal if xv > av then Push-Search(v,∞, 0) end 2 3 4 5 end */ 6 Push-Search(Vertex u, Non-negative real-value ǫ, Non-negative Integer δ) 7 begin 8 Set-Params(u, ǫ, δ) if ǫu = 0 then return 0 end sum ← 0 ℓ ← min{ǫu, xu −Pk:child of u xk} if ℓ > 0 and δu > 0 then xu ← xu − ℓ, sum ← ℓ Set-Params(u, δ, ǫ − ℓ) end foreach j ∈ c(u) do if sum = ǫu then return 0 /* Speedup end t ←Push-Search(j, ǫu, δu) sum ← sum + t, xu ← xu − t Set-Params(u, δ, ǫ − sum) end return sum 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 end 28 Set-Params(Vertex i, Non-negative integer δ, Non-negative real-value ǫ) 29 if xi > ai then 30 31 end 32 else 33 34 end δi ← δ + 1, ǫi ← min{ǫ, xi − ai} δi ← δ − 1, ǫi ← min{xi, ǫ} 17
1505.01446
1
1505
2015-05-06T17:51:01
Public Transit Labeling
[ "cs.DS" ]
We study the journey planning problem in public transit networks. Developing efficient preprocessing-based speedup techniques for this problem has been challenging: current approaches either require massive preprocessing effort or provide limited speedups. Leveraging recent advances in Hub Labeling, the fastest algorithm for road networks, we revisit the well-known time-expanded model for public transit. Exploiting domain-specific properties, we provide simple and efficient algorithms for the earliest arrival, profile, and multicriteria problems, with queries that are orders of magnitude faster than the state of the art.
cs.DS
cs
Public Transit Labeling∗ Daniel Delling1, Julian Dibbelt2, Thomas Pajor3 and Renato F. Werneck4 1Sunnyvale, USA, [email protected] 2Karlsruhe Institute of Technology, Germany, [email protected] 3Microsoft Research, USA, [email protected] 4San Francisco, USA, [email protected] May 5, 2015 Abstract We study the journey planning problem in public transit networks. Developing efficient preprocessing-based speedup techniques for this problem has been challenging: current approaches either require massive preprocessing effort or provide limited speedups. Leveraging recent advances in Hub Labeling, the fastest algorithm for road networks, we revisit the well-known time-expanded model for public transit. Exploiting domain- specific properties, we provide simple and efficient algorithms for the earliest arrival, profile, and multicriteria problems, with queries that are orders of magnitude faster than the state of the art. 1 Introduction Recent research on route planning in transportation networks [5] has produced several speedup techniques varying in preprocessing time, space, query performance, and simplicity. Overall, queries on road networks are several orders of magnitude faster than on public transit [5]. Our aim is to reduce this gap. There are many natural query types in public transit. An earliest arrival query seeks a journey that arrives at a target stop t as early as possible, given a source stop s and a departure time (e. g., "now"). A multicriteria query also considers the number of transfers when traveling from s to t. A profile query reports all quickest journeys between two stops within a time range. ∗An extended abstract of this paper has been accepted at the 14th International Symposium on Experimental Algorithms (SEA'15). Work done mostly while all authors were at Microsoft Research Silicon Valley. 1 These problems can be approached by variants of Dijkstra's algorithm [13] applied to a graph modeling the public transit network, with various techniques to handle time- dependency [18]. In particular, the time-expanded (TE) graph encodes time in the vertices, creating a vertex for every event (e. g., a train departure or arrival at a stop at a specific time). Newer approaches, like CSA [12] and RAPTOR [11], work directly on the timetable. Speedup techniques [5] such as Transfer Patterns [4,6], Timetable Contraction Hierarchies [14], and ACSA [20] use preprocessing to create auxiliary data that is then used to accelerate queries. For aperiodic timetables, the TE model yields a directed acyclic graph (DAG), and several public transit query problems translate to reachability problems. Although these can be solved by simple graph searches, this is too slow for our application. Different methodologies exist to enable faster reachability computation [7, 15, 16, 19, 21 -- 23]. In particular, the 2-hop labeling [8] scheme associates with each vertex two labels (forward and backward); reachability (or shortest-path distance) can be determined by intersecting the source's forward label and the target's backward label. On continental road networks, 2-hop labeling distance queries take less than a microsecond [2]. In this work, we adapt 2-hop labeling to public transit networks, improving query performance by orders of magnitude over previous methods, while keeping preprocessing time practical. Starting from the time-expanded graph model (Section 3), we extend the labeling scheme by carefully exploiting properties of public transit networks (Section 4). Besides earliest arrival and profile queries, we address multicriteria and location-to-location queries, as well as reporting the full journey description quickly (Section 5). We validate our Public Transit Labeling (PTL) algorithm by careful experimental evaluation on large metropolitan and national transit networks (Section 6), achieving queries within microseconds. 2 Preliminaries Let G = (V, A) be a (weighted) directed graph, where V is the set of vertices and A the set of arcs. An arc between two vertices u, v ∈ V is denoted by (u, v). A path is a sequence of adjacent vertices. A vertex v is reachable from a vertex u if there is a path from u to v. A DAG is a graph that is both directed and acyclic. We consider aperiodic timetables, consisting of sets of stops S, events E, trips T, and footpaths F. Stops are distinct locations where one can board a transit vehicle (such as bus stops or subway platforms). Events are the scheduled departures and arrivals of vehicles. Each event e ∈ E has an associated stop stop(e) and time time(e). Let E(p) = {e0(p), . . . , ekp (p)} be the list (ordered by time) of events at a stop p. We set time(ei(p)) = −∞ for i < 0, and time(ei(p)) = ∞ for i > kp. For simplicity, we may drop the index of an event (as in e(p) ∈ E(p)) or its stop (as in e ∈ E). A trip is a sequence of events served by the same vehicle. A pair of a consecutive departure and arrival events of a trip is a connection. Footpaths model transfers between nearby stops, each with a predetermined walking duration. A journey planning algorithm outputs a set of journeys. A journey is a sequence of trips 2 (each with a pair of pick-up and drop-off stops) and footpaths in the order of travel. Journeys can be measured according to several criteria, such as arrival time or number of transfers. A journey j1 dominates a journey j2 if and only if j1 is no worse in any criterion than j2. If j1 and j2 are equal in all criteria, we break ties arbitrarily. A set of non-dominated journeys is called a Pareto set. Multicriteria Pareto optimization is NP-hard in general, but practical for natural criteria in public transit networks [11,12,17,18]. A journey is tight if there is no other journey between the same source and target that dominates it in terms of departure and arrival time, e. g., that departs later and arrives earlier. Given a timetable, stops s and t, and a departure time τ, the (s, t, τ)-earliest arrival (EA) problem asks for an s -- t journey that arrives at t as early as possible and departs at s no earlier than τ. The (s, t)-profile problem asks for a Pareto set of all tight journeys between s and t over the entire timetable period. Finally, the (s, t, τ)-multicriteria (MC) problem asks for a Pareto set of journeys departing at s no earlier than τ and minimizing the criteria arrival time and number of transfers. We focus on computing the values of the associated optimization criteria of the journeys (i. e., departure time, arrival times, number of transfers), which is enough for many applications. Section 5 discusses how the full journey description can be obtained with little overhead. Our algorithms are based on the 2-hop labeling scheme for directed graphs [8]. It associates with every vertex v a forward label Lf(v) and a backward label Lb(v). In a reachability labeling, labels are subsets of V , and vertices u ∈ Lf(v) ∪ Lb(v) are hubs of v. Every hub in Lf(v) must be reachable from v, which in turn must be reachable by every hub in Lb(v). In addition, labels must obey the cover property: for any pair of vertices u and v, the intersection Lf(u) ∩ Lb(v) must contain at least one hub on a u -- v path (if it exists). It follows from this definition that Lf(u) ∩ Lb(v) 6= ∅ if and only if v is reachable from u. In a shortest path labeling, each hub u ∈ Lf(v) also keeps the associated distance dist(u, v), or dist(v, u) for backward labels, and the cover property requires Lf(u) ∩ Lb(v) to contain at least one hub on a shortest u -- v path. If labels are kept sorted by hub ID, a distance label query efficiently computes dist(u, v) by a coordinated linear sweep over Lf(u) and Lb(v), finding the hub w ∈ Lf(u) ∩ Lb(v) that minimizes dist(u, w) + dist(w, v). In contrast, a reachability label query can stop as soon as any matching hub is found. In general, smaller labels lead to less space and faster queries. Many algorithms to compute labelings have been proposed [2,3,7,15,21,23], often for restricted graph classes. We leverage (as a black box) the recent RXL algorithm [9], which efficiently computes small shortest path labelings for a variety of graph classes at scale. It is a sampling-based greedy algorithm that builds labels one hub at a time, with priority to vertices that cover as many relevant paths as possible. Different approaches for transforming a timetable into a graph exist (see [18] for an overview). In this work, we focus on the time-expanded model. Since it uses scalar arc costs, it is a natural choice for adapting the labeling approach. In contrast, the time-dependent model (another popular approach) associates functions with the arcs, which makes adaption more difficult. 3 3 Basic Approach We build the time-expanded graph from the timetable as follows. We group all departure and arrival events by the stop where they occur. We sort all events at a stop by time, merging events that happen at the same stop and time. We then add a vertex for each unique event, a waiting arc between two consecutive events of the same stop, and a connection arc for each connection (between the corresponding departure and arrival event). The cost of arc (u, v) is time(v) − time(u), i. e., the time difference of the corresponding events. To account for footpaths between two stops a and b, we add, from each vertex at stop a, a foot arc to the first reachable vertex at b (based on walking time), and vice versa. As events and vertices are tightly coupled in this model, we use the terms interchangeably. Any label generation scheme (we use RXL [9]) on the time-expanded graph creates two (forward and backward) event labels for every vertex (event), enabling event-to-event queries. For our application reachability labels [21], which only store hubs (without distances), suffice. First, since all arcs point to the future, time-expanded graphs are DAGs. Second, if an event e is reachable from another event e0 (i. e., Lf(e0) ∩ Lb(e) 6= ∅), we can compute the time to get from e0 to e as time(e) − time(e0). In fact, all paths between two events have equal cost. In practice, however, event-to-event queries are of limited use, as they require users to specify both departure and arrival times, one of which is usually unknown. Therefore, we discuss earliest arrival and profile queries, which optimize arrival time and are thus more meaningful. See Section 5 for multicriteria queries. Earliest Arrival Queries. Given event labels, we answer an (s, t, τ)-EA query as follows. We first find the earliest event ei(s) ∈ E(s) at the source stop s that suits the departure time, i. e., with time(ei(s)) ≥ τ and time(ei−1(s)) < τ. Next, we search at the target stop t for the earliest event ej(t) ∈ E(t) that is reachable from ei(s) by testing whether Lf(ei(s))∩ Lb(ej(t)) 6= ∅ and Lf(ei(s)) ∩ Lb(ej−1(t)) = ∅. Then, time(ej(t)) is the earliest arrival time. One could find ej(t) using linear search (which is simple and cache-friendly), but binary search is faster in theory and in practice. To accelerate queries, we prune (skip) all events e(t) with time(e(t)) < τ, since Lf(ei(s)) ∩ Lb(e(t)) = ∅ always holds in such cases. Moreover, to avoid evaluating Lf(ei(s)) multiple times, we use hash-based queries [9]: we first build a hash set of the hubs in Lf(ei(s)), then check the reachability for an event e(t) by probing the hash with hubs h ∈ Lb(e(t)). Profile Queries. To answer an (s, t)-profile query, we perform a coordinated sweep over the events at s and t. For the current event ei(s) ∈ E(s) at the source stop (initialized to the earliest event e0(s) ∈ E(s)), we find the first event ej(t) ∈ E(t) at the target stop that is reachable, i. e., such that Lf(ei(s)) ∩ Lb(ej(t)) 6= ∅ and Lf(ei(s)) ∩ Lb(ej−1(t)) = ∅. This gives us the earliest arrival time time(ej(t)). To identify the latest departure time from s for that earliest arrival event (and thus have a tight journey), we increase i until Lf(ei(s)) ∩ Lb(ej(t)) = ∅, then add (time(ei−1(s)), time(ej(t))) to the profile. We 4 repeat the process starting from the events ei(s) and ej+1(t). Since we increase either i or j after each intersection test, the worst-case time to find all tight journeys is linear in the number of events (at s and t) multiplied by the size of their largest label. 4 Leveraging Public Transit Our approach can be refined to exploit features specific to public transit networks. As described so far, our labeling scheme maintains reachability information for all pairs of events (by covering all paths of the time-expanded graph, breaking ties arbitrarily). However, in public transit networks we actually are only interested in certain paths. In particular, the labeling does not need to cover any path ending at a departure event (or beginning at an arrival event). We can thus discard forward labels from arrival events and backward labels from departure events. Trimmed Event Labels. Moreover, we can disregard paths representing dominated jour- neys that depart earlier and arrive later than others (i. e., journeys that are not tight, cf. Section 2). Consider all departure events of a stop. If a certain hub is reachable from event ei(s), then it is also reachable from e0(s), . . . , ei−1(s), and is thus potentially added to the forward labels of all these earlier events. In fact, experiments show that on average the same hub is added to 1.8 -- 5.0 events per stop (depending on the network). We therefore compute trimmed event labels by discarding all but the latest occurrence of each hub from the forward labels. Similarly, we only keep the earliest occurrence of each hub in the backward labels. (Preliminary experiments have shown that we obtain very similar label sizes with a much slower algorithm that greedily covers tight journeys explicitly [2,9].) Unfortunately, we can no longer just apply the query algorithms from Section 3 with trimmed event labels: if the selected departure event at s does not correspond to a tight journey toward t, the algorithm will not find a solution (though one might exist). One could circumvent this issue by also running the algorithm from subsequent departure events at s, which however may lead to quadratic query complexity in the worst case (for both EA and profile queries). Stop Labels. We solve this problem by working with stop labels: For each stop p, we merge all forward event labels Lf(e0(p)), . . . , Lf(ek(p)) into a forward stop label SLf(p), and all backward event labels into a backward stop label SLb(p). Similar to distance labels, each stop label SL(p) is a list of pairs (h, timep(h)), each containing a hub and a time, sorted by hub. For a forward label, timep(h) encodes the latest departure time from p to reach hub h. More precisely, let h be a hub in an event label Lf(ei(p)): we add the pair (h, time(ei(p))) to the stop label SLf(p) only if h /∈ Lf(ej(p)), j > i, i. e., only if h does not appear in the label of another event with a later departure time at the stop. Analogously, for backward stop labels, timep(h) encodes the earliest arrival time at p from h. 5 By restricting ourselves to these entries, we effectively discard dominated (non-tight) journeys to these hubs. It is easy to see that these stop labels obey a tight journey cover property: for each pair of stops s and t, SLf(s) ∩ SLb(t) contains at least one hub on each tight journey between them (or any equivalent journey that departs and arrives at the same time; recall from Section 2 that we allow arbitrary tie-breaking). This property does not, however, imply that the label intersection only contains tight journeys: for example, SLf(s) and SLb(t) could share a hub that is important for long distance travel, but not to get from s to t. The remainder of this section discusses how we handle this fact during queries. Stop Label Profile Queries. To run an (s,t)-profile query on stop labels, we perform a coordinated sweep over both labels SLf(s) and SLb(t). For every matching hub h, i. e., (h, times(h)) ∈ SLf(s) and (h, timet(h)) ∈ SLb(t), we consider the journey induced by (times(h), timet(h)) for output. However, since we are only interested in reporting tight journeys, we maintain (during the algorithm) a tentative set of tight journeys, removing dominated journeys from it on-the-fly. (We found this to be faster than adding all journeys during the sweep and only discarding dominated journeys at the end.) We can further improve the efficiency of this approach in practice by (globally) reassigning hub IDs by the time of day. Note that every hub h of a stop label is still also an event and carries an event time time(h). (Not to be confused with times(h) and timet(h).) We assign sequential IDs to all hubs h in order of increasing time(h), thus ensuring that hubs in the label intersection are enumerated chronologically. Note that this does not imply that journeys are enumerated in order of departure or arrival time, since each hub h may appear anywhere along its associated journey. However, preliminary experiments have shown that this approach leads to fewer insertions into the tentative set of tight journeys, reducing query time. Moreover, as in shortest path labels [9], we improve cache efficiency by storing the values for hubs and times separately in a stop label, accessing times only for matching hubs. Overall, stop and event labels have different trade-offs: maintaining the profile requires less effort with event labels (any discovered journey is already tight), but fewer hubs are scanned with stop labels (there are no duplicate hubs). Stop Label Earliest Arrival Queries. Reassigned hub IDs also enable fast (s, t, τ)-EA queries. We use binary search in SLf(s) and SLb(t) to find the earliest relevant hub h, i. e., with time(h) ≥ τ. From there, we perform a linear coordinated sweep as in the profile query, finding (h, times(h)) ∈ SLf(s) and (h, timet(h)) ∈ SLb(t). However, instead of maintaining tentative profile entries (times(h), timet(h)), we ignore solutions that depart too early (i. e., times(h) < τ), while picking the hub h∗ that minimizes the tentative best arrival time timet(h∗). (Note that time(h) ≥ τ does not imply times(h) ≥ τ.) Once we scan a hub h with time(h) ≥ timet(h∗), the tentative best arrival time cannot be improved anymore, and we stop the query. For practical performance, pruning the scan, so that we only sweep hubs h between τ ≤ time(h) ≤ timet(h∗), is very important. 6 5 Practical Extensions So far, we presented stop-to-stop queries, which report the departure and arrival times of the quickest journey(s). In this section, we address multicriteria queries, general location- to-location requests, and obtaining detailed journey descriptions. Multicriteria Optimization and Minimum Transfer Time. Besides optimizing arrival time, many users also prefer journeys with fewer transfers. To solve the underlying multicriteria optimization problem, we adapt our labeling approach by (1) encoding transfers as arc costs in the graph, (2) computing shortest path labels based on these costs (instead of reachability labels on an unweighted graph), and (3) adjusting the query algorithm to find the Pareto set of solutions. Reconsider the earliest arrival graph from Section 3. As before, we add a vertex for each unique event, linking consecutive events at the same stop with waiting arcs of cost 0. However, each connection arc (u, w) in the graph is subdivided by an intermediate connection vertex v, setting the cost of arc (u, v) to 0 and the cost of arc (v, w) to 1. By interpreting costs of 1 as leaving a vehicle, we can count the number of trips taken along any path. To model staying in the vehicle, consecutive connection vertices of the same trip are linked by zero-cost arcs. A shortest path labeling on this graph now encodes the number of transfers as the shortest path distance between two events, while the duration of the journey can still be deduced from the time difference of the events. Consider a fixed source event e(s) and the arrival events of a target stop e0(t), e1(t), . . . in order of increasing time. The minimum number of transfers required to reach the target stop t never increases with arrival times. (Hence, the whole Pareto set P of multicriteria solutions can be computed with a single Dijkstra run [18].) We exploit this property to compute (s, t, τ)-EA multicriteria (MC) queries from the labels as follows. We initialize P as the empty set. We then perform an (s, t, τ)-EA query (with all optimizations described in Section 3) to compute the fastest journey in the solution, i. e., the one with most transfers. We add this journey to P. We then check (by performing distance label queries) for each subsequent event at t whether there is a journey with fewer transfers (than the most recently added entry of P), in which case we add the journey to P and repeat. The MC query ends once the last event at the target stop has been processed. We can stop earlier with the following optimization: we first run a distance label query on the last event at t to obtain the smallest possible number of transfers to travel from s to t. We may then already stop the MC query once we add a journey to P with this many transfers. Note that, since we do not need to check for domination in P explicitly, our algorithm maintains P in constant time per added journey. Minimum Transfer Times. Transit agencies often model an entire station with multiple platforms as a single stop and account for the time required to change trips inside the station by associating a minimum transfer time mtt(p) with each stop p. To incorporate them into 7 the EA graph, we first locally replace each affected stop p by a set of new stops p∗, distributing conflicting trips (between which transferring is impossible due to mtt(p)) to different stops of p∗. We then add footpaths between all pairs of stops in p∗ with length mtt(p). A small set p∗ can be computed by solving an appropriate coloring problem [10]. For the MC graph, we need not change the input. Instead, it is sufficient to shift each arrival event e ∈ E(p) by adding mtt(p) to time(e) before creating the vertices. s s (h) = timep(h)−dist(s∗, p) so that the journey starts at s∗ and add (h, time∗ Location-to-Location Queries. A query between arbitrary locations s∗ and t∗, which may employ walking or driving as the first and last legs of the journey, can be handled It first computes sets S and T of relevant stops near the by a two-stage approach. origin s∗ and destination t∗ that can be reached by car or on foot. With that information, [1] is built from all forward stop labels associated with S. For a forward superlabel each entry (h, timep(h)) ∈ SLf(p) in the label of stop p ∈ S, we adjust the departure time time∗ (h)) to the superlabel. For duplicate hubs that occur in multiple stop labels, we keep only the latest departure time from s∗. This can be achieved with a coordinated sweep, always adding the next hub of minimum ID. A backward superlabel (for T ) is built analogously. For location-to-location queries, we then simply run our stop-label-based EA and profile query algorithms using the superlabels. In practice, we need not build superlabels explicitly but can simulate the building sweep during the query (which in itself is a coordinated sweep over two labels). A similar approach is possible for event labels. Moreover, point-of-interest queries (such as finding the closest restaurants to a given location) can be computed by applying known techniques [1] to these superlabels. Journey Descriptions. While for many applications it suffices to report departure and arrival times (and possibly the number of transfers) per journey, sometimes a more detailed description is needed. We could apply known path unpacking techniques [1] to retrieve the full sequence of connections (and transfers), but in public transit it is usually enough to report the list of trips with associated transfer stops. We can accomplish that by storing with each hub the sequences of trips (and transfer stops) for travel between the hub and its label vertex. 6 Experiments Setup. We implemented all algorithms in C++ using Visual Studio 2013 with full opti- mization. All experiments were conducted on a machine with two 8-core Intel Xeon E5-2690 CPUs and 384 GiB of DDR3-1066 RAM, running Windows 2008R2 Server. All runs are sequential. We use at most 32 bits for distances. We consider four realistic inputs: the metropolitan networks of London (data.london. gov.uk) and Madrid (emtmadrid.es), and the national networks of Sweden (trafiklab.se) and Switzerland (gtfs.geops.ch). London includes all modes of transport, Madrid contains 8 Table 1. Size of timetables and the earliest arrival (EA) and multicriteria (MC) graphs. Trips Footp. Dy. Instance 133 k London 165 k Madrid 548 k Sweden Switzerland 27.1 k 23,706 k 2,198 k Conns Stops 5,133 k 20.8 k 4.7 k 4,527 k 51.1 k 12,657 k 45.7 k 1.3 k 1.1 k 29.8 k EA Graph V MC Graph A V A 72,162 k 9,852 k 1 4,719 k 51,043 k 34,505 k 1 3,003 k 13,730 k 7,530 k 93,194 k 2 8,151 k 34,806 k 20,808 k 2 7,979 k 49,656 k 31,685 k 170,503 k only buses, and the national networks contain both long-distance and local transit. We consider 24-hour timetables for the metropolitan networks, and two days for national ones (to enable overnight journeys). Footpaths were generated using a known heuristic [10] for Madrid; they are part of the input for the other networks. See Table 1 for size figures of the timetables and resulting graphs. The average number of unique events per stop ranges from 160 for Sweden to 644 for Madrid. (Recall from Section 3 that we merge all coincident events at a stop.) Note that no two instances dominate each other (w. r. t. number of stops, connections, trips, events per stop, and footpaths). Preprocessing. Table 2 reports preprocessing figures for the unweighted earliest arrival graph (which also enables profile queries) and the multicriteria graph. For earliest ar- rival (EA), preprocessing takes well below an hour and generates about one gigabyte, which is quite practical. Although there are only 37 -- 70 hubs per label, the total number of hubs per stop (i. e., the combined size of all labels) is quite large (5,630 -- 49,247). By eliminating redundancy (cf. Section 4), stop labels have only a fifth as many hubs (for Madrid). Even though they need to store an additional distance value per hub, total space usage is still smaller. In general, average labels sizes (though not total space) are higher for metropolitan instances. This correlates with the higher number of daily journeys in these networks. Table 2. Preprocessing figures. Label sizes are averages of forward and backward labels. Earliest Arrival Event Labels Stop Labels Multicriteria Event Labels Instance London Madrid Sweden Switzerland RXL Hubs Hubs Space Hubs Space RXL Hubs [h:m] p. lbl p. stop [MiB] p. stop [MiB] [h:m] p. lbl 0:54 0:25 0:32 0:42 7,075 1,257 49:19 403 10:55 9,830 700 36:14 1,536 2,970 708 61:36 70 15,480 1,334 77 49,247 963 37 5,630 1,226 42 11,189 1,282 Hubs Space p. stop [MiB] 734 162,565 26,871 404 258,008 10,155 29,046 12,637 190 216 58,022 12,983 9 London Sweden Switzerland Table 3. Evaluating earliest arrival queries. Bullets (•) indicate different features: profile query (Prof.), stop labels (St. lbs.), pruning (Prn.), hashing (Hash), and binary search (Bin.). The column "=" indicates the average number of matched hubs. St.lbs. Hash Prof. Prn. Bin. = [µs] Lbls. Hubs = [µs] Lbls. Hubs = [µs] ◦ ◦ ◦ ◦ ◦ 108.4 1 8.7 ◦ ◦ • ◦ ◦ 5.8 1 16.1 ◦ ◦ • • ◦ 3.8 1 16.1 ◦ ◦ • • • 7.0 4 2.1 ◦ • ◦ ◦ ◦ 5,707 218 20.4 2.0 13,037 1,126 ◦ • • ◦ ◦ 62 3.8 861 2.0 • ◦ ◦ ◦ ◦ 658.5 40,892 211 141.7 423.7 13,590 118 39.4 786.6 29,381 240 81.4 • • ◦ ◦ ◦ 5,707 218 24.5 Lbls. Hubs 6,936 1,360 1,047 332 6.9 1 5.4 1 3.6 1 3 2.1 81 10.0 3.6 16 2,415 1,581 1,083 179 2,855 711 14.7 5.9 4.2 2.8 54.8 6.2 2.0 13,037 1,126 74.3 68.0 34.4 34.4 6.5 2.0 2.0 89.0 33.5 33.5 7.6 2.0 2.0 2.0 2,855 81 12.1 2.0 3,485 1,676 1,151 204 1 1 1 4 699 19 Preprocessing the multicriteria (MC) graph is much more expensive: times increase by a factor of 26.2 -- 54.8 for the metropolitan and 67.9 -- 88 for the national networks. On Madrid, Sweden, and Switzerland labels are five times larger compared to EA, and on London the factor is even more than ten. This is immediately reflected in the space consumption, which is up to 26 GiB (London). Queries. We now evaluate query performance. For each algorithm, we ran 100,000 queries between random source and target stops, at random departure times between 0:00 and 23:59 (of the first day). Table 3 reports detailed figures, organized in three blocks: event label EA queries, stop label EA queries, and profile queries (with both event and stop labels). We discuss MC queries later. We observe that event labels result in extremely fast EA queries (6.9 -- 14.7 µs), even without optimizations. As expected, pruning and hashing reduce the number of accesses to labels and hubs (see columns "Lbls." and "Hubs"). Although binary search cannot stop as soon as a matching hub is found (see the "=" column), it accesses fewer labels and hubs, achieving query times below 3 µs on all instances. Using stop labels (cf. Section 4) in their basic form is significantly slower than using event labels. With pruning enabled, however, query times (3.6 -- 6.2 µs) are within a factor of two of the event labels, while saving a factor of 1.1 -- 2.4 in space. For profile queries, stop labels are clearly the best approach. It scans up to a factor of 5.1 fewer hubs and is up to 3.3 times faster, computing the profile of the full timetable period in under 80 µs on all instances. The difference in factors is due to the overhead of maintaining the Pareto set during the stop label query. 10 Table 4. Comparison with the state of the art. Presentation largely based on [5], with some additional results taken from [6]. The first block of techniques considers the EA problem, the second the MC problem and the third the profile problem. Instance Query [ms] 1.8 8.7 0.3 0.7 0.2 0.0028 0.0030 0.0021 0.0021 5.4 3.1 0.3 0.0266 0.0643 0.0276 0.0217 Criteria Prep. Tran. Prof. [·106] Dy. Arr. [h] Jn. ◦ 1 • ◦ -- n/a 4.9 2 • ◦ ◦ n/a 46.2 0.2 ◦ < 0.1 p • ◦ 1.7 n/a ◦ 1 • ◦ n/a 19 4.8 1 • ◦ ◦ 0.9 13.9 249 1 • ◦ ◦ 0.9 5.1 0.9 1 • ◦ ◦ 4.5 0.9 0.4 ◦ 2 • ◦ 1.0 12.7 0.5 ◦ 2 • ◦ 0.7 23.7 1.0 1 • • ◦ 5.1 -- 1.8 ◦ 1 • • n/a 4.8 ◦ 1 • • 1.9 13.9 1 • • ◦ 1.8 5.1 1 • • ◦ 4.5 1.9 ◦ 2 • • 1.7 12.7 ◦ 2 • • 23.7 1.7 1 • ◦ • -- 98.2 161.0 4.9 • 2 • ◦ n/a 171.0 46.2 0.2 • < 0.1 p • ◦ 3.7 n/a 1.7 1 • ◦ • 3.3 16.4 13.9 249 1 • ◦ • 0.9 5.1 81.0 0.0743 • 1 • ◦ 0.1119 0.4 110.7 4.5 2 • ◦ • 0.0121 12.7 0.5 12.7 2 • ◦ • 23.7 0.7 31.5 0.0245 Stops Conns [·103] 20.8 252.4 30.5 4.6 248.4 20.8 4.7 51.1 27.1 20.8 4.6 248.4 20.8 4.7 51.1 27.1 20.8 252.4 30.5 248.4 20.8 4.7 51.1 27.1 185 372 49.3 10.9 36.2 61.6 Name London Germany Europe (LD) Madrid Germany London Madrid Sweden Switzerland Algorithm CSA [12] ACSA [20] CH [14] TP [5] TP [6] PTL PTL PTL PTL RAPTOR [11] London Madrid TP [5] Germany TP [6] London PTL PTL Madrid Sweden PTL Switzerland PTL CSA [12] London Germany ACSA [20] Europe (LD) CH [14] Germany TP [6] PTL London Madrid PTL Sweden PTL PTL Switzerland 11 Comparison. Table 4 compares our new algorithm (indicated as PTL, for Public Transit Labeling) to the state of the art and also evaluates multicriteria queries. In this experiment, PTL uses event labels with pruning, hashing and binary search for earliest arrival (and multicriteria) queries, and stop labels for profile queries. We compare PTL to CSA [12] and RAPTOR [11] (currently the fastest algorithms without preprocessing), as well as Accelerated CSA (ACSA) [20], Timetable Contraction Hierarchies (CH) [14], and Transfer Patterns (TP) [4,6] (which make use of preprocessing). Since RAPTOR always optimizes transfers (by design), we only include it for the MC problem. Note that the following evaluation should be taken with a grain of salt, as no standardized benchmark instances exist, and many data sets used in the literature are proprietary. Although precise numbers are not available for several competing methods, it is safe to say they use less space than PTL, particularly for the MC problem. Table 4 shows that PTL queries are very efficient. Remarkably, they are faster on the national networks than on the metropolitan ones: the latter are smaller in most aspects, but have more frequent journeys (that must be covered). Compared to other methods, PTL is 2 -- 3 orders of magnitude faster on London than CSA and RAPTOR for EA (factor 643), profile (factor 2,167), and MC (factor 203) queries. We note, however, that PTL is a point-to-point algorithm (as are ACSA, TP, and CH); for one-to-all queries, CSA and RAPTOR would be faster. PTL has 1 -- 2 orders of magnitude faster preprocessing and queries than TP for the EA and profile problems. On Madrid, EA queries are 233 times faster while preprocessing is faster by a factor of 48. Note that Sweden (PTL) and Germany (TP) have a similar number of connections, but PTL queries are 95 times faster. (Germany does have more stops, but recall that PTL query performance depends more on the frequency of trips.) For the MC problem, the difference is smaller, but both preprocessing and queries of PTL are still an order of magnitude faster than TP (up to 48 times for MC queries on Madrid). Compared to ACSA and CH (for which figures are only available for the EA and profile problems), PTL has slower preprocessing but significantly faster queries (even when accounting for different network sizes). 7 Conclusion We introduced PTL, a new preprocessing-based algorithm for journey planning in public transit networks, by revisiting the time-expanded model and adapting the Hub Labeling approach to it. By further exploiting structural properties specific to timetables, we obtained simple and efficient algorithms that outperform the current state of the art on large metropolitan and country-sized networks by orders of magnitude for various realistic query types. Future work includes developing tailored algorithms for hub computation (instead of using RXL as a black box), compressing the labels (e. g., using techniques from [6] and [9]), exploring other hub representations (e. g., using trips instead of events, as in 3-hop labeling [21]), using multicore- and instruction-based parallelism for preprocessing and 12 queries, and handling dynamic scenarios (e. g., temporary station closures and train delays or cancellations [5]). References [1] Ittai Abraham, Daniel Delling, Amos Fiat, Andrew V. Goldberg, and Renato F. Werneck. HLDB: Location-based services in databases. In Proceedings of the 20th ACM SIGSPATIAL International Symposium on Advances in Geographic Information Systems (GIS'12), pages 339 -- 348. ACM Press, 2012. Best Paper Award. [2] Ittai Abraham, Daniel Delling, Andrew V. Goldberg, and Renato F. Werneck. Hierarchical hub labelings for shortest paths. In Proceedings of the 20th Annual European Symposium on Algorithms (ESA'12), volume 7501 of Lecture Notes in Computer Science, pages 24 -- 35. Springer, 2012. [3] Takuya Akiba, Yoichi Iwata, and Yuichi Yoshida. Fast exact shortest-path distance queries on large networks by pruned landmark labeling. In Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data (SIGMOD'13), pages 349 -- 360. ACM Press, 2013. [4] Hannah Bast, Erik Carlsson, Arno Eigenwillig, Robert Geisberger, Chris Harrelson, Veselin Raychev, and Fabien Viger. Fast routing in very large public transportation networks using transfer patterns. In Proceedings of the 18th Annual European Symposium on Algorithms (ESA'10), volume 6346 of Lecture Notes in Computer Science, pages 290 -- 301. Springer, 2010. [5] Hannah Bast, Daniel Delling, Andrew V. Goldberg, Matthias Müller -- Hannemann, Thomas Pa- jor, Peter Sanders, Dorothea Wagner, and Renato F. Werneck. Route planning in transportation networks. Technical Report MSR-TR-2014-4, Microsoft Research, 2014. [6] Hannah Bast and Sabine Storandt. Frequency-based search for public transit. In Proceedings of the 22nd ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems. ACM Press, November 2014. [7] James Cheng, Silu Huang, Huanhuan Wu, and Ada Wai-Chee Fu. Tf-label: A topological-folding labeling scheme for reachability querying in a large graph. In Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data (SIGMOD'13), pages 193 -- 204. ACM Press, 2013. [8] Edith Cohen, Eran Halperin, Haim Kaplan, and Uri Zwick. Reachability and distance queries via 2-hop labels. SIAM Journal on Computing, 32(5):1338 -- 1355, 2003. [9] Daniel Delling, Andrew V. Goldberg, Thomas Pajor, and Renato F. Werneck. Robust distance queries on massive networks. In Proceedings of the 22nd Annual European Symposium on Algorithms (ESA'14), volume 8737 of Lecture Notes in Computer Science, pages 321 -- 333. Springer, September 2014. [10] Daniel Delling, Bastian Katz, and Thomas Pajor. Parallel computation of best connections in public transportation networks. ACM Journal of Experimental Algorithmics, 17(4):4.1 -- 4.26, July 2012. [11] Daniel Delling, Thomas Pajor, and Renato F. Werneck. Round-based public transit routing. Transportation Science, 2014. accepted for publication. 13 [12] Julian Dibbelt, Thomas Pajor, Ben Strasser, and Dorothea Wagner. Intriguingly simple and fast transit routing. In Proceedings of the 12th International Symposium on Experimental Algorithms (SEA'13), volume 7933 of Lecture Notes in Computer Science, pages 43 -- 54. Springer, 2013. [13] Edsger W. Dijkstra. A note on two problems in connexion with graphs. Numerische Mathematik, 1:269 -- 271, 1959. [14] Robert Geisberger. Contraction of timetable networks with realistic transfers. In Proceedings of the 9th International Symposium on Experimental Algorithms (SEA'10), volume 6049 of Lecture Notes in Computer Science, pages 71 -- 82. Springer, May 2010. [15] Ruoming Jin and Guan Wang. Simple, fast, and scalable reachability oracle. Proceedings of the VLDB Endowment, 6(14):1978 -- 1989, 2013. [16] Florian Merz and Peter Sanders. Preach: A fast lightweight reachability index using pruning and contraction hierarchies. In Proceedings of the 22nd Annual European Symposium on Algorithms (ESA'14), volume 8737 of Lecture Notes in Computer Science, pages 701 -- 712. Springer, September 2014. [17] Matthias Müller -- Hannemann and Karsten Weihe. On the cardinality of the Pareto set in bicriteria shortest path problems. Annals of Operations Research, 147(1):269 -- 286, 2006. [18] Evangelia Pyrga, Frank Schulz, Dorothea Wagner, and Christos Zaroliagis. Efficient models for timetable information in public transportation systems. ACM Journal of Experimental Algorithmics, 12(2.4):1 -- 39, 2008. [19] Stephan Seufert, Avishek Anand, Srikanta Bedathur, and Gerhard Weikum. Ferrari: Flexible and efficient reachability range assignment for graph indexing. In Proceedings of the 29th International Conference on Data Engineering, pages 1009 -- 1020. IEEE Computer Society, 2013. [20] Ben Strasser and Dorothea Wagner. Connection scan accelerated. In Proceedings of the 16th Meeting on Algorithm Engineering and Experiments (ALENEX'14), pages 125 -- 137. SIAM, 2014. [21] Yosuke Yano, Takuya Akiba, Yoichi Iwata, and Yuichi Yoshida. Fast and scalable reachability queries on graphs by pruned labeling with landmarks and paths. In Proceedings of the 22nd International Conference on Information and Knowledge Management, pages 1601 -- 1606. ACM Press, 2013. [22] Hilmi Yildirim, Vineet Chaoji, and Mohammad J. Zaki. Grail: Scalable reachability index for large graphs. Proceedings of the VLDB Endowment, 3(1):276 -- 284, 2010. [23] Andy Diwen Zhu, Wenqing Lin, Sibo Wang, and Xiaokui Xiao. Reachability queries on large dynamic graphs: A total order approach. In Proceedings of the 2014 ACM SIGMOD International Conference on Management of Data (SIGMOD'14), pages 1323 -- 1334. ACM Press, 2014. 14
0908.0968
4
0908
2010-03-28T18:23:28
Approximating the Statistics of various Properties in Randomly Weighted Graphs
[ "cs.DS", "cs.DM" ]
Consider the setting of \emph{randomly weighted graphs}, namely, graphs whose edge weights are chosen independently according to probability distributions with finite support over the non-negative reals. Under this setting, properties of weighted graphs typically become random variables and we are interested in computing their statistical features. Unfortunately, this turns out to be computationally hard for some properties albeit the problem of computing them in the traditional setting of algorithmic graph theory is tractable. For example, there are well known efficient algorithms that compute the \emph{diameter} of a given weighted graph, yet, computing the \emph{expected} diameter of a given randomly weighted graph is \SharpP{}-hard even if the edge weights are identically distributed. In this paper, we define a family of properties of weighted graphs and show that for each property in this family, the problem of computing the \emph{$k^{\text{th}}$ moment} (and in particular, the expected value) of the corresponding random variable in a given randomly weighted graph $G$ admits a \emph{fully polynomial time randomized approximation scheme (FPRAS)} for every fixed $k$. This family includes fundamental properties of weighted graphs such as the diameter of $G$, the \emph{radius} of $G$ (with respect to any designated vertex) and the weight of a \emph{minimum spanning tree} of $G$.
cs.DS
cs
Approximating the Statistics of various Properties in Randomly Weighted Graphs Yuval Emek ∗ Amos Korman † Yuval Shavitt ‡ November 1, 2018 Abstract Consider the setting of randomly weighted graphs, namely, graphs whose edge weights are chosen independently according to probability distributions with finite support over the non- negative reals. Under this setting, properties of weighted graphs typically become random variables and we are interested in computing their statistical features. Unfortunately, this turns out to be computationally hard for some properties albeit the problem of computing them in the traditional setting of algorithmic graph theory is tractable. For example, there are well known efficient algorithms that compute the diameter of a given weighted graph, yet, computing the expected diameter of a given randomly weighted graph is #P-hard even if the edge weights are identically distributed. In this paper, we define a family of properties of weighted graphs and show that for each property in this family, the problem of computing the kth moment (and in particular, the expected value) of the corresponding random variable in a given randomly weighted graph G admits a fully polynomial time randomized approximation scheme (FPRAS) for every fixed k. This family includes fundamental properties of weighted graphs such as the diameter of G, the radius of G (with respect to any designated vertex) and the weight of a minimum spanning tree of G. 0 1 0 2 r a M 8 2 ] S D . s c [ 4 v 8 6 9 0 . 8 0 9 0 : v i X r a ∗Microsoft Israel R&D Center, Herzliya, Israel and School of Electrical Engineering, Tel Aviv University, Tel Aviv, Israel. E-mail: [email protected]. Supported in part by The Israel Science Foundation, grant 664/05. †CNRS and Universit´e Paris Diderot - Paris 7, France. E-mail: [email protected]. Supported in part by the ANR project ALADDIN, by the INRIA project GANG, and by COST Action 295 DYNAMO. ‡School of Electrical Engineering, Tel Aviv University, Tel Aviv, Israel. E-mail: [email protected]. 1 Introduction In the traditional setting of graph algorithms, the input is typically a graph G whose edges are often associated with some weights. In most applications, G represents a real-life network and the edge weights correspond to some attributes of the network's links which are assumed to be known when one wishes to apply some graph algorithm to G. Unfortunately, in many scenarios these attributes of the real-life network cannot be determined. Still, however, it is often believed that the attributes of the network's links are governed by some known probability distributions. For example, the latency along each communication link in the Internet backbone is usually assumed to be a random variable, rather than a fixed value that can be determined a priori. The same situation appears in the emerging field of networking called delay tolerant networks (DTNs) [13] that includes sparse ah-hoc networks [35, 4], space exploration networks [9], submarine networks [31], and sensor networks. Our goal in this paper is to advance the theoretic foundations of graph algorithms operating in the context of edge weights that obey some specified probability distributions. In this context, various properties of the graph become random variables and we wish to design better algorithms for the problems of computing the statistical features of these random variables. This turns out to be a non-trivial task even for basic and fundamental graph properties which are easy to compute in the traditional (deterministic) setting. Similar challenges were previously tackled in many works (see the survey of Ball et al. [3]), however the computational angle of these problems received little treatment. The model. A randomly weighted (RW) graph is a graph1 G in which the edge weights are independent random variables with finite support over the non-negative reals. Specifically, every edge e ∈ E (G) is associated with some positive integer m(e) and with some non-negative reals e , . . . , W m(e) W 1 e with probability pi are called the phases of edge e. e independently of all other edges. The reals W 1 e = 1, such that the weight of e is w (e) = W i , wherePm(e) e , . . . , W m(e) e i=1 pi e and p1 e, . . . , pm(e) e A special subclass of RW graphs that plays a major role in this paper is that of biased coin weighted (BCW) graphs in which m(e) = 2 for all edges e ∈ E (G). It will be convenient to slightly change the notation for BCW graphs: edge e ∈ E (G) is said to take on its heavy phase W H e with probability pe and on its light phase W L e ≥ 0. A BCW e = W L for all edges e ∈ E (G) is referred to as an graph G in which pe = p, W H identically distributed weighted graph. e with probability 1 − pe, where W H e = W H , and W L e ≥ W L 1Unless stated otherwise, all graphs in this paper are assumed to be finite and undirected, though not necessarily simple. The vertex set and edge set of graph G are denoted by V (G) and E (G), respectively. 1 Weighted graph properties. Let G be the collection of all (not necessarily simple) connected2 graphs G with non-negative edge weights w : E (G) → R≥0. Throughout, we think of a weighted graph property as a function X that assigns a non-negative real X (G) to each graph G ∈ G. A weighted graph property X : G → R≥0 is said to be distance-cumulative if it satisfies the following requirements for every graph G ∈ G: (R1) If G′ ∈ G is the graph obtained from G by multiplying all edge weights by some factor r ∈ R≥0, then X (G′) = r · X (G). (R2) If G′ ∈ G is the graph obtained from G by increasing the weight of some edge e ∈ E (G) by an additive term r ∈ R≥0, then X (G) ≤ X (G′) ≤ X (G) + r. (R3) If w (e) = 0 for some edge e ∈ E (G), then X (G/e) = X (G), where G/e ∈ G is the graph obtained from G by contracting the edge e. (R4) If e, e′ ∈ E (G) are parallel edges and w (e) ≥ w (e′), then X (G − e) = X (G), where G − e ∈ G is the graph obtained from G by removing the edge e. (R5) If X (G) is strictly positive, then X (G) ≥ min{w (e) e ∈ E (G)}. (R6) X (G) = 0 if and only if the graph obtained from G by removing all (strictly) positive weight edges is connected. Requirements (R1) -- (R5) and the sufficiency direction of requirement (R6) are naturally sat- isfied by weighted graph properties in which the edge weights correspond to time delays, routing costs, etc. The necessity direction of requirement (R6) is slightly more restrictive. We extend the definition of distance-cumulative weighted graph properties X by assuming that X (G) = ∞ for every disconnected graph G. A weighted graph property X is said to be efficiently calculated if there exists a polynomial time algorithm that computes X (G) for every graph G. Consider some graph G ∈ G. The diameter of G, denoted diam(G), is defined as diam(G) = max{distG(u, v) u, v ∈ V (G)}, where distG(u, v) is the distance between u and v in G, namely, the length of a shortest (with respect to the edge weights) path from u to v. For a designated vertex u ∈ V (G), the radius of G, denoted rad(G), is defined as rad(G) = max{distG(u, v) v ∈ V (G)}. The weight of a minimum spanning tree of G, denoted MST(G), is defined as MST(G) = min{Pe∈T w (e) T is a spanning tree of G}. It is easy to verify that diam(G), rad(G), and MST(G) are distance-cumulative weighted graph properties. Efficient algorithms that com- pute them are described in most textbooks on graph algorithms (e.g., [12]). Another distance- cumulative weighted graph property is the diameter of a min-diameter spanning tree, defined as min{diam(T ) T is a spanning tree of G}. The min-diameter spanning tree is also known to be efficiently calculated [19]. Two more efficiently calculated weighted graph properties that fit into the definition of distance- cumulative properties by slightly modifying requirement (R5) are the all pairs average distance and the single source average distance with respect to some designated vertex. Our techniques can be adjusted to handle such a modification, however, this is beyond the scope of the current version of 2Graph G is said to be connected if it admits a path between u and v for every two vertices u, v ∈ V (G). 2 the paper. Our contribution. Let X be some distance-cumulative weighted graph property and assume that it is efficiently calculated. Given some connected RW graph G, X (G) is a random variable -- denote it by X -- and we are interested in approximating its kth moment, i.e., E[X k], for any fixed k. Specifically, we develop a fully polynomial time randomized approximation scheme (FPRAS) for the problem, namely, a randomized algorithm that runs in time poly(G, 1/ǫ) for any choice of ǫ > 0, where G stands for the number of bits required to encode G in a standard binary representation, and returns a (1 + ǫ)-approximation of E[X k] with probability3 at least 3/4. The following theorem is established in Sections 3, 4, and 5. Theorem 1. The problem of computing the kth moment of X (G) on connected RW graphs G admits an FPRAS for every fixed k. In general, Theorem 1 is best possible. This is because exact solutions to the problems of computing E[diam(G)] and E[rad(G)] are #P-hard to obtain even when the input is restricted to identically distributed weighted graphs. Refer to Section 6 for a proof of this rather simple observation. To the best of our knowledge, our FPRAS yields the first provably polynomial time algorithm with guaranteed approximation ratio for any non-trivial statistical feature of a weighted graph property in randomly weighted graphs. Moreover, it seems that most related literature focuses on individual weighted graph properties and does not attempt to provide a framework for a more general theory of such properties; indeed, Snyder & Steele call for such a framework in their survey [32]. We hope that our technique which is suitable for all distance-cumulative weighted graph properties will be a significant step in that direction. Related work. The algorithmic aspects of randomly weighted graphs have been extensively studied since the early 60's (cf. Fulkerson [17]) mainly in the context of the shortest (s, t)-path, the longest (s, t)-path (a.k.a. the PERT problem), and maximum (s, t)-flow. A comprehensive account of the various methods developed for the computation (and approximation) of the statistical features corresponding to these weighted graph properties is provided by Ball et al. [3] who also observe that an exact computation of the expected values of these weighted graph properties is #P-hard. Note that except for a few special cases (e.g., series-parallel networks with a specific type of edge distributions), none of the algorithms developed in that context is provably polynomial with guaranteed approximation ratio. Distance-cumulative weighted graph properties were also investigated under this setting. Hassin & Zemel [20] prove that the diameter (and radius) of a complete n-vertex graph whose edge weights 3Using the median of means method, the success probability of an FPRAS can be increased to 1 − ǫ for any choice of ǫ > 0 at the cost of increasing the run-time by an O(log(1/ǫ)) factor. 3 are uniformly and independently distributed in [0, 1] is almost surely Θ(log(n)/n). The hidden constants in this expression were resolved by Janson [23] who shows that the (s, t)-distance, radius with respect to s, and diameter of a complete n-vertex graph whose edge weights are uniformly and independently distributed in [0, 1] converge in probability to ln n/n, 2 ln n/n, and 3 ln n/n, respectively. Frieze [14] shows that for every distribution function F with finite variance whose derivative at zero exists and satisfies F ′(0) = D > 0, if the edge weights in a complete n-vertex graph G are independently distributed according to F , then the weight of a minimum spanning j=1 1/j3. This is generalized by Steele [33] who shows that the assumption on the finite variance can be lifted. For the special case of F being the uniform distribution over [0, 1], Beveridge et al. [7] establish a variant of this bound for r-regular graphs. tree of G converges in probability to ζ(3)/D, where ζ(3) =P∞ Asymptotic results for minimum spanning trees on n points uniformly and independently dis- tributed in the Euclidean unit ball are established by Bertsimas & van Rysin [6]. Kulkarni [28] and Alexopoulos & Jacobson [1] present algorithms that compute the distribution of MST(G) for graphs G whose edge weights obey exponential and discrete distributions, respectively. The run-times of their algorithms are not necessarily polynomial, though. A non-trivial upper bound on E[MST(G)] is established by Jain & Mamer [22]. A different, yet, related subject that admits a plethora of literature is average case analysis for graph algorithms (e.g. [15, 25, 11, 29]). There it is assumed that the edge weights in the input of some graph algorithm are drawn from a specified probability distribution and the goal is to analyze the expected run-time of the algorithm with respect to that distribution; refer to [16] for a survey. It is important to point out that upon invocation of the graph algorithm, the actual edge weights are determined, and in particular, known to the algorithm, in contrast to the RW graphs setting in which the challenge is to cope with the uncertainty in the edge weights. Techniques. We now provide an informal overview of the construction of an FPRAS for E[X (G)], where X is some efficiently calculated distance-cumulative weighted graph property and G is an RW graph; approximating higher moments is very similar. Note that if the variance of X (G) is at most some polynomial times E[X (G)]2 (that is, the critical ratio is polynomial), then E[X (G)] can be approximated by means of sampling (a.k.a. Monte Carlo method). However, there exist some simple examples (cf. Appendix A) in which the variance is too large, and therefore a different approach must be sought. Our first step is to employ a simple reduction that allows us to focus on BCW graphs rather than arbitrary RW graphs. This reduction is presented in Section 5. So, in what follows our goal is to approximate E[X (G)] to within a multiplicative error of 1 + O(ǫ), where G is a BCW graph. The desired approximation would have been straightforward to obtain if we could have efficiently approximated P(X (G) > x) for arbitrary choices of real x ≥ 0. It turns out that the case x = 0 is 4 well known: approximating P(X (G) > 0) is equivalent to approximating the all-terminal network [3]) in the graph G0 obtained from G by removing all edges whose light reliability problem (cf. phases are strictly positive. The FPRAS developed by Karger in [24] for the all-terminal network reliability problem is used to obtain this approximation. Karger's technique is based on identifying a collection C of polynomially many (2-way) cuts in G0 such that the probability that all edges of some cut not in C take on their heavy phases is small. (Of course, Karger uses the language of network reliability, rather than that of BCW graphs.) Unfortunately, approximating P(X (G) > x) to within a multiplicative error of 1 + O(ǫ) for an arbitrary choice of real x > 0 seems to be a challenging task. In fact, when X = MST (namely, we are required to approximate the expected weight of a minimum spanning tree), an efficient implementation of this task would yield an FPRAS for the Tutte polynomial TG(x, y) of arbitrary graphs G for every x, y > 1 (refer to Bollob´as [8] for a comprehensive treatment of the Tutte polynomial and its many applications); whether or not such an FPRAS exists is an important open question [2, 18]. Instead, we use a careful "sliding window" argument to show that the desired approximation of E[X (G)] can be efficiently obtained by repeatedly calling a procedure called Procedure Estimate. Given a positive real x, Procedure Estimate approximates P(X (G) > x) to within an additive error of O(ǫ) · P(X (G) > 0). In other words, we show that it suffices to produce a weaker approximation of P(X (G) > x); the quality of this weaker approximation is determined by P(X (G) > 0). The "sliding window" argument, presented in Section 3, is based on iteratively resetting all edge phases in G smaller than some threshold for a carefully chosen sequence of thresholds. Procedure Estimate itself is presented in Section 4. The main trick there relies on formulating the real valued random variable Y that maps each instance I of the probability space defined by E (G) − E (G0) to P(X (G) > x I). Since E[Y ] = P(X (G) > x), it is sufficient to approximate E[Y ]. We would have wanted to do so by sampling instances I of the probability space defined by E (G) − E (G0) and then computing P(X (G) > x I). Sampling instances of the probability space defined by E (G) − E (G0) is a straightforward task. The problem is that given such an instance I, it is not clear how to efficiently compute P(X (G) > x I). To tackle this obstacle, we revisit the cut collection C and for each instance I, identify those cuts in C that conditioned on I, imply X (G) > x. For that to work, we must extend Karger's construction of C to r-way cuts for all r ≥ 2. This extension builds upon the recent bound of Berend & Tassa on the Bell number [5]. We then employ the method of Karp, Luby, and Madras [26, 27] for probabilistic DNF satisfiability to approximate the probability that at least one of these cuts is induced by the edges in E (G0) that take on their heavy phase. 5 2 Preliminaries Randomly weighted graphs. Throughout we consider some distance-cumulative weighted graph property X and some n-vertex connected RW graph G. Let X denote the random vari- able that takes on X (G). By requirement (R1), we may assume without loss of generality that the edge phases of G are scaled so that the smallest non-zero phase is exactly 1. Con- sequently requirement (R5) implies that X is either 0, or it is bounded from below by 1. On the other hand, requirements (R2) and (R4) guarantee that X is bounded from above by xmax = n2 · max{W i e e ∈ E (G) and 1 ≤ i ≤ m(e)}. Suppose that G is a BCW graph. In what follows we assume that 0 < pe < 1 for every edge e ∈ E (G) (this assumption is clearly without loss of generality as the phases of an edge are not required to be disjoint). Let F ⊆ E (G) be some subset of the edges. Each edge e ∈ F takes on its heavy phase with probability pe and on its light phase with probability 1 − pe; this defines a probability space. It will be convenient to view an instance I of this probability space as a Boolean function I : F → {H , L}, where I(e) =( H if e takes on its heavy phase W H e ; L if e takes on its light phase W L e . At the risk of abusing notation, we may sometime write F when we actually refer to the probability space it defines; our intentions will be clear from the context. Cuts and compact cuts. Consider some connected graph G. An r-way cut C of G is a partition of V (G) to r pairwise disjoint subsets, that is, C = {U1, . . . , Ur}, where S1≤i≤r Ui = V (G) and Ui ∩ Uj = ∅ for every i 6= j. The subsets U1, . . . , Ur are referred to as the clusters of C. A cut refers4 to an r-way cut for any r ≥ 2. Consider some r-way cut C = {U1, . . . , Ur} of G. We say that an edge e ∈ E (G) crosses C if e ∈ Ui × Uj for some i 6= j. The set of edges crossing C is denoted by E (C). The cardinality E (C) is referred to as the size of C; if the edges of G are assigned with positive costs c : E (G) → R>0, then the sumPe∈E (C) c(e) is referred to as the cost of C. The cut C is called compact if G(Ui) is connected for every 1 ≤ i ≤ r. Note that every r-way cut is a compact r′-way cut for some r′ ≥ r. A min cut (respectively, min cost cut) is a cut of minimum size (resp., cost). It is easy to verify that a min cut (resp., min cost cut) must be a compact 2-way cut. Consider some subset F ⊆ E (G) and a compact cut C of G. We say that F induces the cut C if the connected components of the graph obtained from G by removing the edges in F agree with the clusters of C. In particular, F must be a superset of E (C); it may contain additional edges as long as the removal of these edges does not disconnect any cluster of C. 4In some literature, a cut refers to a 2-way cut, while an r-way cut for r > 2 is called a multiway cut. We do not make this distinction. 6 Analogy to the all-terminal network reliability problem. Consider some BCW graph G and some distance-cumulative weighted graph property X . Suppose that we wish to approximate e = 0} and let G0 be the restriction of G to the probability that X (G) > 0. Let E0 = {e ∈ E (G) W L the edges in E0. Requirement (R6) implies that the event X (G) > 0 depends only on the probability space E0; specifically, X (G) > 0 if and only if X (G0) > 0. Moreover, if G0 is disconnected, then X (G0) = ∞ with probability 1, thus we subsequently assume that G0 is connected. By employing requirement (R6) once more, we conclude that X (G0) > 0 if and only if the edges that take on their heavy (positive) phases under the probability space E0 induce a cut on G0. This leads us to an analogy between the problem of approximating P(X (G) > 0) and the all-terminal network reliability (ATNR) problem. The input to ATNR is a connected undirected graph H in which each edge e fails (i.e., removed) with some specified probability. The goal is to compute the probability, referred to as the failure probability of H and denoted FAIL(H), that H becomes disconnected following such an edge failure experiment. ATNR is known to be ♯P-complete [34, 3] and Karger develops an FPRAS for it [24]. Since H becomes disconnected if and only if the failing edges induce a cut on it, we conclude that P(X (G0) > 0) = FAIL(G0), where the latter is defined over an instance of ATNR in which each edge e ∈ E (G0) fails with probability pe (the probability that e takes on its heavy phase in the BCW graph framework). Consequently, approximating P(X (G) > 0) can be performed by a direct application of Karger's algorithm. of X and fix ¯X =Pn Monte Carlo method and approximators. Consider some probability space with sample space Ω and let X : Ω → R be a real valued random variable over this probability space. Suppose that the expectation of X is defined and denote it by µ. Let X1, . . . , Xn be n independent samples i=1 Xi/n. Evaluating µ by ¯X is referred to as the Monte Carlo method (cf. [26]). Let ǫ and ǫ be some positive reals. The following two theorems are direct consequences of Chernoff's inequality [10] (Theorem 2.1) and Hoeffding's inequality [21] (Theorem 2.2). Theorem 2.1. If X is an indicator random variable (namely, X ∈ {0, 1}), then taking n ≥ 4 ln(2/ǫ)µ/ǫ2 samples guarantees that P( ¯X − µ > ǫ) ≤ ǫ. Theorem 2.2. If X is almost surely in the interval [a, b], where b − a = ρ, then taking n ≥ ln(2/ǫ)ρ2/(2ǫ2) samples guarantees that P( ¯X − µ > ǫ) ≤ ǫ. This leads us to notion of approximators. Consider some non-negative real value v that we would like to approximate with the real v′. Then v′ is said to be an (ǫ, ǫ)-approximator of v if it satisfies the inequality v − v′ ≤ ǫ with probability at least 1 − ǫ, where the probability is taken over the randomness used to generate v′. Under this terminology, Theorems 2.1 and 2.2 provide sufficient conditions to guarantee that ¯X is an (ǫ, ǫ)-approximator of µ. Proposition 2.3. If v1 is an (ǫ1, ǫ1)-approximator of v0 and v2 is an (ǫ2, ǫ2)-approximator of v1, then v2 is an (ǫ1 + ǫ2, ǫ1 + ǫ2)-approximator of v0. Proposition 2.4. If v′ i is an (ǫ, ǫ)-approximator of vi for every 1 ≤ i ≤ n, then Pn i=1 v′ i/n is an 7 (ǫ, n · ǫ)-approximator ofPn i=1 vi/n. 3 An FPRAS for BCW graphs In this section we consider some n-vertex BCW graph G and some small performance parameter ǫ > 0; our goal is to approximate E[X k] to within a multiplicative error of 1+O(ǫ). Here, we restrict our attention to the case k = 1, that is, we approximate E[X]. Extending our result to larger (yet fixed) values of k is mainly a matter of notation and we omit it from this version of the paper. The approximation presented in this section builds upon the more sophisticated Procedure Estimate which is presented in Section 4. Theorem 3.1. There exists a randomized algorithm that with probability at least 3/4, approximates E[X] to within a multiplicative error of 1 + O(ǫ) in time poly(G, 1/ǫ). Let N be the smallest integer such that xmax < (1 + ǫ)N . (Note that N is proportional to log(xmax)/ǫ = poly(G, 1/ǫ)). Clearly, we have 0 ≤ X < (1 + ǫ)N . Fix πi = P(X ≥ (1 + ǫ)i) for every 0 ≤ i ≤ N . Towards the approximation of E[X], we first define A = = NXi=1 NXi=1 = π0 + (1 + ǫ)i−1 · P(cid:0)(1 + ǫ)i−1 ≤ X < (1 + ǫ)i(cid:1) (1 + ǫ)i−1 · [πi−1 − πi] N −1Xi=1 N −1Xi=1 ǫ · (1 + ǫ)i−1 · πi − (1 + ǫ)N −1 · πN ǫ · (1 + ǫ)i−1 · πi , = π0 + where (1) is due to the fact that πN = 0. It is easy to verify that E[X]/(1 + ǫ) ≤ A ≤ E[X] , (1) (2) so our next goal is to approximate A. Note that (1) enables the computation of a (1 + ǫ)- approximation of E[X] based on (1 + ǫ)-approximations of P(X ≥ x) for sufficiently many values of x. Unfortunately, we do not know how to obtain such an approximation directly and we are forced to apply some modifications to G. The shrunk graphs. Fix κ =llog1+ǫ(cid:16) n2(1+ǫ) ǫ (cid:17)m. For i = 0, 1, . . . , N − 1, let Gi be the BCW graph obtained from G by setting W ϕ e ← 0 for every edge e ∈ E (G) and phase ϕ ∈ {H , L} such that W ϕ e < (1 + ǫ)i−κ. We refer to a phase that was set to 0 in this process as a shrunk phase; the graphs G0, . . . , GN −1 are called the shrunk graphs. (Clearly, if the heavy phase of some edge is shrunk, then so is the light phase.) 8 Let Xi be the random variable that takes on X (Gi). Requirement (R2) guarantees that X0 ≥ X1 ≥ ··· ≥ XN −1. The assumption that the minimum positive phase is scaled to 1 implies that G = G0 = G1 = ··· = Gκ, hence X = X0 = X1 = ··· = Xκ. If i > κ, then Xi may be smaller than X, however it is not much smaller as depicted in the following proposition. Proposition 3.2. If X ≥ (1 + ǫ)i for some 0 ≤ i ≤ N − 1, then X/(1 + ǫ) < Xi ≤ X. Proof. Since phase W ϕ and (R4) guarantee that e < (1 + ǫ)i−κ ≤ (1 + ǫ)i · e shrinks in Gi only if W ϕ n2(1+ǫ) , requirements (R2) ǫ Xi > X − n2 · ǫ(1 + ǫ)i n2(1 + ǫ) > X − ǫX 1 + ǫ = X/(1 + ǫ) . The assertion follows. Fix π′ i = P(Xi ≥ (1 + ǫ)i) for every 0 ≤ i ≤ N − 1 and define A′ = π′ 0 + N −1Xi=1 ǫ · (1 + ǫ)i−1 · π′ i . Clearly, π′ we have i ≤ πi for every 0 ≤ i ≤ N − 1, thus A′ ≤ A. On the other hand, for every 1 ≤ i ≤ N − 1, π′ i−1 = P(Xi−1 ≥ (1 + ǫ)i−1) ≥ P(Xi ≥ (1 + ǫ)i−1) ≥ P(X ≥ (1 + ǫ)i) = πi , where the last inequality is due to Proposition 3.2. Since, π′ 0 = π0, we get A (1 + ǫ) π0 (1 + ǫ) π′ 0 (1 + ǫ) = ≤ + + = π′ 0 + = π′ 0 + N −1Xi=2 N −2Xi=1 ǫ · (1 + ǫ)i−2 · πi N −1Xi=1 N −1Xi=1 ǫ · (1 + ǫ)i−2 · π′ ǫ · (1 + ǫ)i−1 · π′ i ≤ A′ , ǫ · (1 + ǫ)i−2 · π′ i−1 i−1 therefore A/(1 + ǫ) ≤ A′ ≤ A . (3) So, our next goal is to approximate A′. 9 i i Relying on local approximators. Consider some n-vertex BCW graph H and denote the random variable that takes on X (H) by XH . Let δ, δ > 0 be some performance parameters. Recall that Karger's FPRAS for ATNR can be used to generate a real E >0 that serves as a (δ · P(XH > 0), δ)-approximator of P(XH > 0) in time poly(n, 1/δ, log(1/δ)) (see Section 2). In Section 4 we present Procedure Estimate that given some x > 0, runs in time poly(n, 1/δ, log(1/δ)) and returns a real E ≥x that serves as a (δ · P(XH > 0), δ)-approximator of P(XH ≥ x). Set the performance parameters δ ←(cid:16) ǫ n(1+ǫ)(cid:17)2 and δ ← 1/(8N ). For i = 0, 1, . . . , N − 1, we invoke Karger's FPRAS and our Procedure Estimate on H ← Gi with x ← (1 + ǫ)i to produce the and E ≥x → E ≥x local approximators E >0 → E >0 i = if i = 0; if 0 < i < N − κ; if N − κ ≤ i ≤ N − 1 How well does A′′ approximates A′? In attempt to answer this question, we first establish the following lemma. Lemma 3.3. With probability at least 3/4, we have (a) π′ (b) π′ Proof. By the choice of δ = 1/(8N ), we may use a union bound argument and conclude that the inequalities 0 for all 0 ≤ i ≤ κ; and i−κ for all κ < i ≤ N − 1. E >0 max{E ≥x E ≥x i − π′′ i − π′′ i ≤ δπ′ i ≤ δπ′ and A′′ = π′′ ǫ · (1 + ǫ)i−1 · π′′ i . We then define i ,E >0 i+κ} 0 + N −1Xi=1 π′′ 0 i . P(XH > 0) − E >0 ≤ δ · P(XH > 0) P(XH ≥ x) − E ≥x ≤ δ · P(XH > 0) (4) (5) hold (simultaneously) for all N invocations of Karger's FPRAS and Procedure Estimate with probability at least 3/4; the remainder of the proof is conditioned on that event. By the definition of the shrunk graphs, we have P(Xi > 0) = P(X0 ≥ 1) = π′ 0 for every 0 ≤ i ≤ κ (6) and P(Xi > 0) = P(Xi ≥ (1 + ǫ)i−κ) ≤ P(Xi−κ ≥ (1 + ǫ)i−κ) = π′ i−κ for every κ < i ≤ N − 1 . (7) Combining (6) and (4) implies that π′ 0 − π′′ 0 ≤ δπ′ 0 as required for i = 0. Next, (5) guarantees that P(Xi ≥ (1 + ǫ)i) − E ≥x i ≤ δ · P(Xi > 0) (8) 10 for every 0 ≤ i ≤ N − 1, while (4) guarantees that E >0 i+κ ≤P(Xi+κ > 0) + δ · P(Xi+κ > 0) ≤P(Xi ≥ (1 + ǫ)i) + δ · P(Xi+κ > 0) ≤P(Xi ≥ (1 + ǫ)i) + δ · P(Xi > 0) (9) (10) for every 0 ≤ i < N − κ, where (9) is due to (7) and (10) follows from the definition of the shrunk graphs. By combining (8) and (10), it follows that for every 0 < i < N − κ, we have P(Xi ≥ (1 + ǫ)i) − δ · P(Xi > 0) ≤ max{E ≥x i ,E >0 i+κ} ≤ P(Xi ≥ (1 + ǫ)i) + δ · P(Xi > 0) , or in other words, P(Xi ≥ (1 + ǫ)i) − max{E ≥x i ,E >0 i+κ} ≤ δ · P(Xi > 0) . i − π′′ This yields the desired π′ every κ < i < N − κ due to (7). It remains to show that π′ consequence of (8) and (7). i ≤ δπ′ 0 for every 0 < i ≤ κ due to (6); and π′ i − π′′ i ≤ δπ′ i−κ for i − π′′ i ≤ δπ′ i−κ for every N − κ ≤ i ≤ N − 1. This is a direct We are now ready to complete the analysis. Lemma 3.3 guarantees that A′ − A′′ = (cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ π′ ≤ δπ′ = δπ′ i )(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) π′ 0 − π′′ 0 + 0 + i − π′′ ǫ · (1 + ǫ)i−1 · (π′ N −1Xi=1 N −1Xi=1 ǫ · (1 + ǫ)i−1 · π′ i − π′′ 0 − π′′ i ǫ · (1 + ǫ)i−1# + 0"1 + N −1Xi=κ+1 κXi=1 ǫ · (1 + ǫ)i−1 · δπ′ 0(cid:20)1 + ǫ · (cid:21) + δ · (1 + ǫ)κ N −1Xi=κ+1 (1 + ǫ)κ − 1 i# ǫ · (1 + ǫ)i−1 · π′ ǫ i−κ = δ · (1 + ǫ)κ ·"π′ N −κ−1Xi=1 ≤ δ · (1 + ǫ)κ · A′ ≤ δ · 0 + ǫ · (1 + ǫ)i−κ−1 · π′ i−κ · A′ n(1+ǫ)(cid:17)2 with probability at least 3/4. By the choice of δ =(cid:16) ǫ Theorem 3.1 follows by combining the last inequality with (2) and (3). ǫ n2(1 + ǫ)2 , we conclude that A′ − A′′ ≤ ǫA′. 11 4 Procedure Estimate In this section we present and analyze Procedure Estimate. Let G be some n-vertex BCW graph and denote the random variable that takes on X (G) by X. Consider some positive real x and perfor- mance parameters ǫ, ǫ > 0. Given G and x, Procedure Estimate runs in time poly(n, 1/ǫ, log(1/ǫ)) and outputs an (ǫ · P(X > 0), ǫ)-approximator of P(X ≥ x). Recall that requirement (R3) implies that edges of zero weight can be contracted without affecting the value of X . This means that we may contract every edge e ∈ E (G) such that W H e = 0 without affecting P(X > 0) and P(X ≥ x). Indeed, in what follows we assume that W H e = W L e > 0 for all edges e ∈ E (G). Fix E = E (G). It will be convenient to partition the edges in E according to their light phases e > 0}. Let G0 be the restriction of to E0 = {e ∈ E W L G to the edges in E0. Recall that the event X = X (G) > 0 occurs if and only if X (G0) > 0 (see Section 2); denote the probability of this event by P0. Fix c = (5 +√17)/2 ≈ 4.56. If P0 is sufficiently large, specifically, at least n−c, then the desired e = 0} and to E − E0 = {e ∈ E W L approximation can be obtained by a direct Monte Carlo method. Indeed, Theorem 2.1 guarantees that a Monte Carlo method with O(log(1/ǫ)nc/ǫ2) = poly(n, 1/ǫ, log(1/ǫ)) trials suffices to generate an (ǫ· P0, ǫ)-approximator of P(X ≥ x). (The random variable for which we apply the Monte Carlo method is simply the indicator of the event X ≥ x.) This applies in particular to the case where G0 is disconnected which means that P0 = 1. Therefore in what follows we may assume that P0 < n−c and in particular, that G0 is connected. Note that if P0 is extremely small (e.g., exponentially small in n), then the above Monte Carlo method requires too many samples in order to obtain an (ǫ · P0, ǫ)-approximator of P(X ≥ x). Dealing with small P0. How do we efficiently generate an (ǫ · P0, ǫ)-approximator of P(X ≥ x) when P0 is small? For that purpose we introduce the real valued random variable Y which is defined over the probability space E − E0 by mapping each instance I : E − E0 → {H , L} to P(X ≥ x I), namely, I is mapped to the probability that X (G) is at least x conditioned on I. This can be viewed as decomposing the probability space E into the Cartesian product of the probability spaces E − E0, from which I is chosen, and E0, over which P(X ≥ x I) is defined. A crucial observation here is that E[Y ] = XI:E−E0→{H ,L} = XI:E−E0→{H ,L} = P(X ≥ x) , P(I) · P(X ≥ x I) P(X ≥ x ∧ I) 12 hence our goal is to provide a good approximation for E[Y ]. Another important observation is that P(X ≥ x I) ≤ P(X > 0 I) = P(X > 0) = P0 for every instance I : E − E0 → {H , L} (recall that the event X > 0 does not depend on the probability space E − E0), therefore Y ∈ [0, P0] with probability 1. Fix k = 2 ln(4/ǫ)/ǫ2 and repeat the following process for j = 1, . . . , k. Choose some instance Ij : E − E0 → {H , L} with probability P(Ij) (this can be easily generated by randomly choosing the phase of each edge in E − E0 independently of all other edges) and let Yj = P(X ≥ x Ij); in other words, Yj is a random sample of Y . Unfortunately, we do not know how to efficiently compute the exact value of Yj for a given instance Ij. Instead, we will generate an approximate sample Y ′ j which is an (ǫ · P0/2, ǫ/(2k))-approximator of Yj. We will soon explain how the Y ′ j s are generated, but first let us explain how they are employed to obtain the desired (ǫ · P0, ǫ)-approximator of E[Y ]. Let ¯Y =Pk j /k. Theorem 2.2 guarantees that ¯Y is an (ǫ · P0/2, ǫ/2)-approximator of E[Y ]. By Proposition 2.4, we conclude that ¯Y ′ is an (ǫ · P0/2, ǫ/2)-approximator of ¯Y . Therefore Proposition 2.3 implies that ¯Y ′ is an (ǫ · P0, ǫ)-approximator of E[Y ] = P(X ≥ x) as required. j=1 Yj/k and ¯Y ′ =Pk j=1 Y ′ It remains to present the process through which the Generating the approximate samples. approximate samples Y ′ j are generated (recall that each approximate sample should be an (ǫ · P0/2, ǫ/(2k))-approximator of P(X ≥ x I) for some given instance I : E − E0 → {H , L}). The technique we use for this process is an extension of Karger's technique [24]. In order to simplify the description of this process, we first assume that there exists some real p such that pe = p for all edges e ∈ E0 (all these edges have zero light phase, however their heavy phases may vary). This assumption is removed later on. Given some compact cut C of G0, let H(C) denote the event that all edges in E (C) ⊆ E0 take on their heavy (positive) phases. Let C be some min cut of G0 and let χ = E (C) be its size. Since P(H(C)) = pχ, the assumption that P0 < n−c implies that pχ < n−c. The following two theorems are established in [24] for the case of 2-way cuts. Building upon the recent bound of Berend & Tassa on the Bell number [5], we extend them to (compact) r-way cuts for all r ≥ 2 simultaneously. Theorem 4.1. For every real α ≥ 1, there are less than 13n2α compact cuts of size at most αχ in G0. Moreover, these cuts can be enumerated in expected time O(n2α). Proof. The theorem is established by presenting a random process that generates each compact cut of size at most αχ in G0 with probability greater than 1 13 n−2α. Observe first that if an r-way cut C satisfies E (C) ≤ αχ, then r must be at most 2α as otherwise there exists some cluster U of C with less than χ edges crossing between U and V (G0) − U , in contradiction to the assumption that χ is the size of a min cut of G0. 13 Fix k = ⌈2α⌉. Our random process first performs random edge contractions in G0 until k vertices v1, . . . , vk remain in the graph (cf. Section 2.2.1 in [24]); each vertex vi corresponds to some subset Vi ⊆ V (G0) so that {V1, . . . , Vk} is a partition of V (G0) (the subgraph induced on G0 by Vi is connected). We then take P = {W1, . . . , Wℓ}, 1 ≤ ℓ ≤ k, to be a partition of {v1, . . . , vk} chosen uniformly at random out of the Bk possible partitions of {v1, . . . , vk}, where Bk is the kth Bell number. The cut bC = {U1, . . . , Uℓ} generated by our random process is defined by setting Uj =S{Vi vi ∈ Wj} for j = 1, . . . , ℓ. It is important to note that bC is not necessarily a compact cut, however, if C is any compact cut of size at most αχ in G0, then it can be generated by our random process. Our goal in the remainder of this proof is to show that C is indeed generated with probability greater than 1 13 n−2α. Karger [24] shows that the probability that none of the edges crossing C is contracted during the random edge contractions is at least (cid:18)1 − 2α n (cid:19)(cid:18)1 − 2α n − 1(cid:19) ···(cid:18)1 − 2α 2α(cid:1)(cid:0) n k + 1(cid:19) = (cid:0) k 2α(cid:1) , where generalized binomial coefficients5 are used when 2α is not an integer. It remains to prove that ( k 2α) ( n 2α) B−1 k > 1 13 n−2α. Indeed, (cid:0) k 2α(cid:1)(cid:0) n 2α(cid:1) B−1 k B−1 k ≥ (cid:18) k > (cid:18) k > n−2α · 2α(cid:19)2α(cid:18) 2α en(cid:19)2α en(cid:19)2α(cid:18) ln(k + 1) 0.792k (cid:19)k k(cid:18) ln(k + 1) 0.792e (cid:19)k 1 (11) , where inequality 11 is due to Berend & Tassa [5]. The assertion follows as 1 k ≥ 2. Theorem 4.2. For every real α ≥ 1, the probability that there exists some compact cut C of size at least αχ in G0 such that H(C) occurs is O(n−αη), where η is defined by fixing pχ = n−(2+η). 13 when > 1 k(cid:16) ln(k+1) 0.792e (cid:17)k Proof. Let C1, . . . , Ct be the compact cuts of size at least αχ and for each 1 ≤ i ≤ t, let χi = E (Ci). We assume without loss of generality that αχ ≤ χ1 ≤ ··· ≤ χt. Denote pi = pχi = P(H(Ci)) and consider some real β ≥ 1. By Theorem 4.1, there are less than 13n2β compact cuts of size at most βχ. It follows that χ13n2β must be greater than βχ. 5Generalized binomial coefficients are a generalization of the standard binomial coefficients (cid:0)x y(cid:1) to non-integral x and y. This generalization is based on replacing the factorial in the standard definition with the Gamma function. Many of the identities and bounds that hold for the standard binomial coefficients also hold in the generalized case, including the bounds (cid:16) x y (cid:17)y y(cid:17)y . ≤ (cid:0)x y(cid:1) ≤ (cid:16) ex 14 We shall bound the probability that H(Ci) occurs for some (at least one) 1 ≤ i ≤ t by bounding i=1 pi. The first t′ = 13n2α+1/ ln(n) terms are bounded simply by observing that the sumPt t′Xi=1 pi ≤ 13n2α+1/ ln(n) · pαχ = 13e · n2α · n−α(2+η) = 13e · n−αη . ln(s)−ln(13) Thus it remains to bound the remaining t − t′ terms. Given some β ≥ α, we write s = 13n2β+1/ ln(n) and conclude that χs > (cid:16)β + 1 = s−(1+η/2) · 131+η/2 . · χ. Therefore ps < (pχ) ln(s)−ln(13) ln(s)−ln(13) 2 ln n 2 2 ln(n)(cid:17) χ = Summing over all i > t′, we get (cid:17)−(2+η) Xi>t′ 2 ln n =(cid:16)e 2 ln n =(cid:16)n−(2+η)(cid:17) ln(s)−ln(13) pi < 131+η/2 ·Xs>t′ ≤ 131+η/2 ·Z ∞ = 131+η/2 ·(cid:18)−(η/2) · s−η/2(cid:12)(cid:12)(cid:12)(cid:12) s−(1+η/2)ds s−(1+η/2) ∞ 13n2α+1/ ln(n)(cid:19) = 131+η/2 · (η/2) · 13−(η/2) · n−αη · e−η/2 ≤ 13 · n−αη . t′ The assertion follows. Notice that the compact cuts addressed in Theorems 4.1 and 4.2 may have an arbitrary number of clusters, but their size is compared to αχ, where χ is the size of the smallest 2-way cut in G0. This point is crucial for the validity of the arguments. Write pχ = n−(2+η). We must have η > c − 2 as pχ < n−c. Fix α = c−1+ln(1/ǫ)/ ln(n) and let C be the collection of all compact cuts of size at most αχ in G0. By Theorem 4.1, C consists of O(n2α) = O(nc−1/ǫ) compact cuts that can be enumerated in expected time O(nc−1/ǫ). 2 Given some sub-collection B ⊆ C, let ψ(B) = P _C∈B H(C)! be the probability that all crossing edges of some (at least one) cut in B take on their heavy phases. Theorem 4.2 guarantees that 0 ≤ P0 − ψ(C) ≤ γn−αη for some universal constant γ. The choice of c = (5 + √17)/2 and of α = c−1+ln(1/ǫ)/ ln(n) and the assumption that η > c − 2 ensure that γn−αη ≤ ǫn−(2+η)/4 = ǫpχ/4 as long as (4γ)4 ≤ (1/ǫ)c−4, which yields the following corollary. Corollary 4.3. The probability that there exists some compact cut C /∈ C such that H(C) occurs is at most ǫpχ/4 ≤ ǫ · P0/4. 2 15 Consider some instance I : E − E0 → {H , L}. Our goal is to efficiently generate an (ǫ · P0/2, ǫ/(2k))-approximator of P(X ≥ x I). For a given compact r-way cut C = {U1, . . . , Ur} of G0, we construct the graph GC,I as follows. The vertex set of GC,I is V (GC,I ) = {u1, . . . , ur}. For every edge e ∈ E0 with one endpoint in the cluster Ui and the other in the cluster Uj, i 6= j, we e . In addition, for every edge e ∈ E − E0 with add an edge (ui, uj) to E (GC,I ) whose weight is W H one endpoint in the cluster Ui and the other in the cluster Uj, i 6= j, we add an edge (ui, uj) to E (GC,I ) whose weight is W I(e) Observation 4.4. Conditioned on the instance I : E − E0 → {H , L}, and on the event that the set of edges in E0 that take on their heavy phases induces the compact r-way cut C on G0, we have X (GC,I ) = X. . The following observation is due to requirement (R3). e Let BI be the collection of all compact cuts C of G0 such that X (GC,I ) ≥ x. Observation 4.4 implies that P(X ≥ x I) = ψ(BI ). By Corollary 4.3, we know that ψ(BI −C) ≤ ǫ·P0/4, and hence ψ(BI ) − ǫ · P0/4 ≤ ψ(BI ∩ C) ≤ ψ(BI ). Consequently, it suffices to generate an (ǫ · P0/4, ǫ/(2k))- approximator of ψ(BI ∩ C). Probabilistic DNF satisfiability. The approximation of ψ(BI ∩C) is performed by the method of Karp, Luby, and Madras [26, 27] for approximating the probability that a formula in disjunctive normal form (DNF) is satisfied. Given some DNF formula φ, and given the probability qi that xi is assigned to true for each variable xi (independently of all other variables), the method of Karp et al. generates a (δ · q(φ), δ)-approximator of the probability q(φ) that φ is satisfied in time O(φ log(1/δ)/δ2), where φ stands for the size of the formula (number of literals). Cast into that framework, the event WC∈BI ∩C H(C) is encoded as a DNF formula whose vari- ables correspond to whether or not the edges in E0 take on their heavy phases and whose clauses correspond to the cuts in BI ∩C. Such a DNF formula has BI ∩C ≤ C = O(nc−1/ǫ) clauses, each with at most n literals. Therefore an (ǫ· ψ(BI ∩C)/4, ǫ/(2k))-approximator of ψ(BI ∩C), which also serves as an (ǫ · P0/4, ǫ/(2k))-approximator of ψ(BI ∩C) since ψ(BI ∩ C) ≤ P0, can be generated in time O(log(k/ǫ)nc/ǫ3) = poly(n, 1/ǫ, log(1/ǫ)). Varying heavy phase probabilities. Recall that in attempt to simplify the description of the process that generates approximate samples of the random variable Y , we assumed that pe = p for all edges e ∈ E0. We now turn to lift this assumption. The technique we use here is essentially identical to that used by Karger [24] for a similar purpose; we describe it for completeness. The BCW graph G0 with varying heavy phase probabilities 0 < pe < 1 is transformed into a BCW graph H, V (H) = V (G0), with uniform heavy phase probabilities p = 1 − θ for some sufficiently small θ > 0. For each edge e = (u, v) ∈ E0 with heavy phase probability 0 < pe < 1, we introduce a bundle of ke = ln(1/pe)/θ parallel (u, v) edges in H with the same heavy and light phases as e (recall that the light phase of e is zero). The probability that all ke edges in this bundle 16 take on their heavy phase is (1 − θ)ln(1/pe)/θ which converges to pe as θ → 0. By requirement (R4), it is sufficient to generate approximate samples for the random variable Y with respect to the graph H in the limit as θ → 0. The technique we introduced earlier in this section is suitable for that as H has uniform heavy phase probabilities. In particular it is sufficient to enumerate all the small compact cuts C of H, identify those inducing X (GC,I ) ≥ x for a given instance I : E−E0 → {H , L}, and then approximate the probability that all crossing edges of at least one of them take on their heavy phases. Note that changing the parameter θ scales the size of cuts in H without changing their relative sizes. We construct a graph H ′, V (H ′) = V (G0), with positive costs on the edges by assigning cost ln(1/pe) to each edge e ∈ E0 (the phases of the edges in E0 are ignored in the context of H ′). The small cost cuts in H ′ correspond to the small sized cuts in H; they can be enumerated by known techniques. Given the small cuts in H that induce X (GC,I ) ≥ x, we have to approximate the probability, as θ → 0, that all crossing edges of at least one of them take on their heavy phases. We already argued that this is exactly the probability that all crossing edges of at least one of the corresponding cuts in G0 take on their heavy phases. Approximating this probability is done as before by constructing the appropriate DNF formula and employing the method of Karp et al. [26, 27]. 5 Transforming RW graphs into BCW graphs So far, we have developed an approximation for E[X (G)k], where G is a BCW graph. In this section we are interested in extending our algorithm to the (general) case of RW graphs. This extension relies on an efficient transformation of any RW graph G into a BCW graph G′ such that the random variable X (G′) is stochastically equivalent to the random variable X (G) and G′ = O(G). This is similar to a method presented by Mirchandani [30] (see also [3]). positive integer m(e) and some non-negative phases W 1 Let G be an arbitrary RW graph and consider some edge e ∈ E (G). Recall that there exists some e, . . . , pm(e) , e e (independently of all other edges). We assume without loss of generality that if m(e) > 2, then the phases of e are distinct (identical phases can be merged into one) and ordered so that W 1 wherePm(e) e = 1, such that w (e) = W i e with probability pi and probabilities p1 i=1 pi e , . . . , W m(e) e e < ··· < W m(e) e . The BCW graph G′ is obtained by replacing every edge e = (u, v) ∈ E (G) such that m(e) > 2 with m(e) − 1 parallel edges e1, . . . , em(e)−1 = (u, v) ∈ E (G′), each having exactly two phases. The heavy phases of all new edges are set to be W m(e) e for every 1 ≤ i ≤ m(e) − 1. The probabilities p(e1), . . . , p(em(e)−1) are designed to guarantee that the random variable Me = min{w (e1), . . . , w (em(e)−1)} in G′ is stochastically equivalent to the random . The light phase of ei is set to be W L ei = W i e 17 variable w (e) in G. This is achieved by setting p(ei) = 1 − Indeed, for every 1 ≤ i ≤ m(e), we have pi e j=1 pj e 1 −Pi−1 P(Me = W i e) = i−1Yj=1 p(ej) · (1 − p(ei)) = i−1Yj=1 e j=1 pj j=1 pj e . = 1 −Pi 1 −Pi−1 1 −Pj 1 −Pj−1 l=1 pl e e · l=1 pl = pi e , pi e j=1 pj e 1 −Pi−1 where the last equation holds by telescoping. Requirement (R4) implies that X (G′) is stochastically equivalent to X (G). Theorem 1 now follows (at least when k = 1) from Theorem 3.1. 6 Hardness In this section we prove that the problem of computing the expected diameter of an RW graph is #P-hard. The problem remains #P-hard even when restricted to identically distributed weighted graphs. Our line of arguments immediately implies that computing the radius of an identically distributed weighted graph with respect to a designated vertex is also #P-hard. Hardness is established by reduction from the most basic variant of the two terminal network reliability (TTNR) problem defined as follows. On input connected graph G and two vertices s, t ∈ V (G), the goal is to compute the probability P that s and t become disconnected when each edge in E (G) is removed with probability 1/2 independently of all other edges. The #P-hardness of TTNR is established by Valiant [34]. Since the support of P consists of integer multiples of 2−m, where m = E (G), we conclude that it is #P-hard to approximate P to within a one-sided additive error of ǫ for any ǫ < 2−m. Given a graph G with two vertices s, t ∈ V (G) as input of TTNR, we construct an identically distributed weighted graph G′ with parameters p = 1/2, W H = 1, and W L = 0. G′ is obtained from G by adding a new edge e = (s, t) and augmenting the resulting graph with two simple paths, one connecting s to the new vertex s′ and the other connecting t to the new vertex t′. Each new simple path consists of k = Θ(m) new vertices. The reduction is cast in the following lemma. Lemma 6.1. Let D be the random variable that takes on diam(G′). Then P ≤ 2(E[D] − k) < P + 2−m. Proof. Let D′ be the random variable that takes on distG′(s′, t′). By definition, we know that D′ ≤ D with probability 1. We shall take k to be sufficiently large so that Chernoff's inequality implies that P(distG′(s′, s) < n ∨ distG′(t, t′) < n) < 2−(m+1)/n, where n = V (G). By the construction of G′, it follows that P(D > D′) < 2−(m+1)/n. Since D − D′ < n, we conclude that 0 ≤ E[D] − E[D′] < 2−(m+1). 18 By the linearity of expectation, we have E[D′] = E[distG′(s′, s)] + E[dist(s, t)] + E[distG′(t, t′)] = k + E[dist(s, t)] , where the last term can be rewritten as E[dist(s, t)] = E[dist(s, t) w (e) = 1] · P(w (e) = 1) + E[dist(s, t) w (e) = 0] · P(w (e) = 0) = E[dist(s, t) w (e) = 1]/2 . The assertion is established by arguing that E[dist(s, t) w (e) = 1] = P . Indeed, when w (e) = 1, then distG′(s, t) ∈ {0, 1}. The argument holds since the distG′(s, t) = 0 instances (respectively, the distG′(s, t) = 1 instances) of the probability space E (G′) correspond to the instances of TTNR in which s and t remain connected (resp., become disconnected). 7 Conclusions We study the setting of graphs whose edge weights are independent random variables and show that for the wide family of distance-cumulative weighted graph properties, the problem of computing the kth moment admits an FPRAS. Computing the expectation (i.e., the first moment) for example is difficult when the variance is large, and hence too many samples are required for the Monte Carlo method in order to take into account low probability events6 that may drastically affect the expectation. Our technique does not guarantee a (multiplicative) approximation for the kth central moment (and in particular, the variance) when this is close to zero, however, it does provide us with the ability to decide if the kth central moment is close to zero. There are still some fundamental weighted graph properties which are not distance-cumulative, and hence cannot be dealt with via our technique, such as the shortest (s, t)-path and the weight of a maximum matching. It is also natural to consider the directed analogue of randomly weighted graphs and in particular, various network flow problems. Another aspect that calls for further research, once encoding issues are resolved, is that of continuous distributions for the edge weights. Acknowledgment We would like to thank Noga Alon for helpful discussions. References [1] C. Alexopoulos and J.A. Jacobson. State space partition algorithms for stochastic systems with appli- cations to minimum spanning trees. Networks, 35(2):118 -- 138, 2000. 6Events occurring with probability which is low with respect to the limited computational resources of our algo- rithm are still expected to occur in practice if the network in hand (say, the Internet) is being used very frequently. 19 [2] N. Alon, A. Frieze, and D. Welsh. Polynomial time randomized approximation schemes for Tutte- Grothendieck invariants: the dense case. Random Struct. Algorithms, 6(4):459 -- 478, 1995. [3] M.O. Ball, C.J. Colbourn, and J.S. Provan. Network reliability. Handbook of Operations Research: Network Models, pp. 673 -- 762, Elsevier North-Holland, 1995. [4] N. Banerjee, M.D. Corner, and B.N. Levine. An energy-efficient architecture for DTN throwboxes. In Proc. IEEE Infocom, 2007. [5] D. Berend and T. Tassa. Improved bounds on Bell numbers and on moments of sums of random variables. To appear in Probability and Mathematical Statistics. [6] D.J. Bertsimas and G. van Rysin. An asymptotic determination of the minimum spanning tree and minimum matching constants in geometrical probability. Oper. Res. Lett., 9:223 -- 231, 1990. [7] A. Beveridge, A.Frieze, and C. McDiarmid. Random minimum length spanning trees in regular graphs. Combinatorica, 18:311 -- 333, 1998. [8] B. Bollob´as. Modern Graph Theory. Graduate texts in mathematics, Springer-Verlag, Berlin, New York, 1998. [9] S. Burleigh, A. Hooke, L. Torgerson, K. Fall, V. Cerf, B. Durst, K. Scott, and H. Weiss. Delay-tolerant networking: an approach to interplanetary internet. IEEE Communications Magazine, 41(6):128 -- 136, 2003. [10] H. Chernoff. A measure of asymptotic efficiency for tests of a hypothesis based on the sum of observa- tions. Annals of Mathematical Statistics, 23(4):493 -- 507, 1952. [11] C. Cooper, A.M. Frieze, K. Mehlhorn, and V. Priebe. Average-case complexity of shortest-paths prob- lems in the vertex-potential model. Random Struct. Algorithms, 16(1):33 -- 46, 2000. [12] S. Even. Graph Algorithms. Computer Science Press, 1979. [13] K. Fall. A delay-tolerant network architecture for challenged internets. In Proc. ACM SIGCOMM, pages 27 -- 34, 2003. [14] A.M. Frieze. On the value of a random minimum spanning tree problem. Discrete Appl. Math., 10:47 -- 56, 1985. [15] A.M. Frieze and G.R. Grimmett. The shortest-path problem for graphs with random arc-lengths. Dis- crete Appl. Math., 10:57 -- 77, 1985. [16] A.M. Frieze and C. McDiarmid. Algorithmic theory of random graphs. Random Struct. Algorithms, 10(1-2):5 -- 42, 1997. [17] D.R. Fulkerson. Expected critical path lengths in PERT Networks. Oper. Res., 10:808 -- 817, 1962. [18] L.A. Goldberg and M. Jerrum. Inapproximability of the Tutte polynomial. Inf. Comput., 206(7):908 -- 929, 2008. [19] R. Hassin and A. Tamir. On the minimum diameter spanning tree problem. Inf. Process. Lett., 53(2):109 -- 111, 1995. [20] R. Hassin and E. Zemel. On shortest paths in graphs with random weights. Mathematics of Operations Research, 10(4):557 -- 564, 1985. 20 [21] W. Hoeffding. Probability inequalities for sums of bounded random variables. J. American Statistical Association, 58(301):13 -- 30, 1963. [22] A. Jain and J.W. Mamer. Approximations for the random minimal spanning tree with applications to network provisioning. Oper. Res., 36:575 -- 584, 1988. [23] S. Janson. One, two and three times logn/n for paths in a complete graph with random weights. Combinatorics, Probability and Computing, 8:347 -- 361, 1999. [24] D.R. Karger. A randomized fully polynomial time approximation scheme for the all-terminal network reliability problem. SIAM J. Comput. (SICOMP), 29(2):492 -- 514, 1999. [25] D.R. Karger, D. Koller, and S.J. Phillips. Finding the hidden path: time bounds for all-pairs shortest paths. SIAM J. Comput. (SICOMP), 22(6):1199 -- 1217, 1993. [26] R.M. Karp and M. Luby. Monte-Carlo algorithms for the planar multiterminal network reliability prob- lem. J. Complexity (JC), 1(1):45 -- 64, 1985. [27] R.M. Karp, M. Luby, and N. Madras. Monte-Carlo approximation algorithms for enumeration problems. J. Algorithms, 10(3):429 -- 448, 1989. [28] V.G. Kulkarni. Minimal spanning trees in undirected networks with exponentially distributed arc weights. Networks, 18(2):111 -- 124, 1988. [29] U. Mayer. Average-case complexity of single-source shortest-paths algorithms: lower and upper bounds. J. Algorithms, 48(1):91 -- 134, 2003. [30] P.B. Mirchandani. Shortest distance and reliability of probabilistic networks. Comp. Oper. Res., 3:347 -- 355, 1976. [31] J. Partan, J. Kurose, and B.N. Levine. A survey of practical issues in underwater networks. ACM SIGMOBILE Mobile Computing and Communications Review, 11(4), 2007. [32] T.L. Snyder and J.M. Steele. Probabilistic networks and network algorithms. Handbook of Operations Research: Network Models, pp. 401 -- 424, Elsevier North-Holland, 1995. [33] J.M. Steele. On Frieze's ζ(3) limit for lengths of minimal spanning trees. Discrete Appl. Math., 18:99 -- 103, 1987. [34] L.G. Valiant. The complexity of enumeration and reliability problems. SIAM J. Comput. (SICOMP), 8(3):410 -- 421, 1979. [35] X. Zhang, J. Kurose,B.N. Levine, D. Towsley, and H. Zhang. Study of a bus-based disruption-tolerant network: mobility modeling and impact on routing. In Proc. ACM MobiCom, 2007. 21 APPENDIX A High critical ratio Consider the identically distributed weighted graph G consisting of 2 vertices and m parallel edges connecting them, where each edge is of weight 1 with probability 1/2; and of weight 22m otherwise. Let X denote the random variable that takes on the diameter of G. It is easy to verify that E[X] ≈ 2m, while Var[X] ≈ 23m, so the critical ratio here is roughly 2m. Indeed, a Monte Carlo method with significantly less than 2m samples would probably estimate the expected diameter of G to be 1 which is an awful approximation. i
1607.04829
2
1607
2016-08-01T05:58:40
Logic Programming with Graph Automorphism: Integrating naut with Prolog (Tool Description)
[ "cs.DS" ]
This paper presents the plnauty~library, a Prolog interface to the nauty graph-automorphism tool. Adding the capabilities of nauty to Prolog combines the strength of the "generate and prune" approach that is commonly used in logic programming and constraint solving, with the ability to reduce symmetries while reasoning over graph objects. Moreover, it enables the integration of nauty in existing tool-chains, such as SAT-solvers or finite domain constraints compilers which exist for Prolog. The implementation consists of two components: plnauty, an interface connecting \nauty's C library with Prolog, and plgtools, a Prolog framework integrating the software component of nauty, called gtools, with Prolog. The complete tool is available as a SWI-Prolog module. We provide a series of usage examples including two that apply to generate Ramsey graphs. This paper is under consideration for publication in TPLP.
cs.DS
cs
Logic Programming with Graph Automorphism: Integrating nauty with Prolog (Tool Description)∗ 1 Michael Frank and Michael Codish Department of Computer Science Ben-Gurion University of the Negev (e-mail: {frankm,mcodish}@cs.bgu.ac.il) Beer-Sheva, Israel Abstract This paper presents the pl-nauty library, a Prolog interface to the nauty graph-automorphism tool. Adding the capabilities of nauty to Prolog combines the strength of the "generate and prune" approach that is commonly used in logic programming and constraint solving, with the ability to reduce symmetries while reasoning over graph objects. Moreover, it enables the integration of nauty in existing tool-chains, such as SAT-solvers or finite domain constraints compilers which exist for Prolog. The implementation consists of two components: pl-nauty, an interface connecting nauty's C library with Prolog, and pl-gtools, a Prolog framework integrating the software component of nauty, called gtools, with Prolog. The complete tool is available as a SWI-Prolog module. We provide a series of usage examples including two that apply to generate Ramsey graphs. This paper is under consideration for publication in TPLP. 1 Introduction Many problems, particularly in combinatorics, reduce to asking whether some graph with a given property exists, or alternatively, asking how many such non-isomorphic graphs exist. Such graph search and graph enumeration problems are notoriously difficult, in no small part due to the extremely large number of symmetries in graphs. In practical prob- lem solving, it is often advantageous to eliminate these symmetries which arise naturally due to graph isomorphism: typically, if a graph G is a solution then so is any other graph G(cid:48) that is isomorphic to G. General approaches to graph search problems typically involve either: generate and test, explicitly enumerating all (non-isomorphic) graphs and checking each for the given property, or constrain and generate, encoding the problem for some general-purpose dis- crete satisfiability solver (i.e. SAT, integer programming, constraint programming), which does the enumeration implicitly. In the explicit approach, one typically iterates, repeat- edly applying an extend and reduce approach: First extend the set of all non-isomorphic graphs with n vertices, in all possible ways, to graphs with n + 1 vertices; and then re- duce the extensions to their non-isomorphic (canonical) representatives. In the constraint based approach, one typically first encodes the problem and then applies a constraint solver in order to produce solutions. The (unknown) graph is represented in terms of ∗ Supported by the Israel Science Foundation, grant 182/13. 2 Michael Frank and Michael Codish Boolean variables describing it as an adjacency matrix A. The encoding is a conjunction of constraints that constitute a model, ϕA, such that any satisfying assignment to ϕA is a solution to the graph search problem. Typically, symmetry breaking constraints (Craw- ford et al. 1996; Codish et al. 2013) are added to the model to reduce the number of isomorphic solutions, while maintaining the correctness of the model. It remains unknown whether a polynomial time algorithm exists to decide the graph isomorphism problem. Nevertheless, finding good graph isomorphism algorithms is crit- ical when exploring graph search and enumeration problems. Recently an algorithm was published by Babai (2015) which runs in time O (exp (logc(n))), for some constant c > 1, and solves the graph isomorphism problem. Nevertheless, top of the line graph isomor- phism tools use different methods, which are, in practice, faster. McKay (1981) introduces an algorithm for graph canonization, and its implementation, called nauty (which stands for no automorphisms, yes? ), is described in (McKay 1990). In contrast to earlier works, where the canonical representation of a graph was typically defined to be the smallest graph isomorphic to it (in the lexicographic order), nauty introduced a notion which takes structural properties of the graph into account. For details on how nauty defines canonicity and for the inner workings of the nauty algorithm see (McKay 1981; McKay 1990; Hartke and Radcliffe 2009; McKay and Piperno 2014). In recent years nauty has gained a great deal of popularity and success. Other, similar tools, are bliss (Junttila and Kaski 2007) and saucy (Darga et al. 2004). The nauty graph automorphism tool consists of two main components. (1) a C library, nauty, which may be linked to at runtime, that contains functions applicable to find the canonical labeling of a graph, and (2) a collection of applications, gtools, that implement an assortment of common tasks that nauty is typically applied to. When downloading the tool both components are included. During compilation static library files are created for the C library. These files may be linked to at runtime, and header files are provided which may be included in foreign C code. During compilation, the applications of gtools are compiled into a set of command line applications. This paper presents a lightweight Prolog interface to both components of nauty which we term pl-nauty and pl-gtools. The implementation of pl-nauty is by direct use of Prolog's foreign language interface. The implementation of pl-gtools is slightly more complex. Each gtools application is run as a child process with the input and output controlled via unix pipes. The pl-gtools framework provides a set of general predicates to support this type of application integration. The integration of nauty into Prolog facilitates programming with the strengths of the two paradigms: logic programming for solving graph search problems on the one hand, and efficient pruning of (intermediate) solutions modulo graph isomorphism, on the other. It enables Prolog programs which address graph search problems to apply nauty natively, through Prolog, in the process of graph search and enumeration. Graphs may be generated non-deterministically and may be canonized deterministically. It also facilitates the interaction with various graph representations: those used in nauty, and those more natural for use with Prolog. The interface for nauty from within Prolog combines well also with other tools and techniques typically applied when addressing graph search problems, such as constraint and SAT based programming. For example, recent work (Codish et al. 2016), presents a computer-based proof that the Ramsey number R(4, 3, 3) = 30, thus closing a long Logic Programming with Graph Automorphism 3 open problem concerning the value of R(4, 3, 3). That paper made extensive use of SAT solvers, symmetry breaking techniques, and the nauty library. It was this experience that led us to implement pl-nauty. The remaining sections of this paper are organized in the following manner: Section (2) introduces the definitions used throughout the paper, as well as the running example of Ramsey graphs. Section (3) introduces the core of the pl-nauty library by examples. Section (4) details the pl-gtools framework, and details the template used to integrate gtools applications with Prolog. Section (5) closes some technical loose ends, including details of supported platforms, package availability, and additional references to source code. Finally, Section 6 concludes. A graph G = (V, E) consists of a set of vertices V = [n] = (cid:8) 1, . . . , n (cid:9) and a set of edges E ⊆ V × V . In the examples presented in this paper graphs are always simple. Meaning that they are undirected, there are no self loops, and no multiple edges. The tools we present allow also directed graphs and support vertex-coloring. 2 Preliminaries Two graphs G = ([n], E) and G(cid:48) = ([n], E(cid:48)) are said to be isomorphic if the vertices of one graph may be permuted to obtain the other. Namely, if there exists a permutation π: [n] → [n] such that (u, v) ∈ E ⇐⇒ (π(u), π(v)) ∈ E(cid:48). Graph isomorphism is an equivalence relation. As such, it induces equivalence classes on any set of graphs, wherein graphs G, G(cid:48) are in the same equivalence class if G and G(cid:48) are isomorphic. The canonical representation of a graph G is some fixed value can(G) such that for every graph G(cid:48) isomorphic to G we have can(G) = can(G(cid:48)). The running example we use throughout this paper concerns the generation of Ramsey graphs: A R(s, t; n) Ramsey graph, where s, t, n ∈ N, is a graph G with n vertices such that G contains no clique of size s nor an independent set of size t. We denote by R(s, t; n) the set of all non-isomorphic Ramsey R(s, t; n) graphs. The Ramsey number R(s, t) is the smallest natural number n for which no R(s, t; n) graph exist. 3 Interfacing Prolog with nauty's C library The pl-nauty interface is implemented using the foreign language interface of SWI- Prolog (Wielemaker et al. 2012). The nauty C library is linked with corresponding C code written for Prolog, which involves four low-level Prolog predicates: (1) densenauty/8, (2) canonic graph/6, (3) isomorphic graphs/6, and (4) graph convert/5. The ex- perienced nauty user will find densenauty/8 to be a direct interface to the corre- sponding C function in nauty. The canonic graph/6 predicate performs graph can- onization only. The isomorphic graphs/6 predicate tests two graphs for isomorphism, and graph convert/5 converts between the supported graph formats such as between the graph6 (McKay ) format often used in nauty and the Boolean adjacency matrices natural in logic programming. We present several examples of the pl-nauty library in Prolog. The first two examples revolve around enumerating Ramsey graphs modulo isomorphism. The rest are simple demonstrations of the core pl-nauty predicates in various cases. In the first example 4 Michael Frank and Michael Codish we apply a straightforward iterative approach to enumerate all solutions modulo isomor- phism. The second example illustrates how nauty integrates into an existing tool-chain, all specified as part of the Prolog process. Here we first construct a constraint model, infused with a partial symmetry breaking predicate. Then, apply the finite domain con- straint compiler BEE (Metodi and Codish 2012; Metodi et al. 2013) (written in Prolog) to obtain a CNF model, apply a SAT solver (through its Prolog interface), and then generate all solutions of constraint model. At the end of each iteration we apply predi- cates from the pl-nauty library to remove isomorphic solutions. The core of the code, with an emphasis on using the pl-nauty library is presented below. The complete code is available for download as part of the pl-nauty library, in the examples directory. 3.1 The First Example: Generate and Test In the code below, the predicate genRamseyGT(S, T, N, Graphs) iterates starting from the empty graph to generate in Graphs, the set of all canonical Ramsey (S, T ; N ) col- orings. We represent graphs as Boolean adjacency matrices: a list of N length-N lists. At iteration I it takes, Acc, the canonical set of Ramsey (S, T ; I) colorings computed thus far and calls the predicate extendRamsey(S, T, I, Acc, NewAcc) to obtain, NewAcc, the canonical set of Ramsey (S, T ; I + 1) colorings. genRamseyGT(S, T, N, Graphs) :- genRamsey(0, S, T, N, [[]], Graphs). genRamsey(I, S, T, N, Acc, Graphs) :- I < N, !, I1 is I+1, extendRamsey(S, T, I, Acc, NewAcc), genRamsey(I1, S, T, N, NewAcc, Graphs). genRamsey(N, _, _, N, Graphs, Graphs). The predicate extendRamsey(S, T, N, Graphs, NewGraphs) takes a list, Graphs of (canonical) Ramsey (S, T ; N ) graphs. Then, a new vertex is added in all possible ways to each graph in Graphs and those new graphs that are Ramsey (S, T ; N + 1) colorings are canonized. Finally, the resulting graphs are sorted to remove duplicates, resulting in NewGraphs. It is the call to canonic_graph/3 that interfaces to our Prolog integration of the nauty tool. extendRamsey(S, T, N, Graphs, NewGraphs) :- N1 is N+1, findall(Canonic, (member(Graph, Graphs), addVertex(Graph, NewGraph), isRamsey(S,T,N1,NewGraph), canonic_graph(N1, NewGraph, Canonic) /* #1 (test)*/ /* #2 (reduce)*/ ), GraphsTmp), sort(GraphsTmp, NewGraphs). The predicate addVertex(Matrix,ExtendedMatrix) extends non-deterministically an adjacency Matrix with a new vertex by adding a new first row and equal first column. addVertex(Matrix,[NewRowNewRows]) :- NewRow = [0Xs], addFirstCol(Matrix,Xs,NewRows). addFirstCol([],[],[]). addFirstCol([RowRows],[XXs],[[XRow]NewRows]) :- member(X,[0,1]), addFirstCol(Rows,Xs,NewRows). To complete the example, we illustrate the test predicate isRamsey(S,T,N,Graph) which succeeds if the given Graph is a Ramsey (S, T ; N ) coloring. This is so if it is not Logic Programming with Graph Automorphism 5 possible to choose S vertices from the graph, the edges between which are all "colored" 0, or T vertices from the graph, the edges between which are all "colored" 1. isRamsey(S,T,N,Graph) :- forall( choose(N, S, Vs), mono(0, Vs, Graph) ), forall( choose(N, T, Vs), mono(1, Vs, Graph) ). mono(Color, Vs, Graph) :- cliqeEdges(Vs,Graph,Es), maplist(==(Color), Es). cliqeEdges([],_,[]). cliqeEdges([IIs],Graph,Es) :- cliqeEdges(I, Is, Graph, Es0), cliqeEdges(Is, Graph, Es). cliqeEdges(_,[],_,[]). cliqeEdges(I,[JJs], Graph, [EEs]) :- nth1(I, Graph, Gi), nth1(J, Gi, E), cliqeEdges(I,Js,Graph,Es). choose(N,K,C) :- numlist(1,N,Ns), length(C,K), choose(C,Ns). choose([],[]). choose([IIs],[IJs]) :- choose(Is,Js). choose(Is,[_Js]) :- choose(Is,Js). We first demonstrate the application of the genRamseyGT to the so called, "party problem". What is the smallest number of people that must be invited to a party so that at least three know each other, or at least three do not know each other. This is the smallest N for which there is no (3, 3; N ) coloring. The following two calls illustrate that there is a single canonical coloring when N = 5 and none when N = 6. So, the answer to the party problem (as well-known) is 6. ?- genRamseyGT(3,3,5,Gs). Gs = [ [[0,1,1,0,0], [1,0,0,1,0], [1,0,0,0,1], [0,1,0,0,1], [0,0,1,1,0]]]. ?- genRamseyGT(3,3,6,Gs). Gs = []. We make three observations regarding the generation of graphs in this example. Con- sider the predicate extendRamsey/5. 1. If the call canonic_graph(N1, NewGraph, Canonic), at the line marked /* #2 */, is replaced by the line Canonic = NewGraph, then all solutions are found, not just the canonical ones. For example, when N = 5 there are 12 solutions, all of them isomorphic. ?- genRamseyGT(3,3,5,Gs), length(Gs,M). M = 12. 2. If the call to isRamsey(S,T,N1,NewGraph), at the line marked /* #1 */, is re- moved then we generate all non-isomorphic graphs on N vertices. For example, ?- genRamseyGT(3,3,5,Gs), length(Gs,M). M = 34. 3. If both changes are made, then we generate all graphs on N vertices. ?- genRamseyGT(3,3,5,Gs), length(Gs,M). M = 1024. We now demonstrate the application of the genRamseyGT to generate incrementally all non-isomorphic (3, 5; N ) Ramsey colorings. It is known (Radziszowski 1994) that R(3, 5) = 14. Table (1) summarizes the enumeration of all non-isomorphic (3, 5; N ) col- orings graphs. The first row indicates the number of (non-isomorphic) colorings gener- ated. The next rows detail the time (in seconds) to compute these colorings and the time 6 n R(3, 5; n) time (sec) nauty (sec) Michael Frank and Michael Codish 1 1 2 2 3 3 4 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 5 6 7 8 9 10 11 12 13 14 13 0.00 0.00 32 0.03 0.00 71 0.20 0.01 179 0.90 0.02 290 4.66 0.06 313 16.61 0.09 105 39.24 0.11 12 52.72 0.11 1 55.75 0.11 0 56.20 0.11 Table 1. Enumerating R(3, 5; n) graphs: Generate, Test & Reduce. spent in the calls to canonic_graph. It is notable that the time spent to reduce solutions modulo isomorphism using nauty is negligible. To summarize this section, we stress that this is a toy application with the intention to illustrate an application of the integration of Prolog with the nauty package. A more elaborate solution of this problem would, for example, combine the calls addVertex(Graph, NewGraph), isRamsey(S,T,N1,NewGraph) in extendRamsey to add edges connecting the new vertex to the rest of the graph incrementally so as not to violate the isRamsey condition. This combination could also perform various propagation based optimizations. 3.2 The Second Example: Constrain and Generate In the code below, the predicate genRamseyCG(S, T, N, Graphs) encodes an instance ramsey(S,T,N) to a finite domain constraint model. We adopt BEE (Metodi and Codish 2012; Metodi et al. 2013) for this purpose. The call to encode/3 generates a constraint model, Constraints and the N × N Matrix of Boolean (Prolog) variables. The Matrix structure serves as a mapping between the instance variables, which talks about the search for Ramsey colorings, and the Constraints variables. It specifies the connec- tion between variables in the constraint model and edges in the unknown graph we are searching for. The call to bCompile/2 compiles the constraints to a corresponding CNF. The call to solveAll/3 iterates with the underlying SAT solver to provide all satisfying Assignments of the CNF (modulo the variables of interest in the list Booleans). Satisfy- ing assignments are then decoded back to the world of graphs in the call to decode/3, and finally it is here that we call on the predicate canonic_graph/3 from the pl-nauty interface to restrict solutions to their canonical forms and remove isomorphic solutions by sorting these. genRamseyCG(S, T, N, Graphs) :- encode(ramsey(S,T,N), Matrix, Constraints), bCompile(Constraints,CNF), projectVariables(Matrix, Booleans), solveAll(CNF,Booleans,Assignments), decode(Assignments,Matrix,Graphs0), maplist(canonic_graph(N), Graphs0, Graphs1), sort(Graphs1, Graphs). The predicate encode/3 is presented below. It first creates an N × N adjacency Matrix with Boolean variables representing the object of the search for a Ramsey(S,T;N) graph. It then imposes three sets of constraints: (1) the call to lex_star/2 constrains the rows of Matrix to be pairwise lexicographically ordered. This implements the symmetry break described in (Codish et al. 2013); (2) the first call to no_clique/4 constrains the graph represented by Matrix to contain no independent set of size S, and (3) the second call to no_clique/4 constrains the graph represented by Matrix to contain no clique of size T. Logic Programming with Graph Automorphism 7 The full details of the example are available for download as part of the pl-nauty library, in the examples directory. encode(ramsey(S,T,N), map(Matrix), Constraints) :- adj_matrix_create(N, Matrix), lex_star(Matrix, Cs1-Cs2), no_clique(0, S, Matrix, Cs2-Cs3), no_clique(1, T, Matrix, Cs3-Cs4), Cs4 = [], Constraints = Cs1. /* #1 */ /* #2 */ /* #3 */ The following illustrates the BEE constraint model, with the associated adjacency ma- trix, produced by a call to the encode/3 predicate for a Ramsey R(3, 3; 5) instance. Note that the elements on the diagonal of the matrix are −1 which is how false is represented in BEE. The constraint model consists of three types of constraints corresponding to the three annotated calls in encode/3. [[-1,A,B,C,D], [A,-1,E,F,G], [B,E,-1,H,I], [C,F,H,-1,J], [D,G,I,J,-1]] % #1 pairwise lexicographical order % #2 no independent set bool_array_or([A,B,E]), bool_arrays_lex([B,C,D],[E,F,G]), bool_array_or([A,C,F]), bool_arrays_lex([A,B,D],[F,H,J]), bool_array_or([A,D,G]), bool_arrays_lex([A,F,G],[B,H,I]), bool_array_or([B,C,H]), bool_arrays_lex([A,E,F],[D,I,J]), bool_arrays_lex([B,E,I],[C,F,J]), bool_array_or([B,D,I]), bool_array_or([C,D,J]), bool_arrays_lex([C,F,H],[D,G,I]), bool_array_or([E,F,H]), bool_array_or([E,G,I]), bool_array_or([F,G,J]), bool_array_or([H,I,J]), % #3 no clique bool_array_or([-A,-B,-E]), bool_array_or([-A,-C,-F]), bool_array_or([-A,-D,-G]), bool_array_or([-B,-C,-H]), bool_array_or([-B,-D,-I]), bool_array_or([-C,-D,-J]), bool_array_or([-E,-F,-H]), bool_array_or([-E,-G,-I]), bool_array_or([-F,-G,-J]), bool_array_or([-H,-I,-J]) Table (2) summarizes the enumeration of all non-isomorphic (3, 5; N ) colorings graphs using the constrain and generate approach. The first row indicates the number of (non- isomorphic) colorings generated. The second row indicates the number of colorings found when solving the constraint model (with the partial symmetry break). The next rows detail the time (in seconds) to compute these colorings and the time spent in the calls to canonic_graph. It is notable that the time spent to reduce solutions modulo isomorphism using nauty is negligible. n R(3, 5; n) #SAT time (sec) nauty (sec) 1 1 1 2 2 2 3 3 3 4 7 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 5 6 7 8 9 10 11 12 13 14 13 18 0.00 0.00 32 63 0.00 0.00 71 255 0.02 0.00 179 1100 0.02 0.01 290 3912 0.12 0.05 313 7319 0.74 0.16 105 3806 1.97 0.05 12 272 1.16 0.00 1 2 1.15 0.00 0 0 0.07 0.00 Table 2. Enumerating R(3, 5; n) graphs: Constrain, Generate & Reduce. 3.3 The graph_convert/5 predicate The graph_convert/5 predicate performs conversions between the different graph for- mats that are supported by pl-nauty. Supported formats include: adjacency matrices, adjacency lists, edge lists, and the graph6 format. As an example, to convert a graph, or a list of graphs, from the graph6 format, to Prolog's adjacency matrix format: ?- Graph = 'DqK', graph_convert(5, graph6_atom, adj_matrix, Graph, AdjMatrix). 8 Michael Frank and Michael Codish Graph = 'DqK', AdjMatrix = [[0,1,1,0,0], [1,0,0,1,0], [1,0,0,0,1], [0,1,0,0,1], [0,0,1,1,0]] ?- Graphs = ['DRo','Dbg','DdW','DLo','D[S','DpS','DYc','DqK','DMg','DkK','Dhc','DUW'], maplist(graph_convert(5, graph6_atom, adj_matrix), Graphs, AdjMatrices). = ['DRo','Dbg','DdW','DLo','D[S','DpS','DYc','DqK','DMg','DkK','Dhc','DUW'], Graphs AdjMatrices = [[[0,0,1,0,1],[0,0,0,1,1],[1,0,0,1,0],[0,1,1,0,0],[1,1,0,0,0]], [[0,1,0,0,1],[1,0,0,1,0],[0,0,0,1,1],[0,1,1,0,0],[1,0,1,0,0]], [[0,1,0,1,0],[1,0,0,0,1],[0,0,0,1,1],[1,0,1,0,0],[0,1,1,0,0]], [[0,0,0,1,1],[0,0,1,0,1],[0,1,0,1,0],[1,0,1,0,0],[1,1,0,0,0]], [[0,0,1,1,0],[0,0,1,0,1],[1,1,0,0,0],[1,0,0,0,1],[0,1,0,1,0]], [[0,1,1,0,0],[1,0,0,0,1],[1,0,0,1,0],[0,0,1,0,1],[0,1,0,1,0]], [[0,0,1,0,1],[0,0,1,1,0],[1,1,0,0,0],[0,1,0,0,1],[1,0,0,1,0]], [[0,1,1,0,0],[1,0,0,1,0],[1,0,0,0,1],[0,1,0,0,1],[0,0,1,1,0]], [[0,0,0,1,1],[0,0,1,1,0],[0,1,0,0,1],[1,1,0,0,0],[1,0,1,0,0]], [[0,1,0,1,0],[1,0,1,0,0],[0,1,0,0,1],[1,0,0,0,1],[0,0,1,1,0]], [[0,1,0,0,1],[1,0,1,0,0],[0,1,0,1,0],[0,0,1,0,1],[1,0,0,1,0]], [[0,0,1,1,0],[0,0,0,1,1],[1,0,0,0,1],[1,1,0,0,0],[0,1,1,0,0]]] 3.4 The canonic graph/6 predicate The canonic graph/6 predicate performs graph canonization and it takes the form canonic graph(N, InputFmt, OutputFmt, Graph, Perm, Canonic) where InputFmt is the format of the N vertex input graph (Graph), OutputFmt is the format of the canon- ical graph (Canonic), and Perm is the permutation whose application to the input graph renders the canonical representative. For example: ?- N = 5, Graph = [[0,1,0,0,0], [1,0,1,0,1], [0,1,0,1,0], [0,0,1,0,1], [0,1,0,1,0]], canonic_graph(N,adj_matrix,adj_matrix,Graph,Perm,Canonic). = 5, N Graph = [[0,1,0,0,0],[1,0,1,0,1],[0,1,0,1,0],[0,0,1,0,1],[0,1,0,1,0]], Canonic = [[0,0,0,0,1],[0,0,0,1,1],[0,0,0,1,1],[0,1,1,0,0],[1,1,1,0,0]], Perm = [1, 5, 2, 4, 3] A compact version of canonic graph/6 is also included in pl-nauty in the form of the predicate canonic_graph/3. The predicate canonic_graph/3 takes the form canonic_graph(NVert, Graph, Canonic) and it is equivalent to canonic_graph(NVert, adj_matrix, adj_matrix, Graph, _, Canonic). For example: ?- N = 5, Graph = [[0,1,0,0,0], [1,0,1,0,1], [0,1,0,1,0], [0,0,1,0,1], [0,1,0,1,0]], canonic_graph(N,Graph,Canonic). N Graph Canonic = [[0,0,0,0,1],[0,0,0,1,1],[0,0,0,1,1],[0,1,1,0,0],[1,1,1,0,0]] = 5, = [[0,1,0,0,0],[1,0,1,0,1],[0,1,0,1,0],[0,0,1,0,1],[0,1,0,1,0]], 3.5 The isomorphic_graphs/6 predicate The isomorphic_graphs/6 predicate tests for graph isomorphism. It takes the form: isomorphic_graphs(N, Graph1, Graph2, Perm, Canonic, Opts) and tests if the two N vertex input graphs, Graph1 and Graph2 are isomorphic via a permutation Perm. If they are then Canonic is the canonical form they share. The predicate takes a list Opts of options to customize the behavior of this predicate. Options include any of the following: fmt1(Fmt1) the format of Graph1, fmt2(Fmt2) the format of Graph2, cgfmt(CgFmt) the format of Canonic. In the case where Graph1 and Graph2 are not isomorphic the predicate will fail silently. For example: ?- N = 5, Graph1 = [[0,1,0,1,1], [1,0,1,0,0], [0,1,0,1,0], [1,0,1,0,1], [1,0,0,1,0]], Logic Programming with Graph Automorphism 9 Graph2 = [[0,1,0,1,1], [1,0,1,0,0], [0,1,0,0,1], [1,0,0,0,1], [1,0,1,1,0]], isomorphic_graphs(N, Graph1, Graph2, Perm, Canonic, []). = 5, N Graph1 = [[0,1,0,1,1],[1,0,1,0,0],[0,1,0,1,0],[1,0,1,0,1],[1,0,0,1,0]], Graph2 = [[0,1,0,1,1],[1,0,1,0,0],[0,1,0,0,1],[1,0,0,0,1],[1,0,1,1,0]], Perm Canonic = [[0,1,0,1,0],[1,0,0,0,1],[0,0,0,1,1],[1,0,1,0,1],[0,1,1,1,0]] = [1,2,3,5,4], ?- N = 5, Graph1 = [[0,1,1,0,1],[1,0,0,0,1],[1,0,0,0,0],[0,0,0,0,0],[1,1,0,0,0]], Graph2 = [[0,1,0,0,1],[1,0,1,1,0],[0,1,0,0,1],[0,1,0,0,1],[1,0,1,1,0]], isomorphic_graphs(N, Graph1, Graph2, Perm, Canonic, []). false. 3.6 The densenauty/8 predicate Most of the core predicates of pl-nauty and many of the examples described above are based on the densenauty/8 predicate. The densenauty/8 predicate is a direct in- terface to the nauty C library function of the same name. The predicate is called in a similar fashion to its counterpart in the nauty C library. A complete documentation of densenauty/8 may be found in the source code provided with pl-nauty, and in the nauty user guide (McKay 2016). Briefly, the predicate densenauty/8 takes the following form: densenauty(NVert, Graph, Labeling, Partition, Permutation, Orbits, Canonic, Opts) where NVert is the number of vertices in the input graph, Graph is the input graph, Labeling, Partition and Orbits are the labeling, partition and orbits of the input graph, as described in the nauty user guide (McKay 2016), Canonic is the canonical form of the input graph, and Permutation is the permutation of the nodes of the input graph which may be applied to obtain the Canonic representative. The last argument, Opts is used to modify the behavior of densenauty. For example, it may be used to control the format of the input graph, and Canonic representative. 4 Interfacing Prolog and gtools The nauty graph automorphism tool comes with a collection of applications called gtools, that implement an assortment of common tasks that nauty is typically ap- plied to. During installation (of nauty) these are compiled into a set of command line applications. These applications cannot simply be loaded using the foreign language in- terface. Each application is like a black box. We do not wish to access its source code. One straightforward approach to integrate gtools with Prolog is to run each such ap- plication from within Prolog, write its output to a temporary file, and then to read the file, and continue with the task that the Prolog program is addressing. A more elegant solution makes use of unix pipes to skip that intermediate step of writing and reading from files. The output is directly read/written via Prolog. The voodoo is using pipes (which are like in-memory files). We have implemented a Prolog library called pl-gtools, which provides a framework for calling the applications in gtools 10 Michael Frank and Michael Codish using unix pipes. The pl-gtools framework supports two types of gtools applications which take any number of command line arguments and write their output to standard output. The first type does not require any input, and the second requires some form of input (from standard input). We present a general template to support the two "sides" of the pipe: a child predicate (which typically executes a gtools command), and a parent predicate (which typically reads the output of the child). The framework includes predicates: gtools_exec/6 and gtools_fetch/2, and two ad- ditional predicates for applications which respectively require uni- and bi-directional com- munication: gtools_fork_exec/2 and gtools_fork_exec_bidi/2. For uni-directional communication, a call to gtools_fork_exec(Parent, Child) will fork and execute the Parent goal as the parent process and the Child goal as the child process. It assumes that both Parent and Child take an additional argument which is unified with the corresponding input/output streams (to support communication from child to parent). For bi-directional communication, a call to gtools_fork_exec_bidi(Parent, Child) is exactly the same, except that the Parent and Child take two additional arguments to support two way communication. The predicate gtools_fetch/2 reads the next line from the output stream of the child and converts it to an atom. When the end of the stream is reached then the predicate fails. A call to gtools_exec/6 takes the form gtools exec(NautyDir, Cmd, Args, InputStream, OutputStream, ErrorStream) where: NautyDir is the directory in the file system which contains the gtools applications, Cmd is the name of the gtools command that we which to execute, and Args is its argument list. The final three arguments specify the standard input, output and error streams. The call to gtools_exec/6 invokes the exec/1 predicate of SWI-Prolog, replacing the current process image with Cmd and its Args. We present two example uses of pl-gtools. The first, calls geng from gtools, which iterates over all non-isomorphic graphs with a given number of vertices. The second, calls shortg from gtools, which reduces a set of graphs to non-isomorphic members. 4.1 Example 1: geng This example illustrates how the framework is applied for an application which reads no input. The gtools application geng receives an argument n and outputs one line for each non-isomorphic graph with n vertices. Its Prolog implementation consists of three predicates: geng/2, parent geng/2 and child geng/2. The predicate geng/2 is the main predicate which backtracks over all results of the gtools application. The predicates parent geng/2 and child geng/2 implement respectively the parent and child sides of the pipe. geng(N, Graph) :- gtools_fork_exec(geng:parent_geng(Graph), geng:child_geng(N)). parent_geng(Graph,Read) :- gtools_fetch(Read, Graph). child_geng(N,Stream) :- gtools_exec('nauty26r3', geng, ['-q', N], _, Stream, _). 4.2 Example 2: shortg This example illustrates how the framework is applied for an application which reads from standard input. The shortg application reads a list of graphs in the graph6 for- Logic Programming with Graph Automorphism 11 mat (McKay ) from standard input, and removes all isomorphic duplicates, writing to standard output. It can be applied as follows: After integrating shortg with pl-gtools it could be called from Prolog like so: ?- InputGraphs = ['DRo','Dbg','DdW', 'DLo','D[S','DpS', 'DYc','DqK','DMg', 'DkK','Dhc','DUW'], % a list of graphs in graph6 format shortg(InputGraphs, OutputGraphs). % the call to shortg InputGraphs = ['DRo','Dbg','DdW','DLo','D[S','DpS', 'DYc','DqK' ... ], OutputGraphs = ['DqK']. The implementation of shortg in Prolog consists of three predicates and is very similar to that for geng except that communication between the child and parent processes is bi-directional. shortg(In, Out) :- gtools_fork_exec_bidi(shortg:parent_shortg(In, Out), shortg:child_shortg). parent_shortg(In, Out, PRead, PWrite) :- maplist(writeln(PWrite), In), flush_output(PWrite), close(PWrite), findall(O, gtools_fetch(PRead, O), Out), close(PRead). child_shortg(CRead, CWrite) :- gtools_exec('nauty26r3', shortg, ['-q'], CRead, CWrite, _). In this example, shortg/2 takes two arguments: In a list of input graphs in the graph6 format, to be reduced modulo isomorphism, and Out will be unified with the set of reduced graphs. The predicate calls the gtools fork exec bidi/2 predicate. Pipes are opened to setup two way communication between the parent and child. Two additional predicates are implemented: one for the parent process and one for the child process. Each predicate takes, as its last two arguments the read and write ends of the pipes, so communication may be established. In our case, the parent writes the set of input graphs to the write end of the pipe, and then reads the results from the read end of the child's pipe. The child calls gtools exec/6, and executes shortg/2. 5 Technical Details A short overview of some technical details regarding pl-nauty and pl-gtools follows. The package containing pl-nauty and pl-gtools is available for download from the pl-nauty homepage at: http://www.cs.bgu.ac.il/~frankm/plnauty. The pack- age contains a README file, which contains usage and installation instructions, as well as an examples directory containing the examples discussed in this paper. The C code for pl-nauty may be found in the src directory. Also in the src directory are the two module files for pl-nauty and pl-gtools. Both pl-nauty and pl-gtools were compiled and tested on Debian Linux and Ubuntu Linux using the 7.x.x branch of SWI-Prolog. It is important to mention that both pl-nauty and pl-gtools contain Linux specific features, and are oriented towards SWI- Prolog. It should also be noted that pl-nauty is not thread-safe, for reasons of perfor- mance. If you require a thread-safe version of pl-nauty you should synchronize calls to the predicates of the pl-nauty module. 12 Michael Frank and Michael Codish 6 Conclusion We have presented, and made available, a Prolog interface to the core components of the nauty graph-automorphism tool (McKay 1981) which is often cited as "The world's fastest isomorphism testing program" (see for example http://www3.cs.stonybrook.edu/ ~algorith/implement/nauty/implement.shtml). The contribution of the paper is in the utility of the tool which we expect to be widely used. The tool facilitates programming with the strengths of two paradigms: logic programming for solving graph search problems on the one hand, and efficient pruning of (intermediate) solutions modulo graph isomor- phism, on the other. It enables Prolog programs which address graph search problems to apply nauty natively, through Prolog, in the process of graph search and enumeration. Graphs may be generated non-deterministically and may be canonized deterministically. References Babai, L. 2015. Graph isomorphism in quasipolynomial time. CoRR abs/1512.03547. Codish, M., Frank, M., Itzhakov, A., and Miller, A. 2016. Computing the ramsey number r(4,3,3) using abstraction and symmetry breaking. Constraints, 1–19. Also in: Proceedings of the Thirteenth International Conference on Integration of Artificial Intelligence and Oper- ations Research Techniques in Constraint Programming. Codish, M., Miller, A., Prosser, P., and Stuckey, P. J. 2013. Breaking symmetries in graph representation. In Proceedings of the 23rd International Joint Conference on Artificial Intelligence, Beijing, China, F. Rossi, Ed. IJCAI/AAAI. Crawford, J., Ginsberg, M., Luks, E., and Roy, A. 1996. Symmetry-breaking predicates for search problems. Morgan Kaufmann, 148–159. Darga, P. T., Liffiton, M. H., Sakallah, K. A., , and Markov, I. L. 2004. Exploiting In Proceedings of the 41st Design Automation structure in symmetry detection for CNF. Conference. Hartke, S. G. and Radcliffe, A. J. 2009. McKay's canonical graph labeling algorithm. Contemporary Mathematics 479, 99–111. Junttila, T. and Kaski, P. 2007. Engineering an efficient canonical labeling tool for large and sparse graphs. In Proceedings of the Ninth Workshop on Algorithm Engineeringand Ex- periments. SIAM, 135–149. McKay, Brendan D. and Piperno, A. 2016. nauty and Traces Users Guide (Version 2.6). McKay, B. The graph6 format. (web pages describing the format). McKay, B. 1990. nauty user's guide (version 1.5). Tech. Rep. TR-CS-90-02, Australian National University, Computer Science Department. McKay, B. D. 1981. Practical graph isomorphism. Congressus Numerantium 30, 45–87. McKay, B. D. and Piperno, A. 2014. Practical graph isomorphism, II. Journal of Symbolic Computation 60, 94–112. Metodi, A. and Codish, M. 2012. Compiling finite domain constraints to SAT with BEE. TPLP 12, 4-5, 465–483. Metodi, A., Codish, M., and Stuckey, P. J. 2013. Boolean equi-propagation for concise and efficient SAT encodings of combinatorial problems. J. Artif. Intell. Res. (JAIR) 46, 303–341. Radziszowski, S. P. 1994. Small Ramsey numbers. Electronic Journal of Combinatorics. Revision #14: January, 2014. Wielemaker, J., Schrijvers, T., Triska, M., and Lager, T. 2012. SWI-Prolog. Theory and Practice of Logic Programming 12, 1-2, 67–96.
1910.11142
1
1910
2019-10-22T10:39:48
Tractable Minor-free Generalization of Planar Zero-field Ising Models
[ "cs.DS", "math.ST", "physics.data-an", "stat.ML", "math.ST" ]
We present a new family of zero-field Ising models over $N$ binary variables/spins obtained by consecutive "gluing" of planar and $O(1)$-sized components and subsets of at most three vertices into a tree. The polynomial-time algorithm of the dynamic programming type for solving exact inference (computing partition function) and exact sampling (generating i.i.d. samples) consists in a sequential application of an efficient (for planar) or brute-force (for $O(1)$-sized) inference and sampling to the components as a black box. To illustrate the utility of the new family of tractable graphical models, we first build a polynomial algorithm for inference and sampling of zero-field Ising models over $K_{3,3}$-minor-free topologies and over $K_{5}$-minor-free topologies -- both are extensions of the planar zero-field Ising models -- which are neither genus - nor treewidth-bounded. Second, we demonstrate empirically an improvement in the approximation quality of the NP-hard problem of inference over the square-grid Ising model in a node-dependent non-zero "magnetic" field.
cs.DS
cs
Tractable Minor-free Generalization of Planar Zero-field Ising Models Tractable Minor-free Generalization of Planar Zero-field Ising Models Valerii Likhosherstov Department of Engineering University of Cambridge Cambridge, UK Yury Maximov Theoretical Division and Center for Nonlinear Studies Los Alamos National Laboratory Los Alamos, NM, USA Michael Chertkov Graduate Program in Applied Mathematics University of Arizona Tucson, AZ, USA Editor: [email protected] [email protected] [email protected] Abstract We present a new family of zero-field Ising models over N binary variables/spins obtained by consecutive "gluing" of planar and O(1)-sized components and subsets of at most three vertices into a tree. The polynomial time algorithm of the dynamic programming type for solving exact inference (computing partition function) and exact sampling (generating i.i.d. samples) consists in a sequential application of an efficient (for planar) or brute-force (for O(1)-sized) inference and sampling to the components as a black box. To illustrate utility of the new family of tractable graphical models, we first build a polynomial algorithm for inference and sampling of zero-field Ising models over K33-minor-free topologies and over K5-minor-free topologies -- both are extensions of the planar zero-field Ising models -- which are neither genus- no treewidth-bounded. Second, we demonstrate empirically an improvement in the approximation quality of the NP-hard problem of inference over the square-grid Ising model in a node-dependent non-zero "magnetic" field. Keywords: Graphical model, Ising model, partition function, statistical inference. 9 1 0 2 t c O 2 2 ] S D . s c [ 1 v 2 4 1 1 1 . 0 1 9 1 : v i X r a 1. Introduction of normal edges E(G) ⊆ (cid:0)V (G) Let G = (V (G), E(G)) be an undirected graph with a set of vertices V (G) and a set which associate the following probability to each random N (cid:44) V (G)-dimensional binary variable/spin configuration X ∈ {±1}N : (cid:1) (no loops or multiple edges). We discuss Ising models 2 P(X) (cid:44) W(X) Z , 1 (1) Likhosherstov, Maximov and Chertkov where W(X) (cid:44) exp (cid:18) (cid:88) v∈V (G) µvxv + (cid:88) e={v,w}∈E(G) (cid:19) and Z (cid:44) (cid:88) X∈{±1}N Jexvxw W(X). (2) Here, µ = (µv, v ∈ V (G)) is a vector of (magnetic) fields, J = (Je, e ∈ E(G)) is a vector of the (pairwise) spin interactions, and the normalization constant Z, which is defined as a sum over 2N spin configurations, is referred to as the partition function. Given the model specification I = (cid:104)G, µ, J(cid:105), we address the tasks of finding the exact value of Z (inference) and drawing exact samples with the probability (1). Related work. It has been known since the seminal contributions of Fisher (1966) and Kasteleyn (1963) that computation of the partition function in the zero-field (µ = 0) Ising model over a planar graph and sampling from the respective probability distribution are both tractable, that is, these are tasks of complexity polynomial in N . As shown by Barahona (1982), even when G is planar or when µ = 0 (zero field ), the positive results are hard to generalize -- both addition of the non-zero (magnetic) field and the extension beyond planar graphs make the computation of the partition function NP-hard. These results are also consistent with the statement from Jerrum and Sinclair (1993) that computation of the partition function of the zero-field Ising model is a #P-complete problem, even in the ferromagnetic case when all components of J are positive. Therefore, describing (cid:104)G, µ, J(cid:105) families for which computations of the partition function and sampling are tractable remains an open question. The simplest tractable (i.e., inference and sampling are polynomial in N ) example is one when G is a tree, and the corresponding inference algorithm, known as dynamic pro- gramming and/or belief propagation, has a long history in physics (Bethe, 1935; Peierls, 1936), optimal control (Bellman, 1952), information theory (Gallager, 1963), and artificial intelligence (Pearl, 1982). Extension to the case when G is a tree of (t + 1)-sized cliques "glued" together, or more formally when G is of a treewidth t, is known as the junction tree algorithm (Verner Jensen et al., 1990), which has complexity of counting and sampling that grow exponentially with t. Another insight originates from the foundational statistical physics literature of the last century related to the zero-field version of (1), i.e. when µ = 0, over planar G. Onsager (1944) found a closed-form solution of (1) in the case of a homogeneous Ising model over an infinite two-dimensional square grid. Kac and Ward (1952) reduced the inference of (1) over a finite square lattice to computing a determinant. Kasteleyn (1963) generalized this result to an arbitrary (finite) planar graph. Kasteleyn's approach consists of expanding each vertex of G into a gadget and reducing the Ising model inference to the problem of counting perfect matchings over the expanded graph. Kasteleyn's construction was simplified by 3 Fisher (1966). The tightest running time estimate for Kasteleyn's method gives O(N 2 ). Kasteleyn conjectured, which was later proven by Gallucio and Loebl (1999), that the approach extends to the case of the zero-field Ising model over graphs embedded in a surface of genus g with a multiplicative O(4g) penalty. A parallel way of reducing the planar zero-field Ising model to a perfect matching count- ing problem consists of constructing the so-called expanded dual graph (Bieche et al., 1980; Barahona, 1982; Schraudolph and Kamenetsky, 2009). This approach is advantageous be- cause using the expanded dual graph allows a one-to-one correspondence between spin 2 Tractable Minor-free Generalization of Planar Zero-field Ising Models configurations and perfect matchings. An extra advantage of this approach is that the re- duction allows us to develop an exact efficient sampling. Based on linear algebra and planar separator theory (Lipton and Tarjan, 1979), Wilson (1997) introduced an algorithm that 3 allows to sample perfect matchings over planar graphs in O(N 2 ) time. The algorithms were implemented by Thomas and Middleton (2009, 2013) for the Ising model sampling, however, the implementation was limited to only the special case of a square lattice. Thomas and Middleton (2009) also suggested a simple extension of the Wilson's algorithm to the case of bounded genus graphs, again with the 4g factor in complexity. Notice that imposing the zero field condition is critical, as otherwise, the Ising model over a planar graph is NP-hard (Barahona, 1982). On the other hand, even in the case of zero magnetic field the Ising models over general graphs are difficult (Barahona, 1982). Wagner's theorem (Diestel, 2006, chap. 4.4) states that G is planar if and only if it does not have K33 and K5 as minors (Figure 2(b)). Both families of K33-free and K5-free graphs generalize and extend the family of planar graphs, since K33 (K5) is nonplanar but K5-free (K33-free). Both families are genus-unbounded, since a disconnected set of g K33 (K5) graphs has a genus of g (Battle et al., 1962) and is K5-free (K33-free). Moreover, both families are treewidth-unbounded, since planar square grid of size t × t has a treewidth of t (Bodlaender, 1998). Therefore, the question of interest becomes generalizing tractable inference and sampling in the zero-field Ising model over a K33-free or K5-free graph. To extend tractability of the special cases as an approximation to a more general class of inference problems it is natural to consider a family of tractable spanning subgraphs and then exploit the fact that the log-partition function log Z(µ, J) is convex and hence can be upper-bounded by a linear combination of tractable partition functions. Tree-reweighted (TRW) approximation (Wainwright et al., 2005) was the first example in the literature where such upper-bounding was constructed with the trees used as a basic element. The upper-bound TRW approach (Wainwright et al., 2005) was extended by Globerson and Jaakkola (2007), where utilizing a planar spanning subgraph (and not a tree) as the basic (tractable) element was suggested. Contribution. In this manuscript, we, first of all, compile results that were scattered 3 over the literature on (at least) O(N 2 )-efficient exact sampling and exact inference in the zero-field Ising model over planar graphs. To the best of our knowledge, we are the first to present a complete and mathematically accurate description of the tight asymptotic bounds. Then, we describe a new family of zero-field Ising models on graphs that are more general than planar. Given a tree decomposition of such graphs into planar and "small" (O(1)-sized) components "glued" together along sets of at most three vertices, inference and sampling over the new family of models is of polynomial time. We further show that all the K33-free or K5-free graphs are included in this family and, moreover, their aforementioned 3 tree decomposition can be constructed with O(N ) efforts. This allows us to prove an O(N 2 ) upper bound on run time complexity for exact inference and exact sampling of the K5-free or K33-free zero-field Ising models. Finally, we show how the newly introduced tractable family of the zero-field Ising models allows extension of the approach of Globerson and Jaakkola (2007) resulting in an upper- bound for log-partition function over general Ising models, non-planar and including non- zero magnetic field. Instead of using planar spanning subgraphs as in the work of Globerson and Jaakkola (2007), we use more general (non-planar) basic tractable elements. Using 3 Likhosherstov, Maximov and Chertkov the methodology of Globerson and Jaakkola (2007), we illustrate the approach through experiments with a nonzero-field Ising model on a square grid for which exact inference is known to be NP-hard (Barahona, 1982). Relation to other algorithms. The result presented in this manuscript is similar to the approach used to count perfect matchings in K5-free graphs (Curticapean, 2014; Straub et al., 2014). However, we do not use a transition to perfect matching counting as it is typically done in studies of zero-field Ising models over planar graphs (Fisher, 1966; Kasteleyn, 1963; Thomas and Middleton, 2009). Presumably, a direct transition to perfect matching counting can be done via a construction of an expanded graph in the fashion of Fisher (1966); Kasteleyn (1963). However, this results in a size increase and, what's more important, there is no direct correspondence between spin configurations and perfect matchings, therefore exact sampling is not supported. Structure. Section 2 states the problems of exact inference and exact sampling for pla- nar zero-field Ising models. In Section 3 we introduce the concept of c-nice decomposition of graphs, and then formulate and prove tractability of the zero-field Ising models over graphs which are c-nice decomposible. Section 4 is devoted to application of the algorithm intro- duced in the preceding Section to examples of the zero-field Ising model over the K33-free (but possibly K − 5 containing) and K5-free (but possibly K3,3 containing) graphs. Section 5 presents an empirical application of the newly introduced family of tractable models to an upper-bounding log-partition function of a broader family of intractable graphical models (planar nonzero-field Ising models). Section 6 is reserved for conclusions. Throughout the text, we use common graph-theoretic notations and definitions (Diestel, 2006) and also restate the most important concepts briefly. 2. Planar Topology In this Section, we consider the special I = (cid:104)G, 0, J(cid:105) case of the zero-field Ising model over a planar graph and introduce transition from I to the perfect matching model over a different (derived from G) planar graph. One-to-one correspondence between a spin configuration over the Ising model and corresponding perfect matching configuration over the derived graph translates the exact inference and exact sampling over I to the corresponding exact inference and exact sampling in the derived perfect matching model. 2.1 Expanded Dual Graph The graph is planar when it can be drawn on (embedded into) a plane without edge inter- sections. We assume that the planar embedding of G is given (and if not, it can be found in O(N ) time according to Boyer and Myrvold (2004)). In this Section we follow in our constructions of Schraudolph and Kamenetsky (2009). Let us, first, triangulate G by triangulating one after another each face of the original graph and then setting Je = 0 for all the newly added edges e ∈ E(G). Complexity of the triangulation is O(N ), see Schraudolph and Kamenetsky (2009) for an example. (For convenience, we will then use the same notation for the derived, triangulated graph as for the original graph.) Second, construct a new graph, GF , where each vertex f of V (GF ) is a face of G, and there is an edge e = {f1, f2} in E(GF ) if and only if f1 and f2 share an edge in G. By 4 Tractable Minor-free Generalization of Planar Zero-field Ising Models (a) (b) Figure 1: (a) A fragment of G's embedding after triangulation (black), expanded dual graph G∗ (red). (b) Possible X configurations and corresponding M (X) (wavy lines) on a single face of G. Rotation symmetric and reverse sign configurations are omitted. construction, GF is planar, and it is embedded in the same plane as G, so that each new edge e = {f1, f2} ∈ E(GF ) intersects the respective old edge. Call GF a dual graph of G. Since G is triangulated, each f ∈ V (GF ) has degree 3 in GF . Third, obtain a planar graph G∗ and its embedding from GF by substituting each f ∈ V (GF ) by a K3 triangle so that each vertex of the triangle is incident to one edge, going outside the triangle (see Figure 1(a) for illustration). Call G∗ the expanded dual graph of G. Newly introduced triangles of G∗, substituting GF 's vertices, are called Fisher cities (Fisher, 1966). We refer to edges outside triangles as intercity edges and denote their set C. Notice that e∗ ∈ E∗ I . The set E(G∗) \ E∗ as E∗ intersects exactly one e ∈ E(G) and vice versa, which defines a bijection between E∗ I I and I = E(G) ≤ 3N − 6, where N is the E(G); denote it by g : E∗ size (cardinality) of G. A set E(cid:48) ⊆ E(G) is called a perfect matching (PM) of G, if edges of E(cid:48) are disjoint and their union equals V . Let PM(G) denote the set of all Perfect Matchings (PM) of G. Notice I = O(N ). Since G∗ is planar, one also that E∗ finds that E(G∗) = O(N ). Constructing G∗ requires O(N ) steps. I is a PM of G∗, and thus V (G∗) = 2E∗ I of Fisher city edges is denoted as E∗ I → E(G). Observe that E∗ 2.2 Perfect Matching (PM) Model For every spin configuration X ∈ {±1}N , let I(X) be a set {e ∈ E∗ I g(e) = {v, w}, xv = xw}. Each Fisher city is incident to an odd number of edges in I(X). Thus, I(X) can C. Denote the resulting PM by M (X) ∈ be uniquely completed to a PM by edges from E∗ PM(G∗) (see Figure 1(b) for an illustration). Let C+ = {+1} × {±1}N−1. Lemma 1 M is a bijection between C+ and PM(G∗). 5 +++++- Likhosherstov, Maximov and Chertkov Define weights on G∗ according to ∀e∗ ∈ E(G∗) : ce∗ (cid:44) (cid:40) exp(2Jg(e∗)), 1, e∗ ∈ E∗ e∗ ∈ E∗ I C Lemma 2 For E(cid:48) ∈ PM(G∗) holds P(M (X) = E(cid:48)) = 1 Z∗ (cid:89) e∗∈E(cid:48) where Z∗ (cid:44) (cid:88) E(cid:48)∈PM(G∗) (cid:89) e∗∈E(cid:48) ce∗ = 1 2 Z exp ce∗,  (cid:88) e∈E(G)  Je (3) (4) (5) is the partition function of the PM distribution (PM model) defined by (4). See proofs of the Lemma 1 and Lemma 2 in Appendix A. Second transition of (5) reduces the problem of computing Z to computing Z∗. Furthermore, only two equiprobable spin configurations X(cid:48) and −X(cid:48) (one of which is in C+) correspond to E(cid:48), and they can be recovered from E(cid:48) in O(N ) steps, thus resulting in the statement that one samples from I if sampling from (4) is known. weights ce, e ∈ E(cid:48), as a probability distribution over M ∈ PM( G): P( M ) ∝(cid:81) The PM model can be defined for an arbitrary graph G, N = V ( G) with positive e∈ M ce. Our subsequent derivations are based on the following Theorem 3 Given the PM model defined on planar graph G of size N with positive edge weights {ce}, one can find its partition function and sample from it in O( N 3 2 ) time (steps). Algorithms, constructively proving the theorem, are directly inferred from Wilson (1997); Thomas and Middleton (2009), with minor changes/generalizations. We describe the algo- rithms in Appendix B. Corollary 4 Exact inference and exact sampling of the PM model over G∗ (and, hence, zero-field Ising model I over the planar graph G) take O(N 3 2 ) time. 3. c-nice Decomposition of the Topology We commence by introducing the concept of c-nice decomposition of a graph and stating the main result on the tractability of the new family of Ising models in Subsection 3.1. Then we proceed building a helpful "conditioning" machinery in Subsection 3.2 and subse- quently describing algorithms for the the efficient exact inference (Subsection 3.3) and exact sampling (Subsection 3.4), therefore proving the aforementioned statement constructively. 6 Tractable Minor-free Generalization of Planar Zero-field Ising Models 3.1 Decomposition tree and the key result (of the manuscript) We mainly follow Curticapean (2014); Reed and Li (2008) in the definition of the decompo- sition tree and its properties sufficient for our goals. (Let us also remind that we consider here graphs containing no self-loops or multiple edges.) Graph G(cid:48) is a subgraph of G whenever V (G(cid:48)) ⊆ V (G) and E(G(cid:48)) ⊆ E(G). For two subgraphs G(cid:48) and G(cid:48)(cid:48) of G, let G(cid:48) ∪ G(cid:48)(cid:48) = (V (G(cid:48)) ∪ V (G(cid:48)(cid:48)), E(G(cid:48)) ∪ E(G(cid:48)(cid:48))) (graph union). Consider a tree decomposition T = (cid:104)T,G(cid:105) of a graph G into a set of subgraphs G (cid:44) {Gt} of G, where t are nodes of a tree T , that is, t ∈ V (T ). One of the nodes of the tree, r ∈ V (T ), is selected as the root. For each node t ∈ V (T ), its parent is the first node on the unique path from t to r. G≤t denotes the graph union of Gt(cid:48) for all the nodes t(cid:48) in V (T ) that are t or its descendants. G(cid:2)t denotes the graph union of Gt(cid:48) for all the nodes t(cid:48) in V (T ) that are neither t nor descendants of t. For two neighboring nodes of the tree, t, p ∈ V (T ) and {t, p} ∈ E(T ), the set of overlapping vertices of Gt and Gp, K (cid:44) V (Gt) ∩ V (Gp), is called an attachment set of t or p. If p is a parent of t, then K is a navel of t. We assume that the navel of the root is empty. T is a c-nice decomposition of G if the following requirements are satisfied: 1. ∀t ∈ V (T ) with a navel K, it holds that K = V (G≤t) ∩ V (G(cid:2)t). 2. Every attachment set K is of size 0, 1, 2, or 3. 3. ∀t ∈ V (T ), either V (Gt) ≤ c or Gt is planar. 4. If t ∈ V (T ) is such that V (Gt) > c, addition of all edges of type e = {v, w}, where v, w belong to the same attachment set of t (if e is not yet in E(Gt)) does not destroy planarity of Gt. Stating it informally, the c-nice decomposition of G is a tree decomposition of G into planar and "small" (of size at most c) subgraphs Gt, "glued" via subsets of at most three vertices of G. Figure 2(a) shows an example of a c-nice decomposition with c = 8. There are various similar ways to define a graph decomposition in literature, and the one pre- sented above is customized (to our purposes) to include only properties significant for our consecutive analysis. The remainder of this Section is devoted to a constructive proof of the following key statement of the manuscript. Theorem 5 Let I = (cid:104)G, 0, J(cid:105) be any zero-field Ising model where there exists a c-nice decomposition T of G, where c is an absolute constant. Then, there is an algorithm which, given I,T as an input: (1) finds Z and (2) samples a configuration from I in time O( (cid:80) t∈V (T ) V (Gt) 3 2 ). 3.2 Inference and sampling conditioned on 1, 2, or 3 vertices/spins Before presenting the algorithm that proves Theorem 5 constructively, let us introduce the auxiliary machinery of "conditioning", which describes the partition function of a zero-field Ising model over a planar graph conditioned on 1, 2, or 3 spins. Consider a zero-field Ising 7 Likhosherstov, Maximov and Chertkov Figure 2: a) An exemplary graph G and its 8-nice decomposition T , where t ∈ {1,··· , 7} labels nodes of the decomposition tree T and node 4 is chosen as the root (r = 4). Identical vertices of G in its subgraphs Gt are shown connected by dashed lines. Navels of size 1, 2, and 3 are highlighted. Component G5 is nonplanar, and G4 becomes nonplanar when all attachment edges are added (according to the fourth item of the definition of the c-nice decomposition). G≤3 and G(cid:2)3 are shown with dotted lines. Note that the decomposition is non-unique for the graph. For instance, edges that belong to the attachment set can go to either of the two subgraphs containing this set or even repeat in both. b) Minors K5 and K33 are forbidden in the planar graphs. Mobius ladder and its subgraphs are the only nonplanar graphs allowed in the 8-nice decomposition of a K5-free graph. c) The left panel is an example of conditioning on three vertices/spins in the center of a graph. The right panel shows a modified graph where the three vertices (from the left panel) are reduced to one vertex, then leading to a modification of the pairwise interactions within the associated zero-field Ising model over the reduced graph. d) Example of a graph that contains K5 as a minor: by contracting the highlighted groups of vertices and deleting the remaining vertices, one arrives at the K5 graph. model I = (cid:104)G, 0, J(cid:105) defined over a planar graph G. We intend to use the algorithm for efficient inference and sampling of I as a black box in our subsequent derivations. Let us now introduce the notion of conditioning. Consider a spin configuration X ∈ {±1}N , a subset V (cid:48) = {v(1), . . . , v(ω)} ⊆ V (G), and define a condition S = {xv(1) = s(1), . . . , xv(ω) = s(ω)} on V (cid:48), where s(1), . . . , s(ω) = ±1 are fixed values. Conditional versions of the probability distribution (1 -- 2) and the conditional partition function become (cid:26) 1, xv(1) = s(1), . . . , xv(ω) = s(ω) 0, otherwise , (6) (7) P(XS) (cid:44) W(X) × 1(XS) where ZS (cid:44) (cid:88) , 1(XS) (cid:44) W(X) × 1(XS). ZS X∈{±1}N 8 ++ -- + Tractable Minor-free Generalization of Planar Zero-field Ising Models Notice that when ω = 0, S = {} and (6 -- 7) is reduced to (1 -- 2). The subset of V (G) is connected whenever the subgraph, induced by this subset is connected. Inference and sampling of I can be extended as follows (a formal proof can be found in the Appendix A). Lemma 6 Given I = (cid:104)G, 0, J(cid:105) where G is planar and a condition S on a connected subset V (cid:48) ⊆ V (G), V (cid:48) ≤ 3, computing the conditional partition function ZS and sampling from P(XS) are tasks of O(N 3 2 ) complexity. Intuitively, the conditioning algorithm proving the Lemma takes the subset of connected vertices and "collapses" them into a single vertex. The graph remains planar and the task is reduced to conditioning on one vertex, which is an elementary operation given the algorithm from section 2. (See Figure 2(c) for an illustration.) 3.3 Inference algorithm This subsection constructively proves the inference part of Theorem 5. For each t ∈ V (T ), let I≤t (cid:44) (cid:104)G≤t, 0,{Je e ∈ E(G≤t) ⊆ E(G)}(cid:105) denote a zero-field Ising submodel induced by G≤t. Denote the partition function and subvector of X related to I≤t as Z≤t and X≤t (cid:44) {xvv ∈ V (G≤t)}, respectively. Further, let K be t's navel and let S = {∀v ∈ K : xv = s(v)} denote some condition on K. Recall that K ≤ 3. For each t, the algorithm computes conditional partition functions ≤tS for all choices of condition spin values {s(v) = ±1}. Each t is processed only when its Z children have already been processed, so the algorithm starts at the leaf and ends at the ≤r{} is computed root. If r ∈ G(T ) is a root, its navel is empty and G≤r = G, hence Z = Z after r's processing. Suppose all children of t, c1, ..., cm ∈ V (T ) with navels K1, ..., Km ⊆ V (Gt) have already been processed, and now t itself is considered. Denote a spin configuration on Gt as Yt (cid:44) {yv = ±1 v ∈ V (Gt)}. I≤c1, ...,I≤cm are I≤t's submodels induced by G≤c1, ..., G≤cm, which can only intersect at their navels in Gt. Based on this, one states the following dynamic programming relation: 1(YtS) exp Jeyvyw e={v,w}∈E(Gt) ≤ci Si[Yt]. Z (8) Here, Si[Yt] denotes a condition {∀v ∈ Ki : xv = yv} on Ki. The goal is to efficiently perform summation in (8). Let I (0), I (1), I (2), I (3) be a partition of {1, ..., m} by navel sizes. Figure 3(a,b) illustrates inference in t. 1. Navels of size 0, 1. Notice that if i ∈ I (0), then Z ≤ci {} = Z≤ci is constant, which was ≤ci computed before. The same is true for i ∈ I (1) and Z S(i)[Yt] 2 Z≤ci. = 1 2. Navels of size 2. Let i ∈ I (2) denote Ki = {ui, qi} and simplify notation Z≤ci Z≤ci xui =y1,xqi =y2 for convenience. Notice that Z zero-field nature of I≤ci, one finds Z one arrives at log Z Bi (cid:44) log Z ≤ci −1,−1 and Z ≤ci Si[Yt] = Ai + Biyuiyqi, where Ai (cid:44) log Z ≤ci +1,+1 − log Z ≤ci +1,+1 = Z ≤ci +1,−1. (cid:44) ≤ci Si[Yt] is strictly positive, and due to the ≤ci −1,+1. Then, ≤ci +1,−1 and ≤ci +1,−1 = Z ≤ci +1,+1 + log Z y1,y2 9 (cid:88) ≤tS = Z Yt∈{±1}V (Gt)  (cid:88)  · m(cid:89) i=1 Likhosherstov, Maximov and Chertkov Figure 3: a) Example of inference at node t with children c1, c2, c3, c4. Navels K1 = {u1, q1, h1}, K2 = {u2, q2, h2}, K3 = {u2, q2}, K4 = {u4}, and K = {u, q, h} are highlighted. Fragments of I≤ci are shown with dotted lines. Here, I (0) = ∅, I (1) = {4}, I (2) = {3}, and I (3) = {1, 2}, indicating that one child is glued over one node, one child is glued over two nodes, and two children are glued over three nodes. b) "Aggregated" Ising model It and its pairwise interactions are shown. Both c) and d) illustrate sampling over It. One sample spins in It conditioned on S(t) and then repeats the procedure at the child nodes. 3. Navels of size 3. Let i ∈ I (3), and as above, denote Ki = {ui, qi, hi} and Z≤ci Z≤ci xui =y1,xqi =y2,xhi =y3. Due to the zero-field nature of I≤ci, it holds that Z there are such Ai, Bi, Ci, Di that log Z = Ai + Biy1y2 + Ciy1y3 + Diy2y3 for all y1, y2, y3 = ±1, which is guaranteed since the following system of equations has a solution: ≤ci +1,y2,y3 ≤ci −1,y2,y3 . Observe that ≤ci y1,y2,y3 y1,y2,y3 = Z (cid:44)  . log Z log Z log Z log Z  ≤tS = M ·(cid:88) (cid:88) where M (cid:44) 2−I (1) ·(cid:0)(cid:81) ≤ci +1,+1,+1 ≤ci +1,+1,−1 ≤ci +1,−1,+1 ≤ci +1,−1,−1 +1 +1 −1 −1 +1 −1 +1 −1 +1 −1 −1 +1  = Ai  × +1 +1 +1 +1 (cid:18) (cid:88) (cid:88) (cid:19) i∈I (0)∪I (1) Z≤ci(cid:1)· exp((cid:80) Considering three cases, one rewrites Eq. (8) as (Ciyuiyhi + Diyqiyhi) 1(YtS) exp e={v,w}∈E(Gt) Jeyvyw + Bi Ci Di i∈I (2)∪I (3) i∈I (3) + (9) (10) Z Yt Biyuiyqi i∈I (2)∪I (3) Ai). The sum in Eq. (10) is simply a conditional partition function of a zero-field Ising model It defined over a graph Gt with pairwise interactions of I adjusted by the addition of Bi, Ci, and Di summands at the appropriate navel edges (if a corresponding edge is not present in Gt, it has to be added). If V (Gt) ≤ c, then (10) is computed a maximum of four times (depending on navel size) by brute force (O(1) time). Otherwise, if K is a disconnected set in Gt, we add zero-interaction , 10 + -- ++ -- ++ -- -- + -- -- ++ -- ++ -- Tractable Minor-free Generalization of Planar Zero-field Ising Models edges inside it to make it connected. Possible addition of edges inside K, K1, . . . , Km doesn't destroy planarity according to the fourth item in the definition of the c-nice decomposition above. Finally, we compute (10) using Lemma 6 in time O(V (Gt) 3 2 ). The inference part of Theorem 5 follows directly from the procedure just described. 3.4 Sampling algorithm Next, we address the sampling part of Theorem 5. We extend the algorithm from section 3.3 so that it supports efficient sampling from I. Assume that the inference pass through T (from leaves to root) has been done so that It for all t ∈ V (T ) are computed. Denote Xt (cid:44) {xv v ∈ V (Gt)}. The sampling algorithm runs backwards, first drawing spin values Xr at the root r of T from the marginal distribution P(Xr), and then processing each node t of T after its parent p is processed. Processing consists of drawing spins Xt from P(Xt Xp) = P(Xt X (t) (cid:44) {xv v ∈ K}), where K is a navel of t. This marginal-conditional scheme generates the correct sample X of spins over G. Let P≤t(X≤t) define a spin distribution of I≤t. Because the Ising model is an example of Markov Random Field, it holds that P≤t(X≤t X (t)) = P(X≤t X (t)). We further derive P(Xt X (t)) = P≤t(Xt X (t)) = 1 Z≤t (cid:18) (cid:88) 1 = Z≤t · exp (cid:18) (cid:88) ∝ exp Jexvxw e={v,w}∈E(Gt) X≤t\Xt (cid:88) (cid:19) · m(cid:89) (cid:88) i=1 exp ≤ci Si[Xt] Z (cid:18) (cid:88) Jexvxw e={v,w}∈E(G≤t) (cid:19) (cid:19) (Cixuixhi + Dixqixhi) . (11) (cid:88) i∈I (3) Jexvxw + Bixuixqi + e={v,w}∈E(Gt) i∈I (2)∪I (3) In other words, sampling from P(Xt X (t)) is reduced to sampling from It conditional on spins X (t) in the navel K. It is done via brute force if V (Gt) ≤ c; otherwise, Lemma 2 ), since K ≤ 3. Sampling efforts cost as much as 6 allows one to draw Xt in O(V (Gt) 3 inference, which concludes the proof of Theorem 5. Figure 3(c,d) illustrates sampling in t. 4. Minor-free Extension of Planar Zero-field Ising Models Contraction is an operation of removing two adjacent vertices v and u (and all edges incident to them) from the graph and adding a new vertex w adjacent to all neighbors of v and u. For two graphs G and H, H is G's minor, if it is isomorphic to a graph obtained from G's subgraph by a series of contractions (Figure 2(d)). G is H-free, if H is not G's minor. According to Wagner's theorem (Diestel, 2006, chap. 4.4), a set of planar graphs coin- cides with an intersection of K33-free graphs and K5-free graphs. Some nonplanar graphs are K33-free (K5-free), for example, K5 (K33). K33-free (K5-free) graphs are neither genus- bounded (a disconnected set of g K5 (K33) graphs is K33-free (K5-free) and has a genus of g (Battle et al., 1962)). K33-free (K5-free) graphs are treewidth-unbounded as well (planar square grid of size t×t is K33-free and K5-free and has a treewidth of t (Bodlaender, 1998)). In the remainder of the section we show that a c-nice decomposition of K33-free graphs and K5-free graphs can be computed in polynomial time and, hence, inference and sampling of zero-field Ising models on these graph families can be performed efficiently. 11 Likhosherstov, Maximov and Chertkov 4.1 Zero-field Ising Models over K33-free Graphs Even though K33-free graphs are Pfaffian-orientable (with the Pfaffian orientation com- putable in polynomial time, see Vazirani (1989)), the expanded dual graph -- introduced to map the zero-field Ising model to the respective PM problem -- is not necessarily K33- free. Therefore, the latter is generally not Pfaffian-orientable. Hence, the reduction to a well-studied perfect matching counting problem is not straightforward. Theorem 7 Let G be K33-free graph of size N with no loops or multiple edges. Then the 5-nice decomposition T of G exists and can be computed in time O(N ). Proof (Sketch) An equivalent decomposition is constructed by Hopcroft and Tarjan (1973); Gutwenger and Mutzel (2001); Vo (1983) in time O(N ). We put a formal proof into Ap- pendix C. Remark 8 The O(N ) construction time of T guarantees that (cid:80) All nonplanar components in T are isomorphic to K5 or its subgraph. t∈V (T ) V (Gt) = O(N ). Therefore, if G is K33-free, it satisfies all the conditions needed for efficient inference and sampling, described in section 3. Theorem 9 For any I = (cid:104)G, 0, J(cid:105) where G is K33-free, inference or sampling of I takes O(N Proof Finding 5-nice T for G is the O(N ) operation. Provided with T , inference and sampling take at most 3 2 ) steps.  (cid:88) t∈V (T ) O V (Gt) 3 2  = O   (cid:88) t∈V (T )  3 2  = O(N V (Gt) 3 2 ) (12) where we apply convexity of f (z) = z 3 2 and the Remark after Theorem 7. 4.2 K33-free Zero-field Ising Models: Implementation and Tests In addition to theoretical justification, which is fully presented in this manuscript, we per- form emprical simulations to validate correctness of inference and sampling algorithm for K33-free zero-field Ising models. To test the correctness of inference, we generate random K33-free models of a given size and then compare the value of PF computed in a brute force way (tractable for sufficiently small graphs) and by our algorithm. See the graph generation algorithm in Appendix E. We simulate samples of sizes from {10, ..., 15} (1000 samples per size) and verify that respective expressions coincide. When testing sampling implementation, we take for granted that the produced samples do not correlate given that the sampling procedure accepts the Ising model as input and 12 Tractable Minor-free Generalization of Planar Zero-field Ising Models (a) (b) Figure 4: (a) KL-divergence of the model probability distribution compared with the em- pirical probability distribution. N, m are the model's size and the number of samples, respectively. (b) Execution time of inference (red dots) and sampling (blue dots) depending on N , shown on a logarithmic scale. Black line corresponds to O(N 3 2 ). uses independent random number generator inside. The construction does not have any memory, therefore, it generates statistically independent samples. To test that the em- pirical distribution is approaching a theoretical one (in the limit of the infinite number of samples), we draw different numbers m of samples from a model of size N . Then we find Kullback-Leibler divergence between the probability distribution of the model (here we use our inference algorithm to compute the normalization, Z) and the empirical probability, obtained from samples. Fig. 4(a) shows that KL-divergence converges to zero as the sample size increases. Zero KL-divergence corresponds to equal distributions. Finally, we simulate inference and sampling for random models of different size N and observe that the computational time (efforts) scales as O(N 4.3 Zero-field Ising Models over K5-free Graphs 3 2 ) (Figure 4(b)).1 It can be shown that result similar to the one described above for the K33-free graphs also holds for the K5-free graphs as well. Theorem 10 Let G be a K5-free graph of size N with no loops or multiple edges. Then, the 8-nice decomposition T of G exists and can be computed in time O(N ). Proof (Sketch) An equivalent decomposition is constructed by Reed and Li (2008) in time O(N ). See Appendix D for formal proof. Remark 11 The O(N ) construction time of T guarantees that (cid:80) t∈V (T ) V (Gt) = O(N ). All nonplanar components in T are isomorphic to the Mobius ladder (Figure 2(b)) or its subgraph. 1. Implementation of the algorithms is available at https://github.com/ValeryTyumen/planar ising. 13 246810log2m051015202530KL-divergenceN=10N=25N=40345678910log2N1086420246log2(sec.)C * N 1.5inferencesampling Likhosherstov, Maximov and Chertkov The graph in Figure 2(a) is actually K5-free. Theorems 5 and 10 allow us to conclude: Theorem 12 Given I = (cid:104)G, 0, J(cid:105) with K5-free G of size N , finding Z and sampling from I take O(N 3 2 ) total time. Proof Analogous to the proof of Theorem 9. 5. Approximate Inference of Square-grid Ising Model In this section, we consider I = (cid:104)G, µ, J(cid:105) such that G is a square-grid graph of size H × H. Finding Z(G, µ, J) for arbitrary µ, J is an NP-hard problem (Barahona, 1982) in such a setting. Construct G(cid:48) by adding an apex vertex connected to all G's vertices by edge (Figure 2 Z(G(cid:48), 0, J(cid:48) = (Jµ ∪ J)), where Jµ = µ 5(a)). Now it can easily be seen that Z(G, µ, J) = 1 are interactions assigned for apex edges. Let {G(r)} be a family of spanning graphs (V (G(r)) = V (G(cid:48)), E(G(r)) ⊆ E(G(cid:48))) and J (r) be interaction values on G(r). Also, denote J (r) = J (r) ∪ {0, e ∈ E(G(cid:48)) \ E(G(r))}. Assuming that log Z(G(r), 0, J (r)) are tractable, the convexity of log Z(G(cid:48), 0, J(cid:48)) allows one to write the following upper bound: ρ(r) log Z(G(r), 0, J (r)). (13) log Z(G(cid:48), 0, J(cid:48)) ≤ ρ(r)≥0,(cid:80) {J (r)},(cid:80) min r ρ(r) J (r)=J(cid:48) r ρ(r)=1 (cid:88) r After graph set {G(r)} has been fixed, one can numerically optimize the right-hand side of (13), as shown in Globerson and Jaakkola (2007) for planar G(r). The extension of the basic planar case is straightforward and is detailed in the Appendix F. The Appendix also contains description of marginal probabilities approximation suggested in Globerson and Jaakkola (2007); Wainwright et al. (2005). The choice for a planar spanning graph (PSG) family {G(r)} of Globerson and Jaakkola (2007) is illustrated in Figure 5(b). A tractable decomposition-based extension of the planar case presented in this manuscript suggests a more advanced construction -- decomposition- based spanning graphs (DSG) (Figure 5(c)). We compare performance of both PSG and DSG approaches as well as the performance of tree-reweighted approximation (TRW) (Wain- wright et al., 2005) in the following setting of Varying Interaction: µ ∼ U(−0.5, 0.5), J ∼ U(−α, α), where α ∈ {1, 1.2, 1.4, . . . , 3}. We opt optimize for grid size H = 15 (225 vertices, 420 edges) and compare upper bounds and marginal probability approximations (superscript alg) with exact values obtained using a junction tree algorithm (Verner Jensen et al., 1990) (superscript true). We compute three types of error: 1. normalized log-partition error 2. error in pairwise marginals and 1 (cid:80) H 2 (log Zalg − log Ztrue), e={v,w}∈E(G) Palg(xvxw = 1) − Ptrue(xvxw = 1), 1E(G) 3. error in singleton central marginal Palg(xv = 1) − Ptrue(xv = 1) where v is a vertex of G with coordinates (8, 8). 14 Tractable Minor-free Generalization of Planar Zero-field Ising Models We average results over 100 trials (see Fig. 6).23 We use the same quasi-Newton algo- rithm (Bertsekas, 1999) and parameters when optimizing (13) for PSG and DSG, but for most settings, DSG outperforms PSG and TRW. Cases with smaller TRW error can be explained by the fact that TRW implicitly optimizes (13) over the family of all spanning trees which can be exponentially big in size, while for PSG and DSG we only use O(H) spanning graphs. Because PSG and DSG approaches come close to each other, we additionally test for each value of α on each plot, whether the difference errP SG − errDSG is bigger than zero. We apply a one-sided Wilcoxon's test (Wilcoxon, 1945) together with the Bonferroni cor- rection because we test 33 times (Jean Dunn, 1961). In most settings, the improvement is statistically significant (Figure 6). 6. Conclusion 3 In this manuscript, we, first of all, describe an algorithm for O(N 2 ) inference and sampling of planar zero-field Ising models on N spins. Then we introduce a new family of zero-field Ising models composed of planar components and graphs of O(1) size. For these models, we describe a polynomial algorithm for exact inference and sampling provided that the decom- 3 position tree is also in the input. A theoretical application is O(N 2 ) inference and sampling algorithm for K33-free or K5-free zero-field Ising models -- both families are supersets of the family of planar zero-field models, and they are both neither treewidth- nor genus-bounded. We show that our scheme offers an improvement of the approximate inference scheme for ar- bitrary topologies. The suggested improvement is based on the planar spanning graph ideas from Globerson and Jaakkola (2007) but we use tractable spanning decomposition-based graphs instead of planar graphs. (That is we keep the algorithm of Globerson and Jaakkola (2007), but substitute planar graphs with a family of spanning decomposition-based graphs that are tractable.) This improvement of Globerson and Jaakkola (2007) results in a tighter upper bound on the true partition function and a more precise approximation of marginal probabilities. 2. Hardware used: 24-core Intel R(cid:13) Xeon R(cid:13) Gold 6136 CPU @ 3.00 GHz 3. Implementation of the algorithms is available at https://github.com/ValeryTyumen/planar_ising 15 Likhosherstov, Maximov and Chertkov Figure 5: Construction of graphs used for approximate inference on a rectangular lattice. For better visualization, vertices connected to an apex are colored white. a) G(cid:48) graph. b) One of planar G(r) graphs used in Globerson and Jaakkola (2007). Such "separator" pattern is repeated for each column and row, resulting in 2(H − 1) graphs in {G(r)}. In addition, Globerson and Jaakkola (2007) adds an independent variables graph where only apex edges are drawn. c) A modified "separator" pattern we propose. Again, the pattern is repeated horizontally and vertically resulting in 2(H − 2) graphs + independent variables graph. This pattern covers more magnetic fields and connects separated parts. Dashed edges indicate the structure of 10-nice decomposition used for inference. (Nonplanar node of size 10 is illustrated on the right.) Figure 6: Comparison of tree-reweighted approximation (TRW), planar spanning graph (PSG), and decomposition-based spanning graph (DSG) approaches. The first plot is for normalized log-partition error, the second is for error in pairwise marginals, and the third is for error in singleton central marginal. Standard errors over 100 trials are shown as error bars. An asterisk "*" indicates the sta- tistically significant improvement of DSG over PSG, with a p-value smaller than 0.01 according to the Wilcoxon test with the Bonferroni correction (Wilcoxon, 1945). 16 1.01.52.02.53.0Interaction Strength0.000.050.100.150.200.250.30Z Bound Errorp < 0.01PSGDSGTRW1.01.52.02.53.0Interaction Strength0.000.020.040.060.080.100.120.140.16Pairwise Marginals Error1.01.52.02.53.0Interaction Strength0.00.10.20.30.4Singleton Marginal Error Tractable Minor-free Generalization of Planar Zero-field Ising Models Appendix A. Lemma Proofs A.1 Lemma 1 Proof Let E(cid:48) ∈ PM(G∗). Call e ∈ E saturated, if it intersects an edge from E(cid:48) ∩ E∗ I . Each Fisher city is incident to an odd number of edges in E(cid:48) ∩ E∗ I . Thus, each face of G has an even number of unsaturated edges. This property is preserved, when two faces/cycles are merged into one by evaluating respective symmetric difference. Therefore, one gets that any cycle in G has an even number of unsaturated edges. For each i define xi := −1ri, where ri is the number of unsaturated edges on the path connecting v1 and vi. The definition is consistent due to aforementioned cycle property. Now for each e = {v, w} ∈ E(G), xv = xw if and only if e is saturated. To conclude, we constructed X such that E(cid:48) = M (X). Such X is unique, because parity of unsaturated edges on a path between v1 and vi uniquely determines relationship between x1 and xi, and x1 is always +1. A.2 Lemma 2 Proof Let X(cid:48) = (x(cid:48) chain of transitions: 1, ..., x(cid:48) N ) ∈ C+, M (X(cid:48)) = E(cid:48). The statement is justified by the following P(M (S) = E(cid:48)) = P(S = X(cid:48)) + P(S = −X(cid:48))  Je e={v,w}∈E(G) w Jex(cid:48) vx(cid:48)  2Jg(e∗) − (cid:88)  (cid:89)  (cid:89) e∗∈E(cid:48)∩E∗ ce∗ Je Je I e∗∈E(cid:48) e∈E(G) ce∗  (cid:88)  (cid:88) − (cid:88) − (cid:88) (cid:89) e∗∈E(cid:48)∩E∗ e∈E(G) e∈E(G) I ce∗ exp exp exp exp 2 Z 2 Z 2 Z 2 Z = = = = = 1 Z∗ e∗∈E(cid:48) (14) A.3 Lemma 6 Proof We consider cases depending on ω and consequently reduce each case to a simpler one. For convenience in cases where applies we denote u (cid:44) v(1), h (cid:44) v(2), q (cid:44) v(3): 1. Conditioning on ω = 0 spins. Trivial given the algorithm described in section 2. 17 Likhosherstov, Maximov and Chertkov 2. Conditioning on ω = 1 spin. Since configurations X and −X have the same probability in I, one deduces that Z xu=s(1) = 1 One also deduces that sampling X from P(X xu = s(1)) is reduced to 1) drawing X = {xv = ±1} from P(X) and then 2) returning X = (s(1)xu) · X as a result. 2 Z. 3. Conditioning on ω = 2 spins. There is an edge e0 = {u, h} ∈ E(G). The following expansion holds: Z xu=s(1),xh=s(2) = (cid:88) X, xu=s(1), xh=s(2) = exp(Je0s(1)s(2)) · = exp(Je0s(1)s(2)) · (cid:88) + e={u,v}∈E(G) v(cid:54)=h e={v,w}∈E(G) exp(cid:0) (cid:88) (cid:88) (cid:88) Jexvxw (cid:1) exp(cid:0) (cid:88) exp(cid:0) (cid:88) (cid:88) e(cid:54)=e0 X, xu=s(1), xh=s(2) e={v,w}∈E(G) (cid:1) Jexvxw Jexvxw X, xu=s(1), xh=s(2) (Jes(1))xv · 1 + e∩e0=∅ e={v,w}∈E(G) (Jes(2))xv · 1(cid:1) (15) e={h,v}∈E(G) v(cid:54)=u Obtain graph G(cid:48) from G by contracting u, h into z. G(cid:48) is still planar and has N − 1 vertices. Preserve pairwise interactions of edges which were not deleted after contrac- tion. For each edge e = {u, v}, v (cid:54)= h set J{z,v} = Jes(1), for each edge e = {h, v}, v (cid:54)= u set J{z,v} = Jes(2). Collapse double edges in G(cid:48) which were possibly created by transforming into single edges. A pairwise interaction of the result edge is set to the sum of collapsed interactions. Define a zero-field Ising model I(cid:48) on the resulted graph G(cid:48) with its pairwise inter- actions, inducing a distribution P(cid:48)(X(cid:48) = {x(cid:48) v = ±1v ∈ V (G(cid:48))}). Let Z(cid:48) denote I(cid:48)'s partition function. A closer look at (15) reveals that Z xu=s(1),xh=s(2) = exp(Je0s(1)s(2)) · Z(cid:48) x(cid:48) z=1 (16) where Z(cid:48) y=1 is a partition function conditioned on a single spin and can be found z(cid:48) efficiently as shown above. Since the equality of sums (16) holds summand-wise, for a given X(cid:48)(cid:48) = {x(cid:48)(cid:48) v = ±1 v ∈ V (G) \ {u, h}} the probabilities P(X(cid:48)(cid:48) ∪ {xu = s(1), xh = s(2)} xu = s(1), xh = s(2)) and P(cid:48)(X(cid:48)(cid:48) ∪ {x(cid:48) z = 1) are the same. Hence, sampling from P(X xu = s(1), xh = s(2)) is reduced to conditional sampling from planar zero-field Ising model P(cid:48)(X(cid:48) x(cid:48) z = 1} x(cid:48) z = 1) of size N − 1. 4. Conditioning on w = 3 spins. Without loss of generality assume that u, h are connected by an edge e0 in G. A derivation similar to (15) and (16) reveals that (preserving the notation of Case 2) Z xu=s(1),xh=s(2),xq=s(3) = exp(Je0s(1)s(2)) · Z(cid:48) x(cid:48) z=1,x(cid:48) q=s(3) (17) 18 Tractable Minor-free Generalization of Planar Zero-field Ising Models which reduces inference conditional on 3 vertices to a simpler case of 2 vertices. Again, sampling from P(X xu = s(1), xt = s(2), xq = s(3)) is reduced to a more basic sampling from P(cid:48)(X(cid:48) x(cid:48) z = 1, x(cid:48) q = s(3)). In principle, Lemma 6 can be extended to arbitrarily large ω leaving a certain freedom for the Ising model conditioning framework. However, in this manuscript we focus on a given special case which is enough for our goals. Appendix B. Theorem 3 Proof B.1 Counting PMs of Planar G in O( N 3 2 ) time This section addresses inference part of Theorem 3. B.1.1 Pfaffian Orientation Consider an orientation on G. G's cycle of even length (built on an even number of vertices) is said to be odd-oriented, if, when all edges along the cycle are traversed in any direction, an odd number of edges are directed along the traversal. For X ⊆ V ( G) let G(X) denote a graph (X,{e ∈ E( G)e ⊆ X}). An orientation of G is called Pfaffian, if all cycles C, such that PM( G(V ( G) − C)) (cid:54)= ∅, are odd-oriented. We will need G to contain a Pfaffian orientation, moreover the construction is easy. Theorem 13 Pfaffian orientation of G can be constructed in O( N ). Proof This theorem is proven constructively, see e.g. Wilson (1997); Vazirani (1989), or Schraudolph and Kamenetsky (2009), where the latter construction is based on specifics of the expanded dual graph. Construct a skew-symmetric sparse matrix K ∈ R N× N (→ denotes orientation of edges): Kij = if {vi, vj} ∈ E( G), vi → vj if {vi, vj} ∈ E( G), vj → vi if {vi, vj} /∈ E( G) (18) ce −ce 0 √ The next result allows to compute PF Z of PM model on G in a polynomial time. Theorem 14 detK > 0, Z = detK. Proof See, e.g., Wilson (1997) or Kasteleyn (1963). B.1.2 Computing detK LU-decomposition of a matrix A = LU , found via Gaussian elimination, where L is a lower- triangular matrix with unit diagonals and U is an upper-triangular matrix, would be a 19 Likhosherstov, Maximov and Chertkov standard way of computing det A, which is then equal to a product of the diagonal elements of U . However, this standard way of constructing the LU decomposition applies only if all A's leading principal submatrices are nonsingular (See e.g. Horn and Johnson (2012), section 3.5, for detailed discussions). And already the 1 × 1 leading principal submatrix of K is zero/singular. Luckily, this difficulty can be resolved through the following construction. Take G's arbitrary perfect matching E(cid:48) ∈ PM( G). In the case of a general planar graph E(cid:48) can be 3 found via e.g. Blum's algorithm (Blum, 1990) in O( 2 ) time, while for graph G∗ appearing in this paper E(cid:48) can be found in O(N ) from a spin configuration using I = M ({+1, ..., +1}) ∈ PM(G∗)). Modify ordering of vertices, M mapping (e.g. E(cid:48) = E∗ V ( G) = {v1, v2, ..., v N}, so that E(cid:48) = {{v1, v2}, ...,{v N−1, v N}}. Build K according to the definition (18). Obtain K from K by swapping column 1 with column 2, 3 with 4 and so on. This results in detK = detK, where the new K is properly conditioned. Lemma 15 K's leading principal submatrices are nonsingular. Proof The proof, presented in Wilson (1997) for the case of unit weights ce, generalizes to arbitrary positive ce. (cid:112) NE( G)) = O( N Notice, that in the general case (of a matrix represented in terms of a general graph) complexity of the LU-decomposition is cubic in the size of the matrix. Fortunately, nested dissection technique, discussed in the following subsection, allows to reduce complexity of computing Z to O( N 3 2 ). N and P3 ≤ 2 3 2 3 (cid:112) N . The LT Lipton and Tarjan (LT) (Lipton and Tarjan, 1979) found an O( N ) algorithm, which B.1.3 Nested Dissection The partition P1, P2, P3 of set V ( G) is a separation of G, if for any v ∈ P1, w ∈ P2 it holds that {v, w} /∈ E( G). We refer to P1, P2 as the parts, and to P3 as the separator. finds a separation P1, P2, P3 such that max(P1,P2) ≤ 2 algorithm can be used to construct the so called nested dissection ordering of V ( G). The ordering is built recursively, by first placing vertices of P1, then P2 and P3, and finally permuting indices of P1 and P2 recursively according to the ordering of G(P1) and G(P2) (See Lipton et al. (1979) for accurate description of details, definitions and analysis of the nested dissection ordering). As shown by Lipton et al. (1979) the complexity of finding the nested dissection ordering is O( N log N ). Let A be a N × N matrix with a sparsity pattern of G. That is, Aij can be nonzero only if i = j or {vi, vj} ∈ E. Theorem 16 (Lipton et al., 1979) If V is ordered according to the nested dissection and A's leading principal submatrices are nonsingular, computing the LU-decomposition of A becomes a problem of the O(N Notice, however, that we cannot directly apply the Theorem to K, because the sparsity pattern of K is asymmetric and does not correspond, in general, to any graph. Let G∗∗ be a planar graph, obtained from G, by contracting each edge in E(cid:48), V (G∗∗) = E(cid:48) = 1 N . Find and fix a nested dissection ordering over V (G∗∗) (it takes O( N log N ) 3 2 ) complexity. 2 20 Tractable Minor-free Generalization of Planar Zero-field Ising Models steps) and let the {v1, v2}, . . . ,{v N−1, v N} enumeration of E(cid:48) correspond to this ordering. Split K into 2 × 2 cells and consider the sparsity pattern of the nonzero cells. One observes that the resulting sparsity pattern coincides with the sparsity patterns of K and G∗∗. Since LU-decomposition can be stated in the 2 × 2 block elimination form, its complexity is reduced down to O( N 3 2 ). This concludes construction of an efficient inference (counting) algorithm for planar PM model. B.2 Sampling PMs of Planar G in O( N 3 2 ) time (Wilson's Algorithm) This section addresses sampling part of Theorem 3. In this section we assume that degrees of G's vertices are upper-bounded by 3. This is true for G∗ - the only type of PM model appearing in the paper. Any other constant substituting 3 wouldn't affect the analysis of complexity. Moreover, Wilson (1997) shows that any PM model on a planar graph can be reduced to bounded-degree planar model without affecting O( N 3 2 ) complexity. B.2.1 Structure of the Algorithm Denote a sampled PM as M , P(M ) = Z−1(cid:81) (cid:112) N ). Then it iterates over v ∈ P3 and for each v it draws an edge of M , e∈M ce. Wilson's algorithm first applies LT algorithm of Lipton and Tarjan (1979) to find a separation P1, P2, P3 of G (max(P1,P2) ≤ N , P3 ≤ 2 2 3 saturating v. Then it appears that, given this intermediate result, drawing remaining edges of M may be split into two independent drawings over G(P1) and G(P2), respectively, and then the process is repeated recursively. 3 2 It takes O( N 3 2 ) steps to sample edges attached to P3 at the first step of the recursion, therefore the overall complexity of the Wilson's algorithm is also O( N 3 2 ). Subsection B.2.2 introduces probabilities required to draw the aforementioned PM sam- ples. Subsections B.2.3 and B.2.4 describe how to sample edges attached to the separator, while Subsection B.3 focuses on describing the recursion. B.2.2 Drawing Perfect Matchings For some Q ∈ E( G) consider the probability of getting Q as a subset of M : (cid:19) (cid:18)(cid:89) · (cid:88) e∈M(cid:48) ce (cid:88) (cid:18)(cid:89) Q⊆M(cid:48) ce e∈Q M(cid:48)∈PM( G) (cid:19) P(Q ⊆ M ) = = 1 Z 1 Z M(cid:48)∈PM( G) e∈M(cid:48)\Q (cid:18) (cid:89) (cid:19) ce (19) Let VQ = ∪e∈Qe and G\Q = G(V ( G) \ VQ). Then the set {M(cid:48) \ Q M(cid:48) ∈ PM( G)} coincides with PM( G\Q). This yields the following expression (cid:19) (cid:18)(cid:89) e∈Q P(Q ⊆ M ) = Z\Q Z 21 ce (20) where Likhosherstov, Maximov and Chertkov (cid:88) (cid:18) (cid:89) M(cid:48)(cid:48)∈PM( G\Q) e∈M(cid:48)(cid:48) (cid:19) ce Z\Q = (21) is a PF of the PM model on G\Q induced by the edge weights ce. For a square matrix A let Ar1,...,rl and columns c1, ..., cl from A. Let [A]r1,...,rl columns c1, ..., cl of A and placing them in this order. c1,...,cl denote the matrix obtained by deleting rows r1, ..., rl c1,...,cl be obtained by leaving only rows r1, ..., rl and Now let VQ = {vi1, ..., vir}, i1 < ... < ir. A simple check demonstrates that deleting vertex from a graph preserves the Pfaffian orientation. By induction this holds for any number of vertices deleted. From that it follows that Ki1,...,ir is a Kasteleyn matrix for G\Q and then i1,...,ir resulting in Z\Q = pf Ki1,...,ir (cid:115) i1,...,ir P(Q ⊆ M ) = (cid:113) = detKi1,...,ir i1,...,ir detKi1,...,ir i1,...,ir detK · (cid:18)(cid:89) e∈Q ce (cid:19) (22) (23) Linear algebra transformations, described by Wilson (1997), suggest that if A is non- singular, then det Ar1,...,rl c1,...,cl This observation allows us to express probability (19) as = ± det[A−1]c1,...,cl r1,...,rl det A (cid:113) det[K−1]i1,...,ir i1,...,ir · (cid:18)(cid:89) e∈Q P(Q ⊆ M ) = (cid:19) ce (24) (25) Now we are in the position to describe the first step of the Wilson's recursion. B.2.3 Step 1: Computing Lower-Right Submatrix of K−1 Find a separation P1, P2, P3 of G. The goal is to sample an edge from every v ∈ P3. Let W be a set of vertices from P3 and their neighbors, then W ≤ 3P3 because each vertex in G is of degree at most 3. Let W ∗∗ ⊆ V (G∗∗) be a set of the contracted edges (recall G∗∗ definition from Subsection B.1.3), containing at least one vertex from W , W ∗∗ ≤ W. Then W ∗∗ is a separator of G∗∗ such that (cid:112) N ≤ 3 · 22(cid:112)V (G∗∗) W ∗∗ ≤ W ≤ 3P3 ≤ 3 · 2 3 2 (26) where one uses that, V (G∗∗) = N 2 . Find a nested dissection ordering (Subsection B.1.3) of V (G∗∗) with W ∗∗ as a top-level separator. This is a correct nested dissection due to Eq. (26). Utilizing this ordering, construct K. Compute L and U - LU-decomposition of K (O( N (cid:112) N and let I be a shorthand notation for ( N − γ + 1, ..., N ). 3 2 ) I, which is a lower-right K−1 ]I 's submatrix of size γ × γ. time). Let γ = 2W ∗∗ ≤ 3· 2 Using L and U , find D = [K−1 5 2 22 Tractable Minor-free Generalization of Planar Zero-field Ising Models It is straightforward to observe that the i-th column of D, di, satisfies (cid:18) (cid:19) [L]I I × [U ]I I × di = ei, (27) where ei is a zero vector with unity at the i-th position. Therefore constructing D is reduced to solving 2γ triangular systems, each of size γ × γ, resulting in O(γ3) = O( N 3 2 ) required steps. B.2.4 Step 2: Sampling Edges in the Separator Now, progressing iteratively, one finds v ∈ P3 which is not yet paired and draw an edge emanating from it. Suppose that the edges, e1 = {vj1, vj2}, ..., ek = {vj2k−1, vj2k}, are already sampled. We assume that by this point we have also computed LU-decomposition Ak = [K−1]j1,...,j2k = LkUk and we will update it to Ak+1 when the new edge is drawn. Then j1,...,j2k P(e1, ..., ek ∈ M ) =(cid:112) det Ak k(cid:89) j=1 cej (28) Next we choose j2k+1 so that vj2k+1 is not saturated yet. We iterate over vj2k+1's neigh- bors considered as candidates for becoming vj2k+2. Let vj to become the next candidate, denote ek+1 = {vj2k+1, vj}. For n ∈ N let α(n) = n + 1 if n is odd and α(n) = n − 1 if n is even. Then the identity ]α(1),α(2),...,α( N ) , 1,2,..., N follows from the definition of K. One deduces from Eq. (29) K−1 = [K−1 (29) Ak+1 = [K−1]j1,...,j2k+1,j j1,...,j2k+1,j = [K−1 (30) Constructing W ∗∗ one has j1, ..., j2k+1, j, α(j1), ..., α(j2k+1), α(j) > N − t. It means that ]α(j1),...,α(j2k+1),α(j) j1,...,j2k+1,j Ak+1 is a submatrix of D with permuted rows and columns, hence Ak+1 is known. We further observe that Ak+1 = (cid:20)Ak y (cid:21) r d = (cid:20)Lk 0 (cid:21)(cid:20)Uk Y (cid:21) R 1 0 z = Lk+1Uk+1 (31) Therefore to update Lk+1 and Uk+1, one just solves the triangular system of equations RUk = r and LkY = y, where R(cid:62), r(cid:62), Y, y are of size 2k × 2 (this is done in O(k2) steps), and then compute z = d − RY which is of the size 2 × 2, then set, u = det z. The probability to pair vj2k+1 and vj is P(ek+1 ∈ M e1, ..., ek ∈ M ) = = = 23 P(e1, ..., ek+1 ∈ M ) P(e1, ..., ek ∈ M ) (cid:112) det Ak+1(cid:81)k+1 (cid:112) det Ak(cid:81)k (cid:112)u det Ak (cid:112) det Ak cek+1 j=1 cej j=1 cej Likhosherstov, Maximov and Chertkov (cid:112)u = cek+1 (32) Therefore maintaining Uk+1 allows us to compute the required probability and draw a new edge from vj2k+1. By construction of G, vj2k+1 has only 3 neighbors, therefore the complexity of this step is O((cid:80)P3 (cid:112) N . 3 2 k=1 k2) = O( N 3 2 ) because P3 ≤ 2 B.3 Step 3: Recursion Let Msep = {e1, e2, ...} be a set of edges drawn on the previous step, and Vsep be a set of vertices saturated by Msep, P3 ⊆ Vsep. Given Msep, the task of sampling M ∈ PM( G) such that Msep ⊆ M is reduced to sampling perfect matchings M1 and M2 over G(P1 \ Vsep) and G(P2 \ Vsep), respectively. Then M = M1 ∪ M2 ∪ Msep becomes the result of the perfect matching drawn from (4). Even though only the first step of the Wilson's recursion was discussed so far, any further step in the recursion is done in exactly the same way with the only exception that vertex degrees may become less than 3, while in G they are exactly 3. Obviously, this does not change the iterative procedure and it also does not affect the complexity analysis. Appendix C. Theorem 7 Proof Prior to the proof we introduce a series of definitions and results. We follow Hopcroft and Tarjan (1973); Gutwenger and Mutzel (2001), see also Mader (2008) to define the tree of triconnected components. The definitions apply for a biconnected graph G (see the definition of biconnected graph and biconnected component e.g. in Appendix D.) Let v, w ∈ V (G). Divide E(G) into equivalence classes E1, ..., Ek so that e1, e2 are in the same class if they lie on a common simple path that has v, w as endpoints. E1, ..., Ek are referred to as separation classes. If k ≥ 2, then {v, w} is a separation pair of G, unless (a) k = 2 and one of the classes is a single edge or (b) k = 3 and each class is a single edge. Graph G is called triconnected if it has no separation pairs. Let {v, w} be a separation pair in G with equivalence classes E1, ..., Ek. Let E(cid:48) = ∪l i=1El, i=l+1El be such that E(cid:48) ≥ 2, E(cid:48)(cid:48) ≥ 2. Then, graphs G1 = (∪e∈E(cid:48)e, E(cid:48)∪{eV}), G2 = E(cid:48)(cid:48) = ∪k (∪e∈E(cid:48)(cid:48)e, E(cid:48)(cid:48) ∪ {eV}) are called split graphs of G with respect to {v, w}, and eV is a virtual edge, which is a new edge between v and w, identifying the split operation. Due to the addition of eV , G1 and G2 are not normal in general. Split G into G1 and G2. Continue splitting G1, G2, and so on, recursively, until no further split operation is possible. The resulting graphs are split components of G. They can either be K3 (triangles), triple bonds, or triconnected normal graphs. Let eV be a virtual edge. There are exactly two split components containing eV : G1 = (V1, E1) and G2 = (V2, E2). Replacing G1 and G2 with G(cid:48) = (V1∪V2, (E1∪E2)\{eV}) is called merging G1 and G2. Do all possible mergings of the cycle graphs (starting from triangles), and then do all possible mergings of multiple bonds starting from triple bonds. Components of the resulting set are referred to as the triconnected components of G. We emphasize again that some graphs (i.e., cycles and bonds) in the set of triconnected com- ponents are not necessarily triconnected. 24 Tractable Minor-free Generalization of Planar Zero-field Ising Models Figure 7: (I) An example biconnected graph G. (II) A separation pair {a, b} of G and separation classes E1, E2, E3 associated with {a, b}. (III) Result of split operation with E(cid:48) = E1 ∪ E2, E(cid:48)(cid:48) = E3. Dashed lines indicate virtual edges and dotted lines connect equivalent virtual edges in split graphs. (IV) Split components of G (non-unique). (V) Triconnected components of G. (VI) Triconnected component tree T of G; spacial alignment of V is preserved. "G," "B," and "C" are examples of the "triconnected graph," "multiple bond," and "cycle," respectively. Lemma 17 (Hopcroft and Tarjan, 1973) Triconnected components are unique for G. Total number of edges within the triconnected components is at most 3E − 6. Consider a graph T (cid:48), where vertices (further referred to as nodes for disambiguation) are triconnected components, and there is an edge between a and b in T (cid:48), when a and b share a (copied) virtual edge. Lemma 18 (Hopcroft and Tarjan, 1973) T (cid:48) is a tree. We will also use the following celebrated result: Lemma 19 (Hall, 1943) Biconnected graph G is K33-free if and only if its nonplanar tri- connected components are exactly K5. The graph on Figure 7 is actually K33-free according to the Lemma. Now we are in the position to give a proof of the Theorem 7. Proof Since G is K33-free and has no loops or multiple edges, it holds that E(G) = O(N ) (Thomason, 2001). In time O(N ) we can find a forest of G's biconnected components (Tarjan, 1971). If we find the 5-nice decomposition of each biconnected component, we can trivially combine them into a single 5-nice decomposition in time O(N ) using navels of size 0 and 1. Hence, we can assume that G is biconnected. Build a tree of triconnected components for G in time O(N ) (Hopcroft and Tarjan, 1973; Gutwenger and Mutzel, 2001; Vo, 1983). Now delete virtual edges, which results in a 5-nice decomposition of G, given the Lemma 19. 25 Likhosherstov, Maximov and Chertkov Appendix D. Proof for Theorem 10 Prior to the proof, we introduce a series of definitions used by Reed and Li (2008). It is assumed that a graph G = (V, E) (no loops and multiple edges) is given. For any X ⊆ V (G) let G−X denote a graph (V (G)\X,{e = {v, w} ∈ E(G) v, w /∈ X}). X ⊆ V (G) is a (i, j)-cut whenever X = i and G− X has at least j connected components. The graph is biconnected whenever it has no (1, 2)-cut. A biconnected component of the graph is a maximal biconnected subgraph. Clearly, a pair of biconnected components can intersect in at most one vertex and a graph of components' intersections is a tree when G is connected (a tree of biconnected components). The graph is 3-connected whenever it has no (2, 2)-cut. A 2-block tree of a biconnected graph G, written (cid:104)T (cid:48),G(cid:48)(cid:105), is a tree T (cid:48) with a set G(cid:48) = t}t∈V (T (cid:48)) with the following properties: {G(cid:48) -- G(cid:48) -- If G is 3-connected then T (cid:48) has a single node r which is colored 1 and G(cid:48) -- If G is not 3-connected then there exists a color 2 node t ∈ V (T (cid:48)) such that t is a graph (possibly with multiple edges) for each t ∈ V (T (cid:48)). r = G. 1. G(cid:48) 1, . . . , T (cid:48) t is a graph with two vertices u and v and no edges for some (2, 2)-cut {u, v} in G. k be the connected components (subtrees) of T (cid:48) − t. Then G − 2. Let T (cid:48) {u, v} has k connected components U1, . . . , Uk and there is a labelling of these i = (V (Ui) ∪ {u, v}, E(Ui) ∪ components such that T (cid:48) {{u, v}}). i ) such that {u, v} ⊆ 3. For each i, there exists exactly one color 1 node ti ∈ V (T (cid:48) is a 2-block tree of G(cid:48) i V (G(cid:48) ti). 4. For each i, {t, ti} ∈ E(T ). A (3, 3)-block tree of a 3-connected graph G, written (cid:104)T (cid:48)(cid:48),G(cid:48)(cid:48)(cid:105), is a tree T (cid:48)(cid:48) with a set G(cid:48)(cid:48) = {G(cid:48)(cid:48) -- G(cid:48)(cid:48) t }t∈V (T (cid:48)(cid:48)) with the following properties: t is a graph (possibly with multiple edges) for each t ∈ V (T (cid:48)(cid:48)). -- If G has no (3, 3)-cut then T has a single node r which is colored 1 and Gr = G. -- If G has a (3, 3)-cut then there exists a color 2 node t ∈ V (T (cid:48)(cid:48)) such that 1. G(cid:48)(cid:48) 1 , . . . , T (cid:48)(cid:48) t is a graph with vertices u, v and w and no edges for some (3, 3)-cut {u, v, w} in G. k be the connected components (subtrees) of T (cid:48)(cid:48) − t. Then G − 2. Let T (cid:48)(cid:48) {u, v, w} has k connected components U1, . . . , Uk and there is a labelling of these i = (V (Ui)∪{u, v, w}, E(Ui)∪ components such that Ti is a (3, 3)-block tree of G(cid:48)(cid:48) {{u, v},{v, w},{u, w}}). i ), such that {u, v, w} ⊆ 3. For each i, there exists exactly one color 1 node ti ∈ V (T (cid:48)(cid:48) V (G(cid:48)(cid:48) ti). 26 Tractable Minor-free Generalization of Planar Zero-field Ising Models 4. For each i, {t, ti} ∈ E(T (cid:48)(cid:48)). Proof Since G is K5-free and has no loops or multiple edges, it holds that E(G) = O(N ) (Thomason, 2001). In time O(N ) we can find a forest of G's biconnected components (Tarjan, 1971). If we find an 8-nice decomposition for each biconnected component, join them into a single 8-nice decomposition by using attachment sets of size 1 for decompositions inside G's connected component and attachment sets of size 0 for decompositions in different connected components. Hence, further we assume that G is biconnected. The O(N ) algorithm of Reed and Li (2008) finds a 2-block tree (cid:104)T (cid:48),G(cid:48)(cid:105) for G and then t ∈ G(cid:48) it finds (3, 3)-block tree (cid:104)T (cid:48)(cid:48),G(cid:48)(cid:48)(cid:105) where all components are for each color 1 node G(cid:48) either planar or Mobius ladders. To get an 8-nice decomposition from each (3, 3)-block tree, 1) for each color 2 node contract an edge between it and one of its neighbours in T (cid:48)(cid:48) and 2) remove all edges which were only created during (cid:104)T (cid:48)(cid:48),G(cid:48)(cid:48)(cid:105) construction (2nd item of (3, 3)-block tree definition). Now we have to draw additional edges in the forest F of obtained 8-nice decompositions so that to get a single 8-nice decomposition T of G. Notice that for each pair of adjacent s = ({u, v}, ∅) is a color 2 node, u, v t, G(cid:48) nodes G(cid:48) are in V (G(cid:48) r of 8-nice decomposition of G(cid:48) t where both u and v are present. For each pair of s and t draw an edge between s and r in F . Then 1) for each color 2 node in F (such as s) contract an edge between it and one of its neighbors (such as r) and 2) remove all edges which were created during (cid:104)T (cid:48),G(cid:48)(cid:105) construction (2nd item of 2-block tree definition). This results is a correct c-nice decomposition for biconnected G. t). Hence, there is at least one component G(cid:48)(cid:48) s ∈ G(cid:48) where G(cid:48) t) and {u, v} ∈ E(G(cid:48) t is color 1 node and G(cid:48) Appendix E. Random Graph Generation As our derivations cover the most general case of planar and K33-free graphs, we want to test them on graphs which are as general as possible. Based on Lemma 19 (notice, that it provides necessary and sufficient conditions for a graph to be K33-free) we implement a randomized construction of K33-free graphs, which is assumed to cover most general K33-free topologies. Namely, one generates a set of K5's and random planar graphs, attaching them by edges to a tree-like structure. Our generation process consists of the following two steps. 1. Planar graph generation. This step accepts N ≥ 3 as an input and generates a normal biconnected planar graph of size N along with its embedding on a plane. The details of the construction are as follows. First, a random embedded tree is drawn iteratively. We start with a single vertex, on each iteration choose a random vertex of an already "grown" tree, and add a new vertex connected only to the chosen vertex. Items I-V in Fig. 8 illustrate this step. Then we triangulate this tree by adding edges until the graph becomes biconnected and all faces are triangles, as in the Subsection 2.1 (VI in Figure 8). Next, to get a normal graph, we remove multiple edges possibly produced by triangulation (VII in Fig. 8). At this point the generation process is complete. 27 Likhosherstov, Maximov and Chertkov Figure 8: Steps of planar graph generation. I-V refers to random tree construction on a plane, VI is a triangulation of a tree, VII is a result after multiple edges removal. 2. K33-free graph generation. Here we take N ≥ 5 as the input and generate a normal biconnected K33-free graph G in a form of its partially merged decomposition T . Namely, we generate a tree T of graphs where each node is either a normal biconnected planar graph or K5, and every two adjacent graphs share a virtual edge. The construction is greedy and is essentially a tree generation process from Step 1. We start with K5 root and then iteratively create and attach new nodes. Let N(cid:48) < N be a size of the already generated graph, N(cid:48) = 5 at first. Notice, that when a node of size n is generated, it contributes n − 2 new vertices to G. An elementary step of iteration here is as follows. If N − N(cid:48) ≥ 3, a coin is flipped and the type of new node is chosen - K5 or planar. If N − N(cid:48) < 3, K5 cannot be added, so a planar type is chosen. If a planar node is added, its size is drawn uniformly in the range between 3 and N − N(cid:48) + 2 and then the graph itself is drawn as described in Step 1. Then we attach a new node to a randomly chosen free edge of a randomly chosen node of T (cid:48). We repeat this process until G is of the desired size N . Fig. 9 illustrates the algorithm. To obtain an Ising model from G, we sample pairwise interactions for each edge of G independently from N (0, 0.12). Notice that the tractable Ising model generation procedure is designed in this section solely for the convenience of testing and it is not claimed to be sampling models of any particular practical interest (e.g. in statistical physics or computer science). Appendix F. Upper Bound Minimization and Marginal Computation in Approximation Scheme Given a fixed ρ, we compute g(J(cid:48), ρ) using L-BFGS-B optimization (Zhu et al., 1997) by back-propagating through Z(G(r), 0, J (r)) and projecting gradients on the constraint linear manifold. On the upper level we also apply L-BFGS-B algorithm to compute h(J(cid:48)), which is possible since (Wainwright et al., 2005; Globerson and Jaakkola, 2007) ∂ ∂ρ(r) g(J(cid:48), ρ) = log Z(G(r), 0, J (r) min) − (M (r))(cid:62)J (r) min, M (r) (cid:44) ∂ ∂J (r) min log Z(G(r), 0, J (r) min) 28 Denote: h(J(cid:48)) (cid:44) ρ(r)≥0,(cid:80) min {J (r)},(cid:80) where h(J(cid:48)) is a tight upper bound for log Z(G(cid:48), 0, J(cid:48)). g(J(cid:48), ρ) (cid:44) g(J(cid:48), ρ), r ρ(r)=1 (cid:88) r ρ(r) log Z(G(r), 0, J (r)) min r ρ(r) J (r)=J(cid:48) Tractable Minor-free Generalization of Planar Zero-field Ising Models Figure 9: Generation of K33-free graph G and its partially merged decomposition T (cid:48). Start- ing with K5 (I), new components are generated and attached to random free edges (II-V). VI is a result graph G obtained by merging all components in T (cid:48). where {J (r) min} is argmin inside g(J(cid:48), ρ)'s definition and M (r) = {M (r) a vector of pairwise marginal expectations. We reparameterize ρ(r) into w(r) > 0. e ∈ E(G(r))} is w(r)(cid:80) r(cid:48) w(r(cid:48)) where For e = {v, w} ∈ E(G) we approximate pairwise marginal probabilities as Wainwright e et al. (2005); Globerson and Jaakkola (2007) Palg(xvxw = 1) = · [ 1 2 ρ(r)M (r) e ] + 1 2 (cid:88) r (cid:88) r Let eA be an edge between central vertex v and apex in G(cid:48). We approximate singleton marginal probability at vertex v as Palg(xv = 1) = · [ 1 2 ρ(r)M (r) eA ] + 1 2 References F Barahona. On the computational complexity of Ising spin glass models. Journal of Physics A: Mathematical and General, 15(10):3241, 1982. Joseph Battle, Frank Harary, and Yukihiro Kodama. Additivity of the genus of a graph. Bull. Amer. Math. Soc., 68(6):565 -- 568, 11 1962. Richard Bellman. On the theory of dynamic programming. Proceedings of the National Academy of Sciences, 38(8):716 -- 719, 1952. D.P. Bertsekas. Nonlinear Programming. Athena Scientific, 1999. H.A. Bethe. Statistical theory of superlattices. Proceedings of Royal Society of London A, 150:552, 1935. 29 Likhosherstov, Maximov and Chertkov L Bieche, J P Uhry, R Maynard, and R Rammal. On the ground states of the frustration model of a spin glass by a matching method of graph theory. Journal of Physics A: Mathematical and General, 13(8):2553, 1980. Norbert Blum. A new approach to maximum matching in general graphs. In Michael S. Paterson, editor, Automata, Languages and Programming, pages 586 -- 597, Berlin, Heidel- berg, 1990. Springer Berlin Heidelberg. Hans L. Bodlaender. A partial k-arboretum of graphs with bounded treewidth. Theoretical Computer Science, 209(1):1 -- 45, 1998. John M Boyer and Wendy J Myrvold. On the cutting edge: Simplified O(n) planarity by edge addition. J. Graph Algorithms Appl., 8(2):241 -- 273, 2004. Radu Curticapean. Counting perfect matchings in graphs that exclude a single-crossing minor. arXiv preprint arXiv:1406.4056, 2014. R. Diestel. Graph Theory. Electronic library of mathematics. Springer, 2006. Michael E. Fisher. On the dimer solution of planar Ising models. Journal of Mathematical Physics, 7(10):1776 -- 1781, 1966. R.G. Gallager. Low density parity check codes. MIT Press, Cambridge, MA, 1963. Anna Gallucio and Martin Loebl. On the theory of pfaffian orientations. I: Perfect matchings and permanents. The Electronic Journal of Combinatorics, 6(1):Research paper R6, 18 p. -- Research paper R6, 18 p., 1999. Amir Globerson and Tommi S Jaakkola. Approximate inference using planar graph decom- position. In Advances in Neural Information Processing Systems, pages 473 -- 480, 2007. Carsten Gutwenger and Petra Mutzel. A linear time implementation of SPQR-trees. In Joe Marks, editor, Graph Drawing, pages 77 -- 90, Berlin, Heidelberg, 2001. Springer Berlin Heidelberg. Dick Wick Hall. A note on primitive skew curves. Bull. Amer. Math. Soc., 49(12):935 -- 936, 12 1943. J. Hopcroft and R. Tarjan. Dividing a graph into triconnected components. SIAM Journal on Computing, 2(3):135 -- 158, 1973. Roger A. Horn and Charles R. Johnson. Matrix Analysis. Cambridge University Press, 2 edition, 2012. Olive Jean Dunn. Multiple comparisons among means. Journal of The American Statistical Association - J AMER STATIST ASSN, 56:52 -- 64, 03 1961. M. Jerrum and A. Sinclair. Polynomial-time approximation algorithms for the Ising model. SIAM Journal on Computing, 22(5):1087 -- 1116, 1993. 30 Tractable Minor-free Generalization of Planar Zero-field Ising Models M. Kac and J. C. Ward. A combinatorial solution of the two-dimensional Ising model. Phys. Rev., 88:1332 -- 1337, Dec 1952. Pieter W Kasteleyn. Dimer statistics and phase transitions. Journal of Mathematical Physics, 4(2):287 -- 293, 1963. Richard J Lipton and Robert Endre Tarjan. A separator theorem for planar graphs. SIAM Journal on Applied Mathematics, 36(2):177 -- 189, 1979. Richard J. Lipton, Donald J. Rose, and Robert Endre Tarjan. Generalized nested dissection. SIAM Journal on Numerical Analysis, 16(2):346 -- 358, 1979. Martin Mader. Planar graph drawing. Master's thesis, University of Konstanz, Konstanz, 2008. Lars Onsager. Crystal statistics. I: A two-dimensional model with an order-disorder tran- sition. Phys. Rev., 65:117 -- 149, Feb 1944. Judea Pearl. Reverend bayes on inference engines: A distributed hierarchical approach. In Proceedings of the Second AAAI Conference on Artificial Intelligence, AAAI'82, pages 133 -- 136. AAAI Press, 1982. H.A. Peierls. Ising's model of ferromagnetism. Proceedings of Cambridge Philosophical Society, 32:477 -- 481, 1936. Bruce Reed and Zhentao Li. Optimization and recognition for K5-minor free graphs in linear time. In Eduardo Sany Laber, Claudson Bornstein, Loana Tito Nogueira, and Luerbio Faria, editors, LATIN 2008: Theoretical Informatics, pages 206 -- 215, Berlin, Heidelberg, 2008. Springer Berlin Heidelberg. Nicol N. Schraudolph and Dmitry Kamenetsky. Efficient exact inference in planar Ising models. In D. Koller, D. Schuurmans, Y. Bengio, and L. Bottou, editors, Advances in Neural Information Processing Systems 21, pages 1417 -- 1424. Curran Associates, Inc., 2009. S. Straub, T. Thierauf, and F. Wagner. Counting the number of perfect matchings in K5- free graphs. In 2014 IEEE 29th Conference on Computational Complexity (CCC), pages 66 -- 77, June 2014. R. Tarjan. Depth-first search and linear graph algorithms. In 12th Annual Symposium on Switching and Automata Theory (SWAT 1971), pages 114 -- 121, Oct 1971. Creighton K. Thomas and A. Alan Middleton. Exact algorithm for sampling the two- dimensional Ising spin glass. Phys. Rev. E, 80:046708, Oct 2009. Creighton K Thomas and A Alan Middleton. Numerically exact correlations and sampling in the two-dimensional Ising spin glass. Physical Review E, 87(4):043303, 2013. Andrew Thomason. The extremal function for complete minors. J. Comb. Theory Ser. B, 81(2):318 -- 338, March 2001. 31 Likhosherstov, Maximov and Chertkov Vijay V. Vazirani. NC algorithms for computing the number of perfect matchings in K3,3- free graphs and related problems. Information and Computation, 80(2):152 -- 164, 1989. Finn Verner Jensen, Kristian Olesen, and Stig Andersen. An algebra of Bayesian belief universes for knowledge based systems. Networks, 20:637 -- 659, 08 1990. Kiem-Phong Vo. Finding triconnected components of graphs. Linear and Multilinear Alge- bra, 13(2):143 -- 165, 1983. Martin J Wainwright, Tommi S Jaakkola, and Alan S Willsky. A new class of upper bounds on the log partition function. IEEE Transactions on Information Theory, 51(7):2313 -- 2335, 2005. Frank Wilcoxon. Individual comparisons by ranking methods. Biometrics bulletin, 1(6): 80 -- 83, 1945. David Bruce Wilson. Determinant algorithms for random planar structures. In Proceedings of the Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '97, pages 258 -- 267, Philadelphia, PA, USA, 1997. Society for Industrial and Applied Mathematics. Ciyou Zhu, Richard H. Byrd, Peihuang Lu, and Jorge Nocedal. Algorithm 778: L-BFGS-B: Fortran subroutines for large-scale bound-constrained optimization. ACM Trans. Math. Softw., 23(4):550 -- 560, December 1997. 32
1803.04327
3
1803
2018-07-24T05:31:40
New Algorithms for Weighted $k$-Domination and Total $k$-Domination Problems in Proper Interval Graphs
[ "cs.DS", "cs.DM", "math.CO" ]
Given a positive integer $k$, a $k$-dominating set in a graph $G$ is a set of vertices such that every vertex not in the set has at least $k$ neighbors in the set. A total $k$-dominating set, also known as a $k$-tuple total dominating set, is a set of vertices such that every vertex of the graph has at least $k$ neighbors in the set. The problems of finding the minimum size of a $k$-dominating, respectively total $k$-dominating set, in a given graph, are referred to as $k$-domination, respectively total $k$-domination. These generalizations of the classical domination and total domination problems are known to be NP-hard in the class of chordal graphs, and, more specifically, even in the classes of split graphs (both problems) and undirected path graphs (in the case of total $k$-domination). On the other hand, it follows from recent work of Kang et al.~(2017) that these two families of problems are solvable in time $\mathcal{O}(|V(G)|^{6k+4})$ in the class of interval graphs. We develop faster algorithms for $k$-domination and total $k$-domination in the class of proper interval graphs, by means of reduction to a single shortest path computation in a derived directed acyclic graph with $\mathcal{O}(|V(G)|^{2k})$ nodes and $\mathcal{O}(|V(G)|^{4k})$ arcs. We show that a suitable implementation, which avoids constructing all arcs of the digraph, leads to a running time of $\mathcal{O}(|V(G)|^{3k})$. The algorithms are also applicable to the weighted case.
cs.DS
cs
New Algorithms for Weighted k-Domination and Total k-Domination Problems in Proper Interval Graphs Nina Chiarelli∗1,2, Tatiana Romina Hartinger†1,2, Valeria Alejandra Leoni‡3,4, Maria In´es Lopez Pujato§3,5, and Martin Milanic¶1,2 1University of Primorska, Faculty of Mathematics, Natural Sciences and Information Technologies, Glagoljaska 8, SI-6000 Koper, Slovenia 2University of Primorska, Andrej Marusic Institute, Muzejski trg 2, SI-6000 Koper, Slovenia 3FCEIA, Universidad Nacional de Rosario, Rosario, Santa Fe, Argentina 4CONICET, Argentina 5ANPCyT, Argentina November 5, 2018 Abstract Given a positive integer k, a k-dominating set in a graph G is a set of vertices such that every vertex not in the set has at least k neighbors in the set. A total k-dominating set, also known as a k-tuple total dominating set, is a set of vertices such that every vertex of the graph has at least k neighbors in the set. The problems of finding the minimum size of a k-dominating, respectively total k-dominating set, in a given graph, are referred to as k-domination, respectively total k-domination. These generalizations of the classical domination and total domination problems are known to be NP-hard in the class of chordal graphs, and, more specifically, even in the classes of split graphs (both problems) and undirected path graphs (in the case of total k-domination). On the other hand, it follows from recent work of Kang et al. (2017) that these two families of problems are solvable in time O(V (G)6k+4) in the class of interval graphs. We develop faster algorithms for k-domination and total k-domination in the class of proper interval graphs, by means of reduction to a single shortest path computation in a derived directed acyclic graph with O(V (G)2k) nodes and O(V (G)4k) arcs. We show that a suitable implementation, which avoids constructing all arcs of the digraph, leads to a running time of O(V (G)3k). The algorithms are also applicable to the weighted case. Keywords: k-domination, total k-domination, proper interval graph, polynomial-time algorithm 1 Introduction Variants of domination in graphs form a rich area of graph theory, with many useful and interesting concepts, results, and challenging problems [32, 33, 35]. In this paper we consider a family of generalizations of classical domination and total domination known as k-domination ∗[email protected][email protected][email protected] §[email protected][email protected] 1 and total k-domination. Given a graph G and a positive integer k, a k-dominating set in G is a set S ⊆ V (G) such that every vertex v ∈ V (G) \ S has at least k neighbors in S, and a total k-dominating set in G is a set S ⊆ V (G) such that every vertex v ∈ V (G) has at least k neighbors in S. The k-domination and the total k-domination problems aim to find the minimum size of a k-dominating, resp. total k-dominating set, in a given graph. The notion of k-domination was introduced by Fink and Jacobson in 1985 [25] and studied in a series of papers (e.g., [14, 22, 24, 29, 45]) and in a survey Chellali et al. [13]. The notion of total k-domination was introduced by Kulli in 1991 [44] and studied under the name of k-tuple total domination by Henning and Kazemi in 2010 [34] and also in a series of recent papers [1, 42, 46, 56]. The terminology "k-tuple total domination" was introduced in analogy with the notion of "k-tuple domination", introduced in 2000 by Harary and Haynes [31].1 The redundancy involved in k-domination and total k-domination problems makes them useful in various applications, for example in forming sets of representatives or in resource allocation in distributed computing systems (see, e.g., [33]). However, these problems are known to be NP-hard [40, 56] and also hard to approximate [18]. The k-domination and total k-domination problems are NP-hard not only for general graphs but also in the class of chordal graphs. More specifically, the problems are NP-hard in the class of split graphs [45, 56] and, in the case of total k-domination, also in the class of undirected path graphs [46]. We consider k-domination and total k-domination in another subclass of chordal graphs, the class of proper interval graphs. A graph G is an interval graph if it has an intersection model consisting of closed intervals on a real line, that is, if there exist a family I of intervals on the real line and a one-to-one correspondence between the vertices of G and the intervals of I such that two vertices are joined by an edge in G if and only if the corresponding intervals intersect. A proper interval graph is an interval graph that has a proper interval model, that is, an intersection model in which no interval contains another one. Proper interval graphs were introduced by Roberts [60], where it was shown that they coincide with the unit interval graphs, that is, interval graphs having an intersection model consisting of intervals of unit length. Various characterizations of proper interval graphs have been developed in the literature (see, e.g., [26,28,39,52]) and several linear-time recognition algorithms are known, which in case of a yes instance also compute a proper interval model (see, e.g., [20] and references cited therein). The usual domination and total domination problems (that is, when k = 1) are known to be solvable in linear time in the class of interval graphs (see [6, 12, 36] and [10, 12, 43, 58, 59], respectively). Furthermore, for each fixed integer k ≥ 1, the k-domination and total k-domination problems are solvable in time O(n6k+4) in the class of interval graphs where n is the order of the input graph. This follows from recent results due to Kang et al. [41], building on previous works by Bui-Xuan et al. [8] and Belmonte and Vatshelle [3]. In fact, Kang et al. studied a more general class of problems, called (ρ, σ)-domination problems, and showed that every such problem can be solved in time O(n6d+4) in the class of n-vertex interval graphs, where d is a parameter associated to the problem (see Corollary 3.2 in [41] and the paragraph following it). The value of parameter d for k-domination and total k-domination equals k, yielding the claimed time complexity. 1.1 Our Results and Approach To the best of our knowledge, the only known polynomial-time algorithms for k-domination and total k-domination for a general (fixed) k in the class of interval graphs follow from the above-mentioned work of Kang et al. [41] and run in time O(n6k+4). We significantly improve 1A set S of vertices is said to be a k-tuple dominating set if every vertex of G is adjacent or equal to at least k vertices in S. 2 the above result for the case of proper interval graphs. We show that for each positive integer k, the k-domination and total k-domination problems are solvable in time O(n3k) in the class of proper interval graphs. Except for k = 1, this significantly improves on the best known running time. Our approach is based on a reduction showing that for each positive integer k, the total k-domination problem on a given proper interval graph G can be reduced to a shortest path computation in a derived edge-weighted directed acyclic graph. A similar reduction works for k-domination. The reductions immediately result in algorithms with running time O(n4k+1). We then show that with a suitable implementation the running time can be improved to O(n3k). The algorithms can be easily adapted to the weighted case, at no expense in the running time. An extended abstract of this work appeared in the Proceedings of ISCO 2018 [16]. 1.2 Related Work We now give an overview of related work and compare our results with the most related other results, in addition to those due to Kang et al. [41], which motivated this work. Overview. Several results on the complexity of k-domination and total k-domination problems were established in the literature. For every k, the k-domination problem is NP-hard in the classes of bipartite graphs [2] and split graphs [45]. The problem is solvable in linear time in the class of graphs every block of which is a clique, a cycle or a complete bipartite graph (including trees, block graphs, cacti, and block-cactus graphs) [45], and, more generally, in any class of graphs of bounded clique-width [21, 53] (see also [17]). For every positive integer k, the total k-domination problem is NP-hard in the classes of split graphs [56], doubly chordal graphs [56], bipartite graphs [56], undirected path graphs [46], and, for k ∈ {2, 3}, also in the class of bipartite planar graphs [1]. The problem is solvable in linear time in the class of graphs every block of which is a clique, a cycle, or a complete bipartite graph [46], and, more generally, in any class of graphs of bounded clique-width [21, 53], and in polynomial time in the class of chordal bipartite graphs [56]. k-domination and total k-domination problems were also studied with respect to their (in)approximability properties, both in general [18] and in restricted graph classes [2], as well as from the parameterized complexity point of view [9, 37]. Besides k-domination and total k-domination, other variants of domination problems solvable in polynomial time in the class of proper interval graphs (or in some of its superclasses) include k-tuple domination for all k ≥ 1 [48] (see also [47] and, for k = 2, [57]), connected domination [59], independent domination [23], paired domination [15], efficient domination [11], liar's domination [54], restrained domination [55], eternal domination [5], power domination [49], outer-connected domination [51], Roman domination [50], Grundy domination [7], etc. Comparison. Bertossi [4] showed how to reduce the total domination problem in a given interval graph to a shortest path computation in a derived edge-weighted directed acyclic graph satisfying some additional constraints on pairs of consecutive arcs. A further transformation reduces the problem to a usual (unconstrained) shortest path computation. Compared to the approach of Bertossi, our approach exploits the additional structure of proper interval graphs in order to gain generality in the problem space. Our approach works for every k and is also more direct, in the sense that the (usual or total, unweighted or weighted) k-domination problem in a given proper interval graph is reduced to a shortest path computation in a derived edge-weighted directed acyclic graph in a single, unified step. The works of Liao and Chang [48] and of Lee and Chang [47] consider various domination problems in the class of strongly chordal graphs (and, in the case of [48], also dually chordal graphs). While the class of strongly chordal graphs generalizes the class of interval graphs, the domination problems studied in [47, 48] all deal with closed neighborhoods, and for those cases 3 structural properties of strongly chordal and dually chordal graphs are helpful for the design of linear-time algorithms. In contrast, k-domination and total k-domination are defined via open neighborhoods and results of [47, 48] do not seem to be applicable or easily adaptable to our setting. Structure of the paper. In Section 2, we describe the reduction for the total k-domination problem. The specifics of the implementation resulting in improved running time are given in Section 3. In Section 4, we discuss how the approach can be modified to solve the k-domination problem. Extensions to the weighted cases are presented in Section 5. We conclude the paper with some open problems in Section 6. In the rest of the section, we fix some definitions and notation. Given a graph G and a set X ⊆ V (G), we denote by G[X] the subgraph of G induced by X and by G − X the subgraph induced by V (G) \ X. For a vertex u in a graph G, we denote by N (u) the set of neighbors of u in G. Note that for every graph G, the set V (G) is a k-dominating set, while G has a total k-dominating set if and only if every vertex of G has at least k neighbors. For notions not defined here, we refer the reader to [19, 61]. 2 The Reduction for Total k-Domination Let k be a positive integer and G = (V, E) a given proper interval graph. We may assume that G is equipped with a proper interval model I = {Ij j = 1, . . . , n} where Ij = [aj, bj] for all j = 1, . . . , n. We may also assume that no two intervals coincide. Moreover, since in a proper interval model the order of the left endpoints equals the order of the right endpoints, we assume that the intervals are sorted increasingly according to their left endpoints, i.e., a1 < . . . < an. We use notation Ij < I(cid:96) if j < (cid:96) and say in this case that Ij is to the left of I(cid:96) and I(cid:96) is to the right of Ij. Also, we write Ij ≤ I(cid:96) if j ≤ (cid:96). Given three intervals Ij, I(cid:96), Im ∈ I, we say that interval I(cid:96) is between intervals Ij and Im if j < (cid:96) < m. We say that interval Ij intersects interval I(cid:96) if Ij ∩ I(cid:96) (cid:54)= ∅. Our approach can be described as follows. Given G, we compute an edge-weighted directed acyclic graph Dt k (where the superscript "t" means "total" and k is the constant specifying the problem) and show that the total k-domination problem on G can be reduced to a shortest path computation in Dt k and illustrate the construction on an example (Example 2.1). Next we explain the intuition behind the reduction and, finally, prove the correctness of the reduction. k. In what follows, we first give the definition of digraph Dt To distinguish the vertices of Dt k by s, s(cid:48), s(cid:48)(cid:48). Each node of Dt k from those of G, we refer to them as nodes. Vertices of G are typically denoted by u or v, and nodes of Dt k is a sequence of intervals from the set I(cid:48) = I ∪ {I0, In+1}, where I0, In+1 are two new, "dummy" intervals such that I0 < I1, I0 ∩ I1 = ∅, In < In+1, and In ∩ In+1 = ∅. We naturally extend the linear order < on I to the whole set I(cid:48). We say that an interval I ∈ I(cid:48) is associated with a node s of Dt k if it appears in sequence s. Given a node s of Dt k, we denote the set of all intervals associated with s by Is. The first and the last interval in Is with respect to ordering < of I(cid:48) are denoted by min(s) and max(s), respectively. A sequence (Ii1, . . . , Iiq ) of intervals from I is said to be increasing if i1 < . . . < iq. k is given by V (Dt The node set of Dt • I0 and In+1 are sequences of intervals of length one.2 2This assures that the intervals min(s) and max(s) are well defined also for s ∈ {I0, In+1}, in which case both k) = {I0, In+1} ∪ S ∪ B, where: are equal to s. 4 • S is the set of so-called small nodes. Set S consists exactly of those increasing sequences s = (Ii1, . . . , Iiq ) of (not necessarily consecutive) intervals from I such that: (1) k + 1 ≤ q ≤ 2k − 1, (2) Iij ∩ Iij+1 (cid:54)= ∅ for all j ∈ {1, . . . , q − 1}, and (3) every interval I ∈ I such that min(s) ≤ I ≤ max(s) intersects at least k intervals from the set Is \ {I}. • B is the set of so-called big nodes. Set B consists exactly of those increasing sequences s = (Ii1, . . . , Ii2k ) of (not necessarily consecutive) intervals from I of length 2k such that: (1) Iij ∩ Iij+1 (cid:54)= ∅ for all j ∈ {1, . . . , 2k − 1} and (2) every interval I ∈ I such that Iik ≤ I ≤ Iik+1 intersects at least k intervals from the set Is \ {I}. The arc set of Dt • Set E0 consists exactly of those ordered pairs (s, s(cid:48)) ∈ V (Dt k is given by E(Dt k) = E0 ∪ E1, where: k) × V (Dt k) such that: (1) max(s) < min(s(cid:48)) and max(s) ∩ min(s(cid:48)) = ∅, (2) every interval I ∈ I such that max(s) < I < min(s(cid:48)) intersects at least k intervals from Is ∪ Is(cid:48), (3) if s is a big node, then the rightmost k + 1 intervals associated with s pairwise intersect, and (4) if s(cid:48) is a big node, then the leftmost k + 1 intervals associated with s(cid:48) pairwise intersect. • Set E1 consists exactly of those ordered pairs (s, s(cid:48)) ∈ V (Dt k) such that s, s(cid:48) ∈ B and there exist 2k + 1 intervals Ii1, . . . , Ii2k+1 in I such that s = (Ii1, Ii2, . . . , Ii2k ) and s(cid:48) = (Ii2, Ii3, . . . , Ii2k+1). To every arc (s, s(cid:48)) of Dt k we associate a non-negative length (cid:96)(s, s(cid:48)), defined as follows: k) × V (Dt  Is(cid:48), 1, 0, (cid:96)(s, s(cid:48)) = if (s, s(cid:48)) ∈ E0 and s(cid:48) (cid:54)= In+1; if (s, s(cid:48)) ∈ E1; otherwise. (∗) The length of a directed path in Dt k is defined, as usual, as the sum of the lengths of its arcs. Example 2.1. Consider the problem of finding a minimum total 2-dominating set in the graph G given by the proper interval model I depicted in Figure 1(a). Using the reduction described above, we obtain the digraph Dt 2 depicted in Figure 1(c) along with the length function on arcs, where, for clarity, nodes (Ii1, . . . , Iip) of Dt 2 are identified with the corresponding strings of indices i1i2 . . . ip. We also omit in the figure the (irrelevant) nodes that do not belong to any directed path from I0 to In+1. There is a unique shortest I0, I9-path in Dt 2, namely (0, 2356, 3567, 9). The path corresponds to {2, 3, 5, 6, 7}, the only minimum total 2-dominating set in G. Lemma 2.2. Given a graph G and a positive integer k, let U be a total k-dominating set in G, and let C be a component of G[U ]. Then V (C) ≥ k + 1. 5 Figure 1: (a) A proper interval model I, (b) the corresponding proper interval graph G, and (c) a part of the derived digraph Dt 2, where only nodes that lie on some directed path from I0 to I9 are shown. Edges in E1 are depicted bold. Proof. Let u ∈ V (C). Since U is a total k-dominating set, u has at least k neighbors in U . However, since C is a component of G[U ], all the neighbors of u in U are in fact in C. Thus, V (C) ≥ {u} ∪ (N (u) ∩ U ) ≥ k + 1. The following proposition establishes the correctness of the reduction. Proposition 2.3. Given a proper interval graph G and a positive integer k, let Dt k be the directed graph constructed as above. Then G has a total k-dominating set of size c if and only if Dt k has a directed path from I0 to In+1 of length c. Before giving a detailed proof of Proposition 2.3, we explain the intuition behind the reduction. The subgraph of G induced by a minimum total k-dominating set may contain several connected components. These components as well as vertices within them are naturally ordered from left to right. Moreover, since each connected subgraph of a proper interval graph has a Hamiltonian path, the nodes of Dt k correspond to paths in G, see condition (2) for small nodes or condition (1) for big nodes. Since each vertex of G has at least k neighbors in the total k-dominating set, each component has at least k + 1 vertices. Components with at least 2k vertices give rise to directed paths in Dt k consisting of big nodes and arcs in E1. Each component with less than 2k vertices corresponds to a unique small node in Dt k, which can be seen as a trivial directed path in Dt k. The resulting paths inherit the left-to-right ordering from the components. Any two consecutive paths (with respect to this ordering) are joined in Dt k by an arc in E0. Moreover, I0 is joined to the leftmost node of the leftmost path by an arc in E0 and, symmetrically, the rightmost node of the rightmost path is joined to In+1 by an arc in E0. Adding such arcs yields a directed path from I0 to In+1 of the desired length. The above process can be reversed. Given a directed path P in Dt k from I0 to In+1, a total k-dominating set in G of the desired size can be obtained as the set of all vertices corresponding 6 I1I2(a)II3I4I5I612354(b)GI7I8768Dt2123678123412352345234634563467356745674678S2356133011111444414000B(c)091 to intervals in I associated with the internal nodes of P . Note that our construction of the graph Dt k implies that such a set is indeed a total k-dominating set in G. For example, condition (3) from the definition of arcs in E0 guarantees that the vertex corresponding to the rightmost interval associated with s ∈ B (where (s, s(cid:48)) ∈ E0) is k-dominated. The condition is related to the fact that in proper interval graphs the neighborhood of a vertex represented by an interval [a, b] splits into two cliques: one for all intervals containing a and another one for all intervals containing b. The digraph Dt k has O(n2k) nodes and O(n4k) arcs and can be, together with the length function (cid:96) on its arcs, computed from G directly from the definition in time O(n4k+1). A shortest directed path (with respect to (cid:96)) from I0 to all nodes reachable from I0 in Dt k can be computed in polynomial time using any of the standard approaches, for example using Dijkstra's algorithm. Actually, since Dt k is acyclic, a dynamic programming approach along a topological ordering of Dt k can be used to compute shortest paths from I0 in linear time (in the size of Dt k). Proposition 2.3 therefore implies that the total k-domination problem is solvable in time O(n4k+1) in the class of n-vertex proper interval graphs. We will show in Section 3 that, with a careful implementation, a shortest I0, In+1-path in Dt k can be computed without examining all the arcs of the digraph, leading to an improved running time of O(n3k). Proof of Proposition 2.3 We assume all notation up to Example 2.1 and, additionally, fix the following notation useful for X ⊆ V (G), we denote by I X the set of intervals in I for both directions of the proof: corresponding to vertices in X. First we establish the forward implication. Suppose that G has a total k-dominating set U of size c. The components of G[U ] can be naturally ordered from left to right, say as C1, . . . , Cr. To each component Ci we will associate a path P i in Dt k defined as a sequence of nodes. The k will be then obtained by combining the paths P i desired directed path P from I0 to In+1 in Dt into a single sequence of nodes preceded by I0 and followed by In+1. We say that a component Ci is small if V (Ci) < 2k and big, otherwise. To every small component Ci we associate a sequence si = (Ii1, . . . , Iip), consisting of the p = V (Ci) intervals corresponding to the vertices of Ci, ordered increasingly. We claim that si is a small node of Dt k. By Lemma 2.2, Ci has at least k + 1 vertices, which, together with the fact that Ci is small, implies property (1) of the definition of a small node. Property (2) follows from the fact that I is a proper interval model of G and Ci is connected. To show that si satisfies property (3) of the definition of a small node, consider an interval I ∈ I such that min(si) ≤ I ≤ max(si). Let u be the vertex of G corresponding to I. Since U is a total k-dominating set, vertex u has at least k neighbors in U . Since min(si) ≤ I ≤ max(si), all the neighbors of u in U must belong to Ci, more specifically, N (u)∩ U ⊆ V (Ci)\{u}. It follows that I intersects at least k intervals from the set Isi \ {I}, establishing also property (3) and with it the claim that si is a small node of Dt k. The path P i associated to component Ci is the one-node path having si as a node. Let now Ci be a big component and let p = V (Ci). Then p ≥ 2k. Let Ij1, . . . , Ijp be the intervals corresponding to the vertices of Ci, ordered increasingly. For every q ∈ {1, . . . , p − 2k + 1}, let si q denote the subsequence of these intervals of length 2k starting at q-th interval, q = (Ijq , Ijq+1, . . . , Ijq+2k−1). We claim that for each q ∈ {1, . . . , p − 2k + 1}, sequence that is, si k. Property (1) follows from the fact that I is a proper interval model si q is a big node of Dt of G and Ci is connected. To show that si q satisfies property (2) of the definition of a big node, consider an interval I ∈ I such that Ijq+k−1 ≤ I ≤ Ijq+k and let u be the vertex of G corresponding to I. Since U is a total k-dominating set, vertex u has at least k neighbors in U . 7 q q q q q such that I ∩ I(cid:48) (cid:54)= ∅. Note that {Ij1, . . . , Ijp} \ Isi Since Ij1 ≤ I ≤ Ijp, all the neighbors of u in U must belong to Ci. It follows that I intersects at least k intervals from the set {Ij1, . . . , Ijp} \ {I}. Suppose for a contradiction that I intersects \ {I} = {Ijq , Ijq+1, . . . , Ijq+2k−1} \ {I}. Since I strictly less that k intervals from the set Isi intersects at least k intervals from the set {Ij1, . . . , Ijp} \ {I}, there is an interval, call it I(cid:48), in = I1 ∪ I2 where the set {Ij1, . . . , Ijp} \ Isi I1 = {Ij1, . . . , Ijq−1} and I2 = {Ijq+2k , . . . , Ijp}. Suppose first that I(cid:48) ∈ I1, that is, I(cid:48) = Ijα for some α ∈ {1, . . . , q − 1}. Since I is a proper interval model of G, conditions Ijq+k−1 ≤ I ≤ Ijq+k and Ijq+k−1 ∩ Ijq+k (cid:54)= ∅ imply that interval I intersects each of the two intervals Ijq+k−1 and Ijq+k (possibly I ∈ {Ijq+k−1, Ijq+k}). Similarly, the fact that I intersects both I(cid:48) = Ijα and Ijq+k implies that I also intersects each of the intervals in the set {Ijα, Ijα+1, . . . , Ijq+k}; in particular, I intersects each of the k + 1 intervals in the set {Ijq , Ijq+1, . . . , Ijq+k}, all of which are in Isi . \ {I}, contradicting the It follows that interval I intersects at least k intervals from the set Isi assumption on I. The case I(cid:48) ∈ I2 is symmetric to the case I(cid:48) ∈ I1. This establishes property (2) and with it the claim that si k. The path associated to component Ci is defined as P i = si p−2k+1. q is a big node of Dt 1, . . . , si Let P denote the sequence of nodes of Dt k obtained by combining the paths P i into a single sequence of nodes preceded by I0 and followed by In+1 in the natural order I0, P 1, . . . , P r, In+1. Since U (cid:54)= ∅, the paths P i are pairwise node-disjoint, and none of them contains I0 or In+1, path P has at least 3 nodes. Moreover, note that for each node s of P other than I0 and In+1, the vertices of G corresponding to intervals associated with s all belong to the same component of G[U ], call it Cs. We claim that P is a path in Dt k, that is, that every two consecutive nodes of P form an k. Consider a pair s, s(cid:48) of consecutive nodes of P . Clearly, s (cid:54)= In+1. We consider three arc in Dt subcases depending on whether s = I0, s ∈ S, or s ∈ B. Suppose first that s = I0. We claim that (s, s(cid:48)) ∈ E0. Property (1) of the definition of the edges in E0 clearly holds, as does (vacuously) property (3) (since I0 /∈ B). To show property (2), consider an interval I ∈ I such that max(s) < I < min(s(cid:48)). Since U is a total k-dominating set, interval I intersects at least k intervals from I U . Since I < min(s(cid:48)) and min(s(cid:48)) is the leftmost interval corresponding to a vertex of U , it follows that I intersects the k leftmost intervals from I U . All these intervals belong to vertices from component C1, and therefore to Is(cid:48). This establishes property (2). A similar argument shows that if s(cid:48) ∈ B, then in order to make sure that the vertex corresponding to min(s(cid:48)) has at least k neighbors in U , interval min(s(cid:48)) must intersect the k intervals associated with s(cid:48) immediately following min(s(cid:48)) in the sequence. This implies that the leftmost k + 1 intervals associated with s(cid:48) pairwise intersect, thus establishing property (4). It follows that (s, s(cid:48)) ∈ E0, as claimed. Suppose now that s ∈ S. We claim that (s, s(cid:48)) ∈ E0. Property (1) of the definition of the edges in E0 follows from the construction of P and the fact that Cs (cid:54)= Cs(cid:48). Property (2) follows from the construction of P together with the fact that U is a total k-dominating set in G. Property (3) is satisfied vacuously. A similar argument as in the case s = I0 establishes property (4). It follows that (s, s(cid:48)) ∈ E0, as claimed. Suppose now that s ∈ B. If s(cid:48) ∈ S, then we conclude that (s, s(cid:48)) ∈ E0 by symmetry with the case s ∈ S, s(cid:48) ∈ B. If s(cid:48) = In+1, then we conclude that (s, s(cid:48)) ∈ E0 by symmetry with the case s = I0. Let now s(cid:48) ∈ B. If Cs (cid:54)= Cs(cid:48), then we can use similar arguments as in the case s ∈ S to show that (s, s(cid:48)) ∈ E0. If Cs = Cs(cid:48), let i ∈ {1, . . . , r} be the index such that Cs = Ci. The construction of P implies that s and s(cid:48) are nodes of P i such that s = si for some q ∈ {1, . . . , p − 2k} where p = V (Ci). The definitions of si (s, s(cid:48)) ∈ E1, showing in particular that (s, s(cid:48)) is an arc of Dt k. q+1 q+1 now imply that q and s(cid:48) = si q and si This shows that P is a directed path from I0 to In+1 in Dt k, as claimed. Furthermore, the 8 definition of the length function (cid:96) and the construction of P imply that the length of P equals the size of U , which is c. Now we establish the backward implication. Suppose that Dt k has a directed path P from I0 to In+1 of length c. Let U be the set of all vertices u ∈ V (G) such that the interval corresponding to u is associated with some node of P . We claim that U is a total k-dominating set in G of size c. Note that since neither of I0 and In+1 is a big node, (I0, In+1) (cid:54)∈ E1; moreover, (I0, In+1) (cid:54)∈ E0 since condition (2) in the definition of an arc in E0 fails. Therefore, (I0, In+1) (cid:54)∈ E(Dt k) and P has at least 3 nodes. The set of nodes of P can be uniquely partitioned into consecutive sets of nodes, say W0, W1, . . . , Wr, Wr+1, such that each Wi is the node set of a maximal subpath P (cid:48) of P such that E(P (cid:48)) ⊆ E1. (Equivalently, the Wi's are the vertex sets of the components of the undirected graph underlying the digraph P − E0.) Note that W0 = {I0} and Wr+1 = {In+1}. For all i ∈ {0, 1, . . . , r +1}, let Ui be the set of vertices of G corresponding to intervals associated with nodes in Wi. We claim that for every 0 ≤ i < j ≤ r + 1 and for every pair of intervals I ∈ I Ui and J ∈ I Uj we have I < J and I ∩ J = ∅. This can be proved by induction on d = j − i. If d = 1, then let (s, s(cid:48)) be the unique arc of P connecting a vertex in Wi with a vertex in Wi+1. By the definition of the Wi's, we have (s, s(cid:48)) (cid:54)∈ E1 and therefore (s, s(cid:48)) ∈ E0. This implies that every interval associated with s is smaller (with respect to ordering <) and disjoint from every interval associated with s(cid:48). Consequently, the definitions of Wi, Wi+1, Ui, Ui+1, and the properties of the arcs in E0 imply that every interval in I Ui is smaller (with respect to ordering <) and disjoint from every interval in I Ui+1. The inductive step follows from the transitivity of the relation on I(cid:48) in which interval I is in relation with interval J if and only if I < J and I ∩ J = ∅. The above claim implies that no edge of G connects a vertex in Ui with a vertex in Uj whenever 1 ≤ i < j ≤ r. More specifically, we claim that for every i ∈ {1, . . . , r}, the subgraph of G induced by Ui is a component of G[U ]. This can be proved using the properties of the k, as follows. Let i ∈ {1, . . . , r}. Suppose first that Wi ∩ S (cid:54)= ∅. Since every arc in arcs in Dt E1 connects a pair of big nodes, we infer that Wi = {s} for some s ∈ S. Using property (2) in the definition of a small node, we infer that G[Ui] is connected. Therefore, since no edge of G connects a vertex in Ui with a vertex in Uj for j (cid:54)= i, we infer that G[Ui] is a component of G[U ], as claimed. Suppose now that Wi ∩ S = ∅, that is, Wi ⊆ B. Let P (cid:48) be the subpath of P such that V (P (cid:48)) = Wi. Since P (cid:48) consists only of big nodes and only of arcs in E1, we can use property (1) in the definition of a big node to infer that G[Ui] is connected. It follows that G[Ui] is a component of G[U ] also in this case. Let us now show that the size of U equals the length of P . This will imply that U ≤ c. For every i ∈ {1, . . . , r + 1}, let P i be the subpath of P of consisting of all the arcs of P entering a node in Wi. By construction, the paths P 1, . . . , P r+1 are pairwise arc-disjoint and their union is P . For every i ∈ {1, . . . , r + 1}, let (cid:96)i denote the the length of P i. The definitions of the Wi's and of the length function imply that (cid:96)i = (cid:96)(si, s(cid:48) i) is the (unique) arc of P such that si (cid:54)∈ Wi and s(cid:48) i ∈ Wi. Since (si, s(cid:48) , (cid:96)(si, s(cid:48) i) + Wi − 1, where (si, s(cid:48) i) ∈ E0, we have if i ∈ {1, . . . , r}; if i = r + 1. (cid:26) Is(cid:48) i) = 0, i Furthermore, we have Is(cid:48) the subgraph of G induced by Ui is a component of G[U ], we have U =(cid:80)r (cid:96)i = +Wi− 1 = Ui for all i ∈ {1, . . . , r}, which implies (cid:96)i = Ui. Since i=1 (cid:96)i, i=1 Ui =(cid:80)r+1 0, i i + Wi − 1, if i ∈ {1, . . . , r}; if i = r + 1. It follows that (cid:26) Is(cid:48) 9 Suppose first that q ≤ k + 1. Let (s(cid:48), s(cid:48)(cid:48)) be the (unique) arc of P such that s(cid:48) which is exactly the length of P (this follows from the fact that the paths P 1, . . . , P r+1 are pairwise arc-disjoint and their union is P ). Therefore, U = c. It remains to show that U is a total k-dominating set of G, that is, that every vertex u ∈ V (G) has at least k neighbors in U . Let u ∈ V (G), let I ∈ I be the interval corresponding to u. We need to show that I intersects at least k intervals from the set I U \ {I}. We consider two cases depending on whether u ∈ U or not. Case 1. u ∈ U . In this case, I ∈ I U and I is associated with some node of P . Let s ∈ V (P ) be such a node. Note that s (cid:54)∈ {I0, In+1}. By construction of U , we have Is ⊆ I U . Suppose first that s is a small node. Then, condition (3) in the definition of a small node implies that I intersects at least k intervals from the set Is \ {I}, which is a subset of I U \ {I}. Suppose now that s is a big node. There exists a unique i ∈ {1, . . . , r} such that s ∈ Wi. Note that Wi is the node set of a subpath of P , say P (cid:48), consisting only of big nodes and arcs in E1. Let Ij1, . . . , Ijp be the intervals corresponding to the vertices in Ui, ordered increasingly. The fact that all arcs of P (cid:48) are in E1 imply that V (P (cid:48)) = Wi = {sq 1 ≤ q ≤ p − 2k + 1} where sq = (Ijq , . . . , Ijq+2k−1) and E(P (cid:48)) = {(sq, sq+1) 1 ≤ q ≤ p − 2k}. Moreover, there exists a unique index q ∈ {1, . . . , p} such that I = Ijq . (cid:54)∈ Wi and s(cid:48)(cid:48) ∈ Wi. Since (s(cid:48), s(cid:48)(cid:48)) ∈ E0 and s(cid:48)(cid:48) ∈ B, condition (4) in the definition of an arc in E0 guarantees that the intervals Ij1, . . . , Ijk+1 pairwise intersect. Clearly, this implies that interval I intersects at least k intervals from the set I U \ {I}. The case when p − q ≤ k is symmetric to the case q ≤ k + 1 and can be analyzed using condition (3) in the definition of an arc in E0. Suppose now that k + 1 < q < p − k. Let α = q − k and let sα = (Ijα, . . . , Ijα+2k−1). Then sα ∈ V (P (cid:48)) and sα is a big node of Dt k. Moreover, Ijα+k−1 = Ijq−1 < Ijq = I = Ijα+k and therefore condition (2) in the definition of a big node implies that I intersects at least k intervals from the set Isα \ {I}, which is a subset of I U \ {I}. Case 2. u (cid:54)∈ U . In this case, I (cid:54)∈ I U . Let I− denote the rightmost interval in the set {I(cid:48) I(cid:48) < I, I(cid:48) ∈ I U} if such an interval exists, otherwise let I− = I0. Similarly, let I + denote the leftmost interval in the set {I(cid:48) I < I(cid:48), I(cid:48) ∈ I U} if such an interval exists, otherwise let I + = In+1. Note that I− < I < I +. We consider several subcases depending on I− and I +. Case 2.1. I− = I0. Let s be the successor of I0 on P . Then, (I0, s) ∈ E0 and since I0 = I− < I < I + = min(s), condition (2) in the definition of an arc in E0 implies that I intersects at least k intervals from Ix ∪ Is. Since I does not intersect any interval associated with I0, we infer that I intersects at least k intervals from Is, which is a subset of I U \ {I}. Case 2.2. I + = In+1. This case is symmetric to Case 2.1. I0 < I− < I + < In+1 and I− ∩ I + = ∅. Case 2.3. In this case, there exists a unique i ∈ {1, . . . , r − 1} such that I− is associated with a node in Wi and I + is associated with a node in Wi+1. Let (s(cid:48), s(cid:48)(cid:48)) be the (unique) arc of P such that s(cid:48) ∈ Wi and s(cid:48)(cid:48) ∈ Wi+1. Then (s(cid:48), s(cid:48)(cid:48)) ∈ E0 and since max(s(cid:48)) = I− < I < I + = min(s(cid:48)(cid:48)), condition (2) in the definition of an arc in E0 implies that I intersects at least k intervals from Is(cid:48) ∪ Is(cid:48)(cid:48), which is a subset of I U \ {I}. Case 2.4. I0 < I− < I + < In+1 and I−∩I + (cid:54)= ∅. In this case, there exists a unique i ∈ {1, . . . , r} such that each of I−, I + is associated with a node in Wi. Furthermore, since I− and I + are consecutive intervals in I U , there exists a node s ∈ Wi such that both I− and I + are associated with s. This is clearly true if Wi consists of a single node. If Wi consists of more than one node, then it consists of big nodes only, and the fact that all edges of P connecting two nodes in Wi 10 are in E1 implies that a node s with the desired property can be obtained by defining s as the node in Wi closest to In+1 (along P ) such that interval I− is associated with s. Clearly, s ∈ S ∪ B. We consider two further subcases. Case 2.4.1. s ∈ S. In this case, we have min(s) ≤ I− < I < I + ≤ max(s) and condition (3) in the definition of a small node implies that interval I intersects at least k intervals from the set Is \ {I}, which is a subset of I U \ {I}. Case 2.4.2. s ∈ B. In this case, Wi is the node set of a subpath of P consisting of big nodes only. Let Ij1, . . . , Ijp be the intervals corresponding to the vertices in Ui, ordered increasingly. There exists a unique index q ∈ {1, . . . , p − 1} such that I− = Ijq and I + = Ijq+1. (cid:54)∈ Wi and Suppose first that q < k. Let (s(cid:48), s(cid:48)(cid:48)) be the (unique) arc of P such that s(cid:48) s(cid:48)(cid:48) ∈ Wi. Then (s(cid:48), s(cid:48)(cid:48)) ∈ E0 and s(cid:48)(cid:48) ∈ B, therefore condition (4) in the definition of an arc in E0 guarantees that the intervals Ij1, . . . , Ijk+1 pairwise intersect. This condition implies that interval I intersects each of the intervals Ij1, . . . , Ijk+1, and therefore also at least k + 1 intervals from the set I U \ {I}. The case when p− q < k is symmetric to the case q < k and can be analyzed using condition (3) in the definition of an arc in E0. Suppose now that k ≤ q ≤ p − k. Let α = q − k + 1 and let sα = (Ijα, Ijα+1, . . . , Ijα+2k−1). A similar argument as in Case 1 shows that sα ∈ Wi and s is a big node of Dt k. Moreover, Ijα+k−1 = Ijq = I− < I < I + = Ijq+1 = Ijα+k . Therefore, condition (2) in the definition of a big node implies that I intersects at least k intervals from the set Isα, which is a subset of I U \{I}. This shows that U is a total k-dominating set of G and completes the proof. 3 Improving the Running Time We assume all notations from Section 2. In particular, G is a given n-vertex proper interval graph equipped with a proper interval model I and (Dt k, (cid:96)) is the derived edge-weighted directed acyclic graph with O(n2k) nodes. We apply Proposition 2.3 and show that a shortest I0, In+1-path k can be computed in time O(n3k). The main idea of the speedup relies on the fact in Dt that the algorithm avoids examining all arcs of the digraph. This is achieved by employing a dynamic programming approach based on a partition of a subset of the node set into O(nk) parts depending on the nodes' suffixes of length k. The partition will enable us to efficiently compute minimum lengths of four types of directed paths in Dt k, all starting in I0 and ending in a specified vertex, vertex set, arc, or arc set. In particular, a shortest I0, In+1-path in Dt k will be also computed this way. Theorem 3.1. For every positive integer k, the total k-domination problem is solvable in time O(V (G)3k) in the class of proper interval graphs. The algorithm proceeds as follows. First, it computes the node set of Dt Proof. In order to describe the algorithm in detail, we need to introduce some notation. Given a node s ∈ S ∪ B, say s = (Ii1, . . . , Iiq ) (recall that k + 1 ≤ q ≤ 2k), we define its k-suffix of s as the sequence (Iiq−k+1, . . . , Iiq ) and denote it by suf k(s). k and a subset B(cid:48) of the set of big nodes consisting of precisely those nodes s ∈ B satisfying condition (3) in the definition of E0 (that is, the rightmost k + 1 intervals associated with s pairwise intersect). Next, it computes a partition {Aσ σ ∈ Σ} of S ∪ B(cid:48) defined by Σ = {suf k(s) : s ∈ S ∪ B(cid:48)} and Aσ = {s ∈ S ∪ B(cid:48) suf k(s) = σ} for all σ ∈ Σ. The algorithm also computes the arc set E1. On the other hand, the arc set E0 is not generated explicitly, except for the arcs in E0 with tail I0 or head In+1. Using dynamic programming, the algorithm will compute the following values. 11 (i) For all s ∈ V (Dt k) \ {I0}, let p0 k ending with an arc from E0. Dt s denote the minimum (cid:96)-length of a directed I0,s-path in (ii) For all s ∈ V (Dt k) \ {I0}, let ps denote the minimum (cid:96)-length of a directed I0,s-path in Dt k. (iii) For all e ∈ E1, let pe denote the minimum (cid:96)-length of a directed path in Dt k starting in I0 and ending with e. (iv) For all σ ∈ Σ, let pσ denote the minimum (cid:96)-length of a directed path in Dt k starting in I0 and ending in Aσ. In all cases, if no path of the corresponding type exists, we set the value of the respective p0 s, ps, pe, or pσ to ∞. Clearly, once all the p0 s, ps, pe, and pσ values will be computed, the length of a shortest I0, In+1-path in Dt k will e given by pIn+1. The above values can be computed using the following recursive formulas: (i) p0 s values: • For s ∈ S ∪ B, let Σs = {σ ∈ Σ (s, s) ∈ E0 for some s ∈ Aσ} and set  Is, min σ∈Σs ∞, p0 s = pσ + Is, if (I0, s) ∈ E0; if (I0, s) (cid:54)∈ E0 and Σs (cid:54)= ∅; otherwise. • For s = In+1, let p0 ps. (ii) ps values: For all s ∈ V (Dt s = min (s,s)∈E0 k) \ {I0}, we have ps = min (iii) pe values: For all e = (s, s(cid:48)) ∈ E1, we have pe = ps + 1. (iv) pσ values: For all σ ∈ Σ, we have pσ = min s∈Aσ ps. (cid:26) (cid:27) p(s,s) . p0 s, min (s,s)∈E1 k such that if s, s(cid:48) ∈ S∪ The above formulas can be computed following any topological sort of Dt B are such that suf k(s) (cid:54)= suf k(s(cid:48)) and suf k(s) is lexicographically smaller than suf k(s(cid:48)), then s appears strictly before s(cid:48) in the ordering. When the algorithm processes a node s ∈ V (Dt k)\{I0}, s, pe for all e = (s, s) ∈ E1, and ps, in this order. For every σ ∈ Σ, it computes the values of p0 the value of pσ is computed as soon as the values of ps are known for all s ∈ Aσ. Correctness of the algorithm. We will justify the recursive formula for the p0 s values when s ∈ S ∪ B; all other recursive formulas follow directly from the definitions of the values involved and length function (cid:96) (cf. equation (∗) on page 5). Let s ∈ S ∪ B and consider a directed I0,s-path P in Dt k ending with an arc (s, s) from E0. Note that by the definition of length function (cid:96), we have (cid:96)(s, s) = Is, independently of s. Thus, p0 s ≥ Is, with equality if and only if (I0, s) ∈ E0. Suppose now that (I0, s) (cid:54)∈ E0. Then s ∈ S ∪ B(cid:48) and setting σ = suf k(s), we have σ ∈ Σ and s ∈ Aσ, which implies σ ∈ Σs. We show next that for every ¯s ∈ Aσ we have (¯s, s) ∈ E0. Let ¯s ∈ Aσ. Then, ¯s ∈ S ∪ B(cid:48) and suf k(¯s) = σ = suf k(s), which implies that max(¯s) = max(s). Let us now verify, using the fact that (s, s) ∈ E0 and the corresponding conditions (1) -- (4) in the definition of E0, that conditions (1) -- (4) in the definition of E0 also hold when applied to the pair (¯s, s). Condition 12 (1) follows from the fact that max(¯s) = max(s). For condition (2), let I ∈ I be an interval such that max(¯s) < I < min(s). Then max(s) < I < min(s) and thus I intersects at least k intervals from Is ∪ Is. This implies that I intersects at least k intervals from the set Isuf k(s) ∪ Is, where Isuf k(s) denotes the set of rightmost k intervals associated with s. Since suf k(¯s) = suf k(s), the set Isuf k(s) coincides with the set of rightmost k intervals associated with ¯s, and therefore I intersects at least k intervals from the set I¯s ∪ Is, yielding condition (2). Condition (3) holds since if ¯s ∈ B then ¯s ∈ B(cid:48). Finally, condition (4) holds since it holds for the arc (s, s) and depends only on s. Thus, conditions (1) -- (4) in the definition of E0 hold when applied to the pair (¯s, s), which implies (¯s, s) ∈ E0, as claimed. Altogether, this justifies that p0 pσ +Is if (I0, s) (cid:54)∈ E0 and Σs (cid:54)= ∅. s = min σ∈Σs Analysis of the running time. The node set of Dt k, including sets S, B, and B(cid:48), as well as the set of arcs in E0 with tail I0 or head In+1 can be computed in time O(n2k+1). In the same time the partition S ∪ B(cid:48) = {Aσ σ ∈ Σ} can be computed, along with a topological sort of Dt as specified above (for example by iterating over the nodes in S ∪ B and building a radix tree with respect to their k-suffixes). When processing a node s ∈ S ∪ B, the set Σs can be computed in time O(nk) by verifying for each σ ∈ Σ, whether an arbitrarily chosen node s ∈ Aσ satisfies (s, s) ∈ E0. (As noted above, this property is independent of the choice of s.) In the same time O(nk), the value of p0 can be computed. The values of pe for all e = (s, s) ∈ E1 as well as ps can be computed in time proportional to d− (s) is the in-degree of s in the spanning subdigraph of Dt k with arc set E1. Processing of node In+1 can be done in time proportional to its in-degree in Dt k can be processed in time (s) ≤ n for all s ∈ σ∈Σ Aσ) = O(n2k). O(cid:16)(cid:80) + O(cid:0)n2k(cid:1) = O(n3k), since, in particular, d− S ∪ B. The values of pσ for all σ ∈ Σ can be computed in overall time O((cid:80) k, which is in O(n2k). We conclude that all the nodes of Dt s∈S∪B Thus, the overall time complexity of the algorithm is O(n3k), as claimed. nk + d− E1 (s) + 1, where d− E1 E1 k s (cid:16) (cid:17)(cid:17) (s) + 1 E1 4 Modifying the Approach for k-Domination With minor modifications of the definitions of small nodes, big nodes, and arcs in E0 of the derived digraph, the approach developed in Sections 2 -- 3 for total k-domination leads to an analogous result for k-domination. Given a proper interval graph G equipped with a proper interval model I (as in Section 2), we construct an edge-weighted directed acyclic graph denoted by Dk. The digraph Dk is defined the same way as Dt k (see Section 2), except for the following: • The set S of small nodes now consists exactly of those increasing sequences s = (Ii1, . . . , Iiq ) of intervals from I such that: (1) 1 ≤ q ≤ 2k − 1, (2) Iij ∩ Iij+1 (cid:54)= ∅ for all j ∈ {1, . . . , q − 1}, and (3) every interval I ∈ I\Is such that min(s) < I < max(s) intersects at least k intervals from the set Is. • The set B of big nodes consists exactly of those increasing sequences s = (Ii1, . . . , Ii2k ) of intervals from I of length 2k such that: (1) Iij ∩ Iij+1 (cid:54)= ∅ for all j ∈ {1, . . . , 2k − 1} and 13 (2) every interval I ∈ I \Is such that Iik < I < Iik+1 intersects at least k intervals from the set Is. • Arc set E0 consists exactly of those ordered pairs (s, s(cid:48)) ∈ V (Dk) × V (Dk) such that: (1) max(s) < min(s(cid:48)) and max(s) ∩ min(s(cid:48)) = ∅, (2) every interval I ∈ I such that max(s) < I < min(s(cid:48)) intersects at least k intervals from Is ∪ Is(cid:48), (3) if s = (Ij1, . . . , Ij2k ) is a big node, then every interval I ∈ I \ Is such that Ijk+1 < (4) if s(cid:48) = (Ij1, . . . , Ij2k ) is a big node, then every interval I ∈ I \ Is(cid:48) such that Ij1 < I < Ij2k intersects at least k intervals in Is, and I < Ijk intersects at least k intervals in Is(cid:48). The arc set E1 is defined analogously as in the case of Dt k (using, of course, ordered pairs from V (Dk)) and the length function (cid:96)(s, s(cid:48)) on the arcs (s, s(cid:48)) of Dk is defined using (∗) (see Section 2). A similar approach as that used to prove Proposition 2.3 yields the following. Proposition 4.1. Given a proper interval graph G and a positive integer k, let Dk be the directed graph constructed as above. Then G has a k-dominating set of size c if and only if Dk has a directed path from I0 to In+1 of length c. Proof. We assume notation from Sections 2 and 4, and, additionally, fix the following notation useful for both directions of the proof: for X ⊆ V (G), we denote by I X the set of intervals in I corresponding to vertices in X. First we establish the forward implication. Suppose that G has a k-dominating set U of size c. The components of G[U ] can be naturally ordered from left to right, say as C1, . . . , Cr. To each component Ci we will associate a path P i in Dk defined as a sequence of nodes. The desired directed path P from I0 to In+1 in Dk will be then obtained by combining the paths P i into a single sequence of nodes preceded by I0 and followed by In+1. We say that a component Ci is small if V (Ci) < 2k and big, otherwise. To every small component Ci we associate a sequence si = (Ii1, . . . , Iip), consisting of the p = V (Ci) intervals corresponding to the vertices of Ci, ordered increasingly. We claim that si is a small node of Dk. Property (1) of the definition of a small node is satisfied by definition. Property (2) follows from the fact that I is a proper interval model of G and Ci is connected. To show that si satisfies property (3) of the definition of a small node, consider an interval I ∈ I \ Is such that min(si) < I < max(si) and let u be the vertex of G corresponding to I. Note that since I (cid:54)∈ Is, we have I (cid:54)∈ I U and hence u (cid:54)∈ U . In particular, since U is a k-dominating set in G, vertex u has at least k neighbors in U . Since min(si) < I < max(si), all the neighbors of u in U must belong to Ci, more specifically, N (u) ∩ U ⊆ V (Ci). It follows that I intersects at least k intervals from the set Isi, establishing also property (3) and with it the claim that si is a small node of Dk. The path P i associated to component Ci is the one-node path having si as a node. Let now Ci be a big component and let p = V (Ci). Then p ≥ 2k. Let Ij1, . . . , Ijp be the intervals corresponding to the vertices of Ci, ordered increasingly. For every q ∈ {1, . . . , p − 2k + 1}, let si q denote the subsequence of these intervals of length 2k starting at q-th interval, that is, si q is a big node of Dk. Property (1) follows from the fact that I is a proper interval model of G and Ci is connected. To show that si q satisfies property (2) of the definition of a big node, consider an interval I ∈ I \ Is such that Ijq+k−1 < I < Ijq+k and let u be the vertex of G − U q = (Ijq , Ijq+1, . . . , Ijq+2k−1). We claim that for each q ∈ {1, . . . , p − 2k + 1}, si 14 q q q q such that I ∩ I(cid:48) (cid:54)= ∅. Note that {Ij1, . . . , Ijp} \ Isi corresponding to I. Since U is a k-dominating set, vertex u has at least k neighbors in U . Since Ij1 < I < Ijp, all the neighbors of u in U must belong to Ci. It follows that I intersects at least k intervals from the set {Ij1, . . . , Ijp} \ {I}. Suppose for a contradiction that I intersects \ {I} = {Ijq , Ijq+1, . . . , Ijq+2k−1} \ {I}. Since I strictly less that k intervals from the set Isi intersects at least k intervals from the set {Ij1, . . . , Ijp} \ {I}, there is an interval, call it I(cid:48), in = I1 ∪ I2 where the set {Ij1, . . . , Ijp} \ Isi I1 = {Ij1, . . . , Ijq−1} and I2 = {Ijq+2k , . . . , Ijp}. Suppose first that I(cid:48) ∈ I1, that is, I(cid:48) = Ijα for some α ∈ {1, . . . , q − 1}. Since I is a proper interval model of G, conditions Ijq+k−1 < I < Ijq+k and Ijq+k−1 ∩ Ijq+k (cid:54)= ∅ imply that interval I has non-empty intersection with interval Ijq+k−1. Similarly, the fact that I intersects both I(cid:48) = Ijα and Ijq+k−1 implies that I also intersects each of the intervals in the set {Ijα, Ijα+1, . . . , Ijq+k−1}; in particular, I intersects each of the k intervals in the set {Ijq , Ijq+1, . . . , Ijq+k−1}, which is a subset of Isi . This contradicts the assumption on I. The case I(cid:48) ∈ I2 is symmetric to the case I(cid:48) ∈ I1. This establishes property (2) and with it the claim that si q is a big node of Dk. The path associated to component Ci is defined as P i = si p−2k+1. 1, . . . , si Let P denote the sequence of nodes of Dk obtained by combining the paths P i into a single sequence of nodes preceded by I0 and followed by In+1, in the natural order I0, P 1, . . . , P r, In+1. Since U (cid:54)= ∅, the paths P i are pairwise node-disjoint, and none of them contains I0 or In+1, path P has at least 3 nodes. Moreover, note that for each node s of P other than I0 and In+1, the vertices of G corresponding to intervals associated with s all belong to the same component of G[U ], call it Cs. We claim that P is a path in Dk, that is, that every two consecutive nodes of P form an arc in Dk. Consider a pair s, s(cid:48) of consecutive nodes of P . Clearly, s (cid:54)= In+1. We consider three subcases depending on whether s = I0, s ∈ S, or s ∈ B. Suppose first that s = I0. We claim that (s, s(cid:48)) ∈ E0. Property (1) of the definition of the edges in E0 clearly holds, as does (vacuously) property (3) (since I0 /∈ B). To show property (2), consider an interval I ∈ I such that max(s) < I < min(s(cid:48)). Since U is a k-dominating set and I corresponds to a vertex of G not in U , interval I intersects at least k intervals from I U . Since I < min(s(cid:48)) and min(s(cid:48)) is the leftmost interval corresponding to a vertex of U , it follows that I intersects the k leftmost intervals from I U . All these intervals belong to vertices from component C1, and therefore to Is(cid:48). This establishes property (2). It remains to verify property (4). Let s(cid:48) ∈ B, say s(cid:48) = (Ij1, . . . , Ij2k ), and consider an interval I ∈ I \ Is(cid:48) such that Ij1 < I < Ijk . We claim that I ∈ I \ I U . Suppose that this is not the case. The construction of P implies that Is(cid:48) consists of the 2k leftmost intervals corresponding to vertices in U . In particular, if I ∈ I U , then condition Ij1 < I < Ijk implies that I = Ijα for some 1 < α < k, hence I ∈ Is(cid:48), a contradiction. Since I ∈ I \ I U and U is a k-dominating set in G, interval I intersects at least k intervals from I U . Again, since Ij1, . . . , Ij2k are the 2k leftmost intervals corresponding to vertices in I U and I < Ijk , the fact that I intersects at least k intervals from I U implies that I also intersects at least k intervals from the set {Ij1, . . . , Ij2k−1}, which is a subset of Is(cid:48). This establishes property (4). It follows that (s, s(cid:48)) ∈ E0, as claimed. Suppose now that s ∈ S. We claim that (s, s(cid:48)) ∈ E0. Property (1) of the definition of the edges in E0 follows from the construction of P and the fact that Cs (cid:54)= Cs(cid:48). Property (2) follows from the construction of P together with the fact that U is a k-dominating set in G. Property (3) is satisfied vacuously. A similar argument as in the case s = I0 establishes property (4) (this time using the fact that if s(cid:48) ∈ B, then Is(cid:48) consists of the 2k leftmost intervals in I Ci where Ci is the component of G[U ] containing the vertices corresponding to intervals associated with s(cid:48)). It follows that (s, s(cid:48)) ∈ E0, as claimed. Suppose now that s ∈ B. If s(cid:48) ∈ S, then we conclude that (s, s(cid:48)) ∈ E0 by symmetry with the case s ∈ S, s(cid:48) ∈ B. If s(cid:48) = In+1, then we conclude that (s, s(cid:48)) ∈ E0 by symmetry with the 15 case s = I0. Let now s(cid:48) ∈ B. If Cs (cid:54)= Cs(cid:48), then we can use similar arguments as in the case s ∈ S to show that (s, s(cid:48)) ∈ E0. If Cs = Cs(cid:48), let i ∈ {1, . . . , r} be the index such that Cs = Ci. The construction of P implies that s and s(cid:48) are nodes of P i such that s = si for some q ∈ {1, . . . , p − 2k} where p = V (Ci). The definitions of si (s, s(cid:48)) ∈ E1, showing in particular that (s, s(cid:48)) is an arc of Dk. q+1 q+1 now imply that q and s(cid:48) = si q and si This shows that P is a directed path from I0 to In+1 in Dk, as claimed. Furthermore, the construction of P implies that the length of P equals the size of U , which is c. Now we establish the converse implication. Suppose that Dk has a directed path P from I0 to In+1 of length c. Let U be the set of all vertices u ∈ V (G) such that the interval corresponding to u is associated with some node of P . We claim that U is a k-dominating set in G of size c. Note that since neither of I0 and In+1 is a big node, (I0, In+1) (cid:54)∈ E1; moreover, (I0, In+1) (cid:54)∈ E0 since condition (2) in the definition of an arc in E0 fails. Therefore, (I0, In+1) (cid:54)∈ E(Dk) and P has at least 3 nodes. The set of nodes of P can be uniquely partitioned into consecutive sets of nodes, say W0, W1, . . . , Wr, Wr+1, such that each Wi is the node set of a maximal subpath P (cid:48) of P such that E(P (cid:48)) ⊆ E1. (Equivalently, the Wi's are the vertex sets of the components of the undirected graph underlying the digraph P − E0.) Note that W0 = {I0} and Wr+1 = {In+1}. For all i ∈ {0, 1, . . . , r + 1}, let Ui be the set of vertices of G corresponding to intervals in I(cid:48) associated with nodes in Wi. We claim that for every 0 ≤ i < j ≤ r + 1 and for every pair of intervals I ∈ I Ui and J ∈ I Uj we have I < J and I ∩ J = ∅. This can be proved by induction on d = j − i. If d = 1, then let (s, s(cid:48)) be the unique arc of P connecting a vertex in Wi with a vertex in Wi+1. By the definition of the Wi's, we have (s, s(cid:48)) (cid:54)∈ E1 and therefore (s, s(cid:48)) ∈ E0, which implies that every interval associated with s is smaller (with respect to ordering <) and disjoint from every interval associated with s(cid:48). Consequently, the definitions of Wi, Wi+1, Ui, Ui+1, and the properties of the arcs in E1 imply that every interval in I Ui is smaller (with respect to ordering <) and disjoint from every interval in I Ui+1. The inductive step follows from the transitivity of the relation on I(cid:48) in which interval I is in relation with interval J if and only if I < J and I ∩ J = ∅. The above claim implies that no edge of G connects a vertex in Ui with a vertex in Uj whenever 1 ≤ i < j ≤ r. More specifically, we claim that for every i ∈ {1, . . . , r}, the subgraph of G induced by Ui is a component of G[U ]. This can be proved using the properties of the arcs in Dk, as follows. Let i ∈ {1, . . . , r}. Suppose first that Wi ∩ S (cid:54)= ∅. Since every arc in E1 connects a pair of big nodes, we infer that Wi = {s} for some s ∈ S. Using property (2) in the definition of a small node, we infer that G[Ui] is connected. Therefore, since no edge of G connects a vertex in Ui with a vertex in Uj for j (cid:54)= i, we infer that G[Ui] is a component of G[U ], as claimed. Suppose now that Wi ∩ S = ∅, that is, Wi ⊆ B. Let P (cid:48) be the subpath of P such that V (P (cid:48)) = Wi. Since P (cid:48) consists only of big nodes and only of arcs in E1, we can use property (1) in the definition of a big node to infer that G[Ui] is connected. It follows that G[Ui] is a component of G[U ] also in this case. Let us now show that the size of U equals the length of P . This will imply that U ≤ c. For every i ∈ {1, . . . , r + 1}, let P i be the subpath of P of consisting of all the arcs of P entering a node in Wi. By construction, the paths P 1, . . . , P r+1 are pairwise arc-disjoint and their union is P . For every i ∈ {1, . . . , r + 1}, let (cid:96)i denote the the length of P i. The definitions of the Wi's and of the length function imply that (cid:96)i = (cid:96)(si, s(cid:48) i) is the (unique) arc of P such that si (cid:54)∈ Wi and s(cid:48) i ∈ Wi. Since (si, s(cid:48) , (cid:96)(si, s(cid:48) i) + Wi − 1, where (si, s(cid:48) i) ∈ E0, we have if i ∈ {1, . . . , r}; if i = r + 1. (cid:26) Is(cid:48) i) = i 0, 16 It follows that (cid:26) Is(cid:48) i 0, + Wi − 1, if i ∈ {1, . . . , r}; if i = r + 1. i Furthermore, we have Is(cid:48) i=1 Ui =(cid:80)r+1 the subgraph of G induced by Ui is a component of G[U ], we have U =(cid:80)r (cid:96)i = +Wi− 1 = Ui for all i ∈ {1, . . . , r}, which implies (cid:96)i = Ui. Since i=1 (cid:96)i, which is exactly the length of P (this follows from the fact that the paths P 1, . . . , P r+1 are pairwise arc-disjoint and their union is P ). Therefore, U = c. It remains to show that U is a k-dominating set of G, that is, that every vertex u ∈ V (G)\U has at least k neighbors in U . Let u ∈ V (G) \ U and let I ∈ I be the interval corresponding to u. We need to show that I intersects at least k intervals from the set I U . Note that I (cid:54)∈ I U . Let I− denote the rightmost interval in the set {I(cid:48) I(cid:48) < I, I(cid:48) ∈ I U} if such an interval exists, otherwise let I− = I0. Similarly, let I + denote the leftmost interval in the set {I(cid:48) I < I(cid:48), I(cid:48) ∈ I U} if such an interval exists, otherwise let I + = In+1. Note that I− < I < I +. We consider several subcases depending on I− and I +. Case 1. I− = I0. Let s be the successor of I0 on P . Then, (I0, s) ∈ E0 and since I0 = I− < I < I + = min(s), condition (2) in the definition of an arc in E0 implies that I intersects at least k intervals from Ix ∪ Is. Since I does not intersect any interval associated with I0, we infer that I intersects at least k intervals from Is, which is a subset of I U . Case 2. I + = In+1. This case is symmetric to Case 1. Case 3. I0 < I− < I + < In+1 and I− ∩ I + = ∅. In this case, there exists a unique i ∈ {1, . . . , r − 1} such that I− is associated with a node in Wi and I + is associated with a node in Wi+1. Let (s(cid:48), s(cid:48)(cid:48)) be the (unique) arc of P such that s(cid:48) ∈ Wi and s(cid:48)(cid:48) ∈ Wi+1. Then (s(cid:48), s(cid:48)(cid:48)) ∈ E0 and since max(s(cid:48)) = I− < I < I + = min(s(cid:48)(cid:48)), condition (2) in the definition of an arc in E0 implies that I intersects at least k intervals from Is(cid:48) ∪ Is(cid:48)(cid:48), which is a subset of I U . Case 4. I0 < I− < I + < In+1 and I− ∩ I + (cid:54)= ∅. In this case, there exists a unique i ∈ {1, . . . , r} such that each of I−, I + is associated with a node in Wi. Furthermore, since I− and I + are consecutive intervals in I U , there exists a node s ∈ Wi such that both I− and I + are associated with s. This is clearly true if Wi consists of a single node. If Wi consists of more than one node, then it consists of big nodes only, and the fact that all edges of P connecting two nodes in Wi are in E1 implies that a node s with the desired property can be obtained by defining s as the node in Wi closest to In+1 (along P ) such that interval I− is associated with s. Clearly, s ∈ S ∪ B. We consider two further subcases. Case 4.1. s ∈ S. In this case, we have min(s) ≤ I− < I < I + ≤ max(s) and condition (3) in the definition of a small node implies that interval I intersects at least k intervals from the set Is, which is a subset of I U . Case 4.2. s ∈ B. In this case, Wi is the node set of a subpath of P , say P (cid:48), consisting of big nodes only. Let Ij1, . . . , Ijp be the intervals corresponding to the vertices in Ui, ordered increasingly. The fact that all arcs of P (cid:48) are in E1 imply that V (P (cid:48)) = Wi = {sq 1 ≤ q ≤ p − 2k + 1} where sq = (Ijq , . . . , Ijq+2k−1) and E(P (cid:48)) = {(sq, sq+1) 1 ≤ q ≤ p − 2k}. Moreover, there exists a unique index q ∈ {1, . . . , p − 1} such that I− = Ijq and I + = Ijq+1. Suppose first that q < k. Let (s(cid:48), s(cid:48)(cid:48)) be the (unique) arc of P such that s(cid:48) (cid:54)∈ Wi and s(cid:48)(cid:48) ∈ Wi. Then (s(cid:48), s(cid:48)(cid:48)) ∈ E0 and s(cid:48)(cid:48) ∈ B, and Ij1 < I < Ijk . Therefore, condition (4) in the definition of an arc in E0 guarantees that interval I intersects at least k intervals from Is(cid:48)(cid:48), and hence also at least k intervals from the set I U . The case when p− q < k is symmetric to the case q < k and can be analyzed using condition (3) in the definition of an arc in E0. 17 Suppose now that k ≤ q ≤ p−k. Let α = q−k+1 and let sα = (Ijα, Ijα+1, . . . , Ijα+2k−1). Then sα ∈ V (P (cid:48)) and sα is a big node of Dk. Moreover, Ijα+k−1 = Ijq = I− < I < I + = Ijq+1 = Ijα+k . Therefore, condition (2) in the definition of a big node implies that I intersects at least k intervals from the set Isα, which is a subset of I U . This shows that U is a k-dominating set of G and completes the proof. Theorem 4.2. For every positive integer k, the k-domination problem is solvable in time O(V (G)3k) in the class of proper interval graphs. Proof. The digraph Dk has O(n2k) nodes and O(n4k) arcs and can be, together with the length function (cid:96) on its arcs, computed from G directly from the definition in time O(n4k+1). Therefore, Proposition 4.1 implies the the k-domination problem is solvable in time O(n4k+1) in the class of n-vertex proper interval graphs. Furthermore, the same speedup as the one used for total k-domination in the proof of Theorem 3.1 applies also to k-domination. This proves Theorem 4.2. 5 The Weighted Problems The approach of Kang et al. [41], which implies that k-domination and total k-domination are solvable in time O(V (G)6k+4) in the class of interval graphs also works for the weighted versions of the problems, where each vertex u ∈ V (G) is equipped with a non-negative cost c(u) and the task is to find a (usual or total) k-dominating set of G of minimum total cost. For both families of problems, our approach can also be easily adapted to the weighed case. Denoting I∈J c(I), it suffices to generalize the length function from (∗) in a straightforward way, as follows: the total cost of a set J of vertices (i.e., intervals) by c(J ) =(cid:80)  c(Is(cid:48)), c(min(s(cid:48))), 0, (cid:96)(s, s(cid:48)) = if (s, s(cid:48)) ∈ E0 and s(cid:48) (cid:54)= In+1; if (s, s(cid:48)) ∈ E1; otherwise. Except for this change, the algorithms are the same as for the unweighted versions, and the proof of correctness can be adapted easily. We therefore obtain the following algorithmic result. Theorem 5.1. For every positive integer k, the weighted k-domination and weighted total k-domination problems are solvable in time O(V (G)3k) in the class of proper interval graphs. 6 Conclusion In this work, we developed novel algorithms for weighted k-domination and total k-domination problems in the class of proper interval graphs. The time complexity was significantly improved, from O(n6k+4) to O(n3k), for each fixed integer k ≥ 1. Our work leaves open several questions. Even though polynomial for each fixed k, our algorithms are too slow to be of practical use, and the main question is whether the exponential dependency on k of the running time can be avoided. A related question is whether k-domination and total k-domination problems are fixed-parameter tractable with respect to k in the class of proper interval graphs. Could it be that even the more general problems of vector domination and total vector domination (see, e.g., [18, 27, 30, 38]), problems which generalize k-domination and total k-domination when k is part of input, can be solved in polynomial time for proper interval graphs? It would also be interesting to determine the complexity of these problems in generalizations of proper interval graphs such as interval graphs, strongly chordal graphs, cocomparability graphs, and AT-free graphs. 18 Acknowledgements The authors are grateful to Matjaz Krnc for helpful comments. This work is supported in part by the Slovenian Research Agency (I0-0035, research program P1-0285 and research projects N1-0032, J1-7051, and J1-9110). The work for this paper was partly done in the framework of a bilateral project between Argentina and Slovenia, financed by the Slovenian Research Agency (BI-AR/15 -- 17 -- 009) and MINCYT-MHEST (SLO/14/09). References [1] G. Argiroffo, V. Leoni, and P. Torres. 2018. total {k}-dominations for some subclasses of bipartite graphs. Lett., https://doi.org/10.1016/j.ipl.2018.06.007. total and Inform. Process. To appear. DOI: 10.1016/j.ipl.2018.06.007. Available online at Complexity of k-tuple [2] D. Bakhshesh, M. Farshi, and M. Hasheminezhad. Complexity results for k-domination and α-domination problems and their variants. 2017. arXiv:1702.00533 [cs.CC]. [3] R. Belmonte and M. Vatshelle. Graph classes with structured neighborhoods and algorithmic applications. Theoret. Comput. Sci., 511:54 -- 65, 2013. [4] A. A. Bertossi. Total domination in interval graphs. Inform. Process. Lett., 23(3):131 -- 134, 1986. [5] A. Braga, C. C. de Souza, and O. Lee. The eternal dominating set problem for proper interval graphs. Inform. Process. Lett., 115(6-8):582 -- 587, 2015. [6] A. Brandstadt, V. D. Chepoi, and F. F. Dragan. The algorithmic use of hypertree structure and maximum neighbourhood orderings. Discrete Appl. Math., 82(1-3):43 -- 77, 1998. [7] B. Bresar, T. Gologranc, and T. Kos. Dominating sequences under atomic changes with applications in Sierpi´nski and interval graphs. Appl. Anal. Discrete Math., 10(2):518 -- 531, 2016. [8] B.-M. Bui-Xuan, J. A. Telle, and M. Vatshelle. Fast dynamic programming for locally Theoret. Comput. Sci., checkable vertex subset and vertex partitioning problems. 511:66 -- 76, 2013. [9] D. Cattan´eo and S. Perdrix. The parameterized complexity of domination-type problems In Theory and applications of models of computation, and application to linear codes. volume 8402 of Lecture Notes in Comput. Sci., pages 86 -- 103. Springer, Cham, 2014. [10] G. J. Chang. Labeling algorithms for domination problems in sun-free chordal graphs. Discrete Appl. Math., 22(1):21 -- 34, 1988/89. [11] G. J. Chang, C. Pandu Rangan, and S. R. Coorg. Weighted independent perfect domination on cocomparability graphs. Discrete Appl. Math., 63(3):215 -- 222, 1995. [12] M.-S. Chang. Efficient algorithms for the domination problems on interval and circular-arc graphs. SIAM J. Comput., 27(6):1671 -- 1694, 1998. [13] M. Chellali, O. Favaron, A. Hansberg, and L. Volkmann. k-domination and k-independence in graphs: a survey. Graphs Combin., 28(1):1 -- 55, 2012. 19 [14] M. Chellali and N. Meddah. Trees with equal 2-domination and 2-independence numbers. Discuss. Math. Graph Theory, 32(2):263 -- 270, 2012. [15] T. C. E. Cheng, L. Y. Kang, and C. T. Ng. Paired domination on interval and circular-arc graphs. Discrete Appl. Math., 155(16):2077 -- 2086, 2007. [16] N. Chiarelli, T. R. Hartinger, V. A. Leoni, M. I. Lopez Pujato, and M. Milanic. Improved algorithms for k-domination and total k-domination in proper interval graphs. In Combinatorial Optimization - 5th International Symposium, ISCO 2018, Marrakesh, Morocco, April 11-13, 2018, Revised Selected Papers, volume 10856 of Lecture Notes in Comput. Sci., pages 290 -- 302. Springer, 2018. [17] F. Cicalese, G. Cordasco, L. Gargano, M. Milanic, and U. Vaccaro. Latency-bounded target set selection in social networks. Theoret. Comput. Sci., 535:1 -- 15, 2014. [18] F. Cicalese, M. Milanic, and U. Vaccaro. On the approximability and exact algorithms for vector domination and related problems in graphs. Discrete Appl. Math., 161(6):750 -- 767, 2013. [19] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. Introduction to algorithms. MIT Press, Cambridge, MA, third edition, 2009. [20] D. G. Corneil. A simple 3-sweep LBFS algorithm for the recognition of unit interval graphs. Discrete Appl. Math., 138(3):371 -- 379, 2004. [21] B. Courcelle, J. A. Makowsky, and U. Rotics. Linear time solvable optimization problems on graphs of bounded clique-width. Theory Comput. Syst., 33(2):125 -- 150, 2000. [22] E. DeLaVina, W. Goddard, M. A. Henning, R. Pepper, and E. R. Vaughan. Bounds on the k-domination number of a graph. Appl. Math. Lett., 24(6):996 -- 998, 2011. [23] M. Farber. Independent domination in chordal graphs. Oper. Res. Lett., 1(4):134 -- 138, 1981/82. [24] O. Favaron, A. Hansberg, and L. Volkmann. On k-domination and minimum degree in graphs. J. Graph Theory, 57(1):33 -- 40, 2008. [25] J. F. Fink and M. S. Jacobson. n-domination in graphs. In Graph theory with applications to algorithms and computer science (Kalamazoo, Mich., 1984), Wiley-Intersci. Publ., pages 283 -- 300. Wiley, New York, 1985. [26] F. Gardi. The Roberts characterization of proper and unit interval graphs. Discrete Math., 307(22):2906 -- 2908, 2007. [27] T. Gerlach and J. Harant. A note on domination in bipartite graphs. Discuss. Math. Graph Theory, 22(2):229 -- 231, 2002. [28] M. Gutierrez and L. Oubina. Metric characterizations of proper interval graphs and tree-clique graphs. J. Graph Theory, 21(2):199 -- 205, 1996. [29] A. Hansberg and R. Pepper. On k-domination and j-independence in graphs. Discrete Appl. Math., 161(10-11):1472 -- 1480, 2013. [30] J. Harant, A. Pruchnewski, and M. Voigt. On dominating sets and independent sets of graphs. Combin. Probab. Comput., 8(6):547 -- 553, 1999. 20 [31] F. Harary and T. W. Haynes. Double domination in graphs. Ars Combin., 55:201 -- 213, 2000. [32] T. W. Haynes, S. T. Hedetniemi, and P. J. Slater, editors. Domination in graphs. Advanced topics, volume 209 of Monographs and Textbooks in Pure and Applied Mathematics. Marcel Dekker, Inc., New York, 1998. [33] T. W. Haynes, S. T. Hedetniemi, and P. J. Slater. Fundamentals of domination in graphs, volume 208 of Monographs and Textbooks in Pure and Applied Mathematics. Marcel Dekker, Inc., New York, 1998. [34] M. A. Henning and A. P. Kazemi. k-tuple total domination in graphs. Discrete Appl. Math., 158(9):1006 -- 1011, 2010. [35] M. A. Henning and A. Yeo. Total domination in graphs. Springer Monographs in Mathematics. Springer, New York, 2013. [36] W. L. Hsu and K.-H. Tsai. Linear time algorithms on circular-arc graphs. Inform. Process. Lett., 40(3):123 -- 129, 1991. [37] T. Ishii, H. Ono, and Y. Uno. Subexponential fixed-parameter algorithms for partial vector domination. Discrete Optim., 22(part A):111 -- 121, 2016. [38] T. Ishii, H. Ono, and Y. Uno. (Total) vector domination for graphs with bounded branchwidth. Discrete Appl. Math., 207:80 -- 89, 2016. [39] Z. Jackowski. A new characterization of proper interval graphs. Discrete Math., 105(1-3):103 -- 109, 1992. [40] M. S. Jacobson and K. Peters. Complexity questions for n-domination and related parameters. Congr. Numer., 68:7 -- 22, 1989. Eighteenth Manitoba Conference on Numerical Mathematics and Computing (Winnipeg, MB, 1988). [41] D. Y. Kang, O.-j. Kwon, T. J. F. Strømme, and J. A. Telle. A width parameter useful for chordal and co-comparability graphs. Theoret. Comput. Sci., 704:1 -- 17, 2017. [42] A. P. Kazemi. On the total k-domination number of graphs. Discuss. Math. Graph Theory, 32(3):419 -- 426, 2012. [43] J. M. Keil. Total domination in interval graphs. Inform. Process. Lett., 22(4):171 -- 174, 1986. [44] V. R. Kulli. On n-total domination number in graphs. In Graph theory, combinatorics, algorithms, and applications (San Francisco, CA, 1989), pages 319 -- 324. SIAM, Philadelphia, PA, 1991. [45] J. K. Lan and G. J. Chang. Algorithmic aspects of the k-domination problem in graphs. Discrete Appl. Math., 161(10-11):1513 -- 1520, 2013. [46] J. K. Lan and G. J. Chang. On the algorithmic complexity of k-tuple total domination. Discrete Appl. Math., 174:81 -- 91, 2014. [47] C.-M. Lee and M.-S. Chang. Variations of Y -dominating functions on graphs. Discrete Math., 308(18):4185 -- 4204, 2008. 21 [48] C.-S. Liao and G. J. Chang. k-tuple domination in graphs. Inform. Process. Lett., 87(1):45 -- 50, 2003. [49] C.-S. Liao and D. T. Lee. Power domination in circular-arc graphs. Algorithmica, 65(2):443 -- 466, 2013. [50] M. Liedloff, T. Kloks, J. Liu, and S.-L. Peng. Efficient algorithms for Roman domination on some classes of graphs. Discrete Appl. Math., 156(18):3400 -- 3415, 2008. [51] C.-J. Lin, J.-J. Liu, and Y.-L. Wang. Finding outer-connected dominating sets in interval graphs. Inform. Process. Lett., 115(12):917 -- 922, 2015. [52] P. J. Looges and S. Olariu. Optimal greedy algorithms for indifference graphs. Comput. Math. Appl., 25(7):15 -- 25, 1993. [53] S.-i. Oum and P. Seymour. Approximating clique-width and branch-width. J. Combin. Theory Ser. B, 96(4):514 -- 528, 2006. [54] B. S. Panda and S. Paul. A linear time algorithm for liar's domination problem in proper interval graphs. Inform. Process. Lett., 113(19-21):815 -- 822, 2013. [55] B. S. Panda and D. Pradhan. A linear time algorithm to compute a minimum restrained dominating set in proper interval graphs. Discrete Math. Algorithms Appl., 7(2):1550020, 21, 2015. [56] D. Pradhan. Algorithmic aspects of k-tuple total domination in graphs. Inform. Process. Lett., 112(21):816 -- 822, 2012. [57] T. Pramanik, S. Mondal, and M. Pal. Minimum 2-tuple dominating set of an interval graph. Int. J. Comb., 2011. Article ID 389369, 14 pages, 2011. [58] G. Ramalingam and C. Pandu Rangan. Total domination in interval graphs revisited. Inform. Process. Lett., 27(1):17 -- 21, 1988. [59] G. Ramalingam and C. Pandu Rangan. A unified approach to domination problems on interval graphs. Inform. Process. Lett., 27(5):271 -- 274, 1988. [60] F. S. Roberts. Indifference graphs. In Proof Techniques in Graph Theory (Proc. Second Ann Arbor Graph Theory Conf., Ann Arbor, Mich., 1968), pages 139 -- 146. Academic Press, New York, 1969. [61] D. B. West. Introduction to Graph Theory. Prentice Hall, Inc., Upper Saddle River, NJ, 1996. 22
1805.02349
2
1805
2019-01-30T23:32:37
(Nearly) Efficient Algorithms for the Graph Matching Problem on Correlated Random Graphs
[ "cs.DS", "cs.IT", "cs.LG", "cs.IT" ]
We give a quasipolynomial time algorithm for the graph matching problem (also known as noisy or robust graph isomorphism) on correlated random graphs. Specifically, for every $\gamma>0$, we give a $n^{O(\log n)}$ time algorithm that given a pair of $\gamma$-correlated $G(n,p)$ graphs $G_0,G_1$ with average degree between $n^{\varepsilon}$ and $n^{1/153}$ for $\varepsilon = o(1)$, recovers the "ground truth" permutation $\pi\in S_n$ that matches the vertices of $G_0$ to the vertices of $G_n$ in the way that minimizes the number of mismatched edges. We also give a recovery algorithm for a denser regime, and a polynomial-time algorithm for distinguishing between correlated and uncorrelated graphs. Prior work showed that recovery is information-theoretically possible in this model as long the average degree was at least $\log n$, but sub-exponential time algorithms were only known in the dense case (i.e., for $p > n^{-o(1)}$). Moreover, "Percolation Graph Matching", which is the most common heuristic for this problem, has been shown to require knowledge of $n^{\Omega(1)}$ "seeds" (i.e., input/output pairs of the permutation $\pi$) to succeed in this regime. In contrast our algorithms require no seed and succeed for $p$ which is as low as $n^{o(1)-1}$.
cs.DS
cs
(Nearly) Efficient Algorithms for the Graph Matching Problem on Correlated Random Graphs ∗ Boaz Barak ∗ Chi-Ning Chou ∗ Zhixian Lei ∗ Tselil Schramm ∗ Yueqi Sheng February 1, 2019 Abstract We give a quasipolynomial time algorithm for the graph matching problem (also known as noisy or robust graph isomorphism) on correlated random graphs. Specifically, for every γ > 0, we give a nO(log n) time algorithm that given a pair of γ-correlated Erdos-R´enyi graphs G0, G1 with average degree between no(1) and n1/153, recovers the "ground truth" permutation π ∈ Sn that matches the vertices of G0 to the vertices of Gn in the way that minimizes the number of mismatched edges. We also give a recovery algorithm for a denser regime, and a polynomial- time algorithm for distinguishing between correlated and uncorrelated graphs. Prior work showed that recovery is information-theoretically possible in this model as long the average degree was at least log n, but truly subexponential-time algorithms were only known for graphs with average degree Ω(n2). In contrast our algorithms succeed for average degree as low as no(1). 9 1 0 2 n a J 0 3 ] S D . s c [ 2 v 9 4 3 2 0 . 5 0 8 1 : v i X r a ∗ Harvard University. Supported by NSF awards CCF 1565264 and CNS 1618026, and the Simons Foundation. Emails: [email protected], [email protected], [email protected], [email protected], [email protected]. 1 Introduction The graph matching problem is a well-studied computational problem in a great many areas of com- puter science. Some examples include machine learning [CSS07], computer vision [CL12], pattern recognition [BBM05], computational biology [SXB08, VCP+11], social network analysis [KL14], and de-anonimzation [NS09].1 The graph matching problem is the task of computing, given a pair (G0, G1) of n vertex graphs, the permutation π∗ = arg min π∈Sn (cid:107)G0 − π(G1)(cid:107) (1) where we identify the graphs with their adjacency matrices, and write π(G1) for the matrix ob- (cid:62) tained by permuting the rows and columns according to π (i.e., the matrix P G1P where P is the permutation matrix corresponding to π). 1.1 The Correlated Erdos-R´enyi model The graph matching problem can be thought of as a noisy (and hence harder) variant of the graph isomorphism problem. In fact, the graph matching problem is NP hard in the worst case.2 O'Donnell et al. also show that graph matching is hard to approximate assuming Feige's Random 3SAT hypothesis [OWWZ14]. Hence, much of the existing work is focused on practical heuristics or specific generative models. In a 2011 paper, Pedarsani et al. [PG11] introduced the correlated Erdos-R´enyi model as a case study for a de-anonymization task. This is the G(n, p; γ) model in which the pair (G0, G1) is generated as follows:3 • We sample a "base graph" B from the Erdos-R´enyi distribution G(n, p). • We sample π at random in Sn (the set of permutations on the elements [n]). • We let G0 be a randomly subsampled subgraph of B obtained by including every edge of B in G0 with probability γ independently. • We let G1 be an independently subsampled subgraph of π(B) obtained by including every edge of π(B) in G1 with probability γ independently. Given (G0, G1), our goal is to recover π. Though initially introduced as a toy model for a specific application, the problem of recovering π in G(n, p; γ) is a natural and well-motivated statistical inference problem, and it has since received a lot of attention in the information theory and statistics communities (c.f., [YG13, KL14, LFP14, KHG15, CK16, CK17, MX18]). Below we will use Dstruct(n, p; γ) (or Dstruct for short, when the parameters are clear from the context) to denote the "structured" joint distribution above on triples (G0, G1, π) of pairs of graphs and a permutation π such that G1 is a noisy version of π(G0). One can see that the graphs G0 and G1 are individually distributed according to the Erdos-R´enyi distribution G(n, pγ), but there is significant correlation between G0 and G1. It can be shown that as long as pγ2 (cid:29) log n/n, the permutation π will be the one that minimizes the right-hand side of (1), and hence it is possible to recover π information theoretically. Indeed, Cullina and Kivayash [CK16, CK17] precisely characterized the parameters p, γ for which information theoretic recovery is possible. Specifically, they showed recovery is possible if pγ2 > log n+ω(1) and impossible when pγ2 < log n−ω(1) . n n 1See the surveys [LR13, CFSV04], the latter of which is titled "Thirty Years of Graph Matching in Pattern Recognition". 2If we allow weights and self-loops it is equivalent to the quadratic assignment problem [Law63, BC¸ PP99]. 3Some works also studied a more general variant where G0 and G1 use different subsampling parameters γ0, γ1. 1 Paper Cullina & Kivayash [CK16, CK17] Yartseva & Grossglauser [YG13] Algorithm info-theoretic Requirements pγ2n ≥ log n + ω(1) percolation pγ2n = Ω(log n) This paper Mossel & Xu [MX18] subgraph matching seeded local statistics pn ∈ [no(1), n1/153] ∪ [n2/3, n1−] γ ≥ (1/ log n)o(1) pn ≥ log n + ω(1) γ = Θ(1) Runtime, pn = nδ exp(O(n)) exp(n1−δ−Θ(δ2)) nO(log n) δ ∈ N, nO(log n) if 1 else exp(nΩ(1)) Figure 1: A comparison of algorithms for recovery of the permutation in the correlated Erdos-R´enyi model, when (G0, G1, π) ∼ Dstruct(n, p; γ). However, none of these works have given efficient algorithms. Yartseva and Grossglauser [YG13] analyzed a simple algorithm known as Percolation Graph Matching (PGM), which was used success- fully by Narayanan and Shmatikov [NS09] to de-anonymize many real-world networks. (Similar algorithms were also analyzed by [KL14, KHG15, LFP14].) This algorithm starts with a "seed set" S of vertices in G0 that are mapped by π to G1, and for which the mapping πS is given. It propa- gates this information according to a simple percolation, until it recovers the original permutation. Yartseva and Grossglauser gave precise characterization of the size of the seed set required as a −1+δ (where the expected function of p and γ [YG13]. Specifically, in the case that γ = Ω(1) and p = n degree of G0 and G1 is Θ(nδ)), the size of the seed set required is S = n1−δ−Θ(δ2). In the general S setting when one is not given such a seed set, we would require about n steps to obtain it by brute force, which yields an exp(nΩ(1)) time algorithm in this regime. Lyzinski et al. [LFF+16] also gave negative results for popular convex relaxations for graph matching on random correlated graphs. Subsequent work. Subsequent to our work, Mossel and Xu [MX18] obtained new algorithms for the seeded setting based on a delicate analysis of local neighborhoods. Notably, they achieve recovery at the information-theoretic threshold. Though the exact dependence of the seed set size δ ∈ N, their on the average degree is complicated to state, roughly speaking whenever pn = nδ for 1 δ (cid:60) N, the seed set has size O(log n), giving quasi-polynomial time algorithms. However, when 1 δ and (cid:98) 1 δ(cid:99). seed set size is nΩ(1) with the constant in the exponent depending on the difference of 1 1.2 Our results In this work we give quasipolynomial time algorithms for recovering the hidden permutation π in the G(n, p; γ) model for every constant (and even slightly sub-constant) γ and a wide range of p. Theorem 1.1 (Recovery). For every  > 0 and γ > 0, if pn ∈ [no(1), n1/153] or pn ∈ [n2/3, n1−], then there is a quasipolynomial-time randomized algorithm A such that with high probability over (G0, G1, π) ∼ Dstruct(n, p; γ) and over the choices of A, A(G0, G1) = π. One can see that we obtain (nearly) efficient recovery even for sub-polynomial degrees. As discussed in Section 3, our results are more general and handle (slightly) sub-constant noise γ. See Theorem 3.2 for a precise statement of the parameters (including the o(1) in the minimum sparsity np = no(1)). To the best of our knowledge, the best previously known algorithms for any pn < n1− required subexponential (i.e., exp(nΩ(1))) time. At first, the requirement that the average degree pn be in a union of two disjoint intervals may seem strange. Indeed, modulo a combinatorial conjecture, our algorithm works for all values of 2 (cid:48) has density larger than .99 e np ∈ [Ω(log n), 1). In order to give this conjecture, we need the following definition; for the sake of exposition, we have pared it down. For the full requirements, see Theorem 4.1. Definition 1.2 (simplified version). Let v, e be positive integers. We say that H is a (v, e)-test family if H is a set of v-vertex e-edge graphs, such that each H ∈ H has no non-trivial automorphisms, (cid:48) ∈ H, no every strict subgraph of H has edge density < e shared subgraph of H, H Conjecture 1.3. For all sufficiently large integers v > v0, for every integer e such that v + log v < e (cid:28) v2, there exists a (v, e)-test family. A proof of this conjecture would immediately extend Theorem 1.1 to every pn ∈ [Ω(log n), 1). In fact, our proof of Theorem 1.1 proceeds by establishing this conjecture for v = Θ(log n) and e ∈ [v + o(v), (1 + 1 152)v] ∪ [3v, O(v)]. We find it difficult to believe that the existence of a (v, e)-test family would be discontinuous in e as a function of v; however our techniques for the two regimes are different, and while we did not make a special effort to optimize the constants 1 152 or 3, it seems that completely filling in the gap requires some delicate and technical combinatorial arguments. v. Finally, we also require H ≥ vΩ(e).4 v, and further for pairs of distinct H, H Hypothesis testing. We also consider the potentially easier "hypothesis testing" task of distin- guishing a pair of graphs (G0, G1) sampled from Dstruct(n, p; γ) from a pair (G0, G1) that is drawn from the "null distribution" Dnull(n, pγ) of two independent samples from G(n, pγ). For this problem we give a polynomial time algorithm for a range of values of p. Theorem 1.4 (Distinguishing). For arbitrarily small  > 0 and for every γ > 0, if pn ∈ [n, n1/153] or pn ∈ [n2/3, n1−], then there is a pseudo-polynomial time5 deterministic algorithm A that distinguishes with probability at least6 0.9 between the case that (G0, G1) are sampled from Dstruct(n, p; γ) and the case that they are sampled from Dnull(n, pγ). See Theorem 2.2 for the full settings of parameters that we achieve for distinguishing. 1.3 Approach and techniques −1+δ (i.e., graphs of average degree ∼ nδ): In this section we illustrate our approach and techniques. For the sake of simplicity and concrete- ness we first focus on the following task. Given a pair of graphs (G0, G1), distinguish between the following two cases for p = n Null case: (G0, G1) are drawn from the distribution Dnull of two independent graphs from the Erdos-R´enyi distribution G(n, p/2). Planted/structured case: (G0, G1) are drawn from the distribution Dstruct(n, p; 1/2). That is, we sam- ple B from G(n, p) and a random permutation π ∼ Sn, and both G0 and G1 are independently subsampled subgraphs of B where each edge is kept with probability 1/2. The labels of the vertices of G1 are additionally permuted according to π. Before we present our approach to solve this problem, we explain some of the challenges. In the Dnull case the graphs G0, G1 are completely unrelated, and there is no permutation of the vertices so that G0 and G1 overlap on more than a p fraction of the edges, while in the Dstruct case (cid:1) graphs on v vertices and e edges, so the size requirement on H is quite stringent. 4 Notice that there are only(cid:0)v2/2 they are "roughly isomorphic", in the sense that there is a permutation that will make them agree 5 The algorithm is pseudo-polynomial because it depends on the bit complexity of log p log n . 6We can amplify this to probability 1 − δ, but this incurs a dependence on δ in the exponent of the runtime. e 3 on about a quarter of their edges. Since random graphs are in fact an easy instance of the graph isomorphism problem, we could perhaps hope that known graph isomorphism algorithms will actually succeed in this "random noisy" case as well. Alas, it turns out not to be the case. We now present some rough intuition why common graph isomorphism heuristics fail in our setting. (If you are not interested in seeing why some algorithms fail but rather only why our approach succeeds, feel free to skip ahead to Section 1.3.1.) Let's start with one of the simplest possible heuristics for graph isomorphism: sort the vertices of G0 and G1 according to their degrees and then match them to each other. If G0 and G1 are isomorphic via some permutation π then it will of course be the case that the degree of every vertex v of G0 is equal to the degree of π(v) in G1. Generally, even in a random graph, this heuristic will not completely recover the isomorphism since we will have many ties: vertices with identical degrees. Nevertheless, this approach would map many vertices correctly, and in particular the highest degree vertex in a random graph is likely to be unique and so be mapped correctly. However, in the noisy setting, even the highest degree vertex is unlikely to be the same in both graphs. The reason is that in a random graph of average degree ∆, the degrees of all the vertices are roughly distributed as independent Poisson random variable with expectation ∆. The vertex ∗ v with highest degree in G0 is likely to have degree which is k ln n standard deviations higher than the mean. But since the graphs are only 1 4-correlated, the corresponding matched vertex ∗ = π(v ∗ ∗ ) is likely to have degree which is only 1 w 4k higher than the mean. It can be calculated that ∗ this means that w is extremely unlikely to be the highest degree vertex of G1. In fact, we expect ∗ that about n15/16 vertices will have degree larger than w ∗ ∼ √ s. In the context of graph isomorphism algorithms, we often go beyond the degree to look at the degree profile of a vertex v, which is the set of degrees of all the neighbors of v. In the case that G0 and G1 are isomorphic via π, the degree profiles of v and π(v) are identical. However, in the noisy 4-correlated, the degree profiles of v and π(v) are quite far apart. case when G0 and G1 are only 1 About a quarter of the neighbors of v and π(v) will be matched, but for them the degrees are only roughly correlated, rather than equal. Moreover the other three quarters of neighbors will not be matched, and for them the degrees in both graphs will just be independent Poisson variables. Another common heuristic for graph isomorphism is to match G0 and G1 by taking their top eigenvectors and sorting them (breaking ties using lower order eigenvectors). Once again this will fail in our case, because even if the permutation was the identity, the top eigenvector of G0 is likely to be very different from the top eigenvector of G1. This is for similar reasons as before: the top eigenvector of G0 is the vector v0 such that the quantity v standard deviations higher ∗/4 than the mean for some particular value k or so standard deviations higher than the mean, and hence v0 will not be the top eigenvector of A1. One could also imagine using a different heuristic, such as cycle counts, to distinguish -- in (cid:62) 0 A1v0 will only be k . However, it is likely that the v (cid:62) 0 A0v0 is k ∗ ∗ Section 2, we discuss the shortcomings of such "simple" heuristics in detail. 1.3.1 The "black swan" approach Now that we have appreciated the failure of the canonical graph isomorphism algorithms, we describe our approach. Our approach can be thought of as "using a flock of black swans". Specifically, suppose that H is an O(1)-sized subgraph that is a "black swan," in the sense that it has extremely low probability µ (cid:28) 1 of appearing as a subgraph of a random graph G0 drawn from G(n, p/2).7 Another way to say it is that E XH(G) = µ where XH(G) is the subgraph count of H in G, or the 7For technical reasons, for the distinguishing section we actually take µ = O(1) and only use µ (cid:28) 1 for recovery, but we discuss here the case µ (cid:28) 1 for intuition. 4 number of subgraphs of G isomorphic to H.8 Figure 2: In this example, XH(G) = 2. If we are lucky and H appears in both G0 and G1, then we can conclude that it is most likely that the vertices of H in G0 are mapped to the vertices of H in G1, since the probability that both copies appear by chance is µ2. This is much smaller than µ( 1 2)O(1), which is the probability that H appears in G0 and those edges were not dropped in G1. If we are further lucky (or chose our swan carefully) so that H has no non-trivial automorphism, then it turns out that we can in such a case deduce the precise permutation of the vertices of H in G0 to the vertices of H in G1. The above does not seem helpful in designing an algorithm to recover the permutation, or even to distinguish between Dnull and Dstruct since by its nature as a "black swan", most of the times H will not appear as a subgraph of G0, and hence we would not be able to use it. Our approach is to use a flock of such swans, which are a set H of graphs H1, . . . , Ht such that the probability of every individual graph Hi occurring as a subgraph is very small, but the probability of some graph Hi occurring is very high. We carefully designate properties of the family (which we call the test graph family) so that when i (cid:44) j the events that Hi and Hj occur as subgraphs are roughly independent. Already, this allows us to use the common occurrences of graphs in this family to deduce whether (G0, G1) came from the null distribution (in which case such occurrences will be rare) or whether they came from the structured distribution (in which case they will be more frequent). In particular, if we define H = {H1, . . . , Ht}, and the polynomial pH(G0, G1) = (XH(G0) − µ)(XH(G1) − µ), then the value of pH will be noticeably higher when (G0, G1) are drawn from Dstruct than when they are drawn from Dnull. This will result in an efficient algorithm to distinguish the two distributions. We also use the "swans" for recovery, as we will discuss below. (cid:88) H∈H 1.3.2 Constructing the flock of black swans It turns out that demonstrating the existence9 of a family of "swans," or "test graphs," is a delicate task, as we need to satisfy several properties that are in opposition to one another. On one hand, we want the family to be large, so that we can compensate for the fact that each member is a "black swan" and appears with very small probability. On the other hand, we need each member of the family to have a small number of edges. Suppose that one of our swans, H, has e edges. If it appears in the base graph B, then it only survives in both G0 and G1 with probability γ2e. That is, the correlation between XH(G0) and XH(G1) decays exponentially in the number of edges of H, and if H is too large we cannot expect it to help us recover. As a side effect, keeping H small helps 8More formally, XH(G) is the number of injective homomorphisms of H to G, divided by the number of automorphisms of H. That is, if H has vertex set [v] and G has vertex set [n], then XH(G) = σ:[v]→[n]1-to-1 (i,j)∈E(H) Gσ(i),σ(j). 9We note that since the graphs in the family will be of size v = O(log n), and counting the number of occurrences of a graph on v vertices takes time nO(v), once we fix v we can perform brute-force enumeration over all graphs on v vertices with negligible effect on the asymptotic runtime. For this reason, demonstrating the existence of a family is enough. (The construction need not be algorithmic, though ours is). aut(H)(cid:80) 1 (cid:81) 5 with the computational efficiency of the task of finding these occurrences. A third constraint is that we need the events that each member of the family occurs to be roughly independent. It is very easy to come up with a large family of graphs for which the events of them co-occurring together are highly correlated, but such a family would not be useful for our algorithm. Ensuring this independence amounts to obtaining control over the edge density of the common subgraphs that appear in pairs of distinct test graphs. Luckily, we are able to demonstrate the existence of families of graphs achieving the desired properties, though this require some care. The above discussion applies to the distinguishing problem of telling Dnull and Dstruct apart. However, if we can ensure that the joint occurrences of our family of test graphs cover all the vertices of G0 and G1, then we can actually recover the permutation. This underlies our recovery algorithm. To simultaneously ensure these conditions we need to make the number of vertices of each Hi logarithmic rather than constant, which results in a quasipolynomial time algorithm. (cid:48) vertices and e (cid:48) (cid:48) of H with v (cid:48) is related to its size. −1+δ this will require e ≥ (1 − δ) · v edges, so that the average degree is close to 2. Properties of the test graphs. We now describe more precisely (though still not in full formality, see Section 4) the properties that our family H of "black swans" or test graphs needs to satisfy so the above algorithm will succeed: Low likelihood of appearing. Each graph in our test family will have v vertices and e edges. To ensure that it is indeed a "black swan", we require that nvpe = µ for µ slightly subconstant. −1v. In fact, we will set e to In particular, in the regime p = n be almost exactly (1 − δ) −1v. Note that when, say, δ < 1/10 these are graphs with less than, say 10 9 Strict balance. This condition is well-known in the random graphs literature, and it ensures that the random variable XH(G) is well behaved. It states that for every H in the family H, every induced subgraph H edges has strictly smaller edge density, (cid:48)/v (cid:48) < e/v. We will actually require a strengthened, quantitative notion of strict balance, in e which the density of H Intersection balance. To ensure that for every pair of distinct graphs H1, H2 in our family the random variables XH1(G) and XH2(G) will be asymptotically independent when µ (cid:28) 1, we will need to have even tighter control over the density of their common subgraphs. We will require that for every two such graphs, any subgraph H of their intersection satisfies the stronger condition that e No non-trivial automorphism. To ensure we can recover the permutation correctly from an oc- currence of H in G0 and an occurrence in G1, we require that every H in H has no non-trivial automorphism. Largeness. Finally to ensure that there actually will be many subgraphs from this family in our graph, we will require that Hµγe > n. (For distinguishing, it will suffice that Hγ2e = Ω(1).) We conjecture that a family achieving these properties can be obtained with any density e/v > 1 (see Conjecture 1.3). However, at the moment we only demonstrate the existence of such families of graphs with certain densities, which is why our algorithms do not work for all ranges of p.10 We now illustrate one such construction. First and foremost, it can be shown that for integer d ≥ 3, random d-regular graphs H satisfy the requirements of strict balance and trivial automorphism group. Further, a sufficiently large fraction of the set of d-regular random graphs will satisfy the intersection balance property. So for graphs with e = (1 − δ) −1 = d/2, we easily 10More accurately, we do have conjectured constructions that demonstrate the existence of such graphs for all densities, (cid:48)/v (cid:48) < e/v − α for some sufficiently large α > 0. −1v where (1 − δ) (cid:48) but have not yet been able to analyze them in all regimes. 6 have such a family. (cid:48) (cid:48) on v (k + 1) edges and v = v (cid:48) vertices (and hence 1.5v However, the above construction does not give us graphs of all densities, and in particular does not allow us to handle the most interesting regime of sparse Erdos-R´enyi correlated graphs −0.999 or so) which requires test graph of density roughly 1 + δ for some small δ and (e.g., p < n in particular a non integer average degree of roughly 2 + 2δ. Here is one example for such a construction when δ is 1/(3k + 3) for some large integer k. We start with a random 3-regular edges). We then subdivide every edge by inserting k graph H intermediate vertices into it, and so turning it into a path of length k + 1. The resulting graph H (cid:48) + ke (cid:48) will have e = 1.5v vertices, and one can verify that e = (1 − δ) −1v. Moreover, it can be shown that the densest subgraphs of H will "respect" the underlying structure, in the sense that for every original edge of H , a subgraph of H maximizing the density will either include all the corresponding path or none of it. Using this observation, and the expansion properties of random graphs, it is possible to show that strict balance condition and even the intersection balance condition hold. Moreover, we can also use known properties of random graphs to rule out non-trivial automorphism. Finally, since the number of 3-regular (cid:48) = Ω(v) we get a super exponential (i.e., 2ω(v)) number of graphs, graphs on v which will allow us to get a sufficiently large family. We will furthermore need to make the notion of strict balance quantitative. For this and the remaining details, see Section 4, where we also give our constructions for other values of (1 − δ) (cid:48) = v (cid:48) + 1.5kv (cid:48) −1. (cid:48) (cid:48) vertices is v ), for v (cid:48)Ω(v (cid:48) 1.4 Related work As mentioned above, there is an extremely large body of literature on the graph matching problem. We discussed above the works on correlated Erdos-R´enyi graphs, but people have also studied other generative models such as power law graphs and others (e.g., see [JLG+15]). On a technical level, our work is inspired by recent works on sum-of-squares, and using low degree polynomials for inference problems [HKP+17]. In particular, our starting point is a low degree distinguisher from the planted and structured distributions. However, there are some differences with the prior works. These works typically searched for objects such as cuts, vectors, or assignments that are less structured than searching for permutations. Moreover, unlike prior works where the polynomial distinguishers used fairly simple polynomials (such as counting edges, triangles, cycles, etc..), we need to use subgraphs with more complex structure. This is related to the fact that despite this inspiration, our algorithm at the moment is not a sum-of- squares algorithm. It remains an open problem whether the natural sum-of-squares relaxation for (1) captures our algorithm. In our analysis we draw on the vast literature on analyzing the distribution of subgraph counts (e.g., see [JLR11]). Our setting is however somewhat different as we need to construct a family of graphs with related but not identical properties to those studied in prior works; in particular, some differences arise because of the fact that the graphs G0, G1 are correlated, and the fact that we work in the regime where the graphs have size growing with n and appear o(1) times in expectation. 1.5 Organization In Section 2 we give our distinguishing algorithm between Dnull and Dstruct (Theorem 1.4). Then in Section 3 we build on this algorithm to obtain a recovery algorithm that recovers the "ground truth" permutation from (G0, G1) drawn from Dstruct. This algorithm builds upon and extends the techniques of our distinguishing algorithm. Both the recovery algorithm and distinguishing 7 algorithms use as a "black box" the existence of families H of "test graphs" (the black swans) that satisfy certain properties. In Section 4 we show how to construct such test families. Notation. For a graph G = (V, E) and a subset of the vertices S ⊆ V, we use G[S] to denote the vertex-induced subgraph on S and we use E[S] to denote the set of edges with both endpoints in S. We use V(X) to denote the variance of the random variable X. For an event E, I[E] is the 0-1 indicator that E occurs. For a two graphs G, H, we use G (cid:27) H to indicate that G and H are isomorphic, and H ⊆ G to indicate that G contains H as an edge-induced subgraph. We use nk to denote the falling factorial, nk = n(n − 1)··· (n − k + 1). We will also use standard big-O notation, and we will use f (n) (cid:28) g(n) to denote that limn→∞ f (n) → 0. g(n) 2 Distinguishing the null and structured distributions In this section, we give an algorithm for the following distinguishing problem: Problem 2.1 (Distinguishing). We are given two n-vertex graphs G0, G1, sampled equally likely from one of the following distributions: • The null distribution, Dnull: G0 and G1 are sampled independently from G(n, pγ). • The structured distribution, Dstruct: First, a graph B ∼ G(n, p) is sampled. Then, we indepen- dently sample G0, G1 from G by subsampling every edge with probability γ. Finally, we set G1 to be a copy of G1 in which the vertex labels have been permuted according to a uniformly random permutation π. Our goal is to decide with probability ≥ 0.9 whether G0, G1 were sampled from Dnull or Dstruct. This section will be devoted to a proof of the following theorem, which is a generalization and −1/3, n directly implies Theorem 1.4: Theorem 2.2 (Distinguishing algorithm, restatement). For arbitrarily small , δ > 0, if pγ ∈ [ nδ , n1/153 n ] or pγ ∈ [n −b n) for constant b, there is a nγ−O(1) time algorithm A that distinguishes −] and if γ = Ω(log with probability at least11 0.9 between the case that (G0, G1) are sampled from Dstruct(n, p; γ) and the case that they are sampled from Dnull(n, pγ). In particular, if γ = Ω(1) then the algorithm runs in polynomial time. Recall that for graphs G, H, we define the subgraph count XH(G) to be the number of subgraphs of G isomorphic to H. Since G0, G1 sampled from Dstruct are correlated, if a subgraph H appears in G0 then it is more likely to also appear in G1, and the subgraph counts are correlated. The following lemma uses this approach to give a certain "test": a polynomial pH(G0, G1) that has zero mean when (G0, G1) is chosen from the null distribution, but positive mean when they are chosen from the structured distribution. This test will not be good enough, since even in the structured case, it will be unlikely that the polynomial takes a non-zero value, but will serve as our starting point. n Lemma 2.3. Let H be a graph with v vertices and e edges, define the subgraph count-deviation correlation polynomial (cid:17)(cid:16) XH(G0) − E[XH(G0)] (cid:17), XH(G1) − E[XH(G1)] (cid:16) pH(G0, G1) = 11We can amplify this to probability 1− δ by incurring extra runtime, gaining a dependence on δ in the exponent of n. 8 (2) where G0, G1 are two n vertex graphs and the expectation is taken over G0, G1 from the Erdos-R´enyi distribution G(n, pγ). Then in the structured distribution, [pH(G0, G1)] = Θ(1) · EDstruct(n,p;γ) (cid:16) EDstruct[XH(G0)] (cid:17)2 EG∼G(n,p)[XK(G)] where K ⊆ H is the subgraph of H which minimizes EG∼G(n,p)[XK(G)]. Proof. Note that under the null distribution, G0, G1 are independent. Therefore (cid:32) (cid:104) (cid:105)(cid:33)2 [pH(G0, G1)] = EDnull EDnull XH(G0) − E[XH(G0)] = 0. On the other hand, in the structured distribution, G0 and G1 are correlated. That is, (cid:104) XH(G0) · XH(G1) (cid:105) − E[XH(G0)] · E[XH(G1)]. EDstruct [pH(G0, G1)] = EDstruct (3) For an ordered subset of vertices S ⊂ V(G0) of size v, we define 1S⊇H(G0) to be the indicator that G0[S] contains H as a labeled subgraph (at times we will drop the parameter G0 for the sake of conciseness). Expanding XH(G0) and XH(G1) into sums of such indicators, we have (cid:88) (cid:104) (cid:105) , 1S0⊇H(G0) · 1S1⊇H(G1) (4) (cid:104) XH(G0) · XH(G1) (cid:105) EDstruct = 1 aut(H)2 · S0∈V(G0)v,S1∈V(G1)v EDstruct where we use V(G0)v to denote all ordered subsets of v vertices of G0. The aut(H)2 is due to the fact that the sum is over ordered subset of V(G0) and V(G1) of size v and thus it counts the number of labeled ordered copies of H in G0 as well as G1. To avoid over-counting, we divide the number of automorphisms of H and get the 1 1 We recall that originally, we identified V(G0) and V(G1) both with the set [n]. For each summand, the value of the expectation is determined by the number of edges shared between the realization of H on S0 and the realization of H on π−1(S1), where π is the random permutation we applied to the vertices of G1. Without loss of generality, suppose that π was the identity permutation (for notational convenience). Then let EH(S0, S1) be the number of edges in the intersection of H as realized on S0 and S1 when both are identified with [n]. Then letting aut(H) be the number of automorphisms of H, we have aut(H)2 factor. Eq. (4) = · 1 aut(H)2 (cid:88) v(cid:88) e(cid:88) k=0 (cid:96)=0 S0∈V(G0)v, S1∈V(G1)v S0∩S1=k,EH(S0,S1)=(cid:96) γ2ep2e−(cid:96). (5) We can more elegantly express this quantity as a sum over all subgraphs J ⊆ H, upon which the copy of H on S0 and the copy of H on S1 may intersect. So we may re-group the sum according to these unlabeled edge-induced subgraphs J that give the intersection. Further, for each J we can define the number cJ(H) to be the number of ways one can obtain a graph by taking two ordered, labeled copies of H and intersecting them on a subgraph isomorphic to J. Specifically, to have such graphs with J as an intersection, one must (a) choose a copy of J in H for the G0 copy, (b) choose a copy of J in H for the G1 copy, (c) choose an automorphism between the copies. Thus, for each subgraph J, we have cJ(H) = XJ(H)2 · aut(J). 9 Now, let us move from the summation over ordered subsets to the summation over unlabeled edge-induced subgraphs J, we have E[XH(G0) · XH(G1)] = 1 cJ(H) · n2v−V(J) · γ2e · p2e−E(J), (6) (cid:88) aut(H)2 J⊆H as there are cJ(H) ways of intersecting two copies of H on the subgraph J, and for each such type of intersection there are n2v−V(J) choices of vertices for S0, S1. To finish off the proof, we observe that by following an identical sequence of manipulations we can re-write the squared expectation in the same manner, (cid:104) (cid:104) (cid:105) · EDstruct (cid:105) EDstruct XH(G0) XH(G1) = 1 aut(H)2 J⊆H (cid:88) The difference is of course that because the expectations were taken separately, the intersection has no effect on the exponent of p. This allows us to re-write Eq. (3): cJ(H) · n2v−V(J) · γ2ep2e. (cid:17) , −E(J) − 1 p cJ(H) · n2v−V(J) · γ2ep2e(cid:16) (7) Eq. (3) = 1 aut(H)2 (cid:88) J⊂H E(J)≥1 where we have used that if E(J) = 0, the terms cancel. To obtain the final conclusion, we use that p is bounded away from 1, and that cJ(H) and aut(H) (cid:3) are independent of n. The need for test sets. Lemma 2.3 guarantees that the count-deviation polynomial pH has larger expected value under Dstruct than Dnull. However, this fact alone does not prove that pH is a distinguisher. To illustrate this point, let us for simplicity suppose that we are in the regime where nv(γp)e = C for C constant. In this case, Lemma 2.3 gives us that (cid:104) pH(G0, G1) (cid:105) ≈ C · γe, (cid:0)pH(G0, G1)(cid:1)1/2 ≈ C. EDstruct VDnull up to lower-order terms (assuming that H has no subgraph K with E XK(G) < E XH(G)). On the other hand, a simple calculation gives an optimistic bound on the standard deviation of pH under Dnull of So the standard deviation in the null case is too large for us to reliably detect the offset expectation. Our solution is to identify a "test set" of graphs H, such that the estimators pH for H ∈ H are close to independent.12 If we had H = T trials, intuitively we expect the standard deviation to decrease by a factor of T. So long as we satisfy √ < C · γe, C√ T the variance in the null case may be sufficiently small that we reliably distinguish. In order to translate this cartoon sketch into a reality, we will require some additional properties of our test set which will be crucial in controlling the variance. 12Here we mean in the sense that the variance of their average is asymptotically equal to an average of independent estimators. 10 2.1 Test subgraphs for distinguishing Given a graph H with e edges and v vertices, in expectation there are nv · pe/ aut(H) copies of H in G(n, p). Because of our prevailing intuition that random graphs are well-behaved, we might naively expect that the number of copies of H is concentrated around its mean; however some simple examples demonstrate that this is not always the case. Example: the need for balance. Consider for example the graph H given by appending a "hair", or a path of length 1, to a clique of size 4 (see Fig. 3). H has 5 vertices, 7 edges, and 3! automorphisms, so in G(n, p) with p = 2n −5/7, we have E G∼G(n,p) [XH(G)] = 1 3! · n5 · p7 = 27 3! · (1 − on(1)). So in expectation, H appears in G 27 3! times. However, if we restrict our attention to the clique K4 −5/6), the expectation of the Figure 3: Necessity of being balanced. In this example, when p = O(n count of H is O(1), however, with high probability H does not have a single occurrence in G(n, p). which is a subgraph of H, in expectation E G∼G(n,p) [XK4(G)] = 1 4! · n4 · p6 = O(n −2/7). So while the expected number of copies of H is constant, K4 is not expected to appear even once! The large expected count of H is due to a small-probability event; if K4 appears (with polynomially small probability), then we will see many copies of H. This issue is well known in the study of random graphs (it is among the first topics in the textbook of Janson et al. [JLR11]). From that well-developed literature, we borrow the following concept: Definition 2.4 (Balanced graph). The density of a graph is the ratio of its edges to the vertices. A graph H with edge density α is called balanced if it has no strict subgraphs of density larger than α. If all strict subgraphs of H have density strictly smaller than α, then H is called strictly balanced. If a graph H is expected to appear at least once, then the balancedness of a graph H is what determines whether the number of copies of H in G(n, p) is well-concentrated around its mean. For example, Lemma 2.3 already allows us the following observation: Observation 2.5. If H is a graph of fixed size such that EG∼G(n,p)[XH(G)] = Θ(1), then if H is not balanced, VG∼G(n,p)[XH(G)] = ω(1). This follows from applying Lemma 2.3 with γ = 1, in which case EDstruct[pH(G0, G1)] = VG∼G(n,p)[XH(G)], and taking K to be the densest subgraph of H, which must have E[XK(G)] = o(1). 11 To ensure asymptotic independence, we will require that each of the graphs n our test set H be strictly balanced. Theorem (see Theorem 4.1). Let δ ∈ (0, 1) be a rational number, so that } or 1−δ ≥ 3. Let v be a sufficiently large even integer. There exists a test set of graphs H = {H}, each on v 1 vertices and containing e = 1 1. Every H ∈ H is strictly balanced. 2. Every H ∈ H has no non-trivial automorphisms. H ≥ vc 1 1−δ v, for a constant c independent of v. 3. We will prove this proposition in Section 4; for now, assuming we have such a family, we 1−δv edges, which satisfies the following properties: 1−δ ∈ (1, 1 + 1 153] ∪ { 3 , 2, 5 2 1 2 proceed to prove Theorem 1.4. 2.2 Concentration for distinguisher We are now ready to prove that there is a poly-time computable distinguishing polynomial with bounded variance. The existing results on concentration of subgraph counts is not sufficient for us here, because we are interested in the setting of correlated graphs. We will bound the variance directly. Theorem 2.6. Suppose that p = nδ−1 for δ ∈ (0, 1) with 1 1−δ ≥ 3. Then 1−δ ∈ (1, 1 + 1 there exists a polynomial P(G0, G1) such that EDnull[P(G0, G1)] = 0, and 153] ∪ { 3 } or (cid:16)VDstruct (P(G0, G1))1/2 , VDnull (P(G0, G1))1/2(cid:17) . [P(G0, G1)] ≥ 40 · max , 2, 5 2 2 1 EDstruct Further, P(G0, G1) is a sum of subgraph count-deviation correlation polynomials for subgraphs of size v = γ−O(1), and is computable in time nO(v), where the O(·) in the exponent of n hides only a dependence on the size of the representation of (1 − δ) −1 as a ratio of two integers. When γ = Ω(1), the algorithm runs in polynomial time. Proof of Theorem 2.6. Choose v to be a sufficiently large even integer such that vc > 400/(γ)2, where 1−δ v. LetH be the test set of subgraphs guaranteed c is the constant from Theorem 4.1 so thatH ≥ v c −1. By this setting of parameters we by Theorem 4.1 with v vertices and e edges, so that e have then that E[XH(G0)] = 1 ± o(1). v (cid:88) = (1 − δ) Define the polynomial P to be the average of pH over H ∈ H, pH(G0, G1). P(G0, G1) = 1H H∈H Since every H ∈ H is strictly balanced, every strict subgraph K ⊂ H has EG∼G(n,p)[XK(G)] = ω(1). So by Lemma 2.3 (or by the more precise Equation (7)) we have that where we have also used that aut(H) = 1 for every H ∈ H. [P(G0, G1)] ≥ nvγ2e(pe − p2e), EDstruct We define the following quantity, which will show up repeatedly in our variance bounds: (8) The bounds from Lemma 2.3 gives us the expectation of P under Dnull and Dstruct. Using the balancedness properties of our test set, we will bound the variance of P under Dnull and Dstruct. (pγ)(1−δ)−1n = O(1). ρ = v2 12 Variance bound for Dnull. Because G0 and G1 are independent and identically distributed, we have P(G0, G1)2(cid:105) (cid:104) EDnull (cid:88) (cid:88) (cid:88) H,H(cid:48)∈H H,H(cid:48)∈H H,H(cid:48)∈H = 1H2 = 1H2 = 1H2 [pH(G0, G1) · pH(cid:48)(G0, G1)] (cid:104)(cid:16) (cid:17) ·(cid:16) XH(cid:48)(G0) − E[XH(cid:48)(G0)] XH(G0) − E[XH(G0)] (cid:33)2 (cid:105) − E[XH(G0)] · E[XH(cid:48)(G0)] (cid:104) XH(G0) · XH(cid:48)(G0) . (cid:17)(cid:105)(cid:33)2 (cid:32) EDnull (cid:32) EDnull EDnull (9) (cid:48) . For each such J, let κJ = XJ(H) and let κ(cid:48) (cid:104) (cid:105) XH(G0)·XH(cid:48)(G0) Now, we will re-write the expression within the square as we did in the proof of Lemma 2.3, when bounding the expectation of pH under Dstruct. We will sum over graphs J which are subgraphs of both H and H be the graph given by taking the union of H and H and identifying the vertices and edges on the subgraph J, the first term in Eq. (9) can be re-written as follows. EDnull where we have also used that aut(H) = aut(H on 2v − V(J) vertices occurs with probability (pγ)2e−E(J) ) = 1. In G(n, pγ), the event that H ∪J H ·aut(J)·n2v−V(J)· E κJ·κ(cid:48) (cid:88) ). Then, letting H ∪J H on 2v−V(J) vertices] (cid:104) I[H∪JH (cid:105), (10) . This gives us G∼G(n,pγ) (cid:88) is present = XJ(H J⊆H,H(cid:48) = (cid:48) (cid:48) (cid:48) (cid:48) (cid:48) (cid:48) J J κJ · κ(cid:48) J · aut(J) · n2v−V(J) · (pγ)2e−E(J). Eq. (10) = J⊆H,H(cid:48) Re-writing the term E[XH(G0)] E[XH(cid:48)(G1)] similarly and combining with Eq. (11), (cid:104) (cid:88) XH(G0) · XH(cid:48)(G0) EDnull = κJ · κ(cid:48) (cid:105) − E[XH(G0)] · E[XH(cid:48)(G0)] · aut(J) · n2v−V(J) · (pγ)2e(cid:16) (pγ) −E(J) − 1 (cid:17). J J⊆H,H (cid:48) E(J)≥1 , if there is a subgraph J ⊆ H, H (cid:48) (cid:48) (cid:48) , K must be a strict subgraph. Since H, H . Therefore, we −1V(J) − βJ for some fixed (as a function of n) positive βJ. Thus has density strictly less than that of H and H (cid:48) (cid:48) (11) (12)  ≤ (cid:33)2 ≤ v2s. · s! (cid:32)(cid:32)v (cid:33) s (cid:48) ) · aut(J) XJ(H (14) · aut(J) · n2v−V(J) −1+βJ (pγ)2e−V(J)(1−δ) (cid:33)i Now, when H (cid:44) H are strictly balanced, every J ⊆ H, H can assume that E(J) ≤ (1 − δ) (cid:48) returning to Equation (12), when H (cid:44) H , κJ · κ(cid:48) Eq. (12) ≤ (cid:88) J J⊆H,H (cid:48) E(J)≥1 ≤ n2v(pγ)2e+minJ βJ · (cid:32) v(cid:88) (cid:1) subgraphs J of size i, so κJ using that there are at most(cid:0)v   ·  (cid:88) (cid:88) XJ(H) · aut(J) J⊆HJ=s J⊆HJ=s (cid:88) J⊆HJ=s · aut(J) ≤ κJ · κ(cid:48) i=2 J i v2 13 (13) where we have grouped subgraphs J according to i = V(J), then bounded the contribution of the n(pγ)(1−δ)−1 , Since the final sum in Equation (13) is geometric, using Equation (8) we have that when H (cid:44) H (cid:48) , Eq. (12) ≤ (pγ)minJ βJ · n2v(pγ)2e · ρ2 ρv−1 − 1 ρ − 1 where the extra (pγ)minJ βJ factor is due to the strictly balanced property which implies βJ is a positive constant independent of n for each J. When H = H , an identical calculation bounds the terms in Equation (12) for which J (cid:44) H; when J = H, then (since H has no non-trivial automorphisms) the term contributes nv(pγ)e. Thus we have (cid:48) Eq. (12) ≤ nv(pγ)e + (pγ)minJ βJ · n2v(pγ)2e · ρ2 ρv−1−1 (cid:33)2 (pγ)minJ βJ · n2v(pγ)2e · ρ2 ρv−1−1 ρ−1 ρ−1 (cid:32) (cid:48) (cid:48). H = H H (cid:44) H (15) (16) Finally, combining with Equation (9), this gives a bound on the variance: VDnull(P(G0, G1)) ≤ (pγ)2 min βJ · n2v(pγ)2e · ρ2 ρv−1 − 1 ρ − 1 + 1Hn2v(pγ)2e. Note that in Equation (16), ρ = O(1) and n2v(pγ)2e = O(1) while (pγ)minJ βJ = o(1), thus, the first term in Equation (16) is o(1). Furthermore H ≥ 200 · γ−2e, therefore the second term is at most 200n2vp2eγ4e = 1 1 200 E[P(G0, G1)]2. Thus, for sufficiently large n we have [P(G0, G1)] ≥ 40 · VDnull (P(G0, G1))1/2 . EDstruct Variance bound for Dstruct. In the structured case, the correlation of G0 and G1 introduces some additional complications. In particular, because G0 and G1 are not independent, the expectation does not factor nicely. We'll expand the expression for EDstruct[P(G0, G1)2]; we'll use the shorthand XH for XH(G) to save space when G doesn't matter. We have VDstruct[P(G0, G1)] = EDstruct = 1H2 (cid:104)(cid:16) [P(G0, G1)]2 XH(G0) − E[XH] (cid:17)(cid:16) (cid:17)(cid:16) XH(cid:48)(G0) − E[XH(cid:48)] (cid:104)(cid:16) XH(cid:48)(G0) − E[XH(cid:48)] (cid:17)(cid:16) XH(G1) − E[XH] (cid:17)(cid:16) (cid:17)(cid:105) EDstruct (cid:17)(cid:105) XH(cid:48)(G1) − E[XH(cid:48)] (cid:17)(cid:105) . XH(cid:48)(G1) − E[XH(cid:48)] (17) XH(G1) − E[XH] (cid:17)(cid:16) As in the proof of Lemma 2.3, we will write XH(G) as a sum of indicators that ordered subsets of vertices contain H as a subgraph. We apply such a transformation to the first half of the summand above, and we have (cid:17)(cid:16) XH(cid:48)(G0) − E[XH(cid:48)] (cid:17)(cid:16) XH(G1) − E[XH] (cid:105). (cid:104) (1A⊇H − E[1A⊇H])(1B⊇H(cid:48) − E[1B⊇H(cid:48)])(1C⊇H − E[1C⊇H])(1D⊇H(cid:48) − E[1D⊇H(cid:48)]) XH(cid:48)(G1) − E[XH(cid:48)] (cid:17)(cid:105) (18) EDstruct [P(G0, G1)2] − EDstruct (cid:88) (cid:104)(cid:16) XH(G0) − E[XH] H,H(cid:48)∈H − EDstruct (cid:104)(cid:16) (cid:88) XH(G0) − E[XH] EDstruct = (cid:17)(cid:16) EDstruct A∈V(G0)v B∈V(G0)v C∈V(G1)v D∈V(G1)v 14 (cid:48) (cid:48) −E(J) p We have already seen that sums of the form(cid:80) E[1A⊇H1B⊇H(cid:48)] are equivalent to weighted sums over . The term(cid:80) E[1A⊇H] E[1B⊇H(cid:48)], on the other hand, corresponds to Rather than expand the product above into 16 terms, we liken it to a process of inclusion-exclusion. subgraphs J ⊆ H, H by choosing the intersection to be equal to the subgraph J. Specifically, the weight for each subgraph J is proportional to n a similar sum, but the weight for the Jth term is proportional merely to n . For terms in which J contains no edges, these weights are equivalent; when E(J) > 0, the weight of the first term dominates the weight of the second. Therefore, when the second term is subtracted from the first, we are "exclude" the intersections J which contain no edges (up to lower order terms). , which correspond to different ways of taking the union of the graphs H, H −V(J) An analogous phenomenon transpires above. The leading term, E[1A⊇H1B⊇H(cid:48)1C⊇H1B⊇H(cid:48)] in- cludes all ways of intersecting the two copies of H and the two copies of H . The following "order-1 exclusion term", E[1A⊇H] E[1B⊇H(cid:48)1C⊇H1D⊇H(cid:48)], is subtracted to exclude terms in which the copy of H in G0 does not intersect with any of the other subgraphs on any edges. After subtract- ing all three of the order-1 exclusion terms, we must add the six "order-2 inclusion terms", (e.g. E[1A⊇H] E[1B⊇H(cid:48)] E[1C⊇H1D⊇H(cid:48)]), and so on, until we are finally left with a summation in which must intersect with at least one other subgraph on at least one edge.13 every copy of H and H we refer to (that in G0 or G1), we now attach subscripts H0, H1). We can write our expression as a sum over subgraphs J ⊆ H0, H 0, K ⊆ H1, H (cid:48) (cid:48) 1, and L ⊆ H0 ∪J H (cid:48) (cid:48) 0 and H 1 all contain at least one edge in J ∪ K ∪ L: 1, which satisfy the condition E(J, K, L) that H0, H1, H (cid:48) To disambiguate which "copy" of H and H , H1 ∪K H −V(J) (cid:48) 0 (cid:48) (cid:48) (cid:48) Eq. (18) ≤ (cid:88) cJ,K,L(H, H (cid:48) ) · n4v−V(J)−V(K)−V(L) · (γp)4e(γp) −E(J)−E(K) −E(L). p (cid:48) 1 J⊆H0,H (cid:48) K⊆H1,H (cid:48) 0 ,H1∪KH 1 E(J,K,L) (cid:48) 0 L⊆H0∪JH (cid:48) J (cid:48) (cid:48) κJ L κK L κ(cid:48) K where we have let cJ,K,L(H, H ) to be the number of ways one can obtain a graph by (a) taking two ordered, labeled copies of H and intersecting them on a subgraph isomorphic to J, (b) taking and intersecting them on a subgraph isomorphic to K, and (c) two ordered, labeled copies of H the intersection of the above two intersecting parts is isomorphic to L. For our bounds, we will · aut(J) · aut(K) · aut(L) = O(1) is independent ) ≤ κJκKκ(cid:48) ultimately only use that cJ,K,L(H, H of n. To obtain the expression for the variance, we now subtract the second half of the summand from Equation (17), EDstruct[pH(G0, G1)] · EDstruct[pH(cid:48)(G0, G1)]. This term, too, can be written as a summation over subgraphs J, K, L, in which there must be an intersection between H0, H1 and (cid:48) (cid:48) 1. Since it is only re-weighted according to the intersections of H0, H1 with each , H between H (cid:48) (cid:48) 0 1 with each other, subtracting this term will fully cancel any combination of J, K, L , H other and H 0 in which the exclusive intersections occur between copies of the identical graph (i.e. both copies ). Therefore, letting F (J, K, L) be the condition that the exclusive intersections in J∪K∪L (cid:48) are H or H in G1 contains the edge (π(u), π(v)), this term is included in the summation. On the other hand if H in G0 does not share any edges with the second copy of H in G1 or either copy of H 13For example, if H in G0 contains the edge (u, v), and H , the term is excluded. (cid:48) (cid:48) 15 cJ,K,L(H, H (cid:48) ) · n4v−V(J)−V(K)−V(L) · (γp)4e(γp) −E(J)−E(K) −E(L). p (19) (cid:48) are not between H0, H1 and H 0 , H (cid:48) 1, we have that (cid:88) V(P(G0, G1)) ≤ 1H2 (cid:88) H,H(cid:48)∈H J⊆H0,H (cid:48) K⊆H1,H (cid:48) 0 L⊆H0∪JH ,H1∪KH 1 E(J,K,L)∧F (J,K,L) Now we claim that if H (cid:44) H (cid:48) 0 (cid:48) 1 (cid:48) , H , then the union of J, K, L must be strictly sparser than H or H (cid:48) , or (cid:48) 1 given by identifying the edges together is . The conditions E(J, K, L) and F (J, K, L) ensure that we cannot have (cid:48) . At this point, we appeal to the following (cid:48) equivalently, that the graph union HU of H0, H1, H 0 strictly denser than H and H HU isomorphic to a disjoint union of copies of H and H claim: Claim 2.7. Suppose that A is a graph of density α, and let B be a strictly balanced graph of density β ≤ α. Then if J ⊂ A, B is a non-empty proper subgraph of both A and B, and we form the graph A ∪J B by identifying the vertices corresponding to J in A and B, then A ∪J B has density strictly larger than β. Proof. We have that the density of A ∪J B is given by (cid:48) E(A) + E(B) − E(J) V(A) + V(B) − J = αV(A) + βV(B) − E(J) V(A) + V(B) − J . Since B is strictly balanced, by definition J ⊂ B must be sparser than B. Thus, E(J) < βJ, and the (cid:3) conclusion follows. (cid:48) with a copy of H). That is, the density of HU is strictly larger than (1 − δ) We can apply this claim iteratively if we take one intersection at a time (first intersecting a −1. Therefore, −1(V(J) + V(K) + V(L)) − minJ,K,L βJ,K,L, where βJ,K,L is a positive , we have that the value of the summation is bounded copy of H E(L) + E(J) + E(K) ≤ (1 − δ) number independent of n. So when H (cid:44) H by (cid:48) (cid:48) ) · n4v−V(J)−V(K)−V(L) · γ2ep4e−(1−δ) −1(E(J)+E(K)+E(L))+minJ,K,L βJ,K,L cJ,K,L(H, H ≤ (cid:88) ≤ n4vγ2ep4e+minJ,K,L βJ,K,L · 3v(cid:88) J⊆H0,H (cid:48) K⊆H1,H (cid:48) 0 L⊆H0∪JH ,H1∪KH 1 E(J,K,L)∧F (J,K,L) (cid:48) 1 (cid:48) 0 i=2 (cid:33)i (cid:32) 4v6 np(1−δ)−1 = n4vγ2ep4e+minJ,K,L βJ,K,L · ρ2 · ρ3v−1 − 1 ρ − 1 . (cid:48) ) using the same trick as we did in Equation (14) and finally where we have bounded the cJ,K,L(H, H applied Equation (8). (cid:48) When H = H union of H's, so that H0 intersects fully with H when all of the copies intersect fully. For those two terms, the value is n2v(γp)2e + nvpeγ2e. , the above applies except for the case when J = ∅, K = ∅, and L is the disjoint (cid:48) 0 and the identical thing happens in G1, and also Thus, our bound on the variance is VDstruct(P(G0, G1)) ≤ n4vγ2ep4e+minJ βJ · ρ2 · ρ3v−1 − 1 ρ − 1 16 + 1H ·(cid:16) n2v(γp)2e + nvpeγ2e(cid:17) . (20) Here, the first term has magnitude O(pminJ,K,L βJ,K,L/γ2e) · E[XH(G)0]4 = o(1), since p = o(1) and minJ,K,L βJ,K,L, ρ, γ, E[XH(G)0] = O(1). Since H = (c1v)c2e > , the second term is at most 400 γ2 (cid:18) (cid:19)e 1 400 E[P(G0, G1)]2 + γ3e 400 E[XH(G)0]. Therefore for n sufficiently large we have that [P(G0, G1)] ≥ 40 · VDstruct(P(G0, G1))1/2. EDstruct This completes the proof. 2.3 Putting everything together (cid:3) Given Theorem 2.6, we can complete our algorithm and prove Theorem 2.2: Proof of Theorem 2.2. The algorithm is as follows: compute the value of P(G0, G1), and if the value is EDstruct[P(G0, G1)], say that G0 and G1 come from Dstruct, otherwise say that G0 and G1 larger than 1 come from Dnull. Clearly the algorithm runs in polynomial time: it requires counting the number 3 of occurrences of constant-sized subgraphs in two graphs of size n. The claim is that in both cases, we are correct with probability at least 0.99.14 The reason is that if we apply Chebyshev's inequality to P(G0, G1), by Theorem 2.6 and Lemma 2.3 we have that in the structured distribution, P(G0, G1) is unlikely to be too small: PrDstruct (cid:32) P(G0, G1) < 1 2 (cid:32) P(G0, G1) ≥ 1 4 EDstruct [P(G0, G1)] ≤ 4 1600 . (cid:33) (cid:33) At the same time, Chebyshev's inequality also guarantees that P(G0, G1) is not too large with good probability: PrDnull This concludes the proof. EDstruct [P(G0, G1)] ≤ 16 1600 . (cid:3) 3 Recovering the ground truth permutation In this section, we will solve the following recovery problem: Problem 3.1. Let G0, G1 be n-vertex graphs sampled from Dstruct(n, p; γ) according to the following procedure: God samples a "base" graph B ∼ G(n, p), then twice independently subsamples each edge of B with probability γ to form the graphs G0, G1, and finally applies a random permutation π∗ to G1 to obtain G1. We are given G0, G1 without knowledge of π∗ We give a quasipolynomial time algorithm for the above problem; below we state the precise guarantees. Theorem 3.2 (Recovery). For an arbitrarily small constant δ > 0, if (G0, G1, π) ∼ Dstruct(n, p; γ) so that p ∈ [ nε , then there is a randomized nO(log n)-time algorithm A that recovers π exactly with high probability over the input (G0, G1) and over the choices of A. 14Notice that had we taken v = ω(1), we could amplify this probability to 1 − o(1). 15We did not make an effort to optimize the constant in the exponent n1/153. −δ], and γ ≥ (cid:16) 1 , our goal is to recover π∗ (cid:32)(cid:18) log log4 n n ] where15 ε = Ω or p ∈ [n −1/3, n (cid:17)o(1) (cid:33) (cid:19) 1 2 , n1/153 n log n log n . 17 Note that Theorem 3.2 implies Theorem 1.1. Our algorithm first finds a rough estimate of π∗ using test subgraphs (as we did for our distinguishing algorithm), then completes the estimate via a boosting procedure. We fill in the details of our strategy in Sections 3.1 and 3.2. In Sections 3.3 to 3.6, we prove that our algorithm successfully estimates π∗ , and in Section 3.7 we give the boosting algorithm. Finally, we tie everything together and prove Theorem 3.2 in Section 3.8. 3.1 Test subgraphs for recovery To recover the permutation π∗ For the purposes of distinguishing, we used the counts of subgraphs belonging to a specially constructed "test set" of strictly balanced graphs with no non-trivial automorphisms. However, we only used subgraphs of size O(1) to distinguish, each of which crucially appeared only O(1) times. For a fixed constant size s, there are only 2s2 possible subgraphs on s vertices; if each appears only with multiplicity O(1), most vertices in the graph will not participate in such subgraphs. , we will use the same "test set" of subgraphs we used for distinguishing, only now we will choose the subgraphs to have size Ω(log n) (and consequently we will have a larger test set, so that more vertices are covered). Also, we will set their density so that every subgraph which does appear in both G0 and G1 almost certainly appears exactly once. If we see an occurrence of such a subgraph H in both G0 and G1, we can be confident that the vertices of H in G0 and G1 correspond to each other in π∗ . Finally, we fix any mis-matched vertices with a boosting procedure. We require stronger conditions from our test set, which we delineate below. Theorem 3.3 (see Theorem 4.1 and Propositions 4.9 and 4.16). Let d a rational number λ ∈ [0, 1]. Let v, e be integers such that e = d d ≥ 6 (with arbitrary λ), then there exists a test set of graphs H v e edges, which satisfies the following properties: (cid:48) = d + λ for an integer d ≥ 2 and 2 v. Then so long as d = 2 and λ ≤ 1 76 or d(cid:48) = {H}, each on v vertices and containing 1. Every H ∈ H is strictly balanced, in a strong sense: for any α ∈ (0, 1), every subgraph of H on at (cid:48) (cid:48) most αv vertices has density ( d 2 − f (α, d (cid:48) (cid:48) )) for an explicit function f (α, d ) > 0. 2. Every H ∈ H has no non-trivial automorphisms. 3. The size of the family is H ≥ vΩ(Cd(cid:48)·v), for a constant Cd(cid:48) depending on d (cid:48) 4. For every pair of distinct graphs H, H in a strong sense: E(J) ≤ ( d (cid:48) 2 (cid:48) ∈ H, every common subgraph J ⊂ H, H (cid:48) − g(d )) · V(J) for an explicit function g(d and H (cid:48) (cid:48) . (cid:48) Because our constructions differ depending on the value of d is less dense than H (cid:48) ) > 0. , we have stated the theorem in generality here; for precise statements, see Section 4. 3.2 The recovery algorithm The recovery algorithm consists of four steps. Algorithm 3.4 (Recovery). On input (G0, G1) ∼ Dstruct(n, p; γ): 1. Generate a family of test graphs H := H v rem 3.3, choosing v, d as follows: (cid:48) d(cid:48) that satisfies the properties guaranteed in Theo- 18 • If p = nδ−1 ∈ [ nε is also an integer, for some λ chosen from the window λ ∈(cid:16) 2δ , n1/153 n n ], choose v = Θ(log n) to be the smallest even integer so that λv . Choose −]: Choose v = Θ(log n) to be the smallest even integer so that 1−δ + log log n 4 log n (cid:48)(cid:99))v is also an integer. 1−δ + log log n log n 1−δ , 2δ (cid:17) (cid:48) = 2 + λ. d • If p = nδ−1 ∈ [n there is some d (cid:48) ∈(cid:16) 2 −1/3, n (cid:48) − (cid:98)d In Lemma 3.13, we verify that these conditions are feasible. , so that (d 1−δ , 2 (cid:17) 2. For each vertex u ∈ V(G0), we find all H ∈ H such that u is incident on a copy of H in G0, and H · v · nv−1qe distinct H, then we so that H also appears in G1. If u is incident on at least 1 2 choose one uniformly at random, and set π(u) equal to the corresponding vertex in the copy (cid:48) of H in G1. If a collision occurs so that π(u) = π(u , ties are broken arbitrarily. ) for u (cid:44) u (cid:48) 3. Run a boosting algorithm (Algorithm 3.22, see Section 3.7) with the partial map obtained from step 3 . Output the resulting permutation π. To prove that Algorithm 3.4 works, we'll establish the following three claims: • The probability that a vertex u ∈ V appears in a test graph H ∈ H which appears more than once in the base graph B, and also appears at least once in both G0, G1, is small. • Each vertex u ∈ V appears in some test graph H ∈ H in both G0, G1 with large enough probability. Since most H ∈ H that appear in both G0, G1 will appear uniquely in the base graph B, together, these claims imply that in step 2 we will match many vertices to each other, and make few mistakes. • Given a one-to-one map between an Ω(1)-fraction of the vertices of G0, G1 which is consistent with π∗ on all but o(1) of the matches, the boosting algorithm recovers the optimal permutation π∗ . 3.3 Few test graphs introduce errors in the algorithm In this subsection, we will prove that few test graphs H ∈ H appear more than once in the base graph, and also survive the subsampling in both G0 and G1. We will bound the probability of this event in a straightforward manner, taking advantage of properties of the test graphs in H. Lemma 3.5. Suppose that G0, G1 ∼ Dstruct(n, p; γ) are both subsampled from the base graph B = (V, E). Define q = pγ2. Suppose we have chosen H to be a test set comprised of graphs on v vertices as constructed in Section 4, so that H ∈ H has average degree d (cid:48) For a vertex u ∈ V, let Bu be the number of "bad" H ∈ H that contain u, such that H ∈ H appears at , and so that npd least twice in the base graph B, and that a copy of H survives in both G0 and in G1. (cid:48)/2 < 1. (cid:33) (cid:48)/2 and p = nδ−1 for δ < 1 (cid:32) 3, then: (cid:48) = 2 + λ ≤ 2 + 1 If d And if d (cid:48) ≥ 6, then if 2v2+2(d v8 76 and further v log2 v (cid:28) λ2 log2 n, 1 E[Bu] ≤ H · v · nv−1qe · O 50 ≤ v2(d − 1 50 , then: (cid:48)+2) · np 1 2 d (cid:48)/2 ≤ 1 2q E[Bu] ≤ H · v · nv−1qe · 16 v2(d < npd 1√ v (cid:48)+2)nqd (cid:48)+2)q 1 (cid:16) , (cid:17) . (cid:48)+ 1 50 19 Proof. Fix some H ∈ H, and let BH u be the bad event that the vertex u is contained in H, and H appears more than once in the base graph B, and also that at least one copy of H survives in both G0 and G1. Let 1H⊇S be the indicator that the ordered vertex set S ⊂ V contains a labeled copy of H in B. If there is a copy of H on the ordered vertex set S ⊂ V where S contains u, and also a (cid:48) < v, then the product distinct copy of H on a different ordered set of vertices S of indicators 1(0) H⊇S S,H to be the indicators that H survives on S in G0, G1 respectively. · 1(1) H⊇S(cid:48) yields 1. Now, define the indicators IG0 S,H (cid:48) ⊂ V so that S ∩ S The probability that u is contained in H which appears more than once in B and which has at , IG1 least one copy surviving in both G0, G1 is at most u ] ≤ (cid:88) (cid:88) (cid:48)⊆V S,S S=S (cid:48)=v S∩S (cid:48)<v u∈S = E(cid:104) 1H⊇S · 1H⊇S(cid:48) ·(cid:16)IG0 (cid:20)(cid:16)IG0 (cid:17) ·(cid:16)IG1 S,H E + IG0 S(cid:48),H S,H + IG0 S(cid:48),H + IG1 S(cid:48),H S,H S,H + IG1 S(cid:48),H (cid:17)(cid:105) (cid:17) ·(cid:16)IG1 (cid:21) · Pr[1H⊇S · 1H⊇S(cid:48)] (cid:17) (cid:12)(cid:12)(cid:12)(cid:12) 1H⊇S · 1H⊇S(cid:48) Pr[BH (21) Now, because the edges of G0, G1 are subsampled from B independently, (cid:48)⊆V S,S S=S (cid:48)=v S∩S (cid:48)<v u∈S (cid:48) The copies of H on S, S entire graph H). Therefore, if the copies of H and H J ⊂ H, then (cid:48) Thus, we may refine the sum over S, S (cid:48) which S, S intersect: (cid:20)(cid:16)IG0 E + IG0 S(cid:48),H S,H Eq. (21) = (cid:21) + IG1 S(cid:48),H (cid:17) (cid:12)(cid:12)(cid:12)(cid:12) 1H⊇S · 1H⊇S(cid:48) 4γ2ep2e−E(J) ≤(cid:88) (cid:17) ·(cid:16)IG1 (cid:88) (cid:88) S,H J⊂H (cid:48)⊆V S,S S∩S (cid:48)=J u∈S (cid:48) may have shared edges (though because S (cid:44) S (cid:48) , they cannot share the intersect on the edge-induced strict subgraph Pr[1H⊇S · 1H(cid:48)⊇S] = p2e−E(J). (cid:20)(cid:16)IG0 = E + IG0 S(cid:48),H S,H (cid:17) (cid:12)(cid:12)(cid:12)(cid:12) 1H⊇S · 1H⊇S(cid:48) (cid:21)2 =(cid:0)2γe(cid:1)2 . in Eq. (21) into a sum over the proper subgraph J upon XJ(H)2 · aut(J) · v · (n − 1)2v−1−V(J) · 4γ2ep2e−E(J) J⊂H ≤ 4v · n2v−1γ2ep2e(cid:88) J⊂H XJ(H)2 · aut(J) · n −V(J) · p −E(J). (22) (cid:48) that intersect on J is at most XJ(H)2 · aut(J) for the where we have used that the number of S, S choice of the position of J in H for each set and the automorphism between the two copies of J, v for the choice of the position of u within S, and (n − 1)2v−1−V(J) for the choice of the identities of (cid:48) the remaining vertices in S and S The strict balancedness property of H is no longer sufficient to ensure that this sum is small; that is because the density of H is such that nqe/v (cid:28) 1, and therefore we must be careful that the terms of Eq. (22) corresponding to the densest, and largest, subgraphs are not too numerous. Because we utilize different constructions for our test set H depending on the density of H, we will require distinct arguments for bounding Eq. (22) for the case when E(H)/V(H) ≤ 1.5 and E(H)/V(H) > 1.5. We now apply the following lemmas: . 20 (cid:88) J⊂H XJ(H)2 · aut(J) · n −V(J) q Lemma 3.6. When the average degree of H is d sufficiently large, (cid:48) = 2 + λ with λ ∈ [0, 1 76], then if 1 v8 −E(J) ≤ (1−θ)v(cid:88) s=1 v2q 1 λθ 100 s  1 nq1+ 1 2 λ + θv 2 λ nq1+ 1 (cid:48) ≥ 6, so that 2v2+2(d ≤ nqd (cid:48)/2, for v λ(1−θ). q 1 100 λ(cid:17)θv v(cid:16) v8nq1+ 1 2 (cid:48)+2)nqd (cid:48)/2 ≤ 1 2q − 1 50 and Lemma 3.7. When the average degree of H is d (nqd (cid:48)/2)v−1 ≤ v2(d (cid:48)+2)q 1 50 , then(cid:88) XJ(H)2 · aut(J) · n J⊂H −V(J) −E(J) ≤ 4(v2(d (cid:48)+2)q 1 50 ) · q (cid:48)+2)q 1 50 ≤ v2(d (cid:33)v−1 (cid:32) 1 nqd(cid:48)/2 . We will prove these lemmas in Section 3.6; first we will complete the theorem. Sparse case. with setting q = p and θ = 600 log v (cid:48)/2 ≥ v −8) In the sparse case, we will apply Lemma 3.6 (under the assumption that npd 100 log v2p 1 (cid:16) θλ(1 − δ) log n < (2 − 6(1 − δ)) log v < 0, 3. The summation term from the bound in Lemma 3.6 is thus ≤ 1√ vn λ log n . At this parameter setting, if p = nδ−1, then θλ(cid:17) = 2 log v − 1 100 λ(1−θ)(cid:17) = log θv + θv(8 log v − (δ − λ 2 v log2 v − 1 ≤ log θv + 4800 λ log n 300 + δ ) log n) − 1 100 λ 2 λ log n (cid:28) 0, λ)θvp 1 100 −vp −e. Also, for λ(1 − θ)(1 − δ) log n so long as δ < 1 the second term, (cid:16)θv · (v8np1+ 1 log 2 where the final inequality follows for n sufficiently large given our assumption that v log2 v (cid:28) λ2 log2 n. It follows that the second term is ≤ 1 (cid:32) −e. Therefore, (cid:33) −vp · n λ 300 n (cid:16) −1/2(cid:17) · v · nv−1qe, ≤ O v (23) Eq. (22) ≤ 4v · n2v−1γ2ep2e · o 1√ vnvpe where we have used that q = pγ2. By linearity of expectation, summing over all H ∈ H, the number of H which u participates in that have at least two distinct appearances in B and survive at least once in each of G0, G1 is at most (by Eq. (23)): (cid:88) H∈H  ≤ (cid:88) H∈H E[Bu] = E BH u Pr BH u (cid:104) (cid:105) ≤ H · v · nv−1qe · O (cid:16) v −1/2(cid:17) which completes the proof for the sparse case. 21 Dense case. Lemma 3.7 (since we have assumed that 2v2+2(d (cid:48)+2)q 1 In the dense case, since J is always a strict subgraph of H, we can now apply (cid:48)+2)nqd (cid:48)/2 ≤ 1 2q 50 ≤ v2(d (cid:33)v−1 (cid:32) 1 npd(cid:48)/2 (cid:16) − 1 50 ) to bound Eq. (22): (cid:48)+2) · np 1 2 d (cid:17) . (cid:48)+ 1 50 v2(d (24) Eq. (22) ≤ 4v · n2v−1γ2eq2e · 4 · (v2(d (cid:48)+2)p 1 50 ) · = 4v · nv−1qe · 4 (cid:48) where we have used that q = pγ2 and e = d 2 v. Now by definition of Bu and by Eq. (24), (cid:88) H∈H  ≤ (cid:88) H∈H E[Bu] = E BH u Pr BH u (cid:104) (cid:105) ≤ H · 4v · nv−1qe · 4 (cid:16) (cid:48)+2) · np 1 2 d (cid:48)+ 1 50 v2(d (cid:17) , which completes the proof for the dense case. (cid:3) Therefore we have bounded the probability that each vertex participates in a test graph H introduces errors in the map constructed by the algorithm (that is, which appears more than once in B and survives subsampling in both graphs). 3.4 Many vertices appear in test subgraphs To guarantee that the algorithm recovers a Ω(1) fraction of π∗ , we will show that many vertices in B are incident on a copy of H which is present in both G0 and G1. It will be convenient for us to think of the intersection graph of G0 and G1: Definition 3.8 (Intersection graph). For G0, G1 ∼ Dstruct, the intersection graph G is the subgraph of the base graph B induced by edges that were sub-sampled in both G0 and G1. Note that the distribution of intersection graph is the same as G(n, pγ2). We will lower bound the probability that a vertex is contained in at least one test graph inside the intersection graph. Lemma 3.9. Define q := pγ2, and let G ∼ G(n, q). Furthermore let H be a test set with H ∈ H having (cid:48) = d + λ for an integer d = 2 or d ≥ 6, and λ ∈ [0, 1], so that nqd (cid:48)/2 < 1 v vertices and average degree d and H · vnv−1qe ≥ 1. If d = 2, then we also require λ ∈ (0, 1 (cid:48)/2 ≥ 1, and (cid:48) (cid:29) v2. − 1 50 , and nq(1−β) 1 v2 = o(nq1+ 1 2 d For a vertex u ∈ V(G), let Nu be the number of H ∈ H that u appears in in G. When these conditions λ). If d ≥ 6, then we require that 2v2+2(d 76], v log2 v (cid:28) λ2 log2 n, v8nqd (cid:48)/2 ≤ 1 2q 50 ≤ v2(d (cid:48)+2)nqd (cid:48)+2)q 1 3 are met, then Proof. Our proof is via the second moment method. First, the mean of Nu can be calculated as follows: E[1S⊇H] = H · v · (n − 1)v−1qe, (25) V[Nu] ≤ o(E[Nu]2). (cid:105) = H · (cid:88) E[Nu] = E(cid:104)(cid:88) H∈H (cid:88) S⊆V, S=v, u∈S 1S⊇H S⊆V, S=v, u∈S 22 since there are v choices for the position of u in H, then (n− 1)v choices for the (ordered) remaining vertices of H, as H has no non-trivial automorphisms. Now, we will bound the second moment. We expand the expression in terms of the indicators 1S⊇H, the indicator that the ordered vertex subset S ⊂ V which includes u has H as an edge-induced subgraph in G. u] = E(cid:104)(cid:16)(cid:88) H∈H E[N2 (cid:17)2(cid:105) 1S⊇H (cid:88) S⊆V, S=v, u∈S = E(cid:104) (cid:88) (cid:88) (cid:88) H,H(cid:48)∈H = (cid:88) 1S⊇H · 1S(cid:48)⊇H(cid:48)(cid:105) (cid:88) (cid:48)⊆V, S,S S=S (cid:48)=v, u∈S,S (cid:48) E[1S⊇H1S(cid:48)⊇H] + (cid:88) H∈H (cid:48)⊆V, S,S S=S (cid:48)=v, u∈S,S (cid:48) H(cid:44)H(cid:48)∈H (cid:48)⊆V, S,S S=S (cid:48)=v, u∈S,S (cid:48) E[1S⊇H1S(cid:48)⊇H(cid:48)]. (26) In the final step, we have split the terms corresponding to products of indicators of the same subgraph H, and products of indicators of distinct subgraphs H, H . We will bound each of these summations individually. (cid:48) Contribution of copies of the same subgraph H. The first term of Eq. (26) is the second moment of the number of labeled copies of H incident on u. To bound the expectation E[1S⊇H1S(cid:48)⊇H], we need to consider the overlap of the ordered vertex sets S and S (and specifically, the overlap of the copies of H on those sets). For each vertex-induced subgraph J ⊆ H, we may have the copies of H (cid:48) overlapping on J. In that case, the indicators 1S⊇H, 1S(cid:48)⊇H are not independent, and we on S and S have (cid:48) (cid:88) (cid:48)⊂V S,S S=S (cid:48)=v u∈S,S (cid:48) Recall that XJ(H) denotes the subgraph count of J in H. Taking this into account, E[1S⊇H1S(cid:48)⊇H] = XJ(H)2 · aut(J) · n2v−1−V(J) · q2e−E(J) E[1S⊇H1S(cid:48)⊇H] = q2e−E(J). q2e−E(J) ≤ (cid:88) (cid:88) (cid:88) J⊆H V(J)≥1 (cid:48)⊂V S,S (cid:48)=v S=S (cid:48), S∩S u∈S,S (cid:48)=J J⊆H V(J)≥1 ≤ n2v−2q2e · (cid:88) J⊆H V(J)≥1 XJ(H)2 · aut(J) · n −V(J)+1 · q −E(J) (27) (cid:48) vertices for the vertices of S, S where we have XJ(H)2 ways that J can appear as a subgraph of H in S and S and create a collision, aut(J) ways that maps J from a copy to another, and for each such occurrence we choose ; 2v− 1 initially, since we are forced to include u, and (n− 1)2v−1−V(J) then subtracting the vertices in J. As in the proof of Lemma 3.5, since nqe/v (cid:28) 1 we must carefully bound Eq. (27) so that the densest J do not cause it to blow up. Since we use two distinct constructions for H, we require different arguments depending on the density of H. We use Lemmas 3.6 and 3.7, mentioned above and proven in Section 3.6. It remains to bound the contribution of H (cid:44) H (cid:48) . (cid:48) 23 Contribution of distinct subgraphs H, H term Eq. (26) as a sum over subgraphs J as before, we have . For a fixed pair H, H E[1S⊇H1S(cid:48)⊇H(cid:48)] = E[1S⊇H1S(cid:48)⊇H(cid:48)] (cid:88) (cid:48)⊆V, S,S S=S (cid:48)=v, u∈S,S (cid:48) (cid:88) (cid:88) (cid:48)⊆V, S,S (cid:48)=v, S=S (cid:48), S∩S u∈S,S (cid:48)=J (cid:48)⊆V, S,S S=S (cid:48)=v, (cid:48), S∩S u∈S,S (cid:48)=J XJ(H) · XJ(H (cid:48) J⊆H,H (cid:48) V(J)≥1 (cid:88) (cid:88) ≤ (cid:88) = J⊆H,H (cid:48) V(J)≥1 J⊆H,H (cid:48) V(J)≥1 q2e−E(J) (cid:48) ) · aut(J) · n2v−1−V(J) · q2e−E(J), (28) (cid:48) ∈ H, expressing the second (cid:48) where to obtain the last inequality we have used that there are at most XJ(H)·XJ(H (cid:48) ) ways for S, S to intersect on J, aut(J) ways that maps J from a copy to another, and there are at most (n− 1)2v−1−V(J) choices of vertices for S, S once we are forced to include u. To bound Eq. (28), we need to use the property of our graph family that for every H (cid:44) H inside the family, the density of the densest common subgraph is appreciably less than the density of H. Again because our guarantees differ depending on the density of H, we bound this quantity separately for the case when H has density at most 1.5 and the case when H has density at least 3. (cid:48) ∈ H v d(cid:48), λ). Then for distinct H, H Lemma 3.10. Let d (cid:48) (cid:48) 76]. Suppose that v2 = o(nq1+ 1 ) · aut(J) · n −V(J)+1q −E(J) ≤ v2 + nq2(1 + o(1)). 3 (cid:88) (cid:48) = 2 + λ for λ ∈ (0, 1 XJ(H) · XJ(H (cid:48) J⊆H,H (cid:48) V(J)≥1 (cid:48) = d + λ for d ≥ 6 and λ ∈ [0, 1]. Define β = (λ + 1 (cid:88) Lemma 3.11. Let d (cid:48) (cid:29) v2. Then for distinct H, H nq(1−β) 1 2 d XJ(H) · XJ(H (cid:48) (cid:48) ∈ H v d(cid:48), ) · aut(J) · n −V(J)+1q −E(J) ≤ v2 + nqd (cid:48)/2 · (1 + o(1)). 26) 1 d(cid:48) , and suppose that J⊆H,H (cid:48) V(J)≥1 We will prove these lemmas in Section 3.6; with these bounds in hand, we complete the proof of the theorem. Bounding the variance of Nu when H is sparse. We are now equipped to bound the variance of Nu. We return to Eq. (27); we wish to apply Lemma 3.6, which bounds this sum for all J (cid:44) H, and −e. So When H has density at to it we will add the term for J = H, which gives an additional n most 1 + 1 152, Eq. (27) ≤ n2v−1q2e · θv(v8nq1+ λ (1−θ)v(cid:88) λ(1−θ) −vq θλ + 100 v2q 1 nq1+ λ 2 s + 1 nvqe  . nvqe s=1 100 2 )θvq 1 2 ≥ 1. Now, we choose where we have applied Lemma 3.6 under the assumption that v8nq1+ λ θ = 800 log v λ log n ; at this parameter setting, using that q = nδ−1 for δ < 1 2,  1 θλ(cid:17) (cid:16) log v2q 1 100 = 2 log v − 1 100 θλ · (1 − δ) log n < (2 − 4) log v < 0, 24 so the sum is at most nvqe . Also, for the third term, using that nq1+λ/2 < 1 and that (1− δ)(1− θ) > 1 2, 1 (cid:16)θv · (v8nq1+ 1 2 log λ)θvq 1 100 λ(1−θ)(cid:17) ≤ log (cid:16)θv · v8θv · q 1 λ(1−θ)(cid:17) = log θv + 8θv log v − 1 100 ≤ log θv + 6400 λ log n 100 v log2 v − 1 200 λ(1 − δ)(1 − θ) log n λ log n < 0, where the final inequality follows for n sufficiently large given our assumption that v log2 v (cid:28) λ2 log2 n. It follows that Eq. (27) ≤ 3nv−1qe. u] − E[Nu]2 ≤ H2 · n2v−2q2e(cid:16) Thus, using Eqs. (25) to (28) together with Lemma 3.6 and Lemma 3.10 we have E[N2 v2 + nq2(1 + o(1)) ≤ H2 · n2v−2q2e · nq2(1 + o(1)) + 3 · H · nv−1qe, (29) (30) where we have subtracted the third term from the first term and simplified the second term. (cid:48)/2 (cid:28) 1, and because E[Nu] = H· v· (n− 1)v−1· qe, Because we have set the density so that nq2 (cid:28) nqd the first term has magnitude o(E[Nu]2). + H · 3nv−1qe − H2v2n2v−2q2e (cid:17) We compare the second term against E[Nu]2; we have that · ≤ 6 · Hnv−1qe v2H2n2(v−1)q2e by assumption. Thus, if these conditions are satisfied, 4 · H · nv−1qe = 6n v2 E[Nu]2 which completes the proof for sparse H. V(Nu) = o(E[Nu]2), 1 Hnvqe ≤ o(1), Bounding the variance of Nu when H is dense. When H has density at least 3, using Eqs. (25) −e −vq to (28) together with Lemma 3.7 (to which we add the term for J = H, which contributes n and dominates the contribution of the other terms) and Lemma 3.11 (we meet the assumptions since we have assumed v2 < nqd (cid:48)/2−1/50 < nq(1−β)d u] − E[Nu]2 ≤ H2 · n2v−2q2e(cid:16) E[N2 (cid:17) (cid:48)/2) we have v2 + nqd (cid:48)/2(1 + o(1)) (cid:32) + H · n2v−1q2e · 4 (cid:48)/2) · (1 + o(1)) + H · n2v−1q2e · 4 ≤ H2 · n2v−2q2e · (nqd (cid:33)v − H2v2n2v−2q2e (cid:32) (cid:33)v 1 nqd(cid:48)/2 1 nqd(cid:48)/2 , where to obtain the final line we have subtracted the third term from the first term. Because we (cid:48)/2 = o(1), and since E[Nu] = H· v· (n− 1)v−1 · qe, the first term have set the density of H so that nqd (cid:18) has magnitude o(E[Nu]2). To bound the second term, using Eq. (25), we have (cid:19)v H · n2v−1q2e · 4 E[Nu]2 1 nqd(cid:48)/2 = (cid:19)v (cid:18) 1 4n nqd(cid:48)/2 H · v2 · = 4n v2 1 Hnvqe ≤ o(1), by assumption. It follows that if these conditions are satisfied, V(Nu) = o(E[Nu]2), which completes the proof for dense H. (cid:3) 25 From Lemma 3.9, we know that with good probability each vertex u will be covered by at least one graph from the test set H in the intersection graph. 3.5 Partial solution The previous two lemmas allow us to argue that step 2 of Algorithm 3.4 what we call a partial solution. We start by defining the notion of a (θ, η) partial solution, which corresponds to getting η-accurate information about a θ fraction of the vertices: ) are sampled from Dstruct(n, p; γ), and s ∈ {1, . . . , n} Definition 3.12 (Partial solutions). If (G0, G1, π∗ and 0 < η ≤ 1 are some constants then we say that a partial function π : [n] → [n] is an (s, η) partial solution if π is a one-to-one function that is defined on at least s inputs, and such that for at least η fraction of the inputs u on which π is defined, π(u) = π∗ Lemma 3.13. Suppose that G0, G1 ∼ Dstruct(n, p; γ). Then under the conditions of Theorem 3.2 with probability 1 − o(1) over the choice of G0, G1 ∼ Dstruct(n, p; γ) and the randomness of the algorithm, step 2 of Algorithm 3.4 recovers a ( n log v v1/8 )-partial solution. , 1 − 1 (u). Proof. We begin by noting that the parameters chosen at the start of Algorithm 3.4 satisfy the requirements of Lemmas 3.5 and 3.9: Sparse case requirements. λ ∈ (cid:16) 2δ (cid:17) . It can be verified that λ ≤ 1 If p = nδ−1 ∈ [ n , n1/153 n n ], we have chosen d (cid:48) = 2 + λ for λ in the range 76. We have chosen v = Θ(log n) to be the 1−δ + log log n log n smallest even integer so that λv is also an integer. We must verify the following conditions: 1−δ , 2δ • For sufficiently large n, there exists such a choice of λ and v so that v and λv are integers: We have that so long as v = Θ(log n), the interval of choices of λ is such that there is at least one value such that λv is an integer. • v log2 v (cid:28) λ2 log2 n. We have required that δ ≥ (cid:113) (log log n)4 , from which this follows. This log n condition is used by Lemma 3.5. • npd (cid:48)/2 < 1. (cid:48) Using that d 2 = 1 + 1 2 λ and p = nδ−1, taking logarithms we have that this is equivalent to log n − (1 − δ)(1 + 1 2 λ) log n = (δ − 1 2 λ + 1 2 δλ) log n < 0 ⇐⇒ 2δ (1 − δ) < λ. For our choice of λ, this requirement is satisfied. This condition is used by Lemma 3.5. • v2 (cid:28) nq1+ 1 Again taking a logarithm, we have that this condition is equivalent to λ. 3 log n − (1 + 1 3 Since we have required δ ≥ (cid:113) (log log n)4 λ)(1 − δ) log n − 2 log v (cid:29) 0, ⇐= λ < 3δ 1 − δ (cid:29) log v log n and λ < 2δ 1−δ + O − 6 log v log n − Ω (cid:17) (cid:16) log v log n log n condition. This condition is used by Lemma 3.9 and Lemma 3.10. (cid:32) log v (cid:33) log n . , we satisfy this 26 (cid:48)/2v8 ≥ 1. • nqd Again taking logarithms, we have that this condition is equivalent to (cid:18) (cid:19) δ − 1 2 λ + 1 2 λδ log n − (2 + λ) log 1 γ + 8 log v > 0 which is in turn implied by log 1 γ (cid:28) log v, and (cid:18) δ − 1 2 λ + 1 2 λδ (cid:19) > −1.9 log v log n , where the latter condition can be strengthened to ≥ 2δ 1 − δ 1 − δ − 1.9 log v 2δ log n + 1.9 log v log n > λ. This latter condition is met by our choice of λ. By assumption, γ−1 = o(logc n) for any constant c, so the first condition is met as well. This condition is used by Lemma 3.5, Lemma 3.6, and Lemma 3.9. • 1 ≤ H · vnv−1q d (cid:48) 2 v. We first address the lower bound. By Proposition 4.16, we can take H to be of size up to (λv)cλv for c = 69 (cid:18) which is in turn implied by log v − log 100. Taking logarithms, this is equivalent to 0 < cλv log(λv) + log v + (v − 1) log n − v(1 − δ)(1 + 1 2 (cid:19) (cid:18) And this holds when + log v v λδ − 1 v δ − 1 2 λ + 1 2 0 < cλ (cid:19) (cid:18) 1 λ + log 1 γ (cid:28) log v, log n v (cid:28) log v, log 1 λ (cid:28) log v, and λ) log n − v(2 + λ) log 1 γ 1 γ , log n − (2 + λ) log (cid:19) δ − 1 2 λ + 1 2 λδ > −0.9 · cλ log v log n . And (since δ is sufficiently small) the latter condition can be strengthened as follows: 2δ (1 − δ − 1.8c log v log n) > 2δ 1 − δ + 1.8 · c log v log n > 2δ 1 − δ ≥ λ, + log v log n (cid:18)(cid:113) log n (cid:19) This is met by our choice of λ, and we also have λ−1 ≤ O(δ−1) = o satisfy the lower bound. condition: Claim 3.14. In the sparse case when d (cid:48) = 2 + λ, Hvnv−1qd . Therefore, we In fact, under these conditions, we satisfy the following, stronger (log log n)4 (cid:48)/2 ≥ vλv/100. This condition is used by Lemma 3.9. • p = nδ−1 for δ < 1 3. This holds by assumption. This condition is used by Lemma 3.5. 27 (cid:48) ∈(cid:16) 2 Dense case requirements. 1−δ + log log n and d 4 log n the following conditions: 1−δ , 2 (cid:17) If p = nδ−1 ∈ [n so that d −], we have chosen an even integer v = Θ(log n) (cid:48) ≥ 6. We must verify v is an integer. It can be verified that d −1/3, n (cid:48) (cid:48) (cid:48) − (cid:98)d (cid:48) so that d v is an integer. (cid:48)(cid:99)v is also an integer. • There exists a choice of d We first notice that this implies that (d chosen v even, and because (cid:98)d Now, we see that so long as v = Ω(log n), for n sufficiently large there is at least one integer (cid:48) in the allowed interval of d • npd Taking the logarithm, we equivalently require that (cid:48)(cid:99))v is an even integer; this is because we have (cid:48)/2 < 1. v. log n − (1 − δ) (cid:48) d 2 log n < 0 ⇐⇒ d . (cid:48) > 2 1 − δ 2 (1 − δ) − 1 = O( log v log n), as in our satisfies this requirement. When v (cid:28) n and d (cid:48) Our choice of d case, these inequalities are easily satisfied. This condition is used by Lemma 3.5. • nq(1−β) 1 2 d Take logarithm, this is equivalent to requiring that (cid:48) (cid:29) v2. (cid:48) log n − (1 − δ) (cid:48) d 2 log n + 1 2 (cid:48) (1 − δ)(λ + 1 26 ) log n (cid:29) log v. . This condition is used by Lemma 3.9 and Lemma 3.10. Which holds by our choice of λ and d • 2v2+2(d − 1 50 . Taking the logarithm, this is equivalent to requiring that (cid:48)/2 ≤ 1 2p 50 ≤ v2(d (cid:48)+2)npd (cid:48)+2)p 1 1+(2 + 2(d (cid:48) + 2)) log v− 1 50 (cid:48) Which, using that d (cid:48) + 4) log v+log n−d 2 (1−δ) log n < (2d (cid:16) log v (cid:17) 2 (1 − δ) − 1 = O (1 − δ) log n < ±O(log v) < −1 + 1 (cid:48) + 2)) log v − 1 50 50 , is equivalent to log n 1 + (3 + 2(d (1 − δ) log n. (cid:48) (1−δ) log n < −1+ 1 50 (1−δ) log n. 50 ≤ v2(d Using that δ < 1 −  for  fixed as a function of n, and that v = O(log n), gives the desired conclusion. • 2v2+2(d (cid:48)+2)q 1 Since we have assumed that γ = o(logc n) for any constant c, and because p = nδ−1 for δ a constant, the previous condition implies this one as well. This condition is used by Lemma 3.5, Lemma 3.7, and Lemma 3.9. • 1 ≤ H · vnv−1q d (cid:48) 2 v. (cid:48)/2 ≤ 1 2q (cid:48)+2)nqd − 1 50 . 28 By Proposition 4.9, we can take H = vCd·v, where Cd = When d is equivalent to 26) 1 d(cid:48) . 2. Taking the logarithm and dividing by v, we have that the lower bound (cid:48) ≥ 6, Cd > 1 and β = (λ + 1 2 (cid:16) d 4 (1 − β) − 1 (cid:48) λ(cid:17) 0 < Cd log v + log v v + (1 − 1 v (cid:48) ) log n − d 2 This condition is met so long as (cid:28) log v, (cid:28) log v, log n log v v v log 1 γ (cid:28) log v, and (1 − δ) log n − d 2 (cid:33) (1 − δ) − 1 (cid:32)d (cid:48) 2 (cid:48) log 1 γ . ≤ log v 4 log n < 1 2 Cd log v log n ; The first three conditions we have by assumption, and the latter condition can be strengthened to d (cid:48) < 2 1 − δ + log v 2 log n , which our condition on λ satisfies. In fact, we can deduce the following stronger consequence: (cid:48)/2 ≥ v 1 Claim 3.15. In the sparse case when d (cid:48) ≥ 6, Hvnv−1qd 2 Cdv ≥ v 1 4 v. This condition is used by Lemma 3.9. E[Nu]] = o(1). The algorithm returns a partial solution. For each u ∈ V, let Nu be the number of distinct H ∈ H which contain the vertex u and which appear in both G0, G1. In both the sparse and dense regimes, we have that E[Nu] = H · vnv−1qe, which we have set to be at least vΩ(v) (where the Ω hides a dependence on λ in the sparse case). Claim 3.16. For u ∈ V, let Nu be the number of H ∈ H that contain u, so that H survives into both G1 and G2. Then Pr[Nu < 1 2 Proof. By Lemma 3.9, V(Nu) = o(E[Nu]). The claim follows by Chebyshev's inequality. Claim 3.17. With probability 1 − o(1), at least a E[Nu] distinct H ∈ H that survive the subsampling in both G0, G1. 1 that(cid:80) 2 Proof. Let Iu be the indicator that u is contained in at least 1 E[Nu] such H. With Claim 3.16 we have u∈V E[Iu] ≥ (1 − o(1))n. We can then apply the following averaging argument to conclude 2 that with probability 1 − θ − o(1), a θ-fraction of the vertices are covered by at least one H ∈ H: log v fraction of vertices u ∈ V appear in at least  ≤ θ · n Pr (cid:88) (1 − o(1))n ≤(cid:88) u∈V Iu ≥ θn(cid:3) ≥ 1−θ−o(1) as desired. Taking θ = 1 Thus, Pr(cid:2)(cid:80) log v gives us the desired conclusion. (cid:3) Claim 3.18. For u ∈ V, let Bu be the number of H ∈ H that contain u, so that H appears at least twice in the base graph B, and so that at least one copy of H survives into both G0 and G1. Then with probability at least 1 − o(1), at most n  + n · Pr v1/4 of u ∈ V have Bu ≥ 1 (cid:88) (cid:88) Iu ≥ θn  . [Iu] = E Iu < θn E[Nu]. E G0,G1 u∈V u∈V u∈V u∈V Iu v1/4 (cid:3) 1 29 Proof. Let Ju be the event that Bu ≥ v have that −1/4 E[Nu]. From Lemma 3.5 and Markov's inequality, we E[Bu] ≤ O(v −1/4). ≤ v −1/2 E[Nu] v−1/4 E[Nu] v−1/4 E[Nu] Pr[Ju] ≤ Then by Markov's inequality we get Iu ≥ Pr (cid:88) u∈V  ≤ O(v n log2 v −1/4 log2 v), as desired. E[Nu] distinct H ∈ H that appear in both G0, G1, we choose a uniformly random H ∈ H that it participates in, and match it based on that copy of H. In our algorithm, independently for every vertex which participates in at least 1 2 (cid:3) Given these conditions, Claim 3.17 (using Lemma 3.9) proves that step 2 of Algorithm 3.4 will log v) fraction of the vertices of G0, G1; since the H ∈ H have no non-trivial match at least an Ω( 1 automorphisms, the matches are always correct (and one-to-one) unless H is "bad", i.e. there is more than one copy of the H that was chosen in the base graph B. By Claim 3.18, with high probability the proportion of such "bad" H incident on each u ∈ V in the intersection graph is at most log2 v v1/4 ; since we make the choice of mapping for each vertex −1/8 fraction of the matched vertices, independently, a Chernoff bound implies that for all but a v we will make the match based on an H that appears only once in the base graph B. This completes (cid:3) the proof. 3.6 Bounds on the order-2 moments of subgraph counts Here we prove Lemmas 3.6, 3.7, 3.10 and 3.11, each of which bounds correlations of the counts of subgraphs in the test sets H, in the sparse and dense cases respectively. 3.6.1 Sparse case Lemma 3.6. When the average degree of H is d sufficiently large, (cid:48) = 2 + λ with λ ∈ [0, 1 76], then if 1 v8 −E(J) ≤ (1−θ)v(cid:88) v2q 1 λθ 100 s s=1 nq1+ 1 2 λ  + θv 1 nq1+ 1 2 λ v8nq1+ 1 2 v(cid:16) ≤ nqd (cid:48)/2, for v λ(1−θ). q 1 100 λ(cid:17)θv (cid:88) J⊂H XJ(H)2 · aut(J) · n −V(J) q − 1 Proof. We will make use of Lemma 4.18, which states that if J has (1 − α)v vertices, then it has density at most 1 + λ v))s. First, 2 we are going to remove the aut(J) with the following lemma. Lemma 3.19. Suppose that H is a connected graph on v ≥ 1 vertices with maximum degree ∆. Suppose also that pv2 < 1, and that the densest subgraph J λα; taking V(J) = s then gives that E(J) ≤ (1 + λ λ(1 − s − 1 100 100 2 −E(J) ≤ v2∆(v−s) (cid:88) ∗ ⊂ H on s vertices has αs edges. Then, −αV(J) XJ(H)2 · p −V(J) n XJ(H)2 aut(J) · n −V(J) p (cid:88) J⊂H,V(J)=s J⊂H,V(J)=s 30 s (cid:0)v (cid:1) ≤ min(vs/s!, vv−s) vertex induced subgraphs of H of size s, aut(J) can be trivially upper bounded We will prove Lemma 3.19 in the end of this subsubsection. Now, note that there are only by V(J)!, and the maximum degree of J is at most 3. Therefore, splitting the sum by the size of the (cid:88) subgraph J, v2s · n −sq −(1+ λ 2 − 1 100 λ(1− s v ))s + v8(v−s) · n −sq −(1+ λ 2 − 1 100 λ(1− s v ))s, XJ(H)2 · aut(J) · n −V(J) · q J⊂H V(J)≥1 And taking the maximal density in each of the sums, s=1 s=(1−θ)v+1 v−1(cid:88)  −E(J) ≤ (1−θ)v(cid:88) ≤ (1−θ)v(cid:88) ≤ (1−θ)v(cid:88) ≤ (1−θ)v(cid:88) λ− 1 s=1 s=1 λ 1 100 s=1   v2q 1 nq1+ 1 2 s s s (1−θ)v v2 λ− 1 + v8v 2 100 λθ nq1+ 1 v ≥ 1, the first term in the second sum dominates: s=(1−θ)v+1 λ 1 v 100 1 λ− 1 v8nq1+ 1 2 v2 λ− 1 λθ 100 s λθ 100 nq1+ 1 2 λ + θv + v8vθv  1 nq1+ 1 2 λ 1 λ− 1 v8nq1+ 1 2 100 λ 1 v λ(cid:17)θv v8nq1+ 1 2 λ(1−θ). q 1 100 v−1(cid:88)  v(cid:16) Since we have assumed that v8nq1+ 1 2 And finally simplifying both terms, This gives us our conclusion. Lemma 3.10. Let d (cid:88) (cid:48) = 2 + λ for λ ∈ (0, 1 XJ(H) · XJ(H (cid:48) J⊆H,H (cid:48) V(J)≥1 76]. Suppose that v2 = o(nq1+ 1 ) · aut(J) · n −V(J)+1q −E(J) ≤ v2 + nq2(1 + o(1)). 3 λ). Then for distinct H, H Proof. We split up the sum into J corresponding to an isolated vertex, for which XJ(H) = XJ(H and into J with more vertices (and therefore possibly edges): (cid:3) (cid:48) ∈ H v d(cid:48), (cid:48) ) = v, XJ(H) · XJ(H (cid:48) ) · aut(J) · n −V(J)+1q −E(J) ≤ v2 + J⊆H,H J⊆H,H (cid:48) (cid:48) V(J)≥1 V(J)=k λ)V(J) − 2, Since we have by Proposition 4.16 that E(J) ≤ (1 + 1 v(cid:88) (cid:88) k=2 3 XJ(H) · XJ(H (cid:48) ) · aut(J) · n −V(J)+1 · q2e−E(J) (cid:48) ) · aut(J) · n −k+1 · q −(1+ 1 3 λ)k+2 v(cid:88) (cid:88) (cid:88) ≤ v2 + XJ(H) · XJ(H k=2 J⊆H,H (cid:48) V(J)=k and finally because there are at most vk vertex-induced subgraphs J on k vertices and each of them has at most v non-trivial automorphisms, we obtain the crude upper bound V(J) v(cid:88) v2k · n −k · q −(1+ 1 3 λ)k = v2 + nq2 k=2 k=2 v(cid:88)  k . v2 n · q(1+ 1 (cid:3) 3 λ) ≤ v2 + nq2 So long as v2 = o(nq1+ 1 3 λ), the conclusion holds. 31 Proof of Lemma 3.19. Let us start with an observation on the number of non-trivial automorphsims for a vertex-induced subgraph of a graph that has no non-trivial automorphism. Claim 3.20. Suppose that H is a v-vertex graph with no non-trivial automorphisms, and let J be a graph obtained from H by removing (cid:96) edges. Then J has at most v2(cid:96) non-trivial automorphsims. Proof. Let S ⊂ V(J) be the ordered set of endpoints of the (cid:96) edges removed. We have S ≤ 2(cid:96). Now suppose by way of contradiction that J has more than v2(cid:96) non-trivial automorphisms. Then by a pigeonhole argument, there must be an ordered set of vertices T ⊂ V(J) and two distinct automorphisms, π and σ, such that π(S) = σ(S) = T. But then, π◦σ−1 is a non-trivial automorphism of J that maps S to S, and can therefore be extended to a nontrivial automorphism of H. This is a (cid:3) contradiction. Let Sv−s be the set of vertex-induced subgraphs of H obtainable by removing (v − s) vertices, and for each J ∈ Sv−s, let S(J)(cid:96) be the set of edge-induced subgraphs obtainable from J by removing (cid:96) edges. If there is a subgraph K ⊂ H which appears in more than one set S(J)(cid:96), we remove some of its appearances so that the S(J)(cid:96) form a partition. Re-writing the sum on the left-hand side, we have(cid:88) XJ(H)2 aut(J) · n −V(J) −E(J) = p XK(H)2 aut(K) · n −V(K) −E(K) p (31) J⊂H V(J)=s XK(H)2 aut(K) · n −V(K) p −E(J)+(cid:96) (32) Now we bound aut(K): if we remove v − s vertices from H this removes at most ∆(v − s) edges, and then we remove at most (cid:96) additional edges, which removes at most ∆(v − s) + (cid:96) edges. Then applying Claim 3.20: (cid:88) (cid:88) J∈Sv−s ∆v/2(cid:88) ∆v/2(cid:88) (cid:96)=0 (cid:88) (cid:88) K∈S(J)(cid:96) J∈Sv−s K∈S(J)(cid:96) (cid:96)=0 = K∈S(J)(cid:96) (cid:88) (cid:96)=0 max (cid:96)∈[∆v/2] J∈Sv−s ∆v/2(cid:88) (cid:32) ≤ (cid:88) ≤ (cid:88) ≤ v2∆(v−s) (cid:88) ≤ v2∆(v−s) (cid:88) J∈Sv−s J∈Sv−s J⊂H,J=s and so long as pv2 < 1, this is maximized for (cid:96) = 0: XK(H)2v2(∆(v−s)+(cid:96)) · n (cid:33) ∆v/2(cid:88) (cid:88) (v2p)(cid:96) K∈S(J)(cid:96) (cid:96)=0 −V(K) p −E(J)+(cid:96) (33) XK(H)2v2∆sn −V(K) −E(J) p (34) ∆v/2(cid:88) (cid:88) K∈S(J)(cid:96) XJ(H)2 · p (cid:96)=0 −V(K) XK(H)2n −αV(J) −V(J), n −E(J) p (35) (36) where in the final line we have used that the S(J)(cid:96) form a partition, and that α is the maximum (cid:3) density of any subgraph J. 32 3.6.2 Dense case Lemma 3.7. When the average degree of H is d (nqd (cid:48)/2)v−1 ≤ v2(d (cid:48)+2)q 1 50 , then(cid:88) XJ(H)2 · aut(J) · n J⊂H −V(J) −E(J) ≤ 4(v2(d (cid:48)+2)q 1 50 ) · q 50 ≤ v2(d (cid:33)v−1 (cid:32) 1 nqd(cid:48)/2 . (cid:48) ≥ 6, so that 2v2+2(d (cid:48)+2)q 1 (cid:48)+2)nqd (cid:48)/2 ≤ 1 2q − 1 50 and (cid:48) = d + λ for d > 2, our construction is as follows: we We will rely upon the following claim, which bounds the density of subgraphs of H. Proof. When H ∈ H have average degree d sample a d-regular graph on v vertices, then add a uniformly random matching on λv vertices. Claim (consequence of Claim 4.11). For H ∈ H v  (cid:16) d J ⊆ H of with V(J) = (1 − θ)v for θ ∈ [0, 1], − 1 V(J) − 1 (cid:48) = d + λ for d ≥ 6 and λ ∈ [0, 1], For any (cid:17)V(J) if θ < 1 if θ ≥ 1 2 E(J) ≤ d(cid:48) with d θv , . 50 50 2 (cid:48) 2 (cid:48) d 2 J⊆H V(J)=k v2(d nkq d(cid:48) (cid:48)+2)vq 1 50 v k=v/2 ≤ v2(d (cid:48)+2)(v−k) 2 k− 1 50 (v−k)  v−1(cid:88)  k=v/2 33 1 v2(d(cid:48)+2) · n · q( d(cid:48) 2 + 1 50 ) ≤ v2(d (cid:48)+2)vq 1 50 v · 2 1 v2(d(cid:48)+2) · n · q( d(cid:48) 2 + 1 50 ) k v−1 (cid:33)v−1 . (cid:32) 1 nqd(cid:48)/2 = v2(d (cid:48)+2)q 1 50 · 2 Thus, we can split J according to size. We have that: XJ(H)2 · aut(J) · n −V(J) −E(J) q (cid:88) ≤ v/2−1(cid:88) J⊆H (cid:88) k=0 J⊆H V(J)=k v−1(cid:88) (cid:88) k=v/2 J⊆H V(J)=k XJ(H)2 · aut(J) · n −V(J) −E(J) + q XJ(H)2 · aut(J) · n −V(J) −E(J). q We first bound the first summation. We have that v/2−1(cid:88) (cid:88) k=0 J⊆H V(J)=k XJ(H)2 · aut(J) · n −V(J) q −E(J) ≤ v/2−1(cid:88) k=0  v2 nq d(cid:48) − 1 2 50 k ≤ 2, where we have upper bounded XJ(H) by v!/V(J)! and upper bounded aut(J) byV(J)! and obtained 50 ≥ 2v2. − 1 (cid:48) the final inequality used by our choice of d The second summation we bound in the same manner, but now using that if k = (1 − θ)v then θv = v − k, and there are at most vv−k subgraphs of size k: (cid:88) v−1(cid:88) (cid:48)+1)(v−k) (cid:88) −(cid:16) d (cid:48) 2 k− 1 (cid:17) 50 (v−k) −V(J) −V(J) , nq d (cid:48) 2 XJ(H)2 · aut(J) · n XJ(H)2n v2(d q q k=v/2 J⊆H V(J)=k −E(J) ≤ v−1(cid:88) ≤ v−1(cid:88) k=v/2 (cid:48)/2+ 1 Where to obtain the first inequality we have applied Lemma 3.19 and to obtain the final inequality we have bounded this geometric sum by its leading term where k = v − 1, and have used that v2(d (cid:48)+2)nqd Combining these two terms, the term from the second summation has larger magnitude than (cid:48)+2)q1/50. This completes (cid:3) the term from the first summation, as we have assumed (nqd the proof. (cid:48)/2)v−1 ≤ v2(d 50 ≤ 1 2. Lemma 3.11. Let d (cid:48) (cid:29) v2. Then for distinct H, H nq(1−β) 1 2 d XJ(H) · XJ(H (cid:48) (cid:48) = d + λ for d ≥ 6 and λ ∈ [0, 1]. Define β = (λ + 1 (cid:88) (cid:48) ∈ H v d(cid:48), ) · aut(J) · n −E(J) ≤ v2 + nqd −V(J)+1q (cid:48)/2 · (1 + o(1)). 26) 1 d(cid:48) , and suppose that J⊆H,H (cid:48) V(J)≥1 2(1− β)d XJ(H) · XJ(H v(cid:88)  v(cid:88) (cid:48)/2 · (cid:48)/2 · k=2 k=2 (cid:48) ) · aut(J) · n (cid:88)  J⊆H,H (cid:48) V(J)=k v2 nq(1−β) d(cid:48) 2 k−1 , J⊆H,H (cid:48) V(J)≥1 ≤ v2 + nqd ≤ v2 + nqd (cid:48) has at most E(J) ≤ 1 Proof. We will use Proposition 4.9, from which we have that for β = (λ + 1 J ⊆ H, H bound XJ(H) ≤ v (cid:88) V(J)/V(J)! and aut(J) ≤ V(J)! (and pulling out the special case V(J) = 1), d(cid:48) , every subgraph (cid:48) − ξ, by applying the trivial (cid:48) < 1 2d (cid:48) ·V(J)− d (cid:48) 2 . Since 1 2(1− β)d 26) 1 −V(J)+1q −E(J) XJ(H) · XJ(H (cid:48) ) · aut(J) · n −V(J) q −(1−β) d (cid:48) 2 V(J) and using that v2 (cid:28) nq(1−β) d conclusion. (cid:48) 2 , we have that the geometric sum is 1 + o(1), which gives us our (cid:3) 3.7 Boosting from a partial assignment So far, we have shown that our algorithm partially recovers the ground truth permutation (with some errors). In this section we show how to "boost" this to full recovery of the ground truth permutation. There are many algorithms in the literature on the graph matching problem that deal with recovering the ground truth permutation from such a partial matching on a subset of the vertices, which is typically known as a seed set [YG13, LFP14, LAV+14]. These works typically study a simple percolation, which can be shown to succeed in a random graph [JŁT+12]. However, our setting is somewhat different: • These algorithms typically assume that the seed set is chosen at random, while in our setting the seed set (i.e., partial solution) is learned from the graph and has arbitrary correlation with it. • These algorithms typically (though not always [KHG15]) assume that the permutation is known perfectly on the seed set (i.e., that they are given an (s, 1) partial solution), while it will be more convenient for us to allow some probability of error. 34 For this reason, we reprove here that a percolation-like algorithm succeeds in our more general setting (albeit with worse bounds than those of [JŁT+12]). Specifically, we show that we can boost an ( Ω(n), 1 − o(1)) partial solution to a the full ground truth: Lemma 3.21 (Boosting from partial knowledge). Let p, γ, n, , c, θ be such that pγn ≥ logc n for c > 1, θ = o(γ2) and θ = Ω(log1−c n). Then there is a polynomial-time algorithm A such that with probability 1 − o(1) over the choice of (G0, G1, π∗ ) from Dstruct(n, p; γ), if A is given G0, G1 and any (θn, 1 − ) partial solution π, then it outputs the ground truth permutation π∗ . Lemma 3.21 completes the proof of Theorem 3.2. Note the order of quantifiers in Lemma 3.21: the partial solution π can be adversarially chosen, as long as it satisfies the desired conditions. The proof of Lemma 3.21 is obtained by analyzing the following percolation algorithm. This is the same algorithm used in prior works except that we set our parameters in a particular way, and the "seed set" can depend arbitrarily on the graph. We will denote by G the "intersection graph" of G0 and G1 (see Definition 3.8). Note that G is distributed according to G(n, q) where q = γ2p. We let c be some sufficiently large constant. Input: (G0, G1, π∗ Algorithm 3.22 (Boosting from a non-random seed). . ) ∼ Dstruct(n, p; γ) with and a partial one-to-one map π : V(G0) → V(G1), defined on at least θn vertices of V(G0), such that for all but an  fraction of the u's on which π is defined, π(u) = π∗ (u). Goal: Recover π∗ 1. Let u be a vertex of G0 and v be a vertex of G1. We define the number of "common neighbors" of u, v, denoted as N(u, v), to be the number of w's such that (i) w is a neighbor of u, (ii) π is defined on w, and (iii) π(w) is a neighbor of v. 2. Let ∆ ∈ N be a parameter, which we set as (cid:98)θγ2np/100(cid:99) where θ is the fraction of vertices on which π is defined. there is a pair (u, v) where π is not defined at u with N(u, v) ≥ ∆ then define π(u) = v. 3. Step 1: Completing the solution. Repeat the following until we cannot do so anymore: If 4. If the permutation is not yet complete at the end of step 1, complete it to a full permutation 5. Step 2: Fixing the solution. We let ∆(cid:48) = (cid:98)γ2np/100(cid:99). Repeat the following until we cannot do such that N(u, π(u)), N(π−1(v), v) ≤ ∆(cid:48)/10 arbitrarily. it anymore: if there exists a pair u, v with N(u, v) ≥ ∆(cid:48) then modify the permutation π to map u to v and map π−1(v) to π(u). 6. Output π inputs on which π is defined, and in Step 2 we increase in every iteration the potential(cid:80) This algorithm will indeed run in polynomial time: In Step 1 we keep increasing the number of u N(u, π(u)) and so we can only run in polynomial time. Lemma 3.21 will follow from the following two claims: Claim 3.23 (Step 1 analysis). With probability 1 − o(1) over the choice of the graphs (G0, G1), by the end of Step 1, the permutation π is defined on all inputs, and there are at most 10n vertices v on which π(v) (cid:44) π∗ Claim 3.24 (Step 2 analysis). With probability 1 − o(1) over the choice of the graphs (G0, G1), by the end of Step 2, the permutation π will equal π∗ (v). . The following lemmas will be useful for our proof. 35 In our setting of parameters, with p < n ) ∼ Dnull(n, p; γ). Then with probability at least (u), the number of joint neighbors in G = G0 ∩ π∗−1(G1) of Lemma 3.25 (Few common neighbors). Let (G0, G1, π∗ 1 − o(1), for every pair u and v such that v (cid:44) π∗ u and v is at most 10(γp)2n · log n. Proof. If u (cid:44) v, then their neighbors in G are chosen independently at random and the expected number of them is (γp)2n. The probability that this variable is 10 log n times larger than the expectation will be exponentially small in 10 log n and so we can take a union over all n2 pairs of (cid:3) vertices. −Ω(1), it will always be the case that 10(pγ)2n log n (cid:28) ∆ = (cid:98)θqn/100(cid:99). Lemma 3.26 (Expansion). Let G ∼ G(n, q). If q ≥ c log n/n then then with high probability over G, for every non-empty set S, E(S, S) = (1 ± 10√ Proof. Let S with S = θn. We assume θ ≥ 1/2 (otherwise move to the complement). In a random graph, the random variable X = E(S, S) is just the sum of at least SS = θ(1 − θ)n2 independent Bernoulli random variables each with expectation q, and so µ = E[X] = θ(1 − θ)qn2. kθqn2 is exponentially small in k. As long as k is larger (cid:1) ≤ 10θn log n then we can take a union bound over all such sets S. Hence the So, the probability that X − µ ≥ (cid:112) than 10 log(cid:0) n c)qSS. θn √ (cid:112) 10 log nθ2qn3 ≤ θ(cid:112) qn log nn < 10θqn2/ deviation will always be smaller than q ≥ c log n/n. c as long as (cid:3) We now turn to completing the analysis of the algorithm by proving Claims 3.23 and 3.24. . Under our assumptions, A ≥ θn/2 and B ≤ θn. Proof of Claim 3.23. Let S be the current set on which π is defined, and let T = [n] \ S. We write S = A ∪ B where A is the "good" set, on which π agrees with π∗ , and B is the "bad" set, on which π disagrees with π∗ Let (u1, v1), . . . , (uk, vk) be the pairs we add to the permutation π during Step 1 in chronological order. We start by bounding the number of "bad pairs" where π(ui) (cid:44) vi. In such a bad pair ui and , and a necessary condition for N(ui, vi) ≥ ∆ vi have o(∆) shared neighbors under the ground truth π∗ is for ui to have at least ∆/2 neighbors that were themselves previously mismatched. So, if there are b "bad pairs", then it means that there is a sequence u1, . . . , ub such that each ui has at least ∆/2 neighbors that are either in the original set B or are of the form uj for j < i. Suppose towards a contradiction that b ≥ B. Then the set B (cid:48) = B ∪ {u1, . . . , uB} has size 2B ≤ 2θn, but half of the (cid:48) vertices in it have ∆/2 edges going into B . Hence the average degree of the induced subgraph on (cid:48) is at least ∆/4. Since the expected average degree would be θqn = o(∆) this corresponds to a B deviation of about ∆B and its complement. If qn (cid:29) log n/θ then this contradicts Lemma 3.26. The above shows that the number of mistakes we make is at most O(θn) but we still need to rule out the possibility that we simply get "stuck" and can't find a pair (u, v) with N(u, v) ≥ ∆. (cid:48) ∪ B (cid:48) Suppose towards a contradiction we get stuck after we have defined π on a set S (cid:48) where A is the bad set on which we (cid:48)/n. We know that α ≥ θ. Also, the argument above showed that defined it incorrectly. Let α = A B (cid:48) ≤ 10θn. There are about qA (cid:48)(n − A and its compliment, and so (since the degree of the graph is qn), there will be at least α/10 fraction of the vertices in the compliment (cid:48) ≥ 20θn/α (or of A equivalently, α(1 − α) ≥ 20θ), there will be more than 2B that (cid:48) have more than ∆ edges into A in the intersection graph G. Hence, even if we ignore all vertices u (cid:48) is the "good" set on which we defined π correctly. and B (cid:48)) in the number of edges between B (cid:48) that have at least αqn/10 edges into A . This means that as long as n − A (cid:48) vertices u in the compliment of A (cid:48) (cid:48)) edges between A (cid:48) (cid:48) = Ω(θqnB (cid:48) = A (cid:48) (cid:48) 36 such that either u ∈ B (cid:48) neither u nor π∗ (u) were defined. or π∗ (u) ∈ π(B (cid:48) ), we still can find one vertex u such that N(u, π∗ (u)) ≥ ∆ and In particular this means that at the end of step 1, at most 20θn vertices are undefined and for (cid:3) them we complete the permutation arbitrarily. Proof of Claim 3.24. In this step we assume we have an almost optimal permutation π such that π(v) = π∗ (v) for all but δ fraction of v's (for δ = O(θ))16. The main idea is that with high probability over the choice of random graphs, they will satisfy expansion properties that guarantee that our boosting algorithm does not get stuck. Note that this is with respect to an arbitrary initial error pattern. That is, with high probability over the choice of random graphs, no matter which almost optimal permutation we are starting with, the algorithm will not get stuck. Concretely, the following lemma shows that with high probability over the choice of random graphs, Step 2: Fixing the solution can keep making progress in fixing mismatched vertices: ) ∼ Dnull(n, p; γ) and δ ∈ (0, 1/10). Then with probability at least 1 − o(1) Lemma 3.27. Let (G0, G1, π∗ on at least 1− δ fraction, after one ), for any permutation π that agrees with π∗ over the choice of (G0, G1, π∗ round of the Step 2: Fixing the solution in Algorithm 3.20, the fixed permutation will agree with π∗ on at least 1 − δ/2 fraction. Further, if δ = o(pγ), then the fixed permutation will equal π∗ . Before we prove Lemma 3.27, note that it addresses the reviewer's (valid!) concern in our original proof of Claim 3.22. The reason is that Step 2: Fixing the solution is able to keep making progress and fixes every mismatched vertices in the end. Proof of Lemma 3.27. The main idea is based on the following expansion property of random graphs. Claim 3.28. Let G ∼ G(n, q) where q ≥ 20000 log n/n. Then with high probability, for any subset S of size S ≤ n/20000, E(S, S) ≤ S∆(cid:48) Proof of Claim 3.28. Let S with S = θn where θ ≤ 1/100. In random graph G ∼ G(n, q), we let (cid:1). By Chernoff's bound, we know that the (cid:1) ≤ 10θn log n then we can simply take an union bound over all possible S. As a result, (cid:106) qn (cid:107) random variable X = E(S, S) and µ = E[X] = q(cid:0)θn probability that X − µ > (cid:112) 10 log(cid:0) n kθ2n2q is exponentially small in k. Thus, as long as k is larger than 100 where ∆(cid:48) = 100 2 . θn (cid:113) X ≤ µ + ≤ qnS 20000 (cid:115) 10θn log nθ2n2q + qnS · 10θ log n qn ≤ S∆(cid:48) 100 with high probability. (cid:3) Next, apply averaging argument on Claim 3.28 and G to be the intersection graph and S to be the set of mismatched vertices, there are at least S/2 vertices in S having less than ∆(cid:48)/50 edges to vertices in S. Thus, Step 2: Fixing the solution would correct S/2 many vertices. As for the case where δ = o(pγ), the size of mismatched vertices is o(∆(cid:48) ) and thus Step 2: Fixing (cid:3) the solution would fix all the remaining vertices. 16In the previous version, we did not take care of the possibility of some weird correlation between the error pattern and the almost optimal permutation we are starting with. (cid:3) 37 3.8 Putting it all together Here, we tie up loose ends and prove Theorem 3.2. Proof of Theorem 3.2. The proof of correctness follows together from Lemma 3.13 and from Lemma 3.21. cannot take more than poly((cid:0) v2 (which takes(cid:0)n The running time of Algorithm 3.4 is nO(log n), since it simply requires constructing H (which (cid:1)) = vO(v) time), then looking for the subgraphs in H in G1, G2 (cid:1)H = vO(v) · nO(v) = nO(v) time). The runtime of Algorithm 3.22 is polynomial time. d(cid:48)v Thus, we conclude that there is a quasi-polynomial time algorithm that solves Problem 3.1 with (cid:3) high probability in the specified parameter region. v 4 Test Subgraphs Both the distinguishing and recovery algorithms rely on a carefully chosen "test set" of graphs with a set of delicate properties. In this section, we construct test sets with these characteristics. Theorem 4.1 (General overview of test graph properties). For any rational scalar d ∈ (2, 2 + 1 d ∈ Z≥3 or d ≥ 6, and sufficiently large even integer v, there exists a set H v following properties. 1. Every H ∈ H v 2. Every H ∈ H v 3. Every H ∈ H v (cid:16) d 4. For every pair of distinct graphs H, H d has average degree d, or density d/2, i.e., e = dv/2. d is strictly balanced. d has no non-trivial automorphisms. (cid:17)V(J) (where α(d) > 0 depends on the density d). d have no shared subgraphs J ⊂ H, H 76) or d of v-vertex graphs with the of edge density − α(d) (cid:48) ∈ H v (cid:48) larger than 2 5. The size of the family is H = vΩd(v). In fact, Theorem 4.1 is the union of Propositions 4.2, 4.9 and 4.16, each of which covers a different set of densities d (and each of which contains a more precise quantitative statement). When d is an integer, random d-regular graph satisfy all but condition 4, and the graphs have sufficiently different edge sets on average that we can argue that a sufficiently large fraction of d-regular graphs can be chosen while still satisfying condition 5. On the other hand, when d is a non-integer, the strict balancedness property is less straight- forward to satisfy. Further, for recovery we require a strengthened, quantitative notion of strict balance. In Section 4.1, we will prove that random d-regular graphs satisfy our requirements, and in Sections 4.2.1 and 4.2.2 we design constructions that leverage d-regular regular random graphs to obtain graphs of dense and sparse non-integer average degrees. 4.1 Test subgraphs with integer average degree Suppose that we were only interested in constructing test sets of graphs with integer average degree d ≥ 3. For those cases, random d-regular graphs will satisfy almost all of our requirements for the individual graphs H, and we will prove that there is a large subset of graphs on d vertices so that every pair of graphs have no dense common subgraphs. 38 Proposition 4.2. For each integer d ≥ 3 and α ∈ [ 12 d-regular graphs on v vertices H v = v 1 d , with H v 2 d , 1], for v sufficiently large, there exists a set of 25 α·d·v such that every graph H ∈ H is connected, has no non-trivial automorphisms, and for every distinct pair H, H (cid:48) ∈ H, H and H Random d-regular graphs are known to satisfy many of our requirements, either absolutely or do not contain any common subgraphs J with E(J) > αd · V(J) − d. (cid:48) with high probability. For example, the following well-known fact: Fact 4.3. For integer d ≥ 2, any connected d-regular graph is strictly balanced. Proof. If H is a d-regular graph and J is a proper subgraph of H, then J must have at least one vertex (cid:3) of degree less than d. Additionally, classical results assert that random d-regular graphs are with high probability connected, and also contain no non-trivial automorphisms. Theorem 4.4 ([Bol81, Wor80, Luc89]). If H is a random d-regular graph on v vertices and 3 ≤ d ≤ O(v0.02), then H is connected asymptotically almost surely. Theorem 4.5 ([Bol, DMCW84, KSV02]). If H is a random d-regular graph on v vertices and 3 ≤ d ≤ v−4, then almost surely H has no non-trivial automorphisms. It is not too difficult to see that there are at least vΩ(v) d-regular graphs on v vertices; however, a precise formula is also known. The following is a consequence of a theorem of McKay and Wormwald. Fact 4.6 ([MW90]). For 3 ≤ d ≤ o( v), there are at least √ (dv)! (dv/2)!2dv/2(d!)ved2 d-regular graphs on v vertices. Now, we will prove that there is a set of at least vΩ(dv) d-regular graphs that have all of the above properties, while not sharing any dense subgraphs. (cid:48) Proof of Proposition 4.2. We construct a meta-graph G whose vertices correspond to d-regular graphs. For two d-regular graphs H, H intersect on a subgraph J of average degree at least α · d. , we add an edge between their vertices in G if H and H First, we argue that most H do not have small subgraphs of density α. This follows from a result of Bollob´as, who proves that d-regular random graphs are good expanders. Theorem 4.7 ([Bol88]). If d ≥ 3 is a fixed integer and H is a d-regular random graph on v vertices, then almost surely every subset S of k ≤ v/2 vertices of H has at least cd · dk edges to S, where cd ≥ 3 50. When d ≥ 6, cd ≥ 13 75.17 (cid:48) For constant-sized subsets, we also use the following known lemma. Lemma 4.8 (e.g. [Wor]). For any fixed integer d ≥ 3, a d-regular random graph H on v vertices does not contain any subgraphs J of fixed size with E(J) > V(J), asymptotically almost surely. 17In general, cd → 1 2 as d → ∞. 39 So to rule out dense shared subgraphs on fewer than 100 vertices, we use Lemma 4.8, to conclude that all but an o(1) fraction of d-regular graphs cannot contain a subgraph on at most 100 with density > 1. graphs contain subgraphs J of size less than v/2 with more than (dV(J)− 3 edges. Thus, for a "typical" pair of d-regular graphs H, H [100, v/2] the conclusion holds: For larger subgraphs, we apply Theorem 4.7, concluding that only a o(1) fraction of all d-regular ·V(J) with V(J) ∈ and for any J ⊂ H, H 50dV(J))/2 = d 47 100 (cid:48) (cid:48) V(J) − d, where the final inequality holds by our lower bound V(J) ≥ 101. V(J) ≤ d 48 E(J) < d 47 100 100 For convenience, fix α so that α ≥ 48 (cid:48) (cid:48) 2v− dV(J)α ≤ 1−α 100. For a "typical" d-regular graph H, we bound the number which share a subgraph of more than v/2 vertices with at least dα · V(J) of d-regular graphs H edges. For each such subgraph J ⊆ H, H intersects with at most M(1−α)dv graphs H , where M2k denotes the number of matchings on 2k elements. This is because once J is fixed, there remain at most d 2 dv edges in the rest of the graph, and the number of ways to arrange them is at most M(1−α)dv, the number of matchings on the (1 − α)dv "half edges" that leave the vertices of degree less than d once J is removed. Again for convenience, let β := 1 − α. There are at most at most 2dv/2 choices for of J, as that is the number of subsets of edges. Thus, the degree of a typical H (one which does not have dense subgraphs of size < v/2) in G is at most DG := 2dv/2 · Mβdv. Now, we remove the o(1) fraction of vertices of the meta-graph G corresponding to H with small dense subgraphs, nontrivial automorphisms, insufficiently expanding small subgraphs, or which are disconnected, to obtain a new meta-graph G we find the maximum (cid:48) independent set. Since the maximum degree in G is at most DG, the largest independent set has size at least G (cid:48)/(DG + 1). This independent set is our set H. (cid:48) . In the remaining graph G (cid:48) Applying Fact 4.6, we have that ≥ 1 4 H ≥ (DG + 1) G (cid:48) · G DG · ≥ 1 4 ≥ 1 8ed2 (dv)! (cid:32) 2dv)!2dv/2(d!)ved2 ( 1 · e · ββ · 2 · d(1+β) 1 2 β · dv)! · 2βdv/2 · ( 1 (cid:33)1/(1−β) 2dv/2 · (β · dv)! (1−β)dv/2 v , where in the final line we have applied Striling's approximation. The conclusion follows. (cid:3) 4.2 Test subgraphs with non-integer average degrees Now, we will use our integer-average-degree sets to construct a test set for graphs of non-integer average degrees. 4.2.1 Test subgraphs with density at least 3 Here, we will show that for graphs of average degree at least 6. In this regime, the expansion properties of d-regular random graphs are so strong that they allow us to tread less delicately, and simply add a random matching on top of a d-regular random graph to obtain a graph with average degree between d and d + 1, without jeopardizing the strict balancedness property. Our construction will be as follows: 40 Proposition 4.9. Let d ≥ 6 be an integer, and let λ ∈ (0, 1) be a rational number. Define d (1 − λ) · d. Then for any β ∈ [0, (λ + 1 , H v (cid:48) v vertices with average degree d (cid:48) = λ · (d + 1) + d(cid:48) ] and sufficiently large integers v, there exists a set of graphs on 26) 1 d(cid:48), with d(cid:48) ≥ v( 1 H v 4 (1−β)·d (cid:48)−λ/2)·v such that every H ∈ H v (cid:48), H ∈ H v of distinct H d(cid:48) has no non-trivial automorphisms and is strictly balanced, and so that every pair d(cid:48) do not intersect on subgraphs J with E(J) ≥ (1 − β) 1 (cid:48) · V(J) − d (cid:48) 2 . 2d Proof. Our construction will be as follows: we sample a d-regular random graph H, we add a random matching M on λ · v random vertices to obtain the graph H ∪ M, and we add it to the set G if H ∪ M is simple and if H ∈ H v d . Then, we will find the largest subset of pairs (H, M) ∈ H such that no pair of graphs H ∪ M and H (cid:48) ∪ M (cid:48) d − 1 5. First, we prove that H ∪ M is simple with constant probability. overlap on a subgraph with average degree larger than Claim 4.10. If d is a fixed integer, H is a d-regular random graph on v vertices, and M is a random matching on λv vertices, then with probability at least exp(− 1 4(d2 + 2d)) the matching M does not contain any edges that are included in H. Proof. The probability that H ∪ M is simple is at least the probability that a random (d + 1)-regular graph drawn from the configuration model is simple; this is known to occur with probability at least exp( 1−(d+1)2 (cid:3) Each H ∪ M clearly has the desired average degree; we will prove that our other desired properties hold as well. Claim 4.11. With high probability, H ∪ M is strictly balanced. Further, for any subgraph J ⊆ H ∪ M of with V(J) = (1 − θ)v, ) [Wor]. 4  d (cid:48) 2 (cid:48) d 2 E(J) ≤ V(J) − 1 V(J) − 1 50 V(J) θ · v 50 if θ > 1 if θ ≤ 1 2 2 , . Proof. Applying Theorem 4.7 with cd the expansion constant of d-regular random graphs, we have S edges. that in H, for every subgraph S containing at most v/2 vertices, S contains at most (1−cd) d 2, because J must expand in H, even if J contains the maximum 2 Thus, ifV(J) = (1−θ)v with θ > 1 (cid:18)1 possible number of vertices in M we have E(J) ≤ (1 − cd) λv, 1 2 Since for d ≥ 6, dcd ≥ 1 + 1 has at most (1 − θ − cdθ) d edges in M, If V(J) = (1 − θ)v with θ ≤ 1 · (1 − θ)v + min d 2 2 (cid:19) ≤ d (cid:48) 2 (1 − θ)v (d · cd − 1 + λ)(1 − θ)v. (37) · (1 − θ)v − 1 2 V(J). (cid:48) 25, this quantity is strictly smaller than d 2 2, then again by the expansion of the complement of V(J) in H, J 2v edges in H. Thus, even if J contains the maximum possible number of E(J) ≤ (1 − θ − cdθ) d 2 v + min (1 − θ)v λv, 1 2 (1 − θ)v + (λ − d · cd) v. θ 2 When d ≥ 6, dcd ≥ 1 + 1 Claim 4.12. With high probability over H ∪ M ∈ G, H ∪ M has no non-trivial automorphisms. (cid:48) 25 and this is strictly less than d 2 v. (cid:3) (cid:18)1 2 (cid:19) ≤ d (cid:48) 2 41 Proof. To establish our claim, we utilize the following result which is a corollary of a theorem of McKay and Wormwald. Theorem 4.13 (Corollary 3.8 in [MW84]). Let d ≥ 3 be a fixed integer. With high probability, a random simple graph on v vertices with λv vertices of degree d + 1 and (1− λ)v vertices of degree d has no non-trivial automorphsism. 26) 1 Standard arguments (see e.g. [JLR11]) establish that our distribution over graphs is contiguous with the uniform distribution over simple graphs on v vertices with this degree sequence, therefore this conclusion holds for the set G as well. (cid:3) Claim 4.14. For any d ≥ 6 and β ∈ [0, (λ + 1 d(cid:48) ], there is a set S of at least v( 1 (cid:48)−λ/2)v of pairs 4 (1−β)d (cid:48) · V(J) − d (H, M) such that no two pairs in S share a common subgraph J with E(J) ≥ 1 2(1 − β)d (cid:48) 2 . Proof. We again construct a meta-graph G, with one vertex for every pair of H ∈ H v d and matching M on (1 − λ)v vertices. We place an edge between (H, M) and (H (cid:48) (cid:48), M ) in the meta-graph if there is a shared subgraph J of H ∪ M, H (cid:48)V(J) − d 2(1 − β)d 2 . We'll take S to be the largest independent set in G; to obtain a lower bound on its size, we will bound the degree of (H, M) in G. (cid:48) 2 , we can apply Lemma 4.8 to conclude that with high probability over (H, M) and (H ), every J contains at most V(J) edges from H, and we also have that it contains at most V(J)/2 edges from M. Thus, as long as E(J) ≤ 3 (cid:48)V(J) − d 6 (this is using the fact that for V(J) ≤ 2, there cannot be more than one edge). do not overlap on subgraphs J with E(J) ≥ αdV(J) − d. Also, we can use Theorem 4.7 to conclude that with high probability for any subgraph J of H ∪ M and H 2 when d ≥ 6 and β ≤ 1 (cid:48) Now we consider larger subgraphs. By construction, H and H First, for subgraphs J ⊆ H ∪ M, H of size at most V(J) ≤ 25 · 26 · d such that E(J) ≥ 1 2(1 − β)d V(J) ≤ 1 (cid:48) ∪ M (cid:48) (cid:48) ∪ M (cid:48) (cid:48) ∪ M (cid:48), M (cid:48) (cid:48) 2 (cid:48) (cid:48) E(J) ≤ 1 2 ((1 − cd)dV(J) + V(J)) < 1 2 of size < v/2 has (d − 1 25)V(J) < 1 2 (d − 1 (cid:48) 26)V(J) − d , 2 26 (cid:48) ∪ M (cid:48) with E(K) ≥ 1 must intersect on at least We now bound DH,M, the degree of (H, M) in the meta-graph G, or the number of pairs (H where the second inequality uses that d ≥ 6 and the third inequality uses that V(J) > 25 · 26 · d (cid:48) 2 . 2(1 − β) · Suppose therefore that there exists some subgraph K ⊆ H ∪ M, H (cid:48) · V(K) − d d+λ ; it must follow that V(K) ≥ v/2. Furthermore, since the restriction of K (cid:48) 2 , for β < λ+ 1 d must have fewer than αdV(K) − d edges, we can conclude that the matchings M and (cid:48) to H and H αdv edges since V(K) ≥ v (cid:48) M 2. (cid:48), M (cid:48) ) and M. If (cid:96) > λv/2, (cid:16) 1 2(1 − β)d for which (H, M) can share at least (cid:96) = this is already a contradiction, and the graph G has no edges. Otherwise, DH,M is at most the number of choices of (cid:96) edges in M, times the number choices for the m = λv − 2(cid:96) vertices outside of these (cid:96) edges that could be in the matching in M (cid:48) , times the number of matchings remaining on m elements (corresponding to the leftover vertices). This is at most (cid:17) · V(K) ≥ 1 (cid:48) − αd (cid:16) 1 4(1 − β)d 4(1 − β)d (cid:17) · v edges between M (cid:48) v − 1 (cid:48) − 1 αd (cid:48) 2 2 (cid:32) 1 2 (cid:33) · λv (cid:96) DH,M ≤ (cid:33) (cid:32) v m · Mm. 42 On the other hand, with high probability over our choice of matchings M, G has at least exp(− 1 /2 vertices from Claim 4.10. The size of the maximum independent set in G is at least 2d))H v 4(d2 + d S ≥ G DH,M + 1 ≥ 1 2 ≥ 1 4 2 2 d λv (cid:96) · 1 4(d2 + 2d)) · H v · exp(− 1 (cid:1) · Mm (cid:1)(cid:0) v (cid:0) 1 (d2 + 2d)) · H v · exp(−1 4 − λv v− 1 · Ω(v) 4 (1−β)d (cid:48) + 1 m d 2 2 · Θ(v) · αdv− 4 log v v, = H v d λv · 2v ·(cid:16) m 1 e (cid:17)m/2 2 1 2 where we have bounded the binomial coefficients by 2v and applied Stirling's inequality to estimate the number of matchings. Finally, becauseH v α·dv by Proposition 4.2, we have our conclusion. (cid:3) d(cid:48) to be the largest independent set S given by the previous claim, then Finally, taking H v removing the o(1) fraction of graphs with non-trivial automorphisms, concludes the proof. ≥ v 1 (cid:3) d 2 4.2.2 Test subgraphs with density close to 1 In this subsection, we describe a graph family H of graphs of density close to 1 that satisfies the desired properties. In this regime, our strategy is to sample a 3-regular random graph and subdivide its edges into paths. If we want to achieve an arbitrary average degree, the paths that we subdivide cannot all have the same length. However, when we subdivide into paths that are sufficiently long, the expansion of the 3-regular graph will compensate for the asymmetry.18 Using this intuition, we are able to prove that our construction satisfies the desired properties when our target density is close to 1 (few degree-3 vertices relative to the number of degree-2 vertices). Algorithm 4.15 (Generating H v (cid:48) ∈ [2, 2 + )). . (cid:106) (1−λ)v (cid:107) d(cid:48) for d Input: An integer v and a desired average degree d = k, so that (1−λ)v number λ ∈ (0, 1). Let average number of desired degree-2 vertices per edge of H. (cid:48) ∈ [2, 3), so that d (cid:48) = 2(1− λ) + λ3 for a rational = α · k + (1 − α) · (k + 1) for α ∈ (0, 1); this is the In this subsection, we design test sets with density close to 1. 3λv/2 3λv/2 We require that λv is an integer , that 3λv is an even integer, and that α3λv/2 is an integer. For each graph H ∈ H v 3 : 1. Choose α · 3λv/2 edges of H uniformly at random, and replace them with paths of length k 2. For the remaining (1 − α) · 3λv/2 edges, replace them with k + 1 length paths. (subdivide the edge with k vertices). (cid:48) to the set H v Add the resulting graph H d(cid:48). Proposition 4.16. Let d with λ3v an even integer. Then the set H v (cid:48) average degree d (cid:48) = (1− λ)· 2 + λ· 3 = 2 + λ for λ ∈ (0, 1 76], and let v be a sufficiently large integer d(cid:48) produced by Algorithm 4.15 is a set of graphs on v vertices with , with 100, and furthermore every H ∈ H v d(cid:48) ≥ (λv)c·λv, H v for a constant c > 69 and every pair of distinct H, H (cid:48) ∈ H v d(cid:48) do not intersect on any subgraphs J with E(J) ≥ (1 + 1 d(cid:48) has no non-trivial automorphisms, is strictly balanced, λ)V(J) − 2. 3 18Of course, one might hope that choosing the lengths of the edges randomly will also compensate for the asymmetry, regardless of the path lengths; we conjecture that this is the case but have not proven it as of yet. 43 Proof. Let H ∈ H(cid:48) or (k + 1)-path to a single edge). H Claim 4.17. H has no non-trivial automorphisms. (cid:48) , and let H3 be the corresponding 3-regular graph (given by shrinking every k -- has average degree d by construction. (cid:48) Proof. This follows from the fact that H3 has no non-trivial automorphisms; an automorphism of H corresponds to an automorphism of H3, as in an automorphism of H, every subdivided edge is (cid:3) mapped to a subdivided edge. 76]. Suppose that H ∈ H v Lemma 4.18. (Quantitative strict balance). Let d d(cid:48) (cid:48) is a graph on v vertices with average degree d , produced by Algorithm 4.15 by subdividing the edges of the 3-regular graph H3 into paths. Any subgraph J ⊂ H with (1 − θ)v vertices has density at most λ − 1 1 + 1 2 The proof of Lemma 4.18 is somewhat involved, and we prove it below after completing the (cid:48) = 2 + λ, with λ ∈ (0, 1 θλ. In particular, H is strictly balanced. 100 proof of the proposition. Finally, it remains to prove that many pairs H, H (cid:48) ∈ H do not overlap on dense subgraphs. (cid:48) (cid:48) with at most 100 vertices in H3 or H 3 , we already have that H3, H 109, then every distinct pair H, H (cid:48) 3, the density is bounded by 1. Claim 4.19. If λ < 11 d(cid:48) overlap on no subgraphs J with E(J) ≥ (1 + λ/4)V(J) − 2. Proof. First, we use Lemma 4.8 (and our construction of H3) to conclude that for any shared subgraph J of H, H 3 come from H λv (cid:48) Since H3, H with E(J3) ≥ 12 · 3V(J3) − 3. If H3, H 25 degree δ, then in H, H (cid:48) 3 do not overlap on any subgraph J3 (cid:48) 3 overlap on a subgraph J3 of size at least 101 with average δV(J3) · (k + 1) δV(J3) · k and again if we use that k > 3(1−λ) 2λ − 1, and that δ < 3 − 1 E(J) V(J) ≤ 1 + the corresponding subgraph J will have density at most E(J) V(J) ≤ 1 δ − 1 δ · k V(J3) + 1 50 we get that 1 2 1 + 1 2 ≤ 1 + < 1 + , λ 4 1 2 δ − 1 δ · ( 3(1−λ) 2λ − 1) 1 + 1 2 2 2 , (cid:48) ∈ H v whenever λ < 11 than 1, V(J) ≥ 100 · k ≥ 100( 3(1−λ) λ − 1) > 6 109. Since we have assumed that V(J3) ≥ 100 and that the density of J3 is larger λ, and we have that )V(J) − 2, E(J) < (1 + λ 3 as desired. (cid:3) Finally, we note that the size of H v 3 , from which we get our bound. (cid:3) We now prove that our graphs are strictly balanced; in fact we will need a quantitative version d(cid:48) is simply the size of H λv of this statement, which first requires the following supporting lemma. (cid:48) = 2 + λ, with 0 < λ ≤ 1 9. Suppose that H ∈ H v Lemma 4.20. Let d d(cid:48) is a graph on v vertices with average (cid:48) , produced by Algorithm 4.15 by subdividing the 3-regular graph H3 on λv vertices into k- and degree d (k + 1)-paths. Then any subgraph J ⊂ H containing at most (1 − θ)λv vertices of H3 (vertices of degree 3 in H) has density at most 1 + 1 2 θλ + 152 150 λ − 1 θλ2. 30 44 Proof. First, the following claim allows us to consider only J corresponding to full edge-induced J3 ⊂ H. Claim 4.21. Suppose that J is a subgraph of H with density at least 1, and that J contains only a proper subset of the edges an vertices which correspond to the subdivided path given by the edge e in H3. Then the subgraph J ⊂ J given by removing all vertices and edges from the path corresponding to e has larger density than J. Proof. The edge e is subdivided into a path. If J contains a strict sub-path, then it must contain a vertex of degree 1. In a graph of density at least 1, density can only increase when vertices of degree-1 are removed. Therefore, if we remove the degree-1 vertices one-by-one until we obtain J, (cid:3) we obtain a graph that can only be denser. By Claim 4.21, J is at its densest if every subdivided edge from H is either present or completely missing, thus we may restrict our attention to subgraphs J which correspond exactly to edge- induced subgraphs J3 of H3, with all subdivided edges fully present. Suppose that J3 has average degree δ. To obtain J, every edge of J3 is subdivided into a k- or (k + 1)-path; let the average path length among subdivided edges present in J be k. In H, by design the average path length is 2(1−λ) Claim 4.22. 3λ . From this, we can lower bound k as follows: (1 − θ). 2(1 − θ)λv − (cid:96)), where (cid:96) accounts Proof. By assumption, V(J3) = (1 − θ)λv. Suppose that E(J3) = ( 3 for edges missing from J3 entirely and also for edges with only one endpoint in V(J3). The total 2(1 − θ)λv − (cid:96))k. Therefore the total number of number of edges in subdivided paths in J is then ( 3 θλv + (cid:96))(k + 1). The total number of vertices edges along subdivided paths outside J is at most ( 3 participating in subdivided paths in H is (1 − λ)v, and from this we get 2 k ≥ 2(1 − λ) − θ −(cid:18) 1 − δ 3 3λ (cid:19) (cid:18)3 (1 − θ)λv − (cid:96) 2 and solving for k we get By definition of (cid:96) and δ, we have (cid:96) = 3−δ 2 (cid:18)3 θλv + (cid:96) (cid:19) · (k + 1) ≥ (1 − λ)v, (cid:19) · k + k ≥ 2(1 − λ) 2 (1 − θ)λv. Plugging this in, we have our bound. (cid:17) , δ(cid:16) 2(1−λ) 3λ − θ − (1 − θ)(1 − δ 3) δ − 1 1 2 δk 1 + 1 2 − θ − 2(cid:96) 3λv ≤ 1 + δ − 1 1 + 1 2 3λ 1 2 . (cid:3) (38) Then applying our lower bound on k from Claim 4.22, we have that E(J) V(J) ≤ 1 δV(J3)(k + 1) δV(J3)k V(J3) + 1 2 2 = 1 + where in the final inequality we apply our lower bound on k. Taking the derivative with respect to δ, one may verify that so long as λ < 1/7 and δ ≤ 3, this quantity grows with δ. We obtain an upper bound on δ using the expansion of H3, from Theorem 4.7. If θ < 1 2(3− θ· 3 2, we have that J3 can contain at most 1 2(3 − 3 25) ≥ 1 2, we 25)λv edges, since the set of size θλv not included in J3 has 25)(1− θ)λv edges, for 25)(1 − θ) for non-negative θ, we use the former, looser 2(3− 3 have that J3 can contain at most 1 θλv. If θ > 1 expansion at least 3 2(3 − θ 3 50 the same reason. Since 1 bound. 45 Returning to Eq. (38) we have that E(J) V(J) ≤ 1 + = 1 + 1 2 ≤ 1 + 1 2 = 1 + 1 2 ≤ 1 + 1 2 1 + 1 λ · 1 25 θ θ(cid:17) θ − 38 (cid:16) 2(1−λ) 25) − 1 2(3 − θ 3  2(3 − θ 3 3λ − θ − (1 − θ) 1 25) 1 − 3 (cid:19) ·(cid:18) λ ·(cid:18) (cid:18) 1 λθ2 − 3 1 − 1 λ ·(cid:18) 1 − 3 θ + 38 25 25 (cid:19) λ ·(cid:18) 1 − 1 θ2 − 254 625 15 1 − 1 15 25 λθ + 153 1250 1 + 4 3 25 λθ − 4 625 θ + 152 75 θ + 152 75 λθ θ 25 25 .  (cid:19)(cid:19) 1250 λθ3 λθ − 153 1250 λθ2 + 356 15625 λθ2 + 3 λθ3 1250 λθ3 − 6 15625 (cid:19) λθ4 Where to obtain the third line we have used that for θ ∈ [0, 1] and λ ≤ 1 the parentheses is at least 3 conclusion follows. 4, and in the last step we have used that θ ∈ [0, 1] and λ ≤ 1 9 the denominator within 9. The (cid:3) Finally, we prove Lemma 4.18. 100 λ − 1 θλ. In particular, H is strictly balanced. (cid:48) = 2 + λ, with λ ∈ (0, 1 76]. Suppose that H ∈ H v Lemma 4.18. (Quantitative strict balance). Let d d(cid:48) (cid:48) is a graph on v vertices with average degree d , produced by Algorithm 4.15 by subdividing the edges of the 3-regular graph H3 into paths. Any subgraph J ⊂ H with (1 − θ)v vertices has density at most 1 + 1 2 Proof. Here, we consider arbitrary edge-induced subgraphs J ⊆ H. We let J3 ⊆ H3 be the edge- induced subgraph of H3 which contains any edge for which the corresponding path in J is at least partially present. That is, we allow the subdivided path corresponding to each edge (cid:96) ∈ E(J3) to be only partially present in J. For an edge (cid:96) ∈ E(J3), we'll let and VJ((cid:96)), EJ((cid:96)) be the vertex set and edge set of the corresponding path in J, and define VH((cid:96)), EH((cid:96)) correspondingly for H; also define k((cid:96)) to be the path length of the path corresponding to (cid:96) in H. For a subgraph J ⊂ H where V(J) = (1 − θ)v, we consider two cases: and V(J3) ≥ (1 − 1 λ − 1 1 + 1 2 For the second case, the number of "path vertices" (vertices that result from subdividing edges θ)λv θ)λv. For the first case, by Lemma 4.20 we know the density is at most θλ2 ≤ 1 + 1 θλ when λ ≤ 1 76. V(J3) ≤ (1 − 1 θλ + 152 300 λ − 1 100 60 2 2 2 of H3) in J is at most θ)λv = (1 − λ)v − θv + 1 (# path vtcs ∈ J) ≤ (1 − θ)v − (1 − 1 2 2 Note that for each edge (cid:96) in J3 we have E((cid:96)) ≤ (1 + 1 k((cid:96))) · V((cid:96)). We can bound the average 1 using the following claim: Claim 4.23. Define k to be the average length of a subdivided path in J, as weighted by the number (cid:88) of vertices present in that path: k((cid:96)) in J θλv (39) (cid:80) 1 := 1 k VJ((cid:96)). If J contains at least a (1 − α)-fraction of the path vertices of H, then (1 + 27 16 (cid:96)∈E(J3) VJ((cid:96)) (1 − 27 16 2(1 − λ) 2(1 − λ) λα) ≤ 1 k 1 k((cid:96)) (cid:96)∈E(J3) 3λ 3λ ≤ λα). 46 Proof. Recall that VH((cid:96)) is the number of path vertices on path (cid:96) in H. Consider the sum(cid:80) k((cid:96)))VH((cid:96)); we have that 1 + 1 k((cid:96)) VH((cid:96)) = (1 − λ)v. VH((cid:96)) = E(H) = (cid:88) (cid:88) (cid:32) (cid:33) (cid:18) (cid:19) v, 1 (cid:96)∈E(H3) (cid:96)∈E(H3)(1+ (cid:96)∈E(H3) Therefore We can split the sum over (cid:96) ∈ E(H3) into to the sum inside and outside of J. Because 1 k((cid:96)) outside of J can be lower bounded by 1 1 combination of have 1 k((cid:96)) k , the average of (cid:96)∈E(H3) VH\J((cid:96)) k+1 and 1 1 (cid:80) 1 k((cid:96)) 3λ k is a convex k+1. Thus we = 2(1 − λ) , α 1 k + 1 + (1 − α) ≤ 1 k Which gives: 3λ 1 + 1 k((cid:96)) and λ (cid:80) 2 (cid:80) VH((cid:96)) (cid:96)∈E(H3) (cid:96)∈E(H3) VH((cid:96)) = VJ((cid:96)) +(cid:80) (cid:80) (cid:96)∈E(H3) (cid:96)∈E(H3) VH((cid:96)) 2(1 − λ) . ≤ 27 (1 + α k + 1 ). 1 2(1 − λ) k Now, since by construction k = (cid:98) 2(1−λ) 3λ (cid:99) and λ < 1 claim. 3λ ≤ λ gives us the (cid:3) Now in the extreme case when all of the vertices of H3 are included in J, J has at least (1−θ−λ)v 9, using the upper bound 1 k 16 θ. (cid:32) (cid:96)∈E(J3) (cid:96)∈E(J3) (cid:88) VJ((cid:96)) = 1 + 1 k((cid:96)) ≥ 1 − 9 8 path vertices. Thus, the proportion of path vertices of H included in J, is at least EJ((cid:96)) ≤ (cid:88) 9. Thus we can apply Claim 4.23, with α := 9 8 # path vtcs ∈ V(J) # path vtcs ∈ V(H) (cid:33) assuming λ < 1 path vertices in J Eq. (39), and we have E(J) = ≤ 1 − λ − θ = 1 − θ 1 − λ 1 − λ (cid:32) (cid:33) (cid:88) θ, and our bound on the number of 1 + 1 (cid:32) k (cid:96)∈E(J3) (cid:32) 3λ 2(1 − λ) 1 + ≤(cid:18) 1 − λ − θ + 1 2 ≤(cid:18) λ − θ + 1 1 + 1 2 2 λ − θ − 5 1 + 1 2 2 Where to obtain the third line we have used that (1+ 243 (1−λ) we have used that (1 + λ)(1 − 1 (1 + 243 128 θλ + 3 2 λθ + 3λ2θ − 3θλ(1 − 1 2 1 − λ − θ + 1 θλ) 2 λ(1 + 2λθ) − θ(1 − 1 2 9, and to obtain the final line (cid:19) 3λ (1 − λ) v < 2 for λ < 1 λθ + 3λ2θ VJ((cid:96)) λ)(1 + λ) ·(cid:18) (cid:33) (cid:19) (cid:19) (cid:33) θλ λ) ≤ ≤ v, θλ v 128 θλ + 3λ2θ(cid:17) 2 λ) ≥ 1 for λ ≤ 1. Therefore the density is upper bounded by λ − λθ 2 − 3λ (1 − θ) λ(1 − θ) − 2λθ + 3λ2θ (1 − θ) + 1 = 1 + 1 2 1 − θ 3. Combine the above two cases we get the (cid:3) λ − λθ when λ ≤ 1 = 2 , ≤ E(J) V(J) 1 + 1 2 λ − θ − 5 (1 − θ)v 2 and this quantity is at most 1 + 1 2 lemma. (cid:16) v 47 Discussion and open problems We have shown the first (nearly) efficient algorithms for the graph matching problem on correlated Erdos-R´enyi graphs in a wide range of parameters. However, our results can still be improved in several ways. First of all, for the actual recovery task, we obtain only quasipolynomial as opposed to polynomial time algorithms. Second, even for distinguishing, our algorithms still don't work in all regimes of parameters, and there are still some annoying "gaps" in our coverage. Resolving both these problems would be extremely interesting. One approach to give a more general and robust method can be to embed our algorithms in a convex program such as the sum-of-squares semidefinite program. One advantage of this program is that while its analysis might need to use the existence of a test set, the actual algorithm will be independent of it, and would be identical in all ranges of parameters, and independent of the correlated Erdos-R´enyi model. This suggests that it could generalize to more settings, and perhaps also help bridge the gap between distinguishing and recovery. Another question is whether our algorithms can inform in any way practical heuristics for the graph matching problem. One of the most common heuristics is the propagation graph matching (PGM) algorithm that gradually grows knowledge of the permutation from a "seed set" by looking at vertices that have at least r neighbors into this set. From our perspective, this can be thought of as an algorithm that looks for a particular subgraph H which is the "star graph" with one internal vertex and r leaves. Our results suggest that it might be possible to get some mileage from looking at more complicated patterns and more than one pattern. Acknowledgements Boaz Barak is grateful to Negar Kiyavash for telling him about the graph matching problem, and the results of [CK16, CK17] during a very enjoyable and useful visit to EPFL in the summer of 2017. Tselil Schramm thanks Sam Hopkins for valuable and vigorous discussions which helped guide the exposition. We all thank anonymous STOC 2019 referee for pointing out some issues in the prior version of this paper. References [BBM05] Alexander C Berg, Tamara L Berg, and Jitendra Malik, Shape matching and object recog- nition using low distortion correspondences, Computer Vision and Pattern Recognition, 2005. CVPR 2005. IEEE Computer Society Conference on, vol. 1, IEEE, 2005, pp. 26 -- 33. [BC¸ PP99] Rainer E. Burkard, Eranda C¸ ela, Panos M. Pardalos, and Leonidas S. Pitsoulis, The quadratic assignment problem, pp. 1713 -- 1809, Springer US, Boston, MA, 1999. [Bol] [Bol81] [Bol88] B´ela Bollob´as, The asymptotic number of unlabelled regular graphs, Journal of the London Mathematical Society s2-26, no. 2, 201 -- 206. B´ela Bollob´as, Random graphs, Cambridge University Press, 1981, pp. 80 -- 102. B´ela Bollob´as, The isoperimetric number of random regular graphs, European Journal of Combinatorics 9 (1988), no. 3, 241 -- 244. 48 [CFSV04] Donatello Conte, Pasquale Foggia, Carlo Sansone, and Mario Vento, Thirty years of graph matching in pattern recognition, International journal of pattern recognition and artificial intelligence 18 (2004), no. 03, 265 -- 298. [CK16] [CK17] [CL12] Daniel Cullina and Negar Kiyavash, Improved achievability and converse bounds for erdos- renyi graph matching, ACM SIGMETRICS Performance Evaluation Review, vol. 44, ACM, 2016, pp. 63 -- 72. , Exact alignment recovery for correlated erdos renyi graphs, arXiv preprint arXiv:1711.06783 (2017). Minsu Cho and Kyoung Mu Lee, Progressive graph matching: Making a move of graphs via probabilistic voting, Computer Vision and Pattern Recognition (CVPR), 2012 IEEE Conference on, IEEE, 2012, pp. 398 -- 405. [CSS07] Timothee Cour, Praveen Srinivasan, and Jianbo Shi, Balanced graph matching, Advances in Neural Information Processing Systems, 2007, pp. 313 -- 320. [DMCW84] B D. McKay and N C. Wormald, Automorphisms of random graphs with specified degrees, 325 -- 338. [HKP+17] [JLG+15] [JLR11] [JŁT+12] [KHG15] Samuel B Hopkins, Pravesh K Kothari, Aaron Potechin, Prasad Raghavendra, Tselil Schramm, and David Steurer, The power of sum-of-squares for detecting hidden structures, FOCS (2017). Shouling Ji, Weiqing Li, Neil Zhenqiang Gong, Prateek Mittal, and Raheem A Beyah, On your social network de-anonymizablity: Quantification and large scale evaluation with seed knowledge., NDSS, 2015. S. Janson, T. Luczak, and A. Rucinski, Random graphs, Wiley Series in Discrete Mathe- matics and Optimization, Wiley, 2011. Svante Janson, Tomasz Łuczak, Tatyana Turova, Thomas Vallier, et al., Bootstrap perco- lation on the random graph g {n, p}, The Annals of Applied Probability 22 (2012), no. 5, 1989 -- 2047. Ehsan Kazemi, S Hamed Hassani, and Matthias Grossglauser, Growing a graph match- ing from a handful of seeds, Proceedings of the VLDB Endowment 8 (2015), no. 10, 1010 -- 1021. [KL14] Nitish Korula and Silvio Lattanzi, An efficient reconciliation algorithm for social networks, Proceedings of the VLDB Endowment 7 (2014), no. 5, 377 -- 388. [KSV02] Jeong Han Kim, Benny Sudakov, and Van H Vu, On the asymmetry of random regular graphs and random graphs, Random Structures & Algorithms 21 (2002), no. 3-4, 216 -- 224. [LAV+14] Vince Lyzinski, Sancar Adali, Joshua T Vogelstein, Youngser Park, and Carey E Priebe, Seeded graph matching via joint optimization of fidelity and commensurability, arXiv preprint arXiv:1401.3813 (2014). [Law63] Eugene L Lawler, The quadratic assignment problem, Management science 9 (1963), no. 4, 586 -- 599. 49 [LFF+16] [LFP14] [LR13] [Luc89] [MW84] [MW90] [MX18] [NS09] V. Lyzinski, D. E. Fishkind, M. Fiori, J. T. Vogelstein, C. E. Priebe, and G. Sapiro, Graph matching: Relax at your own risk, IEEE Transactions on Pattern Analysis and Machine Intelligence 38 (2016), no. 1, 60 -- 73. Vince Lyzinski, Donniell E Fishkind, and Carey E Priebe, Seeded graph matching for correlated erdos-r´enyi graphs., Journal of Machine Learning Research 15 (2014), no. 1, 3513 -- 3540. Lorenzo Livi and Antonello Rizzi, The graph matching problem, Pattern Analysis and Applications 16 (2013), no. 3, 253 -- 283. Tomasz Luczak, Sparse random graphs with a given degree sequence, Proceedings of the Symposium on Random Graphs, Poznan, 1989, pp. 165 -- 182. B. D. McKay and N. C. Wormald, Automorphisms of random graphs with specified vertices, Combinatorica 4 (1984), no. 4, 325 -- 338. Brendan D. McKay and Nicholas C. Wormald, Asymptotic enumeration by degree se- quence of graphs of high degree, European Journal of Combinatorics 11 (1990), no. 6, 565 -- 580. Elchanan Mossel and Jiaming Xu, Seeded graph matching via large neighborhood statistics, arXiv preprint arXiv:1807.10262 (2018). Arvind Narayanan and Vitaly Shmatikov, De-anonymizing social networks, Security and Privacy, 2009 30th IEEE Symposium on, IEEE, 2009, pp. 173 -- 187. [OWWZ14] Ryan O'Donnell, John Wright, Chenggang Wu, and Yuan Zhou, Hardness of robust graph isomorphism, lasserre gaps, and asymmetry of random graphs, Proceedings of the twenty-fifth annual ACM-SIAM symposium on Discrete algorithms, SIAM, 2014, pp. 1659 -- 1677. [PG11] [SXB08] [VCP+11] [Wor] [Wor80] [YG13] Pedram Pedarsani and Matthias Grossglauser, On the privacy of anonymized networks, Proceedings of the 17th ACM SIGKDD international conference on Knowledge dis- covery and data mining, ACM, 2011, pp. 1235 -- 1243. Rohit Singh, Jinbo Xu, and Bonnie Berger, Global alignment of multiple protein interaction networks with application to functional orthology detection, Proceedings of the National Academy of Sciences 105 (2008), no. 35, 12763 -- 12768. Joshua T Vogelstein, John M Conroy, Louis J Podrazik, Steven G Kratzer, Eric T Harley, Donniell E Fishkind, R Jacob Vogelstein, and Carey E Priebe, Large (brain) graph matching via fast approximate quadratic programming, arXiv preprint arXiv:1112.5507 (2011). Nicholas C Wormald, Models of random regular graphs. , Some problems in the enumeration of labelled graphs, Bulletin of the Australian Mathematical Society 21 (1980), no. 1, 159 -- 160. Lyudmila Yartseva and Matthias Grossglauser, On the performance of percolation graph matching, Proceedings of the first ACM conference on Online social networks, ACM, 2013, pp. 119 -- 130. 50
1911.11354
1
1911
2019-11-26T05:54:43
Finding Route Hotspots in Large Labeled Networks
[ "cs.DS" ]
In many advanced network analysis applications, like social networks, e-commerce, and network security, hotspots are generally considered as a group of vertices that are tightly connected owing to the similar characteristics, such as common habits and location proximity. In this paper, we investigate the formation of hotspots from an alternative perspective that considers the routes along the network paths as the auxiliary information, and attempt to find the route hotspots in large labeled networks. A route hotspot is a cohesive subgraph that is covered by a set of routes, and these routes correspond to the same sequential pattern consisting of vertices' labels. To the best of our knowledge, the problem of Finding Route Hotspots in Large Labeled Networks has not been tackled in the literature. However, it is challenging as counting the number of hotspots in a network is #P-hard. Inspired by the observation that the sizes of hotspots decrease with the increasing lengths of patterns, we prove several anti-monotonicity properties of hotspots, and then develop a scalable algorithm called FastRH that can use these properties to effectively prune the patterns that cannot form any hotspots. In addition, to avoid the duplicate computation overhead, we judiciously design an effective index structure called RH-Index for storing the hotspot and pattern information collectively, which also enables incremental updating and efficient query processing. Our experimental results on real-world datasets clearly demonstrate the effectiveness and scalability of our proposed methods.
cs.DS
cs
Finding Route Hotspots in Large Labeled Networks Mingtao Lei†, Xi Zhang†∗, Lingyang Chu‡, Zhefeng Wang§, Philip S. Yu(cid:107), Binxing Fang† †Key Laboratory of Trustworthy Distributed Computing and Service (BUPT), Ministry of Education, Beijing University of Posts and Telecommunications, Beijing, China ‡Huawei Technologies Canada, Burnaby, Canada. §Huawei Technologies, Hangzhou, China {leimingtao, zhangx, fangbx}@bupt.edu.cn, [email protected], [email protected], [email protected] (cid:107)Department of Computer Science, University of Illinois at Chicago, IL, USA 9 1 0 2 v o N 6 2 ] S D . s c [ 1 v 4 5 3 1 1 . 1 1 9 1 : v i X r a Abstract -- In many advanced network analysis applications, like social networks, e-commerce, and network security, hotspots are generally considered as a group of vertices that are tightly connected owing to the similar characteristics, such as common habits and location proximity. In this paper, we investigate the formation of hotspots from an alternative perspective that considers the routes along the network paths as the auxiliary information, and attempt to find the route hotspots in large labeled networks. A route hotspot is a cohesive subgraph that is covered by a set of routes, and these routes correspond to the same sequential pattern consisting of vertices' labels. To the best of our knowledge, the problem of Finding Route Hotspots in Large Labeled Networks has not been tackled in the literature. However, it is challenging as counting the number of hotspots in a network is #P-hard. Inspired by the observation that the sizes of hotspots decrease with the increasing lengths of patterns, we prove several anti-monotonicity properties of hotspots, and then develop a scalable algorithm called FastRH that can use these properties to effectively prune the patterns that cannot form any hotspots. In addition, to avoid the duplicate computation overhead, we judiciously design an effective index structure called RH-Index for storing the hotspot and pattern information collectively, which also enables incremental updating and efficient query processing. Our experimental results on real-world datasets clearly demonstrate the effectiveness and scalability of our proposed methods. Index Terms -- Graphs, sequential pattern, community detec- tion, indexing I. INTRODUCTION Finding communities from real-world networks has gained significant interests, which enjoys various applications involv- ing social networks, e-commerce, and network security. Con- ventional community detection methods detect communities as groups of vertices that are densely interconnected, which focus on the graph structures of communities. More often than not, besides the topology information, the valuable co-occurrence information [1] and route information [2] may also help to find meaningful communities. The route on the graph, which is a sequence of consecutive edges, is a natural descriptive model for many real-world net- works. The route defined here is similar to that defined in [3], which is also a sequence of edges and the consecutive edges must share a vertex. Examples in network security are shown in Figure 1, where each vertex corresponds to a tuple contain- ing an IP address, a port and a specific vulnerability. And each ∗Corresponding author. (a) (b) Fig. 1. Two examples of network security, where each vertex corresponds to a tuple containing an IP address, a port and a specific vulnerability. The colored arrow lines on edges represent routes, where a route is a sequence of consecutive edges, incidenting a chain of attacks. Fig. 1(a) shows that the vulnerabilities Web Trojan and PHP hackers frequently first exploit Code Execution, and then exploit the vulnerability SQL Injection. Fig. 1(b) indicates that hackers frequently first exploit the vulnerability PHP Code Execution on specific systems, then exploit the same kind of vulnerability (i.e., PHP Code Execution) on some other systems, and further exploit the vulnerability Sensitive Information Sniffing. These two examples show two types of successful attacking paths in network security. edge indicates that the two connected systems are incident in the network. Hackers may find a sequence of exploits (i.e., a route) along the network path that can enable a successful attack. For example, the routes marked by the colored arrow lines indicate that some hackers frequently first exploit the vulnerabilities Web Trojan and PHP Code Execution, and then exploit the vulnerability SQL Injection (Fig. 1(a)), while some other hackers frequently first exploit the vulnerability PHP Code Execution on some specific systems, then exploit the same kind of vulnerability (i.e., PHP Code Execution) on other systems, and further exploit the vulnerability Sensitive Information Sniffing (Fig. 1(b)). Another example lies in the anti-money laundering analysis [4], where each vertex is a user of a bank and an edge represents their money transfer relationship. Here a route can denote a sequence of transfer behaviours among a set of users. The routes may also exist in the collaboration networks, such as DBLP [5], where each vertex is an author and an edge represents their collaboration relationship. In addition to collaboration relationships, we also consider the authors' citation relationships to build the citation sequence that is used as the route. Specifically, for every two WebTrojan172.91.0.134:8081PHPCodeExecution172.91.0.153:8082PHPCodeExecution172.91.0.112:8080>mnInjection172.91.0.40:88PHPCodeExecution172.91.0.53:8080PHPCodeExecution172.91.0.51:8080PHPCodeExecution172.91.0.112:8080PHPCodeExecution172.91.0.47:8080SensitiveInformationSnifring172.91.0.93:8081 k-truss [7]. But these dense subgraphs cannot be adopted to model route hotspots as they mainly focus on the graph struc- tures but ignore how routes perform. To better introduce the model, we give a more specific example of network security in Figure 2, where each vertex in the graph corresponds to a system vulnerability and is labeled as its type, such as DB (the database), WS (the website system), MS (the management system) and PS (the portal system). The induced subgraph of {v4, v7, v8, v9, v10} is a 4-truss. However, there are no routes traversing the edges (v7, v8), (v8, v9) and (v8, v10) in this subgraph. A coverage relationship that requires the subgraph is covered by a group of routes may make more sense. On the other hand, there also exist some concepts with the goal of discovering a group of routes that move together, such as convoy [8] and trajectory gathering pattern [9]. These concepts can be distinguished based on how the "group" is defined. However, using such group patterns to model route hotspots is limited by the following two issues. First, although these approaches are able to identify a group of objects moving together, they only consider spatial proximity for clustering a group of objects rather than more refined and meaning- ful interconnection relationships between pair-wised objects. Moreover, the group of objects they find may not be densely interconnected and thus are not suitable for our problem settings. For example, as shown in Figure 2, the subgraph of {v1, v2, v3, v4, v5} is obtained by spatial clustering and is covered by {T1,T2,T4}, but it is not a dense structure. Second, the output of these approaches may be varied by using different distance measures to obtain clustering results. In contrast, our proposal working with k-truss to indicate dense groups is independent of distance measures. With the insights given above, we regard a route hotspot as a cohesive subgraph covered by a set of routes containing the same sequential pattern. An appropriate model of route hotspot should possess the following key attributes. 1) (Cohesiveness) The value of the cohesiveness function that measures the structure of route hotspot is high. 2) (Participation) The route hotspot should contain at least min sup subroutes (a subroute is one of the consecutive portions of the full route). 3) (Coverage) These subroutes contained by the route hotspot can cover the route hotspot. 4) (Correlation) Each route contained in the route hotspot should contain the same sequential pattern. The cohesiveness condition is straightforward as hotspots are supposed to be dense subgraphs. Here we use k-truss as it has a stronger guarantee on cohesive structure than k-core. Furthermore, computing k-truss subgraphs takes low computa- tional cost, that is, polynomial time [7]. The participation and coverage conditions are also straightforward as the hotspot is defined on the graph and route set. The correlation condition shows that, in the route hotspot, routes should contain the same sequential pattern, which is a sequence of consecutive labels, and thus we can mark the hotspot by this pattern. As shown in Figure 2, let k = 3 and min sup = 3. The induced Fig. 2. An example network, where each vertex corresponds to a specific label, including DB, WS, MS and PS respectively. The colored arrow lines on edges represent routes, where a route T is a sequence of consecutive edges. The dashed ellipse represents a route hotspot (i.e., the induced subgraph H of {v4, v6, v7, v9}) that can be marked by the sequential pattern (cid:104)P S, M S, DB(cid:105), which is covered by qualified routes that form this hotspot. consecutive collaborative authors A and B in the route, B should have cited a paper published by A. Such routes can indicate the trends of their research interests. Informally, given a graph as well as routes on it, it is interesting to discover dense components which are covered by groups of routes that share the same patterns implying common behaviours. In the examples of network security that are shown in Figure 1, the detection of these components can facilitate in both identifying the security vulnerable areas in the networks and extracting the features of hacker behaviours, and these features can be used for hacker identification. In the example of the anti-money laundering analysis, the frequent money transfer behaviours among a specific group of users could be suspicious, and the detection of such users may indicate money laundering. In the third example given above, the detection can discover groups of closely cooperated scholars who hold the same continuous research interests in the collaboration networks. We call such dense components route hotspots and aim to discover the route hotspots in an efficient manner. We can also understand the route hotspots detection problem from the perspective of the patterns. It would also be interest- ing to find the same patterns that are shared by a specific dense component. Although a few previous studies have attempted to mine frequent patterns from a large graph, a pattern that is frequent in the whole graph is not necessarily frequent in a dense component of the graph. Thus, the detection of route hotspots can also help to find meaningful patterns regarding to a specific component of the graph. However, effectively finding route hotspots in large labeled networks is a non-trivial problem. It is challenging on how to define the route hotspot appropriately and how to develop an efficient solution for route hotspot finding. A. Challenge 1: Suitable Model We first review some related models defined in the previous work and then conclude the key attributes that are required to be possessed by our model. On one hand, various community models have been pro- posed to describe dense subgraphs, such as k-core [6] and 𝑣"𝑣#𝑣$𝑣"%𝑣&𝐷𝐵𝑣)𝑊𝑆𝑃𝑆𝑊𝑆𝑀𝑆𝑀𝑆𝐷𝐵𝐷𝐵𝑀𝑆𝑣.𝑣/𝑣0𝑣1𝑃𝑆𝒯"𝒯#𝒯)𝒯&𝒯.𝒯/𝒯0𝒯1 subgraph H of {v4, v6, v7, v9} is a 4-truss, which contains T5, T6, T7 and one portion of T8, where each route contain the same sequential pattern (cid:104)P S, M S(cid:105) and these routes can cover H. Therefore, H is a route hotspot for k = 3 and pattern (cid:104)P S, M S(cid:105). We will give more formal definitions in Section III. B. Challenge 2: Efficient Detection Algorithm It is natural to ask whether we can apply or extend the existing algorithms for sequential pattern mining, commu- nity detection, or group pattern discovery to discover route hotspots? Unfortunately, the answer is no due to the following challenges. First, the conventional sequential pattern mining methods, like PrefixSpan [10], can only find the patterns that exist in the routes and describe how patterns are located on the graph. They don't consider dense graph structures. Second, the routes may contain an exponential number of patterns. Since the conventional community detection meth- ods, such as BULK [11], can only detect route hotspots of one pattern at a time, it is computationally intractable to use those methods for each of the exponential number of patterns. Third, the group pattern discovery methods, like CuTS [8], are not designed to process network topology information and thus the group of vertices they detect may not be densely connected from the perspective of the graph structure such as k-truss. Last but not least, it is of practical importance to provide a fast query service to answer user queries for interesting route hotspots in real time. As the number of route hotspots is usually huge in a large labeled network, enumerating and indexing all of them efficiently is extremely challenging. To tackle these challenges, we make the following contri- butions in this work. First, to the best of our knowledge, we are the first to detect the route hotspots in the large labeled networks. We prove that counting the number of route hotspots is #P-hard and propose to solve the problem by exploring the graph structure and sequential patterns simultaneously. Second, to reduce the computational cost of the straight- forward greedy algorithms, we first prove the pattern anti- monotonicity and the hotspot anti-monotonicity properties on route hotspots, and then develop an efficient algorithm called FastRH via applying these properties. FastRH can also be parallelized since the detection procedure for different patterns is independent, and thus can be speeded up. Third, to store the huge number of decomposed route hotspots, we design a tree index structure called RH-Index, which can efficiently index more than 8.2 × 105 hotspots for 6.7 × 105 patterns by using 2.3 hours and 39.9 GB main memory on a commodity PC with a large main memory as shown in Section VII on CN dataset. We also develop an efficient querying method that takes only 0.12 seconds on average for each query pattern. Fourth, we report an extensive experimental study on real- world datasets. The results clearly show that our method is accurate, efficient and scalable in finding and indexing route hotspots. The rest of the paper is organized as follows. We review the related work in Section II and formulate the problem in Section III. In Section IV and V, we present the greedy algo- rithm and the improved solution. The route hotspot indexing is introduced in Section VI. We report the evaluation results in Section VII, and conclude the paper in Section VIII. II. RELATED WORK In this section, we review the related work, which can be categorized into sequential pattern mining, k-truss based community detection and group pattern discovery in spatial- temporal data. A. Sequential pattern mining Sequential pattern mining, which is first introduced by Agrawal and Srikant in [12], is a well-studied topic in data mining. Given a set of sequences, the algorithms of sequential pattern mining, like FreeSpan [13] and PrefixSpan [10], are proposed to find all frequent subsequences. To deal with the large scale of data, approximated methods [14], [15] and distributed methods [16], [17] are proposed. Riondato et al. [18] apply Vapnik-Chervonenkis (VC) dimen- sion to provide tight bounds on the sample size, which is linearly dependent on the VC-dimension of a range space associated with the dataset to be mined. Progressive sampling methods [15] start from small samples and then increment the sampling sizes gradually until meeting the stopping conditions or hitting the upper bound. Li et al. [16] parallelize the FP- Growth on distributed machines in order to reduce memory use and computational cost. Ge et al. [17] develop a memory- efficient distributed dynamic programming approach to mine probabilistic frequent sequential patterns. A comprehensive review for this topic can be found in [19]. However, these approaches are not designed for graph data, and thus cannot be adopted for our problem. B. k-truss based community detection As there are various definitions on communities, here we mainly focus on the previous studies that are related to k- truss. Recently, Zhang et al. [20] propose to find interesting (k, r)-cores, where each vertex in a (k, r)-core connects to at least k other vertices and the similarity between any two vertices of the (k, r)-core is bounded by a similarity threshold r. However, a connected k-core is not guaranteed to be 2-edge- connected, while k-truss is more rigorous than k-core owing to its triangle-based definition. Thus, k-truss based community models are proposed. Huang et al. [21] propose to search k-truss communities in large-scale networks. To support the efficient search of k-truss communities, index, which can be updated incrementally under a dynamic graph setting. They also extend the k-truss community detection models to probabilistic graphs [22] and attributed graphs [11]. In particular, for probabilistic graphs, to meet the requirements they design a compact TABLE I FREQUENTLY USED NOTATIONS. Notation G(V, E, la) Π D, Dp min sup T , t s p Hp(k) np Lp, Tp, Ep Description The labeled undirected graph. The union of labels in G. The route set and the subset of Dp, where each route contains p. The user defined positive integer parameter. The route and the subroute of T . The sequence. The sequential pattern. The route hotspot with fixed p and k. The node of RH-Index for pattern p. The linked item, routes, and edges of np. in real-world networks, they propose the notion of (k, γ)- truss, where the probability of each edge contained in at least (k − 2) triangles is at least γ. For attributed graphs, motivated by balancing the attribute homogeneity and coverage, they propose the attributed truss community model and define the (k, d)-truss. The proposed (k, d)-truss is a connected k-truss containing all query nodes and each node of the (k, d)-truss has a distance no larger than d from every query node. Such models are proven to be effective in retrieving meaningful communities in probabilistic graphs and attributed graphs. In contrast to previous studies, our hotspot is uniquely iden- tified by a pattern, which is not touched by the above methods. Thus, these methods cannot be applied straightforwardly to detect route hotspots. C. Group pattern discovery in spatio-temporal data Discovering groups of objects that travel together in spatio- temporal data is called group pattern discovery [9] and has enjoyed many applications, such as movement behaviour anal- ysis [2]. Vieira et al. [23] propose to discover flocks, where a flock is a group of objects that travel together within a disc of some user-specified size for at least k consecutive timestamps. To deal with the so-called lossy-flock problem, the notion of convoy [8] is proposed, where the convoy is defined to have multiple objects that are densely connected with respect to a specific distance during k consecutive time points. Subsequently, to describe the common behaviours in dense groups, the trajectory gathering pattern [9] is proposed, where a gathering is regarded as a dense and continuing group of individuals. Zhang et al. [24] propose GMOVE, to model human mobility from massive geo-tagged social media, by grouping the users that share similar moving behaviors. However, these methods only consider spatial proximity for clustering a group of objects rather than more refined and meaningful interconnection relationships between paired objects. Thus there is no straightforward way to apply these methods on route hotspots detection. III. PROBLEM FORMULATION In this section, we first define route hotspot, and then introduce the route hotspot finding problem. A. Graph and k-truss We consider an undirected graph G = (V, E, la), where (1) V is a finite set of vertices, (2) E = {(u, v) u, v ∈ V } ⊆ T1 = (1,(cid:104)(v1, v2), (v2, v5)(cid:105)) T2 = (2,(cid:104)(v1, v3), (v3, v5)(cid:105)) T3 = (3,(cid:104)(v1, v4), (v4, v7), (v7, v9)(cid:105)) T4 = (4,(cid:104)(v1, v4), (v4, v5)(cid:105)) T5 = (5,(cid:104)(v6, v4), (v4, v6)(cid:105)) T6 = (6,(cid:104)(v6, v7), (v7, v9)(cid:105)) T7 = (7,(cid:104)(v6, v7), (v7, v4), (v4, v9)(cid:105)) T8 = (8,(cid:104)(v6, v7), (v7, v10)(cid:105)) Fig. 3. A route set D of Figure 2, where T1 is a route with tid = 1, and (cid:104)P S, W S, DB(cid:105) is a sequence induced by T1. V × V is a set of edges; (3) la is a labeling function that maps each vertex v to the unique label Lv = la(v) in Π. Π denotes the set of labels. We denote the set of neighbors of v as N (v), i.e., N (v) = {u ∈ V (v, u) ∈ E}. The degree of v is denoted by d(v) = N (v). A triangle in G is a cycle of length 3. We denote a triangle as (cid:52)uvw, where u, v, w ∈ V are the three vertices on the cycle. The support of an edge e(u, v), denoted by sup(e, G), is defined as {(cid:52)uvw : w ∈ V }. We denote e ∈ (cid:52), if e is an edge of (cid:52). A k-truss H(VH , EH ) is a subgraph of G, such that ∀e ∈ EH , sup(e, H) ≥ (k−2). H is said to be a maximal k-truss, if there does not exist another k-truss that can contain it. B. Route on Graph A subroute t of T , denoted by t T , Let es = (cid:104)e1, . . . , eh−1(cid:105) be a sequence of edges, where ei = e(vi, vi+1) ∈ E (1 ≤ i < h). A route is a tuple T = (tid, es), where tid is a unique route-id. We say that e(vi, vi+1) is contained by T , denoted by e(vi, vi+1) ∈ T . A route set D is a set of routes, and D denotes the number of routes. The length of the route is h − 1, the number of edges. ∈ is the consecutive portions of T . For example, one of (cid:104)(v1, v2), (v2, v3)(cid:105) and (cid:104)(v2, v3), (v3, v4)(cid:105) are subroutes of (cid:104)(v1, v2), (v2, v3), (v3, v4)(cid:105). Given a subgraph H = (VH , EH ) of G, T is said to be route containment with H, denoted by T ∈ H, if ∀e(u, v) ∈ T , such that e ∈ EH. For example, given the subgraph H of G in Figure 2, where H is a vertex-induced subgraph induced by {v4, v6, v7, v9}, T7 in Figure 3 is route containment with H as each edge in T is an edge of H. Similarly, the subroute (cid:104)(v6, v7), (v7, v4)(cid:105) of T7 is also route containment with H. D is said to be route set containment with H, if ∀T ∈ D, such that T ∈ H, denoted by D (cid:98) H. For example, given H1 = (VH1, EH1) induced from {v1, v2, v3, v5} in Figure 2 and {T1,T2} in Figure 3, H1 contains not only the individual routes T1, T2, but also their route set {T1,T2}. D is said to cover H, denoted by H (cid:0) D, if each edge of H exists in at least one route of D. Note that if D covers H, H must contain the route set D, but not vice versa. Continued with the above example, H is covered by {T1,T2}, but neither T1 nor T2 can cover H on its own. C. Sequence and Pattern We are interested in sequential patterns carried by routes in D. Formally, a sequence s = (cid:104)L1, . . . , Lh(cid:105) is a sequence of labels, which is induced by T , where Li = Lvi for 1 ≤ i ≤ h. Li is called the i-th item of s. The length of s is len(s) = h. A sequence p = (cid:104)A1, . . . , Al(cid:105) is called a subsequence of s and s is called a supersequence of p, denoted as p (cid:118) s, if there exists a sequence of consecutive integers 1 ≤ B1 < B2 < . . . < Bl ≤ h such that A1 = LB1, A2 = LB2 , . . . , Al = LBl. A route T is said to contain p, if s is induced by T and p (cid:118) s, which is denoted as p ≺ T for simplicity. p is said to be a l-pattern, if len(p) = l. The support of a sequence p in D is the number of routes containing p, i.e., fD(p) = {T p ≺ T ∧ T ∈ D}. Given a positive integer min sup as the sequence support threhold, a sequence p is called a sequential pattern in D if fD(p) ≥ min sup. Now we give an example to explain the concepts, including the graph, the route, the sequence and the pattern. Example 1 (Concepts): Figure 2 and Figure 3 show a tiny graph and a set of routes. The graph G has 10 vertices {v1, . . . , v10}, 17 edges and Π = {P S, W S, M S, DB}. The route set D = {T1, . . . ,T8}. We can always find a sequence supporting a route. For example, s1 = (cid:104)P S, W S, DB(cid:105) is induced by T1. Given min sup = 3, there are 4 frequent sequential patterns, whose lengths are greater than or equal to 2. The patterns are (cid:104)P S, M S(cid:105), (cid:104)P S, M S, DB(cid:105), (cid:104)P S, DB(cid:105) and (cid:104)M S, DB(cid:105). Suppose that H2 is a subgraph induced by {v4, v6, v7, v8, v9, v10}, and it's obvious that H2 is a 3-truss and is maximal. D. Route Hotspot With the commonly accepted desiderata of a good route hotspot described in Section I, we now give a precise definition of route hotspot. Definition 1 (Route Hotspot): Given a graph G, a set of routes D, a pattern p, two parameters k and min sup, Hp(k) (denoted as H for short) is a route hotspot, if H satisfies the following conditions: 1) H is a k-truss and is connected. 2) H contains at least min sup subroutes of routes in D, where each subroute t contains the same pattern p. Formally, ∃Dp = {t ∈ T p ≺ t ∧ T ∈ D} and fDp (p) ≥ min sup, such that Dp (cid:98) H. 3) Dp can cover H and the length of each subroute t in Dp should be as long as possible. Formally, H (cid:0) Dp. 4) H is a maximal subgraph satisfying conditions (1), (2) and (3). That is, (cid:64)H(cid:48) ⊆ G, such that H ⊂ H(cid:48), and H(cid:48) satisfies conditions (1), (2) and (3). Note that we don't consider the patterns whose lengths are equal to 1 since it's trivial and meaningless. An example of route hotspot H for p = (cid:104)P S, M S(cid:105) and k = 3 is given in Section I.1, with the corresponding G in Figure 2, D in Figure 3 and min sup = 3 respectively. Note that a vertex whose label doesn't belong to the pattern may also appear in a hotspot, in order to act as a "bridge" between other vertices. Specifically, suppose p ≺ T , the length of T may be longer than the length of p and thus some vertices in T may be associated with labels that don't exist in p. For example, in Figure 3, T6 contains the pattern (cid:104)P S, M S(cid:105), but v9 ∈ T6 doesn't correspond to the label P S or M S. Nevertheless, v9 is still involved in the hotspot as it may be indispensable in a practical network, e.g., it may act as a starting point or an endpoint of an attack sequence in the network security scenario. Moreover, longer routes are expected to cover route hotspots more easily than those with shorter lengths, and thus can help us find more hotspots. E. The FRHLN problem Hotspots in Large Labeled Networks (FRHLN) . Now we are ready to define the problem of Finding Route Definition 2 (FRHLN): Given a graph G, a route set D, a user-specific parameter min sup, the problem of finding route hotspots in large labeled networks is to enumerate all route hotspots Hp(k) for each p and k, where k ≥ 2, len(p) ≥ 2 and each Hp(k) contains at least min sup subroutes. route hotspots is #P-hard. We prove in Theorem 1 that counting the number of the Theorem 1 (Hardness): Given a graph G, a route set D and a user input threshold min sup, the problem of counting the number of route hotspots in G is #P-hard. Sketch: We prove this theorem by a reduction from the Sequential Pattern Mining (SPM) problem, which is known to be #P-hard [25]. Given an instance of the SPM problem, where the input is a sequence database S and a minimal support min sup, we are asked how many patterns p in S satisfy fS(p) ≥ min sup. Here, fS(p) is the number of unique sequences in S that contain p. We denote the union of the items (i.e., the labels of the vertices) in S as I, where the items follow an arbitrary fixed total order. Using S, we can construct a graph G and a route set D as follows. We assume that each item in I represents a vertex (say vi) in G and with a unique label (say Ii). Therefore, the number of vertices and labels in G are both I. To construct G, we add edges for every two vertices, and then every three vertices can form a triangle. For each sequence s in S, we build a route T with the following two steps. Step 1: since s is an ordered list of items, let T travel the edges with the order of items in s. For example, if s = (cid:104)I4, I2, I3(cid:105), T travels (v4, v2) and (v2, v3) sequentially. Step 2: let T travel all the other edges which are not visited in Step 1. Apparently, G is ensured to be covered by T . Then we obtain a route for each s, and put all these routes in D. This reduction step takes polynomial time. For any pattern p ⊂ S, since fS(p) ≥ min sup, at least min sup routes in D contain p. As G is a complete graph, according to our route hotspot definition, there must exist a route hotspot Hp(k) for a pattern p and a k, where k ranges from 2 to I − 1. Therefore, the number of route hotspots in G is I − 2 times the number of patterns in S, which is exactly the answer to the SPM problem. Consequentially, as SPM problem, the problem of counting the number of route hotspots in G is also #P-hard. The above theorem shows that finding a polynomial-time exact algorithm for computing the number of route hotspots in G is hard. Thus we need to look for pruning strategies to tackle the efficiency issue. Table I summarizes the frequently used notations for the rest of the paper. IV. THE GREEDY ROUTE HOTSPOT FINDING In this section, we first define the trussness of the subgraph, edge, and route, and then introduce the greedy route hotspot detection method. A. The Trussness of Subgraph, Edge and Route The definitions of the trussness of subgraph, edge, and route are listed as follows. Definition 3 (Subgraph Trussness [21]): The trussness of a subgraph H ⊆ G represents the minimum support of an edge in H, denoted by τ (H). For the purpose of unifying the notion of k-truss, we make τ (H) = min{sup(e, H)e ∈ E(H)} + 2. Thus, the trussness of a k-truss is equal to k. Definition 4 (Edge Trussness [21]): The trussness of an edge e ∈ E(H) is defined as τH (e) = maxH(cid:48)⊆H{τ (H(cid:48))e ∈ E(H(cid:48))}. Definition 5 (Route Trussness): The trussness of a route T ∈ H is the maximum trussness of the edge trussness, denoted by τH (T ) = max{τH (e)e ∈ T }. Consider the graph G in Figure 2 as an example. The trussness of G is τ (G) = 2. According to Definition 4, the trussness of an edge e is equal to the maximum value of the trussness for different subgraphs that contain e. For example, the subgraph H = (VH , EH ) contains the edge e(v4, v9), where VH = {v4, v6, v7, v8, v9, v10} and EH = {e(v4, v6), e(v4, v7), e(v4, v9), e(v6, v7), e(v6, v8), e(v7, v8), e(v7, v9), e(v7, v10), e(v8, v10)}. The trussness of H is 4, which is the largest value among that of subgraphs containing e(v4, v9). Thus, the trussness of the edges e(v4, v9) is 4. The trussness of the routes T1, T5 in Figure 3 are τG(T1) = 2, τG(T5) = 4. The above definitions can be leveraged to prune unqualified edges and routes. We say that, an edge or a route is unqualified if it cannot be used to form a route hotspot. We also say that, a pair of pattern p and k is unqualified if Hp(k) = ∅. For instance, for a route hotspot Hp(k), the support of each edge in Hp(k) must be greater than or equal to k. Thus, if τG(T ) < k, which indicates that the trussness of edges in T is less than k, T is thus unqualified for a route hotspot and can be pruned safely. We then propose Algorithm 1 to detect hotspots for a pair of inputs p and k. The general idea is that, we iteratively prune unqualified edges and routes based on the trussness informa- tion, and use the remaining edges to form the route hotspots. Specifically, let Hp(Vp, Ep) denote a subgraph induced by Dp. We first set up an empty queue Q to store unqualified edges (Line 1). We compute the support for each edge and put unqualified edges, whose supports are less than k− 2, into Q (Lines 2-3). For each e in Q, we decrement the supports of Remove e from T ; end for while ∃T ∈ Dp, such that e ∈ T do e(u, v) = Q.dequeue(); for Each w ∈ N (u) and (v, w) ∈ Ep do sup((u, w), Hp) ← sup((u, w), Hp) − 1; sup((v, w), Hp) ← sup((v, w), Hp) − 1; Algorithm 1: Hotspot Detection For p And k Input: Hp(Vp, Ep), Dp, min sup, p, k Output: A set of hotspots Φp(k) 1: Q ← ∅; 2: Compute sup(e, Hp) for each edge e ∈ Ep; 3: Push each e(u, v) into Q if sup(e, Hp) < (k − 2); 4: while Q (cid:54)= ∅ do 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: end while 22: if Ep (cid:54)= ∅ then 23: 24: 25: 26: end if 27: return Φp(k) end while while ∃T ∈ Dp, such that τHp (T ) < k ∨ p /∈ T do end while Remove e from Ep; while ∃e(cid:48) ∈ Ep, such that e(cid:48) /∈ any T in Dp do end while Push each e(cid:48) into Q if sup(e(cid:48), Hp) < (k − 2); Remove T from Dp; sup(e(cid:48), Hp) = 0; while ∃ a connected subgraph Hp(k) of Hp, such that Dp(k) (cid:98) Hp(k) and Dp(k) ≥ min sup do Φp(k) ← Φp(k) ∪ Hp(k); end while those related edges who can form triangles with e in Hp (Lines 6-9). Then e will be removed from the routes that contain e (Lines 10-12). Upon the removal of e, some routes may become unqualified and thus will be removed from Dp (Lines 13-15). After that, e is removed from Ep (Line 16). For each e(cid:48) ∈ Ep, if it is not contained in any T , the support of e(cid:48) will be set as zero (Lines 17-19). We then find all the edges that are unqualified again and put them into Q (Line 20). This process iterates until Q becomes empty. The remaining edges in Ep are used to form connected subgraphs. If the subgraph contains at least min sup routes that contain p, it would be a route hotspot and put into Φp(k) (Lines 22-26). Finally, Φp(k) is returned (Line 27). complexity of this enumeration is O((cid:80) The correctness of Algorithm 1 is apparent since the al- gorithm essentially detects hotspots by definition. The time complexity of Algorithm 1 is determined by the enumera- tion of all triangles for each edge in Hp(Vp, Ep). The time (d(vi) + d(vj))) = O(Vpd2 pmax), where Vp is the volume of Vp and dpmaxdenotes the maximum degree of the vertices in Vp. B. The Greedy Route Hotspot Detection (GreedyRH) (vi,vj )∈Ep Algorithm 1 can be used iteratively to find all route hotspots, but it requires all feasible patterns and feasible values of k as prior inputs. To obtain such inputs, we denote S = {s ≺ T T ∈ D} as a set of sequences, and denote P as a set of patterns mined from S with the support threshold min sup. We also denote kmax − truss as the maximum truss in G, indicating that (cid:64)H ∈ G, such that ∀e ∈ EH , sup(e, H) ≥ (kmax − 1). Observation 1: If there exists a route hotspot Hp(k), p must belong to P . for k = 2 → kmax do Algorithm 2: Greedy Hotspot Detection (GreedyRH) Input: Graph G, D, min sup, P , kmax Output: A set of hotspots Φ 1: for Each p ∈ P do 2: 3: 4: 5: 6: 7: end for 8: return Φ Initialize Dp based on D and induce Hp(Vp, Ep) based on Dp; Φp(k):= Call Algorithm 1 by using Hp, Dp, min sup, p, k as input; Φ ← Φ ∪ Φp(k); end for Observation 2: For each route hotspot Hp(k), k must be less than or equal to kmax. Observation 1 implies that P is a superset of qualified patterns. Observation 2 implies that kmax is the upper bound of the maximum value of k. Based on these observations, we propose Algorithm 2, called GreedyRH, that runs iteratively for each pattern p and each k (2 ≤ k ≤ kmax) and returns all route hotspots. P can be obtained by applying a sequential pattern mining method, like PrefixSpan [10]. And kmax can be obtained by applying a truss decomposition method, like [7]. The time complexity of GreedyRH is related to the number of patterns and kmax. We denote the maximal length of routes as hmax. Thus, the number of patterns is at most Πhmax. For each pattern, the Algorithm 1 will be performed for at most (kmax−1) times. Therefore, the time complexity of GreedyRH is O(Πhmax × (kmax − 1) × V × d2 max), where V is the volume of V and dmax denotes the maximum degree of the vertices in V . The greedy algorithm, i.e., GreedyRH, is correct due to the following reasons. First, it calls Algorithm 1 iteratively to find all route hotspots, where Algorithm 1 detects a specific route hotspot for a pair of inputs p and k by definition. Second, according to Observations 1 and 2, we can obtain all the patterns and the maximum value of k. Thus, GreedyRH can find all qualified route hotspots for all the patterns and all possible values of k, ensuring the correctness of this method. However, running GreedyRH is impractical. We then analyze the unnecessary computational overhead. 1) Not every k-truss can form a hotspot: The upper bound kmax for k may be too loose. When increasing k, some edges may be removed from G and the remaining part may not be covered by at least min sup routes. Thus, checking every k becomes unnecessary. 2) Not every pattern is frequent in a k-truss: In a k- truss of G, the number of routes containing the same p may be less than min sup. Thus, checking unfrequent patterns in k-trusses also becomes unnecessary. To overcome these drawbacks, we develop an improved algorithm and describe it precisely in the next section. V. THE NOVEL ROUTE HOTSPOT FINDING In this section, we first prove the anti-monotonicity and independence properties that can be used to avoid unnecessary checking. With these properties, we then propose a novel efficient finding method. A. Anti-Monotonicity And Independence Properties Theorem 2 (Pattern Anti-monotonicity on Hotspots): For patterns p1, p2, where p1 ≥ 2 and p1 (cid:118) p2, and a fixed k, where k ≥ 2, the following two properties hold. 1) If there exists a hotspot Hp2(k) (cid:54)= ∅, there must exist a 2) If Hp1 (k) = ∅, Hp2 (k) = ∅. hotspot Hp1(k) (cid:54)= ∅. Proof: Suppose that Hp2(k) = (Vp2(k), Ep2(k)) is a hotspot for p2. We build a subgraph Hp1 = (Vp1 , Ep1), where Vp1 = Vp2(k) and Ep1 = Ep2 (k). There must exist min sup routes, denoted by D(cid:48), containing p2. Since p1 (cid:118) p2, for ∀T ∈ D(cid:48), p1 ≺ T . Thus, D(cid:48) can also cover Hp1. For p1 and k, Hp1 and D(cid:48) satisfy the conditions (1), (2) and (3) of Definition 1, respectively. We just need to determine whether there exists a subgraph Hp1(k) (Hp1 ⊂ Hp1 (k)) satisfying condition (4) of Definition 1. As p1 (cid:118) p2, the size of Hp1 i.e., must be larger than or equal Hp2(k) ⊆ Hp1. Meanwhile, it is obvious that Hp1 ⊆ G. Thus, we can always find a maximal Hp1 (say Hp1(k)) which is exactly a route hotspot for p1 and k, where Hp1 ⊆ Hp1(k) and Hp1 (k) ⊆ G. The property 1 holds. to the size of Hp2(k), The second property is the contraposition of the first one, and thus it holds as well. Theorem 3 (Hotspot Anti-monotonicity with Patterns): For a pattern p and a fixed k (k > 2), if there exists a hotspot Hp(k), there must exist a hotspot Hp(k − 1). Proof: Suppose that Hp(k) = (Vp(k), Ep(k)) is a hotspot for p and k. We build a subgraph Hp = (Vp, Ep), where Vp = Vp(k) and Ep = Ep(k). Hp is a k-truss, where sup(e, H) ≥ (k − 1) ≥ (k − 2). Thus, Hp is also a (k − 1)-truss. Since Hp(k) is a route hotspot, there must exist min sup routes, denoted by D(cid:48), containing p. D(cid:48) can also cover Hp. For p and k − 1, Hp and D(cid:48) satisfy the conditions (1), (2) and (3) of Definition 1, respectively. We just need to determine whether Hp satisfies condition (4) of Definition 1, i.e., whether Hp is a maximal subgraph for p and (k − 1). However, the size of Hp is at least equal to the size of Hp(k). Similar to the proof for Theorem 2, there must exist a Hp satisfying condition (4) of Definition 1, which is exactly a hotspot Hp(k − 1) for p and (k − 1). The above two properties ensure that we can prune unquali- fied patterns and values of k efficiently and safely. Theorem 2 indicates how to prune unqualified edges for a new pattern based on existing patterns. For any pattern p1 and p2, if p1 (cid:118) p2 and p1 is unqualified, then p2 is also unqualified. Theorem 3 indicates how to prune unqualified edges for the same pattern with different values of k. For any p, if k is unqualified, then (k + 1) is also unqualified. We then give an example to show how the above two theorems work. Continued with Example 1, we consider min sup = 3. According to Theorem 2, (cid:104)W S(cid:105) cannot be grown to (cid:104)W S, DB(cid:105), since there are only 2 routes containing (cid:104)W S, DB(cid:105), which doesn't meet the condition of min sup. Then, there are no route hotspots for (cid:104)W S, DB(cid:105) or other patterns grown from (cid:104)W S, DB(cid:105). According to Theorem 3, Algorithm 3: Fast Hotspot Scanner (FastRH) Input: G, D, min sup Output: The set of hotspots Φ 1: Initialize: P 2, Qp ← ∅; 2: Put all p2 ∈ P 2 into Qp; 3: while Qp (cid:54)= ∅ do 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: end if 15: end while 16: return Φ Generate P i+1 based on pi; Put all pi+1 ∈ P i+1 into Qp; pi = Qp.dequeue(), k ← 2; Initialize Dpi based on D and induce Hpi (Vpi , Epi ) based on Dpi ; while Epi (cid:54)= ∅ ∧ Dpi ≥ min sup do Φpi (k):= Call Algorithm 1 by using Hpi , Dpi , min sup, pi, k as input; Φ ← Φ ∪ Φpi (k); k ← k + 1; end while if Φpi (2) (cid:54)= ∅ then given the pattern (cid:104)P S, M S(cid:105), as there are no route hotspots for k = 4, there will be no route hotspots for k = 5 or even larger values of k. We also propose the independence property for route hotspot detection. Proposition 1 (Computation Independence): The detection process for different patterns is independent. Proposition 1 allows us to speed up the route hotspot detection in a parallel manner. Next, based on Theorem 2 and 3 as well as Proposition 1, we will introduce the improved hotspot finding algorithm compared with GreedyRH. B. The Fast Route Hotspot Scanner (FastRH) Algorithm 3 shows the procedure of the improved route hotspot detection, i.e., FastRH, that can prune unnecessary checking for unqualified patterns and values of k. Denote pi as the length-i pattern. For initialization, we first calculate the set of length-2 patterns P 2 (Line 1) and put them into a pattern queue Qp (Line 2). For each pattern pi extracted from Qp (Line 4), we initialize the route set Dpi for pi and build a graph Hpi based on Dpi (Line 5). We iteratively call Algorithm 1 to obtain the route set Φpi(k). According to Theorem 3, instead of enumerating k from 2 to kmax in Algorithm 2, here we increment k until all the edges have been removed (Lines 6-10), which can reduce the number of iterations. According to Theorem 2, instead of enumerating patterns from P in Algorithm 2, here we generate P i+1 only when the hotspots for pi exist, and put all candidate length- (i + 1) patterns into Qp; otherwise, we stop the pattern growth from pi immediately (Lines 11-14). This process iterates until Qp becomes empty. Finally, the exact set of route hotspots Φ is returned. Please note that lines 3-15 can be parallelized according to Proposition 1. That is, we use the multithreading technique and process multiple patterns at a time in each iteration. Compared with GreedyRH, the scanner is improved in efficiency due to two reasons. First, it can reduce unnecessary checking for unqualified patterns since a large number of patterns that cannot form route hotspots have been pruned (Line 11-14). Theoretically, we can have up to Πhmax pat- terns, where hmax is the maximum length of patterns. E.g., the datasets GW in Section VII has 107 patterns, but only 8.6 × 105 patterns (in Table V) can form route hotspots. That means FastRH prunes 91.4% patterns safely. Second, FastRH saves unnecessary checking for unqualified values of k. For instance, Table V demonstrates that the maximum k for GW is 6, less than kmax = 16 in Table II, indicating the unnecessary computation with k ranging from 7 to 16. Please note that FastRH and its parallelized version PFastRH can produce the correct results of route hotspot finding, as they both adopt Theorems 2 and 3 that can prune unqualified patterns and values of k safely. Although the computation cost can be saved significantly with FastRH, when a user inputs a new min sup, the route hotspot detection procedures have to be performed from scratch, even if the same detection has been performed before. To avoid the duplicate detection, it is essential to store the detected hotspots to enable the quick answering for new user queries. In the next section, we develop a novel framework to index all the detected route hotspots. VI. ROUTE HOTSPOT INDEXING In this section, we propose an efficient indexing structure for the route hotspots, which is named as the Route Hotspot Index, or RH-Index for short. The RH-Index follows the pattern growth property, which is first introduced in FreeSpan [13]. However, the existing pattern growth-based tree structures like FreeSpan can only mine and index the sequential patterns whose information is quite simple, but fall short in storing the rich information associated with route hotspots. In particular, they are not able to store the hotspot information and thus cannot be applied to recover the route hotspots from the index for answering the user queries. Moreover, their index construction processes only consider the pattern anti-monotonicity, but ignore the hotspot anti-monotonicity, which may result in low efficiency due to the redundant computing for unqualified values of k. To overcome these challenges, RH-Index is proposed by introducing the hotspot information and qualified values of k in the index structure. Compared to previous pattern growth- based tree structures such as FreeSpan, the benefits are two- fold. First, it can recover the indexed route hotspots with the linked edges stored in the index. Moreover, the recovery procedure can be quite efficient by using the stored trussness information of edges. Specifically, the RH-Index can directly use the edges, whose trussness is greater than or equal to k, to recover the indexed route hotspots, avoiding extracting unqualified edges whose trussness is smaller than k. Second, following the pattern and hotspot anti-monotonicity properties, the RH-Index can update incrementally when new routes are inserted or the existing routes are deleted, minimizing the overhead needed for index reconstruction. ni = Q.dequeue(); q ← q + 1; if ∃nj ∈ ni.children, such that nj .Lj is equal to q-th item of p then Algorithm 5: Query Processing with RH-Index Input: T, p, k Output: The set of hotspots Φp(k) 1: Q ← n0, q ← 0; 2: while Q (cid:54)= ∅ ∧ q < len(p) do 3: 4: 5: 6: end if 7: end while 8: np = Q.dequeue(); 9: Collect edges Ep(k) from np.Ep where ∀e, w(e) ≥ k; 10: Induce Φp(k) from Ep(k). 11: return Φp(k) Q.inqueue(nj ); T, where L0 = ∅, T0 = ∅, E0 = ∅ (Line 1). Then, we generate the first layer nodes of T, which represent length- 1 patterns, and put all nodes into Q (Lines 2-6). Here ni.Li and ni.Ti refer to Li and Ti of node ni, respectively. The rest of RH-Index nodes are built iteratively as the lengths of patterns increase. For each node ni dequeued from Q, we first obtain the pattern p represented by ni and then grow p by appending Lj (Line 11). Then Lj, Tj and Ej of nj will be built correspondingly (Lines 12-15). Finally, the RH- Index T is successfully built and returned. Please note that the construction of RH-Index don't need to wait until FastRH has detected all the route hotspots. Instead, they may interleave to improve the efficiency. In particular, each time when the set of route hotspots for a specific pattern p is found, a new tree node np can thus be built on the tree. When new routes are inserted or existing routes are deleted, the RH-Index is required to be updated. Inserting new routes may lead to (1) updating some existing nodes with the revised trussness information and edges; or (2) inserting some new nodes as some new patterns become qualified. Let Dnew denote the set of inserted routes, and Algorithm 1 is called to determine the nodes that represent the patterns contained by Dnew and make the corresponding updating operations. Note that the pattern and hotspot anti-monotonicity properties introduced in Theorem 2 and Theorem 3 can be used to prune unqualified patterns and values of k, avoiding unnecessary updates. This updating process continues until pattern growth ends. We omit the route deletion process as it is similar to the insertion case. B. Query Processing Using RH-Index We can easily retrieve the hotspots with the given p and k, since the nodes of RH-Index store the trussness information as the weights of edges, which indicate the largest values of k for each hotspot marked by p. Here we propose a query processing method for RH-Index. The answer to query (p, k) is the set corresponding to hotspots Φp(k). The query processing algorithm is outlined in Algorithm 5. The general idea is that it traverses the RH-Index in a breadth- first order to locate the specific node representing the input pattern, and collects the appropriate edges from this node to form the subgraphs, i.e., the route hotspots for answering the queries. Specifically, we first initialize a queue Q with the root node n0 and a parameter q with 0 (Line 1), where q counts the Fig. 4. An example of RH-Index. Note that, although the first layer nodes, such as n2 and n4, cannot form any route hotspots, we still retain these nodes to support index updating. Assign ni.Li ← Li, ni.Ei ← ∅ and calculate ni.Ti; ni.pi ← Li; n0.addChild(ni), Q.inqueue(ni); Algorithm 4: RH-Index Construction Input: G, D, The set of route hotspots Φ Output: A RH-Index T 1: Q ← ∅, n0.L0 ← ∅, n0.E0 ← ∅ and n0.T0 ← ∅; 2: for Each item Li ∈ L do 3: 4: 5: 6: end for 7: while Q (cid:54)= ∅ do 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: end if 18: end while 19: return T p ← ni.pi ∪ Lj; Lj = Lj; Tj ← DHp (2), where Hp(2) ∈ Φp(2); Ej ← {(e, k)e ∈ EHp(k) ∧ Hp(k) ∈ Φp(k)}; ni.addChild(nj );Q.inqueue(nj ); end for ni = Q.dequeue(); if ni.Ei (cid:54)= ∅ then for Each item Lj ∈ L do A. Route Hotspot Index Construction We first define RH-Index. Denote L as the set of all items in the patterns, and we map each item in L to Π by using a function χ : L → Π. The i-th node of the RH-Index is denoted by ni, consisting of the item Li, the list of routes Ti and the list of edges Ei. The i-th pattern pi is the inverted sequence traveling from ni to n0 along the tree structure. Ti stores the routes which can cover all the hotspots for pi. The edges of the found hotspots are stored in Ei. The edges in Ei are the tuples, each of which consists of an edge e and the edge weight w(e), where w(e) represents the maximal trussness of the hotspot containing e. Given G, D in Example 1 and min sup = 3, we can build the corresponding RH-Index consisting of 8 nodes, as shown in Figure 4. For node n0, L0 = ∅, T0 = ∅, E0 = ∅. For the 1-pattern p, Tp = ∅, Ep = ∅, since we only consider the patterns whose lengths are greater than 1. n6 corresponds to indexed hotspots for p6 = (cid:104)P S, M S(cid:105). L6 = M S, T6 = {5, 6, 7, 8}, E6 = {((v4, v6), 3), ((v4, v7), 3), ((v4, v9), 3), ((v6, v7), 3), ((v7, v9), 3)}. We then introduce how to construct the RH-Index with the given G, D and the returned route hotspots Φ. The index is built in a top-down manner by using Algorithm 4. We first the root node of initialize a queue Q and construct 𝑛"𝑛#𝑛$𝑛%𝑛&𝑛'𝑛(∅𝑛*∅∅∅∅∅𝑃𝑆𝐷𝐵𝑊𝑆𝑀𝑆𝑀𝑆𝐷𝐵𝐷𝐵𝕋#𝕋$𝕋%𝕋&𝕋'𝕋(𝕋*𝔼&𝔼'𝔼(𝔼*𝕋'={5,6,7,8}𝔼'𝑣%𝑣'𝑣<𝑃𝑆𝑣(𝐷𝐵33333∅𝐷𝐵𝕋>𝑛>𝑀𝑆𝑀𝑆 TABLE II GRAPH STATISTICS. #VERTICES, #EDGES AND #ROUTES INDICATE THE NUMBER OF VERTICES, THE NUMBER OF EDGES AND THE NUMBER OF ROUTES RESPECTIVELY. kmax IS THE MAXIMUM VALUE OF k FOR THE GRAPH. #AT IS THE AVERAGE LENGTH OF THE ROUTES. GW WB CN YELP #Vertices 5.0 × 104 2.0 × 105 1.0 × 106 1.4 × 105 #Edges 1.3 × 106 4.9 × 106 3.9 × 106 5.6 × 106 #Routes 3.5 × 105 1.0 × 106 5.0 × 106 4.9 × 105 #AT 6.31 7.90 5.03 4.00 kmax 16 31 58 61 number of layers that we have traversed along the RH-Index tree. The algorithm first visits a node ni of RH-Index (ni starts from n0). In each step, it increments q and visits the children of ni in the next layer to select the appropriate node (say nj) that follows the label sequence of p (Lines 3-4), and put nj into Q (Line 5). Then it continues to find the appropriate children of nj. This process iterates until Q is empty or q reaches the length of p (Line 2). If Q is not empty, np is dequeued from Q, which represents the pattern p. It then selects the edges from Ep whose edge weights are greater than or equal to k (Line 9). Finally, the output is the connected subgraphs that are built with the selected edges (Lines 10-11). The following example illustrates the quick query answer- ing. Given the RH-Index in Figure 4, suppose there is a query ((cid:104)P S, M S(cid:105), 3). It first visits the first layer nodes and obtain the node n1, where n1.L1 = P S. Then it visits the children of n1, and obtains the node n6, where n6.L6 = M S. From n6.E6, it selects the edges whose weights are greater than or equal to 3, and finally it recovers the route hotspots for (cid:104)P S, M S(cid:105) and k = 3 based on the selected edges. In summary, RH-Index is simple to construct and efficient to query. We will evaluate its effectiveness and scalability in the experimental section. VII. EXPERIMENTS In this section, we evaluate the effectiveness and efficiency of our proposed algorithms on real-world networks. A. Experimental Setup 1) Evaluation Datasets: The following 4 real-world data sets are used for evaluation. • CN [26] is a collaboration network extracted from DBLP [5]. We regard each author as a vertex and each col- laboration paper between two authors as an undirected edge. The label of a vertex represents the author's main research topic. In addition to collaborative relationships that are used to construct the network, we also consider the authors' citation relationships to build the citation sequence that is used as the route. Specifically, for every two consecutive authors A and B in the sequence, B should have cited at least one paper published by A. In CN, the detection of the route hotspot is to identify a group of closely collaborated authors that are covered by a set of routes (i.e., citing sequences), indicating they have common evolving research interests. • GW [27] is a location-based dataset collected from Gowalla where users share their locations by checking- in. To construct GW, we first run k-means [28] to cluster proximate locations as a common vertex, and then connect two vertices if there exists a user moving between them. The labels of vertices are generated randomly as positive integers ranging from 1 to 100. A route repre- sents the path of a user in chronological order. In GW, the detection can discover groups of friends sharing the same traveling routes, indicating they have the common movement and mobility pattern. • WB [29] is a microblogging network crawled from Sina Weibo. We regard each user as a vertex and each reciprocal following relationship between two users as an undirected edge. The label of a vertex represents the location of the user. A route represents a sequence of users along the network path according to their following time. For example, for three consecutive users A, B and C in the sequence, B follows A first and then C follows B subsequently. In WB, the detection can discover groups of Sina Weibo users who are closely connected and meanwhile have the same following behavior. • YELP [30] is built by treating each business location as a vertex associated with a unique label. If two businesses are reviewed by at least one common user, there would be an edge between the two vertices. The routes follow the order of reviews according to their published time. In YELP, the detection can identify clusters of businesses as well as the common reviewing sequences carried by these businesses. The network statistics are shown in Table II. 2) Comparison Methods: • CuTS [8] aims to find convoys which are groups of objects traveling together for a certain period of time. As it is not designed to process graph data, to compare with our proposal, we make a minor modification, that is, we use NG-DBSCAN [31] instead of DBSCAN [32] as the clustering algorithm. Note that we consider the convoys as the route hotspots when using CuTS. • CuTSG extends CuTS in that it first finds convoys by using CuTS, and then determines whether a convoy can also cover a connected maximal k-truss with as many vertices, edges and routes as possible. • GreedyRH is the greedy algorithm described in Algo- rithm 2. • FastRH is our core algorithm described in Algorithm 3. We apply both the properties of pattern anti-monotonicity and hotspot anti-monotonicity on GreedyRH. • PFastRH is the parallel version of FastRH, which is implemented by using multithreading. • GreedyRHP is an improved algorithm based on GreedyRH, where we apply the property of pattern anti- monotonicity on GreedyRH. • GreedyRHH is the other improved algorithm based on GreedyRH, where we apply the property of hotspot anti- THE PS ON THE GW, WB, YELP AND CN. TABLE III min sup PS (FastRH) PS (GreedyRHP) PS (GreedyRHH) PS (PFastRH) min sup PS (FastRH) PS (GreedyRHP) PS (GreedyRHH) PS (PFastRH) GW/WB/YELP 20 10 30 40 50 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% CN 200 400 300 100 500 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% monotonicity on GreedyRH. 3) Evaluation Metrics: • Precision Score (PS). C denotes the complete set of hotspots obtained by GreedyRH and C denotes the set of hotspots obtained by other methods, such as FastRH, GreedyRHP, GreedyRHH and PFastRH. PS is computed as P S = . This metric is used to verify our proposal works correctly with the anti-monotonicity and independence properties (i.e., Theorem 2, Theorem 3 and Proposition 1). Please note that, as CuTS and CuTSG don't use these properties to prune unqualified route hotspots or achieve parallel speedup, they are not evalu- ated in terms of PS. C∩ C C • Time Cost and Space Cost. "Time Cost" is the running time for the detection or indexing process. "Space Cost" is the main memory used for indexing. • Number of Patterns (#NP) and Number of Hotspots (#NH). "Number of Patterns" and "Number of Hotspots" refer to the total number of patterns that are used to support hotspots and the total number of hotspots that are obtained with our methods respectively. We use #CuNP, #CuGNP and #RHNP (resp. #CuNH, #CuGNH and #RHNH) to represent the total number of patterns (resp. number of hotspots) obtained with CuTS, CuTSG and PFastRH. 4) Implementation Details: All algorithms are imple- mented in Java and all of the experiments are conducted on a commodity PC with Linux 16.04, Core-i7 6700K CPU (4.00GHz) and 64 GB main memory. We use 8 threads for running PFastRH. To evaluate the impacts of min sup, we set min sup = 100, 200, 300, 400, 500 for CN, and min sup = 10, 20, 30, 40, 50 for GW, WB and YELP respectively. B. Experimental results 1) Effectiveness Analysis: We evaluate the effectiveness of these methods on WB, GW, CN and YELP, but omit the results of GreedyRH as it is too slow on large datasets. Table III shows the precision scores with varying min sup for all compared methods. We can see that the PS values of FastRH, GreedyRHP, GreedyRHH, and PFastRH on GW, WB, CN, and YELP are always equal to 100%. It indicates that, FastRH, GreedyRHP, GreedyRHH, and PFastRH won't change the number of hotspots, which validates the correctness of our pattern and hotspot anti-monotonicity properties as well as the independent properties. 2) Analysis on Patterns and Route Hotspots: We analyze the total number of patterns and route hotspots obtained with PFastRH, CuTS and CuTSG by varying min sup, and the results are shown in Figure 5. (a) #NH and #NP (GW) (b) #NH and #NP (WB) (c) #NH and #NP (YELP) (d) #NH and #NP (CN) Fig. 5. #NH and #NP on the GW, WB, YELP, and CN. It can be observed that #NP and #NH decrease when min sup increases. Generally, #NH would be greater than or equal to #NP as one pattern may correspond to multiple hotspots, but we can observe in Figure 5 that #NH is almost equal to #NP when min sup is large. The reason is that larger min sup may make some route hotspots become unqualified as their numbers of routes are now less than min sup. Note that, #CuNH is equal to #CuNP, as CuTS considers a pattern (i.e., a convoy) as a hotspot. Also, as shown in Figure 5, #CuNP and #CuNH are larger than #CuGNP and #CuGNH, because the definition of k- truss-based convoys defined in CuTSG is more rigorous than that defined in CuTS. In the datasets WB and CN, #CuNP and #CuGNP (resp. #CuNH and #CuGNH) are greater than #RHNP (resp. #RHNH) when min sup is small. This is because the definition of route hotspot defined in Definition 1 uses both pattern and graph information, which is able to avoid a large amount of unqualified patterns. However, when min sup increases, #CuNP and #CuGNP become smaller than #RHNP, and #CuNH and #CuGNH are also smaller than #RHNH. This is because CuTS and CuTSG only use route information but ignore the sequential patterns in the routes. In the datasets GW and YELP, #RHNH is greater than #CuNH and #CuGNH with different min sup. We can also observe that, for each dataset, the gap between #RHNH and #RHHP is larger than that between #CuGNH and #CuGNP, as well 01020304050min_sup0123456#NH and #NP 104#RHNH#RHNP#CuNH#CuNP#CuGNH#CuGNP01020304050min_sup0246810#NH and #NP 104#RHNH#RHNP#CuNH#CuNP#CuGNH#CuGNP01020304050min_sup0123#NH and #NP 104#RHNH#RHNP#CuNH#CuNP#CuGNH#CuGNP0100200300400500min_sup02468#NH and #NP 104#RHNH#RHNP#CuNH#CuNP#CuGNH#CuGNP as that between #CuNH and #CuNP. The reason is that, our method can find more densely interconnected subgraphs with larger values of k. 3) Efficiency of Hotspot Finding: We evaluate the effi- ciency of FastRH, GreedyRHP, GreedyRHH, PFastRH, CuTS and CuTSG by varying min sup. The performances in terms of time cost are shown in Figure 6, where the time cost is the running time for a specific algorithm. Please note that as GreedyRH is too slow, we omit its results. (a) #NP with #Vertices (b) #NP with #Routes (a) Time Cost (GW) (b) Time Cost (WB) (c) #NH with #Vertices (d) #NH with #Routes (c) Time Cost (YELP) (d) Time Cost (CN) Fig. 6. The Time Cost on the GW, WB, YELP, and CN. As shown in Figure 6, when min sup increases, the time cost decreases due to the decrease of #NP and #NH shown in Figure 5. We can observe that GreedyRHH is more efficient than GreedyRHP. The reason is that GreedyRHH uses the hotspot anti-monotonicity to prune unnecessary candidate val- ues of k, and this pruning policy can prevent a significant num- ber of checking operations. This is validated in Table VI that the number of route hotspots drops sharply with the increase of k. FastRH is faster than GreedyRHH and GreedyRHP, since FastRH uses two pruning rules to speed up the hotspot finding process. PFastRH is even faster than FastRH because PFastRH is a parallel method. CuTS is the fastest one since it only uses the route information. CuTSG is faster than GreedyRH and its variations, as it doesn't consider the patterns in routes and thus avoids the sequential pattern mining process. Please note that another reason why CuTS and CuTSG are faster than PFastRH is that we only use 8 threads in our experiments (according to our machine), which limits the speed-up ratio of the parallelized algorithm. As shown in Figure 7, with the increasing number of vertices and routes for CN, the time cost increases almost linearly. This is because a greater number of vertices and routes bring in a greater number of patterns and route hotspots, i.e., #NP and #NH, and thus it would take longer time. The (e) Time Cost with #Vertices (f) Time Cost with #Routes Fig. 7. The #NP, #NH and Time Cost on sampled subgraphs of CN with different values of min sup, where #Vertices=1.0 × 105, 3.0 × 105, 5.0 × 105, 1.0 × 106 and #Routes=5.0 × 105, 1.5 × 106, 2.5 × 106, 5.0 × 106 respectively. The Time Cost is obtained by PFastRH. TABLE IV AN EXAMPLE OF NRH-INDEX. ID 1 2 . . . Pattern (cid:104)a, b(cid:105) (cid:104)a, b(cid:105) . . . k 2 3 . . . (v1, v2), (v1, v3), (v2, v3), (v2, v4), (v2, v5), (v3, v4), (v3, v5) (v1, v2), (v1, v3), (v2, v3), (v2, v4), (v2, v5), (v3, v4), (v3, v5) Edges . . . near-linear increasing demonstrates that route hotspots in the network is near-uniform. the distribution of 4) Indexing and Query Processing: We evaluate the scal- ability and the efficiency of RH-Index. Since it's trivial for the situation when a hotspot owns just one route, we fix min sup = 2. Please note that a larger min sup can result in smaller RH-Index. For comparing with RH-Index, we propose a naıve method called NRH-Index, where each hotspot is stored as a set of edges in the row of a big table. NRH-Index can also support querying by patterns via traversing rows in that big table. Table IV shows an example of NRH-Index with pattern (cid:104)a, b(cid:105) and k = 2, 3. Please note that the IDs in this example are assigned randomly. The indexing performance of RH-Index is shown in Table V, where "#MNRH" and "#MRH" are the cost of the main memory for NRH-Index and RH-Index respectively; "#TNRH" 01020304050min_sup0150300450600750Time/sGreedyRHPGreedyRHHFastRHPFastRHCuTSCuTSG01020304050min_sup01234Time/ 103 sGreedyRHPGreedyRHHFastRHPFastRHCuTSCuTSG01020304050min_sup02004006008001000Time/sGreedyRHPGreedyRHHFastRHPFastRHCuTSCuTSG0100200300400500min_sup00.511.522.533.5Time/ 104 sGreedyRHPGreedyRHHFastRHPFastRHCuTSCuTSG00.20.40.60.81#Vertices 10601234#NP 104min_sup=100min_sup=200min_sup=300min_sup=400min_sup=500012345#Route 10601234#NP 104min_sup=100min_sup=200min_sup=300min_sup=400min_sup=50000.20.40.60.81#Vertex 106012345#NH 104min_sup=100min_sup=200min_sup=300min_sup=400min_sup=500012345#Route 106012345#NH 104min_sup=100min_sup=200min_sup=300min_sup=400min_sup=50000.20.40.60.81#Vertices 10600.20.40.60.81Time/ 104 smin_sup=100min_sup=200min_sup=300min_sup=400min_sup=500012345#Route 10600.20.40.60.81Time/ 104 smin_sup=100min_sup=200min_sup=300min_sup=400min_sup=500 INDEX STATISTICS (SIZE IN MEGABYTES AND TIME IN SECONDS) TABLE V In addition, the query time generally increases with the size of the networks. #MNRH #MRH #TNRH #TRH #NP #NH #AVH #AEH #ARH #ALH max{k} GW 47,924 13,336 382 294 8.6 × 105 2.1 × 106 20.6 25.0 4.0 6.31 6 WB 44,035 28,181 865 691 95.5 131.2 19.7 2.82 7 1.6 × 105 3.8 × 106 1.8 × 105 5.4 × 105 6.7 × 105 8.2 × 105 YELP 27,102 19,776 945 934 42.6 51.3 9.5 4.00 20 CN 39,918 15,403 8,392 8,166 15.5 17.6 32.2 3.39 12 #NH FOR DIFFERENT VALUES OF k ON ALL DATASETS TABLE VI GW 1.7 × 106 4.6 × 105 1.6 × 104 370 9 WB 3.6 × 105 1.6 × 105 YELP 5.2 × 105 1.6 × 104 76 11 4 118 29 18 CN 7.8 × 105 3.1 × 104 6, 163 1, 707 602 k = 2 k = 3 k = 4 k = 5 k = 6 and "#TRH" denote the time cost to build NRH-Index and RH- Index respectively, including both detection time and indexing time; "#AVH", "#AEH", "#ARH", "#ALH" are the average number of vertices, edges, routes and the length of patterns for each hotspot. As shown in Table V, over all the datasets, the memory cost of NRH-Index (i.e., #MNRH) is much larger than that of RH-Index (i.e., #MRH), and similarly, the time cost of NRH-Index (i.e., #TNRH) is also greater than that of RH-Index (i.e., #TRH). The main reason is that RH-Index uses a tree-based structure to index the route hotspots, which can save both space and time cost compared with the table-based structure. Table VI shows how k affects the performance on different datasets. Since the evaluated RH-Index is obtained by fixing min sup = 2, one can obtain the maximum number of hotspots when k = 2, and this number decreases when k increases. The maximum value of k is 12 for CN. It can also be observed that the number of hotspots drops quickly when k increases, which is beneficial for GreedyRHH. We compare the average query time of RH-Index and NRH- Index in Table VII. The query time includes the time to find patterns and the time to recover hotspots. It is shown that over all datasets, the time cost for querying RH-Index is much lower than that for NRH-Index, indicating that RH-Index is much more efficient even with far less memory requirement. TABLE VII QUERY TIME(IN MILLISECONDS) DataSet With NRH-Index With RH-Index GW 0.098 0.043 WB 9.468 0.864 YELP 0.424 0.224 CN1 1.789 0.067 CN2 3.786 0.090 CN 4.715 0.122 C. Case Study Two case studies from CN and YELP are given to explain the effectiveness of our method. Fig. 8. Case Study for (cid:104)DB, DM, SP(cid:105) and k = 3 in CN, where the dashed rectangles represent the research areas and the colored and dashed lines represent routes in the hotspot. We omit the edges. Figure 8 shows a route hotspot for pattern (cid:104)DB, DM, SP(cid:105) and k = 3, where DB, DM and SP stand for Database, Data Mining and Sequential Pattern respectively. This hotspot shows how the research highlights evolved in the 2000s. During the time, the techniques for database were applied to data mining, and then applied to sequential pattern mining, and the detected scholars in theses domains had close cooperations. Figure 9 shows interesting relationships among dance, event planning, and buffets. Dance1 and Dance2 denote two different vertices but have the same attribute dance, and so is for Hotel1 and Hotel2 affiliated with the same attribute Hotel. From the observed sequential pattern (cid:104)Dance, Event Planning, Buffets(cid:105), we can know that dance, event planning and buffets are tightly coupled activities, and people who participate these activities usually first dance, then followed by the planning on the subsequent activities, and finally go on for dinner. Note that, vertices whose attributes don't exist in this pattern may also appear in the hotspot (e.g., attributes Hotel and Night Life don't appear in the pattern but appear in the hotspot). The reason is that our definition is relaxed in the attributes so that triangles can be formed easily. Fig. 9. Case Study for (cid:104)Dance, Event Planning, Buffets(cid:105) and k = 3 in YELP, where the colored lines represent routes in the hotspot. We omit the edges. In contrast to the route hotspot for (cid:104)Dance, Event Planning, Buffets(cid:105) and k = 3, as shown in Figure 9, we cannot find the route hotspot for (cid:104)Dance, Buffets, Event Planning(cid:105) and k = 3. The reason is that, people don't exhibit such kind of behaviors on YELP. Wei CuiDBSPDBDMSPXueminLinKeWangHui XiongJiaweiHanJian PeiDMDatabaseData MiningSequential PatternBuffetsHotel1Event PlanningNight LifeDance2Hotel2Dance1 VIII. CONCLUSION In this paper, we study the problem of finding route hotspots in large labeled networks. We introduce the definition of the route hotspot and propose a novel approach FastRH to find them, based on pattern anti-monotonicity and hotspot anti- monotonicity properties. To preserve the detected hotspots and support fast user querying by patterns, we design a novel index, called RH-Index. Extensive experiments performed on large real-world networks demonstrate the effectiveness and efficiency of the proposed methods. ACKNOWLEDGMENT This work is supported in part by the National Key Research and Development Program of China under Grant 2017YFB0803301, in part by Natural Science Foundation of China under Grant 61976026 and U1836215, in part by 111 Project under Grant B18008, and in part by NSF under grants III-1526499, III-1763325, III-1909323, and CNS-1930941. REFERENCES [22] X. Huang, W. Lu, and L. Lakshmanan, "Truss decomposition of proba- bilistic graphs: Semantics and algorithms." in SIGMOD, 2016, pp. 77 -- 90. [23] M. R. Vieira, P. Bakalov, and V. J. Tsotras, "On-line discovery of flock patterns in spatio-temporal data," in SIGSPATIAL, 2009, pp. 286 -- 295. [24] C. Zhang, K. Zhang, Q. Yuan, L. Zhang, T. Hanratty, and J. Han, "Gmove: Group-level mobility modeling using geo-tagged social me- dia," in SIGKDD, 2016, pp. 1305 -- 1314. [25] G. Dimitrios, K. Roni, M.Heikki, S. Sanjeev, T. Hannu, and S. R. Sewak, "Discovering all most specific sentences." TODS, pp. 140 -- 174, 2003. [26] J. Tang, J. Zhang, L. Yao, L. Zhang, and Z. Su, "Arnetminer: Extraction and mining of academic social networks." in SIGKDD, 2008, pp. 990 -- 998. [27] E. Cho, S. Myers, and J. Leskovec, "Friendship and mobility: User movement in location-based social networks." in SIGKDD, 2011, pp. 1082 -- 1090. [28] S. Lloyd, "Least squares quantization in pcm." TIT, pp. 129 -- 137, 1982. [29] J. Zhang, B. Liu, J. Tang, T. Chen, and J. Li, "Social influence locality for modeling retweeting behaviors." in IJCAI, 2013, pp. 2761 -- 2767. [30] YELP, "Yelp dataset challenge," https://www.yelp.com/dataset challenge. [31] A. Lulli, M. Dell'Amico, P. Michiardi, and L. Ricci, "Ng-dbscan: scalable density-based clustering for arbitrary data," PVLDB, pp. 157 -- 168, 2016. [32] M. Ester, H.-P. Kriegel, J. Sander, X. Xu et al., "A density-based algorithm for discovering clusters in large spatial databases with noise." in KDD, 1996, pp. 226 -- 231. [1] L. Chu, Z. Wang, J. Pei, Y. Zhang, Y. Yang, and E. Chen, "Finding theme communities from database networks," PVLDB, vol. 12, no. 10, pp. 1071 -- 1084, 2019. [2] Z. Shang, G. Li, and Z. Bao, "Dita: A distributed in-memory trajectory analytics system." in SIGMOD, 2018, pp. 1681 -- 1684. [3] J. Dai, B. Yang, C. Guo, and Z. Ding, "Personalized route recommen- dation using big trajectory data," in ICDE, 2015, pp. 543 -- 554. [4] E. Lopez-Rojas, A. Elmir, and S. Axelsson, "Paysim: A financial mobile money simulator for fraud detection," in EMSS, 2016, pp. 249 -- 255. [5] DBLP, "Dblp computer science bibliography," http://dblp.uni-trier.de. [6] Y. Peng, Y. Zhang, W. Zhang, X. Lin, and L. Qin, "Efficient probabilistic k-core computation on uncertain graphs." in ICDE, 2018, pp. 1192 -- 1203. [7] J. Wang and J. Cheng, "Truss decomposition in massive networks." PVLDB, pp. 812 -- 823, 2012. [8] H. Jeung, M. L. Yiu, X. Zhou, C. S. Jensen, and H. T. Shen, "Discovery of convoys in trajectory databases," PVLDB, pp. 1068 -- 1080, 2008. [9] K. Zheng, Y. Zheng, N. J. Yuan, and S. Shang, "On discovery of gathering patterns from trajectories," in ICDE, 2013, pp. 242 -- 253. [10] J. Pei, J. Han, B. Mortazavi-Asl, H. Pinto, Q. Chen, U. Dayal, and M.- C. Hsu, "Pre-fixspan: Mining sequential patterns efficiently by prefix- projected pattern growth." in ICDE, 2001, pp. 215 -- 224. [11] X. Huang and L. V. Lakshmanan, "Attribute-driven community search," in PVLDB, 2017, pp. 949 -- 960. [12] R. Agrawal and R. Srikant, "Mining sequential patterns." in ICDE, 2005, pp. 3 -- 14. [13] J. Han, J. Pei, B. Mortazavi-Asl, Q. Chen, U. Dayal, and M.-C. Hsu, "Freespan: Frequent pattern-projected sequential pattern mining." in SIGKDD, 2000, pp. 355 -- 359. [14] M. Riondato and E. M. Kornaropoulos, "Fast approximation of between- ness centrality through sampling." in WSDM, 2014, pp. 413 -- 422. [15] M. Riondato and E. Upfal, "Mining frequent itemsets through progres- sive sampling with rademacher averages," in KDD, 2015, pp. 1005 -- 1014. [16] H. Li, W. Yi, Z. Dong, Z. Ming, and Y. C. Edward, "Pfp: parallel fp- growth for query recommendation," in RecSys, 2008, pp. 107 -- 114. [17] J. Ge and Y. Xia, "Distributed sequential pattern mining in large scale uncertain databases," in PAKDD, 2016, pp. 17 -- 29. [18] M. Riondato and E. Upfal, "Efficient discovery of association rules and frequent itemsets through sampling with tight performance guarantees." in ECML PKDD, 2012, pp. 25 -- 41. [19] G. Dong and J. Pei, Sequence data mining. Springer, 2007, vol. 33. [20] F. Zhang, Y. Zhang, L. Qin, W. Zhang, and X. Lin, "When engagement meets similarity: efficient (k, r)-core computation on social networks." in PVLDB, 2017, pp. 998 -- 1009. [21] X. Huang, H. Cheng, L. Qin, W. Tian, and J. Yu, "Querying k-truss community in large and dynamic graphs." in SIGMOD, 2014, pp. 1311 -- 1322.
1201.3307
1
1201
2012-01-16T16:25:09
Multi-scale Community Detection using Stability Optimisation within Greedy Algorithms
[ "cs.DS", "cs.SI", "physics.soc-ph" ]
Many real systems can be represented as networks whose analysis can be very informative regarding the original system's organisation. In the past decade community detection received a lot of attention and is now an active field of research. Recently stability was introduced as a new measure for partition quality. This work investigates stability as an optimisation criterion that exploits a Markov process view of networks to enable multi-scale community detection. Several heuristics and variations of an algorithm optimising stability are presented as well as an application to overlapping communities. Experiments show that the method enables accurate multi-scale network analysis.
cs.DS
cs
Multi-scale Community Detection using Stability Optimisation within Greedy Algorithms Erwan Le Martelot Department of Computing Imperial College London Chris Hankin Department of Computing Imperial College London London SW7 2AZ, United Kingdom London SW7 2AZ, United Kingdom [email protected] [email protected] July 9, 2018 Abstract Many real systems can be represented as networks whose analysis can be very informa- tive regarding the original system's organisation. In the past decade community detection received a lot of attention and is now an active field of research. Recently stability was introduced as a new measure for partition quality. This work investigates stability as an optimisation criterion that exploits a Markov process view of networks to enable multi-scale community detection. Several heuristics and variations of an algorithm optimising stability are presented as well as an application to overlapping communities. Experiments show that the method enables accurate multi-scale network analysis. Keywords: lapping communities community detection, multi-scale, stability, Markov process, random walks, over- 1 Introduction In various fields such as biology, sociology, engineering and beyond, systems are commonly rep- resented as graphs, or networks (e.g. protein networks, social networks, web). In the past decade the field of community detection attracted a lot of interest considering community structures as important features of real-world networks [10]. Commonly, given a network of any kind, looking for communities refers to finding groups of nodes that are more densely connected internally than with the rest of the network. The concept considers the inhomogeneity within the connections between nodes to derive a partitioning of the network. This definition is the one we follow in this work. (The definition of community can indeed vary depending on the field of study or the application.) As opposed to clustering methods which commonly involve a given number of clus- ters, communities within networks are usually unknown, can be of unequal size and density and often have hierarchies [10, 25]. Finding such partitioning can give information on the underlying structure of a network and its functioning. It can also be used as a more compact representation of the network, for instance for visualisations. The detection of a community structure in networks can be divided in two problems. The first problem is algorithmic: "How to partition a graph?" The second problem is more semantic related: "How to measure the quality of a partition?" which requires an accepted definition of 1 a community such as the one given above. These two problems can be seen as separate in some methods such as [30] where a fairly generic aggregating algorithm optimises a partition quality criterion. Other algorithms such as [4] still use the same criterion but exploit the topology of the network based on what the criterion is trying to achieve and attempt to guide the aggregation towards better solutions than a more generic aggregation method would produce. The quality of a partition can be measured using several functions. To date the most common and explored measure is modularity [33]. Regarding the partitioning algorithm, partitioning graphs is an NP-hard task [10] and hence finding the optimum community partition is of similar complexity. Heuristics based algorithms have thus been devised to provide acceptable solutions at a reduced complexity. Considering the sizes of some real-world networks (e.g. web, protein networks) a lot of effort has been put into finding efficient algorithms able to deal with larger and larger networks. However, returning to the definition of communities, it has been shown that networks often have several levels of organisation [43], leading to different partitions for each level. Therefore communities in networks can be present at various scales (or resolutions) and can have a hier- archical structure. This multi-scale aspect cannot be handled by modularity optimisation alone [11, 10]. To address this issue methods have been provided to adapt modularity optimisation to multi-scale (multi-resolution) analysis using a tuning parameter [39, 3]. Other methods such as [40] consider intra clusters connectivity and provide a tuning parameter to aim at commu- nities of various sizes. Yet the search for a partition quality function that acknowledges the multi-resolution nature of networks with appropriate theoretical foundations has received less attention. Recently, stability [8] was introduced as a new quality measure for community par- titions. Based on this measure [24] presented an investigation of the use of stability as an optimisation criterion for multi-scale analysis. In this work we expand upon these initial results and present a broader investigation of stability optimisation involving heuristics for speed gain and/or accuracy as well as an application to overlapping community detection. The next section provides a literature review presenting contributions to community detection relevant to this work. Then the concept of stability optimisation is presented followed by the introduction of optimisation heuristics. Experiments are then performed in order to assess our method and its variation as well as to compare them with other relevant methods found in the literature. An application to the detection of overlapping communities is then presented and assessed. The paper is concluded by discussing the potential of our approach and its implications for the field and future work. 2 Background community j and ai =(cid:80) While several community partition quality measures exists [26, 8, 10], the most commonly found in the literature is modularity [33]. Given a partition into c communities let e be the community matrix of size c × c where each eij gives the fraction of links going from a community i to a j eij the fraction of links connected to i. (If the graph is undirected, each eij not on the diagonal should be given half of the edges connecting communities i and j so that the number of edges connecting the communities is given by eij + eji [33].) Modularity QM is the sum of the difference between the fraction of links within a partition linking to this very partition minus the expected value of the fraction of links doing so if edges were randomly placed: QM = (eii − a2 i ) (1) c(cid:88) i=1 2 One advantage of modularity is to impose no constraint on the shape of communities as opposed for instance to the clique percolation method [35] that defines communities as adjacent k-cliques thus imposing that each node in a community is part of a k-clique. Modularity was initially introduced to evaluate partitions. However its use has broadened from partition quality measure to optimisation function and modularity optimisation is now a very common approach to community detection [30, 5, 31, 4]. (Recent reviews and comparisons of community detection methods including modularity optimisation methods can be found in [10, 23].) Modularity optimisation methods commonly start with each node placed in a different community and then successively merge the communities that maximise modularity at each step. Modularity is thus locally optimised at each step based on the assumption that a local peak should indicate a particularly good partition. The first algorithm of this kind was Newman's fast algorithm [30]. Here, for each candidate partition the variation in modularity ∆QM that merging two communities i and j would yield is computed as ∆QMij = 2(eij − aiaj) (2) where i and j are the communities merged in the new candidate partition. Computing only ∆QM minimises the computations required to evaluate modularity and leads to the fast greedy algorithm given in Algorithm 1. This algorithm enables the incremental building of a hierarchy Algorithm 1 Sketch of a greedy algorithm for modularity optimisation. 1. Divide in as many clusters as there are nodes 2. Measure modularity variation ∆QM for each candidate partition where a pair of clusters are merged 3. Select the network with the highest ∆QM 4. Go back to step 2 where each new partition is the local optima maximising QM at each step. It was shown to provide good solutions with respect to the original Girvan-Newman algorithm that performs accurately but is computationally highly demanding and is thus not suitable for large networks [33]. (Note that accuracy refers in this context to a high modularity value. Other measures, such as stability, might rank partitions differently.) Since then other methods have been devised such as [5] optimising the former method, another approach based on the eigenvectors of matrices [31] and the Louvain method [4]. The latter has shown to outperform in speed previous greedy modularity optimisation methods by reducing the number of intermediate steps for building the hierarchy. The method works in two steps that are repeated until no further aggregation is possible. The first step aggregates nodes by moving them from their community to a neighbour community if this move results in an increase of modularity. Once no move can provide any increase the second step consists in creating the graph of the communities. Then the method is reapplied from step one to this new graph. Other approaches have looked at introducing biases to alter the behaviour of the modularity optimisation towards communities of various sizes. In [6], the authors observed that in [30] large communities are favoured at the expense of smaller ones biasing the partitioning towards a structure with a few large clusters which may not be an accurate representation of the network. They provided a normalised measure of ∆QM defined as ∆Q(cid:48) Mij = max (3) (cid:19) , ∆QMij aj (cid:18) ∆QMij ai 3 which aims at treating communities of different sizes equally. These methods all rely on modularity optimisation. Yet modularity optimisation suffers from several issues. One issue is known as the resolution limit meaning that modularity optimisation methods can fail to detect small communities or over-partition networks [11] thus missing the most natural partitioning of the network. Another issue is that the modularity landscape admits a large number of structurally different high-modularity value solutions and lacks a clear global maximum value [14]. It has also been shown that random-graphs can have a high modularity value [15]. However not all methods rely on modularity. A popular non modularity-related method is known as InfoMap [41]. InfoMap considers information flow probabilities of random walks within a network to compress the network. The compression principle decomposes the network into modules that provide a coarse view of the graph. This view provides a first level of encoding. Then a second level of encoding is performed locally in each module. The content of each modules, namely a neighbourhood of nodes, provides the fine-grain view of the graph. This technique of compression is therefore based on a two level representation of the graph. The module level provides a partition of the network that can be interpreted in terms of communities as at highlights the structure of the network. So far the methods presented only return one best partition for a given network. Yet it is commonly acknowledged that networks often have several levels of organisation [43]. Therefore community detection methods should be able to identify different partitions at various scales. In this respect several methods have been proposed. In [39], modularity optimisation is modified by using a scalar parameter γ in front of the null term (the fraction of edges connecting vertices of a same community in a random graph) turning equation (1) into (cid:88) QMγ = (eii − γa2 i ) (4) i where γ can be varied to alter the importance given to the null term (modularity optimisation is found for γ = 1). In [3], modularity optimisation is performed on a network where each node's strength has been reinforced with self loops. Considering the adjacency matrix A, modularity optimisation is performed on A + rI where I is the identity matrix and r is a scalar: QMr = QM (A + rI) (5) Varying the value of r enables the detection of communities at various coarseness levels (modu- larity optimisation is found for r = 0). With their resolution parameter, the two latter methods enable a multi-scale network analysis. Another multi-scale method, not relying on modularity, was introduced in [40]. The model uses no null factor and is therefore not subject to the resolution limit found in modularity. The quality of a partition is expressed as follows: QH (γ) = − 1 2 (Aij − γJij) (6) (cid:88) i(cid:54)=j where A is the adjacency matrix and Jij = 1 − Aij (i.e. J is the complement of the adjacency matrix A) and γ the resolution parameter. The models therefore considers the amount of con- nections within clusters less the connections missing to get fully connected clusters. γ varies the importance of the missing connections. A small γ value will favour large clusters while a large γ value will favour dense clusters. Recently, a new partition quality measure called stability was introduced in [8]. The stability of a graph considers the graph as a Markov chain where each node represents a state and each 4 edge a possible state transition. Let n be the number of nodes, m the number of edges, A the n × n adjacency matrix containing the weights of all edges (the graph can be weighted or not), d a size n vector giving for each node its degree (or strength for a weighted network) and D = diag(d) the corresponding diagonal matrix. The stability of a graph considers the graph as a Markov chain where each node represents a state and each edge a possible state transition. The chain distribution is given by the stationary distribution π = d 2m (7) Also let Π be the corresponding diagonal matrix Π = diag(π). The transition between states is given by the n × n stochastic matrix (8) Assuming a community partition, let H be the indicator matrix of size n× c giving for each node its community. The clustered auto-covariance matrix at Markov time t is defined as: M = D−1A Rt = H T (ΠM t − πT π)H (9) Stability at time t noted QSt is given by the trace of Rt and the global stability measure QS considers the minimum value of the QSt over time from time 0 to a given upper bound τ : QS = min 0≤t≤τ trace(Rt) This model can be extended to deal with real values of t by using the linear interpolation: Rt = (c(t) − t) · R(f (t)) + (t − f (t)) · R(c(t)) (10) (11) where c(t) returns the smallest integer greater than t and f (t) returns the greatest integer smaller than t. This is useful to investigate for instance time values between 0 and 1 in which case the equation becomes simply: Rt = (1 − t) · R(0) + t · R(1) (12) It was indeed shown in [8] that the use of Markov time with values between 0 and 1 enables detecting finer partitions than those detected at time 1 and above. Also, this model can be turned into a continuous time Markov process by using the expression e(M−I)t in place of M t (where e is the exponential function) [8]. Several Markov processes could be considered here as discussed in [22]. Stability has been introduced as a measure to evaluate the quality of a partition hierarchy and has been used to assess the results of various modularity optimisation algorithms. Further mathematical foundations have been presented in [22, 21]. Stability has been shown to unify some known clustering heuristics including modularity. Based on this theoretical work, [24] presented a stability optimisation method similar to the fast modularity optimisation method from [30]. The work showed that stability can be optimised similarly to modularity optimisation. While related approaches such as [3, 39] also offer a multi-scale analysis with their respective parameters, these methods offer a tuneable version of modularity optimisation by modifying the importance of the null factor or by adding self-loops to nodes. Such analysis remains based on a one step random walk analysis of the network with modifications of its structure. [40] also considers a very strict topology criterion by aiming at fully connected communities. In contrast, stability optimisation enables random walks of variable length defined by the Markov time thus exploiting thoroughly the actual topology of the network similarly to an information flow through 5 a network. As communities reflect the organisation of a network, and hence its connectivity, this approach seems to be more suitable. The next section presents the stability optimisation method. The paper then develops further the idea by presenting several optimisation heuristics that enable significant gains in speed and potentially in accuracy. Then the method is applied to the detection of overlapping communities. All the methods are tested against several datasets and compared with one another as well as with other popular methods. 3 Stability Optimisation 3.1 Principle As discussed in [8], studying the stability of a partition along the Markov time can help addressing the partition scale issue and the optimal community identification. The results from the authors indeed show with the stability curve that the clustering varies depending on the time window during which the Markov time is considered. From there, [24] used the Markov time as a resolution parameter in a greedy optimisation context where stability is used as the optimisation criterion. The principle is the following. Let At = DM t, considering equation (9), the autocovariance can also be expressed as Rt = H T (ΠM t − πT π)H = H T ( At − πT π)H = 1 2m 1 2m H T AtH − H tπT πH (13) The trace of the autocovariance can then be expressed as the modularity of the graph with adjacency matrix At. The community matrix for At is then noted et. trace(Rt) = trace( H T AtH − H tπT πH) = 1 2m 1 2m trace(H T AtH) − trace(H tπT πH) (14) Using this expression, this trace can then be expressed using two forms commonly found in the modularity literature. The first one uses the adjacency matrix with nodes indices i and j as well as the δ(i, j) function returning 1 if i and j belong to the same community, zero otherwise: (Atij − didj 2m )δ(i, j) (15) The second form uses the previously defined community matrix, noted here et for time t: trace(Rt) = 1 2m (cid:88) i,j 1 2m Atij δ(i, j) − ( c(cid:88) trace(Rt) = i=1 (cid:88) i,j i,j 1 2m didjδ(i, j) = )2(cid:88) etii − c(cid:88) c(cid:88) (etii − a2 i ) a2 i = i=1 i=1 c(cid:88) (etii − a2 i ) In this work we will use the latter expression. Stability at time t is therefore defined as: QSt = trace(Rt) = i=1 This is the analogue of equation (1) for At. Therefore the optimisation of stability at time t only is equivalent to the optimisation of modularity taking the adjacency matrix At. These results are for the Markov chain model. The continuous time model would use the adjacency matrix At = De(M−I)t. Considering stability at time t as the modularity of a graph given by the adjacency matrix At allows the modularity optimisation techniques to be applied to stability. 6 (16) (17) Stability optimisation then becomes a broader measure where modularity is the special case t = 1 in the Markov chain. Greedy modularity optimisation is based on computing the change in modularity between an initial partition and a new partition where two clusters have been merged. The change in modularity when merging communities i and j is given by equation (2) and similarly the change in stability at time t is = 2(etij − aiaj) Following equation (10) the new QS candidate value Q(cid:48) ∆QStij S is: Q(cid:48) S = min 0≤t≤τ (QSt + ∆QSt) Other modularity optimisation methods may use different ways to compute ∆QM based on the way they aggregate communities (e.g. Louvain method from [4]). Considering that stability optimisation at time t can be seen as modularity optimisation for At, these expressions would also be valid for computing ∆QS. 3.2 Greedy Optimisation Following the steps from Algorithm 1, a similar stability optimisation method can be derived [24]. At each clustering step, the partition with the best Q(cid:48) S value is kept and QS is then updated as QS = Q(cid:48) S. For computational reasons the time needs to be sampled between 0 and τ . Markov time can be sampled linearly or following a log scale. The latter is usually more efficient for large time intervals. All the matrices et are computed in the initialisation step of the algorithm and then updated by successively merging the lines and columns corresponding to the communities merged together. This leads to the greedy stability optimisation (GSO) algorithm given in Algorithm 2 from [24], based on the principle of Algorithm 1. Depending on the boundaries considered for the Markov time the partition returned by the algorithm will vary. Indeed, the larger the Markov time window, the longer in time a partition must keep a high stability value to get a high overall stability value, as defined in equation (10). The Markov time thus acts as a resolution parameter. Compared to Newman's fast algorithm the additional cost of stability computation and mem- ory requirement is proportional to the number of times considered in the Markov time window. For each time t considered in the computation, a matrix et must be computed and kept in mem- ory. Let n be the number of nodes in a network, m the number of edges and s the number of time steps required for stability computation. The number of merge operations needed to terminate are n − 1. Each merging operation requires to iterate through all edges, hence m times, and for each edge to compute the stability variation s times. The computation of each ∆Q can be per- formed in constant time. In a non optimised implementation the merging of communities i and j can be performed in n steps, hence the complexity of the algorithm would be O(n(m.s + n)). However the merging of communities i and j really consists in adding the edges of community j to i and then delete j. To do so there is one operation per edge. The size of a cluster at iteration i is given by: (18) (19) (20) (21) and therefore the average cluster size over all iterations is cs(i) = n n − i n(cid:88) ≈ ln(n) + γ 1 i · n(cid:88) ¯cs = 1 n cs(i) = i=1 i=1 7 Algorithm 2 Greedy Stability Optimisation (GSO) algorithm taking in input an adjacency matrix and a window of Markov times, and returning a partition and its stability value. Divide in as many communities as there are nodes Set this partition as current partition Ccur and as best known partition C Set its stability value as best known stability Q Set its stability vector (stability values at each Markov time) as current stability vector QV Compute initial community matrix e Compute initial community matrices at Markov times et while 2 communities at least are left in current partition: length(e) > 1 do Initialise best loop stability Qloop ← −∞ for all pair of communities with edges linking them: eij > 0 do for all times t in time window do Compute dQV (t) ← ∆QSt end for Compute partition stability vector: QVtmp ← QV + dQV Compute partition stability value by taking its minimum value: Qtmp ← min(QVtmp) if current stability is the best of the loop: Qtmp > Qloop then Qloop ← Qtmp QVloop ← QVtmp Keep in memory best pair of communities (i, j) end if end for Compute Ccur by merging the communities i and j Update matrices e and et by merging rows i and j and columns i and j Set current stability vector to best loop stability vector: QV ← QVloop if best loop stability higher than best known stability: Qloop > Q then Q ← Qloop C ← Ccur end if end while return best found partition C and its stability Q where γ is the Euler-Mascheroni constant. As the number of edges is bounded by the number of nodes squared, the algorithm can be implemented with the complexity O(n(m.s + ln2(n))) provided the appropriate data structures are used to exploit this, as discussed in [5]. As s should be a low value, the complexity is O(n(m + ln2(n))). It should however be noted that the technique used to compute the matrices M t can bring additional complexity, whether using a naive approach, a fast matrix multiplication algorithm such as Strassen's [44], other data structures and/or approximation techniques. The optimisation of this task will not be addressed in this work. 3.3 Analysis Frequently in the literature modularity is used to rank the quality of algorithms. However as this work optimises stability, using modularity is inappropriate. Modularity has also several draw- backs as previously mentioned (e.g. random-graphs can have high modularity [15], modularity has a resolution limit [11]). Finally as our method enables multi-scale network analysis and thus considers several relevant partitions per network, modularity is ill-suited. In the absence of any knowledge of a network, the analyst would look for partitions that are consistently found on some intervals of the Markov time. These will be called stable partitions. First, such partitions should have the same number of communities. (In some cases one may look for very similar partitions and not identical ones though.) However, while successive partitions for successive Markov times are likely to have some similarity, the number of communities does not necessarily reflect the actual partitioning of a network. Therefore an additional measure that 8 considers the actual information contained in the partitions is required in order to better identify stable partitions. This can be achieved by using the normalised mutual information (NMI) [12] which has proved to be reliable [7]. The NMI between two partitions A and B is defined as: (cid:80)cB n ) +(cid:80)cB j=1 Cijlog( Cij·n Ci∗C∗j ) j=1 C∗jlog( C∗j n ) −2(cid:80)cA (cid:80)cA i=1 i=1 Ci∗log( Ci∗ N M I(A, B) = where n is the number of nodes, cA is the number of communities in A, cB is the number of communities in B, C is the confusion matrix where Cij is the number of nodes of community i in A that are in community j in B, Ci∗ is the sum of elements in row i, C∗j is the sum of elements in column j. If A = B then N M I(A, B) = 1. On the contrary if A and B are completely different (including if A or B classifies everything in one single cluster) then N M I(A, B) = 0. Computing the NMI between successive partitions (i.e. one at time t and the next one at time t + dt) provides additional information beyond the number of communities found in each partition and enables a fine detection of stable partitions. 4 Heuristics 4.1 Time-window Optimisation As investigated in [24] a large time window does not imply many intermediate time values. While the full mathematical definition of stability considers all Markov times in a given interval, all Markov times may not be crucial to a good (or even exact) approximation of stability. The fastest way to approximate stability is to compute it with only one Markov time value. As stability tends to decrease as the Markov time increases, we are seeking whether the following approximation can be made: QS = min 0≤t≤τ trace(Rt) ≈ trace(Rτ ) (22) The need for considering consecutive time values in the computation of stability addresses an issue encountered within random walks. Considering for instance a graph with three nodes a, b and c with an edge between nodes a and b and between nodes b and c. Using a Markov time of 2 only (i.e. a random walk of 2 steps with no consideration of the first step) starting from a there would be no transition between a and b as after one step from a the random walker would be in b and then it could only go back to a or walk to c. However, the more densely connected the clusters, the less likely this situation is to happen as many paths can be taken to reach each node. The work from [24] showed that optimising stability based on equation (22) provides results very similar in accuracy to those found by optimising the full stability (i.e. using a finely sampled time-window) while providing a significant gain in speed. In order to exploit these results algorithmically, the greedy stabilisation at one Markov time becomes very similar to a modularity optimisation algorithm. The input time window becomes a single time value as opposed to an array of time values and the computation of the stability can be simplified, as given in Algorithm 3. 4.2 Randomisation Another approach for speed optimisation is to randomise the aggregation algorithm. Considering Algorithm 2, looking for the best pair in all the possible pairs in the network is time consuming. The merging of two communities affects the stability based only on the local structure affected 9 Algorithm 3 Modification of the Greedy Stabilisation Algorithm algorithm from Algorithm 2 optimised for using a single Markov time value. Divide in as many communities as there are nodes Set this partition as current partition Ccur and as best known partition C Set its stability value as best known stability Q and current partition stability Qcur Compute initial community matrices e and et while 2 communities at least are left in current partition: length(e) > 1 do Initialise best loop stability variation ∆Qloop ← −∞ for all pair of communities with edges linking them: eij > 0 do Compute local variation of stability ∆Qtmp if current stability variation is the best of the loop: ∆Qtmp > ∆Qloop then ∆Qloop = ∆Qtmp Keep in memory best pair of communities (i, j) end if end for Compute Ccur by merging the communities i and j Update matrices e and et by merging rows i and j and columns i and j Add to current stability the best loop stability variation: Qcur ← Qcur + ∆Qloop if current stability higher than best known stability: Qcur > Q then Q ← Qcur C ← Ccur end if end while return best found partition C and its stability Q by this change. Therefore looking at all the possible pairs to merge in the entire network at each pass may not always be necessary and yet is significantly time consuming. The most important at each pass is rather to select the best pair within a set of pairs affecting the same area in a network. This idea has been developed in [34] for modularity optimisation. The same principle can be adapted to stability optimisation, as given in Algorithm 4 below. At each pass the algorithm selects k communities, with k a parameter to be set, and merges the best pair found within these k communities instead of within the whole network. We set here k using the best values found in [34]: k = 1 during the first half of the community merging process in Algorithm 2 and then taking k = 2 for the second half. This approach significantly reduces the time required for each pass. Before the complexity of a pass was O(m) as each pass was iterating over all edges. With this heuristic each pass takes k communities and checks the edges linking it to other communities. As found earlier, the average cluster size is in O(ln(n)) and the number of edges is thus bound by O(ln2(n)). As a result the complexity of a pass is in O(k · ln2(n)) = O(ln2(n)). Therefore the algorithm complexity becomes O(n · ln2(n)). Another advantage of exploring randomly only a subpart of the graph at each pass is that it enables the formation of clusters concurrently. By considering all pairs throughout the network like in Algorithm 1 or Algorithm 2 there is a risk of formation of large clusters that may absorb vertices rather than allowing the formation of new communities. 4.3 Multi-step Aggregation In [42] the authors suggest a different way to avoid the formation of large clusters by using a multi- step approach that merges several pairs of candidate clusters per pass, thus greatly promoting the concurrent formation of clusters. The method has also the advantage of reducing the number of passes from n − 1 to n−1 k with k the number of cluster merging per pass. The same principle can be applied for stability optimisation, as given in Algorithm 5. The complexity is therefore similar but with a k division factor which with the time optimised version is O( n k (m + ln2(n))). While in the same order of complexity as the non-optimised version the k factor enables a gain 10 Algorithm 4 Randomised Greedy Stability Optimisation (RGSO) algorithm taking in input an adjacency matrix and a window of Markov times, and returning a partition and its stability value. Divide in as many communities as there are nodes Set this partition as current partition Ccur and as best known partition C Set its stability value as best known stability Q Set its stability vector (stability values at each Markov time) as current stability vector QV Compute initial community matrix e Compute initial community matrices at Markov times et while 2 communities at least are left in current partition: length(e) > 1 do Initialise best loop stability Qloop ← −∞ if nb lines(e) < nb lines(adj)/2 then k = 2 else k = 1 end if for c = 1 to k do Select random community i (different from previously picked if k > 1) for all communities j sharing edges with i do for all times t in time window do Compute dQV (t) ← ∆QSt end for Compute partition stability vector: QVtmp ← QV + dQV Compute partition stability value by taking its minimum value: Qtmp ← min(QVtmp) if current stability is the best of the loop: Qtmp > Qloop then Qloop ← Qtmp QVloop ← QVtmp Keep in memory best pair of communities (i, j) end if end for end for Compute Ccur by merging the communities i and j Update matrices e and et by merging rows i and j and columns i and j Set current stability vector to best loop stability vector: QV ← QVloop if best loop stability higher than best known stability: Qloop > Q then Q ← Qloop C ← Ccur end if end while return best found partition C and its stability Q in overall execution time that can be significant. One drawback of this method when optimising modularity is that one cannot know in advance the best value for the parameter k [42]. However as we are using stability and not modularity, we are mainly interested in the behaviour when reaching stable partitions. One insight is that, compared to community detection using modularity, the detection of stable partitions may be less sensitive to the tuning of k as these partitions are persistent through a window of time and therefore already show a form of robustness to parameter setup. This is investigated in the following series of experiments. 4.4 Time-window Optimisation combined with the Louvain Method The previous optimisation methods explored a variation of the greedy stability optimisation where only one Markov time is considered instead of a time window. In addition it has been shown that optimising stability for time t is equivalent to optimising modularity of the graph with adjacency matrix At, as given in equation (17). Therefore using Newman's greedy modularity 11 Algorithm 5 Multi-Step Greedy Stability Optimisation (MSGSO) algorithm taking in input an adjacency matrix, a window of Markov times and a number of pairs k to merge per iteration, and returning a partition and its stability value. Divide in as many communities as there are nodes Set this partition as current partition Ccur and as best known partition C Set its stability value as best known stability Q Set its stability vector (stability values at each Markov time) as current stability vector QV Compute initial community matrix e Compute initial community matrices at Markov times et while 2 communities at least are left in current partition: length(e) > 1 do Set the pair list to an empty list for all pair of communities with edges linking them: eij > 0 do for all times t in time window do Compute dQV (t) ← ∆QSt end for Compute partition stability vector: QVtmp ← QV + dQV Compute partition stability value by taking its minimum value: Qtmp ← min(QVtmp) if current stability is the best of the loop: Qtmp > Qloop then Qloop ← Qtmp QVloop ← QVtmp Add the pair (i, j) with the values Qtmp and dQV to the pair list end if end for Sort the pair list by their stability values Qtmp for k times (the number of pairs to merge per iteration) do Select best pair (i, j) in the pair list Compute Ccur by merging the communities i and j Update matrices e and et by merging rows i and j and columns i and j Set current stability vector to best loop stability vector: QV ← QVloop if best loop stability higher than best known stability: Qloop > Q then Q ← Qloop C ← Ccur end if Remove from the pair list all pairs that share a node with the selected pair end for end while return best found partition C and its stability Q optimisation would be equivalent to using Algorithm 2. Yet, instead of Newman's algorithm any other modularity optimisation method can potentially be used, such as the Louvain method [4] previously mentioned and interesting for its execution speed. The Markov time thus remains the resolution parameter to compute the matrix At but enables the Louvain method to process the resulting network without modifying its code. This offers an alternative algorithm to optimise stability. Comparing the results of this combination with the other methods to optimise stability can also enable to evaluate how robust are the detected stable partitions with respect to the aggregation algorithm in addition to the Markov time. 5 Experiments This section presents sets of experiments that were run to assess the methods presented in this paper. The community detection algorithms were implemented in Matlab1 except for the code of 1The code developed for this work is available on request. More can also be found at http://www.elemartelot. org. 12 the Louvain method downloaded from the authors website2 (we used their hybrid C++ Matlab implementation). All experiments were run using Matlab R2011a under MacOS X on an iMac 3.06GHz Intel Core i3. 5.1 Test Networks The networks considered for the experiments are two synthetic and four real-world data networks3 that have been used as benchmarks in the literature to assess community detection algorithms. The networks have been chosen for their respective properties (e.g. multi-scale, scale-free) and popularity that enable an assessment of our method and comparisons with other approaches. While selecting very large networks can demonstrate speed efficiency, the results are commonly ranked using modularity which as previously discussed is not suitable for this work. We therefore deemed appropriate to use here networks of smaller size with some knowledge of their structure or content used for the evaluation of the results, similarly to what has been done in related work [39, 3, 4, 40]. The following two synthetic datasets are used: Ravasz and Barab´asi's scale-free hierarchical network: This network was presented in [38] and defines a hierarchical network of 125 nodes as shown in Figure 1(a). It is hereafter referred to as RB-125. The network is built iteratively from a small cluster of 5 densely linked nodes. A node at the centre of a square is connected to 4 others at the corners of the square themselves also connected to their neighbours. Then 4 replicas of this cluster are generated and placed around the first one, producing a 25 nodes network. The centre of the central cluster is linked to the corner nodes of the other clusters. This process is repeated again to produce the 125 nodes network. The structure can be seen as 25 clusters of 5 nodes or 5 clusters of 25 nodes. Arenas et al's homogeneous in degree network: This network taken from [2] and named H13-4 is a two hierarchy levels network of 256 nodes organised as follow. 13 edges are distributed between the nodes of each of the 16 communities of the first level (internal community) formed of 16 nodes each. 4 edges are distributed between nodes of each of the 4 communities of the second level (external community) formed of 64 nodes each. 1 edge per node links it with any community of the rest of the network. The network is presented in Figure 1(b). The following real-data networks are used: Zachary's karate club: This network is a social network of friendships between 34 members of a karate club at a US university in 1970 [45]. Following a dispute the network was divided into 2 groups between the club's administrator and the club's instructor. The dispute ended in the instructor creating his own club and taking about half of the initial club with him. The network considered here is the unweighted version of the network, and is undirected. The network can hence be divided into 2 main communities, as shown in Figure 2(a). A division into 4 communities has also been acknowledged [29]. Lusseau et al's dolphins social network: This network is an undirected social network resulting from observations of a community of 62 bottle-nose dolphins over a period of 7 years [28]. Nodes represent dolphins and edges represent frequent associations between dolphin pairs occurring more often than expected by chance. Analysis of the data revealed 2 main groups as shown in Figure 2(b) and a further division can be made into 4 groups [27]. American college football dataset: This dataset contains the network of American football games between Division I colleges during regular season Fall 2000 [13]. The 115 nodes represent teams and the edges represent games between 2 teams. The teams are divided into 12 groups containing around 8-12 teams each and games are more frequent between members of the same 2http://sites.google.com/site/findcommunities/ 3Available from http://www-personal.umich.edu/~mejn/netdata/ 13 (a) RB-125 (b) H13-4 Figure 1: (a) Hierarchical scale free network generated in 3 steps producing 125 nodes at step 3 [38]. (b) Network presented in [2] made of 256 nodes organised in two hierarchical levels with 16 communities of 16 nodes for the first level and 4 communities of 64 nodes for the second level. group (teams play on average seven intragroup games and four intergroup games). Also teams that are geographically close but belong to different groups are more likely to play one another than teams separated by a large distance. Therefore in this dataset the groups can be considered as known communities as their nodes should be more interconnected than with the rest of the network. Les Mis´erables: This dataset taken from [19] represents the co-appearance of 77 characters in Victor Hugo's novel Les Mis´erables. Two nodes share an edge if the corresponding characters appear in a same chapter of the book. The values on the edges are the number of such co- appearances. (a) Karate network (b) Dolphins network (c) Les Mis´erables network Figure 2: Two real-world data networks: (a) Zachary's karate club network [45], (b) Lusseau's dolphins network [28], (c) Characters co-appearance network taken from the novel Les Mis´erables. The colours represent different identified communities. 14 SN89PLSN100Oscar 5.2 Assessment and Comparison with Other Approaches The first set of experiments assesses the greedy stability optimisation method without heuristic (as presented in Section 3). The method is tested on the one hand against various datasets and on the other hand against other relevant approaches. The methods used for comparison are Newman's fast algorithm [30], Danon et al's method [6], the Louvain method [4], Infomap [41], Reichardt and Bornholdt's method [39], Arenas et al's method [3] and Ronhovde and Nussinov's method [40]. Both Reichardt and Bornholdt's, Arenas et al's and Ronhovde and Nussinov's methods use a resolution parameter that enables multi-scale community detection based on this parameter. The Louvain method also returns a succession of partitions (not tuneable). The other methods are not multi-scale and hence return only one partition. First to assess and compare the algorithms used in this work we use the established knowledge of the communities for each network to assess the algorithms results. We then use the normalised mutual information to analyse in more detail the stability optimisation results. 5.2.1 Comparative Results The networks are analysed by the seven aforementioned community detection methods (4 non multi-scale, 3 multi-scale) and our stability optimisation algorithm for which both discrete and continuous Markov time versions are used. Table 1 provides the results of the community detection methods that have no resolution parameter. The results show that these methods do not necessarily find the most meaningful partitions and that different methods can identify different partitions. Yet an unexpected result is not necessarily meaningless. For example in the RB-125 network, the central node of the central community has many more connections than the other nodes and more connections outside its community than inside. Therefore this node can be seen as a community on its own. While it is not the initially expected answer, this partition is relevant and reflects the situation of the node according to some optimisation criteria. Table 1: Number of detected communities by Newman's fast algorithm, Danon et al's, Louvain and InfoMap methods on the presented networks. The identified division(s) known for these networks are also indicated ('-' indicates that there is no clear a priori knowledge). The Louvain method returns a hierarchy of partitions, given in order. Algorithm RB-125 H13-4 Karate Dolphins Football Miserables Fast Newman Danon Louvain InfoMap Identified 6 6 4 4 30, 10, 6 12, 4 22 5, 25 13 4, 16 3 4 6, 4 3 2, 4 4 4 10, 5 6 2, 4 6 6 12, 10 12 12 5 6 9, 6 10 - Figure 3 plots the results of the tuneable methods along their respective parameter values. For Reichardt and Bornholdt's as well as Ronhovde and Nussinov's algorithm, the x-axis represents 10γ. For Arenas et al's the x-axis represents r − r0 where r0 = − m n with m the number of edges and n the number of nodes. (See [3] for details. The authors use the lower bound rasymp = − 2m n but we found experimentally that values of r below r0 were irrelevant.) The value of r0 is calculated for each network. For our algorithm, the x-axis represents the Markov time t. The time window sampling is done from time 0 to 100 with a step of 0.05 between within [0, 2], a 15 step of 0.25 within [2, 10] and a step of 1 afterwards. The steps between successive values of the parameter are 0.05 for Arenas and 0.05 10 = 0.005 for Reichardt and Bornholdt's and Ronhovde and Nussinov's methods (as the x-axis represents 10γ). (a) RB-125 network (b) H13-4 network (c) Karate club network (d) Dolphins social network (e) American football network (f) Les Mis´erables characters network Figure 3: Number of partitions returned by Reichardt and Bornholdt's, Arenas et al's, Ronhovde and Nussinov's and our stability optimisation methods. The x-axis represents 10γ for Reichardt and Bornholdt's and Ronhovde and Nussinov's methods, r − r0 for Arenas et al's and t for ours. The dotted horizontal lines indicate known partitions size: (a) 5 and 25, (b) 4 and 16, (c) 2 and 4, (d) 2 and 4, (e) 12. 16 Reichardt and BornholdtArenas et alsRonhovde and NussinovGSO [0,t] DiscreteGSO [0,t] Continuous10−1100101102100101102ParameterNumber of Communities10−1100101102100101102ParameterNumber of Communities10−1100101102100101102ParameterNumber of Communities10−1100101102100101102ParameterNumber of Communities10−1100101102100101102ParameterNumber of Communities10−1100101102100101102ParameterNumber of Communities Considering only stability optimisation we can observe that the two Markov processes behave in a very similar way. For this reason we will only comment on the discrete time version, the same being true for the other model. From Figure 3 it can be observed that the behaviour of our method is opposite to those of Reichardt and Bornholdt's and Arenas et al's methods and also very different from Ronhovde and Nussinov's method. At low values of t partitions are small (at t = 0 our method finds as many partitions as there are nodes). Then as t increases, partitions tend to become larger. Conversely, the three other methods start by partitioning in large clusters when their parameter is minimal. Then they find finer partitions as their parameter increases. However it is noteworthy that the progression of Ronhovde and Nussinov's method can be different from the two others, for instance in Figure 4(d) or Figure 3(f). Considering Figure 3(a) for instance, after t = 4, the result of our algorithm remains stable on 5 clusters that represent the most stable partition. A partition in 6 elements can also be found and corresponds to the 5 large communities with the centre of the central community in a separate community. Also, when t ∈ [0.1, 0.2] the algorithm finds a partition in 26 communities (25 small communities plus central node on its own). Arenas et al's method detects the 5 communities around about r − r0 ∈ [1.5, 2.5]. Then it grows to stabilise on 25 communities around r− r0 ∈ [9, 25] and then goes up to 26 communities and more. Reichardt and Bornholdt's method stabilises around 5 communities around γ = [0.5, 0.9] and around 26 communities around γ = 3.6 and onwards. (Note that it may still go higher for greater values of γ.) Ronhovde and Nussinov's method mainly stabilises on a partition of size 25 but also detects several other partitions. Looking at the stability optimisation and Reichardt et al's method compared to Arenas et al's method, the two former tend to stabilise at intermediate partitions of a size 1 larger than those detected by the latter. By using the resistance parameter r, Arenas et al's method alters the impact of edge weights across the network. In this instance this blends the central node into the small central community. However when considering the partition in 25 communities, this central node has 4 connections with all communities, including its own. By adding it to any community, this community would gain 4 edges pointing inside and 80 pointing outside. Therefore it is ambiguous whether this node should belong to the small central community or any of the others. This is handled in our method by keeping this node in a separate community until it is clear that it belongs to the central community of the 5 communities partition (it then shares 20 edges inside its own community and 16 edges with each of the 4 others). On Figure 3(b), the intended partitions in 16 and then 4 communities are clearly detected. As expected the most stable partition is the partition in 4 communities, as indicated by the stability optimisation methods with the long stretch of time settling on this partition compared to the shorter plateau for 16 communities. Considering Figure 3(c), our algorithm quickly settles on the 2 expected partitions (visual- isations of the found partition confirm that this is the same as Figure 2(a)), found by Arenas et al's for about r − r0 ∈ [0.7, 2] and by Reichardt et al's for about γ ∈ [0.4, 0.8]. It also con- sistently settles beforehand on the partition in 4 communities, revealing the relevance of this partition, as suggested by other analysis [29]. Ronhovde and Nussinov's method mainly misses these communities. Regarding Figure 3(d), our algorithm settles on 2 partitions, as expected from the results [27] that analysed the dataset using modularity. Arenas et al's solution for r − r0 ∈ [0.7, 1.2] and Reichardt et al's solution for γ ∈ [0.2, 0.5] corresponds to the partition of [27]. Our algorithm also stops over on 4 partitions for t ∈ [0.5, 3[ \1.5 which is another relevant division size of the network [27]. Ronhovde and Nussinov's method misses these communities. On Figure 3(e) we can observe several scales of relevance. Based on the knowledge of the teams distribution, a community of size 12 is expected. Such partition is detected at an early time (t = 0.3) with our method and is the first plateau. A normalised mutual information 17 value of 0.919 compared with the 12 known groups can be found by our method on this plateau. Most of the nodes are therefore placed into the right communities. Regarding the remaining nodes, [18] explains that some nodes do not fit in the expected classification due to a loose intra- community connectivity and more connections out of the community. Therefore other divisions can also be of relevance. While stability settles on a few plateaus the other methods tend to detect many intermediate partitions on short intervals. As the time grows communities also grow bigger and get more stable. A partition into 3 communities is consistently identified followed by a partition with 2 communities (both also detected by Ronhovde and Nussinov's method). Analysing the former we find that it reflects the geographical locations of the teams, reflecting the fact that teams located geographically closer are more likely to play one another. This partition separates the country roughly into West, South-east and North-east. Then the partition with 2 communities divides the country into West and East. Therefore the successive stable partitions reflect the organisation of the teams, first locally with the 12 communities partition and then nationally with the partitions in 3 and 2 communities (other partitions in between may also reflect smaller geographical divisions). Another analysis could consider the large and stable communities (e.g. of size 2 or 3) and sub-partition them to analyse the games distribution at a smaller geographical scale. Analysing the network of the characters from Les Mis´erables several divisions appear. Con- sidering stability optimisation 2 main partitions appear, as shown on Figure 3(f), while the other methods detect more partitions on short intervals. The first one consistently identified by our method contains 5 communities and the second one contains 3 communities. In the partition into 5 communities the first is a central community containing most of the main plot characters such as Valjean, Javert, Cosette, Marius or the Thenardier. The second community relates to the story of Fantine, the third one relates to Mgr Myriel, the fourth one relates to Valjean's story as a prisoner and contains other convicts. The fifth one relates to Gavroche, another main character. Considering the partition in 3 communities, the central community is merged with the fourth community (convicts, judge, etc) and the third community. The community mainly represents characters connected to Valjean at a moment of his story. The second community remains as well as the fifth one with Marius now part of it. Overall, the detection of stable partition is clearer than for the other methods. Reichardt and Bornholdt's and Arenas et al's methods uncover some partitions but it is not clear which one is most relevant. Ronhovde and Nussinov's method misses the partitions. These results highlight the fact that different methods provide different approaches and solu- tions to the problem of community partitions. Consistent or stable partitions are used to identify relevant divisions in a network. (Arenas et al's had a similar view considering the persistence of some partitions when changing the resolution scale in their method [3].). Considering the three tuneable methods the results show that stability optimisation tends to stabilise on fewer parti- tions and often more consistently than the other two methods. This is useful to identify most relevant partitions and hence inform about network structure in the absence of a priori knowl- edge. Once a stable partition is found, it should inform accurately about the structure of the network and can be considered relevant. Each community could then potentially be submitted for further partitioning. 5.2.2 Stable Partitions Analysis As discussed previously, the consistency of the number of communities over successive Markov times is not sufficient to guarantee stable partitions. We introduced the use of the NMI in order to inform further about the similarity of information contained within partitions found at successive time values. Figure 4 shows for the test networks the stability optimisation curve 18 for the Markov chain model along with the NMI between partitions found successively. We can (a) RB-125 network (b) H13-4 network (c) Karate club network (d) Dolphins social network (e) American football network (f) Les Mis´erables characters network Figure 4: Number of partitions and normalised mutual information between two successive partitions for the stability optimisation methods using the discrete time (Markov chain) model. observe that for the time values where the partitions of relevance are found, the associated NMI reaches 1 or almost. In Figure 4(a) the NMI stabilises at 1 where the number of communities is set on 5 and 26 (as discussed above), thus indicating stable partitions. For the hierarchical network the results from Figure 4(b) show that the NMI supports the detection in 4 and 16 communities. Note that for the partition in 16 communities, the NMI reaches 1 for a smaller time interval than the one during which the partition size is stable at 16. This highlights the need for a precise measure such as NMI to detect accurately stable partitions. Figure 4(c) and Figure 4(d) clearly show for the karate and dolphins networks that the most stable partitions 19 10−1100101102100101102Nb. Communities10−11001011020.80.91Markov timeNMI10−1100101102100102104Nb. Communities10−11001011020.80.91Markov timeNMI10−1100101102100101102Nb. Communities10−11001011020.80.91Markov timeNMI10−1100101102100101102Nb. Communities10−11001011020.80.91Markov timeNMI10−1100101102100102104Nb. Communities10−11001011020.80.91Markov timeNMI10−1100101102100101102Nb. Communities10−11001011020.80.91Markov timeNMI are of size 2 even though size 3 and 4 are also detected with stable partition size and NMI reaching 1. The american football network has a partition in 12 reaching a NMI very close to 1, as shown in Figure 4(e), indicating an almost stable partition (few nodes differ while the core of the partition is the same). However the most stable partitions are found with a smaller amount of communities. Regarding the characters network from Les Mis´erables the results shown in Figure 4(f) support the relevance of the partition in 5 communities identified and commented above. The NMI is indeed stable at 1 for a large time window for this partition. 5.3 Heuristics Comparison As both the Markov chain (discrete time) and the continuous time models behave similarly we present only the results of the Markov chain model (the same results hold for the continuous time model). 5.3.1 Time-window Optimisation This set of experiments compares the results obtained using a single Markov time value instead of a time-window. For the time optimised method, we use both the algorithm from Algorithm 3 and the hybrid method using the Louvain method to optimise modularity of the graph derived for each time t. They are compared against the initial algorithm from Algorithm 2. The results are shown in Figure 5. We can observe that the difference between the GSO runs considering the time window and the GSO runs considering only its upper bound is minimal. The curves are similar or overlapping thus suggesting that the approximation from equation (22) holds. The optimisation performed using the upper time value only combined with the Louvain method (LSO) also provides very similar results. It is noteworthy that while the LSO method may have a curve more different than the two others, the stable partitions detected are the same thus suggesting that the stability of partitions is robust to the optimisation algorithm. 5.3.2 Randomisation The randomised version with and without time-optimisation are compared against the GSO. For the randomised version, each configuration was run 100 times and the results displayed are averaged over these runs. The results are shown in Figure 6. As can be observed the randomised versions with and without time-optimisation behave similarly. Also the randomised versions provide on average results similar to the initial GSO algorithm. We can observe that in some cases, mainly regarding the synthetic networks, the average number of partitions can remain slightly above the partition sizes given by the initial GSO algorithm. Analysing the results shows that some nodes can end up isolated due to the random process. Also some small communities may not join a larger community they would be part of according to the initial GSO version's results. Taking as example the RB-125 network and considering the time up to 10, some runs where 5 communities are expected would uncover more than 5 communities. In these runs, some of the 5 five large communities (in 25 nodes) have sub communities of 5 nodes detected separately or sometimes an isolated node. The randomised method therefore provides a faster GSO algorithm but sometimes to the expense of accuracy. A post-processing step could be used to check irregular classifications and put the isolated nodes in the neighbour community which leads to the best increase in stability. This can be done using an algorithm similar to the refinement process from [32] where each node on the edge between two communities is put in the other community to test if this move would result in a modularity increase (here it would be stability increase). This method was already an adaptation of the Kernighan-Lin algorithm [17] that aims at minimising the total edge weights across clusters 20 (a) RB-125 network (b) H13-4 network (c) Karate club network (d) Dolphins social network (e) American football network (f) Les Mis´erables characters network Figure 5: Number of partitions returned by the GSO and the time-optimised GSO methods (using the Markov chain model): in red and full line with circle markers is the regular GSO from Algorithm 2; in green and dashed line with square markers is the time-optimised GSO from Algorithm 3 using only one time value; in blue dotted and dashed line with triangle markers is the time-optimised version using the Louvain method (LSO). by repeatedly swapping nodes belonging to different clusters that yields a maximum weight cut reduction. In our case here, one pass on selected nodes (isolated or small communities) could be sufficient to classify correctly all the isolated nodes. Therefore this post-processing step would be a minimal computational overhead. Another way, more traditional, to detect anomalies can be to perform several runs and keep for each node the classification the most consistently found over these runs. 21 10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities (a) RB-125 network (b) H13-4 network (c) Karate club network (d) Dolphins social network (e) American football network (f) Les Mis´erables characters network Figure 6: Number of partitions returned by the GSO and randomised GSO methods (Markov chain model): in red and full line with circle markers is the GSO from Algorithm 2; in green and dashed line with '+' markers is the randomised version; in blue dotted and dashed line with '×' markers is the randomised time-optimised version. A pre-processing step could also be applied to the network by removing all the nodes having only one neighbour. Indeed, considering equation (18) a node with one edge that is added to the community of its only neighbour can only provide a positive ∆QS, hence an increase in stability. Therefore these nodes can be removed at the beginning thus reducing the size of the network submitted for partitioning. Once community detection has been performed these nodes can be added again and join their neighbour's community. This pre-processing step can be used for all the techniques presented here in order to reduce the problem space. 22 10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities 5.3.3 Multi-step Aggregation The multi-step version with values of k ∈ {2, 5, 10} are compared against the GSO. The results are given in Figure 7. (a) RB-125 network (b) H13-4 network (c) Karate club network (d) Dolphins social network (e) American football network (f) Les Mis´erables characters network Figure 7: Number of partitions returned by the regular and multi-step GSO methods (Markov chain model). The red and full line with circle markers is the regular GSO from Algorithm 2. The remaining curves are the multi-step versions: in green and dashed line with '+' markers is with k = 2; in blue and dotted and dashed line with '×' markers is with k = 5; in cyan and dotted line with '*' marker is with k = 10. 23 10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities10−1100101102100101102Markov timeNumber of Communities From these results, we can observe that the value of k has little impact on the result and especially on stable partitions. As only non-overlapping pairs are used in the algorithm, each step uses at most k pairs for aggregation that do not overlap and are thus unlikely to compete against each other. Using a value of k = 10 is not affecting the quality of the result while speeding up the aggregation process by merging up to 10 pairs per loop. The results seem to indicate that the value of k can be chosen fairly large. A generalisation with no parameter could consider at each step half (or any other subset) of the pairs and merge the ones that do not overlap. Note that this heuristic could also be run with a time-optimised setup using only one Markov time value. It could also be combined with randomisation. All heuristics could potentially be blended together. However we cannot present all the possible combinations. We investigated several usages of all methods in order to provide concrete results and analysis of their respective behaviour. Considering those results we can expect the time-optimised version of any method to behave similarly to the GSO time-window setup. Similarly randomisation of any method will speed it up but may lead to a few isolated nodes in some runs that a post-processing step can simply detect and put in the right community. 5.3.4 Running Time Comparison To illustrate the difference in running time between the various heuristics, Figure 8 provides for each method derived from the initial GSO algorithm from Algorithm 2 the average running time over 10 runs on the RB-125. The methods used are initial GSO, randomised GSO, multi-step GSO with k values taken at 2, 5, 10 and 25. All are run with and without the time-optimisation heuristic. Figure 8: Running time of the various heuristics applied to the initial GSO algorithm on the RB-125 network (using the Markov chain model). Each run is performed 10 times and the time provided is the average running time of these runs. While all the setups using a sampled time-window take longer as the Markov time grows the time-optimised versions (using one one Markov time) remain constant in execution time. Therefore the computation of the matrices M t does not affect the processing time as t grows. Considering all the sampled time-window runs or all the time-optimised runs, we can observe 24 10−110010110200.10.20.30.40.50.60.70.8Markov timeRunning time (s) GSO [0,t]GSO tRGSO [0,t]RGSO tMSGSO k=2 [0,t]MSGSO k=2 tMSGSO k=5 [0,t]MSGSO k=5 tMSGSO k=10 [0,t]MSGSO k=10 tMSGSO k=25 [0,t]MSGSO k=25 t that the randomised version is clearly the fastest of all. Regarding the multi-step models, we can observe that for values of k greater than 5, the execution speed is faster than the initial GSO algorithm. The greater k, the faster the execution. 6 Detecting Overlapping Communities 6.1 Method In order to apply the results of this work to overlapping communities, one can consider the line graph (or edge graph) [16] of the original network as the data to process rather than the network itself. Considering a graph G with N its set of nodes and E its set of edges: G = (N, E) with E ⊂ N × N the line graph L(G) of an undirected graph G is the graph that represents the adjacencies between edges of G. Therefore the nodes of L(G) are the edges of G. L(G) = (E, F ) with F ⊂ E × E ≡ (N × N ) × (N × N ) Two vertices of L(G) are adjacent if and only if their corresponding edges are adjacent in G. (v1, v2), (v3, v4) ∈ F ⇔ vi = vj for one i ∈ 1, 2 and j ∈ 3, 4 This idea has already been used in previous work [36, 37, 9] and is similar to the work on link communities from [1]. Indeed by working with L(G) the community detection is performed on the edges and we are thus looking at edges (or links) communities. In addition, applying this to stability optimisation enables detecting multi-scale edge communities. 6.2 Assessement In order to illustrate the concept, we reuse Zachary's karate club network as it provides a social network where people can potentially belong to several communities. We also use a network of politics books from [20]. The dataset contains 105 books about US politics published around the time of the 2004 presidential election and sold by Amazon.com. The nodes represent the books and the edges between nodes represent frequent co-purchasing of books by the same buyers. A suggestion of book labels has been given in [32] according to their political tendency: liberal, neutral, or conservative. The overlapping community detection seems to be more relevant than a crisp community detection approach as books on political tendencies like many fuzzy notions may sometimes share features and thus overlap. A book can be neutral but still addressing interesting concepts for readers from one side or the other. A book can also be neutral with a tendency to one side or the other. As a result it seems that the expected communities could be the two communities: liberal and conservative, with an overlap for fairly neutral books. The results of the overlapping community detection are presented in Figure 9. We can observe on Figure 9(a) that the most stable partitions are found for times around 1 with 4 communities, and then times after 2 with 2 communities. These results are consistent with the knowledge of the network, and with the results found with previous experiments. In addition they encompass the overlapping information between communities. Figure 10(a) and Figure 10(b) show those two partitions. On Figure 9(b) stable partitions are found between times 1 and 2 with 3 communities, and then mostly after time 7 with 2 communities. Figure 10(d) and Figure 10(e) show those two partitions. 25 (a) Karate club network (b) American politics books network Figure 9: Number of partitions and normalised mutual information between two successive partitions for the stability optimisation methods applied to overlapping communities on the Karate club network and the American politics books network. The results are for the discrete time (Markov chain) model. The neutral labels by Newman shown in red with a star marker in Figure 10(c) are scattered around the two main groups, thus suggesting that neutral books might not reflect a community in the definition accepted here but rather a set of books that can be of interest to both communities. The neutral books on the left are mainly represented by the third edge community, the ones on the right seem to be more densely linked to the blue community, and are thus classified in the blue community. The remaining neutral books can be found on the edge between communities. Using the edge communities, we can provide a classification of books with overlap to indicate shared interests as well as a potential third edge community. The third small community (in red) may reveal a subset of neutral books sharing some features that other neutral books do not, or books belonging to the green community but still neutral enough to be of interest to the blue community. The overall classification we obtain is not exactly the same as the one suggested by Newman but shares strong similarities. These divisions are perfectly sensible with the set being analysed. We can thus verify the hypothesis formulated above about the distribution of books within communities. One asset of this approach is that it is compatible with all the crisp boundaries community detection methods and hence all the work discussed previously above can be used here. One criticism of the approach is that it always finds overlapping node communities on the boundaries between communities as by definition a node that joins two edges belonging to two different edge communities belongs to two associated node communities. While the overlapping between communities seems to be a common feature of social networks, it might not always be the case for all kinds of networks. 7 Conclusion Stability optimisation is a technique aiming at optimising a partition quality measure called stability [8]. This technique was introduced in [24] in its basic form. However further heuristics, optimisations and applications had not been assessed. This work presented a broader investiga- 26 10−1100101102100101102Nb. Communities10−11001011020.80.91Markov timeNMI10−1100101102100101102Nb. Communities10−11001011020.80.91Markov timeNMI (a) 4 communities (b) 2 communities (c) 3 node communities by Newman (d) 3 edge communities (e) 2 edge communities Figure 10: (a) and (b): Partitions in 4 and 2 edge communities on Zachary's karate club network. (c): Partitions of the American politics books network in 3 node communities by Newman; (d) and (e): Partition of the American politics books network into 3 and 2 edge communities. tion of stability as an optimisation criterion for a greedy approach. Stability is a measure that encompasses other measures such as the well known modularity [33]. Its optimisation can be achieved similarly to modularity optimisation but enables accurate multi-scale community detection by the use of Markov time as a resolution parameter. The results showed that stability optimisation accurately detects partitions of relevance by uncovering stable partitions. Several heuristics have been devised and tested to provide speed improvement and alternative ways to build the communities. The first optimisation is based on the reduction of the number of Markov time values used for stability computation. Experiments showed that this heuristic can provide significant gain in speed with no loss of accuracy. The second optimisation is based on a randomisation of the algorithm. Experiments showed that this heuristic provides significant speed performance increase with no significant loss of accuracy. The third heuristic is a multi-step version of the algorithm. Experiments showed that this heuristic can also provide significant gain in speed. It is noteworthy that these three heuristics can also be combined together. Then stability optimisation was also combined with the Louvain method to show that other modularity optimisation methods can be combined with stability optimisation with no overhead. This combination also enabled to study further the robustness of the uncovered partitions, not only to the Markov time, but also to the aggregation algorithm used. Experiments overall demonstrated that stable partitions are uncovered by all stability optimisation methods 27 1234567891011121314151617181920212223242526272829303132333412345678910111213141516171819202122232425262728293031323334 consistently. The results showed that multiple levels of organisations are clearly identified when optimising stability over time. Stability optimisation tends to settle for longer on fewer partitions than other related approaches considered here, thus highlighting better partitions of relevance. Stability optimisation also converges towards large and stable clusters. This behaviour differs from those of other approaches and in the absence of a priori knowledge our method has therefore the advantage of leading to stable and relevant communities from where a deeper analysis could be performed in each community subgraph. Finally stability optimisation was also applied to the detection of overlapping communities by using the line graph of the initial graph [16]. This approach had been used in [36, 37, 9]. However this work enabled the detection of stable edge (or link) communities, thus offering not one but several partitions of relevance based on the uncovered scales. The method was tested on binary undirected graphs as it was deemed appropriate for the purpose of this work but it can equally be applied to directed weighted graphs. Indeed even if the initial adjacency matrix contains only zeros and ones the adjacency matrices At used for stability optimisation are real-valued matrices. References [1] Yong-Yeol Ahn, James P. Bagrow, and Sune Lehmann. Link communities reveal multiscale complexity in networks. Nature, 466:761–764, August 2010. [2] Alex Arenas, Albert D´ıaz-Guilera, and Conrad J. P´erez-Vicente. Synchronization reveals topological scales in complex networks. Physical Review Letters, 96(11):114102, March 2006. [3] Alex Arenas, Alberto Fernandez, and Sergio Gomez. Analysis of the structure of complex networks at different resolution levels. New Journal of Physics, 10:053039, Jan 2008. [4] Vincent D. Blondel, Jean-Loup Guillaume, Renaud Lambiotte, and Etienne Lefebvre. Fast unfolding of communities in large networks. Journal of Statistical Mechanics: Theory and Experiment, 10:1742–5468, 2008. [5] Aaron Clauset, M. E. J. Newman, and Cristopher Moore. Finding community structure in very large networks. Physical Review E, 70:066111, August 2004. [6] Leon Danon, Albert D´ıaz-Guilera, and Alex Arenas. The effect of size heterogeneity on community identification in complex networks. Journal of Statistical Mechanics: Theory and Experiment, 2006(11):P11010, November 2006. ISSN 1742-5468. [7] Leon Danon, Albert D´ıaz-Guilera, Jordi Duch, and Alex Arenas. Comparing community structure identification. Journal of Statistical Mechanics: Theory and Experiment, 2005(9): P09008, September 2005. ISSN 1742-5468. [8] Jean-Charles Delvenne, Sophia N. Yaliraki, and Mauricio Barahona. Stability of graph communities across time scales. PNAS, 107(29):12755–12760, 2010. [9] T. S. Evans and R. Lambiotte. Line graphs, link partitions, and overlapping communities. Phys. Rev. E, 80(1):016105, July 2009. [10] Santo Fortunato. Community detection in graphs. Physics Reports, 486(3-5):75–174, 2010. ISSN 0370-1573. 28 [11] Santo Fortunato and Marc Barth´elemy. Resolution limit in community detection. PNAS, 104(1):36–41, January 2007. [12] Ana L. N. Fred and Anil K. Jain. Robust data clustering. IEEE Computer Society Confer- ence on Computer Vision and Pattern Recognition, 2:128–133, 2003. ISSN 1063-6919. [13] M. Girvan and M. E. J. Newman. Community structure in social and biological networks. PNAS, 99:7821–7826, 2002. [14] Benjamin H. Good, Yves-Alexandre de Montjoye, and Aaron Clauset. Performance of mod- ularity maximization in practical contexts. Physical Review E, 81(4):046106, April 2010. [15] Roger Guimer`a, Marta Sales-Pardo, and Lu´ıs A. Nunes Amaral. Modularity from fluctu- ations in random graphs and complex networks. Physical Review E, 70(2):025101, August 2004. [16] Frank Harary and Roberts Norman. Some properties of line digraphs. Rendiconti del Circolo Matematico di Palermo, 9:161–168, 1960. ISSN 0009-725X. 10.1007/BF02854581. [17] B. W. Kernighan and S. Lin. An efficient heuristic procedure for partitioning graphs. The Bell system technical journal, 49(1):291–307, 1970. [18] Alireza Khadivi, Ali Ajdari Rad, and Martin Hasler. Network community-detection en- hancement by proper weighting. Physical Review E, 83(4):046104, April 2011. [19] Donald Ervin Knuth. The Stanford GraphBase. A Platform for Combinatorial Computing. Addison-Wesley, Reading, MA, 1993. [20] V. Krebs. Books about us politics. http://www.orgnet.com, 2008. [21] Renaud Lambiotte. Multi-scale Modularity in Complex Networks. ArXiv e-prints, April 2010. [22] Renaud Lambiotte, Jean-Charles Delvenne, and Mauricio Barahona. Laplacian Dynamics and Multiscale Modular Structure in Networks. ArXiv e-prints, December 2008. [23] Andrea Lancichinetti and Santo Fortunato. Community detection algorithms: A compara- tive analysis. Physical Review E, 80(5):056117, Nov 2009. [24] Erwan Le Martelot and Chris Hankin. Multi-scale community detection using stability as optimisation criterion in a greedy algorithm. In Proceedings of the 2011 International Conference on Knowledge Discovery and Information Retrieval (KDIR 2011), pages 216– 225, Paris, October 2011. SciTePress. [25] Jure Leskovec, Kevin J. Lang, Anirban Dasgupta, and Michael W. Mahoney. Statistical properties of community structure in large social and information networks. In Proceeding of the 17th international conference on World Wide Web, WWW '08, pages 695–704, New York, NY, USA, 2008. ACM. ISBN 978-1-60558-085-2. [26] Jure Leskovec, Kevin J. Lang, and Michael Mahoney. Empirical comparison of algorithms for network community detection. In Proceedings of the 19th international conference on World wide web, WWW '10, pages 631–640, New York, NY, USA, 2010. ACM. ISBN 978-1-60558-799-8. 29 [27] David Lusseau and M. E. J. Newman. Identifying the role that individual animals play in their social network. Proceedings of the Royal Society London B, 271:S477–S481, 2004. [28] David Lusseau, Karsten Schneider, Oliver J. Boisseau, Patti Haase, Elisabeth Slooten, and Steve M. Dawson. The bottlenose dolphin community of doubtful sound features a large proportion of long-lasting associations. can geographic isolation explain this unique trait? Behavioral Ecology and Sociobiology, 54(4):396–405, 2003. [29] A. Medus, G. Acuna, and C. Dorso. Detection of community structures in networks via global optimization. Physica A: Statistical Mechanics and its Applications, 358(2-4):593– 604, December 2005. ISSN 03784371. [30] M. E. J. Newman. Fast algorithm for detecting community structure in networks. Physical Review E, 69(6):066133, Jun 2004. [31] M. E. J. Newman. Finding community structure in networks using the eigenvectors of matrices. Physical Review E, 74:036104, 2006. [32] M. E. J. Newman. Modularity and community structure in networks. PNAS, 103(23): 8577–8582, June 2006. [33] M. E. J. Newman and M. Girvan. Finding and evaluating community structure in networks. Phisical Review E, 69:026113, February 2004. [34] Michael Ovelgonne, Andreas Geyer-Schulz, and Martin Stein. Randomized greedy modu- larity optimization for group detection in huge social networks. In Proceedings of the 4th SNA-KDD Workshop '10 (SNA-KDD'10), pages 1–9, Washington, DC, USA, July 2010. [35] Gergely Palla, Imre Derenyi, Illes Farkas, and Tamas Vicsek. Uncovering the overlapping community structure of complex networks in nature and society. Nature, 435(7043):814–818, June 2005. ISSN 0028-0836. [36] Jose B. Pereira-Leal, Anton J. Enright, and Christos A. Ouzounis. Detection of functional modules from protein interaction networks. Proteins, 54:49–57, 2004. [37] Clara Pizzuti. Overlapped community detection in complex networks. In Proceedings of the 11th Annual conference on Genetic and evolutionary computation, GECCO '09, pages 859–866, New York, NY, USA, 2009. ACM. ISBN 978-1-60558-325-9. [38] Erzs´ebet Ravasz and Albert L. Barab´asi. Hierarchical organization in complex networks. Physical Review E, 67(2):026112, Feb 2003. [39] J. Reichardt and S. Bornholdt. Statistical mechanics of community detection. Phys Rev E, 74(1 Pt 2):016110, July 2006. ISSN 1539-3755. [40] Peter Ronhovde and Zohar Nussinov. Local resolution-limit-free potts model for community detection. Physical Review E, 81(4):046114, April 2010. [41] Martin Rosvall and Carl T. Bergstrom. Maps of random walks on complex networks reveal community structure. Proceedings of the National Academy of Sciences, 105(4):1118–1123, 2008. [42] Philipp Schuetz and Amedeo Caflisch. Efficient modularity optimization by multistep greedy algorithm and vertex mover refinement. Physical Review E, 77(4):046112, Apr 2008. 30 [43] Herbert A. Simon. The architecture of complexity. In Proceedings of the American Philo- sophical Society, pages 467–482, 1962. [44] Volker Strassen. Gaussian elimination is not optimal. Numerische Mathematik, 13:354–356, 1969. ISSN 0029-599X. 10.1007/BF02165411. [45] Wayne W. Zachary. An information flow model for conflict and fission in small groups. Journal of Anthropological Research, 33(4):452–473, 1977. 31
1910.09131
1
1910
2019-10-21T03:21:24
Adaptive Learned Bloom Filter (Ada-BF): Efficient Utilization of the Classifier
[ "cs.DS", "cs.LG" ]
Recent work suggests improving the performance of Bloom filter by incorporating a machine learning model as a binary classifier. However, such learned Bloom filter does not take full advantage of the predicted probability scores. We proposed new algorithms that generalize the learned Bloom filter by using the complete spectrum of the scores regions. We proved our algorithms have lower False Positive Rate (FPR) and memory usage compared with the existing approaches to learned Bloom filter. We also demonstrated the improved performance of our algorithms on real-world datasets.
cs.DS
cs
Adaptive Learned Bloom Filter (Ada-BF): Efficient Utilization of the Classifier Zhenwei Dai∗ and Anshumali Shrivastava† ∗Dept. of Statistics and Dept. of Computer Science†, Rice University October 22, 2019 Abstract Recent work suggests improving the performance of Bloom filter by incorporating a machine learning model as a binary classifier. However, such learned Bloom filter does not take full advantage of the predicted probability scores. We proposed new algorithms that generalize the learned Bloom filter by using the complete spectrum of the scores regions. We proved our algorithms have lower False Positive Rate (FPR) and memory usage compared with the existing approaches to learned Bloom filter. We also demonstrated the improved performance of our algorithms on real-world datasets. 1 Introduction Bloom filter (BF) is a widely used data structure for low-memory and high-speed approximate membership testing [Bloom, 1970]. Bloom filters compress a given set S into bit arrays, where we can approximately test whether a given element (or query) x belongs to a set S, i.e., x ∈ S or otherwise. Several applications, in particular caching in memory constrained systems, have benefited tremendously from BF [Broder et al., 2002]. Bloom filter ensures a zero false negative rate (FNR), which is a critical requirement for many applications. However, BF does not have a non-zero false positive rate (FPR) [Dillinger and Manolios, 2004] due to hashing collisions, which measures the performance of BF. There is a known theoretical limit to this reduction. To achieve a FPR of , BF costs at least n log2(1/) log2 e bits (n = S), which is log2 e ≈ 44% off from the theoretical lower bound [Carter et al., 1978]. Mitzenmacher [2002] proposed Compressed Bloom filter to address the suboptimal space usage of BF, where the space usage can reach the theoretical lower bound in the optimal case. To achieve a more significant reduction of FPR, researchers have generalized BF and incorporated information beyond the query itself to break through the theoretical lower bound of space usage. Bruck et al. [2006] has made use of the query frequency and varied the number of hash functions based on the query frequency to reduce the overall FPR. Recent work [Kraska et al., 2018, Mitzenmacher, 2018] has proposed to improve the performance of standard Bloom filter by incorporating a machine learning model. This approach paves a new hope of reducing false positive rates beyond the theoretical limit, by using context-specific information in the form of a machine learning model [Hsu et al., 2019]. Rae et al. [2019] further proposed Neural Bloom Filter that learns to write to memory using a distributed write scheme and achieves compression gains over the classical Bloom filter. The key idea behind Kraska et al. [2018] is to use the machine learning model as a pre-filter to give each query x a score s(x). s(x) is usually positively associated with the odds that x ∈ S. The assumption is that in many practical settings, the membership of a query in the set S can be figured out from observable features of x and such information is captured by the classifier assigned score s(x). The proposal of Kraska et al. 1 uses this score and treats query x with score s(x) higher than a pre-determined threshold τ (high confidence predictions) as a direct indicator of the correct membership. Queries with scores less than τ are passed to the back-up Bloom filter. Compared to the standard Bloom filter, learned Bloom filter (LBF) uses a machine learning model to answer keys with high score s(x). Thus, the classifier reduces the number of the keys hashed into the Bloom filter. When the machine learning model has a reliable prediction performance, learned Bloom filter significantly reduce the FPR and save memory usage [Kraska et al., 2018]. Mitzenmacher [2018] further provided a formal mathematical model for estimating the performance of LBF. In the same paper, the author proposed a generalization named sandwiched learned Bloom filter (sandwiched LBF), where an initial filter is added before the learned oracle to improve the FPR if the parameters are chosen optimally. Wastage of Information: For existing learned Bloom filters to have a lower FPR, the classifier score greater than the threshold τ should have a small probability of wrong answer. Also, a significant fraction of the keys should fall in this high threshold regime to ensure that the backup filter is small. However, when the score s(x) is less than τ, the information in the score s(x) is never used. Thus, there is a clear waste of information. For instance, consider two elements x1 and x2 with τ > s(x1) (cid:29) s(x2). In the existing solutions, x1 and x2 will be treated in the exact same way, even though there is enough prior to believing that x1 is more likely positive compared to x2. Strong dependency on Generalization: It is natural to assume that prediction with high confidence implies a low FPR when the data distribution does not change. However, this assumption is too strong for many practical settings. First and foremost, the data distribution is likely to change in an online streaming environment where Bloom filters are deployed. Data streams are known to have bursty nature with drift in distribution [Kleinberg, 2003]. As a result, the confidence of the classifier, and hence the threshold, is not completely reliable. Secondly, the susceptibility of machine learning oracles to adversarial examples brings new vulnerability in the system. Examples can be easily created where the classifier with any given confidence level τ, is incorrectly classified. Bloom filters are commonly used in networks where such increased adversarial false positive rate can hurt the performance. An increased latency due to collisions can open new possibilities of Denial-of-Service attacks (DoS) [Feinstein et al., 2003]. Motivation: For a binary classifier, the density of score distribution, f (s(x)) shows a different trend for elements in the set and outside the set S. We observe that for keys, f (s(x)x ∈ S) shows ascending trend as s(x) increases while f (s(x)x /∈ S) has an opposite trend. To reduce the overall FPR, we need lower FPRs for groups with a high f (s(x)x /∈ S). Hence, if we are tuning the number of hash functions differently, more hash functions are required for the corresponding groups. While for groups with a few non-keys, we allow higher FPRs. This variability is the core idea to obtaining a sweeter trade-off. Our Contributions: Instead of only relying on the classifier whether score s(x) is above a single specific threshold, we propose two algorithms, Ada-BF and disjoint Ada-BF, that rely on the complete spectrum of scores regions by adaptively tuning Bloom filter parameters in different score regions. 1) Ada-BF tunes the number of hash functions differently in different regions to adjust the FPR adaptively; disjoint Ada-BF allocates variable memory Bloom filters to each region. 2) Our theoretical analysis reveals a new set of trade-offs that brings lower FPR with our proposed scheme compared to existing alternatives. 3) We evaluate the performance of our algorithms on two datasets: malicious URLs and malware MD5 signatures, where 2 our methods reduce the FPR by over 80% and save 50% of the memory usage over existing learned Bloom filters. Notations: Our paper includes some notations that need to be defined here. Let [g] denote the index set {1, 2,··· , g}. We define query x as a key if x ∈ S, or a non-key if x /∈ S. Let n denote the size of keys (n = S), and m denote the size of non-keys. We denote K as the number of hash functions used in the Bloom filter. 2 Review: Bloom Filter and Learned Bloom Filter Bloom Filter: Standard Bloom filter for compressing a set S consists of an R-bits array and K indepen- dent random hash function h1, h2,··· , hK, taking integer values between 0 and R − 1, i.e., hi : S ⇒ {0, 1,··· , R − 1}. The bit array is initialized with all 0. For every item x ∈ S, the bit value of hi(x) = 1, for all i ∈ {0, 1,··· , K}, is set to 1. ), for all i ∈ {0, 1,··· , K}, (cid:48) To check a membership of an item x have been set to 1. It is clear that Bloom filter has zero FNR (false negative rate). However, due to lossy hash functions, x )s are set to 1 due to random collisions. It can be shown that if the hash functions are independent, the expected FPR can be written as follows may be wrongly identified to be positive when x in the set S, we return true if all the bits hi(x (cid:48) (cid:48) /∈ S while all the hi(x (cid:48) (cid:48) (cid:32) (cid:18) (cid:19)Kn(cid:33)K . E (FPR) = 1 − 1 − 1 R Learned Bloom filter: Learned Bloom filter adds a binary classification model to reduce the effective number of keys going to the Bloom filter. The classifier is pre-trained on some available training data to classify whether any given query x belongs to S or not based on its observable features. LBF sets a threshold, τ, where x is identified as a key if s(x) ≥ τ. Otherwise, x will be inserted into a Bloom filter to identify its membership in a further step (Figure 1). Like standard Bloom filter, LBF also has zero FNR. And the false positives can be either caused by that false positives of the classification model (s(xx /∈ S) ≥ τ) or that of the Bloom filter. It is clear than when the region s(x) ≥ τ contains large number of keys, the number of keys inserted into the Bloom filter decreases which leads to favorable FPR. However, since we identify the region s(x) ≥ τ as positives, higher values of τ is better. At the same time, large τ decreases the number of keys in the region s(x) ≥ τ, increasing the load of the Bloom filter. Thus, there is a clear trade-off. 3 A Strict Generalization: Adaptive Learned Bloom Filter (Ada-BF) With the formulation of LBF in the previous section, LBF actually divides the x into two groups. When s(x) ≥ τ, x will be identified as a key directly without testing with the Bloom filter. In other words, it uses zero hash function to identify its membership. Otherwise, we will test its membership using K hash functions. In other view, LBF switches from K hash functions to no hash function at all, based on s(x) ≥ τ or not. Continuing with this mindset, we propose adaptive learned Bloom filter, where x is divided into g 3 groups based on s(x), and for group j, we use Kj hash functions to test its membership. The structure of Ada-BF is represented in Figure 1(b). Figure 1: Panel A-C show the structure of LBF, Ada-BF and disjoint Ada-BF respectively. More specifically, we divide the spectrum into g regions, where x ∈ Group j if s(x) ∈ [τj−1, τj), j = 1, 2,··· , g. Without loss of generality, here, we assume 0 = τ0 < τ1 < ··· < τg−1 < τg = 1. Keys from group j are inserted into Bloom filter using Kj independent hash functions. Thus, we use different number of universal hash functions for keys from different groups. For a group j, the expected FPR can be expressed as, (cid:32) (cid:18) t=1 ntKt(cid:33)Kj (cid:19)(cid:80)g = αKj (1) E (FPRj) = 1 − 1 − 1 R where nt = (cid:80)n t=1 I(τt−1 ≤ s(xixi ∈ S) < τt) is the number of keys falling in group t, and Kj is the number of hash functions used in group j. By varying Kj, E (FPRj) can be controlled differently for each group. Variable number of hash functions gives us enough flexibility to tune the FPR of each region. To avoid the bit array being overloaded, we only increase the Kj for groups with large number of keys nj, while decrease Kj for groups with small nj. It should be noted that f (s(x)x ∈ S) shows an opposite trend compared to f (s(x)x /∈ S) as s(x) increases (Figure 2). Thus, there is a need for variable tuning, and a spectrum of regions gives us the room to exploit these variability efficiently. Clearly, Ada-BF generalizes the LBF. When Ada-BF only divides the queries into two groups, by setting K1 = K, K2 = 0 and τ1 = τ, Ada-BF reduces to the LBF. 3.1 Simplifying the Hyper-Parameters To implement Ada-BF, there are some hyper-parameters to be determined, including the number of hash functions for each group Kj and the score thresholds to divide groups, τj (τ0 = 0, τg = 1). Altogether, we need to tune 2g − 1 hyper-parameters. Use these hyper-parameters, for Ada-BF, the expected overall FPR can be expressed as, E (FPR) = pjE (FPRj) = pjαKj (2) g(cid:88) g(cid:88) j=1 j=1 4 m reasonable time. However, since the estimated false positive items(cid:80)g (cid:80)m i=1 I(τj−1 ≤ where pj = P r(τj−1 ≤ s(xixi /∈ S) < τj). Empirically, pj can be estimated by pj = 1 s(xixi /∈ S) < τj) = mj m (m is size of non-keys in the training data and mj is size of non-keys belonging to group j). It is almost impossible to find the optimal hyper-parameters that minimize the E (FPR) in j=1 mjαKj = O(maxj(mjαKj )), we prefer mjαKj to be similar across groups when E (FPR) is minimized. While αKj decreases exponentially fast with larger Kj, to keep mjαKj stable across different groups, we require mj to grow exponentially fast with Kj. Moreover, since f (s(x)x /∈ S) increases as s(x) becomes smaller for most cases, Kj should also be larger for smaller s(x). Hence, to balance the number of false positive items, as j diminishes, we should increase Kj linearly and let mj grow exponentially fast. = c and Kj − Kj+1 = 1 With this idea, we provide a strategy to simplify the tuning procedure. We fix pj pj+1 for j = 1, 2,··· , g − 1. Since the true density of s(xx /∈ S) is unknown. To implement the strategy, we estimate pj = c. This strategy ensures pj to grow exponentially fast with pj+1 Kj. Now, we only have three hyper-parameters, c, Kmin and Kmax (Kmax = K1). By default, we may also set Kmin = Kg = 0, equivalent to identifying all the items in group g as keys. by (cid:100)pj and fix mj mj+1 = mj mj+1 pj+1 Lemma 1: Assume 1) the scores of non-keys, s(x)x /∈ S, are independently following a distribution f; 2) The scores of non-keys in the training set are independently sampled from a distribution f. Then, the jpj − pj, converges to 0 in probability as m becomes larger. Moreover, if overall estimation error of pj,(cid:80) (cid:21)2 (cid:113) 1−2/π , with probability at least 1 − δ, we have(cid:80) (cid:20)(cid:113) 1 m ≥ 2(k−1) jpj − pj ≤ . π + δ 2 Even though in the real application, we cannot access the exact value of pj, which may leads to the estimation error of the real E (FPR). However, Lemma 1 shows that as soon as we can collect enough non-keys to estimate the pj, the estimation error is almost negligible. Especially for the large scale membership testing task, collecting enough non-keys is easy to perform. 3.2 Analysis of Adaptive Learned Bloom Filter Compared with the LBF, Ada-BF makes full use the of the density distribution s(x) and optimizes the FPR in different regions. Next, we will show Ada-BF can reduce the optimal FPR of the LBF without increasing the memory usage. When pj/pj+1 = cj ≥ c > 1 and Kj − Kj+1 = 1, the expected FPR follows, g(cid:88) j=1 E (FPR) = pjαKj = (cid:80)g (cid:80)g j=1 cg−jαKj j=1 cg−j ≤  (1 − c)(1 − (cα)g) α − c)(αg − (cα)g) ( 1 1 − c 1 − cg · g, αKmax, cα (cid:54)= 1 cα = 1 (3) where Kmax = K1. To simplify the analysis, we assume cα > 1 in the following theorem. Given the number of groups g is fixed, this assumption is without loss of generality satisfied by raising c since α will increase as c becomes larger. For comparisons, we also need τ of the LBF to be equal to τg−1 of the Ada-BF. In this case, queries with scores higher than τ are identified as keys directly by the machine learning model. So, to compare the overall FPR, we only need to compare the FPR of queries with scores lower than τ. ≥ c > 1 for all j ∈ [g − 1], if there exists λ > 0 such that cα ≥ 1 + λ Theorem 1: For Ada-BF, given pj pj+1 holds, and nj+1 − nj > 0 for all j ∈ [g − 1] (nj is the number of keys in group j). When g is large enough 5 and g ≤ (cid:98)2K(cid:99), then Ada-BF has smaller FPR than the LBF. Here K is the number of hash functions of the LBF. Theorem 1 requires the number of keys nj keeps increasing while pj decreases exponentially fast with j. As shown in figure 2, on real dataset, we observe from the histogram that as score increases, f (s(x)x /∈ S) decreases very fast while f (s(x)x ∈ S) increases. So, the assumptions of Theorem 1 are more or less satisfied. Moreover, when the number of buckets is large enough, the optimal K of the LBF is large as well. Given the assumptions hold, theorem 1 implies that we can choose a larger g to divide the spectrum into more groups and get better FPR. The LBF is sub-optimal as it only has two regions. Our experiments clearly show this trend. For figure 3(a), Ada-BF achieves 25% of the FPR of the LBF when the bitmap size = 200Kb, while when the budget of buckets = 500Kb, Ada-BF achieves 15% of the FPR of the LBF. For figure 3(b), Ada-BF only reduces the FPR of the LBF by 50% when the budget of buckets = 100Kb, while when the budget of buckets = 300Kb, Ada-BF reduces 70% of the FPR of the LBF. Therefore, both the analytical and experimental results indicate superior performance of Ada-BF by dividing the spectrum into more small groups. On the contrary, when g is small, Ada-BF is more similar to the LBF, and their performances are less differentiable. 4 Disjoint Adaptive Learned Bloom Filter (Disjoint Ada-BF) Ada-BF divides keys into g groups based on their scores and hashes the keys into the same Bloom filter using different numbers of hash functions. With the similar idea, we proposed an alternative approach, disjoint Ada-BF, which also divides the keys into g groups, but hashes keys from different groups into independent Bloom filters. The structure of disjoint Ada-BF is represented in Figure 1(c). Assume we have total budget of R bits for the Bloom filters and the keys are divided into g groups using the same idea of that in Ada-BF. j=1 Rj). Then, during the look up stage, we just need to identify a query's group and check its membership in the corresponding Bloom filter. Consequently, the keys from group j are inserted into j-th Bloom filter whose length is Rj (R =(cid:80)g 4.1 Simplifying the Hyper-Parameters Analogous to Ada-BF, disjoint Ada-BF also has a lot of hyper-parameters, including the thresholds of scores for groups division and the lengths of each Bloom filters. To determine thresholds τj, we use similar tuning strategy discussed in the previous section of tuning the number of groups g and mj = c. To find Rj that mj+1 optimizes the overall FPR, again, we refer to the idea in the previous section that the expected number of false positives should be similar across groups. For a Bloom filter with Rj buckets, the optimal number of hash functions Kj can be approximated as Kj = Rj log(2), where nj is the number of keys in group j. And the nj corresponding optimal expected FPR is E (FPRj) = µRj /nj (µ ≈ 0.618). Therefore, to enforce the expected number of false items being similar across groups, Rj needs to satisfy mj · µ Rj nj = m1 · µ R1 n1 ⇐⇒ Rj nj − R1 n1 = (j − 1)log(c) log(µ) Since nj is known given the thresholds τj and the total budget of buckets R are known, thus, Rj can be solved accordingly. Moreover, when the machine learning model is accurate, to save the memory usage, we may also set Rg = 0, which means the items in group j will be identified as keys directly. 6 4.2 Analysis of Disjoint Adaptive Learned Bloom Filter The disjoint Ada-BF uses a group of shorter Bloom filters to store the hash outputs of the keys. Though the approach to control the FPR of each group is different from the Ada-BF, where the Ada-BF varies K and disjoint Ada-BF changes the buckets allocation, both methods share the same core idea to lower the overall FPR by reducing the FPR of the groups dominated by non-keys. Disjoint Ada-BF allocates more buckets for these groups to a achieve smaller FPR. In the following theorem, we show that to achieve the same optimal expected FPR of the LBF, disjoint Ada-BF consumes less buckets. Again, for comparison we need τ of the LBF is equal to τg−1 of the disjoint Ada-BF. pj If = c > 1 and nj+1 − nj > 0 for all j ∈ [g − 1] (nj is the number of keys in group j), Theorem 2: to achieve the optimal FPR of the LBF, the disjoint Ada-BF consumes less buckets compared with the LBF when g is large. pj+1 5 Experiment Baselines: We test the performance of four different learned Bloom filters: 1) standard Bloom filter, 2) learned Bloom filter, 3) sandwiched learned Bloom filter, 4) adaptive learned Bloom filter, and 5) disjoint adaptive learned Bloom filter. We use two datasets which have different associated tasks, namely: 1) Malicious URLs Detection and 2) Virus Scan. Since all the variants of Bloom filter structures ensure zero FNR, the performance is measured by their FPRs and corresponding memory usage. 5.1 Task1: Malicious URLs Detection We explore using Bloom filters to identify malicious URLs. We used the URLs dataset downloaded from Kaggle, including 485,730 unique URLs. 16.47% of the URLs are malicious, and others are benign. We randomly sampled 30% URLs (145,719 URLs) to train the malicious URL classification model. 17 lexical features are extracted from URLs as the classification features, such as "host name length", "path length", "length of top level domain", etc. We used "sklearn.ensemble.RandomForestClassifier1" to train a random forest model. After saving the model with "pickle", the model file costs 146Kb in total. "sklearn.predict_prob" was used to give scores for queries. We tested the optimal FPR for the four learned Bloom filter methods under the total memory budget = 200Kb to 500Kb (kilobits). Since the standard BF does not need a machine learning model, to make a fair comparison, the bitmap size of BF should also include the machine learning model size (146 Kb in this experiment). Thus, the total bitmap size of BF is 346Kb to 646Kb. To implement the LBF, we tuned τ between 0 and 1, and picked the one giving the minimal FPR. The number of hash functions was determined by K = Round( R log 2), where n0 is the number of keys hashed into the Bloom filter conditional τ. To n0 implement the sandwiched LBF, we searched the optimal τ and calculated the corresponding initial and backup filter size by the formula in Mitzenmacher [2018]. When the optimal backup filter size is larger than the total bits budget, sandwiched LBF does not need a initial filter and reduces to a standard LBF. For the Ada-BF, we used the tuning strategy described in the previous section. Kmin was set to 0 by default. Thus, we only need to tune the combination of (Kmax, c) that gives the optimal FPR. Similarly, for disjoint Ada-BF, we fixed Rg = 0 and searched for the optimal (g, c). 1The Random Forest classifier consists 10 decision trees, and each tree has at most 20 leaf nodes. 7 (a) (b) Figure 2: Histogram of the classifier's score distributions of keys (Malicious) and non-keys (Benign) for Task 1. We can see that nj (number of keys in region j) is monotonic when score > 0.3. The partition was only done to ensure pj pj +1 ≥ c Result: Our trained machine learning model has a classification accuracy of 0.93. Considering the non- informative frequent class classifier (just classify as benign URL) gives accuracy of 0.84, our trained learner is not a strong classifier. However, the distribution of scores is desirable (Figure 2), where as s(x) increases, the empirical density of s(x) decreases for non-keys and also increases for keys. In our experiment, when the sandwiched LBF is optimized, the backup filter size always exceeds the total bitmap size. Thus, it reduces to the LBF and has the same FPR (as suggested by Figure 4(a)). Our experiment shows that compared to the LBF and sandwiched LBF, both Ada-BF and disjoint Ada-BF achieve much lower FPRs. When filter size = 500Kb, Ada-BF reduces the FPR by 81% compared to LBF or sandwiched LBF (disjoint FPR reduces the FPR by 84%). Moreover, to achieve a FPR ≈ 0.9%, Ada-BF and disjoint Ada-BF only require 200Kb, while both LBF and the sandwiched LBF needs more than 350Kb. And to get a FPR ≈ 0.35%, Ada-BF and disjoint Ada-BF reduce the memory usage from over 500Kb of LBF to 300Kb, which shows that our proposed algorithms save over 40% of the memory usage compared with LBF and sandwiched LBF. 5.2 Task 2: Virus Scan Bloom filter is widely used to match the file's signature with the virus signature database. Our dataset includes the information of 41323 benign files and 96724 viral files. The virus files are collected from VirusShare database [Vir]. The dataset provides the MD5 signature of the files, legitimate status and other 53 variables characterizing the file, like "Size of Code", "Major Link Version" and "Major Image Version". We trained a machine learning model with these variables to differentiate the benign files from the viral documents. We randomly selected 20% samples as the training set to build a binary classification model using Random Forest model 2. We used "sklearn.ensemble.RandomForestClassifier" to tune the model, and the Random Forest classifier costs about 136Kb. The classification model achieves 0.98 prediction accuracy on the testing set. The predicted the class probability (with the function "predict_prob" in "sklearn" library) is used as the score s(x). Other implementation details are similar to that in Task 1. 2The Random Forest classifier consists 15 decision trees, and each tree has at most 5 leaf nodes. 8 0.00.20.40.60.81.0Score102103104CountScore Distribution of Malicious URLsMalicious0.00.20.40.60.81.0Score100101102103104105CountScore Distribution of Benign URLsBenign (a) (b) Figure 3: Histogram of the classifier score distributions for the Virus Scan Dataset. The partition was only done to ensure pj pj +1 ≥ c. Result: As the machine learning model achieves high prediction accuracy, figure 4 suggests that all the learned Bloom filters show huge advantage over the standard BF where the FPR is reduced by over 98%. Similar to the previous experiment results, we observe consistently lower FPRs of our algorithms although the the score distributions are not smooth or continuous (Figure 3). Again, our methods show very similar performance. Compared with LBF, our methods reduce the FPRs by over 80%. To achieve a 0.2% FPR, the LBF and sandwiched LBF cost about 300Kb bits, while Ada-BF only needs 150Kb bits, which is equivalent to 50% memory usage reduction compared to the previous methods. 5.3 Sensitivity to Hyper-parameter Tuning Compared with the LBF and sandwiched LBF where we only need to search the space of τ to optimize the FPR, our algorithms require to tune a series of score thresholds. In the previous sections, we have proposed a simple but useful tuning strategies where the score thresholds can be determined by only two hyper-parameters, (K, c). Though our hyper-parameter tuning technique may lead to a sub-optimal choice, our experiment results have shown we can still gain significantly lower FPR compared with previous LBF. Moreover, if the number of groups K is misspecified from the optimal choice (of K), we can still achieve very similar FPR compared with searching both K and c. Figure 5 shows that for both Ada-BF and disjoint Ada-BF, tuning c while fixing K has already achieved similar FPRs compared with optimal case by tuning both (K, c), which suggests our algorithm does not require very accurate hyper-parameter tuning to achieve significant reduction of the FPR. 5.4 Discussion: Sandwiched Learned Bloom filter versus Learned Bloom filter Sandwiched LBF is a generalization of LBF and performs no worse than LBF. Although Mitzenmacher [2018] has shown how to allocate bits for the initial filter and backup filter to optimize the expected FPR, their result is based on the a fixed FNR and FPR. While for many classifiers, FNR and FPR are expressed as functions of the prediction score τ. Figure 4(a) shows that the sandwiched LBF always has the same FPR as LBF though we increase the bitmap size from 200Kb to 500Kb. This is because the sandwiched LBF is optimized when τ corresponds to a small FPR and a large FNR, where the optimal backup filter size even 9 0.10.20.30.40.50.60.70.80.9Score102CountScore Distribution of Viral FilesViral0.10.20.30.40.50.60.70.80.9Score102103CountScore Distribution of Benign FilesBenign (a) (b) Figure 4: FPR with memory budget for all the five baselines (the bit budget of BF = bitmap size + learner size). (a) FPRs comparison of Malicious URL detection experiment; (b) FPRs comparison of Virus scan experiment. exceeds the total bitmap size. Hence, we should not allocate any bits to the initial filter, and the sandwiched LBF reduces to LBF. On the other hand, our second experiment suggests as the bitmap size becomes larger, sparing more bits to the initial filter is clever, and the sandwiched LBF shows the its advantage over the LBF (Figure 6(b)). 6 Conclusion We have presented new approaches to implement learned Bloom filters. We demonstrate analytically and empirically that our approaches significantly reduce the FPR and save the memory usage compared with the previously proposed LBF and sandwiched LBF even when the learner's discrimination power . We envision that our work will help and motivate integrating machine learning model into probabilistic algorithms in a more efficient way. 10 5.0%10.0%15.0%False Positive Rates Comparison200250300350400450500Bitmap Size (Kb)0.00%0.50%1.00%1.50%2.00%2.50%False Positive RateBFLBFsandwiched LBFAda-BFdisjoint Ada-BF20.0%40.0%False Positive Rates Comparison100150200250300Bitmap Size (Kb)0.00%0.10%0.20%0.30%0.40%0.50%0.60%0.70%0.80%False Positive RateBFLBFsandwiched LBFAda-BFdisjoint Ada-BF References Virusshare 2018. https://virusshare.com/research.4n6. Burton H Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422 -- 426, 1970. Andrei Broder, Michael Mitzenmacher, and Andrei Broder I Michael Mitzenmacher. Network applications of bloom filters: A survey. In Internet Mathematics. Citeseer, 2002. Jehoshua Bruck, Jie Gao, and Anxiao Jiang. Weighted bloom filter. In 2006 IEEE International Symposium on Information Theory, pages 2304 -- 2308. IEEE, 2006. Larry Carter, Robert Floyd, John Gill, George Markowsky, and Mark Wegman. Exact and approximate membership testers. In Proceedings of the tenth annual ACM symposium on Theory of computing, pages 59 -- 65. ACM, 1978. Peter C. Dillinger and Panagiotis Manolios. Bloom filters in probabilistic verification. In Alan J. Hu and Andrew K. Martin, editors, Formal Methods in Computer-Aided Design, page 370, Berlin, Heidelberg, 2004. Springer Berlin Heidelberg. ISBN 978-3-540-30494-4. Laura Feinstein, Dan Schnackenberg, Ravindra Balupari, and Darrell Kindred. Statistical approaches to ddos attack detection and response. In Proceedings DARPA information survivability conference and exposition, volume 1, pages 303 -- 314. IEEE, 2003. Chen-Yu Hsu, Piotr Indyk, Dina Katabi, and Ali Vakilian. Learning-based frequency estimation algorithms. In International Conference on Learning Representations, 2019. URL https://openreview.net/ forum?id=r1lohoCqY7. Jon Kleinberg. Bursty and hierarchical structure in streams. Data Mining and Knowledge Discovery, 7(4): 373 -- 397, 2003. Tim Kraska, Alex Beutel, Ed H Chi, Jeffrey Dean, and Neoklis Polyzotis. The case for learned index structures. In Proceedings of the 2018 International Conference on Management of Data, pages 489 -- 504. ACM, 2018. Michael Mitzenmacher. Compressed bloom filters. IEEE/ACM Transactions on Networking (TON), 10(5): 604 -- 612, 2002. Michael Mitzenmacher. A model for learned bloom filters and optimizing by sandwiching. In Advances in Neural Information Processing Systems, pages 464 -- 473, 2018. Jack W Rae, Sergey Bartunov, and Timothy P Lillicrap. Meta-learning neural bloom filters. arXiv preprint arXiv:1906.04304, 2019. 11 Appendix A Sensitivity to hyper-parameter tuning (a) (b) Figure 5: FPR comparison of tuning c while fixing the number of groups K and tuning both (K, c) Appendix B More comparisons between the LBF and sandwiched LBF (a) (b) Figure 6: FPR comparison between LBF and sandwiched LBF under different bitmap sizes. (a) malicious URL experiment; (b) malware detection experiment Appendix C Proof of the Statements Proof of Lemma 1: Let Zj(x) = (cid:80)m and mj = (cid:80)m i=1 Zj(xi) counts the number of non-keys falling in group j and pj = mj 1(s(x) ∈ [τj−1, τj)x /∈ S), then Zj(x) ∼ Bernoulli(pj), m . To upper i=1 12 200250300350400450500Budget of buckets (Kb)0.00%0.20%0.40%0.60%0.80%1.00%1.20%False Positive RateAda-BF: FPRs with different KK=10K=11K=12Optimal200250300350400450500Budget of buckets (Kb)0.00%0.20%0.40%0.60%0.80%1.00%1.20%False Positive RateDisjoint Ada-BF: FPRs with different KK=10K=11K=12Optimal200250300350400450600700800Budget of buckets (Kb)0.00%0.50%1.00%1.50%2.00%2.50%False Positive RateLBF vs sandwiched LBFLBFsandwiched LBF100150200250300350400450500Budget of buckets (Kb)0.00%0.10%0.20%0.30%0.40%0.50%0.60%0.70%False Positive RateLBF vs sandwiched LBFLBFsandwiched LBF bound the probability of the overall estimation error of pj, first, we need to evaluate its expectation, Since mj is a binomial random variable, its exact cdf is hard to compute. But with central limit theorem, when m is large, mj−mpj · mpj (1−pj ) −→ N (0, 1). Thus, we can approximate E (pj − pj) = E mj−mpj √ mpj (1−pj ) . √ j=1pj − pj(cid:17) E(cid:16)(cid:80)K (cid:113) pj (1−pj ) π ·(cid:113) pj (1−pj ) ≈ (cid:113) 2 is approximated by E(cid:16)(cid:80)K mπ ·(cid:16)(cid:80)K We need to further upper bound the tail probability of(cid:80)K (cid:80)K j=1pj − pj, j=1pj − pj(cid:17) ≈(cid:113) 2 larger. m m (if Z ∼ N (0, 1), E (Z) = j=1 (cid:18) (cid:19) (cid:113) 2 (cid:17) (cid:112)pj(1 − pj) π ). Then, the expectation of overall error , which goes to 0 as m becomes j=1pj − pj. First, we upper bound the variance of (cid:16) Var (pj − pj) − E (pj − pj)2(cid:17) (cid:113) V (p) Now, by envoking the Chebyshev's inequality,  K(cid:88) j=1 Var pj − pj  K(cid:88) j=1 P pj − pj ≥   ≤ K ≈ K m  = P (cid:16) ≤ = Thus,(cid:80)K Moreover, since we have  K(cid:88) j=1 E pj − pj m π i=1 j=1 j=1 j=1 (cid:33)2 (cid:44) K  K(cid:88) pj(1 − pj) pj − pj − E Var (pj − pj) = K  ≥  − E K(cid:88) K(cid:88) pj(1 − pj) − 2 (cid:32) K(cid:88) K(cid:88)  K(cid:88)  K(cid:88) j=1pj − pj(cid:17) (cid:16)(cid:80)K  − E(cid:16)(cid:80)K j=1pj − pj(cid:17)(cid:17)2  − E(cid:16)(cid:80)K j=1pj − pj(cid:17)(cid:17)2 −→ 0 as m −→ ∞ (cid:16)  ≈ pj(1 − pj)) ≤ pj − pj KV (p) (K − 1) Var j=1 j=1 j=1 m mπ (cid:114) 2 (cid:32) K(cid:88) (cid:113) (cid:19)(cid:19) i=1 ( j=1 mπ (cid:113) (cid:114) 2 K(cid:88) pj(1 − pj) − 2 K(cid:88) (cid:18) (cid:18) ≤ K(cid:88) (cid:18) (cid:19) (cid:19)(cid:18) pj(1 − pj) j=1 j=1 π 1 − 2 π 1 − 1 K ≤ 1 − 2 π (cid:33)2 pj(1 − pj) V (p) = 13 j=1pj − pj converges to 0 in probability as m −→ ∞. (cid:3)  pj − pj (4) (5) Then, by Eq 4 and Eq 5, we can upper bound P  K(cid:88) j=1 P pj − pj ≥  (cid:20)(cid:113) 1 (cid:113) 1−2/π (cid:105) ≤ δ. (cid:3) π + δ When m ≥ 2(k−1) 2 (cid:104)(cid:80)K P j=1pj − pj ≥  ≤ , we have m (cid:21)2 (cid:104)(cid:80)K  ≤ by, KV (p) (cid:105) j=1pj − pj ≥  j=1pj − pj(cid:17)(cid:17)2  − E(cid:16)(cid:80)K (cid:16)  −(cid:113) 2 (cid:16) (cid:17)2 π )(K − 1) mπ (K − 1)  −(cid:113) 2 (cid:17)2 ≥ (K−1)(1− 2 mπ (K − 1) (1 − 2 m m δ (cid:16) (6) , thus, π ) Proof of Theorem 1: For comparison, we choose τ = τg−1, for both LBF and Ada-BF, queries with scores larger than τ are identified as keys directly by the same machine learning model. Thus, to compare the overall FPR, we only need to evaluate the FPR of queries with score lower than τ. Let p0 = P [s(x) < τx /∈ S] be the probability of a key with score lower than τ. Let n0 denote the number I(s(xi) < τ ). For learned Bloom filter using K hash functions, of keys with score less than τ, n0 = (cid:80) i:xi∈S (cid:32) (cid:19)Kn0(cid:33)K (cid:18) 1 − 1 R = 1 − p0 + p0βK, (7) E (FPR) = (1 − p0) + p0 1 − the expected FPR follows, where R is the length of the Bloom filter. For Ada-BF, assume we fix the number of groups g. Then, we only need to determine Kmax and Kmin = Kmax − g + 1. Let pj = P r(τj−1 ≤ s(x) < τjx /∈ S) The expected FPR of the Ada-BF is, (cid:32) (cid:18) g(cid:88) j=1 E (FPRa) = 1 − pj 1 − 1 R j=1 Kj nj(cid:33)K (cid:19)(cid:80)g−1 g−1(cid:88) j j=1 j=1 nj = n0. Next, we give a strategy to select Kmax which ensures a lower FPR of Ada-BF than = pjαKj , (8) where(cid:80)g−1 LBF. 14 Select Kmax = (cid:98)K + g i=1 j−1(cid:88) g−2(cid:88) g−2(cid:88) j=1 i=2 j=1 njK = K n1 + 2 − 1(cid:99). Then, we have g−1(cid:88) g−1(cid:88)  (g − 1)(g − 2)  (g − 1)(g − 2) g−1(cid:88) 2K g − 2 g − 2 2 2 2 (j − 1)nj 2 g − 2 j=1 n1 + n1 + (n1 + Ti) = n1(g − 1) + (g − 2)(g − 1 − j) 2 Tj (g + j − 2)(g − 1 − j) j=1 2  Tj(g − j − 1)  g−2(cid:88)  j=1 Tj n0K = = ≤ = By Eq 9. we further get the relationship between α and β. g−1(cid:88) g−1(cid:88) Kjnj = (Kmax − j + 1)nj ≤ n0 Kmax − g 2 + 1 (cid:16) j=1 j=1 Moreover, by Eq. 3, we have, E (FPRa) = (1 − c)(1 − (cα)g) α − c)(αg − (cα)g) ( 1 (9) (cid:17) ≤ n0K =⇒ α ≤ β. βKmax αKmax ≤ (1 − c)(1 − (cα)g) α − c)(αg − (cα)g) ( 1 ≤ βKmax α(c − 1) (cid:18) 1 + λ cα − 1 (cid:18) 1 + λ < E (FPR) λ ≤ E (FPR) (cid:19) β(cid:98)g/2−1(cid:99)(cid:19) βKmax−K . λ Therefore, as g increases, the upper bound of E (FPRa) decreases exponentially fast. Moreover, since 1+λ λ β(cid:98)g/2−1(cid:99) ≤ 1. Thus, the E (FPRe) is reduced to strictly is a constant, when g is large enough, we have 1+λ lower than E (FPR). (cid:3) λ Proof of Theorem 2: Let η = log(c) section, we require the expected false positive items should be similar across the groups. Thus, we have log(0.618) < 0. By the tuning strategy described in the previous log(µ) ≈ log(c) p1 · µR1/n1 = pj · µRj /nj =⇒ Rj = nj + (j − 1)η for j ∈ [g − 1] , (cid:18) R1 n1 (cid:19) where Rj is the budget of buckets for group j. For group j, since all the queries are identified as keys by the machine learning model directly, thus, Rg = 0. Given length of Bloom filter for group 1, R1, the total budget 15 R1 + (j − 1)njη nj n1 g−1(cid:88) of buckets can be expressed as, g−1(cid:88) of keys with score less than τ, n0 = (cid:80) nj = (cid:80) Rj = j=1 j=1 Let p0 = P r(s(x) < τx /∈ S) and pj = P r(τj−1 ≤ s(x) < τjx /∈ S). Let n0 denote the number I(s(xi) < τ ), and nj be the number of keys in group j, I(τj−1 ≤ s(xi) < τj). Due to τ = τg−1, we have(cid:80)g−1 i:xi∈S i:xi∈S j=1 nj = n0. Moreover, since τg−1 = τ, queries with score higher than τ have the same FPR for both disjoint Ada-BF and LBF. So, we only need to compare the FPR of the two methods when the score is lower than τ. If LBF and Ada-BF achieve the same optimal expected FPR, we have p0 · µR/n0 = =⇒ R = pj · µRj /nj = g · p1 · µR1/n1 log(p0/p1) − log(g) R1 − n0 log(µ) log(1 −(cid:0) 1 c )(cid:1)g − log(cid:0)1 − 1 c (cid:1) − log(g) (cid:35) , = R1 − nj nj n1 j=1 where R is the budget of buckets of LBF. Let Tj = nj+1 − nj ≥ 0. Next, we upper bound(cid:80)g−1 (cid:80)g−1 j=1(j − 1)nj. g−1(cid:88) g−2(cid:88) log(µ) Ti) = n1(g − 1) + Tj(g − j − 1) nj = n1 + j=1 nj with g−1(cid:88) j=1 n0 n1 g−1(cid:88) (cid:34) g−2(cid:88) g−2(cid:88) j=1 n1 + n1 + j=1 (g − 2)(g − 1 − j) 2 Tj (g + j − 2)(g − 1 − j) j=1 2   Tj i=1 i=2 (n1 + g−1(cid:88) j−1(cid:88)  (g − 1)(g − 2)  (g − 1)(g − 2) g−1(cid:88) (j − 1)nj 2 2 j=1 2 g − 2 2 g − 2 2 g − 2 j=1 = ≤ = (cid:34) R ≥ g−1(cid:88) Therefore, we can lower bound R, R1 − (j − 1)nj nj n1 Now, we can lower bound R −(cid:80)g−1 j=1 j=1 Rj, R − g−1(cid:88) Rj ≥ g−1(cid:88) (j − 1)nj 2(log(1 −(cid:0) 1 c )(cid:1)g − log(cid:0)1 − 1 (g − 2) log(µ) c (cid:1) − log(g)) (cid:35) . (cid:34) −η − 2(log(1 −(cid:0) 1 c )(cid:1)g − log(cid:0)1 − 1 (g − 2) log(µ) c (cid:1) − log(g)) (cid:35) . j=1 j=1 16 Since η is a negative constant, while 2(log(1−( 1 fore, when g is large, η − 2(log(1−( 1 c ))g−log(1− 1 (g−2) log(µ) disjoint Ada-BF consumes less memory than LBF to achieve the same expected FPR. < 0 and R −(cid:80)g−1 c )−log(g)) c ))g−log(1− 1 (g−2) log(µ) c )−log(g)) approaches to 0 when g is large. There- j=1 Rj is strictly larger than 0. So, 17
1307.7430
2
1307
2018-01-10T13:55:06
Holographic Algorithms Beyond Matchgates
[ "cs.DS", "cs.CC" ]
Holographic algorithms introduced by Valiant are composed of two ingredients: matchgates, which are gadgets realizing local constraint functions by weighted planar perfect matchings, and holographic reductions, which show equivalences among problems with different descriptions via certain basis transformations. In this paper, we replace matchgates in the paradigm above by the affine type and the product type constraint functions, which are known to be tractable in general (not necessarily planar) graphs. More specifically, we present polynomial-time algorithms to decide if a given counting problem has a holographic reduction to another problem defined by the affine or product-type functions. Our algorithms also find a holographic transformation when one exists. We further present polynomial-time algorithms of the same decision and search problems for symmetric functions, where the complexity is measured in terms of the (exponentially more) succinct representations. The algorithm for the symmetric case also shows that the recent dichotomy theorem for Holant problems with symmetric constraints is efficiently decidable. Our proof techniques are mainly algebraic, e.g., using stabilizers and orbits of group actions.
cs.DS
cs
Holographic Algorithms Beyond Matchgates✩ Jin-Yi Caia, Heng Guob,∗, Tyson Williamsc aUniversity of Wisconsin - Madison, 1210 West Dayton Street, Madison, WI 53706, US bUniversity of Edinburgh, Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, UK cBlocher Consulting, 206 North Randolph, Champaign, IL 61820, US 8 1 0 2 n a J 0 1 ] S D . s c [ 2 v 0 3 4 7 . 7 0 3 1 : v i X r a Abstract Holographic algorithms introduced by Valiant are composed of two ingredients: matchgates, which are gadgets realizing local constraint functions by weighted planar perfect matchings, and holographic reductions, which show equivalences among problems with different descriptions via certain basis transformations. In this paper, we replace matchgates in the paradigm above by the affine type and the product type constraint functions, which are known to be tractable in general (not necessarily planar) graphs. More specifically, we present polynomial-time algorithms to decide if a given counting problem has a holographic reduction to another problem defined by the affine or product-type functions. Our algorithms also find a holographic transformation when one exists. We further present polynomial-time algorithms of the same decision and search problems for symmetric functions, where the complexity is measured in terms of the (exponentially more) succinct representations. The algorithm for the symmetric case also shows that the recent dichotomy theorem for Holant problems with symmetric constraints is efficiently decidable. Our proof techniques are mainly algebraic, e.g., using stabilizers and orbits of group actions. Keywords: Counting complexity, holographic algorithms 1. Introduction Recently a number of complexity dichotomy theorems have been obtained for counting problems. Typi- cally, such dichotomy theorems assert that a vast majority of problems expressible within certain frameworks are #P-hard, however an intricate subset manages to escape this fate. These exceptions exhibit some rich mathematical structure, leading to polynomial-time algorithms. Holographic reductions and algorithms, in- troduced by Valiant [45], play key roles in many recent dichotomy theorems [14, 25, 20, 15, 35, 22, 12, 33]. Indeed, many interesting tractable cases are solvable using holographic reductions. This fascinating fact urges us to explore the full reach of holographic algorithms. Valiant's holographic algorithms [45, 44] have two main ingredients. The first is to encode computation in planar graphs via gadget construction, called matchgates [43, 42, 9, 17, 10]. The result of the computation is then obtained by counting the number of perfect matchings in a related planar graph, which can be done in polynomial time by Kasteleyn's (a.k.a. the FKT) algorithm [36, 41, 37]. The second one is the notion of holographic transformations/reductions, which show equivalences of problems with different descriptions via basis transformations. Thus, in order to apply the holographic algorithm, one must find a suitable holographic transformation along with matchgates realizing the desired constraint functions. This procedure has been made algorithmic [9, 17]. In this paper, we replace matchgates in the paradigm above by the affine type or the product type constraint functions, both of which are known to be tractable over general (i.e. not necessarily planar) graphs [24]. We present polynomial-time algorithms to decide if a given counting problem has a holographic ✩A preliminary version has appeared in ICALP 2014 [11]. ∗Corresponding author Email addresses: [email protected] (Jin-Yi Cai), [email protected] (Heng Guo), [email protected] (Tyson Williams) Preprint submitted to Elsevier August 28, 2018 reduction to another problem defined by affine or product-type functions. Our algorithm also finds a holo- graphic reduction when one exists. Although, conceptually, we do not add new tractable cases, the task of finding these transformations is often non-trivial. For example, generalized Fibonacci gates [23] are the same as the product-type via transformations, but at first glance, the former look much more complicated than the latter. To formally state the results, we briefly introduce some notation. The counting problems we consider are those expressible as a Holant problem [23, 21, 19, 24]. A Holant problem is defined by a set F of constraint functions, which we call signatures, and is denoted by Holant(F ). An instance of Holant(F ) is a tuple Ω = (G,F , π), called a signature grid, where G = (V, E) is a graph and π labels each vertex v ∈ V and its incident edges with some fv ∈ F and its input variables. Here fv maps {0, 1}deg(v) to C, where deg(v) is the degree of v. We consider all possible 0-1 edge assignments. An assignment σ to the edges E gives an evaluation Qv∈V fv(σE(v)), where E(v) denotes the incident edges of v and σE(v) denotes the restriction of σ to E(v). The counting problem on the instance Ω is to compute HolantΩ = Xσ:E→{0,1}Yv∈V fv(cid:0)σE(v)(cid:1) . For example, consider the problem of counting Perfect Matching on G. This problem corresponds to attaching the Exact-One function at every vertex of G. The Exact-One function is an example of a symmetric signature, which are functions that only depend on the Hamming weight of the input. We denote a symmetric signature by f = [f0, f1, . . . , fn] where fw is the value of f on inputs of Hamming weight w. For example, [0, 1, 0, 0] is the Exact-One function on three bits. The output is 1 if and only if the input is 001, 010, or 100, and the output is 0 otherwise. Holant problems contain both counting constraint satisfaction problems and counting graph homomor- phisms as special cases. All three classes of problems have received considerable attention, which has resulted in a number of dichotomy theorems (see [39, 34, 29, 2, 28, 4, 27, 1, 5, 31, 32, 8, 13, 14, 6, 30, 3, 7, 24]). Despite the success with #CSP and graph homomorphisms, the case with Holant problems is more difficult. Recently, a dichotomy theorem for Holant problems with symmetric signatures was obtained [12], but the general (i.e. not necessarily symmetric) case has a richer and more intricate structure. The same dichotomy for general signatures remains open. Our first main result is an efficient procedure to decide whether a given Holant problem can be solved by affine or product-type signatures via holographic transformations. In past classification efforts, we have been in the same situation several times, where one concrete problem determines the complexity of a wide range of problems. However, the brute force way to check whether this concrete problem already belongs to known tractable classes is time-consuming. We hope that the efficient decision procedure given here mitigates this issue, and would help the pursuit towards a general Holant dichotomy. Theorem 1.1. There is a polynomial-time algorithm to decide, given a finite set of signatures F , whether Holant(F ) admits a holographic algorithm based on affine or product-type signatures. The holographic algorithms for Holant(F ) are all polynomial time in the size of the problem input Ω. The polynomial time decision algorithm of Theorem 1.1 is on another level; it decides based on any specific set of signatures F whether the counting problem Holant(F ) defined by F has such a holographic algorithm. Symmetric signatures are an important special case. Because symmetric signatures can be presented exponentially more succinctly, we would like the decision algorithm to be efficient when measured in terms of this succinct description. An algorithm for this case needs to be exponentially faster than the one in Theorem 1.1. In Theorem 1.2, we present a polynomial time algorithm for the case of symmetric signatures. The increased efficiency is based on several signature invariants under orthogonal transformations. Theorem 1.2. There is a polynomial-time algorithm to decide, given a finite set of symmetric signatures F expressed in the succinct notation, whether Holant(F ) admits a holographic algorithm based on affine or product-type signatures. 2 A dichotomy theorem classifies every set of signatures as defining either a tractable problem or an intractable problem (e.g. #P-hard). Yet it would be more useful if given a specific set of signatures, one could decide to which case it belongs. This is the decidability problem of a dichotomy theorem. In [12], a dichotomy regarding symmetric complex-weighted signatures for Holant problems was proved. However, the decidability problem was left open. Of the five tractable cases in the dichotomy theorem, three of them are easy, but the remaining two cases are more challenging, which are (1) holographic algorithms using affine signatures and (2) holographic algorithms using product-type signatures. As a consequence of Theorem 1.2, this decidability is now proved. Corollary 1.3. The dichotomy theorem for symmetric complex-weighted Holant problems in [12] is decidable in polynomial time. Previous work on holographic algorithms focused almost exclusively on those with matchgates [45, 44, 16, 25, 17, 18, 33]. (This has led to a misconception in the community that holographic algorithms are always based on matchgates.) The first example of a holographic algorithm using something other than matchgates came in [23]. These holographic algorithms use generalized Fibonacci gates. A symmetric signature f = [f0, f1, . . . , fn] is a generalized Fibonacci gate of type λ ∈ C if fk+2 = λfk+1 + fk holds for all k ∈ {0, 1, . . . , n − 2}. The standard Fibonacci gates are of type λ = 1, in which case, the entries of the signature satisfy the recurrence relation of the Fibonacci numbers. The generalized Fibonacci gates were immediately put to use in a dichotomy theorem [21]. As it turned out, for nearly all values of λ, the generalized Fibonacci gates are equivalent to product-type signatures via holographic transformations. Our results provide a systematic way to determine such equivalences and we hope these results help in determining the full reach of holographic algorithms. The constraint functions we call signatures are essentially tensors. A group of transformations acting upon these tensors yields an orbit. Previously, in [12], we have shown that it is sufficient to restrict holographic transformations to those from or related to the orthogonal group (see Lemma 2.7 and Lemma 2.10). Thus, our question can be rephrased as the following: given a tensor, determine whether its orbit under the orthogonal group action (or related transformations) intersects the set of affine or product-type tensors. As showed by Theorems 1.1 and 1.2, this can be done efficiently, even for a set rather than a single tensor. In contrast, this orbit intersection problem with the general linear group acting on two arbitrary tensors is NP-hard [38]. In our setting, the actions are much more restricted and we consider an arbitrary tensor against one of the two fixed sets. Similar orbit problems are central in geometric complexity theory [40]. Our techniques are mainly algebraic. A particularly useful insight is that an orthogonal transformation in the standard basis is equivalent to a diagonal transformation in the(cid:2) 1 1 mations are much easier to understand, this gives us some leverage to understand orbits under orthogonal transformations. Also, the groups of transformations that stabilize the affine and product-type signatures play important roles in our proofs. Comparing to similar results for matchgates [17], the proofs are very different in that each proof relies heavily on distinct properties of matchgates or the affine and product-type signatures. i −i(cid:3) basis. Since diagonal transfor- In Section 2, we review basic notation and state previous results, many of which come from [12]. In Section 3, we present some example problems that are tractable by holographic algorithms using affine or product-type signatures. The proof of Theorem 1.1 spans two sections. The affine case is handled in Section 4 and the product-type case is handled in Section 5. The proof of Theorem 1.2 also spans two sections. Once again, the affine case is handled in Section 6 and the product-type case is handled in Section 7. 2. Preliminaries 2.1. Problems and Definitions The framework of Holant problems is defined for functions mapping [q]k to F for a finite q and some field F. In this paper, we investigate some of the tractable complex-weighted Boolean Holant problems, that is, all functions are of the type [2]k → C. Strictly speaking, for consideration of models of computation, functions take complex algebraic numbers. 3 A signature grid Ω = (G,F , π) consists of a graph G = (V, E) and a set of constraint functions (also called signatures) F , where π labels each vertex v ∈ V and its incident edges with some fv ∈ F and its input variables. Note that in particular, π specifies an ordering of edges/variables on each vertex. The Holant problem on instance Ω is to evaluate HolantΩ = PσQv∈V fv(σ E(v)), a sum over all edge assignments σ : E → {0, 1}. A function fv can be represented by listing its values in lexicographical order as in a truth table, which is a vector in C2deg(v) . Equivalently, fv can be treated as a tensor in (C2)⊗ deg(v). We also use fx to denote the value f (x), where x is a binary string. A function f ∈ F is also called a signature. A symmetric signature f on k Boolean variables can be expressed as [f0, f1, . . . , fk], where fw is the value of f on inputs of Hamming weight w. A Holant problem is parametrized by a set of signatures. Definition 2.1. Given a set of signatures F , we define the counting problem Holant(F ) as: Input: A signature grid Ω = (G,F , π); Output: HolantΩ. A signature f of arity n is degenerate if there exist unary signatures uj ∈ C2 (1 ≤ j ≤ n) such that f = u1 ⊗ ··· ⊗ un. In a signature grid, it is equivalent to replace a degenerate one by corresponding unary signatures. A symmetric degenerate signature has the form u⊗n, where the superscript denotes the tensor power. Replacing a signature f ∈ F by a constant multiple cf , where c 6= 0, does not change the complexity of Holant(F ). It introduces a global factor to HolantΩ. We say a signature set F is tractable (resp. #P-hard) if the corresponding counting problem Holant(F ) can be solved in polynomial time (resp. #P-hard). Similarly for a signature f , we say f is tractable (resp. #P- hard) if {f} is. 2.2. Holographic Reduction To introduce the idea of holographic reductions, it is convenient to consider bipartite graphs. We can always transform a general graph into a bipartite graph while preserving the Holant value, as follows. For each edge in the graph, we replace it by a path of length two. (This operation is called the 2-stretch of the graph and yields the edge-vertex incidence graph.) Each new vertex is assigned the binary Equality signature (=2) = [1, 0, 1]. We use Holant (F G) to denote the Holant problem on bipartite graphs H = (U, V, E), where each vertex in U or V is assigned a signature in F or G, respectively. An input instance for this bipartite Holant problem is a bipartite signature grid and is denoted by Ω = (H,F G, π). Signatures in F are considered as row vectors (or covariant tensors); signatures in G are considered as column vectors (or contravariant tensors) [26]. For a 2-by-2 matrix T and a signature set F , define TF = {g ∃f ∈ F of arity n, g = T ⊗nf}, similarly for F T . Whenever we write T ⊗nf or TF , we view the signatures as column vectors; similarly for f T ⊗n or F T as row vectors. Let T be an element of GL2(C), the group of invertible 2-by-2 complex matrices. The holographic transformation defined by T is the following operation: given a signature grid Ω = (H,F G, π), for the same graph H, we get a new grid Ω′ = (H,F T T −1G, π′) by replacing f ∈ F (or g ∈ G) with T ⊗nf (or (cid:0)T −1(cid:1)⊗n g). Theorem 2.2 (Valiant's Holant Theorem [45]). If there is a holographic transformation mapping signature grid Ω to Ω′, then HolantΩ = HolantΩ′ . Therefore, an invertible holographic transformation does not change the complexity of the Holant problem in the bipartite setting. Furthermore, there is a particular kind of holographic transformation, the orthogonal transformation, that preserves binary equality and thus can be used freely in the standard setting. Let O2(C) be the group of 2-by-2 complex matrices that are orthogonal. Recall that a matrix T is orthogonal if T T T = I. Theorem 2.3 (Theorem 2.6 in [19]). Suppose T ∈ O2(C) and let Ω = (H,F , π) be a signature grid. Under a holographic transformation by T , we get a new grid Ω′ = (H, TF , π′) and HolantΩ = HolantΩ′ . 4 We also use SO2(C) to denote the group of special orthogonal matrices, i.e. the subgroup of O2(C) with determinant 1. 2.3. Tractable Signature Sets without a Holographic Transformation The following two signature sets are tractable without a holographic transformation [24]. Definition 2.4. A k-ary function f (x1, . . . , xk) is affine if it has the form λ · χAx=0 · iPn j=1hvj,xi, where λ 6= 0 is in C, x = (x1, x2, . . . , xk, 1)T, A is a matrix over F2, vj is a vector over F2 for each j = 1, . . . , n, and χ is a 0-1 indicator function such that χAx=0 is 1 iff Ax = 0. Note that the dot product j=1 on the exponent of i = √−1 is evaluated as a sum hvj , xi is calculated over F2, while the summationPn mod 4 of 0-1 terms. We use A to denote the set of all affine functions. Notice that there is no restriction on the number of rows in the matrix A. It is permissible that A is the zero matrix so that χAx=0 = 1 holds for all x. An equivalent way to express the exponent of i is as a quadratic polynomial (evaluated mod 4) where all cross terms have an even coefficient. This equivalent expression is often easier to use. Definition 2.5. A function is of product type if it can be expressed as a function product of unary functions, binary equality functions ([1, 0, 1]), and binary disequality functions ([0, 1, 0]). We use P to denote the set of product-type functions. The above two types of functions, when restricted to be symmetric, have been characterized explicitly. It has been shown (cf. Lemma 2.2 in [35]) that if f is a symmetric signature in P, then f is either degenerate, binary disequality, or of the form [a, 0, . . . , 0, b] for some a, b ∈ C. It is also known that (cf. [19]) the set of non-degenerate symmetric signatures in A is precisely the nonzero signatures (λ 6= 0) in F1 ∪ F2 ∪ F3 with arity at least 2, where F1, F2, and F3 are three families of signatures defined as 1 F1 =nλ(cid:16)[ 1 F2 =nλ(cid:16)[ 1 F3 =nλ(cid:16)[ 1 1 ]⊗k(cid:17) λ ∈ C, k = 1, 2, . . . , r = 0, 1, 2, 3o , −1(cid:3)⊗k(cid:17) λ ∈ C, k = 1, 2, . . . , r = 0, 1, 2, 3o , and −i(cid:3)⊗k(cid:17) λ ∈ C, k = 1, 2, . . . , r = 0, 1, 2, 3o . 0 ]⊗k + ir [ 0 1 ]⊗k + ir(cid:2) 1 i ]⊗k + ir(cid:2) 1 Let F123 = F1 ∪ F2 ∪ F3 be the union of these three sets of signatures. We explicitly list all the signatures in F123 (as row vectors) up to an arbitrary constant multiple from C: 1. [1, 0, . . . , 0,±1]; 2. [1, 0, . . . , 0,±i]; 3. [1, 0, 1, 0, . . . , 0 or 1]; 4. [1,−i, 1,−i, . . . , (−i) or 1]; 5. [0, 1, 0, 1, . . . , 0 or 1]; 6. [1, i, 1, i, . . . , i or 1]; 7. [1, 0,−1, 0, 1, 0,−1, 0, . . ., 0 or 1 or (−1)]; 8. [1, 1,−1,−1, 1, 1,−1,−1, . . ., 1 or (−1)]; 9. [0, 1, 0,−1, 0, 1, 0,−1, . . ., 0 or 1 or (−1)]; 10. [1,−1,−1, 1, 1,−1,−1, 1, . . ., 1 or (−1)]. (F1, r = 0, 2) (F1, r = 1, 3) (F2, r = 0) (F2, r = 1) (F2, r = 2) (F2, r = 3) (F3, r = 0) (F3, r = 1) (F3, r = 2) (F3, r = 3) 1To be consistent with previous papers, we still use F1, F2, and F3 to denote the subclasses of A . They are not to be confused with A1, A2, and A3 that will be introduced in Definition 2.8. 5 2.4. A -transformable and P-transformable Signatures The tractable sets A and P are still tractable under a suitable holographic transformation. This is captured by the following definition. Definition 2.6. A set F of signatures is A -transformable (resp. P-transformable) if there exists a holo- graphic transformation T such that F ⊆ T A (resp. F ⊆ T P) and [1, 0, 1]T ⊗2 ∈ A (resp. [1, 0, 1]T ⊗2 ∈ P). To refine the above definition, we consider the stabilizer group of A , Technically what we defined is the left stabilizer group of A , but it turns out that the left and right stabilizer groups of A coincide [12]. Stab(A ) = {T ∈ GL2(C) T A = A }. Name α D H2 X Z Value √i = e πi 4 = 1+i√2 [ 1 0 0 i ] 1√2(cid:2) 1 1 1 −1(cid:3) 1√2(cid:2) 1 1 i −i(cid:3) [ 0 1 1 0 ] Table 1: Notations for some matrices and numbers 1. Note that Z = DH2 and that D2Z = 1√2(cid:2) 1 1 Some matrices and numbers are used extensively throughout the paper. We summarize them in Table It is easy to verify that D, H2, X, Z ∈ Stab(A ). In fact, Stab(A ) is precisely the set of nonzero scalar multiples of the group generated by D and H2 [12]. Note that the zero matrix is not a stabilizer since A does not include the zero function. −i i(cid:3) = ZX, hence X = Z−1D2Z. The next lemma is the first step toward understanding A -transformable signatures. Recall that O2(C) is the group of 2-by-2 orthogonal complex matrices. The lemma shows that to determine A -transformability, it is necessary and sufficient to consider only the orthogonal transformations and related ones. Lemma 2.7 ([12]). Let F be a set of signatures. Then F is A -transformable iff there exists an H ∈ O2(C) such that F ⊆ H A or F ⊆ H [ 1 0 0 α ] A . Non-degenerate symmetric A -transformable signatures are captured by three sets A1, A2, and A3, which will be defined next (not to be confused with F1, F2, and F3). Definition 2.8. A symmetric signature f of arity n is in, respectively, A1, or A2, or A3 if there exists an H ∈ O2(C) and a nonzero constant c ∈ C such that f has the following form, respectively: • cH⊗n(cid:16)[ 1 • or cH⊗n(cid:16)[ 1 • or cH⊗n(cid:16)[ 1 −1(cid:3)⊗n(cid:17), where β = αtn+2r, r ∈ {0, 1, 2, 3}, and t ∈ {0, 1}; 1 ]⊗n + β(cid:2) 1 −i(cid:3)⊗n(cid:17); i ]⊗n +(cid:2) 1 −α(cid:3)⊗n(cid:17), where r ∈ {0, 1, 2, 3}. α ]⊗n + ir(cid:2) 1 For i ∈ {1, 2, 3}, when such an orthogonal H exists, we say that f ∈ Ai with transformation H. If f ∈ Ai with I2, the identity matrix, then we say f is in the canonical form of Ai. Note that there is no direct correspondences between (Ai) and (Fi). Lemma 2.9 ([12]). Let f be a non-degenerate symmetric signature. Then f is A -transformable iff f ∈ A1 ∪ A2 ∪ A3. 6 Analogous results hold for P-transformable signatures. Let the stabilizer group of P be Stab(P) = {T ∈ GL2(C) T P = P}. 1 0 ] [12]. The group Stab(P) is generated by (up to nonzero scalars) matrices of the form [ 1 0 X = [ 0 1 Lemma 2.10 ([12]). Let F be a set of signatures. Then F is P-transformable iff there exists an H ∈ O2(C) 0 ν ] for any ν ∈ C∗ and Definition 2.11. A symmetric signature f of arity n is in P1 if there exist an H ∈ O2(C) and a nonzero such that F ⊆ HP or F ⊆ H(cid:2) 1 1 c ∈ C such that f = cH⊗n(cid:16)[ 1 i −i(cid:3) P. 1 ]⊗n + β(cid:2) 1 −1(cid:3)⊗n(cid:17), where β 6= 0. It is easy to check that A1 ⊂ P1. We define P2 = A2. For i ∈ {1, 2}, when H ∈ O2(C) exists (in Definition 2.11 and 2.8, respectively), we say that f ∈ Pi with transformation H. If f ∈ Pi with I2, then we say f is in the canonical form of Pi. Lemma 2.12 ([12]). Let f be a non-degenerate symmetric signature. Then f is P-transformable iff f ∈ P1 ∪ P2. 3. Some Example Problems In this section, we illustrate a few problems that are tractable via holographic reductions to affine or product-type functions. Although the algorithms to solve them follow from a known paradigm, it is often non-trivial to find the correct holographic transformation. Our main result provides a systematic way to search for these transformations. 3.1. A Fibonacci-like Problem Fibonacci gates were introduced in [23]. They define tractable counting problems, and holographic algo- rithms based on Fibonacci gates work over general (i.e. not necessarily planar) graphs. However, Fibonacci gates are symmetric by definition. An example of a Fibonacci gate is the signature f = [f0, f1, f2, f3] = [1, 0, 1, 1]. Its entries satisfy the recurrence relation of the Fibonacci numbers, i.e. f2 = f1+f0 and f3 = f2+f1. For Holant(f ), the input is a 3-regular graph, and the problem is to count spanning subgraphs such that no vertex has degree 1. A symmetric signature g = [g0, g1, . . . , gn] is a generalized Fibonacci gate of type λ ∈ C if gk+2 = λgk+1 + gk holds for all k ∈ {0, 1, . . . , n− 2}. The standard Fibonacci gates are of type λ = 1. An example of a generalized Fibonacci gate is g = [3, 1, 3, 1], which has type λ = 0. In contrast to Holant(f ), the problem Holant(g) permits all possible spanning subgraphs. The output is the sum of the weights of each spanning subgraph. The weight of a spanning subgraph S is 3k(S), where k(S) is the number of vertices of even degree in S. Since g = [3, 1, 3, 1] is Fibonacci, the problem Holant(g) is computable in polynomial time [19, 12]. One new family of holographic algorithms in this paper extends Fibonacci gates to asymmetric signatures. In full notation, the ternary signature g is (3, 1, 1, 3, 1, 3, 3, 1)T. Consider the asymmetric signature h = (3, 1,−1,−3,−1,−3, 3, 1)T. This signature h differs from g by a negative sign in four entries. Although h is not a generalized Fibonacci gate or even a symmetric signature, it still defines a tractable Holant problem. Holant(h) = Holant (=2 h) = Holant(cid:0)=2(Z−1)⊗2 Z⊗3h(cid:1) = Holant(cid:16)[1, 0,−1] h(cid:17) , Under a holographic transformation by Z−1, where Z = 1√2(cid:2) 1 1 i −i(cid:3), where h = 2i√2(0, 1, 0, 0, 0, 0, 2i, 0). Both [1, 0,−1](x1, x2) = Equality(x1, x2)·[1,−1](x1) and h(x1, x2, x3) = 2i√2 · Equality(x1, x2) · Disequality(x2, x3) · [1, 2i](x1) are product-type signatures. It turns out that for all values of λ 6= ±2i, the generalized Fibonacci gates of type λ are P-transformable. The value of λ indicates under which holographic transformation the signatures become product type. For λ = ±2i, the generalized Fibonacci gates of type λ are vanishing, which means the output is always zero for every possible input (see [12] for more on vanishing signatures). 7 1 0 0 1 1 0 0 1 1 0 1 0 0 1 (a) An admissible assignment to this graph fragment. The circle vertices are assigned g and the square ver- tices are assigned 6=2. (b) The orientation induced by the assignment in (a). Figure 1: A fragment of an instance to Holant (6=2 g), which must be a (2, 4)-regular bipartite graph. Note the saddle orientation of the edges incident to the two vertices with all four edges depicted. 3.2. Some Cycle Cover Problems and Orientation Problems To express some problems involving asymmetric signatures of arity 4, it is convenient to arrange the 16 outputs into a 4-by-4 matrix. With a slight abuse of notation, we also write a function f (x1, x2, x3, x4) in its matrix form, namely f =" f0000 f0010 f0001 f0011 f1100 f1110 f1101 f1111#, where the row is indexed by two bits (x1, x2) and the f0100 f0110 f0101 f0111 f1000 f1010 f1001 f1011 column is indexed by two bits (x4, x3) in reverse order. We call this the signature matrix. Consider the problem of counting the number of cycle covers in a given graph. This problem is #P- hard even when restricted to planar 4-regular graphs [33]. As a Holant problem, its expression is Holant(f ), where f (x1, x2, x3, x4) is the symmetric signature [0, 0, 1, 0, 0]. The signature matrix of f is(cid:20) 0 0 0 1 1 0 0 0(cid:21). The six entries in the support of f , which are all of Hamming weight two (indicating that a cycle cover passes through each vertex exactly twice), can be divided into two parts, namely {0011, 0110, 1100, 1001} and {0101, 1010}. In the planar setting, this corresponds to a pairing of consecutive or non-consecutive incident edges. Both sets are invariant under cyclic permutations. 0 1 1 0 0 1 1 0 0 1 0 0 0 0 1 0 Suppose we removed the inputs 0101 and 1010 from the support of f , which are the two 1's on the anti- diagonal in the middle of Mf . Call the resulting signature g, which has signature matrix(cid:20) 0 0 0 1 new 0's impose a constraint on the types of cycle covers allowed. We call a cycle cover valid if it satisfies this new constraint. A valid cycle cover must not pass through a vertex in a "crossing" way. Counting the number of such cycle covers over 4-regular graphs can be done in polynomial time, even without the planarity restriction. The signature g(x1, x2, x3, x4) = Dis-Equality(x1, x3) · Dis-Equality(x2, x4) is of the product type P, therefore Holant(g) is tractable. 1 0 0 0(cid:21).2 These Under a holographic transformation by Z = 1√2(cid:2) 1 1 where g := (Z−1)⊗4g =(cid:20) −1 0 0 0 Holant(g) = Holant (=2 g) = Holant(cid:0)=2Z⊗2 (Z−1)⊗4g(cid:1) = Holant (6=2 g) , 0 0 0 −1(cid:21). This problem has the following interpretation. It is a Holant problem i −i(cid:3), we obtain the problem on bipartite graphs. On the right side of the bipartite graph, the vertices must all have degree 4 and are assigned the signature g. On the left side, the vertices must all have degree 2 and are assigned the binary disequality constraint 6=2. The disequality constraints suggest an orientation between their two neighboring vertices of degree 4 (see Figure 1). By convention, we view the edge as having its tail assigned 0 and its head 0 0 1 0 0 1 0 0 2Recall that in general we require the input signature grid to specify the ordering of the edges (namely variables) on each vertex. This is not necessary for symmetric signatures, but when asymmetric signatures are involved, specifying the ordering is essential. 8 assigned 1. Then every valid assignment in this bipartite graph naturally corresponds to an orientation in the original 4-regular graph. If the four inputs 0011, 0110, 1100, and 1001 were in the support of g, then the Holant sum would be over all possible orientations with an even number of incoming edges at each vertex. As it is, the sum is over all possible orientations with an even number of incoming edges at each vertex that also forbid those four types of orientations at each vertex, as specified by g. The following orientations are admissible by g: The orientation of the edges are such that at each vertex all edges are oriented out (source vertex), or all edges are oriented in (sink vertex), or the edges are cyclically oriented in, out, in, out (saddle vertex). vertices in an orientation O. We can express this asPO∈O(G)(−1)s(O), where O(G) is the set of admissible Thus, the output of Holant (6=2 g) is a weighted sum over of these admissible orientations. Each admis- sible orientation O contributes a weight (−1)s(O) to the sum, where s(O) is the number of source and sink orientations for G, which are those orientations that only contain source, sink, and saddle vertices. In words, the value is the number of admissible orientations with an even number of sources and sinks minus the number of admissible orientations with an odd number of sources and sinks. This orientation problem may seem quite different from the restricted cycle cover problem we started with, but they are, in fact, the same problem. Since Holant(g) is tractable, so is Holant (6=2 g). Now, consider a slight generalization of this orientation problem. Problem: #λ-SourceSinkSaddleOrientations Input: An undirected 4-regular graph G (equipped with a local edge-ordering on every vertex). Output: PO∈O(G) λs(O). For λ = −1, we recover the orientation problem from above. For λ = 1, the problem is also tractable since, when viewed as a bipartite Holant problem on the (2, 4)-regular bipartite vertex-edge incidence graph, the disequality constraint on the vertices of degree 2 and the constraint on the vertices of degree 4 are both product-type functions. As a function of x1, x2, x3, x4, the constraint on the degree 4 vertices is Equality(x1, x3) · Equality(x2, x4). Let sk,m(G) be the number of O ∈ O(G) such that s(O) ≡ k (mod m). Then the output of this problem with λ = 1 is s0,2(G) + s1,2(G) and the output of this problem with λ = −1 is s0,2(G) − s1,2(G). Therefore, we can compute both s0,2(G) and s1,2(G). However, more is possible. For λ = i, the problem is tractable using affine constraints. In the (2, 4)-regular bipartite vertex-edge incidence graph, the disequality constraint assigned to the vertices of degree 2 is affine. On the vertices of degree 4, the assigned constraint function is an affine signature since the affine support is defined by the affine linear system x1 = x3 and x2 = x4 while the quadratic polynomial in the exponent of i is 2x1x2 + 3x1 + 3x2 + 1. (Recall that in the definition of A , Definition 2.4, we need to evaluate the quadratic polynomial mod 4 instead of 2, and x2 = x for any x ∈ {0, 1}.) Although the output is a complex number, the real and imaginary parts encode separate information. The real part is s0,4(G) − s2,4(G) and the imaginary part is s1,4(G) − s3,4(G). Since s0,2(G) = s0,4(G) + s2,4(G) and s1,2(G) = s1,4(G) + s3,4(G), we can actually compute all four quantities s0,4(G), s1,4(G), s2,4(G), and s3,4(G) in polynomial time. 3.3. An Enigmatic Problem Some problems may be a challenge for the human intelligence to grasp. But in a platonic view of computational complexity, they are no less valid problems. For example, consider the problem Holant((1 + c2)−1[1, 0,−i] f ) where f has the signature matrix (4+4i)(cid:18)28+20√2+r2(cid:16)799+565√2(cid:17)(cid:19) (4+4i)(cid:18)28+20√2+r2(cid:16)799+565√2(cid:17)(cid:19) −8i(cid:18)13+9√2+2q82+58√2(cid:19) 0   −8i(cid:18)13+9√2+2q82+58√2(cid:19) (−4+4i)(cid:18)12+8√2+q274+194√2(cid:19) (−4+4i)(cid:18)12+8√2+q274+194√2(cid:19) −16(cid:18)13+9√2+2q82+58√2(cid:19) −8i(cid:18)13+9√2+2q82+58√2(cid:19) 8i(cid:18)18+13√2+4q41+29√2(cid:19) (4+4i)(cid:18)28+20√2+r2(cid:16)799+565√2(cid:17)(cid:19) (4+4i)(cid:18)28+20√2+r2(cid:16)799+565√2(cid:17)(cid:19)   and c = 1 +√2 +q2(1 + √2). Most likely no one has ever considered this problem before. Yet this nameless −c 1(cid:3), and hence it is really the same problem as a more (−4+4i)(cid:18)12+8√2+q274+194√2(cid:19) (−4+4i)(cid:18)12+8√2+q274+194√2(cid:19) 8i(cid:18)18+13√2+4q41+29√2(cid:19) −8i(cid:18)13+9√2+2q82+58√2(cid:19) problem is A -transformable under T = [ 1 0 0 α ](cid:2) 1 c 9 comprehensible problem defined by f = (T −1)⊗4f . Namely, Holant((1 + c2)−1[1, 0, −i] f ) = Holant((1 + c2)−1[1, 0, −i]T ⊗2 (T −1)⊗4f ) = Holant([1, 0, 1] f ) = Holant( f ), 3 + x2 1 −1 1 −1 −1 where f =(cid:20) 1 −1 −1 −1 1(cid:21). We can express f as f (x1, x2, x3, x4) = iQ(x), where Q(x1, x2, x3, x4) = 2(x2 −1 −1 1 + −1 −1 −1 −1 4 + x1x2 + x2x3 + x3x4 + x4x1). Therefore, f is affine, which means that Holant( f ) as well as x2 2 + x2 Holant((1 + c2)−1[1, 0,−i] f ) are tractable. Furthermore, notice that f only contains integers even though (1 + c2)−1[1, 0,−i] and f contain many complex numbers with irrational real and imaginary parts. Thus, Holant((1 + c2)−1[1, 0,−i] f ) is not only tractable, but it always outputs an integer. Apparent anomalies like Holant((1 + c2)−1[1, 0,−i] f ), however contrived they may seem to be to the human eye, behoove the creation of a systematic theory to understand and characterize the tractable cases. 4. General A -transformable Signatures In this section, we give the algorithm to check A -transformable signatures. Our general strategy is to bound the number of possible transformations by a polynomial in the length of the function, and then enumerate all of them. There are some cases where this number cannot be bounded, and those cases are handled separately. Let f be a signature of arity n. It is given as a column vector in C2n with bit length N , which is on the order of 2n. We denote its entries by fx = f (x) indexed by x ∈ {0, 1}n. The entries are from a fixed degree algebraic extension of Q and we may assume basic bit operations in the field take unit time. . Hence a naive check of the membership of affine signatures would result in a super-polynomial running time in N . Instead, we present a polynomial-time algorithm. Notice that the number of general affine signatures of arity n is on the order of 2n2 Lemma 4.1. There is an algorithm to decide whether a given signature f of arity n belongs to A with running time polynomial in N , the bit length of f . Proof. We may assume that f is not identically zero. Normalize f so that the first nonzero entry of f is 1. If there exists a nonzero entry of f after normalization that is not a power of i, then f 6∈ A , so assume that all entries are now powers of i. The next step is to decide if the support S 6= ∅ of f forms an affine linear subspace. We try to build a basis for S inductively. It may end successfully or find an inconsistency. We choose the index of the first nonzero entry b0 ∈ S as our first basis element. Assume we have a set of basis elements B = {b0, . . . , bk} ⊆ S. Consider the affine linear span Span(B). We check if Span(B) ⊆ S. If not, then S is not affine and f 6∈ A , so suppose that this is the case. If Span(B) = S, then we are done. Lastly, if S − Span(B) 6= ∅, then pick the next element bk+1 ∈ S − Span(B). Let B′ = B ∪ {bk+1} and repeat with the new basis set B′. Now assume that S is an affine subspace, that we have a linear system defining it, and that every nonzero entry of f is a power of i. If S has dimension 0, then S is a single point, and f ∈ A . Otherwise, dim(S) = r ≥ 1, and (after reordering) x1, . . . , xr are free variables of the linear system defining S. For each x ∈ {0, 1}r, let y ∈ {0, 1}n−r be the unique extension such that xy ∈ S. For each x, define px ∈ Z4 such that fxy = ipx 6= 0. We will use the alternative expression for affine functions: namely, we want to decide if there exists a quadratic polynomial Q(x) = rXj=1 cjx2 j + 2 X1≤k<ℓ≤r ckℓxkxℓ + c, where c, cj, ckℓ ∈ Z4, for 1 ≤ j ≤ r and 1 ≤ k < ℓ ≤ r, such that Q(x) ≡ px (mod 4) for all x ∈ {0, 1}r. Setting x = 0 ∈ {0, 1}r determines c. Setting exactly one xj = 1 and the rest to 0 determines cj. Setting exactly two xk = xℓ = 1 and the rest to 0 determines ckℓ. Then we verify if Q(x) is consistent with f , and f ∈ A iff it is so. 10 For later use, we note the following corollary. Corollary 4.2. There is an algorithm to decide whether a given signature f of arity n belongs to [ 1 0 with running time polynomial in N , the bit length of f . 0 α ] A Proof. For arity(f ) = n, just check if(cid:2) 1 0 α−1(cid:3)⊗n 0 f ∈ A by Lemma 4.1. We can strengthen Lemma 2.7 by restricting to orthogonal transformations within SO2(C). Lemma 4.3. Let F be a set of signatures. Then F is A -transformable iff there exists an H ∈ SO2(C) such that F ⊆ H A or F ⊆ H [ 1 0 Proof. Sufficiency is obvious by Lemma 2.7. 0 α ] A . Assume that F is A -transformable. By Lemma 2.7, there exists an H ∈ O2(C) such that F ⊆ H A or 0 α ] A . If H ∈ SO2(C), we are done, so assume that H ∈ O2(C) \ SO2(C). We want to find an 0 −1(cid:3) ∈ SO2(C). There are two cases F ⊆ H [ 1 0 H′ ∈ SO2(C) such that F ⊆ H′A or F ⊆ H′ [ 1 0 to consider. 1. Suppose F ⊆ H A . Then since(cid:2) 1 0 2. Suppose F ⊆ H [ 1 0 0 α ] A . Then since(cid:2) 1 0 0 −1(cid:3) A 0 α ] A . Let H′ = H(cid:2) 1 0 0 −1(cid:3) ∈ Stab(A ), F ⊆ H(cid:2) 1 0 0 −1(cid:3) ∈ Stab(A ) commutes with [ 1 0 = H(cid:2) 1 0 0 α ](cid:2) 1 0 0 −1(cid:3) A 0 −1(cid:3) [ 1 0 F ⊆ H [ 1 0 = H′ [ 1 0 = H′A . 0 α ] A . 0 α ] A 0 α ], We now observe some properties of a signature under transformations in SO2(C). Let f be a signature and H =(cid:2) a b H with eigenvalues a− bi and a + bi respectively. Let Z′ =(cid:2) 1 i −b a(cid:3) ∈ SO2(C) where a2 + b2 = 1. Notice that v0 = (1, i) and v1 = (1,−i) are row eigenvectors of a+bi(cid:3). 1 −i(cid:3). Then Z′H = T Z′, where T =(cid:2) a−bi For an index or a bit-string u = (u1, . . . , un) ∈ {0, 1}n of length n, let 0 0 vu := vu1 ⊗ vu2 ⊗ . . . ⊗ vun , and let wt(u) be the Hamming weight of u. Then vu is a row eigenvector of the 2n-by-2n matrix H⊗n with eigenvalue (a − bi)n−wt(u)(a + bi)wt(u) = (a − bi)n−2wt(u) = (a + bi)2wt(u)−n (1) since (a + bi)(a − bi) = a2 + b2 = 1. In this paper, the following Z′-transformation plays an important role. For any function f on {0, 1}n, we define f = Z′⊗nf. Then fu = hvu, fi, as a dot product. Lemma 4.4. Suppose f and g are signatures of arity n and let H = (cid:2) a b g = H⊗nf iff g = T ⊗n f . −b a(cid:3) and T = (cid:2) a−bi 0 0 a+bi(cid:3). Then Proof. Since Z′H = T Z′, g = H⊗nf ⇐⇒ Z′⊗ng = Z′⊗nH⊗nf ⇐⇒ Z′⊗ng = T ⊗nZ′⊗nf ⇐⇒ g = T ⊗n f . 11 We note that vT u is also a column eigenvector of H⊗n with eigenvalue (a−bi)2wt(u)−n. Now we characterize the signatures that are invariant under transformations in SO2(C). Lemma 4.5. Let f be a signature. Then f is invariant under transformations in SO2(C) (up to a nonzero constant) iff the support of f contains at most one Hamming weight. Proof. This clearly holds when f is identically zero, so assume that f contains a nonzero entry and has arity n. Such an f is invariant under any H (up to a nonzero constant) iff f is a column eigenvector of H⊗n. Consider H = (cid:2) a b −b a(cid:3) ∈ SO2(C) where a2 + b2 = 1. Then H⊗n has n + 1 distinct eigenvalues (a − bi)n−w(a + bi)w, for 0 ≤ w ≤ n. As a consequence, f is a column eigenvector of H⊗n iff f is a nonzero linear combination of vT u of the same Hamming weight wt(u). Hence f is invariant under H iff the support of f contains at most one Hamming weight. Using Lemma 4.5, we can efficiently decide if there exists an H ∈ SO2(C) such that H⊗nf ∈ A . Lemma 4.6. There is an algorithm to decide in time polynomial in N , for any input signature f of arity n, whether there exists an H ∈ SO2(C) such that H⊗nf ∈ A . If so, either f ∈ A and f is invariant under any transformation in SO2(C), or there exist at most 8n many H ∈ SO2(C) such that H⊗nf ∈ A , and they can all be computed in time polynomial in N . Proof. Compute f = Z′⊗nf . If the support of f contains at most one Hamming weight, then by Lemma 4.5, f is invariant under any H ∈ SO2(C). Therefore we only need to directly decide if f ∈ A , which we do by Lemma 4.1. Now assume there are at least two nonzero entries of f with distinct Hamming weights, say u1, u2 ∈ −b a(cid:3) ∈ {0, 1}n. Then fu1 and fu2 are nonzero, and 0 < wt(u2)− wt(u1) ≤ n. Suppose there exists an H =(cid:2) a b a+bi(cid:3) SO2(C) such that g = H⊗nf ∈ A . Then by Lemma 4.4, we have g = T ⊗n f , where T = (cid:2) a−bi is a diagonal transformation. Recall H2 and D from Table 1. Since Z′ = √2H2D ∈ Stab(A ), we have g = Z′⊗ng ∈ A . Also since T is diagonal, both gu1 and gu2 are nonzero. Therefore, there must exist an r ∈ {0, 1, 2, 3} such that 0 0 ir = gu2 gu1 = (a + bi)2wt(u2)−n fu2 (a + bi)2wt(u1)−n fu1 = (a + bi)2wt(u2)−2wt(u1) fu2 fu1 , (2) where we used (1). Recall that 0 < wt(u2) − wt(u1) ≤ n. View a + bi as a variable, and then there are at most 2n solutions to (2), given r and fu1 and fu2. There are 4 possible values of r, resulting in at most 8n many solutions for a, b ∈ C such that a + bi satisfies (2) and a2 + b2 = 1. Each (a, b) solution corresponds to a distinct H ∈ SO2(C). We also want to efficiently decide if there exists an H ∈ SO2(C) such that H⊗nf ∈ [ 1 0 0 α ] A . 0 α ] A with running time polynomial in N . If so, either f ∈ [ 1 0 Lemma 4.7. There is an algorithm to decide, for any input signature f of arity n, whether there exists an H ∈ SO2(C) such that H⊗nf ∈ [ 1 0 0 α ] A and f is invariant under any transformation in SO2(C), or there exist O(nN 16) many H ∈ SO2(C) such that H⊗nf ∈ [ 1 0 Proof. Compute f = Z′⊗nf . If the support of f contains at most one Hamming weight, then by Lemma 4.5, f is invariant under any H ∈ SO2(C). Therefore we only need to directly decide if f ∈ [ 1 0 0 α ] A , which we do by Corollary 4.2. 0 α ] A , and they can all be computed in polynomial time in N . Now assume there are at least two nonzero entries of f that are of distinct Hamming weight. Let u1, u2 ∈ {0, 1}n be such that fu1 and fu2 are nonzero, and 0 < wt(u2) − wt(u1) ≤ n. We derive necessary 0 α ] A . Thus, assume such an H =(cid:2) a b −b a(cid:3) conditions for the existence of H ∈ SO2(C) such that H⊗nf ∈ [ 1 0 exists, where a2 + b2 = 1. 12 Let g = H⊗nf . Then g = Z′⊗ng ∈ (cid:2) 1 i a+bi(cid:3). Thus gu = (a + bi)2wt(u)−n fu for any u ∈ {0, 1}n. Let t = wt(u1) − wt(u2). Then (cid:2) a−bi 1 −i(cid:3) [ 1 0 0 α ] A . By Lemma 4.4, we have g = T ⊗n f , where T = 0 0 gu1 gu2 = (a + bi)2wt(u1)−n fu1 (a + bi)2wt(u2)−n fu2 = (a + bi)2t fu1 fu2 . Hence (a + bi)2t = fu2 fu1 gu1 gu2 . · 1 −i(cid:3)⊗n factor cancels when taking ratios of entries, so we omit it. Let h′ = [ 1 0 g =(cid:2) 1 i power of α or 0. Moreover, each entry of (cid:2) 1 i We claim that the value of each entry in g as well as the number of possible values is bounded by a polynomial in N , and hence so are the ratios between them. Let h ∈ A be a signature such that 0 α ]⊗n h. Every nonzero entry of h is a power of i, up to a constant factor λ. This constant [ 1 0 0 α ]⊗n h. Then every entry of h′ is a is also a power of α. Therefore every entry of g is an exponential sum of 2n terms, each a power of α or 0. Recall that α8 = 1 and hence there are 8 possible values of these powers. Let c0 denote the number of 0 and ci (for 1 ≤ i ≤ 8) denote the number of αi in an entry gu of g. Then we have 1 −i(cid:3)⊗n and c0 + ci = 2n 8Xi=1 (c0, . . . , c8). There are at most (cid:0)2n+8 8 (cid:1) = O(N 8) choices of (c0, . . . , c8). Thus the number of all possible Clearly the total number of possible values of entries in gu is at most the number of possible choices of ratios is at most O(N 16), and can all be enumerated in time polynomial in N . For any possible value of the ratio gu1 gu2 gives at most 2n different transformations H. Therefore, the total number of transformations is bounded by O(nN 16), and we can find them in time polynomial in N . , each possible value of ciαi = gu. 8Xi=1 fu2 fu1 Now we give an algorithm that efficiently decides if a set of signatures is A -transformable. Theorem 4.8. There is a polynomial-time algorithm to decide, for any finite set of signatures F , whether F is A -transformable. If so, at least one transformation can be found. Proof. By Lemma 4.3, we only need to decide if there exists an H ∈ SO2(C) such that F ⊆ H A or F ⊆ H [ 1 0 0 α ] A . To every signature in F , we apply Lemma 4.6 or Lemma 4.7 to check each case, respectively. If no H exists for some signature, then F is not A -transformable. Otherwise, every signature is A -transformable If every signature in F is invariant under transformations in SO2(C), then F for some H ∈ SO2(C). is A -transformable. Otherwise, we pick the first f ∈ F that is not invariant under transformations in SO2(C). The number of possible transformations that work for f is bounded by a polynomial in the size of the presentation of f . We simply try all such transformations on all other signatures in F that are not invariant under transformations in SO2(C), respectively using Lemma 4.1 or Corollary 4.2 to check if the transformation works. 5. General P-transformable Signatures In this section, we give the algorithm to check P-transformable signatures. Once again, our general strategy is to bound the number of possible transformations (with a few exceptions), and then enumerate all of them. Indeed, the bound will be a constant in this section. The distinct feature for P-transformable signatures is that we have to decompose them first. We begin with the counterpart to Lemma 4.3, which strengthens Lemma 2.10 by restricting to either orthogonal transformations within SO2(C) or no orthogonal transformation at all. 13 H ∈ SO2(C) such that F ⊆ HP. Proof. Sufficiency is obvious by Lemma 2.10. Lemma 5.1. Let F be a set of signatures. Then F is P-transformable iff F ⊆(cid:2) 1 1 F ⊆ H(cid:2) 1 1 Assume that F is P-transformable. By Lemma 2.10, there exists an H ∈ O2(C) such that F ⊆ HP or 1. Suppose F ⊆ HP. If H ∈ SO2(C), then we are done, so assume that H ∈ O2(C) \ SO2(C). We want i −i(cid:3) P. There are two cases to consider. to find an H′ ∈ SO2(C) such that F ⊆ H′P. Let H′ = H(cid:2) 1 0 i −i(cid:3) P or there exists an 0 −1(cid:3) ∈ SO2(C). Then 0 0 = H′P a−bi(cid:3) P F ⊆ H(cid:2) 1 0 0 −1(cid:3) P −b a(cid:3) ∈ SO2(C), then F ⊆ H(cid:2) 1 1 i −i(cid:3) P i −i(cid:3)(cid:2) a+bi ⊆(cid:2) 1 1 ⊆(cid:2) 1 1 i −i(cid:3) P a−bi(cid:3) ∈ Stab(P). Otherwise, H = (cid:2) a b a−bi(cid:3) and (cid:2) a+bi F ⊆ H(cid:2) 1 1 i −i(cid:3) P 0 (cid:3) P ⊆(cid:2) 1 1 i −i(cid:3)(cid:2) 0 i −i(cid:3) P ⊆(cid:2) 1 1 0 (cid:3) ∈ Stab(P). 0 (cid:3) and(cid:2) 0 a−bi a−bi a+bi 0 0 a+bi b −a(cid:3) ∈ O2(C) \ since(cid:2) 1 0 0 −1(cid:3) ∈ Stab(P). 2. Suppose F ⊆ H(cid:2) 1 1 i −i(cid:3) P. If H =(cid:2) a b since H(cid:2) 1 1 SO2(C) and i −i(cid:3) = (cid:2) 1 1 i −i(cid:3)(cid:2) a+bi 0 0 since H(cid:2) 1 1 i −i(cid:3) =(cid:2) 1 1 i −i(cid:3)(cid:2) 0 a+bi a−bi The "building blocks" of P are signatures whose support is contained in two entries with complementary indices. However, for technical convenience that will be explained shortly, in the following definition we restrict to functions that are either unary, or have support of size exactly two. Recall that two signatures are considered the same if one is a nonzero multiple of the other. Definition 5.2. A k-ary function f is a generalized equality if it is a nonzero multiple of [0, 0], [1, 0], [0, 1], or satisfies We use E to denote the set of all generalized equality functions. ∃x ∈ {0, 1}k, ∀y ∈ {0, 1}k, fy = 0 ⇐⇒ y 6∈ {x, x}. For any set F , we let hFi denote the closure under function products without shared variables. It is easy to show that P = hE i (cf. [20]). If we view signatures as tensors, then h·i is the closure under tensor products. That is, if f (x1, x2) = f1(x1)f2(x2), then f = f1⊗ f2 with a correct ordering of indices. In general, we call such f reducible, defined next. Definition 5.3. We call a function f of arity n on variable set x reducible if f has a non-trivial decompo- sition, namely, there exist f1 and f2 of arities n1 and n2 on variable sets x1 and x2, respectively, such that 1 ≤ n1, n2 ≤ n − 1, x1 ∪ x2 = x, x1 ∩ x2 = ∅, and f (x) = f1(x1)f2(x2). Otherwise we call f irreducible. Note that all unary functions, including [0, 0], are irreducible. However, the identically zero function of arity greater than one is reducible. Recall that we call a function degenerate if it is a tensor product of unary functions. All degenerate functions of arity ≥ 2 are reducible, but not vice versa -- a reducible function may be decomposable into only non-unary functions. Due to the same reason, degenerate functions are trivially tractable, but reducible functions are not necessarily so. 14 If a function f is reducible, then we can factor it into functions of smaller arity. This procedure can be applied recursively and terminates when all components are irreducible. Therefore any function has at least one irreducible factorization. We show that such a factorization is unique for functions that are not identically zero. Lemma 5.5. Let f be a function of arity n on variables x that is not identically zero. Assume there exist irreducible functions fi and gj, and two partitions {xi} and {yj} of x for 1 ≤ i ≤ k and 1 ≤ j ≤ k′, such that f (x) = fi(xi) = gj(yj ). kYi=1 k′Yj=1 Definition 5.2 is a slight modification of a similar definition for E that appeared in Section 2 of [20]. For both definitions of E , it follows that P = hE i. The motivation for our slight change in the definition is so that every signature in E is irreducible. Irreducibility is preserved by transformations. Lemma 5.4. Let f be an irreducible function of arity n, and T be a 2-by-2 non-singular matrix. Then g = T ⊗nf is also irreducible. Proof. Suppose g is reducible. By Definition 5.3, there is a non-trivial decomposition g = g1 ⊗ g2. Hence g also has a non-trivial decomposition. f =(cid:0)T −1(cid:1)⊗n Then k = k′, the partitions are the same, and there exists a permutation π on {1, 2,··· , k} such that fi = gπ(j) up to nonzero factors. Proof. Since f is not identically zero, none of the fi or gj is identically zero. Fix an assignment u2, . . . , uk i=2xi) for 1 ≤ j ≤ k′. Let the assignments i=2 fi(ui) 6= 0. Let zj = yj ∩ x1, and vj = yj ∩ (∪k u2, . . . , uk restricted to vj be wj. Then we have such that c =Qk cf1(x1) = f1(x1) fi(ui) = kYi=2 k′Yj=1 gj(zj , wj). Define new functions hj(zj) = gj(zj, wj ) for 1 ≤ j ≤ k′. Then f1(x1) = 1 c k′Yj=1 hj(zj ). Since f1 is irreducible, there cannot be two zj that are nonempty. And yet, x1 = ∪k′ j=1zj , so it follows that x1 = zj for some 1 ≤ j ≤ k′. We may assume j = 1, so x1 ⊆ y1. By the same argument we have y1 ⊆ xi, for some i. But by disjointness of x = ∪k i=1xi, we must have y1 ⊆ x1. Thus after a permutation, we have x1 = y1. Therefore f1 = g1 up to a nonzero constant. By fixing some assignment to x1 = y1 such that f1 and g1 are not zero, we may cancel this factor, and the proof is completed by induction. Therefore we must have that k = k′ and the two sets {fi} and {gj} are equal, where we identify functions up to nonzero constants. In fact, we can efficiently find the unique factorization. Lemma 5.6. There is an algorithm to compute in time polynomial in N , for any input signature f of arity n that is not identically zero, the unique factorization of f into irreducible factors. More specifically, the i=1 ni = n algorithm computes irreducible f1, . . . , fk of arities n1, . . . , nk ∈ Z+ (for some k ≥ 1) such thatPk and f (x1, . . . , xk) =Qk i=1 fi(xi). 15 Proof. We may partition the variables x into two sets x1 and x2 of length n1 and n2, respectively, such that 1 ≤ n1, n2 ≤ n− 1, x1∪ x2 = x, and x1∩ x2 = ∅. Define a 2n1-by-2n2 matrix M such that Mu1,u2 = f (u1, u2) for u1 ∈ {0, 1}n1 and u2 ∈ {0, 1}n2. Then M is of rank at most 1 iff there exist f1 and f2 of arity n1 and n2, such that f (x) = f1(x1)f2(x2). Therefore, in order to factor f , we only need to run through all distinct partitions, and check if there exists at least one such matrix of rank at most 1. If none exists, then f is irreducible. The total number of possible such partitions is 2n−1 − 1. Hence the running time is polynomial in 2n ≤ N . component is irreducible. The total running time is polynomial in N . Once we have found f = f1 ⊗ f2, we recursively apply the above procedure to f1 and f2 until every This factorization algorithm gives a simple algorithm to determine membership in P. Lemma 5.7. There is an algorithm to decide, for a given signature f of arity n, whether f ∈ P with running time polynomial in N . Proof. We may assume that f is not identically zero, and we obtain its unique factorization f =Ni fi by Lemma 5.6. Then f ∈ P iff for all i, we have fi ∈ E . Since membership in E is easy to check, our proof is complete. Let T ∈ GL2(C) be some transformation and f some signature. To check if f ∈ T P, it suffices to first factor f and then check if each irreducible factor is in T E . T ∈ GL2(C). Then f ∈ T P iff fi ∈ T E for all 1 ≤ i ≤ k. i=1 fi is not identically zero and that fi is irreducible for all 1 ≤ i ≤ k. Let Lemma 5.8. Suppose f =Nk Proof. Suppose f is of arity n and fi is of arity ni so thatPk there exists gi ∈ E such that fi = T ⊗nigi. Thus f =Nk we haveNk m1, . . . , mk′ ∈ Z+, such that f = T ⊗ng, where g = Nk′ T ⊗migi ∈ T E for all 1 ≤ i ≤ k′, which is also irreducible by Lemma 5.4. ThenNk′ i=1 ni = n. If fi ∈ T E for all 1 ≤ i ≤ k, then i=1 gi. Since gi ∈ E , On the other hand, assume f ∈ T P. By the definition of P, there exist g1, . . . , gk′ ∈ E of arities i=1 gi. Since gi ∈ E , gi is irreducible. Let f′i = i=1 fi. By Lemma 5.5, we have k = k′ and {fi} and {f′i} are the same up to a permutation. Therefore each fi ∈ T E . i=1 f′i = f =Nk i=1 fi =Nk i=1 T ⊗nigi = T ⊗nNk i=1 gi ∈ P. Therefore f ∈ T P. With Lemma 5.6 and Lemma 5.8 in mind, we focus our attention on membership in E . We show how to efficiently decide if there exists an H ∈ SO2(C) such that H⊗nf ∈ E when f is irreducible. Lemma 5.9. There is an algorithm to decide, for a given irreducible signature f of arity n ≥ 2, whether there exists an H ∈ SO2(C) such that H⊗nf ∈ E with running time polynomial in N . If so, there exist at most eight H ∈ SO2(C) such that H⊗nf ∈ E unless f = (1, 0, 0, 1)T or f = (0, 1,−1, 0)T. −b a(cid:3) ∈ SO2(C) such that g = H⊗nf ∈ E , where a2 + b2 = 1. Then Proof. Assume there exists an H =(cid:2) a b 1 −i(cid:3) E . In by Lemma 4.4, there exists a diagonal transformation T =(cid:2) a−bi particular, g and f have the same support. For two vectors u, x ∈ {0, 1}n, the entry indexed by row u and column x in the matrix (cid:2) 1 i is iwt(x)(−1)hx,ui, where wt(·) denotes Hamming weight and h·,·i is the dot product. Since g ∈ E , g is irreducible. Thus g has two nonzero entries with opposite index, say x and x. Hence a+bi(cid:3) such that g = T ⊗n f ∈(cid:2) 1 i 1 −i(cid:3)⊗n 0 0 we have for any vector u ∈ {0, 1}n. gu = iwt(x)(−1)hx,uigx + iwt(x)(−1)hx,uigx = iwt(x)(−1)hx,uigx + in−wt(x)(−1)wt(u)−hx,uigx = (−1)hx,ui(cid:16)iwt(x)gx + in−wt(x)(−1)wt(u)gx(cid:17) 16 For u1, u2 ∈ {0, 1}n, if wt(u1) ≡ wt(u2) (mod 2), then gu1 = ±gu2. (3) Therefore, if any entry of f with even Hamming weight is 0, then all entries with even Hamming weight are 0. This also holds for entries with odd Hamming weight. However, f is not identically zero because it is irreducible and of arity n ≥ 2. Therefore, we know that either all entries of even Hamming weight are not 0 or all entries of odd Hamming weight are not 0. If n ≥ 3, or if n = 2 and all entries of even Hamming weight are not 0, then we can take two nonzero entries of f whose Hamming weight differ by 2. Their ratio restricts the possible choices of a + bi, as in the proof of Lemma 4.7, because the only possible ratios for gu1/gu2 are ±1 by (3). Together with a2 + b2 = 1, this gives at most 8 possible matrices H ∈ SO2(C). The remaining case is when n = 2 and all entries of f with even Hamming weight are 0. By (3), we have g = λ(0, 1,±1, 0)T for some λ 6= 0 since g and f have the same support. Then from f = (T −1)⊗2g, where T −1 =(cid:2) a+bi ±1 0(cid:3). Hence, up to a nonzero scalar, f = (0, 1, 1, 0)T or f = (0, 1,−1, 0)T. Finally f = (Z′−1)⊗2 f , and we get f = (1, 0, 0, 1)T or f = (0, 1,−1, 0)T, up to a nonzero scalar. a−bi(cid:3) is diagonal, we calculate that T −1(cid:2) 0 1 ±1 0(cid:3) (T −1)T =(cid:2) 0 1 0 0 Now we give an algorithm that efficiently decides if a set of signatures is P-transformable. Theorem 5.10. There is a polynomial-time algorithm to decide, for any finite set of signatures F , whether F is P-transformable. If so, at least one transformation can be found. i −i(cid:3) P or if there exists an H ∈ SO2(C) such that i −i(cid:3) P, we simply apply Lemma 5.7 to each signature in(cid:2) 1 1 Proof. By Lemma 5.1, we only need to decide if F ⊆(cid:2) 1 1 F ⊆ HP. To check if F ⊆(cid:2) 1 1 not of this form. This means that f has a unique factorization f = Ni fi where some fi is not a unary Now to check if F ⊆ HP. We may assume that no signature in F is identically zero. Now we obtain the unique factorization of each signature in F using Lemma 5.6. If every irreducible factor is either a unary signature, or (1, 0, 0, 1)T, or (0, 1,−1, 0)T, then F ⊆ hE i = P. Otherwise, let f ∈ F be a signature that is signature, or (1, 0, 0, 1)T, or (0, 1,−1, 0)T. Assume it is f1. By applying Lemma 5.8 to f , we get the necessary condition f1 ∈ H E . Then we apply Lemma 5.9 to f1. If the test passes, then by the definition of f1, we have at most eight transformations in SO2(C) that could work. For each possible transformation H, we apply Lemma 5.7 to every signature in H−1F to check if it works. i −i(cid:3)−1 F . 6. Symmetric A -transformable Signatures In the next two sections, we consider the case when the signatures are symmetric. The significant difference is that a symmetric signature of arity n is given by n + 1 values, instead of 2n values. This exponentially more succinct representation requires us to find a more efficient algorithm. 6.1. A Single Signature Recall Definition 2.8. To begin with, we provide efficient algorithms to decide membership in each of A1, A2, and A3 for a single signature. If the signature is in one of the sets, then the algorithm also finds at least one corresponding orthogonal transformation satisfying Definition 2.8. By Lemma 2.9, this is enough to check if a single signature is A -transformable. We say a signature f satisfies a second order recurrence relation, if there exist not all zero a, b, c ∈ C, such that for all 0 ≤ k ≤ n − 2, afk + bfk+1 + cfk+2 = 0. For a non-degenerate signature of arity at least 3, these coefficients are unique up to a nonzero scalar. Lemma 6.1. Let f be a non-degenerate symmetric signature of arity n ≥ 3. If f satisfies a second order recurrence relation with coefficients a, b, c ∈ C and another one with coefficients a′, b′, c′ ∈ C, then there exists a nonzero k ∈ C such that (a, b, c) = k(a′, b′, c′). 17 f1 f2 ... fn−1 Proof. A function f = [f0, f1, . . . , fn] is degenerate if and only if f0, . . . , fn forms a geometric sequence. As f is non-degenerate, the matrix A = h f0 f1 ... fn−1 f1 f2 ... fn i has rank 2. Let B = (cid:20) f0 f1 ... fn−2 f2 f3 ... fn (cid:21). We claim that rank(B) ≥ 2, which implies that f satisfies at most one second order recurrence relation up to a nonzero scalar, as desired. If (f1, . . . , fn−1) = 0, then f0, fn 6= 0 since rank(A) = 2, so rank(B) = 2 as well. Otherwise, (f1, . . . , fn−1) 6= 0. Consider the matrices A1 = h f0 f1 ... fn−2 f1 f2 ... fn−1i and A2 = h f1 f2 ... fn−1 matrices of both A and B. Both A1 and A2 have rank at least 1 since (f1, . . . , fn−1) 6= 0. We show that either rank(A1) = 2 or rank(A2) = 2, which implies that rank(B) ≥ 2. For a contradiction, suppose rank(A1) = rank(A2) = 1. Then there exist λ, µ ∈ C such that (f0, . . . , fn−2) = λ(f1, . . . , fn−1) and (f2, . . . , fn) = µ(f1, . . . , fn−1). If λ = 0, then f0 = f1 = 0 as n ≥ 3. It implies that rank(A2) = rank(A). However, rank(A) = 2, a contradiction. Similarly if µ = 0, then rank(A1) = 2, a contradiction. Otherwise λ, µ 6= 0 and we get fi 6= 0 for all 0 ≤ i ≤ n, and λµ = 1. This implies that rank(A) = 1, a contradiction. f2 f3 ... fn i, which are sub- For a signature with a second order recurrence relation, the quantity b2 − 4ac is nonzero precisely when the signature can be expressed as the sum of two degenerate signatures that are linearly independent. Lemma 6.2. Let f be a non-degenerate symmetric signature of arity n ≥ 3. Then f satisfies a second order recurrence relation with coefficients a, b, c satisfying b2 − 4ac 6= 0 iff there exist a0, b0, a1, b1 (satisfying b0(cid:3)⊗n a0b1 6= a1b0) such that f =(cid:2) a0 b1(cid:3)⊗n +(cid:2) a1 . Proof. The "only if" direction is straightforward to verify. For the other direction, assume that there exist a, b, c ∈ C not all zero, such that for all 0 ≤ k ≤ n − 2, afk + bfk+1 + cfk+2 = 0. If c 6= 0, then since b2 − 4ac 6= 0, we can solve this recurrence with the initial values of f0 and f1, namely, there exist c0, c1 6= 0 and λ1 6= λ2 such that for any 0 ≤ k ≤ n, fk = c0λk 1 + c1λk 2 . In other words, we can express f as f = c0(cid:2) 1 λ1(cid:3)⊗n + c1(cid:2) 1 λ2(cid:3)⊗n The other case of c = 0 implies that b 6= 0. Hence the entries f0,··· , fn−1 satisfy a first order recurrence relation and the recurrence does not involve the last entry fn. Thus there must exist c0, c1 and λ such that 1 ]⊗n. Moreover, if any of c0 or c1 equals 0, then f is degenerate which contradicts the f = c0 [ 1 assumption. The lemma follows from a normalization. λ ]⊗n + c1 [ 0 . Normalizing shows the claim. The following definition of the θ function is crucial. A priori, θ(v0, v1) may be not well-defined, but this is circumvented by insisting that v0 and v1 be linearly independent. Definition 6.3. For a pair of linearly independent vectors v0 =(cid:2) a0 a1b0 − a0b1(cid:19)2 θ(v0, v1) :=(cid:18) a0a1 + b0b1 . b0(cid:3) and v1 =(cid:2) a1 b1(cid:3), we define Furthermore, suppose that a signature f of arity n ≥ 3 can be expressed as f = v⊗n are linearly independent. Then we define θ(f ) = θ(v0, v1). 0 + v⊗n 1 , where v0 and v1 Intuitively, this formula is the square of the cotangent of the angle from v0 to v1. This notion of cotangent is properly extended to the complex domain. The expression is squared so that θ(v0, v1) = θ(v1, v0). Let f = v⊗n 0 + v⊗n be a non-degenerate signature of arity n ≥ 3. Since f is non-degenerate, v0 and v1 are linearly independent. The next proposition implies that this expression for f via v0 and v1 is unique up to a root of unity. Therefore, θ(f ) from Definition 6.3 is well-defined. 1 Proposition 6.4 (Lemma 9.1 in [23]). Let a, b, c, d be four vectors and suppose that c, d are linearly independent. If for some n ≥ 3, we have a⊗n + b⊗n = c⊗n + d⊗n, then there exist ω0 and ω1 satisfying ωn 0 = ωn 1 = 1 such that either a = ω0c and b = ω1d or a = ω0d and b = ω1c. 18 For the convenience of future use, we can generalize Proposition 6.4 to the following simple lemma. Lemma 6.5. Let a, b, c, d be four vectors and suppose that c, d are linearly independent. Furthermore, let x0, x1, y0, y1 be nonzero scalars. If for some n ≥ 3, we have x0a⊗n + x1b⊗n = y0c⊗n + y1d⊗n, then there exist ω0 and ω1, such that either a = ω0c, b = ω1d, x0ωn 1 = y1; or a = ω0d, b = ω1c, x0ωn 0 = y0, and x1ωn 0 = y1, and x1ωn 1 = y0. It is easy to verify that θ is invariant under an orthogonal transformation. Lemma 6.6. For two linearly independent vectors v0, v1 ∈ C2 and H ∈ O2(C), let bv0 = Hv0 and bv1 = Hv1. Then θ(v0, v1) = θ(bv0,bv1). Proof. Within the square in the definition of θ, the numerator is the dot product, which is invariant under any orthogonal transformation. Also, the denominator is the determinant, which is invariant under any orthogonal transformation up to a sign. Now we have some necessary conditions for membership in A1 ∪ A2 ∪ A3. Recall that A1 ⊆ P1. Lemma 6.7. Let f be a non-degenerate symmetric signature of arity at least 3. Then 1. f ∈ P1 =⇒ θ(f ) = 0, 2. f ∈ A2 =⇒ θ(f ) = −1, and 3. f ∈ A3 =⇒ θ(f ) = − 1 2 . Proof. The result clearly holds when f is in the canonical form of each set. This extends to the rest of each set by Lemma 6.6. These results imply the following corollary. Corollary 6.8. Let f be a non-degenerate symmetric signature f of arity n ≥ 3. If f is A -transformable, then f is of the form v⊗n , where v0 and v1 are linearly independent, and θ(v0, v1) ∈ {0,−1,− 1 2}. 0 + v⊗n 1 0 + v⊗n 1 with v0 = [ 1 i ] and v1 is not a multiple of(cid:2) 1 −i(cid:3), then θ(f ) = −1 but f is not in A2. However, The condition given in Lemma 6.7 is not sufficient to determine if f ∈ A1 ∪ A2 ∪ A3. For example, if f = v⊗n this is essentially the only exceptional case. We achieve the full characterization with some extra conditions. The next lemma gives an equivalent form for membership in A1, A2, and A3 using transformations in O2(C) \ SO2(C). Only having to consider transformation matrices in O2(C) \ SO2(C) is convenient since such matrices are their own inverses. Lemma 6.9. Suppose f is a non-degenerate symmetric signature of arity n ≥ 3 and let F ∈ {A1, A2, A3}. Then f ∈ F iff there exists an H ∈ O2(C) \ SO2(C) such that f ∈ F with H. Proof. Sufficiency is trivial. For necessity, assume that f ∈ F with H ∈ O2(C). If H ∈ O2(C) \ SO2(C), then we are done, so further assume that H ∈ SO2(C). By the definition of F , 1 (cid:1) , 0 −1(cid:3) H−1 ∈ O2(C) \ SO2(C), so it follows that where c 6= 0 and v0, v1, and β depend on F . Let H′ =(cid:2) 1 0 1 (cid:1) = cH′⊗n(H′H)⊗n(cid:0)v⊗n = cH′⊗n(cid:2) 1 0 1 (cid:1) 0 −1(cid:3)⊗n(cid:0)v⊗n = cH′⊗n(cid:0)v⊗n 0 (cid:1) 1 (cid:1) , = cβH′⊗n(cid:0)v⊗n where in the fourth step, we use the fact that(cid:2) 1 0 0 −1(cid:3) v0 = v1 and(cid:2) 1 0 0 −1(cid:3) v1 = v0 for any F ∈ {A1, A2, A3}. To finish, we rewrite β−1 in the form required in Definition 2.8 as follows: f = cH⊗n(cid:0)v⊗n 1 + βv⊗n 0 + β−1v⊗n 0 + βv⊗n 0 + βv⊗n H′T = H′−1 = H′. Then f = (H′H′)⊗nf 0 + βv⊗n 19 r′ ∈ {0, 1, 2, 3} such that r′ ≡ −tn − r (mod 4), so β−1 = αtn+2r′ as required; • if F = A1, then β = αtn+2r for some t ∈ {0, 1} and r ∈ {0, 1, 2, 3} and β−1 = α−tn−2r. Pick • if F = A2, then β = 1, so β−1 = 1 = β as required; • if F = A3, then β = ir for some r ∈ {0, 1, 2, 3}, so β−1 = i−r = i4−r as required. Before considering A1, we prove a technical lemma that is also applicable when considering P1. 1 0 + v⊗n Lemma 6.10. Let f = v⊗n are linearly independent. If θ(f ) = 0, then there exist an H ∈ O2(C) and a nonzero k ∈ C satisfying a1 = kb0 and b1 = −ka0 such that be a symmetric signature of arity n ≥ 3, where v0 =(cid:2) a0 H⊗nf = λ(cid:16)[ 1 for some nonzero λ ∈ C. Proof. Since θ(f ) = 0, we have a0a1 + b0b1 = 0. By linear independence, we have a1b0 6= a0b1. Thus, there exists a nonzero k ∈ C such that a1 = kb0 and b1 = −ka0. (Note that this is clearly true even if one of a0 0, which is nonzero since a1b0 6= a0b1. Also, let u0 = v0√c and or b0, but not both, is zero.) Let c = a2 1 −1(cid:3) M−1 is u1 = v1 also orthogonal and what we need. Under a transformation by H, we have k√c , so it follows that the matrix M = [u0 u1] is orthogonal. Then the matrix H = 1√2(cid:2) 1 1 b1(cid:3) b0(cid:3) and v1 =(cid:2) a1 1 ]⊗n + kn(cid:2) 1 −1(cid:3)⊗n(cid:17) 0 + b2 H⊗nf = H⊗n(cid:0)c = λ(cid:16)[ 1 n 2 u⊗n 0 + knc 1 ]⊗n + kn(cid:2) 1 n 2 u⊗n 1 (cid:1) −1(cid:3)⊗n(cid:17) , where λ = (c/2) n 2 6= 0. Now we give the characterization of A1. 0 + v⊗n Lemma 6.11. Let f = v⊗n are linearly independent. Then f ∈ A1 iff θ(f ) = 0 and there exist an r ∈ {0, 1, 2, 3} and t ∈ {0, 1} such that an 1 = αtn+2rbn Proof. Suppose f ∈ A1. By Lemma 6.9, after a suitable normalization, there exists a transformation be a symmetric signature of arity n ≥ 3, where v0 =(cid:2) a0 b1(cid:3) b0(cid:3) and v1 =(cid:2) a1 0 6= 0 or bn 1 = αtn+2ran 0 6= 0. 1 H =(cid:2) x y y −x(cid:3) ∈ O2(C) \ SO2(C) such that f = H⊗n(cid:16)[ 1 1 ]⊗n + β(cid:2) 1 −1(cid:3)⊗n(cid:17) , where β = αtn+2r for some r ∈ {0, 1, 2, 3} and some t ∈ {0, 1}. Since H ∈ O2(C), we have x2 + y2 = 1. By Lemma 6.7, θ(f ) = 0. Now we have two expressions for f , which are b0(cid:3)⊗n (cid:2) a0 b1(cid:3)⊗n +(cid:2) a1 y−x(cid:3)⊗n = f =(cid:2) x+y y+x(cid:3)⊗n + β(cid:2) x−y . Since v0 and v1 are linearly independent, we know that a0 and a1 cannot both be 0. Suppose a0 6= 0. By Lemma 6.5, we have two cases. 1 = β(x + y)n = 1. Suppose a0 = ω0(x + y) and b1 = ω1(x + y) where ωn 1 = β. Then we have bn 0 = 1 and ωn βan 0 6= 0. Since β = αtn+2r, we are done. 2. Suppose a0 = ω0(x− y) and b1 = ω1(y− x) where ωn αtn+2r(−1)n(y − x)n = αtn+2r+4nbn r′ ≡ −tn − r − 2n (mod 4). Then α−tn−2r−4n = αtn+2r′ is of the desired form. 1 = α−tn−2r−4nan 1 , so bn Otherwise, a1 6= 0, in which case, similar reasoning shows that an For sufficiency, we apply Lemma 6.10, which gives 1 = αtn+2rbn 0 6= 0. 0 = β and ωn 0 = β(x− y)n = 1 = 1. Then we have an 0 6= 0. Pick r′ ∈ {0, 1, 2, 3} such that for some H ∈ O2(C), some nonzero λ ∈ C, and some nonzero k ∈ C satisfying a1 = kb0 and b1 = −ka0. The ratio of these coefficients is kn. We consider two cases. H⊗nf = λ(cid:16)[ 1 1 ]⊗n + kn(cid:2) 1 −1(cid:3)⊗n(cid:17) 20 1. Suppose an 2. Suppose bn 1 = αtn+2rbn 1 = αtn+2ran 0 6= 0. Then kn = αtn+2r, so f ∈ A1. 0 6= 0. Then kn = (−1)nαtn+2r. Pick r′ ∈ {0, 1, 2, 3} such that r′ ≡ r + 2n (mod 4). Then kn = αtn+2r′ , so f ∈ A1. Now we give the characterization of A3. 1 0 + v⊗n Lemma 6.12. Let f = v⊗n b0(cid:3) and v1 = b1(cid:3) are linearly independent. Then f ∈ A3 iff there exist an ε ∈ {1,−1} and r ∈ {0, 1, 2, 3} such that (cid:2) a1 a1(cid:0)√2a0 + εib0(cid:1) = b1(cid:0)εia0 − √2b0(cid:1), an H =(cid:2) x y y −x(cid:3) ∈ O2(C) − SO2(C) such that be a symmetric signature of arity n ≥ 3, where v0 = (cid:2) a0 1 = ir(cid:0)εia0 − √2b0(cid:1)n f = H⊗n(cid:16)[ 1 Proof. Suppose f ∈ A3. By Lemma 6.9, after a suitable normalization, there exists a transformation 1 = ir(cid:0)√2a0 + εib0(cid:1)n α ]⊗n + ir(cid:2) 1 −α(cid:3)⊗n(cid:17) , and bn for some r ∈ {0, 1, 2, 3}. Since H ∈ O2(C), we have x2 + y2 = 1. By Lemma 6.7, θ(f ) = − 1 a0a1+b0b1 a0b1−a1b0 . After rearranging terms, we get = ± i√2 2 , which implies . a1(cid:16)√2a0 + εib0(cid:17) = b1(cid:16)εia0 − √2b0(cid:17) , for some ε ∈ {1,−1}. Since v0 and v1 are linearly independent, we know that a1 and b1 cannot both be 0. Also, if √2a0 + εib0 and εia0−√2b0 are both 0, then we have −√2a0 = εib0 and εia0 = √2b0, which implies a0 = b0 = 0, a contradiction. Therefore, we have √2b0) b1 = c(√2a0 + εib0) for some c 6= 0. To prove necessity, it remains to show that cn is a power of i. Now using H−1 = H, we have two expressions for (H−1)⊗nf , which are a1 = c(εia0 − and (4) h xa0+yb0 ya0−xb0i⊗n +h xa1+yb1 ya1−xb1i⊗n = H⊗n(cid:16)(cid:2) a0 b0(cid:3)⊗n b1(cid:3)⊗n(cid:17) =(cid:0)H−1(cid:1)⊗n +(cid:2) a1 f = [ 1 α ]⊗n + ir(cid:2) 1 −α(cid:3)⊗n . By Lemma 6.5, there are two cases to consider, each of which has two more cases depending on ε. 1. Suppose ya0− xb0 = α(xa0 + yb0), ya1− xb1 = −α(xa1 + yb1), (xa0 + yb0)n = 1, and (xa1 + yb1)n = ir. By rearranging the first two equations, we get (y − αx)a0 = (x + αy)b0 and (y + αx)a1 = (x − αy)b1. (5) It cannot be the case that a0 = b0 = 0 or y − αx = x + αy = 0. If a0 = 0, then x + αy = 0, so a1 = −√2ib1 by (5) and y 6= 0 lest x = 0 as well. If b0 = 0, then y − αx = 0, so √2ia1 = b1, by the same argument. Now we consider the different cases for ε. (a) If ε = 1, then a1 = c(ia0 − √2b0) and b1 = c(√2a0 + ib0) by (4). If a0 = 0, then a1 = −c√2b0 and b1 = cib0, which contradicts a1 = −√2ib1; if b0 = 0, then a1 = cia0 and b1 = c√2a0, which contradicts √2ia1 = b1. Thus, (y − αx)a0 = (x + αy)b0 6= 0 by (5). Also from (5), (y + αx)a1 = (x − αy)b1. Then since c 6= 0 and using (4) with ε = 1, we get (y + αx)(cid:16)ia0 − √2b0(cid:17) = (x − αy)(cid:16)√2a0 + ib0(cid:17) . Using (y − αx)a0 = (x + αy)b0 6= 0, we get (y + αx)(cid:16)i(x + αy) − √2(y − αx)(cid:17) = (x − αy)(cid:16)√2(x + αy) + i(y − αx)(cid:17) . This equation simplifies to x2 + y2 = 0, which is a contradiction. 21 (b) If ε = −1, then a1 = c(−ia0 − √2b0) and b1 = c(√2a0 − ib0), from (4). Then we get xa1 + yb1 = xc(cid:16)−ia0 − √2b0(cid:17) + yc(cid:16)√2a0 − ib0(cid:17) = c(cid:16)−i(xa0 + yb0) + √2(ya0 − xb0)(cid:17) = c(xa0 + yb0), Now we consider the different cases for ε. where in the third step, we used ya0 − xb0 = α(xa0 + yb0) from (5). Raising this equation to the nth power and using (xa0 + yb0)n = 1 and (xa1 + yb1)n = ir, we conclude that cn = ir. 2. Suppose ya0− xb0 = −α(xa0 + yb0), ya1− xb1 = α(xa1 + yb1), (xa0 + yb0)n = ir, and (xa1 + yb1)n = 1. (a) If ε = 1, then a1 = c(ia0 − √2b0) and b1 = c(√2a0 + ib0) by (4). Using similar reasoning to that (b) If ε = −1, then a1 = c(−ia0 − √2b0) and b1 = c(√2a0 − ib0) by (4). Using similar reasoning to For sufficiency, suppose the three equations hold for some ε ∈ {1,−1} and some r ∈ {0, 1, 2, 3}. Further in case 1b leads to (−c)nir = 1, so cn is a power of i. that in case 1a leads to a contradiction. assume ε = 1, in which case, the equations are as well as From (6), we have a1(cid:16)√2a0 + ib0(cid:17) = b1(cid:16)ia0 − √2b0(cid:17)n √2b0) √2b0(cid:17) , 1 = ir(cid:16)√2a0 + ib0(cid:17)n b1 = c(√2a0 + ib0) and and bn an 1 = ir(cid:16)ia0 − a1 = c(ia0 − (6) (7) . (8) for some c ∈ C. In (6), a1, b1 cannot be both zero. Similarly, √2a0 + ib0, ia0 − √2b0 cannot be both zero. Thus at least one equation in (8) has both sides nonzero and we can always find some c even if one factor is zero. We can write (8) as 0). Using (7) or (8), whichever equation is not zero on both sides, 0 6= 0 because otherwise v0 is a multiple 2 , we know that a2 0 + b2 0+b2 0(cid:2) a0 b0 b0 −a0(cid:3). Also let T = 0 + b2 0) by (6) and (8). Then √2 1√a2 0 + b2 i i(cid:2) a0 b0(cid:3) . , we want to calculate T ⊗nf . First, b1(cid:3) = ch i −√2 (cid:2) a1 This implies that a0a1 + b0b1 = ci(a2 we have cn = ir. Since (6) implies θ(f ) = − 1 of(cid:2) 1 ±i(cid:3), which makes θ(f ) = −1 regardless of v1. We now define two orthogonal matrices T1 = 1√1+i(cid:2) 1 α b1(cid:3)⊗n b0(cid:3)⊗n +(cid:2) a1 T1T2 ∈ O2(C). For f =(cid:2) a0 b0(cid:3) =qa2 T2(cid:2) a0 where γ =q a2 −α 1(cid:3) and T2 = b0(cid:3) = γ(cid:2) 1 T(cid:2) a0 −α(cid:3) , 1+i . Furthermore, a1b0 − a0b1 = √2i(a0a1 + b0b1) = −c√2(a2 a1b0−a0b1(cid:3) = cqa2 −√2i . 0h i 0(cid:2) a0a1+b0b1 −√2i = cγh i−√2α −iα−√2i = −cγ [ 1 −α(cid:3)⊗n + (−c)n [ 1 b1(cid:3) = T2(cid:2) a1 pa2 −α 1(cid:3)h i b1(cid:3) = cγ(cid:2) 1 α T(cid:2) a1 T ⊗nf = γn(cid:16)(cid:2) 1 It follows that Thus α ]⊗n(cid:17) . 1 0 + b2 0 + b2 0 + b2 0 [ 1 0 ] 0+b2 0 and α ] . 22 then T =(cid:2) x y y −x(cid:3) where x = a0 + αb0 p(i + 1) (a2 0 + b2 0) and y = b0 − αa0 p(i + 1) (a2 0 + b2 0) When ε = −1, the argument is similar. In this case, a1 = c(−ia0 − √2b0) and b1 = c(√2a0 − ib0) for some c ∈ C satisfying cn = ir and the entries of T are . . So T transforms f into the canonical form of A3. If we write out the orthogonal transformation T explicitly, x = a0 − αb0 p(i + 1) (a2 0 + b2 0) and y = b0 + αa0 p(i + 1) (a2 0 + b2 0) 2 , unless det((cid:2) a0 a1 b0 b1(cid:3)) = 0. Remark: Notice that either a1(√2a0 + ib0) = b1(ia0 − √2b0) or a1(√2a0 − ib0) = b1(−ia0 − √2b0) implies θ(f ) = − 1 As mentioned before, A2 = P2 requires a stronger condition than just θ. If f ∈ A2 = P2, then θ(f ) = −1, but the reverse is not true. If f = v⊗n 1 with v0 = [1, i] and v1 is not a multiple of [1,−i], then θ(f ) = −1 but f is not in A2 = P2, since any orthogonal H fixes {[1, i], [1,−i]} set-wise, up to a scalar multiple. The next lemma, which appeared in [12], gives a characterization of A2. It says that any signature in A2 0 + v⊗n is essentially in canonical form. For completeness, we include its proof. 1 1 1 a + bi = β 2n + β− 1 2n − β− 1 Lemma 6.13 ([12]). Let f be a non-degenerate symmetric signature. Then f ∈ A2 iff f is of the form −i(cid:3)⊗n(cid:17) for some c, β 6= 0. c(cid:16)[ 1 i ]⊗n + β(cid:2) 1 −i(cid:3)⊗n(cid:17) for some c, β 6= 0. Consider the orthogonal transformation Proof. Assume that f = c(cid:16)[ 1 i ]⊗n + β(cid:2) 1 2n(cid:17) and b = 1 2n(cid:17). We pick a and b in this way so that 2i(cid:16)β 2(cid:16)β H =(cid:2) a b b −a(cid:3), where a = 1 a−bi(cid:17)n 2n , and (a + bi)(a − bi) = a2 + b2 = 1. Also(cid:16) a+bi 2n , a − bi = β− 1 ai+b(cid:3)⊗n(cid:17) H⊗nf = c(cid:16)(cid:2) a+bi −ai+b(cid:3)⊗n + β(cid:2) a−bi i ]⊗n(cid:17) = c(cid:16)(a + bi)n(cid:2) 1 −i(cid:3)⊗n + (a − bi)nβ [ 1 = cpβ(cid:16)(cid:2) 1 i ]⊗n(cid:17) , −i(cid:3)⊗n f = cpβ(H−1)⊗n(cid:16)(cid:2) 1 −i(cid:3)⊗n i ]⊗n(cid:17) . so f can be written as = β. Then + [ 1 + [ 1 Therefore f ∈ A2. fixed setwise under any orthogonal transformation up to nonzero constants. On the other hand, the desired form f = c([ 1 i ]⊗n + β [ 1 i ]⊗n) follows from the fact that {[ 1 i ] ,(cid:2) 1 −i(cid:3)} is Remark: Notice that θ(v0, v1) = −1 for linearly independent v0 and v1 if and only if at least one of v0, v1 is [ 1 i ] or(cid:2) 1 −i(cid:3), up to a nonzero scalar. We now present the polynomial-time algorithm to check if f ∈ A1 ∪ A2 ∪ A3. Lemma 6.14. Given a non-degenerate symmetric signature f of arity at least 3, there is a polynomial-time algorithm to decide whether f ∈ Ak for each k ∈ {1, 2, 3}. If so, k is unique and at least one corresponding orthogonal transformation can be found in polynomial time. 23 Proof. First we check if f satisfies a second order recurrence relation. If it does, then the coefficients (a, b, c) of the second order recurrence relation are unique up to a nonzero scalar by Lemma 6.1. If the coefficients satisfy b2 − 4ac 6= 0, then by Lemma 6.2, we can express f as v⊗n , where v0 and v1 are linearly independent and arity(f ) = n. All of this must be true for f to be in A1 ∪ A2 ∪ A3. With this alternate expression for f , we apply Lemma 6.11, Lemma 6.13, and Lemma 6.12 to decide if f ∈ Ak for each k ∈ {1, 2, 3} respectively. These sets are disjoint by Lemma 6.7, so there can be at most one k such that f ∈ Ak. 6.2. Set of Symmetric Signatures 0 + v⊗n 1 We first show that if a non-degenerate signature f of arity at least 3 is in A1 or A3, then for any set F containing f , there are only a small constant number of transformations to check to decide whether F is A -transformable. If f ∈ A2, then there can be more than a constant number of transformations to check. However, this number is at most linear in the arity of f . Notice that any non-degenerate symmetric signature f ∈ A of arity at least 3 is in F123 (introduced in Section 2.3), which contains signatures expressed as a sum of two tensor powers. Therefore θ(f ) is well- defined. By Lemma 2.7, to check A -transformability, we may restrict our attention to the sets A and [ 1 0 0 α ] A up to orthogonal transformations. In particular, θ(f ) = 0 −1 − 1 2 0 α ] F1, if f ∈ F1 ∪ F2 ∪ [ 1 0 if f ∈ F3, if f ∈ [ 1 0 0 α ] (F2 ∪ F3). (9) 0 α ] A . SO2(C). [ 0 1 F ⊆ H′ [ 1 0 1 0 ](cid:2) 1 1 1 −1(cid:3) A , Lemma 6.15. Let F be a set of symmetric signatures and suppose F contains a non-degenerate signature Before we prove necessity, we first claim that without loss of generality, we may assume H ∈ O2(C) \ 1 −1(cid:3) [ 1 0 If H ∈ SO2(C), we let eH = H [ 0 1 0 α ](cid:2) 1 0 0 −1(cid:3), and(cid:2) 1 0 f ∈ A1 of arity n ≥ 3 with H ∈ O2(C). Then F is A -transformable iff F is a subset of H A , or H(cid:2) 1 1 or H(cid:2) 1 1 Proof. Sufficiency follows from Lemma 2.7 and both H, H2 = 1√2(cid:2) 1 1 1 −1(cid:3) ∈ O2(C). 1 0 ] ∈ O2(C) \ SO2(C). Then f ∈ A1 also with eH. From 1 1 (cid:3) [ 1 0 0 α ] =(cid:2) 1 −1 1 −1(cid:3) [ 1 0 0 −1(cid:3) [ 1 0 1 0 ] ∈ Stab(A ), it follows that eH A = H A . Also [ 0 1 (cid:2) 1 1 1 −1(cid:3) [ 1 0 0 −1(cid:3) ∈ Stab(A ). It follows that eH(cid:2) 1 1 1 −1(cid:3) [ 1 0 0 α ] A = H(cid:2) 1 1 Suppose F is A -transformable. By Lemma 4.3, there exists an H′ ∈ SO2(C) such that F ⊆ H′A or 0 α ] A . We only need to show there exists an M ∈ Stab(A ), such that H′ = HM in the first case, and in the second case H′ = H(cid:2) 1 1 1 −1(cid:3) M , and M [ 1 0 f = H⊗n(cid:16)[ 1 g = T ⊗n(cid:16)[ 1 where β = αtn+2r for some r ∈ {0, 1, 2, 3} and t ∈ {0, 1}. Let g = (H′−1)⊗nf and T = H′−1H so that 1 ]⊗n + β(cid:2) 1 1 ]⊗n + β(cid:2) 1 −1(cid:3)⊗n(cid:17) , −1(cid:3)⊗n(cid:17) . Since f ∈ A1 with H, after a suitable normalization by a nonzero scalar, we have 1 −1(cid:3)(cid:2) 1 0 0 α ] =(cid:2) 1 1 1 −1(cid:3) [ 1 0 0 α ] M′ for some M′ ∈ Stab(A ). Note that T ∈ O2(C)\ SO2(C) since H′ ∈ SO2(C) and H ∈ O2(C)\ SO2(C). Thus T = T −1 and HT = H′. F ⊆ H′A or F ⊆ H′ [ 1 0 Let T =(cid:2) a b b −a(cid:3) for some a, b ∈ C such that a2 + b2 = 1. There are two possibilities according to whether 1. If F ⊆ H′A , then g ∈ F123 since g is symmetric and non-degenerate. Since θ(g) = 0, by (9), g ∈ F1 0 α ] A . 0 α ] = [ 1 0 0 α ] = 0 α ] A . or g ∈ F2. We discuss the two cases of g separately. • Suppose g ∈ F1. Then we have T ⊗n(cid:16)[ 1 1 ]⊗n + β(cid:2) 1 −1(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 0 ]⊗n + it [ 0 1 ]⊗n(cid:17) 24 for some λ 6= 0 and t ∈ {0, 1, 2, 3}. Plugging in the expression for T , we have Then by Lemma 6.5, we have a + b = 0 or a − b = 0. Together with a2 + b2 = 1, we can solve for some λ 6= 0 and t ∈ {0, 1, 2, 3}. Plugging in the expression for T , we have 0 ]⊗n + it [ 0 1 ]⊗n(cid:17) . 1 0 (cid:3), up to a constant multiple ±1. Since 1 ]⊗n + it(cid:2) 1 1 ]⊗n + it(cid:2) 1 −1(cid:3)⊗n(cid:17) −1(cid:3)⊗n(cid:17) • Suppose g ∈ F2. Then we have (cid:16)(cid:2) a+b b−a(cid:3)⊗n 1 −1(cid:3) or T = 1√2(cid:2) 1 −1 a+b(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 for T = 1√2(cid:2) 1 1 1 −1(cid:3)(cid:2) 0 −1 1 0 (cid:3) ∈ Stab(A ), we have T ∈ Stab(A ), so we are done. (cid:2) 0 −1 −1(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 a+b(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 + β(cid:2) a−b −1 −1(cid:3) = 1√2(cid:2) 1 1 T ⊗n(cid:16)[ 1 1 ]⊗n + β(cid:2) 1 (cid:16)(cid:2) a+b b−a(cid:3)⊗n + β(cid:2) a−b 0 −1(cid:3) or T = ± [ 0 1 2. If F ⊆ H′ [ 1 0 T ⊗n(cid:16)[ 1 1 ]⊗n + β(cid:2) 1 1 −1(cid:3) or T = 1√2(cid:2) 1 1 Thus T = ±(cid:2) 1 0 0 α ] A , then we have g ∈ [ 1 0 T = 1√2(cid:2) 1 1 Moreover, Then by Lemma 6.5, we have a + b = a − b or a + b = −(a − b). Therefore either a = 0 or b = 0. 1 0 ] and both matrices are in Stab(A ). for some λ 6= 0. This is essentially the same as the case where g ∈ F1 above, except that the coefficients are different. However, the coefficients do not affect the argument and our conclusion in this case that 0 α ] F123. Since θ(g) = 0, by (9), g ∈ [ 1 0 0 α ] F1. That is, 0 ]⊗n + it [ 0 0 ]⊗n + itαn [ 0 0 α ]⊗n(cid:16)[ 1 1 ]⊗n(cid:17) = λ(cid:16)[ 1 1 ]⊗n(cid:17) −1(cid:3)⊗n(cid:17) = λ [ 1 0 1 0 (cid:3) ∈ Stab(A ). 1 0 (cid:3), up to a constant multiple ±1. Notice that(cid:2) 0 −1 1 −1(cid:3)(cid:2) 0 −1 1 0 (cid:3) [ 1 0 (cid:2) 0 −1 1 0 (cid:3) 0 α ] =(cid:2) 0 −α 0 α ](cid:2) 0 −α α−1 0 (cid:3) = [ 1 0 = −α [ 1 0 0 α ] [ 0 1 i 0 ] , and [ 0 1 i 0 ] ∈ Stab(A ). Lemma 6.16. Let F be a set of symmetric signatures and suppose F contains a non-degenerate signature f ∈ A2 of arity n ≥ 3. Then there exists a set H ⊆ O2(C) of size O(n) such that F is A -transformable iff there exists an H ∈ H such that F ⊆ H A . Moreover H can be computed in polynomial time in the input length of the symmetric signature f . Proof. Sufficiency is trivial by Lemma 4.3. Suppose F is A -transformable. By Lemma 4.3, there exists an H ∈ SO2(C) such that F ⊆ H A or 0 α ] A . In the first case, we show that the number of choices of H can be limited to O(n). Then we F ⊆ H [ 1 0 show that the second case is impossible. Since f ∈ A2, after a suitable normalization by a nonzero scalar, we have for some ν 6= 0 by Lemma 6.13. Let g = (H−1)⊗nf . Then There are two possibilities according to whether F ⊆ H A or F ⊆ H [ 1 0 0 α ] A . f = [ 1 i ]⊗n + ν(cid:2) 1 −i(cid:3)⊗n −i(cid:3)⊗n(cid:17) . i ]⊗n + ν(cid:2) 1 g = (H−1)⊗n(cid:16)[ 1 25 for some λ 6= 0 and r ∈ {0, 1, 2, 3}. Because H−1 ∈ SO2(C), we may assume that H−1 is of the form 1. Suppose F ⊆ H A . Therefore g ∈ F123. Since θ(g) = −1, by (9), g ∈ F3. Then we have (H−1)⊗n(cid:16)[ 1 −b a(cid:3) where a2 + b2 = 1. Therefore (cid:2) a b λ(cid:16)[ 1 i ]⊗n + ir(cid:2) 1 i ]⊗n + ν(cid:2) 1 −i(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 i ]⊗n + ir(cid:2) 1 −i(cid:3)⊗n(cid:17) −i(cid:3)⊗n(cid:17) =(cid:2) a b −b a(cid:3)⊗n(cid:16)[ 1 = (a + bi)n [ 1 −i(cid:3)⊗n(cid:17) i ]⊗n + ν(cid:2) 1 i ]⊗n + ν(a − bi)n(cid:2) 1 λir = ν(a − bi)n. . −i(cid:3)⊗n Comparing the coefficients, by Lemma 6.5, we have λ = (a + bi)n and Hence, ir(a + bi)n = ν(a − bi)n. Since (a + bi)(a− bi) = a2 + b2 = 1, we know that (a + bi)2n = νi−r. Therefore a + bi = ω2n(νi−r)1/2n, where ω2n is a 2n-th root of unity. There are 4 choices for r, and 2n choices for ω2n. However, a − bi = 1 a+bi , and (a, b) can be solved from (a + bi, a − bi). Hence there are only O(n) choices for H, depending on f . 2. Suppose F ⊆ H [ 1 0 0 α ] A . Then g ∈ [ 1 0 0 α ] F123. However, θ(g) = −1, which contradicts (9). Lemma 6.17. Let F be a set of symmetric signatures and suppose F contains a non-degenerate signature f ∈ A3 of arity n ≥ 3 with H ∈ O2(C). Then F is A -transformable iff F ⊆ H [ 1 0 Proof. Sufficiency is trivial by Lemma 4.3. 0 α ] A . Suppose F is A -transformable. As in the proof of Lemma 6.15, we may assume that H ∈ O2(C)\SO2(C). By Lemma 4.3, there exists an H′ ∈ SO2(C) such that F ⊆ H′A or F ⊆ H′ [ 1 0 0 α ] A . We show the first case is impossible. Then in the second case, we show that there exists an M such that H′ = HM , where M [ 1 0 0 α ] M′ for some M′ ∈ Stab(A ). 0 α ] = [ 1 0 Since f ∈ A3 with H, after a suitable normalization by a nonzero scalar, we have for some r ∈ {0, 1, 2, 3}. Let g = (H′−1)⊗nf and T = H′−1H so that f = H⊗n(cid:16)[ 1 g = T ⊗n(cid:16)[ 1 α ]⊗n + ir(cid:2) 1 α ]⊗n + ir(cid:2) 1 −α(cid:3)⊗n(cid:17) −α(cid:3)⊗n(cid:17) . Note that T ∈ O2(C)\ SO2(C) since H′ ∈ SO2(C) and H ∈ O2(C)\ SO2(C). Thus T = T −1 and HT = H′. b −a(cid:3) for some a, b ∈ C such that a2 + b2 = 1. There are two possibilities according to whether Let T =(cid:2) a b F ⊆ H′A or F ⊆ H′ [ 1 0 1. Suppose F ⊆ H′A . Then g = (H′−1)⊗nf ∈ F123. However, θ(g) = − 1 2. Suppose F ⊆ H′ [ 1 0 • Suppose g ∈ [ 1 0 0 α ] A . Then g ∈ [ 1 0 0 α ] F2. Then we have 0 α ] (F2 ∪ F3) by (9). We 0 α ] F123, so θ(g) = − 1 discuss the these two cases separately. 2 , which contradicts (9). 2 and g ∈ [ 1 0 0 α ] A . for some λ 6= 0 and t ∈ {0, 1, 2, 3}. Plugging in the expression for T , we have T ⊗n(cid:16)[ 1 α ]⊗n + ir(cid:2) 1 −1(cid:3)⊗n(cid:17) −α(cid:3)⊗n(cid:17) = λ [ 1 0 = λ(cid:16)[ 1 b+αa(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 0 α ]⊗n(cid:16)[ 1 1 ]⊗n + it(cid:2) 1 −α(cid:3)⊗n(cid:17) α ]⊗n + it(cid:2) 1 −α(cid:3)⊗n(cid:17) . α ]⊗n + it(cid:2) 1 + ir(cid:2) a−αb 26 (cid:16)(cid:2) a+αb b−αa(cid:3)⊗n Then by Lemma 6.5, we have either or b − aα = α(a + bα) and b + aα = −α(a − bα) b − aα = −α(a + bα) and b + aα = α(a − bα). The first case is impossible. In the second case, we have a = ±1 and b = 0. This implies T = ±(cid:2) 1 0 • Suppose g ∈ [ 1 0 0 α ]. 0 α ] F3. Then we have T ⊗n(cid:16)[ 1 α ]⊗n + ir(cid:2) 1 0 −1(cid:3) ∈ Stab(A ), which commutes with [ 1 0 −α(cid:3)⊗n(cid:17) = λ [ 1 0 = λ(cid:16)[ 1 b+αa(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 (cid:16)(cid:2) a+αb b−αa(cid:3)⊗n + ir(cid:2) a−αb −i(cid:3)⊗n(cid:17) 0 α ]⊗n(cid:16)[ 1 i ]⊗n + it(cid:2) 1 −αi(cid:3)⊗n(cid:17) αi ]⊗n + it(cid:2) 1 −αi(cid:3)⊗n(cid:17) . αi ]⊗n + it(cid:2) 1 for some λ 6= 0 and t ∈ {0, 1, 2, 3}. Plugging in the expression for T , we have Then by Lemma 6.5, we have either or b − aα = αi(a + bα) and b + aα = −αi(a − bα) b − aα = −αi(a + bα) and b + aα = αi(a − bα). 1 0 ] [ 1 0 0 α ] = [ 1 0 The first case is impossible. In the second case, we have a = 0 and b = ±1. This implies that T = ± [ 0 1 1 0 ] ∈ Stab(A ). 1 0 ]. Note that [ 0 1 0 α ](cid:2) 0 α α−1 0(cid:3) and(cid:2) 0 α α−1 0(cid:3) = α−1 [ 0 i Now we are ready to show how to decide if a finite set of signatures is A -transformable. To avoid trivialities, we assume F contains a non-degenerate signature of arity at least 3. If every non-degenerate signature in F has arity at most two, then Holant(F ) is tractable. Theorem 6.18. There is a polynomial-time algorithm to decide, for any finite input set F of symmetric signatures containing a non-degenerate signature f of arity n ≥ 3, whether F is A -transformable. Proof. By Lemma 6.14, we can decide if f is in Ak for some k ∈ {1, 2, 3}. If not, then by Lemma 2.9, F is not A -transformable. Otherwise, f ∈ Ak for some unique k. Depending on k, we apply Lemma 6.15, Lemma 6.16, or Lemma 6.17 to check if F is A -transformable. 7. Symmetric P-transformable Signatures To decide if a signature set is P-transformable, we face the same issue as in the A -transformable case. Namely, a symmetric signature of arity n is given by n + 1 values, instead of 2n values. This exponentially more succinct representation requires us to find a more efficient algorithm. The next lemma tells us how to decide membership in P1 for signatures of arity at least 3. Lemma 7.1. Let f = v⊗n independent. Then f ∈ P1 iff θ(f ) = 0. Proof. Necessity is clear by Lemma 6.7 and sufficiency follows from Lemma 6.10. 0 + v⊗n be a symmetric signature of arity n ≥ 3, where v0 and v1 are linearly 1 Since A2 = P2, the membership problem for P2 is handled by Lemma 6.13. Using Lemma 7.1 and Lemma 6.13, we can efficiently decide membership in P1 ∪ P2. 27 Lemma 7.2. Given a non-degenerate symmetric signature f of arity at least 3, there is a polynomial-time algorithm to decide whether f ∈ Pk for some k ∈ {1, 2}. If so, k is unique and at least one corresponding orthogonal transformation can be found in polynomial time. Proof. First we check if f satisfies a second order recurrence relation. If it does, then the coefficients (a, b, c) of the second order recurrence relation are unique up to a nonzero scalar by Lemma 6.1. If the coefficients satisfy b2 − 4ac 6= 0, then by Lemma 6.2, we can express f as v⊗n , where v0 and v1 are linearly independent and arity(f ) = n. All of this must be true for f to be in P1 ∪ P2. With this alternate expression for f , we apply Lemma 7.1 and Lemma 6.13 to decide if f ∈ Pk for some k ∈ {1, 2} respectively. These sets are disjoint by Lemma 6.7, so there can be at most one k such that f ∈ Pk. 0 + v⊗n 1 Like the symmetric affine case, the following lemmas assume the signature set F contains a non-degenerate signature of arity at least 3 in P1 or P2. Unlike the symmetric affine case, the number of transformations to be checked to decide whether F is P-transformable is always a small constant. Lemma 7.3. Let F be a set of symmetric signatures and suppose F contains a non-degenerate signature f ∈ P1 of arity n ≥ 3 with H ∈ O2(C). Then F is P-transformable iff F ⊆ H(cid:2) 1 1 1 −1(cid:3) P. Then by Lemma 5.1, there exists an H′ ∈ SO2(C) such that F ⊆ H′P or F ⊆ H′(cid:2) 1 1 H′ = H(cid:2) 1 1 Suppose F is P-transformable. As in the proof of Lemma 6.15, we may assume H ∈ O2(C) \ SO2(C). second case we can take H′ = I2. In the first case, we show that there exists an M ∈ Stab(P) such that Since f ∈ P1 with H, after a suitable normalization by a nonzero scalar, we have i −i(cid:3) P, where in the Proof. Sufficiency is trivial by Lemma 2.10. 1 −1(cid:3) M . Then we show that the second case is impossible. −1(cid:3)⊗n(cid:17) −1(cid:3)⊗n(cid:17) . f = H⊗n(cid:16)[ 1 g = T ⊗n(cid:16)[ 1 1 ]⊗n + β(cid:2) 1 1 ]⊗n + β(cid:2) 1 for some β 6= 0. Let g = (H′−1)⊗nf and T = H′−1H so that Note that T ∈ O2(C)\ SO2(C) since H′ ∈ SO2(C) and H ∈ O2(C)\ SO2(C). Thus T = T −1 and HT = H′. 1. Suppose F ⊆ H′P. Then g must be a generalized equality since g ∈ P with arity n ≥ 3. The only sym- metric non-degenerate generalized equalities in P with arity n ≥ 3 have the form λ(cid:16)[ 1 1 ]⊗n(cid:17), 0 ]⊗n + β′ [ 0 for some λ, β′ 6= 0. Thus 0 ]⊗n + β′ [ 0 Let T =(cid:2) a b T ⊗n(cid:16)[ 1 −1(cid:3)⊗n(cid:17) = λ(cid:16)[ 1 1 ]⊗n + β(cid:2) 1 b −a(cid:3) for a, b ∈ C such that a2 + b2 = 1. Then = λ(cid:16)[ 1 a+b(cid:3)⊗n b−a(cid:3)⊗n + β(cid:2) a−b (cid:2) a+b −1 −1(cid:3) = ± 1√2(cid:2) 1 1 1 −1(cid:3) or T = ± 1√2(cid:2) 1 −1 T = ± 1√2(cid:2) 1 1 1 −1(cid:3)(cid:2) 0 −1 2. Suppose F ⊆ H′(cid:2) 1 1 i −i(cid:3) P, and θ(g) = θ([ 1 However, any h ∈ (cid:2) 1 1 i ]⊗n + d(cid:2) 1 −i(cid:3)⊗n By Lemma 6.5 we have either a − b = 0 or a + b = 0. Together with a2 + b2 = 1, the only solutions are this case is complete. 1 0 (cid:3) ∈ Stab(P), i −i(cid:3) P that is non-degenerate and has arity at least 3 must have the form 1 ]⊗n(cid:17) . 1 ]⊗n(cid:17) . 1 0 (cid:3). Since ± 1√2 for some nonzero c, d ∈ C, which implies that θ(h) = −1. This contradicts θ(g) = −1(cid:3)) = 0 by Lemma 6.7. i −i(cid:3) P. Then g ∈(cid:2) 1 1 I2,± 1√2(cid:2) 0 −1 1 ] ,(cid:2) 1 0 ]⊗n + β′ [ 0 c [ 1 0. Lemma 7.4. Let F be a set of symmetric signatures and suppose F contains a non-degenerate signature f ∈ P2 of arity n ≥ 3. Then F is P-transformable iff all non-degenerate signatures in F are contained in P2 ∪ {=2}. 28 is the binary equality signature =2. Otherwise, we can express g as 1 1 0 0 g = λZ⊗2(cid:18) 0 g = cZ⊗m(cid:16)[ 1 = c(cid:16)[ 1 0(cid:19) = λ(cid:18) 1 1(cid:19) 1 ]⊗m(cid:17) −i(cid:3)⊗m(cid:17) i ]⊗m + β(cid:2) 1 0 ]⊗m + β [ 0 for some c, β 6= 0 with m ≥ 2. Thus, g ∈ P2 = A2 by Lemma 6.13. We conclude that the symmetric non-degenerate subset of ZP is contained in P2 ∪ {=2}. Therefore, the non-degenerate subset of F is contained in P2 ∪ {=2}. 2. Suppose F ⊆ HP. By assumption, F contains f ∈ P2 = A2 of arity n ≥ 3. After a suitable normalization by a scalar, we have Proof. Suppose F is P-transformable. Let Z = 1√2(cid:2) 1 1 i −i(cid:3). Then by Lemma 5.1, F ⊆ ZP or there exists an H ∈ SO2(C) such that F ⊆ HP. In first case, we show that all the non-degenerate symmetric signatures in ZP are contained in P2 ∪ {=2}. Then we show that the second case is impossible. 1. Suppose F ⊆ ZP. Let g ∈ ZP be a symmetric non-degenerate signature of arity m. If (Z−1)⊗2g = λ[0, 1, 0] is the binary disequality signature up to a nonzero scalar λ ∈ C, then for some β 6= 0 by Lemma 6.13. Let g = (H−1)⊗nf so that f = [ 1 g =(cid:0)H−1(cid:1)⊗n(cid:16)[ 1 i ]⊗n + β(cid:2) 1 −i(cid:3)⊗n −i(cid:3)⊗n(cid:17) . i ]⊗n + β(cid:2) 1 −i(cid:3)) = −1 since d ]⊗n for some nonzero c, d ∈ C, which i ] ,(cid:2) 1 In particular, f and g have the same arity n ≥ 3. By Lemma 6.7, θ(g) = θ([ 1 H−1 ∈ O2(C). However, g ∈ P must be of the form [ c has θ(g) = 0. This is a contradiction. 0 ]⊗n + [ 0 It is easy to see that all of above is reversible. Therefore sufficiency follows. Now we are ready to show how to decide if a finite set of signatures is P-transformable. To avoid trivialities, we assume F contains a non-degenerate signature of arity at least 3. If every non-degenerate signature in F has arity at most two, then Holant(F ) is tractable. Theorem 7.5. There is a polynomial-time algorithm to decide, for any finite input set F of symmetric signatures containing a non-degenerate signature f of arity n ≥ 3, whether F is P-transformable. Proof. By Lemma 7.2, we can decide if f is in Pk for some k ∈ {1, 2}. If not, then by Lemma 2.12, F is not P-transformable. Otherwise, f ∈ Pk for some unique k. Depending on k, we apply Lemma 7.3 or Lemma 7.4 to check if F is P-transformable. Acknowledgements. This research is supported by NSF CCF-1714275. HG was also supported by a Simons Award for Graduate Students in Theoretical Computer Science from the Simons Foundation when he was a graduate student. We thank anonymous referees for their valuable comments. References [1] Andrei Bulatov, Martin Dyer, Leslie Ann Goldberg, Markus Jalsenius, and David Richerby. The com- plexity of weighted Boolean #CSP with mixed signs. Theor. Comput. Sci., 410(38-40):3949 -- 3961, 2009. [2] Andrei Bulatov and Martin Grohe. The complexity of partition functions. Theor. Comput. Sci., 348(2):148 -- 186, 2005. 29 [3] Andrei A. Bulatov. The complexity of the counting constraint satisfaction problem. J. ACM, 60(5):34:1 -- 34:41, 2013. [4] Andrei A. Bulatov and V´ıctor Dalmau. Towards a dichotomy theorem for the counting constraint satisfaction problem. Inform. and Comput., 205(5):651 -- 678, 2007. [5] Jin-Yi Cai and Xi Chen. A decidable dichotomy theorem on directed graph homomorphisms with non-negative weights. In FOCS, pages 437 -- 446. IEEE Computer Society, 2010. [6] Jin-Yi Cai and Xi Chen. Complexity of counting CSP with complex weights. J. ACM, 64(3):19:1 -- 19:39, 2017. [7] Jin-Yi Cai, Xi Chen, and Pinyan Lu. Graph homomorphisms with complex values: A dichotomy theorem. SIAM J. Comput., 42(3):924 -- 1029, 2013. [8] Jin-Yi Cai, Xi Chen, and Pinyan Lu. Nonnegative weighted #CSP: An effective complexity dichotomy. SIAM J. Comput., 45(6):2177 -- 2198, 2016. [9] Jin-Yi Cai, Vinay Choudhary, and Pinyan Lu. On the theory of matchgate computations. Theory of Computing Systems, 45(1):108 -- 132, 2009. [10] Jin-Yi Cai and Aaron Gorenstein. Matchgates revisited. Theory of Computing, 10(868):4001 -- 4030, 2014. [11] Jin-Yi Cai, Heng Guo, and Tyson Williams. Holographic algorithms beyond matchgates. In ICALP (1), pages 271 -- 282, 2014. [12] Jin-Yi Cai, Heng Guo, and Tyson Williams. A complete dichotomy rises from the capture of vanishing signatures. SIAM J. Comput., 45(5):1671 -- 1728, 2016. [13] Jin-Yi Cai, Sangxia Huang, and Pinyan Lu. From Holant to #CSP and back: Dichotomy for Holantc problems. Algorithmica, 64(3):511 -- 533, 2012. [14] Jin-Yi Cai and Michael Kowalczyk. Spin systems on k-regular graphs with complex edge functions. Theor. Comput. Sci., 461:2 -- 16, 2012. [15] Jin-Yi Cai, Michael Kowalczyk, and Tyson Williams. Gadgets and anti-gadgets leading to a complexity dichotomy. In ITCS, pages 452 -- 467. ACM, 2012. [16] Jin-Yi Cai and Pinyan Lu. Holographic algorithms with unsymmetric signatures. In SODA, pages 54 -- 63. Society for Industrial and Applied Mathematics, 2008. [17] Jin-Yi Cai and Pinyan Lu. Holographic algorithms: From art to science. J. Comput. Syst. Sci., 77(1):41 -- 61, 2011. [18] Jin-Yi Cai and Pinyan Lu. Signature theory in holographic algorithms. Algorithmica, 61(4):779 -- 816, 2011. [19] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. Computational complexity of Holant problems. SIAM J. Comput., 40(4):1101 -- 1132, 2011. [20] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. Dichotomy for Holant* problems of Boolean domain. In SODA, pages 1714 -- 1728. SIAM, 2011. [21] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. Holographic reduction, interpolation and hardness. Computa- tional Complexity, 21(4):573 -- 604, 2012. [22] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. Dichotomy for Holant* problems with domain size 3. In SODA, pages 1278 -- 1295. SIAM, 2013. 30 [23] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. Holographic algorithms by Fibonacci gates. Linear Algebra and its Applications, 438(2):690 -- 707, 2013. [24] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. The complexity of complex weighted Boolean #CSP. J. Comput. System Sci., 80(1):217 -- 236, 2014. [25] Jin-Yi Cai, Pinyan Lu, and Mingji Xia. Holographic algorithms with matchgates capture precisely tractable planar #CSP. SIAM J. Comput., 46(3):853 -- 889, 2017. [26] C. T. J. Dodson and T. Poston. Tensor Geometry, volume 130 of Graduate Texts in Mathematics. Springer-Verlag, second edition, 1991. [27] Martin Dyer, Leslie Ann Goldberg, and Mark Jerrum. The complexity of weighted Boolean #CSP. SIAM J. Comput., 38(5):1970 -- 1986, 2009. [28] Martin Dyer, Leslie Ann Goldberg, and Mike Paterson. On counting homomorphisms to directed acyclic graphs. J. ACM, 54(6), 2007. [29] Martin Dyer and Catherine Greenhill. The complexity of counting graph homomorphisms. Random Struct. Algorithms, 17(3-4):260 -- 289, 2000. [30] Martin Dyer and David Richerby. An effective dichotomy for the counting constraint satisfaction prob- lem. SIAM J. Comput., 42(3):1245 -- 1274, 2013. [31] Leslie Ann Goldberg, Martin Grohe, Mark Jerrum, and Marc Thurley. A complexity dichotomy for partition functions with mixed signs. SIAM J. Comput., 39(7):3336 -- 3402, 2010. [32] Heng Guo, Sangxia Huang, Pinyan Lu, and Mingji Xia. The complexity of weighted Boolean #CSP modulo k. In STACS, pages 249 -- 260. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2011. [33] Heng Guo and Tyson Williams. The complexity of planar Boolean #CSP with complex weights. In ICALP, pages 516 -- 527. Springer Berlin Heidelberg, 2013. [34] Pavol Hell and Jaroslav Nesetril. On the complexity of H-coloring. J. Comb. Theory Ser. B, 48(1):92 -- 110, 1990. [35] Sangxia Huang and Pinyan Lu. A dichotomy for real weighted Holant problems. Computational Com- plexity, 25(1):255 -- 304, 2016. [36] P. W. Kasteleyn. The statistics of dimers on a lattice. Physica, 27(12):1209 -- 1225, 1961. [37] P. W. Kasteleyn. Graph theory and crystal physics. In F. Harary, editor, Graph Theory and Theoretical Physics, pages 43 -- 110. Academic Press, London, 1967. [38] Neeraj Kayal. Affine projections of polynomials: Extended abstract. In STOC, pages 643 -- 662. ACM, 2012. [39] L´aszl´o Lov´asz. Operations with structures. Acta Math. Hung., 18(3-4):321 -- 328, 1967. [40] Ketan D. Mulmuley and Milind Sohoni. Geometric complexity theory I: An approach to the P vs. NP and related problems. SIAM J. Comput., 31(2):496 -- 526, 2001. [41] H. N. V. Temperley and Michael E. Fisher. Dimer problem in statistical mechanics -- an exact result. Philosophical Magazine, 6(68):1061 -- 1063, 1961. [42] Leslie G. Valiant. Expressiveness of matchgates. Theor. Comput. Sci., 289(1):457 -- 471, 2002. [43] Leslie G. Valiant. Quantum circuits that can be simulated classically in polynomial time. SIAM J. Comput., 31(4):1229 -- 1254, 2002. 31 [44] Leslie G. Valiant. Accidental algorthims. In FOCS, pages 509 -- 517. IEEE Computer Society, 2006. [45] Leslie G. Valiant. Holographic algorithms. SIAM J. Comput., 37(5):1565 -- 1594, 2008. 32
1411.1124
3
1411
2018-02-26T23:29:06
Nearly Linear-Time Packing and Covering LP Solvers
[ "cs.DS", "math.NA", "math.NA", "math.OC" ]
Packing and covering linear programs (PC-LPs) form an important class of linear programs (LPs) across computer science, operations research, and optimization. In 1993, Luby and Nisan constructed an iterative algorithm for approximately solving PC-LPs in nearly linear time, where the time complexity scales nearly linearly in $N$, the number of nonzero entries of the matrix, and polynomially in $\varepsilon$, the (multiplicative) approximation error. Unfortunately, all existing nearly linear-time algorithms for solving PC-LPs require time at least proportional to $\varepsilon^{-2}$. In this paper, we break this longstanding barrier by designing a packing solver that runs in time $\tilde{O}(N \varepsilon^{-1})$ and covering LP solver that runs in time $\tilde{O}(N \varepsilon^{-1.5})$. Our packing solver can be extended to run in time $\tilde{O}(N \varepsilon^{-1})$ for a class of well-behaved covering programs. In a follow-up work, Wang et al. showed that all covering LPs can be converted into well-behaved ones by a reduction that blows up the problem size only logarithmically. At high level, these two algorithms can be described as linear couplings of several first-order descent steps. This is an application of our linear coupling technique to problems that are not amenable to blackbox applications known iterative algorithms in convex optimization.
cs.DS
cs
Nearly Linear-Time Packing and Covering LP Solvers (Achieving Width-Independence and O(1/ε)-Convergence) Zeyuan Allen-Zhu [email protected] Microsoft Research AI Lorenzo Orecchia [email protected] Boston University November 4, 2014∗ Abstract Packing and covering linear programs (PC-LPs) form an important class of linear programs (LPs) across computer science, operations research, and optimization. In 1993, Luby and Nisan [25] constructed an iterative algorithm for approximately solving PC-LPs in nearly linear time, where the time complexity scales nearly linearly in N , the number of nonzero entries of the matrix, and polynomially in ε, the (multiplicative) approximation error. Unfortunately, existing nearly linear-time algorithms [2, 11, 24, 32, 36, 37] for solving PC-LPs require time at least proportional to ε−2. In this paper, we break this longstanding barrier by designing a packing solver that runs in time eO(N ε−1) and covering LP solver that runs in time eO(N ε−1.5). Our packing solver can be extended to run in time eO(N ε−1) for a class of well-behaved covering programs. In a follow-up work, Wang et al. [35] showed that all covering LPs can be converted into well-behaved ones by a reduction that blows up the problem size only logarithmically. At high level, these two algorithms can be described as linear couplings of several first-order descent steps. This is an application of our linear coupling technique (see [3]) to problems that are not amenable to blackbox applications known iterative algorithms in convex optimization. ∗First version of this paper appeared on arXiv on this date. A 6-paged abstract of this paper, entitled "Nearly- Linear Time Positive LP Solver with Faster Convergence Rate," was presented at the STOC 2015 conference in Portland, OR. [1]. The journal version shall appear in Mathematical Programming. 1 Introduction A packing linear program (LP) takes the form max{cT x : Ax ≤ b} where c ∈ Rn ≥0, and A ∈ Rm×n . A covering LP can be written as min{bT y : AT y ≥ c}, with the same requirements on ≥0 A, b, and c. We denote by N the number of non-zero elements in matrix A. We assume without loss of generality that the two LP programs are in their standard forms: ≥0, b ∈ Rm Packing LP: Covering LP: max x∈Rn min y∈Rm ≥0{1T x : Ax ≤ 1} , ≥0{1T y : AT y ≥ 1} . (1.1) (1.2) The two programs are dual to each other, so we denote by OPT ≥ 0 their shared optimum. We say x is a (1 − ε)-approximation for the packing LP if Ax ≤ 1 and 1T x ≥ (1 − ε)OPT, and y a (1 + ε)-approximation for the covering LP if AT y ≥ 1 and 1T y ≤ (1 + ε)OPT. In this paper, we study first-order iterative methods for solving packing and covering linear programs (PC-LPs) efficiently.1 Of course, it is possible to adopt the Interior Point or Ellipsoid methods to obtain approximate solvers with a log(1/ε) dependence on the number of iterations. However, the computational cost of such algorithms is typically high, as each iteration requires solving a linear system, and thus is not suitable for large-scale applications. To address this issue, researchers have developed iterative approximate PC-LP solvers that achieve a better dependence on the problem size (e.g., nearly linear in N ) at the cost of having a poly(1/ε) dependence on the approximation parameter ε. Such iterative solvers have been widely applied in approximation algorithms (e.g., MinSetCover [25], MaxSet, MaxDiCut, Max-k- CSP [33], bipartite matching), probabilistic checkable proofs [33], zero-sum matrix games [30], scheduling [32], graph embedding [32], flow controls [11, 12], auction mechanisms [38], wireless sensor networks [15], and many other areas. In addition, techniques developed in this line of research have inspired important results on other fundamental algorithmic problems, such as the design of fast algorithms for multi-commodity flow problems [10, 19, 20, 26, 32] and the equivalence between QIP and PSPACE [22]. Previous iterative approximate solvers can be divided into two classes, width-dependent and width-independent solvers (see also Table 1). Width-Dependent Solvers2 . Based on multiplicative weight update ideas (a.k.a. exponentiated gradient updates), researchers have obtained solvers for PC-LPs with a running time at least N multiplied with ρOPT ∈ [1,∞), where ρ is the width of the program, i.e., the largest entry of matrix A. For instance, PC-LPs can be solved in O( N ρ2OPT2 log m )-time using some more refined analysis [8]. These algorithms only require "oracle-access" to the matrix A. When A is given explicitly like in this paper, the running time can be reduced to O( N ρOPT log m ) by deploying Nesterov's accelerated gradient method [30], or Nemirovski's mirror prox method [27]. )-time [32], or O( N ρOPT log m ε2 ε2 ε Width-dependent algorithms are not polynomial time but only pseudo-polynomial time. Width-Independent, but Super Linear-Time Solvers. Researchers also tried to appropri- ately scale the matrix so as to avoid the width penalty in the above methods. For instance, Bienstock and Iyengar [14] built on Nesterov's method [30] and obtained a running time O(ε−1N√Kn log m) 1Luby and Nisan, who originally studied iterative solvers for this class of problems [25], dubbed them positive LPs. However, the class of LPs with non-negative constraint matrices is slightly larger, including mixed-packing-and- covering LPs. For this reason, we prefer to stick to the PC-LP terminology. 2Most width-dependent solvers study the minmax problem minx≥0, 1T x=1 maxy≥0, 1T y=1 yT Ax , whose optimal value equals 1/OPT. Their approximation guarantees are often written in terms of additive error. We have translated their performances to multiplicative error for a clear comparison. 1 Paper Running Time Width Indepen- dent? Nearly Linear- Time? Plotkin et al. [32] Arora et al. [8] Nemirovski [27], Nesterov [30] Bienstock and Iyengar [14] Nesterov [28]: packing LP only Chudak and Eleut´erio [16]: packing LP only parallel solvers [2, 9, 11, 12, 25, 35, 36] Young [36] Bartal et al. [11, 12] Young [37] Koufogiannakis and Young [24] Theorem 3.4 packing LP Theorem 5.3 well-behaved covering LP Theorem 6.6 covering LP ) ε ε ) ) ) ε2 ε2 O(N × ρ2OPT2 log m O(N × ρOPT log m O(N × ρOPT log m √Kn log m O(N × O(N ×(cid:0)n + ε (cid:1)) √n e ε (cid:1)) O(N ×(cid:0)n + √n e O(N × log2 N log(1/ε) O((md + N ) × log N O(nm × log N ε2 ) O(N × log N ε2 ) ε2 ) at best ε2 ) 3 O(N + (n + m) × log N ε2 ) ) ε O(N × log N log ε−1 O(N × log N log ε−1 O(N × log N log ε−1 ε1.5 ε ) ) no no no yes yes yes yes yes yes yes yes yes yes yes no no no no no no yes almost yes almost yes yes yes yes yes yes Table 1: Comparisons among iterative approximate solvers for packing and covering LPs. The width ρ ∈ [1/OPT,∞) is defined as the largest entry of the constraint matrix A. where K is the maximum number of non-zeros per row of A. This is O(ε−1N n√log m) in the worst case. The results of [16, 28] improved this complexity (for packing LP only) to eO(ε−1N√n), at a cost of enduring an eO(N n)-time preprocessing stage. gave an algorithm running in O(cid:0) N log2 N Width-Independent, Nearly Linear-Time Solvers. Perhaps the most desirable complexity is a running time that is both independent of the width parameter ρ, and also nearly linearly scales with N . 4 This line of research was initiated by a seminal paper of Luby and Nisan [25], who (cid:1) time with no dependence on the width ρ. This is also the first nearly linear-time approximate solver for PC-LPs, and also the first to run in parallel in nearly linear-work and polylogarithmic depth. ε4 The parallel algorithm of Luby and Nisan was extended by [2, 9, 11, 34, 36]. Most notably, ) iterations, each costing a matrix-vector the algorithm of Wang et al. [34] runs in O( log2 N log(1/ε) multiplication that can be implemented in O(N ) total work. ε2 The ideas of Luby and Nisan also led to sequential width-independent, nearly linear-time PC-LP solvers [11, 12, 24, 36, 37]. Most notably, the algorithm of Koufogiannakis and Young [24] runs in time O(cid:0)N + log N ε2 × (n + m)(cid:1). Despite the amount of work in this area, the O(1/ε2) convergence rate was established in 1997 [11, 12] and has not been improved since then. On a separate note, Klein and Young [23] 3The parameter d is the maximum number of constraints each variable is in; md may be larger than N . 4Some of these solvers still have a polylog(ρ) dependence. Since each occurrence of log(ρ) can be replaced with log(nm) after slightly modifying the matrix A, we have done so in Table 1 for a fair comparisons. 2 showed that all Dantzig-Wolfe type algorithms have to suffer from a O(1/ε2) convergence rate. This lack of progress constitutes a significant limitation, as the ε−2-dependence (also known as the 1/√T convergence) on the approximation parameter ε is particularly poor. 1.1 Our Results Packing LP. We present an algorithm PacLPSolver that runs in O( log(nm/ε) log(1/ε) N ) total time. This gives the first width-independent, and the first nearly linear-time solver for packing LP with an ε−1 convergence (i.e., an 1/T convergence). In contrast, no nearly linear-time algorithm has achieved any convergence rate faster than ε−2 before our work. ε Interestingly, the maximum (weighted) bipartite matching is just one instance of a packing LP. As a consequence, our PacLPSolver algorithm finds an approximate maximum bipartite matching in time eO(mε−1). This new matching algorithm, which arises purely from convex-optimization arguments, matches the running time of the best known combinatorial algorithm for maximum weighted bipartite matching [17]. ε Covering LP. A symmetric design of PacLPSolver gives rise to an algorithm CovLPSolverwb with the same running time O( log(nm/ε) log(1/ε) N ), but only solving well-behaved covering LP instances. At a high level, we say an instance is well-behaved if the constraint AT y ≥ 1 is "never redundant": for instance, if the optimal solution y∗ satisfies C · 1 ≥ AT y∗ ≥ 1 for some constant C > 1 then the covering LP is well-behaved. For the general covering LP without well-behavior assumptions, we propose a different algorithm CovLPSolver that runs in time O( log(nm/ε) log(1/ε) N ). Again, we emphasize that no nearly linear-time covering LP solver can achieve a convergence rate faster than ε−2 (or equivalently O(1/√T )) before our work. Remark. After the first version of this paper appeared on arXiv in 2014, Wang, Rao and Ma- honey [35] showed all covering LPs can be converted into well-behaved ones, by blowing up the problem size logarithmically. In other words, they obtained a nearly linear-time covering LP solver with ε−1 convergence by a reduction to CovLPSolverwb. Nevertheless, our CovLPSolver, being a direct method, may still be of practical and theoretical interests. ε1.5 1.2 Main Challenge and Our Approach Width-Independence vs. Acceleration. Previous solvers for PC-LPs are based on standard techniques in non-smooth optimization. They first implicitly or explicitly smoothen the objective, often by the entropy regularizer. Then, they minimize the resulting convex objective either via variations of full-gradient methods, yielding parallel algorithms, or via variations of coordinate- gradient methods, yielding sequential algorithms. The main challenge in previous work is to show that the width dependence can sometimes be completely removed for PC-LPs, if the underlying minimization method is designed cleverly. Of course, the slower the convergence rate is, the easier it is to design nearly linear-time solvers. The ε−4-convergence solver of Awerbuch and Khandekar [9] and the ε−3-convergence solver of [2] are arguably the simplest nearly linear-time solvers at this point. In this paper, we achieve the ε−1 convergence that is typical for accelerated gradient descent over smoothened objectives [30], but without paying the width or any additional super-logarithmic factors. The challenge in this approach is to preserve the width-independence and the accelerated rate at the same time. We stress here that our algorithm is not an instance of any known variant of 3 accelerated gradient descent5. Moreover, the incorporation of width-independence and Nesterov's acceleration requires significant effort, as witnessed by the lack of progress on this problem for the last 15 years. Finally, our algorithms are not Dantzig-Wolfe type, so can overcome the 1/ε2 lower bound of Klein and Young [23]. Our High-Level Approach. Our approach is based on an improved convex formalization f (x) of the PC-LP objective, together with our linear-coupling framework for designing efficient first-order methods [3] for minimizing f (x). The improved formalization shows that our smoothened objective f (x) satisfies either the clas- sical condition for Lipschitz smoothness or a different condition based on multiplicative change. This formalization also clarifies why width-independent algorithms exist in the first place. See Lemma 2.7 and the related discussion for more details. The linear-coupling framework in our previous work [3] provides a different interpretation of Nesterov's acceleration for smooth optimization [29]. In a nutshell, this linear-coupling framework allows us to construct accelerated algorithms by coupling the executions of a gradient descent algorithm, yielding iterates {yk} and a mirror descent step algorithm, with iterates {zk}. The name "linear coupling" stems from the fact that, at iteration k + 1, the gradient of the objective is queried at a point xk+1, which is a linear combination of gradient and mirror steps, i.e., xk+1 = (1 − τ ) · zk + (1 − τ ) · yk. In this paper, we apply linear coupling in a very non-trivial manner. We design a gradient and a mirror descent step, each very specific to the underlying PC-LP problem. We also perform a coupling step xk+1 = (1 − τ ) · zk + (1 − τ ) · yk, but need to design a different analysis to preserve width independence. None of these components has appeared in [3]. Arithmetic Precision. Throughout this paper, we assume exact arithmetic operations for pre- senting the cleanest proofs. If the updates are calculated within precision poly(ε−1,n,m) , or equiva- lently when word size O(log(ε−1 + n + m)) is used, our results still hold.6 1 Roadmap. We relax the packing LP in Section 2, and provide our packing LP solver in Section 3. We relax the covering LP in Section 4, and provide our covering LP solver in the well-behaved case in Section 5. In Section 6, we provide our full covering LP solver. 2 Relaxation of the Packing Linear Program To solve packing LP, we minimize a relaxed version of the original LP, where the hard constraint Ax ≤ 1 is regularized by entropy and replaced by an exponential penalty function. Notations. Recall that the packing LP in its standard form is maxx≥0{1T x : Ax ≤ 1}. Let us denote by OPT the optimal value of this linear program, and x∗ any optimal solution. We say that x is a (1 − ε)-approximation for the packing LP if Ax ≤ 1 and 1T x ≥ (1 − ε)OPT. 5This can be verified by observing that our objective fµ(x), to be introduced later, is not globally Lipschitz smooth, so that one cannot apply accelerated gradient descent directly. 6Due to space limitation, we quickly sketch why logarithmic word size suffices for our algorithms. On one hand, one can prove in an iteration, if x is calculated with a small additive error 1/poly(1/ε, n, m), then the objective f (x) may increase only by 1/poly(1/ε, n, m) in that iteration. The proof of this relies on the fact that (1) one can assume without loss of generality all entries of A are no more than poly(1/ε, n, m) and (2) our algorithms ensure f (x) < poly(1/ε, n, m) for all iterations with high probability, so even though we are using the exponential functions, f (x) will not change additively by much. On the other hand, one can similarly prove that each ∇if (x) can be calculated within an additive error 1/poly(1/ε, n, m) in each iteration. They together imply that the total error incurred by arithmetic operations can be made negligible. 4 Throughout this paper, we use the indices i ∈ [n] to denote the columns of A, and the indices j ∈ [m] to denote the rows of A. We let A:i be the i-th column vector of A, and Aj: the j-th row i · kA:ik∞ the A-norm of x. By vector of A. Given any vector x, we denote by kxkA =qPi∈[n] x2 simple scaling, we can assume without loss of generality that7 (2.1) min i∈[n]{kA:ik∞} = 1 . def= {x ∈ Rn : xi ∈(cid:2)0, We restrict the domain of x and the range of OPT as follows. 1 kA:ik∞(cid:3)}. Under assumption (2.1), Fact 2.1. Define the bounding box ∆box we have OPT ∈ [1, n] and {x : x ≥ 0 ∧ Ax ≤ 1} ⊆ ∆box. Proof. Suppose that i∗ is the column that achieves the smallest infinite norm kA:ik∞ over all columns. Letting x be such that xi = 1 at i = i∗ and xi = 0 at i 6= i∗, we claim that x is a feasible solution for the packing LP (1.1), simply because kA:i∗k∞ = 1 according to (2.1). This feasible solution x yields an objective value 1T x = 1, proving that OPT ≥ 1. On the other hand, for any solution x ≥ 0 satisfying Ax ≤ 1, we must have xi ≤ for each i. Therefore, 1T x ≤Pi together imply xi ≤ 1 This bounding-box constraint allows us to focus only on searching x in ∆box. The inclusion {x : x ≥ 0 ∧ Ax ≤ 1} ⊆ ∆box is obvious, since the constraints x ≥ 0 and Ax ≤ 1 (cid:3) kA:ik∞ ≤ n, proving that OPT ≤ n. for every i ∈ [n]. kA:ik∞ kA:ik∞ 1 1 Our Regularized Objective. We now introduce the smoothed objective fµ(x) that we minimize over ∆box in order to approximately solve packing LP. At a high level, this objective fµ(x) turns each row of the hard, non-smooth LP constraint Ax ≤ 1 into an exponential penalty function so that we only need to require x ∈ ∆box throughout the algorithm. Formally, the packing LP can be written as the following minimization problem by introducing the Lagrangian variable y ∈ Rm: x∈∆box(cid:8) − 1T x + max regularizer to be the generalized entropy H(y) = −Pm The problem can be now smoothened by introducing a concave regularizer over y ≥ 0. We take this j=1 yj log yj + yj over the first orthant y ≥ 0, and minimize the following smoothened objective fµ(x) over x ∈ ∆box: y≥0 {yT Ax − 1T y}(cid:9) . (2.2) min fµ(x) def= −1T x + max y≥0 {yT Ax − 1T y + µ · H(y) } . (2.3) j=1 e Above, µ > 0 is some smoothing parameter to be chosen later. By explicitly computing the maximization over y ≥ 0, fµ(x) can be rewritten as ((Ax)j−1) − 1T x . Fact 2.2. fµ(x) = µPm We study the minimization problem on fµ(x) over x ∈ ∆box. Intuitively fµ(x) captures the original packing LP (1.1) as follows. Firstly, since we want to maximize 1T x, the negative term −1T x shows up in fµ(x). Secondly, if a packing constraint j ∈ [m] is violated by ε, that is, (Ax)j ≥ 1 + ε, the exponential penalty in fµ(x) introduces a penalty at least µeε/µ; this will be a large penalty if µ ≤ O(ε/ log(n/ε)). Remark 2.3. The use of exponential function at least traces back to [32] in 1991 (implicitly) and to [21] in 1994 (explicitly). The way most previous results minimize fµ(x) is by taking a logarithm 1µ 7If mini∈[n]{kA:ik∞} = 0 then the packing LP is unbounded so we are done. Otherwise, if mini∈[n]{kA:ik∞} = v > 0 we scale all entries of A by 1/v, and scale OPT by v. 5 g(x) = log(cid:0)Pm j=1 e((Ax)j−1)/µ(cid:1), explicitly or implicitly arguing that g(x) is Lipschitz smooth (i.e., k∇2f (x)k is bounded), and then taking gradient descent.8 Unfortunately, the Lipschitz smoothness parameter of g(x) depends on the width of the LP, and thus first-order iterative approaches based on directly minimizing g(x) are mostly width-dependent [8, 27, 30, 32]. One can also reduce the width parameter of g(x) which yields super linear-time solvers [14, 16, 28]. In this paper, we directly perform gradient descent and mirror descent on fµ(x) -without taking the logarithm. Note that traditional accelerated gradient methods [29, 30] should not be applied directly to minimize fµ because it is not Lipschitz smooth.9 Our fµ(x) incurs a regularization error. The next proposition bounds this error following a similar treatment in [2]. ε 4 log(nm/ε) and recall x∗ is an optimal solution for packing LP. Proposition 2.4. Let µ = (a) fµ(u∗) ≤ −(1 − ε)OPT for u∗ def= (1 − ε/2)x∗ ∈ ∆box. (b) fµ(x) ≥ −(1 + ε)OPT for every x ∈ ∆box. (c) If x ∈ ∆box satisfies fµ(x) ≤ −(1−θ)OPT for some θ ∈ [0, 1], then 1 solution to the packing LP. 1+ε x is a 1−θ 1+ε -approximate Remark 2.5. Our box constraint x ∈ ∆box is almost redundant for minimizing fµ(x): whenever x ≥ 0 and fµ(x) ≤ 0, one should automatically have xi ≤ 1+ε . However, this constraint shall be kA:ik∞ used to make sure that our updates are always inside ∆box. µm (nm)2 − (1 − ε/2)OPT ≤ −(1 − ε)OPT . ≤ Proof of Proposition 2.4. (a) We have 1T u∗ = (1 − ε/2)OPT by the definition of OPT. from the feasibility Ax∗ ≤ 1 in the packing LP, we have Au∗ − 1 ≤ −ε/2 · 1, and can compute fµ(u∗) as follows: e −ε/2 µ − (1 − ε/2)OPT ((Au∗)j−1) − 1T u∗ ≤ µXj 1µ e fµ(u∗) = µXj (b) Suppose towards contradiction that fµ(x) < −(1 + ε)OPT. Since fµ(x) > −1T x, it must satisfy that 1T x > (1 + ε)OPT. Suppose that 1T x = (1 + v)OPT for some v > ε. By the definition of OPT, we must have that Ax < (1 + v)1 is broken, and therefore there exists some j ∈ [m] satisfying that (Ax)j ≥ 1 + v. In such a case, the objective fµ(x) ≥ µev/µ − (1 + v)OPT = − (1 + v)OPT nm ε ε 4 log(nm/ε)(cid:16)( )4(cid:17)v/ε ≥(cid:16)(cid:16)( nm ε (cid:17)2 )v/ε − (1 + v)(cid:17)OPT > 0 giving a contradiction to the assumption that fµ(x) < 0. (c) Note that x satisfies fµ(x) ≤ −(1 − δ)OPT ≤ 0, and we first show Ax ≤ (1 + ε)1. Let us assume that v = maxj((Ax)j − 1) ≥ 0 because otherwise we will have Ax ≤ 1. Under this 8Note that some of the previous results (such as [8, 32]) appear to directly minimizePm j=1 e((Ax)j−1)/µ as opposed to its logarithm g(x). However, their per-iteration objective decrease is multiplicative, meaning it is essentially equivalent to performing a single gradient-descent step on g(x) with additive objective decrease. without the constraint x ∈ ∆box. The techniques in [2] only leads to ε−2 convergence (see Table 1). 9The exact same fµ(x) also appeared in our previous work [2], albeit without this smoothing interpretation and 6 definition, we have Ax ≤ (1 + v)1 and therefore 1T x ≤ (1 + v)OPT by the definition of OPT. We compute fµ(x) as follows. − (1 + v)OPT ≥ µ(cid:16)( )4(cid:17)v/ε − (1 + v)n . fµ(x) ≥ µe The above quantity is positive whenever v ≥ ε, and therefore, to satisfy fµ(x) ≤ 0 we must have v ≤ ε, which is equivalent to Ax ≤ (1+ε)1. Next, because −1T x ≤ fµ(x) ≤ −(1−δ)OPT, we know 1T x ≥ (1−δ)OPT. Letting x0 = 1 1+ε x, we both have that x0 is feasible (i.e., Ax0 ≤ 1), (cid:3) and x0 has an objective 1T x0 at least as large as 1−δ 4 log(nm/ε)(cid:16)( )4(cid:17)v/ε − (1 + v)n = 1+ε OPT. nm nm ε ε ε vµ Some Non-Standard Smoothness Properties. The gradient and Hessian of fµ(x) can be written in the following closed forms: ((Ax)j−1). 1µ Fact 2.6. ∇fµ(x) = AT p(x) − 1 and ∇2fµ(x) = 1 µ AT diag{p(x)}A, where pj(x) def= e By staring at these closed forms, we note that fµ(x) is not Lipschitz-smooth: for instance, each ∇2 iifµ(x) can go to infinity so the spectral norm of ∇2fµ(x) is unbounded. However, the non- negativity of A guarantees that whenever ∇2 iifµ(x) is large for some coordinate i, the corresponding entry of the gradient ∇ifµ(x) must also be large. This still allows us to take a larger step in direction ei than traditionally allowed by coordinate descent. The above intuition is formalized in the next lemma, whose proof is by simple manipulation of Hessian. The first half of the lemma is the same as the traditional coordinate Lipschitz-smoothness property, but holds only conditionally; the second half is a salient characteristic of this work and requires the non-negativity of A. These smoothness properties will be crucial in applying gradient descent arguments in Section 3.3, and are the main motivation for us to adopt the k · kA norm for our proposed algorithms. 1 LkA:ik∞ , 1 LkA:ik∞(cid:3): dν(cid:12)(cid:12)(cid:12) (AT p(x + νei))i λ . 4 kA:ik∞L {= λ 0 (cid:12)Z λ (cid:12) (cid:12) (cid:12)Z λ (cid:12) (cid:12) kA:ik∞ 0 µ 1 µ y= z≤ 2 x= Lemma 2.7. Let L def= 4 µ . Then, for every x ≥ 0, every i ∈ [n], and every λ ∈(cid:2)− (a) If ∇ifµ(x) ≤ 1, then(cid:12)(cid:12)∇ifµ(x + λei) − ∇ifµ(x)(cid:12)(cid:12) ≤ LkA:ik∞ · λ . (b) If ∇ifµ(x) ≥ 1, then ∇ifµ(x + λei) ≥(cid:16)1 − kA:ik∞L λ(cid:17)∇ifµ(x) . dν(cid:12)(cid:12)(cid:12) ∇2 iifµ(x + νei) ∇ifµ(x + νei) + 1 (AT diag{p(x + νei)}A)ii Proof of Lemma 2.7. Using the fact that ∇ifµ(x) > −1 for all x, we have: (cid:12) (cid:12) log ∇ifµ(x + λei) + 1 (cid:12) ∇ifµ(x) + 1 (cid:12) (cid:12) (cid:12) { holds because L = 4 Above, x holds because R λ according to Fact 2.6; z is because the numerator isPj A2 λ ≤ ∇ifµ(x + λei) + 1 λ ≤ 1 Our assumption on λ implies kA:ik∞L over x ∈ [− 1 4 ]. This yields the simpler bound: µ . This immediately implies e− kA:ik∞L 4 , 1 4 4 0 g0(ν)dν = g(λ) − g(0) where g(ν) = log(∇ifµ(x + νei) + 1); y holds j,ipj while the denominator isPj Aj,ipj; kA:ik∞L 4 λ. ≤ e ∇ifµ(x) + 1 4 , so that we can use the approximation x ≤ ex−1 ≤ 1.2x −kA:ik∞L 4 λ ≤ ∇ifµ(x + λei) − ∇ifµ(x) ∇ifµ(x) + 1 ≤ 1.2kA:ik∞L 4 λ. 7 (a) Assuming that ∇ifµ(x) ∈ (−1, 1], we have: (cid:12) (cid:12)∇ifµ(x + λei) − ∇ifµ(x)(cid:12)(cid:12)(cid:12) ≤ 2.4 · kA:ik∞L (cid:12) 4 (b) Assuming ∇ifµ(x) ≥ 1, we have ∇ifµ(x + λei) ≥ ∇ifµ(x) − kA:ik∞L 4 λ ≤ kA:ik∞Lλ . λ(cid:16)∇ifµ(x) + 1(cid:17) ≥(cid:16)1 − kA:ik∞L 2 λ(cid:17)∇ifµ(x) . (cid:3) (cid:3) Initialization. Fact 2.8. Let xstart i Iterative methods require a starting point, and we use the following one for each i ∈ [n]. Then, xstart ∈ ∆box and fµ(xstart) ≤ − 1−ε n . def= 1−ε/2 nkA:ik∞ −ε/2 µ − n e Proof. Using the fact that Axstart − 1 ≤ −ε/2 · 1, we compute fµ(xstart) as follows: 1 − ε/2 1µ e fµ(xstart) = µXj ((Axstart)j−1) − 1T xstart ≤ µXj µm (nm)2 − Above, we have used 1T xstart ≥ xstart ≤ 1 − ε/2 1 − ε n ≤ − . i = 1−ε/2 n n , where i is the column s.t. kA:ik∞ = 1. 3 Our Packing LP Solver Recall traditional (accelerated or not) gradient descent [29, 30] or coordinate descent [6, 18, 31] should not be applied directly to minimize fµ, because fµ is not Lipschitz-smooth. We select i ∈ [n] uniformly at random. Let ξ(i) Our proposed algorithm PacLPSolver starts with some initial vector x0 = y0 = xstart (see Fact 2.8) and z0 = 0, and is divided into T iterations. In each iteration k, it computes a weighted midpoint xk ← τ zk−1 + (1 − τ )yk−1 for some parameter τ ∈ (0, 1). This step is analogous to that in traditional accelerated coordinate descent [6, 18, 31]. We then compute yk and zk as follows. k = (0, . . . , 0, Tp(v), 0, . . . , 0) be the vector that is only non-zero at coordinate i, where v = ∇ifµ(xk) ∈ [−1,∞), and Tp(v) is the thresholding function Tp(v) def= min{v, 1}. We refer to ξ(i) k , zi(cid:9) for k as the truncated gradient.10 Next, 2kz − zk−1k2 def= arg minz∈∆box(cid:8) 1 • Perform a mirror (descent) step zk ← z(i) some parameter αk (cid:28) 1/n to be chosen later. • Perform a gradient (descent) step yk ← y(i) A + hnαkξ(i) k − zk−1). nαkL (z(i) def= xk + 1 k k This finishes the description of our PacLPSolver. Remark 3.1. We use the superscript (i) on ξ(i) to emphasize that the value depends on the choice of i. We use generic parameters τ, αk, T in the above description and their precise values are presented in Algorithm 1. k and z(i) k , y(i) k the objective (i.e., fµ(xk) − fµ(y(i) Our update on yk is a "gradient descent step" because we shall prove that it strictly decreases k ) ≥ 0). Our update on zk is a "mirror descent step" because we shall apply standard mirror descent analysis [13] to it. We explicitly describe how to implement the mirror step (its proof is straightforward by computing the gradient): 10A similar gradient truncation was developed in our prior work [2], but for a different purpose (to ensure paral- lelism) and not applied to coordinate gradient. The truncation idea of this paper also inspired later works in matrix scaling [7] and in SDP [5]. 8 . recall ∆box def= {x ∈ Rn : xi ∈(cid:2)0, 1 kA:ik∞(cid:3)} . parameters . number of iterations ε ε µ , τ ← 1 4 log(nm/ε) , L ← 4 3·nL and α0 ← 1 nL . ). , xstart ∈ ∆box, ε ∈ (0, 1/30]. Algorithm 1 PacLPSolver(A, xstart, ε) Input: A ∈ Rm×n ≥0 Output: x ∈ ∆box. 1: µ ← 2: T ← d3nL log(1/ε)e = O(n · log(nm/ε)·log(1/ε) 3: x0 = y0 ← xstart, z0 ← 0. 4: for k ← 1 to T do 1−τ αk−1 αk ← 1 xk ← τ zk−1 + (1 − τ )yk−1. Randomly select i ∈ [n] uniformly at random. Define vector ξ(i) k zk ← z(i) yk ← y(i) 10: 11: end for 12: return yT . def= arg minz∈∆box(cid:8) 1 2kz − zk−1k2 k − zk−1). 5: def= xk + 1 nαkL (z(i) 9: 6: 7: 8: k k A + hnαkξ(i) k , zi(cid:9). to be all-zero except at coordinate i, where ξ(i) k,i = min{1,∇ifµ(xk)}. . See Proposition 3.2 Proposition 3.2. If ∆box = {x ∈ Rn : xi ∈(cid:2)0, z = arg minz∈∆box(cid:8) 1 kA:ik∞(cid:3)} for some constant C > 0, the minimizer A + hδei, zi(cid:9) for any δ ∈ R and basis vector ei can be computed as 2kz − zk−1k2 follows: C 1. z ← zk−1. 2. zi ← zi − δ/kA:ik∞. 3. If zi < 0, then zi ← 0; if zi > C/kA:ik∞, zi ← C/kA:ik∞. 4. Return z. We also point out that Lemma 3.3. Each iteration of PacLPSolver can be implemented to run in expected O(N/n) time. The total expected running time is O(T N/n). Lemma 3.3 is not hard to prove, but anyways included in Appendix E. It follows from standard implementation tricks which compute xk and yk only implicitly: that is to express xk and yk as linear combinations of two less-frequently-updated vectors. 3.1 Convergence Statement In this section, we focus on proving the following main theorem. Theorem 3.4. PacLPSolver(A, xstart, ε) outputs some yT satisfying E[fµ(yT )] ≤ −(1 − 3ε)OPT . It is straightforward to use Markov's bound to turn Theorem 3.4 into a probabilistic one yT Corollary 3.5. With probability at least 2/3, the output yT = PacLPSolver(A, xstart, ε) satisfies 1+ε is a (1 − O(ε)) approximate solution to the packing LP program. The expected running that time is O( log(nm/ε) log(1/ε) N ). ε Proof of Corollary 3.5. Since for every x ∈ ∆box it satisfies fµ(x) ≥ −(1 + ε)OPT according to Proposition 2.4.b, we obtain that fµ(yT ) + (1 + ε)OPT is a random variable that is non-negative, 9 whose expectation E[fµ(yT ) + (1 + ε)OPT] ≤ 4ε according to Theorem 3.4. By Markov bound, with at least probability 2/3, we obtain some yT satisfying fµ(yT ) ≤ −(1 − 11ε)OPT, which yields a (1− O(ε)) approximate solution to packing LP according to Proposition 2.4.c. The running time (cid:3) follows from Lemma 3.3. Before we prove prove Theorem 3.4 in subsequent subsections, let us first point out that our iterates xk, yk, zk never leave the bounding box ∆box: Lemma 3.6. We have xk, yk, zk ∈ ∆box for all k = 0, 1, . . . , T . (The proof of Lemma 3.6 is included in Appendix A, and the main technique already appeared in randomized coordinate descent [18].) 3.2 Step 1: Mirror Descent Guarantee k = arg minz∈∆box(cid:8) 1 2kz− 1 2 1 2 A + (z(i) 1 2 (cid:3) A A 1 2 1 2 1 2 1 2 A − k , z(i) Proof. Denoting by Va(b) = 1 A as a function of b ∈ ∆box parameterized at a ∈ ∆box, we have ∇iVa(b) = kA:ik∞ · (ai − bi). In the optimization language, Va(b) is the Bregman divergence of the k · k2 (cid:10)nαkξ(i) A regularizer [13]. We derive the following sequence of inequalities: k , zk−1 − u(cid:11) =(cid:10)nαkξ(i) k (cid:11) +(cid:10)nαkξ(i) k − u(cid:11) k , zk−1 − z(i) (cid:10)nαkξ(i) k (cid:11) +(cid:10) − ∇Vzk−1(z(i) k , zk−1 − z(i) k ), z(i) (cid:10)nαkξ(i) k (cid:11) − kzk−1 − z(i) k , zk−1 − z(i) k k2 kL(cid:16)(cid:10)ξ(i) A(cid:17) + k , xk − yk(cid:11) − kxk − ykk2 kL ·(cid:10)ξ(i) k , xk − yk(cid:11) + kzk−1 − uk2 ≤ n2α2 k , z(cid:11)(cid:9), which implies k (cid:11) ≥ 0 for all u ∈ ∆box. Equality y can be checked for every k , u − z(i) k,' − u')2(cid:17) . = kA:ik∞(cid:16) − k − u(cid:11) kzk−1 − uk2 A − kzk−1 − uk2 A − kz(i) k − uk2 A . k = arg minz∈∆box(cid:8)Vzk−1(z) +(cid:10)nαkξ(i) k,' − u') = kA:ik∞(zk−1,' − z(i) k ) + nαξ(i) coordinate ' ∈ [n] as follows: that (cid:10)∇Vzk−1(z(i) −∇'Vzk−1(z(i) k,') · (z(i) (zk−1,' − z(i) Above, x is due to the minimality of z(i) kz(i) k − uk2 kz(i) k − uk2 k,' − u') k,')2 + (u' − zk−1,')2 − k ) · (z(i) z is by our choice of yk which satisfies that zk−1 − z(i) k = nαkL(xk − y(i) k ). x≤ y= L 2 1 2 n2α2 z= 1 2 1 2 In addition, as a simple corollary of Proposition 3.2, we have the following fact Fact 3.8. z(i) k,i ≥ 0, then z(i) ξ(i) nαkξ(i) k,i k,i − zk−1,i ≤ kA:ik∞ k,i ≤ xk,i; if ξ(i) k,i ≤ zk−1,i and y(i) and y(i) k,i − xk,i = 1 nαkLz(i) k,i ≤ 0, then z(i) k,i − zk−1,i ≤ ξ(k) k,i k,i ≥ zk−1,i and y(i) LkA:ik∞ ≤ k,i ≥ xk,i. 1 LkA:ik∞ . If 10 kz(i) k − uk2 A . 1 2 kzk−1 − uk2 A − 1 2 kL ·(cid:10)ξ(i) k (cid:11) + k , xk − y(i) Following almost classical analysis of mirror descent (cf. textbook [13]), our update z(i) zk−1k2 Lemma 3.7 (mirror descent). For every u ∈ ∆box, it satisfies A + hnαkξ(i) (cid:10)nαkξ(i) k , zi(cid:9) satisfies k , zk−1 − u(cid:11) ≤ n2α2 2kb − ak2 3.3 Step 2: Gradient Descent Guarantee nαkL (z(i) We call our update y(i) lemma guarantees fµ(y(i) decreases at least by 1 Lemma 3.9 (gradient descent). We have fµ(xk) − fµ(y(i) k ← xk + 1 k − zk−1) a gradient descent step, because the following k ) ≤ fµ(xk), that is, the objective only decreases; moreover, the objective 2h∇fµ(xk), xk − y(i) k i. 2h∇fµ(xk), xk − y(i) k i ≥ 0. k ) ≥ 1 This Lemma 3.9, which is characteristic of the PC-LP setting, is strong in the following sense. Even though the update y(i) k , the progress we make is a function of the true gradient ∇ifµ(xk), including the large component that was discarded. This is possible because the smoothness guarantee of Lemma 2.7.b allows us to take a long coordinate step even though fµ(x) is not Lipschitz-smooth. k only depends on the truncated gradient ξ(i) 2 1 2 k,i = ∇ifµ(xk). k = xk + sλei for some s ∈ {−1, +1} and step k ) = fµ(xk) − fµ(xk + sλei) = −sZ λ LkA:ik∞(cid:3). We first focus on the case ∇ifµ(xk) ∈ [−1, 1] so ξ(i) fµ(xk) − fµ(y(i) sZ λ 0 (cid:16) − ∇ifµ(xk) − LkA:ik∞ · sχ(cid:17)dχ = −∇ifµ(xk) · sλ − h∇fµ(xk), y(i) k,i = −s∇ifµ(xk) (see also Fact 3.8). 0 (cid:16)∇ifµ(xk + sχei)(cid:17)dχ · λ2 ξ(k) k,i LkA:ik∞ −∇ifµ(xk) · sλ − k − xki . LkA:ik∞ LkA:ik∞ · λ · − z= 2 1 x≥ y≥ k i ≥ 0 (cid:3) h∇fµ(xk), xk − y(i) k i . 1 2 ∇ifµ(x)dχ = 1 LkA:ik∞ . Finally, we have h∇fµ(xk), xk − y(i) k,i have the same sign, and xk,' = y(i) k,' for ' 6= i. Above, x uses Lemma 2.7.a, y uses Fact 3.8, and z uses ξ(k) Next, we turn to the case of ∇ifµ(xk) > 1. In this case, we have s = −1 and k ) = fµ(xk) − fµ(xk − λei) =Z λ 0 ∇ifµ(xk − χei)dχ 1 2 Z λ 0 2 y≥ fµ(xk) − fµ(y(i) Z λ 0 (cid:16)1 − kA:ik∞L Above, x uses Lemma 2.7.b and y uses χ ≤ λ ≤ because ∇ifµ(xk) and xk,i − y(i) 3.4 Step 3: Putting All Together χ(cid:17)∇ifµ(x)dχ x≥ length λ ∈(cid:2)0, Proof of Lemma 3.9. Using Fact 3.8, we write y(i) We denote by η(i) ∇ifµ(xk) − ξ(i) k ∈ Rn ≥0 the vector that is only non-zero at coordinate i, and satisfies η(i) k,i = k,i ∈ [0,∞). In other words, the full gradient ∇fµ(xk) = Ei[(0, . . . , n∇ifµ(xk), . . . , 0)] = Ei[nη(i) k + nξ(i) k ] can be (in expectation) decomposed into the a large non-negative component η(i) k ∈ [0,∞)n and a truncated component ξ(i) k did not contribute to the descent steps (see Line 9 of PacLPSolver). Now, for any u ∈ ∆box, we can use a basic convexity argument and the mirror descent lemma to compute that k ∈ [−1, 1]n. Recall that η(i) αk(fµ(xk) − fµ(u)) ≤(cid:10)αk∇fµ(xk), xk − u(cid:11) =(cid:10)αk∇fµ(xk), xk − zk−1(cid:11) +(cid:10)αk∇fµ(xk), zk−1 − u(cid:11) =(cid:10)αk∇fµ(xk), xk − zk−1(cid:11) + Eih(cid:10)nαkη(i) k , zk−1 − u(cid:11) +(cid:10)nαkξ(i) k , zk−1 − u(cid:11)i 11 (3.1) Ai (3.2) 1 2 1 2 (fµ(yk−1) − fµ(xk)) (cid:10)∇fµ(xk), yk−1 − xk(cid:11) + Eih(cid:10)nαkη(i) kL ·(cid:10)ξ(i) k , zk−1 − u(cid:11) + n2α2 k , zk−1 − u(cid:11) +(cid:10)nαkξ(i) k (cid:11) + k , xk − y(i) kzk−1 − uk2 k , zk−1 − u(cid:11)i kz(i) k − uk2 A − + Eih (cid:10)nαkη(i) (1 − τ )αk (1 − τ )αk τ τ x= y≤ Above, x is because xk = τ zk−1 + (1− τ )yk−1, which implies that τ (xk − zk−1) = (1− τ )(yk−1 − xk). y uses convexity and Lemma 3.7. This above computation is motivated by [3], and as we shall see below, it allows one to linearly couple gradient and mirror steps. Intuitively, the first term in the box of (3.2) is the loss introduced by the large gradient η(i) k . This part was truncated so did not contribute to the mirror step. The second term in the box is the loss introduced by mirror descent on the small gradient ξ(i) k in Lemma 3.7. gradient step -that is, the objective decrease of fµ(xk) − fµ(y(i) Now comes an important observation. As shown by Lemma 3.10 below, the performance of the k )- is at least proportional to the total loss incurred in the box. Intuitively, this means that the progress in the gradient step is so large that it outweighs not only the loss from mirror descent (as is typical in accelerated gradient analyses [3, 30]) but also the loss term introduced by η(i) k . Lemma 3.10 (gradient descent total guarantee). For every u ≥ 0, (cid:10)nαkη(i) k , zk−1 − u(cid:11) + n2α2 kL ·(cid:10)ξ(i) k , xk − y(i) k (cid:11) ≤ 3nαkL · (fµ(xk) − fµ(y(i) k )) . The proof of Lemma 3.10 is a careful case analysis and several simple applications of Lemma 3.9. We remark that to properly upper bound hnαkη(i) k , zk−1 − ui, one needs to have some good upper bound the coordinates of zk−1. This is exactly the place we need our redundant constraint which ensures zk−1,i ≤ 1 Proof of Lemma 3.10. There are three possibilities: (see Remark 2.5). kA:ik∞ by the definition k are only different at coordinate ; k = xk − ei LkA:ik∞ 12 kL · (fµ(xk) − fµ(y(i) k )) (see Proposition 3.2), k,i = 0, then we must have ξ(i) k , zk−1 − u(cid:11) + n2α2 • If η(i) (cid:10)nαkη(i) k,i > 0 and z(i) • If η(i) and accordingly y(i) kL ·(cid:10)ξ(i) k,i = ∇ifµ(xk) ∈ [−1, 1]. Lemma 3.9 implies k (cid:11) k , xk − y(i) kL ·(cid:10)∇fµ(xk), xk − y(i) = n2α2 k (cid:11) ≤ 2n2α2 k,i = zk−1,i − nαk kA:ik∞ k,i > 0, then we precisely have z(i) k,i = xk,i − LkA:ik∞ < xk,i. In this case, 1 1 + n2α2 kA:ik∞ nαk · ∇ifµ(xk) · nαk · ∇ifµ(xk) · (cid:10)nαkη(i) kL ·(cid:10)ξ(i) k , zk−1 − u(cid:11) + n2α2 k (cid:11) k , xk − y(i) k (cid:11) kL ·(cid:10)ξ(i) k , xk − y(i) kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) k (cid:11) + n2α2 kL(cid:1) · (fµ(xk) − fµ(y(i) Above, x follows from the fact that zk−1 ∈ ∆box and therefore zk−1,i ≤ 1 of ∆box, and u ≥ 0; y follows from the fact that xk and y(i) i, and ξ(i) and { uses Lemma 3.9. nαkL ·(cid:10)∇fµ(xk), xk − y(i) (cid:0)2nαkL + 2n2α2 k,i = 1 < ∇ifµ(xk) (since η(i) k,i > 0); z follows from the fact that y(i) kA:ik∞ + n2α2 kA:ik∞ k )) . {≤ x≤ y< z= 1 (cid:3) (3.3) Ai kzk − uk2 Ai . kzk − uk2 1 2 kL · (fµ(xk) − fµ(y(i) k )) . k,i; y uses the k,' for every ' 6= i; z is from our choice k ); and { uses Lemma 3.9. k ) ≥ 0, we conclude that kL) · (fµ(xk) − fµ(y(i) k )) 1 2 1 2 1 2 n2α2 k,i + 1 > η(i) (cid:10)nαkη(i) k , zk−1 − u(cid:11) + n2α2 kL ·(cid:10)ξ(i) k (cid:11) k , xk − y(i) kL ·(cid:10)∇fµ(xk), xk − y(i) (cid:0)nαk∇ifµ(xk) · zk−1,i(cid:1) + n2α2 k (cid:11) (cid:10)nαk∇fµ(xk), zk−1 − z(i) k (cid:11) + n2α2 kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) + n2α2 kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) { ≤ 4n2α2 k,i and ∇ifµ(xk) > ξ(i) Above, x is because u ≥ 0, ∇ifµ(xk) = η(i) k,i = 0 and the fact that zk−1,' = z(i) assumption that z(i) of yk which satisfies that zk−1 − z(i) k = nαkL(xk − y(i) kL ·(cid:10)ξ(i) (cid:10)nαkη(i) Combining the three cases, and using the fact that fµ(xk) − fµ(y(i) k (cid:11) ≤ (2nαkL + 4n2α2 ≤ 3nαkL · (fµ(xk) − fµ(y(i) Above, the last inequality uses our choice of αk, which implies nαk ≤ nαT = 1 αk(fµ(xk) − fµ(u)) ≤(cid:10)αk∇fµ(xk), xk − u(cid:11) (fµ(yk−1) − fµ(xk)) + Eih3nαkL · (fµ(xk) − fµ(y(i) αkfµ(xk) +(cid:0)3nαkL − αk(cid:1)fµ(yk−1) + Eih − 3nαkL · fµ(y(i) k , zk−1 − u(cid:11) + n2α2 kzk−1 − uk2 A − Plugging Lemma 3.10 back to (3.2), we have k )) . εL ≤ 1 4 . k , xk − y(i) kzk−1 − uk2 (1 − τ )αk k )) + k ) + A − y≤ x≤ x≤ y= z= τ • If η(i) k,i > 0 and z(i) k,i = 0, then we have Above, x uses Lemma 3.10; and y is because we have chosen τ to satisfy 1 τ = 3nL. Next, recall that we have picked αk so that (3nL−1)αk = 3nL·αk−1 in Algorithm 1. Telescoping Here, the second inequality is due to fµ(y0) = fµ(xstart) ≤ 0 from Fact 2.8, and the fact that n n n i=1 i=1 A = A = ku∗k2 kz0 − u∗k2 rearrange and obtain that X X (x∗i )2 · kA:ik∞ ≤ (u∗i )2 · kA:ik∞ ≤ k=0(cid:0)1 − 1 Finally, using the fact that PT k=1 αk = αT ·PT−1 E[fµ(yT )] ≤ Pk αk OPT =(cid:0)1 − (1 − nαT L = (1 − 1 We choose T = d3nL log(1/ε)e so that fµ(u∗) ≤ −(1 − ε)OPT < 0 (see Proposition 2.4.a), we obtain )T(cid:1)fµ(u∗) + E[fµ(yT )] ≤ (1 − ε)fµ(u∗) + ε/3 · OPT < −(1 − 3ε)OPT . 3nαT L 1 X fµ(u∗) + 3nαT L 3nL i=1 1 1 Therefore, we have finished proving Theorem 3.4. 3nL(cid:1)k = 3nαT L(cid:0)1 − (1 − 1 3nL )T(cid:1), we 1 3nαT L OPT . 3nL )T ≤ ε. Combining this with the fact that x∗i = OPT . (cid:3) (3.3) for k = 1, . . . , T and choosing u∗ = (1 − ε/2)x∗, we have αkfµ(u∗) ≤ 3fµ(y0) − 3nαT L · E[fµ(yT )] + kz0 − u∗k2 − T X k=1 A ≤ −3nαT L · E[fµ(yT )] + OPT . 13 4 Relaxation of the Covering Linear Program Since PacLPSolver gives only an approximate packing LP solution, we cannot infer from it a dual covering LP solution. Therefore, we have to work on a relaxed version of covering LP directly. For input matrix A ∈ Rm×n , we rewrite the covering LP problem (1.2) as follows in order to be ≥0 notationally close to packing LP: min x≥0{1T x : Ax ≥ 1} . (4.1) We denote by OPT the optimal value to this LP, and by x∗ any of its optimal solutions. We say that x is a (1 + ε)-approximation for the covering LP if Ax ≥ 1 and 1T x ≤ (1 + ε)OPT. Again, we use indices i ∈ [n] for the columns of A, and indices j ∈ [m] for the rows of A. We denote by A:i the i-th column vector of A, and Aj: the j-th row vector of A. We assume without loss of generality by simple scaling that11 min j∈[m]{kAj:k∞} = 1 . (4.2) Proposition 4.1. The normalization (4.2) ensures OPT ∈ [1, m]. Proof. Suppose that j∗ is the row that achieves the smallest infinite norm kAj:k∞ over all rows j ∈ [m]. Then, for any solution x ∈ Rn ≥0 satisfying hAj∗:, xi ≥ 1, we must have 1T x ≥ 1/kAj∗:k∞ = 1 using (4.2). On the other hand, we can construct a feasible solution x as follows. Initialize x = 0, and then for each row j, let us find the coordinate i that maximizes the value of Aij among all columns i. Then, we increase xi by 1/Aij = 1/kAj:k∞. After we have exhausted all the m rows, (cid:3) In our covering LP solvers, we assume that an initial solution, achieving a constant approxima- tion, is available to the algorithm. Such a solution can be obtained for instance by the covering LP solver from Young [37] with constant  in time O(N log N ). we arrive at some x ≥ 0 satisfying Ax ≥ 1 as well as 1T x =Pj 1/kAj:k∞ ≤ m. Definition 4.2. Let x] be a given 2-approximate solution to the covering problem given and let OPT0 def= 1T x] ∈ [OPT, 2OPT]. Without loss of generality, assume OPT0 ≥ 2. We now introduce the smoothed objective fµ(x) we are going to minimize in order to solve covering LP. Symmetric to the case in the packing solver, this smoothed objective fµ(x) turns each row of the LP constraint Ax ≥ 1 into an exponential penalty function. Definition 4.3. Letting µ def= 4 log(nm/ε) , we define the smoothed objective fµ(x) as ε (1−(Ax)j ) + 1T x . 1µ fµ(x) def= µPm j=1 e We present some properties about fµ(x). They together imply that the minimum of fµ(x) is around OPT, and if one approximately finds the minimum of fµ(x) up to an additive error O(εOPT), this corresponds to a (1 + O(ε))-approximate solution to the covering LP (4.1). The proofs are analogous to Section 2, and included in Appendix B for completeness' sake. Proposition 4.5. (a) fµ(u∗) ≤ (1 + ε)OPT for u∗ def= (1 + ε/2)x∗. (b) fµ(x) ≥ (1 − ε)OPT for every x ≥ 0. 11If minj∈[m]{kAj:k∞} = 0 then the covering LP is infeasible so we are done. Otherwise, if minj∈[m]{kAj:k∞} = v > 0 we scale all entries of A by 1/v, and scale OPT by v. 14 (1−(Ax)j ). 1µ Fact 4.4. ∇fµ(x) = 1 − AT p(x) and ∇2fµ(x) = 1 µ AT diag{p(x)}A, where pj(x) def= e (c) For any x ≥ 0 satisfying fµ(x) ≤ 2OPT, we must have Ax ≥ (1 − ε)1. (d) If x ≥ 0 satisfies fµ(x) ≤ (1 + δ)OPT for some δ ∈ [0, 1], then 1 solution to the covering LP. 1−ε x is a 1+δ 1−ε -approximate 5 Our Covering LP Solver in the Well-Conditioned Case Recall in packing LPs, since it satisfies 0 ≤ x∗i ≤ a bounding box ∆box. Unfortunately, it no longer satisfies x∗i ≤ cannot directly turn PacLPSolver into its symmetric version to solve covering LP. (see Fact 2.1), we can minimize fµ over in covering LPs, so one kA:ik∞ kA:ik∞ 1 1 In this section, we show that this symmetric covering LP solver still solves all well-behaved covering LP instances. Specifically, we say the covering LP is well-behaved if:12 Assumption 5.1. There exists some optimal covering LP solution x∗ satisfying x∗i ≤ 9 the initial point x] satisfies x] . kA:ik∞ i ≤ 9 kA:ik∞ ; and For instance, well-behaved instances naturally arise from those where the constraints Ax ≥ 1 are non-redundant. If the optimal covering LP solution x∗ and the initial point x] satisfy 1 ≤ Ax∗ ≤ 9·1 and 1 ≤ Ax] ≤ 9 · 1, then Assumption 5.1 is satisfied. Well-behaved covering LP problems immediately satisfy the following: e 10 −ε/2 µ + 2OPT ≤ def= {x ∈ Rn : xi ∈ (cid:2)0, kA:ik∞(cid:3)}. Under Assumption 5.1, we have u∗ def= Fact 5.2. Define ∆box (1 + ε/2)x∗ ∈ ∆box and xstart def= (1 + ε/2) · x] ∈ ∆box. Also, it satisfies fµ(xstart) ≤ 3OPT. Proof. The claims u∗, xstart ∈ ∆box are trivial after noticing ε ≤ 1/30. Using the fact that Axstart − 1 ≥ (1 + ε/2)Ax] − 1 ≥ ε/2 · 1, we compute fµ(xstart) as follows: fµ(xstart) = µXj (1−(Axstart)j ) + 1T xstart ≤ µXj µm (nm)2 + 2OPT < 3OPT . (cid:3) We now describe CovLPSolverwb (which is a symmetric variant of PacLPSolver) that solves well-behaved covering LP problems, see Algorithm 2. It starts with the initial vector x0 = y0 = xstart and z0 = 0. Then, CovLPSolverwb is divided into T iterations. In each iteration k, it computes a weighted midpoint xk ← τ zk−1 + (1 − τ )yk−1 for some parameter τ ∈ (0, 1), and then proceeds to compute yk and zk as follows. k = (0, . . . , 0,−Tp(v), 0, . . . , 0) be the vector that is only non-zero at coordinate i, where v = −∇ifµ(xk) ∈ [−1,∞), and recall Tp(v) def= min{v, 1}. We refer to ξ(i) k , zi(cid:9) for k as the truncated gradient. Next, • Perform a mirror (descent) step zk ← z(i) some parameter αk (cid:28) 1/n to be chosen later. • Perform a gradient (descent) step yk ← y(i) We select i ∈ [n] uniformly at random. Let ξ(i) def= arg minz∈∆box(cid:8) 1 A + hnαkξ(i) 2kz − zk−1k2 k − zk−1). This finishes the description of CovLPSolverwb. It is not surprising to deduce the following theorem similar to Theorem 3.4. We include its proof in Appendix C for completeness. nαkL (z(i) def= xk + 1 1µ e k k 12The constant 9 in this section can be replaced with any other constant greater than 1. 15 ε µ , τ ← 1 4 log(nm/ε) , L ← 4 21·nL and α0 ← 1 nL . ). , xstart ∈ ∆box, ε ∈ (0, 1/30]. Algorithm 2 CovLPSolverwb(A, xstart, ε) Input: A ∈ Rm×n ≥0 Output: x ∈ ∆box. 1: µ ← 2: T ← d21nL log(1/ε)e = O(n · log(nm/ε)·log(1/ε) 3: x0 = y0 ← xstart, z0 ← 0. 4: for k ← 1 to T do 1−τ αk−1 αk ← 1 xk ← τ zk−1 + (1 − τ )yk−1. Randomly select i ∈ [n] uniformly at random. Define vector ξ(i) zk ← z(i) yk ← y(i) 10: 11: end for 12: return yT . def= arg minz∈∆box(cid:8) 1 2kz − zk−1k2 k − zk−1). def= xk + 1 nαkL (z(i) 9: k 5: 6: 7: 8: k ε A + hnαkξ(i) k , zi(cid:9). . recall ∆box def= {x ∈ Rn : xi ∈(cid:2)0, 10 kA:ik∞(cid:3)} . parameters . number of iterations k be all-zero except at coordinate i, where ξ(i) k,i = max{−1,∇ifµ(xk))}. . See Proposition 3.2 Theorem 5.3. Under the well-behavior assumption 5.1 in the covering LP problem, CovLPSolverwb(A, xstart, ε) outputs some yT satisfying E[fµ(yT )] ≤ (1 + 4.6ε)OPT . Again, using the same proof as Corollary 3.5, one can apply Markov's bound to turn Theorem 5.3 into a probabilistic statement: Corollary 5.4. Under the well-behavior assumption 5.1 in the covering LP problem, with proba- bility at least 2/3, yT = CovLPSolverwb(A, xstart, ε) satisfies that yT 1−ε is a (1 + O(ε)) approximate solution to covering LP. The expected running time is O(cid:16) log(nm/ε) log(1/ε) ε N(cid:17) . In subsequent work, after the conference presen- Removing the well-behavior assumption. tation of this paper, Wang, Mahoney and Rao [35] showed the following theorem. Theorem 5.5 (Wang et al. [35]). Any covering LP with constraint matrix A ∈ Rm×n ≥0 can be converted into an equivalent but well-behaved covering LP with matrix eA ∈ Rm×n·O(log(mn/ε)) and sparsity N · O(log(mn/ε)). The conversion takes time N · O(log(mn/ε)). As a result, we can apply our covering solver CovLPSolverwb to this modified LP and apply of sparsity N our Theorem 5.3 to solve any covering LP in expected time O( log2(nm/ε) log(1/ε) N ). ε 6 Our Covering LP Solver in the General Case In this section, we remove the well-behavior assumption and propose a different algorithm CovLPSolver to solve all covering LP instances. This algorithm introduces a factor 1/√ε loss in the running time, but is a direct covering LP solver without using any reduction. The main difference to PacLPSolver and CovLPSolverwb is that, this time we abandon the box 16 , xstart ∈ ∆simplex, ε ∈ (0, 1/30]. ε Algorithm 3 CovLPSolver(A, xstart, ε) Input: A ∈ Rm×n ≥0 Output: x ∈ ∆simplex. 1: µ ← 2: T ← d 1 3: α0 ← (1 − τ )T 4: x0 = y0 = z0 ← xstart. 5: for k ← 1 to T do 1−τ αk−1. 4 log(nm/ε) , β ← √ε, τ ← µβ 12n . τ log(1/ε)e = O( log(nm/ε) log(1/ε) ε1.5 12nβ and γ ← ε 6β . 6: ε n). . parameters . so that αT = ε . number of iterations 12nβ and γ = 2αT n 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: k to be all-zero except at coordinate i, where ξ(i) def= arg minz∈∆simplex(cid:8)Vzk−1(z) + h(1 + γ)nαkξ(i) αk ← 1 xk ← τ zk−1 + (1 − τ )yk−1. Randomly select i uniformly at random from [n]. Define vector ξ(i) k k , zi(cid:9). zk ← z(i) if ∇ifµ(xk) < −β then Pick j∗ ∈ [m] such that(cid:26) Pj<j∗ Aπ(j),i · pπ(j)(xk) < 1 + β Pj≤j∗ Aπ(j),i · pπ(j)(xk) ≥ 1 + β yk ← y(i) yk ← y(i) def= xk + δ · ei where δ = µβ def= xk. 2Aπ(j∗),i else Denote by π the permutation that satisfies Aπ(1),i ≤ ··· ≤ Aπ(m),i. k k . end if 17: 18: end for 19: return yT . k,i = max{−β,∇ifµ(xk)}. . See Proposition 6.4 . j∗ ∈ [m] always exists, see (6.1) x ∈ ∆simplex def= {x ∈ Rn : xi ≥ 0 ∧ 1T x ≤ 2OPT0} . Again, this constraint 1T x ≤ 2OPT0 is redundant just like the old ∆box constraint for packing LP (recall Remark 2.5); however, it shall be used to make sure that our updates are always inside ∆simplex. It is a simple fact that Fact 6.1. u∗ def= (1 + ε/2)x∗ ∈ ∆simplex. Recall that the initial vector x] is defined in Definition 4.2, and OPT0 is a crude approximation to OPT, satisfying OPT0 def= 1T x] ∈ [OPT, 2OPT]. We choose different starting vector xstart from Section 5: Proposition 6.2. Letting xstart def= (1+ε/2)·x]+( 1 4OPT. Proof. Using Axstart − 1 ≥ (1 + ε/2)Ax] − 1 ≥ ε/2 · 1, we compute fµ(xstart) as follows: fµ(xstart) = µXj Also, we have 1T xstart ≤ (1 + ε/2)OPT0 + 1 ≤ 2OPT0. (Recall OPT0 ≥ 2 in Definition 4.2.) µm (nm)2 + 3OPT < 4OPT . (cid:3) Our proposed algorithm CovLPSolver starts with the initial vector x0 = y0 = z0 = xstart (1−(Axstart)j ) + 1T xstart ≤ µXj n ), we have xstart ∈ ∆simplex and fµ(xstart) ≤ −ε/2 µ + 2OPT + 1 ≤ n , . . . , 1 1µ e e 17 constraint and study the minimization of fµ(x) over a simplex We select i ∈ [n] uniformly at random, and let ξ(i) and is divided into T iterations. In each iteration k, as usual, it computes a weighted midpoint xk ← τ zk−1 + (1 − τ )yk−1 for some parameter τ ∈ (0, 1), and then computes yk and zk as follows. k = (0, . . . , 0, Tc(v), 0, . . . , 0) be the vector that is only non-zero at coordinate i, where v = ∇ifµ(xk) ∈ (−∞, 1] and Tc(v) def= max{−β, v} is the new thresholding function for some parameter β def= √ε. Then, k , zi(cid:9) def= arg minz∈∆simplex(cid:8)Vzk−1(z) + h(1 + γ)nαkξ(i) • Perform a mirror (descent) step zk ← z(i) for some positive parameters γ (cid:28) 1 and αk (cid:28) 1/n, where Vx(y) def=Pn is the so-called Bregman divergence of the generalized entropy function (c.f. [13]). i=1 yi log yi xi + xi − yi k • If ∇ifµ(xk) < −β, perform a gradient (descent) step yk ← y(i) practice, one can line-search over δ, but we choose an explicit δ as follows. k def= xk + δei for some δ > 0. In – Denote by π the permutation that satisfies Aπ(1),i ≤ ··· ≤ Aπ(m),i – Pick j∗ ∈ [m] s.t. (cid:26) Pj<j∗ Aπ(j),i · pπ(j)(xk) < 1 + β Pj≤j∗ Aπ(j),i · pπ(j)(xk) ≥ 1 + β j=1 Aπ(j),i · pπ(j)(xk) =Pm Pm – Set δ = µβ . 2Aπ(j∗),i . Such j∗ exists because j=1 Aji · pj(xk) = 1 − ∇ifµ(xk) ≥ 1 + β . (6.1) This finishes the description of our CovLPSolver. Remark 6.3. We use the superscript (i) on ξ(i) to emphasize that the value depends on the choice of i. We have used generic parameters τ, αk, T in the above description and their precise values are presented in Algorithm 3. k and z(i) k , y(i) k the objective (i.e., fµ(xk) − fµ(y(i) Our update on yk is a "gradient descent step" because we shall prove that it strictly decreases k ) ≥ 0). Our update on zk is a "mirror descent step" because we shall apply standard mirror descent analysis [13] to it. We explicitly describe how to implement this mirror step: (proved in Appendix D) Proposition 6.4. If zk−1 ∈ ∆simplex and zk−1 > 0, the minimizer z = arg minz∈∆simplex(cid:8)Vzk−1(z) + hδei, zi(cid:9) for any scalar δ ∈ R and basis vector ei can be computed as follows: 1. z ← zk−1. 2. zi ← zi · e−δ. 3. If 1T z > 2OPT0, z ← 2OPT0 1T z z. 4. Return z. We also point out that Lemma 6.5. Each iteration of CovLPSolver can be implemented to run in expected O(N/n) time. The total expected running time is O(T N/n). The proof of Lemma 6.5 is analogous to its packing counterpart, and included in Section F. 6.1 Main Proof Ideas and Ingredients In CovLPSolver, we pick a random coordinate i ∈ [n] at each iteration, and decompose ∇if (xk) = ξ + η, where η ∈ (−∞, 0] is the (negative) large gradient component and ξ ∈ [−√ε, 1] is the 18 truncated gradient component. In other words, we truncate the gradient ∇if (xk) at a negative threshold −β = −√ε, rather than at −1 as in CovLPSolverwb. The reason for this new threshold −√ε can be understood as follows. In PacLPSolver (and symmetrically in CovLPSolverwb), we used Lemma 3.10 to show that our gradient descent step yk decreases the objective by an amount that both includes the ξ and η components. Unfortunately, for covering LP, this decrease amount is only proportional to η but not to ξ (compare Lemma 3.10 with Lemma 6.14 later). This forces us to treat the small gradient ξ separately using mirror descent, but not gradient descent. If ξ were in [−1, 1], classical theory of mirror descent [13] (or multiplicative weight update [8]) would imply that the mirror step zk converges at a rate ∝ ε−2. This is too slow. Instead, since truncated ξ into a smaller interval [−√ε, 1], using a negative-width technique (see Section 6.5), we improve this mirror-descent convergence rate from ε−2 to ε−1.5. On the other hand, due to this truncation at −√ε instead of −1, our gradient step on yk also converges slower, at a rate 1/ε1.5 instead of 1/ε. This is why β = √ε is the best truncation threshold, as it balances gradient and mirror descent. Another ingredient behind our proof is a new distance bound that is uncommon in first-order analysis. Recall that, given convex function g(x), traditional analysis applies convexity argument If g(x) = e−x is g(x) − g(x∗) ≤ h∇g(x), x − x∗i to bound the objective distance to optimum. univariate, x = −1, and x∗ = −100, this bound becomes e−1 ≈ e−1 − e−100 ≤ e−1 · 99, which is very loose. In our analysis, we replace this convexity argument with a more benign bound, specifically designed for covering LP (see Lemma 6.10). 6.2 Convergence Statement The main convergence theorem of this section is as follows: Theorem 6.6. CovLPSolver(A, xstart, ε) outputs some yT satisfying E[fµ(yT )] ≤ (1 + 9ε)OPT . Again, using the same proof as Corollary 3.5, one can apply Markov's bound to turn Theorem 5.3 into a probabilistic statement: yT Corollary 6.7. With probability at least 2/3, yT = CovLPSolver(A, xstart, ε) satisfies that 1−ε is a (1 + O(ε)) approximate solution to the covering LP program. The expected running time is O( log(nm/ε) log(1/ε) N ). ε1.5 Before delving into the proof of Theorem 6.6, we make the following observations: Fact 6.8. For every k ∈ {0, 1, . . . , T}, it satisfies xk, yk ≥ 0, zk > 0, and zk ∈ ∆simplex . Proof. Since the xstart satisfies 1T xstart ≤ 2OPT0 by Proposition 6.2, we have z0 = xstart ∈ ∆simplex. Also, the mirror descent step (see Proposition 6.4) ensures zk,i > 0 for all rounds k and coordinates i, as well as zk ∈ ∆simplex for all rounds k. However, we xk and yk may not necessarily lie inside (cid:3) ∆simplex, but will always stay non-negative. We prove Theorem 6.6 in the subsequent subsections. 6.3 Step 1: Distance Adjustment Using convexity, one can obtain fµ(xk) − fµ(u) ≤ h∇fµ(xk), xk − ui for every u ∈ ∆simplex. (6.2) 19 Note that inequality (6.2) can be very loose for exponential functions. For instance, if fµ(x) were as simple as ex, then the convexity inequality eb − ea ≤ eb · (b − a) says • when b = 2 and a = −10, we have e2 − e−10 ≤ 12e2; • when b = 2 and a = −100, we have e2 − e−100 ≤ 102e2. In this section, we strengthen (6.2) in the special case of u = u∗ def= (1 + ε/2)x∗. For analysis Although e−100 ≈ e−10, the two upper bounds are off from each other by a factor of 10. purpose, let eA be the adjusted matrix of A described as follows. Definition 6.9 (adjusted matrix eA). For each row j ∈ [m], if (Au∗)j ≤ 2 then we keep it and let def= Aj:. Otherwise, -that is, if (Au∗)j > 2- we define eAj: e Aj: row Aj:, but scaled down by a factor of (Au∗)j · Aj: to be the same j-th . It is clear from this definition that def= 2 (Au∗)j 2 Lemma 6.10 (distance adjustment). and Aji ≥ eAji for all (i, j) ∈ [n] × [m] (1 + ε)1 ≤ eAu∗ ≤ 21. fµ(xk) − fµ(u∗) ≤ h1 − AT p(xk), xk − u∗i + heAT p(xk) − AT p(xk), u∗i + εOPT = h∇fµ(xk), xk − u∗i + heAT p(xk) − AT p(xk), u∗i + εOPT At high level, ignoring the negligible term εOPT, Lemma 6.10 strengthens the classical bound due to the extra term of heAT p(xk) − AT p(xk), u∗i. This extra term is always non-positive since e A ≤ A coordinate-wise, but may be very negative in certain cases. Proof of Lemma 6.10. pj(xk) ·(cid:0)(eAu∗)j − (Au∗)j(cid:1) + εOPT m j=1 j=1 m (1−(Au∗)j )(cid:17) + h1, xk − u∗i j=1(cid:16)e X (1−(Axk)j ) − e (1−(eAu∗)j )(cid:17) + h1, xk − u∗i + µ · m · e−1/µ (1−(Axk)j ) − e fµ(xk) − fµ(u∗) = µ j=1(cid:16)e X X (1−(Axk)j ) ·(cid:0)(eAu∗)j − (Axk)j(cid:1) + h1, xk − u∗i + εOPT X pj(xk) ·(cid:0)(eAu∗)j − (Axk)j(cid:1) + h1, xk − u∗i + εOPT X X pj(xk) ·(cid:0)(Au∗)j − (Axk)j(cid:1) + h1, xk − u∗i + = h−AT p(xk), xk − u∗i + h1, xk − u∗i + heAT p(xk) − AT p(xk), u∗i + εOPT . j=1 m y≤ x≤ j=1 = = µ m 1µ e m 1µ m 1µ 1µ 1µ (1−(Au∗)j ) ≤ −e Above, x is because if (Au∗)j 6= (eAu∗)j for some j, then it must satisfy that (eAu∗)j = 2, and (1−(eAu∗)j ) + e−1/µ. y uses the convexity inequality of eb − ea ≤ therefore −e (cid:3) eb · (b − a), and the fact that µme−1/µ (cid:28) εOPT. 6.4 Step 2: Gradient Truncation For analysis purpose, let us separate the indices i ∈ [n] into large and small ones. Definition 6.11. We make the following definitions. 1µ 1µ 20 def= {i ∈ [n] : ∇ifµ(xk) < −β} and [n] \ Bk be the set of large and small indices. • Let Bk • Let ξk ∈ [−β, 1]n be the truncated gradient so that ξk,i = Tc(∇ifµ(xk)) for each i ∈ [n]. • Let ηk ∈ (−∞, 0]n be the large gradient so that ∇fµ(xk) = ξk + ηk. It is clear that ηk,i = 0 for every i 6∈ B, and ηk,i = (1 + β) − (AT p(xk))i for every i ∈ B. ηk,i = 0 for every i 6∈ B, and eηk,i = (1 + β) − (eAT p(xk))i for every i ∈ B. e k = (0, . . . ,eηk,i, . . . , 0). We emphasize that η(i) k = (0, . . . , ξk,i, . . . , 0) and eη(i) 6=eηk, and ξ(i) • Let eηk ∈ (−∞,∞)n be the adjusted large gradient so that k = (0, . . . , 0, ηk,i, 0, . . . , 0), the vector that is zero at all coordinates other than i, 6= ηk, The following key lemma is very analogous to (3.1) in the packing LP analysis. We denote by η(i) and similarly ξ(i) η(i) k 6= ξk. e k k τ (1 − τ ) Lemma 6.12 (distance upper bound). fµ(xk) − fµ(u∗) ≤ (fµ(yk−1) − fµ(xk)) + Eihhnξ(i) instead of eη(i) (3.1). The reason we can have the stronger term eη(i) Note that if one uses η(i) k Lemma 6.10. k k , zk−1 − u∗ii + Eihhneη(i) k ,−u∗ii + εOPT . k , then Lemma 6.12 becomes trivial to prove just like is precisely due to the distance adjustment (1 − τ ) (1 − τ ) (1 − τ ) (1 − τ ) (1 − τ ) (1 − τ ) h∇fµ(xk), yk−1 − xki + h∇fµ(xk), zk−1 − u∗i + heAT p(xk) − AT p(xk), u∗i (fµ(yk−1) − fµ(xk)) + h∇fµ(xk), zk−1 − u∗i + heAT p(xk) − AT p(xk), u∗i (fµ(yk−1) − fµ(xk)) + hξk + ηk, zk−1 − u∗i + heAT p(xk) − AT p(xk), u∗i (fµ(yk−1) − fµ(xk)) + hξk, zk−1 − u∗i + heAT p(xk) − AT p(xk) − ηk, u∗i (fµ(yk−1) − fµ(xk)) + hξk, zk−1 − u∗i + h−eηk, u∗i (fµ(yk−1) − fµ(xk)) + Eihhnξ(i) k , zk−1 − u∗i + h−neη(i) (eAT p(xk) − AT p(xk))i − ηk,i ≤ 0 − 0 = −eηk,i; for every i ∈ Bk, we have (eAT p(xk) − AT p(xk))i − ηk,i = (eAT p(xk) − AT p(xk))i −(cid:0)(1 + β) − (AT p(xk))i(cid:1) where the two equalities follow from the definitions of ηk,i and eηk,i. Above, x is due to Lemma 6.10. y is because xk = τ zk−1 + (1 − τ )yk−1, which implies that τ (xk − zk−1) = (1 − τ )(yk−1 − xk). z is by the convexity of fµ(·). { is because hηk, zk−1i ≤ 0, since ηk ≤ 0 while zk−1 ≥ 0. needs some careful justification: for every i 6∈ Bk, we have = −(cid:0)(1 + β) − (eAT p(xk))i(cid:1) = −eηk,i , k , u∗ii . (cid:3) z≤ ≤ {≤ = = τ τ τ 21 τ τ τ (cid:0)fµ(xk) − fµ(u∗)(cid:1) − εOPT h∇fµ(xk), xk − u∗i + heAT p(xk) − AT p(xk), u∗i = h∇fµ(xk), xk − zk−1i + h∇fµ(xk), zk−1 − u∗i + heAT p(xk) − AT p(xk), u∗i x≤ y= Proof of Lemma 6.12. We derive the following sequence of inequalities: 6.5 Step 3: Mirror Descent Guarantee Our update z(i) k descent step [13]. We begin by explaining an attempt that is too weak for obtaining the ε−1.5 convergence rate. def= arg minz∈∆simplex(cid:8)Vzk−1(z) + h(1 + γ)nαkξ(i) k , zi(cid:9) is, by its definition, a mirror Using the classical theory, it is not hard to repeat the proof of Lemma 3.7 -although changing A to Vx(y)- and obtain that, as long as ξk,i is in [−1, +1] for each the distance function from k · k2 coordinate i, for every u ∈ ∆simplex, Ei(cid:2)αk(cid:10)nξ(i) k , zk−1 − u(cid:11)(cid:3) ≤ Vzk−1(u) − EihV z(i) k (u)i + O(α2 kn)OPT . This inequality only yields a slower ε−2 convergence rate, and ±1 is also know as the width parameter from the multiplicative-weight-update language [8]. In our lemma below, we make use of the fact ξk,i is in [−β, +1] ⊆ [−1, +1]. In essence, this kβn) factor. We call it the negative-width kn) factor with a better O(α2 allows us to replace the O(α2 technique.13 Formally, Lemma 6.13 (mirror descent). Denoting by γ def= 2αT n, we have Ei(cid:2)αk(cid:10)nξ(i) k , zk−1 − u∗(cid:11)(cid:3) ≤ Vzk−1(cid:0) u∗ 1 + γ(cid:1) − EihV z(i) 1 + γ(cid:1)i + 12OPT · γαkβ . k (cid:0) u∗ The proof is somewhat technical and included in Appendix D. 6.6 Step 4: Gradient Descent Guarantee We show our gradient step never increases the objective for all choices of i. In addition, it decreases the objective by an amount proportional to the adjusted large gradient eη(i) Lemma 6.14 (gradient descent). For every i ∈ [n], we have (a) fµ(xk) − fµ(y(i) (b) fµ(xk) − fµ(y(i) k ) ≥ 0, and k ) ≥ µβ k , u∗i . k . 12 · h−eη(i) The proof of Lemma 6.14 is quite technical and can be found in Appendix D. At high level, one would hope to prove that the gradient step decreases the objective by an amount proportional to the large gradient η(i) k . If that were true, the entire proof structure of our covering LP convergence would become much closer to that of packing LP, and there would be absolutely no need for the introduction of the distance k , rather than the adjusted large gradienteη(i) adjustment in Section 6.3, as well as the definitions of eA and eη. Unfortunately, if one replaces eη with η in the above lemma, the inequality is false. The reason behind it is very similar to what we have summarized in Section 6.3, and related to the fact that the exponential penalty function is not Lipschitz smooth. 6.7 Step 5: Putting All Together Combining Lemma 6.12, Lemma 6.13, and Lemma 6.14, we obtain that αk(cid:0)fµ(xk) − fµ(u∗)(cid:1) − αkεOPT 13This negative width technique is related to [8, Definition 3.2], where the authors analyze the multiplicative weight update method in a special case when the oracle returns loss values only in [−', +ρ], for some ' (cid:28) ρ. This technique is also a sub-case of a more general theory of mirror descent, known as the local-norm convergence, that we have summarized in a separate and later paper [4]. 22 (1 − τ )αk (1 − τ )αk τ τ ≤ ≤ (fµ(yk−1) − fµ(xk)) + Eihαkhnξ(i) (fµ(yk−1) − fµ(xk)) + Vzk−1(cid:0) u∗ k , zk−1 − u∗ii + Eihαkhneη(i) k ,−u∗ii 1 + γ(cid:1) − EihV 1 + γ(cid:1)i k (cid:0) u∗ + 12OPT · γαkβ + Eih 12αkn k )(cid:1)i µβ (cid:0)fµ(xk) − fµ(y(i) z(i) Remark 6.15. Above, the quantity "12OPT · γαkβ" is the loss term introduced by the mirror descent. Unlike the packing LP case -see (3.2)- this loss term is not dominated by the gradient step. (If one could do so, this would give CovLPSolver an ε−1 convergence rate.) The quantity "αkhnξ(i) is dominated by our gradient step progress owing to Lemma 6.14. This is similar to the packing LP case -see Lemma 3.10. k , zk−1−u∗i" is the loss introduced by the (adjusted) large gradienteη, and Using the choice αk = αk−1 1−τ and telescoping the above inequality for k = 1, . . . , T , we have From here, let us use the special choice of τ = µβ 12n . We obtain that − αk(cid:0)fµ(u∗) + εOPT(cid:1) (1 − τ )αk ≤ 12γαkβOPT + τ τ 1 + γ(cid:1) − Eih αk fµ(yk−1) + Vzk−1(cid:0) u∗ αk(cid:1) · 12γβOPT + k=0 (1 − τ )k = αT · 1−(1−τ )T α0 τ α0 τ τ −(cid:0) TXk=1 We compute thatPT E(cid:2)fµ(yT )(cid:3) ≤ αk(cid:1)(cid:0)fµ(u∗) + εOPT(cid:1) ≤(cid:0) TXk=1 k=1 αk = αT ·PT−1 τ (cid:0)fµ(u∗) + εOPT(cid:1) + Therefore, we rearrange and get αT τ αT fµ(y(i) k ) + V z(i) 1 + γ(cid:1)i . k (cid:0) u∗ E(cid:2)fµ(yT )(cid:3) . αT τ fµ(y0) + Vz0(cid:0) u∗ 1 + γ(cid:1) − < αT τ , and recall that γ = 2αT n. ≤ (1 + 9ε)OPT . (cid:3) u∗i log(u∗i · n) + 4OPT (2 log(nm) + 4) · OPT . y≤ i T u∗i τ α αT τ · 12γβOPT + fµ(y0) + Vz0(cid:0) u∗ 1 + γ(cid:1) , Vz0(cid:0) u∗ 1 + γ(cid:1) . Proposition 6.2), which implies that fµ(y0) ≤ 4OPT and 1T xstart ≤ 4OPT. We also have =⇒ E(cid:2)fµ(yT )(cid:3) ≤ fµ(u∗) + εOPT + 24αT nβOPT + (1 − τ )T fµ(y0) + Vz0(cid:0) u∗ 1 + γ(cid:1) = Vxstart(cid:0) u∗ 1 + γ(cid:1) = (1 + γ)xstart From this point, we need to use our special choice of the initial point x0 = y0 = z0 = xstart (see u∗i 1 + γ u∗i 1 + γ i − + xstart (6.3) log n i Above, inequality x follows because xstart ≥ 1/n for all i ∈ [n] according to the definition in Proposition 6.2; inequality y follows because each u∗i ≤ (1 + ε/2)x∗i ≤ (1 + ε/2)OPT ≤ (1 + ε/2)m and 1T u∗i = (1 + ε/2)OPT, as well as the fact that ε is sufficiently small. 12nβ . Substituting into (6.3) all of these parameters, along with the aforementioned inequalities fµ(y0) ≤ 4OPT and that Finally, we choose β = √ε, T = d 1 1+γ(cid:1) ≤ (2 log(nm) + 4)· OPT, as well as fµ(u∗) ≤ (1 + ε)OPT from Proposition 4.5.a, we obtain Vz0(cid:0) u∗ E(cid:2)fµ(yT )(cid:3) ≤ (1 + ε)OPT + εOPT + 2εOPT + εfµ(y0) + τ log(1/ε)e, and α0 such that αT = ε (2 log(nm) + 4)OPT µβ/12n ε/12nβ i=1 X X i=1 n x≤ This finishes the proof of Theorem 6.6. 23 Acknowledgements We would like to thank Jon Kelner, Neal Young and the anonymous reviewers for discussing this paper. Appendix A Proof of Lemma 3.6 k = 1 and γl at each iteration k ≥ 1, Lemma 3.6. We have xk, yk, zk ∈ ∆box for all k = 0, 1, . . . , T . Proof. This is true at the beginning as x0 = y0 = xstart ∈ ∆box (see Fact 2.8) and z0 = 0 ∈ ∆box. In fact, it suffices for us to show that for every k ≥ 1, yk =Pk k satisfying Pl γl k ≥ 0 for each l = 0, . . . , k. If this is true, we can prove the lemma by induction: 3. yk is also in ∆box because yk = Pk For the rest of the proof, we show that yk =Pk 1. xk = τ zk−1 + (1 − τ )yk−1 must be in ∆box because yk−1 and zk−1 are and τ ∈ [0, 1], 2. zk is in ∆box by the definition that zk = arg minz∈∆box{···}, and kzl is a convex combination of the zl's and ∆box is kzl for some scalars γl convex. l=0 γl l=0 γl l=0 γl 1 (1 − τ )γl k−1, (cid:0) nαk−1L − 1 nαkL , 1 nαkL(cid:1) + τ(cid:0)1 − 1 kzl for every k ≥ 1 with coefficients14 nαk−1L(cid:1), nα1L (z1 − z0) = 1 l = 0, . . . , k − 2; l = k − 1; l = k. nα1L z1 +(cid:0)1 − 1 nα1L(cid:1)z0. For γl k = 1 This is true at the base case k = 1 because y1 = x1 + 1 the general k ≥ 2, we have yk = xk + nαkL (zk − zk−1) = τ zk−1 + (1 − τ )yk−1 + 1 nαkL (zk − zk−1) γl k−1zl + = τ zk−1 + (1 − τ )(cid:16) k−2Xl=0 =(cid:16) k−2Xl=0 (1 − τ )γl k−1zl(cid:17) +(cid:18)(cid:16) 1 nαk−1L 1 1 nαkL zk−1(cid:17) + nαkL(cid:17) + τ(cid:16)1 − 1 nαk−1L − kzl as desired. (zk − zk−1) 1 nαk−1L(cid:17)(cid:19)zk−1 + 1 nαkL zk . It is now easy to check that under our definition of αk (which satisfies αk ≥ αk−1 and αk ≥ l=0 γl α0 = 1 nL , we must have γl Therefore, we obtain yk =Pk k−1 +(cid:18)(cid:16) X nαk−1L − nαk−1L(cid:17) +(cid:18)(cid:16) k−2Xl=0 (1 − τ )γl = (1 − τ )(cid:16)1 − γl k = 1 1 l k ≥ 0 for all k and l. Also, 1 nαk−1L(cid:17)(cid:19) + 1 nαkL(cid:17) + τ(cid:16)1 − nαk−1L − nαkL(cid:17) + τ(cid:16)1 − 1 1 1 nαk−1L(cid:17)(cid:19) + 1 nαkL = 1 . (cid:3) 14We wish to point out that this proof coincides with a lemma from the accelerated coordinate descent theory of Fercoq and Richt´arik [18]. Their paper is about optimizing an objective function that is Lipschitz smooth, and thus irrelevant to our work. nαkL 1 24 B Proof of Proposition 4.5 Proposition 4.5. (a) fµ(u∗) ≤ (1 + ε)OPT for u∗ def= (1 + ε/2)x∗. (b) fµ(x) ≥ (1 − ε)OPT for every x ≥ 0. (c) For any x ≥ 0 satisfying fµ(x) ≤ 2OPT, we must have Ax ≥ (1 − ε)1. (d) If x ≥ 0 satisfies fµ(x) ≤ (1 + δ)OPT for some δ ∈ [0, 1], then 1 solution to the covering LP. 1−ε x is a 1+δ 1−ε -approximate Proof. µm (nm)2 + (1 + ε/2)OPT ≤ (1 + ε)OPT . ≤ (a) We have 1T u∗ = (1 + ε/2)OPT by the definition of OPT. Also, from the feasibility constraint Ax∗ ≥ 1 in the covering LP, we have Au∗ − 1 ≥ ε/2 · 1, and can compute fµ(u∗) as follows: −ε/2 e µ + (1 + ε/2)OPT (1−(Au∗)j ) + 1T u∗ ≤ µXj 1µ e fµ(u∗) = µXj (b) Suppose towards contradiction that fµ(x) < (1 − ε)OPT. Since fµ(x) < OPT ≤ m, we must (1−(Ax)j ) ≤ fµ(x)/µ ≤ m/µ. This further implies have that for every j ∈ [m], it satisfies that e (Ax)j ≥ 1− ε by the definition of µ. In other words, Ax ≥ (1− ε)1. By the definition of OPT, we must then have 1T x ≥ (1 − ε)OPT, finishing the proof that fµ(x) ≥ 1T x ≥ (1 − ε)OPT, giving a contradiction. 1µ (c) To show Ax ≥ (1 − ε)1, we can assume that v = maxj(1 − (Ax)j) > ε because otherwise we are done. Under this definition, we have ε 4 log(nm/ε) ( nm ε )4 (cid:29) 2OPT , = µ(cid:0)( nm ε )4(cid:1)v/ε ≥ vµ fµ(x) ≥ µe contradicting to our assumption that fµ(x) ≤ 2OPT. Therefore, we must have v ≤ ε, that is, Ax ≥ (1 − ε)1. (d) For any x satisfying fµ(x) ≤ (1 + θ)OPT ≤ 2OPT, owing to Proposition 4.5.c, we first have that x is approximately feasible, i.e., Ax ≥ (1−ε)1. Next, because 1T x ≤ fµ(x) ≤ (1+θ)OPT, we know that x yields an objective 1T x ≤ (1 + θ)OPT. Letting x0 = 1 1−ε x, we both have that (cid:3) x0 is feasible (i.e., Ax0 ≥ 1), and x0 has an objective 1T x0 at most 1+δ 1−ε OPT. C Missing Proofs for Section 5 In this section we prove Theorem 5.3. Because the proof structure is almost identical to that of Theorem 3.4, we spend most of the discussions only pointing out the difference rather than repeating the proofs. The following three lemmas are completely identical to the ones in the packing LP case, so we restate them below: Lemma C.1 (cf. Lemma 3.3). Each iteration of CovLPSolverwb can be implemented to run in expected O(N/n) time. Lemma C.2 (cf. Lemma 3.6). We have xk, yk, zk ∈ ∆box for all k = 0, 1, . . . , T . Lemma C.3 (cf. Lemma 3.7). For every u ∈ ∆box, it satisfies (cid:10)nαkξ(i) (cid:10)ξ(i) k , xk − y(i) k (cid:11) + 1 2kzk−1 − uk2 k − uk2 A . A − 1 2kz(i) k , zk−1 − u(cid:11) ≤ n2α2 kL · 25 For the gradient descent guarantee of Section 3.3, one can first note that Lemma 2.7 remains true: this can be verified by replacing ∇ifµ(x) + 1 in its proof with 1 − ∇ifµ(x). For this reason, Lemma 3.9 (which is built on Lemma 2.7) also remains true. We state it below: Lemma C.4 (cf. Lemma 3.9). We have fµ(xk) − fµ(y(i) Putting All Together. Denote by η(i) and satisfies η(i) k ∈ Rn k,i = ∇ifµ(xk) − ξ(i) k,i ∈ (−∞, 0]. In other words, the full gradient k + nξ(i) k ] ∇fµ(xk) = Ei[(0, . . . , n∇ifµ(xk), . . . , 0)] = Ei[nη(i) k ) ≥ 1 2h∇fµ(xk), xk − y(i) k i ≥ 0. ≤0 the vector that is only non-zero at coordinate i, can be (in expectation) decomposed into the a large but non-positive component η(i) and a small component ξ(i) convexity argument and the mirror descent lemma to compute that k ∈ (−∞, 0]n k ∈ [−1, 1]n. Similar as Section 3.4, for any u ∈ ∆box, we can use a basic (C.1) Ai (C.2) k , zk−1 − u(cid:11)i kz(i) k − uk2 A − 1 2 1 2 αk(fµ(xk) − fµ(u)) ≤(cid:10)αk∇fµ(xk), xk − u(cid:11) =(cid:10)αk∇fµ(xk), xk − zk−1(cid:11) +(cid:10)αk∇fµ(xk), zk−1 − u(cid:11) =(cid:10)αk∇fµ(xk), xk − zk−1(cid:11) + Eih(cid:10)nαkη(i) (cid:10)∇fµ(xk), yk−1 − xk(cid:11) + Eih(cid:10)nαkη(i) kL ·(cid:10)ξ(i) k , zk−1 − u(cid:11) + n2α2 + Eih (cid:10)nαkη(i) (1 − τ )αk (1 − τ )αk (fµ(yk−1) − fµ(xk)) k , zk−1 − u(cid:11) +(cid:10)nαkξ(i) k , zk−1 − u(cid:11)i k , zk−1 − u(cid:11) +(cid:10)nαkξ(i) k (cid:11) + k , xk − y(i) kzk−1 − uk2 y≤ x= τ τ Above, x is because xk = τ zk−1 + (1− τ )yk−1, which implies that τ (xk − zk−1) = (1− τ )(yk−1 − xk). y uses convexity and Lemma C.3. We can establish the following lemma to upper bound the boxed term in (C.2). Its proof is in the same spirit to that of Lemma 3.10, and is the only place that we require all vectors to reside in ∆box. Lemma C.5 (cf. Lemma 3.10). For every u ∈ ∆box, k , xk − y(i) k )) . (cid:10)nαkη(i) k , zk−1 − u(cid:11) + n2α2 kL ·(cid:10)ξ(i) k (cid:11) ≤ 21nαkL · (fµ(xk) − fµ(y(i) Proof of Lemma C.5. Now there are three possibilities: k,i = 0, then we must have ξ(i) k , zk−1−u(cid:11)+n2α2 • If η(i) (cid:10)nαkη(i) • If η(i) k,i < 0 and z(i) z(i) k,i = zk−1,i + nαk kA:ik∞ k,i < 10 kA:ik∞ , and accordingly y(i) k,i = ∇ifµ(xk) ∈ [−1, 1]. Lemma C.4 implies kL·(cid:10)ξ(i) k , xk−y(i) (thus z(i) k (cid:11) = n2α2 kL·(cid:10)∇fµ(xk), xk−y(i) k (cid:11) ≤ 2n2α2 k is not on the boundary of ∆box), then we precisely have kL·(fµ(xk)−fµ(y(i) k )) k,i = xk,i + 1 > xk,i. In this case, + n2α2 kL ·(cid:10)ξ(i) (cid:10)nαkη(i) k , zk−1 − u(cid:11) + n2α2 nαk · ∇ifµ(xk) · −10 kA:ik∞ nαk · ∇ifµ(xk) · −10 kA:ik∞ 10nαkL ·(cid:10)∇fµ(xk), xk − y(i) (cid:0)20nαkL + 2n2α2 LkA:ik∞ k (cid:11) k , xk − y(i) k (cid:11) kL ·(cid:10)ξ(i) k , xk − y(i) kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) + n2α2 k (cid:11) kL(cid:1) · (fµ(xk) − fµ(y(i) + n2α2 k )) . x≤ y< z= {≤ 26 Above, x follows from the fact that zk−1, u ∈ ∆box and therefore zk−1,i ≥ 0 and ui ≤ 10 kA:ik∞ by the definition of ∆box, and u ≥ 0; y follows from the fact that xk and y(i) k are only different at coordinate i, and ξ(i) k,i < 0); z follows from the fact that y(i) k = xk + ei k,i = −1 > ∇ifµ(xk) (since η(i) ; and { uses Lemma C.4. kL · (fµ(xk) − fµ(y(i) k,i < 0, together with ∇ifµ(xk) < ξ(i) k )) . k,i and k,i ≥ zk−1,i; z is from our choice of yk k,i and z(i) k ); and { uses Lemma C.4. n2α2 kL ·(cid:10)ξ(i) k (cid:11) k , zk−1 − u(cid:11) + n2α2 (cid:10)nαkη(i) k , xk − y(i) kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) (cid:10)nαkη(i) k (cid:11) + n2α2 k , zk−1 − z(i) k (cid:11) kL ·(cid:10)∇fµ(xk), xk − y(i) (cid:10)nαk∇fµ(xk), zk−1 − z(i) k (cid:11) + n2α2 k (cid:11) + n2α2 kL ·(cid:10)∇fµ(xk), xk − y(i) kL ·(cid:10)∇fµ(xk), xk − y(i) k (cid:11) { ≤ 4n2α2 Above, x is because ui ≤ 10 kA:ik∞ xk,i ≤ y(i) k,i − 1 < η(i) k,i; y uses ∇ifµ(xk) = η(i) which satisfies that zk−1 − z(i) k = nαkL(xk − y(i) kL ·(cid:10)ξ(i) k , zk−1 − u(cid:11) + n2α2 (cid:10)nαkη(i) k , xk − y(i) k,i and η(i) = z(i) y≤ x≤ z= LkA:ik∞ k,i < 0 and z(i) • If η(i) k,i = 10 kA:ik∞ , then we have x∗i < 12OPT . 1 2 1 2 (cid:3) (C.3) 75 21nαT L OPT . k )) + 1 2 k ) + n i=1 1 21nL 1 2 A − (1 − τ )αk k )) . εL ≤ 1 4 . Plugging Lemma C.5 back to (C.2), we have Above, x uses Lemma C.5; and y is because we have chosen τ to satisfy 1 k ) ≥ 0, we conclude that kL) · (fµ(xk) − fµ(y(i) k )) Combining the three cases, and using the fact that fµ(xk) − fµ(y(i) k (cid:11) ≤ (20nαkL + 4n2α2 ≤ 21nαkL · (fµ(xk) − fµ(y(i) Above, the last inequality uses our choice of αk, which implies nαk ≤ nαT = 1 αk(fµ(xk) − fµ(u)) ≤(cid:10)αk∇fµ(xk), xk − u(cid:11) (fµ(yk−1) − fµ(xk)) + Eih21nαkL · (fµ(xk) − fµ(y(i) αkfµ(xk) +(cid:0)21nαkL − αk(cid:1)fµ(yk−1) + Eih − 21nαkL · fµ(y(i) Ai kzk − uk2 Ai . kzk − uk2 Next, recall that we have picked αk so that (21nL − 1)αk = 21nL · αk−1 in CovLPSolverwb. X A ≤ −21nαT L·E[fµ(yT )]+75OPT . Here, the second inequality is due to fµ(y0) = fµ(xstart) ≤ 3OPT from Fact 5.2, and the fact that X X X (x∗i )2·kA:ik∞ ≤ 10(1+ε/2)2 (u∗i )2·kA:ik∞ ≤ (1+ε/2)2 kz0−u∗k2 21nL(cid:1)k = 21nαT L(cid:0)1 − (1 − 1 21nL )T(cid:1), we k=0(cid:0)1 − 1 Finally, using the fact thatPT k=1 αk = αT ·PT−1 E[fµ(yT )] ≤ Pk αk OPT =(cid:0)1 − (1 − αkfµ(u∗) ≤ 21fµ(y0)−21nαT L·E[fµ(yT )]+kz0−u∗k2 Telescoping (C.3) for k = 1, . . . , T and choosing u∗ = (1 + ε/2)x∗, we have kzk−1 − uk2 kzk−1 − uk2 A − )T(cid:1)fµ(u∗) + rearrange and obtain that A = ku∗k2 τ = 21nL. fµ(u∗) + 21nαT L T − k=1 n i=1 n i=1 21nαT L x≤ y≤ A = τ 75 27 We choose T = d21nL log(1/ε)e so that that fµ(u∗) ≤ (1 + ε)OPT (see Proposition 4.5.a), we obtain nαT L = (1 − 1 1 21nL )T ≤ ε. Combining this with the fact Therefore, we have finished proving Theorem 5.3. E[fµ(yT )] ≤ (1 + ε)OPT + 3.6ε · OPT < (1 + 4.6ε)OPT . (cid:3) D Missing Proofs for Section 6 Proposition 6.4. If zk−1 ∈ ∆simplex and zk−1 > 0, the minimizer z = arg minz∈∆simplex(cid:8)Vzk−1(z) + hδei, zi(cid:9) for any scalar δ ∈ R and basis vector ei can be computed as follows: 1. z ← zk−1. 2. zi ← zi · e−δ. 3. If 1T z > 2OPT0, z ← 2OPT0 1T z z. 4. Return z. Proof. Let us denote by z the returned value of the described procedure, and g(u) def= Vzk−1(u) + hδei, ui. Since ∆simplex is a convex body and g(·) is convex, to show z = arg minz∈∆simplex{g(u)}, it suffices for us to prove that for every u ∈ ∆simplex, h∇g(z), u − zi ≥ 0. Since the gradient ∇g(z) can be written explicitly, this is equivalent to δ(ui − zi) +Pn '=1 log z' zk−1,' · (u' − z') ≥ 0 . If the re-scaling in step 3 is not executed, then we have z' = zk−1,' for every ' 6= i, and zi = zk−1,i · e−δ; thus, the left-hand side is zero so the above inequality is true for every u ∈ ∆simplex. Otherwise, we have 1T z = 2OPT0 and there exists some constant Z > 1 such that, z' = zk−1,'/Z for every ' 6= i, and zi = zk−1,i · e−δ/Z. In such a case, the left-hand side equals to It is clear at this moment that since log Z > 0 and 1T u ≤ 2OPT0 = 1T z, the above quantity is (cid:3) always non-negative, finishing the proof. (ui − zi) · (δ − δ) +Pn '=1 − log Z · (u' − z') . Lemma 6.13. Denoting by γ def= 2αT n, we have Ei(cid:2)αk(cid:10)nξ(i) k , zk−1 − u∗(cid:11)(cid:3) ≤ Vzk−1(cid:0) u∗ 1 + γ(cid:1) − EihV z(i) 1 + γ(cid:1)i + 12OPT · γαkβ . k (cid:0) u∗ Proof. Define w(x) def=Pi xi log(xi) − xi and accordingly, Vx(y) = w(y) − h∇w(x), y − xi − w(x) = Pi yi log yi + xi− yi. We first compute using the classical analysis of mirror descent step as follows: xi k (cid:11) k , zk−1 − z(i) . (D.1) k (cid:11) − Vzk−1(z(i) k ) u∗ k − k , z(i) k − k ), z(i) k , zk−1(cid:11) + αk(cid:10)nξ(i) k , zk−1 − u∗(cid:11) 1 + γE + (1 + γ)αk(cid:10)nξ(i) γαk(cid:10)nξ(i) = (1 + γ)αkDnξ(i) k (cid:11) k , zk−1 − z(i) D∇w(zk−1) − ∇w(z(i) 1 + γE + (1 + γ)αk(cid:10)nξ(i) 1 + γ(cid:1) − w(zk−1) −D∇w(zk−1), =(cid:16)w(cid:0) u∗ 1 + γ − zk−1E(cid:17) −(cid:16)w(cid:0) u∗ k E(cid:17) k ) −D∇w(z(i) u∗ 1 + γ(cid:1) − w(z(i) 1 + γ − z(i) +(cid:16)w(zk−1) − w(z(i) k (cid:11)(cid:17) + (1 + γ)αk(cid:10)nξ(i) k ) −(cid:10)∇w(zk−1), zk−1 − z(i) = Vzk−1(cid:0) u∗ k (cid:0) u∗ 1 + γ(cid:1) + (1 + γ)αk(cid:10)nξ(i) 1 + γ(cid:1) − V k , zk−1 − z(i) k (cid:11) k , zk−1 − z(i) k ), x≤ u∗ u∗ z(i) 28 Above, x is because z(i) saying ∀u ∈ ∆simplex, ⇐⇒ ∀u ∈ ∆simplex, In particular, we have 1T u∗ Substituting u = u∗ k = arg minz∈∆simplex(cid:8)Vzk−1(z) + h(1 + γ)αknξ(i) k , u − z(i) k ) − ∇w(zk−1) + (1 + γ)αknξ(i) h∇Vzk−1(z(i) h∇w(z(i) k ) + (1 + γ)αknξ(i) k , zi(cid:9), which is equivalent to k i ≥ 0 k , u − z(i) k i ≥ 0 . < 2OPT ≤ 2OPT0 and therefore u∗ 1+γ = 1T (1+ε/2)x∗ 1+γ ∈ ∆simplex. 1+γ 1+γ into the above inequality we get x. Next, we upper bound the term in the box: k , zk−1i + 2zk−1,i · γαknβ . (D.2) zk−1,i · γαknξk,i }≤ k,i(cid:17) + zk−1,i − z(i) z(i) k,i zk−1,i k,i − zk−1,i2 k,i, zk−1,i} (1 + γ)αknξk,i · (zk−1,i − z(i) (1 + γ)αkhnξ(i) k , zk−1 − z(i) (1 + γ)αknξk,i · (zk−1,i − z(i) k i − Vzk−1(z(i) k ) k,i) −(cid:16)z(i) k,i log k,i) − z(i) k,i) − z(i) (1 + γ)αknξk,i · (zk−1,i − z(i) (1 + γ)2zk−1,i · (αknξk,i)2 2zk−1,i · (αknξk,i)2 zk−1,i · γαknξk,i + 2zk−1,i · γαknβ = γαkhnξ(i) 2 max{z(i) k,i − zk−1,i2 4zk−1,i ≤ x≤ y≤ z≤ {≤ ~≤ Above, x uses the facts (i) a log a same sign, and (iii) ξ(i) have a log a ab − b2/4 ≤ a2. uses (1 + γ)2 < 2. } uses ξk,i ≤ 1 and γ = 2αT n ≥ 2αkn. ~ uses ξk,i ≥ −β. k and ξk,i have the 6= i; y uses the inequality that for every a, b > 0, we k,i ≤ 2zk−1,i.16 { uses Cauchy-Shwarz: b + b − a ≥ 0 for any a, b > 0, (ii) zk−1,i − z(i) b + b − a ≥ (a−b)2 2 max{a,b} .15z uses the fact that z(i) k,i0 = 0 for every i0 Next, we combine (D.1) and (D.2) to conclude that z(i) 3OPT0 ≤ 6OPT, we obtain that Taking expectation on both sides with respect to i, and using the property that 1T zk−1 ≤ (cid:3) k (cid:0) u∗ 1 + γ(cid:1) − V 1 + γ(cid:1) + 2zk−1,i · γαknβ . 1 + γ(cid:1)i + 12OPT · γαkβ . 1 + γ(cid:1) − EihV k (cid:0) u∗ k , zk−1 − u∗(cid:11) ≤ Vzk−1(cid:0) u∗ k , zk−1 − u∗(cid:11)(cid:3) ≤ Vzk−1(cid:0) u∗ αk(cid:10)nξ(i) Ei(cid:2)αk(cid:10)nξ(i) Lemma 6.14. For every i ∈ [n], we have (a) fµ(xk) − fµ(y(i) (b) fµ(xk) − fµ(y(i) Proof of Lemma 6.14 part (a). Since if i 6∈ Bk is not a large index we have y(i) is trivial, we focus on i ∈ Bk in the remaining proof. Recall that y(i) k = xk and the claim k = xk + δei for some δ > 0 k ) ≥ 0, and k ) ≥ µβ z(i) k , u∗i . 12 · h−eη(i) τ =0h−∇fµ(xk + τ ei), eiidτ =Z δ k ) =Z δ τ =0(cid:0)hA:i, p(xk + τ ei)i − 1(cid:1)dτ . 15This inequality in fact corresponds to a local strong convexity property of w(·). We have used this technique in our paper [2]. 16This is because, our parameter choices ensure that (1+γ)αkn < 1/2β, which further means −(1+γ)αknξ(i) k,i ≤ 1/2. As a result, we must have z(i) k,i ≤ zk−1,i·e0.5 < 2zk−1,i (see the explicit definition of the mirror step at Proposition 6.4). defined in Algorithm 3, so we have fµ(xk) − fµ(y(i) 29 It is clear that hA:i, p(xk + τ ei)i decreases as τ increases, and therefore it suffices to prove that hA:i, p(xk + δei)i ≥ 1. Suppose that the rows of A:i are sorted (for the simplicity of notation) by the increasing order of Aj,i. Now, by the definition of the algorithm (recall (6.1)), there exists some j∗ ∈ [m] satisfying that Next, by our choice of δ which satisfies δ = µβ X j<j∗ Aj,i · pj(xk) < 1 + β and Xj≤j∗ 2Aj∗,i ≤ µβ µ ≥ pj(xk) · e−β/2 ≥ pj(xk) · (1 − β/2) , Aj,i · pj(xk) ≥ 1 + β . for every j ≤ j∗, we have for every j ≤ j∗: 2Aj,i Aj,iδ pj(xk + δei) = pj(xk) · e− and as a result, Aj,i · pj(xk + δei) ≥ (1 − β/2)Xj≤j∗ hA:i, p(xk + δei) ≥ Xj≤j∗ Aj,i · pj(xk) ≥ (1 − β/2)(1 + β) ≥ 1 . (cid:3) Proof of Lemma 6.14 part (b). Owing to part (a), for every coordinate i such that eηk,i ≥ 0, we automatically have fµ(xk) − fµ(y(i) coordinates i such thateηk,i < 0; these are necessarily large indices i ∈ B. Recall from Definition 6.11 that eηk,i = (1 + β) − (eAT p(xk))i, so we have Pm j=1 eAj,i · pj(xk) − (1 + β) > 0 . k ) ≥ 0 so the lemma is obvious. Therefore, let us focus only on For the simplicity of description, suppose again that each i-th column is sorted in non-decreasing j=1 eAj,i · pj > 1 + β. It is clear that j[ ≥ j∗, owing to the 2Aj[,i ≤ δ, the objective decrease is lower bounded as order, that is, A1,i ≤ ··· ≤ Am,i. The definition of j∗ can be simplified as Let j[ ∈ [m] be the row such that Note that such a j[ must exist becausePm definition that eAji ≤ Aji for all i ∈ [n], j ∈ [m]. Defining δ[ = µβ Pj<j∗ Aj,i · pj(xk) < 1 + β and Pj≤j∗ Aj,i · pj(xk) ≥ 1 + β . Pj<j[ eAj,i · pj(xk) < 1 + β and Pj≤j[ eAj,i · pj(xk) ≥ 1 + β . τ =0h−∇fµ(xk + τ ei), eiidτ =Z δ k ) =Z δ ≥Z δ[ τ =0(cid:0)hA:i, p(xk + τ ei)i − 1(cid:1)dτ =Z δ[ τ =0(cid:16) − 1 +Xj≤j[ Aj,i · pj(xk + τ ei)(cid:17)dτ } {z +Xj>j[Z δ[ fµ(xk) − fµ(y(i) τ =0(cid:0)hA:i, p(xk + τ ei)i − 1(cid:1)dτ {z τ =0 I0 I Aj,i · pj(xk + τ ei)dτ } where the inequality is because δ[ ≤ δ and hA:i, p(xk + τ ei)i ≥ 1 for all τ ≤ δ (see the proof of part (a)). Part I. To lower bound I, we use the monotonicity of pj(·) and obtain that I =Z δ[ τ =0(cid:16) − 1 +Xj≤j[ Aj,i · pj(xk + τ ei)(cid:17)dτ ≥ δ[ ·(cid:16) − 1 +Xj≤j[ Aj,i · pj(xk + δ[ei)(cid:17) . 30 µ 2Aj,i −Aj,i·δ[ X j≤j[ Aj,i · pj(xk) · e Therefore, we obtain that However, our choice of δ[ = µβ for all j ≤ j[ ensures that 2Aj[,i ≤ µβ Aj,i · pj(xk + δ[ei) ≥ Xj≤j[ Aj,i · pj(xk)(cid:17) ≥ I ≥ δ[(cid:16) − 1 + (1 − β/2)Xj≤j[ where the inequality is because(cid:0) 2 2(cid:1)Pj≤j[ Aj,i · pj(xk) ≥ 4−3β 3 − β Now, suppose thatPj≤j[ eAj,i · pj(xk) − (1 + β) = b · eAj[,i · pj[(xk) for some b ∈ [0, 1]. Note that equivalently, whenever ε ≤ 1/9). we can do so by the very definition of j[. Then, we must have ≥ Xj≤j[ 3(cid:16) − 1 +Xj≤j[ Aj,i · pj(xk)(cid:17) , Aj,i · pj(xk) · (1 − β/2) . 3 whenever β ≤ 1 · (1 + β) ≥ 2 3 (or δ[ 6 −1 +Xj≤j[ Aj,i · pj(xk) ≥ −1 +Xj<j[ eAj,i · pj(xk) + Aj[,i · pj[(xk) δ[ I ≥ Therefore, we conclude that ≥ β + b · Aj[,i · pj[(xk) . = −1 + (1 + β) − (1 − b)eAj[,i · pj[(xk) + Aj[,i · pj[(xk) 6eAj[,i · b · eAj[,i · pj[(xk) Above, the last inequality is because u∗i · eAj[,i ≤ heAj[:, u∗i ≤ 2 by our definition of eA. 3(cid:16) − 1 +Xj≤j[ 6eAj[,i ·(cid:16) − (1 + β) +Xj≤j[ eAj,i · pj(xk)(cid:17) ≥ 12 · u∗i ·(cid:16) − (1 + β) +Xj≤j[ eAj,i · pj(xk)(cid:17) . Part I0. To lower bound I0, consider every j > j[ and the integral Aj,i · pj(xk)(cid:17) > δ[ 3 · b · Aj[,i · pj[(xk) = µβ µβ µβ = Z δ[ Aj,i · pj(xk + τ ei)dτ . 2Aj,i ≤ µβ = δ[, we have that pj(xk + τ ei) ≥ pj(xk) · e−β/2 ≥ 1 2Aj[,i τ =0 2 pj(xk). Note that whenever τ ≤ µβ Therefore, Z δ[ τ =0 Aj,i · pj(xk + τ ei)dτ ≥Z µβ τ =0 2Aj,i This implies a lower bound on I0: µβ 4Aj,i · Aj,i · pj(xk) ≥ I0 ≥ Xj>j[ pj(xk) . 1 2 µβ 2Aj,i · Aj,i · Aj,i · pj(xk + τ ei)dτ ≥ µβ 8 ·Xj>j[ u∗i · eAj,i · pj(xk) , Together. Combining the lower bounds on I and I0, we obtain where again in the last inequality we have used u∗i · eAj[,i ≤ heAj[:, u∗i ≤ 2 by our definition of eA. k , u∗i . (cid:3) fµ(xk) − fµ(y(i) k ) ≥ I + I0 ≥ µβ µβ m 12 · u∗i ·(cid:16) − (1 + β) + j=1 eAj,i · pj(xk)(cid:17) = X 12 · h−eη(i) 31 E Proof of Lemma 3.3: Efficient Implementation of PacLPSolver In this section, we illustrate how to implement each iteration of PacLPSolver to run in an expected O(N/n) time. We maintain the following quantities y0k ∈ Rn, ay0k ∈ Rm, Bk,1, Bk,2 ∈ R+ azk ∈ Rm ≥0, zk ∈ Rn ≥0, throughout the algorithm, so as to ensure the following invariants are always satisfied Azk = azk , yk = Bk,1 · zk + Bk,2 · y0k , (E.2) It is clear that when k = 0, letting azk = Az0, y0k = y0, ay0k = Ay0, Bk,1 = 0, and Bk,2 = 1, we can ensure that all the invariants are satisfied initially. We denote kA:ik0 the number of nonzeros elements in vector A:i. In each iteration k = 1, 2, . . . , T : Ay0k = ay0k . (E.1) 1µ Accordingly, for each j, we need to know the value • The step xk = τ zk−1 + (1 − τ )yk−1 does not need to be implemented. • The value ∇if (xk) requires the knowledge of pj(xk) = e This can be computed in O(1) time for each j, and O(kA:ik0) time in total. ((Axk)j−1) for each j such that Aij 6= 0. (Axk)j = τ (Azk−1)j + (1 − τ )(Ayk−1)j =(cid:0)τ + (1 − τ )Bk−1,1(cid:1)azk−1,j + (1 − τ )Bk−1,2ay0k−1,j . • Recall the step zk ← arg minz∈∆box(cid:8) 1 k , zi(cid:9) can be written as zk = A + hnαkξ(i) zk−1 + δei for some δ ∈ R that can be computed in O(1) time (see Proposition 3.2). Observe also zk = zk−1 + δei yields yk = τ zk−1 + (1 − τ )yk−1 + δei nαkL due to Line 6 and Line 10 of Algorithm 1. Therefore, we perform two explicit updates on zk and azk as 2kz − zk−1k2 and two implicit updates on yk as zk ← zk−1 + δei , azk ← azk−1 + δA:i Bk,1 = τ + (1 − τ )Bk−1,1 , Bk,2 = (1 − τ )Bk−1,2 , Bk,2 1 + 1 nαkL 1 Bk,2 + 1 nαkL Bk,2(cid:17) Bk,2(cid:17)(cid:17) It is not hard to verify that after these updates, Ay0k = ay0k and we have Bk,2(cid:17) , ay0k ← ay0k−1 + δA:i ·(cid:16) − Bk,1 y0k ← y0k−1 + δei ·(cid:16) − Bk,1 Bk,1 · zk + Bk,2 · y0k = Bk,1 ·(cid:0)zk−1 + δei(cid:1) + Bk,2 ·(cid:16)y0k−1 + δei ·(cid:16) − = Bk,1 · zk−1 + Bk,2 ·(cid:16)y0k−1 + δei ·(cid:16) 1 = Bk,1 · zk−1 + Bk,2 · y0k−1 + =(cid:0)τ + (1 − τ )Bk−1,1(cid:1) · zk−1 +(cid:0)(1 − τ )Bk−1,2(cid:1) · y0k−1 + = τ zk−1 + (1 − τ )yk−1 + so the invariant yk = Bk,1 · zk + Bk,2 · y0k also holds. In sum, after performing updates on Azk and ay0k in time O(kA:ik0), we can ensure that the invariants in (E.1) and (E.2) are satisfied at iteration k. Bk,2(cid:17)(cid:17) δei nαkL δei nαkL δei nαkL Bk,1 Bk,2 = yk , 1 1 nαkL + nαkL 1 In sum, we only need O(kA:ik0) time to perform the updates in PacLPSolver for an iteration k if the coordinate i is selected. Therefore, each iteration of PacLPSolver can be implemented to run in an expected O(Ei[kA:ik0]) = O(N/n) time. 32 F Proof of Lemma 6.5: Efficient Implementation of CovLPSolver In this section we illustrate how to implement each iteration of CovLPSolver to run in an expected O(N/n) time. We maintain the following quantities az0k ∈ Rm ≥0, ay0k ∈ Rm, Bk,1, Bk,2 ∈ R+ sumzk ∈ R+, szk ∈ R+, z0k ∈ Rn +, y0k ∈ Rn, throughout the algorithm, so as to maintain the following invariants Azk = az0k/szk, (F.1) (F.2) It is clear that when k = 0, letting z0k = z0, szk = 1, sumzk = 1T z0, az0k = Az0, y0k = y0, ay0k = Ay0, Bk,1 = 0, and Bk,2 = 1, we can ensure that all the invariants are satisfied initially. + (1 − τ )Bk−1,2ay0k−1,j . • The step xk = τ zk−1 + (1 − τ )yk−1 does not need to be implemented. • The value pj(xk) = e (1−(Axk)j ) for each j only requires the knowledge of (Axk)j = τ (Azk−1)j + (1 − τ )(Ayk−1)j =(cid:0)τ + (1 − τ )Bk−1,1(cid:1) az0k−1,j This can be computed in O(1) time. szk−1 1µ We denote by kA:ik0 the number of nonzero elements in vector A:i. 1, 2, . . . , T : In each iteration k = zk = z0k/szk, yk = Bk,1 · z0k + Bk,2 · y0k, sumzk = 1T z0k, Ayk = ay0k . • The value ∇if (xk) requires the knowledge of pj(xk) for each j ∈ [m] such that Aij 6= 0. Since we have kA:ik0 such j's, we can compute ∇if (xk) in O(kA:ik0) time. k,i, recall that the mirror step zk ← arg minz∈∆simplex(cid:8)Vzk−1(z) + • Letting δ = (1 + γ)nαkξ(i) hδei, zi(cid:9) has a very simple form (see Proposition 6.4): first multiply the i-th coordinate of zk−1 by e−δ and then, if the sum of all coordinates have exceeded 2OPT0, scale everything down so as to sum up to 2OPT0. This can be implemented as follows: setting δ1 = z0k−1,i(e−δ − 1), z0k ← z0k−1 + δ1ei sumzk ← sumzk−1 + δ1 , az0k ← az0k−1 + δ1A:i , szk ← szk · maxn1, , sumzk szk−1·2OPT0o . These updates can be implemented to run in O(kA:ik0) time, and they together ensure that the invariants in (F.1) are satisfied at iteration k. • Recall that the gradient step is of the form yk ← xk + δ2 · ei for some value δ2 ≥ 0. This value δ2 can be computed in O(kA:ik0) time, since each pj(xk) can be computed in O(1) time, and we can sort the rows of each column of A by preprocessing. Since yk = xk + δ2 · ei = τ zk−1 + (1 − τ )yk−1 + δ2ei, we can implement this update by letting Bk,1 = τ + (1 − τ )Bk−1,1 , Bk,2 = (1 − τ )Bk−1,2 Bk,2 szk−1 + δ2 It is not hard to verify that after these updates, ay0k = Ay0k and we have y0k ← y0k−1 + ei ·(cid:16) − Bk,1δ1 Bk,2(cid:17) , ay0k ← ay0k−1 + A:i ·(cid:16) − Bk,1δ1 Bk,1 · z0k + Bk,2 · y0k = Bk,1 ·(cid:0)z0k−1 + δ1ei(cid:1) + Bk,2 ·(cid:16)y0k−1 + ei ·(cid:16) − = Bk,1 · z0k−1 + Bk,2 ·(cid:0)y0k−1 + δ2ei/Bk,2(cid:1) = Bk,1 · z0k−1 + Bk,2 · y0k−1 + δ2ei + (1 − τ )Bk−1,1(cid:1) · z0k−1 +(cid:0)(1 − τ )Bk−1,2(cid:1) · y0k−1 + δ2ei =(cid:0) szk−1 Bk,2 τ + δ2 Bk,2(cid:17) Bk,2(cid:17)(cid:17) δ2 + Bk,1δ1 Bk,2 33 = τ zk−1 + (1 − τ )yk−1 + δ2ei = yk , so that the invariant yk = Bk,1 · z0k + Bk,2 · y0k is also satisfied. In sum, after running time O(kA:ik0), we can ensure that the invariants in (F.2) are satisfied at iteration k. In sum, we only need O(kA:ik0) time to perform the updates in CovLPSolver for an iteration k if the coordinate i is selected. Therefore, each iteration of CovLPSolver can be implemented to run in an expected O(Ei[kA:ik0]) = O(N/n) time. References [1] Zeyuan Allen-Zhu and Lorenzo Orecchia. Nearly-Linear Time Positive LP Solver with Faster Convergence Rate. In Proceedings of the 47th Annual ACM Symposium on Theory of Com- puting, STOC '15, 2015. [2] Zeyuan Allen-Zhu and Lorenzo Orecchia. Using optimization to break the epsilon barrier: A faster and simpler width-independent algorithm for solving positive linear programs in parallel. In SODA, 2015. [3] Zeyuan Allen-Zhu and Lorenzo Orecchia. Linear Coupling: An Ultimate Unification of Gra- dient and Mirror Descent. In ITCS, 2017. Full version available at http://arxiv.org/abs/ 1407.1537. [4] Zeyuan Allen-Zhu, Zhenyu Liao, and Lorenzo Orecchia. Spectral Sparsification and Regret Minimization Beyond Multiplicative Updates. In STOC, 2015. [5] Zeyuan Allen-Zhu, Yin Tat Lee, and Lorenzo Orecchia. Using optimization to obtain a width- independent, parallel, simpler, and faster positive SDP solver. In SODA, 2016. [6] Zeyuan Allen-Zhu, Peter Richt´arik, Zheng Qu, and Yang Yuan. Even faster accelerated coor- dinate descent using non-uniform sampling. In ICML, 2016. [7] Zeyuan Allen-Zhu, Yuanzhi Li, Rafael Oliveira, and Avi Wigderson. Much Faster Algorithms for Matrix Scaling. In FOCS, 2017. Full version available at http://arxiv.org/abs/1704. 02315. [8] Sanjeev Arora, Elad Hazan, and Satyen Kale. The Multiplicative Weights Update Method: a Meta-Algorithm and Applications. Theory of Computing, 8:121–164, 2012. doi: 10.4086/toc. 2012.v008a006. [9] Baruch Awerbuch and Rohit Khandekar. Stateless distributed gradient descent for positive linear programs. STOC, 2008. doi: 10.1145/1374376.1374476. [10] Baruch Awerbuch, Rohit Khandekar, and Satish Rao. Distributed algorithms for multicom- modity flow problems via approximate steepest descent framework. ACM Transactions on Algorithms, 9(1):1–14, December 2012. ISSN 15496325. doi: 10.1145/2390176.2390179. [11] Yair Bartal, John W. Byers, and Danny Raz. Global optimization using local information In Proceedings 38th Annual Symposium on Foundations ISBN 0-8186-8197-7. doi: with applications to flow control. of Computer Science, pages 303–312. IEEE Comput. Soc, 1997. 10.1109/SFCS.1997.646119. 34 [12] Yair Bartal, John W. Byers, and Danny Raz. Fast, Distributed Approximation Algorithms for Positive Linear Programming with Applications to Flow Control. SIAM Journal on Computing, 33(6):1261–1279, January 2004. ISSN 0097-5397. doi: 10.1137/S0097539700379383. [13] Aharon Ben-Tal and Arkadi Nemirovski. Lectures on Modern Convex Optimization. Society ISBN 978-0-89871-491-3. doi: 10. for Industrial and Applied Mathematics, January 2013. 1137/1.9780898718829. [14] D. Bienstock and G. Iyengar. Faster approximation algorithms for packing and covering prob- lems. Technical report, Columbia University, September 2004. Preliminary version published in STOC '04. [15] John Byers and Gabriel Nasser. Utility-based decision-making in wireless sensor networks. In Mobile and Ad Hoc Networking and Computing, 2000. MobiHOC. 2000 First Annual Workshop on, pages 143–144. IEEE, 2000. [16] Fabi´an A. Chudak and Vania Eleut´erio. Improved Approximation Schemes for Linear Pro- gramming Relaxations of Combinatorial Optimization Problems. In Proceedings of the 11th In- ternational IPCO Conference on Integer Programming and Combinatorial Optimization, pages 81–96, 2005. [17] Ran Duan and Seth Pettie. Linear-Time Approximation for Maximum Weight Matching. Journal of the ACM, 61(1):1–23, January 2014. ISSN 00045411. doi: 10.1145/2529989. [18] Olivier Fercoq and Peter Richt´arik. Accelerated, Parallel and Proximal Coordinate Descent. SIAM Journal on Optimization, 25(4):1997–2023, 2015. [19] Lisa K. Fleischer. Approximating Fractional Multicommodity Flow Independent of the Number of Commodities. SIAM Journal on Discrete Mathematics, 13(4):505–520, January 2000. ISSN 0895-4801. doi: 10.1137/S0895480199355754. [20] Naveen Garg and Jochen Konemann. Faster and Simpler Algorithms for Multicommodity Flow and Other Fractional Packing Problems. SIAM Journal on Computing, 37(2):630–652, January 2007. ISSN 0097-5397. doi: 10.1137/S0097539704446232. [21] Michael D Grigoriadis and Leonid G Khachiyan. Fast approximation schemes for convex programs with many blocks and coupling constraints. SIAM Journal on Optimization, 4(1): 86–107, 1994. [22] Rahul Jain, Zhengfeng Ji, Sarvagya Upadhyay, and John Watrous. QIP = PSPACE. Journal of the ACM (JACM), 58(6):30, 2011. [23] Philip Klein and Neal E Young. On the number of iterations for dantzig–wolfe optimization and packing-covering approximation algorithms. SIAM Journal on Computing, 44(4):1154–1172, 2015. [24] Christos Koufogiannakis and Neal E. Young. A Nearly Linear-Time PTAS for Explicit Frac- tional Packing and Covering Linear Programs. Algorithmica, pages 494–506, March 2013. ISSN 0178-4617. doi: 10.1007/s00453-013-9771-6. Previously appeared in FOCS '07. [25] Michael Luby and Noam Nisan. A parallel approximation algorithm for positive linear pro- gramming. In STOC, pages 448–457, New York, New York, USA, 1993. ACM Press. ISBN 0897915917. doi: 10.1145/167088.167211. 35 [26] Aleksander Madry. Faster approximation schemes for fractional multicommodity flow problems via dynamic graph algorithms. In STOC, New York, New York, USA, 2010. ACM Press. ISBN 9781450300506. doi: 10.1145/1806689.1806708. [27] Arkadi Nemirovski. Prox-Method with Rate of Convergence O(1/t) for Variational Inequalities with Lipschitz Continuous Monotone Operators and Smooth Convex-Concave Saddle Point Problems. SIAM Journal on Optimization, 15(1):229–251, January 2004. ISSN 1052-6234. doi: 10.1137/S1052623403425629. [28] Yu Nesterov. Rounding of convex sets and efficient gradient methods for linear programming problems. Optimisation Methods and Software, 23(1):109–128, 2008. [29] Yurii Nesterov. A method of solving a convex programming problem with convergence rate O(1/k2). In Doklady AN SSSR (translated as Soviet Mathematics Doklady), volume 269, pages 543–547, 1983. [30] Yurii Nesterov. Smooth minimization of non-smooth functions. Mathematical Programming, 103(1):127–152, December 2005. ISSN 0025-5610. doi: 10.1007/s10107-004-0552-5. [31] Yurii Nesterov. Efficiency of Coordinate Descent Methods on Huge-Scale Optimization Prob- ISSN 1052-6234. doi: lems. SIAM Journal on Optimization, 22(2):341–362, jan 2012. 10.1137/100802001. [32] Serge A. Plotkin, David B. Shmoys, and ´Eva Tardos. Fast Approximation Algorithms for Fractional Packing and Covering Problems. Mathematics of Operations Research, 20(2):257– 301, May 1995. ISSN 0364-765X. doi: 10.1287/moor.20.2.257. conference version published in FOCS 1991. [33] Luca Trevisan. Parallel Approximation Algorithms by Positive Linear Programming. Algo- rithmica, 21(1):72–88, May 1998. ISSN 0178-4617. doi: 10.1007/PL00009209. [34] Di Wang, Michael W. Mahoney, Nishanth Mohan, and Satish Rao. Faster parallel solver for positive linear programs via dynamically-bucketed selective coordinate descent. ArXiv e-prints, abs/1511.06468, November 2015. [35] Di Wang, Satish Rao, and Michael W. Mahoney. Unified acceleration method for packing and covering problems via diameter reduction. In ICALP, 2016. [36] Neal E. Young. Sequential and parallel algorithms for mixed packing and covering. In 42nd Annual IEEE Symposium on Foundations of Computer Science (FOCS'01), pages 538–546. IEEE Comput. Soc, 2001. ISBN 0-7695-1116-3. doi: 10.1109/SFCS.2001.959930. [37] Neal E. Young. Nearly linear-time approximation schemes for mixed packing/covering and facility-location linear programs. ArXiv e-prints, abs/1407.3015, July 2014. URL http:// arxiv.org/abs/1407.3015. [38] Edo Zurel and Noam Nisan. An efficient approximate allocation algorithm for combinatorial auctions. In Proceedings of the 3rd ACM conference on Electronic Commerce, pages 125–136. ACM, 2001. 36
1805.03158
1
1805
2018-05-08T16:48:01
Round-Hashing for Data Storage: Distributed Servers and External-Memory Tables
[ "cs.DS" ]
This paper proposes round-hashing, which is suitable for data storage on distributed servers and for implementing external-memory tables in which each lookup retrieves at most a single block of external memory, using a stash. For data storage, round-hashing is like consistent hashing as it avoids a full rehashing of the keys when new servers are added. Experiments show that the speed to serve requests is tenfold or more than the state of the art. In distributed data storage, this guarantees better throughput for serving requests and, moreover, greatly reduces decision times for which data should move to new servers as rescanning data is much faster.
cs.DS
cs
Round-Hashing for Data Storage: Distributed Servers and External-Memory Tables Dipartimento di Informatica, Universit`a di Pisa, Italy Roberto Grossi [email protected] Luca Versari Dipartimento di Informatica, Universit`a di Pisa,Italy [email protected] May 9, 2018 Abstract This paper proposes round-hashing, which is suitable for data storage on distributed servers and for implementing external-memory tables in which each lookup retrieves at most a single block of external memory, using a stash. For data storage, round-hashing is like consistent hashing as it avoids a full rehashing of the keys when new servers are added. Experiments show that the speed to serve requests is tenfold or more than the state of the art. In distributed data storage, this guarantees better throughput for serving requests and, moreover, greatly reduces decision times for which data should move to new servers as rescanning data is much faster. 1 Introduction Consistent hashing was invented by Karger et al. [13] for shared web caching and highest random weight hashing (also known as rendezvous hashing) was invented by Thaler and Ravishankar [24] for web proxy servers. Both hashing methods were conceived independently around the mid 90s, and shared similar goals (with different implementations): cached web pages are assigned to servers, so that when a server goes down, its cached web pages are reassigned to the other servers so as to preserve their load balancing; similarly, when a new server is added, some cached web pages are moved to it from the others. Consistent hashing, in its basic version, maps both web pages and servers to the circular universe [0 . . . 2w − 1], where each hash value requires w bits: each web page starts from its hash value in the circular universe and is assigned to the server whose hash value is clockwise met first; this can be done in O(log m) time using a search data structure of size O(m) for m servers. Rendezvous hashing, for a given web page p, applies hashing to the pairs (cid:104)p, i(cid:105) for each server i, and then assigns p to the server i = i0 that gives the maximum hash value among these pairs; this is computed in O(log m) time using a tree of size O(m) as discussed by Wang and Ravishankar [26]. Table 1 reports a summary of these bounds. Both methods apply their rule above when a server is deleted or added. They have been successfully exploited in the industry, e.g. Akamai for consistent hashing, and Microsoft's cache array routing protocol (CARP) for rendezvous hashing. Among the notable applications, it is worth mentioning Chord [23] for building distributed hash tables in peer-to-peer networks (such as BitTorrent), and Amazon's Dynamo [7] for distributed and cloud computing, with data stored in main memory for speed on a wide set of machines. 1 consistent hashing [13] rendezvous hashing [24] jump consistent hash [14] linear hashing [15, 16] round-hashing (ours) find bucket O(log m) O(log m) O(log m) space O(m) O(m) O(1) O(log(m/s0)) O(1) O(1) O(1) new bucket O(α + log m) O(mα) O(mα) O(s0α) O(s0α) notes local distributed distributed local local, no division Table 1: Performance of the hashing methods for m buckets (servers). Here s0 (cid:28) m is a constant slack parameter (typically s = 64 or 128), and α = (number of stored keys) / m is the load factor. Although creating a new bucket moves O(α) keys on the average, each hashing method can take different time to decide which are the keys to move: "local" means that few other buckets scan their keys, while "distributed" means that all buckets scan their keys in parallel to decide which ones have to move to the new bucket. The O() notation indicates an expected cost. Recently, Lamping and Veach presented jump consistent hashing [14] at Google, observing that consistent hashing can be tailored for data centers and data storage applications in general. In this scenario, servers cannot disappear, as this would mean loss of valuable data; rather, they can be added to increase storage capacity.1 As a result, the hash values "jump" to higher values for the keys moved to a new bucket; moreover, the hash values are a contiguous range [0 . . . m − 1] for m servers, rather than a subset of m integers from [0 . . . 2w − 1]. This has a dramatic impact on the performance of the jump consistent hash, as illustrated in [14], observing that only balance and monotonicity should be guaranteed from the original proposal in [13]. The auxiliary storage is just O(1), as shown in Table 1; average query cost is the m-th harmonic number, so O(log m), with no worst case guarantee. In this paper, we study the problem of consistent hashing for data storage in the above scenario depicted by Lamping and Veach. For the presentation's sake, the keys are the hash values of the web pages, and the servers are the buckets, numbered from 0 to m − 1, where the keys have to be placed. At any time, we want to support the following operations, besides the initialization: • Return the current number m of buckets. • Given a key u, find its corresponding bucket number in [0 . . . m − 1]. • Add a new bucket having number m, thus the range becomes [0 . . . m]. • Release the last bucket m − 1, thus the range becomes [0 . . . m − 2].2 We observe that linear hashing, introduced by Litwin [16] and Larson [15] at the beginning of the 80s, can be successfully employed in this scenario, thus taking O(log m) time and O(1) space, as reported in Table 1. We use a constant slack parameter s0 (cid:28) m (typically s0 = 64 or 128) to guarantee that the number of keys in the most populated bucket is at most 1 + 1/s0 times the number of keys in the least populated bucket. Our first contribution In this paper we present a new hashing scheme, called round-hashing, which applies round-mapping to the hashed value, allowing us to achieve O(1) time and space in the worst case. This is a desirable feature, as otherwise hashing with no worst-case guarantee can pose 1Data is split into shards, where each shard is handled by a cluster of machines with replication, thus it is not acceptable for shards to disappear [14]. 2This operation is not actually mentioned in the original setting, but it comes for free in our case. 2 round q = 0 0 1 2 round q = 1 0 1 2 3 4 5 round q = 2 0 1 2 6 8 10 3 4 5 7 9 11 round q = 3 0 1 2 12 16 20 6 8 10 13 17 21 3 4 5 14 18 22 7 9 11 15 19 23 round q = 4 step s = s0 = 3 0 1 2 24 12 16 20 25 6 8 10 26 13 17 21 27 3 4 5 28 14 18 22 29 7 9 11 30 15 19 23 31 0 1 2 24 32 12 16 20 25 33 6 8 10 26 34 13 17 21 27 35 3 4 5 28 36 14 18 22 29 37 7 9 11 30 38 15 19 23 31 39 step s = 4 step s = 5 = 2s0 − 1 0 1 2 24 32 40 12 16 20 25 33 41 6 8 10 26 34 42 13 17 21 27 35 43 3 4 5 28 36 44 14 18 22 29 37 45 7 9 11 30 38 46 15 19 23 31 39 47 Figure 1: Example of round-mapping with s0 = 3, where the sequences of bucket numbers are not actually materialized by our algorithm. Framed chunks of s0 elements represent which bucket numbers have been added during round q. security issues, such as algorithmic complexity attacks [3, 6] for low-bandwidth denial of service exploiting its worst-case behavior. Round-hashing computes the hash value of the given key and invokes round-mapping for this value, as described in Section 2. Here we give a glimpse using the example with the bucket numbers shown in Figure 1, where we set s0 = 3. round-mapping does not materialize these numbers, and proceeds in rounds q = 0, 1, . . . when adding new bucket numbers, where at the end of round q there are m = 2qs0 bucket numbers. For instance, consider when round q − 1 = 3 ends (m = 8s0) and a new bucket number is requested, so round q = 4 begins. We observe that each round is divided into steps, where each step s = s0, s0 + 1, . . . , 2s0 − 1 handles the next 8 = 2q−1 requests of new bucket numbers. At the end of these steps, 2q−1s0 bucket numbers have been added to the 2q−1s0 ones inherited from round q − 1, and thus we find the claimed m = 2qs0 bucket numbers at the end of round q. Let us go back to the first request for q = 4. It is for block number m = 24, which is implicitly inserted after the first s = s0 = 3 elements, between 2 and 12. Next comes m = 25, so we skip other s = 3 elements, inserting it between 20 and 6. In general, for each step s, we insert a new bucket number by skipping the next s elements from the current position. When step s completes its virtual scan, it means that 2q−1 new block numbers have been served (8 in our example), so we can set s := s + 1 and repeat the scan from the beginning if s < 2s0. In summary, assigning a new block number is simple: skip the next s elements from the current position and insert the new bucket number; if the end of the scan is reached, increase s and restart from the beginning if s < 2s0. Any time we have a permutation of [0 . . . m − 1]: what is non-trivial is that, for any given (hash value) u ∈ [0 . . . m − 1], round-mapping computes the block number at position u in this evolving permutation, in O(1) time using O(1) additional memory, without general division and modulo operations. We refer the reader to Section 2 for a formal description. Finally, looking back at Table 1 when a new bucket is created, we observe that O(α) keys on average are moved from the other buckets, where α is the load factor, namely, the number of stored keys divided by the number m of buckets.3 However, the hashing methods take different time to decide which are the keys to move. Specifically, consistent hashing has to examine the O(α) keys 3We are assuming, wlog, that the buckets have all the same size. 3 in the two neighbor servers in the worst case, and update the data structure in O(log m) time.4 Rendezvous hashing requires that each bucket scans its keys and test whether the new bucket is now the maximum for some of them. Hence all the keys are scanned, O(mα), but only O(α) of them are moved in total. Jump consistent hashing needs to perform a similar task, to see which keys "jump" to the new bucket. Linear hashing and our round-hashing require to scan the keys in s0 = O(1) buckets to find the O(α) ones to move. Note that the methods in the last three rows of Table 1 need little data structure bookkeeping as space usage is O(1). When a new bucket is created, there are pros and cons to involve "all" vs "few" buckets to decide which keys move. At one end, when involving all buckets (rendezvous, jump consistent), Lamping and Veach observe that it is better to take few keys from each of them to relieve a hot spot, but this requires many servers scanning and sending data. At the other end (consistent, linear, round-), involving few buckets may not relieve a hot spot soon, but it makes sense if the data storage is distributed geographically among many data centers, and the most efficient way to move data is to make a copy on physical devices, moving them with a truck to the new data center. Note that suitably increasing s0 can combine the best of these two behaviors, so the choice depends on the application domain. Our second contribution We performed an experimental study of the above hashing methods, since Table 1 does not give the full picture from an algorithm engineering point of view. The code is publicly available at https://github.com/veluca93/round_hashing to replicate the experiments. Our first observation addresses how balanced are the buckets filled with the hashing methods in Table 1. By uniformly sampling all the possible keys, their hash values can be used to estimate how far the number of keys in buckets are from the ideal load factor α, reporting the least and the most populated buckets after the experiments. We observed that jump consistent hashing is very close to α, ranging from 0.988 α to 1.012 α; the experimental study in [14] shows that it compares favorably with consistent hashing (rendezvous hashing is not directly compared). We can match this performance by setting s0 = 128 for linear hashing and s0 = 64 for round-hashing. Our second observation relates to the real cost of instructions on a commodity processor. Concretely to illustrate our points, we refer to Intel processors [11]. Here Euclidean division is not our friend: integer division and modulo operations on 64-bit integers take 85–100 cycles, whereas addition takes 1 cycle (and can be easily pipelined). Interestingly, this goes in the direction of the so-called AC0-RAM dictionaries (e.g. see Andersson et al. [2]) and Practical RAM (e.g. see Brodnik et al. [4] and Miltersen [18]), where integer division and multiplication are not permitted, among others.5 However, multiplication should be taken with a grain of salt as, surprisingly, it takes 3–4 cycles (which becomes 1 cycle when it can be pipelined). Also, the modulo operation for powers of two or for small constants proportional to s0, can be replaced with a few shift and multiplication operations [10] as available, for instance, in the gcc compiler from version 2.6. Our implementation of round-hashing avoids general integer division and modulo operations because they are almost two orders of magnitude slower than the other operations: using them could nullify the advantage of the O(1) time complexity. We applied this tuning also to linear hashing whenever possible. As a result, to find the bucket number for a key, round-hashing is almost an order of magnitude faster than jump consistent hashing, and even much faster than the other hashing methods in Table 1. This is crucial for the system throughput: first, round-hashing can serve tenfold or more requests; second, when a new bucket number is added, it improves the performance of rescanning 4For the sake of discussion, we consider the basic version of consistent hashing, and refer the reader to [13, 14] for the version with multiple hash values per server. 5We thank Rasmus Pagh for pointing us the reference on AC0-RAM dictionaries. 4 the keys to decide which ones move to the new bucket. We refer the reader to Section 3 for further details on our experimental study. Our third contribution We apply round-hashing to obtain a variant of dynamic hash tables, called round-table, that addresses the issues of a high-throughput server with many lookup requests, relatively few updates, and where some keys can be kept in a stash in main memory. We follow the classical two-level external-memory model [1] to evaluate the complexity. Let n be the number of keys currently stored in the table, and B be the maximum number of keys that fit inside one block transfer from main memory to external memory, or vice versa. A stash of size k keys can be kept in main memory. We measure space occupancy using the space utilization 1 − , where 0 ≤  < 1, defined as the ratio of the number n of keys divided by the number of external-memory blocks times B, hence the number of blocks is (cid:100) B(1−)(cid:101). In other words,  represents the "waste" of space in external memory, so the lower , the better. n exp[− B √ 4 · 2 2− ] πB(2−) Round-table achieves the following bounds. Each lookup reads just 1 block from external memory in the worst case, taking O(1) CPU time and thus requiring only O(1) words from main memory. Each update (insertion or deletion) requires to access at most 4s0 blocks in external memory, in the worst case, taking O(s0(B + log n/ log log n)) CPU time w.h.p. (expected time is O(s0B)) and using O(B) memory cells. The number of keys in the stash is k ≈ n/ exp(B). For example, setting s0 = 2/ when  > 0, we obtain k ≈ n , noting that the update cost becomes O(−1) in this case. Thus k is exponentially smaller than Ω(n/B) in main memory, obtained by storing at least one word per external block (as B-trees do). Experiments in Section 4 confirm our estimation. Looking at the vast literature on hashing, apart from the previously mentioned methods, Mirrokni √ et al. [19] provide a version of consistent hashing that keeps bucket load within a factor of 1 + , but it cannot guarantee at most one memory access. The expected optimal bound of 1 + O(1/ B) memory accesses in Jensen and Pagh [12] does not require the stash, with no guarantee of at most one memory access. As for the work on tables with one external-memory access, some results [17, 8] rely on perfect hashing, but are either not dynamic or cannot reach arbitrarily high utilization. A recent cuckoo hashing based approach [21], combined with in-memory Bloom filters to ensure that lookups access the correct position, is not simple to dynamize. A general scheme [22] relies on perfect hashing to store the stash on external memory, thus having higher worst-case cost for internal insertions. The result in [5] achieves single-access lookups, but at the cost of O memory. A solution based on predecessor search needs O(cid:0) n (cid:16) (cid:1) internal memory, as discussed in [20]. B(1−) n B (cid:17) 2 Round-Hashing and Round-Mapping Round-hashing maps the hash value of the input key into a position u along the unitary circumference C, and invokes round-mapping on u to find the corresponding bucket number (note that u can be seen as a fraction of the unit). To this end, given the integer slack parameter s0 > 0, round-mapping maintains a partition of C into arcs of length proportional to either 1/s or 1/(s + 1) for some integer s (s0 ≤ s ≤ 2s0 − 1): if there are m arcs in C, they are consecutively numbered from 0 to m − 1 in clockwise order and in one-to-one correspondence with a permutation of {0, 1, . . . , m− 1}, called the bucket numbers. Also we refer to arcs as short when their length is proportional to 1/(s + 1), and long when their length is proportional to 1/s. Round-mapping supports the following operations, which are better visualized using C and its arcs in clockwise order. • init(): divide the circumference C into s = s0 long arcs, and set m = s0. 5 • numBuckets(): return the current number m of arcs (and, thus, of buckets). • findBucket(u) for 0 ≤ u < 1: return the bucket number assigned to the arc hit by the clockwise fraction u of the circumference C, where u = 0 hits the arc 0. • newBucket(): if all arcs are short, make them long; also, if s = 2 ∗ s0 − 1 then set s := s0, else s := s + 1. Starting from arc 0 and proceeding clockwise in C, find the sequence of the s closest long arcs, and shrink each of them so that it becomes short. In this way, a new short arc is allocated at the end of the sequence, and is associated with a new bucket number m (i.e. numBuckets() = m + 1). Return the bucket numbers for the former arcs. • freeBucket(): inverse operation of newBucket(). If all arcs are long, make them all short; also, if s = s0 then set s := 2 ∗ s0 − 1, else s := s − 1. Take the s + 1 closest short arcs in clockwise order, discard the last one, and change each of the first s ones to be long, releasing the largest bucket number m − 1 (associated with the discarded arc, hence numBuckets() = m − 1). Return the bucket numbers of the original s + 1 short arcs. Wlog we focus on newBucket(), as freeBucket() is simply unrolling the last newBucket() operation. They both require O(s0) time in the worst case, which is O(1) when s0 = O(1). We say that a round starts when s = s0. Let the rounds be numbered as q = 0, 1, 2, . . ., and let the length len(q) = s0 2q of a round q represent how many bucket numbers have been allocated by the last step s = 2s0 − 1. For example, choosing s0 = 3, the first rounds are shown in Figure 1. At step s = 4 of round q = 4, each call to newBucket() takes s consecutive bucket numbers and inserts a new bucket number: after 0 1 2 24 it inserts 32, after 12 16 20 25 it inserts 33, after 6 8 10 26 it inserts 34, and so on. Note that 32, 33, 34, etc., are native of round q = 4. Figure 1 shows of which round the bucket numbers are native, using framed chunks. After the last step s = 2s0 − 1, each round contains twice the bucket numbers than after the last step of the previous round. Also, the concatenation of every other chunk of s0 non-native bucket numbers, produces exactly the outcome of the previous round. We will exploit this regular pattern. As it can be noted, a mapping between the arcs and a permutation is maintained: for example, in round q = 4, arc j for j = 0, 1, 2 corresponds to bucket number b(j) = j; arc j = 4 has b(j) = 24, arc j = 5 has b(j) = 32, . . . , and arc j = 47 has b(j) = 47. Note that we do not maintain this mapping explicitly; still, findBucket(u) is able to identify arc j and its bucket number b(j) in constant time. 2.1 Implementation of findBucket(u) We exploit the invariant property that short arcs are numbered from 0 to p, and thus p + 1 is a multiple of s + 1, where p is maintained as the last added short arc. We also use pow (a), where a > 0, to denote the largest integer exponent e ≥ 0 such that 2e divides a (a.k.a. 2-adic order). Equivalently, pow (a) is the position of the least significant bit 1 in the binary representation of the unsigned integer a > 0. First, consider the ideal situation: after the last step s = 2s0 − 1 of round q, we have len(q) buckets, numbered consecutively from 0 to len(q) − 1. We also have len(q) arcs on the circle, numbered consecutively from 0 to len(q) − 1. As arc j is mapped to bucket number b(j) using our scheme, we give a closed formula for b(j) that can be computed in O(1) time in the word RAM model, where divisions and modulo operations involve just powers of two or constants in the range [s0 . . . 2s0]. Let j = s0 i + x where x ∈ {0, 1, . . . , s0 − 1}. If i = 0, then b(j) = b(x) = x. Thus b(j) = j for 0 ≤ j < s0. Hence, let assume i > 0 in the rest of the section, and thus we need to compute b(j) for j ≥ s0. 6 Algorithm 1: Mapping from arcs to buckets 1 Function findBucket(u) 2 j ← arc hit by u if j < s0 then return j if j > p then j(cid:48) ← j − p+1 else j(cid:48) ← j, s(cid:48) = s + 1 x ← (j(cid:48) % s(cid:48)) % s0 q(cid:48) ← q + (cid:106) s(cid:48)−1 (cid:106) s(cid:48)−1 s0 (cid:107) (cid:107)(cid:17) ·(cid:106) j(cid:48) s(cid:48) 1 + i = return pos(i, x, q(cid:48)) s0 s+1 , s(cid:48) = s (cid:107) (cid:106) j(cid:48)%s(cid:48) + s0 (cid:107) (cid:16) 3 4 5 6 7 8 9 11 12 10 Function pos(i, x, q) e ← position of the least significant bit 1 in i return (cid:98) (s0+x)2q+i (cid:99) 2e+1 We say that the bucket number in position j belongs to chunk i (hence, a chunk is of length s0). For odd values of i, the bucket number is native for round q. For even values of i, the bucket number is native for round q − pow (i), as it can be checked in Figure 1: for example, in round q after the last step, bucket number 9 is in position j = 37 = 3 · 12 + 1, so i = 12 and 9 is native for round q − pow (i) = 4 − 2 = 2. In general, as pow (i) = 0 when i is odd, we can always say that the bucket number is native for round q − pow (i) for i > 0. Another useful observation is that the smallest native number in round q is len(q − 1) by construction (e.g. 24 in round q = 4). In the ideal situation, we find the native round for the bucket number at position j: as its chunk is preserved in the native round, we can use its offset x inside the chunk to recover the value of that bucket number. In the native round q, each chunk i starts with bucket number len(q − 1) as previously observed, increased by one for each such chunk, thus the first bucket number in chunk i is len(q − 1) + (cid:98)i/2(cid:99). Also, any two adjacent numbers in the chunk, differ by 2q−1 by construction. Summing up, there are two cases for the bucket number for j: • i odd and thus native for round q: the bucket number is • i even and thus native for round q − pow (i): the bucket number is (cid:107) (cid:106) (s0+x)2q+i (cid:106) (s0+x)2q+i (cid:107) 2 2pow (i)+1 As pow (a) = 0 when a is odd, we can compactly write these positions in the ideal situation as (cid:22) (s0 + x)2q + i (cid:23) 2pow (i)+1 pos(i, x, q) = Second, consider the general situation, with an intermediate step s0 ≤ s ≤ 2s0 − 1 in round q. Recall that we know the position p of the last created arc. This gives the following picture. The first p + 1 short arcs in clockwise order can be seen as p+1 s+1 consecutive groups, each of s + 1 arcs, and the remaining arcs are long and form groups of s arcs each. Let us set s(cid:48) = s + 1 in the former groups, and s(cid:48) = s in the latter groups. In the following, we equally say that each group contains s(cid:48) arcs or that each group contains s(cid:48) bucket numbers. In general, we say s(cid:48) entries (arcs or bucket numbers) when it is clear from the context. A common feature is that the first s0 entries of each group are inherited from the previous round, and the last s(cid:48) − s0 entries in each group are those added in the current round: each new entry is appended at the end of each group, so the entry in position p is the last in its group. 7 s+1 and, consequently, p := p − p+1 is to reduce this computation to the ideal situation analyzed before. to set j := j − p+1 same size s(cid:48), which are sequentially numbered starting form 0. Now, given a position j, we want to compute b(j), the corresponding bucket number. The idea If j > p, we conceptually remove one entry for each group such that s(cid:48) = s + 1. This is equivalent s+1 . Now, we conceptually have all the groups of the Let i(cid:48) = (cid:98)j/s(cid:48)(cid:99) be the number of the group that contains the entry corresponding to j. We now decide whether j is one of the first s0 entries of its group or not. We have two cases, according to the value of r = j % s(cid:48). If r < s0, the wanted entry is one of the first s0 entries of its group. If we concatenate those entries over all groups, we obtain the ideal situation of the previous round q − 1. There, the wanted entry occupies position j(cid:48) = s0i(cid:48) + r. Hence, b(j) = pos(i(cid:48), r, q − 1) in the ideal situation. If r ≥ s0, the wanted entry is one of the last s(cid:48) entries of its group. Analogously, if we concatenate those entries over all groups, the position of the wanted entry becomes j(cid:48)(cid:48) = (s(cid:48) − s0)i(cid:48) + r − s0, where x = r − s0 is the internal offset. However, we cannot solve this directly. We use instead the observation that the futures entries that will contribute to get the ideal situation for round q, will be appended at the end of each group. In this ideal situation, the wanted entry correspond to arc 2i(cid:48) + 1 and is at position j(cid:48) = s0(2i(cid:48) + 1) + r − s0 for round q. Thus, b(j) = pos(2i(cid:48) + 1, r − s0, q) in the ideal situation. We can summarize the entire computation of b(j) in an equivalent formula computed by Algorithm 1 that can be computed in O(1) time. Lemma 1 findBucket() can be implemented in O(1) time using bitwise operations. Interestingly, findBucket() is much faster then other approaches known in the literature for consistent hashing, as we will see in Section 3. Theorem 1 Round-mapping with integer parameter s0 > 1 can be implemented using O(1) words, so that init(), numBuckets() and findBucket() take O(1) time, and newBucket() and freeBucket() take O(s0) time. 3 Distributed Servers We experimentally evaluated round-hashing and our C implementation of Algortihm 1, on a commodity hardware based on Intel Xeon E3-1545M v5 CPU and 32Gb RAM, running Linux 4.14.34, and using gcc 7.3.1 compiler. We give some implementation details on the experimented algorithms, observing that we decided not to run consistent hashing [13] and rendezvous hashing [24] as they are outperformed by jump consistent hashing as discussed in detail in [14]. Specifically, we ran the following code. • Jump consistent hashing [14]: we employed the implementation provided by the authors' optimized code. • Linear hashing [15, 16]: the pseudocode is provided but not the code, which we wrote in C. As for the O(log m) hash functions, we followed the approach suggested in [15]: we employed the fast and high-quality pseudo-random number generator in [25] using the key to hash as a seed and the jth output as the outcome of the jth hash function. This takes constant time per hash function. Moreover, we replaced all modulo operations with the equivalent faster operations, as we did for round-mapping. 8 Figure 2: Time needed to compute a single hash as the number of buckets varies. • Round-hashing (this paper): we employed the first output from the pseudo-random number generator in [25] as hash value. We chose the size of our hash range to be a power of two, so that mapping a hash value to an arc number can be done without divisions: we computed the product between the number of buckets and the hash value, divided by the maximum possible hash value. Note that some care is required to compute the product correctly as it may overflow. It is worth noting that replacing the expensive division was very effective in our measurements. In particular, we replaced the division by s(cid:48) in Algorithm 1 with the pre-computed equivalent combination of multiplication and shift: as s0 ≤ s(cid:48) ≤ 2s0, this can be done at initialization time with a constant amount of work. This reduced the time per round-hashing call from 14.02ns to 8.71ns, a 60% decrease, which is an interesting lesson that we learned. Figure 2 shows the running times for the above implementations, when computing ten million hash values, as the number of buckets varies on the x-axis. On the y-axis, the running times are reported for jump consistent hashing, linear hashing, and three versions of our round-hashing: the full round-hashing cost (i.e. given a key, return its bucket number); the cost of round-mapping alone (i.e. given a position u in the circumference, return its bucket number); and the cost of computing just the hash value using [25]. As it can be seen, as the overhead of the latter is negligible, the costs of round-hashing and round-mapping are very close and constant along the x-axis, outperforming the non-constant costs of jump consistent hashing and linear hashing, which behave similarly when the number of buckets is large. Note that round-hashing has at least an order of magnitude improvement at around 216 buckets and on, which indicates that it scales well. All the running times in Figure 2 were normalized by the time needed to compute the sum of all the values. Looking at the absolute figures, the running time for the sum is about 0.4ns per element, and that of round mapping is 8–10ns per element (and the pseudo-random number generator in [25] takes twice the cost of the sum). Speed is not the whole story as it is important also how the hash values in the range are 9 s0 jump consistent h. round-hashing σ µ 0.316 1% 99% percentile ratio 7.192 4.465 2.560 0.613 0.421 0.277 min max 0.988 1.012 0.993 1.007 1 29.325 0.610 1.221 0.610 1.221 2 20.272 0.814 1.221 0.814 1.221 4 0.977 1.221 0.977 1.221 0.976 1.085 0.976 1.085 8 0.976 1.028 0.976 1.028 16 0.976 1.002 0.976 1.002 32 64 0.989 1.002 0.989 1.002 0.995 1.002 0.995 1.002 128 1 29.329 0.602 1.232 0.605 1.228 2 20.274 0.803 1.234 0.808 1.228 4 0.964 1.232 0.969 1.225 0.965 1.095 0.970 1.090 8 0.965 1.041 0.970 1.034 16 0.968 1.014 0.973 1.009 32 64 0.980 1.014 0.984 1.009 0.985 1.014 0.990 1.009 128 7.203 4.476 2.583 0.685 0.527 0.417 1.014 2.001 1.500 1.250 1.112 1.053 1.027 1.013 1.007 2.030 1.520 1.264 1.124 1.066 1.037 1.025 1.019 linear hashing Table 2: Statistics on how much hash space is assigned to a given bucket, with a total of 10000 buckets. Note that the actual bucket sizes are obtained by multiplying the numbers in columns min, max, 1%, 99& by the load factor α. Extremal values and percentiles are a ratio from the ideal value. distributed in the buckets. To this end, we show in Table 2 the results using 64-bit hash values: as it was infeasible to compute the bucket for every possible hash value, we chose 109 values at regular intervals in the hash range of 264 values, and computed the bucket size distribution for them. The columns in the table report the parameters for 104 buckets, where the actual bucket sizes are obtained by multiplying parameters in {min,max,1%,99%} by the load factor α = 109/104. Specifically, s0 useful for linear hashing and round-hashing, the standard error σ µ where σ is the variance and µ is the average of the bucket sizes, the minimum and maximum bucket size, the 1% and 99% percentiles of the size, and the ratio between the latter two. This ratio is the most important parameter in the table as it shows how well-balanced are buckets. It can be easily seen that both round-hashing and linear-hashing can match almost perfectly, with round-hashing having a slightly better distribution. Based on this table, we can see that round-hashing and linear-hashing have distribution properties that are similar to jump consistent hashing, as long as we choose suitable values: s0 = 64 for round-hashing and s0 = 128 for linear hashing. Figure 2 has been plotted using these values of s0. 4 External-Memory Tables Given a universe U of keys, and a random hashing function h : U → I, where I = {0, 1, . . . ,I − 1}, we build a hash table that keeps a stash of keys in main memory. Armed with the round-hashing, we obtain a hash table called round-table that uses O(k + 1) words in main memory, where k denotes the number of stash keys. We consider the stash to be a set of k keys, where notation stash[b] indicates the set {x ∈ stash : findBucket(h(x)/I) = b} (e.g. a hash table in main memory with maximum size O(B + log n/ log log n) w.h.p. via a classical load balancing argument). To check if x ∈ stash, we check if x ∈ stash[b] where b = findBucket(x). Also, for a user given parameter , the guaranteed space utilization in external memory is 1 − . 10 s0 0 0.001 0.01  0.03 0.05 0.1 real est. real est. real est. real est. real est. real est. 1 17.2% 18.4% 17.1% 18.3% 16.7% 17.4% 15.9% 15.7% 15.1% 14.5% 13% 4 1.7% 3.4% 16 0.1% 0.01% 32 64 256 ideal 12% 1.7% 5.6% 6.8% 5.5% 6.7% 5.1% 5.9% 4.2% 4.4% 0.1% 1.8% 2.8% 1.7% 2.7% 1.3% 1.9% 0.7% 0.7% 1.4% 2% 1.3% 1.9% 0.9% 1.2% 0.4% 0.3% 0.1% 0.5% 0.003% 0.009% 1.3% 1.6% 1.2% 1.5% 0.8% 0.9% 0.3% 0.6% 0.1% 0.2% 0.003% 0.002% 1.3% 1.3% 1.2% 1.3% 0.8% 1% 0.3% 0.3% 0.08% 0.09% 0.003% 0.0005% 0.0003% 3.4% 0.3% 0.07% 0.8% - 1.2% - 1.2% - - 0.3% - - Table 3: Percentage of elements on the stash as s0 and  change, with B = 1024. n The lookup algorithm is straightforward while the insertion algorithm is a bit more complex (see the appendix for the pseudocode). After checking that the key is not in the table, it proceeds with the insertion. For this, we need to maintain the claimed space utilization of (1 − ). That B(1−)(cid:101) > numBuckets(), we need one more block. We invoke newBucket(), and receive a is, if (cid:100) list of z < 2s0 block numbers. We have to distribute the keys stored in these z blocks over z + 1 blocks, where the extra block has number numBuckets() as it is the latest allocated block number by round-mapping. In the distribution, the keys from the stash are also involved, as described below in the function distribute. After that, findBucket() finds the external-memory block block() that should contain the key: if it is full, the key is added to the stash. Function distribute(b0, b1, . . . , bz−1) takes these z block numbers from newBucket(), knowing that bz = numBuckets() is the new allocated block number, and thus allocates block(bz). Then it loads block(bz−1) and moves to block(bz) all keys x ∈ block(bz−1) such that findBucket(x) = bz. Also, for each x ∈ stash[bz−1] such that findBucket(x) = bz, it moves x to block(bz), if there is room, or to stash[bz] otherwise. Next, we repeat this task for bz−2 and bz−1 while also taking care of moving keys from stash[bz−1] to block(bz−1) if there is room, and so on. In this way, the cost of distribute is 2z + 1 block transfers, using O(B) space in main memory, taking O(s0(B + log n/ log log n)) CPU time w.h.p., and O(s0B) expected time. B(1−)(cid:101) < and its performance can be bound in the same way as above. We check the condition (cid:100) numBuckets()− 1 for n > 0 to run freeBucket() using a slightly different distribute that proceeds in reverse. Note that the rhs of the condition is numBuckets()− 1 to avoid newBucket() being called too soon. The deletion algorithm is similar to the insertion one (see the appendix for the pseudocode), n In Appendix B, we show that as long as we choose s0 > 2  we have that the stash size of a hash table implemented with round-hashing is similar to the behaviour we would get with an uniform hash function (that would require rehashing). Thus, we recommend choosing s0 > 2, as confirmed by the experiments below. Moreover, in Appendix C we show how to keep a copy of the stash in external memory, without increasing space usage but increasing the number of block operations per update to O(1 + s0). To evaluate our approach, we consider the worst-case stash size (over the number of keys) across multiple values of n (going from 210B to 213B) for B = 512, 1024, 2048 as  and s0 vary. The results are reported in Tables 3, 4 and 5 (the last two can be found in the appendix), where the left side of every column reports the ratio predicted by the analysis of Appendix B and the right side shows the effective maximum ratio reported during the experiment. As our analysis is substantially different when s0 > 1, we reported those values in bold to highlight them. Finally, the last row reports the 11 (a)  = 0.1 (b)  = 0.05 (c)  = 0.03 (d)  = 0.01 Figure 3: Stash size (on the y-axis) as n grows (on the x-axis) for s0 =  2 and different values of . best values one can hope to achieve for that value of , that is, the values that our analysis predicts for a uniform hash function. Looking at these results, we can make some observations. First, the values predicted by the analysis match the results fairly well, especially when s0 (cid:29) 1 or s0 (cid:28) 1. In particular, it almost never happens that the analysis is wrong by more than a factor of 3. Second, when s0 is small, stash size is fairly high, even for low space utilization. This is to be expected, as in this case different buckets may have very different assignment probabilities. Third, as s0 grows, stash size quickly approaches the one that we would expect from the ideal case. Nonetheless, the improvement is fairly small when s0 goes over 32, even at low utilization. We thus recommend s0 to be chosen near 32 for practical usage. We also considered how stash size varies over time, as more elements are inserted. To study that, we fixed s0 = 2  , as recommended in the analysis section, and plotted the size of the stash against the number of elements in the table. The plots can be found in Figure 3. These plots clearly show the "cyclic" behavior of round-table: when a new round begins, the distribution of keys in buckets is further away from being uniform and, as a result, the stash size increases. As more steps of the round are completed, the spikes in stash size get progressively smaller as round-table balances keys in a better way, until a new round starts again and the table reverts to its previous behavior. 12 References [1] Alok Aggarwal and Jeffrey Scott Vitter. The input/output complexity of sorting and related problems. Communications of the ACM, 31(9):1116–1127, September 1988. [2] A. Andersson, P. B. Miltersen, S. Riis, and M. Thorup. Static dictionaries on AC0 RAMs: query time θ((cid:112)log n/ log log n) is necessary and sufficient. In Proceedings of 37th Conference on Foundations of Computer Science, pages 441–450, Oct 1996. [3] Noa Bar-Yosef and Avishai Wool. Remote algorithmic complexity attacks against randomized hash tables. In SECRYPT 2007, Proceedings of the International Conference on Security and Cryptography, Barcelona, Spain, July 28-13, 2007, SECRYPT is part of ICETE - The International Joint Conference on e-Business and Telecommunications, pages 117–124, 2007. [4] Andrej Brodnik, Peter Bro Miltersen, and J. Ian Munro. Trans-dichotomous algorithms without multiplication-some upper and lower bounds. In Algorithms and Data Structures, 5th International Workshop, WADS '97, Halifax, Nova Scotia, Canada, August 6-8, 1997, Proceedings, pages 426–439, 1997. [5] F. Cesarini and G. Soda. Single access hashing with overflow separators for dynamic files. BIT Numerical Mathematics, 33(1):15–28, Mar 1993. [6] Scott A. Crosby and Dan S. Wallach. Denial of service via algorithmic complexity attacks. In USENIX Security Symposium. USENIX Association, 2003. [7] Giuseppe DeCandia, Deniz Hastorun, Madan Jampani, Gunavardhan Kakulapati, Avinash Lakshman, Alex Pilchin, Swaminathan Sivasubramanian, Peter Vosshall, and Werner Vogels. Dynamo: amazon's highly available key-value store. In Proceedings of the 21st ACM Symposium on Operating Systems Principles 2007, SOSP 2007, Stevenson, Washington, USA, October 14-17, 2007, pages 205–220, 2007. [8] Ronald Fagin, Jurg Nievergelt, Nicholas Pippenger, and H. Raymond Strong. Extendible hashing - a fast access method for dynamic files. ACM Trans. Database Syst., 4(3):315–344, September 1979. [9] Gaston H. Gonnet and Per-Ake Larson. External hashing with limited internal storage. J. ACM, 35(1):161–184, 1988. [10] T. Granlund and P. L. Montgomery. Division by invariant integers using multiplication. ACM Sigplan Notices, 29:61–72, 1994. [11] Intel Co. Intel 64 and IA-32 Architectures Optimization Reference Manual. Intel, order 248966-040, April 2018. [12] Morten Skaarup Jensen and Rasmus Pagh. Optimality in external memory hashing. Algorith- mica, 52(3):403–411, 2008. [13] David Karger, Eric Lehman, Tom Leighton, Rina Panigrahy, Matthew Levine, and Daniel Lewin. Consistent hashing and random trees: Distributed caching protocols for relieving hot spots on the world wide web. In Proceedings of the Twenty-ninth Annual ACM Symposium on Theory of Computing, STOC '97, pages 654–663, New York, NY, USA, 1997. ACM. 13 [14] John Lamping and Eric Veach. A fast, minimal memory, consistent hash algorithm. CoRR, abs/1406.2294, 2014. [15] Per-Ake Larson. Linear hashing with partial expansions. In VLDB, volume 6, pages 224–232, 1980. [16] Witold Litwin. Linear hashing: a new tool for file and table addressing. In VLDB, volume 80, pages 1–3, 1980. [17] Harry G Mairson. The program complexity of searching a table. In Foundations of Computer Science, 1983., 24th Annual Symposium on, pages 40–47. IEEE, 1983. [18] Peter Bro Miltersen. Lower bounds for static dictionaries on RAMs with bit operations but no multiplication. In Automata, Languages and Programming, 23rd International Colloquium, ICALP96, Paderborn, Germany, 8-12 July 1996, Proceedings, pages 442–453, 1996. [19] Vahab Mirrokni, Mikkel Thorup, and Morteza Zadimoghaddam. Consistent hashing with bounded loads. CoRR, 2016. [20] Rasmus Pagh. Basic external memory data structures. Algorithms for Memory Hierarchies, pages 14–35, 2003. [21] Salvatore Pontarelli, Pedro Reviriego, and Michael Mitzenmacher. EMOMA: exact match in one memory access. CoRR, abs/1709.04711, 2017. [22] M. V. Ramakrishna and Walid R. Tout. Dynamic external hashing with guaranteed single access retrieval, pages 187–201. Springer Berlin Heidelberg, Berlin, Heidelberg, 1989. [23] Ion Stoica, Robert Morris, David Liben-Nowell, David R. Karger, M. Frans Kaashoek, Frank Dabek, and Hari Balakrishnan. Chord: a scalable peer-to-peer lookup protocol for Internet applications. IEEE/ACM Transactions on Networking, 11(1):17–32, February 2003. [24] David Thaler and Chinya V. Ravishankar. Using name-based mappings to increase hit rates. IEEE/ACM Trans. Netw, 6(1):1–14, 1998. [25] Sebastiano Vigna. xoroshiro128+: an extremely fast and well-distributed pseudo random number generator. http://xoroshiro.di.unimi.it/, 2018. [26] Wei Wang and Chinya V. Ravishankar. Hash-based virtual hierarchies for scalable location service in mobile ad-hoc networks. Mobile Networks and Applications, 14(5):625–637, 2009. A Analysis of stash size with a uniform hash function In the following, we consider the arcs along the circle handled by round-mapping as buckets. To give bounds on the expected stash size for a hash function that does not map a value into a bucket equiprobably [9], we will first study the expected number of elements that overflow from a bucket of size B that is expected to reach a load factor of 1 − δ, i.e. when any of the n values are mapped to that bucket with probability O . We will consider the cases in which δ = 0, δ < 0 and 0 < δ < 1 separately. (cid:16) B(1−δ) (cid:17) n The number of values that are assigned to the given bucket is a random variable with binomial distribution B , which, as n grows, can be approximated with a normal variable with distribution N (B(1 − δ), B(1 − δ)). The number of values that overflow from that bucket is given by n, B(1−δ) n (cid:16) (cid:17) 14 1. 0 if x < B values end up in that bucket. 2. x − B if x ≥ B values end up in that bucket. (cid:90) ∞ From this follows that the expected number of overflown values from the bucket is given by With some calculations, we find out that the value of this integral is given by B 1(cid:112)2πB(1 − δ) (cid:112)B(1 − δ)e − B 2 δ2 1−δ √ 2π (x − B)e (x−B(1−δ))2 2B(1−δ) dx (cid:32)√ − δB 2 erfc (cid:33) δ(cid:112)2(1 − δ) B where erfc is the complementary error function. A.1 Case δ = 0 (cid:113) B In this case, we easily get that the expected number of values that overflow from a single bucket is 2π . We can use this result to bound the stash size in the case  = 0 with a uniform hash function: indeed, we get that the expected size of the stash grows as A.2 Case δ > 0 n√ 2πB . As 0 < erfc(x) < 2, we remark that the first term of the above expression is an upper bound. This, as before, proves that the size of the stash with an uniform hash function grows at most as √ which decreases exponentially in B. Under the assumption that  erfc in the above expression with its Taylor series to get a bound of B is big enough, we can replace − B (cid:112)2πB(1 − ) 2 1− e 2 n √ 1 −  √ 2πB n 2B − B 2 2 1− e that improves the previous one by a factor of 1 and  are large enough. B . Of course, this second bound only holds when B A.3 Case δ < 0 In this case, we can replace erfc with its upper bound 2 and ignore the first term, as it is quite smaller than the second one. By multiplying by the number of buckets as in the previous cases, we get the bound of n −δ 1−δ for a hash table that tries to fit n values in buckets that only have space for 1−δ , as one would expect. This corresponds to an expected stash size per bucket of −δB. n 15 B Analysis of stash size with round-hashing s0 s ≤ 1 + 1 Our version of consistent hashing guarantees that, at any time, the expected load on the most-loaded bucket will be, at most, 1 + 1 times the expected load on the least-loaded one. We can give an upper bound for the load factor of those buckets as (1 − )(1 + 1 ) ≤ 1 −  + 1 . If s0 > 2  , our hash table implemented with round-mapping this version of consistent hashing will behave at least as well as a hash table implemented with uniform hashing and a load factor of 1 −  2 , in terms of stash size. We will now consider what happens when s0 ≤ 1  . For simplicity, we will first study the behavior of the stash in the first step s = s0 of every round. Let c be the number of buckets that was present the last time the buckets were all equally sized, and let c + q be the current number of buckets. We know that there are c − s0q buckets with size proportional to 1 c and (s0 + 1)q buckets with size . As the second kind of buckets is less loaded than they should be proportional to s0 s0 s0 c(1+s0) = 1 c+ c s0 with a uniform hash function, we will ignore them as they will not contribute to the stash more than the uniform case. c keys, while only having space for B. Thus, the c − s0q bigger buckets will behave as buckets that have a load factor of 1 − δ with δ given by We expect each of the bigger buckets to be assigned n (cid:18) (cid:19) −δ = = 1 + q c (1 − ) − 1 ≈ q c −  where we used the fact that c + q = n size of B(1−) . The analysis in Subsection A gives us an expected stash (c − s0q) B = n(1 − ) Since c > s0q, we can use standard tools from analysis to find that the maximum value of this n B c − B (cid:18) q c (cid:19) −  (cid:115)(cid:18) function is realized when with a value of n(1 − ) q c = 1 + (cid:34) 1 + s0 − 2s0 (1 − s0 c − ) q c )( q 1 + q c (cid:19) (cid:32)(cid:115)(cid:18) 1 s0 (1 + ) − 1 (cid:19) 1 + 1 s 0 (cid:33)(cid:35) (1 + ) − 1 Note that this expression is decreasing in s0: this proves that the worst-case behavior for stash occurs in the first step of a round, and the above formula actually gives an upper bound on the amount of keys in the stash. (1 − s0)2. Ignoring smaller terms as s0 grows and  goes to 0, we can rewrite the expression asn 1− In particular, when  = 0, we expect the additional stack size (wrt. a uniform hash function) to 4s0 grow as n 4s0 . C Keeping an external-memory copy of the stash In practical applications, it may be useful to keep a copy of the stash on external memory (for example, to have a copy in case of application crashes). We now show a variation on our hash table that achieves this at the cost of increasing the number of block transfer for the updates by an expected constant factor. To achieve this, we treat the "leftover" space in underflown buckets as an array (because of our allocation rule, we know that there is always enough "leftover" space to store 16 the full contents of the stash). We start by filling it from the lowest-indexed bucket and proceed on towards buckets with bigger indexes. To insert a key in the stash on external memory, we try to fit it in the last underflown block used. If the block is full, we find a new block by scanning all the buckets on the left until we find a non-full one: this process will terminate in O(1) block transfers w.h.p.6, as a bucket is not full with probability at least 1 2 . Deletion works in a similar way: if the key to be deleted is not in the last position of our virtual array, we swap it with the last one and go back one position. If we want to insert a "legitimate" key in a block that has stash keys in it, we can identify a stash key since it has the incorrect hash for its bucket. We can then move it to the front of the virtual array and proceed as usual. We proceed in the opposite way if space is freed up in a block that should be used in the virtual array. It remains to see how we reassign the keys after a newBucket() or freeBucket() operation. In the worst case, it may cause us to perform O(s0B) stash operations, which could require up to O(s0B) block transfers. However, we may decide to delay those stash operations, doing O(s0) of them on each of the subsequent update operations, without causing significant changes in how the hash table performs. We can compute the expected number of stash operations and prove that this method performs better in expectation, without requiring O(s0) operations per update. We consider the case of newBucket(), as freeBucket() behaves in the same way. We use the results of Subsection A. Since, before looking into the the stash, we move values within the buckets themselves, the number of stash operations may be bounded by the number of empty cells in the buckets after internal re-arranging. As the load factor on those buckets will be approximately 1 −  − 1 , we expect s0 of those buckets to still have space for B(s0 + 1) elements, plus the elements that were put into the stash. We can give an upper bound for the elements that are put into the stash during this procedure by increasing the load factor to 1− 1 (cid:114) and using the formulas we obtain from the analysis: (cid:16) − s0 s0 B (cid:17) 1 − 1 √ s0 B 2s2 0(1− 1 s0 ) e 2π (s0 + 1) √ √ B + B This can be bounded as 2 number of stash insertions by O(B). π τ e−τ 2 for some τ . Since τ e−τ 2 < 1, we can bound the total This gives a total of O(B(1 + s0)) stash operations. By delaying some of them to the next O(B) updates, we get an expected number of block transfers per operation of O(1 + s0), which is constant as long as s0 is not chosen too big (in particular, it is constant for s0 = 2  ). D Stash sizes for B = 512 and B = 2048 6If we want to reduce the number of block transfers, we can keep an in-memory dictionary that holds the indexes of the buckets that are full, because of keys not in the stash, and perform our scans on that data structure: the expected number of full buckets is smaller than the expected stash size. 17 s0 0 0.001 0.01 0.03 0.05 0.1  est. real est. est. real real real est. est. 1 17.2% 18.9% 17.1% 18.8% 16.7% 17.9% 15.9% 16.1% 15.1% 14.7% 12% 4 1.7% 5.6% 7.3% 5.5% 7.2% 5.1% 6.4% 4.2% 4.8% 3.4% 3.6% 16 2.2% 3.3% 2.1% 3.2% 1.7% 2.4% 1% 0.5% 0.3% 0.06% 0.4% 32 1.9% 2.5% 1.8% 2.4% 1.4% 1.7% 0.8% 0.7% 0.4% 0.9% 0.03% 0.09% 64 1.9% 2.2% 1.7% 2.1% 1.4% 1.4% 0.7% 1.1% 0.4% 0.5% 0.03% 0.04% 256 1.9% 1.9% 1.7% 1.8% 1.3% 1.5% 0.7% 0.8% 0.4% 0.3% 0.03% 0.02% ideal 0.01% 13% 1.7% 0.3% 0.7% 1.3% 1.7% 1.8% real real est. 1% - - - - - - Table 4: Percentage of elements on the stash as s0 and  change, with B = 512. s0 0 0.001 0.01  0.03 0.05 0.1 real est. real est. real est. real est. real est. real est. 1 17.2% 18% 17.1% 17.9% 16.7% 17.1% 15.9% 15.6% 15.1% 14.4% 4 3.3% 16 32 64 256 ideal 12% 1.7% 5.6% 6.5% 5.5% 6.4% 5.1% 5.5% 4.2% 4.2% 0.02% 1.6% 2.4% 1.5% 2.3% 1.1% 1.5% 0.5% 0.5% 1.1% 1.7% 1% 1.6% 0.6% 0.8% 0.2% 0.09% 0.03% 0.2% 0.0002% 0.0002% 0.9% 1.3% 0.8% 1.2% 0.5% 0.5% 0.1% 0.3% 0.02% 0.05% 0.0001% 1e-05% 0.9% 1% 0.8% 0.9% 0.5% 0.6% 0.1% 0.1% 0.01% 0.01% 0.0002% 1e-06% 4e-07% 13% 3.4% 1.6% 0.2% 0.06% 0.0009% 0.008% 0.09% 0.8% 0.5% 0.9% - - - - - - Table 5: Percentage of elements on the stash as s0 and  change, with B = 2048. E Pseudocode Algorithm 2: Lookup algorithm 1 Function lookup(x) 2 if x ∈ stash then return true b ← findBucket(h(x)/I) if x ∈ block(b) then return true return false 3 4 5 18 Algorithm 3: Insertion algorithm 1 Function insert(x) 2 if lookup(x) then return false n ← n + 1 B(1−)(cid:101) > numBuckets() then if (cid:100) distribute(newBucket()) //initially n = 0 n b ← findBucket(h(x)/I) if block(b) < B then block(b) = block(b) ∪ {x} else stash = stash ∪ {x} return true 3 4 5 6 7 8 9 10 11 4 5 6 7 8 9 10 11 12 13 14 15 Algorithm 4: Deletion algorithm 1 Function delete(x) found = false 2 if x ∈ stash then 3 stash = stash \ {x} found = true else b ← findBucket(h(x)/I) if x ∈ block(b) then block(b) = block(b) \ {x} found = true if found then n ← n − 1 if n > 0 and (cid:100) B(1−)(cid:101) < numBuckets() − 1 then n distribute(freeBucket()) return found 19
1612.03856
1
1612
2016-12-12T19:14:47
Improved Algorithms for Decremental Single-Source Reachability on Directed Graphs
[ "cs.DS" ]
Recently we presented the first algorithm for maintaining the set of nodes reachable from a source node in a directed graph that is modified by edge deletions with $o(mn)$ total update time, where $m$ is the number of edges and $n$ is the number of nodes in the graph [Henzinger et al. STOC 2014]. The algorithm is a combination of several different algorithms, each for a different $m$ vs. $n$ trade-off. For the case of $m = \Theta(n^{1.5})$ the running time is $O(n^{2.47})$, just barely below $mn = \Theta(n^{2.5})$. In this paper we simplify the previous algorithm using new algorithmic ideas and achieve an improved running time of $\tilde O(\min(m^{7/6} n^{2/3}, m^{3/4} n^{5/4 + o(1)}, m^{2/3} n^{4/3+o(1)} + m^{3/7} n^{12/7+o(1)}))$. This gives, e.g., $O(n^{2.36})$ for the notorious case $m = \Theta(n^{1.5})$. We obtain the same upper bounds for the problem of maintaining the strongly connected components of a directed graph undergoing edge deletions. Our algorithms are correct with high probabililty against an oblivious adversary.
cs.DS
cs
Improved Algorithms for Decremental Single-Source Reachability on Directed Graphs∗ Monika Henzinger† Sebastian Krinninger† Danupon Nanongkai‡ Abstract Recently we presented the first algorithm for maintaining the set of nodes reachable from a source node in a directed graph that is modified by edge deletions with o(mn) total update time, where m is the number of edges and n is the number of nodes in the graph [Henzinger et al. STOC 2014]. The algorithm is a combination of several different algorithms, each for a different m vs. n trade-off. For the case of m = Θ(n1.5) the running time is O(n2.47), just barely below mn = Θ(n2.5). In this paper we simplify the previous algorithm using new algorithmic ideas and achieve an improved running time of O(min(m7/6n2/3, m3/4n5/4+o(1), m2/3n4/3+o(1)+m3/7n12/7+o(1))). This gives, e.g., O(n2.36) for the notorious case m = Θ(n1.5). We obtain the same upper bounds for the problem of maintaining the strongly connected components of a directed graph undergoing edge deletions. Our algorithms are correct with high probabililty against an oblivious adversary. ∗This paper was presented at the International Colloquium on Automata, Languages and Programming (ICALP) 2015. A full version combining the findings of this paper and its predecessor [HKN14] is available at http://arxiv.org/abs/1504.07959. †University of Vienna, Faculty of Computer Science, Austria. Supported by the Austrian Science Fund (FWF): P23499-N23 and the University of Vienna (IK I049-N). The research leading to these results has received funding from the European Research Council under the European Union's Seventh Framework Programme (FP/2007-2013) / ERC Grant Agreement no. 340506. ‡KTH Royal Institute of Technology, Sweden. Work partially done while at University of Vienna, Faculty of Computer Science, Austria. 1 1 Introduction In this paper we study the decremental reachability problem. Given a directed graph G with n nodes and m edges and a source node s in G a decremental single-source reachability algorithm maintains the set of nodes reachable from s (i.e., all nodes v for which there is a path from s to v in the current version of G) during a sequence of edge deletions. The goal is to minimize the total update time, i.e., the total time needed to process all deletions such that reachability queries can be answered in constant time. A decremental s-t reachability algorithm is given a graph G undergoing edge deletions, a source node s, and a sink node t and it determines after every deletion in G whether s can still reach t. Related Work. The incremental version of the single-source reachability problem, in which edges are inserted into the graph, can be solved with a total update time of O(m) by performing an incremental graph search, where m is the final number of edges. Italiano [Ita88] showed that in directed acyclic graphs the decremental problem can be solved in time O(m) as well. In general directed graphs however, the problem could for a long time only be solved in time O(mn) using the more general decremental single-source shortest paths algorithm of Even and Shiloach [ES81, HK95, Kin99], which maintains a breadth-first search tree rooted at s, called ES-tree. This upper bound of O(mn) is also achieved for the seemingly more complex decremental all-pairs reachability problem (also known as transitive closure) [RZ08, Lac13]. In the fully dynamic version of single-source reachability both insertions and deletions of edges are possible. The matrix-multiplication based transitive closure algorithms of Sankowski [San04] give fully dynamic algorithms for single-source reachability and s-t reachability with worst-case running times of O(n1.575) and O(n1.495) per update, respectively. These upper bounds have recently been complemented by Abboud and Vassilevska Williams [AVW14] as follows. For the decremental s-t reachability problem, a combinatorial algorithm with a worst-case running time of O(n2−δ) (for some δ > 0) per update or query implies a faster combinatorial algorithm for Boolean matrix multiplication and, as has been shown by Vassilevska Williams and Williams [VWW10], for other problems as well. (For non- combinatorial algorithms, Henzinger et al. [HKN+15] showed that there is no algorithm with worst-case O(n1−δ) update and O(n2−δ) query time, assuming the so-called Online Matrix- Vector Multiplication conjecture.) Furthermore, for the problem of maintaining the number of nodes reachable from a source under deletions (which our algorithms can do) a worst-case running time of O(m1−δ) (for some δ > 0) per update or query falsifies the strong exponential time hypothesis. Thus, amortization is indeed necessary to bypass these bounds. In [HKN14] we recently improved upon the long-standing upper bound of O(mn) for decremental single-source reachability in directed graphs. In particular, we developed several algorithms whose combined expected running time is polynomially faster than O(mn) for all values of m (i.e., for all possible densities of the initial graph). By a reduction from single-source reachability, our results in [HKN14] immediately give an o(mn) algorithm for maintaining strongly connected components under edge deletions. Previously, the fastest decremental algorithms for this problem had a total update time of O(mn) as well [RZ08, Lac13, Rod13]. 2 Our Results. In this paper we improve upon the upper bounds provided in [HKN14]. Furthermore, the running times achieved in this paper are arguably more natural than those in [HKN14]. Although we previously broke the O(mn) barrier for all values of m, we barely did so, giving a bound of O(n2.47), when m = Θ(n1.5). In this paper we also get a better improvement, namely O(n2.36) in this notorious case. In general, we can combine the algorithms of this paper to obtain a running time of O(mn0.9+o(1)), whereas in [HKN14] we obtained O(mn0.984). In [HKN14] the starting point was to solve the decremental s-t reachability problem, which is also the case here. For this problem we obtain two algorithms with total update times of O(min(m5/4n1/2, m2/3n4/3+o(1))) and O(m2/3n4/3+o(1) + m3/7n12/7+o(1)), respectively. Just as in [HKN14], extensions of these algorithms solve the decremental single-source reachability problem with total update times of O(min(m7/6n2/3, m3/4n5/4+o(1))) and O(m2/3n4/3+o(1) + m3/7n12/7+o(1)), respectively. Furthermore, it follows from a reduction [RZ08, HKN14] that there are algorithms for the decremental strongly connected components problem whose running times are the same up to a logarithmic factor. We compare these new results to the ones of [HKN14] in Figure 1. All our algorithms are correct with high probability who fixes its sequence of updates and queries before the algorithm is initialized and their running time bounds hold in expectation. Due to space constraints this paper only contains an overview of the algorithm that has a total update time of O(m2/3n4/3+o(1) + m3/7n12/7+o(1)) and is thus the current fastest for dense graphs. The other algorithm and all omitted proofs can be found in the full version of this paper. Comparison of running times for decremental single-source reachability 3 β e m i t g n i n n u R 2.8 2.6 2.4 2.2 2 1.8 1.6 1 1.2 Even-Shiloach [ES81, HK95] Previous paper [HKN14] This paper 1.8 1.4 1.6 Graph density α 2 Figure 1: Running times of decremental single-source reachability algorithms dependent on the density of the initial graph. A point (α, β) in this diagram means that for a graph with m = Θ(nα) the algorithm has a running time of O(nβ+o(1)). 3 Techniques. There are two novel technical contributions: (1) The algorithm of [HKN14] uses two kinds of randomly selected nodes, called hubs and centers, each fulfilling a different purpose. Maintaining an ES-tree for each hub up to depth h, it quickly tests for every pair of centers (x, y) whether there is a path of length at most 2h from x to y going through a hub. If there is no such path, we build a special graph, called path union graph, for the pair (x, y) that contains all paths of length O(h) from x to y. Since there no longer is a path from x to y through a hub of length at most h, we know that their path union graph is "smaller" than the original graph. In this paper we show how to extend this approach multiple layers of path unions graphs. Hubs and centers of the previous algorithms become level k, resp. k − 1 centers in the new approach. Level k − 1 centers serve as hubs for the level k − 2 centers, and more generally level i centers serve as hubs for level i − 1 centers. To do this efficiently we build the ES-tree for a level i center x inside the path-union graph of x and another, potentially higher-level center. The fact that we use the smaller path-union graph instead of the original graph for these ES-trees (together with an improved data structure for computing path-union graphs, see (2) below) gives the improvement in the running time. (2) In [HKN14] we maintain for each center x an approximate path union data structure that computes a superset of the path union of x and any other center y. This superset is an approximation of the path union graph for (x, y) as it might contain paths between the two centers of length O(h log n) (and not as desired O(h)), but no longer. The total time spent in this data structure for x is (a) the size of the constructed path union graph and (b) a one-time "global charge" for using this data structure of O(n2). It is based on a hierarchical graph decomposition technique. Here we present a much simpler data structure that also constructs an approximate path union graph, but that does not require any hierarchical graph decomposition. This reduces the global charge per center from O(n2) to O(m). We believe that this data structure is of independent interest. Outline. In Section 2 we give the preliminaries. In Section 3 we present our new path union data structure. Finally, in Section 4 we show how to combine this idea with the multi-layer path union approach to obtain a faster decremental single-source reachability algorithm for dense graphs. 2 Preliminaries In this section we review some notions and basic facts that we will use in the rest of this paper. We use the following notation: We consider a directed graph G = (V, E) undergoing edge deletions, where V is the set of nodes of G and E is the set of edges of G. We denote by n the number of nodes of G and by m the number of edges of G before the first edge deletion. For every pair of nodes u and v we denote the distance from u to v in G by dG(u, v). For every subset of nodes U ⊆ V , we define E(U) = E ∩ U 2 and denote by G[U] = (U, E[U]) the subgraph of G induced by U. For sets of nodes U ⊆ V and U0 ⊆ V we define E(U, U0) = E ∩ (U × U0), i.e., E(U, U0) is the set of edges (u, v) ∈ E such that u ∈ U and v ∈ U0. We write O(T(m, n)) as an abbreviation for O(T(m, n) · no(1)). 4 Like many decremental shortest paths and reachability algorithms, our algorithms internally use a data structure for maintaining a shortest paths tree up to a relatively small depth. Theorem 2.1 (Even-Shiloach tree [ES81, HK95, Kin99]). There is a decremental algorithm, called Even-Shiloach tree (short: ES-tree), that, given a directed graph G undergoing edge deletions, a source node s, and a parameter h ≥ 1, maintains a shortest paths tree from s and the corresponding distances up to depth h with total update time O(mh), i.e., the algorithm maintains dG(s, v) and the parent of v in the shortest paths tree for every node v such that dG(s, v) ≤ h. By reversing the edges of G it can also maintain the distance from v to s for every node v in the same time. The central concept in the algorithmic framework introduced in [HKN14] is the notion of the path union of a pair of nodes. Definition 2.2. For every directed graph G, every h ≥ 1, and all pairs of nodes x and y of G, the path union P(x, y, h, G) ⊆ V is the set containing all nodes that lie on some path π from x to y in G of weight at most h. The path union has a simple characterization and can be computed efficiently. Lemma 2.3 ([HKN14]). For every directed graph G, every h ≥ 1 and all pairs of nodes x and y of G, we have P(x, y, h, G) = {v ∈ V dG(x, v) + dG(v, y) ≤ h}. We can compute this set in time O(m). Our algorithms use randomization in the following way: by sampling a set of nodes with a sufficiently large probability we can guarantee that certain sets of nodes contain at least one of the sampled nodes with high probability. To the best of our knowledge, the first use of this technique in graph algorithms goes back to Ullman and Yannakakis [UY91]. Lemma 2.4. Let T be a set of size t and let S1, S2, . . . , Sk be subsets of T of size at least q. Let U be a subset of T that was obtained by choosing each element of T independently with probability p = (a ln (kt))/q, for some parameter a. Then, for every 1 ≤ i ≤ k, the set Si contains a node of U with high probability (whp), i.e., probability at least 1 − 1/ta, and the size of U is O((t log (kt))/q) in expectation. 3 Approximate Path Union Data Structure In this section we present a data structure for a graph G undergoing edge deletions, a fixed node x, and a parameter h. Given a node y, it computes an "approximation" of the path union P(x, y, h, G). Using a simple static algorithm the path union can be computed in time O(m) for each pair (x, y). We give an (almost) output-sensitive data structure for this problem, i.e., using our data structure the time will be proportional to the size of the approximate path union which might be o(m). Additionally, we have to pay a global cost of O(m) that is amortized over all approximate path union computations for the node x and all nodes y. This will be useful because in our reachability algorithm we can use probabilistic arguments to bound the size of the approximate path unions. 5 Proposition 3.1. There is a data structure that, given a graph G undergoing edge deletions, a fixed node x, and a parameter h, provides a procedure ApproximatePathUnion such that, given sequence of nodes y1, . . . , yk, this procedure computes sets F1, . . . Fk guaranteeing P(x, y, h, G) ⊆ Fi ⊆ P(x, y, (log m + 3)h, G) for all 1 ≤ i ≤ k. The total running time is O(P 1≤i≤k Fi + m). 3.1 Algorithm Description Internally, the data structure maintains a set R(x) of nodes, initialized with R(x) = V , such that the following invariant is fulfilled at any time: all nodes that can be reached from x by a path of length at most h are contained in R(x) (but R(x) might contain other nodes as well). Observe that thus R(x) contains the path union P(x, y, h, G) for every node y. To gain some intuition for our approach consider the following way of computing an approximation of the path union P(x, y, h, G) for some node y. First, compute B1 = {v ∈ R(x) dG[R(x)](v, y) ≤ h} using a backward breadth-first search (BFS) to y in G[R(x)], the subgraph of G induced by R(x). Second, compute F = {v ∈ R(x) dG[B1](x, v) ≤ h} using a forward BFS from x in G[B1]. It can be shown that P(x, y, h, G) ⊆ F ⊆ P(x, y, 2h, G).1 Given B1, we could charge the time for computing F to the set F itself, but we do not know how to pay for computing B1 as B1 \ F might be much larger than F. Our idea is to additionally identify a set of nodes X ⊆ {v ∈ V dG(x, v) > h} and remove it from R(x). Consider a second approach where we first compute B1 as above and then compute B2 = {v ∈ R(x) dG[R(x)](v, y) ≤ 2h} and F = {v ∈ R(x) dG[B2](x, v) ≤ h}. It can be shown that P(x, y, h, G) ⊆ F ⊆ P(x, y, 3h, G). Additionally, all nodes in X = B1 \ F are at distance more than h from x and therefore we can remove X from R(x). Thus, we can charge the work for computing B1 and F to X and F, respectively.2 However, we now have a similar problem as before as we do not know whom to charge for computing B2. We resolve this issue by simply computing Bi = {v ∈ R(x) dG[R(x)](v, y) ≤ ih} for increasing values of i until we arrive at some i∗ such that the size of Bi∗ is at most double the size of Bi∗−1. We then return F = {v ∈ R(x) dG[Bi](x, v) ≤ h} and charge the time for computing Bi to X = Bi−1 \ F and F, respectively. As the size of Bi can double at most O(log n) times we have P(x, y, h, G) ⊆ F ⊆ P(x, y, O(h log n), G), as we show below. Procedure 1 shows the pseudocode of this algorithm. Note that in the special case that x cannot reach y the algorithm returns the empty set. In the analysis below, let i∗ denotes the final value of i before Procedure 1 terminates. 3.2 Correctness We first prove Invariant (I): the set R(x) always contains all nodes that are at distance at most h from x in G. This is true initially as we initialize R(x) to be V and we now show that it 1Indeed, F might contain some node v with dG(x, v) = h and dG(v, y) = h, but it will not contain any node 2Note that in our first approach removing B1 \ F would not have been correct as F was computed w.r.t to w with either dG(x, w) > h or dG(w, y) > h. G[B1] and not w.r.t. G[B2]. 6 Procedure 1: ApproximatePathUnion(y) // All calls of ApproximatePathUnion(y) use fixed x and h. 1 Compute B1 = {v ∈ R(x) dG[R(x)](v, y) ≤ h} // backward BFS to y in subgraph 2 for i = 2 to dlog me + 1 do 3 induced by R(x) Compute Bi = {v ∈ R(x) dG[R(x)](v, y) ≤ ih} // backward BFS to y in if E(Bi) ≤ 2E(Bi−1) then 4 5 6 7 subgraph induced by R(x) Compute F = {v ∈ Bi dG[Bi](x, v) ≤ h} // forward BFS from x in X ← Bi−1 \ F, R(x) ← R(x) \ X return F subgraph induced by Bi continues to hold because we only remove nodes at distance more than h from x. Lemma 3.2. If R(x) ⊆ {v ∈ V dG(x, v) ≤ h}, then for every node v ∈ X removed from R(x), we have dG(x, v) > h. Proof. Let v ∈ X = Bi∗−1 \ F and assume by contradiction that dG(x, v) ≤ h. Since v ∈ Bi∗−1 we have dG[R(x)](v, y) ≤ (i∗ − 1)h. Now consider the shortest path π from x to v in G, which has length at most h. By the assumption, every node on π is contained in G[R(x)]. Therefore, for every node v0 on π, we have dG[R(x)](v0, v) ≤ h and thus dG[R(x)](v0, y) ≤ dG[R(x)](v0, v) + dG[R(x)](v, y) ≤ h + (i∗ − 1)h ≤ i∗h which implies that v0 ∈ Bi∗. Thus, every node on π is contained in Bi∗. As π is a path from x to v of length at most h it follows that dG[Bi∗](x, v) ≤ h. Therefore v ∈ F, which contradicts the assumption v ∈ X. We now complete the correctness proof by showing that the set of nodes returned by the algorithm approximates the path union. Lemma 3.3. Procedure 1 returns a set of nodes F such that P(x, y, h, G) ⊆ F ⊆ P(x, y, (log m+ 3)h, G). Proof. We first argue that the algorithm actually returns some set of nodes F. Note that in Procedure 1 of the algorithm we always have E(Bi) ≥ E(Bi−1) as Bi−1 ⊆ Bi. As E(Bi) is a set of edges and the total number of edges is at most m, the condition E(Bi) ≤ E(Bi−1) therefore must eventually be fulfilled for some 2 ≤ i ≤ dlog me + 1. We now show that P(x, y, h, G) ⊆ F. Let v ∈ P(x, y, h, G), which implies that v lies on a path π from x to y of length at most h. For every node v0 on π we have dG(x, v0) ≤ h, which by Invariant (I) implies v0 ∈ R(x). Thus, the whole path π is contained in G[R(x)]. Therefore 7 dG[R(x)](v0, y) ≤ h for every node v0 on π which implies that π is contained in G[Bi∗]. Then clearly we also have dG[Bi∗](x, v) ≤ h which implies v ∈ F. Finally we show that F ⊆ P(x, y, (log m + 3)h, G) by proving that dG(x, v) + dG(v, y) ≤ (log m + 3)h for every node v ∈ F. As G[Bi∗] is a subgraph of G, we have dG(x, v) ≤ dG[Bi∗](x, v) and dG(v, y) ≤ dG[Bi∗](v, y). By the definition of F we have dG[Bi∗](x, v) ≤ h. As F ⊆ Bi∗ we also have dG[Bi∗](v, y) ≤ i∗h ≤ (dlog me + 1)h ≤ (log m + 2)h. It follows that dG(x, v) + dG(v, y) ≤ h + (log m + 2)h = (log m + 3)h. 3.3 Running Time Analysis To bound the total running time we prove that each call of Procedure 1 takes time proportional to the number of edges in the returned approximation of the path union plus the number of edges incident to the nodes removed from R(x). As each node is removed from R(x) at most once, the time spent on all calls of Procedure 1 is then O(m) plus the sizes of the subgraphs induced by the approximate path unions returned in each call. Lemma 3.4. The running time of Procedure 1 is O(E(F) + E(X, R(x)) + E(R(x), X)) where F is the set of nodes returned by the algorithm, and X is the set of nodes the algorithm removes from R(x). Proof. The running time in iteration 2 ≤ j ≤ i∗ − 1 is O(E(Bj)) as this is the cost of In the last iteration i∗, the algorithm the breadth-first-search performed to compute Bj. additionally has to compute F and X and remove X from R(x). As F is computed by a BFS time is O(P in G[Bi∗] and X ⊆ Bi∗−1 ⊆ Bi∗, these steps take time O(E(Bi∗)). Thus the total running By checking the size bound in Line 4 of Procedure 1 we have E(Bj) > 2E(Bj−1) for follows thatP all 1 ≤ j ≤ i∗ − 1 and E(Bi∗) ≤ 2E(Bi∗−1). By repeatedly applying the first inequality it X 1≤j≤i∗−1 E(Bj) ≤ 2E(Bi∗−1). Therefore we get 1≤j≤i∗ E(Bj)). E(Bj) = X ≤ 2E(Bi∗−1) + 2E(Bi∗−1) = 4E(Bi∗−1) and thus the running time is O(E(Bi∗−1)). Now observe that by X = Bi∗−1 \ F we have Bi∗−1 ⊆ X ∪ F and thus E(Bi∗−1) ⊆ E(F) ∪ E(X) ∪ E(X, F) ∪ E(F, X) ⊆ E(F) ∪ E(X, R(x)) ∪ E(R(x), X) . Therefore the running time is O(E(F) + E(X, R(x)) + E(R(x), X)). 4 Reachability via Center Graph We now show how to combine the approximate path union data structure with a hierarchical approach to get an improved decremental reachability algorithm for dense graphs. The algorithm 8 1≤j≤i∗ 1≤j≤i∗−1 E(Bj) + E(Bi∗) has a parameter 1 ≤ k ≤ log n and for each 1 ≤ i ≤ k a parameter ci ≤ n. We determine suitable choices of these parameters in Section 4.2. For each 1 ≤ i ≤ k − 1, our choice will satisfy ci ≥ ci+1 and ci = O(ci+1). Furthermore, we set hi = (3 + log m)i−1n/c1 for 1 ≤ i ≤ k. At the initialization, the algorithm determines sets of nodes C1 ⊇ C2 ⊇ ··· ⊇ Ck such that s, t ∈ C1 as follows. For each 1 ≤ i ≤ k, we sample each node of the graph with probability aci ln n/n (for a large enough constant a), where the value of ci will be determined later. The set Ci then consists of the sampled nodes, and if i ≤ k − 1, it additionally contains the nodes in Ci+1. For every 1 ≤ i ≤ k we call the nodes in Ci i-centers. In the following we describe an algorithm for maintaining pairwise reachability between all 1-centers. 4.1 Algorithm Description Data Structures. The algorithm uses the following data structures: • For every i-center x and every i ≤ j ≤ k an approximate path union data structure (see Proposition 3.1) with parameter hj. • For every k-center x an incoming and an outgoing ES-tree of depth hk in G. • For every pair of an i-center x and a j-center y such that l := max(i, j) ≤ k − 1, a set of nodes Q(x, y, l) ⊆ V . Initially, Q(x, y, l) is empty and at some point the algorithm might compute Q(x, y, l) using the approximate path union data structure of x. • For every pair of an i-center x and a j-center y such that l := max(i, j) ≤ k − 1 an ES-tree of depth hl from x in Q(x, y, l). • For every pair of an i-center x and a j-center y such that l := max(i, j) ≤ k − 1 a set of (l + 1)-centers certifying that x can reach y. Certified Reachability Between Centers (Links). The algorithm maintains the following limited path information between centers, called links, in a top-down fashion. Let x be a k-center and let y be an i-center for some 1 ≤ i ≤ k − 1. The algorithm links x to y if and only if y is contained in the outgoing ES-tree of depth hk of x. Similarly the algorithm links y to x if and only if y is contained in the incoming ES-tree of depth hk of x. Let x be an i-center and let y be a j-center such that l := max(i, j) ≤ k − 1. If there is an (l + 1)-center z such that x is linked to z and z is linked to y, the algorithm links x to y (we also say that z links x to y). Otherwise, the algorithm computes Q(x, y, l) using the approximate path union data structure of x and starts to maintain an ES-tree from x up to depth hl in G[Q(x, y, l)]. It links x to y if and only if y is contained in the ES-tree of x. Using a list of centers z certifying that x can reach y, maintaining the links between centers is straightforward. Center Graph. The algorithm maintains a graph called center graph. Its nodes are the 1-centers and it contains the edge (x, y) if and only if x is linked to y. The algorithm maintains the transitive closure of the center graph. A query asking whether a center y is reachable from 9 a center x in G is answered by checking the reachability in the center graph. As s and t are 1-centers this answers s-t reachability queries. Correctness. For the algorithm to be correct we have to show that there is a path from s to t in the center graph if and only if there is a path from s to t in G. We can in fact show more generally that this is the case for any pair of 1-centers. Lemma 4.1. For every pair of 1-centers x and y, there is a path from x to y in the center graph if and only if there is a path from x to y in G. 4.2 Running Time Analysis The key to the efficiency of the algorithm is to bound the size of the graphs Q(x, y, l). Lemma 4.2. Let x be an i-center and let y be a j-center such that l := max(i, j) ≤ k − 1. If x is not linked to y by an (l + 1)-center, then Q(x, y, l) contains at most n/cl+1 nodes with high probability. With the help of this lemma we first analyze the running time of each part of the algorithm and argue that our choice of parameters gives the desired total update time. √ Parameter Choice. We carry out the running time analysis with regard to two parameters 1 ≤ b ≤ c ≤ n which we will set at the end of the analysis. We set k = d(log (c/b))/( log n·log log nci+1 = O(ci+1) for 1 ≤ i ≤ k − 1. Note that the number of 1, ck = b and ci = 2 i-centers is O(ci) in expectation. Observe that √ log n/ log log n) √ log n·log log n) = O(n = O(2 (3 + log m)k−1 = O((log n)k) ≤ O((log n) log log n/ log n) = O(no(1)) . √ √ log n · log log n)e+ Furthermore we have √ c1 =(cid:16)2 log n·log log n(cid:17)k−1 log n·log log n(cid:17)k−1 ck ≤(cid:16)2 √ c1 =(cid:16)2 √ √ and by setting k0 = (log (c/b))/( log n · log log n) we have k ≤ k0 + 2 and thus ck ≥ 2log (c/b)b = c b · b = c log n·log log n(cid:17)k0+1 √ ck = 2 log n·log log nc = O(c) . Remember that hi = (3 + log m)i−1n/c1 for 1 ≤ i ≤ k. Therefore we have hi = O(n/c1) = O(n/c). 10 Maintaining ES-Trees. For every k-center we maintain an incoming and an outgoing ES- tree of depth hk, which takes time O(mhk). As there are O(ck) k-centers, maintaining all these trees takes time O(ckmhk) = O(bmn/c). For every i-center x and every j-center y such that l := max(i, j) ≤ k − 1, we maintain an ES-tree up to depth hl in G[Q(x, y, l)]. By Lemma 4.2 Q(x, y, l) has at most n/cl+1 nodes and thus G[Q(x, y, l)] has at most n2/c2 l+1 edges. Maintaining this ES-tree therefore takes time O((n2/c2 l+1)). In total, maintaining all these trees takes time l+1) · hl) = O(n2/c2  n3 ck  = O ! k2 n3 ck ! . n3 b = O  X O X cicj n3 c1c2 i+1 1≤i≤k−1 1≤j≤i  = O  X l+1(n/c1)) = O(n3/(c1c2 X  X 1≤i≤k−1 = O 1≤j≤i cic1n3 ci+1c1ck X 1≤i≤k−1 1≤j≤i Computing Approximate Path Unions. For every i-center x and every i ≤ j ≤ k we maintain an approximate path union data structure with parameter hj. By Proposition 3.1 this data structures has a total running time of O(m) and an additional cost of O(E(Q(x, y, j))) each time the approximate path union Q(x, y, j) is computed for some j-center y. By Lemma 4.2 the number of nodes of Q(x, y, j) is n/cj+1 with high probability and thus its number of edges is n2/c2  X j+1. Therefore, computing all approximate path unions takes time c1m + c1cjn2 != O cim + cicj X  X != O(k2c1m + k2c1n2/ck)= O(cm + cn2/b) . ! n2 c2 j+1 c1m + c1n2 X  X X 1≤i≤k−1 1≤i≤k−1 = O cj+1ck i≤j≤k i≤j≤k O 1≤i≤k−1 i≤j≤k ck time needed for maintaining all these links is O(P Maintaining Links Between Centers. For each pair of an i-center x and a j-center y there are at most O(cl+1) (l+1)-centers that can possibly link x to y. Each such (l+1)-center is added to and removed from the list of (l+1)-centers linking x to y at most once. Thus, the total 1) = O(c3). Maintaining Transitive Closure in Center Graph. The center graph has O(c1) nodes and thus O(c2 1) edges. During the algorithm edges are only deleted from the center graph and never inserted. Thus we can use known O(mn)-time decremental algorithms for maintaining the transitive closure [RZ08, Lac13] in the center graph in time O(c3 1≤j≤i cicjci+1) = O(k2c3 1≤i≤k−1 P 1) = O(c3). running time of O(cid:0)bmn/c + n3/b + cm + c3(cid:1). By setting b = n5/3/m2/3 and c = n4/3/m1/3 Total Running Time. Since the term cn2/b is dominated by the term n3/b, we obtain a total the running time is O(m2/3n4/3 + n4/m) and by setting b = n9/7/m3/7 and c = m1/7n4/7 the running time is O(m3/7n12/7 + m8/7n4/7). 11 4.3 Decremental Single-Source Reachability The algorithm above works for a set of randomly chosen centers. Note that the algorithm stays correct if we add any number of nodes to C1, thus increasing the number of 1-centers for which the algorithm maintains pairwise reachability. If the number of additional centers does not exceed the expected number of randomly chosen centers, then the same running time bounds still apply. Using the reductions of [HKN14] this immediately implies decremental algorithms for maintaining single-source reachability and strongly connected components. Theorem 4.3. There are decremental algorithms for maintaining single-source reachability and strongly connected components with constant query time and expected total update time O(m2/3n4/3 + m3/7n12/7) that are correct with high probability against an oblivious adversary. References [AVW14] Amir Abboud and Virginia Vassilevska Williams. "Popular conjectures imply strong lower bounds for dynamic problems". In: Symposium on Foundations of Computer Science (FOCS). 2014, pp. 434–443 (cit. on p. 2). Shimon Even and Yossi Shiloach. "An On-Line Edge-Deletion Problem". In: Journal of the ACM 28.1 (1981), pp. 1–4 (cit. on pp. 2, 3, 5). Monika Henzinger and Valerie King. "Fully Dynamic Biconnectivity and Transitive Closure". In: Symposium on Foundations of Computer Science (FOCS). 1995, pp. 664–672 (cit. on pp. 2, 3, 5). [HK95] [ES81] [HKN14] Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. "Sublinear- Time Decremental Algorithms for Single-Source Reachability and Shortest Paths on Directed Graphs". In: Symposium on Theory of Computing (STOC). 2014, pp. 674–683 (cit. on pp. 1–5, 12). [Kin99] [HKN+15] Monika Henzinger, Sebastian Krinninger, Danupon Nanongkai, and Thatchaphol Saranurak. "Unifying and Strengthening Hardness for Dynamic Problems via the Online Matrix-Vector Multiplication Conjecture". In: Symposium on Theory of Computing (STOC). 2015, pp. 21–30 (cit. on p. 2). Giuseppe F. Italiano. "Finding Paths and Deleting Edges in Directed Acyclic Graphs". In: Information Processing Letters 28.1 (1988), pp. 5–11 (cit. on p. 2). Valerie King. "Fully Dynamic Algorithms for Maintaining All-Pairs Shortest Paths and Transitive Closure in Digraphs". In: Symposium on Foundations of Computer Science (FOCS). 1999, pp. 81–91 (cit. on pp. 2, 5). Jakub Łącki. "Improved Deterministic Algorithms for Decremental Reachability and Strongly Connected Components". In: ACM Transactions on Algorithms 9.3 (2013). Announced at SODA'11, p. 27 (cit. on pp. 2, 11). Liam Roditty. "Decremental maintenance of strongly connected components". In: Symposium on Discrete Algorithms (SODA). 2013, pp. 1143–1150 (cit. on p. 2). [Rod13] [Ita88] [Lac13] 12 [RZ08] [San04] [UY91] Liam Roditty and Uri Zwick. "Improved Dynamic Reachability Algorithms for Directed Graphs". In: SIAM Journal on Computing 37.5 (2008). Announced at FOCS'02, pp. 1455–1471 (cit. on pp. 2, 3, 11). Piotr Sankowski. "Dynamic Transitive Closure via Dynamic Matrix Inverse". In: Symposium on Foundations of Computer Science (FOCS). 2004, pp. 509–517 (cit. on p. 2). Jeffrey D. Ullman and Mihalis Yannakakis. "High-Probability Parallel Transitive- Closure Algorithms". In: SIAM Journal on Computing 20.1 (1991). Announced at SPAA'90, pp. 100–125 (cit. on p. 5). [VWW10] Virginia Vassilevska Williams and Ryan Williams. "Subcubic Equivalences between Path, Matrix and Triangle Problems". In: Symposium on Foundations of Computer Science (FOCS). 2010, pp. 645–654 (cit. on p. 2). 13
1304.5991
1
1304
2013-04-22T15:48:41
Approximation Algorithms for Vehicle Routing Problems with Stochastic Demands on Trees
[ "cs.DS" ]
We consider the vehicle routing problem with stochastic demands (VRPSD) on tree structured networks with a single depot. The problem we are concerned with in this paper is to find a set of tours for the vehicle with minimum expected length. Every tour begins at the depot, visits a subset of customers and returns to the depot without violating the capacity constraint. Randomized approximation algorithm achieving approximation guarantees of 2 for split-delivery VRPSD, and 3 for un-split delivery VRPSD are obtained.
cs.DS
cs
Approximation Algorithms for Vehicle Routing Problems with Stochastic Demands on Trees Shalabh Vidyarthi and Kaushal K Shukla Department of Computer Engineering Indian Institute of Technology (BHU), Varanasi [email protected], [email protected] Abstract We consider the vehicle routing problem with stochastic demands (VRPSD) on tree structured networks with a single depot. The problem we are concerned with in this paper is to find a set of tours for the vehicle with minimum expected length. Every tour begins at the depot, visits a subset of customers and returns to the depot without violating the capacity constraint. Randomized approximation algorithm achieving approximation guarantees of 2 for split- delivery VRPSD, and 3 for un-split delivery VRPSD are obtained. Keywords: Transportation, Vehicle Routing, Approximation Algorithm 1 Introduction The capacitated vehicle routing problem arises when the customers are to be served by vehicles of limited capacity. The objective is to find set of routes each starting at the depot and visiting a subset of customers such that the value of the total distance travelled is minimized. The capacitated vehicle routing problem (VRP) is defined in [6] on a finite metric space (V,d), where V is a finite set of locations/vertices and d : VXVR+ a distance function that is symmetric and satisfies the triangle inequality. There is a specified depot location r ∈ V, and the problem involves distributing (identical) items from the depot to other locations. Specifically, the depot r has an infinite supply of items and a single vehicle of capacity Q >= 0 (initially located at the depot r) which is used to distribute the items. The demand qi∈ {0, 1... Q} for each location i∈V. In the split delivery version of the problem the demand at a location can be satisfied by multiple visits. In the un-split version the demand at each location needs to be satisfied by a single visit. In the Vehicle Routing Problem with Stochastic Demands, the demands involved are random variables with a known distribution in the range {0,1..., Q} .The exact value of the demand at any location is known only when the vehicle visits the location. The goal is to minimize the expected length. There are two variants of the said problem i.e. with split and un-split deliveries. Related Work Throughout the text we consider the VRPSD on tree networks. A. Gupta et al[6] consider the said problem in general metrics and provide (1+α) approximation (2+ α) and split deliveries for algorithm approximation algorithm for un-split deliveries. Where α (≥1) is the best approximation guarantee for the Travelling Salesman Problem. Bertsimas [3] considers the same problem providing the upper and lower bounds on the expectation values of the total length of the tours. A (1+a +o(1))-approximation algorithm is known for split-delivery VRPSD in the special case of identical demand distributions in the same paper. Related to the tree metric version considered in this paper, Labbe et al. [1] and Karuno et al. [2] discuss some practical situations where tree shaped networks are encountered in VRPs. The problem Tree-CVRP is shown to be strongly NP-Complete by a reduction from the bin packing problem by Hamaguchi and Katoh[8]. Prelimnaries The following discussion holds for both split and un - split delivery versions of VRPSD. We may assume that none of the locations have a zero demand . Since the actual demands are revealed only when the vehicle visits a node, each node must be visited with a probability 1 In [6] a priori Travelling Salesman Tour is followed by the vehicle along with the return to the depots should the demands on a route exceed Q. However on tree networks, the minimum distance that can be covered in satisfying the demands at the various locations is 2S, where S = . Let Di be the random variable representing the demand for customer i. Let pi(k) = Pr(Di = k ) , i ∈ {1,..,n} and k ∈ {1,..,Q}. 2 Bounds and Approximation Algorithms Lower Bound In this section an improved lower bound on the expectation value of the length of the VRPSD in trees is shown. Bertsimas [3] showed that: E[RVRP] ≥ (2/Q) . (1) Corresponding to the priori TSP tour in [6] , the priori sequence for visiting the nodes is decided by a Depth First Search. Let the vertices be labeled [0, 1... n] in order of their visit in the DFS, where 0 represents the depot. Let T j, represent the sub-tree visited between two visits to the depot and length of T j be Lj. The Tj are not disjoint in the case of split deliveries. Let wj denote the node farthest from the depot visited in the tour j. Clearly Lj ≥ 2d (0, wj) (2) Multiplying by the demand ir (r ∈ Tj) and taking summation over all nodes Lj ≥ 2 (3) i(r) and w (j) are same as ir and wj respectively. Since on each tour T j, ∑ ir ≤ Q Lj ≥ (2/Q) (4) Taking summation over all the tours T j RTVRPSD ≥ (2/Q) (5) where is the total number of tours required to fulfill the demands at all locations. Using E[RVRP] = from [3] E[RTVRPSD] ≥ (2/Q) ∑ p1(i1)….pn(in)R(i1,i2,..,in) (6) =(2/Q) E[RTVRPSD] ≥ 2/Q) Approximation Algorithms Split Deliveries In is the split delivery problem this section considered. The main idea used in [6] is initially filling the vehicle with a random number of items. Though it is contrary to a natural strategy of filling a vehicle to capacity, it yields a better expectation value. With slight modification in the SplitALG in [6] we achieve an approximation ratio of 2 for the split TVRPSD. SplitALG for trees is as follows: 1) Compute the order in which the vertices are to be visited by applying a Depth First Search. Label the vertices [0, n], where 0 represents the depot. The vertices are visited in the order 1, 2.., n. 2) Choose a uniformly random value l in the range [0, Q] for initially loading the vehicle. 3) For each i = 1, …, n a) Let Qi’ items be present on the vehicle when it visits the customer i & q i be the demand. If qi < Qi’, serve the demand at the node i and move to the node q (i+1). If qi = Qi’, serve the demand at node i and return to the depot to refill to full capacity Q. Visit location (i+1) from the depot. If qi > Qi’, serve Qi’ units at i and return to the depot for refill to full capacity Q. The vehicle serves Q- qi at i and proceeds to the (i+1) th vertex. Q (i+1)’ = Q – (qi - Qi’). b) d) c) The initial load is uniformly random in the range [0, Q]. A node i is a breakpoint if the vehicle executes a refill trip from i to the depot. The node i is a breakpoint if < l + p.Q ≤ . Since l is the only random variable with a uniform distribution in [0, Q], Pr(i is a break-point) = qi/Q S = , be the sum of all the edges in the tree network, is the length of the initial DFS-tour. The expected solution length is: . 2S + (2/Q) Taking expectation value over demands, the expected solution length is (7) 2S+ (2/Q) . 2S is the length of the initially computed sequence. (2/Q) ≤ . (2/Q) Therefore expected length of the solution is at most 2 times the optimal solution length for TVRPSD instance. Unsplit Deliveries In this section the un-split variant of the problem is considered. The UnsplitALG is very similar to SplitALG for trees. 2) Y. Karuno, H. Nagamochi, and T. Ibaraki. Vehicle scheduling on a tree with release and handling times. Annals of Operations Research, 69(1):193{207, 1997. 3) D. J. Bertsimas, A vehicle routing problem with stochastic demand, Operations Research, 40(3), 574- 585,1992. 4) M. Dror, Vehicle routing with stochastic demands: Models and computational methods, Modeling Uncertainty: An Examination of Stochastic Theory, Methods, and Applications, 46, M. Dror, P. L’Ecuyer and F. Szidarouszky (Eds), 625-649, 2002 5) M. Labbe, G. Laporte, and H. Mercure. Capacitated Vehicle Routing on Trees. Operations Research, 39(4):616-622, 1991. 6) Anupam Gupta, Viswanath Nagarajan, R. Ravi: Technical Note - Approximation Algorithms for VRP with Stochastic Demands. Operations Research 60(1): 123-127 (2012) 7) T.Asano, N.Katoh, K.Kawashima A New Approximation Algorithm for the Capacitated Vehicle Routing Problem on a Tree, Journal of Combinatorial Optimization, 5, 213–231, 2001. 8) S. Hamaguchi and N. Katoh, “A capacitate vehicle routing problem on a tree,” in Proc. of ISAAC’98. Lecture Notes in Computer Science, vol. 1533, Springer-Verlag, Berlin, pp. 397–406, 1998. 1) Compute the order in which the vertices are to be visited by applying a Depth First Search. Label the vertices [0, n], where 0 represents the depot. The vertices are visited in the order 1, 2.., n. 2) Choose a uniformly random value l in the range [0, Q] for initially loading the vehicle. 3) For each i = 1, …, n a) Let Ui’ items be present on the vehicle when it visits the customer i & q i be the demand. If qi < Ui’, serve the demand at the node i and move to the node q (i+1). If qi = Ui’, serve the demand at node i and return to the depot to refill to full capacity Q. Visit location (i+1) from the depot. If qi > Ui’, two visits to the depot are required  b) In the first visit, the vehicle fills up qi units at r and serves the demand at i. c) d)  In the second visit, the vehicle fills up (Q + Ui’ - qi) units at r, and returns to i. It can be observed that the break points in SplitALG and UnsplitALG are identical. The probability that node i is the break-point is qi/Q. The solution length in the above algorithm is 2S+(4/Q) . The expected solution length over demands is 2S + (4/Q) . (2/Q) ≤ The expected value of the additional distance to be travelled when the vehicle runs out of items is twice that of the split deliveries. Using the analysis similar to SplitALG, the expected solution length is at -most 3 times the optimal value for the TVRPSD instance. 3 Conclusions In this paper we derived a lower bound for the expectation value of the length of SVRP tour over a tree network. We also presented constant factor approximation algorithms for the case of split and un - split deliveries. The open questions that arise is to improve these guarantees: Asano et. al [7] achieve an approximation guarantee of 1.35078 for the split delivery case when vehicle capacity is 1. 4 References 1) M. Labbe, G. Laporte, and H. Mercure. Capacitated Vehicle Routing on Trees. Operations Research, 39(4):616-622, 1991.
1808.02174
1
1808
2018-08-07T01:18:57
Test without Trust: Optimal Locally Private Distribution Testing
[ "cs.DS", "cs.CR", "cs.DM", "cs.LG", "math.ST", "math.ST" ]
We study the problem of distribution testing when the samples can only be accessed using a locally differentially private mechanism and focus on two representative testing questions of identity (goodness-of-fit) and independence testing for discrete distributions. We are concerned with two settings: First, when we insist on using an already deployed, general-purpose locally differentially private mechanism such as the popular RAPPOR or the recently introduced Hadamard Response for collecting data, and must build our tests based on the data collected via this mechanism; and second, when no such restriction is imposed, and we can design a bespoke mechanism specifically for testing. For the latter purpose, we introduce the Randomized Aggregated Private Testing Optimal Response (RAPTOR) mechanism which is remarkably simple and requires only one bit of communication per sample. We propose tests based on these mechanisms and analyze their sample complexities. Each proposed test can be implemented efficiently. In each case (barring one), we complement our performance bounds for algorithms with information-theoretic lower bounds and establish sample optimality of our proposed algorithm. A peculiar feature that emerges is that our sample-optimal algorithm based on RAPTOR uses public-coins, and any test based on RAPPOR or Hadamard Response, which are both private-coin mechanisms, requires significantly more samples.
cs.DS
cs
Test without Trust: Optimal Locally Private Distribution Testing Jayadev Acharya∗ Clément L. Canonne† Cody Freitag‡ Himanshu Tyagi§ August 8, 2018 Abstract We study the problem of distribution testing when the samples can only be accessed us- ing a locally differentially private mechanism and focus on two representative testing questions of identity (goodness-of-fit) and independence testing for discrete distributions. We are con- cerned with two settings: First, when we insist on using an already deployed, general-purpose locally differentially private mechanism such as the popular Rappor or the recently introduced Hadamard Response for collecting data, and must build our tests based on the data collected via this mechanism; and second, when no such restriction is imposed, and we can design a bespoke mechanism specifically for testing. For the latter purpose, we introduce the Randomized Aggre- gated Private Testing Optimal Response (Raptor) mechanism which is remarkably simple and requires only one bit of communication per sample. We propose tests based on these mechanisms and analyze their sample complexities. Each proposed test can be implemented efficiently. In each case (barring one), we complement our per- formance bounds for algorithms with information-theoretic lower bounds and establish sample optimality of our proposed algorithm. A peculiar feature that emerges is that our sample-optimal algorithm based on Raptor uses public-coins, and any test based on Rappor or Hadamard Response, which are both private-coin mechanisms, requires significantly more samples. 8 1 0 2 g u A 7 ] S D . s c [ 1 v 4 7 1 2 0 . 8 0 8 1 : v i X r a ∗Cornell University. Email: [email protected]. †Stanford University. Email: [email protected]. Supported by a Motwani Postdoctoral Fellowship. ‡Cornell University. Email: [email protected]. §Indian Institute of Science. Email: [email protected]. 1 1 Introduction Locally differentially private (LDP) mechanisms have gained prominence as methods of choice for sharing sensitive data with untrusted curators. This strong notion of privacy, introduced in [DJW13] (see also [EGS03]) as a variant of differential privacy [DMNS06, Dwo06], requires each user to report only a noisy version of its data such that the distribution of the reported data does not change multiplicatively beyond a prespecified factor when the underlying user data changes. With the proliferation of user data accumulated using such locally private mechanisms, there is an increasing demand for designing data analytics toolkits for operating on the collated user data. In this paper, we consider the design of algorithms aimed at providing a basic ability to such a toolkit, namely the ability to run statistical tests for the underlying user data distribution. At a high-level, we seek to address the following question. How should one conduct statistical testing on the (sensitive) data of users, such that each user maintains their own privacy both to the outside world and to the (untrusted) curator performing the inference? In particular, we consider two fundamental statistical inference problems for a discrete dis- tribution over a large alphabet: identity testing (goodness-of-fit) and independence testing. A prototypical example of the former is testing whether the user data was generated from a uniform distribution; the latter tests if two components of user data vectors are independent. Our main focus is the uniformity testing problem and most of the other results are obtained as an exten- sion using similar techniques. We seek algorithms that are efficient in the number of LDP user data samples required and can be implemented practically. These two problems are instances of distribution testing, a sub-area of statistical hypothesis testing focusing on small-sample analysis introduced by Batu et al. [BFR+00] and Goldreich, Goldwasser, and Ron [GGR98]. Our results are comprehensive, and organized along two axes: First, we consider tests that use existing LDP data release mechanisms to collect inputs at the center and perform a post-processing test on this aggregated data. Specifically, we consider the popular Rappor mechanism of [EPK14] and the recently introduced the Hadamard Response mechanism (HR) of [ASZ18]. Because these mechanisms have utility beyond our specific use-case of distribution testing -- Rappor, for instance, is already deployed in many applications -- it is natural to build a more comprehensive data analytics toolkit using the data accumulated by these mechanisms. To this end, we provide uniformity testing algorithms with optimal sample complexity for both mechanisms; further, for HR, we also provide an independence testing algorithm and analyze its performance. Second, we consider the more general class of public-coin mechanisms for solving testing prob- lems which are allowed to use public randomness. We present a new response mechanism, Random- ized Aggregated Private Testing Optimal Response (Raptor), that only requires users to send a single privatized bit indicating whether their data point is in a (publicly known) random subset of the domain. Using Raptor, we obtain simple algorithms for uniformity and independence testing that are sample-optimal even among public-coin mechanisms. We next provide a detailed description of our results, followed by a discussion of the relevant literature to put them in perspective. At the outset we mention that the problems studied here have been introduced earlier in [She18, GR18]. Our algorithms outperform their counterparts from these papers, and we complement them with information-theoretic lower bounds establishing their optimality (except for the proposed HR-based independence test). 2 1.1 Algorithms and results The privacy level of a locally private mechanism is often parameterized by a single parameter ε > 0. Specifically, an ε-LDP mechanism (cf. Duchi et al. [DJW13]) ensures that for any two distinct values of user data, the distribution of the output reported to the curator is within a multiplicative factor of eε; smaller values of ε indicate stronger privacy guarantees. In this work, we focus on the high-privacy regime, and assume throughout that ε ∈ (0, 1]; however, our choice of 1 as an upper bound is to set a convention and can be replaced with any constant. In uniformity testing, the user data comprises independent samples from an unknown k-ary distribution. These samples are then made available to the curator through an ε-LDP mechanism, and she seeks to determine if the underlying distribution was uniform or γ-far from uniform in total variation distance. How many locally private samples must the curator access? First, we consider two representative locally private mechanisms, Rappor and HR. We briefly describe these mechanisms here informally and provide a more complete definition in Section 2. In Rappor, the k-ary observation of the user is first converted to a k-length vector using one-hot encoding, and then each bit of this vector is independently flipped with probability 1/(1 + eε). HR, on the other hand, is a generalization of the classic Randomized Response (RR) [War65] which roughly maps each k-ary observation x to either a randomly chosen +1 entry of the x-th row of the k × k Hadamard matrix with probability eε/(1 + eε), or to a randomly chosen −1 entry with probability 1/(1+eε). Interestingly, both these mechanisms have been shown recently to be sample- optimal for learning k-ary distributions; see [DJW17, EPK14, WHW+16, YB17, KBR16, ASZ18]. Further, note that both Rappor and HR are private-coin mechanisms, and are symmetric across users. We propose the following algorithm to enable uniformity testing using data obtained via Rap- por. Once again, the description here is brief and a formal description is provided in Section 3.1. Algorithm 1 Uniformity testing using Rappor 1: Obtain Z1, . . . , Zn using Rappor. 2: For each x in [k], compute the number Nx of k-bit vectors Zi for which the x-th entry is 1. 3: Compute the test statistic T described in (11) which is, in essence, a bias-corrected version of the collision statistic Px(N 2 x − Nx). 4: If T is more than roughly n2γ2ε2/k, declare uniform; else declare not uniform. We analyze the sample complexity of the above test and show that it is order-wise optimal among all tests that use Rappor. Result 1 (Sample complexity of uniformity testing using Rappor). The uniformity test de- scribed above requires O(k3/2/(γ2ε2)) samples. Furthermore, any test using Rappor must use Ω(k3/2/(γ2ε2)) samples. Moving now to HR, denote by q∗ the output distribution of HR when the underlying samples are generated from the uniform distribution. (Note that q∗ can be computed explicitly.) Invoking Parseval's theorem, we show that the ℓ2 distance between the q∗ and the output distribution of HR is roughly ε/√k times the ℓ2 distance between the uniform and the user data distributions. This motivates the following test. 3 Algorithm 2 Uniformity testing using HR 1: Obtain Z1, . . . , Zn using HR. 2: Using an appropriate ℓ2-test, test if the ℓ2 distance between the distribution of Zi's and q∗ is less than roughly γε/k; in this case declare uniform. Else declare not uniform. Our next result shows that this test is indeed sample-optimal among all tests using HR. Result 2 (Sample complexity of uniformity testing using HR). The uniformity test described above requires O(k3/2/(γ2ε2)) samples. Furthermore, any test using HR must use Ω(k3/2/(γ2ε2)) samples. Both tests proposed above thus provably cannot be improved beyond this barrier of Ω(k3/2/(γ2ε2)) samples. Interestingly, this was conjectured by Sheffet to be the optimal sample complexity of lo- cally private uniformity testing [She18], although no algorithm achieving this sample complexity was provided. Yet, our next result shows that one can achieve the same guarantees with much fewer samples when public randomness is allowed. Specifically, we describe a new mechanism Raptor, described below: Algorithm 3 The Raptor mechanism 1: The curator and the users sample a uniformly random subset S of [k] of cardinality k/2. 2: Each user computes the bit indicator Bi = 1{Xi∈S} and sends it using RR, i.e., flips it with probability 1/(1 + eε) and sends the outcome to the curator. The key observation is that when the underlying distribution is γ-far from uniform, the bias of Bi is 1/2 + Ω(γ/√k) with constant probability (over the choice of S); while clearly, under uniform the bits Bi are unbiased. Thus, we can simply test for uniformity by learning the bias of the bit up to an accuracy of γ/√k, which can be done using O(k/(γ2ε2)) samples from Raptor. In fact, we further show that (up to constant factors) this number of samples cannot be improved upon. Result 3 (Sample complexity of locally private uniformity testing). Uniformity testing using Rap- tor requires O(k/(γ2ε2)) samples. Furthermore, any public-coin mechanism for locally private uniformity testing requires Ω(k/(γ2ε2)) samples. Although we have stated the previous three results for uniformity testing, our proofs extend easily to identity testing, i.e., the problem of testing equality of the underlying distribution to a fixed known distribution q which is not necessarily uniform. In fact, if we allow simple preprocessing of user observations before applying locally private mechanisms, a reduction argument due to Goldreich [Gol16] can be used to directly convert identity testing to uniformity testing. Our final set of results are for independence testing, where user data consists of two-dimensional vectors (Xi, Yi) from [k] × [k]. We seek to ascertain if these vectors were generated from an inde- pendent distribution p1 ⊗ p2 or a distribution that is γ-far in total variation distance from every independent distribution. For this problem, a natural counterpart of Raptor which simply applies Raptor to each of the two coordinate using independently generated sets yields a sample optimal test -- indeed, we then simply need to test if the pair of indicator-bits are independent or not. This can be done using O(k2/(γ2ε2)), leading to the following result. 4 Result 4 (Sample complexity of locally private independence testing). The sample complexity of locally private independence testing is Θ(k2/(γ2ε2)) and is achieved by a simple public-coin mechanism that applies Raptor to each coordinate of user data. For completeness, we also present a private-coin mechanism for independence testing based on HR which requires O(k3/(γ2ε4)) samples. The proposed test builds on a technique introduced in Acharya, Daskalakis, and Kamath [ADK15] and relies on learning in χ2 divergence. Although this result is suboptimal in the dependence on the privacy parameter ε, it improves on both [She18] and the testing-by-learning baseline approach by a factor of k. We summarize all our results in Table 1 and compare them with the best known prior bounds from [She18]. This work Previous [She18] Private-Coin Public-Coin Private-Coin Uniformity Testing O(cid:16) k3/2 Independence Testing O(cid:16) k3 γ2ε2(cid:17) (cid:8) ⋆ Θ(cid:16) k Θ(cid:16) k2 γ2ε4(cid:17) (cid:8) Table 1: Summary of our results and previous work. The independence testing results hold for independence testing of distributions over [k] × [k]; the symbol (cid:8) (resp. 6(cid:8)) indicates a symmetric (resp. asymmetric) mechanism. Finally, ⋆ indicates that the upper bound is tight (in all parameters) for the subclass of private mechanisms our mechanisms belong to. γ2ε2(cid:17) (cid:8) γ2ε2(cid:17) (cid:8) O(cid:16) k2 O(cid:16) k4 γ2ε2(cid:17) 6(cid:8) γ2ε2(cid:17) 6(cid:8) 1.2 Proof techniques We start by describing the analysis of our tests based on existing ε-LDP mechanisms. Recall that a standard (non-private) uniformity test entails estimating the ℓ2 norm of the underlying distribution by counting the number of collisions in the observed samples. When applying the same idea on the data collected via Rappor, we can naively try to estimate the number of collisions by adding the number of pairs of output vectors with 1s in the x-th coordinate, for each x. However, the resulting statistic has a prohibitively high variance stemming from the noise added by Rappor. We fix this shortcoming by considering a bias-corrected version of this statistic that closely resembles the classic χ2 statistic. However, analyzing the variance of this new statistic turns out to be rather technical and involves handling the covariance of quadratic functions of correlated binomial random variables. Our main technical effort in this part goes into analyzing this covariance, which may find further applications. For our second test that builds on HR, we follow a different approach. In this case, we exploit the structure of Hadamard transform and take recourse to Parseval's theorem to show that the ℓ2 distance to uniformity of the original distribution p is equal, up to an ε/√k factor, to the ℓ2 distance of the Fourier transform H(p) to some (explicit) fixed distribution q; further, it can be shown that kqk2 = O(1/√k). With this structural result in hand, we can test identity of H(p) to q in the Fourier domain, by invoking the non-private ℓ2 tester of Chan et al. [CDVV14] with the corresponding distance parameter γε/√k. Exploiting the fact that q has a small ℓ2 norm leads to the stated sample complexity. Our private-coin mechanism for independence testing uses HR as well, and once again hinges on the idea that testing and learning in the Fourier domain can be done efficiently. To wit, we adapt the "testing-by-learning" framework of Acharya, Daskalakis, and Kamath [ADK15] (which they show 5 can be applied to many testing problems, including independence testing) to our private setting. The main insight here is that instead of using HR to learn and test the original distribution p in χ2 distance, we perform both operations directly in the transformed domain to the distribution at the output of HR. Namely, we first learn the transform of p1⊗p2, then test whether the outcome is close to the transform of p. The main challenge here is to show that the variant of Hadamard transform that we use preserves (as was the case for uniformity testing) the ℓ2 distance from independence. We believe this approach to be quite general, as was the case in [ADK15], and that it can be used to tackle many other distribution testing questions such as locally private testing of monotonicity or log-concavity. As mentioned above, our main results -- the optimal public-coin mechanisms for identity and independence testing -- are remarkably simple. The key heuristic underlying both can be sum- marized as follows: If p is γ-far from uniform, then with constant probability a uniformly random subset S ⊆ [k] of size k/2 will satisfy p(S) = 1/2 ± Ω(γ/√k); on the other hand, if p is uniform then p(S) = 1/2 always holds. Thus, one can reduce the original testing problem (over alphabet size k) to the much simpler question of estimating the bias of a coin. This latter task is very easy to perform optimally in a locally private manner -- for instance it can be completed via RR -- and requires each player to send only one bit to the server. Hence, the main technical difficulty is to prove this quite intuitive claim. We do this by showing anticoncentration bounds for a suitable random variable by bounding its fourth moment and invoking the Paley -- Zygmund inequality. As a byproduct, we end up establishing a more general version, Theorem 14, which we believe to be of independent interest. Our information-theoretic lower bounds are all based on a general approach introduced recently by Acharya, Canonne, and Tyagi [ACT18] (in a non-private setting) that allows us to handle the change in distances between distributions when information constraints are imposed on samples. We utilize the by-now-standard "Paninski construction" [Pan08], a collection C of 2k/2 distribu- In tions obtained by adding a small pointwise perturbation to the k-ary uniform distribution. order to obtain a lower bound for the sample complexity of locally private uniformity testing, fol- lowing [ACT18], we identify such a mechanism to the n noisy channels (Wj : [k] → {0, 1}∗)j∈[n] (that is, the randomized mappings used by the n players) it induces on the samples and consider the distribution W(p) of the tuple of n messages when the underlying distribution of the samples is p. The key step then is to bound the χ2 divergence between (i) W(u), the distribution of the mes- sages under the uniform distribution; and (ii) Ep∈C[W(p)], the average distribution of the messages when p is chosen uniformly at random among the "perturbed distributions." Using the results of [ACT18], this in turn is tantamount to obtaining an upper bound the Frobe- nius norm of specific [k/2] × [k/2] matrices H1, . . . , Hn that capture the information constraints imposed by Wj's. Deriving these bounds for Frobenius norms constitutes the main technical part of the lower bounds and relies on a careful analysis of the underlying mechanism and of the LDP constraints it must satisfy. On the range of parameters. As pointed out earlier, in this work we focus on the high-privacy regime, i.e., the case when the privacy parameter ε is small and the privacy constraints on the mechanisms are the most stringent. From a technical standpoint, this allows us to rewrite the expressions such as eε−1 , which appear frequently, as simply Θ(ε) and greatly simplifies the statements of our results. However, our results carry through to the general setting of large ε, with eε−1 eε+1 replacing Θ(ε) term; the former is Θ(1) for large ε. eε+1 and eε/2−1 eε/2+1 6 1.3 Related prior work Testing properties of a distribution by observing samples from it is a central problem in statistics and has been studied for over a century. Motivated by applications arising from algorithms dealing with massive amounts of data, it has seen renewed interest in the computer science community under the broad title of distribution testing, with a particular focus on sample-optimal algorithms for discrete distributions. This literature itself is over two decades old; we refer an interested reader to surveys and books [Rub12, Can15, Gol17, BW17] for a comprehensive review. Here, we only touch upon works that are related directly to our paper. Sample complexity for uniformity testing was settled in [Pan08], following a long line of work. The related, and more general, problem of identity testing has seen revived interest lately. The sample complexity for this problem was shown to be Θ(k1/2/γ2) in [VV17], and by now even the optimal dependence on the error probability is known (cf. [HM13, DGPP16]). Moreover, a work of Goldreich [Gol16] further shows that any uniformity testing algorithm implies an identity testing one with similar sample complexity. Another variant of this problem, termed "instance-optimal" identity testing and introduced in [VV17], seeks to characterize the dependence of the sample complexity on the distribution q we are testing identity to, instead of the alphabet size. As pointed out in [ACT18], the reduction from [Gol16] can be used in conjunction with results from [BCG17] to go through even for the instance-optimal setting. This observation allows us to focus on uniformity testing only, even when local privacy constraints are imposed. The optimal sample complexity for the independence testing problem where both observations are from the same set1 [k] was shown to be Θ(k/γ2) in [ADK15, DK16]. Moving now to distribution testing settings with privacy constraints, the setting of differentially private (DP) testing has by now been extensively studied. Here the algorithm itself is run by a trusted curator who has access to all the user data, but needs to ensure that the output of the test maintains differential privacy. Private identity testing in this sense has been considered in [CDK17, ADR17], with a complete characterization of sample complexity derived in [ASZ17]. Interestingly, in several parameter ranges of interest the sample complexity here matches the sample complexity for the non-private case discussed earlier, showing that "privacy often comes at no additional cost" in this setting. As we show in this work, this is in stark contrast to what can be achieved in the more stringent locally private setting. We are not aware of any existing private algorithm for DP independence testing. While the literature on DP testing includes several interesting mechanisms, for instance the works [GLRV16, KR17, WLK15] which contain mechanisms for both identity and independence testing, finite-sample guarantees are not available and the results hold only in the asymptotic regime. Finally, coming to the literature most closely related to our work, locally private hypothesis testing was considered first by Sheffet in [She18] where, too, both identity and independence test- ing were considered. This work characterized the sample complexity of LDP independence and uniformity testing when using Randomized Response, and introduced more general mechanisms. However, as pointed-out in Table 1, the algorithms proposed in [She18] require significantly more samples than our sample-optimal algorithms for those questions. Moreover, the overall sample complexity without restricting to any specific class of mechanisms has not been considered. An interesting concern studied in Sheffet's work is the distinction between symmetric and asymmetric mechanisms. Broadly speaking, the latter are locally private mechanisms where each 1The more general question asks to test independence of distributions over [k1] × [k2], or even over [k1] × · · · × [kd]. Optimal (non-private) sample complexities for these generalizations are also known [DK16]. 7 player applies the same randomized function W to its data, where asymmetric mechanisms allow different behaviors, with player i using its own Wi. While we mention this distinction in our results (see Table 1), we observe in Lemma 4 that allowing asymmetric mechanisms can only improve the sample complexity by at most a logarithmic factor. Another class of problems of statistical inference requires learning the unknown distribution up to a desired accuracy of γ in total variation distance. Clearly, the testing problems we consider can be solved by privately learning the distributions (to accuracy γ). The optimal sample complexity of locally private learning discrete k-ary distributions is known to be Θ(k2/(γ2ε2)); see [DJW17, EPK14, YB17, KBR16, ASZ18]. (Furthermore, all these sample-optimal learning schemes are symmetric.) This readily implies a sample complexity upper bound of O(k2/(γ2ε2)) for locally private identity testing, and of O(k4/(γ2ε2)) for independence testing. In this respect the theoretical guarantees from [She18] are either implied or superseded by this "testing-by-learning" approach. 2 Notation and Preliminaries We write [k] for the set of integers {1, 2, . . . , k}, and denote by log and ln the binary and natural logarithms, respectively. We make extensive use of the standard asymptotic O(·), Ω(·), and Θ(·) notation; moreover, we shall sometimes use an . bn, a & bn, and an ≍ bn for their non-asymptotic counterparts (i.e., an . c1bn, a & c1bn, and c1an ≤ bn ≤ c2an for every n, where c1, c2 > 0 are absolute constants). Following the standard setting of distribution testing, we consider probability distributions over a discrete (and known) domain Ω. Denote by ∆(Ω) the set of all such distributions, p: [k] → [0, 1] : Xx∈Ω , p(x) = 1  ∆(Ω) =   endowed with the total variation distance (statistical distance) as a metric, defined as dTV(p, q) = supS⊆Ω(p(S)− q(S)). It is easy to see that dTV(p, q) = 1 2kp − qk1, where kp − qk1 is the ℓ1 distance between p and q as probability mass functions. For a distance parameter γ ∈ (0, 1], we say that p, q ∈ ∆(Ω) are γ-far if dTV(p, q) > γ; otherwise, they are γ-close. We denote by p1 ⊗ p2 the product distribution over [k1] × [k2] defined by (p1 ⊗ p2)(x1, x2) = p1(x1) · p2(x2), for p1 ∈ ∆([k1]), p2 ∈ ∆([k2]). In distribution testing, for a prespecified set of distributions C ⊆ ∆(Ω) and given independent samples from an unknown p ∈ ∆(Ω), our goal is to distinguish between the cases (i) p ∈ C and (ii) p is γ-far from every q ∈ C with constant probability2. The sample complexity of testing C is defined as the minimum number of samples required to achieve this task in the worst case over all p ∈ ∆(Ω) (as a function of γ, Ω, and all other relevant parameters of C). The specific problem of identity testing corresponds to Ω = [k] and C = {q} for some fixed and known q ∈ ∆([k]). Uniformity testing is the special case of identity testing with q being the uniform distribution, i.e., q(x) = 1/k for all x ∈ [k]. Lastly, independence testing corresponds to Ω = [k] × [k] and C := { p1 ⊗ p2 : p1, p2 ∈ ∆([k]) }. 2As is typical, we set that probability to be 2/3; by a standard argument, this can be amplified to any 1 − δ at the price of an extra O(log(1/δ)) factor in the sample complexity and running time. 8 2.1 Local Differential Privacy We consider the standard setting of ε-local differential privacy, which we recall below. A 1-user mechanism is simply a randomized mapping which, given as input user data x ∈ X , outputs a random variable Z taking values in Z. We represent this mechanism by a channel W : X → Z where W (z x) denotes the probability that the mechanism outputs z when the user input is x. Similarly, an n-user mechanism is represented by W = (Wj : X → Y)j≥0 where Wj denotes the channel used for the j-th user; when n is clear from context, we will simply use mechanism for an n-user mechanism. For our purposes, X will be the domain of our discrete probability distributions, [k], and Z will be identified with {0, 1}ℓ, for some integer ℓ ≥ 0. Note that each channel Wj is applied independently to each user's data. In particular, for inde- pendent samples X1, . . . , Xn, the outputs Z1, . . . , Zn of W are independent, too. The mechanisms described above are private-coin mechanisms: they only require independent, local randomness at each user to implement the local channels W1, . . . , Wn. A private-coin mechanism is further said to be symmetric if Wj is the same for all j, in which case, with an abuse of notation, we denote it W : X → Z. A broader class of mechanisms of interest to us are public-coin mechanisms, where the output of each user may depend additionally on shared public randomness U (independent of the users' data); when the shared randomness takes the value u, the mechanism uses channels W u j . Clearly, private-coin mechanisms are a special case, corresponding to constant U. The above distinction between symmetric and asymmetric mechanisms applies to public-coin mechanisms as well. A public-coin mechanism W is an ε-locally differentially private (ε-LDP) mechanism if it satisfies the following: max u max z∈Y max x,x′∈X j (z x′) W u j (z x) ≤ eε, W u ∀ 1 ≤ j ≤ n. (1) 2.2 Existing LDP mechanisms Three LDP mechanisms will be of interest to us: randomized response, Rappor, and Hadamard response. Randomized response. The k-randomized response (k-RR) mechanism [War65] is an ε-LDP mechanism, WRR, with Z = X = [k], such that WRR(z x) := ( eε 1 eε+k−1 eε+k−1 if z = x, otherwise. (2) Originally introduced for the binary case (k = 2), it is one of the simplest and most natural response mechanisms. Rappor. The randomized aggregatable privacy-preserving ordinal response (Rappor) is an ε- LDP mechanism introduced in [DJW13, EPK14]. Its simplest implementation, k-Rappor, maps X = [k] to Z = [2k] in two steps. First, a one-hot encoding is applied to the input x ∈ [k] to obtain a vector y ∈ {0, 1}k such that yj = 1 for j = x and yj = 0 for j 6= x. The privatized output, z ∈ Z, of k-Rappor is represented by a k-bit vector obtained by independently flipping each bit of y independently with probability 1 eε/2+1. 9 Note that if x is drawn from p ∈ ∆(k), this leads to z ∈ {0, 1}k such that the coordinates are (non-independent) Bernoulli random variables with zi distributed as Bern(αR · p(i) + βR) where αR, βR are defined as αR := eε/2 − 1 eε/2 + 1 = ε 4 + o(ε), βR := 1 eε/2 + 1 = 1 2 + o(1). (3) Hadamard Response. Hadamard response is a symmetric, communication- and time-efficient mechanism, proposed in [ASZ18]. In order to define the Hadamard response mechanism, we first define a general family of ε-LDP mechanisms that include RR as a special case. Let s ≤ K be two integers, and for each x ∈ X = [k] let Cx ⊆ Z = [K] be a subset of size with Cx = s. Then, the general privatization scheme is described by ∀z ∈ [K], W (z x) := ( eε 1 seε+K−s seε+K−s if z ∈ Cx, if z ∈ Z \ Cx (4) which can easily be seen to be ε-LDP. Further, note that k-RR corresponds to the special case with K = k, s = 1, and Cx = {x} for all x. The Hadamard Response mechanism (HR), is obtained by choosing s = K/2, and a collection of sets (Cx)x∈[k] such that (A) For every x ∈ [k], Cx = s = K 2 . (B) For every distinct x, x′ ∈ [k], the symmetric difference ∆(Cx, Cx′) satisfies ∆(Cx, Cx′) = s. For these parameters, we get that W (z x) =( 2 K · K · 2 eε eε+1 1 eε+1 if z ∈ Cx, if z ∈ Z \ Cx, ∀z ∈ [K]. (5) Let q(p, Cx) denote the probability that the privatized output z lies in Cx, when the input distri- bution is p. Then, from (A) and (B) it can be seen that Pr[ Z ∈ Cx Z = x ] = Xz∈Cx W (z x) eε eε + 1 , Pr[ Z ∈ Cx Z 6= x ] = 1 2 and combining these two q(p, Cx) = 1 2 + eε − 1 2(eε + 1) p(x) . (6) A method for constructing sets (Cx)x∈[k] that also allows efficient implementation of the resulting mechanism was proposed in [ASZ18] using Hadamard codes (hence the name Hadamard Response). Specifically, let K := 2⌈log(k+1)⌉ (7) so that k + 1 ≤ K ≤ 2(k + 1), and let HK ∈ {−1, 1}K×K be the Hadamard matrix of order K (see Section 2.3 for more details). Hereafter, we identify each row of HK to a subset of [K]. As K ≥ k + 1, we can pick an injection φ: [k] → {2, . . . , K} and map each x ∈ [k] to a distinct subset Cx ⊆ [K] defined by the φ(x)-th row of HK. By Fact 1 in the next section, this family (Cx)x∈[k] satisfies (A) and (B). 10 2.3 Hadamard matrices and linear codes Next, we recall some useful properties of Hadamard matrices which will be needed for our analysis of HR-based tests. Definition 1. Let M ≥ 1 be any power of two. The Hadamard matrix of order M, denoted HM , is the matrix of size M × M defined recursively by Sylvester's construction: (i) H1 := h1i, and (ii) for m ≥ 1, H2m := "H2m−1 H2m−1 H2m−1 −H2m−1# . Note that all entries of HM are in {−1, 1}. Fact 1. Let m ≥ 1 be any integer. Then, the Hadamard matrix H2m has the following properties: (i) The first row of H2m is the all-one vector. (ii) For every j ≥ 2, the j-th row of H2m is balanced, i.e, contains exactly 2m−1 entries equal to 1. (iii) Every two distinct rows are orthogonal; that is, for every 1 ≤ i < j ≤ 2m, the i-th and j-th row agree (resp. disagree) on exactly 2m−1 entries. Fix any m ≥ 1. The Hadamard matrix H2m corresponds to the Walsh -- Hadamard transform (or Fourier transform; see, for example, [O'D14]). Specifically, for any two functions f, g : {0, 1}m → R, define the inner product hf, gi over R{0,1}m as 1 (8) hf, gi := 2m Xx∈{0,1}m f(x)g(x), and let k·k denote the norm induced by this inner product. Moreover, the functions χS : {0, 1}m → R defined for every S ⊆ [m] by χS(x) = (−1)hx,Si = Qi∈S(−1)xi form an orthonormal basis, whereby every f : {0, 1}m → R can be uniquely written as f(x) = Xx∈{0,1}m ∀x ∈ {0, 1}m, f(S)χS(x) (9) where f(S) := hf, χSi. The Walsh -- Hadamard matrix specifies this transformation of basis. Specif- ically, we note following standard fact: Fact 2. Let m ≥ 1. Then, for every x ∈ {0, 1}m and subset S ⊆ [m] identified to its characteristic vector s ∈ {0, 1}m, we have that (H2m)s,x = (H2m)x,s = χS(x) . This spectral view of Walsh -- Hadamard matrix leads to Parseval's Theorem, which is instru- mental in design of our tests based on HR. Theorem 3 (Parseval's Theorem). For every function f : {0, 1}m → R, f(S)2 . kfk2 = XS⊆[m] 11 2.4 On symmetry and asymmetry While all the LDP mechanisms underlying our proposed sample-optimal tests in this paper can be cast as symmetric mechanisms, the next result shows that asymmetric mechanisms can in any case yield at most a logarithmic-factor improvement in sample complexity over symmetric ones. Lemma 4. Suppose that there exists a private-coin (respectively public-coin) LDP mechanism for some task T with n users and probability of success 5/6. Then, there exists a private-coin (respec- tively public-coin) symmetric LDP mechanism for T with n′ = O(n log n) users and probability of success 2/3. Proof. Let W = (Wi)i∈[n] be the purported mechanism, with Wi : X → Y being the mapping of the i-th user. We create a symmetric (randomized) mechanism W : X → [n] × Y as follows: On input x ∈ X , use private (respectively public) randomness to generate I ∈ [n] uniformly at random (and independently of everything else); and output (I, WI(x)).3 Clearly, the resulting mechanism is symmetric. Further, by a standard coupon-collector argu- ment, for n′ = O(n log n) we have that with probability at least 5/6, each i ∈ [n] will be drawn at least once. Whenever this is the case, upon gathering all the outputs, the referee can then select a subset of n outputs and simulate the original mechanism, having received the output of W1, . . . , Wn. Overall, the probability of failure is at most 1/6 + 1/6 = 1/3 by a union bound. 2.5 A warmup for the binary case We conclude this section with simple algorithms for identity and independence testing for the case when Ω = {0, 1}, i.e, for support size k = 2. These algorithms will be used later in our optimal tests based on Raptor. 2.5.1 Private estimation of the bias of a coin. First, we deal with the problem of estimating the bias of a coin up to an additive accuracy of ±γ, when the outcomes of coin tosses can be accessed via an ε-LDP mechanism. Note that this yields as a corollary an algorithm for identity testing over {0, 1}. Indeed, to test if the generating distribution p equals q ∈ ∆({0, 1}) or is γ-far from it, we estimate probability p(0) to additive ±γ/2 and compare it with q(0). The following result is a folklore and is included for completeness. Lemma 5 (Locally Private Bias Estimation, Warmup). For ε ∈ (0, 1], an estimate of the bias of a coin with an additive accuracy of γ can be obtained using O(cid:0)1/(γ2ε2)(cid:1) samples via ε-LDP RR. Moreover, any estimate of bias obtained via ε-LDP RR must use Ω(cid:0)1/(γ2ε2)(cid:1) samples. Proof. Recall from (2) that an ε-LDP RR is described by the channel WRR(0 0) = W (1 1) = eε eε+1. When a Bern(ρ) random variable passes through this channel, the output is a Bernoulli random variable with mean ρ′ := ρ eε eε + 1 + (1 − ρ) 1 eε + 1 = 1 eε + 1 + ρ eε − 1 eε + 1 . Therefore, estimating ρ to ±γ using this mechanism is equivalent to estimating ρ′ to an additive γ′ := eε+1 eε−1 γ, which can be done with O(1/γ′2) = O(1/(γ2ε2)) samples (the second as ε . 1). 3Note that for public-coin mechanisms, one can define W : X → Y, as there is no need for a user to communicate the random index I to the referee. 12 It remains to prove optimality. For k = 2, it can shown that any ε-LDP scheme can be obtained by passing output of an ε-LDP RR through another channel. Therefore, RR will require the least number of samples for estimating the bias, and it suffices to show the claimed bound of Ω(cid:0)1/(γ2ε2)(cid:1) for RR. To that end, suppose we provide as input a Bernoulli random variable with bias 1/2 + γ to RR. Then, the output has bias 1 2 + O(γε). On the other hand, when the input is Bern(1/2), then the output is Bern(1/2) as well. Therefore, distinguishing between a Bern(1/2) and a Bern(1/2 + γ) using samples from an ε-LDP RR is at least as hard as distinguishing Bern(1/2) and Bern(1/2 + O(γε)) without privacy constraints. This latter task is known to require the stated number of samples. 2 + γ eε−1 eε+1 = 1 2.5.2 Independence testing over {0, 1} × {0, 1} As a corollary of Lemma 5, we obtain an algorithm for locally private independence testing for k = 2, which, too, will be used later in the paper. Corollary 6. For ε ∈ (0, 1], there exists a symmetric, private-coin ε-LDP mechanism that tests whether a distribution over {0, 1} × {0, 1} is a product distribution or γ-far from any product distribution using O(cid:0)1/(γ2ε2)(cid:1) samples. Proof. Consider a distribution p over {0, 1} × {0, 1} with marginals p1 and p2. Note that p(0, 0) − p1(0)p2(0) = p(x, y) − p1(x)p2(y) , x, y ∈ {0, 1}. Thus, if p is γ-far in total variation distance from any product distribution, it must hold that dTV(p, p1 ⊗ p2) ≥ γ, which in view of the equation above yields p(0, 0) − p1(0)p2(0) ≥ γ/2. Using this observation, we can test for independence using O(1/(ε2γ2)) samples as follows. First, note that for any symbol x, p(x) can be estimated up to an accuracy γ using O(1/(ε2γ2)) samples by converting the observation X to the binary observation 1{X=x} and applying the estimator of Lemma 5. Thus, we can estimate p(0, 0), p1(0), and p2(0) up to an accuracy γ/16 by assigning O(1/(ε2γ2)) samples each for them. Denote the respective estimates by p(0, 0), p1(0), and p2(0). When p(0, 0) = p1(0)p2(0), p(0, 0) − p1(0)p2(0) ≤ p(0, 0) − p(0, 0) + p1(0) − p1(0) + p2(0) − p2(0) ≤ 3 16 γ. On the other hand, when p(0, 0) − p1(0)p2(0) ≥ γ/2, we have p(0, 0)− p1(0)p2(0) ≥ p(0, 0)−p1(0)p2(0)−p(0, 0)−p(0, 0)−p1(0)−p1(0)−p2(0)−p2(0) ≥ Thus, for k = 2, locally private independence testing can be performed with O(1/(ε2γ2)) samples by estimating the probabilities p(0, 0), p1(0), p2(0) and comparing p(0, 0) − p1(0)p2(0) to the threshold γ/4. 5 16 γ. 3 Locally Private Uniformity Testing using Existing Mechanisms In this section, we provide two locally private mechanisms for uniformity testing. As discussed earlier, this in turn provides similar mechanisms for identity testing as well. These two tests, based respectively on the symmetric, private-coin mechanisms Rappor and HR, will be seen to have the same sample complexity of O(k3/2/γ2ε2). However, the first has the advantage of being based on a widespread mechanism, while the second is more efficient in terms of both time and communication. 13 3.1 A mechanism based on Rappor Given n independent samples from p, let the output of Rappor applied to these samples be denoted by b1, . . . , bn ∈ {0, 1}k, where bi = (bi1, . . . , bik) for i ∈ [n]. The following fact is a simple consequence of the definition of Rappor. Fact 7. Let i, j ∈ [n], and x, y ∈ [k]. Pr[ bix = 1, bjy = 1 ] =  (αRp(x) + βR)(αRp(y) + βR) (αRp(x) + βR)(αRp(y) + βR) − α2  αRp(x) + βR where αR, βR are defined as in (3). Rp(x)p(y) if i 6= j if i = j, x 6= y if i = j, x = y First idea: Counting Collisions. A natural idea would be to try and estimate kpk2 2 by counting the collisions from the output of Rappor. Since this only adds post-processing to Rappor, which is LDP, the overall procedure does not violate the ε-LDP constraint. For σx i,j defined as 1{bix=1,bjx=1}, i,j counting collisions over all samples and x ∈ [k], i 6= j, the statistic S := P1≤i<j≤nPx∈[k] σx differentially private symbols can be seen to have expectation E[S] = n 2!(cid:16)α2 Rkpk2 2 + 2αRβR + kβ2 R(cid:17) ≍ 1 2 ε2n2kpk2 2 + Θ(k) . Up to the constant normalizing factor, this suggests an unbiased estimator for kpk2 2, and thereby also for kp − uk2 2 − 1/k. However, the issue lies with the variance of this estimator. Indeed, it can be shown that Var(S) ≈ n3k (for constant ε). Thus, if we use this statistic to distinguish between kpk2 2 > (1 + Ω(γ2))/k for uniformity testing, we need 2 = 1/k and kpk2 2 = kpk2 √n3k ≪ n2ε2 · γ2 k i.e., n ≫ k3/(γ4ε4). This sample requirement turns out to be off by a quadratic factor, and even worse than the trivial upper bound obtained by learning p. An Optimal Mechanism. We now propose our testing mechanism based on Rappor, which, in essence, uses a privatized version of a χ2-type statistic of [CDVV14, ADK15, VV17]. For x ∈ [k], let the number of occurrences of x among the n (privatized) outputs of Rappor be Nx := n Xj=1 1{bjx=1} which by the definition of Rappor follows a Bin(n, αRp(x) + βR) distribution. Now, letting T := Xx∈[k] (cid:18)Nx − (n − 1)(cid:18) αR k + βR(cid:19)(cid:19)2 − Nx! + k(n − 1)(cid:18) αR k + βR(cid:19)2 (10) (11) we get a statistic, applied to the output of Rappor, which (as we shall see) is up to normalization an unbiased estimator for the squared ℓ2 distance of p to uniform. The main difference with the naive 14 approach we discussed previously, however, lies in the extra linear term. Indeed, the collision-based statistic was of the form S ∝ Xx∈[k](cid:16)N 2 x − Nx(cid:17) , and in comparison, keeping in mind that Nx is typically concentrated around its expected value of roughly n/2, our new statistics can be seen to take the form T ≈ Xx∈[k](cid:16)N 2 x − nNx(cid:17) + Θ(kn2), since βR ≈ 1/2. That is, now the fluctuations of the quadratic term are reduced significantly by the subtracted linear term, bringing down the variance of the statistic. This motivates our testing algorithm based on Rappor, Algorithm 4, and leads to the main result of this section: Theorem 8. For ε ∈ (0, 1], Algorithm 4 based on ε-LDP Rappor can test whether a distribution is uniform or γ-far from uniform using samples. γ2ε2! O k3/2 Algorithm 4 Locally Private Uniformity Testing using Rappor Require: Privacy parameter ε > 0, distance parameter γ ∈ (0, 1), n samples 1: Set as in (3). αR ← eε/2 − 1 eε/2 + 1 , βR ← eε/2 + 1 1 2: Apply (ε-LDP) Rappor to the n samples to obtain (bi)1≤i≤n 3: Compute Nx for every x ∈ [k], as defined in (10) 4: Compute T , as defined in (11) 5: if T < n(n − 1)α2 Rγ2/k then return uniform 6: 7: else 8: 9: end if return not uniform ⊲ Time O(k) per user ⊲ Time O(kn) ⊲ Time O(k) Proof of Theorem 8. Clearly, since Rappor is an ε-LDP mechanism, the overall Algorithm 4 does not violate the ε-LDP constraint. We now analyze the error performance of the proposed test, which we will do simply by using Chebyshev's inequality. Towards that, we evaluate the expected value and the variance of T . The following evaluation of expected value of statistic T uses a simple calculation entailing moments of a Binomial random variable: 15 Lemma 9. With T defined as above, we have E[T ] = n(n − 1)α2 Rkp − uk2 2 where the expectation is taken over the private-coins used by Rappor and the samples drawn from Rγ2 . k p. In particular, (i) if p = u, then E[T ] = 0; while (ii) if dTV(p, u) > γ, then E[T ] > 2n(n−1) α2 n)E[Nx]2, we have Proof. Letting λ := (cid:0) αR x(cid:3) = E[Nx] + (1 − 1 k + βR(cid:1) and using the fact that E(cid:2)N 2 Eh(Nx − (n − 1)λ)2 − Nxi + k(n − 1)λ2 E[T ] = Xx∈[k] = Xx∈[k](cid:16)EhN 2 = Xx∈[k](cid:18) n − 1 = n(n − 1) Xx∈[k] E[Nx]2 n xi − 2(n − 1)λE[Nx] + (n − 1)2λ2 − E[Nx](cid:17) + k(n − 1)λ2 E[Nx]2 − 2(n − 1)λE[Nx] + n(n − 1)λ2(cid:19) n2 − 2λ n E[Nx] + λ2! = n(n − 1) Xx∈[k](cid:18) E[Nx] n − λ = αR (p(x) − 1/k), gives the result. n − λ(cid:19)2 , which, along with the observation that E[Nx] Turning to the variance, we get the following: Lemma 10. With T defined as above, we have Var(T ) ≤ 4kn2 + 8n3α2 Rkp − uk2 2 = 4kn2 + 8nE[T ] . The proof of this lemma is quite technical and relies on a tedious analysis of the covariance of the random variables (Nx)x∈[k], in view of bounding quantities of the form Cov(f(Nx), f(Ny)). We defer the details to Appendix B. With these two lemmata, we are in a position to conclude the argument. Suppose n ≥ C · k3/2 Rγ2 , for some constant C > 0 to be specified later. Recall that αR = ε/4 + o(ε) when ε → 0, leading to the claimed sample complexity. First, consider the case when p = u. In this case E[T ] = 0 and Var(T ) ≤ 4kn2 by Lemmas 9 α2 and 10, and so by Chebyshev's inequality Pr" T ≥ n2 α2 Rγ2 k # ≤ k2 Var(T ) n4α4 Rγ4 ≤ 17k3 8n2α4 Rγ4 < 3 C 2 which is at most 1/3 for C ≥ 3. Chebyshev's inequality Next, when dTV(p, u) > γ, E[T ] > 2n2 α2 Rγ2 k and Var(T ) ≤ 4kn2 + 8nE[T ], and again by Pr" T < n2 α2 Rγ2 k # ≤ Pr(cid:20) T < 1 2 E[T ](cid:21) ≤ 4 Var(T ) E[T ]2 ≤ 17k3 2n2α4 Rγ4 + 10k Rγ2 ≤ nα2 17 2C 2 + 10 C√k which is at most 1/3 for C ≥ 23. Taking C = 23 concludes the proof of Theorem 8. 16 3.2 A mechanism based on Hadamard Response Although the Rappor-based mechanism of Section 3.1 achieves a significantly improved sample complexity over the naive learning-and-testing approach, it suffers several shortcomings. The most apparent is its time complexity: inherently, the one-hot encoding procedure used in Rappor leads to a time complexity of Θ(kn), with an extra linear dependence on the alphabet size k, which is far from the "gold standard" of O(n) complexity. A more time-efficient procedure is obtained using HR. In fact, we describe an algorithm for testing uniformity based on HR that has the same sample complexity as the one based on Rappor described above, but is much more time-efficient. Theorem 11. For ε ∈ (0, 1], Algorithm 5 based on ε-LDP HR can test whether a distribution is uniform or γ-far from uniform using γ2ε2! O k3/2 samples. Moreover, the algorithm runs in time near-linear in the number of samples. Algorithm 5 Locally Private Uniformity Testing using Hadamard Response Require: Privacy parameter ε > 0, distance parameter γ ∈ (0, 1), n samples 1: Set αH ← eε − 1 eε + 1 K ← 2⌈log(k+1)⌉ 2: Apply the HR (with parameters ε, K) to the n samples to obtain n independent samples in ⊲ Time O(log k) per user [K] 3: Invoke the testing algorithm Test-ℓ2 of Theorem 13 on these n samples, with parameters γ′ ← and q∗ being the explicit distribution from Theorem 12 b ← , 1 + αH√K return uniform 4: if Test-ℓ2 accepts then 5: 6: else 7: 8: end if return not uniform 2αH γ kK ⊲ Time O(n log k + n log n) To describe the intuition behind this algorithm, suppose we feed inputs from an input distri- bution p ∈ ∆([k]) to the more general mechanism in Section 2.2, whose output then follows some induced distribution q ∈ ∆([K]). A natural hope is that whenever p is uniform (over [k]), then q is uniform (over [K]), too; and that conversely if p is not uniform, then q is neither, and that the distance to uniformity is preserved. This is not exactly what we will obtain. However, we can get something close to it in the next result, which suffices for our purpose.4 4To see that our desired statement cannot hold as stated above, note that for p = u, (14) implies q(z1) = 1+αH K , since Dz1 = k as the first column of HK is the all-one vector. Thus the squared ℓ2 distance of q to uniform is at least α2 H /K. 17 Theorem 12. Let ε ∈ (0, 1], K = O(k) be a power of 2, and denote by q the output distribution over [K]. Then, we have kq − q∗k2 2 = α2 K · kp − uk2 H 2 ≍ ε2 k kp − uk2 2 , (12) where αH := eε−1 dent of p, with kq∗k2 ≤ (1 + αH)/√K. Moreover, q∗ can be sampled in time O(log K). eε+1 , and q∗ ∈ ∆([K]) is an explicit distribution, efficiently computable and indepen- Thus, when p = u, we get q = q∗. Otherwise when dTV(p, u) > γ, then kq − q∗k2 2 > 4α2 H γ2 kK = Θ ε2 k2 γ2! . (13) The observation above suggests that if we can estimate the ℓ2 distance between q and q∗, we can get our desired uniformity test. We facilitate this by invoking the result below, which follows from the ℓ2-distance estimation algorithm of [CDVV14, Proposition 3.1], combined with an observation from [DK16, Lemma 2.3]:5 Theorem 13 (Adapted from [CDVV14, Proposition 3.1]). For two unknown distributions p, q ∈ ∆([k]), there exists an algorithm Test-ℓ2 that distinguishes with probability at least 2/3 between the cases kp − qk2 ≤ γ/2 and kp − qk2 > γ by observing O(min(kpk2,kqk2)/γ2) samples from each. Moreover, this algorithm runs in time near-linear in the number of samples. We apply the algorithm of Theorem 13 to our case by generating desired number of samples from q∗, which can simply be obtained by passing samples from the uniform distribution via HR, and using them along with the samples observed from q at the output of HR. We need to distinguish between the cases q = q∗ and kq − q∗k2 > γ′/√K, which by the previous result can be done using O(kq∗k2K/γ′2) samples where γ′ := 2αH γ/√k. Substituting K = O(k) and kq∗k2 = O(1/√K), the number of samples we need is 1 √K · K · √k O  γε !2  = O k3/2 γ2ε2! , which is our claimed sample complexity. The time complexity follows from the efficiency of Hadamard encoding (see [ASZ18, Section 4.1]), which allows each player to generate their private sample in time O(log K) = O(log k), and to send only O(log k) bits.6 After this, running the Test-ℓ2 algorithm takes time O(n log K + n log n), the first term being the time required to generate n samples from q∗. Thus, to conclude the proof of Theorem 11, it only remains to establish Theorem 12 -- which we do next. Proof of Theorem 12. For any z ∈ [K], let Dz ⊆ [k] be the set of symbols x such that z ∈ Cx. 5[CDVV14] require that b ≥ max(kpk2, kqk2); [DK16] shows how to relax this requirement to b ≥ min(kpk2, kqk2). 6This is significantly better than the O(k) time and communication per player of Algorithm 4. 18 Then, from Eq. (4) (recalling that s = K/2) we get q(z) = Xx∈Dz W (z x)p(x) + Xx∈Dz = 1 s (cid:18)p(Dz) + αH K eε + p(Dc z) eε + 1 (2p(Dz) − 1) . W (z x)p(x) 1 1 eε + 1(cid:19) + K · 1 = K Define q∗ ∈ ∆([K]) as eε − 1 eε + 1 · (p(Dz) − p(Dc z)) (14) (15) q∗(z) := 1 K + αH K (cid:18)2Dz k − 1(cid:19) , ∀z ∈ [K], so that q∗(z) ∈ [(1 − αH)/K, (1 + αH)/K] for every z and kq∗k2 ≤ (1 + αH)/√K. From Eqs. (14) and (15), we get kq − q∗k2 2 = Xz∈[K] (q(z) − q∗(z))2 = 4α2 H k (cid:19)2 K 2 Xz∈[K](cid:18)p(Dz) − Dz . (16) Note that we may view a probability distribution p ∈ ∆([k]) as a function p : {0, 1}k → R with p(s) = p(S) = Xx∈S p(x), ∀s ∈ {0, 1}k, where we identify s ∈ {0, 1}k with the subset S = { x ∈ [k] : sx = 1 } ⊆ [k] and use the two notations interchangeably. Also, from Fact 2 and the definition of the Cx as sets encoded by the rows of the matrix HK, we have that whereby χφ(x)(z) = (HK)φ(x),z = 21{z∈Cx} − 1, Xx∈[k](cid:18)p(x) − ∀ z ∈ [K], x ∈ [k], k(cid:19) χφ(x)(z) = 2(cid:18)p(Dz) − Dz k (cid:19) , ∀ z ∈ [K]. 1 Now, consider the function g : [K] → R defined by g(z) = 2 (p(Dz) − Dz /k),7. Using the previous equation, we can view g alternatively as 1 k(cid:19) χT (z), ∀ z ∈ [K]. (p(x) − 1/k) 1{T =φ(x)}, ∀ T ∈ [K], Therefore, g(z) = XT∈φ([k])(cid:18)p(φ−1(T )) − g(T ) = Xx∈[k] k (cid:19)2 K Xz∈[K](cid:18)p(Dz) − Dz = kgk2 = XT∈[K] 4 which by Parseval's theorem (Theorem 3) gives g(T )2 = Xx∈[k](cid:18)p(x) − 1 k(cid:19)2 = kp − uk2 2 . The identity above, together with (16), yields kq − q∗k2 2 = α2 K kp − uk2 H 2 . The claimed result then follows from the fact that αH = ε 2 + o(ε). 7Recall that K is a power of two, so [K] can be identified to {0, 1}log K . 19 4 Optimal Locally Private Uniformity Testing In the foregoing treatment, we saw that existing (private-coin) mechanisms such as Rappor and HR can perform uniformity testing using O(k3/2/(γ2ε2)) samples at best. In this section, we describe our public-coin mechanism, Raptor,8 and use it to design an algorithm for testing uniformity that requires only O(k/(γ2ε2)) samples and constant communication9 per sample. Our algorithm builds upon the warmup algorithm of Lemma 5, which allows us to perform uniformity testing for k = 2 using O(1/(γ2ε2)) samples. Specifically, we use public randomness to reduce the uniformity testing problem for an arbitrary k to that for k = 2, albeit with γ replaced with γ/√k; and then apply the warmup algorithm. To enable the aforementioned reduction, we need to show that the probabilities of a randomly generated set differ appropriately under the uniform distribution and a distribution that is γ far from uniform in total variation distance. To accomplish this, we prove a more general result which might be of independent interest. We say that random variables X1, X2, . . . , Xk are 4-symmetric if E[Xi1Xi2 Xi3Xi4] depends only on the number of times each element appears in the multiset probability perturbation δ. {i1, i2, i3, i4}.10 The following result constitutes a concentration bound for Z = Pi∈[k] δiXi for a Theorem 14 (Probability perturbation concentration). Consider a vector δ such that Pi∈[k] δi = 0. Let random variables X1, . . . , Xk be 4-symmetric and Z = Pi∈[k] δiXi. Then, for every α ∈ (0, 1/4), Pr"(cid:18)EhX 2 1i − E[X1X2](cid:19) −s 38α 1 − 2α E(cid:2)X 4 1(cid:3) ≤ Z 2 kδk2 2 ≤ 1 1 − 2α(cid:18)EhX 2 1i − E[X1X2](cid:19)# ≥ α. The proof requires a careful evaluation of the second and the fourth moments of Z and is deferred to Appendix A. As a corollary, we obtain the result below, which is at the core of our reduction argument. Corollary 15. Consider a distribution p ∈ ∆([k]) such that dTV(p, u) > γ. For a random subset S of [k] distributed uniformly over all subsets of [k] of cardinality k/2, it holds that Proof. Let Y1, . . . , Yk be independent random bits, and let X1, . . . , Xk be obtained by conditioning (Y1, . . . , Yk) on the event Pi∈[k] Xi = k/2. Consider the random set S defined as p(S) − Pr(cid:20)(cid:12)(cid:12)(cid:12)(cid:12) 1 2(cid:12)(cid:12)(cid:12)(cid:12) > γ √5k (cid:21) > 1 477 . S = { i ∈ [k] : Xi = 1 } . Letting δ := p − u, we have p(S) − u(S) = p(S) − 1 2 = Xi∈[k] δiXi. 8Which stands for Randomized Aggregated Private Testing Optimal Response. 9In fact, we only need 1-bit per sample if we allow asymmetric implementation. 10That is, if E[Xi1 Xi2 Xi3 Xi4 ] does not depend on the actual values of i1, i2, i3, i4 (for which there are k4 possibilities) but only on the quantities 1{ia=ib}, for 1 ≤ a < b ≤ 4 (for which there are 2(4 2) possibilities). 20 Note that E(cid:2)X 2 1(cid:3) = E(cid:2)X 4 1(cid:3) = 1/2. Also, E[X1X2] = 1 2 1 2 k k Yi = Y1 = 1, Pr[ X2 = 1 X1 = 1 ] 2 # Xi=1 2 − 1(cid:19)# Yi = (cid:18) k 2 − 1(cid:19)# Xi=2 Yi = (cid:18) k k k = = = 1 2 1 2 Pr" Y2 = 1(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Pr" Y2 = 1(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) E" Y2 (cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Xi=2 E" Yj (cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Xi=2 Yj (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) E Xj=2  Xi=2 k k k which by symmetry yields E[X1X2] = 1 2 Taking the average of the right-side, we get Yi = (cid:18) k 2 − 1(cid:19)#, ∀ 2 ≤ j ≤ k. E[X1X2] = Finally, note that 1 2(k − 1) Yi = (cid:18) k 2 − 1(cid:19)  = (k − 2) 4(k − 1) ≤ 1 4 . kδk2 2 ≥ so that, applying Theorem 14 to Z = Pk i=1 δiXi with α := 1/477 we get 1 ≥ , 1 kkδk2 4γ2 k Pr" Z 2 > γ2 5k # ≥ 1 477 , which completes the proof. Armed with this result, we can divide our LDP testing problem into two parts: A public-coin ε-LDP mechanism releases 1-bit per sample to the curator, and the curator applies a test to the received bits to accomplish uniformity testing. This specific mechanism suggested by the previous corollary is our Raptor (see Section 1.1 for a description). While in this paper we have only considered its use for testing uniformity and independence, since it provides locally private 1-bit outputs that, in essence, preserve the ℓ2 distance of the underlying distribution from any other fixed one, we can foresee many other use-cases for Raptor and pose it as a standalone mechanism of independent interest. Recall that in Raptor the curator and the users pick a random subset S of size k/2 from their shared randomness, and each user sends the indicator function that its input lies in this set S using ε-LDP RR. This is precisely the 1-bit information from samples required to enable the estimator of Lemma 5. Note that when the underlying distribution p is uniform, the probability p(S) of user bit being 1 is exactly 1/2. Also, by Corollary 15 when p is γ-far from uniform we have p(S) = 1/2 ± Ω(γ/√k) with a constant probability (over the choice of S); by repeating the 21 protocol a constant number of times,11 we can ensure that with high constant probability at least one of the choices of S will indeed have this property. Therefore, we obtain an instance of the uniformity testing problem for k = 2, namely the problem of privately distinguishing a Bern(1/2) from Bern(cid:16)1/2 ± c1γ√k(cid:17). Thus, when we apply Raptor to the samples, the curator gets the 1-bit updates required by Lemma 5 to which it can apply the estimator prescribed in Lemma 5 to solve the underlying uniformity testing instance for k = 2 using O k γ2 (eε + 1)2 (eε − 1)2! samples. Since we used ε-LDP RR to send each bit, Raptor, too, is ε-LDP and thereby so is our overall uniformity test. We summarize the overall algorithm and its performance below. Theorem 16. For ε ∈ (0, 1], Algorithm 6 based on ε-LDP Raptor can test whether a distribution is uniform or γ-far from uniform using samples. O(cid:18) k γ2ε2(cid:19) Algorithm 6 Locally Private Uniformity Testing using Raptor Require: Privacy parameter ε > 0, distance parameter γ ∈ (0, 1), n = mT samples 1: Set c ← 2: for t from 1 to T do 3: 1 477 c δ ← 2(1 + c) , γ′ ← γ √5k , T = Θ(1) ⊲ In parallel 4: 5: Generate uniformly at random a subset St of [k] of cardinality k/2 Apply Raptor using St to each sample in the mini-batch of m samples Use the estimator in the proof of Lemma 5 to test with probability of failure δ if p(St) = 1/2 (unbiased) or p(St) − 1/2 > γ′ (biased) 6: end for 7: Let τ denote the fraction of the T outcomes that returned unbiased 8: if τ > 1 − (δ + c 4) then return uniform 9: 10: else 11: 12: end if return not uniform Proof of Theorem 16. The proof of correctness follows the foregoing outline, which we describe in more detail. Let c := 1/477 be the constant from Corollary 15, and let δ := c 2(1+c) , and set γ′ := γ√5k . By a standard amplification argument,12 one can amplify the success probability of 11To preserve the symmetry of our mechanism, we note that this can be done "in parallel" at each user. That is, each user considers the same T = Θ(1) many random subsets, and sends their corresponding T privatized (with parameter ε′ = ε/T ) indicator bits to the curator. 12Namely, letting the server divide the received samples into O(log(1/δ)) disjoint batches, and running the private estimation procedure of Lemma 5 independently T times, before outputting the majority vote. 22 the private estimation procedure of Lemma 5 to 1 − δ, using a total of O(log(1/δ)/(γ′ 2ε2)) = O(1/(γ′2ε2)) samples (to achieve privacy ε and accuracy γ′). Consider the t-th test from Algorithm 6 (where 1 ≤ t ≤ T ), and let bt be the indicator that the bias estimation outputs unbiased. If p is uniform, then by the above we have Pr[ bt = 1 ] ≥ 1 − δ (where the probability is over the choice of the random subset St, and the randomness of the bias estimation). However, if p is γ-far from uniform, by Corollary 15 it it the case that Pr[ bt = 1 ] ≤ (1 − c) + cδ = 1 − (δ + c 2). Therefore, for a sufficiently large constant in the choice of T = Θ(1/c2) = Θ(1), a Chernoff bound argument ensures that we can distinguish between these two cases with probability at least 2/3. 5 Proofs of Optimality: Lower Bounds for Uniformity Testing We now establish that the public-coin testing algorithm in the previous section has optimal sample- complexity for any LDP uniformity testing algorithm. Furthermore, we establish lower bounds on the sample complexity for any LDP testing algorithm using Rappor or HR, showing that the tests we proposed using these mechanisms are sample optimal (up to constant factors) in their class. 5.1 Lower bound for public-coin mechanisms We first show that any uniformity testing algorithm that uses data from an ε-LDP public-coin mechanism (which includes private-coin mechanisms) requires at least Ω(cid:0)k/(γ2ε2)(cid:1) samples. Theorem 17. For ε ∈ (0, 1], any ε-LDP public-coin mechanism for uniformity testing must use Ω(cid:18) k γ2ε2(cid:19) samples. Proof. Our lower bound relies on analyzing the standard "Paninski construction" [Pan08], which we briefly recall. Assuming without loss of generality that k is even, we partition the domain in k/2 consecutive pairs (2i − 1, 2i). For a given parameter γ ∈ (0, 1/2], the family of "no-instances" is the collection of 2k/2 distributions (pθ)θ∈{−1,+1}k/2 where pθ(2i − 1) = 1 + 2θiγ k , pθ(2i) = 1 − 2θiγ k , i ∈ [k/2] . Note that every such pθ is a total variation exactly γ from the uniform distribution on [k]. Our starting point will be the proof of the public-coin lower bound of [ACT18, Theorem 6.1] for uniformity testing in a (non-private) distributed setting. Note that the proof in [ACT18] proceeds by noting that once we restrict our attention to the hypothesis testing problem implied by Paninski's construction, we can derandomize and find a deterministic protocol that outperforms the public- coin protocol. Therefore, it suffices to bound the performance of deterministic protocols. However, in our current application, relaxing to deterministic protocols will get rid of local privacy constraints and will not lead to useful bounds. Instead, we note in similar vein as the proof in [ACT18] that we can derandomize public randomness and find a private-coin ε-LDP protocol that achieves the same performance for Paninski's construction as the public-coin protocol we start with. Therefore, it suffices to restrict our attention to private-coin protocols. 23 Let W be an arbitrary ε-LDP private-coin mechanism for uniformity testing. For 1 ≤ j ≤ n and θ, θ′ ∈ {−1, +1}k/2, define Hj(θ, θ′) as Hj(θ, θ′) := γ2 θi1θ′i2 k Xm Xi1,i2∈[k/2] Pk i=1 Wj(m i) where m ∈ ({0, 1}∗)n denotes the tuple of outputs from the n users. Let (Wj(m 2i1 − 1) − Wj(m 2i1)) (Wj(m 2i2 − 1) − Wj(m 2i2)) . ¯Wj(m) := 1 k k Xi=1 Wj(m i) i.e., ¯Wj(m) is the probability of user j outputting m when the input distribution is uniform. Let δm i,j be such that Then by the conditions for LDP, we must have Wj(m 2i − 1) − Wj(m 2i) = ¯Wj(m)δm i,j. Furthermore, we can rewrite Hj(θ, θ′) = = θi1θ′i2 γ2 k2 Xm Xi1,i2∈[k/2] γ2 k2 θT Hjθ′, (cid:12)(cid:12)(cid:12) δm i,j(cid:12)(cid:12)(cid:12) ≤ eε − 1 . ¯Wj(m)δm i1,jδm i2,j = Xi1,i2∈[k/2] θi1θ′i2 γ2 k2 Xm ¯Wj(m)δm i2,j! i1,jδm where Hj is an [k/2] × [k/2] matrix with (i1, i2)th entry equal to i2,j . ¯Wj(m)δm i1,jδm Hj(i1, i2) := Xm ¯Wj(m) = 1, we further get that Hj(i1, i2) ≤ (eε − 1)2 . By using that Pm For a given distribution p ∈ ∆([k]), denote by W(p) ∈ ∆(({0, 1}∗)n) the product distribution over m (the tuple of n messages) when each user gets an independent sample from p. In [ACT18], it is shown that, with n users, the χ2 distance between the distributions of (i) the output of the mechanism under the Paninski mixture, W no := 1 2k/2 Pθ W(pθ), and (ii) the output of the mechanism under the uniform distribution W yes := W(u), is bounded by exp γ2 k2 θT ( Xj=1    − 1 = Eθ,θ′  We will also rely on the following technical claim: Claim 18 ([ACT18, Claim 6.10]). Consider random vectors θ, θ′ ∈ {−1, 1}k/2 with each θi and θ′i distributed uniformly over {−1, 1}, independent of each other and independent for different i's. Then, for any symmetric matrix H, Hj(θ, θ′)  Hj)θ′    − 1 . Xj=1 Eθ,θ′  exp  n n ln Eθθ′eλθT Hθ′ ≤ λ2kHk2 F , ∀ λ > 0 . 24 Using this claim, and choosing λ := γ2 k2 we obtain the following upper bound on the distance between the distributions of the output of the mechanisms in the two cases: dTV(W no,W yes) ≤ exp  n  − 1 ≤ exp F Hjk2  F γ4 Xj=1kHjk2 Xj=1 k4 k  ≤ exp γ4n2 k4 (cid:16)(k/2)2 (eε − 1)4(cid:17)! − 1 ≤ exp γ4n2 k4 n  γ4 n   − 1 4k2 (eε − 1)4! − 1 . This implies the claimed lower bound by a standard application of Le Cam's two-point method (as e.g. detailed by Pollard [Pol03]), as one must have n = Ω(k/(ε2γ2)) for the RHS to be Ω(1). 5.2 Lower bound for Rappor In this section, we prove a lower bound for any uniformity testing mechanism that uses Rappor, not only the algorithm from Section 3.1 (Theorem 8). In fact, the next result shows that that algorithm requires the least number of samples (up to constant factors) among all mechanisms based on the output Rappor, even those allowing public-coin protocols in their post-processing stage. Theorem 19. In the high-privacy regime, any ε-LDP mechanism for uniformity testing that uses Rappor for reporting user data must use samples. γ2ε2! Ω k3/2 Proof. We once again take recourse to Pollard's recipe and proceed as in the proof of Theorem 17. Denote by W : [k] → {0, 1}k the channel from the input to the output of Rappor. Letting for conciseness qε := eε/(1 + eε), we first observe that for any observation i ∈ [k] one has (1 − qε){ ℓ : ℓ6=i,mℓ=1 } (1 − qε)m(1)+1, W (m i) = (miqε + (1 − mi)(1 − qε)) · q{ ℓ : ℓ6=i,mℓ=0 } (1 − qε)m(1)−1 + (1 − mi)qm(0)−1 = miqm(0)+1 ε ε ε where m(0) and m(1), respectively, denote the number of 0's and 1's in m. As was seen in the previous proof of lower bound, for our purpose, we need to evaluate Pi∈[k] W (m i) and W (m i) − W (m i′). For the former quantity, we have W (m i) = qm(0) ε Xi∈[k] (1 − qε)m(1)(cid:18)m(1) qε 1 − qε + m(0) 1 − qε qε (cid:19) . For the latter, we have W (m i) − W (m i′) = qm(0) ε (1 − qε)m(1)(mi − mi′)(cid:18) qε 1 − qε − 1 − qε qε (cid:19) . We are now in a position to prove the lower bound. We are considering protocols where each sample Xj is reported to the center using Rappor, and so, each sample is reported using the same channel 25 W described above. Therefore, the k × k matrix Hj used in the previous proof does not depend on j and satisfies H(i1, i2) := Hj(i1, i2) = kXm It follows that H(i1, i2) = k · (e2ε − 1)2 eε qm(0) ε (1 − qε)m(1) · ·Xm (W (m2i1 − 1) − W (m2i1)) (W (m2i2 − 1) − W (m2i2)) . Pk i=1 W (m i) (m2i1−1 − m2i1)(m2i2−1 − m2i2) m(1)e2ε + m(0) . The key observation that facilitates our bound is that for i1 6= i2, the sum on the right-side is 0. Indeed, consider the set of messages of fixed type, namely those with m(0) and m(1) fixed. Note that in any such set, only messages with m2i1 6= m2i1−1 and m2i2 6= m2i2−1 contribute to the sum. Furthermore, for any fixed m2i2 6= m2i2−1, the contributions corresponding to m2i1 = 1, m2i1−1 = 0 and m2i1 = 0, m2i1−1 = 1 negate each other when i1 6= i2, whereby the overall sum is 0. Thus, we have H(i1, i2) = 1{i1=i2} k(e2ε − 1)2 eε ≤ 1{i1=i2} = 1{i1=i2} (e2ε − 1)2 eε (e2ε − 1)2 eε , qm(0) ε qm(0) ε (1 − qε)m(1) · m2i1−1 − m2i12 (1 − qε)m(1) m(1)e2ε + m(0) ·Xm ·Xm where the inequality holds since m(1)e2ε + m(0) ≥ k for every ε ≥ 0. It follows that kHk2 F ≤ k · (e2ε − 1)4 e2ε , whereby dTV(W no,W yes) ≤ exp γ4n2 ≤ exp γ4n2 k4 k F! − 1 ≤ exp γ4n2 k4 kHk2 e2εk3 (cid:16)e2ε − 1(cid:17)4! − 1, γ2(eε−1)2(cid:17), establishing the result. k3/2 which can only be Ω(1) if n = Ω(cid:16) (e2ε − 1)4 e2ε !! − 1 5.3 Lower bound for Hadamard Response Finally, we establish the analogue of Theorem 19 for any mechanism based on Hadamard Response. Theorem 20. In the high-privacy regime, any ε-LDP mechanism for uniformity testing that uses HR for reporting user data must use samples. Ω k3/2 γ2ε2! 26 Proof. The proof follows the same outline as the proof of Theorem 19 -- we show once again that the matrix H corresponding to using HR for reporting each users data is a diagonal matrix. Specifically, considering the set of messages as {0, . . . , K − 1} and the inputs as {0, . . . k − 1} for convenience, the matrix H in the proof of lower bound is given by H(i1, i2) = k K−1 Xm=0 (W (m 2i1) − W (m 2i1 + 1)) (W (m 2i2) − W (m 2i2 + 1)) , 0 ≤ i1, i2 ≤ k − 1 2 , Pk−1 i=0 W (m i) where W (m i) denotes the probability that HR outputs m when the input is i and is given by W (m i) = 2 K(eε + 1) (cid:16)eε1{m∈Ci} + 1{m /∈Ci}(cid:17) = 2 K(eε + 1)(cid:16)(eε − 1)1{m∈Ci} + 1(cid:17) . With a slight abuse of notation, we use m and i interchangeably to denote their values and the binary vectors corresponding to binary representation of those values. Further, let hx, yi = ⊕ xiyi denote the standard (parity) inner product for vectors over F2. With this convention, for HR we have 1{m∈Ci} = 1{hm,ii=0}. Note that for m = 0 and every i, 1{m∈Ci} = 1, which implies that W (0 i) is the same for all i. It follows that the term corresponding to m = 0 in the expression for H(i1, i2) is 0. Moreover, using Pk−1 1{hm,ii=0} = K/2 for m 6= 0, we obtain 2 k−1 i=0 k W (m i) = Xi=1 2 1{hm,ii=0} + k! K(eε + 1) (cid:16)eε − 1(cid:17) Xi=0 K(eε + 1) (cid:18)(cid:16)eε − 1(cid:17) K + k(cid:19) = c(ε, k, K) · k K = 2 , where c(ε, k, K) = 2((eε − 1)K/2 + k)/(k(eε + 1)); by assumption, k ≤ K ≤ 2k, which implies that c(ε, k, K) ∈ [1, 2]. Therefore, for every 0 ≤ i1, i2 ≤ (k − 1)/2, H(i1, i2) = c(ε, k, K) · 4(eε − 1)2 K(eε + 1)2 K−1 Xm=1(cid:16)1{hm,2i1i=0} − 1{hm,2i1+1i=0}(cid:17)· (cid:16)1{hm,2i2i=0} − 1{hm,2i2+1i=0}(cid:17) . (17) We claim that H(i1, i2) = 0 for i1 6= i2. Indeed, a case analysis yields (cid:16)1{hm,2i1i=0} − 1{hm,2i1+1i=0}(cid:17)(cid:16)1{hm,2i2i=0} − 1{hm,2i2+1i=0}(cid:17) where the condition 1{hm,1i6=0} indicates that the expression is nonzero only when m is odd. Thus, the summands in (17) can be restricted to odd m, and further, each summand equals = (cid:16)1{hm,2i1i=hm,2i2i} − 1{hm,2i1i6=hm,2i2i}(cid:17) 1{hm,1i6=0} , 1{hm,2i1i=hm,2i2i} − 1{hm,2i1i6=hm,2i2i} = 1{hm,2(i1⊕i2)i=0} − 1{hm,2(i1⊕i2)i=1} . 27 We can simplify the expression on the right-side by noting that each odd m has the binary form (b, 1) and h(b, 1), 2ii = hb, ii. Hence, K−1 Xm=1(cid:16)1{hm,2i1i=0} − 1{hm,2i1+1i=0}(cid:17)(cid:16)1{hm,2i2i=0} − 1{hm,2i2+1i=0}(cid:17) (K−1)/2 = = Xm=0 (cid:16)1{hm,(i1⊕i2)i=0} − 1{hm,(i1⊕i2)i=1}(cid:17) K − 1 1{i1=i2}. 2 since for any nonzero vector j, { m : hm, jii = 0 } = { m : hm, jii = 1 } . In summary, we have H(i1, i2) = c(ε, k, K) · 4(eε − 1)2(K − 1) K(eε + 1)2 1{i1=i2}, whereby using c(ε, k, K) ∈ [1, 2] we get F = Xi1,i2 kHk2 H(i1, i2)2 = O k (eε + 1)4! . (eε − 1)4 The proof is completed in the same manner as the proof of Theorem 19. 6 Independence Testing In this section, we treat independence testing. We begin in Section 6.1 with an independence testing mechanism based on HR that does not require public randomness and which achieves significantly improved sample complexity over the state-of-the-art (in dependence on the alphabet size). However, we do not have matching lower bounds for its performance. Then, in Section 6.2, we describe and analyze an optimal procedure that uses public randomness, akin to the optimal uniformity testing mechanism of Section 4. 6.1 A mechanism based on Hadamard Response and private χ 2 learning We present a symmetric, private-coin LDP mechanism for testing independence of distributions over [k] × [k] (although, as we note in Remark 1, our mechanism can be easily extended to handle a more general setting). Theorem 21. For ε ∈ (0, 1], Algorithm 7 based on a symmetric private-coin ε-LDP mechanism can test whether a distribution over [k] × [k] is a product distribution or γ-far from product using samples. γ2ε4! O k3 28 The rest of this section is dedicated to the proof of Theorem 21. The argument will follow the "testing-by-hybrid-learning" approach of [ADK15], modified suitably for the local differential privacy setting. Specifically, instead of learning and testing the underlying user data distributions, we simply do this in the Fourier domain for the distributions seen at the output of HR; details follow. Denote by H the HR mapping from [k] to [K], where K = O(k), and αH := eε−1 eε+1 as in Section 3.2. For any probability distribution p ∈ ∆([k] × [k]), we define T (p) ∈ ∆([K] × [K]) as the distribution of (Z1, Z2) obtained by the process below: (1) Draw (X1, X2) from p; (2) apply HR independently to X1 and X2 to obtain Z1 and Z2. It is immediate to see that if p is a product distribution with marginals p1 and p2, then T (p) = H(p1) ⊗ H(p2) . We build our test on observations (Z1, Z2) from each user, with distribution T (p). Our proposed test uses these samples. It builds on several components that we will describe later; for ease of presentation, we summarize the overall algorithm in Algorithm 7. For Section 6.1, we rely on a Algorithm 7 Locally Private Independence Testing Require: Privacy parameter ε > 0, distance parameter γ ∈ (0, 1) 1: Set αH ← eε − 1 eε + 1 , K ← 2⌈log(k+1)⌉ 2: Each of the n = 2n1 + n2 users, given their data (X1, X2), applies HR independently to X1 and X2 and sends the outcomes to the curator 3: Use the first 2n1 samples from T (p) to obtain n1 samples from T (p1 ⊗ p2) 4: Apply the algorithm of Corollary 27 to the n1 = O(k3/α4 H γ2) samples from T (p1⊗ p2) obtained in the previous step to learn a distribution q ∈ ∆([K] × [K]) such that minz q(z) ≥ 1/(50K 2) and, with probability at least 4/5, χ2(T (p1 ⊗ p2), q) ≤ α4 Hγ2/k2 5: Apply the algorithm of Theorem 22 to the remaining n2 = O(√K 2/γ′2) = O(k3/(α4 H γ2)) samples from T (p) to distinguish, with probability at least 9/10, between χ2(T (p), q) > γ′2 χ2(T (p), q) ≤ γ′2/2, and where γ′2 := 2α4 H γ2/k2. 6: if χ2(T (p), Q) ≤ γ′2/2 then return independent return not independent 7: 8: else 9: 10: end if 29 result of [ADK15], modified slightly for our purposes:13 Theorem 22 ([ADK15, Theorem 1]). Given the explicit description of a distribution q ∈ ∆([k]) such that minx∈[k] q(x) ≥ 1 50k and samples from an unknown distribution p ∈ ∆([k]), there exists an efficient algorithm with that can distinguish with probability at least 9/10 between the cases χ2(p, q) < γ2 2 and χ2(p, q) ≥ γ2 using O(√k/γ2) samples. In addition to Theorem 22, our proposed algorithm builds on Corollary 27 which we will describe and prove below. But before we prove this result, we note that this algorithm can be seen to satisfy all the properties claimed in Theorem 21. Indeed, it requires O(k3/(α4 H γ2)); its privacy is immediate since the observations at the curator are obtained by passing user data via HR. The mechanism is clearly symmetric, as each user sends the output of HR (applied independently to both marginal of their data) to the curator -- it is only at the curator that these privatized outputs are used and combined to generate samples from T (p), T (p1 ⊗ p2), T (p1), or T (p2). As for the correctness, it will follow from Corollary 27 and Theorem 22 (ensuring that the algorithm is overall correct with probability at least 7/10 > 2/3), once the following structural property is established: For p that is γ-far from any product distribution has χ2(T (p), q) > γ′2. Formally, we show the following: Theorem 23. Let p ∈ ∆([k] × [k]) with marginals p1, p2 ∈ ∆([k]), and q ∈ ∆([k] × [k]) be a product distribution such that χ2(T (p1 ⊗ p2),T (q)) ≤ α4 . (i) If p is a product distribution, then χ2(T (p),T (q)) ≤ α4 . (ii) if p is γ-far from being a product distribution, then χ2(T (p),T (q)) > H γ2 k2 H γ2 k2 H γ2 2α4 k2 . It only remains to establish the structural property above and χ2 learning algorithm Corollary 27. Proof of structural result Theorem 23. We prove that (i) if p is independent, then χ2(T (p1⊗ p2), q) will be small, while (ii) if p is far from independent then χ2(T (p1⊗ p2), q) must be noticeably larger. The key technical component is the next lemma. Lemma 24. Let p, q ∈ ∆([k] × [k]) be two distributions, with marginals p1, p2 and q1, q2, respec- tively. Then, kT (p) − T (q)k2 2 = α4 K 2kp − qk2 H 2 + α2 H K 2 (cid:16)kp1 − q1k2 2(cid:17) . 2 + kp2 − q2k2 In particular, if dTV(p, q) > γ, then kT (p) − T (q)k2 > Proof. The proof is similar to that of Theorem 12. Note that it follows in the manner of (14) that 2α2 H γ Kk . 13This statement differs slightly from that in [ADK15], but can be seen to follow from their analysis. Indeed, the difference only impacts the analysis of the variance of their estimator, which now goes through because of our assumption on minx∈[k] q(x). 30 for every (z1, z2) ∈ [K] × [K], T (p)(z1, z2) 4 = = X(x1,x2)∈[k]×[k] K 2(eε + 1)2 X(x1,x2)∈[k]×[k] K 2 X(x1,x2)∈[k]×[k] K 2 Xx1,x2 α2 H = 1 = W (z1 x1)W (z2 x2)p(x1, x2) p(x1, x2)(cid:16)(eε − 1)1{z1∈Cx1} + 1(cid:17)(cid:16)(eε − 1)1{z2∈Cx2} + 1(cid:17) p(x1, x2)(cid:16)αHχφ(x1)(z1) + 1(cid:17)(cid:16)αHχφ(x2)(z2) + 1(cid:17) p(x1, x2)χφ(x1)(z1)χφ(x2)(z2) + αH K 2(cid:16)Xx1 p1(x1)χφ(x1)(z1) +Xx2 1 K 2 , p2(x2)χφ(x2)(z2)(cid:17) + H] · 1 K 2 for every where by the second-to-last identity above gives T (p)(z1, z2) ∈ [1 − α2 (z1, z2). As an analogous expression holds for T (q)(z1, z2), setting g := T (p) − T (q) we have H , 1 + α2 g(z1, z2) = α2 H K 2 X(x1,x2)∈[k]×[k] K 2(cid:16) Xx1∈[k] (p(x1, x2) − p1(x1)p2(x2)) χφ(x1)(z1)χφ(x2)(z2) (p1(x1) − q1(x1))χφ(x1)(z1) + Xx2∈[k] αH + (p2(x2) − q2(x2))χφ(x2)(z2)(cid:17), for every (z1, z2) ∈ [K] × [K]. Now, as in Theorem 12, but looking at the corresponding characters for the Hadamard transform from [k] × [k] to [K] × [K],14 we get g(T ) = α2 H K 2 X(x1,x2)∈[k]×[k] K 2(cid:16) Xx1∈[k] (p(x1, x2) − p1(x1)p2(x2)) 1{T =(φ(x1),φ(x2))} (p1(x1) − q1(x1)) 1{T =φ(x1)} + Xx2∈[k] αH + (p2(x2) − q2(x2)) 1{T =φ(x2)}(cid:17) . By Parseval's theorem (Theorem 3), (T (p)(z1, z2) − T (q)(z1, z2))2 1 kgk2 = g(T )2 K 2 X(z1,z2)∈[K]×[K] = XT∈[K]×[K] K 4 X(x1,x2)∈[k]×[k] α4 H = (p(x1, x2) − q(x1, x2))2 + α2 H K 4(cid:16)Xx1 (p1(x1) − q1(x1))2 +Xx2 (p2(x2) − q2(x2))2(cid:17), 14There are (K + 1)2 characters for [K] × [K] of the form χT (z1)χS(z2), χT (z1), and χT (z2) for S, T ⊆ [K], along with the constant character. Note that the constant character will not appear in the proof of Lemma 24, as we consider the transform of the difference of two functions, canceling the constant term. 31 so that kT (p) − T (q)k2 2 = α4 K 2kp − qk2 H 2 + α2 H K 2 (cid:16)kp1 − q1k2 2 + kp2 − q2k2 2(cid:17) ≥ α4 K 2 kp − qk2 H 2 , as claimed. Proof of Theorem 23. The first statement is obvious, as then T (p) = T (p1 ⊗ p2). Turning to the second, assume that p is γ-far from being a product distribution, so that in particular dTV(p, q) > γ. This implies by Lemma 24 that kT (p) − T (q)k2 H γ2)/(K 2k2) which along with kT (q)k∞ ≤ K 2 ≤ 2 2 > (4α4 1+α2 H K 2 yields χ2(T (p),T (q)) = Xz∈[K]×[K] (T (p)(z) − T (q)(z))2 T (q)(z) K 2 2 kT (p) − T (q)k2 2 > H γ2 2α4 k2 , ≥ as claimed. Learning in χ2 distance in the Hadamard domain. Next, we establish the correctness of Step 4. That is, we show that by leveraging the product structure one can (privately) learn T (p1 ⊗ p2) to the desired χ2 accuracy with the number of samples scaling as k3. To do so, will rely on the following result in [KOPS15] on learning in χ2 distance: Lemma 25 ([KOPS15, Lemma 4]). The Laplace (add-1) estimator can learn k-ary distributions to χ2 distance γ2, with probability 9/10, using O(k/γ2) samples. The next corollary ensues. Corollary 26. There is an efficient estimator to learn product distributions over [k] × [k] to χ2 distance γ2, with probability 4/5, using O(k/γ2) samples. Proof. Let p = p1 ⊗ p2 ∈ ∆([k] × [k]) be a product distribution, and p1, p2 be the hypotheses obtained by using the estimator of Lemma 25 independently on the two marginals of p, with distance parameter γ2/3. We claim that p := p1 ⊗ p2 can serve as our desired estimate. Indeed, by a union bound, with probability at least 4/5 it is the case that χ2(p1, p1) ≤ γ2/3 and χ2(p2, p2) ≤ γ2/3. When this happens, χ2(p, p) = −1 + X(x1,x2)∈[k]×[k] p1(x1)2p2(x2)2 p1(x1)p2(x2) p1(x1)2 p2(x2)2 p2(x2) p1(x1) Xx2∈[k] = −1 + Xx1∈[k] = −1 + (χ2(p1, p1) + 1)(χ2(p2, p2) + 1) = χ2(p1, p1)χ2(p2, p2) + χ2(p1, p1) + χ2(p2, p2) γ4 9 ≤ + 2 3 γ2 < γ2, concluding the proof. As a further corollary, we finally obtain the desired algorithm for LDP χ2-learning. 32 Hγ2/k2, with probability 4/5, using O(k3/(α4 Corollary 27. There exists an algorithm based on a private-coin, symmetric ε-LDP mechanism that learns T (p1 ⊗ p2) to χ2 distance γ′2 := α4 H γ2)) samples. Moreover, the estimate q ∈ ∆([K] × [K]) obtained by this algorithm is a product distribu- tion with minz∈[K]×[K] q(z) ≥ 1/(50K 2). The last point follows from the fact that T (p1 ⊗ p2)(z) ≥ 1/(2K 2) for every z ∈ [K] × [K]. Hence, if q(z) < 1/(50K 2) for some z, then χ2(T (p1 ⊗ p2), q) ≫ 1. Remark 1. To conclude this section, we note that a straightforward generalization of Algorithm 7, Corollary 27, and Theorems 22 and 23 to the case [k1] × [k2] leads to a symmetric private-coin ε-LDP mechanism to test whether a distribution over [k1] × [k2] is a product distribution vs. γ-far from product with sample complexity O(cid:0)(k1k2)(k1 + k2 + √k1k2)/(γ2ε4)(cid:1). 6.2 Optimal independence testing using public-coin mechanisms We proceed, as for uniformity testing, by reducing independence testing for arbitrary k to that for k = 2; an algorithm for solving the latter problem is given as a warmup in Corollary 6. We show that if dTV(p, p1 ⊗ p2) ≥ γ, uniformly random sets S1, S2 ⊆ [k] of cardinality k/2 satisfy p(S1, S2) − p1(S1)p2(S2) = Ω(γ/k), (18) with constant probability. Therefore, we can perform our independence test by repeating the mech- anism of Corollary 6 O(1) times, each for independently generated S1, S2 applied to O(k2/(γ2ε2)) samples. Indeed, the claim above guarantees that, with high constant probability, when dTV(p, p1 ⊗ p2) ≥ γ, one of the O(1) repetitions will produce sets S1, S2 that satisfy (18). On the other hand, clearly when p = p1 ⊗ p2, we have p(S1 × S2) = p1(S1)p2(S2) for all S1, S2 ⊆ [k]. Thus, the mechanism described in Corollary 6 will allow us to perform independence testing using O(k2/(γ2ε2)) samples by obtaining first the estimates p, p1, and p2, respectively, of p(S1 × S2), p1(S1), and p2(S2), and then comparing p − p1 p2 with a suitable threshold.15 Hence, we can (as we did for uniformity testing) divide the LDP testing problem into two parts: A public-coin ε-LDP mechanism releases 3 bits per sample to the curator, and then the curator applies a test to the received bits to perform independence testing on the reduced domain {0, 1} × {0, 1}. The specific mechanism underlying the first part will be Raptor (specifically, a bivariate variant of Raptor given in Algorithm 8); the second part relies on the estimator of Corollary 6. As in Section 4, we can boost the probability of success to 2/3 by performing the above two-part test a constant number of times and using the median trick. 15As was the case for our uniformity testing algorithm, to preserve the symmetry of our mechanism we can ask that these O(1) repetitions be done "in parallel" at each user; further, for each of these repetitions every user sends three privatized bits to the central server, corresponding to the indicators of S1 × [k], [k] × S2, and S1 × S2. 33 Algorithm 8 The Raptor mechanism, bivariate version 1: The curator and the users sample two independent and uniformly random subsets S1, S2 of [k] of cardinality k/2. 2: Each user computes the three bit indicators B1,i = 1{X1,i∈S1}, B2,i = 1{X2,i∈S1}, Bi = 1{(X1,i,X2,i)∈S1×S2} and sends them using RR, i.e., flips each of them independently with probability 1/(1 + eε/3) and sends the outcome to the curator. ⊲ Parameter ε/3 to obtain ε-LDP of the joint 3 bits. It only remains to prove the claim (18). This requires the following (somewhat technical) extension of Theorem 14; for simplicity, we provide a less general version that addresses only a specific choice of random variables X and Y . Theorem 28 (Joint probability perturbation concentration). Consider a matrix δ ∈ Rk×k such that, for every i0, j0 ∈ [k], Pj∈[k] δi0,j = Pi∈[k] δi,j0 = 0. Let random variables X = (X1, . . . , Xk) and Y = (Y1, . . . , Yk) be independent and uniformly distributed over k-length binary sequences of weight k/2. Define Z = P(i,j)∈[k]×[k] δijXiYj. Then, there exist constants c1, c2, ρ > 0 such that Pr" Z 2 kδk2 F ∈ [c1, c2]# ≥ ρ. We provide the details of the proof of Theorem 28 in Appendix C. In particular, choosing δij := (p(i, j) − p1(i)p2(j)), we obtain the desired result as a corollary: Corollary 29. Consider p ∈ ∆([k] × [k]) with marginals p1, p2 such that dTV(p, p1 ⊗ p2) ≥ γ. For randomly chosen subsets S1 and S2, generated uniformly and independently over all subsets of [k] of cardinality [k/2], there exist positive constants c and ρ such that Pr(cid:20)p(S1 × S2) − p1(S1)p2(S2) ≥ c dTV(p, p1 ⊗ p2) k (cid:21) ≥ ρ . Proof. Setting δij = (p(i, j) − p1(i)p2(j)) in Theorem 28, note that Z = Xi,j XiYj(p(i, j) − p1(i)p2(j)) = p(S1 × S2) − p1(S1)p2(S2) and that i,j ≥ (cid:16)Pi,j∈[k] δi,j(cid:17)2 k2 δ2 4γ2 k2 . ≥ kδk2 F = Xi,j∈[k] Thus, the claim follows from Theorem 28. Finally, we show that the sample requirement for our mechanism is optimal for ε ∈ (0, 1]. The proof is similar to that of Theorem 17, since the uniform distribution on [k] × [k] is also a product distribution. The only caveat is that we need to ensure that each perturbed distribution is at total variation distance at least γ from every product distribution, not only the uniform one. Fortunately, we can get this using the following simple fact: 34 Fact 30. Assume p is γ-close to some product distribution q ∈ ∆([k] × [k]). Then, p is γ-close to the product distribution induced by its own marginals, i.e., dTV(p, p1 ⊗ p2) ≤ 3γ. Consequently, to show that the perturbed distribution is γ-far from independent it is enough to prove it is (3γ)-far from the product of its marginals, which in turn is immediate. This implies that locally private independence testing is information-theoretically at least as hard as locally private bound. In summary, combining the upper and lower bounds we have shown the following result. uniformity testing over [k]×[k] (i.e., over alphabet size k2), yielding the Ω(cid:0)k2/(γ2ε2)(cid:1) sample lower Theorem 31. There exists a symmetric, public-coin ε-LDP mechanism to test whether a distribu- tion over [k] × [k] is a product distribution vs. γ-far from product using γ2ε2! O k2 samples. Furthermore, any ε-LDP mechanism for testing independence in this regime must use Ω(cid:16) k2 γ2ε2(cid:17) samples. Acknowledgments. We thank Jon Ullman for bringing to our attention the relation between symmetric and asymmetric schemes, Lemma 4, and outlining its proof. References [ACT18] [ADK15] Jayadev Acharya, Clément L. Canonne, and Himanshu Tyagi. Distributed simulation and distributed inference. CoRR, abs/1804.06952, 2018. Jayadev Acharya, Constantinos Daskalakis, and Gautam Kamath. Optimal testing for properties of distributions. In Advances in Neural Information Processing Systems 28, NIPS '15, pages 3577 -- 3598. Curran Associates, Inc., 2015. [ADR17] Maryam Aliakbarpour, Ilias Diakonikolas, and Ronitt Rubinfeld. Differentially arXiv preprint private identity and closeness testing of discrete distributions. arXiv:1707.05497, 2017. [ASZ17] [ASZ18] [BCG17] Jayadev Acharya, Ziteng Sun, and Huanyu Zhang. Differentially private testing of identity and closeness of discrete distributions. arXiv preprint arXiv:1707.05128, 2017. Jayadev Acharya, Ziteng Sun, and Huanyu Zhang. Communication efficient, sample optimal, linear time locally private discrete distribution estimation. arXiv preprint arXiv:1802.04705, 2018. Eric Blais, Clément L. Canonne, and Tom Gur. Distribution testing lower bounds via reductions from communication complexity. In Proceedings of the 32nd Computational Complexity Conference, CCC '17, pages 28:1 -- 28:40, Dagstuhl, Germany, 2017. Schloss Dagstuhl -- Leibniz-Zentrum fuer Informatik. [BFR+00] Tuğkan Batu, Lance Fortnow, Ronitt Rubinfeld, Warren D. Smith, and Patrick White. Testing that distributions are close. In Proceedings of the 41st Annual IEEE Symposium on Foundations of Computer Science, FOCS '00, pages 259 -- 269, Washington, DC, USA, 2000. IEEE Computer Society. 35 [BW17] [Can15] [CDK17] Sivaraman Balakrishnan and Larry A. Wasserman. Hypothesis testing for high- dimensional multinomials: A selective review. CoRR, abs/1712.06120, 2017. Clément L. Canonne. A survey on distribution testing: Your data is big. but is it blue? Electronic Colloquium on Computational Complexity (ECCC), 22(63), 2015. Bryan Cai, Constantinos Daskalakis, and Gautam Kamath. Priv'it: Private and sam- ple efficient identity testing. In Proceedings of the 34th International Conference on Machine Learning, ICML '17, pages 635 -- 644. JMLR, Inc., 2017. [CDVV14] Siu-On Chan, Ilias Diakonikolas, Gregory Valiant, and Paul Valiant. Optimal al- gorithms for testing closeness of discrete distributions. In Proceedings of the 25th Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '14, pages 1193 -- 1203, Philadelphia, PA, USA, 2014. SIAM. [DGPP16] Ilias Diakonikolas, Themis Gouleakis, John Peebles, and Eric Price. Collision-based testers are optimal for uniformity and closeness. arXiv preprint arXiv:1611.03579, 2016. [DJW13] [DJW17] [DK16] John C. Duchi, Michael I. Jordan, and Martin J. Wainwright. Local privacy and statistical minimax rates. In FOCS, pages 429 -- 438. IEEE Computer Society, 2013. John C. Duchi, Michael I. Jordan, and Martin J. Wainwright. Minimax optimal pro- cedures for locally private estimation. Journal of the American Statistical Association, 2017. Ilias Diakonikolas and Daniel M. Kane. A new approach for testing properties of discrete distributions. In Proceedings of the 57th Annual IEEE Symposium on Foun- dations of Computer Science, FOCS '16, pages 685 -- 694, Washington, DC, USA, 2016. IEEE Computer Society. [DMNS06] Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith. Calibrating noise to sensitivity in private data analysis. In Proceedings of the 3rd Conference on Theory of Cryptography, TCC '06, pages 265 -- 284, Berlin, Heidelberg, 2006. Springer. [Dwo06] [EGS03] [EPK14] Cynthia Dwork. Differential privacy. In ICALP (2), volume 4052 of Lecture Notes in Computer Science, pages 1 -- 12. Springer, 2006. Alexandre Evfimievski, Johannes Gehrke, and Ramakrishnan Srikant. Limiting privacy breaches in privacy preserving data mining. In Proceedings of the 22nd ACM SIGMOD- SIGACT-SIGART Symposium on Principles of Database Systems, PODS '03, pages 211 -- 222, New York, NY, USA, 2003. ACM. Úlfar Erlingsson, Vasyl Pihur, and Aleksandra Korolova. RAPPOR: Randomized ag- gregatable privacy-preserving ordinal response. In Proceedings of the 2014 ACM Con- ference on Computer and Communications Security, CCS '14, pages 1054 -- 1067, New York, NY, USA, 2014. ACM. [GGR98] Oded Goldreich, Shafi Goldwasser, and Dana Ron. Property testing and its connection to learning and approximation. Journal of the ACM, 45(4):653 -- 750, July 1998. 36 [GLRV16] Marco Gaboardi, Hyun-Woo Lim, Ryan M. Rogers, and Salil P. Vadhan. Differentially private chi-squared hypothesis testing: Goodness of fit and independence testing. In Proceedings of the 33rd International Conference on Machine Learning, ICML '16, pages 1395 -- 1403. JMLR, Inc., 2016. [Gol16] [Gol17] [GR18] [HM13] [KBR16] [KOPS15] Oded Goldreich. The uniform distribution is complete with respect to testing identity to a fixed distribution. Electronic Colloquium on Computational Complexity (ECCC), 23(15), 2016. Oded Goldreich. Introduction to Property Testing. Cambridge University Press, 2017. Marco Gaboardi and Ryan Rogers. Local private hypothesis testing: Chi-square tests. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th International Con- ference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 1612 -- 1621, Stockholmsmässan, Stockholm Sweden, 10 -- 15 Jul 2018. PMLR. Dayu Huang and Sean Meyn. Generalized error exponents for small sample univer- sal hypothesis testing. IEEE Transactions on Information Theory, 59(12):8157 -- 8181, 2013. Peter Kairouz, Keith Bonawitz, and Daniel Ramage. Discrete distribution estima- tion under local privacy. In ICML, volume 48 of JMLR Workshop and Conference Proceedings, pages 2436 -- 2444. JMLR.org, 2016. Sudeep Kamath, Alon Orlitsky, Dheeraj Pichapati, and Ananda Theertha Suresh. On learning distributions from their samples. In Peter Grünwald, Elad Hazan, and Satyen Kale, editors, Proceedings of The 28th Conference on Learning Theory, volume 40 of Proceedings of Machine Learning Research, pages 1066 -- 1100, Paris, France, 03 -- 06 Jul 2015. PMLR. [KR17] Daniel Kifer and Ryan M. Rogers. A new class of private chi-square tests. In Pro- ceedings of the 20th International Conference on Artificial Intelligence and Statistics, AISTATS '17, pages 991 -- 1000. JMLR, Inc., 2017. [O'D14] Ryan O'Donnell. Analysis of Boolean Functions. Cambridge University Press, 2014. [Pan08] Liam Paninski. A coincidence-based test for uniformity given very sparsely sampled discrete data. IEEE Transactions on Information Theory, 54(10):4750 -- 4755, 2008. [Pol03] David Pollard. Asymptopia, 2003. Manuscript. [Rub12] [She18] Ronitt Rubinfeld. Taming big probability distributions. XRDS: Crossroads, The ACM Magazine for Students, 19(1):24, sep 2012. Or Sheffet. Locally private hypothesis testing. In Jennifer Dy and Andreas Krause, edi- tors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 4612 -- 4621, Stockholmsmässan, Stockholm Sweden, 10 -- 15 Jul 2018. PMLR. [VV17] Gregory Valiant and Paul Valiant. An automatic inequality prover and instance opti- mal identity testing. SIAM Journal on Computing, 46(1):429 -- 455, 2017. 37 [War65] Stanley L. Warner. Randomized response: A survey technique for eliminating evasive answer bias. Journal of the American Statistical Association, 60(309):63 -- 69, 1965. [WHW+16] Shaowei Wang, Liusheng Huang, Pengzhan Wang, Yiwen Nie, Hongli Xu, Wei Yang, Xiang-Yang Li, and Chunming Qiao. Mutual information optimally local private dis- crete distribution estimation. arXiv preprint arXiv:1607.08025, 2016. [WLK15] Yue Wang, Jaewoo Lee, and Daniel Kifer. Revisiting differentially private hypothesis tests for categorical data. arXiv preprint arXiv:1511.03376, 2015. [YB17] Min Ye and Alexander Barg. Optimal schemes for discrete distribution estimation under local differential privacy. In 2017 IEEE International Symposium on Information Theory (ISIT), pages 759 -- 763, June 2017. A Proof of Theorem 14 Theorem 32 (Probability perturbation concentration, restated). Consider a vector δ such that Pi∈[k] δi = 0. Let random variables X1, . . . , Xk be 4-symmetric and Z = Pi∈[k] δiXi. Then, for every α ∈ (0, 1/4), Pr"(cid:18)EhX 2 1i − E[X1X2](cid:19) −s 38α 1 − 2α 1i − E[X1X2](cid:19)# ≥ α. 1 − 2α(cid:18)EhX 2 2 ≤ Z 2 kδk2 E(cid:2)X 4 1(cid:3) ≤ Proof. Since X1, X2, . . . , Xk are 4-symmetric, the expectations E[XaXbXcXd] depends only on the number of times each distinct element appears in the multiset {a, b, c, d}. For ease of notation, we replace the highest frequency element in {a, b, c, d} with 1, second highest with 2, and so on, to obtain a representation S and denote mS := E[Qi∈S Xi]. For instance, E(cid:2)X 2 a(cid:3) = m{1,1} and E[XaXb] = m{1,2} for distinct a, b. With this notation at our disposal, we are ready to proceed with the proof. 1 Note first that Moreover, for the variance of Z, we have E[Z] = Xi∈[k] δiE[Xi] = m{1} Xi∈[k] δi = 0. δ2 i1 δi1δi2 δi1δi2 E[Xi1Xi2] Var(Z) = EhZ 2i = Xi1,i2∈[k] EhX 2 i1i + Xi16=i2 = Xi1∈[k] = m{1,1}kδk2 2 + m{1,2}Xi6=j 2 + m{1,2} = m{1,1}kδk2 = (m{1,1} − m{1,2})kδk2 = (cid:18)EhX 2 (cid:16) Xi∈[k] 1i − E[X1X2](cid:19)kδk2 2 , 2 δi1δi2 E[Xi1Xi2] δi(cid:17)2 − Xi∈[k] δ2 i  38 (19) (20) where we used Pi∈[k] δi = 0 in the previous identity. It follows from Chebyshev's inequality that 1 Pr(cid:20) Z 2 ≤ 1 − 2α (cid:16)EhX 2 1i − E[X1X2](cid:17)kδk2 2(cid:21) ≥ 1 − 2α. For the lower tail bound, we derive a bound for E(cid:2)Z 4(cid:3) and invoke the Paley -- Zygmund inequality. Specifically, we have EhZ 4i = Xi1,i2,i3,i4 δi1δi2δi3δi4 E[Xi1Xi2Xi3Xi4] = m{1,1,1,1}Σ1 + m{1,1,1,2}Σ2,1 + m{1,1,2,2}Σ2,2 + m{1,1,2,3}Σ3 + m{1,2,3,4}Σ4, where we have abbreviated i1 δi2 + δ3 i2δi1(cid:17) , δ2 i1δ2 i2, Σ1 = kδk4 4, Σ2,1 = 4 Xi1<i2(cid:16)δ3 Σ2,2 = 6 Xi1<i2 Σ3 = 12 Xi1<i2<i3(cid:16)δ2 Σ4 = 24 Xi1<i2<i3<i4 i1 δi2δi3 + δi1δ2 i3(cid:17) , i2δi3 + δi1δi2δ2 δi1 δi2δi3δi4. The expressions for Σ's above can be simplified further by using Pi∈[k] δi = 0. Observe now that Σ1 + Σ2,1 + Σ2,2 + Σ3 + Σ4 = (cid:16) Xi∈[k] = 0. δi(cid:17)4 Also, for Σ2,1 and Σ2,2, we obtain Σ2,1 = 4 Xi Σ2,2 = 3 Xi δiXi i Xi δ2 δ3 i −Xi i −Xi δ2 4, δ4 i! = −4kδk4 i! = 3kδk4 δ4 2 − 3kδk4 4. Finally, the expressions for Σ's can be seen to satisfy, δi!2 Xi Xi δ2 i = Xi δ4 i + 1 2 Σ2,1 + 1 3 Σ2,2 + 1 6 Σ3, whereby Σ3 = −6Σ1 − 3Σ2,1 − 2Σ2,2 = 12kδk4 4 − 6kδk4 2 39 Combining the relations above, we obtain EhZ 4i = (cid:0)m{1,1,1,1} − 4m{1,1,1,2} − 3m{1,1,2,2} + 12m{1,1,2,3} − 6m{1,2,3,4}(cid:1)kδk4 4 +(cid:0)3m{1,1,2,2} − 6m{1,1,2,3} + 3m{1,2,3,4}(cid:1)kδk4 ≤ (cid:0)m{1,1,1,1} + 3m{1,1,2,2} + 15m{1,1,2,3}(cid:1)kδk4 2. 2 Note that by symmetry 2(m{1,1,2,2} − m{1,1,2,3}) = E[X 2 1 (X2 − X3)2] ≥ 0 and by symmetry and the Cauchy -- Schwarz inequality Therefore, the previous inequality yields m{1,1,1,1} = EhX 4 1i ≥ EhX 2 2i = m{1,1,2,2}. 1 X 2 We now take recourse to the Paley -- Zygmund inequality, restated below: EhZ 4i ≤ 19EhX 4 1ikδk4 2 . (21) Theorem 33 (Paley -- Zygmund (Refined version)). Suppose U is a non-negative random variable with finite variance. Then, for every θ ∈ [0, 1], Pr[ U > θE[U] ] ≥ (1 − θ)2E[U]2 Var U + (1 − θ)2E[U]2 . (22) Applying this to Z 2 and substituting the bounds of Eqs. (20) and (21) above, and setting θ := 1 −s 38α 1 − 2α we obtain 2 1(cid:3)kδk4 qE(cid:2)X 4 1(cid:3) − E[X1X2])kδk2 (E(cid:2)X 2 2 ≤ 1 −s 19α 1 − 2αpE[Z 4] E[Z 2] , Prh Z 2 ≥ θ(EhX 2 1i − E[X1X2])kδk2 2i ≥ which completes the proof. B Proof of Lemma 10 (1 − θ)2(E(cid:2)X 2 1(cid:3)kδk4 2 + (1 − θ)2(E(cid:2)X 2 1(cid:3) − E[X1X2])2kδk4 1(cid:3) − E[X1X2])2kδk4 2 2 19E(cid:2)X 4 = 2α , Lemma 34 (Variance of the Rappor-based estimator, restated). With T defined as in (10), we have Var(T ) ≤ 4kn2 + 8n3α2 Rkp − uk2 2 = 4kn2 + 8nE[T ] . Proof of Lemma 10. Letting again λ := αR have k + βR and λx := 1 n E[Nx] = αRpx + βR for x ∈ [k], we Var(T ) = Xx,y∈[k] Cov(f(Nx), f(Ny)) , 40 where f : [0,∞) → R is given by f(t) = (t − (n − 1)λ)2 − t + (n − 1)λ2. The key difficulty in analysis arises from the fact that Rappor renders the multiplicities Nx's dependent random variable. They are negatively associated, but since f is not monotone this does not imply that the cross covariance terms are non-positive. Thus, we need to take recourse to a more direct, elaborate treatment. Fix x 6= y in [k]. Expanding the covariance term, recalling E[f(Nx)] = n(n − 1)(λx − λ)2 from the proof of Lemma 9 and abbreviating r := 2(n − 1)λ + 1 and m := n − 1, we obtain after a few manipulations that Cov(f(Nx), f(Ny)) = E[(f(Nx) − E[f(Nx)])(f(Ny) − E[f(Ny)])] = EhN 2 yi − rEhN 2 x N 2 x Ny + NxN 2 yi + mnλy(2λ − λy)EhN 2 xi + mnλx(2λ − λx)EhN 2 yi + r2E[NxNy] − rmn(λy(2λ − λy)E[Nx] + λx(2λ − λx)E[Ny]) + m2n2λxλy(2λ − λx)(2λ − λy) = EhN 2 yi − rEhN 2 x N 2 − 2m2nλλx(2λ − λx)E[Ny] + m2λx(2λ − λx)E[Ny]2 + r2E[NxNy] + m2n2λxλy(2λ − λx)(2λ − λy). x Ny + NxN 2 yi − 2m2nλλy(2λ − λy)E[Nx] + m2λy(2λ − λy)E[Nx]2 Substituting r − 1 = 2mλ and EhN 2 for Nx, we get yi = E[Ny] + m n E[Ny]2 in the previous identity, and similarly Cov(f(Nx), f(Ny)) = EhN 2 yi − (2mλ + 1)EhN 2 x N 2 x Ny + NxN 2 yi − 2m2λ(2λ − λy)E[Nx]E[Ny] − 2m2λ(2λ − λx)E[Nx]E[Ny] + m2λx(2λ − λx)E[Ny]2 + m2λy(2λ − λy)E[Nx]2 + (2mλ + 1)2E[NxNy] + m2E[Nx]E[Ny](2λ − λx)(2λ − λy). (23) We proceed by evaluating the expressions for E[NxNy], E(cid:2)N 2 rately. x Ny(cid:3), EhNxN 2 yi, and EhN 2 x N 2 yi sepa- Specifically, by Fact 7, we get E[NxNy] = X1≤i,j≤n n Pr[ bix = 1, bjy = 1 ] = (λxλy − α2 Xi=1 = n2λxλy − nα2 Rp(x)p(y)) +Xi6=j Rp(x)p(y). λxλy (24) 41 x Ny(cid:3), we get Turning to E(cid:2)N 2 x Nyi = X1≤i,j,ℓ≤n EhN 2 Pr[ bix = 1, bjx = 1, bℓy = 1 ] = n Pr[ bix = 1, biy = 1 ] + 6 n = nλxλy − nα2 xλy + 2 n Rp(x)p(y) + n(n − 1)(n − 2)λ2 3!λ2 xλy 2!(cid:16)λxλy + 2λx(λxλy − α2 Rp(x)p(y))(cid:17) + n(n − 1)λxλy + 2n(n − 1)λ2 xλy − 2n(n − 1)α2 Rλxp(x)p(y), which yields EhN 2 x Nyi = n2λxλy − (2mλx + 1)nα2 For the last term, note that Rp(x)p(y) + mn2λ2 xλy. (25) EhN 2 x N 2 yi = X1≤i,j,i′,j′≤n = n(cid:16)λxλy − α2 Pr(cid:2) bix = 1, bjx = 1, bi′y = 1, bj′y = 1(cid:3) Rp(x)p(y)(cid:17) + n 2!(cid:16)2λxλy + 4λx(cid:16)λxλy − α2 Rp(x)p(y)(cid:17)2(cid:19) Rp(x)p(y)(cid:17)(cid:17) Rp(x)p(y)(cid:17) + 4(cid:16)λxλy − α2 y + 24λxλy(cid:16)λxλy − α2 xλy + 6λxλ2 Rp(x)p(y)(cid:17) +4λy(cid:16)λxλy − α2 + n + 24 n 3!(cid:16)6λ2 4!λ2 xλ2 y where the second identity follows from counting the different possibilities for the values taken by i, i′, j, j′; we divide into cases based on the number of different values taken and apply Fact 7 for This after a tedious simplification leads to each subcase. Note that the total number of terms is n + 14(cid:0)n EhN 2 yi = n(cid:16)λxλy − α2 x N 2 2(cid:1) + 36(cid:0)n Rp(x)p(y)(cid:17) + mn(cid:16)λxλy + 2λx(cid:16)λxλy − α2 3(cid:1) + 24(cid:0)n Rp(x)p(y)(cid:17) 4(cid:1) = n4. +2λy(cid:16)λxλy − α2 + mn(m − 1)(cid:16)λ2 + mn(m − 1)(m − 2)λ2 y + mn2(λ2 Rp(x)p(y)(cid:17) + 2(cid:16)λxλy − α2 xλy + λxλ2 xλ2 y y + 4λxλy(cid:16)λxλy − α2 y) + n2λxλy − 4α2 xλ2 Rmn (p(x)p(y)λx + p(x)p(y)λy) + 2α4 xλy + λxλ2 Rp(x)p(y)(cid:17)2(cid:19) Rp(x)p(y)(cid:17)(cid:17) Rm2np(x)p(y)λxλy Rmnp(x)2p(y)2 − α2 = m2n2λ2 − 2α2 Rnp(x)p(y) , (26) Upon combining Eqs. (24) to (26) with (23) and further simplifying the expressions, we get Cov(f(Nx), f(Ny)) = 2α4 Rn(n − 1)(cid:16)p(x)2p(y)2 − 2(n − 1)p(x)p(y)(cid:16)p(x) − 1 k(cid:17)(cid:16)p(y) − 1 k(cid:17)(cid:17) . 42 We proceed by summing both sides over pairs of distinct x, y ∈ [k] to obtain p(x)2p(y)2 − 4α4 Cov(f(Nx), f(Ny)) Xx6=y = 2α4 Rn(n − 1)Xx6=y Rn(n − 1)(cid:16)kpk4 Rn2 + 4α4 = 2α4 2 − kpk4 4(cid:17) − 4α4 Rn(n − 1)2kp − uk2 Rn(n − 1)2kp − uk2 2 , where we have used Px∈[k] p(x)(cid:16)p(x) − 1 ≤ 2α4 ≤ 2n2 + 4α2 terms. 2 Rn(n − 1)2 Xx6=y Rn(n − 1)2 p(x)p(y)(cid:16)p(x) − 1 kp − uk4 k(cid:17)(cid:16)p(y) − 1 k(cid:17) k(cid:17)2 p(x)2(cid:16)p(x) − 1  2 − Xx∈[k] k(cid:17) = kpk2 2 − 1/k = kp − uk2 2 and bounded the non-negative This completes our bound for the cross-variance terms. Turning now to the variances, we note that Var(f(Nx)) = 2n(n − 1)λ2 1 8 ≤ n2 + α2 x(1 − λx)2 + 4n(n − 1)2λx(1 − λx)(λ − λx)2 k(cid:17)2 Rn(n − 1)2(cid:16)p(x) − 1 , where the previous inequality holds since λx ∈ [0, 1]. It follows that Var(f(Nx)) ≤ 1 8 n2k + α2 Rn(n − 1)2kp − uk2 2 . Xx∈[k] Putting everything together, we conclude Cov(f(Nx), f(Ny)) ≤ 17 8 n2 + 5α2 Rn(n − 1)2kp − uk2 2 , Var(T ) = Xx∈[k] Var(f(Nx)) + Xx6=y proving the lemma. C Proof of Theorem 28 Theorem 35 (Joint probability perturbation concentration, restated). Consider a matrix δ ∈ Rk×k such that, for every i0, j0 ∈ [k], Pj∈[k] δi0,j = Pi∈[k] δi,j0 = 0. Let random variables X = (X1, . . . , Xk) and Y = (Y1, . . . , Yk) be independent and uniformly distributed over k-length binary sequences of weight k/2. Define Z = P(i,j)∈[k]×[k] δijXiYj. Then, there exist constants c1, c2, ρ > 0 such that Pr" Z 2 kδk2 F ∈ [c1, c2]# ≥ ρ. Proof. The proof is similar to that of Theorem 14, with further technicalities difficulties arising since the random variables (Xi, Yj) assigned as weights to δij, 1 ≤ i, j ≤ k, are not 4-symmetric (as a pair). However, δ has an additional structure since both its rows and columns sum to zero; we 43 complete the proof by exploiting this property and the fact that Xi's and Yj's are individually 4- symmetric. As before, we use the notation mS := E[Qi∈S Xi], and moreover, let m′S := E[Qi∈S Yi]. First, observe that by independence of Xi's and Yj's and since P(i,j)∈[k]×[k] δij = 0, we have E[Z] = X(i,j)∈[k]×[k] δij E[Xi]E[Yj] = m{1}m′ {1} X(i,j)∈[k]×[k] δij = 0 . Furthermore, Var(Z) = EhZ 2i = X(i1,j1)∈[k]×[k] X(i2,j2)∈[k]×[k] δi1j1δi2j2 E[Xi1Xi2]E[Yj1Yj2] = Xi1,i2 = Xi1,i2 = Xi1,i2 = (m′ δi1j1δi2j2 E[Xi1Xi2] Xj1,j2 E[Xi1Xi2] m′ {1,1}Xj1 E[Xi1Xi2] (m′ {1,1} − m′ {1,1} − m′ )Xi1,i2Xj {1,2} E[Yj1Yj2] δi1j1δi2j1 + m′ {1,2} )Xj δi1jδi2j E[Xi1Xi2] , {1,2} Xj16=j2 δi1jδi2j + m′ δi1j1δi2j2  δi1j(cid:17)2! {1,2}(cid:16)Xj where the previous identity uses Pj δi1j = 0. Repeating the same manipulations with the outer sum, we get Var(Z) = EhZ 2i = (m′ {1,1} − m′ {1,2} = (m′ {1,1} − m′ {1,2} = (m{1,1} − m{1,2})(m′ ij + m{1,2} Xi16=i2 δ2 )Xj m{1,1}Xi )Xj (m{1,1} − m{1,2})Xi {1,1} − m′ )kδk2 F . {1,2} δi1jδi2j! ij + m{1,2}(cid:16)Xi δ2 δi,j(cid:17)2! Up to this point, our calculations are valid for any independent choice of 4-symmetric (X1, . . . , Xk) and (Y1, . . . , Yk). For our specific choice, using calculations from the proof of Corollary 15, we obtain the following: 1 16kδk2 F ≤ Var(Z) = 1 4 Eh(X1 − X2)2iEh(Y1 − Y2)2ikδk2 F ≤ 1 4kδk2 F . It remains to bound the fourth moment of Z; for simplicity, we provide this proof only for our specific choice of random variables. We have EhZ 4i = X(i1,j1) X(i2,j2) X(i3,j3) X(i4,j4) δi1j1δi2j2δi3j3δi4j4 E[Xi1Xi2Xi3Xi4]E[Yj1Yj2Yj3Yj4] = Xi1,i2,i3,i4 E[Xi1Xi2Xi3Xi4] Xj1,j2,j3,j4 E[Yj1Yj2Yj3Yj4]δi1j1δi2j2δi3j3δi4j4 . 44 Consider the inner summation for an arbitrary fixed choice of i1, i2, i3, i4. We show first that the inner summation can be expressed as αkXj δi1jδi2jδi3jδi4j + βkXj δi1jδi2j ·Xj δi3jδi4j, (27) for appropriate coefficients αk and βk. To that end, we introduce the notations: For ℓ ≤ 4, denote pℓ(j1, . . . , jℓ) := Pr[ Yj1 = 1, . . . , Yjℓ = 1 ] pℓ(j1, . . . , jℓ−1) := Pr(cid:2) Yjℓ = 1 Yj1 = 1, . . . , Yjℓ−1 = 1(cid:3), jℓ /∈ {j1, . . . , jℓ−1}, pℓ(j1, . . . , jm) := Pr(cid:2) Yjℓ = 1 Yj1 = 1, . . . , Yjm = 1, Yjm+1 = 1, . . . , Yjℓ−1 = 1(cid:3), jr /∈ {j1, . . . , jm}, jr distinct for m + 1 < r ≤ ℓ, and the corresponding notation qℓ(j1, . . . , jm) := 1−pℓ(j1, . . . , jm). With this in hand, we can write Xj1,j2,j3,j4 E[Yj1Yj2Yj3Yj4] δi1j1δi2j2δi3j3δi4j4 = Xj1,j2,j3 = Xj1,j2,j3 = Xj1,j2,j3 δi4j4 δi1j1δi2j2δi3j3  Xj4∈{j1,j2,j3} p3(j1, j2, j3)δi1j1δi2j2δi3j3 p3(j1, j2, j3)q4(j1, j2, j3)δi1j1δi2j2δi3j3 Xj4∈{j1,j2,j3}  Xj4∈{j1,j2,j3} E[Yj1Yj2Yj3] + Xj4 /∈{j1,j2,j3} δi4j4 E[Yj1Yj2Yj3Yj4]  δi4j4  δi4j4 + p4(j1, j2, j3) Xj4 /∈{j1,j2,j3} δi4j4, above has, by symmetry, the form p3(j1, j2, j3)q4(j1, j2, j3)δi1j1δi2j2δi3j3δi4j1 where we have used Pj δi4,j = 0 in the previous identity. Next, note that each term in the sum Xj1,j2,j3 = Xj1,j2 = Xj1,j2 where we have once again used Pj3 δi3,j3 = 0 to obtain the last line from the second-to-last. This p2(j1, j2)(cid:16)q3(j1, j2) Xj3∈{j1,j2} p2(j1, j2)(cid:16)1 − p3(j1, j2)(cid:0)1 + q4(j1, j2)(cid:1)(cid:17) Xj3∈{j1,j2} δi1j1δi2j2δi3j3δi4j1 + p3(j1, j2)q4(j1, j2) Xj3 /∈{j1,j2} δi1j1δi2j2δi3j3δi4j1(cid:17) leaves us with terms of the form δi1j1δi2j2δi3j3δi4j1, Xj1,j2 p2(j1, j2)(cid:16)1 − p3(j1, j2)(cid:0)1 + q4(j1, j2)(cid:1)(cid:17) (δi1j1δi2j2δi3j1δi4j1 + δi1j1δi2j2δi3j2δi4j1) . Finally, splitting the summation above into terms with j1 = j2 and j1 6= j2, we end up with terms of the form (27). Note that the resulting coefficients αk, βk entail terms dependent on k which can be handled and bounded (crucially, independently of k) in the manner of proof of Corollary 15. To complete the proof, we handle each term in (27) separately. For the first, we obtain Xj Xi1,i2,i3,i4 δi1jδi2jδi3jδi4j E[X1X2X3X4] ≤ 19EhX 4 1iXj (cid:16)Xi δ2 ij(cid:17)2 45 ≤ 19EhX 4 1ikδk2 F , where the inequality uses (21). For the second term, note that Xi1,i2,i3,i4 Xi1Xi2Xi3Xi4Xj δi1jδi2j ·Xj′ δi3j′δi4j′ = (cid:16)Xj (cid:16)Xi Xiδij(cid:17)2(cid:17)2 , whereby the expected value of the left-side can be bounded by E  Xj Xi  Xiδij!2  2  = Xj,j′ Xiδij′!2 E Xiδij!2 Xi  Xi  vuuut E E Xiδij!4 Xiδij′!4 Xi Xi ≤ Xj,j′     ≤ 19EhX 4 1iXj,j′ kδ·,jk2 2kδ·,j′k2 2, where the final inequality uses (21). The sum on the right-side can be seen to simplify as Xj,j′ kδ·,jk2 2kδ·,j′k2 2 = Xj,j′ Xi δ2 i,jXi Therefore, on combining the observations above, we obtain δ2 i,j′ =  Xij 2 δ2 i,j  = kδk4 F . for an appropriate absolute constant c′. The proof is completed in the manner of that of Theorem 14 using the Paley -- Zygmund inequality. EhZ 4i ≤ c′kδk4 F , 46
1802.07090
1
1802
2018-02-20T12:43:05
The Parameterized Complexity of Packing Arc-Disjoint Cycles in Tournaments
[ "cs.DS" ]
Given a directed graph $D$ on $n$ vertices and a positive integer $k$, the Arc-Disjoint Cycle Packing problem is to determine whether $D$ has $k$ arc-disjoint cycles. This problem is known to be W[1]-hard in general directed graphs. In this paper, we initiate a systematic study on the parameterized complexity of the problem restricted to tournaments. We show that the problem is fixed-parameter tractable and admits a polynomial kernel when parameterized by the solution size $k$. In particular, we show that it can be solved in $2^{\mathcal{O}(k \log k)} n^{\mathcal{O}(1)}$ time and has a kernel with $\mathcal{O}(k)$ vertices. The primary ingredient in both these results is a min-max theorem that states that every tournament either contains $k$ arc-disjoint triangles or has a feedback arc set of size at most $6k$. Our belief is that this combinatorial result is of independent interest and could be useful in other problems related to cycles in tournaments.
cs.DS
cs
The Parameterized Complexity of Packing Arc-Disjoint Cycles in Tournaments R. Krithika1, Abhishek Sahu1, Saket Saurabh1,2, and Meirav Zehavi3 1The Institute of Mathematical Sciences, HBNI, Chennai, India. , {rkrithikaasahusaket}@imsc.res.in 2University of Bergen, Bergen, Norway 3Ben-Gurion University, Beersheba, Israel. [email protected] Abstract Given a directed graph D on n vertices and a positive integer k, the Arc-Disjoint Cycle Packing problem is to determine whether D has k arc-disjoint cycles. This problem is known to be W[1]-hard in general directed graphs. In this paper, we initi- ate a systematic study on the parameterized complexity of the problem restricted to tournaments. We show that the problem is fixed-parameter tractable and admits a polynomial kernel when parameterized by the solution size k. In particular, we show that it can be solved in 2O(k log k)nO(1) time and has a kernel with O(k) vertices. The primary ingredient in both these results is a min-max theorem that states that every tournament either contains k arc-disjoint triangles or has a feedback arc set of size at most 6k. Our belief is that this combinatorial result is of independent interest and could be useful in other problems related to cycles in tournaments. 1 Introduction Given a (directed or undirected) graph G and a positive integer k, the Disjoint Cycle Packing problem is to determine whether G has k (vertex or arc/edge) disjoint cycles. Packing disjoint cycles is a fundamental problem in Graph Theory and Algorithm Design with applications in several areas. Since the publication of the classic Erdos-P´osa theorem in 1965 [17], this problem has received significant scientific attention in various algorithmic realms. In particular, Vertex-Disjoint Cycle Packing in undirected graphs is one of the first problems studied in the framework of parameterized complexity. In this framework, each problem instance is associated with a non-negative integer k called parameter, and a problem is said to be fixed-parameter tractable (FPT) if it can be solved in f(k)nO(1) time for some function f, where n is the input size. For convenience, the running time f(k)nO(1) where f grows super-polynomially with k is denoted as O⋆(f(k)). A kernelization algorithm is a polynomial-time algorithm that transforms an arbitrary instance of the problem to an equivalent instance of the same problem whose size is bounded by some computable function g of the parameter of the original instance. The resulting instance is called a kernel and if g is a polynomial function, then it is called a polynomial kernel and we say that the problem admits a polynomial kernel. Kernelization typically involves applying a set of rules (called reduction rules) to the given instance to produce another instance. A reduction rule is said to be safe if it is sound and complete, i.e., applying it to the given instance produces an equivalent instance. In order to classify parameterized problems as being FPT or not, the W-hierarchy is defined: FPT ⊆ W[1] ⊆ W[2] ⊆ · · · ⊆ XP. It is believed that the subset relations in this sequence are all strict, and a parameterized problem that 1 is hard for some complexity class above FPT in this hierarchy is said to be fixed-parameter intractable. Further details on parameterized algorithms can be found in [15, 16, 19]. Vertex-Disjoint Cycle Packing in undirected graphs is FPT with respect to the solution size k [10, 25] but has no polynomial kernel unless NP ⊆ coNP/poly [11]. In contrast, Edge-Disjoint Cycle Packing in undirected graphs admits a kernel with O(k log k) vertices (and is therefore FPT) [11]. On directed graphs, Vertex-Disjoint Cycle Packing and Arc-Disjoint Cycle Packing are equivalent and turn out to be W[1]-hard [23, 30]. Therefore, studying these problems on a subclass of directed graphs is a natural direction of research. Tournaments form a mathematically rich subclass of directed graphs with interesting structural and algorithmic properties [5,26]. A tournament is a directed graph in which there is a single arc between every pair of distinct vertices. Tournaments have several applications in modeling round-robin tournaments and in the study of voting theory and social choice theory. Further, the combinatorics of inclusion relations of tournaments is reasonably well-understood [13]. A seminal result in the theory of undirected graphs is the Graph Minor Theorem (also known as the Robertson and Seymour theorem) that states that undirected graphs are well-quasi-ordered under the minor relation [29]. Developing a similar theory of inclusion relations of directed graphs has been a long- standing research challenge. However, there is such a result known for tournaments that states that tournaments are well-quasi-ordered under the strong immersion relation [13]. In fact, this result also holds for a superclass of tournaments, namely, semicomplete digraphs [7]. A semicomplete digraph is a directed graph in which there is at least one arc between every pair of distinct vertices. Many results (including some of the ones described in this work) for tournaments straightaway hold for semicomplete digraphs too. This is another reason why tournaments is one of the most well-studied classes of directed graphs. Feedback Vertex Set and Feedback Arc Set are two well-explored algorithmic problems on tournaments. A feedback vertex (arc) set is a set of vertices (arcs) whose dele- tion results in an acyclic graph. Given a directed graph and a positive integer k, Feedback Arc (Vertex) Set is the problem of determining if the graph has a set of at most k arcs (vertices) whose deletion results in an acyclic graph. These problems are the dual problems of Vertex-Disjoint Cycle Packing and Arc-Disjoint Cycle Packing, respectively. They are known to be NP-hard on tournaments [2, 12, 14, 31] but are FPT when parameter- ized by k [3,20,22,28]. Further, Feedback Arc Set in Tournaments has a kernel with O(k) vertices [9] and Feedback Vertex Set in Tournaments has a kernel with O(k1.5) vertices [24]. Though Feedback Arc Set and Feedback Vertex Set are intensively studied in tournaments, their duals have surprisingly not been considered in the literature until recently [8, 24]. Any tournament that has a cycle also has a triangle [6]. Therefore, if a tournament has k vertex-disjoint cycles, then it also has k vertex-disjoint triangles. Thus, Vertex-Disjoint Cycle Packing in tournaments is just packing vertex-disjoint trian- gles. A straightforward application of the color coding technique shows that this problem is FPT and a kernel with O(k2) vertices is an immediate consequence of the quadratic element kernel known for 3-Set Packing [1]. Recently, a kernel with O(k1.5) vertices was shown for this problem using interesting variants and generalizations of the popular expansion lemma [24]. Focusing on Arc-Disjoint Cycle Packing in tournaments, it is easy to verify that a tournament that has k arc-disjoint cycles need not necessarily have k arc-disjoint trian- gles. This observation hints that packing arc-disjoint cycles could be significantly harder than packing vertex-disjoint cycles. This is the starting point of our study. In this pa- per, we investigate the parameterized complexity of Arc-Disjoint Cycle Packing in tournaments. 2 Arc-Disjoint Cycle Packing in Tournaments (ACT) Input: A tournament T and a positive integer k. Question: Do there exist k arc-disjoint cycles in T ? Parameter: k We show that ACT is FPT and admits a polynomial kernel. En route, we discover an interesting min-max relation analogous to the classical Erdos-P´osa theorem. In particular, we show the following results. • A tournament T has k arc-disjoint cycles if and only if T has k arc-disjoint cycles each of length at most 2k + 1 (Lemma 1). • Every tournament T either contains k arc-disjoint triangles or has a feedback arc set of size at most 6(k − 1) (Theorem 4). • ACT admits a kernel with O(k) vertices (Theorem 13). • ACT can be solved in O⋆(2O(k log k)) time (Theorem 14). The paper is organized as follows. In Section 2, we give some definitions related to directed graphs, cycles and tournaments. In Section 3, we show the first two combinatorial results about tournaments. In Section 4, we show that ACT is FPT and admits a polynomial kernel. In Section 5, we describe an improved FPT algorithm and a linear vertex kernel for ACT. Finally, we conclude with some remarks in Section 6. 2 Preliminaries The set {1, 2, . . . , n} is denoted by [n]. A directed graph (or digraph) is a pair consisting of a set V of vertices and a set A of arcs. An arc is specified as an ordered pair of vertices. We will consider only simple unweighted digraphs. For a digraph D, V(D) and A(D) denote the set of its vertices and the set of its arcs, respectively. Two vertices u, v are said to be adjacent in D if (u, v) ∈ A(D) or (v, u) ∈ A(D). For an arc e = (u, v), head(e) denotes v and tail(e) denotes u. For a vertex v ∈ V(D), its out-neighborhood, denoted by N+(v), is the set {u ∈ V(D) (v, u) ∈ A(D)} and its in-neighborhood, denoted by N−(v), is the set {u ∈ V(D) (u, v) ∈ A(D)}. For a set of arcs F, V(F) denotes the union of the sets of endpoints of arcs in F. For a set X ⊆ V(D) ∪ E(D), D − X denotes the digraph obtained from D by deleting X. A path P in D is a sequence (v1, . . . , vk) of distinct vertices such that for each i ∈ [k − 1], (vi, vi+1) ∈ A(D). The set {v1, . . . , vk} is denoted by V(P) and the set {(vi, vi+1) i ∈ [k − 1]} is denoted by A(P). A path P is called an induced (or chordless) path if there is no arc in D that is between two non-consecutive vertices of P. A cycle C in D is a sequence (v1, . . . , vk) of distinct vertices such that (v1, . . . , vk) is a path and (vk, v1) ∈ A(D). The set {v1, . . . , vk} is denoted by V(C) and the set {(vi, vi+1) i ∈ [k − 1]} ∪ {(vk, v1)} is denoted by A(C). A cycle C = (v1, . . . , vk) is called an induced (or chordless) cycle if there is no arc in D that is between two non-consecutive vertices of C with the exception of the arc (vk, v1). The length of a path or cycle X is the number of vertices in it and is denoted by X. For a set C of paths or cycles, A(C) denotes the set {e ∈ A(D) ∃C ∈ C, e ∈ A(C)}. A cycle on three vertices is called a triangle. A digraph is said to be triangle-free if it has no triangles. A digraph is called a directed acyclic graph if it has no cycles. Any directed acyclic graph D has an ordering σ called topological ordering of its vertices such that for each (u, v) ∈ A(D), σ(u) < σ(v) holds. A feedback vertex (arc) set is a set of vertices (arcs) whose deletion results in an acyclic graph. For a digraph D, let fas(D) denote the size of a minimum feedback arc set of D. A tournament T is a digraph in which for every pair u, v 3 of distinct vertices either (u, v) ∈ A(T ) or (v, u) ∈ A(T ) but not both. A tournament is called transitive if it is a directed acyclic graph and a transitive tournament has a unique topological ordering. 3 An Erdos-P´osa Type Theorem The classical Erdos-P´osa theorem for cycles in undirected graphs states that there exists a function f(k) = O(k log k) such that for each non-negative integer k, every undirected graph either contains k vertex-disjoint cycles or has a feedback vertex set consisting of f(k) vertices [17]. An interesting consequence of this theorem is that it leads to an FPT algorithm for Vertex-Disjoint Cycle Packing. It is well known that the treewidth (tw ) of a graph is not larger than the size of its feedback vertex set, and that a naive dynamic programming scheme solves Vertex-Disjoint Cycle Packing in 2O(tw log tw )n time and exponential space (see, e.g., [15]). Thus, the existence of a 2O(k log2 k)n time algorithm that uses exponential space can be viewed as a direct consequence of the Erdos-P´osa theorem (see [25] for more details). In this section, we show that that there exists a function h(k) such that for each non- negative integer k, every tournament either contains k arc-disjoint cycles or has a feedback arc set consisting of h(k) arcs. First, we show that h(k) is O(k2) and then improve it to O(k). The following result is crucial in proving the former. Lemma 1. Let k and r be positive integers such that r ≤ k. If a tournament T contains a set C of r arc-disjoint cycles, then it also contains a set C ∗ of r arc-disjoint cycles each of length at most 2k + 1. Proof. Let C be a set of r arc-disjoint cycles in T that minimizes PC∈C C. If every cycle in C is a triangle, then the claim trivially holds. Otherwise, let C be a longest cycle in C and let ℓ denote its length. Let vi, vj be a pair of non-consecutive vertices in C. Then, either (vi, vj) ∈ A(T ) or (vj, vi) ∈ A(T ). In any case, the arc e between vi and vj along with A(C) forms a cycle C ′ of length less than ℓ with A(C ′) \ {e} ⊂ A(C). By our choice of C, this implies that e is an arc in some other cycle bC ∈ C. This property is true for the arc between any pair of non-consecutive vertices in C. Therefore, we have (cid:0)ℓ 2(cid:1) − ℓ ≤ ℓ(k − 1) leading to ℓ ≤ 2k + 1. This lemma essentially shows that it suffices to determine the existence of k arc-disjoint cycles in T each of length at most 2k + 1 in order to determine if (T, k) is a yes-instance of ACT. This leads to the following quadratic Erdos-P´osa bound. Recall that for a digraph D, fas(D) denotes the size of a minimum feedback arc set of D. Theorem 2. For every non-negative integer k, every tournament T either contains k arc- disjoint cycles or has a feedback arc set of size O(k2). Proof. Suppose C is a maximal set of arc-disjoint cycles in T . If C ≥ k, then the claim holds. Otherwise, from Lemma 1, we may assume that each cycle in C is of length at most 2k + 1. Let D denote the digraph obtained from T by deleting the arcs that are in some cycle in C. Clearly, D is acyclic as C is maximal. Then, it follows that fas(T ) ≤ (2k + 1)(k − 1). Next, we strengthen this result to arrive at a linear min-max bound. We will use the following lemma in the process. For a digraph D, let Λ(D) denote the number of non- adjacent pairs of vertices in D. That is, Λ(D) is the number of pairs u, v of vertices of D such that neither (u, v) ∈ A(D) nor (v, u) ∈ A(D). 4 Lemma 3. Let D be a triangle-free digraph in which for every pair u, v of distinct vertices, at most one of (u, v) or (v, u) is in A(D). Then, fas(D) ≤ Λ(D). Proof. We will prove the claim by induction on V(D). The claim trivially holds for V(D) ≤ 2. Suppose V(D) ≥ 3. First, we apply a simple preprocessing rule on D. If D has a vertex v that either has no in-neighbours or has no out-neighbours, then we delete v from D to get the digraph D ′. Clearly, there is no cycle in D that contains v and thus fas(D) = fas(D ′). Therefore, subsequently, we may assume that for every vertex v ∈ V(D), N+(v) 6= ∅ and N−(v) 6= ∅. For a vertex v ∈ V(D), we define first(v) to be the number of induced paths of length 3 with v as the first vertex. Similarly, we define mid(v) to be the number of induced paths of length 3 with v as the second vertex. We claim that Pv∈V(D) first(v) = Pv∈V(D) mid(v). Consider an induced path P = (u, v, w) of length 3 in D. Then, P contributes 1 to first(u) and does not contribute to first(x) for any x 6= u. Further, P contributes 1 to mid(v) and does not contribute to mid(x) for any x 6= v. Therefore, P contributes 1 to Pv∈V(D) first(v) and Pv∈V(D) mid(v). Hence, Pv∈V(D) first(v) = Pv∈V(D) mid(v). It now follows that there is a vertex u ∈ V(D) such that first(u) ≤ mid(u). Define the sets Iu, Ou and Ru as Iu = N−(v), Ou = N+(v) and Ru = V(D) \ (Iu ∪ Ou). That is, Iu is the set of in-neighbours of u, Ou is the set of out-neighbours of u and Ru is the set of vertices that are not adjacent with u. Observe that Iu 6= ∅ and Ou 6= ∅. Let D1 and D2 be the subgraphs D[Iu ∪ Ru] and D[Ou], respectively. Then, as D1 and D2 are vertex-disjoint induced subgraphs of D, we have Λ(D) ≥ Λ(D1) + Λ(D2). Now, any induced path P = (x, u, y) of length 3 in D with u as the second vertex satisfies the property that x ∈ V(D1) and y ∈ V(D2). Further, (x, y), (y, x) /∈ A(D) due to the facts that P is an induced path and D is triangle-free. Then, mid(u) is the number of pairs x, y of non-adjacent vertices with x ∈ Iu, y ∈ Ou. Therefore, Λ(D) ≥ Λ(D1) + Λ(D2) + mid(u) as Iu ⊆ V(D1), Ou ⊆ V(D2) and V(D1) ∩ V(D2) = ∅. Let E denote the set of arcs (x, y) in D with x ∈ Ou and y ∈ Ru. Let F1 and F2 be feedback arc sets of D1 and D2, respectively. We claim that F = F1 ∪ F2 ∪ E is a feedback arc set of D. If there is a cycle C in the graph obtained from D by removing arcs in F, then C has an arc (p, q) with p ∈ V(D1), q ∈ V(D2) and an arc (r, s) with r ∈ V(D2), s ∈ V(D1). However, as D has no triangle, any arc (x, y) with x ∈ V(D2) and y ∈ V(D1) satisfies x ∈ Ou and y ∈ Ru. That is, (r, s) ∈ E leading to a contradiction. Therefore, it follows that fas(D) ≤ fas(D1) + fas(D2) + E. Note that E = first(u) as any induced path P = (u, v, w) starting at u satisfies v ∈ Ou, w ∈ Ru and any arc (x, y) with x ∈ Ou, y ∈ Ru corresponds to an induced path (u, x, y) starting at u. Also, by the choice of u, we have first(u) ≤ mid(u). Therefore, fas(D) ≤ fas(D1) + fas(D2) + mid(u). By induction hypothesis, we have fas(D1) ≤ Λ(D1) and fas(D2) ≤ Λ(D2). Hence, fas(D) ≤ Λ(D1) + Λ(D2) + mid(u). As Λ(D) ≥ Λ(D1) + Λ(D2) + mid(u), we have fas(D) ≤ Λ(D). This leads to the following main result of this section. Theorem 4. For every non-negative integer k, every tournament T either contains k arc- disjoint triangles or has a feedback arc set of size at most 6(k − 1) that can be obtained in polynomial time. Proof. Suppose C is a maximal set of arc-disjoint triangles in T with C ≤ k − 1. Let D denote the digraph obtained from T by deleting the arcs that are in some triangle in C. Clearly, D has no triangle and Λ(D) ≤ 3(k − 1). From Lemma 3, we have fas(D) ≤ 3(k − 1). Also, if F is a feedback arc set of D, then F ∪ A(C) is a feedback arc set of T . Therefore, fas(T ) ≤ 6(k − 1). 5 We will use this result crucially in showing that ACT can be solved in O⋆(2O(k log k)) time and admits a kernel with O(k) vertices. 4 Fixed-Parameter Tractability and Kernelization Complex- ity In this section, we show that ACT is FPT and admits a polynomial kernel. We show that the first result is a direct consequence of Lemma 1 and the second follows from Theorem 4. 4.1 An FPT Algorithm Consider an instance I = (T, k) of ACT. Let n denote V(T ) and m denote A(T ). Suppose I is a yes-instance and C is a set of k arc-disjoint cycles in T . From Lemma 1, we may assume that the total number of arcs that are in cycles in C is at most (2k + 1)k. Using this observation, we proceed as follows. We color the arcs of T uniformly at random from the color set [ℓ] where ℓ = 2k2 + k. Let χ : A(T ) → [ℓ] denote this coloring. Proposition 5 ( [4]). If E is a subset of A(T ) of size ℓ, then the probability that the arcs in E are colored with pairwise distinct colors is at least e−ℓ. Next, we define the notion of a colorful solution for our problem. Definition 4.1. (Colorful set of cycles) A set C of arc-disjoint cycles in T that satisfies the property that for any two (not necessarily distinct) cycles C, C ′ ∈ C and for any two distinct arcs e ∈ A(C), e ′ ∈ A(C ′), χ(e) 6= χ(e ′) holds is said to be a colorful set of cycles. Rephrasing Proposition 5 in the context of our problem, we have the following observa- tion. Observation 6. If C is a solution of I with the property that for each C ∈ C, C ≤ 2k + 1, then C is a colorful set of cycles in T with probability at least e−ℓ. Armed with the guarantee that a solution (if one exists) of I is colorful with sufficiently high probability, we focus on finding a colorful set of cycles in T . Lemma 7. If T has a colorful set of k cycles, then such a set can be obtained in ℓ!nO(1) time. i ) = V(T ) and A(Dσ Proof. Consider a permutation σ of [ℓ]. For each i ∈ [k], let Dσ i denote the subgraph of T with V(Dσ i ) = A(T ) ∩ {(u, v) ∈ A(T ) 2(i − 1)k + i ≤ σ(χ((u, v))) ≤ 2k + 2(i − 1)k + i}. That is, A(Dσ 1 ) is the set of arcs of T that are colored with the first 2k + 1 colors, A(Dσ 2 ) is the set of arcs of T that are colored with the next 2k + 1 colors and so on. For each i ∈ [k], let Cσ i . Let Cσ denote the set {Cσ i ∈ [k]}. For each permutation σ of [ℓ], we compute the corresponding set Cσ. If i T has a colorful set of k cycles, then Cπ = k for some permutation π of [ℓ]. Therefore, by computing Cπ for every permutation π of [ℓ], we can obtain a colorful set of k cycles in T (if one exists). i denote a cycle (if one exists) in Dσ Using the standard technique of derandomization of color coding based algorithms [4, 15, 27], we have the following result by taking m = A(T ). Proposition 8 ( [4, 15, 27]). Given integers m, ℓ ≥ 1, there is a family Fm,ℓ of coloring functions χ : A(T ) → [ℓ] of size eℓℓO(log ℓ) log m that can be constructed in eℓℓO(log ℓ)m log m time satisfying the following property: for every set E ⊆ A(T ) of size ℓ, there is a function χ ∈ Fm,ℓ such that χ(e) 6= χ(e ′) for any two distinct arcs e, e ′ ∈ E. 6 Then, we have the following result. Theorem 9. ACT can be solved in O⋆(2O(k2 log k)) time. Proof. Consider an instance I = (T, k) of ACT. Let ℓ = 2k2 + k. First, we compute the family Fm,ℓ of eℓℓO(log ℓ) log m coloring functions using Proposition 8 where m is the number of arcs in T . Then, for each coloring function χ : A(T ) → [ℓ] in Fm,ℓ, we determine if T has a colorful set of k cycles using Lemma 7. Due to the properties of Fm,ℓ guaranteed by Proposition 8, it follows that I is a yes-instance if and only if T has a set of k cycles that is colorful with respect to at least one of the coloring functions. The overall running time is O⋆(2O(k2 log k)). Observe that the running time of the algorithm to find a colorful set of k cycles can be improved to 2ℓnO(1) by employing a standard dynamic programming scheme. This will result in an O⋆(2O(k2)) time algorithm for ACT. However, we skip the details of the same as we will describe an O⋆(2O(k log k)) time algorithm for ACT in Section 5. 4.2 A Polynomial Kernel Now, we show that ACT admits a polynomial kernel. We use Theorem 4 to describe a quadratic vertex kernel. Theorem 10. ACT admits a kernel with O(k2) vertices. Proof. Let (T, k) denote an instance of ACT. From Theorem 4, we know that T has either k arc-disjoint triangles or a feedback arc set F of size at most 6(k − 1). In the former case, we return a trivial yes-instance of constant size as the kernel. In the latter case, S = V(F) is a feedback vertex set of T of size at most 12k. Let D denote the transitive tournament T − S and δ denote its unique topological ordering. Observe that for each v ∈ S, the subtournament of T induced by V(D) ∪ {v} is also transitive. If there is a cycle in D ∪ {v}, then this cycle (which is also a cycle in T ) has no arc from F leading to a contradiction. For each v ∈ S, let R(v) be the set of first (with respect to δ) 2k + 1 vertices in N+(v). Let T ′ be the subtournament of T induced by S ∪ {R(v) v ∈ S}. Clearly, T ′ has O(k2) vertices. We claim that (T ′, k) is the required kernel of (T, k). We need to show that T has k arc-disjoint cycles if and only if T ′ has k arc-disjoint cycles. The reverse direction of the claim holds trivially. Let us now prove the forward direction. Suppose T has a set of k arc- disjoint cycles. Among all such sets, let C be one that minimizes PC∈C V(C)∩(V(T )\V(T ′)). Suppose there is a cycle C in C that is not in T ′. Then, there is a vertex vi ∈ V(C) that is not in T ′. As argued earlier, any cycle in T has at least two vertices from S. Let x and y be two such vertices in C where (x, v1, . . . , vi, . . . , vq, y) is a path in C from x to y with internal vertices from V(D). The subtournaments bT = D ∪ {x} and eT = D ∪ {y} are transitive with unique topological orderings σ and π, respectively. Observe that for all distinct u, v ∈ V(D), π(u) < π(v) if and only if σ(u) < σ(v). As (x, v1, . . . , vi, . . . , vq) is a path in bT , it follows that σ(x) < σ(vj) for each j ∈ [q]. Similarly, as (v1, . . . , vi, . . . , vq, y) is a path in eT , we have π(y) > π(vj) for each j ∈ [q]. As vi /∈ V(T ′), it follows that vi /∈ R(x) and R(x) = 2k + 1. Then, there is at least one vertex z in R(x) such that the arcs (x, z) and (z, y) are not in any cycle in C. Now, σ(z) < σ(vi) as z, vi ∈ N+(x), vi /∈ R(x) and z ∈ R(x). Thus, we have π(z) < π(vi). As π(vi) < π(y), it follows that (z, y) ∈ A(T ) as π(z) < π(y). Then, by replacing the path (x, v1, . . . , vi, . . . , vq, y) by (x, z, y), we obtain another set C ′ of k arc-disjoint cycles such that PC∈C V(C) ∩ (V(T ) \ V(T ′)) > PC∈C ′ V(C) ∩ (V(T ) \ V(T ′)). However, this leads to a contradiction by the choice of C. 7 5 An Improved FPT Algorithm and A Smaller Kernel Next, we show that ACT can be solved in O⋆(2O(k log k)) time and admits a kernel with O(k) vertices. 5.1 A Linear Vertex Kernel We show that the linear kernelization described in [9] for Feedback Arc Set in Tourna- ments also leads to a linear kernelization for our problem. In order to describe the kernel, we need to state some terminology defined in [9]. Let T be a tournament on n vertices. First, we apply the following reduction rule. Reduction Rule 5.1. If a vertex v is not in any cycle, then delete v from T . This rule is clearly safe as our goal is to find k cycles and v cannot be in any of them. To describe our next rule, we need to state some terminology and a lemma known from [9]. For an ordering σ of V(T ), let Tσ denote the tournament T whose vertices are ordered according to σ. Clearly, V(Tσ) = V(T ) and A(Tσ) = A(T ) since T and Tσ denote the same tournament. An arc (u, v) ∈ A(Tσ) is called a back arc if σ(u) > σ(v) and it is called a forward arc otherwise. An interval is a consecutive set of vertices in Tσ. Lemma 11 ( [9]). 1 Let Tσ be an ordered tournament on which Reduction Rule 5.1 is not applicable. Let B denote the set of back arcs in Tσ and E denote the set of arcs in Tσ with endpoints in different intervals. If V(Tσ) ≥ 2B + 1, then there exists a partition J of V(Tσ) into intervals with the following properties that can be computed in polynomial time. • There is at least one arc e = (u, v) ∈ A(T ) with e ∈ B ∩ E. • There are B ∩ E arc-disjoint cycles using only arcs in E. Our reduction rule that is based on this lemma is as follows. Reduction Rule 5.2. Let Tσ be an ordered tournament on which Reduction Rule 5.1 is not applicable. Let B denote the set of back arcs in Tσ and E denote the set of arcs in Tσ with endpoints in different intervals. Let J be a partition of V(Tσ) into intervals satisfying the properties specified in Lemma 11. Reverse all arcs in B ∩ E and decrease k by B ∩ E. Lemma 12. Reduction Rule 5.2 is safe. Proof. Let T ′ σ be the tournament obtained from Tσ by reversing all arcs in B∩E. Suppose T ′ σ has k − B ∩ E arc-disjoint cycles. Then, it is guaranteed that each such cycle is completely contained in an interval. This is due to the fact that T ′ σ has no back arc with endpoints in different intervals. Indeed, if a cycle in T ′ σ uses a forward (back) arc with endpoints in different intervals, then it also uses a back (forward) arc with endpoints in different intervals. It follows that for each arc (u, v) ∈ E, neither (u, v) nor (v, u) is used in these k − B ∩ E cycles. Hence, these k − B ∩ E cycles in T ′ σ are also cycles in Tσ. Then, we can add a set of B ∩ E cycles obtained from the second property of Lemma 11 to these k − B ∩ E cycles to get k cycles in Tσ. Conversely, consider a set of k cycles in Tσ. As argued earlier, we know that the number of cycles that have an arc that is in E is at most B ∩ E. The remaining cycles (at least k − B ∩ E of them) do not contain any arc that is in E, in particular, they do not contain any arc from B ∩ E. Therefore, these cycles are also cycles in T ′ σ. 1Lemma 11 is Lemma 3.9 of [9] that has been rephrased to avoid the use of several definitions and terminology introduced in [9]. 8 Theorem 13. ACT admits a kernel with O(k) vertices. Proof. Let (T, k) denote the instance obtained from the input instance by applying Re- duction Rule 5.1 exhaustively. From Lemma 4, we know that either T has k arc-disjoint triangles or has a feedback arc set of size at most 6(k − 1) that can be obtained in polyno- mial time. In the first case, we return a trivial yes-instance of constant size as the kernel. In the second case, let F be the feedback arc set of size at most 6(k − 1) of T . Let σ denote a topological ordering of the vertices of the directed acyclic graph T − F. As V(T − F) = V(T ), σ is an ordering of V(T ) such that Tσ has at most 6(k − 1) back arcs. If V(Tσ) ≥ 12k − 11, then from Lemma 11, there is a partition of V(Tσ) into intervals with the specified proper- ties. Therefore, Reduction Rule 5.2 is applicable (and the parameter drops by at least 1). When we obtain an instance where neither of the Reduction Rules 5.1 and 5.2 is applicable, it follows that the tournament in that instance has at most 12k vertices. 5.2 A Faster FPT Algorithm Here, we show that ACT can be solved in O⋆(2O(k log k)) time. The idea is to reduce the problem to the following Arc-Disjoint Paths problem in directed acyclic graphs. Arc-Disjoint Paths Parameter: k Input: A digraph D on n vertices and k ordered pairs (s1, t1), . . . , (sk, tk) of vertices of D. Question: Do there exist arc-disjoint paths P1, . . . , Pk in D such that Pi is a path from si to ti for each i ∈ [k]? On directed acyclic graphs, Arc-Disjoint Paths is known to be NP-complete [18], W[1]-hard [30] and solvable in nO(k) time [21]. Despite its fixed-parameter intractability, we will show that we can use the nO(k) algorithm to describe another (and faster) FPT algorithm for ACT. Theorem 14. ACT can be solved in O⋆(2O(k log k)) time. Proof. Consider an instance (T, k) of ACT. Using Theorem 13, we obtain a kernel I = (bT ,bk) such that bT has O(k) vertices. Further, bk ≤ k. By definition, (T, k) is a yes-instance if and only if (bT ,bk) is a yes-instance. Using Theorem 4, we know that bT either contains bk arc- disjoint triangles or has a feedback arc set of size at most 6(bk − 1) that can be obtained in polynomial time. If Theorem 4 returns a set of bk arc-disjoint triangles in bT , then we declare that (T, k) is a yes-instance. Otherwise, let bF be the feedback arc set of size at most 6(bk − 1) returned by Theorem 4. Let D denote the (acyclic) digraph obtained from bT by deleting bF. Observe that D has } of bk arc-disjoint cycles. For each C ∈ C, O(k) vertices. Suppose bT has a set C = {C1, . . . , Cbk we know that A(C) ∩bF 6= ∅ as bF is a feedback arc set of bT . We can guess that subset F of bF such that F = bF ∩ A(C). Then, for each cycle Ci ∈ C, we can guess the arcs Fi from F that it contains and also the order σi in which they appear. This information is captured as a partition F of F into bk sets, F1 to Fbk and the set {σ1, . . . , σbk } of permutations where σi is a permutation of Fi for each i ∈ [bk]. Any cycle Ci that has Fi ⊆ F contains a (v, x)-path between every pair (u, v), (x, y) of consecutive arcs of Fi with arcs from A(D). That is, there is a path from head(σ−1 i ((j + 1) mod Fi)) with arcs from D for each j ∈ [Fi]. The total number of such paths in these bk cycles is O(F) and the arcs of these paths are contained in D which is a (simple) directed acyclic graph. The number of choices for F is 2bF and the number of choices for a partition F = } of permutations is 2O(bF log bF). Once such a i (j)) and tail(σ−1 {F1, . . . , Fbk } of F and a set X = {σ1, . . . , σbk 9 choice is made, the problem of finding bk arc-disjoint cycles in bT reduces to the problem of } in bT such that for each 1 ≤ i ≤ bk and for each finding bk arc-disjoint cycles C = {C1, . . . , Cbk 1 ≤ j ≤ Fi, Ci has a path Pij between head(σ−1 i ((j + 1) mod Fi)) with arcs from D = bT − bF. This problem is essentially finding r = O(bF) arc-disjoint paths in D and can be solved in V(D)O(r) time using the algorithm in [21]. Therefore, the overall running time of the algorithm is O⋆(2O(k log k)) as V(D) = O(k) and r = O(k). i (j)) and tail(σ−1 6 Concluding Remarks We initiated the parameterized complexity study of the Arc-Disjoint Cycle Packing problem on tournaments. We showed that it is FPT when parameterized by the solution size and admits a linear vertex kernel. However, the classical complexity status of the problem is still open, i.e, we do not know if it is NP-hard or not. Resolving the same is a natural future research direction. We conjecture that it is indeed NP-hard. Note that the classical complexity status of the dual problem (Feedback Arc Set in Tournaments) was a long-standing open problem until it was shown to be NP-hard [2, 12, 14]. References [1] F. N. Abu-Khzam. An Improved Kernelization Algorithm for r-Set Packing. Informa- tion Processing Letters, 110(16):621–624, 2010. [2] N. Alon. Ranking Tournaments. SIAM Journal of Discrete Mathematics, 20(1):137– 142, 2006. [3] N. Alon, D. Lokshtanov, and S. Saurabh. Fast FAST. In 36th International Colloquium on Automata, Languages, and Programming (ICALP) Proceedings, Part I, pages 49–58, 2009. [4] N. Alon, R. Yuster, and U. Zwick. Color-Coding. Journal of the ACM, 42(4):844–856, 1995. [5] J. Bang-Jensen and G. Gutin. Paths, Trees and Cycles in Tournaments. Congressus Numerantium, 115:131–170, 1996. [6] J. Bang-Jensen and G. Gutin. Digraphs: Theory, Algorithms and Applications. Springer-Verlag London, 2009. [7] F. Barbero, C. Paul, and M. Pilipczuk. Strong Immersion is a Well-quasi-ordering for Semi-complete Digraphs. CoRR, abs/1707.03563, 2017. [8] S. Bessy, M. Bougeret, and J. Thiebaut. Triangle Packing in (sparse) Tournaments: Approximation and Kernelization. In Proceedings of the 25th Annual European Sym- posium on Algorithms (ESA), pages 1–23, 2017. [9] S. Bessy, F. V. Fomin, S. Gaspers, C. Paul, A. Perez, S. Saurabh, and S. Thomass´e. Kernels for Feedback Arc Set in Tournaments. Journal of Computer and System Sci- ences, 77(6):1071–1078, 2011. [10] H. L. Bodlaender. On Disjoint Cycles. International Journal of Foundations of Com- puter Science, 5(1):59–68, 1994. 10 [11] H. L. Bodlaender, S. Thomass´e, and A. Yeo. Kernel Bounds for Disjoint Cycles and Disjoint Paths. Theoretical Computer Science, 412(35):4570–4578, 2011. [12] P. Charbit, S. Thomass´e, and A. Yeo. The Minimum Feedback Arc Set Problem is NP-Hard for Tournaments. Combinatorics, Probability and Computing, 16(1):1–4, 2007. [13] M. Chudnovsky and P. Seymour. A Well-quasi-order for Tournaments. Journal of Combinatorial Theory, Series B, 101(1):47–53, 2011. [14] V. Conitzer. Computing Slater Rankings Using Similarities Among Candidates. In 21st National Conference on Artificial Intelligence - Volume 1, pages 613–619, 2006. [15] M. Cygan, F. V. Fomin, L. Kowalik, D. Lokshtanov, D. Marx, M. Pilipczuk, M. Pilipczuk, and S. Saurabh. Parameterized Algorithms. Springer, 2015. [16] R. G. Downey and M. R. Fellows. Fundamentals of Parameterized Complexity. Springer-Verlag London, 2013. [17] P. Erdos and L. P´osa. On Independent Circuits Contained in a Graph. Canadian Journal of Mathematics, 17:347–352, 1965. [18] S. Even, A. Itai, and A. Shamir. On the Complexity of Timetable and Multicommodity Flow Problems. SIAM Journal on Computing, 5(4):691–703, 1976. [19] J. Flum and M. Grohe. Parameterized Complexity Theory. Springer, 2006. [20] F. V. Fomin, D. Lokshtanov, V. Raman, and S. Saurabh. Fast Local Search Algorithm In Proceedings of the 24th AAAI for Weighted Feedback Arc Set in Tournaments. Conference on Artificial Intelligence, pages 65–70, 2010. [21] S. Fortune, J. Hopcroft, and J. Wyllie. The Directed Subgraph Homeomorphism Problem. Theoretical Computer Science, 10(2):111–121, 1980. [22] M. Karpinski and W. Schudy. Faster Algorithms for Feedback Arc Set Tournament, Kemeny Rank Aggregation and Betweenness Tournament. In 21st International Sym- posium on Algorithms and Computation (ISAAC), pages 3–14. Springer Berlin Heidel- berg, 2010. [23] M. Krivelevich, Z. Nutov, M. R. Salavatipour, J. V. Yuster, and R. Yuster. Approxima- tion Algorithms and Hardness Results for Cycle Packing Problems. ACM Transactions on Algorithms, 3(4), 2007. [24] T. Le, D. Lokshtanov, S. Saurabh, S. Thomass´e, and M. Zehavi. Subquadratic Kernels for Implicit 3-Hitting Set and 3-Set Packing Problems. In Proceedings of the 29th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 331–342, 2018. [25] D. Lokshtanov, A. Mouawad, S. Saurabh, and M. Zehavi. Packing Cycles Faster In 44th International Colloquium on Automata, Languages, and Than Erdos-P´osa. Programming (ICALP), pages 71:1–71:15, 2017. [26] J.W. Moon. Topics on Tournaments. Holt, Rinehart and Winston, New York, 1968. [27] M. Naor, L. J. Schulman, and A. Srinivasan. Splitters and Near-optimal Derandom- ization. In Proceedings of IEEE 36th Annual Foundations of Computer Science, pages 182–191, 1995. 11 [28] V. Raman and S. Saurabh. Parameterized Algorithms for Feedback Set problems and their Duals in Tournaments. Theoretical Computer Science, 351(3):446–458, 2006. [29] N. Robertson and P.D. Seymour. Graph Minors. XX. Wagner's Conjecture. Journal of Combinatorial Theory, Series B, 92(2):325–357, 2004. [30] A. Slivkins. Parameterized Tractability of Edge-Disjoint Paths on Directed Acyclic Graphs. SIAM Journal on Discrete Mathematics, 24(1):146–157, 2010. [31] E. Speckenmeyer. On Feedback Problems in Digraphs. In 15th International Workshop on Graph-Theoretic Concepts in Computer Science, pages 218–231. Springer Berlin Heidelberg, 1990. 12
1902.01829
1
1902
2019-02-05T17:59:51
Hierarchical Matrix Operations on GPUs: Matrix-Vector Multiplication and Compression
[ "cs.DS", "cs.MS" ]
Hierarchical matrices are space and time efficient representations of dense matrices that exploit the low rank structure of matrix blocks at different levels of granularity. The hierarchically low rank block partitioning produces representations that can be stored and operated on in near-linear complexity instead of the usual polynomial complexity of dense matrices. In this paper, we present high performance implementations of matrix vector multiplication and compression operations for the $\mathcal{H}^2$ variant of hierarchical matrices on GPUs. This variant exploits, in addition to the hierarchical block partitioning, hierarchical bases for the block representations and results in a scheme that requires only $O(n)$ storage and $O(n)$ complexity for the mat-vec and compression kernels. These two operations are at the core of algebraic operations for hierarchical matrices, the mat-vec being a ubiquitous operation in numerical algorithms while compression/recompression represents a key building block for other algebraic operations, which require periodic recompression during execution. The difficulties in developing efficient GPU algorithms come primarily from the irregular tree data structures that underlie the hierarchical representations, and the key to performance is to recast the computations on flattened trees in ways that allow batched linear algebra operations to be performed. This requires marshaling the irregularly laid out data in a way that allows them to be used by the batched routines. Marshaling operations only involve pointer arithmetic with no data movement and as a result have minimal overhead. Our numerical results on covariance matrices from 2D and 3D problems from spatial statistics show the high efficiency our routines achieve---over 550GB/s for the bandwidth-limited mat-vec and over 850GFLOPS/s in sustained performance for the compression on the P100 Pascal GPU.
cs.DS
cs
HIERARCHICAL MATRIX OPERATIONS ON GPUS: MATRIX-VECTOR MULTIPLICATION AND COMPRESSION WAJIH HALIM BOUKARAM1, GEORGE TURKIYYAH2, AND DAVID E. KEYES1 Abstract. Hierarchical matrices are space and time efficient representations of dense matrices that exploit the low rank structure of matrix blocks at dif- ferent levels of granularity. The hierarchically low rank block partitioning produces representations that can be stored and operated on in near-linear complexity instead of the usual polynomial complexity of dense matrices. In this paper, we present high performance implementations of matrix vec- tor multiplication and compression operations for the H2 variant of hierarchical matrices on GPUs. The H2 variant exploits, in addition to the hierarchical block partitioning, hierarchical bases for the block representations and results in a scheme that requires only O(n) storage and O(n) complexity for the mat-vec and compression kernels. These two operations are at the core of algebraic operations for hierarchical matrices, the mat-vec being a ubiquitous operation in numerical algorithms while compression/recompression represents a key building block for other algebraic operations, which require periodic re- compression during execution. The difficulties in developing efficient GPU algorithms come primarily from the irregular tree data structures that underlie the hierarchical representations, and the key to performance is to recast the computations on flattened trees in ways that allow batched linear algebra operations to be performed. This requires marshaling the irregularly laid out data in a way that allows them to be used by the batched routines. Marshaling operations only involve pointer arithmetic with no data movement and as a result have minimal overhead. Our numerical results on covariance matrices from 2D and 3D problems from spatial statistics show the high efficiency our routines achieve -- over 550 GB/s for the bandwidth-limited matrix-vector operation and over 850 GFLOPS/s in sustained performance for the compression operation on the P100 Pascal GPU. 1. Introduction Large dense matrices are ubiquitous in scientific computing. The discretization of integral operators associated with elliptic PDEs results in systems that are dense and on the order of the mesh size. Schur complement methods exploiting dimension reduction in PDE discretizations give rise to large dense systems. Kernel-based ma- chine learning algorithms generate large dense matrices describing pairwise relations between data points. Numerical optimization problems arising in inverse problems 1Extreme Computing Research Center (ECRC), King Abdullah University of Science and Technology (KAUST), Thuwal 23955, Saudi Arabia. 2Department of Computer Science, American University of Beirut (AUB), Beirut, Lebanon. E-mail addresses: [email protected], [email protected], [email protected]. 1 and data assimilation are generating ever-more exigent demands for manipulating large dense Hessians. Spatial statistics generates dense covariance matrices from ever larger data sets. The sizes of these matrices as they arise in practical applications make their direct storage prohibitive and would require algorithms of polynomial complexity for performing matrix-vector multiplication, matrix-matrix multiplication, factor- ization, and related linear algebra operations. Fortunately, many of these matri- ces described above have an underlying data sparse structure, consisting of blocks many of which can be well-approximated by low rank factorizations. Even though the blocks are of varying sizes and locations in the matrix, tree-based data struc- tures can be used to take advantage of this inherent data sparsity and organize the block approximations hierarchically, in effect compressing the dense matrix in an accuracy-controlled manner. The resulting representations, termed hierarchical matrices, provide an efficient and practical way of storing the dense matrices of very large dimension that appear in a broad range of settings. Hierarchical matrices can avoid superlinear growth in memory requirements and store n × n dense matrices in a scalable manner. For the H2 hierarchical represen- tations considered in this paper, they require only O(kn) units of storage where k is a representative rank for the low rank blocks. This asymptotically optimal storage requirement of hierarchical matrices is a critical advantage, particularly in GPU en- vironments characterized by relatively small global memories. For many standard applications, the compressed hierarchical form produces a few orders-of-magnitude reduction in required memory compared to the equivalent dense representation and makes it possible to fit the matrix in the limited global memory of current genera- tion GPUs, overcoming the disadvantage of the slow transfer of data between GPU and main memory. Efficient CPU hosted algorithms and software for hierarchical matrices are avail- able [1] and have been used in a variety of applications. More recently a task-based parallel implementation was demonstrated on the Intel Phi [2]. In contrast, there have been only limited efforts in the development of algorithms appropriate for GPU environments. For example, a recent work accelerated some of the readily vectorizable portions of the computation, such as setting up an initial stiffness ma- trix [3]. Another work used parallel work queues for H-matrix vector multiplication [4]. However, methods addressing the core H2-matrix operations on GPUs are not yet available. The lack of high-performance GPU algorithms is likely due to the fact that the naturally recursive data structures and formulations of the hierarchical matrix algorithms do not readily map to the throughput-oriented architecture of GPUs. Alternative representations and algorithmic formulations are needed to exploit the memory hierarchy of GPUs, expose fine-grained parallelism, orchestrate data move- ment to hide latencies and reduce global memory transactions, and increase occu- pancy to enhance parallelism, in order to obtain performance. Because hierarchical matrices occupy conceptually a middle ground between dense and sparse matrices, they can inherit some of the powerful GPU advantages of working with regular memory access patterns and can also leverage ideas from algorithms for sparse linear algebra computations on GPUs [5, 6, 7, 8] for working efficiently with the irregular patterns. This work seeks to develop GPU-resident data structures and associated data parallel algorithms for operating on hierarchical matrices. Specifically, we describe two algorithms including matrix-vector multiplication (HMV) and matrix com- pression that operate on flattened representations of the hierarchical matrix. Both algorithms are work optimal, O(n), and demonstrate high absolute performance on matrices of size up to 1M × 1M stored entirely on the GPU. The memory- bound HMV achieves more than 550 GB/s, surpassing the STREAM benchmark [9], and the compute-bound hierarchical matrix compression achieves more than 850 GFLOPS/s on the Pascal P100 GPU. These two operations are foundational routines for almost all other algebraic operations on hierarchical matrices, including matrix multiplication, inversion, factorization and others. We plan to use them as the building blocks for a complete GPU H2-library. We also hope that by making available high performance implementations of these basic hierarchical matrix rou- tines, we will encourage broader experimentation with hierarchical matrices in var- ious applications. We employ the word "experimentation" advisedly, inasmuch as the numerical analysis of rank growth and error propagation in chains of hierarchi- cal operations is not yet completely mature. It may be that the high compressibility will prove more practically tolerable in some applications than others. The rest of this paper is organized as follows. In Section 2, we describe the flattened data structures used to represent the row and column basis trees as well as the matrix tree that stores the matrix block data expressed in terms of these row and column bases. Section 3 describes a GPU matrix vector multiplication (HMV) algorithm and shows its performance on sample covariance matrices arising from 2D and 3D spatial statistics. Section 4 describes the hierarchical compression operation expressed in terms of batched QR and SVD operations, and analyzes the performance of its various phases on the same covariance matrices above. Discussion and conclusions are presented in Section 5. 2. Hierarchical matrices 2.1. Flavors of hierarchical matrices. A great deal of work has been done in the development of representations that exploit the low rank structure of matrix blocks in a hierarchical fashion. We do not attempt to review this literature here except for mentioning a few representative works in this section. We refer the reader to [10, 11] for an introduction and survey. Hackbusch [12, 12] pioneered the concepts of hierarchical matrices in the form of H and H2 matrices as a way to generalize fast multipole methods, and devel- oped a substantial mathematical theory for their ability to approximate integral operators and boundary value problems of elliptic PDEs. These ideas have been developed considerably over the years, for the construction and use of hierarchical matrices in solving discretized integral equations and preconditioning finite element discretizations of PDEs [13, 14, 15, 16, 17]. Hierarchically semi-separable (HSS) and hierarchically block-separable (HBS) are related and well-studied rank-structured representations that also use low rank blocks of a dense matrix in a hierarchical fashion. Matrices are semi-separable if their upper and lower triangular parts are, each, part of a low rank matrix. HSS matrices extend this idea and refer to matrices whose off-diagonal blocks are all of low rank and expressed in a nested basis. Their block structure is equivalent to what is also known as a weak admissibility criterion [18]. HSS matrices have been shown to be useful representations for integral equations in the plane and for sparse systems of equations that can be reduced to matrices of this form, for example by using nested dissection on 2D grids. Fast factorization algorithms for HSS matrices have been developed in [19]. HBS matrices have a similar structure but emphasize the telescoping nature of the matrix factorization [20] to use in the construction of direct solvers for integral equations [21]. Hierarchically off-diagonal low rank (HODLR) matrices which simplify the HSS representation by using non-nested and separate bases for various matrix blocks have been used for fast factorizations in [22]. 2.2. Structure of a general hierarchal matrix with nested bases. In this paper, we use the H2 representation as it allows a general block structuring of the matrix, has asymptotically optimal memory complexity, and in practice results in a representation with a small memory footprint in applications. The represen- tation achieves the O(n) memory complexity by exploiting two different types of hierarchies in the underlying matrix. One type of hierarchy is related to the granularity of matrix blocks where larger blocks that admit low rank approximations sit at higher levels in a tree represen- tation of the matrix, whereas the smaller low rank blocks sit at the lower levels. Figure 1 illustrates a block partitioning of a sample matrix. The matrix has three different block sizes that admit a low rank representation and are shown in blue. The matrix also has some blocks that do not admit such a representation and are stored as dense matrices and are shown in red. We denote the low rank decom- position of a given block by U SV T , where S is a k × k matrix with k generically denoting the rank of the block, and refer to U and V as the column and row bases in which the S block data is expressed. The S matrices are termed coupling matrices. The middle diagram of Figure 2 shows the levels of the matrix separated out. The bottom level contains the S data of only the smallest blocks of the matrix, the next level up contains the S data corresponding to the mid-sized blocks, and the level above it contains the S data for the largest blocks of the partitioning. The top two levels of the tree illustrated here are empty because there are no blocks of the appropriate size that admit a low rank representation. This hierarchy of block partitioning is common to all hierarchical matrix formats, although the H and H2 representations offer the most flexibility and generality, as they do not place restrictions on the admissible partitionings. Low rank blocks of any size, as well as dense blocks, can be located anywhere in the matrix. The second hierarchy, specific to the H2 format, is related to the manner in which the low rank blocks are represented, using nested row and column bases, U and V . Nestedness means that bases for the higher levels (larger blocks) may be obtained through suitable transformations of the bases of the lower levels and therefore need not be explicitly stored. Figure 2 illustrates how the bottom level of the basis trees is explicitly stored and can be directly used. For example, the block (4, 9) of the matrix of Figure 1 is a low rank block of the smallest size, therefore expressed as U4S49V T 9 , with U4 and V9 explicitly stored at the leaves of the bases trees as shown. At the next level up, the bases do not have an explicit representation but each basis (denoted graphically by a circle) can be obtained, when needed, from its children through small transfer matrices. These nested bases allow significant reduction in storage and produce the algorithmically optimal memory complexity. Figure 1. A three-level hierarchical matrix with its dense m×m blocks shown in red and its low rank blocks shown in blue. Figure 2. The low rank part of the matrix in Fig. 1 "disassembled" into its constituent basis trees (U and V) and matrix tree (S) representations. Representation is done level by level for all trees. The representation of the low rank portion of a hierarchical matrix An×n consists therefore of the tree triplet U, S, V: • The U tree organizes the row indices of the matrix hierarchically. We use a binary tree in this work but other organizations are possible. A node in 1234567891011121314151612345678910111213141516V9VS4,9SU4U the tree at level l represents a row block at this level of the matrix and is used to store column basis vectors in which the data of the matrix blocks at level l are expressed. Thin basis matrices U of size m × k are stored explicitly at its leaves. Small interlevel transfer matrices E of size kc × kp (referring to the ranks of the child and parent nodes) are stored at the higher levels and used to compute with the level-appropriate bases, which are never explicitly stored. When referring to a basis node as U l i , we refer to the node i at level l in the basis tree which is either stored explicitly at the leaves, or implicitly via the transfer matrices higher level of the tree. The relationship between a node U l−1 i2 uses the transfer matrices El i+ and its children U l i1 and U l i1 and El i2 : (1) U l−1 i+ =(cid:20)U l i1 i2(cid:21) . i2(cid:21)(cid:20)El i1 El U l Similarly, the V tree, consisting of explicit thin basis matrices at the leaves and small inter-level transfer matrices F , organizes column indices hierar- chically and its nodes are used to represent the row basis vectors for the column blocks at various level of granularity. The structure of this tree need not be identical to that of U, although the examples described in this paper come from symmetric matrices where we use the same block row and column trees. • The S tree is an incomplete quadtree that stores the coupling matrices S for all the blocks of the matrix. Other N-ary trees would be needed if the basis trees were not binary. As we describe below, the tree is stored level by level, with each level being a block sparse matrix. The sparsity pattern of the block sparse matrix at level l is directly related to the low ranks blocks that exist at that level of granularity: a k × k coupling matrix exists in the entry (i, j) of level l if a block at that level of granularity exists in the hierarchical matrix partitioning. In that case, the corresponding matrix block is U l j are the column bases and row bases of block row i and column block j at level l, respectively. The non-zero block entries from all levels form the leaves of the quadtree, and collectively they cover all the low rank blocks of the matrix. The storage needed for S depends on the structure of the tree and the distribution of the leaves but assuming a bounded number of non-zero entries in the block rows/columns, a reasonable assumption in many applications, its memory requirements have optimal complexity, O(kn), where k is a representative rank. , where U l i and V l ijV l j i Sl T Besides the low rank blocks, a set of dense m × m matrices that are not com- pressed need to be also stored. The complement of the low rank leaves of the quadtree represents blocks of the original matrix that are not economically ex- pressible as low rank factorizations and are more effectively stored in their explicit dense format. These dense leaves appear only at the finest level of the quadtree and in practical terms represent blocks of a fixed small size that is tuned to the ex- ecution hardware. We have used m = 64 for the examples in this paper. We store these dense blocks as a separate block sparse matrix and allow them to appear anywhere in the matrix. Symbol n m kl U , V U , V E, F S i, j (or i1, i2, etc.) i+ x(i) x, y U, E, etc. Description matrix size size of dense blocks typical rank of blocks in matrix tree at level l block row and column basis trees, with explicit bases stored at leaves only bases at the leaf level of U and V transfer matrices for the U and V bases, respectively matrix quadtree of coupling matrix blocks indices of block rows and block columns respectively index of the parent block of block i sub-vector of a vector x corresponding to the block i vectors defined at every level in the basis trees batched U , E, etc. arrays, marshaled for use by batched linear algebra kernels Table 1. Notation used. Notation. Table 1 summarizes the symbols used in the description of the tree algorithms on the hierarchal matrix. 3. Strategies for Efficient GPU processing of H-matrix Trees GPU routines are executed as kernels and can be called from the host CPU by specifying a launch configuration, organizing the GPU threads into thread blocks and thread blocks into grids. Launching a kernel causes a short stall (as much as 10 microseconds) as the kernel is prepared for execution. Let us call this stall the kernel launch overhead. For kernels that do a lot of processing, this stall is quite insignificant and does not impact performance; however, when the kernel execution is comparable to the overhead it presents a problem. All of the individual operations involved in H-matrices are on very small matrix blocks. Execution of these operations using a kernel call per block will be limited by the kernel overhead. To minimize the impact of the overhead, operations are best executed in large batches [23]. Efficiently marshaling the operations into these batches is also key to a high performance implementation. To that end, we flatten the tree by levels and store the level data in contiguous chunks of memory where each matrix block is stored consecutively in column major order. Operation marshaling then involves specialized kernels that process each level in parallel to produce the necessary data for the linear algebra batch kernels. The benefits of this decomposition are two- fold: the marshaling kernels can access the level data in coalesced global memory reads and the batch kernels can execute without any knowledge of the tree data structure. Since every kernel call uses a single launch configuration, the operations handled by each batch routine must have the same size; in the H-matrix setting, this translates to a fixed rank per level of the trees. Variable size batch kernels will be needed to overcome this limitation, but this will be the focus of future work. 3.1. Flattened Tree Structure. The flattened structure of the tree is represented by three arrays head, next, and parent of node indices, with each node index referring to a block of rows/columns. The head array contains the node index of the first child of a node while each entry in the next array gives us the index of the next sibling of a node. The parent array contains the parent node index of each node allowing us to traverse the tree in any direction. An example of this storage scheme for the structure of the basis tree is depicted in Figure 3. The node indices 1 2 3 4 5 6 7 8 1 1 - 2 - 2 1 4 3 9 2 4 1 6 - Level Pointers parent head next 10 11 12 13 14 15 3 4 5 6 7 8 8 2 8 5 16 2 3 3 10 12 14 - 7 - 4 - 9 4 - - 5 - 11 5 - - 6 - 13 6 - - 7 - 15 7 - - Figure 3. Basis tree structure. Data associated with the basis tree uses the node numbers to locate the position of the node data in memory. Examples for the MVM operation include the x and y trees (in the nodes), the basis leaves (shown as rectangles), and the inter-level transfer matrices (in the nodes). stored in this flattened structure are used by the marshaling routines of the various hierarchical operations to efficiently generate data from each level that can then be passed on to the batch kernels. The data can come from trees that share the same structure as the basis trees, such as the(cid:98)x and(cid:98)y trees of the MVM described in Section 4.1 and the Z and T trees of the orthogonalization described in Section 5.2. 3.2. Marshaling Operations. Specialized marshaling kernels for each operation generate the data that batched linear algebra routines need to execute the operation. This includes the pointers to matrix blocks from a level as well as matrix block dimensions and we denote marshaled data by the subscript. This data can then fed into the appropriate batch routines for execution using a single kernel call per level. Since the levels of the tree have been flattened into arrays, it is straightforward to parallelize using simple parallel transformations, either by a simple kernel or using libraries such as Thrust [24]. These transformations are executed very quickly and constitue a negligible portion of the execution time within each operation. Examples of the marshaling routine for a few of these operations are described in each section, such as the upsweep marshaling of the matrix vector operation described in Algorithm 1 and the marshaling of the orthogonalization operation described in Algorithm 5, with a few omitted for the sake of brevity. For the operations presented in this paper, we rely on high performance batched linear algebra kernels for QR and singular value decompositions. We do not describe these kernels here, as their details may be found in [25]. We also use the high performance matrix-matrix multiplication batched routines from the CUBLAS [26] and MAGMA [27] libraries. 4. Hierarchical matrix-vector multiplication 4.1. Overview. In this section, we describe the different phases of the HMV al- gorithm and their efficient GPU implementations. Since the hierarchical matrix Figure 4. Overview of the HMV. Computation with the low rank blocks is split into three phases: upsweep, multiplication, and down- sweep. The upsweep computes a tree x from the input vector x by first projecting it to the basis leaves and then sweeping up the tree using the transfer matrices. x is then fed into the block sparse multiplication phase to produce the y tree. Finally, the downsweep computes the out- put vector y by first accumulating partial sums within each level of y using the transfer matrices. The leaf level of y then contains the full sums in terms of the basis leaves which are expanded to form the output vector y and added to the results of the dense matrix-vector product to produce the final result. may be viewed as the sum of a dense portion AD and a low rank portion ALR the products with AD and ALR are done separately (but concurrently when possible, as detailed below) and added as shown in Figure 4. The product of the dense blocks with the input vector is computed via a block sparse matrix vector multiplication routine. The product of the low rank blocks with the input is then computed in three additional phases: an upsweep phase, a multiplication phase, and a down- sweep phase as illustrated in Figure 4. For intuition, we may think of this algorithm as the hierarchical generalization of the way we multiply a regular dense low rank matrix, U SV T , by a vector x. In this case we would do it in three phases: first VTxF4Tx4F3Tx3F2Tx2F1Tx1bxxUpsweepSMultUy4E4y3E3y2E2y1E1y0ybyDownsweep+=ADxyDense apply the transpose of V to x, then multiply the small resulting product by S, and then apply U to obtain the final product. The hierarchical analogue first applies the transpose of the bases of all levels of V to x by sweeping up the tree to compute partial contribution to the output vector expressed in the row basis U l. Finally, the nodes of a vector tree (cid:98)x. The multiplication phase then computes a vector tree (cid:98)y where each node in (cid:98)yl is the product of a block row of coupling matrices in Sl with the corresponding nodes of (cid:98)xl. The nodes of (cid:98)yl represent the level's a downsweep phase expands the nodes of (cid:98)y, multiplying them by the bases from the corresponding levels of U to produce the final output vector y. It is also worth noting that these phases of the HMV computation are very closely related to the phases of the fast multipole method [28]. T (2) T j1 T j1 F l j2 j = V l j T(cid:105)(cid:34)V l j+ =(cid:104)F l (cid:98)xl−1 x(j) for all nodes j within a level l, with l in 0··· q. This process is trivial for the leaves since they are stored explicitly; however the inner nodes are expressed in terms of their children using the relationship defined in Eq. 1. For simplicity, let us consider j+ can be computed as: 4.2. Upsweep phase. The upsweep computes a tree (cid:98)x as the products of the transposed nodes of the column basis V with the input vector x; i.e. (cid:98)xl a parent node j+ with two children j1 and j2. The node(cid:98)xl−1 T(cid:35)(cid:20)x(j1) x(j2)(cid:21) = F l (cid:98)xl using the above equation. To avoid the prohibitive overhead of O(n) kernel launches required to execute this operation recursively on the GPU, we use the flattened We can compute every node in(cid:98)x by starting at the leaves and sweeping up the tree tree structure described in section 3 to compute (cid:98)x level by level. The leaves are processed simply using a single batch matrix vector operation. Considering a binary tree for the basis trees, an upsweep kernel marshals the data for the operations in a level to generate two batches (one for each child) which are then executed by the batch matrix vector operation. Like all marshaling operations used in the rest of this paper, this marshaling operation uses the flattened tree structure described in Section 3 to efficiently generate the necessary pointer data for the batched routines, the F, x and y pointer arrays in this operation, using a single kernel call. This leads us to Algorithm 1 for marshaling the upsweep operations and Algorithm 2 to j1 + F l j2 T (cid:98)xl V l j2 T j1 j2 . 4.3. Multiplication phase. The second phase of the computation builds a vector compute(cid:98)x. tree (cid:98)y, where each node i in a level l is the product of the block row i of level l of the coupling matrix tree with the corresponding nodes in(cid:98)x. This operation can be expressed as (3) i = (cid:88)j∈{bi} (cid:98)yl Sl j ij(cid:98)xl where bi is the set of column indexes of the matrix blocks in the block row i. We could follow the same marshaling approach as the upsweep, but given the potential nonuniform distribution of blocks in different rows as well as the obvious similarity to a block sparse matrix vector multiplication, we opt to generate block sparse row index data for the matrix tree. This data is efficiently generated once during the construction of the hierarchical matrix and stored per level of the matrix tree. Algorithm 1 GPU upsweep marshaling routine 1 procedure marshalUpsweep(F (l),(cid:98)x(l),(cid:98)x(l−1)) np = levelptr[l − 1] kp = levelrank[l − 1] nc = levelptr[l] kc = levelrank[l] in parallel for p = np → nc 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i = p − np c = head[p] ci = 0 while c (cid:54)= empty do F(ci)[i] = ptr(cid:0)F (l)(cid:1) + (c − nc) × kc × kp x(ci)[i] = ptr(cid:0)(cid:98)x(l)(cid:1) + (c − nc) × kc y(ci)[i] = ptr(cid:0)(cid:98)x(l−1)(cid:1) + i × kp ci = ci + 1 c = next[c] (cid:46) Batch index (cid:46) Extract level pointer data A = a c b d  i j k l e f g h m o n p  e f g h i j k l m n o p Values ColIdx RowPtr a 1 1 b 3 3 c 2 4 d 3 5 Figure 5. The BSR storage for a 6 × 6 matrix with 2 × 2 blocks. Figure 5 shows an example of the block sparse row index data for a simple matrix. This leads us to Algorithm 3 for the computation of (cid:98)y. Algorithm 2 GPU upsweep algorithm for forming(cid:98)x 1 procedure upsweep(V , F , x,(cid:98)x) q = heightof((cid:98)x) m , V T , (batch) x,(cid:98)xq(cid:1) gemvBatched(cid:0) n for l = q → 1 do N = n/m/2q−l+1 2 3 4 5 6 7 8 T , x, y] = marshalUpsweep(F lT [F for j = 1 → 2 do gemvBatched(N, F(j)T , x(j), y(j)) ,(cid:98)xl,(cid:98)xl−1) (cid:46) leaf level, log(n/m) (cid:46) up the V tree (cid:46) binary tree Algorithm 3 GPU Matrix Tree Multiplication for (cid:98)y procedure TreeMultiply(S,(cid:98)x, (cid:98)y) q = heightof((cid:98)y) (cid:98)yl = blockSparseMV(Sl,(cid:98)xl) in parallel for l = 1 → q 4.4. Downsweep phase. After the multiplication phase, each level of the vector i. (4) y(i) = y(i) + U l of the nodes of the block row basis U at that level. We can finalize the computation tree(cid:98)y now contains a partial contribution of the output vector y expressed in terms by expanding the nodes of (cid:98)yl at each level l as: i(cid:98)yl Since we don't have an explicit representation of the inner nodes of the basis tree, we use the nested basis property to express the partial sum of a level with its child level in terms of the basis nodes of the child level. Taking a parent node i+ at level l − 1 and its two children i1 and i2 at level l, we have the partial sum: (5) i+ +(cid:20)U l i+ (cid:21)+(cid:20)U l i2(cid:21) =(cid:20)U l i2(cid:21) =(cid:20)U l i1(cid:98)yl−1 i1(cid:98)yl i1(cid:98)yl i+ (cid:98)yl−1 i2(cid:98)yl−1 i2(cid:98)yl i2(cid:98)yl i(cid:98)yl−1 i =(cid:98)yl Sweeping down (cid:98)y and setting each node (cid:98)yl i+ , the level l at each step now also contains the partial sum of y for all levels above l expressed in the nodes of U l. The leaf level will then contain the complete sum which is finally expanded into y. We follow the same approach as in the upsweep, where each level is processed in parallel by first marshaling the operations and then executing using a batch matrix vector product. This leads us to Algorithm 4 for computing y. The downsweep marshaling algorithm is structurally very similar to the upsweep marshaling routine described in Algorithm 1 and is omitted for brevity. i2(cid:21)(cid:20)El i2(cid:21)(cid:20)El i1 yl−1 i2 yl−1 i + El U l−1 U l El U l El i1 i1 U l i+ i1 i1 U l i1 i2(cid:21) . i+ +(cid:98)yl i+ +(cid:98)yl Algorithm 4 GPU downsweep for computing y 2 3 4 5 6 for l = 1 → q do N = n/m/2q−l 1 procedure downsweep(U , E, (cid:98)y, y) q = heightof((cid:98)y) [E, x, y] = marshalDownsweep(El,(cid:98)yl−1,(cid:98)yl) gemvBatched(cid:0) n gemvBatched(N, E, x, y) m , U, (cid:98)yq, y(cid:1) 7 (cid:46) leaf level, log(n/m) (cid:46) down the U tree 4.5. Kernel streaming. The upper levels of the tree operations do not provide enough work to saturate the GPU and kernel overhead starts to impact performance for these levels. To overcome this, we can use streams to try to overlap some stages of the computation with the processing of the upper levels. Unfortunately, the scheduler will only launch a new kernel when the resources are available, which typically happens towards the end of the BSR multiplication kernel. It therefore makes most sense to overlap the dense multiplication portion of the computation with the low rank portion. Many GPUs support a feature called stream priorities that allow execution of a kernel on a low priority stream to be suspended in favor of a kernel on a higher priority stream. By setting the dense phase as the lowest priority and the tree operations as the highest priority, we can effectively hide the overhead and hardware underuse of the tree operations. The performance results below show the effect of this overlap which, as expected, is beneficial for relatively small sized problems. On larger problems, the work at the higher levels of the trees is a very tiny fraction of the overall computation and there is relatively little benefit derived from the overlap. The (cid:98)x and (cid:98)y trees are stored in temporary workspace, allowing the dense and low rank phases to overlap, requiring only a single stream synchronization between the dense phase and the final phase of the downsweep. 4.6. Performance results. To demonstrate the performance of the HMV oper- ation, we generated two families of hierarchical covariance matrices for a spatial Gaussian process with n = 214 ··· 220 observation points placed on randomly per- turbed 2D and 3D regular grids in [0, 1]2 and [0, 1]3 respectively. The covariance ma- trices were generated using an isotropic exponential kernel with correlation length 0.1 in 2D and 0.2 in 3D [29] and are representative of hierarchical matrices that arise in several applications [10]. The hierarchical matrices were generated ab initio in the following way. The n points are first partitioned into clusters using a KD-tree with a mean split, generat- ing the index sets of the basis tree nodes. The basis and transfer matrices are then generated using Chebyshev interpolation [30]. A dual traversal [31, 32] of the basis tree generates the quadtree described in Section 2.2, where the coupling matrices at the leaves are generated by evaluating the kernel at the interpolation points. The leaf size m was set to 64, tuned to the P100 GPU, and a uniform rank of 64 was used for all levels of the matrix, corresponding to the use of 8× 8 grids and 4× 4× 4 Chebyshev grids in 2D and 3D respectively. The choice of the leaf size only influ- ences performance and has no effect on the accuracy of the representation, since overall accuracy is limited by the low rank blocks. The resulting approximation error was less than 10−7 in 2D and less than 10−3 in 3D for all problem sizes, as measured by computing (cid:107)Ax−AHx(cid:107)/(cid:107)Ax(cid:107) where A is the exact (dense) covariance, AH is its hierarchical representation, and x is a randomly generated vector whose entries are sampled from a uniform [0, 1] distribution. For the large problems, it is not possible to store the dense A nor is it practical to perform the O(n2) Ax prod- uct, and as a result we sampled 10% of the rows and used the analytical expression of the matrix entries. While a rank of 64 may seem high for a leaf size of 64, it is often the case that the ranks at the leaves increase temporarily due to low rank updates that may be applied to the blocks of the matrix during hierarchical matrix operations. This rank will be reduced during compression and the effect on matrix vector multiplication performance is shown in Section 5.5. For illustration, Figure 6 shows the structure of the 2D and 3D covariance ma- trices for the n = 214 problem size. The small dense blocks of size 64×64 are shown in red in the zoomed details. As expected, the 3D matrix has more dense blocks and its low rank trees are bushier than those of the 2D matrix which puts more pressure on memory (or alternatively permit lower accuracy for the same memory footprint as a 2D problem of the same size). The performance results shown here are for these matrices in their original analytically-derived hierarchical form. The algebraic compression discussed in section 5 will reduce the memory footprint of the low rank portions substantially and further reduce the HMV time, as will be shown in section 5.5. Figure 6. Structure of the 2D (top) and 3D (bottom) sample covariance matrices used in the examples for n = 214, with a zoom on portions of them. Notice that the 3D problem does not have as many large blocks that admit a low rank approximation as the 2D problem and therefore results in a representation that has higher memory demand for the same accuracy. Figure 7. Breakdown of the HMV phases in percentages of total oper- ation time in single (left) and double (right) precision on a P100 GPU showing that, for smaller problem sizes where the basis tree has very few levels, the upsweep and downsweep do not fully utilize the hardware. Figure 7 shows the profile of the execution of the HMV of the 3D problems in single and double precision. The upsweep and downsweep phases show relatively poor performance for the smaller problems sizes, since the small batches generated 214215216217218219220020406080100Problemsize%totaltimeDenseMultUpsweepDownsweep214215216217218219020406080100Problemsize%totaltime (a) Time for the HMV in single and dou- ble precision for a 2D problem. (b) Time for the HMV in single and dou- ble precision for a 3D problem. Figure 8. Runtime of HMV on a single P100 GPU, showing asymptot- ically linear growth with problem size. Notice that the streamed version that allows overlapping between the dense and the low rank phases of HMV provides performance boost on small problems. On the larger problems, where the available bandwidth is saturated with the low rank data, the improvement due to overlapping is diminished. (a) Achieved bandwidth for the HMV in single and double precision for a 2D problem. (b) Achieved bandwidth for the HMV in single and double precision for a 3D problem. Figure 9. Achieved bandwidth of HMV on a single P100 GPU with the streamed kernel achieving up to 78% of the theoretical bandwidth peak of the GPU. for the upper levels of the trees do not provide enough work to saturate the GPU, leading to lower performance during those phases. The impact of the smaller higher 2142152162172182192202−112−92−72−52−32−1ProblemSizeTime(s)HMVSPHMVDPStreamedHMVSPStreamedHMVDPHMVSP(CUBLAS)HMVDP(CUBLAS)LinearGrowth2142152162172182192202−112−92−72−52−32−1ProblemSizeTime(s)HMVSPHMVDPStreamedHMVSPStreamedHMVDPHMVSP(CUBLAS)HMVDP(CUBLAS)LinearGrowth2142152162172182192200200400600800ProblemSizeBandwidth(GB/s)HMVSPHMVDPStreamedHMVSPStreamedHMVDPHMVSP(CUBLAS)HMVDP(CUBLAS)TheoreticalPeak2142152162172182192200200400600800ProblemSizeBandwidth(GB/s)HMVSPHMVDPStreamedHMVSPStreamedHMVDPHMVSP(CUBLAS)HMVDP(CUBLAS)TheoreticalPeak levels is alleviated as the problem size increases, where the larger lower levels that can saturate the GPU dominate the workload. Kernel streaming as discussed in Section 4.5 allows us to increase hardware usage during those phases. Figures 8a and 8b show the execution time of the HMV in double and single precision for the 2D and 3D problems respectively. The streamed kernel shows up to 27% performance improvement for the smaller problem sizes. We can also see the expected linear growth of the algorithm for all versions. We also compare the effect of using different batched kernels. All versions using the batched GEMV and block spMV kernels from [33, 34] show significant improvements over the same algorithms implemented with the vendor provided routines in CUBLAS [26] and CUSPARSE [35]. Since the matrix vector multiplication is a memory bound routine, we gauge the performance of the kernels by bandwidth. Since this operation is bandwidth limited, we compute performance as the total number of bytes transferred over total execution time. This includes all dense and coupling matrices in the matrix tree as well as the leaves and transfer matrices of the basis trees. Figures 9a and 9b show the achieved bandwidth of the various HMV kernels, with the streamed version achieving up to 78% of the theoretical peak bandwidth of the P100 GPU. The improvement in achieved bandwidth over the non- streamed version that does not allow the overlap of the different portions of the computation is substantial for the small problem sizes. We note that performance was quite stable and reproducible between runs. 5. Hierarchical matrix compression j can be compressed into the form U(cid:48)i S(cid:48)ijV (cid:48)T 5.1. Overview. Compression is a core operation in hierarchical matrix algebra. For example, in the course of implementing BLAS3 operations, matrix blocks get added, generally producing increased apparent ranks. The matrix needs to be compressed in order to maintain the optimal complexity. The goal of compression is therefore to construct new nested row and columns bases in which the matrix blocks can be expressed more compactly, i.e., where blocks originally represented as UiSijV T j where the dimensions of S(cid:48) are smaller than the dimensions of S. The primary task here is to construct the common basis U(cid:48)i in which all blocks of a given block row can be expressed, without incurring the quadratic cost that would be needed if a straight SVD of the whole row block is performed. The same goes for column blocks and V (cid:48)j when the two bases U and V are different. Finally, once the compact and more efficient nested block row/column basis has been generated, the new S(cid:48)ij for every matrix block is computed by a transformation of the form TU iSijT T V j, leading to a smaller memory footprint and reduced hierarchical operation runtimes. The algorithms presented are adapted from [36] to fit the architecture of the GPU. In order to introduce the somewhat involved algorithm, let's first consider how the new basis for a block row Aq i at the finest level q would be generated. A here denotes only the low rank portions of the hierarchical matrix, since the dense blocks are not compressed. Aq i consists of b low rank blocks expressed at level q as UiSijV T j with j = j1 ··· jb, and additional pieces representing the restriction of blocks from higher levels to their "t" rows as shown in Figure 10. (6) Aq i = U q i (cid:104)portions of ancestors Sq ij1V qT j1 ··· Sq ijb V qT jb (cid:105) = U q i BqT i Figure 10. Matrix block row Aq chical matrix for the sixth row of the leaf level. Aq level q and sub-blocks coming from higher level block rows. i of the low rank portion of the hierar- i includes 5 blocks at The optimal basis can be generated by computing the SVD of U q , truncating it to the desired approximation, and using the truncated left singular vectors as the new basis U(cid:48)q i . This would however require the expensive SVD of the O(n)-sized Bq i and then perform the SVD with the small R factor. i . In order to avoid it, we would first compute the QR decomposition of Bq i BqT i (7) Aq i = U q i Bq i T = U q i (Qq i Rq i )T = U q i Rq i T T Qq i new basis (cid:124) (cid:123)(cid:122) (cid:125) The optimal basis U(cid:48)q is then simply the truncated left singular vectors of what i T , and this finishes the process might be thought of as a new weighted basis U q for level q. When we move to higher levels in the tree, we need to insure that the U(cid:48) bases remain nested. This requires additional singular value decompositions, but involving only small transfer matrices, as we go up U in an upsweep traversal described in Section 5.4. i can be done efficiently by exploiting the nestedness of the bases. Let us assume that the QR decomposition of Bq−1 i of the QR decomposition of Bq The task of computing Rq i Rq i+ Rq−1 i+ . Then, i Aq i+ , the parent block i+ at level q − 1, is available as Qq−1 jb (cid:105) ijb V qT i Sq jb (cid:105) = U q ··· Sq i =(cid:104) i-portion of i (cid:104)Eq i+ Rq−1 i conveniently expressible as: ij1 V qT j1 i+ )T Sq ··· U q ij1 V qT j1 U q−1 i+ Bq−1 i (Qq−1 ijb V qT T U q = U q i Sq i+ (8) with Bq i BqT i Assuming the V q bases are orthogonal, the block diagonal matrix in Eq. 9 is or- thogonal and the QR of Bq i simply reduces to the QR of the small stack at the end of Eq. 9 which involves only b + 1 blocks, each being a small k× k coupling/transfer matrix, and therefore can be done quite efficiently. Since this QR uses the Rq−1 matrix from level q− 1, the overall computation starts from the root and goes down (9) Bq i = = diag(Qq−1 i+ , V q j1,··· , V q jb ) i+ EqT i i+ Rq−1 Qq−1 j1 SqT V l ij1 ... jb SqT V q ijb   i i+ EqT Rq−1 SqT ij1 ... SqT ijb  .  Aqi the tree computing all the Rl i matrices for all levels in a downsweep traversal. As with previous operations, all blocks at a given level can obviously be processed in parallel. We also observe here that the Q factors are not needed and a specialized QR decomposition avoiding their expensive storage and computation improves the performance of the algorithm. j V l Orthogonalizing the V basis tree can be done in a pre-processing phase. A basis is orthogonal if V lT j is the identity matrix for all levels l. Orthogonalizing a basis involves performing QR on the finest level basis and then going up the tree to compute new transfer matrices that allow higher level nodes to satisfy the orthogonality condition. This is also done via additional QR operations involving the transfer matrices. In summary, the overall compression procedure consists of the following three computational steps: • An upsweep of the basis trees to orthogonalize them. This step uses a sequence of batched QR calls, one per level, to produce an orthogonal basis. This is described in Section 5.2. • A downsweep of the basis trees, using the coupling blocks Sij, to construct the Ri factors for the new bases. This step uses a sequence of batched QR kernel calls, one per level, on the stacks at the end of Eq. 9. This is described in Section 5.3. • An upsweep of the basis tree to truncate the new bases to the desired tolerance. This step uses a sequence of batched SVD calls, again one per level, on the UiRi bases to produce the new optimal basis. The Sij blocks are then transformed into these bases via batched matrix multiplication operations. This is described in Section 5.4. j = I. This is equivalent to the conditions that V qT j V q 5.2. Basis orthogonalization. Orthogonalizing a nested basis tree V replaces it by a new nested basis where every node satisfies the orthogonality condition V lT j V l j = I at the finest c Fc = I for all levels, where c ranges over the two children of every node in the basis tree. Besides allowing the simplification in the R computation algorithm, orthogonalizing the basis of an H- matrix simplifies error computations and matrix projections. It is also structurally similar to the truncation algorithms described in Section 5.4. level q and that the transfer matrices satisfy (cid:80)c F T A by-product of orthogonalization is also a set of projection matrices that trans- form between the old basis and the new orthogonal one. These projection matrices are stored in a tree that shares the same structure as the basis tree, where pro- cessing each node of the basis tree produces a node in the projection tree TV . We assume here that V = U and do not make a distinction between the row and column bases and drop the subscript V from T . If we denote by Ql i the new orthogonal basis at level l, the original basis V l j can be recovered as Ql jT l j . We will use this transformation to express the coupling matrices in the new orthogonal basis. As in the upsweep of the HMV algorithm, we perform the orthogonalization operation one level at a time, starting at the leaves and sweeping up the tree. Processing the leaves simply requires QR factorization of each leaf node where the Q factor becomes the new orthogonal leaf and the R factor is output into the leaf level of T . The inner nodes are expressed in terms of their children using the nested basis property and must be orthogonalized in a way that preserves this property. Algorithm 5 GPU orthogonalization upsweep marshaling routine 1 procedure marshalQRupsweep(Z,(cid:98)T (l), F (l)) np = levelptr[l − 1] kp = levelrank[l − 1] nc = levelptr[l] kc = levelrank[l] in parallel for p = np → nc 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i = p − np c = head[p] ci = 0 while c (cid:54)= empty do Z[c − nc] = ptr(Z) + i × 2 × kc × kp + ci T[c − nc] = ptr(cid:16)(cid:98)T (l)(cid:17) + (c − nc) × kc × kc F[c − nc] = ptr(cid:0)F (l)(cid:1) + (c − nc) × kc × kp ci = ci + kc c = next[c] q = heightof(T ) Algorithm 6 Basis Orthogonalization 1 procedure QRupsweep(V , F , T ) 2 3 4 5 6 7 [V, T q] = qrBatched(cid:0) n for l = q → 1 do N = n/m/2q−l [Z, T, F] = marshalQRupsweep(Z, T l, F l) gemmBatched(N, Z, T, F) [Z, T l−1] = qrBatched(N/2, Z) F = marshalQRunstack(Z, F l) F l = copyBatched(F) m , V(cid:1) 8 9 10 (cid:46) Batch index (cid:46) Binary Tree (cid:46) Extract level pointer data (cid:46) leaf level, log(n/m) (cid:46) up the tree Given an inner node j+ at level l − 1 with children j1 and j2 at processed level l, we have V l−1 j+ =(cid:20)V l j1 j2(cid:21)(cid:20)Fj1 Fj2(cid:21) =(cid:20)Ql V l j1 j2(cid:21)(cid:20)T l j1Fj1 T l j2Fj2(cid:21) =(cid:20)Ql j1 Ql j2(cid:21) Z Ql Forming the 2kl × kl−1 matrix Z, computing its QR factorization and using the two kl × kl−1 blocks of the Q factor as the new transfer matrices, gives us the new orthogonal inner nodes that satisfies the nested basis property. The R factor is then output into level l − 1 of the projection tree T . Z is formed by first marshaling the operations based on the data in the projection tree and the basis tree transfer nodes and then operating on them using a batched matrix- matrix multiplication routine. Z is then factorized using a batch QR factorization routine and the sub-blocks are copied back as the new transfer matrices using a marshaled batch copy operation. This leads us to Algorithm 5 for marshaling the orthogonalization upsweep operations and Algorithm 6 for computing the projection tree T and the new orthogonal basis. The left side of Figure 11 depicts this operation for the binary basis tree. Algorithm 7 Projection of Coupling Matrices 1 procedure Projection(T , S) 2 3 in parallel for l = 1 → q T S = ws(Sl) [TU , S, T S, TV ] = marshalProjection(T l, Sl, T S) nb = sizeof(Sl) gemmBatched(nb, T S, TU , S) T ) gemmBatched(nb, Sl, T S, TV 4 5 6 7 (cid:46) Temporary workspace Finally, the projection phase transforms the coupling matrices of each matrix block Al ij at level l using the projection matrices stored in T l: Al ij = U l i Sl ijV l T j = Ql i Sl ijT l T i(cid:0)T l j (cid:1) Ql T j . The new coupling matrices are obtained by left and right multiplications with the computed projection matrices independently at all levels. The operations are first marshaled by level and then executed using batch matrix-matrix multiplication routines. This operation is described in Algorithm 7 and depicted in the right panel of Figure 11 for a single level of the matrix tree. 5.3. Basis generation. In this phase we construct a basis tree R for the block rows of the matrix tree. This tree will have the same structure as the row basis tree. Every node i at every level l will store the matrix Rl i which will postmultiply the corresponding U l i to produce the new basis that will be truncated. As described Figure 11. Left: Basis orthogonalization starting from the leaves and sweeping up the tree to overwrite the basis with an orthogonal one and generate the projection tree T (only a single level is depicted here). Right: Projection of the leaf level of coupling matrices into a new ba- sis using a projection tree T . The new basis could be more compact, resulting in lower rank for the level. QRgemmQRVTFZSlTlTlSlProject ¯Si = i Rl−1 i+ El T Sl T ij1 Sl T ij2 ... Sl T ijb   earlier, Rl node is Ui and from higher level blocks that also span the block row i. i depends on matrix data coming from bocks at level l whose row basis Denoting the parent node of i by i+, the relevant block row ¯Si that enters the computation of Rl i is depicted in Figure 12 and expressed as: where b is the number of blocks in the block row at level l. The first block Rl−1 i+ ElT represents data coming from the levels of blocks above l. The node Rl i can then be computed as the R factor of the QR factorization of ¯Si. The tree is computed starting at the root of the matrix tree followed by a sweep down to the leaves. Marshaling the block row from the matrix tree data and the parent level of R into a batch matrix-matrix multiplication and a batch transpose operation allows us to quickly form ¯Si for a level. This matrix is then fed into a batch QR factorization routine that does not form Q. The marshaling routine for this operation makes use of the generated BSR data of the level of the matrix tree and is described in Algorithm 8. Putting everything together leads us to Algorithm 9 to form the tree R. i 5.4. Basis truncation. Once the R matrix of each block row is computed, we can generate the new compressed basis tree, which allows the ranks of the blocks at the approximation. This is the heart of algebraic compression. every level l to decrease from kl to(cid:101)kl while maintaining a prescribed accuracy  in The truncation process is structurally similar to the upsweep of the orthogonal- ization in that processing the nodes produces projection matrices which are then Figure 12. Constructing Rl data, and transfer matrices. i from its parent level, the matrix tree row RESlRl−1i+ElTiSlTij1SlTij2...SlTijbtransposegemmQR Algorithm 8 GPU Basis Generation marshaling routine 1 procedure marshalBasisGen(Rl−1, El, Sl) 2 3 4 5 6 7 nr = levelrows[l] kp = levelrank[l − 1] kc = levelrank[l] in parallel for r = 1 → nr bs = rowPtr [r] be = rowPtr [r + 1] pr = parent [r] 8 9 10 11 12 13 14 RE[r] = ptr(cid:0) ¯S(cid:1) + r × ldS × kc R[r] = ptr(cid:0)Rl−1(cid:1) + pr × kp × kp E[r] = ptr(cid:0)El(cid:1) + r × kp × kp ¯S[i] = ptr(cid:0) ¯S(cid:1) + i × ldS × kc + kp + (i − bs) × kc S[i] = ptr(cid:0)S(l)(cid:1) + i × kc × kc for i = bs → be do Algorithm 9 Basis Generation q = heightof(R) 1 procedure BasisGeneration(E, S, R) 2 3 R0 = 0 4 5 6 7 for l = 1 → q do N = n/m/2q−l nb = sizeof(Sl) [RE, R, E, S, ¯S] = marshalBasisGen(Rl−1, El, Sl) gemmBatched(N, RE, R, E transposeBatched(nb, S, ¯S)] Rl = qrBatched*(N, ¯S) T ) 8 9 10 (cid:46) ldS = rows of ¯S (cid:46) leaf level, log(n/m) (cid:46) down the matrix tree (cid:46) number of block rows (cid:46) number of blocks in level l (cid:46) Q not computed used to sweep up the tree; however processing each node involves different com- putational kernels. For the leaf nodes U q i to produce a new basis node W q i and produce the truncated basis by discarding singular vectors corresponding to values that are less than a threshold relative to the largest singular value. . We then compute the singular value decomposition of W q i , we first use Rq i = U q i RqT i As we impose a constant rank per level, we use a fast reduction to compute the i = QqT i will be the new compact basis node. Finally, the projection Processing the inner nodes of the tree follows the same procedure as the orthogo- left singular vectors Qq matrix into the new basis is computed as T q maximum truncated rank(cid:101)kq for the given tolerance at the leaf level. The truncated nalization: we form the 2(cid:101)kl×kl−1 matrix Z using the original transfer matrices and proceed to compute its truncated singular value decomposition. The two(cid:101)kl ×(cid:101)kl−1 blocks of the truncated left singular vectors Ql i will be the new transfer matrices for the truncated inner node, and the projection matrix is computed as T l i Zi. The marshaling procedures are very similar to those of the orthogonalization with the addition of applying the factor R to the original basis. The operations are then the projection matrices. We then compute a weighted Z matrix, W l i = ZiRl i = QlT i U q i . i, and carried out by batch singular value decompositions and matrix-matrix multiplica- tions. This leads us to Algorithm 10 for producing the new compact basis and the corresponding projection matrix tree T given a relative threshold  for truncation. Finally, the projection of the coupling matrices is carried out in the same way as the projection phase of the orthogonalization procedure, using marshaled batch matrix-matrix multiplications with the projection matrix tree produced by Algo- rithm 10. 5.5. Performance results. We study the performance of the GPU compression procedure using the same two families of 2D and 3D covariance matrices described in Section 4.6 for HMV. The matrices were originally generated as hierarchical matrices in a generic polynomial basis. As a result, their representation is not particularly memory efficient and algebraic compression can be therefore expected to produce new compressed hierarchical representation to reduce their memory footprint in an accuracy controllable way. Problem size 214 215 216 217 218 219 2 −AH (cid:107)AH 1 (cid:107)F (cid:107)AH 1 (cid:107)F 6.40 × 10−8 9.85 × 10−8 1.14 × 10−7 1.52 × 10−7 1.74 × 10−7 2.19 × 10−7 (cid:107)Ax−AH 1 x(cid:107) (cid:107)Ax(cid:107) 3.33 × 10−7 3.60 × 10−7 3.47 × 10−7 3.50 × 10−7 3.49 × 10−7 3.52 × 10−7 (cid:107)Ax−AH 2 x(cid:107) (cid:107)Ax(cid:107) 3.12 × 10−7 3.36 × 10−7 3.50 × 10−7 3.58 × 10−7 3.47 × 10−7 3.48 × 10−7 Table 2. Compression errors for the 2D problem using a truncation threshold of 10−7. Tables 2 and 3 show the compression errors for the 2D and 3D problems re- In this table, A refers to the exact dense covariance (that is never spectively. Algorithm 10 Basis Truncation (cid:46) leaf level, log(n/m) (cid:46) new basis (cid:46) truncate the basis (cid:46) transformation between bases (cid:46) replace basis by the new one (cid:46) up the tree 1 procedure SVDupsweep(U , E, R, T , ) 2 q = heightof(T ) 4 m , U, Rq(cid:1) 3 W = gemmBatched(cid:0) n [W,(cid:101)k(q)] = svdBatched(cid:0) n m , W, (cid:1) T q = gemmBatched(cid:0) n m , W T , U(cid:1) 5 U = W for l = q → 1 do N = n/m/2q−l [T, E] = marshalSVDupsweep(T l, El) Z = gemmBatched(N, T, E) W = gemmBatched(N/2, Z, Rl−1) [W,(cid:101)kl−1] = svdBatched(N/2, W, ) T l−1 = gemmBatched(cid:0)N/2, W T , Z(cid:1) F = marshalSVDunstack(W, F l) F l = copyBatched(F) 6 7 8 9 10 11 12 13 14 15 Problem size 214 215 216 217 218 219 2 −AH (cid:107)AH 1 (cid:107)F (cid:107)AH 1 (cid:107)F 1.33 × 10−3 1.75 × 10−3 2.08 × 10−3 2.35 × 10−3 2.85 × 10−3 2.83 × 10−3 (cid:107)Ax−AH 1 x(cid:107) (cid:107)Ax(cid:107) 9.10 × 10−4 9.49 × 10−4 9.19 × 10−4 9.62 × 10−4 9.78 × 10−4 9.76 × 10−4 (cid:107)Ax−AH 2 x(cid:107) (cid:107)Ax(cid:107) 9.54 × 10−4 1.03 × 10−3 9.35 × 10−4 9.70 × 10−4 9.62 × 10−4 9.68 × 10−4 Table 3. Compression errors for the 3D problem using a truncation threshold of 10−3. formed but whose entries have analytical expressions from the underlying kernel), AH1 refers to the hierarchal matrix approximation of the covariance generated us- ing the generic Chebyshev polynomial basis described earlier, and AH2 refers to the algebraically compressed covariance. The AH2 matrices were generated using a truncation threshold of 10−7 for the 2D problems and 10−3 for the 3D problems. These thresholds were chosen to correspond to the errors that already existed in the AH1 matrix approximation so that the algebraic compression does not introduce further approximation errors. Therefore the reduction in memory footprint comes purely from the generation of more efficient bases to represent the matrix. The first column of Tables 2 and 3 shows the relative error between the origi- nal hierarchical matrix AH1 and the compressed matrix AH2 in the Frobenius norm. As expected, these errors are on the order of the truncation threshold used in the compression. We note here that the Frobenius norm error is computed, quite inex- pensively, in the course of the truncation operation and does not require a separate post-processing operation. This is a useful feature for applications that require adaptive tolerances and fine error control inside chains of hierarchical operations. The second and third columns show the relative error pre- and post-compression respectively, measured in the 2-norm (cid:107)Ax − AHx(cid:107)/(cid:107)Ax(cid:107) where x is a random vec- tor whose entries are uniformly distributed. For the large problems where it is too expensive to compute Ax, we randomly sampled 10% of the rows and scaled the resulting error. As expected, comparing the second and third columns shows that compression with the appropriate thresholds had little to no effect on the accuracy of the resulting matrix. We first profile and measure the performance of the orthogonalization kernel. Figure 13 shows the percentage of total operation time spent in each of the three phases of the orthogonalization in single and double precision. It is easy to see that the projection phase dominates the runtime for the larger problem sizes, making the computational kernel at the core of this operation, the batched matrix-matrix multiplication, the main performance limiter. On the P100 GPU and for small matrix sizes, the CUBLAS batched gemm routines we use show lackluster perfor- mance and stand to be improved; the single precision performance is actually quite close to that of the double precision. We see this effect in the runtimes of the orthogonalization in Figures 14a and 14b; however, the expected linear growth of the algorithm remains. As the kernels involved in this computation are compute bound, Figures 14c and 14d show the performance in single and double precision Figure 13. Breakdown of the orthogonalization phases in percentages of total operation time in single (left) and double (right) precision on a P100 GPU, showing that the projection phase dominates the runtime. (a) Time for the orthogonalization in single and double precision for a 2D problem. (b) Time for the orthogonalization in single and double precision for a 3D problem. (c) Performance of orthogonalization in single and double precision for a 2D problem. (d) Performance of orthogonalization in single and double precision for a 3D problem. Figure 14. Runtime and achieved performance of the orthogonalization on a single P100 GPU. Note the asymptotic linear growth with problem size. Double and single precision times are closer to each other than expected due to the performance of the CUBLAS batched gemm routines. 214215216217218219220020406080100Problemsize%totaltimeLeavesUpsweepProjection214215216217218219020406080100Problemsize%totaltime2142152162172182192202−92−72−52−3ProblemSizeTime(s)H-OrthogSPH-OrthogDPLinearGrowth2142152162172182192202−92−72−52−3ProblemSizeTime(s)H-OrthogSPH-OrthogDPLinearGrowth2142152162172182192205001,0001,5002,000ProblemSizeGFLOP/sH-OrthogSPH-OrthogDP2142152162172182192205001,0001,5002,000ProblemSizeGFLOP/sH-OrthogSPH-OrthogDP Figure 15. Breakdown of the compression phases in percentages of total operation time in single (left) and double (right) precision on a P100 GPU, showing that the truncation and basis generation phases dominate the computation. (a) Time for the compression in single and double precision for a 2D problem. (b) Time for the compression in single and double precision for a 3D problem. (c) Performance of compression in single and double precision for a 2D problem. (d) Performance of compression in single and double precision for a 3D problem. Figure 16. Runtime and achieved performance of compression on a single P100 GPU, showing asymptotically linear growth with problem size. 214215216217218219220020406080100Problemsize%totaltimeBasisGenTruncationProjection214215216217218219020406080100Problemsize%totaltime2142152162172182192202−52−42−32−22−12021ProblemSizeTime(s)H-CompressSPH-CompressDPLinearGrowth2142152162172182192202−52−42−32−22−12021ProblemSizeTime(s)H-CompressSPH-CompressDPLinearGrowth214215216217218219220100200300400500600ProblemSizeGFLOP/sH-CompressSPH-CompressDP214215216217218219220100200300400500600ProblemSizeGFLOP/sH-CompressSPH-CompressDP (a) Effect of the compression on mem- ory for the 2D problem with a truncation threshold of 10−7. (b) Effect of the compression on mem- ory for the 3D problem with a truncation threshold of 10−3. (c) Effect of the compression on HMV for the 2D problem. (d) Effect of the compression on HMV for the 3D problem. Figure 17. Effect of the compression on memory and runtime for the 2D and 3D problems, showing significant memory savings for the low rank portion and the HMV time. for the 2D and 3D problems in GFLOP/s. Overall however, the orthogonalization phase represents a relatively small percentage (10 -- 15%) of the total compression time. Figure 15 shows the runtime profile of the compression in single and double pre- cision where both truncation and basis generation phases are dominant due to the relatively costly SVD operations on the basis nodes and the QR decompositions on the coupling matrix data, especially when compared to the matrix-matrix multipli- cations of the projection phase. Figures 16a and 16b show the asymptotic growth of the compression algorithm. Since this is also a compute bound algorithm, we show the performance of the compression in GFLOP/s as the total number of operations executed by each batched kernel over total execution time in Figures 16c and 16d. 2142152162172182192202−62−3202326ProblemSizeMemory(GB)DenseBlocksSPDenseBlocksDPLRBlocksSPLRBlocksDPCompressedLRBlocksSPCompressedLRBlocksDPLinearGrowth2142152162172182192202−52−32−1212325ProblemSizeMemory(GB)DenseBlocksSPDenseBlocksDPLRBlocksSPLRBlocksDPCompressedLRBlocksSPCompressedLRBlocksDPLinearGrowth2142152162172182192202−122−102−82−62−4ProblemSizeTime(s)HMVMSPHMVMDPCompressedHMVMSPCompressedHMVMDPLinearGrowth2142152162172182192202−112−92−72−52−3ProblemSizeTime(s)HMVMSPHMVMDPCompressedHMVMSPCompressedHMVMDPLinearGrowth Figures 17a and 17b show the significant memory savings achieved by the al- gebraic compression procedure. The compression also has a positive effect on the runtime of the hierarchical matrix arithmetic as shown in the improved runtimes of the matrix-vector operation in Figures 17c and 17d. 6. Summary and Conclusions Hierarchical matrices provide memory-efficient approximations for many of the dense matrices that appear in a variety of contexts in scientific computing. In their H2 form, which may be viewed as an algebraic generalization of fast multipole methods, they have asymptotically optimal memory requirements and can store approximations of dense matrices in O(n) units of storage. This optimal memory footprint makes them particularly useful representations on modern hardware ar- chitectures, which are characterized by their limited memory relative to the raw arithmetic performance of their cores, such as GPUs and manycore processors. The objective of this work is to develop algorithms for operating on H2 matrices, that expose the fine grained parallelism to allow for efficient GPU execution. We describe algorithms and high performance implementations of hierarchical matrix vector multiplication as well as hierarchical matrix compression, a key component to efficient H2−matrix arithmetic, and show that the computations are amenable to highly efficient processing on GPUs. By flattening the representation trees of a hierarchical matrix, we can efficiently marshal the operations for parallel execution using high performance batched kernels, and cleanly separate the linear algebra from the tree operations. Operating directly on the compressed representation, we demonstrate that the matrix vector operation can be completed in under 29ms at 78% of the theoretical peak bandwidth on the P100 GPU for a problem size of over a million involving a representative covariance matrix arising in 3D spatial statistics. The compression of a matrix from an initial hierarchical representation generated from an analytical kernel to an optimal algebraically-compressed one that preserves the original accu- racy, can be done in under 1.7s for the million sized 3D problem and executes at nearly 850 GFLOPS/s on the P100 GPU, including a basis orthogonalization phase that executes at more than 2, 000 GFLOPS/s and basis generation and truncation phases at over 600 GFLOPS. With the core compression algorithm in place, our future work will tackle BLAS3 operations on hierarchical matrices, including matrix-matrix multiplication and ma- trix inversion on GPUS, and explore applications of hierarchical matrices that can benefit from the high performance of GPUs. References [1] R. Kriemann, H-lib pro, 2016. [Online]. Available: www.hlibpro.com [2] -- -- , "H-LU factorization on many-core systems," Computing and Visualization in Science, vol. 16, no. 3, pp. 105 -- 117, 2013. [3] S. Borm and S. Christophersen, "Approximation of BEM matrices using GPGPUs," arXiv, vol. abs/1510.07244, 2015. [4] P. Zaspel, "Algorithmic patterns for h-matrices on many-core processors," CoRR, vol. abs/1708.09707, 2017. [Online]. Available: http://arxiv.org/abs/1708.09707 [5] S. Filippone, V. Cardellini, D. Barbieri, and A. Fanfarillo, "Sparse matrix-vector multiplica- tion on gpgpus," ACM Transactions on Mathematical Software, vol. 43, no. 4, pp. 30:1 -- 30:49, 2017. [6] N. Bell, S. Dalton, and L. Olson, "Exposing fine-grained parallelism in algebraic multigrid methods," SIAM Journal on Scientific Computing, vol. 34, no. 4, pp. 123 -- 152, 2012. [7] N. Bell and M. Garland, "Implementing sparse matrix-vector multiplication on throughput- oriented processors," in SC '09: Proceedings of the Conference on High Performance Com- puting Networking, Storage and Analysis, 2009, pp. 1 -- 11. [8] D. Merrill and M. Garland, "Merge-based parallel sparse matrix-vector multiplication," in SC16: International Conference for High Performance Computing, Networking, Storage and Analysis, 2016, pp. 678 -- 689. [9] T. Deakin, J. Price, M. Martineau, and S. McIntosh-Smith, GPU-STREAM v2.0: Bench- marking the Achievable Memory Bandwidth of Many-Core Processors Across Diverse Parallel Programming Models, ser. ISC High Performance 2016. Lecture Notes in Computer Science. Springer, 2016, vol. 9945, pp. 489 -- 507. [10] W. Hackbusch, Hierarchical Matrices: Algorithms and Analysis. Springer, 2015. [11] J. Ballani and D. Kressner, Matrices with Hierarchical Low-Rank Structures. Cham: Springer International Publishing, 2016, pp. 161 -- 209. [12] W. Hackbusch, "A sparse matrix arithmetic based on H-matrices. part i: Introduction to [13] W. Hackbusch and S. Borm, "Data-sparse approximation by adaptive h2-matrices," Com- H-matrices," Computing, vol. 62, no. 2, pp. 89 -- 108, 1999. puting, vol. 69, no. 1, pp. 1 -- 35, 2002. [14] S. Borm, "Approximation of integral operators by matrices with adaptive bases," Computing, vol. 74, no. 3, pp. 249 -- 271, 2005. [15] -- -- , "Approximation of solution operators of elliptic partial differential equations by H- and H2-matrices," Numerische Mathematik, vol. 115, no. 2, pp. 165 -- 193, 2010. [16] L. Grasedyck, W. Hackbusch, and B. N. Khoromskij, "Solution of large scale algebraic matrix riccati equations by use of hierarchical matrices," Computing, vol. 70, no. 2, pp. 121 -- 165, 2003. [17] L. Grasedyck, R. Kriemann, and S. Le Borne, "Domain decomposition based H-lu preconditioning," Numerische Mathematik, vol. 112, no. 4, pp. 565 -- 600, 2009. [Online]. Available: http://dx.doi.org/10.1007/s00211-009-0218-6 [18] W. Hackbusch, B. N. Khoromskij, and R. Kriemann, "Hierarchical matrices based on a weak admissibility criterion," Computing, vol. 73, no. 3, pp. 207 -- 243, Oct 2004. [19] J. Xia, S. Chandrasekaran, M. Gu, and X. S. Li, "Fast algorithms for hierarchically semisep- arable matrices," Numerical Linear Algebra with Applications, vol. 17, no. 6, pp. 953 -- 976, 2010. [20] A. Gillman, P. M. Young, and P.-G. Martinsson, "A direct solver with o (n) complexity for integral equations on one-dimensional domains," Frontiers of Mathematics in China, vol. 7, no. 2, pp. 217 -- 247, 2012. [21] P.-G. Martinsson, "A direct solver for variable coefficient elliptic pdes discretized via a com- posite spectral collocation method," Journal of Computational Physics, vol. 242, pp. 460 -- 479, 2013. [22] S. Ambikasaran and E. Darve, "An o(n log n) fast direct solver for partial hierarchically semi-separable matrices," Journal of Scientific Computing, vol. 57, no. 3, pp. 477 -- 501, 2013. [23] A. Haidar, T. Dong, P. Luszczek, S. Tomov, and J. Dongarra, "Optimization for performance and energy for batched matrix computations on GPUs," in Proceedings of the 8th Workshop on General Purpose Processing Using GPUs, ser. GPGPU-8. New York, NY, USA: ACM, 2015, pp. 59 -- 69. [24] N. Bell and J. Hoberock, "Thrust: A productivity-oriented library for cuda," in GPU com- puting gems Jade edition. Elsevier, 2011, pp. 359 -- 371. [25] W. H. Boukaram, G. Turkiyyah, H. Ltaief, and D. E. Keyes, "Batched qr and svd algorithms on gpus with applications in hierarchical matrix compression," Parallel Computing, 2017. [Online]. Available: http://www.sciencedirect.com/science/article/pii/S0167819117301461 [26] NVIDIA, cuBLAS Library Documentation (v8.0), 2016. [27] Dongarra et al., Accelerating Numerical Dense Linear Algebra Calculations with GPUs. Springer, 2014, ch. Numerical Computations with GPUs, pp. 1 -- 26. [28] R. Yokota, G. Turkiyyah, and D. Keyes, "Communication Complexity of the Fast Multipole Method and Its Algebraic Variants," Supercomputing Frontiers and Innovations, vol. 1, no. 1, pp. 63 -- 84, Apr. 2014. [29] S. Ambikasaran, D. Foreman-Mackey, L. Greengard, D. W. Hogg, and M. O'Neil, "Fast direct methods for gaussian processes," IEEE Transactions on Pattern Analysis & Machine Intelligence, vol. 38, no. 2, pp. 252 -- 265, 2016. [30] S. Borm, M. Lohndorf, and J. M. Melenk, "Approximation of integral operators by variable- order interpolation," Numerische Mathematik, vol. 99, no. 4, pp. 605 -- 643, 2005. to multi-dimensional problems," Computing, vol. 64, no. 1, pp. 21 -- 47, 2000. [31] W. Hackbusch and B. N. Khoromskij, "A sparse H-matrix arithmetic. Part II: Application [32] L. Grasedyck and W. Hackbusch, "Construction and arithmetics of H-matrices," Computing, [33] A. Abdelfattah, D. Keyes, and H. Ltaief, "Kblas: An optimized library for dense matrix- vector multiplication on gpu accelerators," ACM Transactions Mathematical Software, vol. 42, no. 3, pp. 18:1 -- 18:31, 2016. vol. 70, no. 4, pp. 295 -- 334, 2003. [34] A. Abdelfattah, H. Ltaief, D. Keyes, and J. Dongarra, "Performance optimization of sparse matrix-vector multiplication for multi-component pde-based applications using gpus," Con- currency and Computation: Practice and Experience, vol. 28, no. 12, pp. 3447 -- 3465, 2016. [35] NVIDIA, cuSPARSE Library Documentation (v8.0), 2016. [36] S. Borm, Efficient numerical methods for non-local operators: H2-matrix compression, al- gorithms and analysis, ser. EMS tracts in mathematics. European Mathematical Society, 2010, vol. 14.
1004.1220
1
1004
2010-04-08T02:05:02
Relaxation-based coarsening and multiscale graph organization
[ "cs.DS", "math.NA" ]
In this paper we generalize and improve the multiscale organization of graphs by introducing a new measure that quantifies the "closeness" between two nodes. The calculation of the measure is linear in the number of edges in the graph and involves just a small number of relaxation sweeps. A similar notion of distance is then calculated and used at each coarser level. We demonstrate the use of this measure in multiscale methods for several important combinatorial optimization problems and discuss the multiscale graph organization.
cs.DS
cs
RELAXATION-BASED COARSENING AND MULTISCALE GRAPH ORGANIZATION DORIT RON∗, ILYA SAFRO† , AND ACHI BRANDT‡ Abstract. In this paper we generalize and improve the multiscale organization of graphs by introducing a new measure that quantifies the "closeness" between two nodes. The calculation of the measure is linear in the number of edges in the graph and involves just a small number of relaxation sweeps. A similar notion of distance is then calculated and used at each coarser level. We demonstrate the use of this measure in multiscale methods for several important combinatorial optimization problems and discuss the multiscale graph organization. 1. Introduction. A general approach for solving many large-scale graph prob- lems, as well as most other classes of large-scale computational science problems, is through multilevel (multiscale, multiresolution, etc.) algorithms. This approach gen- erally involves coarsening the problem, producing from it a sequence of progressively coarser levels (smaller, hence simpler, related problems), then recursively using the (approximate) solution of each coarse problem to provide an initial approximation to the solution at the next-finer level. At each level, this initial approximation is first improved by what we generally call "local processing" (LP). This is an inexpensive sequence of short steps, each involving only a few unknowns, together covering all unknowns of that level several times over. The usual examples of LP are few sweeps of classical (e.g., Gauss-Seidel or Jacobi) relaxation in the case of solving a system of equations, or a few Monte Carlo passes in statistical-physics simulations. Following the LP, the resulting approximation may be further improved by one or several cy- cles, each using again a coarser-level approximation followed by LP, applying them at each time to the residual problem (the problem of calculating the error in the current approximation). See, for example, references [6, 7, 11, 12, 13, 14, 38, 42]. At each level of coarsening one needs to define the set of coarse unknown variables and the equations (or the stochastic relations) that they should satisfy (or the energy that they should minimize). Each coarse unknown is defined in terms of the next- finer-level unknowns (defined, not calculated: they are all unknowns until the coarse level is approximately solved and the fine level is interpolated from that solution). The following are examples: • The set of coarse unknowns can simply represent a chosen subset of the fine- • If the fine-level variables are real numbers or vectors, each coarse variable can • If the fine-level variables are Ising spins (having only values of +1 or −1), each coarse variable can again be an Ising spin, representing the sign of the sum of several fine spins. • A coarse variable can be defined from several fine variables by a stochastic • In the case of graph problems, each node of the coarse graph can represent represent a weighted average of several of them. level set. process ([5], for example). [email protected] ∗Faculty of Mathematics and Computer Science, The Weizmann Institute of Science, †Mathematics and Computer Science Division, Argonne National Laboratory, [email protected] ‡Faculty of Mathematics and Computer Science, The Weizmann Institute of Science, [email protected] 1 an aggregate of several fine-level nodes or a weighted aggregate of such nodes, that is, allowing each fine-level node to be split between several aggregates. The choice of an adequate local processing at a fine level and the choice of an adequate set of variables at the next-coarser level are strongly coupled. The general guiding rule [10] is that this pair of choices is good if (and to the extent that) a fine- level solution can always be recovered from the corresponding set of coarse variables by a short iterative use of a suitably modified version of the LP. That version is called compatible LP (CLP). Examples are compatible Monte Carlo (CMC), introduced in [13], and compatible relaxation (CR), introduced in [8]. The CLP, needed in several important upscaling procedures (such as the selec- tion of the coarse variables, the acceleration of the fine-level simulations, and the processing of fine-level windows within coarse simulations; see [10]) can also be used for performing the interpolation from the coarse solution to obtain the first approxi- mation at the fine level. When possible, however, the construction of a more explicit interpolation is desired in order to apply it for the direct formulation of equations (or an energy functional) that should govern the coarse level, as in Galerkin coarsening. In the process of defining the set of coarse variables and in constructing an explicit interpolation, it is important to know how "close" two given fine-level variables are to each other at the stage of switching to the coarse level. We need to know, in other words, to what extent the value after the LP of one variable implies the value of the other. If they are sufficiently close, they can, for example, be aggregated to form a coarse variable. The central issue addressed in the present article is how to measure this "close- ness" between two variables in a system of equations or between two nodes in a given graph. (We consider the latter to be a special case of the former, by associating the graph with the system formed by its Laplacian.) More generally, we want to define the distance of one variable xi from a small subset S of several variables, in order to measure how well xi can be interpolated from S following the LP. In classical Algebraic Multigrid (AMG), aimed at solving the linear system n(cid:88) j=1 Ax = b or aijxj = bi , (i = 1, ..., n) , (1.1) the closeness of two unknowns xi and xj is measured simply by the relative size of their coupling aij, for example, by the quantity aik, aij/max( (cid:88) (cid:88) akj) (1.2) k k (or similarly by the relative size of their coupling in some power of A). Although this definition has worked well for the coarsening procedures of discretized scalar elliptic differential equations, it is not really effective, and sometimes meaningless, for systems lacking sufficient diagonal dominance (including many discretized nonscalar elliptic systems). Moreover, even for systems with a fully dominant diagonal (such as the Laplacian of a graph), the classical AMG definition may result in wrong coarsening, for example, in graphs with nonlocal edges (see example in Sec. 3). Instead, we propose to define the "closeness" between two variables exactly, by measuring how well their values are correlated at the coarsening stage, namely, fol- lowing the LP relaxation sweeps. Since the coarse level is actually applied to the residual system, the two variables will be considered close if their errors have nearly 2 the same ratio in all relaxed vectors. We will thus create a sequence of K normalized relaxed error vectors x(1), ..., x(K), each obtained by relaxing the homogeneous system Ax = 0 from some (e.g., random) start and then normalizing the result. We will then define the algebraic distance (reciprocal of "closeness") between any two variables xi and xj as (cid:18) K(cid:88) k=1 (cid:19)1/p minη ηx(k) i − η−1x(k) j p , (1.3) where p ≥ 2 in order to attach larger weights to larger differences (using usually either p = 2 or the maximum norm (p → ∞)). This use of η gives a symmetric measure of how well xi can be interpolated from xj or vice versa. For the graph Laplacian (and other zero-sum A) this can be simplified to a distance defined as (cid:18) K(cid:88) k=1 (cid:19)1/2 i − x(k) (x(k) j )2 or i − x(k) x(k) j . K max k=1 (1.4) More generally, the distance of a node xi from a subset S of several nodes can similarly be defined as the deviation of the best-fitted interpolation from S to xi, where the deviation is the L2 norm of the vector of K errors obtained upon applying the interpolation to our K normalized relaxed error vectors, and the best-fitted in- terpolation is the one having the minimal deviation. (This least-square interpolation is the one introduced in bootstrap AMG (BAMG) [9] for the coarse-to-fine explicit interpolation.) An essential aspect of the "algebraic distance" defined here is that it is a crude local distance. It measures meaningful closeness only between neighboring nodes; the closer they are the less fuzzy is their measured distance. For nodes that should not be considered as neighbors, their algebraic distance just detects the fact that they are far apart; its exact value carries no further meaning. The important point is that this crude local definition of distance is fast to calculate and is all that is required for the coarsening purposes. A similar notion of distance is then similarly calculated at each coarser level. Indeed, we argue that meaningful distances in a general graph should, in princi- ple, be defined (not just calculated) only in such a multiscale fashion. This essential viewpoint, and relations to diffusion distances and spectral clustering are discussed in Section 5. In particular, we advocate the replacement of spectral methods by AMG- like multilevel algorithms, which are both faster and more tunable to define better solutions to many fuzzy graph problems (see, for example, [41, 42]). The paper is organized as follows. The graph problems we use to demonstrate our approach are introduced in Sec 2. The calculation of the "algebraic distance" and its use within the multiscale algorithm is described in Section 3. Results of tests are summarized in Section 4. Finally, the relations of our approach to diffusion distances and spectral clustering are discussed in Section 5. 2. Notation and problem definitions. Given a weighted graph G = (V, E), where V = {1, 2, ..., n} is the set of nodes (vertices) and E is the set of edges. Denote by wij the non-negative weight (coupling) of the undirected edge ij between nodes i and j; if ij /∈ E, then wij = 0. We consider as our examples the following two optimization problems. 3 2.1. Linear ordering. Let π be a bijection π : V −→ {1, 2, ..., n} . The purpose of linear ordering problems is to minimize some functional over all pos- sible permutations π. The following functional should be minimized for the minimum p-sum problem1 (MpSP): σp(G, π) = wijπ(i) − π(j)p . (2.1) (cid:88) ij In the generalized form of the problem that emerges during the multilevel solver, each vertex i is assigned with a volume (or length), denoted vi. Given the vector of all volumes, v, the task now is to minimize the cost σp(G, π, v) def = σp(G, x) = wijxi − xjp , (cid:88) ij 2 +(cid:80) where xi = vi k,π(k)<π(i) vk; that is each vertex is positioned at its center of mass, capturing a segment on the real axis that equals its length. The original form of the problem is the special case where all the volumes are equal. In particular, we would like to concentrate on the minimum linear arrangement (where p = 1) and the minimum 2-sum problem (M2SP) that were proven to be NP-complete in [23, 24] and whose solution can serve as an approximation for many different linear ordering problems replacing the spectral approaches [41, 42]. 2.2. Partitioning. The goal of the 2-partitioning problem is to find a partition of V into two disjoint nonempty subsets Π1 and Π2 such that wij , subject to Πk ≤ (1 + α) · V 2 , (k = 1, 2) , (2.2) (cid:88) minimize i∈Π1,j∈Π2 where α is a given imbalance factor. Graph partitioning is an NP-hard problem [22] used in many fields of computer science and engineering. Applications include VLSI design, minimizing the cost of data distribution in parallel computing and optimal tasks scheduling. Because of its practical importance, many different heuristics (spectral [36], combinatorial [31, 21], evolutionist [15], etc.) have been developed to provide an approximation in a reason- able (and, one hopes, linear) computational time. However, only the introduction of multilevel methods for partitioning [30, 35, 2, 34, 46, 3, 37, 4, 27, 29, 1] has really provided a breakthrough in efficiency and quality. 3. The coarsening algorithm. In the multilevel framework a hierarchy of de- creasing size graphs G0, G1, ..., Gk is constructed. Starting from the given graph, G0 = G, we create by recursive coarsening the sequence G1, ..., Gk, then solve the coarsest level directly, and uncoarsen the solution back to G. In general, the AMG-based coarsening is interpreted as a process of weighted aggregation of the graph nodes to define the nodes of the next coarser graph. In weighted aggregation each node can be divided into fractions, and different fractions 1We use this definition for simplicity. The usual definition of the functional is σp(G, π) = ij wijπ(i) − π(j)p)1/p, which yields the same minimization problem. 4 ((cid:80) belong to different aggregates. The construction of a coarse graph from a given one is divided into three stages. First a subset of the fine nodes is chosen to serve as the seeds of the aggregates (the nodes of the coarse graph). Then the rules for aggregation are determined, thereby establishing the fraction of each nonseed node belonging to each aggregate. Finally, the graph couplings (or edges) between the coarse nodes are calculated. The entire coarsening scheme is shown in Algorithm 1. The AMG-based multilevel framework for graph optimization problems is dis- cussed, for example, in [42]. In the present work we generalize the coarsening part of the AMG-based framework. The problem-dependent solution of the coarsest level and the uncoarsening are not changed here. They are fully described in [42] and references therein. The principal difference between the previous AMG-based coarsening approaches [42, 28, 17] and the new relaxation-based approach is the improved measure, the algebraic coupling, assigned to each edge, or, more generally, between any two nodes, in the graph. The algebraic coupling is the reciprocal of the calculated algebraic distance introduced below. Algebraic distance and coupling. The need for an improved measure for the graph couplings can be explained by observing the graph depicted in Figure 3.1: one additional edge ij (connecting nodes i and j) is added to a regular twodimensional mesh. While coarsening, nodes i and j clearly should not belong to the same aggregate unless their coupling is much stronger than other graph couplings. However, if the weight of ij is just somewhat larger than all other graph edges, and if the black dots are some of the seeds of the coarse aggregates (chosen by some AMG-based criterion; see, for example, Algorithm 2), node i will tend to be aggregated with node j, rather than with any of its neighbors. Such a decision will create bad coarse-level approximations in many optimization problems (e.g., linear ordering and partitioning). Moreover, at the next-coarser levels the approximation may further deteriorate by making similar wrong decisions, making the entire neighborhood of i close to j, thereby promoting linear arrangements in which many local couplings would unnecessarily become long- range ones. To prevent this situation we would like to have a measure that not only evaluates the coupling between i and j according to the direct coupling between them but also takes into account the contribution of connections between the neighborhoods of i and j. That is, if the immediate (graph) neighbors of i are connected to those of j, the coupling between i and j should be enhanced, while if i's neighbors are not connected to those of j, as in Figure 3.1, a significant weakening of the ij coupling is due. This measure will prevent possible errors while coarsening. We introduce the notion of algebraic distance, which is based on the same set of test vectors (TVs) being used in the bootstrap AMG (BAMG) [9]. The key new ingredient of the adaptive BAMG setup is the use of several TVs, collectively repre- senting algebraically smooth error, to define the interpolation weights. When a priori knowledge of the nature of this error is not available, slightly relaxed random vectors are used for this task. A set of some K low-residual TVs {x(k)}K k=1 can first be ob- tained by relaxation. Namely, each x(k) is a result of r fine-level relaxation sweeps on the homogeneous equation Ax = 0, starting from a random approximation, where A is the Laplacian of the graph. In particular, we have used a small number (usually r=10) of Jacobi under relaxation sweeps with ω = 0.5. That is, the new value for each x(k), k = 1, ..., K (in our tests K = 20) is N EW = (1 − ω)x(k) + ωx(k) x(k) JAC , 5 (3.1) Fig. 3.1. Mesh graph with an additional edge between nodes i and j. The black dots mark some of the nodes selected to serve as the seeds of the coarse aggregates; see Algorithm 2. where JAC = D−1(D − A)x(k) , x(k) (3.2) D being the diagonal of A. The algebraic distance from node i to node j is defined over the K relaxed TVs by Other definitions, such as dij = K max k=1 i − x(k) x(k) j . K(cid:88) k=1 dij = i − x(k) (x(k) j )2 (3.3) (3.4) are also possible. Hence, only if dij is small may nodes i and j be aggregated into the same coarse node. The algebraic coupling between i and j, cij, is defined as the reciprocal of dij: cij = 1/dij . (3.5) Data: Q , ν Result: coarse graph For every edge ij derive its algebraic distance dij (3.3) or (3.4) and algebraic coupling cij (3.5); SelectCoarseNodes(Q , ν); Define the coarse graph using the matrix P in Equation (3.7); Algorithm 1: Coarsening scheme We return to the example in Figure 3.1 and demonstrate the outcome of Definition (3.3) by comparing dij with di∗ = min{diss a nearest neighbor of i}. We show that i will not tend to be connected to j unless wij equals the sum of i's other couplings. 6 jiq Furthermore, we show that even if i is connected to j as a result of strong wij, i's other neighbors will not tend to be connected to i as well but will prefer other neighbors; hence the neighborhoods of i and j will not tend to be connected to each other. Consider Table 3.1. The number K of TVs is given in the leftmost column. The number r of Jacobi relaxation sweeps varies from 10 to 100 as shown in the second to the left column. Each of the four columns to the right presents the (natural) logarithm of dij/di∗, averaged over 100 independent runs, for graph couplings wuv = 1 when u and v are nearest neighbors, and wij = 1, 2, 3, or 4 as shown. The numbers in parentheses are the corresponding standard deviations. Clearly the strength of the coupling between i and j is relatively decreased when measured by the algebraic distance. For instance, if the graph coupling between i and j is 1 (as are all other couplings in the graph), then after 20 relaxation sweeps (with K = 10) dij is three times bigger than the minimum of the (algebraic distance of the) edges to i's four nearest neighbors. Thus, the algebraic coupling between i and j is not the strongest coupling of i (not even close to it), and hence it is guaranteed that i and j will not belong to the same coarse node. The importance of using more than just 1 TV can be seen from the values of the standard deviations: The use of 1 TV results in standard deviations similar to the average, which means that ln(dij/di∗) has a significant chance to become negative, so ij has a significant chance to be the strongest coupling of i. With 10 TVs this chance becomes much smaller, at least for wij ≤ 2. Even with 10 TVs, however, the chance grows with wij, becoming more than 50% roughly when wij ≥ 4. Thus, the aggregation of i with j becomes likely. This by itself is fine and justified. What we really need to avoid is that entire neighborhoods of i and j will, as a result, be aggregated at some coarser level. Hence, it is important to see whether the neighbors of i will tend to be aggregated with i (and thus also with j) or will prefer their other neighbors. To see that, we calculate the (natural) logarithm of dqi/dqi∗, where dqi∗ = min{dqss a nearest neighbor of q other than i}. As shown in Table 3.2, q would rather be aggregated with one of its other-than-i neighbors. For example, for K = 10, r = 20 and wij = 4 out of the 100 runs, in 95 q would have been connected with i. The main conclusion is that nodes i and j do not tend to be connected as long as wij is smaller than the sum of all other couplings of i or of j. When the coupling is of the same strength, they will be connected about half the time, but then, not less important, the neighbors of i (and similarly of j) will not tend to join them but will prefer to be connected to other nearest neighbors nodes. Similar results are obtained when using (3.4) to calculate dij. With the notion of the algebraic coupling in mind, the coarse nodes selection and the calculation of the aggregation weights are modified as follows. Seed selection. The construction of the set of seeds C and its complement F is guided by the principle that each F -node should be "strongly coupled" to C. We will include in C nodes with exceptionally large volume or nodes expected (if used as seeds) to aggregate around them an exceptionally large total volume of F -nodes. We start with C = ∅, hence F = V , and then sequentially transfer nodes from F to C, as follows. As a measure of how large an aggregate seeded by i ∈ F might grow, we define its future volume ϑi by ϑi = vi + . (3.6) (cid:88) ij∈E cji(cid:80) vj · jk∈E cjk Nodes with future volume larger than ν times the average of the ϑi's are first trans- ferred to C as most "representative" (in our tests ν = 2). The insertion of additional 7 wuv = 1 for (u, v) nearest neighbors K 1 5 10 r 10 20 50 100 10 20 50 100 10 20 50 100 wij = 1 2.47(1.51) 2.74(1.74) 2.65(1.36) 3.03(1.72) 1(0.502) 1.34(0.442) 1.68(0.342) 1.78(0.467) 0.821(0.281) 1.09(0.268) 1.49(0.263) 1.69(0.315) wij = 2 1.88(1.74) 2.1(1.59) 1.98(1.76) 2.14(1.32) 0.628(0.416) 0.825(0.415) 1.04(0.338) 1.06(0.392) 0.443(0.294) 0.624(0.239) 0.86(0.235) 1.01(0.275) Table 3.1 wij = 3 1.38(1.85) 1.4(1.26) 1.92(1.41) 1.51(1.42) 0.24(0.417) 0.435(0.358) 0.643(0.306) 0.743(0.369) 0.022(0.293) 0.298(0.235) 0.504(0.226) 0.572(0.264) wij = 4 1.14(1.69) 1.44(1.59) 1.5(1.59) 1.16(1.78) -0.0484(0.397) 0.208(0.332) 0.362(0.296) 0.396(0.359) -0.244(0.313) 0.0126(0.253) 0.2(0.204) 0.285(0.271) Statistical results (over 100 runs) for the average (and, in parentheses, the standard deviation) of ln(dij /di∗), calculated with K TVs and r Jacobi relaxation sweeps for different relative strengths of wij . wuv = 1 for (u, v) nearest neighbors K 1 5 10 r 10 20 50 100 10 20 50 100 10 20 50 100 wij = 1 0.975(1.67) 0.911(1.62) 1.37(1.77) 0.897(1.55) 0.382(0.534) 0.434(0.444) 0.498(0.436) 0.501(0.522) 0.283(0.312) 0.362(0.281) 0.448(0.311) 0.464(0.377) wij = 2 0.939(1.7) 1.09(1.31) 1.14(1.79) 1.23(1.45) 0.482(0.428) 0.472(0.366) 0.755(0.53) 0.746(0.544) 0.299(0.316) 0.419(0.295) 0.531(0.35) 0.682(0.348) Table 3.2 wij = 3 1.14(1.63) 1.02(1.46) 1.28(1.49) 1.29(1.53) 0.416(0.52) 0.592(0.486) 0.784(0.526) 0.812(0.549) 0.376(0.307) 0.449(0.288) 0.672(0.351) 0.839(0.374) wij = 4 1.07(1.89) 0.931(1.64) 1.24(1.45) 1.31(1.44) 0.587(0.487) 0.663(0.458) 0.813(0.455) 0.816(0.535) 0.401(0.357) 0.441(0.327) 0.604(0.333) 0.749(0.39) Statistical results (over 100 runs) for the average (and, in parentheses, the standard deviation) of ln(dqi/dqi∗) (see Figure 3.1), calculated with K TVs and r Jacobi relaxation sweeps for different relative strengths of wij . F -nodes to C depends on a "strength of coupling to C" threshold Q (in our tests Q = 0.5), as specified in Algorithm 2. Coarse nodes. Each node in the chosen set C becomes the seed of an aggregate that will constitute one coarse-level node. Next it is necessary to determine for each i ∈ F a list of j ∈ C to which i will belong. Define caliber, l, to be the maximal number of C-points allowed in that list. The selection we propose here is based on both measures: the graph couplings wij's and the algebraic couplings cij's. Define for each i ∈ F a coarse neighborhood ¯¯N C(i) = {j ∈ C : ij ∈ E}. Set D to be the maximal cij in ¯¯N C(i). Construct a possibly smaller coarse neighborhood by including only nodes with strong algebraic coupling ¯N C(i) = {j ∈ ¯¯N C(i) : cij ≥ β ∗ D}, we use 8 Data: Q, ν Result: set of seeds C C ← ∅, F ← V ; Calculate ϑi (3.6) for each i ∈ F , and their average ϑ; C ←nodes i with ϑi > ν · ϑ; F ← V \ C; forall i ∈ F in descending order of ϑi do if ((cid:80) j∈(C∩N (i)) cij/(cid:80) j∈(C∩N (i)) wij/(cid:80) ((cid:80) j∈N (i) cij) ≤ Q or j∈N (i) wij) ≤ Q then move i from F to C; end Algorithm 2: SelectCoarseNodes(Q, ν) β = 0.5. If ¯N C(i) > l, then the final coarse neighborhood N C(i) will include the first l largest wij's in ¯N C(i). If ¯N C(i) ≤ l, then N C(i) ← ¯N C(i). This construction of the coarse neighborhood N C(i) of i ∈ F is summarized in Algorithm 3. (In the results below we have used only l = 1 and l = 2.) The classical AMG interpolation matrix P (of size V × C) is then defined by wik for i ∈ F, j ∈ N C(i) for i ∈ C, j = i otherwise . (3.7)  wij/ (cid:80) 1 0 k∈N C (i) Pij = Pij represents the fraction of i that will belong to the jth aggregate. Data: l, i, β ¯¯N C(i) ← {j ∈ C : ij ∈ E}; D = maxj∈ ¯¯N C (i)cij; ¯N C(i) = {j ∈ ¯¯N C(i) : cij ≥ β ∗ D}; if l < ¯N C(i) then N C(i) ← the l largest wij's in ¯N C(i); if l ≥ ¯N C(i) then N C(i) ← ¯N C(i); Algorithm 3: The coarse neighborhood N C(i) Coarse graph couplings. The coarse couplings are constructed as follows. Let I(k) be the ordinal number in the coarse graph of the node that represents the aggregate around a seed whose ordinal number at the fine level is k. Following the weighted aggregation scheme used in [43], the edge connecting two coarse aggregates, p = I(i) and q = I(j), is assigned with the weight w(coarse) k(cid:54)=l PkiwklPlj. The volume of the ith coarse aggregate is(cid:80) =(cid:80) pq j vjPji. 4. Computational results. We demonstrate the power of our new relaxation- based coarsening scheme by comparing its experimental results with those of the classical AMG-based coarsening for three important NP-hard optimization problems: the minimum 2-sum ((2.1) with p = 2), the minimum linear arrangement ((2.1) with p = 1), and the minimum 2-partitioning (2.2) problems. In all cases the results are 9 obtained by taking the lightest possible uncoarsening schemes, so that differences due to the different coarsening schemes are least blurred. We have implemented and tested the new coarsening scheme by using the linear ordering packages developed in [41] and in [40] and the Scotch package [35] on a Linux machine. The implementation is nonparallel and has not been optimized. The results should be considered only qualitatively and can certainly be improved by more advanced uncoarsening. Thus, no intensive attempt to achieve the best-known results for the particular test sets was done. The details regarding the uncoarsening schemes for the above problems are given in [41, 40, 17]. 4.1. The minimum p-sum problem. We present the numerical comparison for two minimum p-sum problems: the minimum 2-sum problem and the minimum linear arrangement. For these problems we have designed a full relaxation-based coarsening solver and evaluated it on a test set of 150 graphs of different nature, size (V ≤ 5·106 and E ≤ 107) and properties. The test graphs are taken from [19] and from real- life network data such as social networks, power grids, and peer-to-peer connections. Our solvers are free and can be downloaded with detailed solutions for every graph from [39]. To emphasize the difference in the minimization results between the two coarsening schemes (the relaxation-based and the classical AMG-based schemes), we measure the results obtained at the end of the multilevel cycle before the final local optimization postprocessing (Gauss-Seidel relaxation and the local processing in [41, 40]), as well as after its application. Moreover, we use small calibers, l = 1, 2, since these demonstrate more sharply the quality of matching between the F -points and the C-points. For higher calibers it is also important to use the adaptive BAMG scheme [9] for calculating the interpolation weights, which is beyond the scope of this work. Small calibers are important for maintaining the low complexity of the multilevel framework, which is vital, for example, for hypergraphs and expanders. The minimum 2-sum problem (M2SP). A comparison of the relaxation- based and AMG-based coarsenings with calibers 1 and 2 is presented in Figures 4.1(a) and 4.1(b), respectively. Each x-axis scale division corresponds to one graph from the test set. The y-axis corresponds to the ratio between the average cost obtained by 100 runs of the AMG-based coarsening and the one obtained by 100 runs of the relaxation-based coarsening. Each figure contains two curves: the dashed curves with cost measurements before applying the postprocessing of local optimization (e.g., Gauss-Seidel relaxation, Window Minimization [41]) and the regular curves with cost measurements after adding such optimization steps. Clearly most graphs benefit from the relaxation-based coarsening, showing a ratio greater than 1. The ratio decreases when more optimization is used, especially since the Gauss-Seidel relaxation is powerful algorithmic component for this problem and thus brings the results of the two coarsening schemes closer to each other as is indicated by the regular curves. All the these results were obtained with K = 10 TVs. When we lowered K to 5, we observed no significant change in the results. Our number of Jacobi overrelaxation sweeps r = 20 cannot be reduced by more than twice since this relaxation scheme is expected to evolve slowly. The detailed analysis of the convergence properties are presented in [16]. The minimum linear arrangement problem. Similarly to the previous prob- lem, we designed a relaxation-based solver and established a series of experiments for the minimum linear arrangement problem. The experimental setup was identical to that of the M2SP. It was based on the solver designed in [40]. In this case we can observe even more significant improvement when employing the relaxation-based 10 (a) l = 1 (b) l = 2 Fig. 4.1. Results for the minimum 2-sum problem. coarsening than for the M2SP. (a) l = 1 (b) l = 2 Fig. 4.2. Results for the minimum 1-sum (linear arrangement) problem. Which graphs are most beneficial? It is remarkable that the most beneficial graphs in our test set come from VLSI design and general optimization problems. We know that these graphs are very irregular (compared, for example, with finite-element graphs and with those that pose 2D/3D geometry). Thus, we may conclude that the algebraic couplings help to identify the weakness of nonlocal connections and prevent them from being aggregated. In several examples, we achieved the best known results with caliber 1, while using classical AMG-based approaches they can be achieved with bigger calibers only. the first term is taken into account (namely, ((cid:80) An algebraic coupling-based algorithm. We have also tried a straightforward algorithm in which, during coarsening, the weights of the graph are simply replaced by their algebraic couplings. That is, in the if statement at the end of Algorithm 2, only j∈N (i) cij) ≤ Q). Similarly, in Algorithm 3, wij (in the first if) is replaced by cij. We present the comparison of the obtained simple algebraic couplings based coarsening scheme with j∈(C∩N (i)) cij/(cid:80) 11 050100150graphs ordered by ratios0.911.11.21.31.4ratios between old and new multilevel solversbefore final optimizationafter final optimization050100150graphs ordered by ratios0.911.11.21.31.4ratios between old and new multilevel solversbefore final optimizationafter final optimization050100150graphs ordered by ratios0.911.11.21.31.4ratios between old and new multilevel solversbefore final optimizationafter final optimization050100150graphs ordered by ratios0.911.11.21.31.4ratios between old and new multilevel solversbefore final optimizationafter final optimization the mixed scheme described in Algorithms 2 and 3 in Figure 4.3. The comparison was done for the M2SP including postprocessing (of local optimization) using the same experimental setup. The bold curve corresponds to the ratios between the classical AMG-based results and the simple algebraic coupling-based coarsening scheme. To see the difference between this algorithm and the more elaborate one, we add a copy of its results, that is, the bold curve from Figure 4.1(a). The mixed version is clearly better: in about 25 more graphs the results are improved. The average improvement was 1.5%. Fig. 4.3. Results for the minimum 2-sum problem. Comparison of the algebraic distance based only and mixed full relaxation based algorithms. 4.2. The minimum 2-partitioning problem. We compared the relaxation- based coarsening and the classical AMG-based by combining two packages. The coarsening part was the same as in the minimum p-sum problems. The uncoarsening was based on the Scotch package; details of its fastest version can be taken from [17]. The comparison of the relaxation-based and the AMG-based coarsenings with caliber 1 is presented in Figure 4.4. The interpretation of x- and y-axes is similar to Figure 4.1. Included are 15 graphs of different nature and size. The details regarding the numerical results can be obtained from [39]. The four best ratios are obtained for graphs with power-law degree distributions. More results for the graph and hy- pergraph partitioning problems are reported in [16]. Even though the algorithm used there only substitutes the original given couplings by their algebraic couplings, it is already clear that better results are observed for most tested instances of both graphs and hypergraphs. 4.3. Running time. The implementation of stationary iterative processes and their running time are well studied issues. These topics are beyond the scope of this paper; we refer the reader to two books in which one can find discussions about sequential and parallel matrix-vector multiplications and general relaxations [25, 26]. Typical running time of an AMG-based framework for linear ordering problems on graphs can be found in [40, 41, 42]. The introduction of the algebraic disctance did not increase significantly those running time estimations. 5. Multiscale distance definition and hierarchical organization. As men- tioned in the introduction, the algebraic distance defined above is only a crude local 12 050100150graphs ordered by ratios0.90.9511.051.11.151.2ratios between old and new multilevel solvers Fig. 4.4. Results for the minimum 2-partitioning problem. distance, measuring meaningful relative distances only between neighboring nodes while also detecting which nodes should not be considered as close neighbors. This fuzzy local distance, which can be calculated rapidly, is all we need for coarsening. A similar distance is then calculated at each coarser level, thus yielding a multiscale definition of distances through the entire graph, where at large distances one defines the distances only between (usually large) aggregates of nodes, not between any indi- vidual pair of distant nodes. Such multiscale distances are not only far less expensive to calculate: we next list several reasons why, in principle, distances in a general large graph should be defined better in such a multiscale fashion. • At large distances the detailed individual distances (the exact travelling time from each house in Baltimore to each house in Boston, say) are usually not of interest. • The distance in a general graph is a fuzzy notion, whose definition is to a certain extent arbitrary. The difference between the two distances of two neighboring nodes from a third, far one is much less than the difference be- tween various, equally legitimate distance definitions, and also far less than the accuracy of the graph data (e.g., its edge weights) and far less than the accuracy of solving the equations that define these distances. • The most important reason: At different scales different factors should in In particular, at increasingly principle enter into the distance definition. larger distances, intrinsic properties of increasingly larger aggregates should play a progressively more important role. For example, in image segmenta- tion, while at the finest level the "closeness" of two neighboring pixels (i.e., their chance to belong to the same segment) can be defined by their color similarity, at larger scales the closeness of two neighboring patches should be defined in terms of the similarity in their average color (which is different from the direct color similarity of neighboring pixels along the boundary be- tween the patches) and also in terms of similarity in various texture measure (color variances, shape moments of subaggregates, average orientation of fine embedded edges, etc.) and other aggregative properties [44], [45]. Another example: in the problem of identifying clusters in a large set of points in Rd, at the finest level the distance between data points can simply be their Euclidean distance, while at coarser levels the distance between two aggre- 13 graphs ordered by ratios11.21.41.61.822.22.42.62.8ratios between old and new multilevel solvers gates of points should also take into account similarity in terms of aggregative properties, such as density, orientation and dimensionality [32]. • The multiscale definition of distance also brings much needed flexibility into the way distances at one level are converted into distances at coarser levels. For example, in a graph whose finest level consists of face images and their similarity scores, if at some coarse level node A is the union of two fine- level nodes A1 and A2, and node B is the union of B1 and B2, then the coarse weight wAB of the edge (A, B) can be defined either as some average of wA1B1 , wA1B2, wA2B1, and wA2B2 , or alternatively as the maximum (or Lp average with large p) of those four weights. The former choice (average) is more suitable if one wants to cluster faces having a similar pose, while the latter choice (max or Lp) is more suitable if we need clusters of images each belonging to the same person (or, generally, when the clustering should be based on transitive similarity). An ingenious rigorous definition of distances in a general graph, introduced in [18], is called diffusion distance. Denoting by p(t, yx) the probability of a random walk on the graph starting at x to reach y after t steps, the diffusion distance between two nodes xi and xj is defined by (cid:88) d(xi, xj, t)2 = w(y)[p(t, yxi) − p(t, yxj)]2 , (5.1) y with some suitable choice of the node weights w. This is, in fact, a multiscale definition of distance, with the diffusion time t serving as the scaling parameter. And indeed the definition is used for hierarchical organizations of graphs (even though large- scale distances are still defined in detail for any pair of nodes). The calculation of our "algebraic distance" can be viewed as just a fast way to compute a crude approximation to diffusion distances at some small t. The essential practical point is that this crude and inexpensive "algebraic dis- tance" is all one needs for solving graph problems by repeated coarsening. The cal- culation of the diffusion map (the diffusion distances at various scales t) for a large graph is, on the other hand, quite expensive, requiring computing (possibly many) eigenvectors of the graph Laplacian. The fast way to calculate them should involve using a multiscale algorithm such as AMG (which is likely to work well in those cases where hierarchical organizations of the graph is meaningful; the AMG solver can, by the way, calculate many eigenvectors for nearly the same work of calculating only one [33]). However, instead of calculating the diffusion map and then use it for organizing the graph, the AMG structure can itself be used directly, and more efficiently for any such organization. Indeed, as pointed out in [9], the same coarsening procedures used by the AMG solver can directly be used for efficient hierarchical organizations (such as multiscale clustering) of a graph (as in [32]) or for multiscale segmentation of an image (as in [44], [45]). As exemplified in this article (and also in [41], [42]), this kind of procedures can also be used for many other types of graph problems, in particular, it can also be used for detecting small hidden cliques in random graphs [20]. Thus, for discrete graphs, and analogously also for related continuum field prob- lems, although the diffusion map is a useful theoretical concept, it is often not the most practical tool. We believe this to be true for most if not all spectral graph methods (using eigenvectors of the graph Laplacian): The same AMG structure that would rapidly calculate the eigenvectors can be better used to directly address the 14 problem at hand. As pointed out in the discussion of multiscale distances, this can yield not just faster solutions but also, and more important, better definitions and more tunable treatments for many practical problems. 6. Conclusions. We have proposed a new measure that quantifies the "close- ness" between two nodes in a given graph. The calculation of the measure is linear in the number of edges in the graph and involves just a small number of relaxation sweeps. The calculated measure is all that is required for coarsening purposes. A similar notion of distance is then calculated and used at each coarser level. We demonstrate the use of this new measure for the minimum (1,2)-sum linear order- ing problem and for the minimum 2-partitioning problem. The improvement in the results shows that this measure indeed detects the most important couplings in the graph and helps in producing a better coarsening, while at the same time preventing nonlocal vertices from belonging to the same coarse aggregate. Acknowledgments. This work was partially funded by the CSCAPES institute, a DOE project, and in part by DOE Contract DE-AC02-06CH11357. We express our gratitude to Dr. C´edric Chevalier for providing us with a modification of Scotch software and helping to design the minimum 2-partitioning problem experiments. REFERENCES [1] A. Abou-Rjeili and G. Karypis. Multilevel algorithms for partitioning power-law graphs. In IPDPS, 2006. [2] C. J. Alpert, J.-H. Huang, and A. B. Kahng. Multilevel circuit partitioning. In Design Au- tomation Conference, pages 530–533, 1997. [3] R. Banos, C. Gil, J. Ortega, and F.G. Montoya. Multilevel heuristic algorithm for graph partitioning. In Applications of Evolutionary Computing, pages 143–153, 2003. [4] S. T. Barnard and H. D. Simon. A fast multilevel implementation of recursive spectral bisection for partitioning unstructured problems. Concurrency: Practice and Experience, 6:101–107, 1994. [5] H. W. J. Blote, J. R. Heringa, A. Hoogland, E.W. Meyer, and T. S. Smit. Monte Carlo renormalization of the 3D Ising model: Analyticity and convergence. Phys. Rev. Lett., 76:2613, 1996. [6] A. Brandt. Multi-level adaptive solutions to boundary-value problems. Math. Comp., 31(138):333–390, April 1977. [7] A. Brandt. Algebraic multigrid theory: The symmetric case. Jornal of Appl. Math. Comp., 19:23–56, 1986. [8] A. Brandt. General highly accurate algebraic coarsening. Electronic Trans. Num. Anal. 10 (2000) 1-20, 2000. [9] A. Brandt. Multiscale scientific computation: Review 2001. In T. Barth, R. Haimes, and T. Chan, editors, Multiscale and Multiresolution methods (Proceeding of the Yosemite Educational Symposium, October 2000). Springer-Verlag, 2001. [10] A. Brandt. Principles of systematic upscaling. In J. Fish, editor, Bridging the Scales in Science and Engineering. Oxford University Press, 2008. [11] A. Brandt, S. McCormick, and J. Ruge. Algebraic multigrid (AMG) for automatic multigrid solution with application to geodetic computations. Institute for Computational Studies, Fort Collins, Colorado, POB 1852, USA, 1982. [12] A. Brandt, S. McCormick, and J. Ruge. Algebraic multigrid (AMG) for sparse matrix equations. In D.J. Evans, editor, Sparsity and its Applications, pages 257–284. Cambridge University Press, Cambridge, 1984. [13] A. Brandt and D. Ron. Renormalization multigrid (RMG): Statistically optimal renormaliza- tion group flow and coarse-to-fine Monte Carlo acceleration. J. Stat. Physics, 102(231), 2001. [14] A. Brandt and D. Ron. Chapter 1 : Multigrid solvers and multilevel optimization strategies. In J. Cong and J. R. Shinnerl, editors, Multilevel Optimization and VLSICAD. Kluwer, 2003. 15 [15] T. N. Bui and B. R. Moon. Genetic algorithm and graph partitioning. IEEE Trans. Comput., 45(7):841–855, 1996. [16] Jie Chen and Ilya Safro. Algebraic distance on graphs. Technical Report ANL/MCS-P1696- 1009, Argonne National Laboratory. [17] C. Chevalier and I. Safro. Comparison of coarsening schemes for multilevel graph partitioning. In Proceedings of the 4th Learning and Intelligent Optimization conference, 2009. [18] R. R. Coifman and S. Lafon. Diffusion maps. Applied and Computational Harmonic Analysis, 21(1):5–30, 2006. [19] T. Davis. University of florida sparse matrix collection. NA Digest, 97(23), 1997. [20] Uriel Feige and Dorit Ron. Finding hidden cliques in linear time. Submitted, 2010. [21] C. M. Fiduccia and R. M. Mattheyses. A linear-time heuristic for improving network partitions. In Proceedings of the 19th Design Automation Conference, pages 175–181. IEEE, 1982. [22] M. R. Garey and D. S. Johnson. Computers and Interactability. A Guide to the Theory of NP- Completeness. A Series of Books in the Mathematical Sciences. Freemann And Company, 1979. [23] M. R. Garey, D. S. Johnson, and L. Stockmeyer. Some simplified NP-complete problems. In Proceedings of the Sixth Annual ACM Symposium on Theory of Somputing, pages 47–63. ACM Press, 1974. [24] A. George and A. Pothen. An analysis of spectral envelope reduction via quadratic assignment problems. SIAM Journal on Matrix Analysis and Applications, 18(3):706–732, 1997. [25] Ananth Grama, George Karypis, Anshul Gupta, and Vipin Kumar. Introduction to Parallel Computing: Design and Analysis of Algorithms. Addison-Wesley, 2003. [26] Michael T. Heath. Scientific Computing. McGraw-Hill, Inc., New York, NY, USA, 2002. [27] B. Hendrickson and R. W. Leland. A multi-level algorithm for partitioning graphs. In Super- computing, 1995. [28] Y. F. Hu and J. A. Scott. A multilevel algorithm for wavefront reduction. SIAM J. Scientific Computing, 23:2000–031, 2001. [29] G. Karypis and V. Kumar. A fast and high quality multilevel scheme for partitioning irregular graphs. Technical Report 95-035, University of Minnesota, June 1995. [30] G. Karypis and V. Kumar. Metis A Software Package for Partitioning Unstructured Graphs, Partitioning Meshes, and Computing Fill-Reducing Orderings of Sparse Matrices. Univer- sity of Minnesota, Department of Computer Science and Engineering, Army HPC Research Center, Minneapolis, MN 55455, U.S.A., 4 edition, September 1998. [31] B. W. Kernighan and S. Lin. An efficient heuristic procedure for partitioning graphs. BELL System Technical Journal, pages 291–307, February 1970. [32] D. Kushnir, M. Galun, and A. Brandt. Fast multiscale clustering and manifold identification. Special Issue on Similarity-Based Pattern Recognition, Pattern Recognition, 39:1876–1891, 2006. [33] D. Kushnir, M. Galun, and A. Brandt. Efficient multilevel eigensolvers with applications to IEEE Transaction on Pattern Analysis and Machine Intelligence data analysis tasks. (TPAMI-2008-08-0468), 2008. [34] H. Meyerhenke, B. Monien, and T. Sauerwald. A new diffusion-based multilevel algorithm for computing graph partitions of very high quality. In Proc. of the 22nd International Parallel and Distributed Processing Symposium, (IPDPS'08). IEEE Computer Society, 2008. [35] Scotch: Static mapping, graph partitioning, and sparse matrix block ordering package. http: //www.labri.fr/~pelegrin/scotch/. [36] A. Pothen, H. D. Simon, and K.-P. Liou. Partitioning sparse matrices with eigenvectors of graphs. SIAM Journal of Matrix Analysis, 11(3):430–452, July 1990. [37] D. Ron, S. Wishko-Stern, and A. Brandt. An algebraic multigrid based algorithm for bisection- ing general graphs. Technical Report MCS05-01, Department of Computer Science and Applied Mathematics, The Weizmann Institute of Science, 2005. [38] J. Ruge and K. Stuben. Algebraic multigrid. In S. F. McCormick, editor, Multigrid Methods, pages 73–130. SIAM, Philadelphia, 1987. [39] I. Safro. Homepage of our projects. http://www.mcs.anl.gov/safro. [40] I. Safro, D. Ron, and A. Brandt. Graph minimum linear arrangement by multilevel weighted edge contractions. Journal of Algorithms, 60(1):24–41, 2006. [41] I. Safro, D. Ron, and A. Brandt. Multilevel algorithm for the minimum 2-sum problem. Journal of Graph Algorithms and Applications, 10(2):237–258, 2006. [42] I. Safro, D. Ron, and A. Brandt. Multilevel algorithms for linear ordering problems. Journal of Experimental Algorithmics, 13:1.4–1.20, 2008. [43] E. Sharon, A. Brandt, and R. Basri. Fast multiscale image segmentation. In Proceedings IEEE Conference on Computer Vision and Pattern Recognition, pages 70–77, 2000. 16 [44] E. Sharon, A. Brandt, and R. Basri. Fast multiscale image segmentation. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition, pages 70–77, South Carolina, 2000. [45] E. Sharon, M. Galun, D. Sharon, R. Basri, and A. Brandt. Hierarchy and adaptivity in seg- menting visual scenes. Nature, 442:810–813, 2006. [46] C. Walshaw. Multilevel refinement for combinatorial optimisation problems. Annals Oper. Res., 131:325–372, 2004. The submitted manuscript has been created in part by UChicago Argonne, LLC, Operator of Argonne National Laboratory ("Argonne"). Ar- gonne, a U.S. Department of Energy Office of Sci- ence laboratory, is operated under Contract No. DE-AC02-06CH11357. The U.S. Government re- tains for itself, and others acting on its behalf, a paid-up nonexclusive, irrevocable worldwide li- cense in said article to reproduce, prepare deriva- tive works, distribute copies to the public, and perform publicly and display publicly, by or on behalf of the Government. 17
1105.2686
2
1105
2013-04-26T15:15:13
Smoothed Performance Guarantees for Local Search
[ "cs.DS" ]
We study popular local search and greedy algorithms for scheduling. The performance guarantee of these algorithms is well understood, but the worst-case lower bounds seem somewhat contrived and it is questionable if they arise in practical applications. To find out how robust these bounds are, we study the algorithms in the framework of smoothed analysis, in which instances are subject to some degree of random noise. While the lower bounds for all scheduling variants with restricted machines are rather robust, we find out that the bounds are fragile for unrestricted machines. In particular, we show that the smoothed performance guarantee of the jump and the lex-jump algorithm are (in contrast to the worst case) independent of the number of machines. They are Theta(phi) and Theta(log(phi)), respectively, where 1/phi is a parameter measuring the magnitude of the perturbation. The latter immediately implies that also the smoothed price of anarchy is Theta(log(phi)) for routing games on parallel links. Additionally we show that for unrestricted machines also the greedy list scheduling algorithm has an approximation guarantee of Theta(log(phi)).
cs.DS
cs
Smoothed Performance Guarantees for Local Search ∗ Tobias Brunsch Dept. of Computer Science University of Bonn, Germany [email protected] Heiko Roglin Dept. of Computer Science University of Bonn, Germany [email protected] Cyriel Rutten Tjark Vredeveld Dept. of Quantitative Economics Maastricht University, The Netherlands [email protected] Dept. of Quantitative Economics Maastricht University, The Netherlands [email protected] Abstract We study popular local search and greedy algorithms for standard machine schedul- ing problems. The performance guarantee of these algorithms is well understood, but the worst-case lower bounds seem somewhat contrived and it is questionable whether they arise in practical applications. To find out how robust these bounds are, we study the algorithms in the framework of smoothed analysis, in which instances are subject to some degree of random noise. While the lower bounds for all scheduling variants with restricted machines are rather robust, we find out that the bounds are fragile for unrestricted machines. In particular, we show that the smoothed performance guarantee of the jump and the lex-jump algorithm are (in contrast to the worst case) independent of the number of machines. They are Θ(φ) and Θ(log φ), respectively, where 1/φ is a parameter measuring the magnitude of the perturbation. The latter immediately implies that also the smoothed price of anarchy is Θ(log φ) for routing games on parallel links. Additionally, we show that for unrestricted machines also the greedy list scheduling algorithm has an approximation guarantee of Θ(log φ). 1 Introduction The performance guarantee of local search and greedy algorithms for scheduling problems is well studied and understood. For most algorithms, matching upper and lower bounds on their approximation ratio are known. The lower bounds are often somewhat contrived, however, and it is questionable whether they resemble typical instances in practical ap- plications. For that reason, we study these algorithms in the framework of smoothed analysis, in which instances are subject to some degree of random noise. By doing so, we find out for which heuristics and scheduling variants the lower bounds are robust and for which they are fragile and not very likely to occur in practical applications. Since pure Nash equilibria can be seen as local optima, our results also imply a new bound on the smoothed price of anarchy, showing that known worst-case results are too pessimistic in the presence of noise. ∗A preliminary version of this paper appeared in the proceedings of ESA 2011. 1 Let us first describe the scheduling problems that we study. We assume that there is a set J = {1, . . . , n} of jobs each of which needs to be processed on one of the machines from the set M = {1, . . . , m}. All jobs and machines are available for processing at time 0. The goal is to schedule the jobs on the machines such that the makespan, i.e., the time at which the last job is completed, is minimized. Each machine i ∈ M has a speed si and each job j ∈ J has a processing requirement pj. The time pij it takes to fully process job j on machine i depends on the machine environment. We consider two machine environments. The first one is the one of uniform parallel machines, also known as related machines: pij = pj/si. The second machine environment that we consider is the one of restricted related machines: a job j is only allowed to be processed on a subset Mj ⊆ M of the machines. The processing time is therefore pij = pj/si if i ∈ Mj and pij = ∞ if i /∈ Mj. An instance I of a scheduling problem consists of the machine speeds s1, . . . , sm, the processing requirements p1, . . . , pn, and in the restricted case the allowed machine set Mj ⊆ M for every job j. A special case for both machine environments is when all speeds are equal, i.e., si = 1 for all i ∈ M . In the notation of Graham et al. [13] these problems are denoted by QCmax and QMjCmax for the related machine problems and PCmax and PMjCmax in case of identical machines. In these problems, makespan minimization is equivalent to minimizing the maximum machine finishing time. Once the assignment of the jobs to the machines is known, the order in which the jobs are processed is of no importance to determine the machine finishing times, as long as the jobs are processed without any idle time in between. Therefore, we assume that the jobs that are scheduled on a machine i share this processor in such a way that they all finish at the same time. In this case, we say that the machines are identical. Even in the case that all speeds are equal, the problems under consideration are known to be strongly NP-hard when m is part of the input (see, e.g., Garey and Johnson [10]). This has motivated a lot of research in the previous decades on approximation algorithms for scheduling problems. Since some of the theoretically best approximation algorithms are rather involved, a lot of research has focused on simple heuristics like greedy algorithms and local search algorithms which are easy to implement. While greedy algorithms make reasonable ad hoc decisions to obtain a schedule, local search algorithms start with some schedule and iteratively improve the current schedule by performing some kind of local improvements until no such is possible anymore. In this article, we consider the following algorithms that can be applied to all scheduling variants that we have described above: • List scheduling is a greedy algorithm that starts from an empty schedule and a list of jobs. Then, it repeatedly selects the next unscheduled job from the list and assigns it to the machine on which it will be completed the earliest with respect to the current partial schedule. We call any schedule that can be generated by list scheduling a list schedule. • The jump and the lex-jump algorithms are local search algorithms that start with In each an arbitrary schedule and iteratively perform a local improvement step. improvement step, one job is reassigned (jumped) from a machine i to a different machine i(cid:48) where it finishes earlier. In the jump algorithm, only jobs on critical machines i, i.e., machines that have maximum finishing time, are considered to be 2 improving. In the lex-jump algorithm, the jobs can be arbitrary. Note that a local step is lex-jump improving if and only if the sorted vector of machine finishing times decreases lexicographically, hence the term lex-jump. A schedule for which there is no jump improvement step or no lex-jump improvement step is called jump optimal or lex-jump optimal, respectively. For each of these three algorithms, we are interested in their performance guarantees, i.e., the worst case bound on the ratio of the makespan of a schedule to be returned by the algorithm over the makespan of an optimal schedule. The final schedule returned by a local search algorithm is called a local optimum. Usually, there are multiple local optima for a given scheduling instance both for the jump and the lex-jump algorithm with varying quality. As we do not know which local optimum is found by the local search, we will always bound the quality of the worst local optimum. Since local optima for lex-jump and pure Nash equilibria are the same, see e.g. [26], this corresponds to bounding the price of anarchy in the scheduling game that is obtained if jobs are selfish agents trying to minimize their own completion time and if the makespan is considered as the welfare function. Similarly, list scheduling can produce different schedules depending on the order in which the jobs are inserted into the list. Also for list scheduling we will bound the quality of the worst schedule that can be obtained. The processing requirement on a machine i ∈ M is defined as (cid:80) of a machine is defined by Li(I, σ) =(cid:80) Notation. Consider an instance I for the scheduling problem and a schedule σ for this instance. By Ji(σ) ⊆ J we denote the set of jobs assigned to machine i according to σ. j∈Ji(σ) pj and the load j∈Ji(σ) pij. The makespan Cmax(I, σ) of σ can be written as Cmax(I, σ) = maxi∈M Li(I, σ). The optimal makespan, i.e., the makespan of an optimal schedule is denoted by C∗ max(I). By Jump(I), Lex(I), and List(I) we denote the set of all feasible jump optimal schedules, lex-jump optimal schedules, and list schedules, respectively, according to instance I. If the instance I is clear from the context, we simply write Li(σ) instead of Li(I, σ), Cmax(σ) instead of Cmax(I, σ), and C∗ max(I). If the schedule σ is clear as well, we simplify our notation further to Li and Cmax and we write Ji instead of Ji(σ). By appropriate scaling, we may assume w.l.o.g. that the slowest machine has speed smin = 1 and that all processing requirements are bounded by pj ≤ 1. In Appendix A, the notation is summarized in a table. max instead of C∗ Smoothed analysis. As can be seen in Table 1, the worst-case approximation guarantee of jump and lex-jump is known for all scheduling variants and it is constant only for the simplest case with unrestricted and identical machines. In all other cases it increases with the number m of machines. For list scheduling, the case with unrestricted and related machines has been considered. Cho and Sahni [6] and Aspnes et al. [2] showed that the performance guarantee of list scheduling is Θ(log m) in this case. In order to analyze the robustness of the worst-case bounds, we turn to the framework of smoothed analysis, introduced by Spielman and Teng [24] to explain why certain al- gorithms perform well in practice in spite of a poor worst-case running time. Smoothed analysis is a hybrid of average-case and worst-case analysis: First, an adversary chooses 3 an instance. Second, this instance is slightly randomly perturbed. The smoothed per- formance is the expected performance, where the expectation is taken over the random perturbation. The adversary, trying to make the algorithm perform as bad as possible, chooses an instance that maximizes this expected performance. This assumption is made to model that often the input an algorithm gets is subject to imprecise measurements, rounding errors, or numerical imprecision. If the smoothed performance guarantee of an algorithm is small, then bad worst-case instances might exist, but one is very unlikely to encounter them if instances are subject to some small amount of random noise. We follow the more general model of smoothed analysis introduced by Beier and Vocking [5]. In this model, the adversary is even allowed to specify the probability distri- bution of the random noise. The influence he can exert is described by a parameter φ ≥ 1 denoting the maximum density of the noise. This model is formally defined as follows. Definition 1. In a φ-smooth instance I, the adversary chooses the following input data: • the number m of machines; • arbitrary machine speeds smax := s1 ≥ . . . ≥ sm =: smin = 1, in the case of non- identical machines; • the number n of jobs; • an arbitrary set Mj ⊆ M for each job j ∈ J, in the case of restricted machines; • for each pj, a probability density fj : [0, 1] → [0, φ] according to which pj is chosen independently of the processing requirements of the other jobs. Note that the only perturbed part of the instance are the processing requirements. Formally, a φ-smooth instance is not a single instance but a distribution over instances. We write I ∼ I to denote that the instance I is drawn from the φ-smooth instance I. The parameter φ specifies how close the analysis is to a worst case analysis. The adversary can, for example, choose for every pj an interval of length 1/φ from which pj is drawn uniformly at random. For φ = 1, every processing requirement is uniformly distributed over [0, 1], and hence the input model equals the average case for uniformly distributed processing times. When φ gets larger, the adversary can specify the processing requirements more and more precisely, and for φ → ∞ the smoothed analysis approaches a worst-case analysis. In this article, we analyze the smoothed performance guarantee of the jump, the lex- jump, and the list scheduling algorithm. As mentioned above, to define the approximation guarantee of these algorithms on a given instance, we consider the worst local optimum (for the jump and the lex-jump algorithm) or the worst order in which the jobs are inserted into the list (for the list scheduling algorithm). Now, the smoothed performance is defined to be the worst expected approximation guarantee of any φ-smooth instance. Our results. Our results for the jump and lex-jump algorithm are summarized in Ta- ble 1. The first remarkable observation is that the smoothed performance guarantees for all variants of restricted machines are robust against random noise. We show that even 4 worst case φ-smooth jump lex-jump jump Θ(1) lex-jump Θ(1) Θ(1) [9, 23] log log m (cid:16) log m (cid:16) log m (cid:16) log S log log S log log m (cid:17) (cid:17) (cid:17) Θ Θ [7] [3] Θ(φ) [2.1] √ m) [3.1] Θ ( m · smax (cid:17) (cid:16)√ Θ(log φ) [2.2, 2.3] (cid:16) log m (cid:16) log m log log m (cid:17) (cid:17) log log m Θ [3.2] [3.2] Θ ( Θ(1) [9, 23] √ m) [6, 23] √ m) [21] unrestricted identical unrestricted related restricted identical restricted related (cid:17) Θ ( m · smax (cid:16)√ schedules. Here, S =(cid:80)m Θ [21] Θ [21] Θ [3.1] Ω Table 1: Worst-case and smoothed performance guarantees for jump and lex-jump optimal i=1 si, and we assume w.l.og. that smin = 1. With [X.Y] we refer to the section in this article where the bound is shown. for large perturbations with constant φ, the worst-case lower bounds carry over. This can be seen as an indication that neither the jump algorithm nor the lex-jump algorithm yield a good approximation ratio for scheduling with restricted machines in practice. The situation is much more promising for the unrestricted variants. Here, the worst- case bounds are fragile and do not carry over to the smoothed case. The interesting case is the one of unrestricted and related machines. Even though both for jump and for lex- jump the worst-case lower bound is not robust, there is a significant difference between these two: while the smoothed approximation ratio for jump grows linearly with the per- turbation parameter φ, it grows only logarithmically in φ for lex-jump optimal schedules. This proves that also in the presence of random noise lex-jump optimal schedules are significantly better than jump optimal schedules. As mentioned earlier, this also implies that the smoothed price of anarchy is Θ(log φ). Additionally, we show that the smoothed approximation ratio of list scheduling is Θ(log φ) as well, even when the order of the list may be specified after the realizations of the processing times are known. This indicates that both the lex-jump algorithm and the list scheduling algorithm should yield good approximations on practical instances. Related work. The approximability of QCmax is well understood. Cho and Sahni [6] showed that list scheduling has a performance guarantee of at most 1 + √2m − 2/2 for m ≥ 3 and that it is at least Ω(log m). Aspnes et al. [2] improved the upper bound to O(log m) matching the lower bound asymptotically. Hochbaum and Shmoys [14] designed a polynomial time approximation scheme for this problem. Polynomial time approximation algorithms and polynomial time approximation schemes for special cases of the problem on restricted related machines are given in, among others, [18, 11, 20]. More work on restricted related parallel machines is discussed in the survey of Leung and Li [17]. In the last decade, there has been a strong interest in understanding the worst-case behavior of local optima. We refer to the survey [1] and the book [19] for a comprehensive overview of the worst-case analysis and other theoretical aspects of local search. It follows from the work of Cho and Sahni [6] that for the problem on unrestricted related machines the performance guarantee of the jump algorithm is (1 + √4m − 3)/2 and this bound is (cid:9)(cid:1). For the problem on restricted related formance guarantee is Θ(cid:0) min(cid:8) log m tight [23]. For lex-jump optimal schedules, Czumaj and Vocking [7] showed that the per- log log m , log smax 5 (cid:112) (cid:1), where S = (cid:80)m machines, Rutten et al. [21] showed that the performance guarantee of locally optimal 1 + 4(m − 1)smax)/2 and that schedules with respect to the jump neighborhood is (1 + this bound is tight up to a constant factor. Moreover, they showed that the performance i=1 si. When all speeds are equal, Awerbuch et al. [3] showed that the performance guarantee for lex-jump guarantee of lex-jump optimal schedules is Θ(cid:0) log S optimal schedules is Θ(cid:0) log m (cid:1). log log S log log m Up to now, smoothed analysis has been mainly applied to running time analysis (see, e.g., [25] for a survey). The first exception is the paper by Becchetti et al. [4] who in- troduced the concept of smoothed competitive analysis, which is equivalent to smoothed performance guarantees for online algorithms. Schafer and Sivadasan [22] performed a smoothed competitive analysis for metrical task systems. Englert et al. [8] considered the 2-Opt algorithm for the traveling salesman problem and determined, among others, the smoothed performance guarantee of local optima of the 2-Opt algorithm. Hoefer and Souza [15] presented one of the first average case analyses for the price of anarchy. The remainder of this article is organized as follows. In Section 2, we provide asymp- totically matching upper and lower bounds on the smoothed performance guarantees of jump optimal, lex-jump optimal, and list schedules in case of unrestricted related ma- chines. In Section 3, we show that smoothing does not help for the setting of restricted machines. 2 Unrestricted Related Machines 2.1 Jump Optimal Schedules We show that the smoothed performance guarantee grows linearly with the smoothing parameter φ and is independent of the number of jobs and machines. In particular, it is constant if the smoothing parameter is constant. In proving our results, we make use of the following proposition which follows from Cho and Sahni [6]. Proposition 2. For any scheduling instance I with m unrestricted related machines and n jobs max σ∈Jump(I) Cmax(I, σ) max(I) ≤ C∗ 1 + 4 min{m, n} − 3 2 + √n . 1 2 ≤ (1) (cid:112) (cid:21) (cid:20) Theorem 3. For any φ-smooth instance I with unrestricted and related machines, E I∼I max σ∈Jump(I) Cmax(I, σ) C∗ max(I) < 5.1φ + 2.5 = O(φ) . Proof. First note that if m > n, then there exist an optimal schedule and a worst jump- optimal schedule that do not schedule any job on any of the slowest m − n machines. We ignore these slowest m − n machines, and therefore we assume that m ≤ n. We will prove an upper bound on the performance guarantee of jump optimal schedules that decreases j∈J pj increases and that is valid for when the sum of processing requirements Q = (cid:80) 6 every instance. Then, we will argue that for φ-smooth instances Q is usually not too small, which yields the theorem. Let σ denote an arbitrary jump optimal schedule for some arbitrary processing require- ments pj ∈ [0, 1]. Let i be an arbitrary machine, let machine imax be a critical machine in schedule σ, and let j be a job assigned to machine imax by schedule σ. By jump optimality of σ it follows that Cmax(σ) = Limax ≤ Li + pj/si ≤ Li + pmax/si , where pmax denotes the processing requirement of the largest job. The previous inequality yields that si· Cmax(σ) ≤ si· Li + pmax for all machines i ∈ M . Summing over all machines from M \ {imax} and adding simax · Limax to both sides of the inequality, we find that (cid:88) (cid:88) si · Li ≤ (n − 1) · pmax + si · Li (cid:88) i∈M i∈M si · Cmax(σ) ≤ since Limax = Cmax(σ). Noting that (cid:80) i∈M\{imax} pmax + upper bound on the makespan of any jump optimal schedule σ: j∈J pj = Q yields the following (cid:88) i∈M si · Li = (cid:80) i∈M Cmax(σ) ≤ i∈M si Q/(cid:80) where the last inequality follows since pmax ≤ 1. Using the well-known bound C∗ i∈M si i∈M si we obtain max ≥ Q(cid:80) n − 1(cid:80) + , Q(cid:80) + i∈M si n − 1(cid:80) i∈M si ≤ (cid:16) (cid:17) 1 + n − 1 Q ∗ max . · C Cmax(σ) ≤ Hence, max σ∈Jump(I) Cmax(I, σ) max(I) ≤ 1 + C∗ n − 1 Q . (2) The performance guarantee of any jump optimal schedule can only be bad if Q is small. Since the instance is φ-smooth, the processing requirements are random variables in [0, 1] with bounded densities. Let F denote the failure event that Q ≤ (n − √n ln n)/(2φ). We Then, Pr[pj ≥ a] ≥ Pr[xj ≥ a] for any a ∈ [0, 1]. Let X = (cid:80) define xj to be independent random variables drawn uniformly from [0, 1/φ] for all j ∈ J. j∈J xj. Then, for any a ∈ [0, n], it follows that Pr[Q ≥ a] ≥ Pr[X ≥ a]. Hence, n − √n ln n n − √n ln n (cid:35) (cid:34) (cid:35) Pr [F] = Pr Q ≤ 2φ (cid:34) (cid:34) ≤ Pr (cid:35) √n ln n 2φ ≤ e X ≤ 2φ −(ln n)/2 = 1 √n = Pr E [X] − X ≥ , (3) where the last inequality follows from Hoeffding's bound [16] (see also Theorem 31 in the appendix). Consider the random variable (cid:40) 1 2 + √n if event F occurs , 1 + n−1 otherwise , Q Z = 7 and let Y = maxσ∈Jump(I) denote by F the complement of F and obtain Cmax(I,σ) max(I) . Due to Inequalities (1) and (2) we have Y ≤ Z. We C∗ I∼I [Y ] ≤ E E I∼I [Z] ≤ E I∼I (cid:18) (3) ≤ 1 + < 2.5 + (cid:3) + E (cid:2) ZF (cid:19) 2φ(n − 1) n − √n ln n (cid:112) 1 − ln(n)/n 2φ + I∼I [ ZF] · Pr 1/2 + √n I∼I [F] √n < 2.5 + 5.1φ . For the third inequality, we used Q > (n − √n ln n)/(2φ) if event F does not hold. The last inequality holds since (cid:112) 2 max n∈Z+ 1 − < 5.1, ln(n)/n where the maximum is attained for n = 3. Corollary 4. Consider an instance of scheduling with unrestricted and related machines in which the processing requirement of every job is chosen independently and uniformly at random from [0, 1]. The expected performance guarantee of the worst jump optimal schedule is O(1). Next, we show that the upper bound on the smoothed performance guarantee provided in Theorem 3 is tight up to constant factor when φ ≥ 2. Theorem 5. There is a class of φ-smooth instances I with unrestricted and related ma- chines such that (cid:20) (cid:21) E I∼I max σ∈Jump(I) Cmax(I, σ) C∗ max(I) = Ω(φ) . Proof. For any φ > 2 we construct a φ-smooth instance I with n = (cid:100)4φ2 + 1(cid:101) and m = n machines. Let s1 = n − 1 4φ ≥ φ > 2 and s2 = . . . = sn = 1 . We assume that the processing requirement p1 is chosen uniformly from the interval [1 − 1/φ, 1] while the processing requirements of all other jobs are chosen uniformly from the interval [0, 1/φ]. In an optimal schedule, job 1 is scheduled on machine 1, and all other machines process exactly one job (see Figure 1). Hence, ∗ max = max C , p2, . . . , pn ≤ max s1 (cid:27) (cid:26) 1 (cid:27) , 1 φ s1 = 1 φ . (cid:26) p1 We show that with high probability there exists a jump optimal schedule σ with Cmax(σ) > 1− 1/φ. In order to find such a schedule σ, we first schedule job 1 on machine 2. Then, we consider the remaining jobs one after another and schedule unassigned jobs to machine 1 8 Figure 1: Optimal schedule Figure 2: Machines 1 and 2 of sched- ule σ if event E occurs holds with high probability with respect to φ. that Q2 :=(cid:80)n (cid:2)L2 − 1/(φs1), L2 until either L1 ∈ unscheduled is then exclusively assigned to one empty machine. Let E denote the event j=2 pj ≥ s1. Note that E [Q2] = (n− 1)/(2φ) = 2s1. We will see that event E (cid:1) or all jobs are scheduled. Any job that remains (cid:2)L2 − (cid:1) since Q2/s1 ≥ 1 ≥ p1 = L2 and pj ≤ 1/φ for all jobs j = 2, . . . , n (see Consider the case that event E occurs. Then, schedule σ is such that L1 ∈ 1/(φs1), L2 Figure 2). Now, we argue that schedule σ is jump optimal. First observe that machine 2 defines the makespan since L2 > max{L1, p2/1, . . . , pn/1}. Job 1, which is the only job assigned to that machine, cannot jump to a machine i > 2 because these have the same speed as machine 2. Furthermore, it cannot jump to machine 1 because L1 + p1 s1 ≥ L2 − 1 φs1 + 1 − 1/φ s1 = L2 + 1 − 2/φ s1 > L2 as φ > 2. Hence, σ is a jump optimal schedule with Cmax(σ) C∗ max > 1 − 1/φ 1/φ = φ − 1 . (4) It remains to determine the probability of event E. Recalling E [Q2] = 2s1, s1 = (n − 1)/(4φ), and n ≥ 4φ2 + 1, this can be bounded with Hoeffding's bound [16] (see also Theorem 31) as follows: Pr(cid:2) (cid:3) = Pr [Q2 < s1] = Pr (cid:16) n−1 (cid:17)2 E −2 = exp 4φ (n − 1)/φ2 (cid:20)  = exp (cid:18) (cid:21) (cid:19) (cid:19) (cid:18) (cid:18) 1 −2s2 (cid:19) (n − 1)/φ2 φ2 2 . E [Q2] − Q2 > s1 ≤ exp n − 1 8 − ≤ exp − (cid:18) (cid:18) (cid:19)(cid:19) φ2 2 Let X = maxσ∈Jump(I) antee can be bounded from below as follows: Cmax(I,σ) max(I) . Applying Inequality (4) the smoothed performance guar- C∗ I∼I [X] ≥ E E I∼I [ XE] · Pr I∼I [E] ≥ (φ − 1) · 1 − exp − 9 s1≈φs2=1p1≤1sn=1p2≤1φpn≤1φs1≈φs2=1p1≈1p2=12φ±12φ≤1φs1pl=12φ±12φ (cid:18) = (φ − 1) − (φ − 1) · exp − (cid:19) φ2 2 > φ − 1.14 = Ω(φ) , where the last inequality follows because (φ − 1) · exp(−φ2/2) < 0.14 for φ > 2. 2.2 Upper Bounds for List Schedules and Lex-jump Optimal Schedules Although the worst case performance bound on unrestricted related machines for list scheduling is slightly worse than the one for lex-jump scheduling, we show that the smoothed performance guarantee of both schedules is O(log φ). In the next subsection, we show that this bound is asymptotically tight. Theorem 6. Let α be an arbitrary positive real. For φ ≥ 2 and any φ-smooth instance I with unrestricted and related machines (cid:21) (cid:18) 32φ (cid:19)n/2 ≤ 2α/6 (cid:20) (cid:20) max σ∈Lex(I)∪List(I) Pr I∼I and Cmax(I, σ) max(I) ≥ α C∗ (cid:21) Cmax(I, σ) C∗ max(I) E I∼I max σ∈Lex(I)∪List(I) ≤ 18 log2 φ + 30 = O(log φ) . (cid:88) Note that the assumption φ ≥ 2 in Theorem 6 is no real restriction as for φ ∈ [1, 2) any φ-smooth instance is a 2-smooth instance. Hence, for these values we can apply all bounds from Theorem 6 when substituting φ by 2. In particular, the expected value is a constant. In the remainder of this section, we will use the following notation (see also Ap- pendix A). Let Ji,j(σ) denote the set of all jobs that are scheduled on machine i and have index at most j, i.e., Ji,j(σ) = Ji(σ) ∩ {1, . . . , j}. If σ is clear from the context, then we just write Ji,j. We start with observing an essential property that both lex-jump optimal schedules and list schedules have in common. Definition 7. We call a schedule σ on machines 1, . . . , m with speeds s1, . . . , sm a near list schedule, if we can index the jobs in such a way that Li(cid:48) + pj si(cid:48) ≥ Li − (cid:96)∈Ji,j−1(σ) p(cid:96) si (5) for all machines i(cid:48) list schedules for instance I. (cid:54)= i and all jobs j ∈ Ji(σ). With NL(I) we denote the set of all near Inequality (5) can be interpreted as follows. Assume that the jobs are already indexed correctly and imagine that on each machine the jobs form a stack, ordered from top to bottom ascendingly according to their index. Now, consider an arbitrary job j on machine i (see Figure 3a). Inequality (5) states that the completion time of job j after removing all jobs above j is minimized on machine i in case only job j is allowed to move (see Figure 3b). Lemma 8. For any instance I the relation Lex(I) ∪ List(I) ⊆ NL(I) holds. 10 (a) Jobs on machine i, including job j, visualized as a stack (b) Job j does not benefit from jumping to machine i(cid:48) Figure 3: Interpretation of Inequality (5) Note that in general neither Lex(I) ⊆ List(I) nor List(I) ⊆ Lex(I) holds (see Figure 4). Moreover, there also exist near list schedules that are neither in Lex(I) nor in List(I) (see Figure 4c), i.e., near list schedules are a non-trivial generalization of both lex-jump optimal schedules and list schedules. (a) A list schedule which is not lex-jump optimal (b) A lex-jump optimal schedule which is no list schedule (c) A near list schedule which is neither lex-jump optimal nor a list schedule Figure 4: Relationship between Lex(I), List(I), and NL(I) Proof of Lemma 8. For any schedule σ ∈ Lex(I), we can index the jobs arbitrarily and, by definition, even the stronger inequality Li(cid:48) + pj/si(cid:48) ≥ Li holds. For σ ∈ List(I) we can index the jobs in reverse order in which they appear in the list that was used for list scheduling. Consider an arbitrary job j ∈ Ji(σ) and a machine i(cid:48) i(cid:48) and Li, Li(cid:48) denote the loads of machines i and i(cid:48) before assigning job j to machine i and the loads of i and i(cid:48) in the final schedule, respectively. Then, L(cid:48) i(cid:48) + pj/si(cid:48) as j is assigned to machine i according to list scheduling. Since Li = L(cid:48) (cid:96)∈Ji,j p(cid:96)/si and Li(cid:48) ≥ L(cid:48) i + pj/si = Li − (cid:54)= i. Let L(cid:48) i +(cid:80) i + pj/si ≤ L(cid:48) (cid:80) (cid:96)∈Ji,j−1 i(cid:48), this implies Li(cid:48) + pj/si(cid:48) ≥ L(cid:48) i(cid:48) + pj/si(cid:48) ≥ L(cid:48) i, L(cid:48) p(cid:96)/si. In the remainder, we fix an instance I and consider an arbitrary schedule σ ∈ NL(I) 11 ii0jii0jj≥0s2=2p3=1s1=3p1=1p2=3s2=4p3=2s1=7p1=1p2=1s2=4p3=2s1=7p2=1p1=1p4=18 with appropriate indices of the jobs such that Inequality (5) holds. To prove Theorem 6, we show that in case the ratio of Cmax(I, σ) over C∗ max(I) is large, then instance I needs to have many very small jobs, see Corollary 17. This holds even when the instance I is deterministically picked by some adversary. This observation allows us to prove the main theorem of this subsection by showing that for any φ-smooth instance, there are only "few" small jobs in expectation. The latter implies that a large ratio only happens with (exponentially) small probability. In our proofs, we adopt some of the notation also used by Czumaj and Vocking [7] (see also Appendix A). Given a schedule σ, we set c = (cid:98)Cmax(σ)/C∗ max(cid:99) − 1. Recall that the machines are ordered such that s1 ≥ . . . ≥ sm. For any integer k ≤ c let Hk = {1, . . . , ik} where ik = max{i ∈ M : Li(cid:48) ≥ k · C∗ ≤ i}. Note that ik = m for all k ≤ 0 and hence Hk = M for such k (see Figure 5). Further, define Rk = Hk \ Hk+1 for all k ∈ {0, . . . , c − 1} and Rc = Hc. Note that this classification always refers to schedule σ even if additionally other schedules are considered. Some properties follow straightforwardly. max ∀ i(cid:48) Figure 5: Machine classification by Czumaj and Vocking Property 1. For each machine i ∈ Hk, Li ≥ k · C∗ Property 2. Machine ik + 1, if it exists, is the first machine in M \ Hk, i.e., the machine with the least index, and, hence, a fastest machine in M \ Hk. Property 3. Lik+1 < k · C∗ max for all k ∈ {1, . . . , c}, and L1 < (c + 2) · C∗ max. max. As mentioned, we need to show that there are many small jobs. To do so, we will show that the the speeds of the machines in low classes, i.e., R0 and R1, are exponentially small with respect to the machines in the highest class Rc (Lemma 14) and that the machines in low classes need to process high volume (Lemma 13). We start by showing that the highest class is nonempty. Lemma 9. Machine 1 is in class Rc. Proof. Let i be a critical machine. If i = 1, then we obtain L1/C∗ max > c. Otherwise we apply Inequality (5) for the job j = min{(cid:96) ∈ Ji} with the smallest index max = Cmax(σ)/C∗ 12 (c+1)·C∗maxc·C∗max(c−1)·C∗max(c−2)·C∗max0·C∗max1·C∗max1234mHc=Hc−1Hc−2H0=H−1=... on machine i and for machine 1. This yields L1 + pj/s1 ≥ Li. Hence, L1/C∗ Li/C∗ the fact that any job can contribute at most C∗ max ≥ max − 1 ≥ c, where the second inequality is due to max ≥ Cmax(σ)/C∗ max − (pj/s1)/C∗ max to the makespan of a fastest machine. Let t and k be integers satisfying 0 ≤ t ≤ k ≤ c. Several times we will consider the max to the load of first many jobs on some machine i ∈ Hk which contribute at least t · C∗ (cid:9). machine i. We denote the set of those jobs by Ji,≥t. Formally, i = min(cid:8)j : Ji,≥t = Ji,jt (cid:88) ∗ max for jt i p(cid:96)/si ≥ t · C (cid:96)∈Ji,j Using this notation, Lemma 10 and Corollary 11 restrict the machines on which a job in Ji,≥t can be scheduled in an optimal schedule. Lemma 10. Let k1 > k2 and t ≤ k1 be positive integers, let i1 ∈ Hk1 and i2 ∈ M \ Hk2 be machines in Hk1 and not in Hk2, respectively, and let j ∈ Ji1,≥t be a job on machine i1. Then, the load job j would contribute to machine i2 is bounded from below by pj/si2 > (k1 − k2 − t) · C∗ Proof. We apply Inequality (5) for machine i1, for the first machine i(cid:48) to Hk2, and for job j to obtain 2 that does not belong max. Li(cid:48) 2 + pj si(cid:48) 2 ≥ Li1 − which implies pj si(cid:48) 2 ≥ Li1 − Li(cid:48) 2 − (cid:88) (cid:96)∈Ji1,j−1 (cid:88) (cid:96)∈Ji1,j−1 p(cid:96) si1 p(cid:96) si1 , . 2 2 max. The claim follows since si(cid:48) < k2 · C∗ > (k1 − k2 − t) · C∗ max. Furthermore, j ∈ Ji1,≥t yields (cid:80) 2 and Properties 1 and 3 we obtain Li1 ≥ k1 · C∗ By the choice of the machines i1 and i(cid:48) and Li(cid:48) pj/si(cid:48) Corollary 11. Let i ∈ Hk be an arbitrary machine and let t ∈ {1, . . . , k} be an integer. Then, in any optimal schedule any job j ∈ Ji,≥t is assigned to machines from Hk−t−1. Proof. Assume, for contradiction, that there is a job j ∈ Ji,≥t which is assigned to a machine i(cid:48) ∈ M \ Hk−t−1 by an optimal schedule. By Lemma 10 this job causes a load of more than (k− (k− t− 1)− t)· C∗ max on this machine contradicting the assumption max = C∗ that the considered schedule is optimal. p(cid:96)/si1 < t · C∗ (cid:96)∈Ji1,j−1 2 ≥ si2. max max. Hence, Czumaj and Vocking [7] showed that in a lex-jump optimal schedule the speeds of any two machines which are at least two classes apart differ by a factor of at least 2. Aspnes et al. [2] showed a similar property. In general, near list schedules have a slightly weaker property. Lemma 12. Let k ∈ {5, . . . , c} and assume Hk (cid:54)= ∅. The speed of any machine in class Hk is at least twice the speed of any machine in M \ Hk−4. 13 i∈Hk the jobs from(cid:83) Proof. We may assume that M \ Hk−4 (cid:54)= ∅, since otherwise all machines have a load larger than C∗ max as Hk (cid:54)= ∅. Let i0 ∈ Hk and i2 ∈ M \ Hk−4 be arbitrary machines and consider least one job in(cid:83) Ji,≥2. If we would assign only these jobs to machines in Hk, then there would be a machine with load at least 2 · C∗ max. Consequently, in an optimal schedule at ∈ M \ Hk, say job j ∈ Ji1,≥2. i(cid:48)∈Hk Since job j contributes at most C∗ max to the load of machine i∗ in this optimal schedule, this implies pj/si∗ ≤ C∗ Ji(cid:48),≥2 is assigned to some machine i∗ max and, hence, pj si0 ≤ C ∗ max (6) as si0 ≥ si∗. Due to Lemma 10, the load that would be contributed by job j on machine i2 is bounded by pj/si2 > (k − (k − 4)− 2)· C∗ max. Inequality (6) yields si0 ≥ 2· si2 as claimed in the lemma. max = 2· C∗ We want to show that machines in low classes, i.e., machines in R0∪R1, have exponen- tially small speeds (with respect to c) compared to the speeds of the machines in a high class, i.e., those in Rc. Lemma 12 already implies that the machine speeds would double every five classes if no class Rk was empty. Although some classes Rk can be empty, we show that not too many of these machine classes are empty. This is done in Lemma 14 which follows from the next lemma. The machines i ∈ Hk, k ≥ 2, are overloaded compared to an optimal schedule, even if we just consider the first few jobs j ∈ Ji,≥t on them (where t ≥ 2). On the other hand, in Corollary 11 we showed that in any optimal schedule these jobs are not assigned to machines in much lower classes, i.e., to machines from M \ Hk−t−1. Consequently, in any optimal schedule the machines in Hk−t−1 \ Hk consume the current overload of Hk. Lemma 13. Let t ≤ k be positive integers. In any optimal schedule the total processing requirement on all machines in Hk−t−1 \ Hk is at least c(cid:88) (cid:88) k(cid:48)=k i∈Rk(cid:48) (cid:48) (t + k − k − 1) · si · C ∗ max . Note that Lemma 13 also holds for the case t = k where Hk−t−1 = H−1 = M . yields that in any optimal schedule σ∗ all jobs in (cid:83)c Proof. Applying Corollary 11 with t(cid:48)(k(cid:48)) = t+(k(cid:48) ∈ {k, . . . , c} i∈Rk(cid:48) Ji,≥t(cid:48)(k(cid:48)) are assigned to − t(cid:48)(k(cid:48)) − 1 = k − t − 1 for any index k(cid:48). Furthermore, in σ∗ the machines in Hk−t−1 as k(cid:48) processing requirement on any machine i ∈ Hk is at most si · C∗ max, i.e., the machines in Hk−t−1 \ Hk must consume the remainder. Hence, these machines must process jobs with c(cid:88) total processing requirement at least −k) for arbitrary integers k(cid:48) c(cid:88) (cid:88) (cid:88) (cid:88) c(cid:88) (cid:88) (cid:83) k(cid:48)=k (cid:48) (t (k (cid:48) ) − 1) · si · C ∗ max . k(cid:48)=k ∗ max ≥ k(cid:48)=k This yields the claimed bound as t(cid:48)(k(cid:48)) − 1 = t + k(cid:48) (cid:96)∈Ji,≥t(cid:48)(k(cid:48)) si · C p(cid:96) − i∈Rk(cid:48) i∈Rk(cid:48) k(cid:48)=k i∈Rk(cid:48) − k − 1. 14 Although some machine classes Rk might be empty, we are able to show that this cannot be the case for two consecutive classes. Lemma 14. Hk−2 \ Hk (cid:54)= ∅ for any k ∈ {1, . . . , c − 1}. Proof. Let i(cid:48) be a slowest machine in Hk. requirement on any machine i ∈ Hk−2 \ Hk is at most si · C∗ max ≤ si(cid:48) · C∗ c(cid:88) Lemma 13 with t = 1 implies (cid:88) c(cid:88) In any optimal schedule σ∗ the processing max. Applying (cid:48) (k − k) · si · C ∗ max ≥ (cid:48) (k − k) · si(cid:48) · C ∗ max · Rk(cid:48) . ∗ max ≥ k(cid:48)=k i∈Rk(cid:48) It follows that Hk−2 \ Hk · si(cid:48) · C c(cid:88) Hk−2 \ Hk ≥ k(cid:48)=k k(cid:48)=k (cid:48) (k − k) · Rk(cid:48) ≥ (c − k) · Rc ≥ 1 since k < c and since Rc (cid:54)= ∅ due to Lemma 9. We can now show that machine speeds double every six classes. To be more formal: Lemma 15. Let 0 ≤ k2 ≤ k1 ≤ c be integers, let i1 be any machine of Rk1 and let i2 ∈ Rk2. Then, si1 ≥ si2 · 2(cid:98)∆/6(cid:99) where ∆ = k1 − k2. Proof. We prove the claim by induction. For ∆ ∈ {0, . . . , 5}, the claim trivially holds as si1 ≥ si2. Assume that the claim holds up to some integer ∆∗ ≥ 5. We show that it is also true for ∆ = ∆∗ + 1 ≥ 6. Note that for such ∆ we have k1 ≥ 6. According to Lemma 14 the class Hk1−6 \ Hk1−4 ⊆ M \ Hk1−4 contains at least one machine. Let i(cid:48) be the fastest machine in Hk1−6 \ Hk1−4. Then si(cid:48) ≥ si2. Lemma 12 and the induction hypothesis imply si1 ≥ 2si(cid:48) and si(cid:48) ≥ si2 · 2(cid:98)(∆−6)/6(cid:99), respectively. Hence, si1 ≥ si2 · 2(cid:98)∆/6(cid:99). Since the machines in low classes are exponentially slower than the machines in high classes (with respect to c) and as their aggregated total processing requirement in an opti- mal schedule is large (Lemma 13), it follows that many jobs have processing requirements exponentially small in c. Lemma 16. Let i ∈ M \ H2 be an arbitrary machine. Then each job j assigned to machine i by an optimal schedule has processing requirement at most pj ≤ 2−c/6+2. Proof. For c ≤ 12 the claim is true since we rescale all processing requirements to be at most 1. Assume c ≥ 13. Consider an optimal schedule σ∗ and let j be a job processed on a machine i ∈ M \ H2 = R1∪ R0 according to σ∗. Note that M \ H2 (cid:54)= ∅ due to Lemma 14. Then, pj/si ≤ C∗ max, i.e., ∗ pj ≤ si · C max . To bound si · C∗ max, consider the job j(cid:48) = min{(cid:96) ∈ J1(σ)} with the smallest index on machine 1 of schedule σ and consider the first machine i(cid:48) ∈ Hc−3 \ Hc−1 = Rc−3 ∪ Rc−2 which exists due to Lemma 14 and c ≥ 13. Applying Inequality (5), we obtain Li(cid:48)(σ) + (7) 15 pj(cid:48)/si(cid:48) ≥ L1(σ), i.e., pj(cid:48) ≥ si(cid:48) · (L1(σ) − Li(cid:48)(σ)). Since machine 1 belongs to Hc due to Lemma 9 and since machine i(cid:48) is the first machine that does not belong to Hc−1, we have L1(σ) ≥ c · C∗ max. Lemma 15 yields si(cid:48) ≥ si · 2(cid:98)(c−3−1)/6(cid:99). Applying Inequality 7 and pj(cid:48) ≤ 1 according to our input max, which implies pj(cid:48) ≥ si(cid:48) · C∗ max and Li(cid:48)(σ) < (c − 1) · C∗ model we obtain ∗ max ≤ si(cid:48) · C pj ≤ si · C ∗ max · 2 −(cid:98)(c−4)/6(cid:99) ≤ pj(cid:48) · 2 −c/6+2 ≤ 2 −c/6+2 . Corollary 17. The processing requirement of at least n/2 jobs is at most 2−c/6+2. Proof. Lemma 13 for k = t = 2 implies that the total processing requirement of all jobs assigned to machines from M \ H2 = H−1 \ H2 according to σ∗ is at least(cid:80) si · C∗ max which is an upper bound for the total processing requirement of all jobs assigned to machines in H2 according to σ∗. Since all jobs assigned to machines from M \ H2 by an optimal schedule have processing requirement at most 2−c/6+2 due to Lemma 16, at least half of the jobs have processing requirement at most 2−c/6+2. i∈H2 Since having many so small jobs is unlikely when the processing requirements have been smoothed, it follows that the smoothed performance guarantee, which is between c + 1 and c + 2, cannot be too high, yielding Theorem 6. Proof of Theorem 6. If Cmax(σ)/C∗ max ≥ α, then at least n/2 jobs have processing require- ment at most 2−α/6+3 due to Corollary 17 and c = (cid:98)Cmax(σ)/C∗ max(cid:99) − 1 ≥ α − 2. The probability that one specific job is that small is bounded by φ · 2−α/6+3 = 8φ · 2−α/6 in the smoothed input model. Hence, the probability that the processing requirement of at (cid:19)(cid:16) least n/2 jobs is at most 2−α/6+3, is bounded from above by (cid:19)(cid:16) −α/6(cid:17)n/2 (cid:18)n (cid:18)n (cid:88) (cid:88) −α/6(cid:17)k (cid:16) −α/6(cid:17)n/2 · 8φ · 2 (cid:16) 8φ · 2 −α/6(cid:17)n−k −α/6(cid:17)n/2 ≤ 1 − 8φ · 2 (cid:16) = 32φ · 2 8φ · 2 k k≥ n 2 . Note that the first inequality holds if 8φ · 2−α/6 < 1. Otherwise, the bound is trivially true. This yields Pr I∼I max σ∈NL(I) Cmax(I, σ) max(I) ≥ α C∗ ≤ As for n = 1 any schedule σ ∈ NL(I) is optimal, we just consider the case n ≥ 2. For k ≥ 1 let αk = αk(φ) = 6k log2 φ + 30, i.e., 2αk/6 = 32φk. If α ≥ αk, then we obtain k k≥ n 2 ≤ 2n · (cid:20) (cid:20) (cid:20) Pr I∼I max σ∈NL(I) Cmax(I, σ) max(I) ≥ α C∗ (cid:21) ≤ (cid:90) ∞ as φ ≥ 2. Since αk+1 − αk = 6 log2 φ we obtain max σ∈NL(I) Cmax(I, σ) C∗ max(I) max σ∈NL(I) Pr I∼I E I∼I = 0 (cid:21) Cmax(I, σ) max(I) ≥ αk C∗ ≤ φ1−k ≤ 21−k (cid:21) Cmax(I, σ) max(I) ≥ α C∗ dα (cid:21) (cid:21) (cid:18) 32φ (cid:19)n/2 2α/6 . ≤ Pr I∼I max σ∈NL(I) (cid:16) (cid:20) φ1−k(cid:17)n/2 (cid:20) 16 ∞(cid:88) k=1 ≤ α1 + (cid:20) (cid:90) αk+1 ∞(cid:88) αk k=1 ≤ α1 + 6 log2 φ · Cmax(I, σ) max(I) ≥ α C∗ max σ∈NL(I) Pr I∼I 21−k = 18 log2 φ + 30 . (cid:21) dα 2.3 Lower Bounds for List Schedules and Lex-jump Optimal Schedules In this subsection, we show that the upper bound, given in Theorem 6, on the smoothed performance guarantee on lex-jump optimal as well as list schedules is tight up to a constant factor. We provide a φ-smooth instance such that the worst lex-jump optimal schedule as well as the worst schedule that can be obtained by list scheduling has a lower bound on the performance guarantee of Ω(log φ), for any realization of the processing times. Theorem 18. There is a class of φ-smooth instances I with unrestricted and related machines such that, for any I ∈ I, = Ω(log φ) = Ω(log φ) . max max and σ∈List(I) Cmax(I, σ) C∗ max(I) σ∈Lex(I) Cmax(I, σ) C∗ max(I) To prove this theorem, we first present a φ-smooth instance and in Algorithm 1, we implicitely give a permutation of the jobs such that list scheduling using this permutation results in a schedule σ which we will show is also lex-jump optimal. The schedule σ resembles the worst case example constructed by Czumaj and Vocking [7]: Machines are partitioned into classes indexed by 0, 1, . . . , r. We will show that in σ, each machine in class i has a load of approximately i, whereas the optimal makespan is bounded by 3. Hence, we can lower bound the performance guarantee in the order of the number of classes. Whereas Czumaj and Vocking needed Θ(log m/ log log m) classes, we only need Θ(log φ) classes. j : [0, 2r+1] → [0, φ/2r+1] for an appropriate integer r. As scaling of all processing requirements does not change the approximation ratio, for sake of simplicity we do not consider probability densities fj : [0, 1] → [0, φ] but scaled densities f(cid:48) Let φ ≥ 4 and consider an integer r = (cid:98)log4 φ(cid:99) ≥ 1, i.e., φ ≥ 4r = 22r. The machines are partitioned into machine classes Mk for k = 0, . . . , r, such that machine class Mk contains r!/k! machines of speed 2k. Also the jobs are partitioned into job classes J(cid:96) for (cid:96) = 1, . . . , r such that a job class J(cid:96) contains r!/((cid:96) − 1)! jobs each having a processing ⊆ (0, 2r+1). Note that the density of this instance is bounded by φ/2r+1 which is valid in the variant of our model that we use in this subsection. The permutation of the jobs is such that list scheduling constructs the schedule σ in the following way: requirement uniformly drawn from(cid:2)2(cid:96), 2(cid:96) + 2r+1/φ(cid:1) for k = 1 to r do for (cid:96) = r down to k do Algorithm 1: 1. 2. 3. 4. 5. end for end for Schedule r!/(cid:96)! arbitrary jobs of class J(cid:96) according to list scheduling. 17 Note that for any job class J(cid:96) all (cid:96) · r!/(cid:96)! = r!/((cid:96) − 1)! jobs have been scheduled. Let σ be the resulting schedule. First, we show a key property of σ. Lemma 19. For any index (cid:96) = 1, . . . , r each machine in M(cid:96) is assigned exactly (cid:96) jobs of job class J(cid:96) and no other jobs. The machines in M0 remain empty. Proof. Let σ(k, (cid:96)) denote the partial schedule after processing line 3 of iteration (k, (cid:96)) of Algorithm 1. Within the (k, (cid:96))th iteration, we call a machine i ∈ M(cid:96) used if a job of class J(cid:96) has already been assigned to i during that iteration. Otherwise, we call machine i unused. We show the two claims below inductively and simultaneously. The lemma then follows straightforwardly from the second claim since the last iteration is (r, r). Claim 1. During iteration (k, (cid:96)), r!/(cid:96)! jobs of class J(cid:96) are assigned to r!/(cid:96)! distinct ma- chines (i.e. all machines) of class M(cid:96). Claim 2. In the partial schedule σ(k, (cid:96)) each machine in class M(cid:96)(cid:48) is assigned (cid:26) (cid:48) k = k min{k − 1, (cid:96)(cid:48) } : : (cid:96)(cid:48) ≥ (cid:96) , (cid:96)(cid:48) < (cid:96) , jobs of class J(cid:96)(cid:48) and no other jobs. Figure 6 visualizes the partial schedule σ(k, (cid:96)). Machine i with speed si = 2i is a representative for all machines in class Mi. With Li we refer to the current load of machine i and with L(cid:48) i to the load of machine i at the end of iteration (k, k), i.e., in the partial schedule σ(k, k). In phase (k, (cid:96)), r!/(cid:96)! jobs of size roughly 2(cid:96) are being assigned to the r!/(cid:96)! machines in M(cid:96). All machines in M(cid:96)(cid:48) for (cid:96)(cid:48) > (cid:96) just received a job of roughly size 2(cid:96)(cid:48) ∈ {k, . . . , (cid:96) − 1} will still receive a single job of size roughly 2(cid:96)(cid:48) during iteration k of the outer loop. Figure 6 follows from the observations. . All machines in M(cid:96)(cid:48) for (cid:96)(cid:48) Figure 6: The partial schedule σ(k, (cid:96)) First, we validate the claims for the first iteration (1, r). As only r!/r! = 1 job of class Jr has to be scheduled and since all machines are still empty, the job will be scheduled on the fastest machine which is the single machine in Mr. Hence, both claims hold true for 18 ≈2r≈2l≈2l−1≈2krll−1kk−1k−210Li≈(k−1)·2i+2i2i=kL0i≈(k−1)·2i+2i2i=kLi≈(k−1)·2i2i=k−1L0i≈(k−1)·2i+2i2i=kLi≈i·2i2i=iL0i≈i·2i2i=i the first iteration. Now, consider an arbitrary iteration (k, (cid:96)) and assume both claims hold true for all previous iterations. Consider a job j ∈ J(cid:96) which needs to be assigned to a machine during iteration (k, (cid:96)). We show that job j will always be assigned to an unused machine i ∈ M(cid:96). To see this, first note that the previous iteration was either (k, (cid:96) + 1) or (k − 1, k − 1). Let i ∈ M(cid:96) be an unused machine. By the second claim, we know that this machine carries k − 1 jobs of class J(cid:96). Consequently, we can upper bound its load by 22r · 2r+1−(cid:96) ≤ k + φ · 2r+1−(cid:96) ≤ k + k · (2(cid:96) + 2r+1/φ) 1 2r , = k + Li + 2(cid:96) < k (cid:96) pj si where we used that k ≤ (cid:96), φ ≥ 22r, and (cid:96)/2(cid:96) ≤ 1/2 for all integers (cid:96) ≥ 1. class M(cid:96)(cid:48) for some (cid:96)(cid:48) and thus Consider a machine machine h which is either used (in that case let (cid:96)(cid:48) = (cid:96)) or in ∈ {(cid:96) + 1, . . . , r}. By Claim 2, this machine carries k jobs of class J(cid:96)(cid:48) Lh + pj sh ≥ k · 2(cid:96)(cid:48) 2(cid:96)(cid:48) + 2(cid:96) = k + 2(cid:96)−(cid:96)(cid:48) > k + 1 2r > Li + pj si . carries min{k − 1, (cid:96)(cid:48) } jobs of class J(cid:96)(cid:48) and thus Finally, consider a machine h ∈ M(cid:96)(cid:48) for some (cid:96)(cid:48) = min(cid:8)k − 1, (cid:96) } · 2(cid:96)(cid:48) , 1(cid:9)) + 2max{k−(cid:96)(cid:48),1} (cid:48) ≥ (k − max(cid:8)k − (cid:96) min{k − 1, (cid:96)(cid:48) 2(cid:96)(cid:48) pj sh ≥ Lh + + 2(cid:96) (cid:48)(cid:9) + 2(cid:96)−(cid:96)(cid:48) ≥ k + 1 > Li + pj si , ∈ {1, . . . , (cid:96) − 1}. Again by Claim 2, it where the second inequality follows from (cid:96) ≥ max{k, (cid:96)(cid:48) + 1} and the third inequality follows from 2i − i ≥ 1 for all positive integers i. With this complete case analysis we have shown that job j will be assigned to an unused machine i ∈ M(cid:96). We conclude that during iteration (k, (cid:96)), each of the r!/(cid:96)! jobs to be assigned will be assigned to an unused machine in M(cid:96). Note that M(cid:96) = r!/(cid:96)!, and hence for each job there always exists such an unused machine. The first claim and the second claim follow immediately. Lemma 20. Schedule σ is lex-jump optimal. Proof. It follows from Lemma 19 that the load of any machine i ∈ M(cid:96) can be bounded by (cid:96) ≤ Li ≤ (cid:96) + (cid:96) · 2r+1 2(cid:96)φ ≤ (cid:96) + (cid:96) 2(cid:96) · 2r+1 22r ≤ (cid:96) + 1 2 · 2r+1 22r < (cid:96) + 1 . If a job j assigned to machine i ∈ M(cid:96) would jump to another machine i(cid:48) ∈ M(cid:96)(cid:48), then Li(cid:48) + (cid:48) pj si(cid:48) ≥ (cid:96) + 2(cid:96) 2(cid:96)(cid:48) = (cid:96) − ((cid:96) − (cid:96) (cid:48) ) + 2(cid:96)−(cid:96)(cid:48) ≥ (cid:96) + 1 > Li , where the last inequality follows from 2k − k ≥ 1 for all integers k. Thus, any job would be worse off by jumping to another machine, and hence schedule σ is lex-jump optimal. 19 We conclude this subsection by proving Theorem 18. Proof of Theorem 18. We consider schedule σ constructed above which is both a list sched- ule and a lex-jump optimal schedule. By Lemma 19 the load of the single machine in Mr is at least r. Hence, Cmax(σ) ≥ r. Now, consider a schedule σ(cid:48) in which each machine in M(cid:96) processes a single job from job class J(cid:96)+1, (cid:96) = 0, . . . , r − 1. The single machine in Mr remains empty. Then, the load of any machine i ∈ M(cid:96) with job j assigned to it is bounded as follows: Li = pj/si ≤ (2(cid:96)+1 + 2r+1/φ)/2(cid:96) ≤ 2 + 2r+1/(22r · 21) = 2 + 2 −r < 3 . max(I) ≤ Cmax(I, σ(cid:48)) < 3 and the theorem follows: Cmax(σ)/C∗ Hence, C∗ Ω(r) = Ω(log φ). max(I) ≥ r/3 = 3 Restricted Machines In this section, we provide lower bound examples showing that the worst-case performance guarantees for all variants of the restricted machines are robust against random noise. Our lower bounds are in the order of the worst-case bounds and hold in particular for φ = 2. In our lower bound constructions all processing requirements are chosen uniformly at random from intervals of length 1/2. This means that even with large perturbations the worst-case lower bounds still apply. 3.1 Jump Neighborhood on Restricted Machines (cid:112) Rutten et al. [21] showed that the makespan of a jump optimal schedule is at most a factor m − 3/4 away from the optimal makespan on restricted identical machines. On of 1/2 + restricted related machines they showed that the makespan of a jump optimal schedule (m − 1) · smax + 1/4 away from the makespan of an is not more than a factor of 1/2 + optimal schedule, assuming that smin = 1. They provided two examples showing that the bound on identical machines is tight and the one on related machines is tight up to a constant factor. We show that even on φ-smooth instances these bounds are tight up to a constant factor. As in [21], we construct an example with two job classes and three machine classes. The first machine class consists of only one machine and this machine is the slowest among all machines. The first class of jobs can only be scheduled on machines in the first two classes, whereas the jobs in the second class are allowed on all machines. To construct a bad example, we schedule all jobs in the first class on the slowest machine and use the jobs of the second class to fill the machines in the second machine class so that the schedule will be jump optimal, with high probability. Theorem 21. For every φ ≥ 2 there exists a class of φ-smooth instances I on restricted related machines such that (cid:112) (cid:20) (cid:21) E I∼I max σ∈Jump(I) Cmax(I, σ) C∗ max(I) = Ω (√m · smax) , assuming without loss of generality that smin = 1. 20 Proof. It suffices to show the theorem for φ = 2 and m ≥ 3. W.l.o.g. we assume smin = 1 and set s := smax/smin = smax. Let z > 2 be an arbitrary integer, let (cid:48) m = m − 2 ≥ 1 , (cid:48) k = m(cid:48) s ≤ √m(cid:48) , (cid:114) and k =(cid:6)k (cid:48)(cid:7) . In the remainder we assume that √m(cid:48)s ≥ 17. This is possible because we only want to derive an asymptotic bound. We consider the following φ-smooth instance I. The set M of machines is partitioned into three classes M1, M2, and M3 such that M1 = 1 , − k The machine in M1 has speed 1, the machines in M2 have speed M2 = k , (cid:48) and M3 = m (cid:48) − (k − 1) > m (cid:48) ≥ 0 . (cid:26) (cid:27) (cid:48) s = max k(cid:48) k 1, s · ∈ [1, s] , and the machines in M3 have speed s. Let the set J of jobs be partitioned into two subsets J1 and J2, consisting of J1 =(cid:4)2zsk (cid:48)(cid:5) and J2 =(cid:6)32zs · (m (cid:48) − k ≤ (cid:100)32zs · M3(cid:101) )(cid:7) (cid:48) jobs whose processing requirements are independently and uniformly drawn from [1/2, 1] and from [0, 1/2], respectively. The jobs in J1 are only allowed to be scheduled on the machines in M1 ∪ M2, whereas the jobs in J2 are allowed to be scheduled on any machine. First, we construct a schedule σ(cid:48) to bound the optimal makespan: Use the list schedul- ing algorithm to schedule all jobs in J1 on the machines in M2, and all jobs in J2 on the machines in M3. Figure 7 depicts schedule σ(cid:48). Machine i is a representative for all machines in class Mi. Figure 7: Schedule σ(cid:48) (cid:80) Li ≤ Along the same lines as in [12], it follows that for all machines i ∈ M2 pj j∈J1 M2 + max j∈J1 s(cid:48) pj J1·1 M2 + 1 s(cid:48) ≤ 2zsk(cid:48) k + 1 s(cid:48) ≤ ≤ 21 k 2zsk(cid:48) s · k(cid:48) k + 1 1 = 2z + 1 . .2zsk0ks2≥s·k0k.32zs·M3·12M3s3=ss1=1J1J2 Similarly, for all machines i ∈ M3 (cid:80) pj j∈J2 M3 + max j∈J2 pj s ≤ J2· 1 M3 + 1 2 2 s 32zs·M3 2·M3 + 1 s ≤ ≤ 16z + 1 . Li ≤ Hence, C∗ (cid:48) s ≤ 2s · k /k optimal schedule σ, we observe that max ≤ Cmax(σ(cid:48)) ≤ 17z. Before we proceed with constructing a 'bad' jump (cid:48) (8) due to 1 ≤ (√m(cid:48) + 1)/k ≤ 2√m(cid:48)s/k = 2s · k(cid:48)/k. We construct a jump optimal schedule σ on the φ-smooth instance I such that the corresponding makespan exceeds zsk(cid:48) with high probability: Schedule all jobs in J1 on the − 1 ≤ L1 ≤ 2zsk(cid:48). Next, start assigning jobs from J2 single machine in M1. Then, zsk(cid:48) to the machines in M2 according to the list scheduling algorithm with an arbitrary job permutation, until (cid:2)L1 − 1 (a) either J2 becomes empty, or until (b) Li ∈ (cid:1) for all i ∈ M2. If there remain unscheduled jobs in J2, then we (cid:18) 2s(cid:48) , L1 pj and let E denote the event that Q > 4z(sk(cid:48))2. If E occurs, then assign them to the machines in M3 using list scheduling. Let Q =(cid:80) (cid:88) (cid:19) j∈J2 (cid:48) (cid:48) s i∈M2 · L1 ≤ M2 · 2s · k(cid:48) k (cid:48) · 2zsk = 4z(sk )2 < Q due to Inequality (8), i.e., the algorithm will end up in case (b) as pj ≤ 1/2 for any job j ∈ J2. This shows that no machine i ∈ M2 is critical. Using the same argument as for the analysis of σ(cid:48) we can show that the load of any machine i ∈ M3 is bounded from above by 16z + 1 < 17z − 1 ≤ z · √m(cid:48) − 1 ≤ L1, i.e., the machine in M1 is the unique critical machine. As each job on this machine has processing requirement at least 1/2 and due to the property of the loads of the machines in M2 in case (b), schedule σ is jump optimal and Cmax(σ) = L1 ≥ zsk(cid:48) · s − 1 = zsk(cid:48) − 1. It remains to determine the probability Pr[E]. For this, note that as √m(cid:48)s ≥ 17 by our initial assumption. On the other hand, 4z(sk(cid:48))2 = 4zsm(cid:48). Applying Hoeffding's Inequality [16] (see also Theorem 31), we obtain (cid:18) · 1 − (cid:19) k(cid:48) m(cid:48) E[Q] = J2 4 ≥ 8zs · (m (cid:18) (cid:48) = 8zsm (cid:48) (cid:48) (cid:19) − k 1 (cid:48) ) = 8zsm (cid:48) > 6zsm Pr(cid:2) ¯E · 1 − √m(cid:48)s ≤ Pr(cid:2)Q − E[Q] ≤ −2zsm (cid:48)(cid:3) (cid:3) = Pr(cid:2)Q ≤ 4zsm (cid:48)(cid:3) (cid:33) (cid:19) (cid:1)2 (cid:0) 1 2 · (2zsm(cid:48))2 J2 · 32z2s2m(cid:48)2 32zsm(cid:48) + 1 ≤ exp ≤ exp (cid:32) (cid:18) − − 2 , 22 which becomes arbitrarily close to 0 when z increases. Hence, for sufficiently large inte- gers z E I∼I max σ∈Jump(I) Cmax(I, σ) C∗ max(I) (cid:20) ≥ E I∼I zsk(cid:48) 17z ≥ max σ∈Jump(I) − 1 17 18 ≥ · (cid:112) Cmax(I, σ) · Pr I∼I [E] C∗ max(I) (m − 2) · smax − 1 z . (cid:21) (cid:12)(cid:12)(cid:12)(cid:12)E 18 Corollary 22. For every φ ≥ 2 there exists a class of φ-smooth instances I on restricted identical machines such that (cid:21) (cid:21) (cid:20) (cid:20) (cid:20) E I∼I max σ∈Jump(I) Cmax(I, σ) C∗ max(I) = Ω(√m) . Remark. In the proof of Theorem 21 we introduce an arbitrary integer z. We argue that there exists a sufficiently large value for z such that the desired result follows. Choosing an even larger value for z implies that the results above not only hold in expectation but also with high probability. 3.2 Lex-jump Optimal Schedules on Restricted Identical Machines In this subsection, we show that there exist instances with φ ≥ 8 such that the smoothed performance guarantee for lex-jump optimal schedules in the restricted setting is in the same order as the worst case performance guarantee. As in Section 2.3, we construct an instance with several job classes and machine classes and the loads of the machines are gradually decreasing with increasing machine class. By setting the sets Mj of allowed machines equal to the union of only one or two machine classes and choosing to schedule the jobs on the wrong machines, we can enforce that jobs cannot leave the machine class on which they are scheduled in the lex-jump optimal solution, whereas the optimal makespan is still small. Theorem 23. For every φ ≥ 8 there exists a class of φ-smooth instances I on restricted identical machines such that E I∼I max σ∈Lex(I) Cmax(I, σ) C∗ max(I) = Ω (cid:21) (cid:18) log m log log m (cid:19) . First, we introduce the φ-smooth instance I for φ ≥ 8. Given an integer k ≥ 68, consider the following recurrence formula: a0 = k2 , a1 = k3 , and ah = (cid:24)(cid:18) ah−1 (cid:19) (cid:25) ah−2 − 7 15 · ah−1 for h ≥ 2 . Starting with a1/a0 = k, the fraction ah/ah−1 decreases with increasing index h until it is less or equal 1. To see this, note that ah/ah−1 ≥ 1 implies that ah−1 ≥ ah−2. Therefore, we know that ah ≥ ah−1 ≥ . . . ≥ a0 = k2 > 15. Furthermore, we can bound the ratio ah/ah−1 from above by ah/ah−1 ≤ ah−1/ah−2 − 7/15 + 1/ah−1 < ah−1/ah−2 − 6/15 < ah−1/ah−2. Let zk be the smallest integer h such that ah/ah−1 ≤ 1. Hence, a0, a1, . . . , azk−1 is a strictly increasing sequence. We will bound the number zk from above later in the analysis. 23 h and J B We consider zk job classes J1, . . . ,Jzk and as many machine classes M1, . . . , Mzk . Each machine class Mh contains mh = ah−1 machines with speed 1. Each job class Jh consists of two subclasses J A h of size ah and of size bh = 17mh, respectively. The jobs in class J A h are called type A jobs, have processing requirements independently and uniformly distributed in [7/8, 1], and can be processed on machines in Mh ∪ Mh+1. As a convention let Mzk+1 = ∅. Jobs in class J B h are called type B jobs, have processing requirements independently and uniformly distributed in [0, 1/8], and can only be processed on machines in Mh. The schedule σ = σ(I) for an instance I ∈ I is obtained by scheduling the jobs in Jh on the machines in Mh using LPT (longest processing time) scheduling, i.e., list scheduling with a list in which the jobs are ordered according to non-increasing processing requirements. Note that the LPT algorithm first schedules all type A jobs and then all type B jobs. Schedule σ(I) is visualized in Figure 8. Machine h represents all machines in class Mh. Figure 8: Schedule σ(I) h =(cid:80) (cid:3)(cid:12)(cid:12) ≤ j∈J A h h and E B mh 32 , h =(cid:80) respectively . We show that schedule σ is lex-jump optimal with high probability. To be more specific, pj are we show lex-jump optimality when the values QA close to their expectations for all h = 1, . . . , zk. Let E A pj and QB h denote the events that j∈J B h (cid:12)(cid:12)QA h − E(cid:2)QA h (cid:3)(cid:12)(cid:12) ≤ mh 16 and (cid:12)(cid:12)QB h − E(cid:2)QB h Moreover, let E denote the event that the events E A all h = 1, . . . , zk. By ¯E A machine and job classes and for the number m of machines. h , and ¯E we refer to the complement of E A h and E B h , ¯E B First, we analyze the sequence a0, a1, . . . , azk to obtain bounds for the number zk of h are simultaneously true for h , E B h , and E. Lemma 24. For any h = 1, . . . , zk the following inequality holds: Proof. The claim is true for h = 1. By definition of ah, ah ah−1 ≤ k − (h − 1) · 2 5 . (cid:16) ah−1 (cid:17) ah ah−1 ≤ ah−2 − 7 · ah−1 + 1 15 ah−1 ah−1 ah−2 − 6 15 ≤ = ah−1 ah−2 − 2 5 24 12zkJ1JzkJ2≈1516a1a0+1716≥1516k≈1516a2a1+1716≈1516azkazk−1+1716 for any h = 2, . . . , zk as ah−1 ≥ a0 = k2 ≥ 15. The claim follows by induction. Now, we can bound the number zk of job classes. Corollary 25. The number zk of machine classes and job classes is bounded by 5k/2. Proof. Applying Lemma 24 for h = zk − 1 we obtain azk−1 azk−2 ≤ k − (zk − 2) · 2 5 . 1 < Hence, zk < (k − 1) · 5 2 + 2 < 5k 2 . Lemma 26. The number m of machines is bounded by Γ(k(cid:48) + 3) where Γ denotes the gamma function and where k(cid:48) = (cid:100)5k/2(cid:101). Proof. By induction we show that (cid:18) 2 (cid:19)h ah ≤ k2 · 5 · (k(cid:48) k(cid:48)! − h)! for any h = 0, . . . , zk − 1. Note that zk ≤ 5k/2 ≤ k(cid:48) due to Corollary 25. For h = 0 the claim holds since a0 = k2. For h ≥ 1 we apply Lemma 24 to get ah ah−1 ≤ k − (h − 1) · 2 5 ≤ (cid:48) 2 5 · (k − (h − 1)) . The induction hypothesis for ah−1 yields (cid:18) 2 (cid:19)h−1 k(cid:48)! (cid:18) 2 (cid:19)h k(cid:48)! − h)! . (k(cid:48) ah ≤ · Recalling mh = ah−1 we can bound the number m of machines by using − (h − 1))! (k(cid:48) 5 5 · = k2 · (cid:48) 2 5 · (k zk(cid:88) h=1 − (h − 1)) · k2 · zk−1(cid:88) zk−1(cid:88) ah k2 ≤ h=0 h=0 m k2 = mh k2 = k(cid:48)! − h)! ≤ k (cid:48) (k(cid:48) ! · e . Hence, m ≤ e · k2 · k(cid:48)! ≤ (k(cid:48) + 2)! = Γ(k(cid:48) + 3). Lemma 27. Event ¯E occurs with probability at most 10k · exp(−k/2). h and ¯E B Proof. We bound the probability for the events ¯E A (cid:32) 2(cid:0) mh (cid:1)2 ah−1 ≥ a0 = k2, ah ≤ k · ah−1 (see Lemma 24), bh = 17mh, and k ≥ 68 we obtain (cid:1)2 (cid:0) 1 (cid:17) (cid:104)(cid:12)(cid:12)(cid:12)QA (cid:18) h − E[QA h ] Pr(cid:2) ¯E A (cid:3) = Pr (cid:12)(cid:12)(cid:12) > ≤ 2 exp mh 16 (cid:33) (cid:19) (cid:18) (cid:19) ah · (cid:16) (cid:105) 16 h 8 = 2 exp ah−1 ah · − ah−1 2 ≤ 2 exp − ≤ 2 exp k 2 − − ah−1 2k h to occur. Recalling mh = 25 and Pr(cid:2) ¯E B h (cid:3) = Pr (cid:104)(cid:12)(cid:12)(cid:12)QB (cid:18) h − E[QB h ] (cid:12)(cid:12)(cid:12) > mh 17mh · ah−1 8 (cid:32) (cid:105) mh 32 (cid:19) ≤ 2 exp (cid:18) 2(cid:0) mh (cid:1)2 (cid:0) 1 (cid:1)2 (cid:19) bh · 32 8 (cid:33) (cid:18) ≤ 2 exp − ≤ 2 exp − (cid:19) . k 2 = 2 exp − − k2 136 (cid:19) h=1 (cid:21) (cid:20) log log m (cid:18) (cid:19) (cid:18) k 2 − k 2 − (cid:1)(cid:35) h ∪ ¯E B h · Pr I∼I [E] , ≥ E I∼I max σ∈Lex(I) (cid:0) ¯E A E I∼I max σ∈Lex(I) (cid:21) (cid:12)(cid:12)(cid:12)(cid:12)E (cid:34) zk(cid:91) ≤ 10k · exp due to Corollary 25. ≤ 2zk · 2 exp Cmax(I, σ) C∗ max(I) Cmax(I, σ) C∗ max(I) (cid:3) = Pr As event E occurs with high probability and as Lemma 28. The loads of the machines within the same class differ only slightly. Each of the first inequalities stems from Hoeffding's bound [16] (see also Theorem 31). A union bound yields to prove Theorem 23 it suffices to bound the expected value conditioned on event E by Pr(cid:2) ¯E (cid:20) (cid:1). Therefore, in the remainder of this section we assume that event E happens. Ω(cid:0) log m particular, Li − Li(cid:48) ≤ 1/8 for any machines i, i(cid:48) Proof. Suppose to the contrary that there exist two machines i, i(cid:48) ∈ Mh such that Li−Li(cid:48) > 1/8. Recall that according to the LPT rule all type A jobs will be assigned to the machines before the type B jobs are assigned. After all type A jobs have been assigned to the machines in Mh, the difference in load between any two machines in Mh is at most 1 since pj ≤ 1 for all jobs j. Since the processing time of all type B jobs is bounded by 1/8, Li − Li(cid:48) > 1/8 implies that no type B job is assigned to machine i nor to any machine that has load at least Li. Hence, all type B jobs are assigned to the machines that have load less than Li. Note that there are at most mh − 1 such machines. As the difference in load between machine i and any other machine in Mh is at most 1, the total amount of processing requirements of type B jobs in class Mh is bounded by QB h ≤ (mh − 1) · 1 < 17mh/16 − mh/32 = E[QB h ] − mh/32 contradicting the assumption that event E B Lemma 29. For any machine i ∈ Mh the inequality ∈ Mh. h holds. In (cid:12)(cid:12)(cid:12)(cid:12)Li − 1 mh (cid:18) E(cid:2)QA h (cid:3) + E(cid:2)QB h (cid:3)(cid:19)(cid:12)(cid:12)(cid:12)(cid:12) ≤ 7 32 holds, i.e., the load of machine i is close to the expected average machine load in class Mh. 26 Proof. By applying the triangle inequality we obtain (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Li − E(cid:2)QA (cid:3) + E(cid:2)QB (cid:3) h h mh (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ ≤ (cid:12)(cid:12)(cid:12)(cid:12)Li − (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Li − (cid:12)(cid:12)(cid:12)(cid:12) + (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) + QA h + QB h mh (cid:80) Li(cid:48) i(cid:48)∈Mh Mh (cid:12)(cid:12)(cid:12)(cid:12)QA h − E(cid:2)QA h (cid:3)(cid:12)(cid:12)(cid:12)(cid:12) mh + (cid:12)(cid:12)(cid:12)(cid:12)QB h − E(cid:2)QB h (cid:3)(cid:12)(cid:12)(cid:12)(cid:12) mh 1 16 + 1 32 ≤ 7 32 , where the second inequality holds since E A Lemma 28. h and E B h are true. The last inequality is due to Lemma 30. Schedule σ is lex-jump optimal. Proof. We need to show that Li(cid:48) + pj ≥ Li holds for any machine i ∈ Mh, any job j ∈ Ji, and any machine i(cid:48) ∈ Mj. Let i ∈ Mh be an arbitrary machine. First, consider the last job j that has been assigned to i. Then, Li(cid:48) + pj ≥ Li for any machine i(cid:48) ∈ Mh as this job was assigned to machine i by list scheduling. Furthermore, job j is a smallest job on machine i due to the LPT rule. Hence, Li(cid:48) + pj(cid:48) ≥ Li for any machine i(cid:48) ∈ Mh and any job j(cid:48) For type B jobs on machine i the set of allowed machines equals Mh. It just remains to show that Li(cid:48) + pj ≥ Li for any machine i(cid:48) ∈ Mh+1 and any type A job j ∈ Ji with i ∈ Mh. Recalling ah = (cid:100)(ah−1/ah−2) − 7/15) · ah−1(cid:101) for h ≥ 2, mh = ah−1, and bh/mh = 17 we observe that ∈ Ji assigned to machine i. + 1 16 · bh+1 mh+1 15 16 · 1 16 · ah+1 ah bh mh + = (cid:19) (cid:3) 7 16 − for any h = 1, . . . , zk − 1. This implies E(cid:2)QA (cid:3) + E(cid:2)QB h+1 h+1 (cid:3) mh+1 h h 15 = = ≥ mh 7 15 16 bh+1 15 16 · ah−1 − 16 ah+1 + 1 mh+1 (cid:18) ah E(cid:2)QA (cid:3) + E(cid:2)QB (cid:3) + E(cid:2)QB (cid:3) (cid:3) + E(cid:2)QB (cid:3) (cid:3) (cid:3) + E(cid:2)QB mh+1 21 32 7 16 7 32 mh − h+1 + h h + 7 8 − + 7 32 ≥ Li , mh h+1 E(cid:2)QA E(cid:2)QA E(cid:2)QA h h Li(cid:48) + pj ≥ ≥ = where the first and the last inequality are due to Lemma 29. Finally, we can prove Theorem 23. 27 Proof of Theorem 23. As mentioned before, due to Lemma 27 it suffices to bound the expected value conditioned on event E. If event E holds, then schedule σ = σ(I) is lex- jump optimal (see Lemma 30), i.e., σ ∈ Lex(I), and has makespan QA 1 + QB 1 Li ≥ Cmax ≥ max i∈M1 m1 15 16 k3 + 1 16 · 17k2 k2 − = ≥ 3 32 ≥ m1 15 16 k , E[QA 1 ] + E[QB 1 ] m1 16 + m1 32 m1 − where the third inequality is due to the occurrence of E A following schedule σ(cid:48): 1 and E B 1 . Now, consider the • For h = 1, . . . , zk − 1 spread the jobs of class J A h evenly among the machines in h = ah = mh+1 = Mh+1, each machine is assigned exactly one class Mh+1. As J A type A job. • Spread the jobs of class J A zk evenly among the machines in class Mzk . As J A azk ≤ azk−1 = mzk = Mzk, each machine is assigned at most one type A job. zk = • For h = 1, . . . , zk spread the jobs of class J B As J B h = 17mh = 17 · Mh, each machine is assigned exactly 17 type B jobs. h evenly among the machines in class Mh. Note that with 'evenly' we refer to the number of jobs on each machine and not to the load. Figure 9 shows schedule σ(cid:48) where each machine h is a representative for all machines in class Mh. Figure 9: Schedule σ(cid:48) As each machine contains at most 2 type A jobs and 17 type B jobs, the makespan of max ≥ max is bounded by 2·1+17·1/8 ≤ 5. This implies Cmax(σ)/C∗ schedule σ(cid:48) and hence C∗ 3k/16 = Ω(Γ−1(m)) due to Lemma 26. Hence, (cid:20) E I∼I max σ∈Lex(I) Cmax(I, σ) C∗ max(I) ≥ E I∼I Remark. The worst case upper bound on the performance guarantee for lex-jump optimal schedules on restricted related machines is O i si/sm [21]. As for log log S (cid:21) (cid:12)(cid:12)(cid:12)(cid:12)E (cid:20) Cmax(I, σ(I)) (cid:17) (cid:16) log S C∗ max(I) (cid:12)(cid:12)(cid:12)(cid:12)E (cid:21) (cid:18) log m , where S =(cid:80) = Ω log log m (cid:19) . 28 12zk−1JB1JBzk−1JB2≤178zkJBzk≤1≤1≤1≤1≤178≤178≤178JA2JA1JAzk−1JAzkJAzk−2 identical machines S = m, i.e., each machine has speed 1, the upper bound matches the lower bound of Theorem 23 up to a constant factor and smoothing does also not improve the performance guarantee for the worst lex-jump optimal schedules on restricted related machines. Lemma 27 established that E occurs with high probability. Hence, if we choose k suitably large, the stated results not only hold in expectation, but also with high probability. 4 Concluding Remarks We have proven that the lower bounds for all scheduling variants with restricted ma- chines are rather robust against random noise, not only in expectation but even with high probability. We have also shown that the situation looks much better for unrestricted machines where we obtained performance guarantees of Θ(φ) and Θ(log φ) for the jump and lex-jump algorithm, respectively. The latter bound also holds for the price of anarchy of routing on parallel links and for the list scheduling algorithm, even when the order in which the jobs are presented to the algorithm can be chosen by the adversary when the realization of the processing times are known. There are several interesting directions of research and we view our results only as a first step towards fully understanding local search and greedy algorithms in the framework of smoothed analysis. For example, we have only perturbed the processing requirements, and it might be the case that the worst-case bounds for the restricted scheduling variants break down if also the sets Mj are to some degree random. In general it would be interesting to study different perturbation models where the sets Mj and/or the speeds si are perturbed. Lemma 15 and Corollary 17 indicate that there need to exist many machines having exponentially small speeds. We conjecture that if speeds are being smoothed, then the smoothed performance guarantee of near list schedules on restricted related machines is Θ(log φ) as well. Another interesting question is the following: since we do not know which local opti- mum is reached, we have always looked at the worst local optimum. It might, however, be the case that the local optima reached in practice are better than the worst local op- timum. It would be interesting to study the quality of the local optimum reached under some reasonable assumptions on how exactly the local search algorithms work. An exten- sion in this direction would be to analyze the quality of coordination mechanisms under smoothing. Acknowledgments We thank three anonymous referees for their valuable comments and suggestions that helped to improve the writing of the paper. References [1] E. Angel. A survey of approximation results for local search algorithms. In E. Bampis, K. Jansen, and C. Kenyon, editors, Efficient Approximation and Online Algorithms, 29 volume 3484 of LNCS, pages 30 -- 73. Springer-Verlag, Heidelberg, Germany, 2006. [2] J. Aspnes, Y. Azar, A. Fiat, S. A. Plotkin, and O. Waarts. On-line routing of virtual circuits with applications to load balancing and machine scheduling. Journal of the ACM, 44(3):486 -- 504, 1997. [3] B. Awerbuch, Y. Azar, Y. Richter, and D. Tsur. Tradeoffs in worst-case equilibria. Theoretical Computer Science, 361:200 -- 209, 2006. [4] L. Becchetti, S. Leonardi, A. Marchetti-Spaccamela, G. Schafer, and T. Vredeveld. Average case and smoothed competitive analysis for the multi-level feedback algo- rithm. Mathematics of Operations Research, 31(3):85 -- 108, 2006. [5] R. Beier and B. Vocking. Random knapsack in expected polynomial time. Journal of Computer and System Sciences, 69(3):306 -- 329, 2004. [6] Y. Cho and S. Sahni. Bounds for list schedules on uniform processors. SIAM Journal on Computing, 9:91 -- 103, 1980. [7] A. Czumaj and B. Vocking. Tight bounds for worst-case equilibria. Transactions on Algorithms ACM, 3(1), 2007. [8] M. Englert, H. Roglin, and B. Vocking. Worst case and probabilistic analysis of the 2-opt algorithm for the TSP. In Proceedings of the 18th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1295 -- 13004, 2007. [9] G. Finn and E. Horowitz. A linear time approximation algorithm for multiprocessor scheduling. BIT, 19:312 -- 320, 1979. [10] M. R. Garey and D. S. Johnson. Computers and Intractibility: A Guide to the Theory of NP-Completeness. W.H. Freeman & Co., New York, NY, 1979. [11] C. A. Glass and H. Kellerer. Parallel machine scheduling with job assignment restric- tions. Naval Research Logistics, 54(3):250 -- 257, 2007. [12] R. L. Graham. Bounds for certain multiprocessing anomalies. Bell System Technical Journal, 45:1563 -- 1581, 1966. [13] R. L. Graham, E. L. Lawler, J. K. Lenstra, and A. H. G. Rinnooy Kan. Optimization and approximation in deterministic sequencing and scheduling: a survey. Annals of Discrete Mathematics, 5:287 -- 326, 1979. [14] D. S. Hochbaum and D. B. Shmoys. A polynomial approximation scheme for machine scheduling on uniform processors: using the dual approximation approach. SIAM Journal on Computing, 17:539 -- 551, 1988. [15] M. Hoefer and A. Souza. Tradeoffs and average-case equilibria in selfish routing. ACM Transactions on Computation Theory, 2(1):article 2, 2010. [16] W. Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58(301):13 -- 30, 1963. 30 [17] J. Y. T. Leung and C. L. Li. Scheduling with processing set restrictions: A survey. International Journal of Production Economics, 116:251 -- 262, 2008. [18] C. L. Li. Scheduling unit-length jobs with machine eligibility restrictions. European Journal of Operational Research, 174:1325 -- 1328, 2006. [19] W. P. A. J. Michiels, E. H. L. Aarts, and J. H. M. Korst. Theoretical Aspects of Local Search. Springer-Verlag, Heidelberg, Germany, 2007. [20] J. Ou, J. Y.-T. Leung, and C. L. Li. Scheduling parallel machines with inclusive set restrictions. Naval Research Logistics, 55(4):328 -- 338, 2008. [21] C. Rutten, D. Recalde, P. Schuurman, and T. Vredeveld. Performance guarantees of jump neighborhoods on restricted related parallel machines. Operations Research Letters, 40:287 -- 291, 2012. [22] G. Schafer and N. Sivadasan. Topology matters: Smoothed competitiveness of met- rical task systems. Theoretical Computer Science, 341(1 -- 3):3 -- 14, 2005. [23] P. Schuurman and T. Vredeveld. Performance guarantees of local search for multi- processor scheduling. Informs Journal on Computing, 19(1):52 -- 63, 2007. [24] D. A. Spielman and S. H. Teng. Smoothed analysis of algorithms: Why the simplex algorithm usually takes polynomial time. Journal of the ACM, 51(3):385 -- 463, 2004. [25] D. A. Spielman and S. H. Teng. Smoothed analysis: an attempt to explain the behavior of algorithms in practice. Communications of the ACM, 52(10):76 -- 84, 2009. [26] B. Vocking. Selfish load balancing. In N. Nisan, T. Roughgarden, E. Tardos, and V. Vazirani, editors, Algorithmic Game Theory, chapter 20. Cambridge University Press, New York, NY, USA, 2007. 31 A Table of notation In the table below, the notation used in this paper is summarized. set of jobs 1, . . . , n J set of machines 1, . . . , m M processing requirement of job j pj speed of machine i si Mj set of machines on which job j can be scheduled smax maximum speed of the machines smin = 1 minimum speed of the machines; C∗ Cmax(σ) makespan of schedule σ Ji(σ) Li(σ) by scaling we assume w.l.o.g. it to be 1. optimal makespan set of jobs scheduling on machine i in schedule σ =(cid:80) j∈Ji(σ) pj/si max (σ) (cid:96)∈Ji,j (σ) p(cid:96)/si ≥ t · C∗ load of machine i in schedule σ. = Ji(σ) ∩ {1, . . . , j} Ji,j(σ) jt = min i Ji,≥t(σ) = Ji,jt c C∗ ik (cid:110) j : (cid:80) (cid:107) (cid:106) Cmax(σ) = max{i ∈ M : Li(cid:48) ≥ k · C∗ assuming s1 ≥ s2 ≥ . . . ≥ sm = {1, . . . , ik} = Hk \ Hk+1 for k = 0, 1, . . . , c − 1 = Hc. max ∀ i(cid:48) Hk Rk Rc − 1 = i max (cid:111) max ≤ i}, B Hoeffding's bound On several occasions in this paper we use Hoeffding's bound [16] to bound tail probabilities. For completeness, we state the bound in the following theorem. Theorem 31. Let X1, . . . , Xn be independent random variables. Define X :=(cid:80)n j=1 Xj and µ = E[X]. If each Xj ∈ [aj, bj] for some constants aj and bj, j = 1, . . . , n, then for any t > 0 Pr [X ≤ E[X] − t] ≤ exp Pr [X ≥ E[X] + t] ≤ exp j(bj − aj)2 −2t −2t j(bj − aj)2 and, , . (cid:32) (cid:32) (cid:80) (cid:80) (cid:33) (cid:33) 32